@capyclaw/ppt-suite 2.5.70 → 2.5.72

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 (109) hide show
  1. package/composition.lock.json +27 -27
  2. package/contract/ppt-contract.json +1 -1
  3. package/dsh-suite.json +27 -17
  4. package/node_modules/@capyclaw/asset-service/dsh-suite.json +1 -1
  5. package/node_modules/@capyclaw/asset-service/package.json +1 -1
  6. package/node_modules/@capyclaw/asset-service/src/index.mjs +4 -3
  7. package/node_modules/@capyclaw/document-workbench/package.json +6 -3
  8. package/node_modules/@capyclaw/document-workbench/src/client/index.mjs +56 -3
  9. package/node_modules/@capyclaw/document-workbench/src/client/visibility.mjs +112 -0
  10. package/node_modules/@capyclaw/document-workbench/src/model/manifest.mjs +6 -4
  11. package/node_modules/@capyclaw/document-workbench/src/model/ops.mjs +7 -2
  12. package/node_modules/@capyclaw/document-workbench/src/session/index.mjs +8 -0
  13. package/node_modules/@capyclaw/document-workbench/src/store/file-backend.mjs +17 -10
  14. package/node_modules/@capyclaw/document-workbench/src/store/projection.mjs +39 -0
  15. package/node_modules/@capyclaw/document-workbench/src/testing/index.mjs +14 -11
  16. package/node_modules/@capyclaw/editor-host/dsh-suite.json +1 -1
  17. package/node_modules/@capyclaw/editor-host/package.json +1 -1
  18. package/node_modules/@capyclaw/editor-host/src/index.mjs +12 -21
  19. package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
  20. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +3 -1
  21. package/node_modules/@capyclaw/foundation/abi/index.mjs +15 -0
  22. package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
  23. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +21 -4
  24. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +5 -1
  25. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +5 -2
  26. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +4 -0
  27. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +13 -3
  28. package/node_modules/@capyclaw/foundation/package.json +1 -1
  29. package/node_modules/@capyclaw/plugin-kit/package.json +4 -1
  30. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +5 -2
  31. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
  32. package/node_modules/@capyclaw/plugin-kit/src/ledger.mjs +151 -0
  33. package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
  34. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +13 -5
  35. package/node_modules/@capyclaw/portal/package.json +1 -1
  36. package/node_modules/@capyclaw/ppt-editor/app.js +458 -10
  37. package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +1 -1
  38. package/node_modules/@capyclaw/ppt-editor/heartbeat-worker.js +5 -2
  39. package/node_modules/@capyclaw/ppt-editor/index.html +4 -0
  40. package/node_modules/@capyclaw/ppt-editor/package.json +2 -2
  41. package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +1 -1
  42. package/node_modules/@capyclaw/ppt-skill-api/package.json +1 -1
  43. package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1 -1
  44. package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +1 -1
  45. package/node_modules/@capyclaw/ppt-skill-proposal/package.json +1 -1
  46. package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +1 -1
  47. package/node_modules/@capyclaw/ppt-workbench/core/deck-layout.js +3 -1
  48. package/node_modules/@capyclaw/ppt-workbench/core/ops/slide.js +9 -3
  49. package/node_modules/@capyclaw/ppt-workbench/core/text.js +14 -2
  50. package/node_modules/@capyclaw/ppt-workbench/package.json +10 -8
  51. package/node_modules/@capyclaw/ppt-workbench/plugin.mjs +13 -1
  52. package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +1 -1
  53. package/node_modules/@capyclaw/ppt-workbench/server/embedded-host.mjs +200 -29
  54. package/node_modules/@capyclaw/ppt-workbench/server/relay.mjs +10 -7
  55. package/node_modules/@capyclaw/ppt-workbench/server/shared/SHARED_MANIFEST.json +4 -4
  56. package/node_modules/@capyclaw/ppt-workbench/server/store/backends/file-backend.mjs +3 -0
  57. package/node_modules/@capyclaw/ppt-workbench/server/store/checkpoints.mjs +4 -1
  58. package/node_modules/@capyclaw/ppt-workbench/server/store/index.mjs +4 -0
  59. package/node_modules/@capyclaw/ppt-workbench/server/store/sessions.mjs +139 -4
  60. package/node_modules/@capyclaw/ppt-workbench/server/store/shape.mjs +37 -0
  61. package/node_modules/@capyclaw/service-broker/README.md +1 -1
  62. package/node_modules/@capyclaw/service-broker/lib/host.mjs +11 -6
  63. package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +13 -5
  64. package/node_modules/@capyclaw/service-broker/package.json +1 -1
  65. package/node_modules/@capyclaw/service-host/dsh-suite.json +1 -1
  66. package/node_modules/@capyclaw/service-host/package.json +2 -2
  67. package/node_modules/@capyclaw/service-host/src/index.mjs +45 -27
  68. package/node_modules/@capyclaw/skills-service/README.md +42 -10
  69. package/node_modules/@capyclaw/skills-service/package.json +6 -3
  70. package/node_modules/@capyclaw/skills-service/server.mjs +129 -51
  71. package/node_modules/@capyclaw/suite-kit/README.md +289 -0
  72. package/node_modules/@capyclaw/suite-kit/bin/dsh-domain.mjs +98 -0
  73. package/node_modules/@capyclaw/suite-kit/bin/dsh-suite.mjs +174 -0
  74. package/node_modules/@capyclaw/suite-kit/client/embed.js +35 -0
  75. package/node_modules/@capyclaw/suite-kit/domain.schema.json +129 -0
  76. package/node_modules/@capyclaw/suite-kit/package.json +58 -0
  77. package/node_modules/@capyclaw/suite-kit/src/activation-registry.mjs +184 -0
  78. package/node_modules/@capyclaw/suite-kit/src/artifacts.mjs +131 -0
  79. package/node_modules/@capyclaw/suite-kit/src/capability.mjs +181 -0
  80. package/node_modules/@capyclaw/suite-kit/src/compose.mjs +201 -0
  81. package/node_modules/@capyclaw/suite-kit/src/domain.mjs +138 -0
  82. package/node_modules/@capyclaw/suite-kit/src/embed.mjs +81 -0
  83. package/node_modules/@capyclaw/suite-kit/src/host.mjs +251 -0
  84. package/node_modules/@capyclaw/suite-kit/src/index.mjs +24 -0
  85. package/node_modules/@capyclaw/suite-kit/src/manifest.mjs +263 -0
  86. package/node_modules/@capyclaw/suite-kit/src/orchestration.mjs +100 -0
  87. package/node_modules/@capyclaw/suite-kit/src/profile.mjs +584 -0
  88. package/node_modules/@capyclaw/suite-kit/src/surface.mjs +28 -0
  89. package/node_modules/@capyclaw/suite-kit/suite.schema.json +128 -0
  90. package/node_modules/@capyclaw/tool-host/dsh-suite.json +1 -1
  91. package/node_modules/@capyclaw/tool-host/lib/host.mjs +15 -4
  92. package/node_modules/@capyclaw/tool-host/package.json +1 -1
  93. package/node_modules/@capyclaw/tool-host/src/index.mjs +19 -5
  94. package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +71 -3
  95. package/node_modules/@capyclaw/work-store/README.md +83 -0
  96. package/node_modules/@capyclaw/work-store/STANDARD.md +263 -0
  97. package/node_modules/@capyclaw/work-store/cordis.patch.yml +3 -0
  98. package/node_modules/@capyclaw/work-store/dsh-suite.json +33 -0
  99. package/node_modules/@capyclaw/work-store/icon.svg +7 -0
  100. package/node_modules/@capyclaw/work-store/lib/host.mjs +21 -0
  101. package/node_modules/@capyclaw/work-store/package.json +68 -0
  102. package/node_modules/@capyclaw/work-store/src/backend.mjs +90 -0
  103. package/node_modules/@capyclaw/work-store/src/db.mjs +199 -0
  104. package/node_modules/@capyclaw/work-store/src/envelope.mjs +132 -0
  105. package/node_modules/@capyclaw/work-store/src/index.mjs +571 -0
  106. package/node_modules/@capyclaw/work-store/src/interop.mjs +70 -0
  107. package/node_modules/@capyclaw/work-store/src/refs.mjs +99 -0
  108. package/node_modules/@capyclaw/work-store/src/routes.mjs +135 -0
  109. package/package.json +16 -14
@@ -4050,6 +4050,13 @@ endobj
4050
4050
  if (st && st.align) style += " text-align: " + String(st.align) + ";";
4051
4051
  return '<p style="' + style + '">' + body + "</p>";
4052
4052
  }
4053
+ function normalizeImageClip(clip) {
4054
+ if (!clip || typeof clip !== "object") return null;
4055
+ const range = clip.range;
4056
+ const okRange = Array.isArray(range) && range.length === 2 && range.every((p) => Array.isArray(p) && p.length === 2 && p.every((n) => isFinite(Number(n))));
4057
+ if (typeof clip.shape !== "string" || !okRange) return null;
4058
+ return { shape: clip.shape, range: range.map((p) => [Number(p[0]), Number(p[1])]) };
4059
+ }
4053
4060
  function patchElement(el, props) {
4054
4061
  ;
4055
4062
  ["left", "top", "width", "height", "rotate", "opacity"].forEach((k) => {
@@ -4058,7 +4065,7 @@ endobj
4058
4065
  if (props.fill != null) el.fill = String(props.fill);
4059
4066
  if (el.type === "image") {
4060
4067
  if (props.src != null) el.src = String(props.src);
4061
- if (props.clip != null) el.clip = props.clip;
4068
+ if (props.clip != null) el.clip = normalizeImageClip(props.clip);
4062
4069
  return;
4063
4070
  }
4064
4071
  if (el.type === "latex") {
@@ -4149,7 +4156,7 @@ endobj
4149
4156
  }
4150
4157
  return Object.assign(base, {
4151
4158
  src,
4152
- clip: e.clip || null,
4159
+ clip: normalizeImageClip(e.clip),
4153
4160
  ...e.opacity != null ? { opacity: Number(e.opacity) } : {}
4154
4161
  });
4155
4162
  }
@@ -4260,6 +4267,10 @@ endobj
4260
4267
  // A/projects/ppt/src/core/ops/slide.js
4261
4268
  var idx2 = (c) => c.id != null ? c.id : c.index;
4262
4269
  var clone3 = (P, i) => JSON.parse(JSON.stringify(P.getSlides()[i]));
4270
+ var cleanSlide = (s) => {
4271
+ if (!s || !Array.isArray(s.elements)) return s;
4272
+ return { ...s, elements: s.elements.map((e) => e && e.type === "image" ? { ...e, clip: normalizeImageClip(e.clip) } : e) };
4273
+ };
4263
4274
  var slideOps = {
4264
4275
  "set-background": {
4265
4276
  run(P, c) {
@@ -4276,12 +4287,12 @@ endobj
4276
4287
  },
4277
4288
  "add-slide": {
4278
4289
  run(P, c) {
4279
- P.addSlide(c.slide || {}, c.index);
4290
+ P.addSlide(cleanSlide(c.slide || {}), c.index);
4280
4291
  }
4281
4292
  },
4282
4293
  "update-slide": {
4283
4294
  run(P, c) {
4284
- if (!P.updateSlide(idx2(c), c.slide)) throw new Error("update-slide 未命中");
4295
+ if (!P.updateSlide(idx2(c), cleanSlide(c.slide))) throw new Error("update-slide 未命中");
4285
4296
  }
4286
4297
  },
4287
4298
  "remove-slide": {
@@ -4684,12 +4695,379 @@ endobj
4684
4695
  return el;
4685
4696
  }
4686
4697
 
4698
+ // C/packages/capyclaw-foundation/abi/kinds.mjs
4699
+ var nonEmpty = { type: "string", minLength: 1 };
4700
+ var kebab = { type: "string", pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$" };
4701
+ var INTERFACE_KINDS = Object.freeze({
4702
+ "skill-provider@1": Object.freeze({
4703
+ kind: "skill-provider@1",
4704
+ major: 1,
4705
+ title: "技能提供者",
4706
+ summary: "把一个 SKILL.md 目录注册进 dsh skills 服务,可选附带契约快照与契约注记。",
4707
+ unique: false,
4708
+ schema: Object.freeze({
4709
+ type: "object",
4710
+ required: ["skill"],
4711
+ additionalProperties: false,
4712
+ properties: {
4713
+ name: kebab,
4714
+ skill: nonEmpty,
4715
+ contract: nonEmpty,
4716
+ rank: { type: "number", min: 0, max: 1e3 },
4717
+ note: { type: "function" }
4718
+ }
4719
+ })
4720
+ }),
4721
+ "tool-provider@1": Object.freeze({
4722
+ kind: "tool-provider@1",
4723
+ major: 1,
4724
+ title: "工具提供者",
4725
+ summary: "声明一组工具并注册到工具面(注册表 / MCP 壳 / 能力报告)。",
4726
+ unique: false,
4727
+ schema: Object.freeze({
4728
+ type: "object",
4729
+ required: ["namespace", "provide"],
4730
+ additionalProperties: false,
4731
+ properties: {
4732
+ namespace: kebab,
4733
+ prefixNamespace: { type: "boolean" },
4734
+ provide: { type: "function" },
4735
+ instructions: nonEmpty,
4736
+ capabilities: { type: "object" }
4737
+ }
4738
+ })
4739
+ }),
4740
+ "runtime-driver@1": Object.freeze({
4741
+ kind: "runtime-driver@1",
4742
+ major: 1,
4743
+ title: "运行时驱动",
4744
+ summary: "一个长驻进程的启动、就绪、健康与回收;端口由内核分配,应用不自己 spawn。",
4745
+ unique: true,
4746
+ uniqueBy: "id",
4747
+ schema: Object.freeze({
4748
+ type: "object",
4749
+ required: ["id", "entry"],
4750
+ additionalProperties: false,
4751
+ properties: {
4752
+ id: kebab,
4753
+ entry: nonEmpty,
4754
+ when: { type: "function" },
4755
+ args: { type: "array", items: { type: "string" } },
4756
+ port: { type: ["number", "string", "function"] },
4757
+ portArg: nonEmpty,
4758
+ dir: nonEmpty,
4759
+ env: { type: "function" },
4760
+ health: {
4761
+ type: "object",
4762
+ required: ["path"],
4763
+ additionalProperties: false,
4764
+ properties: {
4765
+ path: nonEmpty,
4766
+ expect: { type: "object" },
4767
+ timeoutMs: { type: "number", min: 1 }
4768
+ }
4769
+ },
4770
+ restart: {
4771
+ type: "object",
4772
+ additionalProperties: false,
4773
+ properties: {
4774
+ max: { type: "integer", min: 0 },
4775
+ backoffMs: { type: "number", min: 0 }
4776
+ }
4777
+ }
4778
+ }
4779
+ })
4780
+ }),
4781
+ "http-router@1": Object.freeze({
4782
+ kind: "http-router@1",
4783
+ major: 1,
4784
+ title: "路由挂载者",
4785
+ summary: "把一组 HTTP 路由挂到内核的共享宿主上,前缀冲突由内核检测。",
4786
+ unique: false,
4787
+ schema: Object.freeze({
4788
+ type: "object",
4789
+ required: ["mount", "routes"],
4790
+ additionalProperties: false,
4791
+ properties: {
4792
+ mount: { type: "string", pattern: "^/" },
4793
+ routes: { type: "function" },
4794
+ host: { type: "string", enum: ["shared", "own"] }
4795
+ }
4796
+ })
4797
+ }),
4798
+ "ui-panel@1": Object.freeze({
4799
+ kind: "ui-panel@1",
4800
+ major: 1,
4801
+ title: "界面面板",
4802
+ summary: "把静态资源目录挂到挂载点,缓存头与 404 兜底由内核处理。",
4803
+ unique: false,
4804
+ schema: Object.freeze({
4805
+ type: "object",
4806
+ required: ["mount", "root"],
4807
+ additionalProperties: false,
4808
+ properties: {
4809
+ mount: { type: "string", pattern: "^/" },
4810
+ root: nonEmpty,
4811
+ index: nonEmpty,
4812
+ cache: { type: "string", enum: ["no-store", "revalidate", "immutable"] }
4813
+ }
4814
+ })
4815
+ }),
4816
+ "lifecycle-hook@1": Object.freeze({
4817
+ kind: "lifecycle-hook@1",
4818
+ major: 1,
4819
+ title: "生命周期钩子",
4820
+ summary: "在安装 / 启动 / 停止 / 升级四个时点插入行为,时序与幂等由内核保证。",
4821
+ unique: false,
4822
+ schema: Object.freeze({
4823
+ type: "object",
4824
+ additionalProperties: false,
4825
+ properties: {
4826
+ onInstall: { type: "function" },
4827
+ onStart: { type: "function" },
4828
+ onStop: { type: "function" },
4829
+ onUpgrade: { type: "function" }
4830
+ }
4831
+ }),
4832
+ /** schema 表达不了「至少一个钩子」,用额外校验补。 */
4833
+ extra(impl, errors) {
4834
+ const hooks = ["onInstall", "onStart", "onStop", "onUpgrade"].filter((key) => typeof impl[key] === "function");
4835
+ if (!hooks.length) errors.push("$ 至少需要实现一个钩子(onInstall/onStart/onStop/onUpgrade)");
4836
+ }
4837
+ }),
4838
+ "host-event@1": Object.freeze({
4839
+ kind: "host-event@1",
4840
+ major: 1,
4841
+ title: "宿主事件订阅",
4842
+ summary: "订阅宿主生命周期/界面注入事件;适配器负责在插件自己的 ctx 上注册与注销。",
4843
+ unique: false,
4844
+ schema: Object.freeze({
4845
+ type: "object",
4846
+ required: ["event", "handler"],
4847
+ additionalProperties: false,
4848
+ properties: {
4849
+ event: nonEmpty,
4850
+ handler: { type: "function" }
4851
+ }
4852
+ })
4853
+ }),
4854
+ "client-panel@1": Object.freeze({
4855
+ kind: "client-panel@1",
4856
+ major: 1,
4857
+ title: "客户端面板",
4858
+ summary: "声明页面开机全局变量与可选静态目录;适配器负责 webserver/index-inject 注入与静态挂载。",
4859
+ unique: false,
4860
+ schema: Object.freeze({
4861
+ type: "object",
4862
+ additionalProperties: false,
4863
+ properties: {
4864
+ mount: { type: "string", pattern: "^/" },
4865
+ root: nonEmpty,
4866
+ index: nonEmpty,
4867
+ prepare: { type: "function" },
4868
+ bootGlobals: { type: "function" }
4869
+ }
4870
+ }),
4871
+ extra(impl, errors) {
4872
+ if (!impl.root && !impl.prepare && !impl.bootGlobals) {
4873
+ errors.push("$ 至少需要 root / prepare / bootGlobals 之一");
4874
+ }
4875
+ if (impl.root && !impl.mount) errors.push("$ 提供 root 时必须同时提供 mount");
4876
+ }
4877
+ }),
4878
+ "own-server@1": Object.freeze({
4879
+ kind: "own-server@1",
4880
+ major: 1,
4881
+ title: "自有 HTTP 面",
4882
+ summary: "宿主有网页端口时挂到该端口的前缀下(不新起端口),否则由 service-host 托管独立 loopback origin。",
4883
+ unique: true,
4884
+ uniqueBy: "id",
4885
+ schema: Object.freeze({
4886
+ type: "object",
4887
+ required: ["id", "handler"],
4888
+ additionalProperties: false,
4889
+ properties: {
4890
+ id: kebab,
4891
+ mount: { type: "string", pattern: "^/" },
4892
+ port: { type: ["number", "string", "function"] },
4893
+ host: nonEmpty,
4894
+ handler: { type: "function" },
4895
+ start: { type: "function" },
4896
+ stop: { type: "function" }
4897
+ }
4898
+ })
4899
+ }),
4900
+ "service-provider@1": Object.freeze({
4901
+ kind: "service-provider@1",
4902
+ major: 1,
4903
+ title: "宿主服务提供者",
4904
+ summary: "向宿主 ctx 提供一个具名服务;服务工厂必须同步,异步启动放在 start 钩子里。",
4905
+ unique: true,
4906
+ uniqueBy: "service",
4907
+ schema: Object.freeze({
4908
+ type: "object",
4909
+ required: ["service", "provide"],
4910
+ additionalProperties: false,
4911
+ properties: {
4912
+ service: nonEmpty,
4913
+ provide: { type: "function" },
4914
+ when: { type: "function" },
4915
+ start: { type: "function" },
4916
+ stop: { type: "function" }
4917
+ }
4918
+ })
4919
+ }),
4920
+ "raw@1": Object.freeze({
4921
+ kind: "raw@1",
4922
+ major: 1,
4923
+ title: "原生插件(逃生舱)",
4924
+ summary: "极少数需要自定义装配的插件;必须在 meta/foundation.allowlist.json 登记,且不得与其他接口混用。",
4925
+ unique: false,
4926
+ exclusive: true,
4927
+ schema: Object.freeze({
4928
+ type: "object",
4929
+ required: ["apply"],
4930
+ additionalProperties: false,
4931
+ properties: {
4932
+ apply: { type: "function" }
4933
+ }
4934
+ })
4935
+ })
4936
+ });
4937
+ var INTERFACE_KIND_NAMES = Object.freeze(Object.keys(INTERFACE_KINDS));
4938
+
4939
+ // C/packages/capyclaw-foundation/abi/errors.mjs
4940
+ var ERROR_CODES = Object.freeze({
4941
+ /** 插件入口形状不对:缺 name / 没有 implements / 导出了 apply 等。 */
4942
+ E_PLUGIN_SHAPE: "E_PLUGIN_SHAPE",
4943
+ /** 插件声明的 ABI 主版本与内核不兼容。 */
4944
+ E_ABI_MISMATCH: "E_ABI_MISMATCH",
4945
+ /** 描述符的 kind 不在内核认识的接口表里。 */
4946
+ E_KIND_UNKNOWN: "E_KIND_UNKNOWN",
4947
+ /** 描述符字段不满足接口 schema。 */
4948
+ E_SCHEMA: "E_SCHEMA",
4949
+ /** 内核没有提供该能力(通常是 os.* 子系统缺失)。 */
4950
+ E_CAP_MISSING: "E_CAP_MISSING",
4951
+ /** 唯一性接口被第二个插件实现(例如同 id 的 runtime-driver)。 */
4952
+ E_DUP_INTERFACE: "E_DUP_INTERFACE",
4953
+ /** 同名插件被重复挂载。 */
4954
+ E_DUP_PLUGIN: "E_DUP_PLUGIN",
4955
+ /** 内核没有为这个 kind 注册适配器(接口定义存在但实现未就绪)。 */
4956
+ E_KIND_UNAVAILABLE: "E_KIND_UNAVAILABLE",
4957
+ /** 适配器在编译期抛错。 */
4958
+ E_ADAPTER_THREW: "E_ADAPTER_THREW",
4959
+ /** 插件入口没有拿到 baseUrl,相对路径无法解析。 */
4960
+ E_BASE_URL_MISSING: "E_BASE_URL_MISSING",
4961
+ /** 运行时没有 ctx.os:foundation 未安装或未启用。 */
4962
+ E_KERNEL_MISSING: "E_KERNEL_MISSING",
4963
+ E_KERNEL_CLOSED: "E_KERNEL_CLOSED",
4964
+ E_NOT_READY: "E_NOT_READY",
4965
+ E_CAP_RESERVED: "E_CAP_RESERVED",
4966
+ E_CAP_CONFLICT: "E_CAP_CONFLICT"
4967
+ });
4968
+
4969
+ // C/packages/capyclaw-foundation/abi/spec.mjs
4970
+ var KINDS = Object.freeze({
4971
+ "skill-provider": "skill-provider@1",
4972
+ "tool-provider": "tool-provider@1",
4973
+ "runtime-driver": "runtime-driver@1",
4974
+ "http-router": "http-router@1",
4975
+ "ui-panel": "ui-panel@1",
4976
+ "lifecycle-hook": "lifecycle-hook@1",
4977
+ "host-event": "host-event@1",
4978
+ "client-panel": "client-panel@1",
4979
+ "own-server": "own-server@1",
4980
+ "service-provider": "service-provider@1",
4981
+ raw: "raw@1"
4982
+ });
4983
+
4984
+ // C/packages/capyclaw-foundation/abi/visibility.mjs
4985
+ var VISIBILITY_MESSAGE = "capyclaw:workbench:visibility";
4986
+ var VISIBILITY_ACK_MESSAGE = "capyclaw:workbench:visibility-ack";
4987
+ var VISIBILITY_STATES = Object.freeze(["foreground", "background", "hidden", "detached"]);
4988
+ var VISIBILITY_DEFAULTS = Object.freeze({
4989
+ detachAfterMs: 12e4,
4990
+ visibilityAckTimeoutMs: 1500,
4991
+ hiddenGraceMs: 250
4992
+ });
4993
+ var STATE_SET = new Set(VISIBILITY_STATES);
4994
+ function isVisibilityState(value) {
4995
+ return typeof value === "string" && STATE_SET.has(value);
4996
+ }
4997
+ function normalizeVisibilityState(value) {
4998
+ return isVisibilityState(value) ? value : "foreground";
4999
+ }
5000
+
5001
+ // C/packages/capyclaw-document-workbench/src/client/visibility.mjs
5002
+ function createVisibilitySubscriber({ onState = () => {
5003
+ }, win = globalThis.window, sendAck = true } = {}) {
5004
+ let state = "foreground";
5005
+ let started = false;
5006
+ const listeners = [];
5007
+ const transition = (next, data2) => {
5008
+ if (next === state) return;
5009
+ state = next;
5010
+ onState(state, data2);
5011
+ };
5012
+ const onMessage = (event) => {
5013
+ const origin = win && win.location && win.location.origin;
5014
+ if (event.origin !== origin) return;
5015
+ const data2 = event.data;
5016
+ if (!data2 || data2.type !== VISIBILITY_MESSAGE) return;
5017
+ const next = normalizeVisibilityState(data2.state);
5018
+ transition(next, data2);
5019
+ if (sendAck && event.source) {
5020
+ event.source.postMessage({ type: VISIBILITY_ACK_MESSAGE, state, sid: data2.sid }, event.origin);
5021
+ }
5022
+ };
5023
+ const onDocVisibility = () => {
5024
+ const doc = win && win.document;
5025
+ transition(doc && doc.hidden ? "hidden" : "foreground");
5026
+ };
5027
+ function start() {
5028
+ if (started || !win || typeof win.addEventListener !== "function") return;
5029
+ started = true;
5030
+ win.addEventListener("message", onMessage);
5031
+ listeners.push([win, "message", onMessage]);
5032
+ if (win.parent === win) {
5033
+ const doc = win.document;
5034
+ if (doc && typeof doc.addEventListener === "function") {
5035
+ doc.addEventListener("visibilitychange", onDocVisibility);
5036
+ listeners.push([doc, "visibilitychange", onDocVisibility]);
5037
+ }
5038
+ }
5039
+ }
5040
+ function stop() {
5041
+ if (!started) return;
5042
+ started = false;
5043
+ for (const [target, type, handler] of listeners) {
5044
+ try {
5045
+ target.removeEventListener(type, handler);
5046
+ } catch {
5047
+ }
5048
+ }
5049
+ listeners.length = 0;
5050
+ }
5051
+ return {
5052
+ start,
5053
+ stop,
5054
+ get state() {
5055
+ return state;
5056
+ }
5057
+ };
5058
+ }
5059
+
5060
+ // C/packages/capyclaw-plugin-kit/src/editor/heartbeat.mjs
5061
+ var HEARTBEAT_INTERVAL_MS = 3e3;
5062
+
4687
5063
  // C/packages/capyclaw-document-workbench/src/client/index.mjs
4688
5064
  var DEFAULTS = {
4689
5065
  pollTimeoutSec: 3,
4690
5066
  claimRetryMs: 800,
4691
5067
  activeClaimRetryMs: 1500,
4692
- heartbeatMs: 3e3,
5068
+ /* 心跳间隔取 plugin-kit 单一真源 HEARTBEAT_INTERVAL_MS(3s),与 heartbeat-worker.js
5069
+ * 的 setInterval 字面量同拍(worker 侧由 plugin-kit drift 测试钉死,防再次漂移)。 */
5070
+ heartbeatMs: HEARTBEAT_INTERVAL_MS,
4693
5071
  stateDebounceMs: 800,
4694
5072
  errorRetryMs: 500,
4695
5073
  shotIdleMs: 3e3,
@@ -4725,6 +5103,10 @@ endobj
4725
5103
  onStatus = () => {
4726
5104
  },
4727
5105
  onNote = () => {
5106
+ },
5107
+ /* 渲染面可见性回调(标准 §4):宿主信号 → 适配器挂起/恢复渲染。
5108
+ * 只影响渲染面;桥接面节奏不受它驱动(P2/P3)。 */
5109
+ onVisibility = () => {
4728
5110
  }
4729
5111
  } = {}) {
4730
5112
  if (typeof api !== "function") throw new Error("createEditorClient 需要 api(path, init)");
@@ -4763,6 +5145,10 @@ endobj
4763
5145
  wakeFlag: false,
4764
5146
  wakeResolve: null,
4765
5147
  wakeListeners: [],
5148
+ /* 渲染面可见性(标准 §3/§4):初始 foreground,宿主信号驱动迁移。
5149
+ * 订阅器在 claimLoop 注册唤醒监听处创建并 start,stop() 一并摘除。 */
5150
+ visibilityState: "foreground",
5151
+ visibilitySubscriber: null,
4766
5152
  /* A:结构化取消——stop 即 abort,在飞请求立刻 reject。 */
4767
5153
  abort: new AbortController(),
4768
5154
  /* D:可 await 停机排水——记录在飞 pump/shoot 任务,stop 等它们 settle。 */
@@ -4891,7 +5277,7 @@ endobj
4891
5277
  }
4892
5278
  async function claimLoop() {
4893
5279
  if (!shadow && storage && typeof window !== "undefined" && window.addEventListener) {
4894
- window.addEventListener("storage", (event) => {
5280
+ const onSingleton = (event) => {
4895
5281
  if (event.key === st.singletonKey && event.newValue && event.newValue !== st.clientId) {
4896
5282
  if (st.active) {
4897
5283
  st.active = false;
@@ -4900,7 +5286,9 @@ endobj
4900
5286
  note("");
4901
5287
  }
4902
5288
  }
4903
- });
5289
+ };
5290
+ window.addEventListener("storage", onSingleton);
5291
+ st.wakeListeners.push([window, "storage", onSingleton]);
4904
5292
  }
4905
5293
  const onWake = () => wake();
4906
5294
  if (typeof window !== "undefined" && window.addEventListener) {
@@ -4915,6 +5303,15 @@ endobj
4915
5303
  document.addEventListener("visibilitychange", onVisible);
4916
5304
  st.wakeListeners.push([document, "visibilitychange", onVisible]);
4917
5305
  }
5306
+ if (!st.visibilitySubscriber) {
5307
+ st.visibilitySubscriber = createVisibilitySubscriber({
5308
+ onState: (state) => {
5309
+ st.visibilityState = state;
5310
+ onVisibility(state);
5311
+ }
5312
+ });
5313
+ st.visibilitySubscriber.start();
5314
+ }
4918
5315
  pump();
4919
5316
  let firstClaim = !shadow;
4920
5317
  for (; ; ) {
@@ -5204,6 +5601,17 @@ endobj
5204
5601
  }
5205
5602
  }
5206
5603
  st.wakeListeners = [];
5604
+ try {
5605
+ st.visibilitySubscriber?.stop();
5606
+ } catch {
5607
+ }
5608
+ st.visibilitySubscriber = null;
5609
+ if (!shadow && storage) {
5610
+ try {
5611
+ if (storage.getItem(st.singletonKey) === st.clientId) storage.removeItem(st.singletonKey);
5612
+ } catch {
5613
+ }
5614
+ }
5207
5615
  wake();
5208
5616
  try {
5209
5617
  st.unsubscribe?.();
@@ -5221,6 +5629,11 @@ endobj
5221
5629
  }
5222
5630
  return {
5223
5631
  state: st,
5632
+ /* 渲染面当前可见性(标准 §3):foreground/background/hidden/detached。
5633
+ * 只读投影;迁移由宿主信号驱动,桥接面不读它来节流。 */
5634
+ get visibilityState() {
5635
+ return st.visibilityState;
5636
+ },
5224
5637
  claim,
5225
5638
  ensureLinked,
5226
5639
  restore,
@@ -5298,13 +5711,34 @@ endobj
5298
5711
  // A/projects/ppt/src/editor/deck-shape.js
5299
5712
  function normalizeDeck(deck) {
5300
5713
  const doc = deck && typeof deck === "object" && !Array.isArray(deck) ? deck : {};
5301
- const slides = Array.isArray(doc.slides) ? doc.slides.filter((one) => one && typeof one === "object") : [];
5714
+ const slides = (Array.isArray(doc.slides) ? doc.slides.filter((one) => one && typeof one === "object") : []).map(cleanSlide2);
5302
5715
  const title = typeof doc.title === "string" ? doc.title : "";
5303
5716
  return { ...doc, title, slides };
5304
5717
  }
5718
+ function cleanSlide2(s) {
5719
+ if (!Array.isArray(s.elements)) return s;
5720
+ let changed = false;
5721
+ const elements = s.elements.map((e) => {
5722
+ if (!e || e.type !== "image") return e;
5723
+ const clip = normalizeImageClip(e.clip);
5724
+ const orig = e.clip == null ? null : e.clip;
5725
+ if (JSON.stringify(clip) === JSON.stringify(orig)) return e;
5726
+ changed = true;
5727
+ return { ...e, clip };
5728
+ });
5729
+ return changed ? { ...s, elements } : s;
5730
+ }
5305
5731
 
5306
5732
  // A/projects/ppt/src/editor/session.js
5307
5733
  var API_BASE = new URL("api/desktop/works/ppt-bridge", document.baseURI).pathname.replace(/\/$/, "");
5734
+ function applyRenderVisibility(state, win = window) {
5735
+ const suspended = state === "hidden" || state === "detached";
5736
+ win.__CAPYCLAW_RENDER_SUSPENDED__ = suspended;
5737
+ if (typeof win.CustomEvent === "function" && typeof win.dispatchEvent === "function") {
5738
+ win.dispatchEvent(new win.CustomEvent("capyclaw:render-visibility", { detail: { state } }));
5739
+ }
5740
+ return suspended;
5741
+ }
5308
5742
  function createEditorSession({
5309
5743
  api,
5310
5744
  applyOp: applyOp2,
@@ -5409,6 +5843,8 @@ endobj
5409
5843
  storage: shadow ? null : typeof localStorage !== "undefined" ? localStorage : null,
5410
5844
  heartbeatWorkerUrl: "./heartbeat-worker.js",
5411
5845
  singletonKey: sid ? "ppt-workbench-singleton@" + sid : "ppt-workbench-singleton",
5846
+ /* 表面可见性回调(共享 client 订阅宿主 visibility 消息后调用):只挂起渲染面。 */
5847
+ onVisibility: (state) => applyRenderVisibility(state),
5412
5848
  onStatus: ui2.badge,
5413
5849
  onNote: ui2.note
5414
5850
  });
@@ -6036,6 +6472,13 @@ html[data-theme="dark"] #ms-panel .ms-hint, html[data-theme="dark"] #ms-panel .m
6036
6472
  btn.title = mode === "dark" ? "切换为亮色主题" : "切换为暗色主题";
6037
6473
  }
6038
6474
  }
6475
+ var themeListenerAttached = false;
6476
+ function attachThemeListener() {
6477
+ if (themeListenerAttached) return;
6478
+ if (!window.PptApp || typeof window.PptApp.on !== "function") return;
6479
+ window.PptApp.on("uitheme-change", (d) => syncTheme(d && d.mode));
6480
+ themeListenerAttached = true;
6481
+ }
6039
6482
  function announceSession() {
6040
6483
  if (!currentSid) return;
6041
6484
  fetch(apiBase + "/activate", {
@@ -6050,6 +6493,9 @@ html[data-theme="dark"] #ms-panel .ms-hint, html[data-theme="dark"] #ms-panel .m
6050
6493
  document.addEventListener("visibilitychange", () => {
6051
6494
  if (!document.hidden) announceSession();
6052
6495
  });
6496
+ window.addEventListener("capyclaw:render-visibility", (e) => {
6497
+ if (e && e.detail && e.detail.state === "foreground") announceSession();
6498
+ });
6053
6499
  function setEmptyMeta(pages) {
6054
6500
  const box2 = document.querySelector("[data-empty-meta]");
6055
6501
  if (!box2) return;
@@ -6099,7 +6545,7 @@ html[data-theme="dark"] #ms-panel .ms-hint, html[data-theme="dark"] #ms-panel .m
6099
6545
  const box2 = $("[data-editor]");
6100
6546
  try {
6101
6547
  await runtime.ensureRuntime();
6102
- if (typeof window.PptApp.on === "function") window.PptApp.on("uitheme-change", (d) => syncTheme(d && d.mode));
6548
+ attachThemeListener();
6103
6549
  await window.PptApp.mount(box2, { uiTheme });
6104
6550
  syncTheme(typeof window.PptApp.getUiTheme === "function" ? window.PptApp.getUiTheme() : uiTheme);
6105
6551
  runtime.wrapAssetExport();
@@ -6166,6 +6612,7 @@ html[data-theme="dark"] #ms-panel .ms-hint, html[data-theme="dark"] #ms-panel .m
6166
6612
  initSession(sid);
6167
6613
  await withTimeout((async () => {
6168
6614
  await runtime.ensureRuntime();
6615
+ attachThemeListener();
6169
6616
  if (!window.PptApp.isMounted()) {
6170
6617
  await window.PptApp.mount($("[data-editor]"), { uiTheme });
6171
6618
  runtime.wrapAssetExport();
@@ -6207,7 +6654,8 @@ html[data-theme="dark"] #ms-panel .ms-hint, html[data-theme="dark"] #ms-panel .m
6207
6654
  }
6208
6655
  });
6209
6656
  });
6210
- window.addEventListener("pagehide", () => {
6657
+ window.addEventListener("pagehide", (event) => {
6658
+ if (event && event.persisted) return;
6211
6659
  if (session) session.release();
6212
6660
  });
6213
6661
  document.addEventListener("click", (e) => {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "contractVersion": "2.5.0",
3
- "packageVersion": "2.5.70",
3
+ "packageVersion": "2.5.72",
4
4
  "toolCount": 32,
5
5
  "tools": [
6
6
  {
@@ -45,7 +45,10 @@ self.onmessage = function(e) {
45
45
  function startHeartbeat() {
46
46
  if (intervalHandle) clearInterval(intervalHandle);
47
47
 
48
- // 每 4 秒发送心跳(留 1 秒缓冲,避免刚好 5 秒时被判过期)
48
+ // 心跳节奏统一为 3s:单一真源是 editor/heartbeat.mjs 的 HEARTBEAT_INTERVAL_MS。
49
+ // 本文件是原样拷贝的经典 Worker,运行时不能 import npm 模块,故以字面量承载节奏,
50
+ // 由 test/heartbeat-constants.test.mjs 钉死与常量一致,防止再次漂移。
51
+ // 心跳对象是编辑器「在场租约」(editor-host /claim);两层租约语义见 heartbeat.mjs 头注。
49
52
  intervalHandle = setInterval(() => {
50
53
  if (!active) return;
51
54
 
@@ -66,7 +69,7 @@ function startHeartbeat() {
66
69
  });
67
70
  }
68
71
  });
69
- }, 4000);
72
+ }, 3000);
70
73
 
71
74
  // 立即发送第一次
72
75
  sendClaim().catch(() => {});
@@ -164,6 +164,10 @@
164
164
  if (t && t.tagName === 'IMG' && isMedia(t.src)) attempts.delete(t);
165
165
  }, true);
166
166
  setInterval(function () {
167
+ /* 渲染面挂起(表面生命周期标准 §5):表面 hidden/detached 时 session.js 的
168
+ * onVisibility 置此旗标——整 tick 直接跳过:不扫描、不重试、不累加退避计数。
169
+ * 恢复前台后旗标清零,下一 tick 自然继续,坏图重试从挂起前的进度接着走。 */
170
+ if (window.__CAPYCLAW_RENDER_SUSPENDED__) return;
167
171
  var imgs = document.images;
168
172
  for (var i = 0; i < imgs.length; i++) {
169
173
  var im = imgs[i];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/ppt-editor",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "PPT 工作台浏览器界面:PPTist 运行时资产 + 编辑器客户端(可选安装;未装时工作台 headless 运行)。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.mjs",
@@ -38,7 +38,7 @@
38
38
  "license": "AGPL-3.0-or-later",
39
39
  "scripts": {},
40
40
  "dependencies": {
41
- "@capyclaw/plugin-kit": "^0.2.6"
41
+ "@capyclaw/plugin-kit": "^0.2.10"
42
42
  },
43
43
  "author": {
44
44
  "name": "CapyClaw",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "contractVersion": "2.5.0",
3
- "packageVersion": "2.5.70",
3
+ "packageVersion": "2.5.72",
4
4
  "toolCount": 32,
5
5
  "tools": [
6
6
  {