@rindo/core 3.2.3 → 3.2.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/cli/index.cjs +11 -16
- package/cli/index.js +11 -16
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/rindo.js +2765 -2560
- package/compiler/rindo.min.js +2 -2
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/dev-server/ws.js +1 -1
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +1 -1
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +89 -38
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/index.js +34 -28
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/shadow-css.js +1 -2
- package/internal/package.json +1 -1
- package/internal/rindo-private.d.ts +14 -3
- package/internal/rindo-public-compiler.d.ts +11 -0
- package/internal/rindo-public-runtime.d.ts +1 -0
- package/internal/testing/index.js +19 -13
- package/internal/testing/package.json +1 -1
- package/internal/testing/shadow-css.js +1 -2
- package/mock-doc/index.cjs +2 -2
- package/mock-doc/index.js +2 -2
- package/mock-doc/package.json +1 -1
- package/package.json +7 -7
- package/screenshot/package.json +1 -1
- package/sys/node/autoprefixer.js +2 -2
- package/sys/node/glob.js +1 -1
- package/sys/node/graceful-fs.js +1 -1
- package/sys/node/index.js +290 -283
- package/sys/node/node-fetch.js +1 -4
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +46 -24
- package/testing/jest/jest-setup-test-framework.d.ts +8 -0
- package/testing/package.json +1 -1
- package/testing/reset-build-conditionals.d.ts +10 -0
- package/testing/spec-page.d.ts +5 -0
- package/sys/node/713.node-fetch.js +0 -452
package/sys/node/package.json
CHANGED
package/sys/node/worker.js
CHANGED
package/testing/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo Testing v3.2.
|
|
2
|
+
Rindo Testing v3.2.4 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
function _lazyRequire(e) {
|
|
5
5
|
return new Proxy({}, {
|
|
@@ -376,6 +376,12 @@ function resetBuildConditionals(e) {
|
|
|
376
376
|
e.scopedSlotTextContentFix = !1, e.slotChildNodesFix = !1;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
function removeDomNodes(e) {
|
|
380
|
+
var t, r;
|
|
381
|
+
null != e && ((null === (t = e.childNodes) || void 0 === t ? void 0 : t.length) || e.remove(),
|
|
382
|
+
null === (r = e.childNodes) || void 0 === r || r.forEach(removeDomNodes));
|
|
383
|
+
}
|
|
384
|
+
|
|
379
385
|
function assertPath(e) {
|
|
380
386
|
if ("string" != typeof e) throw new TypeError("Path must be a string. Received " + JSON.stringify(e));
|
|
381
387
|
}
|
|
@@ -946,7 +952,7 @@ function getAppUrl(e, t, r) {
|
|
|
946
952
|
|
|
947
953
|
var debug_1, constants$2, re_1, parseOptions_1, identifiers, semver, major_1, posix, pathBrowserify, caller, pathParse, parse, getNodeModulesDirs, nodeModulesPaths, normalizeOptions, slice, toStr, implementation, functionBind, src, isCoreModule, realpathFS$1, defaultIsFile$1, defaultIsDir$1, defaultRealpath, maybeRealpath, defaultReadPackage, getPackageCandidates$1, async, current, core, mod, core_1, isCore, realpathFS, defaultIsFile, defaultIsDir, defaultRealpathSync, maybeRealpathSync, defaultReadPackageSync, getPackageCandidates, sync, resolve;
|
|
948
954
|
|
|
949
|
-
const rindo_js = require("../compiler/rindo.js"), appData = _lazyRequire("@rindo/core/internal/app-data"), testing = _lazyRequire("@rindo/core/internal/testing"), index_cjs = _lazyRequire("../mock-doc/index.cjs"), path$2 = require("path"), crypto$3 = require("crypto"), os$2 = require("os"), process$3 = require("process"), fs$2 = require("fs"), index_js = _lazyRequire("../dev-server/index.js"), child_process$2 = require("child_process"), path__default = _interopDefaultLegacy(path$2), os__namespace = _interopNamespace(os$2), process__namespace = _interopNamespace(process$3), fs__default = _interopDefaultLegacy(fs$2), debug = ("object" == typeof process && process.env,
|
|
955
|
+
const require$$3 = require("util"), rindo_js = require("../compiler/rindo.js"), appData = _lazyRequire("@rindo/core/internal/app-data"), testing = _lazyRequire("@rindo/core/internal/testing"), index_cjs = _lazyRequire("../mock-doc/index.cjs"), path$2 = require("path"), crypto$3 = require("crypto"), os$2 = require("os"), process$3 = require("process"), fs$2 = require("fs"), index_js = _lazyRequire("../dev-server/index.js"), child_process$2 = require("child_process"), require$$3__default = _interopDefaultLegacy(require$$3), path__default = _interopDefaultLegacy(path$2), os__namespace = _interopNamespace(os$2), process__namespace = _interopNamespace(process$3), fs__default = _interopDefaultLegacy(fs$2), debug = ("object" == typeof process && process.env,
|
|
950
956
|
() => {});
|
|
951
957
|
|
|
952
958
|
debug_1 = debug;
|
|
@@ -954,10 +960,13 @@ debug_1 = debug;
|
|
|
954
960
|
const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
955
961
|
|
|
956
962
|
constants$2 = {
|
|
957
|
-
SEMVER_SPEC_VERSION: "2.0.0",
|
|
958
963
|
MAX_LENGTH: 256,
|
|
964
|
+
MAX_SAFE_COMPONENT_LENGTH: 16,
|
|
959
965
|
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
|
|
960
|
-
|
|
966
|
+
RELEASE_TYPES: [ "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease" ],
|
|
967
|
+
SEMVER_SPEC_VERSION: "2.0.0",
|
|
968
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
969
|
+
FLAG_LOOSE: 2
|
|
961
970
|
}, re_1 = createCommonjsModule((function(e, t) {
|
|
962
971
|
const {MAX_SAFE_COMPONENT_LENGTH: r} = constants$2, s = (t = e.exports = {}).re = [], n = t.src = [], o = t.t = {};
|
|
963
972
|
let i = 0;
|
|
@@ -991,11 +1000,11 @@ constants$2 = {
|
|
|
991
1000
|
a("STAR", "(<|>)?=?\\s*\\*"), a("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"), a("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
992
1001
|
}));
|
|
993
1002
|
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
parseOptions_1 = e => e ? "object" != typeof e ? {
|
|
1003
|
+
const looseOption = Object.freeze({
|
|
997
1004
|
loose: !0
|
|
998
|
-
}
|
|
1005
|
+
}), emptyOpts = Object.freeze({});
|
|
1006
|
+
|
|
1007
|
+
parseOptions_1 = e => e ? "object" != typeof e ? looseOption : e : emptyOpts;
|
|
999
1008
|
|
|
1000
1009
|
const numeric = /^[0-9]+$/, compareIdentifiers$1 = (e, t) => {
|
|
1001
1010
|
const r = numeric.test(e), s = numeric.test(t);
|
|
@@ -1014,7 +1023,7 @@ class SemVer {
|
|
|
1014
1023
|
if (r = parseOptions_1(r), e instanceof SemVer) {
|
|
1015
1024
|
if (e.loose === !!r.loose && e.includePrerelease === !!r.includePrerelease) return e;
|
|
1016
1025
|
e = e.version;
|
|
1017
|
-
} else if ("string" != typeof e) throw new TypeError(`Invalid Version: ${e}`);
|
|
1026
|
+
} else if ("string" != typeof e) throw new TypeError(`Invalid Version: ${require$$3__default.default.inspect(e)}`);
|
|
1018
1027
|
if (e.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
1019
1028
|
debug_1("SemVer", e, r), this.options = r, this.loose = !!r.loose, this.includePrerelease = !!r.includePrerelease;
|
|
1020
1029
|
const s = e.trim().match(r.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
@@ -1071,22 +1080,22 @@ class SemVer {
|
|
|
1071
1080
|
if (r !== s) return compareIdentifiers(r, s);
|
|
1072
1081
|
} while (++t);
|
|
1073
1082
|
}
|
|
1074
|
-
inc(e, t) {
|
|
1083
|
+
inc(e, t, r) {
|
|
1075
1084
|
switch (e) {
|
|
1076
1085
|
case "premajor":
|
|
1077
|
-
this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", t);
|
|
1086
|
+
this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", t, r);
|
|
1078
1087
|
break;
|
|
1079
1088
|
|
|
1080
1089
|
case "preminor":
|
|
1081
|
-
this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", t);
|
|
1090
|
+
this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", t, r);
|
|
1082
1091
|
break;
|
|
1083
1092
|
|
|
1084
1093
|
case "prepatch":
|
|
1085
|
-
this.prerelease.length = 0, this.inc("patch", t), this.inc("pre", t);
|
|
1094
|
+
this.prerelease.length = 0, this.inc("patch", t, r), this.inc("pre", t, r);
|
|
1086
1095
|
break;
|
|
1087
1096
|
|
|
1088
1097
|
case "prerelease":
|
|
1089
|
-
0 === this.prerelease.length && this.inc("patch", t), this.inc("pre", t);
|
|
1098
|
+
0 === this.prerelease.length && this.inc("patch", t, r), this.inc("pre", t, r);
|
|
1090
1099
|
break;
|
|
1091
1100
|
|
|
1092
1101
|
case "major":
|
|
@@ -1104,14 +1113,24 @@ class SemVer {
|
|
|
1104
1113
|
break;
|
|
1105
1114
|
|
|
1106
1115
|
case "pre":
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1116
|
+
{
|
|
1117
|
+
const e = Number(r) ? 1 : 0;
|
|
1118
|
+
if (!t && !1 === r) throw new Error("invalid increment argument: identifier is empty");
|
|
1119
|
+
if (0 === this.prerelease.length) this.prerelease = [ e ]; else {
|
|
1120
|
+
let s = this.prerelease.length;
|
|
1121
|
+
for (;--s >= 0; ) "number" == typeof this.prerelease[s] && (this.prerelease[s]++,
|
|
1122
|
+
s = -2);
|
|
1123
|
+
if (-1 === s) {
|
|
1124
|
+
if (t === this.prerelease.join(".") && !1 === r) throw new Error("invalid increment argument: identifier already exists");
|
|
1125
|
+
this.prerelease.push(e);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
if (t) {
|
|
1129
|
+
let s = [ t, e ];
|
|
1130
|
+
!1 === r && (s = [ t ]), 0 === compareIdentifiers(this.prerelease[0], t) ? isNaN(this.prerelease[1]) && (this.prerelease = s) : this.prerelease = s;
|
|
1131
|
+
}
|
|
1132
|
+
break;
|
|
1112
1133
|
}
|
|
1113
|
-
t && (0 === compareIdentifiers(this.prerelease[0], t) ? isNaN(this.prerelease[1]) && (this.prerelease = [ t, 0 ]) : this.prerelease = [ t, 0 ]);
|
|
1114
|
-
break;
|
|
1115
1134
|
|
|
1116
1135
|
default:
|
|
1117
1136
|
throw new Error(`invalid increment argument: ${e}`);
|
|
@@ -1211,7 +1230,7 @@ const formatComponentRuntimeMembers = (e, t = !0) => ({
|
|
|
1211
1230
|
}
|
|
1212
1231
|
const r = e.indexOf("://");
|
|
1213
1232
|
if (-1 !== r) {
|
|
1214
|
-
const t = r +
|
|
1233
|
+
const t = r + 3, s = e.indexOf("/", t);
|
|
1215
1234
|
if (-1 !== s) {
|
|
1216
1235
|
const n = e.slice(0, r), o = e.slice(t, s);
|
|
1217
1236
|
if ("file" === n && ("" === o || "localhost" === o) && isVolumeCharacter(e.charCodeAt(s + 1))) {
|
|
@@ -3155,7 +3174,7 @@ const COMMON_DIR_MODULE_EXTS = [ ".tsx", ".ts", ".mjs", ".js", ".jsx", ".json",
|
|
|
3155
3174
|
d("/");
|
|
3156
3175
|
const D = {
|
|
3157
3176
|
name: "in-memory",
|
|
3158
|
-
version: "3.2.
|
|
3177
|
+
version: "3.2.4",
|
|
3159
3178
|
events: a,
|
|
3160
3179
|
access: async e => u(e),
|
|
3161
3180
|
accessSync: u,
|
|
@@ -3963,7 +3982,10 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
|
|
|
3963
3982
|
testing.resetPlatform(), testing.setErrorHandler(void 0), resetBuildConditionals(appData.BUILD),
|
|
3964
3983
|
testing.modeResolutionChain.length = 0;
|
|
3965
3984
|
})), afterEach((async () => {
|
|
3966
|
-
|
|
3985
|
+
var e, t, r, s, n, o;
|
|
3986
|
+
global.__CLOSE_OPEN_PAGES__ && await global.__CLOSE_OPEN_PAGES__(), testing.stopAutoApplyChanges();
|
|
3987
|
+
const i = null === (n = null === (s = null === (r = null === (t = null === (e = global.window) || void 0 === e ? void 0 : e.document) || void 0 === t ? void 0 : t.childNodes) || void 0 === r ? void 0 : r[1]) || void 0 === s ? void 0 : s.childNodes) || void 0 === n ? void 0 : n.find((e => "BODY" === e.nodeName));
|
|
3988
|
+
null === (o = null == i ? void 0 : i.childNodes) || void 0 === o || o.forEach(removeDomNodes),
|
|
3967
3989
|
index_cjs.teardownGlobal(global), global.Context = {}, global.resourcesUrl = "/build";
|
|
3968
3990
|
}));
|
|
3969
3991
|
const t = jasmine.getEnv();
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
import { MockNode } from '@rindo/core/mock-doc';
|
|
1
2
|
export declare function jestSetupTestFramework(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Recursively removes all child nodes of a passed node starting with the
|
|
5
|
+
* furthest descendant and then moving back up the DOM tree.
|
|
6
|
+
*
|
|
7
|
+
* @param node The mocked DOM node that will be removed from the DOM
|
|
8
|
+
*/
|
|
9
|
+
export declare function removeDomNodes(node: MockNode): void;
|
package/testing/package.json
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type * as d from '@rindo/core/internal';
|
|
2
|
+
/**
|
|
3
|
+
* Reset build conditionals used for testing to a known "good state".
|
|
4
|
+
*
|
|
5
|
+
* This function does not return a value, but rather mutates its argument in place.
|
|
6
|
+
* Certain values are set to `true` or `false` for testing purpose (see this function's implementation for the full
|
|
7
|
+
* list). Build conditional options _not_ in that list that are set to `true` when this function is invoked will remain
|
|
8
|
+
* set to `true`.
|
|
9
|
+
*
|
|
10
|
+
* @param b the build conditionals to reset.
|
|
11
|
+
*/
|
|
2
12
|
export declare function resetBuildConditionals(b: d.BuildConditionals): void;
|
package/testing/spec-page.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { NewSpecPageOptions, SpecPage } from '@rindo/core/internal';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new spec page for unit testing
|
|
4
|
+
* @param opts the options to apply to the spec page that influence its configuration and operation
|
|
5
|
+
* @returns the created spec page
|
|
6
|
+
*/
|
|
2
7
|
export declare function newSpecPage(opts: NewSpecPageOptions): Promise<SpecPage>;
|
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.id = 713;
|
|
3
|
-
exports.ids = [713];
|
|
4
|
-
exports.modules = {
|
|
5
|
-
|
|
6
|
-
/***/ 713:
|
|
7
|
-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
8
|
-
|
|
9
|
-
__webpack_require__.r(__webpack_exports__);
|
|
10
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11
|
-
/* harmony export */ "toFormData": () => (/* binding */ toFormData)
|
|
12
|
-
/* harmony export */ });
|
|
13
|
-
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(749);
|
|
14
|
-
/* harmony import */ var formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(951);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let s = 0;
|
|
19
|
-
const S = {
|
|
20
|
-
START_BOUNDARY: s++,
|
|
21
|
-
HEADER_FIELD_START: s++,
|
|
22
|
-
HEADER_FIELD: s++,
|
|
23
|
-
HEADER_VALUE_START: s++,
|
|
24
|
-
HEADER_VALUE: s++,
|
|
25
|
-
HEADER_VALUE_ALMOST_DONE: s++,
|
|
26
|
-
HEADERS_ALMOST_DONE: s++,
|
|
27
|
-
PART_DATA_START: s++,
|
|
28
|
-
PART_DATA: s++,
|
|
29
|
-
END: s++
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
let f = 1;
|
|
33
|
-
const F = {
|
|
34
|
-
PART_BOUNDARY: f,
|
|
35
|
-
LAST_BOUNDARY: f *= 2
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const LF = 10;
|
|
39
|
-
const CR = 13;
|
|
40
|
-
const SPACE = 32;
|
|
41
|
-
const HYPHEN = 45;
|
|
42
|
-
const COLON = 58;
|
|
43
|
-
const A = 97;
|
|
44
|
-
const Z = 122;
|
|
45
|
-
|
|
46
|
-
const lower = c => c | 0x20;
|
|
47
|
-
|
|
48
|
-
const noop = () => {};
|
|
49
|
-
|
|
50
|
-
class MultipartParser {
|
|
51
|
-
/**
|
|
52
|
-
* @param {string} boundary
|
|
53
|
-
*/
|
|
54
|
-
constructor(boundary) {
|
|
55
|
-
this.index = 0;
|
|
56
|
-
this.flags = 0;
|
|
57
|
-
|
|
58
|
-
this.onHeaderEnd = noop;
|
|
59
|
-
this.onHeaderField = noop;
|
|
60
|
-
this.onHeadersEnd = noop;
|
|
61
|
-
this.onHeaderValue = noop;
|
|
62
|
-
this.onPartBegin = noop;
|
|
63
|
-
this.onPartData = noop;
|
|
64
|
-
this.onPartEnd = noop;
|
|
65
|
-
|
|
66
|
-
this.boundaryChars = {};
|
|
67
|
-
|
|
68
|
-
boundary = '\r\n--' + boundary;
|
|
69
|
-
const ui8a = new Uint8Array(boundary.length);
|
|
70
|
-
for (let i = 0; i < boundary.length; i++) {
|
|
71
|
-
ui8a[i] = boundary.charCodeAt(i);
|
|
72
|
-
this.boundaryChars[ui8a[i]] = true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.boundary = ui8a;
|
|
76
|
-
this.lookbehind = new Uint8Array(this.boundary.length + 8);
|
|
77
|
-
this.state = S.START_BOUNDARY;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @param {Uint8Array} data
|
|
82
|
-
*/
|
|
83
|
-
write(data) {
|
|
84
|
-
let i = 0;
|
|
85
|
-
const length_ = data.length;
|
|
86
|
-
let previousIndex = this.index;
|
|
87
|
-
let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
|
|
88
|
-
const boundaryLength = this.boundary.length;
|
|
89
|
-
const boundaryEnd = boundaryLength - 1;
|
|
90
|
-
const bufferLength = data.length;
|
|
91
|
-
let c;
|
|
92
|
-
let cl;
|
|
93
|
-
|
|
94
|
-
const mark = name => {
|
|
95
|
-
this[name + 'Mark'] = i;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const clear = name => {
|
|
99
|
-
delete this[name + 'Mark'];
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const callback = (callbackSymbol, start, end, ui8a) => {
|
|
103
|
-
if (start === undefined || start !== end) {
|
|
104
|
-
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const dataCallback = (name, clear) => {
|
|
109
|
-
const markSymbol = name + 'Mark';
|
|
110
|
-
if (!(markSymbol in this)) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (clear) {
|
|
115
|
-
callback(name, this[markSymbol], i, data);
|
|
116
|
-
delete this[markSymbol];
|
|
117
|
-
} else {
|
|
118
|
-
callback(name, this[markSymbol], data.length, data);
|
|
119
|
-
this[markSymbol] = 0;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
for (i = 0; i < length_; i++) {
|
|
124
|
-
c = data[i];
|
|
125
|
-
|
|
126
|
-
switch (state) {
|
|
127
|
-
case S.START_BOUNDARY:
|
|
128
|
-
if (index === boundary.length - 2) {
|
|
129
|
-
if (c === HYPHEN) {
|
|
130
|
-
flags |= F.LAST_BOUNDARY;
|
|
131
|
-
} else if (c !== CR) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
index++;
|
|
136
|
-
break;
|
|
137
|
-
} else if (index - 1 === boundary.length - 2) {
|
|
138
|
-
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
|
139
|
-
state = S.END;
|
|
140
|
-
flags = 0;
|
|
141
|
-
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
|
142
|
-
index = 0;
|
|
143
|
-
callback('onPartBegin');
|
|
144
|
-
state = S.HEADER_FIELD_START;
|
|
145
|
-
} else {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (c !== boundary[index + 2]) {
|
|
153
|
-
index = -2;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (c === boundary[index + 2]) {
|
|
157
|
-
index++;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
break;
|
|
161
|
-
case S.HEADER_FIELD_START:
|
|
162
|
-
state = S.HEADER_FIELD;
|
|
163
|
-
mark('onHeaderField');
|
|
164
|
-
index = 0;
|
|
165
|
-
// falls through
|
|
166
|
-
case S.HEADER_FIELD:
|
|
167
|
-
if (c === CR) {
|
|
168
|
-
clear('onHeaderField');
|
|
169
|
-
state = S.HEADERS_ALMOST_DONE;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
index++;
|
|
174
|
-
if (c === HYPHEN) {
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (c === COLON) {
|
|
179
|
-
if (index === 1) {
|
|
180
|
-
// empty header field
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
dataCallback('onHeaderField', true);
|
|
185
|
-
state = S.HEADER_VALUE_START;
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
cl = lower(c);
|
|
190
|
-
if (cl < A || cl > Z) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
break;
|
|
195
|
-
case S.HEADER_VALUE_START:
|
|
196
|
-
if (c === SPACE) {
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
mark('onHeaderValue');
|
|
201
|
-
state = S.HEADER_VALUE;
|
|
202
|
-
// falls through
|
|
203
|
-
case S.HEADER_VALUE:
|
|
204
|
-
if (c === CR) {
|
|
205
|
-
dataCallback('onHeaderValue', true);
|
|
206
|
-
callback('onHeaderEnd');
|
|
207
|
-
state = S.HEADER_VALUE_ALMOST_DONE;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
break;
|
|
211
|
-
case S.HEADER_VALUE_ALMOST_DONE:
|
|
212
|
-
if (c !== LF) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
state = S.HEADER_FIELD_START;
|
|
217
|
-
break;
|
|
218
|
-
case S.HEADERS_ALMOST_DONE:
|
|
219
|
-
if (c !== LF) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
callback('onHeadersEnd');
|
|
224
|
-
state = S.PART_DATA_START;
|
|
225
|
-
break;
|
|
226
|
-
case S.PART_DATA_START:
|
|
227
|
-
state = S.PART_DATA;
|
|
228
|
-
mark('onPartData');
|
|
229
|
-
// falls through
|
|
230
|
-
case S.PART_DATA:
|
|
231
|
-
previousIndex = index;
|
|
232
|
-
|
|
233
|
-
if (index === 0) {
|
|
234
|
-
// boyer-moore derrived algorithm to safely skip non-boundary data
|
|
235
|
-
i += boundaryEnd;
|
|
236
|
-
while (i < bufferLength && !(data[i] in boundaryChars)) {
|
|
237
|
-
i += boundaryLength;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
i -= boundaryEnd;
|
|
241
|
-
c = data[i];
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (index < boundary.length) {
|
|
245
|
-
if (boundary[index] === c) {
|
|
246
|
-
if (index === 0) {
|
|
247
|
-
dataCallback('onPartData', true);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
index++;
|
|
251
|
-
} else {
|
|
252
|
-
index = 0;
|
|
253
|
-
}
|
|
254
|
-
} else if (index === boundary.length) {
|
|
255
|
-
index++;
|
|
256
|
-
if (c === CR) {
|
|
257
|
-
// CR = part boundary
|
|
258
|
-
flags |= F.PART_BOUNDARY;
|
|
259
|
-
} else if (c === HYPHEN) {
|
|
260
|
-
// HYPHEN = end boundary
|
|
261
|
-
flags |= F.LAST_BOUNDARY;
|
|
262
|
-
} else {
|
|
263
|
-
index = 0;
|
|
264
|
-
}
|
|
265
|
-
} else if (index - 1 === boundary.length) {
|
|
266
|
-
if (flags & F.PART_BOUNDARY) {
|
|
267
|
-
index = 0;
|
|
268
|
-
if (c === LF) {
|
|
269
|
-
// unset the PART_BOUNDARY flag
|
|
270
|
-
flags &= ~F.PART_BOUNDARY;
|
|
271
|
-
callback('onPartEnd');
|
|
272
|
-
callback('onPartBegin');
|
|
273
|
-
state = S.HEADER_FIELD_START;
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
} else if (flags & F.LAST_BOUNDARY) {
|
|
277
|
-
if (c === HYPHEN) {
|
|
278
|
-
callback('onPartEnd');
|
|
279
|
-
state = S.END;
|
|
280
|
-
flags = 0;
|
|
281
|
-
} else {
|
|
282
|
-
index = 0;
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
index = 0;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (index > 0) {
|
|
290
|
-
// when matching a possible boundary, keep a lookbehind reference
|
|
291
|
-
// in case it turns out to be a false lead
|
|
292
|
-
lookbehind[index - 1] = c;
|
|
293
|
-
} else if (previousIndex > 0) {
|
|
294
|
-
// if our boundary turned out to be rubbish, the captured lookbehind
|
|
295
|
-
// belongs to partData
|
|
296
|
-
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
|
297
|
-
callback('onPartData', 0, previousIndex, _lookbehind);
|
|
298
|
-
previousIndex = 0;
|
|
299
|
-
mark('onPartData');
|
|
300
|
-
|
|
301
|
-
// reconsider the current character even so it interrupted the sequence
|
|
302
|
-
// it could be the beginning of a new sequence
|
|
303
|
-
i--;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
break;
|
|
307
|
-
case S.END:
|
|
308
|
-
break;
|
|
309
|
-
default:
|
|
310
|
-
throw new Error(`Unexpected state entered: ${state}`);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
dataCallback('onHeaderField');
|
|
315
|
-
dataCallback('onHeaderValue');
|
|
316
|
-
dataCallback('onPartData');
|
|
317
|
-
|
|
318
|
-
// Update properties for the next call
|
|
319
|
-
this.index = index;
|
|
320
|
-
this.state = state;
|
|
321
|
-
this.flags = flags;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
end() {
|
|
325
|
-
if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
|
|
326
|
-
(this.state === S.PART_DATA && this.index === this.boundary.length)) {
|
|
327
|
-
this.onPartEnd();
|
|
328
|
-
} else if (this.state !== S.END) {
|
|
329
|
-
throw new Error('MultipartParser.end(): stream ended unexpectedly');
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function _fileName(headerValue) {
|
|
335
|
-
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
|
336
|
-
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
|
337
|
-
if (!m) {
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
const match = m[2] || m[3] || '';
|
|
342
|
-
let filename = match.slice(match.lastIndexOf('\\') + 1);
|
|
343
|
-
filename = filename.replace(/%22/g, '"');
|
|
344
|
-
filename = filename.replace(/&#(\d{4});/g, (m, code) => {
|
|
345
|
-
return String.fromCharCode(code);
|
|
346
|
-
});
|
|
347
|
-
return filename;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
async function toFormData(Body, ct) {
|
|
351
|
-
if (!/multipart/i.test(ct)) {
|
|
352
|
-
throw new TypeError('Failed to fetch');
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
|
356
|
-
|
|
357
|
-
if (!m) {
|
|
358
|
-
throw new TypeError('no or bad content-type header, no multipart boundary');
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const parser = new MultipartParser(m[1] || m[2]);
|
|
362
|
-
|
|
363
|
-
let headerField;
|
|
364
|
-
let headerValue;
|
|
365
|
-
let entryValue;
|
|
366
|
-
let entryName;
|
|
367
|
-
let contentType;
|
|
368
|
-
let filename;
|
|
369
|
-
const entryChunks = [];
|
|
370
|
-
const formData = new formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__/* .FormData */ .Ct();
|
|
371
|
-
|
|
372
|
-
const onPartData = ui8a => {
|
|
373
|
-
entryValue += decoder.decode(ui8a, {stream: true});
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const appendToFile = ui8a => {
|
|
377
|
-
entryChunks.push(ui8a);
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
const appendFileToFormData = () => {
|
|
381
|
-
const file = new fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__/* .File */ .$B(entryChunks, filename, {type: contentType});
|
|
382
|
-
formData.append(entryName, file);
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
const appendEntryToFormData = () => {
|
|
386
|
-
formData.append(entryName, entryValue);
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
const decoder = new TextDecoder('utf-8');
|
|
390
|
-
decoder.decode();
|
|
391
|
-
|
|
392
|
-
parser.onPartBegin = function () {
|
|
393
|
-
parser.onPartData = onPartData;
|
|
394
|
-
parser.onPartEnd = appendEntryToFormData;
|
|
395
|
-
|
|
396
|
-
headerField = '';
|
|
397
|
-
headerValue = '';
|
|
398
|
-
entryValue = '';
|
|
399
|
-
entryName = '';
|
|
400
|
-
contentType = '';
|
|
401
|
-
filename = null;
|
|
402
|
-
entryChunks.length = 0;
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
parser.onHeaderField = function (ui8a) {
|
|
406
|
-
headerField += decoder.decode(ui8a, {stream: true});
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
parser.onHeaderValue = function (ui8a) {
|
|
410
|
-
headerValue += decoder.decode(ui8a, {stream: true});
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
parser.onHeaderEnd = function () {
|
|
414
|
-
headerValue += decoder.decode();
|
|
415
|
-
headerField = headerField.toLowerCase();
|
|
416
|
-
|
|
417
|
-
if (headerField === 'content-disposition') {
|
|
418
|
-
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
|
419
|
-
const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
|
420
|
-
|
|
421
|
-
if (m) {
|
|
422
|
-
entryName = m[2] || m[3] || '';
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
filename = _fileName(headerValue);
|
|
426
|
-
|
|
427
|
-
if (filename) {
|
|
428
|
-
parser.onPartData = appendToFile;
|
|
429
|
-
parser.onPartEnd = appendFileToFormData;
|
|
430
|
-
}
|
|
431
|
-
} else if (headerField === 'content-type') {
|
|
432
|
-
contentType = headerValue;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
headerValue = '';
|
|
436
|
-
headerField = '';
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
for await (const chunk of Body) {
|
|
440
|
-
parser.write(chunk);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
parser.end();
|
|
444
|
-
|
|
445
|
-
return formData;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
/***/ })
|
|
450
|
-
|
|
451
|
-
};
|
|
452
|
-
;
|