mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 17:23:37 +08:00
refactor(apple): reuse keyed archive object class facts (#17373)
This commit is contained in:
@@ -255,11 +255,6 @@ const keyedArchiveTable = (objectTable: readonly unknown[]) => {
|
||||
classFactsOfReference(record(value).$class);
|
||||
const classNameOf = (value: unknown): string | null =>
|
||||
classFactsOfObject(value)?.name ?? null;
|
||||
const hasClassSuperclass = (value: unknown, superclass: string): boolean =>
|
||||
classFactsOfObject(value)?.superclasses.includes(superclass) ?? false;
|
||||
/** The class and superclass names an object's descriptor declares in `$classes`. */
|
||||
const classChainOf = (value: unknown): readonly string[] =>
|
||||
classFactsOfObject(value)?.superclasses ?? [];
|
||||
/** The string an archived string object holds, if it is one. */
|
||||
const archivedString = (target: unknown): string | undefined => {
|
||||
if (typeof target === "string") return target;
|
||||
@@ -384,9 +379,7 @@ const keyedArchiveTable = (objectTable: readonly unknown[]) => {
|
||||
return {
|
||||
resolve,
|
||||
hierarchy,
|
||||
classNameOf,
|
||||
hasClassSuperclass,
|
||||
classChainOf,
|
||||
classFactsOfObject,
|
||||
classTable,
|
||||
objectReference,
|
||||
};
|
||||
@@ -402,9 +395,7 @@ const parseKeyedArchive = (
|
||||
const {
|
||||
resolve,
|
||||
hierarchy: toHierarchy,
|
||||
classNameOf,
|
||||
hasClassSuperclass,
|
||||
classChainOf,
|
||||
classFactsOfObject,
|
||||
classTable,
|
||||
objectReference,
|
||||
} = keyedArchiveTable(objectTable);
|
||||
@@ -416,7 +407,8 @@ const parseKeyedArchive = (
|
||||
for (const [index, raw] of objectTable.entries()) {
|
||||
if (index === 0) continue;
|
||||
const resolved = record(resolve(raw));
|
||||
const archivedClassName = classNameOf(raw);
|
||||
const classFacts = classFactsOfObject(raw);
|
||||
const archivedClassName = classFacts?.name ?? null;
|
||||
// An archived object names its class with its own `$class` reference;
|
||||
// when that reference cannot be resolved the object is still observed,
|
||||
// with an unknown class. Scalars and class descriptors are not objects.
|
||||
@@ -435,7 +427,7 @@ const parseKeyedArchive = (
|
||||
// Authored objectID, object-id, id and archiveUID fields are data. Only
|
||||
// the original table position identifies an archived object.
|
||||
const objectId = String(index);
|
||||
const kind = classifyObject(className, classChainOf(raw));
|
||||
const kind = classifyObject(className, classFacts?.superclasses ?? []);
|
||||
let safeAttributes: Record<string, JsonValue> | undefined;
|
||||
const getSafeAttributes = (): Record<string, JsonValue> => {
|
||||
safeAttributes ??= jsonSafeRecord(fields);
|
||||
@@ -459,7 +451,7 @@ const parseKeyedArchive = (
|
||||
if (
|
||||
className !== null &&
|
||||
(isInterfaceBuilderConnectionClass(className) ||
|
||||
hasClassSuperclass(raw, "NSNibConnector"))
|
||||
(classFacts?.superclasses.includes("NSNibConnector") ?? false))
|
||||
) {
|
||||
const controlAction = /ControlConnector/iu.test(className);
|
||||
const uiKit = isUIKitRuntimeConnectionClass(className);
|
||||
|
||||
Reference in New Issue
Block a user