Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions apps/web/src/components/views/elements/EffectsOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ const EffectsOverlay: FunctionComponent<IProps> = ({ roomWidth }) => {
if (!name) return null;
let effect: ICanvasEffect | null = effectsRef.current.get(name) || null;
if (effect === null) {
const options = CHAT_EFFECTS.find((e) => e.command === name)?.options;
const definition = CHAT_EFFECTS.find((e) => e.command === name)!;
try {
const { default: Effect } = await import(`../../../effects/${name}`);
effect = new Effect(options);
effectsRef.current.set(name, effect!);
effect = await definition.getRenderer();
effectsRef.current.set(name, effect);
} catch (err) {
logger.warn(`Unable to load effect module at '../../../effects/${name}.`, err);
logger.warn(`Unable to run effect module.`, err);
}
}
return effect;
Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/effects/confetti/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ Copyright 2020 Nordeck IT + Consulting GmbH.

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
*/

import type ICanvasEffect from "../ICanvasEffect";

export type ConfettiOptions = {
type ConfettiOptions = {
/**
* max confetti count
*/
Expand Down Expand Up @@ -54,7 +55,7 @@ export const DefaultOptions: ConfettiOptions = {
export default class Confetti implements ICanvasEffect {
private readonly options: ConfettiOptions;

public constructor(options: { [key: string]: any }) {
public constructor(options: Partial<ConfettiOptions>) {
this.options = { ...DefaultOptions, ...options };
}

Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/effects/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
Please see LICENSE files in the repository root for full details.
*/

export type Effect<TOptions extends { [key: string]: any }> = {
import type ICanvasEffect from "./ICanvasEffect.ts";

export type Effect = {
/**
* one or more emojis that will trigger this effect
*/
Expand All @@ -29,7 +31,7 @@
*/
fallbackMessage: () => string;
/**
* animation options
* animation options TODO

Check warning on line 34 in apps/web/src/effects/effect.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=element-web&issues=AZ1E0X_plli-YfopVE-X&open=AZ1E0X_plli-YfopVE-X&pullRequest=33008
*/
options: TOptions;
getRenderer(): Promise<ICanvasEffect>;
};
6 changes: 3 additions & 3 deletions apps/web/src/effects/fireworks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Copyright 2020 Nordeck IT + Consulting GmbH.

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
*/

import type ICanvasEffect from "../ICanvasEffect";

export type FireworksOptions = {
type FireworksOptions = {
/**
* max fireworks count
*/
Expand Down Expand Up @@ -55,7 +55,7 @@ export const DefaultOptions: FireworksOptions = {
export default class Fireworks implements ICanvasEffect {
private readonly options: FireworksOptions;

public constructor(options: { [key: string]: any }) {
public constructor(options: Partial<FireworksOptions>) {
this.options = { ...DefaultOptions, ...options };
}

Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/effects/hearts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ Copyright 2022 Arseny Uskov

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
*/

import type ICanvasEffect from "../ICanvasEffect";
import { arrayFastClone } from "../../utils/arrays";

export type HeartOptions = {
type HeartOptions = {
/**
* The maximum number of hearts to render at a given time
*/
Expand Down Expand Up @@ -51,7 +52,7 @@ const KEY_FRAME_INTERVAL = 15; // 15ms, roughly
export default class Hearts implements ICanvasEffect {
private readonly options: HeartOptions;

public constructor(options: { [key: string]: any }) {
public constructor(options: Partial<HeartOptions>) {
this.options = { ...DefaultOptions, ...options };
}

Expand Down
87 changes: 50 additions & 37 deletions apps/web/src/effects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,88 +5,101 @@ Copyright 2020 Nordeck IT + Consulting GmbH.

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
*/

import { _t, _td } from "../languageHandler";
import { type ConfettiOptions } from "./confetti";
import { type Effect } from "./effect";
import { type FireworksOptions } from "./fireworks";
import { type RainfallOptions } from "./rainfall";
import { type SnowfallOptions } from "./snowfall";
import { type SpaceInvadersOptions } from "./spaceinvaders";
import { type HeartOptions } from "./hearts";
import { type Effect } from "./effect.ts";

/**
* This configuration defines room effects that can be triggered by custom message types and emojis
*/
export const CHAT_EFFECTS: Array<Effect<{ [key: string]: any }>> = [
export const CHAT_EFFECTS: Array<Effect> = [
{
emojis: ["🎊", "🎉"],
msgType: "nic.custom.confetti",
command: "confetti",
description: () => _td("chat_effects|confetti_description"),
fallbackMessage: () => _t("chat_effects|confetti_message") + " 🎉",
options: {
maxCount: 150,
speed: 3,
frameInterval: 15,
alpha: 1.0,
gradient: false,
getRenderer: async () => {
const { default: Effect } = await import("./confetti/index.ts");
return new Effect({
maxCount: 150,
speed: 3,
frameInterval: 15,
alpha: 1.0,
gradient: false,
});
},
} as Effect<ConfettiOptions>,
},
{
emojis: ["🎆"],
msgType: "nic.custom.fireworks",
command: "fireworks",
description: () => _td("chat_effects|fireworks_description"),
fallbackMessage: () => _t("chat_effects|fireworks_message") + " 🎆",
options: {
maxCount: 500,
gravity: 0.05,
getRenderer: async () => {
const { default: Effect } = await import("./fireworks/index.ts");
return new Effect({
maxCount: 500,
gravity: 0.05,
});
},
} as Effect<FireworksOptions>,
},
{
emojis: ["🌧️", "⛈️", "🌦️"],
msgType: "io.element.effect.rainfall",
command: "rainfall",
description: () => _td("chat_effects|rainfall_description"),
fallbackMessage: () => _t("chat_effects|rainfall_message") + " 🌧️",
options: {
maxCount: 600,
speed: 10,
getRenderer: async () => {
const { default: Effect } = await import("./rainfall/index.ts");
return new Effect({
maxCount: 600,
speed: 10,
});
},
} as Effect<RainfallOptions>,
},
{
emojis: ["❄", "🌨"],
msgType: "io.element.effect.snowfall",
command: "snowfall",
description: () => _td("chat_effects|snowfall_description"),
fallbackMessage: () => _t("chat_effects|snowfall_message") + " ❄",
options: {
maxCount: 200,
gravity: 0.05,
maxDrift: 5,
getRenderer: async () => {
const { default: Effect } = await import("./snowfall/index.ts");
return new Effect({
maxCount: 200,
gravity: 0.05,
maxDrift: 5,
});
},
} as Effect<SnowfallOptions>,
},
{
emojis: ["👾", "🌌"],
msgType: "io.element.effects.space_invaders",
command: "spaceinvaders",
description: () => _td("chat_effects|spaceinvaders_description"),
fallbackMessage: () => _t("chat_effects|spaceinvaders_message") + " 👾",
options: {
maxCount: 50,
gravity: 0.01,
getRenderer: async () => {
const { default: Effect } = await import("./spaceinvaders/index.ts");
return new Effect({
maxCount: 50,
gravity: 0.01,
});
},
} as Effect<SpaceInvadersOptions>,
},
{
emojis: ["💝"],
msgType: "io.element.effect.hearts",
command: "hearts",
description: () => _td("chat_effects|hearts_description"),
fallbackMessage: () => _t("chat_effects|hearts_message") + " 💝",
options: {
maxCount: 120,
gravity: 3.2,
getRenderer: async () => {
const { default: Effect } = await import("./hearts/index.ts");
return new Effect({
maxCount: 120,
gravity: 3.2,
});
},
} as Effect<HeartOptions>,
},
];
7 changes: 4 additions & 3 deletions apps/web/src/effects/rainfall/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ Copyright 2021 Josias Allestad

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
*/

import type ICanvasEffect from "../ICanvasEffect";
import { arrayFastClone } from "../../utils/arrays";

export type RainfallOptions = {
type RainfallOptions = {
/**
* The maximum number of raindrops to render at a given time
*/
Expand Down Expand Up @@ -38,7 +39,7 @@ const KEY_FRAME_INTERVAL = 15;
export default class Rainfall implements ICanvasEffect {
private readonly options: RainfallOptions;

public constructor(options: { [key: string]: any }) {
public constructor(options: Partial<RainfallOptions>) {
this.options = { ...DefaultOptions, ...options };
}

Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/effects/snowfall/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Copyright 2020-2023 The Matrix.org Foundation C.I.C.

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
*/

import type ICanvasEffect from "../ICanvasEffect";
import { arrayFastClone } from "../../utils/arrays";

export type SnowfallOptions = {
type SnowfallOptions = {
/**
* The maximum number of snowflakes to render at a given time
*/
Expand Down Expand Up @@ -43,7 +44,7 @@ const KEY_FRAME_INTERVAL = 15; // 15ms, roughly
export default class Snowfall implements ICanvasEffect {
private readonly options: SnowfallOptions;

public constructor(options: { [key: string]: any }) {
public constructor(options: Partial<SnowfallOptions>) {
this.options = { ...DefaultOptions, ...options };
}

Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/effects/spaceinvaders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Copyright 2021-2023 The Matrix.org Foundation C.I.C.

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
*/

import type ICanvasEffect from "../ICanvasEffect";
import { arrayFastClone } from "../../utils/arrays";

export type SpaceInvadersOptions = {
type SpaceInvadersOptions = {
/**
* The maximum number of invaders to render at a given time
*/
Expand Down Expand Up @@ -37,7 +38,7 @@ const GLYPH = "👾";
export default class SpaceInvaders implements ICanvasEffect {
private readonly options: SpaceInvadersOptions;

public constructor(options: { [key: string]: any }) {
public constructor(options: Partial<SpaceInvadersOptions>) {
this.options = { ...DefaultOptions, ...options };
}

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"@element-hq/element-web-playwright-common": "catalog:",
"@nx-tools/nx-container": "^7.2.1",
"@nx/jest": "^22.5.0",
"@types/node": "22",
"@playwright/test": "catalog:",
"@types/node": "22",
"cronstrue": "^3.0.0",
"eslint-plugin-matrix-org": "^3.0.0",
"husky": "^9.0.0",
"knip": "5.87.0",
"knip": "6.1.0",
"lint-staged": "^16.0.0",
"lodash": "^4.17.21",
"mermaid": "^11.13.0",
Expand Down Expand Up @@ -67,9 +67,9 @@
"jest-fixed-jsdom": "patches/jest-fixed-jsdom.patch",
"jsdom": "patches/jsdom.patch",
"rollup": "patches/rollup.patch",
"knip": "patches/knip.patch",
"postcss-mixins": "patches/postcss-mixins.patch",
"app-builder-lib": "patches/app-builder-lib.patch"
"app-builder-lib": "patches/app-builder-lib.patch",
"knip": "patches/knip.patch"
},
"peerDependencyRules": {
"allowedVersions": {
Expand Down
13 changes: 0 additions & 13 deletions patches/knip.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,3 @@ index d451e0ab75c530b794e6925466e18e798b7df960..ca4eeb240ef200fe8996453276451327
...plugins.map(id => toDeferResolve(id)),
...(plugins.includes('@babel/plugin-transform-runtime')
? [toDeferResolve('@babel/runtime', { optional: true })]
diff --git a/dist/typescript/pragmas/custom.js b/dist/typescript/pragmas/custom.js
index 6ab98ae60cf8f07047a0ad7132c11a0da780bfbc..7c8818e81cde7e4ee9c11084d55043441e37208e 100644
--- a/dist/typescript/pragmas/custom.js
+++ b/dist/typescript/pragmas/custom.js
@@ -2,7 +2,7 @@ import { IMPORT_FLAGS } from "../../constants.js";
import { getEnvSpecifier } from "../../plugins/vitest/helpers.js";
import { isAbsolute, isInternal } from "../../util/path.js";
import { getLeadingComments, stripQuotes } from "../ast-helpers.js";
-const VITEST_ENV = /@(vitest|jest)-environment\s+(\S+)/g;
+const VITEST_ENV = /@(vitest)-environment\s+(\S+)/g;
export const collectCustomImports = (sourceFile) => {
const comments = getLeadingComments(sourceFile);
if (!comments.length)
Loading
Loading