fix(artifacts): read AppKit connectors from flat keyed-archive NIBs (#900)
* fix(artifacts): read AppKit connectors from flat keyed-archive NIBs Flat AppKit NIBs archive NSNibOutletConnector and NSNibControlConnector endpoints and the outlet or selector name under NSSource, NSDestination, and NSLabel. The keyed-archive parser read only source, destination, and label, so it skipped every such connector: XLD.app's 64 decoded NIBs had no outlet or target-action edges. The NS-prefixed keys now follow the same source and destination convention as compiled NIBArchive documents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(artifacts): read AppKit control connectors from the control to its target NSNibControlConnector archives NSSource as the sending control and NSDestination as the action target. The previous commit inverted them like the unprefixed fields, so every flat AppKit action ran from the target to the control. The action trace selects a control and follows control -> action, and the graph keys the selector by its target, so neither could resolve these actions. The NS-prefixed keys are now read as source and destination for outlets and actions alike. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(artifacts): key AppKit connector endpoints by their node identity An NSSource or NSDestination object with an identifier field was referenced by that identifier, but its node is keyed by its authored object ID or archive UID. The connector then pointed at a synthetic unknown node. NS-prefixed endpoints now use the referenced object's node identity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f0a68dce60
commit
27c272bd9a
@@ -317,3 +317,110 @@ describe("keyed archive decoding and graph limits", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("AppKit keyed archive connectors", () => {
|
||||
it("reads outlet and control connectors from NS-prefixed keys", () => {
|
||||
const parsed = parseInterfaceBuilderRecords({
|
||||
$archiver: "NSKeyedArchiver",
|
||||
$objects: [
|
||||
"$null",
|
||||
{ $class: { UID: 6 } },
|
||||
{ $class: { UID: 7 }, identifier: "unrelated-identifier" },
|
||||
{
|
||||
$class: { UID: 8 },
|
||||
NSSource: { UID: 1 },
|
||||
NSDestination: { UID: 2 },
|
||||
NSLabel: { UID: 5 },
|
||||
},
|
||||
{
|
||||
$class: { UID: 9 },
|
||||
NSSource: { UID: 2 },
|
||||
NSDestination: { UID: 1 },
|
||||
NSLabel: { UID: 10 },
|
||||
},
|
||||
"o_button",
|
||||
{
|
||||
$classname: "NSCustomObject",
|
||||
$classes: ["NSCustomObject", "NSObject"],
|
||||
},
|
||||
{ $classname: "NSButton", $classes: ["NSButton", "NSObject"] },
|
||||
{
|
||||
$classname: "NSNibOutletConnector",
|
||||
$classes: ["NSNibOutletConnector", "NSNibConnector", "NSObject"],
|
||||
},
|
||||
{
|
||||
$classname: "NSNibControlConnector",
|
||||
$classes: ["NSNibControlConnector", "NSNibConnector", "NSObject"],
|
||||
},
|
||||
"buttonClicked:",
|
||||
],
|
||||
$top: {},
|
||||
});
|
||||
|
||||
expect(parsed.connections).toEqual([
|
||||
expect.objectContaining({
|
||||
kind: "outlet",
|
||||
source_id: "1",
|
||||
destination_id: "2",
|
||||
label: "o_button",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
kind: "action",
|
||||
source_id: "2",
|
||||
destination_id: "1",
|
||||
label: "buttonClicked:",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it("projects an AppKit action from the control through the selector to its target", () => {
|
||||
const analysis = buildInterfaceBuilderAnalysis({
|
||||
targetSha256: hash,
|
||||
toolVersion: "test",
|
||||
documents: [
|
||||
{
|
||||
relativePath: "MainMenu.nib",
|
||||
archiveSha256: hash,
|
||||
documentKind: "nib",
|
||||
raw: {
|
||||
$archiver: "NSKeyedArchiver",
|
||||
$objects: [
|
||||
"$null",
|
||||
{ $class: { UID: 4 } },
|
||||
{ $class: { UID: 5 } },
|
||||
{
|
||||
$class: { UID: 6 },
|
||||
NSSource: { UID: 2 },
|
||||
NSDestination: { UID: 1 },
|
||||
NSLabel: "buttonClicked:",
|
||||
},
|
||||
{ $classname: "BuildDelegate", $classes: ["NSObject"] },
|
||||
{ $classname: "NSButton", $classes: ["NSButton", "NSObject"] },
|
||||
{
|
||||
$classname: "NSNibControlConnector",
|
||||
$classes: ["NSNibControlConnector", "NSObject"],
|
||||
},
|
||||
],
|
||||
$top: {},
|
||||
},
|
||||
},
|
||||
],
|
||||
limits: interfaceBuilderLimitsSchema.parse({}),
|
||||
});
|
||||
const byId = new Map(analysis.graph.nodes.map((node) => [node.id, node]));
|
||||
const action = analysis.graph.nodes.find(({ kind }) => kind === "action");
|
||||
const from = analysis.graph.edges
|
||||
.filter(
|
||||
({ to, relation }) => relation === "target_action" && to === action?.id,
|
||||
)
|
||||
.map(({ from: id }) => byId.get(id)?.name);
|
||||
const to = analysis.graph.edges
|
||||
.filter(
|
||||
({ from: id, relation }) =>
|
||||
relation === "target_action" && id === action?.id,
|
||||
)
|
||||
.map(({ to: id }) => (id === null ? null : byId.get(id)?.kind));
|
||||
expect(from).toEqual(["NSButton"]);
|
||||
expect(to).toEqual(expect.arrayContaining(["objc_selector", "unknown"]));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user