@beeintel/batch-image 0.0.0-stage → 1.0.1

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 (241) hide show
  1. package/FONT-LICENSE.txt +93 -0
  2. package/README.md +184 -3
  3. package/dist/assets/11st-D7qGO5e4.webp +0 -0
  4. package/dist/assets/UPNG-CPfdwFSy.js +2298 -0
  5. package/dist/assets/adjust-card-B63b81iV.webp +0 -0
  6. package/dist/assets/adjust-final.worker-C2JbTvv5.js +6945 -0
  7. package/dist/assets/amazon-CjTtpZTq.webp +0 -0
  8. package/dist/assets/ascii_art-B4UGbtGs.webp +0 -0
  9. package/dist/assets/auction-j26eVUQO.webp +0 -0
  10. package/dist/assets/background-DGdZUdkL.webp +0 -0
  11. package/dist/assets/background-card-wK7DRpvM.png +0 -0
  12. package/dist/assets/body-CUFdRg8w.webp +0 -0
  13. package/dist/assets/bounded-cutout.worker-BZR6mbaI.js +9615 -0
  14. package/dist/assets/brand-mark-card-cFUeDeO2.webp +0 -0
  15. package/dist/assets/buyma-dAxYNjow.webp +0 -0
  16. package/dist/assets/codec.worker-7W6hmsm6.js +7349 -0
  17. package/dist/assets/contour_lines-C_CqrgV1.webp +0 -0
  18. package/dist/assets/creema-B1tWyCPx.webp +0 -0
  19. package/dist/assets/crop-final.worker-Owin7TvX.js +7035 -0
  20. package/dist/assets/cutout-CzMvV5An.webp +0 -0
  21. package/dist/assets/cutout-card-CN4gNFBz.png +0 -0
  22. package/dist/assets/cutout.worker-DyH6Prbn.js +3894 -0
  23. package/dist/assets/depop-CkVC5Fn1.webp +0 -0
  24. package/dist/assets/dewrinkle-kFzP6LqD.webp +0 -0
  25. package/dist/assets/dither-CcxmO2e6.webp +0 -0
  26. package/dist/assets/douyin-CP_HwBDF.webp +0 -0
  27. package/dist/assets/download.worker-DnGSB6P_.js +17779 -0
  28. package/dist/assets/duotone-Cdg_3fQf.webp +0 -0
  29. package/dist/assets/ebay-CxLfrRAf.webp +0 -0
  30. package/dist/assets/edit-Cv-txfZm.webp +0 -0
  31. package/dist/assets/effect.worker-qu1eCcII.js +9227 -0
  32. package/dist/assets/engraving-BENh1O2O.webp +0 -0
  33. package/dist/assets/etsy-CSvz9GpY.webp +0 -0
  34. package/dist/assets/expand-C60VE9nK.webp +0 -0
  35. package/dist/assets/facebook-Ca2nJJiQ.webp +0 -0
  36. package/dist/assets/film_stock-Bqauwcq4.webp +0 -0
  37. package/dist/assets/final.worker-BnzJ3N5C.js +7035 -0
  38. package/dist/assets/final.worker-Csc1zoYS.js +7054 -0
  39. package/dist/assets/final.worker-DzBFT9xk.js +6922 -0
  40. package/dist/assets/final.worker-XpgKnlaz.js +7217 -0
  41. package/dist/assets/flatlay-CPiVmlAa.webp +0 -0
  42. package/dist/assets/flatlay-fold-B-CRYy87.webp +0 -0
  43. package/dist/assets/flatlay-open-Dzas8okC.webp +0 -0
  44. package/dist/assets/g-market-DXuYK_JH.webp +0 -0
  45. package/dist/assets/ghost-BCEAx_Zx.webp +0 -0
  46. package/dist/assets/ghost-front-WFgA4sUo.webp +0 -0
  47. package/dist/assets/ghost-three-quarter-Rt8cXj34.webp +0 -0
  48. package/dist/assets/gif-CObOIITx.js +303 -0
  49. package/dist/assets/glass_tiles-3IXP-Hmg.webp +0 -0
  50. package/dist/assets/glitch_art-D1i3qben.webp +0 -0
  51. package/dist/assets/glitch_blur-C4q_9zyq.webp +0 -0
  52. package/dist/assets/glow-Bv9EHBU5.webp +0 -0
  53. package/dist/assets/gradient_map-BR-UVYMP.webp +0 -0
  54. package/dist/assets/halftone-CWdKu2_6.webp +0 -0
  55. package/dist/assets/holo_sticker-BQDikLg2.webp +0 -0
  56. package/dist/assets/idus-7diqRNPs.webp +0 -0
  57. package/dist/assets/imagetracer.worker-CgunQTPG.js +7096 -0
  58. package/dist/assets/instagram-Bf0IVidT.webp +0 -0
  59. package/dist/assets/kakao-talk-Df79L_Mv.webp +0 -0
  60. package/dist/assets/kaleidoscope-BxqMZuWo.webp +0 -0
  61. package/dist/assets/karrot-BXFPhDwt.webp +0 -0
  62. package/dist/assets/kaufland-BDDy6e0C.webp +0 -0
  63. package/dist/assets/lazada-ConR4e1O.webp +0 -0
  64. package/dist/assets/lens_flare-DgyiAv_j.webp +0 -0
  65. package/dist/assets/light_leak-kUdpoFuC.webp +0 -0
  66. package/dist/assets/line-Dr1j___B.webp +0 -0
  67. package/dist/assets/linkedin-4s_9Wh03.webp +0 -0
  68. package/dist/assets/lo_fi-DSdl3yY_.webp +0 -0
  69. package/dist/assets/logo-preparation.worker-D9oa7SME.js +420 -0
  70. package/dist/assets/mercado-libre-C8CskEiS.webp +0 -0
  71. package/dist/assets/mercari-jp-DHj7nz4O.webp +0 -0
  72. package/dist/assets/metadata.worker-B_9_BgN1.js +6456 -0
  73. package/dist/assets/mirror_collage-JtSKCeSh.webp +0 -0
  74. package/dist/assets/model-BbeF-fsf.webp +0 -0
  75. package/dist/assets/model-BjWhieit.webp +0 -0
  76. package/dist/assets/momo-BWXO_8Df.webp +0 -0
  77. package/dist/assets/motion_blur-B8YUHeSg.webp +0 -0
  78. package/dist/assets/naver-xQKL8lWg.webp +0 -0
  79. package/dist/assets/nuvemshop-DPt6rnA-.webp +0 -0
  80. package/dist/assets/olx-B87gp-Il.webp +0 -0
  81. package/dist/assets/orient-card-Da0ii6mX.webp +0 -0
  82. package/dist/assets/orient-final.worker-CdF5Y5zD.js +6909 -0
  83. package/dist/assets/orientation-preview.worker-B7uFzz3J.js +6865 -0
  84. package/dist/assets/ort.bundle.min-CreFV8V1.js +9311 -0
  85. package/dist/assets/ort.webgpu.bundle.min-CAudaHZO.js +9311 -0
  86. package/dist/assets/otto-market-DWZyNKJn.webp +0 -0
  87. package/dist/assets/paper_texture-CXphyIrs.webp +0 -0
  88. package/dist/assets/pinterest-ByZqih2J.webp +0 -0
  89. package/dist/assets/polish-DFy6LNG7.webp +0 -0
  90. package/dist/assets/poshmark-DnZi2vA1.webp +0 -0
  91. package/dist/assets/posterize-SpLVGq1s.webp +0 -0
  92. package/dist/assets/preview.worker-DcrCKKWl.js +380 -0
  93. package/dist/assets/qoo10-C1pq81Jx.webp +0 -0
  94. package/dist/assets/rakuten-ulYog1hL.webp +0 -0
  95. package/dist/assets/recolor-mBX7vdFT.webp +0 -0
  96. package/dist/assets/resize-DVEAl0Um.webp +0 -0
  97. package/dist/assets/runtime-0663b902fb3937883a34.wasm +0 -0
  98. package/dist/assets/runtime-355a5c80c7bfdf8737de.mjs +2817 -0
  99. package/dist/assets/runtime-49871f5a4409519797e1.wasm +0 -0
  100. package/dist/assets/runtime-74cf72f9a2b7befc115a.mjs +2817 -0
  101. package/dist/assets/shadow-card-DTZEH60r.png +0 -0
  102. package/dist/assets/shopee-Bxfei6sj.webp +0 -0
  103. package/dist/assets/shopify-wVaBafcF.webp +0 -0
  104. package/dist/assets/shopline-DMoaJ7Bh.webp +0 -0
  105. package/dist/assets/sparkle-CD5GSGip.webp +0 -0
  106. package/dist/assets/ssg-DQoFx5u5.webp +0 -0
  107. package/dist/assets/staging-CIc8pQJ6.webp +0 -0
  108. package/dist/assets/standard-cutout.worker-BYLzdpR-.js +1261 -0
  109. package/dist/assets/text-DQW2mBGp.webp +0 -0
  110. package/dist/assets/textured_glass-D2coxp7n.webp +0 -0
  111. package/dist/assets/tga-VGxWDes0.js +752 -0
  112. package/dist/assets/tilt_shift-BKs46yeX.webp +0 -0
  113. package/dist/assets/transformers.web-DB57cIO5.js +28891 -0
  114. package/dist/assets/tritone-CcR4qizk.webp +0 -0
  115. package/dist/assets/upscale-BrLadyUk.webp +0 -0
  116. package/dist/assets/upscale-creative-DnZnQufJ.webp +0 -0
  117. package/dist/assets/upscale-crisp-Ckdmbsnn.webp +0 -0
  118. package/dist/assets/vinted-1QDsxvC6.webp +0 -0
  119. package/dist/assets/watercolor-CV67zYNE.webp +0 -0
  120. package/dist/assets/watermark-CpPrxaT5.webp +0 -0
  121. package/dist/assets/wave_distortion-CV5jVfK4.webp +0 -0
  122. package/dist/assets/whatsapp-CWJxqzR6.webp +0 -0
  123. package/dist/assets/worker-DfrCFP3O.js +55 -0
  124. package/dist/assets/xerox_noise-CbbHY1S1.webp +0 -0
  125. package/dist/assets/youtube-DS12d5mi.webp +0 -0
  126. package/dist/assets/zalando-CenfWOwz.webp +0 -0
  127. package/dist/browser-adapter.d.ts +4 -0
  128. package/dist/browser-cutout-capability.d.ts +4 -0
  129. package/dist/browser-cutout-resources.d.ts +3 -0
  130. package/dist/browser-local-capabilities.d.ts +5 -0
  131. package/dist/capabilities.d.ts +18 -0
  132. package/dist/chunks/AdjustToolPanel-BELqYSUR.js +195 -0
  133. package/dist/chunks/BackgroundToolPanel-Dy_l8KFl.js +41 -0
  134. package/dist/chunks/BatchMaterials-niGKrga3.js +806 -0
  135. package/dist/chunks/BatchModeChoices-BRqn6zNI.js +111 -0
  136. package/dist/chunks/BatchOutputColorPicker-CCvmIF-b.js +75 -0
  137. package/dist/chunks/BatchReferenceFields-C4t7OSTw.js +316 -0
  138. package/dist/chunks/BeautifyToolPanel-Dc-ddaBC.js +215 -0
  139. package/dist/chunks/BrandMarkToolPanel-FKxXth_3.js +1179 -0
  140. package/dist/chunks/ContentTrimControl-BQfigZPq.js +297 -0
  141. package/dist/chunks/CropToolPanel-BhSuHkYm.js +218 -0
  142. package/dist/chunks/CutoutToolPanel-BfaZZSE_.js +73 -0
  143. package/dist/chunks/DisclosureToolPanel-B_oc5fld.js +76 -0
  144. package/dist/chunks/ExpandToolPanel-D_ZODTUZ.js +67 -0
  145. package/dist/chunks/ImageEffectsToolPanel-BRLPIt4q.js +966 -0
  146. package/dist/chunks/IpAuditToolPanel-DfY-mBSe.js +96 -0
  147. package/dist/chunks/ListingToolPanel-B9Yh3LBK.js +783 -0
  148. package/dist/chunks/MaterialSelectionPlate-DhioUjdW.js +30 -0
  149. package/dist/chunks/MetadataToolPanel-KVrtb3K0.js +104 -0
  150. package/dist/chunks/OrientToolPanel-BTrwaWBm.js +161 -0
  151. package/dist/chunks/PluginActionFooter.vue_vue_type_script_setup_true_lang-C2kJCYeA.js +102 -0
  152. package/dist/chunks/ResizeToolPanel-Ch_-WR74.js +1178 -0
  153. package/dist/chunks/RetouchToolPanel-BTS33Dsd.js +350 -0
  154. package/dist/chunks/ShadowToolPanel-DxJE4eyV.js +254 -0
  155. package/dist/chunks/SvgExportToolPanel-RHmuQARH.js +219 -0
  156. package/dist/chunks/TranslationToolPanel-B_qTA1hM.js +125 -0
  157. package/dist/chunks/UpscaleToolPanel-D0H-j2Tr.js +127 -0
  158. package/dist/chunks/engine-D-T-1RSx.js +69 -0
  159. package/dist/chunks/entry-DK9FjQZ_.js +42946 -0
  160. package/dist/chunks/gpu-CScw5MNG.js +231 -0
  161. package/dist/chunks/hosted-resources-COzZ7nZY.js +8196 -0
  162. package/dist/chunks/loader-circle-UFoEem2a.js +16 -0
  163. package/dist/chunks/motionFeatures-D4miwXxc.js +4405 -0
  164. package/dist/chunks/search-BjTSm1KS.js +18 -0
  165. package/dist/chunks/standard-cutout-vPpP6xBc.js +45 -0
  166. package/dist/chunks/static-logo-2F9ORZWc.js +34 -0
  167. package/dist/config.d.ts +66 -0
  168. package/dist/contracts.d.ts +272 -0
  169. package/dist/index.d.ts +23 -0
  170. package/dist/index.js +13 -0
  171. package/dist/node/catalog.mjs +45 -0
  172. package/dist/node/cli.mjs +11 -0
  173. package/dist/node/index.d.mts +20 -0
  174. package/dist/node/index.mjs +2 -0
  175. package/dist/node/prepare.mjs +114 -0
  176. package/dist/node/vite.mjs +46 -0
  177. package/dist/processing.d.ts +1 -0
  178. package/dist/processing.js +12105 -0
  179. package/dist/remote-contracts.d.ts +114 -0
  180. package/dist/resource-contracts.d.ts +40 -0
  181. package/dist/resources/cutout/9ae2e5375a34fa413530954dc20d085d175faffc86108c13619220d0557f80bf.json +1 -0
  182. package/dist/resources/cutout/f119dabecc64bc436d3d08425dde96ec2598fd40541eba97d8d53a4e8bbdcaea.json +1 -0
  183. package/dist/resources/cutout/resources.json +195 -0
  184. package/dist/resources/cutout/sources.json +294 -0
  185. package/dist/resources.json +1191 -0
  186. package/dist/service-contracts.d.ts +43 -0
  187. package/dist/slots.d.ts +21 -0
  188. package/dist/style.css +1 -0
  189. package/dist/types/batch/api.d.ts +89 -0
  190. package/dist/types/batch/cutout-output.d.ts +2 -0
  191. package/dist/types/batch/features/background/engine.d.mts +12 -0
  192. package/dist/types/batch/features/basic-edit/contracts.d.ts +87 -0
  193. package/dist/types/batch/features/basic-edit/engine.d.mts +96 -0
  194. package/dist/types/batch/features/brand-mark/contracts.d.ts +84 -0
  195. package/dist/types/batch/features/brand-mark/engine.d.mts +68 -0
  196. package/dist/types/batch/features/export-compression/contracts.d.ts +44 -0
  197. package/dist/types/batch/features/export-compression/gifenc.d.ts +33 -0
  198. package/dist/types/batch/features/export-compression/plan.d.ts +45 -0
  199. package/dist/types/batch/features/export-compression/presentation.d.ts +70 -0
  200. package/dist/types/batch/features/export-compression/upng.d.ts +6 -0
  201. package/dist/types/batch/features/final-image/resize.d.mts +15 -0
  202. package/dist/types/batch/features/image-effects/contracts.d.ts +58 -0
  203. package/dist/types/batch/features/image-effects/gpu-pixel-runtime.d.ts +15 -0
  204. package/dist/types/batch/features/image-effects/photo-audit.d.ts +21 -0
  205. package/dist/types/batch/features/image-effects/photo-v7-cpu.d.ts +9 -0
  206. package/dist/types/batch/features/image-effects/profiles-v4.d.ts +157 -0
  207. package/dist/types/batch/features/image-effects/profiles-v5.d.ts +20 -0
  208. package/dist/types/batch/features/image-effects/profiles-v6.d.ts +14 -0
  209. package/dist/types/batch/features/image-effects/profiles-v7.d.ts +53 -0
  210. package/dist/types/batch/features/image-effects/profiles-v8.d.ts +113 -0
  211. package/dist/types/batch/features/image-effects/profiles-v9.d.ts +20 -0
  212. package/dist/types/batch/features/image-translation/params.d.ts +257 -0
  213. package/dist/types/batch/features/listing-remake/transport.d.ts +21 -0
  214. package/dist/types/batch/features/metadata/bytes.d.mts +13 -0
  215. package/dist/types/batch/features/metadata/containers.d.mts +20 -0
  216. package/dist/types/batch/features/metadata/declaration.d.mts +5 -0
  217. package/dist/types/batch/features/metadata/engine.d.mts +9 -0
  218. package/dist/types/batch/features/metadata/exchange.d.mts +48 -0
  219. package/dist/types/batch/features/shadow/contracts.d.ts +43 -0
  220. package/dist/types/batch/features/shadow/engine.d.mts +33 -0
  221. package/dist/types/batch/features/svg-export/download-contract.d.ts +33 -0
  222. package/dist/types/batch/features/svg-export/download-prepare.d.ts +2 -0
  223. package/dist/types/batch/features/svg-export/download.d.ts +7 -0
  224. package/dist/types/batch/features/svg-export/imagetracer.d.ts +6 -0
  225. package/dist/types/batch/features/svg-export/optimizer.d.ts +2 -0
  226. package/dist/types/batch/ids.d.ts +1 -0
  227. package/dist/types/batch/model.d.ts +317 -0
  228. package/dist/types/batch/public/config.d.ts +66 -0
  229. package/dist/types/batch/public/contracts.d.ts +272 -0
  230. package/dist/types/batch/public/remote-contracts.d.ts +114 -0
  231. package/dist/types/batch/public/resource-contracts.d.ts +40 -0
  232. package/dist/types/batch/public/service-contracts.d.ts +43 -0
  233. package/dist/types/batch/queue.d.ts +34 -0
  234. package/dist/types/batch/receipts.d.ts +85 -0
  235. package/dist/types/batch/retention.d.ts +13 -0
  236. package/dist/types/onnxruntime-web.d.ts +5 -0
  237. package/dist/types/plugins/cutout/core/hosted-resources.d.ts +11 -0
  238. package/dist/types/processing.d.ts +18 -0
  239. package/dist/types/shared/svg-security.d.mts +4 -0
  240. package/dist/types/workspace-worker.d.ts +2 -0
  241. package/package.json +95 -6
@@ -0,0 +1,18 @@
1
+ import { J as e } from "./entry-DK9FjQZ_.js";
2
+ /**
3
+ * @license @lucide/vue v1.47.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */
8
+ const c = {
9
+ name: "search",
10
+ size: 24,
11
+ node: [
12
+ ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
13
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
14
+ ]
15
+ }, r = e(c);
16
+ export {
17
+ r as S
18
+ };
@@ -0,0 +1,45 @@
1
+ import { L as n } from "./hosted-resources-COzZ7nZY.js";
2
+ const w = "" + new URL("../assets/standard-cutout.worker-BYLzdpR-.js", import.meta.url).href;
3
+ class f {
4
+ constructor(r) {
5
+ this.options = r;
6
+ }
7
+ worker;
8
+ nextId = 0;
9
+ stopped = !1;
10
+ pending;
11
+ run(r, s = () => {
12
+ }, p = "transparent", d = !1, u = 0) {
13
+ if (!this.options?.resources)
14
+ return Promise.reject(new Error("MISSING_RESOURCE: 显式标准模型/ORT资源尚未配置"));
15
+ if (this.stopped) return Promise.reject(new Error("本机标准抠图已停止"));
16
+ if (this.pending) return Promise.reject(new Error("标准模式上一项尚未结束,请稍后重试。"));
17
+ const o = this.worker ??= this.options?.workerUrl ? n(this.options.workerUrl, { type: "module" }) : n(w, { type: "module" }), t = ++this.nextId;
18
+ return new Promise((h, c) => {
19
+ const i = setTimeout(
20
+ () => this.dispose(new Error("标准模式处理超时,请检查模型下载或选择其它模式。")),
21
+ 12e5
22
+ );
23
+ this.pending = { id: t, reject: c, timer: i }, o.onmessage = ({ data: e }) => {
24
+ this.worker !== o || this.pending?.id !== t || e.id !== t || (e.type === "progress" ? s(e.progress) : e.type === "error" ? this.dispose(new Error(e.error)) : e.type === "result" && (clearTimeout(i), this.pending = void 0, h(e.result)));
25
+ }, o.onerror = (e) => {
26
+ e.preventDefault(), this.worker === o && this.dispose(new Error(e.message || "标准推理Worker无法启动"));
27
+ }, o.postMessage({
28
+ id: t,
29
+ blob: r,
30
+ background: p,
31
+ trimTransparent: d,
32
+ trimPadding: u,
33
+ resources: this.options?.resources
34
+ });
35
+ });
36
+ }
37
+ dispose(r = new Error("本机标准抠图已停止")) {
38
+ this.stopped = !0, this.worker?.terminate(), this.worker = void 0;
39
+ const s = this.pending;
40
+ this.pending = void 0, s && (clearTimeout(s.timer), s.reject(r));
41
+ }
42
+ }
43
+ export {
44
+ f as StandardCutoutEngine
45
+ };
@@ -0,0 +1,34 @@
1
+ import { w as l, F as L, G as c, C as P } from "./hosted-resources-COzZ7nZY.js";
2
+ const f = (o) => {
3
+ throw Object.assign(new Error(o), { code: "INVALID_IMAGE" });
4
+ }, h = [137, 80, 78, 71, 13, 10, 26, 10];
5
+ function N(o) {
6
+ if ((!(o instanceof Uint8Array) || o.length < 2 || o.length > 5 * 1024 * 1024) && f("Logo为空或超过5MiB限制"), o.length >= 8 && h.every((e, g) => o[g] === e)) {
7
+ let e = 8, g = 0, a = !1, t = !1;
8
+ for (; e < o.length; ) {
9
+ (++g > 4096 || e + 12 > o.length) && f("Logo PNG段不完整");
10
+ const n = l(o).getUint32(e), r = e + 12 + n;
11
+ (n > 2147483647 || r > o.length) && f("Logo PNG段越界");
12
+ const i = L(o, e + 4, e + 8);
13
+ if ((!/^[A-Za-z]{4}$/.test(i) || i[2] !== i[2].toUpperCase() || c(o.subarray(e + 4, r - 4)) !== l(o).getUint32(r - 4)) && f("Logo PNG段或CRC无效"), (g === 1 && (i !== "IHDR" || n !== 13) || g > 1 && i === "IHDR") && f("Logo PNG头无效"), ["acTL", "fcTL", "fdAT"].includes(i) && f("Logo必须为静态单帧,不支持PNG动画"), i === "IDAT" ? (t && f("Logo PNG图像段顺序无效"), a = !0) : a && (t = !0), e = r, i === "IEND") {
14
+ (n || e !== o.length || !a) && f("Logo PNG结尾无效");
15
+ return;
16
+ }
17
+ }
18
+ f("Logo PNG缺少结尾");
19
+ }
20
+ if (P(o, 0, "RIFF") && P(o, 8, "WEBP")) {
21
+ (o.length < 20 || l(o).getUint32(4, !0) + 8 !== o.length) && f("Logo WebP RIFF长度无效");
22
+ let e = 12, g = 0, a = !1;
23
+ for (; e < o.length; ) {
24
+ (++g > 4096 || e + 8 > o.length) && f("Logo WebP段不完整");
25
+ const t = L(o, e, e + 4), n = l(o).getUint32(e + 4, !0), r = e + 8 + n, i = r + n % 2;
26
+ (i > o.length || !/^[\x20-\x7e]{4}$/.test(t) || n % 2 && o[r] !== 0) && f("Logo WebP段越界或padding无效"), (t === "ANIM" || t === "ANMF") && f("Logo必须为静态单帧,不支持WebP动画"), t === "VP8X" && ((g !== 1 || a || n !== 10) && f("Logo WebP扩展头无效"), a = !0, o[e + 8] & 2 && f("Logo必须为静态单帧,不支持WebP动画")), e = i;
27
+ }
28
+ return;
29
+ }
30
+ o[0] === 255 && o[1] === 216 || f("Logo仅支持PNG、JPEG及WebP");
31
+ }
32
+ export {
33
+ N as a
34
+ };
@@ -0,0 +1,66 @@
1
+ /** An exact allowlist. New tools, entries and execution modes stay closed. */
2
+ export interface WorkspaceCapability {
3
+ toolId: string;
4
+ entryId?: string;
5
+ execution: 'local' | 'remote';
6
+ mode?: string;
7
+ }
8
+ export type WorkspaceResetAction = 'draft' | 'newBatch' | 'restoreVersion';
9
+ export interface WorkspaceResetRequest {
10
+ readonly action: WorkspaceResetAction;
11
+ /** full clears the tool draft; parameters preserves its selected assets/mode where supported. */
12
+ readonly intent?: 'full' | 'parameters';
13
+ readonly toolId?: string;
14
+ readonly entryId?: string;
15
+ readonly batchId: string;
16
+ }
17
+ export interface WorkspaceParameterDefault {
18
+ readonly schemaVersion: 1;
19
+ readonly toolId: string;
20
+ readonly entryId?: string;
21
+ /** Existing tool parameter schema. Asset/task identities are never accepted in defaults. */
22
+ readonly params: Readonly<Record<string, unknown>>;
23
+ }
24
+ export interface WorkspaceNavigationRequest {
25
+ readonly reason: 'busy' | 'history' | 'readonly';
26
+ readonly batchId: string;
27
+ readonly toolId?: string;
28
+ readonly entryId?: string;
29
+ }
30
+ export interface WorkspaceConfig {
31
+ toolOptions?: {
32
+ translation?: {
33
+ targets: readonly {
34
+ code: string;
35
+ label: string;
36
+ }[];
37
+ };
38
+ expand?: {
39
+ prompt?: boolean;
40
+ ratios?: readonly string[];
41
+ };
42
+ };
43
+ /** The host opens its route/container. The core never constructs a product URL. */
44
+ navigation?: {
45
+ openWorkspace(request: WorkspaceNavigationRequest): void | Promise<void>;
46
+ };
47
+ parameterDefaults?: readonly WorkspaceParameterDefault[];
48
+ capabilities?: readonly WorkspaceCapability[];
49
+ visibility?: {
50
+ brand?: boolean;
51
+ history?: boolean;
52
+ import?: boolean;
53
+ export?: boolean;
54
+ newBatch?: boolean;
55
+ draftReset?: boolean;
56
+ theme?: boolean;
57
+ language?: boolean;
58
+ /** 服务可用性诊断与重新检测入口;不影响实际执行能力检查。 */
59
+ serviceStatus?: boolean;
60
+ };
61
+ /** Host confirmation/reset policy. False or rejection preserves the original state. */
62
+ beforeReset?(request: WorkspaceResetRequest): boolean | Promise<boolean>;
63
+ }
64
+ /** V1 compatibility only: omitting config retains the original metadata tool.
65
+ * Passing an explicit {} closes it too. Every newly introduced tool stays closed. */
66
+ export declare const DEFAULT_WORKSPACE_CONFIG: WorkspaceConfig;
@@ -0,0 +1,272 @@
1
+ import type { WorkspaceConfig } from './config';
2
+ import type { WorkspaceServices } from './service-contracts';
3
+ export * from './service-contracts';
4
+ /** Version 1 candidate surface. No product identity, authorization or wallet objects. */
5
+ export interface MetadataParameters {
6
+ version: 1;
7
+ removeGps: true;
8
+ removeDevice: true;
9
+ removeSerial: true;
10
+ removeTime: boolean;
11
+ removeAuthorComments: boolean;
12
+ }
13
+ export interface MetadataResult {
14
+ blob: Blob;
15
+ inputSha256: string;
16
+ outputSha256: string;
17
+ changed: boolean;
18
+ format: 'png' | 'jpeg' | 'webp';
19
+ removedCount: number;
20
+ removed: Record<'gps' | 'device' | 'serial' | 'time' | 'authorComments', number>;
21
+ }
22
+ export interface MetadataExecutor {
23
+ run(blob: Blob, params: MetadataParameters | {
24
+ execution: 'browser';
25
+ mode: 'declare';
26
+ }, expectedSha256?: string, signal?: AbortSignal): Promise<MetadataResult>;
27
+ dispose(): void;
28
+ }
29
+ export interface WorkspaceFile {
30
+ name: string;
31
+ blob: Blob;
32
+ itemId: string;
33
+ versionId: string;
34
+ }
35
+ export interface WorkspaceAssetIdentity {
36
+ assetId: string;
37
+ assetVersionId: string;
38
+ sha256: string;
39
+ }
40
+ export interface WorkspaceAssetReference extends WorkspaceAssetIdentity {
41
+ mime: string;
42
+ bytes: number;
43
+ width: number;
44
+ height: number;
45
+ }
46
+ export interface WorkspaceExternalSource {
47
+ readonly url: string;
48
+ readonly expectedSha256?: string;
49
+ }
50
+ export interface WorkspaceExecutionPlan {
51
+ readonly clientRequestId: string;
52
+ readonly operationId: string;
53
+ readonly itemId: string;
54
+ readonly inputVersionId: string;
55
+ readonly inputSha256: string;
56
+ readonly toolId: string;
57
+ readonly toolVersion: '1' | '2';
58
+ readonly params: Readonly<Record<string, unknown>>;
59
+ }
60
+ export interface WorkspaceDisclosure {
61
+ method?: 'manual' | 'ai';
62
+ decision: 'YES' | 'NO' | 'REVIEW';
63
+ reason: string;
64
+ status: 'verified' | 'unchanged' | 'review';
65
+ verified: boolean;
66
+ keywordPresent: boolean;
67
+ fileSha256: string;
68
+ }
69
+ export type WorkspaceLocalResult = {
70
+ kind: 'image';
71
+ blob: Blob;
72
+ reason?: string;
73
+ disclosure?: WorkspaceDisclosure;
74
+ } | {
75
+ kind: 'analysis';
76
+ reason: string;
77
+ skipped?: boolean;
78
+ disclosure?: WorkspaceDisclosure;
79
+ };
80
+ export interface WorkspaceLocalExecutor {
81
+ run(plan: WorkspaceExecutionPlan, input: Blob, context: {
82
+ signal: AbortSignal;
83
+ readAsset(reference: WorkspaceAssetIdentity): Promise<Blob>;
84
+ progress(value: {
85
+ stage: 'decode' | 'process' | 'encode';
86
+ completed: number;
87
+ total?: number;
88
+ }): void;
89
+ }): Promise<WorkspaceLocalResult>;
90
+ dispose(): void;
91
+ }
92
+ export interface WorkspaceLocalCapability {
93
+ supports?(params: Readonly<Record<string, unknown>>): boolean;
94
+ createExecutor(): WorkspaceLocalExecutor;
95
+ }
96
+ import type { WorkspaceRemoteExecution, WorkspaceRemoteResultDetails } from './remote-contracts';
97
+ export * from './remote-contracts';
98
+ export interface WorkspacePageSession {
99
+ readonly active: boolean;
100
+ readonly batchId: string | undefined;
101
+ start(): Promise<void>;
102
+ bind(batchId: string): void;
103
+ stop(): void;
104
+ }
105
+ export interface BatchWorkspaceAdapter {
106
+ namespace: string;
107
+ /** SDK 页签绑定;需配合按项目读取的持久化,缺省保留旧的命名空间单写者契约。 */
108
+ pageSession?: () => WorkspacePageSession;
109
+ services?: WorkspaceServices;
110
+ coordination?: {
111
+ acquire(namespace: string): Promise<() => void | Promise<void>>;
112
+ };
113
+ assets: {
114
+ read(key: string): Promise<Blob | undefined>;
115
+ write(key: string, blob: Blob): Promise<void>;
116
+ remove(key: string): Promise<void>;
117
+ describe(blob: Blob): Promise<{
118
+ sha256: string;
119
+ width: number;
120
+ height: number;
121
+ }>;
122
+ /** Resolve a frozen identity without relying on mutable UI draft metadata. */
123
+ resolveReference?(identity: WorkspaceAssetIdentity, signal?: AbortSignal): Promise<WorkspaceAssetReference>;
124
+ readReference?(reference: WorkspaceAssetReference, signal?: AbortSignal): Promise<Blob>;
125
+ /** Explicit host-owned external IO. Frozen versions require an expected hash. */
126
+ readExternal?(source: WorkspaceExternalSource, signal?: AbortSignal): Promise<Blob>;
127
+ };
128
+ execution?: {
129
+ local?: Readonly<Record<string, WorkspaceLocalCapability>>;
130
+ remote?: WorkspaceRemoteExecution;
131
+ };
132
+ persistence: {
133
+ load(page?: {
134
+ batchId?: string;
135
+ }): Promise<unknown>;
136
+ save(snapshot: unknown): Promise<void>;
137
+ loadBatch?(batchId: string): Promise<unknown>;
138
+ list?(): Promise<unknown[]>;
139
+ removeBatch?(batchId: string): Promise<void>;
140
+ };
141
+ metadata: {
142
+ createExecutor(): MetadataExecutor;
143
+ };
144
+ download?(file: WorkspaceFile): Promise<void> | void;
145
+ }
146
+ export type WorkspaceCommand = {
147
+ type: 'updateConfig';
148
+ config: WorkspaceConfig;
149
+ display?: WorkspaceDisplay;
150
+ } | {
151
+ type: 'updateContext';
152
+ adapter: BatchWorkspaceAdapter;
153
+ revision: string;
154
+ display?: WorkspaceDisplay;
155
+ } | {
156
+ type: 'newBatch';
157
+ } | {
158
+ type: 'openBatch';
159
+ batchId: string;
160
+ } | {
161
+ type: 'restoreVersion';
162
+ itemId: string;
163
+ versionId: string;
164
+ } | {
165
+ type: 'resetDraft';
166
+ toolId: string;
167
+ entryId?: string;
168
+ } | {
169
+ type: 'runTool';
170
+ toolId: string;
171
+ params: Readonly<Record<string, unknown>>;
172
+ } | {
173
+ type: 'cancelAttempt';
174
+ attemptId: string;
175
+ } | {
176
+ type: 'queryAttempt' | 'stopWaiting' | 'resumeWaiting' | 'cancelRemote';
177
+ attemptId: string;
178
+ } | {
179
+ type: 'importFiles';
180
+ files: File[];
181
+ } | {
182
+ type: 'openTool';
183
+ toolId: string;
184
+ entryId?: string;
185
+ } | {
186
+ type: 'runMetadataCleanup';
187
+ removeTime?: boolean;
188
+ removeAuthorComments?: boolean;
189
+ } | {
190
+ type: 'select';
191
+ itemIds: string[];
192
+ } | {
193
+ type: 'exportCurrent';
194
+ itemIds?: string[];
195
+ };
196
+ export type WorkspaceCommandResult = {
197
+ status: 'completed';
198
+ operationId?: string;
199
+ files?: readonly WorkspaceFile[];
200
+ } | {
201
+ status: 'rejected';
202
+ code: string;
203
+ message: string;
204
+ };
205
+ export interface WorkspaceSnapshot {
206
+ readonly schemaVersion: 1;
207
+ readonly context: Readonly<{
208
+ namespace: string;
209
+ revision: string;
210
+ }>;
211
+ readonly writable: boolean;
212
+ readonly ready: boolean;
213
+ readonly batchId: string;
214
+ readonly selectedIds: readonly string[];
215
+ readonly items: readonly {
216
+ readonly id: string;
217
+ readonly name: string;
218
+ readonly currentVersionId: string;
219
+ readonly versions: readonly {
220
+ readonly id: string;
221
+ readonly sha256?: string;
222
+ readonly parentVersionId?: string;
223
+ }[];
224
+ }[];
225
+ readonly attempts: readonly {
226
+ readonly id: string;
227
+ readonly clientRequestId: string;
228
+ readonly operationId: string;
229
+ readonly itemId: string;
230
+ readonly taskId?: string;
231
+ readonly inputVersionId?: string;
232
+ readonly status: string;
233
+ readonly statusVersion: number;
234
+ readonly outcome?: Readonly<Omit<WorkspaceRemoteResultDetails, 'disclosure'>> & {
235
+ readonly disclosure?: Readonly<WorkspaceDisclosure> | null;
236
+ };
237
+ readonly admission?: 'accepted' | 'not_accepted' | 'unknown';
238
+ readonly remoteExecutionStatus?: string;
239
+ readonly publicationStatus?: 'pending' | 'unknown' | 'published';
240
+ readonly waitingStopped?: boolean;
241
+ readonly applied?: boolean;
242
+ readonly error?: string;
243
+ }[];
244
+ readonly operations: readonly {
245
+ readonly id: string;
246
+ readonly toolId: string;
247
+ readonly toolVersion: string;
248
+ readonly params: Readonly<Record<string, unknown>>;
249
+ }[];
250
+ }
251
+ export interface WorkspaceEvent {
252
+ readonly type: 'ready' | 'changed' | 'disposed' | 'error';
253
+ readonly snapshot: WorkspaceSnapshot;
254
+ readonly message?: string;
255
+ }
256
+ export interface BatchWorkspaceHandle {
257
+ command(command: WorkspaceCommand): Promise<WorkspaceCommandResult>;
258
+ snapshot(): WorkspaceSnapshot;
259
+ subscribe(listener: (event: WorkspaceEvent) => void): () => void;
260
+ dispose(): Promise<void>;
261
+ }
262
+ export interface BatchWorkspaceProps {
263
+ adapter: BatchWorkspaceAdapter;
264
+ config?: WorkspaceConfig;
265
+ display?: WorkspaceDisplay;
266
+ revision?: string;
267
+ onEvent?: (event: WorkspaceEvent) => void;
268
+ }
269
+ export interface WorkspaceDisplay {
270
+ locale?: 'en' | 'zh-CN' | 'ja' | 'ko' | 'ar' | 'es' | 'fr' | 'de';
271
+ theme?: 'light' | 'dark' | 'system';
272
+ }
@@ -0,0 +1,23 @@
1
+ import { type DefineComponent, type SlotsType, type ComputedOptions, type MethodOptions, type ComponentOptionsMixin, type PublicProps } from 'vue';
2
+ import type { WorkspaceConfig } from './config';
3
+ import type { WorkspaceSlots } from './slots';
4
+ import type { BatchWorkspaceAdapter, BatchWorkspaceHandle, BatchWorkspaceProps, WorkspaceDisplay } from './contracts';
5
+ export * from './contracts';
6
+ export * from './config';
7
+ export * from './slots';
8
+ export * from './resource-contracts';
9
+ export { createBrowserCutoutCapability } from './browser-cutout-capability';
10
+ export { createBrowserCutoutResources } from './browser-cutout-resources';
11
+ export { resolveWorkspaceCapability, workspaceExecutionSupport, workspaceToolVisible, } from './capabilities';
12
+ export { createBrowserBatchAdapter } from './browser-adapter';
13
+ export { createBrowserLocalCapabilities } from './browser-local-capabilities';
14
+ export declare function createBatchWorkspace(options: {
15
+ adapter: BatchWorkspaceAdapter;
16
+ config?: WorkspaceConfig;
17
+ slots?: WorkspaceSlots;
18
+ display?: WorkspaceDisplay;
19
+ revision?: string;
20
+ }): BatchWorkspaceHandle & {
21
+ mount(container: HTMLElement): Promise<void>;
22
+ };
23
+ export declare const BatchWorkspace: DefineComponent<BatchWorkspaceProps, BatchWorkspaceHandle, {}, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, BatchWorkspaceProps, {}, SlotsType<WorkspaceSlots>>;
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import { b7 as r, b8 as s, b9 as o, ba as t, bb as c, bc as b, bd as p, be as i, bf as l, bg as u } from "./chunks/entry-DK9FjQZ_.js";
2
+ export {
3
+ r as BatchWorkspace,
4
+ s as DEFAULT_WORKSPACE_CONFIG,
5
+ o as createBatchWorkspace,
6
+ t as createBrowserBatchAdapter,
7
+ c as createBrowserCutoutCapability,
8
+ b as createBrowserCutoutResources,
9
+ p as createBrowserLocalCapabilities,
10
+ i as resolveWorkspaceCapability,
11
+ l as workspaceExecutionSupport,
12
+ u as workspaceToolVisible
13
+ };
@@ -0,0 +1,45 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { readFile } from 'node:fs/promises';
3
+
4
+ const metadata = new URL('../resources/cutout/', import.meta.url);
5
+ export function digest(bytes) {
6
+ return createHash('sha256').update(bytes).digest('hex');
7
+ }
8
+ export async function readCatalog() {
9
+ const catalog = JSON.parse(await readFile(new URL('resources.json', metadata), 'utf8'));
10
+ const names = new Set();
11
+ if (catalog.schemaVersion !== 1 || !Array.isArray(catalog.assets) || !catalog.assets.length)
12
+ throw Error('Invalid SDK resource catalog');
13
+ for (const asset of catalog.assets) {
14
+ if (
15
+ !/^[a-f0-9]{64}\.(bin|json)$/.test(asset.name) ||
16
+ asset.name.split('.')[0] !== asset.sha256 ||
17
+ names.has(asset.name) ||
18
+ !Number.isSafeInteger(asset.bytes) ||
19
+ asset.bytes <= 0 ||
20
+ asset.bytes > 32 * 1024 * 1024 ||
21
+ ![
22
+ 'application/octet-stream',
23
+ 'application/json',
24
+ 'application/wasm',
25
+ 'text/javascript',
26
+ ].includes(asset.mime)
27
+ )
28
+ throw Error('Invalid SDK resource entry');
29
+ names.add(asset.name);
30
+ }
31
+ return catalog;
32
+ }
33
+ export async function readManifest(binding) {
34
+ if (
35
+ !/^[a-f0-9]{64}\.json$/.test(binding.manifest) ||
36
+ binding.manifest !== `${binding.manifestSha256}.json`
37
+ )
38
+ throw Error('Invalid SDK manifest binding');
39
+ const bytes = await readFile(new URL(binding.manifest, metadata));
40
+ if (digest(bytes) !== binding.manifestSha256) throw Error('SDK model manifest hash mismatch');
41
+ return { bytes, manifest: JSON.parse(bytes) };
42
+ }
43
+ export async function readSources() {
44
+ return JSON.parse(await readFile(new URL('sources.json', metadata), 'utf8'));
45
+ }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import { prepareBatchResources } from './prepare.mjs';
3
+ import path from 'node:path';
4
+
5
+ const args = process.argv.slice(2);
6
+ const offline = args.includes('--offline');
7
+ const positional = args.filter((arg) => arg !== '--offline');
8
+ if (positional.length !== 1 || positional.some((arg) => arg.startsWith('-')))
9
+ throw Error('Usage: batch-images-prepare-resources <directory> [--offline]');
10
+ const assets = await prepareBatchResources({ directory: path.resolve(positional[0]), offline });
11
+ console.log(`Batch resources verified: ${assets.length} immutable files`);
@@ -0,0 +1,20 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface BatchResourceAsset {
3
+ name: string;
4
+ sha256: string;
5
+ bytes: number;
6
+ mime: string;
7
+ }
8
+ export interface BatchResourceOptions {
9
+ /** Explicit local resource/cache directory, kept outside Git. */
10
+ directory: string;
11
+ }
12
+ export declare function verifyBatchResources(
13
+ options: BatchResourceOptions,
14
+ ): Promise<BatchResourceAsset[]>;
15
+ export declare function prepareBatchResources(
16
+ options: BatchResourceOptions & { offline?: boolean },
17
+ ): Promise<BatchResourceAsset[]>;
18
+ export declare function createBatchResourcesPlugin(
19
+ options: BatchResourceOptions & { publicPath?: string },
20
+ ): Plugin;
@@ -0,0 +1,2 @@
1
+ export { prepareBatchResources, verifyBatchResources } from './prepare.mjs';
2
+ export { createBatchResourcesPlugin } from './vite.mjs';
@@ -0,0 +1,114 @@
1
+ import { createRequire } from 'node:module';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { mkdir, readFile, writeFile, rename, rm } from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import { digest, readCatalog, readManifest, readSources } from './catalog.mjs';
6
+
7
+ const require = createRequire(import.meta.url);
8
+ function resourceDirectory(options) {
9
+ if (!options?.directory?.trim()) throw Error('An explicit resource directory is required');
10
+ return path.resolve(options.directory);
11
+ }
12
+ async function valid(directory, asset) {
13
+ try {
14
+ const bytes = await readFile(path.join(directory, asset.name));
15
+ return bytes.length === asset.bytes && digest(bytes) === asset.sha256;
16
+ } catch (error) {
17
+ if (error.code === 'ENOENT') return false;
18
+ throw error;
19
+ }
20
+ }
21
+ async function download(url, size, sha256) {
22
+ const response = await fetch(url, {
23
+ headers: { 'User-Agent': 'Mozilla/5.0', Referer: 'https://img.ly/' },
24
+ signal: AbortSignal.timeout(20 * 60_000),
25
+ });
26
+ if (!response.ok || !response.body) throw Error(`Resource download failed: ${response.status}`);
27
+ const parts = [];
28
+ let received = 0;
29
+ for await (const part of response.body) {
30
+ received += part.length;
31
+ if (received > size) throw Error('Resource exceeds declared size');
32
+ parts.push(part);
33
+ }
34
+ const bytes = Buffer.concat(parts);
35
+ if (bytes.length !== size || digest(bytes) !== sha256)
36
+ throw Error('Resource download integrity failure');
37
+ return bytes;
38
+ }
39
+ async function store(directory, name, bytes, expected) {
40
+ if (
41
+ !/^[a-f0-9]{64}\.(bin|json)$/.test(name) ||
42
+ name.split('.')[0] !== expected ||
43
+ digest(bytes) !== expected
44
+ )
45
+ throw Error('Resource name/hash mismatch');
46
+ const target = path.join(directory, name);
47
+ const temporary = `${target}.${randomUUID()}.tmp`;
48
+ try {
49
+ await writeFile(temporary, bytes);
50
+ await rename(temporary, target);
51
+ } finally {
52
+ await rm(temporary, { force: true });
53
+ }
54
+ }
55
+ export async function verifyBatchResources(options) {
56
+ const directory = resourceDirectory(options);
57
+ const catalog = await readCatalog();
58
+ for (const asset of catalog.assets) {
59
+ if (!(await valid(directory, asset)))
60
+ throw Error(
61
+ `Batch resource missing or corrupt: ${asset.name}; run batch-images-prepare-resources`,
62
+ );
63
+ }
64
+ return catalog.assets;
65
+ }
66
+ export async function prepareBatchResources(options) {
67
+ const directory = resourceDirectory(options);
68
+ if (options.offline) return verifyBatchResources(options);
69
+ const index = await readCatalog();
70
+ const sources = await readSources();
71
+ await mkdir(directory, { recursive: true });
72
+ for (const [model, binding] of Object.entries(index.models)) {
73
+ const { bytes: manifestBytes, manifest } = await readManifest(binding);
74
+ for (const [logicalPath, entry] of Object.entries(manifest.files)) {
75
+ const assets = entry.chunks.map((chunk) => ({
76
+ name: chunk.name,
77
+ sha256: chunk.sha256,
78
+ bytes: chunk.offsets[1] - chunk.offsets[0],
79
+ }));
80
+ if ((await Promise.all(assets.map((asset) => valid(directory, asset)))).every(Boolean))
81
+ continue;
82
+ const source = sources.find(
83
+ (item) =>
84
+ item.logicalPath === logicalPath &&
85
+ (model === 'isnet_fp16' ? item.upstreamChunks : !item.upstreamChunks),
86
+ );
87
+ if (!source || source.sha256 !== entry.sha256 || source.size !== entry.size)
88
+ throw Error('Source does not match the SDK manifest');
89
+ let bytes;
90
+ if (source.npm) {
91
+ const transformersRequire = createRequire(require.resolve('@huggingface/transformers'));
92
+ const runtime = path.dirname(transformersRequire.resolve('onnxruntime-web'));
93
+ bytes = await readFile(path.join(runtime, path.basename(source.npmPath)));
94
+ } else if (source.upstreamChunks) {
95
+ const parts = [];
96
+ for (const chunk of source.upstreamChunks)
97
+ parts.push(
98
+ await download(
99
+ new URL(chunk.name, source.url).href,
100
+ chunk.offsets[1] - chunk.offsets[0],
101
+ chunk.hash,
102
+ ),
103
+ );
104
+ bytes = Buffer.concat(parts);
105
+ } else bytes = await download(source.url, source.size, source.sha256);
106
+ if (bytes.length !== entry.size || digest(bytes) !== entry.sha256)
107
+ throw Error(`SDK source integrity failure: ${logicalPath}`);
108
+ for (const chunk of entry.chunks)
109
+ await store(directory, chunk.name, bytes.subarray(...chunk.offsets), chunk.sha256);
110
+ }
111
+ await store(directory, binding.manifest, manifestBytes, binding.manifestSha256);
112
+ }
113
+ return verifyBatchResources(options);
114
+ }