@gtkx/cli 1.0.0-rc.3 → 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 +3 -3
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +14 -14
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/codegen/store-resolver.d.ts +1 -3
- package/dist/codegen/store-resolver.d.ts.map +1 -1
- package/dist/codegen/store-resolver.js +13 -32
- 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.js +13 -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/react-compiler.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 +18 -18
- package/src/codegen/store-resolver.ts +14 -40
- 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 +15 -15
- 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/react-compiler.ts +1 -1
- package/src/vitest-plugin.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/cli",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
4
|
"description": "Command-line tool and Vite plugin stack that scaffolds, develops, builds, and documents GTKX applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -56,25 +56,25 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@babel/core": "^8.0.1",
|
|
58
58
|
"@babel/preset-typescript": "^8.0.1",
|
|
59
|
-
"@swc/core": "^1.15.
|
|
59
|
+
"@swc/core": "^1.15.47",
|
|
60
60
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
61
61
|
"citty": "^0.2.2",
|
|
62
62
|
"fast-xml-parser": "^5.10.1",
|
|
63
63
|
"react-refresh": "^0.18.0",
|
|
64
|
-
"vite": "^8.
|
|
65
|
-
"@gtkx/
|
|
66
|
-
"@gtkx/
|
|
67
|
-
"@gtkx/
|
|
68
|
-
"@gtkx/
|
|
69
|
-
"@gtkx/
|
|
70
|
-
"@gtkx/vitest": "1.0.0-rc.
|
|
71
|
-
"create-gtkx": "1.0.0-rc.
|
|
64
|
+
"vite": "^8.2.0",
|
|
65
|
+
"@gtkx/codegen": "1.0.0-rc.4",
|
|
66
|
+
"@gtkx/config": "1.0.0-rc.4",
|
|
67
|
+
"@gtkx/runtime": "1.0.0-rc.4",
|
|
68
|
+
"@gtkx/utils": "1.0.0-rc.4",
|
|
69
|
+
"@gtkx/mcp": "1.0.0-rc.4",
|
|
70
|
+
"@gtkx/vitest": "1.0.0-rc.4",
|
|
71
|
+
"create-gtkx": "1.0.0-rc.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/babel__core": "^7.20.5",
|
|
75
75
|
"@types/react-refresh": "^0.14.7",
|
|
76
76
|
"vitest": "^4.1.10",
|
|
77
|
-
"@gtkx/testing": "1.0.0-rc.
|
|
77
|
+
"@gtkx/testing": "1.0.0-rc.4"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"react": "^19"
|
package/src/codegen/freshness.ts
CHANGED
|
@@ -27,15 +27,12 @@ const namespaceBarrelPath = (giStoreDir: string, library: string): string => {
|
|
|
27
27
|
return join(giStoreDir, namespace, "index.js");
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// The manifest is what makes the store resolvable as a package, and npm's prune of a generated store
|
|
31
|
+
// removes the link while leaving the directory behind, so both have to be checked.
|
|
32
|
+
const hasManifest = (storeDir: string): boolean => existsSync(join(storeDir, "package.json"));
|
|
32
33
|
|
|
33
34
|
const isGiStoreStale = (store: CodegenStore, libraries: string[]): boolean => {
|
|
34
|
-
if (!existsSync(store.giLinkDir) || !
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (!isStoreResolvable(store.giStoreDir, "gi")) {
|
|
35
|
+
if (!existsSync(store.giLinkDir) || !hasManifest(store.giStoreDir)) {
|
|
39
36
|
return true;
|
|
40
37
|
}
|
|
41
38
|
|
|
@@ -47,7 +44,7 @@ const isReactStoreStale = (store: CodegenStore): boolean => {
|
|
|
47
44
|
return false;
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
if (!existsSync(store.jsxLinkDir) || !
|
|
47
|
+
if (!existsSync(store.jsxLinkDir) || !hasManifest(store.jsxStoreDir)) {
|
|
51
48
|
return true;
|
|
52
49
|
}
|
|
53
50
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
resolveElementComponents,
|
|
5
5
|
resolveElementProps,
|
|
6
6
|
resolveLazyElements,
|
|
7
|
-
|
|
7
|
+
resolveOmittedProps,
|
|
8
8
|
} from "@gtkx/config/internal";
|
|
9
9
|
import { info } from "@gtkx/utils";
|
|
10
10
|
import { rmSync } from "node:fs";
|
|
@@ -17,7 +17,7 @@ import { type CodegenStore, resolveCodegenContext } from "./store-resolver.js";
|
|
|
17
17
|
type RunCodegenOptions = {
|
|
18
18
|
cwd?: string;
|
|
19
19
|
mode?: string | undefined;
|
|
20
|
-
|
|
20
|
+
isForced?: boolean;
|
|
21
21
|
inputs?: CodegenInputs;
|
|
22
22
|
resolved?: LoadedConfig;
|
|
23
23
|
};
|
|
@@ -28,7 +28,7 @@ type LoadedConfig = {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
type RunCodegenResult = {
|
|
31
|
-
|
|
31
|
+
isRegenerated: boolean;
|
|
32
32
|
namespaces: number;
|
|
33
33
|
intrinsicElements: number;
|
|
34
34
|
duration: number;
|
|
@@ -44,7 +44,7 @@ type CodegenOptionsInput = {
|
|
|
44
44
|
elements: Config["elements"];
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
type PreparedCodegen = CodegenInputs & {
|
|
47
|
+
type PreparedCodegen = CodegenInputs & { isForced: boolean };
|
|
48
48
|
|
|
49
49
|
type RunOptionsInput = {
|
|
50
50
|
root: string;
|
|
@@ -89,11 +89,11 @@ const codegenOptions = ({ store, libraries, girPath, elements }: CodegenOptionsI
|
|
|
89
89
|
userComponents: resolveElementComponents(elements),
|
|
90
90
|
userProps: resolveElementProps(elements),
|
|
91
91
|
userLazyElements: resolveLazyElements(elements),
|
|
92
|
-
|
|
92
|
+
userOmittedProps: resolveOmittedProps(elements),
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
const disabledCodegenResult = (configFile: string): RunCodegenResult => ({
|
|
96
|
-
|
|
96
|
+
isRegenerated: false,
|
|
97
97
|
namespaces: 0,
|
|
98
98
|
intrinsicElements: 0,
|
|
99
99
|
duration: 0,
|
|
@@ -118,9 +118,9 @@ const prepareCodegen = (options: RunCodegenOptions, cwd: string, config: Config)
|
|
|
118
118
|
throw new Error(GIR_PATH_MISSING_MESSAGE);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
const
|
|
121
|
+
const isForced = options.isForced === true || isCodegenStale({ girPath, libraries, store });
|
|
122
122
|
|
|
123
|
-
return { girPath, libraries, store,
|
|
123
|
+
return { girPath, libraries, store, isForced };
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenResult> => {
|
|
@@ -133,9 +133,9 @@ const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenRe
|
|
|
133
133
|
return disabledCodegenResult(configFile);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
const { girPath, libraries, store,
|
|
136
|
+
const { girPath, libraries, store, isForced } = prepareCodegen(options, cwd, config);
|
|
137
137
|
|
|
138
|
-
if (options.
|
|
138
|
+
if (options.isForced) {
|
|
139
139
|
clearGeneratedStores(store);
|
|
140
140
|
}
|
|
141
141
|
|
|
@@ -146,11 +146,11 @@ const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenRe
|
|
|
146
146
|
girPath,
|
|
147
147
|
elements: config.elements,
|
|
148
148
|
}),
|
|
149
|
-
|
|
149
|
+
isForced,
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
return {
|
|
153
|
-
|
|
153
|
+
isRegenerated: result.isRegenerated,
|
|
154
154
|
namespaces: result.namespaces,
|
|
155
155
|
intrinsicElements: result.intrinsicElements,
|
|
156
156
|
duration: result.duration,
|
|
@@ -182,8 +182,8 @@ const resolveInputsOrNull = (cwd: string, config: Config): CodegenInputs | null
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
const maybeAnnounceStale = (
|
|
186
|
-
if (!
|
|
185
|
+
const maybeAnnounceStale = (shouldAnnounce: boolean | undefined, inputs: CodegenInputs | null): void => {
|
|
186
|
+
if (!shouldAnnounce) {
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -202,9 +202,9 @@ const getRunOptions = ({ root, mode, inputs, resolved }: RunOptionsInput): RunCo
|
|
|
202
202
|
|
|
203
203
|
const ensureGenerated = async (
|
|
204
204
|
cwd: string,
|
|
205
|
-
options: {
|
|
205
|
+
options: { shouldAnnounce?: boolean; mode?: string } = {},
|
|
206
206
|
): Promise<boolean> => {
|
|
207
|
-
if (options.
|
|
207
|
+
if (options.shouldAnnounce && process.env.GTKX_DISABLE_PREFLIGHT === "1") {
|
|
208
208
|
return false;
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -218,11 +218,11 @@ const ensureGenerated = async (
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
const inputs = resolveInputsOrNull(context.root, context.config);
|
|
221
|
-
maybeAnnounceStale(options.
|
|
221
|
+
maybeAnnounceStale(options.shouldAnnounce, inputs);
|
|
222
222
|
const resolved = { config: context.config, configFile: context.configFile };
|
|
223
223
|
const result = await runCodegen(getRunOptions({ root: context.root, mode: options.mode, inputs, resolved }));
|
|
224
224
|
|
|
225
|
-
return result.
|
|
225
|
+
return result.isRegenerated;
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
const resolveConfigWatch = async (
|
|
@@ -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";
|
|
@@ -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,36 +52,27 @@ 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
|
-
|
|
80
|
-
const native = resolvePackage(require, dir, "@gtkx/native");
|
|
81
59
|
|
|
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
|
};
|
|
@@ -109,4 +83,4 @@ const resolveCodegenContext = async (cwd: string, mode?: string): Promise<Codege
|
|
|
109
83
|
return { root: cwd, config, configFile };
|
|
110
84
|
};
|
|
111
85
|
|
|
112
|
-
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,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ElementProps,
|
|
3
|
-
|
|
3
|
+
mergeOmittedProps,
|
|
4
4
|
type OmittedProps,
|
|
5
5
|
readBuiltinElements,
|
|
6
6
|
resolveGirPath,
|
|
7
7
|
resolveLibraries,
|
|
8
|
-
|
|
8
|
+
resolveStore,
|
|
9
9
|
} from "@gtkx/codegen";
|
|
10
|
+
import { writeDocs } from "@gtkx/codegen/internal";
|
|
10
11
|
import { loadConfig } from "@gtkx/config";
|
|
11
|
-
import {
|
|
12
|
+
import { resolveOmittedProps } from "@gtkx/config/internal";
|
|
12
13
|
import { info } from "@gtkx/utils";
|
|
13
14
|
import { defineCommand } from "citty";
|
|
14
15
|
import { existsSync } from "node:fs";
|
|
15
|
-
import {
|
|
16
|
-
import { resolveReactSubexports } from "../codegen/store-resolver.js";
|
|
16
|
+
import { resolve } from "node:path";
|
|
17
17
|
import { cwdArg, resolveCwd } from "../internal/entry-arg.js";
|
|
18
18
|
|
|
19
19
|
const docs = defineCommand({
|
|
@@ -66,17 +66,17 @@ const docs = defineCommand({
|
|
|
66
66
|
const outDir = resolve(cwd, args.out);
|
|
67
67
|
const builtin = await resolveDocsElements(cwd);
|
|
68
68
|
|
|
69
|
-
const {
|
|
69
|
+
const { isRegenerated, namespaces } = writeDocs({
|
|
70
70
|
libraries,
|
|
71
71
|
girPath,
|
|
72
72
|
outDir,
|
|
73
73
|
basePath: args["base-path"],
|
|
74
74
|
props: builtin.props,
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
omittedProps: mergeOmittedProps(builtin.omittedProps, resolveOmittedProps(config.elements)),
|
|
76
|
+
isForced: args.force,
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
if (!
|
|
79
|
+
if (!isRegenerated) {
|
|
80
80
|
info(`docs: pages in ${outDir} are up to date`);
|
|
81
81
|
|
|
82
82
|
return;
|
|
@@ -91,16 +91,16 @@ const docs = defineCommand({
|
|
|
91
91
|
},
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
const resolveDocsElements = async (cwd: string): Promise<{ props: ElementProps;
|
|
95
|
-
const
|
|
94
|
+
const resolveDocsElements = async (cwd: string): Promise<{ props: ElementProps; omittedProps: OmittedProps }> => {
|
|
95
|
+
const { gi, reactSubexports } = resolveStore(cwd);
|
|
96
96
|
|
|
97
|
-
if (!existsSync(
|
|
98
|
-
return { props: {},
|
|
97
|
+
if (!existsSync(gi.storeDir)) {
|
|
98
|
+
return { props: {}, omittedProps: {} };
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
const { props,
|
|
101
|
+
const { props, omittedProps } = await readBuiltinElements(reactSubexports, gi.storeDir);
|
|
102
102
|
|
|
103
|
-
return { props,
|
|
103
|
+
return { props, omittedProps };
|
|
104
104
|
};
|
|
105
105
|
|
|
106
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 {
|
|
@@ -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";
|
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;
|