Latest repo

This commit is contained in:
Marc
2025-06-02 16:42:16 +00:00
parent 53ddf1a329
commit cde5fae175
27907 changed files with 3875388 additions and 1 deletions

21
node_modules/@vitejs/plugin-react-swc/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Arnaud Barré (https://github.com/ArnaudBarre)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

108
node_modules/@vitejs/plugin-react-swc/README.md generated vendored Normal file
View File

@@ -0,0 +1,108 @@
# @vitejs/plugin-react-swc [![npm](https://img.shields.io/npm/v/@vitejs/plugin-react-swc)](https://www.npmjs.com/package/@vitejs/plugin-react-swc)
Speed up your Vite dev server with [SWC](https://swc.rs/)
- ✅ A fast Fast Refresh (~20x faster than Babel)
- ✅ Enable [automatic JSX runtime](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)
## Installation
```sh
npm i -D @vitejs/plugin-react-swc
```
## Usage
```ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
export default defineConfig({
plugins: [react()],
});
```
## Caveats
This plugin has limited options to enable good performances and be transpiler agnostic. Here is the list of non-configurable options that impact runtime behaviour:
- [useDefineForClassFields](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier) is always activated, as this matches the current ECMAScript spec
- `jsx runtime` is always `automatic`
- In development:
- esbuild is disabled, so the [esbuild configuration](https://vitejs.dev/config/shared-options.html#esbuild) has no effect
- `target` is ignored and defaults to `es2020` (see [`devTarget`](#devtarget))
- JS files are not transformed
- tsconfig is not resolved, so properties other than the ones listed above behaves like TS defaults
## Options
### jsxImportSource
Control where the JSX factory is imported from.
`@default` "react"
```ts
react({ jsxImportSource: "@emotion/react" });
```
### tsDecorators
Enable TypeScript decorators. Requires `experimentalDecorators` in tsconfig.
`@default` false
```ts
react({ tsDecorators: true });
```
### plugins
Use SWC plugins. Enable SWC at build time.
```ts
react({ plugins: [["@swc/plugin-styled-components", {}]] });
```
### devTarget
Set the target for SWC in dev. This can avoid to down-transpile private class method for example.
For production target, see https://vitejs.dev/config/build-options.html#build-target.
`@default` "es2020"
```ts
react({ devTarget: "es2022" });
```
### parserConfig
Override the default include list (.ts, .tsx, .mts, .jsx, .mdx).
This requires to redefine the config for any file you want to be included (ts, mdx, ...).
If you want to trigger fast refresh on compiled JS, use `jsx: true`. Exclusion of node_modules should be handled by the function if needed. Using this option to use JSX inside `.js` files is highly discouraged and can be removed in any future version.
```ts
react({
parserConfig(id) {
if (id.endsWith(".res")) return { syntax: "ecmascript", jsx: true };
if (id.endsWith(".ts")) return { syntax: "typescript", tsx: false };
},
});
```
## Consistent components exports
For React refresh to work correctly, your file should only export React components. The best explanation I've read is the one from the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).
If an incompatible change in exports is found, the module will be invalidated and HMR will propagate. To make it easier to export simple constants alongside your component, the module is only invalidated when their value changes.
You can catch mistakes and get more detailed warning with this [eslint rule](https://github.com/ArnaudBarre/eslint-plugin-react-refresh).
## Migrating from `vite-plugin-swc-react-refresh`
The documentation for the previous version of the plugin is available in the [v2 branch](https://github.com/vitejs/vite-plugin-react-swc/tree/v2)
To migrate, see this [changelog](https://github.com/vitejs/vite-plugin-react-swc/releases/tag/v3.0.0-beta.0)

214
node_modules/@vitejs/plugin-react-swc/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,214 @@
// src/index.ts
var import_fs = require("fs");
var import_path = require("path");
var import_url = require("url");
var import_core = require("@swc/core");
var import_module = require("module");
var import_meta = {};
var runtimePublicPath = "/@react-refresh";
var preambleCode = `import { injectIntoGlobalHook } from "__PATH__";
injectIntoGlobalHook(window);
window.$RefreshReg$ = () => {};
window.$RefreshSig$ = () => (type) => type;`;
var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_path.dirname)((0, import_url.fileURLToPath)(import_meta.url));
var resolve = (0, import_module.createRequire)(
typeof __filename !== "undefined" ? __filename : import_meta.url
).resolve;
var reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
var refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
var _a, _b;
var isWebContainer = (_b = (_a = globalThis.process) == null ? void 0 : _a.versions) == null ? void 0 : _b.webcontainer;
var react = (_options) => {
let hmrDisabled = false;
const options = {
jsxImportSource: (_options == null ? void 0 : _options.jsxImportSource) ?? "react",
tsDecorators: _options == null ? void 0 : _options.tsDecorators,
plugins: (_options == null ? void 0 : _options.plugins) ? _options == null ? void 0 : _options.plugins.map((el) => [resolve(el[0]), el[1]]) : void 0,
devTarget: (_options == null ? void 0 : _options.devTarget) ?? "es2020",
parserConfig: _options == null ? void 0 : _options.parserConfig
};
return [
{
name: "vite:react-swc:resolve-runtime",
apply: "serve",
enforce: "pre",
// Run before Vite default resolve to avoid syscalls
resolveId: (id) => id === runtimePublicPath ? id : void 0,
load: (id) => id === runtimePublicPath ? (0, import_fs.readFileSync)((0, import_path.join)(_dirname, "refresh-runtime.js"), "utf-8") : void 0
},
{
name: "vite:react-swc",
apply: "serve",
config: () => ({
esbuild: false,
optimizeDeps: {
include: [`${options.jsxImportSource}/jsx-dev-runtime`],
esbuildOptions: { jsx: "automatic" }
}
}),
configResolved(config) {
if (config.server.hmr === false) hmrDisabled = true;
const mdxIndex = config.plugins.findIndex(
(p) => p.name === "@mdx-js/rollup"
);
if (mdxIndex !== -1 && mdxIndex > config.plugins.findIndex((p) => p.name === "vite:react-swc")) {
throw new Error(
"[vite:react-swc] The MDX plugin should be placed before this plugin"
);
}
if (isWebContainer) {
config.logger.warn(
"[vite:react-swc] SWC is currently not supported in WebContainers. You can use the default React plugin instead."
);
}
},
transformIndexHtml: (_, config) => [
{
tag: "script",
attrs: { type: "module" },
children: preambleCode.replace(
"__PATH__",
config.server.config.base + runtimePublicPath.slice(1)
)
}
],
async transform(code, _id, transformOptions) {
const id = _id.split("?")[0];
const refresh = !(transformOptions == null ? void 0 : transformOptions.ssr) && !hmrDisabled;
const result = await transformWithOptions(
id,
code,
options.devTarget,
options,
{
refresh,
development: true,
runtime: "automatic",
importSource: options.jsxImportSource
}
);
if (!result) return;
if (!refresh) return result;
const hasRefresh = refreshContentRE.test(result.code);
if (!hasRefresh && !reactCompRE.test(result.code)) return result;
const sourceMap = JSON.parse(result.map);
sourceMap.mappings = ";;" + sourceMap.mappings;
result.code = `import * as RefreshRuntime from "${runtimePublicPath}";
${result.code}`;
if (hasRefresh) {
sourceMap.mappings = ";;;;;;" + sourceMap.mappings;
result.code = `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
const prevRefreshReg = window.$RefreshReg$;
const prevRefreshSig = window.$RefreshSig$;
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
${result.code}
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;
`;
}
result.code += `
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
RefreshRuntime.registerExportsForReactRefresh("${id}", currentExports);
import.meta.hot.accept((nextExports) => {
if (!nextExports) return;
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate("${id}", currentExports, nextExports);
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
});
});
`;
return { code: result.code, map: sourceMap };
}
},
options.plugins ? {
name: "vite:react-swc",
apply: "build",
enforce: "pre",
// Run before esbuild
config: (userConfig) => ({
build: silenceUseClientWarning(userConfig)
}),
transform: (code, _id) => transformWithOptions(_id.split("?")[0], code, "esnext", options, {
runtime: "automatic",
importSource: options.jsxImportSource
})
} : {
name: "vite:react-swc",
apply: "build",
config: (userConfig) => ({
build: silenceUseClientWarning(userConfig),
esbuild: {
jsx: "automatic",
jsxImportSource: options.jsxImportSource,
tsconfigRaw: {
compilerOptions: { useDefineForClassFields: true }
}
}
})
}
];
};
var transformWithOptions = async (id, code, target, options, reactConfig) => {
const decorators = (options == null ? void 0 : options.tsDecorators) ?? false;
const parser = options.parserConfig ? options.parserConfig(id) : id.endsWith(".tsx") ? { syntax: "typescript", tsx: true, decorators } : id.endsWith(".ts") || id.endsWith(".mts") ? { syntax: "typescript", tsx: false, decorators } : id.endsWith(".jsx") ? { syntax: "ecmascript", jsx: true } : id.endsWith(".mdx") ? (
// JSX is required to trigger fast refresh transformations, even if MDX already transforms it
{ syntax: "ecmascript", jsx: true }
) : void 0;
if (!parser) return;
let result;
try {
result = await (0, import_core.transform)(code, {
filename: id,
swcrc: false,
configFile: false,
sourceMaps: true,
jsc: {
target,
parser,
experimental: { plugins: options.plugins },
transform: {
useDefineForClassFields: true,
react: reactConfig
}
}
});
} catch (e) {
const message = e.message;
const fileStartIndex = message.indexOf("\u256D\u2500[");
if (fileStartIndex !== -1) {
const match = message.slice(fileStartIndex).match(/:(\d+):(\d+)]/);
if (match) {
e.line = match[1];
e.column = match[2];
}
}
throw e;
}
return result;
};
var silenceUseClientWarning = (userConfig) => ({
rollupOptions: {
onwarn(warning, defaultHandler) {
var _a2, _b2;
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes("use client")) {
return;
}
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
return;
}
if ((_b2 = (_a2 = userConfig.build) == null ? void 0 : _a2.rollupOptions) == null ? void 0 : _b2.onwarn) {
userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
} else {
defaultHandler(warning);
}
}
}
});
var src_default = react;
// <stdin>
module.exports = src_default;
module.exports.default = src_default;

34
node_modules/@vitejs/plugin-react-swc/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,34 @@
import { ParserConfig, JscTarget } from "@swc/core";
import { PluginOption } from "vite";
type Options = {
/**
* Control where the JSX factory is imported from.
* @default "react"
*/
jsxImportSource?: string;
/**
* Enable TypeScript decorators. Requires experimentalDecorators in tsconfig.
* @default false
*/
tsDecorators?: boolean;
/**
* Use SWC plugins. Enable SWC at build time.
* @default undefined
*/
plugins?: [string, Record<string, any>][];
/**
* Set the target for SWC in dev. This can avoid to down-transpile private class method for example.
* For production target, see https://vitejs.dev/config/build-options.html#build-target
* @default "es2020"
*/
devTarget?: JscTarget;
/**
* Override the default include list (.ts, .tsx, .mts, .jsx, .mdx).
* This requires to redefine the config for any file you want to be included.
* If you want to trigger fast refresh on compiled JS, use `jsx: true`.
* Exclusion of node_modules should be handled by the function if needed.
*/
parserConfig?: (id: string) => ParserConfig | undefined;
};
declare const react: (_options?: Options) => PluginOption[];
export default react;

214
node_modules/@vitejs/plugin-react-swc/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,214 @@
// src/index.ts
import { readFileSync } from "fs";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
import {
transform
} from "@swc/core";
import { createRequire } from "module";
var runtimePublicPath = "/@react-refresh";
var preambleCode = `import { injectIntoGlobalHook } from "__PATH__";
injectIntoGlobalHook(window);
window.$RefreshReg$ = () => {};
window.$RefreshSig$ = () => (type) => type;`;
var _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
var resolve = createRequire(
typeof __filename !== "undefined" ? __filename : import.meta.url
).resolve;
var reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
var refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
var _a, _b;
var isWebContainer = (_b = (_a = globalThis.process) == null ? void 0 : _a.versions) == null ? void 0 : _b.webcontainer;
var react = (_options) => {
let hmrDisabled = false;
const options = {
jsxImportSource: (_options == null ? void 0 : _options.jsxImportSource) ?? "react",
tsDecorators: _options == null ? void 0 : _options.tsDecorators,
plugins: (_options == null ? void 0 : _options.plugins) ? _options == null ? void 0 : _options.plugins.map((el) => [resolve(el[0]), el[1]]) : void 0,
devTarget: (_options == null ? void 0 : _options.devTarget) ?? "es2020",
parserConfig: _options == null ? void 0 : _options.parserConfig
};
return [
{
name: "vite:react-swc:resolve-runtime",
apply: "serve",
enforce: "pre",
// Run before Vite default resolve to avoid syscalls
resolveId: (id) => id === runtimePublicPath ? id : void 0,
load: (id) => id === runtimePublicPath ? readFileSync(join(_dirname, "refresh-runtime.js"), "utf-8") : void 0
},
{
name: "vite:react-swc",
apply: "serve",
config: () => ({
esbuild: false,
optimizeDeps: {
include: [`${options.jsxImportSource}/jsx-dev-runtime`],
esbuildOptions: { jsx: "automatic" }
}
}),
configResolved(config) {
if (config.server.hmr === false) hmrDisabled = true;
const mdxIndex = config.plugins.findIndex(
(p) => p.name === "@mdx-js/rollup"
);
if (mdxIndex !== -1 && mdxIndex > config.plugins.findIndex((p) => p.name === "vite:react-swc")) {
throw new Error(
"[vite:react-swc] The MDX plugin should be placed before this plugin"
);
}
if (isWebContainer) {
config.logger.warn(
"[vite:react-swc] SWC is currently not supported in WebContainers. You can use the default React plugin instead."
);
}
},
transformIndexHtml: (_, config) => [
{
tag: "script",
attrs: { type: "module" },
children: preambleCode.replace(
"__PATH__",
config.server.config.base + runtimePublicPath.slice(1)
)
}
],
async transform(code, _id, transformOptions) {
const id = _id.split("?")[0];
const refresh = !(transformOptions == null ? void 0 : transformOptions.ssr) && !hmrDisabled;
const result = await transformWithOptions(
id,
code,
options.devTarget,
options,
{
refresh,
development: true,
runtime: "automatic",
importSource: options.jsxImportSource
}
);
if (!result) return;
if (!refresh) return result;
const hasRefresh = refreshContentRE.test(result.code);
if (!hasRefresh && !reactCompRE.test(result.code)) return result;
const sourceMap = JSON.parse(result.map);
sourceMap.mappings = ";;" + sourceMap.mappings;
result.code = `import * as RefreshRuntime from "${runtimePublicPath}";
${result.code}`;
if (hasRefresh) {
sourceMap.mappings = ";;;;;;" + sourceMap.mappings;
result.code = `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
const prevRefreshReg = window.$RefreshReg$;
const prevRefreshSig = window.$RefreshSig$;
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
${result.code}
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;
`;
}
result.code += `
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
RefreshRuntime.registerExportsForReactRefresh("${id}", currentExports);
import.meta.hot.accept((nextExports) => {
if (!nextExports) return;
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate("${id}", currentExports, nextExports);
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
});
});
`;
return { code: result.code, map: sourceMap };
}
},
options.plugins ? {
name: "vite:react-swc",
apply: "build",
enforce: "pre",
// Run before esbuild
config: (userConfig) => ({
build: silenceUseClientWarning(userConfig)
}),
transform: (code, _id) => transformWithOptions(_id.split("?")[0], code, "esnext", options, {
runtime: "automatic",
importSource: options.jsxImportSource
})
} : {
name: "vite:react-swc",
apply: "build",
config: (userConfig) => ({
build: silenceUseClientWarning(userConfig),
esbuild: {
jsx: "automatic",
jsxImportSource: options.jsxImportSource,
tsconfigRaw: {
compilerOptions: { useDefineForClassFields: true }
}
}
})
}
];
};
var transformWithOptions = async (id, code, target, options, reactConfig) => {
const decorators = (options == null ? void 0 : options.tsDecorators) ?? false;
const parser = options.parserConfig ? options.parserConfig(id) : id.endsWith(".tsx") ? { syntax: "typescript", tsx: true, decorators } : id.endsWith(".ts") || id.endsWith(".mts") ? { syntax: "typescript", tsx: false, decorators } : id.endsWith(".jsx") ? { syntax: "ecmascript", jsx: true } : id.endsWith(".mdx") ? (
// JSX is required to trigger fast refresh transformations, even if MDX already transforms it
{ syntax: "ecmascript", jsx: true }
) : void 0;
if (!parser) return;
let result;
try {
result = await transform(code, {
filename: id,
swcrc: false,
configFile: false,
sourceMaps: true,
jsc: {
target,
parser,
experimental: { plugins: options.plugins },
transform: {
useDefineForClassFields: true,
react: reactConfig
}
}
});
} catch (e) {
const message = e.message;
const fileStartIndex = message.indexOf("\u256D\u2500[");
if (fileStartIndex !== -1) {
const match = message.slice(fileStartIndex).match(/:(\d+):(\d+)]/);
if (match) {
e.line = match[1];
e.column = match[2];
}
}
throw e;
}
return result;
};
var silenceUseClientWarning = (userConfig) => ({
rollupOptions: {
onwarn(warning, defaultHandler) {
var _a2, _b2;
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes("use client")) {
return;
}
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
return;
}
if ((_b2 = (_a2 = userConfig.build) == null ? void 0 : _a2.rollupOptions) == null ? void 0 : _b2.onwarn) {
userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
} else {
defaultHandler(warning);
}
}
}
});
var src_default = react;
export {
src_default as default
};

33
node_modules/@vitejs/plugin-react-swc/package.json generated vendored Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "@vitejs/plugin-react-swc",
"description": "Speed up your Vite dev server with SWC",
"version": "3.7.1",
"author": "Arnaud Barré (https://github.com/ArnaudBarre)",
"license": "MIT",
"repository": "github:vitejs/vite-plugin-react-swc",
"type": "module",
"main": "index.cjs",
"types": "index.d.ts",
"module": "index.mjs",
"exports": {
".": {
"types": "./index.d.ts",
"require": "./index.cjs",
"import": "./index.mjs"
}
},
"keywords": [
"vite",
"vite-plugin",
"react",
"swc",
"react-refresh",
"fast refresh"
],
"peerDependencies": {
"vite": "^4 || ^5"
},
"dependencies": {
"@swc/core": "^1.7.26"
}
}

View File

@@ -0,0 +1,455 @@
/*! Copyright (c) Meta Platforms, Inc. and affiliates. **/
const REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
const REACT_MEMO_TYPE = Symbol.for("react.memo");
let allFamiliesByID = /* @__PURE__ */ new Map();
let allFamiliesByType = /* @__PURE__ */ new WeakMap();
let allSignaturesByType = /* @__PURE__ */ new WeakMap();
const updatedFamiliesByType = /* @__PURE__ */ new WeakMap();
let pendingUpdates = [];
const helpersByRendererID = /* @__PURE__ */ new Map();
const helpersByRoot = /* @__PURE__ */ new Map();
const mountedRoots = /* @__PURE__ */ new Set();
const failedRoots = /* @__PURE__ */ new Set();
let rootElements = /* @__PURE__ */ new WeakMap();
let isPerformingRefresh = false;
function computeFullKey(signature) {
if (signature.fullKey !== null) {
return signature.fullKey;
}
let fullKey = signature.ownKey;
let hooks2;
try {
hooks2 = signature.getCustomHooks();
} catch (err) {
signature.forceReset = true;
signature.fullKey = fullKey;
return fullKey;
}
for (let i = 0; i < hooks2.length; i++) {
const hook = hooks2[i];
if (typeof hook !== "function") {
signature.forceReset = true;
signature.fullKey = fullKey;
return fullKey;
}
const nestedHookSignature = allSignaturesByType.get(hook);
if (nestedHookSignature === void 0) {
continue;
}
const nestedHookKey = computeFullKey(nestedHookSignature);
if (nestedHookSignature.forceReset) {
signature.forceReset = true;
}
fullKey += "\n---\n" + nestedHookKey;
}
signature.fullKey = fullKey;
return fullKey;
}
function haveEqualSignatures(prevType, nextType) {
const prevSignature = allSignaturesByType.get(prevType);
const nextSignature = allSignaturesByType.get(nextType);
if (prevSignature === void 0 && nextSignature === void 0) {
return true;
}
if (prevSignature === void 0 || nextSignature === void 0) {
return false;
}
if (computeFullKey(prevSignature) !== computeFullKey(nextSignature)) {
return false;
}
if (nextSignature.forceReset) {
return false;
}
return true;
}
function isReactClass(type) {
return type.prototype && type.prototype.isReactComponent;
}
function canPreserveStateBetween(prevType, nextType) {
if (isReactClass(prevType) || isReactClass(nextType)) {
return false;
}
if (haveEqualSignatures(prevType, nextType)) {
return true;
}
return false;
}
function resolveFamily(type) {
return updatedFamiliesByType.get(type);
}
function getProperty(object, property) {
try {
return object[property];
} catch (err) {
return void 0;
}
}
function performReactRefresh() {
if (pendingUpdates.length === 0) {
return null;
}
if (isPerformingRefresh) {
return null;
}
isPerformingRefresh = true;
try {
const staleFamilies = /* @__PURE__ */ new Set();
const updatedFamilies = /* @__PURE__ */ new Set();
const updates = pendingUpdates;
pendingUpdates = [];
updates.forEach(([family, nextType]) => {
const prevType = family.current;
updatedFamiliesByType.set(prevType, family);
updatedFamiliesByType.set(nextType, family);
family.current = nextType;
if (canPreserveStateBetween(prevType, nextType)) {
updatedFamilies.add(family);
} else {
staleFamilies.add(family);
}
});
const update = {
updatedFamilies,
// Families that will re-render preserving state
staleFamilies
// Families that will be remounted
};
helpersByRendererID.forEach((helpers) => {
helpers.setRefreshHandler(resolveFamily);
});
let didError = false;
let firstError = null;
const failedRootsSnapshot = new Set(failedRoots);
const mountedRootsSnapshot = new Set(mountedRoots);
const helpersByRootSnapshot = new Map(helpersByRoot);
failedRootsSnapshot.forEach((root) => {
const helpers = helpersByRootSnapshot.get(root);
if (helpers === void 0) {
throw new Error(
"Could not find helpers for a root. This is a bug in React Refresh."
);
}
if (!failedRoots.has(root)) {
}
if (rootElements === null) {
return;
}
if (!rootElements.has(root)) {
return;
}
const element = rootElements.get(root);
try {
helpers.scheduleRoot(root, element);
} catch (err) {
if (!didError) {
didError = true;
firstError = err;
}
}
});
mountedRootsSnapshot.forEach((root) => {
const helpers = helpersByRootSnapshot.get(root);
if (helpers === void 0) {
throw new Error(
"Could not find helpers for a root. This is a bug in React Refresh."
);
}
if (!mountedRoots.has(root)) {
}
try {
helpers.scheduleRefresh(root, update);
} catch (err) {
if (!didError) {
didError = true;
firstError = err;
}
}
});
if (didError) {
throw firstError;
}
return update;
} finally {
isPerformingRefresh = false;
}
}
function register(type, id) {
if (type === null) {
return;
}
if (typeof type !== "function" && typeof type !== "object") {
return;
}
if (allFamiliesByType.has(type)) {
return;
}
let family = allFamiliesByID.get(id);
if (family === void 0) {
family = { current: type };
allFamiliesByID.set(id, family);
} else {
pendingUpdates.push([family, type]);
}
allFamiliesByType.set(type, family);
if (typeof type === "object" && type !== null) {
switch (getProperty(type, "$$typeof")) {
case REACT_FORWARD_REF_TYPE:
register(type.render, id + "$render");
break;
case REACT_MEMO_TYPE:
register(type.type, id + "$type");
break;
}
}
}
function setSignature(type, key, forceReset, getCustomHooks) {
if (!allSignaturesByType.has(type)) {
allSignaturesByType.set(type, {
forceReset,
ownKey: key,
fullKey: null,
getCustomHooks: getCustomHooks || (() => [])
});
}
if (typeof type === "object" && type !== null) {
switch (getProperty(type, "$$typeof")) {
case REACT_FORWARD_REF_TYPE:
setSignature(type.render, key, forceReset, getCustomHooks);
break;
case REACT_MEMO_TYPE:
setSignature(type.type, key, forceReset, getCustomHooks);
break;
}
}
}
function collectCustomHooksForSignature(type) {
const signature = allSignaturesByType.get(type);
if (signature !== void 0) {
computeFullKey(signature);
}
}
function injectIntoGlobalHook(globalObject) {
let hook = globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__;
if (hook === void 0) {
let nextID = 0;
globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
renderers: /* @__PURE__ */ new Map(),
supportsFiber: true,
inject: (injected) => nextID++,
onScheduleFiberRoot: (id, root, children) => {
},
onCommitFiberRoot: (id, root, maybePriorityLevel, didError) => {
},
onCommitFiberUnmount() {
}
};
}
if (hook.isDisabled) {
console["warn"](
"Something has shimmed the React DevTools global hook (__REACT_DEVTOOLS_GLOBAL_HOOK__). Fast Refresh is not compatible with this shim and will be disabled."
);
return;
}
const oldInject = hook.inject;
hook.inject = function(injected) {
const id = oldInject.apply(this, arguments);
if (typeof injected.scheduleRefresh === "function" && typeof injected.setRefreshHandler === "function") {
helpersByRendererID.set(id, injected);
}
return id;
};
hook.renderers.forEach((injected, id) => {
if (typeof injected.scheduleRefresh === "function" && typeof injected.setRefreshHandler === "function") {
helpersByRendererID.set(id, injected);
}
});
const oldOnCommitFiberRoot = hook.onCommitFiberRoot;
const oldOnScheduleFiberRoot = hook.onScheduleFiberRoot || (() => {
});
hook.onScheduleFiberRoot = function(id, root, children) {
if (!isPerformingRefresh) {
failedRoots.delete(root);
if (rootElements !== null) {
rootElements.set(root, children);
}
}
return oldOnScheduleFiberRoot.apply(this, arguments);
};
hook.onCommitFiberRoot = function(id, root, maybePriorityLevel, didError) {
const helpers = helpersByRendererID.get(id);
if (helpers !== void 0) {
helpersByRoot.set(root, helpers);
const current = root.current;
const alternate = current.alternate;
if (alternate !== null) {
const wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null && mountedRoots.has(root);
const isMounted = current.memoizedState != null && current.memoizedState.element != null;
if (!wasMounted && isMounted) {
mountedRoots.add(root);
failedRoots.delete(root);
} else if (wasMounted && isMounted) {
} else if (wasMounted && !isMounted) {
mountedRoots.delete(root);
if (didError) {
failedRoots.add(root);
} else {
helpersByRoot.delete(root);
}
} else if (!wasMounted && !isMounted) {
if (didError) {
failedRoots.add(root);
}
}
} else {
mountedRoots.add(root);
}
}
return oldOnCommitFiberRoot.apply(this, arguments);
};
}
function createSignatureFunctionForTransform() {
let savedType;
let hasCustomHooks;
let didCollectHooks = false;
return function(type, key, forceReset, getCustomHooks) {
if (typeof key === "string") {
if (!savedType) {
savedType = type;
hasCustomHooks = typeof getCustomHooks === "function";
}
if (type != null && (typeof type === "function" || typeof type === "object")) {
setSignature(type, key, forceReset, getCustomHooks);
}
return type;
} else {
if (!didCollectHooks && hasCustomHooks) {
didCollectHooks = true;
collectCustomHooksForSignature(savedType);
}
}
};
}
function isLikelyComponentType(type) {
switch (typeof type) {
case "function": {
if (type.prototype != null) {
if (type.prototype.isReactComponent) {
return true;
}
const ownNames = Object.getOwnPropertyNames(type.prototype);
if (ownNames.length > 1 || ownNames[0] !== "constructor") {
return false;
}
if (type.prototype.__proto__ !== Object.prototype) {
return false;
}
}
const name = type.name || type.displayName;
return typeof name === "string" && /^[A-Z]/.test(name);
}
case "object": {
if (type != null) {
switch (getProperty(type, "$$typeof")) {
case REACT_FORWARD_REF_TYPE:
case REACT_MEMO_TYPE:
return true;
default:
return false;
}
}
return false;
}
default: {
return false;
}
}
}
if (window.$RefreshReg$) {
throw new Error(
"React refresh runtime was loaded twice. Maybe you forgot the base path?"
);
}
function getRefreshReg(filename) {
return (type, id) => register(type, filename + " " + id);
}
function registerExportsForReactRefresh(filename, moduleExports) {
for (const key in moduleExports) {
if (key === "__esModule") continue;
const exportValue = moduleExports[key];
if (isLikelyComponentType(exportValue)) {
register(exportValue, filename + " export " + key);
}
}
}
function debounce(fn, delay) {
let handle;
return () => {
clearTimeout(handle);
handle = setTimeout(fn, delay);
};
}
const hooks = [];
window.__registerBeforePerformReactRefresh = (cb) => {
hooks.push(cb);
};
const enqueueUpdate = debounce(async () => {
if (hooks.length) await Promise.all(hooks.map((cb) => cb()));
performReactRefresh();
}, 16);
function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
var _a, _b;
const ignoredExports = (_b = (_a = window.__getReactRefreshIgnoredExports) == null ? void 0 : _a.call(window, { id })) != null ? _b : [];
if (predicateOnExport(
ignoredExports,
prevExports,
(key) => key in nextExports
) !== true) {
return "Could not Fast Refresh (export removed)";
}
if (predicateOnExport(
ignoredExports,
nextExports,
(key) => key in prevExports
) !== true) {
return "Could not Fast Refresh (new export)";
}
let hasExports = false;
const allExportsAreComponentsOrUnchanged = predicateOnExport(
ignoredExports,
nextExports,
(key, value) => {
hasExports = true;
if (isLikelyComponentType(value)) return true;
return prevExports[key] === nextExports[key];
}
);
if (hasExports && allExportsAreComponentsOrUnchanged === true) {
enqueueUpdate();
} else {
return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react-swc#consistent-components-exports`;
}
}
function predicateOnExport(ignoredExports, moduleExports, predicate) {
for (const key in moduleExports) {
if (key === "__esModule") continue;
if (ignoredExports.includes(key)) continue;
const desc = Object.getOwnPropertyDescriptor(moduleExports, key);
if (desc && desc.get) return key;
if (!predicate(key, moduleExports[key])) return key;
}
return true;
}
const __hmr_import = (module) => import(
/* @vite-ignore */
module
);
var refresh_runtime_default = { injectIntoGlobalHook };
export {
__hmr_import,
createSignatureFunctionForTransform,
refresh_runtime_default as default,
getRefreshReg,
injectIntoGlobalHook,
registerExportsForReactRefresh,
validateRefreshBoundaryAndEnqueueUpdate
};