@vnejs/compatibility.scenario.point_and_click-with-vars.counters 0.2.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,12 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "./types.js";
3
+ type PointAndClickExecHandler = (payload: {
4
+ line?: string;
5
+ keywords?: string[];
6
+ }) => unknown;
7
+ export declare class CompatibilityPointAndClickCounters extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
8
+ name: string;
9
+ init: () => Promise<unknown[]> | undefined;
10
+ onPointAndClickExec: ({ line, keywords }?: Parameters<PointAndClickExecHandler>[0]) => Promise<unknown> | undefined;
11
+ }
12
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import { regModule } from "@vnejs/shared";
3
+ export class CompatibilityPointAndClickCounters extends ModuleCore {
4
+ name = "compatibility.scenario.point_and_click-with-vars.counters";
5
+ init = () => this.emit(this.EVENTS.POINT_AND_CLICK.EXEC_REG, {
6
+ module: this.CONST.VARS_COUNTERS.EXEC_NAME,
7
+ handler: this.onPointAndClickExec,
8
+ });
9
+ onPointAndClickExec = ({ line = "", keywords = [] } = {}) => this.emitOne(this.EVENTS.VARS_COUNTERS.EXEC_CHECK, { line, keywords });
10
+ }
11
+ regModule(CompatibilityPointAndClickCounters);
@@ -0,0 +1,7 @@
1
+ import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
+ import type { PluginName as PointAndClickPluginName, SubscribeEvents as PointAndClickSubscribeEvents } from "@vnejs/contracts.scenario.point_and_click";
3
+ import type { PluginName as VarsCountersPluginName, Constants as VarsCountersConstants, SubscribeEvents as VarsCountersSubscribeEvents } from "@vnejs/contracts.vars.counters";
4
+ export type PluginEvents = ModuleCoreEvents & Record<PointAndClickPluginName, PointAndClickSubscribeEvents> & Record<VarsCountersPluginName, VarsCountersSubscribeEvents>;
5
+ export type PluginConstants = ModuleCoreConstants & Record<VarsCountersPluginName, VarsCountersConstants>;
6
+ export type PluginSettings = ModuleCoreSettings;
7
+ export type PluginParams = ModuleCoreParams;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@vnejs/compatibility.scenario.point_and_click-with-vars.counters",
3
+ "version": "0.2.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": "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.point_and_click": "~0.2.0",
35
+ "@vnejs/contracts.vars.counters": "~0.2.0",
36
+ "@vnejs/shared": "~0.2.0"
37
+ },
38
+ "devDependencies": {
39
+ "@vnejs/configs.ts-common": "~0.2.0",
40
+ "@vnejs/configs.vitest": "~0.2.0",
41
+ "@vnejs/test-utils": "~0.2.0"
42
+ }
43
+ }
package/src/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import { regModule } from "@vnejs/shared";
3
+
4
+ import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "./types.js";
5
+
6
+ type PointAndClickExecHandler = (payload: { line?: string; keywords?: string[] }) => unknown;
7
+
8
+ type PointAndClickExecRegPayload = {
9
+ module?: string;
10
+ handler?: PointAndClickExecHandler;
11
+ };
12
+
13
+ export class CompatibilityPointAndClickCounters extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
14
+ name = "compatibility.scenario.point_and_click-with-vars.counters";
15
+
16
+ init = () =>
17
+ this.emit(this.EVENTS.POINT_AND_CLICK.EXEC_REG, {
18
+ module: this.CONST.VARS_COUNTERS.EXEC_NAME,
19
+ handler: this.onPointAndClickExec,
20
+ } satisfies PointAndClickExecRegPayload);
21
+
22
+ onPointAndClickExec = ({ line = "", keywords = [] }: Parameters<PointAndClickExecHandler>[0] = {}) =>
23
+ this.emitOne(this.EVENTS.VARS_COUNTERS.EXEC_CHECK, { line, keywords });
24
+ }
25
+
26
+ regModule(CompatibilityPointAndClickCounters);
@@ -0,0 +1,16 @@
1
+ import { SUBSCRIBE_EVENTS as PAC_EVENTS, PLUGIN_NAME as PAC } from "@vnejs/contracts.scenario.point_and_click";
2
+ import { CONSTANTS as VARS_COUNTERS_CONST, PLUGIN_NAME as VARS_COUNTERS, SUBSCRIBE_EVENTS as VARS_COUNTERS_EVENTS } from "@vnejs/contracts.vars.counters";
3
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
4
+
5
+ export const registerCompatibilityVne = () => {
6
+ registerCoreVne();
7
+ registerVnePlugin(PAC, { events: PAC_EVENTS });
8
+ registerVnePlugin(VARS_COUNTERS, { constants: VARS_COUNTERS_CONST, events: VARS_COUNTERS_EVENTS });
9
+ };
10
+
11
+ export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
12
+ ModuleClass: T,
13
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
14
+ ) => baseCreateTestModule(ModuleClass, options);
15
+
16
+ export { PAC_EVENTS, VARS_COUNTERS_CONST, VARS_COUNTERS_EVENTS };
@@ -0,0 +1,34 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { CompatibilityPointAndClickCounters } from "../index.js";
6
+ import { createCompatibilityTestModule, VARS_COUNTERS_CONST, VARS_COUNTERS_EVENTS, PAC_EVENTS, registerCompatibilityVne } from "./setup.js";
7
+
8
+ describe("CompatibilityPointAndClickCounters", () => {
9
+ beforeEach(() => registerCompatibilityVne());
10
+
11
+ it("init registers point and click exec handler", async () => {
12
+ const { module, observer } = createCompatibilityTestModule(CompatibilityPointAndClickCounters, { subscribe: false });
13
+ const execReg = spyEvent(observer, PAC_EVENTS.EXEC_REG);
14
+
15
+ await (module as CompatibilityPointAndClickCounters).init();
16
+
17
+ expect(execReg).toHaveBeenCalledOnce();
18
+ expect(execReg.mock.calls[0]?.[0]).toMatchObject({ module: VARS_COUNTERS_CONST.EXEC_NAME });
19
+ });
20
+
21
+ it("registered handler emits EXEC_CHECK", async () => {
22
+ const { module, observer } = createCompatibilityTestModule(CompatibilityPointAndClickCounters, { subscribe: false });
23
+ const execReg = spyEvent(observer, PAC_EVENTS.EXEC_REG);
24
+ const execCheck = spyEvent(observer, VARS_COUNTERS_EVENTS.EXEC_CHECK);
25
+
26
+ await (module as CompatibilityPointAndClickCounters).init();
27
+
28
+ const handler = execReg.mock.calls[0]?.[0]?.handler as (payload: { line?: string; keywords?: string[] }) => unknown;
29
+ await handler({ line: "line", keywords: ["a"] });
30
+
31
+ expect(execCheck).toHaveBeenCalledOnce();
32
+ expect(execCheck).toHaveBeenCalledWith({ line: "line", keywords: ["a"] });
33
+ });
34
+ });
package/src/types.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
+ import type { PluginName as PointAndClickPluginName, SubscribeEvents as PointAndClickSubscribeEvents } from "@vnejs/contracts.scenario.point_and_click";
3
+ import type {
4
+ PluginName as VarsCountersPluginName,
5
+ Constants as VarsCountersConstants,
6
+ SubscribeEvents as VarsCountersSubscribeEvents,
7
+ } from "@vnejs/contracts.vars.counters";
8
+
9
+ export type PluginEvents = ModuleCoreEvents &
10
+ Record<PointAndClickPluginName, PointAndClickSubscribeEvents> &
11
+ Record<VarsCountersPluginName, VarsCountersSubscribeEvents>;
12
+
13
+ export type PluginConstants = ModuleCoreConstants & Record<VarsCountersPluginName, VarsCountersConstants>;
14
+
15
+ export type PluginSettings = ModuleCoreSettings;
16
+
17
+ export type PluginParams = 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", "src/tests"]
9
+ }