@gtkx/codegen 1.2.0 → 1.2.2
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/docs/symbol-page.js +1 -1
- package/dist/docs/symbol-page.js.map +1 -1
- package/dist/gir/class.d.ts +7 -2
- package/dist/gir/class.d.ts.map +1 -1
- package/dist/gir/class.js +4 -1
- package/dist/gir/class.js.map +1 -1
- package/dist/store/gi/interface.js +2 -2
- package/dist/store/gi/interface.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +4 -2
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +3 -2
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +156 -18
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/record-layout.d.ts +5 -2
- package/dist/store/gi/record-layout.d.ts.map +1 -1
- package/dist/store/gi/record-layout.js +2 -1
- package/dist/store/gi/record-layout.js.map +1 -1
- package/dist/store/gi/signal.d.ts.map +1 -1
- package/dist/store/gi/signal.js +14 -14
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/resolve-store.d.ts.map +1 -1
- package/dist/store/resolve-store.js +1 -0
- package/dist/store/resolve-store.js.map +1 -1
- package/package.json +3 -3
- package/src/docs/symbol-page.ts +1 -1
- package/src/gir/class.ts +12 -3
- package/src/store/gi/interface.ts +2 -2
- package/src/store/gi/record-constructor.ts +4 -2
- package/src/store/gi/record-field-accessor.ts +241 -20
- package/src/store/gi/record-layout.ts +11 -1
- package/src/store/gi/signal.ts +20 -23
- package/src/store/resolve-store.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../../src/store/gi/signal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA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QAAQ,EAAE,IAAI,0BAA0B,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QACpE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,CAAC","sourcesContent":["import { camelCase, sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirClass } from \"../../gir/class.js\";\nimport type { GirCallable, GirParameter, GirReturnValue } from \"../../gir/parameter.js\";\nimport type { GirProperty } from \"../../gir/property.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport type { Declaration } from \"../../writer/module.js\";\nimport {\n isCellInout,\n primaryReturnKind,\n renderDescriptor,\n renderParamDescriptor,\n} from \"../../analysis/descriptor-render.js\";\nimport { tCallback, tObject, tVoid } from \"../../analysis/descriptor.js\";\nimport {\n collectInterfaceProperties,\n forEachAncestor,\n resolvePrerequisiteReference,\n} from \"../../analysis/inheritance.js\";\nimport { renderHandlerParameters, renderHandlerResultType } from \"../../analysis/param-structure.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { resolveInterfaces } from \"../../gir/ancestry.js\";\nimport { isCallerAllocatedOut, isOutParameter } from \"../../gir/parameter.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { indent, renderBlock, renderBracedOrEmpty } from \"../../writer/emit.js\";\nimport { parentCompanionRef } from \"./companion.js\";\nimport { getDoc, handlerSpec } from \"./doc-spec.js\";\nimport { isAllocatableCallerOut, isRecordInout, renderCallerOutInstance } from \"./param-marshal.js\";\n\ntype SignalMapSpec = {\n context: ModuleContext;\n klass: GirClass;\n className: string;\n isParentlessObjectSubclass: boolean;\n suffix: string;\n renderEntry: (context: ModuleContext, signal: GirCallable) => string;\n};\n\ntype EmitArgOptions = {\n context: ModuleContext;\n parameter: GirParameter;\n descriptor: string;\n argIndex: number;\n};\n\ntype NamedMember = { name: string };\n\nconst SIGNAL_HANDLER_TYPE = \"(...args: any[]) => any\";\nconst SIGNALS_SUFFIX = \"Signals\";\nconst SIGNAL_EMIT_SUFFIX = \"SignalEmit\";\n\nconst DEPRECATED_SIGNAL_ALIASES: Map<string, string> = new Map([\n [\"addEventListener\", \"on\"],\n [\"removeEventListener\", \"off\"],\n]);\n\nconst deprecatedAliasDoc = (method: string): string => {\n const replacement = DEPRECATED_SIGNAL_ALIASES.get(method);\n\n if (replacement === undefined) {\n return \"\";\n }\n\n return `/** @deprecated Since 1.2. Use \\`${replacement}\\` instead. Removed in v2. */\\n`;\n};\n\nconst renderSignalMembers = (context: ModuleContext, klass: GirClass): string[] => {\n if (klass.glibGetType === undefined) {\n return [];\n }\n\n const signals = collectClassSignals(context, klass);\n\n if (signals.length === 0) {\n return [];\n }\n\n const isRootObject = context.namespace.name === \"GObject\" && klass.name === \"Object\";\n context.addRuntimeImport(\"connectSignal\");\n context.addRuntimeImport(\"getSignalBaseName\");\n context.addRuntimeImport(\"t\");\n const connectCases = signals.map((signal) => renderConnectCase(context, signal));\n const emitCases = signals.map((signal) => renderEmitCase(context, signal));\n\n const connectDefault = isRootObject\n ? \"default:\\n throw new globalThis.Error(\\\"Unknown signal '\\\" + signal + \\\"'\\\");\"\n : \"default:\\n return super.connect(signal as never, handler as never, isAfter);\";\n\n const emitDefault = isRootObject\n ? \"default:\\n throw new globalThis.Error(\\\"Unknown signal '\\\" + sigName + \\\"'\\\");\"\n : \"default:\\n return super.emit(sigName, ...args);\";\n\n const connectBody = indent([...connectCases, connectDefault].join(\"\\n\"), 1);\n const connectSwitch = `switch (getSignalBaseName(signal)) {\\n${connectBody}\\n}`;\n const emitBody = indent([...emitCases, emitDefault].join(\"\\n\"), 1);\n const emitSwitch = `switch (getSignalBaseName(sigName)) {\\n${emitBody}\\n}`;\n\n return [\n renderBlock(\n `connect(signal: string, handler: ${SIGNAL_HANDLER_TYPE}, isAfter?: boolean): number`,\n connectSwitch,\n ),\n renderBlock(\"emit(sigName: string, ...args: unknown[]): unknown\", emitSwitch),\n ];\n};\n\nconst renderSignalDeclarations = (\n context: ModuleContext,\n klass: GirClass,\n className: string,\n isParentlessObjectSubclass: boolean,\n): Declaration[] => {\n const base = { context, klass, className, isParentlessObjectSubclass };\n\n const declarations: Declaration[] = [\n {\n name: `${className}${SIGNALS_SUFFIX}`,\n code: renderSignalMap({ ...base, suffix: SIGNALS_SUFFIX, renderEntry: renderSignalHandlerType }),\n },\n {\n name: `${className}${SIGNAL_EMIT_SUFFIX}`,\n code: renderSignalMap({ ...base, suffix: SIGNAL_EMIT_SUFFIX, renderEntry: renderSignalEmitEntry }),\n },\n ];\n\n if (\n klass.glibGetType !== undefined &&\n (collectClassSignals(context, klass).length > 0 ||\n collectNotifyDetails(context, klass).length > 0 ||\n klass.implements.length > 0)\n ) {\n const isRootObject = context.namespace.name === \"GObject\" && klass.name === \"Object\";\n declarations.push({ name: className, code: renderSignalConnectInterface(className, isRootObject) });\n }\n\n return declarations;\n};\n\nconst renderSignalMap = (spec: SignalMapSpec): string => {\n const { context, klass, className, isParentlessObjectSubclass, suffix, renderEntry } = spec;\n const extendsRefs = signalMapParentRefs(context, klass, isParentlessObjectSubclass, suffix);\n const extendsClause = extendsRefs.length === 0 ? \"\" : ` extends ${extendsRefs.join(\", \")}`;\n\n const signalEntries = collectClassSignals(context, klass).map(\n (signal) => `${signalDoc(signal)}${sourceStringLiteral(signal.name)}: ${renderEntry(context, signal)};`,\n );\n\n const entries = [\n ...signalEntries,\n ...renderNotifyDetailEntries(context, klass, suffix),\n ...renderCustomNotifyEntry(context, klass, suffix),\n ];\n\n return renderBracedOrEmpty(`export interface ${className}${suffix}${extendsClause}`, entries.join(\"\\n\"));\n};\n\nconst signalDoc = (signal: GirCallable): string =>\n renderJsDoc(signal.doc, undefined, handlerSpec(signal, signal.parameters));\n\nconst renderCustomNotifyEntry = (context: ModuleContext, klass: GirClass, suffix: string): string[] => {\n if (context.namespace.name !== \"GObject\" || klass.name !== \"Object\") {\n return [];\n }\n\n return [`[detail: \\`notify::\\${string}\\`]: ${gobjectObjectMapRef(context, suffix)}[\"notify\"];`];\n};\n\nconst renderNotifyDetailEntries = (context: ModuleContext, klass: GirClass, suffix: string): string[] => {\n const notifyValue = `${gobjectObjectMapRef(context, suffix)}[\"notify\"]`;\n\n return collectNotifyDetails(context, klass).map((property) => {\n const detailedSignal = `notify::${property.name}`;\n const doc = getDoc(property);\n\n return `${doc}${sourceStringLiteral(detailedSignal)}: ${notifyValue};`;\n });\n};\n\nconst signalMapParentRefs = (\n context: ModuleContext,\n klass: GirClass,\n isParentlessObjectSubclass: boolean,\n suffix: string,\n): string[] => {\n const parentRef = parentCompanionRef(context, klass, suffix);\n\n if (parentRef !== undefined) {\n return [parentRef];\n }\n\n if (!isParentlessObjectSubclass) {\n return [];\n }\n\n const prerequisiteRefs = klass.prerequisites\n .map((name) => resolvePrerequisiteReference(context, name))\n .filter((entry): entry is string => entry !== undefined)\n .map((entry) => `${entry}${suffix}`);\n\n if (prerequisiteRefs.length > 0) {\n return prerequisiteRefs;\n }\n\n return [gobjectObjectMapRef(context, suffix)];\n};\n\nconst gobjectObjectMapRef = (context: ModuleContext, suffix: string): string => {\n if (context.namespace.name === \"GObject\") {\n return `Object${suffix}`;\n }\n\n return `${context.addCrossNamespaceImport(\"GObject\")}.Object${suffix}`;\n};\n\nconst renderSignalConnectInterface = (className: string, isRootObject: boolean): string => {\n const map = `${className}${SIGNALS_SUFFIX}`;\n const emitMap = `${className}${SIGNAL_EMIT_SUFFIX}`;\n\n const lines = [\n `__signals__?: ${map};`,\n `connect<K extends keyof ${map}>(signal: K, handler: ${map}[K], isAfter?: boolean): number;`,\n `emit<K extends keyof ${emitMap}>(sigName: K, ...args: ${emitMap}[K][\"args\"]): ${emitMap}[K][\"result\"];`,\n \"emit(sigName: string, ...args: unknown[]): unknown;\",\n ];\n\n if (!isRootObject) {\n const chainable = (methods: string[], trailing: string): void => {\n for (const method of methods) {\n lines.push(\n deprecatedAliasDoc(method) +\n `${method}<K extends keyof ${map}>(signal: K, handler: ${map}[K]${trailing}): this;`,\n );\n }\n };\n\n chainable([\"on\", \"once\", \"addEventListener\"], \", isAfter?: boolean\");\n chainable([\"off\", \"removeEventListener\"], \"\");\n }\n\n return renderBracedOrEmpty(`export interface ${className}`, lines.join(\"\\n\"));\n};\n\nconst renderSignalHandlerType = (context: ModuleContext, signal: GirCallable): string => {\n const params = renderHandlerParameters(signal.parameters, (ref, nullable) => renderTsType(context, ref, nullable));\n\n return `(${params.join(\", \")}) => ${renderResultType(context, signal, false, true)}`;\n};\n\nconst renderResultType = (\n context: ModuleContext,\n signal: GirCallable,\n shouldIncludeCallerAllocated: boolean,\n isOptOut: boolean,\n): string =>\n renderHandlerResultType({\n library: context.library,\n signal,\n renderType: (ref, nullable) => renderTsType(context, ref, nullable),\n shouldIncludeCallerAllocated,\n isOptOut,\n });\n\nconst renderSignalEmitEntry = (context: ModuleContext, signal: GirCallable): string => {\n const args = renderHandlerParameters(\n signal.parameters,\n (ref, nullable) => renderTsType(context, ref, nullable),\n isCallerAllocatedOut,\n );\n\n const result = renderResultType(context, signal, true, false);\n\n return `{ args: [${args.join(\", \")}]; result: ${result} }`;\n};\n\nconst nonVarargParameters = (signal: GirCallable): GirParameter[] =>\n signal.parameters.filter((parameter) => !parameter.isVarargs);\n\nconst renderConnectCase = (context: ModuleContext, signal: GirCallable): string => {\n const callback = renderCallback(context, signal);\n const body = `return connectSignal(this, signal, { callback: ${callback}, handler, isAfter: isAfter ?? false });`;\n\n return renderBlock(`case ${sourceStringLiteral(signal.name)}:`, body);\n};\n\nconst renderEmitArgLiteral = (options: EmitArgOptions): { literal: string; nextArgIndex: number } => {\n const { context, parameter, descriptor, argIndex } = options;\n\n if (isOutParameter(parameter)) {\n return { literal: `{ type: ${descriptor}, direction: \"out\" }`, nextArgIndex: argIndex };\n }\n\n if (isCellInout(context.library, parameter)) {\n return {\n literal: `{ type: ${descriptor}, direction: \"inout\", value: args[${String(argIndex)}] }`,\n nextArgIndex: argIndex + 1,\n };\n }\n\n if (isCallerAllocatedOut(parameter)) {\n const value = renderCallerOutInstance(context, parameter);\n\n return {\n literal: `{ type: ${descriptor}, direction: \"out\", isCallerAllocated: true, value: ${value} }`,\n nextArgIndex: argIndex,\n };\n }\n\n if (isRecordInout(context, parameter)) {\n return {\n literal:\n `{ type: ${descriptor}, direction: \"inout\", isCallerAllocated: true, ` +\n `value: args[${String(argIndex)}] }`,\n nextArgIndex: argIndex + 1,\n };\n }\n\n return { literal: `{ type: ${descriptor}, value: args[${String(argIndex)}] }`, nextArgIndex: argIndex + 1 };\n};\n\nconst renderEmitReturnArg = (context: ModuleContext, returnValue: GirReturnValue): string => {\n if (primaryReturnKind(context.library, returnValue) === \"void\") {\n return \"\";\n }\n\n return `, ${renderDescriptor(context, returnValue.type, returnValue.transferOwnership)}`;\n};\n\nconst renderEmitCase = (context: ModuleContext, signal: GirCallable): string => {\n const params = nonVarargParameters(signal);\n\n if (params.some((parameter) => isCallerAllocatedOut(parameter) && !isAllocatableCallerOut(context, parameter))) {\n return renderUnsupportedEmitCase(signal);\n }\n\n context.addRuntimeImport(\"emitSignal\");\n let argIndex = 0;\n\n const argLiterals = params.map((parameter) => {\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership);\n const rendered = renderEmitArgLiteral({ context, parameter, descriptor, argIndex });\n argIndex = rendered.nextArgIndex;\n\n return rendered.literal;\n });\n\n const returnArg = renderEmitReturnArg(context, signal.returnValue);\n const body = `return emitSignal(this, sigName, [${argLiterals.join(\", \")}]${returnArg});`;\n\n return renderBlock(`case ${sourceStringLiteral(signal.name)}:`, body);\n};\n\nconst renderUnsupportedEmitCase = (signal: GirCallable): string => {\n const message = `emit() cannot allocate the caller-allocated out-parameter of '${signal.name}'`;\n\n return renderBlock(\n `case ${sourceStringLiteral(signal.name)}:`,\n `throw new globalThis.Error(${sourceStringLiteral(message)});`,\n );\n};\n\nconst renderCallback = (context: ModuleContext, signal: GirCallable): string => {\n const params = nonVarargParameters(signal);\n\n const callbackParamDescriptors = params.map((parameter) =>\n renderParamDescriptor(context, parameter, parameter.type, { argIndexOffset: 1 }),\n );\n\n const callbackArgs = [tObject(\"borrowed\"), ...callbackParamDescriptors, tVoid];\n const userDataIndex = String(params.length + 1);\n\n return tCallback({\n argTypes: callbackArgs,\n returns: renderDescriptor(context, signal.returnValue.type, signal.returnValue.transferOwnership),\n options: [\n \"hasDestroy: true\",\n \"destroyKind: \\\"closureNotify\\\"\",\n \"hasUserData: true\",\n `userDataIndex: ${userDataIndex}`,\n ],\n });\n};\n\nconst forEachInterfaceSignal = (\n context: ModuleContext,\n klass: GirClass,\n consider: (signal: GirCallable) => void,\n): void => {\n for (const iface of resolveInterfaces(context.library, context.namespace.name, klass.implements)) {\n for (const signal of iface.klass.signals) {\n consider(signal);\n }\n }\n};\n\nconst collectClassSignals = (context: ModuleContext, klass: GirClass): GirCallable[] => {\n const inheritedNames = collectInheritedSignalNames(context, klass);\n const seen: Set<string> = new Set();\n const result: GirCallable[] = [];\n\n const consider = (signal: GirCallable): void => {\n const name = camelCase(signal.name);\n\n if (!signal.introspectable || inheritedNames.has(name) || seen.has(name)) {\n return;\n }\n\n seen.add(name);\n result.push(signal);\n };\n\n for (const signal of klass.signals) {\n consider(signal);\n }\n\n forEachInterfaceSignal(context, klass, consider);\n\n return result;\n};\n\nconst addMemberNames = (target: Set<string>, source: GirClass, select: (source: GirClass) => NamedMember[]): void => {\n for (const member of select(source)) {\n target.add(camelCase(member.name));\n }\n};\n\nconst collectInheritedMemberNames = (\n context: ModuleContext,\n klass: GirClass,\n select: (source: GirClass) => NamedMember[],\n): Set<string> => {\n const names: Set<string> = new Set();\n\n forEachAncestor(context, klass, (ancestor, interfaces) => {\n addMemberNames(names, ancestor.klass, select);\n\n for (const iface of interfaces) {\n addMemberNames(names, iface.klass, select);\n }\n });\n\n return names;\n};\n\nconst collectInheritedSignalNames = (context: ModuleContext, klass: GirClass): Set<string> =>\n collectInheritedMemberNames(context, klass, (source) => source.signals);\n\nconst collectNotifyDetails = (context: ModuleContext, klass: GirClass): GirProperty[] => {\n const inherited = collectInheritedMemberNames(context, klass, (source) => source.properties);\n const seen: Set<string> = new Set();\n const result: GirProperty[] = [];\n\n const consider = (property: GirProperty): void => {\n const name = camelCase(property.name);\n\n if (inherited.has(name) || seen.has(name)) {\n return;\n }\n\n seen.add(name);\n result.push(property);\n };\n\n for (const property of klass.properties) {\n consider(property);\n }\n\n for (const { property } of collectInterfaceProperties(context, klass)) {\n consider(property);\n }\n\n return result;\n};\n\nexport { renderSignalMembers, renderSignalDeclarations };\n"]}
|
|
1
|
+
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../../src/store/gi/signal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAM7D,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EACH,0BAA0B,EAC1B,eAAe,EACf,4BAA4B,GAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,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,MAAM,QAAQ,GAAG,CAAC,QAAqB,EAAQ,EAAE;QAC7C,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEtC,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;IAED,KAAK,MAAM,EAAE,QAAQ,EAAE,IAAI,0BAA0B,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QACpE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,CAAC","sourcesContent":["import { camelCase, sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirClass, GirSignal } from \"../../gir/class.js\";\nimport type { GirCallable, GirParameter, GirReturnValue } from \"../../gir/parameter.js\";\nimport type { GirProperty } from \"../../gir/property.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport type { Declaration } from \"../../writer/module.js\";\nimport {\n isCellInout,\n primaryReturnKind,\n renderDescriptor,\n renderParamDescriptor,\n} from \"../../analysis/descriptor-render.js\";\nimport { tCallback, tObject, tVoid } from \"../../analysis/descriptor.js\";\nimport {\n collectInterfaceProperties,\n forEachAncestor,\n resolvePrerequisiteReference,\n} from \"../../analysis/inheritance.js\";\nimport { renderHandlerParameters, renderHandlerResultType } from \"../../analysis/param-structure.js\";\nimport { renderTsType } from \"../../analysis/ts-type.js\";\nimport { resolveInterfaces } from \"../../gir/ancestry.js\";\nimport { isCallerAllocatedOut, isOutParameter } from \"../../gir/parameter.js\";\nimport { renderJsDoc } from \"../../writer/doc.js\";\nimport { indent, renderBlock, renderBracedOrEmpty } from \"../../writer/emit.js\";\nimport { parentCompanionRef } from \"./companion.js\";\nimport { getDoc, handlerSpec } from \"./doc-spec.js\";\nimport { isAllocatableCallerOut, isRecordInout, renderCallerOutInstance } from \"./param-marshal.js\";\n\ntype SignalMapSpec = {\n context: ModuleContext;\n klass: GirClass;\n className: string;\n isParentlessObjectSubclass: boolean;\n suffix: string;\n renderEntry: (context: ModuleContext, signal: GirCallable) => string;\n};\n\ntype EmitArgOptions = {\n context: ModuleContext;\n parameter: GirParameter;\n descriptor: string;\n argIndex: number;\n};\n\ntype NamedMember = { name: string };\n\nconst SIGNAL_HANDLER_TYPE = \"(...args: any[]) => any\";\nconst SIGNALS_SUFFIX = \"Signals\";\nconst SIGNAL_EMIT_SUFFIX = \"SignalEmit\";\n\nconst DEPRECATED_SIGNAL_ALIASES: Map<string, string> = new Map([\n [\"addEventListener\", \"on\"],\n [\"removeEventListener\", \"off\"],\n]);\n\nconst deprecatedAliasDoc = (method: string): string => {\n const replacement = DEPRECATED_SIGNAL_ALIASES.get(method);\n\n if (replacement === undefined) {\n return \"\";\n }\n\n return `/** @deprecated Since 1.2. Use \\`${replacement}\\` instead. Removed in v2. */\\n`;\n};\n\nconst renderSignalMembers = (context: ModuleContext, klass: GirClass): string[] => {\n if (klass.glibGetType === undefined) {\n return [];\n }\n\n const signals = collectClassSignals(context, klass);\n\n if (signals.length === 0) {\n return [];\n }\n\n const isRootObject = context.namespace.name === \"GObject\" && klass.name === \"Object\";\n context.addRuntimeImport(\"connectSignal\");\n context.addRuntimeImport(\"getSignalBaseName\");\n context.addRuntimeImport(\"t\");\n const connectCases = signals.map((signal) => renderConnectCase(context, signal));\n const emitCases = signals.map((signal) => renderEmitCase(context, signal));\n\n const connectDefault = isRootObject\n ? \"default:\\n throw new globalThis.Error(\\\"Unknown signal '\\\" + signal + \\\"'\\\");\"\n : \"default:\\n return super.connect(signal as never, handler as never, isAfter);\";\n\n const emitDefault = isRootObject\n ? \"default:\\n throw new globalThis.Error(\\\"Unknown signal '\\\" + sigName + \\\"'\\\");\"\n : \"default:\\n return super.emit(sigName, ...args);\";\n\n const connectBody = indent([...connectCases, connectDefault].join(\"\\n\"), 1);\n const connectSwitch = `switch (getSignalBaseName(signal)) {\\n${connectBody}\\n}`;\n const emitBody = indent([...emitCases, emitDefault].join(\"\\n\"), 1);\n const emitSwitch = `switch (getSignalBaseName(sigName)) {\\n${emitBody}\\n}`;\n\n return [\n renderBlock(\n `connect(signal: string, handler: ${SIGNAL_HANDLER_TYPE}, isAfter?: boolean): number`,\n connectSwitch,\n ),\n renderBlock(\"emit(sigName: string, ...args: unknown[]): unknown\", emitSwitch),\n ];\n};\n\nconst renderSignalDeclarations = (\n context: ModuleContext,\n klass: GirClass,\n className: string,\n isParentlessObjectSubclass: boolean,\n): Declaration[] => {\n const base = { context, klass, className, isParentlessObjectSubclass };\n\n const declarations: Declaration[] = [\n {\n name: `${className}${SIGNALS_SUFFIX}`,\n code: renderSignalMap({ ...base, suffix: SIGNALS_SUFFIX, renderEntry: renderSignalHandlerType }),\n },\n {\n name: `${className}${SIGNAL_EMIT_SUFFIX}`,\n code: renderSignalMap({ ...base, suffix: SIGNAL_EMIT_SUFFIX, renderEntry: renderSignalEmitEntry }),\n },\n ];\n\n if (\n klass.glibGetType !== undefined &&\n (collectClassSignals(context, klass).length > 0 ||\n collectNotifyDetails(context, klass).length > 0 ||\n klass.implements.length > 0)\n ) {\n const isRootObject = context.namespace.name === \"GObject\" && klass.name === \"Object\";\n declarations.push({ name: className, code: renderSignalConnectInterface(className, isRootObject) });\n }\n\n return declarations;\n};\n\nconst renderSignalMap = (spec: SignalMapSpec): string => {\n const { context, klass, className, isParentlessObjectSubclass, suffix, renderEntry } = spec;\n const extendsRefs = signalMapParentRefs(context, klass, isParentlessObjectSubclass, suffix);\n const extendsClause = extendsRefs.length === 0 ? \"\" : ` extends ${extendsRefs.join(\", \")}`;\n const signals = collectClassSignals(context, klass);\n\n const signalEntries = signals.flatMap((signal) => {\n const value = renderEntry(context, signal);\n const entry = `${signalDoc(signal)}${sourceStringLiteral(signal.name)}: ${value};`;\n\n if (!signal.isDetailed) {\n return [entry];\n }\n\n return [entry, `[detail: \\`${signal.name}::\\${string}\\`]: ${value};`];\n });\n\n const entries = [...signalEntries, ...renderNotifyDetailEntries(context, klass, suffix)];\n\n return renderBracedOrEmpty(`export interface ${className}${suffix}${extendsClause}`, entries.join(\"\\n\"));\n};\n\nconst signalDoc = (signal: GirCallable): string =>\n renderJsDoc(signal.doc, undefined, handlerSpec(signal, signal.parameters));\n\nconst renderNotifyDetailEntries = (context: ModuleContext, klass: GirClass, suffix: string): string[] => {\n const notifyValue = `${gobjectObjectMapRef(context, suffix)}[\"notify\"]`;\n\n return collectNotifyDetails(context, klass).map((property) => {\n const detailedSignal = `notify::${property.name}`;\n const doc = getDoc(property);\n\n return `${doc}${sourceStringLiteral(detailedSignal)}: ${notifyValue};`;\n });\n};\n\nconst signalMapParentRefs = (\n context: ModuleContext,\n klass: GirClass,\n isParentlessObjectSubclass: boolean,\n suffix: string,\n): string[] => {\n const parentRef = parentCompanionRef(context, klass, suffix);\n\n if (parentRef !== undefined) {\n return [parentRef];\n }\n\n if (!isParentlessObjectSubclass) {\n return [];\n }\n\n const prerequisiteRefs = klass.prerequisites\n .map((name) => resolvePrerequisiteReference(context, name))\n .filter((entry): entry is string => entry !== undefined)\n .map((entry) => `${entry}${suffix}`);\n\n if (prerequisiteRefs.length > 0) {\n return prerequisiteRefs;\n }\n\n return [gobjectObjectMapRef(context, suffix)];\n};\n\nconst gobjectObjectMapRef = (context: ModuleContext, suffix: string): string => {\n if (context.namespace.name === \"GObject\") {\n return `Object${suffix}`;\n }\n\n return `${context.addCrossNamespaceImport(\"GObject\")}.Object${suffix}`;\n};\n\nconst renderSignalConnectInterface = (className: string, isRootObject: boolean): string => {\n const map = `${className}${SIGNALS_SUFFIX}`;\n const emitMap = `${className}${SIGNAL_EMIT_SUFFIX}`;\n\n const lines = [\n `__signals__?: ${map};`,\n `connect<K extends keyof ${map}>(signal: K, handler: ${map}[K], isAfter?: boolean): number;`,\n `emit<K extends keyof ${emitMap}>(sigName: K, ...args: ${emitMap}[K][\"args\"]): ${emitMap}[K][\"result\"];`,\n ];\n\n if (isRootObject) {\n lines.push(\"emit(sigName: string, ...args: unknown[]): unknown;\");\n } else {\n const chainable = (methods: string[], trailing: string): void => {\n for (const method of methods) {\n lines.push(\n deprecatedAliasDoc(method) +\n `${method}<K extends keyof ${map}>(signal: K, handler: ${map}[K]${trailing}): this;`,\n );\n }\n };\n\n chainable([\"on\", \"once\", \"addEventListener\"], \", isAfter?: boolean\");\n chainable([\"off\", \"removeEventListener\"], \"\");\n }\n\n return renderBracedOrEmpty(`export interface ${className}`, lines.join(\"\\n\"));\n};\n\nconst renderSignalHandlerType = (context: ModuleContext, signal: GirCallable): string => {\n const params = renderHandlerParameters(signal.parameters, (ref, nullable) => renderTsType(context, ref, nullable));\n\n return `(${params.join(\", \")}) => ${renderResultType(context, signal, false, true)}`;\n};\n\nconst renderResultType = (\n context: ModuleContext,\n signal: GirCallable,\n shouldIncludeCallerAllocated: boolean,\n isOptOut: boolean,\n): string =>\n renderHandlerResultType({\n library: context.library,\n signal,\n renderType: (ref, nullable) => renderTsType(context, ref, nullable),\n shouldIncludeCallerAllocated,\n isOptOut,\n });\n\nconst renderSignalEmitEntry = (context: ModuleContext, signal: GirCallable): string => {\n const args = renderHandlerParameters(\n signal.parameters,\n (ref, nullable) => renderTsType(context, ref, nullable),\n isCallerAllocatedOut,\n );\n\n const result = renderResultType(context, signal, true, false);\n\n return `{ args: [${args.join(\", \")}]; result: ${result} }`;\n};\n\nconst nonVarargParameters = (signal: GirCallable): GirParameter[] =>\n signal.parameters.filter((parameter) => !parameter.isVarargs);\n\nconst renderConnectCase = (context: ModuleContext, signal: GirCallable): string => {\n const callback = renderCallback(context, signal);\n const body = `return connectSignal(this, signal, { callback: ${callback}, handler, isAfter: isAfter ?? false });`;\n\n return renderBlock(`case ${sourceStringLiteral(signal.name)}:`, body);\n};\n\nconst renderEmitArgLiteral = (options: EmitArgOptions): { literal: string; nextArgIndex: number } => {\n const { context, parameter, descriptor, argIndex } = options;\n\n if (isOutParameter(parameter)) {\n return { literal: `{ type: ${descriptor}, direction: \"out\" }`, nextArgIndex: argIndex };\n }\n\n if (isCellInout(context.library, parameter)) {\n return {\n literal: `{ type: ${descriptor}, direction: \"inout\", value: args[${String(argIndex)}] }`,\n nextArgIndex: argIndex + 1,\n };\n }\n\n if (isCallerAllocatedOut(parameter)) {\n const value = renderCallerOutInstance(context, parameter);\n\n return {\n literal: `{ type: ${descriptor}, direction: \"out\", isCallerAllocated: true, value: ${value} }`,\n nextArgIndex: argIndex,\n };\n }\n\n if (isRecordInout(context, parameter)) {\n return {\n literal:\n `{ type: ${descriptor}, direction: \"inout\", isCallerAllocated: true, ` +\n `value: args[${String(argIndex)}] }`,\n nextArgIndex: argIndex + 1,\n };\n }\n\n return { literal: `{ type: ${descriptor}, value: args[${String(argIndex)}] }`, nextArgIndex: argIndex + 1 };\n};\n\nconst renderEmitReturnArg = (context: ModuleContext, returnValue: GirReturnValue): string => {\n if (primaryReturnKind(context.library, returnValue) === \"void\") {\n return \"\";\n }\n\n return `, ${renderDescriptor(context, returnValue.type, returnValue.transferOwnership)}`;\n};\n\nconst renderEmitCase = (context: ModuleContext, signal: GirCallable): string => {\n const params = nonVarargParameters(signal);\n\n if (params.some((parameter) => isCallerAllocatedOut(parameter) && !isAllocatableCallerOut(context, parameter))) {\n return renderUnsupportedEmitCase(signal);\n }\n\n context.addRuntimeImport(\"emitSignal\");\n let argIndex = 0;\n\n const argLiterals = params.map((parameter) => {\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership);\n const rendered = renderEmitArgLiteral({ context, parameter, descriptor, argIndex });\n argIndex = rendered.nextArgIndex;\n\n return rendered.literal;\n });\n\n const returnArg = renderEmitReturnArg(context, signal.returnValue);\n const body = `return emitSignal(this, sigName, [${argLiterals.join(\", \")}]${returnArg});`;\n\n return renderBlock(`case ${sourceStringLiteral(signal.name)}:`, body);\n};\n\nconst renderUnsupportedEmitCase = (signal: GirCallable): string => {\n const message = `emit() cannot allocate the caller-allocated out-parameter of '${signal.name}'`;\n\n return renderBlock(\n `case ${sourceStringLiteral(signal.name)}:`,\n `throw new globalThis.Error(${sourceStringLiteral(message)});`,\n );\n};\n\nconst renderCallback = (context: ModuleContext, signal: GirCallable): string => {\n const params = nonVarargParameters(signal);\n\n const callbackParamDescriptors = params.map((parameter) =>\n renderParamDescriptor(context, parameter, parameter.type, { argIndexOffset: 1 }),\n );\n\n const callbackArgs = [tObject(\"borrowed\"), ...callbackParamDescriptors, tVoid];\n const userDataIndex = String(params.length + 1);\n\n return tCallback({\n argTypes: callbackArgs,\n returns: renderDescriptor(context, signal.returnValue.type, signal.returnValue.transferOwnership),\n options: [\n \"hasDestroy: true\",\n \"destroyKind: \\\"closureNotify\\\"\",\n \"hasUserData: true\",\n `userDataIndex: ${userDataIndex}`,\n ],\n });\n};\n\nconst forEachInterfaceSignal = (\n context: ModuleContext,\n klass: GirClass,\n consider: (signal: GirSignal) => void,\n): void => {\n for (const iface of resolveInterfaces(context.library, context.namespace.name, klass.implements)) {\n for (const signal of iface.klass.signals) {\n consider(signal);\n }\n }\n};\n\nconst collectClassSignals = (context: ModuleContext, klass: GirClass): GirSignal[] => {\n const inheritedNames = collectInheritedSignalNames(context, klass);\n const seen: Set<string> = new Set();\n const result: GirSignal[] = [];\n\n const consider = (signal: GirSignal): void => {\n const name = camelCase(signal.name);\n\n if (!signal.introspectable || inheritedNames.has(name) || seen.has(name)) {\n return;\n }\n\n seen.add(name);\n result.push(signal);\n };\n\n for (const signal of klass.signals) {\n consider(signal);\n }\n\n forEachInterfaceSignal(context, klass, consider);\n\n return result;\n};\n\nconst addMemberNames = (target: Set<string>, source: GirClass, select: (source: GirClass) => NamedMember[]): void => {\n for (const member of select(source)) {\n target.add(camelCase(member.name));\n }\n};\n\nconst collectInheritedMemberNames = (\n context: ModuleContext,\n klass: GirClass,\n select: (source: GirClass) => NamedMember[],\n): Set<string> => {\n const names: Set<string> = new Set();\n\n forEachAncestor(context, klass, (ancestor, interfaces) => {\n addMemberNames(names, ancestor.klass, select);\n\n for (const iface of interfaces) {\n addMemberNames(names, iface.klass, select);\n }\n });\n\n return names;\n};\n\nconst collectInheritedSignalNames = (context: ModuleContext, klass: GirClass): Set<string> =>\n collectInheritedMemberNames(context, klass, (source) => source.signals);\n\nconst collectNotifyDetails = (context: ModuleContext, klass: GirClass): GirProperty[] => {\n const inherited = collectInheritedMemberNames(context, klass, (source) => source.properties);\n const seen: Set<string> = new Set();\n const result: GirProperty[] = [];\n\n const consider = (property: GirProperty): void => {\n const name = camelCase(property.name);\n\n if (inherited.has(name) || seen.has(name)) {\n return;\n }\n\n seen.add(name);\n result.push(property);\n };\n\n for (const property of klass.properties) {\n consider(property);\n }\n\n for (const { property } of collectInterfaceProperties(context, klass)) {\n consider(property);\n }\n\n return result;\n};\n\nexport { renderSignalMembers, renderSignalDeclarations };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-store.d.ts","sourceRoot":"","sources":["../../src/store/resolve-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD;;;GAGG;AACH,KAAK,aAAa,GAAG;IACjB,mFAAmF;IACnF,EAAE,EAAE,YAAY,CAAC;IACjB,0GAA0G;IAC1G,GAAG,EAAE,YAAY,GAAG,IAAI,CAAC;IACzB,+EAA+E;IAC/E,eAAe,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-store.d.ts","sourceRoot":"","sources":["../../src/store/resolve-store.ts"],"names":[],"mappings":"AAEA,OAA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AE,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC;QACnC,eAAe,EAAE,kBAAkB,CAAC,KAAK,CAAC;KAC7C,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,mBAAmB,EAAsB,CAAC","sourcesContent":["import { existsSync, readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, join, parse, relative, sep } from \"node:path\";\nimport type { StoreOptions } from \"./store-fs.js\";\nimport { sweepStagingDirs } from \"../staging.js\";\n\n/**\n * Where a project's generated stores live, ready to spread into `runCodegen`. `jsx` is null when the\n * project has no `@gtkx/react` installed, in which case only the `@gtkx/gi` store can be generated.\n */\ntype ResolvedStore = {\n /** Where the `@gtkx/gi` store goes, versioned by the installed `@gtkx/runtime`. */\n gi: StoreOptions;\n /** Where the `@gtkx/jsx` store goes, versioned by the installed `@gtkx/react`; null when it is absent. */\n jsx: StoreOptions | null;\n /** Subexport names of the installed `@gtkx/react`, empty when it is absent. */\n reactSubexports: string[];\n};\n\ntype ResolvedPackage = { dir: string; nodeModules: string; version: string };\ntype StoreConsumer = { name: string; nodeModules: string };\n\nconst STORE_DIR = \".gtkx\";\nconst SCOPE = \"@gtkx\";\nconst STORE_NAMES: string[] = [\"gi\", \"jsx\"];\n\nconst STORE_CONSUMERS: string[] = [\n \"@gtkx/cli\",\n \"@gtkx/components\",\n \"@gtkx/css\",\n \"@gtkx/react\",\n \"@gtkx/testing\",\n];\n\nconst readManifest = (path: string): { version?: string; exports?: Record<string, unknown> } =>\n JSON.parse(readFileSync(path, \"utf8\")) as { version?: string; exports?: Record<string, unknown> };\n\nconst subexportNames = (packageDir: string): string[] =>\n Object.keys(readManifest(join(packageDir, \"package.json\")).exports ?? {})\n .filter((key) => key.startsWith(\"./\") && key !== \"./package.json\")\n .map((key) => key.slice(2));\n\nconst loadPackage = (manifest: string, nodeModules: string): ResolvedPackage | null => {\n if (!existsSync(manifest)) {\n return null;\n }\n\n const real = realpathSync(manifest);\n\n return { dir: dirname(real), nodeModules, version: readManifest(real).version ?? \"0.0.0\" };\n};\n\nconst nodeModulesChain = function* (projectRoot: string): Generator<string> {\n const { root } = parse(projectRoot);\n let current = projectRoot;\n\n while (current !== root) {\n yield join(current, \"node_modules\");\n current = dirname(current);\n }\n\n yield join(root, \"node_modules\");\n};\n\nconst resolvePackage = (projectRoot: string, packageName: string): ResolvedPackage | null => {\n for (const nodeModules of nodeModulesChain(projectRoot)) {\n const found = loadPackage(join(nodeModules, packageName, \"package.json\"), nodeModules);\n\n if (found !== null) {\n return found;\n }\n }\n\n const unscoped = packageName.replace(/^@[^/]+\\//, \"\");\n\n return loadPackage(join(projectRoot, \"packages\", unscoped, \"package.json\"), join(projectRoot, \"node_modules\"));\n};\n\nconst isWithin = (parent: string, child: string): boolean => {\n const path = relative(parent, child);\n\n return path === \"\" || (path !== \"..\" && !path.startsWith(`..${sep}`));\n};\n\nconst canImport = (fromNodeModules: string, targetNodeModules: string): boolean =>\n isWithin(dirname(targetNodeModules), dirname(fromNodeModules));\n\nconst storeOptions = (nodeModules: string, name: string, version: string): StoreOptions => ({\n storeDir: join(nodeModules, STORE_DIR, name),\n linkDir: join(nodeModules, SCOPE, name),\n version,\n});\n\nconst resolveRuntime = (projectRoot: string): ResolvedPackage => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n throw new Error(`Cannot resolve @gtkx/runtime from ${projectRoot}; is it installed?`);\n }\n\n return runtime;\n};\n\nconst storeNodeModules = (runtime: ResolvedPackage, react: ResolvedPackage | null): string => {\n if (react !== null && canImport(react.nodeModules, runtime.nodeModules)) {\n return react.nodeModules;\n }\n\n return runtime.nodeModules;\n};\n\nconst findUnreachableConsumer = (projectRoot: string, nodeModules: string): StoreConsumer | null => {\n for (const name of STORE_CONSUMERS) {\n const consumer = resolvePackage(projectRoot, name);\n\n if (consumer !== null && !canImport(consumer.nodeModules, nodeModules)) {\n return { name, nodeModules: consumer.nodeModules };\n }\n }\n\n return null;\n};\n\nconst unreachableConsumerMessage = (consumer: StoreConsumer, nodeModules: string): string =>\n `Cannot write the generated store to ${nodeModules}: ${consumer.name} is installed in ` +\n `${consumer.nodeModules}, above it, so that copy can never import the generated @gtkx/gi. Install every ` +\n \"@gtkx package in one node_modules, then run gtkx codegen again.\";\n\nconst checkConsumers = (projectRoot: string, nodeModules: string): void => {\n const consumer = findUnreachableConsumer(projectRoot, nodeModules);\n\n if (consumer !== null) {\n throw new Error(unreachableConsumerMessage(consumer, nodeModules));\n }\n};\n\nconst jsxOptions = (react: ResolvedPackage | null, nodeModules: string): StoreOptions | null =>\n react === null ? null : storeOptions(nodeModules, \"jsx\", react.version);\n\nconst getReactSubexports = (react: ResolvedPackage | null): string[] =>\n react === null ? [] : subexportNames(react.dir);\n\nconst storePaths = (nodeModules: string): string[] =>\n STORE_NAMES.flatMap((name) => [join(nodeModules, STORE_DIR, name), join(nodeModules, SCOPE, name)]);\n\nconst findStoreNodeModules = (projectRoot: string): string | null => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n return null;\n }\n\n return storeNodeModules(runtime, resolvePackage(projectRoot, \"@gtkx/react\"));\n};\n\nconst getShadowingStorePaths = (projectRoot: string): string[] => {\n const nodeModules = join(projectRoot, \"node_modules\");\n const anchored = findStoreNodeModules(projectRoot);\n\n if (anchored === null || anchored === nodeModules) {\n return [];\n }\n\n return storePaths(nodeModules);\n};\n\nconst stagingRoots = (projectRoot: string): string[] => {\n const nodeModules = join(projectRoot, \"node_modules\");\n const anchored = findStoreNodeModules(projectRoot);\n\n return anchored === null || anchored === nodeModules ? [nodeModules] : [nodeModules, anchored];\n};\n\nconst sweepProjectStaging = (projectRoot: string): void => {\n for (const nodeModules of stagingRoots(projectRoot)) {\n for (const name of STORE_NAMES) {\n sweepStagingDirs(join(nodeModules, STORE_DIR, name));\n }\n }\n};\n\n/**\n * Resolves where a project's `@gtkx/gi` and `@gtkx/jsx` stores belong, from the project root alone. The\n * result supplies every `runCodegen` input except `libraries` and `girPath`, so a caller that has\n * already resolved those can spread it straight into the call.\n *\n * Both stores go in one `node_modules`, found by walking the project's `node_modules` chain upwards:\n * the one `@gtkx/react` resolves from, or `@gtkx/runtime`'s when no React is installed. That is the\n * project's own directory when it installs those packages itself, and the workspace root when npm or\n * yarn hoisted them there. Keeping the pair together is what lets the jsx store import the gi store, and\n * anchoring them where the `@gtkx` packages sit is what lets `@gtkx/react`, the CLI, and the project's\n * sources all reach the bindings. A package manager that hoists therefore gives every project sharing\n * that `node_modules` one shared store.\n *\n * Store versions come from the installed `@gtkx/runtime` and `@gtkx/react`, so a dependency upgrade\n * invalidates the stores. Pass explicit `gi` or `jsx` options to `runCodegen` to override any of it.\n *\n * @param projectRoot Directory holding the project's `package.json`, whose `node_modules` chain is walked.\n * @returns The store locations and the React subexports that shape the jsx store.\n * @throws If `@gtkx/runtime` cannot be resolved from the project, or a `@gtkx` package that imports the\n * bindings is installed above the `node_modules` the stores would go in, since it could not reach them.\n */\nconst resolveStore = (projectRoot: string): ResolvedStore => {\n const runtime = resolveRuntime(projectRoot);\n const react = resolvePackage(projectRoot, \"@gtkx/react\");\n const nodeModules = storeNodeModules(runtime, react);\n checkConsumers(projectRoot, nodeModules);\n\n return {\n gi: storeOptions(nodeModules, \"gi\", runtime.version),\n jsx: jsxOptions(react, nodeModules),\n reactSubexports: getReactSubexports(react),\n };\n};\n\nexport { getShadowingStorePaths, resolveStore, sweepProjectStaging, type ResolvedStore };\n"]}
|
|
1
|
+
{"version":3,"file":"resolve-store.js","sourceRoot":"","sources":["../../src/store/resolve-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;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iB,EAAE;IACxD,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrD,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAEzC,OAAO;QACH,EAAE,EAAE,YAAY,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC;QACpD,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC;QACnC,eAAe,EAAE,kBAAkB,CAAC,KAAK,CAAC;KAC7C,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,mBAAmB,EAAsB,CAAC","sourcesContent":["import { existsSync, readFileSync, realpathSync } from \"node:fs\";\nimport { dirname, join, parse, relative, sep } from \"node:path\";\nimport type { StoreOptions } from \"./store-fs.js\";\nimport { sweepStagingDirs } from \"../staging.js\";\n\n/**\n * Where a project's generated stores live, ready to spread into `runCodegen`. `jsx` is null when the\n * project has no `@gtkx/react` installed, in which case only the `@gtkx/gi` store can be generated.\n */\ntype ResolvedStore = {\n /** Where the `@gtkx/gi` store goes, versioned by the installed `@gtkx/runtime`. */\n gi: StoreOptions;\n /** Where the `@gtkx/jsx` store goes, versioned by the installed `@gtkx/react`; null when it is absent. */\n jsx: StoreOptions | null;\n /** Subexport names of the installed `@gtkx/react`, empty when it is absent. */\n reactSubexports: string[];\n};\n\ntype ResolvedPackage = { dir: string; nodeModules: string; version: string };\ntype StoreConsumer = { name: string; nodeModules: string };\n\nconst STORE_DIR = \".gtkx\";\nconst SCOPE = \"@gtkx\";\nconst STORE_NAMES: string[] = [\"gi\", \"jsx\"];\n\nconst STORE_CONSUMERS: string[] = [\n \"@gtkx/cli\",\n \"@gtkx/components\",\n \"@gtkx/css\",\n \"@gtkx/react\",\n \"@gtkx/runtime\",\n \"@gtkx/testing\",\n];\n\nconst readManifest = (path: string): { version?: string; exports?: Record<string, unknown> } =>\n JSON.parse(readFileSync(path, \"utf8\")) as { version?: string; exports?: Record<string, unknown> };\n\nconst subexportNames = (packageDir: string): string[] =>\n Object.keys(readManifest(join(packageDir, \"package.json\")).exports ?? {})\n .filter((key) => key.startsWith(\"./\") && key !== \"./package.json\")\n .map((key) => key.slice(2));\n\nconst loadPackage = (manifest: string, nodeModules: string): ResolvedPackage | null => {\n if (!existsSync(manifest)) {\n return null;\n }\n\n const real = realpathSync(manifest);\n\n return { dir: dirname(real), nodeModules, version: readManifest(real).version ?? \"0.0.0\" };\n};\n\nconst nodeModulesChain = function* (projectRoot: string): Generator<string> {\n const { root } = parse(projectRoot);\n let current = projectRoot;\n\n while (current !== root) {\n yield join(current, \"node_modules\");\n current = dirname(current);\n }\n\n yield join(root, \"node_modules\");\n};\n\nconst resolvePackage = (projectRoot: string, packageName: string): ResolvedPackage | null => {\n for (const nodeModules of nodeModulesChain(projectRoot)) {\n const found = loadPackage(join(nodeModules, packageName, \"package.json\"), nodeModules);\n\n if (found !== null) {\n return found;\n }\n }\n\n const unscoped = packageName.replace(/^@[^/]+\\//, \"\");\n\n return loadPackage(join(projectRoot, \"packages\", unscoped, \"package.json\"), join(projectRoot, \"node_modules\"));\n};\n\nconst isWithin = (parent: string, child: string): boolean => {\n const path = relative(parent, child);\n\n return path === \"\" || (path !== \"..\" && !path.startsWith(`..${sep}`));\n};\n\nconst canImport = (fromNodeModules: string, targetNodeModules: string): boolean =>\n isWithin(dirname(targetNodeModules), dirname(fromNodeModules));\n\nconst storeOptions = (nodeModules: string, name: string, version: string): StoreOptions => ({\n storeDir: join(nodeModules, STORE_DIR, name),\n linkDir: join(nodeModules, SCOPE, name),\n version,\n});\n\nconst resolveRuntime = (projectRoot: string): ResolvedPackage => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n throw new Error(`Cannot resolve @gtkx/runtime from ${projectRoot}; is it installed?`);\n }\n\n return runtime;\n};\n\nconst storeNodeModules = (runtime: ResolvedPackage, react: ResolvedPackage | null): string => {\n if (react !== null && canImport(react.nodeModules, runtime.nodeModules)) {\n return react.nodeModules;\n }\n\n return runtime.nodeModules;\n};\n\nconst findUnreachableConsumer = (projectRoot: string, nodeModules: string): StoreConsumer | null => {\n for (const name of STORE_CONSUMERS) {\n const consumer = resolvePackage(projectRoot, name);\n\n if (consumer !== null && !canImport(consumer.nodeModules, nodeModules)) {\n return { name, nodeModules: consumer.nodeModules };\n }\n }\n\n return null;\n};\n\nconst unreachableConsumerMessage = (consumer: StoreConsumer, nodeModules: string): string =>\n `Cannot write the generated store to ${nodeModules}: ${consumer.name} is installed in ` +\n `${consumer.nodeModules}, above it, so that copy can never import the generated @gtkx/gi. Install every ` +\n \"@gtkx package in one node_modules, then run gtkx codegen again.\";\n\nconst checkConsumers = (projectRoot: string, nodeModules: string): void => {\n const consumer = findUnreachableConsumer(projectRoot, nodeModules);\n\n if (consumer !== null) {\n throw new Error(unreachableConsumerMessage(consumer, nodeModules));\n }\n};\n\nconst jsxOptions = (react: ResolvedPackage | null, nodeModules: string): StoreOptions | null =>\n react === null ? null : storeOptions(nodeModules, \"jsx\", react.version);\n\nconst getReactSubexports = (react: ResolvedPackage | null): string[] =>\n react === null ? [] : subexportNames(react.dir);\n\nconst storePaths = (nodeModules: string): string[] =>\n STORE_NAMES.flatMap((name) => [join(nodeModules, STORE_DIR, name), join(nodeModules, SCOPE, name)]);\n\nconst findStoreNodeModules = (projectRoot: string): string | null => {\n const runtime = resolvePackage(projectRoot, \"@gtkx/runtime\");\n\n if (runtime === null) {\n return null;\n }\n\n return storeNodeModules(runtime, resolvePackage(projectRoot, \"@gtkx/react\"));\n};\n\nconst getShadowingStorePaths = (projectRoot: string): string[] => {\n const nodeModules = join(projectRoot, \"node_modules\");\n const anchored = findStoreNodeModules(projectRoot);\n\n if (anchored === null || anchored === nodeModules) {\n return [];\n }\n\n return storePaths(nodeModules);\n};\n\nconst stagingRoots = (projectRoot: string): string[] => {\n const nodeModules = join(projectRoot, \"node_modules\");\n const anchored = findStoreNodeModules(projectRoot);\n\n return anchored === null || anchored === nodeModules ? [nodeModules] : [nodeModules, anchored];\n};\n\nconst sweepProjectStaging = (projectRoot: string): void => {\n for (const nodeModules of stagingRoots(projectRoot)) {\n for (const name of STORE_NAMES) {\n sweepStagingDirs(join(nodeModules, STORE_DIR, name));\n }\n }\n};\n\n/**\n * Resolves where a project's `@gtkx/gi` and `@gtkx/jsx` stores belong, from the project root alone. The\n * result supplies every `runCodegen` input except `libraries` and `girPath`, so a caller that has\n * already resolved those can spread it straight into the call.\n *\n * Both stores go in one `node_modules`, found by walking the project's `node_modules` chain upwards:\n * the one `@gtkx/react` resolves from, or `@gtkx/runtime`'s when no React is installed. That is the\n * project's own directory when it installs those packages itself, and the workspace root when npm or\n * yarn hoisted them there. Keeping the pair together is what lets the jsx store import the gi store, and\n * anchoring them where the `@gtkx` packages sit is what lets `@gtkx/react`, the CLI, and the project's\n * sources all reach the bindings. A package manager that hoists therefore gives every project sharing\n * that `node_modules` one shared store.\n *\n * Store versions come from the installed `@gtkx/runtime` and `@gtkx/react`, so a dependency upgrade\n * invalidates the stores. Pass explicit `gi` or `jsx` options to `runCodegen` to override any of it.\n *\n * @param projectRoot Directory holding the project's `package.json`, whose `node_modules` chain is walked.\n * @returns The store locations and the React subexports that shape the jsx store.\n * @throws If `@gtkx/runtime` cannot be resolved from the project, or a `@gtkx` package that imports the\n * bindings is installed above the `node_modules` the stores would go in, since it could not reach them.\n */\nconst resolveStore = (projectRoot: string): ResolvedStore => {\n const runtime = resolveRuntime(projectRoot);\n const react = resolvePackage(projectRoot, \"@gtkx/react\");\n const nodeModules = storeNodeModules(runtime, react);\n checkConsumers(projectRoot, nodeModules);\n\n return {\n gi: storeOptions(nodeModules, \"gi\", runtime.version),\n jsx: jsxOptions(react, nodeModules),\n reactSubexports: getReactSubexports(react),\n };\n};\n\nexport { getShadowingStorePaths, resolveStore, sweepProjectStaging, type ResolvedStore };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/codegen",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Generates the typed GTKX bindings and API reference from GIR and OpenGL registry data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"fast-xml-parser": "^5.10.1",
|
|
59
59
|
"fast-xml-validator": "^1.4.1",
|
|
60
60
|
"typescript": "^6.0.3",
|
|
61
|
-
"@gtkx/
|
|
62
|
-
"@gtkx/
|
|
61
|
+
"@gtkx/utils": "1.2.2",
|
|
62
|
+
"@gtkx/react": "1.2.2"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"release": "tsx ../../scripts/release-package.ts"
|
package/src/docs/symbol-page.ts
CHANGED
|
@@ -633,7 +633,7 @@ const fieldsSection = (record: GirRecord, context: ModuleContext, claimedNames:
|
|
|
633
633
|
const entries: MetaDocEntry[] = [];
|
|
634
634
|
|
|
635
635
|
for (const slot of slots) {
|
|
636
|
-
const field = resolveRecordFieldEntry(context, slot, claimedNames);
|
|
636
|
+
const field = resolveRecordFieldEntry(context, slot, claimedNames, record.fields);
|
|
637
637
|
|
|
638
638
|
if (field === undefined) {
|
|
639
639
|
continue;
|
package/src/gir/class.ts
CHANGED
|
@@ -11,6 +11,12 @@ type GirVirtualMethod = GirCallable & {
|
|
|
11
11
|
invoker: string | undefined;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
/** A `<glib:signal>` on a class or interface. */
|
|
15
|
+
type GirSignal = GirCallable & {
|
|
16
|
+
/** Whether the signal takes a `::detail` suffix, so `changed::key` reaches only that detail. */
|
|
17
|
+
isDetailed: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
14
20
|
/** A `<class>` or `<interface>` declared by a GIR namespace. */
|
|
15
21
|
type GirClass = {
|
|
16
22
|
/** Name GIR gives the type, without its namespace prefix. */
|
|
@@ -54,7 +60,7 @@ type GirClass = {
|
|
|
54
60
|
/** GObject properties the type declares. */
|
|
55
61
|
properties: GirProperty[];
|
|
56
62
|
/** GObject signals the type declares. */
|
|
57
|
-
signals:
|
|
63
|
+
signals: GirSignal[];
|
|
58
64
|
/** Virtual methods the type declares, carrying the documentation their vtable slots are generated from. */
|
|
59
65
|
vfuncs: GirVirtualMethod[];
|
|
60
66
|
};
|
|
@@ -88,8 +94,11 @@ const classFromNode = (node: RawNode, isInterface: boolean, context: ParseContex
|
|
|
88
94
|
constructors: getChildren(node, GIR_CONSTRUCTOR_TAG).map((ctor) => functionFromNode(ctor, context)),
|
|
89
95
|
functions: getChildren(node, "function").map((fn) => functionFromNode(fn, context)),
|
|
90
96
|
properties: getChildren(node, "property").map((property) => propertyFromNode(property, context)),
|
|
91
|
-
signals: getChildren(node, "glib:signal").map((signal) =>
|
|
97
|
+
signals: getChildren(node, "glib:signal").map((signal) => ({
|
|
98
|
+
...parseCallable(signal, context),
|
|
99
|
+
isDetailed: isAttrTrue(signal, "detailed"),
|
|
100
|
+
})),
|
|
92
101
|
vfuncs: virtualMethodsFromNode(node, context),
|
|
93
102
|
});
|
|
94
103
|
|
|
95
|
-
export { classFromNode, type GirClass, type GirVirtualMethod };
|
|
104
|
+
export { classFromNode, type GirClass, type GirSignal, type GirVirtualMethod };
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
renderStaticHead,
|
|
22
22
|
} from "./callables.js";
|
|
23
23
|
import { annotationSpec, getDoc } from "./doc-spec.js";
|
|
24
|
-
import { renderSourceGtype } from "./gtype-binding.js";
|
|
24
|
+
import { gtypeMemberDeclaration, renderSourceGtype } from "./gtype-binding.js";
|
|
25
25
|
import { methodExportName } from "./method.js";
|
|
26
26
|
import {
|
|
27
27
|
type PropertyAccessorArgs,
|
|
@@ -378,7 +378,7 @@ const renderInterfaceClass = (context: ModuleContext, options: InterfaceClassOpt
|
|
|
378
378
|
const members: string[] = [];
|
|
379
379
|
|
|
380
380
|
if (gtypeExpr !== undefined) {
|
|
381
|
-
members.push(renderInterfaceHasInstance(context, className, gtypeExpr));
|
|
381
|
+
members.push(gtypeMemberDeclaration(context), renderInterfaceHasInstance(context, className, gtypeExpr));
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
members.push(...renderStaticHead(context, callables, className), renderInterfaceBrand(context, implRef));
|
|
@@ -11,7 +11,7 @@ import { renderBlock, renderBracedOrEmpty } from "../../writer/emit.js";
|
|
|
11
11
|
import { type Callables, staticMembers } from "./callables.js";
|
|
12
12
|
import { getDoc } from "./doc-spec.js";
|
|
13
13
|
import { renderSourceGtype } from "./gtype-binding.js";
|
|
14
|
-
import { emitFieldWrite, isEmittableField, isInlineField } from "./record-field-accessor.js";
|
|
14
|
+
import { emitFieldWrite, isEmittableField, isInlineField, isStorableFieldType } from "./record-field-accessor.js";
|
|
15
15
|
import { computeRecordFieldSlots, type RecordFieldSlot } from "./record-layout.js";
|
|
16
16
|
import { isConstructibleRecord } from "./value-marshalable.js";
|
|
17
17
|
|
|
@@ -25,7 +25,9 @@ type RecordConstructorSpec = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const isWritableFieldSlot = (context: ModuleContext, entry: RecordFieldSlot): entry is WritableFieldSlot =>
|
|
28
|
-
entry.field.writable &&
|
|
28
|
+
entry.field.writable &&
|
|
29
|
+
isEmittableField(context, entry.field) &&
|
|
30
|
+
isStorableFieldType(context, entry.field.type);
|
|
29
31
|
|
|
30
32
|
const renderRecordConstructorPropsInterface = (
|
|
31
33
|
context: ModuleContext,
|