@gjsify/cli 0.64.33 → 0.64.35

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.
@@ -843,15 +843,19 @@ async function resolveCarriedRuntime(layout, settings, projectDir) {
843
843
  });
844
844
  }
845
845
  /**
846
- * `gjsify.ship.nodeModules`: the npm packages an `--app node` bundle imports and cannot contain,
847
- * staged beside the bundle with what they need at runtime (`utils/ship/node-modules.ts`).
846
+ * `gjsify.ship.nodeModules`: the npm packages a bundle imports (`--app node`) or loads an addon
847
+ * from (`--app gjs`, through `@gjsify/napi`) and cannot contain, staged beside the bundle with
848
+ * what they need at runtime (`utils/ship/node-modules.ts`).
848
849
  *
849
- * Only for a node payload: a GJS bundle inlines or rewrites them, so one declaration can serve a
850
- * project that ships GJS on Linux and Node on macOS and Windows. Mutates `runtime` because the
851
- * files take the same route as the carried interpreter — already stage-relative, past the planner.
850
+ * Both runtimes need it: a GJS bundle inlines the package's JS, but the Node-API addon behind it
851
+ * is found at run time relative to the BUNDLE's own location (ADR 0084), so the package's
852
+ * `package.json` and its prebuilt directory have to sit in a `node_modules/` beside the bundle —
853
+ * one declaration serves a project that ships GJS on Linux and Node on macOS and Windows.
854
+ * Mutates `runtime` because the files take the same route as the carried interpreter — already
855
+ * stage-relative, past the planner.
852
856
  */
853
857
  function carryNodeModules(runtime, layout, settings, projectDir, declared, exclude) {
854
- if (declared === undefined || declared.length === 0 || settings.app !== 'node')
858
+ if (declared === undefined || declared.length === 0)
855
859
  return;
856
860
  const closure = resolveNodeModulesClosure(declared, projectDir, {
857
861
  target: { os: layout.os, cpu: settings.arch },
@@ -656,7 +656,7 @@ export interface ConfigDataShip extends AppMetadata {
656
656
  */
657
657
  bundledTypelibs?: string[] | ShipBundledTypelibsOptions;
658
658
  /**
659
- * npm packages the `--app node` bundle imports but cannot contain, by NAME — e.g.
659
+ * npm packages the bundle imports or loads an addon from but cannot contain, by NAME — e.g.
660
660
  * `["node-llama-cpp"]`.
661
661
  *
662
662
  * An `--app node` build keeps every Node-API addon package external (an addon finds its
@@ -669,8 +669,10 @@ export interface ConfigDataShip extends AppMetadata {
669
669
  * per-platform addon package is chosen: `gjsify install --os <os> --cpu <cpu>` before `ship`.
670
670
  * A required one that is missing is an error.
671
671
  *
672
- * Ignored for a GJS payload, so one declaration serves a project that ships GJS on Linux and
673
- * Node on macOS and Windows. `@gjsify/node-gi` is not listed here; `ship` carries it itself.
672
+ * Applies to a GJS payload too: its bundle loads an addon through `@gjsify/napi` from the
673
+ * package's own directory, found relative to the bundle at run time, so one declaration serves
674
+ * a project that ships GJS on Linux and Node on macOS and Windows. `@gjsify/node-gi` is not
675
+ * listed here; `ship` carries it itself.
674
676
  */
675
677
  nodeModules?: string[];
676
678
  /**
@@ -681,18 +683,23 @@ export interface ConfigDataShip extends AppMetadata {
681
683
  */
682
684
  nodeModulesExclude?: string[];
683
685
  /**
684
- * Additions for ONE package format — `deb` or `rpm` — on top of everything above.
686
+ * Additions for ONE format — `deb`, `rpm` or `appimage` — on top of everything above.
685
687
  *
686
688
  * Exists for a library the distros disagree about: one that Fedora ships and Ubuntu does
687
689
  * not, where the `.rpm` should use the system copy and only the `.deb` needs to carry
688
690
  * its own. `bundledTypelibs` and `extraFiles` are staged for every format of a
689
691
  * layout, so there is no way to say "the `.deb` only" with them.
690
692
  *
691
- * What a format carries here is read back off its package like any other staged file, so a
693
+ * The AppImage is here for the same question answered from the other end: it carries its
694
+ * libraries unconditionally, since nothing on the host is declared for it, so a library the
695
+ * distro packages should take from the system belongs in its `formats.appimage` and in
696
+ * neither package.
697
+ *
698
+ * What a format carries here is read back off its artifact like any other staged file, so a
692
699
  * namespace bundled this way no longer becomes a `Depends:` entry of THAT package — and
693
700
  * still does in the other format's.
694
701
  */
695
- formats?: Partial<Record<'deb' | 'rpm', ShipFormatOptions>>;
702
+ formats?: Partial<Record<'deb' | 'rpm' | 'appimage', ShipFormatOptions>>;
696
703
  /**
697
704
  * Directory holding COMPILED gettext catalogues in the layout `bindtextdomain` reads —
698
705
  * `<lang>/LC_MESSAGES/<domain>.mo` — e.g. `"dist/locale"`, which is what
@@ -881,7 +888,7 @@ export interface ShipBundleOptions {
881
888
  /** The entry the Windows program directory carries. */
882
889
  win32?: string;
883
890
  }
884
- /** One entry of `gjsify.ship.formats`: the staged files only that package format carries. */
891
+ /** One entry of `gjsify.ship.formats`: the staged files only that format carries. */
885
892
  export interface ShipFormatOptions {
886
893
  /**
887
894
  * Directories whose `*.typelib` and shared libraries this format carries, staged flat into
@@ -893,6 +900,10 @@ export interface ShipFormatOptions {
893
900
  * Destination (relative to the install prefix) → source file, like
894
901
  * {@link ConfigDataShip.extraFiles} but for this format only, e.g. a plugin directory the
895
902
  * bundled library finds by a path baked in at build time.
903
+ *
904
+ * The prefix is the format's own: `/usr` for a `.deb`/`.rpm`, and `usr/` inside the AppDir
905
+ * for an AppImage — the same substitution every other staged path goes through, so one
906
+ * destination spelling serves all three.
896
907
  */
897
908
  extraFiles?: Record<string, string>;
898
909
  }
@@ -32,6 +32,18 @@ const FONT_EXTENSIONS = ['.ttf', '.otf', '.ttc', '.otc'];
32
32
  * inside `@gjsify/gtk-runtime-<target>` and not this host's.
33
33
  */
34
34
  const WEB_FONT_EXTENSIONS = ['.woff', '.woff2', '.eot'];
35
+ /**
36
+ * The keys `gjsify.ship.formats` takes, in the order the refusal lists them.
37
+ *
38
+ * Spelled as a `Record<FormatFilesId, …>` and read back with `Object.keys` rather than as a
39
+ * literal list, for the reason `depends.ts`'s tables give: a member added to {@link FormatFilesId}
40
+ * and not here fails to BUILD, where a list would merely refuse the new key at run time, in a
41
+ * project that declared it correctly.
42
+ */
43
+ const FORMAT_FILES_IDS = Object.keys({ deb: null, rpm: null, appimage: null });
44
+ function isFormatFilesId(id) {
45
+ return FORMAT_FILES_IDS.includes(id);
46
+ }
35
47
  export function discoverPayload(input) {
36
48
  const { projectDir, ship } = input;
37
49
  const bundlePath = resolveBundle(input);
@@ -60,19 +72,20 @@ export function discoverPayload(input) {
60
72
  };
61
73
  }
62
74
  /**
63
- * `gjsify.ship.formats`, resolved to absolute paths. A key other than `deb`/`rpm` is refused: a
64
- * format that is not a distro package has no overlay to carry the files, so they would be
65
- * dropped without a word.
75
+ * `gjsify.ship.formats`, resolved to absolute paths. A key outside {@link FORMAT_FILES_IDS} is
76
+ * refused: a format whose payload is not assembled from an overlay has nowhere to put the files,
77
+ * so they would be dropped without a word.
66
78
  */
67
79
  function discoverFormatFiles(projectDir, ship, layoutOs) {
68
80
  const out = {};
69
- // deb and rpm exist on the Linux layout only. Looking for their files while assembling a macOS or
81
+ // All three exist on the Linux layout only. Looking for their files while assembling a macOS or
70
82
  // Windows target would fail on a directory that only the Linux build produces.
71
83
  if (layoutOs !== undefined && layoutOs !== 'linux')
72
84
  return out;
73
85
  for (const [id, options] of Object.entries(ship.formats ?? {})) {
74
- if (id !== 'deb' && id !== 'rpm') {
75
- throw new Error(`gjsify ship: \`gjsify.ship.formats.${id}\` is not a format that carries its own files. Known: deb, rpm.`);
86
+ if (!isFormatFilesId(id)) {
87
+ throw new Error(`gjsify ship: \`gjsify.ship.formats.${id}\` is not a format that carries its own files. ` +
88
+ `Known: ${FORMAT_FILES_IDS.join(', ')}.`);
76
89
  }
77
90
  out[id] = {
78
91
  typelibFiles: discoverTypelibs(projectDir, options?.bundledTypelibs),
@@ -1,5 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // npm packages an `--app node` bundle imports but cannot contain: found, then staged as a TREE.
2
+ // npm packages a bundle imports (`--app node`) or loads an addon from (`--app gjs`) but cannot
3
+ // contain: found, then staged as a TREE.
3
4
  //
4
5
  // WHY THIS EXISTS. `rolldown-plugin-gjsify`'s `nodeNativeExternalPlugin` keeps every Node-API
5
6
  // addon package EXTERNAL in an `--app node` bundle, because an addon finds its `.node` relative
@@ -200,8 +200,10 @@ export async function planOverlay(settings, format, inputs) {
200
200
  });
201
201
  }
202
202
  // `gjsify.ship.formats.<id>`: files only THIS format carries (a library built against the
203
- // distro's own sonames cannot ship in the other format). Typelibs land beside the bundle in
204
- // `gi/`, where the launcher's guarded block finds them.
203
+ // distro's own sonames cannot ship in the other format, and one an AppImage must carry
204
+ // unconditionally should not be in either package). Typelibs land beside the bundle in `gi/`,
205
+ // where the launcher's guarded block finds them — under the AppDir that is `usr/lib/<name>/gi`,
206
+ // since `appDirPayload` maps this whole plan through the same prefix.
205
207
  // READ here, as the changelog is compressed here: a stage manifest carries rendered bytes only
206
208
  // (`--from-stage` rehydrates the overlay from the sidecar and never touches the project).
207
209
  const own = settings.formatFiles[format.id];
@@ -80,6 +80,26 @@ export type FormatId = 'deb' | 'rpm' | 'flatpak' | 'appimage' | 'macos-app' | 'm
80
80
  * REQUIRED — a new format cannot be added without saying which side it is on.
81
81
  */
82
82
  export type DistroFormatId = Extract<FormatId, 'deb' | 'rpm'>;
83
+ /**
84
+ * The formats that carry FILES of their own (`gjsify.ship.formats.<id>`).
85
+ *
86
+ * Deliberately NOT {@link DistroFormatId}, and the two were one type until an
87
+ * AppImage needed a library the distro packages must not carry. The questions
88
+ * differ: `DistroFormatId` asks whether the artifact has a *dependency field* to
89
+ * write a package name into, this one asks whether it has an *overlay* to put a
90
+ * file in. An AppImage answers no to the first — `depends: null`, because it
91
+ * takes its interpreter from the host with nowhere to declare it — and yes to
92
+ * the second: `planOverlay` runs for every format, and the appimage branch maps
93
+ * the result through `appDirPayload`, which prefixes it with `usr/`.
94
+ *
95
+ * Widening `DistroFormatId` instead would have reached `extraDepends`,
96
+ * `typelibPackages`, `NODE_PACKAGE`, `SCHEMA_COMPILER_PACKAGE` and
97
+ * `deriveDepends` — every one of them a `Record` that would then demand an
98
+ * `appimage` package name for a field that does not exist.
99
+ *
100
+ * `Extract<…>` for {@link DistroFormatId}'s reason: it cannot outlive `FormatId`.
101
+ */
102
+ export type FormatFilesId = Extract<FormatId, 'deb' | 'rpm' | 'appimage'>;
83
103
  /** An operating system in the repo-wide `process.platform` spelling (root AGENTS.md § Runtime & platform model). */
84
104
  export type HostOs = 'linux' | 'darwin' | 'win32';
85
105
  /**
@@ -558,10 +578,10 @@ export interface ShipSettings extends PackSettings {
558
578
  */
559
579
  typelibFiles: string[];
560
580
  /**
561
- * What ONLY one package format carries (`gjsify.ship.formats`), resolved to absolute paths.
581
+ * What ONLY one format carries (`gjsify.ship.formats`), resolved to absolute paths.
562
582
  * Staged into that format's overlay, not the shared payload — which is the whole point.
563
583
  */
564
- formatFiles: Partial<Record<DistroFormatId, {
584
+ formatFiles: Partial<Record<FormatFilesId, {
565
585
  typelibFiles: string[];
566
586
  extraFiles: Record<string, string>;
567
587
  }>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/cli",
3
- "version": "0.64.33",
3
+ "version": "0.64.35",
4
4
  "description": "CLI for Gjsify",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -142,22 +142,22 @@
142
142
  "cli"
143
143
  ],
144
144
  "dependencies": {
145
- "@gjsify/blueprint": "^0.64.33",
146
- "@gjsify/buffer": "^0.64.33",
147
- "@gjsify/create-app": "^0.64.33",
148
- "@gjsify/node-globals": "^0.64.33",
149
- "@gjsify/node-polyfills": "^0.64.33",
150
- "@gjsify/npm-registry": "^0.64.33",
151
- "@gjsify/resolve-npm": "^0.64.33",
152
- "@gjsify/rolldown-plugin-gjsify": "^0.64.33",
153
- "@gjsify/vite-plugin-blueprint": "^0.64.33",
154
- "@gjsify/rolldown-plugin-pnp": "^0.64.33",
155
- "@gjsify/semver": "^0.64.33",
156
- "@gjsify/tar": "^0.64.33",
157
- "@gjsify/tsc": "^0.64.33",
158
- "@gjsify/utils": "^0.64.33",
159
- "@gjsify/web-polyfills": "^0.64.33",
160
- "@gjsify/workspace": "^0.64.33",
145
+ "@gjsify/blueprint": "^0.64.35",
146
+ "@gjsify/buffer": "^0.64.35",
147
+ "@gjsify/create-app": "^0.64.35",
148
+ "@gjsify/node-globals": "^0.64.35",
149
+ "@gjsify/node-polyfills": "^0.64.35",
150
+ "@gjsify/npm-registry": "^0.64.35",
151
+ "@gjsify/resolve-npm": "^0.64.35",
152
+ "@gjsify/rolldown-plugin-gjsify": "^0.64.35",
153
+ "@gjsify/vite-plugin-blueprint": "^0.64.35",
154
+ "@gjsify/rolldown-plugin-pnp": "^0.64.35",
155
+ "@gjsify/semver": "^0.64.35",
156
+ "@gjsify/tar": "^0.64.35",
157
+ "@gjsify/tsc": "^0.64.35",
158
+ "@gjsify/utils": "^0.64.35",
159
+ "@gjsify/web-polyfills": "^0.64.35",
160
+ "@gjsify/workspace": "^0.64.35",
161
161
  "acorn": "^8.17.0",
162
162
  "cosmiconfig": "^9.0.2",
163
163
  "get-tsconfig": "^4.14.0",
@@ -166,13 +166,13 @@
166
166
  "yargs": "^18.0.0"
167
167
  },
168
168
  "devDependencies": {
169
- "@gjsify/unit": "^0.64.33",
169
+ "@gjsify/unit": "^0.64.35",
170
170
  "@types/yargs": "^17.0.35",
171
171
  "typescript": "^6.0.3"
172
172
  },
173
173
  "peerDependencies": {
174
- "@gjsify/oxfmt-native": "^0.64.33",
175
- "@gjsify/rolldown-native": "^0.64.33"
174
+ "@gjsify/oxfmt-native": "^0.64.35",
175
+ "@gjsify/rolldown-native": "^0.64.35"
176
176
  },
177
177
  "peerDependenciesMeta": {
178
178
  "@gjsify/oxfmt-native": {