@gtkx/cli 1.0.0-rc.3 → 1.0.0
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 +8 -9
- package/dist/builder.d.ts +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +2 -1
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/codegen/freshness.d.ts.map +1 -1
- package/dist/codegen/freshness.js +3 -6
- package/dist/codegen/freshness.js.map +1 -1
- package/dist/codegen/run-codegen.d.ts +4 -4
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +15 -14
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/codegen/store-resolver.d.ts +1 -3
- package/dist/codegen/store-resolver.d.ts.map +1 -1
- package/dist/codegen/store-resolver.js +13 -32
- package/dist/codegen/store-resolver.js.map +1 -1
- package/dist/commands/build.js +1 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/codegen.js +1 -1
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +4 -2
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/docs.js +13 -13
- package/dist/commands/docs.js.map +1 -1
- package/dist/dev/entry-env.d.ts +3 -0
- package/dist/dev/entry-env.d.ts.map +1 -0
- package/dist/dev/entry-env.js +3 -0
- package/dist/dev/entry-env.js.map +1 -0
- package/dist/dev/runner-deps.d.ts.map +1 -1
- package/dist/dev/runner-deps.js +1 -0
- package/dist/dev/runner-deps.js.map +1 -1
- package/dist/dev/runner-main.d.ts.map +1 -1
- package/dist/dev/runner-main.js +3 -3
- package/dist/dev/runner-main.js.map +1 -1
- package/dist/dev/runner.d.ts +1 -0
- package/dist/dev/runner.d.ts.map +1 -1
- package/dist/dev/runner.js +22 -12
- package/dist/dev/runner.js.map +1 -1
- package/dist/dev/supervisor.d.ts +10 -3
- package/dist/dev/supervisor.d.ts.map +1 -1
- package/dist/dev/supervisor.js +37 -18
- package/dist/dev/supervisor.js.map +1 -1
- package/dist/internal/application-args.d.ts +6 -0
- package/dist/internal/application-args.d.ts.map +1 -0
- package/dist/internal/application-args.js +10 -0
- package/dist/internal/application-args.js.map +1 -0
- package/dist/internal/errors.d.ts +1 -2
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/run-cli-tool.d.ts +10 -0
- package/dist/internal/run-cli-tool.d.ts.map +1 -0
- package/dist/internal/run-cli-tool.js +15 -0
- package/dist/internal/run-cli-tool.js.map +1 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/handlers.d.ts +1 -1
- package/dist/mcp/handlers.d.ts.map +1 -1
- package/dist/mcp/handlers.js +79 -42
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/serialize-widget.d.ts +2 -2
- package/dist/mcp/serialize-widget.d.ts.map +1 -1
- package/dist/mcp/serialize-widget.js +47 -17
- package/dist/mcp/serialize-widget.js.map +1 -1
- package/dist/mcp/widget-properties.d.ts +6 -0
- package/dist/mcp/widget-properties.d.ts.map +1 -0
- package/dist/mcp/widget-properties.js +102 -0
- package/dist/mcp/widget-properties.js.map +1 -0
- package/dist/refresh-runtime.d.ts +0 -10
- package/dist/refresh-runtime.d.ts.map +1 -1
- package/dist/refresh-runtime.js +0 -17
- package/dist/refresh-runtime.js.map +1 -1
- package/dist/settings/compile.d.ts.map +1 -1
- package/dist/settings/compile.js +8 -12
- package/dist/settings/compile.js.map +1 -1
- package/dist/settings/schema.d.ts +1 -1
- package/dist/settings/schema.d.ts.map +1 -1
- package/dist/settings/schema.js +1 -1
- package/dist/settings/schema.js.map +1 -1
- package/dist/vite-plugins/asset-emitter.d.ts +9 -0
- package/dist/vite-plugins/asset-emitter.d.ts.map +1 -0
- package/dist/vite-plugins/asset-emitter.js +2 -0
- package/dist/vite-plugins/asset-emitter.js.map +1 -0
- package/dist/vite-plugins/asset-extensions.d.ts +1 -2
- package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
- package/dist/vite-plugins/asset-extensions.js +1 -1
- package/dist/vite-plugins/asset-extensions.js.map +1 -1
- package/dist/vite-plugins/built-url.d.ts.map +1 -1
- package/dist/vite-plugins/built-url.js +14 -10
- package/dist/vite-plugins/built-url.js.map +1 -1
- package/dist/vite-plugins/ensure-store.d.ts +4 -0
- package/dist/vite-plugins/ensure-store.d.ts.map +1 -0
- package/dist/vite-plugins/ensure-store.js +10 -0
- package/dist/vite-plugins/ensure-store.js.map +1 -0
- package/dist/vite-plugins/icons.d.ts.map +1 -1
- package/dist/vite-plugins/icons.js.map +1 -1
- package/dist/vite-plugins/react-compiler.d.ts +1 -1
- package/dist/vite-plugins/react-compiler.d.ts.map +1 -1
- package/dist/vite-plugins/react-compiler.js.map +1 -1
- package/dist/vite-plugins/resources.d.ts +1 -1
- package/dist/vite-plugins/resources.d.ts.map +1 -1
- package/dist/vite-plugins/resources.js +6 -15
- package/dist/vite-plugins/resources.js.map +1 -1
- package/dist/vite-plugins/settings.js.map +1 -1
- package/dist/vite-plugins/undeclared-library.d.ts +1 -1
- package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
- package/dist/vite-plugins/undeclared-library.js.map +1 -1
- package/dist/vite-plugins/worker.d.ts +4 -0
- package/dist/vite-plugins/worker.d.ts.map +1 -0
- package/dist/vite-plugins/worker.js +136 -0
- package/dist/vite-plugins/worker.js.map +1 -0
- package/dist/vitest-plugin.d.ts +4 -3
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +11 -4
- package/dist/vitest-plugin.js.map +1 -1
- package/env.d.ts +25 -0
- package/package.json +17 -13
- package/src/builder.ts +3 -2
- package/src/cli.ts +4 -2
- package/src/codegen/freshness.ts +3 -8
- package/src/codegen/run-codegen.ts +19 -19
- package/src/codegen/store-resolver.ts +14 -40
- package/src/commands/build.ts +1 -1
- package/src/commands/codegen.ts +1 -1
- package/src/commands/dev.ts +4 -2
- package/src/commands/docs.ts +15 -15
- package/src/dev/entry-env.ts +3 -0
- package/src/dev/runner-deps.ts +1 -0
- package/src/dev/runner-main.ts +3 -4
- package/src/dev/runner.ts +44 -13
- package/src/dev/supervisor.ts +70 -27
- package/src/internal/application-args.ts +13 -0
- package/src/internal/errors.ts +1 -1
- package/src/internal/run-cli-tool.ts +22 -0
- package/src/internal.ts +2 -0
- package/src/mcp/client.ts +1 -1
- package/src/mcp/handlers.ts +124 -57
- package/src/mcp/index.ts +1 -0
- package/src/mcp/serialize-widget.ts +71 -21
- package/src/mcp/widget-properties.ts +153 -0
- package/src/refresh-runtime.ts +0 -17
- package/src/settings/compile.ts +8 -11
- package/src/settings/schema.ts +2 -2
- package/src/vite-plugins/asset-emitter.ts +5 -0
- package/src/vite-plugins/asset-extensions.ts +1 -1
- package/src/vite-plugins/built-url.ts +19 -13
- package/src/vite-plugins/ensure-store.ts +14 -0
- package/src/vite-plugins/icons.ts +2 -5
- package/src/vite-plugins/react-compiler.ts +3 -2
- package/src/vite-plugins/resources.ts +10 -19
- package/src/vite-plugins/settings.ts +2 -2
- package/src/vite-plugins/undeclared-library.ts +1 -1
- package/src/vite-plugins/worker.ts +235 -0
- package/src/vitest-plugin.ts +12 -4
- package/dist/internal/resolve-cli-tool.d.ts +0 -3
- package/dist/internal/resolve-cli-tool.d.ts.map +0 -1
- package/dist/internal/resolve-cli-tool.js +0 -27
- package/dist/internal/resolve-cli-tool.js.map +0 -1
- package/src/internal/resolve-cli-tool.ts +0 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-widget.d.ts","sourceRoot":"","sources":["../../src/mcp/serialize-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"serialize-widget.d.ts","sourceRoot":"","sources":["../../src/mcp/serialize-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAA8C,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEvG,KAAK,gBAAgB,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC;AAEvD,KAAK,gBAAgB,GAAG;IACpB,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,cAAc,GAAG,MAAM,CAAC;IAC7C,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACpD,CAAC;AAyDF,QAAA,MAAM,eAAe,GACjB,QAAQ,GAAG,CAAC,MAAM,EAClB,WAAW,gBAAgB,EAC3B,SAAS,gBAAgB,EACzB,iBAAgC,KACjC,gBAkBF,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,23 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
import { DEFAULT_SUBTREE_DEPTH, MAX_SUBTREE_WIDGETS } from "@gtkx/mcp/internal";
|
|
2
|
+
const getChildren = (widget) => {
|
|
2
3
|
const children = [];
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
child = child.getNextSibling();
|
|
8
|
-
}
|
|
4
|
+
let child = widget.getFirstChild();
|
|
5
|
+
while (child) {
|
|
6
|
+
children.push(child);
|
|
7
|
+
child = child.getNextSibling();
|
|
9
8
|
}
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
return children;
|
|
10
|
+
};
|
|
11
|
+
const createNode = (widget, expansion) => ({
|
|
12
|
+
id: expansion.resolveId(widget),
|
|
13
|
+
type: widget.constructor.name,
|
|
14
|
+
role: expansion.testing.formatRole(widget.getAccessibleRole()),
|
|
15
|
+
name: widget.getName() || null,
|
|
16
|
+
text: expansion.testing.getWidgetText(widget),
|
|
17
|
+
isSensitive: widget.getSensitive(),
|
|
18
|
+
isVisible: widget.getVisible(),
|
|
19
|
+
cssClasses: widget.getCssClasses(),
|
|
20
|
+
children: [],
|
|
21
|
+
});
|
|
22
|
+
const expandNode = (expansion, parent) => {
|
|
23
|
+
const children = getChildren(parent.widget);
|
|
24
|
+
const canDescend = parent.depth < expansion.maxDepth;
|
|
25
|
+
const shownCount = canDescend ? Math.min(children.length, expansion.budget) : 0;
|
|
26
|
+
expansion.budget -= shownCount;
|
|
27
|
+
for (const child of children.slice(0, shownCount)) {
|
|
28
|
+
const node = createNode(child, expansion);
|
|
29
|
+
parent.node.children.push(node);
|
|
30
|
+
expansion.pending.push({ depth: parent.depth + 1, node, widget: child });
|
|
31
|
+
}
|
|
32
|
+
if (shownCount < children.length) {
|
|
33
|
+
parent.node.hiddenChildren = children.length - shownCount;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const serializeWidget = (widget, resolveId, testing, maxDepth = DEFAULT_SUBTREE_DEPTH) => {
|
|
37
|
+
const expansion = {
|
|
38
|
+
budget: MAX_SUBTREE_WIDGETS - 1,
|
|
39
|
+
maxDepth,
|
|
40
|
+
pending: [],
|
|
41
|
+
resolveId,
|
|
42
|
+
testing,
|
|
20
43
|
};
|
|
44
|
+
const root = createNode(widget, expansion);
|
|
45
|
+
let parent = { depth: 0, node: root, widget };
|
|
46
|
+
while (parent !== undefined) {
|
|
47
|
+
expandNode(expansion, parent);
|
|
48
|
+
parent = expansion.pending.shift();
|
|
49
|
+
}
|
|
50
|
+
return root;
|
|
21
51
|
};
|
|
22
52
|
export { serializeWidget };
|
|
23
53
|
//# sourceMappingURL=serialize-widget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-widget.js","sourceRoot":"","sources":["../../src/mcp/serialize-widget.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialize-widget.js","sourceRoot":"","sources":["../../src/mcp/serialize-widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAyB,MAAM,oBAAoB,CAAC;AAuBvG,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAgB,EAAE;IACrD,MAAM,QAAQ,GAAiB,EAAE,CAAC;IAClC,IAAI,KAAK,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IAEnC,OAAO,KAAK,EAAE,CAAC;QACX,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,KAAK,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAE,SAAoB,EAAoB,EAAE,CAAC,CAAC;IAChF,EAAE,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI;IAC7B,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;IAC9D,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI;IAC9B,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC;IAC7C,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE;IAClC,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE;IAC9B,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE;IAClC,QAAQ,EAAE,EAAE;CAC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AAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC3C,IAAI,MAAM,GAA8B,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAEzE,OAAO,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC9B,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAyB,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { DEFAULT_SUBTREE_DEPTH, MAX_SUBTREE_WIDGETS, type SerializedWidget } from \"@gtkx/mcp/internal\";\n\ntype WidgetIdResolver = (widget: Gtk.Widget) => string;\n\ntype WidgetFormatting = {\n formatRole(role: Gtk.AccessibleRole): string;\n getWidgetText(widget: Gtk.Widget): string | null;\n};\n\ntype PendingWidget = {\n depth: number;\n node: SerializedWidget;\n widget: Gtk.Widget;\n};\n\ntype Expansion = {\n budget: number;\n maxDepth: number;\n pending: PendingWidget[];\n resolveId: WidgetIdResolver;\n testing: WidgetFormatting;\n};\n\nconst getChildren = (widget: Gtk.Widget): Gtk.Widget[] => {\n const children: Gtk.Widget[] = [];\n let child = widget.getFirstChild();\n\n while (child) {\n children.push(child);\n child = child.getNextSibling();\n }\n\n return children;\n};\n\nconst createNode = (widget: Gtk.Widget, expansion: Expansion): SerializedWidget => ({\n id: expansion.resolveId(widget),\n type: widget.constructor.name,\n role: expansion.testing.formatRole(widget.getAccessibleRole()),\n name: widget.getName() || null,\n text: expansion.testing.getWidgetText(widget),\n isSensitive: widget.getSensitive(),\n isVisible: widget.getVisible(),\n cssClasses: widget.getCssClasses(),\n children: [],\n});\n\nconst expandNode = (expansion: Expansion, parent: PendingWidget): void => {\n const children = getChildren(parent.widget);\n const canDescend = parent.depth < expansion.maxDepth;\n const shownCount = canDescend ? Math.min(children.length, expansion.budget) : 0;\n expansion.budget -= shownCount;\n\n for (const child of children.slice(0, shownCount)) {\n const node = createNode(child, expansion);\n parent.node.children.push(node);\n expansion.pending.push({ depth: parent.depth + 1, node, widget: child });\n }\n\n if (shownCount < children.length) {\n parent.node.hiddenChildren = children.length - shownCount;\n }\n};\n\nconst serializeWidget = (\n widget: Gtk.Widget,\n resolveId: WidgetIdResolver,\n testing: WidgetFormatting,\n maxDepth = DEFAULT_SUBTREE_DEPTH,\n): SerializedWidget => {\n const expansion: Expansion = {\n budget: MAX_SUBTREE_WIDGETS - 1,\n maxDepth,\n pending: [],\n resolveId,\n testing,\n };\n\n const root = createNode(widget, expansion);\n let parent: PendingWidget | undefined = { depth: 0, node: root, widget };\n\n while (parent !== undefined) {\n expandNode(expansion, parent);\n parent = expansion.pending.shift();\n }\n\n return root;\n};\n\nexport { serializeWidget, type WidgetFormatting };\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
+
import { type SerializedProperty } from "@gtkx/mcp/internal";
|
|
3
|
+
import type { WidgetRegistry } from "./widget-registry.js";
|
|
4
|
+
declare function readWidgetProperties(widget: Gtk.Widget, properties: string[], registry: WidgetRegistry): Record<string, SerializedProperty>;
|
|
5
|
+
export { readWidgetProperties };
|
|
6
|
+
//# sourceMappingURL=widget-properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-properties.d.ts","sourceRoot":"","sources":["../../src/mcp/widget-properties.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAapF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAyH3D,iBAAS,oBAAoB,CACzB,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,UAAU,EAAE,MAAM,EAAE,EACpB,QAAQ,EAAE,cAAc,GACzB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAUpC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as GObject from "@gtkx/gi/gobject";
|
|
2
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
+
import { propertyNotFoundError } from "@gtkx/mcp/internal";
|
|
4
|
+
import { getHandle, getInstanceType, TYPE_ENUM, TYPE_FLAGS, typeIsA, typeName, } from "@gtkx/runtime";
|
|
5
|
+
import { fromValue, getValueType } from "@gtkx/runtime/internal";
|
|
6
|
+
import { camelCase, errorMessage, kebabCase } from "@gtkx/utils";
|
|
7
|
+
const SCALAR_TYPES = new Set(["string", "number", "boolean"]);
|
|
8
|
+
const canonicalName = (name) => kebabCase(name).replaceAll("_", "-");
|
|
9
|
+
const widgetTypeName = (widget) => typeName(getInstanceType(widget)) ?? widget.constructor.name;
|
|
10
|
+
const byName = (left, right) => left.localeCompare(right);
|
|
11
|
+
const isScalar = (value) => value === null || SCALAR_TYPES.has(typeof value);
|
|
12
|
+
function prototypesFor(widget) {
|
|
13
|
+
const prototypes = [];
|
|
14
|
+
let prototype = Object.getPrototypeOf(widget);
|
|
15
|
+
while (prototype !== null && prototype !== Object.prototype) {
|
|
16
|
+
prototypes.push(prototype);
|
|
17
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
18
|
+
}
|
|
19
|
+
return prototypes;
|
|
20
|
+
}
|
|
21
|
+
function getAccessor(widget, member) {
|
|
22
|
+
for (const prototype of prototypesFor(widget)) {
|
|
23
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, member);
|
|
24
|
+
if (descriptor !== undefined) {
|
|
25
|
+
return descriptor;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
function getReadableNames(prototype) {
|
|
31
|
+
const descriptors = Object.entries(Object.getOwnPropertyDescriptors(prototype));
|
|
32
|
+
return descriptors.filter(([, descriptor]) => descriptor.get !== undefined).map(([member]) => kebabCase(member));
|
|
33
|
+
}
|
|
34
|
+
function readablePropertyNames(widget) {
|
|
35
|
+
const names = prototypesFor(widget).flatMap((prototype) => getReadableNames(prototype));
|
|
36
|
+
return [...new Set(names)].toSorted(byName);
|
|
37
|
+
}
|
|
38
|
+
const requireReadableProperty = (widget, property) => {
|
|
39
|
+
if (getAccessor(widget, camelCase(property))?.get !== undefined) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
throw propertyNotFoundError(widgetTypeName(widget), property, readablePropertyNames(widget));
|
|
43
|
+
};
|
|
44
|
+
function readNativeProperty(widget, property) {
|
|
45
|
+
const value = new GObject.Value();
|
|
46
|
+
widget.getProperty(property, value);
|
|
47
|
+
const handle = getHandle(value);
|
|
48
|
+
return { type: getValueType(handle), handle };
|
|
49
|
+
}
|
|
50
|
+
function describeObjectValue(value, registry) {
|
|
51
|
+
if (typeof value !== "object" || value === null) {
|
|
52
|
+
return { value: String(value) };
|
|
53
|
+
}
|
|
54
|
+
const name = typeName(getInstanceType(value)) ?? value.constructor.name;
|
|
55
|
+
if (!(value instanceof Gtk.Widget)) {
|
|
56
|
+
return { value: name };
|
|
57
|
+
}
|
|
58
|
+
registry.register(value);
|
|
59
|
+
return { value: name, widgetId: registry.getOrCreateId(value) };
|
|
60
|
+
}
|
|
61
|
+
function representValue(value, registry) {
|
|
62
|
+
if (isScalar(value)) {
|
|
63
|
+
return { value };
|
|
64
|
+
}
|
|
65
|
+
if (typeof value === "bigint") {
|
|
66
|
+
return { value: value.toString() };
|
|
67
|
+
}
|
|
68
|
+
if (Array.isArray(value)) {
|
|
69
|
+
return { value: value.map(String) };
|
|
70
|
+
}
|
|
71
|
+
return describeObjectValue(value, registry);
|
|
72
|
+
}
|
|
73
|
+
function representNativeProperty(native, registry) {
|
|
74
|
+
if (typeIsA(native.type, TYPE_ENUM)) {
|
|
75
|
+
return { value: GObject.enumToString(native.type, Number(fromValue(native.handle))) };
|
|
76
|
+
}
|
|
77
|
+
if (typeIsA(native.type, TYPE_FLAGS)) {
|
|
78
|
+
return { value: GObject.flagsToString(native.type, Number(fromValue(native.handle))) };
|
|
79
|
+
}
|
|
80
|
+
return representValue(fromValue(native.handle), registry);
|
|
81
|
+
}
|
|
82
|
+
function serializeProperty(widget, property, registry) {
|
|
83
|
+
const native = readNativeProperty(widget, property);
|
|
84
|
+
const type = typeName(native.type) ?? String(native.type);
|
|
85
|
+
try {
|
|
86
|
+
return { type, ...representNativeProperty(native, registry) };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return { type, value: null, note: `cannot be represented over MCP: ${errorMessage(error)}` };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function readWidgetProperties(widget, properties, registry) {
|
|
93
|
+
const values = {};
|
|
94
|
+
for (const name of properties) {
|
|
95
|
+
const property = canonicalName(name);
|
|
96
|
+
requireReadableProperty(widget, property);
|
|
97
|
+
values[property] = serializeProperty(widget, property, registry);
|
|
98
|
+
}
|
|
99
|
+
return values;
|
|
100
|
+
}
|
|
101
|
+
export { readWidgetProperties };
|
|
102
|
+
//# sourceMappingURL=widget-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-properties.js","sourceRoot":"","sources":["../../src/mcp/widget-properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAA2B,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAEH,SAAS,EACT,eAAe,EAEf,SAAS,EACT,UAAU,EACV,OAAO,EACP,QAAQ,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,YAAY,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,CAAC;IAEtD,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,uBAAuB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC1C,MAAM,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { propertyNotFoundError, type SerializedProperty } from \"@gtkx/mcp/internal\";\nimport {\n type ExternalObject,\n getHandle,\n getInstanceType,\n type Handle,\n TYPE_ENUM,\n TYPE_FLAGS,\n typeIsA,\n typeName,\n} from \"@gtkx/runtime\";\nimport { fromValue, getValueType } from \"@gtkx/runtime/internal\";\nimport { camelCase, errorMessage, kebabCase } from \"@gtkx/utils\";\nimport type { WidgetRegistry } from \"./widget-registry.js\";\n\ntype PropertyRepresentation = Omit<SerializedProperty, \"type\">;\ntype NativeProperty = { type: bigint; handle: ExternalObject<Handle> };\n\nconst SCALAR_TYPES: Set<string> = new Set([\"string\", \"number\", \"boolean\"]);\n\nconst canonicalName = (name: string): string => kebabCase(name).replaceAll(\"_\", \"-\");\nconst widgetTypeName = (widget: Gtk.Widget): string => typeName(getInstanceType(widget)) ?? widget.constructor.name;\nconst byName = (left: string, right: string): number => left.localeCompare(right);\n\nconst isScalar = (value: unknown): value is string | number | boolean | null =>\n value === null || SCALAR_TYPES.has(typeof value);\n\nfunction prototypesFor(widget: Gtk.Widget): object[] {\n const prototypes: object[] = [];\n let prototype = Object.getPrototypeOf(widget) as object | null;\n\n while (prototype !== null && prototype !== Object.prototype) {\n prototypes.push(prototype);\n prototype = Object.getPrototypeOf(prototype) as object | null;\n }\n\n return prototypes;\n}\n\nfunction getAccessor(widget: Gtk.Widget, member: string): PropertyDescriptor | undefined {\n for (const prototype of prototypesFor(widget)) {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, member);\n\n if (descriptor !== undefined) {\n return descriptor;\n }\n }\n\n return undefined;\n}\n\nfunction getReadableNames(prototype: object): string[] {\n const descriptors = Object.entries(Object.getOwnPropertyDescriptors(prototype));\n\n return descriptors.filter(([, descriptor]) => descriptor.get !== undefined).map(([member]) => kebabCase(member));\n}\n\nfunction readablePropertyNames(widget: Gtk.Widget): string[] {\n const names = prototypesFor(widget).flatMap((prototype) => getReadableNames(prototype));\n\n return [...new Set(names)].toSorted(byName);\n}\n\nconst requireReadableProperty = (widget: Gtk.Widget, property: string): void => {\n if (getAccessor(widget, camelCase(property))?.get !== undefined) {\n return;\n }\n\n throw propertyNotFoundError(widgetTypeName(widget), property, readablePropertyNames(widget));\n};\n\nfunction readNativeProperty(widget: Gtk.Widget, property: string): NativeProperty {\n const value = new GObject.Value();\n widget.getProperty(property, value);\n const handle = getHandle(value);\n\n return { type: getValueType(handle), handle };\n}\n\nfunction describeObjectValue(value: unknown, registry: WidgetRegistry): PropertyRepresentation {\n if (typeof value !== \"object\" || value === null) {\n return { value: String(value) };\n }\n\n const name = typeName(getInstanceType(value)) ?? value.constructor.name;\n\n if (!(value instanceof Gtk.Widget)) {\n return { value: name };\n }\n\n registry.register(value);\n\n return { value: name, widgetId: registry.getOrCreateId(value) };\n}\n\nfunction representValue(value: unknown, registry: WidgetRegistry): PropertyRepresentation {\n if (isScalar(value)) {\n return { value };\n }\n\n if (typeof value === \"bigint\") {\n return { value: value.toString() };\n }\n\n if (Array.isArray(value)) {\n return { value: value.map(String) };\n }\n\n return describeObjectValue(value, registry);\n}\n\nfunction representNativeProperty(native: NativeProperty, registry: WidgetRegistry): PropertyRepresentation {\n if (typeIsA(native.type, TYPE_ENUM)) {\n return { value: GObject.enumToString(native.type, Number(fromValue(native.handle))) };\n }\n\n if (typeIsA(native.type, TYPE_FLAGS)) {\n return { value: GObject.flagsToString(native.type, Number(fromValue(native.handle))) };\n }\n\n return representValue(fromValue(native.handle), registry);\n}\n\nfunction serializeProperty(widget: Gtk.Widget, property: string, registry: WidgetRegistry): SerializedProperty {\n const native = readNativeProperty(widget, property);\n const type = typeName(native.type) ?? String(native.type);\n\n try {\n return { type, ...representNativeProperty(native, registry) };\n } catch (error) {\n return { type, value: null, note: `cannot be represented over MCP: ${errorMessage(error)}` };\n }\n}\n\nfunction readWidgetProperties(\n widget: Gtk.Widget,\n properties: string[],\n registry: WidgetRegistry,\n): Record<string, SerializedProperty> {\n const values: Record<string, SerializedProperty> = {};\n\n for (const name of properties) {\n const property = canonicalName(name);\n requireReadableProperty(widget, property);\n values[property] = serializeProperty(widget, property, registry);\n }\n\n return values;\n}\n\nexport { readWidgetProperties };\n"]}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import RefreshRuntime from "react-refresh/runtime";
|
|
2
2
|
import "./refresh-globals.js";
|
|
3
3
|
type ComponentType = (...args: unknown[]) => unknown;
|
|
4
|
-
/**
|
|
5
|
-
* Builds the per-module `$RefreshReg$` and `$RefreshSig$` hooks that React Refresh
|
|
6
|
-
* transformed code expects, scoping every registered component to the given module.
|
|
7
|
-
*
|
|
8
|
-
* @param moduleId Identifier used to namespace registered component types so they are unique across modules.
|
|
9
|
-
* @returns An object with `$RefreshReg$` and `$RefreshSig$` to install as module-local globals.
|
|
10
|
-
*/
|
|
11
4
|
declare function createModuleRegistration(moduleId: string): {
|
|
12
5
|
$RefreshReg$: (type: ComponentType, id: string) => void;
|
|
13
6
|
$RefreshSig$: typeof RefreshRuntime.createSignatureFunctionForTransform;
|
|
14
7
|
};
|
|
15
8
|
declare function isRefreshBoundary(moduleExports: Record<string, unknown>): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Applies all pending React Refresh updates, re-rendering components whose modules have changed.
|
|
18
|
-
*/
|
|
19
9
|
declare function performRefresh(): void;
|
|
20
10
|
export { createModuleRegistration, isRefreshBoundary, performRefresh };
|
|
21
11
|
//# sourceMappingURL=refresh-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-runtime.d.ts","sourceRoot":"","sources":["../src/refresh-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,sBAAsB,CAAC;AAE9B,KAAK,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"refresh-runtime.d.ts","sourceRoot":"","sources":["../src/refresh-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,sBAAsB,CAAC;AAE9B,KAAK,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAErD,iBAAS,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACjD,YAAY,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,YAAY,EAAE,OAAO,cAAc,CAAC,mCAAmC,CAAC;CAC3E,CAOA;AAeD,iBAAS,iBAAiB,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAU1E;AAED,iBAAS,cAAc,IAAI,IAAI,CAE9B;AAED,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/refresh-runtime.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import RefreshRuntime from "react-refresh/runtime";
|
|
2
2
|
import "./refresh-globals.js";
|
|
3
|
-
/**
|
|
4
|
-
* Builds the per-module `$RefreshReg$` and `$RefreshSig$` hooks that React Refresh
|
|
5
|
-
* transformed code expects, scoping every registered component to the given module.
|
|
6
|
-
*
|
|
7
|
-
* @param moduleId Identifier used to namespace registered component types so they are unique across modules.
|
|
8
|
-
* @returns An object with `$RefreshReg$` and `$RefreshSig$` to install as module-local globals.
|
|
9
|
-
*/
|
|
10
3
|
function createModuleRegistration(moduleId) {
|
|
11
4
|
return {
|
|
12
5
|
$RefreshReg$: (type, id) => {
|
|
@@ -15,13 +8,6 @@ function createModuleRegistration(moduleId) {
|
|
|
15
8
|
$RefreshSig$: RefreshRuntime.createSignatureFunctionForTransform,
|
|
16
9
|
};
|
|
17
10
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Determines whether a module can act as a React Refresh boundary, meaning every one of
|
|
20
|
-
* its exports (ignoring `__esModule`) looks like a React component type.
|
|
21
|
-
*
|
|
22
|
-
* @param moduleExports The module's export object to inspect.
|
|
23
|
-
* @returns `true` when the module qualifies as a refresh boundary, `false` otherwise.
|
|
24
|
-
*/
|
|
25
11
|
const isComponentExport = (key, value) => key === "__esModule" || RefreshRuntime.isLikelyComponentType(value);
|
|
26
12
|
const areAllExportsComponents = (moduleExports) => {
|
|
27
13
|
for (const key in moduleExports) {
|
|
@@ -40,9 +26,6 @@ function isRefreshBoundary(moduleExports) {
|
|
|
40
26
|
}
|
|
41
27
|
return Object.keys(moduleExports).some((k) => k !== "__esModule");
|
|
42
28
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Applies all pending React Refresh updates, re-rendering components whose modules have changed.
|
|
45
|
-
*/
|
|
46
29
|
function performRefresh() {
|
|
47
30
|
RefreshRuntime.performReactRefresh();
|
|
48
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-runtime.js","sourceRoot":"","sources":["../src/refresh-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,sBAAsB,CAAC;AAI9B
|
|
1
|
+
{"version":3,"file":"refresh-runtime.js","sourceRoot":"","sources":["../src/refresh-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,sB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-globals.js\";\n\ntype ComponentType = (...args: unknown[]) => unknown;\n\nfunction createModuleRegistration(moduleId: string): {\n $RefreshReg$: (type: ComponentType, id: string) => void;\n $RefreshSig$: typeof RefreshRuntime.createSignatureFunctionForTransform;\n} {\n return {\n $RefreshReg$: (type: ComponentType, id: string) => {\n RefreshRuntime.register(type, `${moduleId} ${id}`);\n },\n $RefreshSig$: RefreshRuntime.createSignatureFunctionForTransform,\n };\n}\n\nconst isComponentExport = (key: string, value: unknown): boolean =>\n key === \"__esModule\" || RefreshRuntime.isLikelyComponentType(value);\n\nconst areAllExportsComponents = (moduleExports: Record<string, unknown>): boolean => {\n for (const key in moduleExports) {\n if (!isComponentExport(key, moduleExports[key])) {\n return false;\n }\n }\n\n return true;\n};\n\nfunction isRefreshBoundary(moduleExports: Record<string, unknown>): boolean {\n if (RefreshRuntime.isLikelyComponentType(moduleExports)) {\n return true;\n }\n\n if (!areAllExportsComponents(moduleExports)) {\n return false;\n }\n\n return Object.keys(moduleExports).some((k) => k !== \"__esModule\");\n}\n\nfunction performRefresh(): void {\n RefreshRuntime.performReactRefresh();\n}\n\nexport { createModuleRegistration, isRefreshBoundary, performRefresh };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/settings/compile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/settings/compile.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,IAWrC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/settings/compile.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { resolveCliTool } from "../internal/resolve-cli-tool.js";
|
|
1
|
+
import { runCliTool } from "../internal/run-cli-tool.js";
|
|
4
2
|
const SCHEMA_COMPILER = "glib-compile-schemas";
|
|
5
3
|
const SCHEMA_COMPILE_TIMEOUT_MS = 30_000;
|
|
6
4
|
const compileSchemas = (dir) => {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
runCliTool({
|
|
6
|
+
tool: SCHEMA_COMPILER,
|
|
7
|
+
args: ["--strict", dir],
|
|
8
|
+
target: dir,
|
|
9
|
+
options: {
|
|
9
10
|
stdio: ["ignore", "pipe", "pipe"],
|
|
10
11
|
timeout: SCHEMA_COMPILE_TIMEOUT_MS,
|
|
11
12
|
encoding: "utf8",
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
const details = formatChildProcessError(error);
|
|
16
|
-
const suffix = details ? `:\n${details}` : "";
|
|
17
|
-
throw new Error(`glib-compile-schemas failed for ${dir}${suffix}`, { cause: error });
|
|
18
|
-
}
|
|
13
|
+
},
|
|
14
|
+
});
|
|
19
15
|
};
|
|
20
16
|
export { compileSchemas };
|
|
21
17
|
//# sourceMappingURL=compile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/settings/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/settings/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAC/C,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEzC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAQ,EAAE;IACzC,UAAU,CAAC;QACP,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC;QACvB,MAAM,EAAE,GAAG;QACX,OAAO,EAAE;YACL,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;YACjC,OAAO,EAAE,yBAAyB;YAClC,QAAQ,EAAE,MAAM;SACnB;KACJ,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { runCliTool } from \"../internal/run-cli-tool.js\";\n\nconst SCHEMA_COMPILER = \"glib-compile-schemas\";\nconst SCHEMA_COMPILE_TIMEOUT_MS = 30_000;\n\nconst compileSchemas = (dir: string): void => {\n runCliTool({\n tool: SCHEMA_COMPILER,\n args: [\"--strict\", dir],\n target: dir,\n options: {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n timeout: SCHEMA_COMPILE_TIMEOUT_MS,\n encoding: \"utf8\",\n },\n });\n};\n\nexport { compileSchemas };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/settings/schema.ts"],"names":[],"mappings":"AAWA,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/settings/schema.ts"],"names":[],"mappings":"AAWA,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,QAAA,MAAM,aAAa,iBAAiB,CAAC;AAGrC,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;AA6BF,QAAA,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,MAAM,EAKhD,CAAC;AAEF,QAAA,MAAM,6BAA6B,GAAI,MAAM,MAAM,EAAE,SAAS,MAAM,GAAG,IAAI,KAAG,MAAM,GAAG,IAwBtF,CAAC;AAEF,QAAA,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,MAA4D,CAAC;AAmDtG,QAAA,MAAM,aAAa,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,GAAG,IAAI,KAAG,eAShE,CAAC;AAEF,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,6BAA6B,EAC7B,aAAa,EACb,aAAa,GAChB,CAAC"}
|
package/dist/settings/schema.js
CHANGED
|
@@ -115,7 +115,7 @@ const emitSchemaEnv = (rootDir, dataDir) => {
|
|
|
115
115
|
const content = renderEnvModule(parsed);
|
|
116
116
|
const path = schemaEnvPath(rootDir);
|
|
117
117
|
const isWritten = didWriteChanges(path, content);
|
|
118
|
-
return { path,
|
|
118
|
+
return { path, isWritten };
|
|
119
119
|
};
|
|
120
120
|
export { SCHEMA_SUFFIX, prependSchemaDir, stageSchema, findSchemaFiles, stageAndCompileProjectSchemas, schemaEnvPath, emitSchemaEnv, };
|
|
121
121
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/settings/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAe,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAyB,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE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AAC,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACvF,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACxC,CAAC,CAAC;AAEF,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,6BAA6B,EAC7B,aAAa,EACb,aAAa,GAChB,CAAC","sourcesContent":["import { sortStrings, warn } from \"@gtkx/utils\";\nimport { createHash } from \"node:crypto\";\nimport { copyFileSync, type Dirent, mkdirSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, relative } from \"node:path\";\nimport { DATA_IMPORT_PREFIX } from \"../internal/data-dir.js\";\nimport { removeTempDir } from \"../internal/staging-dir.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 written: boolean;\n};\n\nconst SCHEMA_SUFFIX = \".gschema.xml\";\nconst STAGED_NAME_LENGTH = 16;\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 toForwardSlashes = (value: string): string => value.replaceAll(/[/\\\\]/g, \"/\");\n\nconst getModuleSpecifier = (dataDirAbs: string, filePath: string): string =>\n `${DATA_IMPORT_PREFIX}/${toForwardSlashes(relative(dataDirAbs, filePath))}`;\n\nconst readVisibleEntries = (dir: string): Dirent[] => {\n try {\n return readdirSync(dir, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(\".\"));\n } catch {\n return [];\n }\n};\n\nconst isSchemaFile = (entry: Dirent): boolean => entry.isFile() && entry.name.endsWith(SCHEMA_SUFFIX);\n\nconst collectSchemaFiles = (dir: string, found: string[]): void => {\n for (const entry of readVisibleEntries(dir)) {\n const full = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n collectSchemaFiles(full, found);\n } else if (isSchemaFile(entry)) {\n found.push(full);\n }\n }\n};\n\nconst findSchemaFiles = (dataDir: string): string[] => {\n const found: string[] = [];\n collectSchemaFiles(dataDir, found);\n\n return sortStrings(found);\n};\n\nconst stageAndCompileProjectSchemas = (root: string, dataDir: string | null): string | null => {\n if (dataDir === null) {\n return null;\n }\n\n const schemaFiles = findSchemaFiles(join(root, dataDir));\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, dataDirAbs: string): ParsedSchemaFile | null => {\n const specifier = getModuleSpecifier(dataDirAbs, filePath);\n\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[], dataDirAbs: string): ParsedSchemaFile[] => {\n const parsed: ParsedSchemaFile[] = [];\n\n for (const filePath of schemaFiles) {\n const result = parseSchemaFileOrWarn(filePath, dataDirAbs);\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, dataDir: string | null): SchemaEnvResult => {\n const dataDirAbs = dataDir === null ? null : join(rootDir, dataDir);\n const schemaFiles = dataDirAbs === null ? [] : findSchemaFiles(dataDirAbs);\n const parsed = dataDirAbs === null ? [] : parseProjectSchemas(schemaFiles, dataDirAbs);\n const content = renderEnvModule(parsed);\n const path = schemaEnvPath(rootDir);\n const isWritten = didWriteChanges(path, content);\n\n return { path, written: isWritten };\n};\n\nexport {\n SCHEMA_SUFFIX,\n prependSchemaDir,\n stageSchema,\n findSchemaFiles,\n stageAndCompileProjectSchemas,\n schemaEnvPath,\n emitSchemaEnv,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/settings/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAe,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;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CAAC;IACpE,MAAM,WAAW,GAAG,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACvF,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACxC,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,eAAe,EACf,6BAA6B,EAC7B,aAAa,EACb,aAAa,GAChB,CAAC","sourcesContent":["import { sortStrings, warn } from \"@gtkx/utils\";\nimport { createHash } from \"node:crypto\";\nimport { copyFileSync, type Dirent, mkdirSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, relative } from \"node:path\";\nimport { DATA_IMPORT_PREFIX } from \"../internal/data-dir.js\";\nimport { removeTempDir } from \"../internal/staging-dir.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;\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 toForwardSlashes = (value: string): string => value.replaceAll(/[/\\\\]/g, \"/\");\n\nconst getModuleSpecifier = (dataDirAbs: string, filePath: string): string =>\n `${DATA_IMPORT_PREFIX}/${toForwardSlashes(relative(dataDirAbs, filePath))}`;\n\nconst readVisibleEntries = (dir: string): Dirent[] => {\n try {\n return readdirSync(dir, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(\".\"));\n } catch {\n return [];\n }\n};\n\nconst isSchemaFile = (entry: Dirent): boolean => entry.isFile() && entry.name.endsWith(SCHEMA_SUFFIX);\n\nconst collectSchemaFiles = (dir: string, found: string[]): void => {\n for (const entry of readVisibleEntries(dir)) {\n const full = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n collectSchemaFiles(full, found);\n } else if (isSchemaFile(entry)) {\n found.push(full);\n }\n }\n};\n\nconst findSchemaFiles = (dataDir: string): string[] => {\n const found: string[] = [];\n collectSchemaFiles(dataDir, found);\n\n return sortStrings(found);\n};\n\nconst stageAndCompileProjectSchemas = (root: string, dataDir: string | null): string | null => {\n if (dataDir === null) {\n return null;\n }\n\n const schemaFiles = findSchemaFiles(join(root, dataDir));\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, dataDirAbs: string): ParsedSchemaFile | null => {\n const specifier = getModuleSpecifier(dataDirAbs, filePath);\n\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[], dataDirAbs: string): ParsedSchemaFile[] => {\n const parsed: ParsedSchemaFile[] = [];\n\n for (const filePath of schemaFiles) {\n const result = parseSchemaFileOrWarn(filePath, dataDirAbs);\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, dataDir: string | null): SchemaEnvResult => {\n const dataDirAbs = dataDir === null ? null : join(rootDir, dataDir);\n const schemaFiles = dataDirAbs === null ? [] : findSchemaFiles(dataDirAbs);\n const parsed = dataDirAbs === null ? [] : parseProjectSchemas(schemaFiles, dataDirAbs);\n const content = renderEnvModule(parsed);\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 findSchemaFiles,\n stageAndCompileProjectSchemas,\n schemaEnvPath,\n emitSchemaEnv,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-emitter.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/asset-emitter.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACjF,CAAC;AAEF,OAAO,EAAE,KAAK,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-emitter.js","sourceRoot":"","sources":["../../src/vite-plugins/asset-emitter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,CAAC","sourcesContent":["type AssetEmitter = {\n emitFile: (file: { type: \"asset\"; fileName: string; source: Buffer }) => void;\n};\n\nexport { type AssetEmitter };\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":"AAyBA,QAAA,MAAM,QAAQ,QAAoE,CAAC;AACnF,QAAA,MAAM,aAAa,QAA6E,CAAC;AAEjG,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -24,5 +24,5 @@ const ASSET_EXTENSIONS = [
|
|
|
24
24
|
];
|
|
25
25
|
const ASSET_RE = new RegExp(String.raw `\.(?:${ASSET_EXTENSIONS.join("|")})$`, "i");
|
|
26
26
|
const ASSET_PATH_RE = new RegExp(String.raw `\.(?:${ASSET_EXTENSIONS.join("|")})(?:\?.*)?$`, "i");
|
|
27
|
-
export {
|
|
27
|
+
export { ASSET_RE, ASSET_PATH_RE };
|
|
28
28
|
//# sourceMappingURL=asset-extensions.js.map
|
|
@@ -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,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;AAEjG,OAAO,EAAE,
|
|
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,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;AAEjG,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC","sourcesContent":["const ASSET_EXTENSIONS = [\n \"png\",\n \"jpg\",\n \"jpeg\",\n \"gif\",\n \"svg\",\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\");\n\nexport { ASSET_RE, ASSET_PATH_RE };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built-url.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/built-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"built-url.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/built-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAkCnC,iBAAS,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBhD;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
const EXECUTABLE_URL_BASE = "`file://${process.execPath}`";
|
|
3
|
+
const LEADING_SLASHES = /^\/+/;
|
|
4
|
+
const executableRelativeUrl = (target) => {
|
|
5
|
+
const specifier = JSON.stringify(target.replace(LEADING_SLASHES, "./"));
|
|
6
|
+
return `decodeURIComponent(new URL(${specifier}, ${EXECUTABLE_URL_BASE}).pathname)`;
|
|
7
|
+
};
|
|
8
|
+
const bundleRelativeUrl = (filename) => {
|
|
9
|
+
const specifier = JSON.stringify(`./${filename}`);
|
|
10
|
+
return `decodeURIComponent(new URL(${specifier}, import.meta.url).pathname)`;
|
|
11
|
+
};
|
|
1
12
|
const renderAssetUrl = (filename, type, assetBase) => {
|
|
2
13
|
if (type !== "asset") {
|
|
3
14
|
return undefined;
|
|
4
15
|
}
|
|
5
|
-
if (assetBase) {
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
runtime: `require("path").join(${executableDir},` +
|
|
9
|
-
`${JSON.stringify(assetBase)},${JSON.stringify(filename)})`,
|
|
10
|
-
};
|
|
16
|
+
if (assetBase === undefined) {
|
|
17
|
+
return { runtime: bundleRelativeUrl(filename) };
|
|
11
18
|
}
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
runtime: `new URL(${filenameLiteral}, import.meta.url).pathname`,
|
|
15
|
-
};
|
|
19
|
+
return { runtime: executableRelativeUrl(posix.join(assetBase, filename)) };
|
|
16
20
|
};
|
|
17
21
|
function gtkxBuiltUrl(assetBase) {
|
|
18
22
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built-url.js","sourceRoot":"","sources":["../../src/vite-plugins/built-url.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"built-url.js","sourceRoot":"","sources":["../../src/vite-plugins/built-url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAC3D,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAU,EAAE;IACrD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;IAExE,OAAO,8BAA8B,SAAS,KAAK,mBAAmB,aAAa,CAAC;AACxF,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAU,EAAE;IACnD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC;IAElD,OAAO,8BAA8B,SAAS,8BAA8B,CAAC;AACjF,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CACnB,QAAgB,EAChB,IAAY,EACZ,SAA6B,EACE,EAAE;IACjC,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;IACpD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;AAC/E,CAAC,CAAC;AAEF,SAAS,YAAY,CAAC,SAAkB;IACpC,OAAO;QACH,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,OAAO;QAEd,MAAM,CAAC,UAAU;YACb,IAAI,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,CAAC;gBAC1C,OAAO;YACX,CAAC;YAED,OAAO;gBACH,YAAY,EAAE;oBACV,cAAc,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE;wBAC7B,OAAO,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;oBACrD,CAAC;iBACJ;aACJ,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport { posix } from \"node:path\";\n\nconst EXECUTABLE_URL_BASE = \"`file://${process.execPath}`\";\nconst LEADING_SLASHES = /^\\/+/;\n\nconst executableRelativeUrl = (target: string): string => {\n const specifier = JSON.stringify(target.replace(LEADING_SLASHES, \"./\"));\n\n return `decodeURIComponent(new URL(${specifier}, ${EXECUTABLE_URL_BASE}).pathname)`;\n};\n\nconst bundleRelativeUrl = (filename: string): string => {\n const specifier = JSON.stringify(`./${filename}`);\n\n return `decodeURIComponent(new URL(${specifier}, import.meta.url).pathname)`;\n};\n\nconst renderAssetUrl = (\n filename: string,\n type: string,\n assetBase: string | undefined,\n): { runtime: string } | undefined => {\n if (type !== \"asset\") {\n return undefined;\n }\n\n if (assetBase === undefined) {\n return { runtime: bundleRelativeUrl(filename) };\n }\n\n return { runtime: executableRelativeUrl(posix.join(assetBase, filename)) };\n};\n\nfunction gtkxBuiltUrl(assetBase?: string): Plugin {\n return {\n name: \"gtkx:built-url\",\n apply: \"build\",\n\n config(userConfig) {\n if (userConfig.experimental?.renderBuiltUrl) {\n return;\n }\n\n return {\n experimental: {\n renderBuiltUrl(filename, { type }) {\n return renderAssetUrl(filename, type, assetBase);\n },\n },\n };\n },\n };\n}\n\nexport { gtkxBuiltUrl };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-store.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/ensure-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,QAAA,MAAM,eAAe,QAAO,MAM1B,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ensureGenerated } from "../codegen/run-codegen.js";
|
|
2
|
+
const TEST_MODE = "test";
|
|
3
|
+
const gtkxEnsureStore = () => ({
|
|
4
|
+
name: "gtkx:ensure-store",
|
|
5
|
+
async config() {
|
|
6
|
+
await ensureGenerated(process.cwd(), { shouldAnnounce: true, mode: TEST_MODE });
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
export { gtkxEnsureStore };
|
|
10
|
+
//# sourceMappingURL=ensure-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-store.js","sourceRoot":"","sources":["../../src/vite-plugins/ensure-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,MAAM,eAAe,GAAG,GAAW,EAAE,CAAC,CAAC;IACnC,IAAI,EAAE,mBAAmB;IAEzB,KAAK,CAAC,MAAM;QACR,MAAM,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACpF,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport { ensureGenerated } from \"../codegen/run-codegen.js\";\n\nconst TEST_MODE = \"test\";\n\nconst gtkxEnsureStore = (): Plugin => ({\n name: \"gtkx:ensure-store\",\n\n async config() {\n await ensureGenerated(process.cwd(), { shouldAnnounce: true, mode: TEST_MODE });\n },\n});\n\nexport { gtkxEnsureStore };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/icons.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/icons.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AA0C/C,iBAAS,SAAS,IAAI,MAAM,CA0B3B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|