@gtkx/codegen 1.0.0-rc.2 → 1.0.0-rc.3
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/dist/analysis/descriptor-render.d.ts +2 -0
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +25 -4
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +4 -8
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +4 -8
- 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 -4
- package/dist/docs/element-page.js.map +1 -1
- package/dist/docs/pipeline.d.ts +2 -0
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +2 -0
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/fingerprint.d.ts +1 -0
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +3 -0
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +7 -2
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +4 -2
- package/dist/gi.js.map +1 -1
- package/dist/gir/libraries.d.ts +4 -3
- package/dist/gir/libraries.d.ts.map +1 -1
- package/dist/gir/libraries.js +2 -1
- package/dist/gir/libraries.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx.d.ts +2 -0
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +4 -0
- package/dist/jsx.js.map +1 -1
- package/dist/react/element-config.d.ts +3 -0
- package/dist/react/element-config.d.ts.map +1 -1
- package/dist/react/element-config.js +4 -1
- package/dist/react/element-config.js.map +1 -1
- package/dist/runner.d.ts +2 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +4 -1
- package/dist/runner.js.map +1 -1
- package/dist/store/gi/callables.d.ts.map +1 -1
- package/dist/store/gi/callables.js +0 -5
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +0 -2
- 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 +1 -0
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +5 -4
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +2 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +22 -6
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record.d.ts.map +1 -1
- package/dist/store/gi/record.js +0 -7
- package/dist/store/gi/record.js.map +1 -1
- package/dist/store/gi/value-marshalable.d.ts +15 -0
- package/dist/store/gi/value-marshalable.d.ts.map +1 -0
- package/dist/store/gi/value-marshalable.js +66 -0
- package/dist/store/gi/value-marshalable.js.map +1 -0
- package/dist/store/jsx/intrinsic-elements.d.ts +1 -2
- package/dist/store/jsx/intrinsic-elements.d.ts.map +1 -1
- package/dist/store/jsx/intrinsic-elements.js +1 -2
- package/dist/store/jsx/intrinsic-elements.js.map +1 -1
- package/dist/store/jsx/omitted-props.d.ts +10 -0
- package/dist/store/jsx/omitted-props.d.ts.map +1 -0
- package/dist/store/jsx/omitted-props.js +22 -0
- package/dist/store/jsx/omitted-props.js.map +1 -0
- package/dist/store/jsx/pipeline.d.ts +2 -0
- package/dist/store/jsx/pipeline.d.ts.map +1 -1
- package/dist/store/jsx/pipeline.js +2 -0
- package/dist/store/jsx/pipeline.js.map +1 -1
- package/dist/store/jsx/props.d.ts +1 -1
- package/dist/store/jsx/props.d.ts.map +1 -1
- package/dist/store/jsx/props.js +6 -11
- package/dist/store/jsx/props.js.map +1 -1
- package/package.json +3 -4
- package/src/analysis/descriptor-render.ts +35 -3
- package/src/analysis/ts-type.ts +4 -11
- package/src/docs/api-reference.ts +4 -9
- package/src/docs/element-page.ts +5 -9
- package/src/docs/pipeline.ts +3 -0
- package/src/fingerprint.ts +16 -2
- package/src/gi.ts +12 -3
- package/src/gir/libraries.ts +5 -4
- package/src/index.ts +1 -0
- package/src/jsx.ts +5 -0
- package/src/react/element-config.ts +8 -2
- package/src/runner.ts +8 -1
- package/src/store/gi/callables.ts +0 -6
- package/src/store/gi/function.ts +0 -2
- package/src/store/gi/method.ts +1 -0
- package/src/store/gi/record-constructor.ts +9 -4
- package/src/store/gi/record-field-accessor.ts +41 -6
- package/src/store/gi/record.ts +0 -9
- package/src/store/gi/value-marshalable.ts +96 -0
- package/src/store/jsx/intrinsic-elements.ts +0 -9
- package/src/store/jsx/omitted-props.ts +32 -0
- package/src/store/jsx/pipeline.ts +3 -0
- package/src/store/jsx/props.ts +6 -18
- package/dist/store/gi/class-struct-record.d.ts +0 -10
- package/dist/store/gi/class-struct-record.d.ts.map +0 -1
- package/dist/store/gi/class-struct-record.js +0 -52
- package/dist/store/gi/class-struct-record.js.map +0 -1
- package/src/store/gi/class-struct-record.ts +0 -72
|
@@ -5,6 +5,7 @@ import { isConstructableProperty } from "../gir/property.js";
|
|
|
5
5
|
import { elementPropTypeFor } from "../store/jsx/element-prop-imports.js";
|
|
6
6
|
import { buildGirIndex } from "../store/jsx/gir-index.js";
|
|
7
7
|
import { getGlibName, implementedInterfaces, newlyImplementedInterfaces, signalHandlerName, } from "../store/jsx/intrinsic-elements.js";
|
|
8
|
+
import { isOmittedProp } from "../store/jsx/omitted-props.js";
|
|
8
9
|
import { isObjectProp } from "../store/jsx/props.js";
|
|
9
10
|
import { classMethodEntries, docMarkdown, docsDefaultValue, firstSentence, implementsLine, joinSections, metaBlock, methodsSectionBlocks, originSignatureBlocks, renderDocsSignalSignature, renderDocsType, } from "./render.js";
|
|
10
11
|
const createElementPageContext = (library, linkFor) => ({ library, girIndex: buildGirIndex(library), linkFor });
|
|
@@ -43,7 +44,7 @@ const memberOwners = (entry, context) => [
|
|
|
43
44
|
}),
|
|
44
45
|
];
|
|
45
46
|
const propertyEntry = (context, owner, property, jsName) => {
|
|
46
|
-
const isObject = isObjectProp(
|
|
47
|
+
const isObject = isObjectProp(context.library, property);
|
|
47
48
|
const baseType = renderDocsType(context.library, property.type, false);
|
|
48
49
|
const type = isObject ? `${baseType} | ReactElement` : baseType;
|
|
49
50
|
const meta = [`\`${type}\``];
|
|
@@ -61,12 +62,12 @@ const propertyEntry = (context, owner, property, jsName) => {
|
|
|
61
62
|
}
|
|
62
63
|
return { name: jsName, meta: meta.join(" · "), doc: docMarkdown(property.doc) };
|
|
63
64
|
};
|
|
64
|
-
const propJsName = (property, seen) => {
|
|
65
|
+
const propJsName = (property, owner, seen) => {
|
|
65
66
|
if (!property.introspectable) {
|
|
66
67
|
return undefined;
|
|
67
68
|
}
|
|
68
69
|
const jsName = toCamelIdentifier(property.name);
|
|
69
|
-
if (seen.has(jsName)) {
|
|
70
|
+
if (seen.has(jsName) || isOmittedProp(owner.glibName, jsName)) {
|
|
70
71
|
return undefined;
|
|
71
72
|
}
|
|
72
73
|
seen.add(jsName);
|
|
@@ -75,7 +76,7 @@ const propJsName = (property, seen) => {
|
|
|
75
76
|
const ownerPropEntries = (context, owner, seen) => {
|
|
76
77
|
const entries = [];
|
|
77
78
|
for (const property of owner.klass.properties) {
|
|
78
|
-
const jsName = propJsName(property, seen);
|
|
79
|
+
const jsName = propJsName(property, owner, seen);
|
|
79
80
|
if (jsName !== undefined) {
|
|
80
81
|
entries.push(propertyEntry(context, owner, property, jsName));
|
|
81
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-page.js","sourceRoot":"","sources":["../../src/docs/element-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,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/D,OAAO,YAAY,CAAC;QAChB,WAAW,CAAC,KAAK,CAAC;QAClB,KAAK,KAAK,CAAC,QAAQ,EAAE;QACrB,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QAC5B,WAAW,CAAC,KAAK,CAAC;QAClB,GAAG,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC;QACnC,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;QACzC,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;QAC3C,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;KAC9C,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAA2B,CAAC","sourcesContent":["import { sortStringsBy, toCamelIdentifier, upperFirst } from \"@gtkx/utils\";\nimport type { GirClass } from \"../gir/class.js\";\nimport type { Library } from \"../gir/library.js\";\nimport { ancestorChain } from \"../gir/ancestry.js\";\nimport { type GirNamespace, namespaceDirectory } from \"../gir/namespace.js\";\nimport { type GirProperty, isConstructableProperty } from \"../gir/property.js\";\nimport { elementPropTypeFor } from \"../store/jsx/element-prop-imports.js\";\nimport { buildGirIndex, type GirIndex } from \"../store/jsx/gir-index.js\";\nimport {\n getGlibName,\n type GlibNamedClass,\n implementedInterfaces,\n newlyImplementedInterfaces,\n signalHandlerName,\n} from \"../store/jsx/intrinsic-elements.js\";\nimport { isObjectProp } from \"../store/jsx/props.js\";\nimport {\n classMethodEntries,\n docMarkdown,\n docsDefaultValue,\n firstSentence,\n implementsLine,\n joinSections,\n metaBlock,\n methodsSectionBlocks,\n originSignatureBlocks,\n renderDocsSignalSignature,\n renderDocsType,\n} from \"./render.js\";\n\ntype ElementPageContext = {\n library: Library;\n girIndex: GirIndex;\n linkFor: (glibName: string) => string | undefined;\n};\n\ntype MemberOwner = {\n klass: GirClass;\n namespace: GirNamespace;\n origin: string | undefined;\n glibName: string | undefined;\n};\n\ntype PropEntry = {\n name: string;\n meta: string;\n doc: string;\n};\n\ntype SignalEntry = {\n name: string;\n signature: string;\n doc: string;\n origin: string | undefined;\n};\n\nconst createElementPageContext = (\n library: Library,\n linkFor: (glibName: string) => string | undefined,\n): ElementPageContext => ({ library, girIndex: buildGirIndex(library), linkFor });\n\nconst frontmatter = (entry: GlibNamedClass): string => {\n const sentence = firstSentence(entry.klass.doc);\n const description = sentence.length > 0 ? sentence : `API reference for the ${entry.glibName} element.`;\n\n return `---\\ndescription: ${JSON.stringify(description)}\\n---`;\n};\n\nconst importBlock = (entry: GlibNamedClass): string =>\n `\\`\\`\\`tsx\\nimport { ${entry.glibName} } from \"@gtkx/jsx/${namespaceDirectory(entry.namespace)}\";\\n\\`\\`\\``;\n\nconst glibLabel = (context: ElementPageContext, glibName: string): string => {\n const link = context.linkFor(glibName);\n\n return link === undefined ? `\\`${glibName}\\`` : `[${glibName}](${link})`;\n};\n\nconst hierarchySection = (entry: GlibNamedClass, context: ElementPageContext): string[] => {\n const ancestors = [...ancestorChain(context.library, entry.klass, entry.namespace.name)].slice(1).toReversed();\n\n if (ancestors.length === 0) {\n return [];\n }\n\n const parts = ancestors.map((ancestor) => {\n const glib = getGlibName(ancestor.klass);\n\n return glib === undefined ? `\\`${ancestor.namespaceName}.${ancestor.klass.name}\\`` : glibLabel(context, glib);\n });\n\n parts.push(`**${entry.glibName}**`);\n const lines = [\"## Hierarchy\", parts.join(\" → \")];\n\n const interfaces = implementedInterfaces(entry.klass, entry.namespace, context.library)\n .map((iface) => getGlibName(iface.klass))\n .filter((name): name is string => name !== undefined);\n\n lines.push(...implementsLine(interfaces));\n\n return lines;\n};\n\nconst memberOwners = (entry: GlibNamedClass, context: ElementPageContext): MemberOwner[] => [\n { klass: entry.klass, namespace: entry.namespace, origin: undefined, glibName: entry.glibName },\n ...newlyImplementedInterfaces(\n entry.klass,\n entry.namespace,\n context.library,\n (glibName) => glibName !== undefined && elementPropTypeFor(glibName) !== undefined,\n ).map((iface) => {\n const glibName = getGlibName(iface.klass);\n\n return { klass: iface.klass, namespace: iface.namespace, origin: glibName, glibName };\n }),\n];\n\nconst propertyEntry = (\n context: ElementPageContext,\n owner: MemberOwner,\n property: GirProperty,\n jsName: string,\n): PropEntry => {\n const isObject = isObjectProp(\n { library: context.library, klass: owner.klass, namespace: owner.namespace },\n property,\n jsName,\n );\n\n const baseType = renderDocsType(context.library, property.type, false);\n const type = isObject ? `${baseType} | ReactElement` : baseType;\n const meta: string[] = [`\\`${type}\\``];\n\n if (property.defaultValue !== undefined) {\n meta.push(`default \\`${docsDefaultValue(property.defaultValue)}\\``);\n }\n\n if (property.constructOnly) {\n meta.push(\"construct-only\");\n }\n\n if (!isConstructableProperty(property)) {\n meta.push(`read-only, observe with \\`onNotify${upperFirst(jsName)}\\``);\n }\n\n if (owner.origin !== undefined) {\n meta.push(`from \\`${owner.origin}\\``);\n }\n\n return { name: jsName, meta: meta.join(\" · \"), doc: docMarkdown(property.doc) };\n};\n\nconst propJsName = (property: GirProperty, seen: Set<string>): string | undefined => {\n if (!property.introspectable) {\n return undefined;\n }\n\n const jsName = toCamelIdentifier(property.name);\n\n if (seen.has(jsName)) {\n return undefined;\n }\n\n seen.add(jsName);\n\n return jsName;\n};\n\nconst ownerPropEntries = (context: ElementPageContext, owner: MemberOwner, seen: Set<string>): PropEntry[] => {\n const entries: PropEntry[] = [];\n\n for (const property of owner.klass.properties) {\n const jsName = propJsName(property, seen);\n\n if (jsName !== undefined) {\n entries.push(propertyEntry(context, owner, property, jsName));\n }\n }\n\n return entries;\n};\n\nconst propertyEntries = (entry: GlibNamedClass, context: ElementPageContext, seen: Set<string>): PropEntry[] => {\n const entries: PropEntry[] = [];\n\n for (const owner of memberOwners(entry, context)) {\n entries.push(...ownerPropEntries(context, owner, seen));\n }\n\n return entries;\n};\n\nconst propsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {\n const seen: Set<string> = new Set();\n const entries = propertyEntries(entry, context, seen);\n\n const intro = [\n `\\`ref\\` receives the \\`${selfType}\\` instance.`,\n \"Every mutable property also has an `onNotify<Prop>` handler prop called with the new value \" +\n \"when the property changes.\",\n \"Props inherited from ancestor elements are documented on their own pages.\",\n ].join(\" \");\n\n if (entries.length === 0) {\n return [\"## Props\", intro];\n }\n\n const sorted = sortStringsBy(entries, (item) => item.name);\n\n return [\"## Props\", intro, ...sorted.map((item) => metaBlock(item.name, item.meta, item.doc))];\n};\n\nconst ownerSignalEntries = (\n context: ElementPageContext,\n owner: MemberOwner,\n selfType: string,\n seen: Set<string>,\n): SignalEntry[] => {\n const entries: SignalEntry[] = [];\n\n for (const signal of owner.klass.signals) {\n const name = signalHandlerName(signal.name);\n\n if (seen.has(name)) {\n continue;\n }\n\n seen.add(name);\n\n entries.push({\n name,\n signature: renderDocsSignalSignature(context.library, signal, selfType),\n doc: docMarkdown(signal.doc),\n origin: owner.origin,\n });\n }\n\n return entries;\n};\n\nconst signalsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {\n const seen: Set<string> = new Set();\n const entries: SignalEntry[] = [];\n\n for (const owner of memberOwners(entry, context)) {\n entries.push(...ownerSignalEntries(context, owner, selfType, seen));\n }\n\n if (entries.length === 0) {\n return [];\n }\n\n return [\"## Signals\", ...originSignatureBlocks(entries)];\n};\n\nconst methodsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {\n const entries = classMethodEntries(context.library, entry.namespace, entry.klass);\n const importPath = `@gtkx/gi/${namespaceDirectory(entry.namespace)}`;\n\n const intro =\n `Methods are called on the \\`${selfType}\\` instance, obtained with the \\`ref\\` prop or ` +\n `imported from \\`${importPath}\\`. Methods inherited from ancestors are documented on their own pages.`;\n\n return methodsSectionBlocks(entries, intro);\n};\n\nconst renderElementPage = (entry: GlibNamedClass, context: ElementPageContext): string => {\n const selfType = `${entry.namespace.name}.${entry.klass.name}`;\n\n return joinSections([\n frontmatter(entry),\n `# ${entry.glibName}`,\n docMarkdown(entry.klass.doc),\n importBlock(entry),\n ...hierarchySection(entry, context),\n ...propsSection(entry, context, selfType),\n ...signalsSection(entry, context, selfType),\n ...methodsSection(entry, context, selfType),\n ]);\n};\n\nexport { createElementPageContext, renderElementPage, type ElementPageContext };\n"]}
|
|
1
|
+
{"version":3,"file":"element-page.js","sourceRoot":"","sources":["../../src/docs/element-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAqB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAoB,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAiB,MAAM,2BAA2B,CAAC;AACzE,OAAO,EACH,WAAW,EAEX,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACH,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,GACjB,MAAM,aAAa,CAAC;AA4BrB,MAAM,wBAAwB,GAAG,CAC7B,OAAgB,EAChB,OAAiD,EAC/B,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAElF,MAAM,WAAW,GAAG,CAAC,KAAqB,EAAU,EAAE;IAClD,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,KAA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,GACP,+BAA+B,QAAQ,iDAAiD;QACxF,mBAAmB,UAAU,yEAAyE,CAAC;IAE3G,OAAO,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAE,OAA2B,EAAU,EAAE;IACrF,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAE/D,OAAO,YAAY,CAAC;QAChB,WAAW,CAAC,KAAK,CAAC;QAClB,KAAK,KAAK,CAAC,QAAQ,EAAE;QACrB,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QAC5B,WAAW,CAAC,KAAK,CAAC;QAClB,GAAG,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC;QACnC,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;QACzC,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;QAC3C,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;KAC9C,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAA2B,CAAC","sourcesContent":["import { sortStringsBy, toCamelIdentifier, upperFirst } from \"@gtkx/utils\";\nimport type { GirClass } from \"../gir/class.js\";\nimport type { Library } from \"../gir/library.js\";\nimport { ancestorChain } from \"../gir/ancestry.js\";\nimport { type GirNamespace, namespaceDirectory } from \"../gir/namespace.js\";\nimport { type GirProperty, isConstructableProperty } from \"../gir/property.js\";\nimport { elementPropTypeFor } from \"../store/jsx/element-prop-imports.js\";\nimport { buildGirIndex, type GirIndex } from \"../store/jsx/gir-index.js\";\nimport {\n getGlibName,\n type GlibNamedClass,\n implementedInterfaces,\n newlyImplementedInterfaces,\n signalHandlerName,\n} from \"../store/jsx/intrinsic-elements.js\";\nimport { isOmittedProp } from \"../store/jsx/omitted-props.js\";\nimport { isObjectProp } from \"../store/jsx/props.js\";\nimport {\n classMethodEntries,\n docMarkdown,\n docsDefaultValue,\n firstSentence,\n implementsLine,\n joinSections,\n metaBlock,\n methodsSectionBlocks,\n originSignatureBlocks,\n renderDocsSignalSignature,\n renderDocsType,\n} from \"./render.js\";\n\ntype ElementPageContext = {\n library: Library;\n girIndex: GirIndex;\n linkFor: (glibName: string) => string | undefined;\n};\n\ntype MemberOwner = {\n klass: GirClass;\n namespace: GirNamespace;\n origin: string | undefined;\n glibName: string | undefined;\n};\n\ntype PropEntry = {\n name: string;\n meta: string;\n doc: string;\n};\n\ntype SignalEntry = {\n name: string;\n signature: string;\n doc: string;\n origin: string | undefined;\n};\n\nconst createElementPageContext = (\n library: Library,\n linkFor: (glibName: string) => string | undefined,\n): ElementPageContext => ({ library, girIndex: buildGirIndex(library), linkFor });\n\nconst frontmatter = (entry: GlibNamedClass): string => {\n const sentence = firstSentence(entry.klass.doc);\n const description = sentence.length > 0 ? sentence : `API reference for the ${entry.glibName} element.`;\n\n return `---\\ndescription: ${JSON.stringify(description)}\\n---`;\n};\n\nconst importBlock = (entry: GlibNamedClass): string =>\n `\\`\\`\\`tsx\\nimport { ${entry.glibName} } from \"@gtkx/jsx/${namespaceDirectory(entry.namespace)}\";\\n\\`\\`\\``;\n\nconst glibLabel = (context: ElementPageContext, glibName: string): string => {\n const link = context.linkFor(glibName);\n\n return link === undefined ? `\\`${glibName}\\`` : `[${glibName}](${link})`;\n};\n\nconst hierarchySection = (entry: GlibNamedClass, context: ElementPageContext): string[] => {\n const ancestors = [...ancestorChain(context.library, entry.klass, entry.namespace.name)].slice(1).toReversed();\n\n if (ancestors.length === 0) {\n return [];\n }\n\n const parts = ancestors.map((ancestor) => {\n const glib = getGlibName(ancestor.klass);\n\n return glib === undefined ? `\\`${ancestor.namespaceName}.${ancestor.klass.name}\\`` : glibLabel(context, glib);\n });\n\n parts.push(`**${entry.glibName}**`);\n const lines = [\"## Hierarchy\", parts.join(\" → \")];\n\n const interfaces = implementedInterfaces(entry.klass, entry.namespace, context.library)\n .map((iface) => getGlibName(iface.klass))\n .filter((name): name is string => name !== undefined);\n\n lines.push(...implementsLine(interfaces));\n\n return lines;\n};\n\nconst memberOwners = (entry: GlibNamedClass, context: ElementPageContext): MemberOwner[] => [\n { klass: entry.klass, namespace: entry.namespace, origin: undefined, glibName: entry.glibName },\n ...newlyImplementedInterfaces(\n entry.klass,\n entry.namespace,\n context.library,\n (glibName) => glibName !== undefined && elementPropTypeFor(glibName) !== undefined,\n ).map((iface) => {\n const glibName = getGlibName(iface.klass);\n\n return { klass: iface.klass, namespace: iface.namespace, origin: glibName, glibName };\n }),\n];\n\nconst propertyEntry = (\n context: ElementPageContext,\n owner: MemberOwner,\n property: GirProperty,\n jsName: string,\n): PropEntry => {\n const isObject = isObjectProp(context.library, property);\n const baseType = renderDocsType(context.library, property.type, false);\n const type = isObject ? `${baseType} | ReactElement` : baseType;\n const meta: string[] = [`\\`${type}\\``];\n\n if (property.defaultValue !== undefined) {\n meta.push(`default \\`${docsDefaultValue(property.defaultValue)}\\``);\n }\n\n if (property.constructOnly) {\n meta.push(\"construct-only\");\n }\n\n if (!isConstructableProperty(property)) {\n meta.push(`read-only, observe with \\`onNotify${upperFirst(jsName)}\\``);\n }\n\n if (owner.origin !== undefined) {\n meta.push(`from \\`${owner.origin}\\``);\n }\n\n return { name: jsName, meta: meta.join(\" · \"), doc: docMarkdown(property.doc) };\n};\n\nconst propJsName = (property: GirProperty, owner: MemberOwner, seen: Set<string>): string | undefined => {\n if (!property.introspectable) {\n return undefined;\n }\n\n const jsName = toCamelIdentifier(property.name);\n\n if (seen.has(jsName) || isOmittedProp(owner.glibName, jsName)) {\n return undefined;\n }\n\n seen.add(jsName);\n\n return jsName;\n};\n\nconst ownerPropEntries = (context: ElementPageContext, owner: MemberOwner, seen: Set<string>): PropEntry[] => {\n const entries: PropEntry[] = [];\n\n for (const property of owner.klass.properties) {\n const jsName = propJsName(property, owner, seen);\n\n if (jsName !== undefined) {\n entries.push(propertyEntry(context, owner, property, jsName));\n }\n }\n\n return entries;\n};\n\nconst propertyEntries = (entry: GlibNamedClass, context: ElementPageContext, seen: Set<string>): PropEntry[] => {\n const entries: PropEntry[] = [];\n\n for (const owner of memberOwners(entry, context)) {\n entries.push(...ownerPropEntries(context, owner, seen));\n }\n\n return entries;\n};\n\nconst propsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {\n const seen: Set<string> = new Set();\n const entries = propertyEntries(entry, context, seen);\n\n const intro = [\n `\\`ref\\` receives the \\`${selfType}\\` instance.`,\n \"Every mutable property also has an `onNotify<Prop>` handler prop called with the new value \" +\n \"when the property changes.\",\n \"Props inherited from ancestor elements are documented on their own pages.\",\n ].join(\" \");\n\n if (entries.length === 0) {\n return [\"## Props\", intro];\n }\n\n const sorted = sortStringsBy(entries, (item) => item.name);\n\n return [\"## Props\", intro, ...sorted.map((item) => metaBlock(item.name, item.meta, item.doc))];\n};\n\nconst ownerSignalEntries = (\n context: ElementPageContext,\n owner: MemberOwner,\n selfType: string,\n seen: Set<string>,\n): SignalEntry[] => {\n const entries: SignalEntry[] = [];\n\n for (const signal of owner.klass.signals) {\n const name = signalHandlerName(signal.name);\n\n if (seen.has(name)) {\n continue;\n }\n\n seen.add(name);\n\n entries.push({\n name,\n signature: renderDocsSignalSignature(context.library, signal, selfType),\n doc: docMarkdown(signal.doc),\n origin: owner.origin,\n });\n }\n\n return entries;\n};\n\nconst signalsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {\n const seen: Set<string> = new Set();\n const entries: SignalEntry[] = [];\n\n for (const owner of memberOwners(entry, context)) {\n entries.push(...ownerSignalEntries(context, owner, selfType, seen));\n }\n\n if (entries.length === 0) {\n return [];\n }\n\n return [\"## Signals\", ...originSignatureBlocks(entries)];\n};\n\nconst methodsSection = (entry: GlibNamedClass, context: ElementPageContext, selfType: string): string[] => {\n const entries = classMethodEntries(context.library, entry.namespace, entry.klass);\n const importPath = `@gtkx/gi/${namespaceDirectory(entry.namespace)}`;\n\n const intro =\n `Methods are called on the \\`${selfType}\\` instance, obtained with the \\`ref\\` prop or ` +\n `imported from \\`${importPath}\\`. Methods inherited from ancestors are documented on their own pages.`;\n\n return methodsSectionBlocks(entries, intro);\n};\n\nconst renderElementPage = (entry: GlibNamedClass, context: ElementPageContext): string => {\n const selfType = `${entry.namespace.name}.${entry.klass.name}`;\n\n return joinSections([\n frontmatter(entry),\n `# ${entry.glibName}`,\n docMarkdown(entry.klass.doc),\n importBlock(entry),\n ...hierarchySection(entry, context),\n ...propsSection(entry, context, selfType),\n ...signalsSection(entry, context, selfType),\n ...methodsSection(entry, context, selfType),\n ]);\n};\n\nexport { createElementPageContext, renderElementPage, type ElementPageContext };\n"]}
|
package/dist/docs/pipeline.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ElementProps } from "../store/jsx/element-prop-imports.js";
|
|
2
|
+
import { type OmittedProps } from "../store/jsx/omitted-props.js";
|
|
2
3
|
type DocsElementLink = {
|
|
3
4
|
text: string;
|
|
4
5
|
link: string;
|
|
@@ -15,6 +16,7 @@ type DocsOptions = {
|
|
|
15
16
|
outDir: string;
|
|
16
17
|
basePath?: string;
|
|
17
18
|
props?: ElementProps;
|
|
19
|
+
omitProps?: OmittedProps;
|
|
18
20
|
force?: boolean;
|
|
19
21
|
};
|
|
20
22
|
type DocsResult = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/docs/pipeline.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/docs/pipeline.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,sCAAsC,CAAC;AAE1F,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,+BAA+B,CAAC;AAInF,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,aAAa,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAC;AAEF,KAAK,WAAW,GAAG;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAcF,KAAK,UAAU,GAAG;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,aAAa,EAAE,CAAC;CAC/B,CAAC;AAuKF,QAAA,MAAM,SAAS,GAAI,SAAS,WAAW,KAAG,UAyBzC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,CAAC"}
|
package/dist/docs/pipeline.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Library } from "../gir/library.js";
|
|
|
6
6
|
import { namespaceDirectory } from "../gir/namespace.js";
|
|
7
7
|
import { setElementProps } from "../store/jsx/element-prop-imports.js";
|
|
8
8
|
import { collectIntrinsicElementClasses } from "../store/jsx/intrinsic-elements.js";
|
|
9
|
+
import { setOmittedProps } from "../store/jsx/omitted-props.js";
|
|
9
10
|
import { createElementPageContext, renderElementPage } from "./element-page.js";
|
|
10
11
|
import { elementSlug, firstSentence, namespaceOrder } from "./render.js";
|
|
11
12
|
const MANIFEST_FILENAME = "manifest.json";
|
|
@@ -136,6 +137,7 @@ const writePages = (outDir, pages) => {
|
|
|
136
137
|
};
|
|
137
138
|
const writeDocs = (options) => {
|
|
138
139
|
setElementProps(options.props ?? {});
|
|
140
|
+
setOmittedProps(options.omitProps ?? {});
|
|
139
141
|
const basePath = options.basePath ?? "/reference";
|
|
140
142
|
const manifestPath = join(options.outDir, MANIFEST_FILENAME);
|
|
141
143
|
const cached = cachedDocsResult(options, manifestPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/docs/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAqB,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,8BAA8B,EAAuB,MAAM,oCAAoC,CAAC;AACzG,OAAO,EAAE,wBAAwB,EAA2B,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAwCzE,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C,MAAM,kBAAkB,GAAG,CAAC,SAAwB,EAAE,QAA0B,EAAU,EAAE;IACxF,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAA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C,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAEvD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxE,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAiB,EAAE,UAAU,EAAE,CAAC;IAC9C,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtD,aAAa,CACT,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC1C,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAC7F,CAAC;IAEF,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC7C,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAA+E,CAAC","sourcesContent":["import { sortStringsBy } from \"@gtkx/utils\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { computeGiFingerprint, FINGERPRINT_FILENAME, isGiStoreFresh } from \"../fingerprint.js\";\nimport { Library } from \"../gir/library.js\";\nimport { namespaceDirectory } from \"../gir/namespace.js\";\nimport { type ElementProps, setElementProps } from \"../store/jsx/element-prop-imports.js\";\nimport { collectIntrinsicElementClasses, type GlibNamedClass } from \"../store/jsx/intrinsic-elements.js\";\nimport { createElementPageContext, type ElementPageContext, renderElementPage } from \"./element-page.js\";\nimport { elementSlug, firstSentence, namespaceOrder } from \"./render.js\";\n\ntype DocsElementLink = {\n text: string;\n link: string;\n};\n\ntype DocsNamespace = {\n name: string;\n directory: string;\n link: string;\n elements: DocsElementLink[];\n};\n\ntype DocsOptions = {\n libraries: string[];\n girPath: string[];\n outDir: string;\n basePath?: string;\n props?: ElementProps;\n force?: boolean;\n};\n\ntype DocsManifest = {\n namespaces: DocsNamespace[];\n};\n\ntype GeneratedDocs = {\n pages: { path: string; content: string }[];\n namespaces: DocsNamespace[];\n};\n\ntype Page = { path: string; content: string };\ntype NamespacePages = { docs: DocsNamespace; pages: Page[] };\n\ntype DocsResult = {\n regenerated: boolean;\n namespaces: DocsNamespace[];\n};\n\nconst MANIFEST_FILENAME = \"manifest.json\";\n\nconst namespaceIndexPage = (namespace: DocsNamespace, elements: GlibNamedClass[]): string => {\n const rows = elements.map((entry, index) => {\n const link = namespace.elements[index]?.link ?? \"\";\n const description = firstSentence(entry.klass.doc).replaceAll(\"|\", String.raw`\\|`);\n\n return `| [${entry.glibName}](${link}) | ${description} |`;\n });\n\n const description =\n `Reference pages for the ${String(namespace.elements.length)} JSX elements in ` +\n `the ${namespace.name} namespace.`;\n\n return [\n \"---\",\n `description: ${JSON.stringify(description)}`,\n \"---\",\n \"\",\n `# ${namespace.name} elements`,\n \"\",\n `Elements in this namespace are imported from \\`@gtkx/jsx/${namespace.directory}\\`; the matching ` +\n `classes, enums, and functions are imported from \\`@gtkx/gi/${namespace.directory}\\`.`,\n \"\",\n \"| Element | Description |\",\n \"| --- | --- |\",\n ...rows,\n \"\",\n ].join(\"\\n\");\n};\n\nconst rootIndexPage = (namespaces: DocsNamespace[], libraries: string[]): string => {\n const rows = namespaces.map(\n (ns) => `| [${ns.name}](${ns.link}) | \\`@gtkx/jsx/${ns.directory}\\` | ${String(ns.elements.length)} |`,\n );\n\n const librariesList = libraries.map((library) => `\\`${library}\\``).join(\", \");\n\n return [\n \"---\",\n \"description: \\\"Generated reference documentation for every JSX element in this project's GIR libraries.\\\"\",\n \"---\",\n \"\",\n \"# Element Reference\",\n \"\",\n \"This reference documents every JSX element generated from the GObject-Introspection data for \" +\n `${librariesList}, together with the namespaces they pull in. It is produced by \\`gtkx docs\\` ` +\n \"using the same pipeline that generates the `@gtkx/jsx` and `@gtkx/gi` bindings, so every page \" +\n \"matches the types your editor sees.\",\n \"\",\n \"Each element page lists:\",\n \"\",\n \"- **Props** derived from GObject properties, plus the element props GTKX adds (such as `children` \" +\n \"and named slots), with types, defaults, and upstream documentation.\",\n \"- **Signals** as `on<Signal>` handler props with their exact handler signatures.\",\n \"- **Methods** available on the underlying instance through the `ref` prop.\",\n \"\",\n \"## Namespaces\",\n \"\",\n \"| Namespace | Import | Elements |\",\n \"| --- | --- | --- |\",\n ...rows,\n \"\",\n ].join(\"\\n\");\n};\n\nconst groupElementsByNamespace = (elements: GlibNamedClass[]): Map<string, GlibNamedClass[]> => {\n const byNamespace: Map<string, GlibNamedClass[]> = new Map();\n\n for (const entry of elements) {\n const list = byNamespace.get(entry.namespace.name) ?? [];\n list.push(entry);\n byNamespace.set(entry.namespace.name, list);\n }\n\n return byNamespace;\n};\n\nconst buildElementLinks = (elements: GlibNamedClass[], basePath: string): Map<string, string> => {\n const linkByGlibName: Map<string, string> = new Map();\n\n for (const entry of elements) {\n const directory = namespaceDirectory(entry.namespace);\n const link = `${basePath}/${directory}/${elementSlug(entry.klass.name)}`;\n\n if (linkByGlibName.values().some((existing) => existing === link)) {\n throw new Error(`Docs page slug collision for ${entry.glibName} at ${link}`);\n }\n\n linkByGlibName.set(entry.glibName, link);\n }\n\n return linkByGlibName;\n};\n\nconst namespacePages = (input: {\n name: string;\n elements: GlibNamedClass[];\n basePath: string;\n linkByGlibName: Map<string, string>;\n pageContext: ElementPageContext;\n}): NamespacePages => {\n const { name, elements, basePath, linkByGlibName, pageContext } = input;\n const directory = name.toLowerCase();\n\n const docs: DocsNamespace = {\n name,\n directory,\n link: `${basePath}/${directory}/`,\n elements: elements.map((entry) => ({ text: entry.glibName, link: linkByGlibName.get(entry.glibName) ?? \"\" })),\n };\n\n const pages: Page[] = elements.map((entry) => ({\n path: `${directory}/${elementSlug(entry.klass.name)}.md`,\n content: renderElementPage(entry, pageContext),\n }));\n\n pages.push({ path: `${directory}/index.md`, content: namespaceIndexPage(docs, elements) });\n\n return { docs, pages };\n};\n\nconst generatePages = (options: DocsOptions, basePath: string, library: Library): GeneratedDocs => {\n const intrinsicElements = collectIntrinsicElementClasses(library);\n const byNamespace = groupElementsByNamespace(intrinsicElements);\n const linkByGlibName = buildElementLinks(intrinsicElements, basePath);\n const pageContext = createElementPageContext(library, (glibName: string) => linkByGlibName.get(glibName));\n const pages: Page[] = [];\n const namespaces: DocsNamespace[] = [];\n const orderedNames = sortStringsBy(byNamespace.keys(), namespaceOrder);\n\n for (const name of orderedNames) {\n const elements = sortStringsBy(byNamespace.get(name) ?? [], (entry) => entry.glibName);\n const result = namespacePages({ name, elements, basePath, linkByGlibName, pageContext });\n pages.push(...result.pages);\n namespaces.push(result.docs);\n }\n\n pages.push({ path: \"index.md\", content: rootIndexPage(namespaces, options.libraries) });\n\n return { pages, namespaces };\n};\n\nconst cachedDocsResult = (options: DocsOptions, manifestPath: string): DocsResult | undefined => {\n if (options.force === true || !isGiStoreFresh(options.outDir, options.libraries, options.girPath)) {\n return undefined;\n }\n\n if (!existsSync(manifestPath)) {\n return undefined;\n }\n\n const manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as DocsManifest;\n\n return { regenerated: false, namespaces: manifest.namespaces };\n};\n\nconst writePages = (outDir: string, pages: Page[]): void => {\n for (const page of pages) {\n const target = join(outDir, page.path);\n mkdirSync(dirname(target), { recursive: true });\n writeFileSync(target, page.content);\n }\n};\n\nconst writeDocs = (options: DocsOptions): DocsResult => {\n setElementProps(options.props ?? {});\n const basePath = options.basePath ?? \"/reference\";\n const manifestPath = join(options.outDir, MANIFEST_FILENAME);\n const cached = cachedDocsResult(options, manifestPath);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const library = Library.load(options.libraries, options.girPath);\n const { pages, namespaces } = generatePages(options, basePath, library);\n rmSync(options.outDir, { recursive: true, force: true });\n mkdirSync(options.outDir, { recursive: true });\n writePages(options.outDir, pages);\n const manifest: DocsManifest = { namespaces };\n writeFileSync(manifestPath, JSON.stringify(manifest));\n\n writeFileSync(\n join(options.outDir, FINGERPRINT_FILENAME),\n JSON.stringify(computeGiFingerprint(library.girFiles, options.libraries, options.girPath)),\n );\n\n return { regenerated: true, namespaces };\n};\n\nexport { writeDocs, type DocsElementLink, type DocsNamespace, type DocsOptions, type DocsResult };\n"]}
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/docs/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAqB,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,8BAA8B,EAAuB,MAAM,oCAAoC,CAAC;AACzG,OAAO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AO,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC1C,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAC7F,CAAC;IAEF,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC7C,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAA+E,CAAC","sourcesContent":["import { sortStringsBy } from \"@gtkx/utils\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { computeGiFingerprint, FINGERPRINT_FILENAME, isGiStoreFresh } from \"../fingerprint.js\";\nimport { Library } from \"../gir/library.js\";\nimport { namespaceDirectory } from \"../gir/namespace.js\";\nimport { type ElementProps, setElementProps } from \"../store/jsx/element-prop-imports.js\";\nimport { collectIntrinsicElementClasses, type GlibNamedClass } from \"../store/jsx/intrinsic-elements.js\";\nimport { type OmittedProps, setOmittedProps } from \"../store/jsx/omitted-props.js\";\nimport { createElementPageContext, type ElementPageContext, renderElementPage } from \"./element-page.js\";\nimport { elementSlug, firstSentence, namespaceOrder } from \"./render.js\";\n\ntype DocsElementLink = {\n text: string;\n link: string;\n};\n\ntype DocsNamespace = {\n name: string;\n directory: string;\n link: string;\n elements: DocsElementLink[];\n};\n\ntype DocsOptions = {\n libraries: string[];\n girPath: string[];\n outDir: string;\n basePath?: string;\n props?: ElementProps;\n omitProps?: OmittedProps;\n force?: boolean;\n};\n\ntype DocsManifest = {\n namespaces: DocsNamespace[];\n};\n\ntype GeneratedDocs = {\n pages: { path: string; content: string }[];\n namespaces: DocsNamespace[];\n};\n\ntype Page = { path: string; content: string };\ntype NamespacePages = { docs: DocsNamespace; pages: Page[] };\n\ntype DocsResult = {\n regenerated: boolean;\n namespaces: DocsNamespace[];\n};\n\nconst MANIFEST_FILENAME = \"manifest.json\";\n\nconst namespaceIndexPage = (namespace: DocsNamespace, elements: GlibNamedClass[]): string => {\n const rows = elements.map((entry, index) => {\n const link = namespace.elements[index]?.link ?? \"\";\n const description = firstSentence(entry.klass.doc).replaceAll(\"|\", String.raw`\\|`);\n\n return `| [${entry.glibName}](${link}) | ${description} |`;\n });\n\n const description =\n `Reference pages for the ${String(namespace.elements.length)} JSX elements in ` +\n `the ${namespace.name} namespace.`;\n\n return [\n \"---\",\n `description: ${JSON.stringify(description)}`,\n \"---\",\n \"\",\n `# ${namespace.name} elements`,\n \"\",\n `Elements in this namespace are imported from \\`@gtkx/jsx/${namespace.directory}\\`; the matching ` +\n `classes, enums, and functions are imported from \\`@gtkx/gi/${namespace.directory}\\`.`,\n \"\",\n \"| Element | Description |\",\n \"| --- | --- |\",\n ...rows,\n \"\",\n ].join(\"\\n\");\n};\n\nconst rootIndexPage = (namespaces: DocsNamespace[], libraries: string[]): string => {\n const rows = namespaces.map(\n (ns) => `| [${ns.name}](${ns.link}) | \\`@gtkx/jsx/${ns.directory}\\` | ${String(ns.elements.length)} |`,\n );\n\n const librariesList = libraries.map((library) => `\\`${library}\\``).join(\", \");\n\n return [\n \"---\",\n \"description: \\\"Generated reference documentation for every JSX element in this project's GIR libraries.\\\"\",\n \"---\",\n \"\",\n \"# Element Reference\",\n \"\",\n \"This reference documents every JSX element generated from the GObject-Introspection data for \" +\n `${librariesList}, together with the namespaces they pull in. It is produced by \\`gtkx docs\\` ` +\n \"using the same pipeline that generates the `@gtkx/jsx` and `@gtkx/gi` bindings, so every page \" +\n \"matches the types your editor sees.\",\n \"\",\n \"Each element page lists:\",\n \"\",\n \"- **Props** derived from GObject properties, plus the element props GTKX adds (such as `children` \" +\n \"and named slots), with types, defaults, and upstream documentation.\",\n \"- **Signals** as `on<Signal>` handler props with their exact handler signatures.\",\n \"- **Methods** available on the underlying instance through the `ref` prop.\",\n \"\",\n \"## Namespaces\",\n \"\",\n \"| Namespace | Import | Elements |\",\n \"| --- | --- | --- |\",\n ...rows,\n \"\",\n ].join(\"\\n\");\n};\n\nconst groupElementsByNamespace = (elements: GlibNamedClass[]): Map<string, GlibNamedClass[]> => {\n const byNamespace: Map<string, GlibNamedClass[]> = new Map();\n\n for (const entry of elements) {\n const list = byNamespace.get(entry.namespace.name) ?? [];\n list.push(entry);\n byNamespace.set(entry.namespace.name, list);\n }\n\n return byNamespace;\n};\n\nconst buildElementLinks = (elements: GlibNamedClass[], basePath: string): Map<string, string> => {\n const linkByGlibName: Map<string, string> = new Map();\n\n for (const entry of elements) {\n const directory = namespaceDirectory(entry.namespace);\n const link = `${basePath}/${directory}/${elementSlug(entry.klass.name)}`;\n\n if (linkByGlibName.values().some((existing) => existing === link)) {\n throw new Error(`Docs page slug collision for ${entry.glibName} at ${link}`);\n }\n\n linkByGlibName.set(entry.glibName, link);\n }\n\n return linkByGlibName;\n};\n\nconst namespacePages = (input: {\n name: string;\n elements: GlibNamedClass[];\n basePath: string;\n linkByGlibName: Map<string, string>;\n pageContext: ElementPageContext;\n}): NamespacePages => {\n const { name, elements, basePath, linkByGlibName, pageContext } = input;\n const directory = name.toLowerCase();\n\n const docs: DocsNamespace = {\n name,\n directory,\n link: `${basePath}/${directory}/`,\n elements: elements.map((entry) => ({ text: entry.glibName, link: linkByGlibName.get(entry.glibName) ?? \"\" })),\n };\n\n const pages: Page[] = elements.map((entry) => ({\n path: `${directory}/${elementSlug(entry.klass.name)}.md`,\n content: renderElementPage(entry, pageContext),\n }));\n\n pages.push({ path: `${directory}/index.md`, content: namespaceIndexPage(docs, elements) });\n\n return { docs, pages };\n};\n\nconst generatePages = (options: DocsOptions, basePath: string, library: Library): GeneratedDocs => {\n const intrinsicElements = collectIntrinsicElementClasses(library);\n const byNamespace = groupElementsByNamespace(intrinsicElements);\n const linkByGlibName = buildElementLinks(intrinsicElements, basePath);\n const pageContext = createElementPageContext(library, (glibName: string) => linkByGlibName.get(glibName));\n const pages: Page[] = [];\n const namespaces: DocsNamespace[] = [];\n const orderedNames = sortStringsBy(byNamespace.keys(), namespaceOrder);\n\n for (const name of orderedNames) {\n const elements = sortStringsBy(byNamespace.get(name) ?? [], (entry) => entry.glibName);\n const result = namespacePages({ name, elements, basePath, linkByGlibName, pageContext });\n pages.push(...result.pages);\n namespaces.push(result.docs);\n }\n\n pages.push({ path: \"index.md\", content: rootIndexPage(namespaces, options.libraries) });\n\n return { pages, namespaces };\n};\n\nconst cachedDocsResult = (options: DocsOptions, manifestPath: string): DocsResult | undefined => {\n if (options.force === true || !isGiStoreFresh(options.outDir, options.libraries, options.girPath)) {\n return undefined;\n }\n\n if (!existsSync(manifestPath)) {\n return undefined;\n }\n\n const manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as DocsManifest;\n\n return { regenerated: false, namespaces: manifest.namespaces };\n};\n\nconst writePages = (outDir: string, pages: Page[]): void => {\n for (const page of pages) {\n const target = join(outDir, page.path);\n mkdirSync(dirname(target), { recursive: true });\n writeFileSync(target, page.content);\n }\n};\n\nconst writeDocs = (options: DocsOptions): DocsResult => {\n setElementProps(options.props ?? {});\n setOmittedProps(options.omitProps ?? {});\n const basePath = options.basePath ?? \"/reference\";\n const manifestPath = join(options.outDir, MANIFEST_FILENAME);\n const cached = cachedDocsResult(options, manifestPath);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const library = Library.load(options.libraries, options.girPath);\n const { pages, namespaces } = generatePages(options, basePath, library);\n rmSync(options.outDir, { recursive: true, force: true });\n mkdirSync(options.outDir, { recursive: true });\n writePages(options.outDir, pages);\n const manifest: DocsManifest = { namespaces };\n writeFileSync(manifestPath, JSON.stringify(manifest));\n\n writeFileSync(\n join(options.outDir, FINGERPRINT_FILENAME),\n JSON.stringify(computeGiFingerprint(library.girFiles, options.libraries, options.girPath)),\n );\n\n return { regenerated: true, namespaces };\n};\n\nexport { writeDocs, type DocsElementLink, type DocsNamespace, type DocsOptions, type DocsResult };\n"]}
|
package/dist/fingerprint.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ type JsxFingerprintInput = {
|
|
|
15
15
|
components: Record<string, ModuleExport>;
|
|
16
16
|
lazyElements: string[];
|
|
17
17
|
props: Record<string, ModuleExport>;
|
|
18
|
+
omitProps: Record<string, string[]>;
|
|
18
19
|
};
|
|
19
20
|
/** The freshness sentinel of the `@gtkx/jsx` store, derived from the React element config. */
|
|
20
21
|
type JsxFingerprint = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAOA,0FAA0F;AAC1F,KAAK,aAAa,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,KAAK,YAAY,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,oFAAoF;AACpF,KAAK,mBAAmB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACvC,CAAC;AAEF,8FAA8F;AAC9F,KAAK,cAAc,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB,EAAE,MAAM,CAAC;CACjC,CAAC;AAGF,QAAA,MAAM,oBAAoB,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAOA,0FAA0F;AAC1F,KAAK,aAAa,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,O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print.js
CHANGED
|
@@ -26,6 +26,7 @@ const hashGi = (girFiles, libraries, girPath) => {
|
|
|
26
26
|
hash.update(sortAlpha(libraries));
|
|
27
27
|
hash.update("\n");
|
|
28
28
|
hash.update(sortAlpha(girPath));
|
|
29
|
+
hash.update("\n");
|
|
29
30
|
const hashedFiles = sortStrings([...girFiles, ...overrideFiles()]);
|
|
30
31
|
for (const file of hashedFiles) {
|
|
31
32
|
hash.update("\n");
|
|
@@ -65,6 +66,7 @@ const isGiStoreFresh = (giStoreDir, libraries, girPath) => {
|
|
|
65
66
|
};
|
|
66
67
|
const hasMatchingRecordedInputs = (sentinel, libraries, girPath) => sortAlpha(sentinel.libraries) === sortAlpha(libraries) && sortAlpha(sentinel.girPath ?? []) === sortAlpha(girPath);
|
|
67
68
|
const serializeModuleExports = (map) => sortStrings(Object.keys(map)).map((type) => [type, map[type]?.module ?? "", map[type]?.export ?? ""]);
|
|
69
|
+
const serializeOmitProps = (map) => sortStrings(Object.keys(map)).map((type) => [type, sortAlpha(map[type] ?? [])]);
|
|
68
70
|
const hashJsx = (input) => createHash("sha256")
|
|
69
71
|
.update(JSON.stringify([
|
|
70
72
|
CODEGEN_VERSION,
|
|
@@ -72,6 +74,7 @@ const hashJsx = (input) => createHash("sha256")
|
|
|
72
74
|
serializeModuleExports(input.components),
|
|
73
75
|
sortStrings(input.lazyElements),
|
|
74
76
|
serializeModuleExports(input.props),
|
|
77
|
+
serializeOmitProps(input.omitProps),
|
|
75
78
|
]))
|
|
76
79
|
.digest("hex");
|
|
77
80
|
const computeJsxFingerprint = (input, intrinsicElementCount) => ({
|
package/dist/fingerprint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAe,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import { createHash } from \"node:crypto\";\nimport { type Dirent, existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** The freshness sentinel of the `@gtkx/gi` store, derived purely from the GIR inputs. */\ntype GiFingerprint = {\n value: string;\n girFiles: string[];\n libraries: string[];\n girPath?: string[];\n};\n\ntype ModuleExport = { module: string; export: string };\n\n/** The `@gtkx/react` element config that shapes the generated `@gtkx/jsx` store. */\ntype JsxFingerprintInput = {\n reactVersion: string;\n components: Record<string, ModuleExport>;\n lazyElements: string[];\n props: Record<string, ModuleExport>;\n};\n\n/** The freshness sentinel of the `@gtkx/jsx` store, derived from the React element config. */\ntype JsxFingerprint = {\n value: string;\n intrinsicElementCount: number;\n};\n\nconst require = createRequire(import.meta.url);\nconst FINGERPRINT_FILENAME = \".codegen-fingerprint.json\";\nconst CODEGEN_VERSION: string = (require(\"../package.json\") as { version: string }).version;\nconst OVERRIDES_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), \"..\", \"overrides\");\n\nconst sortAlpha = (values: string[]): string => sortStrings(values).join(\",\");\n\n// The overrides are copied verbatim into the store, so editing one changes the output even though no\n// GIR file moved. Without them in the hash a stale override survives every non-forced run.\nconst overrideFiles = (): string[] => {\n if (!existsSync(OVERRIDES_ROOT)) {\n return [];\n }\n\n return readdirSync(OVERRIDES_ROOT, { recursive: true, withFileTypes: true })\n .filter((entry: Dirent) => entry.isFile())\n .map((entry: Dirent) => join(entry.parentPath, entry.name));\n};\n\nconst hashGi = (girFiles: string[], libraries: string[], girPath: string[]): string => {\n const hash = createHash(\"sha256\");\n hash.update(CODEGEN_VERSION);\n hash.update(\"\\n\");\n hash.update(sortAlpha(libraries));\n hash.update(\"\\n\");\n hash.update(sortAlpha(girPath));\n const hashedFiles = sortStrings([...girFiles, ...overrideFiles()]);\n\n for (const file of hashedFiles) {\n hash.update(\"\\n\");\n hash.update(file);\n hash.update(\"\\0\");\n hash.update(readFileSync(file));\n }\n\n return hash.digest(\"hex\");\n};\n\nconst computeGiFingerprint = (girFiles: string[], libraries: string[], girPath: string[]): GiFingerprint => ({\n value: hashGi(girFiles, libraries, girPath),\n girFiles,\n libraries,\n girPath,\n});\n\nconst isGiStoreFresh = (giStoreDir: string, libraries: string[], girPath: string[]): boolean => {\n const sentinelPath = join(giStoreDir, FINGERPRINT_FILENAME);\n\n if (!existsSync(sentinelPath)) {\n return false;\n }\n\n let sentinel: GiFingerprint;\n\n try {\n sentinel = JSON.parse(readFileSync(sentinelPath, \"utf8\")) as GiFingerprint;\n } catch {\n return false;\n }\n\n if (!hasMatchingRecordedInputs(sentinel, libraries, girPath)) {\n return false;\n }\n\n try {\n return hashGi(sentinel.girFiles, sentinel.libraries, girPath) === sentinel.value;\n } catch {\n return false;\n }\n};\n\nconst hasMatchingRecordedInputs = (sentinel: GiFingerprint, libraries: string[], girPath: string[]): boolean =>\n sortAlpha(sentinel.libraries) === sortAlpha(libraries) && sortAlpha(sentinel.girPath ?? []) === sortAlpha(girPath);\n\nconst serializeModuleExports = (map: Record<string, ModuleExport>): [string, string, string][] =>\n sortStrings(Object.keys(map)).map((type) => [type, map[type]?.module ?? \"\", map[type]?.export ?? \"\"]);\n\nconst hashJsx = (input: JsxFingerprintInput): string =>\n createHash(\"sha256\")\n .update(\n JSON.stringify([\n CODEGEN_VERSION,\n input.reactVersion,\n serializeModuleExports(input.components),\n sortStrings(input.lazyElements),\n serializeModuleExports(input.props),\n ]),\n )\n .digest(\"hex\");\n\nconst computeJsxFingerprint = (input: JsxFingerprintInput, intrinsicElementCount: number): JsxFingerprint => ({\n value: hashJsx(input),\n intrinsicElementCount,\n});\n\nconst jsxStoreFreshness = (\n jsxStoreDir: string,\n input: JsxFingerprintInput,\n): { fresh: boolean; intrinsicElementCount: number } => {\n const sentinelPath = join(jsxStoreDir, FINGERPRINT_FILENAME);\n\n if (!existsSync(sentinelPath)) {\n return { fresh: false, intrinsicElementCount: 0 };\n }\n\n let sentinel: JsxFingerprint;\n\n try {\n sentinel = JSON.parse(readFileSync(sentinelPath, \"utf8\")) as JsxFingerprint;\n } catch {\n return { fresh: false, intrinsicElementCount: 0 };\n }\n\n return sentinel.value === hashJsx(input)\n ? { fresh: true, intrinsicElementCount: sentinel.intrinsicElementCount }\n : { fresh: false, intrinsicElementCount: 0 };\n};\n\nexport {\n FINGERPRINT_FILENAME,\n computeGiFingerprint,\n isGiStoreFresh,\n computeJsxFingerprint,\n jsxStoreFreshness,\n type GiFingerprint,\n type JsxFingerprintInput,\n type JsxFingerprint,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAe,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA2BzC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AACzD,MAAM,eAAe,GAAY,OAAO,CAAC,iBAAiB,CAAyB,CAAC,OAAO,CAAC;AAC5F,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAE3F,MAAM,SAAS,GAAG,CAAC,MAAgB,EAAU,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAA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C,CAAC;AAEH,MAAM,iBAAiB,GAAG,CACtB,WAAmB,EACnB,KAA0B,EACuB,EAAE;IACnD,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IAE7D,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC;IACtD,CAAC;IAED,IAAI,QAAwB,CAAC;IAE7B,IAAI,CAAC;QACD,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAmB,CAAC;IAChF,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC;IACtD,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC;QACpC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB,EAAE;QACxE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC;AACrD,CAAC,CAAC;AAEF,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,GAIpB,CAAC","sourcesContent":["import { sortStrings } from \"@gtkx/utils\";\nimport { createHash } from \"node:crypto\";\nimport { type Dirent, existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/** The freshness sentinel of the `@gtkx/gi` store, derived purely from the GIR inputs. */\ntype GiFingerprint = {\n value: string;\n girFiles: string[];\n libraries: string[];\n girPath?: string[];\n};\n\ntype ModuleExport = { module: string; export: string };\n\n/** The `@gtkx/react` element config that shapes the generated `@gtkx/jsx` store. */\ntype JsxFingerprintInput = {\n reactVersion: string;\n components: Record<string, ModuleExport>;\n lazyElements: string[];\n props: Record<string, ModuleExport>;\n omitProps: Record<string, string[]>;\n};\n\n/** The freshness sentinel of the `@gtkx/jsx` store, derived from the React element config. */\ntype JsxFingerprint = {\n value: string;\n intrinsicElementCount: number;\n};\n\nconst require = createRequire(import.meta.url);\nconst FINGERPRINT_FILENAME = \".codegen-fingerprint.json\";\nconst CODEGEN_VERSION: string = (require(\"../package.json\") as { version: string }).version;\nconst OVERRIDES_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), \"..\", \"overrides\");\n\nconst sortAlpha = (values: string[]): string => sortStrings(values).join(\",\");\n\n// The overrides are copied verbatim into the store, so editing one changes the output even though no\n// GIR file moved. Without them in the hash a stale override survives every non-forced run.\nconst overrideFiles = (): string[] => {\n if (!existsSync(OVERRIDES_ROOT)) {\n return [];\n }\n\n return readdirSync(OVERRIDES_ROOT, { recursive: true, withFileTypes: true })\n .filter((entry: Dirent) => entry.isFile())\n .map((entry: Dirent) => join(entry.parentPath, entry.name));\n};\n\nconst hashGi = (girFiles: string[], libraries: string[], girPath: string[]): string => {\n const hash = createHash(\"sha256\");\n hash.update(CODEGEN_VERSION);\n hash.update(\"\\n\");\n hash.update(sortAlpha(libraries));\n hash.update(\"\\n\");\n hash.update(sortAlpha(girPath));\n hash.update(\"\\n\");\n const hashedFiles = sortStrings([...girFiles, ...overrideFiles()]);\n\n for (const file of hashedFiles) {\n hash.update(\"\\n\");\n hash.update(file);\n hash.update(\"\\0\");\n hash.update(readFileSync(file));\n }\n\n return hash.digest(\"hex\");\n};\n\nconst computeGiFingerprint = (\n girFiles: string[],\n libraries: string[],\n girPath: string[],\n): GiFingerprint => ({\n value: hashGi(girFiles, libraries, girPath),\n girFiles,\n libraries,\n girPath,\n});\n\nconst isGiStoreFresh = (\n giStoreDir: string,\n libraries: string[],\n girPath: string[],\n): boolean => {\n const sentinelPath = join(giStoreDir, FINGERPRINT_FILENAME);\n\n if (!existsSync(sentinelPath)) {\n return false;\n }\n\n let sentinel: GiFingerprint;\n\n try {\n sentinel = JSON.parse(readFileSync(sentinelPath, \"utf8\")) as GiFingerprint;\n } catch {\n return false;\n }\n\n if (!hasMatchingRecordedInputs(sentinel, libraries, girPath)) {\n return false;\n }\n\n try {\n return hashGi(sentinel.girFiles, sentinel.libraries, girPath) === sentinel.value;\n } catch {\n return false;\n }\n};\n\nconst hasMatchingRecordedInputs = (sentinel: GiFingerprint, libraries: string[], girPath: string[]): boolean =>\n sortAlpha(sentinel.libraries) === sortAlpha(libraries) && sortAlpha(sentinel.girPath ?? []) === sortAlpha(girPath);\n\nconst serializeModuleExports = (map: Record<string, ModuleExport>): [string, string, string][] =>\n sortStrings(Object.keys(map)).map((type) => [type, map[type]?.module ?? \"\", map[type]?.export ?? \"\"]);\n\nconst serializeOmitProps = (map: Record<string, string[]>): [string, string][] =>\n sortStrings(Object.keys(map)).map((type) => [type, sortAlpha(map[type] ?? [])]);\n\nconst hashJsx = (input: JsxFingerprintInput): string =>\n createHash(\"sha256\")\n .update(\n JSON.stringify([\n CODEGEN_VERSION,\n input.reactVersion,\n serializeModuleExports(input.components),\n sortStrings(input.lazyElements),\n serializeModuleExports(input.props),\n serializeOmitProps(input.omitProps),\n ]),\n )\n .digest(\"hex\");\n\nconst computeJsxFingerprint = (input: JsxFingerprintInput, intrinsicElementCount: number): JsxFingerprint => ({\n value: hashJsx(input),\n intrinsicElementCount,\n});\n\nconst jsxStoreFreshness = (\n jsxStoreDir: string,\n input: JsxFingerprintInput,\n): { fresh: boolean; intrinsicElementCount: number } => {\n const sentinelPath = join(jsxStoreDir, FINGERPRINT_FILENAME);\n\n if (!existsSync(sentinelPath)) {\n return { fresh: false, intrinsicElementCount: 0 };\n }\n\n let sentinel: JsxFingerprint;\n\n try {\n sentinel = JSON.parse(readFileSync(sentinelPath, \"utf8\")) as JsxFingerprint;\n } catch {\n return { fresh: false, intrinsicElementCount: 0 };\n }\n\n return sentinel.value === hashJsx(input)\n ? { fresh: true, intrinsicElementCount: sentinel.intrinsicElementCount }\n : { fresh: false, intrinsicElementCount: 0 };\n};\n\nexport {\n FINGERPRINT_FILENAME,\n computeGiFingerprint,\n isGiStoreFresh,\n computeJsxFingerprint,\n jsxStoreFreshness,\n type GiFingerprint,\n type JsxFingerprintInput,\n type JsxFingerprint,\n};\n"]}
|
package/dist/gi.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { Library } from "./gir/library.js";
|
|
2
2
|
import { type GiStoreOptions } from "./store/gi-store.js";
|
|
3
|
+
type GiCodegenOptions = {
|
|
4
|
+
gi: GiStoreOptions;
|
|
5
|
+
libraries: string[];
|
|
6
|
+
girPath: string[];
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* Generates the `@gtkx/gi` store from the loaded GIR library and links it into the project. This is the
|
|
5
10
|
* react-free half of codegen: it can run before `@gtkx/gi` (or `@gtkx/react`) exists, since it produces them.
|
|
6
11
|
*
|
|
7
12
|
* @returns The number of namespaces written.
|
|
8
13
|
*/
|
|
9
|
-
declare const runGiCodegen: (library: Library,
|
|
14
|
+
declare const runGiCodegen: (library: Library, options: GiCodegenOptions) => number;
|
|
10
15
|
export { isGiStoreFresh } from "./fingerprint.js";
|
|
11
16
|
export type { GiStoreOptions } from "./store/gi-store.js";
|
|
12
|
-
export { runGiCodegen };
|
|
17
|
+
export { runGiCodegen, type GiCodegenOptions };
|
|
13
18
|
//# sourceMappingURL=gi.d.ts.map
|
package/dist/gi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gi.d.ts","sourceRoot":"","sources":["../src/gi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAyB,KAAK,cAAc,EAAgB,MAAM,qBAAqB,CAAC;AAG/F
|
|
1
|
+
{"version":3,"file":"gi.d.ts","sourceRoot":"","sources":["../src/gi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAyB,KAAK,cAAc,EAAgB,MAAM,qBAAqB,CAAC;AAG/F,KAAK,gBAAgB,GAAG;IACpB,EAAE,EAAE,cAAc,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,YAAY,GAAI,SAAS,OAAO,EAAE,SAAS,gBAAgB,KAAG,MAYnE,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|
package/dist/gi.js
CHANGED
|
@@ -8,12 +8,14 @@ import { generateNamespaceModule } from "./store/gi/pipeline.js";
|
|
|
8
8
|
*
|
|
9
9
|
* @returns The number of namespaces written.
|
|
10
10
|
*/
|
|
11
|
-
const runGiCodegen = (library,
|
|
11
|
+
const runGiCodegen = (library, options) => {
|
|
12
|
+
const { gi, libraries, girPath } = options;
|
|
12
13
|
const namespaces = Array.from(library.namespaces.values(), (namespace) => ({
|
|
13
14
|
directory: namespaceDirectory(namespace),
|
|
14
15
|
rawSource: generateNamespaceModule(namespace, library),
|
|
15
16
|
}));
|
|
16
|
-
|
|
17
|
+
const fingerprint = computeGiFingerprint(library.girFiles, [...libraries], [...girPath]);
|
|
18
|
+
writeGiStore(gi, namespaces, fingerprint);
|
|
17
19
|
return library.namespaces.size;
|
|
18
20
|
};
|
|
19
21
|
export { isGiStoreFresh } from "./fingerprint.js";
|
package/dist/gi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gi.js","sourceRoot":"","sources":["../src/gi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oB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Content":["import type { Library } from \"./gir/library.js\";\nimport { computeGiFingerprint } from \"./fingerprint.js\";\nimport { namespaceDirectory } from \"./gir/namespace.js\";\nimport { type GiNamespaceInput, type GiStoreOptions, writeGiStore } from \"./store/gi-store.js\";\nimport { generateNamespaceModule } from \"./store/gi/pipeline.js\";\n\ntype GiCodegenOptions = {\n gi: GiStoreOptions;\n libraries: string[];\n girPath: string[];\n};\n\n/**\n * Generates the `@gtkx/gi` store from the loaded GIR library and links it into the project. This is the\n * react-free half of codegen: it can run before `@gtkx/gi` (or `@gtkx/react`) exists, since it produces them.\n *\n * @returns The number of namespaces written.\n */\nconst runGiCodegen = (library: Library, options: GiCodegenOptions): number => {\n const { gi, libraries, girPath } = options;\n\n const namespaces: GiNamespaceInput[] = Array.from(library.namespaces.values(), (namespace) => ({\n directory: namespaceDirectory(namespace),\n rawSource: generateNamespaceModule(namespace, library),\n }));\n\n const fingerprint = computeGiFingerprint(library.girFiles, [...libraries], [...girPath]);\n writeGiStore(gi, namespaces, fingerprint);\n\n return library.namespaces.size;\n};\n\nexport { isGiStoreFresh } from \"./fingerprint.js\";\nexport type { GiStoreOptions } from \"./store/gi-store.js\";\nexport { runGiCodegen, type GiCodegenOptions };\n"]}
|
package/dist/gir/libraries.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
declare const
|
|
1
|
+
type LibrarySelection = typeof LIBRARIES_WILDCARD | string[] | undefined;
|
|
2
|
+
declare const LIBRARIES_WILDCARD = "*";
|
|
3
|
+
declare const resolveLibraries: (libraries: LibrarySelection, girPath: string[]) => string[];
|
|
3
4
|
declare const discoverGirNamespaces: (girPath: string[]) => string[];
|
|
4
|
-
export { resolveLibraries, discoverGirNamespaces };
|
|
5
|
+
export { resolveLibraries, discoverGirNamespaces, type LibrarySelection };
|
|
5
6
|
//# sourceMappingURL=libraries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libraries.d.ts","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libraries.d.ts","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"AAIA,KAAK,gBAAgB,GAAG,OAAO,kBAAkB,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAEzE,QAAA,MAAM,kBAAkB,MAAM,CAAC;AAK/B,QAAA,MAAM,gBAAgB,GAAI,WAAW,gBAAgB,EAAE,SAAS,MAAM,EAAE,KAAG,MAAM,EAqBhF,CAAC;AA4CF,QAAA,MAAM,qBAAqB,GAAI,SAAS,MAAM,EAAE,KAAG,MAAM,EAQxD,CAAC;AAkBF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|
package/dist/gir/libraries.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { GIR_LIBRARY_PATTERN, LIBRARIES_WILDCARD } from "@gtkx/config/internal";
|
|
2
1
|
import { sortStrings } from "@gtkx/utils";
|
|
3
2
|
import { readdirSync } from "node:fs";
|
|
3
|
+
const LIBRARIES_WILDCARD = "*";
|
|
4
|
+
const GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\d+(?:\.\d+)*$/;
|
|
4
5
|
const DEFAULT_LIBRARIES = ["Gtk-4.0"];
|
|
5
6
|
const GIR_FILE_SUFFIX = ".gir";
|
|
6
7
|
const resolveLibraries = (libraries, girPath) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libraries.js","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libraries.js","sourceRoot":"","sources":["../../src/gir/libraries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKtC,MAAM,kBAAkB,GAAG,GAAG,CAAC;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M,aAAa,GAA8B,IAAI,GAAG,EAAE,CAAC;IAE3D,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QACxB,oBAAoB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,WAAW,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;IACrD,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAEtD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAE3E,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,UAAU,CAAC;QACtB,CAAC;IACL,CAAC;IAED,OAAO,CAAC,CAAC;AACb,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAyB,CAAC","sourcesContent":["import { sortStrings } from \"@gtkx/utils\";\nimport { readdirSync } from \"node:fs\";\n\ntype GirNamespace = { name: string; version: string; identifier: string };\ntype LibrarySelection = typeof LIBRARIES_WILDCARD | string[] | undefined;\n\nconst LIBRARIES_WILDCARD = \"*\";\nconst GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\\d+(?:\\.\\d+)*$/;\nconst DEFAULT_LIBRARIES: string[] = [\"Gtk-4.0\"];\nconst GIR_FILE_SUFFIX = \".gir\";\n\nconst resolveLibraries = (libraries: LibrarySelection, girPath: string[]): string[] => {\n if (libraries === undefined) {\n return [...DEFAULT_LIBRARIES];\n }\n\n if (libraries === LIBRARIES_WILDCARD) {\n const discovered = discoverGirNamespaces(girPath);\n\n if (discovered.length === 0) {\n throw new Error(\n `gtkx.config.ts: \\`libraries: \"*\"\\` matched no .gir files in [${girPath.join(\", \")}]. ` +\n \"Install gobject-introspection data packages, or list the libraries explicitly.\",\n );\n }\n\n return discovered;\n }\n\n const hasGtk = libraries.some((library) => library.startsWith(\"Gtk-\"));\n\n return [...new Set([...(hasGtk ? [] : DEFAULT_LIBRARIES), ...libraries])];\n};\n\nconst readDirEntries = (dir: string): string[] => {\n try {\n return readdirSync(dir);\n } catch {\n return [];\n }\n};\n\nconst parseGirNamespace = (entry: string): GirNamespace | undefined => {\n if (!entry.endsWith(GIR_FILE_SUFFIX)) {\n return undefined;\n }\n\n const identifier = entry.slice(0, -GIR_FILE_SUFFIX.length);\n\n if (!GIR_LIBRARY_PATTERN.test(identifier)) {\n return undefined;\n }\n\n const separator = identifier.indexOf(\"-\");\n\n return { name: identifier.slice(0, separator), version: identifier.slice(separator + 1), identifier };\n};\n\nconst recordHighest = (highestByName: Map<string, GirNamespace>, parsed: GirNamespace): void => {\n const existing = highestByName.get(parsed.name);\n\n if (existing === undefined || compareVersions(parsed.version, existing.version) > 0) {\n highestByName.set(parsed.name, parsed);\n }\n};\n\nconst collectDirNamespaces = (highestByName: Map<string, GirNamespace>, dir: string): void => {\n for (const entry of readDirEntries(dir)) {\n const parsed = parseGirNamespace(entry);\n\n if (parsed !== undefined) {\n recordHighest(highestByName, parsed);\n }\n }\n};\n\nconst discoverGirNamespaces = (girPath: string[]): string[] => {\n const highestByName: Map<string, GirNamespace> = new Map();\n\n for (const dir of girPath) {\n collectDirNamespaces(highestByName, dir);\n }\n\n return sortStrings(highestByName.values().map(({ identifier }) => identifier));\n};\n\nconst compareVersions = (a: string, b: string): number => {\n const aParts = a.split(\".\");\n const bParts = b.split(\".\");\n const length = Math.max(aParts.length, bParts.length);\n\n for (let index = 0; index < length; index += 1) {\n const difference = Number(aParts[index] ?? 0) - Number(bParts[index] ?? 0);\n\n if (difference !== 0) {\n return difference;\n }\n }\n\n return 0;\n};\n\nexport { resolveLibraries, discoverGirNamespaces, type LibrarySelection };\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { discoverGirNamespaces, resolveLibraries } from "./gir/libraries.js";
|
|
|
5
5
|
export { type BuiltinElement, type BuiltinElements, type ModuleExport, readBuiltinElements, } from "./react/element-config.js";
|
|
6
6
|
export { runCodegen } from "./runner.js";
|
|
7
7
|
export type { ElementProps } from "./store/jsx/element-prop-imports.js";
|
|
8
|
+
export { mergeOmitProps, type OmittedProps } from "./store/jsx/omitted-props.js";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,gBAAgB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,SAAS,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,mBAAmB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,gBAAgB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,SAAS,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,mBAAmB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export { resolveGirPath } from "./gir/gir-path.js";
|
|
|
4
4
|
export { discoverGirNamespaces, resolveLibraries } from "./gir/libraries.js";
|
|
5
5
|
export { readBuiltinElements, } from "./react/element-config.js";
|
|
6
6
|
export { runCodegen } from "./runner.js";
|
|
7
|
+
export { mergeOmitProps } from "./store/jsx/omitted-props.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAQhB,gBAAgB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAKH,SAAS,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAIH,mBAAmB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export {\n API_SYMBOL_KINDS,\n type ApiLookupResult,\n type ApiNamespaceSummary,\n type ApiReference,\n type ApiReferenceOptions,\n type ApiSearchOptions,\n type ApiSymbol,\n type ApiSymbolKind,\n loadApiReference,\n} from \"./docs/api-reference.js\";\nexport {\n type DocsElementLink,\n type DocsNamespace,\n type DocsOptions,\n type DocsResult,\n writeDocs,\n} from \"./docs/pipeline.js\";\nexport { resolveGirPath } from \"./gir/gir-path.js\";\nexport { discoverGirNamespaces, resolveLibraries } from \"./gir/libraries.js\";\nexport {\n type BuiltinElement,\n type BuiltinElements,\n type ModuleExport,\n readBuiltinElements,\n} from \"./react/element-config.js\";\nexport { runCodegen } from \"./runner.js\";\nexport type { ElementProps } from \"./store/jsx/element-prop-imports.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAQhB,gBAAgB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAKH,SAAS,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAIH,mBAAmB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAqB,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n API_SYMBOL_KINDS,\n type ApiLookupResult,\n type ApiNamespaceSummary,\n type ApiReference,\n type ApiReferenceOptions,\n type ApiSearchOptions,\n type ApiSymbol,\n type ApiSymbolKind,\n loadApiReference,\n} from \"./docs/api-reference.js\";\nexport {\n type DocsElementLink,\n type DocsNamespace,\n type DocsOptions,\n type DocsResult,\n writeDocs,\n} from \"./docs/pipeline.js\";\nexport { resolveGirPath } from \"./gir/gir-path.js\";\nexport { discoverGirNamespaces, resolveLibraries } from \"./gir/libraries.js\";\nexport {\n type BuiltinElement,\n type BuiltinElements,\n type ModuleExport,\n readBuiltinElements,\n} from \"./react/element-config.js\";\nexport { runCodegen } from \"./runner.js\";\nexport type { ElementProps } from \"./store/jsx/element-prop-imports.js\";\nexport { mergeOmitProps, type OmittedProps } from \"./store/jsx/omitted-props.js\";\n"]}
|
package/dist/jsx.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Library } from "./gir/library.js";
|
|
2
2
|
import { type ModuleExport } from "./react/element-config.js";
|
|
3
3
|
import { type JsxStoreOptions } from "./store/jsx-store.js";
|
|
4
|
+
import { type OmittedProps } from "./store/jsx/omitted-props.js";
|
|
4
5
|
type RunJsxCodegenOptions = {
|
|
5
6
|
getLibrary: () => Library;
|
|
6
7
|
jsx: JsxStoreOptions;
|
|
@@ -9,6 +10,7 @@ type RunJsxCodegenOptions = {
|
|
|
9
10
|
userComponents: Record<string, ModuleExport>;
|
|
10
11
|
userLazyElements: string[];
|
|
11
12
|
userProps: Record<string, ModuleExport>;
|
|
13
|
+
userOmitProps: OmittedProps;
|
|
12
14
|
giRegenerated: boolean;
|
|
13
15
|
force: boolean;
|
|
14
16
|
};
|
package/dist/jsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAOhD,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAOhD,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGjF,KAAK,oBAAoB,GAAG;IACxB,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,GAAG,EAAE,eAAe,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,aAAa,EAAE,YAAY,CAAC;IAC5B,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,qBAAqB,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,aAAa,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,mBAAmB,CAqCvF,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,CAAC"}
|
package/dist/jsx.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computeJsxFingerprint, FINGERPRINT_FILENAME, jsxStoreFreshness, } from "./fingerprint.js";
|
|
2
2
|
import { readBuiltinElements } from "./react/element-config.js";
|
|
3
3
|
import { writeJsxStore } from "./store/jsx-store.js";
|
|
4
|
+
import { mergeOmitProps } from "./store/jsx/omitted-props.js";
|
|
4
5
|
import { generateJsxFiles } from "./store/jsx/pipeline.js";
|
|
5
6
|
/**
|
|
6
7
|
* Generates the `@gtkx/jsx` store, reading the framework's built-in element config from the freshly
|
|
@@ -12,11 +13,13 @@ const runJsxCodegen = async (options) => {
|
|
|
12
13
|
const components = { ...builtin.components, ...options.userComponents };
|
|
13
14
|
const lazyElements = [...builtin.lazyElements, ...options.userLazyElements];
|
|
14
15
|
const props = { ...builtin.props, ...options.userProps };
|
|
16
|
+
const omitProps = mergeOmitProps(builtin.omitProps, options.userOmitProps);
|
|
15
17
|
const fingerprintInput = {
|
|
16
18
|
reactVersion: options.jsx.version,
|
|
17
19
|
components,
|
|
18
20
|
lazyElements,
|
|
19
21
|
props,
|
|
22
|
+
omitProps,
|
|
20
23
|
};
|
|
21
24
|
if (!options.force && !options.giRegenerated) {
|
|
22
25
|
const { fresh, intrinsicElementCount } = jsxStoreFreshness(options.jsx.storeDir, fingerprintInput);
|
|
@@ -29,6 +32,7 @@ const runJsxCodegen = async (options) => {
|
|
|
29
32
|
components,
|
|
30
33
|
lazyElements,
|
|
31
34
|
props,
|
|
35
|
+
omitProps,
|
|
32
36
|
});
|
|
33
37
|
writeJsxStore(options.jsx, namespaces, metadata, {
|
|
34
38
|
relativePath: FINGERPRINT_FILENAME,
|
package/dist/jsx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.js","sourceRoot":"","s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AAY,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;QACjC,UAAU;QACV,YAAY;QACZ,KAAK;QACL,SAAS;KACZ,CAAC;IAEF,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAEnG,IAAI,KAAK,EAAE,CAAC;YACR,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;QACzD,CAAC;IACL,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,qBAAqB,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE;QAC3F,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,UAAU;QACV,YAAY;QACZ,KAAK;QACL,SAAS;KACZ,CAAC,CAAC;IAEH,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE;QAC7C,YAAY,EAAE,oBAAoB;QAClC,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI;KAC1G,CAAC,CAAC;IAEH,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;AACxD,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAuD,CAAC","sourcesContent":["import type { Library } from \"./gir/library.js\";\nimport {\n computeJsxFingerprint,\n FINGERPRINT_FILENAME,\n type JsxFingerprintInput,\n jsxStoreFreshness,\n} from \"./fingerprint.js\";\nimport { type ModuleExport, readBuiltinElements } from \"./react/element-config.js\";\nimport { type JsxStoreOptions, writeJsxStore } from \"./store/jsx-store.js\";\nimport { mergeOmitProps, type OmittedProps } from \"./store/jsx/omitted-props.js\";\nimport { generateJsxFiles } from \"./store/jsx/pipeline.js\";\n\ntype RunJsxCodegenOptions = {\n getLibrary: () => Library;\n jsx: JsxStoreOptions;\n giStoreDir: string;\n reactSubexports: string[];\n userComponents: Record<string, ModuleExport>;\n userLazyElements: string[];\n userProps: Record<string, ModuleExport>;\n userOmitProps: OmittedProps;\n giRegenerated: boolean;\n force: boolean;\n};\n\ntype RunJsxCodegenResult = {\n regenerated: boolean;\n intrinsicElementCount: number;\n};\n\n/**\n * Generates the `@gtkx/jsx` store, reading the framework's built-in element config from the freshly\n * linked `@gtkx/react` and layering the project's own element config over it. This is the react-importing\n * half of codegen: it must run only after the gi store has been written and linked.\n */\nconst runJsxCodegen = async (options: RunJsxCodegenOptions): Promise<RunJsxCodegenResult> => {\n const builtin = await readBuiltinElements(options.reactSubexports, options.giStoreDir);\n const components = { ...builtin.components, ...options.userComponents };\n const lazyElements = [...builtin.lazyElements, ...options.userLazyElements];\n const props = { ...builtin.props, ...options.userProps };\n const omitProps = mergeOmitProps(builtin.omitProps, options.userOmitProps);\n\n const fingerprintInput: JsxFingerprintInput = {\n reactVersion: options.jsx.version,\n components,\n lazyElements,\n props,\n omitProps,\n };\n\n if (!options.force && !options.giRegenerated) {\n const { fresh, intrinsicElementCount } = jsxStoreFreshness(options.jsx.storeDir, fingerprintInput);\n\n if (fresh) {\n return { regenerated: false, intrinsicElementCount };\n }\n }\n\n const { namespaces, metadata, intrinsicElementCount } = generateJsxFiles(options.getLibrary(), {\n reactSubexports: options.reactSubexports,\n components,\n lazyElements,\n props,\n omitProps,\n });\n\n writeJsxStore(options.jsx, namespaces, metadata, {\n relativePath: FINGERPRINT_FILENAME,\n content: `${JSON.stringify(computeJsxFingerprint(fingerprintInput, intrinsicElementCount), null, 2)}\\n`,\n });\n\n return { regenerated: true, intrinsicElementCount };\n};\n\nexport { runJsxCodegen, type RunJsxCodegenOptions, type RunJsxCodegenResult };\n"]}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { ModuleExport } from "@gtkx/react/config";
|
|
2
|
+
import type { OmittedProps } from "../store/jsx/omitted-props.js";
|
|
2
3
|
/** The codegen-relevant subset of a React element config; behaviors are ignored at codegen time. */
|
|
3
4
|
type BuiltinElement = {
|
|
4
5
|
component?: ModuleExport;
|
|
5
6
|
lazy?: boolean;
|
|
6
7
|
props?: ModuleExport;
|
|
8
|
+
omitProps?: string[];
|
|
7
9
|
};
|
|
8
10
|
/** The framework's built-in element config, split into the maps codegen consumes. */
|
|
9
11
|
type BuiltinElements = {
|
|
10
12
|
components: Record<string, ModuleExport>;
|
|
11
13
|
lazyElements: string[];
|
|
12
14
|
props: Record<string, ModuleExport>;
|
|
15
|
+
omitProps: OmittedProps;
|
|
13
16
|
};
|
|
14
17
|
declare const readBuiltinElements: (reactSubexports: string[], giStoreDir: string) => Promise<BuiltinElements>;
|
|
15
18
|
export { type ModuleExport } from "@gtkx/react/config";
|