@hanzogui/static 4.4.0 → 7.0.0

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.
Files changed (101) hide show
  1. package/dist/check-dep-versions.cjs +1 -1
  2. package/dist/checkDeps.cjs +11 -11
  3. package/dist/constants.cjs +2 -2
  4. package/dist/exports.cjs +2 -2
  5. package/dist/extractor/bundle.cjs +20 -39
  6. package/dist/extractor/bundleConfig.cjs +46 -46
  7. package/dist/extractor/createExtractor.cjs +39 -39
  8. package/dist/extractor/createLogger.cjs +1 -1
  9. package/dist/extractor/extractHelpers.cjs +1 -1
  10. package/dist/extractor/extractMediaStyle.cjs +7 -7
  11. package/dist/extractor/extractToClassNames.cjs +9 -9
  12. package/dist/extractor/extractToNative.cjs +7 -7
  13. package/dist/extractor/{getGuiConfigPathFromOptionsConfig.cjs → getHanzoguiConfigPathFromOptionsConfig.cjs} +5 -5
  14. package/dist/extractor/getPrefixLogs.cjs +1 -1
  15. package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
  16. package/dist/extractor/{loadGui.cjs → loadHanzogui.cjs} +97 -141
  17. package/dist/extractor/regenerateConfig.cjs +20 -20
  18. package/dist/extractor/{watchGuiConfig.cjs → watchHanzoguiConfig.cjs} +15 -15
  19. package/dist/getPragmaOptions.cjs +6 -6
  20. package/dist/helpers/{requireGuiCore.cjs → requireHanzoguiCore.cjs} +12 -12
  21. package/dist/registerRequire.cjs +21 -21
  22. package/dist/worker.cjs +3 -3
  23. package/package.json +22 -22
  24. package/src/check-dep-versions.ts +1 -5
  25. package/src/checkDeps.ts +28 -30
  26. package/src/constants.ts +2 -2
  27. package/src/exports.ts +2 -2
  28. package/src/extractor/bundle.ts +11 -13
  29. package/src/extractor/bundleConfig.ts +57 -57
  30. package/src/extractor/createEvaluator.ts +2 -2
  31. package/src/extractor/createExtractor.ts +62 -55
  32. package/src/extractor/createLogger.ts +5 -3
  33. package/src/extractor/esbuildTsconfigPaths.ts +1 -1
  34. package/src/extractor/extractHelpers.ts +15 -12
  35. package/src/extractor/extractMediaStyle.ts +19 -13
  36. package/src/extractor/extractToClassNames.ts +11 -11
  37. package/src/extractor/extractToNative.ts +13 -13
  38. package/src/extractor/{getGuiConfigPathFromOptionsConfig.ts → getHanzoguiConfigPathFromOptionsConfig.ts} +3 -3
  39. package/src/extractor/getPrefixLogs.ts +3 -3
  40. package/src/extractor/getStaticBindingsForScope.ts +2 -2
  41. package/src/extractor/{loadGui.ts → loadHanzogui.ts} +86 -83
  42. package/src/extractor/regenerateConfig.ts +34 -24
  43. package/src/extractor/{watchGuiConfig.ts → watchHanzoguiConfig.ts} +10 -10
  44. package/src/getPragmaOptions.ts +6 -6
  45. package/src/helpers/requireHanzoguiCore.ts +28 -0
  46. package/src/registerRequire.ts +34 -36
  47. package/src/server.ts +2 -2
  48. package/src/types.ts +13 -10
  49. package/src/worker.ts +7 -7
  50. package/types/check-dep-versions.d.ts.map +1 -1
  51. package/types/checkDeps.d.ts.map +1 -1
  52. package/types/constants.d.ts.map +1 -1
  53. package/types/exports.d.ts +2 -2
  54. package/types/exports.d.ts.map +1 -1
  55. package/types/extractor/bundle.d.ts +2 -2
  56. package/types/extractor/bundle.d.ts.map +1 -1
  57. package/types/extractor/bundleConfig.d.ts +12 -12
  58. package/types/extractor/bundleConfig.d.ts.map +1 -1
  59. package/types/extractor/createEvaluator.d.ts +2 -2
  60. package/types/extractor/createEvaluator.d.ts.map +1 -1
  61. package/types/extractor/createExtractor.d.ts +5 -5
  62. package/types/extractor/createExtractor.d.ts.map +1 -1
  63. package/types/extractor/createLogger.d.ts +2 -2
  64. package/types/extractor/createLogger.d.ts.map +1 -1
  65. package/types/extractor/extractHelpers.d.ts +8 -8
  66. package/types/extractor/extractHelpers.d.ts.map +1 -1
  67. package/types/extractor/extractMediaStyle.d.ts +4 -4
  68. package/types/extractor/extractMediaStyle.d.ts.map +1 -1
  69. package/types/extractor/extractToClassNames.d.ts +2 -2
  70. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  71. package/types/extractor/extractToNative.d.ts +3 -3
  72. package/types/extractor/extractToNative.d.ts.map +1 -1
  73. package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +3 -0
  74. package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +1 -0
  75. package/types/extractor/getPrefixLogs.d.ts +2 -2
  76. package/types/extractor/getPrefixLogs.d.ts.map +1 -1
  77. package/types/extractor/loadHanzogui.d.ts +22 -0
  78. package/types/extractor/loadHanzogui.d.ts.map +1 -0
  79. package/types/extractor/regenerateConfig.d.ts +4 -4
  80. package/types/extractor/regenerateConfig.d.ts.map +1 -1
  81. package/types/extractor/watchHanzoguiConfig.d.ts +5 -0
  82. package/types/extractor/watchHanzoguiConfig.d.ts.map +1 -0
  83. package/types/helpers/requireHanzoguiCore.d.ts +3 -0
  84. package/types/helpers/requireHanzoguiCore.d.ts.map +1 -0
  85. package/types/registerRequire.d.ts +3 -3
  86. package/types/registerRequire.d.ts.map +1 -1
  87. package/types/server.d.ts +2 -2
  88. package/types/server.d.ts.map +1 -1
  89. package/types/types.d.ts +10 -10
  90. package/types/types.d.ts.map +1 -1
  91. package/types/worker.d.ts +4 -4
  92. package/types/worker.d.ts.map +1 -1
  93. package/src/helpers/requireGuiCore.ts +0 -28
  94. package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +0 -3
  95. package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +0 -1
  96. package/types/extractor/loadGui.d.ts +0 -22
  97. package/types/extractor/loadGui.d.ts.map +0 -1
  98. package/types/extractor/watchGuiConfig.d.ts +0 -5
  99. package/types/extractor/watchGuiConfig.d.ts.map +0 -1
  100. package/types/helpers/requireGuiCore.d.ts +0 -3
  101. package/types/helpers/requireGuiCore.d.ts.map +0 -1
@@ -10,7 +10,7 @@ import {
10
10
  type PseudoStyles,
11
11
  type SplitStyleProps,
12
12
  type StaticConfig,
13
- type GuiComponentState,
13
+ type HanzoguiComponentState,
14
14
  } from '@hanzogui/web'
15
15
  import { existsSync, readFileSync } from 'node:fs'
16
16
  import { basename, dirname, resolve, relative } from 'node:path'
@@ -18,17 +18,17 @@ import { nodeModuleNameResolver, sys } from 'typescript'
18
18
  import type { ViewStyle } from 'react-native'
19
19
 
20
20
  import { FAILED_EVAL } from '../constants'
21
- import { requireGuiCore } from '../helpers/requireGuiCore'
21
+ import { requireHanzoguiCore } from '../helpers/requireHanzoguiCore'
22
22
  import type {
23
23
  ExtractedAttr,
24
24
  ExtractedAttrStyle,
25
25
  ExtractorOptions,
26
26
  ExtractorParseProps,
27
- GuiOptions,
28
- GuiOptionsWithFileInfo,
27
+ HanzoguiOptions,
28
+ HanzoguiOptionsWithFileInfo,
29
29
  Ternary,
30
30
  } from '../types'
31
- import type { LoadedComponents, GuiProjectInfo } from './bundleConfig'
31
+ import type { LoadedComponents, HanzoguiProjectInfo } from './bundleConfig'
32
32
  import { createEvaluator, createSafeEvaluator } from './createEvaluator'
33
33
  import { evaluateAstNode } from './evaluateAstNode'
34
34
  import {
@@ -44,7 +44,7 @@ import {
44
44
  import { findTopmostFunction } from './findTopmostFunction'
45
45
  import { cleanupBeforeExit, getStaticBindingsForScope } from './getStaticBindingsForScope'
46
46
  import { literalToAst } from './literalToAst'
47
- import { loadGui, loadGuiSync } from './loadGui'
47
+ import { loadHanzogui, loadHanzoguiSync } from './loadHanzogui'
48
48
  import { logLines } from './logLines'
49
49
  import { normalizeTernaries } from './normalizeTernaries'
50
50
  import { setPropsToFontFamily } from './propsToFontFamilyCache'
@@ -72,7 +72,7 @@ type FileOrPath = NodePath<t.Program> | t.File
72
72
 
73
73
  let hasLoggedBaseInfo = false
74
74
 
75
- function isFullyDisabled(props: GuiOptions) {
75
+ function isFullyDisabled(props: HanzoguiOptions) {
76
76
  return props.disableExtraction && props.disableDebugAttr
77
77
  }
78
78
 
@@ -114,7 +114,7 @@ export function createExtractor(
114
114
  }),
115
115
  }
116
116
 
117
- const componentState: GuiComponentState = {
117
+ const componentState: HanzoguiComponentState = {
118
118
  focus: false,
119
119
  focusVisible: false,
120
120
  focusWithin: false,
@@ -138,7 +138,7 @@ export function createExtractor(
138
138
  process.env.IDENTIFY_TAGS !== 'false' &&
139
139
  (process.env.NODE_ENV === 'development' || process.env.IDENTIFY_TAGS)
140
140
 
141
- let projectInfo: GuiProjectInfo | null = null
141
+ let projectInfo: HanzoguiProjectInfo | null = null
142
142
 
143
143
  // cache of dynamically discovered styled components, keyed by absolute file path
144
144
  // persists across files within the same worker/extractor instance
@@ -217,21 +217,21 @@ export function createExtractor(
217
217
  }
218
218
  }
219
219
 
220
- // we load hanzo-gui delayed because we need to set some global/env stuff before importing
220
+ // we load hanzogui delayed because we need to set some global/env stuff before importing
221
221
  // otherwise we'd import `rnw` and cause it to evaluate react-native-web which causes errors
222
222
 
223
- function loadSync(props: GuiOptions) {
223
+ function loadSync(props: HanzoguiOptions) {
224
224
  if (isFullyDisabled(props)) {
225
225
  return null
226
226
  }
227
- return (projectInfo ||= loadGuiSync(props))
227
+ return (projectInfo ||= loadHanzoguiSync(props))
228
228
  }
229
229
 
230
- async function load(props: GuiOptions) {
230
+ async function load(props: HanzoguiOptions) {
231
231
  if (isFullyDisabled(props)) {
232
232
  return null
233
233
  }
234
- return (projectInfo ||= await loadGui(props))
234
+ return (projectInfo ||= await loadHanzogui(props))
235
235
  }
236
236
 
237
237
  return {
@@ -239,10 +239,10 @@ export function createExtractor(
239
239
  logger,
240
240
  },
241
241
  cleanupBeforeExit,
242
- loadGui: load,
243
- loadGuiSync: loadSync,
244
- getGui() {
245
- return projectInfo?.guiConfig
242
+ loadHanzogui: load,
243
+ loadHanzoguiSync: loadSync,
244
+ getHanzogui() {
245
+ return projectInfo?.hanzoguiConfig
246
246
  },
247
247
  parseSync: (f: FileOrPath, props: ExtractorParseProps) => {
248
248
  globalThis.expo ||= {} // expo-modules-core checks this and avoids loading "native" modules if exists
@@ -257,12 +257,12 @@ export function createExtractor(
257
257
  }
258
258
 
259
259
  function parseWithConfig(
260
- { components, guiConfig }: GuiProjectInfo,
260
+ { components, hanzoguiConfig }: HanzoguiProjectInfo,
261
261
  fileOrPath: FileOrPath,
262
262
  options: ExtractorParseProps
263
263
  ) {
264
264
  const {
265
- config = 'gui.config.ts',
265
+ config = 'hanzogui.config.ts',
266
266
  importsWhitelist = ['constants.js'],
267
267
  evaluateVars = true,
268
268
  sourcePath = '',
@@ -288,7 +288,7 @@ export function createExtractor(
288
288
  styledCheckCache.delete(sourcePath)
289
289
  }
290
290
 
291
- if (sourcePath.includes('.gui-dynamic-eval')) {
291
+ if (sourcePath.includes('.hanzogui-dynamic-eval')) {
292
292
  return null
293
293
  }
294
294
 
@@ -300,7 +300,7 @@ export function createExtractor(
300
300
  proxyThemeVariables,
301
301
  getDefaultProps,
302
302
  pseudoDescriptors,
303
- } = requireGuiCore(platform)
303
+ } = requireHanzoguiCore(platform)
304
304
 
305
305
  let shouldPrintDebug = options.shouldPrintDebug || false
306
306
 
@@ -331,7 +331,7 @@ export function createExtractor(
331
331
 
332
332
  function isValidStyleKey(name: string, staticConfig: StaticConfig) {
333
333
  if (!projectInfo) {
334
- throw new Error(`Gui extractor not loaded yet`)
334
+ throw new Error(`Hanzogui extractor not loaded yet`)
335
335
  }
336
336
  if (platform === 'native' && name[0] === '$' && mediaQueryConfig[name.slice(1)]) {
337
337
  return false
@@ -355,7 +355,7 @@ export function createExtractor(
355
355
  pseudoDescriptors[name] ||
356
356
  // don't disable variants or else you lose many things flattening
357
357
  staticConfig.variants?.[name] ||
358
- projectInfo?.guiConfig?.shorthands[name]
358
+ projectInfo?.hanzoguiConfig?.shorthands[name]
359
359
  )
360
360
  }
361
361
 
@@ -366,7 +366,7 @@ export function createExtractor(
366
366
  const isTargetingHTML = platform === 'web'
367
367
  const ogDebug = shouldPrintDebug
368
368
  const tm = timer()
369
- const propsWithFileInfo: GuiOptionsWithFileInfo = {
369
+ const propsWithFileInfo: HanzoguiOptionsWithFileInfo = {
370
370
  ...options,
371
371
  sourcePath,
372
372
  allLoadedComponents: components ? [...components] : [],
@@ -384,7 +384,7 @@ export function createExtractor(
384
384
  ].join(' ')
385
385
  )
386
386
  }
387
- if (process.env.DEBUG?.startsWith('@hanzo/gui')) {
387
+ if (process.env.DEBUG?.startsWith('hanzogui')) {
388
388
  logger.info(
389
389
  [
390
390
  'loaded:',
@@ -394,14 +394,14 @@ export function createExtractor(
394
394
  }
395
395
  }
396
396
 
397
- tm.mark('load-gui', !!shouldPrintDebug)
397
+ tm.mark('load-hanzogui', !!shouldPrintDebug)
398
398
 
399
399
  if (!isFullyDisabled(options)) {
400
- if (!guiConfig?.themes) {
400
+ if (!hanzoguiConfig?.themes) {
401
401
  console.error(
402
- `⛔️ Error: Missing "themes" in your gui.config file:
402
+ `⛔️ Error: Missing "themes" in your hanzogui.config file:
403
403
 
404
- You may not need the compiler! Remember you can run GUI with no configuration at all.
404
+ You may not need the compiler! Remember you can run Hanzogui with no configuration at all.
405
405
 
406
406
  You may have not "export default" your config (you can also "export const config").
407
407
 
@@ -410,17 +410,17 @@ export function createExtractor(
410
410
  - or search your lockfile for mis-matches.
411
411
  `
412
412
  )
413
- console.info(` Got config:`, guiConfig)
413
+ console.info(` Got config:`, hanzoguiConfig)
414
414
  process.exit(0)
415
415
  }
416
416
  }
417
417
 
418
- const firstThemeName = Object.keys(guiConfig?.themes || {})[0]
419
- const firstTheme = guiConfig?.themes[firstThemeName] || {}
418
+ const firstThemeName = Object.keys(hanzoguiConfig?.themes || {})[0]
419
+ const firstTheme = hanzoguiConfig?.themes[firstThemeName] || {}
420
420
 
421
421
  if (!firstTheme || typeof firstTheme !== 'object') {
422
422
  const err = `Missing theme ${firstThemeName}, an error occurred when importing your config`
423
- console.info(err, `Got config:`, guiConfig)
423
+ console.info(err, `Got config:`, hanzoguiConfig)
424
424
  console.info(`Looking for theme:`, firstThemeName)
425
425
  throw new Error(err)
426
426
  }
@@ -443,9 +443,9 @@ export function createExtractor(
443
443
  if (!isFullyDisabled(options)) {
444
444
  if (Object.keys(components || []).length === 0) {
445
445
  console.warn(
446
- `Warning: GUI didn't find any valid components (DEBUG=hanzo-gui for more)`
446
+ `Warning: Hanzogui didn't find any valid components (DEBUG=hanzogui for more)`
447
447
  )
448
- if (process.env.DEBUG === '@hanzo/gui') {
448
+ if (process.env.DEBUG === 'hanzogui') {
449
449
  console.info(`components`, Object.keys(components || []), components)
450
450
  }
451
451
  }
@@ -487,7 +487,7 @@ export function createExtractor(
487
487
 
488
488
  if (extractStyledDefinitions && enableDynamicEvaluation) {
489
489
  // check all imports for `styled`, not just valid packages
490
- // styled( is basically guaranteed to be hanzo-gui regardless of source
490
+ // styled( is basically guaranteed to be hanzogui regardless of source
491
491
  if (node.specifiers.some((specifier) => specifier.local.name === 'styled')) {
492
492
  doesUseValidImport = true
493
493
  // don't break - need to collect all import declarations for the styled() handler
@@ -655,7 +655,7 @@ export function createExtractor(
655
655
  )
656
656
  }
657
657
 
658
- const out = loadGuiSync({
658
+ const out = loadHanzoguiSync({
659
659
  forceExports: true,
660
660
  components: [sourcePath],
661
661
  cacheKey: version,
@@ -684,14 +684,14 @@ export function createExtractor(
684
684
  if (foundNames) {
685
685
  colorLog(
686
686
  Color.FgYellow,
687
- ` | GUI found dynamic components: ${foundNames}`
687
+ ` | Hanzogui found dynamic components: ${foundNames}`
688
688
  )
689
689
  }
690
690
  }
691
691
  } catch (err: any) {
692
692
  if (shouldPrintDebug) {
693
693
  logger.info(
694
- `skip optimize styled(${variableName}), unable to pre-process (DEBUG=hanzo-gui for more)`
694
+ `skip optimize styled(${variableName}), unable to pre-process (DEBUG=hanzogui for more)`
695
695
  )
696
696
  }
697
697
  }
@@ -895,7 +895,7 @@ export function createExtractor(
895
895
  return
896
896
  }
897
897
 
898
- // validate its a proper import from hanzo-gui (or internally inside gui)
898
+ // validate its a proper import from hanzogui (or internally inside hanzogui)
899
899
  const binding = traversePath.scope.getBinding(node.name.name)
900
900
  let moduleName = ''
901
901
  let dynamicComponent: { staticConfig: any } | null = null
@@ -919,7 +919,7 @@ export function createExtractor(
919
919
  // proactively load the file
920
920
  dynamicLoadingInProgress.add(resolved)
921
921
  try {
922
- const out = loadGuiSync({
922
+ const out = loadHanzoguiSync({
923
923
  forceExports: true,
924
924
  components: [resolved],
925
925
  })
@@ -971,7 +971,7 @@ export function createExtractor(
971
971
  getValidComponent(propsWithFileInfo, moduleName, node.name.name)
972
972
  if (!component || !component.staticConfig) {
973
973
  if (shouldPrintDebug) {
974
- logger.info(`\n - No GUI conf for: ${node.name.name}\n`)
974
+ logger.info(`\n - No Hanzogui conf for: ${node.name.name}\n`)
975
975
  }
976
976
  return
977
977
  }
@@ -1104,7 +1104,9 @@ export function createExtractor(
1104
1104
  : []),
1105
1105
 
1106
1106
  // when using a non-CSS driver, de-opt on enterStyle/exitStyle
1107
- ...(guiConfig?.animations.isReactNative ? ['enterStyle', 'exitStyle'] : []),
1107
+ ...(hanzoguiConfig?.animations.isReactNative
1108
+ ? ['enterStyle', 'exitStyle']
1109
+ : []),
1108
1110
  ])
1109
1111
 
1110
1112
  const inlineWhenUnflattened = new Set(staticConfig.inlineWhenUnflattened || [])
@@ -1174,7 +1176,7 @@ export function createExtractor(
1174
1176
  style: {},
1175
1177
  theme: defaultTheme,
1176
1178
  viewProps: defaultProps,
1177
- conf: guiConfig!,
1179
+ conf: hanzoguiConfig!,
1178
1180
  props: defaultProps,
1179
1181
  componentState,
1180
1182
  styleProps: {
@@ -1286,9 +1288,9 @@ export function createExtractor(
1286
1288
 
1287
1289
  const name = attribute.name.name
1288
1290
 
1289
- // in hanzo-gui style is handled at the end of the style loop so its not as simple as just
1291
+ // in hanzogui style is handled at the end of the style loop so its not as simple as just
1290
1292
  // adding this as a "style" property
1291
- // its not used often when using hanzo-gui so not optimizing it for now
1293
+ // its not used often when using hanzogui so not optimizing it for now
1292
1294
  if (name === 'style') {
1293
1295
  shouldDeopt = true
1294
1296
  return null
@@ -1909,7 +1911,7 @@ export function createExtractor(
1909
1911
  if (!isValidStyleKey(key, staticConfig)) {
1910
1912
  return []
1911
1913
  }
1912
- const name = guiConfig?.shorthands[key] || key
1914
+ const name = hanzoguiConfig?.shorthands[key] || key
1913
1915
  if (value === undefined) {
1914
1916
  logger.warn(
1915
1917
  `⚠️ Error evaluating default style for component, prop ${key} ${value}`
@@ -2018,7 +2020,12 @@ export function createExtractor(
2018
2020
  hasImportedTheme = true
2019
2021
  programPath.node.body.push(
2020
2022
  t.importDeclaration(
2021
- [t.importSpecifier(t.identifier('_GuiTheme'), t.identifier('Theme'))],
2023
+ [
2024
+ t.importSpecifier(
2025
+ t.identifier('_HanzoguiTheme'),
2026
+ t.identifier('Theme')
2027
+ ),
2028
+ ],
2022
2029
  t.stringLiteral('@hanzogui/web')
2023
2030
  )
2024
2031
  )
@@ -2026,10 +2033,10 @@ export function createExtractor(
2026
2033
 
2027
2034
  traversePath.replaceWith(
2028
2035
  t.jsxElement(
2029
- t.jsxOpeningElement(t.jsxIdentifier('_GuiTheme'), [
2036
+ t.jsxOpeningElement(t.jsxIdentifier('_HanzoguiTheme'), [
2030
2037
  t.jsxAttribute(t.jsxIdentifier('name'), themeVal.value),
2031
2038
  ]),
2032
- t.jsxClosingElement(t.jsxIdentifier('_GuiTheme')),
2039
+ t.jsxClosingElement(t.jsxIdentifier('_HanzoguiTheme')),
2033
2040
  [traversePath.node]
2034
2041
  )
2035
2042
  )
@@ -2187,7 +2194,7 @@ export function createExtractor(
2187
2194
 
2188
2195
  let key = Object.keys(cur.value)[0]
2189
2196
  const value = cur.value[key]
2190
- const fullKey = guiConfig?.shorthands[key]
2197
+ const fullKey = hanzoguiConfig?.shorthands[key]
2191
2198
  // expand shorthands
2192
2199
  if (fullKey) {
2193
2200
  cur.value = { [fullKey]: value }
@@ -2615,7 +2622,7 @@ export function createExtractor(
2615
2622
  node,
2616
2623
  lineNumbers,
2617
2624
  filePath,
2618
- config: guiConfig!,
2625
+ config: hanzoguiConfig!,
2619
2626
  flatNodeName,
2620
2627
  attemptEval,
2621
2628
  jsxPath: traversePath,
@@ -2651,9 +2658,9 @@ export function createExtractor(
2651
2658
 
2652
2659
  if (!(err instanceof BailOptimizationError)) {
2653
2660
  console.error(
2654
- `@hanzogui/static error, reverting optimization. In ${filePath} ${lineNumbers} on ${originalNodeName}: ${err.message}. For stack trace set environment GUI_DEBUG=1`
2661
+ `@hanzogui/static error, reverting optimization. In ${filePath} ${lineNumbers} on ${originalNodeName}: ${err.message}. For stack trace set environment TAMAGUI_DEBUG=1`
2655
2662
  )
2656
- if (process.env.GUI_DEBUG === '1') {
2663
+ if (process.env.TAMAGUI_DEBUG === '1') {
2657
2664
  console.error(err.stack)
2658
2665
  }
2659
2666
  }
@@ -1,13 +1,15 @@
1
1
  import { basename } from 'node:path'
2
2
 
3
- import type { GuiOptions } from '../types'
3
+ import type { HanzoguiOptions } from '../types'
4
4
  import { getPrefixLogs } from './getPrefixLogs'
5
5
 
6
- export function createLogger(sourcePath: string, options: GuiOptions) {
6
+ export function createLogger(sourcePath: string, options: HanzoguiOptions) {
7
7
  const shouldLogTiming = options.logTimings ?? true
8
8
  const start = Date.now()
9
9
  const mem =
10
- process.env.GUI_SHOW_MEMORY_USAGE && shouldLogTiming ? process.memoryUsage() : null
10
+ process.env.TAMAGUI_SHOW_MEMORY_USAGE && shouldLogTiming
11
+ ? process.memoryUsage()
12
+ : null
11
13
 
12
14
  return (res) => {
13
15
  if (!shouldLogTiming) {
@@ -25,7 +25,7 @@ export function TsconfigPathsPlugin(): Plugin {
25
25
  name,
26
26
  setup({ onResolve }) {
27
27
  onResolve({ filter: /.*/ }, (args) => {
28
- // skip @gui packages - they should be externalized, not resolved via tsconfig
28
+ // skip @hanzogui packages - they should be externalized, not resolved via tsconfig
29
29
  if (args.path.startsWith('@hanzogui/')) {
30
30
  return null
31
31
  }
@@ -6,7 +6,7 @@ import * as t from '@babel/types'
6
6
  import findRoot from 'find-root'
7
7
 
8
8
  import { memoize } from '../helpers/memoize'
9
- import type { ExtractedAttr, GuiOptionsWithFileInfo, Ternary } from '../types'
9
+ import type { ExtractedAttr, HanzoguiOptionsWithFileInfo, Ternary } from '../types'
10
10
 
11
11
  // import { astToLiteral } from './literalToAst'
12
12
 
@@ -98,7 +98,7 @@ export function findComponentName(scope) {
98
98
  }
99
99
 
100
100
  export function isValidThemeHook(
101
- props: GuiOptionsWithFileInfo,
101
+ props: HanzoguiOptionsWithFileInfo,
102
102
  jsxPath: NodePath<t.JSXElement>,
103
103
  n: t.MemberExpression,
104
104
  sourcePath?: string
@@ -122,7 +122,7 @@ export function isValidThemeHook(
122
122
  }
123
123
 
124
124
  export const isInsideComponentPackage = (
125
- props: GuiOptionsWithFileInfo,
125
+ props: HanzoguiOptionsWithFileInfo,
126
126
  moduleName: string
127
127
  ) => {
128
128
  return getValidComponentsPaths(props).some((path) => {
@@ -130,14 +130,17 @@ export const isInsideComponentPackage = (
130
130
  })
131
131
  }
132
132
 
133
- export const isComponentPackage = (props: GuiOptionsWithFileInfo, srcName: string) => {
133
+ export const isComponentPackage = (
134
+ props: HanzoguiOptionsWithFileInfo,
135
+ srcName: string
136
+ ) => {
134
137
  return getValidComponentsPaths(props).some((path) => {
135
138
  return srcName.startsWith(path)
136
139
  })
137
140
  }
138
141
 
139
142
  export function getValidComponent(
140
- props: GuiOptionsWithFileInfo,
143
+ props: HanzoguiOptionsWithFileInfo,
141
144
  moduleName: string,
142
145
  componentName: string
143
146
  ) {
@@ -158,7 +161,7 @@ export function getValidComponent(
158
161
  return null
159
162
  }
160
163
 
161
- export const isValidModule = (props: GuiOptionsWithFileInfo, moduleName: string) => {
164
+ export const isValidModule = (props: HanzoguiOptionsWithFileInfo, moduleName: string) => {
162
165
  if (typeof moduleName !== 'string') {
163
166
  throw new Error(`No module name`)
164
167
  }
@@ -172,7 +175,7 @@ export const isValidModule = (props: GuiOptionsWithFileInfo, moduleName: string)
172
175
  }
173
176
 
174
177
  export const getValidImport = (
175
- props: GuiOptionsWithFileInfo,
178
+ props: HanzoguiOptionsWithFileInfo,
176
179
  moduleName: string,
177
180
  componentName?: string
178
181
  ) => {
@@ -184,7 +187,7 @@ export const getValidImport = (
184
187
  }
185
188
 
186
189
  export const isValidImport = (
187
- props: GuiOptionsWithFileInfo,
190
+ props: HanzoguiOptionsWithFileInfo,
188
191
  moduleName: string,
189
192
  componentName?: string
190
193
  ) => {
@@ -194,12 +197,12 @@ export const isValidImport = (
194
197
  return Boolean(getValidImport(props, moduleName, componentName))
195
198
  }
196
199
 
197
- const getValidComponentPackages = memoize((props: GuiOptionsWithFileInfo) => {
198
- // just always look for `gui` and `@hanzogui/core`
199
- return [...new Set(['@hanzogui/core', '@hanzo/gui', ...(props.components || [])])]
200
+ const getValidComponentPackages = memoize((props: HanzoguiOptionsWithFileInfo) => {
201
+ // just always look for `hanzogui` and `@hanzogui/core`
202
+ return [...new Set(['@hanzogui/core', 'hanzogui', ...(props.components || [])])]
200
203
  })
201
204
 
202
- export const getValidComponentsPaths = memoize((props: GuiOptionsWithFileInfo) => {
205
+ export const getValidComponentsPaths = memoize((props: HanzoguiOptionsWithFileInfo) => {
203
206
  return getValidComponentPackages(props).flatMap((pkg) => {
204
207
  const root = findRoot(pkg)
205
208
  const based = basename(root)
@@ -1,31 +1,31 @@
1
1
  import type { NodePath } from '@babel/traverse'
2
2
  import * as t from '@babel/types'
3
- import type { GuiInternalConfig } from '@hanzogui/core'
3
+ import type { HanzoguiInternalConfig } from '@hanzogui/core'
4
4
  import * as core from '@hanzogui/core'
5
5
  import type { ViewStyle } from 'react-native'
6
6
 
7
- import { requireGuiCore } from '../helpers/requireGuiCore'
8
- import type { StyleObject, GuiOptionsWithFileInfo, Ternary } from '../types'
7
+ import { requireHanzoguiCore } from '../helpers/requireHanzoguiCore'
8
+ import type { StyleObject, HanzoguiOptionsWithFileInfo, Ternary } from '../types'
9
9
  import { isPresent, isValidImport } from './extractHelpers'
10
10
 
11
11
  export function extractMediaStyle(
12
- props: GuiOptionsWithFileInfo,
12
+ props: HanzoguiOptionsWithFileInfo,
13
13
  ternary: Ternary,
14
14
  jsxPath: NodePath<t.JSXElement>,
15
- guiConfig: GuiInternalConfig,
15
+ hanzoguiConfig: HanzoguiInternalConfig,
16
16
  sourcePath: string,
17
17
  importance = 0,
18
18
  shouldPrintDebug: boolean | 'verbose' = false
19
19
  ) {
20
- const { getCSSStylesAtomic } = requireGuiCore('web')
20
+ const { getCSSStylesAtomic } = requireHanzoguiCore('web')
21
21
  const mt = getMediaQueryTernary(props, ternary, jsxPath, sourcePath)
22
22
  if (!mt) {
23
23
  return null
24
24
  }
25
25
  const { key } = mt
26
- const mq = guiConfig.media[key]
26
+ const mq = hanzoguiConfig.media[key]
27
27
  if (!mq) {
28
- console.error(`Media query "${key}" not found: ${Object.keys(guiConfig.media)}`)
28
+ console.error(`Media query "${key}" not found: ${Object.keys(hanzoguiConfig.media)}`)
29
29
  return null
30
30
  }
31
31
  const getStyleObj = (styleObj: ViewStyle | null, negate = false) => {
@@ -40,7 +40,7 @@ export function extractMediaStyle(
40
40
  return null
41
41
  }
42
42
  // for now order first strongest
43
- const mediaKeys = Object.keys(guiConfig.media)
43
+ const mediaKeys = Object.keys(hanzoguiConfig.media)
44
44
  const mediaKeyPrecendence = mediaKeys.reduce((acc, cur, i) => {
45
45
  acc[cur] = new Array(importance + 1).fill(':root').join('')
46
46
  return acc
@@ -54,7 +54,13 @@ export function extractMediaStyle(
54
54
  const styles = getCSSStylesAtomic(styleObj as any)
55
55
 
56
56
  const singleMediaStyles = styles.map((style) => {
57
- const mediaStyle = core.createMediaStyle(style, key, guiConfig.media, true, negate)
57
+ const mediaStyle = core.createMediaStyle(
58
+ style,
59
+ key,
60
+ hanzoguiConfig.media,
61
+ true,
62
+ negate
63
+ )
58
64
  const className = `.${mediaStyle[core.StyleObjectIdentifier]}`
59
65
  return {
60
66
  ...mediaStyle,
@@ -79,7 +85,7 @@ export function extractMediaStyle(
79
85
  }
80
86
 
81
87
  function getMediaQueryTernary(
82
- props: GuiOptionsWithFileInfo,
88
+ props: HanzoguiOptionsWithFileInfo,
83
89
  ternary: Ternary,
84
90
  jsxPath: NodePath<t.JSXElement>,
85
91
  sourcePath: string
@@ -128,7 +134,7 @@ function getMediaQueryTernary(
128
134
  }
129
135
 
130
136
  function getMediaInfoFromExpression(
131
- props: GuiOptionsWithFileInfo,
137
+ props: HanzoguiOptionsWithFileInfo,
132
138
  test: t.Expression,
133
139
  jsxPath: NodePath<t.JSXElement>,
134
140
  sourcePath: string,
@@ -167,7 +173,7 @@ function getMediaInfoFromExpression(
167
173
  }
168
174
 
169
175
  export function isValidMediaCall(
170
- props: GuiOptionsWithFileInfo,
176
+ props: HanzoguiOptionsWithFileInfo,
171
177
  jsxPath: NodePath<t.JSXElement>,
172
178
  init: t.Expression,
173
179
  sourcePath: string
@@ -4,8 +4,8 @@ import * as t from '@babel/types'
4
4
  import { mergeProps, StyleObjectIdentifier, StyleObjectRules } from '@hanzogui/web'
5
5
  import * as path from 'node:path'
6
6
  import * as util from 'node:util'
7
- import { requireGuiCore } from '../helpers/requireGuiCore'
8
- import type { StyleObject, GuiOptions, Ternary } from '../types'
7
+ import { requireHanzoguiCore } from '../helpers/requireHanzoguiCore'
8
+ import type { StyleObject, HanzoguiOptions, Ternary } from '../types'
9
9
  import { babelParse } from './babelParse'
10
10
  import type { Extractor } from './createExtractor'
11
11
  import { createLogger } from './createLogger'
@@ -37,7 +37,7 @@ export type ExtractToClassNamesProps = {
37
37
  extractor: Extractor
38
38
  source: string | Buffer
39
39
  sourcePath?: string
40
- options: GuiOptions
40
+ options: HanzoguiOptions
41
41
  shouldPrintDebug: boolean | 'verbose'
42
42
  }
43
43
 
@@ -55,7 +55,7 @@ export async function extractToClassNames({
55
55
  shouldPrintDebug,
56
56
  }: ExtractToClassNamesProps): Promise<ExtractedResponse | null> {
57
57
  const tm = timer()
58
- const { getCSSStylesAtomic, createMediaStyle } = requireGuiCore('web')
58
+ const { getCSSStylesAtomic, createMediaStyle } = requireHanzoguiCore('web')
59
59
 
60
60
  if (sourcePath.includes('node_modules')) {
61
61
  return null
@@ -78,9 +78,9 @@ export async function extractToClassNames({
78
78
  console.warn(`${sourcePath.slice(0, 100)} - bad filename.`)
79
79
  }
80
80
 
81
- if (!options.disableExtraction && !options['_disableLoadGui']) {
81
+ if (!options.disableExtraction && !options['_disableLoadHanzogui']) {
82
82
  // dont include loading in timing of parsing (one time cost)
83
- await extractor.loadGui(options)
83
+ await extractor.loadHanzogui(options)
84
84
  }
85
85
 
86
86
  const printLog = createLogger(sourcePath, options)
@@ -98,7 +98,7 @@ export async function extractToClassNames({
98
98
  tm.mark(`babel-parse`, shouldPrintDebug === 'verbose')
99
99
 
100
100
  const cssMap = new Map<string, { css: string; commentTexts: string[] }>()
101
- const guiConfig = extractor.getGui()!
101
+ const hanzoguiConfig = extractor.getHanzogui()!
102
102
 
103
103
  const res = await extractor.parse(ast, {
104
104
  shouldPrintDebug,
@@ -208,7 +208,7 @@ export async function extractToClassNames({
208
208
  const mediaStyle = createMediaStyle(
209
209
  style,
210
210
  mediaName,
211
- extractor.getGui()!.media,
211
+ extractor.getHanzogui()!.media,
212
212
  mediaType,
213
213
  false,
214
214
  mediaStylesSeen
@@ -218,11 +218,11 @@ export async function extractToClassNames({
218
218
  continue
219
219
  }
220
220
 
221
- if (mediaName in guiConfig.media) {
221
+ if (mediaName in hanzoguiConfig.media) {
222
222
  const mediaStyle = createMediaStyle(
223
223
  style,
224
224
  mediaName,
225
- extractor.getGui()!.media,
225
+ extractor.getHanzogui()!.media,
226
226
  true,
227
227
  false,
228
228
  mediaStylesSeen
@@ -284,7 +284,7 @@ export async function extractToClassNames({
284
284
  parserProps,
285
285
  attr.value,
286
286
  jsxPath,
287
- extractor.getGui()!,
287
+ extractor.getHanzogui()!,
288
288
  sourcePath || '',
289
289
  mediaStylesSeen++,
290
290
  shouldPrintDebug