@modern-js/utils 2.58.2-alpha.0 → 2.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli/index.js +3 -1
- package/dist/cjs/cli/monorepo.js +3 -2
- package/dist/cjs/cli/port.js +2 -1
- package/dist/cjs/cli/require.js +4 -1
- package/dist/cjs/cli/runtimeExports.js +3 -3
- package/dist/cjs/cli/version.js +32 -0
- package/dist/esm/cli/index.js +1 -0
- package/dist/esm/cli/monorepo.js +3 -2
- package/dist/esm/cli/port.js +4 -3
- package/dist/esm/cli/require.js +5 -2
- package/dist/esm/cli/runtimeExports.js +3 -3
- package/dist/esm/cli/version.js +8 -0
- package/dist/esm-node/cli/index.js +1 -0
- package/dist/esm-node/cli/monorepo.js +3 -2
- package/dist/esm-node/cli/port.js +2 -1
- package/dist/esm-node/cli/require.js +4 -1
- package/dist/esm-node/cli/runtimeExports.js +3 -3
- package/dist/esm-node/cli/version.js +8 -0
- package/dist/types/cli/babel.d.ts +1 -1
- package/dist/types/cli/constants.d.ts +1 -1
- package/dist/types/cli/get/data.d.ts +1 -1
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/port.d.ts +1 -1
- package/dist/types/cli/version.d.ts +1 -0
- package/package.json +4 -4
- package/dist/compiled/ajv/codegen.js +0 -1
- package/dist/compiled/ajv/index.js +0 -9
- package/dist/compiled/ajv/license +0 -22
- package/dist/compiled/ajv/package.json +0 -1
- package/dist/compiled/ajv/types/ajv.d.ts +0 -16
- package/dist/compiled/ajv/types/compile/codegen/code.d.ts +0 -40
- package/dist/compiled/ajv/types/compile/codegen/index.d.ts +0 -79
- package/dist/compiled/ajv/types/compile/codegen/scope.d.ts +0 -79
- package/dist/compiled/ajv/types/compile/errors.d.ts +0 -13
- package/dist/compiled/ajv/types/compile/index.d.ts +0 -80
- package/dist/compiled/ajv/types/compile/ref_error.d.ts +0 -6
- package/dist/compiled/ajv/types/compile/resolve.d.ts +0 -12
- package/dist/compiled/ajv/types/compile/rules.d.ts +0 -28
- package/dist/compiled/ajv/types/compile/util.d.ts +0 -40
- package/dist/compiled/ajv/types/compile/validate/index.d.ts +0 -42
- package/dist/compiled/ajv/types/compile/validate/subschema.d.ts +0 -47
- package/dist/compiled/ajv/types/core.d.ts +0 -173
- package/dist/compiled/ajv/types/runtime/validation_error.d.ts +0 -7
- package/dist/compiled/ajv/types/types/index.d.ts +0 -183
- package/dist/compiled/ajv/types/types/json-schema.d.ts +0 -124
- package/dist/compiled/ajv/types/types/jtd-schema.d.ts +0 -169
- package/dist/compiled/ajv/types/vocabularies/errors.d.ts +0 -1
- package/dist/compiled/ajv/uri-js.d.ts +0 -59
- package/dist/compiled/ajv-keywords/index.d.ts +0 -1
- package/dist/compiled/ajv-keywords/index.js +0 -1
- package/dist/compiled/ajv-keywords/license +0 -21
- package/dist/compiled/ajv-keywords/package.json +0 -1
- package/dist/compiled/better-ajv-errors/index.d.ts +0 -1
- package/dist/compiled/better-ajv-errors/index.js +0 -1
- package/dist/compiled/better-ajv-errors/license +0 -13
- package/dist/compiled/better-ajv-errors/package.json +0 -1
- package/dist/compiled/schema-utils3/index.d.ts +0 -1
- package/dist/compiled/schema-utils3/index.js +0 -3
- package/dist/compiled/schema-utils3/license +0 -20
- package/dist/compiled/schema-utils3/package.json +0 -1
package/dist/cjs/cli/index.js
CHANGED
@@ -37,6 +37,7 @@ __reExport(cli_exports, require("./watch"), module.exports);
|
|
37
37
|
__reExport(cli_exports, require("./config"), module.exports);
|
38
38
|
__reExport(cli_exports, require("./action"), module.exports);
|
39
39
|
__reExport(cli_exports, require("./route"), module.exports);
|
40
|
+
__reExport(cli_exports, require("./version"), module.exports);
|
40
41
|
// Annotate the CommonJS export names for ESM import in node:
|
41
42
|
0 && (module.exports = {
|
42
43
|
...require("./constants"),
|
@@ -60,5 +61,6 @@ __reExport(cli_exports, require("./route"), module.exports);
|
|
60
61
|
...require("./watch"),
|
61
62
|
...require("./config"),
|
62
63
|
...require("./action"),
|
63
|
-
...require("./route")
|
64
|
+
...require("./route"),
|
65
|
+
...require("./version")
|
64
66
|
});
|
package/dist/cjs/cli/monorepo.js
CHANGED
@@ -59,14 +59,15 @@ const isPnpmWorkspaces = (root) => import_fs.default.existsSync(import_path.defa
|
|
59
59
|
const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
60
60
|
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
61
61
|
let inMonorepo = false;
|
62
|
+
let monorepoRoot = appDirectory;
|
62
63
|
for (let depth = 0; depth < maxDepth; depth++) {
|
63
64
|
if (isMonorepo(appDirectory)) {
|
64
65
|
inMonorepo = true;
|
65
66
|
break;
|
66
67
|
}
|
67
|
-
|
68
|
+
monorepoRoot = import_path.default.dirname(appDirectory);
|
68
69
|
}
|
69
|
-
return inMonorepo ?
|
70
|
+
return inMonorepo ? monorepoRoot : void 0;
|
70
71
|
};
|
71
72
|
const getMonorepoPackages = (root) => {
|
72
73
|
let packages = [];
|
package/dist/cjs/cli/port.js
CHANGED
@@ -34,7 +34,8 @@ module.exports = __toCommonJS(port_exports);
|
|
34
34
|
var import_net = __toESM(require("net"));
|
35
35
|
var import_compiled = require("../compiled");
|
36
36
|
var import_logger = require("./logger");
|
37
|
-
const getPort = async (
|
37
|
+
const getPort = async (expectPort, { tryLimits = 20, strictPort = false, slient = false } = {}) => {
|
38
|
+
let port = expectPort;
|
38
39
|
if (typeof port === "string") {
|
39
40
|
port = parseInt(port, 10);
|
40
41
|
}
|
package/dist/cjs/cli/require.js
CHANGED
@@ -26,7 +26,9 @@ __export(require_exports, {
|
|
26
26
|
tryResolve: () => tryResolve
|
27
27
|
});
|
28
28
|
module.exports = __toCommonJS(require_exports);
|
29
|
+
var import_node_path = require("node:path");
|
29
30
|
var import_fs = require("./fs");
|
31
|
+
var import_node_url = require("node:url");
|
30
32
|
async function compatibleRequire(path, interop = true) {
|
31
33
|
if (path.endsWith(".json")) {
|
32
34
|
return require(path);
|
@@ -36,7 +38,8 @@ async function compatibleRequire(path, interop = true) {
|
|
36
38
|
requiredModule = require(path);
|
37
39
|
} catch (err) {
|
38
40
|
if (err.code === "ERR_REQUIRE_ESM" || err instanceof SyntaxError) {
|
39
|
-
|
41
|
+
const modulePath = (0, import_node_path.isAbsolute)(path) ? (0, import_node_url.pathToFileURL)(path).href : path;
|
42
|
+
requiredModule = await import(modulePath);
|
40
43
|
return interop ? requiredModule.default : requiredModule;
|
41
44
|
} else {
|
42
45
|
throw err;
|
@@ -50,11 +50,11 @@ const memo = (fn) => {
|
|
50
50
|
const createRuntimeExportsUtils = memo((pwd = "", namespace = "index") => {
|
51
51
|
const entryExportFile = import_path.default.join(pwd, `.runtime-exports/${namespace}.js`);
|
52
52
|
const addExport = (statement) => {
|
53
|
-
|
53
|
+
const statementStr = (0, import_path2.normalizeOutputPath)(statement);
|
54
54
|
try {
|
55
55
|
import_compiled.fs.ensureFileSync(entryExportFile);
|
56
|
-
if (!import_compiled.fs.readFileSync(entryExportFile, "utf8").includes(
|
57
|
-
import_compiled.fs.appendFileSync(entryExportFile, `${
|
56
|
+
if (!import_compiled.fs.readFileSync(entryExportFile, "utf8").includes(statementStr)) {
|
57
|
+
import_compiled.fs.appendFileSync(entryExportFile, `${statementStr}
|
58
58
|
`);
|
59
59
|
}
|
60
60
|
} catch {
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var version_exports = {};
|
20
|
+
__export(version_exports, {
|
21
|
+
isVersionAtLeast1819: () => isVersionAtLeast1819
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(version_exports);
|
24
|
+
function isVersionAtLeast1819() {
|
25
|
+
const nodeVersion = process.versions.node;
|
26
|
+
const versionArr = nodeVersion.split(".").map(Number);
|
27
|
+
return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
|
28
|
+
}
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
30
|
+
0 && (module.exports = {
|
31
|
+
isVersionAtLeast1819
|
32
|
+
});
|
package/dist/esm/cli/index.js
CHANGED
package/dist/esm/cli/monorepo.js
CHANGED
@@ -28,14 +28,15 @@ var isMonorepo = function(root) {
|
|
28
28
|
var findMonorepoRoot = function(appDirectory) {
|
29
29
|
var maxDepth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : PACKAGE_MAX_DEPTH;
|
30
30
|
var inMonorepo = false;
|
31
|
+
var monorepoRoot = appDirectory;
|
31
32
|
for (var depth = 0; depth < maxDepth; depth++) {
|
32
33
|
if (isMonorepo(appDirectory)) {
|
33
34
|
inMonorepo = true;
|
34
35
|
break;
|
35
36
|
}
|
36
|
-
|
37
|
+
monorepoRoot = path.dirname(appDirectory);
|
37
38
|
}
|
38
|
-
return inMonorepo ?
|
39
|
+
return inMonorepo ? monorepoRoot : void 0;
|
39
40
|
};
|
40
41
|
var getMonorepoPackages = function(root) {
|
41
42
|
var packages = [];
|
package/dist/esm/cli/port.js
CHANGED
@@ -4,13 +4,14 @@ import net from "net";
|
|
4
4
|
import { chalk } from "../compiled";
|
5
5
|
import { logger } from "./logger";
|
6
6
|
var getPort = function() {
|
7
|
-
var _ref = _async_to_generator(function(
|
8
|
-
var _ref2, _ref_tryLimits, tryLimits, _ref_strictPort, strictPort, _ref_slient, slient, original, found, attempts, e;
|
7
|
+
var _ref = _async_to_generator(function(expectPort) {
|
8
|
+
var _ref2, _ref_tryLimits, tryLimits, _ref_strictPort, strictPort, _ref_slient, slient, port, original, found, attempts, e;
|
9
9
|
var _arguments = arguments;
|
10
10
|
return _ts_generator(this, function(_state) {
|
11
11
|
switch (_state.label) {
|
12
12
|
case 0:
|
13
13
|
_ref2 = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, _ref_tryLimits = _ref2.tryLimits, tryLimits = _ref_tryLimits === void 0 ? 20 : _ref_tryLimits, _ref_strictPort = _ref2.strictPort, strictPort = _ref_strictPort === void 0 ? false : _ref_strictPort, _ref_slient = _ref2.slient, slient = _ref_slient === void 0 ? false : _ref_slient;
|
14
|
+
port = expectPort;
|
14
15
|
if (typeof port === "string") {
|
15
16
|
port = parseInt(port, 10);
|
16
17
|
}
|
@@ -87,7 +88,7 @@ var getPort = function() {
|
|
87
88
|
}
|
88
89
|
});
|
89
90
|
});
|
90
|
-
return function getPort2(
|
91
|
+
return function getPort2(expectPort) {
|
91
92
|
return _ref.apply(this, arguments);
|
92
93
|
};
|
93
94
|
}();
|
package/dist/esm/cli/require.js
CHANGED
@@ -2,13 +2,15 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
|
3
3
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
4
4
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
5
|
+
import { isAbsolute } from "node:path";
|
5
6
|
import { findExists } from "./fs";
|
7
|
+
import { pathToFileURL } from "node:url";
|
6
8
|
function compatibleRequire(path) {
|
7
9
|
return _compatibleRequire.apply(this, arguments);
|
8
10
|
}
|
9
11
|
function _compatibleRequire() {
|
10
12
|
_compatibleRequire = _async_to_generator(function(path) {
|
11
|
-
var interop, requiredModule, err;
|
13
|
+
var interop, requiredModule, err, modulePath;
|
12
14
|
var _arguments = arguments;
|
13
15
|
return _ts_generator(this, function(_state) {
|
14
16
|
switch (_state.label) {
|
@@ -40,9 +42,10 @@ function _compatibleRequire() {
|
|
40
42
|
3,
|
41
43
|
4
|
42
44
|
];
|
45
|
+
modulePath = isAbsolute(path) ? pathToFileURL(path).href : path;
|
43
46
|
return [
|
44
47
|
4,
|
45
|
-
import(
|
48
|
+
import(modulePath)
|
46
49
|
];
|
47
50
|
case 3:
|
48
51
|
requiredModule = _state.sent();
|
@@ -22,11 +22,11 @@ var createRuntimeExportsUtils = memo(function() {
|
|
22
22
|
var pwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", namespace = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "index";
|
23
23
|
var entryExportFile = path.join(pwd, ".runtime-exports/".concat(namespace, ".js"));
|
24
24
|
var addExport = function(statement) {
|
25
|
-
|
25
|
+
var statementStr = normalizeOutputPath(statement);
|
26
26
|
try {
|
27
27
|
fs.ensureFileSync(entryExportFile);
|
28
|
-
if (!fs.readFileSync(entryExportFile, "utf8").includes(
|
29
|
-
fs.appendFileSync(entryExportFile, "".concat(
|
28
|
+
if (!fs.readFileSync(entryExportFile, "utf8").includes(statementStr)) {
|
29
|
+
fs.appendFileSync(entryExportFile, "".concat(statementStr, "\n"));
|
30
30
|
}
|
31
31
|
} catch (e) {
|
32
32
|
}
|
@@ -21,14 +21,15 @@ const isPnpmWorkspaces = (root) => fs.existsSync(path.join(root, WORKSPACE_FILES
|
|
21
21
|
const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
22
22
|
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
23
23
|
let inMonorepo = false;
|
24
|
+
let monorepoRoot = appDirectory;
|
24
25
|
for (let depth = 0; depth < maxDepth; depth++) {
|
25
26
|
if (isMonorepo(appDirectory)) {
|
26
27
|
inMonorepo = true;
|
27
28
|
break;
|
28
29
|
}
|
29
|
-
|
30
|
+
monorepoRoot = path.dirname(appDirectory);
|
30
31
|
}
|
31
|
-
return inMonorepo ?
|
32
|
+
return inMonorepo ? monorepoRoot : void 0;
|
32
33
|
};
|
33
34
|
const getMonorepoPackages = (root) => {
|
34
35
|
let packages = [];
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import net from "net";
|
2
2
|
import { chalk } from "../compiled";
|
3
3
|
import { logger } from "./logger";
|
4
|
-
const getPort = async (
|
4
|
+
const getPort = async (expectPort, { tryLimits = 20, strictPort = false, slient = false } = {}) => {
|
5
|
+
let port = expectPort;
|
5
6
|
if (typeof port === "string") {
|
6
7
|
port = parseInt(port, 10);
|
7
8
|
}
|
@@ -1,4 +1,6 @@
|
|
1
|
+
import { isAbsolute } from "node:path";
|
1
2
|
import { findExists } from "./fs";
|
3
|
+
import { pathToFileURL } from "node:url";
|
2
4
|
async function compatibleRequire(path, interop = true) {
|
3
5
|
if (path.endsWith(".json")) {
|
4
6
|
return require(path);
|
@@ -8,7 +10,8 @@ async function compatibleRequire(path, interop = true) {
|
|
8
10
|
requiredModule = require(path);
|
9
11
|
} catch (err) {
|
10
12
|
if (err.code === "ERR_REQUIRE_ESM" || err instanceof SyntaxError) {
|
11
|
-
|
13
|
+
const modulePath = isAbsolute(path) ? pathToFileURL(path).href : path;
|
14
|
+
requiredModule = await import(modulePath);
|
12
15
|
return interop ? requiredModule.default : requiredModule;
|
13
16
|
} else {
|
14
17
|
throw err;
|
@@ -17,11 +17,11 @@ const memo = (fn) => {
|
|
17
17
|
const createRuntimeExportsUtils = memo((pwd = "", namespace = "index") => {
|
18
18
|
const entryExportFile = path.join(pwd, `.runtime-exports/${namespace}.js`);
|
19
19
|
const addExport = (statement) => {
|
20
|
-
|
20
|
+
const statementStr = normalizeOutputPath(statement);
|
21
21
|
try {
|
22
22
|
fs.ensureFileSync(entryExportFile);
|
23
|
-
if (!fs.readFileSync(entryExportFile, "utf8").includes(
|
24
|
-
fs.appendFileSync(entryExportFile, `${
|
23
|
+
if (!fs.readFileSync(entryExportFile, "utf8").includes(statementStr)) {
|
24
|
+
fs.appendFileSync(entryExportFile, `${statementStr}
|
25
25
|
`);
|
26
26
|
}
|
27
27
|
} catch {
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { BabelConfig, BabelConfigUtils, BabelTransformOptions } from '@modern-js/types';
|
1
|
+
import type { BabelConfig, BabelConfigUtils, BabelTransformOptions } from '@modern-js/types';
|
2
2
|
export declare const getBabelUtils: (config: BabelTransformOptions) => BabelConfigUtils;
|
3
3
|
export declare const applyUserBabelConfig: (defaultOptions: BabelTransformOptions, userBabelConfig?: BabelConfig | BabelConfig[], extraBabelUtils?: Partial<BabelConfigUtils>) => BabelTransformOptions;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { InternalPlugins } from '@modern-js/types';
|
1
|
+
import type { InternalPlugins } from '@modern-js/types';
|
2
2
|
export { NESTED_ROUTE_SPEC_FILE, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_RENDER_FUNCTION_NAME, SERVER_PLUGIN_BFF, SERVER_PLUGIN_EXPRESS, SERVER_PLUGIN_KOA, SERVER_PLUGIN_SERVER, SERVER_PLUGIN_POLYFILL, } from '../universal/constants';
|
3
3
|
export declare const JS_EXTENSIONS: string[];
|
4
4
|
/**
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { InternalPlugins } from '@modern-js/types';
|
1
|
+
import type { InternalPlugins } from '@modern-js/types';
|
2
2
|
export declare function getPackageManager(cwd?: string): Promise<"pnpm" | "npm" | "yarn">;
|
3
3
|
export declare const getCoreJsVersion: (corejsPkgPath: string) => string;
|
4
4
|
export declare const getAntdMajorVersion: (appDirectory: string) => number | null;
|
package/dist/types/cli/port.d.ts
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
* @param strictPort - Whether to throw an error when the port is occupied.
|
6
6
|
* @returns Available port number.
|
7
7
|
*/
|
8
|
-
export declare const getPort: (
|
8
|
+
export declare const getPort: (expectPort: string | number, { tryLimits, strictPort, slient, }?: {
|
9
9
|
tryLimits?: number | undefined;
|
10
10
|
strictPort?: boolean | undefined;
|
11
11
|
slient?: boolean | undefined;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function isVersionAtLeast1819(): boolean;
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.58.2
|
18
|
+
"version": "2.58.2",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -162,9 +162,9 @@
|
|
162
162
|
"jest": "^29",
|
163
163
|
"typescript": "^5",
|
164
164
|
"webpack": "^5.93.0",
|
165
|
-
"@scripts/build": "2.58.
|
166
|
-
"@
|
167
|
-
"@
|
165
|
+
"@scripts/build": "2.58.2",
|
166
|
+
"@scripts/jest-config": "2.58.2",
|
167
|
+
"@modern-js/types": "2.58.2"
|
168
168
|
},
|
169
169
|
"sideEffects": false,
|
170
170
|
"scripts": {
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require('./').codegen;
|