@gtkx/codegen 1.0.0 → 1.2.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 +59 -38
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +25 -10
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +37 -9
- 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 +25 -0
- package/dist/analysis/interface-conflicts.d.ts.map +1 -0
- package/dist/analysis/interface-conflicts.js +139 -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 +3 -2
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +26 -26
- 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/analysis/type-shape.d.ts +3 -2
- package/dist/analysis/type-shape.d.ts.map +1 -1
- package/dist/analysis/type-shape.js +2 -1
- package/dist/analysis/type-shape.js.map +1 -1
- package/dist/compile.d.ts +14 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +125 -24
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +2 -0
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +11 -10
- 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 +1 -0
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +93 -19
- 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 +10 -9
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/fingerprint.d.ts +20 -3
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +56 -37
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +1 -0
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +8 -2
- 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/gir-path.d.ts +1 -1
- package/dist/gir/gir-path.js +1 -1
- package/dist/gir/gir-path.js.map +1 -1
- package/dist/gir/library.d.ts +5 -1
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +9 -2
- 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 +6 -6
- package/dist/gir/parse.js.map +1 -1
- package/dist/gir/primitives.js +1 -1
- package/dist/gir/primitives.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/args.d.ts.map +1 -1
- package/dist/khronos/args.js +8 -6
- package/dist/khronos/args.js.map +1 -1
- 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/khronos/render.d.ts.map +1 -1
- package/dist/khronos/render.js +8 -4
- package/dist/khronos/render.js.map +1 -1
- package/dist/runner.d.ts +7 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +21 -3
- 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 +0 -1
- package/dist/store/compile-store.d.ts.map +1 -1
- package/dist/store/compile-store.js +7 -32
- package/dist/store/compile-store.js.map +1 -1
- package/dist/store/gi/callables.d.ts +6 -3
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +40 -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 +104 -44
- 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 +11 -3
- 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 +29 -12
- 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 +34 -19
- 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 -24
- 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 -8
- package/dist/store/gi/property-accessor.d.ts.map +1 -1
- package/dist/store/gi/property-accessor.js +49 -91
- 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 +34 -13
- 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 +20 -4
- 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/return-wrap.js +1 -1
- package/dist/store/gi/return-wrap.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 +55 -28
- 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 -4
- 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 -7
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +54 -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 +8 -1
- package/dist/xml.d.ts.map +1 -1
- package/dist/xml.js +70 -1
- package/dist/xml.js.map +1 -1
- package/overrides/gobject/object.ts.ejs +2 -0
- package/package.json +14 -3
- package/src/analysis/descriptor-render.ts +106 -52
- package/src/analysis/descriptor.ts +76 -15
- package/src/analysis/inheritance.ts +134 -44
- package/src/analysis/interface-conflicts.ts +235 -0
- package/src/analysis/param-capability.ts +3 -6
- package/src/analysis/param-structure.ts +2 -2
- package/src/analysis/ts-type.ts +43 -28
- package/src/analysis/type-key.ts +14 -0
- package/src/analysis/type-shape.ts +5 -2
- package/src/compile.ts +192 -27
- package/src/docs/api-reference.ts +13 -10
- package/src/docs/element-page.ts +5 -2
- package/src/docs/pipeline.ts +140 -24
- package/src/docs/render.ts +7 -3
- package/src/docs/symbol-page.ts +12 -11
- package/src/fingerprint.ts +95 -47
- package/src/gi.ts +10 -2
- 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/gir-path.ts +1 -1
- package/src/gir/library.ts +10 -2
- package/src/gir/namespace.ts +8 -2
- package/src/gir/parameter.ts +15 -0
- package/src/gir/parse.ts +10 -7
- package/src/gir/primitives.ts +1 -1
- package/src/guards.ts +23 -0
- package/src/internal.ts +2 -0
- package/src/json.ts +11 -0
- package/src/khronos/args.ts +9 -6
- 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/khronos/render.ts +8 -6
- package/src/runner.ts +26 -4
- package/src/staging.ts +67 -0
- package/src/store/compile-store.ts +7 -38
- package/src/store/gi/callables.ts +60 -33
- package/src/store/gi/callback.ts +9 -9
- package/src/store/gi/class.ts +140 -53
- package/src/store/gi/companion.ts +7 -6
- package/src/store/gi/constant.ts +13 -3
- package/src/store/gi/constructor-props.ts +1 -1
- package/src/store/gi/enum.ts +36 -26
- package/src/store/gi/function.ts +30 -24
- package/src/store/gi/gtype-binding.ts +7 -2
- package/src/store/gi/interface.ts +39 -20
- package/src/store/gi/method.ts +26 -32
- 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 +73 -161
- package/src/store/gi/record-constructor.ts +53 -21
- package/src/store/gi/record-field-accessor.ts +26 -4
- 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/return-wrap.ts +1 -1
- package/src/store/gi/signal.ts +66 -42
- 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 -4
- package/src/store/resolve-store.ts +133 -18
- package/src/store/store-fs.ts +82 -35
- 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 +103 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-shape.js","sourceRoot":"","sources":["../../src/analysis/type-shape.ts"],"names":[],"mappings":"AAKA,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,GAAuB,EAAuB,EAAE,CACvF,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAEzD,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,GAAuB,EAA0B,EAAE;IACpF,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAE3C,OAAO,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAE,GAAuB,EAAiC,EAAE;IACtG,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAE3C,OAAO,IAAI,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAgB,EAAW,EAAE,CACnD,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,oBAAoB,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC;AAErG,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import type { Library } from \"../gir/library.js\";\nimport type { PrimitiveCategory } from \"../gir/primitives.js\";\nimport type { CArrayType, TypeId } from \"../gir/type-id.js\";\nimport type { GirType } from \"../gir/type.js\";\n\nconst resolvedTypeFor = (library: Library, ref: TypeId | undefined): GirType | undefined =>\n ref === undefined ? undefined : library.typeFor(ref);\n\nconst carrayFor = (library: Library, ref: TypeId | undefined): CArrayType | undefined => {\n const type = resolvedTypeFor(library, ref);\n\n return type?.kind === \"carray\" ? type : undefined;\n};\n\nconst primitiveCategoryFor = (library: Library, ref: TypeId | undefined): PrimitiveCategory | undefined => {\n const type = resolvedTypeFor(library, ref);\n\n return type?.kind === \"primitive\" ? type.category : undefined;\n};\n\nconst isUnboundedArray = (type: CArrayType): boolean =>\n type.isZeroTerminated && type.lengthParameterIndex === undefined && type.fixedSize === undefined;\n\nexport { carrayFor, isUnboundedArray, primitiveCategoryFor };\n"]}
|
|
1
|
+
{"version":3,"file":"type-shape.js","source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port type { PrimitiveCategory } from \"../gir/primitives.js\";\nimport type { CArrayType, ListType, TypeId } from \"../gir/type-id.js\";\nimport type { GirType } from \"../gir/type.js\";\n\nconst resolvedTypeFor = (library: Library, ref: TypeId | undefined): GirType | undefined =>\n ref === undefined ? undefined : library.typeFor(ref);\n\nconst carrayFor = (library: Library, ref: TypeId | undefined): CArrayType | undefined => {\n const type = resolvedTypeFor(library, ref);\n\n return type?.kind === \"carray\" ? type : undefined;\n};\n\nconst primitiveCategoryFor = (library: Library, ref: TypeId | undefined): PrimitiveCategory | undefined => {\n const type = resolvedTypeFor(library, ref);\n\n return type?.kind === \"primitive\" ? type.category : undefined;\n};\n\nconst isUnboundedArray = (type: CArrayType): boolean =>\n type.isZeroTerminated && type.lengthParameterIndex === undefined && type.fixedSize === undefined;\n\nconst isByteSequence = (library: Library, type: CArrayType | ListType): boolean =>\n type.kind === \"list\" ? type.flavor === \"gbytearray\" : primitiveCategoryFor(library, type.element) === \"uint8\";\n\nexport { carrayFor, isByteSequence, isUnboundedArray, primitiveCategoryFor };\n"]}
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
type
|
|
1
|
+
type ProjectFile = {
|
|
2
2
|
fileName: string;
|
|
3
|
+
origin?: string | undefined;
|
|
4
|
+
};
|
|
5
|
+
type SourceModule = ProjectFile & {
|
|
3
6
|
source: string;
|
|
4
7
|
};
|
|
5
|
-
type
|
|
8
|
+
type EmitModulesParams = {
|
|
6
9
|
projectDir: string;
|
|
7
|
-
|
|
8
|
-
compilerOptions: Record<string, unknown>;
|
|
10
|
+
files: SourceModule[];
|
|
9
11
|
label: string;
|
|
10
12
|
};
|
|
11
|
-
|
|
13
|
+
type FailedProjectInput = {
|
|
14
|
+
projectDir: string;
|
|
15
|
+
keepAt: string;
|
|
16
|
+
error: unknown;
|
|
17
|
+
};
|
|
18
|
+
declare const keepFailedProject: (input: FailedProjectInput) => Error;
|
|
19
|
+
declare const emitModules: (params: EmitModulesParams) => void;
|
|
12
20
|
declare const checkModules: (params: {
|
|
13
21
|
modules: SourceModule[];
|
|
14
22
|
resolveFrom: string;
|
|
15
23
|
label: string;
|
|
16
24
|
}) => void;
|
|
17
|
-
export {
|
|
25
|
+
export { checkModules, emitModules, keepFailedProject, type SourceModule };
|
|
18
26
|
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAOA,KAAK,WAAW,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,KAAK,YAAY,GAAG,WAAW,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAYF,KAAK,iBAAiB,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAOF,KAAK,kBAAkB,GAAG;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC;AAiLF,QAAA,MAAM,iBAAiB,GAAI,OAAO,kBAAkB,KAAG,KActD,CAAC;AAoDF,QAAA,MAAM,WAAW,GAAI,QAAQ,iBAAiB,KAAG,IAUhD,CAAC;AAwBF,QAAA,MAAM,YAAY,GAAI,QAAQ;IAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAAG,IAwB/F,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,CAAC"}
|
package/dist/compile.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { errorCode, errorMessage, normalizeError } from "@gtkx/utils";
|
|
2
|
+
import { existsSync, mkdirSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { dirname, isAbsolute, join, relative } from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import ts from "typescript";
|
|
6
|
+
import { createStagingDir, sweepStrandedDirs } from "./staging.js";
|
|
5
7
|
const BASE_COMPILER_OPTIONS = {
|
|
6
8
|
module: "esnext",
|
|
7
9
|
moduleResolution: "bundler",
|
|
@@ -28,6 +30,23 @@ const CHECK_OPTIONS = {
|
|
|
28
30
|
isolatedDeclarations: true,
|
|
29
31
|
noEmit: true,
|
|
30
32
|
};
|
|
33
|
+
const DECLARATION_EMIT = {
|
|
34
|
+
declaration: true,
|
|
35
|
+
isolatedDeclarations: true,
|
|
36
|
+
removeComments: false,
|
|
37
|
+
};
|
|
38
|
+
const MODULE_EMIT = {
|
|
39
|
+
removeComments: false,
|
|
40
|
+
};
|
|
41
|
+
const DECLARATION_OPTIONS = ts.convertCompilerOptionsFromJson({ ...BASE_COMPILER_OPTIONS, ...DECLARATION_EMIT }, ".").options;
|
|
42
|
+
const MODULE_OPTIONS = ts.convertCompilerOptionsFromJson({ ...BASE_COMPILER_OPTIONS, ...MODULE_EMIT }, ".").options;
|
|
43
|
+
const TS_EXTENSION_PATTERN = /\.tsx?$/;
|
|
44
|
+
const DECLARATION_EXTENSION = ".d.ts";
|
|
45
|
+
const JAVASCRIPT_EXTENSION = ".js";
|
|
46
|
+
const CHECK_DIR = ".gtkx-check";
|
|
47
|
+
const FAILED_CHECK_DIR = `${CHECK_DIR}.failed`;
|
|
48
|
+
const LEGACY_CHECK_PREFIX = `${CHECK_DIR}-`;
|
|
49
|
+
const ESM_SCOPE_MANIFEST = `${JSON.stringify({ type: "module" }, null, 4)}\n`;
|
|
31
50
|
const FORMAT_HOST = {
|
|
32
51
|
getCanonicalFileName: (fileName) => fileName,
|
|
33
52
|
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
|
|
@@ -47,41 +66,88 @@ const linkToolingModules = (projectDir) => {
|
|
|
47
66
|
rmSync(link, { force: true });
|
|
48
67
|
};
|
|
49
68
|
};
|
|
69
|
+
const ensureModuleScope = (projectDir) => {
|
|
70
|
+
try {
|
|
71
|
+
writeFileSync(join(projectDir, "package.json"), ESM_SCOPE_MANIFEST, { flag: "wx" });
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (errorCode(error) !== "EEXIST") {
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
50
79
|
const isProjectFile = (rel) => !rel.startsWith("..") && !isAbsolute(rel) && !rel.split(/[/\\]/).includes("node_modules");
|
|
51
|
-
const
|
|
80
|
+
const projectDiagnosticFile = (diagnostic, projectDir) => {
|
|
52
81
|
const { file, start } = diagnostic;
|
|
53
82
|
if (file === undefined || start === undefined) {
|
|
54
83
|
return undefined;
|
|
55
84
|
}
|
|
56
|
-
const
|
|
57
|
-
if (!isProjectFile(
|
|
85
|
+
const fileName = relative(projectDir, file.fileName);
|
|
86
|
+
if (!isProjectFile(fileName)) {
|
|
58
87
|
return undefined;
|
|
59
88
|
}
|
|
60
89
|
const { line, character } = file.getLineAndCharacterOfPosition(start);
|
|
61
90
|
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
62
|
-
return
|
|
91
|
+
return {
|
|
92
|
+
fileName,
|
|
93
|
+
text: `${fileName}:${String(line + 1)}:${String(character + 1)} - ${message} (TS${String(diagnostic.code)})`,
|
|
94
|
+
};
|
|
63
95
|
};
|
|
64
|
-
const
|
|
65
|
-
const
|
|
96
|
+
const projectDiagnosticFiles = (diagnostics, projectDir) => {
|
|
97
|
+
const diagnosed = [];
|
|
66
98
|
for (const diagnostic of diagnostics) {
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
|
|
99
|
+
const entry = projectDiagnosticFile(diagnostic, projectDir);
|
|
100
|
+
if (entry !== undefined) {
|
|
101
|
+
diagnosed.push(entry);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return diagnosed;
|
|
105
|
+
};
|
|
106
|
+
const collectOrigins = (files) => {
|
|
107
|
+
const origins = new Map();
|
|
108
|
+
for (const { fileName, origin } of files) {
|
|
109
|
+
if (origin !== undefined) {
|
|
110
|
+
origins.set(fileName, origin);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return origins;
|
|
114
|
+
};
|
|
115
|
+
const groupByOrigin = (diagnosed, origins) => {
|
|
116
|
+
const grouped = new Map();
|
|
117
|
+
for (const { fileName } of diagnosed) {
|
|
118
|
+
const origin = origins.get(fileName);
|
|
119
|
+
if (origin !== undefined) {
|
|
120
|
+
grouped.set(origin, (grouped.get(origin) ?? new Set()).add(fileName));
|
|
70
121
|
}
|
|
71
122
|
}
|
|
72
|
-
return
|
|
123
|
+
return grouped;
|
|
73
124
|
};
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
125
|
+
const originLines = (diagnosed, files) => [...groupByOrigin(diagnosed, collectOrigins(files))].map(([origin, generated]) => `Generated from ${origin}: ${[...generated].join(", ")}`);
|
|
126
|
+
const diagnosticError = (params, diagnostics) => {
|
|
127
|
+
const diagnosed = projectDiagnosticFiles(diagnostics, params.projectDir);
|
|
128
|
+
const { label } = params;
|
|
129
|
+
if (diagnosed.length === 0) {
|
|
130
|
+
return new Error(`Compiling ${label} failed:\n${ts.formatDiagnostics(diagnostics, FORMAT_HOST).trim()}`);
|
|
78
131
|
}
|
|
79
|
-
|
|
132
|
+
const lines = [...diagnosed.map((entry) => entry.text), ...originLines(diagnosed, params.files)];
|
|
133
|
+
return new Error(`Compiling ${label} found ${String(diagnosed.length)} error(s):\n${lines.join("\n")}`);
|
|
134
|
+
};
|
|
135
|
+
const keepFailedProject = (input) => {
|
|
136
|
+
const { projectDir, keepAt, error } = input;
|
|
137
|
+
if (!existsSync(projectDir)) {
|
|
138
|
+
return normalizeError(error);
|
|
139
|
+
}
|
|
140
|
+
rmSync(keepAt, { recursive: true, force: true });
|
|
141
|
+
renameSync(projectDir, keepAt);
|
|
142
|
+
const rebased = errorMessage(error).split(projectDir).join(keepAt);
|
|
143
|
+
return new Error(`${rebased}\nThe generated sources are kept at ${keepAt}, where every path above resolves.`, {
|
|
144
|
+
cause: error,
|
|
145
|
+
});
|
|
80
146
|
};
|
|
81
147
|
const runProgram = (params) => {
|
|
82
148
|
const parsed = ts.parseJsonConfigFileContent({
|
|
83
149
|
compilerOptions: { ...BASE_COMPILER_OPTIONS, ...params.compilerOptions },
|
|
84
|
-
files: params.
|
|
150
|
+
files: params.files.map((file) => `./${file.fileName}`),
|
|
85
151
|
}, ts.sys, params.projectDir);
|
|
86
152
|
const program = ts.createProgram({
|
|
87
153
|
rootNames: parsed.fileNames,
|
|
@@ -94,22 +160,55 @@ const runProgram = (params) => {
|
|
|
94
160
|
}
|
|
95
161
|
return [...program.emit().diagnostics];
|
|
96
162
|
};
|
|
163
|
+
const replaceExtension = (fileName, extension) => `${fileName.replace(TS_EXTENSION_PATTERN, "")}${extension}`;
|
|
164
|
+
const transpileOptions = (compilerOptions, fileName) => ({
|
|
165
|
+
compilerOptions,
|
|
166
|
+
fileName,
|
|
167
|
+
reportDiagnostics: true,
|
|
168
|
+
});
|
|
169
|
+
const emitModule = (module, projectDir) => {
|
|
170
|
+
const fileName = join(projectDir, module.fileName);
|
|
171
|
+
const declaration = ts.transpileDeclaration(module.source, transpileOptions(DECLARATION_OPTIONS, fileName));
|
|
172
|
+
const javascript = ts.transpileModule(module.source, transpileOptions(MODULE_OPTIONS, fileName));
|
|
173
|
+
const diagnostics = [...declaration.diagnostics ?? [], ...javascript.diagnostics ?? []];
|
|
174
|
+
if (diagnostics.length > 0) {
|
|
175
|
+
return diagnostics;
|
|
176
|
+
}
|
|
177
|
+
writeFileSync(replaceExtension(fileName, DECLARATION_EXTENSION), declaration.outputText);
|
|
178
|
+
writeFileSync(replaceExtension(fileName, JAVASCRIPT_EXTENSION), javascript.outputText);
|
|
179
|
+
return [];
|
|
180
|
+
};
|
|
181
|
+
const emitModules = (params) => {
|
|
182
|
+
const diagnostics = [];
|
|
183
|
+
for (const module of params.files) {
|
|
184
|
+
diagnostics.push(...emitModule(module, params.projectDir));
|
|
185
|
+
}
|
|
186
|
+
if (diagnostics.length > 0) {
|
|
187
|
+
throw diagnosticError(params, diagnostics);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
97
190
|
const compileProject = (params) => {
|
|
191
|
+
ensureModuleScope(params.projectDir);
|
|
98
192
|
const unlinkToolingModules = linkToolingModules(params.projectDir);
|
|
99
193
|
try {
|
|
100
194
|
const diagnostics = runProgram(params);
|
|
101
195
|
if (diagnostics.length > 0) {
|
|
102
|
-
throw diagnosticError(params
|
|
196
|
+
throw diagnosticError(params, diagnostics);
|
|
103
197
|
}
|
|
104
198
|
}
|
|
105
199
|
finally {
|
|
106
200
|
unlinkToolingModules();
|
|
107
201
|
}
|
|
108
202
|
};
|
|
203
|
+
const stageCheckProject = (checkRoot) => {
|
|
204
|
+
const projectDir = createStagingDir(join(checkRoot, CHECK_DIR));
|
|
205
|
+
sweepStrandedDirs(checkRoot, LEGACY_CHECK_PREFIX);
|
|
206
|
+
return projectDir;
|
|
207
|
+
};
|
|
109
208
|
const checkModules = (params) => {
|
|
110
209
|
const checkRoot = join(params.resolveFrom, "node_modules");
|
|
111
|
-
|
|
112
|
-
const
|
|
210
|
+
const projectDir = stageCheckProject(checkRoot);
|
|
211
|
+
const keepAt = join(checkRoot, FAILED_CHECK_DIR);
|
|
113
212
|
try {
|
|
114
213
|
for (const module of params.modules) {
|
|
115
214
|
const filePath = join(projectDir, module.fileName);
|
|
@@ -118,14 +217,16 @@ const checkModules = (params) => {
|
|
|
118
217
|
}
|
|
119
218
|
compileProject({
|
|
120
219
|
projectDir,
|
|
121
|
-
|
|
220
|
+
files: params.modules,
|
|
122
221
|
compilerOptions: CHECK_OPTIONS,
|
|
123
222
|
label: params.label,
|
|
124
223
|
});
|
|
125
224
|
}
|
|
126
|
-
|
|
127
|
-
|
|
225
|
+
catch (error) {
|
|
226
|
+
throw keepFailedProject({ projectDir, keepAt, error });
|
|
128
227
|
}
|
|
228
|
+
rmSync(projectDir, { recursive: true, force: true });
|
|
229
|
+
rmSync(keepAt, { recursive: true, force: true });
|
|
129
230
|
};
|
|
130
|
-
export {
|
|
231
|
+
export { checkModules, emitModules, keepFailedProject };
|
|
131
232
|
//# sourceMappingURL=compile.js.map
|
package/dist/compile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,YAAY,CAAC;AAc5B,MAAM,qBAAqB,GAAG;IAC1B,MAAM,EAAE,QAAQ;IAChB,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,CAAC,QAAQ,CAAC;IACf,GAAG,EAAE,WAAW;IAChB,eAAe,EAAE,OAAO;IACxB,gBAAgB,EAAE,CAAC,QAAQ,CAAC;IAC5B,MAAM,EAAE,IAAI;IACZ,0BAA0B,EAAE,IAAI;IAChC,wBAAwB,EAAE,IAAI;IAC9B,iBAAiB,EAAE,IAAI;IACvB,0BAA0B,EAAE,IAAI;IAChC,oBAAoB,EAAE,KAAK;IAC3B,0BAA0B,EA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CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC1D,eAAe,EAAE,aAAa;YAC9B,KAAK,EAAE,MAAM,CAAC,KAAK;SACtB,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAqB,CAAC","sourcesContent":["import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport ts from \"typescript\";\n\ntype SourceModule = {\n fileName: string;\n source: string;\n};\n\ntype CompileProjectParams = {\n projectDir: string;\n fileNames: string[];\n compilerOptions: Record<string, unknown>;\n label: string;\n};\n\nconst BASE_COMPILER_OPTIONS = {\n module: \"esnext\",\n moduleResolution: \"bundler\",\n target: \"esnext\",\n lib: [\"esnext\"],\n jsx: \"react-jsx\",\n jsxImportSource: \"react\",\n customConditions: [\"source\"],\n strict: true,\n exactOptionalPropertyTypes: true,\n noUncheckedIndexedAccess: true,\n noImplicitReturns: true,\n noFallthroughCasesInSwitch: true,\n allowUnreachableCode: false,\n allowImportingTsExtensions: true,\n forceConsistentCasingInFileNames: true,\n resolveJsonModule: true,\n rewriteRelativeImportExtensions: true,\n skipLibCheck: true,\n types: [\"node\"],\n};\n\nconst CHECK_OPTIONS = {\n declaration: true,\n isolatedDeclarations: true,\n noEmit: true,\n};\n\nconst FORMAT_HOST: ts.FormatDiagnosticsHost = {\n getCanonicalFileName: (fileName) => fileName,\n getCurrentDirectory: () => ts.sys.getCurrentDirectory(),\n getNewLine: () => \"\\n\",\n};\n\nconst codegenModules = (): string => {\n const sourceDir = dirname(fileURLToPath(import.meta.url));\n\n return join(dirname(sourceDir), \"node_modules\");\n};\n\nconst linkToolingModules = (projectDir: string): (() => void) => {\n const link = join(projectDir, \"node_modules\");\n\n if (existsSync(link)) {\n return (): void => undefined;\n }\n\n symlinkSync(codegenModules(), link, \"junction\");\n\n return () => {\n rmSync(link, { force: true });\n };\n};\n\nconst isProjectFile = (rel: string): boolean =>\n !rel.startsWith(\"..\") && !isAbsolute(rel) && !rel.split(/[/\\\\]/).includes(\"node_modules\");\n\nconst projectDiagnosticLine = (diagnostic: ts.Diagnostic, projectDir: string): string | undefined => {\n const { file, start } = diagnostic;\n\n if (file === undefined || start === undefined) {\n return undefined;\n }\n\n const filePath = relative(projectDir, file.fileName);\n\n if (!isProjectFile(filePath)) {\n return undefined;\n }\n\n const { line, character } = file.getLineAndCharacterOfPosition(start);\n const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, \"\\n\");\n\n return `${filePath}:${String(line + 1)}:${String(character + 1)} - ${message} (TS${String(diagnostic.code)})`;\n};\n\nconst projectDiagnosticLines = (diagnostics: ts.Diagnostic[], projectDir: string): string[] => {\n const lines: string[] = [];\n\n for (const diagnostic of diagnostics) {\n const line = projectDiagnosticLine(diagnostic, projectDir);\n\n if (line !== undefined) {\n lines.push(line);\n }\n }\n\n return lines;\n};\n\nconst diagnosticError = (label: string, projectDir: string, diagnostics: ts.Diagnostic[]): Error => {\n const lines = projectDiagnosticLines(diagnostics, projectDir);\n\n if (lines.length > 0) {\n return new Error(`Type checking ${label} found ${String(lines.length)} error(s):\\n${lines.join(\"\\n\")}`);\n }\n\n return new Error(`Type checking ${label} failed:\\n${ts.formatDiagnostics(diagnostics, FORMAT_HOST).trim()}`);\n};\n\nconst runProgram = (params: CompileProjectParams): ts.Diagnostic[] => {\n const parsed = ts.parseJsonConfigFileContent(\n {\n compilerOptions: { ...BASE_COMPILER_OPTIONS, ...params.compilerOptions },\n files: params.fileNames.map((name) => `./${name}`),\n },\n ts.sys,\n params.projectDir,\n );\n\n const program = ts.createProgram({\n rootNames: parsed.fileNames,\n options: parsed.options,\n configFileParsingDiagnostics: parsed.errors,\n });\n\n const diagnostics = ts.getPreEmitDiagnostics(program);\n\n if (diagnostics.length > 0) {\n return [...diagnostics];\n }\n\n return [...program.emit().diagnostics];\n};\n\nconst compileProject = (params: CompileProjectParams): void => {\n const unlinkToolingModules = linkToolingModules(params.projectDir);\n\n try {\n const diagnostics = runProgram(params);\n\n if (diagnostics.length > 0) {\n throw diagnosticError(params.label, params.projectDir, diagnostics);\n }\n } finally {\n unlinkToolingModules();\n }\n};\n\nconst checkModules = (params: { modules: SourceModule[]; resolveFrom: string; label: string }): void => {\n const checkRoot = join(params.resolveFrom, \"node_modules\");\n mkdirSync(checkRoot, { recursive: true });\n const projectDir = mkdtempSync(join(checkRoot, \".gtkx-check-\"));\n\n try {\n for (const module of params.modules) {\n const filePath = join(projectDir, module.fileName);\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, module.source);\n }\n\n compileProject({\n projectDir,\n fileNames: params.modules.map((module) => module.fileName),\n compilerOptions: CHECK_OPTIONS,\n label: params.label,\n });\n } finally {\n rmSync(projectDir, { recursive: true, force: true });\n }\n};\n\nexport { compileProject, checkModules, type SourceModule };\n"]}
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;A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AC,SAAS,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAEjD,IAAI,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YACnD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QAED,cAAc,CAAC;YACX,UAAU;YACV,KAAK,EAAE,MAAM,CAAC,OAAO;YACrB,eAAe,EAAE,aAAa;YAC9B,KAAK,EAAE,MAAM,CAAC,KAAK;SACtB,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,iBAAiB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAqB,CAAC","sourcesContent":["import { errorCode, errorMessage, normalizeError } from \"@gtkx/utils\";\nimport { existsSync, mkdirSync, renameSync, rmSync, symlinkSync, writeFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport ts from \"typescript\";\nimport { createStagingDir, sweepStrandedDirs } from \"./staging.js\";\n\ntype ProjectFile = {\n fileName: string;\n origin?: string | undefined;\n};\n\ntype SourceModule = ProjectFile & {\n source: string;\n};\n\ntype ProjectContext = {\n projectDir: string;\n files: ProjectFile[];\n label: string;\n};\n\ntype CompileProjectParams = ProjectContext & {\n compilerOptions: Record<string, unknown>;\n};\n\ntype EmitModulesParams = {\n projectDir: string;\n files: SourceModule[];\n label: string;\n};\n\ntype DiagnosedFile = {\n fileName: string;\n text: string;\n};\n\ntype FailedProjectInput = {\n projectDir: string;\n keepAt: string;\n error: unknown;\n};\n\nconst BASE_COMPILER_OPTIONS = {\n module: \"esnext\",\n moduleResolution: \"bundler\",\n target: \"esnext\",\n lib: [\"esnext\"],\n jsx: \"react-jsx\",\n jsxImportSource: \"react\",\n customConditions: [\"source\"],\n strict: true,\n exactOptionalPropertyTypes: true,\n noUncheckedIndexedAccess: true,\n noImplicitReturns: true,\n noFallthroughCasesInSwitch: true,\n allowUnreachableCode: false,\n allowImportingTsExtensions: true,\n forceConsistentCasingInFileNames: true,\n resolveJsonModule: true,\n rewriteRelativeImportExtensions: true,\n skipLibCheck: true,\n types: [\"node\"],\n};\n\nconst CHECK_OPTIONS = {\n declaration: true,\n isolatedDeclarations: true,\n noEmit: true,\n};\n\nconst DECLARATION_EMIT = {\n declaration: true,\n isolatedDeclarations: true,\n removeComments: false,\n};\n\nconst MODULE_EMIT = {\n removeComments: false,\n};\n\nconst DECLARATION_OPTIONS = ts.convertCompilerOptionsFromJson(\n { ...BASE_COMPILER_OPTIONS, ...DECLARATION_EMIT },\n \".\",\n).options;\n\nconst MODULE_OPTIONS = ts.convertCompilerOptionsFromJson(\n { ...BASE_COMPILER_OPTIONS, ...MODULE_EMIT },\n \".\",\n).options;\n\nconst TS_EXTENSION_PATTERN = /\\.tsx?$/;\nconst DECLARATION_EXTENSION = \".d.ts\";\nconst JAVASCRIPT_EXTENSION = \".js\";\nconst CHECK_DIR = \".gtkx-check\";\nconst FAILED_CHECK_DIR = `${CHECK_DIR}.failed`;\nconst LEGACY_CHECK_PREFIX = `${CHECK_DIR}-`;\nconst ESM_SCOPE_MANIFEST = `${JSON.stringify({ type: \"module\" }, null, 4)}\\n`;\n\nconst FORMAT_HOST: ts.FormatDiagnosticsHost = {\n getCanonicalFileName: (fileName) => fileName,\n getCurrentDirectory: () => ts.sys.getCurrentDirectory(),\n getNewLine: () => \"\\n\",\n};\n\nconst codegenModules = (): string => {\n const sourceDir = dirname(fileURLToPath(import.meta.url));\n\n return join(dirname(sourceDir), \"node_modules\");\n};\n\nconst linkToolingModules = (projectDir: string): (() => void) => {\n const link = join(projectDir, \"node_modules\");\n\n if (existsSync(link)) {\n return (): void => undefined;\n }\n\n symlinkSync(codegenModules(), link, \"junction\");\n\n return () => {\n rmSync(link, { force: true });\n };\n};\n\nconst ensureModuleScope = (projectDir: string): void => {\n try {\n writeFileSync(join(projectDir, \"package.json\"), ESM_SCOPE_MANIFEST, { flag: \"wx\" });\n } catch (error) {\n if (errorCode(error) !== \"EEXIST\") {\n throw error;\n }\n }\n};\n\nconst isProjectFile = (rel: string): boolean =>\n !rel.startsWith(\"..\") && !isAbsolute(rel) && !rel.split(/[/\\\\]/).includes(\"node_modules\");\n\nconst projectDiagnosticFile = (diagnostic: ts.Diagnostic, projectDir: string): DiagnosedFile | undefined => {\n const { file, start } = diagnostic;\n\n if (file === undefined || start === undefined) {\n return undefined;\n }\n\n const fileName = relative(projectDir, file.fileName);\n\n if (!isProjectFile(fileName)) {\n return undefined;\n }\n\n const { line, character } = file.getLineAndCharacterOfPosition(start);\n const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, \"\\n\");\n\n return {\n fileName,\n text: `${fileName}:${String(line + 1)}:${String(character + 1)} - ${message} (TS${String(diagnostic.code)})`,\n };\n};\n\nconst projectDiagnosticFiles = (diagnostics: ts.Diagnostic[], projectDir: string): DiagnosedFile[] => {\n const diagnosed: DiagnosedFile[] = [];\n\n for (const diagnostic of diagnostics) {\n const entry = projectDiagnosticFile(diagnostic, projectDir);\n\n if (entry !== undefined) {\n diagnosed.push(entry);\n }\n }\n\n return diagnosed;\n};\n\nconst collectOrigins = (files: ProjectFile[]): Map<string, string> => {\n const origins: Map<string, string> = new Map();\n\n for (const { fileName, origin } of files) {\n if (origin !== undefined) {\n origins.set(fileName, origin);\n }\n }\n\n return origins;\n};\n\nconst groupByOrigin = (diagnosed: DiagnosedFile[], origins: Map<string, string>): Map<string, Set<string>> => {\n const grouped: Map<string, Set<string>> = new Map();\n\n for (const { fileName } of diagnosed) {\n const origin = origins.get(fileName);\n\n if (origin !== undefined) {\n grouped.set(origin, (grouped.get(origin) ?? new Set<string>()).add(fileName));\n }\n }\n\n return grouped;\n};\n\nconst originLines = (diagnosed: DiagnosedFile[], files: ProjectFile[]): string[] =>\n [...groupByOrigin(diagnosed, collectOrigins(files))].map(\n ([origin, generated]) => `Generated from ${origin}: ${[...generated].join(\", \")}`,\n );\n\nconst diagnosticError = (params: ProjectContext, diagnostics: ts.Diagnostic[]): Error => {\n const diagnosed = projectDiagnosticFiles(diagnostics, params.projectDir);\n const { label } = params;\n\n if (diagnosed.length === 0) {\n return new Error(`Compiling ${label} failed:\\n${ts.formatDiagnostics(diagnostics, FORMAT_HOST).trim()}`);\n }\n\n const lines = [...diagnosed.map((entry) => entry.text), ...originLines(diagnosed, params.files)];\n\n return new Error(`Compiling ${label} found ${String(diagnosed.length)} error(s):\\n${lines.join(\"\\n\")}`);\n};\n\nconst keepFailedProject = (input: FailedProjectInput): Error => {\n const { projectDir, keepAt, error } = input;\n\n if (!existsSync(projectDir)) {\n return normalizeError(error);\n }\n\n rmSync(keepAt, { recursive: true, force: true });\n renameSync(projectDir, keepAt);\n const rebased = errorMessage(error).split(projectDir).join(keepAt);\n\n return new Error(`${rebased}\\nThe generated sources are kept at ${keepAt}, where every path above resolves.`, {\n cause: error,\n });\n};\n\nconst runProgram = (params: CompileProjectParams): ts.Diagnostic[] => {\n const parsed = ts.parseJsonConfigFileContent(\n {\n compilerOptions: { ...BASE_COMPILER_OPTIONS, ...params.compilerOptions },\n files: params.files.map((file) => `./${file.fileName}`),\n },\n ts.sys,\n params.projectDir,\n );\n\n const program = ts.createProgram({\n rootNames: parsed.fileNames,\n options: parsed.options,\n configFileParsingDiagnostics: parsed.errors,\n });\n\n const diagnostics = ts.getPreEmitDiagnostics(program);\n\n if (diagnostics.length > 0) {\n return [...diagnostics];\n }\n\n return [...program.emit().diagnostics];\n};\n\nconst replaceExtension = (fileName: string, extension: string): string =>\n `${fileName.replace(TS_EXTENSION_PATTERN, \"\")}${extension}`;\n\nconst transpileOptions = (compilerOptions: ts.CompilerOptions, fileName: string): ts.TranspileOptions => ({\n compilerOptions,\n fileName,\n reportDiagnostics: true,\n});\n\nconst emitModule = (module: SourceModule, projectDir: string): ts.Diagnostic[] => {\n const fileName = join(projectDir, module.fileName);\n const declaration = ts.transpileDeclaration(module.source, transpileOptions(DECLARATION_OPTIONS, fileName));\n const javascript = ts.transpileModule(module.source, transpileOptions(MODULE_OPTIONS, fileName));\n const diagnostics = [...declaration.diagnostics ?? [], ...javascript.diagnostics ?? []];\n\n if (diagnostics.length > 0) {\n return diagnostics;\n }\n\n writeFileSync(replaceExtension(fileName, DECLARATION_EXTENSION), declaration.outputText);\n writeFileSync(replaceExtension(fileName, JAVASCRIPT_EXTENSION), javascript.outputText);\n\n return [];\n};\n\nconst emitModules = (params: EmitModulesParams): void => {\n const diagnostics: ts.Diagnostic[] = [];\n\n for (const module of params.files) {\n diagnostics.push(...emitModule(module, params.projectDir));\n }\n\n if (diagnostics.length > 0) {\n throw diagnosticError(params, diagnostics);\n }\n};\n\nconst compileProject = (params: CompileProjectParams): void => {\n ensureModuleScope(params.projectDir);\n const unlinkToolingModules = linkToolingModules(params.projectDir);\n\n try {\n const diagnostics = runProgram(params);\n\n if (diagnostics.length > 0) {\n throw diagnosticError(params, diagnostics);\n }\n } finally {\n unlinkToolingModules();\n }\n};\n\nconst stageCheckProject = (checkRoot: string): string => {\n const projectDir = createStagingDir(join(checkRoot, CHECK_DIR));\n sweepStrandedDirs(checkRoot, LEGACY_CHECK_PREFIX);\n\n return projectDir;\n};\n\nconst checkModules = (params: { modules: SourceModule[]; resolveFrom: string; label: string }): void => {\n const checkRoot = join(params.resolveFrom, \"node_modules\");\n const projectDir = stageCheckProject(checkRoot);\n const keepAt = join(checkRoot, FAILED_CHECK_DIR);\n\n try {\n for (const module of params.modules) {\n const filePath = join(projectDir, module.fileName);\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, module.source);\n }\n\n compileProject({\n projectDir,\n files: params.modules,\n compilerOptions: CHECK_OPTIONS,\n label: params.label,\n });\n } catch (error) {\n throw keepFailedProject({ projectDir, keepAt, error });\n }\n\n rmSync(projectDir, { recursive: true, force: true });\n rmSync(keepAt, { recursive: true, force: true });\n};\n\nexport { checkModules, emitModules, keepFailedProject, type SourceModule };\n"]}
|
|
@@ -10,6 +10,8 @@ type ApiReferenceOptions = {
|
|
|
10
10
|
props?: ElementProps;
|
|
11
11
|
/** GObject properties the project omits from generated props; without it pages show props that do not exist. */
|
|
12
12
|
omittedProps?: OmittedProps;
|
|
13
|
+
/** Describes GIR byte sequences as `Uint8Array` rather than `number[]`; defaults to false. */
|
|
14
|
+
isByteArrayTyped?: boolean;
|
|
13
15
|
};
|
|
14
16
|
/** Narrows an `ApiReference.symbols` enumeration. */
|
|
15
17
|
type ApiSymbolQuery = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-reference.d.ts","sourceRoot":"","sources":["../../src/docs/api-reference.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-reference.d.ts","sourceRoot":"","sources":["../../src/docs/api-reference.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,sCAAsC,CAAC;AAE1F,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,+BAA+B,CAAC;AAKnF,uEAAuE;AACvE,KAAK,mBAAmB,GAAG;IACvB,kGAAkG;IAClG,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8CAA8C;IA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;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,eAAe;IAqB5D,gHAAgH;IAChH,OAAO,CAAC,KAAK,GAAE,cAAmB,GAAG,SAAS,EAAE;IAUhD;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,EAAE;IAe9C,mFAAmF;IACnF,UAAU,IAAI,mBAAmB,EAAE;IAWnC;;;OAGG;IACH,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE;IAY5C,uGAAuG;IACvG,QAAQ,IAAI,MAAM;IA2BlB;;;OAGG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAqCtD;AAED,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACtB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sanitizeIdentifier, sanitizeTypeIdentifier, sortStrings, sortStringsBy } from "@gtkx/utils";
|
|
2
|
+
import { isEmittableEntity } from "../gir/emittable.js";
|
|
2
3
|
import { Library } from "../gir/library.js";
|
|
3
4
|
import { namespaceDirectory } from "../gir/namespace.js";
|
|
4
5
|
import { dedupeCallables, isEmittableCallable } from "../store/gi/callables.js";
|
|
@@ -71,11 +72,11 @@ const functionEntry = (namespace, docsContext, fn) => {
|
|
|
71
72
|
return { kind: "function", namespace, name, doc: fn.doc, fn };
|
|
72
73
|
};
|
|
73
74
|
const classEntry = (namespace, klass) => {
|
|
74
|
-
if (!klass
|
|
75
|
+
if (!isEmittableEntity(klass)) {
|
|
75
76
|
return undefined;
|
|
76
77
|
}
|
|
77
78
|
const kind = klass.isInterface ? "interface" : "class";
|
|
78
|
-
return { kind, namespace, name:
|
|
79
|
+
return { kind, namespace, name: sanitizeTypeIdentifier(klass.name), doc: klass.doc, klass };
|
|
79
80
|
};
|
|
80
81
|
const classEntries = (namespace) => {
|
|
81
82
|
const entries = [];
|
|
@@ -88,10 +89,10 @@ const classEntries = (namespace) => {
|
|
|
88
89
|
return entries;
|
|
89
90
|
};
|
|
90
91
|
const recordEntry = (namespace, record) => {
|
|
91
|
-
if (
|
|
92
|
+
if (record.isVtable || !isEmittableEntity(record)) {
|
|
92
93
|
return undefined;
|
|
93
94
|
}
|
|
94
|
-
return { kind: "record", namespace, name: record.name, doc: record.doc, record };
|
|
95
|
+
return { kind: "record", namespace, name: sanitizeTypeIdentifier(record.name), doc: record.doc, record };
|
|
95
96
|
};
|
|
96
97
|
const recordEntries = (namespace) => {
|
|
97
98
|
const entries = [];
|
|
@@ -109,7 +110,7 @@ const valueEntries = (namespace) => [
|
|
|
109
110
|
.map((enumeration) => ({
|
|
110
111
|
kind: "enum",
|
|
111
112
|
namespace,
|
|
112
|
-
name: enumeration.name,
|
|
113
|
+
name: sanitizeTypeIdentifier(enumeration.name),
|
|
113
114
|
doc: enumeration.doc,
|
|
114
115
|
enumeration,
|
|
115
116
|
})),
|
|
@@ -118,21 +119,21 @@ const valueEntries = (namespace) => [
|
|
|
118
119
|
.map((callback) => ({
|
|
119
120
|
kind: "callback",
|
|
120
121
|
namespace,
|
|
121
|
-
name: callback.name,
|
|
122
|
+
name: sanitizeTypeIdentifier(callback.name),
|
|
122
123
|
doc: callback.doc,
|
|
123
124
|
callback,
|
|
124
125
|
})),
|
|
125
126
|
...namespace.aliases.map((alias) => ({
|
|
126
127
|
kind: "alias",
|
|
127
128
|
namespace,
|
|
128
|
-
name: alias.name,
|
|
129
|
+
name: sanitizeTypeIdentifier(alias.name),
|
|
129
130
|
doc: alias.doc,
|
|
130
131
|
alias,
|
|
131
132
|
})),
|
|
132
133
|
...namespace.constants.map((constant) => ({
|
|
133
134
|
kind: "constant",
|
|
134
135
|
namespace,
|
|
135
|
-
name: constant.name,
|
|
136
|
+
name: sanitizeIdentifier(constant.name),
|
|
136
137
|
doc: constant.doc,
|
|
137
138
|
constant,
|
|
138
139
|
})),
|
|
@@ -190,7 +191,7 @@ class ApiReference {
|
|
|
190
191
|
this.libraries = options.libraries;
|
|
191
192
|
this.props = options.props ?? {};
|
|
192
193
|
this.omittedProps = options.omittedProps ?? {};
|
|
193
|
-
this.library = Library.load(options.libraries, options.girPath);
|
|
194
|
+
this.library = Library.load(options.libraries, options.girPath, options.isByteArrayTyped === true);
|
|
194
195
|
this.elementContext = { library: this.library, linkFor: () => undefined };
|
|
195
196
|
this.buildIndex();
|
|
196
197
|
}
|