@gtkx/cli 1.0.0-rc.2 → 1.0.0-rc.4
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/README.md +4 -5
- package/dist/codegen/freshness.d.ts.map +1 -1
- package/dist/codegen/freshness.js +5 -6
- package/dist/codegen/freshness.js.map +1 -1
- package/dist/codegen/run-codegen.d.ts +5 -5
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +22 -26
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/codegen/store-resolver.d.ts +3 -5
- package/dist/codegen/store-resolver.d.ts.map +1 -1
- package/dist/codegen/store-resolver.js +13 -35
- package/dist/codegen/store-resolver.js.map +1 -1
- package/dist/commands/build.js +1 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/codegen.js +1 -1
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +16 -13
- package/dist/commands/docs.js.map +1 -1
- package/dist/dev/supervisor.js +14 -14
- package/dist/dev/supervisor.js.map +1 -1
- package/dist/mcp/handlers.js +1 -1
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/mcp/serialize-widget.js +2 -2
- package/dist/mcp/serialize-widget.js.map +1 -1
- package/dist/refresh-runtime.d.ts +0 -10
- package/dist/refresh-runtime.d.ts.map +1 -1
- package/dist/refresh-runtime.js +0 -17
- package/dist/refresh-runtime.js.map +1 -1
- package/dist/settings/schema.d.ts +1 -1
- package/dist/settings/schema.d.ts.map +1 -1
- package/dist/settings/schema.js +1 -1
- package/dist/settings/schema.js.map +1 -1
- package/dist/vite-plugins/index.js +1 -1
- package/dist/vite-plugins/index.js.map +1 -1
- package/dist/vite-plugins/react-compiler.js +1 -1
- package/dist/vite-plugins/react-compiler.js.map +1 -1
- package/dist/vite-plugins/resources.js +1 -1
- package/dist/vite-plugins/resources.js.map +1 -1
- package/dist/vite-plugins/undeclared-library.d.ts +2 -1
- package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
- package/dist/vite-plugins/undeclared-library.js +4 -4
- package/dist/vite-plugins/undeclared-library.js.map +1 -1
- package/dist/vitest-plugin.d.ts +0 -6
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +0 -6
- package/dist/vitest-plugin.js.map +1 -1
- package/env.d.ts +25 -0
- package/package.json +11 -11
- package/src/codegen/freshness.ts +5 -8
- package/src/codegen/run-codegen.ts +34 -44
- package/src/codegen/store-resolver.ts +16 -46
- package/src/commands/build.ts +1 -1
- package/src/commands/codegen.ts +1 -1
- package/src/commands/dev.ts +1 -1
- package/src/commands/docs.ts +24 -13
- package/src/dev/supervisor.ts +16 -16
- package/src/mcp/handlers.ts +1 -1
- package/src/mcp/serialize-widget.ts +2 -2
- package/src/refresh-runtime.ts +0 -17
- package/src/settings/schema.ts +2 -2
- package/src/vite-plugins/index.ts +1 -1
- package/src/vite-plugins/react-compiler.ts +2 -2
- package/src/vite-plugins/resources.ts +1 -1
- package/src/vite-plugins/undeclared-library.ts +6 -5
- package/src/vitest-plugin.ts +0 -6
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveStore } from "@gtkx/codegen";
|
|
1
2
|
import { type Config, loadConfig } from "@gtkx/config";
|
|
2
3
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
3
4
|
import { createRequire } from "node:module";
|
|
@@ -23,7 +24,7 @@ type ResolvedPackage = { dir: string; version: string };
|
|
|
23
24
|
type CodegenContext = {
|
|
24
25
|
root: string;
|
|
25
26
|
config: Config;
|
|
26
|
-
configFile: string
|
|
27
|
+
configFile: string;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
const readVersion = (packageJsonPath: string): string => {
|
|
@@ -32,24 +33,6 @@ const readVersion = (packageJsonPath: string): string => {
|
|
|
32
33
|
return parsed.version ?? "0.0.0";
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
const readSubexports = (packageDir: string): string[] => {
|
|
36
|
-
const parsed = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8")) as {
|
|
37
|
-
exports?: Record<string, unknown>;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return Object.keys(parsed.exports ?? {})
|
|
41
|
-
.filter((key) => key.startsWith("./") && key !== "./package.json")
|
|
42
|
-
.map((key) => key.slice(2));
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/** Resolves the `@gtkx/react` subexport names for a project without requiring runtime/native to be installed. */
|
|
46
|
-
const resolveReactSubexports = (dir: string): string[] => {
|
|
47
|
-
const require = createRequire(pathToFileURL(join(dir, "__gtkx_resolver__.js")).href);
|
|
48
|
-
const react = resolvePackage(require, dir, "@gtkx/react");
|
|
49
|
-
|
|
50
|
-
return react === null ? [] : readSubexports(react.dir);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
36
|
const resolvePackage = (require: NodeJS.Require, dir: string, packageName: string): ResolvedPackage | null => {
|
|
54
37
|
try {
|
|
55
38
|
const real = realpathSync(require.resolve(`${packageName}/package.json`));
|
|
@@ -69,48 +52,35 @@ const resolvePackage = (require: NodeJS.Require, dir: string, packageName: strin
|
|
|
69
52
|
}
|
|
70
53
|
};
|
|
71
54
|
|
|
55
|
+
const siblingStore = (giDir: string): string => join(dirname(giDir), "jsx");
|
|
56
|
+
|
|
72
57
|
const resolveCodegenStore = (dir: string): CodegenStore => {
|
|
73
58
|
const require = createRequire(pathToFileURL(join(dir, "__gtkx_resolver__.js")).href);
|
|
74
|
-
const runtime = resolvePackage(require, dir, "@gtkx/runtime");
|
|
75
|
-
|
|
76
|
-
if (runtime === null) {
|
|
77
|
-
throw new Error("Cannot resolve @gtkx/runtime from the project; is it installed?");
|
|
78
|
-
}
|
|
79
59
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (native === null) {
|
|
60
|
+
if (resolvePackage(require, dir, "@gtkx/native") === null) {
|
|
83
61
|
throw new Error("Cannot resolve @gtkx/native from the project; is it installed?");
|
|
84
62
|
}
|
|
85
63
|
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const nodeModules = join(dir, "node_modules");
|
|
64
|
+
const store = resolveStore(dir);
|
|
65
|
+
const hasReactRuntime = resolvePackage(require, dir, "react") !== null;
|
|
89
66
|
|
|
90
67
|
return {
|
|
91
|
-
giStoreDir:
|
|
92
|
-
giLinkDir:
|
|
93
|
-
jsxStoreDir:
|
|
94
|
-
jsxLinkDir:
|
|
95
|
-
runtimeVersion:
|
|
68
|
+
giStoreDir: store.gi.storeDir,
|
|
69
|
+
giLinkDir: store.gi.linkDir,
|
|
70
|
+
jsxStoreDir: store.jsx?.storeDir ?? siblingStore(store.gi.storeDir),
|
|
71
|
+
jsxLinkDir: store.jsx?.linkDir ?? siblingStore(store.gi.linkDir),
|
|
72
|
+
runtimeVersion: store.gi.version,
|
|
96
73
|
react:
|
|
97
|
-
|
|
98
|
-
? {
|
|
99
|
-
version: react.version,
|
|
100
|
-
subexports: readSubexports(react.dir),
|
|
101
|
-
}
|
|
74
|
+
hasReactRuntime && store.jsx !== null
|
|
75
|
+
? { version: store.jsx.version, subexports: store.reactSubexports }
|
|
102
76
|
: null,
|
|
103
77
|
};
|
|
104
78
|
};
|
|
105
79
|
|
|
106
|
-
const resolveCodegenContext = async (cwd: string, mode?: string): Promise<CodegenContext
|
|
80
|
+
const resolveCodegenContext = async (cwd: string, mode?: string): Promise<CodegenContext> => {
|
|
107
81
|
const { config, configFile } = await loadConfig(cwd, { mode });
|
|
108
82
|
|
|
109
|
-
if (configFile === undefined) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
83
|
return { root: cwd, config, configFile };
|
|
114
84
|
};
|
|
115
85
|
|
|
116
|
-
export {
|
|
86
|
+
export { resolveCodegenStore, resolveCodegenContext, type CodegenStore, type CodegenContext };
|
package/src/commands/build.ts
CHANGED
|
@@ -21,7 +21,7 @@ const build = defineCommand({
|
|
|
21
21
|
async run({ args }) {
|
|
22
22
|
const { cwd, entry } = resolveEntry(args);
|
|
23
23
|
info(`Building ${entry}`);
|
|
24
|
-
await ensureGenerated(cwd, {
|
|
24
|
+
await ensureGenerated(cwd, { shouldAnnounce: true, mode: BUILD_MODE });
|
|
25
25
|
|
|
26
26
|
await buildApp({
|
|
27
27
|
entry,
|
package/src/commands/codegen.ts
CHANGED
|
@@ -36,7 +36,7 @@ const codegen = defineCommand({
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const startedAt = Date.now();
|
|
39
|
-
const result = await runCodegen({ cwd,
|
|
39
|
+
const result = await runCodegen({ cwd, isForced: true });
|
|
40
40
|
syncSchemaEnv(cwd);
|
|
41
41
|
const lines = formatCodegenResult(result, Date.now() - startedAt);
|
|
42
42
|
|
package/src/commands/dev.ts
CHANGED
|
@@ -15,7 +15,7 @@ const dev = defineCommand({
|
|
|
15
15
|
},
|
|
16
16
|
async run({ args }) {
|
|
17
17
|
const { cwd, entry: entryPath } = resolveEntry(args);
|
|
18
|
-
await ensureGenerated(cwd, {
|
|
18
|
+
await ensureGenerated(cwd, { shouldAnnounce: true, mode: DEV_MODE });
|
|
19
19
|
const watch: DevWatch | undefined = await resolveConfigWatch(cwd, DEV_MODE);
|
|
20
20
|
await runDevSupervisor(entryPath, cwd, watch);
|
|
21
21
|
},
|
package/src/commands/docs.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ElementProps,
|
|
3
|
+
mergeOmittedProps,
|
|
4
|
+
type OmittedProps,
|
|
5
|
+
readBuiltinElements,
|
|
6
|
+
resolveGirPath,
|
|
7
|
+
resolveLibraries,
|
|
8
|
+
resolveStore,
|
|
9
|
+
} from "@gtkx/codegen";
|
|
10
|
+
import { writeDocs } from "@gtkx/codegen/internal";
|
|
2
11
|
import { loadConfig } from "@gtkx/config";
|
|
12
|
+
import { resolveOmittedProps } from "@gtkx/config/internal";
|
|
3
13
|
import { info } from "@gtkx/utils";
|
|
4
14
|
import { defineCommand } from "citty";
|
|
5
15
|
import { existsSync } from "node:fs";
|
|
6
|
-
import {
|
|
7
|
-
import { resolveReactSubexports } from "../codegen/store-resolver.js";
|
|
16
|
+
import { resolve } from "node:path";
|
|
8
17
|
import { cwdArg, resolveCwd } from "../internal/entry-arg.js";
|
|
9
18
|
|
|
10
19
|
const docs = defineCommand({
|
|
@@ -55,17 +64,19 @@ const docs = defineCommand({
|
|
|
55
64
|
const libraries = resolveLibraries(config.libraries, girPath);
|
|
56
65
|
const startedAt = Date.now();
|
|
57
66
|
const outDir = resolve(cwd, args.out);
|
|
67
|
+
const builtin = await resolveDocsElements(cwd);
|
|
58
68
|
|
|
59
|
-
const {
|
|
69
|
+
const { isRegenerated, namespaces } = writeDocs({
|
|
60
70
|
libraries,
|
|
61
71
|
girPath,
|
|
62
72
|
outDir,
|
|
63
73
|
basePath: args["base-path"],
|
|
64
|
-
props:
|
|
65
|
-
|
|
74
|
+
props: builtin.props,
|
|
75
|
+
omittedProps: mergeOmittedProps(builtin.omittedProps, resolveOmittedProps(config.elements)),
|
|
76
|
+
isForced: args.force,
|
|
66
77
|
});
|
|
67
78
|
|
|
68
|
-
if (!
|
|
79
|
+
if (!isRegenerated) {
|
|
69
80
|
info(`docs: pages in ${outDir} are up to date`);
|
|
70
81
|
|
|
71
82
|
return;
|
|
@@ -80,16 +91,16 @@ const docs = defineCommand({
|
|
|
80
91
|
},
|
|
81
92
|
});
|
|
82
93
|
|
|
83
|
-
const
|
|
84
|
-
const
|
|
94
|
+
const resolveDocsElements = async (cwd: string): Promise<{ props: ElementProps; omittedProps: OmittedProps }> => {
|
|
95
|
+
const { gi, reactSubexports } = resolveStore(cwd);
|
|
85
96
|
|
|
86
|
-
if (!existsSync(
|
|
87
|
-
return {};
|
|
97
|
+
if (!existsSync(gi.storeDir)) {
|
|
98
|
+
return { props: {}, omittedProps: {} };
|
|
88
99
|
}
|
|
89
100
|
|
|
90
|
-
const { props } = await readBuiltinElements(
|
|
101
|
+
const { props, omittedProps } = await readBuiltinElements(reactSubexports, gi.storeDir);
|
|
91
102
|
|
|
92
|
-
return props;
|
|
103
|
+
return { props, omittedProps };
|
|
93
104
|
};
|
|
94
105
|
|
|
95
106
|
export { docs };
|
package/src/dev/supervisor.ts
CHANGED
|
@@ -28,8 +28,8 @@ type SupervisorState = {
|
|
|
28
28
|
watchers: FSWatcher[];
|
|
29
29
|
fork: ForkRunner;
|
|
30
30
|
child: SupervisedChild | null;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
isShuttingDown: boolean;
|
|
32
|
+
isRestarting: boolean;
|
|
33
33
|
capturedChildExit: number | undefined;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -72,11 +72,11 @@ const captureShutdownExit = (state: SupervisorState, code: number | null, signal
|
|
|
72
72
|
const handleChildExit = (state: SupervisorState, code: number | null, signal: NodeJS.Signals | null): void => {
|
|
73
73
|
state.child = null;
|
|
74
74
|
|
|
75
|
-
if (state.
|
|
75
|
+
if (state.isRestarting) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
if (state.
|
|
79
|
+
if (state.isShuttingDown) {
|
|
80
80
|
captureShutdownExit(state, code, signal);
|
|
81
81
|
|
|
82
82
|
return;
|
|
@@ -101,12 +101,12 @@ const launch = (state: SupervisorState): void => {
|
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
const isRestartBlocked = (state: SupervisorState): boolean => state.
|
|
104
|
+
const isRestartBlocked = (state: SupervisorState): boolean => state.isRestarting || state.isShuttingDown;
|
|
105
105
|
|
|
106
106
|
const relaunchAfterExit = (state: SupervisorState): void => {
|
|
107
|
-
state.
|
|
107
|
+
state.isRestarting = false;
|
|
108
108
|
|
|
109
|
-
if (state.
|
|
109
|
+
if (state.isShuttingDown) {
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -121,20 +121,20 @@ const restart = async (state: SupervisorState): Promise<void> => {
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
state.
|
|
124
|
+
state.isRestarting = true;
|
|
125
125
|
info("gtkx.config.ts changed; regenerating bindings...");
|
|
126
126
|
|
|
127
127
|
try {
|
|
128
128
|
await watch.regenerate();
|
|
129
129
|
} catch (error_) {
|
|
130
130
|
error("Codegen failed; keeping the current dev runner. Fix the error and save again.", error_);
|
|
131
|
-
state.
|
|
131
|
+
state.isRestarting = false;
|
|
132
132
|
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
if (state.
|
|
137
|
-
state.
|
|
136
|
+
if (state.isShuttingDown) {
|
|
137
|
+
state.isRestarting = false;
|
|
138
138
|
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
@@ -142,7 +142,7 @@ const restart = async (state: SupervisorState): Promise<void> => {
|
|
|
142
142
|
const current = state.child;
|
|
143
143
|
|
|
144
144
|
if (current === null) {
|
|
145
|
-
state.
|
|
145
|
+
state.isRestarting = false;
|
|
146
146
|
launch(state);
|
|
147
147
|
|
|
148
148
|
return;
|
|
@@ -164,7 +164,7 @@ const scheduleRestart = (state: SupervisorState, timer: DebounceTimer): void =>
|
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
const isWatchedChange = (state: SupervisorState, names: Set<string>, filename: string | Buffer | null): boolean => {
|
|
167
|
-
if (filename === null || state.
|
|
167
|
+
if (filename === null || state.isShuttingDown) {
|
|
168
168
|
return false;
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -222,7 +222,7 @@ const closeWatchers = (state: SupervisorState): void => {
|
|
|
222
222
|
|
|
223
223
|
const shutdownOnSignal = (state: SupervisorState, signal: NodeJS.Signals): Promise<void> =>
|
|
224
224
|
new Promise<void>((resolve) => {
|
|
225
|
-
state.
|
|
225
|
+
state.isShuttingDown = true;
|
|
226
226
|
closeWatchers(state);
|
|
227
227
|
|
|
228
228
|
if (!state.child) {
|
|
@@ -261,8 +261,8 @@ const runDevSupervisor = async (
|
|
|
261
261
|
watchers: [],
|
|
262
262
|
fork,
|
|
263
263
|
child: null,
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
isShuttingDown: false,
|
|
265
|
+
isRestarting: false,
|
|
266
266
|
capturedChildExit: undefined,
|
|
267
267
|
};
|
|
268
268
|
|
package/src/mcp/handlers.ts
CHANGED
|
@@ -37,7 +37,7 @@ const HANDLERS: Record<ServerInitiatedMethod, ValidatedHandler> = {
|
|
|
37
37
|
return {
|
|
38
38
|
tree: testing.prettyWidget(container, {
|
|
39
39
|
getId: (w) => registry.getOrCreateId(w),
|
|
40
|
-
|
|
40
|
+
shouldHighlight: false,
|
|
41
41
|
...((params.maxDepth !== undefined) && { maxDepth: params.maxDepth }),
|
|
42
42
|
}),
|
|
43
43
|
};
|
|
@@ -31,8 +31,8 @@ const serializeWidget = (
|
|
|
31
31
|
role: testing.formatRole(widget.getAccessibleRole()),
|
|
32
32
|
name: widget.getName() || null,
|
|
33
33
|
text: testing.getWidgetNodeText(widget),
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
isSensitive: widget.getSensitive(),
|
|
35
|
+
isVisible: widget.getVisible(),
|
|
36
36
|
cssClasses: widget.getCssClasses(),
|
|
37
37
|
children,
|
|
38
38
|
};
|
package/src/refresh-runtime.ts
CHANGED
|
@@ -3,13 +3,6 @@ import "./refresh-globals.js";
|
|
|
3
3
|
|
|
4
4
|
type ComponentType = (...args: unknown[]) => unknown;
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Builds the per-module `$RefreshReg$` and `$RefreshSig$` hooks that React Refresh
|
|
8
|
-
* transformed code expects, scoping every registered component to the given module.
|
|
9
|
-
*
|
|
10
|
-
* @param moduleId Identifier used to namespace registered component types so they are unique across modules.
|
|
11
|
-
* @returns An object with `$RefreshReg$` and `$RefreshSig$` to install as module-local globals.
|
|
12
|
-
*/
|
|
13
6
|
function createModuleRegistration(moduleId: string): {
|
|
14
7
|
$RefreshReg$: (type: ComponentType, id: string) => void;
|
|
15
8
|
$RefreshSig$: typeof RefreshRuntime.createSignatureFunctionForTransform;
|
|
@@ -22,13 +15,6 @@ function createModuleRegistration(moduleId: string): {
|
|
|
22
15
|
};
|
|
23
16
|
}
|
|
24
17
|
|
|
25
|
-
/**
|
|
26
|
-
* Determines whether a module can act as a React Refresh boundary, meaning every one of
|
|
27
|
-
* its exports (ignoring `__esModule`) looks like a React component type.
|
|
28
|
-
*
|
|
29
|
-
* @param moduleExports The module's export object to inspect.
|
|
30
|
-
* @returns `true` when the module qualifies as a refresh boundary, `false` otherwise.
|
|
31
|
-
*/
|
|
32
18
|
const isComponentExport = (key: string, value: unknown): boolean =>
|
|
33
19
|
key === "__esModule" || RefreshRuntime.isLikelyComponentType(value);
|
|
34
20
|
|
|
@@ -54,9 +40,6 @@ function isRefreshBoundary(moduleExports: Record<string, unknown>): boolean {
|
|
|
54
40
|
return Object.keys(moduleExports).some((k) => k !== "__esModule");
|
|
55
41
|
}
|
|
56
42
|
|
|
57
|
-
/**
|
|
58
|
-
* Applies all pending React Refresh updates, re-rendering components whose modules have changed.
|
|
59
|
-
*/
|
|
60
43
|
function performRefresh(): void {
|
|
61
44
|
RefreshRuntime.performReactRefresh();
|
|
62
45
|
}
|
package/src/settings/schema.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { renderEnvModule } from "./render.js";
|
|
|
11
11
|
|
|
12
12
|
type SchemaEnvResult = {
|
|
13
13
|
path: string;
|
|
14
|
-
|
|
14
|
+
isWritten: boolean;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const SCHEMA_SUFFIX = ".gschema.xml";
|
|
@@ -155,7 +155,7 @@ const emitSchemaEnv = (rootDir: string, dataDir: string | null): SchemaEnvResult
|
|
|
155
155
|
const path = schemaEnvPath(rootDir);
|
|
156
156
|
const isWritten = didWriteChanges(path, content);
|
|
157
157
|
|
|
158
|
-
return { path,
|
|
158
|
+
return { path, isWritten };
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
export {
|
|
@@ -13,7 +13,7 @@ const gtkxVitePlugins = (mode?: string): Plugin[] => {
|
|
|
13
13
|
|
|
14
14
|
return [
|
|
15
15
|
createConfigPlugin({ name: "gtkx:config", loadConfig }),
|
|
16
|
-
gtkxUndeclaredLibrary(
|
|
16
|
+
gtkxUndeclaredLibrary(loadConfig),
|
|
17
17
|
gtkxSettings(),
|
|
18
18
|
gtkxIcons(),
|
|
19
19
|
gtkxResources(loadConfig),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResolvedReactCompilerOptions } from "@gtkx/config";
|
|
1
|
+
import type { ResolvedReactCompilerOptions } from "@gtkx/config/internal";
|
|
2
2
|
import type { Plugin, ResolvedConfig, UserConfig } from "vite";
|
|
3
3
|
import { transformAsync } from "@babel/core";
|
|
4
4
|
import babelPresetTypescriptNs from "@babel/preset-typescript";
|
|
@@ -61,7 +61,7 @@ function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plu
|
|
|
61
61
|
enforce: "pre",
|
|
62
62
|
|
|
63
63
|
async config(config: UserConfig) {
|
|
64
|
-
const resolved = await loadConfig(config.root ?? process.cwd());
|
|
64
|
+
const resolved = await loadConfig.resolve(config.root ?? process.cwd());
|
|
65
65
|
state.options = resolved.reactCompiler;
|
|
66
66
|
},
|
|
67
67
|
|
|
@@ -253,7 +253,7 @@ const refreshDevRegistration = async (state: PluginState): Promise<void> => {
|
|
|
253
253
|
};
|
|
254
254
|
|
|
255
255
|
const resolveResourceConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader) => {
|
|
256
|
-
const { applicationId } = await loadConfig(config.root ?? process.cwd());
|
|
256
|
+
const { applicationId } = await loadConfig.resolve(config.root ?? process.cwd());
|
|
257
257
|
state.prefix = deriveResourcePrefix(applicationId);
|
|
258
258
|
|
|
259
259
|
return {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { ConfigLoader } from "@gtkx/config/internal";
|
|
1
2
|
import type { Plugin, UserConfig } from "vite";
|
|
2
3
|
import { discoverGirNamespaces, resolveGirPath } from "@gtkx/codegen";
|
|
3
|
-
import {
|
|
4
|
+
import { createConfigLoader } from "@gtkx/config/internal";
|
|
4
5
|
|
|
5
6
|
type PluginState = {
|
|
6
7
|
root: string;
|
|
7
|
-
|
|
8
|
+
loadConfig: ConfigLoader;
|
|
8
9
|
girPath: string[] | null;
|
|
9
10
|
};
|
|
10
11
|
|
|
@@ -12,7 +13,7 @@ const GENERATED_MODULE_PATTERN = /^@gtkx\/(?:gi|jsx)\/([a-z0-9]+)$/;
|
|
|
12
13
|
|
|
13
14
|
const girSearchPaths = async (state: PluginState): Promise<string[]> => {
|
|
14
15
|
if (state.girPath === null) {
|
|
15
|
-
const { config } = await loadConfig(state.root
|
|
16
|
+
const { config } = await state.loadConfig.load(state.root);
|
|
16
17
|
state.girPath = resolveGirPath(config.girPath);
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -42,10 +43,10 @@ const undeclaredLibraryError = (source: string, namespace: string, girPath: stri
|
|
|
42
43
|
);
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
function gtkxUndeclaredLibrary(
|
|
46
|
+
function gtkxUndeclaredLibrary(loadConfig: ConfigLoader = createConfigLoader()): Plugin {
|
|
46
47
|
const state: PluginState = {
|
|
47
48
|
root: "",
|
|
48
|
-
|
|
49
|
+
loadConfig,
|
|
49
50
|
girPath: null,
|
|
50
51
|
};
|
|
51
52
|
|
package/src/vitest-plugin.ts
CHANGED
|
@@ -3,11 +3,5 @@ import gtkxVitest from "@gtkx/vitest";
|
|
|
3
3
|
import { gtkxVitePlugins } from "./vite-plugins/index.js";
|
|
4
4
|
import { gtkxSettingsWorkerEnv } from "./vite-plugins/settings-worker-env.js";
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Vite plugin factory that assembles the plugins needed to run GTKX apps under Vitest,
|
|
8
|
-
* combining the shared GTKX Vite plugins with the `@gtkx/vitest` test integration.
|
|
9
|
-
*
|
|
10
|
-
* @returns The ordered array of Vite plugins to include in a Vitest configuration.
|
|
11
|
-
*/
|
|
12
6
|
const gtkx = (): Plugin[] => [...gtkxVitePlugins(), gtkxSettingsWorkerEnv(), gtkxVitest()];
|
|
13
7
|
export default gtkx;
|