@shiqianjiang/ceru-plugin-cli 0.1.1 → 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.
Files changed (153) hide show
  1. package/README.md +9 -5
  2. package/assets/catalog.json +1 -1
  3. package/assets/core-contracts.js +1 -0
  4. package/assets/index.html +94 -93
  5. package/assets/playground.js +293 -30
  6. package/assets/sandbox.js +50 -19
  7. package/assets/style.css +16 -0
  8. package/dist/dependencies.d.ts +6 -0
  9. package/dist/dependencies.js +45 -0
  10. package/dist/dev.d.ts +2 -0
  11. package/dist/dev.js +297 -144
  12. package/dist/frameworks.d.ts +2 -2
  13. package/dist/frameworks.js +11 -29
  14. package/dist/index.js +12 -4
  15. package/dist/project.d.ts +1 -0
  16. package/dist/project.js +48 -21
  17. package/dist/socket-broker.d.ts +23 -0
  18. package/dist/socket-broker.js +230 -0
  19. package/package.json +71 -67
  20. package/schemas/config.schema.json +349 -0
  21. package/templates/connected-library/js/.vscode/ceru.code-snippets +37 -9
  22. package/templates/connected-library/js/.vscode/launch.json +36 -46
  23. package/templates/connected-library/js/.vscode/tasks.json +11 -3
  24. package/templates/connected-library/js/README.md +7 -2
  25. package/templates/connected-library/js/ceru-plugin.code-workspace +8 -0
  26. package/templates/connected-library/js/package.json +4 -3
  27. package/templates/connected-library/js/src/index.js +7 -5
  28. package/templates/connected-library/ts/.vscode/ceru.code-snippets +37 -9
  29. package/templates/connected-library/ts/.vscode/launch.json +36 -46
  30. package/templates/connected-library/ts/.vscode/tasks.json +11 -3
  31. package/templates/connected-library/ts/README.md +7 -2
  32. package/templates/connected-library/ts/ceru-plugin.code-workspace +8 -0
  33. package/templates/connected-library/ts/package.json +4 -3
  34. package/templates/connected-library/ts/src/index.ts +7 -5
  35. package/templates/guest-adapter/js/.vscode/ceru.code-snippets +37 -9
  36. package/templates/guest-adapter/js/.vscode/launch.json +36 -46
  37. package/templates/guest-adapter/js/.vscode/tasks.json +11 -3
  38. package/templates/guest-adapter/js/README.md +7 -2
  39. package/templates/guest-adapter/js/ceru-plugin.code-workspace +8 -0
  40. package/templates/guest-adapter/js/package.json +4 -3
  41. package/templates/guest-adapter/ts/.vscode/ceru.code-snippets +37 -9
  42. package/templates/guest-adapter/ts/.vscode/launch.json +36 -46
  43. package/templates/guest-adapter/ts/.vscode/tasks.json +11 -3
  44. package/templates/guest-adapter/ts/README.md +7 -2
  45. package/templates/guest-adapter/ts/ceru-plugin.code-workspace +8 -0
  46. package/templates/guest-adapter/ts/package.json +4 -3
  47. package/templates/importer/js/.vscode/ceru.code-snippets +37 -9
  48. package/templates/importer/js/.vscode/launch.json +36 -46
  49. package/templates/importer/js/.vscode/tasks.json +11 -3
  50. package/templates/importer/js/README.md +8 -3
  51. package/templates/importer/js/ceru-plugin.code-workspace +8 -0
  52. package/templates/importer/js/ceru.plugin.json +8 -24
  53. package/templates/importer/js/package.json +4 -3
  54. package/templates/importer/js/src/index.js +28 -34
  55. package/templates/importer/ts/.vscode/ceru.code-snippets +37 -9
  56. package/templates/importer/ts/.vscode/launch.json +36 -46
  57. package/templates/importer/ts/.vscode/tasks.json +11 -3
  58. package/templates/importer/ts/README.md +8 -3
  59. package/templates/importer/ts/ceru-plugin.code-workspace +8 -0
  60. package/templates/importer/ts/ceru.plugin.json +8 -24
  61. package/templates/importer/ts/package.json +4 -3
  62. package/templates/importer/ts/src/index.ts +28 -34
  63. package/templates/react/js/.vscode/ceru.code-snippets +37 -9
  64. package/templates/react/js/.vscode/launch.json +36 -46
  65. package/templates/react/js/.vscode/tasks.json +11 -3
  66. package/templates/react/js/README.md +7 -2
  67. package/templates/react/js/ceru-plugin.code-workspace +8 -0
  68. package/templates/react/js/ceru.plugin.json +1 -5
  69. package/templates/react/js/package.json +4 -3
  70. package/templates/react/ts/.vscode/ceru.code-snippets +37 -9
  71. package/templates/react/ts/.vscode/launch.json +36 -46
  72. package/templates/react/ts/.vscode/tasks.json +11 -3
  73. package/templates/react/ts/README.md +7 -2
  74. package/templates/react/ts/ceru-plugin.code-workspace +8 -0
  75. package/templates/react/ts/ceru.plugin.json +1 -5
  76. package/templates/react/ts/package.json +4 -3
  77. package/templates/snapshot.json +22 -2
  78. package/templates/source/js/.vscode/ceru.code-snippets +37 -9
  79. package/templates/source/js/.vscode/launch.json +36 -46
  80. package/templates/source/js/.vscode/tasks.json +11 -3
  81. package/templates/source/js/README.md +7 -2
  82. package/templates/source/js/ceru-plugin.code-workspace +8 -0
  83. package/templates/source/js/ceru.plugin.json +9 -0
  84. package/templates/source/js/package.json +4 -3
  85. package/templates/source/js/src/index.js +29 -26
  86. package/templates/source/ts/.vscode/ceru.code-snippets +37 -9
  87. package/templates/source/ts/.vscode/launch.json +36 -46
  88. package/templates/source/ts/.vscode/tasks.json +11 -3
  89. package/templates/source/ts/README.md +7 -2
  90. package/templates/source/ts/ceru-plugin.code-workspace +8 -0
  91. package/templates/source/ts/ceru.plugin.json +9 -0
  92. package/templates/source/ts/package.json +4 -3
  93. package/templates/source/ts/src/index.ts +29 -26
  94. package/templates/vue/js/.vscode/ceru.code-snippets +37 -9
  95. package/templates/vue/js/.vscode/launch.json +36 -46
  96. package/templates/vue/js/.vscode/tasks.json +11 -3
  97. package/templates/vue/js/README.md +7 -2
  98. package/templates/vue/js/ceru-plugin.code-workspace +8 -0
  99. package/templates/vue/js/ceru.plugin.json +1 -4
  100. package/templates/vue/js/package.json +4 -3
  101. package/templates/vue/ts/.vscode/ceru.code-snippets +37 -9
  102. package/templates/vue/ts/.vscode/launch.json +36 -46
  103. package/templates/vue/ts/.vscode/tasks.json +11 -3
  104. package/templates/vue/ts/README.md +7 -2
  105. package/templates/vue/ts/ceru-plugin.code-workspace +8 -0
  106. package/templates/vue/ts/ceru.plugin.json +1 -4
  107. package/templates/vue/ts/package.json +4 -3
  108. package/templates/vue-tsx/js/.vscode/ceru.code-snippets +37 -9
  109. package/templates/vue-tsx/js/.vscode/launch.json +36 -46
  110. package/templates/vue-tsx/js/.vscode/tasks.json +11 -3
  111. package/templates/vue-tsx/js/README.md +7 -2
  112. package/templates/vue-tsx/js/ceru-plugin.code-workspace +8 -0
  113. package/templates/vue-tsx/js/ceru.plugin.json +1 -4
  114. package/templates/vue-tsx/js/package.json +4 -3
  115. package/templates/vue-tsx/ts/.vscode/ceru.code-snippets +37 -9
  116. package/templates/vue-tsx/ts/.vscode/launch.json +36 -46
  117. package/templates/vue-tsx/ts/.vscode/tasks.json +11 -3
  118. package/templates/vue-tsx/ts/README.md +7 -2
  119. package/templates/vue-tsx/ts/ceru-plugin.code-workspace +8 -0
  120. package/templates/vue-tsx/ts/ceru.plugin.json +1 -4
  121. package/templates/vue-tsx/ts/package.json +4 -3
  122. package/templates/web-dist/js/.vscode/ceru.code-snippets +37 -9
  123. package/templates/web-dist/js/.vscode/launch.json +36 -46
  124. package/templates/web-dist/js/.vscode/tasks.json +11 -3
  125. package/templates/web-dist/js/README.md +7 -2
  126. package/templates/web-dist/js/ceru-plugin.code-workspace +8 -0
  127. package/templates/web-dist/js/package.json +4 -3
  128. package/templates/web-dist/ts/.vscode/ceru.code-snippets +37 -9
  129. package/templates/web-dist/ts/.vscode/launch.json +36 -46
  130. package/templates/web-dist/ts/.vscode/tasks.json +11 -3
  131. package/templates/web-dist/ts/README.md +7 -2
  132. package/templates/web-dist/ts/ceru-plugin.code-workspace +8 -0
  133. package/templates/web-dist/ts/package.json +4 -3
  134. package/templates/web-surface/js/.vscode/ceru.code-snippets +37 -9
  135. package/templates/web-surface/js/.vscode/launch.json +36 -46
  136. package/templates/web-surface/js/.vscode/tasks.json +11 -3
  137. package/templates/web-surface/js/README.md +7 -2
  138. package/templates/web-surface/js/ceru-plugin.code-workspace +8 -0
  139. package/templates/web-surface/js/ceru.plugin.json +9 -0
  140. package/templates/web-surface/js/package.json +4 -3
  141. package/templates/web-surface/js/src/view.js +4 -1
  142. package/templates/web-surface/js/ui/search-note.css +3 -0
  143. package/templates/web-surface/ts/.vscode/ceru.code-snippets +37 -9
  144. package/templates/web-surface/ts/.vscode/launch.json +36 -46
  145. package/templates/web-surface/ts/.vscode/tasks.json +11 -3
  146. package/templates/web-surface/ts/README.md +7 -2
  147. package/templates/web-surface/ts/ceru-plugin.code-workspace +8 -0
  148. package/templates/web-surface/ts/ceru.plugin.json +9 -0
  149. package/templates/web-surface/ts/package.json +4 -3
  150. package/templates/web-surface/ts/src/view.ts +4 -1
  151. package/templates/web-surface/ts/ui/search-note.css +3 -0
  152. package/assets/shared-react.js +0 -77
  153. package/assets/shared-vue.js +0 -44
@@ -149,6 +149,339 @@
149
149
  "contributes": {
150
150
  "type": "object",
151
151
  "properties": {
152
+ "menus": {
153
+ "type": "array",
154
+ "maxItems": 64,
155
+ "items": {
156
+ "type": "object",
157
+ "properties": {
158
+ "id": {
159
+ "type": "string",
160
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
161
+ },
162
+ "title": {
163
+ "type": "string",
164
+ "minLength": 1,
165
+ "maxLength": 4096
166
+ },
167
+ "commandId": {
168
+ "type": "string",
169
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
170
+ },
171
+ "slot": {
172
+ "enum": [
173
+ "playlist.import",
174
+ "playlist.actions",
175
+ "track.actions",
176
+ "player.actions",
177
+ "search.tools"
178
+ ]
179
+ },
180
+ "icon": {
181
+ "oneOf": [
182
+ {
183
+ "type": "object",
184
+ "properties": {
185
+ "kind": {
186
+ "const": "host"
187
+ },
188
+ "name": {
189
+ "type": "string",
190
+ "minLength": 1,
191
+ "maxLength": 4096
192
+ }
193
+ },
194
+ "required": [
195
+ "kind",
196
+ "name"
197
+ ],
198
+ "additionalProperties": false
199
+ },
200
+ {
201
+ "type": "object",
202
+ "properties": {
203
+ "kind": {
204
+ "const": "asset"
205
+ },
206
+ "resource": {
207
+ "type": "string",
208
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
209
+ }
210
+ },
211
+ "required": [
212
+ "kind",
213
+ "resource"
214
+ ],
215
+ "additionalProperties": false
216
+ }
217
+ ]
218
+ },
219
+ "when": {
220
+ "type": "object",
221
+ "properties": {
222
+ "kinds": {
223
+ "type": "array",
224
+ "items": {
225
+ "enum": [
226
+ "track",
227
+ "playlist"
228
+ ]
229
+ }
230
+ },
231
+ "loggedIn": {
232
+ "type": "boolean"
233
+ }
234
+ },
235
+ "required": [],
236
+ "additionalProperties": false
237
+ }
238
+ },
239
+ "required": [
240
+ "id",
241
+ "slot",
242
+ "title",
243
+ "commandId"
244
+ ],
245
+ "additionalProperties": false
246
+ }
247
+ },
248
+ "homeSections": {
249
+ "type": "array",
250
+ "maxItems": 32,
251
+ "items": {
252
+ "type": "object",
253
+ "properties": {
254
+ "id": {
255
+ "type": "string",
256
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
257
+ },
258
+ "title": {
259
+ "type": "string",
260
+ "minLength": 1,
261
+ "maxLength": 4096
262
+ },
263
+ "kind": {
264
+ "enum": [
265
+ "playlists",
266
+ "charts",
267
+ "custom"
268
+ ]
269
+ },
270
+ "icon": {
271
+ "oneOf": [
272
+ {
273
+ "type": "object",
274
+ "properties": {
275
+ "kind": {
276
+ "const": "host"
277
+ },
278
+ "name": {
279
+ "type": "string",
280
+ "minLength": 1,
281
+ "maxLength": 4096
282
+ }
283
+ },
284
+ "required": [
285
+ "kind",
286
+ "name"
287
+ ],
288
+ "additionalProperties": false
289
+ },
290
+ {
291
+ "type": "object",
292
+ "properties": {
293
+ "kind": {
294
+ "const": "asset"
295
+ },
296
+ "resource": {
297
+ "type": "string",
298
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
299
+ }
300
+ },
301
+ "required": [
302
+ "kind",
303
+ "resource"
304
+ ],
305
+ "additionalProperties": false
306
+ }
307
+ ]
308
+ },
309
+ "view": {
310
+ "type": "string",
311
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
312
+ },
313
+ "providerIds": {
314
+ "type": "array",
315
+ "items": {
316
+ "type": "string",
317
+ "minLength": 1,
318
+ "maxLength": 4096
319
+ },
320
+ "maxItems": 128,
321
+ "uniqueItems": true
322
+ },
323
+ "order": {
324
+ "type": "integer",
325
+ "minimum": -1000,
326
+ "maximum": 1000
327
+ }
328
+ },
329
+ "required": [
330
+ "id",
331
+ "title",
332
+ "kind"
333
+ ],
334
+ "additionalProperties": false
335
+ }
336
+ },
337
+ "uiExtensions": {
338
+ "type": "array",
339
+ "maxItems": 64,
340
+ "items": {
341
+ "type": "object",
342
+ "properties": {
343
+ "id": {
344
+ "type": "string",
345
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
346
+ },
347
+ "slot": {
348
+ "enum": [
349
+ "home.header",
350
+ "home.content.before",
351
+ "home.content.after",
352
+ "search.source-selector.after",
353
+ "playlist.header.actions",
354
+ "playlist.item.actions",
355
+ "player.actions",
356
+ "settings.sections"
357
+ ]
358
+ },
359
+ "mode": {
360
+ "enum": [
361
+ "append",
362
+ "prepend",
363
+ "wrap",
364
+ "replace"
365
+ ]
366
+ },
367
+ "view": {
368
+ "type": "string",
369
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
370
+ },
371
+ "order": {
372
+ "type": "integer",
373
+ "minimum": -1000,
374
+ "maximum": 1000
375
+ },
376
+ "when": {
377
+ "type": "object",
378
+ "properties": {
379
+ "loggedIn": {
380
+ "type": "boolean"
381
+ },
382
+ "route": {
383
+ "type": "string",
384
+ "minLength": 1,
385
+ "maxLength": 4096
386
+ }
387
+ },
388
+ "required": [],
389
+ "additionalProperties": false
390
+ }
391
+ },
392
+ "required": [
393
+ "id",
394
+ "slot",
395
+ "mode",
396
+ "view"
397
+ ],
398
+ "additionalProperties": false
399
+ }
400
+ },
401
+ "styles": {
402
+ "type": "array",
403
+ "maxItems": 64,
404
+ "items": {
405
+ "type": "object",
406
+ "properties": {
407
+ "id": {
408
+ "type": "string",
409
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
410
+ },
411
+ "resource": {
412
+ "type": "string",
413
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
414
+ },
415
+ "scope": {
416
+ "enum": [
417
+ "surface",
418
+ "slot",
419
+ "application"
420
+ ]
421
+ },
422
+ "slots": {
423
+ "type": "array",
424
+ "maxItems": 16,
425
+ "items": {
426
+ "enum": [
427
+ "home.header",
428
+ "home.content.before",
429
+ "home.content.after",
430
+ "search.source-selector.after",
431
+ "playlist.header.actions",
432
+ "playlist.item.actions",
433
+ "player.actions",
434
+ "settings.sections"
435
+ ]
436
+ }
437
+ },
438
+ "order": {
439
+ "type": "integer",
440
+ "minimum": -1000,
441
+ "maximum": 1000
442
+ }
443
+ },
444
+ "required": [
445
+ "id",
446
+ "resource",
447
+ "scope"
448
+ ],
449
+ "additionalProperties": false
450
+ }
451
+ },
452
+ "playlistImporters": {
453
+ "type": "array",
454
+ "maxItems": 64,
455
+ "items": {
456
+ "type": "object",
457
+ "properties": {
458
+ "id": {
459
+ "type": "string",
460
+ "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$"
461
+ },
462
+ "title": {
463
+ "type": "string",
464
+ "minLength": 1,
465
+ "maxLength": 4096
466
+ },
467
+ "description": {
468
+ "type": "string",
469
+ "minLength": 1,
470
+ "maxLength": 4096
471
+ },
472
+ "placeholder": {
473
+ "type": "string",
474
+ "minLength": 1,
475
+ "maxLength": 4096
476
+ }
477
+ },
478
+ "required": [
479
+ "id",
480
+ "title"
481
+ ],
482
+ "additionalProperties": false
483
+ }
484
+ },
152
485
  "providers": {
153
486
  "type": "array",
154
487
  "maxItems": 64,
@@ -413,7 +746,21 @@
413
746
  },
414
747
  "name": {
415
748
  "enum": [
749
+ "account.profile",
750
+ "downloads.manage",
751
+ "localMusic.read",
752
+ "localMusic.write",
753
+ "settings.read",
754
+ "settings.write",
755
+ "window.control",
756
+ "hotkeys.register",
757
+ "rooms.read",
758
+ "rooms.control",
759
+ "ai.use",
760
+ "devices.control",
761
+ "ui.styles.global",
416
762
  "network.request",
763
+ "network.socket",
417
764
  "network.private",
418
765
  "network.discovery",
419
766
  "credentials.use",
@@ -580,6 +927,8 @@
580
927
  "default": "vanilla"
581
928
  },
582
929
  "sharedLibraries": {
930
+ "deprecated": true,
931
+ "description": "Legacy field ignored since 0.1.2. Vue and React production runtimes are bundled into the plugin.",
583
932
  "type": "object",
584
933
  "properties": {
585
934
  "vue": {
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
6
- ],
7
- "description": "使用宿主平台图标,无需打入插件"
4
+ "body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
5
+ "description": "使用宿主平台图标,无需打入插件",
8
6
  },
9
7
  "Host lodash": {
10
8
  "prefix": "ceru-lodash",
9
+ "body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
10
+ "description": "调用宿主的带类型 Lodash 工具",
11
+ },
12
+ "Host HTTP client": {
13
+ "prefix": "ceru-http",
14
+ "body": [
15
+ "const http = ctx.http.create({",
16
+ " baseURL: '${1:https://example.com}',",
17
+ " permissionKey: '${2:api}',",
18
+ " requestPermission: true,",
19
+ "})",
20
+ ],
21
+ "description": "使用宿主 Axios 代理;无需将请求库打入插件",
22
+ },
23
+ "Permission group": {
24
+ "prefix": "ceru-permission-group",
11
25
  "body": [
12
- "ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
31
+ "description": "一次申请一组用户可理解的能力",
32
+ },
33
+ "Grouped music provider": {
34
+ "prefix": "ceru-provider",
35
+ "body": [
36
+ "ctx.providers.register('${1:catalog}', {",
37
+ " tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
38
+ " playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
39
+ " charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
40
+ "})",
41
+ ],
42
+ "description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
15
43
  },
16
44
  "Source rate limit": {
17
45
  "prefix": "ceru-rate-limit",
@@ -20,8 +48,8 @@
20
48
  " code: 'RATE_LIMITED',",
21
49
  " message: '${1:请稍后重试}',",
22
50
  " recovery: { mode: 'await-user', maxWaitMs: 60000 }",
23
- "})"
51
+ "})",
24
52
  ],
25
- "description": "返回结构化限流结果,由 Host 决定换源与交互"
26
- }
53
+ "description": "返回结构化限流结果,由 Host 决定换源与交互",
54
+ },
27
55
  }
@@ -1,46 +1,36 @@
1
- {
2
- "version": "0.2.0",
3
- "configurations": [
4
- {
5
- "name": "Launch Ceru plugin",
6
- "type": "pwa-chrome",
7
- "request": "attach",
8
- "port": 9223,
9
- "preLaunchTask": "Ceru: dev",
10
- "webRoot": "${workspaceFolder}",
11
- "sourceMaps": true,
12
- "sourceMapPathOverrides": {
13
- "ceru:///*": "${workspaceFolder}/*"
14
- },
15
- "skipFiles": [
16
- "**/node_modules/**"
17
- ],
18
- "address": "127.0.0.1",
19
- "urlFilter": "http://127.0.0.1:4179/*",
20
- "targetTypes": [
21
- "page",
22
- "iframe"
23
- ]
24
- },
25
- {
26
- "name": "Attach to Ceru plugin",
27
- "type": "pwa-chrome",
28
- "request": "attach",
29
- "port": 9223,
30
- "webRoot": "${workspaceFolder}",
31
- "sourceMaps": true,
32
- "sourceMapPathOverrides": {
33
- "ceru:///*": "${workspaceFolder}/*"
34
- },
35
- "skipFiles": [
36
- "**/node_modules/**"
37
- ],
38
- "address": "127.0.0.1",
39
- "urlFilter": "http://127.0.0.1:4179/*",
40
- "targetTypes": [
41
- "page",
42
- "iframe"
43
- ]
44
- }
45
- ]
46
- }
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Launch Ceru plugin",
6
+ "type": "pwa-chrome",
7
+ "request": "attach",
8
+ "port": 9223,
9
+ "preLaunchTask": "Ceru: dev",
10
+ "webRoot": "${workspaceFolder}",
11
+ "sourceMaps": true,
12
+ "sourceMapPathOverrides": {
13
+ "ceru:///*": "${workspaceFolder}/*"
14
+ },
15
+ "skipFiles": ["**/node_modules/**"],
16
+ "address": "127.0.0.1",
17
+ "urlFilter": "http://127.0.0.1:4179/",
18
+ "timeout": 30000
19
+ },
20
+ {
21
+ "name": "Attach to Ceru plugin",
22
+ "type": "pwa-chrome",
23
+ "request": "attach",
24
+ "port": 9223,
25
+ "webRoot": "${workspaceFolder}",
26
+ "sourceMaps": true,
27
+ "sourceMapPathOverrides": {
28
+ "ceru:///*": "${workspaceFolder}/*"
29
+ },
30
+ "skipFiles": ["**/node_modules/**"],
31
+ "address": "127.0.0.1",
32
+ "urlFilter": "http://127.0.0.1:4179/",
33
+ "timeout": 30000
34
+ }
35
+ ]
36
+ }
@@ -3,8 +3,7 @@
3
3
  "tasks": [
4
4
  {
5
5
  "label": "Ceru: dev",
6
- "type": "npm",
7
- "script": "dev",
6
+ "type": "process",
8
7
  "isBackground": true,
9
8
  "problemMatcher": {
10
9
  "owner": "ceru",
@@ -15,8 +14,17 @@
15
14
  "background": {
16
15
  "activeOnStart": true,
17
16
  "beginsPattern": "^.*$",
18
- "endsPattern": "^Electron debugger:"
17
+ "endsPattern": "^CERU_DEBUG_READY "
19
18
  }
19
+ },
20
+ "command": "node",
21
+ "args": [
22
+ "${workspaceFolder}/node_modules/@shiqianjiang/ceru-plugin-cli/dist/bin.js",
23
+ "dev",
24
+ "--ensure-running"
25
+ ],
26
+ "options": {
27
+ "cwd": "${workspaceFolder}"
20
28
  }
21
29
  },
22
30
  {
@@ -26,8 +26,13 @@ VS Code 按 F5 选择 Launch Ceru plugin;已有调试窗口时选择 Attach to
26
26
  - 默认封面:await ctx.assets.url('placeholder.cover')。
27
27
  - 共享工具:ctx.utils.lodash。
28
28
 
29
- 框架模板默认使用声明过版本的宿主 Vue/React 生产运行时;开发编译器不进入插件。
30
- 若需要把生产运行时一起打包,可将 ceru.plugin.json 的 sharedLibraries 改为 {}。
29
+ Vue/React 的生产运行代码、页面和样式直接编入发行 JS,宿主不提供框架。
30
+ TypeScript、Vue 编译器、构建工具与开发服务器不会进入产物。
31
+ 运行 npm run preview 可只加载 dist/plugin.js 检查发布后的行为。
32
+
33
+ 若 VS Code 打开的是父目录,请打开本工程的 ceru-plugin.code-workspace,
34
+ 再在“运行和调试”中选择 Launch Ceru plugin;已经运行 npm/pnpm dev 时选择 Attach to Ceru plugin。
35
+ F5 执行当前下拉框中的配置,不会自动选择终端所在的子工程。
31
36
 
32
37
  ## 边界
33
38
 
@@ -0,0 +1,8 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": ".",
5
+ },
6
+ ],
7
+ "settings": {},
8
+ }
@@ -7,13 +7,14 @@
7
7
  "dev": "ceru-plugin dev",
8
8
  "build": "ceru-plugin build",
9
9
  "typecheck": "tsc --noEmit",
10
- "validate": "ceru-plugin validate dist/plugin.js"
10
+ "validate": "ceru-plugin validate dist/plugin.js",
11
+ "preview": "ceru-plugin preview dist/plugin.js"
11
12
  },
12
13
  "dependencies": {
13
- "@shiqianjiang/ceru-plugin-sdk": "^0.1.0"
14
+ "@shiqianjiang/ceru-plugin-sdk": "^0.2.0"
14
15
  },
15
16
  "devDependencies": {
16
- "@shiqianjiang/ceru-plugin-cli": "^0.1.0",
17
+ "@shiqianjiang/ceru-plugin-cli": "^0.2.0",
17
18
  "typescript": "~5.9.3",
18
19
  "electron": "^44.4.2",
19
20
  "prettier": "^3.6.2"
@@ -28,11 +28,13 @@ export default definePlugin(async (ctx) => {
28
28
  })
29
29
 
30
30
  ctx.providers.register('catalog', {
31
- async search() {
32
- return { items: [] }
33
- },
34
- async resolve() {
35
- return ctx.playback.failure({ code: 'UNSUPPORTED', message: '请接入真实音乐库 API' })
31
+ tracks: {
32
+ async search() {
33
+ return { items: [] }
34
+ },
35
+ async resolve() {
36
+ return ctx.playback.failure({ code: 'UNSUPPORTED', message: '请接入真实音乐库 API' })
37
+ },
36
38
  },
37
39
  })
38
40
  })
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "Host platform icon": {
3
3
  "prefix": "ceru-icon",
4
- "body": [
5
- "{ kind: 'host', name: 'platform.${1:tx}' }"
6
- ],
7
- "description": "使用宿主平台图标,无需打入插件"
4
+ "body": ["{ kind: 'host', name: 'platform.${1:tx}' }"],
5
+ "description": "使用宿主平台图标,无需打入插件",
8
6
  },
9
7
  "Host lodash": {
10
8
  "prefix": "ceru-lodash",
9
+ "body": ["ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"],
10
+ "description": "调用宿主的带类型 Lodash 工具",
11
+ },
12
+ "Host HTTP client": {
13
+ "prefix": "ceru-http",
14
+ "body": [
15
+ "const http = ctx.http.create({",
16
+ " baseURL: '${1:https://example.com}',",
17
+ " permissionKey: '${2:api}',",
18
+ " requestPermission: true,",
19
+ "})",
20
+ ],
21
+ "description": "使用宿主 Axios 代理;无需将请求库打入插件",
22
+ },
23
+ "Permission group": {
24
+ "prefix": "ceru-permission-group",
11
25
  "body": [
12
- "ctx.utils.lodash.${1:uniqBy}(${2:items}, ${3:key})"
26
+ "const permission = await ctx.permissions.requestGroup({",
27
+ " group: '${1:libraryRead}',",
28
+ " intent: operation.userIntent,",
29
+ "})",
13
30
  ],
14
- "description": "调用宿主的带类型 Lodash 工具"
31
+ "description": "一次申请一组用户可理解的能力",
32
+ },
33
+ "Grouped music provider": {
34
+ "prefix": "ceru-provider",
35
+ "body": [
36
+ "ctx.providers.register('${1:catalog}', {",
37
+ " tracks: { search: ${2:searchTracks}, resolve: ${3:resolveTrack}, lyrics: ${4:getLyrics} },",
38
+ " playlists: { search: ${5:searchPlaylists}, categories: ${6:getCategories}, list: ${7:listPlaylists}, get: ${8:getPlaylist} },",
39
+ " charts: { list: ${9:listCharts}, getTracks: ${10:getChartTracks} },",
40
+ "})",
41
+ ],
42
+ "description": "注册分组 Provider,返回标准歌曲/歌单/歌词 JSON",
15
43
  },
16
44
  "Source rate limit": {
17
45
  "prefix": "ceru-rate-limit",
@@ -20,8 +48,8 @@
20
48
  " code: 'RATE_LIMITED',",
21
49
  " message: '${1:请稍后重试}',",
22
50
  " recovery: { mode: 'await-user', maxWaitMs: 60000 }",
23
- "})"
51
+ "})",
24
52
  ],
25
- "description": "返回结构化限流结果,由 Host 决定换源与交互"
26
- }
53
+ "description": "返回结构化限流结果,由 Host 决定换源与交互",
54
+ },
27
55
  }