@tamagui/static 1.0.0-alpha.34 → 1.0.0-alpha.38
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/.buildinfo +1 -0
- package/dist/extractor/createEvaluator.js.map +2 -2
- package/dist/extractor/createExtractor.js +86 -105
- package/dist/extractor/createExtractor.js.map +2 -2
- package/dist/extractor/extractHelpers.js +1 -3
- package/dist/extractor/extractHelpers.js.map +2 -2
- package/dist/extractor/extractMediaStyle.js +8 -10
- package/dist/extractor/extractMediaStyle.js.map +2 -2
- package/dist/extractor/extractToClassNames.js +20 -10
- package/dist/extractor/extractToClassNames.js.map +2 -2
- package/dist/extractor/getStaticBindingsForScope.js +7 -0
- package/dist/extractor/getStaticBindingsForScope.js.map +2 -2
- package/dist/forwardPropsList.js +140 -0
- package/dist/forwardPropsList.js.map +7 -0
- package/dist/index.cjs +133 -205
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/patchReactNativeWeb.js +3 -30
- package/dist/patchReactNativeWeb.js.map +2 -2
- package/package.json +7 -7
- package/dist/cjs/constants.js +0 -33
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/extractor/accessSafe.js +0 -33
- package/dist/cjs/extractor/accessSafe.js.map +0 -7
- package/dist/cjs/extractor/babelParse.js +0 -52
- package/dist/cjs/extractor/babelParse.js.map +0 -7
- package/dist/cjs/extractor/buildClassName.js +0 -62
- package/dist/cjs/extractor/buildClassName.js.map +0 -7
- package/dist/cjs/extractor/createEvaluator.js +0 -73
- package/dist/cjs/extractor/createEvaluator.js.map +0 -7
- package/dist/cjs/extractor/createExtractor.js +0 -903
- package/dist/cjs/extractor/createExtractor.js.map +0 -7
- package/dist/cjs/extractor/ensureImportingConcat.js +0 -46
- package/dist/cjs/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/cjs/extractor/evaluateAstNode.js +0 -116
- package/dist/cjs/extractor/evaluateAstNode.js.map +0 -7
- package/dist/cjs/extractor/extractHelpers.js +0 -118
- package/dist/cjs/extractor/extractHelpers.js.map +0 -7
- package/dist/cjs/extractor/extractMediaStyle.js +0 -187
- package/dist/cjs/extractor/extractMediaStyle.js.map +0 -7
- package/dist/cjs/extractor/extractToClassNames.js +0 -279
- package/dist/cjs/extractor/extractToClassNames.js.map +0 -7
- package/dist/cjs/extractor/findTopmostFunction.js +0 -29
- package/dist/cjs/extractor/findTopmostFunction.js.map +0 -7
- package/dist/cjs/extractor/generatedUid.js +0 -50
- package/dist/cjs/extractor/generatedUid.js.map +0 -7
- package/dist/cjs/extractor/getPropValueFromAttributes.js +0 -71
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/cjs/extractor/getSourceModule.js +0 -91
- package/dist/cjs/extractor/getSourceModule.js.map +0 -7
- package/dist/cjs/extractor/getStaticBindingsForScope.js +0 -150
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/cjs/extractor/hoistClassNames.js +0 -66
- package/dist/cjs/extractor/hoistClassNames.js.map +0 -7
- package/dist/cjs/extractor/literalToAst.js +0 -56
- package/dist/cjs/extractor/literalToAst.js.map +0 -7
- package/dist/cjs/extractor/loadTamagui.js +0 -63
- package/dist/cjs/extractor/loadTamagui.js.map +0 -7
- package/dist/cjs/extractor/logLines.js +0 -23
- package/dist/cjs/extractor/logLines.js.map +0 -7
- package/dist/cjs/extractor/normalizeTernaries.js +0 -102
- package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
- package/dist/cjs/extractor/removeUnusedHooks.js +0 -101
- package/dist/cjs/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/patchReactNativeWeb.js +0 -129
- package/dist/cjs/patchReactNativeWeb.js.map +0 -7
- package/dist/cjs/types.js +0 -4
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/constants.js +0 -10
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/extractor/accessSafe.js +0 -11
- package/dist/esm/extractor/accessSafe.js.map +0 -7
- package/dist/esm/extractor/babelParse.js +0 -30
- package/dist/esm/extractor/babelParse.js.map +0 -7
- package/dist/esm/extractor/buildClassName.js +0 -40
- package/dist/esm/extractor/buildClassName.js.map +0 -7
- package/dist/esm/extractor/createEvaluator.js +0 -51
- package/dist/esm/extractor/createEvaluator.js.map +0 -7
- package/dist/esm/extractor/createExtractor.js +0 -840
- package/dist/esm/extractor/createExtractor.js.map +0 -7
- package/dist/esm/extractor/ensureImportingConcat.js +0 -24
- package/dist/esm/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/esm/extractor/evaluateAstNode.js +0 -94
- package/dist/esm/extractor/evaluateAstNode.js.map +0 -7
- package/dist/esm/extractor/extractHelpers.js +0 -94
- package/dist/esm/extractor/extractHelpers.js.map +0 -7
- package/dist/esm/extractor/extractMediaStyle.js +0 -151
- package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
- package/dist/esm/extractor/extractToClassNames.js +0 -240
- package/dist/esm/extractor/extractToClassNames.js.map +0 -7
- package/dist/esm/extractor/findTopmostFunction.js +0 -23
- package/dist/esm/extractor/findTopmostFunction.js.map +0 -7
- package/dist/esm/extractor/generatedUid.js +0 -28
- package/dist/esm/extractor/generatedUid.js.map +0 -7
- package/dist/esm/extractor/getPropValueFromAttributes.js +0 -49
- package/dist/esm/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/esm/extractor/getSourceModule.js +0 -69
- package/dist/esm/extractor/getSourceModule.js.map +0 -7
- package/dist/esm/extractor/getStaticBindingsForScope.js +0 -128
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/esm/extractor/hoistClassNames.js +0 -44
- package/dist/esm/extractor/hoistClassNames.js.map +0 -7
- package/dist/esm/extractor/literalToAst.js +0 -34
- package/dist/esm/extractor/literalToAst.js.map +0 -7
- package/dist/esm/extractor/loadTamagui.js +0 -41
- package/dist/esm/extractor/loadTamagui.js.map +0 -7
- package/dist/esm/extractor/logLines.js +0 -17
- package/dist/esm/extractor/logLines.js.map +0 -7
- package/dist/esm/extractor/normalizeTernaries.js +0 -52
- package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
- package/dist/esm/extractor/removeUnusedHooks.js +0 -78
- package/dist/esm/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/esm/index.js +0 -14
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/patchReactNativeWeb.js +0 -107
- package/dist/esm/patchReactNativeWeb.js.map +0 -7
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/extractor/loadTamagui.js +0 -41
- package/dist/extractor/loadTamagui.js.map +0 -7
- package/dist/jsx/constants.js +0 -9
- package/dist/jsx/extractor/accessSafe.js +0 -10
- package/dist/jsx/extractor/babelParse.js +0 -29
- package/dist/jsx/extractor/buildClassName.js +0 -39
- package/dist/jsx/extractor/createEvaluator.js +0 -50
- package/dist/jsx/extractor/createExtractor.js +0 -839
- package/dist/jsx/extractor/ensureImportingConcat.js +0 -23
- package/dist/jsx/extractor/evaluateAstNode.js +0 -93
- package/dist/jsx/extractor/extractHelpers.js +0 -93
- package/dist/jsx/extractor/extractMediaStyle.js +0 -150
- package/dist/jsx/extractor/extractToClassNames.js +0 -239
- package/dist/jsx/extractor/findTopmostFunction.js +0 -22
- package/dist/jsx/extractor/generatedUid.js +0 -27
- package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -48
- package/dist/jsx/extractor/getSourceModule.js +0 -68
- package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -127
- package/dist/jsx/extractor/hoistClassNames.js +0 -43
- package/dist/jsx/extractor/literalToAst.js +0 -33
- package/dist/jsx/extractor/loadTamagui.js +0 -40
- package/dist/jsx/extractor/logLines.js +0 -16
- package/dist/jsx/extractor/normalizeTernaries.js +0 -51
- package/dist/jsx/extractor/removeUnusedHooks.js +0 -77
- package/dist/jsx/index.js +0 -13
- package/dist/jsx/patchReactNativeWeb.js +0 -106
- package/dist/jsx/types.js +0 -0
- package/types/constants.d.ts.map +0 -1
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/loadTamagui.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/patchReactNativeWeb.d.ts.map +0 -1
- package/types/types.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -73,6 +73,7 @@ __export(exports, {
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
// src/extractor/createExtractor.ts
|
|
76
|
+
var import_path2 = __toModule(require("path"));
|
|
76
77
|
var import_traverse = __toModule(require("@babel/traverse"));
|
|
77
78
|
var t9 = __toModule(require("@babel/types"));
|
|
78
79
|
var CoreNode = __toModule(require("@tamagui/core-node"));
|
|
@@ -255,9 +256,7 @@ function isValidThemeHook(jsxPath, n, sourcePath) {
|
|
|
255
256
|
return true;
|
|
256
257
|
}
|
|
257
258
|
__name(isValidThemeHook, "isValidThemeHook");
|
|
258
|
-
var isInsideTamagui = /* @__PURE__ */ __name((srcName) =>
|
|
259
|
-
return srcName.includes("/tamagui/_jsx") || srcName.includes("/core/src");
|
|
260
|
-
}, "isInsideTamagui");
|
|
259
|
+
var isInsideTamagui = /* @__PURE__ */ __name((srcName) => srcName.includes("/tamagui/"), "isInsideTamagui");
|
|
261
260
|
|
|
262
261
|
// src/extractor/createEvaluator.ts
|
|
263
262
|
function createEvaluator({
|
|
@@ -321,6 +320,7 @@ __name(findTopmostFunction, "findTopmostFunction");
|
|
|
321
320
|
// src/extractor/getStaticBindingsForScope.ts
|
|
322
321
|
var import_path = __toModule(require("path"));
|
|
323
322
|
var t5 = __toModule(require("@babel/types"));
|
|
323
|
+
var import_core_node = __toModule(require("@tamagui/core-node"));
|
|
324
324
|
var import_fs_extra = __toModule(require("fs-extra"));
|
|
325
325
|
|
|
326
326
|
// src/extractor/getSourceModule.ts
|
|
@@ -389,6 +389,9 @@ function getSourceModule(itemName, itemBinding) {
|
|
|
389
389
|
__name(getSourceModule, "getSourceModule");
|
|
390
390
|
|
|
391
391
|
// src/extractor/getStaticBindingsForScope.ts
|
|
392
|
+
var tamaguiConstants = {
|
|
393
|
+
defaultMediaQueries: import_core_node.defaultMediaQueries
|
|
394
|
+
};
|
|
392
395
|
var isLocalImport = /* @__PURE__ */ __name((path3) => path3.startsWith(".") || path3.startsWith("/"), "isLocalImport");
|
|
393
396
|
function resolveImportPath(sourcePath, path3) {
|
|
394
397
|
const sourceDir = (0, import_path.dirname)(sourcePath);
|
|
@@ -424,6 +427,9 @@ function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCac
|
|
|
424
427
|
if (!node.specifiers.length)
|
|
425
428
|
continue;
|
|
426
429
|
if (!isLocalImport(importPath)) {
|
|
430
|
+
if (importPath === "tamagui") {
|
|
431
|
+
Object.assign(ret, tamaguiConstants);
|
|
432
|
+
}
|
|
427
433
|
continue;
|
|
428
434
|
}
|
|
429
435
|
const moduleName = resolveImportPath(sourcePath, importPath);
|
|
@@ -537,43 +543,6 @@ function literalToAst(literal) {
|
|
|
537
543
|
}
|
|
538
544
|
__name(literalToAst, "literalToAst");
|
|
539
545
|
|
|
540
|
-
// src/extractor/loadTamagui.ts
|
|
541
|
-
var import_path2 = __toModule(require("path"));
|
|
542
|
-
var import_core_node = __toModule(require("@tamagui/core-node"));
|
|
543
|
-
var loadedTamagui = null;
|
|
544
|
-
function loadTamagui(props) {
|
|
545
|
-
if (loadedTamagui) {
|
|
546
|
-
return loadedTamagui;
|
|
547
|
-
}
|
|
548
|
-
process.env.IS_STATIC = "is_static";
|
|
549
|
-
const proxyWorm = require("@tamagui/fake-react-native");
|
|
550
|
-
const Mod = require("module");
|
|
551
|
-
const og = Mod.prototype.require;
|
|
552
|
-
Mod.prototype.require = function(path3) {
|
|
553
|
-
if (path3.startsWith("react-native") && !path3.startsWith("react-native-web/dist/cjs/exports")) {
|
|
554
|
-
return proxyWorm;
|
|
555
|
-
}
|
|
556
|
-
return og.apply(this, arguments);
|
|
557
|
-
};
|
|
558
|
-
const configPath = (0, import_path2.join)(process.cwd(), props.config);
|
|
559
|
-
const tamaguiConfigExport = require(configPath);
|
|
560
|
-
const tamaguiConfig = tamaguiConfigExport["default"] || tamaguiConfigExport;
|
|
561
|
-
const components = {};
|
|
562
|
-
for (const module2 of props.components) {
|
|
563
|
-
const exported = require(module2);
|
|
564
|
-
Object.assign(components, exported);
|
|
565
|
-
}
|
|
566
|
-
process.env.IS_STATIC = void 0;
|
|
567
|
-
Mod.prototype.require = og;
|
|
568
|
-
(0, import_core_node.createTamagui)(tamaguiConfig);
|
|
569
|
-
loadedTamagui = {
|
|
570
|
-
components,
|
|
571
|
-
tamaguiConfig
|
|
572
|
-
};
|
|
573
|
-
return loadedTamagui;
|
|
574
|
-
}
|
|
575
|
-
__name(loadTamagui, "loadTamagui");
|
|
576
|
-
|
|
577
546
|
// src/extractor/normalizeTernaries.ts
|
|
578
547
|
var import_generator2 = __toModule(require("@babel/generator"));
|
|
579
548
|
var t7 = __toModule(require("@babel/types"));
|
|
@@ -697,7 +666,7 @@ function removeUnusedHooks(compFn, shouldPrintDebug) {
|
|
|
697
666
|
__name(removeUnusedHooks, "removeUnusedHooks");
|
|
698
667
|
|
|
699
668
|
// src/extractor/createExtractor.ts
|
|
700
|
-
var { mediaQueryConfig, postProcessStyles
|
|
669
|
+
var { mediaQueryConfig, postProcessStyles } = CoreNode;
|
|
701
670
|
var FAILED_EVAL = Symbol("failed_style_eval");
|
|
702
671
|
var UNTOUCHED_PROPS = {
|
|
703
672
|
key: true,
|
|
@@ -710,18 +679,44 @@ var validHooks = {
|
|
|
710
679
|
useTheme: true
|
|
711
680
|
};
|
|
712
681
|
var createTernary = /* @__PURE__ */ __name((x) => x, "createTernary");
|
|
682
|
+
var loadedTamagui = null;
|
|
683
|
+
function loadTamagui(props) {
|
|
684
|
+
if (loadedTamagui) {
|
|
685
|
+
return loadedTamagui;
|
|
686
|
+
}
|
|
687
|
+
process.env.IS_STATIC = "is_static";
|
|
688
|
+
const proxyWorm = require("@dish/proxy-worm");
|
|
689
|
+
const Mod = require("module");
|
|
690
|
+
const og = Mod.prototype.require;
|
|
691
|
+
Mod.prototype.require = function(path3) {
|
|
692
|
+
if (path3.startsWith("react-native")) {
|
|
693
|
+
return proxyWorm;
|
|
694
|
+
}
|
|
695
|
+
return og.apply(this, arguments);
|
|
696
|
+
};
|
|
697
|
+
const tamaguiConfigExport = require((0, import_path2.join)(process.cwd(), props.config));
|
|
698
|
+
const tamaguiConfig = tamaguiConfigExport["default"] || tamaguiConfigExport;
|
|
699
|
+
const components = {};
|
|
700
|
+
for (const module2 of props.components) {
|
|
701
|
+
const exported = require(module2);
|
|
702
|
+
Object.assign(components, exported);
|
|
703
|
+
}
|
|
704
|
+
process.env.IS_STATIC = void 0;
|
|
705
|
+
Mod.prototype.require = og;
|
|
706
|
+
return {
|
|
707
|
+
components,
|
|
708
|
+
tamaguiConfig
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
__name(loadTamagui, "loadTamagui");
|
|
713
712
|
function createExtractor() {
|
|
714
|
-
|
|
713
|
+
console.log("create");
|
|
714
|
+
const shouldAddDebugProp = process.env.TARGET !== "native" && process.env.IDENTIFY_TAGS !== "false" && (process.env.NODE_ENV === "development" || process.env.DEBUG || process.env.IDENTIFY_TAGS);
|
|
715
715
|
require("esbuild-register/dist/node").register({
|
|
716
716
|
target: "es2019",
|
|
717
717
|
format: "cjs"
|
|
718
718
|
});
|
|
719
|
-
let loadedTamaguiConfig;
|
|
720
|
-
let hasLogged = false;
|
|
721
719
|
return {
|
|
722
|
-
getTamagui() {
|
|
723
|
-
return loadedTamaguiConfig;
|
|
724
|
-
},
|
|
725
720
|
parse: (fileOrPath, _a) => {
|
|
726
721
|
var _b = _a, {
|
|
727
722
|
config = "tamagui.config.ts",
|
|
@@ -731,9 +726,7 @@ function createExtractor() {
|
|
|
731
726
|
sourcePath = "",
|
|
732
727
|
onExtractTag,
|
|
733
728
|
getFlattenedNode,
|
|
734
|
-
|
|
735
|
-
disableExtractInlineMedia,
|
|
736
|
-
disableDebugAttr
|
|
729
|
+
onDidFlatten
|
|
737
730
|
} = _b, props = __objRest(_b, [
|
|
738
731
|
"config",
|
|
739
732
|
"importsWhitelist",
|
|
@@ -742,38 +735,31 @@ function createExtractor() {
|
|
|
742
735
|
"sourcePath",
|
|
743
736
|
"onExtractTag",
|
|
744
737
|
"getFlattenedNode",
|
|
745
|
-
"
|
|
746
|
-
"disableExtractInlineMedia",
|
|
747
|
-
"disableDebugAttr"
|
|
738
|
+
"onDidFlatten"
|
|
748
739
|
]);
|
|
749
740
|
if (sourcePath === "") {
|
|
750
741
|
throw new Error(`Must provide a source file name`);
|
|
751
742
|
}
|
|
752
|
-
if (!Array.isArray(props.components)) {
|
|
753
|
-
throw new Error(`Must provide components array with list of Tamagui component modules`);
|
|
754
|
-
}
|
|
755
743
|
const { components, tamaguiConfig } = loadTamagui({
|
|
756
744
|
config,
|
|
757
745
|
components: props.components || ["tamagui"]
|
|
758
746
|
});
|
|
759
|
-
|
|
760
|
-
const defaultTheme = tamaguiConfig.themes[Object.keys(tamaguiConfig.themes)[0]];
|
|
747
|
+
let doesUseValidImport = false;
|
|
761
748
|
const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
|
762
749
|
const isInternalImport = /* @__PURE__ */ __name((importStr) => isInsideTamagui(sourcePath) && importStr[0] === ".", "isInternalImport");
|
|
763
750
|
const validComponents = Object.keys(components).filter((key) => {
|
|
764
751
|
var _a2;
|
|
765
|
-
return
|
|
752
|
+
return !!((_a2 = components[key]) == null ? void 0 : _a2.staticConfig);
|
|
766
753
|
}).reduce((obj, name) => {
|
|
767
754
|
obj[name] = components[name];
|
|
768
755
|
return obj;
|
|
769
756
|
}, {});
|
|
770
|
-
let doesUseValidImport = false;
|
|
771
757
|
for (const bodyPath of body) {
|
|
772
758
|
if (bodyPath.type !== "ImportDeclaration")
|
|
773
759
|
continue;
|
|
774
760
|
const node = "node" in bodyPath ? bodyPath.node : bodyPath;
|
|
775
761
|
const from = node.source.value;
|
|
776
|
-
if (
|
|
762
|
+
if (from === "tamagui" || isInternalImport(from)) {
|
|
777
763
|
if (node.specifiers.some((specifier) => {
|
|
778
764
|
const name = specifier.local.name;
|
|
779
765
|
return validComponents[name] || validHooks[name];
|
|
@@ -796,11 +782,6 @@ function createExtractor() {
|
|
|
796
782
|
return fileOrPath.type === "File" ? (0, import_traverse.default)(fileOrPath, a) : fileOrPath.traverse(a);
|
|
797
783
|
}, "callTraverse");
|
|
798
784
|
let programPath;
|
|
799
|
-
const res = {
|
|
800
|
-
flattened: 0,
|
|
801
|
-
optimized: 0,
|
|
802
|
-
modified: 0
|
|
803
|
-
};
|
|
804
785
|
callTraverse({
|
|
805
786
|
Program: {
|
|
806
787
|
enter(path3) {
|
|
@@ -808,7 +789,6 @@ function createExtractor() {
|
|
|
808
789
|
}
|
|
809
790
|
},
|
|
810
791
|
JSXElement(traversePath) {
|
|
811
|
-
var _a2;
|
|
812
792
|
const node = traversePath.node.openingElement;
|
|
813
793
|
const ogAttributes = node.attributes;
|
|
814
794
|
const componentName = findComponentName(traversePath.scope);
|
|
@@ -822,7 +802,7 @@ function createExtractor() {
|
|
|
822
802
|
return;
|
|
823
803
|
}
|
|
824
804
|
const source = binding.path.parent.source;
|
|
825
|
-
if (
|
|
805
|
+
if (source.value !== "tamagui" && !isInternalImport(source.value)) {
|
|
826
806
|
return;
|
|
827
807
|
}
|
|
828
808
|
if (!validComponents[binding.identifier.name]) {
|
|
@@ -833,29 +813,11 @@ function createExtractor() {
|
|
|
833
813
|
if (!component || !component.staticConfig) {
|
|
834
814
|
return;
|
|
835
815
|
}
|
|
836
|
-
const originalNodeName = node.name.name;
|
|
837
|
-
if (shouldPrintDebug) {
|
|
838
|
-
console.log(`
|
|
839
|
-
<${originalNodeName} />`);
|
|
840
|
-
}
|
|
841
|
-
const filePath = sourcePath.replace(process.cwd(), ".");
|
|
842
|
-
const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
|
|
843
|
-
if (shouldAddDebugProp && !disableDebugAttr) {
|
|
844
|
-
const preName = componentName ? `${componentName}:` : "";
|
|
845
|
-
res.modified++;
|
|
846
|
-
node.attributes.unshift(t9.jsxAttribute(t9.jsxIdentifier("data-is"), t9.stringLiteral(` ${preName}${node.name.name} ${filePath.replace("./", "")}:${lineNumbers} `)));
|
|
847
|
-
}
|
|
848
|
-
if (disableExtraction) {
|
|
849
|
-
if (!hasLogged) {
|
|
850
|
-
console.log("\u{1F95A} Tamagui disableExtraction set: no CSS or optimizations will be run");
|
|
851
|
-
hasLogged = true;
|
|
852
|
-
}
|
|
853
|
-
return;
|
|
854
|
-
}
|
|
855
816
|
const { staticConfig } = component;
|
|
817
|
+
const originalNodeName = node.name.name;
|
|
856
818
|
const isTextView = staticConfig.isText || false;
|
|
857
819
|
const validStyles = (staticConfig == null ? void 0 : staticConfig.validStyles) ?? {};
|
|
858
|
-
let tagName =
|
|
820
|
+
let tagName = isTextView ? "span" : "div";
|
|
859
821
|
traversePath.get("openingElement").get("attributes").forEach((path3) => {
|
|
860
822
|
const attr = path3.node;
|
|
861
823
|
if (t9.isJSXSpreadAttribute(attr))
|
|
@@ -874,17 +836,21 @@ function createExtractor() {
|
|
|
874
836
|
]);
|
|
875
837
|
const excludeProps = new Set(props.excludeProps ?? []);
|
|
876
838
|
const isExcludedProp = /* @__PURE__ */ __name((name) => {
|
|
877
|
-
const
|
|
878
|
-
if (
|
|
839
|
+
const res = excludeProps.has(name);
|
|
840
|
+
if (res && shouldPrintDebug)
|
|
879
841
|
console.log(` excluding ${name}`);
|
|
880
|
-
return
|
|
842
|
+
return res;
|
|
881
843
|
}, "isExcludedProp");
|
|
882
844
|
const isDeoptedProp = /* @__PURE__ */ __name((name) => {
|
|
883
|
-
const
|
|
884
|
-
if (
|
|
845
|
+
const res = deoptProps.has(name);
|
|
846
|
+
if (res && shouldPrintDebug)
|
|
885
847
|
console.log(` deopting ${name}`);
|
|
886
|
-
return
|
|
848
|
+
return res;
|
|
887
849
|
}, "isDeoptedProp");
|
|
850
|
+
if (shouldPrintDebug) {
|
|
851
|
+
console.log(`
|
|
852
|
+
<${originalNodeName} />`);
|
|
853
|
+
}
|
|
888
854
|
const staticNamespace = getStaticBindingsForScope(traversePath.scope, importsWhitelist, sourcePath, bindingCache, shouldPrintDebug);
|
|
889
855
|
const attemptEval = !evaluateVars ? evaluateAstNode : createEvaluator({
|
|
890
856
|
tamaguiConfig,
|
|
@@ -957,11 +923,11 @@ function createExtractor() {
|
|
|
957
923
|
let isFlattened = false;
|
|
958
924
|
attrs = traversePath.get("openingElement").get("attributes").flatMap((path3) => {
|
|
959
925
|
try {
|
|
960
|
-
const
|
|
961
|
-
if (!
|
|
926
|
+
const res = evaluateAttribute(path3);
|
|
927
|
+
if (!res) {
|
|
962
928
|
path3.remove();
|
|
963
929
|
}
|
|
964
|
-
return
|
|
930
|
+
return res;
|
|
965
931
|
} catch (err) {
|
|
966
932
|
console.log("Error extracting attribute", err.message, err.stack);
|
|
967
933
|
console.log("node", path3.node);
|
|
@@ -972,8 +938,8 @@ function createExtractor() {
|
|
|
972
938
|
}
|
|
973
939
|
}).flat(4).filter(isPresent);
|
|
974
940
|
function isStaticAttributeName(name) {
|
|
975
|
-
var
|
|
976
|
-
return !!
|
|
941
|
+
var _a2;
|
|
942
|
+
return !!validStyles[name] || ((_a2 = staticConfig.validPropsExtra) == null ? void 0 : _a2[name]) || !!import_helpers.pseudos[name];
|
|
977
943
|
}
|
|
978
944
|
__name(isStaticAttributeName, "isStaticAttributeName");
|
|
979
945
|
function isExtractable(obj) {
|
|
@@ -983,10 +949,8 @@ function createExtractor() {
|
|
|
983
949
|
return false;
|
|
984
950
|
}
|
|
985
951
|
const propName = prop.key["name"];
|
|
986
|
-
if (!isStaticAttributeName(propName)
|
|
987
|
-
|
|
988
|
-
console.log(" not a valid style prop!", propName);
|
|
989
|
-
}
|
|
952
|
+
if (!isStaticAttributeName(propName)) {
|
|
953
|
+
console.log(" not a valid style prop!", propName);
|
|
990
954
|
return false;
|
|
991
955
|
}
|
|
992
956
|
return true;
|
|
@@ -1045,15 +1009,13 @@ function createExtractor() {
|
|
|
1045
1009
|
const attr = { type: "attr", value: attribute };
|
|
1046
1010
|
if (t9.isJSXSpreadAttribute(attribute)) {
|
|
1047
1011
|
const arg = attribute.argument;
|
|
1048
|
-
const conditional = t9.isConditionalExpression(arg) ? [arg.test, arg.
|
|
1012
|
+
const conditional = t9.isConditionalExpression(arg) ? [arg.test, arg.alternate, arg.consequent] : t9.isLogicalExpression(arg) && arg.operator === "&&" ? [arg.left, arg.right, null] : null;
|
|
1049
1013
|
if (conditional) {
|
|
1050
1014
|
const [test, alt, cons] = conditional;
|
|
1051
1015
|
if (!test)
|
|
1052
1016
|
throw new Error(`no test`);
|
|
1053
1017
|
if ([alt, cons].some((side) => side && !isExtractable(side))) {
|
|
1054
|
-
|
|
1055
|
-
console.log("not extractable", alt, cons);
|
|
1056
|
-
}
|
|
1018
|
+
console.log("not extractable", alt, cons);
|
|
1057
1019
|
return attr;
|
|
1058
1020
|
}
|
|
1059
1021
|
return [
|
|
@@ -1084,9 +1046,6 @@ function createExtractor() {
|
|
|
1084
1046
|
return attr;
|
|
1085
1047
|
}
|
|
1086
1048
|
if (name[0] === "$" && t9.isJSXExpressionContainer(attribute == null ? void 0 : attribute.value)) {
|
|
1087
|
-
if (disableExtractInlineMedia) {
|
|
1088
|
-
return attr;
|
|
1089
|
-
}
|
|
1090
1049
|
const shortname = name.slice(1);
|
|
1091
1050
|
if (mediaQueryConfig[shortname]) {
|
|
1092
1051
|
const expression = attribute.value.expression;
|
|
@@ -1120,22 +1079,11 @@ function createExtractor() {
|
|
|
1120
1079
|
inlinePropCount++;
|
|
1121
1080
|
return attr;
|
|
1122
1081
|
}
|
|
1123
|
-
if (name === "tag") {
|
|
1124
|
-
return {
|
|
1125
|
-
type: "attr",
|
|
1126
|
-
value: path3.node
|
|
1127
|
-
};
|
|
1128
|
-
}
|
|
1129
1082
|
const styleValue = attemptEvalSafe(value);
|
|
1130
1083
|
if (!isStaticAttributeName(name)) {
|
|
1131
1084
|
let keys = [name];
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
if (out) {
|
|
1135
|
-
keys = Object.keys(out);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
if (keys.some((k) => !isStaticAttributeName(k) && k !== "tag")) {
|
|
1085
|
+
console.warn("\u26A0\uFE0F NEED TO DO PROP MAPPING HERE");
|
|
1086
|
+
if (keys.some((k) => !isStaticAttributeName(k))) {
|
|
1139
1087
|
if (shouldPrintDebug) {
|
|
1140
1088
|
console.log(" ! inlining, not static attribute name", name);
|
|
1141
1089
|
}
|
|
@@ -1146,9 +1094,7 @@ function createExtractor() {
|
|
|
1146
1094
|
if (styleValue !== FAILED_EVAL) {
|
|
1147
1095
|
return {
|
|
1148
1096
|
type: "style",
|
|
1149
|
-
value: { [name]: styleValue }
|
|
1150
|
-
name,
|
|
1151
|
-
attr: path3.node
|
|
1097
|
+
value: { [name]: styleValue }
|
|
1152
1098
|
};
|
|
1153
1099
|
}
|
|
1154
1100
|
if (t9.isBinaryExpression(value)) {
|
|
@@ -1210,9 +1156,6 @@ function createExtractor() {
|
|
|
1210
1156
|
function getStaticConditional(value2) {
|
|
1211
1157
|
if (t9.isConditionalExpression(value2)) {
|
|
1212
1158
|
try {
|
|
1213
|
-
if (shouldPrintDebug) {
|
|
1214
|
-
console.log("attempt", value2.alternate, value2.consequent);
|
|
1215
|
-
}
|
|
1216
1159
|
const aVal = attemptEval(value2.alternate);
|
|
1217
1160
|
const cVal = attemptEval(value2.consequent);
|
|
1218
1161
|
if (shouldPrintDebug) {
|
|
@@ -1275,6 +1218,8 @@ function createExtractor() {
|
|
|
1275
1218
|
if (parentFn) {
|
|
1276
1219
|
modifiedComponents.add(parentFn);
|
|
1277
1220
|
}
|
|
1221
|
+
const filePath = sourcePath.replace(process.cwd(), ".");
|
|
1222
|
+
const lineNumbers = node.loc ? node.loc.start.line + (node.loc.start.line !== node.loc.end.line ? `-${node.loc.end.line}` : "") : "";
|
|
1278
1223
|
let ternaries = [];
|
|
1279
1224
|
attrs = attrs.reduce((out, cur) => {
|
|
1280
1225
|
const next = attrs[attrs.indexOf(cur) + 1];
|
|
@@ -1282,8 +1227,8 @@ function createExtractor() {
|
|
|
1282
1227
|
ternaries.push(cur.value);
|
|
1283
1228
|
}
|
|
1284
1229
|
if ((!next || next.type !== "ternary") && ternaries.length) {
|
|
1285
|
-
const normalized = normalizeTernaries(ternaries).map((
|
|
1286
|
-
var _b2 =
|
|
1230
|
+
const normalized = normalizeTernaries(ternaries).map((_a2) => {
|
|
1231
|
+
var _b2 = _a2, { alternate, consequent } = _b2, rest = __objRest(_b2, ["alternate", "consequent"]);
|
|
1287
1232
|
return {
|
|
1288
1233
|
type: "ternary",
|
|
1289
1234
|
value: __spreadProps(__spreadValues({}, rest), {
|
|
@@ -1333,19 +1278,17 @@ function createExtractor() {
|
|
|
1333
1278
|
const shouldFlatten = !shouldDeopt && inlinePropCount === 0 && !hasSpread && staticConfig.neverFlatten !== true && (staticConfig.neverFlatten === "jsx" ? hasOnlyStringChildren : true);
|
|
1334
1279
|
if (!shouldFlatten) {
|
|
1335
1280
|
attrs = attrs.reduce((acc, cur) => {
|
|
1336
|
-
var
|
|
1281
|
+
var _a2;
|
|
1337
1282
|
if (cur.type === "style") {
|
|
1338
1283
|
for (const key in cur.value) {
|
|
1339
|
-
const
|
|
1284
|
+
const shouldInsertNull = !!((_a2 = staticConfig.ensureOverriddenProp) == null ? void 0 : _a2[key]);
|
|
1340
1285
|
const isSetInAttrsAlready = attrs.some((x) => x.type === "attr" && x.value.type === "JSXAttribute" && x.value.name.name === key);
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
});
|
|
1348
|
-
}
|
|
1286
|
+
const shouldInsertNullOverride = shouldInsertNull && !isSetInAttrsAlready;
|
|
1287
|
+
if (shouldInsertNullOverride) {
|
|
1288
|
+
acc.push({
|
|
1289
|
+
type: "attr",
|
|
1290
|
+
value: t9.jsxAttribute(t9.jsxIdentifier(key), t9.jsxExpressionContainer(t9.nullLiteral()))
|
|
1291
|
+
});
|
|
1349
1292
|
}
|
|
1350
1293
|
}
|
|
1351
1294
|
}
|
|
@@ -1360,7 +1303,7 @@ function createExtractor() {
|
|
|
1360
1303
|
if (cur.type !== "attr" || !t9.isJSXAttribute(cur.value) || typeof cur.value.name.name !== "string") {
|
|
1361
1304
|
if (cur.type === "style") {
|
|
1362
1305
|
const key = Object.keys(cur.value)[0];
|
|
1363
|
-
if (!validStyles[key] && !pseudos[key]) {
|
|
1306
|
+
if (!validStyles[key] && !import_helpers.pseudos[key]) {
|
|
1364
1307
|
if (shouldPrintDebug) {
|
|
1365
1308
|
console.log(" \u274C excluding", key);
|
|
1366
1309
|
}
|
|
@@ -1378,6 +1321,9 @@ function createExtractor() {
|
|
|
1378
1321
|
attrs = attrs.reduce((acc, cur) => {
|
|
1379
1322
|
if (cur.type === "style") {
|
|
1380
1323
|
if ((prev == null ? void 0 : prev.type) === "style") {
|
|
1324
|
+
if (shouldPrintDebug) {
|
|
1325
|
+
console.log(" \u{1F500} merging style");
|
|
1326
|
+
}
|
|
1381
1327
|
Object.assign(prev.value, cur.value);
|
|
1382
1328
|
return acc;
|
|
1383
1329
|
}
|
|
@@ -1387,7 +1333,7 @@ function createExtractor() {
|
|
|
1387
1333
|
return acc;
|
|
1388
1334
|
}, []);
|
|
1389
1335
|
if (shouldPrintDebug) {
|
|
1390
|
-
console.log(" - attrs (combined
|
|
1336
|
+
console.log(" - attrs (combined styles): ", attrs.map(attrStr).join(", "));
|
|
1391
1337
|
}
|
|
1392
1338
|
const getStyles = /* @__PURE__ */ __name((props2) => {
|
|
1393
1339
|
if (!props2)
|
|
@@ -1398,7 +1344,7 @@ function createExtractor() {
|
|
|
1398
1344
|
delete props2[key];
|
|
1399
1345
|
}
|
|
1400
1346
|
}
|
|
1401
|
-
const out = postProcessStyles(props2, staticConfig
|
|
1347
|
+
const out = postProcessStyles(props2, staticConfig);
|
|
1402
1348
|
const next = (out == null ? void 0 : out.style) ?? props2;
|
|
1403
1349
|
if (shouldPrintDebug) {
|
|
1404
1350
|
console.log(" >> getStyles: ", objToStr(props2), "==>>", objToStr(next));
|
|
@@ -1407,7 +1353,7 @@ function createExtractor() {
|
|
|
1407
1353
|
}
|
|
1408
1354
|
if (staticConfig.validStyles) {
|
|
1409
1355
|
for (const key in next) {
|
|
1410
|
-
if (!staticConfig.validStyles[key] && !pseudos[key]) {
|
|
1356
|
+
if (!staticConfig.validStyles[key] && !import_helpers.pseudos[key]) {
|
|
1411
1357
|
delete next[key];
|
|
1412
1358
|
}
|
|
1413
1359
|
}
|
|
@@ -1451,11 +1397,7 @@ function createExtractor() {
|
|
|
1451
1397
|
case "style":
|
|
1452
1398
|
const next = {};
|
|
1453
1399
|
for (const key in attr.value) {
|
|
1454
|
-
|
|
1455
|
-
next["transform"] = completeStylesProcessed["transform"];
|
|
1456
|
-
} else {
|
|
1457
|
-
next[key] = completeStylesProcessed[key] ?? attr.value[key];
|
|
1458
|
-
}
|
|
1400
|
+
next[key] = completeStylesProcessed[key] ?? attr.value[key];
|
|
1459
1401
|
}
|
|
1460
1402
|
attr.value = next;
|
|
1461
1403
|
break;
|
|
@@ -1471,13 +1413,20 @@ function createExtractor() {
|
|
|
1471
1413
|
if (shouldPrintDebug) {
|
|
1472
1414
|
console.log(" - attrs (after): ", attrs.map(attrStr).join(", "));
|
|
1473
1415
|
}
|
|
1416
|
+
if (shouldAddDebugProp) {
|
|
1417
|
+
const preName = componentName ? `${componentName}:` : "";
|
|
1418
|
+
attrs.unshift({
|
|
1419
|
+
type: "attr",
|
|
1420
|
+
value: t9.jsxAttribute(t9.jsxIdentifier("data-is"), t9.stringLiteral(` ${preName}${node.name.name} ${filePath.replace("./", "")}:${lineNumbers} `))
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1474
1423
|
if (shouldFlatten) {
|
|
1475
1424
|
if (shouldPrintDebug) {
|
|
1476
1425
|
console.log(" [\u2705] flattening", originalNodeName, flatNode);
|
|
1477
1426
|
}
|
|
1478
1427
|
isFlattened = true;
|
|
1479
1428
|
node.name.name = flatNode;
|
|
1480
|
-
|
|
1429
|
+
onDidFlatten == null ? void 0 : onDidFlatten();
|
|
1481
1430
|
if (closingElement) {
|
|
1482
1431
|
closingElement.name.name = flatNode;
|
|
1483
1432
|
}
|
|
@@ -1486,7 +1435,6 @@ function createExtractor() {
|
|
|
1486
1435
|
console.log(" [\u274A] inline props ", inlinePropCount, shouldDeopt ? " deopted" : "", hasSpread ? " spread" : "", "!flatten", staticConfig.neverFlatten);
|
|
1487
1436
|
console.log(" - attrs (end): ", attrs.map(attrStr).join(", "));
|
|
1488
1437
|
}
|
|
1489
|
-
res.optimized++;
|
|
1490
1438
|
onExtractTag({
|
|
1491
1439
|
attrs,
|
|
1492
1440
|
node,
|
|
@@ -1509,7 +1457,6 @@ function createExtractor() {
|
|
|
1509
1457
|
removeUnusedHooks(comp, shouldPrintDebug);
|
|
1510
1458
|
}
|
|
1511
1459
|
}
|
|
1512
|
-
return res;
|
|
1513
1460
|
}
|
|
1514
1461
|
};
|
|
1515
1462
|
}
|
|
@@ -1528,7 +1475,8 @@ var util = __toModule(require("util"));
|
|
|
1528
1475
|
var import_generator3 = __toModule(require("@babel/generator"));
|
|
1529
1476
|
var t14 = __toModule(require("@babel/types"));
|
|
1530
1477
|
var import_core_node3 = __toModule(require("@tamagui/core-node"));
|
|
1531
|
-
var
|
|
1478
|
+
var import_helpers3 = __toModule(require("@tamagui/helpers"));
|
|
1479
|
+
var import_helpers4 = __toModule(require("@tamagui/helpers"));
|
|
1532
1480
|
var import_invariant2 = __toModule(require("invariant"));
|
|
1533
1481
|
var import_loader_utils = __toModule(require("loader-utils"));
|
|
1534
1482
|
|
|
@@ -1615,42 +1563,40 @@ __name(ensureImportingConcat, "ensureImportingConcat");
|
|
|
1615
1563
|
// src/extractor/extractMediaStyle.ts
|
|
1616
1564
|
var t12 = __toModule(require("@babel/types"));
|
|
1617
1565
|
var import_core_node2 = __toModule(require("@tamagui/core-node"));
|
|
1618
|
-
|
|
1566
|
+
var import_helpers2 = __toModule(require("@tamagui/helpers"));
|
|
1567
|
+
function extractMediaStyle(ternary, jsxPath, mediaQueries, sourcePath, importance = 0, shouldPrintDebug = false) {
|
|
1619
1568
|
const mt = getMediaQueryTernary(ternary, jsxPath, sourcePath);
|
|
1620
1569
|
if (!mt) {
|
|
1621
1570
|
return null;
|
|
1622
1571
|
}
|
|
1623
1572
|
const { key } = mt;
|
|
1624
|
-
const mq =
|
|
1573
|
+
const mq = mediaQueries[key];
|
|
1625
1574
|
if (!mq) {
|
|
1626
|
-
console.error(`Media query "${key}" not found: ${Object.keys(
|
|
1575
|
+
console.error(`Media query "${key}" not found: ${Object.keys(mediaQueries)}`);
|
|
1627
1576
|
return null;
|
|
1628
1577
|
}
|
|
1629
1578
|
const getStyleObj = /* @__PURE__ */ __name((styleObj, negate = false) => {
|
|
1630
1579
|
return styleObj ? { styleObj, negate } : null;
|
|
1631
1580
|
}, "getStyleObj");
|
|
1632
|
-
const styleOpts = [
|
|
1633
|
-
getStyleObj(ternary.consequent, false),
|
|
1634
|
-
getStyleObj(ternary.alternate, true)
|
|
1635
|
-
].filter(isPresent);
|
|
1581
|
+
const styleOpts = [getStyleObj(ternary.consequent, false), getStyleObj(ternary.alternate, true)].filter(isPresent);
|
|
1636
1582
|
if (shouldPrintDebug && !styleOpts.length) {
|
|
1637
1583
|
console.log(" media query, no styles?");
|
|
1638
1584
|
return null;
|
|
1639
1585
|
}
|
|
1640
|
-
const mediaKeys = Object.keys(
|
|
1586
|
+
const mediaKeys = Object.keys(mediaQueries);
|
|
1641
1587
|
const mediaKeyPrecendence = mediaKeys.reduce((acc, cur, i) => {
|
|
1642
1588
|
acc[cur] = new Array(importance + 1).fill(":root").join("");
|
|
1643
1589
|
return acc;
|
|
1644
1590
|
}, {});
|
|
1645
1591
|
let mediaStyles = [];
|
|
1646
1592
|
for (const { styleObj, negate } of styleOpts) {
|
|
1647
|
-
const styles = (0,
|
|
1593
|
+
const styles = (0, import_helpers2.getStylesAtomic)(styleObj);
|
|
1648
1594
|
const singleMediaStyles = styles.map((style) => {
|
|
1649
1595
|
const negKey = negate ? "0" : "";
|
|
1650
1596
|
const ogPrefix = style.identifier.slice(0, style.identifier.indexOf("-") + 1);
|
|
1651
1597
|
const identifier3 = `${style.identifier.replace(ogPrefix, `${ogPrefix}${MEDIA_SEP}${key}${negKey}${MEDIA_SEP}`)}`;
|
|
1652
1598
|
const className = `.${identifier3}`;
|
|
1653
|
-
const mediaSelector = (0, import_core_node2.mediaObjectToString)(
|
|
1599
|
+
const mediaSelector = (0, import_core_node2.mediaObjectToString)(mediaQueries[key]);
|
|
1654
1600
|
const screenStr = negate ? "not all" : "screen";
|
|
1655
1601
|
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
1656
1602
|
const precendencePrefix = mediaKeyPrecendence[key];
|
|
@@ -1827,11 +1773,17 @@ function extractToClassNames({
|
|
|
1827
1773
|
}
|
|
1828
1774
|
const cssMap = new Map();
|
|
1829
1775
|
const existingHoists = {};
|
|
1830
|
-
const
|
|
1776
|
+
const mediaQueries = options.mediaQueries ?? import_core_node3.defaultMediaQueries;
|
|
1777
|
+
let flattened = 0;
|
|
1778
|
+
let optimized = 0;
|
|
1779
|
+
extractor.parse(ast, __spreadProps(__spreadValues({
|
|
1831
1780
|
sourcePath,
|
|
1832
1781
|
shouldPrintDebug
|
|
1833
1782
|
}, options), {
|
|
1834
1783
|
getFlattenedNode: ({ tag }) => tag,
|
|
1784
|
+
onDidFlatten() {
|
|
1785
|
+
flattened++;
|
|
1786
|
+
},
|
|
1835
1787
|
onExtractTag: ({
|
|
1836
1788
|
attrs,
|
|
1837
1789
|
node,
|
|
@@ -1842,6 +1794,7 @@ function extractToClassNames({
|
|
|
1842
1794
|
lineNumbers,
|
|
1843
1795
|
programPath
|
|
1844
1796
|
}) => {
|
|
1797
|
+
optimized++;
|
|
1845
1798
|
let finalClassNames = [];
|
|
1846
1799
|
let finalAttrs = [];
|
|
1847
1800
|
let finalStyles = [];
|
|
@@ -1867,18 +1820,18 @@ function extractToClassNames({
|
|
|
1867
1820
|
if (!style)
|
|
1868
1821
|
return [];
|
|
1869
1822
|
const styleWithPrev = ensureNeededPrevStyle(style);
|
|
1870
|
-
const
|
|
1871
|
-
if (
|
|
1872
|
-
finalStyles = [...finalStyles, ...
|
|
1823
|
+
const res = (0, import_helpers4.getStylesAtomic)(styleWithPrev);
|
|
1824
|
+
if (res.length) {
|
|
1825
|
+
finalStyles = [...finalStyles, ...res];
|
|
1873
1826
|
}
|
|
1874
|
-
return
|
|
1827
|
+
return res;
|
|
1875
1828
|
}, "addStyles");
|
|
1876
1829
|
let lastMediaImportance = 1;
|
|
1877
1830
|
for (const attr of attrs) {
|
|
1878
1831
|
switch (attr.type) {
|
|
1879
1832
|
case "style":
|
|
1880
1833
|
const styles2 = addStyles(attr.value);
|
|
1881
|
-
const newClassNames = (0,
|
|
1834
|
+
const newClassNames = (0, import_helpers3.concatClassName)(styles2.map((x) => x.identifier).join(" "));
|
|
1882
1835
|
if (shouldPrintDebug) {
|
|
1883
1836
|
console.log(" classnames", newClassNames, finalClassNames);
|
|
1884
1837
|
}
|
|
@@ -1913,7 +1866,7 @@ function extractToClassNames({
|
|
|
1913
1866
|
finalAttrs.push(val);
|
|
1914
1867
|
break;
|
|
1915
1868
|
case "ternary":
|
|
1916
|
-
const mediaExtraction = extractMediaStyle(attr.value, jsxPath,
|
|
1869
|
+
const mediaExtraction = extractMediaStyle(attr.value, jsxPath, mediaQueries, sourcePath, lastMediaImportance, shouldPrintDebug);
|
|
1917
1870
|
if (mediaExtraction) {
|
|
1918
1871
|
lastMediaImportance++;
|
|
1919
1872
|
finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles];
|
|
@@ -1974,10 +1927,12 @@ function extractToClassNames({
|
|
|
1974
1927
|
}
|
|
1975
1928
|
}
|
|
1976
1929
|
}));
|
|
1977
|
-
if (!
|
|
1930
|
+
if (!optimized) {
|
|
1978
1931
|
return null;
|
|
1979
1932
|
}
|
|
1980
|
-
const styles = Array.from(cssMap.values()).map((x) =>
|
|
1933
|
+
const styles = Array.from(cssMap.values()).map((x) => {
|
|
1934
|
+
return x.css;
|
|
1935
|
+
}).join("\n").trim();
|
|
1981
1936
|
if (styles) {
|
|
1982
1937
|
const cssQuery = threaded ? `cssData=${Buffer.from(styles).toString("base64")}` : `cssPath=${cssPath}`;
|
|
1983
1938
|
const remReq = (0, import_loader_utils.getRemainingRequest)(loader);
|
|
@@ -1997,7 +1952,7 @@ function extractToClassNames({
|
|
|
1997
1952
|
}
|
|
1998
1953
|
if (shouldLogTiming && mem) {
|
|
1999
1954
|
const memUsed = Math.round((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204 * 10) / 10;
|
|
2000
|
-
console.log(` \u{
|
|
1955
|
+
console.log(` \u{1F351} ${(0, import_path3.basename)(sourcePath).padStart(40)} ${`${Date.now() - start}`.padStart(3)}ms \u05C1\xB7 ${`${optimized}`.padStart(4)} optimized \xB7 ${flattened} flattened ${memUsed > 10 ? `used ${memUsed}MB` : ""}`);
|
|
2001
1956
|
}
|
|
2002
1957
|
return {
|
|
2003
1958
|
ast,
|
|
@@ -2013,24 +1968,8 @@ var fs = __toModule(require("fs"));
|
|
|
2013
1968
|
var import_path4 = __toModule(require("path"));
|
|
2014
1969
|
function patchReactNativeWeb() {
|
|
2015
1970
|
const rootDir = require.resolve("react-native-web").replace(/\/dist.*/, "");
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
const isEqual = (() => {
|
|
2019
|
-
let res = false;
|
|
2020
|
-
try {
|
|
2021
|
-
res = fs.readFileSync(modulePath, "utf-8") === moduleExports && fs.readFileSync(cjsPath, "utf-8") == cjsExports;
|
|
2022
|
-
} catch {
|
|
2023
|
-
res = false;
|
|
2024
|
-
}
|
|
2025
|
-
return res;
|
|
2026
|
-
})();
|
|
2027
|
-
if (!isEqual) {
|
|
2028
|
-
console.log("\u{1F95A} Tamagui patching react-native-web to share atomic styling primitives");
|
|
2029
|
-
console.log(" > adding", modulePath);
|
|
2030
|
-
console.log(" > adding", cjsPath);
|
|
2031
|
-
fs.writeFileSync(modulePath, moduleExports);
|
|
2032
|
-
fs.writeFileSync(cjsPath, cjsExports);
|
|
2033
|
-
}
|
|
1971
|
+
fs.writeFileSync(import_path4.default.join(rootDir, "dist", "tamagui-exports.js"), moduleExports);
|
|
1972
|
+
fs.writeFileSync(import_path4.default.join(rootDir, "dist", "cjs", "tamagui-exports.js"), cjsExports);
|
|
2034
1973
|
const moduleEntry = import_path4.default.join(rootDir, "dist", "index.js");
|
|
2035
1974
|
const moduleEntrySrc = fs.readFileSync(moduleEntry, "utf-8");
|
|
2036
1975
|
if (!moduleEntrySrc.includes("// tamagui-patch-v4")) {
|
|
@@ -2051,6 +1990,7 @@ export const TamaguiExports = TExports
|
|
|
2051
1990
|
exports.TamaguiExports = _interopRequireDefault(require("./tamagui-exports"));
|
|
2052
1991
|
// tamagui-patch-end
|
|
2053
1992
|
`);
|
|
1993
|
+
console.log(`Tamagui patched react-native-web`);
|
|
2054
1994
|
}
|
|
2055
1995
|
}
|
|
2056
1996
|
__name(patchReactNativeWeb, "patchReactNativeWeb");
|
|
@@ -2075,12 +2015,6 @@ var forwardedPropsObj = `{
|
|
|
2075
2015
|
}
|
|
2076
2016
|
`;
|
|
2077
2017
|
var moduleExports = `
|
|
2078
|
-
export { atomic } from './exports/StyleSheet/compile'
|
|
2079
|
-
export { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'
|
|
2080
|
-
export { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'
|
|
2081
|
-
export { default as i18Style } from './exports/StyleSheet/i18nStyle'
|
|
2082
|
-
export { default as createDOMProps } from './modules/createDOMProps'
|
|
2083
|
-
export { default as AccessibilityUtil } from './modules/AccessibilityUtil'
|
|
2084
2018
|
export { default as createElement } from './exports/createElement'
|
|
2085
2019
|
export { default as css } from './exports/StyleSheet/css'
|
|
2086
2020
|
export { default as TextAncestorContext } from './exports/Text/TextAncestorContext'
|
|
@@ -2093,12 +2027,6 @@ import * as fwdProps from './modules/forwardedProps'
|
|
|
2093
2027
|
export const forwardedProps = ${forwardedPropsObj}
|
|
2094
2028
|
`;
|
|
2095
2029
|
var cjsExports = `
|
|
2096
|
-
exports.atomic = require('./exports/StyleSheet/compile').atomic
|
|
2097
|
-
exports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')
|
|
2098
|
-
exports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')
|
|
2099
|
-
exports.i18Style = require('./exports/StyleSheet/i18nStyle')
|
|
2100
|
-
exports.createDOMProps = require('./modules/createDOMProps')
|
|
2101
|
-
exports.AccessibilityUtil = require('./modules/AccessibilityUtil')
|
|
2102
2030
|
exports.createElement = require('./exports/createElement')
|
|
2103
2031
|
exports.css = require('./exports/StyleSheet/css')
|
|
2104
2032
|
exports.TextAncestorContext = require('./exports/Text/TextAncestorContext')
|
|
@@ -2112,5 +2040,5 @@ exports.forwardedProps = ${forwardedPropsObj}
|
|
|
2112
2040
|
`;
|
|
2113
2041
|
|
|
2114
2042
|
// src/index.ts
|
|
2115
|
-
process.env.
|
|
2043
|
+
process.env.SNACKUI_COMPILE_PROCESS = "1";
|
|
2116
2044
|
//# sourceMappingURL=index.cjs.map
|