@hanzogui/static 4.4.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.
- package/LICENSE +40 -19
- package/dist/check-dep-versions.cjs +1 -1
- package/dist/checkDeps.cjs +5 -5
- package/dist/constants.cjs +2 -2
- package/dist/extractor/bundle.cjs +16 -35
- package/dist/extractor/bundleConfig.cjs +16 -16
- package/dist/extractor/createExtractor.cjs +7 -7
- package/dist/extractor/extractHelpers.cjs +1 -1
- package/dist/extractor/extractToNative.cjs +3 -3
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/loadGui.cjs +49 -93
- package/dist/extractor/regenerateConfig.cjs +2 -2
- package/dist/getPragmaOptions.cjs +1 -1
- package/dist/registerRequire.cjs +11 -11
- package/package.json +22 -21
- package/src/check-dep-versions.ts +1 -5
- package/src/checkDeps.ts +9 -11
- package/src/constants.ts +2 -2
- package/src/extractor/bundle.ts +5 -7
- package/src/extractor/bundleConfig.ts +16 -16
- package/src/extractor/createExtractor.ts +21 -14
- package/src/extractor/createLogger.ts +3 -1
- package/src/extractor/esbuildTsconfigPaths.ts +1 -1
- package/src/extractor/extractHelpers.ts +5 -2
- package/src/extractor/extractMediaStyle.ts +7 -1
- package/src/extractor/extractToNative.ts +3 -3
- package/src/extractor/getPrefixLogs.ts +1 -1
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/loadGui.ts +16 -13
- package/src/extractor/regenerateConfig.ts +17 -7
- package/src/getPragmaOptions.ts +1 -1
- package/src/registerRequire.ts +18 -20
- package/src/types.ts +4 -1
- package/src/worker.ts +1 -1
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/constants.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/createLogger.d.ts.map +1 -1
- package/types/extractor/extractHelpers.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/loadGui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/registerRequire.d.ts.map +1 -1
- package/types/types.d.ts.map +1 -1
- package/types/worker.d.ts +1 -1
|
@@ -134,7 +134,7 @@ const handleEsmFeaturesPlugin: esbuild.Plugin = {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
// skip most node_modules
|
|
137
|
-
if (args.path.includes('node_modules') && !args.path.includes('@
|
|
137
|
+
if (args.path.includes('node_modules') && !args.path.includes('@hanzogui')) {
|
|
138
138
|
return null
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -161,8 +161,8 @@ const handleEsmFeaturesPlugin: esbuild.Plugin = {
|
|
|
161
161
|
|
|
162
162
|
// stub files with top-level await - they're typically runtime-only
|
|
163
163
|
if (hasTopLevelAwait(contents, args.path)) {
|
|
164
|
-
if (process.env.DEBUG?.startsWith('
|
|
165
|
-
console.info(`[
|
|
164
|
+
if (process.env.DEBUG?.startsWith('gui')) {
|
|
165
|
+
console.info(`[gui] stubbing file with top-level await: ${args.path}`)
|
|
166
166
|
}
|
|
167
167
|
return {
|
|
168
168
|
// Keep this as an ESM-shaped stub so esbuild doesn't inline a top-level
|
|
@@ -297,7 +297,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
297
297
|
|
|
298
298
|
if (
|
|
299
299
|
process.env.NODE_ENV === 'development' &&
|
|
300
|
-
process.env.DEBUG?.startsWith('
|
|
300
|
+
process.env.DEBUG?.startsWith('gui')
|
|
301
301
|
) {
|
|
302
302
|
console.info(`Building config entry`, configEntry)
|
|
303
303
|
}
|
|
@@ -371,10 +371,10 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
371
371
|
colorLog(
|
|
372
372
|
Color.FgYellow,
|
|
373
373
|
`
|
|
374
|
-
➡ [
|
|
374
|
+
➡ [gui] built config, components, prompt (${Date.now() - start}ms)`
|
|
375
375
|
)
|
|
376
376
|
|
|
377
|
-
if (process.env.DEBUG?.startsWith('
|
|
377
|
+
if (process.env.DEBUG?.startsWith('gui')) {
|
|
378
378
|
colorLog(
|
|
379
379
|
Color.Dim,
|
|
380
380
|
`
|
|
@@ -427,7 +427,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
427
427
|
// check for ProxyWorm - indicates a module loading error
|
|
428
428
|
if (config._isProxyWorm) {
|
|
429
429
|
throw new Error(
|
|
430
|
-
`Got a proxied config - likely a module loading error. Set DEBUG=
|
|
430
|
+
`Got a proxied config - likely a module loading error. Set DEBUG=gui for details.`
|
|
431
431
|
)
|
|
432
432
|
}
|
|
433
433
|
|
|
@@ -459,7 +459,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
459
459
|
component.moduleName
|
|
460
460
|
|
|
461
461
|
if (!component.moduleName) {
|
|
462
|
-
if (process.env.DEBUG?.includes('
|
|
462
|
+
if (process.env.DEBUG?.includes('gui') || process.env.IS_GUI_DEV) {
|
|
463
463
|
console.warn(
|
|
464
464
|
`⚠️ no module name found: ${component.moduleName} ${JSON.stringify(
|
|
465
465
|
baseComponents
|
|
@@ -471,7 +471,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
471
471
|
|
|
472
472
|
if (
|
|
473
473
|
process.env.NODE_ENV === 'development' &&
|
|
474
|
-
process.env.DEBUG?.startsWith('
|
|
474
|
+
process.env.DEBUG?.startsWith('gui')
|
|
475
475
|
) {
|
|
476
476
|
console.info('Loaded components', components)
|
|
477
477
|
}
|
|
@@ -488,9 +488,9 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
488
488
|
return res
|
|
489
489
|
} catch (err: any) {
|
|
490
490
|
console.error(
|
|
491
|
-
`Error bundling gui config: ${err?.message} (run with DEBUG=
|
|
491
|
+
`Error bundling gui config: ${err?.message} (run with DEBUG=gui to see stack)`
|
|
492
492
|
)
|
|
493
|
-
if (process.env.DEBUG?.includes('
|
|
493
|
+
if (process.env.DEBUG?.includes('gui')) {
|
|
494
494
|
console.error(err.stack)
|
|
495
495
|
}
|
|
496
496
|
} finally {
|
|
@@ -502,7 +502,7 @@ export async function bundleConfig(props: GuiOptions) {
|
|
|
502
502
|
|
|
503
503
|
export async function writeGuiCSS(outputCSS: string, config: GuiInternalConfig) {
|
|
504
504
|
const flush = async () => {
|
|
505
|
-
colorLog(Color.FgYellow, ` ➡ [
|
|
505
|
+
colorLog(Color.FgYellow, ` ➡ [gui] output css: ${outputCSS}`)
|
|
506
506
|
await FS.writeFile(outputCSS, css)
|
|
507
507
|
}
|
|
508
508
|
|
|
@@ -624,7 +624,7 @@ export async function loadComponentsInner(
|
|
|
624
624
|
})
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
-
if (process.env.DEBUG === '
|
|
627
|
+
if (process.env.DEBUG === 'gui') {
|
|
628
628
|
console.info(`loadModule`, loadModule, format)
|
|
629
629
|
}
|
|
630
630
|
|
|
@@ -666,7 +666,7 @@ export async function loadComponentsInner(
|
|
|
666
666
|
} catch (err) {
|
|
667
667
|
console.info('babel err', err, writtenContents)
|
|
668
668
|
writtenContents = fileContents
|
|
669
|
-
if (process.env.DEBUG?.startsWith('
|
|
669
|
+
if (process.env.DEBUG?.startsWith('gui')) {
|
|
670
670
|
console.info(`Error parsing babel likely`, err)
|
|
671
671
|
}
|
|
672
672
|
|
|
@@ -779,7 +779,7 @@ export function loadComponentsInnerSync(
|
|
|
779
779
|
})
|
|
780
780
|
}
|
|
781
781
|
|
|
782
|
-
if (process.env.DEBUG === '
|
|
782
|
+
if (process.env.DEBUG === 'gui') {
|
|
783
783
|
console.info(`loadModule`, loadModule, require.resolve(loadModule))
|
|
784
784
|
}
|
|
785
785
|
|
|
@@ -814,7 +814,7 @@ export function loadComponentsInnerSync(
|
|
|
814
814
|
} catch (err) {
|
|
815
815
|
console.info('babel err', err, writtenContents)
|
|
816
816
|
writtenContents = fileContents
|
|
817
|
-
if (process.env.DEBUG?.startsWith('
|
|
817
|
+
if (process.env.DEBUG?.startsWith('gui')) {
|
|
818
818
|
console.info(`Error parsing babel likely`, err)
|
|
819
819
|
}
|
|
820
820
|
} finally {
|
|
@@ -217,7 +217,7 @@ export function createExtractor(
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
// we load
|
|
220
|
+
// we load gui 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
223
|
function loadSync(props: GuiOptions) {
|
|
@@ -384,7 +384,7 @@ export function createExtractor(
|
|
|
384
384
|
].join(' ')
|
|
385
385
|
)
|
|
386
386
|
}
|
|
387
|
-
if (process.env.DEBUG?.startsWith('
|
|
387
|
+
if (process.env.DEBUG?.startsWith('gui')) {
|
|
388
388
|
logger.info(
|
|
389
389
|
[
|
|
390
390
|
'loaded:',
|
|
@@ -401,7 +401,7 @@ export function createExtractor(
|
|
|
401
401
|
console.error(
|
|
402
402
|
`⛔️ Error: Missing "themes" in your gui.config file:
|
|
403
403
|
|
|
404
|
-
You may not need the compiler! Remember you can run
|
|
404
|
+
You may not need the compiler! Remember you can run Gui 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
|
|
|
@@ -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:
|
|
446
|
+
`Warning: Gui didn't find any valid components (DEBUG=gui for more)`
|
|
447
447
|
)
|
|
448
|
-
if (process.env.DEBUG === '
|
|
448
|
+
if (process.env.DEBUG === 'gui') {
|
|
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
|
|
490
|
+
// styled( is basically guaranteed to be gui 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
|
|
@@ -684,14 +684,14 @@ export function createExtractor(
|
|
|
684
684
|
if (foundNames) {
|
|
685
685
|
colorLog(
|
|
686
686
|
Color.FgYellow,
|
|
687
|
-
` |
|
|
687
|
+
` | Gui 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=
|
|
694
|
+
`skip optimize styled(${variableName}), unable to pre-process (DEBUG=gui 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
|
|
898
|
+
// validate its a proper import from gui (or internally inside gui)
|
|
899
899
|
const binding = traversePath.scope.getBinding(node.name.name)
|
|
900
900
|
let moduleName = ''
|
|
901
901
|
let dynamicComponent: { staticConfig: any } | null = null
|
|
@@ -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
|
|
974
|
+
logger.info(`\n - No Gui 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
|
|
1107
|
+
...(guiConfig?.animations.isReactNative
|
|
1108
|
+
? ['enterStyle', 'exitStyle']
|
|
1109
|
+
: []),
|
|
1108
1110
|
])
|
|
1109
1111
|
|
|
1110
1112
|
const inlineWhenUnflattened = new Set(staticConfig.inlineWhenUnflattened || [])
|
|
@@ -1286,9 +1288,9 @@ export function createExtractor(
|
|
|
1286
1288
|
|
|
1287
1289
|
const name = attribute.name.name
|
|
1288
1290
|
|
|
1289
|
-
// in
|
|
1291
|
+
// in gui 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
|
|
1293
|
+
// its not used often when using gui so not optimizing it for now
|
|
1292
1294
|
if (name === 'style') {
|
|
1293
1295
|
shouldDeopt = true
|
|
1294
1296
|
return null
|
|
@@ -2018,7 +2020,12 @@ export function createExtractor(
|
|
|
2018
2020
|
hasImportedTheme = true
|
|
2019
2021
|
programPath.node.body.push(
|
|
2020
2022
|
t.importDeclaration(
|
|
2021
|
-
[
|
|
2023
|
+
[
|
|
2024
|
+
t.importSpecifier(
|
|
2025
|
+
t.identifier('_GuiTheme'),
|
|
2026
|
+
t.identifier('Theme')
|
|
2027
|
+
),
|
|
2028
|
+
],
|
|
2022
2029
|
t.stringLiteral('@hanzogui/web')
|
|
2023
2030
|
)
|
|
2024
2031
|
)
|
|
@@ -7,7 +7,9 @@ export function createLogger(sourcePath: string, options: GuiOptions) {
|
|
|
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
|
|
10
|
+
process.env.GUI_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 @
|
|
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
|
}
|
|
@@ -130,7 +130,10 @@ export const isInsideComponentPackage = (
|
|
|
130
130
|
})
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
export const isComponentPackage = (
|
|
133
|
+
export const isComponentPackage = (
|
|
134
|
+
props: GuiOptionsWithFileInfo,
|
|
135
|
+
srcName: string
|
|
136
|
+
) => {
|
|
134
137
|
return getValidComponentsPaths(props).some((path) => {
|
|
135
138
|
return srcName.startsWith(path)
|
|
136
139
|
})
|
|
@@ -196,7 +199,7 @@ export const isValidImport = (
|
|
|
196
199
|
|
|
197
200
|
const getValidComponentPackages = memoize((props: GuiOptionsWithFileInfo) => {
|
|
198
201
|
// just always look for `gui` and `@hanzogui/core`
|
|
199
|
-
return [...new Set(['@hanzogui/core', '
|
|
202
|
+
return [...new Set(['@hanzogui/core', 'gui', ...(props.components || [])])]
|
|
200
203
|
})
|
|
201
204
|
|
|
202
205
|
export const getValidComponentsPaths = memoize((props: GuiOptionsWithFileInfo) => {
|
|
@@ -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(
|
|
57
|
+
const mediaStyle = core.createMediaStyle(
|
|
58
|
+
style,
|
|
59
|
+
key,
|
|
60
|
+
guiConfig.media,
|
|
61
|
+
true,
|
|
62
|
+
negate
|
|
63
|
+
)
|
|
58
64
|
const className = `.${mediaStyle[core.StyleObjectIdentifier]}`
|
|
59
65
|
return {
|
|
60
66
|
...mediaStyle,
|
|
@@ -63,7 +63,7 @@ export function getBabelPlugin() {
|
|
|
63
63
|
|
|
64
64
|
export function getBabelParseDefinition(options: GuiOptions) {
|
|
65
65
|
return {
|
|
66
|
-
name: '
|
|
66
|
+
name: 'gui',
|
|
67
67
|
|
|
68
68
|
visitor: {
|
|
69
69
|
Program: {
|
|
@@ -419,7 +419,7 @@ export function getBabelParseDefinition(options: GuiOptions) {
|
|
|
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
|
|
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('
|
|
469
|
+
if (process.env.DEBUG?.startsWith('gui')) {
|
|
470
470
|
console.warn('⚠️ Cannot pass style attribute to extracted style')
|
|
471
471
|
}
|
|
472
472
|
}
|
|
@@ -4,6 +4,6 @@ import type { GuiOptions } from '../types'
|
|
|
4
4
|
export function getPrefixLogs(options?: GuiOptions) {
|
|
5
5
|
return (
|
|
6
6
|
options?.prefixLogs ??
|
|
7
|
-
` 🐥 [
|
|
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=
|
|
140
|
+
` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=gui for more)`
|
|
141
141
|
)
|
|
142
|
-
} else if (process.env.DEBUG?.startsWith('
|
|
142
|
+
} else if (process.env.DEBUG?.startsWith('gui')) {
|
|
143
143
|
console.info(`Error in partial evaluation`, err.message, err.stack)
|
|
144
144
|
}
|
|
145
145
|
}
|
package/src/extractor/loadGui.ts
CHANGED
|
@@ -29,7 +29,7 @@ const getFilledOptions = (propsIn: Partial<GuiOptions>): GuiOptions => ({
|
|
|
29
29
|
// defaults
|
|
30
30
|
platform: (process.env.GUI_TARGET as any) || 'web',
|
|
31
31
|
config: 'gui.config.ts',
|
|
32
|
-
components: ['
|
|
32
|
+
components: ['gui'],
|
|
33
33
|
...(propsIn as Partial<GuiOptions>),
|
|
34
34
|
})
|
|
35
35
|
|
|
@@ -53,7 +53,7 @@ export async function loadGui(
|
|
|
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=
|
|
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
|
|
@@ -102,7 +102,7 @@ export const generateThemesAndLog = async (options: GuiOptions, force = false) =
|
|
|
102
102
|
const whitespaceBefore = ` `
|
|
103
103
|
colorLog(
|
|
104
104
|
Color.FgYellow,
|
|
105
|
-
`${whitespaceBefore}➡ [
|
|
105
|
+
`${whitespaceBefore}➡ [gui] generated themes: ${relative(
|
|
106
106
|
process.cwd(),
|
|
107
107
|
options.themeBuilder.output
|
|
108
108
|
)}`
|
|
@@ -171,20 +171,20 @@ export async function loadGuiBuildConfigAsync(
|
|
|
171
171
|
...out,
|
|
172
172
|
}
|
|
173
173
|
} catch (err) {
|
|
174
|
-
console.error(`[
|
|
174
|
+
console.error(`[gui] Error loading ${buildFilePath}:`, err)
|
|
175
175
|
throw err
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
if (!guiOptions) {
|
|
180
180
|
throw new Error(
|
|
181
|
-
`No
|
|
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
186
|
config: 'gui.config.ts',
|
|
187
|
-
components: ['
|
|
187
|
+
components: ['gui', '@hanzogui/core'],
|
|
188
188
|
...guiOptions,
|
|
189
189
|
} as GuiOptions
|
|
190
190
|
}
|
|
@@ -192,7 +192,9 @@ export async function loadGuiBuildConfigAsync(
|
|
|
192
192
|
/**
|
|
193
193
|
* @deprecated Use loadGuiBuildConfigAsync instead to avoid EPIPE errors
|
|
194
194
|
*/
|
|
195
|
-
export function loadGuiBuildConfigSync(
|
|
195
|
+
export function loadGuiBuildConfigSync(
|
|
196
|
+
guiOptions: Partial<GuiOptions> | undefined
|
|
197
|
+
) {
|
|
196
198
|
const buildFilePath = guiOptions?.buildFile ?? './gui.build.ts'
|
|
197
199
|
if (fsExtra.existsSync(buildFilePath)) {
|
|
198
200
|
const registered = registerRequire('web')
|
|
@@ -214,12 +216,12 @@ export function loadGuiBuildConfigSync(guiOptions: Partial<GuiOptions> | undefin
|
|
|
214
216
|
}
|
|
215
217
|
if (!guiOptions) {
|
|
216
218
|
throw new Error(
|
|
217
|
-
`No
|
|
219
|
+
`No gui build options found either via input props or at gui.build.ts`
|
|
218
220
|
)
|
|
219
221
|
}
|
|
220
222
|
return {
|
|
221
223
|
config: 'gui.config.ts',
|
|
222
|
-
components: ['
|
|
224
|
+
components: ['gui', '@hanzogui/core'],
|
|
223
225
|
...guiOptions,
|
|
224
226
|
} as GuiOptions
|
|
225
227
|
}
|
|
@@ -290,7 +292,7 @@ export function loadGuiSync({
|
|
|
290
292
|
if (!components) {
|
|
291
293
|
throw new Error(`No components loaded`)
|
|
292
294
|
}
|
|
293
|
-
if (process.env.DEBUG === '
|
|
295
|
+
if (process.env.DEBUG === 'gui') {
|
|
294
296
|
console.info(`components`, components)
|
|
295
297
|
}
|
|
296
298
|
|
|
@@ -323,7 +325,7 @@ export function loadGuiSync({
|
|
|
323
325
|
if (err instanceof Error) {
|
|
324
326
|
if (!SHOULD_DEBUG && !forceExports) {
|
|
325
327
|
console.warn(
|
|
326
|
-
`Error loading gui.config.ts (set DEBUG=
|
|
328
|
+
`Error loading gui.config.ts (set DEBUG=gui to see full stack), running gui without custom config`
|
|
327
329
|
)
|
|
328
330
|
console.info(`\n\n ${err.message}\n\n`)
|
|
329
331
|
} else {
|
|
@@ -371,10 +373,11 @@ export async function getOptions({
|
|
|
371
373
|
tsconfigPath,
|
|
372
374
|
guiOptions: {
|
|
373
375
|
platform: (process.env.GUI_TARGET as any) || 'web',
|
|
374
|
-
components: ['
|
|
376
|
+
components: ['gui'],
|
|
375
377
|
...guiOptions,
|
|
376
378
|
config:
|
|
377
|
-
guiOptions?.config ??
|
|
379
|
+
guiOptions?.config ??
|
|
380
|
+
(await getDefaultGuiConfigPath(root, guiOptions?.config)),
|
|
378
381
|
},
|
|
379
382
|
paths: {
|
|
380
383
|
root,
|
|
@@ -33,28 +33,38 @@ export async function regenerateConfig(
|
|
|
33
33
|
spaces: 2,
|
|
34
34
|
})
|
|
35
35
|
} catch (err) {
|
|
36
|
-
if (process.env.DEBUG?.includes('
|
|
36
|
+
if (process.env.DEBUG?.includes('gui') || process.env.IS_GUI_DEV) {
|
|
37
37
|
console.warn('regenerateConfig error', err)
|
|
38
38
|
}
|
|
39
39
|
// ignore for now
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export function regenerateConfigSync(
|
|
43
|
+
export function regenerateConfigSync(
|
|
44
|
+
_guiOptions: GuiOptions,
|
|
45
|
+
config: BundledConfig
|
|
46
|
+
) {
|
|
44
47
|
try {
|
|
45
48
|
FS.ensureDirSync(dirname(confFile))
|
|
46
|
-
FS.writeJSONSync(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
FS.writeJSONSync(
|
|
50
|
+
confFile,
|
|
51
|
+
transformConfig(config, _guiOptions.platform || 'web'),
|
|
52
|
+
{
|
|
53
|
+
spaces: 2,
|
|
54
|
+
}
|
|
55
|
+
)
|
|
49
56
|
} catch (err) {
|
|
50
|
-
if (process.env.DEBUG?.includes('
|
|
57
|
+
if (process.env.DEBUG?.includes('gui') || process.env.IS_GUI_DEV) {
|
|
51
58
|
console.warn('regenerateConfig error', err)
|
|
52
59
|
}
|
|
53
60
|
// ignore for now
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
export async function generateGuiThemes(
|
|
64
|
+
export async function generateGuiThemes(
|
|
65
|
+
guiOptions: GuiOptions,
|
|
66
|
+
force = false
|
|
67
|
+
) {
|
|
58
68
|
if (!guiOptions.themeBuilder) {
|
|
59
69
|
return
|
|
60
70
|
}
|
package/src/getPragmaOptions.ts
CHANGED
package/src/registerRequire.ts
CHANGED
|
@@ -68,17 +68,16 @@ export function registerRequire(
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// capture original resolve BEFORE esbuild-register patches it
|
|
71
|
-
// so we can use Node's native exports resolution for @
|
|
71
|
+
// so we can use Node's native exports resolution for @hanzogui packages
|
|
72
72
|
const originalResolveFilename = Module._resolveFilename
|
|
73
73
|
|
|
74
74
|
const { unregister } = register({
|
|
75
75
|
hookIgnoreNodeModules: false,
|
|
76
|
-
// don't transform @
|
|
76
|
+
// don't transform @hanzogui packages - they have pre-built dist files
|
|
77
77
|
hookMatcher: (filename) => {
|
|
78
78
|
if (
|
|
79
|
-
filename.includes('@
|
|
80
|
-
|
|
81
|
-
/\/(hanzo\/gui|gui)\/code\/(core|ui|packages)\//.test(filename)
|
|
79
|
+
filename.includes('@hanzogui') ||
|
|
80
|
+
/\/gui\/code\/(core|ui|packages)\//.test(filename)
|
|
82
81
|
) {
|
|
83
82
|
return false
|
|
84
83
|
}
|
|
@@ -88,10 +87,10 @@ export function registerRequire(
|
|
|
88
87
|
|
|
89
88
|
// esbuild-register's registerTsconfigPaths replaces Module._resolveFilename
|
|
90
89
|
// but tsconfig paths resolution bypasses Node's package exports
|
|
91
|
-
// we need to restore Node's native resolution for @
|
|
90
|
+
// we need to restore Node's native resolution for @hanzogui packages
|
|
92
91
|
const tsconfigPatchedResolve = Module._resolveFilename
|
|
93
92
|
Module._resolveFilename = function (request: string, ...args: any[]) {
|
|
94
|
-
// for @
|
|
93
|
+
// for @hanzogui packages, use Node's native resolution (respects exports)
|
|
95
94
|
if (request.startsWith('@hanzogui/')) {
|
|
96
95
|
return originalResolveFilename.call(this, request, ...args)
|
|
97
96
|
}
|
|
@@ -113,8 +112,8 @@ export function registerRequire(
|
|
|
113
112
|
return staticExtractionStub
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
if (path === '
|
|
117
|
-
return og.apply(this, ['
|
|
115
|
+
if (path === 'gui' && platform === 'native') {
|
|
116
|
+
return og.apply(this, ['gui/native'])
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
if (path === '@hanzogui/core') {
|
|
@@ -157,14 +156,12 @@ export function registerRequire(
|
|
|
157
156
|
|
|
158
157
|
if (!whitelisted[path]) {
|
|
159
158
|
if (proxyWormImports && !path.includes('.gui-dynamic-eval')) {
|
|
160
|
-
// allow
|
|
159
|
+
// allow gui and its sub-packages through - they re-export components
|
|
161
160
|
// with staticConfig needed for dynamic eval optimization.
|
|
162
161
|
// also allow requires FROM within gui packages (relative imports like ./Separator.cjs)
|
|
163
162
|
const callerFile = this?.filename || this?.id || ''
|
|
164
163
|
const isFromGuiPkg =
|
|
165
|
-
callerFile.includes('@
|
|
166
|
-
callerFile.includes('@gui') ||
|
|
167
|
-
callerFile.includes('node_modules/@hanzo/')
|
|
164
|
+
callerFile.includes('@hanzogui') || callerFile.includes('node_modules/gui/')
|
|
168
165
|
const isFromStaticLoader =
|
|
169
166
|
!callerFile ||
|
|
170
167
|
callerFile === '.' ||
|
|
@@ -172,8 +169,9 @@ export function registerRequire(
|
|
|
172
169
|
callerFile.endsWith('/[eval]') ||
|
|
173
170
|
callerFile.includes('/code/compiler/static/') ||
|
|
174
171
|
callerFile.includes('/.gui/')
|
|
172
|
+
|
|
175
173
|
if (
|
|
176
|
-
path === '
|
|
174
|
+
path === 'gui' ||
|
|
177
175
|
path.startsWith('@hanzogui/') ||
|
|
178
176
|
isFromGuiPkg ||
|
|
179
177
|
isFromStaticLoader
|
|
@@ -233,7 +231,7 @@ export function registerRequire(
|
|
|
233
231
|
*/
|
|
234
232
|
|
|
235
233
|
console.warn(
|
|
236
|
-
` [
|
|
234
|
+
` [gui] skipped "${path}" (set GUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`
|
|
237
235
|
)
|
|
238
236
|
}
|
|
239
237
|
|
|
@@ -246,7 +244,7 @@ export function registerRequire(
|
|
|
246
244
|
unregister: () => {
|
|
247
245
|
if (hasWarnedForModules.size) {
|
|
248
246
|
console.info(
|
|
249
|
-
` [
|
|
247
|
+
` [gui] skipped loading ${hasWarnedForModules.size} module, see: https://gui.dev/docs/intro/errors#warning-001`
|
|
250
248
|
)
|
|
251
249
|
hasWarnedForModules.clear()
|
|
252
250
|
}
|
|
@@ -258,9 +256,9 @@ export function registerRequire(
|
|
|
258
256
|
}
|
|
259
257
|
}
|
|
260
258
|
|
|
261
|
-
const IGNORES =
|
|
262
|
-
|
|
263
|
-
|
|
259
|
+
const IGNORES = process.env.GUI_IGNORE_BUNDLE_ERRORS
|
|
260
|
+
const extraIgnores =
|
|
261
|
+
IGNORES === 'true' ? [] : process.env.GUI_IGNORE_BUNDLE_ERRORS?.split(',')
|
|
264
262
|
|
|
265
263
|
const knownIgnorableModules = {
|
|
266
264
|
'@gorhom/bottom-sheet': true,
|
|
@@ -268,7 +266,7 @@ const knownIgnorableModules = {
|
|
|
268
266
|
solito: true,
|
|
269
267
|
'expo-linear-gradient': true,
|
|
270
268
|
'@expo/vector-icons': true,
|
|
271
|
-
'
|
|
269
|
+
'gui/linear-gradient': true,
|
|
272
270
|
// animation libraries not needed for static extraction
|
|
273
271
|
'@emotion/is-prop-valid': true,
|
|
274
272
|
'framer-motion': true,
|
package/src/types.ts
CHANGED
|
@@ -78,7 +78,10 @@ export type GuiOptionsWithFileInfo = GuiOptions & {
|
|
|
78
78
|
allLoadedComponents: LoadedComponents[]
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export type ExtractorParseProps = Omit<
|
|
81
|
+
export type ExtractorParseProps = Omit<
|
|
82
|
+
GuiOptionsWithFileInfo,
|
|
83
|
+
'allLoadedComponents'
|
|
84
|
+
> & {
|
|
82
85
|
platform: GuiPlatform
|
|
83
86
|
shouldPrintDebug?: boolean | 'verbose'
|
|
84
87
|
onExtractTag: (props: ExtractTagProps) => void
|
package/src/worker.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-dep-versions.d.ts","sourceRoot":"","sources":["../src/check-dep-versions.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"check-dep-versions.d.ts","sourceRoot":"","sources":["../src/check-dep-versions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8oBH,+CAA+C;AAC/C,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,OAAO,CAAA;IACtB,QAAQ,EAAE,SAAS;QACjB,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,SAAS;YAAE,YAAY,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAC9C,EAAE,CAAA;CACJ,CAAA;AAED,qBAAa,IAAI;IACf,4GAA4G;IAC5G,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAE3C;;;;;;;;;;OAUG;gBACS,IAAI,EAAE,MAAM;IAKjB,iBAAiB,IAAI,MAAM;IAI3B,eAAe,IAAI,SAAS,UAAU,EAAE;IAMxC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAc9C,IAAW,0BAA0B,IAAI,OAAO,CAE/C;CACF"}
|
package/types/checkDeps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkDeps.d.ts","sourceRoot":"","sources":["../src/checkDeps.ts"],"names":[],"mappings":"AAIA,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;IACnC,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IACrC,WAAW,gBAAgB;CAC5B;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,CAAC,EAAE,SAAS,GAAG,eAAe,EAAE,EAAE,CAAA;IACzC,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACtC,CAAA;
|
|
1
|
+
{"version":3,"file":"checkDeps.d.ts","sourceRoot":"","sources":["../src/checkDeps.ts"],"names":[],"mappings":"AAIA,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;IACnC,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IACrC,WAAW,gBAAgB;CAC5B;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,CAAC,EAAE,SAAS,GAAG,eAAe,EAAE,EAAE,CAAA;IACzC,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACtC,CAAA;AA+TD,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,iBA8B3C"}
|
package/types/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gBAAgB,CAAA;AAG1C,eAAO,MAAM,SAAS,MAAM,CAAA;AAG5B,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gBAAgB,CAAA;AAG1C,eAAO,MAAM,SAAS,MAAM,CAAA;AAG5B,eAAO,MAAM,QAAQ,KAA8C,CAAA;AAEnE,eAAO,MAAM,WAAW,eAA8B,CAAA;AAEtD,eAAO,MAAM,YAAY,qBAC0C,CAAA"}
|