@vnejs/bridge.plugins.text.plugins.save.auto 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 +1 -0
- package/dist/index.js +5 -0
- package/dist/modules/bridge_plugin_text_plugin_save_auto.d.ts +7 -0
- package/dist/modules/bridge_plugin_text_plugin_save_auto.js +8 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/package.json +41 -4
- package/src/index.ts +9 -0
- package/src/modules/bridge_plugin_text_plugin_save_auto.ts +13 -0
- package/src/tests/save.auto.test.ts +34 -0
- package/src/tests/setup.ts +16 -0
- package/src/types.ts +11 -0
- package/tsconfig.json +9 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vnejs/contracts.text";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "@vnejs/contracts.text";
|
|
2
|
+
import { regPlugin } from "@vnejs/registry";
|
|
3
|
+
import { BridgePluginTextPluginSaveAuto } from "./modules/bridge_plugin_text_plugin_save_auto.js";
|
|
4
|
+
const PLUGIN_NAME = "BRIDGE_PLUGIN_TEXT_PLUGIN_SAVE_AUTO";
|
|
5
|
+
regPlugin(PLUGIN_NAME, {}, [BridgePluginTextPluginSaveAuto]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "../types.js";
|
|
3
|
+
export declare class BridgePluginTextPluginSaveAuto extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
4
|
+
name: string;
|
|
5
|
+
subscribe: () => void;
|
|
6
|
+
onTextEmitNext: () => Promise<import("@vnejs/registry").EmitResults<"vne:autosave:make">> | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
export class BridgePluginTextPluginSaveAuto extends ModuleCore {
|
|
3
|
+
name = "bridge_plugin_text_plugin_save_auto";
|
|
4
|
+
subscribe = () => {
|
|
5
|
+
this.on(this.EVENTS.TEXT.EMIT_NEXT, this.onTextEmitNext, { priority: -100000 });
|
|
6
|
+
};
|
|
7
|
+
onTextEmitNext = () => this.emit(this.EVENTS.SAVE_AUTO.MAKE);
|
|
8
|
+
}
|
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 SaveAutoPluginName, SubscribeEvents as SaveAutoSubscribeEvents } from "@vnejs/contracts.save.auto";
|
|
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<SaveAutoPluginName, SaveAutoSubscribeEvents>;
|
|
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,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/bridge.plugins.text.plugins.save.auto",
|
|
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.save.auto": "~0.2.0",
|
|
35
|
+
"@vnejs/contracts.text": "~0.2.0",
|
|
36
|
+
"@vnejs/registry": "~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,9 @@
|
|
|
1
|
+
import "@vnejs/contracts.text";
|
|
2
|
+
|
|
3
|
+
import { regPlugin } from "@vnejs/registry";
|
|
4
|
+
|
|
5
|
+
import { BridgePluginTextPluginSaveAuto } from "./modules/bridge_plugin_text_plugin_save_auto.js";
|
|
6
|
+
|
|
7
|
+
const PLUGIN_NAME = "BRIDGE_PLUGIN_TEXT_PLUGIN_SAVE_AUTO";
|
|
8
|
+
|
|
9
|
+
regPlugin(PLUGIN_NAME, {}, [BridgePluginTextPluginSaveAuto]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
|
|
3
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "../types.js";
|
|
4
|
+
|
|
5
|
+
export class BridgePluginTextPluginSaveAuto extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
6
|
+
name = "bridge_plugin_text_plugin_save_auto";
|
|
7
|
+
|
|
8
|
+
subscribe = () => {
|
|
9
|
+
this.on(this.EVENTS.TEXT.EMIT_NEXT, this.onTextEmitNext, { priority: -100000 });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
onTextEmitNext = () => this.emit(this.EVENTS.SAVE_AUTO.MAKE);
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
import { BridgePluginTextPluginSaveAuto } from "../modules/bridge_plugin_text_plugin_save_auto.js";
|
|
6
|
+
import { createCompatibilityTestModule, registerCompatibilityVne, SAVE_AUTO_EVENTS, TEXT_EVENTS } from "./setup.js";
|
|
7
|
+
|
|
8
|
+
describe("BridgePluginTextPluginSaveAuto", () => {
|
|
9
|
+
beforeEach(() => registerCompatibilityVne());
|
|
10
|
+
|
|
11
|
+
it("subscribe registers TEXT.EMIT_NEXT handler with priority -100000", () => {
|
|
12
|
+
const { module, observer } = createCompatibilityTestModule(BridgePluginTextPluginSaveAuto, { subscribe: false });
|
|
13
|
+
|
|
14
|
+
(module as BridgePluginTextPluginSaveAuto).subscribe();
|
|
15
|
+
|
|
16
|
+
expect(observer.subscribers[TEXT_EVENTS.EMIT_NEXT]?.flatMap((group) => group.subscribers)).toEqual(
|
|
17
|
+
expect.arrayContaining([
|
|
18
|
+
expect.objectContaining({
|
|
19
|
+
func: (module as BridgePluginTextPluginSaveAuto).onTextEmitNext,
|
|
20
|
+
options: expect.objectContaining({ priority: -100000 }),
|
|
21
|
+
}),
|
|
22
|
+
]),
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("TEXT.EMIT_NEXT emits SAVE_AUTO.MAKE", async () => {
|
|
27
|
+
const { observer } = createCompatibilityTestModule(BridgePluginTextPluginSaveAuto);
|
|
28
|
+
const make = spyEvent(observer, SAVE_AUTO_EVENTS.MAKE);
|
|
29
|
+
|
|
30
|
+
await observer.emit(TEXT_EVENTS.EMIT_NEXT);
|
|
31
|
+
|
|
32
|
+
expect(make).toHaveBeenCalledOnce();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SUBSCRIBE_EVENTS as SAVE_AUTO_EVENTS, PLUGIN_NAME as SAVE_AUTO } from "@vnejs/contracts.save.auto";
|
|
2
|
+
import { PARAMS as TEXT_PARAMS, PLUGIN_NAME as TEXT, SETTINGS_KEYS as TEXT_SETTINGS, SUBSCRIBE_EVENTS as TEXT_EVENTS } from "@vnejs/contracts.text";
|
|
3
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
export const registerCompatibilityVne = () => {
|
|
6
|
+
registerCoreVne();
|
|
7
|
+
registerVnePlugin(TEXT, { events: TEXT_EVENTS, params: TEXT_PARAMS, settings: TEXT_SETTINGS });
|
|
8
|
+
registerVnePlugin(SAVE_AUTO, { events: SAVE_AUTO_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 { SAVE_AUTO_EVENTS, 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 SaveAutoPluginName, SubscribeEvents as SaveAutoSubscribeEvents } from "@vnejs/contracts.save.auto";
|
|
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<SaveAutoPluginName, SaveAutoSubscribeEvents>;
|
|
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