@tamagui/static 1.0.1-beta.113 → 1.0.1-beta.116

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.
@@ -24,9 +24,9 @@ __export(getStaticBindingsForScope_exports, {
24
24
  getStaticBindingsForScope: () => getStaticBindingsForScope
25
25
  });
26
26
  module.exports = __toCommonJS(getStaticBindingsForScope_exports);
27
+ var import_child_process = require("child_process");
27
28
  var import_path = require("path");
28
29
  var t = __toESM(require("@babel/types"));
29
- var import_fs_extra = require("fs-extra");
30
30
  var import_evaluateAstNode = require("./evaluateAstNode");
31
31
  var import_getSourceModule = require("./getSourceModule");
32
32
  const isLocalImport = (path) => path.startsWith(".") || path.startsWith("/");
@@ -40,23 +40,44 @@ function resolveImportPath(sourcePath, path) {
40
40
  }
41
41
  return path;
42
42
  }
43
+ const cache = /* @__PURE__ */ new Map();
44
+ const pending = /* @__PURE__ */ new Map();
45
+ setInterval(() => {
46
+ if (cache.size) {
47
+ cache.clear();
48
+ }
49
+ }, 10);
50
+ const loadCmd = `${(0, import_path.join)(__dirname, "loadFile.js")}`;
51
+ const child = (0, import_child_process.fork)(loadCmd, [], {
52
+ execArgv: ["-r", "esbuild-register"]
53
+ });
43
54
  function importModule(path) {
44
- const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
45
- for (const file of filenames) {
46
- if ((0, import_fs_extra.existsSync)(file)) {
47
- const { unregister } = require("esbuild-register/dist/node").register({
48
- target: "es2019",
49
- format: "cjs"
50
- });
51
- try {
52
- return require(file);
53
- } catch {
54
- } finally {
55
- unregister();
56
- }
57
- }
55
+ if (pending.has(path)) {
56
+ return pending.get(path);
58
57
  }
59
- return null;
58
+ const promise = new Promise((res, rej) => {
59
+ if (cache.has(path)) {
60
+ return cache.get(path);
61
+ }
62
+ const listener = (msg) => {
63
+ if (!msg)
64
+ return;
65
+ if (typeof msg !== "string")
66
+ return;
67
+ if (msg[0] === "-") {
68
+ rej(new Error(msg.slice(1)));
69
+ return;
70
+ }
71
+ child.removeListener("message", listener);
72
+ const val = JSON.parse(msg);
73
+ cache.set(path, val);
74
+ res(val);
75
+ };
76
+ child.once("message", listener);
77
+ child.send(`${path.replace(".js", "")}`);
78
+ });
79
+ pending.set(path, promise);
80
+ return promise;
60
81
  }
61
82
  function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
62
83
  const bindings = scope.getAllBindings();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/extractor/getStaticBindingsForScope.ts"],
4
- "sourcesContent": ["import { dirname, extname, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nfunction importModule(path: string) {\n const filenames = [path.replace('.js', '.tsx'), path.replace('.js', '.ts'), path]\n for (const file of filenames) {\n if (existsSync(file)) {\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n try {\n // TODO we can clear this when we see updates on it later on\n return require(file)\n } catch {\n // doesn't exists\n } finally {\n unregister()\n }\n }\n }\n return null\n}\n\nexport function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Record<string, any> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n const src = importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n // crude esmodule check\n // TODO: make sure this actually works\n // if (src && src.__esModule) {\n // ret[k] = src.default\n // } else {\n ret[k] = src\n // }\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch (e) {\n // skip\n // if (shouldPrintDebug) {\n // console.error('[\uD83D\uDC07] cant eval, skipping', cacheKey) //, e.message)\n // }\n }\n }\n\n return ret\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0C;AAG1C,QAAmB;AACnB,sBAA2B;AAE3B,6BAAgC;AAChC,6BAAgC;AAEhC,MAAM,gBAAgB,CAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG;AAEnF,2BAA2B,YAAoB,MAAc;AAC3D,QAAM,YAAY,yBAAQ,UAAU;AACpC,MAAI,cAAc,IAAI,GAAG;AACvB,QAAI,yBAAQ,IAAI,MAAM,IAAI;AACxB,cAAQ;AAAA,IACV;AACA,WAAO,yBAAQ,WAAW,IAAI;AAAA,EAChC;AACA,SAAO;AACT;AAEA,sBAAsB,MAAc;AAClC,QAAM,YAAY,CAAC,KAAK,QAAQ,OAAO,MAAM,GAAG,KAAK,QAAQ,OAAO,KAAK,GAAG,IAAI;AAChF,aAAW,QAAQ,WAAW;AAC5B,QAAI,gCAAW,IAAI,GAAG;AACpB,YAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,QACpE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ACF;AAGA,QAAI;AACF,UAAI,KAAK,4CAAgB,IAAI,MAAM,QAAW,gBAAgB;AAC9D,mBAAa,YAAY,IAAI;AAC7B;AAAA,IACF,SAAS,GAAP;AAAA,IAKF;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { fork, spawn } from 'child_process'\nimport { dirname, extname, join, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport esbuild from 'esbuild'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nconst cache = new Map()\nconst pending = new Map()\nsetInterval(() => {\n if (cache.size) {\n cache.clear()\n }\n}, 10)\n\nconst loadCmd = `${join(__dirname, 'loadFile.js')}`\nconst child = fork(loadCmd, [], {\n execArgv: ['-r', 'esbuild-register'],\n})\n\nfunction importModule(path: string) {\n if (pending.has(path)) {\n return pending.get(path)\n }\n const promise = new Promise((res, rej) => {\n if (cache.has(path)) {\n return cache.get(path)\n }\n const listener = (msg: any) => {\n if (!msg) return\n if (typeof msg !== 'string') return\n if (msg[0] === '-') {\n rej(new Error(msg.slice(1)))\n return\n }\n child.removeListener('message', listener)\n const val = JSON.parse(msg)\n cache.set(path, val)\n res(val)\n }\n child.once('message', listener)\n child.send(`${path.replace('.js', '')}`)\n })\n pending.set(path, promise)\n return promise\n}\n\nexport function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Record<string, any> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n const src = importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n // crude esmodule check\n // TODO: make sure this actually works\n // if (src && src.__esModule) {\n // ret[k] = src.default\n // } else {\n ret[k] = src\n // }\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch (e) {\n // skip\n // if (shouldPrintDebug) {\n // console.error('[\uD83D\uDC07] cant eval, skipping', cacheKey) //, e.message)\n // }\n }\n }\n\n return ret\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA4B;AAC5B,kBAAgD;AAGhD,QAAmB;AAInB,6BAAgC;AAChC,6BAAgC;AAEhC,MAAM,gBAAgB,CAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG;AAEnF,2BAA2B,YAAoB,MAAc;AAC3D,QAAM,YAAY,yBAAQ,UAAU;AACpC,MAAI,cAAc,IAAI,GAAG;AACvB,QAAI,yBAAQ,IAAI,MAAM,IAAI;AACxB,cAAQ;AAAA,IACV;AACA,WAAO,yBAAQ,WAAW,IAAI;AAAA,EAChC;AACA,SAAO;AACT;AAEA,MAAM,QAAQ,oBAAI,IAAI;AACtB,MAAM,UAAU,oBAAI,IAAI;AACxB,YAAY,MAAM;AAChB,MAAI,MAAM,MAAM;AACd,UAAM,MAAM;AAAA,EACd;AACF,GAA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C,EAAE,sBAAsB,MAAM,KAAK,OAAO,SAAS,SAAS;AAC/D;AAAA,IACF;AAGA,UAAM,MAAM,OAAO,aAAa,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;AAInF,QAAI,CAAC,OAAO,CAAC,IAAI,MAAM;AACrB;AAAA,IACF;AAGA,QAAI,OAAO,IAAI,GAAG,UAAU,YAAY,OAAO,IAAI,GAAG,QAAQ,UAAU;AACtE,cAAQ,MAAM,kCAAkC;AAChD;AAAA,IACF;AAEA,QAAI,CAAC,EAAE,aAAa,IAAI,EAAE,GAAG;AAC3B,cAAQ,MAAM,0BAA0B;AACxC;AAAA,IACF;AAEA,UAAM,WAAW,GAAG,IAAI,GAAG,QAAQ,IAAI,GAAG,SAAS,IAAI,GAAG;AAG1D,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAEA,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAGA,QAAI;AACF,UAAI,KAAK,4CAAgB,IAAI,MAAM,QAAW,gBAAgB;AAC9D,mBAAa,YAAY,IAAI;AAC7B;AAAA,IACF,SAAS,GAAP;AAAA,IAKF;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ process.on("message", (path) => {
3
+ var _a, _b, _c;
4
+ if (typeof path !== "string") {
5
+ throw new Error(`Not a string: ${path}`);
6
+ }
7
+ try {
8
+ const out = require(path);
9
+ (_a = process.send) == null ? void 0 : _a.call(process, JSON.stringify(out));
10
+ } catch (err) {
11
+ if (err instanceof Error) {
12
+ (_b = process.send) == null ? void 0 : _b.call(process, `-${err.message}
13
+ ${err.stack}`);
14
+ } else {
15
+ (_c = process.send) == null ? void 0 : _c.call(process, `-${err}`);
16
+ }
17
+ }
18
+ });
19
+ setInterval(() => {
20
+ }, 1e3);
21
+ //# sourceMappingURL=loadFile.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/extractor/loadFile.ts"],
4
+ "sourcesContent": ["process.on('message', (path) => {\n if (typeof path !== 'string') {\n throw new Error(`Not a string: ${path}`)\n }\n try {\n const out = require(path)\n process.send?.(JSON.stringify(out))\n } catch (err) {\n if (err instanceof Error) {\n process.send?.(`-${err.message}\\n${err.stack}`)\n } else {\n process.send?.(`-${err}`)\n }\n }\n})\n\nsetInterval(() => {}, 1000)\n"],
5
+ "mappings": ";AAAA,QAAQ,GAAG,WAAW,CAAC,SAAS;AAAhC;AACE,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,IAAI,MAAM,iBAAiB,MAAM;AAAA,EACzC;AACA,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,kBAAQ,SAAR,iCAAe,KAAK,UAAU,GAAG;AAAA,EACnC,SAAS,KAAP;AACA,QAAI,eAAe,OAAO;AACxB,oBAAQ,SAAR,iCAAe,IAAI,IAAI;AAAA,EAAY,IAAI;AAAA,IACzC,OAAO;AACL,oBAAQ,SAAR,iCAAe,IAAI;AAAA,IACrB;AAAA,EACF;AACF,CAAC;AAED,YAAY,MAAM;AAAC,GAAG,GAAI;",
6
+ "names": []
7
+ }
@@ -41,6 +41,7 @@ function registerRequire() {
41
41
  }
42
42
  const proxyWorm = require("@tamagui/proxy-worm");
43
43
  const rnw = require("react-native-web");
44
+ const core = require("@tamagui/core-node");
44
45
  Mod.prototype.require = function(path) {
45
46
  var _a, _b;
46
47
  if (import_constants.SHOULD_DEBUG) {
@@ -55,6 +56,9 @@ function registerRequire() {
55
56
  if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
56
57
  return rnw;
57
58
  }
59
+ if (path === "@tamagui/core") {
60
+ return core;
61
+ }
58
62
  try {
59
63
  const out = og.apply(this, arguments);
60
64
  if (!nameToPaths[path]) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/require.ts"],
4
- "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 500)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n // return og('react-native-web')\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)\\n`,\n err.message\n )\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n if (++tries > 10) {\n // avoid infinite loops\n process.exit(1)\n }\n }\n }\n}\n\nexport function unregis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AK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,cAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,OACN;AACA,UAAI,+BAAc;AAChB,gBAAQ,IAAI,IAAI,KAAK;AAAA,MACvB;AACA,UAAI,EAAE,QAAQ,IAAI;AAEhB,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,6BAA6B;AAClC,MAAI,UAAU,UAAU;AAC1B;",
4
+ "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 500)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const core = require('@tamagui/core-node')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n // return og('react-native-web')\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)\\n`,\n err.message\n )\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n if (++tries > 10) {\n // avoid infinite loops\n process.exit(1)\n }\n }\n }\n}\n\nexport function unregisterRequire() {\n Mod.prototype.require = og\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAIrB,uBAA6B;AAE7B,MAAM,cAAc,CAAC;AACrB,MAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAM,KAAK,IAAI,UAAU;AACzB,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAEpC,IAAI,QAAQ;AACZ,YAAY,MAAM;AAChB,UAAQ;AACV,GAAG,GAAG;AAEC,2BAA2B;AAChC,MAAI,IAAI,UAAU,YAAY,WAAW,cAAc;AACrD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAC/C,QAAM,MAAM,QAAQ,kBAAkB;AACtC,QAAM,OAAO,QAAQ,oBAAoB;AAEzC,MAAI,UAAU,UAAU,SAAU,MAAc;AA5BlD;AA6BI,QAAI,+BAAc;AAChB,cAAQ,IAAI,mBAAmB,IAAI;AAAA,IACrC;AACA,QAAI,KAAK,SAAS,MAAM,GAAG;AACzB,aAAO,CAAC;AAAA,IACV;AACA,QACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,wBACT;AACA,aAAO;AAAA,IACT;AACA,QACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,mCAAmC,GACpD;AACA,aAAO;AAAA,IAET;AACA,QAAI,SAAS,iBAAiB;AAC5B,aAAO;AAAA,IACT;AACA,QAAI;AACF,YAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AACpC,UAAI,CAAC,YAAY,OAAO;AACtB,YAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,qBAAW,OAAO,KAAK;AACrB,gBAAI;AACF,oBAAM,OAAO,UAAI,SAAJ,mBAAU;AACvB,kBAAI,MAAM;AACR,oBAAI,KAAK,eAAe;AACtB,mCAAY,KAAK,kBAAjB,mBAAoC,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,sBAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,cAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,OACN;AACA,UAAI,+BAAc;AAChB,gBAAQ,IAAI,IAAI,KAAK;AAAA,MACvB;AACA,UAAI,EAAE,QAAQ,IAAI;AAEhB,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,6BAA6B;AAClC,MAAI,UAAU,UAAU;AAC1B;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts"],
4
- "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { PseudoStyles } from '@tamagui/core-node'\nimport { StyleObject } from '@tamagui/core-node'\nimport { ViewStyle } from 'react-native'\n\nexport type { StyleObject } from '@tamagui/helpers'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface TamaguiOptions {\n // module paths you want to compile with tamagui (for example ['tamagui'])\n components: string[]\n // your tamagui.config.ts\n config?: string\n evaluateVars?: boolean\n importsWhitelist?: string[]\n disable?: boolean\n disableExtraction?: boolean\n disableDebugAttr?: boolean\n disableExtractInlineMedia?: boolean\n disableExtractVariables?: boolean\n excludeReactNativeWebExports?: string[]\n exclude?: RegExp\n logTimings?: boolean\n prefixLogs?: string\n\n // probably non user options\n cssPath?: string\n cssData?: any\n deoptProps?: Set<string>\n excludeProps?: Set<string>\n inlineProps?: Set<string>\n forceExtractStyleDefinitions?: boolean\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: ViewStyle & PseudoStyles\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n}\n\nexport type ExtractorParseProps = TamaguiOptions & {\n target: 'native' | 'html'\n sourcePath?: string\n shouldPrintDebug?: boolean | 'verbose'\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string\n extractStyledDefinitions?: boolean\n // identifer, rule\n onStyleRule?: (identifier: string, rules: string[]) => void\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
4
+ "sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { PseudoStyles, StyleObject } from '@tamagui/core-node'\nimport { ViewStyle } from 'react-native'\n\nexport type { StyleObject } from '@tamagui/helpers'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface TamaguiOptions {\n // module paths you want to compile with tamagui (for example ['tamagui'])\n components: string[]\n // your tamagui.config.ts\n config?: string\n evaluateVars?: boolean\n importsWhitelist?: string[]\n disable?: boolean\n disableExtraction?: boolean\n disableDebugAttr?: boolean\n disableExtractInlineMedia?: boolean\n disableExtractVariables?: boolean\n excludeReactNativeWebExports?: string[]\n exclude?: RegExp\n logTimings?: boolean\n prefixLogs?: string\n\n // probably non user options\n cssPath?: string\n cssData?: any\n deoptProps?: Set<string>\n excludeProps?: Set<string>\n inlineProps?: Set<string>\n forceExtractStyleDefinitions?: boolean\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: ViewStyle & PseudoStyles\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n}\n\nexport type ExtractorParseProps = TamaguiOptions & {\n target: 'native' | 'html'\n sourcePath?: string\n shouldPrintDebug?: boolean | 'verbose'\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string\n extractStyledDefinitions?: boolean\n // identifer, rule\n onStyleRule?: (identifier: string, rules: string[]) => void\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
- import { dirname, extname, resolve } from "path";
1
+ import { fork } from "child_process";
2
+ import { dirname, extname, join, resolve } from "path";
2
3
  import * as t from "@babel/types";
3
- import { existsSync } from "fs-extra";
4
4
  import { evaluateAstNode } from "./evaluateAstNode";
5
5
  import { getSourceModule } from "./getSourceModule";
6
6
  const isLocalImport = (path) => path.startsWith(".") || path.startsWith("/");
@@ -14,23 +14,44 @@ function resolveImportPath(sourcePath, path) {
14
14
  }
15
15
  return path;
16
16
  }
17
+ const cache = /* @__PURE__ */ new Map();
18
+ const pending = /* @__PURE__ */ new Map();
19
+ setInterval(() => {
20
+ if (cache.size) {
21
+ cache.clear();
22
+ }
23
+ }, 10);
24
+ const loadCmd = `${join(__dirname, "loadFile.js")}`;
25
+ const child = fork(loadCmd, [], {
26
+ execArgv: ["-r", "esbuild-register"]
27
+ });
17
28
  function importModule(path) {
18
- const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
19
- for (const file of filenames) {
20
- if (existsSync(file)) {
21
- const { unregister } = require("esbuild-register/dist/node").register({
22
- target: "es2019",
23
- format: "cjs"
24
- });
25
- try {
26
- return require(file);
27
- } catch {
28
- } finally {
29
- unregister();
30
- }
31
- }
29
+ if (pending.has(path)) {
30
+ return pending.get(path);
32
31
  }
33
- return null;
32
+ const promise = new Promise((res, rej) => {
33
+ if (cache.has(path)) {
34
+ return cache.get(path);
35
+ }
36
+ const listener = (msg) => {
37
+ if (!msg)
38
+ return;
39
+ if (typeof msg !== "string")
40
+ return;
41
+ if (msg[0] === "-") {
42
+ rej(new Error(msg.slice(1)));
43
+ return;
44
+ }
45
+ child.removeListener("message", listener);
46
+ const val = JSON.parse(msg);
47
+ cache.set(path, val);
48
+ res(val);
49
+ };
50
+ child.once("message", listener);
51
+ child.send(`${path.replace(".js", "")}`);
52
+ });
53
+ pending.set(path, promise);
54
+ return promise;
34
55
  }
35
56
  function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
36
57
  const bindings = scope.getAllBindings();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/extractor/getStaticBindingsForScope.ts"],
4
- "sourcesContent": ["import { dirname, extname, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nfunction importModule(path: string) {\n const filenames = [path.replace('.js', '.tsx'), path.replace('.js', '.ts'), path]\n for (const file of filenames) {\n if (existsSync(file)) {\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n try {\n // TODO we can clear this when we see updates on it later on\n return require(file)\n } catch {\n // doesn't exists\n } finally {\n unregister()\n }\n }\n }\n return null\n}\n\nexport function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Record<string, any> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n const src = importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n // crude esmodule check\n // TODO: make sure this actually works\n // if (src && src.__esModule) {\n // ret[k] = src.default\n // } else {\n ret[k] = src\n // }\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch (e) {\n // skip\n // if (shouldPrintDebug) {\n // console.error('[\uD83D\uDC07] cant eval, skipping', cacheKey) //, e.message)\n // }\n }\n }\n\n return ret\n}\n"],
5
- "mappings": "AAAA;AAGA;AACA;AAEA;AACA;AAEA,MAAM,gBAAgB,CAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG;AAEnF,2BAA2B,YAAoB,MAAc;AAC3D,QAAM,YAAY,QAAQ,UAAU;AACpC,MAAI,cAAc,IAAI,GAAG;AACvB,QAAI,QAAQ,IAAI,MAAM,IAAI;AACxB,cAAQ;AAAA,IACV;AACA,WAAO,QAAQ,WAAW,IAAI;AAAA,EAChC;AACA,SAAO;AACT;AAEA,sBAAsB,MAAc;AAClC,QAAM,YAAY,CAAC,KAAK,QAAQ,OAAO,MAAM,GAAG,KAAK,QAAQ,OAAO,KAAK,GAAG,IAAI;AAChF,aAAW,QAAQ,WAAW;AAC5B,QAAI,WAAW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;AAEA,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAGA,QAAI;AACF,UAAI,KAAK,gBAAgB,IAAI,MAAM,QAAW,gBAAgB;AAC9D,mBAAa,YAAY,IAAI;AAC7B;AAAA,IACF,SAAS,GAAP;AAAA,IAKF;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { fork, spawn } from 'child_process'\nimport { dirname, extname, join, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport esbuild from 'esbuild'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nconst cache = new Map()\nconst pending = new Map()\nsetInterval(() => {\n if (cache.size) {\n cache.clear()\n }\n}, 10)\n\nconst loadCmd = `${join(__dirname, 'loadFile.js')}`\nconst child = fork(loadCmd, [], {\n execArgv: ['-r', 'esbuild-register'],\n})\n\nfunction importModule(path: string) {\n if (pending.has(path)) {\n return pending.get(path)\n }\n const promise = new Promise((res, rej) => {\n if (cache.has(path)) {\n return cache.get(path)\n }\n const listener = (msg: any) => {\n if (!msg) return\n if (typeof msg !== 'string') return\n if (msg[0] === '-') {\n rej(new Error(msg.slice(1)))\n return\n }\n child.removeListener('message', listener)\n const val = JSON.parse(msg)\n cache.set(path, val)\n res(val)\n }\n child.once('message', listener)\n child.send(`${path.replace('.js', '')}`)\n })\n pending.set(path, promise)\n return promise\n}\n\nexport function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Record<string, any> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n const src = importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n // crude esmodule check\n // TODO: make sure this actually works\n // if (src && src.__esModule) {\n // ret[k] = src.default\n // } else {\n ret[k] = src\n // }\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch (e) {\n // skip\n // if (shouldPrintDebug) {\n // console.error('[\uD83D\uDC07] cant eval, skipping', cacheKey) //, e.message)\n // }\n }\n }\n\n return ret\n}\n"],
5
+ "mappings": "AAAA;AACA;AAGA;AAIA;AACA;AAEA,MAAM,gBAAgB,CAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG;AAEnF,2BAA2B,YAAoB,MAAc;AAC3D,QAAM,YAAY,QAAQ,UAAU;AACpC,MAAI,cAAc,IAAI,GAAG;AACvB,QAAI,QAAQ,IAAI,MAAM,IAAI;AACxB,cAAQ;AAAA,IACV;AACA,WAAO,QAAQ,WAAW,IAAI;AAAA,EAChC;AACA,SAAO;AACT;AAEA,MAAM,QAAQ,oBAAI,IAAI;AACtB,MAAM,UAAU,oBAAI,IAAI;AACxB,YAAY,MAAM;AAChB,MAAI,MAAM,MAAM;AACd,UAAM,MAAM;AAAA,EACd;AACF,GAAG,EAAE;AAEL,MAAM,UAAU,GAA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O,SAAS,SAAS;AAC/D;AAAA,IACF;AAGA,UAAM,MAAM,OAAO,aAAa,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;AAInF,QAAI,CAAC,OAAO,CAAC,IAAI,MAAM;AACrB;AAAA,IACF;AAGA,QAAI,OAAO,IAAI,GAAG,UAAU,YAAY,OAAO,IAAI,GAAG,QAAQ,UAAU;AACtE,cAAQ,MAAM,kCAAkC;AAChD;AAAA,IACF;AAEA,QAAI,CAAC,EAAE,aAAa,IAAI,EAAE,GAAG;AAC3B,cAAQ,MAAM,0BAA0B;AACxC;AAAA,IACF;AAEA,UAAM,WAAW,GAAG,IAAI,GAAG,QAAQ,IAAI,GAAG,SAAS,IAAI,GAAG;AAG1D,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAEA,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAGA,QAAI;AACF,UAAI,KAAK,gBAAgB,IAAI,MAAM,QAAW,gBAAgB;AAC9D,mBAAa,YAAY,IAAI;AAC7B;AAAA,IACF,SAAS,GAAP;AAAA,IAKF;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,20 @@
1
+ process.on("message", (path) => {
2
+ var _a, _b, _c;
3
+ if (typeof path !== "string") {
4
+ throw new Error(`Not a string: ${path}`);
5
+ }
6
+ try {
7
+ const out = require(path);
8
+ (_a = process.send) == null ? void 0 : _a.call(process, JSON.stringify(out));
9
+ } catch (err) {
10
+ if (err instanceof Error) {
11
+ (_b = process.send) == null ? void 0 : _b.call(process, `-${err.message}
12
+ ${err.stack}`);
13
+ } else {
14
+ (_c = process.send) == null ? void 0 : _c.call(process, `-${err}`);
15
+ }
16
+ }
17
+ });
18
+ setInterval(() => {
19
+ }, 1e3);
20
+ //# sourceMappingURL=loadFile.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/extractor/loadFile.ts"],
4
+ "sourcesContent": ["process.on('message', (path) => {\n if (typeof path !== 'string') {\n throw new Error(`Not a string: ${path}`)\n }\n try {\n const out = require(path)\n process.send?.(JSON.stringify(out))\n } catch (err) {\n if (err instanceof Error) {\n process.send?.(`-${err.message}\\n${err.stack}`)\n } else {\n process.send?.(`-${err}`)\n }\n }\n})\n\nsetInterval(() => {}, 1000)\n"],
5
+ "mappings": "AAAA,QAAQ,GAAG,WAAW,CAAC,SAAS;AAAhC;AACE,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,IAAI,MAAM,iBAAiB,MAAM;AAAA,EACzC;AACA,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,kBAAQ,SAAR,iCAAe,KAAK,UAAU,GAAG;AAAA,EACnC,SAAS,KAAP;AACA,QAAI,eAAe,OAAO;AACxB,oBAAQ,SAAR,iCAAe,IAAI,IAAI;AAAA,EAAY,IAAI;AAAA,IACzC,OAAO;AACL,oBAAQ,SAAR,iCAAe,IAAI;AAAA,IACrB;AAAA,EACF;AACF,CAAC;AAED,YAAY,MAAM;AAAC,GAAG,GAAI;",
6
+ "names": []
7
+ }
@@ -16,6 +16,7 @@ function registerRequire() {
16
16
  }
17
17
  const proxyWorm = require("@tamagui/proxy-worm");
18
18
  const rnw = require("react-native-web");
19
+ const core = require("@tamagui/core-node");
19
20
  Mod.prototype.require = function(path) {
20
21
  var _a;
21
22
  if (SHOULD_DEBUG) {
@@ -30,6 +31,9 @@ function registerRequire() {
30
31
  if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
31
32
  return rnw;
32
33
  }
34
+ if (path === "@tamagui/core") {
35
+ return core;
36
+ }
33
37
  try {
34
38
  const out = og.apply(this, arguments);
35
39
  if (!nameToPaths[path]) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/require.ts"],
4
- "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 500)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n // return og('react-native-web')\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)\\n`,\n err.message\n )\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n if (++tries > 10) {\n // avoid infinite loops\n process.exit(1)\n }\n }\n }\n}\n\nexport function unregisterRequire() {\n Mod.prototype.require = og\n}\n"],
5
- "mappings": "AAAA;AAIA;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YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,cAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,OACN;AACA,UAAI,cAAc;AAChB,gBAAQ,IAAI,IAAI,KAAK;AAAA,MACvB;AACA,UAAI,EAAE,QAAQ,IAAI;AAEhB,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,6BAA6B;AAClC,MAAI,UAAU,UAAU;AAC1B;",
4
+ "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 500)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const core = require('@tamagui/core-node')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n // return og('react-native-web')\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)\\n`,\n err.message\n )\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n if (++tries > 10) {\n // avoid infinite loops\n process.exit(1)\n }\n }\n }\n}\n\nexport function unregisterRequire() {\n Mod.prototype.require = og\n}\n"],
5
+ "mappings": "AAAA;AAIA;AAEA,MAAM,cAAc,CAAC;AACrB,MAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAM,KAAK,IAAI,UAAU;AACzB,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAEpC,IAAI,QAAQ;AACZ,YAAY,MAAM;AAChB,UAAQ;AACV,GAAG,GAAG;AAEC,2BAA2B;AAChC,MAAI,IAAI,UAAU,YAAY,WAAW,cAAc;AACrD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAC/C,QAAM,MAAM,QAAQ,kBAAkB;AACtC,QAAM,OAAO,QAAQ,oBAAoB;AAEzC,MAAI,UAAU,UAAU,SAAU,MAAc;AA5BlD;AA6BI,QAAI,cAAc;AAChB,cAAQ,IAAI,mBAAmB,IAAI;AAAA,IACrC;AACA,QAAI,KAAK,SAAS,MAAM,GAAG;AACzB,aAAO,CAAC;AAAA,IACV;AACA,QACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,wBACT;AACA,aAAO;AAAA,IACT;AACA,QACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,mCAAmC,GACpD;AACA,aAAO;AAAA,IAET;AACA,QAAI,SAAS,iBAAiB;AAC5B,aAAO;AAAA,IACT;AACA,QAAI;AACF,YAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AACpC,UAAI,CAAC,YAAY,OAAO;AACtB,YAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,qBAAW,OAAO,KAAK;AACrB,gBAAI;AACF,oBAAM,OAAO,UAAI,SAAJ,mBAAU;AACvB,kBAAI,MAAM;AACR,oBAAI,KAAK,eAAe;AACtB,8BAAY,KAAK,mBAAmB,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,KAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,cAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,OACN;AACA,UAAI,cAAc;AAChB,gBAAQ,IAAI,IAAI,KAAK;AAAA,MACvB;AACA,UAAI,EAAE,QAAQ,IAAI;AAEhB,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,6BAA6B;AAClC,MAAI,UAAU,UAAU;AAC1B;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
- import { dirname, extname, resolve } from "path";
1
+ import { fork } from "child_process";
2
+ import { dirname, extname, join, resolve } from "path";
2
3
  import * as t from "@babel/types";
3
- import { existsSync } from "fs-extra";
4
4
  import { evaluateAstNode } from "./evaluateAstNode";
5
5
  import { getSourceModule } from "./getSourceModule";
6
6
  const isLocalImport = (path) => path.startsWith(".") || path.startsWith("/");
@@ -14,23 +14,44 @@ function resolveImportPath(sourcePath, path) {
14
14
  }
15
15
  return path;
16
16
  }
17
+ const cache = /* @__PURE__ */ new Map();
18
+ const pending = /* @__PURE__ */ new Map();
19
+ setInterval(() => {
20
+ if (cache.size) {
21
+ cache.clear();
22
+ }
23
+ }, 10);
24
+ const loadCmd = `${join(__dirname, "loadFile.js")}`;
25
+ const child = fork(loadCmd, [], {
26
+ execArgv: ["-r", "esbuild-register"]
27
+ });
17
28
  function importModule(path) {
18
- const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
19
- for (const file of filenames) {
20
- if (existsSync(file)) {
21
- const { unregister } = require("esbuild-register/dist/node").register({
22
- target: "es2019",
23
- format: "cjs"
24
- });
25
- try {
26
- return require(file);
27
- } catch {
28
- } finally {
29
- unregister();
30
- }
31
- }
29
+ if (pending.has(path)) {
30
+ return pending.get(path);
32
31
  }
33
- return null;
32
+ const promise = new Promise((res, rej) => {
33
+ if (cache.has(path)) {
34
+ return cache.get(path);
35
+ }
36
+ const listener = (msg) => {
37
+ if (!msg)
38
+ return;
39
+ if (typeof msg !== "string")
40
+ return;
41
+ if (msg[0] === "-") {
42
+ rej(new Error(msg.slice(1)));
43
+ return;
44
+ }
45
+ child.removeListener("message", listener);
46
+ const val = JSON.parse(msg);
47
+ cache.set(path, val);
48
+ res(val);
49
+ };
50
+ child.once("message", listener);
51
+ child.send(`${path.replace(".js", "")}`);
52
+ });
53
+ pending.set(path, promise);
54
+ return promise;
34
55
  }
35
56
  function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
36
57
  const bindings = scope.getAllBindings();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/extractor/getStaticBindingsForScope.ts"],
4
- "sourcesContent": ["import { dirname, extname, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nfunction importModule(path: string) {\n const filenames = [path.replace('.js', '.tsx'), path.replace('.js', '.ts'), path]\n for (const file of filenames) {\n if (existsSync(file)) {\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n try {\n // TODO we can clear this when we see updates on it later on\n return require(file)\n } catch {\n // doesn't exists\n } finally {\n unregister()\n }\n }\n }\n return null\n}\n\nexport function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Record<string, any> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n const src = importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n // crude esmodule check\n // TODO: make sure this actually works\n // if (src && src.__esModule) {\n // ret[k] = src.default\n // } else {\n ret[k] = src\n // }\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch (e) {\n // skip\n // if (shouldPrintDebug) {\n // console.error('[\uD83D\uDC07] cant eval, skipping', cacheKey) //, e.message)\n // }\n }\n }\n\n return ret\n}\n"],
5
- "mappings": "AAAA;AAGA;AACA;AAEA;AACA;AAEA,MAAM,gBAAgB,CAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KA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M;AACrB;AAAA,IACF;AAGA,QAAI,OAAO,IAAI,GAAG,UAAU,YAAY,OAAO,IAAI,GAAG,QAAQ,UAAU;AACtE,cAAQ,MAAM,kCAAkC;AAChD;AAAA,IACF;AAEA,QAAI,CAAC,EAAE,aAAa,IAAI,EAAE,GAAG;AAC3B,cAAQ,MAAM,0BAA0B;AACxC;AAAA,IACF;AAEA,UAAM,WAAW,GAAG,IAAI,GAAG,QAAQ,IAAI,GAAG,SAAS,IAAI,GAAG;AAG1D,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAEA,QAAI,aAAa,eAAe,QAAQ,GAAG;AACzC,UAAI,KAAK,aAAa;AACtB;AAAA,IACF;AAGA,QAAI;AACF,UAAI,KAAK,gBAAgB,IAAI,MAAM,QAAW,gBAAgB;AAC9D,mBAAa,YAAY,IAAI;AAC7B;AAAA,IACF,SAAS,GAAP;AAAA,IAKF;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { fork, spawn } from 'child_process'\nimport { dirname, extname, join, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport esbuild from 'esbuild'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nconst cache = new Map()\nconst pending = new Map()\nsetInterval(() => {\n if (cache.size) {\n cache.clear()\n }\n}, 10)\n\nconst loadCmd = `${join(__dirname, 'loadFile.js')}`\nconst child = fork(loadCmd, [], {\n execArgv: ['-r', 'esbuild-register'],\n})\n\nfunction importModule(path: string) {\n if (pending.has(path)) {\n return pending.get(path)\n }\n const promise = new Promise((res, rej) => {\n if (cache.has(path)) {\n return cache.get(path)\n }\n const listener = (msg: any) => {\n if (!msg) return\n if (typeof msg !== 'string') return\n if (msg[0] === '-') {\n rej(new Error(msg.slice(1)))\n return\n }\n child.removeListener('message', listener)\n const val = JSON.parse(msg)\n cache.set(path, val)\n res(val)\n }\n child.once('message', listener)\n child.send(`${path.replace('.js', '')}`)\n })\n pending.set(path, promise)\n return promise\n}\n\nexport function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Record<string, any> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n const src = importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n // crude esmodule check\n // TODO: make sure this actually works\n // if (src && src.__esModule) {\n // ret[k] = src.default\n // } else {\n ret[k] = src\n // }\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch (e) {\n // skip\n // if (shouldPrintDebug) {\n // console.error('[\uD83D\uDC07] cant eval, skipping', cacheKey) //, e.message)\n // }\n }\n }\n\n return ret\n}\n"],
5
+ "mappings": "AAAA;AACA;AAGA;AAIA;AACA;AAEA,MAAM,gBAAgB,CAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG;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", (path) => {
2
+ var _a, _b, _c;
3
+ if (typeof path !== "string") {
4
+ throw new Error(`Not a string: ${path}`);
5
+ }
6
+ try {
7
+ const out = require(path);
8
+ (_a = process.send) == null ? void 0 : _a.call(process, JSON.stringify(out));
9
+ } catch (err) {
10
+ if (err instanceof Error) {
11
+ (_b = process.send) == null ? void 0 : _b.call(process, `-${err.message}
12
+ ${err.stack}`);
13
+ } else {
14
+ (_c = process.send) == null ? void 0 : _c.call(process, `-${err}`);
15
+ }
16
+ }
17
+ });
18
+ setInterval(() => {
19
+ }, 1e3);
20
+ //# sourceMappingURL=loadFile.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/extractor/loadFile.ts"],
4
+ "sourcesContent": ["process.on('message', (path) => {\n if (typeof path !== 'string') {\n throw new Error(`Not a string: ${path}`)\n }\n try {\n const out = require(path)\n process.send?.(JSON.stringify(out))\n } catch (err) {\n if (err instanceof Error) {\n process.send?.(`-${err.message}\\n${err.stack}`)\n } else {\n process.send?.(`-${err}`)\n }\n }\n})\n\nsetInterval(() => {}, 1000)\n"],
5
+ "mappings": "AAAA,QAAQ,GAAG,WAAW,CAAC,SAAS;AAAhC;AACE,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,IAAI,MAAM,iBAAiB,MAAM;AAAA,EACzC;AACA,MAAI;AACF,UAAM,MAAM,QAAQ,IAAI;AACxB,kBAAQ,SAAR,iCAAe,KAAK,UAAU,GAAG;AAAA,EACnC,SAAS,KAAP;AACA,QAAI,eAAe,OAAO;AACxB,oBAAQ,SAAR,iCAAe,IAAI,IAAI;AAAA,EAAY,IAAI;AAAA,IACzC,OAAO;AACL,oBAAQ,SAAR,iCAAe,IAAI;AAAA,IACrB;AAAA,EACF;AACF,CAAC;AAED,YAAY,MAAM;AAAC,GAAG,GAAI;",
6
+ "names": []
7
+ }
@@ -16,6 +16,7 @@ function registerRequire() {
16
16
  }
17
17
  const proxyWorm = require("@tamagui/proxy-worm");
18
18
  const rnw = require("react-native-web");
19
+ const core = require("@tamagui/core-node");
19
20
  Mod.prototype.require = function(path) {
20
21
  var _a, _b, _c;
21
22
  if (SHOULD_DEBUG) {
@@ -30,6 +31,9 @@ function registerRequire() {
30
31
  if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
31
32
  return rnw;
32
33
  }
34
+ if (path === "@tamagui/core") {
35
+ return core;
36
+ }
33
37
  try {
34
38
  const out = og.apply(this, arguments);
35
39
  if (!nameToPaths[path]) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/require.ts"],
4
- "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 500)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n // return og('react-native-web')\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)\\n`,\n err.message\n )\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n if (++tries > 10) {\n // avoid infinite loops\n process.exit(1)\n }\n }\n }\n}\n\nexport function unregisterRequire() {\n Mod.prototype.require = og\n}\n"],
5
- "mappings": "AAAA;AAIA;AAEA,MAAM,cAAc,CAAC;AACrB,MAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAM,KAAK,IAAI,UAAU;AACzB,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAEpC,IAAI,QAAQ;AACZ,YAAY,MAAM;AAChB,UAAQ;AACV,GAAG,GAAG;AAEC,2BAA2B;AAChC,MAAI,IAAI,UAAU,YAAY,WAAW,cAAc;AACrD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAC/C,QAAM,MAAM,QAAQ,kBAAkB;AAEtC,MAAI,UAAU,UAAU,SAAU,MAAc;AA3BlD;AA4BI,QAAI,cAAc;AAChB,cAAQ,IAAI,mBAAmB,IAAI;AAAA,IACrC;AACA,QAAI,KAAK,SAAS,MAAM,GAAG;AACzB,aAAO,CAAC;AAAA,IACV;AACA,QACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,wBACT;AACA,aAAO;AAAA,IACT;AACA,QACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,mCAAmC,GACpD;AACA,aAAO;AAAA,IAET;AACA,QAAI;AACF,YAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AACpC,UAAI,CAAC,YAAY,OAAO;AACtB,YAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,qBAAW,OAAO,KAAK;AACrB,gBAAI;AACF,oBAAM,OAAO,UAAI,SAAJ,mBAAU;AACvB,kBAAI,MAAM;AACR,oBAAI,KAAK,eAAe;AACtB,yCAAY,KAAK,mBAAjB,8BAAoC,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,KAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,cAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,OACN;AACA,UAAI,cAAc;AAChB,gBAAQ,IAAI,IAAI,KAAK;AAAA,MACvB;AACA,UAAI,EAAE,QAAQ,IAAI;AAEhB,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,6BAA6B;AAClC,MAAI,UAAU,UAAU;AAC1B;",
4
+ "sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 500)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const core = require('@tamagui/core-node')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n // return og('react-native-web')\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)\\n`,\n err.message\n )\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n if (++tries > 10) {\n // avoid infinite loops\n process.exit(1)\n }\n }\n }\n}\n\nexport function unregisterRequire() {\n Mod.prototype.require = og\n}\n"],
5
+ "mappings": "AAAA;AAIA;AAEA,MAAM,cAAc,CAAC;AACrB,MAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAM,KAAK,IAAI,UAAU;AACzB,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAEpC,IAAI,QAAQ;AACZ,YAAY,MAAM;AAChB,UAAQ;AACV,GAAG,GAAG;AAEC,2BAA2B;AAChC,MAAI,IAAI,UAAU,YAAY,WAAW,cAAc;AACrD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAC/C,QAAM,MAAM,QAAQ,kBAAkB;AACtC,QAAM,OAAO,QAAQ,oBAAoB;AAEzC,MAAI,UAAU,UAAU,SA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@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/static",
3
- "version": "1.0.1-beta.113",
3
+ "version": "1.0.1-beta.116",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -17,11 +17,11 @@
17
17
  "watch": "tamagui-build --watch",
18
18
  "clean": "tamagui-build clean",
19
19
  "clean:build": "tamagui-build clean:build",
20
- "test": "NODE_ENV=test TAMAGUI_COMPILE_PROCESS=1 jest --forceExit",
20
+ "test": "NODE_ENV=test jest --forceExit",
21
21
  "test:output": "TAMAGUI_TARGET=web node -r esbuild-register test-output.tsx",
22
22
  "test:babel": "DISABLE_PRE_TEST=true yarn test tests/babel-test.tsx",
23
- "test:debug": "NODE_ENV=test TAMAGUI_COMPILE_PROCESS=1 DEBUG_FILE=extract-specs.tsx DEBUG=1 yarn test",
24
- "test:watch": "NODE_ENV=test TAMAGUI_COMPILE_PROCESS=1 yarn test --watch",
23
+ "test:debug": "NODE_ENV=test DEBUG_FILE=extract-specs.tsx DEBUG=1 yarn test",
24
+ "test:watch": "NODE_ENV=test yarn test --watch",
25
25
  "test:update-snapshots": "NODE_ENV=test jest --updateSnapshot"
26
26
  },
27
27
  "tests": {
@@ -38,13 +38,13 @@
38
38
  "@babel/parser": "^7.15.7",
39
39
  "@babel/traverse": "^7.15.4",
40
40
  "@expo/match-media": "^0.3.0",
41
- "@tamagui/build": "^1.0.1-beta.113",
42
- "@tamagui/core-node": "^1.0.1-beta.113",
43
- "@tamagui/fake-react-native": "^1.0.1-beta.113",
44
- "@tamagui/helpers": "^1.0.1-beta.113",
45
- "@tamagui/patch-rnw": "^1.0.1-beta.113",
46
- "@tamagui/proxy-worm": "^1.0.1-beta.113",
47
- "@tamagui/shorthands": "^1.0.1-beta.113",
41
+ "@tamagui/build": "^1.0.1-beta.116",
42
+ "@tamagui/core-node": "^1.0.1-beta.116",
43
+ "@tamagui/fake-react-native": "^1.0.1-beta.116",
44
+ "@tamagui/helpers": "^1.0.1-beta.116",
45
+ "@tamagui/patch-rnw": "^1.0.1-beta.116",
46
+ "@tamagui/proxy-worm": "^1.0.1-beta.116",
47
+ "@tamagui/shorthands": "^1.0.1-beta.116",
48
48
  "babel-literal-to-ast": "^2.1.0",
49
49
  "esbuild": "^0.14.49",
50
50
  "esbuild-register": "^3.3.3",
@@ -52,7 +52,7 @@
52
52
  "fs-extra": "^10.1.0",
53
53
  "invariant": "^2.2.4",
54
54
  "lodash": "^4.17.21",
55
- "tamagui": "^1.0.1-beta.113"
55
+ "tamagui": "^1.0.1-beta.116"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@babel/plugin-syntax-typescript": "^7.14.5",
@@ -1,7 +1,9 @@
1
- import { dirname, extname, resolve } from 'path'
1
+ import { fork, spawn } from 'child_process'
2
+ import { dirname, extname, join, resolve } from 'path'
2
3
 
3
4
  import { Binding, NodePath } from '@babel/traverse'
4
5
  import * as t from '@babel/types'
6
+ import esbuild from 'esbuild'
5
7
  import { existsSync } from 'fs-extra'
6
8
 
7
9
  import { evaluateAstNode } from './evaluateAstNode'
@@ -20,25 +22,44 @@ function resolveImportPath(sourcePath: string, path: string) {
20
22
  return path
21
23
  }
22
24
 
25
+ const cache = new Map()
26
+ const pending = new Map()
27
+ setInterval(() => {
28
+ if (cache.size) {
29
+ cache.clear()
30
+ }
31
+ }, 10)
32
+
33
+ const loadCmd = `${join(__dirname, 'loadFile.js')}`
34
+ const child = fork(loadCmd, [], {
35
+ execArgv: ['-r', 'esbuild-register'],
36
+ })
37
+
23
38
  function importModule(path: string) {
24
- const filenames = [path.replace('.js', '.tsx'), path.replace('.js', '.ts'), path]
25
- for (const file of filenames) {
26
- if (existsSync(file)) {
27
- const { unregister } = require('esbuild-register/dist/node').register({
28
- target: 'es2019',
29
- format: 'cjs',
30
- })
31
- try {
32
- // TODO we can clear this when we see updates on it later on
33
- return require(file)
34
- } catch {
35
- // doesn't exists
36
- } finally {
37
- unregister()
39
+ if (pending.has(path)) {
40
+ return pending.get(path)
41
+ }
42
+ const promise = new Promise((res, rej) => {
43
+ if (cache.has(path)) {
44
+ return cache.get(path)
45
+ }
46
+ const listener = (msg: any) => {
47
+ if (!msg) return
48
+ if (typeof msg !== 'string') return
49
+ if (msg[0] === '-') {
50
+ rej(new Error(msg.slice(1)))
51
+ return
38
52
  }
53
+ child.removeListener('message', listener)
54
+ const val = JSON.parse(msg)
55
+ cache.set(path, val)
56
+ res(val)
39
57
  }
40
- }
41
- return null
58
+ child.once('message', listener)
59
+ child.send(`${path.replace('.js', '')}`)
60
+ })
61
+ pending.set(path, promise)
62
+ return promise
42
63
  }
43
64
 
44
65
  export function getStaticBindingsForScope(
@@ -0,0 +1,17 @@
1
+ process.on('message', (path) => {
2
+ if (typeof path !== 'string') {
3
+ throw new Error(`Not a string: ${path}`)
4
+ }
5
+ try {
6
+ const out = require(path)
7
+ process.send?.(JSON.stringify(out))
8
+ } catch (err) {
9
+ if (err instanceof Error) {
10
+ process.send?.(`-${err.message}\n${err.stack}`)
11
+ } else {
12
+ process.send?.(`-${err}`)
13
+ }
14
+ }
15
+ })
16
+
17
+ setInterval(() => {}, 1000)
package/src/require.ts CHANGED
@@ -24,6 +24,7 @@ export function registerRequire() {
24
24
 
25
25
  const proxyWorm = require('@tamagui/proxy-worm')
26
26
  const rnw = require('react-native-web')
27
+ const core = require('@tamagui/core-node')
27
28
 
28
29
  Mod.prototype.require = function (path: string) {
29
30
  if (SHOULD_DEBUG) {
@@ -47,6 +48,9 @@ export function registerRequire() {
47
48
  return rnw
48
49
  // return og('react-native-web')
49
50
  }
51
+ if (path === '@tamagui/core') {
52
+ return core
53
+ }
50
54
  try {
51
55
  const out = og.apply(this, arguments)
52
56
  if (!nameToPaths[path]) {
package/src/types.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { NodePath } from '@babel/traverse'
2
2
  import * as t from '@babel/types'
3
- import { PseudoStyles } from '@tamagui/core-node'
4
- import { StyleObject } from '@tamagui/core-node'
3
+ import type { PseudoStyles, StyleObject } from '@tamagui/core-node'
5
4
  import { ViewStyle } from 'react-native'
6
5
 
7
6
  export type { StyleObject } from '@tamagui/helpers'
@@ -0,0 +1,4 @@
1
+ import { NodePath } from '@babel/traverse';
2
+ import * as t from '@babel/types';
3
+ export declare function getStaticBindingsForScope(scope: NodePath<t.JSXElement>['scope'], whitelist: string[] | undefined, sourcePath: string, bindingCache: Record<string, string | null>, shouldPrintDebug: boolean | 'verbose'): Record<string, any>;
4
+ //# sourceMappingURL=getStaticBindingsForScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getStaticBindingsForScope.d.ts","sourceRoot":"","sources":["../../src/extractor/getStaticBindingsForScope.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AA4DjC,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,EACtC,SAAS,sBAAe,EACxB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAC3C,gBAAgB,EAAE,OAAO,GAAG,SAAS,GACpC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAqIrB"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=loadFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadFile.d.ts","sourceRoot":"","sources":["../../src/extractor/loadFile.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"require.d.ts","sourceRoot":"","sources":["../src/require.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,cAAc,UAAoB,CAAA;AAO/C,wBAAgB,eAAe,SAsE9B;AAED,wBAAgB,iBAAiB,SAEhC"}
1
+ {"version":3,"file":"require.d.ts","sourceRoot":"","sources":["../src/require.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,cAAc,UAAoB,CAAA;AAO/C,wBAAgB,eAAe,SA0E9B;AAED,wBAAgB,iBAAiB,SAEhC"}
package/types/types.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { NodePath } from '@babel/traverse';
2
2
  import * as t from '@babel/types';
3
- import { PseudoStyles } from '@tamagui/core-node';
4
- import { StyleObject } from '@tamagui/core-node';
3
+ import type { PseudoStyles, StyleObject } from '@tamagui/core-node';
5
4
  import { ViewStyle } from 'react-native';
6
5
  export type { StyleObject } from '@tamagui/helpers';
7
6
  export declare type ClassNameObject = t.StringLiteral | t.Expression;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,oBAAY,eAAe,GAAG,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,UAAU,CAAA;AAE5D,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED,MAAM,WAAW,cAAc;IAE7B,UAAU,EAAE,MAAM,EAAE,CAAA;IAEpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,yBAAyB,CAAC,EAAE,OAA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