Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

Location:
imaps-frontend/node_modules/@vitejs/plugin-react
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/@vitejs/plugin-react/dist/index.cjs

    rd565449 r0c6b92a  
    6363  window.$RefreshSig$ = prevRefreshSig;
    6464}`;
    65 const sharedFooter = `
     65const sharedFooter = (id) => `
    6666if (import.meta.hot && !inWebWorker) {
    6767  RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
    68     RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports);
     68    RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
     69  id
     70)}, currentExports);
    6971    import.meta.hot.accept((nextExports) => {
    7072      if (!nextExports) return;
    71       const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports);
     73      const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(
     74  id
     75)}, currentExports, nextExports);
    7276      if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
    7377    });
     
    7579}`;
    7680function addRefreshWrapper(code, id) {
    77   return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter.replace("__SOURCE__", JSON.stringify(id));
     81  return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter(id);
    7882}
    7983function addClassComponentRefreshWrapper(code, id) {
    80   return sharedHeader + code + sharedFooter.replace("__SOURCE__", JSON.stringify(id));
     84  return sharedHeader + code + sharedFooter(id);
    8185}
    8286
     
    195199        // This crates issues the react compiler because the re-order is too important
    196200        // People should use @babel/plugin-transform-react-jsx-development to get back good line numbers
    197         retainLines: hasCompiler(plugins) ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
     201        retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
    198202        parserOpts: {
    199203          ...babelOptions.parserOpts,
     
    204208        generatorOpts: {
    205209          ...babelOptions.generatorOpts,
     210          // import attributes parsing available without plugin since 7.26
     211          importAttributesKeyword: "with",
    206212          decoratorsBeforeExport: true
    207213        },
     
    222228    }
    223229  };
    224   const dependencies = ["react", jsxImportDevRuntime, jsxImportRuntime];
     230  const dependencies = [
     231    "react",
     232    "react-dom",
     233    jsxImportDevRuntime,
     234    jsxImportRuntime
     235  ];
    225236  const staticBabelPlugins = typeof opts.babel === "object" ? opts.babel?.plugins ?? [] : [];
    226   if (hasCompilerWithDefaultRuntime(staticBabelPlugins)) {
    227     dependencies.push("react/compiler-runtime");
     237  const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins);
     238  if (reactCompilerPlugin != null) {
     239    const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin);
     240    dependencies.push(reactCompilerRuntimeModule);
    228241  }
    229242  const viteReactRefresh = {
     
    269282        return;
    270283      }
     284      if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
     285        return;
     286      }
    271287      if (userConfig.build?.rollupOptions?.onwarn) {
    272288        userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
     
    307323  return value !== void 0;
    308324}
    309 function hasCompiler(plugins) {
    310   return plugins.some(
     325function getReactCompilerPlugin(plugins) {
     326  return plugins.find(
    311327    (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler"
    312328  );
    313329}
    314 function hasCompilerWithDefaultRuntime(plugins) {
    315   return plugins.some(
    316     (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler" && p[1]?.runtimeModule === void 0
    317   );
     330function getReactCompilerRuntimeModule(plugin) {
     331  let moduleName = "react/compiler-runtime";
     332  if (Array.isArray(plugin)) {
     333    if (plugin[1]?.target === "17" || plugin[1]?.target === "18") {
     334      moduleName = "react-compiler-runtime";
     335    } else if (typeof plugin[1]?.runtimeModule === "string") {
     336      moduleName = plugin[1]?.runtimeModule;
     337    }
     338  }
     339  return moduleName;
    318340}
    319341
  • imaps-frontend/node_modules/@vitejs/plugin-react/dist/index.mjs

    rd565449 r0c6b92a  
    5555  window.$RefreshSig$ = prevRefreshSig;
    5656}`;
    57 const sharedFooter = `
     57const sharedFooter = (id) => `
    5858if (import.meta.hot && !inWebWorker) {
    5959  RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
    60     RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports);
     60    RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
     61  id
     62)}, currentExports);
    6163    import.meta.hot.accept((nextExports) => {
    6264      if (!nextExports) return;
    63       const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports);
     65      const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(
     66  id
     67)}, currentExports, nextExports);
    6468      if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
    6569    });
     
    6771}`;
    6872function addRefreshWrapper(code, id) {
    69   return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter.replace("__SOURCE__", JSON.stringify(id));
     73  return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter(id);
    7074}
    7175function addClassComponentRefreshWrapper(code, id) {
    72   return sharedHeader + code + sharedFooter.replace("__SOURCE__", JSON.stringify(id));
     76  return sharedHeader + code + sharedFooter(id);
    7377}
    7478
     
    187191        // This crates issues the react compiler because the re-order is too important
    188192        // People should use @babel/plugin-transform-react-jsx-development to get back good line numbers
    189         retainLines: hasCompiler(plugins) ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
     193        retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
    190194        parserOpts: {
    191195          ...babelOptions.parserOpts,
     
    196200        generatorOpts: {
    197201          ...babelOptions.generatorOpts,
     202          // import attributes parsing available without plugin since 7.26
     203          importAttributesKeyword: "with",
    198204          decoratorsBeforeExport: true
    199205        },
     
    214220    }
    215221  };
    216   const dependencies = ["react", jsxImportDevRuntime, jsxImportRuntime];
     222  const dependencies = [
     223    "react",
     224    "react-dom",
     225    jsxImportDevRuntime,
     226    jsxImportRuntime
     227  ];
    217228  const staticBabelPlugins = typeof opts.babel === "object" ? opts.babel?.plugins ?? [] : [];
    218   if (hasCompilerWithDefaultRuntime(staticBabelPlugins)) {
    219     dependencies.push("react/compiler-runtime");
     229  const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins);
     230  if (reactCompilerPlugin != null) {
     231    const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin);
     232    dependencies.push(reactCompilerRuntimeModule);
    220233  }
    221234  const viteReactRefresh = {
     
    261274        return;
    262275      }
     276      if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
     277        return;
     278      }
    263279      if (userConfig.build?.rollupOptions?.onwarn) {
    264280        userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
     
    299315  return value !== void 0;
    300316}
    301 function hasCompiler(plugins) {
    302   return plugins.some(
     317function getReactCompilerPlugin(plugins) {
     318  return plugins.find(
    303319    (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler"
    304320  );
    305321}
    306 function hasCompilerWithDefaultRuntime(plugins) {
    307   return plugins.some(
    308     (p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler" && p[1]?.runtimeModule === void 0
    309   );
     322function getReactCompilerRuntimeModule(plugin) {
     323  let moduleName = "react/compiler-runtime";
     324  if (Array.isArray(plugin)) {
     325    if (plugin[1]?.target === "17" || plugin[1]?.target === "18") {
     326      moduleName = "react-compiler-runtime";
     327    } else if (typeof plugin[1]?.runtimeModule === "string") {
     328      moduleName = plugin[1]?.runtimeModule;
     329    }
     330  }
     331  return moduleName;
    310332}
    311333
  • imaps-frontend/node_modules/@vitejs/plugin-react/dist/refreshUtils.js

    rd565449 r0c6b92a  
    88
    99/* eslint-disable no-undef */
    10 const enqueueUpdate = debounce(exports.performReactRefresh, 16)
     10const hooks = []
     11window.__registerBeforePerformReactRefresh = (cb) => {
     12  hooks.push(cb)
     13}
     14const enqueueUpdate = debounce(async () => {
     15  if (hooks.length) await Promise.all(hooks.map((cb) => cb()))
     16  exports.performReactRefresh()
     17}, 16)
    1118
    1219// Taken from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/runtime/RefreshUtils.js#L141
     
    2633}
    2734
    28 function validateRefreshBoundaryAndEnqueueUpdate(prevExports, nextExports) {
    29   if (!predicateOnExport(prevExports, (key) => key in nextExports)) {
     35function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
     36  const ignoredExports = window.__getReactRefreshIgnoredExports?.({ id }) ?? []
     37  if (
     38    predicateOnExport(
     39      ignoredExports,
     40      prevExports,
     41      (key) => key in nextExports,
     42    ) !== true
     43  ) {
    3044    return 'Could not Fast Refresh (export removed)'
    3145  }
    32   if (!predicateOnExport(nextExports, (key) => key in prevExports)) {
     46  if (
     47    predicateOnExport(
     48      ignoredExports,
     49      nextExports,
     50      (key) => key in prevExports,
     51    ) !== true
     52  ) {
    3353    return 'Could not Fast Refresh (new export)'
    3454  }
     
    3656  let hasExports = false
    3757  const allExportsAreComponentsOrUnchanged = predicateOnExport(
     58    ignoredExports,
    3859    nextExports,
    3960    (key, value) => {
     
    4364    },
    4465  )
    45   if (hasExports && allExportsAreComponentsOrUnchanged) {
     66  if (hasExports && allExportsAreComponentsOrUnchanged === true) {
    4667    enqueueUpdate()
    4768  } else {
    48     return 'Could not Fast Refresh. Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports'
     69    return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports`
    4970  }
    5071}
    5172
    52 function predicateOnExport(moduleExports, predicate) {
     73function predicateOnExport(ignoredExports, moduleExports, predicate) {
    5374  for (const key in moduleExports) {
    5475    if (key === '__esModule') continue
     76    if (ignoredExports.includes(key)) continue
    5577    const desc = Object.getOwnPropertyDescriptor(moduleExports, key)
    56     if (desc && desc.get) return false
    57     if (!predicate(key, moduleExports[key])) return false
     78    if (desc && desc.get) return key
     79    if (!predicate(key, moduleExports[key])) return key
    5880  }
    5981  return true
  • imaps-frontend/node_modules/@vitejs/plugin-react/package.json

    rd565449 r0c6b92a  
    11{
    22  "name": "@vitejs/plugin-react",
    3   "version": "4.3.1",
     3  "version": "4.3.4",
    44  "license": "MIT",
    55  "author": "Evan You",
     
    3939  "homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
    4040  "dependencies": {
    41     "@babel/core": "^7.24.5",
    42     "@babel/plugin-transform-react-jsx-self": "^7.24.5",
    43     "@babel/plugin-transform-react-jsx-source": "^7.24.1",
     41    "@babel/core": "^7.26.0",
     42    "@babel/plugin-transform-react-jsx-self": "^7.25.9",
     43    "@babel/plugin-transform-react-jsx-source": "^7.25.9",
    4444    "@types/babel__core": "^7.20.5",
    4545    "react-refresh": "^0.14.2"
    4646  },
    4747  "peerDependencies": {
    48     "vite": "^4.2.0 || ^5.0.0"
     48    "vite": "^4.2.0 || ^5.0.0 || ^6.0.0"
    4949  },
    5050  "devDependencies": {
Note: See TracChangeset for help on using the changeset viewer.