@shiqianjiang/ceru-plugin-cli 0.3.15 → 3.0.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 (302) hide show
  1. package/README.md +26 -7
  2. package/assets/compatibility.json +18 -0
  3. package/dist/compatibility.d.ts +24 -0
  4. package/dist/compatibility.js +119 -0
  5. package/dist/component.d.ts +6 -0
  6. package/dist/component.js +60 -0
  7. package/dist/dev-music.d.ts +19 -0
  8. package/dist/dev-music.js +81 -0
  9. package/dist/dev-plugin-services.d.ts +10 -0
  10. package/dist/dev-plugin-services.js +67 -0
  11. package/dist/dev.d.ts +1 -9
  12. package/dist/dev.js +53 -713
  13. package/dist/frameworks.d.ts +5 -2
  14. package/dist/frameworks.js +43 -6
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +54 -23
  17. package/dist/init.js +3 -3
  18. package/dist/migrate.d.ts +3 -0
  19. package/dist/migrate.js +109 -0
  20. package/dist/project.d.ts +5 -2
  21. package/dist/project.js +131 -43
  22. package/dist/test-hooks.d.ts +1 -0
  23. package/dist/test-hooks.js +209 -0
  24. package/dist/test-services.d.ts +4 -0
  25. package/dist/test-services.js +54 -0
  26. package/dist/watch-vue-types.d.ts +17 -0
  27. package/dist/watch-vue-types.js +145 -0
  28. package/package.json +10 -6
  29. package/schemas/config.schema.json +954 -452
  30. package/templates/account-qrcode/js/.vscode/extensions.json +3 -0
  31. package/templates/account-qrcode/js/.vscode/launch.json +19 -0
  32. package/templates/account-qrcode/js/.vscode/settings.json +20 -0
  33. package/templates/account-qrcode/js/.vscode/tasks.json +43 -0
  34. package/templates/account-qrcode/js/README.md +15 -0
  35. package/templates/account-qrcode/js/_gitignore +6 -0
  36. package/templates/account-qrcode/js/ceru-plugin.code-workspace +8 -0
  37. package/templates/account-qrcode/js/ceru.plugin.json +62 -0
  38. package/templates/account-qrcode/js/package.json +24 -0
  39. package/templates/account-qrcode/js/src/Login.vue +25 -0
  40. package/templates/account-qrcode/js/src/index.js +25 -0
  41. package/templates/account-qrcode/js/src/login-html.js +23 -0
  42. package/templates/account-qrcode/js/tsconfig.json +17 -0
  43. package/templates/account-qrcode/ts/.vscode/extensions.json +3 -0
  44. package/templates/account-qrcode/ts/.vscode/launch.json +19 -0
  45. package/templates/account-qrcode/ts/.vscode/settings.json +20 -0
  46. package/templates/account-qrcode/ts/.vscode/tasks.json +43 -0
  47. package/templates/account-qrcode/ts/README.md +15 -0
  48. package/templates/account-qrcode/ts/_gitignore +6 -0
  49. package/templates/account-qrcode/ts/ceru-plugin.code-workspace +8 -0
  50. package/templates/account-qrcode/ts/ceru.plugin.json +62 -0
  51. package/templates/account-qrcode/ts/package.json +24 -0
  52. package/templates/account-qrcode/ts/src/Login.vue +25 -0
  53. package/templates/account-qrcode/ts/src/index.ts +25 -0
  54. package/templates/account-qrcode/ts/src/login-html.ts +23 -0
  55. package/templates/account-qrcode/ts/tsconfig.json +17 -0
  56. package/templates/connected-library/js/.vscode/launch.json +12 -29
  57. package/templates/connected-library/js/.vscode/tasks.json +2 -3
  58. package/templates/connected-library/js/README.md +26 -12
  59. package/templates/connected-library/js/ceru.plugin.json +122 -50
  60. package/templates/connected-library/js/package.json +5 -5
  61. package/templates/connected-library/js/src/index.js +46 -5
  62. package/templates/connected-library/js/src/settings.js +28 -0
  63. package/templates/connected-library/ts/.vscode/launch.json +12 -29
  64. package/templates/connected-library/ts/.vscode/tasks.json +2 -3
  65. package/templates/connected-library/ts/README.md +26 -12
  66. package/templates/connected-library/ts/ceru.plugin.json +122 -50
  67. package/templates/connected-library/ts/package.json +5 -5
  68. package/templates/connected-library/ts/src/index.ts +46 -5
  69. package/templates/connected-library/ts/src/settings.ts +28 -0
  70. package/templates/encrypted-source/README.md +86 -0
  71. package/templates/encrypted-source/js/.prettierrc.json +5 -0
  72. package/templates/encrypted-source/js/.vscode/ceru.code-snippets +55 -0
  73. package/templates/encrypted-source/js/.vscode/extensions.json +3 -0
  74. package/templates/encrypted-source/js/.vscode/launch.json +15 -0
  75. package/templates/encrypted-source/js/.vscode/settings.json +20 -0
  76. package/templates/encrypted-source/js/.vscode/tasks.json +40 -0
  77. package/templates/encrypted-source/js/DEMO.md +77 -0
  78. package/templates/encrypted-source/js/README.md +13 -0
  79. package/templates/encrypted-source/js/_gitignore +6 -0
  80. package/templates/encrypted-source/js/ceru-plugin.code-workspace +8 -0
  81. package/templates/encrypted-source/js/ceru.plugin.json +95 -0
  82. package/templates/encrypted-source/js/package.json +26 -0
  83. package/templates/encrypted-source/js/resources/xor-byte.wasm +0 -0
  84. package/templates/encrypted-source/js/resources/xor-byte.wat +5 -0
  85. package/templates/encrypted-source/js/src/demo.js +200 -0
  86. package/templates/encrypted-source/js/src/fixtures.js +118 -0
  87. package/templates/encrypted-source/js/src/index.js +4 -0
  88. package/templates/encrypted-source/js/tests/demo.test.mjs +357 -0
  89. package/templates/encrypted-source/js/tsconfig.json +16 -0
  90. package/templates/encrypted-source/ts/.prettierrc.json +5 -0
  91. package/templates/encrypted-source/ts/.vscode/ceru.code-snippets +55 -0
  92. package/templates/encrypted-source/ts/.vscode/extensions.json +3 -0
  93. package/templates/encrypted-source/ts/.vscode/launch.json +15 -0
  94. package/templates/encrypted-source/ts/.vscode/settings.json +20 -0
  95. package/templates/encrypted-source/ts/.vscode/tasks.json +40 -0
  96. package/templates/encrypted-source/ts/DEMO.md +77 -0
  97. package/templates/encrypted-source/ts/README.md +13 -0
  98. package/templates/encrypted-source/ts/_gitignore +6 -0
  99. package/templates/encrypted-source/ts/ceru-plugin.code-workspace +8 -0
  100. package/templates/encrypted-source/ts/ceru.plugin.json +95 -0
  101. package/templates/encrypted-source/ts/package.json +26 -0
  102. package/templates/encrypted-source/ts/resources/xor-byte.wasm +0 -0
  103. package/templates/encrypted-source/ts/resources/xor-byte.wat +5 -0
  104. package/templates/encrypted-source/ts/src/demo.ts +212 -0
  105. package/templates/encrypted-source/ts/src/fixtures.ts +125 -0
  106. package/templates/encrypted-source/ts/src/index.ts +4 -0
  107. package/templates/encrypted-source/ts/tests/demo.test.mjs +357 -0
  108. package/templates/encrypted-source/ts/tsconfig.json +17 -0
  109. package/templates/guest-adapter/js/.vscode/launch.json +12 -29
  110. package/templates/guest-adapter/js/.vscode/tasks.json +2 -3
  111. package/templates/guest-adapter/js/README.md +10 -10
  112. package/templates/guest-adapter/js/ceru.plugin.json +67 -62
  113. package/templates/guest-adapter/js/package.json +5 -5
  114. package/templates/guest-adapter/js/src/index.js +1 -1
  115. package/templates/guest-adapter/js/src/settings.js +8 -0
  116. package/templates/guest-adapter/ts/.vscode/launch.json +12 -29
  117. package/templates/guest-adapter/ts/.vscode/tasks.json +2 -3
  118. package/templates/guest-adapter/ts/README.md +10 -10
  119. package/templates/guest-adapter/ts/ceru.plugin.json +67 -62
  120. package/templates/guest-adapter/ts/package.json +5 -5
  121. package/templates/guest-adapter/ts/src/index.ts +1 -1
  122. package/templates/guest-adapter/ts/src/settings.ts +8 -0
  123. package/templates/importer/js/.vscode/launch.json +12 -29
  124. package/templates/importer/js/.vscode/tasks.json +2 -3
  125. package/templates/importer/js/README.md +10 -10
  126. package/templates/importer/js/ceru.plugin.json +23 -21
  127. package/templates/importer/js/package.json +5 -5
  128. package/templates/importer/ts/.vscode/launch.json +12 -29
  129. package/templates/importer/ts/.vscode/tasks.json +2 -3
  130. package/templates/importer/ts/README.md +10 -10
  131. package/templates/importer/ts/ceru.plugin.json +23 -21
  132. package/templates/importer/ts/package.json +5 -5
  133. package/templates/page-extension/js/.vscode/extensions.json +3 -0
  134. package/templates/page-extension/js/.vscode/launch.json +19 -0
  135. package/templates/page-extension/js/.vscode/settings.json +20 -0
  136. package/templates/page-extension/js/.vscode/tasks.json +43 -0
  137. package/templates/page-extension/js/README.md +9 -0
  138. package/templates/page-extension/js/_gitignore +6 -0
  139. package/templates/page-extension/js/ceru-plugin.code-workspace +8 -0
  140. package/templates/page-extension/js/ceru.plugin.json +94 -0
  141. package/templates/page-extension/js/package.json +24 -0
  142. package/templates/page-extension/js/src/Open.vue +6 -0
  143. package/templates/page-extension/js/src/Search.vue +62 -0
  144. package/templates/page-extension/js/src/index.js +54 -0
  145. package/templates/page-extension/js/tsconfig.json +17 -0
  146. package/templates/page-extension/ts/.vscode/extensions.json +3 -0
  147. package/templates/page-extension/ts/.vscode/launch.json +19 -0
  148. package/templates/page-extension/ts/.vscode/settings.json +20 -0
  149. package/templates/page-extension/ts/.vscode/tasks.json +43 -0
  150. package/templates/page-extension/ts/README.md +9 -0
  151. package/templates/page-extension/ts/_gitignore +6 -0
  152. package/templates/page-extension/ts/ceru-plugin.code-workspace +8 -0
  153. package/templates/page-extension/ts/ceru.plugin.json +94 -0
  154. package/templates/page-extension/ts/package.json +24 -0
  155. package/templates/page-extension/ts/src/Open.vue +6 -0
  156. package/templates/page-extension/ts/src/Search.vue +62 -0
  157. package/templates/page-extension/ts/src/index.ts +54 -0
  158. package/templates/page-extension/ts/tsconfig.json +17 -0
  159. package/templates/playback-hook/js/.prettierrc.json +5 -0
  160. package/templates/playback-hook/js/.vscode/extensions.json +3 -0
  161. package/templates/playback-hook/js/.vscode/launch.json +19 -0
  162. package/templates/playback-hook/js/.vscode/settings.json +20 -0
  163. package/templates/playback-hook/js/.vscode/tasks.json +50 -0
  164. package/templates/playback-hook/js/README.md +24 -0
  165. package/templates/playback-hook/js/_gitignore +6 -0
  166. package/templates/playback-hook/js/ceru-plugin.code-workspace +8 -0
  167. package/templates/playback-hook/js/ceru.plugin.json +36 -0
  168. package/templates/playback-hook/js/package.json +23 -0
  169. package/templates/playback-hook/js/src/index.js +25 -0
  170. package/templates/playback-hook/js/tests/hooks.json +316 -0
  171. package/templates/playback-hook/js/tsconfig.json +16 -0
  172. package/templates/playback-hook/ts/.prettierrc.json +5 -0
  173. package/templates/playback-hook/ts/.vscode/extensions.json +3 -0
  174. package/templates/playback-hook/ts/.vscode/launch.json +19 -0
  175. package/templates/playback-hook/ts/.vscode/settings.json +20 -0
  176. package/templates/playback-hook/ts/.vscode/tasks.json +50 -0
  177. package/templates/playback-hook/ts/README.md +24 -0
  178. package/templates/playback-hook/ts/_gitignore +6 -0
  179. package/templates/playback-hook/ts/ceru-plugin.code-workspace +8 -0
  180. package/templates/playback-hook/ts/ceru.plugin.json +36 -0
  181. package/templates/playback-hook/ts/package.json +23 -0
  182. package/templates/playback-hook/ts/src/index.ts +25 -0
  183. package/templates/playback-hook/ts/tests/hooks.json +316 -0
  184. package/templates/playback-hook/ts/tsconfig.json +16 -0
  185. package/templates/player-skin/js/.vscode/extensions.json +3 -0
  186. package/templates/player-skin/js/.vscode/launch.json +19 -0
  187. package/templates/player-skin/js/.vscode/settings.json +20 -0
  188. package/templates/player-skin/js/.vscode/tasks.json +43 -0
  189. package/templates/player-skin/js/README.md +11 -0
  190. package/templates/player-skin/js/_gitignore +6 -0
  191. package/templates/player-skin/js/assets/studio-preview.svg +15 -0
  192. package/templates/player-skin/js/ceru-plugin.code-workspace +8 -0
  193. package/templates/player-skin/js/ceru.plugin.json +77 -0
  194. package/templates/player-skin/js/package.json +24 -0
  195. package/templates/player-skin/js/src/Artwork.vue +9 -0
  196. package/templates/player-skin/js/src/Background.vue +15 -0
  197. package/templates/player-skin/js/src/BuiltinLyrics.vue +15 -0
  198. package/templates/player-skin/js/src/Lyrics.vue +28 -0
  199. package/templates/player-skin/js/tsconfig.json +17 -0
  200. package/templates/player-skin/ts/.vscode/extensions.json +3 -0
  201. package/templates/player-skin/ts/.vscode/launch.json +19 -0
  202. package/templates/player-skin/ts/.vscode/settings.json +20 -0
  203. package/templates/player-skin/ts/.vscode/tasks.json +43 -0
  204. package/templates/player-skin/ts/README.md +11 -0
  205. package/templates/player-skin/ts/_gitignore +6 -0
  206. package/templates/player-skin/ts/assets/studio-preview.svg +15 -0
  207. package/templates/player-skin/ts/ceru-plugin.code-workspace +8 -0
  208. package/templates/player-skin/ts/ceru.plugin.json +77 -0
  209. package/templates/player-skin/ts/package.json +24 -0
  210. package/templates/player-skin/ts/src/Artwork.vue +9 -0
  211. package/templates/player-skin/ts/src/Background.vue +15 -0
  212. package/templates/player-skin/ts/src/BuiltinLyrics.vue +15 -0
  213. package/templates/player-skin/ts/src/Lyrics.vue +28 -0
  214. package/templates/player-skin/ts/tsconfig.json +17 -0
  215. package/templates/react/js/.vscode/launch.json +12 -29
  216. package/templates/react/js/.vscode/tasks.json +2 -3
  217. package/templates/react/js/README.md +10 -10
  218. package/templates/react/js/ceru.plugin.json +27 -22
  219. package/templates/react/js/package.json +5 -5
  220. package/templates/react/js/src/index.js +1 -1
  221. package/templates/react/ts/.vscode/launch.json +12 -29
  222. package/templates/react/ts/.vscode/tasks.json +2 -3
  223. package/templates/react/ts/README.md +10 -10
  224. package/templates/react/ts/ceru.plugin.json +27 -22
  225. package/templates/react/ts/package.json +5 -5
  226. package/templates/react/ts/src/index.ts +1 -1
  227. package/templates/snapshot.json +152 -6
  228. package/templates/source/js/.vscode/launch.json +12 -29
  229. package/templates/source/js/.vscode/tasks.json +2 -3
  230. package/templates/source/js/README.md +12 -10
  231. package/templates/source/js/ceru.plugin.json +44 -26
  232. package/templates/source/js/package.json +5 -5
  233. package/templates/source/js/src/index.js +10 -8
  234. package/templates/source/ts/.vscode/launch.json +12 -29
  235. package/templates/source/ts/.vscode/tasks.json +2 -3
  236. package/templates/source/ts/README.md +12 -10
  237. package/templates/source/ts/ceru.plugin.json +44 -26
  238. package/templates/source/ts/package.json +5 -5
  239. package/templates/source/ts/src/index.ts +10 -8
  240. package/templates/vue/js/.vscode/launch.json +12 -29
  241. package/templates/vue/js/.vscode/tasks.json +2 -3
  242. package/templates/vue/js/README.md +10 -10
  243. package/templates/vue/js/ceru.plugin.json +27 -22
  244. package/templates/vue/js/package.json +5 -5
  245. package/templates/vue/js/src/index.js +1 -1
  246. package/templates/vue/ts/.vscode/launch.json +12 -29
  247. package/templates/vue/ts/.vscode/tasks.json +2 -3
  248. package/templates/vue/ts/README.md +10 -10
  249. package/templates/vue/ts/ceru.plugin.json +27 -22
  250. package/templates/vue/ts/package.json +5 -5
  251. package/templates/vue/ts/src/index.ts +1 -1
  252. package/templates/vue-tsx/js/.vscode/launch.json +12 -29
  253. package/templates/vue-tsx/js/.vscode/tasks.json +2 -3
  254. package/templates/vue-tsx/js/README.md +10 -10
  255. package/templates/vue-tsx/js/ceru.plugin.json +27 -22
  256. package/templates/vue-tsx/js/package.json +5 -5
  257. package/templates/vue-tsx/js/src/index.js +1 -1
  258. package/templates/vue-tsx/ts/.vscode/launch.json +12 -29
  259. package/templates/vue-tsx/ts/.vscode/tasks.json +2 -3
  260. package/templates/vue-tsx/ts/README.md +10 -10
  261. package/templates/vue-tsx/ts/ceru.plugin.json +27 -22
  262. package/templates/vue-tsx/ts/package.json +5 -5
  263. package/templates/vue-tsx/ts/src/index.ts +1 -1
  264. package/templates/web-dist/js/.vscode/launch.json +12 -29
  265. package/templates/web-dist/js/.vscode/tasks.json +2 -3
  266. package/templates/web-dist/js/README.md +10 -10
  267. package/templates/web-dist/js/ceru.plugin.json +27 -22
  268. package/templates/web-dist/js/package.json +5 -5
  269. package/templates/web-dist/js/src/index.js +1 -1
  270. package/templates/web-dist/ts/.vscode/launch.json +12 -29
  271. package/templates/web-dist/ts/.vscode/tasks.json +2 -3
  272. package/templates/web-dist/ts/README.md +10 -10
  273. package/templates/web-dist/ts/ceru.plugin.json +27 -22
  274. package/templates/web-dist/ts/package.json +5 -5
  275. package/templates/web-dist/ts/src/index.ts +1 -1
  276. package/templates/web-surface/js/.vscode/launch.json +12 -29
  277. package/templates/web-surface/js/.vscode/tasks.json +2 -3
  278. package/templates/web-surface/js/README.md +10 -10
  279. package/templates/web-surface/js/ceru.plugin.json +35 -35
  280. package/templates/web-surface/js/package.json +5 -5
  281. package/templates/web-surface/js/src/index.js +1 -1
  282. package/templates/web-surface/ts/.vscode/launch.json +12 -29
  283. package/templates/web-surface/ts/.vscode/tasks.json +2 -3
  284. package/templates/web-surface/ts/README.md +10 -10
  285. package/templates/web-surface/ts/ceru.plugin.json +35 -35
  286. package/templates/web-surface/ts/package.json +5 -5
  287. package/templates/web-surface/ts/src/index.ts +1 -1
  288. package/assets/core-contracts.js +0 -1
  289. package/assets/electron-app/main.cjs +0 -1
  290. package/assets/electron-app/package.json +0 -8
  291. package/assets/electron.cjs +0 -42
  292. package/assets/index.html +0 -94
  293. package/assets/native-view.js +0 -197
  294. package/assets/playground.js +0 -883
  295. package/assets/sandbox.js +0 -67
  296. package/assets/style.css +0 -337
  297. package/dist/socket-broker.d.ts +0 -23
  298. package/dist/socket-broker.js +0 -229
  299. package/templates/connected-library/js/ui/settings.json +0 -24
  300. package/templates/connected-library/ts/ui/settings.json +0 -24
  301. package/templates/guest-adapter/js/ui/settings.json +0 -14
  302. package/templates/guest-adapter/ts/ui/settings.json +0 -14
package/assets/style.css DELETED
@@ -1,337 +0,0 @@
1
- :root {
2
- color-scheme: dark;
3
- --bg: #101713;
4
- --panel: #19221c;
5
- --line: #2c3b31;
6
- --text: #eaf3ed;
7
- --muted: #9aaa9f;
8
- --green: #98ddb0;
9
- }
10
- * {
11
- box-sizing: border-box;
12
- }
13
- body {
14
- margin: 0;
15
- background: var(--bg);
16
- color: var(--text);
17
- font:
18
- 14px/1.55 system-ui,
19
- 'Microsoft YaHei',
20
- sans-serif;
21
- }
22
- header {
23
- padding: 28px 32px;
24
- display: flex;
25
- align-items: center;
26
- justify-content: space-between;
27
- border-bottom: 1px solid var(--line);
28
- }
29
- h1 {
30
- font-size: 26px;
31
- margin: 8px 0 4px;
32
- }
33
- h2 {
34
- font-size: 14px;
35
- margin: 0 0 14px;
36
- letter-spacing: 0.04em;
37
- }
38
- p {
39
- margin: 4px 0 12px;
40
- }
41
- .badge {
42
- font-size: 11px;
43
- color: var(--green);
44
- letter-spacing: 0.16em;
45
- }
46
- .header-actions,
47
- .row {
48
- display: flex;
49
- gap: 8px;
50
- align-items: center;
51
- }
52
- .status {
53
- font-size: 12px;
54
- color: var(--green);
55
- margin-right: 14px;
56
- }
57
- main {
58
- display: grid;
59
- grid-template-columns: 270px minmax(380px, 1fr) 320px;
60
- gap: 16px;
61
- padding: 20px 24px;
62
- }
63
- section {
64
- background: var(--panel);
65
- border: 1px solid var(--line);
66
- border-radius: 12px;
67
- padding: 18px;
68
- margin-bottom: 16px;
69
- }
70
- button,
71
- input,
72
- select,
73
- textarea {
74
- font: inherit;
75
- color: var(--text);
76
- border: 1px solid #405346;
77
- border-radius: 7px;
78
- background: #202e25;
79
- padding: 8px 10px;
80
- }
81
- button {
82
- cursor: pointer;
83
- }
84
- button:hover {
85
- background: #31493a;
86
- }
87
- button.primary {
88
- background: var(--green);
89
- color: #15231b;
90
- border-color: var(--green);
91
- }
92
- button:disabled {
93
- opacity: 0.45;
94
- cursor: default;
95
- }
96
- input {
97
- min-width: 0;
98
- flex: 1;
99
- }
100
- select {
101
- max-width: 180px;
102
- }
103
- textarea {
104
- width: 100%;
105
- min-height: 130px;
106
- font:
107
- 12px/1.6 ui-monospace,
108
- monospace;
109
- resize: vertical;
110
- }
111
- aside button {
112
- margin: 4px 0;
113
- }
114
- .account-item { position: relative; }
115
- .account-logout {
116
- display: none;
117
- position: absolute;
118
- left: 100%;
119
- top: 0;
120
- z-index: 5;
121
- white-space: nowrap;
122
- }
123
- .account-item:hover .account-logout:not([hidden]),
124
- .account-item:focus-within .account-logout:not([hidden]) { display: block; }
125
- aside .item {
126
- display: flex;
127
- align-items: center;
128
- gap: 8px;
129
- margin: 10px 0;
130
- }
131
- .permission-group {
132
- display: flex;
133
- align-items: center;
134
- justify-content: space-between;
135
- gap: 8px;
136
- margin: 16px 0 6px;
137
- padding-top: 12px;
138
- border-top: 1px solid var(--line);
139
- }
140
- .hint {
141
- font-size: 12px;
142
- color: var(--muted);
143
- }
144
- .empty {
145
- padding: 28px 12px;
146
- text-align: center;
147
- color: var(--muted);
148
- }
149
- pre {
150
- font:
151
- 12px/1.65 ui-monospace,
152
- monospace;
153
- white-space: pre-wrap;
154
- overflow-wrap: anywhere;
155
- max-height: 260px;
156
- overflow: auto;
157
- color: #c4ddcd;
158
- }
159
- .results .track {
160
- display: flex;
161
- align-items: center;
162
- justify-content: space-between;
163
- gap: 12px;
164
- padding: 12px 0;
165
- border-bottom: 1px solid var(--line);
166
- }
167
- .icons {
168
- display: grid;
169
- grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
170
- gap: 8px;
171
- }
172
- .icon-card {
173
- text-align: center;
174
- background: #223127;
175
- border-radius: 8px;
176
- padding: 12px 5px;
177
- font-size: 10px;
178
- color: var(--muted);
179
- }
180
- .icon-card img {
181
- display: block;
182
- width: 26px;
183
- height: 26px;
184
- margin: 0 auto 8px;
185
- }
186
- .static-assets {
187
- display: flex;
188
- gap: 20px;
189
- margin-top: 16px;
190
- }
191
- .static-assets img {
192
- width: 48px;
193
- height: 48px;
194
- object-fit: contain;
195
- border-radius: 6px;
196
- }
197
- .preview {
198
- min-height: 150px;
199
- }
200
- .native-actions {
201
- display: flex;
202
- flex-wrap: wrap;
203
- gap: 8px;
204
- margin: 8px 0;
205
- }
206
- .native-section { margin: 20px 0; }
207
- .native-grid {
208
- display: grid;
209
- grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
210
- gap: 20px;
211
- }
212
- .native-item { min-width: 0; }
213
- .native-item-title {
214
- display: block;
215
- padding: 0;
216
- margin: 8px 0;
217
- border: 0;
218
- text-align: left;
219
- background: transparent;
220
- color: inherit;
221
- }
222
- .native-item .hint {
223
- overflow: hidden;
224
- display: -webkit-box;
225
- -webkit-box-orient: vertical;
226
- -webkit-line-clamp: 2;
227
- }
228
- .native-artwork {
229
- display: block;
230
- width: 100%;
231
- aspect-ratio: 1;
232
- object-fit: cover;
233
- border-radius: 8px;
234
- background: var(--line);
235
- }
236
- .native-list .native-item {
237
- display: flex;
238
- justify-content: space-between;
239
- align-items: center;
240
- gap: 16px;
241
- border-bottom: 1px solid var(--line);
242
- padding: 10px 0;
243
- }
244
- .native-list .native-item-content { display: flex; gap: 12px; align-items: center; }
245
- .native-list .native-artwork { width: 48px; flex-shrink: 0; }
246
- .preview iframe {
247
- width: 100%;
248
- min-height: 280px;
249
- background: white;
250
- border: 0;
251
- border-radius: 8px;
252
- }
253
- .preview label {
254
- display: block;
255
- margin: 10px 0;
256
- }
257
- .preview label input {
258
- display: block;
259
- width: 100%;
260
- }
261
- .host-content-preview {
262
- margin: 12px 0;
263
- padding: 24px;
264
- border: 1px dashed var(--green);
265
- border-radius: 8px;
266
- color: var(--muted);
267
- }
268
- .log-column {
269
- position: sticky;
270
- top: 16px;
271
- max-height: calc(100vh - 30px);
272
- overflow: auto;
273
- }
274
- .log-column h2 {
275
- flex: 1;
276
- margin: 0;
277
- }
278
- .log {
279
- font:
280
- 11px/1.7 ui-monospace,
281
- monospace;
282
- border-bottom: 1px solid var(--line);
283
- padding: 10px 0;
284
- white-space: pre-wrap;
285
- overflow-wrap: anywhere;
286
- }
287
- .log .time {
288
- color: var(--muted);
289
- }
290
- .log.error {
291
- color: #ffb0a7;
292
- }
293
- .log.warn {
294
- color: #ecd398;
295
- }
296
- .hidden {
297
- display: none !important;
298
- }
299
- .error {
300
- background: #542e29;
301
- color: #ffd2cc;
302
- padding: 16px;
303
- white-space: pre-wrap;
304
- margin: 12px 24px;
305
- border-radius: 10px;
306
- }
307
- .permission {
308
- padding: 10px 0;
309
- border-bottom: 1px solid var(--line);
310
- }
311
- .permission input {
312
- width: 100%;
313
- margin: 5px 0;
314
- }
315
- .permission small {
316
- display: block;
317
- color: var(--muted);
318
- }
319
- footer {
320
- padding: 12px 28px 24px;
321
- color: var(--muted);
322
- font-size: 11px;
323
- }
324
- code {
325
- font-family: ui-monospace, monospace;
326
- color: var(--green);
327
- }
328
- @media (max-width: 1150px) {
329
- main {
330
- grid-template-columns: 230px 1fr;
331
- }
332
- .log-column {
333
- grid-column: 1/-1;
334
- position: static;
335
- max-height: 350px;
336
- }
337
- }
@@ -1,23 +0,0 @@
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 {};
@@ -1,229 +0,0 @@
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] >= 224 ||
24
- (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) ||
25
- (parts[0] === 192 && parts[1] === 168));
26
- };
27
- const reservedEvents = new Set([
28
- 'connect',
29
- 'connect_error',
30
- 'disconnect',
31
- 'disconnecting',
32
- 'newListener',
33
- 'removeListener',
34
- 'error',
35
- '__proto__',
36
- 'constructor',
37
- 'prototype',
38
- ]);
39
- /** Network libraries live in the Host. Plugins receive bounded JSON events and opaque handles. */
40
- export class SocketBroker {
41
- connections = new Map();
42
- events = [];
43
- generation = 0;
44
- connecting = 0;
45
- async connect(input, privateAllowed, reservedPorts) {
46
- if (this.connections.size + this.connecting >= 8)
47
- throw new Error('Socket connection limit reached');
48
- this.connecting++;
49
- const generation = this.generation;
50
- try {
51
- const kind = input.kind;
52
- if (!['websocket', 'socket.io'].includes(kind))
53
- throw new Error('Unknown socket protocol');
54
- const url = new URL(input.url);
55
- if (url.username ||
56
- url.password ||
57
- url.hash ||
58
- (kind === 'websocket'
59
- ? !['ws:', 'wss:'].includes(url.protocol)
60
- : !['http:', 'https:'].includes(url.protocol)))
61
- throw new Error('Unsupported socket URL');
62
- const path = kind === 'socket.io' ? String(input.path || '/socket.io/') : url.pathname;
63
- if (!path.startsWith('/') || path.startsWith('//') || /[?#\\]|%(?:2f|5c)/i.test(path))
64
- throw new Error('Invalid socket path');
65
- const hostname = url.hostname.replace(/^\[|\]$/g, '');
66
- const addresses = isIP(hostname)
67
- ? [{ address: hostname, family: isIP(hostname) }]
68
- : await lookup(hostname, { all: true });
69
- if (!addresses.length)
70
- throw new Error('No socket address found');
71
- if (addresses.some((item) => privateAddress(item.address)) && !privateAllowed)
72
- throw new Error('Private network access is not granted');
73
- const defaultPort = ['https:', 'wss:'].includes(url.protocol) ? 443 : 80;
74
- if (reservedPorts.includes(Number(url.port) || defaultPort))
75
- throw new Error('Development ports are reserved');
76
- const chosen = addresses[0];
77
- const Agent = ['https:', 'wss:'].includes(url.protocol) ? HttpsAgent : HttpAgent;
78
- const agent = new Agent({
79
- lookup: ((_hostname, options, callback) => options?.all
80
- ? callback(null, [chosen])
81
- : callback(null, chosen.address, chosen.family)),
82
- });
83
- const id = randomUUID();
84
- let socket;
85
- if (kind === 'socket.io') {
86
- const auth = input.auth ?? {};
87
- if (Buffer.byteLength(JSON.stringify(auth)) > 16384) {
88
- agent.destroy();
89
- throw new Error('Socket auth is too large');
90
- }
91
- socket = io(url.href, {
92
- path,
93
- auth,
94
- autoConnect: false,
95
- forceNew: true,
96
- transports: ['websocket'],
97
- upgrade: false,
98
- reconnection: input.reconnection !== false,
99
- reconnectionAttempts: 5,
100
- reconnectionDelay: 1000,
101
- reconnectionDelayMax: 10000,
102
- timeout: 10000,
103
- transportOptions: { websocket: { agent, followRedirects: false, maxPayload: 65536 } },
104
- });
105
- socket.on('connect', () => this.push(id, 'connect', null));
106
- socket.on('disconnect', (reason) => this.push(id, 'disconnect', reason));
107
- socket.on('connect_error', () => this.push(id, 'error', 'Socket.IO connection failed'));
108
- socket.onAny((event, ...args) => this.push(id, String(event), args));
109
- }
110
- else {
111
- socket = new WebSocket(url.href, {
112
- agent,
113
- followRedirects: false,
114
- handshakeTimeout: 10000,
115
- maxPayload: 65536,
116
- });
117
- socket.on('open', () => this.push(id, 'connect', null));
118
- socket.on('close', (code) => {
119
- this.push(id, 'disconnect', { code });
120
- this.release(id);
121
- });
122
- socket.on('error', () => this.push(id, 'error', 'WebSocket connection failed'));
123
- socket.on('message', (data, binary) => {
124
- if (binary) {
125
- this.push(id, 'error', 'Binary frames are not supported by this JSON channel');
126
- return;
127
- }
128
- this.push(id, 'message', data.toString());
129
- });
130
- }
131
- this.connections.set(id, {
132
- key: String(input.permissionKey),
133
- kind,
134
- socket,
135
- agent,
136
- lastSend: Date.now(),
137
- sends: 0,
138
- });
139
- if (generation !== this.generation) {
140
- this.disconnect(id);
141
- throw new Error('Plugin was stopped while connecting');
142
- }
143
- if (kind === 'socket.io')
144
- socket.connect();
145
- return { id };
146
- }
147
- finally {
148
- this.connecting--;
149
- }
150
- }
151
- push(id, event, data) {
152
- if (!this.connections.has(id))
153
- return;
154
- let text;
155
- try {
156
- text = JSON.stringify(data ?? null);
157
- }
158
- catch {
159
- this.disconnect(id);
160
- return;
161
- }
162
- if (Buffer.byteLength(text) > 65536 || this.events.length >= 256) {
163
- this.disconnect(id);
164
- return;
165
- }
166
- this.events.push({ id, event, data: JSON.parse(text) });
167
- }
168
- send(id, event, data) {
169
- const entry = this.connections.get(id);
170
- if (!entry)
171
- throw new Error('Socket is closed');
172
- const text = JSON.stringify(data ?? null);
173
- if (Buffer.byteLength(text) > 65536)
174
- throw new Error('Socket message is too large');
175
- if (Date.now() - entry.lastSend >= 1000) {
176
- entry.lastSend = Date.now();
177
- entry.sends = 0;
178
- }
179
- if (++entry.sends > 100)
180
- throw new Error('Socket send rate exceeded');
181
- if (entry.kind === 'socket.io') {
182
- if (typeof event !== 'string' || event.length > 128 || reservedEvents.has(event))
183
- throw new Error('Invalid Socket.IO event');
184
- const socket = entry.socket;
185
- if (!socket.connected)
186
- throw new Error('Socket is not connected');
187
- socket.emit(event, data);
188
- }
189
- else {
190
- const socket = entry.socket;
191
- if (socket.readyState !== WebSocket.OPEN)
192
- throw new Error('Socket is not connected');
193
- socket.send(typeof data === 'string' ? data : text);
194
- }
195
- }
196
- release(id) {
197
- const entry = this.connections.get(id);
198
- this.connections.delete(id);
199
- entry?.agent.destroy();
200
- }
201
- disconnect(id) {
202
- const entry = this.connections.get(id);
203
- if (!entry)
204
- return;
205
- this.connections.delete(id);
206
- if (entry.kind === 'socket.io')
207
- entry.socket.disconnect();
208
- else
209
- entry.socket.terminate();
210
- entry.agent.destroy();
211
- this.events = this.events.filter((event) => event.id !== id);
212
- }
213
- revoke(key) {
214
- for (const [id, entry] of this.connections)
215
- if (entry.key === key)
216
- this.disconnect(id);
217
- }
218
- closeAll() {
219
- this.generation++;
220
- for (const id of this.connections.keys())
221
- this.disconnect(id);
222
- this.events = [];
223
- }
224
- drain() {
225
- const events = this.events;
226
- this.events = [];
227
- return events;
228
- }
229
- }
@@ -1,24 +0,0 @@
1
- {
2
- "schemaVersion": "1.0",
3
- "id": "settings",
4
- "root": {
5
- "type": "section",
6
- "title": "音乐库连接 demo",
7
- "children": [
8
- {
9
- "type": "text-input",
10
- "label": "服务器地址",
11
- "bind": "serverUrl"
12
- },
13
- {
14
- "type": "button",
15
- "label": "演示连接",
16
- "action": "connection.connect"
17
- },
18
- {
19
- "type": "text",
20
- "bind": "status"
21
- }
22
- ]
23
- }
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "schemaVersion": "1.0",
3
- "id": "settings",
4
- "root": {
5
- "type": "section",
6
- "title": "音乐库连接 demo",
7
- "children": [
8
- {
9
- "type": "text-input",
10
- "label": "服务器地址",
11
- "bind": "serverUrl"
12
- },
13
- {
14
- "type": "button",
15
- "label": "演示连接",
16
- "action": "connection.connect"
17
- },
18
- {
19
- "type": "text",
20
- "bind": "status"
21
- }
22
- ]
23
- }
24
- }
@@ -1,14 +0,0 @@
1
- {
2
- "schemaVersion": "1.0",
3
- "id": "settings",
4
- "root": {
5
- "type": "section",
6
- "title": "插件设置",
7
- "children": [
8
- {
9
- "type": "text",
10
- "text": "请在 src/index.js 中实现你的服务逻辑。"
11
- }
12
- ]
13
- }
14
- }
@@ -1,14 +0,0 @@
1
- {
2
- "schemaVersion": "1.0",
3
- "id": "settings",
4
- "root": {
5
- "type": "section",
6
- "title": "插件设置",
7
- "children": [
8
- {
9
- "type": "text",
10
- "text": "请在 src/index.ts 中实现你的服务逻辑。"
11
- }
12
- ]
13
- }
14
- }