@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
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
The React framework for Linux.<br />
|
|
9
|
-
|
|
9
|
+
Write native Linux applications with React and TypeScript.
|
|
10
|
+
Built on the GNOME stack and standard web tooling.
|
|
10
11
|
</p>
|
|
11
12
|
|
|
12
13
|
<p align="center">
|
|
@@ -20,15 +21,13 @@
|
|
|
20
21
|
|
|
21
22
|
<p align="center">
|
|
22
23
|
<a href="https://gtkx.dev">Homepage</a> ·
|
|
23
|
-
<a href="https://gtkx.dev/guide/
|
|
24
|
+
<a href="https://gtkx.dev/guide/getting-started">Documentation</a> ·
|
|
24
25
|
<a href="https://github.com/gtkx-org/gtkx/tree/main/examples">Examples</a> ·
|
|
25
26
|
<a href="https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md">Contributing</a>
|
|
26
27
|
</p>
|
|
27
28
|
|
|
28
29
|
---
|
|
29
30
|
|
|
30
|
-
GTKX generates fully typed bindings for the entire GTK4 and Adwaita surface directly from GObject-Introspection. On top of those bindings you get the React programming model: components and hooks driving GObject instances, with Fast Refresh while you develop.
|
|
31
|
-
|
|
32
31
|
<p align="center">
|
|
33
32
|
<img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/examples/tutorial/assets/screenshot.png" alt="The Tasks app: an Adwaita window with a sidebar of smart views and colored lists on the left, and a boxed task list on the right." />
|
|
34
33
|
</p>
|
|
@@ -109,7 +108,7 @@ React Native and similar frameworks hide the native toolkit so one API can run e
|
|
|
109
108
|
|
|
110
109
|
### Why Node.js, and why generated bindings
|
|
111
110
|
|
|
112
|
-
GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [
|
|
111
|
+
GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers the comparison in full.
|
|
113
112
|
|
|
114
113
|
GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
|
|
115
114
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../../src/codegen/freshness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,qBAAqB,CAAC;AAE7E,KAAK,aAAa,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,YAAY,CAAC;CACvB,CAAC;AAIF,QAAA,MAAM,oBAAoB,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,KAAG,aAM3D,CAAC;
|
|
1
|
+
{"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../../src/codegen/freshness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,qBAAqB,CAAC;AAE7E,KAAK,aAAa,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,YAAY,CAAC;CACvB,CAAC;AAIF,QAAA,MAAM,oBAAoB,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,KAAG,aAM3D,CAAC;AAiCF,QAAA,MAAM,cAAc,GAAI,QAAQ,aAAa,KAAG,OAM/C,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,CAAC"}
|
|
@@ -14,12 +14,11 @@ const namespaceBarrelPath = (giStoreDir, library) => {
|
|
|
14
14
|
const namespace = (separator === -1 ? library : library.slice(0, separator)).toLowerCase();
|
|
15
15
|
return join(giStoreDir, namespace, "index.js");
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
// The manifest is what makes the store resolvable as a package, and npm's prune of a generated store
|
|
18
|
+
// removes the link while leaving the directory behind, so both have to be checked.
|
|
19
|
+
const hasManifest = (storeDir) => existsSync(join(storeDir, "package.json"));
|
|
18
20
|
const isGiStoreStale = (store, libraries) => {
|
|
19
|
-
if (!existsSync(store.giLinkDir) || !
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
if (!canResolveGiStoreLinks(store.giStoreDir)) {
|
|
21
|
+
if (!existsSync(store.giLinkDir) || !hasManifest(store.giStoreDir)) {
|
|
23
22
|
return true;
|
|
24
23
|
}
|
|
25
24
|
return libraries.some((library) => !existsSync(namespaceBarrelPath(store.giStoreDir, library)));
|
|
@@ -28,7 +27,7 @@ const isReactStoreStale = (store) => {
|
|
|
28
27
|
if (store.react === null) {
|
|
29
28
|
return false;
|
|
30
29
|
}
|
|
31
|
-
if (!existsSync(store.jsxLinkDir)) {
|
|
30
|
+
if (!existsSync(store.jsxLinkDir) || !hasManifest(store.jsxStoreDir)) {
|
|
32
31
|
return true;
|
|
33
32
|
}
|
|
34
33
|
return REACT_GENERATED_MODULES.some((module) => !existsSync(join(store.jsxStoreDir, module)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freshness.js","sourceRoot":"","sources":["../../src/codegen/freshness.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAqB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ7E,MAAM,uBAAuB,GAAa,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEjF,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAE,MAAc,EAAiB,EAAE;IACxE,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAEvC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,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M,CAAC,CAAC,CAAC,CAAC;AAClG,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,MAAqB,EAAW,EAAE;IACtD,IAAI,CAAC;QACD,OAAO,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7F,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAsB,CAAC","sourcesContent":["import type { Config } from \"@gtkx/config\";\nimport { resolveGirPath, resolveLibraries } from \"@gtkx/codegen\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { type CodegenStore, resolveCodegenStore } from \"./store-resolver.js\";\n\ntype CodegenInputs = {\n girPath: string[];\n libraries: string[];\n store: CodegenStore;\n};\n\nconst REACT_GENERATED_MODULES: string[] = [\"metadata.js\", join(\"gtk\", \"gtk.js\")];\n\nconst resolveCodegenInputs = (cwd: string, config: Config): CodegenInputs => {\n const girPath = resolveGirPath(config.girPath);\n const libraries = resolveLibraries(config.libraries, girPath);\n const store = resolveCodegenStore(cwd);\n\n return { girPath, libraries, store };\n};\n\nconst namespaceBarrelPath = (giStoreDir: string, library: string): string => {\n const separator = library.indexOf(\"-\");\n const namespace = (separator === -1 ? library : library.slice(0, separator)).toLowerCase();\n\n return join(giStoreDir, namespace, \"index.js\");\n};\n\n// The manifest is what makes the store resolvable as a package, and npm's prune of a generated store\n// removes the link while leaving the directory behind, so both have to be checked.\nconst hasManifest = (storeDir: string): boolean => existsSync(join(storeDir, \"package.json\"));\n\nconst isGiStoreStale = (store: CodegenStore, libraries: string[]): boolean => {\n if (!existsSync(store.giLinkDir) || !hasManifest(store.giStoreDir)) {\n return true;\n }\n\n return libraries.some((library) => !existsSync(namespaceBarrelPath(store.giStoreDir, library)));\n};\n\nconst isReactStoreStale = (store: CodegenStore): boolean => {\n if (store.react === null) {\n return false;\n }\n\n if (!existsSync(store.jsxLinkDir) || !hasManifest(store.jsxStoreDir)) {\n return true;\n }\n\n return REACT_GENERATED_MODULES.some((module) => !existsSync(join(store.jsxStoreDir, module)));\n};\n\nconst isCodegenStale = (inputs: CodegenInputs): boolean => {\n try {\n return isGiStoreStale(inputs.store, inputs.libraries) || isReactStoreStale(inputs.store);\n } catch {\n return true;\n }\n};\n\nexport { resolveCodegenInputs, isCodegenStale, type CodegenInputs };\n"]}
|
|
@@ -3,16 +3,16 @@ import { type CodegenInputs } from "./freshness.js";
|
|
|
3
3
|
type RunCodegenOptions = {
|
|
4
4
|
cwd?: string;
|
|
5
5
|
mode?: string | undefined;
|
|
6
|
-
|
|
6
|
+
isForced?: boolean;
|
|
7
7
|
inputs?: CodegenInputs;
|
|
8
8
|
resolved?: LoadedConfig;
|
|
9
9
|
};
|
|
10
10
|
type LoadedConfig = {
|
|
11
11
|
config: Config;
|
|
12
|
-
configFile: string
|
|
12
|
+
configFile: string;
|
|
13
13
|
};
|
|
14
14
|
type RunCodegenResult = {
|
|
15
|
-
|
|
15
|
+
isRegenerated: boolean;
|
|
16
16
|
namespaces: number;
|
|
17
17
|
intrinsicElements: number;
|
|
18
18
|
duration: number;
|
|
@@ -24,12 +24,12 @@ declare const runCodegen: (options?: RunCodegenOptions) => Promise<RunCodegenRes
|
|
|
24
24
|
declare const isCodegenDisabled: (cwd: string, mode?: string) => Promise<boolean>;
|
|
25
25
|
declare const syncSchemaEnv: (cwd: string) => void;
|
|
26
26
|
declare const ensureGenerated: (cwd: string, options?: {
|
|
27
|
-
|
|
27
|
+
shouldAnnounce?: boolean;
|
|
28
28
|
mode?: string;
|
|
29
29
|
}) => Promise<boolean>;
|
|
30
30
|
declare const resolveConfigWatch: (cwd: string, mode?: string) => Promise<{
|
|
31
31
|
paths: string[];
|
|
32
32
|
regenerate: () => Promise<void>;
|
|
33
|
-
}
|
|
33
|
+
}>;
|
|
34
34
|
export { runCodegen, isCodegenDisabled, syncSchemaEnv, ensureGenerated, resolveConfigWatch, type RunCodegenOptions, type RunCodegenResult, };
|
|
35
35
|
//# sourceMappingURL=run-codegen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-codegen.d.ts","sourceRoot":"","sources":["../../src/codegen/run-codegen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"run-codegen.d.ts","sourceRoot":"","sources":["../../src/codegen/run-codegen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,cAAc,CAAC;AAYvD,OAAO,EAAE,KAAK,aAAa,EAAwC,MAAM,gBAAgB,CAAC;AAG1F,KAAK,iBAAiB,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,QAAQ,CAAC,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF,KAAK,YAAY,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACpC,CAAC;AAwFF,QAAA,MAAM,UAAU,GAAU,UAAS,iBAAsB,KAAG,OAAO,CAAC,gBAAgB,CAmCnF,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAU,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,OAAO,CAQ5E,CAAC;AAEF,QAAA,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,IAEpC,CAAC;AA4BF,QAAA,MAAM,eAAe,GACjB,KAAK,MAAM,EACX,UAAS;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,KAC1D,OAAO,CAAC,OAAO,CAoBjB,CAAC;AAEF,QAAA,MAAM,kBAAkB,GACpB,KAAK,MAAM,EACX,OAAO,MAAM,KACd,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAS9D,CAAC;AAEF,OAAO,EACH,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACxB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runCodegen as runCodegenCore } from "@gtkx/codegen";
|
|
2
2
|
import { loadConfig } from "@gtkx/config";
|
|
3
|
-
import { resolveLazyElements } from "@gtkx/config/internal";
|
|
3
|
+
import { resolveElementComponents, resolveElementProps, resolveLazyElements, resolveOmittedProps, } from "@gtkx/config/internal";
|
|
4
4
|
import { info } from "@gtkx/utils";
|
|
5
5
|
import { rmSync } from "node:fs";
|
|
6
6
|
import { resolve } from "node:path";
|
|
@@ -21,10 +21,6 @@ const removeSharedStoreShadow = (cwd) => {
|
|
|
21
21
|
rmSync(path, { recursive: true, force: true });
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
const userModuleExports = (elements, key) => Object.fromEntries(Object.entries(elements?.config ?? {}).flatMap(([type, entry]) => {
|
|
25
|
-
const ref = entry[key];
|
|
26
|
-
return ref === undefined ? [] : [[type, ref]];
|
|
27
|
-
}));
|
|
28
24
|
const codegenOptions = ({ store, libraries, girPath, elements }) => ({
|
|
29
25
|
libraries,
|
|
30
26
|
girPath,
|
|
@@ -41,12 +37,13 @@ const codegenOptions = ({ store, libraries, girPath, elements }) => ({
|
|
|
41
37
|
version: store.react.version,
|
|
42
38
|
},
|
|
43
39
|
reactSubexports: store.react?.subexports ?? [],
|
|
44
|
-
userComponents:
|
|
45
|
-
userProps:
|
|
40
|
+
userComponents: resolveElementComponents(elements),
|
|
41
|
+
userProps: resolveElementProps(elements),
|
|
46
42
|
userLazyElements: resolveLazyElements(elements),
|
|
43
|
+
userOmittedProps: resolveOmittedProps(elements),
|
|
47
44
|
});
|
|
48
45
|
const disabledCodegenResult = (configFile) => ({
|
|
49
|
-
|
|
46
|
+
isRegenerated: false,
|
|
50
47
|
namespaces: 0,
|
|
51
48
|
intrinsicElements: 0,
|
|
52
49
|
duration: 0,
|
|
@@ -65,8 +62,8 @@ const prepareCodegen = (options, cwd, config) => {
|
|
|
65
62
|
if (girPath.length === 0) {
|
|
66
63
|
throw new Error(GIR_PATH_MISSING_MESSAGE);
|
|
67
64
|
}
|
|
68
|
-
const
|
|
69
|
-
return { girPath, libraries, store,
|
|
65
|
+
const isForced = options.isForced === true || isCodegenStale({ girPath, libraries, store });
|
|
66
|
+
return { girPath, libraries, store, isForced };
|
|
70
67
|
};
|
|
71
68
|
const runCodegen = async (options = {}) => {
|
|
72
69
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -75,16 +72,21 @@ const runCodegen = async (options = {}) => {
|
|
|
75
72
|
removeSharedStoreShadow(cwd);
|
|
76
73
|
return disabledCodegenResult(configFile);
|
|
77
74
|
}
|
|
78
|
-
const { girPath, libraries, store,
|
|
79
|
-
if (options.
|
|
75
|
+
const { girPath, libraries, store, isForced } = prepareCodegen(options, cwd, config);
|
|
76
|
+
if (options.isForced) {
|
|
80
77
|
clearGeneratedStores(store);
|
|
81
78
|
}
|
|
82
79
|
const result = await runCodegenCore({
|
|
83
|
-
...codegenOptions({
|
|
84
|
-
|
|
80
|
+
...codegenOptions({
|
|
81
|
+
store,
|
|
82
|
+
libraries,
|
|
83
|
+
girPath,
|
|
84
|
+
elements: config.elements,
|
|
85
|
+
}),
|
|
86
|
+
isForced,
|
|
85
87
|
});
|
|
86
88
|
return {
|
|
87
|
-
|
|
89
|
+
isRegenerated: result.isRegenerated,
|
|
88
90
|
namespaces: result.namespaces,
|
|
89
91
|
intrinsicElements: result.intrinsicElements,
|
|
90
92
|
duration: result.duration,
|
|
@@ -113,8 +115,8 @@ const resolveInputsOrNull = (cwd, config) => {
|
|
|
113
115
|
return null;
|
|
114
116
|
}
|
|
115
117
|
};
|
|
116
|
-
const maybeAnnounceStale = (
|
|
117
|
-
if (!
|
|
118
|
+
const maybeAnnounceStale = (shouldAnnounce, inputs) => {
|
|
119
|
+
if (!shouldAnnounce) {
|
|
118
120
|
return;
|
|
119
121
|
}
|
|
120
122
|
if (inputs === null || isCodegenStale(inputs)) {
|
|
@@ -128,29 +130,23 @@ const getRunOptions = ({ root, mode, inputs, resolved }) => {
|
|
|
128
130
|
return { cwd: root, mode, inputs, resolved };
|
|
129
131
|
};
|
|
130
132
|
const ensureGenerated = async (cwd, options = {}) => {
|
|
131
|
-
if (options.
|
|
133
|
+
if (options.shouldAnnounce && process.env.GTKX_DISABLE_PREFLIGHT === "1") {
|
|
132
134
|
return false;
|
|
133
135
|
}
|
|
134
136
|
const context = await resolveCodegenContext(cwd, options.mode);
|
|
135
|
-
if (!context) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
137
|
syncSchemaEnv(cwd);
|
|
139
138
|
if (context.config.codegen === false) {
|
|
140
139
|
removeSharedStoreShadow(context.root);
|
|
141
140
|
return false;
|
|
142
141
|
}
|
|
143
142
|
const inputs = resolveInputsOrNull(context.root, context.config);
|
|
144
|
-
maybeAnnounceStale(options.
|
|
143
|
+
maybeAnnounceStale(options.shouldAnnounce, inputs);
|
|
145
144
|
const resolved = { config: context.config, configFile: context.configFile };
|
|
146
145
|
const result = await runCodegen(getRunOptions({ root: context.root, mode: options.mode, inputs, resolved }));
|
|
147
|
-
return result.
|
|
146
|
+
return result.isRegenerated;
|
|
148
147
|
};
|
|
149
148
|
const resolveConfigWatch = async (cwd, mode) => {
|
|
150
149
|
const { configFile, root } = await loadConfig(cwd, { mode });
|
|
151
|
-
if (configFile === undefined) {
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
150
|
return {
|
|
155
151
|
paths: [resolve(root, configFile)],
|
|
156
152
|
regenerate: async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-codegen.js","sourceRoot":"","sources":["../../src/codegen/run-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAe,UAAU,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAsB,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAqB,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAyC/E,MAAM,wBAAwB,GAC1B,+DAA+D;IAC/D,wGAAwG;IACxG,qCAAqC,CAAC;AAE1C,MAAM,uBAAuB,GAAG,CAAC,GAAW,EAAQ,EAAE;IAClD,KAAK,MAAM,IAAI,IAAI;QACf,OAAO,CAAC,GAAG,EAAE,uBAAuB,CAAC;QACrC,OAAO,CAAC,GAAG,EAAE,wBAAwB,CAAC;QACtC,OAAO,CAA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AG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO;QACH,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAClC,UAAU,EAAE,KAAK,IAAI,EAAE;YACnB,MAAM,UAAU,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EACH,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,kBAAkB,GAGrB,CAAC","sourcesContent":["import { runCodegen as runCodegenCore } from \"@gtkx/codegen\";\nimport { type Config, loadConfig } from \"@gtkx/config\";\nimport { resolveLazyElements } from \"@gtkx/config/internal\";\nimport { info } from \"@gtkx/utils\";\nimport { rmSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { resolveDataDir } from \"../internal/data-dir.js\";\nimport { emitSchemaEnv } from \"../settings/schema.js\";\nimport { type CodegenInputs, isCodegenStale, resolveCodegenInputs } from \"./freshness.js\";\nimport { type CodegenStore, resolveCodegenContext } from \"./store-resolver.js\";\n\ntype RunCodegenOptions = {\n cwd?: string;\n mode?: string | undefined;\n force?: boolean;\n inputs?: CodegenInputs;\n resolved?: LoadedConfig;\n};\n\ntype LoadedConfig = {\n config: Config;\n configFile: string | undefined;\n};\n\ntype RunCodegenResult = {\n regenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n duration: number;\n girPath?: string[] | undefined;\n configFile?: string | undefined;\n libraries?: string[] | undefined;\n};\n\ntype CodegenOptionsInput = {\n store: CodegenStore;\n libraries: string[];\n girPath: string[];\n elements: Config[\"elements\"];\n};\n\ntype PreparedCodegen = CodegenInputs & { force: boolean };\n\ntype RunOptionsInput = {\n root: string;\n mode: string | undefined;\n inputs: CodegenInputs | null;\n resolved: LoadedConfig;\n};\n\nconst GIR_PATH_MISSING_MESSAGE =\n \"No GIR search paths available. Install gobject-introspection \" +\n \"(Linux: `sudo dnf install gobject-introspection-devel` or `sudo apt install libgirepository1.0-dev`), \" +\n \"or set `girPath` in gtkx.config.ts.\";\n\nconst removeSharedStoreShadow = (cwd: string): void => {\n for (const path of [\n resolve(cwd, \"node_modules/.gtkx/gi\"),\n resolve(cwd, \"node_modules/.gtkx/jsx\"),\n resolve(cwd, \"node_modules/@gtkx/gi\"),\n resolve(cwd, \"node_modules/@gtkx/jsx\"),\n ]) {\n rmSync(path, { recursive: true, force: true });\n }\n};\n\nconst userModuleExports = (\n elements: Config[\"elements\"],\n key: \"component\" | \"props\",\n): Record<string, { module: string; export: string }> =>\n Object.fromEntries(\n Object.entries(elements?.config ?? {}).flatMap(([type, entry]) => {\n const ref = entry[key];\n\n return ref === undefined ? [] : [[type, ref] as const];\n }),\n );\n\nconst codegenOptions = ({ store, libraries, girPath, elements }: CodegenOptionsInput) => ({\n libraries,\n girPath,\n gi: {\n storeDir: store.giStoreDir,\n linkDir: store.giLinkDir,\n version: store.runtimeVersion,\n },\n jsx:\n store.react === null\n ? undefined\n : {\n storeDir: store.jsxStoreDir,\n linkDir: store.jsxLinkDir,\n version: store.react.version,\n },\n reactSubexports: store.react?.subexports ?? [],\n userComponents: userModuleExports(elements, \"component\"),\n userProps: userModuleExports(elements, \"props\"),\n userLazyElements: resolveLazyElements(elements),\n});\n\nconst disabledCodegenResult = (configFile: string | undefined): RunCodegenResult => ({\n regenerated: false,\n namespaces: 0,\n intrinsicElements: 0,\n duration: 0,\n girPath: [],\n configFile,\n libraries: [],\n});\n\nconst clearGeneratedStores = (store: CodegenStore): void => {\n for (const path of [store.giStoreDir, store.giLinkDir, store.jsxStoreDir, store.jsxLinkDir]) {\n rmSync(path, { recursive: true, force: true });\n }\n};\n\nconst resolveLoadedConfig = async (options: RunCodegenOptions, cwd: string): Promise<LoadedConfig> =>\n options.resolved ?? (await loadConfig(cwd, { mode: options.mode }));\n\nconst prepareCodegen = (options: RunCodegenOptions, cwd: string, config: Config): PreparedCodegen => {\n const { girPath, libraries, store } = options.inputs ?? resolveCodegenInputs(cwd, config);\n\n if (girPath.length === 0) {\n throw new Error(GIR_PATH_MISSING_MESSAGE);\n }\n\n const isForce = options.force === true || isCodegenStale({ girPath, libraries, store });\n\n return { girPath, libraries, store, force: isForce };\n};\n\nconst runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenResult> => {\n const cwd = options.cwd ?? process.cwd();\n const { config, configFile } = await resolveLoadedConfig(options, cwd);\n\n if (config.codegen === false) {\n removeSharedStoreShadow(cwd);\n\n return disabledCodegenResult(configFile);\n }\n\n const { girPath, libraries, store, force } = prepareCodegen(options, cwd, config);\n\n if (options.force) {\n clearGeneratedStores(store);\n }\n\n const result = await runCodegenCore({\n ...codegenOptions({ store, libraries, girPath, elements: config.elements }),\n force,\n });\n\n return {\n regenerated: result.regenerated,\n namespaces: result.namespaces,\n intrinsicElements: result.intrinsicElements,\n duration: result.duration,\n girPath,\n configFile,\n libraries,\n };\n};\n\nconst isCodegenDisabled = async (cwd: string, mode?: string): Promise<boolean> => {\n try {\n const { config } = await loadConfig(cwd, { mode });\n\n return config.codegen === false;\n } catch {\n return false;\n }\n};\n\nconst syncSchemaEnv = (cwd: string): void => {\n emitSchemaEnv(cwd, resolveDataDir(cwd));\n};\n\nconst resolveInputsOrNull = (cwd: string, config: Config): CodegenInputs | null => {\n try {\n return resolveCodegenInputs(cwd, config);\n } catch {\n return null;\n }\n};\n\nconst maybeAnnounceStale = (announce: boolean | undefined, inputs: CodegenInputs | null): void => {\n if (!announce) {\n return;\n }\n\n if (inputs === null || isCodegenStale(inputs)) {\n info(\"generated bindings missing; running codegen...\");\n }\n};\n\nconst getRunOptions = ({ root, mode, inputs, resolved }: RunOptionsInput): RunCodegenOptions => {\n if (inputs === null) {\n return { cwd: root, mode, resolved };\n }\n\n return { cwd: root, mode, inputs, resolved };\n};\n\nconst ensureGenerated = async (\n cwd: string,\n options: { announce?: boolean; mode?: string } = {},\n): Promise<boolean> => {\n if (options.announce && process.env.GTKX_DISABLE_PREFLIGHT === \"1\") {\n return false;\n }\n\n const context = await resolveCodegenContext(cwd, options.mode);\n\n if (!context) {\n return false;\n }\n\n syncSchemaEnv(cwd);\n\n if (context.config.codegen === false) {\n removeSharedStoreShadow(context.root);\n\n return false;\n }\n\n const inputs = resolveInputsOrNull(context.root, context.config);\n maybeAnnounceStale(options.announce, inputs);\n const resolved = { config: context.config, configFile: context.configFile };\n const result = await runCodegen(getRunOptions({ root: context.root, mode: options.mode, inputs, resolved }));\n\n return result.regenerated;\n};\n\nconst resolveConfigWatch = async (\n cwd: string,\n mode?: string,\n): Promise<{ paths: string[]; regenerate: () => Promise<void> } | undefined> => {\n const { configFile, root } = await loadConfig(cwd, { mode });\n\n if (configFile === undefined) {\n return undefined;\n }\n\n return {\n paths: [resolve(root, configFile)],\n regenerate: async () => {\n await runCodegen({ cwd: root, mode });\n },\n };\n};\n\nexport {\n runCodegen,\n isCodegenDisabled,\n syncSchemaEnv,\n ensureGenerated,\n resolveConfigWatch,\n type RunCodegenOptions,\n type RunCodegenResult,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"run-codegen.js","sourceRoot":"","sources":["../../src/codegen/run-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAe,UAAU,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACH,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAA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AAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAClC,UAAU,EAAE,KAAK,IAAI,EAAE;YACnB,MAAM,UAAU,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EACH,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,kBAAkB,GAGrB,CAAC","sourcesContent":["import { runCodegen as runCodegenCore } from \"@gtkx/codegen\";\nimport { type Config, loadConfig } from \"@gtkx/config\";\nimport {\n resolveElementComponents,\n resolveElementProps,\n resolveLazyElements,\n resolveOmittedProps,\n} from \"@gtkx/config/internal\";\nimport { info } from \"@gtkx/utils\";\nimport { rmSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { resolveDataDir } from \"../internal/data-dir.js\";\nimport { emitSchemaEnv } from \"../settings/schema.js\";\nimport { type CodegenInputs, isCodegenStale, resolveCodegenInputs } from \"./freshness.js\";\nimport { type CodegenStore, resolveCodegenContext } from \"./store-resolver.js\";\n\ntype RunCodegenOptions = {\n cwd?: string;\n mode?: string | undefined;\n isForced?: boolean;\n inputs?: CodegenInputs;\n resolved?: LoadedConfig;\n};\n\ntype LoadedConfig = {\n config: Config;\n configFile: string;\n};\n\ntype RunCodegenResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n duration: number;\n girPath?: string[] | undefined;\n configFile?: string | undefined;\n libraries?: string[] | undefined;\n};\n\ntype CodegenOptionsInput = {\n store: CodegenStore;\n libraries: string[];\n girPath: string[];\n elements: Config[\"elements\"];\n};\n\ntype PreparedCodegen = CodegenInputs & { isForced: boolean };\n\ntype RunOptionsInput = {\n root: string;\n mode: string | undefined;\n inputs: CodegenInputs | null;\n resolved: LoadedConfig;\n};\n\nconst GIR_PATH_MISSING_MESSAGE =\n \"No GIR search paths available. Install gobject-introspection \" +\n \"(Linux: `sudo dnf install gobject-introspection-devel` or `sudo apt install libgirepository1.0-dev`), \" +\n \"or set `girPath` in gtkx.config.ts.\";\n\nconst removeSharedStoreShadow = (cwd: string): void => {\n for (const path of [\n resolve(cwd, \"node_modules/.gtkx/gi\"),\n resolve(cwd, \"node_modules/.gtkx/jsx\"),\n resolve(cwd, \"node_modules/@gtkx/gi\"),\n resolve(cwd, \"node_modules/@gtkx/jsx\"),\n ]) {\n rmSync(path, { recursive: true, force: true });\n }\n};\n\nconst codegenOptions = ({ store, libraries, girPath, elements }: CodegenOptionsInput) => ({\n libraries,\n girPath,\n gi: {\n storeDir: store.giStoreDir,\n linkDir: store.giLinkDir,\n version: store.runtimeVersion,\n },\n jsx:\n store.react === null\n ? undefined\n : {\n storeDir: store.jsxStoreDir,\n linkDir: store.jsxLinkDir,\n version: store.react.version,\n },\n reactSubexports: store.react?.subexports ?? [],\n userComponents: resolveElementComponents(elements),\n userProps: resolveElementProps(elements),\n userLazyElements: resolveLazyElements(elements),\n userOmittedProps: resolveOmittedProps(elements),\n});\n\nconst disabledCodegenResult = (configFile: string): RunCodegenResult => ({\n isRegenerated: false,\n namespaces: 0,\n intrinsicElements: 0,\n duration: 0,\n girPath: [],\n configFile,\n libraries: [],\n});\n\nconst clearGeneratedStores = (store: CodegenStore): void => {\n for (const path of [store.giStoreDir, store.giLinkDir, store.jsxStoreDir, store.jsxLinkDir]) {\n rmSync(path, { recursive: true, force: true });\n }\n};\n\nconst resolveLoadedConfig = async (options: RunCodegenOptions, cwd: string): Promise<LoadedConfig> =>\n options.resolved ?? (await loadConfig(cwd, { mode: options.mode }));\n\nconst prepareCodegen = (options: RunCodegenOptions, cwd: string, config: Config): PreparedCodegen => {\n const { girPath, libraries, store } = options.inputs ?? resolveCodegenInputs(cwd, config);\n\n if (girPath.length === 0) {\n throw new Error(GIR_PATH_MISSING_MESSAGE);\n }\n\n const isForced = options.isForced === true || isCodegenStale({ girPath, libraries, store });\n\n return { girPath, libraries, store, isForced };\n};\n\nconst runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenResult> => {\n const cwd = options.cwd ?? process.cwd();\n const { config, configFile } = await resolveLoadedConfig(options, cwd);\n\n if (config.codegen === false) {\n removeSharedStoreShadow(cwd);\n\n return disabledCodegenResult(configFile);\n }\n\n const { girPath, libraries, store, isForced } = prepareCodegen(options, cwd, config);\n\n if (options.isForced) {\n clearGeneratedStores(store);\n }\n\n const result = await runCodegenCore({\n ...codegenOptions({\n store,\n libraries,\n girPath,\n elements: config.elements,\n }),\n isForced,\n });\n\n return {\n isRegenerated: result.isRegenerated,\n namespaces: result.namespaces,\n intrinsicElements: result.intrinsicElements,\n duration: result.duration,\n girPath,\n configFile,\n libraries,\n };\n};\n\nconst isCodegenDisabled = async (cwd: string, mode?: string): Promise<boolean> => {\n try {\n const { config } = await loadConfig(cwd, { mode });\n\n return config.codegen === false;\n } catch {\n return false;\n }\n};\n\nconst syncSchemaEnv = (cwd: string): void => {\n emitSchemaEnv(cwd, resolveDataDir(cwd));\n};\n\nconst resolveInputsOrNull = (cwd: string, config: Config): CodegenInputs | null => {\n try {\n return resolveCodegenInputs(cwd, config);\n } catch {\n return null;\n }\n};\n\nconst maybeAnnounceStale = (shouldAnnounce: boolean | undefined, inputs: CodegenInputs | null): void => {\n if (!shouldAnnounce) {\n return;\n }\n\n if (inputs === null || isCodegenStale(inputs)) {\n info(\"generated bindings missing; running codegen...\");\n }\n};\n\nconst getRunOptions = ({ root, mode, inputs, resolved }: RunOptionsInput): RunCodegenOptions => {\n if (inputs === null) {\n return { cwd: root, mode, resolved };\n }\n\n return { cwd: root, mode, inputs, resolved };\n};\n\nconst ensureGenerated = async (\n cwd: string,\n options: { shouldAnnounce?: boolean; mode?: string } = {},\n): Promise<boolean> => {\n if (options.shouldAnnounce && process.env.GTKX_DISABLE_PREFLIGHT === \"1\") {\n return false;\n }\n\n const context = await resolveCodegenContext(cwd, options.mode);\n syncSchemaEnv(cwd);\n\n if (context.config.codegen === false) {\n removeSharedStoreShadow(context.root);\n\n return false;\n }\n\n const inputs = resolveInputsOrNull(context.root, context.config);\n maybeAnnounceStale(options.shouldAnnounce, inputs);\n const resolved = { config: context.config, configFile: context.configFile };\n const result = await runCodegen(getRunOptions({ root: context.root, mode: options.mode, inputs, resolved }));\n\n return result.isRegenerated;\n};\n\nconst resolveConfigWatch = async (\n cwd: string,\n mode?: string,\n): Promise<{ paths: string[]; regenerate: () => Promise<void> }> => {\n const { configFile, root } = await loadConfig(cwd, { mode });\n\n return {\n paths: [resolve(root, configFile)],\n regenerate: async () => {\n await runCodegen({ cwd: root, mode });\n },\n };\n};\n\nexport {\n runCodegen,\n isCodegenDisabled,\n syncSchemaEnv,\n ensureGenerated,\n resolveConfigWatch,\n type RunCodegenOptions,\n type RunCodegenResult,\n};\n"]}
|
|
@@ -14,11 +14,9 @@ type CodegenReactPackage = {
|
|
|
14
14
|
type CodegenContext = {
|
|
15
15
|
root: string;
|
|
16
16
|
config: Config;
|
|
17
|
-
configFile: string
|
|
17
|
+
configFile: string;
|
|
18
18
|
};
|
|
19
|
-
/** Resolves the `@gtkx/react` subexport names for a project without requiring runtime/native to be installed. */
|
|
20
|
-
declare const resolveReactSubexports: (dir: string) => string[];
|
|
21
19
|
declare const resolveCodegenStore: (dir: string) => CodegenStore;
|
|
22
|
-
declare const resolveCodegenContext: (cwd: string, mode?: string) => Promise<CodegenContext
|
|
23
|
-
export {
|
|
20
|
+
declare const resolveCodegenContext: (cwd: string, mode?: string) => Promise<CodegenContext>;
|
|
21
|
+
export { resolveCodegenStore, resolveCodegenContext, type CodegenStore, type CodegenContext };
|
|
24
22
|
//# sourceMappingURL=store-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-resolver.d.ts","sourceRoot":"","sources":["../../src/codegen/store-resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store-resolver.d.ts","sourceRoot":"","sources":["../../src/codegen/store-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,cAAc,CAAC;AAMvD,KAAK,YAAY,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAIF,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AA6BF,QAAA,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,YAqB1C,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAU,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,cAAc,CAIvF,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveStore } from "@gtkx/codegen";
|
|
1
2
|
import { loadConfig } from "@gtkx/config";
|
|
2
3
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
3
4
|
import { createRequire } from "node:module";
|
|
@@ -7,18 +8,6 @@ const readVersion = (packageJsonPath) => {
|
|
|
7
8
|
const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
8
9
|
return parsed.version ?? "0.0.0";
|
|
9
10
|
};
|
|
10
|
-
const readSubexports = (packageDir) => {
|
|
11
|
-
const parsed = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
|
|
12
|
-
return Object.keys(parsed.exports ?? {})
|
|
13
|
-
.filter((key) => key.startsWith("./") && key !== "./package.json")
|
|
14
|
-
.map((key) => key.slice(2));
|
|
15
|
-
};
|
|
16
|
-
/** Resolves the `@gtkx/react` subexport names for a project without requiring runtime/native to be installed. */
|
|
17
|
-
const resolveReactSubexports = (dir) => {
|
|
18
|
-
const require = createRequire(pathToFileURL(join(dir, "__gtkx_resolver__.js")).href);
|
|
19
|
-
const react = resolvePackage(require, dir, "@gtkx/react");
|
|
20
|
-
return react === null ? [] : readSubexports(react.dir);
|
|
21
|
-
};
|
|
22
11
|
const resolvePackage = (require, dir, packageName) => {
|
|
23
12
|
try {
|
|
24
13
|
const real = realpathSync(require.resolve(`${packageName}/package.json`));
|
|
@@ -34,39 +23,28 @@ const resolvePackage = (require, dir, packageName) => {
|
|
|
34
23
|
return { dir: dirname(real), version: readVersion(real) };
|
|
35
24
|
}
|
|
36
25
|
};
|
|
26
|
+
const siblingStore = (giDir) => join(dirname(giDir), "jsx");
|
|
37
27
|
const resolveCodegenStore = (dir) => {
|
|
38
28
|
const require = createRequire(pathToFileURL(join(dir, "__gtkx_resolver__.js")).href);
|
|
39
|
-
|
|
40
|
-
if (runtime === null) {
|
|
41
|
-
throw new Error("Cannot resolve @gtkx/runtime from the project; is it installed?");
|
|
42
|
-
}
|
|
43
|
-
const native = resolvePackage(require, dir, "@gtkx/native");
|
|
44
|
-
if (native === null) {
|
|
29
|
+
if (resolvePackage(require, dir, "@gtkx/native") === null) {
|
|
45
30
|
throw new Error("Cannot resolve @gtkx/native from the project; is it installed?");
|
|
46
31
|
}
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const nodeModules = join(dir, "node_modules");
|
|
32
|
+
const store = resolveStore(dir);
|
|
33
|
+
const hasReactRuntime = resolvePackage(require, dir, "react") !== null;
|
|
50
34
|
return {
|
|
51
|
-
giStoreDir:
|
|
52
|
-
giLinkDir:
|
|
53
|
-
jsxStoreDir:
|
|
54
|
-
jsxLinkDir:
|
|
55
|
-
runtimeVersion:
|
|
56
|
-
react:
|
|
57
|
-
? {
|
|
58
|
-
version: react.version,
|
|
59
|
-
subexports: readSubexports(react.dir),
|
|
60
|
-
}
|
|
35
|
+
giStoreDir: store.gi.storeDir,
|
|
36
|
+
giLinkDir: store.gi.linkDir,
|
|
37
|
+
jsxStoreDir: store.jsx?.storeDir ?? siblingStore(store.gi.storeDir),
|
|
38
|
+
jsxLinkDir: store.jsx?.linkDir ?? siblingStore(store.gi.linkDir),
|
|
39
|
+
runtimeVersion: store.gi.version,
|
|
40
|
+
react: hasReactRuntime && store.jsx !== null
|
|
41
|
+
? { version: store.jsx.version, subexports: store.reactSubexports }
|
|
61
42
|
: null,
|
|
62
43
|
};
|
|
63
44
|
};
|
|
64
45
|
const resolveCodegenContext = async (cwd, mode) => {
|
|
65
46
|
const { config, configFile } = await loadConfig(cwd, { mode });
|
|
66
|
-
if (configFile === undefined) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
47
|
return { root: cwd, config, configFile };
|
|
70
48
|
};
|
|
71
|
-
export {
|
|
49
|
+
export { resolveCodegenStore, resolveCodegenContext };
|
|
72
50
|
//# sourceMappingURL=store-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-resolver.js","sourceRoot":"","sources":["../../src/codegen/store-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAwBzC,MAAM,WAAW,GAAG,CAAC,eAAuB,EAAU,EAAE;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAyB,CAAC;IAEzF,OAAO,MAAM,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K,CAAC,GAAG,KAAK,IAAI;YACjC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,eAAe,EAAE;YACnE,CAAC,CAAC,IAAI;KACjB,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,KAAK,EAAE,GAAW,EAAE,IAAa,EAA2B,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAE/D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAC7C,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAA0C,CAAC","sourcesContent":["import { resolveStore } from \"@gtkx/codegen\";\nimport { type Config, loadConfig } from \"@gtkx/config\";\nimport { existsSync, readFileSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\ntype CodegenStore = {\n giStoreDir: string;\n giLinkDir: string;\n jsxStoreDir: string;\n jsxLinkDir: string;\n runtimeVersion: string;\n react: CodegenReactPackage | null;\n};\n\ntype CodegenReactPackage = {\n version: string;\n subexports: string[];\n};\n\ntype ResolvedPackage = { dir: string; version: string };\n\ntype CodegenContext = {\n root: string;\n config: Config;\n configFile: string;\n};\n\nconst readVersion = (packageJsonPath: string): string => {\n const parsed = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { version?: string };\n\n return parsed.version ?? \"0.0.0\";\n};\n\nconst resolvePackage = (require: NodeJS.Require, dir: string, packageName: string): ResolvedPackage | null => {\n try {\n const real = realpathSync(require.resolve(`${packageName}/package.json`));\n\n return { dir: dirname(real), version: readVersion(real) };\n } catch {\n const unscoped = packageName.replace(/^@[^/]+\\//, \"\");\n const workspacePkg = join(dir, \"packages\", unscoped, \"package.json\");\n\n if (!existsSync(workspacePkg)) {\n return null;\n }\n\n const real = realpathSync(workspacePkg);\n\n return { dir: dirname(real), version: readVersion(real) };\n }\n};\n\nconst siblingStore = (giDir: string): string => join(dirname(giDir), \"jsx\");\n\nconst resolveCodegenStore = (dir: string): CodegenStore => {\n const require = createRequire(pathToFileURL(join(dir, \"__gtkx_resolver__.js\")).href);\n\n if (resolvePackage(require, dir, \"@gtkx/native\") === null) {\n throw new Error(\"Cannot resolve @gtkx/native from the project; is it installed?\");\n }\n\n const store = resolveStore(dir);\n const hasReactRuntime = resolvePackage(require, dir, \"react\") !== null;\n\n return {\n giStoreDir: store.gi.storeDir,\n giLinkDir: store.gi.linkDir,\n jsxStoreDir: store.jsx?.storeDir ?? siblingStore(store.gi.storeDir),\n jsxLinkDir: store.jsx?.linkDir ?? siblingStore(store.gi.linkDir),\n runtimeVersion: store.gi.version,\n react:\n hasReactRuntime && store.jsx !== null\n ? { version: store.jsx.version, subexports: store.reactSubexports }\n : null,\n };\n};\n\nconst resolveCodegenContext = async (cwd: string, mode?: string): Promise<CodegenContext> => {\n const { config, configFile } = await loadConfig(cwd, { mode });\n\n return { root: cwd, config, configFile };\n};\n\nexport { resolveCodegenStore, resolveCodegenContext, type CodegenStore, type CodegenContext };\n"]}
|
package/dist/commands/build.js
CHANGED
|
@@ -19,7 +19,7 @@ const build = defineCommand({
|
|
|
19
19
|
async run({ args }) {
|
|
20
20
|
const { cwd, entry } = resolveEntry(args);
|
|
21
21
|
info(`Building ${entry}`);
|
|
22
|
-
await ensureGenerated(cwd, {
|
|
22
|
+
await ensureGenerated(cwd, { shouldAnnounce: true, mode: BUILD_MODE });
|
|
23
23
|
await buildApp({
|
|
24
24
|
entry,
|
|
25
25
|
assetBase: args["asset-base"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAA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AAQ;QACX,YAAY,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,0EAA0E;SAC1F;KACJ;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC,CAAC;QAC1B,MAAM,eAAe,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QAEvE,MAAM,QAAQ,CAAC;YACX,KAAK;YACL,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;YAC7B,IAAI,EAAE;gBACF,IAAI,EAAE,GAAG;aACZ;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAC3C,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { info } from \"@gtkx/utils\";\nimport { defineCommand } from \"citty\";\nimport { build as buildApp } from \"../builder.js\";\nimport { ensureGenerated } from \"../codegen/run-codegen.js\";\nimport { entryArg, resolveEntry } from \"../internal/entry-arg.js\";\n\nconst BUILD_MODE = \"production\";\n\nconst build = defineCommand({\n meta: {\n name: \"build\",\n description: \"Build application for production\",\n },\n args: {\n ...entryArg,\n \"asset-base\": {\n type: \"string\",\n description: \"Asset base path relative to executable directory (e.g., ../share/my-app)\",\n },\n },\n async run({ args }) {\n const { cwd, entry } = resolveEntry(args);\n info(`Building ${entry}`);\n await ensureGenerated(cwd, { shouldAnnounce: true, mode: BUILD_MODE });\n\n await buildApp({\n entry,\n assetBase: args[\"asset-base\"],\n vite: {\n root: cwd,\n },\n });\n\n info(\"Build complete: dist/bundle.js\");\n },\n});\n\nexport { build };\n"]}
|
package/dist/commands/codegen.js
CHANGED
|
@@ -30,7 +30,7 @@ const codegen = defineCommand({
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
const startedAt = Date.now();
|
|
33
|
-
const result = await runCodegen({ cwd,
|
|
33
|
+
const result = await runCodegen({ cwd, isForced: true });
|
|
34
34
|
syncSchemaEnv(cwd);
|
|
35
35
|
const lines = formatCodegenResult(result, Date.now() - startedAt);
|
|
36
36
|
for (const line of lines) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1G,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,OAAO,GAAG,aAAa,CAAC;IAC1B,IAAI,EAAE;QACF,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,+EAA+E;KAC/F;IACD,IAAI,EAAE;QACF,KAAK,EAAE;YACH,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,qFAAqF;YAClG,OAAO,EAAE,KAAK;SACjB;QACD,GAAG,MAAM;KACZ;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAE7B,IAAI,MAAM,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;YAC1B,aAAa,CAAC,GAAG,CAAC,CAAC;YACnB,IAAI,CAAC,wEAAwE,CAAC,CAAC;YAE/E,OAAO;QACX,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,KA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AAI,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC;YACzC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC;YAErF,OAAO;QACX,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,aAAa,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC;QAElE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { info } from \"@gtkx/utils\";\nimport { defineCommand } from \"citty\";\nimport { formatCodegenResult } from \"../codegen/report.js\";\nimport { ensureGenerated, isCodegenDisabled, runCodegen, syncSchemaEnv } from \"../codegen/run-codegen.js\";\nimport { cwdArg, resolveCwd } from \"../internal/entry-arg.js\";\n\nconst codegen = defineCommand({\n meta: {\n name: \"codegen\",\n description: \"Generate TypeScript bindings for the GIR libraries declared in gtkx.config.ts\",\n },\n args: {\n force: {\n type: \"boolean\",\n description: \"Wipe the generated store and regenerate unconditionally (recover a corrupted store)\",\n default: false,\n },\n ...cwdArg,\n },\n async run({ args }) {\n const cwd = resolveCwd(args);\n\n if (await isCodegenDisabled(cwd)) {\n await runCodegen({ cwd });\n syncSchemaEnv(cwd);\n info(\"codegen: disabled for this project; reusing an installed binding store\");\n\n return;\n }\n\n if (!args.force) {\n const isRan = await ensureGenerated(cwd);\n info(isRan ? \"codegen: regenerated stale bindings\" : \"codegen: bindings up to date\");\n\n return;\n }\n\n const startedAt = Date.now();\n const result = await runCodegen({ cwd, isForced: true });\n syncSchemaEnv(cwd);\n const lines = formatCodegenResult(result, Date.now() - startedAt);\n\n for (const line of lines) {\n info(line);\n }\n },\n});\n\nexport { codegen };\n"]}
|
package/dist/commands/dev.js
CHANGED
|
@@ -13,7 +13,7 @@ const dev = defineCommand({
|
|
|
13
13
|
},
|
|
14
14
|
async run({ args }) {
|
|
15
15
|
const { cwd, entry: entryPath } = resolveEntry(args);
|
|
16
|
-
await ensureGenerated(cwd, {
|
|
16
|
+
await ensureGenerated(cwd, { shouldAnnounce: true, mode: DEV_MODE });
|
|
17
17
|
const watch = await resolveConfigWatch(cwd, DEV_MODE);
|
|
18
18
|
await runDevSupervisor(entryPath, cwd, watch);
|
|
19
19
|
},
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAiB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,QAAQ,GAAG,aAAa,CAAC;AAE/B,MAAM,GAAG,GAAG,aAAa,CAAC;IACtB,IAAI,EAAE;QACF,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,mCAAmC;KACnD;IACD,IAAI,EAAE;QACF,GAAG,QAAQ;KACd;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,eAAe,CAAC,GAAG,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAiB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,QAAQ,GAAG,aAAa,CAAC;AAE/B,MAAM,GAAG,GAAG,aAAa,CAAC;IACtB,IAAI,EAAE;QACF,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,mCAAmC;KACnD;IACD,IAAI,EAAE;QACF,GAAG,QAAQ;KACd;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,eAAe,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrE,MAAM,KAAK,GAAyB,MAAM,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC5E,MAAM,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,GAAG,EAAE,CAAC","sourcesContent":["import { defineCommand } from \"citty\";\nimport { ensureGenerated, resolveConfigWatch } from \"../codegen/run-codegen.js\";\nimport { type DevWatch, runDevSupervisor } from \"../dev/supervisor.js\";\nimport { entryArg, resolveEntry } from \"../internal/entry-arg.js\";\n\nconst DEV_MODE = \"development\";\n\nconst dev = defineCommand({\n meta: {\n name: \"dev\",\n description: \"Start development server with HMR\",\n },\n args: {\n ...entryArg,\n },\n async run({ args }) {\n const { cwd, entry: entryPath } = resolveEntry(args);\n await ensureGenerated(cwd, { shouldAnnounce: true, mode: DEV_MODE });\n const watch: DevWatch | undefined = await resolveConfigWatch(cwd, DEV_MODE);\n await runDevSupervisor(entryPath, cwd, watch);\n },\n});\n\nexport { dev };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;EAyER,CAAC;AAcH,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/commands/docs.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { readBuiltinElements, resolveGirPath, resolveLibraries,
|
|
1
|
+
import { mergeOmittedProps, readBuiltinElements, resolveGirPath, resolveLibraries, resolveStore, } from "@gtkx/codegen";
|
|
2
|
+
import { writeDocs } from "@gtkx/codegen/internal";
|
|
2
3
|
import { loadConfig } from "@gtkx/config";
|
|
4
|
+
import { resolveOmittedProps } from "@gtkx/config/internal";
|
|
3
5
|
import { info } from "@gtkx/utils";
|
|
4
6
|
import { defineCommand } from "citty";
|
|
5
7
|
import { existsSync } from "node:fs";
|
|
6
|
-
import {
|
|
7
|
-
import { resolveReactSubexports } from "../codegen/store-resolver.js";
|
|
8
|
+
import { resolve } from "node:path";
|
|
8
9
|
import { cwdArg, resolveCwd } from "../internal/entry-arg.js";
|
|
9
10
|
const docs = defineCommand({
|
|
10
11
|
meta: {
|
|
@@ -45,15 +46,17 @@ const docs = defineCommand({
|
|
|
45
46
|
const libraries = resolveLibraries(config.libraries, girPath);
|
|
46
47
|
const startedAt = Date.now();
|
|
47
48
|
const outDir = resolve(cwd, args.out);
|
|
48
|
-
const
|
|
49
|
+
const builtin = await resolveDocsElements(cwd);
|
|
50
|
+
const { isRegenerated, namespaces } = writeDocs({
|
|
49
51
|
libraries,
|
|
50
52
|
girPath,
|
|
51
53
|
outDir,
|
|
52
54
|
basePath: args["base-path"],
|
|
53
|
-
props:
|
|
54
|
-
|
|
55
|
+
props: builtin.props,
|
|
56
|
+
omittedProps: mergeOmittedProps(builtin.omittedProps, resolveOmittedProps(config.elements)),
|
|
57
|
+
isForced: args.force,
|
|
55
58
|
});
|
|
56
|
-
if (!
|
|
59
|
+
if (!isRegenerated) {
|
|
57
60
|
info(`docs: pages in ${outDir} are up to date`);
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
@@ -62,13 +65,13 @@ const docs = defineCommand({
|
|
|
62
65
|
`to ${outDir} in ${String(Date.now() - startedAt)}ms`);
|
|
63
66
|
},
|
|
64
67
|
});
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
if (!existsSync(
|
|
68
|
-
return {};
|
|
68
|
+
const resolveDocsElements = async (cwd) => {
|
|
69
|
+
const { gi, reactSubexports } = resolveStore(cwd);
|
|
70
|
+
if (!existsSync(gi.storeDir)) {
|
|
71
|
+
return { props: {}, omittedProps: {} };
|
|
69
72
|
}
|
|
70
|
-
const { props } = await readBuiltinElements(
|
|
71
|
-
return props;
|
|
73
|
+
const { props, omittedProps } = await readBuiltinElements(reactSubexports, gi.storeDir);
|
|
74
|
+
return { props, omittedProps };
|
|
72
75
|
};
|
|
73
76
|
export { docs };
|
|
74
77
|
//# sourceMappingURL=docs.js.map
|