@hanzogui/static 7.0.0 → 7.3.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 (99) hide show
  1. package/LICENSE +40 -19
  2. package/dist/check-dep-versions.cjs +1 -1
  3. package/dist/checkDeps.cjs +11 -11
  4. package/dist/constants.cjs +2 -2
  5. package/dist/exports.cjs +2 -2
  6. package/dist/extractor/bundle.cjs +6 -6
  7. package/dist/extractor/bundleConfig.cjs +45 -45
  8. package/dist/extractor/createExtractor.cjs +39 -39
  9. package/dist/extractor/createLogger.cjs +1 -1
  10. package/dist/extractor/extractHelpers.cjs +1 -1
  11. package/dist/extractor/extractMediaStyle.cjs +7 -7
  12. package/dist/extractor/extractToClassNames.cjs +9 -9
  13. package/dist/extractor/extractToNative.cjs +7 -7
  14. package/dist/extractor/{getHanzoguiConfigPathFromOptionsConfig.cjs → getGuiConfigPathFromOptionsConfig.cjs} +5 -5
  15. package/dist/extractor/getPrefixLogs.cjs +1 -1
  16. package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
  17. package/dist/extractor/{loadHanzogui.cjs → loadGui.cjs} +65 -65
  18. package/dist/extractor/regenerateConfig.cjs +20 -20
  19. package/dist/extractor/{watchHanzoguiConfig.cjs → watchGuiConfig.cjs} +15 -15
  20. package/dist/getPragmaOptions.cjs +6 -6
  21. package/dist/helpers/{requireHanzoguiCore.cjs → requireGuiCore.cjs} +12 -12
  22. package/dist/registerRequire.cjs +20 -20
  23. package/dist/worker.cjs +3 -3
  24. package/package.json +25 -24
  25. package/src/check-dep-versions.ts +1 -1
  26. package/src/checkDeps.ts +27 -27
  27. package/src/constants.ts +2 -2
  28. package/src/exports.ts +2 -2
  29. package/src/extractor/bundle.ts +9 -9
  30. package/src/extractor/bundleConfig.ts +56 -56
  31. package/src/extractor/createEvaluator.ts +2 -2
  32. package/src/extractor/createExtractor.ts +55 -55
  33. package/src/extractor/createLogger.ts +3 -3
  34. package/src/extractor/extractHelpers.ts +12 -12
  35. package/src/extractor/extractMediaStyle.ts +13 -13
  36. package/src/extractor/extractToClassNames.ts +11 -11
  37. package/src/extractor/extractToNative.ts +13 -13
  38. package/src/extractor/{getHanzoguiConfigPathFromOptionsConfig.ts → getGuiConfigPathFromOptionsConfig.ts} +3 -3
  39. package/src/extractor/getPrefixLogs.ts +3 -3
  40. package/src/extractor/getStaticBindingsForScope.ts +2 -2
  41. package/src/extractor/{loadHanzogui.ts → loadGui.ts} +85 -85
  42. package/src/extractor/regenerateConfig.ts +23 -23
  43. package/src/extractor/{watchHanzoguiConfig.ts → watchGuiConfig.ts} +10 -10
  44. package/src/getPragmaOptions.ts +6 -6
  45. package/src/helpers/requireGuiCore.ts +28 -0
  46. package/src/registerRequire.ts +27 -27
  47. package/src/server.ts +2 -2
  48. package/src/types.ts +10 -10
  49. package/src/worker.ts +7 -7
  50. package/types/constants.d.ts.map +1 -1
  51. package/types/exports.d.ts +2 -2
  52. package/types/exports.d.ts.map +1 -1
  53. package/types/extractor/bundle.d.ts +2 -2
  54. package/types/extractor/bundle.d.ts.map +1 -1
  55. package/types/extractor/bundleConfig.d.ts +12 -12
  56. package/types/extractor/bundleConfig.d.ts.map +1 -1
  57. package/types/extractor/createEvaluator.d.ts +2 -2
  58. package/types/extractor/createEvaluator.d.ts.map +1 -1
  59. package/types/extractor/createExtractor.d.ts +5 -5
  60. package/types/extractor/createExtractor.d.ts.map +1 -1
  61. package/types/extractor/createLogger.d.ts +2 -2
  62. package/types/extractor/createLogger.d.ts.map +1 -1
  63. package/types/extractor/extractHelpers.d.ts +8 -8
  64. package/types/extractor/extractHelpers.d.ts.map +1 -1
  65. package/types/extractor/extractMediaStyle.d.ts +4 -4
  66. package/types/extractor/extractMediaStyle.d.ts.map +1 -1
  67. package/types/extractor/extractToClassNames.d.ts +2 -2
  68. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  69. package/types/extractor/extractToNative.d.ts +3 -3
  70. package/types/extractor/extractToNative.d.ts.map +1 -1
  71. package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +3 -0
  72. package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +1 -0
  73. package/types/extractor/getPrefixLogs.d.ts +2 -2
  74. package/types/extractor/getPrefixLogs.d.ts.map +1 -1
  75. package/types/extractor/loadGui.d.ts +22 -0
  76. package/types/extractor/loadGui.d.ts.map +1 -0
  77. package/types/extractor/regenerateConfig.d.ts +4 -4
  78. package/types/extractor/regenerateConfig.d.ts.map +1 -1
  79. package/types/extractor/watchGuiConfig.d.ts +5 -0
  80. package/types/extractor/watchGuiConfig.d.ts.map +1 -0
  81. package/types/helpers/requireGuiCore.d.ts +3 -0
  82. package/types/helpers/requireGuiCore.d.ts.map +1 -0
  83. package/types/registerRequire.d.ts +3 -3
  84. package/types/registerRequire.d.ts.map +1 -1
  85. package/types/server.d.ts +2 -2
  86. package/types/server.d.ts.map +1 -1
  87. package/types/types.d.ts +10 -10
  88. package/types/types.d.ts.map +1 -1
  89. package/types/worker.d.ts +4 -4
  90. package/types/worker.d.ts.map +1 -1
  91. package/src/helpers/requireHanzoguiCore.ts +0 -28
  92. package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +0 -3
  93. package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +0 -1
  94. package/types/extractor/loadHanzogui.d.ts +0 -22
  95. package/types/extractor/loadHanzogui.d.ts.map +0 -1
  96. package/types/extractor/watchHanzoguiConfig.d.ts +0 -5
  97. package/types/extractor/watchHanzoguiConfig.d.ts.map +0 -1
  98. package/types/helpers/requireHanzoguiCore.d.ts +0 -3
  99. package/types/helpers/requireHanzoguiCore.d.ts.map +0 -1
@@ -6,12 +6,12 @@ import template from '@babel/template'
6
6
  import * as t from '@babel/types'
7
7
  import { basename } from 'node:path'
8
8
  import { getPragmaOptions } from '../getPragmaOptions'
9
- import type { HanzoguiOptions } from '../types'
9
+ import type { GuiOptions } from '../types'
10
10
  import { createExtractor } from './createExtractor'
11
11
  import { createLogger } from './createLogger'
12
12
  import { isSimpleSpread } from './extractHelpers'
13
13
  import { literalToAst } from './literalToAst'
14
- import { loadHanzoguiBuildConfigSync } from './loadHanzogui'
14
+ import { loadGuiBuildConfigSync } from './loadGui'
15
15
 
16
16
  const importNativeView = template(`
17
17
  const __ReactNativeView = require('react-native').View;
@@ -26,12 +26,12 @@ const importWithStyle = template.ast(`import { _withStableStyle } from '@hanzogu
26
26
 
27
27
  const extractor = createExtractor({ platform: 'native' })
28
28
 
29
- let hanzoguiBuildOptionsLoaded: HanzoguiOptions | null
29
+ let guiBuildOptionsLoaded: GuiOptions | null
30
30
 
31
31
  export function extractToNative(
32
32
  sourceFileName: string,
33
33
  sourceCode: string,
34
- options: HanzoguiOptions
34
+ options: GuiOptions
35
35
  ): BabelFileResult {
36
36
  const ast = parse(sourceCode, {
37
37
  sourceType: 'module',
@@ -55,15 +55,15 @@ export function extractToNative(
55
55
  }
56
56
 
57
57
  export function getBabelPlugin() {
58
- return declare((api, options: HanzoguiOptions) => {
58
+ return declare((api, options: GuiOptions) => {
59
59
  api.assertVersion(7)
60
60
  return getBabelParseDefinition(options)
61
61
  })
62
62
  }
63
63
 
64
- export function getBabelParseDefinition(options: HanzoguiOptions) {
64
+ export function getBabelParseDefinition(options: GuiOptions) {
65
65
  return {
66
- name: 'hanzogui',
66
+ name: 'gui',
67
67
 
68
68
  visitor: {
69
69
  Program: {
@@ -106,16 +106,16 @@ export function getBabelParseDefinition(options: HanzoguiOptions) {
106
106
  }
107
107
 
108
108
  if (!options.config && !options.components) {
109
- // if no config/components given try and load from the hanzogui.build.ts file
110
- hanzoguiBuildOptionsLoaded ||= loadHanzoguiBuildConfigSync({})
109
+ // if no config/components given try and load from the gui.build.ts file
110
+ guiBuildOptionsLoaded ||= loadGuiBuildConfigSync({})
111
111
  }
112
112
 
113
113
  const finalOptions = {
114
114
  // @ts-ignore just in case they leave it out
115
115
  platform: 'native',
116
- ...hanzoguiBuildOptionsLoaded,
116
+ ...guiBuildOptionsLoaded,
117
117
  ...options,
118
- } satisfies HanzoguiOptions
118
+ } satisfies GuiOptions
119
119
 
120
120
  const printLog = createLogger(sourcePath, finalOptions)
121
121
 
@@ -419,7 +419,7 @@ export function getBabelParseDefinition(options: HanzoguiOptions) {
419
419
  if (message.includes('Unexpected return value from visitor method')) {
420
420
  message = 'Unexpected return value from visitor method'
421
421
  }
422
- console.warn('Error in Hanzogui parse, skipping', message, err.stack)
422
+ console.warn('Error in Gui parse, skipping', message, err.stack)
423
423
  return
424
424
  }
425
425
  }
@@ -466,7 +466,7 @@ function assertValidTag(node: t.JSXOpeningElement) {
466
466
  if (node.attributes.find((x) => x.type === 'JSXAttribute' && x.name.name === 'style')) {
467
467
  // we can just deopt here instead and log warning
468
468
  // need to make onExtractTag have a special catch error or similar
469
- if (process.env.DEBUG?.startsWith('hanzogui')) {
469
+ if (process.env.DEBUG?.startsWith('gui')) {
470
470
  console.warn('⚠️ Cannot pass style attribute to extracted style')
471
471
  }
472
472
  }
@@ -1,10 +1,10 @@
1
1
  import { isAbsolute, join } from 'node:path'
2
2
 
3
3
  import { statSync } from 'node:fs'
4
- import type { HanzoguiOptions } from '../types'
4
+ import type { GuiOptions } from '../types'
5
5
 
6
- export function getHanzoguiConfigPathFromOptionsConfig(
7
- config: NonNullable<HanzoguiOptions['config']>
6
+ export function getGuiConfigPathFromOptionsConfig(
7
+ config: NonNullable<GuiOptions['config']>
8
8
  ) {
9
9
  if (isAbsolute(config)) {
10
10
  return config
@@ -1,9 +1,9 @@
1
1
  import { Color, colorString } from '@hanzogui/cli-color'
2
- import type { HanzoguiOptions } from '../types'
2
+ import type { GuiOptions } from '../types'
3
3
 
4
- export function getPrefixLogs(options?: HanzoguiOptions) {
4
+ export function getPrefixLogs(options?: GuiOptions) {
5
5
  return (
6
6
  options?.prefixLogs ??
7
- ` 🐥 [hanzogui] ${colorString(Color.FgYellow, options?.platform || 'web')}`
7
+ ` 🐥 [gui] ${colorString(Color.FgYellow, options?.platform || 'web')}`
8
8
  )
9
9
  }
@@ -137,9 +137,9 @@ export async function getStaticBindingsForScope(
137
137
  } catch (err: any) {
138
138
  if (shouldPrintDebug) {
139
139
  console.warn(
140
- ` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=hanzogui for more)`
140
+ ` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=gui for more)`
141
141
  )
142
- } else if (process.env.DEBUG?.startsWith('hanzogui')) {
142
+ } else if (process.env.DEBUG?.startsWith('gui')) {
143
143
  console.info(`Error in partial evaluation`, err.message, err.stack)
144
144
  }
145
145
  }
@@ -1,43 +1,43 @@
1
1
  import { basename, dirname, extname, join, relative, resolve } from 'node:path'
2
2
  // @ts-ignore why
3
3
  import { Color, colorLog } from '@hanzogui/cli-color'
4
- import type { CLIResolvedOptions, CLIUserOptions, HanzoguiOptions } from '@hanzogui/types'
5
- import type { HanzoguiInternalConfig } from '@hanzogui/web'
4
+ import type { CLIResolvedOptions, CLIUserOptions, GuiOptions } from '@hanzogui/types'
5
+ import type { GuiInternalConfig } from '@hanzogui/web'
6
6
  import esbuild from 'esbuild'
7
7
  import * as esbuildWasm from 'esbuild-wasm'
8
8
  import * as fsExtra from 'fs-extra'
9
9
 
10
10
  import { SHOULD_DEBUG } from '../constants'
11
- import { requireHanzoguiCore } from '../helpers/requireHanzoguiCore'
11
+ import { requireGuiCore } from '../helpers/requireGuiCore'
12
12
  import { getNameToPaths, registerRequire } from '../registerRequire'
13
13
  import {
14
- type HanzoguiProjectInfo,
14
+ type GuiProjectInfo,
15
15
  getBundledConfig,
16
16
  getLoadedConfig,
17
17
  hasBundledConfigChanged,
18
18
  loadComponentsSync,
19
- writeHanzoguiCSS,
19
+ writeGuiCSS,
20
20
  } from './bundleConfig'
21
- import { getHanzoguiConfigPathFromOptionsConfig } from './getHanzoguiConfigPathFromOptionsConfig'
21
+ import { getGuiConfigPathFromOptionsConfig } from './getGuiConfigPathFromOptionsConfig'
22
22
  import {
23
- generateHanzoguiThemes,
23
+ generateGuiThemes,
24
24
  regenerateConfig,
25
25
  regenerateConfigSync,
26
26
  } from './regenerateConfig'
27
27
 
28
- const getFilledOptions = (propsIn: Partial<HanzoguiOptions>): HanzoguiOptions => ({
28
+ const getFilledOptions = (propsIn: Partial<GuiOptions>): GuiOptions => ({
29
29
  // defaults
30
- platform: (process.env.TAMAGUI_TARGET as any) || 'web',
31
- config: 'hanzogui.config.ts',
32
- components: ['hanzogui'],
33
- ...(propsIn as Partial<HanzoguiOptions>),
30
+ platform: (process.env.GUI_TARGET as any) || 'web',
31
+ config: 'gui.config.ts',
32
+ components: ['gui'],
33
+ ...(propsIn as Partial<GuiOptions>),
34
34
  })
35
35
 
36
36
  let isLoadingPromise: null | Promise<any>
37
37
 
38
- export async function loadHanzogui(
39
- propsIn: Partial<HanzoguiOptions>
40
- ): Promise<HanzoguiProjectInfo | null> {
38
+ export async function loadGui(
39
+ propsIn: Partial<GuiOptions>
40
+ ): Promise<GuiProjectInfo | null> {
41
41
  if (isLoadingPromise) return await isLoadingPromise
42
42
 
43
43
  let resolvePromise
@@ -53,7 +53,7 @@ export async function loadHanzogui(
53
53
  const bundleInfo = await getBundledConfig(props)
54
54
  if (!bundleInfo) {
55
55
  console.warn(
56
- `No bundled config generated, maybe an error in bundling. Set DEBUG=hanzogui and re-run to get logs.`
56
+ `No bundled config generated, maybe an error in bundling. Set DEBUG=gui and re-run to get logs.`
57
57
  )
58
58
  resolvePromise(null)
59
59
  return null
@@ -62,11 +62,11 @@ export async function loadHanzogui(
62
62
  // this affects the bundled config so run it first
63
63
  await generateThemesAndLog(props)
64
64
 
65
- // if they accidently pass in a config without createHanzogui called,call it
66
- const maybeHanzoguiConfig = bundleInfo.hanzoguiConfig as HanzoguiInternalConfig
67
- if (maybeHanzoguiConfig && !maybeHanzoguiConfig.parsed) {
68
- const { createHanzogui } = requireHanzoguiCore(props.platform || 'web')
69
- bundleInfo.hanzoguiConfig = createHanzogui(bundleInfo.hanzoguiConfig as any)
65
+ // if they accidently pass in a config without createGui called,call it
66
+ const maybeGuiConfig = bundleInfo.guiConfig as GuiInternalConfig
67
+ if (maybeGuiConfig && !maybeGuiConfig.parsed) {
68
+ const { createGui } = requireGuiCore(props.platform || 'web')
69
+ bundleInfo.guiConfig = createGui(bundleInfo.guiConfig as any)
70
70
  }
71
71
 
72
72
  if (!hasBundledConfigChanged()) {
@@ -89,20 +89,20 @@ export async function loadHanzogui(
89
89
  // debounce a bit
90
90
  let waiting = false
91
91
 
92
- export const generateThemesAndLog = async (options: HanzoguiOptions, force = false) => {
92
+ export const generateThemesAndLog = async (options: GuiOptions, force = false) => {
93
93
  if (waiting) return
94
94
  if (!options.themeBuilder) return
95
95
  try {
96
96
  waiting = true
97
97
  await new Promise((res) => setTimeout(res, 30))
98
- const didGenerate = await generateHanzoguiThemes(options, force)
98
+ const didGenerate = await generateGuiThemes(options, force)
99
99
 
100
100
  // only logs when changed
101
101
  if (didGenerate) {
102
102
  const whitespaceBefore = ` `
103
103
  colorLog(
104
104
  Color.FgYellow,
105
- `${whitespaceBefore}➡ [hanzogui] generated themes: ${relative(
105
+ `${whitespaceBefore}➡ [gui] generated themes: ${relative(
106
106
  process.cwd(),
107
107
  options.themeBuilder.output
108
108
  )}`
@@ -111,7 +111,7 @@ export const generateThemesAndLog = async (options: HanzoguiOptions, force = fal
111
111
  if (options.outputCSS) {
112
112
  const loadedConfig = getLoadedConfig()
113
113
  if (loadedConfig) {
114
- await writeHanzoguiCSS(options.outputCSS, loadedConfig)
114
+ await writeGuiCSS(options.outputCSS, loadedConfig)
115
115
  }
116
116
  }
117
117
  }
@@ -120,20 +120,20 @@ export const generateThemesAndLog = async (options: HanzoguiOptions, force = fal
120
120
  }
121
121
  }
122
122
 
123
- const last: Record<string, HanzoguiProjectInfo | null> = {}
123
+ const last: Record<string, GuiProjectInfo | null> = {}
124
124
  const lastVersion: Record<string, string> = {}
125
125
 
126
126
  // esbuild-wasm state - initialized once per process
127
127
  let esbuildWasmInitialized = false
128
128
 
129
129
  /**
130
- * Load hanzogui.build.ts config using esbuild-wasm transform
130
+ * Load gui.build.ts config using esbuild-wasm transform
131
131
  * Uses WASM to avoid native esbuild service lifecycle issues (EPIPE errors)
132
132
  */
133
- export async function loadHanzoguiBuildConfigAsync(
134
- hanzoguiOptions: Partial<HanzoguiOptions> | undefined
135
- ): Promise<HanzoguiOptions> {
136
- const buildFilePath = hanzoguiOptions?.buildFile ?? './hanzogui.build.ts'
133
+ export async function loadGuiBuildConfigAsync(
134
+ guiOptions: Partial<GuiOptions> | undefined
135
+ ): Promise<GuiOptions> {
136
+ const buildFilePath = guiOptions?.buildFile ?? './gui.build.ts'
137
137
  const absolutePath =
138
138
  buildFilePath[0] === '.' ? join(process.cwd(), buildFilePath) : buildFilePath
139
139
 
@@ -166,36 +166,36 @@ export async function loadHanzoguiBuildConfigAsync(
166
166
  throw new Error(`No default export found in ${buildFilePath}: ${out}`)
167
167
  }
168
168
 
169
- hanzoguiOptions = {
170
- ...hanzoguiOptions,
169
+ guiOptions = {
170
+ ...guiOptions,
171
171
  ...out,
172
172
  }
173
173
  } catch (err) {
174
- console.error(`[hanzogui] Error loading ${buildFilePath}:`, err)
174
+ console.error(`[gui] Error loading ${buildFilePath}:`, err)
175
175
  throw err
176
176
  }
177
177
  }
178
178
 
179
- if (!hanzoguiOptions) {
179
+ if (!guiOptions) {
180
180
  throw new Error(
181
- `No hanzogui build options found either via input props or at hanzogui.build.ts`
181
+ `No gui build options found either via input props or at gui.build.ts`
182
182
  )
183
183
  }
184
184
 
185
185
  return {
186
- config: 'hanzogui.config.ts',
187
- components: ['hanzogui', '@hanzogui/core'],
188
- ...hanzoguiOptions,
189
- } as HanzoguiOptions
186
+ config: 'gui.config.ts',
187
+ components: ['gui', '@hanzogui/core'],
188
+ ...guiOptions,
189
+ } as GuiOptions
190
190
  }
191
191
 
192
192
  /**
193
- * @deprecated Use loadHanzoguiBuildConfigAsync instead to avoid EPIPE errors
193
+ * @deprecated Use loadGuiBuildConfigAsync instead to avoid EPIPE errors
194
194
  */
195
- export function loadHanzoguiBuildConfigSync(
196
- hanzoguiOptions: Partial<HanzoguiOptions> | undefined
195
+ export function loadGuiBuildConfigSync(
196
+ guiOptions: Partial<GuiOptions> | undefined
197
197
  ) {
198
- const buildFilePath = hanzoguiOptions?.buildFile ?? './hanzogui.build.ts'
198
+ const buildFilePath = guiOptions?.buildFile ?? './gui.build.ts'
199
199
  if (fsExtra.existsSync(buildFilePath)) {
200
200
  const registered = registerRequire('web')
201
201
  try {
@@ -206,35 +206,35 @@ export function loadHanzoguiBuildConfigSync(
206
206
  throw new Error(`No default export found in ${buildFilePath}: ${out}`)
207
207
  }
208
208
 
209
- hanzoguiOptions = {
210
- ...hanzoguiOptions,
209
+ guiOptions = {
210
+ ...guiOptions,
211
211
  ...out,
212
212
  }
213
213
  } finally {
214
214
  registered.unregister()
215
215
  }
216
216
  }
217
- if (!hanzoguiOptions) {
217
+ if (!guiOptions) {
218
218
  throw new Error(
219
- `No hanzogui build options found either via input props or at hanzogui.build.ts`
219
+ `No gui build options found either via input props or at gui.build.ts`
220
220
  )
221
221
  }
222
222
  return {
223
- config: 'hanzogui.config.ts',
224
- components: ['hanzogui', '@hanzogui/core'],
225
- ...hanzoguiOptions,
226
- } as HanzoguiOptions
223
+ config: 'gui.config.ts',
224
+ components: ['gui', '@hanzogui/core'],
225
+ ...guiOptions,
226
+ } as GuiOptions
227
227
  }
228
228
 
229
229
  // loads in-process using esbuild-register
230
- export function loadHanzoguiSync({
230
+ export function loadGuiSync({
231
231
  forceExports,
232
232
  cacheKey,
233
233
  ...propsIn
234
- }: Partial<HanzoguiOptions> & {
234
+ }: Partial<GuiOptions> & {
235
235
  forceExports?: boolean
236
236
  cacheKey?: string
237
- }): HanzoguiProjectInfo {
237
+ }): GuiProjectInfo {
238
238
  const key = JSON.stringify(propsIn)
239
239
 
240
240
  if (last[key] && !hasBundledConfigChanged()) {
@@ -250,7 +250,7 @@ export function loadHanzoguiSync({
250
250
  // lets shim require and avoid importing react-native + react-native-web
251
251
  // we just need to read the config around them
252
252
  process.env.IS_STATIC = 'is_static'
253
- process.env.TAMAGUI_IS_SERVER = 'true'
253
+ process.env.GUI_IS_SERVER = 'true'
254
254
 
255
255
  const { unregister } = registerRequire(props.platform || 'web', {
256
256
  proxyWormImports: !!forceExports,
@@ -262,18 +262,18 @@ export function loadHanzoguiSync({
262
262
 
263
263
  try {
264
264
  // config
265
- let hanzoguiConfig: HanzoguiInternalConfig | null = null
265
+ let guiConfig: GuiInternalConfig | null = null
266
266
  if (propsIn.config) {
267
- const configPath = getHanzoguiConfigPathFromOptionsConfig(propsIn.config)
267
+ const configPath = getGuiConfigPathFromOptionsConfig(propsIn.config)
268
268
  const exp = require(configPath)
269
269
 
270
270
  if (!exp || exp._isProxyWorm) {
271
271
  throw new Error(`Got a empty / proxied config!`)
272
272
  }
273
273
 
274
- hanzoguiConfig = (exp['default'] || exp['config'] || exp) as HanzoguiInternalConfig
274
+ guiConfig = (exp['default'] || exp['config'] || exp) as GuiInternalConfig
275
275
 
276
- if (!hanzoguiConfig || !hanzoguiConfig.parsed) {
276
+ if (!guiConfig || !guiConfig.parsed) {
277
277
  const confPath = require.resolve(configPath)
278
278
  throw new Error(`Can't find valid config in ${confPath}:
279
279
 
@@ -281,9 +281,9 @@ export function loadHanzoguiSync({
281
281
  }
282
282
 
283
283
  // set up core
284
- if (hanzoguiConfig) {
285
- const { createHanzogui } = requireHanzoguiCore(props.platform || 'web')
286
- createHanzogui(hanzoguiConfig as any)
284
+ if (guiConfig) {
285
+ const { createGui } = requireGuiCore(props.platform || 'web')
286
+ createGui(guiConfig as any)
287
287
  }
288
288
  }
289
289
 
@@ -292,7 +292,7 @@ export function loadHanzoguiSync({
292
292
  if (!components) {
293
293
  throw new Error(`No components loaded`)
294
294
  }
295
- if (process.env.DEBUG === 'hanzogui') {
295
+ if (process.env.DEBUG === 'gui') {
296
296
  console.info(`components`, components)
297
297
  }
298
298
 
@@ -302,14 +302,14 @@ export function loadHanzoguiSync({
302
302
 
303
303
  const info = {
304
304
  components,
305
- hanzoguiConfig,
305
+ guiConfig,
306
306
  nameToPaths: getNameToPaths(),
307
- } satisfies HanzoguiProjectInfo
307
+ } satisfies GuiProjectInfo
308
308
 
309
- if (hanzoguiConfig) {
309
+ if (guiConfig) {
310
310
  const { outputCSS } = props
311
311
  if (outputCSS) {
312
- writeHanzoguiCSS(outputCSS, hanzoguiConfig)
312
+ writeGuiCSS(outputCSS, guiConfig)
313
313
  }
314
314
 
315
315
  regenerateConfigSync(props, info)
@@ -325,7 +325,7 @@ export function loadHanzoguiSync({
325
325
  if (err instanceof Error) {
326
326
  if (!SHOULD_DEBUG && !forceExports) {
327
327
  console.warn(
328
- `Error loading hanzogui.config.ts (set DEBUG=hanzogui to see full stack), running hanzogui without custom config`
328
+ `Error loading gui.config.ts (set DEBUG=gui to see full stack), running gui without custom config`
329
329
  )
330
330
  console.info(`\n\n ${err.message}\n\n`)
331
331
  } else {
@@ -334,12 +334,12 @@ export function loadHanzoguiSync({
334
334
  }
335
335
  }
336
336
  } else {
337
- console.error(`Error loading hanzogui.config.ts`, err)
337
+ console.error(`Error loading gui.config.ts`, err)
338
338
  }
339
339
 
340
340
  return {
341
341
  components: [],
342
- hanzoguiConfig: null,
342
+ guiConfig: null,
343
343
  nameToPaths: {},
344
344
  }
345
345
  }
@@ -351,11 +351,11 @@ export function loadHanzoguiSync({
351
351
  export async function getOptions({
352
352
  root = process.cwd(),
353
353
  tsconfigPath = 'tsconfig.json',
354
- hanzoguiOptions,
354
+ guiOptions,
355
355
  host,
356
356
  debug,
357
357
  }: Partial<CLIUserOptions> = {}): Promise<CLIResolvedOptions> {
358
- const dotDir = join(root, '.hanzogui')
358
+ const dotDir = join(root, '.gui')
359
359
  let pkgJson = {}
360
360
 
361
361
  try {
@@ -371,18 +371,18 @@ export async function getOptions({
371
371
  pkgJson,
372
372
  debug,
373
373
  tsconfigPath,
374
- hanzoguiOptions: {
375
- platform: (process.env.TAMAGUI_TARGET as any) || 'web',
376
- components: ['hanzogui'],
377
- ...hanzoguiOptions,
374
+ guiOptions: {
375
+ platform: (process.env.GUI_TARGET as any) || 'web',
376
+ components: ['gui'],
377
+ ...guiOptions,
378
378
  config:
379
- hanzoguiOptions?.config ??
380
- (await getDefaultHanzoguiConfigPath(root, hanzoguiOptions?.config)),
379
+ guiOptions?.config ??
380
+ (await getDefaultGuiConfigPath(root, guiOptions?.config)),
381
381
  },
382
382
  paths: {
383
383
  root,
384
384
  dotDir,
385
- conf: join(dotDir, 'hanzogui.config.json'),
385
+ conf: join(dotDir, 'gui.config.json'),
386
386
  types: join(dotDir, 'types.json'),
387
387
  },
388
388
  }
@@ -393,7 +393,7 @@ export function resolveWebOrNativeSpecificEntry(entry: string) {
393
393
  const resolved = require.resolve(entry, { paths: [workspaceRoot] })
394
394
  const ext = extname(resolved)
395
395
  const fileName = basename(resolved).replace(ext, '')
396
- const specificExt = process.env.TAMAGUI_TARGET === 'web' ? 'web' : 'native'
396
+ const specificExt = process.env.GUI_TARGET === 'web' ? 'web' : 'native'
397
397
  const specificFile = join(dirname(resolved), fileName + '.' + specificExt + ext)
398
398
  if (fsExtra.existsSync(specificFile)) {
399
399
  return specificFile
@@ -401,10 +401,10 @@ export function resolveWebOrNativeSpecificEntry(entry: string) {
401
401
  return entry
402
402
  }
403
403
 
404
- const defaultPaths = ['hanzogui.config.ts', join('src', 'hanzogui.config.ts')]
404
+ const defaultPaths = ['gui.config.ts', join('src', 'gui.config.ts')]
405
405
  let hasWarnedOnce = false
406
406
 
407
- async function getDefaultHanzoguiConfigPath(root: string, configPath?: string) {
407
+ async function getDefaultGuiConfigPath(root: string, configPath?: string) {
408
408
  const searchPaths = [
409
409
  ...new Set(
410
410
  [configPath, ...defaultPaths].filter(Boolean).map((p) => join(root, p as string))
@@ -419,13 +419,13 @@ async function getDefaultHanzoguiConfigPath(root: string, configPath?: string) {
419
419
 
420
420
  if (!hasWarnedOnce) {
421
421
  hasWarnedOnce = true
422
- console.warn(`Warning: couldn't find hanzogui.config.ts in the following paths given configuration "${configPath}":
422
+ console.warn(`Warning: couldn't find gui.config.ts in the following paths given configuration "${configPath}":
423
423
  ${searchPaths.join(`\n `)}
424
424
  `)
425
425
  }
426
426
  }
427
427
 
428
- export type { HanzoguiProjectInfo }
428
+ export type { GuiProjectInfo }
429
429
 
430
430
  export async function esbuildWatchFiles(entry: string, onChanged: () => void) {
431
431
  let hasRunOnce = false