@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.
Files changed (68) hide show
  1. package/README.md +4 -5
  2. package/dist/codegen/freshness.d.ts.map +1 -1
  3. package/dist/codegen/freshness.js +5 -6
  4. package/dist/codegen/freshness.js.map +1 -1
  5. package/dist/codegen/run-codegen.d.ts +5 -5
  6. package/dist/codegen/run-codegen.d.ts.map +1 -1
  7. package/dist/codegen/run-codegen.js +22 -26
  8. package/dist/codegen/run-codegen.js.map +1 -1
  9. package/dist/codegen/store-resolver.d.ts +3 -5
  10. package/dist/codegen/store-resolver.d.ts.map +1 -1
  11. package/dist/codegen/store-resolver.js +13 -35
  12. package/dist/codegen/store-resolver.js.map +1 -1
  13. package/dist/commands/build.js +1 -1
  14. package/dist/commands/build.js.map +1 -1
  15. package/dist/commands/codegen.js +1 -1
  16. package/dist/commands/codegen.js.map +1 -1
  17. package/dist/commands/dev.js +1 -1
  18. package/dist/commands/dev.js.map +1 -1
  19. package/dist/commands/docs.d.ts.map +1 -1
  20. package/dist/commands/docs.js +16 -13
  21. package/dist/commands/docs.js.map +1 -1
  22. package/dist/dev/supervisor.js +14 -14
  23. package/dist/dev/supervisor.js.map +1 -1
  24. package/dist/mcp/handlers.js +1 -1
  25. package/dist/mcp/handlers.js.map +1 -1
  26. package/dist/mcp/serialize-widget.js +2 -2
  27. package/dist/mcp/serialize-widget.js.map +1 -1
  28. package/dist/refresh-runtime.d.ts +0 -10
  29. package/dist/refresh-runtime.d.ts.map +1 -1
  30. package/dist/refresh-runtime.js +0 -17
  31. package/dist/refresh-runtime.js.map +1 -1
  32. package/dist/settings/schema.d.ts +1 -1
  33. package/dist/settings/schema.d.ts.map +1 -1
  34. package/dist/settings/schema.js +1 -1
  35. package/dist/settings/schema.js.map +1 -1
  36. package/dist/vite-plugins/index.js +1 -1
  37. package/dist/vite-plugins/index.js.map +1 -1
  38. package/dist/vite-plugins/react-compiler.js +1 -1
  39. package/dist/vite-plugins/react-compiler.js.map +1 -1
  40. package/dist/vite-plugins/resources.js +1 -1
  41. package/dist/vite-plugins/resources.js.map +1 -1
  42. package/dist/vite-plugins/undeclared-library.d.ts +2 -1
  43. package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
  44. package/dist/vite-plugins/undeclared-library.js +4 -4
  45. package/dist/vite-plugins/undeclared-library.js.map +1 -1
  46. package/dist/vitest-plugin.d.ts +0 -6
  47. package/dist/vitest-plugin.d.ts.map +1 -1
  48. package/dist/vitest-plugin.js +0 -6
  49. package/dist/vitest-plugin.js.map +1 -1
  50. package/env.d.ts +25 -0
  51. package/package.json +11 -11
  52. package/src/codegen/freshness.ts +5 -8
  53. package/src/codegen/run-codegen.ts +34 -44
  54. package/src/codegen/store-resolver.ts +16 -46
  55. package/src/commands/build.ts +1 -1
  56. package/src/commands/codegen.ts +1 -1
  57. package/src/commands/dev.ts +1 -1
  58. package/src/commands/docs.ts +24 -13
  59. package/src/dev/supervisor.ts +16 -16
  60. package/src/mcp/handlers.ts +1 -1
  61. package/src/mcp/serialize-widget.ts +2 -2
  62. package/src/refresh-runtime.ts +0 -17
  63. package/src/settings/schema.ts +2 -2
  64. package/src/vite-plugins/index.ts +1 -1
  65. package/src/vite-plugins/react-compiler.ts +2 -2
  66. package/src/vite-plugins/resources.ts +1 -1
  67. package/src/vite-plugins/undeclared-library.ts +6 -5
  68. package/src/vitest-plugin.ts +0 -6
@@ -1 +1 @@
1
- {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/vite-plugins/resources.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,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ACH,OAAO,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,QAAQ;YACJ,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Plugin, ResolvedConfig, UserConfig, ViteDevServer } from \"vite\";\nimport { type ConfigLoader, createConfigLoader } from \"@gtkx/config/internal\";\nimport { error, formatChildProcessError, info, sortStrings } from \"@gtkx/utils\";\nimport { execFileSync } from \"node:child_process\";\nimport { copyFileSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { DATA_IMPORT_PREFIX, resolveDataDir } from \"../internal/data-dir.js\";\nimport { type ListedFile, listFilesRecursive } from \"../internal/list-files.js\";\nimport { resolveCliTool } from \"../internal/resolve-cli-tool.js\";\nimport { withStagingDir } from \"../internal/staging-dir.js\";\nimport { ASSET_PATH_RE, ASSET_RE } from \"./asset-extensions.js\";\nimport { renderInitModule } from \"./resource-init-module.js\";\nimport {\n BUNDLE_FILENAME,\n escapeXml,\n fromVirtualId,\n isVirtual,\n REFRESH_EXPORT,\n REL_SEPARATOR,\n toVirtualId,\n VIRTUAL_INIT,\n} from \"./resource-shared.js\";\nimport { stripQuery } from \"./strip-query.js\";\n\ntype ResourceEntry = {\n sourcePath: string;\n stagedRelPath: string;\n resourcePath: string;\n};\n\ntype PluginState = {\n prefix: string;\n isBuild: boolean;\n entries: Map<string, ResourceEntry>;\n sourcePaths: Set<string>;\n devStagingDir: string | null;\n devBundlePath: string;\n server: ViteDevServer | null;\n compiledSignature: string;\n dataDir: string | null;\n};\n\nconst DATA_PREFIX = `${DATA_IMPORT_PREFIX}/`;\nconst RESOURCE_COMPILER = \"glib-compile-resources\";\nconst MANIFEST_PREFIX = \"/\";\n\nconst deriveResourcePrefix = (applicationId: string): string => `/${applicationId.replaceAll(\".\", \"/\")}`;\n\nconst compileBundle = (state: PluginState, outputPath: string): Buffer =>\n withStagingDir(\"resources\", (dir) => {\n const manifest = stageBundle(dir, state.entries);\n\n return runCompiler(dir, manifest, outputPath);\n });\n\nconst stageBundle = (dir: string, entries: Map<string, ResourceEntry>): string => {\n const fileNodes: string[] = [];\n\n for (const entry of entries.values()) {\n const targetPath = join(dir, entry.stagedRelPath);\n mkdirSync(dirname(targetPath), { recursive: true });\n copyFileSync(entry.sourcePath, targetPath);\n fileNodes.push(` <file>${escapeXml(entry.stagedRelPath)}</file>`);\n }\n\n const prefix = escapeXml(MANIFEST_PREFIX);\n const manifest = join(dir, \"gtkx.gresource.xml\");\n\n const xml = [\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\",\n \"<gresources>\",\n ` <gresource prefix=\"${prefix}\">`,\n ...fileNodes,\n \" </gresource>\",\n \"</gresources>\",\n \"\",\n ].join(\"\\n\");\n\n writeFileSync(manifest, xml);\n\n return manifest;\n};\n\nconst runCompiler = (sourceDir: string, manifest: string, outputPath: string): Buffer => {\n try {\n execFileSync(resolveCliTool(RESOURCE_COMPILER), [\n `--sourcedir=${sourceDir}`,\n `--target=${outputPath}`,\n manifest,\n ]);\n } catch (error) {\n const details = formatChildProcessError(error);\n const suffix = details ? `:\\n${details}` : \"\";\n throw new Error(`${RESOURCE_COMPILER} failed${suffix}`, { cause: error });\n }\n\n return readFileSync(outputPath);\n};\n\nconst ensureStagingDir = (state: PluginState): void => {\n if (state.devStagingDir) {\n return;\n }\n\n state.devStagingDir = mkdtempSync(join(tmpdir(), \"gtkx-resources-dev-\"));\n state.devBundlePath = join(state.devStagingDir, BUNDLE_FILENAME);\n};\n\nconst entriesSignature = (state: PluginState): string => sortStrings(state.entries.keys()).join(\"\\0\");\n\nconst compileDevBundle = (state: PluginState): void => {\n ensureStagingDir(state);\n\n if (state.entries.size === 0) {\n return;\n }\n\n compileBundle(state, state.devBundlePath);\n state.compiledSignature = entriesSignature(state);\n};\n\nconst isRefreshHook = (value: unknown): value is () => void => typeof value === \"function\";\n\nconst reregisterDevBundle = async (state: PluginState): Promise<void> => {\n const server = state.server;\n\n if (!server) {\n return;\n }\n\n const mod = await server.ssrLoadModule(VIRTUAL_INIT);\n const refresh: unknown = mod[REFRESH_EXPORT];\n\n if (isRefreshHook(refresh)) {\n refresh();\n }\n};\n\nconst scanDataAssets = (dataDir: string): ListedFile[] => listFilesRecursive(dataDir, (name) => ASSET_RE.test(name));\n\nconst primeDevBundle = (state: PluginState): void => {\n if (state.dataDir === null) {\n return;\n }\n\n for (const { absPath, rel } of scanDataAssets(state.dataDir)) {\n registerEntry(state, absPath, rel);\n }\n\n compileDevBundle(state);\n};\n\nconst registerDevAsset = (state: PluginState): void => {\n if (entriesSignature(state) !== state.compiledSignature) {\n compileDevBundle(state);\n }\n};\n\nconst registerEntry = (state: PluginState, absPath: string, rel: string): ResourceEntry => {\n const existing = state.entries.get(absPath);\n\n if (existing) {\n return existing;\n }\n\n const resourcePath = `${state.prefix}/${rel}`;\n\n const entry: ResourceEntry = {\n sourcePath: absPath,\n stagedRelPath: resourcePath.replace(/^\\/+/, \"\"),\n resourcePath,\n };\n\n state.entries.set(absPath, entry);\n state.sourcePaths.add(absPath);\n\n return entry;\n};\n\nconst isTrackedSource = (state: PluginState, file: string): boolean => state.sourcePaths.has(file);\n\nconst dataAssetSource = (source: string): string | null => {\n const clean = stripQuery(source);\n\n if (!clean.startsWith(DATA_PREFIX) || !ASSET_PATH_RE.test(clean)) {\n return null;\n }\n\n return clean;\n};\n\nconst resolvedAssetId = (\n resolved: { id: string; external: boolean | string } | null,\n clean: string,\n): string | undefined => {\n if (!resolved || resolved.external) {\n return undefined;\n }\n\n return toVirtualId(resolved.id) + REL_SEPARATOR + clean.slice(DATA_PREFIX.length);\n};\n\nconst loadInitModule = (state: PluginState): string => {\n if (!state.isBuild) {\n ensureStagingDir(state);\n }\n\n return renderInitModule({ isBuild: state.isBuild, devBundlePath: state.devBundlePath });\n};\n\nconst loadAssetModule = (state: PluginState, virtualId: string): string => {\n const rest = fromVirtualId(virtualId);\n const separatorIndex = rest.indexOf(REL_SEPARATOR);\n const absPath = rest.slice(0, separatorIndex);\n const rel = rest.slice(separatorIndex + REL_SEPARATOR.length);\n const entry = registerEntry(state, absPath, rel);\n const uri = `resource://${entry.resourcePath}`;\n\n if (!state.isBuild) {\n registerDevAsset(state);\n }\n\n return [\n `import { ensureRegistered } from ${JSON.stringify(VIRTUAL_INIT)};`,\n \"ensureRegistered();\",\n `export default ${JSON.stringify(uri)};`,\n `export const path = ${JSON.stringify(entry.resourcePath)};`,\n ].join(\"\\n\");\n};\n\nconst emitBuildBundle = (\n ctx: { emitFile: (asset: { type: \"asset\"; fileName: string; source: Buffer }) => string },\n state: PluginState,\n): void => {\n if (!state.isBuild || state.entries.size === 0) {\n return;\n }\n\n const compiled = withStagingDir(\"resources-out\", (outDir) => compileBundle(state, join(outDir, BUNDLE_FILENAME)));\n ctx.emitFile({ type: \"asset\", fileName: BUNDLE_FILENAME, source: compiled });\n info(`Compiled ${String(state.entries.size)} resource(s) into ${BUNDLE_FILENAME}`);\n};\n\nconst refreshDevRegistration = async (state: PluginState): Promise<void> => {\n compileDevBundle(state);\n\n try {\n await reregisterDevBundle(state);\n } catch (error_) {\n error(\"Failed to refresh GResource bundle:\", error_);\n }\n};\n\nconst resolveResourceConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader) => {\n const { applicationId } = await loadConfig(config.root ?? process.cwd());\n state.prefix = deriveResourcePrefix(applicationId);\n\n return {\n assetsInclude: [ASSET_RE],\n };\n};\n\nconst refreshTrackedSource = async (state: PluginState, file: string): Promise<void> => {\n if (!isTrackedSource(state, file)) {\n return;\n }\n\n try {\n await refreshDevRegistration(state);\n } catch (error_) {\n error(\"GResource refresh failed:\", error_);\n }\n};\n\nconst attachResourceWatcher = (state: PluginState, server: ViteDevServer): void => {\n state.server = server;\n\n const onFileEvent = (file: string): void => {\n void refreshTrackedSource(state, file);\n };\n\n server.watcher.on(\"change\", onFileEvent);\n server.watcher.on(\"add\", onFileEvent);\n};\n\nconst applyResolvedConfig = (state: PluginState, config: ResolvedConfig): void => {\n state.isBuild = config.command === \"build\";\n\n if (state.isBuild) {\n return;\n }\n\n const relativeDataDir = resolveDataDir(config.root);\n state.dataDir = relativeDataDir === null ? null : join(config.root, relativeDataDir);\n};\n\nconst loadResourceModule = (state: PluginState, id: string): string | undefined => {\n if (id === VIRTUAL_INIT) {\n return loadInitModule(state);\n }\n\n if (!isVirtual(id)) {\n return undefined;\n }\n\n return loadAssetModule(state, id);\n};\n\nfunction gtkxResources(loadConfig: ConfigLoader = createConfigLoader()): Plugin {\n const state: PluginState = {\n prefix: \"\",\n isBuild: false,\n entries: new Map(),\n sourcePaths: new Set(),\n devStagingDir: null,\n devBundlePath: \"\",\n server: null,\n compiledSignature: \"\",\n dataDir: null,\n };\n\n return {\n name: \"gtkx:resources\",\n enforce: \"pre\",\n\n config(config: UserConfig) {\n return resolveResourceConfig(state, config, loadConfig);\n },\n\n configResolved(config: ResolvedConfig) {\n applyResolvedConfig(state, config);\n },\n\n configureServer(server) {\n attachResourceWatcher(state, server);\n primeDevBundle(state);\n },\n\n async resolveId(source, importer, opts) {\n if (source === VIRTUAL_INIT) {\n return VIRTUAL_INIT;\n }\n\n const clean = dataAssetSource(source);\n\n if (clean === null) {\n return;\n }\n\n const resolved = await this.resolve(clean, importer, { ...opts, skipSelf: true });\n\n return resolvedAssetId(resolved, clean);\n },\n\n load(id) {\n return loadResourceModule(state, id);\n },\n\n buildEnd() {\n emitBuildBundle(this, state);\n },\n };\n}\n\nexport { gtkxResources };\n"]}
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/vite-plugins/resources.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,W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AAE,IAAI,EAAE,CAAC,CAAC;YAElF,OAAO,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,EAAE;YACH,OAAO,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,QAAQ;YACJ,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Plugin, ResolvedConfig, UserConfig, ViteDevServer } from \"vite\";\nimport { type ConfigLoader, createConfigLoader } from \"@gtkx/config/internal\";\nimport { error, formatChildProcessError, info, sortStrings } from \"@gtkx/utils\";\nimport { execFileSync } from \"node:child_process\";\nimport { copyFileSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { DATA_IMPORT_PREFIX, resolveDataDir } from \"../internal/data-dir.js\";\nimport { type ListedFile, listFilesRecursive } from \"../internal/list-files.js\";\nimport { resolveCliTool } from \"../internal/resolve-cli-tool.js\";\nimport { withStagingDir } from \"../internal/staging-dir.js\";\nimport { ASSET_PATH_RE, ASSET_RE } from \"./asset-extensions.js\";\nimport { renderInitModule } from \"./resource-init-module.js\";\nimport {\n BUNDLE_FILENAME,\n escapeXml,\n fromVirtualId,\n isVirtual,\n REFRESH_EXPORT,\n REL_SEPARATOR,\n toVirtualId,\n VIRTUAL_INIT,\n} from \"./resource-shared.js\";\nimport { stripQuery } from \"./strip-query.js\";\n\ntype ResourceEntry = {\n sourcePath: string;\n stagedRelPath: string;\n resourcePath: string;\n};\n\ntype PluginState = {\n prefix: string;\n isBuild: boolean;\n entries: Map<string, ResourceEntry>;\n sourcePaths: Set<string>;\n devStagingDir: string | null;\n devBundlePath: string;\n server: ViteDevServer | null;\n compiledSignature: string;\n dataDir: string | null;\n};\n\nconst DATA_PREFIX = `${DATA_IMPORT_PREFIX}/`;\nconst RESOURCE_COMPILER = \"glib-compile-resources\";\nconst MANIFEST_PREFIX = \"/\";\n\nconst deriveResourcePrefix = (applicationId: string): string => `/${applicationId.replaceAll(\".\", \"/\")}`;\n\nconst compileBundle = (state: PluginState, outputPath: string): Buffer =>\n withStagingDir(\"resources\", (dir) => {\n const manifest = stageBundle(dir, state.entries);\n\n return runCompiler(dir, manifest, outputPath);\n });\n\nconst stageBundle = (dir: string, entries: Map<string, ResourceEntry>): string => {\n const fileNodes: string[] = [];\n\n for (const entry of entries.values()) {\n const targetPath = join(dir, entry.stagedRelPath);\n mkdirSync(dirname(targetPath), { recursive: true });\n copyFileSync(entry.sourcePath, targetPath);\n fileNodes.push(` <file>${escapeXml(entry.stagedRelPath)}</file>`);\n }\n\n const prefix = escapeXml(MANIFEST_PREFIX);\n const manifest = join(dir, \"gtkx.gresource.xml\");\n\n const xml = [\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\",\n \"<gresources>\",\n ` <gresource prefix=\"${prefix}\">`,\n ...fileNodes,\n \" </gresource>\",\n \"</gresources>\",\n \"\",\n ].join(\"\\n\");\n\n writeFileSync(manifest, xml);\n\n return manifest;\n};\n\nconst runCompiler = (sourceDir: string, manifest: string, outputPath: string): Buffer => {\n try {\n execFileSync(resolveCliTool(RESOURCE_COMPILER), [\n `--sourcedir=${sourceDir}`,\n `--target=${outputPath}`,\n manifest,\n ]);\n } catch (error) {\n const details = formatChildProcessError(error);\n const suffix = details ? `:\\n${details}` : \"\";\n throw new Error(`${RESOURCE_COMPILER} failed${suffix}`, { cause: error });\n }\n\n return readFileSync(outputPath);\n};\n\nconst ensureStagingDir = (state: PluginState): void => {\n if (state.devStagingDir) {\n return;\n }\n\n state.devStagingDir = mkdtempSync(join(tmpdir(), \"gtkx-resources-dev-\"));\n state.devBundlePath = join(state.devStagingDir, BUNDLE_FILENAME);\n};\n\nconst entriesSignature = (state: PluginState): string => sortStrings(state.entries.keys()).join(\"\\0\");\n\nconst compileDevBundle = (state: PluginState): void => {\n ensureStagingDir(state);\n\n if (state.entries.size === 0) {\n return;\n }\n\n compileBundle(state, state.devBundlePath);\n state.compiledSignature = entriesSignature(state);\n};\n\nconst isRefreshHook = (value: unknown): value is () => void => typeof value === \"function\";\n\nconst reregisterDevBundle = async (state: PluginState): Promise<void> => {\n const server = state.server;\n\n if (!server) {\n return;\n }\n\n const mod = await server.ssrLoadModule(VIRTUAL_INIT);\n const refresh: unknown = mod[REFRESH_EXPORT];\n\n if (isRefreshHook(refresh)) {\n refresh();\n }\n};\n\nconst scanDataAssets = (dataDir: string): ListedFile[] => listFilesRecursive(dataDir, (name) => ASSET_RE.test(name));\n\nconst primeDevBundle = (state: PluginState): void => {\n if (state.dataDir === null) {\n return;\n }\n\n for (const { absPath, rel } of scanDataAssets(state.dataDir)) {\n registerEntry(state, absPath, rel);\n }\n\n compileDevBundle(state);\n};\n\nconst registerDevAsset = (state: PluginState): void => {\n if (entriesSignature(state) !== state.compiledSignature) {\n compileDevBundle(state);\n }\n};\n\nconst registerEntry = (state: PluginState, absPath: string, rel: string): ResourceEntry => {\n const existing = state.entries.get(absPath);\n\n if (existing) {\n return existing;\n }\n\n const resourcePath = `${state.prefix}/${rel}`;\n\n const entry: ResourceEntry = {\n sourcePath: absPath,\n stagedRelPath: resourcePath.replace(/^\\/+/, \"\"),\n resourcePath,\n };\n\n state.entries.set(absPath, entry);\n state.sourcePaths.add(absPath);\n\n return entry;\n};\n\nconst isTrackedSource = (state: PluginState, file: string): boolean => state.sourcePaths.has(file);\n\nconst dataAssetSource = (source: string): string | null => {\n const clean = stripQuery(source);\n\n if (!clean.startsWith(DATA_PREFIX) || !ASSET_PATH_RE.test(clean)) {\n return null;\n }\n\n return clean;\n};\n\nconst resolvedAssetId = (\n resolved: { id: string; external: boolean | string } | null,\n clean: string,\n): string | undefined => {\n if (!resolved || resolved.external) {\n return undefined;\n }\n\n return toVirtualId(resolved.id) + REL_SEPARATOR + clean.slice(DATA_PREFIX.length);\n};\n\nconst loadInitModule = (state: PluginState): string => {\n if (!state.isBuild) {\n ensureStagingDir(state);\n }\n\n return renderInitModule({ isBuild: state.isBuild, devBundlePath: state.devBundlePath });\n};\n\nconst loadAssetModule = (state: PluginState, virtualId: string): string => {\n const rest = fromVirtualId(virtualId);\n const separatorIndex = rest.indexOf(REL_SEPARATOR);\n const absPath = rest.slice(0, separatorIndex);\n const rel = rest.slice(separatorIndex + REL_SEPARATOR.length);\n const entry = registerEntry(state, absPath, rel);\n const uri = `resource://${entry.resourcePath}`;\n\n if (!state.isBuild) {\n registerDevAsset(state);\n }\n\n return [\n `import { ensureRegistered } from ${JSON.stringify(VIRTUAL_INIT)};`,\n \"ensureRegistered();\",\n `export default ${JSON.stringify(uri)};`,\n `export const path = ${JSON.stringify(entry.resourcePath)};`,\n ].join(\"\\n\");\n};\n\nconst emitBuildBundle = (\n ctx: { emitFile: (asset: { type: \"asset\"; fileName: string; source: Buffer }) => string },\n state: PluginState,\n): void => {\n if (!state.isBuild || state.entries.size === 0) {\n return;\n }\n\n const compiled = withStagingDir(\"resources-out\", (outDir) => compileBundle(state, join(outDir, BUNDLE_FILENAME)));\n ctx.emitFile({ type: \"asset\", fileName: BUNDLE_FILENAME, source: compiled });\n info(`Compiled ${String(state.entries.size)} resource(s) into ${BUNDLE_FILENAME}`);\n};\n\nconst refreshDevRegistration = async (state: PluginState): Promise<void> => {\n compileDevBundle(state);\n\n try {\n await reregisterDevBundle(state);\n } catch (error_) {\n error(\"Failed to refresh GResource bundle:\", error_);\n }\n};\n\nconst resolveResourceConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader) => {\n const { applicationId } = await loadConfig.resolve(config.root ?? process.cwd());\n state.prefix = deriveResourcePrefix(applicationId);\n\n return {\n assetsInclude: [ASSET_RE],\n };\n};\n\nconst refreshTrackedSource = async (state: PluginState, file: string): Promise<void> => {\n if (!isTrackedSource(state, file)) {\n return;\n }\n\n try {\n await refreshDevRegistration(state);\n } catch (error_) {\n error(\"GResource refresh failed:\", error_);\n }\n};\n\nconst attachResourceWatcher = (state: PluginState, server: ViteDevServer): void => {\n state.server = server;\n\n const onFileEvent = (file: string): void => {\n void refreshTrackedSource(state, file);\n };\n\n server.watcher.on(\"change\", onFileEvent);\n server.watcher.on(\"add\", onFileEvent);\n};\n\nconst applyResolvedConfig = (state: PluginState, config: ResolvedConfig): void => {\n state.isBuild = config.command === \"build\";\n\n if (state.isBuild) {\n return;\n }\n\n const relativeDataDir = resolveDataDir(config.root);\n state.dataDir = relativeDataDir === null ? null : join(config.root, relativeDataDir);\n};\n\nconst loadResourceModule = (state: PluginState, id: string): string | undefined => {\n if (id === VIRTUAL_INIT) {\n return loadInitModule(state);\n }\n\n if (!isVirtual(id)) {\n return undefined;\n }\n\n return loadAssetModule(state, id);\n};\n\nfunction gtkxResources(loadConfig: ConfigLoader = createConfigLoader()): Plugin {\n const state: PluginState = {\n prefix: \"\",\n isBuild: false,\n entries: new Map(),\n sourcePaths: new Set(),\n devStagingDir: null,\n devBundlePath: \"\",\n server: null,\n compiledSignature: \"\",\n dataDir: null,\n };\n\n return {\n name: \"gtkx:resources\",\n enforce: \"pre\",\n\n config(config: UserConfig) {\n return resolveResourceConfig(state, config, loadConfig);\n },\n\n configResolved(config: ResolvedConfig) {\n applyResolvedConfig(state, config);\n },\n\n configureServer(server) {\n attachResourceWatcher(state, server);\n primeDevBundle(state);\n },\n\n async resolveId(source, importer, opts) {\n if (source === VIRTUAL_INIT) {\n return VIRTUAL_INIT;\n }\n\n const clean = dataAssetSource(source);\n\n if (clean === null) {\n return;\n }\n\n const resolved = await this.resolve(clean, importer, { ...opts, skipSelf: true });\n\n return resolvedAssetId(resolved, clean);\n },\n\n load(id) {\n return loadResourceModule(state, id);\n },\n\n buildEnd() {\n emitBuildBundle(this, state);\n },\n };\n}\n\nexport { gtkxResources };\n"]}
@@ -1,4 +1,5 @@
1
+ import type { ConfigLoader } from "@gtkx/config/internal";
1
2
  import type { Plugin } from "vite";
2
- declare function gtkxUndeclaredLibrary(mode?: string): Plugin;
3
+ declare function gtkxUndeclaredLibrary(loadConfig?: ConfigLoader): Plugin;
3
4
  export { gtkxUndeclaredLibrary };
4
5
  //# sourceMappingURL=undeclared-library.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"undeclared-library.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/undeclared-library.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AA4C/C,iBAAS,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CA+BpD;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
1
+ {"version":3,"file":"undeclared-library.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/undeclared-library.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AA4C/C,iBAAS,qBAAqB,CAAC,UAAU,GAAE,YAAmC,GAAG,MAAM,CA+BtF;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { discoverGirNamespaces, resolveGirPath } from "@gtkx/codegen";
2
- import { loadConfig } from "@gtkx/config";
2
+ import { createConfigLoader } from "@gtkx/config/internal";
3
3
  const GENERATED_MODULE_PATTERN = /^@gtkx\/(?:gi|jsx)\/([a-z0-9]+)$/;
4
4
  const girSearchPaths = async (state) => {
5
5
  if (state.girPath === null) {
6
- const { config } = await loadConfig(state.root, { mode: state.mode });
6
+ const { config } = await state.loadConfig.load(state.root);
7
7
  state.girPath = resolveGirPath(config.girPath);
8
8
  }
9
9
  return state.girPath;
@@ -21,10 +21,10 @@ const undeclaredLibraryError = (source, namespace, girPath) => {
21
21
  return new Error(`Cannot resolve "${source}": the "${identifier}" bindings have not been generated. ` +
22
22
  `Add "${identifier}" to \`libraries\` in gtkx.config.ts, then run gtkx dev or gtkx build again.`);
23
23
  };
24
- function gtkxUndeclaredLibrary(mode) {
24
+ function gtkxUndeclaredLibrary(loadConfig = createConfigLoader()) {
25
25
  const state = {
26
26
  root: "",
27
- mode,
27
+ loadConfig,
28
28
  girPath: null,
29
29
  };
30
30
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"undeclared-library.js","sourceRoot":"","sources":["../../src/vite-plugins/undeclared-library.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ1C,MAAM,wBAAwB,GAAG,kCAAkC,CAAC;AAEpE,MAAM,cAAc,GAAG,KAAK,EAAE,KAAkB,EAAqB,EAAE;IACnE,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QACzB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,UAAkB,EAAU,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAEhH,MAAM,iBAAiB,GAAG,CAAC,OAAiB,EAAE,SAAiB,EAAsB,EAAE,CACnF,qBAAqB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,SAAS,CAAC,CAAC;AAEhG,MAAM,sBAAsB,GAAG,CAAC,MAAc,E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MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QACjF,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import type { Plugin, UserConfig } from \"vite\";\nimport { discoverGirNamespaces, resolveGirPath } from \"@gtkx/codegen\";\nimport { loadConfig } from \"@gtkx/config\";\n\ntype PluginState = {\n root: string;\n mode: string | undefined;\n girPath: string[] | null;\n};\n\nconst GENERATED_MODULE_PATTERN = /^@gtkx\\/(?:gi|jsx)\\/([a-z0-9]+)$/;\n\nconst girSearchPaths = async (state: PluginState): Promise<string[]> => {\n if (state.girPath === null) {\n const { config } = await loadConfig(state.root, { mode: state.mode });\n state.girPath = resolveGirPath(config.girPath);\n }\n\n return state.girPath;\n};\n\nconst getNamespace = (identifier: string): string => identifier.slice(0, identifier.indexOf(\"-\")).toLowerCase();\n\nconst findGirIdentifier = (girPath: string[], namespace: string): string | undefined =>\n discoverGirNamespaces(girPath).find((identifier) => getNamespace(identifier) === namespace);\n\nconst undeclaredLibraryError = (source: string, namespace: string, girPath: string[]): Error => {\n const identifier = findGirIdentifier(girPath, namespace);\n\n if (identifier === undefined) {\n return new Error(\n `Cannot resolve \"${source}\": the binding store has no \"${namespace}\" module, and no GIR data for it ` +\n `was found in [${girPath.join(\", \")}]. If \"${namespace}\" is a library, install its ` +\n \"gobject-introspection data package and add its GIR identifier to `libraries` in gtkx.config.ts. \" +\n \"Otherwise run gtkx codegen to regenerate the store.\",\n );\n }\n\n return new Error(\n `Cannot resolve \"${source}\": the \"${identifier}\" bindings have not been generated. ` +\n `Add \"${identifier}\" to \\`libraries\\` in gtkx.config.ts, then run gtkx dev or gtkx build again.`,\n );\n};\n\nfunction gtkxUndeclaredLibrary(mode?: string): Plugin {\n const state: PluginState = {\n root: \"\",\n mode,\n girPath: null,\n };\n\n return {\n name: \"gtkx:undeclared-library\",\n enforce: \"pre\",\n\n config(config: UserConfig) {\n state.root = config.root ?? process.cwd();\n },\n\n async resolveId(source, importer, options) {\n const namespace = GENERATED_MODULE_PATTERN.exec(source)?.[1];\n\n if (namespace === undefined) {\n return;\n }\n\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });\n\n if (resolved !== null) {\n return;\n }\n\n throw undeclaredLibraryError(source, namespace, await girSearchPaths(state));\n },\n };\n}\n\nexport { gtkxUndeclaredLibrary };\n"]}
1
+ {"version":3,"file":"undeclared-library.js","sourceRoot":"","sources":["../../src/vite-plugins/undeclared-library.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAQ3D,MAAM,wBAAwB,GAAG,kCAAkC,CAAC;AAEpE,MAAM,cAAc,GAAG,KAAK,EAAE,KAAkB,EAAqB,EAAE;IACnE,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QACzB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3D,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,UAAkB,EAAU,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAEhH,MAAM,iBAAiB,GAAG,CAAC,OAAiB,EAAE,SAAiB,EAAsB,EAAE,CACnF,qBAAqB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,SAAS,CAAC,CAAC;AAEhG,MAAM,sBA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AO;YACX,CAAC;YAED,MAAM,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QACjF,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import type { ConfigLoader } from \"@gtkx/config/internal\";\nimport type { Plugin, UserConfig } from \"vite\";\nimport { discoverGirNamespaces, resolveGirPath } from \"@gtkx/codegen\";\nimport { createConfigLoader } from \"@gtkx/config/internal\";\n\ntype PluginState = {\n root: string;\n loadConfig: ConfigLoader;\n girPath: string[] | null;\n};\n\nconst GENERATED_MODULE_PATTERN = /^@gtkx\\/(?:gi|jsx)\\/([a-z0-9]+)$/;\n\nconst girSearchPaths = async (state: PluginState): Promise<string[]> => {\n if (state.girPath === null) {\n const { config } = await state.loadConfig.load(state.root);\n state.girPath = resolveGirPath(config.girPath);\n }\n\n return state.girPath;\n};\n\nconst getNamespace = (identifier: string): string => identifier.slice(0, identifier.indexOf(\"-\")).toLowerCase();\n\nconst findGirIdentifier = (girPath: string[], namespace: string): string | undefined =>\n discoverGirNamespaces(girPath).find((identifier) => getNamespace(identifier) === namespace);\n\nconst undeclaredLibraryError = (source: string, namespace: string, girPath: string[]): Error => {\n const identifier = findGirIdentifier(girPath, namespace);\n\n if (identifier === undefined) {\n return new Error(\n `Cannot resolve \"${source}\": the binding store has no \"${namespace}\" module, and no GIR data for it ` +\n `was found in [${girPath.join(\", \")}]. If \"${namespace}\" is a library, install its ` +\n \"gobject-introspection data package and add its GIR identifier to `libraries` in gtkx.config.ts. \" +\n \"Otherwise run gtkx codegen to regenerate the store.\",\n );\n }\n\n return new Error(\n `Cannot resolve \"${source}\": the \"${identifier}\" bindings have not been generated. ` +\n `Add \"${identifier}\" to \\`libraries\\` in gtkx.config.ts, then run gtkx dev or gtkx build again.`,\n );\n};\n\nfunction gtkxUndeclaredLibrary(loadConfig: ConfigLoader = createConfigLoader()): Plugin {\n const state: PluginState = {\n root: \"\",\n loadConfig,\n girPath: null,\n };\n\n return {\n name: \"gtkx:undeclared-library\",\n enforce: \"pre\",\n\n config(config: UserConfig) {\n state.root = config.root ?? process.cwd();\n },\n\n async resolveId(source, importer, options) {\n const namespace = GENERATED_MODULE_PATTERN.exec(source)?.[1];\n\n if (namespace === undefined) {\n return;\n }\n\n const resolved = await this.resolve(source, importer, { ...options, skipSelf: true });\n\n if (resolved !== null) {\n return;\n }\n\n throw undeclaredLibraryError(source, namespace, await girSearchPaths(state));\n },\n };\n}\n\nexport { gtkxUndeclaredLibrary };\n"]}
@@ -1,10 +1,4 @@
1
1
  import type { Plugin } from "vite";
2
- /**
3
- * Vite plugin factory that assembles the plugins needed to run GTKX apps under Vitest,
4
- * combining the shared GTKX Vite plugins with the `@gtkx/vitest` test integration.
5
- *
6
- * @returns The ordered array of Vite plugins to include in a Vitest configuration.
7
- */
8
2
  declare const gtkx: () => Plugin[];
9
3
  export default gtkx;
10
4
  //# sourceMappingURL=vitest-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vitest-plugin.d.ts","sourceRoot":"","sources":["../src/vitest-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC;;;;;GAKG;AACH,QAAA,MAAM,IAAI,QAAO,MAAM,EAAmE,CAAC;AAC3F,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"vitest-plugin.d.ts","sourceRoot":"","sources":["../src/vitest-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,QAAA,MAAM,IAAI,QAAO,MAAM,EAAmE,CAAC;AAC3F,eAAe,IAAI,CAAC"}
@@ -1,12 +1,6 @@
1
1
  import gtkxVitest from "@gtkx/vitest";
2
2
  import { gtkxVitePlugins } from "./vite-plugins/index.js";
3
3
  import { gtkxSettingsWorkerEnv } from "./vite-plugins/settings-worker-env.js";
4
- /**
5
- * Vite plugin factory that assembles the plugins needed to run GTKX apps under Vitest,
6
- * combining the shared GTKX Vite plugins with the `@gtkx/vitest` test integration.
7
- *
8
- * @returns The ordered array of Vite plugins to include in a Vitest configuration.
9
- */
10
4
  const gtkx = () => [...gtkxVitePlugins(), gtkxSettingsWorkerEnv(), gtkxVitest()];
11
5
  export default gtkx;
12
6
  //# sourceMappingURL=vitest-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vitest-plugin.js","sourceRoot":"","sources":["../src/vitest-plugin.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,IAAI,GAAG,GAAa,EAAE,CAAC,CAAC,GAAG,eAAe,EAAE,EAAE,qBAAqB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;AAC3F,eAAe,IAAI,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport gtkxVitest from \"@gtkx/vitest\";\nimport { gtkxVitePlugins } from \"./vite-plugins/index.js\";\nimport { gtkxSettingsWorkerEnv } from \"./vite-plugins/settings-worker-env.js\";\n\n/**\n * Vite plugin factory that assembles the plugins needed to run GTKX apps under Vitest,\n * combining the shared GTKX Vite plugins with the `@gtkx/vitest` test integration.\n *\n * @returns The ordered array of Vite plugins to include in a Vitest configuration.\n */\nconst gtkx = (): Plugin[] => [...gtkxVitePlugins(), gtkxSettingsWorkerEnv(), gtkxVitest()];\nexport default gtkx;\n"]}
1
+ {"version":3,"file":"vitest-plugin.js","sourceRoot":"","sources":["../src/vitest-plugin.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,MAAM,IAAI,GAAG,GAAa,EAAE,CAAC,CAAC,GAAG,eAAe,EAAE,EAAE,qBAAqB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;AAC3F,eAAe,IAAI,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport gtkxVitest from \"@gtkx/vitest\";\nimport { gtkxVitePlugins } from \"./vite-plugins/index.js\";\nimport { gtkxSettingsWorkerEnv } from \"./vite-plugins/settings-worker-env.js\";\n\nconst gtkx = (): Plugin[] => [...gtkxVitePlugins(), gtkxSettingsWorkerEnv(), gtkxVitest()];\nexport default gtkx;\n"]}
package/env.d.ts CHANGED
@@ -2,98 +2,123 @@
2
2
  /// <reference types="@gtkx/react/env" />
3
3
 
4
4
  declare module "*.aac" {
5
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
5
6
  export const path: string;
6
7
  }
7
8
 
8
9
  declare module "*.avif" {
10
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
9
11
  export const path: string;
10
12
  }
11
13
 
12
14
  declare module "*.eot" {
15
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
13
16
  export const path: string;
14
17
  }
15
18
 
16
19
  declare module "*.flac" {
20
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
17
21
  export const path: string;
18
22
  }
19
23
 
20
24
  declare module "*.gif" {
25
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
21
26
  export const path: string;
22
27
  }
23
28
 
24
29
  declare module "*.ico" {
30
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
25
31
  export const path: string;
26
32
  }
27
33
 
28
34
  declare module "*.jpeg" {
35
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
29
36
  export const path: string;
30
37
  }
31
38
 
32
39
  declare module "*.jpg" {
40
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
33
41
  export const path: string;
34
42
  }
35
43
 
36
44
  declare module "*.mp3" {
45
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
37
46
  export const path: string;
38
47
  }
39
48
 
40
49
  declare module "*.mp4" {
50
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
41
51
  export const path: string;
42
52
  }
43
53
 
44
54
  declare module "*.ogg" {
55
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
45
56
  export const path: string;
46
57
  }
47
58
 
48
59
  declare module "*.otf" {
60
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
49
61
  export const path: string;
50
62
  }
51
63
 
52
64
  declare module "*.png" {
65
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
53
66
  export const path: string;
54
67
  }
55
68
 
56
69
  declare module "*.svg" {
70
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
57
71
  export const path: string;
58
72
  }
59
73
 
60
74
  declare module "*.ttf" {
75
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
61
76
  export const path: string;
62
77
  }
63
78
 
64
79
  declare module "*.wav" {
80
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
65
81
  export const path: string;
66
82
  }
67
83
 
68
84
  declare module "*.webm" {
85
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
69
86
  export const path: string;
70
87
  }
71
88
 
72
89
  declare module "*.webp" {
90
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
73
91
  export const path: string;
74
92
  }
75
93
 
76
94
  declare module "*.woff" {
95
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
77
96
  export const path: string;
78
97
  }
79
98
 
80
99
  declare module "*.woff2" {
100
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
81
101
  export const path: string;
82
102
  }
83
103
 
84
104
  declare module "*.data" {
105
+ /** `resource://` URI of the bundled asset, accepted anywhere GTK takes a URI. */
85
106
  const resourceUri: string;
107
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
86
108
  export const path: string;
87
109
  export default resourceUri;
88
110
  }
89
111
 
90
112
  declare module "*.gpa" {
113
+ /** `resource://` URI of the bundled asset, accepted anywhere GTK takes a URI. */
91
114
  const resourceUri: string;
115
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
92
116
  export const path: string;
93
117
  export default resourceUri;
94
118
  }
95
119
 
96
120
  declare module "*.css?url" {
121
+ /** Filesystem path of the emitted stylesheet, imported without installing it on the default display. */
97
122
  const path: string;
98
123
  export default path;
99
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/cli",
3
- "version": "1.0.0-rc.2",
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.46",
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.1.5",
65
- "@gtkx/codegen": "1.0.0-rc.2",
66
- "@gtkx/config": "1.0.0-rc.2",
67
- "@gtkx/mcp": "1.0.0-rc.2",
68
- "@gtkx/runtime": "1.0.0-rc.2",
69
- "@gtkx/utils": "1.0.0-rc.2",
70
- "@gtkx/vitest": "1.0.0-rc.2",
71
- "create-gtkx": "1.0.0-rc.2"
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.2"
77
+ "@gtkx/testing": "1.0.0-rc.4"
78
78
  },
79
79
  "peerDependencies": {
80
80
  "react": "^19"
@@ -27,15 +27,12 @@ const namespaceBarrelPath = (giStoreDir: string, library: string): string => {
27
27
  return join(giStoreDir, namespace, "index.js");
28
28
  };
29
29
 
30
- const canResolveGiStoreLinks = (giStoreDir: string): boolean =>
31
- existsSync(join(giStoreDir, "node_modules", "@gtkx", "gi", "package.json"));
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) || !existsSync(store.giStoreDir)) {
35
- return true;
36
- }
37
-
38
- if (!canResolveGiStoreLinks(store.giStoreDir)) {
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
 
@@ -1,6 +1,11 @@
1
1
  import { runCodegen as runCodegenCore } from "@gtkx/codegen";
2
2
  import { type Config, loadConfig } from "@gtkx/config";
3
- import { resolveLazyElements } from "@gtkx/config/internal";
3
+ import {
4
+ resolveElementComponents,
5
+ resolveElementProps,
6
+ resolveLazyElements,
7
+ resolveOmittedProps,
8
+ } from "@gtkx/config/internal";
4
9
  import { info } from "@gtkx/utils";
5
10
  import { rmSync } from "node:fs";
6
11
  import { resolve } from "node:path";
@@ -12,18 +17,18 @@ import { type CodegenStore, resolveCodegenContext } from "./store-resolver.js";
12
17
  type RunCodegenOptions = {
13
18
  cwd?: string;
14
19
  mode?: string | undefined;
15
- force?: boolean;
20
+ isForced?: boolean;
16
21
  inputs?: CodegenInputs;
17
22
  resolved?: LoadedConfig;
18
23
  };
19
24
 
20
25
  type LoadedConfig = {
21
26
  config: Config;
22
- configFile: string | undefined;
27
+ configFile: string;
23
28
  };
24
29
 
25
30
  type RunCodegenResult = {
26
- regenerated: boolean;
31
+ isRegenerated: boolean;
27
32
  namespaces: number;
28
33
  intrinsicElements: number;
29
34
  duration: number;
@@ -39,7 +44,7 @@ type CodegenOptionsInput = {
39
44
  elements: Config["elements"];
40
45
  };
41
46
 
42
- type PreparedCodegen = CodegenInputs & { force: boolean };
47
+ type PreparedCodegen = CodegenInputs & { isForced: boolean };
43
48
 
44
49
  type RunOptionsInput = {
45
50
  root: string;
@@ -64,18 +69,6 @@ const removeSharedStoreShadow = (cwd: string): void => {
64
69
  }
65
70
  };
66
71
 
67
- const userModuleExports = (
68
- elements: Config["elements"],
69
- key: "component" | "props",
70
- ): Record<string, { module: string; export: string }> =>
71
- Object.fromEntries(
72
- Object.entries(elements?.config ?? {}).flatMap(([type, entry]) => {
73
- const ref = entry[key];
74
-
75
- return ref === undefined ? [] : [[type, ref] as const];
76
- }),
77
- );
78
-
79
72
  const codegenOptions = ({ store, libraries, girPath, elements }: CodegenOptionsInput) => ({
80
73
  libraries,
81
74
  girPath,
@@ -93,13 +86,14 @@ const codegenOptions = ({ store, libraries, girPath, elements }: CodegenOptionsI
93
86
  version: store.react.version,
94
87
  },
95
88
  reactSubexports: store.react?.subexports ?? [],
96
- userComponents: userModuleExports(elements, "component"),
97
- userProps: userModuleExports(elements, "props"),
89
+ userComponents: resolveElementComponents(elements),
90
+ userProps: resolveElementProps(elements),
98
91
  userLazyElements: resolveLazyElements(elements),
92
+ userOmittedProps: resolveOmittedProps(elements),
99
93
  });
100
94
 
101
- const disabledCodegenResult = (configFile: string | undefined): RunCodegenResult => ({
102
- regenerated: false,
95
+ const disabledCodegenResult = (configFile: string): RunCodegenResult => ({
96
+ isRegenerated: false,
103
97
  namespaces: 0,
104
98
  intrinsicElements: 0,
105
99
  duration: 0,
@@ -124,9 +118,9 @@ const prepareCodegen = (options: RunCodegenOptions, cwd: string, config: Config)
124
118
  throw new Error(GIR_PATH_MISSING_MESSAGE);
125
119
  }
126
120
 
127
- const isForce = options.force === true || isCodegenStale({ girPath, libraries, store });
121
+ const isForced = options.isForced === true || isCodegenStale({ girPath, libraries, store });
128
122
 
129
- return { girPath, libraries, store, force: isForce };
123
+ return { girPath, libraries, store, isForced };
130
124
  };
131
125
 
132
126
  const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenResult> => {
@@ -139,19 +133,24 @@ const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenRe
139
133
  return disabledCodegenResult(configFile);
140
134
  }
141
135
 
142
- const { girPath, libraries, store, force } = prepareCodegen(options, cwd, config);
136
+ const { girPath, libraries, store, isForced } = prepareCodegen(options, cwd, config);
143
137
 
144
- if (options.force) {
138
+ if (options.isForced) {
145
139
  clearGeneratedStores(store);
146
140
  }
147
141
 
148
142
  const result = await runCodegenCore({
149
- ...codegenOptions({ store, libraries, girPath, elements: config.elements }),
150
- force,
143
+ ...codegenOptions({
144
+ store,
145
+ libraries,
146
+ girPath,
147
+ elements: config.elements,
148
+ }),
149
+ isForced,
151
150
  });
152
151
 
153
152
  return {
154
- regenerated: result.regenerated,
153
+ isRegenerated: result.isRegenerated,
155
154
  namespaces: result.namespaces,
156
155
  intrinsicElements: result.intrinsicElements,
157
156
  duration: result.duration,
@@ -183,8 +182,8 @@ const resolveInputsOrNull = (cwd: string, config: Config): CodegenInputs | null
183
182
  }
184
183
  };
185
184
 
186
- const maybeAnnounceStale = (announce: boolean | undefined, inputs: CodegenInputs | null): void => {
187
- if (!announce) {
185
+ const maybeAnnounceStale = (shouldAnnounce: boolean | undefined, inputs: CodegenInputs | null): void => {
186
+ if (!shouldAnnounce) {
188
187
  return;
189
188
  }
190
189
 
@@ -203,18 +202,13 @@ const getRunOptions = ({ root, mode, inputs, resolved }: RunOptionsInput): RunCo
203
202
 
204
203
  const ensureGenerated = async (
205
204
  cwd: string,
206
- options: { announce?: boolean; mode?: string } = {},
205
+ options: { shouldAnnounce?: boolean; mode?: string } = {},
207
206
  ): Promise<boolean> => {
208
- if (options.announce && process.env.GTKX_DISABLE_PREFLIGHT === "1") {
207
+ if (options.shouldAnnounce && process.env.GTKX_DISABLE_PREFLIGHT === "1") {
209
208
  return false;
210
209
  }
211
210
 
212
211
  const context = await resolveCodegenContext(cwd, options.mode);
213
-
214
- if (!context) {
215
- return false;
216
- }
217
-
218
212
  syncSchemaEnv(cwd);
219
213
 
220
214
  if (context.config.codegen === false) {
@@ -224,23 +218,19 @@ const ensureGenerated = async (
224
218
  }
225
219
 
226
220
  const inputs = resolveInputsOrNull(context.root, context.config);
227
- maybeAnnounceStale(options.announce, inputs);
221
+ maybeAnnounceStale(options.shouldAnnounce, inputs);
228
222
  const resolved = { config: context.config, configFile: context.configFile };
229
223
  const result = await runCodegen(getRunOptions({ root: context.root, mode: options.mode, inputs, resolved }));
230
224
 
231
- return result.regenerated;
225
+ return result.isRegenerated;
232
226
  };
233
227
 
234
228
  const resolveConfigWatch = async (
235
229
  cwd: string,
236
230
  mode?: string,
237
- ): Promise<{ paths: string[]; regenerate: () => Promise<void> } | undefined> => {
231
+ ): Promise<{ paths: string[]; regenerate: () => Promise<void> }> => {
238
232
  const { configFile, root } = await loadConfig(cwd, { mode });
239
233
 
240
- if (configFile === undefined) {
241
- return undefined;
242
- }
243
-
244
234
  return {
245
235
  paths: [resolve(root, configFile)],
246
236
  regenerate: async () => {