@vnejs/bridge.plugins.views.scenario.interface.plugins.text.smooth 0.0.0-stage → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/modules/bridge_plugin_interface_plugin_text_smooth.d.ts +9 -0
- package/dist/modules/bridge_plugin_interface_plugin_text_smooth.js +11 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/package.json +39 -4
- package/src/index.ts +11 -0
- package/src/modules/bridge_plugin_interface_plugin_text_smooth.ts +19 -0
- package/src/tests/setup.ts +27 -0
- package/src/tests/text.smooth.test.ts +36 -0
- package/src/types.ts +11 -0
- package/tsconfig.json +9 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "@vnejs/contracts.text";
|
|
2
|
+
import "@vnejs/contracts.text.smooth";
|
|
3
|
+
import "@vnejs/contracts.views.scenario.interface";
|
|
4
|
+
import { regPlugin } from "@vnejs/registry";
|
|
5
|
+
import { BridgePluginInterfacePluginTextSmooth } from "./modules/bridge_plugin_interface_plugin_text_smooth.js";
|
|
6
|
+
const PLUGIN_NAME = "BRIDGE_PLUGIN_INTERFACE_PLUGIN_TEXT_SMOOTH";
|
|
7
|
+
regPlugin(PLUGIN_NAME, {}, [BridgePluginInterfacePluginTextSmooth]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { TextSmoothChangedPayload } from "@vnejs/contracts.text.smooth";
|
|
3
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "../types.js";
|
|
4
|
+
export declare class BridgePluginInterfacePluginTextSmooth extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
subscribe: () => void;
|
|
7
|
+
start: () => void;
|
|
8
|
+
onTextSmoothChanged: ({ tokensVisible, uid }?: TextSmoothChangedPayload) => Promise<import("@vnejs/registry").EmitResults<"vne:interface:text_changed">> | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
export class BridgePluginInterfacePluginTextSmooth extends ModuleCore {
|
|
3
|
+
name = "bridge_plugin_interface_plugin_text_smooth";
|
|
4
|
+
subscribe = () => {
|
|
5
|
+
this.on(this.EVENTS.TEXT_SMOOTH.CHANGED, this.onTextSmoothChanged);
|
|
6
|
+
};
|
|
7
|
+
start = () => {
|
|
8
|
+
this.shared.interfaceTextShowAllTokensOnChange = false;
|
|
9
|
+
};
|
|
10
|
+
onTextSmoothChanged = ({ tokensVisible = 0, uid = "" } = {}) => this.emit(this.EVENTS.INTERFACE.TEXT_CHANGED, { tokens: this.globalState.text.tokens, tokensVisible, uid });
|
|
11
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { PluginName as InterfacePluginName, SubscribeEvents as InterfaceSubscribeEvents } from "@vnejs/contracts.views.scenario.interface";
|
|
3
|
+
import type { PluginName as TextSmoothPluginName, SubscribeEvents as TextSmoothSubscribeEvents } from "@vnejs/contracts.text.smooth";
|
|
4
|
+
export type PluginEvents = ModuleCoreEvents & Record<TextSmoothPluginName, TextSmoothSubscribeEvents> & Record<InterfacePluginName, InterfaceSubscribeEvents>;
|
|
5
|
+
export type PluginConstants = ModuleCoreConstants;
|
|
6
|
+
export type PluginSettings = ModuleCoreSettings;
|
|
7
|
+
export type PluginParams = ModuleCoreParams;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/bridge.plugins.views.scenario.interface.plugins.text.smooth",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.8",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "npx @vnejs/monorepo test",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
23
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
24
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
25
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
26
|
+
},
|
|
27
|
+
"author": "",
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@vnejs/module.core": "~0.2.0",
|
|
31
|
+
"@vnejs/contracts.text": "~0.2.0",
|
|
32
|
+
"@vnejs/contracts.text.smooth": "~0.2.0",
|
|
33
|
+
"@vnejs/contracts.views.scenario.interface": "~0.2.0",
|
|
34
|
+
"@vnejs/registry": "~0.2.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
38
|
+
"@vnejs/configs.vitest": "~0.2.0",
|
|
39
|
+
"@vnejs/test-utils": "~0.2.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "@vnejs/contracts.text";
|
|
2
|
+
import "@vnejs/contracts.text.smooth";
|
|
3
|
+
import "@vnejs/contracts.views.scenario.interface";
|
|
4
|
+
|
|
5
|
+
import { regPlugin } from "@vnejs/registry";
|
|
6
|
+
|
|
7
|
+
import { BridgePluginInterfacePluginTextSmooth } from "./modules/bridge_plugin_interface_plugin_text_smooth.js";
|
|
8
|
+
|
|
9
|
+
const PLUGIN_NAME = "BRIDGE_PLUGIN_INTERFACE_PLUGIN_TEXT_SMOOTH";
|
|
10
|
+
|
|
11
|
+
regPlugin(PLUGIN_NAME, {}, [BridgePluginInterfacePluginTextSmooth]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { TextSmoothChangedPayload } from "@vnejs/contracts.text.smooth";
|
|
3
|
+
|
|
4
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "../types.js";
|
|
5
|
+
|
|
6
|
+
export class BridgePluginInterfacePluginTextSmooth extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
7
|
+
name = "bridge_plugin_interface_plugin_text_smooth";
|
|
8
|
+
|
|
9
|
+
subscribe = () => {
|
|
10
|
+
this.on(this.EVENTS.TEXT_SMOOTH.CHANGED, this.onTextSmoothChanged);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
start = () => {
|
|
14
|
+
this.shared.interfaceTextShowAllTokensOnChange = false;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
onTextSmoothChanged = ({ tokensVisible = 0, uid = "" }: TextSmoothChangedPayload = {}) =>
|
|
18
|
+
this.emit(this.EVENTS.INTERFACE.TEXT_CHANGED, { tokens: this.globalState.text.tokens, tokensVisible, uid });
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SUBSCRIBE_EVENTS as TEXT_SMOOTH_EVENTS, PLUGIN_NAME as TEXT_SMOOTH } from "@vnejs/contracts.text.smooth";
|
|
2
|
+
import { SUBSCRIBE_EVENTS as INTERFACE_EVENTS, PLUGIN_NAME as INTERFACE } from "@vnejs/contracts.views.scenario.interface";
|
|
3
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
export const registerCompatibilityVne = () => {
|
|
6
|
+
registerCoreVne();
|
|
7
|
+
registerVnePlugin(TEXT_SMOOTH, { events: TEXT_SMOOTH_EVENTS });
|
|
8
|
+
registerVnePlugin(INTERFACE, { events: INTERFACE_EVENTS });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
|
|
12
|
+
ModuleClass: T,
|
|
13
|
+
options: Parameters<typeof baseCreateTestModule>[1] = {},
|
|
14
|
+
) =>
|
|
15
|
+
baseCreateTestModule(ModuleClass, {
|
|
16
|
+
state: {
|
|
17
|
+
text: { tokens: [], uid: "", texts: [], speaker: "" },
|
|
18
|
+
...(options.state ?? {}),
|
|
19
|
+
},
|
|
20
|
+
shared: {
|
|
21
|
+
interfaceTextShowAllTokensOnChange: true,
|
|
22
|
+
...(options.shared ?? {}),
|
|
23
|
+
},
|
|
24
|
+
...options,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export { INTERFACE_EVENTS, TEXT_SMOOTH_EVENTS };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
import { BridgePluginInterfacePluginTextSmooth } from "../modules/bridge_plugin_interface_plugin_text_smooth.js";
|
|
6
|
+
import { createCompatibilityTestModule, INTERFACE_EVENTS, registerCompatibilityVne, TEXT_SMOOTH_EVENTS } from "./setup.js";
|
|
7
|
+
|
|
8
|
+
describe("BridgePluginInterfacePluginTextSmooth", () => {
|
|
9
|
+
beforeEach(() => registerCompatibilityVne());
|
|
10
|
+
|
|
11
|
+
it("start resets interfaceTextShowAllTokensOnChange", async () => {
|
|
12
|
+
const { module, shared } = createCompatibilityTestModule(BridgePluginInterfacePluginTextSmooth, {
|
|
13
|
+
shared: { interfaceTextShowAllTokensOnChange: true },
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await (module as BridgePluginInterfacePluginTextSmooth).start();
|
|
17
|
+
|
|
18
|
+
expect(shared.interfaceTextShowAllTokensOnChange).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("TEXT_SMOOTH.CHANGED forwards tokens to INTERFACE.TEXT_CHANGED", async () => {
|
|
22
|
+
const tokens = [
|
|
23
|
+
{ token: "H", marks: [] },
|
|
24
|
+
{ token: "i", marks: [] },
|
|
25
|
+
];
|
|
26
|
+
const { observer } = createCompatibilityTestModule(BridgePluginInterfacePluginTextSmooth, {
|
|
27
|
+
state: { text: { tokens, uid: "line-1", texts: [], speaker: "" } },
|
|
28
|
+
});
|
|
29
|
+
const changed = spyEvent(observer, INTERFACE_EVENTS.TEXT_CHANGED);
|
|
30
|
+
|
|
31
|
+
await observer.emit(TEXT_SMOOTH_EVENTS.CHANGED, { tokensVisible: 3, uid: "line-1" });
|
|
32
|
+
|
|
33
|
+
expect(changed).toHaveBeenCalledOnce();
|
|
34
|
+
expect(changed).toHaveBeenCalledWith({ tokens, tokensVisible: 3, uid: "line-1" });
|
|
35
|
+
});
|
|
36
|
+
});
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { PluginName as InterfacePluginName, SubscribeEvents as InterfaceSubscribeEvents } from "@vnejs/contracts.views.scenario.interface";
|
|
3
|
+
import type { PluginName as TextSmoothPluginName, SubscribeEvents as TextSmoothSubscribeEvents } from "@vnejs/contracts.text.smooth";
|
|
4
|
+
|
|
5
|
+
export type PluginEvents = ModuleCoreEvents & Record<TextSmoothPluginName, TextSmoothSubscribeEvents> & Record<InterfacePluginName, InterfaceSubscribeEvents>;
|
|
6
|
+
|
|
7
|
+
export type PluginConstants = ModuleCoreConstants;
|
|
8
|
+
|
|
9
|
+
export type PluginSettings = ModuleCoreSettings;
|
|
10
|
+
|
|
11
|
+
export type PluginParams = ModuleCoreParams;
|
package/tsconfig.json
ADDED
package/README.md
DELETED