osra 0.6.6 → 0.6.7
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/README.md +21 -7
- package/build/index.js +524 -559
- package/build/index.js.map +1 -1
- package/build/revivables/identity.d.ts +12 -10
- package/build/revivables/index.d.ts +7 -0
- package/package.json +1 -1
|
@@ -9,24 +9,26 @@ export type Messages = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const Messages: Messages;
|
|
11
11
|
declare const IDENTITY_MARKER: unique symbol;
|
|
12
|
-
|
|
12
|
+
/** Phantom shape. A tracked value carries no marker of its own, the mark lives in a WeakMap, so
|
|
13
|
+
* this is what `isType` declares instead: matching it at the type level would widen `Capable` to
|
|
14
|
+
* every object, and nothing a user writes structurally matches this. */
|
|
15
|
+
type IdentityMarked = {
|
|
13
16
|
readonly [IDENTITY_MARKER]: true;
|
|
14
|
-
readonly value: T;
|
|
15
17
|
};
|
|
16
18
|
export type BoxedIdentity<T extends Capable = Capable> = BoxBaseType<typeof type> & {
|
|
17
19
|
id: string;
|
|
18
20
|
inner?: Capable;
|
|
19
21
|
[UnderlyingType]: T;
|
|
20
22
|
};
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
23
|
+
/** Mark a value so osra preserves its reference identity across the boundary. The peer's revived
|
|
24
|
+
* value stands for this one, and handing it back - to you, or onward to a further context and back
|
|
25
|
+
* again - resolves to this very reference. The mark sticks to the value, so only the side that
|
|
26
|
+
* owns it has to opt in. Idempotent, and primitives pass through unchanged. */
|
|
24
27
|
export declare const identity: <T>(value: T) => T;
|
|
25
|
-
export declare const isType: (value: unknown) => value is
|
|
26
|
-
export declare const box: <T extends Capable, TContext extends RevivableContext>(
|
|
27
|
-
/** Identity-box a referenceable value with a caller-supplied inner box,
|
|
28
|
-
*
|
|
29
|
-
* description=undefined) where recursing back through their own box
|
|
28
|
+
export declare const isType: (value: unknown) => value is IdentityMarked;
|
|
29
|
+
export declare const box: <T extends Capable, TContext extends RevivableContext>(value: T, context: TContext) => BoxedIdentity<T>;
|
|
30
|
+
/** Identity-box a referenceable value with a caller-supplied inner box, bypassing the walker. Used
|
|
31
|
+
* by revivables (symbol with description=undefined) where recursing back through their own box
|
|
30
32
|
* would loop into this module again. */
|
|
31
33
|
export declare const boxByReference: <T extends WeakKey, TContext extends RevivableContext>(value: T, innerBox: Capable, context: TContext) => BoxedIdentity;
|
|
32
34
|
export declare const revive: <T extends BoxedIdentity, TContext extends RevivableContext>(value: T, context: TContext) => T[UnderlyingType];
|
|
@@ -71,4 +71,11 @@ export declare const defaultRevivableModules: readonly [typeof transfer, typeof
|
|
|
71
71
|
export type DefaultRevivableModules = typeof defaultRevivableModules;
|
|
72
72
|
export type DefaultRevivableModule = DefaultRevivableModules[number];
|
|
73
73
|
export declare const recursiveBox: <T extends Capable, TModules extends readonly RevivableModule[]>(value: T, context: RevivableContext<TModules>) => DeepReplaceWithBox<T, TModules[number]>;
|
|
74
|
+
/** Box a value your own module claimed in place: every other module gets its turn and children are
|
|
75
|
+
* walked as usual, but `claimedBy` is skipped, and the cycle guard the caller's `recursiveBox`
|
|
76
|
+
* frame already holds for this value is not re-entered.
|
|
77
|
+
* A module needs this when its `isType` matches a bare value rather than a wrapper around one, the
|
|
78
|
+
* way `identity()` marks a reference in place: `recursiveBox` on that same value would come
|
|
79
|
+
* straight back to the module, and the guard would report it as a cycle. */
|
|
80
|
+
export declare const boxClaimedValue: <T extends Capable, TModules extends readonly RevivableModule[]>(value: T, context: RevivableContext<TModules>, claimedBy: string) => DeepReplaceWithBox<T, TModules[number]>;
|
|
74
81
|
export declare const recursiveRevive: <T extends Capable, TModules extends readonly RevivableModule[]>(value: T, context: RevivableContext<TModules>) => DeepReplaceWithRevive<T, TModules[number]>;
|