@hanzogui/static 8.3.0 → 8.3.2
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/check-dep-versions.js +438 -0
- package/dist/cjs/check-dep-versions.js.map +1 -0
- package/dist/cjs/checkDeps.js +343 -0
- package/dist/cjs/checkDeps.js.map +1 -0
- package/dist/cjs/constants.js +13 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/exports.js +27 -0
- package/dist/cjs/exports.js.map +1 -0
- package/dist/cjs/extractor/accessSafe.js +17 -0
- package/dist/cjs/extractor/accessSafe.js.map +1 -0
- package/dist/cjs/extractor/babelParse.js +27 -0
- package/dist/cjs/extractor/babelParse.js.map +1 -0
- package/dist/cjs/extractor/buildClassName.js +65 -0
- package/dist/cjs/extractor/buildClassName.js.map +1 -0
- package/dist/cjs/extractor/bundle.js +257 -0
- package/dist/cjs/extractor/bundle.js.map +1 -0
- package/dist/cjs/extractor/bundleConfig.js +794 -0
- package/dist/cjs/extractor/bundleConfig.js.map +1 -0
- package/dist/cjs/extractor/concatClassName.js +101 -0
- package/dist/cjs/extractor/concatClassName.js.map +1 -0
- package/dist/cjs/extractor/createEvaluator.js +56 -0
- package/dist/cjs/extractor/createEvaluator.js.map +1 -0
- package/dist/cjs/extractor/createExtractor.js +2285 -0
- package/dist/cjs/extractor/createExtractor.js.map +1 -0
- package/dist/cjs/extractor/createLogger.js +34 -0
- package/dist/cjs/extractor/createLogger.js.map +1 -0
- package/dist/cjs/extractor/detectModuleFormat.js +41 -0
- package/dist/cjs/extractor/detectModuleFormat.js.map +1 -0
- package/dist/cjs/extractor/ensureImportingConcat.js +23 -0
- package/dist/cjs/extractor/ensureImportingConcat.js.map +1 -0
- package/dist/cjs/extractor/errors.js +7 -0
- package/dist/cjs/extractor/errors.js.map +1 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.js +43 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.js.map +1 -0
- package/dist/cjs/extractor/esbuildTsconfigPaths.js +68 -0
- package/dist/cjs/extractor/esbuildTsconfigPaths.js.map +1 -0
- package/dist/cjs/extractor/evaluateAstNode.js +107 -0
- package/dist/cjs/extractor/evaluateAstNode.js.map +1 -0
- package/dist/cjs/extractor/extractHelpers.js +183 -0
- package/dist/cjs/extractor/extractHelpers.js.map +1 -0
- package/dist/cjs/extractor/extractMediaStyle.js +143 -0
- package/dist/cjs/extractor/extractMediaStyle.js.map +1 -0
- package/dist/cjs/extractor/extractToClassNames.js +541 -0
- package/dist/cjs/extractor/extractToClassNames.js.map +1 -0
- package/dist/cjs/extractor/extractToNative.js +404 -0
- package/dist/cjs/extractor/extractToNative.js.map +1 -0
- package/dist/cjs/extractor/extractablePath.js +89 -0
- package/dist/cjs/extractor/extractablePath.js.map +1 -0
- package/dist/cjs/extractor/findTopmostFunction.js +17 -0
- package/dist/cjs/extractor/findTopmostFunction.js.map +1 -0
- package/dist/cjs/extractor/generatedUid.js +35 -0
- package/dist/cjs/extractor/generatedUid.js.map +1 -0
- package/dist/cjs/extractor/getGuiConfigPathFromOptionsConfig.js +21 -0
- package/dist/cjs/extractor/getGuiConfigPathFromOptionsConfig.js.map +1 -0
- package/dist/cjs/extractor/getPrefixLogs.js +9 -0
- package/dist/cjs/extractor/getPrefixLogs.js.map +1 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js +75 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +1 -0
- package/dist/cjs/extractor/getSourceModule.js +81 -0
- package/dist/cjs/extractor/getSourceModule.js.map +1 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js +212 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +1 -0
- package/dist/cjs/extractor/hasTopLevelAwait.js +29 -0
- package/dist/cjs/extractor/hasTopLevelAwait.js.map +1 -0
- package/dist/cjs/extractor/hoistClassNames.js +47 -0
- package/dist/cjs/extractor/hoistClassNames.js.map +1 -0
- package/dist/cjs/extractor/literalToAst.js +83 -0
- package/dist/cjs/extractor/literalToAst.js.map +1 -0
- package/dist/cjs/extractor/loadFile.js +24 -0
- package/dist/cjs/extractor/loadFile.js.map +1 -0
- package/dist/cjs/extractor/loadGui.js +414 -0
- package/dist/cjs/extractor/loadGui.js.map +1 -0
- package/dist/cjs/extractor/logLines.js +20 -0
- package/dist/cjs/extractor/logLines.js.map +1 -0
- package/dist/cjs/extractor/normalizeTernaries.js +60 -0
- package/dist/cjs/extractor/normalizeTernaries.js.map +1 -0
- package/dist/cjs/extractor/propsToFontFamilyCache.js +20 -0
- package/dist/cjs/extractor/propsToFontFamilyCache.js.map +1 -0
- package/dist/cjs/extractor/regenerateConfig.js +151 -0
- package/dist/cjs/extractor/regenerateConfig.js.map +1 -0
- package/dist/cjs/extractor/removeUnusedHooks.js +84 -0
- package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -0
- package/dist/cjs/extractor/timer.js +30 -0
- package/dist/cjs/extractor/timer.js.map +1 -0
- package/dist/cjs/extractor/validHTMLAttributes.js +56 -0
- package/dist/cjs/extractor/validHTMLAttributes.js.map +1 -0
- package/dist/cjs/extractor/watchGuiConfig.js +56 -0
- package/dist/cjs/extractor/watchGuiConfig.js.map +1 -0
- package/dist/cjs/getPragmaOptions.js +52 -0
- package/dist/cjs/getPragmaOptions.js.map +1 -0
- package/dist/cjs/helpers/memoize.js +24 -0
- package/dist/cjs/helpers/memoize.js.map +1 -0
- package/dist/cjs/helpers/nativeEntry.js +87 -0
- package/dist/cjs/helpers/nativeEntry.js.map +1 -0
- package/dist/cjs/helpers/requireGuiCore.js +25 -0
- package/dist/cjs/helpers/requireGuiCore.js.map +1 -0
- package/dist/cjs/here.js +8 -0
- package/dist/cjs/here.js.map +1 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/registerRequire.js +263 -0
- package/dist/cjs/registerRequire.js.map +1 -0
- package/dist/cjs/server.js +41 -0
- package/dist/cjs/server.js.map +1 -0
- package/dist/cjs/setup.js +2 -0
- package/dist/cjs/setup.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/worker.js +95 -0
- package/dist/cjs/worker.js.map +1 -0
- package/dist/esm/check-dep-versions.js +433 -0
- package/dist/esm/check-dep-versions.js.map +1 -0
- package/dist/esm/checkDeps.js +339 -0
- package/dist/esm/checkDeps.js.map +1 -0
- package/dist/esm/constants.js +9 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/exports.js +18 -0
- package/dist/esm/exports.js.map +1 -0
- package/dist/esm/extractor/accessSafe.js +13 -0
- package/dist/esm/extractor/accessSafe.js.map +1 -0
- package/dist/esm/extractor/babelParse.js +22 -0
- package/dist/esm/extractor/babelParse.js.map +1 -0
- package/dist/esm/extractor/buildClassName.js +59 -0
- package/dist/esm/extractor/buildClassName.js.map +1 -0
- package/dist/esm/extractor/bundle.js +252 -0
- package/dist/esm/extractor/bundle.js.map +1 -0
- package/dist/esm/extractor/bundleConfig.js +781 -0
- package/dist/esm/extractor/bundleConfig.js.map +1 -0
- package/dist/esm/extractor/concatClassName.js +98 -0
- package/dist/esm/extractor/concatClassName.js.map +1 -0
- package/dist/esm/extractor/createEvaluator.js +51 -0
- package/dist/esm/extractor/createEvaluator.js.map +1 -0
- package/dist/esm/extractor/createExtractor.js +2281 -0
- package/dist/esm/extractor/createExtractor.js.map +1 -0
- package/dist/esm/extractor/createLogger.js +31 -0
- package/dist/esm/extractor/createLogger.js.map +1 -0
- package/dist/esm/extractor/detectModuleFormat.js +37 -0
- package/dist/esm/extractor/detectModuleFormat.js.map +1 -0
- package/dist/esm/extractor/ensureImportingConcat.js +19 -0
- package/dist/esm/extractor/ensureImportingConcat.js.map +1 -0
- package/dist/esm/extractor/errors.js +3 -0
- package/dist/esm/extractor/errors.js.map +1 -0
- package/dist/esm/extractor/esbuildAliasPlugin.js +39 -0
- package/dist/esm/extractor/esbuildAliasPlugin.js.map +1 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.js +63 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.js.map +1 -0
- package/dist/esm/extractor/evaluateAstNode.js +103 -0
- package/dist/esm/extractor/evaluateAstNode.js.map +1 -0
- package/dist/esm/extractor/extractHelpers.js +166 -0
- package/dist/esm/extractor/extractHelpers.js.map +1 -0
- package/dist/esm/extractor/extractMediaStyle.js +138 -0
- package/dist/esm/extractor/extractMediaStyle.js.map +1 -0
- package/dist/esm/extractor/extractToClassNames.js +537 -0
- package/dist/esm/extractor/extractToClassNames.js.map +1 -0
- package/dist/esm/extractor/extractToNative.js +398 -0
- package/dist/esm/extractor/extractToNative.js.map +1 -0
- package/dist/esm/extractor/extractablePath.js +84 -0
- package/dist/esm/extractor/extractablePath.js.map +1 -0
- package/dist/esm/extractor/findTopmostFunction.js +14 -0
- package/dist/esm/extractor/findTopmostFunction.js.map +1 -0
- package/dist/esm/extractor/generatedUid.js +31 -0
- package/dist/esm/extractor/generatedUid.js.map +1 -0
- package/dist/esm/extractor/getGuiConfigPathFromOptionsConfig.js +18 -0
- package/dist/esm/extractor/getGuiConfigPathFromOptionsConfig.js.map +1 -0
- package/dist/esm/extractor/getPrefixLogs.js +6 -0
- package/dist/esm/extractor/getPrefixLogs.js.map +1 -0
- package/dist/esm/extractor/getPropValueFromAttributes.js +71 -0
- package/dist/esm/extractor/getPropValueFromAttributes.js.map +1 -0
- package/dist/esm/extractor/getSourceModule.js +77 -0
- package/dist/esm/extractor/getSourceModule.js.map +1 -0
- package/dist/esm/extractor/getStaticBindingsForScope.js +207 -0
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +1 -0
- package/dist/esm/extractor/hasTopLevelAwait.js +25 -0
- package/dist/esm/extractor/hasTopLevelAwait.js.map +1 -0
- package/dist/esm/extractor/hoistClassNames.js +43 -0
- package/dist/esm/extractor/hoistClassNames.js.map +1 -0
- package/dist/esm/extractor/literalToAst.js +78 -0
- package/dist/esm/extractor/literalToAst.js.map +1 -0
- package/dist/esm/extractor/loadFile.js +22 -0
- package/dist/esm/extractor/loadFile.js.map +1 -0
- package/dist/esm/extractor/loadGui.js +402 -0
- package/dist/esm/extractor/loadGui.js.map +1 -0
- package/dist/esm/extractor/logLines.js +16 -0
- package/dist/esm/extractor/logLines.js.map +1 -0
- package/dist/esm/extractor/normalizeTernaries.js +56 -0
- package/dist/esm/extractor/normalizeTernaries.js.map +1 -0
- package/dist/esm/extractor/propsToFontFamilyCache.js +15 -0
- package/dist/esm/extractor/propsToFontFamilyCache.js.map +1 -0
- package/dist/esm/extractor/regenerateConfig.js +145 -0
- package/dist/esm/extractor/regenerateConfig.js.map +1 -0
- package/dist/esm/extractor/removeUnusedHooks.js +80 -0
- package/dist/esm/extractor/removeUnusedHooks.js.map +1 -0
- package/dist/esm/extractor/timer.js +26 -0
- package/dist/esm/extractor/timer.js.map +1 -0
- package/dist/esm/extractor/validHTMLAttributes.js +53 -0
- package/dist/esm/extractor/validHTMLAttributes.js.map +1 -0
- package/dist/esm/extractor/watchGuiConfig.js +53 -0
- package/dist/esm/extractor/watchGuiConfig.js.map +1 -0
- package/dist/esm/getPragmaOptions.js +49 -0
- package/dist/esm/getPragmaOptions.js.map +1 -0
- package/dist/esm/helpers/memoize.js +21 -0
- package/dist/esm/helpers/memoize.js.map +1 -0
- package/dist/esm/helpers/nativeEntry.js +82 -0
- package/dist/esm/helpers/nativeEntry.js.map +1 -0
- package/dist/esm/helpers/requireGuiCore.js +22 -0
- package/dist/esm/helpers/requireGuiCore.js.map +1 -0
- package/dist/esm/here.js +7 -0
- package/dist/esm/here.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/registerRequire.js +256 -0
- package/dist/esm/registerRequire.js.map +1 -0
- package/dist/esm/server.js +37 -0
- package/dist/esm/server.js.map +1 -0
- package/dist/esm/setup.js +2 -0
- package/dist/esm/setup.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/worker.js +92 -0
- package/dist/esm/worker.js.map +1 -0
- package/package.json +77 -56
- package/src/check-dep-versions.ts +2 -1
- package/src/checkDeps.ts +1 -1
- package/src/exports.ts +17 -17
- package/src/extractor/babelParse.ts +2 -11
- package/src/extractor/buildClassName.ts +1 -1
- package/src/extractor/bundle.ts +13 -9
- package/src/extractor/bundleConfig.ts +25 -21
- package/src/extractor/createEvaluator.ts +3 -3
- package/src/extractor/createExtractor.ts +59 -77
- package/src/extractor/createLogger.ts +2 -2
- package/src/extractor/esbuildTsconfigPaths.ts +55 -120
- package/src/extractor/evaluateAstNode.ts +2 -2
- package/src/extractor/extractHelpers.ts +3 -3
- package/src/extractor/extractMediaStyle.ts +3 -3
- package/src/extractor/extractToClassNames.ts +12 -12
- package/src/extractor/extractToNative.ts +20 -22
- package/src/extractor/findTopmostFunction.ts +5 -13
- package/src/extractor/getGuiConfigPathFromOptionsConfig.ts +1 -1
- package/src/extractor/getPrefixLogs.ts +1 -1
- package/src/extractor/getPropValueFromAttributes.ts +2 -2
- package/src/extractor/getStaticBindingsForScope.ts +6 -6
- package/src/extractor/hasTopLevelAwait.ts +1 -1
- package/src/extractor/literalToAst.ts +2 -2
- package/src/extractor/loadFile.ts +6 -1
- package/src/extractor/loadGui.ts +16 -12
- package/src/extractor/normalizeTernaries.ts +3 -3
- package/src/extractor/regenerateConfig.ts +10 -6
- package/src/extractor/watchGuiConfig.ts +7 -3
- package/src/helpers/nativeEntry.ts +92 -0
- package/src/helpers/requireGuiCore.ts +8 -3
- package/src/here.cjs.ts +6 -0
- package/src/here.ts +8 -0
- package/src/index.ts +2 -2
- package/src/registerRequire.ts +30 -14
- package/src/server.ts +1 -1
- package/src/types.ts +1 -1
- package/src/worker.ts +7 -7
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/constants.d.ts +1 -1
- package/types/constants.d.ts.map +1 -1
- package/types/exports.d.ts +17 -17
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/buildClassName.d.ts +1 -1
- package/types/extractor/buildClassName.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +66 -66
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +2 -2
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createEvaluator.d.ts +1 -1
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts +4 -4
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/createLogger.d.ts +1 -1
- package/types/extractor/createLogger.d.ts.map +1 -1
- package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -1
- package/types/extractor/esbuildTsconfigPaths.d.ts +4 -9
- package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -1
- package/types/extractor/extractHelpers.d.ts +1 -1
- package/types/extractor/extractHelpers.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +2 -3
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -2
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts +4 -4
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/findTopmostFunction.d.ts +1 -1
- package/types/extractor/findTopmostFunction.d.ts.map +1 -1
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +1 -1
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +1 -1
- package/types/extractor/getPrefixLogs.d.ts +1 -1
- package/types/extractor/getPrefixLogs.d.ts.map +1 -1
- package/types/extractor/loadFile.d.ts +1 -0
- package/types/extractor/loadGui.d.ts +1 -1
- package/types/extractor/loadGui.d.ts.map +1 -1
- package/types/extractor/logLines.d.ts.map +1 -1
- package/types/extractor/normalizeTernaries.d.ts +1 -1
- package/types/extractor/normalizeTernaries.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/timer.d.ts.map +1 -1
- package/types/extractor/validHTMLAttributes.d.ts.map +1 -1
- package/types/extractor/watchGuiConfig.d.ts.map +1 -1
- package/types/getPragmaOptions.d.ts +1 -1
- package/types/helpers/memoize.d.ts +1 -1
- package/types/helpers/memoize.d.ts.map +1 -1
- package/types/helpers/nativeEntry.d.ts +16 -0
- package/types/helpers/nativeEntry.d.ts.map +1 -0
- package/types/helpers/requireGuiCore.d.ts +1 -1
- package/types/helpers/requireGuiCore.d.ts.map +1 -1
- package/types/here.d.ts +3 -0
- package/types/here.d.ts.map +1 -0
- package/types/index.d.ts +2 -2
- package/types/index.d.ts.map +1 -1
- package/types/registerRequire.d.ts +1 -1
- package/types/registerRequire.d.ts.map +1 -1
- package/types/server.d.ts +1 -1
- package/types/server.d.ts.map +1 -1
- package/types/types.d.ts +1 -1
- package/types/types.d.ts.map +1 -1
- package/types/worker.d.ts +4 -4
- package/types/worker.d.ts.map +1 -1
- package/dist/check-dep-versions.cjs +0 -372
- package/dist/checkDeps.cjs +0 -271
- package/dist/constants.cjs +0 -51
- package/dist/exports.cjs +0 -49
- package/dist/extractor/accessSafe.cjs +0 -48
- package/dist/extractor/babelParse.cjs +0 -56
- package/dist/extractor/buildClassName.cjs +0 -86
- package/dist/extractor/bundle.cjs +0 -234
- package/dist/extractor/bundleConfig.cjs +0 -729
- package/dist/extractor/concatClassName.cjs +0 -121
- package/dist/extractor/createEvaluator.cjs +0 -88
- package/dist/extractor/createExtractor.cjs +0 -1935
- package/dist/extractor/createLogger.cjs +0 -50
- package/dist/extractor/detectModuleFormat.cjs +0 -55
- package/dist/extractor/ensureImportingConcat.cjs +0 -54
- package/dist/extractor/errors.cjs +0 -28
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -56
- package/dist/extractor/esbuildTsconfigPaths.cjs +0 -126
- package/dist/extractor/evaluateAstNode.cjs +0 -128
- package/dist/extractor/extractHelpers.cjs +0 -182
- package/dist/extractor/extractMediaStyle.cjs +0 -169
- package/dist/extractor/extractToClassNames.cjs +0 -476
- package/dist/extractor/extractToNative.cjs +0 -369
- package/dist/extractor/extractablePath.cjs +0 -51
- package/dist/extractor/findTopmostFunction.cjs +0 -43
- package/dist/extractor/generatedUid.cjs +0 -58
- package/dist/extractor/getGuiConfigPathFromOptionsConfig.cjs +0 -41
- package/dist/extractor/getPrefixLogs.cjs +0 -31
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -85
- package/dist/extractor/getSourceModule.cjs +0 -100
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -213
- package/dist/extractor/hasTopLevelAwait.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs +0 -76
- package/dist/extractor/literalToAst.cjs +0 -109
- package/dist/extractor/loadFile.cjs +0 -17
- package/dist/extractor/loadGui.cjs +0 -373
- package/dist/extractor/logLines.cjs +0 -43
- package/dist/extractor/normalizeTernaries.cjs +0 -95
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -42
- package/dist/extractor/regenerateConfig.cjs +0 -178
- package/dist/extractor/removeUnusedHooks.cjs +0 -108
- package/dist/extractor/timer.cjs +0 -52
- package/dist/extractor/validHTMLAttributes.cjs +0 -79
- package/dist/extractor/watchGuiConfig.cjs +0 -70
- package/dist/getPragmaOptions.cjs +0 -73
- package/dist/helpers/memoize.cjs +0 -45
- package/dist/helpers/requireGuiCore.cjs +0 -40
- package/dist/index.cjs +0 -42
- package/dist/registerRequire.cjs +0 -209
- package/dist/server.cjs +0 -82
- package/dist/setup.cjs +0 -0
- package/dist/types.cjs +0 -18
- package/dist/worker.cjs +0 -111
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
34
|
-
var extractMediaStyle_exports = {};
|
|
35
|
-
__export(extractMediaStyle_exports, {
|
|
36
|
-
extractMediaStyle: () => extractMediaStyle,
|
|
37
|
-
isValidMediaCall: () => isValidMediaCall
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(extractMediaStyle_exports);
|
|
40
|
-
var t = __toESM(require("@babel/types"));
|
|
41
|
-
var core = __toESM(require("@hanzogui/core"));
|
|
42
|
-
var import_requireGuiCore = require("../helpers/requireGuiCore.cjs");
|
|
43
|
-
var import_extractHelpers = require("./extractHelpers.cjs");
|
|
44
|
-
function extractMediaStyle(props, ternary, jsxPath, hanzoguiConfig, sourcePath, importance = 0, shouldPrintDebug = false) {
|
|
45
|
-
const {
|
|
46
|
-
getCSSStylesAtomic
|
|
47
|
-
} = (0, import_requireGuiCore.requireGuiCore)("web");
|
|
48
|
-
const mt = getMediaQueryTernary(props, ternary, jsxPath, sourcePath);
|
|
49
|
-
if (!mt) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
const {
|
|
53
|
-
key
|
|
54
|
-
} = mt;
|
|
55
|
-
const mq = hanzoguiConfig.media[key];
|
|
56
|
-
if (!mq) {
|
|
57
|
-
console.error(`Media query "${key}" not found: ${Object.keys(hanzoguiConfig.media)}`);
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
const getStyleObj = (styleObj, negate = false) => {
|
|
61
|
-
return styleObj ? {
|
|
62
|
-
styleObj,
|
|
63
|
-
negate
|
|
64
|
-
} : null;
|
|
65
|
-
};
|
|
66
|
-
const styleOpts = [getStyleObj(ternary.consequent, false), getStyleObj(ternary.alternate, true)].filter(import_extractHelpers.isPresent);
|
|
67
|
-
if (shouldPrintDebug && !styleOpts.length) {
|
|
68
|
-
console.info(" media query, no styles?");
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const mediaKeys = Object.keys(hanzoguiConfig.media);
|
|
72
|
-
const mediaKeyPrecendence = mediaKeys.reduce((acc, cur, i) => {
|
|
73
|
-
acc[cur] = new Array(importance + 1).fill(":root").join("");
|
|
74
|
-
return acc;
|
|
75
|
-
}, {});
|
|
76
|
-
let mediaStyles = [];
|
|
77
|
-
for (const {
|
|
78
|
-
styleObj,
|
|
79
|
-
negate
|
|
80
|
-
} of styleOpts) {
|
|
81
|
-
const styles = getCSSStylesAtomic(styleObj);
|
|
82
|
-
const singleMediaStyles = styles.map(style => {
|
|
83
|
-
const mediaStyle = core.createMediaStyle(style, key, hanzoguiConfig.media, true, negate);
|
|
84
|
-
const className = `.${mediaStyle[core.StyleObjectIdentifier]}`;
|
|
85
|
-
return {
|
|
86
|
-
...mediaStyle,
|
|
87
|
-
className
|
|
88
|
-
};
|
|
89
|
-
});
|
|
90
|
-
if (shouldPrintDebug === "verbose") {
|
|
91
|
-
console.info(" media styles:", importance, styleObj, singleMediaStyles.map(x => x[core.StyleObjectIdentifier]).join(", "));
|
|
92
|
-
}
|
|
93
|
-
mediaStyles = [...mediaStyles, ...singleMediaStyles];
|
|
94
|
-
}
|
|
95
|
-
ternary.remove();
|
|
96
|
-
return {
|
|
97
|
-
mediaStyles,
|
|
98
|
-
ternaryWithoutMedia: mt.ternaryWithoutMedia
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function getMediaQueryTernary(props, ternary, jsxPath, sourcePath) {
|
|
102
|
-
if (t.isLogicalExpression(ternary.test) && ternary.test.operator === "&&") {
|
|
103
|
-
const mediaLeft = getMediaInfoFromExpression(props, ternary.test.left, jsxPath, sourcePath, ternary.inlineMediaQuery);
|
|
104
|
-
if (mediaLeft) {
|
|
105
|
-
return {
|
|
106
|
-
...mediaLeft,
|
|
107
|
-
ternaryWithoutMedia: {
|
|
108
|
-
...ternary,
|
|
109
|
-
test: ternary.test.right
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const result = getMediaInfoFromExpression(props, ternary.test, jsxPath, sourcePath, ternary.inlineMediaQuery);
|
|
115
|
-
if (result) {
|
|
116
|
-
return {
|
|
117
|
-
...result,
|
|
118
|
-
ternaryWithoutMedia: null
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
function getMediaInfoFromExpression(props, test, jsxPath, sourcePath, inlineMediaQuery) {
|
|
124
|
-
if (inlineMediaQuery) {
|
|
125
|
-
return {
|
|
126
|
-
key: inlineMediaQuery,
|
|
127
|
-
bindingName: inlineMediaQuery
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
if (t.isMemberExpression(test) && t.isIdentifier(test.object) && t.isIdentifier(test.property)) {
|
|
131
|
-
const name = test.object["name"];
|
|
132
|
-
const key = test.property["name"];
|
|
133
|
-
const bindings = jsxPath.scope.getAllBindings();
|
|
134
|
-
const binding = bindings[name];
|
|
135
|
-
if (!binding) return false;
|
|
136
|
-
const bindingNode = binding.path?.node;
|
|
137
|
-
if (!t.isVariableDeclarator(bindingNode) || !bindingNode.init) return false;
|
|
138
|
-
if (!isValidMediaCall(props, jsxPath, bindingNode.init, sourcePath)) return false;
|
|
139
|
-
return {
|
|
140
|
-
key,
|
|
141
|
-
bindingName: name
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
if (t.isIdentifier(test)) {
|
|
145
|
-
const key = test.name;
|
|
146
|
-
const node = jsxPath.scope.getBinding(test.name)?.path?.node;
|
|
147
|
-
if (!t.isVariableDeclarator(node)) return false;
|
|
148
|
-
if (!node.init || !isValidMediaCall(props, jsxPath, node.init, sourcePath)) return false;
|
|
149
|
-
return {
|
|
150
|
-
key,
|
|
151
|
-
bindingName: key
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
function isValidMediaCall(props, jsxPath, init, sourcePath) {
|
|
157
|
-
if (!init || !t.isCallExpression(init)) return false;
|
|
158
|
-
if (!t.isIdentifier(init.callee)) return false;
|
|
159
|
-
if (init.callee.name !== "useMedia") return false;
|
|
160
|
-
const bindings = jsxPath.scope.getAllBindings();
|
|
161
|
-
const mediaBinding = bindings["useMedia"];
|
|
162
|
-
if (!mediaBinding) return false;
|
|
163
|
-
const useMediaImport = mediaBinding.path.parent;
|
|
164
|
-
if (!t.isImportDeclaration(useMediaImport)) return false;
|
|
165
|
-
if (!(0, import_extractHelpers.isValidImport)(props, sourcePath)) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
@@ -1,476 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
34
|
-
var extractToClassNames_exports = {};
|
|
35
|
-
__export(extractToClassNames_exports, {
|
|
36
|
-
extractToClassNames: () => extractToClassNames
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(extractToClassNames_exports);
|
|
39
|
-
var import_generator = __toESM(require("@babel/generator"));
|
|
40
|
-
var t = __toESM(require("@babel/types"));
|
|
41
|
-
var import_web = require("@hanzogui/web");
|
|
42
|
-
var path = __toESM(require("node:path"));
|
|
43
|
-
var util = __toESM(require("node:util"));
|
|
44
|
-
var import_requireGuiCore = require("../helpers/requireGuiCore.cjs");
|
|
45
|
-
var import_babelParse = require("./babelParse.cjs");
|
|
46
|
-
var import_extractablePath = require("./extractablePath.cjs");
|
|
47
|
-
var import_createLogger = require("./createLogger.cjs");
|
|
48
|
-
var import_extractMediaStyle = require("./extractMediaStyle.cjs");
|
|
49
|
-
var import_normalizeTernaries = require("./normalizeTernaries.cjs");
|
|
50
|
-
var import_propsToFontFamilyCache = require("./propsToFontFamilyCache.cjs");
|
|
51
|
-
var import_timer = require("./timer.cjs");
|
|
52
|
-
var import_errors = require("./errors.cjs");
|
|
53
|
-
var import_concatClassName = require("./concatClassName.cjs");
|
|
54
|
-
const remove = () => {};
|
|
55
|
-
const spaceString = t.stringLiteral(" ");
|
|
56
|
-
async function extractToClassNames({
|
|
57
|
-
extractor,
|
|
58
|
-
source,
|
|
59
|
-
sourcePath = "",
|
|
60
|
-
options,
|
|
61
|
-
shouldPrintDebug
|
|
62
|
-
}) {
|
|
63
|
-
const tm = (0, import_timer.timer)();
|
|
64
|
-
const {
|
|
65
|
-
getCSSStylesAtomic,
|
|
66
|
-
createMediaStyle
|
|
67
|
-
} = (0, import_requireGuiCore.requireGuiCore)("web");
|
|
68
|
-
if (!(0, import_extractablePath.isExtractable)(sourcePath, options.extractPackages)) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
if (shouldPrintDebug) {
|
|
72
|
-
console.warn(`--- ${sourcePath} ---
|
|
73
|
-
|
|
74
|
-
`);
|
|
75
|
-
}
|
|
76
|
-
if (typeof source !== "string") {
|
|
77
|
-
throw new Error("`source` must be a string of javascript");
|
|
78
|
-
}
|
|
79
|
-
if (!path.isAbsolute(sourcePath)) {
|
|
80
|
-
throw new Error("`sourcePath` must be an absolute path to a .js file, got: " + sourcePath);
|
|
81
|
-
}
|
|
82
|
-
if (!/.[tj]sx?$/i.test(sourcePath || "")) {
|
|
83
|
-
console.warn(`${sourcePath.slice(0, 100)} - bad filename.`);
|
|
84
|
-
}
|
|
85
|
-
if (!options.disableExtraction && !options["_disableLoadGui"]) {
|
|
86
|
-
await extractor.loadGui(options);
|
|
87
|
-
}
|
|
88
|
-
const printLog = (0, import_createLogger.createLogger)(sourcePath, options);
|
|
89
|
-
let ast;
|
|
90
|
-
try {
|
|
91
|
-
ast = (0, import_babelParse.babelParse)(source, sourcePath);
|
|
92
|
-
} catch (err) {
|
|
93
|
-
console.error("babel parse error:", sourcePath.slice(0, 100));
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
96
|
-
tm.mark(`babel-parse`, shouldPrintDebug === "verbose");
|
|
97
|
-
const cssMap = /* @__PURE__ */new Map();
|
|
98
|
-
const hanzoguiConfig = extractor.getGui();
|
|
99
|
-
const res = await extractor.parse(ast, {
|
|
100
|
-
shouldPrintDebug,
|
|
101
|
-
...options,
|
|
102
|
-
platform: "web",
|
|
103
|
-
sourcePath,
|
|
104
|
-
extractStyledDefinitions: true,
|
|
105
|
-
onStyledDefinitionRule(identifier, rules) {
|
|
106
|
-
const css = rules.join("\n");
|
|
107
|
-
if (shouldPrintDebug) {
|
|
108
|
-
console.info(`adding styled() rule: .${identifier} ${css}`);
|
|
109
|
-
}
|
|
110
|
-
cssMap.set(`.${identifier}`, {
|
|
111
|
-
css,
|
|
112
|
-
commentTexts: []
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
getFlattenedNode: ({
|
|
116
|
-
tag
|
|
117
|
-
}) => {
|
|
118
|
-
return tag;
|
|
119
|
-
},
|
|
120
|
-
onExtractTag: ({
|
|
121
|
-
parserProps,
|
|
122
|
-
attrs,
|
|
123
|
-
node,
|
|
124
|
-
attemptEval,
|
|
125
|
-
jsxPath,
|
|
126
|
-
originalNodeName,
|
|
127
|
-
filePath,
|
|
128
|
-
lineNumbers,
|
|
129
|
-
staticConfig
|
|
130
|
-
}) => {
|
|
131
|
-
if (staticConfig.acceptsClassName === false) {
|
|
132
|
-
throw new import_errors.BailOptimizationError();
|
|
133
|
-
}
|
|
134
|
-
const finalAttrs = [];
|
|
135
|
-
let mergeForwardBaseStyle = null;
|
|
136
|
-
let attrClassName = null;
|
|
137
|
-
let baseFontFamily = "";
|
|
138
|
-
let mediaStylesSeen = 1;
|
|
139
|
-
const comment = util.format("/* %s:%s (%s) */", filePath, lineNumbers, originalNodeName);
|
|
140
|
-
let staticGroupName = null;
|
|
141
|
-
for (const attr of jsxPath.node.openingElement.attributes) {
|
|
142
|
-
if (!t.isJSXAttribute(attr) || !t.isJSXIdentifier(attr.name)) continue;
|
|
143
|
-
if (attr.name.name !== "group") continue;
|
|
144
|
-
if (t.isStringLiteral(attr.value)) {
|
|
145
|
-
staticGroupName = attr.value.value;
|
|
146
|
-
} else if (t.isJSXExpressionContainer(attr.value) && t.isStringLiteral(attr.value.expression)) {
|
|
147
|
-
staticGroupName = attr.value.expression.value;
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
if (staticGroupName) {
|
|
152
|
-
const containerIdentifier = `t_group_${staticGroupName}`;
|
|
153
|
-
const containerType = hanzoguiConfig.settings?.webContainerType || "inline-size";
|
|
154
|
-
const containerSelector = `.${containerIdentifier}`;
|
|
155
|
-
if (!cssMap.has(containerSelector)) {
|
|
156
|
-
cssMap.set(containerSelector, {
|
|
157
|
-
css: `${containerSelector} { container-name: ${staticGroupName}; container-type: ${containerType}; }`,
|
|
158
|
-
commentTexts: [comment]
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
cssMap.get(containerSelector).commentTexts.push(comment);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const hasCSSOnlyAnimationDriver = hanzoguiConfig.animations.outputStyle === "css" && !hanzoguiConfig.animationDrivers;
|
|
165
|
-
let elementIsAnimated = false;
|
|
166
|
-
for (const attr of jsxPath.node.openingElement.attributes) {
|
|
167
|
-
if (!t.isJSXAttribute(attr) || !t.isJSXIdentifier(attr.name)) continue;
|
|
168
|
-
const n = attr.name.name;
|
|
169
|
-
if (n === "transition" && hasCSSOnlyAnimationDriver) continue;
|
|
170
|
-
if (n === "animation" || n === "transition" || n === "animateOnly" || n === "animatePresence" || n === "animatedBy" || n === "enterStyle" || n === "exitStyle") {
|
|
171
|
-
elementIsAnimated = true;
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function addStyle(style) {
|
|
176
|
-
const identifier = style[import_web.StyleObjectIdentifier];
|
|
177
|
-
const rules = style[import_web.StyleObjectRules];
|
|
178
|
-
const selector = `.${identifier}`;
|
|
179
|
-
if (cssMap.has(selector)) {
|
|
180
|
-
const val = cssMap.get(selector);
|
|
181
|
-
val.commentTexts.push(comment);
|
|
182
|
-
} else if (rules.length) {
|
|
183
|
-
cssMap.set(selector, {
|
|
184
|
-
css: rules.join("\n"),
|
|
185
|
-
commentTexts: [comment]
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
return identifier;
|
|
189
|
-
}
|
|
190
|
-
function addStyles(style) {
|
|
191
|
-
const cssStyles = getCSSStylesAtomic(style);
|
|
192
|
-
const classNames = [];
|
|
193
|
-
for (const style2 of cssStyles) {
|
|
194
|
-
const property = style2[0];
|
|
195
|
-
const mediaName = property.slice(1);
|
|
196
|
-
if (mediaName.startsWith("group-")) {
|
|
197
|
-
if (elementIsAnimated) {
|
|
198
|
-
throw new import_errors.BailOptimizationError();
|
|
199
|
-
}
|
|
200
|
-
const mediaStyle = createMediaStyle(style2, mediaName, extractor.getGui().media, "group", false, mediaStylesSeen);
|
|
201
|
-
const identifier2 = addStyle(mediaStyle);
|
|
202
|
-
classNames.push(identifier2);
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
const mediaTypeMatch = mediaName.match(/^(theme|platform)-/);
|
|
206
|
-
if (mediaTypeMatch) {
|
|
207
|
-
const mediaType = mediaTypeMatch[1];
|
|
208
|
-
if (mediaType === "theme" && elementIsAnimated) {
|
|
209
|
-
throw new import_errors.BailOptimizationError();
|
|
210
|
-
}
|
|
211
|
-
const innerKey = mediaType === "theme" ? mediaName.slice("theme-".length) : mediaName;
|
|
212
|
-
const mediaStyle = createMediaStyle(style2, innerKey, extractor.getGui().media, mediaType, false, mediaStylesSeen);
|
|
213
|
-
const identifier2 = addStyle(mediaStyle);
|
|
214
|
-
classNames.push(identifier2);
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
if (mediaName in hanzoguiConfig.media) {
|
|
218
|
-
const mediaStyle = createMediaStyle(style2, mediaName, extractor.getGui().media, true, false, mediaStylesSeen);
|
|
219
|
-
const identifier2 = addStyle(mediaStyle);
|
|
220
|
-
classNames.push(identifier2);
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
const identifier = addStyle(style2);
|
|
224
|
-
classNames.push(identifier);
|
|
225
|
-
}
|
|
226
|
-
return classNames;
|
|
227
|
-
}
|
|
228
|
-
const onlyTernaries = attrs.flatMap(attr => {
|
|
229
|
-
if (attr.type === "attr") {
|
|
230
|
-
const value = attr.value;
|
|
231
|
-
if (t.isJSXSpreadAttribute(value)) {
|
|
232
|
-
console.error(`Should never happen`);
|
|
233
|
-
return [];
|
|
234
|
-
}
|
|
235
|
-
if (value.name.name === "className") {
|
|
236
|
-
let inner = value.value;
|
|
237
|
-
if (t.isJSXExpressionContainer(inner)) {
|
|
238
|
-
inner = inner.expression;
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
const evaluatedValue = inner ? attemptEval(inner) : null;
|
|
242
|
-
if (typeof evaluatedValue === "string") {
|
|
243
|
-
attrClassName = t.stringLiteral(evaluatedValue);
|
|
244
|
-
}
|
|
245
|
-
} catch (e) {
|
|
246
|
-
if (inner) {
|
|
247
|
-
attrClassName ||= inner;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return [];
|
|
251
|
-
}
|
|
252
|
-
finalAttrs.push(value);
|
|
253
|
-
return [];
|
|
254
|
-
}
|
|
255
|
-
if (attr.type === "style") {
|
|
256
|
-
mergeForwardBaseStyle = (0, import_web.mergeProps)(mergeForwardBaseStyle || {}, attr.value);
|
|
257
|
-
baseFontFamily = (0, import_propsToFontFamilyCache.getFontFamilyNameFromProps)(attr.value) || "";
|
|
258
|
-
return [];
|
|
259
|
-
}
|
|
260
|
-
let ternary = attr.value;
|
|
261
|
-
if (ternary.inlineMediaQuery) {
|
|
262
|
-
const mediaExtraction = (0, import_extractMediaStyle.extractMediaStyle)(parserProps, attr.value, jsxPath, extractor.getGui(), sourcePath || "", mediaStylesSeen++, shouldPrintDebug);
|
|
263
|
-
if (mediaExtraction) {
|
|
264
|
-
if (mediaExtraction.mediaStyles) {
|
|
265
|
-
mergeForwardBaseStyle = (0, import_web.mergeProps)(mergeForwardBaseStyle || {}, {
|
|
266
|
-
[`$${ternary.inlineMediaQuery}`]: attr.value.consequent
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
if (mediaExtraction.ternaryWithoutMedia) {
|
|
270
|
-
ternary = mediaExtraction.ternaryWithoutMedia;
|
|
271
|
-
} else {
|
|
272
|
-
return [];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
let mergedAlternate;
|
|
277
|
-
let mergedConsequent;
|
|
278
|
-
if (ternary.alternate && Object.keys(ternary.alternate).length) {
|
|
279
|
-
mergedAlternate = (0, import_web.mergeProps)(mergeForwardBaseStyle || {}, ternary.alternate || {});
|
|
280
|
-
(0, import_propsToFontFamilyCache.forwardFontFamilyName)(ternary.alternate, mergedAlternate, baseFontFamily);
|
|
281
|
-
}
|
|
282
|
-
if (ternary.consequent && Object.keys(ternary.consequent).length) {
|
|
283
|
-
mergedConsequent = (0, import_web.mergeProps)(mergeForwardBaseStyle || {}, ternary.consequent || {});
|
|
284
|
-
(0, import_propsToFontFamilyCache.forwardFontFamilyName)(ternary.consequent, mergedConsequent, baseFontFamily);
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
...ternary,
|
|
288
|
-
alternate: mergedAlternate,
|
|
289
|
-
consequent: mergedConsequent
|
|
290
|
-
};
|
|
291
|
-
});
|
|
292
|
-
const hasTernaries = Boolean(onlyTernaries.length);
|
|
293
|
-
const baseClassNames = mergeForwardBaseStyle ? addStyles(mergeForwardBaseStyle) : null;
|
|
294
|
-
let baseClassNameStr = !baseClassNames ? "" : baseClassNames.join(" ");
|
|
295
|
-
if (baseFontFamily) {
|
|
296
|
-
baseClassNameStr = `font_${baseFontFamily}${baseClassNameStr ? ` ${baseClassNameStr}` : ""}`;
|
|
297
|
-
}
|
|
298
|
-
if (staticGroupName) {
|
|
299
|
-
baseClassNameStr = `t_group_${staticGroupName}${baseClassNameStr ? ` ${baseClassNameStr}` : ""}`;
|
|
300
|
-
}
|
|
301
|
-
const baseTypeClass = staticConfig.isText ? "is_Text" : "is_View";
|
|
302
|
-
baseClassNameStr = `${baseTypeClass}${baseClassNameStr ? ` ${baseClassNameStr}` : ""}`;
|
|
303
|
-
const componentNameFinal = staticConfig.componentName;
|
|
304
|
-
let base = componentNameFinal && componentNameFinal !== "Text" ? t.stringLiteral(`is_${componentNameFinal}${baseClassNameStr ? ` ${baseClassNameStr}` : ""}`) : t.stringLiteral(baseClassNameStr || "");
|
|
305
|
-
attrClassName = attrClassName;
|
|
306
|
-
const baseClassNameExpression = (() => {
|
|
307
|
-
if (attrClassName) {
|
|
308
|
-
if (t.isStringLiteral(attrClassName)) {
|
|
309
|
-
return t.stringLiteral(base.value ? `${base.value} ${attrClassName.value}` : attrClassName.value);
|
|
310
|
-
} else {
|
|
311
|
-
return t.binaryExpression("+", t.binaryExpression("+", attrClassName, spaceString), base);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return base;
|
|
315
|
-
})();
|
|
316
|
-
const expandedTernaries = [];
|
|
317
|
-
if (onlyTernaries.length) {
|
|
318
|
-
const normalizedTernaries = (0, import_normalizeTernaries.normalizeTernaries)(onlyTernaries);
|
|
319
|
-
for (const ternary of normalizedTernaries) {
|
|
320
|
-
if (!expandedTernaries.length) {
|
|
321
|
-
expandTernary(ternary);
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
const prevTernaries = [...expandedTernaries];
|
|
325
|
-
for (const prev of prevTernaries) {
|
|
326
|
-
expandTernary(ternary, prev);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
function expandTernary(ternary, prev) {
|
|
331
|
-
if (ternary.consequent && Object.keys(ternary.consequent).length) {
|
|
332
|
-
const fontFamily = (0, import_propsToFontFamilyCache.getFontFamilyNameFromProps)(ternary.consequent);
|
|
333
|
-
expandedTernaries.push({
|
|
334
|
-
fontFamily,
|
|
335
|
-
// prevTest && test: merge consequent
|
|
336
|
-
test: prev ? t.logicalExpression("&&", prev.test, ternary.test) : ternary.test,
|
|
337
|
-
consequent: prev ? (0, import_web.mergeProps)(prev.consequent, ternary.consequent) : ternary.consequent,
|
|
338
|
-
remove,
|
|
339
|
-
alternate: null
|
|
340
|
-
});
|
|
341
|
-
if (prev) {
|
|
342
|
-
expandedTernaries.push({
|
|
343
|
-
fontFamily,
|
|
344
|
-
// !prevTest && test: just consequent
|
|
345
|
-
test: t.logicalExpression("&&", t.unaryExpression("!", prev.test), ternary.test),
|
|
346
|
-
consequent: ternary.consequent,
|
|
347
|
-
alternate: null,
|
|
348
|
-
remove
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (ternary.alternate && Object.keys(ternary.alternate).length) {
|
|
353
|
-
const fontFamily = (0, import_propsToFontFamilyCache.getFontFamilyNameFromProps)(ternary.alternate);
|
|
354
|
-
const negated = t.unaryExpression("!", ternary.test);
|
|
355
|
-
expandedTernaries.push({
|
|
356
|
-
fontFamily,
|
|
357
|
-
// prevTest && !test: merge alternate
|
|
358
|
-
test: prev ? t.logicalExpression("&&", prev.test, negated) : negated,
|
|
359
|
-
consequent: prev ? (0, import_web.mergeProps)(prev.alternate, ternary.alternate) : ternary.alternate,
|
|
360
|
-
remove,
|
|
361
|
-
alternate: null
|
|
362
|
-
});
|
|
363
|
-
if (prev) {
|
|
364
|
-
expandedTernaries.push({
|
|
365
|
-
fontFamily,
|
|
366
|
-
test: t.logicalExpression("&&", t.unaryExpression("!", prev.test), ternary.test),
|
|
367
|
-
consequent: ternary.alternate,
|
|
368
|
-
remove,
|
|
369
|
-
alternate: null
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
let ternaryClassNameExpr = null;
|
|
375
|
-
if (hasTernaries) {
|
|
376
|
-
for (const ternary of expandedTernaries) {
|
|
377
|
-
if (!ternary.consequent) continue;
|
|
378
|
-
const classNames = addStyles(ternary.consequent);
|
|
379
|
-
if (ternary.fontFamily) {
|
|
380
|
-
classNames.unshift(`font_${ternary.fontFamily}`);
|
|
381
|
-
}
|
|
382
|
-
const baseString = t.isStringLiteral(baseClassNameExpression) ? baseClassNameExpression.value : "";
|
|
383
|
-
const fullClassNameWithDups = (baseString ? `${baseString} ` : "") + classNames.join(" ");
|
|
384
|
-
const fullClassName = (0, import_concatClassName.concatClassName)(fullClassNameWithDups);
|
|
385
|
-
const classNameLiteral = t.stringLiteral(fullClassName);
|
|
386
|
-
if (!ternaryClassNameExpr) {
|
|
387
|
-
ternaryClassNameExpr = t.conditionalExpression(ternary.test, classNameLiteral, baseClassNameExpression);
|
|
388
|
-
} else {
|
|
389
|
-
ternaryClassNameExpr = t.conditionalExpression(ternary.test, classNameLiteral, ternaryClassNameExpr);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
let finalExpression = ternaryClassNameExpr || baseClassNameExpression || null;
|
|
394
|
-
if (shouldPrintDebug) {
|
|
395
|
-
console.info("attrs", JSON.stringify(attrs, null, 2));
|
|
396
|
-
console.info("expandedTernaries", JSON.stringify(expandedTernaries, null, 2));
|
|
397
|
-
console.info("finalExpression", JSON.stringify(finalExpression, null, 2));
|
|
398
|
-
console.info({
|
|
399
|
-
hasTernaries,
|
|
400
|
-
baseClassNameExpression
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
if (finalExpression) {
|
|
404
|
-
finalExpression = hoistClassNames(jsxPath, finalExpression);
|
|
405
|
-
const classNameProp = t.jsxAttribute(t.jsxIdentifier("className"), t.jsxExpressionContainer(finalExpression));
|
|
406
|
-
finalAttrs.unshift(classNameProp);
|
|
407
|
-
}
|
|
408
|
-
node.attributes = finalAttrs;
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
if (!res || !res.modified && !res.optimized && !res.flattened && !res.styled) {
|
|
412
|
-
if (shouldPrintDebug) {
|
|
413
|
-
console.info("no res or none modified", res);
|
|
414
|
-
}
|
|
415
|
-
return null;
|
|
416
|
-
}
|
|
417
|
-
const styles = Array.from(cssMap.values()).map(x => x.css).join("\n").trim();
|
|
418
|
-
const result = (0, import_generator.default)(ast, {
|
|
419
|
-
concise: false,
|
|
420
|
-
filename: sourcePath,
|
|
421
|
-
// this makes the debug output terrible, and i think sourcemap works already
|
|
422
|
-
retainLines: false,
|
|
423
|
-
sourceFileName: sourcePath,
|
|
424
|
-
sourceMaps: true
|
|
425
|
-
}, source);
|
|
426
|
-
if (shouldPrintDebug) {
|
|
427
|
-
console.info("\n -------- output code ------- \n\n", result.code.split("\n").filter(x => !x.startsWith("//")).join("\n"));
|
|
428
|
-
console.info("\n -------- output style -------- \n\n", styles);
|
|
429
|
-
}
|
|
430
|
-
printLog(res);
|
|
431
|
-
return {
|
|
432
|
-
ast,
|
|
433
|
-
styles,
|
|
434
|
-
js: result.code,
|
|
435
|
-
map: result.map,
|
|
436
|
-
stats: {
|
|
437
|
-
styled: res.styled,
|
|
438
|
-
flattened: res.flattened,
|
|
439
|
-
optimized: res.optimized,
|
|
440
|
-
found: res.found
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
function hoistClassNames(path2, expr) {
|
|
445
|
-
if (t.isStringLiteral(expr)) {
|
|
446
|
-
return hoistClassName(path2, expr.value);
|
|
447
|
-
}
|
|
448
|
-
if (t.isLogicalExpression(expr)) {
|
|
449
|
-
const left = t.isStringLiteral(expr.left) ? hoistClassName(path2, expr.left.value) : expr.left;
|
|
450
|
-
const right = t.isStringLiteral(expr.right) ? hoistClassName(path2, expr.right.value) : hoistClassNames(path2, expr.right);
|
|
451
|
-
return t.logicalExpression(expr.operator, left, right);
|
|
452
|
-
}
|
|
453
|
-
if (t.isConditionalExpression(expr)) {
|
|
454
|
-
const cons = t.isStringLiteral(expr.consequent) ? hoistClassName(path2, expr.consequent.value) : hoistClassNames(path2, expr.consequent);
|
|
455
|
-
const alt = t.isStringLiteral(expr.alternate) ? hoistClassName(path2, expr.alternate.value) : hoistClassNames(path2, expr.alternate);
|
|
456
|
-
return t.conditionalExpression(expr.test, cons, alt);
|
|
457
|
-
}
|
|
458
|
-
return expr;
|
|
459
|
-
}
|
|
460
|
-
function hoistClassName(path2, str) {
|
|
461
|
-
const uid = path2.scope.generateUidIdentifier("cn");
|
|
462
|
-
const parent = path2.findParent(path3 => path3.isProgram());
|
|
463
|
-
if (!parent) throw new Error(`no program?`);
|
|
464
|
-
const variable = t.variableDeclaration("const", [t.variableDeclarator(uid, t.stringLiteral(cleanupClassName(str)))]);
|
|
465
|
-
parent.unshiftContainer("body", variable);
|
|
466
|
-
return uid;
|
|
467
|
-
}
|
|
468
|
-
function cleanupClassName(inStr) {
|
|
469
|
-
const out = /* @__PURE__ */new Set();
|
|
470
|
-
for (const part of inStr.split(" ")) {
|
|
471
|
-
if (!part || part === " ") continue;
|
|
472
|
-
if (part === "font_") continue;
|
|
473
|
-
out.add(part);
|
|
474
|
-
}
|
|
475
|
-
return [...out].join(" ");
|
|
476
|
-
}
|