@shiqianjiang/ceru-plugin-issuer 0.2.3 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +85 -20
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -138,17 +138,42 @@ export const MANIFEST_SCHEMA = object({
138
138
  }, ['hostApi', 'logicRuntime']),
139
139
  modules: object({
140
140
  logic: object({ entry: id, activation: strings }, ['entry']),
141
+ share: object({ entry: id, configKeys: strings, guestAdapterId: id, guestGlobals: strings }, [
142
+ 'entry',
143
+ ]),
141
144
  surfaces: {
142
145
  type: 'array',
143
146
  maxItems: 64,
144
- items: object({ id, kind: { enum: ['schema', 'web'] }, entry: id }, [
145
- 'id',
146
- 'kind',
147
- 'entry',
148
- ]),
147
+ items: object({
148
+ id,
149
+ kind: { enum: ['schema', 'web'] },
150
+ entry: id,
151
+ title: { type: 'string', minLength: 1, maxLength: 100 },
152
+ presentation: object({
153
+ kind: { const: 'drawer' },
154
+ placement: { enum: ['left', 'right', 'top', 'bottom'] },
155
+ size: { type: 'integer', minimum: 280, maximum: 1200 },
156
+ }, ['kind']),
157
+ lifecycle: object({ openAction: id, closeAction: id }),
158
+ }, ['id', 'kind', 'entry']),
149
159
  },
150
160
  }),
151
161
  contributes: object({
162
+ lyricConverters: {
163
+ type: 'array',
164
+ maxItems: 16,
165
+ items: object({
166
+ id,
167
+ title: string,
168
+ formats: {
169
+ type: 'array',
170
+ items: {
171
+ enum: ['auto', 'lrc', 'enhanced-lrc', 'yrc', 'qrc', 'krc', 'ttml', 'plain'],
172
+ },
173
+ uniqueItems: true,
174
+ },
175
+ }, ['id', 'title', 'formats']),
176
+ },
152
177
  menus: {
153
178
  type: 'array',
154
179
  maxItems: 64,
@@ -156,6 +181,7 @@ export const MANIFEST_SCHEMA = object({
156
181
  id,
157
182
  title: string,
158
183
  commandId: id,
184
+ description: string,
159
185
  slot: {
160
186
  enum: [
161
187
  'playlist.import',
@@ -247,10 +273,19 @@ export const MANIFEST_SCHEMA = object({
247
273
  playlistImporters: {
248
274
  type: 'array',
249
275
  maxItems: 64,
250
- items: object({ id, title: string, description: string, placeholder: string }, [
251
- 'id',
252
- 'title',
253
- ]),
276
+ items: object({
277
+ id,
278
+ title: string,
279
+ description: string,
280
+ placeholder: string,
281
+ providerId: id,
282
+ examples: {
283
+ type: 'array',
284
+ maxItems: 16,
285
+ items: object({ label: string, value: string }, ['label', 'value']),
286
+ },
287
+ instructions: strings,
288
+ }, ['id', 'title']),
254
289
  },
255
290
  providers: {
256
291
  type: 'array',
@@ -272,7 +307,11 @@ export const MANIFEST_SCHEMA = object({
272
307
  commands: {
273
308
  type: 'array',
274
309
  maxItems: 128,
275
- items: object({ id, title: string, action: id, view: id }, ['id', 'title', 'action']),
310
+ items: object({ id, title: string, description: string, action: id, view: id }, [
311
+ 'id',
312
+ 'title',
313
+ 'action',
314
+ ]),
276
315
  },
277
316
  sidebarItems: {
278
317
  type: 'array',
@@ -291,6 +330,19 @@ export const MANIFEST_SCHEMA = object({
291
330
  id,
292
331
  format: string,
293
332
  compatibilityProfile: string,
333
+ title: string,
334
+ extensions: strings,
335
+ badge: object({
336
+ label: { type: 'string', minLength: 1, maxLength: 24 },
337
+ backgroundColor: {
338
+ type: 'string',
339
+ pattern: '^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$',
340
+ },
341
+ textColor: {
342
+ type: 'string',
343
+ pattern: '^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$',
344
+ },
345
+ }, ['label', 'backgroundColor', 'textColor']),
294
346
  bootstrap: id,
295
347
  runtime: { const: 'ceru-js@1' },
296
348
  projectableProtocols: strings,
@@ -337,6 +389,18 @@ export function validateManifest(value) {
337
389
  for (const items of Object.values(manifest.contributes ?? {}))
338
390
  unique(items.map((p) => p.id), 'contribution id');
339
391
  const views = new Set(manifest.modules.surfaces?.map((p) => p.id));
392
+ const actions = new Set(manifest.contributes?.commands?.map((command) => command.action));
393
+ for (const surface of manifest.modules.surfaces ?? []) {
394
+ for (const action of Object.values(surface.lifecycle ?? {}))
395
+ ensure(actions.has(action), 'Unknown surface lifecycle action: ' + action);
396
+ }
397
+ const share = manifest.modules.share;
398
+ if (share?.guestAdapterId)
399
+ ensure(manifest.contributes?.guestAdapters?.some((adapter) => adapter.id === share.guestAdapterId), 'Unknown share guest adapter: ' + share.guestAdapterId);
400
+ for (const name of share?.guestGlobals ?? [])
401
+ ensure(/^[a-zA-Z_$][\w$]*$/.test(name) && !['globalThis', 'arguments', 'eval'].includes(name), 'Invalid share guest global: ' + name);
402
+ for (const menu of manifest.contributes?.menus ?? [])
403
+ ensure(manifest.contributes?.commands?.some((command) => command.id === menu.commandId), 'Unknown menu command: ' + menu.commandId);
340
404
  for (const items of [
341
405
  manifest.contributes?.commands,
342
406
  manifest.contributes?.sidebarItems,
@@ -456,9 +520,7 @@ export function resolveArtifactConfig(header) {
456
520
  ? personalization
457
521
  : undefined;
458
522
  const config = personalizationObject?.['config'];
459
- const override = plain(config)
460
- ? config
461
- : Object.create(null);
523
+ const override = plain(config) ? config : Object.create(null);
462
524
  return mergeConfig(header.manifest.config ?? Object.create(null), override);
463
525
  }
464
526
  /** Returns customer-facing metadata without changing plugin identity or permissions. */
@@ -742,13 +804,14 @@ function inspectBody(body, manifest) {
742
804
  node.params.length <= 1 &&
743
805
  (!node.params.length || node.params[0].type === 'Identifier'), 'Module must be a function with one context parameter');
744
806
  const generatedEntry = exportedNode.type === 'Identifier' && selfContained.has(exportedNode.name);
745
- modules[key] = preamble.length && !generatedEntry
746
- ? 'async function(ctx) {\n' +
747
- preamble.join('\n') +
748
- '\nreturn (' +
749
- body.slice(exportedNode.start, exportedNode.end) +
750
- ')(ctx);\n}'
751
- : body.slice(node.start, node.end);
807
+ modules[key] =
808
+ preamble.length && !generatedEntry
809
+ ? 'async function(ctx) {\n' +
810
+ preamble.join('\n') +
811
+ '\nreturn (' +
812
+ body.slice(exportedNode.start, exportedNode.end) +
813
+ ')(ctx);\n}'
814
+ : body.slice(node.start, node.end);
752
815
  }
753
816
  ensure(Object.keys(modules).length <= 128, 'Too many modules');
754
817
  const resources = astJson(registry.get('resources'));
@@ -780,6 +843,8 @@ function inspectBody(body, manifest) {
780
843
  };
781
844
  if (manifest.modules.logic)
782
845
  add(manifest.modules.logic.entry);
846
+ if (manifest.modules.share)
847
+ add(manifest.modules.share.entry);
783
848
  for (const surface of manifest.modules.surfaces ?? []) {
784
849
  if (surface.kind === 'web')
785
850
  add(surface.entry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shiqianjiang/ceru-plugin-issuer",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "Static verification, Ed25519 signing and cached personalized issuance of Ceru single-JS plugins",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "node": ">=22.12.0"
24
24
  },
25
25
  "dependencies": {
26
- "@shiqianjiang/ceru-plugin-sdk": "0.2.3",
26
+ "@shiqianjiang/ceru-plugin-sdk": "0.3.0",
27
27
  "acorn": "^8.18.0",
28
28
  "ajv": "^8.20.0"
29
29
  },