@voidhash/mimic 0.0.1-alpha.1 → 0.0.1-alpha.111
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 +51 -0
- package/LICENSE.md +663 -0
- package/dist/Document-ChuFrTk1.cjs +571 -0
- package/dist/Document-CwiAFTIq.mjs +438 -0
- package/dist/Document-CwiAFTIq.mjs.map +1 -0
- package/dist/Presence-DKKP4v5X.d.cts +91 -0
- package/dist/Presence-DKKP4v5X.d.cts.map +1 -0
- package/dist/Presence-DdMVKcOv.mjs +110 -0
- package/dist/Presence-DdMVKcOv.mjs.map +1 -0
- package/dist/Presence-N8u7Eppr.d.mts +91 -0
- package/dist/Presence-N8u7Eppr.d.mts.map +1 -0
- package/dist/Presence-gWrmGBeu.cjs +126 -0
- package/dist/Primitive-CvFVxR8_.d.cts +1175 -0
- package/dist/Primitive-CvFVxR8_.d.cts.map +1 -0
- package/dist/Primitive-lEhQyGVL.d.mts +1175 -0
- package/dist/Primitive-lEhQyGVL.d.mts.map +1 -0
- package/dist/chunk-CLMFDpHK.mjs +18 -0
- package/dist/client/index.cjs +1456 -0
- package/dist/client/index.d.cts +692 -0
- package/dist/client/index.d.cts.map +1 -0
- package/dist/client/index.d.mts +692 -0
- package/dist/client/index.d.mts.map +1 -0
- package/dist/client/index.mjs +1413 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/index.cjs +2577 -0
- package/dist/index.d.cts +143 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +143 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2526 -0
- package/dist/index.mjs.map +1 -0
- package/dist/server/index.cjs +191 -0
- package/dist/server/index.d.cts +148 -0
- package/dist/server/index.d.cts.map +1 -0
- package/dist/server/index.d.mts +148 -0
- package/dist/server/index.d.mts.map +1 -0
- package/dist/server/index.mjs +182 -0
- package/dist/server/index.mjs.map +1 -0
- package/package.json +25 -13
- package/src/EffectSchema.ts +374 -0
- package/src/Primitive.ts +3 -0
- package/src/client/ClientDocument.ts +1 -1
- package/src/client/errors.ts +10 -10
- package/src/index.ts +1 -0
- package/src/primitives/Array.ts +57 -22
- package/src/primitives/Boolean.ts +33 -19
- package/src/primitives/Either.ts +379 -0
- package/src/primitives/Lazy.ts +16 -2
- package/src/primitives/Literal.ts +33 -20
- package/src/primitives/Number.ts +39 -26
- package/src/primitives/String.ts +40 -25
- package/src/primitives/Struct.ts +126 -29
- package/src/primitives/Tree.ts +119 -32
- package/src/primitives/TreeNode.ts +77 -30
- package/src/primitives/Union.ts +56 -29
- package/src/primitives/shared.ts +111 -9
- package/src/server/errors.ts +6 -6
- package/tests/EffectSchema.test.ts +546 -0
- package/tests/primitives/Array.test.ts +108 -0
- package/tests/primitives/Either.test.ts +707 -0
- package/tests/primitives/Struct.test.ts +250 -0
- package/tests/primitives/Tree.test.ts +250 -0
- package/tsdown.config.ts +1 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { _ as OperationPath_d_exports, a as InferSetInput, c as InferUpdateInput, d as ProxyEnvironment_d_exports, g as Operation_d_exports, h as Operation, i as InferProxy, m as Transaction_d_exports, n as AnyTreeNodePrimitive, o as InferSnapshot, p as Transaction, r as AnyPrimitive, s as InferState, t as Primitive_d_exports, u as Transform_d_exports, v as __export } from "./Primitive-CvFVxR8_.cjs";
|
|
2
|
+
import { i as Presence_d_exports } from "./Presence-DKKP4v5X.cjs";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
|
|
5
|
+
//#region src/Document.d.ts
|
|
6
|
+
declare namespace Document_d_exports {
|
|
7
|
+
export { Document, DocumentOptions, NestedTransactionError, OperationError, make };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when attempting to start a nested transaction.
|
|
11
|
+
*/
|
|
12
|
+
declare class NestedTransactionError extends Error {
|
|
13
|
+
readonly _tag = "NestedTransactionError";
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when an operation fails to apply.
|
|
18
|
+
*/
|
|
19
|
+
declare class OperationError extends Error {
|
|
20
|
+
readonly _tag = "OperationError";
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A Document manages state for a primitive-based schema with transaction support.
|
|
25
|
+
*/
|
|
26
|
+
interface Document<TSchema extends AnyPrimitive> {
|
|
27
|
+
/** The schema defining this document's structure */
|
|
28
|
+
readonly schema: TSchema;
|
|
29
|
+
/** Root proxy for accessing and modifying document data */
|
|
30
|
+
readonly root: InferProxy<TSchema>;
|
|
31
|
+
/** Returns the current document state */
|
|
32
|
+
get(): InferState<TSchema> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Returns a readonly snapshot of the entire document state for rendering.
|
|
35
|
+
* The snapshot is a type-safe, readonly structure where:
|
|
36
|
+
* - Required fields and fields with defaults are guaranteed to be defined
|
|
37
|
+
* - Optional fields may be undefined
|
|
38
|
+
*/
|
|
39
|
+
toSnapshot(): InferSnapshot<TSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Runs a function within a transaction.
|
|
42
|
+
* All operations are collected and applied atomically.
|
|
43
|
+
* If the function throws, all changes are rolled back.
|
|
44
|
+
* @returns The return value of the function
|
|
45
|
+
*/
|
|
46
|
+
transaction<R>(fn: (root: InferProxy<TSchema>) => R): R;
|
|
47
|
+
/**
|
|
48
|
+
* Applies external operations (e.g., from server/peers) to the document.
|
|
49
|
+
* These operations are NOT added to pending operations.
|
|
50
|
+
*/
|
|
51
|
+
apply(ops: ReadonlyArray<Operation<any, any, any>>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Returns pending local operations as a Transaction and clears the buffer.
|
|
54
|
+
*/
|
|
55
|
+
flush(): Transaction;
|
|
56
|
+
}
|
|
57
|
+
interface DocumentOptions<TSchema extends AnyPrimitive> {
|
|
58
|
+
/** Initial state for the document */
|
|
59
|
+
readonly initial?: InferState<TSchema>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new Document for the given schema.
|
|
63
|
+
*/
|
|
64
|
+
declare const make: <TSchema extends AnyPrimitive>(schema: TSchema, options?: DocumentOptions<TSchema>) => Document<TSchema>;
|
|
65
|
+
declare namespace EffectSchema_d_exports {
|
|
66
|
+
export { ToSetSchema, ToTreeNodeSetSchema, ToTreeNodeUpdateSchema, ToUpdateSchema, TreeNodeStateSchema, toSetSchema, toUpdateSchema };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Infer the Effect.Schema type for a primitive's set input.
|
|
70
|
+
*/
|
|
71
|
+
type ToSetSchema<T extends AnyPrimitive> = Schema.Schema<InferSetInput<T>>;
|
|
72
|
+
/**
|
|
73
|
+
* Infer the Effect.Schema type for a primitive's update input.
|
|
74
|
+
*/
|
|
75
|
+
type ToUpdateSchema<T extends AnyPrimitive> = Schema.Schema<InferUpdateInput<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Type for TreeNode set schema - uses the node's data set input type
|
|
78
|
+
*/
|
|
79
|
+
type ToTreeNodeSetSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferSetInput<T["data"]>>;
|
|
80
|
+
/**
|
|
81
|
+
* Type for TreeNode update schema - uses the node's data update input type
|
|
82
|
+
*/
|
|
83
|
+
type ToTreeNodeUpdateSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferUpdateInput<T["data"]>>;
|
|
84
|
+
/**
|
|
85
|
+
* Schema for a tree node state (flat storage format).
|
|
86
|
+
*/
|
|
87
|
+
declare const TreeNodeStateSchema: Schema.Struct<{
|
|
88
|
+
id: typeof Schema.String;
|
|
89
|
+
type: typeof Schema.String;
|
|
90
|
+
parentId: Schema.NullOr<typeof Schema.String>;
|
|
91
|
+
pos: typeof Schema.String;
|
|
92
|
+
data: typeof Schema.Unknown;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Convert a Mimic primitive to an Effect.Schema for set operations.
|
|
96
|
+
*
|
|
97
|
+
* The resulting schema:
|
|
98
|
+
* - For structs: required fields (required=true, no default) are non-optional, others are optional
|
|
99
|
+
* - For arrays: uses the element's set schema
|
|
100
|
+
* - For unions: creates a Schema.Union of variant schemas
|
|
101
|
+
* - For TreeNode: delegates to the node's data struct schema
|
|
102
|
+
* - For Tree: returns Schema.Array of TreeNodeState
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const UserSchema = Primitive.Struct({
|
|
107
|
+
* name: Primitive.String().required(),
|
|
108
|
+
* age: Primitive.Number().default(0),
|
|
109
|
+
* email: Primitive.String(),
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* const SetSchema = toSetSchema(UserSchema);
|
|
113
|
+
* // { name: string, age?: number, email?: string }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare function toSetSchema<T extends AnyPrimitive>(primitive: T): ToSetSchema<T>;
|
|
117
|
+
declare function toSetSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeSetSchema<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Convert a Mimic primitive to an Effect.Schema for update operations.
|
|
120
|
+
*
|
|
121
|
+
* The resulting schema:
|
|
122
|
+
* - For structs: all fields are optional (partial updates)
|
|
123
|
+
* - For unions: all variant fields are optional
|
|
124
|
+
* - For TreeNode: delegates to the node's data struct update schema
|
|
125
|
+
* - For simple primitives: same as set schema
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const UserSchema = Primitive.Struct({
|
|
130
|
+
* name: Primitive.String().required(),
|
|
131
|
+
* age: Primitive.Number().default(0),
|
|
132
|
+
* email: Primitive.String(),
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* const UpdateSchema = toUpdateSchema(UserSchema);
|
|
136
|
+
* // { name?: string, age?: string, email?: string }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare function toUpdateSchema<T extends AnyPrimitive>(primitive: T): ToUpdateSchema<T>;
|
|
140
|
+
declare function toUpdateSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeUpdateSchema<T>;
|
|
141
|
+
//#endregion
|
|
142
|
+
export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform };
|
|
143
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/Document.ts","../src/EffectSchema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;cAaa,sBAAA,SAA+B,KAAA;;;;;;AAA5C;AAWa,cAAA,cAAA,SAAuB,KAAA,CAAK;EAexB,SAAA,IAAQ,GAAA,gBAAA;EAAiB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;;AAQjC,UARQ,QAQR,CAAA,gBARiC,YAQjC,CAAA,CAAA;EAQ+B;EAAxB,SAAA,MAAA,EAdG,OAcH;EAQiC;EAArB,SAAA,IAAA,EAnBX,UAmBW,CAnBU,OAmBV,CAAA;EAAkC;EAAI,GAAA,EAAA,EAhBzD,UAgByD,CAhBpC,OAgBoC,CAAA,GAAA,SAAA;EAMvC;;;;AAY3B;;EAE0C,UAAA,EAAA,EA5B1B,aA4B0B,CA5BF,OA4BE,CAAA;EAArB;;AAUrB;;;;EAEY,WAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,IAAA,EAhCgB,UAgChB,CAhCqC,OAgCrC,CAAA,EAAA,GAhCkD,CAgClD,CAAA,EAhCsD,CAgCtD;EACA;;;;aA3BC,cAAc;;;;WAKhB;;UAOM,gCAAgC;;qBAE5B,WAAqB;;;AC7D1C;;AAA8E,cDuEjE,ICvEiE,EAAA,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A,CAAA,SAAA,EA4UhB,CA5UgB,CAAA,EA4UZ,cA5UY,CA4UG,CA5UH,CAAA;AASrE,iBAoUG,cA9Td,CAAA,UA8TuC,oBA9TvC,CAAA,CAAA,SAAA,EA8TwE,CA9TxE,CAAA,EA8T4E,sBA9T5E,CA8TmG,CA9TnG,CAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { i as Presence_d_exports } from "./Presence-N8u7Eppr.mjs";
|
|
2
|
+
import { _ as OperationPath_d_exports, a as InferSetInput, c as InferUpdateInput, d as ProxyEnvironment_d_exports, g as Operation_d_exports, h as Operation, i as InferProxy, m as Transaction_d_exports, n as AnyTreeNodePrimitive, o as InferSnapshot, p as Transaction, r as AnyPrimitive, s as InferState, t as Primitive_d_exports, u as Transform_d_exports } from "./Primitive-lEhQyGVL.mjs";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
|
|
5
|
+
//#region src/Document.d.ts
|
|
6
|
+
declare namespace Document_d_exports {
|
|
7
|
+
export { Document, DocumentOptions, NestedTransactionError, OperationError, make };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when attempting to start a nested transaction.
|
|
11
|
+
*/
|
|
12
|
+
declare class NestedTransactionError extends Error {
|
|
13
|
+
readonly _tag = "NestedTransactionError";
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when an operation fails to apply.
|
|
18
|
+
*/
|
|
19
|
+
declare class OperationError extends Error {
|
|
20
|
+
readonly _tag = "OperationError";
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A Document manages state for a primitive-based schema with transaction support.
|
|
25
|
+
*/
|
|
26
|
+
interface Document<TSchema extends AnyPrimitive> {
|
|
27
|
+
/** The schema defining this document's structure */
|
|
28
|
+
readonly schema: TSchema;
|
|
29
|
+
/** Root proxy for accessing and modifying document data */
|
|
30
|
+
readonly root: InferProxy<TSchema>;
|
|
31
|
+
/** Returns the current document state */
|
|
32
|
+
get(): InferState<TSchema> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Returns a readonly snapshot of the entire document state for rendering.
|
|
35
|
+
* The snapshot is a type-safe, readonly structure where:
|
|
36
|
+
* - Required fields and fields with defaults are guaranteed to be defined
|
|
37
|
+
* - Optional fields may be undefined
|
|
38
|
+
*/
|
|
39
|
+
toSnapshot(): InferSnapshot<TSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Runs a function within a transaction.
|
|
42
|
+
* All operations are collected and applied atomically.
|
|
43
|
+
* If the function throws, all changes are rolled back.
|
|
44
|
+
* @returns The return value of the function
|
|
45
|
+
*/
|
|
46
|
+
transaction<R>(fn: (root: InferProxy<TSchema>) => R): R;
|
|
47
|
+
/**
|
|
48
|
+
* Applies external operations (e.g., from server/peers) to the document.
|
|
49
|
+
* These operations are NOT added to pending operations.
|
|
50
|
+
*/
|
|
51
|
+
apply(ops: ReadonlyArray<Operation<any, any, any>>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Returns pending local operations as a Transaction and clears the buffer.
|
|
54
|
+
*/
|
|
55
|
+
flush(): Transaction;
|
|
56
|
+
}
|
|
57
|
+
interface DocumentOptions<TSchema extends AnyPrimitive> {
|
|
58
|
+
/** Initial state for the document */
|
|
59
|
+
readonly initial?: InferState<TSchema>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new Document for the given schema.
|
|
63
|
+
*/
|
|
64
|
+
declare const make: <TSchema extends AnyPrimitive>(schema: TSchema, options?: DocumentOptions<TSchema>) => Document<TSchema>;
|
|
65
|
+
declare namespace EffectSchema_d_exports {
|
|
66
|
+
export { ToSetSchema, ToTreeNodeSetSchema, ToTreeNodeUpdateSchema, ToUpdateSchema, TreeNodeStateSchema, toSetSchema, toUpdateSchema };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Infer the Effect.Schema type for a primitive's set input.
|
|
70
|
+
*/
|
|
71
|
+
type ToSetSchema<T extends AnyPrimitive> = Schema.Schema<InferSetInput<T>>;
|
|
72
|
+
/**
|
|
73
|
+
* Infer the Effect.Schema type for a primitive's update input.
|
|
74
|
+
*/
|
|
75
|
+
type ToUpdateSchema<T extends AnyPrimitive> = Schema.Schema<InferUpdateInput<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Type for TreeNode set schema - uses the node's data set input type
|
|
78
|
+
*/
|
|
79
|
+
type ToTreeNodeSetSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferSetInput<T["data"]>>;
|
|
80
|
+
/**
|
|
81
|
+
* Type for TreeNode update schema - uses the node's data update input type
|
|
82
|
+
*/
|
|
83
|
+
type ToTreeNodeUpdateSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferUpdateInput<T["data"]>>;
|
|
84
|
+
/**
|
|
85
|
+
* Schema for a tree node state (flat storage format).
|
|
86
|
+
*/
|
|
87
|
+
declare const TreeNodeStateSchema: Schema.Struct<{
|
|
88
|
+
id: typeof Schema.String;
|
|
89
|
+
type: typeof Schema.String;
|
|
90
|
+
parentId: Schema.NullOr<typeof Schema.String>;
|
|
91
|
+
pos: typeof Schema.String;
|
|
92
|
+
data: typeof Schema.Unknown;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Convert a Mimic primitive to an Effect.Schema for set operations.
|
|
96
|
+
*
|
|
97
|
+
* The resulting schema:
|
|
98
|
+
* - For structs: required fields (required=true, no default) are non-optional, others are optional
|
|
99
|
+
* - For arrays: uses the element's set schema
|
|
100
|
+
* - For unions: creates a Schema.Union of variant schemas
|
|
101
|
+
* - For TreeNode: delegates to the node's data struct schema
|
|
102
|
+
* - For Tree: returns Schema.Array of TreeNodeState
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const UserSchema = Primitive.Struct({
|
|
107
|
+
* name: Primitive.String().required(),
|
|
108
|
+
* age: Primitive.Number().default(0),
|
|
109
|
+
* email: Primitive.String(),
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* const SetSchema = toSetSchema(UserSchema);
|
|
113
|
+
* // { name: string, age?: number, email?: string }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare function toSetSchema<T extends AnyPrimitive>(primitive: T): ToSetSchema<T>;
|
|
117
|
+
declare function toSetSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeSetSchema<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Convert a Mimic primitive to an Effect.Schema for update operations.
|
|
120
|
+
*
|
|
121
|
+
* The resulting schema:
|
|
122
|
+
* - For structs: all fields are optional (partial updates)
|
|
123
|
+
* - For unions: all variant fields are optional
|
|
124
|
+
* - For TreeNode: delegates to the node's data struct update schema
|
|
125
|
+
* - For simple primitives: same as set schema
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const UserSchema = Primitive.Struct({
|
|
130
|
+
* name: Primitive.String().required(),
|
|
131
|
+
* age: Primitive.Number().default(0),
|
|
132
|
+
* email: Primitive.String(),
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* const UpdateSchema = toUpdateSchema(UserSchema);
|
|
136
|
+
* // { name?: string, age?: string, email?: string }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare function toUpdateSchema<T extends AnyPrimitive>(primitive: T): ToUpdateSchema<T>;
|
|
140
|
+
declare function toUpdateSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeUpdateSchema<T>;
|
|
141
|
+
//#endregion
|
|
142
|
+
export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform };
|
|
143
|
+
//# sourceMappingURL=index.d.mts.map
|
|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