@hanzogui/static 7.0.0 → 7.3.1
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 +11 -11
- package/dist/constants.cjs +2 -2
- package/dist/exports.cjs +2 -2
- package/dist/extractor/bundle.cjs +6 -6
- package/dist/extractor/bundleConfig.cjs +45 -45
- package/dist/extractor/createExtractor.cjs +39 -39
- package/dist/extractor/createLogger.cjs +1 -1
- package/dist/extractor/extractHelpers.cjs +1 -1
- package/dist/extractor/extractMediaStyle.cjs +7 -7
- package/dist/extractor/extractToClassNames.cjs +9 -9
- package/dist/extractor/extractToNative.cjs +7 -7
- package/dist/extractor/{getHanzoguiConfigPathFromOptionsConfig.cjs → getGuiConfigPathFromOptionsConfig.cjs} +5 -5
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/{loadHanzogui.cjs → loadGui.cjs} +65 -65
- package/dist/extractor/regenerateConfig.cjs +20 -20
- package/dist/extractor/{watchHanzoguiConfig.cjs → watchGuiConfig.cjs} +15 -15
- package/dist/getPragmaOptions.cjs +6 -6
- package/dist/helpers/{requireHanzoguiCore.cjs → requireGuiCore.cjs} +12 -12
- package/dist/registerRequire.cjs +20 -20
- package/dist/worker.cjs +3 -3
- package/package.json +29 -23
- package/src/check-dep-versions.ts +1 -1
- package/src/checkDeps.ts +27 -27
- package/src/constants.ts +2 -2
- package/src/exports.ts +2 -2
- package/src/extractor/bundle.ts +9 -9
- package/src/extractor/bundleConfig.ts +56 -56
- package/src/extractor/createEvaluator.ts +2 -2
- package/src/extractor/createExtractor.ts +55 -55
- package/src/extractor/createLogger.ts +3 -3
- package/src/extractor/extractHelpers.ts +12 -12
- package/src/extractor/extractMediaStyle.ts +13 -13
- package/src/extractor/extractToClassNames.ts +11 -11
- package/src/extractor/extractToNative.ts +13 -13
- package/src/extractor/{getHanzoguiConfigPathFromOptionsConfig.ts → getGuiConfigPathFromOptionsConfig.ts} +3 -3
- package/src/extractor/getPrefixLogs.ts +3 -3
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/{loadHanzogui.ts → loadGui.ts} +85 -85
- package/src/extractor/regenerateConfig.ts +23 -23
- package/src/extractor/{watchHanzoguiConfig.ts → watchGuiConfig.ts} +10 -10
- package/src/getPragmaOptions.ts +6 -6
- package/src/helpers/requireGuiCore.ts +28 -0
- package/src/registerRequire.ts +27 -27
- package/src/server.ts +2 -2
- package/src/types.ts +10 -10
- package/src/worker.ts +7 -7
- package/types/constants.d.ts.map +1 -1
- package/types/exports.d.ts +2 -2
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +2 -2
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +12 -12
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createEvaluator.d.ts +2 -2
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts +5 -5
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/createLogger.d.ts +2 -2
- package/types/extractor/createLogger.d.ts.map +1 -1
- package/types/extractor/extractHelpers.d.ts +8 -8
- package/types/extractor/extractHelpers.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +4 -4
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -2
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts +3 -3
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +3 -0
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +1 -0
- package/types/extractor/getPrefixLogs.d.ts +2 -2
- package/types/extractor/getPrefixLogs.d.ts.map +1 -1
- package/types/extractor/loadGui.d.ts +22 -0
- package/types/extractor/loadGui.d.ts.map +1 -0
- package/types/extractor/regenerateConfig.d.ts +4 -4
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchGuiConfig.d.ts +5 -0
- package/types/extractor/watchGuiConfig.d.ts.map +1 -0
- package/types/helpers/requireGuiCore.d.ts +3 -0
- package/types/helpers/requireGuiCore.d.ts.map +1 -0
- package/types/registerRequire.d.ts +3 -3
- package/types/registerRequire.d.ts.map +1 -1
- package/types/server.d.ts +2 -2
- package/types/server.d.ts.map +1 -1
- package/types/types.d.ts +10 -10
- package/types/types.d.ts.map +1 -1
- package/types/worker.d.ts +4 -4
- package/types/worker.d.ts.map +1 -1
- package/src/helpers/requireHanzoguiCore.ts +0 -28
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +0 -3
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +0 -1
- package/types/extractor/loadHanzogui.d.ts +0 -22
- package/types/extractor/loadHanzogui.d.ts.map +0 -1
- package/types/extractor/watchHanzoguiConfig.d.ts +0 -5
- package/types/extractor/watchHanzoguiConfig.d.ts.map +0 -1
- package/types/helpers/requireHanzoguiCore.d.ts +0 -3
- package/types/helpers/requireHanzoguiCore.d.ts.map +0 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { dirname, join } from 'node:path'
|
|
2
2
|
|
|
3
3
|
import { generateThemes, writeGeneratedThemes } from '@hanzogui/generate-themes'
|
|
4
|
-
import type {
|
|
4
|
+
import type { GuiOptions } from '@hanzogui/types'
|
|
5
5
|
import * as FS from 'fs-extra'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
7
|
+
import { requireGuiCore } from '../helpers/requireGuiCore'
|
|
8
|
+
import type { GuiPlatform } from '../types'
|
|
9
9
|
import type { BundledConfig } from './bundleConfig'
|
|
10
10
|
import { getBundledConfig } from './bundleConfig'
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const confFile = join(
|
|
12
|
+
const guiDir = join(process.cwd(), '.gui')
|
|
13
|
+
const confFile = join(guiDir, 'gui.config.json')
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Sort of a super-set of bundleConfig(), this code needs some refactoring ideally
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
export async function regenerateConfig(
|
|
20
|
-
|
|
20
|
+
guiOptions: GuiOptions,
|
|
21
21
|
configIn?: BundledConfig | null,
|
|
22
22
|
rebuild = false
|
|
23
23
|
) {
|
|
24
24
|
try {
|
|
25
25
|
// this has a side effect of rebuilding config and css!
|
|
26
26
|
// need to improve code here:
|
|
27
|
-
const config = configIn ?? (await getBundledConfig(
|
|
27
|
+
const config = configIn ?? (await getBundledConfig(guiOptions, rebuild))
|
|
28
28
|
if (!config) return
|
|
29
|
-
const out = transformConfig(config,
|
|
29
|
+
const out = transformConfig(config, guiOptions.platform || 'web')
|
|
30
30
|
|
|
31
31
|
await FS.ensureDir(dirname(confFile))
|
|
32
32
|
await FS.writeJSON(confFile, out, {
|
|
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
|
|
@@ -41,35 +41,35 @@ export async function regenerateConfig(
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export function regenerateConfigSync(
|
|
44
|
-
|
|
44
|
+
_guiOptions: GuiOptions,
|
|
45
45
|
config: BundledConfig
|
|
46
46
|
) {
|
|
47
47
|
try {
|
|
48
48
|
FS.ensureDirSync(dirname(confFile))
|
|
49
49
|
FS.writeJSONSync(
|
|
50
50
|
confFile,
|
|
51
|
-
transformConfig(config,
|
|
51
|
+
transformConfig(config, _guiOptions.platform || 'web'),
|
|
52
52
|
{
|
|
53
53
|
spaces: 2,
|
|
54
54
|
}
|
|
55
55
|
)
|
|
56
56
|
} catch (err) {
|
|
57
|
-
if (process.env.DEBUG?.includes('
|
|
57
|
+
if (process.env.DEBUG?.includes('gui') || process.env.IS_GUI_DEV) {
|
|
58
58
|
console.warn('regenerateConfig error', err)
|
|
59
59
|
}
|
|
60
60
|
// ignore for now
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export async function
|
|
65
|
-
|
|
64
|
+
export async function generateGuiThemes(
|
|
65
|
+
guiOptions: GuiOptions,
|
|
66
66
|
force = false
|
|
67
67
|
) {
|
|
68
|
-
if (!
|
|
68
|
+
if (!guiOptions.themeBuilder) {
|
|
69
69
|
return
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const { input, output } =
|
|
72
|
+
const { input, output } = guiOptions.themeBuilder
|
|
73
73
|
const inPath = resolveRelativePath(input)
|
|
74
74
|
const outPath = resolveRelativePath(output)
|
|
75
75
|
const generatedOutput = await generateThemes(inPath)
|
|
@@ -90,7 +90,7 @@ export async function generateHanzoguiThemes(
|
|
|
90
90
|
})())
|
|
91
91
|
|
|
92
92
|
if (hasChanged) {
|
|
93
|
-
await writeGeneratedThemes(
|
|
93
|
+
await writeGeneratedThemes(guiDir, outPath, generatedOutput)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
return hasChanged
|
|
@@ -110,20 +110,20 @@ function cloneDeepSafe(x: any, excludeKeys = {}) {
|
|
|
110
110
|
)
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
function transformConfig(config: BundledConfig, platform:
|
|
113
|
+
function transformConfig(config: BundledConfig, platform: GuiPlatform) {
|
|
114
114
|
if (!config) {
|
|
115
115
|
return null
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
const { getVariableValue } =
|
|
118
|
+
const { getVariableValue } = requireGuiCore(platform)
|
|
119
119
|
|
|
120
120
|
// ensure we don't mangle anything in the original
|
|
121
121
|
const next = cloneDeepSafe(config, {
|
|
122
122
|
validStyles: true,
|
|
123
123
|
}) as BundledConfig
|
|
124
124
|
|
|
125
|
-
const { components, nameToPaths,
|
|
126
|
-
const { themes, tokens } =
|
|
125
|
+
const { components, nameToPaths, guiConfig } = next
|
|
126
|
+
const { themes, tokens } = guiConfig
|
|
127
127
|
|
|
128
128
|
// reduce down to usable, smaller json
|
|
129
129
|
|
|
@@ -172,12 +172,12 @@ function transformConfig(config: BundledConfig, platform: HanzoguiPlatform) {
|
|
|
172
172
|
shorthands: _shorthands,
|
|
173
173
|
userShorthands,
|
|
174
174
|
...cleanedConfig
|
|
175
|
-
} = next.
|
|
175
|
+
} = next.guiConfig
|
|
176
176
|
|
|
177
177
|
return {
|
|
178
178
|
components,
|
|
179
179
|
nameToPaths,
|
|
180
|
-
|
|
180
|
+
guiConfig: {
|
|
181
181
|
...cleanedConfig,
|
|
182
182
|
// Output userShorthands as shorthands (excludes built-ins)
|
|
183
183
|
shorthands: userShorthands,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { esbuildWatchFiles, generateThemesAndLog, getOptions } from './
|
|
1
|
+
import type { GuiOptions } from '@hanzogui/types'
|
|
2
|
+
import { esbuildWatchFiles, generateThemesAndLog, getOptions } from './loadGui'
|
|
3
3
|
import { regenerateConfig } from './regenerateConfig'
|
|
4
4
|
|
|
5
5
|
let isWatching = false
|
|
6
6
|
|
|
7
|
-
export async function
|
|
7
|
+
export async function watchGuiConfig(guiOptions: GuiOptions) {
|
|
8
8
|
if (process.env.NODE_ENV === 'production') {
|
|
9
9
|
return {
|
|
10
10
|
dispose() {},
|
|
@@ -17,22 +17,22 @@ export async function watchHanzoguiConfig(hanzoguiOptions: HanzoguiOptions) {
|
|
|
17
17
|
|
|
18
18
|
isWatching = true
|
|
19
19
|
|
|
20
|
-
const options = await getOptions({
|
|
20
|
+
const options = await getOptions({ guiOptions })
|
|
21
21
|
|
|
22
|
-
if (!options.
|
|
22
|
+
if (!options.guiOptions.config) {
|
|
23
23
|
isWatching = false
|
|
24
24
|
throw new Error(`No config`)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const disposeConfigWatcher = await esbuildWatchFiles(
|
|
28
|
-
options.
|
|
28
|
+
options.guiOptions.config,
|
|
29
29
|
async () => {
|
|
30
|
-
await generateThemesAndLog(options.
|
|
31
|
-
await regenerateConfig(options.
|
|
30
|
+
await generateThemesAndLog(options.guiOptions)
|
|
31
|
+
await regenerateConfig(options.guiOptions, null, true)
|
|
32
32
|
}
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
-
const themeBuilderInput = options.
|
|
35
|
+
const themeBuilderInput = options.guiOptions.themeBuilder?.input
|
|
36
36
|
let disposeThemesWatcher: Function | undefined
|
|
37
37
|
|
|
38
38
|
if (themeBuilderInput) {
|
|
@@ -43,7 +43,7 @@ export async function watchHanzoguiConfig(hanzoguiOptions: HanzoguiOptions) {
|
|
|
43
43
|
// ok
|
|
44
44
|
}
|
|
45
45
|
disposeThemesWatcher = await esbuildWatchFiles(inputPath, async () => {
|
|
46
|
-
await generateThemesAndLog(options.
|
|
46
|
+
await generateThemesAndLog(options.guiOptions)
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
49
|
|
package/src/getPragmaOptions.ts
CHANGED
|
@@ -14,7 +14,7 @@ export function getPragmaOptions({ source, path }: { source: string; path: strin
|
|
|
14
14
|
}
|
|
15
15
|
pragma =
|
|
16
16
|
trimmed
|
|
17
|
-
.match(/(\/\/|\/\*)\s?!?\s?(
|
|
17
|
+
.match(/(\/\/|\/\*)\s?!?\s?(gui-ignore|debug|debug-verbose)(\n|\s|$).*/)?.[2]
|
|
18
18
|
.trim() || ''
|
|
19
19
|
if (pragma) {
|
|
20
20
|
pragma = pragma.replace('!', '').trim()
|
|
@@ -23,7 +23,7 @@ export function getPragmaOptions({ source, path }: { source: string; path: strin
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
switch (pragma) {
|
|
26
|
-
case '
|
|
26
|
+
case 'gui-ignore':
|
|
27
27
|
shouldDisable = true
|
|
28
28
|
break
|
|
29
29
|
|
|
@@ -36,17 +36,17 @@ export function getPragmaOptions({ source, path }: { source: string; path: strin
|
|
|
36
36
|
break
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
if (process.env.
|
|
40
|
-
if (path.includes(process.env.
|
|
39
|
+
if (process.env.GUI_DEBUG_FILE) {
|
|
40
|
+
if (path.includes(process.env.GUI_DEBUG_FILE)) {
|
|
41
41
|
shouldPrintDebug = 'verbose'
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
if (process.env.DEBUG?.includes('
|
|
45
|
+
if (process.env.DEBUG?.includes('gui')) {
|
|
46
46
|
shouldPrintDebug ||= true
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
if (process.env.DEBUG?.includes('
|
|
49
|
+
if (process.env.DEBUG?.includes('gui-verbose')) {
|
|
50
50
|
shouldPrintDebug = 'verbose'
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// this allows us to swap between core native and web in the same process:
|
|
2
|
+
|
|
3
|
+
import type { GuiPlatform } from '../types'
|
|
4
|
+
|
|
5
|
+
export function requireGuiCore(
|
|
6
|
+
platform: GuiPlatform,
|
|
7
|
+
ogRequire: Function = require
|
|
8
|
+
): typeof import('@hanzogui/core') {
|
|
9
|
+
if (!platform) {
|
|
10
|
+
throw new Error(`No platform given to requireGuiCore`)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// avoid tree shaking out themes
|
|
14
|
+
const og1 = process.env.GUI_IS_SERVER
|
|
15
|
+
const og2 = process.env.GUI_KEEP_THEMES
|
|
16
|
+
process.env.GUI_IS_SERVER ||= '1'
|
|
17
|
+
process.env.GUI_KEEP_THEMES ||= '1'
|
|
18
|
+
|
|
19
|
+
const exported = ogRequire(
|
|
20
|
+
platform === 'native' ? '@hanzogui/core/native' : '@hanzogui/core'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
// restore back
|
|
24
|
+
process.env.GUI_IS_SERVER = og1
|
|
25
|
+
process.env.GUI_KEEP_THEMES = og2
|
|
26
|
+
|
|
27
|
+
return exported
|
|
28
|
+
}
|
package/src/registerRequire.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { register } from 'esbuild-register/dist/node'
|
|
2
2
|
|
|
3
3
|
import { esbuildIgnoreFilesRegex } from './extractor/bundle'
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
4
|
+
import { requireGuiCore } from './helpers/requireGuiCore'
|
|
5
|
+
import type { GuiPlatform } from './types'
|
|
6
6
|
|
|
7
7
|
const nameToPaths = {}
|
|
8
8
|
|
|
@@ -54,7 +54,7 @@ function getStaticExtractionStub(path: string) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export function registerRequire(
|
|
57
|
-
platform:
|
|
57
|
+
platform: GuiPlatform,
|
|
58
58
|
{ proxyWormImports } = {
|
|
59
59
|
proxyWormImports: false,
|
|
60
60
|
}
|
|
@@ -62,7 +62,7 @@ export function registerRequire(
|
|
|
62
62
|
// already registered
|
|
63
63
|
if (isRegistered) {
|
|
64
64
|
return {
|
|
65
|
-
|
|
65
|
+
guiRequire: require,
|
|
66
66
|
unregister: () => {},
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -77,7 +77,7 @@ export function registerRequire(
|
|
|
77
77
|
hookMatcher: (filename) => {
|
|
78
78
|
if (
|
|
79
79
|
filename.includes('@hanzogui') ||
|
|
80
|
-
/\/
|
|
80
|
+
/\/gui\/code\/(core|ui|packages)\//.test(filename)
|
|
81
81
|
) {
|
|
82
82
|
return false
|
|
83
83
|
}
|
|
@@ -104,20 +104,20 @@ export function registerRequire(
|
|
|
104
104
|
|
|
105
105
|
isRegistered = true
|
|
106
106
|
|
|
107
|
-
Module.prototype.require =
|
|
107
|
+
Module.prototype.require = guiRequire
|
|
108
108
|
|
|
109
|
-
function
|
|
109
|
+
function guiRequire(this: any, path: string) {
|
|
110
110
|
const staticExtractionStub = getStaticExtractionStub(path)
|
|
111
111
|
if (staticExtractionStub) {
|
|
112
112
|
return staticExtractionStub
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
if (path === '
|
|
116
|
-
return og.apply(this, ['
|
|
115
|
+
if (path === 'gui' && platform === 'native') {
|
|
116
|
+
return og.apply(this, ['gui/native'])
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
if (path === '@hanzogui/core') {
|
|
120
|
-
return
|
|
120
|
+
return requireGuiCore(platform, (path) => {
|
|
121
121
|
return og.apply(this, [path])
|
|
122
122
|
})
|
|
123
123
|
}
|
|
@@ -155,25 +155,25 @@ export function registerRequire(
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
if (!whitelisted[path]) {
|
|
158
|
-
if (proxyWormImports && !path.includes('.
|
|
159
|
-
// allow
|
|
158
|
+
if (proxyWormImports && !path.includes('.gui-dynamic-eval')) {
|
|
159
|
+
// allow gui and its sub-packages through - they re-export components
|
|
160
160
|
// with staticConfig needed for dynamic eval optimization.
|
|
161
|
-
// also allow requires FROM within
|
|
161
|
+
// also allow requires FROM within gui packages (relative imports like ./Separator.cjs)
|
|
162
162
|
const callerFile = this?.filename || this?.id || ''
|
|
163
|
-
const
|
|
164
|
-
callerFile.includes('@hanzogui') || callerFile.includes('node_modules/
|
|
163
|
+
const isFromGuiPkg =
|
|
164
|
+
callerFile.includes('@hanzogui') || callerFile.includes('node_modules/gui/')
|
|
165
165
|
const isFromStaticLoader =
|
|
166
166
|
!callerFile ||
|
|
167
167
|
callerFile === '.' ||
|
|
168
168
|
callerFile === '[eval]' ||
|
|
169
169
|
callerFile.endsWith('/[eval]') ||
|
|
170
170
|
callerFile.includes('/code/compiler/static/') ||
|
|
171
|
-
callerFile.includes('/.
|
|
171
|
+
callerFile.includes('/.gui/')
|
|
172
172
|
|
|
173
173
|
if (
|
|
174
|
-
path === '
|
|
174
|
+
path === 'gui' ||
|
|
175
175
|
path.startsWith('@hanzogui/') ||
|
|
176
|
-
|
|
176
|
+
isFromGuiPkg ||
|
|
177
177
|
isFromStaticLoader
|
|
178
178
|
) {
|
|
179
179
|
return og.apply(this, [path])
|
|
@@ -210,15 +210,15 @@ export function registerRequire(
|
|
|
210
210
|
return out
|
|
211
211
|
} catch (err: any) {
|
|
212
212
|
if (
|
|
213
|
-
!process.env.
|
|
214
|
-
path.includes('
|
|
213
|
+
!process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD &&
|
|
214
|
+
path.includes('gui-dynamic-eval')
|
|
215
215
|
) {
|
|
216
216
|
// ok, dynamic eval fails
|
|
217
217
|
return
|
|
218
218
|
}
|
|
219
219
|
if (allowedIgnores[path] || IGNORES === 'true') {
|
|
220
220
|
// ignore
|
|
221
|
-
} else if (!process.env.
|
|
221
|
+
} else if (!process.env.GUI_SHOW_FULL_BUNDLE_ERRORS && !process.env.DEBUG) {
|
|
222
222
|
if (hasWarnedForModules.has(path)) {
|
|
223
223
|
// ignore
|
|
224
224
|
} else {
|
|
@@ -231,7 +231,7 @@ export function registerRequire(
|
|
|
231
231
|
*/
|
|
232
232
|
|
|
233
233
|
console.warn(
|
|
234
|
-
` [
|
|
234
|
+
` [gui] skipped "${path}" (set GUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`
|
|
235
235
|
)
|
|
236
236
|
}
|
|
237
237
|
|
|
@@ -240,11 +240,11 @@ export function registerRequire(
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
return {
|
|
243
|
-
|
|
243
|
+
guiRequire,
|
|
244
244
|
unregister: () => {
|
|
245
245
|
if (hasWarnedForModules.size) {
|
|
246
246
|
console.info(
|
|
247
|
-
` [
|
|
247
|
+
` [gui] skipped loading ${hasWarnedForModules.size} module, see: https://gui.dev/docs/intro/errors#warning-001`
|
|
248
248
|
)
|
|
249
249
|
hasWarnedForModules.clear()
|
|
250
250
|
}
|
|
@@ -256,9 +256,9 @@ export function registerRequire(
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
const IGNORES = process.env.
|
|
259
|
+
const IGNORES = process.env.GUI_IGNORE_BUNDLE_ERRORS
|
|
260
260
|
const extraIgnores =
|
|
261
|
-
IGNORES === 'true' ? [] : process.env.
|
|
261
|
+
IGNORES === 'true' ? [] : process.env.GUI_IGNORE_BUNDLE_ERRORS?.split(',')
|
|
262
262
|
|
|
263
263
|
const knownIgnorableModules = {
|
|
264
264
|
'@gorhom/bottom-sheet': true,
|
|
@@ -266,7 +266,7 @@ const knownIgnorableModules = {
|
|
|
266
266
|
solito: true,
|
|
267
267
|
'expo-linear-gradient': true,
|
|
268
268
|
'@expo/vector-icons': true,
|
|
269
|
-
'
|
|
269
|
+
'gui/linear-gradient': true,
|
|
270
270
|
// animation libraries not needed for static extraction
|
|
271
271
|
'@emotion/is-prop-valid': true,
|
|
272
272
|
'framer-motion': true,
|
package/src/server.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GuiOptions } from './types'
|
|
2
2
|
|
|
3
3
|
import net from 'node:net'
|
|
4
4
|
|
|
5
|
-
export async function startServer(options:
|
|
5
|
+
export async function startServer(options: GuiOptions) {
|
|
6
6
|
const port = await getAvailablePort()
|
|
7
7
|
const server = net.createServer()
|
|
8
8
|
server.unref()
|
package/src/types.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { NodePath } from '@babel/traverse'
|
|
2
2
|
import type * as t from '@babel/types'
|
|
3
|
-
import type { PseudoStyles, StaticConfig,
|
|
3
|
+
import type { PseudoStyles, StaticConfig, GuiConfig } from '@hanzogui/core'
|
|
4
4
|
import type { StyleObject } from '@hanzogui/helpers'
|
|
5
|
-
import type {
|
|
5
|
+
import type { GuiOptions } from '@hanzogui/types'
|
|
6
6
|
import type { ViewStyle } from 'react-native'
|
|
7
7
|
|
|
8
8
|
import type { LoadedComponents } from './extractor/bundleConfig'
|
|
9
9
|
|
|
10
|
-
export type
|
|
10
|
+
export type GuiPlatform = 'native' | 'web'
|
|
11
11
|
|
|
12
|
-
export type {
|
|
12
|
+
export type { GuiOptions, GuiBuildOptions } from '@hanzogui/types'
|
|
13
13
|
|
|
14
14
|
export type { StyleObject } from '@hanzogui/helpers'
|
|
15
15
|
|
|
@@ -33,7 +33,7 @@ export interface Logger {
|
|
|
33
33
|
|
|
34
34
|
export type ExtractorOptions = {
|
|
35
35
|
logger?: Logger
|
|
36
|
-
platform?:
|
|
36
|
+
platform?: GuiPlatform
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export type ExtractedAttrAttr = {
|
|
@@ -58,7 +58,7 @@ export type ExtractedTernaryAttr = {
|
|
|
58
58
|
export type ExtractedAttr = ExtractedAttrAttr | ExtractedTernaryAttr | ExtractedAttrStyle
|
|
59
59
|
|
|
60
60
|
export type ExtractTagProps = {
|
|
61
|
-
parserProps:
|
|
61
|
+
parserProps: GuiOptionsWithFileInfo
|
|
62
62
|
attrs: ExtractedAttr[]
|
|
63
63
|
node: t.JSXOpeningElement
|
|
64
64
|
attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any
|
|
@@ -70,19 +70,19 @@ export type ExtractTagProps = {
|
|
|
70
70
|
filePath: string
|
|
71
71
|
completeProps: Record<string, any>
|
|
72
72
|
staticConfig: StaticConfig
|
|
73
|
-
config:
|
|
73
|
+
config: GuiConfig
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export type
|
|
76
|
+
export type GuiOptionsWithFileInfo = GuiOptions & {
|
|
77
77
|
sourcePath?: string
|
|
78
78
|
allLoadedComponents: LoadedComponents[]
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export type ExtractorParseProps = Omit<
|
|
82
|
-
|
|
82
|
+
GuiOptionsWithFileInfo,
|
|
83
83
|
'allLoadedComponents'
|
|
84
84
|
> & {
|
|
85
|
-
platform:
|
|
85
|
+
platform: GuiPlatform
|
|
86
86
|
shouldPrintDebug?: boolean | 'verbose'
|
|
87
87
|
onExtractTag: (props: ExtractTagProps) => void
|
|
88
88
|
getFlattenedNode?: (props: { isTextView: boolean; tag: string }) => string
|
package/src/worker.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Worker thread implementation for
|
|
2
|
+
* Worker thread implementation for Gui extraction
|
|
3
3
|
* Used by both piscina (async) and synckit (sync for babel)
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ import { createExtractor } from './extractor/createExtractor'
|
|
|
8
8
|
import type { ExtractedResponse } from './extractor/extractToClassNames'
|
|
9
9
|
import { extractToClassNames as extractToClassNamesImpl } from './extractor/extractToClassNames'
|
|
10
10
|
import { extractToNative as extractToNativeImpl } from './extractor/extractToNative'
|
|
11
|
-
import type {
|
|
11
|
+
import type { GuiOptions } from './types'
|
|
12
12
|
|
|
13
13
|
// Create extractors lazily to avoid loading unused ones
|
|
14
14
|
let webExtractor: ReturnType<typeof createExtractor> | null = null
|
|
@@ -35,7 +35,7 @@ export interface ExtractToClassNamesTask {
|
|
|
35
35
|
type: 'extractToClassNames'
|
|
36
36
|
source: string
|
|
37
37
|
sourcePath: string
|
|
38
|
-
options:
|
|
38
|
+
options: GuiOptions
|
|
39
39
|
shouldPrintDebug: boolean | 'verbose'
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ export interface ExtractToNativeTask {
|
|
|
43
43
|
type: 'extractToNative'
|
|
44
44
|
sourceFileName: string
|
|
45
45
|
sourceCode: string
|
|
46
|
-
options:
|
|
46
|
+
options: GuiOptions
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export interface ClearCacheTask {
|
|
@@ -68,14 +68,14 @@ export async function runTask(task: WorkerTask): Promise<WorkerResult> {
|
|
|
68
68
|
// only skip if both extraction AND debug attrs are disabled (fully disabled)
|
|
69
69
|
const isFullyDisabled =
|
|
70
70
|
task.options.disableExtraction && task.options.disableDebugAttr
|
|
71
|
-
if (!isFullyDisabled && !task.options['
|
|
71
|
+
if (!isFullyDisabled && !task.options['_disableLoadGui']) {
|
|
72
72
|
const cacheKey = JSON.stringify({
|
|
73
73
|
config: task.options.config,
|
|
74
74
|
components: task.options.components,
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
if (!configCache.has(cacheKey)) {
|
|
78
|
-
configCache.set(cacheKey, getWebExtractor().
|
|
78
|
+
configCache.set(cacheKey, getWebExtractor().loadGui(task.options))
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
await configCache.get(cacheKey)
|
|
@@ -100,7 +100,7 @@ export async function runTask(task: WorkerTask): Promise<WorkerResult> {
|
|
|
100
100
|
})
|
|
101
101
|
|
|
102
102
|
if (!configCache.has(cacheKey)) {
|
|
103
|
-
configCache.set(cacheKey, getNativeExtractor().
|
|
103
|
+
configCache.set(cacheKey, getNativeExtractor().loadGui(task.options))
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
await configCache.get(cacheKey)
|
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"}
|
package/types/exports.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export * from './extractor/extractToClassNames';
|
|
|
7
7
|
export * from './extractor/concatClassName';
|
|
8
8
|
export * from './extractor/extractToNative';
|
|
9
9
|
export * from './extractor/extractHelpers';
|
|
10
|
-
export * from './extractor/
|
|
11
|
-
export * from './extractor/
|
|
10
|
+
export * from './extractor/loadGui';
|
|
11
|
+
export * from './extractor/watchGuiConfig';
|
|
12
12
|
export * from './extractor/createLogger';
|
|
13
13
|
export * from './registerRequire';
|
|
14
14
|
export { detectModuleFormat, clearFormatCache } from './extractor/detectModuleFormat';
|
package/types/exports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACrF,cAAc,oBAAoB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import esbuild from 'esbuild';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GuiPlatform } from '../types';
|
|
3
3
|
export declare const esbuildLoaderConfig: {
|
|
4
4
|
readonly '.js': "jsx";
|
|
5
5
|
readonly '.png': "dataurl";
|
|
@@ -34,7 +34,7 @@ type Props = Omit<Partial<esbuild.BuildOptions>, 'entryPoints'> & {
|
|
|
34
34
|
entryPoints: string[];
|
|
35
35
|
resolvePlatformSpecificEntries?: boolean;
|
|
36
36
|
};
|
|
37
|
-
export declare function
|
|
37
|
+
export declare function esbundleGuiConfig(props: Props, platform: GuiPlatform, aliases?: Record<string, string>): Promise<esbuild.BuildResult<{
|
|
38
38
|
outfile: string;
|
|
39
39
|
bundle?: boolean;
|
|
40
40
|
splitting?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/extractor/bundle.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/extractor/bundle.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAO3C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;CAwBtB,CAAA;AAQV,eAAO,MAAM,uBAAuB,QAAqD,CAAA;AAEzF;;GAEG;AAEH,KAAK,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,GAAG;IAChE,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,CAAA;AA6MD,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,WAAW,EACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgBjC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type StaticConfig, type
|
|
1
|
+
import { type StaticConfig, type GuiInternalConfig } from '@hanzogui/web';
|
|
2
2
|
import esbuild from 'esbuild';
|
|
3
|
-
import type {
|
|
3
|
+
import type { GuiOptions } from '../types';
|
|
4
4
|
type NameToPaths = {
|
|
5
5
|
[key: string]: Set<string>;
|
|
6
6
|
};
|
|
@@ -10,9 +10,9 @@ export type LoadedComponents = {
|
|
|
10
10
|
staticConfig: StaticConfig;
|
|
11
11
|
}>;
|
|
12
12
|
};
|
|
13
|
-
export type
|
|
13
|
+
export type GuiProjectInfo = {
|
|
14
14
|
components?: LoadedComponents[];
|
|
15
|
-
|
|
15
|
+
guiConfig?: GuiInternalConfig | null;
|
|
16
16
|
nameToPaths?: NameToPaths;
|
|
17
17
|
cached?: boolean;
|
|
18
18
|
};
|
|
@@ -37,13 +37,13 @@ export declare const esbuildOptionsWithPlugins: {
|
|
|
37
37
|
};
|
|
38
38
|
export type BundledConfig = Exclude<Awaited<ReturnType<typeof bundleConfig>>, undefined>;
|
|
39
39
|
export declare function hasBundledConfigChanged(): boolean;
|
|
40
|
-
export declare const getLoadedConfig: () =>
|
|
41
|
-
export declare function getBundledConfig(props:
|
|
42
|
-
export declare function bundleConfig(props:
|
|
43
|
-
export declare function
|
|
44
|
-
export declare function loadComponents(props:
|
|
45
|
-
export declare function loadComponentsSync(props:
|
|
46
|
-
export declare function loadComponentsInner(props:
|
|
47
|
-
export declare function loadComponentsInnerSync(props:
|
|
40
|
+
export declare const getLoadedConfig: () => GuiInternalConfig | null;
|
|
41
|
+
export declare function getBundledConfig(props: GuiOptions, rebuild?: boolean): Promise<any>;
|
|
42
|
+
export declare function bundleConfig(props: GuiOptions): Promise<any>;
|
|
43
|
+
export declare function writeGuiCSS(outputCSS: string, config: GuiInternalConfig): Promise<void>;
|
|
44
|
+
export declare function loadComponents(props: GuiOptions, forceExports?: boolean): Promise<LoadedComponents[]>;
|
|
45
|
+
export declare function loadComponentsSync(props: GuiOptions, forceExports?: boolean): LoadedComponents[];
|
|
46
|
+
export declare function loadComponentsInner(props: GuiOptions, forceExports?: boolean): Promise<null | LoadedComponents[]>;
|
|
47
|
+
export declare function loadComponentsInnerSync(props: GuiOptions, forceExports?: boolean): null | LoadedComponents[];
|
|
48
48
|
export {};
|
|
49
49
|
//# sourceMappingURL=bundleConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleConfig.d.ts","sourceRoot":"","sources":["../../src/extractor/bundleConfig.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"bundleConfig.d.ts","sourceRoot":"","sources":["../../src/extractor/bundleConfig.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACzE,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAyE1C,KAAK,WAAW,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAChB,MAAM,EACN;QACE,YAAY,EAAE,YAAY,CAAA;KAC3B,CACF,CAAA;CACF,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC/B,SAAS,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;IACpC,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAgGD,eAAO,MAAM,cAAc;;;;;;;;CAEK,CAAA;AAGhC,eAAO,MAAM,yBAAyB;;;;;;;;;CAGN,CAAA;AAEhC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;AAQxF,wBAAgB,uBAAuB,YAMtC;AAID,eAAO,MAAM,eAAe,gCAAqB,CAAA;AAEjD,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,UAAQ,gBASxE;AAgBD,wBAAsB,YAAY,CAAC,KAAK,EAAE,UAAU,gBAmPnD;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,iBAmB7E;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,UAAQ,+BAI3E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,UAAQ,sBAIzE;AAqBD,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,UAAU,EACjB,YAAY,UAAQ,GACnB,OAAO,CAAC,IAAI,GAAG,gBAAgB,EAAE,CAAC,CAyJpC;AAGD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,UAAU,EACjB,YAAY,UAAQ,GACnB,IAAI,GAAG,gBAAgB,EAAE,CAyI3B"}
|