@rindo/core 1.17.4 → 2.5.2
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/LICENSE.md +27 -27
- package/bin/cli.ts +20 -0
- package/bin/rindo +51 -56
- package/cli/index.cjs +1263 -0
- package/cli/index.d.ts +1 -1
- package/cli/index.js +1232 -495
- package/cli/package.json +9 -4
- package/compiler/lib.d.ts +24 -0
- package/compiler/lib.dom.d.ts +20230 -0
- package/compiler/lib.dom.iterable.d.ts +351 -0
- package/compiler/lib.es2015.collection.d.ts +89 -0
- package/compiler/lib.es2015.core.d.ts +517 -0
- package/compiler/lib.es2015.d.ts +30 -0
- package/compiler/lib.es2015.generator.d.ts +79 -0
- package/compiler/lib.es2015.iterable.d.ts +505 -0
- package/compiler/lib.es2015.promise.d.ts +150 -0
- package/compiler/lib.es2015.proxy.d.ts +41 -0
- package/compiler/lib.es2015.reflect.d.ts +123 -0
- package/compiler/lib.es2015.symbol.d.ts +48 -0
- package/compiler/lib.es2015.symbol.wellknown.d.ts +324 -0
- package/compiler/lib.es2016.array.include.d.ts +118 -0
- package/compiler/lib.es2016.d.ts +22 -0
- package/compiler/lib.es2016.full.d.ts +25 -0
- package/compiler/lib.es2017.d.ts +26 -0
- package/compiler/lib.es2017.full.d.ts +25 -0
- package/compiler/lib.es2017.intl.d.ts +32 -0
- package/compiler/lib.es2017.object.d.ts +51 -0
- package/compiler/lib.es2017.sharedmemory.d.ts +137 -0
- package/compiler/lib.es2017.string.d.ts +47 -0
- package/compiler/lib.es2017.typedarrays.d.ts +55 -0
- package/compiler/lib.es2018.asyncgenerator.d.ts +79 -0
- package/compiler/lib.es2018.asynciterable.d.ts +45 -0
- package/compiler/lib.es2018.d.ts +26 -0
- package/compiler/lib.es2018.full.d.ts +25 -0
- package/compiler/lib.es2018.intl.d.ts +61 -0
- package/compiler/lib.es2018.promise.d.ts +32 -0
- package/compiler/lib.es2018.regexp.d.ts +39 -0
- package/compiler/lib.es2019.array.d.ts +85 -0
- package/compiler/lib.es2019.d.ts +25 -0
- package/compiler/lib.es2019.full.d.ts +25 -0
- package/compiler/lib.es2019.object.d.ts +35 -0
- package/compiler/lib.es2019.string.d.ts +33 -0
- package/compiler/lib.es2019.symbol.d.ts +26 -0
- package/compiler/lib.es2020.bigint.d.ts +728 -0
- package/compiler/lib.es2020.d.ts +27 -0
- package/compiler/lib.es2020.full.d.ts +25 -0
- package/compiler/lib.es2020.intl.d.ts +310 -0
- package/compiler/lib.es2020.promise.d.ts +50 -0
- package/compiler/lib.es2020.sharedmemory.d.ts +99 -0
- package/compiler/lib.es2020.string.d.ts +30 -0
- package/compiler/lib.es2020.symbol.wellknown.d.ts +39 -0
- package/compiler/lib.es5.d.ts +4435 -0
- package/compiler/lib.es6.d.ts +25 -0
- package/compiler/lib.esnext.d.ts +25 -0
- package/compiler/lib.esnext.full.d.ts +25 -0
- package/compiler/lib.esnext.intl.d.ts +32 -0
- package/compiler/lib.esnext.promise.d.ts +43 -0
- package/compiler/lib.esnext.string.d.ts +35 -0
- package/compiler/lib.esnext.weakref.d.ts +75 -0
- package/compiler/lib.scripthost.d.ts +327 -0
- package/compiler/lib.webworker.d.ts +6042 -0
- package/compiler/lib.webworker.importscripts.d.ts +26 -0
- package/compiler/lib.webworker.iterable.d.ts +166 -0
- package/compiler/package.json +3 -3
- package/compiler/rindo.d.ts +0 -16
- package/compiler/rindo.js +42738 -40541
- package/compiler/rindo.min.js +2 -15
- package/dependencies.json +73 -50
- package/dev-server/client/index.js +33 -10
- package/dev-server/client/package.json +3 -3
- package/dev-server/connector.html +3 -3
- package/dev-server/index.d.ts +3 -6
- package/dev-server/index.js +256 -252
- package/dev-server/package.json +3 -3
- package/dev-server/server-process.js +1738 -0
- package/dev-server/server-worker-thread.js +39 -0
- package/dev-server/templates/initial-load.html +160 -160
- package/dev-server/ws.js +1 -1
- package/internal/app-data/{index.cjs.js → index.cjs} +7 -5
- package/internal/app-data/index.d.ts +1 -0
- package/internal/app-data/index.js +7 -6
- package/internal/app-data/package.json +11 -5
- package/internal/client/css-shim.js +2 -2
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +193 -119
- package/internal/client/package.json +4 -3
- package/internal/client/{patch.js → patch-browser.js} +8 -24
- package/internal/client/patch-esm.js +23 -0
- package/internal/client/polyfills/css-shim.js +1 -1
- package/internal/client/polyfills/index.js +34 -34
- package/internal/client/shadow-css.js +9 -3
- package/internal/hydrate/index.js +305 -281
- package/internal/hydrate/package.json +2 -2
- package/internal/hydrate/runner.d.ts +24 -12
- package/internal/hydrate/runner.js +153 -124
- package/internal/hydrate/shadow-css.js +24 -24
- package/internal/package.json +5 -4
- package/internal/rindo-core/index.cjs +1 -0
- package/internal/rindo-core/index.d.ts +51 -2
- package/internal/rindo-core/index.js +15 -1
- package/internal/rindo-ext-modules.d.ts +41 -39
- package/internal/rindo-private.d.ts +93 -148
- package/internal/rindo-public-compiler.d.ts +231 -155
- package/internal/rindo-public-runtime.d.ts +42 -39
- package/internal/testing/index.js +144 -121
- package/internal/testing/package.json +2 -2
- package/internal/testing/shadow-css.js +24 -24
- package/mock-doc/index.cjs +4610 -0
- package/mock-doc/index.d.ts +12 -1
- package/mock-doc/index.js +177 -67
- package/mock-doc/package.json +11 -5
- package/package.json +132 -133
- package/readme.md +21 -95
- package/screenshot/compare/build/app.js +33 -33
- package/screenshot/compare/build/p-f4745c2f.entry.js +1 -1
- package/screenshot/connector-base.d.ts +1 -1
- package/screenshot/connector-local.d.ts +1 -1
- package/screenshot/index.js +63 -46
- package/screenshot/package.json +10 -3
- package/screenshot/pixel-match.js +54 -57
- package/screenshot/screenshot-compare.d.ts +1 -1
- package/screenshot/screenshot-fs.d.ts +1 -1
- package/sys/deno/index.js +1785 -0
- package/sys/deno/node-compat.js +2654 -0
- package/sys/deno/worker.js +44 -0
- package/sys/node/autoprefixer.js +8 -1
- package/sys/node/glob.js +1 -1
- package/sys/node/graceful-fs.js +1 -1
- package/sys/node/index.d.ts +1 -1
- package/sys/node/index.js +689 -705
- package/sys/node/node-fetch.js +1 -1
- package/sys/node/package.json +3 -3
- package/sys/node/prompts.js +1 -1
- package/sys/node/worker.js +38 -19
- package/testing/index.d.ts +3 -3
- package/testing/index.js +863 -749
- package/testing/jest/jest-config.d.ts +2 -89
- package/testing/jest/jest-environment.d.ts +1 -1
- package/testing/jest/jest-runner.d.ts +1 -1
- package/testing/jest/jest-screenshot.d.ts +1 -1
- package/testing/jest-preset.js +32 -32
- package/testing/matchers/events.d.ts +1 -1
- package/testing/matchers/screenshot.d.ts +1 -1
- package/testing/mock-fetch.d.ts +1 -1
- package/testing/mocks.d.ts +1 -1
- package/testing/package.json +3 -3
- package/testing/puppeteer/index.d.ts +1 -1
- package/testing/puppeteer/puppeteer-browser.d.ts +2 -2
- package/testing/puppeteer/puppeteer-declarations.d.ts +11 -11
- package/testing/puppeteer/puppeteer-element.d.ts +3 -3
- package/testing/puppeteer/puppeteer-emulate.d.ts +1 -1
- package/testing/puppeteer/puppeteer-events.d.ts +3 -3
- package/testing/puppeteer/puppeteer-page.d.ts +1 -1
- package/testing/puppeteer/puppeteer-screenshot.d.ts +2 -2
- package/testing/reset-build-conditionals.d.ts +1 -1
- package/testing/spec-page.d.ts +1 -1
- package/testing/test-transpile.d.ts +1 -1
- package/testing/testing-logger.d.ts +1 -1
- package/testing/testing-utils.d.ts +1 -1
- package/testing/testing.d.ts +1 -1
- package/cli/index.cjs.js +0 -524
- package/dev-server/content-type-db.json +0 -1
- package/dev-server/server-worker.js +0 -1570
- package/mock-doc/index.cjs.js +0 -4500
|
@@ -1,1570 +0,0 @@
|
|
|
1
|
-
function _interopDefault(e) {
|
|
2
|
-
return e && "object" == typeof e && "default" in e ? e.default : e;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function sendMsg(e, t) {
|
|
6
|
-
e.send(t);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function sendError(e, t) {
|
|
10
|
-
const r = {
|
|
11
|
-
error: {
|
|
12
|
-
message: t
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
if ("string" == typeof t) r.error.message = t + ""; else if (t) try {
|
|
16
|
-
r.error.message = util__default.inspect(t) + "";
|
|
17
|
-
} catch (t) {}
|
|
18
|
-
sendMsg(e, r);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function responseHeaders(e) {
|
|
22
|
-
return Object.assign({}, DEFAULT_HEADERS, e);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getBrowserUrl(e, t, r, s, n) {
|
|
26
|
-
t = "0.0.0.0" === t ? "localhost" : t;
|
|
27
|
-
const o = r && 80 !== r && 443 !== r ? ":" + r : "";
|
|
28
|
-
let i = s;
|
|
29
|
-
return n.startsWith("/") && (n = n.substring(1)), i += n, `${e = e.replace(/\:/g, "")}://${t}${o}${i}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getContentType(e, t) {
|
|
33
|
-
const r = t.replace(/^.*[/\\]/, "").toLowerCase(), s = r.replace(/^.*\./, "").toLowerCase(), n = r.length < t.length;
|
|
34
|
-
return (s.length < r.length - 1 || !n) && e.contentTypes[s] || "application/octet-stream";
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function isDevClient(e) {
|
|
38
|
-
return e.startsWith("/~dev-server");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function isDevServerClient(e) {
|
|
42
|
-
return "/~dev-server" === e;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function serve500(e, t, r, s, n) {
|
|
46
|
-
try {
|
|
47
|
-
r.writeHead(500, responseHeaders({
|
|
48
|
-
"content-type": "text/plain; charset=utf-8",
|
|
49
|
-
"x-source": n
|
|
50
|
-
})), r.write(util__default.inspect(s)), r.end(), e.logRequests && sendMsg(process, {
|
|
51
|
-
requestLog: {
|
|
52
|
-
method: t.method,
|
|
53
|
-
url: t.url,
|
|
54
|
-
status: 500
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
} catch (e) {
|
|
58
|
-
sendError(process, "serve500: " + e);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function serve404(e, t, r, s) {
|
|
63
|
-
try {
|
|
64
|
-
if ("/favicon.ico" === t.pathname) try {
|
|
65
|
-
const t = path.join(e.devServerDir, "static", "favicon.ico");
|
|
66
|
-
r.writeHead(200, responseHeaders({
|
|
67
|
-
"content-type": "image/x-icon",
|
|
68
|
-
"x-source": "favicon: " + s
|
|
69
|
-
}));
|
|
70
|
-
const n = fs.createReadStream(t);
|
|
71
|
-
return n.on("error", e => {
|
|
72
|
-
r.writeHead(404, responseHeaders({
|
|
73
|
-
"content-type": "text/plain; charset=utf-8",
|
|
74
|
-
"x-source": `createReadStream error: ${e}, ${s}`
|
|
75
|
-
})), r.write(util__default.inspect(e)), r.end();
|
|
76
|
-
}), void n.pipe(r);
|
|
77
|
-
} catch (n) {
|
|
78
|
-
serve500(e, t, r, n, s);
|
|
79
|
-
}
|
|
80
|
-
const n = [ "404 File Not Found", "Url: " + t.pathname, "File: " + t.filePath ].join("\n");
|
|
81
|
-
serve404Content(e, t, r, n, s), e.logRequests && sendMsg(process, {
|
|
82
|
-
requestLog: {
|
|
83
|
-
method: t.method,
|
|
84
|
-
url: t.url,
|
|
85
|
-
status: 404
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
} catch (n) {
|
|
89
|
-
serve500(e, t, r, n, s);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function serve404Content(e, t, r, s, n) {
|
|
94
|
-
try {
|
|
95
|
-
const e = responseHeaders({
|
|
96
|
-
"content-type": "text/plain; charset=utf-8",
|
|
97
|
-
"x-source": n
|
|
98
|
-
});
|
|
99
|
-
r.writeHead(404, e), r.write(s), r.end();
|
|
100
|
-
} catch (s) {
|
|
101
|
-
serve500(e, t, r, s, "serve404Content: " + n);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async function serveFile(e, t, r, s) {
|
|
106
|
-
try {
|
|
107
|
-
if (function n(e) {
|
|
108
|
-
const t = e.toLowerCase().trim().split(".").pop();
|
|
109
|
-
return TXT_EXT.includes(t);
|
|
110
|
-
}(r.filePath)) {
|
|
111
|
-
let n = await t.readFile(r.filePath, "utf8");
|
|
112
|
-
e.websocket && function o(e) {
|
|
113
|
-
return (e = e.toLowerCase().trim()).endsWith(".html") || e.endsWith(".htm");
|
|
114
|
-
}(r.filePath) && !isDevServerClient(r.pathname) ? n = function i(e, t, r) {
|
|
115
|
-
var s, n, o;
|
|
116
|
-
const i = function a(e, t, r) {
|
|
117
|
-
let s = e.address, n = e.port;
|
|
118
|
-
return t && (s = t, n = null), getBrowserUrl(null != r ? r : e.protocol, s, n, e.basePath, "/~dev-server");
|
|
119
|
-
}(e, null !== (n = null === (s = t.headers) || void 0 === s ? void 0 : s["x-forwarded-host"]) && void 0 !== n ? n : t.host, null === (o = t.headers) || void 0 === o ? void 0 : o["x-forwarded-proto"]);
|
|
120
|
-
return function l(e, t) {
|
|
121
|
-
return e.includes("</body>") ? e.replace("</body>", t + "</body>") : e.includes("</html>") ? e.replace("</html>", t + "</html>") : `${e}${t}`;
|
|
122
|
-
}(r, `<iframe title="Rindo Dev Server Connector ${version} ⚡" src="${i}" style="display:block;width:0;height:0;border:0;visibility:hidden" aria-hidden="true"></iframe>`);
|
|
123
|
-
}(e, r, n) : function a(e) {
|
|
124
|
-
return (e = e.toLowerCase().trim()).endsWith(".css");
|
|
125
|
-
}(r.filePath) && (n = function l(e, t) {
|
|
126
|
-
const r = Url.parse(e), s = querystring.parse(r.query), n = s["s-hmr"], o = s["s-hmr-urls"];
|
|
127
|
-
n && o && o.split(",").forEach(e => {
|
|
128
|
-
urlVersionIds.set(e, n);
|
|
129
|
-
});
|
|
130
|
-
const i = /url\((['"]?)(.*)\1\)/gi;
|
|
131
|
-
let a, l = t;
|
|
132
|
-
for (;null !== (a = i.exec(t)); ) {
|
|
133
|
-
const e = a[2], t = Url.parse(e), r = path.basename(t.pathname), s = urlVersionIds.get(r);
|
|
134
|
-
if (!s) continue;
|
|
135
|
-
const n = querystring.parse(t.query);
|
|
136
|
-
n["s-hmr"] = s, t.search = querystring.stringify(n);
|
|
137
|
-
const o = Url.format(t);
|
|
138
|
-
l = l.replace(e, o);
|
|
139
|
-
}
|
|
140
|
-
return l;
|
|
141
|
-
}(r.url, n)), function c(e, t) {
|
|
142
|
-
if (!e.gzip) return !1;
|
|
143
|
-
if ("GET" !== t.method) return !1;
|
|
144
|
-
const r = t.headers && t.headers["accept-encoding"];
|
|
145
|
-
return "string" == typeof r && !!r.includes("gzip");
|
|
146
|
-
}(e, r) ? (s.writeHead(200, responseHeaders({
|
|
147
|
-
"content-type": getContentType(e, r.filePath) + "; charset=utf-8",
|
|
148
|
-
"content-encoding": "gzip",
|
|
149
|
-
vary: "Accept-Encoding"
|
|
150
|
-
})), zlib.gzip(n, {
|
|
151
|
-
level: 9
|
|
152
|
-
}, (e, t) => {
|
|
153
|
-
s.end(t);
|
|
154
|
-
})) : (s.writeHead(200, responseHeaders({
|
|
155
|
-
"content-type": getContentType(e, r.filePath) + "; charset=utf-8",
|
|
156
|
-
"content-length": buffer.Buffer.byteLength(n, "utf8")
|
|
157
|
-
})), s.write(n), s.end());
|
|
158
|
-
} else s.writeHead(200, responseHeaders({
|
|
159
|
-
"content-type": getContentType(e, r.filePath),
|
|
160
|
-
"content-length": r.stats.size
|
|
161
|
-
})), fs.createReadStream(r.filePath).pipe(s);
|
|
162
|
-
e.logRequests && sendMsg(process, {
|
|
163
|
-
requestLog: {
|
|
164
|
-
method: r.method,
|
|
165
|
-
url: r.url,
|
|
166
|
-
status: 200
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
} catch (t) {
|
|
170
|
-
serve500(e, r, s, t, "serveFile");
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async function serveDevClient(e, t, r, s) {
|
|
175
|
-
try {
|
|
176
|
-
if (function n(e) {
|
|
177
|
-
return e === OPEN_IN_EDITOR_URL;
|
|
178
|
-
}(r.pathname)) return async function o(e, t, r, s) {
|
|
179
|
-
let n = 200;
|
|
180
|
-
const o = {};
|
|
181
|
-
try {
|
|
182
|
-
e.editors.length > 0 ? (await async function i(e, t, r, s) {
|
|
183
|
-
const n = Url.parse(r.url).query, o = querystring.parse(n);
|
|
184
|
-
if ("string" == typeof o.file) {
|
|
185
|
-
if (s.file = o.file, null == o.line || isNaN(o.line) || (s.line = parseInt(o.line, 10)),
|
|
186
|
-
("number" != typeof s.line || s.line < 1) && (s.line = 1), null == o.column || isNaN(o.column) || (s.column = parseInt(o.column, 10)),
|
|
187
|
-
("number" != typeof s.column || s.column < 1) && (s.column = 1), "string" == typeof o.editor) {
|
|
188
|
-
if (o.editor = o.editor.trim().toLowerCase(), !e.editors.some(e => e.id === o.editor)) return void (s.error = "invalid editor: " + o.editor);
|
|
189
|
-
s.editor = o.editor;
|
|
190
|
-
} else s.editor = e.editors[0].id;
|
|
191
|
-
try {
|
|
192
|
-
const e = await t.stat(s.file);
|
|
193
|
-
s.exists = !!e && e.isFile();
|
|
194
|
-
} catch (e) {
|
|
195
|
-
s.exists = !1;
|
|
196
|
-
}
|
|
197
|
-
} else s.error = "missing file";
|
|
198
|
-
}(e, t, r, o), await async function a(e) {
|
|
199
|
-
if (e.exists && !e.error) try {
|
|
200
|
-
const t = {
|
|
201
|
-
editor: e.editor
|
|
202
|
-
}, r = openInEditorApi.configure(t, t => e.error = t + "");
|
|
203
|
-
if (e.error) return;
|
|
204
|
-
e.open = `${e.file}:${e.line}:${e.column}`, await r.open(e.open);
|
|
205
|
-
} catch (t) {
|
|
206
|
-
e.error = t + "";
|
|
207
|
-
}
|
|
208
|
-
}(o)) : o.error = "no editors available";
|
|
209
|
-
} catch (e) {
|
|
210
|
-
o.error = e + "", n = 500;
|
|
211
|
-
}
|
|
212
|
-
sendMsg(process, {
|
|
213
|
-
requestLog: {
|
|
214
|
-
method: r.method,
|
|
215
|
-
url: r.url,
|
|
216
|
-
status: n
|
|
217
|
-
}
|
|
218
|
-
}), s.writeHead(n, responseHeaders({
|
|
219
|
-
"content-type": "application/json; charset=utf-8"
|
|
220
|
-
})), s.write(JSON.stringify(o, null, 2)), s.end();
|
|
221
|
-
}(e, t, r, s);
|
|
222
|
-
if (isDevServerClient(r.pathname)) return async function i(e, t, r, s) {
|
|
223
|
-
try {
|
|
224
|
-
const n = path.join(e.devServerDir, "connector.html");
|
|
225
|
-
let o = await t.readFile(n, "utf8");
|
|
226
|
-
if ("string" == typeof o) {
|
|
227
|
-
const t = {
|
|
228
|
-
basePath: e.basePath,
|
|
229
|
-
editors: e.editors,
|
|
230
|
-
reloadStrategy: e.reloadStrategy
|
|
231
|
-
};
|
|
232
|
-
o = o.replace("window.__DEV_CLIENT_CONFIG__", JSON.stringify(t)), s.writeHead(200, responseHeaders({
|
|
233
|
-
"content-type": "text/html; charset=utf-8"
|
|
234
|
-
})), s.write(o), s.end();
|
|
235
|
-
} else serve404(e, r, s, "serveDevClientScript");
|
|
236
|
-
} catch (t) {
|
|
237
|
-
serve500(e, r, s, t, "serveDevClientScript");
|
|
238
|
-
}
|
|
239
|
-
}(e, t, r, s);
|
|
240
|
-
if (function a(e) {
|
|
241
|
-
return e === DEV_SERVER_INIT_URL;
|
|
242
|
-
}(r.pathname)) r.filePath = path.join(e.devServerDir, "templates", "initial-load.html"); else {
|
|
243
|
-
const t = r.pathname.replace("/~dev-server/", "");
|
|
244
|
-
r.filePath = path.join(e.devServerDir, "static", t);
|
|
245
|
-
}
|
|
246
|
-
try {
|
|
247
|
-
return r.stats = await t.stat(r.filePath), r.stats ? serveFile(e, t, r, s) : serve404(e, r, s, "serveDevClient no stats");
|
|
248
|
-
} catch (t) {
|
|
249
|
-
return serve404(e, r, s, "serveDevClient stats error " + t);
|
|
250
|
-
}
|
|
251
|
-
} catch (t) {
|
|
252
|
-
return serve500(e, r, s, t, "serveDevClient");
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function createRequestHandler(e, t) {
|
|
257
|
-
return async function(r, s) {
|
|
258
|
-
try {
|
|
259
|
-
const n = function n(e, t) {
|
|
260
|
-
const r = {
|
|
261
|
-
method: (t.method || "GET").toUpperCase(),
|
|
262
|
-
headers: t.headers,
|
|
263
|
-
acceptHeader: t.headers && "string" == typeof t.headers.accept && t.headers.accept || "",
|
|
264
|
-
url: (t.url || "").trim() || "",
|
|
265
|
-
host: t.headers && "string" == typeof t.headers.host && t.headers.host || null
|
|
266
|
-
}, s = (Url.parse(r.url).pathname || "").replace(/\\/g, "/").split("/");
|
|
267
|
-
return r.pathname = s.map(e => decodeURIComponent(e)).join("/"), r.pathname.length > 0 && !isDevClient(r.pathname) && (r.pathname = "/" + r.pathname.substring(e.basePath.length)),
|
|
268
|
-
r.filePath = normalizePath(path.normalize(path.join(e.root, path.relative("/", r.pathname)))),
|
|
269
|
-
r;
|
|
270
|
-
}(e, r);
|
|
271
|
-
if ("" === n.url) return s.writeHead(302, {
|
|
272
|
-
location: "/"
|
|
273
|
-
}), e.logRequests && sendMsg(process, {
|
|
274
|
-
requestLog: {
|
|
275
|
-
method: n.method,
|
|
276
|
-
url: n.url,
|
|
277
|
-
status: 302
|
|
278
|
-
}
|
|
279
|
-
}), s.end();
|
|
280
|
-
if (isDevClient(n.pathname) && e.websocket) return serveDevClient(e, t, n, s);
|
|
281
|
-
if (function o(e) {
|
|
282
|
-
return e.includes("/~dev-module");
|
|
283
|
-
}(n.pathname)) return async function i(e, t, r) {
|
|
284
|
-
try {
|
|
285
|
-
const s = (await function s(e, t) {
|
|
286
|
-
return new Promise(r => {
|
|
287
|
-
t.resolveId = resolveIds++, msgResolves.set(t.resolveId, r), sendMsg(e, t);
|
|
288
|
-
});
|
|
289
|
-
}(process, {
|
|
290
|
-
compilerRequestPath: t.url
|
|
291
|
-
})).compilerRequestResults;
|
|
292
|
-
if (s) {
|
|
293
|
-
const e = {
|
|
294
|
-
"content-type": "application/javascript; charset=utf-8",
|
|
295
|
-
"content-length": Buffer.byteLength(s.content, "utf8"),
|
|
296
|
-
"x-dev-node-module-id": s.nodeModuleId,
|
|
297
|
-
"x-dev-node-module-version": s.nodeModuleVersion,
|
|
298
|
-
"x-dev-node-module-resolved-path": s.nodeResolvedPath,
|
|
299
|
-
"x-dev-node-module-cache-path": s.cachePath,
|
|
300
|
-
"x-dev-node-module-cache-hit": s.cacheHit
|
|
301
|
-
};
|
|
302
|
-
return r.writeHead(s.status, responseHeaders(e)), r.write(s.content), void r.end();
|
|
303
|
-
}
|
|
304
|
-
return serve404(e, t, r, "serveCompilerRequest");
|
|
305
|
-
} catch (s) {
|
|
306
|
-
return serve500(e, t, r, s, "serveCompilerRequest");
|
|
307
|
-
}
|
|
308
|
-
}(e, n, s);
|
|
309
|
-
if (!function a(e, t) {
|
|
310
|
-
return t.endsWith("/") || (t += "/"), e.endsWith("/") || (e += "/"), t.startsWith(e);
|
|
311
|
-
}(e.basePath, n.url)) return e.logRequests && sendMsg(process, {
|
|
312
|
-
requestLog: {
|
|
313
|
-
method: n.method,
|
|
314
|
-
url: n.url,
|
|
315
|
-
status: 404
|
|
316
|
-
}
|
|
317
|
-
}), serve404Content(e, n, s, "404 File Not Found, base path: " + e.basePath, "invalid basePath");
|
|
318
|
-
try {
|
|
319
|
-
if (n.stats = await t.stat(n.filePath), n.stats) {
|
|
320
|
-
if (n.stats.isFile()) return serveFile(e, t, n, s);
|
|
321
|
-
if (n.stats.isDirectory()) return async function l(e, t, r, s) {
|
|
322
|
-
try {
|
|
323
|
-
const n = path.join(r.filePath, "index.html");
|
|
324
|
-
if (r.stats = await t.stat(n), r.stats && r.stats.isFile()) return r.filePath = n,
|
|
325
|
-
serveFile(e, t, r, s);
|
|
326
|
-
} catch (e) {}
|
|
327
|
-
if (!r.pathname.endsWith("/")) return e.logRequests && sendMsg(process, {
|
|
328
|
-
requestLog: {
|
|
329
|
-
method: r.method,
|
|
330
|
-
url: r.url,
|
|
331
|
-
status: 302
|
|
332
|
-
}
|
|
333
|
-
}), s.writeHead(302, {
|
|
334
|
-
location: r.pathname + "/"
|
|
335
|
-
}), s.end();
|
|
336
|
-
try {
|
|
337
|
-
const n = await t.readdir(r.filePath);
|
|
338
|
-
try {
|
|
339
|
-
if (null == dirTemplate) {
|
|
340
|
-
const r = path.join(e.devServerDir, "templates", "directory-index.html");
|
|
341
|
-
dirTemplate = await t.readFile(r, "utf8");
|
|
342
|
-
}
|
|
343
|
-
const o = await async function n(e, t, r) {
|
|
344
|
-
const s = await async function n(e, t, r) {
|
|
345
|
-
return await Promise.all(r.map(async r => {
|
|
346
|
-
const s = path.basename(r), n = await e.stat(r);
|
|
347
|
-
return {
|
|
348
|
-
name: s,
|
|
349
|
-
pathname: Url.resolve(t, s),
|
|
350
|
-
isDirectory: !(!n || !n.isDirectory())
|
|
351
|
-
};
|
|
352
|
-
}));
|
|
353
|
-
}(e, t, r);
|
|
354
|
-
return "/" !== t && s.unshift({
|
|
355
|
-
isDirectory: !0,
|
|
356
|
-
pathname: "../",
|
|
357
|
-
name: ".."
|
|
358
|
-
}), s.map(e => `\n <li class="${e.isDirectory ? "directory" : "file"}">\n <a href="${e.pathname}">\n <span class="icon"></span>\n <span>${e.name}</span>\n </a>\n </li>`).join("");
|
|
359
|
-
}(t, r.pathname, n), i = dirTemplate.replace("{{title}}", r.pathname).replace("{{nav}}", function o(e) {
|
|
360
|
-
const t = e.split("/");
|
|
361
|
-
t.pop();
|
|
362
|
-
let r = "";
|
|
363
|
-
return t.map((e, t) => (r += e + "/", `<a href="${r}">${0 === t ? "~" : e}</a>`)).join("<span>/</span>") + "<span>/</span>";
|
|
364
|
-
}(r.pathname)).replace("{{files}}", o);
|
|
365
|
-
s.writeHead(200, responseHeaders({
|
|
366
|
-
"content-type": "text/html; charset=utf-8",
|
|
367
|
-
"x-directory-index": r.pathname
|
|
368
|
-
})), s.write(i), s.end(), e.logRequests && sendMsg(process, {
|
|
369
|
-
requestLog: {
|
|
370
|
-
method: r.method,
|
|
371
|
-
url: r.url,
|
|
372
|
-
status: 200
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
} catch (t) {
|
|
376
|
-
serve500(e, r, s, t, "serveDirectoryIndex");
|
|
377
|
-
}
|
|
378
|
-
} catch (t) {
|
|
379
|
-
serve404(e, r, s, "serveDirectoryIndex");
|
|
380
|
-
}
|
|
381
|
-
}(e, t, n, s);
|
|
382
|
-
}
|
|
383
|
-
} catch (e) {}
|
|
384
|
-
const o = [ "notfound" ], i = function c(e, t) {
|
|
385
|
-
return !!e.historyApiFallback && ("GET" === t.method && (!!t.acceptHeader.includes("text/html") && !(!e.historyApiFallback.disableDotRule && t.pathname.includes("."))));
|
|
386
|
-
}(e, n);
|
|
387
|
-
if (o.push("validHistoryApi: " + i), i) try {
|
|
388
|
-
const r = path.join(e.root, e.historyApiFallback.index);
|
|
389
|
-
if (o.push("indexFilePath: " + r), n.stats = await t.stat(r), n.stats && n.stats.isFile()) return n.filePath = r,
|
|
390
|
-
serveFile(e, t, n, s);
|
|
391
|
-
} catch (e) {
|
|
392
|
-
o.push("notfound error: " + e);
|
|
393
|
-
}
|
|
394
|
-
return serve404(e, n, s, o.join(", "));
|
|
395
|
-
} catch (t) {
|
|
396
|
-
return serve500(e, r, s, t, "not found error");
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
async function nodeCopyTasks(e, t) {
|
|
402
|
-
const r = {
|
|
403
|
-
diagnostics: [],
|
|
404
|
-
dirPaths: [],
|
|
405
|
-
filePaths: []
|
|
406
|
-
};
|
|
407
|
-
try {
|
|
408
|
-
e = ((e, t = (e => e)) => {
|
|
409
|
-
const r = new Set;
|
|
410
|
-
return e.filter(e => {
|
|
411
|
-
const s = t(e);
|
|
412
|
-
return null == s || !r.has(s) && (r.add(s), !0);
|
|
413
|
-
});
|
|
414
|
-
})((n = await Promise.all(e.map(e => async function r(e, t) {
|
|
415
|
-
return (e => {
|
|
416
|
-
const t = {
|
|
417
|
-
"{": "}",
|
|
418
|
-
"(": ")",
|
|
419
|
-
"[": "]"
|
|
420
|
-
}, r = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
|
|
421
|
-
if ("" === e) return !1;
|
|
422
|
-
let s;
|
|
423
|
-
for (;s = r.exec(e); ) {
|
|
424
|
-
if (s[2]) return !0;
|
|
425
|
-
let r = s.index + s[0].length;
|
|
426
|
-
const n = s[1], o = n ? t[n] : null;
|
|
427
|
-
if (n && o) {
|
|
428
|
-
const t = e.indexOf(o, r);
|
|
429
|
-
-1 !== t && (r = t + 1);
|
|
430
|
-
}
|
|
431
|
-
e = e.slice(r);
|
|
432
|
-
}
|
|
433
|
-
return !1;
|
|
434
|
-
})(e.src) ? await async function r(e, t) {
|
|
435
|
-
return (await asyncGlob(e.src, {
|
|
436
|
-
cwd: t,
|
|
437
|
-
nodir: !0
|
|
438
|
-
})).map(r => function s(e, t, r) {
|
|
439
|
-
const s = path.join(e.dest, e.keepDirStructure ? r : path.basename(r));
|
|
440
|
-
return {
|
|
441
|
-
src: path.join(t, r),
|
|
442
|
-
dest: s,
|
|
443
|
-
warn: e.warn,
|
|
444
|
-
keepDirStructure: e.keepDirStructure
|
|
445
|
-
};
|
|
446
|
-
}(e, t, r));
|
|
447
|
-
}(e, t) : [ {
|
|
448
|
-
src: getSrcAbsPath(t, e.src),
|
|
449
|
-
dest: e.keepDirStructure ? path.join(e.dest, e.src) : e.dest,
|
|
450
|
-
warn: e.warn,
|
|
451
|
-
keepDirStructure: e.keepDirStructure
|
|
452
|
-
} ];
|
|
453
|
-
}(e, t))), e = n.flat ? n.flat(1) : n.reduce((e, t) => (e.push(...t), e), [])), e => e.dest);
|
|
454
|
-
const s = [];
|
|
455
|
-
for (;e.length > 0; ) {
|
|
456
|
-
const t = e.splice(0, 100);
|
|
457
|
-
await Promise.all(t.map(e => processCopyTask(r, s, e)));
|
|
458
|
-
}
|
|
459
|
-
const o = function s(e) {
|
|
460
|
-
const t = [];
|
|
461
|
-
return e.forEach(e => {
|
|
462
|
-
!function r(e, t) {
|
|
463
|
-
(t = normalizePath(t)) !== ROOT_DIR && t + "/" !== ROOT_DIR && "" !== t && (e.includes(t) || e.push(t));
|
|
464
|
-
}(t, path.dirname(e.dest));
|
|
465
|
-
}), t.sort((e, t) => {
|
|
466
|
-
const r = e.split("/").length, s = t.split("/").length;
|
|
467
|
-
return r < s ? -1 : r > s ? 1 : e < t ? -1 : e > t ? 1 : 0;
|
|
468
|
-
}), t;
|
|
469
|
-
}(s);
|
|
470
|
-
try {
|
|
471
|
-
await Promise.all(o.map(e => mkdir(e, {
|
|
472
|
-
recursive: !0
|
|
473
|
-
})));
|
|
474
|
-
} catch (e) {}
|
|
475
|
-
for (;s.length > 0; ) {
|
|
476
|
-
const e = s.splice(0, 100);
|
|
477
|
-
await Promise.all(e.map(e => copyFile(e.src, e.dest)));
|
|
478
|
-
}
|
|
479
|
-
} catch (e) {
|
|
480
|
-
catchError(r.diagnostics, e);
|
|
481
|
-
}
|
|
482
|
-
var n;
|
|
483
|
-
return r;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function getSrcAbsPath(e, t) {
|
|
487
|
-
return path.isAbsolute(t) ? t : path.join(e, t);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
async function processCopyTask(e, t, r) {
|
|
491
|
-
try {
|
|
492
|
-
r.src = normalizePath(r.src), r.dest = normalizePath(r.dest), (await stat(r.src)).isDirectory() ? (e.dirPaths.includes(r.dest) || e.dirPaths.push(r.dest),
|
|
493
|
-
await async function s(e, t, r) {
|
|
494
|
-
try {
|
|
495
|
-
const s = await readdir(r.src);
|
|
496
|
-
await Promise.all(s.map(async s => {
|
|
497
|
-
const n = {
|
|
498
|
-
src: path.join(r.src, s),
|
|
499
|
-
dest: path.join(r.dest, s),
|
|
500
|
-
warn: r.warn
|
|
501
|
-
};
|
|
502
|
-
await processCopyTask(e, t, n);
|
|
503
|
-
}));
|
|
504
|
-
} catch (t) {
|
|
505
|
-
catchError(e.diagnostics, t);
|
|
506
|
-
}
|
|
507
|
-
}(e, t, r)) : function n(e) {
|
|
508
|
-
return e = e.trim().toLowerCase(), IGNORE.some(t => e.endsWith(t));
|
|
509
|
-
}(r.src) || (e.filePaths.includes(r.dest) || e.filePaths.push(r.dest), t.push(r));
|
|
510
|
-
} catch (t) {
|
|
511
|
-
!1 !== r.warn && (buildError(e.diagnostics).messageText = t.message);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function asyncGlob(e, t) {
|
|
516
|
-
return new Promise((r, s) => {
|
|
517
|
-
(0, glob.glob)(e, t, (e, t) => {
|
|
518
|
-
e ? s(e) : r(t);
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
function semiver(e, t, r) {
|
|
524
|
-
return e = e.split("."), t = t.split("."), fn(e[0], t[0]) || fn(e[1], t[1]) || (t[2] = t.slice(2).join("."),
|
|
525
|
-
(r = /[.-]/.test(e[2] = e.slice(2).join("."))) == /[.-]/.test(t[2]) ? fn(e[2], t[2]) : r ? -1 : 1);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
async function checkVersion(e, t) {
|
|
529
|
-
try {
|
|
530
|
-
const r = await async function r(e) {
|
|
531
|
-
try {
|
|
532
|
-
const e = await function t() {
|
|
533
|
-
return new Promise(e => {
|
|
534
|
-
fs.readFile(getLastCheckStoragePath(), "utf8", (t, r) => {
|
|
535
|
-
if (!t && isString(r)) try {
|
|
536
|
-
e(JSON.parse(r));
|
|
537
|
-
} catch (e) {}
|
|
538
|
-
e(null);
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
}();
|
|
542
|
-
if (null == e) return setLastCheck(), null;
|
|
543
|
-
if (!function r(e, t, s) {
|
|
544
|
-
return t + s < e;
|
|
545
|
-
}(Date.now(), e, 6048e5)) return null;
|
|
546
|
-
const t = setLastCheck(), r = await async function s(e) {
|
|
547
|
-
const t = await Promise.resolve().then((function() {
|
|
548
|
-
return function e(t) {
|
|
549
|
-
if (t && t.__esModule) return t;
|
|
550
|
-
var r = {};
|
|
551
|
-
return t && Object.keys(t).forEach((function(e) {
|
|
552
|
-
var s = Object.getOwnPropertyDescriptor(t, e);
|
|
553
|
-
Object.defineProperty(r, e, s.get ? s : {
|
|
554
|
-
enumerable: !0,
|
|
555
|
-
get: function() {
|
|
556
|
-
return t[e];
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
})), r.default = t, r;
|
|
560
|
-
}(require("https"));
|
|
561
|
-
}));
|
|
562
|
-
return new Promise((r, s) => {
|
|
563
|
-
const n = t.request(e, t => {
|
|
564
|
-
if (t.statusCode > 299) return void s(`url: ${e}, staus: ${t.statusCode}`);
|
|
565
|
-
t.once("error", s);
|
|
566
|
-
const n = [];
|
|
567
|
-
t.once("end", () => {
|
|
568
|
-
r(n.join(""));
|
|
569
|
-
}), t.on("data", e => {
|
|
570
|
-
n.push(e);
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
n.once("error", s), n.end();
|
|
574
|
-
});
|
|
575
|
-
}("https://registry.npmjs.org/@rindo/core"), s = JSON.parse(r);
|
|
576
|
-
return await t, s["dist-tags"].latest;
|
|
577
|
-
} catch (t) {
|
|
578
|
-
e.debug("getLatestCompilerVersion error: " + t);
|
|
579
|
-
}
|
|
580
|
-
return null;
|
|
581
|
-
}(e);
|
|
582
|
-
if (null != r) return () => {
|
|
583
|
-
semiver(t, r) < 0 ? function s(e, t, r) {
|
|
584
|
-
const s = [ `Update available: ${t} ${ARROW} ${r}`, "To get the latest, please run:", "npm install @rindo/core" ], n = s[0].length, o = [];
|
|
585
|
-
let i = BOX_TOP_LEFT;
|
|
586
|
-
for (;i.length <= n + 2 * PADDING; ) i += BOX_HORIZONTAL;
|
|
587
|
-
i += BOX_TOP_RIGHT, o.push(i), s.forEach(e => {
|
|
588
|
-
let t = BOX_VERTICAL;
|
|
589
|
-
for (let e = 0; e < PADDING; e++) t += " ";
|
|
590
|
-
for (t += e; t.length <= n + 2 * PADDING; ) t += " ";
|
|
591
|
-
t += BOX_VERTICAL, o.push(t);
|
|
592
|
-
});
|
|
593
|
-
let a = BOX_BOTTOM_LEFT;
|
|
594
|
-
for (;a.length <= n + 2 * PADDING; ) a += BOX_HORIZONTAL;
|
|
595
|
-
a += BOX_BOTTOM_RIGHT, o.push(a);
|
|
596
|
-
let l = `\n${INDENT}${o.join("\n" + INDENT)}\n`;
|
|
597
|
-
l = l.replace(t, e.red(t)), l = l.replace(r, e.green(r)), l = l.replace("npm install @rindo/core", e.cyan("npm install @rindo/core")),
|
|
598
|
-
console.log(l);
|
|
599
|
-
}(e, t, r) : console.debug(`${e.cyan("@rindo/core")} version ${e.green(t)} is the latest version`);
|
|
600
|
-
};
|
|
601
|
-
} catch (t) {
|
|
602
|
-
e.debug("unable to load latest compiler version: " + t);
|
|
603
|
-
}
|
|
604
|
-
return noop;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
function setLastCheck() {
|
|
608
|
-
return new Promise(e => {
|
|
609
|
-
const t = JSON.stringify(Date.now());
|
|
610
|
-
fs.writeFile(getLastCheckStoragePath(), t, () => {
|
|
611
|
-
e();
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
function getLastCheckStoragePath() {
|
|
617
|
-
return path.join(os.tmpdir(), "rindo_last_version_node.json");
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
function getNextWorker(e) {
|
|
621
|
-
const t = e.filter(e => !e.stopped);
|
|
622
|
-
return 0 === t.length ? null : t.sort((e, t) => e.tasks.size < t.tasks.size ? -1 : e.tasks.size > t.tasks.size ? 1 : e.totalTasksAssigned < t.totalTasksAssigned ? -1 : e.totalTasksAssigned > t.totalTasksAssigned ? 1 : 0)[0];
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
async function startDevServerWorker(e, t) {
|
|
626
|
-
let r = !1;
|
|
627
|
-
try {
|
|
628
|
-
const s = function s(e = {}) {
|
|
629
|
-
const t = function r(e = {}) {
|
|
630
|
-
const t = e.process || global.process, r = new Set, s = [], n = os.cpus(), o = n.length, i = os.platform(), a = {
|
|
631
|
-
name: "node",
|
|
632
|
-
version: t.versions.node,
|
|
633
|
-
access: e => new Promise(t => {
|
|
634
|
-
fs.access(e, e => {
|
|
635
|
-
t(!e);
|
|
636
|
-
});
|
|
637
|
-
}),
|
|
638
|
-
accessSync(e) {
|
|
639
|
-
let t = !1;
|
|
640
|
-
try {
|
|
641
|
-
fs.accessSync(e), t = !0;
|
|
642
|
-
} catch (e) {}
|
|
643
|
-
return t;
|
|
644
|
-
},
|
|
645
|
-
addDestory(e) {
|
|
646
|
-
r.add(e);
|
|
647
|
-
},
|
|
648
|
-
removeDestory(e) {
|
|
649
|
-
r.delete(e);
|
|
650
|
-
},
|
|
651
|
-
applyPrerenderGlobalPatch(e) {
|
|
652
|
-
if ("function" != typeof global.fetch) {
|
|
653
|
-
const t = require(path.join(__dirname, "node-fetch.js"));
|
|
654
|
-
global.fetch = (r, s) => {
|
|
655
|
-
if ("string" == typeof r) {
|
|
656
|
-
const n = new URL(r, e.devServerHostUrl).href;
|
|
657
|
-
return t.fetch(n, s);
|
|
658
|
-
}
|
|
659
|
-
return r.url = new URL(r.url, e.devServerHostUrl).href, t.fetch(r, s);
|
|
660
|
-
}, global.Headers = t.Headers, global.Request = t.Request, global.Response = t.Response,
|
|
661
|
-
global.FetchError = t.FetchError;
|
|
662
|
-
}
|
|
663
|
-
e.window.fetch = global.fetch, e.window.Headers = global.Headers, e.window.Request = global.Request,
|
|
664
|
-
e.window.Response = global.Response, e.window.FetchError = global.FetchError;
|
|
665
|
-
},
|
|
666
|
-
checkVersion,
|
|
667
|
-
copyFile: (e, t) => new Promise(r => {
|
|
668
|
-
fs.copyFile(e, t, e => {
|
|
669
|
-
r(!e);
|
|
670
|
-
});
|
|
671
|
-
}),
|
|
672
|
-
createWorkerController(e) {
|
|
673
|
-
const t = path.join(__dirname, "worker.js");
|
|
674
|
-
return new NodeWorkerController(t, e);
|
|
675
|
-
},
|
|
676
|
-
async destroy() {
|
|
677
|
-
const e = [];
|
|
678
|
-
r.forEach(t => {
|
|
679
|
-
try {
|
|
680
|
-
const r = t();
|
|
681
|
-
r && r.then && e.push(r);
|
|
682
|
-
} catch (e) {
|
|
683
|
-
console.error("node sys destroy: " + e);
|
|
684
|
-
}
|
|
685
|
-
}), e.length > 0 && await Promise.all(e), r.clear();
|
|
686
|
-
},
|
|
687
|
-
dynamicImport: e => Promise.resolve((e => ("function" == typeof __webpack_require__ ? __non_webpack_require__ : require)(e))(e)),
|
|
688
|
-
encodeToBase64: e => Buffer.from(e).toString("base64"),
|
|
689
|
-
async ensureDependencies() {
|
|
690
|
-
const e = [];
|
|
691
|
-
let t = null;
|
|
692
|
-
try {
|
|
693
|
-
t = require.resolve("typescript");
|
|
694
|
-
} catch (t) {
|
|
695
|
-
const r = buildError(e);
|
|
696
|
-
r.header = "Unable to find TypeScript", r.messageText = 'Please ensure you install the dependencies first, for example: "npm install"';
|
|
697
|
-
}
|
|
698
|
-
return {
|
|
699
|
-
rindoPath: a.getCompilerExecutingPath(),
|
|
700
|
-
typescriptPath: t,
|
|
701
|
-
diagnostics: e
|
|
702
|
-
};
|
|
703
|
-
},
|
|
704
|
-
async ensureResources() {},
|
|
705
|
-
exit: exit$1,
|
|
706
|
-
getCurrentDirectory: () => normalizePath(t.cwd()),
|
|
707
|
-
getCompilerExecutingPath: () => path.join(__dirname, "..", "..", "compiler", "rindo.js"),
|
|
708
|
-
getDevServerExecutingPath: () => path.join(__dirname, "..", "..", "dev-server", "index.js"),
|
|
709
|
-
getEnvironmentVar: e => process.env[e],
|
|
710
|
-
getLocalModulePath: () => null,
|
|
711
|
-
getRemoteModuleUrl: () => null,
|
|
712
|
-
glob: asyncGlob,
|
|
713
|
-
hardwareConcurrency: o,
|
|
714
|
-
isSymbolicLink: e => new Promise(t => {
|
|
715
|
-
try {
|
|
716
|
-
fs.lstat(e, (e, r) => {
|
|
717
|
-
t(!e && r.isSymbolicLink());
|
|
718
|
-
});
|
|
719
|
-
} catch (e) {
|
|
720
|
-
t(!1);
|
|
721
|
-
}
|
|
722
|
-
}),
|
|
723
|
-
mkdir: (e, t) => new Promise(r => {
|
|
724
|
-
t ? fs.mkdir(e, t, t => {
|
|
725
|
-
r({
|
|
726
|
-
basename: path.basename(e),
|
|
727
|
-
dirname: path.dirname(e),
|
|
728
|
-
path: e,
|
|
729
|
-
newDirs: [],
|
|
730
|
-
error: t
|
|
731
|
-
});
|
|
732
|
-
}) : fs.mkdir(e, t => {
|
|
733
|
-
r({
|
|
734
|
-
basename: path.basename(e),
|
|
735
|
-
dirname: path.dirname(e),
|
|
736
|
-
path: e,
|
|
737
|
-
newDirs: [],
|
|
738
|
-
error: t
|
|
739
|
-
});
|
|
740
|
-
});
|
|
741
|
-
}),
|
|
742
|
-
mkdirSync(e, t) {
|
|
743
|
-
const r = {
|
|
744
|
-
basename: path.basename(e),
|
|
745
|
-
dirname: path.dirname(e),
|
|
746
|
-
path: e,
|
|
747
|
-
newDirs: [],
|
|
748
|
-
error: null
|
|
749
|
-
};
|
|
750
|
-
try {
|
|
751
|
-
fs.mkdirSync(e, t);
|
|
752
|
-
} catch (e) {
|
|
753
|
-
r.error = e;
|
|
754
|
-
}
|
|
755
|
-
return r;
|
|
756
|
-
},
|
|
757
|
-
nextTick: t.nextTick,
|
|
758
|
-
normalizePath,
|
|
759
|
-
onProcessInterrupt: e => {
|
|
760
|
-
s.includes(e) || s.push(e);
|
|
761
|
-
},
|
|
762
|
-
platformPath: path,
|
|
763
|
-
readdir: e => new Promise(t => {
|
|
764
|
-
fs.readdir(e, (r, s) => {
|
|
765
|
-
t(r ? [] : s.map(t => normalizePath(path.join(e, t))));
|
|
766
|
-
});
|
|
767
|
-
}),
|
|
768
|
-
readdirSync(e) {
|
|
769
|
-
try {
|
|
770
|
-
return fs.readdirSync(e).map(t => normalizePath(path.join(e, t)));
|
|
771
|
-
} catch (e) {}
|
|
772
|
-
return [];
|
|
773
|
-
},
|
|
774
|
-
readFile: e => new Promise(t => {
|
|
775
|
-
fs.readFile(e, "utf8", (e, r) => {
|
|
776
|
-
t(r);
|
|
777
|
-
});
|
|
778
|
-
}),
|
|
779
|
-
readFileSync(e) {
|
|
780
|
-
try {
|
|
781
|
-
return fs.readFileSync(e, "utf8");
|
|
782
|
-
} catch (e) {}
|
|
783
|
-
},
|
|
784
|
-
realpath: e => new Promise(t => {
|
|
785
|
-
fs.realpath(e, "utf8", (e, r) => {
|
|
786
|
-
t({
|
|
787
|
-
path: r,
|
|
788
|
-
error: e
|
|
789
|
-
});
|
|
790
|
-
});
|
|
791
|
-
}),
|
|
792
|
-
realpathSync(e) {
|
|
793
|
-
const t = {
|
|
794
|
-
path: void 0,
|
|
795
|
-
error: null
|
|
796
|
-
};
|
|
797
|
-
try {
|
|
798
|
-
t.path = fs.realpathSync(e, "utf8");
|
|
799
|
-
} catch (e) {
|
|
800
|
-
t.error = e;
|
|
801
|
-
}
|
|
802
|
-
return t;
|
|
803
|
-
},
|
|
804
|
-
rename: (e, t) => new Promise(r => {
|
|
805
|
-
fs.rename(e, t, s => {
|
|
806
|
-
r({
|
|
807
|
-
oldPath: e,
|
|
808
|
-
newPath: t,
|
|
809
|
-
error: s,
|
|
810
|
-
oldDirs: [],
|
|
811
|
-
oldFiles: [],
|
|
812
|
-
newDirs: [],
|
|
813
|
-
newFiles: [],
|
|
814
|
-
renamed: [],
|
|
815
|
-
isFile: !1,
|
|
816
|
-
isDirectory: !1
|
|
817
|
-
});
|
|
818
|
-
});
|
|
819
|
-
}),
|
|
820
|
-
resolvePath: e => normalizePath(e),
|
|
821
|
-
rmdir: (e, t) => new Promise(r => {
|
|
822
|
-
t && t.recursive ? fs.rmdir(e, {
|
|
823
|
-
recursive: !0
|
|
824
|
-
}, t => {
|
|
825
|
-
r({
|
|
826
|
-
basename: path.basename(e),
|
|
827
|
-
dirname: path.dirname(e),
|
|
828
|
-
path: e,
|
|
829
|
-
removedDirs: [],
|
|
830
|
-
removedFiles: [],
|
|
831
|
-
error: t
|
|
832
|
-
});
|
|
833
|
-
}) : fs.rmdir(e, t => {
|
|
834
|
-
r({
|
|
835
|
-
basename: path.basename(e),
|
|
836
|
-
dirname: path.dirname(e),
|
|
837
|
-
path: e,
|
|
838
|
-
removedDirs: [],
|
|
839
|
-
removedFiles: [],
|
|
840
|
-
error: t
|
|
841
|
-
});
|
|
842
|
-
});
|
|
843
|
-
}),
|
|
844
|
-
rmdirSync(e, t) {
|
|
845
|
-
try {
|
|
846
|
-
return t && t.recursive ? fs.rmdirSync(e, {
|
|
847
|
-
recursive: !0
|
|
848
|
-
}) : fs.rmdirSync(e), {
|
|
849
|
-
basename: path.basename(e),
|
|
850
|
-
dirname: path.dirname(e),
|
|
851
|
-
path: e,
|
|
852
|
-
removedDirs: [],
|
|
853
|
-
removedFiles: [],
|
|
854
|
-
error: null
|
|
855
|
-
};
|
|
856
|
-
} catch (t) {
|
|
857
|
-
return {
|
|
858
|
-
basename: path.basename(e),
|
|
859
|
-
dirname: path.dirname(e),
|
|
860
|
-
path: e,
|
|
861
|
-
removedDirs: [],
|
|
862
|
-
removedFiles: [],
|
|
863
|
-
error: t
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
},
|
|
867
|
-
stat: e => new Promise(t => {
|
|
868
|
-
fs.stat(e, (e, r) => {
|
|
869
|
-
t(e ? void 0 : r);
|
|
870
|
-
});
|
|
871
|
-
}),
|
|
872
|
-
statSync(e) {
|
|
873
|
-
try {
|
|
874
|
-
return fs.statSync(e);
|
|
875
|
-
} catch (e) {}
|
|
876
|
-
},
|
|
877
|
-
tmpdir: () => os.tmpdir(),
|
|
878
|
-
unlink: e => new Promise(t => {
|
|
879
|
-
fs.unlink(e, r => {
|
|
880
|
-
t({
|
|
881
|
-
basename: path.basename(e),
|
|
882
|
-
dirname: path.dirname(e),
|
|
883
|
-
path: e,
|
|
884
|
-
error: r
|
|
885
|
-
});
|
|
886
|
-
});
|
|
887
|
-
}),
|
|
888
|
-
unlinkSync(e) {
|
|
889
|
-
const t = {
|
|
890
|
-
basename: path.basename(e),
|
|
891
|
-
dirname: path.dirname(e),
|
|
892
|
-
path: e,
|
|
893
|
-
error: null
|
|
894
|
-
};
|
|
895
|
-
try {
|
|
896
|
-
fs.unlinkSync(e);
|
|
897
|
-
} catch (e) {
|
|
898
|
-
t.error = e;
|
|
899
|
-
}
|
|
900
|
-
return t;
|
|
901
|
-
},
|
|
902
|
-
writeFile: (e, t) => new Promise(r => {
|
|
903
|
-
fs.writeFile(e, t, t => {
|
|
904
|
-
r({
|
|
905
|
-
path: e,
|
|
906
|
-
error: t
|
|
907
|
-
});
|
|
908
|
-
});
|
|
909
|
-
}),
|
|
910
|
-
writeFileSync(e, t) {
|
|
911
|
-
const r = {
|
|
912
|
-
path: e,
|
|
913
|
-
error: null
|
|
914
|
-
};
|
|
915
|
-
try {
|
|
916
|
-
fs.writeFileSync(e, t);
|
|
917
|
-
} catch (e) {
|
|
918
|
-
r.error = e;
|
|
919
|
-
}
|
|
920
|
-
return r;
|
|
921
|
-
},
|
|
922
|
-
generateContentHash(e, t) {
|
|
923
|
-
let r = crypto.createHash("sha1").update(e).digest("hex").toLowerCase();
|
|
924
|
-
return "number" == typeof t && (r = r.substr(0, t)), Promise.resolve(r);
|
|
925
|
-
},
|
|
926
|
-
copy: nodeCopyTasks,
|
|
927
|
-
details: {
|
|
928
|
-
cpuModel: (Array.isArray(n) && n.length > 0 ? n[0] && n[0].model : "") || "",
|
|
929
|
-
freemem: () => os.freemem(),
|
|
930
|
-
platform: "darwin" === i || "linux" === i ? i : "win32" === i ? "windows" : "",
|
|
931
|
-
release: os.release(),
|
|
932
|
-
totalmem: os.totalmem()
|
|
933
|
-
}
|
|
934
|
-
}, l = new NodeResolveModule;
|
|
935
|
-
return a.lazyRequire = new NodeLazyRequire(l, {
|
|
936
|
-
"@types/jest": [ "24.9.1", "25.2.3" ],
|
|
937
|
-
"@types/puppeteer": [ "1.19.0", "2.0.1" ],
|
|
938
|
-
jest: [ "24.9.0", "26.0.1" ],
|
|
939
|
-
"jest-cli": [ "24.9.0", "26.0.1" ],
|
|
940
|
-
pixelmatch: [ "4.0.2", "4.0.2" ],
|
|
941
|
-
puppeteer: [ "1.19.0", "2.1.1" ],
|
|
942
|
-
"puppeteer-core": [ "1.19.0", "2.1.1" ],
|
|
943
|
-
"workbox-build": [ "4.3.1", "4.3.1" ]
|
|
944
|
-
}), t.on("SIGINT", () => {
|
|
945
|
-
for (;;) {
|
|
946
|
-
const e = s.pop();
|
|
947
|
-
if ("function" != typeof e) break;
|
|
948
|
-
try {
|
|
949
|
-
e();
|
|
950
|
-
} catch (e) {}
|
|
951
|
-
}
|
|
952
|
-
}), a;
|
|
953
|
-
}(e), s = require("typescript"), n = s.sys.watchFile, o = s.sys.watchDirectory;
|
|
954
|
-
return t.watchTimeout = 80, t.events = (() => {
|
|
955
|
-
const e = [], t = t => {
|
|
956
|
-
const r = e.findIndex(e => e.callback === t);
|
|
957
|
-
return r > -1 && (e.splice(r, 1), !0);
|
|
958
|
-
};
|
|
959
|
-
return {
|
|
960
|
-
emit: (t, r) => {
|
|
961
|
-
const s = t.toLowerCase().trim(), n = e.slice();
|
|
962
|
-
for (const e of n) if (null == e.eventName) try {
|
|
963
|
-
e.callback(t, r);
|
|
964
|
-
} catch (e) {
|
|
965
|
-
console.error(e);
|
|
966
|
-
} else if (e.eventName === s) try {
|
|
967
|
-
e.callback(r);
|
|
968
|
-
} catch (e) {
|
|
969
|
-
console.error(e);
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
on: (r, s) => {
|
|
973
|
-
if ("function" == typeof r) {
|
|
974
|
-
const s = null, n = r;
|
|
975
|
-
return e.push({
|
|
976
|
-
eventName: s,
|
|
977
|
-
callback: n
|
|
978
|
-
}), () => t(n);
|
|
979
|
-
}
|
|
980
|
-
if ("string" == typeof r && "function" == typeof s) {
|
|
981
|
-
const n = r.toLowerCase().trim(), o = s;
|
|
982
|
-
return e.push({
|
|
983
|
-
eventName: n,
|
|
984
|
-
callback: o
|
|
985
|
-
}), () => t(o);
|
|
986
|
-
}
|
|
987
|
-
return () => !1;
|
|
988
|
-
},
|
|
989
|
-
unsubscribeAll: () => {
|
|
990
|
-
e.length = 0;
|
|
991
|
-
}
|
|
992
|
-
};
|
|
993
|
-
})(), t.watchDirectory = (e, r, s) => {
|
|
994
|
-
const n = o(e, e => {
|
|
995
|
-
e = normalizePath(e), r(e, null);
|
|
996
|
-
}, s), i = () => {
|
|
997
|
-
n.close();
|
|
998
|
-
};
|
|
999
|
-
return t.addDestory(i), {
|
|
1000
|
-
close() {
|
|
1001
|
-
t.removeDestory(i), n.close();
|
|
1002
|
-
}
|
|
1003
|
-
};
|
|
1004
|
-
}, t.watchFile = (e, r) => {
|
|
1005
|
-
const o = n(e, (e, n) => {
|
|
1006
|
-
e = normalizePath(e), n === s.FileWatcherEventKind.Created ? (r(e, "fileAdd"), t.events.emit("fileAdd", e)) : n === s.FileWatcherEventKind.Changed ? (r(e, "fileUpdate"),
|
|
1007
|
-
t.events.emit("fileUpdate", e)) : n === s.FileWatcherEventKind.Deleted && (r(e, "fileDelete"),
|
|
1008
|
-
t.events.emit("fileDelete", e));
|
|
1009
|
-
}), i = () => {
|
|
1010
|
-
o.close();
|
|
1011
|
-
};
|
|
1012
|
-
return t.addDestory(i), {
|
|
1013
|
-
close() {
|
|
1014
|
-
t.removeDestory(i), o.close();
|
|
1015
|
-
}
|
|
1016
|
-
};
|
|
1017
|
-
}, t;
|
|
1018
|
-
}({
|
|
1019
|
-
process: e
|
|
1020
|
-
}), n = [];
|
|
1021
|
-
t.editors = await async function n() {
|
|
1022
|
-
const e = [];
|
|
1023
|
-
try {
|
|
1024
|
-
await Promise.all(Object.keys(openInEditorApi.editors).map(async t => {
|
|
1025
|
-
const r = await async function s(e) {
|
|
1026
|
-
let t = !1;
|
|
1027
|
-
try {
|
|
1028
|
-
await openInEditorApi.editors[e].detect(), t = !0;
|
|
1029
|
-
} catch (e) {}
|
|
1030
|
-
return t;
|
|
1031
|
-
}(t);
|
|
1032
|
-
e.push({
|
|
1033
|
-
id: t,
|
|
1034
|
-
priority: EDITOR_PRIORITY[t],
|
|
1035
|
-
supported: r
|
|
1036
|
-
});
|
|
1037
|
-
}));
|
|
1038
|
-
} catch (e) {}
|
|
1039
|
-
return e.filter(e => e.supported).sort((e, t) => e.priority < t.priority ? -1 : e.priority > t.priority ? 1 : 0).map(e => ({
|
|
1040
|
-
id: e.id,
|
|
1041
|
-
name: EDITORS[e.id]
|
|
1042
|
-
}));
|
|
1043
|
-
}();
|
|
1044
|
-
let o = await async function o(e, t, r) {
|
|
1045
|
-
e.port = await async function s(e, t) {
|
|
1046
|
-
return async function t(r) {
|
|
1047
|
-
return await function s(e, t) {
|
|
1048
|
-
return new Promise((r, s) => {
|
|
1049
|
-
const n = net.createServer().once("error", () => {
|
|
1050
|
-
r(!0);
|
|
1051
|
-
}).once("listening", () => {
|
|
1052
|
-
n.once("close", () => {
|
|
1053
|
-
r(!1);
|
|
1054
|
-
}).close();
|
|
1055
|
-
}).on("error", e => {
|
|
1056
|
-
s(e);
|
|
1057
|
-
}).listen(t, e);
|
|
1058
|
-
});
|
|
1059
|
-
}(e, r) ? t(r + 1) : r;
|
|
1060
|
-
}(t);
|
|
1061
|
-
}(e.address, e.port);
|
|
1062
|
-
const n = createRequestHandler(e, t), o = e.https;
|
|
1063
|
-
let i = o ? https.createServer(o, n) : http.createServer(n);
|
|
1064
|
-
return r.push(() => {
|
|
1065
|
-
i.close(), i = null;
|
|
1066
|
-
}), i;
|
|
1067
|
-
}(t, s, n);
|
|
1068
|
-
t.websocket && function i(e, t, r) {
|
|
1069
|
-
function s() {
|
|
1070
|
-
this.isAlive = !0;
|
|
1071
|
-
}
|
|
1072
|
-
const n = {
|
|
1073
|
-
server: t
|
|
1074
|
-
}, o = new ws.Server(n);
|
|
1075
|
-
o.on("connection", t => {
|
|
1076
|
-
t.on("message", t => {
|
|
1077
|
-
e.send(JSON.parse(t.toString()));
|
|
1078
|
-
}), t.isAlive = !0, t.on("pong", s);
|
|
1079
|
-
});
|
|
1080
|
-
const i = setInterval(() => {
|
|
1081
|
-
o.clients.forEach(e => {
|
|
1082
|
-
if (!e.isAlive) return e.close(1e3);
|
|
1083
|
-
e.isAlive = !1, e.ping(noop);
|
|
1084
|
-
});
|
|
1085
|
-
}, 1e4);
|
|
1086
|
-
e.addListener("message", (function a(e) {
|
|
1087
|
-
if (e) {
|
|
1088
|
-
const t = JSON.stringify(e);
|
|
1089
|
-
o.clients.forEach(e => {
|
|
1090
|
-
e.readyState === e.OPEN && e.send(t);
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
|
-
})), r.push(() => {
|
|
1094
|
-
clearInterval(i), o.clients.forEach(e => {
|
|
1095
|
-
e.close(1e3);
|
|
1096
|
-
});
|
|
1097
|
-
});
|
|
1098
|
-
}(e, o, n), o.listen(t.port, t.address), sendMsg(e, {
|
|
1099
|
-
serverStarted: {
|
|
1100
|
-
address: t.address,
|
|
1101
|
-
basePath: t.basePath,
|
|
1102
|
-
browserUrl: getBrowserUrl(t.protocol, t.address, t.port, t.basePath, "/"),
|
|
1103
|
-
port: t.port,
|
|
1104
|
-
protocol: t.protocol,
|
|
1105
|
-
root: t.root,
|
|
1106
|
-
initialLoadUrl: getBrowserUrl(t.protocol, t.address, t.port, t.basePath, t.initialLoadUrl || DEV_SERVER_INIT_URL),
|
|
1107
|
-
error: null
|
|
1108
|
-
}
|
|
1109
|
-
}), r = !0;
|
|
1110
|
-
const i = () => {
|
|
1111
|
-
n.forEach(e => {
|
|
1112
|
-
e();
|
|
1113
|
-
}), n.length = 0, o = null, setTimeout(() => {
|
|
1114
|
-
exit$1(0);
|
|
1115
|
-
}, 5e3).unref(), e.removeAllListeners("message");
|
|
1116
|
-
};
|
|
1117
|
-
e.once("SIGINT", i);
|
|
1118
|
-
} catch (t) {
|
|
1119
|
-
r ? sendError(e, t) : sendMsg(e, {
|
|
1120
|
-
serverStarted: {
|
|
1121
|
-
address: null,
|
|
1122
|
-
basePath: null,
|
|
1123
|
-
browserUrl: null,
|
|
1124
|
-
initialLoadUrl: null,
|
|
1125
|
-
port: null,
|
|
1126
|
-
protocol: null,
|
|
1127
|
-
root: null,
|
|
1128
|
-
error: String(t)
|
|
1129
|
-
}
|
|
1130
|
-
});
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
var fn, exit$1;
|
|
1135
|
-
|
|
1136
|
-
const util = require("util"), util__default = _interopDefault(util), fs = _interopDefault(require("../sys/node/graceful-fs.js")), path = _interopDefault(require("path")), querystring = require("querystring"), Url = require("url"), zlib = require("zlib"), buffer = require("buffer"), openInEditorApi = _interopDefault(require("./open-in-editor-api.js")), net = require("net"), http = require("http"), https = require("https"), glob = _interopDefault(require("../sys/node/glob.js")), os = require("os"), crypto = require("crypto"), cp = require("child_process"), events = require("events"), ws = require("./ws.js"), DEV_SERVER_INIT_URL = "/~dev-server-init", OPEN_IN_EDITOR_URL = "/~dev-server-open-in-editor", version = "0.0.0-dev.20221104122636", msgResolves = new Map;
|
|
1137
|
-
|
|
1138
|
-
let resolveIds = 1;
|
|
1139
|
-
|
|
1140
|
-
const DEFAULT_HEADERS = {
|
|
1141
|
-
"cache-control": "no-cache, no-store, must-revalidate, max-age=0",
|
|
1142
|
-
expires: "0",
|
|
1143
|
-
server: "Rindo Dev Server " + version,
|
|
1144
|
-
date: "Wed, 1 Jan 2000 00:00:00 GMT",
|
|
1145
|
-
"access-control-allow-origin": "*",
|
|
1146
|
-
"access-control-expose-headers": "*"
|
|
1147
|
-
}, TXT_EXT = [ "css", "html", "htm", "js", "json", "svg", "xml" ], IS_NODE_ENV = !("undefined" == typeof global || "function" != typeof require || !global.process || "string" != typeof __filename || global.origin && "string" == typeof global.origin), noop = (global.process.platform,
|
|
1148
|
-
IS_NODE_ENV && global.process.platform, process.cwd, process.exit, () => {}), isString = e => "string" == typeof e, buildError = e => {
|
|
1149
|
-
const t = {
|
|
1150
|
-
level: "error",
|
|
1151
|
-
type: "build",
|
|
1152
|
-
header: "Build Error",
|
|
1153
|
-
messageText: "build error",
|
|
1154
|
-
relFilePath: null,
|
|
1155
|
-
absFilePath: null,
|
|
1156
|
-
lines: []
|
|
1157
|
-
};
|
|
1158
|
-
return e && e.push(t), t;
|
|
1159
|
-
}, catchError = (e, t, r) => {
|
|
1160
|
-
const s = {
|
|
1161
|
-
level: "error",
|
|
1162
|
-
type: "build",
|
|
1163
|
-
header: "Build Error",
|
|
1164
|
-
messageText: "build error",
|
|
1165
|
-
relFilePath: null,
|
|
1166
|
-
absFilePath: null,
|
|
1167
|
-
lines: []
|
|
1168
|
-
};
|
|
1169
|
-
return isString(r) ? s.messageText = r : null != t && (null != t.stack ? s.messageText = t.stack.toString() : null != t.message ? s.messageText = t.message.toString() : s.messageText = t.toString()),
|
|
1170
|
-
null == e || shouldIgnoreError(s.messageText) || e.push(s), s;
|
|
1171
|
-
}, shouldIgnoreError = e => e === TASK_CANCELED_MSG, TASK_CANCELED_MSG = "task canceled", normalizePath = e => {
|
|
1172
|
-
if ("string" != typeof e) throw new Error("invalid path to normalize");
|
|
1173
|
-
e = normalizeSlashes(e.trim());
|
|
1174
|
-
const t = pathComponents(e, getRootLength(e)), r = reducePathComponents(t), s = r[0], n = r[1], o = s + r.slice(1).join("/");
|
|
1175
|
-
return "" === o ? "." : "" === s && n && e.includes("/") && !n.startsWith(".") && !n.startsWith("@") ? "./" + o : o;
|
|
1176
|
-
}, normalizeSlashes = e => e.replace(backslashRegExp, "/"), backslashRegExp = /\\/g, reducePathComponents = e => {
|
|
1177
|
-
if (!Array.isArray(e) || 0 === e.length) return [];
|
|
1178
|
-
const t = [ e[0] ];
|
|
1179
|
-
for (let r = 1; r < e.length; r++) {
|
|
1180
|
-
const s = e[r];
|
|
1181
|
-
if (s && "." !== s) {
|
|
1182
|
-
if (".." === s) if (t.length > 1) {
|
|
1183
|
-
if (".." !== t[t.length - 1]) {
|
|
1184
|
-
t.pop();
|
|
1185
|
-
continue;
|
|
1186
|
-
}
|
|
1187
|
-
} else if (t[0]) continue;
|
|
1188
|
-
t.push(s);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
return t;
|
|
1192
|
-
}, getRootLength = e => {
|
|
1193
|
-
const t = getEncodedRootLength(e);
|
|
1194
|
-
return t < 0 ? ~t : t;
|
|
1195
|
-
}, getEncodedRootLength = e => {
|
|
1196
|
-
if (!e) return 0;
|
|
1197
|
-
const t = e.charCodeAt(0);
|
|
1198
|
-
if (47 === t || 92 === t) {
|
|
1199
|
-
if (e.charCodeAt(1) !== t) return 1;
|
|
1200
|
-
const r = e.indexOf(47 === t ? "/" : "\\", 2);
|
|
1201
|
-
return r < 0 ? e.length : r + 1;
|
|
1202
|
-
}
|
|
1203
|
-
if (isVolumeCharacter(t) && 58 === e.charCodeAt(1)) {
|
|
1204
|
-
const t = e.charCodeAt(2);
|
|
1205
|
-
if (47 === t || 92 === t) return 3;
|
|
1206
|
-
if (2 === e.length) return 2;
|
|
1207
|
-
}
|
|
1208
|
-
const r = e.indexOf("://");
|
|
1209
|
-
if (-1 !== r) {
|
|
1210
|
-
const t = r + "://".length, s = e.indexOf("/", t);
|
|
1211
|
-
if (-1 !== s) {
|
|
1212
|
-
const n = e.slice(0, r), o = e.slice(t, s);
|
|
1213
|
-
if ("file" === n && ("" === o || "localhost" === o) && isVolumeCharacter(e.charCodeAt(s + 1))) {
|
|
1214
|
-
const t = getFileUrlVolumeSeparatorEnd(e, s + 2);
|
|
1215
|
-
if (-1 !== t) {
|
|
1216
|
-
if (47 === e.charCodeAt(t)) return ~(t + 1);
|
|
1217
|
-
if (t === e.length) return ~t;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
return ~(s + 1);
|
|
1221
|
-
}
|
|
1222
|
-
return ~e.length;
|
|
1223
|
-
}
|
|
1224
|
-
return 0;
|
|
1225
|
-
}, isVolumeCharacter = e => e >= 97 && e <= 122 || e >= 65 && e <= 90, getFileUrlVolumeSeparatorEnd = (e, t) => {
|
|
1226
|
-
const r = e.charCodeAt(t);
|
|
1227
|
-
if (58 === r) return t + 1;
|
|
1228
|
-
if (37 === r && 51 === e.charCodeAt(t + 1)) {
|
|
1229
|
-
const r = e.charCodeAt(t + 2);
|
|
1230
|
-
if (97 === r || 65 === r) return t + 3;
|
|
1231
|
-
}
|
|
1232
|
-
return -1;
|
|
1233
|
-
}, pathComponents = (e, t) => {
|
|
1234
|
-
const r = e.substring(0, t), s = e.substring(t).split("/"), n = s.length;
|
|
1235
|
-
return n > 0 && !s[n - 1] && s.pop(), [ r, ...s ];
|
|
1236
|
-
}, urlVersionIds = new Map, EDITORS = {
|
|
1237
|
-
atom: "Atom",
|
|
1238
|
-
code: "Code",
|
|
1239
|
-
emacs: "Emacs",
|
|
1240
|
-
idea14ce: "IDEA 14 Community Edition",
|
|
1241
|
-
phpstorm: "PhpStorm",
|
|
1242
|
-
sublime: "Sublime",
|
|
1243
|
-
webstorm: "WebStorm",
|
|
1244
|
-
vim: "Vim",
|
|
1245
|
-
visualstudio: "Visual Studio"
|
|
1246
|
-
}, EDITOR_PRIORITY = {
|
|
1247
|
-
code: 1,
|
|
1248
|
-
atom: 2,
|
|
1249
|
-
sublime: 3,
|
|
1250
|
-
visualstudio: 4,
|
|
1251
|
-
idea14ce: 5,
|
|
1252
|
-
webstorm: 6,
|
|
1253
|
-
phpstorm: 7,
|
|
1254
|
-
vim: 8,
|
|
1255
|
-
emacs: 9
|
|
1256
|
-
};
|
|
1257
|
-
|
|
1258
|
-
let dirTemplate = null;
|
|
1259
|
-
|
|
1260
|
-
const copyFile = util.promisify(fs.copyFile), mkdir = util.promisify(fs.mkdir), readdir = util.promisify(fs.readdir), readFile = util.promisify(fs.readFile), stat = util.promisify(fs.stat), ROOT_DIR = normalizePath(path.resolve("/")), IGNORE = [ ".ds_store", ".gitignore", "desktop.ini", "thumbs.db" ];
|
|
1261
|
-
|
|
1262
|
-
fn = new Intl.Collator(0, {
|
|
1263
|
-
numeric: 1
|
|
1264
|
-
}).compare;
|
|
1265
|
-
|
|
1266
|
-
const ARROW = "→", BOX_TOP_LEFT = "╭", BOX_TOP_RIGHT = "╮", BOX_BOTTOM_LEFT = "╰", BOX_BOTTOM_RIGHT = "╯", BOX_VERTICAL = "│", BOX_HORIZONTAL = "─", PADDING = 2, INDENT = " ";
|
|
1267
|
-
|
|
1268
|
-
exit$1 = function e(t, r) {
|
|
1269
|
-
function s() {
|
|
1270
|
-
n === r.length && process.exit(t);
|
|
1271
|
-
}
|
|
1272
|
-
r || (r = [ process.stdout, process.stderr ]);
|
|
1273
|
-
var n = 0;
|
|
1274
|
-
r.forEach((function(e) {
|
|
1275
|
-
0 === e.bufferSize ? n++ : e.write("", "utf-8", (function() {
|
|
1276
|
-
n++, s();
|
|
1277
|
-
})), e.write = function() {};
|
|
1278
|
-
})), s(), process.on("exit", (function() {
|
|
1279
|
-
process.exit(t);
|
|
1280
|
-
}));
|
|
1281
|
-
};
|
|
1282
|
-
|
|
1283
|
-
class NodeLazyRequire {
|
|
1284
|
-
constructor(e, t) {
|
|
1285
|
-
this.nodeResolveModule = e, this.lazyDependencies = t, this.moduleData = new Map;
|
|
1286
|
-
}
|
|
1287
|
-
async ensure(e, t, r) {
|
|
1288
|
-
const s = [];
|
|
1289
|
-
let n = !1;
|
|
1290
|
-
const o = r.map(async e => {
|
|
1291
|
-
const r = this.moduleData.get(e);
|
|
1292
|
-
if (r && r.fromDir && r.modulePath) return;
|
|
1293
|
-
const [o, i] = this.lazyDependencies[e];
|
|
1294
|
-
try {
|
|
1295
|
-
const r = this.nodeResolveModule.resolveModule(t, e), s = await async function a(e) {
|
|
1296
|
-
const t = await readFile(e, "utf8");
|
|
1297
|
-
return JSON.parse(t);
|
|
1298
|
-
}(r);
|
|
1299
|
-
if (n = !0, semiver(s.version, o) >= 0) return void this.moduleData.set(e, {
|
|
1300
|
-
fromDir: t,
|
|
1301
|
-
modulePath: path.dirname(r)
|
|
1302
|
-
});
|
|
1303
|
-
} catch (e) {}
|
|
1304
|
-
s.push({
|
|
1305
|
-
moduleId: e,
|
|
1306
|
-
requiredVersionRange: i
|
|
1307
|
-
});
|
|
1308
|
-
});
|
|
1309
|
-
if (await Promise.all(o), 0 === s.length) return Promise.resolve();
|
|
1310
|
-
const i = `Please wait while required dependencies are ${n ? "updated" : "installed"}. This may take a few moments and will only be required for the initial run.`;
|
|
1311
|
-
e.info(e.magenta(i));
|
|
1312
|
-
const a = s.map(e => e.moduleId), l = e.createTimeSpan(`installing dependenc${a.length > 1 ? "ies" : "y"}: ${a.join(", ")}`);
|
|
1313
|
-
try {
|
|
1314
|
-
const r = s.map(e => {
|
|
1315
|
-
let t = e.moduleId;
|
|
1316
|
-
return e.requiredVersionRange && (t += "@" + e.requiredVersionRange), t;
|
|
1317
|
-
});
|
|
1318
|
-
await function c(e, t, r) {
|
|
1319
|
-
return new Promise((s, n) => {
|
|
1320
|
-
const o = [ "install", ...r, "--no-audit", "--save-exact", "--save-dev" ], i = {
|
|
1321
|
-
shell: !0,
|
|
1322
|
-
cwd: t,
|
|
1323
|
-
env: Object.assign({}, process.env)
|
|
1324
|
-
};
|
|
1325
|
-
i.env.NODE_ENV = "development", "debug" === e.getLevel() && o.push("--verbose"),
|
|
1326
|
-
e.debug("npm " + o.join(" ")), e.debug("npm, cwd: " + t);
|
|
1327
|
-
const a = cp.spawn("npm", o, i);
|
|
1328
|
-
let l = "";
|
|
1329
|
-
a.stdout && (a.stdout.setEncoding("utf8"), a.stdout.on("data", e => {
|
|
1330
|
-
l += e;
|
|
1331
|
-
})), a.stderr && (a.stderr.setEncoding("utf8"), a.stderr.on("data", e => {
|
|
1332
|
-
l += e;
|
|
1333
|
-
})), a.once("exit", t => {
|
|
1334
|
-
"debug" === e.getLevel() && e.debug("npm, exit " + t), 0 === t ? s() : n(`failed to install: ${r.join(", ")}${l ? ", " + l : ""}`);
|
|
1335
|
-
});
|
|
1336
|
-
});
|
|
1337
|
-
}(e, t, r), s.forEach(e => {
|
|
1338
|
-
this.moduleData.set(e.moduleId, {
|
|
1339
|
-
fromDir: t,
|
|
1340
|
-
modulePath: null
|
|
1341
|
-
});
|
|
1342
|
-
}), l.finish("installing dependencies finished");
|
|
1343
|
-
} catch (t) {
|
|
1344
|
-
e.error("lazy require failed: " + t);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
require(e) {
|
|
1348
|
-
const t = this.moduleData.get(e);
|
|
1349
|
-
if (!t) throw new Error("lazy required module has not been ensured: " + e);
|
|
1350
|
-
if (!t.modulePath) {
|
|
1351
|
-
const r = this.nodeResolveModule.resolveModule(t.fromDir, e);
|
|
1352
|
-
t.modulePath = path.dirname(r), this.moduleData.set(e, t);
|
|
1353
|
-
}
|
|
1354
|
-
return require(t.modulePath);
|
|
1355
|
-
}
|
|
1356
|
-
getModulePath(e) {
|
|
1357
|
-
const t = this.moduleData.get(e);
|
|
1358
|
-
if (!t) throw new Error("lazy required module has not been ensured: " + e);
|
|
1359
|
-
if (!t.modulePath) {
|
|
1360
|
-
const r = this.nodeResolveModule.resolveModule(t.fromDir, e);
|
|
1361
|
-
t.modulePath = path.dirname(r), this.moduleData.set(e, t);
|
|
1362
|
-
}
|
|
1363
|
-
return t.modulePath;
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
class NodeResolveModule {
|
|
1368
|
-
constructor() {
|
|
1369
|
-
this.resolveModuleCache = new Map;
|
|
1370
|
-
}
|
|
1371
|
-
resolveModule(e, t, r) {
|
|
1372
|
-
const s = `${e}:${t}`, n = this.resolveModuleCache.get(s);
|
|
1373
|
-
if (n) return n;
|
|
1374
|
-
if (r && r.manuallyResolve) return this.resolveModuleManually(e, t, s);
|
|
1375
|
-
if (t.startsWith("@types/")) return this.resolveTypesModule(e, t, s);
|
|
1376
|
-
const o = require("module");
|
|
1377
|
-
e = path.resolve(e);
|
|
1378
|
-
const i = path.join(e, "noop.js");
|
|
1379
|
-
let a = normalizePath(o._resolveFilename(t, {
|
|
1380
|
-
id: i,
|
|
1381
|
-
filename: i,
|
|
1382
|
-
paths: o._nodeModulePaths(e)
|
|
1383
|
-
}));
|
|
1384
|
-
const l = normalizePath(path.parse(e).root);
|
|
1385
|
-
let c;
|
|
1386
|
-
for (;a !== l; ) if (a = normalizePath(path.dirname(a)), c = path.join(a, "package.json"),
|
|
1387
|
-
fs.existsSync(c)) return this.resolveModuleCache.set(s, c), c;
|
|
1388
|
-
throw new Error(`error loading "${t}" from "${e}"`);
|
|
1389
|
-
}
|
|
1390
|
-
resolveTypesModule(e, t, r) {
|
|
1391
|
-
const s = t.split("/"), n = normalizePath(path.parse(e).root);
|
|
1392
|
-
let o, i = normalizePath(path.join(e, "noop.js"));
|
|
1393
|
-
for (;i !== n; ) if (i = normalizePath(path.dirname(i)), o = path.join(i, "node_modules", s[0], s[1], "package.json"),
|
|
1394
|
-
fs.existsSync(o)) return this.resolveModuleCache.set(r, o), o;
|
|
1395
|
-
throw new Error(`error loading "${t}" from "${e}"`);
|
|
1396
|
-
}
|
|
1397
|
-
resolveModuleManually(e, t, r) {
|
|
1398
|
-
const s = normalizePath(path.parse(e).root);
|
|
1399
|
-
let n, o = normalizePath(path.join(e, "noop.js"));
|
|
1400
|
-
for (;o !== s; ) if (o = normalizePath(path.dirname(o)), n = path.join(o, "node_modules", t, "package.json"),
|
|
1401
|
-
fs.existsSync(n)) return this.resolveModuleCache.set(r, n), n;
|
|
1402
|
-
throw new Error(`error loading "${t}" from "${e}"`);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
class NodeWorkerMain extends events.EventEmitter {
|
|
1407
|
-
constructor(e, t) {
|
|
1408
|
-
super(), this.id = e, this.tasks = new Map, this.exitCode = null, this.processQueue = !0,
|
|
1409
|
-
this.sendQueue = [], this.stopped = !1, this.successfulMessage = !1, this.totalTasksAssigned = 0,
|
|
1410
|
-
this.fork(t);
|
|
1411
|
-
}
|
|
1412
|
-
fork(e) {
|
|
1413
|
-
const t = {
|
|
1414
|
-
execArgv: process.execArgv.filter(e => !/^--(debug|inspect)/.test(e)),
|
|
1415
|
-
env: process.env,
|
|
1416
|
-
cwd: process.cwd(),
|
|
1417
|
-
silent: !0
|
|
1418
|
-
};
|
|
1419
|
-
this.childProcess = cp.fork(e, [], t), this.childProcess.stdout.setEncoding("utf8"),
|
|
1420
|
-
this.childProcess.stdout.on("data", e => {
|
|
1421
|
-
console.log(e);
|
|
1422
|
-
}), this.childProcess.stderr.setEncoding("utf8"), this.childProcess.stderr.on("data", e => {
|
|
1423
|
-
console.log(e);
|
|
1424
|
-
}), this.childProcess.on("message", this.receiveFromWorker.bind(this)), this.childProcess.on("error", e => {
|
|
1425
|
-
this.emit("error", e);
|
|
1426
|
-
}), this.childProcess.once("exit", e => {
|
|
1427
|
-
this.exitCode = e, this.emit("exit", e);
|
|
1428
|
-
});
|
|
1429
|
-
}
|
|
1430
|
-
run(e) {
|
|
1431
|
-
this.totalTasksAssigned++, this.tasks.set(e.rindoId, e), this.sendToWorker({
|
|
1432
|
-
rindoId: e.rindoId,
|
|
1433
|
-
args: e.inputArgs
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
sendToWorker(e) {
|
|
1437
|
-
this.processQueue ? this.childProcess.send(e, e => {
|
|
1438
|
-
if (!(e && e instanceof Error) && (this.processQueue = !0, this.sendQueue.length > 0)) {
|
|
1439
|
-
const e = this.sendQueue.slice();
|
|
1440
|
-
this.sendQueue = [], e.forEach(e => this.sendToWorker(e));
|
|
1441
|
-
}
|
|
1442
|
-
}) && !/^win/.test(process.platform) || (this.processQueue = !1) : this.sendQueue.push(e);
|
|
1443
|
-
}
|
|
1444
|
-
receiveFromWorker(e) {
|
|
1445
|
-
if (this.successfulMessage = !0, this.stopped) return;
|
|
1446
|
-
const t = this.tasks.get(e.rindoId);
|
|
1447
|
-
t ? (null != e.rindoRtnError ? t.reject(e.rindoRtnError) : t.resolve(e.rindoRtnValue),
|
|
1448
|
-
this.tasks.delete(e.rindoId), this.emit("response", e)) : null != e.rindoRtnError && this.emit("error", e.rindoRtnError);
|
|
1449
|
-
}
|
|
1450
|
-
stop() {
|
|
1451
|
-
this.stopped = !0, this.tasks.forEach(e => e.reject(TASK_CANCELED_MSG)), this.tasks.clear(),
|
|
1452
|
-
this.successfulMessage ? (this.childProcess.send({
|
|
1453
|
-
exit: !0
|
|
1454
|
-
}), setTimeout(() => {
|
|
1455
|
-
null === this.exitCode && this.childProcess.kill("SIGKILL");
|
|
1456
|
-
}, 100)) : this.childProcess.kill("SIGKILL");
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
class NodeWorkerController extends events.EventEmitter {
|
|
1461
|
-
constructor(e, t) {
|
|
1462
|
-
super(), this.forkModulePath = e, this.workerIds = 0, this.rindoId = 0, this.isEnding = !1,
|
|
1463
|
-
this.taskQueue = [], this.workers = [];
|
|
1464
|
-
const r = os.cpus().length;
|
|
1465
|
-
this.useForkedWorkers = t > 0, this.maxWorkers = Math.max(Math.min(t, r), 2) - 1,
|
|
1466
|
-
this.useForkedWorkers ? this.startWorkers() : this.mainThreadRunner = require(e);
|
|
1467
|
-
}
|
|
1468
|
-
onError(e, t) {
|
|
1469
|
-
if ("ERR_IPC_CHANNEL_CLOSED" === e.code) return this.stopWorker(t);
|
|
1470
|
-
"EPIPE" !== e.code && console.error(e);
|
|
1471
|
-
}
|
|
1472
|
-
onExit(e) {
|
|
1473
|
-
setTimeout(() => {
|
|
1474
|
-
let t = !1;
|
|
1475
|
-
const r = this.workers.find(t => t.id === e);
|
|
1476
|
-
r && (r.tasks.forEach(e => {
|
|
1477
|
-
e.retries++, this.taskQueue.unshift(e), t = !0;
|
|
1478
|
-
}), r.tasks.clear()), this.stopWorker(e), t && this.processTaskQueue();
|
|
1479
|
-
}, 10);
|
|
1480
|
-
}
|
|
1481
|
-
startWorkers() {
|
|
1482
|
-
for (;this.workers.length < this.maxWorkers; ) this.startWorker();
|
|
1483
|
-
}
|
|
1484
|
-
startWorker() {
|
|
1485
|
-
const e = this.workerIds++, t = new NodeWorkerMain(e, this.forkModulePath);
|
|
1486
|
-
t.on("response", this.processTaskQueue.bind(this)), t.once("exit", () => {
|
|
1487
|
-
this.onExit(e);
|
|
1488
|
-
}), t.on("error", t => {
|
|
1489
|
-
this.onError(t, e);
|
|
1490
|
-
}), this.workers.push(t);
|
|
1491
|
-
}
|
|
1492
|
-
stopWorker(e) {
|
|
1493
|
-
const t = this.workers.find(t => t.id === e);
|
|
1494
|
-
if (t) {
|
|
1495
|
-
t.stop();
|
|
1496
|
-
const e = this.workers.indexOf(t);
|
|
1497
|
-
e > -1 && this.workers.splice(e, 1);
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
processTaskQueue() {
|
|
1501
|
-
if (!this.isEnding) for (this.useForkedWorkers && this.startWorkers(); this.taskQueue.length > 0; ) {
|
|
1502
|
-
const e = getNextWorker(this.workers);
|
|
1503
|
-
if (!e) break;
|
|
1504
|
-
e.run(this.taskQueue.shift());
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
send(...e) {
|
|
1508
|
-
return this.isEnding ? Promise.reject(TASK_CANCELED_MSG) : this.useForkedWorkers ? new Promise((t, r) => {
|
|
1509
|
-
const s = {
|
|
1510
|
-
rindoId: this.rindoId++,
|
|
1511
|
-
inputArgs: e,
|
|
1512
|
-
retries: 0,
|
|
1513
|
-
resolve: t,
|
|
1514
|
-
reject: r
|
|
1515
|
-
};
|
|
1516
|
-
this.taskQueue.push(s), this.processTaskQueue();
|
|
1517
|
-
}) : this.mainThreadRunner[e[0]].apply(null, e.slice(1));
|
|
1518
|
-
}
|
|
1519
|
-
handler(e) {
|
|
1520
|
-
return (...t) => this.send(e, ...t);
|
|
1521
|
-
}
|
|
1522
|
-
cancelTasks() {
|
|
1523
|
-
for (const e of this.workers) e.tasks.forEach(e => e.reject(TASK_CANCELED_MSG)),
|
|
1524
|
-
e.tasks.clear();
|
|
1525
|
-
this.taskQueue.length = 0;
|
|
1526
|
-
}
|
|
1527
|
-
destroy() {
|
|
1528
|
-
if (!this.isEnding) {
|
|
1529
|
-
this.isEnding = !0;
|
|
1530
|
-
for (const e of this.taskQueue) e.reject(TASK_CANCELED_MSG);
|
|
1531
|
-
this.taskQueue.length = 0;
|
|
1532
|
-
const e = this.workers.map(e => e.id);
|
|
1533
|
-
for (const t of e) this.stopWorker(t);
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
!function createMessageReceiver(e, t) {
|
|
1539
|
-
e.on("message", e => {
|
|
1540
|
-
if ("number" == typeof e.resolveId) {
|
|
1541
|
-
const t = msgResolves.get(e.resolveId);
|
|
1542
|
-
t && (msgResolves.delete(e.resolveId), t(e));
|
|
1543
|
-
}
|
|
1544
|
-
t(e);
|
|
1545
|
-
});
|
|
1546
|
-
}(process, e => {
|
|
1547
|
-
e.startServer && async function t(e) {
|
|
1548
|
-
try {
|
|
1549
|
-
e.contentTypes = await async function t(e) {
|
|
1550
|
-
const t = path.join(e.devServerDir, "content-type-db.json"), r = util__default.promisify(fs.readFile), s = await r(t, "utf8");
|
|
1551
|
-
return JSON.parse(s);
|
|
1552
|
-
}(e), startDevServerWorker(process, e);
|
|
1553
|
-
} catch (e) {
|
|
1554
|
-
sendMsg(process, {
|
|
1555
|
-
serverStarted: {
|
|
1556
|
-
address: null,
|
|
1557
|
-
basePath: null,
|
|
1558
|
-
browserUrl: null,
|
|
1559
|
-
initialLoadUrl: null,
|
|
1560
|
-
port: null,
|
|
1561
|
-
protocol: null,
|
|
1562
|
-
root: null,
|
|
1563
|
-
error: String(e)
|
|
1564
|
-
}
|
|
1565
|
-
});
|
|
1566
|
-
}
|
|
1567
|
-
}(e.startServer);
|
|
1568
|
-
}), process.on("unhandledRejection", e => {
|
|
1569
|
-
console.log("server worker error", e);
|
|
1570
|
-
});
|