@gtkx/codegen 1.0.0-rc.3 → 1.0.0-rc.4
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 +4 -5
- package/dist/analysis/descriptor-render.d.ts +1 -3
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +14 -37
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +6 -6
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +7 -7
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +2 -2
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js +5 -7
- 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 +3 -5
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +2 -1
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +77 -1
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +62 -0
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/pipeline.d.ts +4 -4
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +4 -4
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/docs/render.js +6 -6
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/symbol-page.d.ts +5 -0
- package/dist/docs/symbol-page.d.ts.map +1 -1
- package/dist/docs/symbol-page.js +2 -2
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +2 -5
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +6 -8
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +3 -11
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +0 -7
- package/dist/gi.js.map +1 -1
- package/dist/gir/field.d.ts +0 -1
- package/dist/gir/field.d.ts.map +1 -1
- package/dist/gir/field.js +0 -3
- package/dist/gir/field.js.map +1 -1
- package/dist/gir/gir-path.d.ts +7 -0
- package/dist/gir/gir-path.d.ts.map +1 -1
- package/dist/gir/gir-path.js +7 -0
- package/dist/gir/gir-path.js.map +1 -1
- package/dist/gir/libraries.d.ts +13 -0
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +12 -0
- package/dist/gir/libraries.js.map +1 -1
- package/dist/gir/parameter.d.ts.map +1 -1
- package/dist/gir/parameter.js +0 -4
- package/dist/gir/parameter.js.map +1 -1
- package/dist/gir/size.d.ts.map +1 -1
- package/dist/gir/size.js +0 -3
- package/dist/gir/size.js.map +1 -1
- package/dist/gir/type-id.d.ts +1 -1
- package/dist/gir/type-id.d.ts.map +1 -1
- package/dist/gir/type-id.js +1 -3
- package/dist/gir/type-id.js.map +1 -1
- package/dist/gir/type-ref.js +1 -1
- package/dist/gir/type-ref.js.map +1 -1
- package/dist/index.d.ts +18 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/dist/jsx.d.ts +7 -12
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +18 -19
- package/dist/jsx.js.map +1 -1
- package/dist/khronos/args.d.ts.map +1 -1
- package/dist/khronos/args.js +1 -1
- package/dist/khronos/args.js.map +1 -1
- package/dist/khronos/pipeline.js +1 -1
- package/dist/khronos/pipeline.js.map +1 -1
- package/dist/khronos/plan.d.ts +2 -2
- package/dist/khronos/plan.d.ts.map +1 -1
- package/dist/khronos/plan.js +6 -6
- package/dist/khronos/plan.js.map +1 -1
- package/dist/react/element-config.d.ts +17 -11
- package/dist/react/element-config.d.ts.map +1 -1
- package/dist/react/element-config.js +22 -15
- package/dist/react/element-config.js.map +1 -1
- package/dist/runner.d.ts +35 -17
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +19 -20
- package/dist/runner.js.map +1 -1
- package/dist/store/compile-store.d.ts +1 -2
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +2 -2
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/callables.js +4 -4
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/constant.d.ts.map +1 -1
- package/dist/store/gi/constant.js +0 -2
- package/dist/store/gi/constant.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +1 -5
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +25 -23
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/property-accessor.d.ts +1 -1
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +5 -7
- package/dist/store/gi/property-accessor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +1 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +3 -9
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +0 -4
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/return-wrap.d.ts +1 -1
- package/dist/store/gi/return-wrap.d.ts.map +1 -1
- package/dist/store/gi/return-wrap.js +4 -4
- package/dist/store/gi/return-wrap.js.map +1 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +13 -16
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts +0 -8
- package/dist/store/gi/value-marshalable.d.ts.map +1 -1
- package/dist/store/gi/value-marshalable.js +0 -9
- package/dist/store/gi/value-marshalable.js.map +1 -1
- package/dist/store/gi-store.d.ts +2 -3
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/element-components.d.ts +0 -2
- package/dist/store/jsx/element-components.d.ts.map +1 -1
- package/dist/store/jsx/element-components.js +0 -4
- package/dist/store/jsx/element-components.js.map +1 -1
- package/dist/store/jsx/element-prop-imports.d.ts +2 -3
- package/dist/store/jsx/element-prop-imports.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-imports.js +0 -2
- package/dist/store/jsx/element-prop-imports.js.map +1 -1
- package/dist/store/jsx/element-prop-types.d.ts +0 -1
- package/dist/store/jsx/element-prop-types.d.ts.map +1 -1
- package/dist/store/jsx/element-prop-types.js +0 -1
- package/dist/store/jsx/element-prop-types.js.map +1 -1
- package/dist/store/jsx/generated-elements.d.ts +29 -0
- package/dist/store/jsx/generated-elements.d.ts.map +1 -0
- package/dist/store/jsx/generated-elements.js +30 -0
- package/dist/store/jsx/generated-elements.js.map +1 -0
- package/dist/store/jsx/jsx.js +6 -6
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.js +7 -7
- package/dist/store/jsx/metadata.js.map +1 -1
- package/dist/store/jsx/omitted-props.d.ts +2 -4
- package/dist/store/jsx/omitted-props.d.ts.map +1 -1
- package/dist/store/jsx/omitted-props.js +2 -4
- package/dist/store/jsx/omitted-props.js.map +1 -1
- package/dist/store/jsx/pipeline.d.ts +3 -1
- package/dist/store/jsx/pipeline.d.ts.map +1 -1
- package/dist/store/jsx/pipeline.js +3 -2
- package/dist/store/jsx/pipeline.js.map +1 -1
- package/dist/store/jsx/props.js +2 -2
- package/dist/store/jsx/props.js.map +1 -1
- package/dist/store/jsx-store.d.ts +2 -3
- 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 +28 -0
- package/dist/store/resolve-store.d.ts.map +1 -0
- package/dist/store/resolve-store.js +65 -0
- package/dist/store/resolve-store.js.map +1 -0
- package/dist/store/store-fs.d.ts +5 -1
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +6 -4
- package/dist/store/store-fs.js.map +1 -1
- package/overrides/gobject/object.ts.ejs +8 -8
- package/package.json +6 -10
- package/src/analysis/descriptor-render.ts +20 -45
- package/src/analysis/descriptor.ts +13 -13
- package/src/analysis/param-structure.ts +8 -10
- package/src/analysis/ts-type.ts +4 -6
- package/src/compile.ts +2 -1
- package/src/docs/api-reference.ts +127 -4
- package/src/docs/pipeline.ts +8 -8
- package/src/docs/render.ts +7 -7
- package/src/docs/symbol-page.ts +7 -2
- package/src/fingerprint.ts +8 -13
- package/src/gi.ts +4 -11
- package/src/gir/field.ts +0 -4
- package/src/gir/gir-path.ts +7 -0
- package/src/gir/libraries.ts +13 -0
- package/src/gir/parameter.ts +0 -4
- package/src/gir/size.ts +0 -3
- package/src/gir/type-id.ts +2 -4
- package/src/gir/type-ref.ts +1 -1
- package/src/index.ts +18 -16
- package/src/internal.ts +2 -0
- package/src/jsx.ts +26 -26
- package/src/khronos/args.ts +1 -1
- package/src/khronos/pipeline.ts +1 -1
- package/src/khronos/plan.ts +8 -8
- package/src/react/element-config.ts +22 -19
- package/src/runner.ts +57 -39
- package/src/store/compile-store.ts +3 -4
- package/src/store/gi/callables.ts +5 -5
- package/src/store/gi/constant.ts +0 -2
- package/src/store/gi/function.ts +1 -5
- package/src/store/gi/method.ts +30 -28
- package/src/store/gi/property-accessor.ts +6 -8
- package/src/store/gi/record-field-accessor.ts +4 -10
- package/src/store/gi/record-layout.ts +0 -4
- package/src/store/gi/return-wrap.ts +5 -5
- package/src/store/gi/signal.ts +17 -17
- package/src/store/gi/value-marshalable.ts +0 -9
- package/src/store/gi-store.ts +2 -4
- package/src/store/jsx/element-components.ts +0 -6
- package/src/store/jsx/element-prop-imports.ts +7 -4
- package/src/store/jsx/element-prop-types.ts +0 -1
- package/src/store/jsx/generated-elements.ts +60 -0
- package/src/store/jsx/jsx.ts +7 -7
- package/src/store/jsx/metadata.ts +8 -8
- package/src/store/jsx/omitted-props.ts +2 -4
- package/src/store/jsx/pipeline.ts +5 -3
- package/src/store/jsx/props.ts +2 -2
- package/src/store/jsx-store.ts +5 -7
- package/src/store/resolve-store.ts +100 -0
- package/src/store/store-fs.ts +12 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Library } from "../../gir/library.js";
|
|
2
2
|
import { type ElementComponentOverrides } from "./element-components.js";
|
|
3
3
|
import { type ElementProps } from "./element-prop-imports.js";
|
|
4
|
+
import { type GeneratedElement } from "./generated-elements.js";
|
|
4
5
|
import { type OmittedProps } from "./omitted-props.js";
|
|
5
6
|
type JsxNamespaceFile = {
|
|
6
7
|
directory: string;
|
|
@@ -10,12 +11,13 @@ type JsxFiles = {
|
|
|
10
11
|
namespaces: JsxNamespaceFile[];
|
|
11
12
|
metadata: string;
|
|
12
13
|
intrinsicElementCount: number;
|
|
14
|
+
elements: GeneratedElement[];
|
|
13
15
|
};
|
|
14
16
|
type JsxGenerationOptions = {
|
|
15
17
|
reactSubexports?: string[];
|
|
16
18
|
components?: ElementComponentOverrides;
|
|
17
19
|
props?: ElementProps;
|
|
18
|
-
|
|
20
|
+
omittedProps?: OmittedProps;
|
|
19
21
|
lazyElements?: string[];
|
|
20
22
|
};
|
|
21
23
|
declare const generateJsxFiles: (library: Library, options?: JsxGenerationOptions) => JsxFiles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/store/jsx/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,KAAK,yBAAyB,EAAoC,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/store/jsx/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,KAAK,yBAAyB,EAAoC,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK1F,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AAExE,KAAK,gBAAgB,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,QAAQ,GAAG;IACZ,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAChC,CAAC;AAEF,KAAK,oBAAoB,GAAG;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,yBAAyB,CAAC;IACvC,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAmBF,QAAA,MAAM,gBAAgB,GAAI,SAAS,OAAO,EAAE,UAAS,oBAAyB,KAAG,QAoBhF,CAAC;AA8EF,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { ImportsBuilder } from "../../writer/imports.js";
|
|
|
4
4
|
import { generateElementComponentsSection } from "./element-components.js";
|
|
5
5
|
import { setElementProps } from "./element-prop-imports.js";
|
|
6
6
|
import { lazyElementSpecs } from "./element-prop-types.js";
|
|
7
|
+
import { collectGeneratedElements } from "./generated-elements.js";
|
|
7
8
|
import { buildGirIndex } from "./gir-index.js";
|
|
8
9
|
import { collectIntrinsicElementClasses } from "./intrinsic-elements.js";
|
|
9
10
|
import { generateJsxSection } from "./jsx.js";
|
|
@@ -11,7 +12,7 @@ import { generateMetadata } from "./metadata.js";
|
|
|
11
12
|
import { setOmittedProps } from "./omitted-props.js";
|
|
12
13
|
const generateJsxFiles = (library, options = {}) => {
|
|
13
14
|
setElementProps(options.props ?? {});
|
|
14
|
-
setOmittedProps(options.
|
|
15
|
+
setOmittedProps(options.omittedProps ?? {});
|
|
15
16
|
const intrinsicElements = collectIntrinsicElementClasses(library);
|
|
16
17
|
const intrinsicElementByGlibName = new Map(intrinsicElements.map((entry) => [entry.glibName, entry]));
|
|
17
18
|
const girIndex = buildGirIndex(library);
|
|
@@ -25,7 +26,7 @@ const generateJsxFiles = (library, options = {}) => {
|
|
|
25
26
|
components: options.components ?? {},
|
|
26
27
|
});
|
|
27
28
|
const metadata = generateMetadata(library);
|
|
28
|
-
return { namespaces, metadata, intrinsicElementCount };
|
|
29
|
+
return { namespaces, metadata, intrinsicElementCount, elements: collectGeneratedElements(intrinsicElements) };
|
|
29
30
|
};
|
|
30
31
|
const orderedIntrinsicNamespaces = (intrinsicElements) => {
|
|
31
32
|
const namespacesWithIntrinsicElements = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/store/jsx/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAqB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAkC,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAqB,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAwB,gBAAgB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Ae,EAAE,OAAO,EAAE;QACjF,OAAO;QACP,YAAY;QACZ,iBAAiB;QACjB,UAAU;KACb,CAAC,CAAC;IAEH,MAAM,YAAY,GAAgB,IAAI,GAAG,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAE3E,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;QACxF,YAAY;QACZ,OAAO;QACP,iBAAiB;QACjB,0BAA0B;KAC7B,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;IAE5D,IAAI,iBAAiB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC,aAAa,CAAC,IAAI,GAAG,cAAc,CAAC;IAEpE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACrD,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAoD,CAAC","sourcesContent":["import { sortStringsBy } from \"@gtkx/utils\";\nimport type { Library } from \"../../gir/library.js\";\nimport { type GirNamespace, namespaceDirectory } from \"../../gir/namespace.js\";\nimport { ImportsBuilder } from \"../../writer/imports.js\";\nimport { type ElementComponentOverrides, generateElementComponentsSection } from \"./element-components.js\";\nimport { type ElementProps, setElementProps } from \"./element-prop-imports.js\";\nimport { type LazyElementSpec, lazyElementSpecs } from \"./element-prop-types.js\";\nimport { collectGeneratedElements, type GeneratedElement } from \"./generated-elements.js\";\nimport { buildGirIndex } from \"./gir-index.js\";\nimport { collectIntrinsicElementClasses, type GlibNamedClass } from \"./intrinsic-elements.js\";\nimport { generateJsxSection } from \"./jsx.js\";\nimport { generateMetadata } from \"./metadata.js\";\nimport { type OmittedProps, setOmittedProps } from \"./omitted-props.js\";\n\ntype JsxNamespaceFile = {\n directory: string;\n source: string;\n};\n\ntype JsxFiles = {\n namespaces: JsxNamespaceFile[];\n metadata: string;\n intrinsicElementCount: number;\n elements: GeneratedElement[];\n};\n\ntype JsxGenerationOptions = {\n reactSubexports?: string[];\n components?: ElementComponentOverrides;\n props?: ElementProps;\n omittedProps?: OmittedProps;\n lazyElements?: string[];\n};\n\ntype NamespaceFilesOptions = {\n library: Library;\n intrinsicElements: GlibNamedClass[];\n intrinsicElementByGlibName: Map<string, GlibNamedClass>;\n lazyByNamespace: Map<string, LazyElementSpec[]>;\n reactSubexports: string[];\n components: ElementComponentOverrides;\n};\n\ntype JsxNamespaceContext = {\n lazyElements: LazyElementSpec[];\n intrinsicElements: GlibNamedClass[];\n intrinsicElementByGlibName: Map<string, GlibNamedClass>;\n reactSubexports: string[];\n components: ElementComponentOverrides;\n};\n\nconst generateJsxFiles = (library: Library, options: JsxGenerationOptions = {}): JsxFiles => {\n setElementProps(options.props ?? {});\n setOmittedProps(options.omittedProps ?? {});\n const intrinsicElements = collectIntrinsicElementClasses(library);\n const intrinsicElementByGlibName = new Map(intrinsicElements.map((entry) => [entry.glibName, entry]));\n const girIndex = buildGirIndex(library);\n const lazyByNamespace = lazyElementSpecs(girIndex, options.lazyElements ?? []);\n\n const { namespaces, intrinsicElementCount } = generateNamespaceFiles({\n library,\n intrinsicElements,\n intrinsicElementByGlibName,\n lazyByNamespace,\n reactSubexports: options.reactSubexports ?? [],\n components: options.components ?? {},\n });\n\n const metadata = generateMetadata(library);\n\n return { namespaces, metadata, intrinsicElementCount, elements: collectGeneratedElements(intrinsicElements) };\n};\n\nconst orderedIntrinsicNamespaces = (intrinsicElements: GlibNamedClass[]): GirNamespace[] => {\n const namespacesWithIntrinsicElements: Map<string, GirNamespace> = new Map();\n\n for (const entry of intrinsicElements) {\n namespacesWithIntrinsicElements.set(entry.namespace.name, entry.namespace);\n }\n\n return sortStringsBy(namespacesWithIntrinsicElements.values(), (entry) => entry.name);\n};\n\nconst generateNamespaceFiles = (\n options: NamespaceFilesOptions,\n): { namespaces: JsxNamespaceFile[]; intrinsicElementCount: number } => {\n const { library, intrinsicElements, intrinsicElementByGlibName, lazyByNamespace, reactSubexports, components } =\n options;\n\n const namespaces: JsxNamespaceFile[] = [];\n let intrinsicElementCount = 0;\n\n for (const namespace of orderedIntrinsicNamespaces(intrinsicElements)) {\n const { source, count } = generateJsxNamespace(namespace, library, {\n lazyElements: lazyByNamespace.get(namespace.name) ?? [],\n intrinsicElements,\n intrinsicElementByGlibName,\n reactSubexports,\n components,\n });\n\n namespaces.push({ directory: namespaceDirectory(namespace), source });\n intrinsicElementCount += count;\n }\n\n return { namespaces, intrinsicElementCount };\n};\n\nconst generateJsxNamespace = (\n targetNamespace: GirNamespace,\n library: Library,\n context: JsxNamespaceContext,\n): { source: string; count: number } => {\n const { lazyElements, intrinsicElements, intrinsicElementByGlibName, reactSubexports, components } = context;\n const targetDirectory = namespaceDirectory(targetNamespace);\n const imports = new ImportsBuilder();\n imports.addSideEffect(`@gtkx/gi/${targetDirectory}`);\n\n if (reactSubexports.includes(targetDirectory)) {\n imports.addSideEffect(`@gtkx/react/${targetDirectory}`);\n }\n\n const elementComponents = generateElementComponentsSection(targetNamespace, library, {\n imports,\n lazyElements,\n intrinsicElements,\n components,\n });\n\n const excludeNames: Set<string> = new Set(elementComponents.exportedNames);\n\n const { source: jsxSection, intrinsicCount } = generateJsxSection(targetNamespace, library, {\n excludeNames,\n imports,\n intrinsicElements,\n intrinsicElementByGlibName,\n });\n\n const body = [imports.toSource().trimEnd(), \"\", jsxSection];\n\n if (elementComponents.source.length > 0) {\n body.push(\"\", elementComponents.source);\n }\n\n const count = elementComponents.exportedNames.size + intrinsicCount;\n\n return { source: `${body.join(\"\\n\")}\\n`, count };\n};\n\nexport { generateJsxFiles, type JsxNamespaceFile, type JsxGenerationOptions };\n"]}
|
package/dist/store/jsx/props.js
CHANGED
|
@@ -133,8 +133,8 @@ const renderSignalHandler = (options) => {
|
|
|
133
133
|
library: types.library,
|
|
134
134
|
signal,
|
|
135
135
|
renderType: (ref, nullable) => renderReactPropType(types, ref, nullable),
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
shouldIncludeCallerAllocated: false,
|
|
137
|
+
isOptOut: true,
|
|
138
138
|
});
|
|
139
139
|
return `(${params.join(", ")}) => ${result}`;
|
|
140
140
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/store/jsx/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAqB,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAoB,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACpH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAyDnD,MAAM,mBAAmB,GAAG,CAAC,KAAyB,EAAE,QAAqB,EAAE,MAAc,EAAQ,EAAE;IACnG,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtE,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEtC,IAAI,YAAY,CAAC,KAAK,CAAC,KAA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E,CAAC;AACtE,CAAC,EACD,GAAG,EAAE;IACD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5D,OAAO,GAAG,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC;AACjD,CAAC,CACJ,CAAC;AAEN,MAAM,mBAAmB,GAAG,CAAC,OAA8B,EAAE,GAAuB,EAAE,UAAmB,EAAU,EAAE;IACjH,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IAExE,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { toCamelIdentifier, upperFirst } from \"@gtkx/utils\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { Library } from \"../../gir/library.js\";\nimport type { GirNamespace } from \"../../gir/namespace.js\";\nimport type { GirCallable } from \"../../gir/parameter.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport { forEachAncestor } from \"../../analysis/inheritance.js\";\nimport { renderHandlerParameters, renderHandlerResultType } from \"../../analysis/param-structure.js\";\nimport { recordTypeTarget, renderBaseType, type TsTypeTarget } from \"../../analysis/ts-type.js\";\nimport { type GirProperty, isConstructableProperty } from \"../../gir/property.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { getGlibName, giNamespaceAlias, isIntrinsicElementClass, signalHandlerName } from \"./intrinsic-elements.js\";\nimport { isOmittedProp } from \"./omitted-props.js\";\n\ntype IntrinsicElementPropsEntries = {\n propLines: string[];\n imports: Map<string, string>;\n objectPropNames: string[];\n};\n\ntype IntrinsicElementScope = {\n library: Library;\n klass: GirClass;\n namespace: GirNamespace;\n};\n\ntype IntrinsicElementPropsOptions = IntrinsicElementScope & {\n isIntrinsicElementAncestor?: (candidate: GirClass) => boolean;\n};\n\ntype PropTypeRenderContext = {\n library: Library;\n imports: Map<string, string>;\n};\n\ntype SignalRenderOptions = {\n types: PropTypeRenderContext;\n signal: GirCallable;\n selfType: string;\n};\n\ntype PropEntryCollector = {\n propLines: string[];\n imports: Map<string, string>;\n objectPropNames: string[];\n acceptProperty: (property: GirProperty) => void;\n acceptSignal: (signal: GirCallable) => void;\n};\n\ntype PropCollectorState = {\n owner: IntrinsicElementScope;\n types: PropTypeRenderContext;\n propLines: string[];\n objectPropNames: string[];\n seen: Set<string>;\n};\n\ntype InterfacePropsOptions = {\n library: Library;\n iface: GirClass;\n namespace: GirNamespace;\n};\n\ntype IntrinsicElementMemberWalk = IntrinsicElementScope & {\n isIntrinsicElementAncestor: (candidate: GirClass) => boolean;\n acceptProperty: (property: GirProperty) => void;\n acceptSignal: (signal: GirCallable) => void;\n};\n\nconst appendPropertyLines = (state: PropCollectorState, property: GirProperty, jsName: string): void => {\n const tsType = renderReactPropType(state.types, property.type, false);\n const doc = renderJsDoc(property.doc);\n\n if (isObjectProp(state.owner.library, property)) {\n state.propLines.push(`${doc}${jsName}?: ${tsType} | ReactElement | null | undefined;`);\n state.objectPropNames.push(jsName);\n\n return;\n }\n\n const isSettable = isConstructableProperty(property);\n\n if (isSettable) {\n state.propLines.push(`${doc}${jsName}?: ${tsType} | null | undefined;`);\n }\n\n const handlerType = `((value: ${tsType} | null, self: Self) => void) | null | undefined`;\n state.propLines.push(`${isSettable ? \"\" : doc}onNotify${upperFirst(jsName)}?: ${handlerType};`);\n};\n\nconst acceptCollectorProperty = (state: PropCollectorState, property: GirProperty): void => {\n if (!property.introspectable) {\n return;\n }\n\n const jsName = toCamelIdentifier(property.name);\n\n if (state.seen.has(jsName) || isOmittedProp(getGlibName(state.owner.klass), jsName)) {\n return;\n }\n\n state.seen.add(jsName);\n appendPropertyLines(state, property, jsName);\n};\n\nconst acceptCollectorSignal = (state: PropCollectorState, signal: GirCallable): void => {\n const handlerName = signalHandlerName(signal.name);\n\n if (state.seen.has(handlerName)) {\n return;\n }\n\n state.seen.add(handlerName);\n const signature = renderSignalHandler({ types: state.types, signal, selfType: \"Self\" });\n state.propLines.push(`${renderJsDoc(signal.doc)}${handlerName}?: (${signature}) | undefined;`);\n};\n\nconst createPropEntryCollector = (owner: IntrinsicElementScope): PropEntryCollector => {\n const { library } = owner;\n const imports: Map<string, string> = new Map();\n const types: PropTypeRenderContext = { library, imports };\n\n const state: PropCollectorState = {\n owner,\n types,\n propLines: [],\n objectPropNames: [],\n seen: new Set<string>(),\n };\n\n return {\n propLines: state.propLines,\n imports,\n objectPropNames: state.objectPropNames,\n acceptProperty: (property) => {\n acceptCollectorProperty(state, property);\n },\n acceptSignal: (signal) => {\n acceptCollectorSignal(state, signal);\n },\n };\n};\n\nconst buildElementPropsEntries = (options: IntrinsicElementPropsOptions): IntrinsicElementPropsEntries => {\n const { library, klass, namespace, isIntrinsicElementAncestor = () => false } = options;\n const collector = createPropEntryCollector({ library, klass, namespace });\n\n walkIntrinsicElementMembers({\n library,\n klass,\n namespace,\n isIntrinsicElementAncestor,\n acceptProperty: collector.acceptProperty,\n acceptSignal: collector.acceptSignal,\n });\n\n return { propLines: collector.propLines, imports: collector.imports, objectPropNames: collector.objectPropNames };\n};\n\nconst buildInterfacePropsEntries = (options: InterfacePropsOptions): IntrinsicElementPropsEntries => {\n const { library, iface, namespace } = options;\n const collector = createPropEntryCollector({ library, klass: iface, namespace });\n\n for (const property of iface.properties) {\n collector.acceptProperty(property);\n }\n\n for (const signal of iface.signals) {\n collector.acceptSignal(signal);\n }\n\n return { propLines: collector.propLines, imports: collector.imports, objectPropNames: collector.objectPropNames };\n};\n\nconst walkIntrinsicElementMembers = (walk: IntrinsicElementMemberWalk): void => {\n const { library, klass, namespace, isIntrinsicElementAncestor, acceptProperty, acceptSignal } = walk;\n\n const visitMembers = (memberClass: GirClass): void => {\n for (const property of memberClass.properties) {\n acceptProperty(property);\n }\n\n for (const signal of memberClass.signals) {\n acceptSignal(signal);\n }\n };\n\n const ancestry = { library, namespace };\n visitMembers(klass);\n\n forEachAncestor(ancestry, klass, (ancestor) => {\n visitMembers(ancestor.klass);\n }, isIntrinsicElementAncestor);\n};\n\nconst isGObjectType = (library: Library, ref: TypeId | undefined): boolean => {\n if (ref === undefined) {\n return false;\n }\n\n const resolved = library.typeFor(ref);\n\n if (resolved?.kind === \"interface\") {\n return true;\n }\n\n if (resolved?.kind !== \"class\") {\n return false;\n }\n\n return isIntrinsicElementClass(resolved.value, resolved.namespace, library);\n};\n\nconst isObjectProp = (library: Library, property: GirProperty): boolean => {\n if (!property.writable || property.constructOnly) {\n return false;\n }\n\n return isGObjectType(library, property.type);\n};\n\nconst renderSignalHandler = (options: SignalRenderOptions): string => {\n const { types, signal, selfType } = options;\n\n const params = [\n ...renderHandlerParameters(signal.parameters, (ref, nullable) => renderReactPropType(types, ref, nullable)),\n `self: ${selfType}`,\n ];\n\n const result = renderHandlerResultType({\n library: types.library,\n signal,\n renderType: (ref, nullable) => renderReactPropType(types, ref, nullable),\n includeCallerAllocated: false,\n optOut: true,\n });\n\n return `(${params.join(\", \")}) => ${result}`;\n};\n\nconst reactTarget = (context: PropTypeRenderContext): TsTypeTarget =>\n recordTypeTarget(\n context.library,\n (name) => {\n context.imports.set(name.namespaceName, giNamespaceAlias(name.namespaceName));\n\n return `${giNamespaceAlias(name.namespaceName)}.${name.typeName}`;\n },\n () => {\n context.imports.set(\"GObject\", giNamespaceAlias(\"GObject\"));\n\n return `${giNamespaceAlias(\"GObject\")}.Type`;\n },\n );\n\nconst renderReactPropType = (context: PropTypeRenderContext, ref: TypeId | undefined, isNullable: boolean): string => {\n const base = renderBaseType(context.library, reactTarget(context), ref);\n\n return isNullable ? `${base} | null` : base;\n};\n\nexport { buildElementPropsEntries, buildInterfacePropsEntries, isObjectProp, reactTarget };\n"]}
|
|
1
|
+
{"version":3,"file":"props.js","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,CAAC;IAExE,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import { toCamelIdentifier, upperFirst } from \"@gtkx/utils\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { Library } from \"../../gir/library.js\";\nimport type { GirNamespace } from \"../../gir/namespace.js\";\nimport type { GirCallable } from \"../../gir/parameter.js\";\nimport type { TypeId } from \"../../gir/type-id.js\";\nimport { forEachAncestor } from \"../../analysis/inheritance.js\";\nimport { renderHandlerParameters, renderHandlerResultType } from \"../../analysis/param-structure.js\";\nimport { recordTypeTarget, renderBaseType, type TsTypeTarget } from \"../../analysis/ts-type.js\";\nimport { type GirProperty, isConstructableProperty } from \"../../gir/property.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { getGlibName, giNamespaceAlias, isIntrinsicElementClass, signalHandlerName } from \"./intrinsic-elements.js\";\nimport { isOmittedProp } from \"./omitted-props.js\";\n\ntype IntrinsicElementPropsEntries = {\n propLines: string[];\n imports: Map<string, string>;\n objectPropNames: string[];\n};\n\ntype IntrinsicElementScope = {\n library: Library;\n klass: GirClass;\n namespace: GirNamespace;\n};\n\ntype IntrinsicElementPropsOptions = IntrinsicElementScope & {\n isIntrinsicElementAncestor?: (candidate: GirClass) => boolean;\n};\n\ntype PropTypeRenderContext = {\n library: Library;\n imports: Map<string, string>;\n};\n\ntype SignalRenderOptions = {\n types: PropTypeRenderContext;\n signal: GirCallable;\n selfType: string;\n};\n\ntype PropEntryCollector = {\n propLines: string[];\n imports: Map<string, string>;\n objectPropNames: string[];\n acceptProperty: (property: GirProperty) => void;\n acceptSignal: (signal: GirCallable) => void;\n};\n\ntype PropCollectorState = {\n owner: IntrinsicElementScope;\n types: PropTypeRenderContext;\n propLines: string[];\n objectPropNames: string[];\n seen: Set<string>;\n};\n\ntype InterfacePropsOptions = {\n library: Library;\n iface: GirClass;\n namespace: GirNamespace;\n};\n\ntype IntrinsicElementMemberWalk = IntrinsicElementScope & {\n isIntrinsicElementAncestor: (candidate: GirClass) => boolean;\n acceptProperty: (property: GirProperty) => void;\n acceptSignal: (signal: GirCallable) => void;\n};\n\nconst appendPropertyLines = (state: PropCollectorState, property: GirProperty, jsName: string): void => {\n const tsType = renderReactPropType(state.types, property.type, false);\n const doc = renderJsDoc(property.doc);\n\n if (isObjectProp(state.owner.library, property)) {\n state.propLines.push(`${doc}${jsName}?: ${tsType} | ReactElement | null | undefined;`);\n state.objectPropNames.push(jsName);\n\n return;\n }\n\n const isSettable = isConstructableProperty(property);\n\n if (isSettable) {\n state.propLines.push(`${doc}${jsName}?: ${tsType} | null | undefined;`);\n }\n\n const handlerType = `((value: ${tsType} | null, self: Self) => void) | null | undefined`;\n state.propLines.push(`${isSettable ? \"\" : doc}onNotify${upperFirst(jsName)}?: ${handlerType};`);\n};\n\nconst acceptCollectorProperty = (state: PropCollectorState, property: GirProperty): void => {\n if (!property.introspectable) {\n return;\n }\n\n const jsName = toCamelIdentifier(property.name);\n\n if (state.seen.has(jsName) || isOmittedProp(getGlibName(state.owner.klass), jsName)) {\n return;\n }\n\n state.seen.add(jsName);\n appendPropertyLines(state, property, jsName);\n};\n\nconst acceptCollectorSignal = (state: PropCollectorState, signal: GirCallable): void => {\n const handlerName = signalHandlerName(signal.name);\n\n if (state.seen.has(handlerName)) {\n return;\n }\n\n state.seen.add(handlerName);\n const signature = renderSignalHandler({ types: state.types, signal, selfType: \"Self\" });\n state.propLines.push(`${renderJsDoc(signal.doc)}${handlerName}?: (${signature}) | undefined;`);\n};\n\nconst createPropEntryCollector = (owner: IntrinsicElementScope): PropEntryCollector => {\n const { library } = owner;\n const imports: Map<string, string> = new Map();\n const types: PropTypeRenderContext = { library, imports };\n\n const state: PropCollectorState = {\n owner,\n types,\n propLines: [],\n objectPropNames: [],\n seen: new Set<string>(),\n };\n\n return {\n propLines: state.propLines,\n imports,\n objectPropNames: state.objectPropNames,\n acceptProperty: (property) => {\n acceptCollectorProperty(state, property);\n },\n acceptSignal: (signal) => {\n acceptCollectorSignal(state, signal);\n },\n };\n};\n\nconst buildElementPropsEntries = (options: IntrinsicElementPropsOptions): IntrinsicElementPropsEntries => {\n const { library, klass, namespace, isIntrinsicElementAncestor = () => false } = options;\n const collector = createPropEntryCollector({ library, klass, namespace });\n\n walkIntrinsicElementMembers({\n library,\n klass,\n namespace,\n isIntrinsicElementAncestor,\n acceptProperty: collector.acceptProperty,\n acceptSignal: collector.acceptSignal,\n });\n\n return { propLines: collector.propLines, imports: collector.imports, objectPropNames: collector.objectPropNames };\n};\n\nconst buildInterfacePropsEntries = (options: InterfacePropsOptions): IntrinsicElementPropsEntries => {\n const { library, iface, namespace } = options;\n const collector = createPropEntryCollector({ library, klass: iface, namespace });\n\n for (const property of iface.properties) {\n collector.acceptProperty(property);\n }\n\n for (const signal of iface.signals) {\n collector.acceptSignal(signal);\n }\n\n return { propLines: collector.propLines, imports: collector.imports, objectPropNames: collector.objectPropNames };\n};\n\nconst walkIntrinsicElementMembers = (walk: IntrinsicElementMemberWalk): void => {\n const { library, klass, namespace, isIntrinsicElementAncestor, acceptProperty, acceptSignal } = walk;\n\n const visitMembers = (memberClass: GirClass): void => {\n for (const property of memberClass.properties) {\n acceptProperty(property);\n }\n\n for (const signal of memberClass.signals) {\n acceptSignal(signal);\n }\n };\n\n const ancestry = { library, namespace };\n visitMembers(klass);\n\n forEachAncestor(ancestry, klass, (ancestor) => {\n visitMembers(ancestor.klass);\n }, isIntrinsicElementAncestor);\n};\n\nconst isGObjectType = (library: Library, ref: TypeId | undefined): boolean => {\n if (ref === undefined) {\n return false;\n }\n\n const resolved = library.typeFor(ref);\n\n if (resolved?.kind === \"interface\") {\n return true;\n }\n\n if (resolved?.kind !== \"class\") {\n return false;\n }\n\n return isIntrinsicElementClass(resolved.value, resolved.namespace, library);\n};\n\nconst isObjectProp = (library: Library, property: GirProperty): boolean => {\n if (!property.writable || property.constructOnly) {\n return false;\n }\n\n return isGObjectType(library, property.type);\n};\n\nconst renderSignalHandler = (options: SignalRenderOptions): string => {\n const { types, signal, selfType } = options;\n\n const params = [\n ...renderHandlerParameters(signal.parameters, (ref, nullable) => renderReactPropType(types, ref, nullable)),\n `self: ${selfType}`,\n ];\n\n const result = renderHandlerResultType({\n library: types.library,\n signal,\n renderType: (ref, nullable) => renderReactPropType(types, ref, nullable),\n shouldIncludeCallerAllocated: false,\n isOptOut: true,\n });\n\n return `(${params.join(\", \")}) => ${result}`;\n};\n\nconst reactTarget = (context: PropTypeRenderContext): TsTypeTarget =>\n recordTypeTarget(\n context.library,\n (name) => {\n context.imports.set(name.namespaceName, giNamespaceAlias(name.namespaceName));\n\n return `${giNamespaceAlias(name.namespaceName)}.${name.typeName}`;\n },\n () => {\n context.imports.set(\"GObject\", giNamespaceAlias(\"GObject\"));\n\n return `${giNamespaceAlias(\"GObject\")}.Type`;\n },\n );\n\nconst renderReactPropType = (context: PropTypeRenderContext, ref: TypeId | undefined, isNullable: boolean): string => {\n const base = renderBaseType(context.library, reactTarget(context), ref);\n\n return isNullable ? `${base} | null` : base;\n};\n\nexport { buildElementPropsEntries, buildInterfacePropsEntries, isObjectProp, reactTarget };\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { JsxNamespaceFile } from "./jsx/pipeline.js";
|
|
2
2
|
import type { RawFile } from "./store-fs.js";
|
|
3
3
|
import { type StoreOptions } from "./store-fs.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { writeJsxStore, type JsxStoreOptions };
|
|
4
|
+
declare const writeJsxStore: (options: StoreOptions, namespaces: JsxNamespaceFile[], metadata: string, rawFiles: RawFile[]) => void;
|
|
5
|
+
export { writeJsxStore };
|
|
7
6
|
//# sourceMappingURL=jsx-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-store.d.ts","sourceRoot":"","sources":["../../src/store/jsx-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAiB,KAAK,YAAY,EAA6B,MAAM,eAAe,CAAC;AAE5F,
|
|
1
|
+
{"version":3,"file":"jsx-store.d.ts","sourceRoot":"","sources":["../../src/store/jsx-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAiB,KAAK,YAAY,EAA6B,MAAM,eAAe,CAAC;AAE5F,QAAA,MAAM,aAAa,GACf,SAAS,YAAY,EACrB,YAAY,gBAAgB,EAAE,EAC9B,UAAU,MAAM,EAChB,UAAU,OAAO,EAAE,KACpB,IAyBF,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/store/jsx-store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildManifest, subpathExport, writeStore } from "./store-fs.js";
|
|
2
|
-
const writeJsxStore = (options, namespaces, metadata,
|
|
2
|
+
const writeJsxStore = (options, namespaces, metadata, rawFiles) => {
|
|
3
3
|
const exportsMap = {
|
|
4
4
|
"./metadata": subpathExport("metadata"),
|
|
5
5
|
};
|
|
@@ -18,8 +18,8 @@ const writeJsxStore = (options, namespaces, metadata, fingerprint) => {
|
|
|
18
18
|
exports: exportsMap,
|
|
19
19
|
peerDependencies: { "@gtkx/gi": "*", "@gtkx/react": "*", react: "*" },
|
|
20
20
|
}),
|
|
21
|
-
rawFiles
|
|
22
|
-
|
|
21
|
+
rawFiles,
|
|
22
|
+
requiresEnvReference: true,
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
export { writeJsxStore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-store.js","sourceRoot":"","sources":["../../src/store/jsx-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"jsx-store.js","sourceRoot":"","sources":["../../src/store/jsx-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE5F,MAAM,aAAa,GAAG,CAClB,OAAqB,EACrB,UAA8B,EAC9B,QAAgB,EAChB,QAAmB,EACf,EAAE;IACN,MAAM,UAAU,GAA4B;QACxC,YAAY,EAAE,aAAa,CAAC,UAAU,CAAC;KAC1C,CAAC;IAEF,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE9D,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,SAAS,IAAI,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAClE,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC,GAAG,aAAa,CAAC,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,UAAU,CAAC;QACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK;QACL,QAAQ,EAAE,aAAa,CAAC;YACpB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,UAAU;YACnB,gBAAgB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;SACxE,CAAC;QACF,QAAQ;QACR,oBAAoB,EAAE,IAAI;KAC7B,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import type { JsxNamespaceFile } from \"./jsx/pipeline.js\";\nimport type { RawFile } from \"./store-fs.js\";\nimport { buildManifest, type StoreOptions, subpathExport, writeStore } from \"./store-fs.js\";\n\nconst writeJsxStore = (\n options: StoreOptions,\n namespaces: JsxNamespaceFile[],\n metadata: string,\n rawFiles: RawFile[],\n): void => {\n const exportsMap: Record<string, unknown> = {\n \"./metadata\": subpathExport(\"metadata\"),\n };\n\n const files = [{ fileName: \"metadata.ts\", source: metadata }];\n\n for (const { directory, source } of namespaces) {\n files.push({ fileName: `${directory}/${directory}.tsx`, source });\n exportsMap[`./${directory}`] = subpathExport(`${directory}/${directory}`);\n }\n\n writeStore({\n storeDir: options.storeDir,\n linkDir: options.linkDir,\n files,\n manifest: buildManifest({\n name: \"@gtkx/jsx\",\n version: options.version,\n exports: exportsMap,\n peerDependencies: { \"@gtkx/gi\": \"*\", \"@gtkx/react\": \"*\", react: \"*\" },\n }),\n rawFiles,\n requiresEnvReference: true,\n });\n};\n\nexport { writeJsxStore };\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { StoreOptions } from "./store-fs.js";
|
|
2
|
+
/**
|
|
3
|
+
* Where a project's generated stores live, ready to spread into `runCodegen`. `jsx` is null when the
|
|
4
|
+
* project has no `@gtkx/react` installed, in which case only the `@gtkx/gi` store can be generated.
|
|
5
|
+
*/
|
|
6
|
+
type ResolvedStore = {
|
|
7
|
+
/** Where the `@gtkx/gi` store goes, versioned by the installed `@gtkx/runtime`. */
|
|
8
|
+
gi: StoreOptions;
|
|
9
|
+
/** Where the `@gtkx/jsx` store goes, versioned by the installed `@gtkx/react`; null when it is absent. */
|
|
10
|
+
jsx: StoreOptions | null;
|
|
11
|
+
/** Subexport names of the installed `@gtkx/react`, empty when it is absent. */
|
|
12
|
+
reactSubexports: string[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Resolves where a project's `@gtkx/gi` and `@gtkx/jsx` stores belong, from the project root alone. The
|
|
16
|
+
* result supplies every `runCodegen` input except `libraries` and `girPath`, so a caller that has
|
|
17
|
+
* already resolved those can spread it straight into the call.
|
|
18
|
+
*
|
|
19
|
+
* Store versions come from the installed `@gtkx/runtime` and `@gtkx/react`, so a dependency upgrade
|
|
20
|
+
* invalidates the stores. Pass explicit `gi` or `jsx` options to `runCodegen` to override any of it.
|
|
21
|
+
*
|
|
22
|
+
* @param projectRoot Directory holding the project's `package.json` and `node_modules`.
|
|
23
|
+
* @returns The store locations and the React subexports that shape the jsx store.
|
|
24
|
+
* @throws If `@gtkx/runtime` cannot be resolved from the project.
|
|
25
|
+
*/
|
|
26
|
+
declare const resolveStore: (projectRoot: string) => ResolvedStore;
|
|
27
|
+
export { resolveStore, type ResolvedStore };
|
|
28
|
+
//# sourceMappingURL=resolve-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-store.d.ts","sourceRoot":"","sources":["../../src/store/resolve-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;;GAGG;AACH,KAAK,aAAa,GAAG;IACjB,mFAAmF;IACnF,EAAE,EAAE,YAAY,CAAC;IACjB,0GAA0G;IAC1G,GAAG,EAAE,YAAY,GAAG,IAAI,CAAC;IACzB,+EAA+E;IAC/E,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAuDF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,YAAY,GAAI,aAAa,MAAM,KAAG,aAe3C,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { dirname, join, parse } from "node:path";
|
|
3
|
+
const STORE_DIR = ".gtkx";
|
|
4
|
+
const SCOPE = "@gtkx";
|
|
5
|
+
const readManifest = (path) => JSON.parse(readFileSync(path, "utf8"));
|
|
6
|
+
const subexportNames = (packageDir) => Object.keys(readManifest(join(packageDir, "package.json")).exports ?? {})
|
|
7
|
+
.filter((key) => key.startsWith("./") && key !== "./package.json")
|
|
8
|
+
.map((key) => key.slice(2));
|
|
9
|
+
const loadPackage = (manifest) => {
|
|
10
|
+
if (!existsSync(manifest)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const real = realpathSync(manifest);
|
|
14
|
+
return { dir: dirname(real), version: readManifest(real).version ?? "0.0.0" };
|
|
15
|
+
};
|
|
16
|
+
const nodeModulesChain = function* (projectRoot) {
|
|
17
|
+
const { root } = parse(projectRoot);
|
|
18
|
+
let current = projectRoot;
|
|
19
|
+
while (current !== root) {
|
|
20
|
+
yield join(current, "node_modules");
|
|
21
|
+
current = dirname(current);
|
|
22
|
+
}
|
|
23
|
+
yield join(root, "node_modules");
|
|
24
|
+
};
|
|
25
|
+
const resolvePackage = (projectRoot, packageName) => {
|
|
26
|
+
for (const nodeModules of nodeModulesChain(projectRoot)) {
|
|
27
|
+
const found = loadPackage(join(nodeModules, packageName, "package.json"));
|
|
28
|
+
if (found !== null) {
|
|
29
|
+
return found;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return loadPackage(join(projectRoot, "packages", packageName.replace(/^@[^/]+\//, ""), "package.json"));
|
|
33
|
+
};
|
|
34
|
+
const storeOptions = (nodeModules, name, version) => ({
|
|
35
|
+
storeDir: join(nodeModules, STORE_DIR, name),
|
|
36
|
+
linkDir: join(nodeModules, SCOPE, name),
|
|
37
|
+
version,
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Resolves where a project's `@gtkx/gi` and `@gtkx/jsx` stores belong, from the project root alone. The
|
|
41
|
+
* result supplies every `runCodegen` input except `libraries` and `girPath`, so a caller that has
|
|
42
|
+
* already resolved those can spread it straight into the call.
|
|
43
|
+
*
|
|
44
|
+
* Store versions come from the installed `@gtkx/runtime` and `@gtkx/react`, so a dependency upgrade
|
|
45
|
+
* invalidates the stores. Pass explicit `gi` or `jsx` options to `runCodegen` to override any of it.
|
|
46
|
+
*
|
|
47
|
+
* @param projectRoot Directory holding the project's `package.json` and `node_modules`.
|
|
48
|
+
* @returns The store locations and the React subexports that shape the jsx store.
|
|
49
|
+
* @throws If `@gtkx/runtime` cannot be resolved from the project.
|
|
50
|
+
*/
|
|
51
|
+
const resolveStore = (projectRoot) => {
|
|
52
|
+
const runtime = resolvePackage(projectRoot, "@gtkx/runtime");
|
|
53
|
+
if (runtime === null) {
|
|
54
|
+
throw new Error(`Cannot resolve @gtkx/runtime from ${projectRoot}; is it installed?`);
|
|
55
|
+
}
|
|
56
|
+
const react = resolvePackage(projectRoot, "@gtkx/react");
|
|
57
|
+
const nodeModules = join(projectRoot, "node_modules");
|
|
58
|
+
return {
|
|
59
|
+
gi: storeOptions(nodeModules, "gi", runtime.version),
|
|
60
|
+
jsx: react === null ? null : storeOptions(nodeModules, "jsx", react.version),
|
|
61
|
+
reactSubexports: react === null ? [] : subexportNames(react.dir),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export { resolveStore };
|
|
65
|
+
//# sourceMappingURL=resolve-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-store.js","sourceRoot":"","sources":["../../src/store/resolve-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAkBjD,MAAM,SAAS,GAAG,OAAO,CAAC;AAC1B,MAAM,KAAK,GAAG,OAAO,CAAC;AAEtB,MAAM,YAAY,GAAG,CAAC,IAAY,EAA2D,EAAE,CAC3F,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC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AK,EAAE,KAAK,CAAC,OAAO,CAAC;QAC5E,eAAe,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC;KACnE,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAsB,CAAC","sourcesContent":["import { existsSync, readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, join, parse } from \"node:path\";\nimport type { StoreOptions } from \"./store-fs.js\";\n\n/**\n * Where a project's generated stores live, ready to spread into `runCodegen`. `jsx` is null when the\n * project has no `@gtkx/react` installed, in which case only the `@gtkx/gi` store can be generated.\n */\ntype ResolvedStore = {\n /** Where the `@gtkx/gi` store goes, versioned by the installed `@gtkx/runtime`. */\n gi: StoreOptions;\n /** Where the `@gtkx/jsx` store goes, versioned by the installed `@gtkx/react`; null when it is absent. */\n jsx: StoreOptions | null;\n /** Subexport names of the installed `@gtkx/react`, empty when it is absent. */\n reactSubexports: string[];\n};\n\ntype ResolvedPackage = { dir: string; version: string };\n\nconst STORE_DIR = \".gtkx\";\nconst SCOPE = \"@gtkx\";\n\nconst readManifest = (path: string): { version?: string; exports?: Record<string, unknown> } =>\n JSON.parse(readFileSync(path, \"utf8\")) as { version?: string; exports?: Record<string, unknown> };\n\nconst subexportNames = (packageDir: string): string[] =>\n Object.keys(readManifest(join(packageDir, \"package.json\")).exports ?? {})\n .filter((key) => key.startsWith(\"./\") && key !== \"./package.json\")\n .map((key) => key.slice(2));\n\nconst loadPackage = (manifest: string): ResolvedPackage | null => {\n if (!existsSync(manifest)) {\n return null;\n }\n\n const real = realpathSync(manifest);\n\n return { dir: dirname(real), version: readManifest(real).version ?? \"0.0.0\" };\n};\n\nconst nodeModulesChain = function* (projectRoot: string): Generator<string> {\n const { root } = parse(projectRoot);\n let current = projectRoot;\n\n while (current !== root) {\n yield join(current, \"node_modules\");\n current = dirname(current);\n }\n\n yield join(root, \"node_modules\");\n};\n\nconst resolvePackage = (projectRoot: string, packageName: string): ResolvedPackage | null => {\n for (const nodeModules of nodeModulesChain(projectRoot)) {\n const found = loadPackage(join(nodeModules, packageName, \"package.json\"));\n\n if (found !== null) {\n return found;\n }\n }\n\n return loadPackage(join(projectRoot, \"packages\", packageName.replace(/^@[^/]+\\//, \"\"), \"package.json\"));\n};\n\nconst storeOptions = (nodeModules: string, name: string, version: string): StoreOptions => ({\n storeDir: join(nodeModules, STORE_DIR, name),\n linkDir: join(nodeModules, SCOPE, name),\n version,\n});\n\n/**\n * Resolves where a project's `@gtkx/gi` and `@gtkx/jsx` stores belong, from the project root alone. The\n * result supplies every `runCodegen` input except `libraries` and `girPath`, so a caller that has\n * already resolved those can spread it straight into the call.\n *\n * Store versions come from the installed `@gtkx/runtime` and `@gtkx/react`, so a dependency upgrade\n * invalidates the stores. Pass explicit `gi` or `jsx` options to `runCodegen` to override any of it.\n *\n * @param projectRoot Directory holding the project's `package.json` and `node_modules`.\n * @returns The store locations and the React subexports that shape the jsx store.\n * @throws If `@gtkx/runtime` cannot be resolved from the project.\n */\nconst resolveStore = (projectRoot: string): ResolvedStore => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n throw new Error(`Cannot resolve @gtkx/runtime from ${projectRoot}; is it installed?`);\n }\n\n const react = resolvePackage(projectRoot, \"@gtkx/react\");\n const nodeModules = join(projectRoot, \"node_modules\");\n\n return {\n gi: storeOptions(nodeModules, \"gi\", runtime.version),\n jsx: react === null ? null : storeOptions(nodeModules, \"jsx\", react.version),\n reactSubexports: react === null ? [] : subexportNames(react.dir),\n };\n};\n\nexport { resolveStore, type ResolvedStore };\n"]}
|
package/dist/store/store-fs.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/** Where one generated store is written and how it is reached. */
|
|
1
2
|
type StoreOptions = {
|
|
3
|
+
/** Directory the generated package is written to, replaced atomically on each run. */
|
|
2
4
|
storeDir: string;
|
|
5
|
+
/** Path the store is symlinked at, which is the specifier's resolution target under `node_modules`. */
|
|
3
6
|
linkDir: string;
|
|
7
|
+
/** Version stamped on the store's `package.json`, taken from the dependency the store is generated for. */
|
|
4
8
|
version: string;
|
|
5
9
|
};
|
|
6
10
|
type StoreFile = {
|
|
@@ -31,7 +35,7 @@ type WriteStoreParams = {
|
|
|
31
35
|
files: StoreFile[];
|
|
32
36
|
manifest: Manifest;
|
|
33
37
|
rawFiles?: RawFile[];
|
|
34
|
-
|
|
38
|
+
requiresEnvReference?: boolean;
|
|
35
39
|
};
|
|
36
40
|
declare const subpathExport: (stem: string) => {
|
|
37
41
|
types: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-fs.d.ts","sourceRoot":"","sources":["../../src/store/store-fs.ts"],"names":[],"mappings":"AAIA,KAAK,YAAY,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,SAAS,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,QAAQ,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF,KAAK,aAAa,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF,K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C,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,KAAK,gBAAgB,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAIF,QAAA,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAGpE,CAAC;AAEH,QAAA,MAAM,aAAa,GAAI,OAAO,aAAa,KAAG,QAc7C,CAAC;AAEF,QAAA,MAAM,UAAU,GAAI,QAAQ,gBAAgB,KAAG,IA0B9C,CAAC;AAuCF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,CAAC"}
|
package/dist/store/store-fs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, relative } from "node:path";
|
|
3
3
|
import { compileStore } from "./compile-store.js";
|
|
4
|
+
const STORE_DIR_MODE = 0o755;
|
|
4
5
|
const subpathExport = (stem) => ({
|
|
5
6
|
types: `./${stem}.d.ts`,
|
|
6
7
|
default: `./${stem}.js`,
|
|
@@ -28,14 +29,13 @@ const writeStore = (params) => {
|
|
|
28
29
|
storeDir: tmp,
|
|
29
30
|
files: params.files,
|
|
30
31
|
packageName: params.manifest.name,
|
|
31
|
-
...(params.
|
|
32
|
+
...(params.requiresEnvReference !== undefined && { requiresEnvReference: params.requiresEnvReference }),
|
|
32
33
|
});
|
|
33
34
|
writePackageJson(tmp, params.manifest);
|
|
34
35
|
const rawFiles = params.rawFiles ?? [];
|
|
35
36
|
for (const raw of rawFiles) {
|
|
36
37
|
writeFileSync(join(tmp, raw.relativePath), raw.content);
|
|
37
38
|
}
|
|
38
|
-
symlinkRelative(join(tmp, "node_modules", ...params.manifest.name.split("/")), tmp);
|
|
39
39
|
swapStore(tmp, params.storeDir, params.linkDir);
|
|
40
40
|
}
|
|
41
41
|
finally {
|
|
@@ -67,7 +67,9 @@ const swapStore = (tmp, storeDir, visibleLink) => {
|
|
|
67
67
|
};
|
|
68
68
|
const createTempStore = (storeDir) => {
|
|
69
69
|
mkdirSync(dirname(storeDir), { recursive: true });
|
|
70
|
-
|
|
70
|
+
const tmp = mkdtempSync(`${storeDir}.tmp-`);
|
|
71
|
+
chmodSync(tmp, STORE_DIR_MODE);
|
|
72
|
+
return tmp;
|
|
71
73
|
};
|
|
72
74
|
export { subpathExport, buildManifest, writeStore };
|
|
73
75
|
//# sourceMappingURL=store-fs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-fs.js","sourceRoot":"","sources":["../../src/store/store-fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"store-fs.js","sourceRoot":"","sources":["../../src/store/store-fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA4ClD,MAAM,cAAc,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AC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5F,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAE,WAAmB,EAAQ,EAAE;IAC3E,MAAM,QAAQ,GAAG,GAAG,QAAQ,MAAM,CAAC;IACnC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAEnD,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvB,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC1B,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAU,EAAE;IACjD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,QAAQ,OAAO,CAAC,CAAC;IAC5C,SAAS,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAE/B,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAmC,CAAC","sourcesContent":["import { chmodSync, existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, symlinkSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\nimport { compileStore } from \"./compile-store.js\";\n\n/** Where one generated store is written and how it is reached. */\ntype StoreOptions = {\n /** Directory the generated package is written to, replaced atomically on each run. */\n storeDir: string;\n /** Path the store is symlinked at, which is the specifier's resolution target under `node_modules`. */\n linkDir: string;\n /** Version stamped on the store's `package.json`, taken from the dependency the store is generated for. */\n version: string;\n};\n\ntype StoreFile = {\n fileName: string;\n source: string;\n};\n\ntype Manifest = {\n name: string;\n type: \"module\";\n version: string;\n sideEffects: true;\n exports: Record<string, unknown>;\n peerDependencies?: Record<string, string>;\n};\n\ntype ManifestInput = {\n name: string;\n version: string;\n exports: Record<string, unknown>;\n peerDependencies?: Record<string, string>;\n};\n\ntype RawFile = { relativePath: string; content: string };\n\ntype WriteStoreParams = {\n storeDir: string;\n linkDir: string;\n files: StoreFile[];\n manifest: Manifest;\n rawFiles?: RawFile[];\n requiresEnvReference?: boolean;\n};\n\nconst STORE_DIR_MODE = 0o755;\n\nconst subpathExport = (stem: string): { types: string; default: string } => ({\n types: `./${stem}.d.ts`,\n default: `./${stem}.js`,\n});\n\nconst buildManifest = (input: ManifestInput): Manifest => {\n const manifest: Manifest = {\n name: input.name,\n type: \"module\",\n version: input.version,\n sideEffects: true,\n exports: { \"./package.json\": \"./package.json\", ...input.exports },\n };\n\n if (input.peerDependencies) {\n manifest.peerDependencies = input.peerDependencies;\n }\n\n return manifest;\n};\n\nconst writeStore = (params: WriteStoreParams): void => {\n const tmp = createTempStore(params.storeDir);\n\n try {\n for (const file of params.files) {\n writeSourceFile(tmp, file.fileName, file.source);\n }\n\n compileStore({\n storeDir: tmp,\n files: params.files,\n packageName: params.manifest.name,\n ...(params.requiresEnvReference !== undefined && { requiresEnvReference: params.requiresEnvReference }),\n });\n\n writePackageJson(tmp, params.manifest);\n const rawFiles = params.rawFiles ?? [];\n\n for (const raw of rawFiles) {\n writeFileSync(join(tmp, raw.relativePath), raw.content);\n }\n\n swapStore(tmp, params.storeDir, params.linkDir);\n } finally {\n rmSync(tmp, { recursive: true, force: true });\n }\n};\n\nconst writeSourceFile = (storeDir: string, fileName: string, source: string): void => {\n const filePath = join(storeDir, fileName);\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, source);\n};\n\nconst symlinkRelative = (linkPath: string, realTarget: string): void => {\n mkdirSync(dirname(linkPath), { recursive: true });\n rmSync(linkPath, { recursive: true, force: true });\n symlinkSync(relative(dirname(linkPath), realTarget), linkPath, \"dir\");\n};\n\nconst writePackageJson = (storeDir: string, manifest: Manifest): void => {\n writeFileSync(join(storeDir, \"package.json\"), `${JSON.stringify(manifest, null, 2)}\\n`);\n};\n\nconst swapStore = (tmp: string, storeDir: string, visibleLink: string): void => {\n const previous = `${storeDir}.old`;\n rmSync(previous, { recursive: true, force: true });\n\n if (existsSync(storeDir)) {\n renameSync(storeDir, previous);\n }\n\n renameSync(tmp, storeDir);\n rmSync(previous, { recursive: true, force: true });\n symlinkRelative(visibleLink, storeDir);\n};\n\nconst createTempStore = (storeDir: string): string => {\n mkdirSync(dirname(storeDir), { recursive: true });\n const tmp = mkdtempSync(`${storeDir}.tmp-`);\n chmodSync(tmp, STORE_DIR_MODE);\n\n return tmp;\n};\n\nexport { subpathExport, buildManifest, writeStore, type StoreOptions, type RawFile };\n"]}
|
|
@@ -9,34 +9,34 @@ declare module "../gobject.js" {
|
|
|
9
9
|
|
|
10
10
|
disconnect(handlerId: number): void;
|
|
11
11
|
|
|
12
|
-
on(sigName: string, callback: (...args: unknown[]) => unknown,
|
|
12
|
+
on(sigName: string, callback: (...args: unknown[]) => unknown, isAfter?: boolean): Object;
|
|
13
13
|
|
|
14
|
-
once(sigName: string, callback: (...args: unknown[]) => unknown,
|
|
14
|
+
once(sigName: string, callback: (...args: unknown[]) => unknown, isAfter?: boolean): Object;
|
|
15
15
|
|
|
16
16
|
off(sigName: string, callback: (...args: unknown[]) => unknown): Object;
|
|
17
17
|
|
|
18
|
-
addEventListener(sigName: string, callback: (...args: unknown[]) => unknown,
|
|
18
|
+
addEventListener(sigName: string, callback: (...args: unknown[]) => unknown, isAfter?: boolean): Object;
|
|
19
19
|
|
|
20
20
|
removeEventListener(sigName: string, callback: (...args: unknown[]) => unknown): Object;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
type GObjectWithConnect = GObject & {
|
|
25
|
-
connect(sigName: string, callback: Listener,
|
|
25
|
+
connect(sigName: string, callback: Listener, isAfter?: boolean): number;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
GObject.prototype.disconnect = function disconnect(handlerId: number): void {
|
|
29
29
|
signalHandlerDisconnect(this, BigInt(handlerId));
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
function onImpl(this: GObjectWithConnect, sigName: string, callback: Listener,
|
|
33
|
-
onSignal(this, sigName, callback,
|
|
32
|
+
function onImpl(this: GObjectWithConnect, sigName: string, callback: Listener, isAfter?: boolean): GObject {
|
|
33
|
+
onSignal(this, sigName, callback, isAfter);
|
|
34
34
|
return this;
|
|
35
35
|
}
|
|
36
36
|
GObject.prototype.on = onImpl;
|
|
37
37
|
|
|
38
|
-
function onceImpl(this: GObjectWithConnect, sigName: string, callback: Listener,
|
|
39
|
-
onceSignal(this, sigName, callback,
|
|
38
|
+
function onceImpl(this: GObjectWithConnect, sigName: string, callback: Listener, isAfter?: boolean): GObject {
|
|
39
|
+
onceSignal(this, sigName, callback, isAfter);
|
|
40
40
|
return this;
|
|
41
41
|
}
|
|
42
42
|
GObject.prototype.once = onceImpl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/codegen",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
4
|
"description": "Generates the typed GTKX bindings and API reference from GIR and OpenGL registry data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -29,13 +29,9 @@
|
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"default": "./dist/index.js"
|
|
31
31
|
},
|
|
32
|
-
"./
|
|
33
|
-
"types": "./dist/
|
|
34
|
-
"default": "./dist/
|
|
35
|
-
},
|
|
36
|
-
"./jsx": {
|
|
37
|
-
"types": "./dist/jsx.d.ts",
|
|
38
|
-
"default": "./dist/jsx.js"
|
|
32
|
+
"./internal": {
|
|
33
|
+
"types": "./dist/internal.d.ts",
|
|
34
|
+
"default": "./dist/internal.js"
|
|
39
35
|
}
|
|
40
36
|
},
|
|
41
37
|
"sideEffects": false,
|
|
@@ -51,8 +47,8 @@
|
|
|
51
47
|
"@types/node": "^26.1.2",
|
|
52
48
|
"fast-xml-parser": "^5.10.1",
|
|
53
49
|
"typescript": "^6.0.3",
|
|
54
|
-
"@gtkx/react": "1.0.0-rc.
|
|
55
|
-
"@gtkx/utils": "1.0.0-rc.
|
|
50
|
+
"@gtkx/react": "1.0.0-rc.4",
|
|
51
|
+
"@gtkx/utils": "1.0.0-rc.4"
|
|
56
52
|
},
|
|
57
53
|
"scripts": {
|
|
58
54
|
"release": "tsx ../../scripts/release-package.ts"
|