@vnejs/plugins.text.meet 0.1.1

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.
@@ -0,0 +1,2 @@
1
+ import "@vnejs/contracts.text";
2
+ import "@vnejs/contracts.text.meet";
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import "@vnejs/contracts.text";
2
+ import "@vnejs/contracts.text.meet";
3
+ import { regPlugin } from "@vnejs/shared";
4
+ import { PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.text.meet";
5
+ import { TextMeet } from "./modules/meet.js";
6
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS }, [TextMeet]);
@@ -0,0 +1,11 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { LineExecHandlerArg } from "@vnejs/module.core";
3
+ import type { TextMeetPayload } from "@vnejs/contracts.text.meet";
4
+ import type { TextMeetPluginConstants, TextMeetPluginEvents, TextMeetPluginParams, TextMeetPluginSettings } from "../types.js";
5
+ export declare class TextMeet extends ModuleCore<TextMeetPluginEvents, TextMeetPluginConstants, TextMeetPluginSettings, TextMeetPluginParams> {
6
+ name: string;
7
+ subscribe: () => void;
8
+ init: () => Promise<unknown[]> | undefined;
9
+ onLineExec: ({ line, args }?: LineExecHandlerArg) => Promise<void>;
10
+ onMeet: ({ speaker, value }?: TextMeetPayload) => Promise<unknown[]> | undefined;
11
+ }
@@ -0,0 +1,21 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import { tokenizeExecLine } from "@vnejs/helpers";
3
+ import { getTextSpeakerInfo } from "@vnejs/contracts.text";
4
+ export class TextMeet extends ModuleCore {
5
+ name = "text.meet";
6
+ subscribe = () => {
7
+ this.on(this.EVENTS.TEXT_MEET.MEET, this.onMeet);
8
+ };
9
+ init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
10
+ onLineExec = async ({ line = "", args = {} } = {}) => {
11
+ const [speaker = "", value = "1"] = tokenizeExecLine(line).map(String);
12
+ await this.emit(this.EVENTS.TEXT_MEET.MEET, { speaker, value, ...args });
13
+ this.emitNext();
14
+ };
15
+ onMeet = ({ speaker = "", value = 1 } = {}) => {
16
+ this.emitLog({ speaker, value });
17
+ const prev = getTextSpeakerInfo(this.globalState["text.speaker"], speaker);
18
+ const meet = (prev.meet ?? 0) + Number(value);
19
+ return this.emit(this.EVENTS.TEXT.SPEAKER_INFO_UPDATE, { speaker, info: { meet } });
20
+ };
21
+ }
@@ -0,0 +1,7 @@
1
+ import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
+ import type { PluginName as TextPluginName, SubscribeEvents as TextSubscribeEvents } from "@vnejs/contracts.text";
3
+ import type { PluginName, SubscribeEvents } from "@vnejs/contracts.text.meet";
4
+ export type TextMeetPluginEvents = ModuleCoreEvents & Record<PluginName, SubscribeEvents> & Record<TextPluginName, TextSubscribeEvents>;
5
+ export type TextMeetPluginConstants = ModuleCoreConstants;
6
+ export type TextMeetPluginSettings = ModuleCoreSettings;
7
+ export type TextMeetPluginParams = ModuleCoreParams;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@vnejs/plugins.text.meet",
3
+ "version": "0.1.1",
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": "echo \"Error: no test specified\" && exit 1",
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
+ "dependencies": {
33
+ "@vnejs/contracts.text.meet": "~0.1.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@vnejs/helpers": "~0.1.0",
37
+ "@vnejs/module.core": "~0.1.0",
38
+ "@vnejs/contracts.text": "~0.1.0",
39
+ "@vnejs/shared": "~0.1.0"
40
+ },
41
+ "devDependencies": {
42
+ "@vnejs/configs.ts-common": "~0.1.0"
43
+ }
44
+ }
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ import "@vnejs/contracts.text";
2
+ import "@vnejs/contracts.text.meet";
3
+
4
+ import { regPlugin } from "@vnejs/shared";
5
+ import { PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.text.meet";
6
+
7
+ import { TextMeet } from "./modules/meet.js";
8
+
9
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS }, [TextMeet]);
@@ -0,0 +1,35 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import { tokenizeExecLine } from "@vnejs/helpers";
3
+
4
+ import type { LineExecHandlerArg } from "@vnejs/module.core";
5
+ import type { TextMeetPayload } from "@vnejs/contracts.text.meet";
6
+ import { getTextSpeakerInfo } from "@vnejs/contracts.text";
7
+
8
+ import type { TextMeetPluginConstants, TextMeetPluginEvents, TextMeetPluginParams, TextMeetPluginSettings } from "../types.js";
9
+
10
+ export class TextMeet extends ModuleCore<TextMeetPluginEvents, TextMeetPluginConstants, TextMeetPluginSettings, TextMeetPluginParams> {
11
+ name = "text.meet";
12
+
13
+ subscribe = () => {
14
+ this.on(this.EVENTS.TEXT_MEET.MEET, this.onMeet);
15
+ };
16
+
17
+ init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
18
+
19
+ onLineExec = async ({ line = "", args = {} }: LineExecHandlerArg = {}) => {
20
+ const [speaker = "", value = "1"] = tokenizeExecLine(line).map(String);
21
+
22
+ await this.emit(this.EVENTS.TEXT_MEET.MEET, { speaker, value, ...args });
23
+
24
+ this.emitNext();
25
+ };
26
+
27
+ onMeet = ({ speaker = "", value = 1 }: TextMeetPayload = {}) => {
28
+ this.emitLog({ speaker, value });
29
+
30
+ const prev = getTextSpeakerInfo(this.globalState["text.speaker"], speaker);
31
+ const meet = (prev.meet ?? 0) + Number(value);
32
+
33
+ return this.emit(this.EVENTS.TEXT.SPEAKER_INFO_UPDATE, { speaker, info: { meet } });
34
+ };
35
+ }
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 TextPluginName, SubscribeEvents as TextSubscribeEvents } from "@vnejs/contracts.text";
3
+ import type { PluginName, SubscribeEvents } from "@vnejs/contracts.text.meet";
4
+
5
+ export type TextMeetPluginEvents = ModuleCoreEvents & Record<PluginName, SubscribeEvents> & Record<TextPluginName, TextSubscribeEvents>;
6
+
7
+ export type TextMeetPluginConstants = ModuleCoreConstants;
8
+
9
+ export type TextMeetPluginSettings = ModuleCoreSettings;
10
+
11
+ export type TextMeetPluginParams = ModuleCoreParams;
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@vnejs/configs.ts-common/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist"
6
+ },
7
+ "include": ["src/**/*.ts"],
8
+ "exclude": ["dist", "node_modules"]
9
+ }