@vnejs/compatibility.scenario.point_and_click-with-vars.flags 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 CompatibilityPointAndClickFlags 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 CompatibilityPointAndClickFlags extends ModuleCore {
4
+ name = "compatibility.scenario.point_and_click-with-vars.flags";
5
+ init = () => this.emit(this.EVENTS.POINT_AND_CLICK.EXEC_REG, {
6
+ module: this.CONST.VARS_FLAGS.EXEC_NAME,
7
+ handler: this.onPointAndClickExec,
8
+ });
9
+ onPointAndClickExec = ({ line = "", keywords = [] } = {}) => this.emitOne(this.EVENTS.VARS_FLAGS.EXEC_CHECK, { line, keywords });
10
+ }
11
+ regModule(CompatibilityPointAndClickFlags);
@@ -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 VarsFlagsPluginName, Constants as VarsFlagsConstants, SubscribeEvents as VarsFlagsSubscribeEvents } from "@vnejs/contracts.vars.flags";
4
+ export type PluginEvents = ModuleCoreEvents & Record<PointAndClickPluginName, PointAndClickSubscribeEvents> & Record<VarsFlagsPluginName, VarsFlagsSubscribeEvents>;
5
+ export type PluginConstants = ModuleCoreConstants & Record<VarsFlagsPluginName, VarsFlagsConstants>;
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.flags",
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.flags": "~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 CompatibilityPointAndClickFlags extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
14
+ name = "compatibility.scenario.point_and_click-with-vars.flags";
15
+
16
+ init = () =>
17
+ this.emit(this.EVENTS.POINT_AND_CLICK.EXEC_REG, {
18
+ module: this.CONST.VARS_FLAGS.EXEC_NAME,
19
+ handler: this.onPointAndClickExec,
20
+ } satisfies PointAndClickExecRegPayload);
21
+
22
+ onPointAndClickExec = ({ line = "", keywords = [] }: Parameters<PointAndClickExecHandler>[0] = {}) =>
23
+ this.emitOne(this.EVENTS.VARS_FLAGS.EXEC_CHECK, { line, keywords });
24
+ }
25
+
26
+ regModule(CompatibilityPointAndClickFlags);
@@ -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_FLAGS_CONST, PLUGIN_NAME as VARS_FLAGS, SUBSCRIBE_EVENTS as VARS_FLAGS_EVENTS } from "@vnejs/contracts.vars.flags";
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_FLAGS, { constants: VARS_FLAGS_CONST, events: VARS_FLAGS_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_FLAGS_CONST, VARS_FLAGS_EVENTS };
@@ -0,0 +1,34 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { CompatibilityPointAndClickFlags } from "../index.js";
6
+ import { createCompatibilityTestModule, VARS_FLAGS_CONST, VARS_FLAGS_EVENTS, PAC_EVENTS, registerCompatibilityVne } from "./setup.js";
7
+
8
+ describe("CompatibilityPointAndClickFlags", () => {
9
+ beforeEach(() => registerCompatibilityVne());
10
+
11
+ it("init registers point and click exec handler", async () => {
12
+ const { module, observer } = createCompatibilityTestModule(CompatibilityPointAndClickFlags, { subscribe: false });
13
+ const execReg = spyEvent(observer, PAC_EVENTS.EXEC_REG);
14
+
15
+ await (module as CompatibilityPointAndClickFlags).init();
16
+
17
+ expect(execReg).toHaveBeenCalledOnce();
18
+ expect(execReg.mock.calls[0]?.[0]).toMatchObject({ module: VARS_FLAGS_CONST.EXEC_NAME });
19
+ });
20
+
21
+ it("registered handler emits EXEC_CHECK", async () => {
22
+ const { module, observer } = createCompatibilityTestModule(CompatibilityPointAndClickFlags, { subscribe: false });
23
+ const execReg = spyEvent(observer, PAC_EVENTS.EXEC_REG);
24
+ const execCheck = spyEvent(observer, VARS_FLAGS_EVENTS.EXEC_CHECK);
25
+
26
+ await (module as CompatibilityPointAndClickFlags).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,13 @@
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 VarsFlagsPluginName, Constants as VarsFlagsConstants, SubscribeEvents as VarsFlagsSubscribeEvents } from "@vnejs/contracts.vars.flags";
4
+
5
+ export type PluginEvents = ModuleCoreEvents &
6
+ Record<PointAndClickPluginName, PointAndClickSubscribeEvents> &
7
+ Record<VarsFlagsPluginName, VarsFlagsSubscribeEvents>;
8
+
9
+ export type PluginConstants = ModuleCoreConstants & Record<VarsFlagsPluginName, VarsFlagsConstants>;
10
+
11
+ export type PluginSettings = ModuleCoreSettings;
12
+
13
+ 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
+ }