@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
package/src/exports.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export * from './checkDeps'
|
|
2
|
-
export * from './types'
|
|
3
|
-
export { createExtractor } from './extractor/createExtractor'
|
|
4
|
-
export { literalToAst } from './extractor/literalToAst'
|
|
5
|
-
export * from './constants'
|
|
6
|
-
export * from './extractor/extractablePath'
|
|
7
|
-
export * from './extractor/extractToClassNames'
|
|
8
|
-
export * from './extractor/concatClassName'
|
|
9
|
-
export * from './extractor/extractToNative'
|
|
10
|
-
export * from './extractor/extractHelpers'
|
|
11
|
-
export * from './extractor/loadGui'
|
|
12
|
-
export * from './extractor/watchGuiConfig'
|
|
13
|
-
export * from './extractor/createLogger'
|
|
14
|
-
export * from './registerRequire'
|
|
15
|
-
export { detectModuleFormat, clearFormatCache } from './extractor/detectModuleFormat'
|
|
16
|
-
export { esbundleGuiConfig } from './extractor/bundle'
|
|
17
|
-
export * from './getPragmaOptions'
|
|
1
|
+
export * from './checkDeps.ts'
|
|
2
|
+
export * from './types.ts'
|
|
3
|
+
export { createExtractor } from './extractor/createExtractor.ts'
|
|
4
|
+
export { literalToAst } from './extractor/literalToAst.ts'
|
|
5
|
+
export * from './constants.ts'
|
|
6
|
+
export * from './extractor/extractablePath.ts'
|
|
7
|
+
export * from './extractor/extractToClassNames.ts'
|
|
8
|
+
export * from './extractor/concatClassName.ts'
|
|
9
|
+
export * from './extractor/extractToNative.ts'
|
|
10
|
+
export * from './extractor/extractHelpers.ts'
|
|
11
|
+
export * from './extractor/loadGui.ts'
|
|
12
|
+
export * from './extractor/watchGuiConfig.ts'
|
|
13
|
+
export * from './extractor/createLogger.ts'
|
|
14
|
+
export * from './registerRequire.ts'
|
|
15
|
+
export { detectModuleFormat, clearFormatCache } from './extractor/detectModuleFormat.ts'
|
|
16
|
+
export { esbundleGuiConfig } from './extractor/bundle.ts'
|
|
17
|
+
export * from './getPragmaOptions.ts'
|
|
@@ -2,19 +2,10 @@ import * as babelParser from '@babel/parser'
|
|
|
2
2
|
import type * as t from '@babel/types'
|
|
3
3
|
|
|
4
4
|
const plugins: babelParser.ParserPlugin[] = [
|
|
5
|
-
'asyncGenerators',
|
|
6
|
-
'classProperties',
|
|
7
|
-
'dynamicImport',
|
|
8
5
|
'functionBind',
|
|
9
6
|
'jsx',
|
|
10
|
-
'numericSeparator',
|
|
11
|
-
'objectRestSpread',
|
|
12
|
-
'optionalCatchBinding',
|
|
13
7
|
'decorators-legacy',
|
|
14
8
|
'typescript',
|
|
15
|
-
'optionalChaining',
|
|
16
|
-
'nullishCoalescingOperator',
|
|
17
|
-
'topLevelAwait',
|
|
18
9
|
]
|
|
19
10
|
|
|
20
11
|
export const parserOptions: babelParser.ParserOptions = Object.freeze({
|
|
@@ -27,11 +18,11 @@ const parser = babelParser.parse.bind(babelParser)
|
|
|
27
18
|
export function babelParse(code: string | Buffer, fileName?: string): t.File {
|
|
28
19
|
const codeString = code.toString()
|
|
29
20
|
try {
|
|
30
|
-
return parser(codeString, parserOptions)
|
|
21
|
+
return parser(codeString, parserOptions)
|
|
31
22
|
} catch (err) {
|
|
32
23
|
throw new Error(
|
|
33
24
|
`Error parsing babel: ${err} in ${fileName}, code:\n${codeString}\n ${
|
|
34
|
-
|
|
25
|
+
err instanceof Error ? err.stack : ''
|
|
35
26
|
}`
|
|
36
27
|
)
|
|
37
28
|
}
|
package/src/extractor/bundle.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
2
3
|
import esbuild from 'esbuild'
|
|
3
|
-
import
|
|
4
|
-
import type { GuiPlatform } from '../types'
|
|
5
|
-
import { detectModuleFormat } from './detectModuleFormat'
|
|
6
|
-
import { esbuildAliasPlugin } from './esbuildAliasPlugin'
|
|
7
|
-
import { hasTopLevelAwait } from './hasTopLevelAwait'
|
|
8
|
-
import { resolveWebOrNativeSpecificEntry } from './loadGui'
|
|
9
|
-
import { TsconfigPathsPlugin } from './esbuildTsconfigPaths'
|
|
4
|
+
import FS from 'fs-extra'
|
|
5
|
+
import type { GuiPlatform } from '../types.ts'
|
|
6
|
+
import { detectModuleFormat } from './detectModuleFormat.ts'
|
|
7
|
+
import { esbuildAliasPlugin } from './esbuildAliasPlugin.ts'
|
|
8
|
+
import { hasTopLevelAwait } from './hasTopLevelAwait.ts'
|
|
9
|
+
import { resolveWebOrNativeSpecificEntry } from './loadGui.ts'
|
|
10
|
+
import { TsconfigPathsPlugin } from './esbuildTsconfigPaths.ts'
|
|
11
|
+
import { url } from '../here.ts'
|
|
12
|
+
|
|
13
|
+
const need = createRequire(url)
|
|
10
14
|
|
|
11
15
|
export const esbuildLoaderConfig = {
|
|
12
16
|
'.js': 'jsx',
|
|
@@ -211,7 +215,7 @@ function getESBuildConfig(
|
|
|
211
215
|
{
|
|
212
216
|
name: 'external',
|
|
213
217
|
setup(build) {
|
|
214
|
-
const proxyWormPath =
|
|
218
|
+
const proxyWormPath = need.resolve('@hanzogui/proxy-worm')
|
|
215
219
|
|
|
216
220
|
// only externalize @hanzogui/core and @hanzogui/web - these are provided at runtime
|
|
217
221
|
// other @hanzogui/* packages (like @hanzogui/config/v3) must be bundled in to avoid
|
|
@@ -278,7 +282,7 @@ function detectEntryFormat(entryPoint: string): esbuild.BuildOptions['format'] {
|
|
|
278
282
|
}
|
|
279
283
|
// bare module specifier - check package.json type field
|
|
280
284
|
try {
|
|
281
|
-
const pkgJsonPath =
|
|
285
|
+
const pkgJsonPath = need.resolve(entryPoint + '/package.json')
|
|
282
286
|
const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'))
|
|
283
287
|
return pkg.type === 'module' ? 'esm' : 'cjs'
|
|
284
288
|
} catch {
|
|
@@ -5,20 +5,24 @@ import { createHash } from 'node:crypto'
|
|
|
5
5
|
import { existsSync, readFileSync, unlinkSync } from 'node:fs'
|
|
6
6
|
import { basename, dirname, extname, join, relative, sep } from 'node:path'
|
|
7
7
|
import { pathToFileURL } from 'node:url'
|
|
8
|
+
import { createRequire } from 'node:module'
|
|
9
|
+
import { load, url } from '../here.ts'
|
|
10
|
+
|
|
11
|
+
const need = createRequire(url)
|
|
8
12
|
// @ts-ignore why
|
|
9
13
|
import { Color, colorLog } from '@hanzogui/cli-color'
|
|
10
14
|
import { type StaticConfig, type GuiInternalConfig } from '@hanzogui/web'
|
|
11
15
|
import esbuild from 'esbuild'
|
|
12
|
-
import
|
|
16
|
+
import FS from 'fs-extra'
|
|
13
17
|
import { readFile } from 'node:fs/promises'
|
|
14
|
-
import { registerRequire, setRequireResult } from '../registerRequire'
|
|
15
|
-
import type { GuiOptions } from '../types'
|
|
16
|
-
import { babelParse } from './babelParse'
|
|
17
|
-
import { esbuildLoaderConfig, esbundleGuiConfig } from './bundle'
|
|
18
|
-
import { getGuiConfigPathFromOptionsConfig } from './getGuiConfigPathFromOptionsConfig'
|
|
19
|
-
import { hasTopLevelAwait } from './hasTopLevelAwait'
|
|
20
|
-
import { requireGuiCore } from '../helpers/requireGuiCore'
|
|
21
|
-
import { detectModuleFormat } from './detectModuleFormat'
|
|
18
|
+
import { registerRequire, setRequireResult } from '../registerRequire.ts'
|
|
19
|
+
import type { GuiOptions } from '../types.ts'
|
|
20
|
+
import { babelParse } from './babelParse.ts'
|
|
21
|
+
import { esbuildLoaderConfig, esbundleGuiConfig } from './bundle.ts'
|
|
22
|
+
import { getGuiConfigPathFromOptionsConfig } from './getGuiConfigPathFromOptionsConfig.ts'
|
|
23
|
+
import { hasTopLevelAwait } from './hasTopLevelAwait.ts'
|
|
24
|
+
import { requireGuiCore } from '../helpers/requireGuiCore.ts'
|
|
25
|
+
import { detectModuleFormat } from './detectModuleFormat.ts'
|
|
22
26
|
|
|
23
27
|
// track temp files for cleanup on exit
|
|
24
28
|
const activeTempFiles = new Set<string>()
|
|
@@ -45,10 +49,10 @@ function getEsbuildStdinLoader(filePath: string): esbuild.Loader {
|
|
|
45
49
|
|
|
46
50
|
function resolvePackageEntry(packageName: string, format: 'esm' | 'cjs') {
|
|
47
51
|
if (format === 'cjs') {
|
|
48
|
-
return
|
|
52
|
+
return need.resolve(packageName)
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
const packageJsonPath =
|
|
55
|
+
const packageJsonPath = need.resolve(`${packageName}/package.json`)
|
|
52
56
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
|
|
53
57
|
const packageRoot = dirname(packageJsonPath)
|
|
54
58
|
const exportEntry = packageJson.exports?.['.']
|
|
@@ -63,7 +67,7 @@ function resolvePackageEntry(packageName: string, format: 'esm' | 'cjs') {
|
|
|
63
67
|
return join(packageRoot, esmEntry)
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
return
|
|
70
|
+
return need.resolve(packageName)
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
function cleanupTempFiles() {
|
|
@@ -296,7 +300,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
296
300
|
// detect format per component module
|
|
297
301
|
const componentFormats: Array<'esm' | 'cjs'> = baseComponents.map((mod) => {
|
|
298
302
|
try {
|
|
299
|
-
const pkgJson =
|
|
303
|
+
const pkgJson = need.resolve(mod + '/package.json')
|
|
300
304
|
const pkg = JSON.parse(readFileSync(pkgJson, 'utf-8'))
|
|
301
305
|
return pkg.type === 'module' ? 'esm' : 'cjs'
|
|
302
306
|
} catch {
|
|
@@ -410,13 +414,13 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
410
414
|
// external requires like @hanzogui/config/v3 that are externalized in the bundled CJS
|
|
411
415
|
if (hasBundledOnce) {
|
|
412
416
|
try {
|
|
413
|
-
delete
|
|
417
|
+
delete need.cache[need.resolve(configOutPath)]
|
|
414
418
|
} catch {
|
|
415
419
|
// file may not exist yet
|
|
416
420
|
}
|
|
417
421
|
for (const p of componentOutPaths) {
|
|
418
422
|
try {
|
|
419
|
-
delete
|
|
423
|
+
delete need.cache[need.resolve(p)]
|
|
420
424
|
} catch {
|
|
421
425
|
// file may not exist yet
|
|
422
426
|
}
|
|
@@ -428,9 +432,9 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
428
432
|
let out: any
|
|
429
433
|
if (configFormat === 'esm') {
|
|
430
434
|
// use file:// URL for proper ESM resolution
|
|
431
|
-
out = await
|
|
435
|
+
out = await load(configOutPath)
|
|
432
436
|
} else {
|
|
433
|
-
out =
|
|
437
|
+
out = need(configOutPath)
|
|
434
438
|
}
|
|
435
439
|
|
|
436
440
|
// try and find .config, even if on .default
|
|
@@ -651,9 +655,9 @@ export async function loadComponentsInner(
|
|
|
651
655
|
let moduleResult: any
|
|
652
656
|
if (format === 'esm') {
|
|
653
657
|
// use file:// URL for proper ESM resolution
|
|
654
|
-
moduleResult = await
|
|
658
|
+
moduleResult = await load(loadModule)
|
|
655
659
|
} else {
|
|
656
|
-
moduleResult =
|
|
660
|
+
moduleResult = need(loadModule)
|
|
657
661
|
}
|
|
658
662
|
|
|
659
663
|
if (!forceExports) {
|
|
@@ -800,10 +804,10 @@ export function loadComponentsInnerSync(
|
|
|
800
804
|
}
|
|
801
805
|
|
|
802
806
|
if (process.env.DEBUG === 'hanzogui') {
|
|
803
|
-
console.info(`loadModule`, loadModule,
|
|
807
|
+
console.info(`loadModule`, loadModule, need.resolve(loadModule))
|
|
804
808
|
}
|
|
805
809
|
|
|
806
|
-
const moduleResult =
|
|
810
|
+
const moduleResult = need(loadModule)
|
|
807
811
|
|
|
808
812
|
if (!forceExports) {
|
|
809
813
|
setRequireResult(name, moduleResult)
|
|
@@ -5,9 +5,9 @@ import type { NodePath } from '@babel/traverse'
|
|
|
5
5
|
import * as t from '@babel/types'
|
|
6
6
|
import esbuild from 'esbuild'
|
|
7
7
|
|
|
8
|
-
import { FAILED_EVAL } from '../constants'
|
|
9
|
-
import type { GuiOptionsWithFileInfo } from '../types'
|
|
10
|
-
import { evaluateAstNode } from './evaluateAstNode'
|
|
8
|
+
import { FAILED_EVAL } from '../constants.ts'
|
|
9
|
+
import type { GuiOptionsWithFileInfo } from '../types.ts'
|
|
10
|
+
import { evaluateAstNode } from './evaluateAstNode.ts'
|
|
11
11
|
|
|
12
12
|
export function createEvaluator({
|
|
13
13
|
props,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NodePath, TraverseOptions } from '@babel/traverse'
|
|
1
|
+
import type { NodePath, TraverseOptions, Visitor } from '@babel/traverse'
|
|
2
2
|
import traverse from '@babel/traverse'
|
|
3
3
|
import * as t from '@babel/types'
|
|
4
4
|
import { Color, colorLog } from '@hanzogui/cli-color'
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
type StaticConfig,
|
|
13
13
|
type GuiComponentState,
|
|
14
14
|
} from '@hanzogui/web'
|
|
15
|
-
import {
|
|
15
|
+
import { readFileSync } from 'node:fs'
|
|
16
16
|
import { basename, dirname, resolve, relative } from 'node:path'
|
|
17
|
-
import { nodeModuleNameResolver, sys } from 'typescript'
|
|
18
17
|
import type { ViewStyle } from 'react-native'
|
|
19
18
|
|
|
20
|
-
import { FAILED_EVAL } from '../constants'
|
|
21
|
-
import { requireGuiCore } from '../helpers/requireGuiCore'
|
|
19
|
+
import { FAILED_EVAL } from '../constants.ts'
|
|
20
|
+
import { requireGuiCore } from '../helpers/requireGuiCore.ts'
|
|
21
|
+
import { registerRequire } from '../registerRequire.ts'
|
|
22
22
|
import type {
|
|
23
23
|
ExtractedAttr,
|
|
24
24
|
ExtractedAttrStyle,
|
|
@@ -27,11 +27,12 @@ import type {
|
|
|
27
27
|
GuiOptions,
|
|
28
28
|
GuiOptionsWithFileInfo,
|
|
29
29
|
Ternary,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
30
|
+
GuiPlatform,
|
|
31
|
+
} from '../types.ts'
|
|
32
|
+
import type { LoadedComponents, GuiProjectInfo } from './bundleConfig.ts'
|
|
33
|
+
import { createEvaluator, createSafeEvaluator } from './createEvaluator.ts'
|
|
34
|
+
import { installedPackageOf } from './extractablePath.ts'
|
|
35
|
+
import { evaluateAstNode } from './evaluateAstNode.ts'
|
|
35
36
|
import {
|
|
36
37
|
attrStr,
|
|
37
38
|
findComponentName,
|
|
@@ -41,18 +42,32 @@ import {
|
|
|
41
42
|
isPresent,
|
|
42
43
|
isValidImport,
|
|
43
44
|
objToStr,
|
|
44
|
-
} from './extractHelpers'
|
|
45
|
-
import { findTopmostFunction } from './findTopmostFunction'
|
|
46
|
-
import {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
45
|
+
} from './extractHelpers.ts'
|
|
46
|
+
import { findTopmostFunction } from './findTopmostFunction.ts'
|
|
47
|
+
import {
|
|
48
|
+
cleanupBeforeExit,
|
|
49
|
+
getStaticBindingsForScope,
|
|
50
|
+
} from './getStaticBindingsForScope.ts'
|
|
51
|
+
import { literalToAst } from './literalToAst.ts'
|
|
52
|
+
import { loadGui, loadGuiSync } from './loadGui.ts'
|
|
53
|
+
import { logLines } from './logLines.ts'
|
|
54
|
+
import { normalizeTernaries } from './normalizeTernaries.ts'
|
|
55
|
+
import { setPropsToFontFamily } from './propsToFontFamilyCache.ts'
|
|
56
|
+
import { timer } from './timer.ts'
|
|
57
|
+
import { validHTMLAttributes } from './validHTMLAttributes.ts'
|
|
58
|
+
import { BailOptimizationError } from './errors.ts'
|
|
59
|
+
import { probe, resolveAlias } from './esbuildTsconfigPaths.ts'
|
|
60
|
+
|
|
61
|
+
// The core of a platform, loaded with the extractor's own require in place so
|
|
62
|
+
// the react-native its native emit asks for is the one this process can run.
|
|
63
|
+
const loadGuiCore = (platform: GuiPlatform) => {
|
|
64
|
+
const { unregister } = registerRequire(platform)
|
|
65
|
+
try {
|
|
66
|
+
return requireGuiCore(platform)
|
|
67
|
+
} finally {
|
|
68
|
+
unregister()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
56
71
|
|
|
57
72
|
const UNTOUCHED_PROPS = {
|
|
58
73
|
key: true,
|
|
@@ -183,60 +198,14 @@ export function createExtractor(
|
|
|
183
198
|
const dynamicComponentCache = new Map<string, LoadedComponents>()
|
|
184
199
|
const dynamicLoadingInProgress = new Set<string>()
|
|
185
200
|
|
|
186
|
-
// lazily loaded tsconfig compiler options for path alias resolution
|
|
187
|
-
let _compilerOptions: any = null
|
|
188
|
-
function getCompilerOptions() {
|
|
189
|
-
if (!_compilerOptions) {
|
|
190
|
-
try {
|
|
191
|
-
_compilerOptions = loadCompilerOptionsFromTsconfig()
|
|
192
|
-
} catch {
|
|
193
|
-
_compilerOptions = {}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return _compilerOptions
|
|
197
|
-
}
|
|
198
|
-
|
|
199
201
|
function resolveImportPath(fromFile: string, importPath: string): string | null {
|
|
202
|
+
const dir = dirname(fromFile)
|
|
200
203
|
if (importPath.startsWith('.')) {
|
|
201
|
-
|
|
202
|
-
const dir = dirname(fromFile)
|
|
203
|
-
const base = resolve(dir, importPath)
|
|
204
|
-
const extensions = ['.tsx', '.ts', '.jsx', '.js']
|
|
205
|
-
for (const ext of extensions) {
|
|
206
|
-
const full = base + ext
|
|
207
|
-
if (existsSync(full)) return full
|
|
208
|
-
}
|
|
209
|
-
// try index files
|
|
210
|
-
for (const ext of extensions) {
|
|
211
|
-
const full = resolve(base, `index${ext}`)
|
|
212
|
-
if (existsSync(full)) return full
|
|
213
|
-
}
|
|
214
|
-
return null
|
|
204
|
+
return probe(resolve(dir, importPath))
|
|
215
205
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (compilerOptions.paths) {
|
|
220
|
-
try {
|
|
221
|
-
const { resolvedModule } = nodeModuleNameResolver(
|
|
222
|
-
importPath,
|
|
223
|
-
fromFile,
|
|
224
|
-
compilerOptions,
|
|
225
|
-
sys
|
|
226
|
-
)
|
|
227
|
-
if (
|
|
228
|
-
resolvedModule &&
|
|
229
|
-
!resolvedModule.resolvedFileName.endsWith('.d.ts') &&
|
|
230
|
-
!resolvedModule.isExternalLibraryImport
|
|
231
|
-
) {
|
|
232
|
-
return resolvedModule.resolvedFileName
|
|
233
|
-
}
|
|
234
|
-
} catch {
|
|
235
|
-
// fallback - tsconfig resolution failed
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return null
|
|
206
|
+
// tsconfig path alias (e.g. ~/foo, @/bar) into project source, never into node_modules
|
|
207
|
+
const file = resolveAlias(importPath, dir)
|
|
208
|
+
return file && !file.includes('node_modules') ? file : null
|
|
240
209
|
}
|
|
241
210
|
|
|
242
211
|
const styledCheckCache = new Map<string, boolean>()
|
|
@@ -338,7 +307,7 @@ export function createExtractor(
|
|
|
338
307
|
proxyThemeVariables,
|
|
339
308
|
getDefaultProps,
|
|
340
309
|
pseudoDescriptors,
|
|
341
|
-
} =
|
|
310
|
+
} = loadGuiCore(platform)
|
|
342
311
|
|
|
343
312
|
let shouldPrintDebug = options.shouldPrintDebug || false
|
|
344
313
|
|
|
@@ -636,8 +605,7 @@ export function createExtractor(
|
|
|
636
605
|
// only keeping a cache around per-file, reset it if it changes
|
|
637
606
|
const bindingCache: Record<string, string | null> = {}
|
|
638
607
|
|
|
639
|
-
const callTraverse = (a: TraverseOptions
|
|
640
|
-
// @ts-ignore
|
|
608
|
+
const callTraverse = (a: TraverseOptions & Visitor) => {
|
|
641
609
|
return fileOrPath.type === 'File' ? traverse(fileOrPath, a) : fileOrPath.traverse(a)
|
|
642
610
|
}
|
|
643
611
|
|
|
@@ -661,7 +629,6 @@ export function createExtractor(
|
|
|
661
629
|
const version = `${Math.random()}`
|
|
662
630
|
|
|
663
631
|
callTraverse({
|
|
664
|
-
// @ts-ignore
|
|
665
632
|
Program: {
|
|
666
633
|
enter(path) {
|
|
667
634
|
programPath = path
|
|
@@ -2009,6 +1976,21 @@ export function createExtractor(
|
|
|
2009
1976
|
(staticConfig.neverFlatten === 'jsx' ? hasOnlyStringChildren : true)
|
|
2010
1977
|
)
|
|
2011
1978
|
|
|
1979
|
+
if (shouldPrintDebug === 'verbose') {
|
|
1980
|
+
logger.info(
|
|
1981
|
+
` flatten? ${originalNodeName} -> ${flatNodeName} ${JSON.stringify({
|
|
1982
|
+
shouldFlatten,
|
|
1983
|
+
shouldDeopt,
|
|
1984
|
+
canFlattenProps,
|
|
1985
|
+
hasSpread,
|
|
1986
|
+
isStyledHOC: staticConfig.isStyledHOC,
|
|
1987
|
+
isHOC: staticConfig.isHOC,
|
|
1988
|
+
isReactNative: staticConfig.isReactNative,
|
|
1989
|
+
neverFlatten: staticConfig.neverFlatten,
|
|
1990
|
+
})}`
|
|
1991
|
+
)
|
|
1992
|
+
}
|
|
1993
|
+
|
|
2012
1994
|
const usedThemeKeys = new Set<string>()
|
|
2013
1995
|
// if it accesses any theme values during evaluation
|
|
2014
1996
|
themeAccessListeners.add((key) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { basename } from 'node:path'
|
|
2
2
|
|
|
3
|
-
import type { GuiOptions } from '../types'
|
|
4
|
-
import { getPrefixLogs } from './getPrefixLogs'
|
|
3
|
+
import type { GuiOptions } from '../types.ts'
|
|
4
|
+
import { getPrefixLogs } from './getPrefixLogs.ts'
|
|
5
5
|
|
|
6
6
|
export function createLogger(sourcePath: string, options: GuiOptions) {
|
|
7
7
|
const shouldLogTiming = options.logTimings ?? true
|
|
@@ -1,134 +1,69 @@
|
|
|
1
1
|
import type { Plugin } from 'esbuild'
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* a gui config that imports through a TS path alias and costs everything else
|
|
20
|
-
* nothing. Losing an alias beats losing the stylesheet.
|
|
21
|
-
*/
|
|
22
|
-
const hasProgramApi = typeof (ts as any)?.sys?.fileExists === 'function'
|
|
23
|
-
|
|
24
|
-
let warned = false
|
|
25
|
-
function warnOnce() {
|
|
26
|
-
if (warned) return
|
|
27
|
-
warned = true
|
|
28
|
-
console.warn(
|
|
29
|
-
` ➡ [hanzogui] typescript ${(ts as any)?.version ?? '(not found)'} has no program API ` +
|
|
30
|
-
`(7.x removed it from the root export), so tsconfig "paths" are not applied when ` +
|
|
31
|
-
`bundling the gui config. Imports resolve through node.`
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface Tsconfig {
|
|
36
|
-
compilerOptions?: {
|
|
37
|
-
baseUrl?: string
|
|
38
|
-
paths?: Record<string, string[]>
|
|
2
|
+
import { statSync } from 'node:fs'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import {
|
|
5
|
+
createPathsMatcher,
|
|
6
|
+
getTsconfig,
|
|
7
|
+
type Cache,
|
|
8
|
+
type PathsMatcher,
|
|
9
|
+
type TsConfigResult,
|
|
10
|
+
} from 'get-tsconfig'
|
|
11
|
+
|
|
12
|
+
const extensions = ['.tsx', '.ts', '.jsx', '.js']
|
|
13
|
+
|
|
14
|
+
const isFile = (path: string) => {
|
|
15
|
+
try {
|
|
16
|
+
return statSync(path).isFile()
|
|
17
|
+
} catch {
|
|
18
|
+
return false
|
|
39
19
|
}
|
|
40
20
|
}
|
|
41
21
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
/** The source file an extensionless path names: the path itself, then each extension, then an index file. */
|
|
23
|
+
export function probe(base: string): string | null {
|
|
24
|
+
for (const ext of ['', ...extensions]) {
|
|
25
|
+
if (isFile(base + ext)) return base + ext
|
|
46
26
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
name,
|
|
52
|
-
setup({ onResolve }) {
|
|
53
|
-
onResolve({ filter: /.*/ }, (args) => {
|
|
54
|
-
// skip @hanzogui packages - they should be externalized, not resolved via tsconfig
|
|
55
|
-
if (args.path.startsWith('@hanzogui/')) {
|
|
56
|
-
return null
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const paths = compilerOptions.paths || {}
|
|
60
|
-
const hasMatchingPath = Object.keys(paths).some((p) =>
|
|
61
|
-
new RegExp(p.replace('*', '\\w*')).test(args.path)
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
if (!hasMatchingPath) {
|
|
65
|
-
return null
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const { resolvedModule } = ts.nodeModuleNameResolver(
|
|
69
|
-
args.path,
|
|
70
|
-
args.importer,
|
|
71
|
-
compilerOptions,
|
|
72
|
-
ts.sys
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
if (!resolvedModule) {
|
|
76
|
-
return null
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const { resolvedFileName } = resolvedModule
|
|
80
|
-
|
|
81
|
-
if (!resolvedFileName || resolvedFileName.endsWith('.d.ts')) {
|
|
82
|
-
return null
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
path: resolvedFileName,
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
},
|
|
27
|
+
for (const ext of extensions) {
|
|
28
|
+
const index = join(base, `index${ext}`)
|
|
29
|
+
if (isFile(index)) return index
|
|
90
30
|
}
|
|
31
|
+
return null
|
|
91
32
|
}
|
|
92
33
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
34
|
+
const configs: Cache<TsConfigResult | null> = new Map()
|
|
35
|
+
const matchers = new Map<string, PathsMatcher | null>()
|
|
36
|
+
|
|
37
|
+
/** Maps a specifier through `compilerOptions.paths` of the tsconfig (or jsconfig) nearest `dir` to a source file. */
|
|
38
|
+
export function resolveAlias(specifier: string, dir: string): string | null {
|
|
39
|
+
if (!matchers.has(dir)) {
|
|
40
|
+
// A dependency's tsconfig may extend a preset it does not ship; that is
|
|
41
|
+
// no paths to map, not a reason to fail the bundle.
|
|
42
|
+
let tsconfig: TsConfigResult | null = null
|
|
43
|
+
try {
|
|
44
|
+
tsconfig =
|
|
45
|
+
getTsconfig(dir, 'tsconfig.json', configs) ??
|
|
46
|
+
getTsconfig(dir, 'jsconfig.json', configs)
|
|
47
|
+
} catch {}
|
|
48
|
+
matchers.set(dir, tsconfig && createPathsMatcher(tsconfig))
|
|
97
49
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
ts.findConfigFile(process.cwd(), ts.sys.fileExists, 'tsconfig.json') ||
|
|
102
|
-
ts.findConfigFile(process.cwd(), ts.sys.fileExists, 'jsconfig.json')
|
|
103
|
-
|
|
104
|
-
if (configPath) {
|
|
105
|
-
return parseTsconfig(configPath)
|
|
106
|
-
}
|
|
107
|
-
return {}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (typeof tsconfig === 'string') {
|
|
111
|
-
if (fs.existsSync(tsconfig)) {
|
|
112
|
-
return parseTsconfig(tsconfig)
|
|
113
|
-
} else {
|
|
114
|
-
throw new Error(`Specified tsconfig file not found: ${tsconfig}`)
|
|
115
|
-
}
|
|
50
|
+
for (const candidate of matchers.get(dir)?.(specifier) ?? []) {
|
|
51
|
+
const file = probe(candidate)
|
|
52
|
+
if (file) return file
|
|
116
53
|
}
|
|
117
|
-
|
|
118
|
-
const baseDir = process.cwd()
|
|
119
|
-
const parsed = ts.parseJsonConfigFileContent(tsconfig, ts.sys, baseDir)
|
|
120
|
-
return parsed.options
|
|
54
|
+
return null
|
|
121
55
|
}
|
|
122
56
|
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
57
|
+
export function TsconfigPathsPlugin(): Plugin {
|
|
58
|
+
return {
|
|
59
|
+
name: 'tsconfig-paths',
|
|
60
|
+
setup({ onResolve }) {
|
|
61
|
+
onResolve({ filter: /.*/ }, ({ path, resolveDir }) => {
|
|
62
|
+
// @hanzogui packages are externalized, never resolved through tsconfig
|
|
63
|
+
if (path.startsWith('@hanzogui/')) return null
|
|
64
|
+
const file = resolveAlias(path, resolveDir || process.cwd())
|
|
65
|
+
return file ? { path: file } : null
|
|
66
|
+
})
|
|
67
|
+
},
|
|
129
68
|
}
|
|
130
|
-
|
|
131
|
-
const baseDir = path.dirname(configFilePath)
|
|
132
|
-
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, baseDir)
|
|
133
|
-
return parsed.options
|
|
134
69
|
}
|