mirror of
https://github.com/morluto/rea.git
synced 2026-11-05 22:36:08 +00:00
* fix(javascript): resolve module-level Electron options in functions * fix(javascript): limit module option ancestry walk * fix(javascript): preserve uncertain captured argument ordering * fix(javascript): retain hoisted activation uncertainty * fix(javascript): retain function ownership through loops * fix(javascript): account for classic global activations * fix(javascript): bind first activations to lexical identities * fix(javascript): retain uncertain global activation timing * fix(javascript): isolate receiver facts and share computed reads * fix(javascript): retain projected and opaque global activations * fix(javascript): refresh activation bounds as opaque effects grow * fix(ci): format website watch directories without changing configuration * fix(javascript): share source reads across opaque-effect updates * fix(javascript): retain constructed-code global activation bounds * fix(javascript): share runtime activation and receiver facts * fix(javascript): reuse pattern reads and function positions * fix(javascript): isolate copied paths and preserve runtime reads * style(javascript): format migrated reference imports * fix(javascript): normalize constructor activation and receiver effects * fix(javascript): retain aliased receiver timing and lexical global this * fix(javascript): preserve effect-free receiver identity across activations * fix(javascript): retain outer activation and prototype effects * fix(javascript): index implicit reads without deep path rescans * fix(javascript): retain aliased prototype and parameter read uncertainty * fix(javascript): index reflected reads through intrinsic invocation facts * fix(javascript): retain unresolved global activation reads * chore: refresh PR branch after review fix publication * fix(javascript): retain projected receiver reads and cache method facts * fix(javascript): retain inherited and implicit activation reads * fix(javascript): retain caller-owned this uncertainty * fix(javascript): retain reflected reads with unresolved spread arguments * fix(javascript): preserve enclosing activation for decorators * fix(javascript): track intrinsic literal prototype effects * fix(javascript): retain catch activation from implicit reads * perf(javascript): reuse effective keys for projected reads * fix(javascript): retain possible caller-owned ambient effects
58 lines
2.2 KiB
TypeScript
58 lines
2.2 KiB
TypeScript
import {
|
|
semanticArrayIndex,
|
|
type JavaScriptSemanticPropertyPath as PropertyPath,
|
|
} from "./javascriptSemanticPropertyPaths.js";
|
|
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
|
|
interface CopiedReferenceSource {
|
|
readonly projection: PropertyPath;
|
|
readonly copyKind?: "object-rest" | "array-rest";
|
|
readonly copyProjectionOffset?: number;
|
|
readonly copyExcludedKeys?: readonly string[];
|
|
readonly copyStartIndex?: number;
|
|
}
|
|
|
|
/** Map copied child selections once; the fresh copy itself keeps its own identity. */
|
|
export const semanticCopiedReferencePath = (
|
|
initializer: CopiedReferenceSource,
|
|
path: PropertyPath,
|
|
effect: "write" | "escape" | "identity",
|
|
): PropertyPath | null => {
|
|
const offset = initializer.copyProjectionOffset;
|
|
if (offset === undefined) return [...initializer.projection, ...path];
|
|
const copiedPath = [...initializer.projection.slice(offset + 1), ...path];
|
|
if (effect === "identity" && copiedPath.length === 0) return null;
|
|
if (effect === "write" && copiedPath.length < 2) return null;
|
|
let [key, ...remaining] = copiedPath;
|
|
if (initializer.copyKind === "array-rest") {
|
|
const startIndex = initializer.copyStartIndex ?? 0;
|
|
if (key === undefined || key === null)
|
|
key = { excludedKeys: [], startIndex };
|
|
else if (typeof key === "object")
|
|
key = {
|
|
excludedKeys: key.excludedKeys.flatMap((name) => {
|
|
const index = semanticArrayIndex(name);
|
|
return index === null ? [] : [String(index + startIndex)];
|
|
}),
|
|
startIndex: (key.startIndex ?? 0) + startIndex,
|
|
};
|
|
else {
|
|
const index = semanticArrayIndex(key);
|
|
if (index === null) return null;
|
|
key = index + startIndex;
|
|
}
|
|
} else {
|
|
const excludedKeys = initializer.copyExcludedKeys ?? [];
|
|
if (key === undefined || key === null) key = { excludedKeys };
|
|
else if (typeof key === "object")
|
|
key = {
|
|
...key,
|
|
excludedKeys: [...new Set([...key.excludedKeys, ...excludedKeys])].sort(
|
|
compareUnicodeCodePoints,
|
|
),
|
|
};
|
|
else if (excludedKeys.includes(String(key))) return null;
|
|
}
|
|
return [...initializer.projection.slice(0, offset), key, ...remaining];
|
|
};
|