sv 0.16.6 → 0.17.1
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/bin.mjs +1 -1
- package/dist/{engine-DbEL5s1q.mjs → engine-1Kj9XHT7.mjs} +1396 -2854
- package/dist/{engine-BhR6Vrxy.d.mts → engine-5Sg3lJiQ.d.mts} +1 -1
- package/dist/shared.json +96 -0
- package/dist/src/index.d.mts +1 -1
- package/dist/src/index.mjs +1 -1
- package/dist/src/testing.d.mts +3 -3
- package/dist/src/testing.mjs +1 -1
- package/dist/templates/addon/package.json +3 -3
- package/package.json +5 -6
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { AGENTS, COMMANDS, Walker, coerceVersion, color, constructCommand, createPrinter, dedent, defineEnv, detect, downloadJson, fileExists, isVersionUnsupportedBelow, js, loadFile, loadPackageJson, minVersion, parse, pnpm, resolveCommand, resolveCommandArray, sanitizeName, saveFile, svelte, svelteConfig, transforms } from "@sveltejs/sv-utils";
|
|
2
|
+
import { AGENTS, COMMANDS, KIT3_TSCONFIG, KIT3_TSCONFIG_DEFAULT, Walker, coerceVersion, color, constructCommand, createPrinter, dedent, defineEnv, detect, downloadJson, fileExists, isKit3, isVersionUnsupportedBelow, js, libSubpathImports, loadFile, loadPackageJson, minVersion, parse, pnpm, resolveCommand, resolveCommandArray, resolveLibPrefix, sanitizeName, saveFile, svelte, svelteConfig, transforms } from "@sveltejs/sv-utils";
|
|
3
|
+
import * as fs$1 from "node:fs";
|
|
3
4
|
import fs, { closeSync, existsSync, openSync, readSync, statSync } from "node:fs";
|
|
5
|
+
import * as path$1 from "node:path";
|
|
4
6
|
import path, { basename, delimiter, dirname, isAbsolute, join, normalize, resolve } from "node:path";
|
|
5
7
|
import { promisify, stripVTControlCharacters, styleText } from "node:util";
|
|
6
8
|
import V, { cwd, stdin, stdout } from "node:process";
|
|
@@ -10,10 +12,11 @@ import { ReadStream } from "node:tty";
|
|
|
10
12
|
import { fileURLToPath } from "node:url";
|
|
11
13
|
import childProcess, { exec, spawn, spawnSync } from "node:child_process";
|
|
12
14
|
import { pipeline } from "node:stream/promises";
|
|
13
|
-
import { PassThrough } from "node:stream";
|
|
15
|
+
import { PassThrough, Writable } from "node:stream";
|
|
14
16
|
import { EventEmitter } from "node:events";
|
|
15
17
|
import crypto from "node:crypto";
|
|
16
|
-
import
|
|
18
|
+
import * as fsp from "node:fs/promises";
|
|
19
|
+
import { cpus, platform } from "node:os";
|
|
17
20
|
import { createGunzip } from "node:zlib";
|
|
18
21
|
//#region \0rolldown/runtime.js
|
|
19
22
|
var __create = Object.create;
|
|
@@ -1348,7 +1351,7 @@ ${i ? styleText("cyan", x$1) : ""}
|
|
|
1348
1351
|
//#endregion
|
|
1349
1352
|
//#region package.json
|
|
1350
1353
|
var name = "sv";
|
|
1351
|
-
var version = "0.
|
|
1354
|
+
var version = "0.17.1";
|
|
1352
1355
|
//#endregion
|
|
1353
1356
|
//#region src/core/errors.ts
|
|
1354
1357
|
var UnsupportedError = class extends Error {
|
|
@@ -1361,6 +1364,7 @@ var UnsupportedError = class extends Error {
|
|
|
1361
1364
|
};
|
|
1362
1365
|
//#endregion
|
|
1363
1366
|
//#region src/core/common.ts
|
|
1367
|
+
const RX_IMPORT_ONLY = /^\s*@\S+\s*$/;
|
|
1364
1368
|
const NO_PREFIX = "--no-";
|
|
1365
1369
|
let options$8 = [];
|
|
1366
1370
|
function getLongFlag(flags) {
|
|
@@ -1530,7 +1534,7 @@ function updateAgent(projectPath, language, packageManager, loadedAddons) {
|
|
|
1530
1534
|
const agentFiles = [
|
|
1531
1535
|
"AGENTS.md",
|
|
1532
1536
|
"GEMINI.md",
|
|
1533
|
-
"CLAUDE.md"
|
|
1537
|
+
".claude/CLAUDE.md"
|
|
1534
1538
|
];
|
|
1535
1539
|
const languageLabel = language === "typescript" ? "TypeScript" : language === "checkjs" ? "JavaScript (JSDoc)" : "None";
|
|
1536
1540
|
const packageManagerLabel = packageManager ?? "npm";
|
|
@@ -1549,6 +1553,7 @@ function updateAgent(projectPath, language, packageManager, loadedAddons) {
|
|
|
1549
1553
|
const agentPath = path.join(projectPath, fileName);
|
|
1550
1554
|
if (!fs.existsSync(agentPath)) continue;
|
|
1551
1555
|
let content = fs.readFileSync(agentPath, "utf-8");
|
|
1556
|
+
if (RX_IMPORT_ONLY.test(content)) continue;
|
|
1552
1557
|
content = content.replace(existingSectionPattern, "");
|
|
1553
1558
|
content = configSection + content;
|
|
1554
1559
|
fs.writeFileSync(agentPath, content);
|
|
@@ -5734,6 +5739,263 @@ function createOptionBuilder(options) {
|
|
|
5734
5739
|
};
|
|
5735
5740
|
}
|
|
5736
5741
|
//#endregion
|
|
5742
|
+
//#region src/addons/ai-tools.ts
|
|
5743
|
+
const REGEX_MD = /\.md$/;
|
|
5744
|
+
const CLIENTS = {
|
|
5745
|
+
"claude-code": {
|
|
5746
|
+
label: "Claude Code",
|
|
5747
|
+
pluginSettings: {
|
|
5748
|
+
path: ".claude/settings.json",
|
|
5749
|
+
marketplace: "svelte",
|
|
5750
|
+
repo: "sveltejs/ai-tools",
|
|
5751
|
+
id: "svelte@svelte"
|
|
5752
|
+
},
|
|
5753
|
+
agentPath: "AGENTS.md",
|
|
5754
|
+
agentLink: {
|
|
5755
|
+
path: ".claude/CLAUDE.md",
|
|
5756
|
+
contents: "@../AGENTS.md\n"
|
|
5757
|
+
},
|
|
5758
|
+
configPath: ".mcp.json",
|
|
5759
|
+
skillsPath: ".claude/skills",
|
|
5760
|
+
agentsPath: ".claude/agents",
|
|
5761
|
+
mcpOptions: {
|
|
5762
|
+
typeLocal: "stdio",
|
|
5763
|
+
typeRemote: "http",
|
|
5764
|
+
env: true
|
|
5765
|
+
}
|
|
5766
|
+
},
|
|
5767
|
+
cursor: {
|
|
5768
|
+
label: "Cursor",
|
|
5769
|
+
agentPath: "AGENTS.md",
|
|
5770
|
+
configPath: ".cursor/mcp.json",
|
|
5771
|
+
skillsPath: ".cursor/skills",
|
|
5772
|
+
agentsPath: ".cursor/agents",
|
|
5773
|
+
mcpOptions: {}
|
|
5774
|
+
},
|
|
5775
|
+
gemini: {
|
|
5776
|
+
label: "Gemini",
|
|
5777
|
+
agentPath: "GEMINI.md",
|
|
5778
|
+
configPath: ".gemini/settings.json",
|
|
5779
|
+
skillsPath: ".gemini/skills",
|
|
5780
|
+
agentsPath: ".gemini/agents",
|
|
5781
|
+
schema: "https://raw.githubusercontent.com/google-gemini/gemini-cli/main/schemas/settings.schema.json",
|
|
5782
|
+
mcpOptions: {}
|
|
5783
|
+
},
|
|
5784
|
+
opencode: {
|
|
5785
|
+
label: "OpenCode",
|
|
5786
|
+
pluginOnly: true,
|
|
5787
|
+
agentPath: "AGENTS.md",
|
|
5788
|
+
configPath: ".opencode/opencode.json",
|
|
5789
|
+
schema: "https://opencode.ai/config.json",
|
|
5790
|
+
customData: { plugin: ["@sveltejs/opencode"] },
|
|
5791
|
+
extraFiles: [{
|
|
5792
|
+
path: ".opencode/svelte.json",
|
|
5793
|
+
data: { $schema: "https://svelte.dev/opencode/schema.json" }
|
|
5794
|
+
}]
|
|
5795
|
+
},
|
|
5796
|
+
vscode: {
|
|
5797
|
+
label: "VS Code",
|
|
5798
|
+
agentPath: "AGENTS.md",
|
|
5799
|
+
configPath: ".vscode/mcp.json",
|
|
5800
|
+
skillsPath: ".github/skills",
|
|
5801
|
+
agentsPath: ".github/agents",
|
|
5802
|
+
agentExtension: ".agent.md",
|
|
5803
|
+
mcpOptions: { serversKey: "servers" }
|
|
5804
|
+
},
|
|
5805
|
+
other: {
|
|
5806
|
+
label: "Other",
|
|
5807
|
+
agentPath: "AGENTS.md"
|
|
5808
|
+
}
|
|
5809
|
+
};
|
|
5810
|
+
const acceptsTools = (client) => Boolean(client && !client.pluginOnly && (client.skillsPath || client.agentsPath || client.configPath));
|
|
5811
|
+
const wantsLooseTools = (client, delivery) => acceptsTools(client) && (!client.pluginSettings || delivery !== "plugin");
|
|
5812
|
+
const wantsMcpConfig = (client, delivery) => Boolean(client?.mcpOptions) && wantsLooseTools(client, delivery);
|
|
5813
|
+
const TOOLS = {
|
|
5814
|
+
mcp: {
|
|
5815
|
+
label: "MCP server",
|
|
5816
|
+
kind: "mcp"
|
|
5817
|
+
},
|
|
5818
|
+
"svelte-code-writer": {
|
|
5819
|
+
label: "svelte-code-writer",
|
|
5820
|
+
kind: "skill",
|
|
5821
|
+
hint: "skill"
|
|
5822
|
+
},
|
|
5823
|
+
"svelte-core-bestpractices": {
|
|
5824
|
+
label: "svelte-core-bestpractices",
|
|
5825
|
+
kind: "skill",
|
|
5826
|
+
hint: "skill"
|
|
5827
|
+
},
|
|
5828
|
+
"svelte-file-editor": {
|
|
5829
|
+
label: "svelte-file-editor",
|
|
5830
|
+
kind: "agent",
|
|
5831
|
+
hint: "sub-agent"
|
|
5832
|
+
}
|
|
5833
|
+
};
|
|
5834
|
+
var ai_tools_default = defineAddon({
|
|
5835
|
+
id: "ai-tools",
|
|
5836
|
+
shortDescription: "Svelte AI tools",
|
|
5837
|
+
homepage: "https://svelte.dev/docs/ai",
|
|
5838
|
+
options: defineAddonOptions().add("ide", {
|
|
5839
|
+
question: "Which client would you like to use?",
|
|
5840
|
+
type: "multiselect",
|
|
5841
|
+
default: [],
|
|
5842
|
+
options: Object.entries(CLIENTS).map(([value, client]) => ({
|
|
5843
|
+
value,
|
|
5844
|
+
label: client.label
|
|
5845
|
+
})),
|
|
5846
|
+
required: true
|
|
5847
|
+
}).add("delivery", {
|
|
5848
|
+
question: "How would you like to add the Svelte tools?",
|
|
5849
|
+
type: "select",
|
|
5850
|
+
default: "plugin",
|
|
5851
|
+
options: [{
|
|
5852
|
+
value: "plugin",
|
|
5853
|
+
label: "Svelte plugin",
|
|
5854
|
+
hint: "recommended, auto-installs & updates"
|
|
5855
|
+
}, {
|
|
5856
|
+
value: "tools",
|
|
5857
|
+
label: "Individual tools",
|
|
5858
|
+
hint: "choose exactly what to add"
|
|
5859
|
+
}],
|
|
5860
|
+
condition: ({ ide }) => ide.some((i) => CLIENTS[i]?.pluginSettings)
|
|
5861
|
+
}).add("tools", {
|
|
5862
|
+
question: "Which tools would you like to add?",
|
|
5863
|
+
type: "multiselect",
|
|
5864
|
+
default: Object.keys(TOOLS),
|
|
5865
|
+
options: Object.entries(TOOLS).map(([value, t]) => ({
|
|
5866
|
+
value,
|
|
5867
|
+
label: t.label,
|
|
5868
|
+
hint: t.hint
|
|
5869
|
+
})),
|
|
5870
|
+
required: false,
|
|
5871
|
+
condition: ({ ide, delivery }) => ide.some((i) => wantsLooseTools(CLIENTS[i], delivery))
|
|
5872
|
+
}).add("mcpSetup", {
|
|
5873
|
+
question: "Which MCP setup would you like to use?",
|
|
5874
|
+
type: "select",
|
|
5875
|
+
default: "remote",
|
|
5876
|
+
options: [{
|
|
5877
|
+
value: "local",
|
|
5878
|
+
label: "Local",
|
|
5879
|
+
hint: "will use stdio"
|
|
5880
|
+
}, {
|
|
5881
|
+
value: "remote",
|
|
5882
|
+
label: "Remote",
|
|
5883
|
+
hint: "will use a remote endpoint"
|
|
5884
|
+
}],
|
|
5885
|
+
condition: ({ ide, delivery, tools }) => (tools === void 0 || tools.includes("mcp")) && ide.some((i) => wantsMcpConfig(CLIENTS[i], delivery))
|
|
5886
|
+
}).build(),
|
|
5887
|
+
run: ({ sv, options }) => {
|
|
5888
|
+
const usePlugin = options.delivery === "plugin";
|
|
5889
|
+
const selected = options.tools ?? Object.keys(TOOLS);
|
|
5890
|
+
const selectedSkills = selected.filter((t) => TOOLS[t]?.kind === "skill");
|
|
5891
|
+
const selectedAgents = selected.filter((t) => TOOLS[t]?.kind === "agent");
|
|
5892
|
+
const wantsMcp = selected.includes("mcp");
|
|
5893
|
+
const getLocalConfig = (o) => {
|
|
5894
|
+
return {
|
|
5895
|
+
...o?.typeLocal ? { type: o.typeLocal } : {},
|
|
5896
|
+
command: o?.command ?? "npx",
|
|
5897
|
+
...o?.env ? { env: {} } : {},
|
|
5898
|
+
...o?.args === null ? {} : { args: o?.args ?? ["-y", "@sveltejs/mcp"] }
|
|
5899
|
+
};
|
|
5900
|
+
};
|
|
5901
|
+
const getRemoteConfig = (o) => {
|
|
5902
|
+
return {
|
|
5903
|
+
...o?.typeRemote ? { type: o.typeRemote } : {},
|
|
5904
|
+
url: "https://mcp.svelte.dev/mcp"
|
|
5905
|
+
};
|
|
5906
|
+
};
|
|
5907
|
+
const filesAdded = [];
|
|
5908
|
+
const filesExistingAlready = [];
|
|
5909
|
+
const sharedFiles = getSharedFiles();
|
|
5910
|
+
const mcpFiles = sharedFiles.filter((file) => file.include.includes("mcp"));
|
|
5911
|
+
const skillFiles = sharedFiles.filter((file) => file.include.includes("skills"));
|
|
5912
|
+
const agentFiles = sharedFiles.filter((file) => file.include.includes("agents"));
|
|
5913
|
+
const agentFile = mcpFiles.find((file) => file.name === "AGENTS.md");
|
|
5914
|
+
const addFile = (path, contents) => {
|
|
5915
|
+
sv.file(path, (content) => {
|
|
5916
|
+
if (content) {
|
|
5917
|
+
filesExistingAlready.push(path);
|
|
5918
|
+
return false;
|
|
5919
|
+
}
|
|
5920
|
+
if (!filesAdded.includes(path)) filesAdded.push(path);
|
|
5921
|
+
return contents;
|
|
5922
|
+
});
|
|
5923
|
+
};
|
|
5924
|
+
for (const ide of options.ide) {
|
|
5925
|
+
const client = CLIENTS[ide];
|
|
5926
|
+
if (!client) continue;
|
|
5927
|
+
if (client.pluginSettings && usePlugin) {
|
|
5928
|
+
const plugin = client.pluginSettings;
|
|
5929
|
+
sv.file(plugin.path, transforms.json(({ data }) => {
|
|
5930
|
+
data.extraKnownMarketplaces ??= {};
|
|
5931
|
+
data.extraKnownMarketplaces[plugin.marketplace] ??= { source: {
|
|
5932
|
+
source: "github",
|
|
5933
|
+
repo: plugin.repo
|
|
5934
|
+
} };
|
|
5935
|
+
data.enabledPlugins ??= {};
|
|
5936
|
+
data.enabledPlugins[plugin.id] = true;
|
|
5937
|
+
}));
|
|
5938
|
+
continue;
|
|
5939
|
+
}
|
|
5940
|
+
if (!client.agentPath) continue;
|
|
5941
|
+
const { mcpOptions, agentPath, agentLink, configPath, skillsPath, agentsPath, agentExtension, schema, customData, extraFiles } = client;
|
|
5942
|
+
if (!filesAdded.includes(agentPath)) sv.file(agentPath, (content) => {
|
|
5943
|
+
if (content) {
|
|
5944
|
+
filesExistingAlready.push(agentPath);
|
|
5945
|
+
return false;
|
|
5946
|
+
}
|
|
5947
|
+
filesAdded.push(agentPath);
|
|
5948
|
+
return agentFile?.contents ?? "";
|
|
5949
|
+
});
|
|
5950
|
+
if (agentLink) addFile(agentLink.path, agentLink.contents);
|
|
5951
|
+
const writeMcp = Boolean(mcpOptions) && wantsMcp;
|
|
5952
|
+
if (configPath && (writeMcp || customData)) sv.file(configPath, transforms.json(({ data }) => {
|
|
5953
|
+
if (schema) data["$schema"] = schema;
|
|
5954
|
+
if (customData) for (const [key, value] of Object.entries(customData)) data[key] = value;
|
|
5955
|
+
if (writeMcp) {
|
|
5956
|
+
const key = mcpOptions.serversKey ?? "mcpServers";
|
|
5957
|
+
data[key] ??= {};
|
|
5958
|
+
data[key].svelte = options.mcpSetup === "local" ? getLocalConfig(mcpOptions) : getRemoteConfig(mcpOptions);
|
|
5959
|
+
}
|
|
5960
|
+
}));
|
|
5961
|
+
if (extraFiles) for (const extra of extraFiles) sv.file(extra.path, transforms.json(({ data }) => {
|
|
5962
|
+
for (const [key, value] of Object.entries(extra.data)) data[key] = value;
|
|
5963
|
+
}));
|
|
5964
|
+
if (skillsPath) for (const file of skillFiles) {
|
|
5965
|
+
if (!selectedSkills.includes(file.name.split("/")[0])) continue;
|
|
5966
|
+
addFile(`${skillsPath}/${file.name}`, file.contents);
|
|
5967
|
+
}
|
|
5968
|
+
if (agentsPath) for (const file of agentFiles) {
|
|
5969
|
+
if (!selectedAgents.includes(file.name.replace(REGEX_MD, ""))) continue;
|
|
5970
|
+
const ext = agentExtension ?? ".md";
|
|
5971
|
+
addFile(`${agentsPath}/${file.name.replace(REGEX_MD, ext)}`, file.contents);
|
|
5972
|
+
}
|
|
5973
|
+
}
|
|
5974
|
+
if (filesExistingAlready.length > 0) R$1.warn(`${filesExistingAlready.map((path) => color.path(path)).join(", ")} already exists, we didn't touch ${filesExistingAlready.length > 1 ? "them" : "it"}. See ${color.website("https://svelte.dev/docs/ai")} for manual setup.`);
|
|
5975
|
+
},
|
|
5976
|
+
nextSteps({ options, cwd }) {
|
|
5977
|
+
const steps = [];
|
|
5978
|
+
for (const ide of options.ide) {
|
|
5979
|
+
const client = CLIENTS[ide];
|
|
5980
|
+
if (!client?.pluginSettings) continue;
|
|
5981
|
+
const plugin = client.pluginSettings;
|
|
5982
|
+
const settingsPath = path.resolve(cwd, plugin.path);
|
|
5983
|
+
if (!fs.existsSync(settingsPath)) continue;
|
|
5984
|
+
let pluginEnabled = false;
|
|
5985
|
+
try {
|
|
5986
|
+
pluginEnabled = Boolean(JSON.parse(fs.readFileSync(settingsPath, "utf8")).enabledPlugins?.[plugin.id]);
|
|
5987
|
+
} catch {}
|
|
5988
|
+
if (!pluginEnabled) continue;
|
|
5989
|
+
const looseDirs = [client.skillsPath, client.agentsPath].filter((dir) => Boolean(dir) && fs.existsSync(path.resolve(cwd, dir)) && fs.readdirSync(path.resolve(cwd, dir)).some((entry) => Object.keys(TOOLS).includes(entry.replace(REGEX_MD, ""))));
|
|
5990
|
+
if (looseDirs.length === 0) continue;
|
|
5991
|
+
steps.push(`${client.label}: the Svelte plugin is enabled and ${looseDirs.map((d) => color.path(d)).join(" + ")} also exist${looseDirs.length > 1 ? "" : "s"} - remove ${looseDirs.length > 1 ? "them" : "it"} (or disable the plugin) to avoid duplicate skills/sub-agents.`);
|
|
5992
|
+
}
|
|
5993
|
+
if (options.delivery === "plugin" && options.ide.includes("claude-code")) steps.push(`Open the project in Claude Code and trust the workspace - the Svelte plugin installs automatically.`);
|
|
5994
|
+
if (options.ide.includes("other")) steps.push(`For other clients: ${color.website(`https://svelte.dev/docs/ai/${options.mcpSetup ?? "remote"}-setup#Other-clients`)}`);
|
|
5995
|
+
return steps;
|
|
5996
|
+
}
|
|
5997
|
+
});
|
|
5998
|
+
//#endregion
|
|
5737
5999
|
//#region src/addons/common.ts
|
|
5738
6000
|
const ESLINT_VERSION = "^10.4.1";
|
|
5739
6001
|
const addEslintConfigPrettier = transforms.script(({ ast, js }) => {
|
|
@@ -5886,6 +6148,7 @@ var better_auth_default = defineAddon({
|
|
|
5886
6148
|
runsAfter("experimental");
|
|
5887
6149
|
},
|
|
5888
6150
|
run: ({ sv, cwd, language, options, directory, dependencyVersion, file }) => {
|
|
6151
|
+
const lib = resolveLibPrefix(dependencyVersion("@sveltejs/kit"));
|
|
5889
6152
|
const svelteVersion = dependencyVersion("svelte");
|
|
5890
6153
|
const svelte5 = !!svelteVersion && coerceVersion(svelteVersion).major === 5;
|
|
5891
6154
|
const [ts, s5] = createPrinter(language === "ts", svelte5);
|
|
@@ -5932,7 +6195,7 @@ var better_auth_default = defineAddon({
|
|
|
5932
6195
|
}
|
|
5933
6196
|
sv.file(`${directory.lib}/server/auth.${language}`, transforms.script(({ ast, comments, js }) => {
|
|
5934
6197
|
js.imports.addNamed(ast, {
|
|
5935
|
-
from:
|
|
6198
|
+
from: `${lib}/server/db`,
|
|
5936
6199
|
imports: [d1 ? "getDb" : "db"]
|
|
5937
6200
|
});
|
|
5938
6201
|
js.imports.addNamed(ast, {
|
|
@@ -5989,7 +6252,7 @@ var better_auth_default = defineAddon({
|
|
|
5989
6252
|
/**
|
|
5990
6253
|
* DO NOT USE!
|
|
5991
6254
|
*
|
|
5992
|
-
* This instance is used by the \`
|
|
6255
|
+
* This instance is used by the \`auth\` CLI for schema generation ONLY.
|
|
5993
6256
|
* To access \`auth\` at runtime, use \`event.locals.auth\`.
|
|
5994
6257
|
*/
|
|
5995
6258
|
export const auth = createAuth(null${ts("!")});`;
|
|
@@ -6013,7 +6276,7 @@ var better_auth_default = defineAddon({
|
|
|
6013
6276
|
const authConfigPath = `${directory.lib}/server/auth.${language}`;
|
|
6014
6277
|
const authSchemaPath = `${directory.lib}/server/db/auth.schema.${language}`;
|
|
6015
6278
|
sv.file(file.package, transforms.json(({ data, json }) => {
|
|
6016
|
-
json.packageScriptsUpsert(data, "auth:schema", `
|
|
6279
|
+
json.packageScriptsUpsert(data, "auth:schema", `auth generate --config ${authConfigPath} --output ${authSchemaPath} --yes`);
|
|
6017
6280
|
}));
|
|
6018
6281
|
sv.file(`${directory.lib}/server/db/auth.schema.${language}`, transforms.text(({ content }) => {
|
|
6019
6282
|
if (content) return false;
|
|
@@ -6028,7 +6291,7 @@ var better_auth_default = defineAddon({
|
|
|
6028
6291
|
sv.file("src/app.d.ts", transforms.script(({ ast, comments, js }) => {
|
|
6029
6292
|
if (d1) js.imports.addNamed(ast, {
|
|
6030
6293
|
imports: ["createAuth"],
|
|
6031
|
-
from:
|
|
6294
|
+
from: `${lib}/server/auth`
|
|
6032
6295
|
});
|
|
6033
6296
|
js.imports.addNamed(ast, {
|
|
6034
6297
|
imports: ["User", "Session"],
|
|
@@ -6052,7 +6315,7 @@ var better_auth_default = defineAddon({
|
|
|
6052
6315
|
});
|
|
6053
6316
|
js.imports.addNamed(ast, {
|
|
6054
6317
|
imports: [d1 ? "createAuth" : "auth"],
|
|
6055
|
-
from:
|
|
6318
|
+
from: `${lib}/server/auth`
|
|
6056
6319
|
});
|
|
6057
6320
|
env.importEnv(ast, js, ["building"]);
|
|
6058
6321
|
const handleContent = dedent`
|
|
@@ -6160,7 +6423,7 @@ var better_auth_default = defineAddon({
|
|
|
6160
6423
|
import { fail, redirect } from '@sveltejs/kit';
|
|
6161
6424
|
${ts("import type { Actions } from './$types';")}
|
|
6162
6425
|
${ts("import type { PageServerLoad } from './$types';")}
|
|
6163
|
-
${!d1 ?
|
|
6426
|
+
${!d1 ? `import { auth } from '${lib}/server/auth';` : ""}
|
|
6164
6427
|
${needsAPIError ? "import { APIError } from 'better-auth/api';" : ""}
|
|
6165
6428
|
|
|
6166
6429
|
export const load${ts(": PageServerLoad")} = (event) => {
|
|
@@ -6229,7 +6492,7 @@ var better_auth_default = defineAddon({
|
|
|
6229
6492
|
import { redirect } from '@sveltejs/kit';
|
|
6230
6493
|
${ts("import type { Actions } from './$types';")}
|
|
6231
6494
|
${ts("import type { PageServerLoad } from './$types';")}
|
|
6232
|
-
${!d1 ?
|
|
6495
|
+
${!d1 ? `import { auth } from '${lib}/server/auth';` : ""}
|
|
6233
6496
|
|
|
6234
6497
|
export const load${ts(": PageServerLoad")} = (event) => {
|
|
6235
6498
|
if (!event.locals.user) {
|
|
@@ -6368,9 +6631,14 @@ var drizzle_default = defineAddon({
|
|
|
6368
6631
|
group: "client",
|
|
6369
6632
|
default: "libsql",
|
|
6370
6633
|
options: [
|
|
6634
|
+
{
|
|
6635
|
+
value: "node-sqlite",
|
|
6636
|
+
label: "node:sqlite",
|
|
6637
|
+
hint: "built-in to Node.js and Deno"
|
|
6638
|
+
},
|
|
6371
6639
|
{
|
|
6372
6640
|
value: "better-sqlite3",
|
|
6373
|
-
hint: "for
|
|
6641
|
+
hint: "for server environments"
|
|
6374
6642
|
},
|
|
6375
6643
|
{
|
|
6376
6644
|
value: "libsql",
|
|
@@ -6396,7 +6664,7 @@ var drizzle_default = defineAddon({
|
|
|
6396
6664
|
runsAfter("experimental");
|
|
6397
6665
|
if (!isKit) return unsupported("Requires SvelteKit");
|
|
6398
6666
|
},
|
|
6399
|
-
run: ({ sv, language, options, directory, dependencyVersion, cwd, cancel, file
|
|
6667
|
+
run: ({ sv, language, options, directory, dependencyVersion, cwd, cancel, file }) => {
|
|
6400
6668
|
const [ts] = createPrinter(language === "ts");
|
|
6401
6669
|
const baseDBPath = path.resolve(cwd, directory.lib, "server", "db");
|
|
6402
6670
|
const paths = {
|
|
@@ -6413,9 +6681,8 @@ var drizzle_default = defineAddon({
|
|
|
6413
6681
|
if (options.postgresql === "neon") sv.devDependency("@neondatabase/serverless", "^1.1.0");
|
|
6414
6682
|
if (options.postgresql === "postgres.js") sv.devDependency("postgres", "^3.4.9");
|
|
6415
6683
|
if (options.sqlite === "better-sqlite3") {
|
|
6416
|
-
sv.dependency("better-sqlite3", "^
|
|
6684
|
+
sv.dependency("better-sqlite3", "^13.0.2");
|
|
6417
6685
|
sv.devDependency("@types/better-sqlite3", "^7.6.13");
|
|
6418
|
-
if (packageManager === "pnpm") sv.file(file.findUp("pnpm-workspace.yaml"), pnpm.allowBuilds("better-sqlite3"));
|
|
6419
6686
|
}
|
|
6420
6687
|
if (options.sqlite === "libsql" || options.sqlite === "turso") sv.devDependency("@libsql/client", "^0.17.3");
|
|
6421
6688
|
sv.file(".env", generateEnv(options, false));
|
|
@@ -6513,7 +6780,13 @@ var drizzle_default = defineAddon({
|
|
|
6513
6780
|
})
|
|
6514
6781
|
`) });
|
|
6515
6782
|
}));
|
|
6516
|
-
|
|
6783
|
+
if (isKit3(dependencyVersion("@sveltejs/kit"))) {
|
|
6784
|
+
const configFile = language === "ts" ? "tsconfig.json" : "jsconfig.json";
|
|
6785
|
+
if (fileExists(cwd, configFile)) sv.file(configFile, transforms.json(({ data }) => {
|
|
6786
|
+
const include = data.include ??= ["src"];
|
|
6787
|
+
if (!include.includes(`drizzle.config.${language}`)) include.push(`drizzle.config.${language}`);
|
|
6788
|
+
}));
|
|
6789
|
+
} else svelteConfig.edit({
|
|
6517
6790
|
sv,
|
|
6518
6791
|
cwd
|
|
6519
6792
|
}, ({ override, js }) => {
|
|
@@ -6641,6 +6914,17 @@ var drizzle_default = defineAddon({
|
|
|
6641
6914
|
clientExpression = js.common.parseExpression(`createClient({ url: ${dbUrl}, authToken: ${dbToken} })`);
|
|
6642
6915
|
} else clientExpression = js.common.parseExpression(`createClient({ url: ${dbUrl} })`);
|
|
6643
6916
|
}
|
|
6917
|
+
if (options.sqlite === "node-sqlite") {
|
|
6918
|
+
js.imports.addNamed(ast, {
|
|
6919
|
+
from: "node:sqlite",
|
|
6920
|
+
imports: ["DatabaseSync"]
|
|
6921
|
+
});
|
|
6922
|
+
js.imports.addNamed(ast, {
|
|
6923
|
+
from: "drizzle-orm/node-sqlite",
|
|
6924
|
+
imports: ["drizzle"]
|
|
6925
|
+
});
|
|
6926
|
+
clientExpression = js.common.parseExpression(`new DatabaseSync(${dbUrl})`);
|
|
6927
|
+
}
|
|
6644
6928
|
if (options.mysql === "mysql2" || options.mysql === "planetscale") {
|
|
6645
6929
|
js.imports.addDefault(ast, {
|
|
6646
6930
|
from: "mysql2/promise",
|
|
@@ -6743,7 +7027,11 @@ const generateEnv = (opts, isExample) => transforms.text(({ content, text }) =>
|
|
|
6743
7027
|
let value;
|
|
6744
7028
|
const comment = ["Drizzle"];
|
|
6745
7029
|
if (opts.docker) value = `"${opts.database === "mysql" ? "mysql" : "postgres"}://root:mysecretpassword@localhost:${PORTS[opts.database]}/local"`;
|
|
6746
|
-
else if (
|
|
7030
|
+
else if ([
|
|
7031
|
+
"better-sqlite3",
|
|
7032
|
+
"libsql",
|
|
7033
|
+
"node-sqlite"
|
|
7034
|
+
].includes(opts.sqlite)) value = opts.sqlite === "libsql" ? "file:local.db" : "local.db";
|
|
6747
7035
|
else if (opts.sqlite === "turso") if (isExample) {
|
|
6748
7036
|
value = "\"libsql://db-name-user.turso.io\"";
|
|
6749
7037
|
comment.push("Replace with your DB credentials!", {
|
|
@@ -6929,12 +7217,25 @@ const FEATURES = {
|
|
|
6929
7217
|
hint: "kit ^2 only",
|
|
6930
7218
|
inNext: false
|
|
6931
7219
|
},
|
|
6932
|
-
handleRenderingErrors: {
|
|
7220
|
+
handleRenderingErrors: {
|
|
7221
|
+
label: "rendering error boundaries",
|
|
7222
|
+
hint: "kit ^2 only",
|
|
7223
|
+
inNext: false
|
|
7224
|
+
},
|
|
6933
7225
|
forkPreloads: {
|
|
6934
7226
|
label: "forked preloading",
|
|
6935
7227
|
off: true
|
|
6936
7228
|
}
|
|
6937
7229
|
};
|
|
7230
|
+
const SOURCE_EXTENSIONS = [
|
|
7231
|
+
".svelte",
|
|
7232
|
+
".svelte.ts",
|
|
7233
|
+
".svelte.js",
|
|
7234
|
+
".ts",
|
|
7235
|
+
".js",
|
|
7236
|
+
".svx",
|
|
7237
|
+
".md"
|
|
7238
|
+
];
|
|
6938
7239
|
const KIT3_PEERS = {
|
|
6939
7240
|
vite: "^8.0.0",
|
|
6940
7241
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
@@ -6966,7 +7267,7 @@ var experimental_default = defineAddon({
|
|
|
6966
7267
|
required: false
|
|
6967
7268
|
}).build(),
|
|
6968
7269
|
setup: ({ runsAfter }) => runsAfter("sveltekitAdapter"),
|
|
6969
|
-
run: ({ sv, cwd, options, language, dependencyVersion }) => {
|
|
7270
|
+
run: ({ sv, cwd, options, language, directory, dependencyVersion }) => {
|
|
6970
7271
|
const kitNext = options.versions.includes("kit");
|
|
6971
7272
|
if (kitNext) {
|
|
6972
7273
|
sv.devDependency("@sveltejs/kit", "next");
|
|
@@ -6982,6 +7283,23 @@ var experimental_default = defineAddon({
|
|
|
6982
7283
|
};
|
|
6983
7284
|
for (const name of Object.keys(deps)) if (name.startsWith("@sveltejs/adapter-")) sv.devDependency(name, "next");
|
|
6984
7285
|
}
|
|
7286
|
+
if (kitNext) {
|
|
7287
|
+
for (const name of ["tsconfig.json", "jsconfig.json"]) {
|
|
7288
|
+
if (!fileExists(cwd, name)) continue;
|
|
7289
|
+
sv.file(name, transforms.json(({ data }) => {
|
|
7290
|
+
data.extends = KIT3_TSCONFIG;
|
|
7291
|
+
data.include ??= [directory.src];
|
|
7292
|
+
for (const [key, value] of Object.entries(data.compilerOptions ?? {})) if (KIT3_TSCONFIG_DEFAULT[key] === value) delete data.compilerOptions[key];
|
|
7293
|
+
}));
|
|
7294
|
+
}
|
|
7295
|
+
sv.file("package.json", transforms.json(({ data }) => {
|
|
7296
|
+
data.imports = {
|
|
7297
|
+
...libSubpathImports(directory.lib),
|
|
7298
|
+
...data.imports
|
|
7299
|
+
};
|
|
7300
|
+
}));
|
|
7301
|
+
for (const relative of sourceFiles(cwd, directory.src)) sv.file(relative, (content) => content.includes("$lib") ? content.replaceAll("$lib", "#lib") : false);
|
|
7302
|
+
}
|
|
6985
7303
|
const config = {};
|
|
6986
7304
|
for (const [name, f] of Object.entries(FEATURES)) {
|
|
6987
7305
|
if (!options.features.includes(name)) continue;
|
|
@@ -6997,147 +7315,12 @@ var experimental_default = defineAddon({
|
|
|
6997
7315
|
}, ({ override }) => override(config));
|
|
6998
7316
|
}
|
|
6999
7317
|
});
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
type: "multiselect",
|
|
7007
|
-
default: [],
|
|
7008
|
-
options: [
|
|
7009
|
-
{
|
|
7010
|
-
value: "claude-code",
|
|
7011
|
-
label: "claude code"
|
|
7012
|
-
},
|
|
7013
|
-
{
|
|
7014
|
-
value: "cursor",
|
|
7015
|
-
label: "Cursor"
|
|
7016
|
-
},
|
|
7017
|
-
{
|
|
7018
|
-
value: "gemini",
|
|
7019
|
-
label: "Gemini"
|
|
7020
|
-
},
|
|
7021
|
-
{
|
|
7022
|
-
value: "opencode",
|
|
7023
|
-
label: "opencode"
|
|
7024
|
-
},
|
|
7025
|
-
{
|
|
7026
|
-
value: "vscode",
|
|
7027
|
-
label: "VSCode"
|
|
7028
|
-
},
|
|
7029
|
-
{
|
|
7030
|
-
value: "other",
|
|
7031
|
-
label: "Other"
|
|
7032
|
-
}
|
|
7033
|
-
],
|
|
7034
|
-
required: true
|
|
7035
|
-
}).add("setup", {
|
|
7036
|
-
question: "What setup would you like to use?",
|
|
7037
|
-
type: "select",
|
|
7038
|
-
default: "remote",
|
|
7039
|
-
options: [{
|
|
7040
|
-
value: "local",
|
|
7041
|
-
label: "Local",
|
|
7042
|
-
hint: "will use stdio"
|
|
7043
|
-
}, {
|
|
7044
|
-
value: "remote",
|
|
7045
|
-
label: "Remote",
|
|
7046
|
-
hint: "will use a remote endpoint"
|
|
7047
|
-
}],
|
|
7048
|
-
required: true,
|
|
7049
|
-
condition: ({ ide }) => !(ide.length === 1 && ide.includes("opencode"))
|
|
7050
|
-
}).build(),
|
|
7051
|
-
run: ({ sv, options }) => {
|
|
7052
|
-
const getLocalConfig = (o) => {
|
|
7053
|
-
return {
|
|
7054
|
-
...o?.typeLocal ? { type: o.typeLocal } : {},
|
|
7055
|
-
command: o?.command ?? "npx",
|
|
7056
|
-
...o?.env ? { env: {} } : {},
|
|
7057
|
-
...o?.args === null ? {} : { args: o?.args ?? ["-y", "@sveltejs/mcp"] }
|
|
7058
|
-
};
|
|
7059
|
-
};
|
|
7060
|
-
const getRemoteConfig = (o) => {
|
|
7061
|
-
return {
|
|
7062
|
-
...o?.typeRemote ? { type: o.typeRemote } : {},
|
|
7063
|
-
url: "https://mcp.svelte.dev/mcp"
|
|
7064
|
-
};
|
|
7065
|
-
};
|
|
7066
|
-
const configurator = {
|
|
7067
|
-
"claude-code": {
|
|
7068
|
-
agentPath: "CLAUDE.md",
|
|
7069
|
-
configPath: ".mcp.json",
|
|
7070
|
-
mcpOptions: {
|
|
7071
|
-
typeLocal: "stdio",
|
|
7072
|
-
typeRemote: "http",
|
|
7073
|
-
env: true
|
|
7074
|
-
}
|
|
7075
|
-
},
|
|
7076
|
-
cursor: {
|
|
7077
|
-
agentPath: "AGENTS.md",
|
|
7078
|
-
configPath: ".cursor/mcp.json",
|
|
7079
|
-
mcpOptions: {}
|
|
7080
|
-
},
|
|
7081
|
-
gemini: {
|
|
7082
|
-
agentPath: "GEMINI.md",
|
|
7083
|
-
configPath: ".gemini/settings.json",
|
|
7084
|
-
schema: "https://raw.githubusercontent.com/google-gemini/gemini-cli/main/schemas/settings.schema.json",
|
|
7085
|
-
mcpOptions: {}
|
|
7086
|
-
},
|
|
7087
|
-
opencode: {
|
|
7088
|
-
agentPath: "AGENTS.md",
|
|
7089
|
-
configPath: ".opencode/opencode.json",
|
|
7090
|
-
schema: "https://opencode.ai/config.json",
|
|
7091
|
-
customData: { plugin: ["@sveltejs/opencode"] },
|
|
7092
|
-
extraFiles: [{
|
|
7093
|
-
path: ".opencode/svelte.json",
|
|
7094
|
-
data: { $schema: "https://svelte.dev/opencode/schema.json" }
|
|
7095
|
-
}]
|
|
7096
|
-
},
|
|
7097
|
-
vscode: {
|
|
7098
|
-
agentPath: "AGENTS.md",
|
|
7099
|
-
configPath: ".vscode/mcp.json",
|
|
7100
|
-
mcpOptions: { serversKey: "servers" }
|
|
7101
|
-
},
|
|
7102
|
-
other: { other: true }
|
|
7103
|
-
};
|
|
7104
|
-
const filesAdded = [];
|
|
7105
|
-
const filesExistingAlready = [];
|
|
7106
|
-
const agentFile = getSharedFiles().filter((file) => file.include.includes("mcp")).find((file) => file.name === "AGENTS.md");
|
|
7107
|
-
for (const ide of options.ide) {
|
|
7108
|
-
const value = configurator[ide];
|
|
7109
|
-
if (value === void 0) continue;
|
|
7110
|
-
if ("other" in value) continue;
|
|
7111
|
-
const { mcpOptions, agentPath, configPath, schema, customData, extraFiles } = value;
|
|
7112
|
-
if (!filesAdded.includes(agentPath)) sv.file(agentPath, (content) => {
|
|
7113
|
-
if (content) {
|
|
7114
|
-
filesExistingAlready.push(agentPath);
|
|
7115
|
-
return false;
|
|
7116
|
-
}
|
|
7117
|
-
filesAdded.push(agentPath);
|
|
7118
|
-
return agentFile?.contents ?? "";
|
|
7119
|
-
});
|
|
7120
|
-
sv.file(configPath, transforms.json(({ data }) => {
|
|
7121
|
-
if (schema) data["$schema"] = schema;
|
|
7122
|
-
if (customData) for (const [key, value] of Object.entries(customData)) data[key] = value;
|
|
7123
|
-
if (mcpOptions) {
|
|
7124
|
-
const key = mcpOptions.serversKey ?? "mcpServers";
|
|
7125
|
-
data[key] ??= {};
|
|
7126
|
-
data[key].svelte = options.setup === "local" ? getLocalConfig(mcpOptions) : getRemoteConfig(mcpOptions);
|
|
7127
|
-
}
|
|
7128
|
-
}));
|
|
7129
|
-
if (extraFiles) for (const extra of extraFiles) sv.file(extra.path, transforms.json(({ data }) => {
|
|
7130
|
-
for (const [key, value] of Object.entries(extra.data)) data[key] = value;
|
|
7131
|
-
}));
|
|
7132
|
-
}
|
|
7133
|
-
if (filesExistingAlready.length > 0) R$1.warn(`${filesExistingAlready.map((path) => color.path(path)).join(", ")} already exists, we didn't touch ${filesExistingAlready.length > 1 ? "them" : "it"}. See ${color.website("https://svelte.dev/docs/mcp/overview#Usage")} for manual setup.`);
|
|
7134
|
-
},
|
|
7135
|
-
nextSteps({ options }) {
|
|
7136
|
-
const steps = [];
|
|
7137
|
-
if (options.ide.includes("other")) steps.push(`For other clients: ${color.website(`https://svelte.dev/docs/mcp/${options.setup}-setup#Other-clients`)}`);
|
|
7138
|
-
return steps;
|
|
7139
|
-
}
|
|
7140
|
-
});
|
|
7318
|
+
/** Workspace-relative source files under `src`, for the `$lib` -> `#lib` rewrite. */
|
|
7319
|
+
function sourceFiles(cwd, src) {
|
|
7320
|
+
const root = path.resolve(cwd, src);
|
|
7321
|
+
if (!fs.existsSync(root)) return [];
|
|
7322
|
+
return fs.readdirSync(root, { recursive: true }).map((entry) => path.join(src, entry)).filter((relative) => SOURCE_EXTENSIONS.some((ext) => relative.endsWith(ext)) && fs.statSync(path.resolve(cwd, relative)).isFile());
|
|
7323
|
+
}
|
|
7141
7324
|
//#endregion
|
|
7142
7325
|
//#region src/addons/mdsvex.ts
|
|
7143
7326
|
var mdsvex_default = defineAddon({
|
|
@@ -7206,11 +7389,15 @@ var paraglide_default = defineAddon({
|
|
|
7206
7389
|
shortDescription: "i18n",
|
|
7207
7390
|
homepage: "https://inlang.com/m/gerre34r/library-inlang-paraglideJs",
|
|
7208
7391
|
options: options$3,
|
|
7209
|
-
setup: ({ isKit, unsupported }) => {
|
|
7392
|
+
setup: ({ isKit, unsupported, runsAfter }) => {
|
|
7210
7393
|
if (!isKit) unsupported("Requires SvelteKit");
|
|
7394
|
+
runsAfter("experimental");
|
|
7211
7395
|
},
|
|
7212
|
-
run: ({ sv, options, file, language, directory }) => {
|
|
7396
|
+
run: ({ sv, options, file, language, directory, dependencyVersion }) => {
|
|
7213
7397
|
const [ts] = createPrinter(language === "ts");
|
|
7398
|
+
const kitRange = dependencyVersion("@sveltejs/kit");
|
|
7399
|
+
const lib = resolveLibPrefix(kitRange);
|
|
7400
|
+
const pathType = isKit3(kitRange) ? "Path" : "Pathname";
|
|
7214
7401
|
const paraglideOutDir = `${directory.lib}/paraglide`;
|
|
7215
7402
|
sv.devDependency("@inlang/paraglide-js", "^2.18.2");
|
|
7216
7403
|
sv.file(file.viteConfig, transforms.script(({ ast, js }) => {
|
|
@@ -7227,7 +7414,7 @@ var paraglide_default = defineAddon({
|
|
|
7227
7414
|
}));
|
|
7228
7415
|
sv.file(`src/hooks.${language}`, transforms.script(({ ast, comments, js }) => {
|
|
7229
7416
|
js.imports.addNamed(ast, {
|
|
7230
|
-
from:
|
|
7417
|
+
from: `${lib}/paraglide/runtime`,
|
|
7231
7418
|
imports: ["deLocalizeUrl"]
|
|
7232
7419
|
});
|
|
7233
7420
|
const expression = js.common.parseExpression("(request) => deLocalizeUrl(request.url).pathname");
|
|
@@ -7250,11 +7437,11 @@ var paraglide_default = defineAddon({
|
|
|
7250
7437
|
}));
|
|
7251
7438
|
sv.file(`src/hooks.server.${language}`, transforms.script(({ ast, comments, js }) => {
|
|
7252
7439
|
js.imports.addNamed(ast, {
|
|
7253
|
-
from:
|
|
7440
|
+
from: `${lib}/paraglide/server`,
|
|
7254
7441
|
imports: ["paraglideMiddleware"]
|
|
7255
7442
|
});
|
|
7256
7443
|
js.imports.addNamed(ast, {
|
|
7257
|
-
from:
|
|
7444
|
+
from: `${lib}/paraglide/runtime`,
|
|
7258
7445
|
imports: ["getTextDirection"]
|
|
7259
7446
|
});
|
|
7260
7447
|
js.kit.addHooksHandle(ast, {
|
|
@@ -7294,7 +7481,7 @@ var paraglide_default = defineAddon({
|
|
|
7294
7481
|
sv.file(`${directory.kitRoutes}/+layout.svelte`, transforms.svelteScript({ language }, ({ ast, svelte, js }) => {
|
|
7295
7482
|
js.imports.addNamed(ast.instance.content, {
|
|
7296
7483
|
imports: ["locales", "localizeHref"],
|
|
7297
|
-
from:
|
|
7484
|
+
from: `${lib}/paraglide/runtime`
|
|
7298
7485
|
});
|
|
7299
7486
|
js.imports.addNamed(ast.instance.content, {
|
|
7300
7487
|
imports: ["page"],
|
|
@@ -7305,14 +7492,14 @@ var paraglide_default = defineAddon({
|
|
|
7305
7492
|
from: "$app/paths"
|
|
7306
7493
|
});
|
|
7307
7494
|
if (language === "ts") js.imports.addNamed(ast.instance.content, {
|
|
7308
|
-
imports: [
|
|
7495
|
+
imports: [pathType],
|
|
7309
7496
|
from: "$app/types",
|
|
7310
7497
|
isType: true
|
|
7311
7498
|
});
|
|
7312
7499
|
svelte.addFragment(ast, dedent`
|
|
7313
7500
|
<div style="display:none">
|
|
7314
7501
|
{#each locales as locale (locale)}
|
|
7315
|
-
<a href={resolve(localizeHref(page.url.pathname, { locale })${ts(
|
|
7502
|
+
<a href={resolve(localizeHref(page.url.pathname, { locale })${ts(` as ${pathType}`)})}>{locale}</a>
|
|
7316
7503
|
{/each}
|
|
7317
7504
|
</div>`, { language });
|
|
7318
7505
|
}));
|
|
@@ -7321,11 +7508,11 @@ var paraglide_default = defineAddon({
|
|
|
7321
7508
|
sv.file(`${directory.kitRoutes}/demo/paraglide/+page.svelte`, transforms.svelteScript({ language }, ({ ast, svelte, js }) => {
|
|
7322
7509
|
js.imports.addNamed(ast.instance.content, {
|
|
7323
7510
|
imports: { m: "m" },
|
|
7324
|
-
from:
|
|
7511
|
+
from: `${lib}/paraglide/messages.js`
|
|
7325
7512
|
});
|
|
7326
7513
|
js.imports.addNamed(ast.instance.content, {
|
|
7327
7514
|
imports: { setLocale: "setLocale" },
|
|
7328
|
-
from:
|
|
7515
|
+
from: `${lib}/paraglide/runtime`
|
|
7329
7516
|
});
|
|
7330
7517
|
let templateCode = "<h1>{m.hello_world({ name: 'SvelteKit User' })}</h1>";
|
|
7331
7518
|
const { validLanguageTags } = parseLanguageTagInput(options.languageTags);
|
|
@@ -7603,7 +7790,7 @@ var sveltekit_adapter_default = defineAddon({
|
|
|
7603
7790
|
});
|
|
7604
7791
|
if (adapter.package === "@sveltejs/adapter-cloudflare") {
|
|
7605
7792
|
sv.devDependency("wrangler", "^4.97.0");
|
|
7606
|
-
if (packageManager === "pnpm") sv.file(file.findUp("pnpm-workspace.yaml"), pnpm.allowBuilds("workerd"
|
|
7793
|
+
if (packageManager === "pnpm") sv.file(file.findUp("pnpm-workspace.yaml"), pnpm.allowBuilds("workerd"));
|
|
7607
7794
|
const ext = fileExists(cwd, "wrangler.toml") ? "toml" : "jsonc";
|
|
7608
7795
|
const applyWranglerConfig = (data) => {
|
|
7609
7796
|
if (ext === "jsonc") data.$schema ??= "./node_modules/wrangler/config-schema.json";
|
|
@@ -7679,11 +7866,10 @@ var tailwindcss_default = defineAddon({
|
|
|
7679
7866
|
default: [],
|
|
7680
7867
|
required: false
|
|
7681
7868
|
}).build(),
|
|
7682
|
-
run: ({ sv, options, file, isKit, directory, dependencyVersion, language
|
|
7869
|
+
run: ({ sv, options, file, isKit, directory, dependencyVersion, language }) => {
|
|
7683
7870
|
const prettierInstalled = Boolean(dependencyVersion("prettier"));
|
|
7684
7871
|
sv.devDependency("tailwindcss", "^4.3.0");
|
|
7685
7872
|
sv.devDependency("@tailwindcss/vite", "^4.3.0");
|
|
7686
|
-
if (packageManager === "pnpm") sv.file(file.findUp("pnpm-workspace.yaml"), pnpm.allowBuilds("@tailwindcss/oxide"));
|
|
7687
7873
|
if (prettierInstalled) sv.devDependency("prettier-plugin-tailwindcss", "^0.8.0");
|
|
7688
7874
|
for (const plugin of plugins) {
|
|
7689
7875
|
if (!options.plugins.includes(plugin.id)) continue;
|
|
@@ -7921,7 +8107,7 @@ const officialAddons$1 = {
|
|
|
7921
8107
|
mdsvex: mdsvex_default,
|
|
7922
8108
|
paraglide: paraglide_default,
|
|
7923
8109
|
storybook: storybook_default,
|
|
7924
|
-
|
|
8110
|
+
aiTools: ai_tools_default,
|
|
7925
8111
|
experimental: experimental_default
|
|
7926
8112
|
};
|
|
7927
8113
|
function getAddonDetails(id) {
|
|
@@ -7930,2711 +8116,1048 @@ function getAddonDetails(id) {
|
|
|
7930
8116
|
return details;
|
|
7931
8117
|
}
|
|
7932
8118
|
//#endregion
|
|
7933
|
-
//#region ../../node_modules/.pnpm/
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
8119
|
+
//#region ../../node_modules/.pnpm/modern-tar@0.7.7/node_modules/modern-tar/dist/packer-BtsuoKCV.js
|
|
8120
|
+
const FILE = "file";
|
|
8121
|
+
const LINK = "link";
|
|
8122
|
+
const SYMLINK = "symlink";
|
|
8123
|
+
const DIRECTORY = "directory";
|
|
8124
|
+
const FLAGTYPE = {
|
|
8125
|
+
"0": FILE,
|
|
8126
|
+
"1": LINK,
|
|
8127
|
+
"2": SYMLINK,
|
|
8128
|
+
"3": "character-device",
|
|
8129
|
+
"4": "block-device",
|
|
8130
|
+
"5": DIRECTORY,
|
|
8131
|
+
"6": "fifo",
|
|
8132
|
+
x: "pax-header",
|
|
8133
|
+
g: "pax-global-header",
|
|
8134
|
+
L: "gnu-long-name",
|
|
8135
|
+
K: "gnu-long-link-name"
|
|
8136
|
+
};
|
|
8137
|
+
const EMPTY = /* @__PURE__ */ new Uint8Array(0);
|
|
8138
|
+
new TextEncoder();
|
|
8139
|
+
const decoder = new TextDecoder();
|
|
8140
|
+
function readString(view, offset, size) {
|
|
8141
|
+
const end = view.indexOf(0, offset);
|
|
8142
|
+
const sliceEnd = end === -1 || end > offset + size ? offset + size : end;
|
|
8143
|
+
return decoder.decode(view.subarray(offset, sliceEnd));
|
|
8144
|
+
}
|
|
8145
|
+
function readOctal(view, offset, size) {
|
|
8146
|
+
let value = 0;
|
|
8147
|
+
const end = offset + size;
|
|
8148
|
+
for (let i = offset; i < end; i++) {
|
|
8149
|
+
const charCode = view[i];
|
|
8150
|
+
if (charCode === 0) break;
|
|
8151
|
+
if (charCode === 32) continue;
|
|
8152
|
+
value = value * 8 + (charCode - 48);
|
|
8153
|
+
}
|
|
8154
|
+
return value;
|
|
8155
|
+
}
|
|
8156
|
+
function readNumeric(view, offset, size) {
|
|
8157
|
+
if (view[offset] & 128) {
|
|
8158
|
+
let result = 0;
|
|
8159
|
+
result = view[offset] & 127;
|
|
8160
|
+
for (let i = 1; i < size; i++) result = result * 256 + view[offset + i];
|
|
8161
|
+
if (!Number.isSafeInteger(result)) throw new Error("TAR number too large");
|
|
8162
|
+
return result;
|
|
8163
|
+
}
|
|
8164
|
+
return readOctal(view, offset, size);
|
|
8165
|
+
}
|
|
8166
|
+
const isBodyless = (header) => header.type === "directory" || header.type === "symlink" || header.type === "link" || header.type === "character-device" || header.type === "block-device" || header.type === "fifo";
|
|
8167
|
+
const stripPath = (p, n) => {
|
|
8168
|
+
const parts = p.split("/").filter(Boolean);
|
|
8169
|
+
return n >= parts.length ? "" : parts.slice(n).join("/");
|
|
8170
|
+
};
|
|
8171
|
+
function transformHeader(header, options) {
|
|
8172
|
+
const { strip, filter, map } = options;
|
|
8173
|
+
if (!strip && !filter && !map) return header;
|
|
8174
|
+
const h = { ...header };
|
|
8175
|
+
if (strip && strip > 0) {
|
|
8176
|
+
const newName = stripPath(h.name, strip);
|
|
8177
|
+
if (!newName) return null;
|
|
8178
|
+
h.name = h.type === "directory" && !newName.endsWith("/") ? `${newName}/` : newName;
|
|
8179
|
+
if (h.linkname) {
|
|
8180
|
+
const isAbsolute = h.linkname.startsWith("/");
|
|
8181
|
+
if (isAbsolute || h.type === "link") {
|
|
8182
|
+
const stripped = stripPath(h.linkname, strip);
|
|
8183
|
+
h.linkname = isAbsolute ? `/${stripped}` || "/" : stripped;
|
|
8184
|
+
}
|
|
8185
|
+
}
|
|
8186
|
+
}
|
|
8187
|
+
if (filter?.(h) === false) return null;
|
|
8188
|
+
const result = map ? map(h) : h;
|
|
8189
|
+
if (result && (!result.name || !result.name.trim() || result.name === "." || result.name === "/")) return null;
|
|
8190
|
+
return result;
|
|
8191
|
+
}
|
|
8192
|
+
const INITIAL_CAPACITY = 256;
|
|
8193
|
+
function createChunkQueue() {
|
|
8194
|
+
let chunks = new Array(INITIAL_CAPACITY);
|
|
8195
|
+
let capacityMask = chunks.length - 1;
|
|
8196
|
+
let head = 0;
|
|
8197
|
+
let tail = 0;
|
|
8198
|
+
let totalAvailable = 0;
|
|
8199
|
+
const consumeFromHead = (count) => {
|
|
8200
|
+
const chunk = chunks[head];
|
|
8201
|
+
if (count === chunk.length) {
|
|
8202
|
+
chunks[head] = EMPTY;
|
|
8203
|
+
head = head + 1 & capacityMask;
|
|
8204
|
+
} else chunks[head] = chunk.subarray(count);
|
|
8205
|
+
totalAvailable -= count;
|
|
8206
|
+
if (totalAvailable === 0 && chunks.length > INITIAL_CAPACITY) {
|
|
8207
|
+
chunks = new Array(INITIAL_CAPACITY);
|
|
8208
|
+
capacityMask = INITIAL_CAPACITY - 1;
|
|
8209
|
+
head = 0;
|
|
8210
|
+
tail = 0;
|
|
7972
8211
|
}
|
|
7973
8212
|
};
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
8213
|
+
function pull(bytes, callback) {
|
|
8214
|
+
if (callback) {
|
|
8215
|
+
let fed = 0;
|
|
8216
|
+
let remaining = Math.min(bytes, totalAvailable);
|
|
8217
|
+
while (remaining > 0) {
|
|
8218
|
+
const chunk = chunks[head];
|
|
8219
|
+
const toFeed = Math.min(remaining, chunk.length);
|
|
8220
|
+
const segment = toFeed === chunk.length ? chunk : chunk.subarray(0, toFeed);
|
|
8221
|
+
consumeFromHead(toFeed);
|
|
8222
|
+
remaining -= toFeed;
|
|
8223
|
+
fed += toFeed;
|
|
8224
|
+
if (!callback(segment)) break;
|
|
8225
|
+
}
|
|
8226
|
+
return fed;
|
|
8227
|
+
}
|
|
8228
|
+
if (totalAvailable < bytes) return null;
|
|
8229
|
+
if (bytes === 0) return EMPTY;
|
|
8230
|
+
const firstChunk = chunks[head];
|
|
8231
|
+
if (firstChunk.length >= bytes) {
|
|
8232
|
+
const view = firstChunk.length === bytes ? firstChunk : firstChunk.subarray(0, bytes);
|
|
8233
|
+
consumeFromHead(bytes);
|
|
8234
|
+
return view;
|
|
8235
|
+
}
|
|
8236
|
+
const result = new Uint8Array(bytes);
|
|
8237
|
+
let copied = 0;
|
|
8238
|
+
let remaining = bytes;
|
|
8239
|
+
while (remaining > 0) {
|
|
8240
|
+
const chunk = chunks[head];
|
|
8241
|
+
const toCopy = Math.min(remaining, chunk.length);
|
|
8242
|
+
result.set(toCopy === chunk.length ? chunk : chunk.subarray(0, toCopy), copied);
|
|
8243
|
+
copied += toCopy;
|
|
8244
|
+
remaining -= toCopy;
|
|
8245
|
+
consumeFromHead(toCopy);
|
|
7985
8246
|
}
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
const
|
|
7995
|
-
|
|
7996
|
-
|
|
8247
|
+
return result;
|
|
8248
|
+
}
|
|
8249
|
+
return {
|
|
8250
|
+
push: (chunk) => {
|
|
8251
|
+
if (chunk.length === 0) return;
|
|
8252
|
+
let nextTail = tail + 1 & capacityMask;
|
|
8253
|
+
if (nextTail === head) {
|
|
8254
|
+
const oldLen = chunks.length;
|
|
8255
|
+
const newLen = oldLen * 2;
|
|
8256
|
+
const newChunks = new Array(newLen);
|
|
8257
|
+
const count = tail - head + oldLen & oldLen - 1;
|
|
8258
|
+
if (head < tail) for (let i = 0; i < count; i++) newChunks[i] = chunks[head + i];
|
|
8259
|
+
else if (count > 0) {
|
|
8260
|
+
const firstPart = oldLen - head;
|
|
8261
|
+
for (let i = 0; i < firstPart; i++) newChunks[i] = chunks[head + i];
|
|
8262
|
+
for (let i = 0; i < tail; i++) newChunks[firstPart + i] = chunks[i];
|
|
8263
|
+
}
|
|
8264
|
+
chunks = newChunks;
|
|
8265
|
+
capacityMask = newLen - 1;
|
|
8266
|
+
head = 0;
|
|
8267
|
+
tail = count;
|
|
8268
|
+
nextTail = tail + 1 & capacityMask;
|
|
8269
|
+
}
|
|
8270
|
+
chunks[tail] = chunk;
|
|
8271
|
+
tail = nextTail;
|
|
8272
|
+
totalAvailable += chunk.length;
|
|
8273
|
+
},
|
|
8274
|
+
available: () => totalAvailable,
|
|
8275
|
+
peek: (bytes) => {
|
|
8276
|
+
if (totalAvailable < bytes) return null;
|
|
8277
|
+
if (bytes === 0) return EMPTY;
|
|
8278
|
+
const firstChunk = chunks[head];
|
|
8279
|
+
if (firstChunk.length >= bytes) return firstChunk.length === bytes ? firstChunk : firstChunk.subarray(0, bytes);
|
|
8280
|
+
const result = new Uint8Array(bytes);
|
|
8281
|
+
let copied = 0;
|
|
8282
|
+
let index = head;
|
|
8283
|
+
while (copied < bytes) {
|
|
8284
|
+
const chunk = chunks[index];
|
|
8285
|
+
const toCopy = Math.min(bytes - copied, chunk.length);
|
|
8286
|
+
if (toCopy === chunk.length) result.set(chunk, copied);
|
|
8287
|
+
else result.set(chunk.subarray(0, toCopy), copied);
|
|
8288
|
+
copied += toCopy;
|
|
8289
|
+
index = index + 1 & capacityMask;
|
|
7997
8290
|
}
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
if (
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8291
|
+
return result;
|
|
8292
|
+
},
|
|
8293
|
+
discard: (bytes) => {
|
|
8294
|
+
if (bytes > totalAvailable) throw new Error("Too many bytes consumed");
|
|
8295
|
+
if (bytes === 0) return;
|
|
8296
|
+
let remaining = bytes;
|
|
8297
|
+
while (remaining > 0) {
|
|
8298
|
+
const chunk = chunks[head];
|
|
8299
|
+
const toConsume = Math.min(remaining, chunk.length);
|
|
8300
|
+
consumeFromHead(toConsume);
|
|
8301
|
+
remaining -= toConsume;
|
|
8007
8302
|
}
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
peek() {
|
|
8011
|
-
const val = this.tail.peek();
|
|
8012
|
-
if (val === void 0 && this.tail.next) return this.tail.next.peek();
|
|
8013
|
-
return val;
|
|
8014
|
-
}
|
|
8015
|
-
isEmpty() {
|
|
8016
|
-
return this.length === 0;
|
|
8017
|
-
}
|
|
8303
|
+
},
|
|
8304
|
+
pull
|
|
8018
8305
|
};
|
|
8019
|
-
}
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
}
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
return
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
concat,
|
|
8144
|
-
copy,
|
|
8145
|
-
equals,
|
|
8146
|
-
fill,
|
|
8147
|
-
from,
|
|
8148
|
-
includes,
|
|
8149
|
-
indexOf,
|
|
8150
|
-
lastIndexOf,
|
|
8151
|
-
swap16,
|
|
8152
|
-
swap32,
|
|
8153
|
-
swap64,
|
|
8154
|
-
toBuffer,
|
|
8155
|
-
toString,
|
|
8156
|
-
write,
|
|
8157
|
-
readDoubleBE,
|
|
8158
|
-
readDoubleLE,
|
|
8159
|
-
readFloatBE,
|
|
8160
|
-
readFloatLE,
|
|
8161
|
-
readInt32BE,
|
|
8162
|
-
readInt32LE,
|
|
8163
|
-
readUInt32BE,
|
|
8164
|
-
readUInt32LE,
|
|
8165
|
-
writeDoubleBE,
|
|
8166
|
-
writeDoubleLE,
|
|
8167
|
-
writeFloatBE,
|
|
8168
|
-
writeFloatLE,
|
|
8169
|
-
writeInt32BE,
|
|
8170
|
-
writeInt32LE,
|
|
8171
|
-
writeUInt32BE,
|
|
8172
|
-
writeUInt32LE
|
|
8173
|
-
};
|
|
8174
|
-
}));
|
|
8175
|
-
//#endregion
|
|
8176
|
-
//#region ../../node_modules/.pnpm/text-decoder@1.2.7/node_modules/text-decoder/lib/pass-through-decoder.js
|
|
8177
|
-
var require_pass_through_decoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8178
|
-
const b4a = require_b4a();
|
|
8179
|
-
module.exports = class PassThroughDecoder {
|
|
8180
|
-
constructor(encoding) {
|
|
8181
|
-
this.encoding = encoding;
|
|
8182
|
-
}
|
|
8183
|
-
get remaining() {
|
|
8184
|
-
return 0;
|
|
8185
|
-
}
|
|
8186
|
-
decode(data) {
|
|
8187
|
-
return b4a.toString(data, this.encoding);
|
|
8188
|
-
}
|
|
8189
|
-
flush() {
|
|
8190
|
-
return "";
|
|
8191
|
-
}
|
|
8192
|
-
};
|
|
8193
|
-
}));
|
|
8194
|
-
//#endregion
|
|
8195
|
-
//#region ../../node_modules/.pnpm/text-decoder@1.2.7/node_modules/text-decoder/lib/utf8-decoder.js
|
|
8196
|
-
var require_utf8_decoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8197
|
-
const b4a = require_b4a();
|
|
8198
|
-
/**
|
|
8199
|
-
* https://encoding.spec.whatwg.org/#utf-8-decoder
|
|
8200
|
-
*/
|
|
8201
|
-
module.exports = class UTF8Decoder {
|
|
8202
|
-
constructor() {
|
|
8203
|
-
this._reset();
|
|
8204
|
-
}
|
|
8205
|
-
get remaining() {
|
|
8206
|
-
return this.bytesSeen;
|
|
8207
|
-
}
|
|
8208
|
-
decode(data) {
|
|
8209
|
-
if (data.byteLength === 0) return "";
|
|
8210
|
-
if (this.bytesNeeded === 0 && trailingIncomplete(data, 0) === 0) {
|
|
8211
|
-
this.bytesSeen = trailingBytesSeen(data);
|
|
8212
|
-
return b4a.toString(data, "utf8");
|
|
8213
|
-
}
|
|
8214
|
-
let result = "";
|
|
8215
|
-
let start = 0;
|
|
8216
|
-
if (this.bytesNeeded > 0) {
|
|
8217
|
-
while (start < data.byteLength) {
|
|
8218
|
-
const byte = data[start];
|
|
8219
|
-
if (byte < this.lowerBoundary || byte > this.upperBoundary) {
|
|
8220
|
-
result += "�";
|
|
8221
|
-
this._reset();
|
|
8222
|
-
break;
|
|
8223
|
-
}
|
|
8224
|
-
this.lowerBoundary = 128;
|
|
8225
|
-
this.upperBoundary = 191;
|
|
8226
|
-
this.codePoint = this.codePoint << 6 | byte & 63;
|
|
8227
|
-
this.bytesSeen++;
|
|
8228
|
-
start++;
|
|
8229
|
-
if (this.bytesSeen === this.bytesNeeded) {
|
|
8230
|
-
result += String.fromCodePoint(this.codePoint);
|
|
8231
|
-
this._reset();
|
|
8232
|
-
break;
|
|
8233
|
-
}
|
|
8234
|
-
}
|
|
8235
|
-
if (this.bytesNeeded > 0) return result;
|
|
8236
|
-
}
|
|
8237
|
-
const trailing = trailingIncomplete(data, start);
|
|
8238
|
-
const end = data.byteLength - trailing;
|
|
8239
|
-
if (end > start) result += b4a.toString(data, "utf8", start, end);
|
|
8240
|
-
for (let i = end; i < data.byteLength; i++) {
|
|
8241
|
-
const byte = data[i];
|
|
8242
|
-
if (this.bytesNeeded === 0) {
|
|
8243
|
-
if (byte <= 127) {
|
|
8244
|
-
this.bytesSeen = 0;
|
|
8245
|
-
result += String.fromCharCode(byte);
|
|
8246
|
-
} else if (byte >= 194 && byte <= 223) {
|
|
8247
|
-
this.bytesNeeded = 2;
|
|
8248
|
-
this.bytesSeen = 1;
|
|
8249
|
-
this.codePoint = byte & 31;
|
|
8250
|
-
} else if (byte >= 224 && byte <= 239) {
|
|
8251
|
-
if (byte === 224) this.lowerBoundary = 160;
|
|
8252
|
-
else if (byte === 237) this.upperBoundary = 159;
|
|
8253
|
-
this.bytesNeeded = 3;
|
|
8254
|
-
this.bytesSeen = 1;
|
|
8255
|
-
this.codePoint = byte & 15;
|
|
8256
|
-
} else if (byte >= 240 && byte <= 244) {
|
|
8257
|
-
if (byte === 240) this.lowerBoundary = 144;
|
|
8258
|
-
else if (byte === 244) this.upperBoundary = 143;
|
|
8259
|
-
this.bytesNeeded = 4;
|
|
8260
|
-
this.bytesSeen = 1;
|
|
8261
|
-
this.codePoint = byte & 7;
|
|
8262
|
-
} else {
|
|
8263
|
-
this.bytesSeen = 1;
|
|
8264
|
-
result += "�";
|
|
8265
|
-
}
|
|
8266
|
-
continue;
|
|
8267
|
-
}
|
|
8268
|
-
if (byte < this.lowerBoundary || byte > this.upperBoundary) {
|
|
8269
|
-
result += "�";
|
|
8270
|
-
i--;
|
|
8271
|
-
this._reset();
|
|
8272
|
-
continue;
|
|
8273
|
-
}
|
|
8274
|
-
this.lowerBoundary = 128;
|
|
8275
|
-
this.upperBoundary = 191;
|
|
8276
|
-
this.codePoint = this.codePoint << 6 | byte & 63;
|
|
8277
|
-
this.bytesSeen++;
|
|
8278
|
-
if (this.bytesSeen === this.bytesNeeded) {
|
|
8279
|
-
result += String.fromCodePoint(this.codePoint);
|
|
8280
|
-
this._reset();
|
|
8281
|
-
}
|
|
8282
|
-
}
|
|
8283
|
-
return result;
|
|
8284
|
-
}
|
|
8285
|
-
flush() {
|
|
8286
|
-
const result = this.bytesNeeded > 0 ? "�" : "";
|
|
8287
|
-
this._reset();
|
|
8288
|
-
return result;
|
|
8289
|
-
}
|
|
8290
|
-
_reset() {
|
|
8291
|
-
this.codePoint = 0;
|
|
8292
|
-
this.bytesNeeded = 0;
|
|
8293
|
-
this.bytesSeen = 0;
|
|
8294
|
-
this.lowerBoundary = 128;
|
|
8295
|
-
this.upperBoundary = 191;
|
|
8296
|
-
}
|
|
8297
|
-
};
|
|
8298
|
-
function trailingIncomplete(data, start) {
|
|
8299
|
-
const len = data.byteLength;
|
|
8300
|
-
if (len <= start) return 0;
|
|
8301
|
-
const limit = Math.max(start, len - 4);
|
|
8302
|
-
let i = len - 1;
|
|
8303
|
-
while (i > limit && (data[i] & 192) === 128) i--;
|
|
8304
|
-
if (i < start) return 0;
|
|
8305
|
-
const byte = data[i];
|
|
8306
|
-
let needed;
|
|
8307
|
-
if (byte <= 127) return 0;
|
|
8308
|
-
if (byte >= 194 && byte <= 223) needed = 2;
|
|
8309
|
-
else if (byte >= 224 && byte <= 239) needed = 3;
|
|
8310
|
-
else if (byte >= 240 && byte <= 244) needed = 4;
|
|
8311
|
-
else return 0;
|
|
8312
|
-
const available = len - i;
|
|
8313
|
-
return available < needed ? available : 0;
|
|
8314
|
-
}
|
|
8315
|
-
function trailingBytesSeen(data) {
|
|
8316
|
-
const len = data.byteLength;
|
|
8317
|
-
if (len === 0) return 0;
|
|
8318
|
-
const last = data[len - 1];
|
|
8319
|
-
if (last <= 127) return 0;
|
|
8320
|
-
if ((last & 192) !== 128) return 1;
|
|
8321
|
-
const limit = Math.max(0, len - 4);
|
|
8322
|
-
let i = len - 2;
|
|
8323
|
-
while (i >= limit && (data[i] & 192) === 128) i--;
|
|
8324
|
-
if (i < 0) return 1;
|
|
8325
|
-
const first = data[i];
|
|
8326
|
-
let needed;
|
|
8327
|
-
if (first >= 194 && first <= 223) needed = 2;
|
|
8328
|
-
else if (first >= 224 && first <= 239) needed = 3;
|
|
8329
|
-
else if (first >= 240 && first <= 244) needed = 4;
|
|
8330
|
-
else return 1;
|
|
8331
|
-
if (len - i !== needed) return 1;
|
|
8332
|
-
if (needed >= 3) {
|
|
8333
|
-
const second = data[i + 1];
|
|
8334
|
-
if (first === 224 && second < 160) return 1;
|
|
8335
|
-
if (first === 237 && second > 159) return 1;
|
|
8336
|
-
if (first === 240 && second < 144) return 1;
|
|
8337
|
-
if (first === 244 && second > 143) return 1;
|
|
8338
|
-
}
|
|
8339
|
-
return 0;
|
|
8340
|
-
}
|
|
8341
|
-
}));
|
|
8342
|
-
//#endregion
|
|
8343
|
-
//#region ../../node_modules/.pnpm/text-decoder@1.2.7/node_modules/text-decoder/index.js
|
|
8344
|
-
var require_text_decoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8345
|
-
const PassThroughDecoder = require_pass_through_decoder();
|
|
8346
|
-
const UTF8Decoder = require_utf8_decoder();
|
|
8347
|
-
module.exports = class TextDecoder {
|
|
8348
|
-
constructor(encoding = "utf8") {
|
|
8349
|
-
this.encoding = normalizeEncoding(encoding);
|
|
8350
|
-
switch (this.encoding) {
|
|
8351
|
-
case "utf8":
|
|
8352
|
-
this.decoder = new UTF8Decoder();
|
|
8353
|
-
break;
|
|
8354
|
-
case "utf16le":
|
|
8355
|
-
case "base64": throw new Error("Unsupported encoding: " + this.encoding);
|
|
8356
|
-
default: this.decoder = new PassThroughDecoder(this.encoding);
|
|
8357
|
-
}
|
|
8358
|
-
}
|
|
8359
|
-
get remaining() {
|
|
8360
|
-
return this.decoder.remaining;
|
|
8361
|
-
}
|
|
8362
|
-
push(data) {
|
|
8363
|
-
if (typeof data === "string") return data;
|
|
8364
|
-
return this.decoder.decode(data);
|
|
8365
|
-
}
|
|
8366
|
-
write(data) {
|
|
8367
|
-
return this.push(data);
|
|
8368
|
-
}
|
|
8369
|
-
end(data) {
|
|
8370
|
-
let result = "";
|
|
8371
|
-
if (data) result = this.push(data);
|
|
8372
|
-
result += this.decoder.flush();
|
|
8373
|
-
return result;
|
|
8374
|
-
}
|
|
8375
|
-
};
|
|
8376
|
-
function normalizeEncoding(encoding) {
|
|
8377
|
-
encoding = encoding.toLowerCase();
|
|
8378
|
-
switch (encoding) {
|
|
8379
|
-
case "utf8":
|
|
8380
|
-
case "utf-8": return "utf8";
|
|
8381
|
-
case "ucs2":
|
|
8382
|
-
case "ucs-2":
|
|
8383
|
-
case "utf16le":
|
|
8384
|
-
case "utf-16le": return "utf16le";
|
|
8385
|
-
case "latin1":
|
|
8386
|
-
case "binary": return "latin1";
|
|
8387
|
-
case "base64":
|
|
8388
|
-
case "ascii":
|
|
8389
|
-
case "hex": return encoding;
|
|
8390
|
-
default: throw new Error("Unknown encoding: " + encoding);
|
|
8391
|
-
}
|
|
8392
|
-
}
|
|
8393
|
-
}));
|
|
8394
|
-
//#endregion
|
|
8395
|
-
//#region ../../node_modules/.pnpm/streamx@2.26.0/node_modules/streamx/lib/errors.js
|
|
8396
|
-
var require_errors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8397
|
-
module.exports = class StreamError extends Error {
|
|
8398
|
-
constructor(msg, code, fn = StreamError) {
|
|
8399
|
-
super(msg);
|
|
8400
|
-
this.code = code;
|
|
8401
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, fn);
|
|
8402
|
-
}
|
|
8403
|
-
static isStreamDestroyed(err) {
|
|
8404
|
-
return err && err.code === "STREAM_DESTROYED";
|
|
8405
|
-
}
|
|
8406
|
-
static isPrematureClose(err) {
|
|
8407
|
-
return err && err.code === "PREMATURE_CLOSE";
|
|
8408
|
-
}
|
|
8409
|
-
static isAborted(err) {
|
|
8410
|
-
return err && err.code === "ABORTED";
|
|
8411
|
-
}
|
|
8412
|
-
get name() {
|
|
8413
|
-
return "StreamError";
|
|
8414
|
-
}
|
|
8415
|
-
static STREAM_DESTROYED() {
|
|
8416
|
-
return new StreamError("Stream was destroyed", "STREAM_DESTROYED", StreamError.STREAM_DESTROYED);
|
|
8417
|
-
}
|
|
8418
|
-
static PREMATURE_CLOSE() {
|
|
8419
|
-
return new StreamError("Premature close", "PREMATURE_CLOSE", StreamError.PREMATURE_CLOSE);
|
|
8420
|
-
}
|
|
8421
|
-
static ABORTED() {
|
|
8422
|
-
return new StreamError("Stream aborted", "ABORTED", StreamError.ABORTED);
|
|
8423
|
-
}
|
|
8424
|
-
};
|
|
8425
|
-
}));
|
|
8426
|
-
//#endregion
|
|
8427
|
-
//#region ../../node_modules/.pnpm/streamx@2.26.0/node_modules/streamx/index.js
|
|
8428
|
-
var require_streamx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8429
|
-
const { EventEmitter } = require_default();
|
|
8430
|
-
const FIFO = require_fast_fifo();
|
|
8431
|
-
const TextDecoder = require_text_decoder();
|
|
8432
|
-
const StreamError = require_errors();
|
|
8433
|
-
const qmt = typeof queueMicrotask === "undefined" ? (fn) => global.process.nextTick(fn) : queueMicrotask;
|
|
8434
|
-
const OPENING = 1;
|
|
8435
|
-
const PREDESTROYING = 2;
|
|
8436
|
-
const DESTROYING = 4;
|
|
8437
|
-
const DESTROYED = 8;
|
|
8438
|
-
const NOT_OPENING = 536870910;
|
|
8439
|
-
const NOT_PREDESTROYING = 536870909;
|
|
8440
|
-
const READ_UPDATING = 32;
|
|
8441
|
-
const READ_PRIMARY = 64;
|
|
8442
|
-
const READ_QUEUED = 128;
|
|
8443
|
-
const READ_RESUMED = 256;
|
|
8444
|
-
const READ_PIPE_DRAINED = 512;
|
|
8445
|
-
const READ_ENDING = 1024;
|
|
8446
|
-
const READ_EMIT_DATA = 2048;
|
|
8447
|
-
const READ_EMIT_READABLE = 4096;
|
|
8448
|
-
const READ_EMITTED_READABLE = 8192;
|
|
8449
|
-
const READ_DONE = 16384;
|
|
8450
|
-
const READ_NEXT_TICK = 32768;
|
|
8451
|
-
const READ_READ_AHEAD = 131072;
|
|
8452
|
-
const READ_FLOWING = 768;
|
|
8453
|
-
const READ_ACTIVE_AND_NEEDS_PUSH = 65552;
|
|
8454
|
-
const READ_PRIMARY_AND_ACTIVE = 80;
|
|
8455
|
-
const READ_EMIT_READABLE_AND_QUEUED = 4224;
|
|
8456
|
-
const READ_RESUMED_READ_AHEAD = 131328;
|
|
8457
|
-
const READ_NOT_ACTIVE = 536870895;
|
|
8458
|
-
const READ_NON_PRIMARY_AND_PUSHED = 536805311;
|
|
8459
|
-
const READ_PUSHED = 536805375;
|
|
8460
|
-
const READ_PAUSED = 536870655;
|
|
8461
|
-
const READ_NOT_QUEUED = 536862591;
|
|
8462
|
-
const READ_NOT_ENDING = 536869887;
|
|
8463
|
-
const READ_PIPE_NOT_DRAINED = 536870143;
|
|
8464
|
-
const READ_NOT_NEXT_TICK = 536838143;
|
|
8465
|
-
const READ_NOT_UPDATING = 536870879;
|
|
8466
|
-
const READ_NO_READ_AHEAD = 536739839;
|
|
8467
|
-
const READ_PAUSED_NO_READ_AHEAD = 536739583;
|
|
8468
|
-
const WRITE_ACTIVE = 1 << 18;
|
|
8469
|
-
const WRITE_UPDATING = 2 << 18;
|
|
8470
|
-
const WRITE_PRIMARY = 4 << 18;
|
|
8471
|
-
const WRITE_QUEUED = 8 << 18;
|
|
8472
|
-
const WRITE_UNDRAINED = 16 << 18;
|
|
8473
|
-
const WRITE_DONE = 32 << 18;
|
|
8474
|
-
const WRITE_EMIT_DRAIN = 64 << 18;
|
|
8475
|
-
const WRITE_NEXT_TICK = 128 << 18;
|
|
8476
|
-
const WRITE_WRITING = 256 << 18;
|
|
8477
|
-
const WRITE_FINISHING = 512 << 18;
|
|
8478
|
-
const WRITE_CORKED = 1024 << 18;
|
|
8479
|
-
const WRITE_NOT_ACTIVE = 469499903;
|
|
8480
|
-
const WRITE_NON_PRIMARY = 535822335;
|
|
8481
|
-
const WRITE_NOT_FINISHING = 402391039;
|
|
8482
|
-
const WRITE_DRAINED = 532676607;
|
|
8483
|
-
const WRITE_NOT_QUEUED = 534773759;
|
|
8484
|
-
const WRITE_NOT_NEXT_TICK = 503316479;
|
|
8485
|
-
const WRITE_NOT_UPDATING = 536346623;
|
|
8486
|
-
const WRITE_NOT_CORKED = 268435455;
|
|
8487
|
-
const ACTIVE = 262160;
|
|
8488
|
-
const NOT_ACTIVE = 536608751;
|
|
8489
|
-
const DONE = 8404992;
|
|
8490
|
-
const DESTROY_STATUS = 14;
|
|
8491
|
-
const OPEN_STATUS = 15;
|
|
8492
|
-
const AUTO_DESTROY = 8405006;
|
|
8493
|
-
const NON_PRIMARY = 535822271;
|
|
8494
|
-
const ACTIVE_OR_TICKING = 33587200;
|
|
8495
|
-
const IS_OPENING = 33587215;
|
|
8496
|
-
const READ_PRIMARY_STATUS = 17423;
|
|
8497
|
-
const READ_STATUS = 16527;
|
|
8498
|
-
const READ_ENDING_STATUS = 1167;
|
|
8499
|
-
const READ_READABLE_STATUS = 12431;
|
|
8500
|
-
const SHOULD_NOT_READ = 214047;
|
|
8501
|
-
const READ_BACKPRESSURE_STATUS = 17422;
|
|
8502
|
-
const READ_UPDATE_SYNC_STATUS = 32879;
|
|
8503
|
-
const READ_NEXT_TICK_OR_OPENING = 32769;
|
|
8504
|
-
const WRITE_PRIMARY_STATUS = 142606351;
|
|
8505
|
-
const WRITE_QUEUED_AND_UNDRAINED = 6291456;
|
|
8506
|
-
const WRITE_QUEUED_AND_ACTIVE = 2359296;
|
|
8507
|
-
const WRITE_DRAIN_STATUS = 6553615;
|
|
8508
|
-
const WRITE_STATUS = 270794767;
|
|
8509
|
-
const WRITE_PRIMARY_AND_ACTIVE = 1310720;
|
|
8510
|
-
const WRITE_ACTIVE_AND_WRITING = 67371008;
|
|
8511
|
-
const WRITE_FINISHING_STATUS = 144965647;
|
|
8512
|
-
const WRITE_BACKPRESSURE_STATUS = 146800654;
|
|
8513
|
-
const WRITE_UPDATE_SYNC_STATUS = 35127311;
|
|
8514
|
-
const WRITE_DROP_DATA = 142606350;
|
|
8515
|
-
const asyncIterator = Symbol.asyncIterator || Symbol("asyncIterator");
|
|
8516
|
-
var WritableState = class {
|
|
8517
|
-
constructor(stream, { highWaterMark = 16384, map = null, mapWritable, byteLength, byteLengthWritable } = {}) {
|
|
8518
|
-
this.stream = stream;
|
|
8519
|
-
this.queue = new FIFO();
|
|
8520
|
-
this.highWaterMark = highWaterMark;
|
|
8521
|
-
this.buffered = 0;
|
|
8522
|
-
this.error = null;
|
|
8523
|
-
this.pipeline = null;
|
|
8524
|
-
this.drains = null;
|
|
8525
|
-
this.byteLength = byteLengthWritable || byteLength || defaultByteLength;
|
|
8526
|
-
this.map = mapWritable || map;
|
|
8527
|
-
this.afterWrite = afterWrite.bind(this);
|
|
8528
|
-
this.afterUpdateNextTick = updateWriteNT.bind(this);
|
|
8529
|
-
}
|
|
8530
|
-
get ending() {
|
|
8531
|
-
return (this.stream._duplexState & WRITE_FINISHING) !== 0;
|
|
8532
|
-
}
|
|
8533
|
-
get ended() {
|
|
8534
|
-
return (this.stream._duplexState & WRITE_DONE) !== 0;
|
|
8535
|
-
}
|
|
8536
|
-
push(data) {
|
|
8537
|
-
if ((this.stream._duplexState & WRITE_DROP_DATA) !== 0) return false;
|
|
8538
|
-
if (this.map !== null) data = this.map(data);
|
|
8539
|
-
this.buffered += this.byteLength(data);
|
|
8540
|
-
this.queue.push(data);
|
|
8541
|
-
if (this.buffered < this.highWaterMark) {
|
|
8542
|
-
this.stream._duplexState |= WRITE_QUEUED;
|
|
8543
|
-
return true;
|
|
8544
|
-
}
|
|
8545
|
-
this.stream._duplexState |= WRITE_QUEUED_AND_UNDRAINED;
|
|
8546
|
-
return false;
|
|
8547
|
-
}
|
|
8548
|
-
shift() {
|
|
8549
|
-
const data = this.queue.shift();
|
|
8550
|
-
this.buffered -= this.byteLength(data);
|
|
8551
|
-
if (this.buffered === 0) this.stream._duplexState &= WRITE_NOT_QUEUED;
|
|
8552
|
-
return data;
|
|
8553
|
-
}
|
|
8554
|
-
end(data) {
|
|
8555
|
-
if (typeof data === "function") this.stream.once("finish", data);
|
|
8556
|
-
else if (data !== void 0 && data !== null) this.push(data);
|
|
8557
|
-
this.stream._duplexState = (this.stream._duplexState | WRITE_FINISHING) & WRITE_NON_PRIMARY;
|
|
8558
|
-
}
|
|
8559
|
-
autoBatch(data, cb) {
|
|
8560
|
-
const buffer = [];
|
|
8561
|
-
const stream = this.stream;
|
|
8562
|
-
buffer.push(data);
|
|
8563
|
-
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED_AND_ACTIVE) buffer.push(stream._writableState.shift());
|
|
8564
|
-
if ((stream._duplexState & OPEN_STATUS) !== 0) return cb(null);
|
|
8565
|
-
stream._writev(buffer, cb);
|
|
8566
|
-
}
|
|
8567
|
-
update() {
|
|
8568
|
-
const stream = this.stream;
|
|
8569
|
-
stream._duplexState |= WRITE_UPDATING;
|
|
8570
|
-
do {
|
|
8571
|
-
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
|
|
8572
|
-
const data = this.shift();
|
|
8573
|
-
stream._duplexState |= WRITE_ACTIVE_AND_WRITING;
|
|
8574
|
-
stream._write(data, this.afterWrite);
|
|
8575
|
-
}
|
|
8576
|
-
if ((stream._duplexState & WRITE_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary();
|
|
8577
|
-
} while (this.continueUpdate() === true);
|
|
8578
|
-
stream._duplexState &= WRITE_NOT_UPDATING;
|
|
8579
|
-
}
|
|
8580
|
-
updateNonPrimary() {
|
|
8581
|
-
const stream = this.stream;
|
|
8582
|
-
if ((stream._duplexState & WRITE_FINISHING_STATUS) === WRITE_FINISHING) {
|
|
8583
|
-
stream._duplexState = stream._duplexState | WRITE_ACTIVE;
|
|
8584
|
-
stream._final(afterFinal.bind(this));
|
|
8585
|
-
return;
|
|
8586
|
-
}
|
|
8587
|
-
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
|
|
8588
|
-
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
|
|
8589
|
-
stream._duplexState |= ACTIVE;
|
|
8590
|
-
stream._destroy(afterDestroy.bind(this));
|
|
8591
|
-
}
|
|
8592
|
-
return;
|
|
8593
|
-
}
|
|
8594
|
-
if ((stream._duplexState & IS_OPENING) === OPENING) {
|
|
8595
|
-
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING;
|
|
8596
|
-
stream._open(afterOpen.bind(this));
|
|
8597
|
-
}
|
|
8598
|
-
}
|
|
8599
|
-
continueUpdate() {
|
|
8600
|
-
if ((this.stream._duplexState & WRITE_NEXT_TICK) === 0) return false;
|
|
8601
|
-
this.stream._duplexState &= WRITE_NOT_NEXT_TICK;
|
|
8602
|
-
return true;
|
|
8603
|
-
}
|
|
8604
|
-
updateCallback() {
|
|
8605
|
-
if ((this.stream._duplexState & WRITE_UPDATE_SYNC_STATUS) === WRITE_PRIMARY) this.update();
|
|
8606
|
-
else this.updateNextTick();
|
|
8607
|
-
}
|
|
8608
|
-
updateNextTick() {
|
|
8609
|
-
if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return;
|
|
8610
|
-
this.stream._duplexState |= WRITE_NEXT_TICK;
|
|
8611
|
-
if ((this.stream._duplexState & WRITE_UPDATING) === 0) qmt(this.afterUpdateNextTick);
|
|
8612
|
-
}
|
|
8613
|
-
};
|
|
8614
|
-
var ReadableState = class {
|
|
8615
|
-
constructor(stream, { highWaterMark = 16384, map = null, mapReadable, byteLength, byteLengthReadable } = {}) {
|
|
8616
|
-
this.stream = stream;
|
|
8617
|
-
this.queue = new FIFO();
|
|
8618
|
-
this.highWaterMark = highWaterMark === 0 ? 1 : highWaterMark;
|
|
8619
|
-
this.buffered = 0;
|
|
8620
|
-
this.readAhead = highWaterMark > 0;
|
|
8621
|
-
this.error = null;
|
|
8622
|
-
this.pipeline = null;
|
|
8623
|
-
this.byteLength = byteLengthReadable || byteLength || defaultByteLength;
|
|
8624
|
-
this.map = mapReadable || map;
|
|
8625
|
-
this.pipeTo = null;
|
|
8626
|
-
this.afterRead = afterRead.bind(this);
|
|
8627
|
-
this.afterUpdateNextTick = updateReadNT.bind(this);
|
|
8628
|
-
}
|
|
8629
|
-
get ending() {
|
|
8630
|
-
return (this.stream._duplexState & READ_ENDING) !== 0;
|
|
8631
|
-
}
|
|
8632
|
-
get ended() {
|
|
8633
|
-
return (this.stream._duplexState & READ_DONE) !== 0;
|
|
8634
|
-
}
|
|
8635
|
-
pipe(pipeTo, cb) {
|
|
8636
|
-
if (this.pipeTo !== null) throw new Error("Can only pipe to one destination");
|
|
8637
|
-
if (typeof cb !== "function") cb = null;
|
|
8638
|
-
this.stream._duplexState |= READ_PIPE_DRAINED;
|
|
8639
|
-
this.pipeTo = pipeTo;
|
|
8640
|
-
this.pipeline = new Pipeline(this.stream, pipeTo, cb);
|
|
8641
|
-
if (cb) this.stream.on("error", noop);
|
|
8642
|
-
if (isStreamx(pipeTo)) {
|
|
8643
|
-
pipeTo._writableState.pipeline = this.pipeline;
|
|
8644
|
-
if (cb) pipeTo.on("error", noop);
|
|
8645
|
-
pipeTo.on("finish", this.pipeline.finished.bind(this.pipeline));
|
|
8646
|
-
} else {
|
|
8647
|
-
const onerror = this.pipeline.done.bind(this.pipeline, pipeTo);
|
|
8648
|
-
const onclose = this.pipeline.done.bind(this.pipeline, pipeTo, null);
|
|
8649
|
-
pipeTo.on("error", onerror);
|
|
8650
|
-
pipeTo.on("close", onclose);
|
|
8651
|
-
pipeTo.on("finish", this.pipeline.finished.bind(this.pipeline));
|
|
8652
|
-
}
|
|
8653
|
-
pipeTo.on("drain", afterDrain.bind(this));
|
|
8654
|
-
this.stream.emit("piping", pipeTo);
|
|
8655
|
-
pipeTo.emit("pipe", this.stream);
|
|
8656
|
-
}
|
|
8657
|
-
push(data) {
|
|
8658
|
-
const stream = this.stream;
|
|
8659
|
-
if (data === null) {
|
|
8660
|
-
this.highWaterMark = 0;
|
|
8661
|
-
stream._duplexState = (stream._duplexState | READ_ENDING) & READ_NON_PRIMARY_AND_PUSHED;
|
|
8662
|
-
return false;
|
|
8663
|
-
}
|
|
8664
|
-
if (this.map !== null) {
|
|
8665
|
-
data = this.map(data);
|
|
8666
|
-
if (data === null) {
|
|
8667
|
-
stream._duplexState &= READ_PUSHED;
|
|
8668
|
-
return this.buffered < this.highWaterMark;
|
|
8669
|
-
}
|
|
8670
|
-
}
|
|
8671
|
-
this.buffered += this.byteLength(data);
|
|
8672
|
-
this.queue.push(data);
|
|
8673
|
-
stream._duplexState = (stream._duplexState | READ_QUEUED) & READ_PUSHED;
|
|
8674
|
-
return this.buffered < this.highWaterMark;
|
|
8675
|
-
}
|
|
8676
|
-
shift() {
|
|
8677
|
-
const data = this.queue.shift();
|
|
8678
|
-
this.buffered -= this.byteLength(data);
|
|
8679
|
-
if (this.buffered === 0) this.stream._duplexState &= READ_NOT_QUEUED;
|
|
8680
|
-
return data;
|
|
8681
|
-
}
|
|
8682
|
-
unshift(data) {
|
|
8683
|
-
const pending = [this.map !== null ? this.map(data) : data];
|
|
8684
|
-
while (this.buffered > 0) pending.push(this.shift());
|
|
8685
|
-
for (let i = 0; i < pending.length - 1; i++) {
|
|
8686
|
-
const data = pending[i];
|
|
8687
|
-
this.buffered += this.byteLength(data);
|
|
8688
|
-
this.queue.push(data);
|
|
8689
|
-
}
|
|
8690
|
-
this.push(pending[pending.length - 1]);
|
|
8691
|
-
}
|
|
8692
|
-
read() {
|
|
8693
|
-
const stream = this.stream;
|
|
8694
|
-
if ((stream._duplexState & READ_STATUS) === READ_QUEUED) {
|
|
8695
|
-
const data = this.shift();
|
|
8696
|
-
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED;
|
|
8697
|
-
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
|
|
8698
|
-
return data;
|
|
8699
|
-
}
|
|
8700
|
-
if (this.readAhead === false) {
|
|
8701
|
-
stream._duplexState |= READ_READ_AHEAD;
|
|
8702
|
-
this.updateNextTick();
|
|
8703
|
-
}
|
|
8704
|
-
return null;
|
|
8705
|
-
}
|
|
8706
|
-
drain() {
|
|
8707
|
-
const stream = this.stream;
|
|
8708
|
-
while ((stream._duplexState & READ_STATUS) === READ_QUEUED && (stream._duplexState & READ_FLOWING) !== 0) {
|
|
8709
|
-
const data = this.shift();
|
|
8710
|
-
if (this.pipeTo !== null && this.pipeTo.write(data) === false) stream._duplexState &= READ_PIPE_NOT_DRAINED;
|
|
8711
|
-
if ((stream._duplexState & READ_EMIT_DATA) !== 0) stream.emit("data", data);
|
|
8712
|
-
}
|
|
8713
|
-
}
|
|
8714
|
-
update() {
|
|
8715
|
-
const stream = this.stream;
|
|
8716
|
-
stream._duplexState |= READ_UPDATING;
|
|
8717
|
-
do {
|
|
8718
|
-
this.drain();
|
|
8719
|
-
while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === READ_READ_AHEAD) {
|
|
8720
|
-
stream._duplexState |= READ_ACTIVE_AND_NEEDS_PUSH;
|
|
8721
|
-
stream._read(this.afterRead);
|
|
8722
|
-
this.drain();
|
|
8723
|
-
}
|
|
8724
|
-
if ((stream._duplexState & READ_READABLE_STATUS) === READ_EMIT_READABLE_AND_QUEUED) {
|
|
8725
|
-
stream._duplexState |= READ_EMITTED_READABLE;
|
|
8726
|
-
stream.emit("readable");
|
|
8727
|
-
}
|
|
8728
|
-
if ((stream._duplexState & READ_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary();
|
|
8729
|
-
} while (this.continueUpdate() === true);
|
|
8730
|
-
stream._duplexState &= READ_NOT_UPDATING;
|
|
8731
|
-
}
|
|
8732
|
-
updateNonPrimary() {
|
|
8733
|
-
const stream = this.stream;
|
|
8734
|
-
if ((stream._duplexState & READ_ENDING_STATUS) === READ_ENDING) {
|
|
8735
|
-
stream._duplexState = (stream._duplexState | READ_DONE) & READ_NOT_ENDING;
|
|
8736
|
-
stream.emit("end");
|
|
8737
|
-
if ((stream._duplexState & AUTO_DESTROY) === DONE) stream._duplexState |= DESTROYING;
|
|
8738
|
-
if (this.pipeTo !== null) this.pipeTo.end();
|
|
8739
|
-
}
|
|
8740
|
-
if ((stream._duplexState & DESTROY_STATUS) === DESTROYING) {
|
|
8741
|
-
if ((stream._duplexState & ACTIVE_OR_TICKING) === 0) {
|
|
8742
|
-
stream._duplexState |= ACTIVE;
|
|
8743
|
-
stream._destroy(afterDestroy.bind(this));
|
|
8744
|
-
}
|
|
8745
|
-
return;
|
|
8746
|
-
}
|
|
8747
|
-
if ((stream._duplexState & IS_OPENING) === OPENING) {
|
|
8748
|
-
stream._duplexState = (stream._duplexState | ACTIVE) & NOT_OPENING;
|
|
8749
|
-
stream._open(afterOpen.bind(this));
|
|
8750
|
-
}
|
|
8751
|
-
}
|
|
8752
|
-
continueUpdate() {
|
|
8753
|
-
if ((this.stream._duplexState & READ_NEXT_TICK) === 0) return false;
|
|
8754
|
-
this.stream._duplexState &= READ_NOT_NEXT_TICK;
|
|
8755
|
-
return true;
|
|
8756
|
-
}
|
|
8757
|
-
updateCallback() {
|
|
8758
|
-
if ((this.stream._duplexState & READ_UPDATE_SYNC_STATUS) === READ_PRIMARY) this.update();
|
|
8759
|
-
else this.updateNextTick();
|
|
8760
|
-
}
|
|
8761
|
-
updateNextTickIfOpen() {
|
|
8762
|
-
if ((this.stream._duplexState & READ_NEXT_TICK_OR_OPENING) !== 0) return;
|
|
8763
|
-
this.stream._duplexState |= READ_NEXT_TICK;
|
|
8764
|
-
if ((this.stream._duplexState & READ_UPDATING) === 0) qmt(this.afterUpdateNextTick);
|
|
8765
|
-
}
|
|
8766
|
-
updateNextTick() {
|
|
8767
|
-
if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return;
|
|
8768
|
-
this.stream._duplexState |= READ_NEXT_TICK;
|
|
8769
|
-
if ((this.stream._duplexState & READ_UPDATING) === 0) qmt(this.afterUpdateNextTick);
|
|
8770
|
-
}
|
|
8771
|
-
};
|
|
8772
|
-
var TransformState = class {
|
|
8773
|
-
constructor(stream) {
|
|
8774
|
-
this.data = null;
|
|
8775
|
-
this.afterTransform = afterTransform.bind(stream);
|
|
8776
|
-
this.afterFinal = null;
|
|
8777
|
-
}
|
|
8778
|
-
};
|
|
8779
|
-
var Pipeline = class {
|
|
8780
|
-
constructor(src, dst, cb) {
|
|
8781
|
-
this.from = src;
|
|
8782
|
-
this.to = dst;
|
|
8783
|
-
this.afterPipe = cb;
|
|
8784
|
-
this.error = null;
|
|
8785
|
-
this.pipeToFinished = false;
|
|
8786
|
-
}
|
|
8787
|
-
finished() {
|
|
8788
|
-
this.pipeToFinished = true;
|
|
8789
|
-
}
|
|
8790
|
-
done(stream, err) {
|
|
8791
|
-
if (err) this.error = err;
|
|
8792
|
-
if (stream === this.to) {
|
|
8793
|
-
this.to = null;
|
|
8794
|
-
if (this.from !== null) {
|
|
8795
|
-
if ((this.from._duplexState & READ_DONE) === 0 || !this.pipeToFinished) this.from.destroy(this.error || /* @__PURE__ */ new Error("Writable stream closed prematurely"));
|
|
8796
|
-
return;
|
|
8797
|
-
}
|
|
8798
|
-
}
|
|
8799
|
-
if (stream === this.from) {
|
|
8800
|
-
this.from = null;
|
|
8801
|
-
if (this.to !== null) {
|
|
8802
|
-
if ((stream._duplexState & READ_DONE) === 0) this.to.destroy(this.error || /* @__PURE__ */ new Error("Readable stream closed before ending"));
|
|
8803
|
-
return;
|
|
8804
|
-
}
|
|
8805
|
-
}
|
|
8806
|
-
if (this.afterPipe !== null) this.afterPipe(this.error);
|
|
8807
|
-
this.to = this.from = this.afterPipe = null;
|
|
8808
|
-
}
|
|
8809
|
-
};
|
|
8810
|
-
function afterDrain() {
|
|
8811
|
-
this.stream._duplexState |= READ_PIPE_DRAINED;
|
|
8812
|
-
this.updateCallback();
|
|
8813
|
-
}
|
|
8814
|
-
function afterFinal(err) {
|
|
8815
|
-
const stream = this.stream;
|
|
8816
|
-
if (err) stream.destroy(err);
|
|
8817
|
-
if ((stream._duplexState & DESTROY_STATUS) === 0) {
|
|
8818
|
-
stream._duplexState |= WRITE_DONE;
|
|
8819
|
-
stream.emit("finish");
|
|
8820
|
-
}
|
|
8821
|
-
if ((stream._duplexState & AUTO_DESTROY) === DONE) stream._duplexState |= DESTROYING;
|
|
8822
|
-
stream._duplexState &= WRITE_NOT_FINISHING;
|
|
8823
|
-
if ((stream._duplexState & WRITE_UPDATING) === 0) this.update();
|
|
8824
|
-
else this.updateNextTick();
|
|
8825
|
-
}
|
|
8826
|
-
function afterDestroy(err) {
|
|
8827
|
-
const stream = this.stream;
|
|
8828
|
-
if (!err && !StreamError.isStreamDestroyed(this.error)) err = this.error;
|
|
8829
|
-
if (err) stream.emit("error", err);
|
|
8830
|
-
stream._duplexState |= DESTROYED;
|
|
8831
|
-
stream.emit("close");
|
|
8832
|
-
const rs = stream._readableState;
|
|
8833
|
-
const ws = stream._writableState;
|
|
8834
|
-
if (rs !== null && rs.pipeline !== null) rs.pipeline.done(stream, err);
|
|
8835
|
-
if (ws !== null) {
|
|
8836
|
-
while (ws.drains !== null && ws.drains.length > 0) ws.drains.shift().resolve(false);
|
|
8837
|
-
if (ws.pipeline !== null) ws.pipeline.done(stream, err);
|
|
8838
|
-
}
|
|
8839
|
-
}
|
|
8840
|
-
function afterWrite(err) {
|
|
8841
|
-
const stream = this.stream;
|
|
8842
|
-
if (err) stream.destroy(err);
|
|
8843
|
-
stream._duplexState &= WRITE_NOT_ACTIVE;
|
|
8844
|
-
if (this.drains !== null) tickDrains(this.drains);
|
|
8845
|
-
if ((stream._duplexState & WRITE_DRAIN_STATUS) === WRITE_UNDRAINED) {
|
|
8846
|
-
stream._duplexState &= WRITE_DRAINED;
|
|
8847
|
-
if ((stream._duplexState & WRITE_EMIT_DRAIN) === WRITE_EMIT_DRAIN) stream.emit("drain");
|
|
8848
|
-
}
|
|
8849
|
-
this.updateCallback();
|
|
8850
|
-
}
|
|
8851
|
-
function afterRead(err) {
|
|
8852
|
-
if (err) this.stream.destroy(err);
|
|
8853
|
-
this.stream._duplexState &= READ_NOT_ACTIVE;
|
|
8854
|
-
if (this.readAhead === false && (this.stream._duplexState & READ_RESUMED) === 0) this.stream._duplexState &= READ_NO_READ_AHEAD;
|
|
8855
|
-
this.updateCallback();
|
|
8856
|
-
}
|
|
8857
|
-
function updateReadNT() {
|
|
8858
|
-
if ((this.stream._duplexState & READ_UPDATING) === 0) {
|
|
8859
|
-
this.stream._duplexState &= READ_NOT_NEXT_TICK;
|
|
8860
|
-
this.update();
|
|
8861
|
-
}
|
|
8862
|
-
}
|
|
8863
|
-
function updateWriteNT() {
|
|
8864
|
-
if ((this.stream._duplexState & WRITE_UPDATING) === 0) {
|
|
8865
|
-
this.stream._duplexState &= WRITE_NOT_NEXT_TICK;
|
|
8866
|
-
this.update();
|
|
8867
|
-
}
|
|
8868
|
-
}
|
|
8869
|
-
function tickDrains(drains) {
|
|
8870
|
-
for (let i = 0; i < drains.length; i++) if (--drains[i].writes === 0) {
|
|
8871
|
-
drains.shift().resolve(true);
|
|
8872
|
-
i--;
|
|
8873
|
-
}
|
|
8874
|
-
}
|
|
8875
|
-
function afterOpen(err) {
|
|
8876
|
-
const stream = this.stream;
|
|
8877
|
-
if (err) stream.destroy(err);
|
|
8878
|
-
if ((stream._duplexState & DESTROYING) === 0) {
|
|
8879
|
-
if ((stream._duplexState & READ_PRIMARY_STATUS) === 0) stream._duplexState |= READ_PRIMARY;
|
|
8880
|
-
if ((stream._duplexState & WRITE_PRIMARY_STATUS) === 0) stream._duplexState |= WRITE_PRIMARY;
|
|
8881
|
-
stream.emit("open");
|
|
8882
|
-
}
|
|
8883
|
-
stream._duplexState &= NOT_ACTIVE;
|
|
8884
|
-
if (stream._writableState !== null) stream._writableState.updateCallback();
|
|
8885
|
-
if (stream._readableState !== null) stream._readableState.updateCallback();
|
|
8886
|
-
}
|
|
8887
|
-
function afterTransform(err, data) {
|
|
8888
|
-
if (data !== void 0 && data !== null) this.push(data);
|
|
8889
|
-
this._writableState.afterWrite(err);
|
|
8890
|
-
}
|
|
8891
|
-
function newListener(name) {
|
|
8892
|
-
if (this._readableState !== null) {
|
|
8893
|
-
if (name === "data") {
|
|
8894
|
-
this._duplexState |= 133376;
|
|
8895
|
-
this._readableState.updateNextTick();
|
|
8896
|
-
}
|
|
8897
|
-
if (name === "readable") {
|
|
8898
|
-
this._duplexState |= READ_EMIT_READABLE;
|
|
8899
|
-
this._readableState.updateNextTick();
|
|
8900
|
-
}
|
|
8901
|
-
}
|
|
8902
|
-
if (this._writableState !== null) {
|
|
8903
|
-
if (name === "drain") {
|
|
8904
|
-
this._duplexState |= WRITE_EMIT_DRAIN;
|
|
8905
|
-
this._writableState.updateNextTick();
|
|
8906
|
-
}
|
|
8907
|
-
}
|
|
8908
|
-
}
|
|
8909
|
-
var Stream = class extends EventEmitter {
|
|
8910
|
-
constructor(opts) {
|
|
8911
|
-
super();
|
|
8912
|
-
this._duplexState = 0;
|
|
8913
|
-
this._readableState = null;
|
|
8914
|
-
this._writableState = null;
|
|
8915
|
-
if (opts) {
|
|
8916
|
-
if (opts.open) this._open = opts.open;
|
|
8917
|
-
if (opts.destroy) this._destroy = opts.destroy;
|
|
8918
|
-
if (opts.predestroy) this._predestroy = opts.predestroy;
|
|
8919
|
-
if (opts.signal) opts.signal.addEventListener("abort", abort.bind(this));
|
|
8920
|
-
}
|
|
8921
|
-
this.on("newListener", newListener);
|
|
8922
|
-
}
|
|
8923
|
-
_open(cb) {
|
|
8924
|
-
cb(null);
|
|
8925
|
-
}
|
|
8926
|
-
_destroy(cb) {
|
|
8927
|
-
cb(null);
|
|
8928
|
-
}
|
|
8929
|
-
_predestroy() {}
|
|
8930
|
-
get readable() {
|
|
8931
|
-
return this._readableState !== null ? true : void 0;
|
|
8932
|
-
}
|
|
8933
|
-
get writable() {
|
|
8934
|
-
return this._writableState !== null ? true : void 0;
|
|
8935
|
-
}
|
|
8936
|
-
get destroyed() {
|
|
8937
|
-
return (this._duplexState & DESTROYED) !== 0;
|
|
8938
|
-
}
|
|
8939
|
-
get destroying() {
|
|
8940
|
-
return (this._duplexState & DESTROY_STATUS) !== 0;
|
|
8941
|
-
}
|
|
8942
|
-
destroy(err) {
|
|
8943
|
-
if ((this._duplexState & DESTROY_STATUS) === 0) {
|
|
8944
|
-
if (!err) err = StreamError.STREAM_DESTROYED();
|
|
8945
|
-
this._duplexState = (this._duplexState | DESTROYING) & NON_PRIMARY;
|
|
8946
|
-
if (this._readableState !== null) {
|
|
8947
|
-
this._readableState.highWaterMark = 0;
|
|
8948
|
-
this._readableState.error = err;
|
|
8949
|
-
}
|
|
8950
|
-
if (this._writableState !== null) {
|
|
8951
|
-
this._writableState.highWaterMark = 0;
|
|
8952
|
-
this._writableState.error = err;
|
|
8953
|
-
}
|
|
8954
|
-
this._duplexState |= PREDESTROYING;
|
|
8955
|
-
this._predestroy();
|
|
8956
|
-
this._duplexState &= NOT_PREDESTROYING;
|
|
8957
|
-
if (this._readableState !== null) this._readableState.updateNextTick();
|
|
8958
|
-
if (this._writableState !== null) this._writableState.updateNextTick();
|
|
8959
|
-
}
|
|
8960
|
-
}
|
|
8961
|
-
};
|
|
8962
|
-
var Readable = class Readable extends Stream {
|
|
8963
|
-
constructor(opts) {
|
|
8964
|
-
super(opts);
|
|
8965
|
-
this._duplexState |= 8519681;
|
|
8966
|
-
this._readableState = new ReadableState(this, opts);
|
|
8967
|
-
if (opts) {
|
|
8968
|
-
if (this._readableState.readAhead === false) this._duplexState &= READ_NO_READ_AHEAD;
|
|
8969
|
-
if (opts.read) this._read = opts.read;
|
|
8970
|
-
if (opts.eagerOpen) this._readableState.updateNextTick();
|
|
8971
|
-
if (opts.encoding) this.setEncoding(opts.encoding);
|
|
8972
|
-
}
|
|
8973
|
-
}
|
|
8974
|
-
static deferred(fn, opts) {
|
|
8975
|
-
const out = new PassThrough(opts);
|
|
8976
|
-
fn().then((src) => {
|
|
8977
|
-
if (src === null) return out.end();
|
|
8978
|
-
if (out.destroying) return;
|
|
8979
|
-
pipeline(src, out, noop);
|
|
8980
|
-
}).catch((err) => out.destroy(err));
|
|
8981
|
-
return out;
|
|
8982
|
-
}
|
|
8983
|
-
setEncoding(encoding) {
|
|
8984
|
-
const dec = new TextDecoder(encoding);
|
|
8985
|
-
const map = this._readableState.map || echo;
|
|
8986
|
-
this._readableState.map = mapOrSkip;
|
|
8987
|
-
return this;
|
|
8988
|
-
function mapOrSkip(data) {
|
|
8989
|
-
const next = dec.push(data);
|
|
8990
|
-
return next === "" && (data.byteLength !== 0 || dec.remaining > 0) ? null : map(next);
|
|
8991
|
-
}
|
|
8992
|
-
}
|
|
8993
|
-
_read(cb) {
|
|
8994
|
-
cb(null);
|
|
8995
|
-
}
|
|
8996
|
-
pipe(dest, cb) {
|
|
8997
|
-
this._readableState.updateNextTick();
|
|
8998
|
-
this._readableState.pipe(dest, cb);
|
|
8999
|
-
return dest;
|
|
9000
|
-
}
|
|
9001
|
-
read() {
|
|
9002
|
-
this._readableState.updateNextTick();
|
|
9003
|
-
return this._readableState.read();
|
|
9004
|
-
}
|
|
9005
|
-
push(data) {
|
|
9006
|
-
this._readableState.updateNextTickIfOpen();
|
|
9007
|
-
return this._readableState.push(data);
|
|
9008
|
-
}
|
|
9009
|
-
unshift(data) {
|
|
9010
|
-
this._readableState.updateNextTickIfOpen();
|
|
9011
|
-
return this._readableState.unshift(data);
|
|
9012
|
-
}
|
|
9013
|
-
resume() {
|
|
9014
|
-
this._duplexState |= READ_RESUMED_READ_AHEAD;
|
|
9015
|
-
this._readableState.updateNextTick();
|
|
9016
|
-
return this;
|
|
9017
|
-
}
|
|
9018
|
-
pause() {
|
|
9019
|
-
this._duplexState &= this._readableState.readAhead === false ? READ_PAUSED_NO_READ_AHEAD : READ_PAUSED;
|
|
9020
|
-
return this;
|
|
9021
|
-
}
|
|
9022
|
-
static _fromAsyncIterator(ite, opts) {
|
|
9023
|
-
let destroy;
|
|
9024
|
-
const rs = new Readable({
|
|
9025
|
-
...opts,
|
|
9026
|
-
read(cb) {
|
|
9027
|
-
ite.next().then(push).then(cb.bind(null, null)).catch(cb);
|
|
9028
|
-
},
|
|
9029
|
-
predestroy() {
|
|
9030
|
-
destroy = ite.return();
|
|
9031
|
-
},
|
|
9032
|
-
destroy(cb) {
|
|
9033
|
-
if (!destroy) return cb(null);
|
|
9034
|
-
destroy.then(cb.bind(null, null)).catch(cb);
|
|
9035
|
-
}
|
|
9036
|
-
});
|
|
9037
|
-
return rs;
|
|
9038
|
-
function push(data) {
|
|
9039
|
-
if (data.done) rs.push(null);
|
|
9040
|
-
else rs.push(data.value);
|
|
9041
|
-
}
|
|
9042
|
-
}
|
|
9043
|
-
static from(data, opts) {
|
|
9044
|
-
if (isReadStreamx(data)) return data;
|
|
9045
|
-
if (data[asyncIterator]) return this._fromAsyncIterator(data[asyncIterator](), opts);
|
|
9046
|
-
if (!Array.isArray(data)) data = data === void 0 ? [] : [data];
|
|
9047
|
-
let i = 0;
|
|
9048
|
-
return new Readable({
|
|
9049
|
-
...opts,
|
|
9050
|
-
read(cb) {
|
|
9051
|
-
this.push(i === data.length ? null : data[i++]);
|
|
9052
|
-
cb(null);
|
|
9053
|
-
}
|
|
9054
|
-
});
|
|
9055
|
-
}
|
|
9056
|
-
static isBackpressured(rs) {
|
|
9057
|
-
return (rs._duplexState & READ_BACKPRESSURE_STATUS) !== 0 || rs._readableState.buffered >= rs._readableState.highWaterMark;
|
|
9058
|
-
}
|
|
9059
|
-
static isPaused(rs) {
|
|
9060
|
-
return (rs._duplexState & READ_RESUMED) === 0;
|
|
9061
|
-
}
|
|
9062
|
-
[asyncIterator]() {
|
|
9063
|
-
const stream = this;
|
|
9064
|
-
let error = null;
|
|
9065
|
-
let promiseResolve = null;
|
|
9066
|
-
let promiseReject = null;
|
|
9067
|
-
this.on("error", (err) => {
|
|
9068
|
-
error = err;
|
|
9069
|
-
});
|
|
9070
|
-
this.on("readable", onreadable);
|
|
9071
|
-
this.on("close", onclose);
|
|
9072
|
-
return {
|
|
9073
|
-
[asyncIterator]() {
|
|
9074
|
-
return this;
|
|
9075
|
-
},
|
|
9076
|
-
next() {
|
|
9077
|
-
return new Promise(function(resolve, reject) {
|
|
9078
|
-
promiseResolve = resolve;
|
|
9079
|
-
promiseReject = reject;
|
|
9080
|
-
const data = stream.read();
|
|
9081
|
-
if (data !== null) ondata(data);
|
|
9082
|
-
else if ((stream._duplexState & DESTROYED) !== 0) ondata(null);
|
|
9083
|
-
});
|
|
9084
|
-
},
|
|
9085
|
-
return() {
|
|
9086
|
-
return destroy(null);
|
|
9087
|
-
},
|
|
9088
|
-
throw(err) {
|
|
9089
|
-
return destroy(err);
|
|
9090
|
-
}
|
|
9091
|
-
};
|
|
9092
|
-
function onreadable() {
|
|
9093
|
-
if (promiseResolve !== null) ondata(stream.read());
|
|
9094
|
-
}
|
|
9095
|
-
function onclose() {
|
|
9096
|
-
if (promiseResolve !== null) ondata(null);
|
|
9097
|
-
}
|
|
9098
|
-
function ondata(data) {
|
|
9099
|
-
if (promiseReject === null) return;
|
|
9100
|
-
if (error) promiseReject(error);
|
|
9101
|
-
else if (data === null && (stream._duplexState & READ_DONE) === 0) promiseReject(StreamError.STREAM_DESTROYED());
|
|
9102
|
-
else promiseResolve({
|
|
9103
|
-
value: data,
|
|
9104
|
-
done: data === null
|
|
9105
|
-
});
|
|
9106
|
-
promiseReject = promiseResolve = null;
|
|
9107
|
-
}
|
|
9108
|
-
function destroy(err) {
|
|
9109
|
-
stream.destroy(err);
|
|
9110
|
-
return new Promise((resolve, reject) => {
|
|
9111
|
-
if (stream._duplexState & DESTROYED) return resolve({
|
|
9112
|
-
value: void 0,
|
|
9113
|
-
done: true
|
|
9114
|
-
});
|
|
9115
|
-
stream.once("close", function() {
|
|
9116
|
-
if (err) reject(err);
|
|
9117
|
-
else resolve({
|
|
9118
|
-
value: void 0,
|
|
9119
|
-
done: true
|
|
9120
|
-
});
|
|
9121
|
-
});
|
|
9122
|
-
});
|
|
9123
|
-
}
|
|
9124
|
-
}
|
|
9125
|
-
};
|
|
9126
|
-
var Writable = class extends Stream {
|
|
9127
|
-
constructor(opts) {
|
|
9128
|
-
super(opts);
|
|
9129
|
-
this._duplexState |= 16385;
|
|
9130
|
-
this._writableState = new WritableState(this, opts);
|
|
9131
|
-
if (opts) {
|
|
9132
|
-
if (opts.writev) this._writev = opts.writev;
|
|
9133
|
-
if (opts.write) this._write = opts.write;
|
|
9134
|
-
if (opts.final) this._final = opts.final;
|
|
9135
|
-
if (opts.eagerOpen) this._writableState.updateNextTick();
|
|
9136
|
-
}
|
|
9137
|
-
}
|
|
9138
|
-
cork() {
|
|
9139
|
-
this._duplexState |= WRITE_CORKED;
|
|
9140
|
-
}
|
|
9141
|
-
uncork() {
|
|
9142
|
-
this._duplexState &= WRITE_NOT_CORKED;
|
|
9143
|
-
this._writableState.updateNextTick();
|
|
9144
|
-
}
|
|
9145
|
-
_writev(batch, cb) {
|
|
9146
|
-
cb(null);
|
|
9147
|
-
}
|
|
9148
|
-
_write(data, cb) {
|
|
9149
|
-
this._writableState.autoBatch(data, cb);
|
|
9150
|
-
}
|
|
9151
|
-
_final(cb) {
|
|
9152
|
-
cb(null);
|
|
9153
|
-
}
|
|
9154
|
-
static isBackpressured(ws) {
|
|
9155
|
-
return (ws._duplexState & WRITE_BACKPRESSURE_STATUS) !== 0;
|
|
9156
|
-
}
|
|
9157
|
-
static drained(ws) {
|
|
9158
|
-
if (ws.destroyed) return Promise.resolve(false);
|
|
9159
|
-
const state = ws._writableState;
|
|
9160
|
-
const writes = (isWritev(ws) ? Math.min(1, state.queue.length) : state.queue.length) + (ws._duplexState & WRITE_WRITING ? 1 : 0);
|
|
9161
|
-
if (writes === 0) return Promise.resolve(true);
|
|
9162
|
-
if (state.drains === null) state.drains = [];
|
|
9163
|
-
return new Promise((resolve) => {
|
|
9164
|
-
state.drains.push({
|
|
9165
|
-
writes,
|
|
9166
|
-
resolve
|
|
9167
|
-
});
|
|
9168
|
-
});
|
|
9169
|
-
}
|
|
9170
|
-
write(data) {
|
|
9171
|
-
this._writableState.updateNextTick();
|
|
9172
|
-
return this._writableState.push(data);
|
|
9173
|
-
}
|
|
9174
|
-
end(data) {
|
|
9175
|
-
this._writableState.updateNextTick();
|
|
9176
|
-
this._writableState.end(data);
|
|
9177
|
-
return this;
|
|
9178
|
-
}
|
|
9179
|
-
};
|
|
9180
|
-
var Duplex = class extends Readable {
|
|
9181
|
-
constructor(opts) {
|
|
9182
|
-
super(opts);
|
|
9183
|
-
this._duplexState = OPENING | this._duplexState & READ_READ_AHEAD;
|
|
9184
|
-
this._writableState = new WritableState(this, opts);
|
|
9185
|
-
if (opts) {
|
|
9186
|
-
if (opts.writev) this._writev = opts.writev;
|
|
9187
|
-
if (opts.write) this._write = opts.write;
|
|
9188
|
-
if (opts.final) this._final = opts.final;
|
|
9189
|
-
}
|
|
9190
|
-
}
|
|
9191
|
-
cork() {
|
|
9192
|
-
this._duplexState |= WRITE_CORKED;
|
|
9193
|
-
}
|
|
9194
|
-
uncork() {
|
|
9195
|
-
this._duplexState &= WRITE_NOT_CORKED;
|
|
9196
|
-
this._writableState.updateNextTick();
|
|
9197
|
-
}
|
|
9198
|
-
_writev(batch, cb) {
|
|
9199
|
-
cb(null);
|
|
9200
|
-
}
|
|
9201
|
-
_write(data, cb) {
|
|
9202
|
-
this._writableState.autoBatch(data, cb);
|
|
9203
|
-
}
|
|
9204
|
-
_final(cb) {
|
|
9205
|
-
cb(null);
|
|
9206
|
-
}
|
|
9207
|
-
write(data) {
|
|
9208
|
-
this._writableState.updateNextTick();
|
|
9209
|
-
return this._writableState.push(data);
|
|
9210
|
-
}
|
|
9211
|
-
end(data) {
|
|
9212
|
-
this._writableState.updateNextTick();
|
|
9213
|
-
this._writableState.end(data);
|
|
9214
|
-
return this;
|
|
9215
|
-
}
|
|
9216
|
-
};
|
|
9217
|
-
var Transform = class extends Duplex {
|
|
9218
|
-
constructor(opts) {
|
|
9219
|
-
super(opts);
|
|
9220
|
-
this._transformState = new TransformState(this);
|
|
9221
|
-
if (opts) {
|
|
9222
|
-
if (opts.transform) this._transform = opts.transform;
|
|
9223
|
-
if (opts.flush) this._flush = opts.flush;
|
|
9224
|
-
}
|
|
9225
|
-
}
|
|
9226
|
-
_write(data, cb) {
|
|
9227
|
-
if (this._readableState.buffered >= this._readableState.highWaterMark) this._transformState.data = data;
|
|
9228
|
-
else this._transform(data, this._transformState.afterTransform);
|
|
9229
|
-
}
|
|
9230
|
-
_read(cb) {
|
|
9231
|
-
if (this._transformState.data !== null) {
|
|
9232
|
-
const data = this._transformState.data;
|
|
9233
|
-
this._transformState.data = null;
|
|
9234
|
-
cb(null);
|
|
9235
|
-
this._transform(data, this._transformState.afterTransform);
|
|
9236
|
-
} else cb(null);
|
|
9237
|
-
}
|
|
9238
|
-
destroy(err) {
|
|
9239
|
-
super.destroy(err);
|
|
9240
|
-
if (this._transformState.data !== null) {
|
|
9241
|
-
this._transformState.data = null;
|
|
9242
|
-
this._transformState.afterTransform();
|
|
9243
|
-
}
|
|
9244
|
-
}
|
|
9245
|
-
_transform(data, cb) {
|
|
9246
|
-
cb(null, data);
|
|
9247
|
-
}
|
|
9248
|
-
_flush(cb) {
|
|
9249
|
-
cb(null);
|
|
9250
|
-
}
|
|
9251
|
-
_final(cb) {
|
|
9252
|
-
this._transformState.afterFinal = cb;
|
|
9253
|
-
this._flush(transformAfterFlush.bind(this));
|
|
9254
|
-
}
|
|
9255
|
-
};
|
|
9256
|
-
var PassThrough = class extends Transform {};
|
|
9257
|
-
function transformAfterFlush(err, data) {
|
|
9258
|
-
const cb = this._transformState.afterFinal;
|
|
9259
|
-
if (err) return cb(err);
|
|
9260
|
-
if (data !== null && data !== void 0) this.push(data);
|
|
9261
|
-
this.push(null);
|
|
9262
|
-
cb(null);
|
|
9263
|
-
}
|
|
9264
|
-
function pipelinePromise(...streams) {
|
|
9265
|
-
return new Promise((resolve, reject) => {
|
|
9266
|
-
return pipeline(...streams, (err) => {
|
|
9267
|
-
if (err) return reject(err);
|
|
9268
|
-
resolve();
|
|
9269
|
-
});
|
|
9270
|
-
});
|
|
9271
|
-
}
|
|
9272
|
-
function pipeline(stream, ...streams) {
|
|
9273
|
-
const all = Array.isArray(stream) ? [...stream, ...streams] : [stream, ...streams];
|
|
9274
|
-
const done = all.length && typeof all[all.length - 1] === "function" ? all.pop() : null;
|
|
9275
|
-
if (all.length < 2) throw new Error("Pipeline requires at least 2 streams");
|
|
9276
|
-
let src = all[0];
|
|
9277
|
-
let dest = null;
|
|
9278
|
-
let error = null;
|
|
9279
|
-
for (let i = 1; i < all.length; i++) {
|
|
9280
|
-
dest = all[i];
|
|
9281
|
-
if (isStreamx(src)) src.pipe(dest, onerror);
|
|
9282
|
-
else {
|
|
9283
|
-
errorHandle(src, true, i > 1, onerror);
|
|
9284
|
-
src.pipe(dest);
|
|
9285
|
-
}
|
|
9286
|
-
src = dest;
|
|
9287
|
-
}
|
|
9288
|
-
if (done) {
|
|
9289
|
-
let fin = false;
|
|
9290
|
-
const autoDestroy = isStreamx(dest) || !!(dest._writableState && dest._writableState.autoDestroy);
|
|
9291
|
-
dest.on("error", (err) => {
|
|
9292
|
-
if (error === null) error = err;
|
|
9293
|
-
});
|
|
9294
|
-
dest.on("finish", () => {
|
|
9295
|
-
fin = true;
|
|
9296
|
-
if (!autoDestroy) done(error);
|
|
9297
|
-
});
|
|
9298
|
-
if (autoDestroy) dest.on("close", () => done(error || (fin ? null : StreamError.PREMATURE_CLOSE())));
|
|
9299
|
-
}
|
|
9300
|
-
return dest;
|
|
9301
|
-
function errorHandle(s, rd, wr, onerror) {
|
|
9302
|
-
s.on("error", onerror);
|
|
9303
|
-
s.on("close", onclose);
|
|
9304
|
-
function onclose() {
|
|
9305
|
-
if (rd && s._readableState && !s._readableState.ended) return onerror(StreamError.PREMATURE_CLOSE());
|
|
9306
|
-
if (wr && s._writableState && !s._writableState.ended) return onerror(StreamError.PREMATURE_CLOSE());
|
|
9307
|
-
}
|
|
9308
|
-
}
|
|
9309
|
-
function onerror(err) {
|
|
9310
|
-
if (!err || error) return;
|
|
9311
|
-
error = err;
|
|
9312
|
-
for (const s of all) s.destroy(err);
|
|
9313
|
-
}
|
|
9314
|
-
}
|
|
9315
|
-
function echo(s) {
|
|
9316
|
-
return s;
|
|
9317
|
-
}
|
|
9318
|
-
function isStream(stream) {
|
|
9319
|
-
return !!stream._readableState || !!stream._writableState;
|
|
9320
|
-
}
|
|
9321
|
-
function isStreamx(stream) {
|
|
9322
|
-
return typeof stream._duplexState === "number" && isStream(stream);
|
|
9323
|
-
}
|
|
9324
|
-
function isEnding(stream) {
|
|
9325
|
-
return !!stream._readableState && stream._readableState.ending;
|
|
9326
|
-
}
|
|
9327
|
-
function isEnded(stream) {
|
|
9328
|
-
return !!stream._readableState && stream._readableState.ended;
|
|
9329
|
-
}
|
|
9330
|
-
function isFinishing(stream) {
|
|
9331
|
-
return !!stream._writableState && stream._writableState.ending;
|
|
9332
|
-
}
|
|
9333
|
-
function isFinished(stream) {
|
|
9334
|
-
return !!stream._writableState && stream._writableState.ended;
|
|
9335
|
-
}
|
|
9336
|
-
function getStreamError(stream, opts = {}) {
|
|
9337
|
-
const err = stream._readableState && stream._readableState.error || stream._writableState && stream._writableState.error;
|
|
9338
|
-
return !opts.all && StreamError.isStreamDestroyed(err) ? null : err;
|
|
9339
|
-
}
|
|
9340
|
-
function isReadStreamx(stream) {
|
|
9341
|
-
return isStreamx(stream) && stream.readable;
|
|
9342
|
-
}
|
|
9343
|
-
function isDisturbed(stream) {
|
|
9344
|
-
return (stream._duplexState & OPENING) !== OPENING || (stream._duplexState & DESTROYING) === DESTROYING || (stream._duplexState & ACTIVE_OR_TICKING) !== 0;
|
|
9345
|
-
}
|
|
9346
|
-
function isTypedArray(data) {
|
|
9347
|
-
return typeof data === "object" && data !== null && typeof data.byteLength === "number";
|
|
9348
|
-
}
|
|
9349
|
-
function defaultByteLength(data) {
|
|
9350
|
-
return isTypedArray(data) ? data.byteLength : 1024;
|
|
9351
|
-
}
|
|
9352
|
-
function noop() {}
|
|
9353
|
-
function abort() {
|
|
9354
|
-
this.destroy(StreamError.ABORTED());
|
|
9355
|
-
}
|
|
9356
|
-
function isWritev(s) {
|
|
9357
|
-
return s._writev !== Writable.prototype._writev && s._writev !== Duplex.prototype._writev;
|
|
9358
|
-
}
|
|
9359
|
-
module.exports = {
|
|
9360
|
-
pipeline,
|
|
9361
|
-
pipelinePromise,
|
|
9362
|
-
isStream,
|
|
9363
|
-
isStreamx,
|
|
9364
|
-
isEnding,
|
|
9365
|
-
isEnded,
|
|
9366
|
-
isFinishing,
|
|
9367
|
-
isFinished,
|
|
9368
|
-
isDisturbed,
|
|
9369
|
-
getStreamError,
|
|
9370
|
-
Stream,
|
|
9371
|
-
Writable,
|
|
9372
|
-
Readable,
|
|
9373
|
-
Duplex,
|
|
9374
|
-
Transform,
|
|
9375
|
-
PassThrough
|
|
9376
|
-
};
|
|
9377
|
-
}));
|
|
9378
|
-
//#endregion
|
|
9379
|
-
//#region ../../node_modules/.pnpm/tar-stream@3.2.0/node_modules/tar-stream/headers.js
|
|
9380
|
-
var require_headers = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
9381
|
-
const b4a = require_b4a();
|
|
9382
|
-
const ZEROS = "0000000000000000000";
|
|
9383
|
-
const SEVENS = "7777777777777777777";
|
|
9384
|
-
const ZERO_OFFSET = "0".charCodeAt(0);
|
|
9385
|
-
const USTAR_MAGIC = b4a.from([
|
|
9386
|
-
117,
|
|
9387
|
-
115,
|
|
9388
|
-
116,
|
|
9389
|
-
97,
|
|
9390
|
-
114,
|
|
9391
|
-
0
|
|
9392
|
-
]);
|
|
9393
|
-
const USTAR_VER = b4a.from([ZERO_OFFSET, ZERO_OFFSET]);
|
|
9394
|
-
const GNU_MAGIC = b4a.from([
|
|
9395
|
-
117,
|
|
9396
|
-
115,
|
|
9397
|
-
116,
|
|
9398
|
-
97,
|
|
9399
|
-
114,
|
|
9400
|
-
32
|
|
9401
|
-
]);
|
|
9402
|
-
const GNU_VER = b4a.from([32, 0]);
|
|
9403
|
-
const MASK = 4095;
|
|
9404
|
-
const MAGIC_OFFSET = 257;
|
|
9405
|
-
const VERSION_OFFSET = 263;
|
|
9406
|
-
exports.decodeLongPath = function decodeLongPath(buf, encoding) {
|
|
9407
|
-
return decodeStr(buf, 0, buf.length, encoding);
|
|
9408
|
-
};
|
|
9409
|
-
exports.encodePax = function encodePax(opts) {
|
|
9410
|
-
let result = "";
|
|
9411
|
-
if (opts.name) result += addLength(" path=" + opts.name + "\n");
|
|
9412
|
-
if (opts.linkname) result += addLength(" linkpath=" + opts.linkname + "\n");
|
|
9413
|
-
const pax = opts.pax;
|
|
9414
|
-
if (pax) for (const key in pax) result += addLength(" " + key + "=" + pax[key] + "\n");
|
|
9415
|
-
return b4a.from(result);
|
|
9416
|
-
};
|
|
9417
|
-
exports.decodePax = function decodePax(buf) {
|
|
9418
|
-
const result = {};
|
|
9419
|
-
while (buf.length) {
|
|
9420
|
-
let i = 0;
|
|
9421
|
-
while (i < buf.length && buf[i] !== 32) i++;
|
|
9422
|
-
const len = parseInt(b4a.toString(buf.subarray(0, i)), 10);
|
|
9423
|
-
if (!len) return result;
|
|
9424
|
-
const b = b4a.toString(buf.subarray(i + 1, len - 1));
|
|
9425
|
-
const keyIndex = b.indexOf("=");
|
|
9426
|
-
if (keyIndex === -1) return result;
|
|
9427
|
-
result[b.slice(0, keyIndex)] = b.slice(keyIndex + 1);
|
|
9428
|
-
buf = buf.subarray(len);
|
|
9429
|
-
}
|
|
9430
|
-
return result;
|
|
9431
|
-
};
|
|
9432
|
-
exports.encode = function encode(opts) {
|
|
9433
|
-
const buf = b4a.alloc(512);
|
|
9434
|
-
let name = opts.name;
|
|
9435
|
-
let prefix = "";
|
|
9436
|
-
if (opts.typeflag === 5 && name[name.length - 1] !== "/") name += "/";
|
|
9437
|
-
if (b4a.byteLength(name) !== name.length) return null;
|
|
9438
|
-
while (b4a.byteLength(name) > 100) {
|
|
9439
|
-
const i = name.indexOf("/");
|
|
9440
|
-
if (i === -1) return null;
|
|
9441
|
-
prefix += prefix ? "/" + name.slice(0, i) : name.slice(0, i);
|
|
9442
|
-
name = name.slice(i + 1);
|
|
9443
|
-
}
|
|
9444
|
-
if (b4a.byteLength(name) > 100 || b4a.byteLength(prefix) > 155) return null;
|
|
9445
|
-
if (opts.linkname && b4a.byteLength(opts.linkname) > 100) return null;
|
|
9446
|
-
b4a.write(buf, name);
|
|
9447
|
-
b4a.write(buf, encodeOct(opts.mode & MASK, 6), 100);
|
|
9448
|
-
b4a.write(buf, encodeOct(opts.uid, 6), 108);
|
|
9449
|
-
b4a.write(buf, encodeOct(opts.gid, 6), 116);
|
|
9450
|
-
encodeSize(opts.size, buf, 124);
|
|
9451
|
-
b4a.write(buf, encodeOct(opts.mtime.getTime() / 1e3 | 0, 11), 136);
|
|
9452
|
-
buf[156] = ZERO_OFFSET + toTypeflag(opts.type);
|
|
9453
|
-
if (opts.linkname) b4a.write(buf, opts.linkname, 157);
|
|
9454
|
-
b4a.copy(USTAR_MAGIC, buf, MAGIC_OFFSET);
|
|
9455
|
-
b4a.copy(USTAR_VER, buf, VERSION_OFFSET);
|
|
9456
|
-
if (opts.uname) b4a.write(buf, opts.uname, 265);
|
|
9457
|
-
if (opts.gname) b4a.write(buf, opts.gname, 297);
|
|
9458
|
-
b4a.write(buf, encodeOct(opts.devmajor || 0, 6), 329);
|
|
9459
|
-
b4a.write(buf, encodeOct(opts.devminor || 0, 6), 337);
|
|
9460
|
-
if (prefix) b4a.write(buf, prefix, 345);
|
|
9461
|
-
b4a.write(buf, encodeOct(cksum(buf), 6), 148);
|
|
9462
|
-
return buf;
|
|
9463
|
-
};
|
|
9464
|
-
exports.decode = function decode(buf, filenameEncoding, allowUnknownFormat) {
|
|
9465
|
-
let typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET;
|
|
9466
|
-
let name = decodeStr(buf, 0, 100, filenameEncoding);
|
|
9467
|
-
const mode = decodeOct(buf, 100, 8);
|
|
9468
|
-
const uid = decodeOct(buf, 108, 8);
|
|
9469
|
-
const gid = decodeOct(buf, 116, 8);
|
|
9470
|
-
const size = decodeOct(buf, 124, 12);
|
|
9471
|
-
const mtime = decodeOct(buf, 136, 12);
|
|
9472
|
-
const type = toType(typeflag);
|
|
9473
|
-
const linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding);
|
|
9474
|
-
const uname = decodeStr(buf, 265, 32);
|
|
9475
|
-
const gname = decodeStr(buf, 297, 32);
|
|
9476
|
-
const devmajor = decodeOct(buf, 329, 8);
|
|
9477
|
-
const devminor = decodeOct(buf, 337, 8);
|
|
9478
|
-
const c = cksum(buf);
|
|
9479
|
-
if (c === 256) return null;
|
|
9480
|
-
if (c !== decodeOct(buf, 148, 8)) throw new Error("Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?");
|
|
9481
|
-
if (isUSTAR(buf)) {
|
|
9482
|
-
if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + "/" + name;
|
|
9483
|
-
} else if (isGNU(buf)) {} else if (!allowUnknownFormat) throw new Error("Invalid tar header: unknown format.");
|
|
9484
|
-
if (typeflag === 0 && name && name[name.length - 1] === "/") typeflag = 5;
|
|
9485
|
-
return {
|
|
9486
|
-
name,
|
|
9487
|
-
mode,
|
|
9488
|
-
uid,
|
|
9489
|
-
gid,
|
|
9490
|
-
size,
|
|
9491
|
-
byteOffset: 0,
|
|
9492
|
-
mtime: /* @__PURE__ */ new Date(1e3 * mtime),
|
|
9493
|
-
type,
|
|
9494
|
-
linkname,
|
|
9495
|
-
uname,
|
|
9496
|
-
gname,
|
|
9497
|
-
devmajor,
|
|
9498
|
-
devminor,
|
|
9499
|
-
pax: null
|
|
9500
|
-
};
|
|
9501
|
-
};
|
|
9502
|
-
function isUSTAR(buf) {
|
|
9503
|
-
return b4a.equals(USTAR_MAGIC, buf.subarray(MAGIC_OFFSET, 263));
|
|
9504
|
-
}
|
|
9505
|
-
function isGNU(buf) {
|
|
9506
|
-
return b4a.equals(GNU_MAGIC, buf.subarray(MAGIC_OFFSET, 263)) && b4a.equals(GNU_VER, buf.subarray(VERSION_OFFSET, 265));
|
|
9507
|
-
}
|
|
9508
|
-
function clamp(index, len, defaultValue) {
|
|
9509
|
-
if (typeof index !== "number") return defaultValue;
|
|
9510
|
-
index = ~~index;
|
|
9511
|
-
if (index >= len) return len;
|
|
9512
|
-
if (index >= 0) return index;
|
|
9513
|
-
index += len;
|
|
9514
|
-
if (index >= 0) return index;
|
|
9515
|
-
return 0;
|
|
9516
|
-
}
|
|
9517
|
-
function toType(flag) {
|
|
9518
|
-
switch (flag) {
|
|
9519
|
-
case 0: return "file";
|
|
9520
|
-
case 1: return "link";
|
|
9521
|
-
case 2: return "symlink";
|
|
9522
|
-
case 3: return "character-device";
|
|
9523
|
-
case 4: return "block-device";
|
|
9524
|
-
case 5: return "directory";
|
|
9525
|
-
case 6: return "fifo";
|
|
9526
|
-
case 7: return "contiguous-file";
|
|
9527
|
-
case 72: return "pax-header";
|
|
9528
|
-
case 55: return "pax-global-header";
|
|
9529
|
-
case 27: return "gnu-long-link-path";
|
|
9530
|
-
case 28:
|
|
9531
|
-
case 30: return "gnu-long-path";
|
|
9532
|
-
}
|
|
9533
|
-
return null;
|
|
9534
|
-
}
|
|
9535
|
-
function toTypeflag(flag) {
|
|
9536
|
-
switch (flag) {
|
|
9537
|
-
case "file": return 0;
|
|
9538
|
-
case "link": return 1;
|
|
9539
|
-
case "symlink": return 2;
|
|
9540
|
-
case "character-device": return 3;
|
|
9541
|
-
case "block-device": return 4;
|
|
9542
|
-
case "directory": return 5;
|
|
9543
|
-
case "fifo": return 6;
|
|
9544
|
-
case "contiguous-file": return 7;
|
|
9545
|
-
case "pax-header": return 72;
|
|
9546
|
-
}
|
|
9547
|
-
return 0;
|
|
9548
|
-
}
|
|
9549
|
-
function indexOf(block, num, offset, end) {
|
|
9550
|
-
for (; offset < end; offset++) if (block[offset] === num) return offset;
|
|
9551
|
-
return end;
|
|
9552
|
-
}
|
|
9553
|
-
function cksum(block) {
|
|
9554
|
-
let sum = 256;
|
|
9555
|
-
for (let i = 0; i < 148; i++) sum += block[i];
|
|
9556
|
-
for (let j = 156; j < 512; j++) sum += block[j];
|
|
9557
|
-
return sum;
|
|
9558
|
-
}
|
|
9559
|
-
function encodeOct(val, n) {
|
|
9560
|
-
val = val.toString(8);
|
|
9561
|
-
if (val.length > n) return SEVENS.slice(0, n) + " ";
|
|
9562
|
-
return ZEROS.slice(0, n - val.length) + val + " ";
|
|
9563
|
-
}
|
|
9564
|
-
function encodeSizeBin(num, buf, off) {
|
|
9565
|
-
buf[off] = 128;
|
|
9566
|
-
for (let i = 11; i > 0; i--) {
|
|
9567
|
-
buf[off + i] = num & 255;
|
|
9568
|
-
num = Math.floor(num / 256);
|
|
9569
|
-
}
|
|
9570
|
-
}
|
|
9571
|
-
function encodeSize(num, buf, off) {
|
|
9572
|
-
if (num.toString(8).length > 11) encodeSizeBin(num, buf, off);
|
|
9573
|
-
else b4a.write(buf, encodeOct(num, 11), off);
|
|
9574
|
-
}
|
|
9575
|
-
function parse256(buf) {
|
|
9576
|
-
let positive;
|
|
9577
|
-
if (buf[0] === 128) positive = true;
|
|
9578
|
-
else if (buf[0] === 255) positive = false;
|
|
9579
|
-
else return null;
|
|
9580
|
-
const tuple = [];
|
|
9581
|
-
let i;
|
|
9582
|
-
for (i = buf.length - 1; i > 0; i--) {
|
|
9583
|
-
const byte = buf[i];
|
|
9584
|
-
if (positive) tuple.push(byte);
|
|
9585
|
-
else tuple.push(255 - byte);
|
|
9586
|
-
}
|
|
9587
|
-
let sum = 0;
|
|
9588
|
-
const l = tuple.length;
|
|
9589
|
-
for (i = 0; i < l; i++) sum += tuple[i] * Math.pow(256, i);
|
|
9590
|
-
return positive ? sum : -1 * sum;
|
|
9591
|
-
}
|
|
9592
|
-
function decodeOct(val, offset, length) {
|
|
9593
|
-
val = val.subarray(offset, offset + length);
|
|
9594
|
-
offset = 0;
|
|
9595
|
-
if (val[offset] & 128) return parse256(val);
|
|
9596
|
-
else {
|
|
9597
|
-
while (offset < val.length && val[offset] === 32) offset++;
|
|
9598
|
-
const end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length);
|
|
9599
|
-
while (offset < end && val[offset] === 0) offset++;
|
|
9600
|
-
if (end === offset) return 0;
|
|
9601
|
-
return parseInt(b4a.toString(val.subarray(offset, end)), 8);
|
|
9602
|
-
}
|
|
9603
|
-
}
|
|
9604
|
-
function decodeStr(val, offset, length, encoding) {
|
|
9605
|
-
return b4a.toString(val.subarray(offset, indexOf(val, 0, offset, offset + length)), encoding);
|
|
9606
|
-
}
|
|
9607
|
-
function addLength(str) {
|
|
9608
|
-
const len = b4a.byteLength(str);
|
|
9609
|
-
let digits = Math.floor(Math.log(len) / Math.log(10)) + 1;
|
|
9610
|
-
if (len + digits >= Math.pow(10, digits)) digits++;
|
|
9611
|
-
return len + digits + str;
|
|
9612
|
-
}
|
|
9613
|
-
}));
|
|
9614
|
-
//#endregion
|
|
9615
|
-
//#region ../../node_modules/.pnpm/tar-stream@3.2.0/node_modules/tar-stream/extract.js
|
|
9616
|
-
var require_extract = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9617
|
-
const { Writable, Readable, getStreamError } = require_streamx();
|
|
9618
|
-
const FIFO = require_fast_fifo();
|
|
9619
|
-
const b4a = require_b4a();
|
|
9620
|
-
const headers = require_headers();
|
|
9621
|
-
const EMPTY = b4a.alloc(0);
|
|
9622
|
-
const MAX_HEADER_SIZE = 4 * 1024 * 1024;
|
|
9623
|
-
var BufferList = class {
|
|
9624
|
-
constructor() {
|
|
9625
|
-
this.buffered = 0;
|
|
9626
|
-
this.shifted = 0;
|
|
9627
|
-
this.queue = new FIFO();
|
|
9628
|
-
this._offset = 0;
|
|
9629
|
-
}
|
|
9630
|
-
push(buffer) {
|
|
9631
|
-
this.buffered += buffer.byteLength;
|
|
9632
|
-
this.queue.push(buffer);
|
|
9633
|
-
}
|
|
9634
|
-
shiftFirst(size) {
|
|
9635
|
-
return this.buffered === 0 ? null : this._next(size);
|
|
9636
|
-
}
|
|
9637
|
-
shift(size) {
|
|
9638
|
-
if (size > this.buffered) return null;
|
|
9639
|
-
if (size === 0) return EMPTY;
|
|
9640
|
-
let chunk = this._next(size);
|
|
9641
|
-
if (size === chunk.byteLength) return chunk;
|
|
9642
|
-
const chunks = [chunk];
|
|
9643
|
-
while ((size -= chunk.byteLength) > 0) {
|
|
9644
|
-
chunk = this._next(size);
|
|
9645
|
-
chunks.push(chunk);
|
|
9646
|
-
}
|
|
9647
|
-
return b4a.concat(chunks);
|
|
9648
|
-
}
|
|
9649
|
-
_next(size) {
|
|
9650
|
-
const buf = this.queue.peek();
|
|
9651
|
-
const rem = buf.byteLength - this._offset;
|
|
9652
|
-
if (size >= rem) {
|
|
9653
|
-
const sub = this._offset ? buf.subarray(this._offset, buf.byteLength) : buf;
|
|
9654
|
-
this.queue.shift();
|
|
9655
|
-
this._offset = 0;
|
|
9656
|
-
this.buffered -= rem;
|
|
9657
|
-
this.shifted += rem;
|
|
9658
|
-
return sub;
|
|
9659
|
-
}
|
|
9660
|
-
this.buffered -= size;
|
|
9661
|
-
this.shifted += size;
|
|
9662
|
-
return buf.subarray(this._offset, this._offset += size);
|
|
9663
|
-
}
|
|
9664
|
-
};
|
|
9665
|
-
var Source = class extends Readable {
|
|
9666
|
-
constructor(self, header, offset) {
|
|
9667
|
-
super();
|
|
9668
|
-
this.header = header;
|
|
9669
|
-
this.offset = offset;
|
|
9670
|
-
this._parent = self;
|
|
9671
|
-
}
|
|
9672
|
-
_read(cb) {
|
|
9673
|
-
if (this.header.size === 0) this.push(null);
|
|
9674
|
-
if (this._parent._stream === this) this._parent._update();
|
|
9675
|
-
cb(null);
|
|
9676
|
-
}
|
|
9677
|
-
_predestroy() {
|
|
9678
|
-
this._parent.destroy(getStreamError(this));
|
|
9679
|
-
}
|
|
9680
|
-
_detach() {
|
|
9681
|
-
if (this._parent._stream === this) {
|
|
9682
|
-
this._parent._stream = null;
|
|
9683
|
-
this._parent._missing = overflow(this.header.size);
|
|
9684
|
-
this._parent._update();
|
|
9685
|
-
}
|
|
9686
|
-
}
|
|
9687
|
-
_destroy(cb) {
|
|
9688
|
-
this._detach();
|
|
9689
|
-
cb(null);
|
|
9690
|
-
}
|
|
9691
|
-
};
|
|
9692
|
-
var Extract = class extends Writable {
|
|
9693
|
-
constructor(opts) {
|
|
9694
|
-
super(opts);
|
|
9695
|
-
if (!opts) opts = {};
|
|
9696
|
-
this._buffer = new BufferList();
|
|
9697
|
-
this._offset = 0;
|
|
9698
|
-
this._header = null;
|
|
9699
|
-
this._stream = null;
|
|
9700
|
-
this._missing = 0;
|
|
9701
|
-
this._longHeader = false;
|
|
9702
|
-
this._callback = noop;
|
|
9703
|
-
this._locked = false;
|
|
9704
|
-
this._finished = false;
|
|
9705
|
-
this._pax = null;
|
|
9706
|
-
this._paxGlobal = null;
|
|
9707
|
-
this._gnuLongPath = null;
|
|
9708
|
-
this._gnuLongLinkPath = null;
|
|
9709
|
-
this._filenameEncoding = opts.filenameEncoding || "utf-8";
|
|
9710
|
-
this._allowUnknownFormat = !!opts.allowUnknownFormat;
|
|
9711
|
-
this._unlockBound = this._unlock.bind(this);
|
|
9712
|
-
}
|
|
9713
|
-
_unlock(err) {
|
|
9714
|
-
this._locked = false;
|
|
9715
|
-
if (err) {
|
|
9716
|
-
this.destroy(err);
|
|
9717
|
-
this._continueWrite(err);
|
|
9718
|
-
return;
|
|
9719
|
-
}
|
|
9720
|
-
this._update();
|
|
9721
|
-
}
|
|
9722
|
-
_consumeHeader() {
|
|
9723
|
-
if (this._locked) return false;
|
|
9724
|
-
this._offset = this._buffer.shifted;
|
|
9725
|
-
try {
|
|
9726
|
-
this._header = headers.decode(this._buffer.shift(512), this._filenameEncoding, this._allowUnknownFormat);
|
|
9727
|
-
} catch (err) {
|
|
9728
|
-
this._continueWrite(err);
|
|
9729
|
-
return false;
|
|
9730
|
-
}
|
|
9731
|
-
if (!this._header) return true;
|
|
9732
|
-
this._header.byteOffset = this._buffer.shifted;
|
|
9733
|
-
switch (this._header.type) {
|
|
9734
|
-
case "gnu-long-path":
|
|
9735
|
-
case "gnu-long-link-path":
|
|
9736
|
-
case "pax-global-header":
|
|
9737
|
-
case "pax-header":
|
|
9738
|
-
this._longHeader = true;
|
|
9739
|
-
this._missing = this._header.size;
|
|
9740
|
-
if (this._missing > MAX_HEADER_SIZE) {
|
|
9741
|
-
this._continueWrite(/* @__PURE__ */ new Error("Header exceeds max size"));
|
|
9742
|
-
return false;
|
|
9743
|
-
}
|
|
9744
|
-
return true;
|
|
9745
|
-
}
|
|
9746
|
-
this._locked = true;
|
|
9747
|
-
this._applyLongHeaders();
|
|
9748
|
-
if (!(this._header.size >= 0)) {
|
|
9749
|
-
this._continueWrite(/* @__PURE__ */ new Error("Invalid header"));
|
|
9750
|
-
return false;
|
|
9751
|
-
}
|
|
9752
|
-
if (this._header.size === 0 || this._header.type === "directory") {
|
|
9753
|
-
this.emit("entry", this._header, this._createStream(), this._unlockBound);
|
|
9754
|
-
return true;
|
|
9755
|
-
}
|
|
9756
|
-
this._stream = this._createStream();
|
|
9757
|
-
this._missing = this._header.size;
|
|
9758
|
-
this.emit("entry", this._header, this._stream, this._unlockBound);
|
|
9759
|
-
return true;
|
|
9760
|
-
}
|
|
9761
|
-
_applyLongHeaders() {
|
|
9762
|
-
if (this._gnuLongPath) {
|
|
9763
|
-
this._header.name = this._gnuLongPath;
|
|
9764
|
-
this._gnuLongPath = null;
|
|
9765
|
-
}
|
|
9766
|
-
if (this._gnuLongLinkPath) {
|
|
9767
|
-
this._header.linkname = this._gnuLongLinkPath;
|
|
9768
|
-
this._gnuLongLinkPath = null;
|
|
9769
|
-
}
|
|
9770
|
-
if (this._pax) {
|
|
9771
|
-
if (this._pax.path) this._header.name = this._pax.path;
|
|
9772
|
-
if (this._pax.linkpath) this._header.linkname = this._pax.linkpath;
|
|
9773
|
-
if (this._pax.size) this._header.size = parseInt(this._pax.size, 10);
|
|
9774
|
-
this._header.pax = this._pax;
|
|
9775
|
-
this._pax = null;
|
|
9776
|
-
}
|
|
9777
|
-
}
|
|
9778
|
-
_decodeLongHeader(buf) {
|
|
9779
|
-
switch (this._header.type) {
|
|
9780
|
-
case "gnu-long-path":
|
|
9781
|
-
this._gnuLongPath = headers.decodeLongPath(buf, this._filenameEncoding);
|
|
9782
|
-
break;
|
|
9783
|
-
case "gnu-long-link-path":
|
|
9784
|
-
this._gnuLongLinkPath = headers.decodeLongPath(buf, this._filenameEncoding);
|
|
9785
|
-
break;
|
|
9786
|
-
case "pax-global-header":
|
|
9787
|
-
this._paxGlobal = headers.decodePax(buf);
|
|
9788
|
-
break;
|
|
9789
|
-
case "pax-header":
|
|
9790
|
-
this._pax = this._paxGlobal === null ? headers.decodePax(buf) : Object.assign({}, this._paxGlobal, headers.decodePax(buf));
|
|
9791
|
-
break;
|
|
9792
|
-
}
|
|
9793
|
-
}
|
|
9794
|
-
_consumeLongHeader() {
|
|
9795
|
-
this._longHeader = false;
|
|
9796
|
-
this._missing = overflow(this._header.size);
|
|
9797
|
-
const buf = this._buffer.shift(this._header.size);
|
|
9798
|
-
try {
|
|
9799
|
-
this._decodeLongHeader(buf);
|
|
9800
|
-
} catch (err) {
|
|
9801
|
-
this._continueWrite(err);
|
|
9802
|
-
return false;
|
|
9803
|
-
}
|
|
9804
|
-
return true;
|
|
9805
|
-
}
|
|
9806
|
-
_consumeStream() {
|
|
9807
|
-
const buf = this._buffer.shiftFirst(this._missing);
|
|
9808
|
-
if (buf === null) return false;
|
|
9809
|
-
this._missing -= buf.byteLength;
|
|
9810
|
-
const drained = this._stream.push(buf);
|
|
9811
|
-
if (this._missing === 0) {
|
|
9812
|
-
this._stream.push(null);
|
|
9813
|
-
if (drained) this._stream._detach();
|
|
9814
|
-
return drained && this._locked === false;
|
|
9815
|
-
}
|
|
9816
|
-
return drained;
|
|
9817
|
-
}
|
|
9818
|
-
_createStream() {
|
|
9819
|
-
return new Source(this, this._header, this._offset);
|
|
9820
|
-
}
|
|
9821
|
-
_update() {
|
|
9822
|
-
while (this._buffer.buffered > 0 && !this.destroying) {
|
|
9823
|
-
if (this._missing > 0) {
|
|
9824
|
-
if (this._stream !== null) {
|
|
9825
|
-
if (this._consumeStream() === false) return;
|
|
9826
|
-
continue;
|
|
8306
|
+
}
|
|
8307
|
+
const CHECKSUM_SPACE = 32;
|
|
8308
|
+
function validateChecksum(block) {
|
|
8309
|
+
const stored = readOctal(block, 148, 8);
|
|
8310
|
+
let sum = 0;
|
|
8311
|
+
for (let i = 0; i < block.length; i++) if (i >= 148 && i < 156) sum += CHECKSUM_SPACE;
|
|
8312
|
+
else sum += block[i];
|
|
8313
|
+
return stored === sum;
|
|
8314
|
+
}
|
|
8315
|
+
function parseUstarHeader(block, strict) {
|
|
8316
|
+
if (strict && !validateChecksum(block)) throw new Error("Invalid tar header checksum.");
|
|
8317
|
+
const typeflag = readString(block, 156, 1);
|
|
8318
|
+
const header = {
|
|
8319
|
+
name: readString(block, 0, 100),
|
|
8320
|
+
mode: readOctal(block, 100, 8),
|
|
8321
|
+
uid: readNumeric(block, 108, 8),
|
|
8322
|
+
gid: readNumeric(block, 116, 8),
|
|
8323
|
+
size: readNumeric(block, 124, 12),
|
|
8324
|
+
mtime: /* @__PURE__ */ new Date(readNumeric(block, 136, 12) * 1e3),
|
|
8325
|
+
type: FLAGTYPE[typeflag] || "file",
|
|
8326
|
+
linkname: readString(block, 157, 100)
|
|
8327
|
+
};
|
|
8328
|
+
const magic = readString(block, 257, 6);
|
|
8329
|
+
if (magic.trim() === "ustar") {
|
|
8330
|
+
header.uname = readString(block, 265, 32);
|
|
8331
|
+
header.gname = readString(block, 297, 32);
|
|
8332
|
+
}
|
|
8333
|
+
if (magic === "ustar") header.prefix = readString(block, 345, 155);
|
|
8334
|
+
return header;
|
|
8335
|
+
}
|
|
8336
|
+
const PAX_MAPPING = {
|
|
8337
|
+
path: ["name", (v) => v],
|
|
8338
|
+
linkpath: ["linkname", (v) => v],
|
|
8339
|
+
size: ["size", (v) => /^\d+$/.test(v) && Number.isSafeInteger(+v) ? +v : NaN],
|
|
8340
|
+
mtime: ["mtime", parseFloat],
|
|
8341
|
+
uid: ["uid", (v) => parseInt(v, 10)],
|
|
8342
|
+
gid: ["gid", (v) => parseInt(v, 10)],
|
|
8343
|
+
uname: ["uname", (v) => v],
|
|
8344
|
+
gname: ["gname", (v) => v]
|
|
8345
|
+
};
|
|
8346
|
+
function parsePax(buffer) {
|
|
8347
|
+
const overrides = Object.create(null);
|
|
8348
|
+
const pax = Object.create(null);
|
|
8349
|
+
let isPax = false;
|
|
8350
|
+
let offset = 0;
|
|
8351
|
+
while (offset < buffer.length) {
|
|
8352
|
+
const spaceIndex = buffer.indexOf(32, offset);
|
|
8353
|
+
if (spaceIndex === -1) break;
|
|
8354
|
+
const length = parseInt(decoder.decode(buffer.subarray(offset, spaceIndex)), 10);
|
|
8355
|
+
if (!(length > 0)) break;
|
|
8356
|
+
const recordEnd = offset + length;
|
|
8357
|
+
const recordStr = decoder.decode(buffer.subarray(spaceIndex + 1, recordEnd - 1));
|
|
8358
|
+
const equalsIndex = recordStr.indexOf("=");
|
|
8359
|
+
if (equalsIndex > 0) {
|
|
8360
|
+
const key = recordStr.slice(0, equalsIndex);
|
|
8361
|
+
const value = recordStr.slice(equalsIndex + 1);
|
|
8362
|
+
pax[key] = value;
|
|
8363
|
+
isPax = true;
|
|
8364
|
+
if (Object.hasOwn(PAX_MAPPING, key)) {
|
|
8365
|
+
const [targetKey, parser] = PAX_MAPPING[key];
|
|
8366
|
+
const parsedValue = parser(value);
|
|
8367
|
+
if (typeof parsedValue === "string" || !Number.isNaN(parsedValue)) overrides[targetKey] = parsedValue;
|
|
8368
|
+
}
|
|
8369
|
+
}
|
|
8370
|
+
offset = recordEnd;
|
|
8371
|
+
}
|
|
8372
|
+
if (isPax) overrides.pax = pax;
|
|
8373
|
+
return overrides;
|
|
8374
|
+
}
|
|
8375
|
+
function applyOverrides(header, overrides) {
|
|
8376
|
+
if (overrides.name !== void 0) header.name = overrides.name;
|
|
8377
|
+
if (overrides.linkname !== void 0) header.linkname = overrides.linkname;
|
|
8378
|
+
if (overrides.size !== void 0) header.size = overrides.size;
|
|
8379
|
+
if (overrides.mtime !== void 0) header.mtime = /* @__PURE__ */ new Date(overrides.mtime * 1e3);
|
|
8380
|
+
if (overrides.uid !== void 0) header.uid = overrides.uid;
|
|
8381
|
+
if (overrides.gid !== void 0) header.gid = overrides.gid;
|
|
8382
|
+
if (overrides.uname !== void 0) header.uname = overrides.uname;
|
|
8383
|
+
if (overrides.gname !== void 0) header.gname = overrides.gname;
|
|
8384
|
+
if (overrides.pax) header.pax = Object.assign({}, header.pax ?? {}, overrides.pax);
|
|
8385
|
+
}
|
|
8386
|
+
function getMetaParser(type) {
|
|
8387
|
+
switch (type) {
|
|
8388
|
+
case "pax-global-header":
|
|
8389
|
+
case "pax-header": return parsePax;
|
|
8390
|
+
case "gnu-long-name": return (data) => ({ name: readString(data, 0, data.length) });
|
|
8391
|
+
case "gnu-long-link-name": return (data) => ({ linkname: readString(data, 0, data.length) });
|
|
8392
|
+
default: return;
|
|
8393
|
+
}
|
|
8394
|
+
}
|
|
8395
|
+
const STATE_HEADER = 0;
|
|
8396
|
+
const STATE_BODY = 1;
|
|
8397
|
+
const MAX_META_SIZE = 8 * 1024 * 1024;
|
|
8398
|
+
const truncateErr = /* @__PURE__ */ new Error("Tar archive is truncated.");
|
|
8399
|
+
function createUnpacker(options = {}) {
|
|
8400
|
+
const strict = options.strict ?? false;
|
|
8401
|
+
const { available, peek, push, discard, pull } = createChunkQueue();
|
|
8402
|
+
let state = STATE_HEADER;
|
|
8403
|
+
let ended = false;
|
|
8404
|
+
let done = false;
|
|
8405
|
+
let eof = false;
|
|
8406
|
+
let currentEntry = null;
|
|
8407
|
+
const paxGlobals = {};
|
|
8408
|
+
let nextEntryOverrides = {};
|
|
8409
|
+
const unpacker = {
|
|
8410
|
+
isEntryActive: () => state === STATE_BODY,
|
|
8411
|
+
isBodyComplete: () => !currentEntry || currentEntry.remaining === 0,
|
|
8412
|
+
canFinish: () => !currentEntry || available() >= currentEntry.remaining + currentEntry.padding,
|
|
8413
|
+
bodyBytes: () => currentEntry && currentEntry.remaining > 0 ? Math.min(currentEntry.remaining, available()) : 0,
|
|
8414
|
+
write(chunk) {
|
|
8415
|
+
if (ended) throw new Error("Archive already ended.");
|
|
8416
|
+
push(chunk);
|
|
8417
|
+
},
|
|
8418
|
+
end() {
|
|
8419
|
+
ended = true;
|
|
8420
|
+
},
|
|
8421
|
+
readHeader() {
|
|
8422
|
+
if (state !== STATE_HEADER) throw new Error("Cannot read header while an entry is active");
|
|
8423
|
+
if (done) return void 0;
|
|
8424
|
+
while (!done) {
|
|
8425
|
+
if (available() < 512) {
|
|
8426
|
+
if (ended) {
|
|
8427
|
+
if (available() > 0 && strict) throw truncateErr;
|
|
8428
|
+
done = true;
|
|
8429
|
+
return;
|
|
9827
8430
|
}
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
8431
|
+
return null;
|
|
8432
|
+
}
|
|
8433
|
+
const headerBlock = peek(512);
|
|
8434
|
+
if (isZeroBlock(headerBlock)) {
|
|
8435
|
+
if (available() < 512 * 2) {
|
|
8436
|
+
if (ended) {
|
|
8437
|
+
if (strict) throw truncateErr;
|
|
8438
|
+
done = true;
|
|
8439
|
+
return;
|
|
8440
|
+
}
|
|
8441
|
+
return null;
|
|
8442
|
+
}
|
|
8443
|
+
if (isZeroBlock(peek(512 * 2).subarray(512))) {
|
|
8444
|
+
discard(512 * 2);
|
|
8445
|
+
done = true;
|
|
8446
|
+
eof = true;
|
|
8447
|
+
return;
|
|
9832
8448
|
}
|
|
9833
|
-
|
|
9834
|
-
|
|
8449
|
+
if (strict) throw new Error("Invalid tar header.");
|
|
8450
|
+
discard(512);
|
|
9835
8451
|
continue;
|
|
9836
8452
|
}
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
this._callback = noop;
|
|
9845
|
-
cb(err);
|
|
9846
|
-
}
|
|
9847
|
-
_write(data, cb) {
|
|
9848
|
-
this._callback = cb;
|
|
9849
|
-
this._buffer.push(data);
|
|
9850
|
-
this._update();
|
|
9851
|
-
}
|
|
9852
|
-
_final(cb) {
|
|
9853
|
-
this._finished = this._missing === 0 && this._buffer.buffered === 0;
|
|
9854
|
-
cb(this._finished ? null : /* @__PURE__ */ new Error("Unexpected end of data"));
|
|
9855
|
-
}
|
|
9856
|
-
_predestroy() {
|
|
9857
|
-
this._continueWrite(null);
|
|
9858
|
-
}
|
|
9859
|
-
_destroy(cb) {
|
|
9860
|
-
if (this._stream) this._stream.destroy(getStreamError(this));
|
|
9861
|
-
cb(null);
|
|
9862
|
-
}
|
|
9863
|
-
[Symbol.asyncIterator]() {
|
|
9864
|
-
let error = null;
|
|
9865
|
-
let promiseResolve = null;
|
|
9866
|
-
let promiseReject = null;
|
|
9867
|
-
let entryStream = null;
|
|
9868
|
-
let entryCallback = null;
|
|
9869
|
-
const extract = this;
|
|
9870
|
-
this.on("entry", onentry);
|
|
9871
|
-
this.on("error", (err) => {
|
|
9872
|
-
error = err;
|
|
9873
|
-
});
|
|
9874
|
-
this.on("close", onclose);
|
|
9875
|
-
return {
|
|
9876
|
-
[Symbol.asyncIterator]() {
|
|
9877
|
-
return this;
|
|
9878
|
-
},
|
|
9879
|
-
next() {
|
|
9880
|
-
return new Promise(onnext);
|
|
9881
|
-
},
|
|
9882
|
-
return() {
|
|
9883
|
-
return destroy(null);
|
|
9884
|
-
},
|
|
9885
|
-
throw(err) {
|
|
9886
|
-
return destroy(err);
|
|
8453
|
+
let internalHeader;
|
|
8454
|
+
try {
|
|
8455
|
+
internalHeader = parseUstarHeader(headerBlock, strict);
|
|
8456
|
+
} catch (err) {
|
|
8457
|
+
if (strict) throw err;
|
|
8458
|
+
discard(512);
|
|
8459
|
+
continue;
|
|
9887
8460
|
}
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
entryStream = null;
|
|
9903
|
-
return;
|
|
8461
|
+
const metaParser = getMetaParser(internalHeader.type);
|
|
8462
|
+
if (metaParser) {
|
|
8463
|
+
if (internalHeader.size > MAX_META_SIZE) throw new Error("Tar metadata entry exceeds maximum size.");
|
|
8464
|
+
const paddedSize = internalHeader.size + (-internalHeader.size & 511);
|
|
8465
|
+
if (available() < 512 + paddedSize) {
|
|
8466
|
+
if (ended && strict) throw truncateErr;
|
|
8467
|
+
return null;
|
|
8468
|
+
}
|
|
8469
|
+
discard(512);
|
|
8470
|
+
const overrides = metaParser(pull(paddedSize).subarray(0, internalHeader.size));
|
|
8471
|
+
if (nextEntryOverrides.pax) nextEntryOverrides = {};
|
|
8472
|
+
const target = internalHeader.type === "pax-global-header" ? paxGlobals : nextEntryOverrides;
|
|
8473
|
+
for (const key in overrides) target[key] = overrides[key];
|
|
8474
|
+
continue;
|
|
9904
8475
|
}
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
8476
|
+
discard(512);
|
|
8477
|
+
const header = internalHeader;
|
|
8478
|
+
if (internalHeader.prefix) header.name = `${internalHeader.prefix}/${header.name}`;
|
|
8479
|
+
applyOverrides(header, paxGlobals);
|
|
8480
|
+
applyOverrides(header, nextEntryOverrides);
|
|
8481
|
+
let archiveSize = header.size;
|
|
8482
|
+
if (isBodyless(header)) {
|
|
8483
|
+
archiveSize = 0;
|
|
8484
|
+
header.size = 0;
|
|
8485
|
+
} else if (header.name.endsWith("/") && header.type === "file") {
|
|
8486
|
+
header.type = DIRECTORY;
|
|
8487
|
+
header.size = 0;
|
|
9914
8488
|
}
|
|
8489
|
+
nextEntryOverrides = {};
|
|
8490
|
+
currentEntry = {
|
|
8491
|
+
header,
|
|
8492
|
+
remaining: archiveSize,
|
|
8493
|
+
padding: -archiveSize & 511
|
|
8494
|
+
};
|
|
8495
|
+
state = STATE_BODY;
|
|
8496
|
+
return header;
|
|
9915
8497
|
}
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
|
|
9925
|
-
|
|
9926
|
-
|
|
9927
|
-
|
|
9928
|
-
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
});
|
|
9951
|
-
});
|
|
9952
|
-
});
|
|
8498
|
+
},
|
|
8499
|
+
streamBody(callback) {
|
|
8500
|
+
if (state !== STATE_BODY || !currentEntry || currentEntry.remaining === 0) return 0;
|
|
8501
|
+
const bytesToFeed = Math.min(currentEntry.remaining, available());
|
|
8502
|
+
if (bytesToFeed === 0) return 0;
|
|
8503
|
+
const fed = pull(bytesToFeed, callback);
|
|
8504
|
+
currentEntry.remaining -= fed;
|
|
8505
|
+
return fed;
|
|
8506
|
+
},
|
|
8507
|
+
skipPadding() {
|
|
8508
|
+
if (state !== STATE_BODY || !currentEntry) return true;
|
|
8509
|
+
if (currentEntry.remaining > 0) throw new Error("Body not fully consumed");
|
|
8510
|
+
if (available() < currentEntry.padding) return false;
|
|
8511
|
+
discard(currentEntry.padding);
|
|
8512
|
+
currentEntry = null;
|
|
8513
|
+
state = STATE_HEADER;
|
|
8514
|
+
return true;
|
|
8515
|
+
},
|
|
8516
|
+
skipEntry() {
|
|
8517
|
+
if (state !== STATE_BODY || !currentEntry) return true;
|
|
8518
|
+
const toDiscard = Math.min(currentEntry.remaining, available());
|
|
8519
|
+
if (toDiscard > 0) {
|
|
8520
|
+
discard(toDiscard);
|
|
8521
|
+
currentEntry.remaining -= toDiscard;
|
|
8522
|
+
}
|
|
8523
|
+
if (currentEntry.remaining > 0) return false;
|
|
8524
|
+
return unpacker.skipPadding();
|
|
8525
|
+
},
|
|
8526
|
+
validateEOF() {
|
|
8527
|
+
if (strict) {
|
|
8528
|
+
if (!eof) throw truncateErr;
|
|
8529
|
+
if (available() > 0) {
|
|
8530
|
+
if (pull(available()).some((byte) => byte !== 0)) throw new Error("Invalid EOF.");
|
|
8531
|
+
}
|
|
9953
8532
|
}
|
|
9954
8533
|
}
|
|
9955
8534
|
};
|
|
9956
|
-
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
return
|
|
9963
|
-
}
|
|
9964
|
-
}));
|
|
9965
|
-
//#endregion
|
|
9966
|
-
//#region ../../node_modules/.pnpm/tar-stream@3.2.0/node_modules/tar-stream/constants.js
|
|
9967
|
-
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9968
|
-
const constants = {
|
|
9969
|
-
S_IFMT: 61440,
|
|
9970
|
-
S_IFDIR: 16384,
|
|
9971
|
-
S_IFCHR: 8192,
|
|
9972
|
-
S_IFBLK: 24576,
|
|
9973
|
-
S_IFIFO: 4096,
|
|
9974
|
-
S_IFLNK: 40960
|
|
9975
|
-
};
|
|
9976
|
-
try {
|
|
9977
|
-
module.exports = __require("fs").constants || constants;
|
|
9978
|
-
} catch {
|
|
9979
|
-
module.exports = constants;
|
|
8535
|
+
return unpacker;
|
|
8536
|
+
}
|
|
8537
|
+
function isZeroBlock(block) {
|
|
8538
|
+
if (block.byteOffset % 8 === 0) {
|
|
8539
|
+
const view = new BigUint64Array(block.buffer, block.byteOffset, block.length / 8);
|
|
8540
|
+
for (let i = 0; i < view.length; i++) if (view[i] !== 0n) return false;
|
|
8541
|
+
return true;
|
|
9980
8542
|
}
|
|
9981
|
-
|
|
8543
|
+
for (let i = 0; i < block.length; i++) if (block[i] !== 0) return false;
|
|
8544
|
+
return true;
|
|
8545
|
+
}
|
|
9982
8546
|
//#endregion
|
|
9983
|
-
//#region ../../node_modules/.pnpm/tar
|
|
9984
|
-
|
|
9985
|
-
const
|
|
9986
|
-
const
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
8547
|
+
//#region ../../node_modules/.pnpm/modern-tar@0.7.7/node_modules/modern-tar/dist/fs/index.js
|
|
8548
|
+
function validateBounds(targetPath, destDir, errorMessage) {
|
|
8549
|
+
const target = path$1.resolve(targetPath);
|
|
8550
|
+
const dest = path$1.resolve(destDir);
|
|
8551
|
+
if (target !== dest && !target.startsWith(dest + path$1.sep)) throw new Error(errorMessage);
|
|
8552
|
+
}
|
|
8553
|
+
const win32Reserved = {
|
|
8554
|
+
":": "",
|
|
8555
|
+
"<": "",
|
|
8556
|
+
">": "",
|
|
8557
|
+
"|": "",
|
|
8558
|
+
"?": "",
|
|
8559
|
+
"*": "",
|
|
8560
|
+
"\"": ""
|
|
8561
|
+
};
|
|
8562
|
+
function normalizeName(name) {
|
|
8563
|
+
const path = name.replace(/\\/g, "/");
|
|
8564
|
+
if (path.split("/").includes("..") || /^[a-zA-Z]:\.\./.test(path)) throw new Error(`${name} points outside extraction directory`);
|
|
8565
|
+
let relative = path;
|
|
8566
|
+
if (/^[a-zA-Z]:/.test(relative)) relative = relative.replace(/^[a-zA-Z]:[/\\]?/, "");
|
|
8567
|
+
else if (relative.startsWith("/")) relative = relative.replace(/^\/+/, "");
|
|
8568
|
+
if (process.platform === "win32") return relative.replace(/[<>:"|?*]/g, (char) => win32Reserved[char]);
|
|
8569
|
+
return relative;
|
|
8570
|
+
}
|
|
8571
|
+
const normalizeHeaderName = (s) => normalizeName(s.replace(/\/+$/, ""));
|
|
8572
|
+
const createOperationQueue = (concurrency) => {
|
|
8573
|
+
let active = 0;
|
|
8574
|
+
const tasks = [];
|
|
8575
|
+
let head = 0;
|
|
8576
|
+
let idle = null;
|
|
8577
|
+
let resolveIdle = null;
|
|
8578
|
+
const ensureIdle = () => idle ??= new Promise((resolve) => resolveIdle = resolve);
|
|
8579
|
+
const flush = () => {
|
|
8580
|
+
while (active < concurrency && head < tasks.length) {
|
|
8581
|
+
const task = tasks[head++];
|
|
8582
|
+
active++;
|
|
8583
|
+
task().finally(() => {
|
|
8584
|
+
active--;
|
|
8585
|
+
flush();
|
|
9997
8586
|
});
|
|
9998
|
-
this.written = 0;
|
|
9999
|
-
this.header = header;
|
|
10000
|
-
this._callback = callback;
|
|
10001
|
-
this._linkname = null;
|
|
10002
|
-
this._isLinkname = header.type === "symlink" && !header.linkname;
|
|
10003
|
-
this._isVoid = header.type !== "file" && header.type !== "contiguous-file";
|
|
10004
|
-
this._finished = false;
|
|
10005
|
-
this._pack = pack;
|
|
10006
|
-
this._openCallback = null;
|
|
10007
|
-
if (this._pack._stream === null) this._pack._stream = this;
|
|
10008
|
-
else this._pack._pending.push(this);
|
|
10009
|
-
}
|
|
10010
|
-
_open(cb) {
|
|
10011
|
-
this._openCallback = cb;
|
|
10012
|
-
if (this._pack._stream === this) this._continueOpen();
|
|
10013
|
-
}
|
|
10014
|
-
_continuePack(err) {
|
|
10015
|
-
if (this._callback === null) return;
|
|
10016
|
-
const callback = this._callback;
|
|
10017
|
-
this._callback = null;
|
|
10018
|
-
callback(err);
|
|
10019
|
-
}
|
|
10020
|
-
_continueOpen() {
|
|
10021
|
-
if (this._pack._stream === null) this._pack._stream = this;
|
|
10022
|
-
const cb = this._openCallback;
|
|
10023
|
-
this._openCallback = null;
|
|
10024
|
-
if (cb === null) return;
|
|
10025
|
-
if (this._pack.destroying) return cb(/* @__PURE__ */ new Error("pack stream destroyed"));
|
|
10026
|
-
if (this._pack._finalized) return cb(/* @__PURE__ */ new Error("pack stream is already finalized"));
|
|
10027
|
-
this._pack._stream = this;
|
|
10028
|
-
if (!this._isLinkname) this._pack._encode(this.header);
|
|
10029
|
-
if (this._isVoid) {
|
|
10030
|
-
this._finish();
|
|
10031
|
-
this._continuePack(null);
|
|
10032
|
-
}
|
|
10033
|
-
cb(null);
|
|
10034
8587
|
}
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
return cb();
|
|
8588
|
+
if (head === tasks.length) {
|
|
8589
|
+
tasks.length = 0;
|
|
8590
|
+
head = 0;
|
|
8591
|
+
if (active === 0 && resolveIdle) {
|
|
8592
|
+
resolveIdle();
|
|
8593
|
+
idle = null;
|
|
8594
|
+
resolveIdle = null;
|
|
10043
8595
|
}
|
|
10044
|
-
this.written += data.byteLength;
|
|
10045
|
-
if (this._pack.push(data)) return cb();
|
|
10046
|
-
this._pack._drain = cb;
|
|
10047
|
-
}
|
|
10048
|
-
_finish() {
|
|
10049
|
-
if (this._finished) return;
|
|
10050
|
-
this._finished = true;
|
|
10051
|
-
if (this._isLinkname) {
|
|
10052
|
-
this.header.linkname = this._linkname ? b4a.toString(this._linkname, "utf-8") : "";
|
|
10053
|
-
this._pack._encode(this.header);
|
|
10054
|
-
}
|
|
10055
|
-
overflow(this._pack, this.header.size);
|
|
10056
|
-
this._pack._done(this);
|
|
10057
|
-
}
|
|
10058
|
-
_final(cb) {
|
|
10059
|
-
if (this.written !== this.header.size) return cb(/* @__PURE__ */ new Error("Size mismatch"));
|
|
10060
|
-
this._finish();
|
|
10061
|
-
cb(null);
|
|
10062
|
-
}
|
|
10063
|
-
_getError() {
|
|
10064
|
-
return getStreamError(this) || /* @__PURE__ */ new Error("tar entry destroyed");
|
|
10065
|
-
}
|
|
10066
|
-
_predestroy() {
|
|
10067
|
-
this._pack.destroy(this._getError());
|
|
10068
|
-
}
|
|
10069
|
-
_destroy(cb) {
|
|
10070
|
-
this._pack._done(this);
|
|
10071
|
-
this._continuePack(this._finished ? null : this._getError());
|
|
10072
|
-
cb();
|
|
10073
8596
|
}
|
|
10074
8597
|
};
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
this._stream = null;
|
|
10083
|
-
}
|
|
10084
|
-
entry(header, buffer, callback) {
|
|
10085
|
-
if (this._finalized || this.destroying) throw new Error("already finalized or destroyed");
|
|
10086
|
-
if (typeof buffer === "function") {
|
|
10087
|
-
callback = buffer;
|
|
10088
|
-
buffer = null;
|
|
10089
|
-
}
|
|
10090
|
-
if (!callback) callback = noop;
|
|
10091
|
-
if (!header.size || header.type === "symlink") header.size = 0;
|
|
10092
|
-
if (!header.type) header.type = modeToType(header.mode);
|
|
10093
|
-
if (!header.mode) header.mode = header.type === "directory" ? DMODE : FMODE;
|
|
10094
|
-
if (!header.uid) header.uid = 0;
|
|
10095
|
-
if (!header.gid) header.gid = 0;
|
|
10096
|
-
if (!header.mtime) header.mtime = /* @__PURE__ */ new Date();
|
|
10097
|
-
if (typeof buffer === "string") buffer = b4a.from(buffer);
|
|
10098
|
-
const sink = new Sink(this, header, callback);
|
|
10099
|
-
if (b4a.isBuffer(buffer)) {
|
|
10100
|
-
header.size = buffer.byteLength;
|
|
10101
|
-
sink.write(buffer);
|
|
10102
|
-
sink.end();
|
|
10103
|
-
return sink;
|
|
10104
|
-
}
|
|
10105
|
-
if (sink._isVoid) return sink;
|
|
10106
|
-
return sink;
|
|
10107
|
-
}
|
|
10108
|
-
finalize() {
|
|
10109
|
-
if (this._stream || this._pending.length > 0) {
|
|
10110
|
-
this._finalizing = true;
|
|
10111
|
-
return;
|
|
10112
|
-
}
|
|
10113
|
-
if (this._finalized) return;
|
|
10114
|
-
this._finalized = true;
|
|
10115
|
-
this.push(END_OF_TAR);
|
|
10116
|
-
this.push(null);
|
|
10117
|
-
}
|
|
10118
|
-
_done(stream) {
|
|
10119
|
-
if (stream !== this._stream) return;
|
|
10120
|
-
this._stream = null;
|
|
10121
|
-
if (this._finalizing) this.finalize();
|
|
10122
|
-
if (this._pending.length) this._pending.shift()._continueOpen();
|
|
10123
|
-
}
|
|
10124
|
-
_encode(header) {
|
|
10125
|
-
if (!header.pax) {
|
|
10126
|
-
const buf = headers.encode(header);
|
|
10127
|
-
if (buf) {
|
|
10128
|
-
this.push(buf);
|
|
10129
|
-
return;
|
|
10130
|
-
}
|
|
10131
|
-
}
|
|
10132
|
-
this._encodePax(header);
|
|
10133
|
-
}
|
|
10134
|
-
_encodePax(header) {
|
|
10135
|
-
const paxHeader = headers.encodePax({
|
|
10136
|
-
name: header.name,
|
|
10137
|
-
linkname: header.linkname,
|
|
10138
|
-
pax: header.pax
|
|
8598
|
+
return {
|
|
8599
|
+
add(op) {
|
|
8600
|
+
const wasIdle = active === 0 && head === tasks.length;
|
|
8601
|
+
return new Promise((resolve, reject) => {
|
|
8602
|
+
tasks.push(() => Promise.resolve().then(op).then(resolve, reject));
|
|
8603
|
+
if (wasIdle) ensureIdle();
|
|
8604
|
+
flush();
|
|
10139
8605
|
});
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
uid: header.uid,
|
|
10144
|
-
gid: header.gid,
|
|
10145
|
-
size: paxHeader.byteLength,
|
|
10146
|
-
mtime: header.mtime,
|
|
10147
|
-
type: "pax-header",
|
|
10148
|
-
linkname: header.linkname && "PaxHeader",
|
|
10149
|
-
uname: header.uname,
|
|
10150
|
-
gname: header.gname,
|
|
10151
|
-
devmajor: header.devmajor,
|
|
10152
|
-
devminor: header.devminor
|
|
10153
|
-
};
|
|
10154
|
-
this.push(headers.encode(newHeader));
|
|
10155
|
-
this.push(paxHeader);
|
|
10156
|
-
overflow(this, paxHeader.byteLength);
|
|
10157
|
-
newHeader.size = header.size;
|
|
10158
|
-
newHeader.type = header.type;
|
|
10159
|
-
this.push(headers.encode(newHeader));
|
|
10160
|
-
}
|
|
10161
|
-
_doDrain() {
|
|
10162
|
-
const drain = this._drain;
|
|
10163
|
-
this._drain = noop;
|
|
10164
|
-
drain();
|
|
10165
|
-
}
|
|
10166
|
-
_predestroy() {
|
|
10167
|
-
const err = getStreamError(this);
|
|
10168
|
-
if (this._stream) this._stream.destroy(err);
|
|
10169
|
-
while (this._pending.length) {
|
|
10170
|
-
const stream = this._pending.shift();
|
|
10171
|
-
stream.destroy(err);
|
|
10172
|
-
stream._continueOpen();
|
|
10173
|
-
}
|
|
10174
|
-
this._doDrain();
|
|
10175
|
-
}
|
|
10176
|
-
_read(cb) {
|
|
10177
|
-
this._doDrain();
|
|
10178
|
-
cb();
|
|
8606
|
+
},
|
|
8607
|
+
onIdle() {
|
|
8608
|
+
return active === 0 && head === tasks.length ? Promise.resolve() : ensureIdle();
|
|
10179
8609
|
}
|
|
10180
8610
|
};
|
|
10181
|
-
|
|
10182
|
-
|
|
8611
|
+
};
|
|
8612
|
+
const BATCH_BYTES = 256 * 1024;
|
|
8613
|
+
const CREATE_FLAGS = fs$1.constants.O_WRONLY | fs$1.constants.O_CREAT | fs$1.constants.O_TRUNC | (fs$1.constants.O_NOFOLLOW ?? 0) | fs$1.constants.O_EXCL;
|
|
8614
|
+
const STATE_OPENING = 1;
|
|
8615
|
+
const STATE_OPEN = 2;
|
|
8616
|
+
const STATE_CLOSED = 3;
|
|
8617
|
+
const STATE_FAILED = 4;
|
|
8618
|
+
const DRAINED_PROMISE = Promise.resolve();
|
|
8619
|
+
function createFileSink(path, { mode = 438, mtime } = {}) {
|
|
8620
|
+
let state = STATE_OPENING;
|
|
8621
|
+
let flushing = false;
|
|
8622
|
+
let fd = null;
|
|
8623
|
+
let queue = [];
|
|
8624
|
+
let spare = [];
|
|
8625
|
+
let bytes = 0;
|
|
8626
|
+
let storedError = null;
|
|
8627
|
+
let endPromise = null;
|
|
8628
|
+
let endResolve = null;
|
|
8629
|
+
let endReject = null;
|
|
8630
|
+
const waitResolves = [];
|
|
8631
|
+
const waitRejects = [];
|
|
8632
|
+
const settleWaiters = () => {
|
|
8633
|
+
if (waitResolves.length === 0) return;
|
|
8634
|
+
for (let i = 0; i < waitResolves.length; i++) waitResolves[i]();
|
|
8635
|
+
waitResolves.length = 0;
|
|
8636
|
+
waitRejects.length = 0;
|
|
8637
|
+
};
|
|
8638
|
+
const failWaiters = (error) => {
|
|
8639
|
+
if (waitRejects.length === 0) return;
|
|
8640
|
+
for (let i = 0; i < waitRejects.length; i++) waitRejects[i](error);
|
|
8641
|
+
waitRejects.length = 0;
|
|
8642
|
+
waitResolves.length = 0;
|
|
8643
|
+
};
|
|
8644
|
+
const resetBuffers = () => {
|
|
8645
|
+
bytes = 0;
|
|
8646
|
+
queue.length = 0;
|
|
8647
|
+
spare.length = 0;
|
|
10183
8648
|
};
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
8649
|
+
const finish = () => {
|
|
8650
|
+
state = STATE_CLOSED;
|
|
8651
|
+
endResolve?.();
|
|
8652
|
+
settleWaiters();
|
|
8653
|
+
};
|
|
8654
|
+
const swapQueues = () => {
|
|
8655
|
+
const current = queue;
|
|
8656
|
+
queue = spare;
|
|
8657
|
+
spare = current;
|
|
8658
|
+
queue.length = 0;
|
|
8659
|
+
return current;
|
|
8660
|
+
};
|
|
8661
|
+
const fail = (error) => {
|
|
8662
|
+
if (storedError) return;
|
|
8663
|
+
storedError = error;
|
|
8664
|
+
state = STATE_FAILED;
|
|
8665
|
+
resetBuffers();
|
|
8666
|
+
flushing = false;
|
|
8667
|
+
const fdToClose = fd;
|
|
8668
|
+
fd = null;
|
|
8669
|
+
if (fdToClose !== null) fs$1.ftruncate(fdToClose, 0, () => fs$1.close(fdToClose));
|
|
8670
|
+
endReject?.(error);
|
|
8671
|
+
failWaiters(error);
|
|
8672
|
+
};
|
|
8673
|
+
const close = () => {
|
|
8674
|
+
if (fd === null) {
|
|
8675
|
+
finish();
|
|
8676
|
+
return;
|
|
10191
8677
|
}
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
function mapWritable(buf) {
|
|
10200
|
-
return b4a.isBuffer(buf) ? buf : b4a.from(buf);
|
|
10201
|
-
}
|
|
10202
|
-
}));
|
|
10203
|
-
//#endregion
|
|
10204
|
-
//#region ../../node_modules/.pnpm/tar-stream@3.2.0/node_modules/tar-stream/index.js
|
|
10205
|
-
var require_tar_stream = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10206
|
-
exports.extract = require_extract();
|
|
10207
|
-
exports.pack = require_pack();
|
|
10208
|
-
}));
|
|
10209
|
-
//#endregion
|
|
10210
|
-
//#region ../../node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js
|
|
10211
|
-
var require_wrappy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10212
|
-
module.exports = wrappy;
|
|
10213
|
-
function wrappy(fn, cb) {
|
|
10214
|
-
if (fn && cb) return wrappy(fn)(cb);
|
|
10215
|
-
if (typeof fn !== "function") throw new TypeError("need wrapper function");
|
|
10216
|
-
Object.keys(fn).forEach(function(k) {
|
|
10217
|
-
wrapper[k] = fn[k];
|
|
10218
|
-
});
|
|
10219
|
-
return wrapper;
|
|
10220
|
-
function wrapper() {
|
|
10221
|
-
var args = new Array(arguments.length);
|
|
10222
|
-
for (var i = 0; i < args.length; i++) args[i] = arguments[i];
|
|
10223
|
-
var ret = fn.apply(this, args);
|
|
10224
|
-
var cb = args[args.length - 1];
|
|
10225
|
-
if (typeof ret === "function" && ret !== cb) Object.keys(cb).forEach(function(k) {
|
|
10226
|
-
ret[k] = cb[k];
|
|
8678
|
+
const fdToClose = fd;
|
|
8679
|
+
fd = null;
|
|
8680
|
+
if (mtime) fs$1.futimes(fdToClose, mtime, mtime, (err) => {
|
|
8681
|
+
if (err) return fail(err);
|
|
8682
|
+
fs$1.close(fdToClose, (closeErr) => {
|
|
8683
|
+
if (closeErr) fail(closeErr);
|
|
8684
|
+
else finish();
|
|
10227
8685
|
});
|
|
10228
|
-
return ret;
|
|
10229
|
-
}
|
|
10230
|
-
}
|
|
10231
|
-
}));
|
|
10232
|
-
//#endregion
|
|
10233
|
-
//#region ../../node_modules/.pnpm/once@1.4.0/node_modules/once/once.js
|
|
10234
|
-
var require_once = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10235
|
-
var wrappy = require_wrappy();
|
|
10236
|
-
module.exports = wrappy(once);
|
|
10237
|
-
module.exports.strict = wrappy(onceStrict);
|
|
10238
|
-
once.proto = once(function() {
|
|
10239
|
-
Object.defineProperty(Function.prototype, "once", {
|
|
10240
|
-
value: function() {
|
|
10241
|
-
return once(this);
|
|
10242
|
-
},
|
|
10243
|
-
configurable: true
|
|
10244
8686
|
});
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
},
|
|
10249
|
-
configurable: true
|
|
8687
|
+
else fs$1.close(fdToClose, (err) => {
|
|
8688
|
+
if (err) fail(err);
|
|
8689
|
+
else finish();
|
|
10250
8690
|
});
|
|
10251
|
-
});
|
|
10252
|
-
function once(fn) {
|
|
10253
|
-
var f = function() {
|
|
10254
|
-
if (f.called) return f.value;
|
|
10255
|
-
f.called = true;
|
|
10256
|
-
return f.value = fn.apply(this, arguments);
|
|
10257
|
-
};
|
|
10258
|
-
f.called = false;
|
|
10259
|
-
return f;
|
|
10260
|
-
}
|
|
10261
|
-
function onceStrict(fn) {
|
|
10262
|
-
var f = function() {
|
|
10263
|
-
if (f.called) throw new Error(f.onceError);
|
|
10264
|
-
f.called = true;
|
|
10265
|
-
return f.value = fn.apply(this, arguments);
|
|
10266
|
-
};
|
|
10267
|
-
f.onceError = (fn.name || "Function wrapped with `once`") + " shouldn't be called more than once";
|
|
10268
|
-
f.called = false;
|
|
10269
|
-
return f;
|
|
10270
|
-
}
|
|
10271
|
-
}));
|
|
10272
|
-
//#endregion
|
|
10273
|
-
//#region ../../node_modules/.pnpm/end-of-stream@1.4.5/node_modules/end-of-stream/index.js
|
|
10274
|
-
var require_end_of_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10275
|
-
var once = require_once();
|
|
10276
|
-
var noop = function() {};
|
|
10277
|
-
var qnt = global.Bare ? queueMicrotask : process.nextTick.bind(process);
|
|
10278
|
-
var isRequest = function(stream) {
|
|
10279
|
-
return stream.setHeader && typeof stream.abort === "function";
|
|
10280
|
-
};
|
|
10281
|
-
var isChildProcess = function(stream) {
|
|
10282
|
-
return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3;
|
|
10283
8691
|
};
|
|
10284
|
-
|
|
10285
|
-
if (
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
if (
|
|
10295
|
-
|
|
10296
|
-
var onfinish = function() {
|
|
10297
|
-
writable = false;
|
|
10298
|
-
if (!readable) callback.call(stream);
|
|
10299
|
-
};
|
|
10300
|
-
var onend = function() {
|
|
10301
|
-
readable = false;
|
|
10302
|
-
if (!writable) callback.call(stream);
|
|
10303
|
-
};
|
|
10304
|
-
var onexit = function(exitCode) {
|
|
10305
|
-
callback.call(stream, exitCode ? /* @__PURE__ */ new Error("exited with error code: " + exitCode) : null);
|
|
10306
|
-
};
|
|
10307
|
-
var onerror = function(err) {
|
|
10308
|
-
callback.call(stream, err);
|
|
10309
|
-
};
|
|
10310
|
-
var onclose = function() {
|
|
10311
|
-
qnt(onclosenexttick);
|
|
10312
|
-
};
|
|
10313
|
-
var onclosenexttick = function() {
|
|
10314
|
-
if (cancelled) return;
|
|
10315
|
-
if (readable && !(rs && rs.ended && !rs.destroyed)) return callback.call(stream, /* @__PURE__ */ new Error("premature close"));
|
|
10316
|
-
if (writable && !(ws && ws.ended && !ws.destroyed)) return callback.call(stream, /* @__PURE__ */ new Error("premature close"));
|
|
10317
|
-
};
|
|
10318
|
-
var onrequest = function() {
|
|
10319
|
-
stream.req.on("finish", onfinish);
|
|
10320
|
-
};
|
|
10321
|
-
if (isRequest(stream)) {
|
|
10322
|
-
stream.on("complete", onfinish);
|
|
10323
|
-
stream.on("abort", onclose);
|
|
10324
|
-
if (stream.req) onrequest();
|
|
10325
|
-
else stream.on("request", onrequest);
|
|
10326
|
-
} else if (writable && !ws) {
|
|
10327
|
-
stream.on("end", onlegacyfinish);
|
|
10328
|
-
stream.on("close", onlegacyfinish);
|
|
10329
|
-
}
|
|
10330
|
-
if (isChildProcess(stream)) stream.on("exit", onexit);
|
|
10331
|
-
stream.on("end", onend);
|
|
10332
|
-
stream.on("finish", onfinish);
|
|
10333
|
-
if (opts.error !== false) stream.on("error", onerror);
|
|
10334
|
-
stream.on("close", onclose);
|
|
10335
|
-
return function() {
|
|
10336
|
-
cancelled = true;
|
|
10337
|
-
stream.removeListener("complete", onfinish);
|
|
10338
|
-
stream.removeListener("abort", onclose);
|
|
10339
|
-
stream.removeListener("request", onrequest);
|
|
10340
|
-
if (stream.req) stream.req.removeListener("finish", onfinish);
|
|
10341
|
-
stream.removeListener("end", onlegacyfinish);
|
|
10342
|
-
stream.removeListener("close", onlegacyfinish);
|
|
10343
|
-
stream.removeListener("finish", onfinish);
|
|
10344
|
-
stream.removeListener("exit", onexit);
|
|
10345
|
-
stream.removeListener("end", onend);
|
|
10346
|
-
stream.removeListener("error", onerror);
|
|
10347
|
-
stream.removeListener("close", onclose);
|
|
8692
|
+
const flush = () => {
|
|
8693
|
+
if (flushing || queue.length === 0 || state !== STATE_OPEN) return;
|
|
8694
|
+
flushing = true;
|
|
8695
|
+
const bufs = swapQueues();
|
|
8696
|
+
const onDone = (err, written = 0) => {
|
|
8697
|
+
if (err) return fail(err);
|
|
8698
|
+
flushing = false;
|
|
8699
|
+
bytes -= written;
|
|
8700
|
+
spare.length = 0;
|
|
8701
|
+
if (bytes < BATCH_BYTES) settleWaiters();
|
|
8702
|
+
if (queue.length > 0) flush();
|
|
8703
|
+
else if (endResolve) close();
|
|
10348
8704
|
};
|
|
8705
|
+
if (bufs.length === 1) {
|
|
8706
|
+
const buf = bufs[0];
|
|
8707
|
+
fs$1.write(fd, buf, 0, buf.length, null, onDone);
|
|
8708
|
+
} else fs$1.writev(fd, bufs, onDone);
|
|
10349
8709
|
};
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
var ancient = typeof process === "undefined" ? false : /^v?\.0/.test(process.version);
|
|
10363
|
-
var isFn = function(fn) {
|
|
10364
|
-
return typeof fn === "function";
|
|
8710
|
+
const onOpen = (err, openFd) => {
|
|
8711
|
+
if (err) return fail(err);
|
|
8712
|
+
if (state === STATE_CLOSED || state === STATE_FAILED) {
|
|
8713
|
+
fs$1.close(openFd);
|
|
8714
|
+
return;
|
|
8715
|
+
}
|
|
8716
|
+
fd = openFd;
|
|
8717
|
+
state = STATE_OPEN;
|
|
8718
|
+
if (endResolve) if (queue.length > 0) flush();
|
|
8719
|
+
else close();
|
|
8720
|
+
else if (bytes >= BATCH_BYTES && !flushing) flush();
|
|
8721
|
+
else settleWaiters();
|
|
10365
8722
|
};
|
|
10366
|
-
|
|
10367
|
-
if (
|
|
10368
|
-
|
|
10369
|
-
|
|
8723
|
+
const write = (chunk) => {
|
|
8724
|
+
if (storedError || state >= STATE_CLOSED || endResolve) return false;
|
|
8725
|
+
const buf = Buffer.isBuffer(chunk) ? chunk : chunk instanceof Uint8Array ? Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength) : Buffer.from(chunk);
|
|
8726
|
+
if (buf.length === 0) return bytes < BATCH_BYTES;
|
|
8727
|
+
queue.push(buf);
|
|
8728
|
+
bytes += buf.length;
|
|
8729
|
+
if (state === STATE_OPEN && !flushing && bytes >= BATCH_BYTES) flush();
|
|
8730
|
+
return bytes < BATCH_BYTES;
|
|
10370
8731
|
};
|
|
10371
|
-
|
|
10372
|
-
|
|
8732
|
+
const waitDrain = () => {
|
|
8733
|
+
if (state === STATE_OPENING || state === STATE_OPEN && bytes >= BATCH_BYTES) return new Promise((resolve, reject) => {
|
|
8734
|
+
waitResolves.push(resolve);
|
|
8735
|
+
waitRejects.push(reject);
|
|
8736
|
+
});
|
|
8737
|
+
return DRAINED_PROMISE;
|
|
10373
8738
|
};
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
8739
|
+
const end = () => {
|
|
8740
|
+
if (state >= STATE_CLOSED) return DRAINED_PROMISE;
|
|
8741
|
+
if (storedError) return Promise.reject(storedError);
|
|
8742
|
+
if (endPromise) return endPromise;
|
|
8743
|
+
endPromise = new Promise((resolve, reject) => {
|
|
8744
|
+
endResolve = resolve;
|
|
8745
|
+
endReject = reject;
|
|
8746
|
+
if (state === STATE_OPEN && !flushing) if (queue.length > 0) flush();
|
|
8747
|
+
else close();
|
|
10379
8748
|
});
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
8749
|
+
return endPromise;
|
|
8750
|
+
};
|
|
8751
|
+
const destroy = (error) => {
|
|
8752
|
+
if (error) {
|
|
8753
|
+
fail(error);
|
|
8754
|
+
return;
|
|
8755
|
+
}
|
|
8756
|
+
if (state >= STATE_CLOSED || storedError) return;
|
|
8757
|
+
resetBuffers();
|
|
8758
|
+
flushing = false;
|
|
8759
|
+
if (fd !== null) {
|
|
8760
|
+
const fdToClose = fd;
|
|
8761
|
+
fd = null;
|
|
8762
|
+
fs$1.close(fdToClose);
|
|
8763
|
+
}
|
|
8764
|
+
finish();
|
|
8765
|
+
};
|
|
8766
|
+
fs$1.open(path, CREATE_FLAGS, mode, (err, openFd) => {
|
|
8767
|
+
if (!err || err.code !== "EEXIST") return onOpen(err, openFd);
|
|
8768
|
+
fs$1.rm(path, { force: true }, (rmErr) => {
|
|
8769
|
+
if (rmErr) return fail(rmErr);
|
|
8770
|
+
fs$1.open(path, CREATE_FLAGS, mode, onOpen);
|
|
10387
8771
|
});
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
if (isRequest(stream)) return stream.abort();
|
|
10395
|
-
if (isFn(stream.destroy)) return stream.destroy();
|
|
10396
|
-
callback(err || /* @__PURE__ */ new Error("stream was destroyed"));
|
|
10397
|
-
};
|
|
8772
|
+
});
|
|
8773
|
+
return {
|
|
8774
|
+
write,
|
|
8775
|
+
end,
|
|
8776
|
+
destroy,
|
|
8777
|
+
waitDrain
|
|
10398
8778
|
};
|
|
10399
|
-
|
|
10400
|
-
|
|
8779
|
+
}
|
|
8780
|
+
const createCache = () => {
|
|
8781
|
+
const m = /* @__PURE__ */ new Map();
|
|
8782
|
+
return {
|
|
8783
|
+
get(k) {
|
|
8784
|
+
const v = m.get(k);
|
|
8785
|
+
if (m.delete(k)) m.set(k, v);
|
|
8786
|
+
return v;
|
|
8787
|
+
},
|
|
8788
|
+
set(k, v) {
|
|
8789
|
+
if (m.set(k, v).size > 1e4) m.delete(m.keys().next().value);
|
|
8790
|
+
},
|
|
8791
|
+
clear() {
|
|
8792
|
+
m.clear();
|
|
8793
|
+
}
|
|
10401
8794
|
};
|
|
10402
|
-
|
|
10403
|
-
|
|
8795
|
+
};
|
|
8796
|
+
const ENOENT = "ENOENT";
|
|
8797
|
+
const MAX_SYMLINKS = 64;
|
|
8798
|
+
const linkSep = process.platform === "win32" ? /[/\\]/ : "/";
|
|
8799
|
+
const linkParts = (linkname) => linkname.split(linkSep).filter((part) => part && part !== ".");
|
|
8800
|
+
const createPathCache = (destDirPath, options, opQueue, concurrency) => {
|
|
8801
|
+
const { maxDepth = 1024, dmode } = options;
|
|
8802
|
+
const dirPromises = createCache();
|
|
8803
|
+
const pathConflicts = /* @__PURE__ */ new Map();
|
|
8804
|
+
const deferredLinks = [];
|
|
8805
|
+
let symlinks;
|
|
8806
|
+
const realDirCache = createCache();
|
|
8807
|
+
const initializeDestDir = async (destDirPath) => {
|
|
8808
|
+
const symbolic = path$1.resolve(destDirPath);
|
|
8809
|
+
try {
|
|
8810
|
+
await fsp.mkdir(symbolic, { recursive: true });
|
|
8811
|
+
} catch (err) {
|
|
8812
|
+
if (err.code === ENOENT) {
|
|
8813
|
+
const parentDir = path$1.dirname(symbolic);
|
|
8814
|
+
if (parentDir === symbolic) throw err;
|
|
8815
|
+
await fsp.mkdir(parentDir, { recursive: true });
|
|
8816
|
+
await fsp.mkdir(symbolic, { recursive: true });
|
|
8817
|
+
} else throw err;
|
|
8818
|
+
}
|
|
8819
|
+
try {
|
|
8820
|
+
return {
|
|
8821
|
+
symbolic,
|
|
8822
|
+
real: await fsp.realpath(symbolic)
|
|
8823
|
+
};
|
|
8824
|
+
} catch (err) {
|
|
8825
|
+
if (err.code === ENOENT) return {
|
|
8826
|
+
symbolic,
|
|
8827
|
+
real: symbolic
|
|
8828
|
+
};
|
|
8829
|
+
throw err;
|
|
8830
|
+
}
|
|
10404
8831
|
};
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
if (
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
|
|
10414
|
-
|
|
10415
|
-
if (err) destroys.forEach(call);
|
|
10416
|
-
if (reading) return;
|
|
10417
|
-
destroys.forEach(call);
|
|
10418
|
-
callback(error);
|
|
8832
|
+
const destDirPromise = initializeDestDir(destDirPath);
|
|
8833
|
+
destDirPromise.catch(() => {});
|
|
8834
|
+
const getRealDir = async (dirPath, errorMessage) => {
|
|
8835
|
+
const destDir = await destDirPromise;
|
|
8836
|
+
if (dirPath === destDir.symbolic) return destDir.real;
|
|
8837
|
+
let promise = realDirCache.get(dirPath);
|
|
8838
|
+
if (!promise) {
|
|
8839
|
+
promise = fsp.realpath(dirPath).then((realPath) => {
|
|
8840
|
+
validateBounds(realPath, destDir.real, errorMessage);
|
|
8841
|
+
return realPath;
|
|
10419
8842
|
});
|
|
10420
|
-
|
|
10421
|
-
|
|
8843
|
+
realDirCache.set(dirPath, promise);
|
|
8844
|
+
}
|
|
8845
|
+
return promise;
|
|
10422
8846
|
};
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
}
|
|
10439
|
-
function processUmask() {
|
|
10440
|
-
return !global.Bare && process.umask ? process.umask() : 0;
|
|
10441
|
-
}
|
|
10442
|
-
exports.extract = function extract(cwd, opts) {
|
|
10443
|
-
if (!cwd) cwd = ".";
|
|
10444
|
-
if (!opts) opts = {};
|
|
10445
|
-
cwd = path$1.resolve(cwd);
|
|
10446
|
-
const xfs = opts.fs || fs$1;
|
|
10447
|
-
const ignore = opts.ignore || opts.filter || noop;
|
|
10448
|
-
const mapStream = opts.mapStream || echo;
|
|
10449
|
-
const own = opts.chown !== false && !win32 && processGetuid() === 0;
|
|
10450
|
-
const extract = opts.extract || tar.extract();
|
|
10451
|
-
const stack = [];
|
|
10452
|
-
const now = /* @__PURE__ */ new Date();
|
|
10453
|
-
const umask = typeof opts.umask === "number" ? ~opts.umask : ~processUmask();
|
|
10454
|
-
const strict = opts.strict !== false;
|
|
10455
|
-
const validateSymLinks = opts.validateSymlinks !== false;
|
|
10456
|
-
let map = opts.map || noop;
|
|
10457
|
-
let dmode = typeof opts.dmode === "number" ? opts.dmode : 0;
|
|
10458
|
-
let fmode = typeof opts.fmode === "number" ? opts.fmode : 0;
|
|
10459
|
-
if (opts.strip) map = strip(map, opts.strip);
|
|
10460
|
-
if (opts.readable) {
|
|
10461
|
-
dmode |= parseInt(555, 8);
|
|
10462
|
-
fmode |= parseInt(444, 8);
|
|
10463
|
-
}
|
|
10464
|
-
if (opts.writable) {
|
|
10465
|
-
dmode |= parseInt(333, 8);
|
|
10466
|
-
fmode |= parseInt(222, 8);
|
|
10467
|
-
}
|
|
10468
|
-
extract.on("entry", onentry);
|
|
10469
|
-
if (opts.finish) extract.on("finish", opts.finish);
|
|
10470
|
-
return extract;
|
|
10471
|
-
function onentry(header, stream, next) {
|
|
10472
|
-
header = map(header) || header;
|
|
10473
|
-
header.name = normalize(header.name);
|
|
10474
|
-
const name = path$1.join(cwd, path$1.join("/", header.name));
|
|
10475
|
-
if (ignore(name, header)) {
|
|
10476
|
-
stream.resume();
|
|
10477
|
-
return next();
|
|
10478
|
-
}
|
|
10479
|
-
const dir = path$1.join(name, ".") === path$1.join(cwd, ".") ? cwd : path$1.dirname(name);
|
|
10480
|
-
validate(xfs, dir, path$1.join(cwd, "."), function(err, valid) {
|
|
10481
|
-
if (err) return next(err);
|
|
10482
|
-
if (!valid) return next(/* @__PURE__ */ new Error(dir + " is not a valid path"));
|
|
10483
|
-
if (header.type === "directory") {
|
|
10484
|
-
stack.push([name, header.mtime]);
|
|
10485
|
-
return mkdirfix(name, {
|
|
10486
|
-
fs: xfs,
|
|
10487
|
-
own,
|
|
10488
|
-
uid: header.uid,
|
|
10489
|
-
gid: header.gid,
|
|
10490
|
-
mode: header.mode
|
|
10491
|
-
}, stat);
|
|
8847
|
+
const prepareDirectory = async (dirPath, mode) => {
|
|
8848
|
+
let promise = dirPromises.get(dirPath);
|
|
8849
|
+
if (promise) return promise;
|
|
8850
|
+
promise = (async () => {
|
|
8851
|
+
if (dirPath === (await destDirPromise).symbolic) return;
|
|
8852
|
+
await prepareDirectory(path$1.dirname(dirPath));
|
|
8853
|
+
try {
|
|
8854
|
+
const stat = await fsp.lstat(dirPath);
|
|
8855
|
+
if (stat.isDirectory()) return;
|
|
8856
|
+
if (stat.isSymbolicLink()) try {
|
|
8857
|
+
const realPath = await getRealDir(dirPath, `Symlink "${dirPath}" points outside the extraction directory.`);
|
|
8858
|
+
if ((await fsp.stat(realPath)).isDirectory()) return;
|
|
8859
|
+
} catch (err) {
|
|
8860
|
+
if (err.code === ENOENT) throw new Error(`Symlink "${dirPath}" points outside the extraction directory.`);
|
|
8861
|
+
throw err;
|
|
10492
8862
|
}
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
if (err) return next(err);
|
|
10501
|
-
switch (header.type) {
|
|
10502
|
-
case "file": return onfile();
|
|
10503
|
-
case "link": return onlink();
|
|
10504
|
-
case "symlink": return onsymlink();
|
|
10505
|
-
}
|
|
10506
|
-
if (strict) return next(/* @__PURE__ */ new Error("unsupported type for " + name + " (" + header.type + ")"));
|
|
10507
|
-
stream.resume();
|
|
10508
|
-
next();
|
|
10509
|
-
});
|
|
10510
|
-
});
|
|
10511
|
-
function stat(err) {
|
|
10512
|
-
if (err) return next(err);
|
|
10513
|
-
utimes(name, header, function(err) {
|
|
10514
|
-
if (err) return next(err);
|
|
10515
|
-
if (win32) return next();
|
|
10516
|
-
chperm(name, header, next);
|
|
10517
|
-
});
|
|
8863
|
+
throw new Error(`"${dirPath}" is not a valid directory component.`);
|
|
8864
|
+
} catch (err) {
|
|
8865
|
+
if (err.code === ENOENT) {
|
|
8866
|
+
await fsp.mkdir(dirPath, { mode: mode ?? options.dmode });
|
|
8867
|
+
return;
|
|
8868
|
+
}
|
|
8869
|
+
throw err;
|
|
10518
8870
|
}
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
8871
|
+
})();
|
|
8872
|
+
dirPromises.set(dirPath, promise);
|
|
8873
|
+
return promise;
|
|
8874
|
+
};
|
|
8875
|
+
return {
|
|
8876
|
+
async ready() {
|
|
8877
|
+
await destDirPromise;
|
|
8878
|
+
},
|
|
8879
|
+
async preparePath(header) {
|
|
8880
|
+
const { name, linkname, type, mode, mtime } = header;
|
|
8881
|
+
const normalizedName = normalizeHeaderName(name);
|
|
8882
|
+
const destDir = await destDirPromise;
|
|
8883
|
+
const outPath = path$1.join(destDir.symbolic, normalizedName);
|
|
8884
|
+
if (maxDepth !== Infinity) {
|
|
8885
|
+
let depth = 1;
|
|
8886
|
+
for (const char of normalizedName) if (char === "/" && ++depth > maxDepth) throw new Error("Tar exceeds max specified depth.");
|
|
8887
|
+
}
|
|
8888
|
+
const prevOp = pathConflicts.get(normalizedName);
|
|
8889
|
+
if (prevOp) {
|
|
8890
|
+
if (prevOp === "directory" && type !== "directory" || prevOp !== "directory" && type === "directory") throw new Error(`Path conflict ${type} over existing ${prevOp} at "${name}"`);
|
|
8891
|
+
return;
|
|
10530
8892
|
}
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
|
|
8893
|
+
const parentDir = path$1.dirname(outPath);
|
|
8894
|
+
switch (type) {
|
|
8895
|
+
case DIRECTORY: {
|
|
8896
|
+
pathConflicts.set(normalizedName, DIRECTORY);
|
|
8897
|
+
const safeMode = mode ? mode & 511 : void 0;
|
|
8898
|
+
await prepareDirectory(outPath, dmode ?? safeMode);
|
|
8899
|
+
if (mtime) await fsp.lutimes(outPath, mtime, mtime).catch(() => {});
|
|
8900
|
+
return;
|
|
8901
|
+
}
|
|
8902
|
+
case FILE:
|
|
8903
|
+
pathConflicts.set(normalizedName, FILE);
|
|
8904
|
+
await prepareDirectory(parentDir);
|
|
8905
|
+
return path$1.join(await getRealDir(parentDir, `File "${name}" points outside the extraction directory.`), path$1.basename(outPath));
|
|
8906
|
+
case SYMLINK: {
|
|
8907
|
+
pathConflicts.set(normalizedName, SYMLINK);
|
|
8908
|
+
if (!linkname) return;
|
|
8909
|
+
validateBounds(path$1.resolve(parentDir, linkname), destDir.symbolic, `Symlink "${linkname}" points outside the extraction directory.`);
|
|
8910
|
+
await prepareDirectory(parentDir);
|
|
8911
|
+
const realParentDir = await fsp.realpath(parentDir);
|
|
8912
|
+
validateBounds(realParentDir, destDir.real, "Symlink parent changed.");
|
|
8913
|
+
validateBounds(path$1.resolve(realParentDir, linkname), destDir.real, `Symlink "${linkname}" points outside the extraction directory.`);
|
|
8914
|
+
const realOutPath = path$1.join(realParentDir, path$1.basename(outPath));
|
|
8915
|
+
try {
|
|
8916
|
+
await fsp.symlink(linkname, realOutPath);
|
|
8917
|
+
} catch (err) {
|
|
8918
|
+
if (err.code !== "EEXIST") throw err;
|
|
8919
|
+
await fsp.rm(realOutPath, { force: true });
|
|
8920
|
+
if (await fsp.realpath(parentDir) !== realParentDir) throw new Error("Symlink parent changed.");
|
|
8921
|
+
await fsp.symlink(linkname, realOutPath);
|
|
8922
|
+
}
|
|
8923
|
+
(symlinks ??= []).push([normalizedName, linkname]);
|
|
8924
|
+
dirPromises.clear();
|
|
8925
|
+
realDirCache.clear();
|
|
8926
|
+
if (mtime) await fsp.lutimes(outPath, mtime, mtime).catch(() => {});
|
|
8927
|
+
return;
|
|
8928
|
+
}
|
|
8929
|
+
case LINK: {
|
|
8930
|
+
pathConflicts.set(normalizedName, LINK);
|
|
8931
|
+
if (!linkname) return;
|
|
8932
|
+
if (path$1.isAbsolute(linkname)) throw new Error(`Hardlink "${linkname}" points outside the extraction directory.`);
|
|
8933
|
+
const linkTarget = path$1.join(destDir.symbolic, linkname);
|
|
8934
|
+
validateBounds(linkTarget, destDir.symbolic, `Hardlink "${linkname}" points outside the extraction directory.`);
|
|
8935
|
+
await prepareDirectory(parentDir);
|
|
8936
|
+
if (linkTarget !== outPath) deferredLinks.push({
|
|
8937
|
+
linkTarget,
|
|
8938
|
+
outPath
|
|
10544
8939
|
});
|
|
10545
|
-
|
|
8940
|
+
return;
|
|
8941
|
+
}
|
|
8942
|
+
default: return;
|
|
10546
8943
|
}
|
|
10547
|
-
|
|
10548
|
-
|
|
8944
|
+
},
|
|
8945
|
+
async checkSymlinks() {
|
|
8946
|
+
if (!symlinks) return;
|
|
8947
|
+
const { symbolic: dest, real } = await destDirPromise;
|
|
8948
|
+
const realPrefix = real + path$1.sep;
|
|
8949
|
+
const root = path$1.parse(real).root;
|
|
8950
|
+
const depth = linkParts(real.slice(root.length)).length;
|
|
8951
|
+
const targetParts = (linkname, resolvedParts, message) => {
|
|
8952
|
+
if (!path$1.isAbsolute(linkname)) return linkParts(linkname);
|
|
8953
|
+
validateBounds(linkname, real, message);
|
|
8954
|
+
resolvedParts.length = 0;
|
|
8955
|
+
const parts = linkParts(linkname.slice(root.length));
|
|
8956
|
+
parts.splice(0, depth);
|
|
8957
|
+
return parts;
|
|
8958
|
+
};
|
|
8959
|
+
const getSymlinkError = async ([name, storedLinkname]) => {
|
|
8960
|
+
const outPath = path$1.join(dest, name);
|
|
8961
|
+
try {
|
|
8962
|
+
try {
|
|
8963
|
+
const resolved = await fsp.realpath(outPath);
|
|
8964
|
+
if (resolved !== real && !resolved.startsWith(realPrefix)) throw new Error(`Symlink "${storedLinkname}" points outside the extraction directory.`);
|
|
8965
|
+
return;
|
|
8966
|
+
} catch (err) {
|
|
8967
|
+
if (err.code !== ENOENT) throw err;
|
|
8968
|
+
}
|
|
8969
|
+
if (!(await fsp.lstat(outPath)).isSymbolicLink()) return;
|
|
8970
|
+
const linkname = await fsp.readlink(outPath);
|
|
8971
|
+
const message = `Symlink "${linkname}" points outside the extraction directory.`;
|
|
8972
|
+
const realParent = await fsp.realpath(path$1.dirname(outPath));
|
|
8973
|
+
validateBounds(realParent, real, message);
|
|
8974
|
+
const resolvedParts = linkParts(path$1.relative(real, realParent));
|
|
8975
|
+
const pendingParts = targetParts(linkname, resolvedParts, message);
|
|
8976
|
+
let followedSymlinks = 0;
|
|
8977
|
+
for (let i = 0; i < pendingParts.length; i++) {
|
|
8978
|
+
const part = pendingParts[i];
|
|
8979
|
+
if (part === "..") {
|
|
8980
|
+
if (!resolvedParts.length) throw new Error(message);
|
|
8981
|
+
resolvedParts.pop();
|
|
8982
|
+
continue;
|
|
8983
|
+
}
|
|
8984
|
+
resolvedParts.push(part);
|
|
8985
|
+
const nextPath = path$1.join(real, ...resolvedParts);
|
|
8986
|
+
let nextStat;
|
|
8987
|
+
try {
|
|
8988
|
+
nextStat = await fsp.lstat(nextPath);
|
|
8989
|
+
} catch (err) {
|
|
8990
|
+
if (err.code === ENOENT) continue;
|
|
8991
|
+
throw err;
|
|
8992
|
+
}
|
|
8993
|
+
if (!nextStat.isSymbolicLink()) continue;
|
|
8994
|
+
if (++followedSymlinks > MAX_SYMLINKS) throw new Error(message);
|
|
8995
|
+
const nextLink = await fsp.readlink(nextPath);
|
|
8996
|
+
resolvedParts.pop();
|
|
8997
|
+
pendingParts.splice(i + 1, 0, ...targetParts(nextLink, resolvedParts, message));
|
|
8998
|
+
}
|
|
8999
|
+
} catch (err) {
|
|
9000
|
+
if (err.code !== ENOENT) return err;
|
|
9001
|
+
}
|
|
9002
|
+
};
|
|
9003
|
+
for (let start = 0; start < symlinks.length; start += concurrency) {
|
|
9004
|
+
const batch = symlinks.slice(start, start + concurrency);
|
|
9005
|
+
const errors = await Promise.all(batch.map((symlink) => opQueue.add(() => getSymlinkError(symlink))));
|
|
9006
|
+
for (const [i, error] of errors.entries()) {
|
|
9007
|
+
if (error === void 0) continue;
|
|
9008
|
+
await fsp.rm(path$1.join(dest, batch[i][0]), { force: true });
|
|
9009
|
+
throw error;
|
|
9010
|
+
}
|
|
10549
9011
|
}
|
|
10550
|
-
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
});
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
9012
|
+
},
|
|
9013
|
+
async applyLinks() {
|
|
9014
|
+
const destRoot = (await destDirPromise).real;
|
|
9015
|
+
for (const { linkTarget, outPath } of deferredLinks) try {
|
|
9016
|
+
const realTargetDir = await fsp.realpath(path$1.dirname(linkTarget));
|
|
9017
|
+
validateBounds(realTargetDir, destRoot, `Hardlink "${linkTarget}" points outside the extraction directory.`);
|
|
9018
|
+
const realTarget = path$1.join(realTargetDir, path$1.basename(linkTarget));
|
|
9019
|
+
const [targetResult, outDirResult] = await Promise.allSettled([opQueue.add(() => fsp.lstat(realTarget)), opQueue.add(() => fsp.realpath(path$1.dirname(outPath)))]);
|
|
9020
|
+
if (targetResult.status === "rejected") throw targetResult.reason;
|
|
9021
|
+
const targetStat = targetResult.value;
|
|
9022
|
+
if (targetStat.isSymbolicLink()) throw new Error(`Hardlink "${linkTarget}" is a symlink.`);
|
|
9023
|
+
if (outDirResult.status === "rejected") throw outDirResult.reason;
|
|
9024
|
+
const realOutDir = outDirResult.value;
|
|
9025
|
+
validateBounds(realOutDir, destRoot, `Hardlink "${outPath}" points outside the extraction directory.`);
|
|
9026
|
+
const realOutPath = path$1.join(realOutDir, path$1.basename(outPath));
|
|
9027
|
+
try {
|
|
9028
|
+
await fsp.link(realTarget, realOutPath);
|
|
9029
|
+
} catch (err) {
|
|
9030
|
+
const code = err.code;
|
|
9031
|
+
if (code !== "EEXIST" && code !== ENOENT) throw err;
|
|
9032
|
+
try {
|
|
9033
|
+
const outStat = await fsp.lstat(realOutPath);
|
|
9034
|
+
if (outStat.dev === targetStat.dev && outStat.ino === targetStat.ino) continue;
|
|
9035
|
+
await fsp.rm(realOutPath, { force: true });
|
|
9036
|
+
} catch (err) {
|
|
9037
|
+
if (err.code !== ENOENT) throw err;
|
|
9038
|
+
}
|
|
9039
|
+
await fsp.link(realTarget, realOutPath);
|
|
9040
|
+
}
|
|
9041
|
+
const linkStat = await fsp.lstat(realOutPath);
|
|
9042
|
+
if (linkStat.dev !== targetStat.dev || linkStat.ino !== targetStat.ino) {
|
|
9043
|
+
await fsp.rm(realOutPath, { force: true });
|
|
9044
|
+
throw new Error(`Hardlink target "${linkTarget}" changed during creation for link at "${outPath}".`);
|
|
9045
|
+
}
|
|
9046
|
+
} catch (err) {
|
|
9047
|
+
if (err.code === ENOENT) throw new Error(`Hardlink target "${linkTarget}" does not exist for link at "${outPath}".`);
|
|
9048
|
+
throw err;
|
|
10560
9049
|
}
|
|
10561
9050
|
}
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
const
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
9051
|
+
};
|
|
9052
|
+
};
|
|
9053
|
+
function unpackTar(directoryPath, options = {}) {
|
|
9054
|
+
const unpacker = createUnpacker(options);
|
|
9055
|
+
const concurrency = options.concurrency || cpus().length || 8;
|
|
9056
|
+
const opQueue = createOperationQueue(concurrency);
|
|
9057
|
+
const pathCache = createPathCache(directoryPath, options, opQueue, concurrency);
|
|
9058
|
+
let currentFileStream = null;
|
|
9059
|
+
let currentWriteCallback = null;
|
|
9060
|
+
let queuedError = null;
|
|
9061
|
+
const onQueuedError = (err) => {
|
|
9062
|
+
queuedError ??= err;
|
|
9063
|
+
if (!writable.destroyed) writable.destroy(err);
|
|
9064
|
+
};
|
|
9065
|
+
const writable = new Writable({
|
|
9066
|
+
async write(chunk, _, cb) {
|
|
9067
|
+
const pendingFileOpens = [];
|
|
9068
|
+
let writeError;
|
|
9069
|
+
try {
|
|
9070
|
+
unpacker.write(chunk);
|
|
9071
|
+
if (unpacker.isEntryActive()) {
|
|
9072
|
+
if (currentFileStream && currentWriteCallback) {
|
|
9073
|
+
let needsDrain = false;
|
|
9074
|
+
const writeCallback = currentWriteCallback;
|
|
9075
|
+
while (!unpacker.isBodyComplete()) {
|
|
9076
|
+
needsDrain = false;
|
|
9077
|
+
if (unpacker.streamBody(writeCallback) === 0) if (needsDrain) await currentFileStream.waitDrain();
|
|
9078
|
+
else return;
|
|
9079
|
+
}
|
|
9080
|
+
while (!unpacker.skipPadding()) return;
|
|
9081
|
+
const streamToClose = currentFileStream;
|
|
9082
|
+
if (streamToClose) opQueue.add(() => streamToClose.end()).catch(onQueuedError);
|
|
9083
|
+
currentFileStream = null;
|
|
9084
|
+
currentWriteCallback = null;
|
|
9085
|
+
} else if (!unpacker.skipEntry()) return;
|
|
9086
|
+
}
|
|
9087
|
+
while (true) {
|
|
9088
|
+
const header = unpacker.readHeader();
|
|
9089
|
+
if (header === void 0 || header === null) return;
|
|
9090
|
+
const transformedHeader = transformHeader(header, options);
|
|
9091
|
+
if (!transformedHeader) {
|
|
9092
|
+
if (!unpacker.skipEntry()) return;
|
|
9093
|
+
continue;
|
|
9094
|
+
}
|
|
9095
|
+
const outPath = await opQueue.add(() => pathCache.preparePath(transformedHeader));
|
|
9096
|
+
if (outPath) {
|
|
9097
|
+
const safeMode = transformedHeader.mode ? transformedHeader.mode & 511 : void 0;
|
|
9098
|
+
const fileStream = createFileSink(outPath, {
|
|
9099
|
+
mode: options.fmode ?? safeMode,
|
|
9100
|
+
mtime: transformedHeader.mtime ?? void 0
|
|
9101
|
+
});
|
|
9102
|
+
pendingFileOpens.push(fileStream.waitDrain().catch((error) => error));
|
|
9103
|
+
let needsDrain = false;
|
|
9104
|
+
const writeCallback = (chunk) => {
|
|
9105
|
+
const writeOk = fileStream.write(chunk);
|
|
9106
|
+
if (!writeOk) needsDrain = true;
|
|
9107
|
+
return writeOk;
|
|
9108
|
+
};
|
|
9109
|
+
while (!unpacker.isBodyComplete()) {
|
|
9110
|
+
needsDrain = false;
|
|
9111
|
+
if (unpacker.streamBody(writeCallback) === 0) if (needsDrain) await fileStream.waitDrain();
|
|
9112
|
+
else {
|
|
9113
|
+
currentFileStream = fileStream;
|
|
9114
|
+
currentWriteCallback = writeCallback;
|
|
9115
|
+
return;
|
|
9116
|
+
}
|
|
9117
|
+
}
|
|
9118
|
+
while (!unpacker.skipPadding()) {
|
|
9119
|
+
currentFileStream = fileStream;
|
|
9120
|
+
currentWriteCallback = writeCallback;
|
|
9121
|
+
return;
|
|
9122
|
+
}
|
|
9123
|
+
opQueue.add(() => fileStream.end()).catch(onQueuedError);
|
|
9124
|
+
} else if (!unpacker.skipEntry()) return;
|
|
9125
|
+
}
|
|
9126
|
+
} catch (err) {
|
|
9127
|
+
writeError = err;
|
|
9128
|
+
} finally {
|
|
9129
|
+
cb((pendingFileOpens.length ? (await Promise.all(pendingFileOpens)).find((error) => error) : void 0) ?? writeError);
|
|
10589
9130
|
}
|
|
9131
|
+
},
|
|
9132
|
+
async final(cb) {
|
|
9133
|
+
try {
|
|
9134
|
+
unpacker.end();
|
|
9135
|
+
unpacker.validateEOF();
|
|
9136
|
+
await pathCache.ready();
|
|
9137
|
+
await opQueue.onIdle();
|
|
9138
|
+
if (queuedError) throw queuedError;
|
|
9139
|
+
await pathCache.checkSymlinks();
|
|
9140
|
+
await pathCache.applyLinks();
|
|
9141
|
+
cb();
|
|
9142
|
+
} catch (err) {
|
|
9143
|
+
cb(err);
|
|
9144
|
+
}
|
|
9145
|
+
},
|
|
9146
|
+
destroy(error, callback) {
|
|
9147
|
+
(async () => {
|
|
9148
|
+
if (currentFileStream) {
|
|
9149
|
+
currentFileStream.destroy(error ?? void 0);
|
|
9150
|
+
currentFileStream = null;
|
|
9151
|
+
currentWriteCallback = null;
|
|
9152
|
+
}
|
|
9153
|
+
await opQueue.onIdle();
|
|
9154
|
+
})().then(() => callback(error ?? null), (e) => callback(error ?? (e instanceof Error ? e : /* @__PURE__ */ new Error("Stream destroyed"))));
|
|
10590
9155
|
}
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
mode: opts.mode,
|
|
10597
|
-
recursive: true
|
|
10598
|
-
}, function(err, made) {
|
|
10599
|
-
if (err) return cb(err);
|
|
10600
|
-
chperm(name, opts, cb);
|
|
10601
|
-
});
|
|
10602
|
-
});
|
|
10603
|
-
}
|
|
10604
|
-
};
|
|
10605
|
-
function validateNotSymlink(fs, name, root, cb) {
|
|
10606
|
-
if (name === root) return cb(null, true);
|
|
10607
|
-
if (!name.startsWith(root + path$1.sep)) return cb(null, false);
|
|
10608
|
-
fs.lstat(name, function(err, st) {
|
|
10609
|
-
if (err && err.code !== "ENOENT" && err.code !== "EPERM") return cb(err);
|
|
10610
|
-
if (err || !st.isSymbolicLink()) return validateNotSymlink(fs, path$1.join(name, ".."), root, cb);
|
|
10611
|
-
cb(null, false);
|
|
10612
|
-
});
|
|
10613
|
-
}
|
|
10614
|
-
function validate(fs, name, root, cb) {
|
|
10615
|
-
if (name === root) return cb(null, true);
|
|
10616
|
-
fs.lstat(name, function(err, st) {
|
|
10617
|
-
if (err && err.code !== "ENOENT" && err.code !== "EPERM") return cb(err);
|
|
10618
|
-
if (err || st.isDirectory()) return validate(fs, path$1.join(name, ".."), root, cb);
|
|
10619
|
-
cb(null, false);
|
|
10620
|
-
});
|
|
10621
|
-
}
|
|
10622
|
-
function noop() {}
|
|
10623
|
-
function echo(name) {
|
|
10624
|
-
return name;
|
|
10625
|
-
}
|
|
10626
|
-
function normalize(name) {
|
|
10627
|
-
return win32 ? name.replace(/\\/g, "/").replace(/[:?<>|]/g, "_") : name;
|
|
10628
|
-
}
|
|
10629
|
-
function strip(map, level) {
|
|
10630
|
-
return function(header) {
|
|
10631
|
-
header.name = header.name.split("/").slice(level).join("/");
|
|
10632
|
-
const linkname = header.linkname;
|
|
10633
|
-
if (linkname && (header.type === "link" || path$1.isAbsolute(linkname))) header.linkname = linkname.split("/").slice(level).join("/");
|
|
10634
|
-
return map(header);
|
|
10635
|
-
};
|
|
10636
|
-
}
|
|
10637
|
-
})))();
|
|
9156
|
+
});
|
|
9157
|
+
return writable;
|
|
9158
|
+
}
|
|
9159
|
+
//#endregion
|
|
9160
|
+
//#region src/core/fetch-packages.ts
|
|
10638
9161
|
const NODE_MODULES = fileURLToPath(new URL("../../node_modules", import.meta.url));
|
|
10639
9162
|
function verifyPackage(addonPkg, specifier) {
|
|
10640
9163
|
const peerDeps = { ...addonPkg.peerDependencies };
|
|
@@ -10684,10 +9207,7 @@ async function downloadPackage(options) {
|
|
|
10684
9207
|
const tarballUrl = pkg.dist.tarball;
|
|
10685
9208
|
const data = await fetch(tarballUrl);
|
|
10686
9209
|
if (!data.body) throw new Error(`Unexpected response: '${tarballUrl}' responded with no body`);
|
|
10687
|
-
await pipeline(data.body, createGunzip(), (
|
|
10688
|
-
header.name = header.name.replace("package", pkg.name);
|
|
10689
|
-
return header;
|
|
10690
|
-
} }));
|
|
9210
|
+
await pipeline(data.body, createGunzip(), unpackTar(path.join(NODE_MODULES, pkg.name), { strip: 1 }));
|
|
10691
9211
|
return await importAddonCode(pkg.name, pkg.version);
|
|
10692
9212
|
}
|
|
10693
9213
|
async function importAddonCode(pkgName, pkgVersion) {
|
|
@@ -10737,31 +9257,40 @@ async function formatFiles(options) {
|
|
|
10737
9257
|
const { start, stop } = vt();
|
|
10738
9258
|
start("Formatting modified files");
|
|
10739
9259
|
const args = [
|
|
10740
|
-
"prettier",
|
|
10741
9260
|
"--write",
|
|
10742
9261
|
"--ignore-unknown",
|
|
10743
9262
|
...options.filesToFormat
|
|
10744
9263
|
];
|
|
10745
|
-
|
|
9264
|
+
let result = await run("prettier", args, options.cwd);
|
|
9265
|
+
if (result.notFound) {
|
|
9266
|
+
const cmd = resolveCommand(options.packageManager, "execute-local", ["prettier", ...args]);
|
|
9267
|
+
result = await run(cmd.command, cmd.args, options.cwd);
|
|
9268
|
+
}
|
|
9269
|
+
if (result.error !== void 0) {
|
|
9270
|
+
stop("Failed to format files");
|
|
9271
|
+
R$1.error(result.error);
|
|
9272
|
+
return;
|
|
9273
|
+
}
|
|
9274
|
+
stop("Successfully formatted modified files");
|
|
9275
|
+
}
|
|
9276
|
+
async function run(command, args, cwd) {
|
|
10746
9277
|
try {
|
|
10747
|
-
|
|
9278
|
+
await z(command, args, {
|
|
10748
9279
|
nodeOptions: {
|
|
10749
|
-
cwd
|
|
9280
|
+
cwd,
|
|
10750
9281
|
stdio: "pipe"
|
|
10751
9282
|
},
|
|
10752
9283
|
throwOnError: true
|
|
10753
9284
|
});
|
|
10754
|
-
|
|
10755
|
-
stop("Failed to format files");
|
|
10756
|
-
R$1.error(result.stderr);
|
|
10757
|
-
return;
|
|
10758
|
-
}
|
|
9285
|
+
return {};
|
|
10759
9286
|
} catch (e) {
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
9287
|
+
if (e?.code === "ENOENT") return {
|
|
9288
|
+
notFound: true,
|
|
9289
|
+
error: `${command} not found`
|
|
9290
|
+
};
|
|
9291
|
+
const output = e?.output;
|
|
9292
|
+
return { error: [output?.stderr, output?.stdout].filter(Boolean).join("\n").trim() || (e instanceof Error ? e.message : "unknown error") };
|
|
10763
9293
|
}
|
|
10764
|
-
stop("Successfully formatted modified files");
|
|
10765
9294
|
}
|
|
10766
9295
|
//#endregion
|
|
10767
9296
|
//#region src/core/package-manager.ts
|
|
@@ -10771,18 +9300,11 @@ async function packageManagerPrompt(cwd) {
|
|
|
10771
9300
|
const agent = (await detect({ cwd }))?.name ?? getUserAgent();
|
|
10772
9301
|
if (!V.stdout.isTTY) return agent;
|
|
10773
9302
|
const pm = await Ee({
|
|
10774
|
-
message: "
|
|
9303
|
+
message: "Detected package managers. Which one should we use to install dependencies?",
|
|
10775
9304
|
options: [{
|
|
10776
9305
|
label: "None",
|
|
10777
9306
|
value: void 0
|
|
10778
|
-
}, ...AGENT_NAMES.map((agent) => {
|
|
10779
|
-
const installed = isInstalled(agent);
|
|
10780
|
-
return {
|
|
10781
|
-
value: agent,
|
|
10782
|
-
label: installed ? agent : color.dim(`${agent} (not installed)`),
|
|
10783
|
-
installed
|
|
10784
|
-
};
|
|
10785
|
-
}).sort((a, b) => Number(b.installed) - Number(a.installed))],
|
|
9307
|
+
}, ...AGENT_NAMES.filter(isInstalled).map((agent) => ({ value: agent }))],
|
|
10786
9308
|
initialValue: agent
|
|
10787
9309
|
});
|
|
10788
9310
|
if (R$2(pm)) {
|
|
@@ -12362,10 +10884,30 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions }
|
|
|
12362
10884
|
cancels
|
|
12363
10885
|
};
|
|
12364
10886
|
}
|
|
10887
|
+
/**
|
|
10888
|
+
* Orders add-ons so every `runsAfter` is honoured, keeping the original order between add-ons that
|
|
10889
|
+
* don't constrain each other. Cycles and unknown ids are ignored rather than fatal - an add-on that
|
|
10890
|
+
* can't be placed simply keeps its position.
|
|
10891
|
+
*/
|
|
12365
10892
|
function orderAddons(addons, setupResults) {
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
10893
|
+
const byId = new Map(addons.map((addon) => [addon.id, addon]));
|
|
10894
|
+
const ordered = [];
|
|
10895
|
+
const placed = /* @__PURE__ */ new Set();
|
|
10896
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
10897
|
+
const place = (addon) => {
|
|
10898
|
+
if (placed.has(addon.id) || visiting.has(addon.id)) return;
|
|
10899
|
+
visiting.add(addon.id);
|
|
10900
|
+
for (const id of setupResults[addon.id]?.runsAfter ?? []) {
|
|
10901
|
+
const dependency = byId.get(id);
|
|
10902
|
+
if (dependency) place(dependency);
|
|
10903
|
+
}
|
|
10904
|
+
visiting.delete(addon.id);
|
|
10905
|
+
placed.add(addon.id);
|
|
10906
|
+
ordered.push(addon);
|
|
10907
|
+
};
|
|
10908
|
+
const seeded = [...addons].sort((a, b) => (setupResults[a.id]?.runsAfter?.length ?? 0) - (setupResults[b.id]?.runsAfter?.length ?? 0));
|
|
10909
|
+
for (const addon of seeded) place(addon);
|
|
10910
|
+
return ordered;
|
|
12369
10911
|
}
|
|
12370
10912
|
//#endregion
|
|
12371
10913
|
export { __toESM as S, name as _, detectPackageManager as a, __commonJSMin as b, defineAddonOptions as c, Command as d, R as f, helpConfig as g, forwardExitCode as h, addPnpmAllowBuilds as i, from as l, create$1 as m, add$1 as n, officialAddons$1 as o, z as p, create as r, defineAddon as s, add as t, program as u, version as v, __require as x, svDeprecated as y };
|