@vnejs/bridge.plugins.text.plugins.scenario.autoread 0.0.0-stage → 0.2.7
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 +2 -0
- package/dist/index.js +6 -0
- package/dist/modules/bridge_plugin_text_plugin_autoread.d.ts +10 -0
- package/dist/modules/bridge_plugin_text_plugin_autoread.js +11 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/package.json +43 -4
- package/src/index.ts +9 -0
- package/src/modules/bridge_plugin_text_plugin_autoread.ts +19 -0
- package/src/tests/scenario.autoread.test.ts +32 -0
- package/src/tests/setup.ts +27 -0
- package/src/types.ts +11 -0
- package/tsconfig.json +6 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "@vnejs/contracts.scenario.autoread";
|
|
2
|
+
import "@vnejs/contracts.text";
|
|
3
|
+
import { PLUGIN_NAME } from "@vnejs/contracts.bridge.plugins.text.plugins.scenario.autoread";
|
|
4
|
+
import { regPlugin } from "@vnejs/registry";
|
|
5
|
+
import { BridgePluginTextPluginAutoread } from "./modules/bridge_plugin_text_plugin_autoread.js";
|
|
6
|
+
regPlugin(PLUGIN_NAME, {}, [BridgePluginTextPluginAutoread]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { AutoreadSourcePayload } from "@vnejs/contracts.scenario.autoread";
|
|
3
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "../types.js";
|
|
4
|
+
export declare class BridgePluginTextPluginAutoread extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
sourceArg: AutoreadSourcePayload;
|
|
7
|
+
subscribe: () => void;
|
|
8
|
+
onTextEmit: () => Promise<import("@vnejs/registry").EmitResults<"vne:autoread:push">> | undefined;
|
|
9
|
+
onTextEmitEnd: () => Promise<import("@vnejs/registry").EmitResults<"vne:autoread:pop">> | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
export class BridgePluginTextPluginAutoread extends ModuleCore {
|
|
3
|
+
name = "bridge_plugin_text_plugin_autoread";
|
|
4
|
+
sourceArg = { source: this.CONST.TEXT.SOURCE };
|
|
5
|
+
subscribe = () => {
|
|
6
|
+
this.on(this.EVENTS.TEXT.EMIT, this.onTextEmit);
|
|
7
|
+
this.on(this.EVENTS.TEXT.EMIT_END, this.onTextEmitEnd);
|
|
8
|
+
};
|
|
9
|
+
onTextEmit = () => this.emit(this.EVENTS.AUTOREAD.PUSH, this.sourceArg);
|
|
10
|
+
onTextEmitEnd = () => this.emit(this.EVENTS.AUTOREAD.POP, this.sourceArg);
|
|
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 AutoreadPluginName, SubscribeEvents as AutoreadSubscribeEvents } from "@vnejs/contracts.scenario.autoread";
|
|
3
|
+
import type { Constants as TextConstants, PluginName as TextPluginName, SubscribeEvents as TextSubscribeEvents } from "@vnejs/contracts.text";
|
|
4
|
+
export type PluginEvents = ModuleCoreEvents & Record<TextPluginName, TextSubscribeEvents> & Record<AutoreadPluginName, AutoreadSubscribeEvents>;
|
|
5
|
+
export type PluginConstants = ModuleCoreConstants & Record<TextPluginName, TextConstants>;
|
|
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,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/bridge.plugins.text.plugins.scenario.autoread",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.7",
|
|
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:plugin": "npm run publish:major",
|
|
24
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
25
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
26
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
27
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
28
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@vnejs/module.core": "~0.2.0",
|
|
34
|
+
"@vnejs/contracts.scenario.autoread": "~0.2.0",
|
|
35
|
+
"@vnejs/contracts.text": "~0.2.0",
|
|
36
|
+
"@vnejs/registry": "~0.2.0",
|
|
37
|
+
"@vnejs/contracts.bridge.plugins.text.plugins.scenario.autoread": "~0.2.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
41
|
+
"@vnejs/configs.vitest": "~0.2.0",
|
|
42
|
+
"@vnejs/test-utils": "~0.2.0",
|
|
43
|
+
"@vnejs/contracts.bridge.plugins.text.plugins.scenario.autoread": "~0.2.0"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "@vnejs/contracts.scenario.autoread";
|
|
2
|
+
import "@vnejs/contracts.text";
|
|
3
|
+
|
|
4
|
+
import { PLUGIN_NAME } from "@vnejs/contracts.bridge.plugins.text.plugins.scenario.autoread";
|
|
5
|
+
import { regPlugin } from "@vnejs/registry";
|
|
6
|
+
|
|
7
|
+
import { BridgePluginTextPluginAutoread } from "./modules/bridge_plugin_text_plugin_autoread.js";
|
|
8
|
+
|
|
9
|
+
regPlugin(PLUGIN_NAME, {}, [BridgePluginTextPluginAutoread]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { AutoreadSourcePayload } from "@vnejs/contracts.scenario.autoread";
|
|
3
|
+
|
|
4
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "../types.js";
|
|
5
|
+
|
|
6
|
+
export class BridgePluginTextPluginAutoread extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
7
|
+
name = "bridge_plugin_text_plugin_autoread";
|
|
8
|
+
|
|
9
|
+
sourceArg: AutoreadSourcePayload = { source: this.CONST.TEXT.SOURCE };
|
|
10
|
+
|
|
11
|
+
subscribe = () => {
|
|
12
|
+
this.on(this.EVENTS.TEXT.EMIT, this.onTextEmit);
|
|
13
|
+
this.on(this.EVENTS.TEXT.EMIT_END, this.onTextEmitEnd);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
onTextEmit = () => this.emit(this.EVENTS.AUTOREAD.PUSH, this.sourceArg);
|
|
17
|
+
|
|
18
|
+
onTextEmitEnd = () => this.emit(this.EVENTS.AUTOREAD.POP, this.sourceArg);
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
import { BridgePluginTextPluginAutoread } from "../modules/bridge_plugin_text_plugin_autoread.js";
|
|
6
|
+
import { AUTOREAD_EVENTS, createCompatibilityTestModule, registerCompatibilityVne, TEXT_CONST, TEXT_EVENTS } from "./setup.js";
|
|
7
|
+
|
|
8
|
+
describe("BridgePluginTextPluginAutoread", () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
registerCompatibilityVne();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("TEXT.EMIT emits AUTOREAD.PUSH with text source", async () => {
|
|
14
|
+
const { observer } = createCompatibilityTestModule(BridgePluginTextPluginAutoread);
|
|
15
|
+
const push = spyEvent(observer, AUTOREAD_EVENTS.PUSH);
|
|
16
|
+
|
|
17
|
+
await observer.emit(TEXT_EVENTS.EMIT);
|
|
18
|
+
|
|
19
|
+
expect(push).toHaveBeenCalledOnce();
|
|
20
|
+
expect(push).toHaveBeenCalledWith({ source: TEXT_CONST.SOURCE });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("TEXT.EMIT_END emits AUTOREAD.POP with text source", async () => {
|
|
24
|
+
const { observer } = createCompatibilityTestModule(BridgePluginTextPluginAutoread);
|
|
25
|
+
const pop = spyEvent(observer, AUTOREAD_EVENTS.POP);
|
|
26
|
+
|
|
27
|
+
await observer.emit(TEXT_EVENTS.EMIT_END);
|
|
28
|
+
|
|
29
|
+
expect(pop).toHaveBeenCalledOnce();
|
|
30
|
+
expect(pop).toHaveBeenCalledWith({ source: TEXT_CONST.SOURCE });
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PARAMS as AUTOREAD_PARAMS,
|
|
3
|
+
PLUGIN_NAME as AUTOREAD,
|
|
4
|
+
SETTINGS_KEYS as AUTOREAD_SETTINGS,
|
|
5
|
+
SUBSCRIBE_EVENTS as AUTOREAD_EVENTS,
|
|
6
|
+
} from "@vnejs/contracts.scenario.autoread";
|
|
7
|
+
import {
|
|
8
|
+
CONSTANTS as TEXT_CONST,
|
|
9
|
+
PARAMS as TEXT_PARAMS,
|
|
10
|
+
PLUGIN_NAME as TEXT,
|
|
11
|
+
SETTINGS_KEYS as TEXT_SETTINGS,
|
|
12
|
+
SUBSCRIBE_EVENTS as TEXT_EVENTS,
|
|
13
|
+
} from "@vnejs/contracts.text";
|
|
14
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
|
|
15
|
+
|
|
16
|
+
export const registerCompatibilityVne = () => {
|
|
17
|
+
registerCoreVne();
|
|
18
|
+
registerVnePlugin(TEXT, { constants: TEXT_CONST, events: TEXT_EVENTS, params: TEXT_PARAMS, settings: TEXT_SETTINGS });
|
|
19
|
+
registerVnePlugin(AUTOREAD, { events: AUTOREAD_EVENTS, params: AUTOREAD_PARAMS, settings: AUTOREAD_SETTINGS });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
|
|
23
|
+
ModuleClass: T,
|
|
24
|
+
options: Parameters<typeof baseCreateTestModule>[1] = {},
|
|
25
|
+
) => baseCreateTestModule(ModuleClass, options);
|
|
26
|
+
|
|
27
|
+
export { AUTOREAD_EVENTS, TEXT_CONST, TEXT_EVENTS };
|
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 AutoreadPluginName, SubscribeEvents as AutoreadSubscribeEvents } from "@vnejs/contracts.scenario.autoread";
|
|
3
|
+
import type { Constants as TextConstants, PluginName as TextPluginName, SubscribeEvents as TextSubscribeEvents } from "@vnejs/contracts.text";
|
|
4
|
+
|
|
5
|
+
export type PluginEvents = ModuleCoreEvents & Record<TextPluginName, TextSubscribeEvents> & Record<AutoreadPluginName, AutoreadSubscribeEvents>;
|
|
6
|
+
|
|
7
|
+
export type PluginConstants = ModuleCoreConstants & Record<TextPluginName, TextConstants>;
|
|
8
|
+
|
|
9
|
+
export type PluginSettings = ModuleCoreSettings;
|
|
10
|
+
|
|
11
|
+
export type PluginParams = ModuleCoreParams;
|
package/tsconfig.json
ADDED
package/README.md
DELETED