@tamagui/static 1.0.0-beta.179 → 1.0.0-beta.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants.js +8 -0
- package/dist/cjs/extractor/accessSafe.js +4 -0
- package/dist/cjs/extractor/babelParse.js +5 -0
- package/dist/cjs/extractor/babelParse.js.map +2 -2
- package/dist/cjs/extractor/buildClassName.js +4 -0
- package/dist/cjs/extractor/createEvaluator.js +5 -0
- package/dist/cjs/extractor/createExtractor.js +857 -730
- package/dist/cjs/extractor/createExtractor.js.map +2 -2
- package/dist/cjs/extractor/ensureImportingConcat.js +4 -0
- package/dist/cjs/extractor/evaluateAstNode.js +4 -0
- package/dist/cjs/extractor/extractHelpers.js +11 -0
- package/dist/cjs/extractor/extractMediaStyle.js +7 -2
- package/dist/cjs/extractor/extractMediaStyle.js.map +2 -2
- package/dist/cjs/extractor/extractToClassNames.js +12 -6
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/extractor/findTopmostFunction.js +4 -0
- package/dist/cjs/extractor/generatedUid.js +4 -0
- package/dist/cjs/extractor/getPrefixLogs.js +4 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js +4 -0
- package/dist/cjs/extractor/getSourceModule.js +4 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js +4 -0
- package/dist/cjs/extractor/hoistClassNames.js +4 -0
- package/dist/cjs/extractor/literalToAst.js +5 -0
- package/dist/cjs/extractor/loadTamagui.js +67 -47
- package/dist/cjs/extractor/loadTamagui.js.map +2 -2
- package/dist/cjs/extractor/logLines.js +4 -0
- package/dist/cjs/extractor/normalizeTernaries.js +4 -0
- package/dist/cjs/extractor/removeUnusedHooks.js +4 -0
- package/dist/cjs/extractor/timer.js +46 -0
- package/dist/cjs/extractor/timer.js.map +7 -0
- package/dist/cjs/extractor/validHTMLAttributes.js +4 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/patchReactNativeWeb.js +23 -7
- package/dist/cjs/patchReactNativeWeb.js.map +2 -2
- package/dist/esm/extractor/babelParse.js.map +2 -2
- package/dist/esm/extractor/createExtractor.js +863 -740
- package/dist/esm/extractor/createExtractor.js.map +2 -2
- package/dist/esm/extractor/extractMediaStyle.js +2 -2
- package/dist/esm/extractor/extractMediaStyle.js.map +2 -2
- package/dist/esm/extractor/extractToClassNames.js +8 -6
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/extractor/loadTamagui.js +63 -47
- package/dist/esm/extractor/loadTamagui.js.map +2 -2
- package/dist/esm/extractor/timer.js +24 -0
- package/dist/esm/extractor/timer.js.map +7 -0
- package/dist/esm/patchReactNativeWeb.js +19 -7
- package/dist/esm/patchReactNativeWeb.js.map +2 -2
- package/dist/jsx/extractor/createExtractor.js +863 -740
- package/dist/jsx/extractor/extractMediaStyle.js +2 -2
- package/dist/jsx/extractor/extractToClassNames.js +8 -6
- package/dist/jsx/extractor/loadTamagui.js +63 -47
- package/dist/jsx/extractor/timer.js +23 -0
- package/dist/jsx/patchReactNativeWeb.js +19 -7
- package/package.json +23 -23
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +1 -1
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +2 -2
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/timer.d.ts +5 -0
- package/types/extractor/timer.d.ts.map +1 -0
- package/types/patchReactNativeWeb.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/extractToClassNames.ts"],
|
|
4
|
-
"sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { ViewStyle } from 'react-native'\nimport { LoaderContext } from 'webpack'\n\nimport { CONCAT_CLASSNAME_IMPORT } from '../constants'\nimport { ClassNameObject, StyleObject, TamaguiOptions, Ternary } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { getPrefixLogs } from './getPrefixLogs'\nimport { hoistClassNames } from './hoistClassNames'\nimport { literalToAst } from './literalToAst'\nimport { logLines } from './logLines'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport type ExtractedResponse = {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n}\n\nexport function extractToClassNames({\n loader,\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n threaded,\n cssPath,\n}: {\n loader: LoaderContext<any>\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean | 'verbose'\n cssPath: string\n threaded?: boolean\n}): ExtractedResponse | null {\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n // @ts-ignore\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n let hasFlattened = false\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n getFlattenedNode: ({ tag }) => {\n hasFlattened = true\n return tag\n },\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n isFlattened,\n }) => {\n let finalClassNames: ClassNameObject[] = []\n let finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n const viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n Object.assign(viewStyles, attr.value)\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null): StyleObject[] => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style':\n if (!isFlattened) {\n if (!attr.name) {\n throw new Error(`No name`)\n }\n\n // only ever one at a time i believe so we can be lazy with this access\n const { hoverStyle, pressStyle, focusStyle } = attr.value\n const pseudos = [\n ['hoverStyle', hoverStyle],\n ['pressStyle', pressStyle],\n ['focusStyle', focusStyle],\n ] as const\n\n const styles = getStylesAtomic(attr.value, {\n splitTransforms: true,\n })\n\n finalStyles = [...finalStyles, ...styles]\n\n for (const [key, value] of pseudos) {\n if (value && Object.keys(value).length) {\n finalAttrs.push(\n t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(literalToAst(value))\n )\n )\n }\n }\n\n for (const style of styles) {\n // leave them as attributes\n finalAttrs.push(\n t.jsxAttribute(t.jsxIdentifier(style.property), t.stringLiteral(style.identifier))\n )\n }\n } else {\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n // prettier-ignore\n const existing = finalClassNames.find((x) => x.type == 'StringLiteral') as t.StringLiteral | null\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n }\n\n break\n case 'attr':\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n case 'ternary':\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (shouldPrintDebug) {\n if (mediaExtraction) {\n // prettier-ignore\n console.log('ternary (mediaStyles)', mediaExtraction.ternaryWithoutMedia?.inlineMediaQuery ?? '', mediaExtraction.mediaStyles.map((x) => x.identifier).join('.'))\n }\n }\n if (!mediaExtraction) {\n addTernaryStyle(\n attr.value,\n addStyles(attr.value.consequent),\n addStyles(attr.value.alternate)\n )\n continue\n }\n lastMediaImportance++\n if (mediaExtraction.mediaStyles) {\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n }\n if (mediaExtraction.ternaryWithoutMedia) {\n addTernaryStyle(mediaExtraction.ternaryWithoutMedia, mediaExtraction.mediaStyles, [])\n } else {\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n }\n break\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' finalClassNames\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n\n function addTernaryStyle(ternary: Ternary, a: any, b: any) {\n const cCN = a.map((x) => x.identifier).join(' ')\n const aCN = b.map((x) => x.identifier).join(' ')\n if (a.length && b.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n const names = buildClassName(finalClassNames)\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n if (!hasFlattened) {\n // not flat\n } else {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { className, rules, identifier, value } of finalStyles) {\n // console.log('backvalue', identifier, value)\n // ast.program.body.unshift(\n // t.expressionStatement(\n // t.callExpression(\n // t.memberExpression(\n // t.callExpression(t.identifier('require'), [t.stringLiteral('@tamagui/core')]),\n // t.identifier('setIdentifierValue')\n // ),\n // [t.stringLiteral(identifier), t.stringLiteral(value)]\n // )\n // )\n // )\n\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n if (styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = loader.remainingRequest\n const importPath = `${cssPath}!=!tamagui-loader?${cssQuery}!${remReq}`\n ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)))\n }\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const timing = `${Date.now() - start}`.padStart(3)\n const path = basename(sourcePath)\n .replace(/\\.[jt]sx?$/, '')\n .slice(0, 22)\n .trim()\n .padStart(24)\n const numOptimized = `${res.optimized}`.padStart(3)\n const numFound = `${res.found}`.padStart(3)\n const numFlattened = `${res.flattened}`.padStart(3)\n const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : ''\n const timingStr = `${timing}ms`.padStart(6)\n console.log(\n `${getPrefixLogs(\n options\n )} ${path} ${numFound} \u00B7 ${numOptimized} \u00B7 ${numFlattened} ${timingStr} ${\n memory ? `(${memory})` : ''\n }`\n )\n }\n\n return {\n ast,\n styles,\n js: result.code,\n map: result.map,\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AACtB,kBAAyB;AACzB,WAAsB;AAEtB,uBAAqB;AACrB,QAAmB;AACnB,uBAAgC;AAChC,qBAAgC;AAChC,uBAAsB;AAItB,uBAAwC;AAExC,wBAA2B;AAC3B,4BAA+B;AAE/B,mCAAsC;AACtC,4BAA+B;AAC/B,+BAAkC;AAClC,2BAA8B;AAC9B,6BAAgC;AAChC,0BAA6B;AAC7B,sBAAyB;
|
|
4
|
+
"sourcesContent": ["import * as path from 'path'\nimport { basename } from 'path'\nimport * as util from 'util'\n\nimport generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport { getStylesAtomic } from '@tamagui/core-node'\nimport { concatClassName } from '@tamagui/helpers'\nimport invariant from 'invariant'\nimport { ViewStyle } from 'react-native'\nimport { LoaderContext } from 'webpack'\n\nimport { CONCAT_CLASSNAME_IMPORT } from '../constants'\nimport { ClassNameObject, StyleObject, TamaguiOptions, Ternary } from '../types'\nimport { babelParse } from './babelParse'\nimport { buildClassName } from './buildClassName'\nimport { Extractor } from './createExtractor'\nimport { ensureImportingConcat } from './ensureImportingConcat'\nimport { isSimpleSpread } from './extractHelpers'\nimport { extractMediaStyle } from './extractMediaStyle'\nimport { getPrefixLogs } from './getPrefixLogs'\nimport { hoistClassNames } from './hoistClassNames'\nimport { literalToAst } from './literalToAst'\nimport { logLines } from './logLines'\nimport { timer } from './timer'\n\nconst mergeStyleGroups = {\n shadowOpacity: true,\n shadowRadius: true,\n shadowColor: true,\n shadowOffset: true,\n}\n\nexport type ExtractedResponse = {\n js: string | Buffer\n styles: string\n stylesPath?: string\n ast: t.File\n map: any // RawSourceMap from 'source-map'\n}\n\nexport function extractToClassNames({\n loader,\n extractor,\n source,\n sourcePath,\n options,\n shouldPrintDebug,\n cssLoaderPath,\n threaded,\n cssPath,\n}: {\n loader: LoaderContext<any>\n cssLoaderPath: string\n extractor: Extractor\n source: string | Buffer\n sourcePath: string\n options: TamaguiOptions\n shouldPrintDebug: boolean | 'verbose'\n cssPath: string\n threaded?: boolean\n}): ExtractedResponse | null {\n const tm = timer()\n\n if (typeof source !== 'string') {\n throw new Error('`source` must be a string of javascript')\n }\n invariant(\n typeof sourcePath === 'string' && path.isAbsolute(sourcePath),\n '`sourcePath` must be an absolute path to a .js file'\n )\n\n const shouldLogTiming = options.logTimings ?? true\n const start = Date.now()\n const mem = shouldLogTiming ? process.memoryUsage() : null\n\n // Using a map for (officially supported) guaranteed insertion order\n let ast: t.File\n\n try {\n // @ts-ignore\n ast = babelParse(source)\n } catch (err) {\n console.error('babel parse error:', sourcePath)\n throw err\n }\n\n tm.mark(`babel-parse`, shouldPrintDebug === 'verbose')\n\n const cssMap = new Map<string, { css: string; commentTexts: string[] }>()\n const existingHoists: { [key: string]: t.Identifier } = {}\n\n let hasFlattened = false\n\n const res = extractor.parse(ast, {\n sourcePath,\n shouldPrintDebug,\n ...options,\n getFlattenedNode: ({ tag }) => {\n hasFlattened = true\n return tag\n },\n onExtractTag: ({\n attrs,\n node,\n attemptEval,\n jsxPath,\n originalNodeName,\n filePath,\n lineNumbers,\n programPath,\n isFlattened,\n }) => {\n let finalClassNames: ClassNameObject[] = []\n let finalAttrs: (t.JSXAttribute | t.JSXSpreadAttribute)[] = []\n let finalStyles: StyleObject[] = []\n\n const viewStyles = {}\n for (const attr of attrs) {\n if (attr.type === 'style') {\n Object.assign(viewStyles, attr.value)\n }\n }\n\n const ensureNeededPrevStyle = (style: ViewStyle) => {\n // ensure all group keys are merged\n const keys = Object.keys(style)\n if (!keys.some((key) => mergeStyleGroups[key])) {\n return style\n }\n for (const k in mergeStyleGroups) {\n if (k in viewStyles) {\n style[k] = style[k] ?? viewStyles[k]\n }\n }\n return style\n }\n\n const addStyles = (style: ViewStyle | null): StyleObject[] => {\n if (!style) return []\n const styleWithPrev = ensureNeededPrevStyle(style)\n const res = getStylesAtomic(styleWithPrev)\n if (res.length) {\n finalStyles = [...finalStyles, ...res]\n }\n return res\n }\n\n // 1 to start above any :hover styles\n let lastMediaImportance = 1\n for (const attr of attrs) {\n switch (attr.type) {\n case 'style':\n if (!isFlattened) {\n // only ever one at a time i believe so we can be lazy with this access\n const { hoverStyle, pressStyle, focusStyle } = attr.value\n const pseudos = [\n ['hoverStyle', hoverStyle],\n ['pressStyle', pressStyle],\n ['focusStyle', focusStyle],\n ] as const\n\n const styles = getStylesAtomic(attr.value, {\n splitTransforms: true,\n })\n finalStyles = [...finalStyles, ...styles]\n\n for (const [key, value] of pseudos) {\n if (value && Object.keys(value).length) {\n finalAttrs.push(\n t.jsxAttribute(\n t.jsxIdentifier(key),\n t.jsxExpressionContainer(literalToAst(value))\n )\n )\n }\n }\n\n for (const style of styles) {\n // leave them as attributes\n finalAttrs.push(\n t.jsxAttribute(t.jsxIdentifier(style.property), t.stringLiteral(style.identifier))\n )\n }\n\n // for (const key in attr.value) {\n // if (pseudos.some((x) => x[0] === key)) {\n // // we handled pseudos above...\n // continue\n // }\n // // leave them as attributes\n // finalAttrs.push(\n // t.jsxAttribute(t.jsxIdentifier(key), t.stringLiteral(attr.value[key]))\n // )\n // }\n } else {\n const styles = addStyles(attr.value)\n const newClassNames = concatClassName(styles.map((x) => x.identifier).join(' '))\n const existing = finalClassNames.find(\n (x) => x.type == 'StringLiteral'\n ) as t.StringLiteral | null\n\n // const newClassNames = concatClassName(Object.values(attr.value))\n // const existing = finalClassNames.find(\n // (x) => x.type == 'StringLiteral'\n // ) as t.StringLiteral | null\n\n if (existing) {\n existing.value = `${existing.value} ${newClassNames}`\n } else {\n finalClassNames = [...finalClassNames, t.stringLiteral(newClassNames)]\n }\n }\n\n break\n case 'attr':\n const val = attr.value\n if (t.isJSXSpreadAttribute(val)) {\n if (isSimpleSpread(val)) {\n finalClassNames.push(\n t.logicalExpression(\n '&&',\n val.argument,\n t.memberExpression(val.argument, t.identifier('className'))\n )\n )\n }\n } else if (val.name.name === 'className') {\n const value = val.value\n if (value) {\n try {\n const evaluatedValue = attemptEval(value)\n finalClassNames.push(t.stringLiteral(evaluatedValue))\n } catch (e) {\n finalClassNames.push(value['expression'])\n }\n }\n continue\n }\n finalAttrs.push(val)\n break\n case 'ternary':\n const mediaExtraction = extractMediaStyle(\n attr.value,\n jsxPath,\n extractor.getTamagui(),\n sourcePath,\n lastMediaImportance,\n shouldPrintDebug\n )\n if (shouldPrintDebug) {\n if (mediaExtraction) {\n // prettier-ignore\n console.log('ternary (mediaStyles)', mediaExtraction.ternaryWithoutMedia?.inlineMediaQuery ?? '', mediaExtraction.mediaStyles.map((x) => x.identifier).join('.'))\n }\n }\n if (!mediaExtraction) {\n addTernaryStyle(\n attr.value,\n addStyles(attr.value.consequent),\n addStyles(attr.value.alternate)\n )\n continue\n }\n lastMediaImportance++\n if (mediaExtraction.mediaStyles) {\n finalStyles = [...finalStyles, ...mediaExtraction.mediaStyles]\n }\n if (mediaExtraction.ternaryWithoutMedia) {\n addTernaryStyle(mediaExtraction.ternaryWithoutMedia, mediaExtraction.mediaStyles, [])\n } else {\n finalClassNames = [\n ...finalClassNames,\n ...mediaExtraction.mediaStyles.map((x) => t.stringLiteral(x.identifier)),\n ]\n }\n break\n }\n }\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' finalClassNames\\n', logLines(finalClassNames.map(x => x['value']).join(' ')))\n }\n\n function addTernaryStyle(ternary: Ternary, a: any, b: any) {\n const cCN = a.map((x) => x.identifier).join(' ')\n const aCN = b.map((x) => x.identifier).join(' ')\n if (a.length && b.length) {\n finalClassNames.push(\n t.conditionalExpression(ternary.test, t.stringLiteral(cCN), t.stringLiteral(aCN))\n )\n } else {\n finalClassNames.push(\n t.conditionalExpression(\n ternary.test,\n t.stringLiteral(' ' + cCN),\n t.stringLiteral(' ' + aCN)\n )\n )\n }\n }\n\n node.attributes = finalAttrs\n\n if (finalClassNames.length) {\n // inserts the _cn variable and uses it for className\n const names = buildClassName(finalClassNames)\n const nameExpr = names ? hoistClassNames(jsxPath, existingHoists, names) : null\n let expr = nameExpr\n\n // if has some spreads, use concat helper\n if (nameExpr && !t.isIdentifier(nameExpr)) {\n if (!hasFlattened) {\n // not flat\n } else {\n ensureImportingConcat(programPath)\n const simpleSpreads = attrs.filter(\n (x) => t.isJSXSpreadAttribute(x.value) && isSimpleSpread(x.value)\n )\n expr = t.callExpression(t.identifier(CONCAT_CLASSNAME_IMPORT), [\n expr,\n ...simpleSpreads.map((val) => val.value['argument']),\n ])\n }\n }\n\n node.attributes.push(\n t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(expr))\n )\n }\n\n const comment = util.format('/* %s:%s (%s) */', filePath, lineNumbers, originalNodeName)\n\n for (const { className, rules, identifier, value } of finalStyles) {\n // console.log('backvalue', identifier, value)\n // ast.program.body.unshift(\n // t.expressionStatement(\n // t.callExpression(\n // t.memberExpression(\n // t.callExpression(t.identifier('require'), [t.stringLiteral('@tamagui/core')]),\n // t.identifier('setIdentifierValue')\n // ),\n // [t.stringLiteral(identifier), t.stringLiteral(value)]\n // )\n // )\n // )\n\n if (cssMap.has(className)) {\n if (comment) {\n const val = cssMap.get(className)!\n val.commentTexts.push(comment)\n cssMap.set(className, val)\n }\n } else if (rules.length) {\n if (rules.length > 1) {\n console.log(' rules error', { rules })\n throw new Error(`Shouldn't have more than one rule`)\n }\n cssMap.set(className, {\n css: rules[0],\n commentTexts: [comment],\n })\n }\n }\n },\n })\n\n if (!res || (!res.modified && !res.optimized && !res.flattened)) {\n if (shouldPrintDebug) {\n console.log('no res or none modified', res)\n }\n return null\n }\n\n const styles = Array.from(cssMap.values())\n .map((x) => x.css)\n .join('\\n')\n .trim()\n\n if (styles) {\n const cssQuery = threaded\n ? `cssData=${Buffer.from(styles).toString('base64')}`\n : `cssPath=${cssPath}`\n const remReq = loader.remainingRequest\n const importPath = `${cssPath}!=!${cssLoaderPath}?${cssQuery}!${remReq}`\n ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)))\n }\n\n const result = generate(\n ast,\n {\n concise: false,\n filename: sourcePath,\n // this makes the debug output terrible, and i think sourcemap works already\n retainLines: false,\n sourceFileName: sourcePath,\n sourceMaps: true,\n },\n source\n )\n\n if (shouldPrintDebug) {\n console.log(\n '\\n -------- output code ------- \\n\\n',\n result.code\n .split('\\n')\n .filter((x) => !x.startsWith('//'))\n .join('\\n')\n )\n console.log('\\n -------- output style -------- \\n\\n', styles)\n }\n\n if (shouldLogTiming) {\n const memUsed = mem\n ? Math.round(((process.memoryUsage().heapUsed - mem.heapUsed) / 1024 / 1204) * 10) / 10\n : 0\n const path = basename(sourcePath)\n .replace(/\\.[jt]sx?$/, '')\n .slice(0, 22)\n .trim()\n .padStart(24)\n const numOptimized = `${res.optimized}`.padStart(3)\n const numFound = `${res.found}`.padStart(3)\n const numFlattened = `${res.flattened}`.padStart(3)\n const memory = process.env.DEBUG && memUsed > 10 ? ` ${memUsed}MB` : ''\n const timing = Date.now() - start\n const timingWarning = timing > 50 ? '\u26A0\uFE0F' : timing > 150 ? '\u2622\uFE0F' : ''\n const timingStr = `${timing}ms${timingWarning}`.padStart(6)\n console.log(\n `${getPrefixLogs(\n options\n )} ${path} ${numFound} \u00B7 ${numOptimized} \u00B7 ${numFlattened} ${timingStr} ${\n memory ? `(${memory})` : ''\n }`\n )\n }\n\n return {\n ast,\n styles,\n js: result.code,\n map: result.map,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AACtB,kBAAyB;AACzB,WAAsB;AAEtB,uBAAqB;AACrB,QAAmB;AACnB,uBAAgC;AAChC,qBAAgC;AAChC,uBAAsB;AAItB,uBAAwC;AAExC,wBAA2B;AAC3B,4BAA+B;AAE/B,mCAAsC;AACtC,4BAA+B;AAC/B,+BAAkC;AAClC,2BAA8B;AAC9B,6BAAgC;AAChC,0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I,SAAS,UAAU,KAAK,IAAI,cAAc;AACrE,UAAM,SAAS,KAAK,IAAI,IAAI;AAC5B,UAAM,gBAAgB,SAAS,KAAK,iBAAO,SAAS,MAAM,iBAAO;AACjE,UAAM,YAAY,GAAG,WAAW,gBAAgB,SAAS,CAAC;AAC1D,YAAQ,IACN,GAAG,wCACD,OACF,KAAK,UAAS,mBAAgB,uBAAoB,iBAAiB,aACjE,SAAS,IAAI,YAAY,IAE7B;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,IAAI,OAAO;AAAA,IACX,KAAK,OAAO;AAAA,EACd;AACF;AAnZgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -38,4 +38,8 @@ function findTopmostFunction(jsxPath) {
|
|
|
38
38
|
return compFn;
|
|
39
39
|
}
|
|
40
40
|
__name(findTopmostFunction, "findTopmostFunction");
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
findTopmostFunction
|
|
44
|
+
});
|
|
41
45
|
//# sourceMappingURL=findTopmostFunction.js.map
|
|
@@ -26,4 +26,8 @@ function getPrefixLogs(options) {
|
|
|
26
26
|
return (options == null ? void 0 : options.prefixLogs) ?? ` ${TAMAGUI_TARGET} | `;
|
|
27
27
|
}
|
|
28
28
|
__name(getPrefixLogs, "getPrefixLogs");
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
getPrefixLogs
|
|
32
|
+
});
|
|
29
33
|
//# sourceMappingURL=getPrefixLogs.js.map
|
|
@@ -67,4 +67,8 @@ function getPropValueFromAttributes(propName, attrs) {
|
|
|
67
67
|
return propValue;
|
|
68
68
|
}
|
|
69
69
|
__name(getPropValueFromAttributes, "getPropValueFromAttributes");
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
getPropValueFromAttributes
|
|
73
|
+
});
|
|
70
74
|
//# sourceMappingURL=getPropValueFromAttributes.js.map
|
|
@@ -87,4 +87,8 @@ function getSourceModule(itemName, itemBinding) {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
__name(getSourceModule, "getSourceModule");
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
getSourceModule
|
|
93
|
+
});
|
|
90
94
|
//# sourceMappingURL=getSourceModule.js.map
|
|
@@ -146,4 +146,8 @@ function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCac
|
|
|
146
146
|
return ret;
|
|
147
147
|
}
|
|
148
148
|
__name(getStaticBindingsForScope, "getStaticBindingsForScope");
|
|
149
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
150
|
+
0 && (module.exports = {
|
|
151
|
+
getStaticBindingsForScope
|
|
152
|
+
});
|
|
149
153
|
//# sourceMappingURL=getStaticBindingsForScope.js.map
|
|
@@ -62,4 +62,8 @@ function hoistClassNames(path, existing, expr) {
|
|
|
62
62
|
__name(replaceStringWithVariable, "replaceStringWithVariable");
|
|
63
63
|
}
|
|
64
64
|
__name(hoistClassNames, "hoistClassNames");
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
hoistClassNames
|
|
68
|
+
});
|
|
65
69
|
//# sourceMappingURL=hoistClassNames.js.map
|
|
@@ -111,4 +111,9 @@ function computeProps(props) {
|
|
|
111
111
|
}, {});
|
|
112
112
|
}
|
|
113
113
|
__name(computeProps, "computeProps");
|
|
114
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
115
|
+
0 && (module.exports = {
|
|
116
|
+
astToLiteral,
|
|
117
|
+
literalToAst
|
|
118
|
+
});
|
|
114
119
|
//# sourceMappingURL=literalToAst.js.map
|
|
@@ -28,56 +28,76 @@ function loadTamagui(props) {
|
|
|
28
28
|
if (loadedTamagui) {
|
|
29
29
|
return loadedTamagui;
|
|
30
30
|
}
|
|
31
|
-
process.env.IS_STATIC = "is_static";
|
|
32
|
-
const proxyWorm = require("@tamagui/proxy-worm");
|
|
33
|
-
const rnw = require("react-native-web");
|
|
34
|
-
const Mod = require("module");
|
|
35
|
-
const og = Mod.prototype.require;
|
|
36
|
-
Mod.prototype.require = function(path) {
|
|
37
|
-
if (path.endsWith(".css")) {
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
|
-
if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated")) {
|
|
41
|
-
return proxyWorm;
|
|
42
|
-
}
|
|
43
|
-
if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
|
|
44
|
-
return rnw;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
return og.apply(this, arguments);
|
|
48
|
-
} catch (err) {
|
|
49
|
-
console.error("Tamagui error loading file:\n");
|
|
50
|
-
console.log(" ", path, "\n");
|
|
51
|
-
console.log(err.message);
|
|
52
|
-
console.log(err.stack);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
31
|
const configPath = (0, import_path.join)(process.cwd(), props.config);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
32
|
+
const { unregister } = require("esbuild-register/dist/node").register({
|
|
33
|
+
target: "es2019",
|
|
34
|
+
format: "cjs"
|
|
35
|
+
});
|
|
36
|
+
try {
|
|
37
|
+
process.env.IS_STATIC = "is_static";
|
|
38
|
+
const proxyWorm = require("@tamagui/proxy-worm");
|
|
39
|
+
const rnw = require("react-native-web");
|
|
40
|
+
const Mod = require("module");
|
|
41
|
+
const og = Mod.prototype.require;
|
|
42
|
+
Mod.prototype.require = function(path) {
|
|
43
|
+
if (path.endsWith(".css")) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated")) {
|
|
47
|
+
return proxyWorm;
|
|
48
|
+
}
|
|
49
|
+
if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
|
|
50
|
+
return rnw;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return og.apply(this, arguments);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.error("Tamagui error loading file:\n");
|
|
56
|
+
console.log(" ", path, "\n");
|
|
57
|
+
console.log(err.message);
|
|
58
|
+
console.log(err.stack);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const exp = require(configPath);
|
|
63
|
+
const tamaguiConfig = exp["default"] || exp;
|
|
64
|
+
if (!tamaguiConfig || !tamaguiConfig.parsed) {
|
|
65
|
+
try {
|
|
66
|
+
const confPath = require.resolve(configPath);
|
|
67
|
+
console.log(`Received:`, tamaguiConfig);
|
|
68
|
+
throw new Error(`Can't find valid config in ${confPath}`);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
throw err;
|
|
71
|
+
}
|
|
66
72
|
}
|
|
73
|
+
const components = {};
|
|
74
|
+
for (const moduleName of props.components) {
|
|
75
|
+
const exported = require(moduleName);
|
|
76
|
+
for (const Name in exported) {
|
|
77
|
+
const val = exported[Name];
|
|
78
|
+
const staticConfig = val == null ? void 0 : val.staticConfig;
|
|
79
|
+
if (staticConfig) {
|
|
80
|
+
Object.assign(components, { [Name]: { staticConfig } });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
process.env.IS_STATIC = void 0;
|
|
85
|
+
Mod.prototype.require = og;
|
|
86
|
+
(0, import_core_node.createTamagui)(tamaguiConfig);
|
|
87
|
+
loadedTamagui = {
|
|
88
|
+
components,
|
|
89
|
+
tamaguiConfig
|
|
90
|
+
};
|
|
91
|
+
return loadedTamagui;
|
|
92
|
+
} catch (err) {
|
|
93
|
+
throw err;
|
|
94
|
+
} finally {
|
|
95
|
+
unregister();
|
|
67
96
|
}
|
|
68
|
-
const components = {};
|
|
69
|
-
for (const module2 of props.components) {
|
|
70
|
-
const exported = require(module2);
|
|
71
|
-
Object.assign(components, exported);
|
|
72
|
-
}
|
|
73
|
-
process.env.IS_STATIC = void 0;
|
|
74
|
-
Mod.prototype.require = og;
|
|
75
|
-
(0, import_core_node.createTamagui)(tamaguiConfig);
|
|
76
|
-
loadedTamagui = {
|
|
77
|
-
components,
|
|
78
|
-
tamaguiConfig
|
|
79
|
-
};
|
|
80
|
-
return loadedTamagui;
|
|
81
97
|
}
|
|
82
98
|
__name(loadTamagui, "loadTamagui");
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
loadTamagui
|
|
102
|
+
});
|
|
83
103
|
//# sourceMappingURL=loadTamagui.js.map
|
|
@@ -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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAGrB,uBAA8B;AAE9B,IAAI,gBAAqB;AAElB,qBAAqB,OAG1B;AACA,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;
|
|
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;AACxB,UAAM,YAAY,QAAQ,qBAAqB;AAC/C,UAAM,MAAM,QAAQ,kBAAkB;AACtC,UAAM,MAAM,QAAQ,QAAQ;AAC5B,UAAM,KAAK,IAAI,UAAU;AACzB,QAAI,UAAU,UAAU,SAAU,MAAc;AAC9C,UAAI,KAAK,SAAS,MAAM,GAAG;AACzB,eAAO,CAAC;AAAA,MACV;AACA,UAAI,SAAS,0BAA0B,KAAK,WAAW,yBAAyB,GAAG;AACjF,eAAO;AAAA,MACT;AACA,UACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,mCAAmC,GACpD;AACA,eAAO;AAAA,MACT;AACA,UAAI;AACF,eAAO,GAAG,MAAM,MAAM,SAAS;AAAA,MACjC,SAAS,KAAP;AACA,gBAAQ,MAAM,+BAA+B;AAC7C,gBAAQ,IAAI,OAAO,MAAM,IAAI;AAC7B,gBAAQ,IAAI,IAAI,OAAO;AACvB,gBAAQ,IAAI,IAAI,KAAK;AAErB,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAGA,UAAM,MAAM,QAAQ,UAAU;AAC9B,UAAM,gBAAiB,IAAI,cAAc;AAEzC,QAAI,CAAC,iBAAiB,CAAC,cAAc,QAAQ;AAC3C,UAAI;AACF,cAAM,WAA2B,AAAhB,QAAQ,QAAQ;AACjC,gBAAQ,IAAI,aAAa,aAAa;AACtC,cAAM,IAAI,MAAM,8BAA8B,UAAU;AAAA,MAC1D,SAAS,KAAP;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAGA,UAAM,aAAa,CAAC;AACpB,eAAW,cAAc,MAAM,YAAY;AACzC,YAAM,WAAW,QAAQ,UAAU;AACnC,iBAAW,QAAQ,UAAU;AAC3B,cAAM,MAAM,SAAS;AACrB,cAAM,eAAe,2BAAK;AAC1B,YAAI,cAAc;AAChB,iBAAO,OAAO,YAAY,GAAG,OAAO,EAAE,aAAa,EAAE,CAAC;AAAA,QACxD;AAAA,MACF;AAAA,IACF;AAGA,YAAQ,IAAI,YAAY;AACxB,QAAI,UAAU,UAAU;AAGxB,wCAAc,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;AA1HgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,4 +37,8 @@ ${prefix}`);
|
|
|
37
37
|
}
|
|
38
38
|
return lines.map((line, i) => prefix + (i == 0 ? "" : " ") + line.trim()).join("\n");
|
|
39
39
|
}, "logLines");
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
logLines
|
|
43
|
+
});
|
|
40
44
|
//# sourceMappingURL=logLines.js.map
|
|
@@ -98,4 +98,8 @@ function normalizeTernaries(ternaries) {
|
|
|
98
98
|
return ternaryExpression;
|
|
99
99
|
}
|
|
100
100
|
__name(normalizeTernaries, "normalizeTernaries");
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
normalizeTernaries
|
|
104
|
+
});
|
|
101
105
|
//# sourceMappingURL=normalizeTernaries.js.map
|
|
@@ -97,4 +97,8 @@ function removeUnusedHooks(compFn, shouldPrintDebug) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
__name(removeUnusedHooks, "removeUnusedHooks");
|
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
+
0 && (module.exports = {
|
|
102
|
+
removeUnusedHooks
|
|
103
|
+
});
|
|
100
104
|
//# sourceMappingURL=removeUnusedHooks.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var timer_exports = {};
|
|
20
|
+
__export(timer_exports, {
|
|
21
|
+
timer: () => timer
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(timer_exports);
|
|
24
|
+
const timer = /* @__PURE__ */ __name(() => {
|
|
25
|
+
const start = Date.now();
|
|
26
|
+
let last = start;
|
|
27
|
+
return {
|
|
28
|
+
mark: (name, print = false) => {
|
|
29
|
+
if (print) {
|
|
30
|
+
const took = Date.now() - last;
|
|
31
|
+
last = Date.now();
|
|
32
|
+
console.log(`Time ${name}: ${took}ms`);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
done: (print = false) => {
|
|
36
|
+
if (print) {
|
|
37
|
+
console.log(`Total time: ${Date.now() - start}ms`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}, "timer");
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
timer
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=timer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/extractor/timer.ts"],
|
|
4
|
+
"sourcesContent": ["export const timer = () => {\n const start = Date.now()\n let last = start\n return {\n mark: (name: string, print = false) => {\n if (print) {\n const took = Date.now() - last\n last = Date.now()\n console.log(`Time ${name}: ${took}ms`)\n }\n },\n done: (print = false) => {\n if (print) {\n console.log(`Total time: ${Date.now() - start}ms`)\n }\n },\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,QAAQ,6BAAM;AACzB,QAAM,QAAQ,KAAK,IAAI;AACvB,MAAI,OAAO;AACX,SAAO;AAAA,IACL,MAAM,CAAC,MAAc,QAAQ,UAAU;AACrC,UAAI,OAAO;AACT,cAAM,OAAO,KAAK,IAAI,IAAI;AAC1B,eAAO,KAAK,IAAI;AAChB,gBAAQ,IAAI,QAAQ,SAAS,QAAQ;AAAA,MACvC;AAAA,IACF;AAAA,IACA,MAAM,CAAC,QAAQ,UAAU;AACvB,UAAI,OAAO;AACT,gBAAQ,IAAI,eAAe,KAAK,IAAI,IAAI,SAAS;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AACF,GAjBqB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -31,4 +31,10 @@ __reExport(src_exports, require("./extractor/extractToClassNames"), module.expor
|
|
|
31
31
|
__reExport(src_exports, require("./extractor/extractHelpers"), module.exports);
|
|
32
32
|
__reExport(src_exports, require("./patchReactNativeWeb"), module.exports);
|
|
33
33
|
process.env.TAMAGUI_COMPILE_PROCESS = "1";
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
TamaguiOptions,
|
|
37
|
+
createExtractor,
|
|
38
|
+
literalToAst
|
|
39
|
+
});
|
|
34
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -39,6 +39,8 @@ function patchReactNativeWeb() {
|
|
|
39
39
|
}
|
|
40
40
|
const patches = [
|
|
41
41
|
{
|
|
42
|
+
id: "dom-props",
|
|
43
|
+
filePath: ["modules", "createDOMProps", "index.js"],
|
|
42
44
|
replacee: ` if (dataSet != null) {`,
|
|
43
45
|
replacer: `
|
|
44
46
|
if (props.dataSet && props.dataSet.className) {
|
|
@@ -46,15 +48,25 @@ function patchReactNativeWeb() {
|
|
|
46
48
|
classList = className
|
|
47
49
|
dataSet = dataSetRest
|
|
48
50
|
}
|
|
51
|
+
if (props.dataSet && props.dataSet.id) {
|
|
52
|
+
domProps['id'] = props.dataSet.id
|
|
53
|
+
}
|
|
49
54
|
if (dataSet != null) {`
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "forward-props",
|
|
58
|
+
filePath: ["modules", "forwardedProps", "index.js"],
|
|
59
|
+
replacee: `dataSet: true,`,
|
|
60
|
+
replacer: `id: true, dataSet: true,`
|
|
50
61
|
}
|
|
51
62
|
];
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
for (const
|
|
63
|
+
for (const { filePath, replacee, replacer } of patches) {
|
|
64
|
+
const files = [
|
|
65
|
+
import_path.default.join(rootDir, "dist", ...filePath),
|
|
66
|
+
import_path.default.join(rootDir, "dist", "cjs", ...filePath)
|
|
67
|
+
];
|
|
68
|
+
for (const file of files) {
|
|
69
|
+
const contents = fs.readFileSync(file, "utf-8");
|
|
58
70
|
if (contents.includes(replacer)) {
|
|
59
71
|
continue;
|
|
60
72
|
}
|
|
@@ -66,7 +78,7 @@ function patchReactNativeWeb() {
|
|
|
66
78
|
continue;
|
|
67
79
|
}
|
|
68
80
|
console.log(" | patch " + import_path.default.relative(rootDir, file));
|
|
69
|
-
fs.writeFileSync(file, contents.
|
|
81
|
+
fs.writeFileSync(file, contents.replace(replacee, replacer));
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
const moduleEntry = import_path.default.join(rootDir, "dist", "index.js");
|
|
@@ -148,4 +160,8 @@ exports.useResponderEvents = require('./modules/useResponderEvents')
|
|
|
148
160
|
const fwdProps = require('./modules/forwardedProps')
|
|
149
161
|
exports.forwardedProps = ${forwardedPropsObj}
|
|
150
162
|
`;
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
patchReactNativeWeb
|
|
166
|
+
});
|
|
151
167
|
//# sourceMappingURL=patchReactNativeWeb.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/patchReactNativeWeb.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path'\n\nimport * as fs from 'fs-extra'\n\n// were patching react-native-web so we can use some internal methods\n// we do it this way because we need to rely on webpack or bundler config to determine cjs vs esm\n// so we can't just require it all directly\n// would be nice in the future to be able to eject from react-native-web entirely optionally\n\n// keep it sync\nexport function patchReactNativeWeb() {\n const rootDir = require.resolve('react-native-web').replace(/\\/dist.*/, '')\n const modulePath = path.join(rootDir, 'dist', 'tamagui-exports.js')\n const cjsPath = path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js')\n const shouldPatchExports =\n fs.existsSync(modulePath) &&\n fs.readFileSync(modulePath, 'utf-8') === moduleExports &&\n fs.existsSync(cjsPath) &&\n fs.readFileSync(cjsPath, 'utf-8') === cjsExports\n if (!shouldPatchExports) {\n console.log(' | patch ' + path.relative(rootDir, modulePath))\n console.log(' | patch ' + path.relative(rootDir, cjsPath))\n fs.writeFileSync(modulePath, moduleExports)\n fs.writeFileSync(cjsPath, cjsExports)\n }\n\n // patch to allow className prop\n const patches = [\n {\n replacee: ` if (dataSet != null) {`,\n replacer: `\n if (props.dataSet && props.dataSet.className) {\n const { className, ...dataSetRest } = props.dataSet\n classList = className\n dataSet = dataSetRest\n }\n if (dataSet != null) {`,\n },\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,SAAoB;AAQb,+BAA+B;AACpC,QAAM,UAAU,AAAgB,oCAAoB,QAAQ,YAAY,EAAE;AAC1E,QAAM,aAAa,oBAAK,KAAK,SAAS,QAAQ,oBAAoB;AAClE,QAAM,UAAU,oBAAK,KAAK,SAAS,QAAQ,OAAO,oBAAoB;AACtE,QAAM,qBACJ,GAAG,WAAW,UAAU,KACxB,GAAG,aAAa,YAAY,OAAO,MAAM,iBACzC,GAAG,WAAW,OAAO,KACrB,GAAG,aAAa,SAAS,OAAO,MAAM;AACxC,MAAI,CAAC,oBAAoB;AACvB,YAAQ,IAAI,mBAAmB,oBAAK,SAAS,SAAS,UAAU,CAAC;AACjE,YAAQ,IAAI,mBAAmB,oBAAK,SAAS,SAAS,OAAO,CAAC;AAC9D,OAAG,cAAc,YAAY,aAAa;AAC1C,OAAG,cAAc,SAAS,UAAU;AAAA,EACtC;AAGA,QAAM,UAAU;AAAA,IACd;AAAA,MACE,UAAU;AAAA,MACV,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import path from 'path'\n\nimport * as fs from 'fs-extra'\n\n// were patching react-native-web so we can use some internal methods\n// we do it this way because we need to rely on webpack or bundler config to determine cjs vs esm\n// so we can't just require it all directly\n// would be nice in the future to be able to eject from react-native-web entirely optionally\n\n// keep it sync\nexport function patchReactNativeWeb() {\n const rootDir = require.resolve('react-native-web').replace(/\\/dist.*/, '')\n const modulePath = path.join(rootDir, 'dist', 'tamagui-exports.js')\n const cjsPath = path.join(rootDir, 'dist', 'cjs', 'tamagui-exports.js')\n const shouldPatchExports =\n fs.existsSync(modulePath) &&\n fs.readFileSync(modulePath, 'utf-8') === moduleExports &&\n fs.existsSync(cjsPath) &&\n fs.readFileSync(cjsPath, 'utf-8') === cjsExports\n if (!shouldPatchExports) {\n console.log(' | patch ' + path.relative(rootDir, modulePath))\n console.log(' | patch ' + path.relative(rootDir, cjsPath))\n fs.writeFileSync(modulePath, moduleExports)\n fs.writeFileSync(cjsPath, cjsExports)\n }\n\n // patch to allow className prop\n const patches = [\n {\n id: 'dom-props',\n filePath: ['modules', 'createDOMProps', 'index.js'],\n replacee: ` if (dataSet != null) {`,\n replacer: `\n if (props.dataSet && props.dataSet.className) {\n const { className, ...dataSetRest } = props.dataSet\n classList = className\n dataSet = dataSetRest\n }\n if (props.dataSet && props.dataSet.id) {\n domProps['id'] = props.dataSet.id\n }\n if (dataSet != null) {`,\n },\n {\n id: 'forward-props',\n filePath: ['modules', 'forwardedProps', 'index.js'],\n replacee: `dataSet: true,`,\n replacer: `id: true, dataSet: true,`,\n },\n ]\n\n for (const { filePath, replacee, replacer } of patches) {\n const files = [\n path.join(rootDir, 'dist', ...filePath),\n path.join(rootDir, 'dist', 'cjs', ...filePath),\n ]\n for (const file of files) {\n const contents = fs.readFileSync(file, 'utf-8')\n if (contents.includes(replacer)) {\n continue\n }\n if (!contents.includes(replacee)) {\n console.warn(\n `\u26A0\uFE0F Error: couldn't apply className patch! Maybe using incompatible react-native-web version.`,\n {\n replacee,\n contents,\n }\n )\n continue\n }\n console.log(' | patch ' + path.relative(rootDir, file))\n fs.writeFileSync(file, contents.replace(replacee, replacer))\n }\n }\n\n // if entry files not patched, patch them:\n const moduleEntry = path.join(rootDir, 'dist', 'index.js')\n const moduleEntrySrc = fs.readFileSync(moduleEntry, 'utf-8')\n if (!moduleEntrySrc.includes('// tamagui-patch-v4')) {\n fs.writeFileSync(\n moduleEntry,\n `${removePatch(moduleEntrySrc)}\n\n// tamagui-patch-v4\nimport * as TExports from './tamagui-exports'\nexport const TamaguiExports = TExports\n// tamagui-patch-end\n`\n )\n }\n const cjsEntry = path.join(rootDir, 'dist', 'cjs', 'index.js')\n const cjsEntrySrc = fs.readFileSync(cjsEntry, 'utf-8')\n if (!cjsEntrySrc.includes('// tamagui-patch-v4')) {\n fs.writeFileSync(\n cjsEntry,\n `${removePatch(cjsEntrySrc)}\n\n// tamagui-patch-v4\nexports.TamaguiExports = _interopRequireDefault(require(\"./tamagui-exports\"));\n// tamagui-patch-end\n`\n )\n }\n}\n\nfunction removePatch(source: string) {\n return source.replace(/\\/\\/ tamagui-patch([.\\s\\S]*)/g, '')\n}\n\n// view exports/View.ts\nconst forwardedPropsObj = `{\n ...fwdProps.defaultProps,\n ...fwdProps.accessibilityProps,\n ...fwdProps.clickProps,\n ...fwdProps.focusProps,\n ...fwdProps.keyboardProps,\n ...fwdProps.mouseProps,\n ...fwdProps.touchProps,\n ...fwdProps.styleProps,\n href: true,\n lang: true,\n onScroll: true,\n onWheel: true,\n pointerEvents: true\n}\n`\n\nconst moduleExports = `\nexport { atomic } from './exports/StyleSheet/compile'\nexport { default as createCompileableStyle } from './exports/StyleSheet/createCompileableStyle'\nexport { default as createReactDOMStyle } from './exports/StyleSheet/createReactDOMStyle'\nexport { default as i18Style } from './exports/StyleSheet/i18nStyle'\nexport { default as createDOMProps } from './modules/createDOMProps'\nexport { default as AccessibilityUtil } from './modules/AccessibilityUtil'\nexport { default as createElement } from './exports/createElement'\nexport { default as css } from './exports/StyleSheet/css'\nexport { default as TextAncestorContext } from './exports/Text/TextAncestorContext'\nexport { default as pick } from './modules/pick'\nexport { default as useElementLayout } from './modules/useElementLayout'\nexport { default as useMergeRefs } from './modules/useMergeRefs'\nexport { default as usePlatformMethods } from './modules/usePlatformMethods'\nexport { default as useResponderEvents } from './modules/useResponderEvents'\nimport * as fwdProps from './modules/forwardedProps'\nexport const forwardedProps = ${forwardedPropsObj}\n`\n\nconst cjsExports = `\nexports.atomic = require('./exports/StyleSheet/compile').atomic\nexports.createCompileableStyle = require('./exports/StyleSheet/createCompileableStyle')\nexports.createReactDOMStyle = require('./exports/StyleSheet/createReactDOMStyle')\nexports.i18Style = require('./exports/StyleSheet/i18nStyle')\nexports.createDOMProps = require('./modules/createDOMProps')\nexports.AccessibilityUtil = require('./modules/AccessibilityUtil')\nexports.createElement = require('./exports/createElement')\nexports.css = require('./exports/StyleSheet/css')\nexports.TextAncestorContext = require('./exports/Text/TextAncestorContext')\nexports.pick = require('./modules/pick')\nexports.useElementLayout = require('./modules/useElementLayout')\nexports.useMergeRefs = require('./modules/useMergeRefs')\nexports.usePlatformMethods = require('./modules/usePlatformMethods')\nexports.useResponderEvents = require('./modules/useResponderEvents')\nconst fwdProps = require('./modules/forwardedProps')\nexports.forwardedProps = ${forwardedPropsObj}\n`\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,SAAoB;AAQb,+BAA+B;AACpC,QAAM,UAAU,AAAgB,oCAAoB,QAAQ,YAAY,EAAE;AAC1E,QAAM,aAAa,oBAAK,KAAK,SAAS,QAAQ,oBAAoB;AAClE,QAAM,UAAU,oBAAK,KAAK,SAAS,QAAQ,OAAO,oBAAoB;AACtE,QAAM,qBACJ,GAAG,WAAW,UAAU,KACxB,GAAG,aAAa,YAAY,OAAO,MAAM,iBACzC,GAAG,WAAW,OAAO,KACrB,GAAG,aAAa,SAAS,OAAO,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e,SAAS,qBAAqB,GAAG;AACnD,OAAG,cACD,aACA,GAAG,YAAY,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAO/B;AAAA,EACF;AACA,QAAM,WAAW,oBAAK,KAAK,SAAS,QAAQ,OAAO,UAAU;AAC7D,QAAM,cAAc,GAAG,aAAa,UAAU,OAAO;AACrD,MAAI,CAAC,YAAY,SAAS,qBAAqB,GAAG;AAChD,OAAG,cACD,UACA,GAAG,YAAY,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,CAM5B;AAAA,EACF;AACF;AA9FgB;AAgGhB,qBAAqB,QAAgB;AACnC,SAAO,OAAO,QAAQ,iCAAiC,EAAE;AAC3D;AAFS;AAKT,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB1B,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAgBU;AAAA;AAGhC,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAgBQ;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/babelParse.ts"],
|
|
4
|
-
"sourcesContent": ["import * as babelParser from '@babel/parser'\n\nexport const parserOptions: babelParser.ParserOptions = Object.freeze({\n plugins: [\n 'asyncGenerators',\n 'classProperties',\n 'dynamicImport',\n 'functionBind',\n 'jsx',\n 'numericSeparator',\n 'objectRestSpread',\n 'optionalCatchBinding',\n 'decorators-legacy',\n 'typescript',\n 'optionalChaining',\n 'nullishCoalescingOperator',\n
|
|
5
|
-
"mappings": ";;AAAA;AAEO,MAAM,gBAA2C,OAAO,OAAO;AAAA,EACpE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as babelParser from '@babel/parser'\n\nexport const parserOptions: babelParser.ParserOptions = Object.freeze({\n plugins: [\n 'asyncGenerators',\n 'classProperties',\n 'dynamicImport',\n 'functionBind',\n 'jsx',\n 'numericSeparator',\n 'objectRestSpread',\n 'optionalCatchBinding',\n 'decorators-legacy',\n 'typescript',\n 'optionalChaining',\n 'nullishCoalescingOperator',\n ],\n sourceType: 'module',\n})\n\nconst parser = babelParser.parse.bind(babelParser)\n\nexport function babelParse(code: string | Buffer): any {\n return parser(code.toString(), parserOptions)\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEO,MAAM,gBAA2C,OAAO,OAAO;AAAA,EACpE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AACd,CAAC;AAED,MAAM,SAAS,YAAY,MAAM,KAAK,WAAW;AAE1C,oBAAoB,MAA4B;AACrD,SAAO,OAAO,KAAK,SAAS,GAAG,aAAa;AAC9C;AAFgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|