@capyclaw/publisher 0.1.0 → 0.1.3

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 (376) hide show
  1. package/README.md +77 -2
  2. package/client/client.js +717 -0
  3. package/cordis.patch.yml +4 -15
  4. package/icon.svg +6 -0
  5. package/locale/en.json +6 -0
  6. package/locale/zh.json +6 -0
  7. package/node_modules/@capyclaw/foundation/README.md +51 -0
  8. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +86 -0
  9. package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
  10. package/node_modules/@capyclaw/foundation/abi/index.mjs +35 -0
  11. package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
  12. package/node_modules/@capyclaw/foundation/abi/loader.mjs +345 -0
  13. package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
  14. package/node_modules/@capyclaw/foundation/abi/spec.mjs +255 -0
  15. package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
  16. package/node_modules/@capyclaw/foundation/abi/version.mjs +82 -0
  17. package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
  18. package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
  19. package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
  20. package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
  21. package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
  22. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +55 -0
  23. package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
  24. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +68 -0
  25. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +113 -0
  26. package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
  27. package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
  28. package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
  29. package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
  30. package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
  31. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +34 -0
  32. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +85 -0
  33. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +50 -0
  34. package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +160 -0
  35. package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
  36. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +185 -0
  37. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +87 -0
  38. package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
  39. package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
  40. package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +188 -0
  41. package/node_modules/@capyclaw/foundation/package.json +53 -0
  42. package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
  43. package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
  44. package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
  45. package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
  46. package/node_modules/@capyclaw/plugin-kit/package.json +69 -0
  47. package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
  48. package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
  49. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +129 -0
  50. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +139 -0
  51. package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
  52. package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
  53. package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
  54. package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
  55. package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
  56. package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
  57. package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
  58. package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
  59. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
  60. package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
  61. package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
  62. package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
  63. package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
  64. package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
  65. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
  66. package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
  67. package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
  68. package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
  69. package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
  70. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +656 -0
  71. package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
  72. package/node_modules/@capyclaw/plugin-validator/bin/cli.mjs +49 -0
  73. package/node_modules/@capyclaw/plugin-validator/lib/index.mjs +303 -0
  74. package/node_modules/@capyclaw/plugin-validator/package.json +28 -0
  75. package/node_modules/@capyclaw/tool-host/README.md +56 -0
  76. package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
  77. package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
  78. package/node_modules/@capyclaw/tool-host/lib/host.mjs +16 -0
  79. package/node_modules/@capyclaw/tool-host/package.json +59 -0
  80. package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
  81. package/node_modules/@capyclaw/tool-host/src/index.mjs +416 -0
  82. package/node_modules/semver/LICENSE +15 -0
  83. package/node_modules/semver/README.md +680 -0
  84. package/node_modules/semver/bin/semver.js +195 -0
  85. package/node_modules/semver/classes/comparator.js +143 -0
  86. package/node_modules/semver/classes/index.js +7 -0
  87. package/node_modules/semver/classes/range.js +577 -0
  88. package/node_modules/semver/classes/semver.js +350 -0
  89. package/node_modules/semver/functions/clean.js +8 -0
  90. package/node_modules/semver/functions/cmp.js +54 -0
  91. package/node_modules/semver/functions/coerce.js +62 -0
  92. package/node_modules/semver/functions/compare-build.js +9 -0
  93. package/node_modules/semver/functions/compare-loose.js +5 -0
  94. package/node_modules/semver/functions/compare.js +7 -0
  95. package/node_modules/semver/functions/diff.js +60 -0
  96. package/node_modules/semver/functions/eq.js +5 -0
  97. package/node_modules/semver/functions/gt.js +5 -0
  98. package/node_modules/semver/functions/gte.js +5 -0
  99. package/node_modules/semver/functions/inc.js +21 -0
  100. package/node_modules/semver/functions/lt.js +5 -0
  101. package/node_modules/semver/functions/lte.js +5 -0
  102. package/node_modules/semver/functions/major.js +5 -0
  103. package/node_modules/semver/functions/minor.js +5 -0
  104. package/node_modules/semver/functions/neq.js +5 -0
  105. package/node_modules/semver/functions/parse.js +18 -0
  106. package/node_modules/semver/functions/patch.js +5 -0
  107. package/node_modules/semver/functions/prerelease.js +8 -0
  108. package/node_modules/semver/functions/rcompare.js +5 -0
  109. package/node_modules/semver/functions/rsort.js +5 -0
  110. package/node_modules/semver/functions/satisfies.js +12 -0
  111. package/node_modules/semver/functions/sort.js +5 -0
  112. package/node_modules/semver/functions/truncate.js +48 -0
  113. package/node_modules/semver/functions/valid.js +8 -0
  114. package/node_modules/semver/index.js +93 -0
  115. package/node_modules/semver/internal/constants.js +67 -0
  116. package/node_modules/semver/internal/debug.js +11 -0
  117. package/node_modules/semver/internal/identifiers.js +29 -0
  118. package/node_modules/semver/internal/lrucache.js +42 -0
  119. package/node_modules/semver/internal/parse-options.js +17 -0
  120. package/node_modules/semver/internal/re.js +223 -0
  121. package/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  122. package/node_modules/semver/package.json +78 -0
  123. package/node_modules/semver/preload.js +4 -0
  124. package/node_modules/semver/range.bnf +17 -0
  125. package/node_modules/semver/ranges/gtr.js +6 -0
  126. package/node_modules/semver/ranges/intersects.js +9 -0
  127. package/node_modules/semver/ranges/ltr.js +6 -0
  128. package/node_modules/semver/ranges/max-satisfying.js +27 -0
  129. package/node_modules/semver/ranges/min-satisfying.js +26 -0
  130. package/node_modules/semver/ranges/min-version.js +63 -0
  131. package/node_modules/semver/ranges/outside.js +82 -0
  132. package/node_modules/semver/ranges/simplify.js +49 -0
  133. package/node_modules/semver/ranges/subset.js +249 -0
  134. package/node_modules/semver/ranges/to-comparators.js +10 -0
  135. package/node_modules/semver/ranges/valid.js +13 -0
  136. package/node_modules/yaml/LICENSE +13 -0
  137. package/node_modules/yaml/README.md +172 -0
  138. package/node_modules/yaml/bin.mjs +11 -0
  139. package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  140. package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  141. package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  142. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  143. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  144. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  145. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  146. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  147. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  148. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  149. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +226 -0
  150. package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  151. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  152. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  153. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  154. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  155. package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  156. package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  157. package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  158. package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  159. package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  160. package/node_modules/yaml/browser/dist/errors.js +57 -0
  161. package/node_modules/yaml/browser/dist/index.js +17 -0
  162. package/node_modules/yaml/browser/dist/log.js +11 -0
  163. package/node_modules/yaml/browser/dist/nodes/Alias.js +118 -0
  164. package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  165. package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  166. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  167. package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  168. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  169. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  170. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  171. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  172. package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  173. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  174. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  175. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  176. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  177. package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  178. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  179. package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  180. package/node_modules/yaml/browser/dist/public-api.js +102 -0
  181. package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  182. package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  183. package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  184. package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  185. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  186. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  187. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  188. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  189. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  190. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  191. package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  192. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  193. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  194. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  195. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  196. package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  197. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  198. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  199. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  200. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  201. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  202. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  203. package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  204. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  205. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  206. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  207. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  208. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  209. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  210. package/node_modules/yaml/browser/dist/util.js +11 -0
  211. package/node_modules/yaml/browser/dist/visit.js +233 -0
  212. package/node_modules/yaml/browser/index.js +5 -0
  213. package/node_modules/yaml/browser/package.json +3 -0
  214. package/node_modules/yaml/dist/cli.d.ts +8 -0
  215. package/node_modules/yaml/dist/cli.mjs +201 -0
  216. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  217. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  218. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  219. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  220. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  221. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  222. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  223. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  224. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  225. package/node_modules/yaml/dist/compose/composer.js +224 -0
  226. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  227. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  228. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  229. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  230. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  231. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  232. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  233. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  234. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  235. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  236. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  237. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +228 -0
  238. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  239. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  240. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  241. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  242. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  243. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  244. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  245. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  246. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  247. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  248. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  249. package/node_modules/yaml/dist/doc/Document.js +337 -0
  250. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  251. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  252. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  253. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  254. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  255. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  256. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  257. package/node_modules/yaml/dist/doc/directives.js +178 -0
  258. package/node_modules/yaml/dist/errors.d.ts +21 -0
  259. package/node_modules/yaml/dist/errors.js +62 -0
  260. package/node_modules/yaml/dist/index.d.ts +25 -0
  261. package/node_modules/yaml/dist/index.js +50 -0
  262. package/node_modules/yaml/dist/log.d.ts +3 -0
  263. package/node_modules/yaml/dist/log.js +19 -0
  264. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  265. package/node_modules/yaml/dist/nodes/Alias.js +120 -0
  266. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  267. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  268. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  269. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  270. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  271. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  272. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  273. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  274. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  275. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  276. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  277. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  278. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  279. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  280. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  281. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  282. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  283. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  284. package/node_modules/yaml/dist/options.d.ts +350 -0
  285. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  286. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  287. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  288. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  289. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  290. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  291. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  292. package/node_modules/yaml/dist/parse/cst.js +112 -0
  293. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  294. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  295. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  296. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  297. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  298. package/node_modules/yaml/dist/parse/parser.js +980 -0
  299. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  300. package/node_modules/yaml/dist/public-api.js +107 -0
  301. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  302. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  303. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  304. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  305. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  306. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  307. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  308. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  309. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  310. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  311. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  312. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  313. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  314. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  315. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  316. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  317. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  318. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  319. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  320. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  321. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  322. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  323. package/node_modules/yaml/dist/schema/tags.js +99 -0
  324. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  325. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  326. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  327. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  328. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  329. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  330. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  331. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  332. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  333. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  334. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  335. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  336. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  337. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  338. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  339. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  340. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  341. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  342. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  343. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  344. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  345. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  346. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  347. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  348. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  349. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  350. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  351. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  352. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  353. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  354. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  355. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  356. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  357. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  358. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  359. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  360. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  361. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  362. package/node_modules/yaml/dist/test-events.js +134 -0
  363. package/node_modules/yaml/dist/util.d.ts +16 -0
  364. package/node_modules/yaml/dist/util.js +28 -0
  365. package/node_modules/yaml/dist/visit.d.ts +102 -0
  366. package/node_modules/yaml/dist/visit.js +236 -0
  367. package/node_modules/yaml/package.json +97 -0
  368. package/node_modules/yaml/util.js +2 -0
  369. package/package.json +34 -14
  370. package/plugin.mjs +113 -0
  371. package/server/archive.mjs +255 -0
  372. package/server/drop.mjs +498 -0
  373. package/server/impl.mjs +222 -76
  374. package/server/routes.mjs +339 -0
  375. package/lib/host.mjs +0 -27
  376. package/server/relay.mjs +0 -70
@@ -0,0 +1,717 @@
1
+ /**
2
+ * @capyclaw/publisher 的浏览器半边:插件页里的「拖拽发布」标签页。
3
+ *
4
+ * 把打包好的插件包(.zip / .tgz / .tar.gz)拖进来 → 宿主解包并规划版本
5
+ * → 确认后 npm publish → 可选地把本机安装更新到刚发布的版本。
6
+ *
7
+ * 发布是不可撤销动作,所以这里固定两段:拖入只做预检(不碰 registry),
8
+ * 点「发布」才真的调 /publisher-drop/publish。发布成功后用插件页自带的
9
+ * install({ spec: 'name@version' }) 把本机升级交给官方安装器。
10
+ */
11
+ window.__ModuleLoader__.load({
12
+ id: '@capyclaw/publisher',
13
+ factory(require) {
14
+ const React = require('react')
15
+ const h = React.createElement
16
+ const NS = 'publisherDrop'
17
+
18
+ const DICT = {
19
+ en: {
20
+ tab: 'Drop to publish',
21
+ heading: 'Drop a package to publish',
22
+ hint: 'Accepts .zip / .tgz / .tar.gz. The archive is unpacked locally, version-checked against npm, and published only after you confirm.',
23
+ choose: 'Choose a file…',
24
+ once: 'One archive at a time.',
25
+ unsupported: 'Unsupported file type. Use .zip, .tgz or .tar.gz.',
26
+ tooLarge: 'That archive is larger than 32 MB.',
27
+ reading: 'Reading the package…',
28
+ analysing: 'Checking npm versions and publish gates…',
29
+ unavailable: 'The Host route is not reachable. Drag-and-drop publishing only works in the Web GUI.',
30
+ failed: 'Could not prepare the package:',
31
+ npmUser: 'npm as',
32
+ npmMissing: 'npm is not logged in on the Host — run npm login first.',
33
+ review: 'Ready to publish',
34
+ fromVersion: 'in package',
35
+ latestVersion: 'on npm',
36
+ targetVersion: 'will publish',
37
+ modeFirst: 'first release',
38
+ modeAhead: 'newer than npm',
39
+ modeBump: 'patch +1',
40
+ files: 'files',
41
+ selfContained: 'self-contained',
42
+ thin: 'dependencies resolved at install time',
43
+ blocking: 'Blocked',
44
+ warnings: 'Heads-up',
45
+ publishAndUpdate: 'Publish and update this machine',
46
+ publishOnly: 'Publish only',
47
+ repick: 'Pick another',
48
+ publishing: 'Publishing to npm… this can take a few seconds',
49
+ dryRunning: 'Dry run: npm will validate the package without publishing…',
50
+ done: 'Published',
51
+ doneHint: 'The package is live on npm.',
52
+ unverified: 'npm accepted the publish, but the registry does not list this version yet — it usually shows up within a minute.',
53
+ openNpm: 'Open on npm',
54
+ updateNow: 'Update this machine to',
55
+ updating: 'Handing it to the plugin installer…',
56
+ updated: 'Handed to the installer — confirm the install dialog.',
57
+ again: 'Publish another',
58
+ recent: 'Recently published here',
59
+ discardFailed: 'Could not drop the staged package; it will be cleaned up later.',
60
+ dryRun: 'Dry run first',
61
+ dryRunTitle: 'Dry run passed',
62
+ dryRunHint: 'npm accepted this package. Nothing was published — publish again to make it real.',
63
+ errBusy: 'The previous publish is still running. Try again in a moment.',
64
+ errStageMissing: 'This preview expired. Drop the package again.',
65
+ errGate: 'The package did not pass the publish gates.',
66
+ errPublish: 'npm rejected the publish.',
67
+ errDryRun: 'Dry run failed — npm would reject this package.',
68
+ errUnpack: 'Could not unpack the archive.',
69
+ errEmpty: 'The archive is empty.',
70
+ errBadRequest: 'Malformed request.',
71
+ errInternal: 'The Host route crashed while handling this.',
72
+ errRegistry: 'Could not read this package from npm.',
73
+ errCorrupted: 'npm accepted the publish but the version is not readable yet. Verify with npm view.',
74
+ errVersionExists: 'That version is already on npm. Bump the version in package.json, or drop the package again to auto-increment.',
75
+ errOtp: 'npm wants a two-factor code. Publish from a terminal with OTP, or turn off 2FA for this package.',
76
+ errNoAuth: 'npm does not accept the current identity. Run npm login on the host, or set NODE_AUTH_TOKEN.',
77
+ retryPublish: 'Retry the publish',
78
+ timeout: 'The Host did not answer within 120s. The npm call may still be running — check with npm view before retrying.',
79
+ },
80
+ zh: {
81
+ tab: '拖拽发布',
82
+ heading: '把插件包拖到这里发布',
83
+ hint: '支持 .zip / .tgz / .tar.gz。压缩包会解到本机,先和 npm 上的版本比对、过发布闸;确认后才会真的发布。',
84
+ choose: '选择文件…',
85
+ once: '一次只能拖一个压缩包。',
86
+ unsupported: '不支持的文件类型,请用 .zip、.tgz 或 .tar.gz。',
87
+ tooLarge: '压缩包超过 32 MB 上限。',
88
+ reading: '正在读取插件包…',
89
+ analysing: '正在比对 npm 版本、跑发布闸…',
90
+ unavailable: '没有连上宿主路由,拖拽发布只在 Web 版可用。',
91
+ failed: '准备发布失败:',
92
+ npmUser: 'npm 身份',
93
+ npmMissing: '宿主还没登录 npm——先在终端里 npm login。',
94
+ review: '准备就绪',
95
+ fromVersion: '包内版本',
96
+ latestVersion: 'npm 最新',
97
+ targetVersion: '本次发布',
98
+ modeFirst: '首次发布',
99
+ modeAhead: '比 npm 新',
100
+ modeBump: '补丁 +1',
101
+ files: '个文件',
102
+ selfContained: '自包含产物',
103
+ thin: '依赖在安装时解析',
104
+ blocking: '不能发布',
105
+ warnings: '注意',
106
+ publishAndUpdate: '发布并更新本机',
107
+ publishOnly: '只发布',
108
+ repick: '换一个包',
109
+ publishing: '正在 npm publish…通常几秒',
110
+ dryRunning: '预演:npm 只校验、不写 registry…',
111
+ done: '发布成功',
112
+ doneHint: '这个版本已经在 npm 上了。',
113
+ unverified: 'npm 已经收下这次发布,但 registry 还没同步出这个版本——通常一分钟内就能查到。',
114
+ openNpm: '在 npm 打开',
115
+ updateNow: '把本机更新到',
116
+ updating: '正在交给插件安装器…',
117
+ updated: '已交给安装器,请在安装对话框里确认。',
118
+ again: '再发一个',
119
+ recent: '本次会话发布记录',
120
+ discardFailed: '没能放弃这次预检,稍后会自动清理。',
121
+ dryRun: '先预演一遍',
122
+ dryRunTitle: '预演通过',
123
+ dryRunHint: 'npm 接受这个包,但还没有真的发布——再点一次「只发布」才会写进 registry。',
124
+ errBusy: '上一次发布还没结束,请稍等一下。',
125
+ errStageMissing: '这次预检已经过期,重新把包拖进来吧。',
126
+ errGate: '这个包没通过发布闸。',
127
+ errPublish: 'npm 拒绝了这次发布。',
128
+ errDryRun: '预演失败——npm 会拒绝这个包。',
129
+ errUnpack: '压缩包解不开。',
130
+ errEmpty: '压缩包是空的。',
131
+ errBadRequest: '请求格式不对。',
132
+ errInternal: '宿主路由处理时崩了,可以重试一次。',
133
+ errRegistry: '读不到 npm 上这个包的信息。',
134
+ errCorrupted: '发布已经提交,但 registry 还读不到这个版本;稍后用 npm view 核对。',
135
+ errVersionExists: '这个版本号已经在 npm 上了。把包里的 version 改高一点,或重新拖进来让发布器自动 +1。',
136
+ errOtp: 'npm 要求两步验证码。先在终端带 OTP 发布一次,或关掉这个包的 2FA 要求。',
137
+ errNoAuth: 'npm 不认当前身份。在宿主机执行 npm login,或设置 NODE_AUTH_TOKEN 后重启 DSH。',
138
+ retryPublish: '重新发布',
139
+ timeout: '宿主 120 秒没有响应。npm 那一侧可能还在跑,先用 npm view 确认再重试。',
140
+ },
141
+ }
142
+
143
+ /** 服务端的 error 码 → 本地文案(服务端消息是中文的,英文界面不能直接显示)。 */
144
+ const ERROR_KEYS = {
145
+ busy: 'errBusy',
146
+ 'stage-missing': 'errStageMissing',
147
+ 'gate-failed': 'errGate',
148
+ 'publish-failed': 'errPublish',
149
+ 'dry-run-failed': 'errDryRun',
150
+ 'unpack-failed': 'errUnpack',
151
+ 'too-large': 'tooLarge',
152
+ empty: 'errEmpty',
153
+ 'bad-request': 'errBadRequest',
154
+ internal: 'errInternal',
155
+ 'registry-unreachable': 'errRegistry',
156
+ 'publish-corrupted': 'errCorrupted',
157
+ 'version-exists': 'errVersionExists',
158
+ 'otp-required': 'errOtp',
159
+ 'not-authenticated': 'errNoAuth',
160
+ }
161
+
162
+ function failText(payload, t, fallback) {
163
+ const key = payload && ERROR_KEYS[payload.error]
164
+ if (key) return t(key)
165
+ return (payload && (payload.message || payload.error)) || fallback
166
+ }
167
+
168
+ function useLocaleRevision(locale) {
169
+ const [revision, setRevision] = React.useState(() => locale.getSnapshot().revision)
170
+ React.useEffect(() => locale.subscribe(() => setRevision(locale.getSnapshot().revision)), [locale])
171
+ return revision
172
+ }
173
+
174
+ const MONO = 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'
175
+ const small = { fontSize: 12, lineHeight: 1.6, color: 'var(--dsw-alias-label-secondary)' }
176
+ const labelStyle = {
177
+ fontSize: 11.5,
178
+ letterSpacing: 0.3,
179
+ textTransform: 'uppercase',
180
+ color: 'var(--dsw-alias-label-secondary)',
181
+ }
182
+
183
+ function icon(paths, size) {
184
+ return h(
185
+ 'svg',
186
+ { viewBox: '0 0 48 48', width: size, height: size, fill: 'none', 'aria-hidden': true },
187
+ ...paths.map((props, index) => h('path', { key: index, ...props })),
188
+ )
189
+ }
190
+
191
+ const Stroke = {
192
+ stroke: 'var(--dsw-alias-brand-primary)',
193
+ strokeWidth: 2.4,
194
+ strokeLinecap: 'round',
195
+ strokeLinejoin: 'round',
196
+ }
197
+
198
+ const CloudArrow = () => icon([
199
+ { d: 'M24 15v14m0-14 6 6m-6-6-6 6', ...Stroke },
200
+ { d: 'M12 31a7 7 0 0 1 .6-13.9A10 10 0 0 1 32 15.4 6.5 6.5 0 0 1 36.4 28', ...Stroke },
201
+ { d: 'M13 38h22', ...Stroke },
202
+ ], 44)
203
+
204
+ const Check = () => icon([{ d: 'M12 25.5 20.5 34 36 16', ...Stroke }], 44)
205
+
206
+ function Badge(props) {
207
+ return h(
208
+ 'span',
209
+ {
210
+ style: {
211
+ padding: '2px 8px',
212
+ borderRadius: 999,
213
+ fontSize: 11.5,
214
+ fontFamily: MONO,
215
+ color: 'var(--dsw-alias-brand-primary)',
216
+ background: 'color-mix(in srgb, var(--dsw-alias-brand-primary) 12%, transparent)',
217
+ },
218
+ },
219
+ props.children,
220
+ )
221
+ }
222
+
223
+ function button(kind, text, onClick, disabled) {
224
+ const primary = kind === 'primary'
225
+ const ghost = kind === 'ghost'
226
+ return h(
227
+ 'button',
228
+ {
229
+ type: 'button',
230
+ disabled: disabled === true,
231
+ onClick,
232
+ style: {
233
+ padding: primary ? '9px 18px' : '7px 14px',
234
+ borderRadius: 10,
235
+ border: ghost ? '1px solid transparent' : '1px solid var(--dsw-alias-border-l1)',
236
+ background: primary
237
+ ? 'var(--dsw-alias-brand-primary)'
238
+ : ghost
239
+ ? 'transparent'
240
+ : 'var(--dsw-alias-bg-layer-2)',
241
+ color: primary ? '#fff' : 'var(--dsw-alias-label-primary)',
242
+ fontSize: primary ? 14 : 13,
243
+ fontWeight: primary ? 600 : 500,
244
+ cursor: disabled === true ? 'not-allowed' : 'pointer',
245
+ opacity: disabled === true ? 0.5 : 1,
246
+ },
247
+ },
248
+ text,
249
+ )
250
+ }
251
+
252
+ function DropTab(props) {
253
+ const install = props.install
254
+ const locale = props.locale
255
+ useLocaleRevision(locale)
256
+ const t = locale.bind(NS)
257
+
258
+ const [health, setHealth] = React.useState(null)
259
+ const [phase, setPhase] = React.useState({ kind: 'idle' })
260
+ const [over, setOver] = React.useState(false)
261
+ const [recent, setRecent] = React.useState([])
262
+ const input = React.useRef(null)
263
+ const inFlight = React.useRef(null)
264
+
265
+ const loadHealth = React.useCallback(async () => {
266
+ try {
267
+ const response = await fetch('/publisher-drop/health', { headers: { accept: 'application/json' } })
268
+ if (!response.ok) throw new Error(`HTTP ${response.status}`)
269
+ const payload = await response.json()
270
+ setHealth(payload)
271
+ if (Array.isArray(payload.recent)) setRecent(payload.recent)
272
+ } catch {
273
+ setHealth({ ok: false, unavailable: true })
274
+ }
275
+ }, [])
276
+
277
+ React.useEffect(() => { loadHealth() }, [loadHealth])
278
+
279
+ /* 卸载时把还在飞的请求掐掉,避免 setPhase 打到已卸载组件上。 */
280
+ React.useEffect(() => () => {
281
+ if (inFlight.current) inFlight.current.abort()
282
+ }, [])
283
+
284
+ const post = async (route, body, headers) => {
285
+ if (inFlight.current) {
286
+ /* 被新请求顶掉:不是超时,调用方静默忽略即可。 */
287
+ inFlight.current.superseded = true
288
+ inFlight.current.abort()
289
+ }
290
+ const controller = new AbortController()
291
+ inFlight.current = controller
292
+ /* npm 偶尔会卡在网络上:请求 120 秒还没回就主动收手,别让按钮永远转圈。 */
293
+ const timer = setTimeout(() => controller.abort(), 120000)
294
+ try {
295
+ const response = await fetch(`/publisher-drop/${route}`, {
296
+ method: 'POST',
297
+ headers: { accept: 'application/json', ...(headers || {}) },
298
+ body,
299
+ signal: controller.signal,
300
+ })
301
+ if (response.status === 404 || response.status === 405) throw new Error(t('unavailable'))
302
+ const payload = await response.json().catch(() => null)
303
+ if (!response.ok || !payload) throw new Error(`HTTP ${response.status}`)
304
+ return payload
305
+ } catch (error) {
306
+ if (error && error.name === 'AbortError') {
307
+ if (controller.superseded) throw error
308
+ const timeout = new Error(t('timeout'))
309
+ timeout.name = 'TimeoutError'
310
+ throw timeout
311
+ }
312
+ throw error
313
+ } finally {
314
+ clearTimeout(timer)
315
+ }
316
+ }
317
+
318
+ const take = React.useCallback(async (file) => {
319
+ if (!file) return
320
+ if (!/\.(zip|tgz|tar\.gz|tar)$/i.test(file.name)) {
321
+ setPhase({ kind: 'error', message: t('unsupported') })
322
+ return
323
+ }
324
+ if (file.size > 32 * 1024 * 1024) {
325
+ setPhase({ kind: 'error', message: t('tooLarge') })
326
+ return
327
+ }
328
+ setPhase({ kind: 'reading', name: file.name })
329
+ try {
330
+ const payload = await post('prepare', file, {
331
+ 'content-type': 'application/octet-stream',
332
+ 'x-dsh-filename': encodeURIComponent(file.name),
333
+ })
334
+ if (!payload.ok) throw new Error(failText(payload, t, 'prepare failed'))
335
+ setPhase({ kind: 'preview', data: payload })
336
+ } catch (error) {
337
+ if (error && error.name === 'AbortError') return
338
+ const message = error && error.message ? error.message : String(error)
339
+ setPhase({ kind: 'error', message: message === t('unavailable') ? message : `${t('failed')} ${message}` })
340
+ }
341
+ }, [t])
342
+
343
+ const onDrop = (event) => {
344
+ event.preventDefault()
345
+ event.stopPropagation()
346
+ setOver(false)
347
+ const files = event.dataTransfer && event.dataTransfer.files
348
+ if (!files || files.length === 0) return
349
+ if (files.length > 1) setPhase({ kind: 'error', message: t('once') })
350
+ take(files[0])
351
+ }
352
+
353
+ const discard = () => {
354
+ const data = phase.kind === 'preview' ? phase.data : null
355
+ if (data && data.token) {
356
+ post('discard', JSON.stringify({ token: data.token }), { 'content-type': 'application/json' }).catch(() => {})
357
+ }
358
+ setPhase({ kind: 'idle' })
359
+ }
360
+
361
+ const handToInstaller = (payload) => {
362
+ if (typeof install !== 'function') return
363
+ const spec = `${payload.name}@${payload.version}`
364
+ try {
365
+ install({ spec, title: payload.name, version: payload.version })
366
+ setPhase((current) => (current.kind === 'done' ? { ...current, updated: true } : current))
367
+ } catch (error) {
368
+ setPhase((current) => (current.kind === 'done'
369
+ ? { ...current, updated: false, installError: error && error.message ? error.message : String(error) }
370
+ : current))
371
+ }
372
+ }
373
+
374
+ const publish = async (updateLocal, dryRun = false) => {
375
+ const data = phase.data
376
+ setPhase({ kind: dryRun ? 'dryRunning' : 'publishing', data, updateLocal })
377
+ try {
378
+ const payload = await post('publish', JSON.stringify({
379
+ token: data.token,
380
+ version: data.plan.version,
381
+ dryRun: dryRun === true,
382
+ }), { 'content-type': 'application/json' })
383
+ if (!payload.ok) throw new Error(failText(payload, t, 'publish failed'))
384
+ setPhase({ kind: 'done', data: payload, updateLocal, dryRun: payload.dryRun === true, updated: false })
385
+ loadHealth()
386
+ if (dryRun !== true && updateLocal && typeof install === 'function') handToInstaller(payload)
387
+ } catch (error) {
388
+ if (error && error.name === 'AbortError') return
389
+ const message = error && error.message ? error.message : String(error)
390
+ setPhase({ kind: 'error', message, data })
391
+ }
392
+ }
393
+
394
+ const busy = phase.kind === 'reading' || phase.kind === 'publishing' || phase.kind === 'dryRunning'
395
+
396
+ /*
397
+ * 页面可能比宿主新(刷新了浏览器但没重启 DSH)。宿主没在 health 里声明 dry-run 时
398
+ * 不显示「先预演一遍」——旧宿主会把它当成真发布。
399
+ */
400
+ const canDryRun = Boolean(health && Array.isArray(health.features) && health.features.includes('dry-run'))
401
+
402
+ const npmLine = health && health.npm
403
+ ? health.npm.ok
404
+ ? h('span', null, `${t('npmUser')} ${health.npm.user}`)
405
+ : h('span', { style: { color: 'var(--dsw-alias-state-error-primary)' } }, t('npmMissing'))
406
+ : null
407
+
408
+ const zoneStyle = {
409
+ display: 'flex',
410
+ flexDirection: 'column',
411
+ alignItems: 'center',
412
+ gap: 8,
413
+ padding: '34px 24px',
414
+ borderRadius: 14,
415
+ border: `1px dashed ${over ? 'var(--dsw-alias-brand-primary)' : 'var(--dsw-alias-border-l2)'}`,
416
+ background: over
417
+ ? 'color-mix(in srgb, var(--dsw-alias-brand-primary) 8%, var(--dsw-alias-bg-layer-1))'
418
+ : 'var(--dsw-alias-bg-layer-1)',
419
+ textAlign: 'center',
420
+ cursor: 'pointer',
421
+ transition: 'border-color 120ms ease, background 120ms ease',
422
+ }
423
+
424
+ const idleBody = h(
425
+ 'div',
426
+ { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 } },
427
+ h(CloudArrow),
428
+ h('div', { style: { fontSize: 16, fontWeight: 600 } }, t('heading')),
429
+ h('div', { style: { ...small, maxWidth: 480 } }, t('hint')),
430
+ h('div', { style: { ...small, fontFamily: MONO } }, t('choose')),
431
+ h('div', { style: { ...small, opacity: 0.7 } }, t('once')),
432
+ )
433
+
434
+ const busyBody = h(
435
+ 'div',
436
+ { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10 } },
437
+ h(CloudArrow),
438
+ h('div', { style: { fontSize: 15, fontWeight: 600 } },
439
+ phase.kind === 'reading'
440
+ ? t('reading')
441
+ : phase.kind === 'dryRunning'
442
+ ? t('dryRunning')
443
+ : t('publishing')),
444
+ h('div', { style: small }, phase.kind === 'reading' ? t('analysing') : (phase.data ? phase.data.name : '')),
445
+ )
446
+
447
+ const renderPreview = (data) => {
448
+ const modeLabel = data.plan.mode === 'first'
449
+ ? t('modeFirst')
450
+ : data.plan.mode === 'ahead'
451
+ ? t('modeAhead')
452
+ : t('modeBump')
453
+ const rows = [
454
+ [t('fromVersion'), data.version || '—'],
455
+ [t('latestVersion'), data.latest || '—'],
456
+ [t('targetVersion'), data.plan.version],
457
+ ]
458
+ const blocked = Array.isArray(data.blocking) && data.blocking.length > 0
459
+
460
+ return h(
461
+ 'div',
462
+ { style: { display: 'flex', flexDirection: 'column', gap: 12 } },
463
+ h(
464
+ 'div',
465
+ { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
466
+ h('div', { style: { fontSize: 16, fontWeight: 650, fontFamily: MONO, wordBreak: 'break-all' } }, data.name),
467
+ h(Badge, null, modeLabel),
468
+ h('span', { style: small }, t('review')),
469
+ ),
470
+ data.description ? h('div', { style: small }, data.description) : null,
471
+ h(
472
+ 'div',
473
+ { style: { display: 'grid', gridTemplateColumns: 'repeat(3, minmax(0, 1fr))', gap: 10 } },
474
+ ...rows.map(([label, value], index) => h(
475
+ 'div',
476
+ {
477
+ key: label,
478
+ style: {
479
+ padding: '10px 12px',
480
+ borderRadius: 10,
481
+ border: '1px solid var(--dsw-alias-border-l1)',
482
+ background: index === 2 ? 'var(--dsw-alias-bg-layer-2)' : 'var(--dsw-alias-bg-layer-1)',
483
+ },
484
+ },
485
+ h('div', { style: labelStyle }, label),
486
+ h('div', {
487
+ style: {
488
+ marginTop: 4,
489
+ fontSize: index === 2 ? 15 : 13.5,
490
+ fontWeight: index === 2 ? 650 : 500,
491
+ fontFamily: MONO,
492
+ color: index === 2 ? 'var(--dsw-alias-brand-primary)' : 'var(--dsw-alias-label-primary)',
493
+ },
494
+ }, value),
495
+ )),
496
+ ),
497
+ h(
498
+ 'div',
499
+ { style: { display: 'flex', gap: 14, flexWrap: 'wrap', ...small } },
500
+ h('span', null, `${data.files} ${t('files')}`),
501
+ h('span', null, data.hasNodeModules ? t('selfContained') : t('thin')),
502
+ ),
503
+ data.warnings && data.warnings.length
504
+ ? h(
505
+ 'div',
506
+ { style: { padding: '10px 12px', borderRadius: 10, background: 'rgba(250, 176, 5, 0.10)' } },
507
+ h('div', { style: { ...labelStyle, marginBottom: 4, color: '#b8860b' } }, t('warnings')),
508
+ ...data.warnings.map((item) => h('div', { key: item, style: { ...small, color: 'var(--dsw-alias-label-primary)' } }, `· ${item}`)),
509
+ )
510
+ : null,
511
+ blocked
512
+ ? h(
513
+ 'div',
514
+ { style: { padding: '10px 12px', borderRadius: 10, background: 'rgba(240, 62, 62, 0.10)' } },
515
+ h('div', { style: { ...labelStyle, marginBottom: 4, color: 'var(--dsw-alias-state-error-primary)' } }, t('blocking')),
516
+ ...data.blocking.map((item) => h('div', { key: item, style: { ...small, color: 'var(--dsw-alias-label-primary)' } }, `· ${item}`)),
517
+ )
518
+ : null,
519
+ h(
520
+ 'div',
521
+ { style: { display: 'flex', gap: 10, flexWrap: 'wrap' } },
522
+ button('primary', t('publishAndUpdate'), () => publish(true), blocked),
523
+ button('secondary', t('publishOnly'), () => publish(false), blocked),
524
+ canDryRun ? button('ghost', t('dryRun'), () => publish(false, true), blocked) : null,
525
+ button('ghost', t('repick'), discard),
526
+ ),
527
+ )
528
+ }
529
+
530
+ const doneBody = phase.kind === 'done' ? h(
531
+ 'div',
532
+ { style: { display: 'flex', flexDirection: 'column', gap: 14 } },
533
+ h('div', { style: { display: 'flex', justifyContent: 'center' } }, h(Check)),
534
+ h('div', { style: { textAlign: 'center', fontSize: 16, fontWeight: 650 } },
535
+ t(phase.dryRun ? 'dryRunTitle' : 'done')),
536
+ h('div', { style: { ...small, textAlign: 'center' } },
537
+ t(phase.dryRun ? 'dryRunHint' : 'doneHint')),
538
+ h(
539
+ 'div',
540
+ {
541
+ style: {
542
+ alignSelf: 'center',
543
+ padding: '8px 14px',
544
+ borderRadius: 10,
545
+ border: '1px solid var(--dsw-alias-border-l1)',
546
+ background: 'var(--dsw-alias-bg-layer-2)',
547
+ fontFamily: MONO,
548
+ fontSize: 14,
549
+ },
550
+ },
551
+ `${phase.data.name}@${phase.data.version}`,
552
+ ),
553
+ !phase.dryRun && phase.data.verified === false
554
+ ? h(
555
+ 'div',
556
+ {
557
+ style: {
558
+ ...small,
559
+ textAlign: 'center',
560
+ padding: '8px 12px',
561
+ borderRadius: 8,
562
+ background: 'var(--dsw-alias-bg-layer-2)',
563
+ color: 'var(--dsw-alias-label-secondary)',
564
+ },
565
+ },
566
+ t('unverified'),
567
+ )
568
+ : null,
569
+ h(
570
+ 'div',
571
+ { style: { display: 'flex', gap: 10, justifyContent: 'center', flexWrap: 'wrap' } },
572
+ !phase.dryRun && phase.data.url
573
+ ? h('a', {
574
+ href: phase.data.url,
575
+ target: '_blank',
576
+ rel: 'noreferrer',
577
+ style: { ...small, color: 'var(--dsw-alias-brand-primary)', alignSelf: 'center' },
578
+ }, t('openNpm'))
579
+ : null,
580
+ phase.dryRun
581
+ ? button('primary', t('publishOnly'), () => publish(phase.updateLocal === true))
582
+ : null,
583
+ phase.dryRun
584
+ ? null
585
+ : phase.updated
586
+ ? h('span', { style: { ...small, alignSelf: 'center' } }, t('updated'))
587
+ : button('secondary', `${t('updateNow')} ${phase.data.version}`, () => handToInstaller(phase.data), typeof install !== 'function'),
588
+ button('primary', t('again'), () => setPhase({ kind: 'idle' })),
589
+ ),
590
+ phase.installError
591
+ ? h('div', { style: { ...small, color: 'var(--dsw-alias-state-error-primary)', textAlign: 'center' } }, phase.installError)
592
+ : null, ) : null
593
+
594
+ const recentList = recent.length
595
+ ? h(
596
+ 'div',
597
+ { style: { marginTop: 18 } },
598
+ h('div', { style: { ...labelStyle, marginBottom: 6 } }, t('recent')),
599
+ ...recent.map((item) => h(
600
+ 'div',
601
+ {
602
+ key: `${item.name}@${item.version}@${item.at}`,
603
+ style: { display: 'flex', gap: 8, alignItems: 'baseline', padding: '3px 0', fontSize: 12.5, fontFamily: MONO },
604
+ },
605
+ h('span', { style: { color: item.ok ? 'var(--dsw-alias-label-primary)' : 'var(--dsw-alias-state-error-primary)' } }, `${item.name}@${item.version}`),
606
+ h('span', { style: { color: 'var(--dsw-alias-label-secondary)', fontFamily: 'inherit' } },
607
+ item.dryRun ? t('dryRun') : item.ok ? item.tag : (item.message || 'failed')),
608
+ )),
609
+ )
610
+ : null
611
+
612
+ return h(
613
+ 'div',
614
+ { style: { margin: '8px 0 32px', maxWidth: 720 } },
615
+ health && health.unavailable
616
+ ? h('div', {
617
+ style: { padding: '12px 14px', borderRadius: 10, background: 'rgba(240, 62, 62, 0.10)', fontSize: 13 },
618
+ }, t('unavailable'))
619
+ : h(
620
+ 'div',
621
+ { style: { display: 'flex', flexDirection: 'column', gap: 14 } },
622
+ phase.kind === 'idle'
623
+ ? h(
624
+ 'div',
625
+ {
626
+ onDragOver: (event) => {
627
+ event.preventDefault()
628
+ if (event.dataTransfer) event.dataTransfer.dropEffect = 'copy'
629
+ setOver(true)
630
+ },
631
+ onDragEnter: (event) => {
632
+ event.preventDefault()
633
+ setOver(true)
634
+ },
635
+ onDragLeave: () => setOver(false),
636
+ onDrop,
637
+ onClick: () => {
638
+ if (!busy && input.current) input.current.click()
639
+ },
640
+ style: zoneStyle,
641
+ },
642
+ idleBody,
643
+ )
644
+ : null,
645
+ busy ? h('div', { style: { ...zoneStyle, cursor: 'default' } }, busyBody) : null,
646
+ phase.kind === 'preview'
647
+ ? h('div', { style: { ...zoneStyle, textAlign: 'left', cursor: 'default', padding: '20px 20px' } }, renderPreview(phase.data))
648
+ : null,
649
+ phase.kind === 'done'
650
+ ? h('div', { style: { ...zoneStyle, textAlign: 'center', cursor: 'default', padding: '28px 20px' } }, doneBody)
651
+ : null,
652
+ phase.kind === 'error'
653
+ ? h(
654
+ 'div',
655
+ {
656
+ role: 'alert',
657
+ style: {
658
+ padding: '12px 14px',
659
+ borderRadius: 10,
660
+ background: 'rgba(240, 62, 62, 0.10)',
661
+ fontSize: 12.5,
662
+ lineHeight: 1.6,
663
+ color: 'var(--dsw-alias-label-primary)',
664
+ },
665
+ },
666
+ h('div', { style: { fontWeight: 600, marginBottom: 4, color: 'var(--dsw-alias-state-error-primary)' } }, '×'),
667
+ phase.message,
668
+ h(
669
+ 'div',
670
+ { style: { marginTop: 10, display: 'flex', gap: 8, flexWrap: 'wrap' } },
671
+ phase.data && phase.data.token
672
+ ? button('secondary', t('retryPublish'), () => publish(phase.updateLocal === true))
673
+ : null,
674
+ button('secondary', t('repick'), () => setPhase({ kind: 'idle' })),
675
+ ),
676
+ )
677
+ : null,
678
+ h(
679
+ 'div',
680
+ { style: { ...small, display: 'flex', justifyContent: 'space-between', gap: 12, flexWrap: 'wrap' } },
681
+ npmLine,
682
+ health && health.packageVersion
683
+ ? h('span', { style: { fontFamily: MONO } }, `publisher ${health.packageVersion}`)
684
+ : null,
685
+ ),
686
+ recentList,
687
+ h('input', {
688
+ type: 'file',
689
+ accept: '.zip,.tgz,.tar.gz,.tar,application/zip',
690
+ ref: input,
691
+ style: { display: 'none' },
692
+ onChange: (event) => {
693
+ const chosen = event.target.files && event.target.files[0]
694
+ take(chosen)
695
+ event.target.value = ''
696
+ },
697
+ }),
698
+ ),
699
+ )
700
+ }
701
+
702
+ return {
703
+ inject: ['slots', 'locale'],
704
+ apply(ctx) {
705
+ ctx.effect(() => ctx.locale.register(NS, 'en', DICT.en), 'publisher: en dictionary')
706
+ ctx.effect(() => ctx.locale.register(NS, 'zh', DICT.zh), 'publisher: zh dictionary')
707
+ const label = ctx.locale.bind(NS)
708
+ ctx.slots.inject('plugins.tab', () =>
709
+ ctx.slots.register(
710
+ { name: 'plugins.tab', id: 'publisher-drop', order: 45, label: () => label('tab') },
711
+ (props) => h(DropTab, { install: props.install, locale: ctx.locale }),
712
+ ),
713
+ )
714
+ },
715
+ }
716
+ },
717
+ })