@gtkx/codegen 1.0.0 → 1.1.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 +1 -1
- package/dist/analysis/descriptor-render.d.ts +12 -15
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +48 -31
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +16 -7
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +15 -3
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/inheritance.d.ts +4 -2
- package/dist/analysis/inheritance.d.ts.map +1 -1
- package/dist/analysis/inheritance.js +80 -38
- package/dist/analysis/inheritance.js.map +1 -1
- package/dist/analysis/interface-conflicts.d.ts +23 -0
- package/dist/analysis/interface-conflicts.d.ts.map +1 -0
- package/dist/analysis/interface-conflicts.js +144 -0
- package/dist/analysis/interface-conflicts.js.map +1 -0
- package/dist/analysis/param-capability.d.ts.map +1 -1
- package/dist/analysis/param-capability.js +3 -4
- package/dist/analysis/param-capability.js.map +1 -1
- package/dist/analysis/param-structure.js +2 -2
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +10 -17
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/analysis/type-key.d.ts +5 -0
- package/dist/analysis/type-key.d.ts.map +1 -0
- package/dist/analysis/type-key.js +9 -0
- package/dist/analysis/type-key.js.map +1 -0
- package/dist/compile.d.ts +12 -3
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +73 -24
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +10 -9
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/element-page.d.ts.map +1 -1
- package/dist/docs/element-page.js +5 -3
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +85 -18
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.d.ts +2 -1
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +5 -4
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +9 -6
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +12 -1
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +44 -28
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +1 -0
- package/dist/gi.js.map +1 -1
- package/dist/gir/ancestry.d.ts +7 -1
- package/dist/gir/ancestry.d.ts.map +1 -1
- package/dist/gir/ancestry.js +9 -1
- package/dist/gir/ancestry.js.map +1 -1
- package/dist/gir/annotations.d.ts +1 -2
- package/dist/gir/annotations.d.ts.map +1 -1
- package/dist/gir/annotations.js +1 -1
- package/dist/gir/annotations.js.map +1 -1
- package/dist/gir/cursor-overrides.d.ts +8 -0
- package/dist/gir/cursor-overrides.d.ts.map +1 -0
- package/dist/gir/cursor-overrides.js +6 -0
- package/dist/gir/cursor-overrides.js.map +1 -0
- package/dist/gir/emittable.d.ts +7 -0
- package/dist/gir/emittable.d.ts.map +1 -0
- package/dist/gir/emittable.js +3 -0
- package/dist/gir/emittable.js.map +1 -0
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +28 -2
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/library.js +1 -1
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/namespace.d.ts +5 -1
- package/dist/gir/namespace.d.ts.map +1 -1
- package/dist/gir/namespace.js +4 -2
- package/dist/gir/namespace.js.map +1 -1
- package/dist/gir/parameter.d.ts +13 -1
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +1 -0
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/parse.d.ts.map +1 -1
- package/dist/gir/parse.js +3 -6
- package/dist/gir/parse.js.map +1 -1
- package/dist/guards.d.ts +16 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +11 -0
- package/dist/guards.js.map +1 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -0
- package/dist/internal.js.map +1 -1
- package/dist/json.d.ts +3 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +11 -0
- package/dist/json.js.map +1 -0
- package/dist/khronos/modules.d.ts.map +1 -1
- package/dist/khronos/modules.js +22 -7
- package/dist/khronos/modules.js.map +1 -1
- package/dist/khronos/parse.d.ts.map +1 -1
- package/dist/khronos/parse.js +3 -4
- package/dist/khronos/parse.js.map +1 -1
- package/dist/khronos/pipeline.d.ts +1 -1
- package/dist/khronos/pipeline.d.ts.map +1 -1
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +1 -7
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +1 -1
- package/dist/khronos/plan.js.map +1 -1
- package/dist/runner.d.ts +5 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +16 -0
- package/dist/runner.js.map +1 -1
- package/dist/staging.d.ts +5 -0
- package/dist/staging.d.ts.map +1 -0
- package/dist/staging.js +57 -0
- package/dist/staging.js.map +1 -0
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +4 -2
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/callables.d.ts +7 -2
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +25 -30
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/callback.d.ts.map +1 -1
- package/dist/store/gi/callback.js +9 -5
- package/dist/store/gi/callback.js.map +1 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +59 -38
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/companion.d.ts.map +1 -1
- package/dist/store/gi/companion.js +6 -6
- package/dist/store/gi/companion.js.map +1 -1
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +10 -2
- package/dist/store/gi/constant.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/enum.d.ts.map +1 -1
- package/dist/store/gi/enum.js +28 -8
- package/dist/store/gi/enum.js.map +1 -1
- package/dist/store/gi/function.d.ts +1 -3
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +24 -18
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +4 -1
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/interface.d.ts.map +1 -1
- package/dist/store/gi/interface.js +32 -17
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/method.d.ts +7 -6
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +13 -21
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +3 -2
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +50 -5
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/pipeline.d.ts.map +1 -1
- package/dist/store/gi/pipeline.js +21 -10
- package/dist/store/gi/pipeline.js.map +1 -1
- package/dist/store/gi/properties.d.ts +2 -1
- package/dist/store/gi/properties.d.ts.map +1 -1
- package/dist/store/gi/properties.js +6 -3
- package/dist/store/gi/properties.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +10 -5
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +95 -44
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts +8 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +31 -10
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +5 -1
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +6 -1
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +8 -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 +19 -8
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/registration.js +2 -2
- package/dist/store/gi/registration.js.map +1 -1
- package/dist/store/gi/signal.d.ts +2 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +30 -24
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts.map +1 -1
- package/dist/store/gi/value-marshalable.js +2 -1
- package/dist/store/gi/value-marshalable.js.map +1 -1
- package/dist/store/gi/vtable.d.ts +4 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +60 -17
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +1 -0
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +15 -20
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/generated-elements.d.ts +2 -1
- package/dist/store/jsx/generated-elements.d.ts.map +1 -1
- package/dist/store/jsx/generated-elements.js +13 -7
- package/dist/store/jsx/generated-elements.js.map +1 -1
- package/dist/store/jsx/jsx.js +3 -3
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.d.ts.map +1 -1
- package/dist/store/jsx/metadata.js +3 -1
- package/dist/store/jsx/metadata.js.map +1 -1
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +3 -3
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/resolve-store.d.ts +14 -3
- package/dist/store/resolve-store.d.ts.map +1 -1
- package/dist/store/resolve-store.js +98 -15
- package/dist/store/resolve-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +9 -6
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +59 -25
- package/dist/store/store-fs.js.map +1 -1
- package/dist/store/store-links.d.ts +3 -0
- package/dist/store/store-links.d.ts.map +1 -0
- package/dist/store/store-links.js +39 -0
- package/dist/store/store-links.js.map +1 -0
- package/dist/writer/comparison-context.d.ts +4 -0
- package/dist/writer/comparison-context.d.ts.map +1 -0
- package/dist/writer/comparison-context.js +13 -0
- package/dist/writer/comparison-context.js.map +1 -0
- package/dist/writer/context.d.ts +3 -3
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +11 -6
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/module.d.ts +13 -5
- package/dist/writer/module.d.ts.map +1 -1
- package/dist/writer/module.js +68 -11
- package/dist/writer/module.js.map +1 -1
- package/dist/xml.d.ts +7 -1
- package/dist/xml.d.ts.map +1 -1
- package/dist/xml.js +43 -1
- package/dist/xml.js.map +1 -1
- package/package.json +14 -3
- package/src/analysis/descriptor-render.ts +90 -45
- package/src/analysis/descriptor.ts +35 -8
- package/src/analysis/inheritance.ts +134 -44
- package/src/analysis/interface-conflicts.ts +237 -0
- package/src/analysis/param-capability.ts +3 -6
- package/src/analysis/param-structure.ts +2 -2
- package/src/analysis/ts-type.ts +13 -17
- package/src/analysis/type-key.ts +14 -0
- package/src/compile.ts +110 -26
- package/src/docs/api-reference.ts +10 -9
- package/src/docs/element-page.ts +5 -2
- package/src/docs/pipeline.ts +129 -19
- package/src/docs/render.ts +7 -3
- package/src/docs/symbol-page.ts +12 -7
- package/src/fingerprint.ts +86 -31
- package/src/gi.ts +1 -0
- package/src/gir/ancestry.ts +17 -1
- package/src/gir/annotations.ts +1 -1
- package/src/gir/cursor-overrides.ts +12 -0
- package/src/gir/emittable.ts +8 -0
- package/src/gir/function.ts +45 -9
- package/src/gir/library.ts +1 -1
- package/src/gir/namespace.ts +8 -2
- package/src/gir/parameter.ts +15 -0
- package/src/gir/parse.ts +5 -7
- package/src/guards.ts +23 -0
- package/src/internal.ts +2 -0
- package/src/json.ts +11 -0
- package/src/khronos/modules.ts +25 -9
- package/src/khronos/parse.ts +3 -4
- package/src/khronos/pipeline.ts +1 -1
- package/src/khronos/plan.ts +0 -1
- package/src/runner.ts +19 -1
- package/src/staging.ts +69 -0
- package/src/store/compile-store.ts +6 -4
- package/src/store/gi/callables.ts +41 -33
- package/src/store/gi/callback.ts +9 -9
- package/src/store/gi/class.ts +79 -48
- package/src/store/gi/companion.ts +7 -6
- package/src/store/gi/constant.ts +12 -2
- package/src/store/gi/constructor-props.ts +1 -1
- package/src/store/gi/enum.ts +35 -21
- package/src/store/gi/function.ts +30 -24
- package/src/store/gi/gtype-binding.ts +7 -2
- package/src/store/gi/interface.ts +37 -18
- package/src/store/gi/method.ts +28 -29
- package/src/store/gi/param-marshal.ts +77 -6
- package/src/store/gi/pipeline.ts +25 -15
- package/src/store/gi/properties.ts +8 -4
- package/src/store/gi/property-accessor.ts +156 -73
- package/src/store/gi/record-constructor.ts +50 -18
- package/src/store/gi/record-field-accessor.ts +8 -1
- package/src/store/gi/record-layout.ts +11 -1
- package/src/store/gi/record.ts +20 -12
- package/src/store/gi/registration.ts +2 -2
- package/src/store/gi/signal.ts +36 -38
- package/src/store/gi/value-marshalable.ts +3 -1
- package/src/store/gi/vtable.ts +97 -20
- package/src/store/gi-store.ts +26 -31
- package/src/store/jsx/generated-elements.ts +17 -8
- package/src/store/jsx/jsx.ts +3 -3
- package/src/store/jsx/metadata.ts +4 -1
- package/src/store/jsx-store.ts +3 -3
- package/src/store/resolve-store.ts +133 -18
- package/src/store/store-fs.ts +87 -34
- package/src/store/store-links.ts +49 -0
- package/src/writer/comparison-context.ts +18 -0
- package/src/writer/context.ts +12 -6
- package/src/writer/module.ts +101 -14
- package/src/xml.ts +61 -1
package/dist/runner.js
CHANGED
|
@@ -5,12 +5,18 @@ import { isGiStoreFresh } from "./fingerprint.js";
|
|
|
5
5
|
import { runGiCodegen } from "./gi.js";
|
|
6
6
|
import { Library } from "./gir/library.js";
|
|
7
7
|
import { generateGlModules } from "./khronos/pipeline.js";
|
|
8
|
+
import { sweepStagingDirs } from "./staging.js";
|
|
9
|
+
import { ensureStoreLink } from "./store/store-fs.js";
|
|
8
10
|
/**
|
|
9
11
|
* Writes and links a project's `@gtkx/gi` and `@gtkx/jsx` stores from the given GObject-Introspection
|
|
10
12
|
* libraries. The gi store is rewritten only when its GIR inputs changed, and the jsx store only when the gi
|
|
11
13
|
* store or the React element config changed, unless `options.isForced` is set. Pass the spread of
|
|
12
14
|
* `resolveStore(projectRoot)` for everything but `libraries` and `girPath`.
|
|
13
15
|
*
|
|
16
|
+
* Every store already on disk is linked at its `linkDir` before anything is generated, so a link an install
|
|
17
|
+
* pruned out of `node_modules` is restored without regenerating the store, and the gi store is reachable
|
|
18
|
+
* under its own specifier while the jsx store is type checked.
|
|
19
|
+
*
|
|
14
20
|
* @param options What to generate and where to write it.
|
|
15
21
|
* @returns A summary of what was regenerated and how long the run took.
|
|
16
22
|
* @throws If `girPath` is empty, which would otherwise generate nothing and report success.
|
|
@@ -78,11 +84,21 @@ const emitStoresWithConfig = async (config) => {
|
|
|
78
84
|
}
|
|
79
85
|
return emitJsxStore({ options, jsx, gi, loadLibrary, isGiRegenerated, namespaces });
|
|
80
86
|
};
|
|
87
|
+
const prepareStores = (stores) => {
|
|
88
|
+
for (const store of stores) {
|
|
89
|
+
if (store === undefined) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
sweepStagingDirs(store.storeDir);
|
|
93
|
+
ensureStoreLink(store);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
81
96
|
const emitStores = async (options) => {
|
|
82
97
|
const { gi, jsx, libraries, girPath } = options;
|
|
83
98
|
if (girPath.length === 0) {
|
|
84
99
|
throw new Error("codegen needs at least one GIR search path; pass the result of resolveGirPath");
|
|
85
100
|
}
|
|
101
|
+
prepareStores([gi, jsx]);
|
|
86
102
|
return emitStoresWithConfig({ options, gi, jsx, libraries, girPath });
|
|
87
103
|
};
|
|
88
104
|
export { runCodegen, runGlCodegen };
|
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;AAIjC,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;AAmDnF;;;;;;;;;GASG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAgC,EAAE;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;IAExC,OAAO;QACH,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;KAC/B,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,OAAyB,EAAsB,EAAE;IACnE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC;QACxC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,eAAe,EAAE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AE;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,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 type { StoreOptions } from \"./store/store-fs.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\";\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};\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 * @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 let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath));\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, libraries, girPath);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath })\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 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 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,eAAe,EAAqB,MAAM,qBAAqB,CAAC;AAmDzE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAgC,EAAE;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;IAExC,OAAO;QACH,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;KAC/B,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,OAAyB,EAAsB,EAAE;IACnE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC;QACxC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,eAAe,EAAE,OAAO,CAAC,eAAe;K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,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,SAAS;QACb,CAAC;QAED,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,KAAK,EAAE,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 { 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};\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 let library: Library | undefined;\n const loadLibrary = (): Library => (library ??= Library.load(libraries, girPath));\n const isGiRegenerated = options.isForced === true || !isGiStoreFresh(gi.storeDir, libraries, girPath);\n\n const namespaces = isGiRegenerated\n ? runGiCodegen(loadLibrary(), { gi, libraries, girPath })\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,5 @@
|
|
|
1
|
+
declare const sweepStrandedDirs: (parentDir: string, prefix: string) => void;
|
|
2
|
+
declare const sweepStagingDirs: (target: string) => void;
|
|
3
|
+
declare const createStagingDir: (target: string) => string;
|
|
4
|
+
export { createStagingDir, sweepStagingDirs, sweepStrandedDirs };
|
|
5
|
+
//# sourceMappingURL=staging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../src/staging.ts"],"names":[],"mappings":"AAiDA,QAAA,MAAM,iBAAiB,GAAI,WAAW,MAAM,EAAE,QAAQ,MAAM,KAAG,IAM9D,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,IAE1C,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAK1C,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/staging.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join } from "node:path";
|
|
3
|
+
const STAGING_SUFFIX = ".tmp-";
|
|
4
|
+
const OWNER_PATTERN = /^(?<pid>\d+)-/;
|
|
5
|
+
const errorCode = (error) => error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
6
|
+
const isOwnerRunning = (pid) => {
|
|
7
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
process.kill(pid, 0);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return errorCode(error) === "EPERM";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const isStranded = (entry, prefix) => {
|
|
19
|
+
if (!entry.startsWith(prefix)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const owner = OWNER_PATTERN.exec(entry.slice(prefix.length))?.groups?.pid;
|
|
23
|
+
return owner === undefined || !isOwnerRunning(Number(owner));
|
|
24
|
+
};
|
|
25
|
+
const readEntries = (parentDir) => {
|
|
26
|
+
try {
|
|
27
|
+
return readdirSync(parentDir);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const removeStrandedDir = (path) => {
|
|
34
|
+
try {
|
|
35
|
+
rmSync(path, { recursive: true, force: true });
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const sweepStrandedDirs = (parentDir, prefix) => {
|
|
42
|
+
for (const entry of readEntries(parentDir)) {
|
|
43
|
+
if (isStranded(entry, prefix)) {
|
|
44
|
+
removeStrandedDir(join(parentDir, entry));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const sweepStagingDirs = (target) => {
|
|
49
|
+
sweepStrandedDirs(dirname(target), `${basename(target)}${STAGING_SUFFIX}`);
|
|
50
|
+
};
|
|
51
|
+
const createStagingDir = (target) => {
|
|
52
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
53
|
+
sweepStagingDirs(target);
|
|
54
|
+
return mkdtempSync(`${target}${STAGING_SUFFIX}${String(process.pid)}-`);
|
|
55
|
+
};
|
|
56
|
+
export { createStagingDir, sweepStagingDirs, sweepStrandedDirs };
|
|
57
|
+
//# sourceMappingURL=staging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staging.js","sourceRoot":"","sources":["../src/staging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,aAAa,GAAG,eAAe,CAAC;AAEtC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAsB,EAAE,CACrD,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAEzG,MAAM,cAAc,GAAG,CAAC,GAAW,EAAW,EAAE;IAC5C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,CAAC;QACD,OAAO,CAAC,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IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAQ,EAAE;IAC9C,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChD,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,WAAW,CAAC,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { mkdirSync, mkdtempSync, readdirSync, rmSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\n\nconst STAGING_SUFFIX = \".tmp-\";\nconst OWNER_PATTERN = /^(?<pid>\\d+)-/;\n\nconst errorCode = (error: unknown): string | undefined =>\n error instanceof Error && \"code\" in error && typeof error.code === \"string\" ? error.code : undefined;\n\nconst isOwnerRunning = (pid: number): boolean => {\n if (!Number.isSafeInteger(pid) || pid <= 0) {\n return false;\n }\n\n try {\n process.kill(pid, 0);\n\n return true;\n } catch (error) {\n return errorCode(error) === \"EPERM\";\n }\n};\n\nconst isStranded = (entry: string, prefix: string): boolean => {\n if (!entry.startsWith(prefix)) {\n return false;\n }\n\n const owner = OWNER_PATTERN.exec(entry.slice(prefix.length))?.groups?.pid;\n\n return owner === undefined || !isOwnerRunning(Number(owner));\n};\n\nconst readEntries = (parentDir: string): string[] => {\n try {\n return readdirSync(parentDir);\n } catch {\n return [];\n }\n};\n\nconst removeStrandedDir = (path: string): void => {\n try {\n rmSync(path, { recursive: true, force: true });\n } catch {\n return;\n }\n};\n\nconst sweepStrandedDirs = (parentDir: string, prefix: string): void => {\n for (const entry of readEntries(parentDir)) {\n if (isStranded(entry, prefix)) {\n removeStrandedDir(join(parentDir, entry));\n }\n }\n};\n\nconst sweepStagingDirs = (target: string): void => {\n sweepStrandedDirs(dirname(target), `${basename(target)}${STAGING_SUFFIX}`);\n};\n\nconst createStagingDir = (target: string): string => {\n mkdirSync(dirname(target), { recursive: true });\n sweepStagingDirs(target);\n\n return mkdtempSync(`${target}${STAGING_SUFFIX}${String(process.pid)}-`);\n};\n\nexport { createStagingDir, sweepStagingDirs, sweepStrandedDirs };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"compile-store.d.ts","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEpF,KAAK,kBAAkB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAqBF,QAAA,MAAM,YAAY,GAAI,QAAQ,kBAAkB,KAAG,IAuBlD,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -17,14 +17,16 @@ const writeEnvReference = (storeDir) => {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
const compileStore = (params) => {
|
|
20
|
-
const fileNames = params.files.map((file) => file.fileName);
|
|
21
20
|
const removeEnvReference = params.requiresEnvReference === true
|
|
22
21
|
? writeEnvReference(params.storeDir)
|
|
23
22
|
: () => undefined;
|
|
23
|
+
const files = params.requiresEnvReference === true
|
|
24
|
+
? [{ fileName: ENV_REFERENCE_FILE }, ...params.files]
|
|
25
|
+
: params.files;
|
|
24
26
|
try {
|
|
25
27
|
compileProject({
|
|
26
28
|
projectDir: params.storeDir,
|
|
27
|
-
|
|
29
|
+
files,
|
|
28
30
|
compilerOptions: EMIT_OPTIONS,
|
|
29
31
|
label: `the generated ${params.packageName} store`,
|
|
30
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-store.js","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"compile-store.js","sourceRoot":"","sources":["../../src/store/compile-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAuC,MAAM,eAAe,CAAC;AASpF,MAAM,YAAY,GAAG;IACjB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,KAAK;IAChB,cAAc,EAAE,KAAK;IACrB,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;CACd,CAAC;AAEF,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAgB,EAAE;IACzD,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,EAAE,+CAA+C,CAAC,CAAC;IAEnG,OAAO,GAAG,EAAE;QACR,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,MAA0B,EAAQ,EAAE;IACtD,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,KAAK,IAAI;QAC3D,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpC,CAAC,CAAC,GAAS,EAAE,CAAC,SAAS,CAAC;IAE5B,MAAM,KAAK,GAAkB,MAAM,CAAC,oBAAoB,KAAK,IAAI;QAC7D,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;QACrD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAEnB,IAAI,CAAC;QACD,cAAc,CAAC;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ;YAC3B,KAAK;YACL,eAAe,EAAE,YAAY;YAC7B,KAAK,EAAE,iBAAiB,MAAM,CAAC,WAAW,QAAQ;SACrD,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,kBAAkB,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { compileProject, type ProjectFile, type SourceModule } from \"../compile.js\";\n\ntype CompileStoreParams = {\n storeDir: string;\n files: SourceModule[];\n packageName: string;\n requiresEnvReference?: boolean;\n};\n\nconst EMIT_OPTIONS = {\n declaration: true,\n removeComments: false,\n sourceMap: false,\n declarationMap: false,\n rootDir: \".\",\n outDir: \".\",\n};\n\nconst ENV_REFERENCE_FILE = \"__gtkx-env__.d.ts\";\n\nconst writeEnvReference = (storeDir: string): (() => void) => {\n writeFileSync(join(storeDir, ENV_REFERENCE_FILE), \"/// <reference types=\\\"@gtkx/react/env\\\" />\\n\");\n\n return () => {\n rmSync(join(storeDir, ENV_REFERENCE_FILE), { force: true });\n };\n};\n\nconst compileStore = (params: CompileStoreParams): void => {\n const removeEnvReference = params.requiresEnvReference === true\n ? writeEnvReference(params.storeDir)\n : (): void => undefined;\n\n const files: ProjectFile[] = params.requiresEnvReference === true\n ? [{ fileName: ENV_REFERENCE_FILE }, ...params.files]\n : params.files;\n\n try {\n compileProject({\n projectDir: params.storeDir,\n files,\n compilerOptions: EMIT_OPTIONS,\n label: `the generated ${params.packageName} store`,\n });\n } finally {\n removeEnvReference();\n }\n\n for (const file of params.files) {\n rmSync(join(params.storeDir, file.fileName), { force: true });\n }\n};\n\nexport { compileStore };\n"]}
|
|
@@ -11,6 +11,10 @@ type InstanceScope = {
|
|
|
11
11
|
methodByName: Map<string, GirFunction>;
|
|
12
12
|
statics: GirFunction[];
|
|
13
13
|
};
|
|
14
|
+
type StaticMember = {
|
|
15
|
+
callable: GirFunction;
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
14
18
|
type InstanceMemberRenderer = (context: ModuleContext, callable: GirFunction, scope: InstanceScope, nameOverride?: string) => string | undefined;
|
|
15
19
|
type PlainTypeMembersOptions = {
|
|
16
20
|
context: ModuleContext;
|
|
@@ -34,11 +38,12 @@ declare const renderStaticSignature: (context: ModuleContext, callable: GirFunct
|
|
|
34
38
|
name: string;
|
|
35
39
|
signature: string;
|
|
36
40
|
} | undefined;
|
|
37
|
-
declare const
|
|
41
|
+
declare const staticMembers: (context: ModuleContext, callables: Callables) => StaticMember[];
|
|
42
|
+
declare const constructorMemberNames: (context: ModuleContext, constructors: GirFunction[]) => string[];
|
|
38
43
|
declare const renderStaticHead: (context: ModuleContext, callables: Callables, ownerClassName: string) => string[];
|
|
39
44
|
declare const renderPlainTypeMembers: (options: PlainTypeMembersOptions) => {
|
|
40
45
|
members: string[];
|
|
41
46
|
claimedNames: Set<string>;
|
|
42
47
|
};
|
|
43
|
-
export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, indexMethodsByName, isEmittableCallable, renderStaticSignature,
|
|
48
|
+
export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, indexMethodsByName, isEmittableCallable, renderStaticSignature, constructorMemberNames, renderStaticHead, renderPlainTypeMembers, staticMembers, type Callables, type InstanceMemberRenderer, type InstanceScope, };
|
|
44
49
|
//# sourceMappingURL=callables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callables.d.ts","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"callables.d.ts","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAmBrD,KAAK,SAAS,GAAG;IACb,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,OAAO,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAC;AAEF,KAAK,aAAa,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,GAAG,CAAC,MAAM,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C,QAAA,MAAM,qBAAqB,GACvB,SAAS,aAAa,EACtB,UAAU,WAAW,EACrB,UAAU;IAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,SAAS,CAAA;CAAE,KAC5F;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAqBxC,CAAC;AAoBF,QAAA,MAAM,aAAa,GAAI,SAAS,aAAa,EAAE,WAAW,SAAS,KAAG,YAAY,EAGjF,CAAC;AAEF,QAAA,MAAM,sBAAsB,GAAI,SAAS,aAAa,EAAE,cAAc,WAAW,EAAE,KAAG,MAAM,EACO,CAAC;AAqBpG,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,WAAW,SAAS,EAAE,gBAAgB,MAAM,KAAG,MAAM,EActG,CAAC;AAuBF,QAAA,MAAM,sBAAsB,GACxB,SAAS,uBAAuB,KACjC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAWhD,CAAC;AAEF,OAAO,EACH,6BAA6B,EAC7B,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,EACb,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,aAAa,GACrB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toCamelIdentifier, uniqBy } from "@gtkx/utils";
|
|
2
2
|
import { hasUnmarshalableParam } from "../../analysis/param-capability.js";
|
|
3
3
|
import { renderBlock } from "../../writer/emit.js";
|
|
4
4
|
import { matchAsyncFinish } from "./async.js";
|
|
5
5
|
import { callableDoc, callableSpec } from "./callable-doc.js";
|
|
6
6
|
import { renderFnExpression } from "./function.js";
|
|
7
7
|
import { gtypeMemberDeclaration } from "./gtype-binding.js";
|
|
8
|
-
import { finishCallExpression, methodExportName, renderMethodBody, renderMethodReturnType, renderMethodSignature, renderPromisifiedBody, renderPromisifiedSignature, } from "./method.js";
|
|
8
|
+
import { finishCallExpression, memberName, methodExportName, renderMethodBody, renderMethodReturnType, renderMethodSignature, renderPromisifiedBody, renderPromisifiedSignature, } from "./method.js";
|
|
9
9
|
import { renderRuntimeOverride, runtimeOverrideRenames } from "./runtime-override.js";
|
|
10
10
|
const renderInstanceMethodSignature = instanceMemberRenderer((context, callable, { name, finishFn }) => `${memberDoc(context, callable, finishFn)}${memberSignatureText(context, callable, name, { finishFn })};`);
|
|
11
11
|
const renderClassInstanceMember = instanceMemberRenderer((context, callable, { name, finishFn }, scope) => finishFn === undefined
|
|
@@ -23,11 +23,9 @@ const instanceScope = (ownerName, callables) => ({
|
|
|
23
23
|
statics: [...callables.constructors, ...callables.functions],
|
|
24
24
|
});
|
|
25
25
|
const dedupeCallables = (callables) => uniqBy(callables.filter((callable) => callable.cIdentifier !== undefined), (callable) => callable.cIdentifier);
|
|
26
|
+
const getEmittableCIdentifier = (context, callable) => isEmittableCallable(context, callable) ? callable.cIdentifier : undefined;
|
|
26
27
|
const renderBinding = (context, callable) => {
|
|
27
|
-
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
const cIdentifier = callable.cIdentifier;
|
|
28
|
+
const cIdentifier = getEmittableCIdentifier(context, callable);
|
|
31
29
|
if (cIdentifier === undefined) {
|
|
32
30
|
return undefined;
|
|
33
31
|
}
|
|
@@ -47,15 +45,12 @@ const generateBindings = (context, callables) => {
|
|
|
47
45
|
}
|
|
48
46
|
};
|
|
49
47
|
const resolveCallableMember = (context, callable, resolveName) => {
|
|
50
|
-
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
const cIdentifier = callable.cIdentifier;
|
|
48
|
+
const cIdentifier = getEmittableCIdentifier(context, callable);
|
|
54
49
|
if (cIdentifier === undefined) {
|
|
55
50
|
return undefined;
|
|
56
51
|
}
|
|
57
52
|
const name = resolveName(callable);
|
|
58
|
-
if (name === undefined || name
|
|
53
|
+
if (name === undefined || !isEmittableMemberName(name)) {
|
|
59
54
|
return undefined;
|
|
60
55
|
}
|
|
61
56
|
return { cIdentifier, name };
|
|
@@ -93,7 +88,7 @@ const renderStaticEntry = (context, callable, siblings, options) => {
|
|
|
93
88
|
const finishFn = matchStaticFinishFunction(context, callable, siblings);
|
|
94
89
|
if (finishFn !== undefined) {
|
|
95
90
|
const name = options.resolveName(callable);
|
|
96
|
-
if (name === undefined || name
|
|
91
|
+
if (name === undefined || !isEmittableMemberName(name)) {
|
|
97
92
|
return undefined;
|
|
98
93
|
}
|
|
99
94
|
return renderPromisifiedCallable(context, callable, finishFn, {
|
|
@@ -113,12 +108,13 @@ const renderInstanceMethod = (context, callable, nameOverride) => renderCallable
|
|
|
113
108
|
isStatic: false,
|
|
114
109
|
canUseRuntimeOverride: true,
|
|
115
110
|
});
|
|
111
|
+
const isEmittableMemberName = (name) => name !== "constructor" && name.length > 0;
|
|
116
112
|
const resolveInstanceMember = (context, callable, scope, nameOverride) => {
|
|
117
113
|
if (!isEmittableCallable(context, callable)) {
|
|
118
114
|
return undefined;
|
|
119
115
|
}
|
|
120
116
|
const name = nameOverride ?? methodExportName(callable);
|
|
121
|
-
if (name
|
|
117
|
+
if (!isEmittableMemberName(name)) {
|
|
122
118
|
return undefined;
|
|
123
119
|
}
|
|
124
120
|
const finishFn = matchFinishFunction(context, callable, scope);
|
|
@@ -173,11 +169,8 @@ const isEmittableCallable = (context, callable) => callable.introspectable &&
|
|
|
173
169
|
callable.cIdentifier !== undefined &&
|
|
174
170
|
!hasUnmarshalableParam(context, callable);
|
|
175
171
|
const constructorMemberName = (girName) => {
|
|
176
|
-
const camel =
|
|
177
|
-
|
|
178
|
-
return undefined;
|
|
179
|
-
}
|
|
180
|
-
return camel;
|
|
172
|
+
const camel = memberName(girName);
|
|
173
|
+
return isEmittableMemberName(camel) ? camel : undefined;
|
|
181
174
|
};
|
|
182
175
|
const renderStaticSignature = (context, callable, options) => {
|
|
183
176
|
if (!isEmittableCallable(context, callable)) {
|
|
@@ -196,19 +189,21 @@ const renderStaticSignature = (context, callable, options) => {
|
|
|
196
189
|
}),
|
|
197
190
|
};
|
|
198
191
|
};
|
|
199
|
-
const
|
|
200
|
-
const
|
|
201
|
-
for (const callable of
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const member = constructorMemberName(callable.name);
|
|
206
|
-
if (member !== undefined) {
|
|
207
|
-
names.push(member);
|
|
192
|
+
const collectStaticMembers = (context, group, resolveName) => {
|
|
193
|
+
const members = [];
|
|
194
|
+
for (const callable of group) {
|
|
195
|
+
const name = isEmittableCallable(context, callable) ? resolveName(callable.name) : undefined;
|
|
196
|
+
if (name !== undefined) {
|
|
197
|
+
members.push({ callable, name });
|
|
208
198
|
}
|
|
209
199
|
}
|
|
210
|
-
return
|
|
200
|
+
return members;
|
|
211
201
|
};
|
|
202
|
+
const staticMembers = (context, callables) => [
|
|
203
|
+
...collectStaticMembers(context, callables.constructors, constructorMemberName),
|
|
204
|
+
...collectStaticMembers(context, callables.functions, memberName),
|
|
205
|
+
];
|
|
206
|
+
const constructorMemberNames = (context, constructors) => collectStaticMembers(context, constructors, constructorMemberName).map((member) => member.name);
|
|
212
207
|
const collectStaticEntries = (context, group, siblings, options) => {
|
|
213
208
|
const blocks = [];
|
|
214
209
|
for (const callable of group) {
|
|
@@ -228,7 +223,7 @@ const renderStaticHead = (context, callables, ownerClassName) => {
|
|
|
228
223
|
returnTypeOverride: ownerClassName,
|
|
229
224
|
}),
|
|
230
225
|
...collectStaticEntries(context, callables.functions, siblings, {
|
|
231
|
-
resolveName: (member) =>
|
|
226
|
+
resolveName: (member) => memberName(member.name),
|
|
232
227
|
ownerName: ownerClassName,
|
|
233
228
|
}),
|
|
234
229
|
];
|
|
@@ -255,5 +250,5 @@ const renderPlainTypeMembers = (options) => {
|
|
|
255
250
|
];
|
|
256
251
|
return { members, claimedNames };
|
|
257
252
|
};
|
|
258
|
-
export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, indexMethodsByName, isEmittableCallable, renderStaticSignature,
|
|
253
|
+
export { renderInstanceMethodSignature, renderClassInstanceMember, instanceMemberSpec, instanceScope, dedupeCallables, generateBindings, matchStaticFinishFunction, indexMethodsByName, isEmittableCallable, renderStaticSignature, constructorMemberNames, renderStaticHead, renderPlainTypeMembers, staticMembers, };
|
|
259
254
|
//# sourceMappingURL=callables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callables.js","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAInE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACH,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AA8CtF,MAAM,6BAA6B,GAA2B,sBAAsB,CAChF,CAAC,OAAO,EAAE,QAAQ,EAAE,EAA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AsB,GAAG,CAC3B,OAAgC,EACgB,EAAE;IAClD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC5D,MAAM,YAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;IAE5C,MAAM,OAAO,GAAa;QACtB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;QAClD,GAAG,0BAA0B,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;KAC1E,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,OAAO,EACH,6BAA6B,EAC7B,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,GAIzB,CAAC","sourcesContent":["import { camelCase, toCamelIdentifier, uniqBy } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport type { JsDocSpec } from \"../../writer/doc.js\";\nimport { hasUnmarshalableParam } from \"../../analysis/param-capability.js\";\nimport { renderBlock } from \"../../writer/emit.js\";\nimport { matchAsyncFinish } from \"./async.js\";\nimport { callableDoc, callableSpec } from \"./callable-doc.js\";\nimport { renderFnExpression } from \"./function.js\";\nimport { gtypeMemberDeclaration } from \"./gtype-binding.js\";\nimport {\n finishCallExpression,\n methodExportName,\n renderMethodBody,\n renderMethodReturnType,\n renderMethodSignature,\n renderPromisifiedBody,\n renderPromisifiedSignature,\n} from \"./method.js\";\nimport { renderRuntimeOverride, runtimeOverrideRenames } from \"./runtime-override.js\";\n\ntype Callables = {\n constructors: GirFunction[];\n functions: GirFunction[];\n methods: GirFunction[];\n};\n\ntype InstanceScope = {\n ownerName: string;\n methodByName: Map<string, GirFunction>;\n statics: GirFunction[];\n};\n\ntype CallableMemberOptions = {\n resolveName: (callable: GirFunction) => string | undefined;\n isStatic: boolean;\n returnTypeOverride?: string | undefined;\n canUseRuntimeOverride?: boolean;\n};\n\ntype StaticEntryOptions = {\n resolveName: (callable: GirFunction) => string | undefined;\n ownerName: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype ResolvedInstanceMember = {\n name: string;\n finishFn: GirFunction | undefined;\n};\n\ntype InstanceMemberRenderer = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n nameOverride?: string,\n) => string | undefined;\n\ntype PlainTypeMembersOptions = {\n context: ModuleContext;\n className: string;\n callables: Callables;\n hasGtype: boolean;\n};\n\nconst renderInstanceMethodSignature: InstanceMemberRenderer = instanceMemberRenderer(\n (context, callable, { name, finishFn }) =>\n `${memberDoc(context, callable, finishFn)}${memberSignatureText(context, callable, name, { finishFn })};`,\n);\n\nconst renderClassInstanceMember: InstanceMemberRenderer = instanceMemberRenderer(\n (context, callable, { name, finishFn }, scope) =>\n finishFn === undefined\n ? renderInstanceMethod(context, callable, name)\n : renderPromisifiedCallable(context, callable, finishFn, {\n name,\n isStatic: false,\n ownerName: scope.ownerName,\n }),\n);\n\nconst memberDoc = (context: ModuleContext, callable: GirFunction, finishFn: GirFunction | undefined): string =>\n callableDoc(context, callable, { finishFn });\n\nconst instanceMemberSpec = (context: ModuleContext, callable: GirFunction, scope: InstanceScope): JsDocSpec =>\n callableSpec(context, callable, { finishFn: matchFinishFunction(context, callable, scope) });\n\nconst instanceScope = (ownerName: string, callables: Callables): InstanceScope => ({\n ownerName,\n methodByName: indexMethodsByName(callables.methods),\n statics: [...callables.constructors, ...callables.functions],\n});\n\nconst dedupeCallables = (callables: GirFunction[]): GirFunction[] =>\n uniqBy(\n callables.filter(\n (callable): callable is GirFunction & { cIdentifier: string } => callable.cIdentifier !== undefined,\n ),\n (callable) => callable.cIdentifier,\n );\n\nconst renderBinding = (\n context: ModuleContext,\n callable: GirFunction,\n): { text: string; cIdentifier: string } | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const cIdentifier = callable.cIdentifier;\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const expression = renderFnExpression(context, callable);\n\n if (expression === undefined) {\n return undefined;\n }\n\n return { text: `const ${toCamelIdentifier(cIdentifier)} = ${expression};`, cIdentifier };\n};\n\nconst generateBindings = (context: ModuleContext, callables: Callables): void => {\n const all = [...callables.constructors, ...callables.functions, ...callables.methods];\n\n for (const callable of all) {\n const binding = renderBinding(context, callable);\n\n if (binding !== undefined) {\n context.module.appendBinding(binding.text, binding.cIdentifier);\n }\n }\n};\n\nconst resolveCallableMember = (\n context: ModuleContext,\n callable: GirFunction,\n resolveName: (callable: GirFunction) => string | undefined,\n): { cIdentifier: string; name: string } | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const cIdentifier = callable.cIdentifier;\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const name = resolveName(callable);\n\n if (name === undefined || name === \"constructor\") {\n return undefined;\n }\n\n return { cIdentifier, name };\n};\n\nconst runtimeOverrideMember = (\n callable: GirFunction,\n name: string,\n doc: string,\n canUseRuntimeOverride: boolean | undefined,\n): string | undefined => {\n if (canUseRuntimeOverride !== true) {\n return undefined;\n }\n\n const override = renderRuntimeOverride(callable, name);\n\n return override === undefined ? undefined : `${doc}${override}`;\n};\n\nconst renderCallableMember = (\n context: ModuleContext,\n callable: GirFunction,\n options: CallableMemberOptions,\n): string | undefined => {\n const resolved = resolveCallableMember(context, callable, options.resolveName);\n\n if (resolved === undefined) {\n return undefined;\n }\n\n const { cIdentifier, name } = resolved;\n const renames = options.canUseRuntimeOverride === true ? runtimeOverrideRenames(callable) : undefined;\n const doc = callableDoc(context, callable, { renames });\n const override = runtimeOverrideMember(callable, name, doc, options.canUseRuntimeOverride);\n\n if (override !== undefined) {\n return override;\n }\n\n const signature = renderMethodSignature(context, callable);\n const returnType = options.returnTypeOverride ?? renderMethodReturnType(context, callable);\n\n const body = renderMethodBody(context, callable, {\n bindingExpression: toCamelIdentifier(cIdentifier),\n returnTypeOverride: options.returnTypeOverride,\n });\n\n const prefix = options.isStatic ? \"static \" : \"\";\n const header = `${prefix}${name}(${signature}): ${returnType}`;\n\n return `${doc}${renderBlock(header, body)}`;\n};\n\nconst renderStaticEntry = (\n context: ModuleContext,\n callable: GirFunction,\n siblings: GirFunction[],\n options: StaticEntryOptions,\n): string | undefined => {\n const finishFn = matchStaticFinishFunction(context, callable, siblings);\n\n if (finishFn !== undefined) {\n const name = options.resolveName(callable);\n\n if (name === undefined || name === \"constructor\") {\n return undefined;\n }\n\n return renderPromisifiedCallable(context, callable, finishFn, {\n name,\n isStatic: true,\n ownerName: options.ownerName,\n });\n }\n\n return renderCallableMember(context, callable, {\n resolveName: options.resolveName,\n isStatic: true,\n returnTypeOverride: options.returnTypeOverride,\n });\n};\n\nconst renderInstanceMethod = (\n context: ModuleContext,\n callable: GirFunction,\n nameOverride?: string,\n): string | undefined =>\n renderCallableMember(context, callable, {\n resolveName: (member) => nameOverride ?? methodExportName(member),\n isStatic: false,\n canUseRuntimeOverride: true,\n });\n\nconst resolveInstanceMember = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n nameOverride?: string,\n): ResolvedInstanceMember | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = nameOverride ?? methodExportName(callable);\n\n if (name === \"constructor\") {\n return undefined;\n }\n\n const finishFn = matchFinishFunction(context, callable, scope);\n\n if (finishFn !== undefined && !isEmittableCallable(context, finishFn)) {\n return undefined;\n }\n\n return { name, finishFn };\n};\n\nfunction instanceMemberRenderer(\n render: (\n context: ModuleContext,\n callable: GirFunction,\n member: ResolvedInstanceMember,\n scope: InstanceScope,\n ) => string | undefined,\n): InstanceMemberRenderer {\n return (context, callable, scope, nameOverride) => {\n const member = resolveInstanceMember(context, callable, scope, nameOverride);\n\n return member === undefined ? undefined : render(context, callable, member, scope);\n };\n}\n\nconst memberSignatureText = (\n context: ModuleContext,\n callable: GirFunction,\n name: string,\n options: { finishFn: GirFunction | undefined; returnTypeOverride?: string | undefined },\n): string => {\n const promisified =\n options.finishFn === undefined ? undefined : renderPromisifiedSignature(context, callable, options.finishFn);\n\n const signature = promisified?.signature ?? renderMethodSignature(context, callable);\n\n const returnType =\n promisified?.returnType ?? options.returnTypeOverride ?? renderMethodReturnType(context, callable);\n\n return `${name}(${signature}): ${returnType}`;\n};\n\nconst matchFinishFunction = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n): GirFunction | undefined =>\n matchAsyncFinish(context.library, callable, [...scope.methodByName.values(), ...scope.statics]);\n\nconst matchStaticFinishFunction = (\n context: ModuleContext,\n callable: GirFunction,\n siblings: GirFunction[],\n): GirFunction | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const finishFn = matchAsyncFinish(context.library, callable, siblings);\n\n if (finishFn === undefined || !isEmittableCallable(context, finishFn)) {\n return undefined;\n }\n\n return finishFn;\n};\n\nconst renderPromisifiedCallable = (\n context: ModuleContext,\n callable: GirFunction,\n finishFn: GirFunction,\n member: { name: string; isStatic: boolean; ownerName: string },\n): string | undefined => {\n const cIdentifier = callable.cIdentifier;\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const { signature, returnType } = renderPromisifiedSignature(context, callable, finishFn);\n\n const body = renderPromisifiedBody(\n context,\n callable,\n finishCallExpression(callable, finishFn, member.ownerName),\n toCamelIdentifier(cIdentifier),\n );\n\n const prefix = member.isStatic ? \"static \" : \"\";\n const header = `${prefix}${member.name}(${signature}): ${returnType}`;\n\n return `${memberDoc(context, callable, finishFn)}${renderBlock(header, body)}`;\n};\n\nconst indexMethodsByName = (methods: GirFunction[]): Map<string, GirFunction> => {\n const map: Map<string, GirFunction> = new Map();\n\n for (const callable of methods) {\n map.set(callable.name, callable);\n }\n\n return map;\n};\n\nconst isEmittableCallable = (context: ModuleContext, callable: GirFunction): boolean =>\n callable.introspectable &&\n callable.shadowedBy === undefined &&\n callable.cIdentifier !== undefined &&\n !hasUnmarshalableParam(context, callable);\n\nconst constructorMemberName = (girName: string): string | undefined => {\n const camel = camelCase(girName);\n\n if (camel === \"constructor\") {\n return undefined;\n }\n\n return camel;\n};\n\nconst renderStaticSignature = (\n context: ModuleContext,\n callable: GirFunction,\n options?: { returnTypeOverride?: string | undefined; siblings?: GirFunction[] | undefined },\n): { name: string; signature: string } | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = constructorMemberName(callable.name);\n\n if (name === undefined) {\n return undefined;\n }\n\n const finishFn =\n options?.siblings === undefined ? undefined : matchStaticFinishFunction(context, callable, options.siblings);\n\n return {\n name,\n signature: memberSignatureText(context, callable, name, {\n finishFn,\n returnTypeOverride: options?.returnTypeOverride,\n }),\n };\n};\n\nconst classConstructorMemberNames = (context: ModuleContext, callables: Callables): string[] => {\n const names: string[] = [];\n\n for (const callable of callables.constructors) {\n if (!isEmittableCallable(context, callable)) {\n continue;\n }\n\n const member = constructorMemberName(callable.name);\n\n if (member !== undefined) {\n names.push(member);\n }\n }\n\n return names;\n};\n\nconst collectStaticEntries = (\n context: ModuleContext,\n group: GirFunction[],\n siblings: GirFunction[],\n options: StaticEntryOptions,\n): string[] => {\n const blocks: string[] = [];\n\n for (const callable of group) {\n const block = renderStaticEntry(context, callable, siblings, options);\n\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n\n return blocks;\n};\n\nconst renderStaticHead = (context: ModuleContext, callables: Callables, ownerClassName: string): string[] => {\n const siblings = [...callables.constructors, ...callables.functions];\n\n return [\n ...collectStaticEntries(context, callables.constructors, siblings, {\n resolveName: (member) => constructorMemberName(member.name),\n ownerName: ownerClassName,\n returnTypeOverride: ownerClassName,\n }),\n ...collectStaticEntries(context, callables.functions, siblings, {\n resolveName: (member) => camelCase(member.name),\n ownerName: ownerClassName,\n }),\n ];\n};\n\nconst renderPlainInstanceMethods = (\n context: ModuleContext,\n methods: GirFunction[],\n claimedNames: Set<string>,\n): string[] => {\n const blocks: string[] = [];\n\n for (const callable of methods) {\n const block = renderInstanceMethod(context, callable);\n\n if (block === undefined) {\n continue;\n }\n\n blocks.push(block);\n claimedNames.add(methodExportName(callable));\n }\n\n return blocks;\n};\n\nconst renderPlainTypeMembers = (\n options: PlainTypeMembersOptions,\n): { members: string[]; claimedNames: Set<string> } => {\n const { context, className, callables, hasGtype } = options;\n const claimedNames: Set<string> = new Set();\n\n const members: string[] = [\n ...(hasGtype ? [gtypeMemberDeclaration(context)] : []),\n ...renderStaticHead(context, callables, className),\n ...renderPlainInstanceMethods(context, callables.methods, claimedNames),\n ];\n\n return { members, claimedNames };\n};\n\nexport {\n renderInstanceMethodSignature,\n renderClassInstanceMember,\n instanceMemberSpec,\n instanceScope,\n dedupeCallables,\n generateBindings,\n matchStaticFinishFunction,\n indexMethodsByName,\n isEmittableCallable,\n renderStaticSignature,\n classConstructorMemberNames,\n renderStaticHead,\n renderPlainTypeMembers,\n type Callables,\n type InstanceMemberRenderer,\n type InstanceScope,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"callables.js","sourceRoot":"","sources":["../../../src/store/gi/callables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAA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AAC,CAAC,EAAE,CAAC;QACtD,GAAG,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;QAClD,GAAG,0BAA0B,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;KAC1E,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,OAAO,EACH,6BAA6B,EAC7B,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,GAIhB,CAAC","sourcesContent":["import { toCamelIdentifier, uniqBy } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport type { JsDocSpec } from \"../../writer/doc.js\";\nimport { hasUnmarshalableParam } from \"../../analysis/param-capability.js\";\nimport { renderBlock } from \"../../writer/emit.js\";\nimport { matchAsyncFinish } from \"./async.js\";\nimport { callableDoc, callableSpec } from \"./callable-doc.js\";\nimport { renderFnExpression } from \"./function.js\";\nimport { gtypeMemberDeclaration } from \"./gtype-binding.js\";\nimport {\n finishCallExpression,\n memberName,\n methodExportName,\n renderMethodBody,\n renderMethodReturnType,\n renderMethodSignature,\n renderPromisifiedBody,\n renderPromisifiedSignature,\n} from \"./method.js\";\nimport { renderRuntimeOverride, runtimeOverrideRenames } from \"./runtime-override.js\";\n\ntype Callables = {\n constructors: GirFunction[];\n functions: GirFunction[];\n methods: GirFunction[];\n};\n\ntype InstanceScope = {\n ownerName: string;\n methodByName: Map<string, GirFunction>;\n statics: GirFunction[];\n};\n\ntype CallableMemberOptions = {\n resolveName: (callable: GirFunction) => string | undefined;\n isStatic: boolean;\n returnTypeOverride?: string | undefined;\n canUseRuntimeOverride?: boolean;\n};\n\ntype StaticEntryOptions = {\n resolveName: (callable: GirFunction) => string | undefined;\n ownerName: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype ResolvedInstanceMember = {\n name: string;\n finishFn: GirFunction | undefined;\n};\n\ntype StaticMember = {\n callable: GirFunction;\n name: string;\n};\n\ntype InstanceMemberRenderer = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n nameOverride?: string,\n) => string | undefined;\n\ntype PlainTypeMembersOptions = {\n context: ModuleContext;\n className: string;\n callables: Callables;\n hasGtype: boolean;\n};\n\nconst renderInstanceMethodSignature: InstanceMemberRenderer = instanceMemberRenderer(\n (context, callable, { name, finishFn }) =>\n `${memberDoc(context, callable, finishFn)}${memberSignatureText(context, callable, name, { finishFn })};`,\n);\n\nconst renderClassInstanceMember: InstanceMemberRenderer = instanceMemberRenderer(\n (context, callable, { name, finishFn }, scope) =>\n finishFn === undefined\n ? renderInstanceMethod(context, callable, name)\n : renderPromisifiedCallable(context, callable, finishFn, {\n name,\n isStatic: false,\n ownerName: scope.ownerName,\n }),\n);\n\nconst memberDoc = (context: ModuleContext, callable: GirFunction, finishFn: GirFunction | undefined): string =>\n callableDoc(context, callable, { finishFn });\n\nconst instanceMemberSpec = (context: ModuleContext, callable: GirFunction, scope: InstanceScope): JsDocSpec =>\n callableSpec(context, callable, { finishFn: matchFinishFunction(context, callable, scope) });\n\nconst instanceScope = (ownerName: string, callables: Callables): InstanceScope => ({\n ownerName,\n methodByName: indexMethodsByName(callables.methods),\n statics: [...callables.constructors, ...callables.functions],\n});\n\nconst dedupeCallables = (callables: GirFunction[]): GirFunction[] =>\n uniqBy(\n callables.filter(\n (callable): callable is GirFunction & { cIdentifier: string } => callable.cIdentifier !== undefined,\n ),\n (callable) => callable.cIdentifier,\n );\n\nconst getEmittableCIdentifier = (context: ModuleContext, callable: GirFunction): string | undefined =>\n isEmittableCallable(context, callable) ? callable.cIdentifier : undefined;\n\nconst renderBinding = (\n context: ModuleContext,\n callable: GirFunction,\n): { text: string; cIdentifier: string } | undefined => {\n const cIdentifier = getEmittableCIdentifier(context, callable);\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const expression = renderFnExpression(context, callable);\n\n if (expression === undefined) {\n return undefined;\n }\n\n return { text: `const ${toCamelIdentifier(cIdentifier)} = ${expression};`, cIdentifier };\n};\n\nconst generateBindings = (context: ModuleContext, callables: Callables): void => {\n const all = [...callables.constructors, ...callables.functions, ...callables.methods];\n\n for (const callable of all) {\n const binding = renderBinding(context, callable);\n\n if (binding !== undefined) {\n context.module.appendBinding(binding.text, binding.cIdentifier);\n }\n }\n};\n\nconst resolveCallableMember = (\n context: ModuleContext,\n callable: GirFunction,\n resolveName: (callable: GirFunction) => string | undefined,\n): { cIdentifier: string; name: string } | undefined => {\n const cIdentifier = getEmittableCIdentifier(context, callable);\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const name = resolveName(callable);\n\n if (name === undefined || !isEmittableMemberName(name)) {\n return undefined;\n }\n\n return { cIdentifier, name };\n};\n\nconst runtimeOverrideMember = (\n callable: GirFunction,\n name: string,\n doc: string,\n canUseRuntimeOverride: boolean | undefined,\n): string | undefined => {\n if (canUseRuntimeOverride !== true) {\n return undefined;\n }\n\n const override = renderRuntimeOverride(callable, name);\n\n return override === undefined ? undefined : `${doc}${override}`;\n};\n\nconst renderCallableMember = (\n context: ModuleContext,\n callable: GirFunction,\n options: CallableMemberOptions,\n): string | undefined => {\n const resolved = resolveCallableMember(context, callable, options.resolveName);\n\n if (resolved === undefined) {\n return undefined;\n }\n\n const { cIdentifier, name } = resolved;\n const renames = options.canUseRuntimeOverride === true ? runtimeOverrideRenames(callable) : undefined;\n const doc = callableDoc(context, callable, { renames });\n const override = runtimeOverrideMember(callable, name, doc, options.canUseRuntimeOverride);\n\n if (override !== undefined) {\n return override;\n }\n\n const signature = renderMethodSignature(context, callable);\n const returnType = options.returnTypeOverride ?? renderMethodReturnType(context, callable);\n\n const body = renderMethodBody(context, callable, {\n bindingExpression: toCamelIdentifier(cIdentifier),\n returnTypeOverride: options.returnTypeOverride,\n });\n\n const prefix = options.isStatic ? \"static \" : \"\";\n const header = `${prefix}${name}(${signature}): ${returnType}`;\n\n return `${doc}${renderBlock(header, body)}`;\n};\n\nconst renderStaticEntry = (\n context: ModuleContext,\n callable: GirFunction,\n siblings: GirFunction[],\n options: StaticEntryOptions,\n): string | undefined => {\n const finishFn = matchStaticFinishFunction(context, callable, siblings);\n\n if (finishFn !== undefined) {\n const name = options.resolveName(callable);\n\n if (name === undefined || !isEmittableMemberName(name)) {\n return undefined;\n }\n\n return renderPromisifiedCallable(context, callable, finishFn, {\n name,\n isStatic: true,\n ownerName: options.ownerName,\n });\n }\n\n return renderCallableMember(context, callable, {\n resolveName: options.resolveName,\n isStatic: true,\n returnTypeOverride: options.returnTypeOverride,\n });\n};\n\nconst renderInstanceMethod = (\n context: ModuleContext,\n callable: GirFunction,\n nameOverride?: string,\n): string | undefined =>\n renderCallableMember(context, callable, {\n resolveName: (member) => nameOverride ?? methodExportName(member),\n isStatic: false,\n canUseRuntimeOverride: true,\n });\n\nconst isEmittableMemberName = (name: string): boolean => name !== \"constructor\" && name.length > 0;\n\nconst resolveInstanceMember = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n nameOverride?: string,\n): ResolvedInstanceMember | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = nameOverride ?? methodExportName(callable);\n\n if (!isEmittableMemberName(name)) {\n return undefined;\n }\n\n const finishFn = matchFinishFunction(context, callable, scope);\n\n if (finishFn !== undefined && !isEmittableCallable(context, finishFn)) {\n return undefined;\n }\n\n return { name, finishFn };\n};\n\nfunction instanceMemberRenderer(\n render: (\n context: ModuleContext,\n callable: GirFunction,\n member: ResolvedInstanceMember,\n scope: InstanceScope,\n ) => string | undefined,\n): InstanceMemberRenderer {\n return (context, callable, scope, nameOverride) => {\n const member = resolveInstanceMember(context, callable, scope, nameOverride);\n\n return member === undefined ? undefined : render(context, callable, member, scope);\n };\n}\n\nconst memberSignatureText = (\n context: ModuleContext,\n callable: GirFunction,\n name: string,\n options: { finishFn: GirFunction | undefined; returnTypeOverride?: string | undefined },\n): string => {\n const promisified =\n options.finishFn === undefined ? undefined : renderPromisifiedSignature(context, callable, options.finishFn);\n\n const signature = promisified?.signature ?? renderMethodSignature(context, callable);\n\n const returnType =\n promisified?.returnType ?? options.returnTypeOverride ?? renderMethodReturnType(context, callable);\n\n return `${name}(${signature}): ${returnType}`;\n};\n\nconst matchFinishFunction = (\n context: ModuleContext,\n callable: GirFunction,\n scope: InstanceScope,\n): GirFunction | undefined =>\n matchAsyncFinish(context.library, callable, [...scope.methodByName.values(), ...scope.statics]);\n\nconst matchStaticFinishFunction = (\n context: ModuleContext,\n callable: GirFunction,\n siblings: GirFunction[],\n): GirFunction | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const finishFn = matchAsyncFinish(context.library, callable, siblings);\n\n if (finishFn === undefined || !isEmittableCallable(context, finishFn)) {\n return undefined;\n }\n\n return finishFn;\n};\n\nconst renderPromisifiedCallable = (\n context: ModuleContext,\n callable: GirFunction,\n finishFn: GirFunction,\n member: { name: string; isStatic: boolean; ownerName: string },\n): string | undefined => {\n const cIdentifier = callable.cIdentifier;\n\n if (cIdentifier === undefined) {\n return undefined;\n }\n\n const { signature, returnType } = renderPromisifiedSignature(context, callable, finishFn);\n\n const body = renderPromisifiedBody(\n context,\n callable,\n finishCallExpression(callable, finishFn, member.ownerName),\n toCamelIdentifier(cIdentifier),\n );\n\n const prefix = member.isStatic ? \"static \" : \"\";\n const header = `${prefix}${member.name}(${signature}): ${returnType}`;\n\n return `${memberDoc(context, callable, finishFn)}${renderBlock(header, body)}`;\n};\n\nconst indexMethodsByName = (methods: GirFunction[]): Map<string, GirFunction> => {\n const map: Map<string, GirFunction> = new Map();\n\n for (const callable of methods) {\n map.set(callable.name, callable);\n }\n\n return map;\n};\n\nconst isEmittableCallable = (context: ModuleContext, callable: GirFunction): boolean =>\n callable.introspectable &&\n callable.shadowedBy === undefined &&\n callable.cIdentifier !== undefined &&\n !hasUnmarshalableParam(context, callable);\n\nconst constructorMemberName = (girName: string): string | undefined => {\n const camel = memberName(girName);\n\n return isEmittableMemberName(camel) ? camel : undefined;\n};\n\nconst renderStaticSignature = (\n context: ModuleContext,\n callable: GirFunction,\n options?: { returnTypeOverride?: string | undefined; siblings?: GirFunction[] | undefined },\n): { name: string; signature: string } | undefined => {\n if (!isEmittableCallable(context, callable)) {\n return undefined;\n }\n\n const name = constructorMemberName(callable.name);\n\n if (name === undefined) {\n return undefined;\n }\n\n const finishFn =\n options?.siblings === undefined ? undefined : matchStaticFinishFunction(context, callable, options.siblings);\n\n return {\n name,\n signature: memberSignatureText(context, callable, name, {\n finishFn,\n returnTypeOverride: options?.returnTypeOverride,\n }),\n };\n};\n\nconst collectStaticMembers = (\n context: ModuleContext,\n group: GirFunction[],\n resolveName: (girName: string) => string | undefined,\n): StaticMember[] => {\n const members: StaticMember[] = [];\n\n for (const callable of group) {\n const name = isEmittableCallable(context, callable) ? resolveName(callable.name) : undefined;\n\n if (name !== undefined) {\n members.push({ callable, name });\n }\n }\n\n return members;\n};\n\nconst staticMembers = (context: ModuleContext, callables: Callables): StaticMember[] => [\n ...collectStaticMembers(context, callables.constructors, constructorMemberName),\n ...collectStaticMembers(context, callables.functions, memberName),\n];\n\nconst constructorMemberNames = (context: ModuleContext, constructors: GirFunction[]): string[] =>\n collectStaticMembers(context, constructors, constructorMemberName).map((member) => member.name);\n\nconst collectStaticEntries = (\n context: ModuleContext,\n group: GirFunction[],\n siblings: GirFunction[],\n options: StaticEntryOptions,\n): string[] => {\n const blocks: string[] = [];\n\n for (const callable of group) {\n const block = renderStaticEntry(context, callable, siblings, options);\n\n if (block !== undefined) {\n blocks.push(block);\n }\n }\n\n return blocks;\n};\n\nconst renderStaticHead = (context: ModuleContext, callables: Callables, ownerClassName: string): string[] => {\n const siblings = [...callables.constructors, ...callables.functions];\n\n return [\n ...collectStaticEntries(context, callables.constructors, siblings, {\n resolveName: (member) => constructorMemberName(member.name),\n ownerName: ownerClassName,\n returnTypeOverride: ownerClassName,\n }),\n ...collectStaticEntries(context, callables.functions, siblings, {\n resolveName: (member) => memberName(member.name),\n ownerName: ownerClassName,\n }),\n ];\n};\n\nconst renderPlainInstanceMethods = (\n context: ModuleContext,\n methods: GirFunction[],\n claimedNames: Set<string>,\n): string[] => {\n const blocks: string[] = [];\n\n for (const callable of methods) {\n const block = renderInstanceMethod(context, callable);\n\n if (block === undefined) {\n continue;\n }\n\n blocks.push(block);\n claimedNames.add(methodExportName(callable));\n }\n\n return blocks;\n};\n\nconst renderPlainTypeMembers = (\n options: PlainTypeMembersOptions,\n): { members: string[]; claimedNames: Set<string> } => {\n const { context, className, callables, hasGtype } = options;\n const claimedNames: Set<string> = new Set();\n\n const members: string[] = [\n ...(hasGtype ? [gtypeMemberDeclaration(context)] : []),\n ...renderStaticHead(context, callables, className),\n ...renderPlainInstanceMethods(context, callables.methods, claimedNames),\n ];\n\n return { members, claimedNames };\n};\n\nexport {\n renderInstanceMethodSignature,\n renderClassInstanceMember,\n instanceMemberSpec,\n instanceScope,\n dedupeCallables,\n generateBindings,\n matchStaticFinishFunction,\n indexMethodsByName,\n isEmittableCallable,\n renderStaticSignature,\n constructorMemberNames,\n renderStaticHead,\n renderPlainTypeMembers,\n staticMembers,\n type Callables,\n type InstanceMemberRenderer,\n type InstanceScope,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../../src/store/gi/callback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../../src/store/gi/callback.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAK7E,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,UAAU,WAAW,KAAG,IAezE,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import { sanitizeTypeIdentifier } from "@gtkx/utils";
|
|
1
2
|
import { callbackAsFunction } from "../../gir/callback.js";
|
|
3
|
+
import { isEmittableEntity } from "../../gir/emittable.js";
|
|
2
4
|
import { callableDoc } from "./callable-doc.js";
|
|
3
5
|
import { renderMethodReturnType, renderMethodSignature } from "./method.js";
|
|
4
6
|
const generateCallback = (context, callback) => {
|
|
5
|
-
if (!callback
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (callback.name.length === 0) {
|
|
7
|
+
if (!isEmittableEntity(callback)) {
|
|
9
8
|
return;
|
|
10
9
|
}
|
|
11
10
|
const fn = callbackAsFunction(callback);
|
|
12
11
|
const signature = renderMethodSignature(context, fn);
|
|
13
12
|
const returnType = renderMethodReturnType(context, fn);
|
|
14
|
-
|
|
13
|
+
const name = sanitizeTypeIdentifier(callback.name);
|
|
14
|
+
context.declare({
|
|
15
|
+
name,
|
|
16
|
+
code: `${callableDoc(context, fn)}export type ${name} = (${signature}) => ${returnType};`,
|
|
17
|
+
owner: callback.name,
|
|
18
|
+
});
|
|
15
19
|
};
|
|
16
20
|
export { generateCallback };
|
|
17
21
|
//# sourceMappingURL=callback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback.js","sourceRoot":"","sources":["../../../src/store/gi/callback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"callback.js","sourceRoot":"","sources":["../../../src/store/gi/callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAoB,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E,MAAM,gBAAgB,GAAG,CAAC,OAAsB,EAAE,QAAqB,EAAQ,EAAE;IAC7E,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,OAAO;IACX,CAAC;IAED,MAAM,EAAE,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,qBAAqB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,sBAAsB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEnD,OAAO,CAAC,OAAO,CAAC;QACZ,IAAI;QACJ,IAAI,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,IAAI,OAAO,SAAS,QAAQ,UAAU,GAAG;QACzF,KAAK,EAAE,QAAQ,CAAC,IAAI;KACvB,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { sanitizeTypeIdentifier } from \"@gtkx/utils\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport { callbackAsFunction, type GirCallback } from \"../../gir/callback.js\";\nimport { isEmittableEntity } from \"../../gir/emittable.js\";\nimport { callableDoc } from \"./callable-doc.js\";\nimport { renderMethodReturnType, renderMethodSignature } from \"./method.js\";\n\nconst generateCallback = (context: ModuleContext, callback: GirCallback): void => {\n if (!isEmittableEntity(callback)) {\n return;\n }\n\n const fn = callbackAsFunction(callback);\n const signature = renderMethodSignature(context, fn);\n const returnType = renderMethodReturnType(context, fn);\n const name = sanitizeTypeIdentifier(callback.name);\n\n context.declare({\n name,\n code: `${callableDoc(context, fn)}export type ${name} = (${signature}) => ${returnType};`,\n owner: callback.name,\n });\n};\n\nexport { generateCallback };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../../src/store/gi/class.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../../src/store/gi/class.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA2E7D,QAAA,MAAM,aAAa,GAAI,SAAS,aAAa,EAAE,OAAO,QAAQ,KAAG,IAsChE,CAAC;AA2PF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|