@gjsify/rolldown-plugin-gjsify 0.36.0 → 0.38.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/lib/app/gjs.d.ts +28 -54
- package/lib/app/gjs.js +124 -211
- package/lib/app/node.d.ts +31 -41
- package/lib/app/node.js +118 -221
- package/lib/plugins/css-as-string.js +10 -2
- package/lib/plugins/napi-node-addon.d.ts +46 -83
- package/lib/plugins/napi-node-addon.js +188 -308
- package/lib/plugins/process-stub.js +27 -1
- package/lib/plugins/rewrite-node-modules-paths.d.ts +12 -36
- package/lib/plugins/rewrite-node-modules-paths.js +60 -144
- package/lib/plugins/unresolved-workspace-import.d.ts +20 -38
- package/lib/plugins/unresolved-workspace-import.js +65 -157
- package/lib/shims/console-gjs.js +11 -19
- package/lib/utils/auto-globals.d.ts +56 -102
- package/lib/utils/auto-globals.js +100 -171
- package/lib/utils/detect-free-globals.d.ts +27 -46
- package/lib/utils/detect-free-globals.js +106 -185
- package/package.json +7 -7
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { Plugin } from 'rolldown';
|
|
2
2
|
/**
|
|
3
|
-
* Fast-path filter
|
|
4
|
-
*
|
|
3
|
+
* Fast-path filter — a superset of what the handler claims; the handler re-checks.
|
|
5
4
|
* Exported so `napi-node-addon.spec.ts` can assert its Rust-compatibility (see
|
|
6
|
-
* {@link BARE_SPECIFIER_RE})
|
|
7
|
-
* entirely under `@gjsify/rolldown-native`, and no build-level test would see
|
|
8
|
-
* it, because every addon gate drives the Node CLI entry.
|
|
5
|
+
* {@link BARE_SPECIFIER_RE}).
|
|
9
6
|
*/
|
|
10
7
|
export declare const ADDON_FILTER_RE: RegExp;
|
|
11
8
|
/** Options for {@link napiNodeAddonPlugin}. */
|
|
@@ -21,22 +18,15 @@ export declare class AddonNotBuiltError extends Error {
|
|
|
21
18
|
constructor(pkgRoot: string);
|
|
22
19
|
}
|
|
23
20
|
/**
|
|
24
|
-
* Locate the compiled `.node` for an addon package root, matching
|
|
25
|
-
*
|
|
26
|
-
* `prebuilds/<platform>-<arch>/<best tag>`. Throws {@link AddonNotBuiltError}
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @param pkgRoot Absolute path to the addon package root (dir with package.json).
|
|
30
|
-
* @param opts.warn Optional sink for a non-fatal warning (ambiguous build dir).
|
|
21
|
+
* Locate the compiled `.node` for an addon package root, matching node-gyp-build's
|
|
22
|
+
* probe order: `build/Release` → `build/Debug` →
|
|
23
|
+
* `prebuilds/<platform>-<arch>/<best tag>`. Throws {@link AddonNotBuiltError} when
|
|
24
|
+
* nothing is found. `opts.warn` sinks the non-fatal ambiguous-build-dir warning.
|
|
31
25
|
*/
|
|
32
26
|
export declare function resolveAddonPath(pkgRoot: string, opts?: {
|
|
33
27
|
warn?: (msg: string) => void;
|
|
34
28
|
}): string;
|
|
35
|
-
/**
|
|
36
|
-
* Walk up from an importer file to the nearest `package.json` directory (the
|
|
37
|
-
* addon package root). Returns null when none is found (should not happen for a
|
|
38
|
-
* real node_modules dep).
|
|
39
|
-
*/
|
|
29
|
+
/** Nearest ancestor directory of `importerFile` holding a `package.json`. */
|
|
40
30
|
export declare function nearestPackageRoot(importerFile: string): string | null;
|
|
41
31
|
/** Direct `.node` import → the addon's exports (ESM default). */
|
|
42
32
|
export declare function directNodeShim(addonPath: string): string;
|
|
@@ -46,12 +36,7 @@ export declare function nodeGypBuildShim(addonPath: string): string;
|
|
|
46
36
|
export declare function bindingsShim(addonPath: string): string;
|
|
47
37
|
/** napi-rs sibling → the raw native exports as the module value. */
|
|
48
38
|
export declare function napiRsShim(addonPath: string): string;
|
|
49
|
-
/**
|
|
50
|
-
* Classify a specifier for interception. Pure decision logic (no filesystem
|
|
51
|
-
* probing beyond what `resolveAddonPath` does via the importer) — exported for
|
|
52
|
-
* the unit tests. Returns the shim kind + the package root to probe, or the
|
|
53
|
-
* literal `.node` path for the direct case.
|
|
54
|
-
*/
|
|
39
|
+
/** Classify a specifier for interception — pure decision logic, no filesystem. */
|
|
55
40
|
export declare function classifySpecifier(source: string): {
|
|
56
41
|
kind: 'node-gyp-build' | 'bindings';
|
|
57
42
|
} | {
|
|
@@ -73,89 +58,67 @@ export interface AddonPackageJson {
|
|
|
73
58
|
/**
|
|
74
59
|
* Is this manifest a gjsify NATIVE BRIDGE whose prebuilds live in per-target
|
|
75
60
|
* sibling packages (ADR 0017) — `@gjsify/webgl` + `@gjsify/webgl-darwin-x64`, …?
|
|
61
|
+
* Such a bridge ships a GI typelib plus a `.so`/`.dylib`/`.dll` loaded through
|
|
62
|
+
* `gi://`, NEVER a Node-API `.node`, so it must never reach `loadAddon()`.
|
|
76
63
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* (`linux-x64` vs napi-rs' `linux-x64-gnu`), so `hostNapiRsTriple()` never matched
|
|
87
|
-
* and nothing fired; on macOS napi-rs' triple IS `darwin-x64` / `darwin-arm64`,
|
|
88
|
-
* so every split bridge looked like a napi-rs package to
|
|
89
|
-
* {@link isNapiRsPackageJson} and {@link resolveNapiRsEntryAddon} then probed
|
|
90
|
-
* `ctx.resolve('@gjsify/webgl-darwin-x64')` — an artifact-only package with no JS
|
|
91
|
-
* entry at all. That probe does not return null: the `unresolved-workspace-import`
|
|
92
|
-
* guard (correctly) treats an unresolvable bare `@gjsify/*` as FATAL, so
|
|
93
|
-
* `gjsify build --app gjs` of any consumer of any split bridge died on darwin with
|
|
94
|
-
* "cannot resolve the workspace package" — invisible to every Linux CI job.
|
|
64
|
+
* The exclusion must be EXPLICIT because the two conventions are indistinguishable
|
|
65
|
+
* by name: ADR 0017's `<self>-<os>-<arch>` optionalDependency is exactly napi-rs'
|
|
66
|
+
* `<self>-<triple>` scheme wherever the vocabularies agree. On Linux they differ by
|
|
67
|
+
* the libc token (`linux-x64` vs `linux-x64-gnu`) so nothing fired, but on macOS
|
|
68
|
+
* napi-rs' triple IS `darwin-arm64`: every split bridge looked like a napi-rs
|
|
69
|
+
* package, {@link resolveNapiRsEntryAddon} probed an artifact-only package with no
|
|
70
|
+
* JS entry, and the `unresolved-workspace-import` guard (correctly) made that
|
|
71
|
+
* unresolvable bare `@gjsify/*` FATAL — so `--app gjs` of any consumer of any split
|
|
72
|
+
* bridge died on darwin, invisible to every Linux CI job.
|
|
95
73
|
*
|
|
96
|
-
* `gjsify.platforms` is the right discriminator:
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* Exported for the unit tests.
|
|
74
|
+
* `gjsify.platforms` is the right discriminator: the OS-axis declaration every
|
|
75
|
+
* native bridge carries (§ Runtime & platform model), which no napi-rs package has
|
|
76
|
+
* reason to declare.
|
|
101
77
|
*/
|
|
102
78
|
export declare function isGjsifyNativeBridge(pkg: AddonPackageJson): boolean;
|
|
103
79
|
/**
|
|
104
|
-
* A package.json describes a napi-rs generated-loader package when EITHER
|
|
105
|
-
*
|
|
80
|
+
* A package.json describes a napi-rs generated-loader package when EITHER signal
|
|
81
|
+
* holds:
|
|
106
82
|
*
|
|
107
83
|
* (a) a top-level `napi` config OBJECT (`{ binaryName, targets, … }`) — the
|
|
108
|
-
* napi-rs CLI's
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* under either naming scheme: `<self>-<triple>` (`@node-rs/argon2` ships
|
|
113
|
-
* `@node-rs/argon2-linux-x64-gnu`) or `<napi.packageName>-<triple>`
|
|
114
|
-
* (`rolldown` ships `@rolldown/binding-linux-x64-gnu`). The key MUST
|
|
115
|
-
* carry a known prefix AND end in a platform triple, so a normal optional
|
|
116
|
-
* dep (`fsevents`) can't match.
|
|
84
|
+
* napi-rs CLI's build block, which no ordinary npm package declares.
|
|
85
|
+
* (b) an `optionalDependencies` entry that is a platform SIBLING (see
|
|
86
|
+
* {@link isNapiRsSibling}) — the key must carry a known prefix AND end in a
|
|
87
|
+
* platform triple, so a normal optional dep (`fsevents`) can't match.
|
|
117
88
|
*
|
|
118
|
-
* Neither fires on a normal package, so pairing this with the "resolved file IS
|
|
119
|
-
*
|
|
120
|
-
*
|
|
89
|
+
* Neither fires on a normal package, so pairing this with the "resolved file IS the
|
|
90
|
+
* package's own native main entry" check ({@link detectNapiRsEntry}) makes
|
|
91
|
+
* entry-replacement safe.
|
|
121
92
|
*/
|
|
122
93
|
export declare function isNapiRsPackageJson(pkg: AddonPackageJson): boolean;
|
|
123
94
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* nearest package.json); the plugin memoizes calls. Exported for the unit tests.
|
|
95
|
+
* Is this absolute file path the NATIVE generated-loader entry of a napi-rs package?
|
|
96
|
+
* Returns the package root + parsed manifest, else null. "Native entry" = a path the
|
|
97
|
+
* manifest names as its entry — NOT its `browser`/wasm fallback and NOT a deep file
|
|
98
|
+
* — so only the one generated loader is ever replaced. Reads the nearest
|
|
99
|
+
* package.json; the plugin memoizes calls.
|
|
130
100
|
*/
|
|
131
101
|
export declare function detectNapiRsEntry(entryFile: string): {
|
|
132
102
|
pkgRoot: string;
|
|
133
103
|
pkg: AddonPackageJson;
|
|
134
104
|
} | null;
|
|
135
105
|
/**
|
|
136
|
-
* Is `dep` a platform sibling of `pkg` — `<prefix>-<triple>` for one of the
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* package's binaries. Exported for the unit tests.
|
|
106
|
+
* Is `dep` a platform sibling of `pkg` — `<prefix>-<triple>` for one of the prefixes
|
|
107
|
+
* above? Both halves must hold: a bare prefix match would claim an ordinary
|
|
108
|
+
* dependency, a bare triple match an unrelated package's binaries.
|
|
140
109
|
*/
|
|
141
110
|
export declare function isNapiRsSibling(pkg: AddonPackageJson, dep: string): boolean;
|
|
142
111
|
/**
|
|
143
112
|
* The napi-rs short platform triple for the CURRENT host (`linux-x64-gnu`,
|
|
144
|
-
* `darwin-arm64`,
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* local-file fallback — see `resolveNapiRsEntryAddon` for why the sibling path
|
|
148
|
-
* cannot just take whatever resolves. Returns null for a host napi-rs doesn't
|
|
149
|
-
* name, and the caller then widens rather than guessing.
|
|
113
|
+
* `darwin-arm64`, …) — the tail napi-rs stamps into a sibling package name and a
|
|
114
|
+
* local binary, and the selector for both. Returns null for a host napi-rs does not
|
|
115
|
+
* name; the caller then widens rather than guessing.
|
|
150
116
|
*/
|
|
151
117
|
export declare function hostNapiRsTriple(): string | null;
|
|
152
118
|
/**
|
|
153
|
-
* Transparent `.node`-addon loader for `gjsify build --app gjs
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* `loadAddon('<abs .node>')`. Inert unless such a specifier is in the graph —
|
|
158
|
-
* every other id returns null. Register ONLY for `--app gjs` (the C-ABI runs
|
|
159
|
-
* under `@gjsify/napi`); never for node/browser/nativescript.
|
|
119
|
+
* Transparent `.node`-addon loader for `gjsify build --app gjs`: resolveId
|
|
120
|
+
* (`order: 'pre'`, importer-aware) rewrites a native-addon acquisition to a virtual
|
|
121
|
+
* module whose value is `loadAddon('<abs .node>')`, and returns null for everything
|
|
122
|
+
* else. Register ONLY for `--app gjs` — the C-ABI runs under `@gjsify/napi`.
|
|
160
123
|
*/
|
|
161
124
|
export declare function napiNodeAddonPlugin(options?: NapiNodeAddonPluginOptions): Plugin;
|