@voidhash/mimic 0.0.2 → 0.0.3
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/.turbo/turbo-build.log +257 -42
- package/dist/Document.cjs +152 -0
- package/dist/Document.d.cts +67 -0
- package/dist/Document.d.cts.map +1 -0
- package/dist/Document.d.mts +68 -0
- package/dist/Document.d.mts.map +1 -0
- package/dist/Document.mjs +147 -0
- package/dist/Document.mjs.map +1 -0
- package/dist/EffectSchema.cjs +180 -0
- package/dist/EffectSchema.d.cts +84 -0
- package/dist/EffectSchema.d.cts.map +1 -0
- package/dist/EffectSchema.d.mts +84 -0
- package/dist/EffectSchema.d.mts.map +1 -0
- package/dist/EffectSchema.mjs +176 -0
- package/dist/EffectSchema.mjs.map +1 -0
- package/dist/FractionalIndex.cjs +365 -0
- package/dist/FractionalIndex.mjs +364 -0
- package/dist/FractionalIndex.mjs.map +1 -0
- package/dist/Operation.cjs +53 -0
- package/dist/Operation.d.cts +39 -0
- package/dist/Operation.d.cts.map +1 -0
- package/dist/Operation.d.mts +39 -0
- package/dist/Operation.d.mts.map +1 -0
- package/dist/Operation.mjs +46 -0
- package/dist/Operation.mjs.map +1 -0
- package/dist/OperationDefinition.cjs +13 -0
- package/dist/OperationDefinition.d.cts +12 -0
- package/dist/OperationDefinition.d.cts.map +1 -0
- package/dist/OperationDefinition.d.mts +12 -0
- package/dist/OperationDefinition.d.mts.map +1 -0
- package/dist/OperationDefinition.mjs +13 -0
- package/dist/OperationDefinition.mjs.map +1 -0
- package/dist/OperationPath.cjs +148 -0
- package/dist/OperationPath.d.cts +60 -0
- package/dist/OperationPath.d.cts.map +1 -0
- package/dist/OperationPath.d.mts +60 -0
- package/dist/OperationPath.d.mts.map +1 -0
- package/dist/OperationPath.mjs +138 -0
- package/dist/OperationPath.mjs.map +1 -0
- package/dist/{Presence-gWrmGBeu.cjs → Presence.cjs} +4 -39
- package/dist/{Presence-N8u7Eppr.d.mts → Presence.d.cts} +2 -2
- package/dist/Presence.d.cts.map +1 -0
- package/dist/{Presence-DKKP4v5X.d.cts → Presence.d.mts} +2 -2
- package/dist/Presence.d.mts.map +1 -0
- package/dist/{Presence-DdMVKcOv.mjs → Presence.mjs} +3 -28
- package/dist/Presence.mjs.map +1 -0
- package/dist/Primitive.cjs +52 -0
- package/dist/Primitive.d.cts +20 -0
- package/dist/Primitive.d.cts.map +1 -0
- package/dist/Primitive.d.mts +20 -0
- package/dist/Primitive.d.mts.map +1 -0
- package/dist/Primitive.mjs +48 -0
- package/dist/Primitive.mjs.map +1 -0
- package/dist/ProxyEnvironment.cjs +34 -0
- package/dist/ProxyEnvironment.d.cts +31 -0
- package/dist/ProxyEnvironment.d.cts.map +1 -0
- package/dist/ProxyEnvironment.d.mts +31 -0
- package/dist/ProxyEnvironment.d.mts.map +1 -0
- package/dist/ProxyEnvironment.mjs +29 -0
- package/dist/ProxyEnvironment.mjs.map +1 -0
- package/dist/Transaction.cjs +66 -0
- package/dist/Transaction.d.cts +56 -0
- package/dist/Transaction.d.cts.map +1 -0
- package/dist/Transaction.d.mts +56 -0
- package/dist/Transaction.d.mts.map +1 -0
- package/dist/Transaction.mjs +58 -0
- package/dist/Transaction.mjs.map +1 -0
- package/dist/Transform.cjs +11 -0
- package/dist/Transform.d.cts +21 -0
- package/dist/Transform.d.cts.map +1 -0
- package/dist/Transform.d.mts +21 -0
- package/dist/Transform.d.mts.map +1 -0
- package/dist/Transform.mjs +6 -0
- package/dist/Transform.mjs.map +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/{chunk-CLMFDpHK.mjs → _virtual/rolldown_runtime.mjs} +1 -1
- package/dist/client/ClientDocument.cjs +590 -0
- package/dist/client/ClientDocument.d.cts +161 -0
- package/dist/client/ClientDocument.d.cts.map +1 -0
- package/dist/client/ClientDocument.d.mts +162 -0
- package/dist/client/ClientDocument.d.mts.map +1 -0
- package/dist/client/ClientDocument.mjs +586 -0
- package/dist/client/ClientDocument.mjs.map +1 -0
- package/dist/client/Rebase.cjs +204 -0
- package/dist/client/Rebase.d.cts +87 -0
- package/dist/client/Rebase.d.cts.map +1 -0
- package/dist/client/Rebase.d.mts +88 -0
- package/dist/client/Rebase.d.mts.map +1 -0
- package/dist/client/Rebase.mjs +198 -0
- package/dist/client/Rebase.mjs.map +1 -0
- package/dist/client/StateMonitor.cjs +133 -0
- package/dist/client/StateMonitor.d.cts +122 -0
- package/dist/client/StateMonitor.d.cts.map +1 -0
- package/dist/client/StateMonitor.d.mts +122 -0
- package/dist/client/StateMonitor.d.mts.map +1 -0
- package/dist/client/StateMonitor.mjs +129 -0
- package/dist/client/StateMonitor.mjs.map +1 -0
- package/dist/client/Transport.cjs +11 -0
- package/dist/client/Transport.d.cts +237 -0
- package/dist/client/Transport.d.cts.map +1 -0
- package/dist/client/Transport.d.mts +237 -0
- package/dist/client/Transport.d.mts.map +1 -0
- package/dist/client/Transport.mjs +6 -0
- package/dist/client/Transport.mjs.map +1 -0
- package/dist/client/WebSocketTransport.cjs +396 -0
- package/dist/client/WebSocketTransport.d.cts +29 -0
- package/dist/client/WebSocketTransport.d.cts.map +1 -0
- package/dist/client/WebSocketTransport.d.mts +29 -0
- package/dist/client/WebSocketTransport.d.mts.map +1 -0
- package/dist/client/WebSocketTransport.mjs +392 -0
- package/dist/client/WebSocketTransport.mjs.map +1 -0
- package/dist/client/errors.cjs +135 -0
- package/dist/client/errors.d.cts +87 -0
- package/dist/client/errors.d.cts.map +1 -0
- package/dist/client/errors.d.mts +87 -0
- package/dist/client/errors.d.mts.map +1 -0
- package/dist/client/errors.mjs +127 -0
- package/dist/client/errors.mjs.map +1 -0
- package/dist/client/index.cjs +22 -1424
- package/dist/client/index.d.cts +8 -692
- package/dist/client/index.d.mts +8 -692
- package/dist/client/index.mjs +9 -1413
- package/dist/index.cjs +20 -2973
- package/dist/index.d.cts +12 -419
- package/dist/index.d.mts +12 -419
- package/dist/index.mjs +13 -2968
- package/dist/primitives/Array.cjs +302 -0
- package/dist/primitives/Array.d.cts +95 -0
- package/dist/primitives/Array.d.cts.map +1 -0
- package/dist/primitives/Array.d.mts +95 -0
- package/dist/primitives/Array.d.mts.map +1 -0
- package/dist/primitives/Array.mjs +301 -0
- package/dist/primitives/Array.mjs.map +1 -0
- package/dist/primitives/Boolean.cjs +95 -0
- package/dist/primitives/Boolean.d.cts +44 -0
- package/dist/primitives/Boolean.d.cts.map +1 -0
- package/dist/primitives/Boolean.d.mts +44 -0
- package/dist/primitives/Boolean.d.mts.map +1 -0
- package/dist/primitives/Boolean.mjs +94 -0
- package/dist/primitives/Boolean.mjs.map +1 -0
- package/dist/primitives/Either.cjs +200 -0
- package/dist/primitives/Either.d.cts +113 -0
- package/dist/primitives/Either.d.cts.map +1 -0
- package/dist/primitives/Either.d.mts +113 -0
- package/dist/primitives/Either.d.mts.map +1 -0
- package/dist/primitives/Either.mjs +199 -0
- package/dist/primitives/Either.mjs.map +1 -0
- package/dist/primitives/Lazy.cjs +46 -0
- package/dist/primitives/Lazy.d.cts +46 -0
- package/dist/primitives/Lazy.d.cts.map +1 -0
- package/dist/primitives/Lazy.d.mts +46 -0
- package/dist/primitives/Lazy.d.mts.map +1 -0
- package/dist/primitives/Lazy.mjs +46 -0
- package/dist/primitives/Lazy.mjs.map +1 -0
- package/dist/primitives/Literal.cjs +91 -0
- package/dist/primitives/Literal.d.cts +46 -0
- package/dist/primitives/Literal.d.cts.map +1 -0
- package/dist/primitives/Literal.d.mts +46 -0
- package/dist/primitives/Literal.d.mts.map +1 -0
- package/dist/primitives/Literal.mjs +90 -0
- package/dist/primitives/Literal.mjs.map +1 -0
- package/dist/primitives/Number.cjs +115 -0
- package/dist/primitives/Number.d.cts +54 -0
- package/dist/primitives/Number.d.cts.map +1 -0
- package/dist/primitives/Number.d.mts +54 -0
- package/dist/primitives/Number.d.mts.map +1 -0
- package/dist/primitives/Number.mjs +114 -0
- package/dist/primitives/Number.mjs.map +1 -0
- package/dist/primitives/String.cjs +127 -0
- package/dist/primitives/String.d.cts +56 -0
- package/dist/primitives/String.d.cts.map +1 -0
- package/dist/primitives/String.d.mts +56 -0
- package/dist/primitives/String.d.mts.map +1 -0
- package/dist/primitives/String.mjs +126 -0
- package/dist/primitives/String.mjs.map +1 -0
- package/dist/primitives/Struct.cjs +207 -0
- package/dist/primitives/Struct.d.cts +96 -0
- package/dist/primitives/Struct.d.cts.map +1 -0
- package/dist/primitives/Struct.d.mts +97 -0
- package/dist/primitives/Struct.d.mts.map +1 -0
- package/dist/primitives/Struct.mjs +206 -0
- package/dist/primitives/Struct.mjs.map +1 -0
- package/dist/primitives/Tree.cjs +575 -0
- package/dist/primitives/Tree.d.cts +185 -0
- package/dist/primitives/Tree.d.cts.map +1 -0
- package/dist/primitives/Tree.d.mts +185 -0
- package/dist/primitives/Tree.d.mts.map +1 -0
- package/dist/primitives/Tree.mjs +574 -0
- package/dist/primitives/Tree.mjs.map +1 -0
- package/dist/primitives/TreeNode.cjs +73 -0
- package/dist/primitives/TreeNode.d.cts +92 -0
- package/dist/primitives/TreeNode.d.cts.map +1 -0
- package/dist/primitives/TreeNode.d.mts +93 -0
- package/dist/primitives/TreeNode.d.mts.map +1 -0
- package/dist/primitives/TreeNode.mjs +72 -0
- package/dist/primitives/TreeNode.mjs.map +1 -0
- package/dist/primitives/Union.cjs +170 -0
- package/dist/primitives/Union.d.cts +81 -0
- package/dist/primitives/Union.d.cts.map +1 -0
- package/dist/primitives/Union.d.mts +81 -0
- package/dist/primitives/Union.d.mts.map +1 -0
- package/dist/primitives/Union.mjs +169 -0
- package/dist/primitives/Union.mjs.map +1 -0
- package/dist/primitives/shared.cjs +60 -0
- package/dist/primitives/shared.d.cts +147 -0
- package/dist/primitives/shared.d.cts.map +1 -0
- package/dist/primitives/shared.d.mts +147 -0
- package/dist/primitives/shared.d.mts.map +1 -0
- package/dist/primitives/shared.mjs +58 -0
- package/dist/primitives/shared.mjs.map +1 -0
- package/dist/server/ServerDocument.cjs +110 -0
- package/dist/server/ServerDocument.d.cts +98 -0
- package/dist/server/ServerDocument.d.cts.map +1 -0
- package/dist/server/ServerDocument.d.mts +99 -0
- package/dist/server/ServerDocument.d.mts.map +1 -0
- package/dist/server/ServerDocument.mjs +106 -0
- package/dist/server/ServerDocument.mjs.map +1 -0
- package/dist/server/errors.cjs +85 -0
- package/dist/server/errors.d.cts +53 -0
- package/dist/server/errors.d.cts.map +1 -0
- package/dist/server/errors.d.mts +53 -0
- package/dist/server/errors.d.mts.map +1 -0
- package/dist/server/errors.mjs +81 -0
- package/dist/server/errors.mjs.map +1 -0
- package/dist/server/index.cjs +9 -185
- package/dist/server/index.d.cts +3 -148
- package/dist/server/index.d.mts +3 -148
- package/dist/server/index.mjs +3 -181
- package/dist/types/index.cjs +16 -0
- package/dist/types/index.d.cts +16 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.mts +16 -0
- package/dist/types/index.d.mts.map +1 -0
- package/dist/types/index.mjs +12 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/tree-helpers.cjs +443 -0
- package/dist/utils/tree-helpers.d.cts +280 -0
- package/dist/utils/tree-helpers.d.cts.map +1 -0
- package/dist/utils/tree-helpers.d.mts +280 -0
- package/dist/utils/tree-helpers.d.mts.map +1 -0
- package/dist/utils/tree-helpers.mjs +439 -0
- package/dist/utils/tree-helpers.mjs.map +1 -0
- package/package.json +2 -2
- package/tsdown.config.ts +1 -1
- package/dist/Document-ChuFrTk1.cjs +0 -571
- package/dist/Document-CwiAFTIq.mjs +0 -438
- package/dist/Document-CwiAFTIq.mjs.map +0 -1
- package/dist/Presence-DKKP4v5X.d.cts.map +0 -1
- package/dist/Presence-DdMVKcOv.mjs.map +0 -1
- package/dist/Presence-N8u7Eppr.d.mts.map +0 -1
- package/dist/Primitive-DqQFc3Gu.d.mts +0 -1180
- package/dist/Primitive-DqQFc3Gu.d.mts.map +0 -1
- package/dist/Primitive-awpEjnKL.d.cts +0 -1180
- package/dist/Primitive-awpEjnKL.d.cts.map +0 -1
- package/dist/client/index.d.cts.map +0 -1
- package/dist/client/index.d.mts.map +0 -1
- package/dist/client/index.mjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/server/index.d.cts.map +0 -1
- package/dist/server/index.d.mts.map +0 -1
- package/dist/server/index.mjs.map +0 -1
|
@@ -1,1180 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
//#region src/OperationPath.d.ts
|
|
4
|
-
declare namespace OperationPath_d_exports {
|
|
5
|
-
export { EncodedOperationPath, OperationPath, OperationPathToken, decode$2 as decode, encode$2 as encode, fromTokens, getRelativePath, isPrefix, make$2 as make, pathsEqual, pathsOverlap };
|
|
6
|
-
}
|
|
7
|
-
type OperationPathToken = string;
|
|
8
|
-
interface OperationPath {
|
|
9
|
-
readonly _tag: "OperationPath";
|
|
10
|
-
readonly toTokens: () => ReadonlyArray<OperationPathToken>;
|
|
11
|
-
readonly concat: (other: OperationPath) => OperationPath;
|
|
12
|
-
readonly append: (token: OperationPathToken) => OperationPath;
|
|
13
|
-
readonly pop: () => OperationPath;
|
|
14
|
-
readonly shift: () => OperationPath;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new operation path.
|
|
18
|
-
* @param stringPath - The string path to create the path from.
|
|
19
|
-
* @returns The new operation path.
|
|
20
|
-
*/
|
|
21
|
-
declare function make$2(stringPath?: string): OperationPath;
|
|
22
|
-
/**
|
|
23
|
-
* Creates a new operation path from tokens.
|
|
24
|
-
* @param tokens - The tokens to create the path from.
|
|
25
|
-
* @returns The new operation path.
|
|
26
|
-
*/
|
|
27
|
-
declare function fromTokens(tokens: ReadonlyArray<OperationPathToken>): OperationPath;
|
|
28
|
-
/**
|
|
29
|
-
* Checks if two operation paths overlap (one is prefix of the other or equal).
|
|
30
|
-
*/
|
|
31
|
-
declare const pathsOverlap: (pathA: OperationPath, pathB: OperationPath) => boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Checks if pathA is a prefix of pathB (pathA is ancestor of pathB).
|
|
34
|
-
*/
|
|
35
|
-
declare const isPrefix: (pathA: OperationPath, pathB: OperationPath) => boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Checks if two paths are exactly equal.
|
|
38
|
-
*/
|
|
39
|
-
declare const pathsEqual: (pathA: OperationPath, pathB: OperationPath) => boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Gets the relative path of pathB with respect to pathA.
|
|
42
|
-
* Assumes pathA is a prefix of pathB.
|
|
43
|
-
*/
|
|
44
|
-
declare const getRelativePath: (basePath: OperationPath, fullPath: OperationPath) => string[];
|
|
45
|
-
/**
|
|
46
|
-
* Encoded representation of an OperationPath for network transport.
|
|
47
|
-
*/
|
|
48
|
-
type EncodedOperationPath = string;
|
|
49
|
-
/**
|
|
50
|
-
* Encodes an OperationPath to a string for network transport.
|
|
51
|
-
* @param path - The operation path to encode.
|
|
52
|
-
* @returns The encoded string representation.
|
|
53
|
-
*/
|
|
54
|
-
declare const encode$2: (path: OperationPath) => EncodedOperationPath;
|
|
55
|
-
/**
|
|
56
|
-
* Decodes an encoded string back to an OperationPath.
|
|
57
|
-
* @param encoded - The encoded string representation.
|
|
58
|
-
* @returns The decoded OperationPath.
|
|
59
|
-
*/
|
|
60
|
-
declare const decode$2: (encoded: EncodedOperationPath) => OperationPath;
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/OperationDefinition.d.ts
|
|
63
|
-
interface OperationDefinition<TKind, TPayload extends Schema.Schema.Any, TTarget extends Schema.Schema.Any> {
|
|
64
|
-
readonly kind: TKind;
|
|
65
|
-
readonly payload: TPayload;
|
|
66
|
-
readonly target: TTarget;
|
|
67
|
-
}
|
|
68
|
-
declare namespace Operation_d_exports {
|
|
69
|
-
export { EncodedOperation, Operation, decode$1 as decode, encode$1 as encode, fromDefinition };
|
|
70
|
-
}
|
|
71
|
-
type Operation<TKind, TPayload extends Schema.Schema.Any, TDef extends OperationDefinition<TKind, TPayload, any>> = {
|
|
72
|
-
readonly kind: TKind;
|
|
73
|
-
readonly path: OperationPath;
|
|
74
|
-
readonly payload: Schema.Schema.Type<TPayload>;
|
|
75
|
-
} & TDef;
|
|
76
|
-
declare const fromDefinition: <TKind, TPayload extends Schema.Schema.Any, TDef extends OperationDefinition<TKind, TPayload, any>>(operationPath: OperationPath, definition: TDef, payload: Schema.Schema.Type<TPayload>) => Operation<TKind, TPayload, TDef>;
|
|
77
|
-
/**
|
|
78
|
-
* Encoded representation of an Operation for network transport.
|
|
79
|
-
*/
|
|
80
|
-
interface EncodedOperation {
|
|
81
|
-
readonly kind: unknown;
|
|
82
|
-
readonly path: EncodedOperationPath;
|
|
83
|
-
readonly payload: unknown;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Encodes an Operation to a JSON-serializable format for network transport.
|
|
87
|
-
* @param operation - The operation to encode.
|
|
88
|
-
* @returns The encoded representation.
|
|
89
|
-
*/
|
|
90
|
-
declare const encode$1: <TKind, TPayload extends Schema.Schema.Any, TDef extends OperationDefinition<TKind, TPayload, any>>(operation: Operation<TKind, TPayload, TDef>) => EncodedOperation;
|
|
91
|
-
/**
|
|
92
|
-
* Decodes an encoded operation back to an Operation.
|
|
93
|
-
* Note: This returns a partial operation without the definition methods.
|
|
94
|
-
* The caller must have the operation definitions to fully reconstruct if needed.
|
|
95
|
-
* @param encoded - The encoded representation.
|
|
96
|
-
* @returns The decoded Operation (without definition-specific methods).
|
|
97
|
-
*/
|
|
98
|
-
declare const decode$1: (encoded: EncodedOperation) => Operation<unknown, Schema.Schema.Any, any>;
|
|
99
|
-
declare namespace Transaction_d_exports {
|
|
100
|
-
export { EncodedTransaction, Transaction, decode, empty, encode, isEmpty, make$1 as make, merge };
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* A Transaction represents a group of operations that were applied atomically.
|
|
104
|
-
*/
|
|
105
|
-
interface Transaction {
|
|
106
|
-
/** Unique identifier for this transaction */
|
|
107
|
-
readonly id: string;
|
|
108
|
-
/** Operations contained in this transaction */
|
|
109
|
-
readonly ops: ReadonlyArray<Operation<any, any, any>>;
|
|
110
|
-
/** Timestamp when the transaction was created */
|
|
111
|
-
readonly timestamp: number;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Creates a new Transaction with the given operations.
|
|
115
|
-
*/
|
|
116
|
-
declare const make$1: (ops: ReadonlyArray<Operation<any, any, any>>) => Transaction;
|
|
117
|
-
/**
|
|
118
|
-
* Creates an empty Transaction.
|
|
119
|
-
*/
|
|
120
|
-
declare const empty: () => Transaction;
|
|
121
|
-
/**
|
|
122
|
-
* Checks if a transaction is empty (has no operations).
|
|
123
|
-
*/
|
|
124
|
-
declare const isEmpty: (tx: Transaction) => boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Merges multiple transactions into one.
|
|
127
|
-
*/
|
|
128
|
-
declare const merge: (txs: ReadonlyArray<Transaction>) => Transaction;
|
|
129
|
-
/**
|
|
130
|
-
* Encoded representation of a Transaction for network transport.
|
|
131
|
-
*/
|
|
132
|
-
interface EncodedTransaction {
|
|
133
|
-
readonly id: string;
|
|
134
|
-
readonly ops: ReadonlyArray<EncodedOperation>;
|
|
135
|
-
readonly timestamp: number;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Encodes a Transaction to a JSON-serializable format for network transport.
|
|
139
|
-
* @param transaction - The transaction to encode.
|
|
140
|
-
* @returns The encoded representation.
|
|
141
|
-
*/
|
|
142
|
-
declare const encode: (transaction: Transaction) => EncodedTransaction;
|
|
143
|
-
/**
|
|
144
|
-
* Decodes an encoded transaction back to a Transaction.
|
|
145
|
-
* @param encoded - The encoded representation.
|
|
146
|
-
* @returns The decoded Transaction.
|
|
147
|
-
*/
|
|
148
|
-
declare const decode: (encoded: EncodedTransaction) => Transaction;
|
|
149
|
-
declare namespace ProxyEnvironment_d_exports {
|
|
150
|
-
export { ProxyEnvironment, ProxyEnvironmentOptions, make };
|
|
151
|
-
}
|
|
152
|
-
type ProxyEnvironment = {
|
|
153
|
-
/** Adds an operation to be collected/applied */
|
|
154
|
-
readonly addOperation: (operation: Operation<any, any, any>) => void;
|
|
155
|
-
/** Gets the current state at the given path */
|
|
156
|
-
readonly getState: (path: OperationPath) => unknown;
|
|
157
|
-
/** Generates a unique ID (UUID) for array elements */
|
|
158
|
-
readonly generateId: () => string;
|
|
159
|
-
};
|
|
160
|
-
interface ProxyEnvironmentOptions {
|
|
161
|
-
/** Callback when an operation is added */
|
|
162
|
-
readonly onOperation: (operation: Operation<any, any, any>) => void;
|
|
163
|
-
/** Function to retrieve current state at a path (defaults to returning undefined) */
|
|
164
|
-
readonly getState?: (path: OperationPath) => unknown;
|
|
165
|
-
/** Optional: Custom ID generator (defaults to crypto.randomUUID) */
|
|
166
|
-
readonly generateId?: () => string;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Creates a ProxyEnvironment.
|
|
170
|
-
* @param optionsOrCallback - Either an options object or a simple callback for operations
|
|
171
|
-
*/
|
|
172
|
-
declare const make: (optionsOrCallback: ProxyEnvironmentOptions | ((operation: Operation<any, any, any>) => void)) => ProxyEnvironment;
|
|
173
|
-
declare namespace Transform_d_exports {
|
|
174
|
-
export { TransformResult };
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Result of transforming an operation against another operation.
|
|
178
|
-
*/
|
|
179
|
-
type TransformResult = {
|
|
180
|
-
type: "transformed";
|
|
181
|
-
operation: Operation<any, any, any>;
|
|
182
|
-
} | {
|
|
183
|
-
type: "noop";
|
|
184
|
-
} | {
|
|
185
|
-
type: "conflict";
|
|
186
|
-
reason: string;
|
|
187
|
-
};
|
|
188
|
-
//#endregion
|
|
189
|
-
//#region src/primitives/shared.d.ts
|
|
190
|
-
/**
|
|
191
|
-
* Base interface that all primitives must implement.
|
|
192
|
-
* Provides type inference helpers and internal operations.
|
|
193
|
-
*
|
|
194
|
-
* @typeParam TState - The state type this primitive holds
|
|
195
|
-
* @typeParam TProxy - The proxy type for interacting with this primitive
|
|
196
|
-
* @typeParam TDefined - Whether the value is guaranteed to be defined (via required() or default())
|
|
197
|
-
* @typeParam THasDefault - Whether this primitive has a default value
|
|
198
|
-
*/
|
|
199
|
-
interface Primitive<TState, TProxy, TRequired extends boolean = false, THasDefault extends boolean = false, TSetInput = unknown, TUpdateInput = unknown> {
|
|
200
|
-
readonly _tag: string;
|
|
201
|
-
readonly _State: TState;
|
|
202
|
-
readonly _Proxy: TProxy;
|
|
203
|
-
readonly _TRequired: TRequired;
|
|
204
|
-
readonly _THasDefault: THasDefault;
|
|
205
|
-
readonly _internal: PrimitiveInternal<TState, TProxy>;
|
|
206
|
-
readonly TSetInput: TSetInput;
|
|
207
|
-
readonly TUpdateInput: TUpdateInput;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Internal operations that each primitive must provide.
|
|
211
|
-
*/
|
|
212
|
-
interface PrimitiveInternal<TState, TProxy> {
|
|
213
|
-
/** Creates a proxy for generating operations */
|
|
214
|
-
readonly createProxy: (env: ProxyEnvironment, path: OperationPath) => TProxy;
|
|
215
|
-
/** Applies an operation to the current state, returning the new state */
|
|
216
|
-
readonly applyOperation: (state: TState | undefined, operation: Operation<any, any, any>) => TState;
|
|
217
|
-
/** Returns the initial/default state for this primitive */
|
|
218
|
-
readonly getInitialState: () => TState | undefined;
|
|
219
|
-
/**
|
|
220
|
-
* Transforms a client operation against a server operation.
|
|
221
|
-
* Used for operational transformation (OT) conflict resolution.
|
|
222
|
-
*
|
|
223
|
-
* @param clientOp - The client's operation to transform
|
|
224
|
-
* @param serverOp - The server's operation that has already been applied
|
|
225
|
-
* @returns TransformResult indicating how the client operation should be handled
|
|
226
|
-
*/
|
|
227
|
-
readonly transformOperation: (clientOp: Operation<any, any, any>, serverOp: Operation<any, any, any>) => TransformResult;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Any primitive type - used for generic constraints.
|
|
231
|
-
*/
|
|
232
|
-
type AnyPrimitive = Primitive<any, any, any, any>;
|
|
233
|
-
/**
|
|
234
|
-
* Infer the state type from a primitive.
|
|
235
|
-
*/
|
|
236
|
-
type InferState<T> = T extends Primitive<infer S, any, any, any> ? S : never;
|
|
237
|
-
/**
|
|
238
|
-
* Infer the proxy type from a primitive.
|
|
239
|
-
*/
|
|
240
|
-
type InferProxy<T> = T extends Primitive<any, infer P, any, any> ? P : never;
|
|
241
|
-
/**
|
|
242
|
-
* Infer the SetInput type from a primitive.
|
|
243
|
-
* Works with both Primitive interface types and types with a TSetInput property (like TreeNodePrimitive).
|
|
244
|
-
*/
|
|
245
|
-
type InferSetInput$5<T> = T extends Primitive<any, any, any, any, infer S, any> ? S : T extends {
|
|
246
|
-
TSetInput: infer S;
|
|
247
|
-
} ? S : never;
|
|
248
|
-
/**
|
|
249
|
-
* Infer the UpdateInput type from a primitive.
|
|
250
|
-
* Works with both Primitive interface types and types with a TUpdateInput property (like TreeNodePrimitive).
|
|
251
|
-
*/
|
|
252
|
-
type InferUpdateInput$5<T> = T extends Primitive<any, any, any, any, any, infer U> ? U : T extends {
|
|
253
|
-
TUpdateInput: infer U;
|
|
254
|
-
} ? U : never;
|
|
255
|
-
/**
|
|
256
|
-
* Helper type to conditionally add undefined based on TRequired and THasDefault.
|
|
257
|
-
* When TRequired is false and THasDefault is false, the value may be undefined.
|
|
258
|
-
* Otherwise, the value is guaranteed to be defined.
|
|
259
|
-
*/
|
|
260
|
-
type MaybeUndefined<T, TRequired extends boolean, THasDefault extends boolean> = TRequired extends false ? THasDefault extends false ? Optional<T> : T : T;
|
|
261
|
-
type Optional<T> = T | undefined;
|
|
262
|
-
/**
|
|
263
|
-
* Helper type to conditionally add undefined based on TRequired and THasDefault.
|
|
264
|
-
* When TRequired is true and THasDefault is false, the value must be provided.
|
|
265
|
-
* Otherwise, the value may be undefined.
|
|
266
|
-
*/
|
|
267
|
-
type NeedsValue<T, TRequired extends boolean, THasDefault extends boolean> = TRequired extends true ? THasDefault extends false ? T : Optional<T> : Optional<T>;
|
|
268
|
-
/**
|
|
269
|
-
* Infer the snapshot type from a primitive.
|
|
270
|
-
* The snapshot is a readonly, type-safe structure suitable for rendering.
|
|
271
|
-
*/
|
|
272
|
-
type InferSnapshot<T> = T extends Primitive<any, infer P, any, any> ? P extends {
|
|
273
|
-
toSnapshot(): infer S;
|
|
274
|
-
} ? S : never : never;
|
|
275
|
-
/**
|
|
276
|
-
* Extract THasDefault from a primitive.
|
|
277
|
-
*/
|
|
278
|
-
type HasDefault<T> = T extends Primitive<any, any, any, infer H> ? H : false;
|
|
279
|
-
/**
|
|
280
|
-
* Extract TDefined from a primitive.
|
|
281
|
-
*/
|
|
282
|
-
type IsDefined<T> = T extends Primitive<any, any, infer D, any> ? D : false;
|
|
283
|
-
/**
|
|
284
|
-
* Infer whether a primitive is required.
|
|
285
|
-
* Alias for IsDefined for clarity.
|
|
286
|
-
*/
|
|
287
|
-
type IsRequired<T> = IsDefined<T>;
|
|
288
|
-
declare class ValidationError extends Error {
|
|
289
|
-
readonly _tag = "ValidationError";
|
|
290
|
-
constructor(message: string);
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* A validator that checks a value and returns whether it's valid.
|
|
294
|
-
*/
|
|
295
|
-
interface Validator<T> {
|
|
296
|
-
readonly validate: (value: T) => boolean;
|
|
297
|
-
readonly message: string;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Runs all validators against a value, throwing ValidationError if any fail.
|
|
301
|
-
*/
|
|
302
|
-
declare function runValidators<T>(value: T, validators: readonly {
|
|
303
|
-
validate: (value: T) => boolean;
|
|
304
|
-
message: string;
|
|
305
|
-
}[]): void;
|
|
306
|
-
/**
|
|
307
|
-
* Checks if an operation is compatible with the given operation definitions.
|
|
308
|
-
* @param operation - The operation to check.
|
|
309
|
-
* @param operationDefinitions - The operation definitions to check against.
|
|
310
|
-
* @returns True if the operation is compatible, false otherwise.
|
|
311
|
-
*/
|
|
312
|
-
declare function isCompatibleOperation(operation: Operation<any, any, any>, operationDefinitions: Record<string, OperationDefinition<any, any, any>>): boolean;
|
|
313
|
-
/**
|
|
314
|
-
* Applies default values to a partial input, recursively handling nested structs.
|
|
315
|
-
*
|
|
316
|
-
* Uses a two-layer approach:
|
|
317
|
-
* 1. First, get the struct's initial state (which includes struct-level defaults)
|
|
318
|
-
* 2. Then, layer the provided values on top
|
|
319
|
-
* 3. Finally, ensure nested structs are recursively processed
|
|
320
|
-
*
|
|
321
|
-
* @param primitive - The primitive definition containing field information
|
|
322
|
-
* @param value - The partial value provided by the user
|
|
323
|
-
* @returns The value with defaults applied for missing fields
|
|
324
|
-
*/
|
|
325
|
-
declare function applyDefaults<T extends AnyPrimitive>(primitive: T, value: Partial<InferState<T>>): InferState<T>;
|
|
326
|
-
//#endregion
|
|
327
|
-
//#region src/primitives/String.d.ts
|
|
328
|
-
type InferSetInput$4<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<string, TRequired, THasDefault>;
|
|
329
|
-
type InferUpdateInput$4<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<string, TRequired, THasDefault>;
|
|
330
|
-
interface StringProxy<TRequired extends boolean = false, THasDefault extends boolean = false> {
|
|
331
|
-
/** Gets the current string value */
|
|
332
|
-
get(): MaybeUndefined<string, TRequired, THasDefault>;
|
|
333
|
-
/** Sets the string value, generating a string.set operation */
|
|
334
|
-
set(value: InferSetInput$4<TRequired, THasDefault>): void;
|
|
335
|
-
/** This is the same as set. Updates the string value, generating a string.set operation */
|
|
336
|
-
update(value: InferUpdateInput$4<TRequired, THasDefault>): void;
|
|
337
|
-
/** Returns a readonly snapshot of the string value for rendering */
|
|
338
|
-
toSnapshot(): MaybeUndefined<string, TRequired, THasDefault>;
|
|
339
|
-
}
|
|
340
|
-
interface StringPrimitiveSchema {
|
|
341
|
-
readonly required: boolean;
|
|
342
|
-
readonly defaultValue: string | undefined;
|
|
343
|
-
readonly validators: readonly Validator<string>[];
|
|
344
|
-
}
|
|
345
|
-
declare class StringPrimitive<TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<string, StringProxy<TRequired, THasDefault>, TRequired, THasDefault, InferSetInput$4<TRequired, THasDefault>, InferUpdateInput$4<TRequired, THasDefault>> {
|
|
346
|
-
readonly _tag: "StringPrimitive";
|
|
347
|
-
readonly _State: string;
|
|
348
|
-
readonly _Proxy: StringProxy<TRequired, THasDefault>;
|
|
349
|
-
readonly _TRequired: TRequired;
|
|
350
|
-
readonly _THasDefault: THasDefault;
|
|
351
|
-
readonly TUpdateInput: InferUpdateInput$4<TRequired, THasDefault>;
|
|
352
|
-
readonly TSetInput: InferSetInput$4<TRequired, THasDefault>;
|
|
353
|
-
private readonly _schema;
|
|
354
|
-
private readonly _opDefinitions;
|
|
355
|
-
constructor(schema: StringPrimitiveSchema);
|
|
356
|
-
/** Mark this string as required */
|
|
357
|
-
required(): StringPrimitive<true, THasDefault>;
|
|
358
|
-
/** Set a default value for this string */
|
|
359
|
-
default(defaultValue: string): StringPrimitive<TRequired, true>;
|
|
360
|
-
/** Add a custom validation rule */
|
|
361
|
-
refine(fn: (value: string) => boolean, message: string): StringPrimitive<TRequired, THasDefault>;
|
|
362
|
-
/** Minimum string length */
|
|
363
|
-
min(length: number): StringPrimitive<TRequired, THasDefault>;
|
|
364
|
-
/** Maximum string length */
|
|
365
|
-
max(length: number): StringPrimitive<TRequired, THasDefault>;
|
|
366
|
-
/** Exact string length */
|
|
367
|
-
length(exact: number): StringPrimitive<TRequired, THasDefault>;
|
|
368
|
-
/** Match a regex pattern */
|
|
369
|
-
regex(pattern: RegExp, message?: string): StringPrimitive<TRequired, THasDefault>;
|
|
370
|
-
/** Validate as email format */
|
|
371
|
-
email(): StringPrimitive<TRequired, THasDefault>;
|
|
372
|
-
/** Validate as URL format */
|
|
373
|
-
url(): StringPrimitive<TRequired, THasDefault>;
|
|
374
|
-
readonly _internal: PrimitiveInternal<string, StringProxy<TRequired, THasDefault>>;
|
|
375
|
-
}
|
|
376
|
-
/** Creates a new StringPrimitive */
|
|
377
|
-
declare const String: () => StringPrimitive<false, false>;
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/primitives/Struct.d.ts
|
|
380
|
-
/**
|
|
381
|
-
* Determines if a field is required for set() operations.
|
|
382
|
-
* A field is required if: TRequired is true AND THasDefault is false
|
|
383
|
-
*/
|
|
384
|
-
type IsRequiredForSet<T> = T extends Primitive<any, any, true, false> ? true : false;
|
|
385
|
-
/**
|
|
386
|
-
* Extract keys of fields that are required for set() (required without default).
|
|
387
|
-
*/
|
|
388
|
-
type RequiredSetKeys<TFields$1 extends Record<string, AnyPrimitive>> = { [K in keyof TFields$1]: IsRequiredForSet<TFields$1[K]> extends true ? K : never }[keyof TFields$1];
|
|
389
|
-
/**
|
|
390
|
-
* Extract keys of fields that are optional for set() (has default OR not required).
|
|
391
|
-
*/
|
|
392
|
-
type OptionalSetKeys<TFields$1 extends Record<string, AnyPrimitive>> = { [K in keyof TFields$1]: IsRequiredForSet<TFields$1[K]> extends true ? never : K }[keyof TFields$1];
|
|
393
|
-
/**
|
|
394
|
-
* Compute the input type for set() operations on a struct.
|
|
395
|
-
* Required fields (required without default) must be provided.
|
|
396
|
-
* Optional fields (has default or not required) can be omitted.
|
|
397
|
-
* Uses each field's TSetInput type to handle nested structs correctly.
|
|
398
|
-
*/
|
|
399
|
-
type StructSetInput<TFields$1 extends Record<string, AnyPrimitive>> = { readonly [K in RequiredSetKeys<TFields$1>]: InferSetInput$5<TFields$1[K]> } & { readonly [K in OptionalSetKeys<TFields$1>]?: InferSetInput$5<TFields$1[K]> };
|
|
400
|
-
/**
|
|
401
|
-
* Input type for set() - respects required/default status of the struct.
|
|
402
|
-
* If the struct is required without a default, the value must be provided.
|
|
403
|
-
* The value itself uses StructSetInput which handles field-level required/default logic.
|
|
404
|
-
*/
|
|
405
|
-
type InferStructSetInput<TFields$1 extends Record<string, AnyPrimitive>, TRequired extends boolean, THasDefault extends boolean> = NeedsValue<StructSetInput<TFields$1>, TRequired, THasDefault>;
|
|
406
|
-
/**
|
|
407
|
-
* Input type for update() - always partial since update only modifies specified fields.
|
|
408
|
-
* For nested structs, allows recursive partial updates.
|
|
409
|
-
*/
|
|
410
|
-
type InferStructUpdateInput<TFields$1 extends Record<string, AnyPrimitive>> = StructUpdateValue<TFields$1>;
|
|
411
|
-
/**
|
|
412
|
-
* Maps a schema definition to its state type.
|
|
413
|
-
* { name: StringPrimitive, age: NumberPrimitive } -> { name: string, age: number }
|
|
414
|
-
*/
|
|
415
|
-
type InferStructState<TFields$1 extends Record<string, AnyPrimitive>> = { readonly [K in keyof TFields$1]: InferState<TFields$1[K]> };
|
|
416
|
-
/**
|
|
417
|
-
* Maps a schema definition to its snapshot type.
|
|
418
|
-
* Each field's snapshot type is inferred from the field primitive.
|
|
419
|
-
*/
|
|
420
|
-
type InferStructSnapshot<TFields$1 extends Record<string, AnyPrimitive>> = { readonly [K in keyof TFields$1]: InferSnapshot<TFields$1[K]> };
|
|
421
|
-
/**
|
|
422
|
-
* Maps a schema definition to a partial update type.
|
|
423
|
-
* Uses each field's TUpdateInput type, which handles nested updates recursively.
|
|
424
|
-
*/
|
|
425
|
-
type StructUpdateValue<TFields$1 extends Record<string, AnyPrimitive>> = { readonly [K in keyof TFields$1]?: InferUpdateInput$5<TFields$1[K]> };
|
|
426
|
-
/**
|
|
427
|
-
* Maps a schema definition to its proxy type.
|
|
428
|
-
* Provides nested field access + get()/set()/toSnapshot() methods for the whole struct.
|
|
429
|
-
*/
|
|
430
|
-
type StructProxy<TFields$1 extends Record<string, AnyPrimitive>, TRequired extends boolean = false, THasDefault extends boolean = false> = { readonly [K in keyof TFields$1]: InferProxy<TFields$1[K]> } & {
|
|
431
|
-
/** Gets the entire struct value */
|
|
432
|
-
get(): MaybeUndefined<InferStructState<TFields$1>, TRequired, THasDefault>;
|
|
433
|
-
/** Sets the entire struct value (only fields that are required without defaults must be provided) */
|
|
434
|
-
set(value: InferStructSetInput<TFields$1, TRequired, THasDefault>): void;
|
|
435
|
-
/** Updates only the specified fields (partial update, handles nested structs recursively) */
|
|
436
|
-
update(value: InferStructUpdateInput<TFields$1>): void;
|
|
437
|
-
/** Returns a readonly snapshot of the struct for rendering */
|
|
438
|
-
toSnapshot(): MaybeUndefined<InferStructSnapshot<TFields$1>, TRequired, THasDefault>;
|
|
439
|
-
};
|
|
440
|
-
interface StructPrimitiveSchema<TFields$1 extends Record<string, AnyPrimitive>> {
|
|
441
|
-
readonly required: boolean;
|
|
442
|
-
readonly defaultValue: InferStructState<TFields$1> | undefined;
|
|
443
|
-
readonly fields: TFields$1;
|
|
444
|
-
readonly validators: readonly Validator<InferStructState<TFields$1>>[];
|
|
445
|
-
}
|
|
446
|
-
declare class StructPrimitive<TFields$1 extends Record<string, AnyPrimitive>, TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<InferStructState<TFields$1>, StructProxy<TFields$1, TRequired, THasDefault>, TRequired, THasDefault, InferStructSetInput<TFields$1, TRequired, THasDefault>, InferStructUpdateInput<TFields$1>> {
|
|
447
|
-
readonly _tag: "StructPrimitive";
|
|
448
|
-
readonly _State: InferStructState<TFields$1>;
|
|
449
|
-
readonly _Proxy: StructProxy<TFields$1, TRequired, THasDefault>;
|
|
450
|
-
readonly _TRequired: TRequired;
|
|
451
|
-
readonly _THasDefault: THasDefault;
|
|
452
|
-
readonly TSetInput: InferStructSetInput<TFields$1, TRequired, THasDefault>;
|
|
453
|
-
readonly TUpdateInput: InferStructUpdateInput<TFields$1>;
|
|
454
|
-
private readonly _schema;
|
|
455
|
-
private readonly _opDefinitions;
|
|
456
|
-
constructor(schema: StructPrimitiveSchema<TFields$1>);
|
|
457
|
-
/** Mark this struct as required */
|
|
458
|
-
required(): StructPrimitive<TFields$1, true, THasDefault>;
|
|
459
|
-
/** Set a default value for this struct */
|
|
460
|
-
default(defaultValue: StructSetInput<TFields$1>): StructPrimitive<TFields$1, TRequired, true>;
|
|
461
|
-
/** Get the fields schema */
|
|
462
|
-
get fields(): TFields$1;
|
|
463
|
-
/** Add a custom validation rule (useful for cross-field validation) */
|
|
464
|
-
refine(fn: (value: InferStructState<TFields$1>) => boolean, message: string): StructPrimitive<TFields$1, TRequired, THasDefault>;
|
|
465
|
-
readonly _internal: PrimitiveInternal<InferStructState<TFields$1>, StructProxy<TFields$1, TRequired, THasDefault>>;
|
|
466
|
-
}
|
|
467
|
-
/** Creates a new StructPrimitive with the given fields */
|
|
468
|
-
declare const Struct: <TFields$1 extends Record<string, AnyPrimitive>>(fields: TFields$1) => StructPrimitive<TFields$1, false, false>;
|
|
469
|
-
//#endregion
|
|
470
|
-
//#region src/primitives/Boolean.d.ts
|
|
471
|
-
type InferSetInput$3<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<boolean, TRequired, THasDefault>;
|
|
472
|
-
type InferUpdateInput$3<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<boolean, TRequired, THasDefault>;
|
|
473
|
-
interface BooleanProxy<TRequired extends boolean = false, THasDefault extends boolean = false> {
|
|
474
|
-
/** Gets the current boolean value */
|
|
475
|
-
get(): MaybeUndefined<boolean, TRequired, THasDefault>;
|
|
476
|
-
/** Sets the boolean value, generating a boolean.set operation */
|
|
477
|
-
set(value: InferSetInput$3<TRequired, THasDefault>): void;
|
|
478
|
-
/** This is the same as set. Updates the boolean value, generating a boolean.set operation */
|
|
479
|
-
update(value: InferUpdateInput$3<TRequired, THasDefault>): void;
|
|
480
|
-
/** Returns a readonly snapshot of the boolean value for rendering */
|
|
481
|
-
toSnapshot(): MaybeUndefined<boolean, TRequired, THasDefault>;
|
|
482
|
-
}
|
|
483
|
-
interface BooleanPrimitiveSchema {
|
|
484
|
-
readonly required: boolean;
|
|
485
|
-
readonly defaultValue: boolean | undefined;
|
|
486
|
-
readonly validators: readonly Validator<boolean>[];
|
|
487
|
-
}
|
|
488
|
-
declare class BooleanPrimitive<TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<boolean, BooleanProxy<TRequired, THasDefault>, TRequired, THasDefault, InferSetInput$3<TRequired, THasDefault>, InferUpdateInput$3<TRequired, THasDefault>> {
|
|
489
|
-
readonly _tag: "BooleanPrimitive";
|
|
490
|
-
readonly _State: boolean;
|
|
491
|
-
readonly _Proxy: BooleanProxy<TRequired, THasDefault>;
|
|
492
|
-
readonly _TRequired: TRequired;
|
|
493
|
-
readonly _THasDefault: THasDefault;
|
|
494
|
-
readonly TUpdateInput: InferUpdateInput$3<TRequired, THasDefault>;
|
|
495
|
-
readonly TSetInput: InferSetInput$3<TRequired, THasDefault>;
|
|
496
|
-
private readonly _schema;
|
|
497
|
-
private readonly _opDefinitions;
|
|
498
|
-
constructor(schema: BooleanPrimitiveSchema);
|
|
499
|
-
/** Mark this boolean as required */
|
|
500
|
-
required(): BooleanPrimitive<true, THasDefault>;
|
|
501
|
-
/** Set a default value for this boolean */
|
|
502
|
-
default(defaultValue: boolean): BooleanPrimitive<TRequired, true>;
|
|
503
|
-
/** Add a custom validation rule */
|
|
504
|
-
refine(fn: (value: boolean) => boolean, message: string): BooleanPrimitive<TRequired, THasDefault>;
|
|
505
|
-
readonly _internal: PrimitiveInternal<boolean, BooleanProxy<TRequired, THasDefault>>;
|
|
506
|
-
}
|
|
507
|
-
/** Creates a new BooleanPrimitive */
|
|
508
|
-
declare const Boolean: () => BooleanPrimitive<false, false>;
|
|
509
|
-
//#endregion
|
|
510
|
-
//#region src/primitives/Number.d.ts
|
|
511
|
-
type InferSetInput$2<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<number, TRequired, THasDefault>;
|
|
512
|
-
type InferUpdateInput$2<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<number, TRequired, THasDefault>;
|
|
513
|
-
interface NumberProxy<TRequired extends boolean = false, THasDefault extends boolean = false> {
|
|
514
|
-
/** Gets the current number value */
|
|
515
|
-
get(): MaybeUndefined<number, TRequired, THasDefault>;
|
|
516
|
-
/** Sets the number value, generating a number.set operation */
|
|
517
|
-
set(value: InferSetInput$2<TRequired, THasDefault>): void;
|
|
518
|
-
/** This is the same as set. Updates the number value, generating a number.set operation */
|
|
519
|
-
update(value: InferUpdateInput$2<TRequired, THasDefault>): void;
|
|
520
|
-
/** Returns a readonly snapshot of the number value for rendering */
|
|
521
|
-
toSnapshot(): MaybeUndefined<number, TRequired, THasDefault>;
|
|
522
|
-
}
|
|
523
|
-
interface NumberPrimitiveSchema {
|
|
524
|
-
readonly required: boolean;
|
|
525
|
-
readonly defaultValue: number | undefined;
|
|
526
|
-
readonly validators: readonly Validator<number>[];
|
|
527
|
-
}
|
|
528
|
-
declare class NumberPrimitive<TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<number, NumberProxy<TRequired, THasDefault>, TRequired, THasDefault, InferSetInput$2<TRequired, THasDefault>, InferUpdateInput$2<TRequired, THasDefault>> {
|
|
529
|
-
readonly _tag: "NumberPrimitive";
|
|
530
|
-
readonly _State: number;
|
|
531
|
-
readonly _Proxy: NumberProxy<TRequired, THasDefault>;
|
|
532
|
-
readonly _TRequired: TRequired;
|
|
533
|
-
readonly _THasDefault: THasDefault;
|
|
534
|
-
readonly TUpdateInput: InferUpdateInput$2<TRequired, THasDefault>;
|
|
535
|
-
readonly TSetInput: InferSetInput$2<TRequired, THasDefault>;
|
|
536
|
-
private readonly _schema;
|
|
537
|
-
private readonly _opDefinitions;
|
|
538
|
-
constructor(schema: NumberPrimitiveSchema);
|
|
539
|
-
/** Mark this number as required */
|
|
540
|
-
required(): NumberPrimitive<true, THasDefault>;
|
|
541
|
-
/** Set a default value for this number */
|
|
542
|
-
default(defaultValue: number): NumberPrimitive<TRequired, true>;
|
|
543
|
-
/** Add a custom validation rule */
|
|
544
|
-
refine(fn: (value: number) => boolean, message: string): NumberPrimitive<TRequired, THasDefault>;
|
|
545
|
-
/** Minimum value (inclusive) */
|
|
546
|
-
min(value: number): NumberPrimitive<TRequired, THasDefault>;
|
|
547
|
-
/** Maximum value (inclusive) */
|
|
548
|
-
max(value: number): NumberPrimitive<TRequired, THasDefault>;
|
|
549
|
-
/** Must be positive (> 0) */
|
|
550
|
-
positive(): NumberPrimitive<TRequired, THasDefault>;
|
|
551
|
-
/** Must be negative (< 0) */
|
|
552
|
-
negative(): NumberPrimitive<TRequired, THasDefault>;
|
|
553
|
-
/** Must be an integer */
|
|
554
|
-
int(): NumberPrimitive<TRequired, THasDefault>;
|
|
555
|
-
readonly _internal: PrimitiveInternal<number, NumberProxy<TRequired, THasDefault>>;
|
|
556
|
-
}
|
|
557
|
-
/** Creates a new NumberPrimitive */
|
|
558
|
-
declare const Number: () => NumberPrimitive<false, false>;
|
|
559
|
-
//#endregion
|
|
560
|
-
//#region src/primitives/Literal.d.ts
|
|
561
|
-
/** Valid literal types */
|
|
562
|
-
type LiteralValue = string | number | boolean | null;
|
|
563
|
-
type InferSetInput$1<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<T, TRequired, THasDefault>;
|
|
564
|
-
type InferUpdateInput$1<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<T, TRequired, THasDefault>;
|
|
565
|
-
interface LiteralProxy<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> {
|
|
566
|
-
/** Gets the current literal value */
|
|
567
|
-
get(): MaybeUndefined<T, TRequired, THasDefault>;
|
|
568
|
-
/** Sets the literal value (must match the exact literal type) */
|
|
569
|
-
set(value: InferSetInput$1<T, TRequired, THasDefault>): void;
|
|
570
|
-
/** This is the same as set. Updates the literal value, generating a literal.set operation */
|
|
571
|
-
update(value: InferUpdateInput$1<T, TRequired, THasDefault>): void;
|
|
572
|
-
/** Returns a readonly snapshot of the literal value for rendering */
|
|
573
|
-
toSnapshot(): MaybeUndefined<T, TRequired, THasDefault>;
|
|
574
|
-
}
|
|
575
|
-
interface LiteralPrimitiveSchema<T extends LiteralValue> {
|
|
576
|
-
readonly required: boolean;
|
|
577
|
-
readonly defaultValue: T | undefined;
|
|
578
|
-
readonly literal: T;
|
|
579
|
-
}
|
|
580
|
-
declare class LiteralPrimitive<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<T, LiteralProxy<T, TRequired, THasDefault>, TRequired, THasDefault, InferSetInput$1<T, TRequired, THasDefault>, InferUpdateInput$1<T, TRequired, THasDefault>> {
|
|
581
|
-
readonly _tag: "LiteralPrimitive";
|
|
582
|
-
readonly _State: T;
|
|
583
|
-
readonly _Proxy: LiteralProxy<T, TRequired, THasDefault>;
|
|
584
|
-
readonly _TRequired: TRequired;
|
|
585
|
-
readonly _THasDefault: THasDefault;
|
|
586
|
-
readonly TUpdateInput: InferUpdateInput$1<T, TRequired, THasDefault>;
|
|
587
|
-
readonly TSetInput: InferSetInput$1<T, TRequired, THasDefault>;
|
|
588
|
-
private readonly _schema;
|
|
589
|
-
private readonly _opDefinitions;
|
|
590
|
-
constructor(schema: LiteralPrimitiveSchema<T>);
|
|
591
|
-
/** Mark this literal as required */
|
|
592
|
-
required(): LiteralPrimitive<T, true, THasDefault>;
|
|
593
|
-
/** Set a default value for this literal */
|
|
594
|
-
default(defaultValue: T): LiteralPrimitive<T, TRequired, true>;
|
|
595
|
-
/** Get the literal value this primitive represents */
|
|
596
|
-
get literal(): T;
|
|
597
|
-
readonly _internal: PrimitiveInternal<T, LiteralProxy<T, TRequired, THasDefault>>;
|
|
598
|
-
}
|
|
599
|
-
/** Creates a new LiteralPrimitive with the given literal value */
|
|
600
|
-
declare const Literal: <T extends LiteralValue>(literal: T) => LiteralPrimitive<T, false, false>;
|
|
601
|
-
//#endregion
|
|
602
|
-
//#region src/primitives/Array.d.ts
|
|
603
|
-
/**
|
|
604
|
-
* Entry in an ordered array with ID and fractional position
|
|
605
|
-
*/
|
|
606
|
-
interface ArrayEntry<T> {
|
|
607
|
-
readonly id: string;
|
|
608
|
-
readonly pos: string;
|
|
609
|
-
readonly value: T;
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Entry in an array snapshot with ID and value snapshot
|
|
613
|
-
*/
|
|
614
|
-
interface ArrayEntrySnapshot<TElement extends AnyPrimitive> {
|
|
615
|
-
readonly id: string;
|
|
616
|
-
readonly value: InferSnapshot<TElement>;
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* Snapshot type for arrays - always an array (never undefined)
|
|
620
|
-
*/
|
|
621
|
-
type ArraySnapshot<TElement extends AnyPrimitive> = readonly ArrayEntrySnapshot<TElement>[];
|
|
622
|
-
/**
|
|
623
|
-
* Compute the input type for array element values.
|
|
624
|
-
* Uses StructSetInput directly for struct elements so that:
|
|
625
|
-
* - Fields that are required AND have no default must be provided
|
|
626
|
-
* - Fields that are optional OR have defaults can be omitted
|
|
627
|
-
*
|
|
628
|
-
* For non-struct elements, falls back to InferSetInput.
|
|
629
|
-
*/
|
|
630
|
-
type ArrayElementSetInput<TElement extends AnyPrimitive> = TElement extends StructPrimitive<infer TFields, any, any> ? StructSetInput<TFields> : InferSetInput$5<TElement>;
|
|
631
|
-
interface ArrayProxy<TElement extends AnyPrimitive> {
|
|
632
|
-
/** Gets the current array entries (sorted by position) */
|
|
633
|
-
get(): ArrayState<TElement>;
|
|
634
|
-
/** Replaces the entire array with new values (generates new IDs and positions, applies defaults) */
|
|
635
|
-
set(values: readonly ArrayElementSetInput<TElement>[]): void;
|
|
636
|
-
/** Appends a value to the end of the array (applies defaults for struct elements) */
|
|
637
|
-
push(value: ArrayElementSetInput<TElement>): void;
|
|
638
|
-
/** Inserts a value at the specified visual index (applies defaults for struct elements) */
|
|
639
|
-
insertAt(index: number, value: ArrayElementSetInput<TElement>): void;
|
|
640
|
-
/** Removes the element with the specified ID */
|
|
641
|
-
remove(id: string): void;
|
|
642
|
-
/** Moves an element to a new visual index */
|
|
643
|
-
move(id: string, toIndex: number): void;
|
|
644
|
-
/** Returns a proxy for the element with the specified ID */
|
|
645
|
-
at(id: string): InferProxy<TElement>;
|
|
646
|
-
/** Finds an element by predicate and returns its proxy */
|
|
647
|
-
find(predicate: (value: InferState<TElement>, id: string) => boolean): InferProxy<TElement> | undefined;
|
|
648
|
-
/** Returns a readonly snapshot of the array for rendering (always returns an array, never undefined) */
|
|
649
|
-
toSnapshot(): ArraySnapshot<TElement>;
|
|
650
|
-
}
|
|
651
|
-
/** The state type for arrays - an array of entries */
|
|
652
|
-
type ArrayState<TElement extends AnyPrimitive> = readonly ArrayEntry<InferState<TElement>>[];
|
|
653
|
-
interface ArrayPrimitiveSchema<TElement extends AnyPrimitive> {
|
|
654
|
-
readonly required: boolean;
|
|
655
|
-
readonly defaultValue: ArrayState<TElement> | undefined;
|
|
656
|
-
readonly element: TElement;
|
|
657
|
-
readonly validators: readonly Validator<ArrayState<TElement>>[];
|
|
658
|
-
}
|
|
659
|
-
/** Input type for array set() - an array of element set inputs */
|
|
660
|
-
type ArraySetInput<TElement extends AnyPrimitive> = readonly ArrayElementSetInput<TElement>[];
|
|
661
|
-
/** Input type for array update() - same as set() for arrays */
|
|
662
|
-
type ArrayUpdateInput<TElement extends AnyPrimitive> = readonly ArrayElementSetInput<TElement>[];
|
|
663
|
-
declare class ArrayPrimitive<TElement extends AnyPrimitive, TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<ArrayState<TElement>, ArrayProxy<TElement>, TRequired, THasDefault, ArraySetInput<TElement>, ArrayUpdateInput<TElement>> {
|
|
664
|
-
readonly _tag: "ArrayPrimitive";
|
|
665
|
-
readonly _State: ArrayState<TElement>;
|
|
666
|
-
readonly _Proxy: ArrayProxy<TElement>;
|
|
667
|
-
readonly _TRequired: TRequired;
|
|
668
|
-
readonly _THasDefault: THasDefault;
|
|
669
|
-
readonly TSetInput: ArraySetInput<TElement>;
|
|
670
|
-
readonly TUpdateInput: ArrayUpdateInput<TElement>;
|
|
671
|
-
private readonly _schema;
|
|
672
|
-
private readonly _opDefinitions;
|
|
673
|
-
constructor(schema: ArrayPrimitiveSchema<TElement>);
|
|
674
|
-
/** Mark this array as required */
|
|
675
|
-
required(): ArrayPrimitive<TElement, true, THasDefault>;
|
|
676
|
-
/** Set a default value for this array */
|
|
677
|
-
default(defaultValue: ArrayState<TElement>): ArrayPrimitive<TElement, TRequired, true>;
|
|
678
|
-
/** Get the element primitive */
|
|
679
|
-
get element(): TElement;
|
|
680
|
-
/** Add a custom validation rule */
|
|
681
|
-
refine(fn: (value: ArrayState<TElement>) => boolean, message: string): ArrayPrimitive<TElement, TRequired, THasDefault>;
|
|
682
|
-
/** Minimum array length */
|
|
683
|
-
minLength(length: number): ArrayPrimitive<TElement, TRequired, THasDefault>;
|
|
684
|
-
/** Maximum array length */
|
|
685
|
-
maxLength(length: number): ArrayPrimitive<TElement, TRequired, THasDefault>;
|
|
686
|
-
readonly _internal: PrimitiveInternal<ArrayState<TElement>, ArrayProxy<TElement>>;
|
|
687
|
-
}
|
|
688
|
-
/** Creates a new ArrayPrimitive with the given element type */
|
|
689
|
-
declare const Array$1: <TElement extends AnyPrimitive>(element: TElement) => ArrayPrimitive<TElement, false, false>;
|
|
690
|
-
//#endregion
|
|
691
|
-
//#region src/primitives/Lazy.d.ts
|
|
692
|
-
/**
|
|
693
|
-
* Type to infer SetInput from a lazy thunk
|
|
694
|
-
*/
|
|
695
|
-
type InferLazySetInput<T extends () => AnyPrimitive> = InferSetInput$5<ReturnType<T>>;
|
|
696
|
-
/**
|
|
697
|
-
* Type to infer UpdateInput from a lazy thunk
|
|
698
|
-
*/
|
|
699
|
-
type InferLazyUpdateInput<T extends () => AnyPrimitive> = InferUpdateInput$5<ReturnType<T>>;
|
|
700
|
-
/**
|
|
701
|
-
* Type to infer state from a lazy thunk
|
|
702
|
-
*/
|
|
703
|
-
type InferLazyState<T extends () => AnyPrimitive> = InferState<ReturnType<T>>;
|
|
704
|
-
/**
|
|
705
|
-
* Type to infer proxy from a lazy thunk
|
|
706
|
-
*/
|
|
707
|
-
type InferLazyProxy<T extends () => AnyPrimitive> = InferProxy<ReturnType<T>>;
|
|
708
|
-
/**
|
|
709
|
-
* Type to infer snapshot from a lazy thunk
|
|
710
|
-
*/
|
|
711
|
-
type InferLazySnapshot<T extends () => AnyPrimitive> = InferSnapshot<ReturnType<T>>;
|
|
712
|
-
declare class LazyPrimitive<TThunk extends () => AnyPrimitive> implements Primitive<InferLazyState<TThunk>, InferLazyProxy<TThunk>, false, false, InferLazySetInput<TThunk>, InferLazyUpdateInput<TThunk>> {
|
|
713
|
-
readonly _tag: "LazyPrimitive";
|
|
714
|
-
readonly _State: InferLazyState<TThunk>;
|
|
715
|
-
readonly _Proxy: InferLazyProxy<TThunk>;
|
|
716
|
-
readonly _TRequired: false;
|
|
717
|
-
readonly _THasDefault: false;
|
|
718
|
-
readonly TSetInput: InferLazySetInput<TThunk>;
|
|
719
|
-
readonly TUpdateInput: InferLazyUpdateInput<TThunk>;
|
|
720
|
-
private readonly _thunk;
|
|
721
|
-
private _resolved;
|
|
722
|
-
constructor(thunk: TThunk);
|
|
723
|
-
/** Resolve and cache the lazy primitive */
|
|
724
|
-
private _resolve;
|
|
725
|
-
/** Mark this lazy primitive as required (delegates to resolved) */
|
|
726
|
-
required(): LazyPrimitive<TThunk>;
|
|
727
|
-
readonly _internal: PrimitiveInternal<InferLazyState<TThunk>, InferLazyProxy<TThunk>>;
|
|
728
|
-
}
|
|
729
|
-
/** Creates a new LazyPrimitive with the given thunk */
|
|
730
|
-
declare const Lazy: <TThunk extends () => AnyPrimitive>(thunk: TThunk) => LazyPrimitive<TThunk>;
|
|
731
|
-
//#endregion
|
|
732
|
-
//#region src/primitives/Union.d.ts
|
|
733
|
-
/**
|
|
734
|
-
* Type constraint for union variants - must be struct primitives
|
|
735
|
-
*/
|
|
736
|
-
type UnionVariants = Record<string, StructPrimitive<any, any, any>>;
|
|
737
|
-
/**
|
|
738
|
-
* Infer the union state type from variants
|
|
739
|
-
*/
|
|
740
|
-
type InferUnionState<TVariants extends UnionVariants> = { [K in keyof TVariants]: InferState<TVariants[K]> }[keyof TVariants];
|
|
741
|
-
/**
|
|
742
|
-
* Infer the union snapshot type from variants
|
|
743
|
-
*/
|
|
744
|
-
type InferUnionSnapshot<TVariants extends UnionVariants> = { [K in keyof TVariants]: InferSnapshot<TVariants[K]> }[keyof TVariants];
|
|
745
|
-
/**
|
|
746
|
-
* Compute the input type for union.set() operations.
|
|
747
|
-
* Uses each variant's TSetInput type.
|
|
748
|
-
*/
|
|
749
|
-
type UnionSetInput<TVariants extends UnionVariants> = { [K in keyof TVariants]: InferSetInput$5<TVariants[K]> }[keyof TVariants];
|
|
750
|
-
/**
|
|
751
|
-
* Proxy for accessing union variants
|
|
752
|
-
*/
|
|
753
|
-
interface UnionProxy<TVariants extends UnionVariants, _TDiscriminator extends string, TRequired extends boolean = false, THasDefault extends boolean = false> {
|
|
754
|
-
/** Gets the current union value */
|
|
755
|
-
get(): MaybeUndefined<InferUnionState<TVariants>, TRequired, THasDefault>;
|
|
756
|
-
/** Sets the entire union value (applies defaults for variant fields) */
|
|
757
|
-
set(value: UnionSetInput<TVariants>): void;
|
|
758
|
-
/** Access a specific variant's proxy (assumes the variant is active) */
|
|
759
|
-
as<K$1 extends keyof TVariants>(variant: K$1): InferProxy<TVariants[K$1]>;
|
|
760
|
-
/** Pattern match on the variant type */
|
|
761
|
-
match<R>(handlers: { [K in keyof TVariants]: (proxy: InferProxy<TVariants[K$1]>) => R }): R | undefined;
|
|
762
|
-
/** Returns a readonly snapshot of the union for rendering */
|
|
763
|
-
toSnapshot(): MaybeUndefined<InferUnionSnapshot<TVariants>, TRequired, THasDefault>;
|
|
764
|
-
}
|
|
765
|
-
interface UnionPrimitiveSchema<TVariants extends UnionVariants, TDiscriminator extends string> {
|
|
766
|
-
readonly required: boolean;
|
|
767
|
-
readonly defaultValue: InferUnionState<TVariants> | undefined;
|
|
768
|
-
readonly discriminator: TDiscriminator;
|
|
769
|
-
readonly variants: TVariants;
|
|
770
|
-
}
|
|
771
|
-
declare class UnionPrimitive<TVariants extends UnionVariants, TDiscriminator extends string = "type", TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<InferUnionState<TVariants>, UnionProxy<TVariants, TDiscriminator, TRequired, THasDefault>, TRequired, THasDefault, UnionSetInput<TVariants>, UnionSetInput<TVariants>> {
|
|
772
|
-
readonly _tag: "UnionPrimitive";
|
|
773
|
-
readonly _State: InferUnionState<TVariants>;
|
|
774
|
-
readonly _Proxy: UnionProxy<TVariants, TDiscriminator, TRequired, THasDefault>;
|
|
775
|
-
readonly _TRequired: TRequired;
|
|
776
|
-
readonly _THasDefault: THasDefault;
|
|
777
|
-
readonly TSetInput: UnionSetInput<TVariants>;
|
|
778
|
-
readonly TUpdateInput: UnionSetInput<TVariants>;
|
|
779
|
-
private readonly _schema;
|
|
780
|
-
private readonly _opDefinitions;
|
|
781
|
-
constructor(schema: UnionPrimitiveSchema<TVariants, TDiscriminator>);
|
|
782
|
-
/** Mark this union as required */
|
|
783
|
-
required(): UnionPrimitive<TVariants, TDiscriminator, true, THasDefault>;
|
|
784
|
-
/** Set a default value for this union */
|
|
785
|
-
default(defaultValue: UnionSetInput<TVariants>): UnionPrimitive<TVariants, TDiscriminator, true, true>;
|
|
786
|
-
/** Get the discriminator field name */
|
|
787
|
-
get discriminator(): TDiscriminator;
|
|
788
|
-
/** Get the variants */
|
|
789
|
-
get variants(): TVariants;
|
|
790
|
-
/** Find the variant key from a state value */
|
|
791
|
-
private _findVariantKey;
|
|
792
|
-
/** Apply defaults to a variant value based on the discriminator */
|
|
793
|
-
private _applyVariantDefaults;
|
|
794
|
-
readonly _internal: PrimitiveInternal<InferUnionState<TVariants>, UnionProxy<TVariants, TDiscriminator, TRequired, THasDefault>>;
|
|
795
|
-
}
|
|
796
|
-
/** Options for creating a Union primitive */
|
|
797
|
-
interface UnionOptions<TVariants extends UnionVariants, TDiscriminator extends string> {
|
|
798
|
-
/** The field name used to discriminate between variants (defaults to "type") */
|
|
799
|
-
readonly discriminator?: TDiscriminator;
|
|
800
|
-
/** The variant struct primitives */
|
|
801
|
-
readonly variants: TVariants;
|
|
802
|
-
}
|
|
803
|
-
/** Creates a new UnionPrimitive with the given variants */
|
|
804
|
-
declare function Union<TVariants extends UnionVariants>(options: UnionOptions<TVariants, "type">): UnionPrimitive<TVariants, "type", false, false>;
|
|
805
|
-
declare function Union<TVariants extends UnionVariants, TDiscriminator extends string>(options: UnionOptions<TVariants, TDiscriminator>): UnionPrimitive<TVariants, TDiscriminator, false, false>;
|
|
806
|
-
//#endregion
|
|
807
|
-
//#region src/primitives/Either.d.ts
|
|
808
|
-
type InferSetInput<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<InferEitherState<TVariants>, TRequired, THasDefault>;
|
|
809
|
-
type InferUpdateInput<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<InferEitherState<TVariants>, TRequired, THasDefault>;
|
|
810
|
-
/**
|
|
811
|
-
* Scalar primitives that can be used as variants in Either
|
|
812
|
-
*/
|
|
813
|
-
type ScalarPrimitive = StringPrimitive<any, any> | NumberPrimitive<any, any> | BooleanPrimitive<any, any> | LiteralPrimitive<any, any, any>;
|
|
814
|
-
/**
|
|
815
|
-
* Infer the union state type from a tuple of scalar primitives
|
|
816
|
-
*/
|
|
817
|
-
type InferEitherState<TVariants extends readonly ScalarPrimitive[]> = InferState<TVariants[number]>;
|
|
818
|
-
/**
|
|
819
|
-
* Infer the union snapshot type from a tuple of scalar primitives
|
|
820
|
-
*/
|
|
821
|
-
type InferEitherSnapshot<TVariants extends readonly ScalarPrimitive[]> = InferState<TVariants[number]>;
|
|
822
|
-
/**
|
|
823
|
-
* Match handlers for Either - optional handlers for each scalar type
|
|
824
|
-
*/
|
|
825
|
-
interface EitherMatchHandlers<R> {
|
|
826
|
-
string?: (value: string) => R;
|
|
827
|
-
number?: (value: number) => R;
|
|
828
|
-
boolean?: (value: boolean) => R;
|
|
829
|
-
literal?: (value: LiteralValue) => R;
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Proxy for accessing Either values
|
|
833
|
-
*/
|
|
834
|
-
interface EitherProxy<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> {
|
|
835
|
-
/** Gets the current value */
|
|
836
|
-
get(): MaybeUndefined<InferEitherState<TVariants>, TRequired, THasDefault>;
|
|
837
|
-
/** Sets the value to any of the allowed variant types */
|
|
838
|
-
set(value: InferSetInput<TVariants, TRequired, THasDefault>): void;
|
|
839
|
-
/** This is the same as set. Updates the value, generating an either.set operation */
|
|
840
|
-
update(value: InferUpdateInput<TVariants, TRequired, THasDefault>): void;
|
|
841
|
-
/** Pattern match on the value type */
|
|
842
|
-
match<R>(handlers: EitherMatchHandlers<R>): R | undefined;
|
|
843
|
-
/** Returns a readonly snapshot of the value for rendering */
|
|
844
|
-
toSnapshot(): MaybeUndefined<InferEitherSnapshot<TVariants>, TRequired, THasDefault>;
|
|
845
|
-
}
|
|
846
|
-
interface EitherPrimitiveSchema<TVariants extends readonly ScalarPrimitive[]> {
|
|
847
|
-
readonly required: boolean;
|
|
848
|
-
readonly defaultValue: InferEitherState<TVariants> | undefined;
|
|
849
|
-
readonly variants: TVariants;
|
|
850
|
-
}
|
|
851
|
-
declare class EitherPrimitive<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<InferEitherState<TVariants>, EitherProxy<TVariants, TRequired, THasDefault>, TRequired, THasDefault, InferSetInput<TVariants, TRequired, THasDefault>, InferUpdateInput<TVariants, TRequired, THasDefault>> {
|
|
852
|
-
readonly _tag: "EitherPrimitive";
|
|
853
|
-
readonly _State: InferEitherState<TVariants>;
|
|
854
|
-
readonly _Proxy: EitherProxy<TVariants, TRequired, THasDefault>;
|
|
855
|
-
readonly _TRequired: TRequired;
|
|
856
|
-
readonly _THasDefault: THasDefault;
|
|
857
|
-
readonly TUpdateInput: InferUpdateInput<TVariants, TRequired, THasDefault>;
|
|
858
|
-
readonly TSetInput: InferSetInput<TVariants, TRequired, THasDefault>;
|
|
859
|
-
private readonly _schema;
|
|
860
|
-
private readonly _opDefinitions;
|
|
861
|
-
constructor(schema: EitherPrimitiveSchema<TVariants>);
|
|
862
|
-
/** Mark this either as required */
|
|
863
|
-
required(): EitherPrimitive<TVariants, true, THasDefault>;
|
|
864
|
-
/** Set a default value for this either */
|
|
865
|
-
default(defaultValue: InferEitherState<TVariants>): EitherPrimitive<TVariants, TRequired, true>;
|
|
866
|
-
/** Get the variants */
|
|
867
|
-
get variants(): TVariants;
|
|
868
|
-
/**
|
|
869
|
-
* Determine the type category of a value based on the variants
|
|
870
|
-
*/
|
|
871
|
-
private _getValueType;
|
|
872
|
-
/**
|
|
873
|
-
* Find the matching variant for a value.
|
|
874
|
-
* For literals, matches exact value. For other types, matches by typeof.
|
|
875
|
-
*/
|
|
876
|
-
private _findMatchingVariant;
|
|
877
|
-
/**
|
|
878
|
-
* Get the operation kind for a variant
|
|
879
|
-
*/
|
|
880
|
-
private _getVariantOperationKind;
|
|
881
|
-
/**
|
|
882
|
-
* Validate a value against the matching variant, including running its validators.
|
|
883
|
-
* Throws ValidationError if the value doesn't match any variant or fails validation.
|
|
884
|
-
*/
|
|
885
|
-
private _validateAndApplyToVariant;
|
|
886
|
-
readonly _internal: PrimitiveInternal<InferEitherState<TVariants>, EitherProxy<TVariants, TRequired, THasDefault>>;
|
|
887
|
-
}
|
|
888
|
-
/**
|
|
889
|
-
* Creates a new EitherPrimitive with the given scalar variant types.
|
|
890
|
-
* Validators defined on the variants are applied when validating values.
|
|
891
|
-
*
|
|
892
|
-
* @example
|
|
893
|
-
* ```typescript
|
|
894
|
-
* // String or number
|
|
895
|
-
* const value = Either(String(), Number());
|
|
896
|
-
*
|
|
897
|
-
* // String, number, or boolean
|
|
898
|
-
* const status = Either(String(), Number(), Boolean()).default("pending");
|
|
899
|
-
*
|
|
900
|
-
* // With literal types
|
|
901
|
-
* const mode = Either(Literal("auto"), Literal("manual"), Number());
|
|
902
|
-
*
|
|
903
|
-
* // With validators - validates string length and number range
|
|
904
|
-
* const constrained = Either(
|
|
905
|
-
* String().min(2).max(50),
|
|
906
|
-
* Number().max(255)
|
|
907
|
-
* );
|
|
908
|
-
* ```
|
|
909
|
-
*/
|
|
910
|
-
declare function Either<TVariants extends readonly ScalarPrimitive[]>(...variants: TVariants): EitherPrimitive<TVariants, false, false>;
|
|
911
|
-
//#endregion
|
|
912
|
-
//#region src/primitives/TreeNode.d.ts
|
|
913
|
-
/**
|
|
914
|
-
* Branded type for TreeNodeSelf - distinguishable at compile time
|
|
915
|
-
*/
|
|
916
|
-
declare const SelfBrand: unique symbol;
|
|
917
|
-
interface TreeNodeSelfType {
|
|
918
|
-
readonly _tag: "TreeNodeSelf";
|
|
919
|
-
readonly _brand: typeof SelfBrand;
|
|
920
|
-
}
|
|
921
|
-
/**
|
|
922
|
-
* Special placeholder for self-referential tree nodes.
|
|
923
|
-
* Use this in the children array when a node type can contain itself.
|
|
924
|
-
*
|
|
925
|
-
* @example
|
|
926
|
-
* ```typescript
|
|
927
|
-
* const FolderNode = TreeNode("folder", {
|
|
928
|
-
* data: Struct({ name: String() }),
|
|
929
|
-
* children: [TreeNodeSelf], // Folder can contain other folders
|
|
930
|
-
* });
|
|
931
|
-
* ```
|
|
932
|
-
*/
|
|
933
|
-
declare const TreeNodeSelf: TreeNodeSelfType;
|
|
934
|
-
/**
|
|
935
|
-
* Type utility to resolve Self placeholders to the actual node type
|
|
936
|
-
*/
|
|
937
|
-
type ResolveSelf<T, TSelf extends AnyTreeNodePrimitive> = T extends TreeNodeSelfType ? TSelf : T;
|
|
938
|
-
/**
|
|
939
|
-
* Type utility to resolve all children in a tuple, replacing Self with the node type
|
|
940
|
-
*/
|
|
941
|
-
type ResolveChildrenUnion<TChildren, TSelf extends AnyTreeNodePrimitive> = TChildren extends readonly (infer U)[] ? ResolveSelf<U, TSelf> : never;
|
|
942
|
-
/**
|
|
943
|
-
* The type for children - either a direct array or a lazy function (for self-referential nodes).
|
|
944
|
-
*/
|
|
945
|
-
type TreeNodeChildrenInput = readonly (AnyTreeNodePrimitive | TreeNodeSelfType)[] | (() => readonly (AnyTreeNodePrimitive | TreeNodeSelfType)[]);
|
|
946
|
-
/**
|
|
947
|
-
* Any TreeNodePrimitive type - used for generic constraints.
|
|
948
|
-
*/
|
|
949
|
-
type AnyTreeNodePrimitive = TreeNodePrimitive<string, StructPrimitive<any>, any>;
|
|
950
|
-
/**
|
|
951
|
-
* Infer the data state type from a TreeNodePrimitive
|
|
952
|
-
*/
|
|
953
|
-
type InferTreeNodeDataState<T extends AnyTreeNodePrimitive> = T extends TreeNodePrimitive<any, infer TData, any> ? InferState<TData> : never;
|
|
954
|
-
/**
|
|
955
|
-
* Infer the type literal from a TreeNodePrimitive
|
|
956
|
-
*/
|
|
957
|
-
type InferTreeNodeType<T extends AnyTreeNodePrimitive> = T extends TreeNodePrimitive<infer TType, any, any> ? TType : never;
|
|
958
|
-
/**
|
|
959
|
-
* Infer the allowed children from a TreeNodePrimitive
|
|
960
|
-
*/
|
|
961
|
-
type InferTreeNodeChildren<T> = T extends TreeNodePrimitive<any, any, infer TChildren> ? TChildren : never;
|
|
962
|
-
/**
|
|
963
|
-
* Configuration for a TreeNode primitive
|
|
964
|
-
*/
|
|
965
|
-
interface TreeNodeConfig<TData$1 extends StructPrimitive<any>, TChildren extends readonly (AnyTreeNodePrimitive | TreeNodeSelfType)[]> {
|
|
966
|
-
readonly data: TData$1;
|
|
967
|
-
readonly children: TChildren | (() => TChildren);
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* TreeNodePrimitive - defines a node type with its data schema and allowed children
|
|
971
|
-
*/
|
|
972
|
-
declare class TreeNodePrimitive<TType extends string, TData$1 extends StructPrimitive<any>, TChildren extends AnyTreeNodePrimitive = AnyTreeNodePrimitive> {
|
|
973
|
-
readonly _tag: "TreeNodePrimitive";
|
|
974
|
-
readonly _Type: TType;
|
|
975
|
-
readonly _Data: TData$1;
|
|
976
|
-
readonly _Children: TChildren;
|
|
977
|
-
/** For InferSetInput compatibility - delegates to the data struct's set input type */
|
|
978
|
-
readonly TSetInput: InferSetInput$5<TData$1>;
|
|
979
|
-
/** For InferUpdateInput compatibility - delegates to the data struct's update input type */
|
|
980
|
-
readonly TUpdateInput: InferUpdateInput$5<TData$1>;
|
|
981
|
-
private readonly _type;
|
|
982
|
-
private readonly _data;
|
|
983
|
-
private readonly _children;
|
|
984
|
-
private _resolvedChildren;
|
|
985
|
-
constructor(type: TType, config: TreeNodeConfig<TData$1, readonly (AnyTreeNodePrimitive | TreeNodeSelfType)[]>);
|
|
986
|
-
/** Get the node type identifier */
|
|
987
|
-
get type(): TType;
|
|
988
|
-
/** Get the data primitive */
|
|
989
|
-
get data(): TData$1;
|
|
990
|
-
/** Get resolved children (resolves lazy thunk if needed, replaces Self with this node) */
|
|
991
|
-
get children(): readonly AnyTreeNodePrimitive[];
|
|
992
|
-
/** Check if a child type is allowed */
|
|
993
|
-
isChildAllowed(childType: string): boolean;
|
|
994
|
-
}
|
|
995
|
-
/** Creates a new TreeNodePrimitive with the given type and config */
|
|
996
|
-
declare const TreeNode: <TType extends string, TData$1 extends StructPrimitive<any>, const TChildren extends readonly (AnyTreeNodePrimitive | TreeNodeSelfType)[]>(type: TType, config: TreeNodeConfig<TData$1, TChildren>) => TreeNodePrimitive<TType, TData$1, ResolveChildrenUnion<TChildren, TreeNodePrimitive<TType, TData$1, any>>>;
|
|
997
|
-
//#endregion
|
|
998
|
-
//#region src/primitives/Tree.d.ts
|
|
999
|
-
/**
|
|
1000
|
-
* A node in the tree state (flat storage format)
|
|
1001
|
-
*/
|
|
1002
|
-
interface TreeNodeState {
|
|
1003
|
-
readonly id: string;
|
|
1004
|
-
readonly type: string;
|
|
1005
|
-
readonly parentId: string | null;
|
|
1006
|
-
readonly pos: string;
|
|
1007
|
-
readonly data: unknown;
|
|
1008
|
-
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Typed node state for a specific node type
|
|
1011
|
-
*/
|
|
1012
|
-
interface TypedTreeNodeState<TNode extends AnyTreeNodePrimitive> {
|
|
1013
|
-
readonly id: string;
|
|
1014
|
-
readonly type: InferTreeNodeType<TNode>;
|
|
1015
|
-
readonly parentId: string | null;
|
|
1016
|
-
readonly pos: string;
|
|
1017
|
-
readonly data: InferTreeNodeDataState<TNode>;
|
|
1018
|
-
}
|
|
1019
|
-
/**
|
|
1020
|
-
* The state type for trees - a flat array of nodes
|
|
1021
|
-
*/
|
|
1022
|
-
type TreeState<_TRoot extends AnyTreeNodePrimitive> = readonly TreeNodeState[];
|
|
1023
|
-
/**
|
|
1024
|
-
* Snapshot of a single node for UI rendering (data properties spread at node level)
|
|
1025
|
-
*/
|
|
1026
|
-
type TreeNodeSnapshot<TNode extends AnyTreeNodePrimitive> = {
|
|
1027
|
-
readonly id: string;
|
|
1028
|
-
readonly type: InferTreeNodeType<TNode>;
|
|
1029
|
-
readonly children: TreeNodeSnapshot<InferTreeNodeChildren<TNode>>[];
|
|
1030
|
-
} & InferTreeNodeDataState<TNode>;
|
|
1031
|
-
/**
|
|
1032
|
-
* Infer the snapshot type for a tree (recursive tree structure for UI)
|
|
1033
|
-
*/
|
|
1034
|
-
type InferTreeSnapshot<T extends TreePrimitive<any>> = T extends TreePrimitive<infer TRoot> ? TreeNodeSnapshot<TRoot> : never;
|
|
1035
|
-
/**
|
|
1036
|
-
* Helper type to infer the update value type from a TreeNode's data.
|
|
1037
|
-
* Uses StructUpdateValue directly to get field-level partial update semantics.
|
|
1038
|
-
* All fields are optional in update operations.
|
|
1039
|
-
*/
|
|
1040
|
-
type TreeNodeUpdateValue<TNode extends AnyTreeNodePrimitive> = TNode["data"] extends StructPrimitive<infer TFields, any, any> ? StructUpdateValue<TFields> : InferUpdateInput$5<TNode["data"]>;
|
|
1041
|
-
/**
|
|
1042
|
-
* Helper type to infer the input type for node data (respects field defaults).
|
|
1043
|
-
* Uses StructSetInput directly so that:
|
|
1044
|
-
* - Fields that are required AND have no default must be provided
|
|
1045
|
-
* - Fields that are optional OR have defaults can be omitted
|
|
1046
|
-
*
|
|
1047
|
-
* This bypasses the struct-level NeedsValue wrapper since tree inserts
|
|
1048
|
-
* always require a data object (even if empty for all-optional fields).
|
|
1049
|
-
*/
|
|
1050
|
-
type TreeNodeDataSetInput<TNode extends AnyTreeNodePrimitive> = TNode["data"] extends StructPrimitive<infer TFields, any, any> ? StructSetInput<TFields> : InferSetInput$5<TNode["data"]>;
|
|
1051
|
-
/**
|
|
1052
|
-
* Typed proxy for a specific node type - provides type-safe data access
|
|
1053
|
-
*/
|
|
1054
|
-
interface TypedNodeProxy<TNode extends AnyTreeNodePrimitive> {
|
|
1055
|
-
/** The node ID */
|
|
1056
|
-
readonly id: string;
|
|
1057
|
-
/** The node type */
|
|
1058
|
-
readonly type: InferTreeNodeType<TNode>;
|
|
1059
|
-
/** Access the node's data proxy */
|
|
1060
|
-
readonly data: InferProxy<TNode["data"]>;
|
|
1061
|
-
/** Get the raw node state */
|
|
1062
|
-
get(): TypedTreeNodeState<TNode>;
|
|
1063
|
-
/** Updates only the specified data fields (partial update, handles nested structs recursively) */
|
|
1064
|
-
update(value: TreeNodeUpdateValue<TNode>): void;
|
|
1065
|
-
}
|
|
1066
|
-
/**
|
|
1067
|
-
* Node proxy with type narrowing capabilities
|
|
1068
|
-
*/
|
|
1069
|
-
interface TreeNodeProxyBase<_TRoot extends AnyTreeNodePrimitive> {
|
|
1070
|
-
/** The node ID */
|
|
1071
|
-
readonly id: string;
|
|
1072
|
-
/** The node type (string) */
|
|
1073
|
-
readonly type: string;
|
|
1074
|
-
/** Type guard - narrows the proxy to a specific node type */
|
|
1075
|
-
is<TNode extends AnyTreeNodePrimitive>(nodeType: TNode): this is TypedNodeProxy<TNode>;
|
|
1076
|
-
/** Type assertion - returns typed proxy (throws if wrong type) */
|
|
1077
|
-
as<TNode extends AnyTreeNodePrimitive>(nodeType: TNode): TypedNodeProxy<TNode>;
|
|
1078
|
-
/** Get the raw node state */
|
|
1079
|
-
get(): TreeNodeState;
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Proxy for accessing and modifying tree nodes
|
|
1083
|
-
*/
|
|
1084
|
-
interface TreeProxy<TRoot$1 extends AnyTreeNodePrimitive> {
|
|
1085
|
-
/** Gets the entire tree state (flat array of nodes) */
|
|
1086
|
-
get(): TreeState<TRoot$1>;
|
|
1087
|
-
/** Replaces the entire tree */
|
|
1088
|
-
set(nodes: TreeState<TRoot$1>): void;
|
|
1089
|
-
/** Gets the root node state */
|
|
1090
|
-
root(): TypedTreeNodeState<TRoot$1> | undefined;
|
|
1091
|
-
/** Gets ordered children states of a parent (null for root's children) */
|
|
1092
|
-
children(parentId: string | null): TreeNodeState[];
|
|
1093
|
-
/** Gets a node proxy by ID with type narrowing capabilities */
|
|
1094
|
-
node(id: string): TreeNodeProxyBase<TRoot$1> | undefined;
|
|
1095
|
-
/** Insert a new node as the first child (applies defaults for node data) */
|
|
1096
|
-
insertFirst<TNode extends AnyTreeNodePrimitive>(parentId: string | null, nodeType: TNode, data: TreeNodeDataSetInput<TNode>): string;
|
|
1097
|
-
/** Insert a new node as the last child (applies defaults for node data) */
|
|
1098
|
-
insertLast<TNode extends AnyTreeNodePrimitive>(parentId: string | null, nodeType: TNode, data: TreeNodeDataSetInput<TNode>): string;
|
|
1099
|
-
/** Insert a new node at a specific index among siblings (applies defaults for node data) */
|
|
1100
|
-
insertAt<TNode extends AnyTreeNodePrimitive>(parentId: string | null, index: number, nodeType: TNode, data: TreeNodeDataSetInput<TNode>): string;
|
|
1101
|
-
/** Insert a new node after a sibling (applies defaults for node data) */
|
|
1102
|
-
insertAfter<TNode extends AnyTreeNodePrimitive>(siblingId: string, nodeType: TNode, data: TreeNodeDataSetInput<TNode>): string;
|
|
1103
|
-
/** Insert a new node before a sibling (applies defaults for node data) */
|
|
1104
|
-
insertBefore<TNode extends AnyTreeNodePrimitive>(siblingId: string, nodeType: TNode, data: TreeNodeDataSetInput<TNode>): string;
|
|
1105
|
-
/** Remove a node and all its descendants */
|
|
1106
|
-
remove(id: string): void;
|
|
1107
|
-
/** Move a node to a new parent at a specific index */
|
|
1108
|
-
move(nodeId: string, newParentId: string | null, toIndex: number): void;
|
|
1109
|
-
/** Move a node after a sibling */
|
|
1110
|
-
moveAfter(nodeId: string, siblingId: string): void;
|
|
1111
|
-
/** Move a node before a sibling */
|
|
1112
|
-
moveBefore(nodeId: string, siblingId: string): void;
|
|
1113
|
-
/** Move a node to be the first child of a parent */
|
|
1114
|
-
moveToFirst(nodeId: string, newParentId: string | null): void;
|
|
1115
|
-
/** Move a node to be the last child of a parent */
|
|
1116
|
-
moveToLast(nodeId: string, newParentId: string | null): void;
|
|
1117
|
-
/** Returns a typed proxy for a specific node's data */
|
|
1118
|
-
at<TNode extends AnyTreeNodePrimitive>(id: string, nodeType: TNode): InferProxy<TNode["data"]>;
|
|
1119
|
-
/** Updates only the specified data fields of a node (partial update) */
|
|
1120
|
-
updateAt<TNode extends AnyTreeNodePrimitive>(id: string, nodeType: TNode, value: TreeNodeUpdateValue<TNode>): void;
|
|
1121
|
-
/** Convert tree to a nested snapshot for UI rendering */
|
|
1122
|
-
toSnapshot(): TreeNodeSnapshot<TRoot$1> | undefined;
|
|
1123
|
-
}
|
|
1124
|
-
interface TreePrimitiveSchema<TRoot$1 extends AnyTreeNodePrimitive> {
|
|
1125
|
-
readonly required: boolean;
|
|
1126
|
-
readonly defaultValue: TreeState<TRoot$1> | undefined;
|
|
1127
|
-
readonly root: TRoot$1;
|
|
1128
|
-
readonly validators: readonly Validator<TreeState<TRoot$1>>[];
|
|
1129
|
-
}
|
|
1130
|
-
/** Input type for tree set() - tree state */
|
|
1131
|
-
type TreeSetInput<TRoot$1 extends AnyTreeNodePrimitive> = TreeState<TRoot$1>;
|
|
1132
|
-
/** Input type for tree update() - same as set() for trees */
|
|
1133
|
-
type TreeUpdateInput<TRoot$1 extends AnyTreeNodePrimitive> = TreeState<TRoot$1>;
|
|
1134
|
-
declare class TreePrimitive<TRoot$1 extends AnyTreeNodePrimitive, TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<TreeState<TRoot$1>, TreeProxy<TRoot$1>, TRequired, THasDefault, TreeSetInput<TRoot$1>, TreeUpdateInput<TRoot$1>> {
|
|
1135
|
-
readonly _tag: "TreePrimitive";
|
|
1136
|
-
readonly _State: TreeState<TRoot$1>;
|
|
1137
|
-
readonly _Proxy: TreeProxy<TRoot$1>;
|
|
1138
|
-
readonly _TRequired: TRequired;
|
|
1139
|
-
readonly _THasDefault: THasDefault;
|
|
1140
|
-
readonly TSetInput: TreeSetInput<TRoot$1>;
|
|
1141
|
-
readonly TUpdateInput: TreeUpdateInput<TRoot$1>;
|
|
1142
|
-
private readonly _schema;
|
|
1143
|
-
private _nodeTypeRegistry;
|
|
1144
|
-
private readonly _opDefinitions;
|
|
1145
|
-
constructor(schema: TreePrimitiveSchema<TRoot$1>);
|
|
1146
|
-
/** Mark this tree as required */
|
|
1147
|
-
required(): TreePrimitive<TRoot$1, true, THasDefault>;
|
|
1148
|
-
/** Set a default value for this tree */
|
|
1149
|
-
default(defaultValue: TreeState<TRoot$1>): TreePrimitive<TRoot$1, TRequired, true>;
|
|
1150
|
-
/** Get the root node type */
|
|
1151
|
-
get root(): TRoot$1;
|
|
1152
|
-
/** Add a custom validation rule */
|
|
1153
|
-
refine(fn: (value: TreeState<TRoot$1>) => boolean, message: string): TreePrimitive<TRoot$1, TRequired, THasDefault>;
|
|
1154
|
-
/**
|
|
1155
|
-
* Build a registry of all node types reachable from root
|
|
1156
|
-
*/
|
|
1157
|
-
private _buildNodeTypeRegistry;
|
|
1158
|
-
/**
|
|
1159
|
-
* Get a node type primitive by its type string
|
|
1160
|
-
*/
|
|
1161
|
-
private _getNodeTypePrimitive;
|
|
1162
|
-
/**
|
|
1163
|
-
* Validate that a node type can be a child of a parent node type
|
|
1164
|
-
*/
|
|
1165
|
-
private _validateChildType;
|
|
1166
|
-
readonly _internal: PrimitiveInternal<TreeState<TRoot$1>, TreeProxy<TRoot$1>>;
|
|
1167
|
-
}
|
|
1168
|
-
/** Options for creating a Tree primitive */
|
|
1169
|
-
interface TreeOptions<TRoot$1 extends AnyTreeNodePrimitive> {
|
|
1170
|
-
/** The root node type */
|
|
1171
|
-
readonly root: TRoot$1;
|
|
1172
|
-
}
|
|
1173
|
-
/** Creates a new TreePrimitive with the given root node type */
|
|
1174
|
-
declare const Tree: <TRoot$1 extends AnyTreeNodePrimitive>(options: TreeOptions<TRoot$1>) => TreePrimitive<TRoot$1, false, false>;
|
|
1175
|
-
declare namespace Primitive_d_exports {
|
|
1176
|
-
export { AnyPrimitive, AnyTreeNodePrimitive, Array$1 as Array, ArrayElementSetInput, ArrayEntry, ArrayEntrySnapshot, ArrayPrimitive, ArrayProxy, ArraySetInput, ArraySnapshot, ArrayState, ArrayUpdateInput, Boolean, BooleanPrimitive, BooleanProxy, Either, EitherMatchHandlers, EitherPrimitive, EitherProxy, HasDefault, InferEitherSnapshot, InferEitherState, InferLazyProxy, InferLazySetInput, InferLazySnapshot, InferLazyState, InferLazyUpdateInput, InferProxy, InferSetInput$5 as InferSetInput, InferSnapshot, InferState, InferStructSnapshot, InferStructState, InferTreeNodeChildren, InferTreeNodeDataState, InferTreeNodeType, InferTreeSnapshot, InferUnionSnapshot, InferUnionState, InferUpdateInput$5 as InferUpdateInput, IsDefined, IsRequired, Lazy, LazyPrimitive, Literal, LiteralPrimitive, LiteralProxy, LiteralValue, MaybeUndefined, NeedsValue, Number, NumberPrimitive, NumberProxy, Optional, Primitive, PrimitiveInternal, ScalarPrimitive, String, StringPrimitive, StringProxy, Struct, StructPrimitive, StructProxy, StructSetInput, StructUpdateValue, Tree, TreeNode, TreeNodeChildrenInput, TreeNodeConfig, TreeNodeDataSetInput, TreeNodePrimitive, TreeNodeProxyBase, TreeNodeSelf, TreeNodeSelfType, TreeNodeSnapshot, TreeNodeState, TreeNodeUpdateValue, TreeOptions, TreePrimitive, TreeProxy, TreeSetInput, TreeState, TreeUpdateInput, TypedNodeProxy, TypedTreeNodeState, Union, UnionOptions, UnionPrimitive, UnionProxy, UnionSetInput, UnionVariants, ValidationError, Validator, applyDefaults, isCompatibleOperation, runValidators };
|
|
1177
|
-
}
|
|
1178
|
-
//#endregion
|
|
1179
|
-
export { InferState as $, InferLazyProxy as A, ArraySnapshot as B, TreeNodeSelfType as C, InferUnionSnapshot as D, ScalarPrimitive as E, ArrayElementSetInput as F, StructProxy as G, ArrayUpdateInput as H, ArrayEntry as I, AnyPrimitive as J, StructSetInput as K, ArrayEntrySnapshot as L, InferLazySnapshot as M, InferLazyState as N, InferUnionState as O, InferLazyUpdateInput as P, InferSnapshot as Q, ArrayProxy as R, TreeNodeSelf as S, InferEitherState as T, InferStructSnapshot as U, ArrayState as V, InferStructState as W, InferProxy as X, HasDefault as Y, InferSetInput$5 as Z, InferTreeNodeDataState as _, OperationPath_d_exports as _t, TreeNodeSnapshot as a, Optional as at, TreeNodeConfig as b, TreePrimitive as c, Validator as ct, TreeState as d, ProxyEnvironment_d_exports as dt, InferUpdateInput$5 as et, TreeUpdateInput as f, EncodedTransaction as ft, InferTreeNodeChildren as g, Operation_d_exports as gt, AnyTreeNodePrimitive as h, Operation as ht, TreeNodeProxyBase as i, NeedsValue as it, InferLazySetInput as j, UnionVariants as k, TreeProxy as l, TransformResult as lt, TypedTreeNodeState as m, Transaction_d_exports as mt, InferTreeSnapshot as n, IsRequired as nt, TreeNodeState as o, Primitive as ot, TypedNodeProxy as p, Transaction as pt, StructUpdateValue as q, TreeNodeDataSetInput as r, MaybeUndefined as rt, TreeNodeUpdateValue as s, PrimitiveInternal as st, Primitive_d_exports as t, IsDefined as tt, TreeSetInput as u, Transform_d_exports as ut, InferTreeNodeType as v, InferEitherSnapshot as w, TreeNodePrimitive as x, TreeNodeChildrenInput as y, ArraySetInput as z };
|
|
1180
|
-
//# sourceMappingURL=Primitive-DqQFc3Gu.d.mts.map
|