@tamagui/static 1.132.16 → 1.132.18

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 (87) hide show
  1. package/dist/extractor/concatClassName.js +69 -0
  2. package/dist/extractor/concatClassName.js.map +6 -0
  3. package/dist/extractor/concatClassName.native.js +69 -0
  4. package/dist/extractor/concatClassName.native.js.map +6 -0
  5. package/dist/extractor/createEvaluator.js +13 -1
  6. package/dist/extractor/createEvaluator.js.map +1 -1
  7. package/dist/extractor/createEvaluator.native.js +6 -1
  8. package/dist/extractor/createEvaluator.native.js.map +2 -2
  9. package/dist/extractor/createExtractor.js +60 -114
  10. package/dist/extractor/createExtractor.js.map +1 -1
  11. package/dist/extractor/createExtractor.native.js +70 -123
  12. package/dist/extractor/createExtractor.native.js.map +2 -2
  13. package/dist/extractor/errors.js +22 -0
  14. package/dist/extractor/errors.js.map +6 -0
  15. package/dist/extractor/errors.native.js +119 -0
  16. package/dist/extractor/errors.native.js.map +6 -0
  17. package/dist/extractor/extractMediaStyle.js +1 -1
  18. package/dist/extractor/extractMediaStyle.js.map +1 -1
  19. package/dist/extractor/extractMediaStyle.native.js +1 -1
  20. package/dist/extractor/extractMediaStyle.native.js.map +2 -2
  21. package/dist/extractor/extractToClassNames.js +212 -172
  22. package/dist/extractor/extractToClassNames.js.map +2 -2
  23. package/dist/extractor/extractToClassNames.native.js +212 -188
  24. package/dist/extractor/extractToClassNames.native.js.map +2 -2
  25. package/dist/extractor/extractToNative.js +47 -78
  26. package/dist/extractor/extractToNative.js.map +1 -1
  27. package/dist/extractor/extractToNative.native.js +23 -39
  28. package/dist/extractor/extractToNative.native.js.map +2 -2
  29. package/dist/extractor/normalizeTernaries.js +5 -3
  30. package/dist/extractor/normalizeTernaries.js.map +1 -1
  31. package/dist/extractor/normalizeTernaries.native.js +5 -3
  32. package/dist/extractor/normalizeTernaries.native.js.map +2 -2
  33. package/dist/extractor/propsToFontFamilyCache.js +7 -8
  34. package/dist/extractor/propsToFontFamilyCache.js.map +1 -1
  35. package/dist/extractor/propsToFontFamilyCache.native.js +9 -10
  36. package/dist/extractor/propsToFontFamilyCache.native.js.map +2 -2
  37. package/dist/registerRequire.js +1 -1
  38. package/dist/registerRequire.js.map +1 -1
  39. package/dist/registerRequire.native.js +1 -1
  40. package/dist/registerRequire.native.js.map +1 -1
  41. package/dist/types.native.js.map +1 -1
  42. package/package.json +15 -15
  43. package/src/extractor/concatClassName.ts +100 -0
  44. package/src/extractor/createEvaluator.ts +26 -1
  45. package/src/extractor/createExtractor.ts +108 -194
  46. package/src/extractor/errors.ts +1 -0
  47. package/src/extractor/extractMediaStyle.ts +1 -1
  48. package/src/extractor/extractToClassNames.ts +377 -264
  49. package/src/extractor/extractToNative.ts +68 -111
  50. package/src/extractor/normalizeTernaries.ts +10 -3
  51. package/src/extractor/propsToFontFamilyCache.ts +5 -5
  52. package/src/registerRequire.ts +1 -1
  53. package/src/types.ts +10 -13
  54. package/types/extractor/concatClassName.d.ts +8 -0
  55. package/types/extractor/concatClassName.d.ts.map +1 -0
  56. package/types/extractor/createEvaluator.d.ts.map +1 -1
  57. package/types/extractor/createExtractor.d.ts.map +1 -1
  58. package/types/extractor/errors.d.ts +3 -0
  59. package/types/extractor/errors.d.ts.map +1 -0
  60. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  61. package/types/extractor/extractToNative.d.ts.map +1 -1
  62. package/types/extractor/normalizeTernaries.d.ts.map +1 -1
  63. package/types/extractor/propsToFontFamilyCache.d.ts +2 -2
  64. package/types/extractor/propsToFontFamilyCache.d.ts.map +1 -1
  65. package/types/types.d.ts +9 -10
  66. package/types/types.d.ts.map +1 -1
  67. package/dist/extractor/buildClassName.js +0 -72
  68. package/dist/extractor/buildClassName.js.map +0 -6
  69. package/dist/extractor/buildClassName.native.js +0 -67
  70. package/dist/extractor/buildClassName.native.js.map +0 -6
  71. package/dist/extractor/ensureImportingConcat.js +0 -50
  72. package/dist/extractor/ensureImportingConcat.js.map +0 -6
  73. package/dist/extractor/ensureImportingConcat.native.js +0 -49
  74. package/dist/extractor/ensureImportingConcat.native.js.map +0 -6
  75. package/dist/extractor/hoistClassNames.js +0 -63
  76. package/dist/extractor/hoistClassNames.js.map +0 -6
  77. package/dist/extractor/hoistClassNames.native.js +0 -66
  78. package/dist/extractor/hoistClassNames.native.js.map +0 -6
  79. package/src/extractor/buildClassName.ts +0 -76
  80. package/src/extractor/ensureImportingConcat.ts +0 -36
  81. package/src/extractor/hoistClassNames.ts +0 -52
  82. package/types/extractor/buildClassName.d.ts +0 -7
  83. package/types/extractor/buildClassName.d.ts.map +0 -1
  84. package/types/extractor/ensureImportingConcat.d.ts +0 -4
  85. package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
  86. package/types/extractor/hoistClassNames.d.ts +0 -6
  87. package/types/extractor/hoistClassNames.d.ts.map +0 -1
@@ -1,50 +0,0 @@
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, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var ensureImportingConcat_exports = {};
24
- __export(ensureImportingConcat_exports, {
25
- ensureImportingConcat: () => ensureImportingConcat
26
- });
27
- module.exports = __toCommonJS(ensureImportingConcat_exports);
28
- var t = __toESM(require("@babel/types"));
29
- const importConcatPkg = "@tamagui/helpers";
30
- function ensureImportingConcat(path) {
31
- const imported = path.get("body").find(
32
- (x) => x.isImportDeclaration() && x.node.source.value === importConcatPkg
33
- ), importSpecifier = t.importSpecifier(
34
- t.identifier("concatClassName"),
35
- t.identifier("concatClassName")
36
- );
37
- if (!imported) {
38
- path.node.body.push(
39
- t.importDeclaration([importSpecifier], t.stringLiteral(importConcatPkg))
40
- );
41
- return;
42
- }
43
- const specifiers = imported.node.specifiers;
44
- specifiers.some(
45
- (x) => t.isImportSpecifier(x) && t.isIdentifier(x.imported) && x.imported.name === "concatClassName"
46
- ) || specifiers.push(
47
- t.importSpecifier(t.identifier("concatClassName"), t.identifier("concatClassName"))
48
- );
49
- }
50
- //# sourceMappingURL=ensureImportingConcat.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/extractor/ensureImportingConcat.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,QAAmB;AAEnB,MAAM,kBAAkB;AAEjB,SAAS,sBAAsB,MAA2B;AAE/D,QAAM,WADW,KAAK,IAAI,MAAM,EACqC;AAAA,IACnE,CAAC,MAAM,EAAE,oBAAoB,KAAK,EAAE,KAAK,OAAO,UAAU;AAAA,EAC5D,GACM,kBAAkB,EAAE;AAAA,IACxB,EAAE,WAAW,iBAAiB;AAAA,IAC9B,EAAE,WAAW,iBAAiB;AAAA,EAChC;AAEA,MAAI,CAAC,UAAU;AACb,SAAK,KAAK,KAAK;AAAA,MACb,EAAE,kBAAkB,CAAC,eAAe,GAAG,EAAE,cAAc,eAAe,CAAC;AAAA,IACzE;AACA;AAAA,EACF;AAEA,QAAM,aAAa,SAAS,KAAK;AAQjC,EAPwB,WAAW;AAAA,IACjC,CAAC,MACC,EAAE,kBAAkB,CAAC,KACrB,EAAE,aAAa,EAAE,QAAQ,KACzB,EAAE,SAAS,SAAS;AAAA,EACxB,KAGE,WAAW;AAAA,IACT,EAAE,gBAAgB,EAAE,WAAW,iBAAiB,GAAG,EAAE,WAAW,iBAAiB,CAAC;AAAA,EACpF;AAEJ;",
5
- "names": []
6
- }
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: !0 });
10
- }, __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from == "object" || typeof from == "function")
12
- for (let key of __getOwnPropNames(from))
13
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
- mod
23
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
- var ensureImportingConcat_exports = {};
25
- __export(ensureImportingConcat_exports, {
26
- ensureImportingConcat: () => ensureImportingConcat
27
- });
28
- module.exports = __toCommonJS(ensureImportingConcat_exports);
29
- var t = __toESM(require("@babel/types")), importConcatPkg = "@tamagui/helpers";
30
- function ensureImportingConcat(path) {
31
- var bodyPath = path.get("body"), imported = bodyPath.find(function(x) {
32
- return x.isImportDeclaration() && x.node.source.value === importConcatPkg;
33
- }), importSpecifier = t.importSpecifier(t.identifier("concatClassName"), t.identifier("concatClassName"));
34
- if (!imported) {
35
- path.node.body.push(t.importDeclaration([
36
- importSpecifier
37
- ], t.stringLiteral(importConcatPkg)));
38
- return;
39
- }
40
- var specifiers = imported.node.specifiers, alreadyImported = specifiers.some(function(x) {
41
- return t.isImportSpecifier(x) && t.isIdentifier(x.imported) && x.imported.name === "concatClassName";
42
- });
43
- alreadyImported || specifiers.push(t.importSpecifier(t.identifier("concatClassName"), t.identifier("concatClassName")));
44
- }
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- ensureImportingConcat
48
- });
49
- //# sourceMappingURL=ensureImportingConcat.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/extractor/ensureImportingConcat.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AACA;;;;;QAAmB,kCAEbA,kBAAkB;AAEjB,SAASC,sBAAsBC,MAAyB;AAC7D,MAAMC,WAAWD,KAAKE,IAAI,MAAA,GACpBC,WAAsDF,SAASG,KACnE,SAACC,GAAAA;WAAMA,EAAEC,oBAAmB,KAAMD,EAAEE,KAAKC,OAAOC,UAAUX;MAEtDY,kBAAkBC,EAAED,gBACxBC,EAAEC,WAAW,iBAAA,GACbD,EAAEC,WAAW,iBAAA,CAAA;AAGf,MAAI,CAACT,UAAU;AACbH,SAAKO,KAAKM,KAAKC,KACbH,EAAEI,kBAAkB;MAACL;OAAkBC,EAAEK,cAAclB,eAAAA,CAAAA,CAAAA;AAEzD;EACF;AAEA,MAAMmB,aAAad,SAASI,KAAKU,YAC3BC,kBAAkBD,WAAWE,KACjC,SAACd,GAAAA;WACCM,EAAES,kBAAkBf,CAAAA,KACpBM,EAAEU,aAAahB,EAAEF,QAAQ,KACzBE,EAAEF,SAASmB,SAAS;;AAGxB,EAAKJ,mBACHD,WAAWH,KACTH,EAAED,gBAAgBC,EAAEC,WAAW,iBAAA,GAAoBD,EAAEC,WAAW,iBAAA,CAAA,CAAA;AAGtE;",
5
- "names": ["importConcatPkg", "ensureImportingConcat", "path", "bodyPath", "get", "imported", "find", "x", "isImportDeclaration", "node", "source", "value", "importSpecifier", "t", "identifier", "body", "push", "importDeclaration", "stringLiteral", "specifiers", "alreadyImported", "some", "isImportSpecifier", "isIdentifier", "name"]
6
- }
@@ -1,63 +0,0 @@
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, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var hoistClassNames_exports = {};
24
- __export(hoistClassNames_exports, {
25
- hoistClassNames: () => hoistClassNames
26
- });
27
- module.exports = __toCommonJS(hoistClassNames_exports);
28
- var t = __toESM(require("@babel/types"));
29
- function hoistClassNames(path, existing, expr) {
30
- const hoist = hoistClassNames.bind(null, path, existing);
31
- if (t.isStringLiteral(expr)) {
32
- if (expr.value.trim() === "")
33
- return expr;
34
- if (existing[expr.value])
35
- return existing[expr.value];
36
- const identifier = replaceStringWithVariable(expr);
37
- return existing[expr.value] = identifier, identifier;
38
- }
39
- if (t.isBinaryExpression(expr)) {
40
- if (t.isPrivateName(expr.left))
41
- throw new Error("no private name");
42
- return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right));
43
- }
44
- if (t.isLogicalExpression(expr))
45
- return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
46
- if (t.isConditionalExpression(expr))
47
- return t.conditionalExpression(
48
- expr.test,
49
- hoist(expr.consequent),
50
- hoist(expr.alternate)
51
- );
52
- return expr;
53
- function replaceStringWithVariable(str) {
54
- const uid = path.scope.generateUidIdentifier("cn"), parent = path.findParent((path2) => path2.isProgram());
55
- if (!parent) throw new Error("no program?");
56
- const variable = t.variableDeclaration("const", [
57
- // adding a space for extra safety
58
- t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`))
59
- ]);
60
- return parent.unshiftContainer("body", variable), uid;
61
- }
62
- }
63
- //# sourceMappingURL=hoistClassNames.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/extractor/hoistClassNames.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,QAAmB;AAEZ,SAAS,gBACd,MACA,UACA,MACA;AACA,QAAM,QAAQ,gBAAgB,KAAK,MAAM,MAAM,QAAQ;AACvD,MAAI,EAAE,gBAAgB,IAAI,GAAG;AAC3B,QAAI,KAAK,MAAM,KAAK,MAAM;AACxB,aAAO;AAET,QAAI,SAAS,KAAK,KAAK;AACrB,aAAO,SAAS,KAAK,KAAK;AAE5B,UAAM,aAAa,0BAA0B,IAAI;AACjD,oBAAS,KAAK,KAAK,IAAI,YAChB;AAAA,EACT;AACA,MAAI,EAAE,mBAAmB,IAAI,GAAG;AAC9B,QAAI,EAAE,cAAc,KAAK,IAAI;AAC3B,YAAM,IAAI,MAAM,iBAAiB;AAEnC,WAAO,EAAE,iBAAiB,KAAK,UAAU,MAAM,KAAK,IAAI,GAAG,MAAM,KAAK,KAAK,CAAC;AAAA,EAC9E;AACA,MAAI,EAAE,oBAAoB,IAAI;AAC5B,WAAO,EAAE,kBAAkB,KAAK,UAAU,MAAM,KAAK,IAAI,GAAG,MAAM,KAAK,KAAK,CAAC;AAE/E,MAAI,EAAE,wBAAwB,IAAI;AAChC,WAAO,EAAE;AAAA,MACP,KAAK;AAAA,MACL,MAAM,KAAK,UAAU;AAAA,MACrB,MAAM,KAAK,SAAS;AAAA,IACtB;AAEF,SAAO;AAEP,WAAS,0BAA0B,KAAoC;AAErE,UAAM,MAAM,KAAK,MAAM,sBAAsB,IAAI,GAC3C,SAAS,KAAK,WAAW,CAACA,UAASA,MAAK,UAAU,CAAC;AACzD,QAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,aAAa;AAC1C,UAAM,WAAW,EAAE,oBAAoB,SAAS;AAAA;AAAA,MAE9C,EAAE,mBAAmB,KAAK,EAAE,cAAc,IAAI,IAAI,KAAK,EAAE,CAAC;AAAA,IAC5D,CAAC;AAED,kBAAO,iBAAiB,QAAQ,QAAQ,GACjC;AAAA,EACT;AACF;",
5
- "names": ["path"]
6
- }
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: !0 });
10
- }, __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from == "object" || typeof from == "function")
12
- for (let key of __getOwnPropNames(from))
13
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
- mod
23
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
- var hoistClassNames_exports = {};
25
- __export(hoistClassNames_exports, {
26
- hoistClassNames: () => hoistClassNames
27
- });
28
- module.exports = __toCommonJS(hoistClassNames_exports);
29
- var t = __toESM(require("@babel/types"));
30
- function hoistClassNames(path, existing, expr) {
31
- var hoist = hoistClassNames.bind(null, path, existing);
32
- if (t.isStringLiteral(expr)) {
33
- if (expr.value.trim() === "")
34
- return expr;
35
- if (existing[expr.value])
36
- return existing[expr.value];
37
- var identifier = replaceStringWithVariable(expr);
38
- return existing[expr.value] = identifier, identifier;
39
- }
40
- if (t.isBinaryExpression(expr)) {
41
- if (t.isPrivateName(expr.left))
42
- throw new Error("no private name");
43
- return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right));
44
- }
45
- if (t.isLogicalExpression(expr))
46
- return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
47
- if (t.isConditionalExpression(expr))
48
- return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate));
49
- return expr;
50
- function replaceStringWithVariable(str) {
51
- var uid = path.scope.generateUidIdentifier("cn"), parent = path.findParent(function(path2) {
52
- return path2.isProgram();
53
- });
54
- if (!parent) throw new Error("no program?");
55
- var variable = t.variableDeclaration("const", [
56
- // adding a space for extra safety
57
- t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`))
58
- ]);
59
- return parent.unshiftContainer("body", variable), uid;
60
- }
61
- }
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- hoistClassNames
65
- });
66
- //# sourceMappingURL=hoistClassNames.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/extractor/hoistClassNames.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AACA;;;;;QAAmB;AAEZ,SAASA,gBACdC,MACAC,UACAC,MAAkB;AAElB,MAAMC,QAAQJ,gBAAgBK,KAAK,MAAMJ,MAAMC,QAAAA;AAC/C,MAAII,EAAEC,gBAAgBJ,IAAAA,GAAO;AAC3B,QAAIA,KAAKK,MAAMC,KAAI,MAAO;AACxB,aAAON;AAET,QAAID,SAASC,KAAKK,KAAK;AACrB,aAAON,SAASC,KAAKK,KAAK;AAE5B,QAAME,aAAaC,0BAA0BR,IAAAA;AAC7CD,oBAASC,KAAKK,KAAK,IAAIE,YAChBA;EACT;AACA,MAAIJ,EAAEM,mBAAmBT,IAAAA,GAAO;AAC9B,QAAIG,EAAEO,cAAcV,KAAKW,IAAI;AAC3B,YAAM,IAAIC,MAAM,iBAAiB;AAEnC,WAAOT,EAAEU,iBAAiBb,KAAKc,UAAUb,MAAMD,KAAKW,IAAI,GAAGV,MAAMD,KAAKe,KAAK,CAAA;EAC7E;AACA,MAAIZ,EAAEa,oBAAoBhB,IAAAA;AACxB,WAAOG,EAAEc,kBAAkBjB,KAAKc,UAAUb,MAAMD,KAAKW,IAAI,GAAGV,MAAMD,KAAKe,KAAK,CAAA;AAE9E,MAAIZ,EAAEe,wBAAwBlB,IAAAA;AAC5B,WAAOG,EAAEgB,sBACPnB,KAAKoB,MACLnB,MAAMD,KAAKqB,UAAU,GACrBpB,MAAMD,KAAKsB,SAAS,CAAA;AAGxB,SAAOtB;AAEP,WAASQ,0BAA0Be,KAAoB;AAErD,QAAMC,MAAM1B,KAAK2B,MAAMC,sBAAsB,IAAA,GACvCC,SAAS7B,KAAK8B,WAAW,SAAC9B,OAAAA;aAASA,MAAK+B,UAAS;;AACvD,QAAI,CAACF,OAAQ,OAAM,IAAIf,MAAM,aAAa;AAC1C,QAAMkB,WAAW3B,EAAE4B,oBAAoB,SAAS;;MAE9C5B,EAAE6B,mBAAmBR,KAAKrB,EAAE8B,cAAc,IAAIV,IAAIlB,KAAK,EAAE,CAAA;KAC1D;AAEDsB,kBAAOO,iBAAiB,QAAQJ,QAAAA,GACzBN;EACT;AACF;",
5
- "names": ["hoistClassNames", "path", "existing", "expr", "hoist", "bind", "t", "isStringLiteral", "value", "trim", "identifier", "replaceStringWithVariable", "isBinaryExpression", "isPrivateName", "left", "Error", "binaryExpression", "operator", "right", "isLogicalExpression", "logicalExpression", "isConditionalExpression", "conditionalExpression", "test", "consequent", "alternate", "str", "uid", "scope", "generateUidIdentifier", "parent", "findParent", "isProgram", "variable", "variableDeclaration", "variableDeclarator", "stringLiteral", "unshiftContainer"]
6
- }
@@ -1,76 +0,0 @@
1
- import * as t from '@babel/types'
2
-
3
- import type { ClassNameObject } from '../types'
4
-
5
- type Builder = (
6
- objects: ClassNameObject[],
7
- extras?: string
8
- ) => t.Expression | t.StringLiteral | null
9
-
10
- export const buildClassName: Builder = (objectsIn, extras = '') => {
11
- let objects = buildClassNameLogic(objectsIn)
12
- if (!objects) return null
13
- if (t.isStringLiteral(objects)) {
14
- // objects.value = objects.value
15
- objects.value = `${extras} ${objects.value}`
16
- } else {
17
- objects = t.binaryExpression('+', t.stringLiteral(extras), objects)
18
- }
19
- return objects
20
- }
21
-
22
- export const buildClassNameLogic: Builder = (objects) => {
23
- return objects.reduce<t.Expression | null>((acc, val) => {
24
- if (acc == null) {
25
- if (
26
- // pass conditional expressions through
27
- t.isConditionalExpression(val) ||
28
- // pass non-null literals through
29
- t.isStringLiteral(val) ||
30
- t.isNumericLiteral(val)
31
- ) {
32
- return val
33
- }
34
- return t.logicalExpression('||', val, t.stringLiteral(''))
35
- }
36
-
37
- let inner: t.Expression
38
- if (t.isStringLiteral(val)) {
39
- if (t.isStringLiteral(acc)) {
40
- // join adjacent string literals
41
- return t.stringLiteral(`${acc.value} ${val.value}`)
42
- }
43
- inner = t.stringLiteral(` ${val.value}`)
44
- } else if (t.isLiteral(val)) {
45
- inner = t.binaryExpression('+', t.stringLiteral(' '), val)
46
- } else if (t.isConditionalExpression(val) || t.isBinaryExpression(val)) {
47
- if (t.isStringLiteral(acc)) {
48
- return t.binaryExpression('+', t.stringLiteral(`${acc.value} `), val)
49
- }
50
- inner = t.binaryExpression('+', t.stringLiteral(' '), val)
51
- } else if (t.isIdentifier(val) || t.isMemberExpression(val)) {
52
- // identifiers and member expressions make for reasonable ternaries
53
- inner = t.conditionalExpression(
54
- val,
55
- t.binaryExpression('+', t.stringLiteral(' '), val),
56
- t.stringLiteral('')
57
- )
58
- } else {
59
- if (t.isStringLiteral(acc)) {
60
- return t.binaryExpression(
61
- '+',
62
- t.stringLiteral(`${acc.value} `),
63
- t.logicalExpression('||', val, t.stringLiteral(''))
64
- )
65
- }
66
- // use a logical expression for more complex prop values
67
- inner = t.binaryExpression(
68
- '+',
69
- t.stringLiteral(' '),
70
- t.logicalExpression('||', val, t.stringLiteral(''))
71
- )
72
- }
73
-
74
- return t.binaryExpression('+', acc, inner)
75
- }, null)
76
- }
@@ -1,36 +0,0 @@
1
- import type { NodePath } from '@babel/traverse'
2
- import * as t from '@babel/types'
3
-
4
- const importConcatPkg = '@tamagui/helpers'
5
-
6
- export function ensureImportingConcat(path: NodePath<t.Program>) {
7
- const bodyPath = path.get('body')
8
- const imported: NodePath<t.ImportDeclaration> | undefined = bodyPath.find(
9
- (x) => x.isImportDeclaration() && x.node.source.value === importConcatPkg
10
- ) as any
11
- const importSpecifier = t.importSpecifier(
12
- t.identifier('concatClassName'),
13
- t.identifier('concatClassName')
14
- )
15
-
16
- if (!imported) {
17
- path.node.body.push(
18
- t.importDeclaration([importSpecifier], t.stringLiteral(importConcatPkg))
19
- )
20
- return
21
- }
22
-
23
- const specifiers = imported.node.specifiers
24
- const alreadyImported = specifiers.some(
25
- (x) =>
26
- t.isImportSpecifier(x) &&
27
- t.isIdentifier(x.imported) &&
28
- x.imported.name === 'concatClassName'
29
- )
30
-
31
- if (!alreadyImported) {
32
- specifiers.push(
33
- t.importSpecifier(t.identifier('concatClassName'), t.identifier('concatClassName'))
34
- )
35
- }
36
- }
@@ -1,52 +0,0 @@
1
- import type { NodePath } from '@babel/traverse'
2
- import * as t from '@babel/types'
3
-
4
- export function hoistClassNames(
5
- path: NodePath<t.JSXElement>,
6
- existing: { [key: string]: t.Identifier },
7
- expr: t.Expression
8
- ) {
9
- const hoist = hoistClassNames.bind(null, path, existing)
10
- if (t.isStringLiteral(expr)) {
11
- if (expr.value.trim() === '') {
12
- return expr
13
- }
14
- if (existing[expr.value]) {
15
- return existing[expr.value]
16
- }
17
- const identifier = replaceStringWithVariable(expr)
18
- existing[expr.value] = identifier
19
- return identifier
20
- }
21
- if (t.isBinaryExpression(expr)) {
22
- if (t.isPrivateName(expr.left)) {
23
- throw new Error(`no private name`)
24
- }
25
- return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right))
26
- }
27
- if (t.isLogicalExpression(expr)) {
28
- return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right))
29
- }
30
- if (t.isConditionalExpression(expr)) {
31
- return t.conditionalExpression(
32
- expr.test,
33
- hoist(expr.consequent),
34
- hoist(expr.alternate)
35
- )
36
- }
37
- return expr
38
-
39
- function replaceStringWithVariable(str: t.StringLiteral): t.Identifier {
40
- // hoist outside fn!
41
- const uid = path.scope.generateUidIdentifier('cn')
42
- const parent = path.findParent((path) => path.isProgram())
43
- if (!parent) throw new Error(`no program?`)
44
- const variable = t.variableDeclaration('const', [
45
- // adding a space for extra safety
46
- t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`)),
47
- ])
48
- // @ts-ignore
49
- parent.unshiftContainer('body', variable)
50
- return uid
51
- }
52
- }
@@ -1,7 +0,0 @@
1
- import * as t from '@babel/types';
2
- import type { ClassNameObject } from '../types';
3
- type Builder = (objects: ClassNameObject[], extras?: string) => t.Expression | t.StringLiteral | null;
4
- export declare const buildClassName: Builder;
5
- export declare const buildClassNameLogic: Builder;
6
- export {};
7
- //# sourceMappingURL=buildClassName.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildClassName.d.ts","sourceRoot":"","sources":["../../src/extractor/buildClassName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAEjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,OAAO,GAAG,CACb,OAAO,EAAE,eAAe,EAAE,EAC1B,MAAM,CAAC,EAAE,MAAM,KACZ,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,aAAa,GAAG,IAAI,CAAA;AAE1C,eAAO,MAAM,cAAc,EAAE,OAU5B,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,OAsDjC,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { NodePath } from '@babel/traverse';
2
- import * as t from '@babel/types';
3
- export declare function ensureImportingConcat(path: NodePath<t.Program>): void;
4
- //# sourceMappingURL=ensureImportingConcat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ensureImportingConcat.d.ts","sourceRoot":"","sources":["../../src/extractor/ensureImportingConcat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAIjC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QA8B9D"}
@@ -1,6 +0,0 @@
1
- import type { NodePath } from '@babel/traverse';
2
- import * as t from '@babel/types';
3
- export declare function hoistClassNames(path: NodePath<t.JSXElement>, existing: {
4
- [key: string]: t.Identifier;
5
- }, expr: t.Expression): any;
6
- //# sourceMappingURL=hoistClassNames.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hoistClassNames.d.ts","sourceRoot":"","sources":["../../src/extractor/hoistClassNames.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAEjC,wBAAgB,eAAe,CAC7B,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,EAC5B,QAAQ,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,UAAU,CAAA;CAAE,EACzC,IAAI,EAAE,CAAC,CAAC,UAAU,OA6CnB"}