@gtkx/codegen 1.2.1 → 1.3.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 +2 -1
- package/dist/analysis/descriptor-render.d.ts +7 -1
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +36 -15
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +4 -1
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +11 -2
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/param-capability.d.ts +5 -2
- package/dist/analysis/param-capability.d.ts.map +1 -1
- package/dist/analysis/param-capability.js +36 -4
- package/dist/analysis/param-capability.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +1 -1
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +28 -10
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.js +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +6 -0
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +11 -2
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/pipeline.d.ts +3 -0
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +10 -1
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/fingerprint.d.ts +5 -0
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +107 -15
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +3 -0
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +29 -7
- package/dist/gi.js.map +1 -1
- package/dist/gir/external-namespaces.d.ts +8 -0
- package/dist/gir/external-namespaces.d.ts.map +1 -0
- package/dist/gir/external-namespaces.js +4 -0
- package/dist/gir/external-namespaces.js.map +1 -0
- package/dist/gir/finish-overrides.d.ts +3 -0
- package/dist/gir/finish-overrides.d.ts.map +1 -0
- package/dist/gir/finish-overrides.js +5 -0
- package/dist/gir/finish-overrides.js.map +1 -0
- package/dist/gir/function.d.ts +5 -2
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +34 -5
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/hidden-symbols.d.ts +3 -0
- package/dist/gir/hidden-symbols.d.ts.map +1 -0
- package/dist/gir/hidden-symbols.js +39 -0
- package/dist/gir/hidden-symbols.js.map +1 -0
- package/dist/gir/library.d.ts +22 -2
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +21 -3
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/ucs4-overrides.d.ts +3 -0
- package/dist/gir/ucs4-overrides.d.ts.map +1 -0
- package/dist/gir/ucs4-overrides.js +7 -0
- package/dist/gir/ucs4-overrides.js.map +1 -0
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +27 -8
- package/dist/jsx.js.map +1 -1
- package/dist/runner.d.ts +8 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +9 -3
- package/dist/runner.js.map +1 -1
- package/dist/store/external-package-links.d.ts +6 -0
- package/dist/store/external-package-links.d.ts.map +1 -0
- package/dist/store/external-package-links.js +158 -0
- package/dist/store/external-package-links.js.map +1 -0
- package/dist/store/gi/callable-doc.d.ts.map +1 -1
- package/dist/store/gi/callable-doc.js +4 -4
- package/dist/store/gi/callable-doc.js.map +1 -1
- package/dist/store/gi/callables.d.ts +1 -1
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +4 -4
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +25 -15
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/constructor-props.js +1 -1
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +2 -1
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts +2 -2
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +6 -13
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.js +2 -2
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/method.d.ts +7 -2
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +126 -30
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +8 -1
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +52 -4
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +2 -3
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +2 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +142 -16
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +5 -2
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +2 -1
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +9 -5
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/runtime-override.js +1 -1
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.js +2 -2
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +82 -12
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +7 -2
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +19 -4
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/jsx.d.ts.map +1 -1
- package/dist/store/jsx/jsx.js +3 -1
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx-store.d.ts +8 -1
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +9 -2
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/resolve-store.d.ts +2 -1
- package/dist/store/resolve-store.d.ts.map +1 -1
- package/dist/store/resolve-store.js +2 -1
- package/dist/store/resolve-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +2 -1
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +8 -3
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +8 -0
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +27 -1
- package/dist/writer/gtk-doc.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +15 -1
- package/overrides/glib/index.ts.ejs +3 -0
- package/overrides/glib/regex.ts.ejs +66 -0
- package/overrides/gobject/index.ts.ejs +3 -0
- package/overrides/gobject/object-class.ts.ejs +27 -0
- package/overrides/gobject/param-spec-getters.ts.ejs +57 -0
- package/overrides/gobject/param-spec.ts.ejs +21 -0
- package/overrides/gobject/value.ts.ejs +6 -1
- package/overrides/graphene/structs.ts.ejs +38 -3
- package/overrides/gtk/index.ts.ejs +2 -0
- package/overrides/gtk/widget-class.ts.ejs +28 -0
- package/package.json +6 -5
- package/src/analysis/descriptor-render.ts +59 -16
- package/src/analysis/descriptor.ts +15 -3
- package/src/analysis/param-capability.ts +68 -5
- package/src/analysis/param-structure.ts +1 -1
- package/src/analysis/ts-type.ts +45 -11
- package/src/compile.ts +1 -1
- package/src/docs/api-reference.ts +20 -2
- package/src/docs/pipeline.ts +15 -1
- package/src/fingerprint.ts +144 -16
- package/src/gi.ts +44 -9
- package/src/gir/external-namespaces.ts +8 -0
- package/src/gir/finish-overrides.ts +5 -0
- package/src/gir/function.ts +52 -14
- package/src/gir/hidden-symbols.ts +39 -0
- package/src/gir/library.ts +36 -3
- package/src/gir/ucs4-overrides.ts +7 -0
- package/src/jsx.ts +33 -8
- package/src/runner.ts +17 -3
- package/src/store/external-package-links.ts +226 -0
- package/src/store/gi/callable-doc.ts +8 -4
- package/src/store/gi/callables.ts +5 -5
- package/src/store/gi/class.ts +42 -32
- package/src/store/gi/constructor-props.ts +1 -1
- package/src/store/gi/function.ts +2 -1
- package/src/store/gi/gtype-binding.ts +7 -15
- package/src/store/gi/interface.ts +2 -2
- package/src/store/gi/method.ts +189 -36
- package/src/store/gi/param-marshal.ts +67 -4
- package/src/store/gi/record-constructor.ts +8 -3
- package/src/store/gi/record-field-accessor.ts +209 -16
- package/src/store/gi/record-layout.ts +11 -1
- package/src/store/gi/record.ts +17 -13
- package/src/store/gi/runtime-override.ts +1 -1
- package/src/store/gi/signal.ts +2 -2
- package/src/store/gi/vtable.ts +118 -11
- package/src/store/gi-store.ts +33 -3
- package/src/store/jsx/jsx.ts +3 -1
- package/src/store/jsx-store.ts +23 -7
- package/src/store/resolve-store.ts +2 -1
- package/src/store/store-fs.ts +10 -2
- package/src/writer/context.ts +11 -0
- package/src/writer/gtk-doc.ts +38 -1
- package/overrides/cairo/context.ts.ejs +0 -1269
- package/overrides/cairo/font-face.ts.ejs +0 -151
- package/overrides/cairo/font-options.ts.ejs +0 -199
- package/overrides/cairo/image-surface.ts.ejs +0 -132
- package/overrides/cairo/index.ts.ejs +0 -22
- package/overrides/cairo/matrix.ts.ejs +0 -171
- package/overrides/cairo/pattern.ts.ejs +0 -476
- package/overrides/cairo/recording-surface.ts.ejs +0 -102
- package/overrides/cairo/region.ts.ejs +0 -237
- package/overrides/cairo/scaled-font.ts.ejs +0 -330
- package/overrides/cairo/surface.ts.ejs +0 -296
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqD,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAEH,KAAK,YAAY,EAIpB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqD,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAEH,KAAK,YAAY,EAIpB,MAAM,gBAAgB,CAAC;AAcxB,+GAA+G;AAC/G,KAAK,cAAc,GAAG;IAClB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yGAAyG;IACzG,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oGAAoG;IACpG,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uGAAuG;IACvG,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAsCF;;;GAGG;AACH,cAAM,OAAO;IACT,OAAO,CAAC,MAAM,CAAC,KAAK;IAcpB;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,cAAmB,GAAG,OAAO;IAWzF,OAAO,CAAC,gBAAgB,CAAwC;IAChE,OAAO,CAAC,aAAa,CAAoC;IACzD,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,UAAU,CAAmB;IACrC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,oBAAoB,CAAS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OAAO,GAAG,SAAS;CAsB/E;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/gir/library.js
CHANGED
|
@@ -44,12 +44,15 @@ class Library {
|
|
|
44
44
|
*
|
|
45
45
|
* @param libraries GIR identifiers to load, such as `Gtk-4.0`.
|
|
46
46
|
* @param girPath Directories searched, in order, for each `.gir` file.
|
|
47
|
-
* @param
|
|
47
|
+
* @param future Behavior the project opted into ahead of the next major version.
|
|
48
48
|
* @returns A library holding every namespace that was parsed.
|
|
49
49
|
*/
|
|
50
|
-
static load(libraries, girPath,
|
|
50
|
+
static load(libraries, girPath, future = {}) {
|
|
51
51
|
const library = new Library();
|
|
52
|
-
library.isByteArrayTypedValue = isByteArrayTyped;
|
|
52
|
+
library.isByteArrayTypedValue = future.isByteArrayTyped === true;
|
|
53
|
+
library.isValueUnwrappedValue = future.isValueUnwrapped === true;
|
|
54
|
+
library.isFinishTrimmedValue = future.isFinishTrimmed === true;
|
|
55
|
+
library.isInoutInPlaceValue = future.isInoutInPlace === true;
|
|
53
56
|
this.drive(library, libraries, girPath);
|
|
54
57
|
return library;
|
|
55
58
|
}
|
|
@@ -60,6 +63,9 @@ class Library {
|
|
|
60
63
|
typeTables = [];
|
|
61
64
|
girFilesValue = [];
|
|
62
65
|
isByteArrayTypedValue = false;
|
|
66
|
+
isValueUnwrappedValue = false;
|
|
67
|
+
isFinishTrimmedValue = false;
|
|
68
|
+
isInoutInPlaceValue = false;
|
|
63
69
|
/** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */
|
|
64
70
|
constructor() {
|
|
65
71
|
this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };
|
|
@@ -227,6 +233,18 @@ class Library {
|
|
|
227
233
|
get isByteArrayTyped() {
|
|
228
234
|
return this.isByteArrayTypedValue;
|
|
229
235
|
}
|
|
236
|
+
/** Whether a `GObject.Value` a binding hands back surfaces as what it holds rather than as the value. */
|
|
237
|
+
get isValueUnwrapped() {
|
|
238
|
+
return this.isValueUnwrappedValue;
|
|
239
|
+
}
|
|
240
|
+
/** Whether a promisified result drops the leading success boolean of a throwing finish function. */
|
|
241
|
+
get isFinishTrimmed() {
|
|
242
|
+
return this.isFinishTrimmedValue;
|
|
243
|
+
}
|
|
244
|
+
/** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */
|
|
245
|
+
get isInoutInPlace() {
|
|
246
|
+
return this.isInoutInPlaceValue;
|
|
247
|
+
}
|
|
230
248
|
/** Paths of the `.gir` files that were read, in the order they were discovered. */
|
|
231
249
|
get girFiles() {
|
|
232
250
|
return this.girFilesValue;
|
package/dist/gir/library.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.js","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACH,oBAAoB,EAGpB,oBAAoB,EACpB,qBAAqB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAoBvD,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAW,EAAE;IACjD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IAEnC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,2BAA2B,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,UAAqB,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,C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CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAElG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE9D,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACnB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACJ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PrimitiveCategory } from \"./primitives.js\";\nimport type { CArrayType, HashTableType, ListType, ParseContext, TypeId } from \"./type-id.js\";\nimport type { GirType } from \"./type.js\";\nimport { callbackFromNode } from \"./callback.js\";\nimport {\n createNamespaceShell,\n type GirNamespace,\n type NamespaceHeader,\n parseNamespaceHeader,\n populateNamespaceBody,\n} from \"./namespace.js\";\nimport { parseGirFile, type RawNode } from \"./parse.js\";\nimport { splitOptionalNamespace } from \"./type-ref.js\";\n\n/** The types belonging to one namespace, addressed by the id half of a {@link TypeId}. */\ntype TypeTable = {\n /** Parsed type in each slot, still `undefined` while only a forward reference to it has been seen. */\n types: (GirType | undefined)[];\n /** Declared name of each slot, `undefined` for anonymous types such as containers and inline callbacks. */\n names: (string | undefined)[];\n /** Slot id each named type occupies, so repeated references resolve to the same id. */\n index: Map<string, number>;\n};\n\n/** A namespace whose header has been read and whose shell is registered, before its body is parsed. */\ntype DiscoveredNamespace = {\n /** Attributes and includes read from the namespace's GIR file. */\n header: NamespaceHeader;\n /** Empty namespace registered for the header, populated once every header is known. */\n shell: GirNamespace;\n};\n\nconst INTERNAL_NS_ID = 0;\n\nconst readRepositoryNode = (path: string): RawNode => {\n const root = parseGirFile(path);\n const repository = root.repository;\n\n if (typeof repository !== \"object\" || repository === null) {\n throw new Error(`GIR file at ${path} has no <repository> root`);\n }\n\n return repository as RawNode;\n};\n\nconst locateGirFile = (identifier: string, girPath: string[]): string => {\n const filename = `${identifier}.gir`;\n\n for (const directory of girPath) {\n const candidate = join(directory, filename);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const tried = girPath.map((directory) => join(directory, filename)).join(\", \");\n throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);\n};\n\n/**\n * The parsed GIR universe: every requested namespace plus everything those namespaces include,\n * with types resolvable across namespace boundaries.\n */\nclass Library {\n private static drive(library: Library, libraries: string[], girPath: string[]): void {\n const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);\n\n for (const { header, shell } of discovered) {\n populateNamespaceBody(shell, header.namespaceNode, library.parseContext(shell.id));\n }\n\n for (const { shell } of discovered) {\n library.addDeclarations(shell);\n }\n\n library.girFilesValue = girFiles;\n }\n\n /**\n * Parses the named GIR libraries along with every namespace they transitively include.\n *\n * @param libraries GIR identifiers to load, such as `Gtk-4.0`.\n * @param girPath Directories searched, in order, for each `.gir` file.\n * @param isByteArrayTyped Whether byte sequences render as `Uint8Array` rather than `number[]`.\n * @returns A library holding every namespace that was parsed.\n */\n static load(libraries: string[], girPath: string[], isByteArrayTyped = false): Library {\n const library = new Library();\n library.isByteArrayTypedValue = isByteArrayTyped;\n this.drive(library, libraries, girPath);\n\n return library;\n }\n\n private namespacesByName: Map<string, GirNamespace> = new Map();\n private namespaceById: (GirNamespace | undefined)[] = [];\n private nsNameById: string[] = [];\n private nsIdByName: Map<string, number> = new Map();\n private typeTables: TypeTable[] = [];\n private girFilesValue: string[] = [];\n private isByteArrayTypedValue = false;\n\n /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */\n constructor() {\n this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };\n this.namespaceById[INTERNAL_NS_ID] = undefined;\n this.nsNameById[INTERNAL_NS_ID] = \"$internal\";\n }\n\n private ensureNsId(name: string): number {\n const existing = this.nsIdByName.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const nsId = this.typeTables.length;\n this.typeTables[nsId] = { types: [], names: [], index: new Map() };\n this.namespaceById[nsId] = undefined;\n this.nsNameById[nsId] = name;\n this.nsIdByName.set(name, nsId);\n\n return nsId;\n }\n\n private registerNamespace(header: NamespaceHeader): GirNamespace {\n const nsId = this.ensureNsId(header.name);\n const shell = createNamespaceShell(header, nsId);\n this.namespaceById[nsId] = shell;\n this.namespacesByName.set(header.name, shell);\n\n return shell;\n }\n\n private namespaceFor(nsId: number): GirNamespace {\n const namespace = this.namespaceById[nsId];\n\n if (namespace === undefined) {\n throw new Error(`No namespace registered for type table id ${String(nsId)}`);\n }\n\n return namespace;\n }\n\n private typeTableFor(nsId: number): TypeTable {\n const typeTable = this.typeTables[nsId];\n\n if (typeTable === undefined) {\n throw new Error(`No type table for namespace id ${String(nsId)}`);\n }\n\n return typeTable;\n }\n\n private insertIntoTypeTable(\n typeTable: TypeTable,\n slot: { type: GirType | undefined; indexKey?: string; displayName?: string },\n ): number {\n const id = typeTable.types.length;\n typeTable.types.push(slot.type);\n typeTable.names.push(slot.displayName);\n\n if (slot.indexKey !== undefined) {\n typeTable.index.set(slot.indexKey, id);\n }\n\n return id;\n }\n\n private resolveTypeId(nsId: number, name: string, type: GirType | undefined): number {\n const typeTable = this.typeTableFor(nsId);\n const existing = typeTable.index.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n return this.insertIntoTypeTable(typeTable, { type, indexKey: name, displayName: name });\n }\n\n private addType(nsId: number, name: string, type: GirType): void {\n this.typeTableFor(nsId).types[this.resolveTypeId(nsId, name, type)] = type;\n }\n\n private findType(nsId: number, name: string): TypeId {\n return { nsId, id: this.resolveTypeId(nsId, name, undefined) };\n }\n\n private addAnonymousType(nsId: number, type: GirType): TypeId {\n const typeTable = this.typeTableFor(nsId);\n const id = this.insertIntoTypeTable(typeTable, { type });\n\n return { nsId, id };\n }\n\n private findTypeByName(currentNsId: number, name: string): TypeId {\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.ensureNsId(namespaceName);\n\n return this.findType(targetNsId, localName);\n }\n\n private parseContext(nsId: number): ParseContext {\n const context: ParseContext = {\n nsId,\n findType: (name) => this.findTypeByName(nsId, name),\n addPrimitive: (category) => this.addPrimitive(category),\n addVarargs: () => this.addVarargs(),\n addContainer: (type: CArrayType | ListType | HashTableType) => this.addAnonymousType(nsId, type),\n addAnonymousCallback: (node) =>\n this.addAnonymousType(nsId, {\n kind: \"callback\",\n namespace: this.namespaceFor(nsId),\n value: callbackFromNode(node, context),\n }),\n };\n\n return context;\n }\n\n private addPrimitive(category: PrimitiveCategory): TypeId {\n return this.findOrAddContainer(`primitive:${category}`, { kind: \"primitive\", category });\n }\n\n private addVarargs(): TypeId {\n return this.findOrAddContainer(\"varargs\", { kind: \"varargs\" });\n }\n\n private findOrAddContainer(key: string, type: GirType): TypeId {\n const typeTable = this.typeTableFor(INTERNAL_NS_ID);\n const existing = typeTable.index.get(key);\n\n if (existing !== undefined) {\n return { nsId: INTERNAL_NS_ID, id: existing };\n }\n\n const id = this.insertIntoTypeTable(typeTable, { type, indexKey: key });\n\n return { nsId: INTERNAL_NS_ID, id };\n }\n\n private addDeclarations(shell: GirNamespace): void {\n this.addClassDeclarations(shell);\n this.addValueDeclarations(shell);\n }\n\n private addClassDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.classes) {\n this.addType(nsId, value.name, { kind: \"class\", namespace: shell, value });\n }\n\n for (const value of shell.interfaces) {\n this.addType(nsId, value.name, { kind: \"interface\", namespace: shell, value });\n }\n\n for (const value of shell.records) {\n this.addType(nsId, value.name, { kind: \"record\", namespace: shell, value });\n }\n }\n\n private addValueDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.enums) {\n this.addType(nsId, value.name, { kind: \"enum\", namespace: shell, value });\n }\n\n for (const value of shell.callbacks) {\n this.addType(nsId, value.name, { kind: \"callback\", namespace: shell, value });\n }\n\n for (const alias of shell.aliases) {\n this.addType(nsId, alias.name, { kind: \"alias\", namespace: shell, value: alias });\n }\n }\n\n private processIdentifier(input: {\n identifier: string;\n girPath: string[];\n seen: Set<string>;\n queue: string[];\n girFiles: string[];\n discovered: DiscoveredNamespace[];\n }): void {\n const { identifier, girPath, seen, queue, girFiles, discovered } = input;\n const namespaceName = identifier.split(\"-\", 1)[0] ?? identifier;\n\n if (seen.has(namespaceName)) {\n return;\n }\n\n seen.add(namespaceName);\n const path = locateGirFile(identifier, girPath);\n girFiles.push(path);\n const header = parseNamespaceHeader(readRepositoryNode(path), path);\n const shell = this.registerNamespace(header);\n discovered.push({ header, shell });\n\n for (const include of header.includes) {\n queue.push(`${include.name}-${include.version}`);\n }\n }\n\n private discoverNamespaces(\n libraries: string[],\n girPath: string[],\n ): { discovered: DiscoveredNamespace[]; girFiles: string[] } {\n const queue: string[] = [...libraries];\n const seen: Set<string> = new Set();\n const discovered: DiscoveredNamespace[] = [];\n const girFiles: string[] = [];\n\n while (queue.length > 0) {\n const identifier = queue.shift();\n\n if (identifier !== undefined) {\n this.processIdentifier({ identifier, girPath, seen, queue, girFiles, discovered });\n }\n }\n\n return { discovered, girFiles };\n }\n\n /** The loaded namespaces, keyed by their GIR name such as `Gtk`. */\n public get namespaces(): Map<string, GirNamespace> {\n return this.namespacesByName;\n }\n\n /** Whether byte sequences render as `Uint8Array` rather than `number[]`. */\n public get isByteArrayTyped(): boolean {\n return this.isByteArrayTypedValue;\n }\n\n /** Paths of the `.gir` files that were read, in the order they were discovered. */\n public get girFiles(): string[] {\n return this.girFilesValue;\n }\n\n /**\n * Reads the type a {@link TypeId} points at.\n *\n * @param tid The type id to dereference.\n * @returns The parsed type, or `undefined` when nothing has been parsed into that slot.\n */\n typeFor(tid: TypeId): GirType | undefined {\n return this.typeTables[tid.nsId]?.types[tid.id];\n }\n\n /**\n * Reads the name a {@link TypeId} was registered under.\n *\n * @param tid The type id to name.\n * @returns The namespace and type name, or `undefined` for an anonymous type.\n */\n nameFor(tid: TypeId): {\n /** GIR namespace to qualify the type with, such as `Gtk`. */\n namespaceName: string;\n /** Unqualified type name as GIR declares it, such as `Widget`. */\n typeName: string;\n } | undefined {\n const typeName = this.typeTables[tid.nsId]?.names[tid.id];\n const namespaceName = this.nsNameById[tid.nsId];\n\n if (typeName === undefined || namespaceName === undefined) {\n return undefined;\n }\n\n return { namespaceName, typeName };\n }\n\n /**\n * Looks up a type by the name a GIR file writes, resolving an unqualified name against the\n * namespace it appears in and a `Namespace.Type` name against the loaded namespaces.\n *\n * @param currentNamespaceName Namespace the name is written in.\n * @param name Type name, optionally qualified with a namespace prefix.\n * @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.\n */\n resolveType(currentNamespaceName: string, name: string): GirType | undefined {\n const currentNsId = this.nsIdByName.get(currentNamespaceName);\n\n if (currentNsId === undefined) {\n return undefined;\n }\n\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.nsIdByName.get(namespaceName);\n\n if (targetNsId === undefined) {\n return undefined;\n }\n\n const id = this.typeTableFor(targetNsId).index.get(localName);\n\n if (id === undefined) {\n return undefined;\n }\n\n return this.typeTableFor(targetNsId).types[id];\n }\n}\n\nexport { Library };\n"]}
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../../src/gir/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACH,oBAAoB,EAGpB,oBAAoB,EACpB,qBAAqB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAC;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AG,CAAC,SAAS,CAAC,CAAC;QAE9D,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACnB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACJ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { PrimitiveCategory } from \"./primitives.js\";\nimport type { CArrayType, HashTableType, ListType, ParseContext, TypeId } from \"./type-id.js\";\nimport type { GirType } from \"./type.js\";\nimport { callbackFromNode } from \"./callback.js\";\nimport {\n createNamespaceShell,\n type GirNamespace,\n type NamespaceHeader,\n parseNamespaceHeader,\n populateNamespaceBody,\n} from \"./namespace.js\";\nimport { parseGirFile, type RawNode } from \"./parse.js\";\nimport { splitOptionalNamespace } from \"./type-ref.js\";\n\n/** The types belonging to one namespace, addressed by the id half of a {@link TypeId}. */\ntype TypeTable = {\n /** Parsed type in each slot, still `undefined` while only a forward reference to it has been seen. */\n types: (GirType | undefined)[];\n /** Declared name of each slot, `undefined` for anonymous types such as containers and inline callbacks. */\n names: (string | undefined)[];\n /** Slot id each named type occupies, so repeated references resolve to the same id. */\n index: Map<string, number>;\n};\n\n/** Behavior a project opted into ahead of the next major version, through the `future` block of its config. */\ntype FutureBehavior = {\n /** Whether byte sequences render as `Uint8Array` rather than `number[]`. */\n isByteArrayTyped?: boolean;\n /** Whether a `GObject.Value` a binding hands back surfaces as what it holds rather than as the value. */\n isValueUnwrapped?: boolean;\n /** Whether a promisified result drops the leading success boolean of a throwing finish function. */\n isFinishTrimmed?: boolean;\n /** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */\n isInoutInPlace?: boolean;\n};\n\n/** A namespace whose header has been read and whose shell is registered, before its body is parsed. */\ntype DiscoveredNamespace = {\n /** Attributes and includes read from the namespace's GIR file. */\n header: NamespaceHeader;\n /** Empty namespace registered for the header, populated once every header is known. */\n shell: GirNamespace;\n};\n\nconst INTERNAL_NS_ID = 0;\n\nconst readRepositoryNode = (path: string): RawNode => {\n const root = parseGirFile(path);\n const repository = root.repository;\n\n if (typeof repository !== \"object\" || repository === null) {\n throw new Error(`GIR file at ${path} has no <repository> root`);\n }\n\n return repository as RawNode;\n};\n\nconst locateGirFile = (identifier: string, girPath: string[]): string => {\n const filename = `${identifier}.gir`;\n\n for (const directory of girPath) {\n const candidate = join(directory, filename);\n\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const tried = girPath.map((directory) => join(directory, filename)).join(\", \");\n throw new Error(`GIR file ${filename} not found on girPath. Tried: ${tried}`);\n};\n\n/**\n * The parsed GIR universe: every requested namespace plus everything those namespaces include,\n * with types resolvable across namespace boundaries.\n */\nclass Library {\n private static drive(library: Library, libraries: string[], girPath: string[]): void {\n const { discovered, girFiles } = library.discoverNamespaces(libraries, girPath);\n\n for (const { header, shell } of discovered) {\n populateNamespaceBody(shell, header.namespaceNode, library.parseContext(shell.id));\n }\n\n for (const { shell } of discovered) {\n library.addDeclarations(shell);\n }\n\n library.girFilesValue = girFiles;\n }\n\n /**\n * Parses the named GIR libraries along with every namespace they transitively include.\n *\n * @param libraries GIR identifiers to load, such as `Gtk-4.0`.\n * @param girPath Directories searched, in order, for each `.gir` file.\n * @param future Behavior the project opted into ahead of the next major version.\n * @returns A library holding every namespace that was parsed.\n */\n static load(libraries: string[], girPath: string[], future: FutureBehavior = {}): Library {\n const library = new Library();\n library.isByteArrayTypedValue = future.isByteArrayTyped === true;\n library.isValueUnwrappedValue = future.isValueUnwrapped === true;\n library.isFinishTrimmedValue = future.isFinishTrimmed === true;\n library.isInoutInPlaceValue = future.isInoutInPlace === true;\n this.drive(library, libraries, girPath);\n\n return library;\n }\n\n private namespacesByName: Map<string, GirNamespace> = new Map();\n private namespaceById: (GirNamespace | undefined)[] = [];\n private nsNameById: string[] = [];\n private nsIdByName: Map<string, number> = new Map();\n private typeTables: TypeTable[] = [];\n private girFilesValue: string[] = [];\n private isByteArrayTypedValue = false;\n private isValueUnwrappedValue = false;\n private isFinishTrimmedValue = false;\n private isInoutInPlaceValue = false;\n\n /** Creates a library with no namespaces loaded; {@link Library.load} builds a populated one. */\n constructor() {\n this.typeTables[INTERNAL_NS_ID] = { types: [], names: [], index: new Map() };\n this.namespaceById[INTERNAL_NS_ID] = undefined;\n this.nsNameById[INTERNAL_NS_ID] = \"$internal\";\n }\n\n private ensureNsId(name: string): number {\n const existing = this.nsIdByName.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const nsId = this.typeTables.length;\n this.typeTables[nsId] = { types: [], names: [], index: new Map() };\n this.namespaceById[nsId] = undefined;\n this.nsNameById[nsId] = name;\n this.nsIdByName.set(name, nsId);\n\n return nsId;\n }\n\n private registerNamespace(header: NamespaceHeader): GirNamespace {\n const nsId = this.ensureNsId(header.name);\n const shell = createNamespaceShell(header, nsId);\n this.namespaceById[nsId] = shell;\n this.namespacesByName.set(header.name, shell);\n\n return shell;\n }\n\n private namespaceFor(nsId: number): GirNamespace {\n const namespace = this.namespaceById[nsId];\n\n if (namespace === undefined) {\n throw new Error(`No namespace registered for type table id ${String(nsId)}`);\n }\n\n return namespace;\n }\n\n private typeTableFor(nsId: number): TypeTable {\n const typeTable = this.typeTables[nsId];\n\n if (typeTable === undefined) {\n throw new Error(`No type table for namespace id ${String(nsId)}`);\n }\n\n return typeTable;\n }\n\n private insertIntoTypeTable(\n typeTable: TypeTable,\n slot: { type: GirType | undefined; indexKey?: string; displayName?: string },\n ): number {\n const id = typeTable.types.length;\n typeTable.types.push(slot.type);\n typeTable.names.push(slot.displayName);\n\n if (slot.indexKey !== undefined) {\n typeTable.index.set(slot.indexKey, id);\n }\n\n return id;\n }\n\n private resolveTypeId(nsId: number, name: string, type: GirType | undefined): number {\n const typeTable = this.typeTableFor(nsId);\n const existing = typeTable.index.get(name);\n\n if (existing !== undefined) {\n return existing;\n }\n\n return this.insertIntoTypeTable(typeTable, { type, indexKey: name, displayName: name });\n }\n\n private addType(nsId: number, name: string, type: GirType): void {\n this.typeTableFor(nsId).types[this.resolveTypeId(nsId, name, type)] = type;\n }\n\n private findType(nsId: number, name: string): TypeId {\n return { nsId, id: this.resolveTypeId(nsId, name, undefined) };\n }\n\n private addAnonymousType(nsId: number, type: GirType): TypeId {\n const typeTable = this.typeTableFor(nsId);\n const id = this.insertIntoTypeTable(typeTable, { type });\n\n return { nsId, id };\n }\n\n private findTypeByName(currentNsId: number, name: string): TypeId {\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.ensureNsId(namespaceName);\n\n return this.findType(targetNsId, localName);\n }\n\n private parseContext(nsId: number): ParseContext {\n const context: ParseContext = {\n nsId,\n findType: (name) => this.findTypeByName(nsId, name),\n addPrimitive: (category) => this.addPrimitive(category),\n addVarargs: () => this.addVarargs(),\n addContainer: (type: CArrayType | ListType | HashTableType) => this.addAnonymousType(nsId, type),\n addAnonymousCallback: (node) =>\n this.addAnonymousType(nsId, {\n kind: \"callback\",\n namespace: this.namespaceFor(nsId),\n value: callbackFromNode(node, context),\n }),\n };\n\n return context;\n }\n\n private addPrimitive(category: PrimitiveCategory): TypeId {\n return this.findOrAddContainer(`primitive:${category}`, { kind: \"primitive\", category });\n }\n\n private addVarargs(): TypeId {\n return this.findOrAddContainer(\"varargs\", { kind: \"varargs\" });\n }\n\n private findOrAddContainer(key: string, type: GirType): TypeId {\n const typeTable = this.typeTableFor(INTERNAL_NS_ID);\n const existing = typeTable.index.get(key);\n\n if (existing !== undefined) {\n return { nsId: INTERNAL_NS_ID, id: existing };\n }\n\n const id = this.insertIntoTypeTable(typeTable, { type, indexKey: key });\n\n return { nsId: INTERNAL_NS_ID, id };\n }\n\n private addDeclarations(shell: GirNamespace): void {\n this.addClassDeclarations(shell);\n this.addValueDeclarations(shell);\n }\n\n private addClassDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.classes) {\n this.addType(nsId, value.name, { kind: \"class\", namespace: shell, value });\n }\n\n for (const value of shell.interfaces) {\n this.addType(nsId, value.name, { kind: \"interface\", namespace: shell, value });\n }\n\n for (const value of shell.records) {\n this.addType(nsId, value.name, { kind: \"record\", namespace: shell, value });\n }\n }\n\n private addValueDeclarations(shell: GirNamespace): void {\n const nsId = shell.id;\n\n for (const value of shell.enums) {\n this.addType(nsId, value.name, { kind: \"enum\", namespace: shell, value });\n }\n\n for (const value of shell.callbacks) {\n this.addType(nsId, value.name, { kind: \"callback\", namespace: shell, value });\n }\n\n for (const alias of shell.aliases) {\n this.addType(nsId, alias.name, { kind: \"alias\", namespace: shell, value: alias });\n }\n }\n\n private processIdentifier(input: {\n identifier: string;\n girPath: string[];\n seen: Set<string>;\n queue: string[];\n girFiles: string[];\n discovered: DiscoveredNamespace[];\n }): void {\n const { identifier, girPath, seen, queue, girFiles, discovered } = input;\n const namespaceName = identifier.split(\"-\", 1)[0] ?? identifier;\n\n if (seen.has(namespaceName)) {\n return;\n }\n\n seen.add(namespaceName);\n const path = locateGirFile(identifier, girPath);\n girFiles.push(path);\n const header = parseNamespaceHeader(readRepositoryNode(path), path);\n const shell = this.registerNamespace(header);\n discovered.push({ header, shell });\n\n for (const include of header.includes) {\n queue.push(`${include.name}-${include.version}`);\n }\n }\n\n private discoverNamespaces(\n libraries: string[],\n girPath: string[],\n ): { discovered: DiscoveredNamespace[]; girFiles: string[] } {\n const queue: string[] = [...libraries];\n const seen: Set<string> = new Set();\n const discovered: DiscoveredNamespace[] = [];\n const girFiles: string[] = [];\n\n while (queue.length > 0) {\n const identifier = queue.shift();\n\n if (identifier !== undefined) {\n this.processIdentifier({ identifier, girPath, seen, queue, girFiles, discovered });\n }\n }\n\n return { discovered, girFiles };\n }\n\n /** The loaded namespaces, keyed by their GIR name such as `Gtk`. */\n public get namespaces(): Map<string, GirNamespace> {\n return this.namespacesByName;\n }\n\n /** Whether byte sequences render as `Uint8Array` rather than `number[]`. */\n public get isByteArrayTyped(): boolean {\n return this.isByteArrayTypedValue;\n }\n\n /** Whether a `GObject.Value` a binding hands back surfaces as what it holds rather than as the value. */\n public get isValueUnwrapped(): boolean {\n return this.isValueUnwrappedValue;\n }\n\n /** Whether a promisified result drops the leading success boolean of a throwing finish function. */\n public get isFinishTrimmed(): boolean {\n return this.isFinishTrimmedValue;\n }\n\n /** Whether a handle-passing inout parameter is mutated in place rather than packed into the result. */\n public get isInoutInPlace(): boolean {\n return this.isInoutInPlaceValue;\n }\n\n /** Paths of the `.gir` files that were read, in the order they were discovered. */\n public get girFiles(): string[] {\n return this.girFilesValue;\n }\n\n /**\n * Reads the type a {@link TypeId} points at.\n *\n * @param tid The type id to dereference.\n * @returns The parsed type, or `undefined` when nothing has been parsed into that slot.\n */\n typeFor(tid: TypeId): GirType | undefined {\n return this.typeTables[tid.nsId]?.types[tid.id];\n }\n\n /**\n * Reads the name a {@link TypeId} was registered under.\n *\n * @param tid The type id to name.\n * @returns The namespace and type name, or `undefined` for an anonymous type.\n */\n nameFor(tid: TypeId): {\n /** GIR namespace to qualify the type with, such as `Gtk`. */\n namespaceName: string;\n /** Unqualified type name as GIR declares it, such as `Widget`. */\n typeName: string;\n } | undefined {\n const typeName = this.typeTables[tid.nsId]?.names[tid.id];\n const namespaceName = this.nsNameById[tid.nsId];\n\n if (typeName === undefined || namespaceName === undefined) {\n return undefined;\n }\n\n return { namespaceName, typeName };\n }\n\n /**\n * Looks up a type by the name a GIR file writes, resolving an unqualified name against the\n * namespace it appears in and a `Namespace.Type` name against the loaded namespaces.\n *\n * @param currentNamespaceName Namespace the name is written in.\n * @param name Type name, optionally qualified with a namespace prefix.\n * @returns The parsed type, or `undefined` when the name is unknown or only a forward reference to it exists.\n */\n resolveType(currentNamespaceName: string, name: string): GirType | undefined {\n const currentNsId = this.nsIdByName.get(currentNamespaceName);\n\n if (currentNsId === undefined) {\n return undefined;\n }\n\n const [namespaceName, localName] = splitOptionalNamespace(name);\n const targetNsId = namespaceName === undefined ? currentNsId : this.nsIdByName.get(namespaceName);\n\n if (targetNsId === undefined) {\n return undefined;\n }\n\n const id = this.typeTableFor(targetNsId).index.get(localName);\n\n if (id === undefined) {\n return undefined;\n }\n\n return this.typeTableFor(targetNsId).types[id];\n }\n}\n\nexport { Library };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ucs4-overrides.d.ts","sourceRoot":"","sources":["../../src/gir/ucs4-overrides.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,+BAA+B,EAAE,GAAG,CAAC,MAAM,CAI/C,CAAC;AAEH,OAAO,EAAE,+BAA+B,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ucs4-overrides.js","sourceRoot":"","sources":["../../src/gir/ucs4-overrides.ts"],"names":[],"mappings":"AAAA,MAAM,+BAA+B,GAAgB,IAAI,GAAG,CAAC;IACzD,gBAAgB;IAChB,qBAAqB;IACrB,iBAAiB;CACpB,CAAC,CAAC;AAEH,OAAO,EAAE,+BAA+B,EAAE,CAAC","sourcesContent":["const RETURNS_MISSING_UCS4_ARRAY_TYPE: Set<string> = new Set([\n \"g_utf8_to_ucs4\",\n \"g_utf8_to_ucs4_fast\",\n \"g_utf16_to_ucs4\",\n]);\n\nexport { RETURNS_MISSING_UCS4_ARRAY_TYPE };\n"]}
|
package/dist/jsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,2BAA2B,CAAC;AAGnF,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGpF,KAAK,oBAAoB,GAAG;IACxB,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,GAAG,EAAE,YAAY,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,gBAAgB,EAAE,YAAY,CAAC;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,QAAA,MAAM,aAAa,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,mBAAmB,CAkDvF,CAAC;AAgBF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/jsx.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { computeJsxFingerprint, FINGERPRINT_FILENAME, jsxStoreFreshness, } from "./fingerprint.js";
|
|
2
|
+
import { externalPackageFor } from "./gir/external-namespaces.js";
|
|
2
3
|
import { readBuiltinElements } from "./react/element-config.js";
|
|
3
4
|
import { writeJsxStore } from "./store/jsx-store.js";
|
|
4
5
|
import { ELEMENTS_FILENAME, renderGeneratedElements } from "./store/jsx/generated-elements.js";
|
|
@@ -12,6 +13,7 @@ const runJsxCodegen = async (options) => {
|
|
|
12
13
|
const omittedProps = mergeOmittedProps(builtin.omittedProps, options.userOmittedProps);
|
|
13
14
|
const fingerprintInput = {
|
|
14
15
|
reactVersion: options.jsx.version,
|
|
16
|
+
reactSubexports: options.reactSubexports,
|
|
15
17
|
components,
|
|
16
18
|
lazyElements,
|
|
17
19
|
props,
|
|
@@ -23,21 +25,38 @@ const runJsxCodegen = async (options) => {
|
|
|
23
25
|
return { isRegenerated: false, intrinsicElementCount };
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
const
|
|
28
|
+
const library = options.getLibrary();
|
|
29
|
+
const { namespaces, metadata, intrinsicElementCount, elements } = generateJsxFiles(library, {
|
|
27
30
|
reactSubexports: options.reactSubexports,
|
|
28
31
|
components,
|
|
29
32
|
lazyElements,
|
|
30
33
|
props,
|
|
31
34
|
omittedProps,
|
|
32
35
|
});
|
|
33
|
-
writeJsxStore(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
writeJsxStore({
|
|
37
|
+
options: options.jsx,
|
|
38
|
+
namespaces,
|
|
39
|
+
metadata,
|
|
40
|
+
externalPackages: storeExternalPackages(library),
|
|
41
|
+
rawFiles: [
|
|
42
|
+
{
|
|
43
|
+
relativePath: FINGERPRINT_FILENAME,
|
|
44
|
+
content: `${JSON.stringify(computeJsxFingerprint(fingerprintInput, intrinsicElementCount), null, 2)}\n`,
|
|
45
|
+
},
|
|
46
|
+
{ relativePath: ELEMENTS_FILENAME, content: renderGeneratedElements(elements) },
|
|
47
|
+
],
|
|
48
|
+
});
|
|
40
49
|
return { isRegenerated: true, intrinsicElementCount };
|
|
41
50
|
};
|
|
51
|
+
const storeExternalPackages = (library) => {
|
|
52
|
+
const packages = new Set();
|
|
53
|
+
for (const namespace of library.namespaces.values()) {
|
|
54
|
+
const packageName = externalPackageFor(namespace.name);
|
|
55
|
+
if (packageName !== undefined) {
|
|
56
|
+
packages.add(packageName);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return [...packages];
|
|
60
|
+
};
|
|
42
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,CAAC,IAAI;aACrG;YACD,EAAE,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,uBAAuB,CAAC,QAAQ,CAAC,EAAE;SAClF;KACJ,CAAC,CAAC;IAEH,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,OAAgB,EAAY,EAAE;IACzD,MAAM,QAAQ,GAAgB,IAAI,GAAG,EAAE,CAAC;IAExC,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;QAClD,MAAM,WAAW,GAAG,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC5B,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { Library } from \"./gir/library.js\";\nimport type { StoreOptions } from \"./store/store-fs.js\";\nimport {\n computeJsxFingerprint,\n FINGERPRINT_FILENAME,\n type JsxFingerprintInput,\n jsxStoreFreshness,\n} from \"./fingerprint.js\";\nimport { externalPackageFor } from \"./gir/external-namespaces.js\";\nimport { type ModuleExport, readBuiltinElements } from \"./react/element-config.js\";\nimport { writeJsxStore } from \"./store/jsx-store.js\";\nimport { ELEMENTS_FILENAME, renderGeneratedElements } from \"./store/jsx/generated-elements.js\";\nimport { mergeOmittedProps, type OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { generateJsxFiles } from \"./store/jsx/pipeline.js\";\n\ntype RunJsxCodegenOptions = {\n getLibrary: () => Library;\n jsx: StoreOptions;\n giStoreDir: string;\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n isGiRegenerated: boolean;\n isForced: boolean;\n};\n\ntype RunJsxCodegenResult = {\n isRegenerated: boolean;\n intrinsicElementCount: number;\n};\n\nconst runJsxCodegen = async (options: RunJsxCodegenOptions): Promise<RunJsxCodegenResult> => {\n const builtin = await readBuiltinElements(options.reactSubexports, options.giStoreDir);\n const components = { ...builtin.components, ...options.userComponents };\n const lazyElements = [...builtin.lazyElements, ...options.userLazyElements];\n const props = { ...builtin.props, ...options.userProps };\n const omittedProps = mergeOmittedProps(builtin.omittedProps, options.userOmittedProps);\n\n const fingerprintInput: JsxFingerprintInput = {\n reactVersion: options.jsx.version,\n reactSubexports: options.reactSubexports,\n components,\n lazyElements,\n props,\n omittedProps,\n };\n\n if (!options.isForced && !options.isGiRegenerated) {\n const { isFresh, intrinsicElementCount } = jsxStoreFreshness(options.jsx.storeDir, fingerprintInput);\n\n if (isFresh) {\n return { isRegenerated: false, intrinsicElementCount };\n }\n }\n\n const library = options.getLibrary();\n\n const { namespaces, metadata, intrinsicElementCount, elements } = generateJsxFiles(library, {\n reactSubexports: options.reactSubexports,\n components,\n lazyElements,\n props,\n omittedProps,\n });\n\n writeJsxStore({\n options: options.jsx,\n namespaces,\n metadata,\n externalPackages: storeExternalPackages(library),\n rawFiles: [\n {\n relativePath: FINGERPRINT_FILENAME,\n content:\n `${JSON.stringify(computeJsxFingerprint(fingerprintInput, intrinsicElementCount), null, 2)}\\n`,\n },\n { relativePath: ELEMENTS_FILENAME, content: renderGeneratedElements(elements) },\n ],\n });\n\n return { isRegenerated: true, intrinsicElementCount };\n};\n\nconst storeExternalPackages = (library: Library): string[] => {\n const packages: Set<string> = new Set();\n\n for (const namespace of library.namespaces.values()) {\n const packageName = externalPackageFor(namespace.name);\n\n if (packageName !== undefined) {\n packages.add(packageName);\n }\n }\n\n return [...packages];\n};\n\nexport { runJsxCodegen };\n"]}
|
package/dist/runner.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ type CodegenRunnerOptions = {
|
|
|
32
32
|
isForced?: boolean;
|
|
33
33
|
/** Emits GIR byte sequences as `Uint8Array` rather than `number[]`; defaults to false. */
|
|
34
34
|
isByteArrayTyped?: boolean;
|
|
35
|
+
/** Surfaces a `GObject.Value` a binding hands back as what it holds rather than as the value; defaults to false. */
|
|
36
|
+
isValueUnwrapped?: boolean;
|
|
37
|
+
/** Drops the leading success boolean from promisified results of a throwing finish; defaults to false. */
|
|
38
|
+
isFinishTrimmed?: boolean;
|
|
39
|
+
/** Mutates a handle-passing inout parameter in place instead of packing it into the result; defaults to false. */
|
|
40
|
+
isInoutInPlace?: boolean;
|
|
35
41
|
};
|
|
36
42
|
/** What a `runCodegen` run produced. */
|
|
37
43
|
type CodegenRunnerResult = {
|
|
@@ -41,6 +47,8 @@ type CodegenRunnerResult = {
|
|
|
41
47
|
namespaces: number;
|
|
42
48
|
/** How many JSX elements the jsx store binds, zero when no jsx store was requested. */
|
|
43
49
|
intrinsicElements: number;
|
|
50
|
+
/** Deprecation notices about how the store was wired, one line each; empty when nothing needs attention. */
|
|
51
|
+
notices: string[];
|
|
44
52
|
/** Wall-clock duration of the run, in milliseconds. */
|
|
45
53
|
duration: number;
|
|
46
54
|
};
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAKjE,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;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a,EAAE,OAAO,CAAC;IACvB,yFAAyF;IACzF,UAAU,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,4GAA4G;IAC5G,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAQF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,UAAU,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,mBAAmB,CAWpF,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,SAAS,gBAAgB,KAAG,kBAmBjD,CAAC;AAiGF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,CAAC"}
|
package/dist/runner.js
CHANGED
|
@@ -6,6 +6,7 @@ import { runGiCodegen } from "./gi.js";
|
|
|
6
6
|
import { Library } from "./gir/library.js";
|
|
7
7
|
import { generateGlModules } from "./khronos/pipeline.js";
|
|
8
8
|
import { sweepStagingDirs } from "./staging.js";
|
|
9
|
+
import { externalPackageNotices } from "./store/external-package-links.js";
|
|
9
10
|
import { ensureStoreLink } from "./store/store-fs.js";
|
|
10
11
|
/**
|
|
11
12
|
* Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection
|
|
@@ -28,6 +29,7 @@ const runCodegen = async (options) => {
|
|
|
28
29
|
isRegenerated: store.isRegenerated,
|
|
29
30
|
namespaces: store.namespaces,
|
|
30
31
|
intrinsicElements: store.intrinsicElements,
|
|
32
|
+
notices: externalPackageNotices(options.gi),
|
|
31
33
|
duration: Date.now() - start,
|
|
32
34
|
};
|
|
33
35
|
};
|
|
@@ -74,12 +76,16 @@ const emitJsxStore = async (input) => {
|
|
|
74
76
|
const emitStoresWithConfig = async (config) => {
|
|
75
77
|
const { options, gi, jsx, libraries, girPath } = config;
|
|
76
78
|
const isByteArrayTyped = options.isByteArrayTyped === true;
|
|
79
|
+
const isValueUnwrapped = options.isValueUnwrapped === true;
|
|
80
|
+
const isFinishTrimmed = options.isFinishTrimmed === true;
|
|
81
|
+
const isInoutInPlace = options.isInoutInPlace === true;
|
|
82
|
+
const future = { isByteArrayTyped, isValueUnwrapped, isFinishTrimmed, isInoutInPlace };
|
|
77
83
|
let library;
|
|
78
|
-
const loadLibrary = () => (library ??= Library.load(libraries, girPath,
|
|
79
|
-
const giInputs = { girFiles: [], libraries, girPath,
|
|
84
|
+
const loadLibrary = () => (library ??= Library.load(libraries, girPath, future));
|
|
85
|
+
const giInputs = { girFiles: [], libraries, girPath, storeVersion: gi.version, ...future };
|
|
80
86
|
const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, giInputs);
|
|
81
87
|
const namespaces = isGiRegenerated
|
|
82
|
-
? runGiCodegen(loadLibrary(), { gi, libraries, girPath,
|
|
88
|
+
? runGiCodegen(loadLibrary(), { gi, libraries, girPath, ...future })
|
|
83
89
|
: 0;
|
|
84
90
|
if (jsx === undefined) {
|
|
85
91
|
return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };
|
package/dist/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,E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MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IACrG,CAAC;IAED,aAAa,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAEzB,OAAO,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAuD,CAAC","sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ModuleExport } from \"./react/element-config.js\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\nimport { sweepStagingDirs } from \"./staging.js\";\nimport { ensureStoreLink, type StoreOptions } from \"./store/store-fs.js\";\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\n/** What to generate and where to write it. */\ntype CodegenRunnerOptions = {\n /** GIR library identifiers such as `\"Gtk-4.0\"`; a `\"*\"` selection must be expanded before it gets here. */\n libraries: string[];\n /** Directories to search for `.gir` files. */\n girPath: string[];\n /** Where to write and link the `@gtkx/gi` store. */\n gi: StoreOptions;\n /** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */\n jsx?: StoreOptions | undefined;\n /** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */\n reactSubexports?: string[];\n /** Component wrappers the project layers over the built-ins, keyed by GLib type name. */\n userComponents?: Record<string, ModuleExport>;\n /** GLib type names whose GObject their parent container creates, added to the framework's own. */\n userLazyElements?: string[];\n /** Base props interfaces the project's elements extend, keyed by GLib type name. */\n userProps?: Record<string, ModuleExport>;\n /** Props the project drops from the generated element props, keyed by GLib type name. */\n userOmittedProps?: OmittedProps;\n /** Regenerates both stores even when their fingerprints are fresh. */\n isForced?: boolean;\n /** Emits GIR byte sequences as `Uint8Array` rather than `number[]`; defaults to false. */\n isByteArrayTyped?: boolean;\n};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install\n * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable\n * under its own specifier while the jsx store is type checked.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n const isByteArrayTyped = options.isByteArrayTyped === true;\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath, isByteArrayTyped));\n const giInputs = { girFiles: [] as string[], libraries, girPath, isByteArrayTyped };\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, giInputs);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath, isByteArrayTyped })\n : 0;\n\n if (jsx === undefined) {\n return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });\n};\n\nconst prepareStores = (stores: (StoreOptions | undefined)[]): void => {\n for (const store of stores) {\n if (store === undefined) {\n continue;\n }\n\n sweepStagingDirs(store.storeDir);\n ensureStoreLink(store);\n }\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (girPath.length === 0) {\n throw new Error(\"codegen needs at least one GIR search path; pass the result of resolveGirPath\");\n }\n\n prepareStores([gi, jsx]);\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAqB,MAAM,qBAAqB,CAAC;AA6DzE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAgC,EAAE;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,MAAM,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OAA6B,EAAwB,EAAE;IAC7E,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEhD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IACrG,CAAC;IAED,aAAa,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAEzB,OAAO,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAuD,CAAC","sourcesContent":["import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { ModuleExport } from \"./react/element-config.js\";\nimport type { OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { checkModules } from \"./compile.js\";\nimport { isGiStoreFresh } from \"./fingerprint.js\";\nimport { runGiCodegen } from \"./gi.js\";\nimport { Library } from \"./gir/library.js\";\nimport { generateGlModules, type GlGenerationReport } from \"./khronos/pipeline.js\";\nimport { sweepStagingDirs } from \"./staging.js\";\nimport { externalPackageNotices } from \"./store/external-package-links.js\";\nimport { ensureStoreLink, type StoreOptions } from \"./store/store-fs.js\";\n\ntype GlCodegenOptions = {\n registryPath: string;\n overrideExports: Set<string>;\n outputDir: string;\n resolveFrom: string;\n};\n\n/** What to generate and where to write it. */\ntype CodegenRunnerOptions = {\n /** GIR library identifiers such as `\"Gtk-4.0\"`; a `\"*\"` selection must be expanded before it gets here. */\n libraries: string[];\n /** Directories to search for `.gir` files. */\n girPath: string[];\n /** Where to write and link the `@gtkx/gi` store. */\n gi: StoreOptions;\n /** Where to write and link the `@gtkx/jsx` store; omit to generate the gi store alone. */\n jsx?: StoreOptions | undefined;\n /** Subexport names of the installed `@gtkx/react`, whose element config shapes the jsx store. */\n reactSubexports?: string[];\n /** Component wrappers the project layers over the built-ins, keyed by GLib type name. */\n userComponents?: Record<string, ModuleExport>;\n /** GLib type names whose GObject their parent container creates, added to the framework's own. */\n userLazyElements?: string[];\n /** Base props interfaces the project's elements extend, keyed by GLib type name. */\n userProps?: Record<string, ModuleExport>;\n /** Props the project drops from the generated element props, keyed by GLib type name. */\n userOmittedProps?: OmittedProps;\n /** Regenerates both stores even when their fingerprints are fresh. */\n isForced?: boolean;\n /** Emits GIR byte sequences as `Uint8Array` rather than `number[]`; defaults to false. */\n isByteArrayTyped?: boolean;\n /** Surfaces a `GObject.Value` a binding hands back as what it holds rather than as the value; defaults to false. */\n isValueUnwrapped?: boolean;\n /** Drops the leading success boolean from promisified results of a throwing finish; defaults to false. */\n isFinishTrimmed?: boolean;\n /** Mutates a handle-passing inout parameter in place instead of packing it into the result; defaults to false. */\n isInoutInPlace?: boolean;\n};\n\n/** What a `runCodegen` run produced. */\ntype CodegenRunnerResult = {\n /** Whether either store was rewritten; false means both were already fresh. */\n isRegenerated: boolean;\n /** How many namespaces the gi store was written with, zero when it was already fresh. */\n namespaces: number;\n /** How many JSX elements the jsx store binds, zero when no jsx store was requested. */\n intrinsicElements: number;\n /** Deprecation notices about how the store was wired, one line each; empty when nothing needs attention. */\n notices: string[];\n /** Wall-clock duration of the run, in milliseconds. */\n duration: number;\n};\n\ntype StoreResult = {\n isRegenerated: boolean;\n namespaces: number;\n intrinsicElements: number;\n};\n\n/**\n * Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection\n * libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi\n * store or the React element config changed, unless `options.isForced` is set. Pass the spread of\n * `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.\n *\n * Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install\n * pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable\n * under its own specifier while the jsx store is type checked.\n *\n * @param options What to generate and where to write it.\n * @returns A summary of what was regenerated and how long the run took.\n * @throws If `girPath` is empty, which would otherwise generate nothing and report success.\n */\nconst runCodegen = async (options: CodegenRunnerOptions): Promise<CodegenRunnerResult> => {\n const start = Date.now();\n const store = await emitStores(options);\n\n return {\n isRegenerated: store.isRegenerated,\n namespaces: store.namespaces,\n intrinsicElements: store.intrinsicElements,\n notices: externalPackageNotices(options.gi),\n duration: Date.now() - start,\n };\n};\n\nconst runGlCodegen = (options: GlCodegenOptions): GlGenerationReport => {\n const { files, report } = generateGlModules({\n registryPath: options.registryPath,\n overrideExports: options.overrideExports,\n });\n\n checkModules({\n modules: [...files].map(([fileName, source]) => ({ fileName, source })),\n resolveFrom: options.resolveFrom,\n label: \"the generated gl modules\",\n });\n\n mkdirSync(options.outputDir, { recursive: true });\n\n for (const [fileName, source] of files) {\n writeFileSync(join(options.outputDir, fileName), source);\n }\n\n return report;\n};\n\nconst jsxUserOptions = (\n options: CodegenRunnerOptions,\n): {\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmittedProps: OmittedProps;\n} => ({\n reactSubexports: options.reactSubexports ?? [],\n userComponents: options.userComponents ?? {},\n userLazyElements: options.userLazyElements ?? [],\n userProps: options.userProps ?? {},\n userOmittedProps: options.userOmittedProps ?? {},\n});\n\nconst emitJsxStore = async (input: {\n options: CodegenRunnerOptions;\n jsx: StoreOptions;\n gi: StoreOptions;\n loadLibrary: () => Library;\n isGiRegenerated: boolean;\n namespaces: number;\n}): Promise<StoreResult> => {\n const { options, jsx, gi, loadLibrary, isGiRegenerated, namespaces } = input;\n const { runJsxCodegen } = await import(\"./jsx.js\");\n\n const jsxResult = await runJsxCodegen({\n getLibrary: loadLibrary,\n jsx,\n giStoreDir: gi.storeDir,\n ...jsxUserOptions(options),\n isGiRegenerated,\n isForced: options.isForced === true,\n });\n\n return {\n isRegenerated: isGiRegenerated || jsxResult.isRegenerated,\n namespaces,\n intrinsicElements: jsxResult.intrinsicElementCount,\n };\n};\n\nconst emitStoresWithConfig = async (config: {\n options: CodegenRunnerOptions;\n gi: StoreOptions;\n jsx: StoreOptions | undefined;\n libraries: string[];\n girPath: string[];\n}): Promise<StoreResult> => {\n const { options, gi, jsx, libraries, girPath } = config;\n const isByteArrayTyped = options.isByteArrayTyped === true;\n const isValueUnwrapped = options.isValueUnwrapped === true;\n const isFinishTrimmed = options.isFinishTrimmed === true;\n const isInoutInPlace = options.isInoutInPlace === true;\n const future = { isByteArrayTyped, isValueUnwrapped, isFinishTrimmed, isInoutInPlace };\n let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath, future));\n const giInputs = { girFiles: [] as string[], libraries, girPath, storeVersion: gi.version, ...future };\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, giInputs);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath, ...future })\n : 0;\n\n if (jsx === undefined) {\n return { isRegenerated: isGiRegenerated, namespaces, intrinsicElements: 0 };\n }\n\n return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });\n};\n\nconst prepareStores = (stores: (StoreOptions | undefined)[]): void => {\n for (const store of stores) {\n if (store === undefined) {\n continue;\n }\n\n sweepStagingDirs(store.storeDir);\n ensureStoreLink(store);\n }\n};\n\nconst emitStores = async (options: CodegenRunnerOptions): Promise<StoreResult> => {\n const { gi, jsx, libraries, girPath } = options;\n\n if (girPath.length === 0) {\n throw new Error(\"codegen needs at least one GIR search path; pass the result of resolveGirPath\");\n }\n\n prepareStores([gi, jsx]);\n\n return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });\n};\n\nexport { runCodegen, runGlCodegen, type CodegenRunnerOptions, type CodegenRunnerResult };\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type StoreLink } from "./store-fs.js";
|
|
2
|
+
declare const ensureExternalPackageLinks: (link: StoreLink) => void;
|
|
3
|
+
declare const resetExternalPackageLinks: (storeDir: string) => void;
|
|
4
|
+
declare const externalPackageNotices: (link: StoreLink) => string[];
|
|
5
|
+
export { ensureExternalPackageLinks, externalPackageNotices, resetExternalPackageLinks };
|
|
6
|
+
//# sourceMappingURL=external-package-links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-package-links.d.ts","sourceRoot":"","sources":["../../src/store/external-package-links.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,eAAe,CAAC;AAwIhE,QAAA,MAAM,0BAA0B,GAAI,MAAM,SAAS,KAAG,IAcrD,CAAC;AAEF,QAAA,MAAM,yBAAyB,GAAI,UAAU,MAAM,KAAG,IAErD,CAAC;AAoDF,QAAA,MAAM,sBAAsB,GAAI,MAAM,SAAS,KAAG,MAAM,EAYvD,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { existsSync, readFileSync, realpathSync, rmSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { EXTERNAL_NAMESPACES } from "../gir/external-namespaces.js";
|
|
5
|
+
import { nodeModulesChain } from "./resolve-store.js";
|
|
6
|
+
import { symlinkRelative } from "./store-fs.js";
|
|
7
|
+
const DEPENDENCY_FIELDS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
8
|
+
const codegenRequire = createRequire(import.meta.url);
|
|
9
|
+
const codegenPackageDirs = new Map();
|
|
10
|
+
const ensuredStores = new Set();
|
|
11
|
+
const storeAnchor = (link) => dirname(dirname(link.linkDir));
|
|
12
|
+
const namespaceShimDirectory = (entry) => entry.namespace.toLowerCase();
|
|
13
|
+
const resolveFromStore = (link, packageName) => {
|
|
14
|
+
const chain = nodeModulesChain(dirname(storeAnchor(link)));
|
|
15
|
+
for (const nodeModules of chain) {
|
|
16
|
+
const manifest = join(nodeModules, packageName, "package.json");
|
|
17
|
+
if (existsSync(manifest)) {
|
|
18
|
+
return dirname(realpathSync(manifest));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
const projectManifestPath = (link) => join(dirname(storeAnchor(link)), "package.json");
|
|
24
|
+
const readManifest = (manifestPath) => {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const sectionNames = (section) => typeof section === "object" && section !== null ? Object.keys(section) : [];
|
|
33
|
+
const declaredDependencies = (manifest) => new Set(DEPENDENCY_FIELDS.flatMap((field) => sectionNames(manifest[field])));
|
|
34
|
+
const isDeclaredByProject = (link, packageName) => {
|
|
35
|
+
const manifest = readManifest(projectManifestPath(link));
|
|
36
|
+
return manifest === undefined || declaredDependencies(manifest).has(packageName);
|
|
37
|
+
};
|
|
38
|
+
const resolveFromCodegen = (packageName) => {
|
|
39
|
+
if (codegenPackageDirs.has(packageName)) {
|
|
40
|
+
return codegenPackageDirs.get(packageName);
|
|
41
|
+
}
|
|
42
|
+
let dir;
|
|
43
|
+
try {
|
|
44
|
+
dir = dirname(realpathSync(codegenRequire.resolve(`${packageName}/package.json`)));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
dir = undefined;
|
|
48
|
+
}
|
|
49
|
+
codegenPackageDirs.set(packageName, dir);
|
|
50
|
+
return dir;
|
|
51
|
+
};
|
|
52
|
+
const resolveEntry = (link, entry) => {
|
|
53
|
+
const directory = namespaceShimDirectory(entry);
|
|
54
|
+
const chainResolved = resolveFromStore(link, entry.packageName);
|
|
55
|
+
if (chainResolved !== undefined) {
|
|
56
|
+
const source = isDeclaredByProject(link, entry.packageName) ? "store" : "hoisted";
|
|
57
|
+
return { packageName: entry.packageName, directory, dir: chainResolved, source };
|
|
58
|
+
}
|
|
59
|
+
const codegenDir = resolveFromCodegen(entry.packageName);
|
|
60
|
+
if (codegenDir !== undefined) {
|
|
61
|
+
return { packageName: entry.packageName, directory, dir: codegenDir, source: "codegen" };
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
};
|
|
65
|
+
const resolveExternalPackages = (link) => {
|
|
66
|
+
const resolutions = [];
|
|
67
|
+
for (const entry of EXTERNAL_NAMESPACES) {
|
|
68
|
+
const resolution = resolveEntry(link, entry);
|
|
69
|
+
if (resolution !== undefined) {
|
|
70
|
+
resolutions.push(resolution);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return resolutions;
|
|
74
|
+
};
|
|
75
|
+
const isLinkedTo = (linkPath, dir) => {
|
|
76
|
+
try {
|
|
77
|
+
return realpathSync(linkPath) === realpathSync(dir);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const applyLink = (storeDir, resolution) => {
|
|
84
|
+
const linkPath = join(storeDir, "node_modules", resolution.packageName);
|
|
85
|
+
if (resolution.source === "codegen") {
|
|
86
|
+
if (!isLinkedTo(linkPath, resolution.dir)) {
|
|
87
|
+
symlinkRelative(linkPath, resolution.dir);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
rmSync(linkPath, { recursive: true, force: true });
|
|
92
|
+
};
|
|
93
|
+
const tryApplyLink = (storeDir, resolution) => {
|
|
94
|
+
try {
|
|
95
|
+
applyLink(storeDir, resolution);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const ensureExternalPackageLinks = (link) => {
|
|
102
|
+
if (ensuredStores.has(link.storeDir)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!existsSync(join(link.storeDir, "package.json"))) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
for (const resolution of resolveExternalPackages(link)) {
|
|
109
|
+
tryApplyLink(link.storeDir, resolution);
|
|
110
|
+
}
|
|
111
|
+
ensuredStores.add(link.storeDir);
|
|
112
|
+
};
|
|
113
|
+
const resetExternalPackageLinks = (storeDir) => {
|
|
114
|
+
ensuredStores.delete(storeDir);
|
|
115
|
+
};
|
|
116
|
+
const externalPackageNotice = (resolution) => `${resolution.packageName} is not installed in this project, so the copy @gtkx/codegen depends on was ` +
|
|
117
|
+
`linked into the generated store; add ${resolution.packageName} to your dependencies, because GTKX 2.0 ` +
|
|
118
|
+
"stops doing this.";
|
|
119
|
+
const hoistedPackageNotice = (resolution) => `${resolution.packageName} is not declared in this project's package.json and only resolves because ` +
|
|
120
|
+
`your package manager hoisted it; add ${resolution.packageName} to your dependencies, because GTKX 2.0 ` +
|
|
121
|
+
"requires the direct dependency.";
|
|
122
|
+
const hasShim = (storeDir, entry) => existsSync(join(storeDir, namespaceShimDirectory(entry), "index.js"));
|
|
123
|
+
const hasStoreLocalLink = (storeDir, packageName) => existsSync(join(storeDir, "node_modules", packageName, "package.json"));
|
|
124
|
+
const unresolvableMessage = (link, entry) => `Cannot resolve ${entry.packageName} from ${storeAnchor(link)} or from @gtkx/codegen; ` +
|
|
125
|
+
"install it next to @gtkx/runtime.";
|
|
126
|
+
const linkFailedMessage = (link, entry) => `Cannot link ${entry.packageName} into the generated store at ${link.storeDir}; ` +
|
|
127
|
+
`install ${entry.packageName} next to @gtkx/runtime.`;
|
|
128
|
+
const entryNotice = (link, entry) => {
|
|
129
|
+
if (!hasShim(link.storeDir, entry)) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
const resolution = resolveEntry(link, entry);
|
|
133
|
+
if (resolution === undefined) {
|
|
134
|
+
throw new Error(unresolvableMessage(link, entry));
|
|
135
|
+
}
|
|
136
|
+
if (resolution.source === "store") {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
if (resolution.source === "hoisted") {
|
|
140
|
+
return hoistedPackageNotice(resolution);
|
|
141
|
+
}
|
|
142
|
+
if (!hasStoreLocalLink(link.storeDir, resolution.packageName)) {
|
|
143
|
+
throw new Error(linkFailedMessage(link, entry));
|
|
144
|
+
}
|
|
145
|
+
return externalPackageNotice(resolution);
|
|
146
|
+
};
|
|
147
|
+
const externalPackageNotices = (link) => {
|
|
148
|
+
const notices = [];
|
|
149
|
+
for (const entry of EXTERNAL_NAMESPACES) {
|
|
150
|
+
const notice = entryNotice(link, entry);
|
|
151
|
+
if (notice !== undefined) {
|
|
152
|
+
notices.push(notice);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return notices;
|
|
156
|
+
};
|
|
157
|
+
export { ensureExternalPackageLinks, externalPackageNotices, resetExternalPackageLinks };
|
|
158
|
+
//# sourceMappingURL=external-package-links.js.map
|