@poe-platform/safe-bash 0.1.821 → 0.1.823
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/dist/safe-bash/chunks/{chunk-HNT2MR4W.js → chunk-363QOIDR.js} +2 -1
- package/dist/safe-bash/chunks/chunk-AGHV53VF.js +42 -0
- package/dist/safe-bash/chunks/{chunk-VF3Q2V3E.js → chunk-RAFD5ZAH.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-67QE3JLU.js → chunk-TZRVK3NU.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-IRJS54AA.js → chunk-VWLQDZFF.js} +20 -12
- package/dist/safe-bash/chunks/{chunk-NAETSXBW.js → chunk-ZJAXMB5M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QX3WKBLI.js → chunk-36FV6BAG.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-ZSHXZ3XG.js → chunk-3EAZRKI4.js} +7 -7
- package/dist/safe-bash/command-chunks/chunk-64HIOP7Q.js +993 -0
- package/dist/safe-bash/command-chunks/{chunk-WOT2YXBT.js → chunk-7ZQVMPSB.js} +213 -42
- package/dist/safe-bash/command-chunks/{chunk-GRFJKJFN.js → chunk-AVSINNZ6.js} +233 -3
- package/dist/safe-bash/command-chunks/{chunk-BZLLQWRK.js → chunk-E5CDHXFA.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-RHXV2KG5.js → chunk-EO3RYGUZ.js} +1010 -58
- package/dist/safe-bash/command-chunks/{chunk-MCUDSE4H.js → chunk-EWECMOQ5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RTUDDAAY.js → chunk-O3KFOFJM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-SLD5A7IL.js → chunk-OU5UEUZN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RKAL5VFP.js → chunk-PLVFJ6FF.js} +255 -616
- package/dist/safe-bash/command-chunks/{chunk-CJIFJ45R.js → chunk-QBCEAYQT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4Q3HP33O.js → chunk-RGKHTSUY.js} +146 -123
- package/dist/safe-bash/command-chunks/{chunk-I7MEH76L.js → chunk-UYNJF5QN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IAHYG67O.js → chunk-V5ZBRM5R.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-R4NPYXQX.js → chunk-WDTWJFPK.js} +320 -67
- package/dist/safe-bash/command-chunks/{chunk-GQV5RWMN.js → chunk-ZFXHSFTU.js} +1 -1
- package/dist/safe-bash/command-chunks/{prompt-tool-debug-ERJKK3XZ.js → prompt-tool-debug-3POFNRYP.js} +5 -5
- package/dist/safe-bash/commands/bc/index.browser.js +1 -1
- package/dist/safe-bash/commands/llm/index.browser.js +3 -1
- package/dist/safe-bash/commands/llm/index.js +1 -1
- package/dist/safe-bash/commands/python/executor.browser.js +12 -1
- package/dist/safe-bash/commands/python/executor.js +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +23 -1
- package/dist/safe-bash/commands/python/index.js +1 -1
- package/dist/safe-bash/core.browser.js +2 -2
- package/dist/safe-bash/full-core.browser.js +30 -6
- package/dist/safe-bash/plugins/index.browser.js +3 -3
- package/dist/safe-bash/registry-entry.browser.js +2 -2
- package/dist/safe-bash/search.browser.js +1 -1
- package/dist/safe-bash/shell/runtime.d.ts +2 -2
- package/dist/safe-bash/shell/runtime.js +11 -2
- package/dist/safe-bash/shell/sync-extra-evaluators.js +12 -12
- package/dist/safe-bash/shell-entry.browser.js +2 -2
- package/dist/safe-bash-command-llm/collections.js +24 -65
- package/dist/safe-bash-command-llm/command.js +6 -6
- package/dist/safe-bash-command-llm/fragment-loaders.d.ts +3 -2
- package/dist/safe-bash-command-llm/index.d.ts +3 -2
- package/dist/safe-bash-command-llm/index.js +10 -8
- package/dist/safe-bash-command-llm/loader-provider.d.ts +25 -0
- package/dist/safe-bash-command-llm/openai-sse.js +2 -2
- package/dist/safe-bash-command-llm/openai.js +4 -4
- package/dist/safe-bash-command-llm/providers/index.js +4 -4
- package/dist/safe-bash-command-llm/providers/openai.js +4 -4
- package/dist/safe-bash-command-llm/python-unicode.d.ts +2 -0
- package/dist/safe-bash-command-llm/templates.d.ts +7 -2
- package/dist/safe-bash-command-llm/types.d.ts +7 -1
- package/dist/safe-bash-command-mcp/index.browser.js +3 -0
- package/dist/safe-bash-command-mcp/index.js +3 -0
- package/dist/safe-bash-command-patch/index.js +2 -2
- package/dist/safe-bash-command-patch/patch-publication.js +1 -1
- package/dist/safe-bash-command-patch/patch.js +2 -2
- package/dist/safe-bash-command-python/build-backend.d.ts +51 -0
- package/dist/safe-bash-command-python/build-dependencies.d.ts +12 -0
- package/dist/safe-bash-command-python/build-environment.d.ts +3 -0
- package/dist/safe-bash-command-python/build-wheel.d.ts +8 -0
- package/dist/safe-bash-command-python/executor.d.ts +12 -2
- package/dist/safe-bash-command-python/executor.js +26 -4
- package/dist/safe-bash-command-python/index.js +26 -4
- package/dist/safe-bash-command-python/jspi.js +2 -2
- package/dist/safe-bash-command-python/llm-assets-node.js +1 -1
- package/dist/safe-bash-command-python/llm-fragment-loader.d.ts +6 -0
- package/dist/safe-bash-command-python/llm-functions-loader.d.ts +5 -1
- package/dist/safe-bash-command-python/llm-loader-discovery.d.ts +13 -0
- package/dist/safe-bash-command-python/llm-package-manager.d.ts +7 -0
- package/dist/safe-bash-command-python/llm-template-loader.d.ts +6 -0
- package/dist/safe-bash-command-python/manifest.d.ts +13 -0
- package/dist/safe-bash-command-python/provisioning.d.ts +33 -5
- package/dist/safe-bash-command-python/provisioning.js +1 -1
- package/dist/safe-bash-command-python/source-environment.d.ts +9 -0
- package/dist/safe-bash-command-python/source-snapshot.d.ts +8 -0
- package/dist/safe-bash-command-python/worker.js +3 -185
- package/dist/safe-bash-csv-engine/index.js +1 -1
- package/dist/safe-bash-csv-engine/python-iso2022.d.ts +21 -0
- package/dist/safe-bash-csv-engine/python-utf7.d.ts +18 -0
- package/dist/safe-bash-csv-engine/text-decoder.d.ts +2 -0
- package/dist/safe-bash-csv-engine/text-decoder.js +7 -3
- package/dist/safe-bash-zip-engine/index.js +1 -1
- package/dist/safe-bash-zip-engine/zip/repair.js +1 -1
- package/dist/safe-bash-zip-engine/zip/sfx.js +1 -1
- package/dist/safe-bash-zip-engine/zip-format.d.ts +3 -1
- package/dist/safe-bash-zip-engine/zip-format.js +1 -1
- package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +1 -1
- package/dist/safe-playwright-cloudflare/shell-browser-resource.js +35 -20
- package/package.json +3 -3
- package/dist/safe-bash/chunks/chunk-PSD2RSOS.js +0 -31
- package/dist/safe-bash/command-chunks/chunk-5EFNQ6FY.js +0 -458
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// packages/safe-bash/src/commands/llm/index.ts
|
|
2
|
-
import { LlmCancelToolCall, createElevenLabsProvider, createLlmCommand, createLlmCommands, createLlmConfiguration, createLlmFragmentLoaders, createLlmFragmentSource, createLlmInputBudget, createLlmService, createLlmSpool, createLlmTemplateStore, createLlmToolRegistry, createLlmUrlFragmentSource, createLlmUrlSource, createOpenAiProvider, encodeLlmBase64, evaluateLlmTemplate, executeLlmToolCalls, findExtractedRange, getLlmAttachmentUrlId, getLlmFragmentPrefix, getLlmModelAliases, llmCommands, llmReferenceVersion, llmTemplateUsesInput, loadLlmPluginFragments, openAiChatOptions, parseLlmSchemaDsl, resolveLlmSchemaInput, resolveLlmUrlAttachment, selectLlmModelByQuery, selectLlmTools, serializeLlmJsonString, serializeLlmJsonValue, serializeLlmTokenUsage, serializeOpenAiChatRequest, streamLlmToolChain, templateYaml, validateLlmTemplateParameters, validateModelOptions } from "../../safe-bash-command-llm/index.js";
|
|
2
|
+
import { LlmCancelToolCall, LlmLoaderLookupError, createElevenLabsProvider, createLlmCommand, createLlmCommands, createLlmConfiguration, createLlmFragmentLoaders, createLlmFragmentSource, createLlmInputBudget, createLlmService, createLlmSpool, createLlmTemplateStore, createLlmToolRegistry, createLlmUrlFragmentSource, createLlmUrlSource, createOpenAiProvider, encodeLlmBase64, evaluateLlmTemplate, executeLlmToolCalls, findExtractedRange, getLlmAttachmentUrlId, getLlmFragmentPrefix, getLlmModelAliases, llmCommands, llmReferenceVersion, llmTemplateUsesInput, loadLlmPluginFragments, openAiChatOptions, parseLlmSchemaDsl, resolveLlmSchemaInput, resolveLlmUrlAttachment, selectLlmModelByQuery, selectLlmTools, serializeLlmJsonString, serializeLlmJsonValue, serializeLlmTokenUsage, serializeOpenAiChatRequest, streamLlmToolChain, templateYaml, validateLlmTemplateParameters, validateModelOptions } from "../../safe-bash-command-llm/index.js";
|
|
3
3
|
|
|
4
4
|
export {
|
|
5
5
|
LlmCancelToolCall,
|
|
6
|
+
LlmLoaderLookupError,
|
|
6
7
|
createElevenLabsProvider,
|
|
7
8
|
createLlmCommand,
|
|
8
9
|
createLlmCommands,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// packages/safe-bash/src/commands/python/index.ts
|
|
2
|
+
import { PythonFailure, PythonPackageConflictError, createPythonBuildBackend, createPythonBuildDependencies, createPythonBuildEnvironment, createPythonCommands, createPythonExecutorCommands, createPythonExecutorPool, createPythonHostBridge, createPythonJspiAssets, createPythonJspiExecutor, createPythonJspiNativeCall, createPythonJspiStatResult, createPythonJspiTrampoline, createPythonLlmCapability, createPythonLlmFragmentLoader, createPythonLlmLoaderDiscovery, createPythonLlmLoaderProvider, createPythonLlmPackageManager, createPythonLlmTemplateLoader, createPythonLlmToolLoader, createPythonPackageCache, createPythonPackageEnvironment, createPythonPackageManifestStore, createPythonShellCapability, createPythonSourcePackageEnvironment, createPythonSourceSnapshot, inspectPythonCapabilities, installPythonLlmDependencies, installPythonLlmPackages, publishPythonBuildWheel, pythonCommands, pythonDocumentPackages, pythonExecutorCommands, pythonHostFailureCode, pythonLlmDependencies, pythonLlmPackages } from "../../safe-bash-command-python/index.js";
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
PythonFailure,
|
|
6
|
+
PythonPackageConflictError,
|
|
7
|
+
createPythonBuildBackend,
|
|
8
|
+
createPythonBuildDependencies,
|
|
9
|
+
createPythonBuildEnvironment,
|
|
10
|
+
createPythonCommands,
|
|
11
|
+
createPythonExecutorCommands,
|
|
12
|
+
createPythonExecutorPool,
|
|
13
|
+
createPythonHostBridge,
|
|
14
|
+
createPythonJspiAssets,
|
|
15
|
+
createPythonJspiExecutor,
|
|
16
|
+
createPythonJspiNativeCall,
|
|
17
|
+
createPythonJspiStatResult,
|
|
18
|
+
createPythonJspiTrampoline,
|
|
19
|
+
createPythonLlmCapability,
|
|
20
|
+
createPythonLlmFragmentLoader,
|
|
21
|
+
createPythonLlmLoaderDiscovery,
|
|
22
|
+
createPythonLlmLoaderProvider,
|
|
23
|
+
createPythonLlmPackageManager,
|
|
24
|
+
createPythonLlmTemplateLoader,
|
|
25
|
+
createPythonLlmToolLoader,
|
|
26
|
+
createPythonPackageCache,
|
|
27
|
+
createPythonPackageEnvironment,
|
|
28
|
+
createPythonPackageManifestStore,
|
|
29
|
+
createPythonShellCapability,
|
|
30
|
+
createPythonSourcePackageEnvironment,
|
|
31
|
+
createPythonSourceSnapshot,
|
|
32
|
+
inspectPythonCapabilities,
|
|
33
|
+
installPythonLlmDependencies,
|
|
34
|
+
installPythonLlmPackages,
|
|
35
|
+
publishPythonBuildWheel,
|
|
36
|
+
pythonCommands,
|
|
37
|
+
pythonDocumentPackages,
|
|
38
|
+
pythonExecutorCommands,
|
|
39
|
+
pythonHostFailureCode,
|
|
40
|
+
pythonLlmDependencies,
|
|
41
|
+
pythonLlmPackages
|
|
42
|
+
};
|
|
@@ -14405,10 +14405,16 @@ var BudgetedPipeStageSink = class {
|
|
|
14405
14405
|
}
|
|
14406
14406
|
}
|
|
14407
14407
|
writeSync(chunk) {
|
|
14408
|
-
this.
|
|
14409
|
-
this.
|
|
14408
|
+
if (!this.canWriteSync(chunk.byteLength)) return false;
|
|
14409
|
+
this.signal.throwIfAborted();
|
|
14410
|
+
if (!(chunk instanceof Uint8Array)) throw new TypeError("Shell output must be Uint8Array");
|
|
14411
|
+
const budget = this.budget;
|
|
14412
|
+
if (chunk.byteLength > budget.limits.maxOutputBytes - budget.bytes) budget.fail("maxOutputBytes");
|
|
14413
|
+
budget.assertPipelineInput(chunk.byteLength);
|
|
14414
|
+
budget.bytes += chunk.byteLength;
|
|
14410
14415
|
this.writable.write(chunk);
|
|
14411
14416
|
if (chunk.byteLength && this.written) this.written.add(this.index);
|
|
14417
|
+
return true;
|
|
14412
14418
|
}
|
|
14413
14419
|
write(chunk) {
|
|
14414
14420
|
try {
|
|
@@ -29331,6 +29337,9 @@ function exportedVariablesView(rawState) {
|
|
|
29331
29337
|
}
|
|
29332
29338
|
var evalSyncFd = (...args) => syncCommandEvaluators.evalSyncFd?.(...args);
|
|
29333
29339
|
var evalSyncRg = (...args) => syncCommandEvaluators.evalSyncRg?.(...args);
|
|
29340
|
+
function canWriteBuiltinOutput(budget, pipe, byteLength3) {
|
|
29341
|
+
return (!pipe || pipe.canWriteSync(byteLength3)) && (budget.bytes + byteLength3 <= budget.maxOutputBytesSmi || byteLength3 <= budget.limits.maxOutputBytes - budget.bytes);
|
|
29342
|
+
}
|
|
29334
29343
|
var createFmtEngine = (...args) => syncCommandEvaluators.createFmtEngine(...args);
|
|
29335
29344
|
var parseFmtArguments = (...args) => syncCommandEvaluators.parseFmtArguments(...args);
|
|
29336
29345
|
var evalSyncCal = (...args) => syncCommandEvaluators.evalSyncCal?.(...args);
|
|
@@ -29484,11 +29493,13 @@ function initializeSyncPrototypes() {
|
|
|
29484
29493
|
}
|
|
29485
29494
|
});
|
|
29486
29495
|
Object.assign(BudgetedPipeStageSink.prototype, {
|
|
29487
|
-
canWriteSync() {
|
|
29496
|
+
canWriteSync(byteLength3 = 0) {
|
|
29488
29497
|
if (this.signal.aborted) return false;
|
|
29489
29498
|
const w = this.writable;
|
|
29490
29499
|
const pipe = w._pipe;
|
|
29491
|
-
|
|
29500
|
+
const avail = pipe?.availableBytes ?? 0;
|
|
29501
|
+
const hwm = pipe?.highWaterMark ?? 0;
|
|
29502
|
+
return Boolean(w.open && pipe && !pipe.failed && !pipe.signal?.aborted && pipe.readerReferences && (!pipe.writes || pipe.writes.size === 0) && (byteLength3 > 0 ? avail + byteLength3 <= hwm : avail < hwm));
|
|
29492
29503
|
}
|
|
29493
29504
|
});
|
|
29494
29505
|
}
|
|
@@ -39051,7 +39062,7 @@ var syncExtraRuntimeMethods = {
|
|
|
39051
39062
|
const encoded = disc.status === 0 ? encodeRedirectTextWithNewlineToScratch(disc.text) ?? fastSharedTextEncoder2.encode(`${disc.text}
|
|
39052
39063
|
`) : void 0;
|
|
39053
39064
|
const byteLength3 = encoded ? encoded.byteLength : 0;
|
|
39054
|
-
if (byteLength3 === 0 || this.budget
|
|
39065
|
+
if (byteLength3 === 0 || canWriteBuiltinOutput(this.budget, fastPipeSink, byteLength3)) {
|
|
39055
39066
|
if (rawState.extensions && !rawState.extensions.eventDepth) publishCommandSpelling(rawState, commandSpelling(command));
|
|
39056
39067
|
const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
|
|
39057
39068
|
this.budget.tick();
|
|
@@ -39085,7 +39096,7 @@ var syncExtraRuntimeMethods = {
|
|
|
39085
39096
|
const encoded = encodeRedirectTextWithNewlineToScratch(rawState.cwd) ?? fastSharedTextEncoder2.encode(`${rawState.cwd}
|
|
39086
39097
|
`);
|
|
39087
39098
|
const byteLength3 = encoded.byteLength;
|
|
39088
|
-
if (this.budget
|
|
39099
|
+
if (canWriteBuiltinOutput(this.budget, fastPipeSink, byteLength3)) {
|
|
39089
39100
|
if (rawState.extensions && !rawState.extensions.eventDepth) publishCommandSpelling(rawState, commandSpelling(command));
|
|
39090
39101
|
const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
|
|
39091
39102
|
this.budget.tick();
|
|
@@ -39154,7 +39165,7 @@ var syncExtraRuntimeMethods = {
|
|
|
39154
39165
|
const encoded = encodeRedirectTextWithNewlineToScratch(outText) ?? fastSharedTextEncoder2.encode(`${outText}
|
|
39155
39166
|
`);
|
|
39156
39167
|
const byteLength3 = encoded.byteLength;
|
|
39157
|
-
if (this.budget
|
|
39168
|
+
if (canWriteBuiltinOutput(this.budget, fastPipeSink, byteLength3)) {
|
|
39158
39169
|
if (rawState.extensions && !rawState.extensions.eventDepth) publishCommandSpelling(rawState, commandSpelling(command));
|
|
39159
39170
|
const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
|
|
39160
39171
|
this.budget.tick();
|
|
@@ -39252,7 +39263,7 @@ var syncExtraRuntimeMethods = {
|
|
|
39252
39263
|
if (preEncoded !== void 0 || formatted2 !== void 0) {
|
|
39253
39264
|
const encoded = preEncoded ?? encodeRedirectTextToScratch(formatted2);
|
|
39254
39265
|
const byteLength3 = encoded.byteLength;
|
|
39255
|
-
if (this.budget
|
|
39266
|
+
if (canWriteBuiltinOutput(this.budget, fastPipeSink, byteLength3)) {
|
|
39256
39267
|
const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
|
|
39257
39268
|
this.budget.tick();
|
|
39258
39269
|
if (fastSyncSink) {
|
|
@@ -44747,15 +44758,12 @@ ${s1}
|
|
|
44747
44758
|
}
|
|
44748
44759
|
const chunk = fastSharedTextEncoder2.encode(this._syncStdoutBatch);
|
|
44749
44760
|
this._syncStdoutBatch = "";
|
|
44750
|
-
if (io.stdout instanceof BudgetedSyncSink && io.stdout.write === BudgetedSyncSink.prototype.write || io.stdout instanceof Capture && io.stdout.write === Capture.prototype.write) {
|
|
44761
|
+
if (io.stdout instanceof BudgetedSyncSink && io.stdout.write === BudgetedSyncSink.prototype.write || io.stdout instanceof Capture && io.stdout.write === Capture.prototype.write || io.stdout instanceof BudgetedPipeStageSink && io.stdout.write === BudgetedPipeStageSink.prototype.write && io.stdout.canWriteSync(chunk.byteLength)) {
|
|
44751
44762
|
if (io.stdout.budget !== this.budget) {
|
|
44752
44763
|
if (chunk.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
44753
44764
|
this.budget.bytes += chunk.byteLength;
|
|
44754
44765
|
}
|
|
44755
44766
|
io.stdout.writeSync(chunk);
|
|
44756
|
-
} else if (io.stdout instanceof BudgetedPipeStageSink && io.stdout.canWriteSync()) {
|
|
44757
|
-
if (chunk.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
44758
|
-
io.stdout.writeSync(chunk);
|
|
44759
44767
|
} else {
|
|
44760
44768
|
if (budgetedSinks.get(io.stdout)?.budget !== this.budget) {
|
|
44761
44769
|
if (chunk.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/safe-bash-command-llm/src/request-source.ts
|
|
2
|
-
function waitForSource(start, signal) {
|
|
2
|
+
function waitForSource(start, signal, late) {
|
|
3
3
|
signal.throwIfAborted();
|
|
4
4
|
return new Promise((resolve, reject) => {
|
|
5
5
|
const abort = () => {
|
|
@@ -13,8 +13,10 @@ function waitForSource(start, signal) {
|
|
|
13
13
|
}).then(
|
|
14
14
|
(value) => {
|
|
15
15
|
signal.removeEventListener("abort", abort);
|
|
16
|
-
if (signal.aborted)
|
|
17
|
-
|
|
16
|
+
if (signal.aborted) {
|
|
17
|
+
if (late) void Promise.resolve().then(() => late(value)).catch(() => void 0);
|
|
18
|
+
reject(signal.reason);
|
|
19
|
+
} else resolve(value);
|
|
18
20
|
},
|
|
19
21
|
(error) => {
|
|
20
22
|
signal.removeEventListener("abort", abort);
|
|
@@ -66,10 +66,10 @@ async function exact(source, offset, length, signal) {
|
|
|
66
66
|
async function readZipSpan(source, index, signal) {
|
|
67
67
|
return decode(await exact(source, index * recordBytes, recordBytes, signal), 0);
|
|
68
68
|
}
|
|
69
|
-
async function validateZipSpans(index, count, factory, signal, chunkSize, initial, centralStart) {
|
|
69
|
+
async function validateZipSpans(index, count, factory, signal, chunkSize, initial, centralStart, allowUnreferencedData = false) {
|
|
70
70
|
if (!count) {
|
|
71
71
|
const start = initial ?? centralStart;
|
|
72
|
-
if (start !== centralStart) fail("ZIP unreferenced local data is unsupported");
|
|
72
|
+
if (!allowUnreferencedData && start !== centralStart) fail("ZIP unreferenced local data is unsupported");
|
|
73
73
|
return start;
|
|
74
74
|
}
|
|
75
75
|
const windowRecords = Math.max(1, Math.floor(Math.min(chunkSize, 65536) / recordBytes));
|
|
@@ -136,11 +136,11 @@ async function validateZipSpans(index, count, factory, signal, chunkSize, initia
|
|
|
136
136
|
let covered = prefix;
|
|
137
137
|
while (record) {
|
|
138
138
|
signal.throwIfAborted();
|
|
139
|
-
if (record.start !== covered) fail("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
|
|
139
|
+
if (record.start < covered || !allowUnreferencedData && record.start !== covered) fail("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
|
|
140
140
|
covered = record.end;
|
|
141
141
|
record = await sorted.next();
|
|
142
142
|
}
|
|
143
|
-
if (covered !== centralStart) fail("ZIP unreferenced local data is unsupported");
|
|
143
|
+
if (!allowUnreferencedData && covered !== centralStart) fail("ZIP unreferenced local data is unsupported");
|
|
144
144
|
return prefix;
|
|
145
145
|
} finally {
|
|
146
146
|
try {
|
|
@@ -489,10 +489,10 @@ async function readZipArchive(input, limits, signal, profile = {}) {
|
|
|
489
489
|
const prefix = profile.disks ? 4 : profile.prefix ? spans[0]?.start ?? reader.centralStart : 0;
|
|
490
490
|
let covered = prefix;
|
|
491
491
|
for (const span of spans) {
|
|
492
|
-
if (span.start !== covered) fail2("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
|
|
492
|
+
if (span.start < covered || !profile.allowUnreferencedData && span.start !== covered) fail2("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
|
|
493
493
|
covered = span.end;
|
|
494
494
|
}
|
|
495
|
-
if (covered !== reader.centralStart) fail2("ZIP unreferenced local data is unsupported");
|
|
495
|
+
if (!profile.allowUnreferencedData && covered !== reader.centralStart) fail2("ZIP unreferenced local data is unsupported");
|
|
496
496
|
if (profile.grow) for (const entry of entries) {
|
|
497
497
|
const start = entry.growStart, length = entry.growLength;
|
|
498
498
|
zipGrowRecords.set(entry, input instanceof Uint8Array ? await reader.bytes.subarray(start, start + length) : { length, version: entry.growVersion, source: () => reader.bytes.stream(start, length) });
|
|
@@ -507,7 +507,7 @@ async function readZipIndexedArchive(input, limits, signal, createSpool, profile
|
|
|
507
507
|
try {
|
|
508
508
|
for await (const record of scanZipDirectory(reader, limits, signal, profile)) await spool.append(encodeZipSpan(record));
|
|
509
509
|
const index = await spool.finish();
|
|
510
|
-
const prefix = await validateZipSpans(index, reader.members, createSpool, signal, reader.chunkSize, profile.disks ? 4 : profile.prefix ? void 0 : 0, reader.centralStart);
|
|
510
|
+
const prefix = await validateZipSpans(index, reader.members, createSpool, signal, reader.chunkSize, profile.disks ? 4 : profile.prefix ? void 0 : 0, reader.centralStart, profile.allowUnreferencedData);
|
|
511
511
|
const entries = {
|
|
512
512
|
length: reader.members,
|
|
513
513
|
async get(position) {
|