@modern-js/utils 2.22.0 → 2.22.1-alpha.0

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.
Files changed (113) hide show
  1. package/dist/FileSizeReporter.d.ts +16 -0
  2. package/dist/FileSizeReporter.js +162 -0
  3. package/dist/alias.d.ts +25 -0
  4. package/dist/alias.js +108 -0
  5. package/dist/analyzeProject.d.ts +2 -0
  6. package/dist/analyzeProject.js +71 -0
  7. package/dist/applyOptionsChain.d.ts +3 -0
  8. package/dist/applyOptionsChain.js +58 -0
  9. package/dist/babel.d.ts +3 -0
  10. package/dist/babel.js +136 -0
  11. package/dist/chainId.d.ts +244 -0
  12. package/dist/chainId.js +196 -0
  13. package/dist/clearConsole.d.ts +1 -0
  14. package/dist/clearConsole.js +31 -0
  15. package/dist/commands.d.ts +4 -0
  16. package/dist/commands.js +48 -0
  17. package/dist/compatRequire.d.ts +13 -0
  18. package/dist/compatRequire.js +82 -0
  19. package/dist/compiled.d.ts +43 -0
  20. package/dist/compiled.js +142 -0
  21. package/dist/constants.d.ts +244 -0
  22. package/dist/constants.js +320 -0
  23. package/dist/debug.d.ts +6 -0
  24. package/dist/debug.js +28 -0
  25. package/dist/emptyDir.d.ts +1 -0
  26. package/dist/emptyDir.js +52 -0
  27. package/dist/ensureAbsolutePath.d.ts +7 -0
  28. package/dist/ensureAbsolutePath.js +38 -0
  29. package/dist/ensureArray.d.ts +1 -0
  30. package/dist/ensureArray.js +32 -0
  31. package/dist/findExists.d.ts +6 -0
  32. package/dist/findExists.js +45 -0
  33. package/dist/generateMetaTags.d.ts +16 -0
  34. package/dist/generateMetaTags.js +61 -0
  35. package/dist/getBrowserslist.d.ts +2 -0
  36. package/dist/getBrowserslist.js +31 -0
  37. package/dist/getCoreJsVersion.d.ts +1 -0
  38. package/dist/getCoreJsVersion.js +46 -0
  39. package/dist/getEntryOptions.d.ts +1 -0
  40. package/dist/getEntryOptions.js +54 -0
  41. package/dist/getPackageManager.d.ts +1 -0
  42. package/dist/getPackageManager.js +87 -0
  43. package/dist/getPort.d.ts +14 -0
  44. package/dist/getPort.js +112 -0
  45. package/dist/getServerConfig.d.ts +1 -0
  46. package/dist/getServerConfig.js +67 -0
  47. package/dist/getTargetDir.d.ts +1 -0
  48. package/dist/getTargetDir.js +41 -0
  49. package/dist/import.d.ts +5 -0
  50. package/dist/import.js +33 -0
  51. package/dist/index.d.ts +44 -0
  52. package/dist/index.js +60 -0
  53. package/dist/is/index.d.ts +58 -0
  54. package/dist/is/index.js +114 -0
  55. package/dist/is/nodeEnv.d.ts +8 -0
  56. package/dist/is/nodeEnv.js +39 -0
  57. package/dist/is/platform.d.ts +2 -0
  58. package/dist/is/platform.js +30 -0
  59. package/dist/is/type.d.ts +8 -0
  60. package/dist/is/type.js +64 -0
  61. package/dist/logger.d.ts +65 -0
  62. package/dist/logger.js +145 -0
  63. package/dist/monorepo.d.ts +11 -0
  64. package/dist/monorepo.js +137 -0
  65. package/dist/nodeEnv.d.ts +3 -0
  66. package/dist/nodeEnv.js +81 -0
  67. package/dist/path.d.ts +18 -0
  68. package/dist/path.js +92 -0
  69. package/dist/pathSerializer.d.ts +16 -0
  70. package/dist/pathSerializer.js +76 -0
  71. package/dist/plugin.d.ts +2 -0
  72. package/dist/plugin.js +46 -0
  73. package/dist/prettyInstructions.d.ts +9 -0
  74. package/dist/prettyInstructions.js +112 -0
  75. package/dist/printBuildError.d.ts +8 -0
  76. package/dist/printBuildError.js +57 -0
  77. package/dist/react.d.ts +1 -0
  78. package/dist/react.js +64 -0
  79. package/dist/readTsConfig.d.ts +2 -0
  80. package/dist/readTsConfig.js +47 -0
  81. package/dist/removeSlash.d.ts +3 -0
  82. package/dist/removeSlash.js +33 -0
  83. package/dist/resolve.d.ts +13 -0
  84. package/dist/resolve.js +63 -0
  85. package/dist/routes.d.ts +2 -0
  86. package/dist/routes.js +58 -0
  87. package/dist/runtimeExports.d.ts +4 -0
  88. package/dist/runtimeExports.js +73 -0
  89. package/dist/ssr.d.ts +8 -0
  90. package/dist/ssr.js +30 -0
  91. package/dist/storage.d.ts +5 -0
  92. package/dist/storage.js +75 -0
  93. package/dist/testUtils.d.ts +5 -0
  94. package/dist/testUtils.js +38 -0
  95. package/dist/types.d.ts +1 -0
  96. package/dist/types.js +15 -0
  97. package/dist/universal/constants.d.ts +9 -0
  98. package/dist/universal/constants.js +30 -0
  99. package/dist/universal/formatWebpack.d.ts +13 -0
  100. package/dist/universal/formatWebpack.js +100 -0
  101. package/dist/universal/nestedRoutes.d.ts +8 -0
  102. package/dist/universal/nestedRoutes.js +131 -0
  103. package/dist/universal/remixRouter.d.ts +1 -0
  104. package/dist/universal/remixRouter.js +17 -0
  105. package/dist/universal/serialize.d.ts +1 -0
  106. package/dist/universal/serialize.js +40 -0
  107. package/dist/version.d.ts +2 -0
  108. package/dist/version.js +92 -0
  109. package/dist/wait.d.ts +2 -0
  110. package/dist/wait.js +29 -0
  111. package/dist/watch.d.ts +8 -0
  112. package/dist/watch.js +90 -0
  113. package/package.json +3 -3
@@ -0,0 +1,75 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var storage_exports = {};
29
+ __export(storage_exports, {
30
+ createStorage: () => createStorage
31
+ });
32
+ module.exports = __toCommonJS(storage_exports);
33
+ var ah = __toESM(require("async_hooks"));
34
+ const createStorage = () => {
35
+ let storage;
36
+ if (typeof ah.AsyncLocalStorage !== "undefined") {
37
+ storage = new ah.AsyncLocalStorage();
38
+ }
39
+ const run = (context, cb) => {
40
+ if (!storage) {
41
+ throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
42
+ `);
43
+ }
44
+ return new Promise((resolve, reject) => {
45
+ storage.run(context, () => {
46
+ try {
47
+ return resolve(cb());
48
+ } catch (error) {
49
+ return reject(error);
50
+ }
51
+ });
52
+ });
53
+ };
54
+ const useContext = () => {
55
+ if (!storage) {
56
+ throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
57
+ `);
58
+ }
59
+ const context = storage.getStore();
60
+ if (!context) {
61
+ throw new Error(
62
+ `Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`
63
+ );
64
+ }
65
+ return context;
66
+ };
67
+ return {
68
+ run,
69
+ useContext
70
+ };
71
+ };
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ createStorage
75
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ *
3
+ * remove the path before "modern.js"
4
+ */
5
+ export declare const initSnapshotSerializer: (root: string) => void;
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var testUtils_exports = {};
19
+ __export(testUtils_exports, {
20
+ initSnapshotSerializer: () => initSnapshotSerializer
21
+ });
22
+ module.exports = __toCommonJS(testUtils_exports);
23
+ const initSnapshotSerializer = (root) => {
24
+ expect.addSnapshotSerializer({
25
+ test: (val) => typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root)),
26
+ print: (val) => (
27
+ // eslint-disable-next-line no-nested-ternary
28
+ typeof val === "string" ? (
29
+ // eslint-disable-next-line no-nested-ternary
30
+ val.includes("node_modules") ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, "/")}"` : val.includes("modern.js") ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, "/")}"` : `"${val.replace(root, "").replace(/\\/g, "/")}"`
31
+ ) : val
32
+ )
33
+ });
34
+ };
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ initSnapshotSerializer
38
+ });
@@ -0,0 +1 @@
1
+ export type Falsy = false | null | undefined | 0 | '';
package/dist/types.js ADDED
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Property mounted on window that describes route manifest
3
+ */
4
+ export declare const ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
5
+ /**
6
+ * hmr socket connect path
7
+ */
8
+
9
+ export declare const HMR_SOCK_PATH = "/webpack-hmr";
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var constants_exports = {};
19
+ __export(constants_exports, {
20
+ HMR_SOCK_PATH: () => HMR_SOCK_PATH,
21
+ ROUTE_MANIFEST: () => ROUTE_MANIFEST
22
+ });
23
+ module.exports = __toCommonJS(constants_exports);
24
+ const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
25
+ const HMR_SOCK_PATH = "/webpack-hmr";
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ HMR_SOCK_PATH,
29
+ ROUTE_MANIFEST
30
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file at
6
+ * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
+ */
8
+ import type { StatsCompilation } from 'webpack';
9
+ declare function formatWebpackMessages(json?: Pick<StatsCompilation, 'errors' | 'warnings'>): {
10
+ errors: string[];
11
+ warnings: string[];
12
+ };
13
+ export { formatWebpackMessages };
@@ -0,0 +1,100 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var formatWebpack_exports = {};
19
+ __export(formatWebpack_exports, {
20
+ formatWebpackMessages: () => formatWebpackMessages
21
+ });
22
+ module.exports = __toCommonJS(formatWebpack_exports);
23
+ const friendlySyntaxErrorLabel = "SyntaxError:";
24
+ function isLikelyASyntaxError(message) {
25
+ return message.includes(friendlySyntaxErrorLabel);
26
+ }
27
+ function formatMessage(stats) {
28
+ let lines = [];
29
+ let message;
30
+ if (typeof stats === "object") {
31
+ const fileName = stats.moduleName ? `File: ${stats.moduleName}
32
+ ` : "";
33
+ const mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
34
+ const details = stats.details ? `
35
+ Details: ${stats.details}
36
+ ` : "";
37
+ const stack = stats.stack ? `
38
+ ${stats.stack}` : "";
39
+ message = `${fileName}${mainMessage}${details}${stack}`;
40
+ } else {
41
+ message = stats;
42
+ }
43
+ lines = message.split("\n");
44
+ lines = lines.map((line) => {
45
+ const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
46
+ line
47
+ );
48
+ if (!parsingError) {
49
+ return line;
50
+ }
51
+ const [, errorLine, errorColumn, errorMessage] = parsingError;
52
+ return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
53
+ });
54
+ message = lines.join("\n");
55
+ message = message.replace(
56
+ /SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
57
+ `${friendlySyntaxErrorLabel} $3 ($1:$2)
58
+ `
59
+ );
60
+ lines = message.split("\n");
61
+ if (lines.length > 2 && lines[1].trim() === "") {
62
+ lines.splice(1, 1);
63
+ }
64
+ lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
65
+ if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
66
+ lines[1] = lines[1].replace("Error: ", "");
67
+ }
68
+ message = lines.join("\n");
69
+ message = message.replace(
70
+ /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
71
+ ""
72
+ );
73
+ message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
74
+ lines = message.split("\n");
75
+ lines = lines.filter(
76
+ (line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
77
+ );
78
+ message = lines.join("\n");
79
+ return message.trim();
80
+ }
81
+ function formatWebpackMessages(json) {
82
+ var _a, _b, _c;
83
+ const formattedErrors = (_a = json == null ? void 0 : json.errors) == null ? void 0 : _a.map(formatMessage);
84
+ const formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
85
+ const result = {
86
+ errors: formattedErrors || [],
87
+ warnings: formattedWarnings || []
88
+ };
89
+ if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
90
+ result.errors = result.errors.filter(isLikelyASyntaxError);
91
+ }
92
+ if (result.errors.length > 1) {
93
+ result.errors.length = 1;
94
+ }
95
+ return result;
96
+ }
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ formatWebpackMessages
100
+ });
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { NestedRoute } from '@modern-js/types';
3
+ export declare const transformNestedRoutes: (routes: NestedRoute[]) => import("react-router-dom").RouteObject[];
4
+ export declare const renderNestedRoute: (nestedRoute: NestedRoute, options?: {
5
+ parent?: NestedRoute;
6
+ DeferredDataComponent?: () => JSX.Element | null;
7
+ props?: Record<string, any>;
8
+ }) => JSX.Element;
@@ -0,0 +1,131 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+ var nestedRoutes_exports = {};
36
+ __export(nestedRoutes_exports, {
37
+ renderNestedRoute: () => renderNestedRoute,
38
+ transformNestedRoutes: () => transformNestedRoutes
39
+ });
40
+ module.exports = __toCommonJS(nestedRoutes_exports);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_react = require("react");
43
+ var import_react_router_dom = require("react-router-dom");
44
+ const transformNestedRoutes = (routes) => {
45
+ const routeElements = [];
46
+ for (const route of routes) {
47
+ const routeElement = renderNestedRoute(route);
48
+ routeElements.push(routeElement);
49
+ }
50
+ return (0, import_react_router_dom.createRoutesFromElements)(routeElements);
51
+ };
52
+ const renderNestedRoute = (nestedRoute, options = {}) => {
53
+ const { children, index, id, component, isRoot, lazyImport } = nestedRoute;
54
+ const Component = component;
55
+ const { parent, DeferredDataComponent, props = {} } = options;
56
+ const routeProps = {
57
+ caseSensitive: nestedRoute.caseSensitive,
58
+ path: nestedRoute.path,
59
+ id: nestedRoute.id,
60
+ loader: createLoader(nestedRoute),
61
+ action: nestedRoute.action,
62
+ hasErrorBoundary: nestedRoute.hasErrorBoundary,
63
+ shouldRevalidate: nestedRoute.shouldRevalidate,
64
+ handle: nestedRoute.handle,
65
+ index: nestedRoute.index,
66
+ element: nestedRoute.element,
67
+ errorElement: nestedRoute.errorElement
68
+ };
69
+ if (nestedRoute.error) {
70
+ const errorElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(nestedRoute.error, {});
71
+ routeProps.errorElement = errorElement;
72
+ }
73
+ let element;
74
+ if (Component) {
75
+ if ((parent == null ? void 0 : parent.loading) && lazyImport) {
76
+ const Loading = parent.loading;
77
+ if (isLoadableComponent(Component)) {
78
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}) });
79
+ } else {
80
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
81
+ }
82
+ } else if (isLoadableComponent(Component) && lazyImport) {
83
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
84
+ } else if (isRoot) {
85
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
86
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, props)),
87
+ typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {})
88
+ ] });
89
+ } else if (lazyImport) {
90
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
91
+ } else {
92
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
93
+ }
94
+ } else {
95
+ nestedRoute.loading = parent == null ? void 0 : parent.loading;
96
+ }
97
+ if (element) {
98
+ routeProps.element = element;
99
+ }
100
+ const childElements = children == null ? void 0 : children.map((childRoute) => {
101
+ return renderNestedRoute(childRoute, { parent: nestedRoute });
102
+ });
103
+ const routeElement = index ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), { index: true }), id) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), { index: false, children: childElements }), id);
104
+ return routeElement;
105
+ };
106
+ function createLoader(route) {
107
+ const { loader } = route;
108
+ if (loader) {
109
+ return (args) => {
110
+ if (typeof route.lazyImport === "function") {
111
+ route.lazyImport();
112
+ }
113
+ return loader(args);
114
+ };
115
+ } else {
116
+ return () => {
117
+ if (typeof route.lazyImport === "function") {
118
+ route.lazyImport();
119
+ }
120
+ return null;
121
+ };
122
+ }
123
+ }
124
+ function isLoadableComponent(component) {
125
+ return component && component.displayName === "Loadable" && component.preload && typeof component.preload === "function";
126
+ }
127
+ // Annotate the CommonJS export names for ESM import in node:
128
+ 0 && (module.exports = {
129
+ renderNestedRoute,
130
+ transformNestedRoutes
131
+ });
@@ -0,0 +1 @@
1
+ export * from '@remix-run/router';
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var remixRouter_exports = {};
16
+ module.exports = __toCommonJS(remixRouter_exports);
17
+ __reExport(remixRouter_exports, require("@remix-run/router"), module.exports);
@@ -0,0 +1 @@
1
+ export declare const serializeJson: (data: any) => string;
@@ -0,0 +1,40 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var serialize_exports = {};
29
+ __export(serialize_exports, {
30
+ serializeJson: () => serializeJson
31
+ });
32
+ module.exports = __toCommonJS(serialize_exports);
33
+ var import_serialize_javascript = __toESM(require("serialize-javascript"));
34
+ const serializeJson = (data) => {
35
+ return (0, import_serialize_javascript.default)(data, { isJSON: true });
36
+ };
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ serializeJson
40
+ });
@@ -0,0 +1,2 @@
1
+ export declare function getPnpmVersion(): Promise<string>;
2
+ export declare const isReact18: (cwd: string) => boolean;
@@ -0,0 +1,92 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ // If the importer is in node compatibility mode or this is not an ESM
35
+ // file that has been converted to a CommonJS file using a Babel-
36
+ // compatible transform (i.e. "__esModule" has not been set), then set
37
+ // "default" to the CommonJS "module.exports" for node compatibility.
38
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
+ mod
40
+ ));
41
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
+ var __async = (__this, __arguments, generator) => {
43
+ return new Promise((resolve, reject) => {
44
+ var fulfilled = (value) => {
45
+ try {
46
+ step(generator.next(value));
47
+ } catch (e) {
48
+ reject(e);
49
+ }
50
+ };
51
+ var rejected = (value) => {
52
+ try {
53
+ step(generator.throw(value));
54
+ } catch (e) {
55
+ reject(e);
56
+ }
57
+ };
58
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
59
+ step((generator = generator.apply(__this, __arguments)).next());
60
+ });
61
+ };
62
+ var version_exports = {};
63
+ __export(version_exports, {
64
+ getPnpmVersion: () => getPnpmVersion,
65
+ isReact18: () => isReact18
66
+ });
67
+ module.exports = __toCommonJS(version_exports);
68
+ var import_path = __toESM(require("path"));
69
+ var import_compiled = require("./compiled");
70
+ function getPnpmVersion() {
71
+ return __async(this, null, function* () {
72
+ const { stdout } = yield (0, import_compiled.execa)("pnpm", ["--version"]);
73
+ return stdout;
74
+ });
75
+ }
76
+ const isReact18 = (cwd) => {
77
+ const pkgPath = import_path.default.join(cwd, "package.json");
78
+ if (!import_compiled.fs.existsSync(pkgPath)) {
79
+ return false;
80
+ }
81
+ const pkgInfo = JSON.parse(import_compiled.fs.readFileSync(pkgPath, "utf8"));
82
+ const deps = __spreadValues(__spreadValues({}, pkgInfo.devDependencies), pkgInfo.dependencies);
83
+ if (typeof deps.react !== "string") {
84
+ return false;
85
+ }
86
+ return import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=18.0.0");
87
+ };
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ getPnpmVersion,
91
+ isReact18
92
+ });
package/dist/wait.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const wait: (time?: number) => Promise<unknown>;
2
+ export { wait };
package/dist/wait.js ADDED
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var wait_exports = {};
19
+ __export(wait_exports, {
20
+ wait: () => wait
21
+ });
22
+ module.exports = __toCommonJS(wait_exports);
23
+ const wait = (time = 0) => new Promise((resolve) => {
24
+ setTimeout(resolve, time);
25
+ });
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ wait
29
+ });
@@ -0,0 +1,8 @@
1
+ export type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
2
+ export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
3
+ type RunTaskType = (option: {
4
+ changedFilePath: string;
5
+ changeType: WatchChangeTypeValueT;
6
+ }) => void | Promise<void>;
7
+ export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("./compiled").FSWatcher;
8
+ export {};