@slicemachine/adapter-next 0.0.2 → 0.0.4
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/SliceSimulator.cjs +14 -41
- package/dist/SliceSimulator.cjs.map +1 -1
- package/dist/SliceSimulator.d.ts +2 -2
- package/dist/SliceSimulator.js +11 -36
- package/dist/SliceSimulator.js.map +1 -1
- package/dist/_virtual/_commonjsHelpers.cjs +5 -0
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
- package/dist/_virtual/_commonjsHelpers.js +5 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/ponyfill.es2018.cjs +5 -0
- package/dist/_virtual/ponyfill.es2018.cjs.map +1 -0
- package/dist/_virtual/ponyfill.es2018.js +5 -0
- package/dist/_virtual/ponyfill.es2018.js.map +1 -0
- package/dist/constants.cjs +5 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/hooks/customType-asset-delete.cjs +3 -5
- package/dist/hooks/customType-asset-delete.cjs.map +1 -1
- package/dist/hooks/customType-asset-delete.js.map +1 -1
- package/dist/hooks/customType-asset-read.cjs +3 -5
- package/dist/hooks/customType-asset-read.cjs.map +1 -1
- package/dist/hooks/customType-asset-read.js.map +1 -1
- package/dist/hooks/customType-asset-update.cjs +4 -6
- package/dist/hooks/customType-asset-update.cjs.map +1 -1
- package/dist/hooks/customType-asset-update.js.map +1 -1
- package/dist/hooks/customType-create.cjs +4 -6
- package/dist/hooks/customType-create.cjs.map +1 -1
- package/dist/hooks/customType-create.js.map +1 -1
- package/dist/hooks/customType-delete.cjs +3 -5
- package/dist/hooks/customType-delete.cjs.map +1 -1
- package/dist/hooks/customType-delete.js.map +1 -1
- package/dist/hooks/customType-read.cjs +1 -1
- package/dist/hooks/customType-read.cjs.map +1 -1
- package/dist/hooks/customType-read.js.map +1 -1
- package/dist/hooks/customType-rename.cjs +6 -0
- package/dist/hooks/customType-rename.cjs.map +1 -0
- package/dist/hooks/customType-rename.d.ts +1 -0
- package/dist/hooks/customType-rename.js +6 -0
- package/dist/hooks/customType-rename.js.map +1 -0
- package/dist/hooks/customType-update.cjs +1 -1
- package/dist/hooks/customType-update.cjs.map +1 -1
- package/dist/hooks/customType-update.js.map +1 -1
- package/dist/hooks/customTypeLibrary-read.cjs +16 -10
- package/dist/hooks/customTypeLibrary-read.cjs.map +1 -1
- package/dist/hooks/customTypeLibrary-read.js +12 -4
- package/dist/hooks/customTypeLibrary-read.js.map +1 -1
- package/dist/hooks/slice-asset-delete.cjs +3 -5
- package/dist/hooks/slice-asset-delete.cjs.map +1 -1
- package/dist/hooks/slice-asset-delete.js.map +1 -1
- package/dist/hooks/slice-asset-read.cjs +3 -5
- package/dist/hooks/slice-asset-read.cjs.map +1 -1
- package/dist/hooks/slice-asset-read.js.map +1 -1
- package/dist/hooks/slice-asset-update.cjs +4 -6
- package/dist/hooks/slice-asset-update.cjs.map +1 -1
- package/dist/hooks/slice-asset-update.js.map +1 -1
- package/dist/hooks/slice-create.cjs +18 -30
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +14 -24
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/slice-delete.cjs +6 -18
- package/dist/hooks/slice-delete.cjs.map +1 -1
- package/dist/hooks/slice-delete.js +3 -13
- package/dist/hooks/slice-delete.js.map +1 -1
- package/dist/hooks/slice-read.cjs +41 -7
- package/dist/hooks/slice-read.cjs.map +1 -1
- package/dist/hooks/slice-read.js +22 -6
- package/dist/hooks/slice-read.js.map +1 -1
- package/dist/hooks/slice-rename.cjs +43 -0
- package/dist/hooks/slice-rename.cjs.map +1 -0
- package/dist/hooks/slice-rename.d.ts +3 -0
- package/dist/hooks/slice-rename.js +26 -0
- package/dist/hooks/slice-rename.js.map +1 -0
- package/dist/hooks/slice-update.cjs +7 -34
- package/dist/hooks/slice-update.cjs.map +1 -1
- package/dist/hooks/slice-update.js +6 -13
- package/dist/hooks/slice-update.js.map +1 -1
- package/dist/hooks/sliceLibrary-read.cjs +16 -20
- package/dist/hooks/sliceLibrary-read.cjs.map +1 -1
- package/dist/hooks/sliceLibrary-read.js +12 -13
- package/dist/hooks/sliceLibrary-read.js.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.cjs +31 -94
- package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.js +31 -75
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -1
- package/dist/hooks/snippet-read.cjs +33 -18
- package/dist/hooks/snippet-read.cjs.map +1 -1
- package/dist/hooks/snippet-read.js +30 -13
- package/dist/hooks/snippet-read.js.map +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/getJSOrTSXFileExtension.cjs +1 -1
- package/dist/lib/getJSOrTSXFileExtension.cjs.map +1 -1
- package/dist/lib/getJSOrTSXFileExtension.js.map +1 -1
- package/dist/lib/isSharedSliceModel.cjs +25 -0
- package/dist/lib/isSharedSliceModel.cjs.map +1 -0
- package/dist/lib/isSharedSliceModel.d.ts +2 -0
- package/dist/lib/isSharedSliceModel.js +8 -0
- package/dist/lib/isSharedSliceModel.js.map +1 -0
- package/dist/lib/pascalCase.cjs +1 -1
- package/dist/lib/pascalCase.cjs.map +1 -1
- package/dist/lib/pascalCase.js.map +1 -1
- package/dist/lib/readJSONFile.cjs +3 -5
- package/dist/lib/readJSONFile.cjs.map +1 -1
- package/dist/lib/readJSONFile.js.map +1 -1
- package/dist/lib/rejectIfNecessary.cjs +1 -1
- package/dist/lib/rejectIfNecessary.cjs.map +1 -1
- package/dist/lib/rejectIfNecessary.js.map +1 -1
- package/dist/lib/updateSliceModelFile.cjs +31 -0
- package/dist/lib/updateSliceModelFile.cjs.map +1 -0
- package/dist/lib/updateSliceModelFile.d.ts +9 -0
- package/dist/lib/updateSliceModelFile.js +14 -0
- package/dist/lib/updateSliceModelFile.js.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.cjs +8 -6
- package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -1
- package/dist/lib/upsertGlobalContentTypes.d.ts +1 -1
- package/dist/lib/upsertGlobalContentTypes.js +4 -0
- package/dist/lib/upsertGlobalContentTypes.js.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +48 -0
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -0
- package/dist/lib/upsertSliceLibraryIndexFile.d.ts +7 -0
- package/dist/lib/upsertSliceLibraryIndexFile.js +31 -0
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs +41 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs.map +1 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.js +41 -0
- package/dist/node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
- package/dist/node_modules/fetch-blob/file.cjs +55 -0
- package/dist/node_modules/fetch-blob/file.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/file.js +55 -0
- package/dist/node_modules/fetch-blob/file.js.map +1 -0
- package/dist/node_modules/fetch-blob/index.cjs +176 -0
- package/dist/node_modules/fetch-blob/index.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/index.js +176 -0
- package/dist/node_modules/fetch-blob/index.js.map +1 -0
- package/dist/node_modules/fetch-blob/streams.cjs +43 -0
- package/dist/node_modules/fetch-blob/streams.cjs.map +1 -0
- package/dist/node_modules/fetch-blob/streams.js +42 -0
- package/dist/node_modules/fetch-blob/streams.js.map +1 -0
- package/dist/node_modules/formdata-polyfill/esm.min.cjs +115 -0
- package/dist/node_modules/formdata-polyfill/esm.min.cjs.map +1 -0
- package/dist/node_modules/formdata-polyfill/esm.min.js +115 -0
- package/dist/node_modules/formdata-polyfill/esm.min.js.map +1 -0
- package/dist/node_modules/node-domexception/index.cjs +10 -0
- package/dist/node_modules/node-domexception/index.cjs.map +1 -0
- package/dist/node_modules/node-domexception/index.js +9 -0
- package/dist/node_modules/node-domexception/index.js.map +1 -0
- package/dist/node_modules/node-fetch/src/body.cjs +237 -0
- package/dist/node_modules/node-fetch/src/body.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/body.js +237 -0
- package/dist/node_modules/node-fetch/src/body.js.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.cjs +10 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.js +10 -0
- package/dist/node_modules/node-fetch/src/errors/abort-error.js.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/base.cjs +17 -0
- package/dist/node_modules/node-fetch/src/errors/base.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/base.js +17 -0
- package/dist/node_modules/node-fetch/src/errors/base.js.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs +14 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js +14 -0
- package/dist/node_modules/node-fetch/src/errors/fetch-error.js.map +1 -0
- package/dist/node_modules/node-fetch/src/headers.cjs +173 -0
- package/dist/node_modules/node-fetch/src/headers.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/headers.js +173 -0
- package/dist/node_modules/node-fetch/src/headers.js.map +1 -0
- package/dist/node_modules/node-fetch/src/index.cjs +292 -0
- package/dist/node_modules/node-fetch/src/index.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/index.js +298 -0
- package/dist/node_modules/node-fetch/src/index.js.map +1 -0
- package/dist/node_modules/node-fetch/src/request.cjs +193 -0
- package/dist/node_modules/node-fetch/src/request.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/request.js +193 -0
- package/dist/node_modules/node-fetch/src/request.js.map +1 -0
- package/dist/node_modules/node-fetch/src/response.cjs +110 -0
- package/dist/node_modules/node-fetch/src/response.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/response.js +110 -0
- package/dist/node_modules/node-fetch/src/response.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.cjs +12 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.js +12 -0
- package/dist/node_modules/node-fetch/src/utils/get-search.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is-redirect.cjs +8 -0
- package/dist/node_modules/node-fetch/src/utils/is-redirect.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is-redirect.js +8 -0
- package/dist/node_modules/node-fetch/src/utils/is-redirect.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is.cjs +28 -0
- package/dist/node_modules/node-fetch/src/utils/is.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/is.js +28 -0
- package/dist/node_modules/node-fetch/src/utils/is.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs +350 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.js +350 -0
- package/dist/node_modules/node-fetch/src/utils/multipart-parser.js.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.cjs +149 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.cjs.map +1 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.js +149 -0
- package/dist/node_modules/node-fetch/src/utils/referrer.js.map +1 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +3599 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs.map +1 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +3599 -0
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
- package/dist/package.json.cjs +5 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/{package.js → package.json.js} +1 -1
- package/dist/package.json.js.map +1 -0
- package/dist/plugin.cjs +6 -2
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +5 -1
- package/dist/plugin.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +32 -15
- package/src/constants.ts +5 -0
- package/src/hooks/customType-rename.ts +3 -0
- package/src/hooks/customTypeLibrary-read.ts +13 -4
- package/src/hooks/slice-create.ts +14 -32
- package/src/hooks/slice-delete.ts +3 -21
- package/src/hooks/slice-read.ts +37 -11
- package/src/hooks/slice-rename.ts +44 -0
- package/src/hooks/slice-update.ts +7 -31
- package/src/hooks/sliceLibrary-read.ts +13 -23
- package/src/hooks/sliceSimulator-setup-read.ts +37 -76
- package/src/hooks/snippet-read.ts +42 -22
- package/src/index.ts +0 -6
- package/src/lib/isSharedSliceModel.ts +14 -0
- package/src/lib/updateSliceModelFile.ts +32 -0
- package/src/lib/upsertGlobalContentTypes.ts +3 -0
- package/src/lib/{buildSliceLibraryIndexFileContents.ts → upsertSliceLibraryIndexFile.ts} +19 -9
- package/src/plugin.ts +4 -0
- package/dist/lib/buildSliceLibraryIndexFileContents.cjs +0 -23
- package/dist/lib/buildSliceLibraryIndexFileContents.cjs.map +0 -1
- package/dist/lib/buildSliceLibraryIndexFileContents.d.ts +0 -10
- package/dist/lib/buildSliceLibraryIndexFileContents.js +0 -23
- package/dist/lib/buildSliceLibraryIndexFileContents.js.map +0 -1
- package/dist/package.cjs +0 -5
- package/dist/package.cjs.map +0 -1
- package/dist/package.js.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const ponyfill_es2018 = require("../web-streams-polyfill/dist/ponyfill.es2018.cjs");
|
|
3
|
+
const POOL_SIZE = 65536;
|
|
4
|
+
if (!globalThis.ReadableStream) {
|
|
5
|
+
try {
|
|
6
|
+
const process = require("node:process");
|
|
7
|
+
const { emitWarning } = process;
|
|
8
|
+
try {
|
|
9
|
+
process.emitWarning = () => {
|
|
10
|
+
};
|
|
11
|
+
Object.assign(globalThis, require("node:stream/web"));
|
|
12
|
+
process.emitWarning = emitWarning;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
process.emitWarning = emitWarning;
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
Object.assign(globalThis, ponyfill_es2018.__require());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const { Blob } = require("buffer");
|
|
23
|
+
if (Blob && !Blob.prototype.stream) {
|
|
24
|
+
Blob.prototype.stream = function name(params) {
|
|
25
|
+
let position = 0;
|
|
26
|
+
const blob = this;
|
|
27
|
+
return new ReadableStream({
|
|
28
|
+
type: "bytes",
|
|
29
|
+
async pull(ctrl) {
|
|
30
|
+
const chunk = blob.slice(position, Math.min(blob.size, position + POOL_SIZE));
|
|
31
|
+
const buffer = await chunk.arrayBuffer();
|
|
32
|
+
position += buffer.byteLength;
|
|
33
|
+
ctrl.enqueue(new Uint8Array(buffer));
|
|
34
|
+
if (position === blob.size) {
|
|
35
|
+
ctrl.close();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=streams.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streams.cjs","sources":["../../../node_modules/fetch-blob/streams.cjs"],"sourcesContent":["/* c8 ignore start */\n// 64 KiB (same size chrome slice theirs blob into Uint8array's)\nconst POOL_SIZE = 65536\n\nif (!globalThis.ReadableStream) {\n // `node:stream/web` got introduced in v16.5.0 as experimental\n // and it's preferred over the polyfilled version. So we also\n // suppress the warning that gets emitted by NodeJS for using it.\n try {\n const process = require('node:process')\n const { emitWarning } = process\n try {\n process.emitWarning = () => {}\n Object.assign(globalThis, require('node:stream/web'))\n process.emitWarning = emitWarning\n } catch (error) {\n process.emitWarning = emitWarning\n throw error\n }\n } catch (error) {\n // fallback to polyfill implementation\n Object.assign(globalThis, require('web-streams-polyfill/dist/ponyfill.es2018.js'))\n }\n}\n\ntry {\n // Don't use node: prefix for this, require+node: is not supported until node v14.14\n // Only `import()` can use prefix in 12.20 and later\n const { Blob } = require('buffer')\n if (Blob && !Blob.prototype.stream) {\n Blob.prototype.stream = function name (params) {\n let position = 0\n const blob = this\n\n return new ReadableStream({\n type: 'bytes',\n async pull (ctrl) {\n const chunk = blob.slice(position, Math.min(blob.size, position + POOL_SIZE))\n const buffer = await chunk.arrayBuffer()\n position += buffer.byteLength\n ctrl.enqueue(new Uint8Array(buffer))\n\n if (position === blob.size) {\n ctrl.close()\n }\n }\n })\n }\n }\n} catch (error) {}\n/* c8 ignore end */\n"],"names":["require$$2"],"mappings":";;AAEA,MAAM,YAAY;AAElB,IAAI,CAAC,WAAW,gBAAgB;AAI9B,MAAI;AACF,UAAM,UAAU,QAAQ;AACxB,UAAM,EAAE,YAAW,IAAK;AACxB,QAAI;AACF,cAAQ,cAAc,MAAM;AAAA,MAAE;AAC9B,aAAO,OAAO,YAAY,QAAQ,kBAAkB;AACpD,cAAQ,cAAc;AAAA,IACvB,SAAQ,OAAP;AACA,cAAQ,cAAc;AACtB,YAAM;AAAA,IACP;AAAA,EACF,SAAQ,OAAP;AAEA,WAAO,OAAO,YAAYA,gBAAAA,WAAuD;AAAA,EAClF;AACH;AAEA,IAAI;AAGF,QAAM,EAAE,KAAI,IAAK,QAAQ;AACzB,MAAI,QAAQ,CAAC,KAAK,UAAU,QAAQ;AAClC,SAAK,UAAU,SAAS,SAAS,KAAM,QAAQ;AAC7C,UAAI,WAAW;AACf,YAAM,OAAO;AAEb,aAAO,IAAI,eAAe;AAAA,QACxB,MAAM;AAAA,QACN,MAAM,KAAM,MAAM;AAChB,gBAAM,QAAQ,KAAK,MAAM,UAAU,KAAK,IAAI,KAAK,MAAM,WAAW,SAAS,CAAC;AAC5E,gBAAM,SAAS,MAAM,MAAM,YAAa;AACxC,sBAAY,OAAO;AACnB,eAAK,QAAQ,IAAI,WAAW,MAAM,CAAC;AAEnC,cAAI,aAAa,KAAK,MAAM;AAC1B,iBAAK,MAAO;AAAA,UACb;AAAA,QACF;AAAA,MACT,CAAO;AAAA,IACF;AAAA,EACF;AACH,SAAS,OAAP;AAAc;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __require as requirePonyfill_es2018 } from "../web-streams-polyfill/dist/ponyfill.es2018.js";
|
|
2
|
+
const POOL_SIZE = 65536;
|
|
3
|
+
if (!globalThis.ReadableStream) {
|
|
4
|
+
try {
|
|
5
|
+
const process = require("node:process");
|
|
6
|
+
const { emitWarning } = process;
|
|
7
|
+
try {
|
|
8
|
+
process.emitWarning = () => {
|
|
9
|
+
};
|
|
10
|
+
Object.assign(globalThis, require("node:stream/web"));
|
|
11
|
+
process.emitWarning = emitWarning;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
process.emitWarning = emitWarning;
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
} catch (error) {
|
|
17
|
+
Object.assign(globalThis, requirePonyfill_es2018());
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const { Blob } = require("buffer");
|
|
22
|
+
if (Blob && !Blob.prototype.stream) {
|
|
23
|
+
Blob.prototype.stream = function name(params) {
|
|
24
|
+
let position = 0;
|
|
25
|
+
const blob = this;
|
|
26
|
+
return new ReadableStream({
|
|
27
|
+
type: "bytes",
|
|
28
|
+
async pull(ctrl) {
|
|
29
|
+
const chunk = blob.slice(position, Math.min(blob.size, position + POOL_SIZE));
|
|
30
|
+
const buffer = await chunk.arrayBuffer();
|
|
31
|
+
position += buffer.byteLength;
|
|
32
|
+
ctrl.enqueue(new Uint8Array(buffer));
|
|
33
|
+
if (position === blob.size) {
|
|
34
|
+
ctrl.close();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=streams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streams.js","sources":["../../../node_modules/fetch-blob/streams.cjs"],"sourcesContent":["/* c8 ignore start */\n// 64 KiB (same size chrome slice theirs blob into Uint8array's)\nconst POOL_SIZE = 65536\n\nif (!globalThis.ReadableStream) {\n // `node:stream/web` got introduced in v16.5.0 as experimental\n // and it's preferred over the polyfilled version. So we also\n // suppress the warning that gets emitted by NodeJS for using it.\n try {\n const process = require('node:process')\n const { emitWarning } = process\n try {\n process.emitWarning = () => {}\n Object.assign(globalThis, require('node:stream/web'))\n process.emitWarning = emitWarning\n } catch (error) {\n process.emitWarning = emitWarning\n throw error\n }\n } catch (error) {\n // fallback to polyfill implementation\n Object.assign(globalThis, require('web-streams-polyfill/dist/ponyfill.es2018.js'))\n }\n}\n\ntry {\n // Don't use node: prefix for this, require+node: is not supported until node v14.14\n // Only `import()` can use prefix in 12.20 and later\n const { Blob } = require('buffer')\n if (Blob && !Blob.prototype.stream) {\n Blob.prototype.stream = function name (params) {\n let position = 0\n const blob = this\n\n return new ReadableStream({\n type: 'bytes',\n async pull (ctrl) {\n const chunk = blob.slice(position, Math.min(blob.size, position + POOL_SIZE))\n const buffer = await chunk.arrayBuffer()\n position += buffer.byteLength\n ctrl.enqueue(new Uint8Array(buffer))\n\n if (position === blob.size) {\n ctrl.close()\n }\n }\n })\n }\n }\n} catch (error) {}\n/* c8 ignore end */\n"],"names":["require$$2"],"mappings":";AAEA,MAAM,YAAY;AAElB,IAAI,CAAC,WAAW,gBAAgB;AAI9B,MAAI;AACF,UAAM,UAAU,QAAQ;AACxB,UAAM,EAAE,YAAW,IAAK;AACxB,QAAI;AACF,cAAQ,cAAc,MAAM;AAAA,MAAE;AAC9B,aAAO,OAAO,YAAY,QAAQ,kBAAkB;AACpD,cAAQ,cAAc;AAAA,IACvB,SAAQ,OAAP;AACA,cAAQ,cAAc;AACtB,YAAM;AAAA,IACP;AAAA,EACF,SAAQ,OAAP;AAEA,WAAO,OAAO,YAAYA,wBAAuD;AAAA,EAClF;AACH;AAEA,IAAI;AAGF,QAAM,EAAE,KAAI,IAAK,QAAQ;AACzB,MAAI,QAAQ,CAAC,KAAK,UAAU,QAAQ;AAClC,SAAK,UAAU,SAAS,SAAS,KAAM,QAAQ;AAC7C,UAAI,WAAW;AACf,YAAM,OAAO;AAEb,aAAO,IAAI,eAAe;AAAA,QACxB,MAAM;AAAA,QACN,MAAM,KAAM,MAAM;AAChB,gBAAM,QAAQ,KAAK,MAAM,UAAU,KAAK,IAAI,KAAK,MAAM,WAAW,SAAS,CAAC;AAC5E,gBAAM,SAAS,MAAM,MAAM,YAAa;AACxC,sBAAY,OAAO;AACnB,eAAK,QAAQ,IAAI,WAAW,MAAM,CAAC;AAEnC,cAAI,aAAa,KAAK,MAAM;AAC1B,iBAAK,MAAO;AAAA,UACb;AAAA,QACF;AAAA,MACT,CAAO;AAAA,IACF;AAAA,EACF;AACH,SAAS,OAAP;AAAc;"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __accessCheck = (obj, member, msg) => {
|
|
3
|
+
if (!member.has(obj))
|
|
4
|
+
throw TypeError("Cannot " + msg);
|
|
5
|
+
};
|
|
6
|
+
var __privateGet = (obj, member, getter) => {
|
|
7
|
+
__accessCheck(obj, member, "read from private field");
|
|
8
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
9
|
+
};
|
|
10
|
+
var __privateAdd = (obj, member, value) => {
|
|
11
|
+
if (member.has(obj))
|
|
12
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
13
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
14
|
+
};
|
|
15
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
16
|
+
__accessCheck(obj, member, "write to private field");
|
|
17
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
var _d, _a;
|
|
21
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
22
|
+
const index = require("../fetch-blob/index.cjs");
|
|
23
|
+
const file = require("../fetch-blob/file.cjs");
|
|
24
|
+
var { toStringTag: t, iterator: i, hasInstance: h } = Symbol, r = Math.random, m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","), f = (a, b, c) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c = c !== void 0 ? c + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c || b[t] == "blob" ? new file.File([b], c, b) : b] : [a, b + ""]), e = (c, f2) => (f2 ? c : c.replace(/\r?\n|\r/g, "\r\n")).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), x = (n, a, e2) => {
|
|
25
|
+
if (a.length < e2) {
|
|
26
|
+
throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const FormData = (_a = class {
|
|
30
|
+
constructor(...a) {
|
|
31
|
+
__privateAdd(this, _d, []);
|
|
32
|
+
if (a.length)
|
|
33
|
+
throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
|
|
34
|
+
}
|
|
35
|
+
get [t]() {
|
|
36
|
+
return "FormData";
|
|
37
|
+
}
|
|
38
|
+
[i]() {
|
|
39
|
+
return this.entries();
|
|
40
|
+
}
|
|
41
|
+
static [h](o) {
|
|
42
|
+
return o && typeof o === "object" && o[t] === "FormData" && !m.some((m2) => typeof o[m2] != "function");
|
|
43
|
+
}
|
|
44
|
+
append(...a) {
|
|
45
|
+
x("append", arguments, 2);
|
|
46
|
+
__privateGet(this, _d).push(f(...a));
|
|
47
|
+
}
|
|
48
|
+
delete(a) {
|
|
49
|
+
x("delete", arguments, 1);
|
|
50
|
+
a += "";
|
|
51
|
+
__privateSet(this, _d, __privateGet(this, _d).filter(([b]) => b !== a));
|
|
52
|
+
}
|
|
53
|
+
get(a) {
|
|
54
|
+
x("get", arguments, 1);
|
|
55
|
+
a += "";
|
|
56
|
+
for (var b = __privateGet(this, _d), l = b.length, c = 0; c < l; c++)
|
|
57
|
+
if (b[c][0] === a)
|
|
58
|
+
return b[c][1];
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
getAll(a, b) {
|
|
62
|
+
x("getAll", arguments, 1);
|
|
63
|
+
b = [];
|
|
64
|
+
a += "";
|
|
65
|
+
__privateGet(this, _d).forEach((c) => c[0] === a && b.push(c[1]));
|
|
66
|
+
return b;
|
|
67
|
+
}
|
|
68
|
+
has(a) {
|
|
69
|
+
x("has", arguments, 1);
|
|
70
|
+
a += "";
|
|
71
|
+
return __privateGet(this, _d).some((b) => b[0] === a);
|
|
72
|
+
}
|
|
73
|
+
forEach(a, b) {
|
|
74
|
+
x("forEach", arguments, 1);
|
|
75
|
+
for (var [c, d] of this)
|
|
76
|
+
a.call(b, d, c, this);
|
|
77
|
+
}
|
|
78
|
+
set(...a) {
|
|
79
|
+
x("set", arguments, 2);
|
|
80
|
+
var b = [], c = true;
|
|
81
|
+
a = f(...a);
|
|
82
|
+
__privateGet(this, _d).forEach((d) => {
|
|
83
|
+
d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
|
|
84
|
+
});
|
|
85
|
+
c && b.push(a);
|
|
86
|
+
__privateSet(this, _d, b);
|
|
87
|
+
}
|
|
88
|
+
*entries() {
|
|
89
|
+
yield* __privateGet(this, _d);
|
|
90
|
+
}
|
|
91
|
+
*keys() {
|
|
92
|
+
for (var [a] of this)
|
|
93
|
+
yield a;
|
|
94
|
+
}
|
|
95
|
+
*values() {
|
|
96
|
+
for (var [, a] of this)
|
|
97
|
+
yield a;
|
|
98
|
+
}
|
|
99
|
+
}, _d = new WeakMap(), _a);
|
|
100
|
+
function formDataToBlob(F, B = index.default) {
|
|
101
|
+
var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), c = [], p = `--${b}\r
|
|
102
|
+
Content-Disposition: form-data; name="`;
|
|
103
|
+
F.forEach((v, n) => typeof v == "string" ? c.push(p + e(n) + `"\r
|
|
104
|
+
\r
|
|
105
|
+
${v.replace(new RegExp("\\r(?!\\n)|(?<!\\r)\\n", "g"), "\r\n")}\r
|
|
106
|
+
`) : c.push(p + e(n) + `"; filename="${e(v.name, 1)}"\r
|
|
107
|
+
Content-Type: ${v.type || "application/octet-stream"}\r
|
|
108
|
+
\r
|
|
109
|
+
`, v, "\r\n"));
|
|
110
|
+
c.push(`--${b}--`);
|
|
111
|
+
return new B(c, { type: "multipart/form-data; boundary=" + b });
|
|
112
|
+
}
|
|
113
|
+
exports.FormData = FormData;
|
|
114
|
+
exports.formDataToBlob = formDataToBlob;
|
|
115
|
+
//# sourceMappingURL=esm.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esm.min.cjs","sources":["../../../node_modules/formdata-polyfill/esm.min.js"],"sourcesContent":["/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */\n\nimport C from 'fetch-blob'\nimport F from 'fetch-blob/file.js'\n\nvar {toStringTag:t,iterator:i,hasInstance:h}=Symbol,\nr=Math.random,\nm='append,set,get,getAll,delete,keys,values,entries,forEach,constructor'.split(','),\nf=(a,b,c)=>(a+='',/^(Blob|File)$/.test(b && b[t])?[(c=c!==void 0?c+'':b[t]=='File'?b.name:'blob',a),b.name!==c||b[t]=='blob'?new F([b],c,b):b]:[a,b+'']),\ne=(c,f)=>(f?c:c.replace(/\\r?\\n|\\r/g,'\\r\\n')).replace(/\\n/g,'%0A').replace(/\\r/g,'%0D').replace(/\"/g,'%22'),\nx=(n, a, e)=>{if(a.length<e){throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e} arguments required, but only ${a.length} present.`)}}\n\nexport const File = F\n\n/** @type {typeof globalThis.FormData} */\nexport const FormData = class FormData {\n#d=[];\nconstructor(...a){if(a.length)throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`)}\nget [t]() {return 'FormData'}\n[i](){return this.entries()}\nstatic [h](o) {return o&&typeof o==='object'&&o[t]==='FormData'&&!m.some(m=>typeof o[m]!='function')}\nappend(...a){x('append',arguments,2);this.#d.push(f(...a))}\ndelete(a){x('delete',arguments,1);a+='';this.#d=this.#d.filter(([b])=>b!==a)}\nget(a){x('get',arguments,1);a+='';for(var b=this.#d,l=b.length,c=0;c<l;c++)if(b[c][0]===a)return b[c][1];return null}\ngetAll(a,b){x('getAll',arguments,1);b=[];a+='';this.#d.forEach(c=>c[0]===a&&b.push(c[1]));return b}\nhas(a){x('has',arguments,1);a+='';return this.#d.some(b=>b[0]===a)}\nforEach(a,b){x('forEach',arguments,1);for(var [c,d]of this)a.call(b,d,c,this)}\nset(...a){x('set',arguments,2);var b=[],c=!0;a=f(...a);this.#d.forEach(d=>{d[0]===a[0]?c&&(c=!b.push(a)):b.push(d)});c&&b.push(a);this.#d=b}\n*entries(){yield*this.#d}\n*keys(){for(var[a]of this)yield a}\n*values(){for(var[,a]of this)yield a}}\n\n/** @param {FormData} F */\nexport function formDataToBlob (F,B=C){\nvar b=`${r()}${r()}`.replace(/\\./g, '').slice(-28).padStart(32, '-'),c=[],p=`--${b}\\r\\nContent-Disposition: form-data; name=\"`\nF.forEach((v,n)=>typeof v=='string'\n?c.push(p+e(n)+`\"\\r\\n\\r\\n${v.replace(/\\r(?!\\n)|(?<!\\r)\\n/g, '\\r\\n')}\\r\\n`)\n:c.push(p+e(n)+`\"; filename=\"${e(v.name, 1)}\"\\r\\nContent-Type: ${v.type||\"application/octet-stream\"}\\r\\n\\r\\n`, v, '\\r\\n'))\nc.push(`--${b}--`)\nreturn new B(c,{type:\"multipart/form-data; boundary=\"+b})}\n"],"names":["F","f","e","m","C"],"mappings":";;;;;;;;;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,CAAC,OAAM;AAAC,aAAO,CAAC,CAAC,KAAI;AAAK,YAAM;AAAA,EAAC;AAAA,EACjC,CAAC,SAAQ;AAAC,aAAO,CAAE,EAAA,CAAC,KAAI;AAAK,YAAM;AAAA,EAAC;AAAC,GAdrC,oBADwB;AAkBjB,SAAS,eAAgB,GAAE,IAAEC,eAAE;AACtC,MAAI,IAAE,GAAG,EAAG,IAAG,EAAC,IAAK,QAAQ,OAAO,EAAE,EAAE,MAAM,GAAG,EAAE,SAAS,IAAI,GAAG,GAAE,IAAE,CAAE,GAAC,IAAE,KAAK;AAAA;AACjF,IAAE,QAAQ,CAAC,GAAE,MAAI,OAAO,KAAG,WAC1B,EAAE,KAAK,IAAE,EAAE,CAAC,IAAE;AAAA;AAAA,EAAY,EAAE,QAAQ,WAAA,0BAAA,GAAqB,GAAE,MAAM;AAAA,CAAO,IACxE,EAAE,KAAK,IAAE,EAAE,CAAC,IAAE,gBAAgB,EAAE,EAAE,MAAM,CAAC;AAAA,gBAAuB,EAAE,QAAM;AAAA;AAAA,GAAsC,GAAG,MAAM,CAAC;AACzH,IAAE,KAAK,KAAK,KAAK;AACjB,SAAO,IAAI,EAAE,GAAE,EAAC,MAAK,mCAAiC,EAAC,CAAC;AAAC;;;"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var __accessCheck = (obj, member, msg) => {
|
|
2
|
+
if (!member.has(obj))
|
|
3
|
+
throw TypeError("Cannot " + msg);
|
|
4
|
+
};
|
|
5
|
+
var __privateGet = (obj, member, getter) => {
|
|
6
|
+
__accessCheck(obj, member, "read from private field");
|
|
7
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
+
};
|
|
9
|
+
var __privateAdd = (obj, member, value) => {
|
|
10
|
+
if (member.has(obj))
|
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
+
};
|
|
14
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
+
__accessCheck(obj, member, "write to private field");
|
|
16
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var _d, _a;
|
|
20
|
+
import Blob from "../fetch-blob/index.js";
|
|
21
|
+
import { File } from "../fetch-blob/file.js";
|
|
22
|
+
var { toStringTag: t, iterator: i, hasInstance: h } = Symbol, r = Math.random, m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","), f = (a, b, c) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c = c !== void 0 ? c + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c || b[t] == "blob" ? new File([b], c, b) : b] : [a, b + ""]), e = (c, f2) => (f2 ? c : c.replace(/\r?\n|\r/g, "\r\n")).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), x = (n, a, e2) => {
|
|
23
|
+
if (a.length < e2) {
|
|
24
|
+
throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const FormData = (_a = class {
|
|
28
|
+
constructor(...a) {
|
|
29
|
+
__privateAdd(this, _d, []);
|
|
30
|
+
if (a.length)
|
|
31
|
+
throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
|
|
32
|
+
}
|
|
33
|
+
get [t]() {
|
|
34
|
+
return "FormData";
|
|
35
|
+
}
|
|
36
|
+
[i]() {
|
|
37
|
+
return this.entries();
|
|
38
|
+
}
|
|
39
|
+
static [h](o) {
|
|
40
|
+
return o && typeof o === "object" && o[t] === "FormData" && !m.some((m2) => typeof o[m2] != "function");
|
|
41
|
+
}
|
|
42
|
+
append(...a) {
|
|
43
|
+
x("append", arguments, 2);
|
|
44
|
+
__privateGet(this, _d).push(f(...a));
|
|
45
|
+
}
|
|
46
|
+
delete(a) {
|
|
47
|
+
x("delete", arguments, 1);
|
|
48
|
+
a += "";
|
|
49
|
+
__privateSet(this, _d, __privateGet(this, _d).filter(([b]) => b !== a));
|
|
50
|
+
}
|
|
51
|
+
get(a) {
|
|
52
|
+
x("get", arguments, 1);
|
|
53
|
+
a += "";
|
|
54
|
+
for (var b = __privateGet(this, _d), l = b.length, c = 0; c < l; c++)
|
|
55
|
+
if (b[c][0] === a)
|
|
56
|
+
return b[c][1];
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
getAll(a, b) {
|
|
60
|
+
x("getAll", arguments, 1);
|
|
61
|
+
b = [];
|
|
62
|
+
a += "";
|
|
63
|
+
__privateGet(this, _d).forEach((c) => c[0] === a && b.push(c[1]));
|
|
64
|
+
return b;
|
|
65
|
+
}
|
|
66
|
+
has(a) {
|
|
67
|
+
x("has", arguments, 1);
|
|
68
|
+
a += "";
|
|
69
|
+
return __privateGet(this, _d).some((b) => b[0] === a);
|
|
70
|
+
}
|
|
71
|
+
forEach(a, b) {
|
|
72
|
+
x("forEach", arguments, 1);
|
|
73
|
+
for (var [c, d] of this)
|
|
74
|
+
a.call(b, d, c, this);
|
|
75
|
+
}
|
|
76
|
+
set(...a) {
|
|
77
|
+
x("set", arguments, 2);
|
|
78
|
+
var b = [], c = true;
|
|
79
|
+
a = f(...a);
|
|
80
|
+
__privateGet(this, _d).forEach((d) => {
|
|
81
|
+
d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
|
|
82
|
+
});
|
|
83
|
+
c && b.push(a);
|
|
84
|
+
__privateSet(this, _d, b);
|
|
85
|
+
}
|
|
86
|
+
*entries() {
|
|
87
|
+
yield* __privateGet(this, _d);
|
|
88
|
+
}
|
|
89
|
+
*keys() {
|
|
90
|
+
for (var [a] of this)
|
|
91
|
+
yield a;
|
|
92
|
+
}
|
|
93
|
+
*values() {
|
|
94
|
+
for (var [, a] of this)
|
|
95
|
+
yield a;
|
|
96
|
+
}
|
|
97
|
+
}, _d = new WeakMap(), _a);
|
|
98
|
+
function formDataToBlob(F, B = Blob) {
|
|
99
|
+
var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), c = [], p = `--${b}\r
|
|
100
|
+
Content-Disposition: form-data; name="`;
|
|
101
|
+
F.forEach((v, n) => typeof v == "string" ? c.push(p + e(n) + `"\r
|
|
102
|
+
\r
|
|
103
|
+
${v.replace(new RegExp("\\r(?!\\n)|(?<!\\r)\\n", "g"), "\r\n")}\r
|
|
104
|
+
`) : c.push(p + e(n) + `"; filename="${e(v.name, 1)}"\r
|
|
105
|
+
Content-Type: ${v.type || "application/octet-stream"}\r
|
|
106
|
+
\r
|
|
107
|
+
`, v, "\r\n"));
|
|
108
|
+
c.push(`--${b}--`);
|
|
109
|
+
return new B(c, { type: "multipart/form-data; boundary=" + b });
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
FormData,
|
|
113
|
+
formDataToBlob
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=esm.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esm.min.js","sources":["../../../node_modules/formdata-polyfill/esm.min.js"],"sourcesContent":["/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */\n\nimport C from 'fetch-blob'\nimport F from 'fetch-blob/file.js'\n\nvar {toStringTag:t,iterator:i,hasInstance:h}=Symbol,\nr=Math.random,\nm='append,set,get,getAll,delete,keys,values,entries,forEach,constructor'.split(','),\nf=(a,b,c)=>(a+='',/^(Blob|File)$/.test(b && b[t])?[(c=c!==void 0?c+'':b[t]=='File'?b.name:'blob',a),b.name!==c||b[t]=='blob'?new F([b],c,b):b]:[a,b+'']),\ne=(c,f)=>(f?c:c.replace(/\\r?\\n|\\r/g,'\\r\\n')).replace(/\\n/g,'%0A').replace(/\\r/g,'%0D').replace(/\"/g,'%22'),\nx=(n, a, e)=>{if(a.length<e){throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e} arguments required, but only ${a.length} present.`)}}\n\nexport const File = F\n\n/** @type {typeof globalThis.FormData} */\nexport const FormData = class FormData {\n#d=[];\nconstructor(...a){if(a.length)throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`)}\nget [t]() {return 'FormData'}\n[i](){return this.entries()}\nstatic [h](o) {return o&&typeof o==='object'&&o[t]==='FormData'&&!m.some(m=>typeof o[m]!='function')}\nappend(...a){x('append',arguments,2);this.#d.push(f(...a))}\ndelete(a){x('delete',arguments,1);a+='';this.#d=this.#d.filter(([b])=>b!==a)}\nget(a){x('get',arguments,1);a+='';for(var b=this.#d,l=b.length,c=0;c<l;c++)if(b[c][0]===a)return b[c][1];return null}\ngetAll(a,b){x('getAll',arguments,1);b=[];a+='';this.#d.forEach(c=>c[0]===a&&b.push(c[1]));return b}\nhas(a){x('has',arguments,1);a+='';return this.#d.some(b=>b[0]===a)}\nforEach(a,b){x('forEach',arguments,1);for(var [c,d]of this)a.call(b,d,c,this)}\nset(...a){x('set',arguments,2);var b=[],c=!0;a=f(...a);this.#d.forEach(d=>{d[0]===a[0]?c&&(c=!b.push(a)):b.push(d)});c&&b.push(a);this.#d=b}\n*entries(){yield*this.#d}\n*keys(){for(var[a]of this)yield a}\n*values(){for(var[,a]of this)yield a}}\n\n/** @param {FormData} F */\nexport function formDataToBlob (F,B=C){\nvar b=`${r()}${r()}`.replace(/\\./g, '').slice(-28).padStart(32, '-'),c=[],p=`--${b}\\r\\nContent-Disposition: form-data; name=\"`\nF.forEach((v,n)=>typeof v=='string'\n?c.push(p+e(n)+`\"\\r\\n\\r\\n${v.replace(/\\r(?!\\n)|(?<!\\r)\\n/g, '\\r\\n')}\\r\\n`)\n:c.push(p+e(n)+`\"; filename=\"${e(v.name, 1)}\"\\r\\nContent-Type: ${v.type||\"application/octet-stream\"}\\r\\n\\r\\n`, v, '\\r\\n'))\nc.push(`--${b}--`)\nreturn new B(c,{type:\"multipart/form-data; boundary=\"+b})}\n"],"names":["F","f","e","m","C"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA,IA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CAAC,KAAI;AAAK,YAAM;AAAA,EAAC;AAAA,EACjC,CAAC,SAAQ;AAAC,aAAO,CAAE,EAAA,CAAC,KAAI;AAAK,YAAM;AAAA,EAAC;AAAC,GAdrC,oBADwB;AAkBjB,SAAS,eAAgB,GAAE,IAAEC,MAAE;AACtC,MAAI,IAAE,GAAG,EAAG,IAAG,EAAC,IAAK,QAAQ,OAAO,EAAE,EAAE,MAAM,GAAG,EAAE,SAAS,IAAI,GAAG,GAAE,IAAE,CAAE,GAAC,IAAE,KAAK;AAAA;AACjF,IAAE,QAAQ,CAAC,GAAE,MAAI,OAAO,KAAG,WAC1B,EAAE,KAAK,IAAE,EAAE,CAAC,IAAE;AAAA;AAAA,EAAY,EAAE,QAAQ,WAAA,0BAAA,GAAqB,GAAE,MAAM;AAAA,CAAO,IACxE,EAAE,KAAK,IAAE,EAAE,CAAC,IAAE,gBAAgB,EAAE,EAAE,MAAM,CAAC;AAAA,gBAAuB,EAAE,QAAM;AAAA;AAAA,GAAsC,GAAG,MAAM,CAAC;AACzH,IAAE,KAAK,KAAK,KAAK;AACjB,SAAO,IAAI,EAAE,GAAE,EAAC,MAAK,mCAAiC,EAAC,CAAC;AAAC;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
if (!globalThis.DOMException) {
|
|
3
|
+
try {
|
|
4
|
+
const { MessageChannel } = require("worker_threads"), port = new MessageChannel().port1, ab = new ArrayBuffer();
|
|
5
|
+
port.postMessage(ab, [ab, ab]);
|
|
6
|
+
} catch (err) {
|
|
7
|
+
err.constructor.name === "DOMException" && (globalThis.DOMException = err.constructor);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../node_modules/node-domexception/index.js"],"sourcesContent":["/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */\n\nif (!globalThis.DOMException) {\n try {\n const { MessageChannel } = require('worker_threads'),\n port = new MessageChannel().port1,\n ab = new ArrayBuffer()\n port.postMessage(ab, [ab, ab])\n } catch (err) {\n err.constructor.name === 'DOMException' && (\n globalThis.DOMException = err.constructor\n )\n }\n}\n\nmodule.exports = globalThis.DOMException\n"],"names":[],"mappings":";AAEA,IAAI,CAAC,WAAW,cAAc;AAC5B,MAAI;AACF,UAAM,EAAE,eAAc,IAAK,QAAQ,mBACnC,OAAO,IAAI,eAAc,EAAG,OAC5B,KAAK,IAAI,YAAa;AACtB,SAAK,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC;AAAA,EAC9B,SAAQ,KAAP;AACA,QAAI,YAAY,SAAS,mBACvB,WAAW,eAAe,IAAI;AAAA,EAEjC;AACH;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
if (!globalThis.DOMException) {
|
|
2
|
+
try {
|
|
3
|
+
const { MessageChannel } = require("worker_threads"), port = new MessageChannel().port1, ab = new ArrayBuffer();
|
|
4
|
+
port.postMessage(ab, [ab, ab]);
|
|
5
|
+
} catch (err) {
|
|
6
|
+
err.constructor.name === "DOMException" && (globalThis.DOMException = err.constructor);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../node_modules/node-domexception/index.js"],"sourcesContent":["/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */\n\nif (!globalThis.DOMException) {\n try {\n const { MessageChannel } = require('worker_threads'),\n port = new MessageChannel().port1,\n ab = new ArrayBuffer()\n port.postMessage(ab, [ab, ab])\n } catch (err) {\n err.constructor.name === 'DOMException' && (\n globalThis.DOMException = err.constructor\n )\n }\n}\n\nmodule.exports = globalThis.DOMException\n"],"names":[],"mappings":"AAEA,IAAI,CAAC,WAAW,cAAc;AAC5B,MAAI;AACF,UAAM,EAAE,eAAc,IAAK,QAAQ,mBACnC,OAAO,IAAI,eAAc,EAAG,OAC5B,KAAK,IAAI,YAAa;AACtB,SAAK,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC;AAAA,EAC9B,SAAQ,KAAP;AACA,QAAI,YAAY,SAAS,mBACvB,WAAW,eAAe,IAAI;AAAA,EAEjC;AACH;"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const Stream = require("node:stream");
|
|
4
|
+
const node_util = require("node:util");
|
|
5
|
+
const node_buffer = require("node:buffer");
|
|
6
|
+
const index = require("../../fetch-blob/index.cjs");
|
|
7
|
+
const esm_min = require("../../formdata-polyfill/esm.min.cjs");
|
|
8
|
+
const fetchError = require("./errors/fetch-error.cjs");
|
|
9
|
+
const base = require("./errors/base.cjs");
|
|
10
|
+
const is = require("./utils/is.cjs");
|
|
11
|
+
const pipeline = node_util.promisify(Stream.pipeline);
|
|
12
|
+
const INTERNALS = Symbol("Body internals");
|
|
13
|
+
class Body {
|
|
14
|
+
constructor(body, {
|
|
15
|
+
size = 0
|
|
16
|
+
} = {}) {
|
|
17
|
+
let boundary = null;
|
|
18
|
+
if (body === null) {
|
|
19
|
+
body = null;
|
|
20
|
+
} else if (is.isURLSearchParameters(body)) {
|
|
21
|
+
body = node_buffer.Buffer.from(body.toString());
|
|
22
|
+
} else if (is.isBlob(body))
|
|
23
|
+
;
|
|
24
|
+
else if (node_buffer.Buffer.isBuffer(body))
|
|
25
|
+
;
|
|
26
|
+
else if (node_util.types.isAnyArrayBuffer(body)) {
|
|
27
|
+
body = node_buffer.Buffer.from(body);
|
|
28
|
+
} else if (ArrayBuffer.isView(body)) {
|
|
29
|
+
body = node_buffer.Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
30
|
+
} else if (body instanceof Stream)
|
|
31
|
+
;
|
|
32
|
+
else if (body instanceof esm_min.FormData) {
|
|
33
|
+
body = esm_min.formDataToBlob(body);
|
|
34
|
+
boundary = body.type.split("=")[1];
|
|
35
|
+
} else {
|
|
36
|
+
body = node_buffer.Buffer.from(String(body));
|
|
37
|
+
}
|
|
38
|
+
let stream = body;
|
|
39
|
+
if (node_buffer.Buffer.isBuffer(body)) {
|
|
40
|
+
stream = Stream.Readable.from(body);
|
|
41
|
+
} else if (is.isBlob(body)) {
|
|
42
|
+
stream = Stream.Readable.from(body.stream());
|
|
43
|
+
}
|
|
44
|
+
this[INTERNALS] = {
|
|
45
|
+
body,
|
|
46
|
+
stream,
|
|
47
|
+
boundary,
|
|
48
|
+
disturbed: false,
|
|
49
|
+
error: null
|
|
50
|
+
};
|
|
51
|
+
this.size = size;
|
|
52
|
+
if (body instanceof Stream) {
|
|
53
|
+
body.on("error", (error_) => {
|
|
54
|
+
const error = error_ instanceof base.FetchBaseError ? error_ : new fetchError.FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
|
|
55
|
+
this[INTERNALS].error = error;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
get body() {
|
|
60
|
+
return this[INTERNALS].stream;
|
|
61
|
+
}
|
|
62
|
+
get bodyUsed() {
|
|
63
|
+
return this[INTERNALS].disturbed;
|
|
64
|
+
}
|
|
65
|
+
async arrayBuffer() {
|
|
66
|
+
const { buffer, byteOffset, byteLength } = await consumeBody(this);
|
|
67
|
+
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
68
|
+
}
|
|
69
|
+
async formData() {
|
|
70
|
+
const ct = this.headers.get("content-type");
|
|
71
|
+
if (ct.startsWith("application/x-www-form-urlencoded")) {
|
|
72
|
+
const formData = new esm_min.FormData();
|
|
73
|
+
const parameters = new URLSearchParams(await this.text());
|
|
74
|
+
for (const [name, value] of parameters) {
|
|
75
|
+
formData.append(name, value);
|
|
76
|
+
}
|
|
77
|
+
return formData;
|
|
78
|
+
}
|
|
79
|
+
const { toFormData } = await Promise.resolve().then(() => require("./utils/multipart-parser.cjs"));
|
|
80
|
+
return toFormData(this.body, ct);
|
|
81
|
+
}
|
|
82
|
+
async blob() {
|
|
83
|
+
const ct = this.headers && this.headers.get("content-type") || this[INTERNALS].body && this[INTERNALS].body.type || "";
|
|
84
|
+
const buf = await this.arrayBuffer();
|
|
85
|
+
return new index.default([buf], {
|
|
86
|
+
type: ct
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async json() {
|
|
90
|
+
const text = await this.text();
|
|
91
|
+
return JSON.parse(text);
|
|
92
|
+
}
|
|
93
|
+
async text() {
|
|
94
|
+
const buffer = await consumeBody(this);
|
|
95
|
+
return new TextDecoder().decode(buffer);
|
|
96
|
+
}
|
|
97
|
+
buffer() {
|
|
98
|
+
return consumeBody(this);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
Body.prototype.buffer = node_util.deprecate(Body.prototype.buffer, "Please use 'response.arrayBuffer()' instead of 'response.buffer()'", "node-fetch#buffer");
|
|
102
|
+
Object.defineProperties(Body.prototype, {
|
|
103
|
+
body: { enumerable: true },
|
|
104
|
+
bodyUsed: { enumerable: true },
|
|
105
|
+
arrayBuffer: { enumerable: true },
|
|
106
|
+
blob: { enumerable: true },
|
|
107
|
+
json: { enumerable: true },
|
|
108
|
+
text: { enumerable: true },
|
|
109
|
+
data: { get: node_util.deprecate(
|
|
110
|
+
() => {
|
|
111
|
+
},
|
|
112
|
+
"data doesn't exist, use json(), text(), arrayBuffer(), or body instead",
|
|
113
|
+
"https://github.com/node-fetch/node-fetch/issues/1000 (response)"
|
|
114
|
+
) }
|
|
115
|
+
});
|
|
116
|
+
async function consumeBody(data) {
|
|
117
|
+
if (data[INTERNALS].disturbed) {
|
|
118
|
+
throw new TypeError(`body used already for: ${data.url}`);
|
|
119
|
+
}
|
|
120
|
+
data[INTERNALS].disturbed = true;
|
|
121
|
+
if (data[INTERNALS].error) {
|
|
122
|
+
throw data[INTERNALS].error;
|
|
123
|
+
}
|
|
124
|
+
const { body } = data;
|
|
125
|
+
if (body === null) {
|
|
126
|
+
return node_buffer.Buffer.alloc(0);
|
|
127
|
+
}
|
|
128
|
+
if (!(body instanceof Stream)) {
|
|
129
|
+
return node_buffer.Buffer.alloc(0);
|
|
130
|
+
}
|
|
131
|
+
const accum = [];
|
|
132
|
+
let accumBytes = 0;
|
|
133
|
+
try {
|
|
134
|
+
for await (const chunk of body) {
|
|
135
|
+
if (data.size > 0 && accumBytes + chunk.length > data.size) {
|
|
136
|
+
const error = new fetchError.FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
|
|
137
|
+
body.destroy(error);
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
accumBytes += chunk.length;
|
|
141
|
+
accum.push(chunk);
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
const error_ = error instanceof base.FetchBaseError ? error : new fetchError.FetchError(`Invalid response body while trying to fetch ${data.url}: ${error.message}`, "system", error);
|
|
145
|
+
throw error_;
|
|
146
|
+
}
|
|
147
|
+
if (body.readableEnded === true || body._readableState.ended === true) {
|
|
148
|
+
try {
|
|
149
|
+
if (accum.every((c) => typeof c === "string")) {
|
|
150
|
+
return node_buffer.Buffer.from(accum.join(""));
|
|
151
|
+
}
|
|
152
|
+
return node_buffer.Buffer.concat(accum, accumBytes);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
throw new fetchError.FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, "system", error);
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
throw new fetchError.FetchError(`Premature close of server response while trying to fetch ${data.url}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const clone = (instance, highWaterMark) => {
|
|
161
|
+
let p1;
|
|
162
|
+
let p2;
|
|
163
|
+
let { body } = instance[INTERNALS];
|
|
164
|
+
if (instance.bodyUsed) {
|
|
165
|
+
throw new Error("cannot clone body after it is used");
|
|
166
|
+
}
|
|
167
|
+
if (body instanceof Stream && typeof body.getBoundary !== "function") {
|
|
168
|
+
p1 = new Stream.PassThrough({ highWaterMark });
|
|
169
|
+
p2 = new Stream.PassThrough({ highWaterMark });
|
|
170
|
+
body.pipe(p1);
|
|
171
|
+
body.pipe(p2);
|
|
172
|
+
instance[INTERNALS].stream = p1;
|
|
173
|
+
body = p2;
|
|
174
|
+
}
|
|
175
|
+
return body;
|
|
176
|
+
};
|
|
177
|
+
const getNonSpecFormDataBoundary = node_util.deprecate(
|
|
178
|
+
(body) => body.getBoundary(),
|
|
179
|
+
"form-data doesn't follow the spec and requires special treatment. Use alternative package",
|
|
180
|
+
"https://github.com/node-fetch/node-fetch/issues/1167"
|
|
181
|
+
);
|
|
182
|
+
const extractContentType = (body, request) => {
|
|
183
|
+
if (body === null) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
if (typeof body === "string") {
|
|
187
|
+
return "text/plain;charset=UTF-8";
|
|
188
|
+
}
|
|
189
|
+
if (is.isURLSearchParameters(body)) {
|
|
190
|
+
return "application/x-www-form-urlencoded;charset=UTF-8";
|
|
191
|
+
}
|
|
192
|
+
if (is.isBlob(body)) {
|
|
193
|
+
return body.type || null;
|
|
194
|
+
}
|
|
195
|
+
if (node_buffer.Buffer.isBuffer(body) || node_util.types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
if (body instanceof esm_min.FormData) {
|
|
199
|
+
return `multipart/form-data; boundary=${request[INTERNALS].boundary}`;
|
|
200
|
+
}
|
|
201
|
+
if (body && typeof body.getBoundary === "function") {
|
|
202
|
+
return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
|
|
203
|
+
}
|
|
204
|
+
if (body instanceof Stream) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
return "text/plain;charset=UTF-8";
|
|
208
|
+
};
|
|
209
|
+
const getTotalBytes = (request) => {
|
|
210
|
+
const { body } = request[INTERNALS];
|
|
211
|
+
if (body === null) {
|
|
212
|
+
return 0;
|
|
213
|
+
}
|
|
214
|
+
if (is.isBlob(body)) {
|
|
215
|
+
return body.size;
|
|
216
|
+
}
|
|
217
|
+
if (node_buffer.Buffer.isBuffer(body)) {
|
|
218
|
+
return body.length;
|
|
219
|
+
}
|
|
220
|
+
if (body && typeof body.getLengthSync === "function") {
|
|
221
|
+
return body.hasKnownLength && body.hasKnownLength() ? body.getLengthSync() : null;
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
};
|
|
225
|
+
const writeToStream = async (dest, { body }) => {
|
|
226
|
+
if (body === null) {
|
|
227
|
+
dest.end();
|
|
228
|
+
} else {
|
|
229
|
+
await pipeline(body, dest);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
exports.clone = clone;
|
|
233
|
+
exports.default = Body;
|
|
234
|
+
exports.extractContentType = extractContentType;
|
|
235
|
+
exports.getTotalBytes = getTotalBytes;
|
|
236
|
+
exports.writeToStream = writeToStream;
|
|
237
|
+
//# sourceMappingURL=body.cjs.map
|