token-goat 2.9.13 → 2.9.15
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.
- package/README.md +28 -1
- package/dist/token-goat-chunk-2X2EBBC6.mjs +277 -0
- package/dist/token-goat-chunk-3BTK54F3.mjs +1733 -0
- package/dist/token-goat-chunk-3NSDDTGL.mjs +34 -0
- package/dist/token-goat-chunk-4EXFN2AW.mjs +29 -0
- package/dist/token-goat-chunk-5V7DAC7V.mjs +123 -0
- package/dist/token-goat-chunk-6DLVZDB6.mjs +34 -0
- package/dist/token-goat-chunk-7ZYK25AO.mjs +24 -0
- package/dist/token-goat-chunk-A4JYKD5H.mjs +144 -0
- package/dist/token-goat-chunk-AH6QILZM.mjs +26 -0
- package/dist/token-goat-chunk-ASYEPR3S.mjs +212 -0
- package/dist/{token-goat-chunk-RDITECDL.mjs → token-goat-chunk-ATIFTMRC.mjs} +31 -13
- package/dist/{token-goat-chunk-ZZI3IDQZ.mjs → token-goat-chunk-BL5LNGBG.mjs} +3935 -11949
- package/dist/{token-goat-chunk-4NXUKV7D.mjs → token-goat-chunk-C5JIO6HK.mjs} +8 -4
- package/dist/{token-goat-chunk-FZU7GMUS.mjs → token-goat-chunk-DQ4J5AFF.mjs} +50 -18
- package/dist/token-goat-chunk-ERTXEKB6.mjs +228 -0
- package/dist/{token-goat-chunk-6B44WLIF.mjs → token-goat-chunk-GIIHUSZX.mjs} +142 -21
- package/dist/token-goat-chunk-GMOUBOX4.mjs +386 -0
- package/dist/{token-goat-chunk-3ESRORNM.mjs → token-goat-chunk-GMQQA7E4.mjs} +12576 -12326
- package/dist/token-goat-chunk-IVUQLQWN.mjs +2046 -0
- package/dist/token-goat-chunk-K7F2BFIK.mjs +2430 -0
- package/dist/{token-goat-chunk-U7X6LQD2.mjs → token-goat-chunk-LCZBPOIN.mjs} +10197 -9717
- package/dist/token-goat-chunk-LMFO66YD.mjs +331 -0
- package/dist/token-goat-chunk-LT7JRU6K.mjs +22 -0
- package/dist/token-goat-chunk-MZDIJJ3R.mjs +420 -0
- package/dist/token-goat-chunk-NDPO7GAH.mjs +177 -0
- package/dist/token-goat-chunk-NDRP4KJQ.mjs +4371 -0
- package/dist/token-goat-chunk-NEI4NC54.mjs +424 -0
- package/dist/token-goat-chunk-NU7TLMQK.mjs +585 -0
- package/dist/token-goat-chunk-OSUFN2FV.mjs +326 -0
- package/dist/token-goat-chunk-OUGNPMDA.mjs +959 -0
- package/dist/token-goat-chunk-PM76YS22.mjs +1341 -0
- package/dist/token-goat-chunk-S4XRY446.mjs +2637 -0
- package/dist/{token-goat-chunk-YOA4N6WA.mjs → token-goat-chunk-SFAS46RE.mjs} +5 -3
- package/dist/{token-goat-chunk-QWSUZWFP.mjs → token-goat-chunk-SZWYESBS.mjs} +793 -650
- package/dist/{token-goat-chunk-B3CTCQTH.mjs → token-goat-chunk-XEPXYDPI.mjs} +3 -2
- package/dist/token-goat-chunk-XTQAOTSO.mjs +89 -0
- package/dist/token-goat-chunk-Y4AFKTHK.mjs +22 -0
- package/dist/token-goat-chunk-YKG35VHC.mjs +228 -0
- package/dist/{token-goat-chunk-JOXLE672.mjs → token-goat-chunk-YQ7WI2CO.mjs} +990 -106
- package/dist/{token-goat-chunk-2WC4ZUXN.mjs → token-goat-chunk-YZX7EFG4.mjs} +1 -1
- package/dist/token-goat-chunk-Z6UXPYJA.mjs +62 -0
- package/dist/token-goat-hook.mjs +16 -8
- package/dist/token-goat.core.mjs +27 -10
- package/docs/cli.md +9 -6
- package/package.json +4 -2
- package/dist/token-goat-chunk-FQCNJV4V.mjs +0 -693
- package/dist/token-goat-chunk-JVNPCQB7.mjs +0 -31
- package/dist/token-goat-chunk-P2PU4CR5.mjs +0 -26
- package/dist/token-goat-chunk-QKXBGBQR.mjs +0 -3653
- package/dist/token-goat-chunk-UM47DRD3.mjs +0 -242
- package/dist/token-goat-chunk-UMXJN7DI.mjs +0 -5521
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
MAX_ZIP_INPUT_BYTES,
|
|
5
|
+
MAX_ZIP_OUTPUT_BYTES,
|
|
6
|
+
ZipInputTooLargeError,
|
|
7
|
+
ZipOutputTooLargeError,
|
|
8
|
+
unzipBounded
|
|
9
|
+
} from "./token-goat-chunk-XTQAOTSO.mjs";
|
|
10
|
+
import {
|
|
11
|
+
createLazyModuleLoader
|
|
12
|
+
} from "./token-goat-chunk-AH6QILZM.mjs";
|
|
13
|
+
import {
|
|
14
|
+
DocumentRefusedError,
|
|
15
|
+
MAX_DOCUMENT_WORK_MILLIS
|
|
16
|
+
} from "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
17
|
+
import {
|
|
18
|
+
pushAll
|
|
19
|
+
} from "./token-goat-chunk-PM76YS22.mjs";
|
|
20
|
+
import {
|
|
21
|
+
init_define_import_meta_env
|
|
22
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
23
|
+
|
|
24
|
+
// src/ooxml_extract.ts
|
|
25
|
+
init_define_import_meta_env();
|
|
26
|
+
import * as fs from "node:fs";
|
|
27
|
+
|
|
28
|
+
// src/xml_parser.ts
|
|
29
|
+
init_define_import_meta_env();
|
|
30
|
+
var MAX_XML_DEPTH = 512;
|
|
31
|
+
var XmlTooDeepError = class extends DocumentRefusedError {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super(message, "XmlTooDeepError");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var NAMED_ENTITIES = {
|
|
37
|
+
lt: "<",
|
|
38
|
+
gt: ">",
|
|
39
|
+
amp: "&",
|
|
40
|
+
quot: '"',
|
|
41
|
+
apos: "'"
|
|
42
|
+
};
|
|
43
|
+
function decodeXmlEntities(text) {
|
|
44
|
+
if (!text.includes("&")) return text;
|
|
45
|
+
return text.replace(/&(#[xX][0-9a-fA-F]+|#[0-9]+|[a-zA-Z_][\w.:-]*);/g, (whole, body) => {
|
|
46
|
+
if (body.charCodeAt(0) === 35) {
|
|
47
|
+
const isHex = body.charCodeAt(1) === 120 || body.charCodeAt(1) === 88;
|
|
48
|
+
const digits = isHex ? body.slice(2) : body.slice(1);
|
|
49
|
+
const code = parseInt(digits, isHex ? 16 : 10);
|
|
50
|
+
if (!Number.isFinite(code) || code < 0 || code > 1114111) return whole;
|
|
51
|
+
if (code >= 55296 && code <= 57343) return whole;
|
|
52
|
+
return String.fromCodePoint(code);
|
|
53
|
+
}
|
|
54
|
+
const named = NAMED_ENTITIES[body];
|
|
55
|
+
return named ?? whole;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function newFrame(name) {
|
|
59
|
+
return { name, children: /* @__PURE__ */ new Map(), text: [], attrs: [] };
|
|
60
|
+
}
|
|
61
|
+
function finishFrame(frame) {
|
|
62
|
+
const text = frame.text.join("");
|
|
63
|
+
if (frame.children.size === 0 && frame.attrs.length === 0) return text;
|
|
64
|
+
const obj = {};
|
|
65
|
+
for (const [key, value] of frame.children) obj[key] = value;
|
|
66
|
+
if (text.length > 0) obj["#text"] = text;
|
|
67
|
+
for (const [key, value] of frame.attrs) obj[`@_${key}`] = value;
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
function addChild(parent, name, value) {
|
|
71
|
+
const existing = parent.children.get(name);
|
|
72
|
+
if (existing === void 0 && !parent.children.has(name)) {
|
|
73
|
+
parent.children.set(name, value);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(existing)) {
|
|
77
|
+
existing.push(value);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
parent.children.set(name, [existing, value]);
|
|
81
|
+
}
|
|
82
|
+
var WHITESPACE = /* @__PURE__ */ new Set([" ", " ", "\n", "\r"]);
|
|
83
|
+
function findTagEnd(src, from) {
|
|
84
|
+
let quote = "";
|
|
85
|
+
for (let i = from; i < src.length; i++) {
|
|
86
|
+
const ch = src[i];
|
|
87
|
+
if (quote !== "") {
|
|
88
|
+
if (ch === quote) quote = "";
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (ch === '"' || ch === "'") {
|
|
92
|
+
quote = ch;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (ch === ">") return i;
|
|
96
|
+
}
|
|
97
|
+
return -1;
|
|
98
|
+
}
|
|
99
|
+
function skipDeclaration(src, from) {
|
|
100
|
+
let quote = "";
|
|
101
|
+
let inSubset = false;
|
|
102
|
+
for (let i = from + 2; i < src.length; i++) {
|
|
103
|
+
const ch = src[i];
|
|
104
|
+
if (quote !== "") {
|
|
105
|
+
if (ch === quote) quote = "";
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (ch === '"' || ch === "'") {
|
|
109
|
+
quote = ch;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (ch === "[") inSubset = true;
|
|
113
|
+
else if (ch === "]") inSubset = false;
|
|
114
|
+
else if (ch === ">" && !inSubset) return i + 1;
|
|
115
|
+
}
|
|
116
|
+
return src.length;
|
|
117
|
+
}
|
|
118
|
+
function parseTagBody(body) {
|
|
119
|
+
let i = 0;
|
|
120
|
+
while (i < body.length && !WHITESPACE.has(body[i])) i++;
|
|
121
|
+
const name = body.slice(0, i);
|
|
122
|
+
const attrs = [];
|
|
123
|
+
while (i < body.length) {
|
|
124
|
+
while (i < body.length && WHITESPACE.has(body[i])) i++;
|
|
125
|
+
if (i >= body.length) break;
|
|
126
|
+
const nameStart = i;
|
|
127
|
+
while (i < body.length && !WHITESPACE.has(body[i]) && body[i] !== "=") i++;
|
|
128
|
+
const attrName = body.slice(nameStart, i);
|
|
129
|
+
if (attrName.length === 0) {
|
|
130
|
+
i++;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
while (i < body.length && WHITESPACE.has(body[i])) i++;
|
|
134
|
+
if (body[i] !== "=") {
|
|
135
|
+
attrs.push([attrName, ""]);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
i++;
|
|
139
|
+
while (i < body.length && WHITESPACE.has(body[i])) i++;
|
|
140
|
+
const quote = body[i];
|
|
141
|
+
if (quote === '"' || quote === "'") {
|
|
142
|
+
const valueStart = i + 1;
|
|
143
|
+
const valueEnd = body.indexOf(quote, valueStart);
|
|
144
|
+
const end = valueEnd === -1 ? body.length : valueEnd;
|
|
145
|
+
attrs.push([attrName, decodeXmlEntities(body.slice(valueStart, end))]);
|
|
146
|
+
i = end + 1;
|
|
147
|
+
} else {
|
|
148
|
+
const valueStart = i;
|
|
149
|
+
while (i < body.length && !WHITESPACE.has(body[i])) i++;
|
|
150
|
+
attrs.push([attrName, decodeXmlEntities(body.slice(valueStart, i))]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return { name, attrs };
|
|
154
|
+
}
|
|
155
|
+
function parseXml(xml) {
|
|
156
|
+
const src = xml.charCodeAt(0) === 65279 ? xml.slice(1) : xml;
|
|
157
|
+
const root = newFrame("");
|
|
158
|
+
const stack = [root];
|
|
159
|
+
const len = src.length;
|
|
160
|
+
let i = 0;
|
|
161
|
+
const top = () => stack[stack.length - 1];
|
|
162
|
+
const pushText = (from, to) => {
|
|
163
|
+
if (to > from) top().text.push(decodeXmlEntities(src.slice(from, to)));
|
|
164
|
+
};
|
|
165
|
+
const closeElement = (name) => {
|
|
166
|
+
let target = -1;
|
|
167
|
+
for (let k = stack.length - 1; k >= 1; k--) {
|
|
168
|
+
if (stack[k].name === name) {
|
|
169
|
+
target = k;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (target === -1) return;
|
|
174
|
+
while (stack.length > target) {
|
|
175
|
+
const frame = stack.pop();
|
|
176
|
+
addChild(top(), frame.name, finishFrame(frame));
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
while (i < len) {
|
|
180
|
+
const lt = src.indexOf("<", i);
|
|
181
|
+
if (lt === -1) {
|
|
182
|
+
pushText(i, len);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
pushText(i, lt);
|
|
186
|
+
if (src.startsWith("<!--", lt)) {
|
|
187
|
+
const end2 = src.indexOf("-->", lt + 4);
|
|
188
|
+
i = end2 === -1 ? len : end2 + 3;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (src.startsWith("<![CDATA[", lt)) {
|
|
192
|
+
const end2 = src.indexOf("]]>", lt + 9);
|
|
193
|
+
top().text.push(src.slice(lt + 9, end2 === -1 ? len : end2));
|
|
194
|
+
i = end2 === -1 ? len : end2 + 3;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (src.startsWith("<!", lt)) {
|
|
198
|
+
i = skipDeclaration(src, lt);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (src.startsWith("<?", lt)) {
|
|
202
|
+
const end2 = src.indexOf("?>", lt + 2);
|
|
203
|
+
const { name: name2, attrs: attrs2 } = parseTagBody(src.slice(lt + 2, end2 === -1 ? len : end2));
|
|
204
|
+
if (name2.length > 0) {
|
|
205
|
+
const frame2 = newFrame(`?${name2}`);
|
|
206
|
+
frame2.attrs = attrs2;
|
|
207
|
+
addChild(top(), frame2.name, finishFrame(frame2));
|
|
208
|
+
}
|
|
209
|
+
i = end2 === -1 ? len : end2 + 2;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (src.startsWith("</", lt)) {
|
|
213
|
+
const end2 = src.indexOf(">", lt + 2);
|
|
214
|
+
closeElement(src.slice(lt + 2, end2 === -1 ? len : end2).trim());
|
|
215
|
+
i = end2 === -1 ? len : end2 + 1;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
const end = findTagEnd(src, lt + 1);
|
|
219
|
+
const tagEnd = end === -1 ? len : end;
|
|
220
|
+
let body = src.slice(lt + 1, tagEnd);
|
|
221
|
+
const selfClosing = body.endsWith("/");
|
|
222
|
+
if (selfClosing) body = body.slice(0, -1);
|
|
223
|
+
const { name, attrs } = parseTagBody(body);
|
|
224
|
+
i = end === -1 ? len : end + 1;
|
|
225
|
+
if (name.length === 0) continue;
|
|
226
|
+
const frame = newFrame(name);
|
|
227
|
+
frame.attrs = attrs;
|
|
228
|
+
if (selfClosing) {
|
|
229
|
+
addChild(top(), name, finishFrame(frame));
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (stack.length > MAX_XML_DEPTH) {
|
|
233
|
+
throw new XmlTooDeepError(`XML nesting deeper than ${MAX_XML_DEPTH} elements; refusing to parse (this file is not something any office application produces)`);
|
|
234
|
+
}
|
|
235
|
+
stack.push(frame);
|
|
236
|
+
}
|
|
237
|
+
while (stack.length > 1) {
|
|
238
|
+
const frame = stack.pop();
|
|
239
|
+
addChild(top(), frame.name, finishFrame(frame));
|
|
240
|
+
}
|
|
241
|
+
return Object.fromEntries(root.children);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/ooxml_extract.ts
|
|
245
|
+
var MAX_OOXML_WORK_MILLIS = MAX_DOCUMENT_WORK_MILLIS;
|
|
246
|
+
var OoxmlTookTooLongError = class extends DocumentRefusedError {
|
|
247
|
+
constructor(message) {
|
|
248
|
+
super(message, "OoxmlTookTooLongError", true);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var NotAnOfficeDocumentError = class extends DocumentRefusedError {
|
|
252
|
+
constructor(message, cause) {
|
|
253
|
+
super(message, "NotAnOfficeDocumentError");
|
|
254
|
+
if (cause !== void 0) this.cause = cause;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
function ooxmlWorkDeadline() {
|
|
258
|
+
return Date.now() + MAX_OOXML_WORK_MILLIS;
|
|
259
|
+
}
|
|
260
|
+
function assertOoxmlWithinDeadline(deadline, hint) {
|
|
261
|
+
if (Date.now() > deadline) {
|
|
262
|
+
throw new OoxmlTookTooLongError(`reading this document's slides/sheets passed the ${MAX_OOXML_WORK_MILLIS}ms limit. ${hint}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
var loadFflate = createLazyModuleLoader(
|
|
266
|
+
async () => await import("fflate"),
|
|
267
|
+
"office-file reading disabled (fflate unavailable)"
|
|
268
|
+
);
|
|
269
|
+
function accessFailureMessage(err, filePath) {
|
|
270
|
+
const code = err?.code;
|
|
271
|
+
if (code === "ENOENT") return `File not found: ${filePath}`;
|
|
272
|
+
return `could not read ${filePath} (${code ?? "unknown error"})`;
|
|
273
|
+
}
|
|
274
|
+
async function readOoxmlZip(filePath, kind) {
|
|
275
|
+
const fflate = await loadFflate();
|
|
276
|
+
if (!fflate) throw new Error("fflate is not installed; run `npm install fflate` to enable this command");
|
|
277
|
+
let stat;
|
|
278
|
+
try {
|
|
279
|
+
stat = fs.statSync(filePath);
|
|
280
|
+
} catch (err) {
|
|
281
|
+
throw new Error(accessFailureMessage(err, filePath), { cause: err });
|
|
282
|
+
}
|
|
283
|
+
if (!stat.isFile()) throw new NotAnOfficeDocumentError(`not a valid ${kind} file: ${filePath}`);
|
|
284
|
+
if (stat.size > MAX_ZIP_INPUT_BYTES) throw new ZipInputTooLargeError(filePath, stat.size, MAX_ZIP_INPUT_BYTES);
|
|
285
|
+
let data;
|
|
286
|
+
try {
|
|
287
|
+
data = fs.readFileSync(filePath);
|
|
288
|
+
} catch (err) {
|
|
289
|
+
throw new Error(accessFailureMessage(err, filePath), { cause: err });
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
return unzipBounded(fflate, new Uint8Array(data), { limitBytes: MAX_ZIP_OUTPUT_BYTES, shouldExtract: () => true });
|
|
293
|
+
} catch (err) {
|
|
294
|
+
if (err instanceof ZipOutputTooLargeError) throw err;
|
|
295
|
+
throw new NotAnOfficeDocumentError(`not a valid ${kind} file: ${filePath}`, err);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
var MAX_OOXML_PART_BYTES = 32 * 1024 * 1024;
|
|
299
|
+
var OoxmlPartTooLargeError = class extends DocumentRefusedError {
|
|
300
|
+
constructor(entryPath, bytes) {
|
|
301
|
+
super(`${entryPath} is ${bytes} bytes, past the ${MAX_OOXML_PART_BYTES}-byte limit for one part of an office file. Split the document, or extract from a smaller copy.`, "OoxmlPartTooLargeError");
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
var MAX_OOXML_DOCUMENT_PART_BYTES = 64 * 1024 * 1024;
|
|
305
|
+
var OoxmlDocumentTooLargeError = class extends DocumentRefusedError {
|
|
306
|
+
constructor(entryPath, spentBytes, partBytes) {
|
|
307
|
+
super(`decoding ${entryPath} (${partBytes} bytes, after ${spentBytes} already decoded) would take this office file past the ${MAX_OOXML_DOCUMENT_PART_BYTES}-byte limit on the XML one document may have decoded at once. Split the document, or extract from a smaller copy.`, "OoxmlDocumentTooLargeError");
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
function ooxmlPartBudget() {
|
|
311
|
+
return { spent: 0 };
|
|
312
|
+
}
|
|
313
|
+
function decodeZipEntry(entries, entryPath, budget) {
|
|
314
|
+
const bytes = entries[entryPath];
|
|
315
|
+
if (bytes === void 0) return null;
|
|
316
|
+
if (bytes.length > MAX_OOXML_PART_BYTES) throw new OoxmlPartTooLargeError(entryPath, bytes.length);
|
|
317
|
+
if (budget.spent + bytes.length > MAX_OOXML_DOCUMENT_PART_BYTES) throw new OoxmlDocumentTooLargeError(entryPath, budget.spent, bytes.length);
|
|
318
|
+
budget.spent += bytes.length;
|
|
319
|
+
return new TextDecoder("utf-8").decode(bytes);
|
|
320
|
+
}
|
|
321
|
+
async function parseOoxmlPart(xmlText) {
|
|
322
|
+
return parseXml(xmlText);
|
|
323
|
+
}
|
|
324
|
+
function pushTextValue(runs, val) {
|
|
325
|
+
if (Array.isArray(val)) {
|
|
326
|
+
for (const v of val) pushTextValue(runs, v);
|
|
327
|
+
} else if (typeof val === "string") {
|
|
328
|
+
runs.push(val);
|
|
329
|
+
} else if (typeof val === "number" || typeof val === "boolean") {
|
|
330
|
+
runs.push(String(val));
|
|
331
|
+
} else if (val !== null && typeof val === "object" && "#text" in val) {
|
|
332
|
+
runs.push(String(val["#text"]));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function collectTextRuns(node, tag, skipInside = []) {
|
|
336
|
+
const runs = [];
|
|
337
|
+
function walk(n) {
|
|
338
|
+
if (Array.isArray(n)) {
|
|
339
|
+
n.forEach(walk);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (n !== null && typeof n === "object") {
|
|
343
|
+
const obj = n;
|
|
344
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
345
|
+
if (skipInside.includes(key)) continue;
|
|
346
|
+
if (key === tag) {
|
|
347
|
+
pushTextValue(runs, val);
|
|
348
|
+
} else if (val !== null && typeof val === "object") {
|
|
349
|
+
walk(val);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
walk(node);
|
|
355
|
+
return runs;
|
|
356
|
+
}
|
|
357
|
+
function collectElements(node, tag, opts = {}) {
|
|
358
|
+
const skip = opts.skipInside;
|
|
359
|
+
const out = [];
|
|
360
|
+
function walk(n) {
|
|
361
|
+
if (Array.isArray(n)) {
|
|
362
|
+
n.forEach(walk);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (n !== null && typeof n === "object") {
|
|
366
|
+
const obj = n;
|
|
367
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
368
|
+
if (skip !== void 0 && skip.includes(key)) continue;
|
|
369
|
+
if (key === tag) {
|
|
370
|
+
if (opts.includeNested !== true) {
|
|
371
|
+
if (Array.isArray(val)) pushAll(out, val);
|
|
372
|
+
else out.push(val);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
for (const item of Array.isArray(val) ? val : [val]) {
|
|
376
|
+
out.push(item);
|
|
377
|
+
if (item !== null && typeof item === "object") walk(item);
|
|
378
|
+
}
|
|
379
|
+
} else if (val !== null && typeof val === "object") {
|
|
380
|
+
walk(val);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
walk(node);
|
|
386
|
+
return out;
|
|
387
|
+
}
|
|
388
|
+
function collectParagraphTexts(node, paragraphTag, runTag, skipInside = [], breakTag) {
|
|
389
|
+
const paragraphs = collectElements(node, paragraphTag, { skipInside });
|
|
390
|
+
if (paragraphs.length === 0) {
|
|
391
|
+
const whole = joinParagraphRuns(node, runTag, skipInside, breakTag);
|
|
392
|
+
return whole.length > 0 ? [whole] : [];
|
|
393
|
+
}
|
|
394
|
+
return paragraphs.map((p) => joinParagraphRuns(p, runTag, skipInside, breakTag));
|
|
395
|
+
}
|
|
396
|
+
function joinParagraphRuns(node, runTag, skipInside, breakTag) {
|
|
397
|
+
const runs = collectTextRuns(node, runTag, skipInside);
|
|
398
|
+
const broken = breakTag !== void 0 && collectElements(node, breakTag, { skipInside }).length > 0;
|
|
399
|
+
return runs.join(broken ? " " : "");
|
|
400
|
+
}
|
|
401
|
+
function sortNumberedParts(paths, pattern) {
|
|
402
|
+
return paths.map((p) => {
|
|
403
|
+
const m = pattern.exec(p);
|
|
404
|
+
return { p, n: m?.[1] !== void 0 ? parseInt(m[1], 10) : Number.MAX_SAFE_INTEGER };
|
|
405
|
+
}).sort((a, b) => a.n - b.n).map((x) => x.p);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export {
|
|
409
|
+
NotAnOfficeDocumentError,
|
|
410
|
+
ooxmlWorkDeadline,
|
|
411
|
+
assertOoxmlWithinDeadline,
|
|
412
|
+
readOoxmlZip,
|
|
413
|
+
ooxmlPartBudget,
|
|
414
|
+
decodeZipEntry,
|
|
415
|
+
parseOoxmlPart,
|
|
416
|
+
collectTextRuns,
|
|
417
|
+
collectElements,
|
|
418
|
+
collectParagraphTexts,
|
|
419
|
+
sortNumberedParts
|
|
420
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CliError,
|
|
5
|
+
_applyFiltersAndPrint,
|
|
6
|
+
applyExitOverride,
|
|
7
|
+
buildProgram,
|
|
8
|
+
cmdCsvProfile,
|
|
9
|
+
cmdCsvQuery,
|
|
10
|
+
cmdDocxOutline,
|
|
11
|
+
cmdDocxTables,
|
|
12
|
+
cmdDocxText,
|
|
13
|
+
cmdHtmlLint,
|
|
14
|
+
cmdHtmlOutline,
|
|
15
|
+
cmdHtmlQuery,
|
|
16
|
+
cmdImageMeta,
|
|
17
|
+
cmdImageText,
|
|
18
|
+
cmdIndex,
|
|
19
|
+
cmdInsertSection,
|
|
20
|
+
cmdJsonOutline,
|
|
21
|
+
cmdJsonQuery,
|
|
22
|
+
cmdNoteAdd,
|
|
23
|
+
cmdOpenApiOp,
|
|
24
|
+
cmdOpenApiOutline,
|
|
25
|
+
cmdPdfExtract,
|
|
26
|
+
cmdPdfLocate,
|
|
27
|
+
cmdPdfMeta,
|
|
28
|
+
cmdPdfOutline,
|
|
29
|
+
cmdPptxNotes,
|
|
30
|
+
cmdPptxOutline,
|
|
31
|
+
cmdPptxSlide,
|
|
32
|
+
cmdPptxText,
|
|
33
|
+
cmdReplace,
|
|
34
|
+
cmdSharepointResolve,
|
|
35
|
+
cmdSkillBody,
|
|
36
|
+
cmdSkillCompact,
|
|
37
|
+
cmdSkillDiff,
|
|
38
|
+
cmdSkillHistory,
|
|
39
|
+
cmdSkillList,
|
|
40
|
+
cmdSkillSection,
|
|
41
|
+
cmdSkillSize,
|
|
42
|
+
cmdSqliteQuery,
|
|
43
|
+
cmdSqliteSchema,
|
|
44
|
+
cmdSqliteTables,
|
|
45
|
+
cmdTranscript,
|
|
46
|
+
cmdTranscriptOutline,
|
|
47
|
+
cmdVideoChapters,
|
|
48
|
+
cmdWriteFile,
|
|
49
|
+
cmdXlsxColumns,
|
|
50
|
+
cmdXlsxHead,
|
|
51
|
+
cmdXlsxQuery,
|
|
52
|
+
cmdXlsxRange,
|
|
53
|
+
cmdXlsxSheets,
|
|
54
|
+
cmdXmlOutline,
|
|
55
|
+
cmdXmlQuery,
|
|
56
|
+
cmdYamlOutline,
|
|
57
|
+
cmdYamlQuery,
|
|
58
|
+
cmdZipList,
|
|
59
|
+
cmdZipRead,
|
|
60
|
+
err,
|
|
61
|
+
expandGlobs,
|
|
62
|
+
fenceFileFieldIfMatched,
|
|
63
|
+
fenceFileText,
|
|
64
|
+
fenceOcrText,
|
|
65
|
+
fileSizeOrZero,
|
|
66
|
+
leftoverIntegrations,
|
|
67
|
+
out,
|
|
68
|
+
requireInt,
|
|
69
|
+
requireNonNegativeInt,
|
|
70
|
+
requirePositiveInt,
|
|
71
|
+
run,
|
|
72
|
+
visualStudioManualSteps
|
|
73
|
+
} from "./token-goat-chunk-GMQQA7E4.mjs";
|
|
74
|
+
import "./token-goat-chunk-LCZBPOIN.mjs";
|
|
75
|
+
import "./token-goat-chunk-LMFO66YD.mjs";
|
|
76
|
+
import {
|
|
77
|
+
cmdDescribe,
|
|
78
|
+
cmdSessionSchema
|
|
79
|
+
} from "./token-goat-chunk-OUGNPMDA.mjs";
|
|
80
|
+
import "./token-goat-chunk-BL5LNGBG.mjs";
|
|
81
|
+
import "./token-goat-chunk-YQ7WI2CO.mjs";
|
|
82
|
+
import "./token-goat-chunk-NEI4NC54.mjs";
|
|
83
|
+
import "./token-goat-chunk-5V7DAC7V.mjs";
|
|
84
|
+
import "./token-goat-chunk-ASYEPR3S.mjs";
|
|
85
|
+
import "./token-goat-chunk-NU7TLMQK.mjs";
|
|
86
|
+
import "./token-goat-chunk-YKG35VHC.mjs";
|
|
87
|
+
import "./token-goat-chunk-3BTK54F3.mjs";
|
|
88
|
+
import "./token-goat-chunk-MZDIJJ3R.mjs";
|
|
89
|
+
import "./token-goat-chunk-XTQAOTSO.mjs";
|
|
90
|
+
import "./token-goat-chunk-AH6QILZM.mjs";
|
|
91
|
+
import "./token-goat-chunk-XEPXYDPI.mjs";
|
|
92
|
+
import "./token-goat-chunk-NDRP4KJQ.mjs";
|
|
93
|
+
import "./token-goat-chunk-2X2EBBC6.mjs";
|
|
94
|
+
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
95
|
+
import "./token-goat-chunk-SFAS46RE.mjs";
|
|
96
|
+
import "./token-goat-chunk-IVUQLQWN.mjs";
|
|
97
|
+
import "./token-goat-chunk-K7F2BFIK.mjs";
|
|
98
|
+
import "./token-goat-chunk-S4XRY446.mjs";
|
|
99
|
+
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
100
|
+
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
101
|
+
import "./token-goat-chunk-PM76YS22.mjs";
|
|
102
|
+
import "./token-goat-chunk-ERTXEKB6.mjs";
|
|
103
|
+
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
104
|
+
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
105
|
+
export {
|
|
106
|
+
CliError,
|
|
107
|
+
_applyFiltersAndPrint,
|
|
108
|
+
applyExitOverride,
|
|
109
|
+
buildProgram,
|
|
110
|
+
cmdCsvProfile,
|
|
111
|
+
cmdCsvQuery,
|
|
112
|
+
cmdDescribe,
|
|
113
|
+
cmdDocxOutline,
|
|
114
|
+
cmdDocxTables,
|
|
115
|
+
cmdDocxText,
|
|
116
|
+
cmdHtmlLint,
|
|
117
|
+
cmdHtmlOutline,
|
|
118
|
+
cmdHtmlQuery,
|
|
119
|
+
cmdImageMeta,
|
|
120
|
+
cmdImageText,
|
|
121
|
+
cmdIndex,
|
|
122
|
+
cmdInsertSection,
|
|
123
|
+
cmdJsonOutline,
|
|
124
|
+
cmdJsonQuery,
|
|
125
|
+
cmdNoteAdd,
|
|
126
|
+
cmdOpenApiOp,
|
|
127
|
+
cmdOpenApiOutline,
|
|
128
|
+
cmdPdfExtract,
|
|
129
|
+
cmdPdfLocate,
|
|
130
|
+
cmdPdfMeta,
|
|
131
|
+
cmdPdfOutline,
|
|
132
|
+
cmdPptxNotes,
|
|
133
|
+
cmdPptxOutline,
|
|
134
|
+
cmdPptxSlide,
|
|
135
|
+
cmdPptxText,
|
|
136
|
+
cmdReplace,
|
|
137
|
+
cmdSessionSchema,
|
|
138
|
+
cmdSharepointResolve,
|
|
139
|
+
cmdSkillBody,
|
|
140
|
+
cmdSkillCompact,
|
|
141
|
+
cmdSkillDiff,
|
|
142
|
+
cmdSkillHistory,
|
|
143
|
+
cmdSkillList,
|
|
144
|
+
cmdSkillSection,
|
|
145
|
+
cmdSkillSize,
|
|
146
|
+
cmdSqliteQuery,
|
|
147
|
+
cmdSqliteSchema,
|
|
148
|
+
cmdSqliteTables,
|
|
149
|
+
cmdTranscript,
|
|
150
|
+
cmdTranscriptOutline,
|
|
151
|
+
cmdVideoChapters,
|
|
152
|
+
cmdWriteFile,
|
|
153
|
+
cmdXlsxColumns,
|
|
154
|
+
cmdXlsxHead,
|
|
155
|
+
cmdXlsxQuery,
|
|
156
|
+
cmdXlsxRange,
|
|
157
|
+
cmdXlsxSheets,
|
|
158
|
+
cmdXmlOutline,
|
|
159
|
+
cmdXmlQuery,
|
|
160
|
+
cmdYamlOutline,
|
|
161
|
+
cmdYamlQuery,
|
|
162
|
+
cmdZipList,
|
|
163
|
+
cmdZipRead,
|
|
164
|
+
err,
|
|
165
|
+
expandGlobs,
|
|
166
|
+
fenceFileFieldIfMatched,
|
|
167
|
+
fenceFileText,
|
|
168
|
+
fenceOcrText,
|
|
169
|
+
fileSizeOrZero,
|
|
170
|
+
leftoverIntegrations,
|
|
171
|
+
out,
|
|
172
|
+
requireInt,
|
|
173
|
+
requireNonNegativeInt,
|
|
174
|
+
requirePositiveInt,
|
|
175
|
+
run,
|
|
176
|
+
visualStudioManualSteps
|
|
177
|
+
};
|