@web-ppt/edit-core 0.5.0-beta.1 → 0.5.0-beta.2

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 (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/dist/collaboration-identity.d.ts +3 -0
  4. package/dist/commands/add-slide-identity.d.ts +2 -0
  5. package/dist/commands/convert-to-custom-geometry.d.ts +4 -0
  6. package/dist/commands/element-geometry.d.ts +6 -0
  7. package/dist/commands/element-hierarchy.d.ts +6 -0
  8. package/dist/commands/element-table-style.d.ts +5 -0
  9. package/dist/commands/frame-decomposition.d.ts +10 -0
  10. package/dist/commands/generated-creation-defaults.d.ts +4 -0
  11. package/dist/commands/geometry-types.d.ts +22 -0
  12. package/dist/commands/group-types.d.ts +24 -0
  13. package/dist/commands/group.d.ts +4 -0
  14. package/dist/commands/insertion-host.d.ts +3 -0
  15. package/dist/commands/insertion-rect.d.ts +2 -0
  16. package/dist/commands/patch-invalidation.d.ts +4 -0
  17. package/dist/commands/patch.d.ts +4 -0
  18. package/dist/commands/record-clone.d.ts +3 -0
  19. package/dist/commands/set-geometry.d.ts +4 -0
  20. package/dist/commands/set-table-style.d.ts +3 -0
  21. package/dist/commands/spid.d.ts +1 -0
  22. package/dist/commands/table-style-types.d.ts +28 -0
  23. package/dist/commands/text-target.d.ts +1 -0
  24. package/dist/commands/types.d.ts +29 -4
  25. package/dist/commands/ungroup.d.ts +4 -0
  26. package/dist/custom-geometry-path.d.ts +3 -0
  27. package/dist/custom-geometry.d.ts +12 -0
  28. package/dist/document-B1jjN-QB.js +274 -0
  29. package/dist/edit-core.js +3597 -2639
  30. package/dist/editor.d.ts +6 -1
  31. package/dist/generate/custom-geometry.d.ts +2 -0
  32. package/dist/generate/index.d.ts +12 -0
  33. package/dist/generate/links.d.ts +3 -0
  34. package/dist/generate/materialize.d.ts +2 -0
  35. package/dist/generate/media.d.ts +13 -0
  36. package/dist/generate/table.d.ts +4 -0
  37. package/dist/generate/template.d.ts +3 -0
  38. package/dist/generate.js +744 -0
  39. package/dist/hyperlink.d.ts +2 -0
  40. package/dist/identity-allocation.d.ts +12 -0
  41. package/dist/identity-watermark.d.ts +4 -0
  42. package/dist/image-resource-DbgJS9n-.js +24 -0
  43. package/dist/{index-D4ZTaYOa.js → index-D2JizcOQ.js} +7 -7
  44. package/dist/index.d.ts +11 -3
  45. package/dist/insertion-CGpb504L.js +6152 -0
  46. package/dist/layout-projection.d.ts +2 -0
  47. package/dist/opc/patch.d.ts +2 -0
  48. package/dist/opc.js +1 -1
  49. package/dist/paragraph-level.d.ts +11 -0
  50. package/dist/paragraph-property-schema.d.ts +1 -1
  51. package/dist/{patch-DO8497wO.js → patch-D7lZelRa.js} +111 -94
  52. package/dist/patch-change.d.ts +4 -0
  53. package/dist/patch-events.d.ts +12 -0
  54. package/dist/recovery-identity.d.ts +2 -1
  55. package/dist/run-property-schema.d.ts +1 -1
  56. package/dist/save/geometry.d.ts +5 -0
  57. package/dist/save/insertion.d.ts +3 -0
  58. package/dist/save/notes.d.ts +2 -0
  59. package/dist/save/run-overrides.d.ts +10 -0
  60. package/dist/save/shape-format.d.ts +3 -0
  61. package/dist/save/table-style-part.d.ts +11 -0
  62. package/dist/save/table.d.ts +3 -0
  63. package/dist/save/text-source-less.d.ts +6 -0
  64. package/dist/save.js +468 -1441
  65. package/dist/table-direct-markup.d.ts +7 -1
  66. package/dist/table-style-part-DBtpxmuo.js +1042 -0
  67. package/dist/table-style.d.ts +20 -0
  68. package/dist/text-model.d.ts +1 -1
  69. package/dist/types.d.ts +44 -1
  70. package/dist/xml.js +1 -1
  71. package/package.json +6 -2
  72. package/dist/insertion-DabLme_U.js +0 -5471
@@ -22,3 +22,5 @@ export declare function rebasedElementBase(doc: EditDoc, slideId: SlideId, recor
22
22
  };
23
23
  /** 文字命令从当前版式的重基值起步,不能把旧版式有效值烘进首次覆盖。 */
24
24
  export declare function rebasedTextBase(doc: EditDoc, slideId: SlideId, id: ElementId): TextBody | null;
25
+ /** 列表改级必须读取九级样式目录,不能从当前段落反推相邻级别的继承值。 */
26
+ export declare function rebasedTextLevelTemplate(doc: EditDoc, slideId: SlideId, id: ElementId): TextBody | undefined;
@@ -1,5 +1,7 @@
1
1
  import type { OpcPackage } from '@web-ppt/core';
2
2
  import type { OpcPartChanges, OpcPatchResult } from './types';
3
+ /** 生成保存从已解压 part 构造全新包;输入和结果都拍快照,调用方不能随后改写。 */
4
+ export declare function createOpcPackage(parts: Readonly<Record<string, Uint8Array>>): OpcPatchResult;
3
5
  /** 释放脱离 EditDoc 单独持有的保存结果;原始解析包仍由 Presentation.dispose() 释放。 */
4
6
  export declare function disposeOpcPackage(pkg: OpcPackage): void;
5
7
  /** 在原 OPC 包上应用 part 级修改;空修改必须保持整包字节身份。 */
package/dist/opc.js CHANGED
@@ -1,4 +1,4 @@
1
- import { d as c, p as e } from "./patch-DO8497wO.js";
1
+ import { d as c, p as e } from "./patch-D7lZelRa.js";
2
2
  export {
3
3
  c as disposeOpcPackage,
4
4
  e as patchOpcPackage
@@ -0,0 +1,11 @@
1
+ import type { TextBody } from '@web-ppt/core';
2
+ import type { FlatTextParagraph, ParagraphPropertyOverrides, TextOverride } from './types';
3
+ import type { TextRange } from './commands/types';
4
+ /** 改级只重基未直设字段;pPr/rPr 的来源直设与用户覆盖继续压过列表样式。 */
5
+ export declare function rebaseParagraphLevel(body: TextBody, paragraph: FlatTextParagraph, paragraphIndex: number, level: number, template: TextBody | undefined): FlatTextParagraph;
6
+ /** 改动中段级别会改变后续同级编号,必须在整段序列上重新计数。 */
7
+ export declare function renumberParagraphs(body: TextBody, paragraphs: readonly FlatTextParagraph[], template: TextBody | undefined): FlatTextParagraph[];
8
+ /** 段落覆盖与列表重基必须一次生成,避免派生布局和稀疏覆盖出现中间态。 */
9
+ export declare function applyParagraphPropertyOverrides(sourceBody: TextBody, override: Extract<TextOverride, {
10
+ kind: 'flat';
11
+ }>, range: TextRange, changes: ParagraphPropertyOverrides, levelTemplate?: TextBody): TextOverride;
@@ -1,4 +1,4 @@
1
1
  import type { ParagraphPropertyOverrides } from './types';
2
- export declare const PARAGRAPH_PROPERTY_FIELDS: readonly ["align", "lineHeight", "spaceBefore", "spaceAfter", "marginLeft", "indent"];
2
+ export declare const PARAGRAPH_PROPERTY_FIELDS: readonly ["align", "lineHeight", "spaceBefore", "spaceAfter", "marginLeft", "indent", "level"];
3
3
  export declare const PARAGRAPH_ALIGNMENTS: readonly ["left", "center", "right", "justify"];
4
4
  export declare function assertParagraphPropertyOverrides(value: ParagraphPropertyOverrides, label: string): void;
@@ -1,9 +1,9 @@
1
- import { deflateSync as j } from "fflate";
1
+ import { deflateSync as T } from "fflate";
2
2
  function N(t, n) {
3
3
  return t.length === n.length && t.every((e, r) => e === n[r]);
4
4
  }
5
- const q = new Uint8Array(), X = Object.freeze(/* @__PURE__ */ Object.create(null)), y = Object.freeze(/* @__PURE__ */ Object.create(null));
6
- function H(t, n, e = y) {
5
+ const J = new Uint8Array(), K = Object.freeze(/* @__PURE__ */ Object.create(null)), $ = Object.freeze(/* @__PURE__ */ Object.create(null));
6
+ function D(t, n, e = $) {
7
7
  let r = t, o = n, s = e, i = !1;
8
8
  const a = {
9
9
  format: "pptx",
@@ -22,26 +22,26 @@ function H(t, n, e = y) {
22
22
  };
23
23
  return Object.defineProperty(a, "dispose", {
24
24
  value: () => {
25
- r = q, o = X, s = y, i = !0;
25
+ r = J, o = K, s = $, i = !0;
26
26
  }
27
27
  }), Object.freeze(a);
28
28
  }
29
- function J(t) {
29
+ function Q(t) {
30
30
  var n;
31
31
  (n = t.dispose) == null || n.call(t);
32
32
  }
33
- const D = new Uint32Array(256);
33
+ const _ = new Uint32Array(256);
34
34
  for (let t = 0; t < 256; t++) {
35
35
  let n = t;
36
36
  for (let e = 0; e < 8; e++) n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
37
- D[t] = n >>> 0;
37
+ _[t] = n >>> 0;
38
38
  }
39
- function _(t) {
39
+ function M(t) {
40
40
  let n = 4294967295;
41
- for (const e of t) n = D[(n ^ e) & 255] ^ n >>> 8;
41
+ for (const e of t) n = _[(n ^ e) & 255] ^ n >>> 8;
42
42
  return (n ^ 4294967295) >>> 0;
43
43
  }
44
- const M = 33639248, C = 101010256, G = 67324752, K = 101075792, Q = 117853008, L = 1, tt = new TextDecoder("utf-8", { fatal: !0 }), et = new TextEncoder(), nt = /* @__PURE__ */ new Set([
44
+ const G = 33639248, v = 101010256, Y = 67324752, tt = 101075792, et = 117853008, x = 1, nt = new TextDecoder("utf-8", { fatal: !0 }), rt = new TextEncoder(), ot = /* @__PURE__ */ new Set([
45
45
  "7z",
46
46
  "aac",
47
47
  "avi",
@@ -66,39 +66,39 @@ const M = 33639248, C = 101010256, G = 67324752, K = 101075792, Q = 117853008, L
66
66
  "woff",
67
67
  "woff2",
68
68
  "zip"
69
- ]), Y = (t, n) => t < n ? -1 : t > n ? 1 : 0;
69
+ ]), B = (t, n) => t < n ? -1 : t > n ? 1 : 0;
70
70
  class p extends Error {
71
71
  constructor(n, e) {
72
72
  super(e), this.reason = n, this.name = "ZipPassthroughUnsupported";
73
73
  }
74
74
  }
75
- const m = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
76
- function Z(t, n, e, r) {
75
+ const E = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
76
+ function O(t, n, e, r) {
77
77
  if (!Number.isSafeInteger(n) || !Number.isSafeInteger(e) || n < 0 || e < 0 || n + e > t.length)
78
78
  throw new Error(`ZIP ${r} 超出文件边界`);
79
79
  }
80
- function rt(t) {
80
+ function st(t) {
81
81
  if (t.length < 22) throw new Error("ZIP 缺少 EOCD");
82
- const n = m(t), e = Math.max(0, t.length - 22 - 65535);
82
+ const n = E(t), e = Math.max(0, t.length - 22 - 65535);
83
83
  for (let r = t.length - 22; r >= e; r--) {
84
- if (n.getUint32(r, !0) !== C) continue;
84
+ if (n.getUint32(r, !0) !== v) continue;
85
85
  const o = n.getUint16(r + 20, !0);
86
86
  if (r + 22 + o === t.length) return r;
87
87
  }
88
88
  throw new Error("ZIP 缺少有效 EOCD");
89
89
  }
90
- function ot(t, n) {
90
+ function ct(t, n) {
91
91
  if (!(n & 2048) && t.some((e) => e >= 128))
92
92
  throw new p("legacy-filename", "ZIP 使用非 UTF-8 文件名,不能安全映射 OPC part");
93
93
  try {
94
- return tt.decode(t);
94
+ return nt.decode(t);
95
95
  } catch {
96
96
  throw new Error("ZIP 文件名不是有效 UTF-8");
97
97
  }
98
98
  }
99
- function T(t, n, e, r, o) {
100
- Z(t, n, e, o);
101
- const s = m(t), i = n + e;
99
+ function L(t, n, e, r, o) {
100
+ O(t, n, e, o);
101
+ const s = E(t), i = n + e;
102
102
  let a = n;
103
103
  for (; a < i; ) {
104
104
  if (a + 4 > i) throw new Error(`ZIP ${o} 字段头不完整`);
@@ -109,9 +109,9 @@ function T(t, n, e, r, o) {
109
109
  }
110
110
  return !1;
111
111
  }
112
- function st(t) {
113
- const n = rt(t), e = m(t), r = e.getUint16(n + 4, !0), o = e.getUint16(n + 6, !0), s = e.getUint16(n + 8, !0), i = e.getUint16(n + 10, !0), a = e.getUint32(n + 12, !0), h = e.getUint32(n + 16, !0), d = e.getUint16(n + 20, !0);
114
- if (n >= 20 && e.getUint32(n - 20, !0) === Q)
112
+ function it(t) {
113
+ const n = st(t), e = E(t), r = e.getUint16(n + 4, !0), o = e.getUint16(n + 6, !0), s = e.getUint16(n + 8, !0), i = e.getUint16(n + 10, !0), a = e.getUint32(n + 12, !0), h = e.getUint32(n + 16, !0), d = e.getUint16(n + 20, !0);
114
+ if (n >= 20 && e.getUint32(n - 20, !0) === et)
115
115
  throw new p("zip64", "ZIP64 定位器不支持直通");
116
116
  if (r || o || s !== i)
117
117
  throw new p("multi-disk", "ZIP 多磁盘格式不支持直通");
@@ -119,94 +119,94 @@ function st(t) {
119
119
  throw new p("zip64", "ZIP64 不支持直通");
120
120
  if (d)
121
121
  throw new p("archive-comment", "带存档注释的 ZIP 不支持直通");
122
- Z(t, h, a, "中央目录");
122
+ O(t, h, a, "中央目录");
123
123
  const U = [], l = /* @__PURE__ */ new Set();
124
124
  let c = h;
125
125
  for (let u = 0; u < i; u++) {
126
- if (Z(t, c, 46, "中央目录条目"), e.getUint32(c, !0) !== M) throw new Error("ZIP 中央目录签名错误");
127
- const f = e.getUint16(c + 8, !0), w = e.getUint16(c + 10, !0), P = e.getUint32(c + 20, !0), I = e.getUint32(c + 24, !0), S = e.getUint16(c + 28, !0), R = e.getUint16(c + 30, !0), V = e.getUint16(c + 32, !0), $ = e.getUint16(c + 34, !0), g = e.getUint32(c + 42, !0), z = 46 + S + R + V;
128
- if (Z(t, c, z, "中央目录条目"), P === 4294967295 || I === 4294967295 || g === 4294967295 || $ === 65535)
126
+ if (O(t, c, 46, "中央目录条目"), e.getUint32(c, !0) !== G) throw new Error("ZIP 中央目录签名错误");
127
+ const f = e.getUint16(c + 8, !0), w = e.getUint16(c + 10, !0), P = e.getUint32(c + 20, !0), I = e.getUint32(c + 24, !0), S = e.getUint16(c + 28, !0), k = e.getUint16(c + 30, !0), X = e.getUint16(c + 32, !0), y = e.getUint16(c + 34, !0), g = e.getUint32(c + 42, !0), z = 46 + S + k + X;
128
+ if (O(t, c, z, "中央目录条目"), P === 4294967295 || I === 4294967295 || g === 4294967295 || y === 65535)
129
129
  throw new p("zip64", "ZIP64 条目不支持直通");
130
- if ($) throw new p("multi-disk", "跨磁盘 ZIP 条目不支持直通");
130
+ if (y) throw new p("multi-disk", "跨磁盘 ZIP 条目不支持直通");
131
131
  if (f & 1) throw new p("encrypted-entry", "ZIP 加密条目不支持直通");
132
132
  if (f & 8)
133
133
  throw new p("data-descriptor", "ZIP 数据描述符不支持直通");
134
134
  if (w !== 0 && w !== 8)
135
135
  throw new p("unsupported-compression", `ZIP 压缩方法 ${w} 不支持直通`);
136
- const x = t.subarray(c + 46, c + 46 + S);
137
- if (T(
136
+ const R = t.subarray(c + 46, c + 46 + S);
137
+ if (L(
138
138
  t,
139
139
  c + 46 + S,
140
- R,
141
- L,
140
+ k,
141
+ x,
142
142
  `中央目录 extra ${u + 1}`
143
143
  ))
144
144
  throw new p("zip64", "ZIP64 中央目录 extra 不支持直通");
145
- const E = ot(x, f);
146
- if (l.has(E)) throw new Error(`ZIP 存在重复条目:${E}`);
147
- if (l.add(E), Z(t, g, 30, `本地头 ${E}`), e.getUint32(g, !0) !== G) throw new Error(`ZIP 本地头签名错误:${E}`);
148
- const A = e.getUint16(g + 6, !0), O = e.getUint16(g + 8, !0);
149
- if (A & 1)
145
+ const m = ct(R, f);
146
+ if (l.has(m)) throw new Error(`ZIP 存在重复条目:${m}`);
147
+ if (l.add(m), O(t, g, 30, `本地头 ${m}`), e.getUint32(g, !0) !== Y) throw new Error(`ZIP 本地头签名错误:${m}`);
148
+ const b = e.getUint16(g + 6, !0), Z = e.getUint16(g + 8, !0);
149
+ if (b & 1)
150
150
  throw new p("encrypted-entry", "ZIP 本地头声明加密,不支持直通");
151
- if (A & 8)
151
+ if (b & 8)
152
152
  throw new p("data-descriptor", "ZIP 本地头使用数据描述符,不支持直通");
153
- if (O !== 0 && O !== 8)
153
+ if (Z !== 0 && Z !== 8)
154
154
  throw new p(
155
155
  "unsupported-compression",
156
- `ZIP 本地头压缩方法 ${O} 不支持直通`
156
+ `ZIP 本地头压缩方法 ${Z} 不支持直通`
157
157
  );
158
- if (A !== f || O !== w || e.getUint32(g + 14, !0) !== e.getUint32(c + 16, !0) || e.getUint32(g + 18, !0) !== P || e.getUint32(g + 22, !0) !== I)
159
- throw new Error(`ZIP 本地头与中央目录元数据不一致:${E}`);
160
- const v = e.getUint16(g + 26, !0), b = e.getUint16(g + 28, !0);
161
- if (T(
158
+ if (b !== f || Z !== w || e.getUint32(g + 14, !0) !== e.getUint32(c + 16, !0) || e.getUint32(g + 18, !0) !== P || e.getUint32(g + 22, !0) !== I)
159
+ throw new Error(`ZIP 本地头与中央目录元数据不一致:${m}`);
160
+ const A = e.getUint16(g + 26, !0), j = e.getUint16(g + 28, !0);
161
+ if (L(
162
162
  t,
163
- g + 30 + v,
164
- b,
165
- L,
166
- `本地头 extra ${E}`
163
+ g + 30 + A,
164
+ j,
165
+ x,
166
+ `本地头 extra ${m}`
167
167
  ))
168
168
  throw new p("zip64", "ZIP64 本地头 extra 不支持直通");
169
- const k = 30 + v + b + P;
170
- Z(t, g, k, `本地条目 ${E}`);
171
- const W = t.subarray(g + 30, g + 30 + v);
172
- if (!N(W, x)) throw new Error(`ZIP 本地头与中央目录名称不一致:${E}`);
169
+ const C = 30 + A + j + P;
170
+ O(t, g, C, `本地条目 ${m}`);
171
+ const H = t.subarray(g + 30, g + 30 + A);
172
+ if (!N(H, R)) throw new Error(`ZIP 本地头与中央目录名称不一致:${m}`);
173
173
  U.push({
174
- name: E,
174
+ name: m,
175
175
  flags: f,
176
176
  method: w,
177
177
  compressedSize: P,
178
178
  uncompressedSize: I,
179
179
  localOffset: g,
180
- localRaw: t.subarray(g, g + k),
180
+ localRaw: t.subarray(g, g + C),
181
181
  centralRaw: t.subarray(c, c + z)
182
182
  }), c += z;
183
183
  }
184
184
  if (c !== h + a) throw new Error("ZIP 中央目录包含未识别记录");
185
185
  if (c !== n)
186
- throw c + 4 <= t.length && e.getUint32(c, !0) === K ? new p("zip64", "ZIP64 EOCD 记录不支持直通") : new Error("ZIP 中央目录与 EOCD 之间存在未识别记录");
186
+ throw c + 4 <= t.length && e.getUint32(c, !0) === tt ? new p("zip64", "ZIP64 EOCD 记录不支持直通") : new Error("ZIP 中央目录与 EOCD 之间存在未识别记录");
187
187
  return { entries: U };
188
188
  }
189
- function B(t) {
189
+ function F(t) {
190
190
  const n = t.reduce((o, s) => o + s.length, 0), e = new Uint8Array(n);
191
191
  let r = 0;
192
192
  for (const o of t)
193
193
  e.set(o, r), r += o.length;
194
194
  return e;
195
195
  }
196
- function ct(t, n) {
196
+ function lt(t, n) {
197
197
  if (n.length > 4294967295) throw new Error(`OPC part 过大,需要 ZIP64:${t.name}`);
198
- const e = t.method === 8 ? j(n, { level: 6 }) : n;
198
+ const e = t.method === 8 ? T(n, { level: 6 }) : n;
199
199
  if (e.length > 4294967295) throw new Error(`OPC part 压缩后过大,需要 ZIP64:${t.name}`);
200
200
  const r = t.localRaw.length - t.compressedSize, o = new Uint8Array(r + e.length);
201
201
  o.set(t.localRaw.subarray(0, r)), o.set(e, r);
202
- const s = m(o), i = _(n);
202
+ const s = E(o), i = M(n);
203
203
  return s.setUint32(14, i, !0), s.setUint32(18, e.length, !0), s.setUint32(22, n.length, !0), { bytes: o, checksum: i, compressedSize: e.length, uncompressedSize: n.length };
204
204
  }
205
- function it(t, n, e) {
206
- const r = t.centralRaw.slice(), o = m(r);
205
+ function at(t, n, e) {
206
+ const r = t.centralRaw.slice(), o = E(r);
207
207
  return n && (o.setUint32(16, n.checksum, !0), o.setUint32(20, n.compressedSize, !0), o.setUint32(24, n.uncompressedSize, !0)), o.setUint32(42, e, !0), r;
208
208
  }
209
- function lt(t, n) {
209
+ function ut(t, n) {
210
210
  const e = [], r = [];
211
211
  let o = 0, s = 0, i = 0;
212
212
  const a = new Set(t.entries.map((f) => f.name));
@@ -216,12 +216,12 @@ function lt(t, n) {
216
216
  i++;
217
217
  continue;
218
218
  }
219
- const P = w ? ct(f, w) : null, I = (P == null ? void 0 : P.bytes) ?? f.localRaw;
220
- e.push(I), r.push(it(f, P, o)), o += I.length, w ? i++ : s++;
219
+ const P = w ? lt(f, w) : null, I = (P == null ? void 0 : P.bytes) ?? f.localRaw;
220
+ e.push(I), r.push(at(f, P, o)), o += I.length, w ? i++ : s++;
221
221
  }
222
- const h = [...n].filter(([f, w]) => !a.has(f) && w !== null).sort(([f], [w]) => Y(f, w));
222
+ const h = [...n].filter(([f, w]) => !a.has(f) && w !== null).sort(([f], [w]) => B(f, w));
223
223
  for (const [f, w] of h) {
224
- const P = F(f, w, o);
224
+ const P = W(f, w, o);
225
225
  e.push(P.local), r.push(P.central), o += P.local.length, i++;
226
226
  }
227
227
  const d = e.length;
@@ -229,54 +229,70 @@ function lt(t, n) {
229
229
  const U = o, l = r.reduce((f, w) => f + w.length, 0);
230
230
  if (U > 4294967295 || l > 4294967295)
231
231
  throw new Error("保存结果需要 ZIP64 偏移,当前不支持");
232
- const c = new Uint8Array(22), u = m(c);
233
- return u.setUint32(0, C, !0), u.setUint16(8, d, !0), u.setUint16(10, d, !0), u.setUint32(12, l, !0), u.setUint32(16, U, !0), { bytes: B([...e, ...r, c]), preservedEntries: s, rewrittenEntries: i };
232
+ const c = new Uint8Array(22), u = E(c);
233
+ return u.setUint32(0, v, !0), u.setUint16(8, d, !0), u.setUint16(10, d, !0), u.setUint32(12, l, !0), u.setUint32(16, U, !0), { bytes: F([...e, ...r, c]), preservedEntries: s, rewrittenEntries: i };
234
234
  }
235
- function ut(t, n) {
235
+ function V(t, n) {
236
236
  const e = Object.keys(t), r = new Set(e), o = e.filter((l) => n.get(l) !== null);
237
- if (o.push(...[...n].filter(([l, c]) => !r.has(l) && c !== null).map(([l]) => l).sort(Y)), o.length > 65535) throw new Error("重压结果需要 ZIP64 条目计数,当前不支持");
237
+ if (o.push(...[...n].filter(([l, c]) => !r.has(l) && c !== null).map(([l]) => l).sort(B)), o.length > 65535) throw new Error("重压结果需要 ZIP64 条目计数,当前不支持");
238
238
  const s = [], i = [];
239
239
  let a = 0;
240
240
  for (const l of o) {
241
241
  const c = n.get(l) ?? t[l];
242
242
  if (!c) throw new Error(`重压时缺少 OPC part:${l}`);
243
- const u = F(l, c, a);
243
+ const u = W(l, c, a);
244
244
  s.push(u.local), i.push(u.central), a += u.local.length;
245
245
  }
246
246
  const h = i.reduce((l, c) => l + c.length, 0);
247
247
  if (a > 4294967295 || h > 4294967295) throw new Error("重压结果需要 ZIP64 偏移,当前不支持");
248
- const d = new Uint8Array(22), U = m(d);
249
- return U.setUint32(0, C, !0), U.setUint16(8, o.length, !0), U.setUint16(10, o.length, !0), U.setUint32(12, h, !0), U.setUint32(16, a, !0), {
250
- bytes: B([...s, ...i, d]),
248
+ const d = new Uint8Array(22), U = E(d);
249
+ return U.setUint32(0, v, !0), U.setUint16(8, o.length, !0), U.setUint16(10, o.length, !0), U.setUint32(12, h, !0), U.setUint32(16, a, !0), {
250
+ bytes: F([...s, ...i, d]),
251
251
  preservedEntries: 0,
252
252
  rewrittenEntries: o.length
253
253
  };
254
254
  }
255
- function F(t, n, e) {
255
+ function W(t, n, e) {
256
256
  if (n.length > 4294967295) throw new Error(`OPC part 过大,需要 ZIP64:${t}`);
257
- const r = et.encode(t);
257
+ const r = rt.encode(t);
258
258
  if (r.length > 65535) throw new Error(`OPC part 路径过长:${t.slice(0, 80)}`);
259
- const o = t.slice(t.lastIndexOf(".") + 1).toLowerCase(), s = nt.has(o) ? null : j(n, { level: 6 }), i = s !== null && s.length < n.length, a = i ? 8 : 0, h = i ? s : n;
259
+ const o = t.slice(t.lastIndexOf(".") + 1).toLowerCase(), s = ot.has(o) ? null : T(n, { level: 6 }), i = s !== null && s.length < n.length, a = i ? 8 : 0, h = i ? s : n;
260
260
  if (h.length > 4294967295) throw new Error(`OPC part 压缩后过大,需要 ZIP64:${t}`);
261
- const d = _(n), U = new Uint8Array(30 + r.length + h.length), l = m(U);
262
- l.setUint32(0, G, !0), l.setUint16(4, 20, !0), l.setUint16(6, 2048, !0), l.setUint16(8, a, !0), l.setUint16(12, 33, !0), l.setUint32(14, d, !0), l.setUint32(18, h.length, !0), l.setUint32(22, n.length, !0), l.setUint16(26, r.length, !0), U.set(r, 30), U.set(h, 30 + r.length);
263
- const c = new Uint8Array(46 + r.length), u = m(c);
264
- return u.setUint32(0, M, !0), u.setUint16(4, 798, !0), u.setUint16(6, 20, !0), u.setUint16(8, 2048, !0), u.setUint16(10, a, !0), u.setUint16(14, 33, !0), u.setUint32(16, d, !0), u.setUint32(20, h.length, !0), u.setUint32(24, n.length, !0), u.setUint16(28, r.length, !0), u.setUint32(42, e, !0), c.set(r, 46), { local: U, central: c };
261
+ const d = M(n), U = new Uint8Array(30 + r.length + h.length), l = E(U);
262
+ l.setUint32(0, Y, !0), l.setUint16(4, 20, !0), l.setUint16(6, 2048, !0), l.setUint16(8, a, !0), l.setUint16(12, 33, !0), l.setUint32(14, d, !0), l.setUint32(18, h.length, !0), l.setUint32(22, n.length, !0), l.setUint16(26, r.length, !0), U.set(r, 30), U.set(h, 30 + r.length);
263
+ const c = new Uint8Array(46 + r.length), u = E(c);
264
+ return u.setUint32(0, G, !0), u.setUint16(4, 798, !0), u.setUint16(6, 20, !0), u.setUint16(8, 2048, !0), u.setUint16(10, a, !0), u.setUint16(14, 33, !0), u.setUint32(16, d, !0), u.setUint32(20, h.length, !0), u.setUint32(24, n.length, !0), u.setUint16(28, r.length, !0), u.setUint32(42, e, !0), c.set(r, 46), { local: U, central: c };
265
265
  }
266
- function at(t, n) {
266
+ function ft(t, n) {
267
267
  const e = /* @__PURE__ */ new Map();
268
268
  for (const [r, o] of Object.entries(n)) {
269
- ft(r);
269
+ q(r);
270
270
  const s = t.parts[r];
271
271
  o === null ? s && e.set(r, null) : (!s || !N(s, o)) && e.set(r, o.slice());
272
272
  }
273
273
  return e;
274
274
  }
275
- function ft(t) {
275
+ function q(t) {
276
276
  const n = t.split("/");
277
277
  if (!t || t.startsWith("/") || t.endsWith("/") || t.includes("\\") || n.some((e) => !e || e === "." || e === ".."))
278
278
  throw new Error(`非法 OPC part 路径:${t}`);
279
279
  }
280
+ function gt(t) {
281
+ const n = /* @__PURE__ */ Object.create(null), e = /* @__PURE__ */ new Map();
282
+ for (const [s, i] of Object.entries(t)) {
283
+ q(s);
284
+ const a = i.slice();
285
+ n[s] = a, e.set(s, a);
286
+ }
287
+ const r = V(/* @__PURE__ */ Object.create(null), e), o = Object.freeze(n);
288
+ return {
289
+ ...r,
290
+ bytes: r.bytes,
291
+ package: D(r.bytes, o),
292
+ mode: "repacked",
293
+ fallbackReason: null
294
+ };
295
+ }
280
296
  function wt(t, n, e) {
281
297
  const r = /* @__PURE__ */ Object.create(null);
282
298
  for (const [s, i] of Object.entries(t.parts))
@@ -284,21 +300,21 @@ function wt(t, n, e) {
284
300
  for (const [s, i] of e) i !== null && (r[s] = i);
285
301
  Object.freeze(r);
286
302
  const o = Object.freeze(Object.fromEntries(Object.entries(t.assets ?? {}).filter(([, s]) => !!s.sourcePart && !!r[s.sourcePart] && !e.has(s.sourcePart))));
287
- return H(n, r, o);
303
+ return D(n, r, o);
288
304
  }
289
- function gt(t) {
290
- J(t);
305
+ function pt(t) {
306
+ Q(t);
291
307
  }
292
- function pt(t, n) {
308
+ function Ut(t, n) {
293
309
  if (t.disposed) throw new Error("OPC 原包已释放,不能保存");
294
- const e = at(t, n);
310
+ const e = ft(t, n);
295
311
  if (e.size) {
296
312
  let r, o = null;
297
313
  try {
298
- r = lt(st(t.bytes), e);
314
+ r = ut(it(t.bytes), e);
299
315
  } catch (s) {
300
316
  if (!(s instanceof p)) throw s;
301
- o = s.reason, r = ut(t.parts, e);
317
+ o = s.reason, r = V(t.parts, e);
302
318
  }
303
319
  return {
304
320
  ...r,
@@ -317,6 +333,7 @@ function pt(t, n) {
317
333
  };
318
334
  }
319
335
  export {
320
- gt as d,
321
- pt as p
336
+ gt as c,
337
+ pt as d,
338
+ Ut as p
322
339
  };
@@ -0,0 +1,4 @@
1
+ import type { EditorChange, Patch, Selection } from './commands/types';
2
+ import type { EditDoc, ProjectionInvalidation } from './types';
3
+ /** 撤销、重做和外部补丁必须给 DOM 层同一套精确失效集合,不能各自近似一遍。 */
4
+ export declare function changeFromPatches(doc: EditDoc, patches: readonly Patch[], inverse: readonly Patch[], source: EditorChange['source'], selection: Selection, dirty: ProjectionInvalidation): EditorChange;
@@ -0,0 +1,12 @@
1
+ import type { EditorPatchEvent, EditorPatchSubscriber, EditorPatchSubscribeOptions } from './commands/types';
2
+ export declare function reportEditorSubscriberError(error: unknown): void;
3
+ /** recovery 前只给协同元数据观察者;普通观察者继续在视图事件后按 FIFO 收到补丁。 */
4
+ export declare class EditorPatchJournal {
5
+ private readonly subscribers;
6
+ private readonly beforeRecoverySubscribers;
7
+ private readonly pending;
8
+ private dispatching;
9
+ subscribe(subscriber: EditorPatchSubscriber, options?: EditorPatchSubscribeOptions): () => void;
10
+ queue(event: EditorPatchEvent): void;
11
+ flush(): void;
12
+ }
@@ -1,5 +1,5 @@
1
1
  import type { Patch } from './commands/types';
2
- import type { EditDoc, EditIdentity } from './types';
2
+ import type { EditDoc, EditIdentity, EditIdentityAllocation } from './types';
3
3
  export declare function assertRecoveryIdentity(value: unknown, prefix: string, sequence: number): asserts value is EditIdentity;
4
4
  export interface RecoveryIdentityFloor {
5
5
  nextSlide: number;
@@ -30,6 +30,7 @@ export interface RecoveryIdentityFloor {
30
30
  minimumNewNotesPart?: number;
31
31
  checkedSlideSource: boolean;
32
32
  checkedNotesSource: boolean;
33
+ allocation?: EditIdentityAllocation;
33
34
  }
34
35
  export declare function createRecoveryIdentityFloor(doc: EditDoc): RecoveryIdentityFloor;
35
36
  export declare function assertRecoveryIdentityFloor(doc: EditDoc, floor: RecoveryIdentityFloor, next: EditIdentity, patches: readonly Patch[], sequence: number): void;
@@ -1,3 +1,3 @@
1
1
  import type { RunPropertyOverrides } from './types';
2
- export declare const RUN_PROPERTY_FIELDS: readonly ["font", "size", "b", "i", "u", "strike", "link"];
2
+ export declare const RUN_PROPERTY_FIELDS: readonly ["font", "size", "color", "b", "i", "u", "strike", "link"];
3
3
  export declare function assertRunPropertyOverrides(value: unknown, label: string, allowEmpty?: boolean): asserts value is RunPropertyOverrides;
@@ -0,0 +1,5 @@
1
+ import type { XmlDocument } from '../xml/types';
2
+ import type { ElementRecord } from '../types';
3
+ export declare function hasGeometryOverride(record: ElementRecord): boolean;
4
+ /** 来源 custGeom 只换 pathLst;调整公式、手柄、连接点和未知扩展继续占原槽位。 */
5
+ export declare function patchElementGeometry(document: XmlDocument, record: ElementRecord): void;
@@ -4,6 +4,7 @@ import type { HyperlinkSaveContext } from './hyperlink';
4
4
  /** 删除、插入、覆盖的先后顺序与整页保存一致;复制片段也复用这一条物化路径。 */
5
5
  export declare function materializeElementTreeState(document: XmlDocument, doc: EditDoc, part: string, records: readonly ElementRecord[], removals: readonly RemovedElementRecord[], options?: {
6
6
  skipInsertions?: ReadonlySet<string>;
7
+ skipReparents?: boolean;
7
8
  scope?: ReadonlySet<string>;
8
9
  links?: HyperlinkSaveContext;
9
10
  }): void;
@@ -12,3 +13,5 @@ export declare function materializeElementRoots(doc: EditDoc, roots: readonly El
12
13
  export declare function materializeInsertionFragment(doc: EditDoc, record: ElementRecord): XmlDocument;
13
14
  /** 新宿主先进入目标树,后续变换与层级补丁才能继续复用统一的 spid 定位。 */
14
15
  export declare function patchInsertedElements(document: XmlDocument, doc: EditDoc, records: readonly ElementRecord[], skip?: ReadonlySet<string>): Set<string>;
16
+ /** 层级编辑移动原宿主本身,未知扩展、关系引用与 spid 因此都不需要重建。 */
17
+ export declare function patchReparentedElements(document: XmlDocument, doc: EditDoc, records: readonly ElementRecord[]): void;
@@ -1,6 +1,8 @@
1
1
  import type { EditDoc, SlideRecord } from '../types';
2
2
  /** 只替换 body 占位符段落;其它形状、关系、扩展和文本格式保持原树。 */
3
3
  export declare function patchNotesText(source: Uint8Array, value: string): Uint8Array;
4
+ /** 生成式保存与新增备注共用同一份最小宿主,避免两条备注序列化规则漂移。 */
5
+ export declare function createGeneratedNotesPart(value: string): Uint8Array;
4
6
  /** 备注关系属于页面元数据;只重定向指定 rId,不能重建整个关系 part。 */
5
7
  export declare function patchSlideNotesRelationship(slide: SlideRecord, source?: Uint8Array): Uint8Array;
6
8
  export interface NotesSavePlan {
@@ -0,0 +1,10 @@
1
+ import type { TextBody } from '@web-ppt/core';
2
+ import type { FlatTextParagraph, RunProperties, TextMark } from '../types';
3
+ import type { XmlElement } from '../xml/types';
4
+ import type { HyperlinkSaveContext } from './hyperlink';
5
+ export declare function applyRunOverrides(properties: XmlElement, mark: TextMark, links?: HyperlinkSaveContext, clearedFallback?: Partial<RunProperties>): void;
6
+ /**
7
+ * OOXML 无法在 run 上表达“跳过 pPr/defRPr、继续继承 lvlNpPr”。改级前若用户清掉了
8
+ * 段落级字符直设,保存时只能把新级继承结果落到 run,才能让 Office 重开与即时投影一致。
9
+ */
10
+ export declare function clearedLevelRunFallback(source: TextBody, paragraph: FlatTextParagraph, mark: TextMark): Partial<RunProperties> | undefined;
@@ -9,6 +9,9 @@ export declare function removeDrawingFillChildren(properties: XmlElement): void;
9
9
  export declare function materializeElementFill(document: XmlDocument, record: ElementRecord, fill: Exclude<Fill, {
10
10
  type: 'image';
11
11
  }> | null): void;
12
+ export declare function materializeElementImageFill(document: XmlDocument, record: ElementRecord, fill: Extract<Fill, {
13
+ type: 'image';
14
+ }>, relationshipId: string): void;
12
15
  export declare function materializeElementStroke(document: XmlDocument, record: ElementRecord, stroke: Stroke | null): void;
13
16
  export declare function hasShapeFormatOverrides(record: ElementRecord): boolean;
14
17
  export declare function patchElementShapeFormat(document: XmlDocument, record: ElementRecord): void;
@@ -0,0 +1,11 @@
1
+ import type { TableStyleDefinition } from '@web-ppt/core';
2
+ import type { EditDoc } from '../types';
3
+ export interface TableStyleSavePlan {
4
+ readonly part: string;
5
+ readonly definitions: readonly TableStyleDefinition[];
6
+ }
7
+ export declare function tableStyleSavePlan(doc: EditDoc): TableStyleSavePlan | null;
8
+ export declare function patchTableStyleContentType(source: Uint8Array, part: string): Uint8Array;
9
+ export declare function patchTableStylePresentationRelationships(source: Uint8Array, part: string): Uint8Array;
10
+ export declare function missingTableStyleDefinitions(source: Uint8Array | undefined, definitions: readonly TableStyleDefinition[]): TableStyleDefinition[];
11
+ export declare function materializeTableStyles(source: Uint8Array | undefined, definitions: readonly TableStyleDefinition[]): Uint8Array;
@@ -1,6 +1,9 @@
1
1
  import type { ElementRecord } from '../types';
2
2
  import type { XmlDocument } from '../xml/types';
3
3
  export declare function hasTableRowOverrides(record: ElementRecord): boolean;
4
+ export declare function hasTableStyleOverride(record: ElementRecord): boolean;
5
+ /** tblPr 只保存六个开关与 styleId;单元格直接格式继续原位直通。 */
6
+ export declare function patchTableStyle(document: XmlDocument, record: ElementRecord): void;
4
7
  /** 从首次触碰基线重建,连续保存不会重复烘入相同行。 */
5
8
  export declare function patchTableRows(document: XmlDocument, record: ElementRecord): void;
6
9
  /** frame 与内部网格必须同生共变;Office 不会替编辑模型猜测各行列的新整数尺寸。 */
@@ -0,0 +1,6 @@
1
+ import type { FlatTextParagraph, TextMark } from '../types';
2
+ import type { XmlElement } from '../xml/types';
3
+ /** 无来源段落没有可克隆的 pPr;生成/插入路径必须把有效列表语义固定下来。 */
4
+ export declare function materializeParagraphLayout(properties: XmlElement, paragraph: FlatTextParagraph): void;
5
+ /** 生成式文字没有来源 rPr;只在这一条边界把有效字符外观摊平。 */
6
+ export declare function materializeRunProperties(properties: XmlElement, mark: TextMark): void;