@tamagui/static 2.0.0-rc.4 → 2.0.0-rc.40
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/check-dep-versions.cjs +201 -96
- package/dist/checkDeps.cjs +250 -46
- package/dist/constants.cjs +32 -30
- package/dist/exports.cjs +18 -13
- package/dist/extractor/accessSafe.cjs +25 -23
- package/dist/extractor/babelParse.cjs +30 -28
- package/dist/extractor/buildClassName.cjs +59 -35
- package/dist/extractor/bundle.cjs +177 -101
- package/dist/extractor/bundleConfig.cjs +554 -167
- package/dist/extractor/concatClassName.cjs +41 -29
- package/dist/extractor/createEvaluator.cjs +54 -41
- package/dist/extractor/createExtractor.cjs +1400 -581
- package/dist/extractor/createLogger.cjs +30 -25
- package/dist/extractor/detectModuleFormat.cjs +55 -0
- package/dist/extractor/ensureImportingConcat.cjs +31 -25
- package/dist/extractor/errors.cjs +12 -10
- package/dist/extractor/esbuildAliasPlugin.cjs +28 -16
- package/dist/extractor/esbuildTsconfigPaths.cjs +60 -36
- package/dist/extractor/evaluateAstNode.cjs +104 -59
- package/dist/extractor/extractHelpers.cjs +130 -67
- package/dist/extractor/extractMediaStyle.cjs +110 -69
- package/dist/extractor/extractToClassNames.cjs +337 -229
- package/dist/extractor/extractToNative.cjs +248 -154
- package/dist/extractor/findTopmostFunction.cjs +22 -13
- package/dist/extractor/generatedUid.cjs +39 -28
- package/dist/extractor/getPrefixLogs.cjs +12 -10
- package/dist/extractor/getPropValueFromAttributes.cjs +52 -34
- package/dist/extractor/getSourceModule.cjs +73 -37
- package/dist/extractor/getStaticBindingsForScope.cjs +131 -68
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +20 -14
- package/dist/extractor/hasTopLevelAwait.cjs +62 -0
- package/dist/extractor/hoistClassNames.cjs +46 -32
- package/dist/extractor/literalToAst.cjs +67 -42
- package/dist/extractor/loadFile.cjs +9 -3
- package/dist/extractor/loadTamagui.cjs +149 -104
- package/dist/extractor/logLines.cjs +27 -19
- package/dist/extractor/normalizeTernaries.cjs +66 -44
- package/dist/extractor/propsToFontFamilyCache.cjs +15 -11
- package/dist/extractor/regenerateConfig.cjs +109 -81
- package/dist/extractor/removeUnusedHooks.cjs +73 -41
- package/dist/extractor/timer.cjs +23 -14
- package/dist/extractor/validHTMLAttributes.cjs +61 -59
- package/dist/extractor/watchTamaguiConfig.cjs +35 -23
- package/dist/getPragmaOptions.cjs +38 -19
- package/dist/helpers/memoize.cjs +24 -16
- package/dist/helpers/requireTamaguiCore.cjs +22 -15
- package/dist/index.cjs +26 -24
- package/dist/registerRequire.cjs +167 -65
- package/dist/server.cjs +35 -28
- package/dist/types.cjs +7 -5
- package/dist/worker.cjs +62 -40
- package/package.json +26 -22
- package/src/checkDeps.ts +305 -68
- package/src/exports.ts +1 -0
- package/src/extractor/babelParse.ts +1 -0
- package/src/extractor/bundle.ts +140 -37
- package/src/extractor/bundleConfig.ts +435 -61
- package/src/extractor/createExtractor.ts +283 -48
- package/src/extractor/detectModuleFormat.ts +42 -0
- package/src/extractor/esbuildTsconfigPaths.ts +6 -1
- package/src/extractor/extractToClassNames.ts +15 -9
- package/src/extractor/extractToNative.ts +66 -33
- package/src/extractor/hasTopLevelAwait.ts +28 -0
- package/src/extractor/loadTamagui.ts +2 -2
- package/src/getPragmaOptions.ts +6 -1
- package/src/registerRequire.ts +88 -8
- package/types/checkDeps.d.ts.map +1 -1
- package/types/exports.d.ts +1 -0
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +83 -1
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +15 -2
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/detectModuleFormat.d.ts +5 -0
- package/types/extractor/detectModuleFormat.d.ts.map +1 -0
- package/types/extractor/esbuildTsconfigPaths.d.ts +8 -0
- package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/hasTopLevelAwait.d.ts +2 -0
- package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
- package/types/getPragmaOptions.d.ts.map +1 -1
- package/types/registerRequire.d.ts.map +1 -1
- package/dist/check-dep-versions.js +0 -389
- package/dist/check-dep-versions.js.map +0 -6
- package/dist/checkDeps.js +0 -60
- package/dist/checkDeps.js.map +0 -6
- package/dist/constants.js +0 -34
- package/dist/constants.js.map +0 -6
- package/dist/exports.js +0 -34
- package/dist/exports.js.map +0 -6
- package/dist/extractor/accessSafe.js +0 -47
- package/dist/extractor/accessSafe.js.map +0 -6
- package/dist/extractor/babelParse.js +0 -59
- package/dist/extractor/babelParse.js.map +0 -6
- package/dist/extractor/buildClassName.js +0 -72
- package/dist/extractor/buildClassName.js.map +0 -6
- package/dist/extractor/bundle.js +0 -135
- package/dist/extractor/bundle.js.map +0 -6
- package/dist/extractor/bundleConfig.js +0 -352
- package/dist/extractor/bundleConfig.js.map +0 -6
- package/dist/extractor/concatClassName.js +0 -69
- package/dist/extractor/concatClassName.js.map +0 -6
- package/dist/extractor/createEvaluator.js +0 -66
- package/dist/extractor/createEvaluator.js.map +0 -6
- package/dist/extractor/createExtractor.js +0 -1215
- package/dist/extractor/createExtractor.js.map +0 -6
- package/dist/extractor/createLogger.js +0 -32
- package/dist/extractor/createLogger.js.map +0 -6
- package/dist/extractor/ensureImportingConcat.js +0 -50
- package/dist/extractor/ensureImportingConcat.js.map +0 -6
- package/dist/extractor/errors.js +0 -22
- package/dist/extractor/errors.js.map +0 -6
- package/dist/extractor/esbuildAliasPlugin.js +0 -36
- package/dist/extractor/esbuildAliasPlugin.js.map +0 -6
- package/dist/extractor/esbuildTsconfigPaths.js +0 -79
- package/dist/extractor/esbuildTsconfigPaths.js.map +0 -6
- package/dist/extractor/evaluateAstNode.js +0 -99
- package/dist/extractor/evaluateAstNode.js.map +0 -6
- package/dist/extractor/extractHelpers.js +0 -108
- package/dist/extractor/extractHelpers.js.map +0 -6
- package/dist/extractor/extractMediaStyle.js +0 -123
- package/dist/extractor/extractMediaStyle.js.map +0 -6
- package/dist/extractor/extractToClassNames.js +0 -351
- package/dist/extractor/extractToClassNames.js.map +0 -6
- package/dist/extractor/extractToNative.js +0 -286
- package/dist/extractor/extractToNative.js.map +0 -6
- package/dist/extractor/findTopmostFunction.js +0 -32
- package/dist/extractor/findTopmostFunction.js.map +0 -6
- package/dist/extractor/generatedUid.js +0 -42
- package/dist/extractor/generatedUid.js.map +0 -6
- package/dist/extractor/getPrefixLogs.js +0 -24
- package/dist/extractor/getPrefixLogs.js.map +0 -6
- package/dist/extractor/getPropValueFromAttributes.js +0 -65
- package/dist/extractor/getPropValueFromAttributes.js.map +0 -6
- package/dist/extractor/getSourceModule.js +0 -62
- package/dist/extractor/getSourceModule.js.map +0 -6
- package/dist/extractor/getStaticBindingsForScope.js +0 -145
- package/dist/extractor/getStaticBindingsForScope.js.map +0 -6
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js +0 -32
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +0 -6
- package/dist/extractor/hoistClassNames.js +0 -63
- package/dist/extractor/hoistClassNames.js.map +0 -6
- package/dist/extractor/literalToAst.js +0 -90
- package/dist/extractor/literalToAst.js.map +0 -6
- package/dist/extractor/loadFile.js +0 -14
- package/dist/extractor/loadFile.js.map +0 -6
- package/dist/extractor/loadTamagui.js +0 -306
- package/dist/extractor/loadTamagui.js.map +0 -6
- package/dist/extractor/logLines.js +0 -30
- package/dist/extractor/logLines.js.map +0 -6
- package/dist/extractor/normalizeTernaries.js +0 -61
- package/dist/extractor/normalizeTernaries.js.map +0 -6
- package/dist/extractor/propsToFontFamilyCache.js +0 -33
- package/dist/extractor/propsToFontFamilyCache.js.map +0 -6
- package/dist/extractor/regenerateConfig.js +0 -123
- package/dist/extractor/regenerateConfig.js.map +0 -6
- package/dist/extractor/removeUnusedHooks.js +0 -72
- package/dist/extractor/removeUnusedHooks.js.map +0 -6
- package/dist/extractor/timer.js +0 -38
- package/dist/extractor/timer.js.map +0 -6
- package/dist/extractor/validHTMLAttributes.js +0 -72
- package/dist/extractor/validHTMLAttributes.js.map +0 -6
- package/dist/extractor/watchTamaguiConfig.js +0 -57
- package/dist/extractor/watchTamaguiConfig.js.map +0 -6
- package/dist/getPragmaOptions.js +0 -46
- package/dist/getPragmaOptions.js.map +0 -6
- package/dist/helpers/memoize.js +0 -33
- package/dist/helpers/memoize.js.map +0 -6
- package/dist/helpers/requireTamaguiCore.js +0 -30
- package/dist/helpers/requireTamaguiCore.js.map +0 -6
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -6
- package/dist/registerRequire.js +0 -100
- package/dist/registerRequire.js.map +0 -6
- package/dist/server.js +0 -58
- package/dist/server.js.map +0 -6
- package/dist/setup.js +0 -1
- package/dist/setup.js.map +0 -6
- package/dist/types.js +0 -14
- package/dist/types.js.map +0 -6
- package/dist/worker.js +0 -72
- package/dist/worker.js.map +0 -6
|
@@ -3,33 +3,39 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var getTamaguiConfigPathFromOptionsConfig_exports = {};
|
|
22
24
|
__export(getTamaguiConfigPathFromOptionsConfig_exports, {
|
|
23
25
|
getTamaguiConfigPathFromOptionsConfig: () => getTamaguiConfigPathFromOptionsConfig
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(getTamaguiConfigPathFromOptionsConfig_exports);
|
|
26
|
-
var import_node_path = require("node:path")
|
|
27
|
-
|
|
28
|
+
var import_node_path = require("node:path");
|
|
29
|
+
var import_node_fs = require("node:fs");
|
|
28
30
|
function getTamaguiConfigPathFromOptionsConfig(config) {
|
|
29
|
-
if ((0, import_node_path.isAbsolute)(config))
|
|
31
|
+
if ((0, import_node_path.isAbsolute)(config)) {
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
30
34
|
const fullPath = (0, import_node_path.join)(process.cwd(), config);
|
|
31
35
|
try {
|
|
32
|
-
if ((0, import_node_fs.statSync)(fullPath).isFile())
|
|
36
|
+
if ((0, import_node_fs.statSync)(fullPath).isFile()) {
|
|
37
|
+
return fullPath;
|
|
38
|
+
}
|
|
33
39
|
} catch {}
|
|
34
40
|
return config;
|
|
35
41
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
34
|
+
var hasTopLevelAwait_exports = {};
|
|
35
|
+
__export(hasTopLevelAwait_exports, {
|
|
36
|
+
hasTopLevelAwait: () => hasTopLevelAwait
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(hasTopLevelAwait_exports);
|
|
39
|
+
var import_traverse = __toESM(require("@babel/traverse"));
|
|
40
|
+
var import_babelParse = require("./babelParse.cjs");
|
|
41
|
+
function hasTopLevelAwait(contents, fileName) {
|
|
42
|
+
if (!contents.includes("await")) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const ast = (0, import_babelParse.babelParse)(contents, fileName);
|
|
46
|
+
let found = false;
|
|
47
|
+
(0, import_traverse.default)(ast, {
|
|
48
|
+
AwaitExpression(path) {
|
|
49
|
+
if (!path.getFunctionParent()) {
|
|
50
|
+
found = true;
|
|
51
|
+
path.stop();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
ForOfStatement(path) {
|
|
55
|
+
if (path.node.await && !path.getFunctionParent()) {
|
|
56
|
+
found = true;
|
|
57
|
+
path.stop();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return found;
|
|
62
|
+
}
|
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var hoistClassNames_exports = {};
|
|
33
35
|
__export(hoistClassNames_exports, {
|
|
34
36
|
hoistClassNames: () => hoistClassNames
|
|
@@ -38,25 +40,37 @@ var t = __toESM(require("@babel/types"));
|
|
|
38
40
|
function hoistClassNames(path, existing, expr) {
|
|
39
41
|
const hoist = hoistClassNames.bind(null, path, existing);
|
|
40
42
|
if (t.isStringLiteral(expr)) {
|
|
41
|
-
if (expr.value.trim() === "")
|
|
42
|
-
|
|
43
|
+
if (expr.value.trim() === "") {
|
|
44
|
+
return expr;
|
|
45
|
+
}
|
|
46
|
+
if (existing[expr.value]) {
|
|
47
|
+
return existing[expr.value];
|
|
48
|
+
}
|
|
43
49
|
const identifier = replaceStringWithVariable(expr);
|
|
44
|
-
|
|
50
|
+
existing[expr.value] = identifier;
|
|
51
|
+
return identifier;
|
|
45
52
|
}
|
|
46
53
|
if (t.isBinaryExpression(expr)) {
|
|
47
|
-
if (t.isPrivateName(expr.left))
|
|
54
|
+
if (t.isPrivateName(expr.left)) {
|
|
55
|
+
throw new Error(`no private name`);
|
|
56
|
+
}
|
|
48
57
|
return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right));
|
|
49
58
|
}
|
|
50
|
-
if (t.isLogicalExpression(expr))
|
|
51
|
-
|
|
59
|
+
if (t.isLogicalExpression(expr)) {
|
|
60
|
+
return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
|
|
61
|
+
}
|
|
62
|
+
if (t.isConditionalExpression(expr)) {
|
|
63
|
+
return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate));
|
|
64
|
+
}
|
|
52
65
|
return expr;
|
|
53
66
|
function replaceStringWithVariable(str) {
|
|
54
|
-
const uid = path.scope.generateUidIdentifier("cn")
|
|
55
|
-
|
|
56
|
-
if (!parent) throw new Error(
|
|
67
|
+
const uid = path.scope.generateUidIdentifier("cn");
|
|
68
|
+
const parent = path.findParent(path2 => path2.isProgram());
|
|
69
|
+
if (!parent) throw new Error(`no program?`);
|
|
57
70
|
const variable = t.variableDeclaration("const", [
|
|
58
71
|
// adding a space for extra safety
|
|
59
72
|
t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`))]);
|
|
60
|
-
|
|
73
|
+
parent.unshiftContainer("body", variable);
|
|
74
|
+
return uid;
|
|
61
75
|
}
|
|
62
76
|
}
|
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var literalToAst_exports = {};
|
|
33
35
|
__export(literalToAst_exports, {
|
|
34
36
|
astToLiteral: () => astToLiteral,
|
|
@@ -37,7 +39,9 @@ __export(literalToAst_exports, {
|
|
|
37
39
|
module.exports = __toCommonJS(literalToAst_exports);
|
|
38
40
|
var t = __toESM(require("@babel/types"));
|
|
39
41
|
function literalToAst(literal) {
|
|
40
|
-
if (literal === null)
|
|
42
|
+
if (literal === null) {
|
|
43
|
+
return t.nullLiteral();
|
|
44
|
+
}
|
|
41
45
|
switch (typeof literal) {
|
|
42
46
|
case "function":
|
|
43
47
|
throw new Error("Unsupported");
|
|
@@ -48,37 +52,58 @@ function literalToAst(literal) {
|
|
|
48
52
|
case "boolean":
|
|
49
53
|
return t.booleanLiteral(literal);
|
|
50
54
|
case "undefined":
|
|
51
|
-
return t.unaryExpression("void", t.numericLiteral(0),
|
|
55
|
+
return t.unaryExpression("void", t.numericLiteral(0), true);
|
|
52
56
|
default:
|
|
53
|
-
|
|
57
|
+
if (Array.isArray(literal)) {
|
|
58
|
+
return t.arrayExpression(literal.map(literalToAst));
|
|
59
|
+
}
|
|
60
|
+
return t.objectExpression(Object.keys(literal).filter(k => {
|
|
61
|
+
return typeof literal[k] !== "undefined";
|
|
62
|
+
}).map(k => {
|
|
63
|
+
return t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]));
|
|
64
|
+
}));
|
|
54
65
|
}
|
|
55
66
|
}
|
|
56
67
|
const easyPeasies = ["BooleanLiteral", "StringLiteral", "NumericLiteral"];
|
|
57
68
|
function astToLiteral(node) {
|
|
58
|
-
if (node) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
if (!node) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (easyPeasies.includes(node.type)) {
|
|
73
|
+
return node.value;
|
|
74
|
+
}
|
|
75
|
+
if (node.name === "undefined" && !node.value) {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
if (t.isNullLiteral(node)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
if (t.isObjectExpression(node)) {
|
|
82
|
+
return computeProps(node.properties);
|
|
83
|
+
}
|
|
84
|
+
if (t.isArrayExpression(node)) {
|
|
85
|
+
return node.elements.reduce(
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
(acc, element) => [...acc, ...(element?.type === "SpreadElement" ? astToLiteral(element.argument) : [astToLiteral(element)])], []);
|
|
67
88
|
}
|
|
68
89
|
}
|
|
69
90
|
function computeProps(props) {
|
|
70
91
|
return props.reduce((acc, prop) => {
|
|
71
|
-
if (prop.type === "SpreadElement")
|
|
72
|
-
|
|
73
|
-
...astToLiteral(prop.argument)
|
|
74
|
-
};
|
|
75
|
-
if (prop.type !== "ObjectMethod") {
|
|
76
|
-
const val = astToLiteral(prop.value);
|
|
77
|
-
if (val !== void 0) return {
|
|
92
|
+
if (prop.type === "SpreadElement") {
|
|
93
|
+
return {
|
|
78
94
|
...acc,
|
|
79
|
-
|
|
95
|
+
...astToLiteral(prop.argument)
|
|
80
96
|
};
|
|
81
97
|
}
|
|
98
|
+
if (prop.type !== "ObjectMethod") {
|
|
99
|
+
const val = astToLiteral(prop.value);
|
|
100
|
+
if (val !== void 0) {
|
|
101
|
+
return {
|
|
102
|
+
...acc,
|
|
103
|
+
[prop.key.name]: val
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
82
107
|
return acc;
|
|
83
108
|
}, {});
|
|
84
109
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
process.on("message", path => {
|
|
2
|
-
if (typeof path
|
|
2
|
+
if (typeof path !== "string") {
|
|
3
|
+
throw new Error(`Not a string: ${path}`);
|
|
4
|
+
}
|
|
3
5
|
try {
|
|
4
6
|
const out = require(path);
|
|
5
7
|
process.send?.(JSON.stringify(out));
|
|
6
8
|
} catch (err) {
|
|
7
|
-
err instanceof Error
|
|
8
|
-
|
|
9
|
+
if (err instanceof Error) {
|
|
10
|
+
process.send?.(`-${err.message}
|
|
11
|
+
${err.stack}`);
|
|
12
|
+
} else {
|
|
13
|
+
process.send?.(`-${err}`);
|
|
14
|
+
}
|
|
9
15
|
}
|
|
10
16
|
});
|
|
11
17
|
setInterval(() => {}, 1e3);
|