@gtkx/cli 1.6.0 → 2.0.0-beta.1
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 +5 -5
- package/dist/codegen/freshness.d.ts.map +1 -1
- package/dist/codegen/freshness.js +45 -16
- package/dist/codegen/freshness.js.map +1 -1
- package/dist/codegen/reference.d.ts.map +1 -1
- package/dist/codegen/reference.js +1 -7
- package/dist/codegen/reference.js.map +1 -1
- package/dist/codegen/report.d.ts.map +1 -1
- package/dist/codegen/report.js +5 -16
- package/dist/codegen/report.js.map +1 -1
- package/dist/codegen/run-codegen.d.ts +3 -5
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +23 -100
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/codegen/store-resolver.d.ts +0 -1
- package/dist/codegen/store-resolver.d.ts.map +1 -1
- package/dist/codegen/store-resolver.js +8 -17
- package/dist/codegen/store-resolver.js.map +1 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +5 -15
- package/dist/commands/docs.js.map +1 -1
- package/dist/deploy/freedesktop/copyright.d.ts.map +1 -1
- package/dist/deploy/freedesktop/copyright.js +2 -13
- package/dist/deploy/freedesktop/copyright.js.map +1 -1
- package/dist/deploy/freedesktop/xml.d.ts.map +1 -1
- package/dist/deploy/freedesktop/xml.js +21 -25
- package/dist/deploy/freedesktop/xml.js.map +1 -1
- package/dist/deploy/node-runtime/license.d.ts.map +1 -1
- package/dist/deploy/node-runtime/license.js +2 -9
- package/dist/deploy/node-runtime/license.js.map +1 -1
- package/dist/deploy/notices/packages.d.ts.map +1 -1
- package/dist/deploy/notices/packages.js +3 -10
- package/dist/deploy/notices/packages.js.map +1 -1
- package/dist/deploy/payload/copy-tree.d.ts.map +1 -1
- package/dist/deploy/payload/copy-tree.js +3 -3
- package/dist/deploy/payload/copy-tree.js.map +1 -1
- package/dist/deploy/payload/stage.d.ts.map +1 -1
- package/dist/deploy/payload/stage.js +1 -3
- package/dist/deploy/payload/stage.js.map +1 -1
- package/dist/deploy/settings/build-manifest.d.ts.map +1 -1
- package/dist/deploy/settings/build-manifest.js +4 -15
- package/dist/deploy/settings/build-manifest.js.map +1 -1
- package/dist/deploy/settings/libraries.d.ts.map +1 -1
- package/dist/deploy/settings/libraries.js +2 -19
- package/dist/deploy/settings/libraries.js.map +1 -1
- package/dist/deploy/settings/paths.d.ts +1 -2
- package/dist/deploy/settings/paths.d.ts.map +1 -1
- package/dist/deploy/settings/paths.js +5 -15
- package/dist/deploy/settings/paths.js.map +1 -1
- package/dist/deploy/settings/screenshots.d.ts.map +1 -1
- package/dist/deploy/settings/screenshots.js +6 -31
- package/dist/deploy/settings/screenshots.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 +4 -4
- package/dist/deploy/targets/flatpak-source.js.map +1 -1
- package/dist/deploy/targets/flatpak-sources.js +1 -1
- package/dist/deploy/targets/flatpak-sources.js.map +1 -1
- package/dist/dev/runner-main.d.ts.map +1 -1
- package/dist/dev/runner-main.js +1 -2
- package/dist/dev/runner-main.js.map +1 -1
- package/dist/dev/schema-dir.d.ts +1 -1
- package/dist/dev/schema-dir.d.ts.map +1 -1
- package/dist/dev/schema-dir.js +2 -4
- package/dist/dev/schema-dir.js.map +1 -1
- package/dist/i18n/catalogs.d.ts.map +1 -1
- package/dist/i18n/catalogs.js +2 -1
- package/dist/i18n/catalogs.js.map +1 -1
- package/dist/i18n/metadata-templates.d.ts.map +1 -1
- package/dist/i18n/metadata-templates.js +2 -1
- package/dist/i18n/metadata-templates.js.map +1 -1
- package/dist/i18n/source-messages.d.ts +3 -21
- package/dist/i18n/source-messages.d.ts.map +1 -1
- package/dist/i18n/source-messages.js +66 -85
- package/dist/i18n/source-messages.js.map +1 -1
- package/dist/i18n/types.d.ts +6 -7
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/i18n/types.js +83 -96
- package/dist/i18n/types.js.map +1 -1
- package/dist/internal/docs-elements.js +2 -2
- package/dist/internal/docs-elements.js.map +1 -1
- package/dist/internal/icon-path.d.ts.map +1 -1
- package/dist/internal/icon-path.js +5 -16
- package/dist/internal/icon-path.js.map +1 -1
- package/dist/internal/source-imports.d.ts.map +1 -1
- package/dist/internal/source-imports.js +10 -41
- package/dist/internal/source-imports.js.map +1 -1
- package/dist/settings/render.d.ts +0 -1
- package/dist/settings/render.d.ts.map +1 -1
- package/dist/settings/render.js +1 -11
- package/dist/settings/render.js.map +1 -1
- package/dist/settings/schema.d.ts +2 -2
- package/dist/settings/schema.d.ts.map +1 -1
- package/dist/settings/schema.js +21 -62
- package/dist/settings/schema.js.map +1 -1
- package/dist/vite-plugins/asset-imports.d.ts +1 -2
- package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
- package/dist/vite-plugins/asset-imports.js +19 -32
- package/dist/vite-plugins/asset-imports.js.map +1 -1
- package/dist/vite-plugins/asset-specifier.d.ts +1 -3
- package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
- package/dist/vite-plugins/asset-specifier.js +1 -4
- package/dist/vite-plugins/asset-specifier.js.map +1 -1
- package/dist/vite-plugins/i18n.d.ts.map +1 -1
- package/dist/vite-plugins/i18n.js +2 -1
- package/dist/vite-plugins/i18n.js.map +1 -1
- package/dist/vite-plugins/index.d.ts.map +1 -1
- package/dist/vite-plugins/index.js +2 -4
- package/dist/vite-plugins/index.js.map +1 -1
- package/dist/vite-plugins/resources.d.ts.map +1 -1
- package/dist/vite-plugins/resources.js +32 -97
- package/dist/vite-plugins/resources.js.map +1 -1
- package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
- package/dist/vite-plugins/settings-worker-env.js +2 -4
- package/dist/vite-plugins/settings-worker-env.js.map +1 -1
- package/dist/vite-plugins/settings.d.ts +1 -2
- package/dist/vite-plugins/settings.d.ts.map +1 -1
- package/dist/vite-plugins/settings.js +8 -14
- package/dist/vite-plugins/settings.js.map +1 -1
- package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
- package/dist/vite-plugins/undeclared-library.js +10 -13
- 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 +0 -1
- package/dist/vite-plugins/worker.js.map +1 -1
- package/package.json +21 -15
- package/src/codegen/freshness.ts +66 -17
- package/src/codegen/reference.ts +1 -8
- package/src/codegen/report.ts +5 -21
- package/src/codegen/run-codegen.ts +28 -145
- package/src/codegen/store-resolver.ts +8 -24
- package/src/commands/docs.ts +5 -17
- package/src/deploy/freedesktop/copyright.ts +2 -14
- package/src/deploy/freedesktop/xml.ts +24 -32
- package/src/deploy/node-runtime/license.ts +2 -8
- package/src/deploy/notices/packages.ts +3 -11
- package/src/deploy/payload/copy-tree.ts +3 -4
- package/src/deploy/payload/stage.ts +2 -6
- package/src/deploy/settings/build-manifest.ts +4 -16
- package/src/deploy/settings/libraries.ts +1 -22
- package/src/deploy/settings/paths.ts +6 -16
- package/src/deploy/settings/screenshots.ts +8 -46
- package/src/deploy/targets/flatpak-pnpm.ts +4 -4
- package/src/deploy/targets/flatpak-source.ts +4 -4
- package/src/deploy/targets/flatpak-sources.ts +1 -1
- package/src/dev/runner-main.ts +1 -2
- package/src/dev/schema-dir.ts +2 -4
- package/src/i18n/catalogs.ts +2 -1
- package/src/i18n/metadata-templates.ts +2 -1
- package/src/i18n/source-messages.ts +77 -115
- package/src/i18n/types.ts +97 -131
- package/src/internal/docs-elements.ts +2 -2
- package/src/internal/icon-path.ts +6 -19
- package/src/internal/source-imports.ts +14 -50
- package/src/settings/render.ts +1 -13
- package/src/settings/schema.ts +19 -81
- package/src/vite-plugins/asset-imports.ts +20 -44
- package/src/vite-plugins/asset-specifier.ts +0 -5
- package/src/vite-plugins/i18n.ts +2 -1
- package/src/vite-plugins/index.ts +2 -4
- package/src/vite-plugins/resources.ts +37 -140
- package/src/vite-plugins/settings-worker-env.ts +2 -4
- package/src/vite-plugins/settings.ts +11 -20
- package/src/vite-plugins/undeclared-library.ts +14 -20
- package/src/vite-plugins/worker.ts +0 -1
- package/dist/i18n/binding-extractor.d.ts +0 -30
- package/dist/i18n/binding-extractor.d.ts.map +0 -1
- package/dist/i18n/binding-extractor.js +0 -1324
- package/dist/i18n/binding-extractor.js.map +0 -1
- package/dist/i18n/extractor-plugin.d.ts +0 -8
- package/dist/i18n/extractor-plugin.d.ts.map +0 -1
- package/dist/i18n/extractor-plugin.js +0 -247
- package/dist/i18n/extractor-plugin.js.map +0 -1
- package/dist/internal/data-dir.d.ts +0 -4
- package/dist/internal/data-dir.d.ts.map +0 -1
- package/dist/internal/data-dir.js +0 -52
- package/dist/internal/data-dir.js.map +0 -1
- package/dist/vite-plugins/animated.d.ts +0 -5
- package/dist/vite-plugins/animated.d.ts.map +0 -1
- package/dist/vite-plugins/animated.js +0 -325
- package/dist/vite-plugins/animated.js.map +0 -1
- package/src/i18n/binding-extractor.ts +0 -1969
- package/src/i18n/extractor-plugin.ts +0 -413
- package/src/internal/data-dir.ts +0 -70
- package/src/vite-plugins/animated.ts +0 -486
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { createConfigLoader,
|
|
2
|
-
import { error, info, isRecord, sortStrings } from "@gtkx/utils";
|
|
1
|
+
import { createConfigLoader, resourceBasePath } from "@gtkx/config/internal";
|
|
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";
|
|
5
5
|
import { parseSync } from "vite";
|
|
6
|
-
import {
|
|
7
|
-
import { listFilesRecursive } from "../internal/list-files.js";
|
|
6
|
+
import { withExclusiveLoad } from "../internal/module-loads.js";
|
|
8
7
|
import { runCliTool } from "../internal/run-cli-tool.js";
|
|
9
8
|
import { parseRuntimeImportsIn, sourceLanguage } from "../internal/source-imports.js";
|
|
10
9
|
import { createRetainedStagingDir, withStagingDir } from "../internal/staging-dir.js";
|
|
11
10
|
import { ASSET_RE } from "./asset-extensions.js";
|
|
12
|
-
import {
|
|
11
|
+
import { isBareRelativeAsset, parseIconSpecifier, parseResourceSpecifier, } from "./asset-specifier.js";
|
|
13
12
|
import { renderInitModule } from "./resource-init-module.js";
|
|
14
13
|
import { BUNDLE_FILENAME, escapeXml, fromVirtualId, ICON_NAME_SEPARATOR, isVirtual, REFRESH_EXPORT, REGISTER_REFRESH_EXPORT, REL_SEPARATOR, RESOURCE_PATH_EXPORT, toVirtualId, VIRTUAL_INIT, } from "./resource-shared.js";
|
|
15
14
|
import { stripQuery } from "./strip-query.js";
|
|
@@ -17,6 +16,7 @@ const RESOURCE_COMPILER = "glib-compile-resources";
|
|
|
17
16
|
const MANIFEST_PREFIX = "/";
|
|
18
17
|
const DEV_STAGING_PREFIX = "resources-dev";
|
|
19
18
|
const MANIFEST_FILENAME = "package.json";
|
|
19
|
+
const DATA_PREFIX = "#data/";
|
|
20
20
|
const BUNDLED_QUERY_MENTION_RE = /[?&](?:icon|resource)(?:[=&]|$)/;
|
|
21
21
|
const ICON_EXTENSIONS = new Set([".png", ".svg", ".xpm"]);
|
|
22
22
|
const ICON_CONTEXTS = new Set([
|
|
@@ -49,12 +49,7 @@ const STOCK_ICON_CONTEXTS = new Set([
|
|
|
49
49
|
]);
|
|
50
50
|
const ICON_SIZE_RE = /^([1-9]\d*)x\1(?:@[1-9]\d*)?$/;
|
|
51
51
|
const RESERVED_ICON_NAMES = new Set(["", ".", ".."]);
|
|
52
|
-
const
|
|
53
|
-
const isWithin = (root, path) => {
|
|
54
|
-
const rel = relative(root, path);
|
|
55
|
-
return rel.length > 0 && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`);
|
|
56
|
-
};
|
|
57
|
-
const isDependencyFile = (root, path) => isWithin(root, path) && relative(root, path).split(sep).includes("node_modules");
|
|
52
|
+
const isDependencyFile = (root, path) => isPathInside(root, path) && relative(root, path).split(sep).includes("node_modules");
|
|
58
53
|
const packageIdentityIn = (dir) => {
|
|
59
54
|
try {
|
|
60
55
|
const manifest = JSON.parse(readFileSync(join(dir, MANIFEST_FILENAME), "utf8"));
|
|
@@ -84,14 +79,14 @@ const validateResourcePath = (resourcePath) => {
|
|
|
84
79
|
return resourcePath;
|
|
85
80
|
};
|
|
86
81
|
const derivedResourcePath = (state, sourcePath) => {
|
|
87
|
-
if (
|
|
88
|
-
return validateResourcePath(`${state.prefix}/${
|
|
82
|
+
if (isPathInside(state.root, sourcePath) && !isDependencyFile(state.root, sourcePath)) {
|
|
83
|
+
return validateResourcePath(`${state.prefix}/${toPosixPath(relative(state.root, sourcePath))}`);
|
|
89
84
|
}
|
|
90
85
|
const owner = packageForFile(sourcePath);
|
|
91
|
-
if (owner === null || !
|
|
86
|
+
if (owner === null || !isPathInside(owner.dir, sourcePath)) {
|
|
92
87
|
throw new Error(`${sourcePath} is outside the application and does not belong to a named package`);
|
|
93
88
|
}
|
|
94
|
-
const packagePath =
|
|
89
|
+
const packagePath = toPosixPath(relative(owner.dir, sourcePath));
|
|
95
90
|
return validateResourcePath(`${state.prefix}/${owner.name}/${packagePath}`);
|
|
96
91
|
};
|
|
97
92
|
const iconExtension = (sourcePath) => {
|
|
@@ -134,7 +129,7 @@ const iconLayoutInParts = (parts, beforeIndex) => {
|
|
|
134
129
|
return isIconLayout(layout) ? layout.join("/") : iconLayoutInParts(parts, index - 1);
|
|
135
130
|
};
|
|
136
131
|
const iconLayoutFromTree = (sourcePath) => {
|
|
137
|
-
const parts =
|
|
132
|
+
const parts = toPosixPath(sourcePath).split("/");
|
|
138
133
|
return iconLayoutInParts(parts, parts.length - 2);
|
|
139
134
|
};
|
|
140
135
|
const derivedIconEntry = (state, sourcePath, requestedName) => {
|
|
@@ -159,7 +154,7 @@ const hasSideEffectIconImport = (code, id) => {
|
|
|
159
154
|
}
|
|
160
155
|
return parsed.module.staticImports.some((statement) => statement.entries.length === 0 && parseIconSpecifier(statement.moduleRequest.value) !== null);
|
|
161
156
|
};
|
|
162
|
-
const retainSideEffectIconImport = (
|
|
157
|
+
const retainSideEffectIconImport = (code, id) => hasSideEffectIconImport(code, id)
|
|
163
158
|
? { code, moduleSideEffects: true }
|
|
164
159
|
: null;
|
|
165
160
|
const compileBundle = (state, outputPath) => withStagingDir("resources", (dir) => {
|
|
@@ -225,16 +220,6 @@ const refreshRegisteredDevBundle = (state) => {
|
|
|
225
220
|
refresh();
|
|
226
221
|
}
|
|
227
222
|
};
|
|
228
|
-
const scanDataAssets = (dataDir) => listFilesRecursive(dataDir, (name) => ASSET_RE.test(name));
|
|
229
|
-
const primeLegacyDevBundle = (state) => {
|
|
230
|
-
if (state.dataDir === null) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
for (const { absPath, rel } of scanDataAssets(state.dataDir)) {
|
|
234
|
-
registerEntry(state, absPath, rel);
|
|
235
|
-
}
|
|
236
|
-
compileDevBundle(state);
|
|
237
|
-
};
|
|
238
223
|
const registerDevAsset = (state) => {
|
|
239
224
|
if (entriesSignature(state) !== state.compiledSignature) {
|
|
240
225
|
compileDevBundle(state);
|
|
@@ -268,7 +253,7 @@ const activateEntry = (state, entry) => {
|
|
|
268
253
|
state.sourcePaths.add(entry.sourcePath);
|
|
269
254
|
return entry;
|
|
270
255
|
};
|
|
271
|
-
const isDeclarativeImporter = (state, importer) => !state.isBuild &&
|
|
256
|
+
const isDeclarativeImporter = (state, importer) => !state.isBuild && importer !== undefined;
|
|
272
257
|
const setSourceAvailability = (state, file, isAvailable) => {
|
|
273
258
|
if (isAvailable) {
|
|
274
259
|
state.missingSourcePaths.delete(file);
|
|
@@ -394,17 +379,6 @@ const resolveIconEntry = async (ctx, state, request) => {
|
|
|
394
379
|
iconName: derived.iconName,
|
|
395
380
|
};
|
|
396
381
|
};
|
|
397
|
-
const resolveLegacyAssetEntry = async (ctx, state, request) => {
|
|
398
|
-
const resolved = await ctx.resolve(request.source, request.importer, { ...request.options, skipSelf: true });
|
|
399
|
-
if (!resolved || resolved.external) {
|
|
400
|
-
return undefined;
|
|
401
|
-
}
|
|
402
|
-
const sourcePath = stripQuery(resolved.id);
|
|
403
|
-
if (!isAbsolute(sourcePath)) {
|
|
404
|
-
return undefined;
|
|
405
|
-
}
|
|
406
|
-
return registerEntry(state, sourcePath, request.source.slice(DATA_PREFIX.length));
|
|
407
|
-
};
|
|
408
382
|
const loadInitModule = (state) => {
|
|
409
383
|
if (state.isBuild) {
|
|
410
384
|
if (state.bundleReferenceId === null) {
|
|
@@ -479,8 +453,7 @@ const loadAssetModule = (state, virtualId) => {
|
|
|
479
453
|
const { absPath, iconName, rel } = virtualAssetMetadata(virtualId);
|
|
480
454
|
const resourcePath = validateResourcePath(rel);
|
|
481
455
|
const { entry, isRegistered } = loadedResourceEntry(state, absPath, resourcePath);
|
|
482
|
-
const
|
|
483
|
-
const defaultValue = iconName ?? (state.isV2 ? entry.resourcePath : uri);
|
|
456
|
+
const defaultValue = iconName ?? entry.resourcePath;
|
|
484
457
|
compileLoadedDevAsset(state, isRegistered);
|
|
485
458
|
return [
|
|
486
459
|
...assetModuleImports(iconName),
|
|
@@ -524,17 +497,17 @@ const bundledSpecifiersIn = (imports) => new Set(imports
|
|
|
524
497
|
.map((entry) => entry.source));
|
|
525
498
|
const isSourceModule = (file) => sourceLanguage(file) !== undefined;
|
|
526
499
|
const isBundledSource = (source) => parseResourceSpecifier(source) !== null || parseIconSpecifier(source) !== null;
|
|
527
|
-
const
|
|
500
|
+
const validateUnbundledSource = (source) => {
|
|
528
501
|
if (isLegacyDataSpecifier(source)) {
|
|
529
502
|
throw new Error(`${JSON.stringify(source)} uses the legacy #data asset form`);
|
|
530
503
|
}
|
|
531
|
-
|
|
504
|
+
rejectInvalidSpecifier(source);
|
|
532
505
|
};
|
|
533
506
|
const resolvedModuleDependency = async (ctx, source, importer) => {
|
|
534
507
|
if (isBundledSource(source)) {
|
|
535
508
|
return null;
|
|
536
509
|
}
|
|
537
|
-
|
|
510
|
+
validateUnbundledSource(source);
|
|
538
511
|
const resolved = await ctx.resolve(source, importer, { skipSelf: true });
|
|
539
512
|
if (resolved === null) {
|
|
540
513
|
throw new Error(`${JSON.stringify(source)} could not be resolved from ${importer}`);
|
|
@@ -554,7 +527,7 @@ const resolvedModuleDependencies = async (ctx, imports, importer) => {
|
|
|
554
527
|
const importerReconciliation = async (ctx, state, id) => {
|
|
555
528
|
const file = stripQuery(id);
|
|
556
529
|
const key = importerKey(file);
|
|
557
|
-
if (
|
|
530
|
+
if (state.isBuild || !isSourceModule(file)) {
|
|
558
531
|
return null;
|
|
559
532
|
}
|
|
560
533
|
const imports = parseRuntimeImportsIn(file);
|
|
@@ -708,27 +681,14 @@ const forgetImporterDeclarations = (state, importer) => {
|
|
|
708
681
|
state.declaredEntries.delete(importer);
|
|
709
682
|
state.declaredIcons.delete(importer);
|
|
710
683
|
};
|
|
711
|
-
const
|
|
712
|
-
const clone = new Map();
|
|
713
|
-
for (const [key, values] of source) {
|
|
714
|
-
clone.set(key, new Set(values));
|
|
715
|
-
}
|
|
716
|
-
return clone;
|
|
717
|
-
};
|
|
718
|
-
const cloneDeclarationMap = (source) => {
|
|
719
|
-
const clone = new Map();
|
|
720
|
-
for (const [key, declarations] of source) {
|
|
721
|
-
clone.set(key, new Map(declarations));
|
|
722
|
-
}
|
|
723
|
-
return clone;
|
|
724
|
-
};
|
|
684
|
+
const cloneMapValues = (source, clone) => new Map([...source].map(([key, value]) => [key, clone(value)]));
|
|
725
685
|
const reconciliationCandidate = (state) => ({
|
|
726
686
|
...state,
|
|
727
|
-
bundledSpecifiers:
|
|
728
|
-
moduleDependencies:
|
|
729
|
-
prunedDependencies:
|
|
730
|
-
declaredEntries:
|
|
731
|
-
declaredIcons:
|
|
687
|
+
bundledSpecifiers: cloneMapValues(state.bundledSpecifiers, (values) => new Set(values)),
|
|
688
|
+
moduleDependencies: cloneMapValues(state.moduleDependencies, (values) => new Set(values)),
|
|
689
|
+
prunedDependencies: cloneMapValues(state.prunedDependencies, (values) => new Set(values)),
|
|
690
|
+
declaredEntries: cloneMapValues(state.declaredEntries, (entries) => new Map(entries)),
|
|
691
|
+
declaredIcons: cloneMapValues(state.declaredIcons, (entries) => new Map(entries)),
|
|
732
692
|
missingSourcePaths: new Set(state.missingSourcePaths),
|
|
733
693
|
});
|
|
734
694
|
const storeBundledSpecifiers = (state, importer, specifiers) => {
|
|
@@ -808,7 +768,7 @@ const commitReconciliation = (state, candidate) => {
|
|
|
808
768
|
state.sourcePaths = candidate.sourcePaths;
|
|
809
769
|
state.iconOwners = candidate.iconOwners;
|
|
810
770
|
};
|
|
811
|
-
const
|
|
771
|
+
const reconcileImporter = async (ctx, state, id) => {
|
|
812
772
|
const reconciliation = await importerReconciliation(ctx, state, id);
|
|
813
773
|
if (reconciliation === null) {
|
|
814
774
|
return;
|
|
@@ -824,7 +784,6 @@ const resolveResourceConfig = async (state, config, loadConfig) => {
|
|
|
824
784
|
const loaded = await loadConfig.load(config.root ?? process.cwd());
|
|
825
785
|
state.prefix = resourceBasePath(loaded.config.applicationId);
|
|
826
786
|
state.root = loaded.root;
|
|
827
|
-
state.isV2 = resolveFuture(loaded.config.future).isResourceImported;
|
|
828
787
|
return {
|
|
829
788
|
assetsInclude: [ASSET_RE],
|
|
830
789
|
};
|
|
@@ -882,12 +841,6 @@ const attachResourceWatcher = (state, server) => {
|
|
|
882
841
|
const applyResolvedConfig = (state, config) => {
|
|
883
842
|
state.isBuild = config.command === "build";
|
|
884
843
|
state.root = config.root;
|
|
885
|
-
state.dataDir = null;
|
|
886
|
-
if (state.isBuild || state.isV2) {
|
|
887
|
-
return;
|
|
888
|
-
}
|
|
889
|
-
const relativeDataDir = resolveDataDir(config.root);
|
|
890
|
-
state.dataDir = relativeDataDir === null ? null : join(config.root, relativeDataDir);
|
|
891
844
|
};
|
|
892
845
|
const loadResourceModule = (state, id) => {
|
|
893
846
|
if (id === VIRTUAL_INIT) {
|
|
@@ -899,7 +852,7 @@ const loadResourceModule = (state, id) => {
|
|
|
899
852
|
return loadAssetModule(state, id);
|
|
900
853
|
};
|
|
901
854
|
const isLegacyDataSpecifier = (source) => source.startsWith(DATA_PREFIX) && ASSET_RE.test(stripQuery(source));
|
|
902
|
-
const
|
|
855
|
+
const rejectInvalidSpecifier = (source) => {
|
|
903
856
|
if (BUNDLED_QUERY_MENTION_RE.test(source)) {
|
|
904
857
|
throw new Error(`${JSON.stringify(source)} is not a valid bundled asset import; use ?resource, ` +
|
|
905
858
|
"?resource=/absolute/path, ?icon, or ?icon=name");
|
|
@@ -937,7 +890,7 @@ const resolveIconResourceId = async (ctx, state, request) => {
|
|
|
937
890
|
? undefined
|
|
938
891
|
: { id: virtualIconId(resolved), moduleSideEffects: true };
|
|
939
892
|
};
|
|
940
|
-
const
|
|
893
|
+
const resolveBundledResourceId = async (ctx, state, request) => {
|
|
941
894
|
if (isLegacyDataSpecifier(request.source)) {
|
|
942
895
|
throw new Error(`${JSON.stringify(request.source)} uses the legacy #data asset form; import it relatively with ` +
|
|
943
896
|
"?resource or ?url");
|
|
@@ -952,30 +905,14 @@ const resolveV2ResourceId = async (ctx, state, request) => {
|
|
|
952
905
|
trackBundledSpecifier(state, request.importer, request.source);
|
|
953
906
|
return resolved;
|
|
954
907
|
}
|
|
955
|
-
|
|
908
|
+
rejectInvalidSpecifier(request.source);
|
|
956
909
|
return undefined;
|
|
957
910
|
};
|
|
958
|
-
const resolveLegacyResourceId = async (ctx, state, request) => {
|
|
959
|
-
if (BUNDLED_QUERY_MENTION_RE.test(request.source)) {
|
|
960
|
-
throw new Error(`${JSON.stringify(request.source)} requires future.v2ResourceImports`);
|
|
961
|
-
}
|
|
962
|
-
if (!isDataAsset(request.source)) {
|
|
963
|
-
return undefined;
|
|
964
|
-
}
|
|
965
|
-
const entry = await resolveLegacyAssetEntry(ctx, state, request);
|
|
966
|
-
return entry === undefined ? undefined : virtualAssetId(entry);
|
|
967
|
-
};
|
|
968
911
|
const resolveResourceId = (ctx, state, request) => {
|
|
969
912
|
if (request.source === VIRTUAL_INIT) {
|
|
970
913
|
return Promise.resolve(VIRTUAL_INIT);
|
|
971
914
|
}
|
|
972
|
-
return state
|
|
973
|
-
? resolveV2ResourceId(ctx, state, request)
|
|
974
|
-
: resolveLegacyResourceId(ctx, state, request);
|
|
975
|
-
};
|
|
976
|
-
const configureResourceServer = (state, server) => {
|
|
977
|
-
attachResourceWatcher(state, server);
|
|
978
|
-
primeLegacyDevBundle(state);
|
|
915
|
+
return resolveBundledResourceId(ctx, state, request);
|
|
979
916
|
};
|
|
980
917
|
const createResourcesPlugin = (state, loadConfig) => ({
|
|
981
918
|
name: "gtkx:resources",
|
|
@@ -986,7 +923,7 @@ const createResourcesPlugin = (state, loadConfig) => ({
|
|
|
986
923
|
applyResolvedConfig(state, config);
|
|
987
924
|
},
|
|
988
925
|
configureServer: (server) => {
|
|
989
|
-
|
|
926
|
+
attachResourceWatcher(state, server);
|
|
990
927
|
},
|
|
991
928
|
buildStart() {
|
|
992
929
|
if (state.isBuild && state.bundleReferenceId === null) {
|
|
@@ -1004,8 +941,8 @@ const createResourcesPlugin = (state, loadConfig) => ({
|
|
|
1004
941
|
return loadResourceModule(state, id);
|
|
1005
942
|
},
|
|
1006
943
|
async transform(code, id) {
|
|
1007
|
-
await
|
|
1008
|
-
return retainSideEffectIconImport(
|
|
944
|
+
await withExclusiveLoad(state, () => reconcileImporter(this, state, id));
|
|
945
|
+
return retainSideEffectIconImport(code, id);
|
|
1009
946
|
},
|
|
1010
947
|
generateBundle(_options, bundle) {
|
|
1011
948
|
finalizeBuildBundle(this, bundle, state);
|
|
@@ -1019,7 +956,6 @@ function gtkxResources(loadConfig = createConfigLoader(), entryPath) {
|
|
|
1019
956
|
prefix: "",
|
|
1020
957
|
root: "",
|
|
1021
958
|
isBuild: false,
|
|
1022
|
-
isV2: false,
|
|
1023
959
|
entries: new Map(),
|
|
1024
960
|
bundledSpecifiers: new Map(),
|
|
1025
961
|
moduleDependencies: new Map(),
|
|
@@ -1033,7 +969,6 @@ function gtkxResources(loadConfig = createConfigLoader(), entryPath) {
|
|
|
1033
969
|
devBundlePath: "",
|
|
1034
970
|
server: null,
|
|
1035
971
|
compiledSignature: "",
|
|
1036
|
-
dataDir: null,
|
|
1037
972
|
bundleReferenceId: null,
|
|
1038
973
|
iconOwners: new Map(),
|
|
1039
974
|
};
|