@remotion/browser-bundler 4.0.527
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/README.md +18 -0
- package/dist/browser-bundler-worker.d.ts +1 -0
- package/dist/browser-bundler-worker.js +1420 -0
- package/dist/browser-module-scope.d.ts +7 -0
- package/dist/compiler.d.ts +7 -0
- package/dist/compiler.js +1604 -0
- package/dist/create-browser-bundle-runtime.d.ts +7 -0
- package/dist/create-browser-bundler.d.ts +2 -0
- package/dist/create-browser-compiler.d.ts +27 -0
- package/dist/create-browser-composition-observer.d.ts +15 -0
- package/dist/dependency-resolution.d.ts +9 -0
- package/dist/errors.d.ts +6 -0
- package/dist/fast-refresh-bridge.d.ts +8 -0
- package/dist/get-browser-composition.d.ts +17 -0
- package/dist/hmr-assets.d.ts +16 -0
- package/dist/hmr-plugins.d.ts +10 -0
- package/dist/http-client.d.ts +9 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +115 -0
- package/dist/index.js.LICENSE.txt +19 -0
- package/dist/load-browser-bundle.d.ts +10 -0
- package/dist/load-rspack.d.ts +3 -0
- package/dist/refresh-virtual-files.d.ts +5 -0
- package/dist/rspack.wasm32-wasi.wasm +0 -0
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.js +689 -0
- package/dist/types.d.ts +60 -0
- package/dist/virtual-project.d.ts +12 -0
- package/dist/wasi-worker-browser.mjs +28176 -0
- package/dist/wasi-worker-browser.mjs.LICENSE.txt +12 -0
- package/package.json +76 -0
package/dist/compiler.js
ADDED
|
@@ -0,0 +1,1604 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
7
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
8
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
9
|
+
for (let key of __getOwnPropNames(mod))
|
|
10
|
+
if (!__hasOwnProp.call(to, key))
|
|
11
|
+
__defProp(to, key, {
|
|
12
|
+
get: () => mod[key],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
18
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
19
|
+
}) : x)(function(x) {
|
|
20
|
+
if (typeof require !== "undefined")
|
|
21
|
+
return require.apply(this, arguments);
|
|
22
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// src/load-rspack.ts
|
|
26
|
+
var rspackBrowserPromise = null;
|
|
27
|
+
var loadRspackBrowser = (onProgress) => {
|
|
28
|
+
const workerGlobal = globalThis;
|
|
29
|
+
workerGlobal.window ??= globalThis;
|
|
30
|
+
if (rspackBrowserPromise) {
|
|
31
|
+
return rspackBrowserPromise;
|
|
32
|
+
}
|
|
33
|
+
const originalFetch = globalThis.fetch.bind(globalThis);
|
|
34
|
+
workerGlobal.fetch = async (input, init) => {
|
|
35
|
+
const response = await originalFetch(input, init);
|
|
36
|
+
const inputUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
37
|
+
if (!inputUrl.split(/[?#]/)[0].endsWith(".wasm")) {
|
|
38
|
+
return response;
|
|
39
|
+
}
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
throw new Error(`Failed to load Rspack WASM: ${response.status}`);
|
|
42
|
+
}
|
|
43
|
+
const contentLength = Number(response.headers.get("content-length"));
|
|
44
|
+
const totalBytes = Number.isFinite(contentLength) && contentLength > 0 ? contentLength : null;
|
|
45
|
+
onProgress?.({
|
|
46
|
+
asset: "rspack-wasm",
|
|
47
|
+
loadedBytes: 0,
|
|
48
|
+
totalBytes
|
|
49
|
+
});
|
|
50
|
+
if (!response.body) {
|
|
51
|
+
onProgress?.({
|
|
52
|
+
asset: "rspack-wasm",
|
|
53
|
+
loadedBytes: totalBytes ?? 0,
|
|
54
|
+
totalBytes
|
|
55
|
+
});
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
const reader = response.body.getReader();
|
|
59
|
+
let loadedBytes = 0;
|
|
60
|
+
let lastProgressUpdate = 0;
|
|
61
|
+
const body = new ReadableStream({
|
|
62
|
+
async pull(controller) {
|
|
63
|
+
try {
|
|
64
|
+
const result = await reader.read();
|
|
65
|
+
if (result.done) {
|
|
66
|
+
onProgress?.({
|
|
67
|
+
asset: "rspack-wasm",
|
|
68
|
+
loadedBytes,
|
|
69
|
+
totalBytes: totalBytes ?? loadedBytes
|
|
70
|
+
});
|
|
71
|
+
controller.close();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
loadedBytes += result.value.byteLength;
|
|
75
|
+
const now = performance.now();
|
|
76
|
+
if (now - lastProgressUpdate >= 50) {
|
|
77
|
+
lastProgressUpdate = now;
|
|
78
|
+
onProgress?.({
|
|
79
|
+
asset: "rspack-wasm",
|
|
80
|
+
loadedBytes,
|
|
81
|
+
totalBytes
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
controller.enqueue(result.value);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
controller.error(error);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
cancel(reason) {
|
|
90
|
+
return reader.cancel(reason);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return new Response(body, {
|
|
94
|
+
headers: response.headers,
|
|
95
|
+
status: response.status,
|
|
96
|
+
statusText: response.statusText
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
rspackBrowserPromise = import("@rspack/browser").finally(() => {
|
|
100
|
+
workerGlobal.fetch = originalFetch;
|
|
101
|
+
});
|
|
102
|
+
return rspackBrowserPromise;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/virtual-project.ts
|
|
106
|
+
var normalizeVirtualPath = (path) => path.startsWith("/") ? path : `/${path}`;
|
|
107
|
+
var getVirtualProjectFiles = (project) => Object.fromEntries(Object.entries(project.files).map(([path, contents]) => [
|
|
108
|
+
normalizeVirtualPath(path),
|
|
109
|
+
contents
|
|
110
|
+
]));
|
|
111
|
+
var getVirtualProjectChanges = ({
|
|
112
|
+
previous,
|
|
113
|
+
next
|
|
114
|
+
}) => ({
|
|
115
|
+
modified: Object.keys(next).filter((path) => previous[path] !== next[path]),
|
|
116
|
+
removed: Object.keys(previous).filter((path) => !Object.hasOwn(next, path))
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// src/create-browser-compiler.ts
|
|
120
|
+
var problemToString = (problem) => {
|
|
121
|
+
if (typeof problem === "object" && problem !== null && "message" in problem && typeof problem.message === "string") {
|
|
122
|
+
return problem.message;
|
|
123
|
+
}
|
|
124
|
+
return String(problem);
|
|
125
|
+
};
|
|
126
|
+
var createBrowserCompiler = async ({
|
|
127
|
+
project,
|
|
128
|
+
virtualFiles,
|
|
129
|
+
configure,
|
|
130
|
+
onProgress
|
|
131
|
+
}) => {
|
|
132
|
+
const rspack = await loadRspackBrowser(onProgress);
|
|
133
|
+
const { volume } = rspack.builtinMemFs;
|
|
134
|
+
let currentFiles = getVirtualProjectFiles(project);
|
|
135
|
+
const rootDir = normalizeVirtualPath(project.rootDir);
|
|
136
|
+
const entryPoint = normalizeVirtualPath(project.entryPoint);
|
|
137
|
+
volume.reset();
|
|
138
|
+
volume.fromJSON({ ...virtualFiles, ...currentFiles });
|
|
139
|
+
const compiler = rspack.rspack(configure(rspack));
|
|
140
|
+
const outputPath = compiler.options.output.path;
|
|
141
|
+
let queue = Promise.resolve();
|
|
142
|
+
let disposed = false;
|
|
143
|
+
let disposal = null;
|
|
144
|
+
let initial = true;
|
|
145
|
+
return {
|
|
146
|
+
compile: (nextProject) => {
|
|
147
|
+
if (disposed) {
|
|
148
|
+
return Promise.reject(new Error("The browser compiler was disposed."));
|
|
149
|
+
}
|
|
150
|
+
const nextFiles = getVirtualProjectFiles(nextProject);
|
|
151
|
+
const run = queue.then(() => {
|
|
152
|
+
if (normalizeVirtualPath(nextProject.rootDir) !== rootDir || normalizeVirtualPath(nextProject.entryPoint) !== entryPoint) {
|
|
153
|
+
throw new Error("Create a new compiler when changing rootDir or entryPoint.");
|
|
154
|
+
}
|
|
155
|
+
if (!Object.hasOwn(nextFiles, entryPoint)) {
|
|
156
|
+
throw new Error(`The virtual entry point does not exist: ${entryPoint}`);
|
|
157
|
+
}
|
|
158
|
+
const { modified, removed } = getVirtualProjectChanges({
|
|
159
|
+
previous: currentFiles,
|
|
160
|
+
next: nextFiles
|
|
161
|
+
});
|
|
162
|
+
for (const path of modified) {
|
|
163
|
+
volume.mkdirSync(path.slice(0, path.lastIndexOf("/")) || "/", {
|
|
164
|
+
recursive: true
|
|
165
|
+
});
|
|
166
|
+
volume.writeFileSync(path, nextFiles[path]);
|
|
167
|
+
}
|
|
168
|
+
for (const path of removed) {
|
|
169
|
+
volume.unlinkSync(path);
|
|
170
|
+
}
|
|
171
|
+
currentFiles = nextFiles;
|
|
172
|
+
const modifiedFiles = initial ? undefined : new Set(modified);
|
|
173
|
+
const removedFiles = initial ? undefined : new Set(removed);
|
|
174
|
+
initial = false;
|
|
175
|
+
return new Promise((resolve, reject) => {
|
|
176
|
+
compiler.run((error, stats) => {
|
|
177
|
+
if (error) {
|
|
178
|
+
reject(error);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (!stats) {
|
|
182
|
+
reject(new Error("Rspack returned no compilation stats"));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
const json = stats.toJson({
|
|
187
|
+
all: false,
|
|
188
|
+
assets: true,
|
|
189
|
+
errors: true,
|
|
190
|
+
hash: true,
|
|
191
|
+
modules: true,
|
|
192
|
+
timings: true,
|
|
193
|
+
warnings: true
|
|
194
|
+
});
|
|
195
|
+
const errors = (json.errors ?? []).map(problemToString);
|
|
196
|
+
resolve({
|
|
197
|
+
bundle: errors.length === 0 ? String(volume.readFileSync(`${outputPath}/bundle.js`, "utf8")) : null,
|
|
198
|
+
assets: stats.compilation.getAssets().map(({ name, source }) => ({
|
|
199
|
+
name,
|
|
200
|
+
content: String(source.source())
|
|
201
|
+
})),
|
|
202
|
+
errors,
|
|
203
|
+
warnings: (json.warnings ?? []).map(problemToString),
|
|
204
|
+
hash: json.hash,
|
|
205
|
+
modules: Object.fromEntries((json.modules ?? []).map((module, index) => [
|
|
206
|
+
String(module.id ?? index),
|
|
207
|
+
module.name ?? module.identifier ?? ""
|
|
208
|
+
])),
|
|
209
|
+
time: json.time
|
|
210
|
+
});
|
|
211
|
+
} catch (readError) {
|
|
212
|
+
reject(readError);
|
|
213
|
+
}
|
|
214
|
+
}, { modifiedFiles, removedFiles });
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
queue = run.then(() => {
|
|
218
|
+
return;
|
|
219
|
+
}, () => {
|
|
220
|
+
return;
|
|
221
|
+
});
|
|
222
|
+
return run;
|
|
223
|
+
},
|
|
224
|
+
dispose: () => {
|
|
225
|
+
disposed = true;
|
|
226
|
+
disposal ??= queue.then(() => new Promise((resolve, reject) => {
|
|
227
|
+
compiler.close((error) => {
|
|
228
|
+
if (error) {
|
|
229
|
+
reject(error);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
resolve();
|
|
233
|
+
});
|
|
234
|
+
}));
|
|
235
|
+
return disposal;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
// src/dependency-resolution.ts
|
|
240
|
+
var createBrowserDependencyPlugin = ({
|
|
241
|
+
rspack,
|
|
242
|
+
resolvedUrls,
|
|
243
|
+
resolvedVersions,
|
|
244
|
+
resolvePackage,
|
|
245
|
+
external,
|
|
246
|
+
development
|
|
247
|
+
}) => {
|
|
248
|
+
const postprocess = (url) => {
|
|
249
|
+
if (development) {
|
|
250
|
+
url.searchParams.set("dev", "");
|
|
251
|
+
}
|
|
252
|
+
url.searchParams.set("external", external.join(","));
|
|
253
|
+
};
|
|
254
|
+
return new rspack.BrowserHttpImportEsmPlugin({
|
|
255
|
+
dependencyUrl: ({ request }) => {
|
|
256
|
+
if (request.startsWith(".") || request.startsWith("/") || request.startsWith("http://") || request.startsWith("https://") || request.includes("!")) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const packageName = request.startsWith("@") ? request.split("/").slice(0, 2).join("/") : request.split("/")[0];
|
|
260
|
+
const resolvedUrl = resolvedUrls[packageName] ?? resolvePackage?.(request);
|
|
261
|
+
if (resolvedUrl) {
|
|
262
|
+
return resolvedUrl;
|
|
263
|
+
}
|
|
264
|
+
const version = resolvedVersions[packageName] ?? (packageName.startsWith("@remotion/") ? resolvedVersions.remotion : null) ?? "latest";
|
|
265
|
+
const subpath = request.slice(packageName.length);
|
|
266
|
+
const url = new URL(`${packageName}@${version}${subpath}`, "https://esm.sh/");
|
|
267
|
+
postprocess(url);
|
|
268
|
+
return url.href;
|
|
269
|
+
},
|
|
270
|
+
dependencyVersions: resolvedVersions,
|
|
271
|
+
domain: "https://esm.sh",
|
|
272
|
+
postprocess: ({ url }) => postprocess(url)
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
// src/hmr-assets.ts
|
|
276
|
+
var getAssetName = (nameOrUrl) => {
|
|
277
|
+
const url = new URL(nameOrUrl, "https://remotion.invalid");
|
|
278
|
+
return url.pathname.split("/").at(-1) ?? "";
|
|
279
|
+
};
|
|
280
|
+
var createBrowserHmrAssetManager = ({
|
|
281
|
+
createObjectUrl,
|
|
282
|
+
revokeObjectUrl
|
|
283
|
+
}) => {
|
|
284
|
+
const assets = new Map;
|
|
285
|
+
const updateAssets = (newAssets) => {
|
|
286
|
+
const nextAssetNames = new Set(newAssets.map((asset) => getAssetName(asset.name)));
|
|
287
|
+
for (const [name, asset] of assets) {
|
|
288
|
+
if (nextAssetNames.has(name)) {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (asset.objectUrl) {
|
|
292
|
+
revokeObjectUrl(asset.objectUrl);
|
|
293
|
+
}
|
|
294
|
+
assets.delete(name);
|
|
295
|
+
}
|
|
296
|
+
for (const asset of newAssets) {
|
|
297
|
+
const name = getAssetName(asset.name);
|
|
298
|
+
const previous = assets.get(name);
|
|
299
|
+
if (previous?.objectUrl) {
|
|
300
|
+
revokeObjectUrl(previous.objectUrl);
|
|
301
|
+
}
|
|
302
|
+
assets.set(name, { content: asset.content, objectUrl: null });
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const bridge = {
|
|
306
|
+
getManifest: (name) => {
|
|
307
|
+
const asset = assets.get(getAssetName(name));
|
|
308
|
+
if (!asset) {
|
|
309
|
+
return Promise.resolve(undefined);
|
|
310
|
+
}
|
|
311
|
+
return Promise.resolve(JSON.parse(asset.content));
|
|
312
|
+
},
|
|
313
|
+
resolveScriptUrl: (name) => {
|
|
314
|
+
const assetName = getAssetName(name);
|
|
315
|
+
const asset = assets.get(assetName);
|
|
316
|
+
if (!asset) {
|
|
317
|
+
throw new Error(`Missing browser HMR asset: ${assetName}`);
|
|
318
|
+
}
|
|
319
|
+
asset.objectUrl ??= createObjectUrl(new Blob([asset.content], { type: "text/javascript" }));
|
|
320
|
+
return asset.objectUrl;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
return {
|
|
324
|
+
bridge,
|
|
325
|
+
dispose: () => {
|
|
326
|
+
for (const asset of assets.values()) {
|
|
327
|
+
if (asset.objectUrl) {
|
|
328
|
+
revokeObjectUrl(asset.objectUrl);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
assets.clear();
|
|
332
|
+
},
|
|
333
|
+
updateAssets
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
// src/hmr-plugins.ts
|
|
337
|
+
var createBrowserReactRefreshPlugin = ({
|
|
338
|
+
rspack,
|
|
339
|
+
refreshRuntime,
|
|
340
|
+
refreshUtils
|
|
341
|
+
}) => ({
|
|
342
|
+
name: "remotion-browser-react-refresh",
|
|
343
|
+
apply: (compiler) => {
|
|
344
|
+
new rspack.ProvidePlugin({
|
|
345
|
+
$ReactRefreshRuntime$: refreshRuntime,
|
|
346
|
+
__react_refresh_utils__: refreshUtils
|
|
347
|
+
}).apply(compiler);
|
|
348
|
+
new rspack.DefinePlugin({
|
|
349
|
+
__react_refresh_error_overlay__: false,
|
|
350
|
+
__react_refresh_library__: JSON.stringify("remotion-browser"),
|
|
351
|
+
__react_refresh_socket__: false,
|
|
352
|
+
__reload_on_runtime_errors__: false
|
|
353
|
+
}).apply(compiler);
|
|
354
|
+
compiler.hooks.compilation.tap("remotion-browser-react-refresh", (compilation) => {
|
|
355
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap("remotion-browser-react-refresh", (_chunk, runtimeRequirements) => {
|
|
356
|
+
runtimeRequirements.add(rspack.RuntimeGlobals.moduleCache);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
var createBrowserHmrRuntimePlugin = ({
|
|
362
|
+
rspack,
|
|
363
|
+
bridgeName
|
|
364
|
+
}) => {
|
|
365
|
+
const bridge = `globalThis[${JSON.stringify(bridgeName)}]`;
|
|
366
|
+
|
|
367
|
+
class BrowserHmrManifestRuntimeModule extends rspack.RuntimeModule {
|
|
368
|
+
constructor() {
|
|
369
|
+
super("remotion browser hmr manifest", rspack.RuntimeModule.STAGE_TRIGGER);
|
|
370
|
+
}
|
|
371
|
+
generate() {
|
|
372
|
+
return `${rspack.RuntimeGlobals.hmrDownloadManifest} = function() {
|
|
373
|
+
return ${bridge}.getManifest(${rspack.RuntimeGlobals.getUpdateManifestFilename}());
|
|
374
|
+
};`;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
name: "remotion-browser-hmr-runtime",
|
|
379
|
+
apply: (compiler) => {
|
|
380
|
+
compiler.hooks.compilation.tap("remotion-browser-hmr-runtime", (compilation) => {
|
|
381
|
+
compilation.hooks.runtimeRequirementInTree.for(rspack.RuntimeGlobals.hmrDownloadManifest).tap("remotion-browser-hmr-runtime", (chunk) => {
|
|
382
|
+
compilation.addRuntimeModule(chunk, new BrowserHmrManifestRuntimeModule);
|
|
383
|
+
});
|
|
384
|
+
rspack.RuntimePlugin.getCompilationHooks(compilation).createScript.tap("remotion-browser-hmr-runtime", (code) => `${code}
|
|
385
|
+
script.src = ${bridge}.resolveScriptUrl(script.src);`);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
// src/http-client.ts
|
|
391
|
+
var makeBrowserHttpClient = ({
|
|
392
|
+
fetchImplementation
|
|
393
|
+
}) => {
|
|
394
|
+
const responseCache = new Map;
|
|
395
|
+
return (url, headers) => {
|
|
396
|
+
const cacheKey = JSON.stringify([
|
|
397
|
+
url,
|
|
398
|
+
Object.entries(headers).sort(([left], [right]) => left.localeCompare(right))
|
|
399
|
+
]);
|
|
400
|
+
const cached = responseCache.get(cacheKey);
|
|
401
|
+
if (cached) {
|
|
402
|
+
return cached;
|
|
403
|
+
}
|
|
404
|
+
const responsePromise = fetchImplementation(url, { headers }).then(async (response) => {
|
|
405
|
+
const responseHeaders = {};
|
|
406
|
+
response.headers.forEach((value, key) => {
|
|
407
|
+
responseHeaders[key] = value;
|
|
408
|
+
});
|
|
409
|
+
return {
|
|
410
|
+
body: new Uint8Array(await response.arrayBuffer()),
|
|
411
|
+
headers: responseHeaders,
|
|
412
|
+
status: response.status
|
|
413
|
+
};
|
|
414
|
+
}).catch((error) => {
|
|
415
|
+
responseCache.delete(cacheKey);
|
|
416
|
+
throw error;
|
|
417
|
+
});
|
|
418
|
+
responseCache.set(cacheKey, responsePromise);
|
|
419
|
+
return responsePromise;
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
// src/refresh-virtual-files.ts
|
|
423
|
+
var getBrowserReactRefreshVirtualFiles = ({
|
|
424
|
+
entry,
|
|
425
|
+
runtime,
|
|
426
|
+
utils
|
|
427
|
+
}) => {
|
|
428
|
+
if (false) {}
|
|
429
|
+
return {
|
|
430
|
+
[entry]: { entry: `var RefreshRuntime = require('react-refresh/runtime');
|
|
431
|
+
var safeThis = (function () {
|
|
432
|
+
// copied from core-js-pure/features/global-this
|
|
433
|
+
'use strict';
|
|
434
|
+
|
|
435
|
+
var check = function (it) {
|
|
436
|
+
return it && it.Math == Math && it;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
440
|
+
// eslint-disable-next-line es/no-global-this -- safe
|
|
441
|
+
return (
|
|
442
|
+
check(typeof globalThis == 'object' && globalThis) ||
|
|
443
|
+
check(typeof window == 'object' && window) ||
|
|
444
|
+
// eslint-disable-next-line no-restricted-globals -- safe
|
|
445
|
+
check(typeof self == 'object' && self) ||
|
|
446
|
+
check(typeof __webpack_require__.g == 'object' && __webpack_require__.g) ||
|
|
447
|
+
// eslint-disable-next-line no-new-func -- fallback
|
|
448
|
+
(function () {
|
|
449
|
+
return this;
|
|
450
|
+
})() ||
|
|
451
|
+
this ||
|
|
452
|
+
Function('return this')()
|
|
453
|
+
);
|
|
454
|
+
})();
|
|
455
|
+
|
|
456
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
457
|
+
if (typeof safeThis !== 'undefined') {
|
|
458
|
+
var $RefreshInjected$ = '__reactRefreshInjected';
|
|
459
|
+
// Namespace the injected flag (if necessary) for monorepo compatibility
|
|
460
|
+
if (
|
|
461
|
+
typeof __react_refresh_library__ !== 'undefined' &&
|
|
462
|
+
__react_refresh_library__
|
|
463
|
+
) {
|
|
464
|
+
$RefreshInjected$ += '_' + __react_refresh_library__;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Only inject the runtime if it hasn't been injected
|
|
468
|
+
if (!safeThis[$RefreshInjected$]) {
|
|
469
|
+
RefreshRuntime.injectIntoGlobalHook(safeThis);
|
|
470
|
+
|
|
471
|
+
// Empty implementation to avoid "ReferenceError: variable is not defined" in module which didn't pass builtin:react-refresh-loader
|
|
472
|
+
safeThis.$RefreshSig$ = () => (type) => type;
|
|
473
|
+
safeThis.$RefreshReg$ = () => {};
|
|
474
|
+
|
|
475
|
+
// Mark the runtime as injected to prevent double-injection
|
|
476
|
+
safeThis[$RefreshInjected$] = true;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
`, runtime: `const RefreshUtils = require('./refreshUtils');
|
|
481
|
+
const RefreshRuntime = require('react-refresh/runtime');
|
|
482
|
+
|
|
483
|
+
function refresh(moduleId, webpackHot) {
|
|
484
|
+
const currentExports = RefreshUtils.getModuleExports(moduleId);
|
|
485
|
+
const fn = (exports) => {
|
|
486
|
+
var errorOverlay;
|
|
487
|
+
if (typeof __react_refresh_error_overlay__ !== 'undefined') {
|
|
488
|
+
errorOverlay = __react_refresh_error_overlay__;
|
|
489
|
+
}
|
|
490
|
+
var testMode;
|
|
491
|
+
if (typeof __react_refresh_test__ !== 'undefined') {
|
|
492
|
+
testMode = __react_refresh_test__;
|
|
493
|
+
}
|
|
494
|
+
RefreshUtils.executeRuntime(
|
|
495
|
+
exports,
|
|
496
|
+
moduleId,
|
|
497
|
+
webpackHot,
|
|
498
|
+
errorOverlay,
|
|
499
|
+
testMode,
|
|
500
|
+
);
|
|
501
|
+
};
|
|
502
|
+
if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
|
|
503
|
+
currentExports.then(fn);
|
|
504
|
+
} else {
|
|
505
|
+
fn(currentExports);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
module.exports = {
|
|
510
|
+
refresh,
|
|
511
|
+
register: RefreshRuntime.register,
|
|
512
|
+
createSignatureFunctionForTransform:
|
|
513
|
+
RefreshRuntime.createSignatureFunctionForTransform,
|
|
514
|
+
};
|
|
515
|
+
`, utils: `/* global __webpack_require__ */
|
|
516
|
+
var Refresh = require('react-refresh/runtime');
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Extracts exports from a webpack module object.
|
|
520
|
+
* @param {string} moduleId A Webpack module ID.
|
|
521
|
+
* @returns {*} An exports object from the module.
|
|
522
|
+
*/
|
|
523
|
+
function getModuleExports(moduleId) {
|
|
524
|
+
if (typeof moduleId === 'undefined') {
|
|
525
|
+
// \`moduleId\` is unavailable, which indicates that this module is not in the cache,
|
|
526
|
+
// which means we won't be able to capture any exports,
|
|
527
|
+
// and thus they cannot be refreshed safely.
|
|
528
|
+
// These are likely runtime or dynamically generated modules.
|
|
529
|
+
return {};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
var maybeModule = __webpack_require__.c[moduleId];
|
|
533
|
+
if (typeof maybeModule === 'undefined') {
|
|
534
|
+
// \`moduleId\` is available but the module in cache is unavailable,
|
|
535
|
+
// which indicates the module is somehow corrupted (e.g. broken Webpacak \`module\` globals).
|
|
536
|
+
// We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
|
|
537
|
+
console.warn(
|
|
538
|
+
'[React Refresh] Failed to get exports for module: ' + moduleId + '.',
|
|
539
|
+
);
|
|
540
|
+
return {};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
var exportsOrPromise = maybeModule.exports;
|
|
544
|
+
if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
|
|
545
|
+
return exportsOrPromise.then(function (exports) {
|
|
546
|
+
return exports;
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
return exportsOrPromise;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Calculates the signature of a React refresh boundary.
|
|
554
|
+
* If this signature changes, it's unsafe to accept the boundary.
|
|
555
|
+
*
|
|
556
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).
|
|
557
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
558
|
+
* @returns {string[]} A React refresh boundary signature array.
|
|
559
|
+
*/
|
|
560
|
+
function getReactRefreshBoundarySignature(moduleExports) {
|
|
561
|
+
var signature = [];
|
|
562
|
+
signature.push(Refresh.getFamilyByType(moduleExports));
|
|
563
|
+
|
|
564
|
+
if (moduleExports == null || typeof moduleExports !== 'object') {
|
|
565
|
+
// Exit if we can't iterate over exports.
|
|
566
|
+
return signature;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
for (var key in moduleExports) {
|
|
570
|
+
if (key === '__esModule') {
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
signature.push(key);
|
|
575
|
+
signature.push(Refresh.getFamilyByType(moduleExports[key]));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
return signature;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Creates a helper that performs a delayed React refresh.
|
|
583
|
+
* @returns {function(function(): void): void} A debounced React refresh function.
|
|
584
|
+
*/
|
|
585
|
+
function createDebounceUpdate() {
|
|
586
|
+
/**
|
|
587
|
+
* A cached setTimeout handler.
|
|
588
|
+
* @type {number | undefined}
|
|
589
|
+
*/
|
|
590
|
+
var refreshTimeout;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Performs react refresh on a delay and clears the error overlay.
|
|
594
|
+
* @param {function(): void} callback
|
|
595
|
+
* @returns {void}
|
|
596
|
+
*/
|
|
597
|
+
function enqueueUpdate(callback) {
|
|
598
|
+
if (typeof refreshTimeout === 'undefined') {
|
|
599
|
+
refreshTimeout = setTimeout(function () {
|
|
600
|
+
refreshTimeout = undefined;
|
|
601
|
+
Refresh.performReactRefresh();
|
|
602
|
+
callback();
|
|
603
|
+
}, 30);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return enqueueUpdate;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Checks if all exports are likely a React component.
|
|
612
|
+
*
|
|
613
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).
|
|
614
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
615
|
+
* @returns {boolean} Whether the exports are React component like.
|
|
616
|
+
*/
|
|
617
|
+
function isReactRefreshBoundary(moduleExports) {
|
|
618
|
+
if (Refresh.isLikelyComponentType(moduleExports)) {
|
|
619
|
+
return true;
|
|
620
|
+
}
|
|
621
|
+
if (
|
|
622
|
+
moduleExports === undefined ||
|
|
623
|
+
moduleExports === null ||
|
|
624
|
+
typeof moduleExports !== 'object'
|
|
625
|
+
) {
|
|
626
|
+
// Exit if we can't iterate over exports.
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
var hasExports = false;
|
|
631
|
+
var areAllExportsComponents = true;
|
|
632
|
+
for (var key in moduleExports) {
|
|
633
|
+
hasExports = true;
|
|
634
|
+
|
|
635
|
+
// This is the ES Module indicator flag
|
|
636
|
+
if (key === '__esModule') {
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// We can (and have to) safely execute getters here,
|
|
641
|
+
// as Webpack manually assigns harmony exports to getters,
|
|
642
|
+
// without any side-effects attached.
|
|
643
|
+
// Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
|
|
644
|
+
var exportValue = moduleExports[key];
|
|
645
|
+
if (!Refresh.isLikelyComponentType(exportValue)) {
|
|
646
|
+
areAllExportsComponents = false;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
return hasExports && areAllExportsComponents;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Checks if exports are likely a React component and registers them.
|
|
655
|
+
*
|
|
656
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).
|
|
657
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
658
|
+
* @param {string} moduleId A Webpack module ID.
|
|
659
|
+
* @returns {void}
|
|
660
|
+
*/
|
|
661
|
+
function registerExportsForReactRefresh(moduleExports, moduleId) {
|
|
662
|
+
if (Refresh.isLikelyComponentType(moduleExports)) {
|
|
663
|
+
// Register module.exports if it is likely a component
|
|
664
|
+
Refresh.register(moduleExports, moduleId + ' %exports%');
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if (
|
|
668
|
+
moduleExports === undefined ||
|
|
669
|
+
moduleExports === null ||
|
|
670
|
+
typeof moduleExports !== 'object'
|
|
671
|
+
) {
|
|
672
|
+
// Exit if we can't iterate over the exports.
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
for (var key in moduleExports) {
|
|
677
|
+
// Skip registering the ES Module indicator
|
|
678
|
+
if (key === '__esModule') {
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
var exportValue = moduleExports[key];
|
|
683
|
+
if (Refresh.isLikelyComponentType(exportValue)) {
|
|
684
|
+
var typeID = moduleId + ' %exports% ' + key;
|
|
685
|
+
Refresh.register(exportValue, typeID);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Compares previous and next module objects to check for mutated boundaries.
|
|
692
|
+
*
|
|
693
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).
|
|
694
|
+
* @param {*} prevExports The current Webpack module exports object.
|
|
695
|
+
* @param {*} nextExports The next Webpack module exports object.
|
|
696
|
+
* @returns {boolean} Whether the React refresh boundary should be invalidated.
|
|
697
|
+
*/
|
|
698
|
+
function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
|
|
699
|
+
var prevSignature = getReactRefreshBoundarySignature(prevExports);
|
|
700
|
+
var nextSignature = getReactRefreshBoundarySignature(nextExports);
|
|
701
|
+
|
|
702
|
+
if (prevSignature.length !== nextSignature.length) {
|
|
703
|
+
return true;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
for (var i = 0; i < nextSignature.length; i += 1) {
|
|
707
|
+
if (prevSignature[i] !== nextSignature[i]) {
|
|
708
|
+
return true;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
return false;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
var enqueueUpdate = createDebounceUpdate();
|
|
716
|
+
|
|
717
|
+
function executeRuntime(
|
|
718
|
+
moduleExports,
|
|
719
|
+
moduleId,
|
|
720
|
+
webpackHot,
|
|
721
|
+
refreshOverlay,
|
|
722
|
+
isTest,
|
|
723
|
+
) {
|
|
724
|
+
registerExportsForReactRefresh(moduleExports, moduleId);
|
|
725
|
+
|
|
726
|
+
if (webpackHot) {
|
|
727
|
+
var isHotUpdate = !!webpackHot.data;
|
|
728
|
+
var prevExports;
|
|
729
|
+
if (isHotUpdate) {
|
|
730
|
+
prevExports = webpackHot.data.prevExports;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (isReactRefreshBoundary(moduleExports)) {
|
|
734
|
+
webpackHot.dispose(
|
|
735
|
+
/**
|
|
736
|
+
* A callback to performs a full refresh if React has unrecoverable errors,
|
|
737
|
+
* and also caches the to-be-disposed module.
|
|
738
|
+
* @param {*} data A hot module data object from Webpack HMR.
|
|
739
|
+
* @returns {void}
|
|
740
|
+
*/
|
|
741
|
+
function hotDisposeCallback(data) {
|
|
742
|
+
// We have to mutate the data object to get data registered and cached
|
|
743
|
+
data.prevExports = moduleExports;
|
|
744
|
+
},
|
|
745
|
+
);
|
|
746
|
+
webpackHot.accept(
|
|
747
|
+
/**
|
|
748
|
+
* An error handler to allow self-recovering behaviours.
|
|
749
|
+
* @param {Error} error An error occurred during evaluation of a module.
|
|
750
|
+
* @returns {void}
|
|
751
|
+
*/
|
|
752
|
+
function hotErrorHandler(error) {
|
|
753
|
+
console.error(error);
|
|
754
|
+
if (
|
|
755
|
+
__reload_on_runtime_errors__ &&
|
|
756
|
+
isUnrecoverableRuntimeError(error)
|
|
757
|
+
) {
|
|
758
|
+
location.reload();
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
|
|
763
|
+
refreshOverlay.handleRuntimeError(error);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (typeof isTest !== 'undefined' && isTest) {
|
|
767
|
+
if (window.onHotAcceptError) {
|
|
768
|
+
window.onHotAcceptError(error.message);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
__webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
|
|
773
|
+
},
|
|
774
|
+
);
|
|
775
|
+
|
|
776
|
+
if (isHotUpdate) {
|
|
777
|
+
if (
|
|
778
|
+
isReactRefreshBoundary(prevExports) &&
|
|
779
|
+
shouldInvalidateReactRefreshBoundary(prevExports, moduleExports)
|
|
780
|
+
) {
|
|
781
|
+
webpackHot.invalidate();
|
|
782
|
+
} else {
|
|
783
|
+
enqueueUpdate(
|
|
784
|
+
/**
|
|
785
|
+
* A function to dismiss the error overlay after performing React refresh.
|
|
786
|
+
* @returns {void}
|
|
787
|
+
*/
|
|
788
|
+
function updateCallback() {
|
|
789
|
+
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
|
|
790
|
+
refreshOverlay.clearRuntimeErrors();
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
} else {
|
|
797
|
+
if (isHotUpdate && typeof prevExports !== 'undefined') {
|
|
798
|
+
webpackHot.invalidate();
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function isUnrecoverableRuntimeError(error) {
|
|
805
|
+
return error.message.startsWith('RuntimeError: factory is undefined');
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
module.exports = Object.freeze({
|
|
809
|
+
enqueueUpdate: enqueueUpdate,
|
|
810
|
+
executeRuntime: executeRuntime,
|
|
811
|
+
getModuleExports: getModuleExports,
|
|
812
|
+
isReactRefreshBoundary: isReactRefreshBoundary,
|
|
813
|
+
shouldInvalidateReactRefreshBoundary: shouldInvalidateReactRefreshBoundary,
|
|
814
|
+
registerExportsForReactRefresh: registerExportsForReactRefresh,
|
|
815
|
+
});
|
|
816
|
+
` }.entry,
|
|
817
|
+
[runtime]: { entry: `var RefreshRuntime = require('react-refresh/runtime');
|
|
818
|
+
var safeThis = (function () {
|
|
819
|
+
// copied from core-js-pure/features/global-this
|
|
820
|
+
'use strict';
|
|
821
|
+
|
|
822
|
+
var check = function (it) {
|
|
823
|
+
return it && it.Math == Math && it;
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
827
|
+
// eslint-disable-next-line es/no-global-this -- safe
|
|
828
|
+
return (
|
|
829
|
+
check(typeof globalThis == 'object' && globalThis) ||
|
|
830
|
+
check(typeof window == 'object' && window) ||
|
|
831
|
+
// eslint-disable-next-line no-restricted-globals -- safe
|
|
832
|
+
check(typeof self == 'object' && self) ||
|
|
833
|
+
check(typeof __webpack_require__.g == 'object' && __webpack_require__.g) ||
|
|
834
|
+
// eslint-disable-next-line no-new-func -- fallback
|
|
835
|
+
(function () {
|
|
836
|
+
return this;
|
|
837
|
+
})() ||
|
|
838
|
+
this ||
|
|
839
|
+
Function('return this')()
|
|
840
|
+
);
|
|
841
|
+
})();
|
|
842
|
+
|
|
843
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
844
|
+
if (typeof safeThis !== 'undefined') {
|
|
845
|
+
var $RefreshInjected$ = '__reactRefreshInjected';
|
|
846
|
+
// Namespace the injected flag (if necessary) for monorepo compatibility
|
|
847
|
+
if (
|
|
848
|
+
typeof __react_refresh_library__ !== 'undefined' &&
|
|
849
|
+
__react_refresh_library__
|
|
850
|
+
) {
|
|
851
|
+
$RefreshInjected$ += '_' + __react_refresh_library__;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// Only inject the runtime if it hasn't been injected
|
|
855
|
+
if (!safeThis[$RefreshInjected$]) {
|
|
856
|
+
RefreshRuntime.injectIntoGlobalHook(safeThis);
|
|
857
|
+
|
|
858
|
+
// Empty implementation to avoid "ReferenceError: variable is not defined" in module which didn't pass builtin:react-refresh-loader
|
|
859
|
+
safeThis.$RefreshSig$ = () => (type) => type;
|
|
860
|
+
safeThis.$RefreshReg$ = () => {};
|
|
861
|
+
|
|
862
|
+
// Mark the runtime as injected to prevent double-injection
|
|
863
|
+
safeThis[$RefreshInjected$] = true;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
`, runtime: `const RefreshUtils = require('./refreshUtils');
|
|
868
|
+
const RefreshRuntime = require('react-refresh/runtime');
|
|
869
|
+
|
|
870
|
+
function refresh(moduleId, webpackHot) {
|
|
871
|
+
const currentExports = RefreshUtils.getModuleExports(moduleId);
|
|
872
|
+
const fn = (exports) => {
|
|
873
|
+
var errorOverlay;
|
|
874
|
+
if (typeof __react_refresh_error_overlay__ !== 'undefined') {
|
|
875
|
+
errorOverlay = __react_refresh_error_overlay__;
|
|
876
|
+
}
|
|
877
|
+
var testMode;
|
|
878
|
+
if (typeof __react_refresh_test__ !== 'undefined') {
|
|
879
|
+
testMode = __react_refresh_test__;
|
|
880
|
+
}
|
|
881
|
+
RefreshUtils.executeRuntime(
|
|
882
|
+
exports,
|
|
883
|
+
moduleId,
|
|
884
|
+
webpackHot,
|
|
885
|
+
errorOverlay,
|
|
886
|
+
testMode,
|
|
887
|
+
);
|
|
888
|
+
};
|
|
889
|
+
if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
|
|
890
|
+
currentExports.then(fn);
|
|
891
|
+
} else {
|
|
892
|
+
fn(currentExports);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
module.exports = {
|
|
897
|
+
refresh,
|
|
898
|
+
register: RefreshRuntime.register,
|
|
899
|
+
createSignatureFunctionForTransform:
|
|
900
|
+
RefreshRuntime.createSignatureFunctionForTransform,
|
|
901
|
+
};
|
|
902
|
+
`, utils: `/* global __webpack_require__ */
|
|
903
|
+
var Refresh = require('react-refresh/runtime');
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Extracts exports from a webpack module object.
|
|
907
|
+
* @param {string} moduleId A Webpack module ID.
|
|
908
|
+
* @returns {*} An exports object from the module.
|
|
909
|
+
*/
|
|
910
|
+
function getModuleExports(moduleId) {
|
|
911
|
+
if (typeof moduleId === 'undefined') {
|
|
912
|
+
// \`moduleId\` is unavailable, which indicates that this module is not in the cache,
|
|
913
|
+
// which means we won't be able to capture any exports,
|
|
914
|
+
// and thus they cannot be refreshed safely.
|
|
915
|
+
// These are likely runtime or dynamically generated modules.
|
|
916
|
+
return {};
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
var maybeModule = __webpack_require__.c[moduleId];
|
|
920
|
+
if (typeof maybeModule === 'undefined') {
|
|
921
|
+
// \`moduleId\` is available but the module in cache is unavailable,
|
|
922
|
+
// which indicates the module is somehow corrupted (e.g. broken Webpacak \`module\` globals).
|
|
923
|
+
// We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
|
|
924
|
+
console.warn(
|
|
925
|
+
'[React Refresh] Failed to get exports for module: ' + moduleId + '.',
|
|
926
|
+
);
|
|
927
|
+
return {};
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
var exportsOrPromise = maybeModule.exports;
|
|
931
|
+
if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
|
|
932
|
+
return exportsOrPromise.then(function (exports) {
|
|
933
|
+
return exports;
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
return exportsOrPromise;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Calculates the signature of a React refresh boundary.
|
|
941
|
+
* If this signature changes, it's unsafe to accept the boundary.
|
|
942
|
+
*
|
|
943
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).
|
|
944
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
945
|
+
* @returns {string[]} A React refresh boundary signature array.
|
|
946
|
+
*/
|
|
947
|
+
function getReactRefreshBoundarySignature(moduleExports) {
|
|
948
|
+
var signature = [];
|
|
949
|
+
signature.push(Refresh.getFamilyByType(moduleExports));
|
|
950
|
+
|
|
951
|
+
if (moduleExports == null || typeof moduleExports !== 'object') {
|
|
952
|
+
// Exit if we can't iterate over exports.
|
|
953
|
+
return signature;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
for (var key in moduleExports) {
|
|
957
|
+
if (key === '__esModule') {
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
signature.push(key);
|
|
962
|
+
signature.push(Refresh.getFamilyByType(moduleExports[key]));
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
return signature;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Creates a helper that performs a delayed React refresh.
|
|
970
|
+
* @returns {function(function(): void): void} A debounced React refresh function.
|
|
971
|
+
*/
|
|
972
|
+
function createDebounceUpdate() {
|
|
973
|
+
/**
|
|
974
|
+
* A cached setTimeout handler.
|
|
975
|
+
* @type {number | undefined}
|
|
976
|
+
*/
|
|
977
|
+
var refreshTimeout;
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Performs react refresh on a delay and clears the error overlay.
|
|
981
|
+
* @param {function(): void} callback
|
|
982
|
+
* @returns {void}
|
|
983
|
+
*/
|
|
984
|
+
function enqueueUpdate(callback) {
|
|
985
|
+
if (typeof refreshTimeout === 'undefined') {
|
|
986
|
+
refreshTimeout = setTimeout(function () {
|
|
987
|
+
refreshTimeout = undefined;
|
|
988
|
+
Refresh.performReactRefresh();
|
|
989
|
+
callback();
|
|
990
|
+
}, 30);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
return enqueueUpdate;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* Checks if all exports are likely a React component.
|
|
999
|
+
*
|
|
1000
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).
|
|
1001
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
1002
|
+
* @returns {boolean} Whether the exports are React component like.
|
|
1003
|
+
*/
|
|
1004
|
+
function isReactRefreshBoundary(moduleExports) {
|
|
1005
|
+
if (Refresh.isLikelyComponentType(moduleExports)) {
|
|
1006
|
+
return true;
|
|
1007
|
+
}
|
|
1008
|
+
if (
|
|
1009
|
+
moduleExports === undefined ||
|
|
1010
|
+
moduleExports === null ||
|
|
1011
|
+
typeof moduleExports !== 'object'
|
|
1012
|
+
) {
|
|
1013
|
+
// Exit if we can't iterate over exports.
|
|
1014
|
+
return false;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
var hasExports = false;
|
|
1018
|
+
var areAllExportsComponents = true;
|
|
1019
|
+
for (var key in moduleExports) {
|
|
1020
|
+
hasExports = true;
|
|
1021
|
+
|
|
1022
|
+
// This is the ES Module indicator flag
|
|
1023
|
+
if (key === '__esModule') {
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// We can (and have to) safely execute getters here,
|
|
1028
|
+
// as Webpack manually assigns harmony exports to getters,
|
|
1029
|
+
// without any side-effects attached.
|
|
1030
|
+
// Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
|
|
1031
|
+
var exportValue = moduleExports[key];
|
|
1032
|
+
if (!Refresh.isLikelyComponentType(exportValue)) {
|
|
1033
|
+
areAllExportsComponents = false;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
return hasExports && areAllExportsComponents;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Checks if exports are likely a React component and registers them.
|
|
1042
|
+
*
|
|
1043
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).
|
|
1044
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
1045
|
+
* @param {string} moduleId A Webpack module ID.
|
|
1046
|
+
* @returns {void}
|
|
1047
|
+
*/
|
|
1048
|
+
function registerExportsForReactRefresh(moduleExports, moduleId) {
|
|
1049
|
+
if (Refresh.isLikelyComponentType(moduleExports)) {
|
|
1050
|
+
// Register module.exports if it is likely a component
|
|
1051
|
+
Refresh.register(moduleExports, moduleId + ' %exports%');
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
if (
|
|
1055
|
+
moduleExports === undefined ||
|
|
1056
|
+
moduleExports === null ||
|
|
1057
|
+
typeof moduleExports !== 'object'
|
|
1058
|
+
) {
|
|
1059
|
+
// Exit if we can't iterate over the exports.
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
for (var key in moduleExports) {
|
|
1064
|
+
// Skip registering the ES Module indicator
|
|
1065
|
+
if (key === '__esModule') {
|
|
1066
|
+
continue;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
var exportValue = moduleExports[key];
|
|
1070
|
+
if (Refresh.isLikelyComponentType(exportValue)) {
|
|
1071
|
+
var typeID = moduleId + ' %exports% ' + key;
|
|
1072
|
+
Refresh.register(exportValue, typeID);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Compares previous and next module objects to check for mutated boundaries.
|
|
1079
|
+
*
|
|
1080
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).
|
|
1081
|
+
* @param {*} prevExports The current Webpack module exports object.
|
|
1082
|
+
* @param {*} nextExports The next Webpack module exports object.
|
|
1083
|
+
* @returns {boolean} Whether the React refresh boundary should be invalidated.
|
|
1084
|
+
*/
|
|
1085
|
+
function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
|
|
1086
|
+
var prevSignature = getReactRefreshBoundarySignature(prevExports);
|
|
1087
|
+
var nextSignature = getReactRefreshBoundarySignature(nextExports);
|
|
1088
|
+
|
|
1089
|
+
if (prevSignature.length !== nextSignature.length) {
|
|
1090
|
+
return true;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
for (var i = 0; i < nextSignature.length; i += 1) {
|
|
1094
|
+
if (prevSignature[i] !== nextSignature[i]) {
|
|
1095
|
+
return true;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
return false;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
var enqueueUpdate = createDebounceUpdate();
|
|
1103
|
+
|
|
1104
|
+
function executeRuntime(
|
|
1105
|
+
moduleExports,
|
|
1106
|
+
moduleId,
|
|
1107
|
+
webpackHot,
|
|
1108
|
+
refreshOverlay,
|
|
1109
|
+
isTest,
|
|
1110
|
+
) {
|
|
1111
|
+
registerExportsForReactRefresh(moduleExports, moduleId);
|
|
1112
|
+
|
|
1113
|
+
if (webpackHot) {
|
|
1114
|
+
var isHotUpdate = !!webpackHot.data;
|
|
1115
|
+
var prevExports;
|
|
1116
|
+
if (isHotUpdate) {
|
|
1117
|
+
prevExports = webpackHot.data.prevExports;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
if (isReactRefreshBoundary(moduleExports)) {
|
|
1121
|
+
webpackHot.dispose(
|
|
1122
|
+
/**
|
|
1123
|
+
* A callback to performs a full refresh if React has unrecoverable errors,
|
|
1124
|
+
* and also caches the to-be-disposed module.
|
|
1125
|
+
* @param {*} data A hot module data object from Webpack HMR.
|
|
1126
|
+
* @returns {void}
|
|
1127
|
+
*/
|
|
1128
|
+
function hotDisposeCallback(data) {
|
|
1129
|
+
// We have to mutate the data object to get data registered and cached
|
|
1130
|
+
data.prevExports = moduleExports;
|
|
1131
|
+
},
|
|
1132
|
+
);
|
|
1133
|
+
webpackHot.accept(
|
|
1134
|
+
/**
|
|
1135
|
+
* An error handler to allow self-recovering behaviours.
|
|
1136
|
+
* @param {Error} error An error occurred during evaluation of a module.
|
|
1137
|
+
* @returns {void}
|
|
1138
|
+
*/
|
|
1139
|
+
function hotErrorHandler(error) {
|
|
1140
|
+
console.error(error);
|
|
1141
|
+
if (
|
|
1142
|
+
__reload_on_runtime_errors__ &&
|
|
1143
|
+
isUnrecoverableRuntimeError(error)
|
|
1144
|
+
) {
|
|
1145
|
+
location.reload();
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
|
|
1150
|
+
refreshOverlay.handleRuntimeError(error);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
if (typeof isTest !== 'undefined' && isTest) {
|
|
1154
|
+
if (window.onHotAcceptError) {
|
|
1155
|
+
window.onHotAcceptError(error.message);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
__webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
|
|
1160
|
+
},
|
|
1161
|
+
);
|
|
1162
|
+
|
|
1163
|
+
if (isHotUpdate) {
|
|
1164
|
+
if (
|
|
1165
|
+
isReactRefreshBoundary(prevExports) &&
|
|
1166
|
+
shouldInvalidateReactRefreshBoundary(prevExports, moduleExports)
|
|
1167
|
+
) {
|
|
1168
|
+
webpackHot.invalidate();
|
|
1169
|
+
} else {
|
|
1170
|
+
enqueueUpdate(
|
|
1171
|
+
/**
|
|
1172
|
+
* A function to dismiss the error overlay after performing React refresh.
|
|
1173
|
+
* @returns {void}
|
|
1174
|
+
*/
|
|
1175
|
+
function updateCallback() {
|
|
1176
|
+
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
|
|
1177
|
+
refreshOverlay.clearRuntimeErrors();
|
|
1178
|
+
}
|
|
1179
|
+
},
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
} else {
|
|
1184
|
+
if (isHotUpdate && typeof prevExports !== 'undefined') {
|
|
1185
|
+
webpackHot.invalidate();
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
function isUnrecoverableRuntimeError(error) {
|
|
1192
|
+
return error.message.startsWith('RuntimeError: factory is undefined');
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
module.exports = Object.freeze({
|
|
1196
|
+
enqueueUpdate: enqueueUpdate,
|
|
1197
|
+
executeRuntime: executeRuntime,
|
|
1198
|
+
getModuleExports: getModuleExports,
|
|
1199
|
+
isReactRefreshBoundary: isReactRefreshBoundary,
|
|
1200
|
+
shouldInvalidateReactRefreshBoundary: shouldInvalidateReactRefreshBoundary,
|
|
1201
|
+
registerExportsForReactRefresh: registerExportsForReactRefresh,
|
|
1202
|
+
});
|
|
1203
|
+
` }.runtime,
|
|
1204
|
+
[utils]: { entry: `var RefreshRuntime = require('react-refresh/runtime');
|
|
1205
|
+
var safeThis = (function () {
|
|
1206
|
+
// copied from core-js-pure/features/global-this
|
|
1207
|
+
'use strict';
|
|
1208
|
+
|
|
1209
|
+
var check = function (it) {
|
|
1210
|
+
return it && it.Math == Math && it;
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
1214
|
+
// eslint-disable-next-line es/no-global-this -- safe
|
|
1215
|
+
return (
|
|
1216
|
+
check(typeof globalThis == 'object' && globalThis) ||
|
|
1217
|
+
check(typeof window == 'object' && window) ||
|
|
1218
|
+
// eslint-disable-next-line no-restricted-globals -- safe
|
|
1219
|
+
check(typeof self == 'object' && self) ||
|
|
1220
|
+
check(typeof __webpack_require__.g == 'object' && __webpack_require__.g) ||
|
|
1221
|
+
// eslint-disable-next-line no-new-func -- fallback
|
|
1222
|
+
(function () {
|
|
1223
|
+
return this;
|
|
1224
|
+
})() ||
|
|
1225
|
+
this ||
|
|
1226
|
+
Function('return this')()
|
|
1227
|
+
);
|
|
1228
|
+
})();
|
|
1229
|
+
|
|
1230
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1231
|
+
if (typeof safeThis !== 'undefined') {
|
|
1232
|
+
var $RefreshInjected$ = '__reactRefreshInjected';
|
|
1233
|
+
// Namespace the injected flag (if necessary) for monorepo compatibility
|
|
1234
|
+
if (
|
|
1235
|
+
typeof __react_refresh_library__ !== 'undefined' &&
|
|
1236
|
+
__react_refresh_library__
|
|
1237
|
+
) {
|
|
1238
|
+
$RefreshInjected$ += '_' + __react_refresh_library__;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// Only inject the runtime if it hasn't been injected
|
|
1242
|
+
if (!safeThis[$RefreshInjected$]) {
|
|
1243
|
+
RefreshRuntime.injectIntoGlobalHook(safeThis);
|
|
1244
|
+
|
|
1245
|
+
// Empty implementation to avoid "ReferenceError: variable is not defined" in module which didn't pass builtin:react-refresh-loader
|
|
1246
|
+
safeThis.$RefreshSig$ = () => (type) => type;
|
|
1247
|
+
safeThis.$RefreshReg$ = () => {};
|
|
1248
|
+
|
|
1249
|
+
// Mark the runtime as injected to prevent double-injection
|
|
1250
|
+
safeThis[$RefreshInjected$] = true;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
`, runtime: `const RefreshUtils = require('./refreshUtils');
|
|
1255
|
+
const RefreshRuntime = require('react-refresh/runtime');
|
|
1256
|
+
|
|
1257
|
+
function refresh(moduleId, webpackHot) {
|
|
1258
|
+
const currentExports = RefreshUtils.getModuleExports(moduleId);
|
|
1259
|
+
const fn = (exports) => {
|
|
1260
|
+
var errorOverlay;
|
|
1261
|
+
if (typeof __react_refresh_error_overlay__ !== 'undefined') {
|
|
1262
|
+
errorOverlay = __react_refresh_error_overlay__;
|
|
1263
|
+
}
|
|
1264
|
+
var testMode;
|
|
1265
|
+
if (typeof __react_refresh_test__ !== 'undefined') {
|
|
1266
|
+
testMode = __react_refresh_test__;
|
|
1267
|
+
}
|
|
1268
|
+
RefreshUtils.executeRuntime(
|
|
1269
|
+
exports,
|
|
1270
|
+
moduleId,
|
|
1271
|
+
webpackHot,
|
|
1272
|
+
errorOverlay,
|
|
1273
|
+
testMode,
|
|
1274
|
+
);
|
|
1275
|
+
};
|
|
1276
|
+
if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
|
|
1277
|
+
currentExports.then(fn);
|
|
1278
|
+
} else {
|
|
1279
|
+
fn(currentExports);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
module.exports = {
|
|
1284
|
+
refresh,
|
|
1285
|
+
register: RefreshRuntime.register,
|
|
1286
|
+
createSignatureFunctionForTransform:
|
|
1287
|
+
RefreshRuntime.createSignatureFunctionForTransform,
|
|
1288
|
+
};
|
|
1289
|
+
`, utils: `/* global __webpack_require__ */
|
|
1290
|
+
var Refresh = require('react-refresh/runtime');
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* Extracts exports from a webpack module object.
|
|
1294
|
+
* @param {string} moduleId A Webpack module ID.
|
|
1295
|
+
* @returns {*} An exports object from the module.
|
|
1296
|
+
*/
|
|
1297
|
+
function getModuleExports(moduleId) {
|
|
1298
|
+
if (typeof moduleId === 'undefined') {
|
|
1299
|
+
// \`moduleId\` is unavailable, which indicates that this module is not in the cache,
|
|
1300
|
+
// which means we won't be able to capture any exports,
|
|
1301
|
+
// and thus they cannot be refreshed safely.
|
|
1302
|
+
// These are likely runtime or dynamically generated modules.
|
|
1303
|
+
return {};
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
var maybeModule = __webpack_require__.c[moduleId];
|
|
1307
|
+
if (typeof maybeModule === 'undefined') {
|
|
1308
|
+
// \`moduleId\` is available but the module in cache is unavailable,
|
|
1309
|
+
// which indicates the module is somehow corrupted (e.g. broken Webpacak \`module\` globals).
|
|
1310
|
+
// We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
|
|
1311
|
+
console.warn(
|
|
1312
|
+
'[React Refresh] Failed to get exports for module: ' + moduleId + '.',
|
|
1313
|
+
);
|
|
1314
|
+
return {};
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
var exportsOrPromise = maybeModule.exports;
|
|
1318
|
+
if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
|
|
1319
|
+
return exportsOrPromise.then(function (exports) {
|
|
1320
|
+
return exports;
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
return exportsOrPromise;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Calculates the signature of a React refresh boundary.
|
|
1328
|
+
* If this signature changes, it's unsafe to accept the boundary.
|
|
1329
|
+
*
|
|
1330
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).
|
|
1331
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
1332
|
+
* @returns {string[]} A React refresh boundary signature array.
|
|
1333
|
+
*/
|
|
1334
|
+
function getReactRefreshBoundarySignature(moduleExports) {
|
|
1335
|
+
var signature = [];
|
|
1336
|
+
signature.push(Refresh.getFamilyByType(moduleExports));
|
|
1337
|
+
|
|
1338
|
+
if (moduleExports == null || typeof moduleExports !== 'object') {
|
|
1339
|
+
// Exit if we can't iterate over exports.
|
|
1340
|
+
return signature;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
for (var key in moduleExports) {
|
|
1344
|
+
if (key === '__esModule') {
|
|
1345
|
+
continue;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
signature.push(key);
|
|
1349
|
+
signature.push(Refresh.getFamilyByType(moduleExports[key]));
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
return signature;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* Creates a helper that performs a delayed React refresh.
|
|
1357
|
+
* @returns {function(function(): void): void} A debounced React refresh function.
|
|
1358
|
+
*/
|
|
1359
|
+
function createDebounceUpdate() {
|
|
1360
|
+
/**
|
|
1361
|
+
* A cached setTimeout handler.
|
|
1362
|
+
* @type {number | undefined}
|
|
1363
|
+
*/
|
|
1364
|
+
var refreshTimeout;
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Performs react refresh on a delay and clears the error overlay.
|
|
1368
|
+
* @param {function(): void} callback
|
|
1369
|
+
* @returns {void}
|
|
1370
|
+
*/
|
|
1371
|
+
function enqueueUpdate(callback) {
|
|
1372
|
+
if (typeof refreshTimeout === 'undefined') {
|
|
1373
|
+
refreshTimeout = setTimeout(function () {
|
|
1374
|
+
refreshTimeout = undefined;
|
|
1375
|
+
Refresh.performReactRefresh();
|
|
1376
|
+
callback();
|
|
1377
|
+
}, 30);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
return enqueueUpdate;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Checks if all exports are likely a React component.
|
|
1386
|
+
*
|
|
1387
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).
|
|
1388
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
1389
|
+
* @returns {boolean} Whether the exports are React component like.
|
|
1390
|
+
*/
|
|
1391
|
+
function isReactRefreshBoundary(moduleExports) {
|
|
1392
|
+
if (Refresh.isLikelyComponentType(moduleExports)) {
|
|
1393
|
+
return true;
|
|
1394
|
+
}
|
|
1395
|
+
if (
|
|
1396
|
+
moduleExports === undefined ||
|
|
1397
|
+
moduleExports === null ||
|
|
1398
|
+
typeof moduleExports !== 'object'
|
|
1399
|
+
) {
|
|
1400
|
+
// Exit if we can't iterate over exports.
|
|
1401
|
+
return false;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
var hasExports = false;
|
|
1405
|
+
var areAllExportsComponents = true;
|
|
1406
|
+
for (var key in moduleExports) {
|
|
1407
|
+
hasExports = true;
|
|
1408
|
+
|
|
1409
|
+
// This is the ES Module indicator flag
|
|
1410
|
+
if (key === '__esModule') {
|
|
1411
|
+
continue;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// We can (and have to) safely execute getters here,
|
|
1415
|
+
// as Webpack manually assigns harmony exports to getters,
|
|
1416
|
+
// without any side-effects attached.
|
|
1417
|
+
// Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
|
|
1418
|
+
var exportValue = moduleExports[key];
|
|
1419
|
+
if (!Refresh.isLikelyComponentType(exportValue)) {
|
|
1420
|
+
areAllExportsComponents = false;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
return hasExports && areAllExportsComponents;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
/**
|
|
1428
|
+
* Checks if exports are likely a React component and registers them.
|
|
1429
|
+
*
|
|
1430
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L818-L835).
|
|
1431
|
+
* @param {*} moduleExports A Webpack module exports object.
|
|
1432
|
+
* @param {string} moduleId A Webpack module ID.
|
|
1433
|
+
* @returns {void}
|
|
1434
|
+
*/
|
|
1435
|
+
function registerExportsForReactRefresh(moduleExports, moduleId) {
|
|
1436
|
+
if (Refresh.isLikelyComponentType(moduleExports)) {
|
|
1437
|
+
// Register module.exports if it is likely a component
|
|
1438
|
+
Refresh.register(moduleExports, moduleId + ' %exports%');
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
if (
|
|
1442
|
+
moduleExports === undefined ||
|
|
1443
|
+
moduleExports === null ||
|
|
1444
|
+
typeof moduleExports !== 'object'
|
|
1445
|
+
) {
|
|
1446
|
+
// Exit if we can't iterate over the exports.
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
for (var key in moduleExports) {
|
|
1451
|
+
// Skip registering the ES Module indicator
|
|
1452
|
+
if (key === '__esModule') {
|
|
1453
|
+
continue;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
var exportValue = moduleExports[key];
|
|
1457
|
+
if (Refresh.isLikelyComponentType(exportValue)) {
|
|
1458
|
+
var typeID = moduleId + ' %exports% ' + key;
|
|
1459
|
+
Refresh.register(exportValue, typeID);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* Compares previous and next module objects to check for mutated boundaries.
|
|
1466
|
+
*
|
|
1467
|
+
* This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L776-L792).
|
|
1468
|
+
* @param {*} prevExports The current Webpack module exports object.
|
|
1469
|
+
* @param {*} nextExports The next Webpack module exports object.
|
|
1470
|
+
* @returns {boolean} Whether the React refresh boundary should be invalidated.
|
|
1471
|
+
*/
|
|
1472
|
+
function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
|
|
1473
|
+
var prevSignature = getReactRefreshBoundarySignature(prevExports);
|
|
1474
|
+
var nextSignature = getReactRefreshBoundarySignature(nextExports);
|
|
1475
|
+
|
|
1476
|
+
if (prevSignature.length !== nextSignature.length) {
|
|
1477
|
+
return true;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
for (var i = 0; i < nextSignature.length; i += 1) {
|
|
1481
|
+
if (prevSignature[i] !== nextSignature[i]) {
|
|
1482
|
+
return true;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
return false;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
var enqueueUpdate = createDebounceUpdate();
|
|
1490
|
+
|
|
1491
|
+
function executeRuntime(
|
|
1492
|
+
moduleExports,
|
|
1493
|
+
moduleId,
|
|
1494
|
+
webpackHot,
|
|
1495
|
+
refreshOverlay,
|
|
1496
|
+
isTest,
|
|
1497
|
+
) {
|
|
1498
|
+
registerExportsForReactRefresh(moduleExports, moduleId);
|
|
1499
|
+
|
|
1500
|
+
if (webpackHot) {
|
|
1501
|
+
var isHotUpdate = !!webpackHot.data;
|
|
1502
|
+
var prevExports;
|
|
1503
|
+
if (isHotUpdate) {
|
|
1504
|
+
prevExports = webpackHot.data.prevExports;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
if (isReactRefreshBoundary(moduleExports)) {
|
|
1508
|
+
webpackHot.dispose(
|
|
1509
|
+
/**
|
|
1510
|
+
* A callback to performs a full refresh if React has unrecoverable errors,
|
|
1511
|
+
* and also caches the to-be-disposed module.
|
|
1512
|
+
* @param {*} data A hot module data object from Webpack HMR.
|
|
1513
|
+
* @returns {void}
|
|
1514
|
+
*/
|
|
1515
|
+
function hotDisposeCallback(data) {
|
|
1516
|
+
// We have to mutate the data object to get data registered and cached
|
|
1517
|
+
data.prevExports = moduleExports;
|
|
1518
|
+
},
|
|
1519
|
+
);
|
|
1520
|
+
webpackHot.accept(
|
|
1521
|
+
/**
|
|
1522
|
+
* An error handler to allow self-recovering behaviours.
|
|
1523
|
+
* @param {Error} error An error occurred during evaluation of a module.
|
|
1524
|
+
* @returns {void}
|
|
1525
|
+
*/
|
|
1526
|
+
function hotErrorHandler(error) {
|
|
1527
|
+
console.error(error);
|
|
1528
|
+
if (
|
|
1529
|
+
__reload_on_runtime_errors__ &&
|
|
1530
|
+
isUnrecoverableRuntimeError(error)
|
|
1531
|
+
) {
|
|
1532
|
+
location.reload();
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
|
|
1537
|
+
refreshOverlay.handleRuntimeError(error);
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
if (typeof isTest !== 'undefined' && isTest) {
|
|
1541
|
+
if (window.onHotAcceptError) {
|
|
1542
|
+
window.onHotAcceptError(error.message);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
__webpack_require__.c[moduleId].hot.accept(hotErrorHandler);
|
|
1547
|
+
},
|
|
1548
|
+
);
|
|
1549
|
+
|
|
1550
|
+
if (isHotUpdate) {
|
|
1551
|
+
if (
|
|
1552
|
+
isReactRefreshBoundary(prevExports) &&
|
|
1553
|
+
shouldInvalidateReactRefreshBoundary(prevExports, moduleExports)
|
|
1554
|
+
) {
|
|
1555
|
+
webpackHot.invalidate();
|
|
1556
|
+
} else {
|
|
1557
|
+
enqueueUpdate(
|
|
1558
|
+
/**
|
|
1559
|
+
* A function to dismiss the error overlay after performing React refresh.
|
|
1560
|
+
* @returns {void}
|
|
1561
|
+
*/
|
|
1562
|
+
function updateCallback() {
|
|
1563
|
+
if (typeof refreshOverlay !== 'undefined' && refreshOverlay) {
|
|
1564
|
+
refreshOverlay.clearRuntimeErrors();
|
|
1565
|
+
}
|
|
1566
|
+
},
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
} else {
|
|
1571
|
+
if (isHotUpdate && typeof prevExports !== 'undefined') {
|
|
1572
|
+
webpackHot.invalidate();
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
function isUnrecoverableRuntimeError(error) {
|
|
1579
|
+
return error.message.startsWith('RuntimeError: factory is undefined');
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
module.exports = Object.freeze({
|
|
1583
|
+
enqueueUpdate: enqueueUpdate,
|
|
1584
|
+
executeRuntime: executeRuntime,
|
|
1585
|
+
getModuleExports: getModuleExports,
|
|
1586
|
+
isReactRefreshBoundary: isReactRefreshBoundary,
|
|
1587
|
+
shouldInvalidateReactRefreshBoundary: shouldInvalidateReactRefreshBoundary,
|
|
1588
|
+
registerExportsForReactRefresh: registerExportsForReactRefresh,
|
|
1589
|
+
});
|
|
1590
|
+
` }.utils
|
|
1591
|
+
};
|
|
1592
|
+
};
|
|
1593
|
+
export {
|
|
1594
|
+
normalizeVirtualPath,
|
|
1595
|
+
makeBrowserHttpClient,
|
|
1596
|
+
getVirtualProjectFiles,
|
|
1597
|
+
getVirtualProjectChanges,
|
|
1598
|
+
getBrowserReactRefreshVirtualFiles,
|
|
1599
|
+
createBrowserReactRefreshPlugin,
|
|
1600
|
+
createBrowserHmrRuntimePlugin,
|
|
1601
|
+
createBrowserHmrAssetManager,
|
|
1602
|
+
createBrowserDependencyPlugin,
|
|
1603
|
+
createBrowserCompiler
|
|
1604
|
+
};
|