@gjsify/rolldown-plugin-gjsify 0.56.0 → 0.57.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.
@@ -28,6 +28,7 @@ import { globToEntryPoints } from '../utils/entry-points.js';
28
28
  import { gjsImportsEmptyPlugin } from '../plugins/gjs-imports-empty.js';
29
29
  import { platformResolvePlugin, browserSuffixChain, BROWSER_REFUSED_SUFFIXES } from '../plugins/platform-resolve.js';
30
30
  import { giRendererPlugin } from '../plugins/gi-renderer.js';
31
+ import { blueprintTemplateExit } from '../utils/blueprint-template-exit.js';
31
32
  import { cssAsStringPlugin } from '../plugins/css-as-string.js';
32
33
  import { unresolvedWorkspaceImportPlugin } from '../plugins/unresolved-workspace-import.js';
33
34
  import { implicitGlobalAssignPlugin } from '../plugins/implicit-global-assign.js';
@@ -135,7 +136,9 @@ export const setupForBrowser = async (input) => {
135
136
  // its bytes and was never parsed by anything. It stays — a `--app browser` build of a
136
137
  // GJS app's sources must not start failing on an import that used to resolve — and the
137
138
  // exit a browser can actually use is now beside it.
138
- blueprintPlugin(),
139
+ // `./x.blp?template` (ADR 0096 § 4): the tree checked against the renderer this target's
140
+ // `--gi-renderer` arm names, or a refusal naming the flag. Never the XML string here.
141
+ blueprintPlugin({ template: blueprintTemplateExit('browser', giRenderer) }),
139
142
  // ADR 0079's addendum. The `window` define above replaces an assignment TARGET as
140
143
  // readily as a read, so `window = {…}` would emit `globalThis = {…}` — code that
141
144
  // replaces the whole global object. This transform runs first and leaves the define
@@ -44,6 +44,7 @@ import { ALIASES_NODE_FOR_NATIVESCRIPT, GI_RENDERERS, getDerivedAliasesSync } fr
44
44
  import { globToEntryPoints } from '../utils/entry-points.js';
45
45
  import { gjsImportsEmptyPlugin } from '../plugins/gjs-imports-empty.js';
46
46
  import { giRendererPlugin } from '../plugins/gi-renderer.js';
47
+ import { blueprintTemplateExit } from '../utils/blueprint-template-exit.js';
47
48
  import { platformResolvePlugin, nativescriptSuffixChain, detectNativescriptPlatform, nativescriptPlatformDefines, } from '../plugins/platform-resolve.js';
48
49
  import { unresolvedWorkspaceImportPlugin } from '../plugins/unresolved-workspace-import.js';
49
50
  import { implicitGlobalAssignPlugin } from '../plugins/implicit-global-assign.js';
@@ -159,7 +160,9 @@ export const setupForNativescript = async (input) => {
159
160
  // READER of the shared node shape, and the projection is what this target
160
161
  // consumes. A `.blp` whose projection loses anything is refused at build time
161
162
  // rather than rendered partially; see `SHARED_TREE_QUERY` in the plugin.
162
- blueprintPlugin(),
163
+ // `./x.blp?template` (ADR 0096 § 4): the tree checked against the renderer this target's
164
+ // `--gi-renderer` arm names, or a refusal naming the flag. Never the XML string here.
165
+ blueprintPlugin({ template: blueprintTemplateExit('nativescript', giRenderer) }),
163
166
  // ADR 0079's addendum, and the `define` comment above is why it is needed here:
164
167
  // a NativeScript app gates on the absence of `window`, but a WRITE to it is a
165
168
  // `ReferenceError` in a strict module body, not a gate. `globalThis.window = …`
@@ -6,6 +6,8 @@ export interface GiRendererOptions {
6
6
  renderer: string;
7
7
  /** GI namespace → the version this arm answers for, from `@gjsify/resolve-npm`. */
8
8
  namespaces: Readonly<Record<string, string>>;
9
+ /** Namespace → a module whose exports ARE that namespace, when it is not a member of `renderer`'s root barrel. */
10
+ specifiers?: Readonly<Record<string, string>>;
9
11
  }
10
12
  /**
11
13
  * The runtime shim for one answered namespace.
@@ -68,6 +68,13 @@
68
68
  import { GJSIFY_VIRTUAL_PREFIX } from '../utils/virtual-module-id.js';
69
69
  import { parseGiSpecifier } from './gjs-gi-node.js';
70
70
  const GI_RENDERER_VIRTUAL_PREFIX = `${GJSIFY_VIRTUAL_PREFIX}gi-renderer:`;
71
+ /** A namespace with its own module IS that module; otherwise it is a member of the renderer's root barrel. */
72
+ function importLine(options, namespace) {
73
+ const own = options.specifiers?.[namespace];
74
+ return own === undefined
75
+ ? `import { ${namespace} as namespace } from ${JSON.stringify(options.renderer)};\n`
76
+ : `import * as namespace from ${JSON.stringify(own)};\n`;
77
+ }
71
78
  /**
72
79
  * The runtime shim for one answered namespace.
73
80
  *
@@ -93,7 +100,7 @@ const GI_RENDERER_VIRTUAL_PREFIX = `${GJSIFY_VIRTUAL_PREFIX}gi-renderer:`;
93
100
  * the other twelve sites and the retirement condition are in `status/open-todos/README.md`.
94
101
  */
95
102
  export function giRendererShimSource(options, namespace, version) {
96
- return (`import { ${namespace} as namespace } from ${JSON.stringify(options.renderer)};\n` +
103
+ return (importLine(options, namespace) +
97
104
  `const RENDERER = ${JSON.stringify(options.renderer)};\n` +
98
105
  `const APP = ${JSON.stringify(options.app)};\n` +
99
106
  `const NS = ${JSON.stringify(namespace)};\n` +
@@ -0,0 +1,13 @@
1
+ /**
2
+ * What `./x.blp?template` means on a target with no GtkBuilder (ADR 0096 § 4): the projected
3
+ * tree, checked against the renderer the target's `--gi-renderer` arm names, so the import site
4
+ * writes no `for=`. Without the arm there is no renderer to check against and no reader for the
5
+ * XML string, so the import is refused at build time, naming the flag.
6
+ */
7
+ export declare function blueprintTemplateExit(app: string, giRenderer: {
8
+ renderer: string;
9
+ } | undefined): {
10
+ renderer: string;
11
+ } | {
12
+ refusal: string;
13
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * What `./x.blp?template` means on a target with no GtkBuilder (ADR 0096 § 4): the projected
3
+ * tree, checked against the renderer the target's `--gi-renderer` arm names, so the import site
4
+ * writes no `for=`. Without the arm there is no renderer to check against and no reader for the
5
+ * XML string, so the import is refused at build time, naming the flag.
6
+ */
7
+ export function blueprintTemplateExit(app, giRenderer) {
8
+ if (giRenderer === undefined) {
9
+ return {
10
+ refusal: `On --app ${app} it is the projected tree of the renderer --gi-renderer composes, and ` +
11
+ 'that flag is off. Pass --gi-renderer, or import the file without `?template`.',
12
+ };
13
+ }
14
+ // `for=` names the package without its scope.
15
+ return { renderer: giRenderer.renderer.replace(/^@gjsify\//, '') };
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-gjsify",
3
- "version": "0.56.0",
3
+ "version": "0.57.0",
4
4
  "description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -63,12 +63,12 @@
63
63
  ],
64
64
  "license": "MIT",
65
65
  "dependencies": {
66
- "@gjsify/console": "^0.56.0",
67
- "@gjsify/resolve-npm": "^0.56.0",
68
- "@gjsify/rolldown-plugin-deepkit": "^0.56.0",
69
- "@gjsify/rolldown-plugin-pnp": "^0.56.0",
70
- "@gjsify/utils": "^0.56.0",
71
- "@gjsify/vite-plugin-blueprint": "^0.56.0",
66
+ "@gjsify/console": "^0.57.0",
67
+ "@gjsify/resolve-npm": "^0.57.0",
68
+ "@gjsify/rolldown-plugin-deepkit": "^0.57.0",
69
+ "@gjsify/rolldown-plugin-pnp": "^0.57.0",
70
+ "@gjsify/utils": "^0.57.0",
71
+ "@gjsify/vite-plugin-blueprint": "^0.57.0",
72
72
  "@rollup/pluginutils": "^5.4.0",
73
73
  "acorn": "^8.17.0",
74
74
  "acorn-typescript": "^1.4.13",
@@ -78,7 +78,7 @@
78
78
  "sass": "^1.101.0"
79
79
  },
80
80
  "peerDependencies": {
81
- "@gjsify/lightningcss-native": "^0.56.0",
81
+ "@gjsify/lightningcss-native": "^0.57.0",
82
82
  "rolldown": "^1.1.4"
83
83
  },
84
84
  "peerDependenciesMeta": {
@@ -90,8 +90,8 @@
90
90
  }
91
91
  },
92
92
  "devDependencies": {
93
- "@gjsify/cli": "^0.56.0",
94
- "@gjsify/unit": "^0.56.0",
93
+ "@gjsify/cli": "^0.57.0",
94
+ "@gjsify/unit": "^0.57.0",
95
95
  "@types/node": "^25.9.2",
96
96
  "rolldown": "^1.1.4",
97
97
  "typescript": "^6.0.3"