@shiqianjiang/ceru-plugin-cli 0.1.2 → 0.2.0
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/README.md +6 -6
- package/assets/core-contracts.js +1 -0
- package/assets/index.html +94 -93
- package/assets/playground.js +293 -30
- package/assets/sandbox.js +50 -19
- package/assets/style.css +16 -0
- package/dist/dependencies.d.ts +6 -0
- package/dist/dependencies.js +45 -0
- package/dist/dev.js +214 -119
- package/dist/index.js +5 -3
- package/dist/project.js +41 -16
- package/dist/socket-broker.d.ts +23 -0
- package/dist/socket-broker.js +230 -0
- package/package.json +71 -67
- package/schemas/config.schema.json +347 -0
- package/templates/connected-library/js/.vscode/ceru.code-snippets +37 -9
- package/templates/connected-library/js/package.json +2 -2
- package/templates/connected-library/js/src/index.js +7 -5
- package/templates/connected-library/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/connected-library/ts/package.json +2 -2
- package/templates/connected-library/ts/src/index.ts +7 -5
- package/templates/guest-adapter/js/.vscode/ceru.code-snippets +37 -9
- package/templates/guest-adapter/js/package.json +2 -2
- package/templates/guest-adapter/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/guest-adapter/ts/package.json +2 -2
- package/templates/importer/js/.vscode/ceru.code-snippets +37 -9
- package/templates/importer/js/README.md +1 -1
- package/templates/importer/js/ceru.plugin.json +8 -24
- package/templates/importer/js/package.json +2 -2
- package/templates/importer/js/src/index.js +28 -34
- package/templates/importer/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/importer/ts/README.md +1 -1
- package/templates/importer/ts/ceru.plugin.json +8 -24
- package/templates/importer/ts/package.json +2 -2
- package/templates/importer/ts/src/index.ts +28 -34
- package/templates/react/js/.vscode/ceru.code-snippets +37 -9
- package/templates/react/js/package.json +2 -2
- package/templates/react/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/react/ts/package.json +2 -2
- package/templates/snapshot.json +4 -2
- package/templates/source/js/.vscode/ceru.code-snippets +37 -9
- package/templates/source/js/ceru.plugin.json +9 -0
- package/templates/source/js/package.json +2 -2
- package/templates/source/js/src/index.js +29 -26
- package/templates/source/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/source/ts/ceru.plugin.json +9 -0
- package/templates/source/ts/package.json +2 -2
- package/templates/source/ts/src/index.ts +29 -26
- package/templates/vue/js/.vscode/ceru.code-snippets +37 -9
- package/templates/vue/js/package.json +2 -2
- package/templates/vue/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/vue/ts/package.json +2 -2
- package/templates/vue-tsx/js/.vscode/ceru.code-snippets +37 -9
- package/templates/vue-tsx/js/package.json +2 -2
- package/templates/vue-tsx/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/vue-tsx/ts/package.json +2 -2
- package/templates/web-dist/js/.vscode/ceru.code-snippets +37 -9
- package/templates/web-dist/js/package.json +2 -2
- package/templates/web-dist/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/web-dist/ts/package.json +2 -2
- package/templates/web-surface/js/.vscode/ceru.code-snippets +37 -9
- package/templates/web-surface/js/ceru.plugin.json +9 -0
- package/templates/web-surface/js/package.json +2 -2
- package/templates/web-surface/js/src/view.js +4 -1
- package/templates/web-surface/js/ui/search-note.css +3 -0
- package/templates/web-surface/ts/.vscode/ceru.code-snippets +37 -9
- package/templates/web-surface/ts/ceru.plugin.json +9 -0
- package/templates/web-surface/ts/package.json +2 -2
- package/templates/web-surface/ts/src/view.ts +4 -1
- package/templates/web-surface/ts/ui/search-note.css +3 -0
package/dist/project.js
CHANGED
|
@@ -7,6 +7,7 @@ import ts from 'typescript';
|
|
|
7
7
|
import { spawnSync } from 'node:child_process';
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
9
9
|
import { stylesheetPlugin, vuePlugin, webDistEntry } from './frameworks.js';
|
|
10
|
+
import { hostModulesPlugin, assertBundledDependencies } from './dependencies.js';
|
|
10
11
|
import { encodeArtifact, parseJsonStrict, readArtifact, validateManifest, LIMITS, } from '@shiqianjiang/ceru-plugin-issuer';
|
|
11
12
|
export async function writeAtomic(path, data, overwrite = false, mode = 0o644) {
|
|
12
13
|
await mkdir(dirname(path), { recursive: true });
|
|
@@ -95,9 +96,9 @@ export async function buildProject(project = '.', options = {}) {
|
|
|
95
96
|
}
|
|
96
97
|
const program = checkTypes(root);
|
|
97
98
|
const checker = program.getTypeChecker();
|
|
98
|
-
const chunks =
|
|
99
|
+
const chunks = new Map();
|
|
99
100
|
const devModules = {};
|
|
100
|
-
const plugins = [vuePlugin(root, config.framework), stylesheetPlugin()];
|
|
101
|
+
const plugins = [hostModulesPlugin(), vuePlugin(root, config.framework), stylesheetPlugin()];
|
|
101
102
|
const defines = {
|
|
102
103
|
'process.env.NODE_ENV': '"production"',
|
|
103
104
|
__VUE_OPTIONS_API__: 'true',
|
|
@@ -151,8 +152,8 @@ export async function buildProject(project = '.', options = {}) {
|
|
|
151
152
|
if (info.imports.length)
|
|
152
153
|
throw new Error('Unbundled import in ' + id);
|
|
153
154
|
const source = result.outputFiles[0].text;
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
assertBundledDependencies(source);
|
|
156
|
+
chunks.set(id, 'async function(ctx) {\n' +
|
|
156
157
|
source +
|
|
157
158
|
'\nif (typeof __ceru_entry.default !== "function") throw new Error("Entry must default-export a function");\nreturn __ceru_entry.default(ctx);\n}');
|
|
158
159
|
if (options.development) {
|
|
@@ -174,7 +175,8 @@ export async function buildProject(project = '.', options = {}) {
|
|
|
174
175
|
outfile: 'entry.js',
|
|
175
176
|
plugins,
|
|
176
177
|
define: defines,
|
|
177
|
-
|
|
178
|
+
banner: { js: 'globalThis.__ceruStart(async function(ctx) {' },
|
|
179
|
+
footer: { js: 'return __ceru_entry.default(ctx); });' },
|
|
178
180
|
loader: {
|
|
179
181
|
'.svg': 'dataurl',
|
|
180
182
|
'.css': 'text',
|
|
@@ -210,8 +212,8 @@ export async function buildProject(project = '.', options = {}) {
|
|
|
210
212
|
const result = await build(base);
|
|
211
213
|
if (result.outputFiles.length !== 1)
|
|
212
214
|
throw new Error('webDist emitted an external file');
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
assertBundledDependencies(result.outputFiles[0].text);
|
|
216
|
+
chunks.set(id, 'async function(ctx) {\n' +
|
|
215
217
|
result.outputFiles[0].text +
|
|
216
218
|
'\nreturn __ceru_entry.default(ctx);\n}');
|
|
217
219
|
if (options.development) {
|
|
@@ -219,7 +221,8 @@ export async function buildProject(project = '.', options = {}) {
|
|
|
219
221
|
...base,
|
|
220
222
|
sourcemap: 'inline',
|
|
221
223
|
sourceRoot: 'ceru:///',
|
|
222
|
-
|
|
224
|
+
banner: { js: 'globalThis.__ceruStart(async function(ctx) {' },
|
|
225
|
+
footer: { js: 'return __ceru_entry.default(ctx); });' },
|
|
223
226
|
});
|
|
224
227
|
devModules[id] = debug.outputFiles[0].text;
|
|
225
228
|
}
|
|
@@ -252,22 +255,44 @@ export async function buildProject(project = '.', options = {}) {
|
|
|
252
255
|
mime: input.mime ?? 'application/octet-stream',
|
|
253
256
|
};
|
|
254
257
|
}
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
const emitted = new Set();
|
|
259
|
+
const body = [];
|
|
260
|
+
const logicEntry = config.manifest.modules.logic?.entry;
|
|
261
|
+
if (logicEntry) {
|
|
262
|
+
const logic = chunks.get(logicEntry);
|
|
263
|
+
if (!logic)
|
|
264
|
+
throw new Error('Missing compiled logic entry: ' + logicEntry);
|
|
265
|
+
body.push('exports.activate = ' + logic + ';');
|
|
266
|
+
emitted.add(logicEntry);
|
|
267
|
+
}
|
|
268
|
+
const visibleSurfaces = (config.manifest.modules.surfaces ?? []).filter((surface) => surface.kind === 'web');
|
|
269
|
+
if (visibleSurfaces.length) {
|
|
270
|
+
const entries = visibleSurfaces.map((surface) => {
|
|
271
|
+
const entry = chunks.get(surface.entry);
|
|
272
|
+
if (!entry)
|
|
273
|
+
throw new Error('Missing compiled Surface entry: ' + surface.entry);
|
|
274
|
+
emitted.add(surface.entry);
|
|
275
|
+
return JSON.stringify(surface.id) + ': ' + entry;
|
|
276
|
+
});
|
|
277
|
+
body.push('exports.surfaces = {\n' + entries.join(',\n') + '\n};');
|
|
278
|
+
}
|
|
279
|
+
const modules = [...chunks].filter(([id]) => !emitted.has(id));
|
|
280
|
+
if (modules.length)
|
|
281
|
+
body.push('exports.modules = {\n' +
|
|
282
|
+
modules.map(([id, entry]) => JSON.stringify(id) + ': ' + entry).join(',\n') +
|
|
283
|
+
'\n};');
|
|
284
|
+
body.push('exports.resources = ' + JSON.stringify(resources) + ';');
|
|
260
285
|
const header = {
|
|
261
286
|
formatVersion: 2,
|
|
262
287
|
syntax: 'js',
|
|
263
288
|
manifest: config.manifest,
|
|
264
289
|
signature: null,
|
|
265
290
|
};
|
|
266
|
-
const artifact = encodeArtifact(header, body);
|
|
291
|
+
const artifact = encodeArtifact(header, body.join('\n') + '\n');
|
|
267
292
|
readArtifact(artifact);
|
|
268
293
|
const output = resolve(root, options.out ?? config.output ?? 'dist/plugin.js');
|
|
269
|
-
if (
|
|
270
|
-
throw new Error('Final output must be a .js
|
|
294
|
+
if (extname(output) !== '.js')
|
|
295
|
+
throw new Error('Final output must be a .js file containing compiled JavaScript');
|
|
271
296
|
const rel = relative(root, output);
|
|
272
297
|
if (rel === '..' || rel.startsWith('..' + sep) || isAbsolute(rel))
|
|
273
298
|
throw new Error('Build output must stay inside project');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface SocketEvent {
|
|
2
|
+
id: string;
|
|
3
|
+
event: string;
|
|
4
|
+
data: unknown;
|
|
5
|
+
}
|
|
6
|
+
/** Network libraries live in the Host. Plugins receive bounded JSON events and opaque handles. */
|
|
7
|
+
export declare class SocketBroker {
|
|
8
|
+
private readonly connections;
|
|
9
|
+
private events;
|
|
10
|
+
private generation;
|
|
11
|
+
private connecting;
|
|
12
|
+
connect(input: any, privateAllowed: boolean, reservedPorts: number[]): Promise<{
|
|
13
|
+
id: string;
|
|
14
|
+
}>;
|
|
15
|
+
private push;
|
|
16
|
+
send(id: string, event: string, data: unknown): void;
|
|
17
|
+
private release;
|
|
18
|
+
disconnect(id: string): void;
|
|
19
|
+
revoke(key: string): void;
|
|
20
|
+
closeAll(): void;
|
|
21
|
+
drain(): SocketEvent[];
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { lookup } from 'node:dns/promises';
|
|
2
|
+
import { isIP } from 'node:net';
|
|
3
|
+
import { Agent as HttpAgent } from 'node:http';
|
|
4
|
+
import { Agent as HttpsAgent } from 'node:https';
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
import { io } from 'socket.io-client';
|
|
7
|
+
import WebSocket from 'ws';
|
|
8
|
+
const privateAddress = (address) => {
|
|
9
|
+
const value = address.toLowerCase();
|
|
10
|
+
if (value.startsWith('::ffff:'))
|
|
11
|
+
return privateAddress(value.slice('::ffff:'.length));
|
|
12
|
+
if (value.includes(':'))
|
|
13
|
+
return (value === '::1' ||
|
|
14
|
+
value.startsWith('fc') ||
|
|
15
|
+
value.startsWith('fd') ||
|
|
16
|
+
value.startsWith('fe80'));
|
|
17
|
+
const parts = value.split('.').map(Number);
|
|
18
|
+
return (parts[0] === 0 ||
|
|
19
|
+
parts[0] === 10 ||
|
|
20
|
+
parts[0] === 127 ||
|
|
21
|
+
(parts[0] === 169 && parts[1] === 254) ||
|
|
22
|
+
(parts[0] === 100 && parts[1] >= 64 && parts[1] <= 127) ||
|
|
23
|
+
(parts[0] === 198 && (parts[1] === 18 || parts[1] === 19)) ||
|
|
24
|
+
parts[0] >= 224 ||
|
|
25
|
+
(parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) ||
|
|
26
|
+
(parts[0] === 192 && parts[1] === 168));
|
|
27
|
+
};
|
|
28
|
+
const reservedEvents = new Set([
|
|
29
|
+
'connect',
|
|
30
|
+
'connect_error',
|
|
31
|
+
'disconnect',
|
|
32
|
+
'disconnecting',
|
|
33
|
+
'newListener',
|
|
34
|
+
'removeListener',
|
|
35
|
+
'error',
|
|
36
|
+
'__proto__',
|
|
37
|
+
'constructor',
|
|
38
|
+
'prototype',
|
|
39
|
+
]);
|
|
40
|
+
/** Network libraries live in the Host. Plugins receive bounded JSON events and opaque handles. */
|
|
41
|
+
export class SocketBroker {
|
|
42
|
+
connections = new Map();
|
|
43
|
+
events = [];
|
|
44
|
+
generation = 0;
|
|
45
|
+
connecting = 0;
|
|
46
|
+
async connect(input, privateAllowed, reservedPorts) {
|
|
47
|
+
if (this.connections.size + this.connecting >= 8)
|
|
48
|
+
throw new Error('Socket connection limit reached');
|
|
49
|
+
this.connecting++;
|
|
50
|
+
const generation = this.generation;
|
|
51
|
+
try {
|
|
52
|
+
const kind = input.kind;
|
|
53
|
+
if (!['websocket', 'socket.io'].includes(kind))
|
|
54
|
+
throw new Error('Unknown socket protocol');
|
|
55
|
+
const url = new URL(input.url);
|
|
56
|
+
if (url.username ||
|
|
57
|
+
url.password ||
|
|
58
|
+
url.hash ||
|
|
59
|
+
(kind === 'websocket'
|
|
60
|
+
? !['ws:', 'wss:'].includes(url.protocol)
|
|
61
|
+
: !['http:', 'https:'].includes(url.protocol)))
|
|
62
|
+
throw new Error('Unsupported socket URL');
|
|
63
|
+
const path = kind === 'socket.io' ? String(input.path || '/socket.io/') : url.pathname;
|
|
64
|
+
if (!path.startsWith('/') || path.startsWith('//') || /[?#\\]|%(?:2f|5c)/i.test(path))
|
|
65
|
+
throw new Error('Invalid socket path');
|
|
66
|
+
const hostname = url.hostname.replace(/^\[|\]$/g, '');
|
|
67
|
+
const addresses = isIP(hostname)
|
|
68
|
+
? [{ address: hostname, family: isIP(hostname) }]
|
|
69
|
+
: await lookup(hostname, { all: true });
|
|
70
|
+
if (!addresses.length)
|
|
71
|
+
throw new Error('No socket address found');
|
|
72
|
+
if (addresses.some((item) => privateAddress(item.address)) && !privateAllowed)
|
|
73
|
+
throw new Error('Private network access is not granted');
|
|
74
|
+
const defaultPort = ['https:', 'wss:'].includes(url.protocol) ? 443 : 80;
|
|
75
|
+
if (reservedPorts.includes(Number(url.port) || defaultPort))
|
|
76
|
+
throw new Error('Development ports are reserved');
|
|
77
|
+
const chosen = addresses[0];
|
|
78
|
+
const Agent = ['https:', 'wss:'].includes(url.protocol) ? HttpsAgent : HttpAgent;
|
|
79
|
+
const agent = new Agent({
|
|
80
|
+
lookup: ((_hostname, options, callback) => options?.all
|
|
81
|
+
? callback(null, [chosen])
|
|
82
|
+
: callback(null, chosen.address, chosen.family)),
|
|
83
|
+
});
|
|
84
|
+
const id = randomUUID();
|
|
85
|
+
let socket;
|
|
86
|
+
if (kind === 'socket.io') {
|
|
87
|
+
const auth = input.auth ?? {};
|
|
88
|
+
if (Buffer.byteLength(JSON.stringify(auth)) > 16384) {
|
|
89
|
+
agent.destroy();
|
|
90
|
+
throw new Error('Socket auth is too large');
|
|
91
|
+
}
|
|
92
|
+
socket = io(url.href, {
|
|
93
|
+
path,
|
|
94
|
+
auth,
|
|
95
|
+
autoConnect: false,
|
|
96
|
+
forceNew: true,
|
|
97
|
+
transports: ['websocket'],
|
|
98
|
+
upgrade: false,
|
|
99
|
+
reconnection: input.reconnection !== false,
|
|
100
|
+
reconnectionAttempts: 5,
|
|
101
|
+
reconnectionDelay: 1000,
|
|
102
|
+
reconnectionDelayMax: 10000,
|
|
103
|
+
timeout: 10000,
|
|
104
|
+
transportOptions: { websocket: { agent, followRedirects: false, maxPayload: 65536 } },
|
|
105
|
+
});
|
|
106
|
+
socket.on('connect', () => this.push(id, 'connect', null));
|
|
107
|
+
socket.on('disconnect', (reason) => this.push(id, 'disconnect', reason));
|
|
108
|
+
socket.on('connect_error', () => this.push(id, 'error', 'Socket.IO connection failed'));
|
|
109
|
+
socket.onAny((event, ...args) => this.push(id, String(event), args));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
socket = new WebSocket(url.href, {
|
|
113
|
+
agent,
|
|
114
|
+
followRedirects: false,
|
|
115
|
+
handshakeTimeout: 10000,
|
|
116
|
+
maxPayload: 65536,
|
|
117
|
+
});
|
|
118
|
+
socket.on('open', () => this.push(id, 'connect', null));
|
|
119
|
+
socket.on('close', (code) => {
|
|
120
|
+
this.push(id, 'disconnect', { code });
|
|
121
|
+
this.release(id);
|
|
122
|
+
});
|
|
123
|
+
socket.on('error', () => this.push(id, 'error', 'WebSocket connection failed'));
|
|
124
|
+
socket.on('message', (data, binary) => {
|
|
125
|
+
if (binary) {
|
|
126
|
+
this.push(id, 'error', 'Binary frames are not supported by this JSON channel');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.push(id, 'message', data.toString());
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
this.connections.set(id, {
|
|
133
|
+
key: String(input.permissionKey),
|
|
134
|
+
kind,
|
|
135
|
+
socket,
|
|
136
|
+
agent,
|
|
137
|
+
lastSend: Date.now(),
|
|
138
|
+
sends: 0,
|
|
139
|
+
});
|
|
140
|
+
if (generation !== this.generation) {
|
|
141
|
+
this.disconnect(id);
|
|
142
|
+
throw new Error('Plugin was stopped while connecting');
|
|
143
|
+
}
|
|
144
|
+
if (kind === 'socket.io')
|
|
145
|
+
socket.connect();
|
|
146
|
+
return { id };
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
this.connecting--;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
push(id, event, data) {
|
|
153
|
+
if (!this.connections.has(id))
|
|
154
|
+
return;
|
|
155
|
+
let text;
|
|
156
|
+
try {
|
|
157
|
+
text = JSON.stringify(data ?? null);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
this.disconnect(id);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (Buffer.byteLength(text) > 65536 || this.events.length >= 256) {
|
|
164
|
+
this.disconnect(id);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.events.push({ id, event, data: JSON.parse(text) });
|
|
168
|
+
}
|
|
169
|
+
send(id, event, data) {
|
|
170
|
+
const entry = this.connections.get(id);
|
|
171
|
+
if (!entry)
|
|
172
|
+
throw new Error('Socket is closed');
|
|
173
|
+
const text = JSON.stringify(data ?? null);
|
|
174
|
+
if (Buffer.byteLength(text) > 65536)
|
|
175
|
+
throw new Error('Socket message is too large');
|
|
176
|
+
if (Date.now() - entry.lastSend >= 1000) {
|
|
177
|
+
entry.lastSend = Date.now();
|
|
178
|
+
entry.sends = 0;
|
|
179
|
+
}
|
|
180
|
+
if (++entry.sends > 100)
|
|
181
|
+
throw new Error('Socket send rate exceeded');
|
|
182
|
+
if (entry.kind === 'socket.io') {
|
|
183
|
+
if (typeof event !== 'string' || event.length > 128 || reservedEvents.has(event))
|
|
184
|
+
throw new Error('Invalid Socket.IO event');
|
|
185
|
+
const socket = entry.socket;
|
|
186
|
+
if (!socket.connected)
|
|
187
|
+
throw new Error('Socket is not connected');
|
|
188
|
+
socket.emit(event, data);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const socket = entry.socket;
|
|
192
|
+
if (socket.readyState !== WebSocket.OPEN)
|
|
193
|
+
throw new Error('Socket is not connected');
|
|
194
|
+
socket.send(typeof data === 'string' ? data : text);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
release(id) {
|
|
198
|
+
const entry = this.connections.get(id);
|
|
199
|
+
this.connections.delete(id);
|
|
200
|
+
entry?.agent.destroy();
|
|
201
|
+
}
|
|
202
|
+
disconnect(id) {
|
|
203
|
+
const entry = this.connections.get(id);
|
|
204
|
+
if (!entry)
|
|
205
|
+
return;
|
|
206
|
+
this.connections.delete(id);
|
|
207
|
+
if (entry.kind === 'socket.io')
|
|
208
|
+
entry.socket.disconnect();
|
|
209
|
+
else
|
|
210
|
+
entry.socket.terminate();
|
|
211
|
+
entry.agent.destroy();
|
|
212
|
+
this.events = this.events.filter((event) => event.id !== id);
|
|
213
|
+
}
|
|
214
|
+
revoke(key) {
|
|
215
|
+
for (const [id, entry] of this.connections)
|
|
216
|
+
if (entry.key === key)
|
|
217
|
+
this.disconnect(id);
|
|
218
|
+
}
|
|
219
|
+
closeAll() {
|
|
220
|
+
this.generation++;
|
|
221
|
+
for (const id of this.connections.keys())
|
|
222
|
+
this.disconnect(id);
|
|
223
|
+
this.events = [];
|
|
224
|
+
}
|
|
225
|
+
drain() {
|
|
226
|
+
const events = this.events;
|
|
227
|
+
this.events = [];
|
|
228
|
+
return events;
|
|
229
|
+
}
|
|
230
|
+
}
|
package/package.json
CHANGED
|
@@ -1,67 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@shiqianjiang/ceru-plugin-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "TypeScript scaffolding, single-file build, watch, validation, signing and issuance for Ceru plugins",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"default": "./dist/index.js"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"bin": {
|
|
16
|
-
"ceru-plugin": "./dist/bin.js"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist",
|
|
20
|
-
"assets",
|
|
21
|
-
"schemas",
|
|
22
|
-
"templates",
|
|
23
|
-
"README.md",
|
|
24
|
-
"LICENSE",
|
|
25
|
-
"ASSET_LICENSE",
|
|
26
|
-
"NOTICE"
|
|
27
|
-
],
|
|
28
|
-
"license": "MIT AND AGPL-3.0-only",
|
|
29
|
-
"author": "澜音团队",
|
|
30
|
-
"engines": {
|
|
31
|
-
"node": ">=22.12.0"
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@vue/
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"react": "19.3.0",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@shiqianjiang/ceru-plugin-cli",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "TypeScript scaffolding, single-file build, watch, validation, signing and issuance for Ceru plugins",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"ceru-plugin": "./dist/bin.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"assets",
|
|
21
|
+
"schemas",
|
|
22
|
+
"templates",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"ASSET_LICENSE",
|
|
26
|
+
"NOTICE"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT AND AGPL-3.0-only",
|
|
29
|
+
"author": "澜音团队",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=22.12.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@babel/core": "^7.29.7",
|
|
35
|
+
"@shiqianjiang/ceru-plugin-issuer": "0.2.0",
|
|
36
|
+
"@shiqianjiang/ceru-plugin-sdk": "0.2.0",
|
|
37
|
+
"@vue/babel-plugin-jsx": "^2.0.1",
|
|
38
|
+
"@vue/compiler-sfc": "3.5.43",
|
|
39
|
+
"axios": "^1.20.0",
|
|
40
|
+
"esbuild": "^0.28.2",
|
|
41
|
+
"lodash-es": "^4.18.1",
|
|
42
|
+
"parse5": "^8.0.1",
|
|
43
|
+
"react": "19.3.0",
|
|
44
|
+
"react-dom": "19.3.0",
|
|
45
|
+
"semver": "^7.7.0",
|
|
46
|
+
"socket.io-client": "^4.8.3",
|
|
47
|
+
"typescript": "~5.9.3",
|
|
48
|
+
"vue": "3.5.43",
|
|
49
|
+
"vue-tsc": "^3.3.11",
|
|
50
|
+
"ws": "^8.21.3"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/CeruMusic/CeruMusic-Plugin-Cli.git",
|
|
59
|
+
"directory": "packages/cli"
|
|
60
|
+
},
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/CeruMusic/CeruMusic-Plugin-Cli#readme",
|
|
65
|
+
"keywords": [
|
|
66
|
+
"ceru-music",
|
|
67
|
+
"plugin",
|
|
68
|
+
"typescript",
|
|
69
|
+
"electron"
|
|
70
|
+
]
|
|
71
|
+
}
|