@stll/docx-core 0.43.1 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,79 @@
1
+ /**
2
+ * A date without its setters. `DeepReadonly` hands a `Date` out as this, so a
3
+ * read-only date is not assignable to `Date` and `setFullYear` and the other
4
+ * setters are not there to call.
5
+ */
6
+ type ReadonlyDate = Omit<Date, Extract<keyof Date, `set${string}`>>;
7
+ /**
8
+ * `Value` with every reachable field, element and entry read-only.
9
+ *
10
+ * An `ArrayBuffer` stays as it is: its bytes are written only through a view
11
+ * built over it (`new Uint8Array(buffer)`), and every reader builds the same
12
+ * views to read it, so no type can tell a reader's view from a writer's.
13
+ */
14
+ type DeepReadonly<Value> = Value extends ((...args: never[]) => unknown) ? Value : Value extends ArrayBuffer ? Value : Value extends Date ? ReadonlyDate : Value extends ReadonlyMap<infer Key, infer Entry> ? ReadonlyMap<DeepReadonly<Key>, DeepReadonly<Entry>> : Value extends ReadonlySet<infer Entry> ? ReadonlySet<DeepReadonly<Entry>> : Value extends readonly (infer Element)[] ? readonly DeepReadonly<Element>[] : Value extends object ? { readonly [Key in keyof Value]: DeepReadonly<Value[Key]>; } : Value;
15
+ declare const writableRecord: unique symbol;
16
+ /**
17
+ * Every record type of the model carries this field, so its `DeepReadonly`
18
+ * form is not assignable to it: TypeScript ignores `readonly` on object
19
+ * fields when it compares types and checks it only on arrays, so a read-only
20
+ * record would otherwise pass to any function that takes the writable record
21
+ * and writes it. The field's type is a mutable array, which `DeepReadonly`
22
+ * turns into a read-only one, and a read-only array is the one read-only
23
+ * value TypeScript refuses where a writable one is expected. The field is
24
+ * optional and never set: a writable record still passes where its read-only
25
+ * form is expected, and an object literal needs nothing extra. A writer copies
26
+ * a read-only value first (`writableCopy`,
27
+ * `cloneDocumentWithParagraphPropertySources`).
28
+ */
29
+ type WritableRecord = {
30
+ readonly [writableRecord]?: unknown[];
31
+ };
32
+ /** A model record's own fields, without the {@link WritableRecord} mark. */
33
+ type RecordField<Value> = Exclude<keyof Value, keyof WritableRecord>;
34
+ /** Markup the container's model does not hold, and where it sat. */
35
+ type PreservedChild = WritableRecord & {
36
+ /**
37
+ * Where the markup goes back. `0` puts it before the first modelled child;
38
+ * the container's modelled count puts it after the last. In a property set
39
+ * it is the schema ordinal, and the two halves merge by it.
40
+ */
41
+ index: number;
42
+ /** Replayable markup for one child, as `captureVerbatimXml` wrote it. */
43
+ xml: string;
44
+ };
45
+ /**
46
+ * A container's unmodelled markup. Absent means the parser read every child
47
+ * the source carried, which is the state a fully modelled container is in; an
48
+ * empty record is never written.
49
+ */
50
+ type PreservedMarkup = WritableRecord & {
51
+ /** Ordered by `index`, then by source order within an index. */
52
+ children?: PreservedChild[];
53
+ };
54
+ /**
55
+ * One attribute an element carried that its parser has no field for.
56
+ *
57
+ * The remainder is a sibling of the child sink, not a member of it: an
58
+ * attribute has no position among children to keep, so it rides the element's
59
+ * own model record — `Paragraph.preservedAttributes` and its siblings — and
60
+ * the serializer writes it back into the same start tag.
61
+ *
62
+ * The name is resolved, never the source's spelling. folio reads an attribute
63
+ * by namespace URI plus local name, so a remainder that kept `"w:rsidR"`
64
+ * textually would keep a second copy of the `w:rsidR` a source spelled
65
+ * `altw:rsidR` under a second binding of the same URI. `namespace` is absent
66
+ * for an unprefixed attribute, which has none; a namespace declaration is not
67
+ * an attribute of the element in this sense and is never in the remainder,
68
+ * because the rebuilt part binds its own prefixes.
69
+ */
70
+ type PreservedAttribute = WritableRecord & {
71
+ /** Resolved namespace URI, absent for an unprefixed attribute. */
72
+ namespace?: string;
73
+ /** Local name, without the prefix the source happened to bind. */
74
+ name: string;
75
+ value: string;
76
+ };
77
+ /** Locate captured markup among the children still present. */
78
+ declare const preservedChildGap: (child: Pick<PreservedChild, "index">, childCount: number) => number;
79
+ export { DeepReadonly as a, preservedChildGap as i, PreservedChild as n, RecordField as o, PreservedMarkup as r, WritableRecord as s, PreservedAttribute as t };
@@ -20,19 +20,19 @@ function docxProjectionSchemaVersion$1() {
20
20
  *
21
21
  * Returns a JavaScript `Error` when the package cannot be projected or a
22
22
  * numeric wire value cannot be represented by the schema.
23
- * @param {Uint8Array} bytes
23
+ * @param {Uint8Array | number[]} bytes
24
24
  * @returns {DocxProjectionWire}
25
25
  */
26
26
  function projectCompressedDocx$1(bytes) {
27
27
  try {
28
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
29
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
28
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
29
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
30
30
  const len0 = WASM_VECTOR_LEN;
31
31
  wasm.projectCompressedDocx(retptr, ptr0, len0);
32
32
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
33
33
  var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
34
- if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
35
- return takeObject(r0);
34
+ if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeFromExternrefTable0(r1);
35
+ return takeFromExternrefTable0(r0);
36
36
  } finally {
37
37
  wasm.__wbindgen_add_to_stack_pointer(16);
38
38
  }
@@ -44,19 +44,19 @@ function projectCompressedDocx$1(bytes) {
44
44
  *
45
45
  * Returns a JavaScript `Error` under the same conditions as
46
46
  * [`project_compressed_docx_with_review_facts`].
47
- * @param {Uint8Array} bytes
47
+ * @param {Uint8Array | number[]} bytes
48
48
  * @returns {DocxPackageProjectionWire}
49
49
  */
50
50
  function projectCompressedDocxWithReadableReviewFacts(bytes) {
51
51
  try {
52
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
53
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
52
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
53
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
54
54
  const len0 = WASM_VECTOR_LEN;
55
55
  wasm.projectCompressedDocxWithReadableReviewFacts(retptr, ptr0, len0);
56
56
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
57
57
  var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
58
- if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
59
- return takeObject(r0);
58
+ if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeFromExternrefTable0(r1);
59
+ return takeFromExternrefTable0(r0);
60
60
  } finally {
61
61
  wasm.__wbindgen_add_to_stack_pointer(16);
62
62
  }
@@ -69,19 +69,19 @@ function projectCompressedDocxWithReadableReviewFacts(bytes) {
69
69
  *
70
70
  * Returns a JavaScript `Error` when the document package itself cannot be
71
71
  * projected. Invalid optional review parts are represented as unknown facts.
72
- * @param {Uint8Array} bytes
72
+ * @param {Uint8Array | number[]} bytes
73
73
  * @returns {DocxPackageProjectionWire}
74
74
  */
75
75
  function projectCompressedDocxWithReviewFacts$1(bytes) {
76
76
  try {
77
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
78
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
77
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
78
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
79
79
  const len0 = WASM_VECTOR_LEN;
80
80
  wasm.projectCompressedDocxWithReviewFacts(retptr, ptr0, len0);
81
81
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
82
82
  var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
83
- if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
84
- return takeObject(r0);
83
+ if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeFromExternrefTable0(r1);
84
+ return takeFromExternrefTable0(r0);
85
85
  } finally {
86
86
  wasm.__wbindgen_add_to_stack_pointer(16);
87
87
  }
@@ -91,19 +91,19 @@ function projectCompressedDocxWithReviewFacts$1(bytes) {
91
91
  *
92
92
  * # Errors
93
93
  * Returns a JavaScript `Error` for malformed input or a resource-limit violation.
94
- * @param {Uint8Array} bytes
94
+ * @param {Uint8Array | number[]} bytes
95
95
  * @returns {DocxProjectionWire}
96
96
  */
97
97
  function projectMainDocumentXml$1(bytes) {
98
98
  try {
99
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
100
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
99
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
100
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
101
101
  const len0 = WASM_VECTOR_LEN;
102
102
  wasm.projectMainDocumentXml(retptr, ptr0, len0);
103
103
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
104
104
  var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
105
- if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
106
- return takeObject(r0);
105
+ if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeFromExternrefTable0(r1);
106
+ return takeFromExternrefTable0(r0);
107
107
  } finally {
108
108
  wasm.__wbindgen_add_to_stack_pointer(16);
109
109
  }
@@ -113,19 +113,19 @@ function projectMainDocumentXml$1(bytes) {
113
113
  *
114
114
  * # Errors
115
115
  * Returns a JavaScript `Error` for malformed input or a resource-limit violation.
116
- * @param {Uint8Array} bytes
116
+ * @param {Uint8Array | number[]} bytes
117
117
  * @returns {DocxParagraphFragmentWire}
118
118
  */
119
119
  function projectParagraphFragment$1(bytes) {
120
120
  try {
121
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
122
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export2);
121
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
122
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export3);
123
123
  const len0 = WASM_VECTOR_LEN;
124
124
  wasm.projectParagraphFragment(retptr, ptr0, len0);
125
125
  var r0 = getDataViewMemory0().getInt32(retptr + 0, true);
126
126
  var r1 = getDataViewMemory0().getInt32(retptr + 4, true);
127
- if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeObject(r1);
128
- return takeObject(r0);
127
+ if (getDataViewMemory0().getInt32(retptr + 8, true)) throw takeFromExternrefTable0(r1);
128
+ return takeFromExternrefTable0(r0);
129
129
  } finally {
130
130
  wasm.__wbindgen_add_to_stack_pointer(16);
131
131
  }
@@ -135,111 +135,99 @@ function __wbg_get_imports() {
135
135
  __proto__: null,
136
136
  "./docx_kernel_bg.js": {
137
137
  __proto__: null,
138
- __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
138
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
139
139
  throw new Error(getStringFromWasm0(arg0, arg1));
140
140
  },
141
- __wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
142
- return addHeapObject(new Error(getStringFromWasm0(arg0, arg1)));
141
+ __wbg_new_37eb45aaf5eeb820: function() {
142
+ return new Array();
143
143
  },
144
- __wbg_new_617a8cdb8bb1130e: function() {
145
- return addHeapObject(/* @__PURE__ */ new Object());
144
+ __wbg_new_787b9fb330d55d78: function(arg0, arg1) {
145
+ return new Error(getStringFromWasm0(arg0, arg1));
146
146
  },
147
- __wbg_new_ee2291f50781bf1d: function() {
148
- return addHeapObject(new Array());
147
+ __wbg_new_cd4348290afae586: function() {
148
+ return /* @__PURE__ */ new Object();
149
149
  },
150
- __wbg_new_with_length_469fcc27bd71672e: function(arg0) {
151
- return addHeapObject(new Array(arg0 >>> 0));
150
+ __wbg_new_with_length_a3dc62dea6e2e158: function(arg0) {
151
+ return new Array(arg0 >>> 0);
152
152
  },
153
- __wbg_push_2baf45db356cf468: function(arg0, arg1) {
154
- return getObject(arg0).push(getObject(arg1));
153
+ __wbg_push_c9f4893fc209f768: function(arg0, arg1) {
154
+ return arg0.push(arg1);
155
155
  },
156
- __wbg_set_145a351398b48c65: function() {
156
+ __wbg_set_2793479888329cb6: function() {
157
157
  return handleError(function(arg0, arg1, arg2) {
158
- return Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
158
+ return Reflect.set(arg0, arg1, arg2);
159
159
  }, arguments);
160
160
  },
161
- __wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
162
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
161
+ __wbg_set_d2d33b52458e984a: function(arg0, arg1, arg2) {
162
+ arg0[arg1 >>> 0] = arg2;
163
163
  },
164
164
  __wbindgen_generic_0000000000000001: function(arg0) {
165
- return addHeapObject(arg0);
165
+ return arg0;
166
166
  },
167
167
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
168
- return addHeapObject(getStringFromWasm0(arg0, arg1));
168
+ return getStringFromWasm0(arg0, arg1);
169
169
  },
170
- __wbindgen_object_drop_ref: function(arg0) {
171
- takeObject(arg0);
170
+ __wbindgen_init_externref_table: function() {
171
+ const table = wasm.__wbindgen_externrefs;
172
+ table.set(0, void 0);
173
+ table.set(1024, void 0);
174
+ table.set(1025, null);
175
+ table.set(1026, true);
176
+ table.set(1027, false);
172
177
  }
173
178
  }
174
179
  };
175
180
  }
176
- function addHeapObject(obj) {
177
- if (heap_next === heap.length) heap.push(heap.length + 1);
178
- const idx = heap_next;
179
- heap_next = heap[idx];
180
- heap[idx] = obj;
181
+ function addToExternrefTable0(obj) {
182
+ const idx = wasm.__wbindgen_export2();
183
+ wasm.__wbindgen_externrefs.set(idx, obj);
181
184
  return idx;
182
185
  }
183
- function dropObject(idx) {
184
- if (idx < 1028) return;
185
- heap[idx] = heap_next;
186
- heap_next = idx;
187
- }
188
186
  let cachedDataViewMemory0 = null;
189
187
  function getDataViewMemory0() {
190
188
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
191
189
  return cachedDataViewMemory0;
192
190
  }
193
191
  function getStringFromWasm0(ptr, len) {
194
- return decodeText(ptr >>> 0, len);
192
+ ptr = ptr >>> 0;
193
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
195
194
  }
196
195
  let cachedUint8ArrayMemory0 = null;
197
196
  function getUint8ArrayMemory0() {
198
197
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
199
198
  return cachedUint8ArrayMemory0;
200
199
  }
201
- function getObject(idx) {
202
- return heap[idx];
203
- }
204
200
  function handleError(f, args) {
205
201
  try {
206
202
  return f.apply(this, args);
207
203
  } catch (e) {
208
- wasm.__wbindgen_export(addHeapObject(e));
204
+ const idx = addToExternrefTable0(e);
205
+ wasm.__wbindgen_export(idx);
209
206
  }
210
207
  }
211
- let heap = new Array(1024).fill(void 0);
212
- heap.push(void 0, null, true, false);
213
- let heap_next = heap.length;
214
208
  function passArray8ToWasm0(arg, malloc) {
215
209
  const ptr = malloc(arg.length * 1, 1) >>> 0;
216
210
  getUint8ArrayMemory0().set(arg, ptr / 1);
217
211
  WASM_VECTOR_LEN = arg.length;
218
212
  return ptr;
219
213
  }
220
- function takeObject(idx) {
221
- const ret = getObject(idx);
222
- dropObject(idx);
223
- return ret;
214
+ function takeFromExternrefTable0(idx) {
215
+ const value = wasm.__wbindgen_externrefs.get(idx);
216
+ wasm.__wbindgen_export5(idx);
217
+ return value;
224
218
  }
225
- let cachedTextDecoder = new TextDecoder("utf-8", {
226
- ignoreBOM: true,
227
- fatal: true
228
- });
219
+ let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
229
220
  cachedTextDecoder.decode();
230
221
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
231
222
  let numBytesDecoded = 0;
232
- function decodeText(ptr, len) {
233
- numBytesDecoded += len;
223
+ function decodeText(bytes) {
224
+ numBytesDecoded += bytes.length;
234
225
  if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
235
- cachedTextDecoder = new TextDecoder("utf-8", {
236
- ignoreBOM: true,
237
- fatal: true
238
- });
226
+ cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
239
227
  cachedTextDecoder.decode();
240
- numBytesDecoded = len;
228
+ numBytesDecoded = bytes.length;
241
229
  }
242
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
230
+ return cachedTextDecoder.decode(bytes);
243
231
  }
244
232
  let WASM_VECTOR_LEN = 0;
245
233
  let wasm;
@@ -247,6 +235,7 @@ function __wbg_finalize_init(instance, module) {
247
235
  wasm = instance.exports;
248
236
  cachedDataViewMemory0 = null;
249
237
  cachedUint8ArrayMemory0 = null;
238
+ wasm.__wbindgen_start();
250
239
  return wasm;
251
240
  }
252
241
  async function __wbg_load(module, imports) {
@@ -277,8 +266,18 @@ async function __wbg_load(module, imports) {
277
266
  return false;
278
267
  }
279
268
  }
269
+ let __wbg_init_promise;
280
270
  async function __wbg_init(module_or_path) {
281
271
  if (wasm !== void 0) return wasm;
272
+ if (__wbg_init_promise === void 0) {
273
+ __wbg_init_promise = __wbg_init_once(module_or_path);
274
+ __wbg_init_promise.catch(() => {
275
+ __wbg_init_promise = void 0;
276
+ });
277
+ }
278
+ return __wbg_init_promise;
279
+ }
280
+ async function __wbg_init_once(module_or_path) {
282
281
  if (module_or_path !== void 0) {
283
282
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) ({module_or_path} = module_or_path);
284
283
  else console.warn("using deprecated parameters for the initialization function; pass a single object instead");
@@ -1,4 +1,4 @@
1
- import { r as PreservedMarkup } from "../preservedMarkup-9L4lbGnE.js";
1
+ import { r as PreservedMarkup } from "../preservedMarkup-BWpGhchw.js";
2
2
  /**
3
3
  * GENERATED FILE — do not edit.
4
4
  *
@@ -1 +1 @@
1
- export { a as SEQUENCE_CHILDREN, o as SETTINGS_CHILDREN, t as assertSafePreservedMarkup, n as isSafePreservedChildXml, r as isWithinPreservedMarkupBudget, i as serializeSequenceChildren } from "../sequenceChildren-BEcOm3tR.js";
1
+ export { a as SEQUENCE_CHILDREN, o as SETTINGS_CHILDREN, t as assertSafePreservedMarkup, n as isSafePreservedChildXml, r as isWithinPreservedMarkupBudget, i as serializeSequenceChildren } from "../sequenceChildren-ESF-Ei5K.js";
@@ -1,4 +1,4 @@
1
- import { o as readXml } from "./streamingXmlParser-GnKxUuw_.js";
1
+ import { c as readXml } from "./streamingXmlParser-BqnCIEZd.js";
2
2
  import { OOXML_NS } from "./xml/xmlNamespaceContext.js";
3
3
  import { TaggedError } from "better-result";
4
4
  // src/schema/sequenceChildren.gen.ts