@gtkx/cli 2.0.0-beta.7 → 2.0.0-beta.9
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/dist/commands/deploy.d.ts +4 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +6 -0
- package/dist/commands/deploy.js.map +1 -1
- package/dist/deploy/depends.d.ts.map +1 -1
- package/dist/deploy/depends.js +24 -2
- package/dist/deploy/depends.js.map +1 -1
- package/dist/deploy/download.d.ts +7 -3
- package/dist/deploy/download.d.ts.map +1 -1
- package/dist/deploy/download.js +19 -15
- package/dist/deploy/download.js.map +1 -1
- package/dist/deploy/native-addon.d.ts +5 -0
- package/dist/deploy/native-addon.d.ts.map +1 -0
- package/dist/deploy/native-addon.js +134 -0
- package/dist/deploy/native-addon.js.map +1 -0
- package/dist/deploy/node-runtime/download.js +2 -2
- package/dist/deploy/node-runtime/download.js.map +1 -1
- package/dist/deploy/node-runtime/elf.d.ts +3 -1
- package/dist/deploy/node-runtime/elf.d.ts.map +1 -1
- package/dist/deploy/node-runtime/elf.js +3 -1
- package/dist/deploy/node-runtime/elf.js.map +1 -1
- package/dist/deploy/node-runtime/guard.d.ts.map +1 -1
- package/dist/deploy/node-runtime/guard.js +7 -14
- package/dist/deploy/node-runtime/guard.js.map +1 -1
- package/dist/deploy/node-runtime/index.d.ts +2 -1
- package/dist/deploy/node-runtime/index.d.ts.map +1 -1
- package/dist/deploy/node-runtime/index.js +29 -6
- package/dist/deploy/node-runtime/index.js.map +1 -1
- package/dist/deploy/node-runtime/sonames.d.ts +5 -0
- package/dist/deploy/node-runtime/sonames.d.ts.map +1 -0
- package/dist/deploy/node-runtime/sonames.js +13 -0
- package/dist/deploy/node-runtime/sonames.js.map +1 -0
- package/dist/deploy/payload/stage.d.ts +2 -1
- package/dist/deploy/payload/stage.d.ts.map +1 -1
- package/dist/deploy/payload/stage.js +22 -2
- package/dist/deploy/payload/stage.js.map +1 -1
- package/dist/deploy/run-deploy.d.ts +1 -0
- package/dist/deploy/run-deploy.d.ts.map +1 -1
- package/dist/deploy/run-deploy.js +139 -80
- package/dist/deploy/run-deploy.js.map +1 -1
- package/dist/deploy/settings/arch.d.ts +9 -3
- package/dist/deploy/settings/arch.d.ts.map +1 -1
- package/dist/deploy/settings/arch.js +27 -6
- package/dist/deploy/settings/arch.js.map +1 -1
- package/dist/deploy/settings/index.d.ts +2 -1
- package/dist/deploy/settings/index.d.ts.map +1 -1
- package/dist/deploy/settings/index.js +2 -1
- package/dist/deploy/settings/index.js.map +1 -1
- package/dist/deploy/settings/paths.d.ts +2 -1
- package/dist/deploy/settings/paths.d.ts.map +1 -1
- package/dist/deploy/settings/paths.js +6 -5
- package/dist/deploy/settings/paths.js.map +1 -1
- package/dist/deploy/targets/appimage.d.ts.map +1 -1
- package/dist/deploy/targets/appimage.js +1 -0
- package/dist/deploy/targets/appimage.js.map +1 -1
- package/dist/deploy/targets/flatpak-pnpm.js +4 -4
- package/dist/deploy/targets/flatpak-pnpm.js.map +1 -1
- package/dist/deploy/targets/flatpak.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak.js +1 -0
- package/dist/deploy/targets/flatpak.js.map +1 -1
- package/dist/deploy/targets/nfpm-target.d.ts.map +1 -1
- package/dist/deploy/targets/nfpm-target.js +1 -0
- package/dist/deploy/targets/nfpm-target.js.map +1 -1
- package/dist/deploy/types.d.ts +4 -2
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/deploy/types.js.map +1 -1
- package/dist/deploy/vendored/appimagetool.js +2 -2
- package/dist/deploy/vendored/appimagetool.js.map +1 -1
- package/dist/deploy/vendored/nfpm.js +1 -1
- package/dist/deploy/vendored/nfpm.js.map +1 -1
- package/dist/dev/font-dir.d.ts +1 -1
- package/dist/dev/font-dir.d.ts.map +1 -1
- package/dist/dev/font-dir.js +0 -3
- package/dist/dev/font-dir.js.map +1 -1
- package/dist/dev/runner.d.ts.map +1 -1
- package/dist/dev/runner.js +19 -6
- package/dist/dev/runner.js.map +1 -1
- package/dist/internal/font-staging.d.ts +5 -2
- package/dist/internal/font-staging.d.ts.map +1 -1
- package/dist/internal/font-staging.js +76 -27
- package/dist/internal/font-staging.js.map +1 -1
- package/dist/internal/icon-staging.d.ts +3 -0
- package/dist/internal/icon-staging.d.ts.map +1 -0
- package/dist/internal/icon-staging.js +40 -0
- package/dist/internal/icon-staging.js.map +1 -0
- package/dist/internal/source-imports.js +1 -1
- package/dist/internal/source-imports.js.map +1 -1
- package/dist/vite-plugins/font-worker-env.d.ts.map +1 -1
- package/dist/vite-plugins/font-worker-env.js +2 -5
- package/dist/vite-plugins/font-worker-env.js.map +1 -1
- package/dist/vite-plugins/font.d.ts.map +1 -1
- package/dist/vite-plugins/font.js +16 -4
- package/dist/vite-plugins/font.js.map +1 -1
- package/dist/vite-plugins/icon-worker-env.d.ts +4 -0
- package/dist/vite-plugins/icon-worker-env.d.ts.map +1 -0
- package/dist/vite-plugins/icon-worker-env.js +23 -0
- package/dist/vite-plugins/icon-worker-env.js.map +1 -0
- package/dist/vite-plugins/icons.js +2 -2
- package/dist/vite-plugins/icons.js.map +1 -1
- package/dist/vite-plugins/react-compiler.js +2 -2
- package/dist/vite-plugins/react-compiler.js.map +1 -1
- package/dist/vite-plugins/resources.js +2 -2
- package/dist/vite-plugins/resources.js.map +1 -1
- package/dist/vite-plugins/settings-worker-env.js +2 -2
- package/dist/vite-plugins/settings-worker-env.js.map +1 -1
- package/dist/vite-plugins/store-links.d.ts.map +1 -1
- package/dist/vite-plugins/store-links.js +2 -1
- package/dist/vite-plugins/store-links.js.map +1 -1
- package/dist/vite-plugins/undeclared-library.js +2 -2
- package/dist/vite-plugins/undeclared-library.js.map +1 -1
- package/dist/vite-plugins/worker.d.ts.map +1 -1
- package/dist/vite-plugins/worker.js +21 -13
- package/dist/vite-plugins/worker.js.map +1 -1
- package/dist/vitest-plugin.d.ts +2 -2
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +4 -2
- package/dist/vitest-plugin.js.map +1 -1
- package/package.json +13 -13
- package/src/commands/deploy.ts +6 -0
- package/src/deploy/depends.ts +30 -3
- package/src/deploy/download.ts +33 -17
- package/src/deploy/native-addon.ts +183 -0
- package/src/deploy/node-runtime/download.ts +2 -2
- package/src/deploy/node-runtime/elf.ts +4 -1
- package/src/deploy/node-runtime/guard.ts +10 -14
- package/src/deploy/node-runtime/index.ts +42 -7
- package/src/deploy/node-runtime/sonames.ts +17 -0
- package/src/deploy/payload/stage.ts +34 -2
- package/src/deploy/run-deploy.ts +209 -94
- package/src/deploy/settings/arch.ts +40 -8
- package/src/deploy/settings/index.ts +4 -1
- package/src/deploy/settings/paths.ts +8 -6
- package/src/deploy/targets/appimage.ts +1 -0
- package/src/deploy/targets/flatpak-pnpm.ts +4 -4
- package/src/deploy/targets/flatpak.ts +1 -0
- package/src/deploy/targets/nfpm-target.ts +1 -0
- package/src/deploy/types.ts +4 -1
- package/src/deploy/vendored/appimagetool.ts +2 -2
- package/src/deploy/vendored/nfpm.ts +1 -1
- package/src/dev/font-dir.ts +1 -6
- package/src/dev/runner.ts +24 -6
- package/src/internal/font-staging.ts +99 -27
- package/src/internal/icon-staging.ts +58 -0
- package/src/internal/source-imports.ts +1 -1
- package/src/vite-plugins/font-worker-env.ts +2 -6
- package/src/vite-plugins/font.ts +21 -3
- package/src/vite-plugins/icon-worker-env.ts +36 -0
- package/src/vite-plugins/icons.ts +2 -2
- package/src/vite-plugins/react-compiler.ts +2 -2
- package/src/vite-plugins/resources.ts +2 -2
- package/src/vite-plugins/settings-worker-env.ts +2 -2
- package/src/vite-plugins/store-links.ts +2 -1
- package/src/vite-plugins/undeclared-library.ts +2 -2
- package/src/vite-plugins/worker.ts +31 -15
- package/src/vitest-plugin.ts +4 -2
|
@@ -2,6 +2,7 @@ import { readFileSync } from "node:fs";
|
|
|
2
2
|
import { parseSync } from "vite";
|
|
3
3
|
import { prependBanner } from "../internal/banner.js";
|
|
4
4
|
import { fontFileName, FONTS_DIR } from "../internal/font-path.js";
|
|
5
|
+
import { stagedFontStatus } from "../internal/font-staging.js";
|
|
5
6
|
import { sourceLanguage } from "../internal/source-imports.js";
|
|
6
7
|
import { xdgDataDirsBanner } from "../internal/xdg-banner.js";
|
|
7
8
|
import { parseFontSpecifier } from "./asset-specifier.js";
|
|
@@ -12,12 +13,19 @@ const VIRTUAL_PREFIX = "\0gtkx-font:";
|
|
|
12
13
|
const { isVirtual, fromVirtualId, resolveToVirtual } = createVirtualNamespace(VIRTUAL_PREFIX);
|
|
13
14
|
const unreadableFontError = (filePath) => `Cannot read a font family name from ${filePath}; ?font expects a TrueType, OpenType, ` +
|
|
14
15
|
"TrueType Collection, WOFF, or WOFF2 font";
|
|
15
|
-
const
|
|
16
|
+
const unstagedFontError = (filePath, importer) => `${filePath} was not staged before the toolkit started, so ${importer} would resolve its family to a ` +
|
|
17
|
+
"fallback font. Fonts are staged from ?font imports found in source files under the project root; move " +
|
|
18
|
+
"the import there, or restart to pick it up.";
|
|
19
|
+
const resolveFontId = async (ctx, state, request) => {
|
|
16
20
|
if (parseFontSpecifier(request.source) === null) {
|
|
17
21
|
return undefined;
|
|
18
22
|
}
|
|
19
23
|
const virtualId = await resolveToVirtual(ctx, request);
|
|
20
|
-
|
|
24
|
+
if (virtualId === undefined) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
state.importers.set(virtualId, request.importer ?? state.root);
|
|
28
|
+
return { id: virtualId, moduleSideEffects: true };
|
|
21
29
|
};
|
|
22
30
|
const emitFont = (ctx, state, filePath, content) => {
|
|
23
31
|
const fileName = `${FONTS_DIR}/${fontFileName(filePath, content)}`;
|
|
@@ -41,6 +49,9 @@ const loadFontModule = (ctx, state, id) => {
|
|
|
41
49
|
if (state.isBuild) {
|
|
42
50
|
emitFont(ctx, state, filePath, content);
|
|
43
51
|
}
|
|
52
|
+
else if (stagedFontStatus(filePath, content) === "absent") {
|
|
53
|
+
return ctx.error(unstagedFontError(filePath, state.importers.get(id) ?? state.root));
|
|
54
|
+
}
|
|
44
55
|
return `export default ${JSON.stringify(family)};`;
|
|
45
56
|
};
|
|
46
57
|
const hasSideEffectFontImport = (code, id) => {
|
|
@@ -59,15 +70,16 @@ const retainSideEffectFontImport = (code, id) => hasSideEffectFontImport(code, i
|
|
|
59
70
|
: null;
|
|
60
71
|
const fontBanner = (state) => (chunk) => state.emitted.size === 0 ? "" : xdgDataDirsBanner(chunk);
|
|
61
72
|
function gtkxFont() {
|
|
62
|
-
const state = { isBuild: false, emitted: new Set() };
|
|
73
|
+
const state = { isBuild: false, root: "", emitted: new Set(), importers: new Map() };
|
|
63
74
|
return {
|
|
64
75
|
name: "gtkx:font",
|
|
65
76
|
enforce: "pre",
|
|
66
77
|
configResolved(config) {
|
|
67
78
|
state.isBuild = config.command === "build";
|
|
79
|
+
state.root = config.root;
|
|
68
80
|
},
|
|
69
81
|
resolveId(source, importer, options) {
|
|
70
|
-
return resolveFontId(this, { source, importer, options });
|
|
82
|
+
return resolveFontId(this, state, { source, importer, options });
|
|
71
83
|
},
|
|
72
84
|
load(id) {
|
|
73
85
|
return loadFontModule(this, state, id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font.js","sourceRoot":"","sources":["../../src/vite-plugins/font.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,C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C;QAED,SAAS,CAAC,IAAI,EAAE,EAAE;YACd,OAAO,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,aAAa,CAAC,OAAO;YACjB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBACjB,OAAO;YACX,CAAC;YAED,OAAO,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QACrD,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { Plugin, Rollup } from \"vite\";\nimport { readFileSync } from \"node:fs\";\nimport { parseSync } from \"vite\";\nimport type { AssetEmitter } from \"./asset-emitter.js\";\nimport { prependBanner } from \"../internal/banner.js\";\nimport { fontFileName, FONTS_DIR } from \"../internal/font-path.js\";\nimport { stagedFontStatus } from \"../internal/font-staging.js\";\nimport { sourceLanguage } from \"../internal/source-imports.js\";\nimport { xdgDataDirsBanner } from \"../internal/xdg-banner.js\";\nimport { parseFontSpecifier } from \"./asset-specifier.js\";\nimport { fontFamilyNames } from \"./font-name.js\";\nimport { stripQuery } from \"./strip-query.js\";\nimport { createVirtualNamespace } from \"./virtual-module.js\";\n\ntype PluginState = {\n isBuild: boolean;\n root: string;\n emitted: Set<string>;\n importers: Map<string, string>;\n};\n\ntype ResolveContext = Parameters<typeof resolveToVirtual>[0];\ntype ResolveRequest = Parameters<typeof resolveToVirtual>[1];\n\ntype RetainedFontModuleId = {\n id: string;\n moduleSideEffects: true;\n};\n\ntype LoadContext = AssetEmitter & {\n addWatchFile: (file: string) => void;\n error: (message: string) => never;\n};\n\nconst VIRTUAL_PREFIX = \"\\0gtkx-font:\";\nconst { isVirtual, fromVirtualId, resolveToVirtual } = createVirtualNamespace(VIRTUAL_PREFIX);\n\nconst unreadableFontError = (filePath: string): string =>\n `Cannot read a font family name from ${filePath}; ?font expects a TrueType, OpenType, ` +\n \"TrueType Collection, WOFF, or WOFF2 font\";\n\nconst unstagedFontError = (filePath: string, importer: string): string =>\n `${filePath} was not staged before the toolkit started, so ${importer} would resolve its family to a ` +\n \"fallback font. Fonts are staged from ?font imports found in source files under the project root; move \" +\n \"the import there, or restart to pick it up.\";\n\nconst resolveFontId = async (\n ctx: ResolveContext,\n state: PluginState,\n request: ResolveRequest,\n): Promise<RetainedFontModuleId | undefined> => {\n if (parseFontSpecifier(request.source) === null) {\n return undefined;\n }\n\n const virtualId = await resolveToVirtual(ctx, request);\n\n if (virtualId === undefined) {\n return undefined;\n }\n\n state.importers.set(virtualId, request.importer ?? state.root);\n\n return { id: virtualId, moduleSideEffects: true };\n};\n\nconst emitFont = (ctx: LoadContext, state: PluginState, filePath: string, content: Buffer): void => {\n const fileName = `${FONTS_DIR}/${fontFileName(filePath, content)}`;\n\n if (state.emitted.has(fileName)) {\n return;\n }\n\n state.emitted.add(fileName);\n ctx.emitFile({ type: \"asset\", fileName, source: content });\n};\n\nconst loadFontModule = (ctx: LoadContext, state: PluginState, id: string): string | undefined => {\n if (!isVirtual(id)) {\n return undefined;\n }\n\n const filePath = stripQuery(fromVirtualId(id));\n const content = readFileSync(filePath);\n const [family] = fontFamilyNames(content);\n\n if (family === undefined) {\n return ctx.error(unreadableFontError(filePath));\n }\n\n ctx.addWatchFile(filePath);\n\n if (state.isBuild) {\n emitFont(ctx, state, filePath, content);\n } else if (stagedFontStatus(filePath, content) === \"absent\") {\n return ctx.error(unstagedFontError(filePath, state.importers.get(id) ?? state.root));\n }\n\n return `export default ${JSON.stringify(family)};`;\n};\n\nconst hasSideEffectFontImport = (code: string, id: string): boolean => {\n const lang = sourceLanguage(stripQuery(id));\n\n if (lang === undefined || !code.includes(\"?font\")) {\n return false;\n }\n\n const parsed = parseSync(id, code, { lang });\n\n if (parsed.errors.length > 0) {\n return false;\n }\n\n return parsed.module.staticImports.some(\n (statement) => statement.entries.length === 0 && parseFontSpecifier(statement.moduleRequest.value) !== null,\n );\n};\n\nconst retainSideEffectFontImport = (\n code: string,\n id: string,\n): { code: string; moduleSideEffects: true } | null =>\n hasSideEffectFontImport(code, id)\n ? { code, moduleSideEffects: true }\n : null;\n\nconst fontBanner = (state: PluginState) => (chunk: Rollup.RenderedChunk): string =>\n state.emitted.size === 0 ? \"\" : xdgDataDirsBanner(chunk);\n\nfunction gtkxFont(): Plugin {\n const state: PluginState = { isBuild: false, root: \"\", emitted: new Set(), importers: new Map() };\n\n return {\n name: \"gtkx:font\",\n enforce: \"pre\",\n\n configResolved(config) {\n state.isBuild = config.command === \"build\";\n state.root = config.root;\n },\n\n resolveId(source, importer, options) {\n return resolveFontId(this, state, { source, importer, options });\n },\n\n load(id) {\n return loadFontModule(this, state, id);\n },\n\n transform(code, id) {\n return retainSideEffectFontImport(code, id);\n },\n\n outputOptions(options) {\n if (!state.isBuild) {\n return;\n }\n\n return prependBanner(options, fontBanner(state));\n },\n };\n}\n\nexport { gtkxFont };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-worker-env.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/icon-worker-env.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,iBAAS,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CA2BtD;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
|
|
2
|
+
import { stageProjectIcons } from "../internal/icon-staging.js";
|
|
3
|
+
import { prependXdgDataDir } from "../internal/xdg-data-dirs.js";
|
|
4
|
+
function gtkxIconWorkerEnv(configFile) {
|
|
5
|
+
const loadConfig = createConfigLoader({ configFile });
|
|
6
|
+
return {
|
|
7
|
+
name: "gtkx:icon-worker-env",
|
|
8
|
+
enforce: "pre",
|
|
9
|
+
async config(config) {
|
|
10
|
+
const loaded = await loadConfig.load(viteProjectRoot(config));
|
|
11
|
+
const shareDir = stageProjectIcons(loaded.root, loaded.config.applicationId, loaded.config.applicationIcon);
|
|
12
|
+
if (shareDir === null) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const existing = config.test?.env?.XDG_DATA_DIRS ?? process.env.XDG_DATA_DIRS;
|
|
16
|
+
return {
|
|
17
|
+
test: { env: { XDG_DATA_DIRS: prependXdgDataDir(shareDir, existing) } },
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export { gtkxIconWorkerEnv };
|
|
23
|
+
//# sourceMappingURL=icon-worker-env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-worker-env.js","sourceRoot":"","sources":["../../src/vite-plugins/icon-worker-env.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,SAAS,iBAAiB,CAAC,UAAmB;IAC1C,MAAM,UAAU,GAAG,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAEtD,OAAO;QACH,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE,KAAK;QAEd,KAAK,CAAC,MAAM,CAAC,MAAkB;YAC3B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;YAE9D,MAAM,QAAQ,GAAG,iBAAiB,CAC9B,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,MAAM,CAAC,aAAa,EAC3B,MAAM,CAAC,MAAM,CAAC,eAAe,CAChC,CAAC;YAEF,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACpB,OAAO;YACX,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;YAE9E,OAAO;gBACH,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,aAAa,EAAE,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE;aAC1E,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { UserConfig } from \"vite\";\nimport type { Plugin } from \"vitest/config\";\nimport { createConfigLoader, viteProjectRoot } from \"@gtkx/config/internal\";\nimport { stageProjectIcons } from \"../internal/icon-staging.js\";\nimport { prependXdgDataDir } from \"../internal/xdg-data-dirs.js\";\n\nfunction gtkxIconWorkerEnv(configFile?: string): Plugin {\n const loadConfig = createConfigLoader({ configFile });\n\n return {\n name: \"gtkx:icon-worker-env\",\n enforce: \"pre\",\n\n async config(config: UserConfig) {\n const loaded = await loadConfig.load(viteProjectRoot(config));\n\n const shareDir = stageProjectIcons(\n loaded.root,\n loaded.config.applicationId,\n loaded.config.applicationIcon,\n );\n\n if (shareDir === null) {\n return;\n }\n\n const existing = config.test?.env?.XDG_DATA_DIRS ?? process.env.XDG_DATA_DIRS;\n\n return {\n test: { env: { XDG_DATA_DIRS: prependXdgDataDir(shareDir, existing) } },\n };\n },\n };\n}\n\nexport { gtkxIconWorkerEnv };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createConfigLoader } from "@gtkx/config/internal";
|
|
1
|
+
import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
|
|
2
2
|
import { info } from "@gtkx/utils";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
@@ -20,7 +20,7 @@ const findIconFiles = (state) => {
|
|
|
20
20
|
}];
|
|
21
21
|
};
|
|
22
22
|
const applyUserConfig = async (state, config, loadConfig) => {
|
|
23
|
-
const { config: gtkxConfig, root } = await loadConfig.load(config
|
|
23
|
+
const { config: gtkxConfig, root } = await loadConfig.load(viteProjectRoot(config));
|
|
24
24
|
state.applicationId = gtkxConfig.applicationId;
|
|
25
25
|
state.source = resolveApplicationIcon(root, gtkxConfig.applicationId, gtkxConfig.applicationIcon);
|
|
26
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/vite-plugins/icons.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/vite-plugins/icons.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACH,gBAAgB,EAChB,sBAAsB,GAEzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAmB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAO9D,MAAM,SAAS,GAAG,OAAO,CAAC;AAE1B,MAAM,aAAa,GAAG,CAAC,KAAkB,EAAgB,EAAE;IACvD,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAO,CAAC;YACJ,OAAO,EAAE,KAAK,C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;QAClB,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,OAAO;QAEd,KAAK,CAAC,MAAM,CAAC,MAAkB;YAC3B,MAAM,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACrD,CAAC;QAED,aAAa,CAAC,OAAO;YACjB,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpC,OAAO;YACX,CAAC;YAED,OAAO,aAAa,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACrD,CAAC;QAED,QAAQ;YACJ,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1C,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { ConfigLoader } from \"@gtkx/config\";\nimport type { Plugin, UserConfig } from \"vite\";\nimport { createConfigLoader, viteProjectRoot } from \"@gtkx/config/internal\";\nimport { info } from \"@gtkx/utils\";\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AssetEmitter } from \"./asset-emitter.js\";\nimport { prependBanner } from \"../internal/banner.js\";\nimport {\n relativeIconPath,\n resolveApplicationIcon,\n type ResolvedApplicationIcon,\n} from \"../internal/icon-path.js\";\nimport { type ListedFile, listFilesRecursive } from \"../internal/list-files.js\";\nimport { xdgDataDirsBanner } from \"../internal/xdg-banner.js\";\n\ntype PluginState = {\n applicationId: string;\n source: ResolvedApplicationIcon;\n};\n\nconst ICONS_DIR = \"icons\";\n\nconst findIconFiles = (state: PluginState): ListedFile[] => {\n if (state.source.kind === \"theme\") {\n return listFilesRecursive(state.source.path);\n }\n\n if (state.source.kind === \"none\") {\n return [];\n }\n\n return [{\n absPath: state.source.path,\n rel: relativeIconPath(state.applicationId, state.source.path),\n }];\n};\n\nconst applyUserConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader): Promise<void> => {\n const { config: gtkxConfig, root } = await loadConfig.load(viteProjectRoot(config));\n state.applicationId = gtkxConfig.applicationId;\n state.source = resolveApplicationIcon(root, gtkxConfig.applicationId, gtkxConfig.applicationIcon);\n};\n\nconst emitIcons = (ctx: AssetEmitter, icons: ListedFile[]): void => {\n for (const { absPath, rel } of icons) {\n ctx.emitFile({ type: \"asset\", fileName: join(ICONS_DIR, rel), source: readFileSync(absPath) });\n }\n\n if (icons.length > 0) {\n info(`Copied ${String(icons.length)} icon(s) into ${ICONS_DIR}/`);\n }\n};\n\nfunction gtkxIcons(loadConfig: ConfigLoader = createConfigLoader()): Plugin {\n const state: PluginState = {\n applicationId: \"\",\n source: { kind: \"none\" },\n };\n\n return {\n name: \"gtkx:icons\",\n enforce: \"pre\",\n apply: \"build\",\n\n async config(config: UserConfig) {\n await applyUserConfig(state, config, loadConfig);\n },\n\n outputOptions(options) {\n if (findIconFiles(state).length === 0) {\n return;\n }\n\n return prependBanner(options, xdgDataDirsBanner);\n },\n\n buildEnd() {\n emitIcons(this, findIconFiles(state));\n },\n };\n}\n\nexport { gtkxIcons };\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { transformAsync } from "@babel/core";
|
|
2
2
|
import babelPresetTypescriptNs from "@babel/preset-typescript";
|
|
3
|
-
import { createConfigLoader } from "@gtkx/config/internal";
|
|
3
|
+
import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
|
|
4
4
|
import babelPluginReactCompilerNs from "babel-plugin-react-compiler";
|
|
5
5
|
const babelPresetTypescript = babelPresetTypescriptNs.default ?? babelPresetTypescriptNs;
|
|
6
6
|
const babelPluginReactCompiler = babelPluginReactCompilerNs.default ?? babelPluginReactCompilerNs;
|
|
@@ -43,7 +43,7 @@ function gtkxReactCompiler(loadConfig = createConfigLoader()) {
|
|
|
43
43
|
name: "gtkx:react-compiler",
|
|
44
44
|
enforce: "pre",
|
|
45
45
|
async config(config) {
|
|
46
|
-
const resolved = await loadConfig.resolve(config
|
|
46
|
+
const resolved = await loadConfig.resolve(viteProjectRoot(config));
|
|
47
47
|
state.options = resolved.reactCompiler;
|
|
48
48
|
},
|
|
49
49
|
configResolved(config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-compiler.js","sourceRoot":"","sources":["../../src/vite-plugins/react-compiler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,uBAAuB,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"react-compiler.js","sourceRoot":"","sources":["../../src/vite-plugins/react-compiler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,uBAAuB,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,0BAA0B,MAAM,6BAA6B,CAAC;AAOrE,MAAM,qBAAqB,GAAG,uBAAuB,CAAC,OAAO,IAAI,uBAAuB,CAAC;AACzF,MAAM,wBAAwB,GAAG,0BAA0B,CAAC,OAAO,IAAI,0BAA0B,CAAC;AAClG,MAAM,gBAAgB,GAAG,YAAY,CAAC;AACtC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAE9C,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAU,EAAW,EAAE;IAC1D,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG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,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;YACnE,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC;QAC3C,CAAC;QAED,cAAc,CAAC,MAAsB;YACjC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QAC7B,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE;YACpB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YAE9B,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;gBACvD,OAAO;YACX,CAAC;YAED,OAAO,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { ConfigLoader } from \"@gtkx/config\";\nimport type { ResolvedReactCompilerOptions } from \"@gtkx/config/internal\";\nimport type { Plugin, ResolvedConfig, UserConfig } from \"vite\";\nimport { transformAsync } from \"@babel/core\";\nimport babelPresetTypescriptNs from \"@babel/preset-typescript\";\nimport { createConfigLoader, viteProjectRoot } from \"@gtkx/config/internal\";\nimport babelPluginReactCompilerNs from \"babel-plugin-react-compiler\";\n\ntype ReactCompilerState = {\n root: string;\n options: ResolvedReactCompilerOptions | null;\n};\n\nconst babelPresetTypescript = babelPresetTypescriptNs.default ?? babelPresetTypescriptNs;\nconst babelPluginReactCompiler = babelPluginReactCompilerNs.default ?? babelPluginReactCompilerNs;\nconst SOURCE_EXTENSION = /\\.[jt]sx?$/;\nconst TYPESCRIPT_EXTENSION = /\\.tsx?$/;\nconst NODE_MODULES = /(?:^|\\/)node_modules\\//;\n\nconst isProjectSource = (root: string, id: string): boolean => {\n if (!SOURCE_EXTENSION.test(id)) {\n return false;\n }\n\n if (NODE_MODULES.test(id)) {\n return false;\n }\n\n if (root !== \"\" && !id.startsWith(`${root}/`)) {\n return false;\n }\n\n return true;\n};\n\nconst compileSource = async (code: string, id: string, options: ResolvedReactCompilerOptions) => {\n const result = await transformAsync(code, {\n filename: id,\n babelrc: false,\n configFile: false,\n sourceMaps: true,\n parserOpts: { plugins: id.endsWith(\".ts\") ? [] : [\"jsx\"] },\n presets: TYPESCRIPT_EXTENSION.test(id) ? [babelPresetTypescript] : [],\n plugins: [[babelPluginReactCompiler, options]],\n });\n\n if (!result?.code) {\n return;\n }\n\n return result.map == null ? { code: result.code } : { code: result.code, map: JSON.stringify(result.map) };\n};\n\nfunction gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plugin {\n const state: ReactCompilerState = {\n root: \"\",\n options: null,\n };\n\n return {\n name: \"gtkx:react-compiler\",\n enforce: \"pre\",\n\n async config(config: UserConfig) {\n const resolved = await loadConfig.resolve(viteProjectRoot(config));\n state.options = resolved.reactCompiler;\n },\n\n configResolved(config: ResolvedConfig) {\n state.root = config.root;\n },\n\n async transform(code, id) {\n const options = state.options;\n\n if (options === null || !isProjectSource(state.root, id)) {\n return;\n }\n\n return compileSource(code, id, options);\n },\n };\n}\n\nexport { gtkxReactCompiler };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createConfigLoader, resourceBasePath } from "@gtkx/config/internal";
|
|
1
|
+
import { createConfigLoader, resourceBasePath, viteProjectRoot } from "@gtkx/config/internal";
|
|
2
2
|
import { error, info, isPathInside, isRecord, sortStrings, toPosixPath } from "@gtkx/utils";
|
|
3
3
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { basename, dirname, extname, isAbsolute, join, posix, relative, sep } from "node:path";
|
|
@@ -781,7 +781,7 @@ const reconcileImporter = async (ctx, state, id) => {
|
|
|
781
781
|
}
|
|
782
782
|
};
|
|
783
783
|
const resolveResourceConfig = async (state, config, loadConfig) => {
|
|
784
|
-
const loaded = await loadConfig.load(config
|
|
784
|
+
const loaded = await loadConfig.load(viteProjectRoot(config));
|
|
785
785
|
state.prefix = resourceBasePath(loaded.config.applicationId);
|
|
786
786
|
state.root = loaded.root;
|
|
787
787
|
return {
|