@poe-platform/safe-bash 0.1.745 → 0.1.747
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 +5 -1
- package/dist/image-ast/browser/sharp.d.ts +1 -1
- package/dist/image-ast/index.js +133 -35
- package/dist/image-ast/sharp.d.ts +1 -1
- package/dist/safe-bash/chunks/{chunk-2F7Q532M.js → chunk-4GK4FAT6.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-EAUCLWEZ.js → chunk-55AGFLG5.js} +540 -284
- package/dist/safe-bash/chunks/{chunk-WCNFCN2G.js → chunk-BS6QFRNX.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-IZZ7KX4E.js → chunk-JCXAGOEK.js} +40 -3
- package/dist/safe-bash/chunks/{chunk-I3DOFJSJ.js → chunk-MUWJPSGN.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-7RP6WOWK.js → chunk-OF2PDE3W.js} +2 -2
- package/dist/safe-bash/chunks/{src-FTMTU65U.js → src-T672TQJC.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-DRCPJVZF.js → chunk-44N2IRVP.js} +17 -5
- package/dist/safe-bash/command-chunks/{chunk-LYKC7WJB.js → chunk-6742OVAC.js} +37 -3
- package/dist/safe-bash/command-chunks/{chunk-BMBXSLVX.js → chunk-6QU5OLPJ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-YHANNN7I.js → chunk-S3BO2NJT.js} +7 -0
- package/dist/safe-bash/commands/basic.d.ts +2 -0
- package/dist/safe-bash/commands/basic.js +236 -9
- package/dist/safe-bash/commands/pr/index.browser.js +1 -1
- package/dist/safe-bash/commands/streams.js +9 -56
- package/dist/safe-bash/commands/table-text/index.js +5 -1
- package/dist/safe-bash/commands/text.js +13 -2
- package/dist/safe-bash/commands/time-env/shared.js +2 -2
- package/dist/safe-bash/commands/time-env/sleep.js +6 -4
- package/dist/safe-bash/commands/timeout/index.d.ts +7 -0
- package/dist/safe-bash/commands/timeout/index.js +52 -32
- package/dist/safe-bash/commands/timeout/scheduler.js +7 -6
- package/dist/safe-bash/core.browser.js +2698 -543
- package/dist/safe-bash/opt-in/commands/shuf/random.js +2 -3
- package/dist/safe-bash/opt-in/shell/extensions/read/index.js +1 -1
- package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +1 -2
- package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +1 -8
- package/dist/safe-bash/playwright/adapter.d.ts +2 -0
- package/dist/safe-bash/playwright/private-target-transport.d.ts +1 -0
- package/dist/safe-bash/playwright/private-target-transport.js +21 -21
- package/dist/safe-bash/shell/runtime.d.ts +20 -1
- package/dist/safe-bash/shell/runtime.js +3021 -532
- package/dist/safe-bash/shell/sync-jq-expression.d.ts +6 -0
- package/dist/safe-bash/shell/sync-jq-expression.js +46 -0
- package/dist/safe-bash-command-cal/index.js +32 -12
- package/dist/safe-bash-command-hostname/index.js +22 -7
- package/dist/safe-bash-command-id/index.js +28 -9
- package/dist/safe-bash-command-pandoc/command.js +1 -1
- package/dist/safe-bash-command-pandoc/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/command.d.ts +2 -2
- package/dist/safe-bash-command-ssconvert/contracts.d.ts +4 -0
- package/dist/safe-bash-command-ssconvert/engine.d.ts +2 -2
- package/dist/safe-bash-command-ssconvert/index.js +524 -276
- package/dist/safe-bash-command-whoami/index.js +26 -12
- package/dist/safe-bash-query-engine/index.js +3 -3
- package/dist/safe-bash-query-engine/interpreter.js +1 -1
- package/dist/safe-bash-query-engine/parser.js +1 -1
- package/dist/safe-bash-query-engine/query-core.js +3 -3
- package/dist/safe-playwright-cloudflare/browser-private-transport.js +8 -13
- package/dist/safe-playwright-cloudflare/browser-storage-control.js +13 -4
- package/dist/safe-playwright-cloudflare/browser-trace-archive.js +1 -1
- package/package.json +18 -14
- package/dist/image-ast/streams/node.d.ts +0 -10
- package/dist/image-ast/streams/node.js +0 -5
- package/dist/image-ast/streams/web.js +0 -94
|
@@ -27222,9 +27222,9 @@ function parseExpression(source, options) {
|
|
|
27222
27222
|
}
|
|
27223
27223
|
let sheetRelative;
|
|
27224
27224
|
const readSheet = () => {
|
|
27225
|
+
if (grammar3.bracketReferences && grammar3.absoluteSheetReferences) sheetRelative = source[offset] !== "$";
|
|
27226
|
+
if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
|
|
27225
27227
|
if (grammar3.bracketReferences) {
|
|
27226
|
-
if (grammar3.absoluteSheetReferences) sheetRelative = source[offset] !== "$";
|
|
27227
|
-
if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
|
|
27228
27228
|
if (source[offset] === "'") return quoted("'", grammar3.stringEscape);
|
|
27229
27229
|
const begin2 = offset;
|
|
27230
27230
|
while (offset < source.length && source[offset] !== grammar3.sheetSeparator && !" []:' \r\n".includes(source[offset])) offset++;
|
|
@@ -27232,7 +27232,6 @@ function parseExpression(source, options) {
|
|
|
27232
27232
|
}
|
|
27233
27233
|
if (grammar3.unquotedSheets) {
|
|
27234
27234
|
const begin2 = offset;
|
|
27235
|
-
if (grammar3.absoluteSheetReferences && source[offset] === "$") offset++;
|
|
27236
27235
|
while (letter(source[offset]) || digit(source[offset])) offset++;
|
|
27237
27236
|
return source.slice(begin2, offset);
|
|
27238
27237
|
}
|
|
@@ -27256,7 +27255,6 @@ function parseExpression(source, options) {
|
|
|
27256
27255
|
return {};
|
|
27257
27256
|
}
|
|
27258
27257
|
offset++;
|
|
27259
|
-
if (grammar3.absoluteSheetReferences && !grammar3.bracketReferences && sheet.startsWith("$")) sheet = sheet.slice(1);
|
|
27260
27258
|
if (sheet.startsWith("[")) {
|
|
27261
27259
|
const close = sheet.indexOf("]");
|
|
27262
27260
|
if (close >= 0) {
|
|
@@ -29124,6 +29122,383 @@ var chartDataTypes = Object.freeze(Object.fromEntries(Object.entries({
|
|
|
29124
29122
|
GODataMatrixVal: { storage: "literal", dimensions: 2 }
|
|
29125
29123
|
}).map(([name5, descriptor3]) => [name5, Object.freeze(descriptor3)])));
|
|
29126
29124
|
|
|
29125
|
+
// packages/safe-bash-command-ssconvert/src/workbook/hyperlinks.ts
|
|
29126
|
+
init_platform();
|
|
29127
|
+
|
|
29128
|
+
// packages/safe-bash-command-ssconvert/src/codecs/odf-write-support.ts
|
|
29129
|
+
init_platform();
|
|
29130
|
+
import { parseXmlSteps } from "@poe-platform/safe-fs/core";
|
|
29131
|
+
var urn = "urn:oasis:names:tc:opendocument:xmlns:";
|
|
29132
|
+
var odfEncryptionNamespace = "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0";
|
|
29133
|
+
var odfNamespaces = {
|
|
29134
|
+
xml: "http://www.w3.org/XML/1998/namespace",
|
|
29135
|
+
office: urn + "office:1.0",
|
|
29136
|
+
style: urn + "style:1.0",
|
|
29137
|
+
text: urn + "text:1.0",
|
|
29138
|
+
table: urn + "table:1.0",
|
|
29139
|
+
draw: urn + "drawing:1.0",
|
|
29140
|
+
fo: urn + "xsl-fo-compatible:1.0",
|
|
29141
|
+
xlink: "http://www.w3.org/1999/xlink",
|
|
29142
|
+
dc: "http://purl.org/dc/elements/1.1/",
|
|
29143
|
+
meta: urn + "meta:1.0",
|
|
29144
|
+
number: urn + "datastyle:1.0",
|
|
29145
|
+
svg: urn + "svg-compatible:1.0",
|
|
29146
|
+
chart: urn + "chart:1.0",
|
|
29147
|
+
config: urn + "config:1.0",
|
|
29148
|
+
form: urn + "form:1.0",
|
|
29149
|
+
script: urn + "script:1.0",
|
|
29150
|
+
of: urn + "of:1.2",
|
|
29151
|
+
manifest: urn + "manifest:1.0",
|
|
29152
|
+
gnm: "http://www.gnumeric.org/odf-extension/1.0",
|
|
29153
|
+
calcext: "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
|
|
29154
|
+
};
|
|
29155
|
+
function odfObject(value3) {
|
|
29156
|
+
return value3 !== null && typeof value3 === "object" && !Array.isArray(value3) ? value3 : void 0;
|
|
29157
|
+
}
|
|
29158
|
+
function odfAttributes(value3, namespace5) {
|
|
29159
|
+
const source = odfObject(value3)?.attributes;
|
|
29160
|
+
if (Array.isArray(source)) return Object.fromEntries(source.flatMap((a3) => {
|
|
29161
|
+
const v2 = odfObject(a3);
|
|
29162
|
+
return typeof v2?.name === "string" && typeof v2.value === "string" && (namespace5 === void 0 || v2.namespace === namespace5) ? [[v2.name, v2.value]] : [];
|
|
29163
|
+
}));
|
|
29164
|
+
if (namespace5 !== void 0) return {};
|
|
29165
|
+
return Object.fromEntries(Object.entries(odfObject(source) ?? {}).filter((entry2) => typeof entry2[1] === "string"));
|
|
29166
|
+
}
|
|
29167
|
+
function odfChildren(value3) {
|
|
29168
|
+
const source = odfObject(value3)?.children;
|
|
29169
|
+
return Array.isArray(source) ? source : [];
|
|
29170
|
+
}
|
|
29171
|
+
function createOdfXml(context2, extended) {
|
|
29172
|
+
let work = 0, nodes = 0;
|
|
29173
|
+
const encoder2 = new TextEncoder(), names2 = /* @__PURE__ */ new Set();
|
|
29174
|
+
const declarations = {
|
|
29175
|
+
...Object.fromEntries(Object.entries(odfNamespaces).map(([prefix2, uri]) => ["xmlns:" + prefix2, uri])),
|
|
29176
|
+
"xmlns:loext": odfEncryptionNamespace
|
|
29177
|
+
};
|
|
29178
|
+
function charge(amount = 1) {
|
|
29179
|
+
context2.signal.throwIfAborted();
|
|
29180
|
+
if (!Number.isSafeInteger(amount) || amount < 0 || amount > (context2.limits.workbookWork ?? Infinity) - work)
|
|
29181
|
+
throw new SsconvertError("resource-limit", "ssconvert OpenDocument work limit exceeded");
|
|
29182
|
+
work += amount;
|
|
29183
|
+
}
|
|
29184
|
+
function name5(value3) {
|
|
29185
|
+
charge(value3.length);
|
|
29186
|
+
if (names2.has(value3)) return;
|
|
29187
|
+
try {
|
|
29188
|
+
const parser = parseXmlSteps(`<${value3} ${Object.entries(declarations).map(([k, v2]) => `${k}="${v2}"`).join(" ")}/>`, { maxNodes: 1, maxAttributes: 100 });
|
|
29189
|
+
let step = parser.next();
|
|
29190
|
+
while (!step.done) step = parser.next();
|
|
29191
|
+
if (step.value.name !== value3 || step.value.children.length) throw new Error("name");
|
|
29192
|
+
} catch {
|
|
29193
|
+
throw new SsconvertError("invalid-request", "Invalid OpenDocument XML name");
|
|
29194
|
+
}
|
|
29195
|
+
names2.add(value3);
|
|
29196
|
+
}
|
|
29197
|
+
function escape3(value3) {
|
|
29198
|
+
charge(value3.length);
|
|
29199
|
+
let result2 = "";
|
|
29200
|
+
for (const c4 of value3) {
|
|
29201
|
+
const code2 = c4.codePointAt(0);
|
|
29202
|
+
if (code2 < 32 && !" \n\r".includes(c4) || code2 === 65534 || code2 === 65535 || code2 >= 55296 && code2 <= 57343)
|
|
29203
|
+
throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: non-XML OpenDocument character");
|
|
29204
|
+
result2 += c4 === "&" ? "&" : c4 === "<" ? "<" : c4 === ">" ? ">" : c4 === '"' ? """ : c4 === "\r" ? " " : c4 === "\n" ? " " : c4 === " " ? "	" : c4;
|
|
29205
|
+
}
|
|
29206
|
+
return result2;
|
|
29207
|
+
}
|
|
29208
|
+
function element2(tag3, attributes4 = {}, content2 = "") {
|
|
29209
|
+
charge();
|
|
29210
|
+
if (++nodes > (context2.limits.workbookNodes ?? Infinity))
|
|
29211
|
+
throw new SsconvertError("resource-limit", "ssconvert OpenDocument XML nodes limit exceeded");
|
|
29212
|
+
name5(tag3);
|
|
29213
|
+
let result2 = "<" + tag3;
|
|
29214
|
+
for (const [key2, value3] of Object.entries(attributes4)) if (value3 !== void 0) {
|
|
29215
|
+
if (!key2.startsWith("xmlns:")) name5(key2);
|
|
29216
|
+
result2 += ` ${key2}="${escape3(String(value3))}"`;
|
|
29217
|
+
}
|
|
29218
|
+
result2 += content2 ? ">" + content2 + "</" + tag3 + ">" : "/>";
|
|
29219
|
+
if (result2.length > context2.limits.outputBytes || encoder2.encode(result2).length > context2.limits.outputBytes)
|
|
29220
|
+
throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
|
|
29221
|
+
return result2;
|
|
29222
|
+
}
|
|
29223
|
+
function text2(value3) {
|
|
29224
|
+
charge(value3.length);
|
|
29225
|
+
let result2 = "", plain = "";
|
|
29226
|
+
function flush() {
|
|
29227
|
+
result2 += escape3(plain);
|
|
29228
|
+
plain = "";
|
|
29229
|
+
}
|
|
29230
|
+
for (let i4 = 0; i4 < value3.length; i4++) {
|
|
29231
|
+
const c4 = value3[i4];
|
|
29232
|
+
if (c4 === " ") {
|
|
29233
|
+
flush();
|
|
29234
|
+
let count = 1;
|
|
29235
|
+
while (value3[i4 + 1] === " ") {
|
|
29236
|
+
i4++;
|
|
29237
|
+
count++;
|
|
29238
|
+
}
|
|
29239
|
+
result2 += element2("text:s", count > 1 ? { "text:c": count } : {});
|
|
29240
|
+
} else if (c4 === " " || c4 === "\n") {
|
|
29241
|
+
flush();
|
|
29242
|
+
result2 += element2(c4 === " " ? "text:tab" : "text:line-break");
|
|
29243
|
+
} else plain += c4;
|
|
29244
|
+
}
|
|
29245
|
+
flush();
|
|
29246
|
+
return result2;
|
|
29247
|
+
}
|
|
29248
|
+
const active = /* @__PURE__ */ new Set();
|
|
29249
|
+
function retained2(value3, depth = 0, hyperlink, hyperlinkContent = false) {
|
|
29250
|
+
charge();
|
|
29251
|
+
const v2 = odfObject(value3);
|
|
29252
|
+
if (!v2 || typeof v2.name !== "string" || typeof v2.namespace !== "string") return "";
|
|
29253
|
+
if (depth > (context2.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert OpenDocument metadata depth limit exceeded");
|
|
29254
|
+
if (active.has(v2)) throw new SsconvertError("invalid-request", "Invalid cyclic OpenDocument metadata");
|
|
29255
|
+
const prefix2 = Object.entries(odfNamespaces).find(([, uri]) => uri === v2.namespace)?.[0];
|
|
29256
|
+
if (!prefix2 || !extended && ["gnm", "calcext"].includes(prefix2)) return "";
|
|
29257
|
+
active.add(v2);
|
|
29258
|
+
try {
|
|
29259
|
+
const attributes4 = {};
|
|
29260
|
+
if (Array.isArray(v2.attributes)) for (const a3 of v2.attributes) {
|
|
29261
|
+
charge();
|
|
29262
|
+
const attribute5 = odfObject(a3);
|
|
29263
|
+
if (typeof attribute5?.name !== "string" || typeof attribute5.value !== "string" || typeof attribute5.namespace !== "string") continue;
|
|
29264
|
+
const p2 = Object.entries(odfNamespaces).find(([, uri]) => uri === attribute5.namespace)?.[0];
|
|
29265
|
+
if (attribute5.namespace && (!p2 || !extended && ["gnm", "calcext"].includes(p2))) continue;
|
|
29266
|
+
attributes4[(p2 ? p2 + ":" : "") + attribute5.name] = attribute5.value;
|
|
29267
|
+
}
|
|
29268
|
+
if (prefix2 === "text" && v2.name === "a" && attributes4["xlink:href"] !== void 0 && hyperlink)
|
|
29269
|
+
attributes4["xlink:href"] = hyperlink(attributes4["xlink:href"]);
|
|
29270
|
+
const children7 = odfChildren(v2);
|
|
29271
|
+
const childHyperlinkContent = Boolean(hyperlink) && prefix2 === "text" && v2.name === "a" && attributes4["xlink:href"] !== void 0;
|
|
29272
|
+
const content2 = Array.isArray(v2.content) ? v2.content.map((c4) => {
|
|
29273
|
+
charge();
|
|
29274
|
+
const item = odfObject(c4);
|
|
29275
|
+
if (item?.kind === "text" && typeof item.text === "string") return escape3(item.text);
|
|
29276
|
+
if (item?.kind !== "element") return "";
|
|
29277
|
+
if (item.index === void 0) return retained2(item.value, depth + 1, hyperlink, childHyperlinkContent);
|
|
29278
|
+
if (typeof item.index !== "number" || !Number.isSafeInteger(item.index) || item.index < 0 || item.index >= children7.length)
|
|
29279
|
+
throw new SsconvertError("invalid-request", "Invalid OpenDocument metadata child index");
|
|
29280
|
+
return retained2(children7[item.index], depth + 1, hyperlink, childHyperlinkContent);
|
|
29281
|
+
}).join("") : (typeof v2.text === "string" ? escape3(v2.text) : "") + children7.map((c4) => retained2(c4, depth + 1, hyperlink, childHyperlinkContent)).join("");
|
|
29282
|
+
if (hyperlinkContent && prefix2 === "text" && !content2 && !children7.length) {
|
|
29283
|
+
if (v2.name === "s" && Object.keys(attributes4).every((key2) => key2 === "text:c")) {
|
|
29284
|
+
const count = Number(attributes4["text:c"] ?? "1");
|
|
29285
|
+
if (!Number.isSafeInteger(count) || count < 0) throw new SsconvertError("invalid-request", "Invalid OpenDocument whitespace count");
|
|
29286
|
+
if (count > context2.limits.outputBytes) throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
|
|
29287
|
+
charge(count);
|
|
29288
|
+
return " ".repeat(count);
|
|
29289
|
+
}
|
|
29290
|
+
if (!Object.keys(attributes4).length && (v2.name === "tab" || v2.name === "line-break"))
|
|
29291
|
+
return escape3(v2.name === "tab" ? " " : "\n");
|
|
29292
|
+
}
|
|
29293
|
+
return element2(prefix2 + ":" + v2.name, attributes4, content2);
|
|
29294
|
+
} finally {
|
|
29295
|
+
active.delete(v2);
|
|
29296
|
+
}
|
|
29297
|
+
}
|
|
29298
|
+
function document6(tag3, body) {
|
|
29299
|
+
return '<?xml version="1.0" encoding="UTF-8"?>\n' + element2(tag3, { ...declarations, "xmlns:loext": void 0, "office:version": "1.2" }, body);
|
|
29300
|
+
}
|
|
29301
|
+
return { element: element2, escape: escape3, text: text2, retained: retained2, document: document6, charge };
|
|
29302
|
+
}
|
|
29303
|
+
|
|
29304
|
+
// packages/safe-bash-command-ssconvert/src/codecs/odf-hyperlinks.ts
|
|
29305
|
+
init_platform();
|
|
29306
|
+
var linkGrammar = { ...excelGrammar, id: "odf-hyperlink", sheetSeparator: ".", absoluteSheetReferences: true };
|
|
29307
|
+
function decodeFragment(source, charge) {
|
|
29308
|
+
let result2 = "";
|
|
29309
|
+
for (let at = 0; at < source.length; ) {
|
|
29310
|
+
charge();
|
|
29311
|
+
const high = "0123456789abcdef".indexOf(source[at + 1]?.toLowerCase() ?? " ");
|
|
29312
|
+
const low = "0123456789abcdef".indexOf(source[at + 2]?.toLowerCase() ?? " ");
|
|
29313
|
+
if (source[at] !== "%" || high < 0 || low < 0) {
|
|
29314
|
+
result2 += source[at++];
|
|
29315
|
+
continue;
|
|
29316
|
+
}
|
|
29317
|
+
const octet = high * 16 + low;
|
|
29318
|
+
const length = octet >= 192 && octet <= 223 ? 6 : octet >= 224 && octet <= 239 ? 9 : octet >= 240 && octet <= 244 ? 12 : 3;
|
|
29319
|
+
const encoded2 = source.slice(at, at + length);
|
|
29320
|
+
try {
|
|
29321
|
+
result2 += decodeURIComponent(encoded2);
|
|
29322
|
+
at += length;
|
|
29323
|
+
} catch {
|
|
29324
|
+
result2 += source.slice(at, at + 3).toUpperCase();
|
|
29325
|
+
at += 3;
|
|
29326
|
+
}
|
|
29327
|
+
}
|
|
29328
|
+
return result2;
|
|
29329
|
+
}
|
|
29330
|
+
function encodeFragment(source) {
|
|
29331
|
+
return "#" + encodeURI(source).split("#").join("%23").split("?").join("%3F");
|
|
29332
|
+
}
|
|
29333
|
+
function translateOdfHyperlink(source, direction2, charge, sheetNames = []) {
|
|
29334
|
+
charge(source.length);
|
|
29335
|
+
if (direction2 === "normalize" && !source.startsWith("#")) return source;
|
|
29336
|
+
function findSheet(name5) {
|
|
29337
|
+
const folded = foldSheetName(name5);
|
|
29338
|
+
return sheetNames.find((candidate) => {
|
|
29339
|
+
charge(candidate.length);
|
|
29340
|
+
return foldSheetName(candidate) === folded;
|
|
29341
|
+
});
|
|
29342
|
+
}
|
|
29343
|
+
let target = direction2 !== "export" && source.startsWith("#") ? source.slice(1) : source;
|
|
29344
|
+
if (direction2 !== "export") {
|
|
29345
|
+
target = decodeFragment(target, charge);
|
|
29346
|
+
const separator2 = target.indexOf(" (");
|
|
29347
|
+
if (separator2 > 0 && target.endsWith(")")) {
|
|
29348
|
+
const name5 = target.slice(0, separator2), sheet = findSheet(target.slice(separator2 + 2, -1));
|
|
29349
|
+
if (sheet !== void 0) {
|
|
29350
|
+
const qualified = quoteNativeSheet(sheet) + "!" + name5;
|
|
29351
|
+
const parsed2 = parseExpression("=" + qualified, { position: { sheet, row: 0, column: 0 }, onWork: charge });
|
|
29352
|
+
if (parsed2.ok && parsed2.document.root.kind === "name" && parsed2.document.root.name === name5 && parsed2.document.root.sheet === sheet)
|
|
29353
|
+
return direction2 === "import" ? qualified : encodeFragment(target);
|
|
29354
|
+
}
|
|
29355
|
+
}
|
|
29356
|
+
}
|
|
29357
|
+
const parsed = parseExpression("=" + target, {
|
|
29358
|
+
grammar: direction2 !== "export" ? linkGrammar : gnumericGrammar,
|
|
29359
|
+
position: { sheet: "", row: 0, column: 0 },
|
|
29360
|
+
onWork: charge
|
|
29361
|
+
});
|
|
29362
|
+
if (parsed.ok) {
|
|
29363
|
+
const node3 = parsed.document.root;
|
|
29364
|
+
if (node3.kind === "name" && node3.workbook === void 0 || node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0) {
|
|
29365
|
+
const sheet = direction2 !== "import" && node3.kind === "name" && node3.sheet !== void 0 ? findSheet(node3.sheet) : void 0;
|
|
29366
|
+
if (sheet !== void 0 && node3.kind === "name") return encodeFragment(node3.name + " (" + sheet + ")");
|
|
29367
|
+
if (direction2 !== "normalize") target = serializeExpression(parsed.document, direction2 === "import" ? { ...gnumericGrammar, quoteSheetName: quoteNativeSheet } : linkGrammar, false, true).slice(1);
|
|
29368
|
+
}
|
|
29369
|
+
}
|
|
29370
|
+
return direction2 === "import" ? target : direction2 === "normalize" ? source : encodeFragment(target);
|
|
29371
|
+
}
|
|
29372
|
+
|
|
29373
|
+
// packages/safe-bash-command-ssconvert/src/workbook/hyperlinks.ts
|
|
29374
|
+
function rewriteWorkbookHyperlinks(book, names2, context2) {
|
|
29375
|
+
let work = 0;
|
|
29376
|
+
const maximum = context2.limits.workbookWork ?? context2.limits.inputBytes + context2.limits.cells * 32;
|
|
29377
|
+
function charge(amount = 1) {
|
|
29378
|
+
context2.signal.throwIfAborted();
|
|
29379
|
+
if (amount > maximum - work) throw new SsconvertError("resource-limit", "ssconvert hyperlink work limit exceeded");
|
|
29380
|
+
work += amount;
|
|
29381
|
+
}
|
|
29382
|
+
const sheets = [...book.sheets, ...book.detachedSheets ?? []].map((sheet2) => sheet2.name);
|
|
29383
|
+
const changes = new Map(sheets.flatMap((name5) => {
|
|
29384
|
+
charge(name5.length);
|
|
29385
|
+
const next = names2.get(foldSheetName(name5));
|
|
29386
|
+
return next === void 0 || next === name5 ? [] : [[foldSheetName(name5), next]];
|
|
29387
|
+
}));
|
|
29388
|
+
if (!changes.size) return book;
|
|
29389
|
+
const renamedSheets = sheets.map((name5) => names2.get(foldSheetName(name5)) ?? name5);
|
|
29390
|
+
function target(source, odf) {
|
|
29391
|
+
charge(source.length);
|
|
29392
|
+
if (odf && !source.startsWith("#")) return source;
|
|
29393
|
+
const native = odf ? translateOdfHyperlink(source, "import", charge, sheets) : source;
|
|
29394
|
+
const parsed = parseExpression("=" + native, { position: { sheet: "", row: 0, column: 0 }, onWork: charge, signal: context2.signal });
|
|
29395
|
+
if (!parsed.ok) return source;
|
|
29396
|
+
const node3 = parsed.document.root;
|
|
29397
|
+
const spellings = node3.kind === "name" && node3.workbook === void 0 ? [node3.sheet] : node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0 ? [node3.first.sheet, node3.last?.sheet] : [];
|
|
29398
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
29399
|
+
for (const spelling of spellings) if (spelling !== void 0) {
|
|
29400
|
+
charge(spelling.length);
|
|
29401
|
+
const name5 = changes.get(foldSheetName(spelling));
|
|
29402
|
+
if (name5 !== void 0 && name5 !== spelling) replacements.set(spelling, name5);
|
|
29403
|
+
}
|
|
29404
|
+
if (!replacements.size) return source;
|
|
29405
|
+
const rewritten = rewriteReferences(parsed.document, { sheets: replacements, signal: context2.signal }).slice(1);
|
|
29406
|
+
charge(rewritten.length);
|
|
29407
|
+
return odf ? translateOdfHyperlink(rewritten, "export", charge, renamedSheets) : rewritten;
|
|
29408
|
+
}
|
|
29409
|
+
function xml2(value3, odf, root, implicitNamespace = false) {
|
|
29410
|
+
let result2 = value3;
|
|
29411
|
+
const pending = [{ value: value3, role: root, depth: 0, assign: (next) => {
|
|
29412
|
+
result2 = next;
|
|
29413
|
+
} }];
|
|
29414
|
+
while (pending.length) {
|
|
29415
|
+
const item = pending.pop();
|
|
29416
|
+
charge();
|
|
29417
|
+
const node3 = odfObject(item.value);
|
|
29418
|
+
if (!node3 || typeof node3.name !== "string" || node3.name !== item.role) continue;
|
|
29419
|
+
const validNamespace = odf ? node3.namespace === odfNamespaces.text || node3.namespace === "http://openoffice.org/2000/text" : node3.namespace === "http://www.gnumeric.org/v10.dtd" || implicitNamespace && (node3.namespace === void 0 || node3.namespace === "");
|
|
29420
|
+
if (!validNamespace) continue;
|
|
29421
|
+
if (item.depth > (context2.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert hyperlink depth limit exceeded");
|
|
29422
|
+
const updated = { ...node3 };
|
|
29423
|
+
item.assign(updated);
|
|
29424
|
+
const attributes4 = odfObject(node3.attributes);
|
|
29425
|
+
const list = Array.isArray(node3.attributes) ? node3.attributes : [];
|
|
29426
|
+
const field = (name5, namespace5) => {
|
|
29427
|
+
if (attributes4 && !namespace5 && typeof attributes4[name5] === "string") return attributes4[name5];
|
|
29428
|
+
for (const value4 of list) {
|
|
29429
|
+
charge();
|
|
29430
|
+
const attribute5 = odfObject(value4);
|
|
29431
|
+
if (attribute5?.name === name5 && attribute5.namespace === namespace5 && typeof attribute5.value === "string") return attribute5.value;
|
|
29432
|
+
}
|
|
29433
|
+
return void 0;
|
|
29434
|
+
};
|
|
29435
|
+
const link = odf ? node3.name === "a" : node3.name === "HyperLink" && field("type", "") === "GnmHLinkCurWB";
|
|
29436
|
+
if (link) {
|
|
29437
|
+
const name5 = odf ? "href" : "target", namespace5 = odf ? odfNamespaces.xlink : "";
|
|
29438
|
+
const source = field(name5, namespace5);
|
|
29439
|
+
if (source !== void 0) {
|
|
29440
|
+
const rewritten = target(source, odf);
|
|
29441
|
+
updated.attributes = attributes4 ? { ...attributes4, [name5]: rewritten } : list.map((value4) => {
|
|
29442
|
+
charge();
|
|
29443
|
+
const attribute5 = odfObject(value4);
|
|
29444
|
+
return attribute5?.name === name5 && attribute5.namespace === namespace5 ? { ...attribute5, value: rewritten } : value4;
|
|
29445
|
+
});
|
|
29446
|
+
}
|
|
29447
|
+
}
|
|
29448
|
+
const childRole = odf ? void 0 : node3.name === "Styles" ? "StyleRegion" : node3.name === "StyleRegion" ? "Style" : node3.name === "Style" ? "HyperLink" : "";
|
|
29449
|
+
const enqueue = (value4, assign) => {
|
|
29450
|
+
charge();
|
|
29451
|
+
const child7 = odfObject(value4);
|
|
29452
|
+
if (typeof child7?.name === "string") pending.push({ value: value4, role: childRole ?? child7.name, depth: item.depth + 1, assign });
|
|
29453
|
+
};
|
|
29454
|
+
if (Array.isArray(node3.children)) {
|
|
29455
|
+
const children7 = [...node3.children];
|
|
29456
|
+
updated.children = children7;
|
|
29457
|
+
children7.forEach((child7, index2) => enqueue(child7, (next) => {
|
|
29458
|
+
children7[index2] = next;
|
|
29459
|
+
}));
|
|
29460
|
+
}
|
|
29461
|
+
if (odf && Array.isArray(node3.content)) {
|
|
29462
|
+
const content2 = [...node3.content];
|
|
29463
|
+
updated.content = content2;
|
|
29464
|
+
content2.forEach((value4, index2) => {
|
|
29465
|
+
charge();
|
|
29466
|
+
const entry2 = odfObject(value4);
|
|
29467
|
+
if (entry2?.kind === "element" && entry2.index === void 0 && entry2.value !== void 0)
|
|
29468
|
+
enqueue(entry2.value, (next) => {
|
|
29469
|
+
content2[index2] = { ...entry2, value: next };
|
|
29470
|
+
});
|
|
29471
|
+
});
|
|
29472
|
+
}
|
|
29473
|
+
}
|
|
29474
|
+
return result2;
|
|
29475
|
+
}
|
|
29476
|
+
const style2 = (value3) => {
|
|
29477
|
+
charge();
|
|
29478
|
+
return value3?.gnumeric === void 0 ? value3 : { ...value3, gnumeric: xml2(value3.gnumeric, false, "Style", true) };
|
|
29479
|
+
};
|
|
29480
|
+
const sheet = (value3) => ({
|
|
29481
|
+
...value3,
|
|
29482
|
+
cells: value3.cells.map((cell) => {
|
|
29483
|
+
charge();
|
|
29484
|
+
return { ...cell, ...cell.style ? { style: style2(cell.style) } : {} };
|
|
29485
|
+
}),
|
|
29486
|
+
...value3.rows ? { rows: value3.rows.map((row) => ({ ...row, ...row.style ? { style: style2(row.style) } : {} })) } : {},
|
|
29487
|
+
...value3.columns ? { columns: value3.columns.map((column) => ({ ...column, ...column.style ? { style: style2(column.style) } : {} })) } : {},
|
|
29488
|
+
...value3.unsupportedRecords ? { unsupportedRecords: value3.unsupportedRecords.map((record7) => {
|
|
29489
|
+
charge();
|
|
29490
|
+
if (record7.disposition !== "retained" || record7.data === void 0) return record7;
|
|
29491
|
+
if (record7.source === "Gnumeric_XmlIO:sax" && record7.kind === "Styles") return { ...record7, data: xml2(record7.data, false, "Styles") };
|
|
29492
|
+
if (record7.kind === "p" && (record7.source === "Gnumeric_OpenCalc:openoffice" || record7.source === "odf:cell-content")) {
|
|
29493
|
+
const data4 = odfObject(record7.data);
|
|
29494
|
+
return data4?.xml === void 0 ? { ...record7, data: xml2(record7.data, true, "p") } : { ...record7, data: { ...data4, xml: xml2(data4.xml, true, "p") } };
|
|
29495
|
+
}
|
|
29496
|
+
return record7;
|
|
29497
|
+
}) } : {}
|
|
29498
|
+
});
|
|
29499
|
+
return { ...book, sheets: book.sheets.map(sheet), ...book.detachedSheets ? { detachedSheets: book.detachedSheets.map(sheet) } : {} };
|
|
29500
|
+
}
|
|
29501
|
+
|
|
29127
29502
|
// packages/safe-bash-command-ssconvert/src/formulas/workbook.ts
|
|
29128
29503
|
function rewriteWorkbook(book, context2, rewrite) {
|
|
29129
29504
|
let work = 0;
|
|
@@ -29181,14 +29556,14 @@ function renameWorkbookSheet(book, sheetId, name5, context2) {
|
|
|
29181
29556
|
if (!sheet || !name5 || name5.includes("\0") || book.sheets.some((s) => s.id !== sheetId && foldSheetName(s.name) === foldSheetName(name5)))
|
|
29182
29557
|
throw new SsconvertError("invalid-request", "Invalid sheet rename");
|
|
29183
29558
|
if (sheet.name === name5) return book;
|
|
29184
|
-
const renamed = rewriteWorkbook(book, context2, (document6) => {
|
|
29559
|
+
const renamed = rewriteWorkbookHyperlinks(rewriteWorkbook(book, context2, (document6) => {
|
|
29185
29560
|
const spellings = /* @__PURE__ */ new Map();
|
|
29186
29561
|
visitFormula(document6.root, (node3) => {
|
|
29187
29562
|
const names2 = node3.kind === "reference" ? [node3.first.sheet, node3.last?.sheet] : node3.kind === "name" ? [node3.sheet] : [];
|
|
29188
29563
|
for (const spelling of names2) if (spelling !== void 0 && foldSheetName(spelling) === foldSheetName(sheet.name)) spellings.set(spelling, name5);
|
|
29189
29564
|
});
|
|
29190
29565
|
return rewriteReferences(document6, { sheets: spellings, signal: context2.signal });
|
|
29191
|
-
});
|
|
29566
|
+
}), /* @__PURE__ */ new Map([[foldSheetName(sheet.name), name5]]), context2);
|
|
29192
29567
|
return snapshotWorkbook({
|
|
29193
29568
|
...renamed,
|
|
29194
29569
|
sheets: renamed.sheets.map((s) => s.id === sheetId ? { ...s, name: name5 } : s),
|
|
@@ -29198,15 +29573,15 @@ function renameWorkbookSheet(book, sheetId, name5, context2) {
|
|
|
29198
29573
|
function remapWorkbookSheets(book, mapping, context2) {
|
|
29199
29574
|
context2.signal.throwIfAborted();
|
|
29200
29575
|
book = snapshotWorkbook(book, context2.limits);
|
|
29201
|
-
const names2 = new Map(book.sheets.map((sheet) => [foldSheetName(sheet.name), mapping.get(sheet.id)?.name ?? sheet.name]));
|
|
29202
|
-
const rewritten = rewriteWorkbook(book, context2, (document6) => {
|
|
29576
|
+
const names2 = new Map([...book.sheets, ...book.detachedSheets ?? []].map((sheet) => [foldSheetName(sheet.name), mapping.get(sheet.id)?.name ?? sheet.name]));
|
|
29577
|
+
const rewritten = rewriteWorkbookHyperlinks(rewriteWorkbook(book, context2, (document6) => {
|
|
29203
29578
|
const spellings = /* @__PURE__ */ new Map();
|
|
29204
29579
|
visitFormula(document6.root, (node3) => {
|
|
29205
29580
|
const refs = node3.kind === "reference" ? [node3.first.sheet, node3.last?.sheet] : node3.kind === "name" ? [node3.sheet] : [];
|
|
29206
29581
|
for (const spelling of refs) if (spelling !== void 0 && names2.has(foldSheetName(spelling))) spellings.set(spelling, names2.get(foldSheetName(spelling)));
|
|
29207
29582
|
});
|
|
29208
29583
|
return rewriteReferences(document6, { sheets: spellings, signal: context2.signal });
|
|
29209
|
-
});
|
|
29584
|
+
}), names2, context2);
|
|
29210
29585
|
const id = (value3) => mapping.get(value3)?.id ?? value3;
|
|
29211
29586
|
const renamedTitles = new Map(book.sheets.flatMap((sheet) => {
|
|
29212
29587
|
const target = mapping.get(sheet.id);
|
|
@@ -35342,7 +35717,7 @@ var german = Object.freeze({
|
|
|
35342
35717
|
shortWeekdays: Object.freeze(["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"])
|
|
35343
35718
|
});
|
|
35344
35719
|
function formattingLocale(name5) {
|
|
35345
|
-
if (["C", "POSIX", "C.UTF-8", "C.utf8", "en_US", "en_US.UTF-8"].includes(name5)) return english;
|
|
35720
|
+
if (["C", "POSIX", "C.UTF-8", "C.utf8", "en_US", "en_US.UTF-8", "en_US.utf8"].includes(name5)) return english;
|
|
35346
35721
|
if (["de_DE", "de_DE.UTF-8", "de_DE.utf8"].includes(name5)) return german;
|
|
35347
35722
|
throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: uncaptured format locale");
|
|
35348
35723
|
}
|
|
@@ -51587,7 +51962,7 @@ init_platform();
|
|
|
51587
51962
|
|
|
51588
51963
|
// packages/safe-bash-command-ssconvert/src/codecs/xlsx-write-support.ts
|
|
51589
51964
|
init_platform();
|
|
51590
|
-
import { parseXmlSteps } from "@poe-platform/safe-fs/core";
|
|
51965
|
+
import { parseXmlSteps as parseXmlSteps2 } from "@poe-platform/safe-fs/core";
|
|
51591
51966
|
|
|
51592
51967
|
// packages/safe-bash-command-ssconvert/src/codecs/xlsx-strings.ts
|
|
51593
51968
|
init_platform();
|
|
@@ -51660,7 +52035,7 @@ function createXlsxXml(context2) {
|
|
|
51660
52035
|
try {
|
|
51661
52036
|
if (parts.length > 2) throw new Error("qualified name");
|
|
51662
52037
|
for (const part of parts) {
|
|
51663
|
-
const parser =
|
|
52038
|
+
const parser = parseXmlSteps2(`<${part}/>`, { maxNodes: 1, maxAttributes: 1 });
|
|
51664
52039
|
let step = parser.next();
|
|
51665
52040
|
while (!step.done) step = parser.next();
|
|
51666
52041
|
if (step.value.name !== part || step.value.namespace || step.value.children.length || step.value.attributes.length)
|
|
@@ -52118,7 +52493,7 @@ init_platform();
|
|
|
52118
52493
|
|
|
52119
52494
|
// packages/safe-bash-command-ssconvert/src/codecs/xlsx.ts
|
|
52120
52495
|
init_platform();
|
|
52121
|
-
import { parseXmlSteps as
|
|
52496
|
+
import { parseXmlSteps as parseXmlSteps3, XmlLimitError } from "@poe-platform/safe-fs/core";
|
|
52122
52497
|
|
|
52123
52498
|
// packages/safe-bash-command-ssconvert/src/codecs/xlsx-schema.ts
|
|
52124
52499
|
init_platform();
|
|
@@ -53937,7 +54312,10 @@ var capturedLocales = Object.freeze({
|
|
|
53937
54312
|
C: "C",
|
|
53938
54313
|
POSIX: "C",
|
|
53939
54314
|
"C.UTF-8": "C.UTF-8",
|
|
53940
|
-
"C.utf8": "C.UTF-8"
|
|
54315
|
+
"C.utf8": "C.UTF-8",
|
|
54316
|
+
en_US: "en_US",
|
|
54317
|
+
"en_US.UTF-8": "en_US.UTF-8",
|
|
54318
|
+
"en_US.utf8": "en_US.UTF-8"
|
|
53941
54319
|
});
|
|
53942
54320
|
function localeCategory(environment, category) {
|
|
53943
54321
|
const env2 = environment.env;
|
|
@@ -55357,7 +55735,7 @@ async function openPackage(bytes, context2) {
|
|
|
55357
55735
|
const text2 = new TextDecoder(encoding, { fatal: true }).decode(plain);
|
|
55358
55736
|
textBytes += plain.length;
|
|
55359
55737
|
if (textBytes > (context2.limits.workbookTextBytes ?? bounds2.maxTotalBytes)) limit("XML text");
|
|
55360
|
-
const parser =
|
|
55738
|
+
const parser = parseXmlSteps3(text2, {
|
|
55361
55739
|
expectedEncoding: encoding,
|
|
55362
55740
|
maxDepth: context2.limits.xmlDepth ?? Infinity,
|
|
55363
55741
|
maxNodes: (context2.limits.workbookNodes ?? Infinity) - nodes,
|
|
@@ -74436,7 +74814,8 @@ function encodeText(text2, charset, transliterate, context2) {
|
|
|
74436
74814
|
const suffixTransliteration = parts.length > 1 && parts.slice(1).every((part) => part.toLowerCase() === "translit");
|
|
74437
74815
|
if (suffixTransliteration) transliterate = true;
|
|
74438
74816
|
const base = suffixTransliteration ? parts[0] : charset;
|
|
74439
|
-
const
|
|
74817
|
+
const locale = base === "" ? converterLocale(context2.environment) : void 0;
|
|
74818
|
+
const name5 = base === "" ? locale === "C" ? "ascii" : locale === "en_US" ? "iso-8859-1" : "utf-8" : encodingName(base);
|
|
74440
74819
|
const admit2 = (length) => {
|
|
74441
74820
|
context2.signal.throwIfAborted();
|
|
74442
74821
|
if (length > context2.limits.outputBytes)
|
|
@@ -77554,7 +77933,7 @@ function rk(bits3) {
|
|
|
77554
77933
|
|
|
77555
77934
|
// packages/safe-bash-command-ssconvert/src/codecs/spreadsheetml.ts
|
|
77556
77935
|
init_platform();
|
|
77557
|
-
import { parseXmlSteps as
|
|
77936
|
+
import { parseXmlSteps as parseXmlSteps4, XmlLimitError as XmlLimitError2 } from "@poe-platform/safe-fs/core";
|
|
77558
77937
|
|
|
77559
77938
|
// packages/safe-bash-command-ssconvert/src/codecs/spreadsheetml-metadata.ts
|
|
77560
77939
|
init_platform();
|
|
@@ -77796,7 +78175,7 @@ async function document3(bytes, context2, probe = false) {
|
|
|
77796
78175
|
const at = text2.indexOf(declared, encodingAt + 8);
|
|
77797
78176
|
text2 = text2.slice(0, at) + "UTF-8" + text2.slice(at + declared.length);
|
|
77798
78177
|
} else text2 = new TextDecoder(encoding, { fatal: true }).decode(bytes);
|
|
77799
|
-
const parser =
|
|
78178
|
+
const parser = parseXmlSteps4(text2, {
|
|
77800
78179
|
expectedEncoding: encoding,
|
|
77801
78180
|
maxDepth: context2.limits.xmlDepth ?? Infinity,
|
|
77802
78181
|
maxNodes: context2.limits.workbookNodes ?? Infinity,
|
|
@@ -86418,6 +86797,13 @@ function probeLotus(bytes, context2) {
|
|
|
86418
86797
|
return (b3.u16(0) === 0 || b3.u16(0) === 255) && ([1028, 1029, 1030].includes(version2) ? length === 2 : [4098, 4099, 4100, 4101].includes(version2) && length >= 19);
|
|
86419
86798
|
}
|
|
86420
86799
|
var lmbcsDoubleByteCodepages = { 16: 932, 17: 949, 18: 950, 19: 936 };
|
|
86800
|
+
function decodeSheetName(bytes) {
|
|
86801
|
+
const zero = bytes.indexOf(0);
|
|
86802
|
+
return Array.from(zero < 0 ? bytes : bytes.subarray(0, zero), (byte) => {
|
|
86803
|
+
const character = singleByteTables["windows-1252"][byte];
|
|
86804
|
+
return character === "\uFFFF" ? String.fromCharCode(byte) : character;
|
|
86805
|
+
}).join("");
|
|
86806
|
+
}
|
|
86421
86807
|
async function lmbcs(bytes, group, context2) {
|
|
86422
86808
|
let text2 = "";
|
|
86423
86809
|
const warn = async (message) => context2.diagnostic?.({ code: "lotus", severity: "warning", message });
|
|
@@ -86866,7 +87252,7 @@ async function readLotus(bytes, context2) {
|
|
|
86866
87252
|
at += length;
|
|
86867
87253
|
if (id === 0) {
|
|
86868
87254
|
if (modern) {
|
|
86869
|
-
if (length >= 18) group = data4.u8(16);
|
|
87255
|
+
if (version2 >= 4098 && length >= 18) group = data4.u8(16);
|
|
86870
87256
|
} else {
|
|
86871
87257
|
active = sheets.length;
|
|
86872
87258
|
sheet(active);
|
|
@@ -86882,8 +87268,7 @@ async function readLotus(bytes, context2) {
|
|
|
86882
87268
|
consumeOperation();
|
|
86883
87269
|
if (length < 5) await warn(`Record with type 0x23 has wrong length ${length}.`);
|
|
86884
87270
|
else {
|
|
86885
|
-
const
|
|
86886
|
-
const name5 = new TextDecoder("windows-1252").decode(zero < 0 ? nameBytes : nameBytes.subarray(0, zero));
|
|
87271
|
+
const name5 = decodeSheetName(data4.bytes.subarray(4));
|
|
86887
87272
|
if (name5) sheet(data4.u16(2)).name = name5;
|
|
86888
87273
|
}
|
|
86889
87274
|
continue;
|
|
@@ -87085,8 +87470,7 @@ async function readLotus(bytes, context2) {
|
|
|
87085
87470
|
consumeOperation();
|
|
87086
87471
|
if (length < 5) await warn(`Record with type 0x1b has wrong length ${length}.`);
|
|
87087
87472
|
else {
|
|
87088
|
-
const
|
|
87089
|
-
const name5 = new TextDecoder("windows-1252").decode(zero < 0 ? nameBytes : nameBytes.subarray(0, zero));
|
|
87473
|
+
const name5 = decodeSheetName(data4.bytes.subarray(4));
|
|
87090
87474
|
if (name5) sheet(data4.u16(2)).name = name5;
|
|
87091
87475
|
}
|
|
87092
87476
|
} else if (subtype === 4001) {
|
|
@@ -89980,53 +90364,6 @@ function prepareOdfFormulaLabels(book, context2, tick) {
|
|
|
89980
90364
|
return { book, documents: documents2 };
|
|
89981
90365
|
}
|
|
89982
90366
|
|
|
89983
|
-
// packages/safe-bash-command-ssconvert/src/codecs/odf-hyperlinks.ts
|
|
89984
|
-
init_platform();
|
|
89985
|
-
var linkGrammar = { ...excelGrammar, id: "odf-hyperlink", sheetSeparator: "." };
|
|
89986
|
-
function translateOdfHyperlink(source, direction2, charge, sheetNames = []) {
|
|
89987
|
-
charge(source.length);
|
|
89988
|
-
if (direction2 === "normalize" && !source.startsWith("#")) return source;
|
|
89989
|
-
function findSheet(name5) {
|
|
89990
|
-
const folded = foldSheetName(name5);
|
|
89991
|
-
return sheetNames.find((candidate) => {
|
|
89992
|
-
charge(candidate.length);
|
|
89993
|
-
return foldSheetName(candidate) === folded;
|
|
89994
|
-
});
|
|
89995
|
-
}
|
|
89996
|
-
let target = direction2 !== "export" && source.startsWith("#") ? source.slice(1) : source;
|
|
89997
|
-
if (direction2 !== "export") {
|
|
89998
|
-
try {
|
|
89999
|
-
target = decodeURIComponent(target);
|
|
90000
|
-
} catch {
|
|
90001
|
-
if (direction2 === "normalize") return source;
|
|
90002
|
-
}
|
|
90003
|
-
const separator2 = target.indexOf(" (");
|
|
90004
|
-
if (separator2 > 0 && target.endsWith(")")) {
|
|
90005
|
-
const name5 = target.slice(0, separator2), sheet = findSheet(target.slice(separator2 + 2, -1));
|
|
90006
|
-
if (sheet !== void 0) {
|
|
90007
|
-
const qualified = quoteNativeSheet(sheet) + "!" + name5;
|
|
90008
|
-
const parsed2 = parseExpression("=" + qualified, { position: { sheet, row: 0, column: 0 }, onWork: charge });
|
|
90009
|
-
if (parsed2.ok && parsed2.document.root.kind === "name" && parsed2.document.root.name === name5 && parsed2.document.root.sheet === sheet)
|
|
90010
|
-
return direction2 === "import" ? qualified : source;
|
|
90011
|
-
}
|
|
90012
|
-
}
|
|
90013
|
-
}
|
|
90014
|
-
const parsed = parseExpression("=" + target, {
|
|
90015
|
-
grammar: direction2 !== "export" ? linkGrammar : gnumericGrammar,
|
|
90016
|
-
position: { sheet: "", row: 0, column: 0 },
|
|
90017
|
-
onWork: charge
|
|
90018
|
-
});
|
|
90019
|
-
if (parsed.ok) {
|
|
90020
|
-
const node3 = parsed.document.root;
|
|
90021
|
-
if (node3.kind === "name" && node3.workbook === void 0 || node3.kind === "reference" && !node3.label && node3.first.workbook === void 0 && node3.last?.workbook === void 0) {
|
|
90022
|
-
const sheet = direction2 !== "import" && node3.kind === "name" && node3.sheet !== void 0 ? findSheet(node3.sheet) : void 0;
|
|
90023
|
-
if (sheet !== void 0 && node3.kind === "name") return "#" + encodeURI(node3.name + " (" + sheet + ")");
|
|
90024
|
-
if (direction2 !== "normalize") target = serializeExpression(parsed.document, direction2 === "import" ? { ...gnumericGrammar, quoteSheetName: quoteNativeSheet } : linkGrammar, false, true).slice(1);
|
|
90025
|
-
}
|
|
90026
|
-
}
|
|
90027
|
-
return direction2 === "import" ? target : direction2 === "normalize" ? source : "#" + encodeURI(target);
|
|
90028
|
-
}
|
|
90029
|
-
|
|
90030
90367
|
// packages/safe-bash-command-ssconvert/src/codecs/odf-schema.ts
|
|
90031
90368
|
init_platform();
|
|
90032
90369
|
var odfReaderStates = {
|
|
@@ -90140,6 +90477,7 @@ TEXT_SPAN TEXT_LINE_BREAK OO_NS_TEXT line-break
|
|
|
90140
90477
|
TEXT_SPAN TEXT_TAB OO_NS_TEXT tab
|
|
90141
90478
|
TEXT_SPAN TEXT_ADDR OO_NS_TEXT a
|
|
90142
90479
|
TEXT_ADDR TEXT_S OO_NS_TEXT s
|
|
90480
|
+
TEXT_ADDR TEXT_LINE_BREAK OO_NS_TEXT line-break
|
|
90143
90481
|
TEXT_ADDR TEXT_TAB OO_NS_TEXT tab
|
|
90144
90482
|
TEXT_ADDR TEXT_SPAN OO_NS_TEXT span
|
|
90145
90483
|
CONTENT_VALIDATION HELP_MESSAGE OO_NS_TABLE help-message
|
|
@@ -90583,13 +90921,13 @@ MASTER_PAGE_FOOTER MASTER_PAGE_HF_P OO_NS_TEXT p`
|
|
|
90583
90921
|
|
|
90584
90922
|
// packages/safe-bash-command-ssconvert/src/codecs/odf-metadata.ts
|
|
90585
90923
|
init_platform();
|
|
90586
|
-
var
|
|
90924
|
+
var urn2 = "urn:oasis:names:tc:opendocument:xmlns:";
|
|
90587
90925
|
var ns = {
|
|
90588
|
-
table: [
|
|
90589
|
-
office: [
|
|
90590
|
-
text: [
|
|
90591
|
-
style: [
|
|
90592
|
-
fo: [
|
|
90926
|
+
table: [urn2 + "table:1.0", "http://openoffice.org/2000/table"],
|
|
90927
|
+
office: [urn2 + "office:1.0", "http://openoffice.org/2000/office"],
|
|
90928
|
+
text: [urn2 + "text:1.0", "http://openoffice.org/2000/text"],
|
|
90929
|
+
style: [urn2 + "style:1.0", "http://openoffice.org/2000/style"],
|
|
90930
|
+
fo: [urn2 + "xsl-fo-compatible:1.0", "http://www.w3.org/1999/XSL/Format"],
|
|
90593
90931
|
dc: ["http://purl.org/dc/elements/1.1/"],
|
|
90594
90932
|
xlink: ["http://www.w3.org/1999/xlink"],
|
|
90595
90933
|
gnm: ["http://www.gnumeric.org/odf-extension/1.0"]
|
|
@@ -90834,8 +91172,8 @@ init_platform();
|
|
|
90834
91172
|
var tableNamespaces = ["urn:oasis:names:tc:opendocument:xmlns:table:1.0", "http://openoffice.org/2000/table"];
|
|
90835
91173
|
function readOdfLabelRanges(parent, sheets, context2, charge) {
|
|
90836
91174
|
const byName = new Map(sheets.map((sheet) => {
|
|
90837
|
-
charge();
|
|
90838
|
-
return [sheet.name, sheet];
|
|
91175
|
+
charge(1 + sheet.name.length);
|
|
91176
|
+
return [foldSheetName(sheet.name), sheet];
|
|
90839
91177
|
}));
|
|
90840
91178
|
const ranges2 = /* @__PURE__ */ new Map();
|
|
90841
91179
|
const sizes = new Map(sheets.map((sheet) => {
|
|
@@ -90871,8 +91209,9 @@ function readOdfLabelRanges(parent, sheets, context2, charge) {
|
|
|
90871
91209
|
});
|
|
90872
91210
|
if (!parsed.ok || parsed.document.root.kind !== "reference") return invalid10();
|
|
90873
91211
|
const first = parsed.document.root.first, last2 = parsed.document.root.last ?? first;
|
|
90874
|
-
const sheet = first.sheet === void 0 ? void 0 : byName.get(first.sheet);
|
|
90875
|
-
|
|
91212
|
+
const sheet = first.sheet === void 0 ? void 0 : byName.get(foldSheetName(first.sheet));
|
|
91213
|
+
const lastSheet = last2.sheet === void 0 ? sheet : byName.get(foldSheetName(last2.sheet));
|
|
91214
|
+
if (!sheet || first.workbook !== void 0 || last2.workbook !== void 0 || lastSheet !== sheet || !first.row || !first.column || !last2.row || !last2.column) return invalid10();
|
|
90876
91215
|
const range5 = { startRow: first.row.value, endRow: last2.row.value, startColumn: first.column.value, endColumn: last2.column.value };
|
|
90877
91216
|
if (Object.values(range5).some((value3) => !Number.isSafeInteger(value3) || value3 < 0) || range5.startRow > range5.endRow || range5.startColumn > range5.endColumn || range5.endRow >= MAX_SHEET_SIZE.rows || range5.endColumn >= MAX_SHEET_SIZE.columns) return invalid10();
|
|
90878
91217
|
return { sheet, range: range5 };
|
|
@@ -90904,170 +91243,6 @@ function readOdfLabelRanges(parent, sheets, context2, charge) {
|
|
|
90904
91243
|
});
|
|
90905
91244
|
}
|
|
90906
91245
|
|
|
90907
|
-
// packages/safe-bash-command-ssconvert/src/codecs/odf-write-support.ts
|
|
90908
|
-
init_platform();
|
|
90909
|
-
import { parseXmlSteps as parseXmlSteps4 } from "@poe-platform/safe-fs/core";
|
|
90910
|
-
var urn2 = "urn:oasis:names:tc:opendocument:xmlns:";
|
|
90911
|
-
var odfEncryptionNamespace = "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0";
|
|
90912
|
-
var odfNamespaces = {
|
|
90913
|
-
xml: "http://www.w3.org/XML/1998/namespace",
|
|
90914
|
-
office: urn2 + "office:1.0",
|
|
90915
|
-
style: urn2 + "style:1.0",
|
|
90916
|
-
text: urn2 + "text:1.0",
|
|
90917
|
-
table: urn2 + "table:1.0",
|
|
90918
|
-
draw: urn2 + "drawing:1.0",
|
|
90919
|
-
fo: urn2 + "xsl-fo-compatible:1.0",
|
|
90920
|
-
xlink: "http://www.w3.org/1999/xlink",
|
|
90921
|
-
dc: "http://purl.org/dc/elements/1.1/",
|
|
90922
|
-
meta: urn2 + "meta:1.0",
|
|
90923
|
-
number: urn2 + "datastyle:1.0",
|
|
90924
|
-
svg: urn2 + "svg-compatible:1.0",
|
|
90925
|
-
chart: urn2 + "chart:1.0",
|
|
90926
|
-
config: urn2 + "config:1.0",
|
|
90927
|
-
form: urn2 + "form:1.0",
|
|
90928
|
-
script: urn2 + "script:1.0",
|
|
90929
|
-
of: urn2 + "of:1.2",
|
|
90930
|
-
manifest: urn2 + "manifest:1.0",
|
|
90931
|
-
gnm: "http://www.gnumeric.org/odf-extension/1.0",
|
|
90932
|
-
calcext: "urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
|
|
90933
|
-
};
|
|
90934
|
-
function odfObject(value3) {
|
|
90935
|
-
return value3 !== null && typeof value3 === "object" && !Array.isArray(value3) ? value3 : void 0;
|
|
90936
|
-
}
|
|
90937
|
-
function odfAttributes(value3, namespace5) {
|
|
90938
|
-
const source = odfObject(value3)?.attributes;
|
|
90939
|
-
if (Array.isArray(source)) return Object.fromEntries(source.flatMap((a3) => {
|
|
90940
|
-
const v2 = odfObject(a3);
|
|
90941
|
-
return typeof v2?.name === "string" && typeof v2.value === "string" && (namespace5 === void 0 || v2.namespace === namespace5) ? [[v2.name, v2.value]] : [];
|
|
90942
|
-
}));
|
|
90943
|
-
if (namespace5 !== void 0) return {};
|
|
90944
|
-
return Object.fromEntries(Object.entries(odfObject(source) ?? {}).filter((entry2) => typeof entry2[1] === "string"));
|
|
90945
|
-
}
|
|
90946
|
-
function odfChildren(value3) {
|
|
90947
|
-
const source = odfObject(value3)?.children;
|
|
90948
|
-
return Array.isArray(source) ? source : [];
|
|
90949
|
-
}
|
|
90950
|
-
function createOdfXml(context2, extended) {
|
|
90951
|
-
let work = 0, nodes = 0;
|
|
90952
|
-
const encoder2 = new TextEncoder(), names2 = /* @__PURE__ */ new Set();
|
|
90953
|
-
const declarations = {
|
|
90954
|
-
...Object.fromEntries(Object.entries(odfNamespaces).map(([prefix2, uri]) => ["xmlns:" + prefix2, uri])),
|
|
90955
|
-
"xmlns:loext": odfEncryptionNamespace
|
|
90956
|
-
};
|
|
90957
|
-
function charge(amount = 1) {
|
|
90958
|
-
context2.signal.throwIfAborted();
|
|
90959
|
-
if (!Number.isSafeInteger(amount) || amount < 0 || amount > (context2.limits.workbookWork ?? Infinity) - work)
|
|
90960
|
-
throw new SsconvertError("resource-limit", "ssconvert OpenDocument work limit exceeded");
|
|
90961
|
-
work += amount;
|
|
90962
|
-
}
|
|
90963
|
-
function name5(value3) {
|
|
90964
|
-
charge(value3.length);
|
|
90965
|
-
if (names2.has(value3)) return;
|
|
90966
|
-
try {
|
|
90967
|
-
const parser = parseXmlSteps4(`<${value3} ${Object.entries(declarations).map(([k, v2]) => `${k}="${v2}"`).join(" ")}/>`, { maxNodes: 1, maxAttributes: 100 });
|
|
90968
|
-
let step = parser.next();
|
|
90969
|
-
while (!step.done) step = parser.next();
|
|
90970
|
-
if (step.value.name !== value3 || step.value.children.length) throw new Error("name");
|
|
90971
|
-
} catch {
|
|
90972
|
-
throw new SsconvertError("invalid-request", "Invalid OpenDocument XML name");
|
|
90973
|
-
}
|
|
90974
|
-
names2.add(value3);
|
|
90975
|
-
}
|
|
90976
|
-
function escape3(value3) {
|
|
90977
|
-
charge(value3.length);
|
|
90978
|
-
let result2 = "";
|
|
90979
|
-
for (const c4 of value3) {
|
|
90980
|
-
const code2 = c4.codePointAt(0);
|
|
90981
|
-
if (code2 < 32 && !" \n\r".includes(c4) || code2 === 65534 || code2 === 65535 || code2 >= 55296 && code2 <= 57343)
|
|
90982
|
-
throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: non-XML OpenDocument character");
|
|
90983
|
-
result2 += c4 === "&" ? "&" : c4 === "<" ? "<" : c4 === ">" ? ">" : c4 === '"' ? """ : c4 === "\r" ? " " : c4 === "\n" ? " " : c4 === " " ? "	" : c4;
|
|
90984
|
-
}
|
|
90985
|
-
return result2;
|
|
90986
|
-
}
|
|
90987
|
-
function element2(tag3, attributes4 = {}, content2 = "") {
|
|
90988
|
-
charge();
|
|
90989
|
-
if (++nodes > (context2.limits.workbookNodes ?? Infinity))
|
|
90990
|
-
throw new SsconvertError("resource-limit", "ssconvert OpenDocument XML nodes limit exceeded");
|
|
90991
|
-
name5(tag3);
|
|
90992
|
-
let result2 = "<" + tag3;
|
|
90993
|
-
for (const [key2, value3] of Object.entries(attributes4)) if (value3 !== void 0) {
|
|
90994
|
-
if (!key2.startsWith("xmlns:")) name5(key2);
|
|
90995
|
-
result2 += ` ${key2}="${escape3(String(value3))}"`;
|
|
90996
|
-
}
|
|
90997
|
-
result2 += content2 ? ">" + content2 + "</" + tag3 + ">" : "/>";
|
|
90998
|
-
if (result2.length > context2.limits.outputBytes || encoder2.encode(result2).length > context2.limits.outputBytes)
|
|
90999
|
-
throw new SsconvertError("resource-limit", "ssconvert OpenDocument output bytes limit exceeded");
|
|
91000
|
-
return result2;
|
|
91001
|
-
}
|
|
91002
|
-
function text2(value3) {
|
|
91003
|
-
charge(value3.length);
|
|
91004
|
-
let result2 = "", plain = "";
|
|
91005
|
-
function flush() {
|
|
91006
|
-
result2 += escape3(plain);
|
|
91007
|
-
plain = "";
|
|
91008
|
-
}
|
|
91009
|
-
for (let i4 = 0; i4 < value3.length; i4++) {
|
|
91010
|
-
const c4 = value3[i4];
|
|
91011
|
-
if (c4 === " ") {
|
|
91012
|
-
flush();
|
|
91013
|
-
let count = 1;
|
|
91014
|
-
while (value3[i4 + 1] === " ") {
|
|
91015
|
-
i4++;
|
|
91016
|
-
count++;
|
|
91017
|
-
}
|
|
91018
|
-
result2 += element2("text:s", count > 1 ? { "text:c": count } : {});
|
|
91019
|
-
} else if (c4 === " " || c4 === "\n") {
|
|
91020
|
-
flush();
|
|
91021
|
-
result2 += element2(c4 === " " ? "text:tab" : "text:line-break");
|
|
91022
|
-
} else plain += c4;
|
|
91023
|
-
}
|
|
91024
|
-
flush();
|
|
91025
|
-
return result2;
|
|
91026
|
-
}
|
|
91027
|
-
const active = /* @__PURE__ */ new Set();
|
|
91028
|
-
function retained2(value3, depth = 0, hyperlink) {
|
|
91029
|
-
charge();
|
|
91030
|
-
const v2 = odfObject(value3);
|
|
91031
|
-
if (!v2 || typeof v2.name !== "string" || typeof v2.namespace !== "string") return "";
|
|
91032
|
-
if (depth > (context2.limits.xmlDepth ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert OpenDocument metadata depth limit exceeded");
|
|
91033
|
-
if (active.has(v2)) throw new SsconvertError("invalid-request", "Invalid cyclic OpenDocument metadata");
|
|
91034
|
-
const prefix2 = Object.entries(odfNamespaces).find(([, uri]) => uri === v2.namespace)?.[0];
|
|
91035
|
-
if (!prefix2 || !extended && ["gnm", "calcext"].includes(prefix2)) return "";
|
|
91036
|
-
active.add(v2);
|
|
91037
|
-
try {
|
|
91038
|
-
const attributes4 = {};
|
|
91039
|
-
if (Array.isArray(v2.attributes)) for (const a3 of v2.attributes) {
|
|
91040
|
-
charge();
|
|
91041
|
-
const attribute5 = odfObject(a3);
|
|
91042
|
-
if (typeof attribute5?.name !== "string" || typeof attribute5.value !== "string" || typeof attribute5.namespace !== "string") continue;
|
|
91043
|
-
const p2 = Object.entries(odfNamespaces).find(([, uri]) => uri === attribute5.namespace)?.[0];
|
|
91044
|
-
if (attribute5.namespace && (!p2 || !extended && ["gnm", "calcext"].includes(p2))) continue;
|
|
91045
|
-
attributes4[(p2 ? p2 + ":" : "") + attribute5.name] = attribute5.value;
|
|
91046
|
-
}
|
|
91047
|
-
if (prefix2 === "text" && v2.name === "a" && attributes4["xlink:href"] !== void 0 && hyperlink)
|
|
91048
|
-
attributes4["xlink:href"] = hyperlink(attributes4["xlink:href"]);
|
|
91049
|
-
const children7 = odfChildren(v2);
|
|
91050
|
-
const content2 = Array.isArray(v2.content) ? v2.content.map((c4) => {
|
|
91051
|
-
charge();
|
|
91052
|
-
const item = odfObject(c4);
|
|
91053
|
-
if (item?.kind === "text" && typeof item.text === "string") return escape3(item.text);
|
|
91054
|
-
if (item?.kind !== "element") return "";
|
|
91055
|
-
if (item.index === void 0) return retained2(item.value, depth + 1, hyperlink);
|
|
91056
|
-
if (typeof item.index !== "number" || !Number.isSafeInteger(item.index) || item.index < 0 || item.index >= children7.length)
|
|
91057
|
-
throw new SsconvertError("invalid-request", "Invalid OpenDocument metadata child index");
|
|
91058
|
-
return retained2(children7[item.index], depth + 1, hyperlink);
|
|
91059
|
-
}).join("") : (typeof v2.text === "string" ? escape3(v2.text) : "") + children7.map((c4) => retained2(c4, depth + 1, hyperlink)).join("");
|
|
91060
|
-
return element2(prefix2 + ":" + v2.name, attributes4, content2);
|
|
91061
|
-
} finally {
|
|
91062
|
-
active.delete(v2);
|
|
91063
|
-
}
|
|
91064
|
-
}
|
|
91065
|
-
function document6(tag3, body) {
|
|
91066
|
-
return '<?xml version="1.0" encoding="UTF-8"?>\n' + element2(tag3, { ...declarations, "xmlns:loext": void 0, "office:version": "1.2" }, body);
|
|
91067
|
-
}
|
|
91068
|
-
return { element: element2, escape: escape3, text: text2, retained: retained2, document: document6, charge };
|
|
91069
|
-
}
|
|
91070
|
-
|
|
91071
91246
|
// packages/safe-bash-command-ssconvert/src/codecs/odf-encrypted-write.ts
|
|
91072
91247
|
init_platform();
|
|
91073
91248
|
var iterations = 1024;
|
|
@@ -91387,8 +91562,8 @@ function createOdfStyles(xml2, extended, book, context2) {
|
|
|
91387
91562
|
}
|
|
91388
91563
|
return { register, styles };
|
|
91389
91564
|
}
|
|
91390
|
-
function
|
|
91391
|
-
const
|
|
91565
|
+
function odfPrintProperties(records, xml2, extended) {
|
|
91566
|
+
const properties = { "style:print": "charts drawings objects" };
|
|
91392
91567
|
for (const source of records) for (const n of odfChildren(source)) {
|
|
91393
91568
|
xml2.charge();
|
|
91394
91569
|
const v2 = odfObject(n), a3 = odfAttributes(n);
|
|
@@ -91406,10 +91581,83 @@ function odfPrintStyles(records, index2, xml2, extended) {
|
|
|
91406
91581
|
} else if (a3.percentage) properties["style:scale-to"] = a3.percentage + "%";
|
|
91407
91582
|
}
|
|
91408
91583
|
}
|
|
91409
|
-
return
|
|
91410
|
-
|
|
91411
|
-
|
|
91412
|
-
|
|
91584
|
+
return properties;
|
|
91585
|
+
}
|
|
91586
|
+
|
|
91587
|
+
// packages/safe-bash-command-ssconvert/src/codecs/odf-style-definitions.ts
|
|
91588
|
+
init_platform();
|
|
91589
|
+
function createOdfStyleDefinitions(book, xml2) {
|
|
91590
|
+
const sections = /* @__PURE__ */ new Map();
|
|
91591
|
+
const shapes2 = /* @__PURE__ */ new Map();
|
|
91592
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
91593
|
+
let anonymous = 0;
|
|
91594
|
+
for (const record7 of book.unsupportedRecords ?? []) {
|
|
91595
|
+
xml2.charge();
|
|
91596
|
+
if (record7.source !== "Gnumeric_OpenCalc:openoffice") continue;
|
|
91597
|
+
const data4 = odfObject(record7.data);
|
|
91598
|
+
const section = record7.kind === "automatic-styles" ? data4?.packagePart === "styles.xml" ? "stylesAutomatic" : "contentAutomatic" : record7.kind === "master-styles" ? "masters" : record7.kind === "font-face-decls" ? "fonts" : record7.kind === "styles" ? "styles" : void 0;
|
|
91599
|
+
if (!section) continue;
|
|
91600
|
+
let entries = sections.get(section);
|
|
91601
|
+
if (!entries) {
|
|
91602
|
+
entries = /* @__PURE__ */ new Map();
|
|
91603
|
+
sections.set(section, entries);
|
|
91604
|
+
}
|
|
91605
|
+
for (const child7 of odfChildren(data4?.xml)) {
|
|
91606
|
+
xml2.charge();
|
|
91607
|
+
const node3 = odfObject(child7), attributes4 = odfAttributes(child7, odfNamespaces.style);
|
|
91608
|
+
const key2 = attributes4.name ? JSON.stringify([node3?.namespace, node3?.name, attributes4.family ?? "", attributes4.name]) : "anonymous:" + anonymous++;
|
|
91609
|
+
entries.set(key2, child7);
|
|
91610
|
+
if (attributes4.name) names2.add(attributes4.name);
|
|
91611
|
+
}
|
|
91612
|
+
}
|
|
91613
|
+
for (const [section, entries] of sections) {
|
|
91614
|
+
const byShape = /* @__PURE__ */ new Map();
|
|
91615
|
+
shapes2.set(section, byShape);
|
|
91616
|
+
for (const child7 of entries.values()) {
|
|
91617
|
+
xml2.charge();
|
|
91618
|
+
const node3 = odfObject(child7), name5 = odfAttributes(child7, odfNamespaces.style).name;
|
|
91619
|
+
if (!node3 || !name5 || !Array.isArray(node3.attributes)) continue;
|
|
91620
|
+
const attributes4 = node3.attributes.filter((value3) => {
|
|
91621
|
+
xml2.charge();
|
|
91622
|
+
const attribute5 = odfObject(value3);
|
|
91623
|
+
return attribute5?.namespace !== odfNamespaces.style || attribute5?.name !== "name";
|
|
91624
|
+
});
|
|
91625
|
+
byShape.set(xml2.retained({ ...node3, attributes: attributes4 }), name5);
|
|
91626
|
+
}
|
|
91627
|
+
}
|
|
91628
|
+
function register(section, tag3, preferredName, attributes4, content2 = "") {
|
|
91629
|
+
const shape = xml2.element(tag3, attributes4, content2);
|
|
91630
|
+
let byShape = shapes2.get(section);
|
|
91631
|
+
const existing = byShape?.get(shape);
|
|
91632
|
+
if (existing !== void 0) return existing;
|
|
91633
|
+
let name5 = preferredName, suffix = 1;
|
|
91634
|
+
while (names2.has(name5)) {
|
|
91635
|
+
xml2.charge();
|
|
91636
|
+
name5 = preferredName + "_" + suffix++;
|
|
91637
|
+
}
|
|
91638
|
+
names2.add(name5);
|
|
91639
|
+
let entries = sections.get(section);
|
|
91640
|
+
if (!entries) {
|
|
91641
|
+
entries = /* @__PURE__ */ new Map();
|
|
91642
|
+
sections.set(section, entries);
|
|
91643
|
+
}
|
|
91644
|
+
entries.set("generated:" + name5, xml2.element(tag3, { "style:name": name5, ...attributes4 }, content2));
|
|
91645
|
+
if (!byShape) {
|
|
91646
|
+
byShape = /* @__PURE__ */ new Map();
|
|
91647
|
+
shapes2.set(section, byShape);
|
|
91648
|
+
}
|
|
91649
|
+
byShape.set(shape, name5);
|
|
91650
|
+
return name5;
|
|
91651
|
+
}
|
|
91652
|
+
function render(section) {
|
|
91653
|
+
let result2 = "";
|
|
91654
|
+
for (const value3 of sections.get(section)?.values() ?? []) {
|
|
91655
|
+
xml2.charge();
|
|
91656
|
+
result2 += typeof value3 === "string" ? value3 : xml2.retained(value3);
|
|
91657
|
+
}
|
|
91658
|
+
return result2;
|
|
91659
|
+
}
|
|
91660
|
+
return { register, render };
|
|
91413
91661
|
}
|
|
91414
91662
|
|
|
91415
91663
|
// packages/safe-bash-command-ssconvert/src/codecs/odf-function-names.ts
|
|
@@ -92254,7 +92502,8 @@ async function readOdf(bytes, context2) {
|
|
|
92254
92502
|
const dateSystem = attr5(children5(calculation, "null-date")[0], "date-value")?.startsWith("1904") ? "1904" : "1900";
|
|
92255
92503
|
const unsupportedRecords = [];
|
|
92256
92504
|
const styles = readStyles(styleRoots, pkg.charge);
|
|
92257
|
-
for (const r of styleRoots) for (const node3 of r.children) if (["styles", "automatic-styles", "master-styles", "font-face-decls", "font-decls"].includes(node3.localName))
|
|
92505
|
+
for (const r of styleRoots) for (const node3 of r.children) if (["styles", "automatic-styles", "master-styles", "font-face-decls", "font-decls"].includes(node3.localName))
|
|
92506
|
+
unsupportedRecords.push(record4(node3, { packagePart: r === preparseRoot ? "content.xml" : "styles.xml" }));
|
|
92258
92507
|
if (manifest) unsupportedRecords.push(record4(manifest));
|
|
92259
92508
|
for (const name5 of ["meta.xml", "settings.xml"]) if (pkg.entries.has(name5)) unsupportedRecords.push(record4(await pkg.document(name5)));
|
|
92260
92509
|
const resources = /* @__PURE__ */ new Set();
|
|
@@ -92562,6 +92811,8 @@ async function readOdf(bytes, context2) {
|
|
|
92562
92811
|
if (calculation) unsupportedRecords.push(record4(calculation));
|
|
92563
92812
|
if (!sheets.length) invalid4("no sheets");
|
|
92564
92813
|
const iteration = children5(calculation, "iteration")[0];
|
|
92814
|
+
const iterationMaximum = Number(attr5(iteration, "steps") ?? "100");
|
|
92815
|
+
if (!Number.isSafeInteger(iterationMaximum) || iterationMaximum < 0) invalid4("invalid iteration count");
|
|
92565
92816
|
const lookup4 = attr5(calculation, "automatic-find-labels");
|
|
92566
92817
|
if (lookup4 !== void 0 && !["true", "false"].includes(lookup4)) invalid4("invalid automatic label lookup setting");
|
|
92567
92818
|
const book = {
|
|
@@ -92573,7 +92824,7 @@ async function readOdf(bytes, context2) {
|
|
|
92573
92824
|
unsupportedRecords,
|
|
92574
92825
|
...iteration ? { iteration: {
|
|
92575
92826
|
enabled: attr5(iteration, "status") === "enable",
|
|
92576
|
-
maximum:
|
|
92827
|
+
maximum: iterationMaximum,
|
|
92577
92828
|
tolerance: Number(attr5(iteration, "maximum-difference") ?? "0.001")
|
|
92578
92829
|
} } : {}
|
|
92579
92830
|
};
|
|
@@ -92831,40 +93082,40 @@ function createOdfWriter(profile) {
|
|
|
92831
93082
|
"table:maximum-difference": iteration?.tolerance ?? 1e-3
|
|
92832
93083
|
})
|
|
92833
93084
|
);
|
|
92834
|
-
|
|
93085
|
+
const definitions4 = createOdfStyleDefinitions(book, xml2);
|
|
93086
|
+
let automatic = "", spreadsheet = "", validations = "", databaseRanges = "";
|
|
92835
93087
|
for (const record7 of book.unsupportedRecords ?? []) {
|
|
92836
93088
|
xml2.charge();
|
|
92837
93089
|
const v2 = odfObject(record7.data), node3 = odfObject(v2?.xml);
|
|
92838
93090
|
if (record7.source === "Gnumeric_OpenCalc:openoffice" && node3) {
|
|
92839
|
-
if (
|
|
92840
|
-
const content2 = odfChildren(node3).map((n) => xml2.retained(n)).join("");
|
|
92841
|
-
if (record7.kind === "automatic-styles") automatic += content2;
|
|
92842
|
-
else if (record7.kind === "master-styles") masters += content2;
|
|
92843
|
-
else if (record7.kind === "font-face-decls") fontFaces += content2;
|
|
92844
|
-
else styleBody += content2;
|
|
92845
|
-
} else if (record7.kind === "content-validations") validations += odfChildren(node3).map((n) => xml2.retained(n)).join("");
|
|
93091
|
+
if (record7.kind === "content-validations") validations += odfChildren(node3).map((n) => xml2.retained(n)).join("");
|
|
92846
93092
|
else if (record7.kind === "database-ranges") databaseRanges += xml2.retained(node3);
|
|
92847
93093
|
}
|
|
92848
93094
|
}
|
|
92849
93095
|
for (const [index2, sheet] of book.sheets.entries()) {
|
|
92850
93096
|
xml2.charge();
|
|
92851
|
-
const sheetStyle = "ta" + index2;
|
|
92852
93097
|
const view2 = odfObject(sheet.view?.gnumeric) ?? {}, properties = odfChildren(sheet.view?.odf).find((n) => odfObject(n)?.name === "table-properties");
|
|
92853
93098
|
const originalProperties = odfAttributes(properties, odfNamespaces.gnm);
|
|
92854
|
-
const print =
|
|
92855
|
-
|
|
92856
|
-
|
|
92857
|
-
|
|
92858
|
-
"
|
|
92859
|
-
"style:
|
|
92860
|
-
|
|
92861
|
-
|
|
92862
|
-
|
|
92863
|
-
"
|
|
92864
|
-
"
|
|
92865
|
-
|
|
92866
|
-
|
|
92867
|
-
|
|
93099
|
+
const print = odfPrintProperties((sheet.unsupportedRecords ?? []).filter((r) => r.kind === "PrintInformation").flatMap((r) => r.data ? [r.data] : []), xml2, extended);
|
|
93100
|
+
const layoutName = definitions4.register("stylesAutomatic", "style:page-layout", "pl" + index2, {}, e("style:page-layout-properties", print));
|
|
93101
|
+
const masterName = definitions4.register("masters", "style:master-page", "mp" + index2, { "style:page-layout-name": layoutName });
|
|
93102
|
+
const sheetStyle = definitions4.register(
|
|
93103
|
+
"contentAutomatic",
|
|
93104
|
+
"style:style",
|
|
93105
|
+
"ta" + index2,
|
|
93106
|
+
{ "style:family": "table", "style:master-page-name": masterName },
|
|
93107
|
+
e("style:table-properties", {
|
|
93108
|
+
"table:display": sheet.visibility && sheet.visibility !== "visible" ? "false" : "true",
|
|
93109
|
+
"style:writing-mode": Number(view2.RTL_Layout ?? 0) ? "rl-tb" : "lr-tb",
|
|
93110
|
+
...extended ? {
|
|
93111
|
+
"gnm:display-formulas": String(Boolean(Number(view2.DisplayFormulas ?? 0))),
|
|
93112
|
+
"gnm:display-col-header": String(!Number(view2.HideColHeader ?? 0)),
|
|
93113
|
+
"gnm:display-row-header": String(!Number(view2.HideRowHeader ?? 0)),
|
|
93114
|
+
"gnm:tab-color": originalProperties["tab-color"],
|
|
93115
|
+
"gnm:tab-text-color": originalProperties["tab-text-color"]
|
|
93116
|
+
} : {}
|
|
93117
|
+
})
|
|
93118
|
+
);
|
|
92868
93119
|
const addresses = /* @__PURE__ */ new Map(), rowCells = /* @__PURE__ */ new Map();
|
|
92869
93120
|
for (const cell of sheet.cells) {
|
|
92870
93121
|
coordinate(cell.row, MAX_SHEET_SIZE.rows);
|
|
@@ -93102,8 +93353,9 @@ function createOdfWriter(profile) {
|
|
|
93102
93353
|
}
|
|
93103
93354
|
}
|
|
93104
93355
|
xml2.charge(originalParagraphs.size);
|
|
93105
|
-
const renderedText = cell.displayedText ?? await renderCellText(cell, book, context2),
|
|
93356
|
+
const renderedText = cell.displayedText ?? await renderCellText(cell, book, context2), paragraph = originalParagraphs.get(key2) ?? [...originalParagraphs.values()].find((p2) => row >= p2.range.startRow && row <= p2.range.endRow && start >= p2.range.startColumn && start <= p2.range.endColumn);
|
|
93106
93357
|
const link = meta?.link ?? links.get(key2);
|
|
93358
|
+
const rendered2 = link ? xml2.escape(renderedText) : xml2.text(renderedText);
|
|
93107
93359
|
content2 += paragraph?.text === renderedText ? paragraph.xml : e("text:p", {}, link ? e("text:a", link, rendered2) : rendered2);
|
|
93108
93360
|
}
|
|
93109
93361
|
const next = !cell && !merge && meta ? Math.min(meta.range.endColumn + 1, stops.find((s) => s > start) ?? meta.range.endColumn + 1) : start + 1;
|
|
@@ -93142,7 +93394,8 @@ function createOdfWriter(profile) {
|
|
|
93142
93394
|
if (pair.axis !== "row" && pair.axis !== "column") throw new SsconvertError("invalid-request", "Invalid OpenDocument label orientation");
|
|
93143
93395
|
const dataSheet = pair.dataSheet === void 0 ? sheet : labelSheets.get(pair.dataSheet);
|
|
93144
93396
|
if (!dataSheet) throw new SsconvertError("unsupported-feature", "OpenDocument label data sheet is not exported");
|
|
93145
|
-
const
|
|
93397
|
+
const absolute = (row, column) => "$" + formatA1(0, column).slice(0, -1) + "$" + (row + 1);
|
|
93398
|
+
const address = (r, name5) => "$" + quoteFormulaString(name5, "'", odfGrammar) + "." + absolute(r.startRow, r.startColumn) + ":." + absolute(r.endRow, r.endColumn);
|
|
93146
93399
|
labelRanges += e("table:label-range", {
|
|
93147
93400
|
"table:label-cell-range-address": address(pair.labels, sheet.name),
|
|
93148
93401
|
"table:data-cell-range-address": address(pair.data, dataSheet.name),
|
|
@@ -93158,8 +93411,8 @@ function createOdfWriter(profile) {
|
|
|
93158
93411
|
parts.set(name5, encoder2.encode(value3));
|
|
93159
93412
|
}
|
|
93160
93413
|
part("mimetype", "application/vnd.oasis.opendocument.spreadsheet");
|
|
93161
|
-
part("content.xml", xml2.document("office:document-content", e("office:scripts") + e("office:font-face-decls") + e("office:automatic-styles", {}, automatic + cellStyles.styles.join("")) + e("office:body", {}, e("office:spreadsheet", {}, spreadsheet))));
|
|
93162
|
-
part("styles.xml", xml2.document("office:document-styles", e("office:font-face-decls", {},
|
|
93414
|
+
part("content.xml", xml2.document("office:document-content", e("office:scripts") + e("office:font-face-decls") + e("office:automatic-styles", {}, definitions4.render("contentAutomatic") + automatic + cellStyles.styles.join("")) + e("office:body", {}, e("office:spreadsheet", {}, spreadsheet))));
|
|
93415
|
+
part("styles.xml", xml2.document("office:document-styles", e("office:font-face-decls", {}, definitions4.render("fonts")) + e("office:styles", {}, definitions4.render("styles")) + e("office:automatic-styles", {}, definitions4.render("stylesAutomatic")) + e("office:master-styles", {}, definitions4.render("masters"))));
|
|
93163
93416
|
part("meta.xml", xml2.document("office:document-meta", e("office:meta", {}, e("meta:generator", {}, "Gnumeric/1.12.61"))));
|
|
93164
93417
|
part("settings.xml", xml2.document("office:document-settings", e("office:settings", {}, e(
|
|
93165
93418
|
"config:config-item-set",
|
|
@@ -159349,7 +159602,7 @@ function bounded2(value3, maximum, name5) {
|
|
|
159349
159602
|
if (!Number.isSafeInteger(value3) || value3 < 0 || value3 > maximum)
|
|
159350
159603
|
throw new SsconvertError("resource-limit", `ssconvert ${name5} limit exceeded`);
|
|
159351
159604
|
}
|
|
159352
|
-
function createEngine(supplied) {
|
|
159605
|
+
function createEngine(supplied = {}) {
|
|
159353
159606
|
const config2 = {
|
|
159354
159607
|
...supplied,
|
|
159355
159608
|
...supplied.entropy === void 0 ? {} : { entropy: Object.freeze({ read: supplied.entropy.read.bind(supplied.entropy) }) },
|
|
@@ -159357,16 +159610,19 @@ function createEngine(supplied) {
|
|
|
159357
159610
|
...supplied.fonts === void 0 ? {} : { fonts: Object.freeze({ resolve: supplied.fonts.resolve.bind(supplied.fonts) }) },
|
|
159358
159611
|
...supplied.password === void 0 ? {} : { password: Object.freeze({ read: supplied.password.read.bind(supplied.password) }) },
|
|
159359
159612
|
...supplied.runtimeFunctions === void 0 ? {} : { runtimeFunctions: snapshotRuntimeFunctions(supplied.runtimeFunctions) },
|
|
159613
|
+
codecs: supplied.codecs ?? [],
|
|
159360
159614
|
limits: Object.freeze({ ...defaultSsconvertLimits, ...supplied.limits }),
|
|
159361
159615
|
environment: Object.freeze({
|
|
159362
159616
|
...supplied.environment,
|
|
159363
|
-
|
|
159364
|
-
|
|
159617
|
+
locale: supplied.environment?.locale ?? "C",
|
|
159618
|
+
timezone: supplied.environment?.timezone ?? "UTC",
|
|
159619
|
+
cwd: supplied.filesystem?.cwd ?? supplied.environment?.cwd ?? supplied.environment?.env?.PWD ?? "/",
|
|
159620
|
+
env: Object.freeze({ ...supplied.environment?.env })
|
|
159365
159621
|
})
|
|
159366
159622
|
};
|
|
159367
159623
|
if (config2.datasource && Object.hasOwn(config2.runtimeFunctions ?? {}, "ATL_LAST"))
|
|
159368
159624
|
throw new TypeError("Conflicting ssconvert datasource runtime function: ATL_LAST");
|
|
159369
|
-
if ((supplied.filesystem?.cwd !== void 0 || supplied.environment
|
|
159625
|
+
if ((supplied.filesystem?.cwd !== void 0 || supplied.environment?.cwd !== void 0) && (!config2.environment.cwd.startsWith("/") || config2.environment.cwd.includes("\0")))
|
|
159370
159626
|
throw new TypeError("ssconvert cwd must be an absolute VFS path");
|
|
159371
159627
|
for (const name5 of ["inputBytes", "outputBytes", "cells", "sheets", "operations"]) {
|
|
159372
159628
|
const value3 = config2.limits[name5];
|
|
@@ -164094,4 +164350,4 @@ tslib/tslib.js:
|
|
|
164094
164350
|
@noble/ciphers/utils.js:
|
|
164095
164351
|
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
164096
164352
|
*/
|
|
164097
|
-
//# sourceMappingURL=chunk-
|
|
164353
|
+
//# sourceMappingURL=chunk-55AGFLG5.js.map
|