@tamagui/static 1.0.0-beta.0.211 → 1.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -5
- package/dist/cjs/extractor/getStaticBindingsForScope.js +10 -1
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +2 -2
- package/dist/cjs/extractor/loadTamagui.js +3 -0
- package/dist/cjs/extractor/loadTamagui.js.map +2 -2
- package/dist/esm/extractor/getStaticBindingsForScope.js +10 -1
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +2 -2
- package/dist/esm/extractor/loadTamagui.js +3 -0
- package/dist/esm/extractor/loadTamagui.js.map +2 -2
- package/dist/jsx/extractor/getStaticBindingsForScope.js +10 -1
- package/dist/jsx/extractor/loadTamagui.js +3 -0
- package/package.json +7 -8
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/getStaticBindingsForScope.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
- bug with props after spread not applying, make them deopt:
|
|
3
|
-
- <YStack {...baseStyle} cursor="default" /> wont be right rn
|
|
4
|
-
- hoverStyle/pressStyle spread + constant
|
|
5
|
-
- LinearGradient
|
|
1
|
+
## static
|
|
@@ -45,7 +45,16 @@ function importModule(path) {
|
|
|
45
45
|
const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
|
|
46
46
|
for (const file of filenames) {
|
|
47
47
|
if ((0, import_fs_extra.existsSync)(file)) {
|
|
48
|
-
|
|
48
|
+
const { unregister } = require("esbuild-register/dist/node").register({
|
|
49
|
+
target: "es2019",
|
|
50
|
+
format: "cjs"
|
|
51
|
+
});
|
|
52
|
+
try {
|
|
53
|
+
return require(file);
|
|
54
|
+
} catch {
|
|
55
|
+
} finally {
|
|
56
|
+
unregister();
|
|
57
|
+
}
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
60
|
return null;
|
|
@@ -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 // TODO we can clear this when we see updates on it later on\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0C;AAG1C,QAAmB;AACnB,sBAA2B;AAE3B,6BAAgC;AAChC,6BAAgC;AAEhC,MAAM,gBAAgB,wBAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,GAA7D;AAEtB,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;AATS;AAWT,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;
|
|
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,wBAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,GAA7D;AAEtB,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;AATS;AAWT,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,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV,CAAC;AACD,UAAI;AAEF,eAAO,QAAQ,IAAI;AAAA,MACrB,QAAE;AAAA,MAEF,UAAE;AACA,mBAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAnBS;AAqBF,mCACL,OACA,YAAsB,CAAC,GACvB,YACA,cACA,kBACqB;AACrB,QAAM,WAAoC,MAAM,eAAe;AAC/D,QAAM,MAA2B,CAAC;AAElC,MAAI,kBAAkB;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_static";
|
|
38
|
+
if (typeof globalThis["__DEV__"] === "undefined") {
|
|
39
|
+
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
40
|
+
}
|
|
38
41
|
const proxyWorm = require("@tamagui/proxy-worm");
|
|
39
42
|
const rnw = require("react-native-web");
|
|
40
43
|
const Mod = require("module");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/loadTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { join } from 'path'\n\nimport type { TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'\nimport { createTamagui } from '@tamagui/core-node'\n\nlet loadedTamagui: any = null\n\nexport function loadTamagui(props: { components: string[]; config: string }): {\n components: Record<string, TamaguiComponent>\n tamaguiConfig: TamaguiInternalConfig\n} {\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n const configPath = join(process.cwd(), props.config)\n\n // threaded caching avoiding 1s loading of large configs every save\n // const cachePath = join(cacheDir, 'tamagui-conf-cached.json')\n // const confStat = statSync(configPath)\n\n // // TODO may want to disable, its pretty optimistic at caching...\n // try {\n // const confCache = readFileSync(cachePath, 'utf-8')\n // const confParsed = JSON.parse(confCache)\n // if (confParsed && confParsed.mtime === confStat.mtime) {\n // return confParsed.value\n // }\n // } catch {\n // // ok, no cache\n // }\n\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n try {\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const Mod = require('module')\n const og = Mod.prototype.require\n Mod.prototype.require = function (path: string) {\n if (path.endsWith('.css')) {\n return {}\n }\n if (path === '@gorhom/bottom-sheet' || path.startsWith('react-native-reanimated')) {\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 }\n try {\n return og.apply(this, arguments)\n } catch (err: any) {\n console.error('Tamagui error loading file:\\n')\n console.log(' ', path, '\\n')\n console.log(err.message)\n console.log(err.stack)\n // avoid infinite loops\n process.exit(1)\n }\n }\n\n // import config\n const exp = require(configPath)\n const tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n try {\n const confPath = require.resolve(configPath)\n console.log(`Received:`, tamaguiConfig)\n throw new Error(`Can't find valid config in ${confPath}`)\n } catch (err) {\n throw err\n }\n }\n\n // import components\n const components = {}\n for (const moduleName of props.components) {\n const exported = require(moduleName)\n for (const Name in exported) {\n const val = exported[Name]\n const staticConfig = val?.staticConfig\n if (staticConfig) {\n Object.assign(components, { [Name]: { staticConfig } })\n }\n }\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n Mod.prototype.require = og\n\n // set up core-node\n createTamagui(tamaguiConfig as any)\n\n loadedTamagui = {\n components,\n tamaguiConfig,\n }\n\n // save cache\n // try {\n // writeFileSync(\n // cachePath,\n // JSON.stringify({\n // value: loadedTamagui,\n // mtime: confStat.mtime,\n // })\n // )\n // } catch (err: any) {\n // console.log(`Error: tamagui config not stringifiable, caching disabled \"${err.message}\"`)\n // }\n\n return loadedTamagui\n } catch (err) {\n throw err\n } finally {\n unregister()\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAGrB,uBAA8B;AAE9B,IAAI,gBAAqB;AAElB,qBAAqB,OAG1B;AACA,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,sBAAK,QAAQ,IAAI,GAAG,MAAM,MAAM;AAiBnD,QAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,IACpE,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,MAAI;AAGF,YAAQ,IAAI,YAAY;
|
|
4
|
+
"sourcesContent": ["import { join } from 'path'\n\nimport type { TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'\nimport { createTamagui } from '@tamagui/core-node'\n\nlet loadedTamagui: any = null\n\nexport function loadTamagui(props: { components: string[]; config: string }): {\n components: Record<string, TamaguiComponent>\n tamaguiConfig: TamaguiInternalConfig\n} {\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n const configPath = join(process.cwd(), props.config)\n\n // threaded caching avoiding 1s loading of large configs every save\n // const cachePath = join(cacheDir, 'tamagui-conf-cached.json')\n // const confStat = statSync(configPath)\n\n // // TODO may want to disable, its pretty optimistic at caching...\n // try {\n // const confCache = readFileSync(cachePath, 'utf-8')\n // const confParsed = JSON.parse(confCache)\n // if (confParsed && confParsed.mtime === confStat.mtime) {\n // return confParsed.value\n // }\n // } catch {\n // // ok, no cache\n // }\n\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n try {\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n // @ts-ignore\n if (typeof globalThis['__DEV__'] === 'undefined') {\n // @ts-ignore\n globalThis['__DEV__'] = process.env.NODE_ENV === 'development'\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const Mod = require('module')\n const og = Mod.prototype.require\n Mod.prototype.require = function (path: string) {\n if (path.endsWith('.css')) {\n return {}\n }\n if (path === '@gorhom/bottom-sheet' || path.startsWith('react-native-reanimated')) {\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 }\n try {\n return og.apply(this, arguments)\n } catch (err: any) {\n console.error('Tamagui error loading file:\\n')\n console.log(' ', path, '\\n')\n console.log(err.message)\n console.log(err.stack)\n // avoid infinite loops\n process.exit(1)\n }\n }\n\n // import config\n const exp = require(configPath)\n const tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n try {\n const confPath = require.resolve(configPath)\n console.log(`Received:`, tamaguiConfig)\n throw new Error(`Can't find valid config in ${confPath}`)\n } catch (err) {\n throw err\n }\n }\n\n // import components\n const components = {}\n for (const moduleName of props.components) {\n const exported = require(moduleName)\n for (const Name in exported) {\n const val = exported[Name]\n const staticConfig = val?.staticConfig\n if (staticConfig) {\n Object.assign(components, { [Name]: { staticConfig } })\n }\n }\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n Mod.prototype.require = og\n\n // set up core-node\n createTamagui(tamaguiConfig as any)\n\n loadedTamagui = {\n components,\n tamaguiConfig,\n }\n\n // save cache\n // try {\n // writeFileSync(\n // cachePath,\n // JSON.stringify({\n // value: loadedTamagui,\n // mtime: confStat.mtime,\n // })\n // )\n // } catch (err: any) {\n // console.log(`Error: tamagui config not stringifiable, caching disabled \"${err.message}\"`)\n // }\n\n return loadedTamagui\n } catch (err) {\n throw err\n } finally {\n unregister()\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAGrB,uBAA8B;AAE9B,IAAI,gBAAqB;AAElB,qBAAqB,OAG1B;AACA,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,sBAAK,QAAQ,IAAI,GAAG,MAAM,MAAM;AAiBnD,QAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,IACpE,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,MAAI;AAGF,YAAQ,IAAI,YAAY;AAExB,QAAI,OAAO,WAAW,eAAe,aAAa;AAEhD,iBAAW,aAAa,QAAQ,IAAI,aAAa;AAAA,IACnD;AAEA,UAAM,YAAY,QAAQ,qBAAqB;AAC/C,UAAM,MAAM,QAAQ,kBAAkB;AACtC,UAAM,MAAM,QAAQ,QAAQ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A,IACF;AAeA,WAAO;AAAA,EACT,SAAS,KAAP;AACA,UAAM;AAAA,EACR,UAAE;AACA,eAAW;AAAA,EACb;AACF;AAhIgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,7 +21,16 @@ function importModule(path) {
|
|
|
21
21
|
const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
|
|
22
22
|
for (const file of filenames) {
|
|
23
23
|
if (existsSync(file)) {
|
|
24
|
-
|
|
24
|
+
const { unregister } = require("esbuild-register/dist/node").register({
|
|
25
|
+
target: "es2019",
|
|
26
|
+
format: "cjs"
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
return require(file);
|
|
30
|
+
} catch {
|
|
31
|
+
} finally {
|
|
32
|
+
unregister();
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
36
|
return null;
|
|
@@ -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 // TODO we can clear this when we see updates on it later on\n
|
|
5
|
-
"mappings": ";;AAAA;AAGA;AACA;AAEA;AACA;AAEA,MAAM,gBAAgB,wBAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,GAA7D;AAEtB,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;AATS;AAWT,sBAAsB,MAAc;AAClC,QAAM,YAAY,CAAC,KAAK,QAAQ,OAAO,MAAM,GAAG,KAAK,QAAQ,OAAO,KAAK,GAAG,IAAI;AAChF,aAAW,QAAQ,WAAW;AAC5B,QAAI,WAAW,IAAI,GAAG;
|
|
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,wBAAC,SAAiB,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,GAA7D;AAEtB,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;AATS;AAWT,sBAAsB,MAAc;AAClC,QAAM,YAAY,CAAC,KAAK,QAAQ,OAAO,MAAM,GAAG,KAAK,QAAQ,OAAO,KAAK,GAAG,IAAI;AAChF,aAAW,QAAQ,WAAW;AAC5B,QAAI,WAAW,IAAI,GAAG;AACpB,YAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,QACpE,QAAQ;AAAA,Q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A,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;AA3IgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -14,6 +14,9 @@ function loadTamagui(props) {
|
|
|
14
14
|
});
|
|
15
15
|
try {
|
|
16
16
|
process.env.IS_STATIC = "is_static";
|
|
17
|
+
if (typeof globalThis["__DEV__"] === "undefined") {
|
|
18
|
+
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
19
|
+
}
|
|
17
20
|
const proxyWorm = require("@tamagui/proxy-worm");
|
|
18
21
|
const rnw = require("react-native-web");
|
|
19
22
|
const Mod = require("module");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/loadTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { join } from 'path'\n\nimport type { TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'\nimport { createTamagui } from '@tamagui/core-node'\n\nlet loadedTamagui: any = null\n\nexport function loadTamagui(props: { components: string[]; config: string }): {\n components: Record<string, TamaguiComponent>\n tamaguiConfig: TamaguiInternalConfig\n} {\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n const configPath = join(process.cwd(), props.config)\n\n // threaded caching avoiding 1s loading of large configs every save\n // const cachePath = join(cacheDir, 'tamagui-conf-cached.json')\n // const confStat = statSync(configPath)\n\n // // TODO may want to disable, its pretty optimistic at caching...\n // try {\n // const confCache = readFileSync(cachePath, 'utf-8')\n // const confParsed = JSON.parse(confCache)\n // if (confParsed && confParsed.mtime === confStat.mtime) {\n // return confParsed.value\n // }\n // } catch {\n // // ok, no cache\n // }\n\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n try {\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const Mod = require('module')\n const og = Mod.prototype.require\n Mod.prototype.require = function (path: string) {\n if (path.endsWith('.css')) {\n return {}\n }\n if (path === '@gorhom/bottom-sheet' || path.startsWith('react-native-reanimated')) {\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 }\n try {\n return og.apply(this, arguments)\n } catch (err: any) {\n console.error('Tamagui error loading file:\\n')\n console.log(' ', path, '\\n')\n console.log(err.message)\n console.log(err.stack)\n // avoid infinite loops\n process.exit(1)\n }\n }\n\n // import config\n const exp = require(configPath)\n const tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n try {\n const confPath = require.resolve(configPath)\n console.log(`Received:`, tamaguiConfig)\n throw new Error(`Can't find valid config in ${confPath}`)\n } catch (err) {\n throw err\n }\n }\n\n // import components\n const components = {}\n for (const moduleName of props.components) {\n const exported = require(moduleName)\n for (const Name in exported) {\n const val = exported[Name]\n const staticConfig = val?.staticConfig\n if (staticConfig) {\n Object.assign(components, { [Name]: { staticConfig } })\n }\n }\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n Mod.prototype.require = og\n\n // set up core-node\n createTamagui(tamaguiConfig as any)\n\n loadedTamagui = {\n components,\n tamaguiConfig,\n }\n\n // save cache\n // try {\n // writeFileSync(\n // cachePath,\n // JSON.stringify({\n // value: loadedTamagui,\n // mtime: confStat.mtime,\n // })\n // )\n // } catch (err: any) {\n // console.log(`Error: tamagui config not stringifiable, caching disabled \"${err.message}\"`)\n // }\n\n return loadedTamagui\n } catch (err) {\n throw err\n } finally {\n unregister()\n }\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAGA;AAEA,IAAI,gBAAqB;AAElB,qBAAqB,OAG1B;AACA,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,MAAM,MAAM;AAiBnD,QAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,IACpE,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,MAAI;AAGF,YAAQ,IAAI,YAAY;
|
|
4
|
+
"sourcesContent": ["import { join } from 'path'\n\nimport type { TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'\nimport { createTamagui } from '@tamagui/core-node'\n\nlet loadedTamagui: any = null\n\nexport function loadTamagui(props: { components: string[]; config: string }): {\n components: Record<string, TamaguiComponent>\n tamaguiConfig: TamaguiInternalConfig\n} {\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n const configPath = join(process.cwd(), props.config)\n\n // threaded caching avoiding 1s loading of large configs every save\n // const cachePath = join(cacheDir, 'tamagui-conf-cached.json')\n // const confStat = statSync(configPath)\n\n // // TODO may want to disable, its pretty optimistic at caching...\n // try {\n // const confCache = readFileSync(cachePath, 'utf-8')\n // const confParsed = JSON.parse(confCache)\n // if (confParsed && confParsed.mtime === confStat.mtime) {\n // return confParsed.value\n // }\n // } catch {\n // // ok, no cache\n // }\n\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n try {\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n // @ts-ignore\n if (typeof globalThis['__DEV__'] === 'undefined') {\n // @ts-ignore\n globalThis['__DEV__'] = process.env.NODE_ENV === 'development'\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const Mod = require('module')\n const og = Mod.prototype.require\n Mod.prototype.require = function (path: string) {\n if (path.endsWith('.css')) {\n return {}\n }\n if (path === '@gorhom/bottom-sheet' || path.startsWith('react-native-reanimated')) {\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 }\n try {\n return og.apply(this, arguments)\n } catch (err: any) {\n console.error('Tamagui error loading file:\\n')\n console.log(' ', path, '\\n')\n console.log(err.message)\n console.log(err.stack)\n // avoid infinite loops\n process.exit(1)\n }\n }\n\n // import config\n const exp = require(configPath)\n const tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n try {\n const confPath = require.resolve(configPath)\n console.log(`Received:`, tamaguiConfig)\n throw new Error(`Can't find valid config in ${confPath}`)\n } catch (err) {\n throw err\n }\n }\n\n // import components\n const components = {}\n for (const moduleName of props.components) {\n const exported = require(moduleName)\n for (const Name in exported) {\n const val = exported[Name]\n const staticConfig = val?.staticConfig\n if (staticConfig) {\n Object.assign(components, { [Name]: { staticConfig } })\n }\n }\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n Mod.prototype.require = og\n\n // set up core-node\n createTamagui(tamaguiConfig as any)\n\n loadedTamagui = {\n components,\n tamaguiConfig,\n }\n\n // save cache\n // try {\n // writeFileSync(\n // cachePath,\n // JSON.stringify({\n // value: loadedTamagui,\n // mtime: confStat.mtime,\n // })\n // )\n // } catch (err: any) {\n // console.log(`Error: tamagui config not stringifiable, caching disabled \"${err.message}\"`)\n // }\n\n return loadedTamagui\n } catch (err) {\n throw err\n } finally {\n unregister()\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGA;AAEA,IAAI,gBAAqB;AAElB,qBAAqB,OAG1B;AACA,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,MAAM,MAAM;AAiBnD,QAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,IACpE,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,MAAI;AAGF,YAAQ,IAAI,YAAY;AAExB,QAAI,OAAO,WAAW,eAA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Aa,EAAE,CAAC;AAAA,QACxD;AAAA,MACF;AAAA,IACF;AAGA,YAAQ,IAAI,YAAY;AACxB,QAAI,UAAU,UAAU;AAGxB,kBAAc,aAAoB;AAElC,oBAAgB;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAeA,WAAO;AAAA,EACT,SAAS,KAAP;AACA,UAAM;AAAA,EACR,UAAE;AACA,eAAW;AAAA,EACb;AACF;AAhIgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,7 +21,16 @@ function importModule(path) {
|
|
|
21
21
|
const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
|
|
22
22
|
for (const file of filenames) {
|
|
23
23
|
if (existsSync(file)) {
|
|
24
|
-
|
|
24
|
+
const { unregister } = require("esbuild-register/dist/node").register({
|
|
25
|
+
target: "es2019",
|
|
26
|
+
format: "cjs"
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
return require(file);
|
|
30
|
+
} catch {
|
|
31
|
+
} finally {
|
|
32
|
+
unregister();
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
36
|
return null;
|
|
@@ -14,6 +14,9 @@ function loadTamagui(props) {
|
|
|
14
14
|
});
|
|
15
15
|
try {
|
|
16
16
|
process.env.IS_STATIC = "is_static";
|
|
17
|
+
if (typeof globalThis["__DEV__"] === "undefined") {
|
|
18
|
+
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
19
|
+
}
|
|
17
20
|
const proxyWorm = require("@tamagui/proxy-worm");
|
|
18
21
|
const rnw = require("react-native-web");
|
|
19
22
|
const Mod = require("module");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"typings": "types",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -33,12 +33,11 @@
|
|
|
33
33
|
"@babel/helper-plugin-utils": "^7.14.5",
|
|
34
34
|
"@babel/parser": "^7.15.7",
|
|
35
35
|
"@babel/traverse": "^7.15.4",
|
|
36
|
-
"@
|
|
37
|
-
"@tamagui/
|
|
38
|
-
"@tamagui/
|
|
39
|
-
"@tamagui/
|
|
40
|
-
"@tamagui/
|
|
41
|
-
"@tamagui/proxy-worm": "^1.0.0-beta.0.211+a49cc7ea",
|
|
36
|
+
"@tamagui/build": "^1.0.0-beta.11",
|
|
37
|
+
"@tamagui/core-node": "^1.0.0-beta.11",
|
|
38
|
+
"@tamagui/fake-react-native": "^1.0.0-beta.11",
|
|
39
|
+
"@tamagui/helpers": "^1.0.0-beta.11",
|
|
40
|
+
"@tamagui/proxy-worm": "^1.0.0-beta.11",
|
|
42
41
|
"babel-literal-to-ast": "^2.1.0",
|
|
43
42
|
"esbuild": "^0.14.36",
|
|
44
43
|
"esbuild-register": "^3.3.2",
|
|
@@ -46,7 +45,7 @@
|
|
|
46
45
|
"fs-extra": "^9.1.0",
|
|
47
46
|
"invariant": "^2.2.4",
|
|
48
47
|
"lodash": "^4.17.21",
|
|
49
|
-
"tamagui": "^1.0.0-beta.
|
|
48
|
+
"tamagui": "^1.0.0-beta.11"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@babel/plugin-syntax-typescript": "^7.14.5",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAGL,qBAAqB,EAOtB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAIL,mBAAmB,EAEpB,MAAM,UAAU,CAAA;AAqCjB,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;;;wBAqBb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,kPAiBrC,mBAAmB;;;;;;
|
|
1
|
+
{"version":3,"file":"createExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/createExtractor.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAE,QAAQ,EAAW,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAGL,qBAAqB,EAOtB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAIL,mBAAmB,EAEpB,MAAM,UAAU,CAAA;AAqCjB,oBAAY,SAAS,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;AAI1D,wBAAgB,eAAe;;;;;;;;;;;;;;;;wBAqBb,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,kPAiBrC,mBAAmB;;;;;;EA0/C3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStaticBindingsForScope.d.ts","sourceRoot":"","sources":["../../src/extractor/getStaticBindingsForScope.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"getStaticBindingsForScope.d.ts","sourceRoot":"","sources":["../../src/extractor/getStaticBindingsForScope.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAwCjC,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTamagui.d.ts","sourceRoot":"","sources":["../../src/extractor/loadTamagui.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAK5E,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAC5E,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAC5C,aAAa,EAAE,qBAAqB,CAAA;CACrC,
|
|
1
|
+
{"version":3,"file":"loadTamagui.d.ts","sourceRoot":"","sources":["../../src/extractor/loadTamagui.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAK5E,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAC5E,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAC5C,aAAa,EAAE,qBAAqB,CAAA;CACrC,CA6HA"}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Nate Wienert
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|