@gtkx/cli 2.0.0-beta.6 → 2.0.0-beta.8
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 +43 -40
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/codegen/freshness.d.ts.map +1 -1
- package/dist/codegen/freshness.js +5 -1
- package/dist/codegen/freshness.js.map +1 -1
- 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/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/index.d.ts.map +1 -1
- package/dist/deploy/node-runtime/index.js +14 -2
- package/dist/deploy/node-runtime/index.js.map +1 -1
- 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 +135 -79
- 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/libraries.d.ts.map +1 -1
- package/dist/deploy/settings/libraries.js +2 -1
- package/dist/deploy/settings/libraries.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-source.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak-source.js +2 -0
- package/dist/deploy/targets/flatpak-source.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 +3 -0
- package/dist/dev/font-dir.d.ts.map +1 -0
- package/dist/dev/font-dir.js +9 -0
- package/dist/dev/font-dir.js.map +1 -0
- package/dist/dev/runner-main.d.ts.map +1 -1
- package/dist/dev/runner-main.js +2 -0
- package/dist/dev/runner-main.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/agent-rules.d.ts.map +1 -1
- package/dist/internal/agent-rules.js +6 -2
- package/dist/internal/agent-rules.js.map +1 -1
- package/dist/internal/banner.d.ts.map +1 -1
- package/dist/internal/banner.js +3 -0
- package/dist/internal/banner.js.map +1 -1
- package/dist/internal/font-path.d.ts +4 -0
- package/dist/internal/font-path.d.ts.map +1 -0
- package/dist/internal/font-path.js +12 -0
- package/dist/internal/font-path.js.map +1 -0
- package/dist/internal/font-staging.d.ts +6 -0
- package/dist/internal/font-staging.d.ts.map +1 -0
- package/dist/internal/font-staging.js +92 -0
- package/dist/internal/font-staging.js.map +1 -0
- package/dist/internal/source-imports.d.ts +2 -1
- package/dist/internal/source-imports.d.ts.map +1 -1
- package/dist/internal/source-imports.js +8 -3
- package/dist/internal/source-imports.js.map +1 -1
- package/dist/internal/xdg-banner.d.ts +4 -0
- package/dist/internal/xdg-banner.d.ts.map +1 -0
- package/dist/internal/xdg-banner.js +11 -0
- package/dist/internal/xdg-banner.js.map +1 -0
- package/dist/internal/xdg-data-dirs.d.ts +2 -1
- package/dist/internal/xdg-data-dirs.d.ts.map +1 -1
- package/dist/internal/xdg-data-dirs.js +1 -1
- package/dist/internal/xdg-data-dirs.js.map +1 -1
- package/dist/settings/schema.d.ts.map +1 -1
- package/dist/settings/schema.js +1 -6
- package/dist/settings/schema.js.map +1 -1
- package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
- package/dist/vite-plugins/asset-extensions.js +2 -0
- package/dist/vite-plugins/asset-extensions.js.map +1 -1
- package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
- package/dist/vite-plugins/asset-imports.js +7 -2
- package/dist/vite-plugins/asset-imports.js.map +1 -1
- package/dist/vite-plugins/asset-specifier.d.ts +5 -1
- package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
- package/dist/vite-plugins/asset-specifier.js +10 -1
- package/dist/vite-plugins/asset-specifier.js.map +1 -1
- package/dist/vite-plugins/css.d.ts.map +1 -1
- package/dist/vite-plugins/css.js +3 -2
- package/dist/vite-plugins/css.js.map +1 -1
- package/dist/vite-plugins/font-name.d.ts +3 -0
- package/dist/vite-plugins/font-name.d.ts.map +1 -0
- package/dist/vite-plugins/font-name.js +406 -0
- package/dist/vite-plugins/font-name.js.map +1 -0
- package/dist/vite-plugins/font-worker-env.d.ts +4 -0
- package/dist/vite-plugins/font-worker-env.d.ts.map +1 -0
- package/dist/vite-plugins/font-worker-env.js +19 -0
- package/dist/vite-plugins/font-worker-env.js.map +1 -0
- package/dist/vite-plugins/font.d.ts +4 -0
- package/dist/vite-plugins/font.d.ts.map +1 -0
- package/dist/vite-plugins/font.js +99 -0
- package/dist/vite-plugins/font.js.map +1 -0
- package/dist/vite-plugins/icons.d.ts.map +1 -1
- package/dist/vite-plugins/icons.js +5 -10
- package/dist/vite-plugins/icons.js.map +1 -1
- package/dist/vite-plugins/index.d.ts.map +1 -1
- package/dist/vite-plugins/index.js +2 -0
- package/dist/vite-plugins/index.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 +3 -3
- 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 +5 -5
- package/dist/vite-plugins/undeclared-library.js.map +1 -1
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +2 -0
- package/dist/vitest-plugin.js.map +1 -1
- package/env.d.ts +9 -0
- package/package.json +17 -15
- package/src/cli.ts +1 -1
- package/src/codegen/freshness.ts +5 -1
- package/src/commands/deploy.ts +6 -0
- 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/index.ts +24 -4
- package/src/deploy/payload/stage.ts +34 -2
- package/src/deploy/run-deploy.ts +203 -93
- package/src/deploy/settings/arch.ts +40 -8
- package/src/deploy/settings/index.ts +4 -1
- package/src/deploy/settings/libraries.ts +2 -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-source.ts +2 -0
- 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 +11 -0
- package/src/dev/runner-main.ts +2 -0
- package/src/dev/runner.ts +24 -6
- package/src/internal/agent-rules.ts +6 -2
- package/src/internal/banner.ts +4 -0
- package/src/internal/font-path.ts +15 -0
- package/src/internal/font-staging.ts +129 -0
- package/src/internal/source-imports.ts +18 -3
- package/src/internal/xdg-banner.ts +13 -0
- package/src/internal/xdg-data-dirs.ts +1 -1
- package/src/settings/schema.ts +1 -8
- package/src/vite-plugins/asset-extensions.ts +2 -0
- package/src/vite-plugins/asset-imports.ts +9 -1
- package/src/vite-plugins/asset-specifier.ts +17 -0
- package/src/vite-plugins/css.ts +4 -2
- package/src/vite-plugins/font-name.ts +582 -0
- package/src/vite-plugins/font-worker-env.ts +25 -0
- package/src/vite-plugins/font.ts +165 -0
- package/src/vite-plugins/icons.ts +6 -12
- package/src/vite-plugins/index.ts +2 -0
- package/src/vite-plugins/react-compiler.ts +2 -2
- package/src/vite-plugins/resources.ts +3 -3
- 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 +5 -5
- package/src/vitest-plugin.ts +2 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { sortStrings } from "@gtkx/utils";
|
|
2
|
+
import { lstatSync, mkdirSync, readFileSync, symlinkSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
5
|
+
import { parseFontSpecifier } from "../vite-plugins/asset-specifier.js";
|
|
6
|
+
import { fontFileName, FONTS_DIR } from "./font-path.js";
|
|
7
|
+
import { discoverSourceImports, sourceLanguage } from "./source-imports.js";
|
|
8
|
+
import { createRetainedStagingDir } from "./staging-dir.js";
|
|
9
|
+
const FONT_DIR_ENV = "GTKX_DEV_FONT_DIR";
|
|
10
|
+
const FONT_QUERY = "?font";
|
|
11
|
+
const fontStaging = createRetainedStagingDir("fonts");
|
|
12
|
+
const isRelativeImport = (source) => source.startsWith("./") || source.startsWith("../");
|
|
13
|
+
const existingPath = (path) => lstatSync(path, { throwIfNoEntry: false }) === undefined ? null : path;
|
|
14
|
+
const resolveRelativeImport = (importer, assetSource) => existingPath(resolve(dirname(importer), assetSource));
|
|
15
|
+
const resolveAbsoluteImport = (root, assetSource) => existingPath(assetSource) ?? existingPath(join(root, assetSource));
|
|
16
|
+
const resolvePackageImport = (importer, assetSource) => {
|
|
17
|
+
try {
|
|
18
|
+
return createRequire(importer).resolve(assetSource);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const resolveFontImport = (root, importer, assetSource) => {
|
|
25
|
+
if (isRelativeImport(assetSource)) {
|
|
26
|
+
return resolveRelativeImport(importer, assetSource);
|
|
27
|
+
}
|
|
28
|
+
if (isAbsolute(assetSource)) {
|
|
29
|
+
return resolveAbsoluteImport(root, assetSource);
|
|
30
|
+
}
|
|
31
|
+
return resolvePackageImport(importer, assetSource);
|
|
32
|
+
};
|
|
33
|
+
const fontFileFor = (root, { importer, source }) => {
|
|
34
|
+
const specifier = parseFontSpecifier(source);
|
|
35
|
+
return specifier === null ? null : resolveFontImport(root, importer, specifier.assetSource);
|
|
36
|
+
};
|
|
37
|
+
const projectFontFiles = (root) => {
|
|
38
|
+
const files = discoverSourceImports(root)
|
|
39
|
+
.map((entry) => fontFileFor(root, entry))
|
|
40
|
+
.filter((path) => path !== null);
|
|
41
|
+
return sortStrings(new Set(files));
|
|
42
|
+
};
|
|
43
|
+
const stagedPath = (fontsDir, sourcePath, content) => join(fontsDir, fontFileName(sourcePath, content));
|
|
44
|
+
const stageFont = (fontsDir, sourcePath) => {
|
|
45
|
+
const target = stagedPath(fontsDir, sourcePath, readFileSync(sourcePath));
|
|
46
|
+
if (existingPath(target) !== null) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
symlinkSync(sourcePath, target, "file");
|
|
50
|
+
};
|
|
51
|
+
const stagedFontsDir = () => {
|
|
52
|
+
const shareDir = process.env[FONT_DIR_ENV];
|
|
53
|
+
return shareDir === undefined || shareDir.length === 0 ? null : join(shareDir, FONTS_DIR);
|
|
54
|
+
};
|
|
55
|
+
const stagedFontStatus = (sourcePath, content) => {
|
|
56
|
+
const fontsDir = stagedFontsDir();
|
|
57
|
+
if (fontsDir === null) {
|
|
58
|
+
return "unmanaged";
|
|
59
|
+
}
|
|
60
|
+
return existingPath(stagedPath(fontsDir, sourcePath, content)) === null ? "absent" : "staged";
|
|
61
|
+
};
|
|
62
|
+
const hasFontImportMention = (filePath) => {
|
|
63
|
+
if (sourceLanguage(filePath) === undefined) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
return readFileSync(filePath, "utf8").includes(FONT_QUERY);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const isUnstagedFont = (fontsDir, sourcePath) => existingPath(stagedPath(fontsDir, sourcePath, readFileSync(sourcePath))) === null;
|
|
74
|
+
const hasUnstagedFontImport = (root, filePath) => {
|
|
75
|
+
const fontsDir = stagedFontsDir();
|
|
76
|
+
if (fontsDir === null || !hasFontImportMention(filePath)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return projectFontFiles(root).some((sourcePath) => isUnstagedFont(fontsDir, sourcePath));
|
|
80
|
+
};
|
|
81
|
+
const stageProjectFonts = (root) => {
|
|
82
|
+
const shareDir = fontStaging.retain();
|
|
83
|
+
const fontsDir = join(shareDir, FONTS_DIR);
|
|
84
|
+
mkdirSync(fontsDir, { recursive: true });
|
|
85
|
+
for (const sourcePath of projectFontFiles(root)) {
|
|
86
|
+
stageFont(fontsDir, sourcePath);
|
|
87
|
+
}
|
|
88
|
+
process.env[FONT_DIR_ENV] = shareDir;
|
|
89
|
+
return shareDir;
|
|
90
|
+
};
|
|
91
|
+
export { hasUnstagedFontImport, stagedFontStatus, stageProjectFonts };
|
|
92
|
+
//# sourceMappingURL=font-staging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-staging.js","sourceRoot":"","sources":["../../src/internal/font-staging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAqB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,wBAAwB,EAAE,MAAM,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C;AAEtF,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAW,EAAE;IACtE,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;IAElC,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAC7F,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAU,EAAE;IAC/C,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC3C,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzC,KAAK,MAAM,UAAU,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC;IAErC,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { sortStrings } from \"@gtkx/utils\";\nimport { lstatSync, mkdirSync, readFileSync, symlinkSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { parseFontSpecifier } from \"../vite-plugins/asset-specifier.js\";\nimport { fontFileName, FONTS_DIR } from \"./font-path.js\";\nimport { discoverSourceImports, type SourceImport, sourceLanguage } from \"./source-imports.js\";\nimport { createRetainedStagingDir } from \"./staging-dir.js\";\n\ntype FontStagingStatus = \"absent\" | \"staged\" | \"unmanaged\";\n\nconst FONT_DIR_ENV = \"GTKX_DEV_FONT_DIR\";\nconst FONT_QUERY = \"?font\";\nconst fontStaging = createRetainedStagingDir(\"fonts\");\n\nconst isRelativeImport = (source: string): boolean => source.startsWith(\"./\") || source.startsWith(\"../\");\n\nconst existingPath = (path: string): string | null =>\n lstatSync(path, { throwIfNoEntry: false }) === undefined ? null : path;\n\nconst resolveRelativeImport = (importer: string, assetSource: string): string | null =>\n existingPath(resolve(dirname(importer), assetSource));\n\nconst resolveAbsoluteImport = (root: string, assetSource: string): string | null =>\n existingPath(assetSource) ?? existingPath(join(root, assetSource));\n\nconst resolvePackageImport = (importer: string, assetSource: string): string | null => {\n try {\n return createRequire(importer).resolve(assetSource);\n } catch {\n return null;\n }\n};\n\nconst resolveFontImport = (root: string, importer: string, assetSource: string): string | null => {\n if (isRelativeImport(assetSource)) {\n return resolveRelativeImport(importer, assetSource);\n }\n\n if (isAbsolute(assetSource)) {\n return resolveAbsoluteImport(root, assetSource);\n }\n\n return resolvePackageImport(importer, assetSource);\n};\n\nconst fontFileFor = (root: string, { importer, source }: SourceImport): string | null => {\n const specifier = parseFontSpecifier(source);\n\n return specifier === null ? null : resolveFontImport(root, importer, specifier.assetSource);\n};\n\nconst projectFontFiles = (root: string): string[] => {\n const files = discoverSourceImports(root)\n .map((entry) => fontFileFor(root, entry))\n .filter((path): path is string => path !== null);\n\n return sortStrings(new Set(files));\n};\n\nconst stagedPath = (fontsDir: string, sourcePath: string, content: Buffer): string =>\n join(fontsDir, fontFileName(sourcePath, content));\n\nconst stageFont = (fontsDir: string, sourcePath: string): void => {\n const target = stagedPath(fontsDir, sourcePath, readFileSync(sourcePath));\n\n if (existingPath(target) !== null) {\n return;\n }\n\n symlinkSync(sourcePath, target, \"file\");\n};\n\nconst stagedFontsDir = (): string | null => {\n const shareDir = process.env[FONT_DIR_ENV];\n\n return shareDir === undefined || shareDir.length === 0 ? null : join(shareDir, FONTS_DIR);\n};\n\nconst stagedFontStatus = (sourcePath: string, content: Buffer): FontStagingStatus => {\n const fontsDir = stagedFontsDir();\n\n if (fontsDir === null) {\n return \"unmanaged\";\n }\n\n return existingPath(stagedPath(fontsDir, sourcePath, content)) === null ? \"absent\" : \"staged\";\n};\n\nconst hasFontImportMention = (filePath: string): boolean => {\n if (sourceLanguage(filePath) === undefined) {\n return false;\n }\n\n try {\n return readFileSync(filePath, \"utf8\").includes(FONT_QUERY);\n } catch {\n return false;\n }\n};\n\nconst isUnstagedFont = (fontsDir: string, sourcePath: string): boolean =>\n existingPath(stagedPath(fontsDir, sourcePath, readFileSync(sourcePath))) === null;\n\nconst hasUnstagedFontImport = (root: string, filePath: string): boolean => {\n const fontsDir = stagedFontsDir();\n\n if (fontsDir === null || !hasFontImportMention(filePath)) {\n return false;\n }\n\n return projectFontFiles(root).some((sourcePath) => isUnstagedFont(fontsDir, sourcePath));\n};\n\nconst stageProjectFonts = (root: string): string => {\n const shareDir = fontStaging.retain();\n const fontsDir = join(shareDir, FONTS_DIR);\n mkdirSync(fontsDir, { recursive: true });\n\n for (const sourcePath of projectFontFiles(root)) {\n stageFont(fontsDir, sourcePath);\n }\n\n process.env[FONT_DIR_ENV] = shareDir;\n\n return shareDir;\n};\n\nexport { hasUnstagedFontImport, stagedFontStatus, stageProjectFonts };\n"]}
|
|
@@ -5,8 +5,9 @@ type SourceImport = {
|
|
|
5
5
|
};
|
|
6
6
|
type SourceLanguage = NonNullable<ParserOptions["lang"]>;
|
|
7
7
|
declare const sourceLanguage: (path: string) => SourceLanguage | undefined;
|
|
8
|
+
declare const sourceDirFor: (root: string) => string;
|
|
8
9
|
declare const discoverSourceFiles: (dir: string) => string[];
|
|
9
10
|
declare const parseRuntimeImportsIn: (path: string) => SourceImport[] | null;
|
|
10
11
|
declare const discoverSourceImports: (dir: string) => SourceImport[];
|
|
11
|
-
export { discoverSourceFiles, discoverSourceImports, parseRuntimeImportsIn, type SourceImport,
|
|
12
|
+
export { discoverSourceFiles, discoverSourceImports, parseRuntimeImportsIn, sourceDirFor, sourceLanguage, type SourceImport, };
|
|
12
13
|
//# sourceMappingURL=source-imports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-imports.d.ts","sourceRoot":"","sources":["../../src/internal/source-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,aAAa,EAAE,MAAM,MAAM,CAAC;AAM/D,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,cAAc,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;AAYzD,QAAA,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,cAAc,GAAG,SAMvD,CAAC;AAEF,QAAA,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,MAAM,EAW5C,CAAC;AA+EN,QAAA,MAAM,qBAAqB,GAAI,MAAM,MAAM,KAAG,YAAY,EAAE,GAAG,IACP,CAAC;AAKzD,QAAA,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,YAAY,EAKxD,CAAC;AAEF,OAAO,
|
|
1
|
+
{"version":3,"file":"source-imports.d.ts","sourceRoot":"","sources":["../../src/internal/source-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,aAAa,EAAE,MAAM,MAAM,CAAC;AAM/D,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,cAAc,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;AAYzD,QAAA,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,cAAc,GAAG,SAMvD,CAAC;AAIF,QAAA,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,MAIpC,CAAC;AAEF,QAAA,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,MAAM,EAW5C,CAAC;AA+EN,QAAA,MAAM,qBAAqB,GAAI,MAAM,MAAM,KAAG,YAAY,EAAE,GAAG,IACP,CAAC;AAKzD,QAAA,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,YAAY,EAKxD,CAAC;AAEF,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,KAAK,YAAY,GACpB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sortStringsBy } from "@gtkx/utils";
|
|
2
|
-
import { globSync, readFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, globSync, readFileSync } from "node:fs";
|
|
3
3
|
import { extname, join } from "node:path";
|
|
4
4
|
import { parseSync, Visitor } from "vite";
|
|
5
5
|
const SOURCE_LANGUAGES = new Map([
|
|
@@ -16,9 +16,14 @@ const sourceLanguage = (path) => {
|
|
|
16
16
|
}
|
|
17
17
|
return SOURCE_LANGUAGES.get(extname(path).toLowerCase());
|
|
18
18
|
};
|
|
19
|
+
const SOURCE_DIR = "src";
|
|
20
|
+
const sourceDirFor = (root) => {
|
|
21
|
+
const sourceDir = join(root, SOURCE_DIR);
|
|
22
|
+
return existsSync(sourceDir) ? sourceDir : root;
|
|
23
|
+
};
|
|
19
24
|
const discoverSourceFiles = (dir) => sortStringsBy(globSync("**/{*,.*}", {
|
|
20
25
|
cwd: dir,
|
|
21
|
-
exclude: ["**/{build,coverage,dist,node_modules,out-tsc}/**", "**/.gtkx-output-*/**"],
|
|
26
|
+
exclude: ["**/{build,coverage,dist,node_modules,out-tsc}/**", "**/.gtkx-output-*/**", "**/.git/**"],
|
|
22
27
|
withFileTypes: true,
|
|
23
28
|
})
|
|
24
29
|
.filter((entry) => entry.isFile())
|
|
@@ -87,5 +92,5 @@ const discoverSourceImports = (dir) => {
|
|
|
87
92
|
const imports = files.flatMap((path) => importsIn(path));
|
|
88
93
|
return sortStringsBy(imports, importKey);
|
|
89
94
|
};
|
|
90
|
-
export { discoverSourceFiles, discoverSourceImports, parseRuntimeImportsIn, sourceLanguage };
|
|
95
|
+
export { discoverSourceFiles, discoverSourceImports, parseRuntimeImportsIn, sourceDirFor, sourceLanguage, };
|
|
91
96
|
//# sourceMappingURL=source-imports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-imports.js","sourceRoot":"","sources":["../../src/internal/source-imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"source-imports.js","sourceRoot":"","sources":["../../src/internal/source-imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAU1C,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAAC;IAC1D,CAAC,KAAK,EAAE,KAAK,CAAC;IACd,CAAC,MAAM,EAAE,KAAK,CAAC;IACf,CAAC,MAAM,EAAE,KAAK,CAAC;IACf,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,KAAK,EAAE,IAAI,CAAC;IACb,CAAC,MAAM,EAAE,KAAK,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,IAAY,EAA8B,EAAE;IAChE,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,gBAAgB,CAAC,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AAO,EAAE,OAAO,CAAC,CAAC;IAErD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAY,EAAyB,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;AAE9G,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAyB,EAAE,CAClE,kBAAkB,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC;AAEzD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAkB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAC/E,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAU,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;AAExF,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAkB,EAAE;IAC1D,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzD,OAAO,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,cAAc,GAEjB,CAAC","sourcesContent":["import type { ESTree, ParseResult, ParserOptions } from \"vite\";\nimport { sortStringsBy } from \"@gtkx/utils\";\nimport { existsSync, globSync, readFileSync } from \"node:fs\";\nimport { extname, join } from \"node:path\";\nimport { parseSync, Visitor } from \"vite\";\n\ntype SourceImport = {\n importer: string;\n source: string;\n};\n\ntype SourceLanguage = NonNullable<ParserOptions[\"lang\"]>;\ntype ParsedModule = ParseResult[\"module\"];\n\nconst SOURCE_LANGUAGES: Map<string, SourceLanguage> = new Map([\n [\".js\", \"jsx\"],\n [\".jsx\", \"jsx\"],\n [\".mjs\", \"jsx\"],\n [\".mts\", \"ts\"],\n [\".ts\", \"ts\"],\n [\".tsx\", \"tsx\"],\n]);\n\nconst sourceLanguage = (path: string): SourceLanguage | undefined => {\n if (path.endsWith(\".d.ts\") || path.endsWith(\".d.mts\")) {\n return undefined;\n }\n\n return SOURCE_LANGUAGES.get(extname(path).toLowerCase());\n};\n\nconst SOURCE_DIR = \"src\";\n\nconst sourceDirFor = (root: string): string => {\n const sourceDir = join(root, SOURCE_DIR);\n\n return existsSync(sourceDir) ? sourceDir : root;\n};\n\nconst discoverSourceFiles = (dir: string): string[] =>\n sortStringsBy(\n globSync(\"**/{*,.*}\", {\n cwd: dir,\n exclude: [\"**/{build,coverage,dist,node_modules,out-tsc}/**\", \"**/.gtkx-output-*/**\", \"**/.git/**\"],\n withFileTypes: true,\n })\n .filter((entry) => entry.isFile())\n .map((entry) => join(entry.parentPath, entry.name))\n .filter((path) => sourceLanguage(path) !== undefined),\n (path) => path,\n );\n\nconst staticImportSources = (module: ParsedModule): string[] => [\n ...module.staticImports.map((statement) => statement.moduleRequest.value),\n ...module.staticExports.flatMap((statement) =>\n statement.entries\n .map((entry) => entry.moduleRequest?.value)\n .filter((source): source is string => source !== undefined),\n ),\n];\n\nconst staticRuntimeImportSources = (module: ParsedModule): string[] => [\n ...module.staticImports\n .filter((statement) => statement.entries.length === 0 || statement.entries.some((entry) => !entry.isType))\n .map((statement) => statement.moduleRequest.value),\n ...module.staticExports.flatMap((statement) =>\n statement.entries\n .filter((entry) => !entry.isType)\n .map((entry) => entry.moduleRequest?.value)\n .filter((source): source is string => source !== undefined),\n ),\n];\n\nconst templateImportSource = (node: ESTree.TemplateLiteral): string | null => {\n const [quasi] = node.quasis;\n\n return quasi === undefined || node.expressions.length > 0 ? null : quasi.value.cooked;\n};\n\nconst literalImportSource = (node: ESTree.Expression): string | null => {\n if (node.type === \"TemplateLiteral\") {\n return templateImportSource(node);\n }\n\n return node.type === \"Literal\" && typeof node.value === \"string\" ? node.value : null;\n};\n\nconst collectDynamicImportSources = (program: ESTree.Program, found: string[]): void => {\n new Visitor({\n ImportExpression: (node) => {\n const source = literalImportSource(node.source);\n\n if (source !== null) {\n found.push(source);\n }\n },\n }).visit(program);\n};\n\nconst parseImportsInWith = (\n path: string,\n staticSources: (module: ParsedModule) => string[],\n): SourceImport[] | null => {\n const lang = sourceLanguage(path);\n\n if (lang === undefined) {\n return [];\n }\n\n let parsed: ParseResult;\n\n try {\n parsed = parseSync(path, readFileSync(path, \"utf8\"), { lang });\n } catch {\n return null;\n }\n\n if (parsed.errors.length > 0) {\n return null;\n }\n\n const sources = staticSources(parsed.module);\n collectDynamicImportSources(parsed.program, sources);\n\n return [...new Set(sources)].map((source) => ({ importer: path, source }));\n};\n\nconst parseImportsIn = (path: string): SourceImport[] | null => parseImportsInWith(path, staticImportSources);\n\nconst parseRuntimeImportsIn = (path: string): SourceImport[] | null =>\n parseImportsInWith(path, staticRuntimeImportSources);\n\nconst importsIn = (path: string): SourceImport[] => parseImportsIn(path) ?? [];\nconst importKey = (entry: SourceImport): string => `${entry.importer}\\0${entry.source}`;\n\nconst discoverSourceImports = (dir: string): SourceImport[] => {\n const files = discoverSourceFiles(dir);\n const imports = files.flatMap((path) => importsIn(path));\n\n return sortStringsBy(imports, importKey);\n};\n\nexport {\n discoverSourceFiles,\n discoverSourceImports,\n parseRuntimeImportsIn,\n sourceDirFor,\n sourceLanguage,\n type SourceImport,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xdg-banner.d.ts","sourceRoot":"","sources":["../../src/internal/xdg-banner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,QAAA,MAAM,iBAAiB,GAAI,OAAO,MAAM,CAAC,aAAa,KAAG,MAM7C,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { outputRootUrlExpression } from "./banner.js";
|
|
2
|
+
import { XDG_DATA_DIRS_DEFAULT } from "./xdg-data-dirs.js";
|
|
3
|
+
const xdgDataDirsBanner = (chunk) => [
|
|
4
|
+
"globalThis.process.env.XDG_DATA_DIRS = (() => {",
|
|
5
|
+
` const root = ${outputRootUrlExpression(chunk)};`,
|
|
6
|
+
` const dirs = globalThis.process.env.XDG_DATA_DIRS || ${JSON.stringify(XDG_DATA_DIRS_DEFAULT)};`,
|
|
7
|
+
" return dirs.split(\":\").includes(root) ? dirs : `${root}:${dirs}`;",
|
|
8
|
+
"})();",
|
|
9
|
+
].join("\n");
|
|
10
|
+
export { xdgDataDirsBanner };
|
|
11
|
+
//# sourceMappingURL=xdg-banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xdg-banner.js","sourceRoot":"","sources":["../../src/internal/xdg-banner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,iBAAiB,GAAG,CAAC,KAA2B,EAAU,EAAE,CAAC;IAC/D,iDAAiD;IACjD,oBAAoB,uBAAuB,CAAC,KAAK,CAAC,GAAG;IACrD,4DAA4D,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,GAAG;IACpG,yEAAyE;IACzE,OAAO;CACV,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { Rollup } from \"vite\";\nimport { outputRootUrlExpression } from \"./banner.js\";\nimport { XDG_DATA_DIRS_DEFAULT } from \"./xdg-data-dirs.js\";\n\nconst xdgDataDirsBanner = (chunk: Rollup.RenderedChunk): string => [\n \"globalThis.process.env.XDG_DATA_DIRS = (() => {\",\n ` const root = ${outputRootUrlExpression(chunk)};`,\n ` const dirs = globalThis.process.env.XDG_DATA_DIRS || ${JSON.stringify(XDG_DATA_DIRS_DEFAULT)};`,\n \" return dirs.split(\\\":\\\").includes(root) ? dirs : `${root}:${dirs}`;\",\n \"})();\",\n].join(\"\\n\");\n\nexport { xdgDataDirsBanner };\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
declare const XDG_DATA_DIRS_DEFAULT = "/usr/local/share:/usr/share";
|
|
1
2
|
declare const prependXdgDataDir: (dir: string, existing: string | undefined) => string;
|
|
2
|
-
export { prependXdgDataDir };
|
|
3
|
+
export { prependXdgDataDir, XDG_DATA_DIRS_DEFAULT };
|
|
3
4
|
//# sourceMappingURL=xdg-data-dirs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xdg-data-dirs.d.ts","sourceRoot":"","sources":["../../src/internal/xdg-data-dirs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xdg-data-dirs.d.ts","sourceRoot":"","sources":["../../src/internal/xdg-data-dirs.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,qBAAqB,gCAAgC,CAAC;AAE5D,QAAA,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS,KAAG,MAQtE,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xdg-data-dirs.js","sourceRoot":"","sources":["../../src/internal/xdg-data-dirs.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AAE5D,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,QAA4B,EAAU,EAAE;IAC5E,MAAM,IAAI,GAAG,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEhG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["const XDG_DATA_DIRS_DEFAULT = \"/usr/local/share:/usr/share\";\n\nconst prependXdgDataDir = (dir: string, existing: string | undefined): string => {\n const base = existing === undefined || existing.length === 0 ? XDG_DATA_DIRS_DEFAULT : existing;\n\n if (base.split(\":\").includes(dir)) {\n return base;\n }\n\n return `${dir}:${base}`;\n};\n\nexport { prependXdgDataDir };\n"]}
|
|
1
|
+
{"version":3,"file":"xdg-data-dirs.js","sourceRoot":"","sources":["../../src/internal/xdg-data-dirs.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AAE5D,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,QAA4B,EAAU,EAAE;IAC5E,MAAM,IAAI,GAAG,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEhG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["const XDG_DATA_DIRS_DEFAULT = \"/usr/local/share:/usr/share\";\n\nconst prependXdgDataDir = (dir: string, existing: string | undefined): string => {\n const base = existing === undefined || existing.length === 0 ? XDG_DATA_DIRS_DEFAULT : existing;\n\n if (base.split(\":\").includes(dir)) {\n return base;\n }\n\n return `${dir}:${base}`;\n};\n\nexport { prependXdgDataDir, XDG_DATA_DIRS_DEFAULT };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/settings/schema.ts"],"names":[],"mappings":"AAyBA,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,QAAA,MAAM,aAAa,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/settings/schema.ts"],"names":[],"mappings":"AAyBA,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,QAAA,MAAM,aAAa,iBAAiB,CAAC;AAKrC,QAAA,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS,KAAG,MAUrE,CAAC;AAKF,QAAA,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,KAAG,IAEpD,CAAC;AAEF,QAAA,MAAM,yBAAyB,GAAI,MAAM,MAAM,EAAE,UAAU,MAAM,KAAG,MAAM,GAAG,IAY5E,CAAC;AA6FF,QAAA,MAAM,2BAA2B,GAAI,aAAa,MAAM,EAAE,KAAG,IAiB5D,CAAC;AAEF,QAAA,MAAM,6BAA6B,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAsB9D,CAAC;AAmDF,QAAA,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,eAYxC,CAAC;AAEF,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,aAAa,GAChB,CAAC"}
|
package/dist/settings/schema.js
CHANGED
|
@@ -4,7 +4,7 @@ import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpat
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
6
6
|
import { I18N_TYPES_FILENAME, i18nTypesPath } from "../i18n/types.js";
|
|
7
|
-
import { discoverSourceImports } from "../internal/source-imports.js";
|
|
7
|
+
import { discoverSourceImports, sourceDirFor } from "../internal/source-imports.js";
|
|
8
8
|
import { removeTempDir } from "../internal/staging-dir.js";
|
|
9
9
|
import { isBareRelativeAsset, parseIconSpecifier, parseResourceSpecifier, } from "../vite-plugins/asset-specifier.js";
|
|
10
10
|
import { compileSchemas } from "./compile.js";
|
|
@@ -12,7 +12,6 @@ import { parseSchemaXml, SchemaParseError } from "./parser.js";
|
|
|
12
12
|
import { renderEnvModule } from "./render.js";
|
|
13
13
|
const SCHEMA_SUFFIX = ".gschema.xml";
|
|
14
14
|
const STAGED_NAME_LENGTH = 16;
|
|
15
|
-
const SOURCE_DIR = "src";
|
|
16
15
|
const RESOURCE_QUERY = "?resource=";
|
|
17
16
|
const ICON_QUERY = "?icon=";
|
|
18
17
|
const prependSchemaDir = (dir, existing) => {
|
|
@@ -41,10 +40,6 @@ const projectRelativeSchemaPath = (root, filePath) => {
|
|
|
41
40
|
return isPathInside(projectRoot, path) ? toPosixPath(relative(projectRoot, path)) : null;
|
|
42
41
|
};
|
|
43
42
|
const getRelativeModuleSpecifier = (filePath) => `*/${basename(filePath)}`;
|
|
44
|
-
const sourceDirFor = (root) => {
|
|
45
|
-
const sourceDir = join(root, SOURCE_DIR);
|
|
46
|
-
return existsSync(sourceDir) ? sourceDir : root;
|
|
47
|
-
};
|
|
48
43
|
const isRelativeImport = (source) => source.startsWith("./") || source.startsWith("../");
|
|
49
44
|
const schemaFileFor = ({ importer, source }) => isRelativeImport(source) && source.endsWith(SCHEMA_SUFFIX) ? resolve(dirname(importer), source) : null;
|
|
50
45
|
const find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AAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE7B,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,OAAe,EAAmB,EAAE;IACvD,MAAM,OAAO,GAAG,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACvD,2BAA2B,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,mBAAmB,CAAC,aAAa,EAAE,0BAA0B,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,mBAAmB,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1F,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEjD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,aAAa,GAChB,CAAC","sourcesContent":["import { isPathInside, sortStrings, toPosixPath, warn } from \"@gtkx/utils\";\nimport { createHash } from \"node:crypto\";\nimport {\n copyFileSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n realpathSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { I18N_TYPES_FILENAME, i18nTypesPath } from \"../i18n/types.js\";\nimport { discoverSourceImports, type SourceImport } from \"../internal/source-imports.js\";\nimport { removeTempDir } from \"../internal/staging-dir.js\";\nimport {\n isBareRelativeAsset,\n parseIconSpecifier,\n parseResourceSpecifier,\n} from \"../vite-plugins/asset-specifier.js\";\nimport { compileSchemas } from \"./compile.js\";\nimport { type ParsedSchemaFile, parseSchemaXml, SchemaParseError } from \"./parser.js\";\nimport { renderEnvModule } from \"./render.js\";\n\ntype SchemaEnvResult = {\n path: string;\n isWritten: boolean;\n};\n\nconst SCHEMA_SUFFIX = \".gschema.xml\";\nconst STAGED_NAME_LENGTH = 16;\nconst SOURCE_DIR = \"src\";\nconst RESOURCE_QUERY = \"?resource=\";\nconst ICON_QUERY = \"?icon=\";\n\nconst prependSchemaDir = (dir: string, existing: string | undefined): string => {\n if (existing === undefined || existing.length === 0) {\n return dir;\n }\n\n if (existing.split(\":\").includes(dir)) {\n return existing;\n }\n\n return `${dir}:${existing}`;\n};\n\nconst stagedSchemaName = (filePath: string): string =>\n `${createHash(\"sha1\").update(filePath).digest(\"hex\").slice(0, STAGED_NAME_LENGTH)}${SCHEMA_SUFFIX}`;\n\nconst stageSchema = (dir: string, filePath: string): void => {\n copyFileSync(filePath, join(dir, stagedSchemaName(filePath)));\n};\n\nconst projectRelativeSchemaPath = (root: string, filePath: string): string | null => {\n let projectRoot: string;\n let path: string;\n\n try {\n projectRoot = realpathSync(root);\n path = realpathSync(filePath);\n } catch {\n return null;\n }\n\n return isPathInside(projectRoot, path) ? toPosixPath(relative(projectRoot, path)) : null;\n};\n\nconst getRelativeModuleSpecifier = (filePath: string): string => `*/${basename(filePath)}`;\n\nconst sourceDirFor = (root: string): string => {\n const sourceDir = join(root, SOURCE_DIR);\n\n return existsSync(sourceDir) ? sourceDir : root;\n};\n\nconst isRelativeImport = (source: string): boolean => source.startsWith(\"./\") || source.startsWith(\"../\");\n\nconst schemaFileFor = ({ importer, source }: SourceImport): string | null =>\n isRelativeImport(source) && source.endsWith(SCHEMA_SUFFIX) ? resolve(dirname(importer), source) : null;\n\nconst findImportedSchemaFiles = (imports: SourceImport[]): string[] => {\n const files = imports\n .map((entry) => schemaFileFor(entry))\n .filter((path): path is string => path !== null);\n\n return sortStrings(new Set(files));\n};\n\nconst blockedAssetSpecifier = (source: string): string | null => {\n if (!isBareRelativeAsset(source)) {\n return null;\n }\n\n const separator = source.lastIndexOf(\"/\");\n const name = source.slice(separator + 1);\n\n if (name.includes(\"*\")) {\n throw new Error(\n `Cannot generate an asset declaration for ${JSON.stringify(source)}: filenames cannot contain *`,\n );\n }\n\n return `*/${name}`;\n};\n\nconst resourceModuleSpecifier = (source: string): string | null => {\n const parsed = parseResourceSpecifier(source);\n const queryIndex = source.indexOf(RESOURCE_QUERY);\n\n if (queryIndex === -1 || typeof parsed?.resourcePath !== \"string\") {\n return null;\n }\n\n const query = source.slice(queryIndex);\n\n if (query.includes(\"*\")) {\n throw new Error(\n `Cannot generate an asset declaration for ${JSON.stringify(source)}: resource paths cannot contain *`,\n );\n }\n\n return `*${query}`;\n};\n\nconst iconModuleSpecifier = (source: string): string | null => {\n const parsed = parseIconSpecifier(source);\n const queryIndex = source.indexOf(ICON_QUERY);\n\n if (queryIndex === -1 || typeof parsed?.iconName !== \"string\") {\n return null;\n }\n\n const query = source.slice(queryIndex);\n\n if (query.includes(\"*\")) {\n throw new Error(\n `Cannot generate an asset declaration for ${JSON.stringify(source)}: icon names cannot contain *`,\n );\n }\n\n return `*${query}`;\n};\n\nconst findAssetModuleSpecifiers = (\n imports: SourceImport[],\n): { blocked: string[]; icons: string[]; resources: string[] } => {\n const collect = (getSpecifier: (source: string) => string | null): string[] =>\n sortStrings(new Set(imports.map((entry) => getSpecifier(entry.source)).filter((value) => value !== null)));\n\n return {\n blocked: collect(blockedAssetSpecifier),\n icons: collect(iconModuleSpecifier),\n resources: collect(resourceModuleSpecifier),\n };\n};\n\nconst canonicalPath = (path: string): string => {\n try {\n return realpathSync(path);\n } catch {\n return resolve(path);\n }\n};\n\nconst assertUniqueSchemaBasenames = (schemaFiles: string[]): void => {\n const owners: Map<string, string> = new Map();\n const canonicalFiles = sortStrings(new Set(schemaFiles.map((path) => canonicalPath(path))));\n\n for (const filePath of canonicalFiles) {\n const name = basename(filePath);\n const owner = owners.get(name);\n\n if (owner !== undefined && owner !== filePath) {\n throw new Error(\n `Cannot generate types for both ${owner} and ${filePath}: relative GSettings schema imports are ` +\n `typed by basename, and both files are named ${name}. Rename one of them.`,\n );\n }\n\n owners.set(name, filePath);\n }\n};\n\nconst stageAndCompileProjectSchemas = (root: string): string | null => {\n const imports = discoverSourceImports(sourceDirFor(root));\n const schemaFiles = findImportedSchemaFiles(imports);\n assertUniqueSchemaBasenames(schemaFiles);\n\n if (schemaFiles.length === 0) {\n return null;\n }\n\n const dir = mkdtempSync(join(tmpdir(), \"gtkx-schemas-\"));\n\n for (const filePath of schemaFiles) {\n stageSchema(dir, filePath);\n }\n\n compileSchemas(dir);\n\n process.once(\"exit\", () => {\n removeTempDir(dir);\n });\n\n return dir;\n};\n\nconst schemaEnvPath = (rootDir: string): string => join(rootDir, \"node_modules\", \".gtkx\", \"env.d.ts\");\n\nconst parseSchemaFileOrWarn = (filePath: string, specifier: string): ParsedSchemaFile | null => {\n try {\n return parseSchemaXml(readFileSync(filePath, \"utf8\"), specifier);\n } catch (error) {\n if (!(error instanceof SchemaParseError)) {\n throw error;\n }\n\n warn(`Skipping ${filePath} in schema type generation: ${error.message}`);\n\n return null;\n }\n};\n\nconst parseProjectSchemas = (schemaFiles: string[], specifierFor: (filePath: string) => string): ParsedSchemaFile[] => {\n const parsed: ParsedSchemaFile[] = [];\n\n for (const filePath of schemaFiles) {\n const result = parseSchemaFileOrWarn(filePath, specifierFor(filePath));\n\n if (result !== null) {\n parsed.push(result);\n }\n }\n\n return parsed;\n};\n\nconst readFileOrNull = (path: string): string | null => {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return null;\n }\n};\n\nconst didWriteChanges = (path: string, content: string): boolean => {\n if (readFileOrNull(path) === content) {\n return false;\n }\n\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, content);\n\n return true;\n};\n\nconst emitSchemaEnv = (rootDir: string): SchemaEnvResult => {\n const imports = discoverSourceImports(sourceDirFor(rootDir));\n const importedFiles = findImportedSchemaFiles(imports);\n assertUniqueSchemaBasenames(importedFiles);\n const imported = parseProjectSchemas(importedFiles, getRelativeModuleSpecifier);\n const assets = findAssetModuleSpecifiers(imports);\n const references = existsSync(i18nTypesPath(rootDir)) ? [`./${I18N_TYPES_FILENAME}`] : [];\n const content = renderEnvModule(imported, assets, { references });\n const path = schemaEnvPath(rootDir);\n const isWritten = didWriteChanges(path, content);\n\n return { path, isWritten };\n};\n\nexport {\n SCHEMA_SUFFIX,\n prependSchemaDir,\n stageSchema,\n assertUniqueSchemaBasenames,\n projectRelativeSchemaPath,\n stageAndCompileProjectSchemas,\n emitSchemaEnv,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/settings/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACH,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAqB,MAAM,+BAA+B,CAAC;AACvG,OAAO,EA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,EACb,gBAAgB,EAChB,WAAW,EACX,2BAA2B,EAC3B,yBAAyB,EACzB,6BAA6B,EAC7B,aAAa,GAChB,CAAC","sourcesContent":["import { isPathInside, sortStrings, toPosixPath, warn } from \"@gtkx/utils\";\nimport { createHash } from \"node:crypto\";\nimport {\n copyFileSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n realpathSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { I18N_TYPES_FILENAME, i18nTypesPath } from \"../i18n/types.js\";\nimport { discoverSourceImports, sourceDirFor, type SourceImport } from \"../internal/source-imports.js\";\nimport { removeTempDir } from \"../internal/staging-dir.js\";\nimport {\n isBareRelativeAsset,\n parseIconSpecifier,\n parseResourceSpecifier,\n} from \"../vite-plugins/asset-specifier.js\";\nimport { compileSchemas } from \"./compile.js\";\nimport { type ParsedSchemaFile, parseSchemaXml, SchemaParseError } from \"./parser.js\";\nimport { renderEnvModule } from \"./render.js\";\n\ntype SchemaEnvResult = {\n path: string;\n isWritten: boolean;\n};\n\nconst SCHEMA_SUFFIX = \".gschema.xml\";\nconst STAGED_NAME_LENGTH = 16;\nconst RESOURCE_QUERY = \"?resource=\";\nconst ICON_QUERY = \"?icon=\";\n\nconst prependSchemaDir = (dir: string, existing: string | undefined): string => {\n if (existing === undefined || existing.length === 0) {\n return dir;\n }\n\n if (existing.split(\":\").includes(dir)) {\n return existing;\n }\n\n return `${dir}:${existing}`;\n};\n\nconst stagedSchemaName = (filePath: string): string =>\n `${createHash(\"sha1\").update(filePath).digest(\"hex\").slice(0, STAGED_NAME_LENGTH)}${SCHEMA_SUFFIX}`;\n\nconst stageSchema = (dir: string, filePath: string): void => {\n copyFileSync(filePath, join(dir, stagedSchemaName(filePath)));\n};\n\nconst projectRelativeSchemaPath = (root: string, filePath: string): string | null => {\n let projectRoot: string;\n let path: string;\n\n try {\n projectRoot = realpathSync(root);\n path = realpathSync(filePath);\n } catch {\n return null;\n }\n\n return isPathInside(projectRoot, path) ? toPosixPath(relative(projectRoot, path)) : null;\n};\n\nconst getRelativeModuleSpecifier = (filePath: string): string => `*/${basename(filePath)}`;\n\nconst isRelativeImport = (source: string): boolean => source.startsWith(\"./\") || source.startsWith(\"../\");\n\nconst schemaFileFor = ({ importer, source }: SourceImport): string | null =>\n isRelativeImport(source) && source.endsWith(SCHEMA_SUFFIX) ? resolve(dirname(importer), source) : null;\n\nconst findImportedSchemaFiles = (imports: SourceImport[]): string[] => {\n const files = imports\n .map((entry) => schemaFileFor(entry))\n .filter((path): path is string => path !== null);\n\n return sortStrings(new Set(files));\n};\n\nconst blockedAssetSpecifier = (source: string): string | null => {\n if (!isBareRelativeAsset(source)) {\n return null;\n }\n\n const separator = source.lastIndexOf(\"/\");\n const name = source.slice(separator + 1);\n\n if (name.includes(\"*\")) {\n throw new Error(\n `Cannot generate an asset declaration for ${JSON.stringify(source)}: filenames cannot contain *`,\n );\n }\n\n return `*/${name}`;\n};\n\nconst resourceModuleSpecifier = (source: string): string | null => {\n const parsed = parseResourceSpecifier(source);\n const queryIndex = source.indexOf(RESOURCE_QUERY);\n\n if (queryIndex === -1 || typeof parsed?.resourcePath !== \"string\") {\n return null;\n }\n\n const query = source.slice(queryIndex);\n\n if (query.includes(\"*\")) {\n throw new Error(\n `Cannot generate an asset declaration for ${JSON.stringify(source)}: resource paths cannot contain *`,\n );\n }\n\n return `*${query}`;\n};\n\nconst iconModuleSpecifier = (source: string): string | null => {\n const parsed = parseIconSpecifier(source);\n const queryIndex = source.indexOf(ICON_QUERY);\n\n if (queryIndex === -1 || typeof parsed?.iconName !== \"string\") {\n return null;\n }\n\n const query = source.slice(queryIndex);\n\n if (query.includes(\"*\")) {\n throw new Error(\n `Cannot generate an asset declaration for ${JSON.stringify(source)}: icon names cannot contain *`,\n );\n }\n\n return `*${query}`;\n};\n\nconst findAssetModuleSpecifiers = (\n imports: SourceImport[],\n): { blocked: string[]; icons: string[]; resources: string[] } => {\n const collect = (getSpecifier: (source: string) => string | null): string[] =>\n sortStrings(new Set(imports.map((entry) => getSpecifier(entry.source)).filter((value) => value !== null)));\n\n return {\n blocked: collect(blockedAssetSpecifier),\n icons: collect(iconModuleSpecifier),\n resources: collect(resourceModuleSpecifier),\n };\n};\n\nconst canonicalPath = (path: string): string => {\n try {\n return realpathSync(path);\n } catch {\n return resolve(path);\n }\n};\n\nconst assertUniqueSchemaBasenames = (schemaFiles: string[]): void => {\n const owners: Map<string, string> = new Map();\n const canonicalFiles = sortStrings(new Set(schemaFiles.map((path) => canonicalPath(path))));\n\n for (const filePath of canonicalFiles) {\n const name = basename(filePath);\n const owner = owners.get(name);\n\n if (owner !== undefined && owner !== filePath) {\n throw new Error(\n `Cannot generate types for both ${owner} and ${filePath}: relative GSettings schema imports are ` +\n `typed by basename, and both files are named ${name}. Rename one of them.`,\n );\n }\n\n owners.set(name, filePath);\n }\n};\n\nconst stageAndCompileProjectSchemas = (root: string): string | null => {\n const imports = discoverSourceImports(sourceDirFor(root));\n const schemaFiles = findImportedSchemaFiles(imports);\n assertUniqueSchemaBasenames(schemaFiles);\n\n if (schemaFiles.length === 0) {\n return null;\n }\n\n const dir = mkdtempSync(join(tmpdir(), \"gtkx-schemas-\"));\n\n for (const filePath of schemaFiles) {\n stageSchema(dir, filePath);\n }\n\n compileSchemas(dir);\n\n process.once(\"exit\", () => {\n removeTempDir(dir);\n });\n\n return dir;\n};\n\nconst schemaEnvPath = (rootDir: string): string => join(rootDir, \"node_modules\", \".gtkx\", \"env.d.ts\");\n\nconst parseSchemaFileOrWarn = (filePath: string, specifier: string): ParsedSchemaFile | null => {\n try {\n return parseSchemaXml(readFileSync(filePath, \"utf8\"), specifier);\n } catch (error) {\n if (!(error instanceof SchemaParseError)) {\n throw error;\n }\n\n warn(`Skipping ${filePath} in schema type generation: ${error.message}`);\n\n return null;\n }\n};\n\nconst parseProjectSchemas = (schemaFiles: string[], specifierFor: (filePath: string) => string): ParsedSchemaFile[] => {\n const parsed: ParsedSchemaFile[] = [];\n\n for (const filePath of schemaFiles) {\n const result = parseSchemaFileOrWarn(filePath, specifierFor(filePath));\n\n if (result !== null) {\n parsed.push(result);\n }\n }\n\n return parsed;\n};\n\nconst readFileOrNull = (path: string): string | null => {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return null;\n }\n};\n\nconst didWriteChanges = (path: string, content: string): boolean => {\n if (readFileOrNull(path) === content) {\n return false;\n }\n\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, content);\n\n return true;\n};\n\nconst emitSchemaEnv = (rootDir: string): SchemaEnvResult => {\n const imports = discoverSourceImports(sourceDirFor(rootDir));\n const importedFiles = findImportedSchemaFiles(imports);\n assertUniqueSchemaBasenames(importedFiles);\n const imported = parseProjectSchemas(importedFiles, getRelativeModuleSpecifier);\n const assets = findAssetModuleSpecifiers(imports);\n const references = existsSync(i18nTypesPath(rootDir)) ? [`./${I18N_TYPES_FILENAME}`] : [];\n const content = renderEnvModule(imported, assets, { references });\n const path = schemaEnvPath(rootDir);\n const isWritten = didWriteChanges(path, content);\n\n return { path, isWritten };\n};\n\nexport {\n SCHEMA_SUFFIX,\n prependSchemaDir,\n stageSchema,\n assertUniqueSchemaBasenames,\n projectRelativeSchemaPath,\n stageAndCompileProjectSchemas,\n emitSchemaEnv,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-extensions.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/asset-extensions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"asset-extensions.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/asset-extensions.ts"],"names":[],"mappings":"AA4BA,QAAA,MAAM,QAAQ,QAAoE,CAAC;AACnF,QAAA,MAAM,aAAa,QAA6E,CAAC;AACjG,QAAA,MAAM,gBAAgB,QAAmE,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-extensions.js","sourceRoot":"","sources":["../../src/vite-plugins/asset-extensions.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG;IACrB,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;CACR,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,QAAQ,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACnF,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,QAAQ,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AACjG,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,QAAQ,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["const ASSET_EXTENSIONS = [\n \"png\",\n \"jpg\",\n \"jpeg\",\n \"gif\",\n \"svg\",\n \"xpm\",\n \"webp\",\n \"webm\",\n \"mp4\",\n \"ogg\",\n \"mp3\",\n \"wav\",\n \"flac\",\n \"aac\",\n \"woff\",\n \"woff2\",\n \"eot\",\n \"ttf\",\n \"otf\",\n \"ico\",\n \"avif\",\n \"data\",\n \"gpa\",\n];\n\nconst ASSET_RE = new RegExp(String.raw`\\.(?:${ASSET_EXTENSIONS.join(\"|\")})$`, \"i\");\nconst ASSET_PATH_RE = new RegExp(String.raw`\\.(?:${ASSET_EXTENSIONS.join(\"|\")})(?:\\?.*)?$`, \"i\");\nconst ASSET_MENTION_RE = new RegExp(String.raw`\\.(?:${ASSET_EXTENSIONS.join(\"|\")})`, \"i\");\n\nexport { ASSET_MENTION_RE, ASSET_PATH_RE, ASSET_RE };\n"]}
|
|
1
|
+
{"version":3,"file":"asset-extensions.js","sourceRoot":"","sources":["../../src/vite-plugins/asset-extensions.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG;IACrB,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;CACR,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,QAAQ,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACnF,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,QAAQ,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AACjG,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,QAAQ,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["const ASSET_EXTENSIONS = [\n \"png\",\n \"jpg\",\n \"jpeg\",\n \"gif\",\n \"svg\",\n \"xpm\",\n \"webp\",\n \"webm\",\n \"mp4\",\n \"ogg\",\n \"mp3\",\n \"wav\",\n \"flac\",\n \"aac\",\n \"woff\",\n \"woff2\",\n \"eot\",\n \"ttf\",\n \"otf\",\n \"ttc\",\n \"otc\",\n \"ico\",\n \"avif\",\n \"data\",\n \"gpa\",\n];\n\nconst ASSET_RE = new RegExp(String.raw`\\.(?:${ASSET_EXTENSIONS.join(\"|\")})$`, \"i\");\nconst ASSET_PATH_RE = new RegExp(String.raw`\\.(?:${ASSET_EXTENSIONS.join(\"|\")})(?:\\?.*)?$`, \"i\");\nconst ASSET_MENTION_RE = new RegExp(String.raw`\\.(?:${ASSET_EXTENSIONS.join(\"|\")})`, \"i\");\n\nexport { ASSET_MENTION_RE, ASSET_PATH_RE, ASSET_RE };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-imports.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/asset-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"asset-imports.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/asset-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,MAAM,CAAC;AAuIhD,iBAAS,gBAAgB,IAAI,MAAM,CASlC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseSync } from "vite";
|
|
2
2
|
import { sourceLanguage } from "../internal/source-imports.js";
|
|
3
3
|
import { ASSET_MENTION_RE } from "./asset-extensions.js";
|
|
4
|
-
import { isAssetSpecifier, isUrlSpecifier, parseIconSpecifier, parseResourceSpecifier, } from "./asset-specifier.js";
|
|
4
|
+
import { isAssetSpecifier, isUrlSpecifier, parseFontSpecifier, parseIconSpecifier, parseResourceSpecifier, } from "./asset-specifier.js";
|
|
5
5
|
import { RESOURCE_PATH_EXPORT } from "./resource-shared.js";
|
|
6
6
|
import { stripQuery } from "./strip-query.js";
|
|
7
7
|
const NODE_MODULES = /(?:^|\/)node_modules\//;
|
|
@@ -11,7 +11,9 @@ const RESOURCE_BINDING = JSON.stringify(RESOURCE_PATH_EXPORT);
|
|
|
11
11
|
const QUERY_ADVICE = `A URL asset exports only its default filesystem path; import the default instead of ${RESOURCE_BINDING}.`;
|
|
12
12
|
const RESOURCE_ADVICE = `A resource asset exports only its default GResource path and ${RESOURCE_BINDING}, and nothing else.`;
|
|
13
13
|
const ICON_ADVICE = "An icon asset exports only its default icon-theme name, and nothing else.";
|
|
14
|
-
const
|
|
14
|
+
const FONT_ADVICE = "A font asset exports only its default font family name, and nothing else.";
|
|
15
|
+
const RELATIVE_ADVICE = "Add ?resource for a GResource, ?icon for a themed icon, ?font for a bundled font, or ?url for an " +
|
|
16
|
+
"emitted file.";
|
|
15
17
|
const boundName = (entry) => {
|
|
16
18
|
const { name } = entry.importName;
|
|
17
19
|
if (name === null || name === DEFAULT_BINDING || entry.isType) {
|
|
@@ -48,6 +50,9 @@ const adviceFor = (source) => {
|
|
|
48
50
|
if (parseIconSpecifier(source) !== null) {
|
|
49
51
|
return ICON_ADVICE;
|
|
50
52
|
}
|
|
53
|
+
if (parseFontSpecifier(source) !== null) {
|
|
54
|
+
return FONT_ADVICE;
|
|
55
|
+
}
|
|
51
56
|
if (isUrlSpecifier(source)) {
|
|
52
57
|
return QUERY_ADVICE;
|
|
53
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-imports.js","sourceRoot":"","sources":["../../src/vite-plugins/asset-imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACzB,MAAM,sBAAs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AC3B,OAAO;IACX,CAAC;IAED,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;AACL,CAAC,CAAC;AAEF,SAAS,gBAAgB;IACrB,OAAO;QACH,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,KAAK;QAEd,SAAS,CAAC,IAAI,EAAE,EAAE;YACd,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import type { ParseResult, Plugin } from \"vite\";\nimport { parseSync } from \"vite\";\nimport { sourceLanguage } from \"../internal/source-imports.js\";\nimport { ASSET_MENTION_RE } from \"./asset-extensions.js\";\nimport {\n isAssetSpecifier,\n isUrlSpecifier,\n parseFontSpecifier,\n parseIconSpecifier,\n parseResourceSpecifier,\n} from \"./asset-specifier.js\";\nimport { RESOURCE_PATH_EXPORT } from \"./resource-shared.js\";\nimport { stripQuery } from \"./strip-query.js\";\n\ntype ParsedModule = ParseResult[\"module\"];\ntype ImportStatement = ParsedModule[\"staticImports\"][number];\ntype ExportStatement = ParsedModule[\"staticExports\"][number];\ntype ExportEntry = ExportStatement[\"entries\"][number];\ntype BindingEntry = { importName: { name: string | null }; isType: boolean };\ntype NamedBinding = { name: string; source: string };\n\nconst NODE_MODULES = /(?:^|\\/)node_modules\\//;\nconst VIRTUAL_PREFIX = \"\\0\";\nconst DEFAULT_BINDING = \"default\";\nconst RESOURCE_BINDING = JSON.stringify(RESOURCE_PATH_EXPORT);\n\nconst QUERY_ADVICE =\n `A URL asset exports only its default filesystem path; import the default instead of ${RESOURCE_BINDING}.`;\n\nconst RESOURCE_ADVICE =\n `A resource asset exports only its default GResource path and ${RESOURCE_BINDING}, and nothing else.`;\n\nconst ICON_ADVICE = \"An icon asset exports only its default icon-theme name, and nothing else.\";\n\nconst FONT_ADVICE = \"A font asset exports only its default font family name, and nothing else.\";\n\nconst RELATIVE_ADVICE =\n \"Add ?resource for a GResource, ?icon for a themed icon, ?font for a bundled font, or ?url for an \" +\n \"emitted file.\";\n\nconst boundName = (entry: BindingEntry): string | null => {\n const { name } = entry.importName;\n\n if (name === null || name === DEFAULT_BINDING || entry.isType) {\n return null;\n }\n\n return name;\n};\n\nconst importBindings = (statement: ImportStatement): NamedBinding[] =>\n statement.entries\n .map((entry) => boundName(entry))\n .filter((name) => name !== null)\n .map((name) => ({ name, source: statement.moduleRequest.value }));\n\nconst exportBinding = (entry: ExportEntry): NamedBinding | null => {\n const name = boundName(entry);\n const source = entry.moduleRequest?.value;\n\n return name === null || source === undefined ? null : { name, source };\n};\n\nconst exportBindings = (statement: ExportStatement): NamedBinding[] =>\n statement.entries.map((entry) => exportBinding(entry)).filter((binding) => binding !== null);\n\nconst bindings = (parsed: ParsedModule): NamedBinding[] => [\n ...parsed.staticImports.flatMap((statement) => importBindings(statement)),\n ...parsed.staticExports.flatMap((statement) => exportBindings(statement)),\n];\n\nconst isBacked = ({ name, source }: NamedBinding): boolean => {\n if (name !== RESOURCE_PATH_EXPORT) {\n return false;\n }\n\n return parseResourceSpecifier(source) !== null;\n};\n\nconst isCheckedSpecifier = (source: string): boolean => isAssetSpecifier(source) || isUrlSpecifier(source);\n\nconst unbackedBinding = (parsed: ParsedModule): NamedBinding | undefined =>\n bindings(parsed).find((binding) => isCheckedSpecifier(binding.source) && !isBacked(binding));\n\nconst adviceFor = (source: string): string => {\n if (parseResourceSpecifier(source) !== null) {\n return RESOURCE_ADVICE;\n }\n\n if (parseIconSpecifier(source) !== null) {\n return ICON_ADVICE;\n }\n\n if (parseFontSpecifier(source) !== null) {\n return FONT_ADVICE;\n }\n\n if (isUrlSpecifier(source)) {\n return QUERY_ADVICE;\n }\n\n return RELATIVE_ADVICE;\n};\n\nconst unbackedBindingError = (path: string, binding: NamedBinding): Error =>\n new Error(\n `${path}: ${JSON.stringify(binding.source)} does not export ${JSON.stringify(binding.name)}, which ` +\n \"gtkx build rejects and gtkx dev would bind as undefined. \" +\n adviceFor(binding.source),\n );\n\nconst isCheckedSource = (path: string): boolean => !path.startsWith(VIRTUAL_PREFIX) && !NODE_MODULES.test(path);\nconst hasCheckedAssetMention = (code: string): boolean => ASSET_MENTION_RE.test(code) || code.includes(\"?url\");\n\nconst checkAssetImports = (code: string, id: string): void => {\n const path = stripQuery(id);\n const lang = sourceLanguage(path);\n\n if (lang === undefined || !isCheckedSource(path) || !hasCheckedAssetMention(code)) {\n return;\n }\n\n const parsed = parseSync(path, code, { lang });\n\n if (parsed.errors.length > 0) {\n return;\n }\n\n const binding = unbackedBinding(parsed.module);\n\n if (binding !== undefined) {\n throw unbackedBindingError(path, binding);\n }\n};\n\nfunction gtkxAssetImports(): Plugin {\n return {\n name: \"gtkx:asset-imports\",\n enforce: \"pre\",\n\n transform(code, id) {\n checkAssetImports(code, id);\n },\n };\n}\n\nexport { gtkxAssetImports };\n"]}
|
|
@@ -6,10 +6,14 @@ type IconSpecifier = {
|
|
|
6
6
|
assetSource: string;
|
|
7
7
|
iconName: string | null;
|
|
8
8
|
};
|
|
9
|
+
type FontSpecifier = {
|
|
10
|
+
assetSource: string;
|
|
11
|
+
};
|
|
9
12
|
declare const isAssetSpecifier: (source: string) => boolean;
|
|
10
13
|
declare const isBareRelativeAsset: (source: string) => boolean;
|
|
11
14
|
declare const parseResourceSpecifier: (source: string) => ResourceSpecifier | null;
|
|
12
15
|
declare const parseIconSpecifier: (source: string) => IconSpecifier | null;
|
|
16
|
+
declare const parseFontSpecifier: (source: string) => FontSpecifier | null;
|
|
13
17
|
declare const isUrlSpecifier: (source: string) => boolean;
|
|
14
|
-
export { isAssetSpecifier, isBareRelativeAsset, isUrlSpecifier, parseIconSpecifier, parseResourceSpecifier, };
|
|
18
|
+
export { isAssetSpecifier, isBareRelativeAsset, isUrlSpecifier, parseFontSpecifier, parseIconSpecifier, parseResourceSpecifier, };
|
|
15
19
|
//# sourceMappingURL=asset-specifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-specifier.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/asset-specifier.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,KAAK,aAAa,GAAG;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;
|
|
1
|
+
{"version":3,"file":"asset-specifier.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/asset-specifier.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,KAAK,aAAa,GAAG;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,KAAK,aAAa,GAAG;IACjB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAcF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,OAAqC,CAAC;AAEjF,QAAA,MAAM,mBAAmB,GAAI,QAAQ,MAAM,KAAG,OAC2C,CAAC;AAE1F,QAAA,MAAM,sBAAsB,GAAI,QAAQ,MAAM,KAAG,iBAAiB,GAAG,IAepE,CAAC;AAEF,QAAA,MAAM,kBAAkB,GAAI,QAAQ,MAAM,KAAG,aAAa,GAAG,IAe5D,CAAC;AAEF,QAAA,MAAM,kBAAkB,GAAI,QAAQ,MAAM,KAAG,aAAa,GAAG,IAS5D,CAAC;AAEF,QAAA,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,OAIxC,CAAC;AAEF,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACzB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { stripQuery } from "./strip-query.js";
|
|
|
3
3
|
const RELATIVE_PREFIX_RE = /^\.\.?(?:\/|$)/;
|
|
4
4
|
const RESOURCE_QUERY_RE = /^resource(?:=([^&#]+))?$/;
|
|
5
5
|
const ICON_QUERY_RE = /^icon(?:=([^&#]+))?$/;
|
|
6
|
+
const FONT_QUERY_RE = /^font$/;
|
|
6
7
|
const URL_QUERY_RE = /(?:^|&)url(?:&|$)/;
|
|
7
8
|
const getQuery = (source) => {
|
|
8
9
|
const queryIndex = source.indexOf("?");
|
|
@@ -34,9 +35,17 @@ const parseIconSpecifier = (source) => {
|
|
|
34
35
|
}
|
|
35
36
|
return { assetSource, iconName: match[1] ?? null };
|
|
36
37
|
};
|
|
38
|
+
const parseFontSpecifier = (source) => {
|
|
39
|
+
const query = getQuery(source);
|
|
40
|
+
const assetSource = stripQuery(source);
|
|
41
|
+
if (query === null || !ASSET_RE.test(assetSource) || !FONT_QUERY_RE.test(query)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return { assetSource };
|
|
45
|
+
};
|
|
37
46
|
const isUrlSpecifier = (source) => {
|
|
38
47
|
const query = getQuery(source);
|
|
39
48
|
return query !== null && URL_QUERY_RE.test(query);
|
|
40
49
|
};
|
|
41
|
-
export { isAssetSpecifier, isBareRelativeAsset, isUrlSpecifier, parseIconSpecifier, parseResourceSpecifier, };
|
|
50
|
+
export { isAssetSpecifier, isBareRelativeAsset, isUrlSpecifier, parseFontSpecifier, parseIconSpecifier, parseResourceSpecifier, };
|
|
42
51
|
//# sourceMappingURL=asset-specifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-specifier.js","sourceRoot":"","sources":["../../src/vite-plugins/asset-specifier.ts"],"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AK,CAAC,EAAE,CAAC;QAC9E,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,MAAc,EAAW,EAAE;IAC/C,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE/B,OAAO,KAAK,KAAK,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,OAAO,EACH,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACzB,CAAC","sourcesContent":["import { ASSET_PATH_RE, ASSET_RE } from \"./asset-extensions.js\";\nimport { stripQuery } from \"./strip-query.js\";\n\ntype ResourceSpecifier = {\n assetSource: string;\n resourcePath: string | null;\n};\n\ntype IconSpecifier = {\n assetSource: string;\n iconName: string | null;\n};\n\ntype FontSpecifier = {\n assetSource: string;\n};\n\nconst RELATIVE_PREFIX_RE = /^\\.\\.?(?:\\/|$)/;\nconst RESOURCE_QUERY_RE = /^resource(?:=([^&#]+))?$/;\nconst ICON_QUERY_RE = /^icon(?:=([^&#]+))?$/;\nconst FONT_QUERY_RE = /^font$/;\nconst URL_QUERY_RE = /(?:^|&)url(?:&|$)/;\n\nconst getQuery = (source: string): string | null => {\n const queryIndex = source.indexOf(\"?\");\n\n return queryIndex === -1 ? null : source.slice(queryIndex + 1);\n};\n\nconst isAssetSpecifier = (source: string): boolean => ASSET_PATH_RE.test(source);\n\nconst isBareRelativeAsset = (source: string): boolean =>\n getQuery(source) === null && RELATIVE_PREFIX_RE.test(source) && ASSET_RE.test(source);\n\nconst parseResourceSpecifier = (source: string): ResourceSpecifier | null => {\n const query = getQuery(source);\n const assetSource = stripQuery(source);\n\n if (query === null || !ASSET_RE.test(assetSource)) {\n return null;\n }\n\n const match = RESOURCE_QUERY_RE.exec(query);\n\n if (match === null) {\n return null;\n }\n\n return { assetSource, resourcePath: match[1] ?? null };\n};\n\nconst parseIconSpecifier = (source: string): IconSpecifier | null => {\n const query = getQuery(source);\n const assetSource = stripQuery(source);\n\n if (query === null || !ASSET_RE.test(assetSource)) {\n return null;\n }\n\n const match = ICON_QUERY_RE.exec(query);\n\n if (match === null) {\n return null;\n }\n\n return { assetSource, iconName: match[1] ?? null };\n};\n\nconst parseFontSpecifier = (source: string): FontSpecifier | null => {\n const query = getQuery(source);\n const assetSource = stripQuery(source);\n\n if (query === null || !ASSET_RE.test(assetSource) || !FONT_QUERY_RE.test(query)) {\n return null;\n }\n\n return { assetSource };\n};\n\nconst isUrlSpecifier = (source: string): boolean => {\n const query = getQuery(source);\n\n return query !== null && URL_QUERY_RE.test(query);\n};\n\nexport {\n isAssetSpecifier,\n isBareRelativeAsset,\n isUrlSpecifier,\n parseFontSpecifier,\n parseIconSpecifier,\n parseResourceSpecifier,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAuCnC,iBAAS,OAAO,IAAI,MAAM,CAazB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|