@vemjs/plugin-api 0.1.0 → 0.1.2
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/CHANGELOG.md +15 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +25 -0
- package/src/index.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
# @vemjs/plugin-api
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 02d5968: fix: replace workspace protocol references with exact versions on npm publish
|
|
8
|
+
- Updated dependencies [02d5968]
|
|
9
|
+
- @vemjs/core@0.1.2
|
|
10
|
+
|
|
3
11
|
## 0.1.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
6
14
|
|
|
15
|
+
- Updated dependencies [f5ccf66]
|
|
16
|
+
- @vemjs/core@0.1.1
|
|
17
|
+
|
|
18
|
+
## 0.1.0
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
7
22
|
- 0498765: chore: release infrastructure, package metadata, and documentation scaffolding
|
|
8
23
|
|
|
9
24
|
This changeset covers all release preparation work for the initial 0.1.0 publish:
|
|
@@ -41,8 +56,6 @@
|
|
|
41
56
|
- Updated dependencies [3fa4848]
|
|
42
57
|
- @vemjs/core@0.2.0
|
|
43
58
|
|
|
44
|
-
## 0.1.0
|
|
45
|
-
|
|
46
59
|
### Features
|
|
47
60
|
|
|
48
61
|
- `PluginRegistry` — plugin activation lifecycle manager
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface PluginContext {
|
|
|
13
13
|
onDidOpenBuffer(cb: () => void): void;
|
|
14
14
|
onDidChangeBuffer(cb: () => void): void;
|
|
15
15
|
onDidChangeMode(cb: (mode: EditorMode) => void): void;
|
|
16
|
+
onSave(cb: () => void): void;
|
|
16
17
|
}
|
|
17
18
|
export declare class PluginRegistry {
|
|
18
19
|
private plugins;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACvC,UAAU,CAAC,IAAI,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,cAAc,CAAC;IAC5B,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACjE,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9E,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACtC,iBAAiB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACvC,UAAU,CAAC,IAAI,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,cAAc,CAAC;IAC5B,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACjE,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9E,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACtC,iBAAiB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CAAC;IACtD,MAAM,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC9B;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,WAAW,CAAiB;gBAExB,WAAW,EAAE,cAAc;IAKhC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAkBjC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAQ1C"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export class PluginRegistry {
|
|
|
5
5
|
editorState;
|
|
6
6
|
constructor(editorState) {
|
|
7
7
|
this.editorState = editorState;
|
|
8
|
+
this.editorState.onExecutePluginCommand((name) => this.executeCommand(name));
|
|
8
9
|
}
|
|
9
10
|
register(plugin) {
|
|
10
11
|
const context = {
|
|
@@ -16,6 +17,7 @@ export class PluginRegistry {
|
|
|
16
17
|
onDidOpenBuffer: (cb) => this.editorState.onDidOpenBuffer(cb),
|
|
17
18
|
onDidChangeBuffer: (cb) => this.editorState.onDidChangeBuffer(cb),
|
|
18
19
|
onDidChangeMode: (cb) => this.editorState.onDidChangeMode(cb),
|
|
20
|
+
onSave: (cb) => this.editorState.onSave(cb),
|
|
19
21
|
};
|
|
20
22
|
plugin.activate(context);
|
|
21
23
|
this.plugins.set(plugin.name, plugin);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAoB7C,MAAM,OAAO,cAAc;IACjB,OAAO,GAA2B,IAAI,GAAG,EAAE,CAAC;IAC5C,QAAQ,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC9C,WAAW,CAAiB;IAEpC,YAAY,WAA2B;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/E,CAAC;IAEM,QAAQ,CAAC,MAAiB;QAC/B,MAAM,OAAO,GAAkB;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1D,kBAAkB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE;gBAC9C,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;YAC/D,CAAC;YACD,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,CAAC;YAC7D,iBAAiB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACjE,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,CAAC;YAC7D,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;SAC5C,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,WAAW,MAAM,CAAC,IAAI,cAAc,CAAC,CAAC;IACpD,CAAC;IAEM,cAAc,CAAC,IAAY;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,EAAE,CAAC;QACR,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,cAAc,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -99,4 +99,29 @@ describe('Plugin System', () => {
|
|
|
99
99
|
editor.handleKey('Escape');
|
|
100
100
|
expect(lastMode).toBe('NORMAL');
|
|
101
101
|
});
|
|
102
|
+
|
|
103
|
+
it('should support save event listeners', () => {
|
|
104
|
+
const editor = new VemEditorState('line1');
|
|
105
|
+
const registry = new PluginRegistry(editor);
|
|
106
|
+
|
|
107
|
+
let saved = false;
|
|
108
|
+
const testPlugin: VemPlugin = {
|
|
109
|
+
name: 'save-listener',
|
|
110
|
+
version: '1.0.0',
|
|
111
|
+
activate(context) {
|
|
112
|
+
context.onSave(() => {
|
|
113
|
+
saved = true;
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
registry.register(testPlugin);
|
|
119
|
+
|
|
120
|
+
// Trigger save (simulate :w)
|
|
121
|
+
editor.handleKey(':');
|
|
122
|
+
editor.handleKey('w');
|
|
123
|
+
editor.handleKey('Enter');
|
|
124
|
+
|
|
125
|
+
expect(saved).toBe(true);
|
|
126
|
+
});
|
|
102
127
|
});
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface PluginContext {
|
|
|
15
15
|
onDidOpenBuffer(cb: () => void): void;
|
|
16
16
|
onDidChangeBuffer(cb: () => void): void;
|
|
17
17
|
onDidChangeMode(cb: (mode: EditorMode) => void): void;
|
|
18
|
+
onSave(cb: () => void): void;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export class PluginRegistry {
|
|
@@ -24,6 +25,7 @@ export class PluginRegistry {
|
|
|
24
25
|
|
|
25
26
|
constructor(editorState: VemEditorState) {
|
|
26
27
|
this.editorState = editorState;
|
|
28
|
+
this.editorState.onExecutePluginCommand((name) => this.executeCommand(name));
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
public register(plugin: VemPlugin): void {
|
|
@@ -36,6 +38,7 @@ export class PluginRegistry {
|
|
|
36
38
|
onDidOpenBuffer: (cb) => this.editorState.onDidOpenBuffer(cb),
|
|
37
39
|
onDidChangeBuffer: (cb) => this.editorState.onDidChangeBuffer(cb),
|
|
38
40
|
onDidChangeMode: (cb) => this.editorState.onDidChangeMode(cb),
|
|
41
|
+
onSave: (cb) => this.editorState.onSave(cb),
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
plugin.activate(context);
|