jazz-tools 0.8.45 → 0.8.49
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +16 -0
- package/dist/{chunk-5WLKIDKU.js → chunk-6OHBW32Q.js} +15 -6
- package/dist/chunk-6OHBW32Q.js.map +1 -0
- package/dist/index.native.js +1 -1
- package/dist/index.web.js +1 -1
- package/package.json +2 -2
- package/src/coValues/account.ts +9 -2
- package/src/coValues/coMap.ts +8 -2
- package/src/implementation/createContext.ts +2 -2
- package/src/tests/coMap.test.ts +9 -6
- package/src/tests/groupsAndAccounts.test.ts +0 -62
- package/src/tests/inbox.test.ts +43 -0
- package/src/tests/utils.ts +2 -2
- package/dist/chunk-5WLKIDKU.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.8.
|
2
|
+
> jazz-tools@0.8.49 build /home/runner/work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index.web":"src/index.web.ts","index.native":"src/index.native.ts"}
|
@@ -11,8 +11,8 @@
|
|
11
11
|
[34mESM[39m Build start
|
12
12
|
[32mESM[39m [1mdist/index.web.js [22m[32m1.08 KB[39m
|
13
13
|
[32mESM[39m [1mdist/index.native.js [22m[32m1.07 KB[39m
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
14
|
+
[32mESM[39m [1mdist/chunk-6OHBW32Q.js [22m[32m81.76 KB[39m
|
15
15
|
[32mESM[39m [1mdist/index.web.js.map [22m[32m270.00 B[39m
|
16
16
|
[32mESM[39m [1mdist/index.native.js.map [22m[32m280.00 B[39m
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
17
|
+
[32mESM[39m [1mdist/chunk-6OHBW32Q.js.map [22m[32m188.47 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 85ms
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.8.49
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies [25dfd90]
|
8
|
+
- cojson@0.8.49
|
9
|
+
|
10
|
+
## 0.8.48
|
11
|
+
|
12
|
+
### Patch Changes
|
13
|
+
|
14
|
+
- 635e824: fix loading of CoMaps with an empty schema
|
15
|
+
- 0a85982: Remove the requirement of calling super.migrate when defining the account migration
|
16
|
+
- Updated dependencies [10ea733]
|
17
|
+
- cojson@0.8.48
|
18
|
+
|
3
19
|
## 0.8.45
|
4
20
|
|
5
21
|
### Patch Changes
|
@@ -450,7 +450,7 @@ async function createJazzContext(options) {
|
|
450
450
|
const account2 = new AccountSchema({
|
451
451
|
fromRaw: rawAccount
|
452
452
|
});
|
453
|
-
await account2.
|
453
|
+
await account2.applyMigration(creationProps);
|
454
454
|
}
|
455
455
|
});
|
456
456
|
const account = AccountSchema.fromNode(node);
|
@@ -493,7 +493,7 @@ async function createJazzContext(options) {
|
|
493
493
|
const account2 = new AccountSchema({
|
494
494
|
fromRaw: rawAccount
|
495
495
|
});
|
496
|
-
await account2.
|
496
|
+
await account2.applyMigration(creationProps);
|
497
497
|
}
|
498
498
|
});
|
499
499
|
const account = AccountSchema.fromNode(node);
|
@@ -1361,7 +1361,11 @@ var CoMapProxyHandler = {
|
|
1361
1361
|
} else if (key in target) {
|
1362
1362
|
return Reflect.get(target, key, receiver);
|
1363
1363
|
} else {
|
1364
|
-
const
|
1364
|
+
const schema = target._schema;
|
1365
|
+
if (!schema) {
|
1366
|
+
return void 0;
|
1367
|
+
}
|
1368
|
+
const descriptor = schema[key] || schema[ItemsSym];
|
1365
1369
|
if (descriptor && typeof key === "string") {
|
1366
1370
|
const raw = target._raw.get(key);
|
1367
1371
|
if (descriptor === "json") {
|
@@ -1552,7 +1556,7 @@ var _Account = class _Account extends CoValueBase {
|
|
1552
1556
|
const account = new this({
|
1553
1557
|
fromRaw: rawAccount
|
1554
1558
|
});
|
1555
|
-
await account.
|
1559
|
+
await account.applyMigration?.(creationProps);
|
1556
1560
|
}
|
1557
1561
|
});
|
1558
1562
|
return this.fromNode(node);
|
@@ -1585,7 +1589,7 @@ var _Account = class _Account extends CoValueBase {
|
|
1585
1589
|
[inspect]() {
|
1586
1590
|
return this.toJSON();
|
1587
1591
|
}
|
1588
|
-
|
1592
|
+
async applyMigration(creationProps) {
|
1589
1593
|
if (creationProps) {
|
1590
1594
|
const profileGroup = RegisteredSchemas["Group"].create({ owner: this });
|
1591
1595
|
profileGroup.addMember("everyone", "reader");
|
@@ -1601,6 +1605,11 @@ var _Account = class _Account extends CoValueBase {
|
|
1601
1605
|
profile.set("inbox", inboxRoot.id);
|
1602
1606
|
profile.set("inboxInvite", inboxRoot.inviteLink);
|
1603
1607
|
}
|
1608
|
+
await this.migrate(creationProps);
|
1609
|
+
}
|
1610
|
+
// Placeholder method for subclasses to override
|
1611
|
+
migrate(creationProps) {
|
1612
|
+
creationProps;
|
1604
1613
|
}
|
1605
1614
|
/** @category Subscription & Loading */
|
1606
1615
|
static load(id, as, depth) {
|
@@ -2841,4 +2850,4 @@ export {
|
|
2841
2850
|
SchemaUnion
|
2842
2851
|
};
|
2843
2852
|
/* istanbul ignore file -- @preserve */
|
2844
|
-
//# sourceMappingURL=chunk-
|
2853
|
+
//# sourceMappingURL=chunk-6OHBW32Q.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/implementation/anonymousJazzAgent.ts","../src/coValues/interfaces.ts","../src/implementation/symbols.ts","../src/implementation/inspect.ts","../src/lib/cache.ts","../src/implementation/refs.ts","../src/implementation/schema.ts","../src/implementation/subscriptionScope.ts","../src/coValues/deepLoading.ts","../src/implementation/createContext.ts","../src/coValues/registeredSchemas.ts","../src/implementation/devtoolsFormatters.ts","../src/coValues/inbox.ts","../src/coValues/coMap.ts","../src/coValues/profile.ts","../src/coValues/account.ts","../src/coValues/group.ts","../src/coValues/coFeed.ts","../src/coValues/coList.ts","../src/coValues/extensions/imageDef.ts","../src/coValues/schemaUnion.ts"],"sourcesContent":["import { LocalNode } from \"cojson\";\n\nexport class AnonymousJazzAgent {\n _type = \"Anonymous\" as const;\n constructor(public node: LocalNode) {}\n}\n","import type { CojsonInternalTypes, RawCoValue } from \"cojson\";\nimport { RawAccount } from \"cojson\";\nimport { AnonymousJazzAgent } from \"../implementation/anonymousJazzAgent.js\";\nimport type { DeeplyLoaded, DepthsIn } from \"../internal.js\";\nimport {\n Ref,\n SubscriptionScope,\n inspect,\n subscriptionsScopes,\n} from \"../internal.js\";\nimport { coValuesCache } from \"../lib/cache.js\";\nimport { type Account } from \"./account.js\";\nimport { fulfillsDepth } from \"./deepLoading.js\";\nimport { type Group } from \"./group.js\";\nimport { RegisteredSchemas } from \"./registeredSchemas.js\";\n\n/** @category Abstract interfaces */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface CoValueClass<Value extends CoValue = CoValue> {\n /** @ignore */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): Value;\n}\n\nexport interface CoValueFromRaw<V extends CoValue> {\n fromRaw(raw: V[\"_raw\"]): V;\n}\n\n/** @category Abstract interfaces */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface CoValue {\n /** @category Content */\n readonly id: ID<this>;\n /** @category Type Helpers */\n _type: string;\n /** @category Collaboration */\n _owner: Account | Group;\n /** @category Internals */\n _raw: RawCoValue;\n /** @internal */\n readonly _loadedAs: Account | AnonymousJazzAgent;\n /** @category Stringifying & Inspection */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(key?: string, seenAbove?: ID<CoValue>[]): any[] | object | string;\n /** @category Stringifying & Inspection */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [inspect](): any;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isCoValue(value: any): value is CoValue {\n return value && value._type !== undefined;\n}\n\nexport function isCoValueClass<V extends CoValue>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any,\n): value is CoValueClass<V> & CoValueFromRaw<V> {\n return typeof value === \"function\" && value.fromRaw !== undefined;\n}\n\n/**\n * IDs are unique identifiers for `CoValue`s.\n * Can be used with a type argument to refer to a specific `CoValue` type.\n *\n * @example\n *\n * ```ts\n * type AccountID = ID<Account>;\n * ```\n *\n * @category CoValues\n */\nexport type ID<T> = CojsonInternalTypes.RawCoID & IDMarker<T>;\n\ntype IDMarker<out T> = { __type(_: never): T };\n\n/** @internal */\nexport class CoValueBase implements CoValue {\n declare id: ID<this>;\n declare _type: string;\n declare _raw: RawCoValue;\n /** @category Internals */\n declare _instanceID: string;\n\n get _owner(): Account | Group {\n const owner =\n this._raw.group instanceof RawAccount\n ? RegisteredSchemas[\"Account\"].fromRaw(this._raw.group)\n : RegisteredSchemas[\"Group\"].fromRaw(this._raw.group);\n\n const subScope = subscriptionsScopes.get(this);\n if (subScope) {\n subScope.onRefAccessedOrSet(this.id, owner.id);\n subscriptionsScopes.set(owner, subScope);\n }\n\n return owner;\n }\n\n /** @private */\n get _loadedAs() {\n const rawAccount = this._raw.core.node.account;\n\n if (rawAccount instanceof RawAccount) {\n return coValuesCache.get(rawAccount, () =>\n RegisteredSchemas[\"Account\"].fromRaw(rawAccount),\n );\n }\n\n return new AnonymousJazzAgent(this._raw.core.node);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(..._args: any) {\n Object.defineProperty(this, \"_instanceID\", {\n value: `instance-${Math.random().toString(36).slice(2)}`,\n enumerable: false,\n });\n }\n\n /** @category Internals */\n static fromRaw<V extends CoValue>(this: CoValueClass<V>, raw: RawCoValue): V {\n return new this({ fromRaw: raw });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(): object | any[] | string {\n return {\n id: this.id,\n type: this._type,\n error: \"unknown CoValue class\",\n };\n }\n\n [inspect]() {\n return this.toJSON();\n }\n\n /** @category Type Helpers */\n castAs<Cl extends CoValueClass & CoValueFromRaw<CoValue>>(\n cl: Cl,\n ): InstanceType<Cl> {\n const casted = cl.fromRaw(this._raw) as InstanceType<Cl>;\n const subscriptionScope = subscriptionsScopes.get(this);\n if (subscriptionScope) {\n subscriptionsScopes.set(casted, subscriptionScope);\n }\n return casted;\n }\n}\n\nexport function loadCoValue<V extends CoValue, Depth>(\n cls: CoValueClass<V>,\n id: ID<V>,\n as: Account | AnonymousJazzAgent,\n depth: Depth & DepthsIn<V>,\n): Promise<DeeplyLoaded<V, Depth> | undefined> {\n return new Promise((resolve) => {\n const unsubscribe = subscribeToCoValue(\n cls,\n id,\n as,\n depth,\n (value) => {\n resolve(value);\n unsubscribe();\n },\n () => {\n resolve(undefined);\n unsubscribe();\n },\n );\n });\n}\n\nexport function ensureCoValueLoaded<V extends CoValue, Depth>(\n existing: V,\n depth: Depth & DepthsIn<V>,\n): Promise<DeeplyLoaded<V, Depth> | undefined> {\n return loadCoValue(\n existing.constructor as CoValueClass<V>,\n existing.id,\n existing._loadedAs,\n depth,\n );\n}\n\nexport function subscribeToCoValue<V extends CoValue, Depth>(\n cls: CoValueClass<V>,\n id: ID<V>,\n as: Account | AnonymousJazzAgent,\n depth: Depth & DepthsIn<V>,\n listener: (value: DeeplyLoaded<V, Depth>) => void,\n onUnavailable?: () => void,\n): () => void {\n const ref = new Ref(id, as, { ref: cls, optional: false });\n\n let unsubscribed = false;\n let unsubscribe: (() => void) | undefined;\n\n ref\n .load()\n .then((value) => {\n if (!value) {\n onUnavailable && onUnavailable();\n return;\n }\n if (unsubscribed) return;\n const subscription = new SubscriptionScope(\n value,\n cls as CoValueClass<V> & CoValueFromRaw<V>,\n (update) => {\n if (fulfillsDepth(depth, update)) {\n listener(update as DeeplyLoaded<V, Depth>);\n }\n },\n );\n\n unsubscribe = () => subscription.unsubscribeAll();\n })\n .catch((e) => {\n console.error(\"Failed to load / subscribe to CoValue\", e);\n });\n\n return function unsubscribeAtAnyPoint() {\n unsubscribed = true;\n unsubscribe && unsubscribe();\n };\n}\n\nexport function createCoValueObservable<V extends CoValue, Depth>() {\n let currentValue: DeeplyLoaded<V, Depth> | undefined = undefined;\n let subscriberCount = 0;\n\n function subscribe(\n cls: CoValueClass<V>,\n id: ID<V>,\n as: Account | AnonymousJazzAgent,\n depth: Depth & DepthsIn<V>,\n listener: () => void,\n onUnavailable?: () => void,\n ) {\n subscriberCount++;\n\n const unsubscribe = subscribeToCoValue(\n cls,\n id,\n as,\n depth,\n (value) => {\n currentValue = value;\n listener();\n },\n onUnavailable,\n );\n\n return () => {\n unsubscribe();\n subscriberCount--;\n if (subscriberCount === 0) {\n currentValue = undefined;\n }\n };\n }\n\n const observable = {\n getCurrentValue: () => currentValue,\n subscribe,\n };\n\n return observable;\n}\n\nexport function subscribeToExistingCoValue<V extends CoValue, Depth>(\n existing: V,\n depth: Depth & DepthsIn<V>,\n listener: (value: DeeplyLoaded<V, Depth>) => void,\n): () => void {\n return subscribeToCoValue(\n existing.constructor as CoValueClass<V>,\n existing.id,\n existing._loadedAs,\n depth,\n listener,\n );\n}\n","export const SchemaInit = Symbol.for(\"SchemaInit\");\nexport type SchemaInit = typeof SchemaInit;\n\nexport const ItemsSym = Symbol.for(\"items\");\nexport type ItemsSym = typeof ItemsSym;\n\nexport const MembersSym = Symbol.for(\"members\");\nexport type MembersSym = typeof MembersSym;\n","export const inspect = Symbol.for(\"nodejs.util.inspect.custom\");\nexport type inspect = typeof inspect;\n","import { RawCoValue } from \"cojson\";\nimport { CoValue } from \"../internal.js\";\n\nconst weakMap = new WeakMap<RawCoValue, CoValue>();\n\nexport const coValuesCache = {\n get: <V extends CoValue>(raw: RawCoValue, compute: () => V) => {\n const cached = weakMap.get(raw);\n if (cached) {\n return cached as V;\n }\n const computed = compute();\n weakMap.set(raw, computed);\n return computed;\n },\n};\n","import type { CoID, RawCoValue } from \"cojson\";\nimport { type Account } from \"../coValues/account.js\";\nimport type {\n AnonymousJazzAgent,\n CoValue,\n ID,\n RefEncoded,\n UnCo,\n} from \"../internal.js\";\nimport {\n instantiateRefEncoded,\n isRefEncoded,\n subscriptionsScopes,\n} from \"../internal.js\";\nimport { coValuesCache } from \"../lib/cache.js\";\n\nconst TRACE_ACCESSES = false;\n\nexport class Ref<out V extends CoValue> {\n constructor(\n readonly id: ID<V>,\n readonly controlledAccount: Account | AnonymousJazzAgent,\n readonly schema: RefEncoded<V>,\n ) {\n if (!isRefEncoded(schema)) {\n throw new Error(\"Ref must be constructed with a ref schema\");\n }\n }\n\n get value() {\n const node =\n \"node\" in this.controlledAccount\n ? this.controlledAccount.node\n : this.controlledAccount._raw.core.node;\n const raw = node.getLoaded(this.id as unknown as CoID<RawCoValue>);\n if (raw) {\n return coValuesCache.get(raw, () =>\n instantiateRefEncoded(this.schema, raw),\n );\n } else {\n return null;\n }\n }\n\n private async loadHelper(): Promise<V | \"unavailable\"> {\n const node =\n \"node\" in this.controlledAccount\n ? this.controlledAccount.node\n : this.controlledAccount._raw.core.node;\n const raw = await node.load(this.id as unknown as CoID<RawCoValue>);\n if (raw === \"unavailable\") {\n return \"unavailable\";\n } else {\n return new Ref(this.id, this.controlledAccount, this.schema).value!;\n }\n }\n\n async load(): Promise<V | undefined> {\n const result = await this.loadHelper();\n if (result === \"unavailable\") {\n return undefined;\n } else {\n return result;\n }\n }\n\n accessFrom(fromScopeValue: CoValue, key: string | number | symbol): V | null {\n const subScope = subscriptionsScopes.get(fromScopeValue);\n\n subScope?.onRefAccessedOrSet(fromScopeValue.id, this.id);\n TRACE_ACCESSES &&\n console.log(subScope?.scopeID, \"accessing\", fromScopeValue, key, this.id);\n\n if (this.value && subScope) {\n subscriptionsScopes.set(this.value, subScope);\n }\n\n if (subScope) {\n const cached = subScope.cachedValues[this.id];\n if (cached) {\n TRACE_ACCESSES && console.log(\"cached\", cached);\n return cached as V;\n } else if (this.value !== null) {\n const freshValueInstance = instantiateRefEncoded(\n this.schema,\n this.value?._raw,\n );\n TRACE_ACCESSES && console.log(\"freshValueInstance\", freshValueInstance);\n subScope.cachedValues[this.id] = freshValueInstance;\n subscriptionsScopes.set(freshValueInstance, subScope);\n return freshValueInstance as V;\n } else {\n return null;\n }\n } else {\n return this.value;\n }\n }\n}\n\nexport function makeRefs<Keys extends string | number>(\n getIdForKey: (key: Keys) => ID<CoValue> | undefined,\n getKeysWithIds: () => Keys[],\n controlledAccount: Account | AnonymousJazzAgent,\n refSchemaForKey: (key: Keys) => RefEncoded<CoValue>,\n): { [K in Keys]: Ref<CoValue> } & {\n [Symbol.iterator]: () => IterableIterator<Ref<CoValue>>;\n length: number;\n} {\n const refs = {} as { [K in Keys]: Ref<CoValue> } & {\n [Symbol.iterator]: () => IterableIterator<Ref<CoValue>>;\n length: number;\n };\n return new Proxy(refs, {\n get(_target, key) {\n if (key === Symbol.iterator) {\n return function* () {\n for (const key of getKeysWithIds()) {\n yield new Ref(\n getIdForKey(key)!,\n controlledAccount,\n refSchemaForKey(key),\n );\n }\n };\n }\n if (typeof key === \"symbol\") return undefined;\n if (key === \"length\") {\n return getKeysWithIds().length;\n }\n const id = getIdForKey(key as Keys);\n if (!id) return undefined;\n return new Ref(\n id as ID<CoValue>,\n controlledAccount,\n refSchemaForKey(key as Keys),\n );\n },\n ownKeys() {\n return getKeysWithIds().map((key) => key.toString());\n },\n getOwnPropertyDescriptor(target, key) {\n const id = getIdForKey(key as Keys);\n if (id) {\n return {\n enumerable: true,\n configurable: true,\n writable: true,\n };\n } else {\n return Reflect.getOwnPropertyDescriptor(target, key);\n }\n },\n });\n}\n\nexport type RefIfCoValue<V> = NonNullable<V> extends CoValue\n ? Ref<UnCo<NonNullable<V>>>\n : never;\n","import type { JsonValue, RawCoValue } from \"cojson\";\nimport { CoJsonValue } from \"cojson/src/jsonValue.js\";\nimport {\n type CoValue,\n type CoValueClass,\n CoValueFromRaw,\n ItemsSym,\n MembersSym,\n SchemaInit,\n isCoValueClass,\n} from \"../internal.js\";\n\n/** @category Schema definition */\nexport const Encoders = {\n Date: {\n encode: (value: Date) => value.toISOString(),\n decode: (value: JsonValue) => new Date(value as string),\n },\n};\n\nexport type CoMarker = { readonly __co: unique symbol };\n/** @category Schema definition */\nexport type co<T> = T | (T & CoMarker);\nexport type IfCo<C, R> = C extends infer _A | infer B\n ? B extends CoMarker\n ? R\n : never\n : never;\nexport type UnCo<T> = T extends co<infer A> ? A : T;\n\nconst optional = {\n ref: optionalRef,\n json<T extends CoJsonValue<T>>(): co<T | undefined> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return { [SchemaInit]: \"json\" satisfies Schema } as any;\n },\n encoded<T>(arg: OptionalEncoder<T>): co<T | undefined> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return { [SchemaInit]: { encoded: arg } satisfies Schema } as any;\n },\n string: {\n [SchemaInit]: \"json\" satisfies Schema,\n } as unknown as co<string | undefined>,\n number: {\n [SchemaInit]: \"json\" satisfies Schema,\n } as unknown as co<number | undefined>,\n boolean: {\n [SchemaInit]: \"json\" satisfies Schema,\n } as unknown as co<boolean | undefined>,\n null: {\n [SchemaInit]: \"json\" satisfies Schema,\n } as unknown as co<null | undefined>,\n Date: {\n [SchemaInit]: { encoded: Encoders.Date } satisfies Schema,\n } as unknown as co<Date | undefined>,\n literal<T extends (string | number | boolean)[]>(\n ..._lit: T\n ): co<T[number] | undefined> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return { [SchemaInit]: \"json\" satisfies Schema } as any;\n },\n};\n\n/** @category Schema definition */\nexport const co = {\n string: {\n [SchemaInit]: \"json\" satisfies Schema,\n } as unknown as co<string>,\n number: {\n [SchemaInit]: \"json\" satisfies Schema,\n } as unknown as co<number>,\n boolean: {\n [SchemaInit]: \"json\" satisfies Schema,\n } as unknown as co<boolean>,\n null: {\n [SchemaInit]: \"json\" satisfies Schema,\n } as unknown as co<null>,\n Date: {\n [SchemaInit]: { encoded: Encoders.Date } satisfies Schema,\n } as unknown as co<Date>,\n literal<T extends (string | number | boolean)[]>(..._lit: T): co<T[number]> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return { [SchemaInit]: \"json\" satisfies Schema } as any;\n },\n json<T extends CoJsonValue<T>>(): co<T> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return { [SchemaInit]: \"json\" satisfies Schema } as any;\n },\n encoded<T>(arg: Encoder<T>): co<T> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return { [SchemaInit]: { encoded: arg } satisfies Schema } as any;\n },\n ref,\n items: ItemsSym as ItemsSym,\n members: MembersSym as MembersSym,\n optional,\n};\n\nfunction optionalRef<C extends CoValueClass>(\n arg: C | ((_raw: InstanceType<C>[\"_raw\"]) => C),\n): co<InstanceType<C> | null | undefined> {\n return ref(arg, { optional: true });\n}\n\nfunction ref<C extends CoValueClass>(\n arg: C | ((_raw: InstanceType<C>[\"_raw\"]) => C),\n options?: never,\n): co<InstanceType<C> | null>;\nfunction ref<C extends CoValueClass>(\n arg: C | ((_raw: InstanceType<C>[\"_raw\"]) => C),\n options: { optional: true },\n): co<InstanceType<C> | null | undefined>;\nfunction ref<\n C extends CoValueClass,\n Options extends { optional?: boolean } | undefined,\n>(\n arg: C | ((_raw: InstanceType<C>[\"_raw\"]) => C),\n options?: Options,\n): Options extends { optional: true }\n ? co<InstanceType<C> | null | undefined>\n : co<InstanceType<C> | null> {\n return {\n [SchemaInit]: {\n ref: arg,\n optional: options?.optional || false,\n } satisfies Schema,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any;\n}\n\nexport type JsonEncoded = \"json\";\nexport type EncodedAs<V> = { encoded: Encoder<V> | OptionalEncoder<V> };\nexport type RefEncoded<V extends CoValue> = {\n ref: CoValueClass<V> | ((raw: RawCoValue) => CoValueClass<V>);\n optional: boolean;\n};\n\nexport function isRefEncoded<V extends CoValue>(\n schema: Schema,\n): schema is RefEncoded<V> {\n return (\n typeof schema === \"object\" &&\n \"ref\" in schema &&\n \"optional\" in schema &&\n typeof schema.ref === \"function\"\n );\n}\n\nexport function instantiateRefEncoded<V extends CoValue>(\n schema: RefEncoded<V>,\n raw: RawCoValue,\n): V {\n return isCoValueClass<V>(schema.ref)\n ? schema.ref.fromRaw(raw)\n : (schema.ref as (raw: RawCoValue) => CoValueClass<V> & CoValueFromRaw<V>)(\n raw,\n ).fromRaw(raw);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Schema = JsonEncoded | RefEncoded<CoValue> | EncodedAs<any>;\n\nexport type SchemaFor<Field> = NonNullable<Field> extends CoValue\n ? RefEncoded<NonNullable<Field>>\n : NonNullable<Field> extends JsonValue\n ? JsonEncoded\n : EncodedAs<NonNullable<Field>>;\n\nexport type Encoder<V> = {\n encode: (value: V) => JsonValue;\n decode: (value: JsonValue) => V;\n};\nexport type OptionalEncoder<V> =\n | Encoder<V>\n | {\n encode: (value: V | undefined) => JsonValue;\n decode: (value: JsonValue) => V | undefined;\n };\n","import type { RawCoValue } from \"cojson\";\nimport { type Account } from \"../coValues/account.js\";\nimport type {\n AnonymousJazzAgent,\n CoValue,\n CoValueClass,\n CoValueFromRaw,\n ID,\n} from \"../internal.js\";\n\nexport const subscriptionsScopes = new WeakMap<\n CoValue,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n SubscriptionScope<any>\n>();\n\nconst TRACE_INVALIDATIONS = false;\n\nexport class SubscriptionScope<Root extends CoValue> {\n scopeID: string = `scope-${Math.random().toString(36).slice(2)}`;\n subscriber: Account | AnonymousJazzAgent;\n entries = new Map<\n ID<CoValue>,\n | { state: \"loading\"; immediatelyUnsub?: boolean }\n | { state: \"loaded\"; rawUnsub: () => void }\n >();\n rootEntry: {\n state: \"loaded\";\n value: RawCoValue;\n rawUnsub: () => void;\n };\n scheduleUpdate: () => void;\n scheduledUpdate: boolean = false;\n cachedValues: { [id: ID<CoValue>]: CoValue } = {};\n parents: { [id: ID<CoValue>]: Set<ID<CoValue>> } = {};\n\n constructor(\n root: Root,\n rootSchema: CoValueClass<Root> & CoValueFromRaw<Root>,\n onUpdate: (newRoot: Root) => void,\n ) {\n this.rootEntry = {\n state: \"loaded\" as const,\n value: root._raw,\n rawUnsub: () => {}, // placeholder\n };\n this.entries.set(root.id, this.rootEntry);\n\n subscriptionsScopes.set(root, this);\n\n this.subscriber = root._loadedAs;\n this.scheduleUpdate = () => {\n const value = rootSchema.fromRaw(this.rootEntry.value) as Root;\n subscriptionsScopes.set(value, this);\n onUpdate(value);\n };\n\n this.rootEntry.rawUnsub = root._raw.core.subscribe(\n (rawUpdate: RawCoValue | undefined) => {\n if (!rawUpdate) return;\n this.rootEntry.value = rawUpdate;\n this.scheduleUpdate();\n },\n );\n }\n\n onRefAccessedOrSet(\n fromId: ID<CoValue>,\n accessedOrSetId: ID<CoValue> | undefined,\n ) {\n // console.log(\"onRefAccessedOrSet\", this.scopeID, accessedOrSetId);\n if (!accessedOrSetId) {\n return;\n }\n\n this.parents[accessedOrSetId] = this.parents[accessedOrSetId] || new Set();\n this.parents[accessedOrSetId]!.add(fromId);\n\n if (!this.entries.has(accessedOrSetId)) {\n const loadingEntry = {\n state: \"loading\",\n immediatelyUnsub: false,\n } as const;\n this.entries.set(accessedOrSetId, loadingEntry);\n const node =\n this.subscriber._type === \"Account\"\n ? this.subscriber._raw.core.node\n : this.subscriber.node;\n void node.loadCoValueCore(accessedOrSetId).then((core) => {\n if (loadingEntry.state === \"loading\" && loadingEntry.immediatelyUnsub) {\n return;\n }\n if (core !== \"unavailable\") {\n const entry = {\n state: \"loaded\" as const,\n rawUnsub: () => {}, // placeholder\n };\n this.entries.set(accessedOrSetId, entry);\n\n const rawUnsub = core.subscribe((rawUpdate) => {\n // console.log(\"ref update\", this.scopeID, accessedOrSetId, JSON.stringify(rawUpdate))\n if (!rawUpdate) return;\n this.invalidate(accessedOrSetId);\n this.scheduleUpdate();\n });\n\n entry.rawUnsub = rawUnsub;\n }\n });\n }\n }\n\n invalidate(\n id: ID<CoValue>,\n fromChild?: ID<CoValue>,\n seen: Set<ID<CoValue>> = new Set(),\n ) {\n if (seen.has(id)) return;\n TRACE_INVALIDATIONS &&\n console.log(\"invalidating\", fromChild, \"->\", id, this.cachedValues[id]);\n delete this.cachedValues[id];\n seen.add(id);\n for (const parent of this.parents[id] || []) {\n this.invalidate(parent, id, seen);\n }\n }\n\n unsubscribeAll() {\n for (const entry of this.entries.values()) {\n if (entry.state === \"loaded\") {\n entry.rawUnsub();\n } else {\n entry.immediatelyUnsub = true;\n }\n }\n this.entries.clear();\n }\n}\n","import { SessionID } from \"cojson\";\nimport { ItemsSym, type Ref, RefEncoded, UnCo } from \"../internal.js\";\nimport { type Account } from \"./account.js\";\nimport { type CoFeed, CoFeedEntry } from \"./coFeed.js\";\nimport { type CoList } from \"./coList.js\";\nimport { type CoKeys, type CoMap } from \"./coMap.js\";\nimport { type CoValue, type ID } from \"./interfaces.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function fulfillsDepth(depth: any, value: CoValue): boolean {\n if (\n value._type === \"CoMap\" ||\n value._type === \"Group\" ||\n value._type === \"Account\"\n ) {\n if (Array.isArray(depth) && depth.length === 1) {\n return Object.entries(value).every(([key, item]) => {\n return (\n value as unknown as {\n _refs: { [key: string]: Ref<CoValue> | undefined };\n }\n )._refs[key]\n ? item && fulfillsDepth(depth[0], item)\n : ((value as CoMap)._schema[ItemsSym] as RefEncoded<CoValue>)!\n .optional;\n });\n } else {\n for (const key of Object.keys(depth)) {\n const map = value as unknown as {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n _refs: { [key: string]: Ref<CoValue> | undefined };\n };\n if (!map._refs[key] && map._schema[key].optional) {\n continue;\n }\n if (!map[key]) {\n return false;\n }\n if (!fulfillsDepth(depth[key], map[key])) {\n return false;\n }\n }\n return true;\n }\n } else if (value._type === \"CoList\") {\n if (depth.length === 0) {\n return true;\n } else {\n const itemDepth = depth[0];\n return (value as CoList).every((item, i) =>\n (value as CoList)._refs[i]\n ? item && fulfillsDepth(itemDepth, item)\n : ((value as CoList)._schema[ItemsSym] as RefEncoded<CoValue>)\n .optional,\n );\n }\n } else if (value._type === \"CoStream\") {\n if (depth.length === 0) {\n return true;\n } else {\n const itemDepth = depth[0];\n return Object.values((value as CoFeed).perSession).every((entry) =>\n entry.ref\n ? entry.value && fulfillsDepth(itemDepth, entry.value)\n : ((value as CoFeed)._schema[ItemsSym] as RefEncoded<CoValue>)\n .optional,\n );\n }\n } else if (value._type === \"BinaryCoStream\") {\n return true;\n } else {\n console.error(value);\n throw new Error(\"Unexpected value type: \" + value._type);\n }\n}\n\ntype UnCoNotNull<T> = UnCo<Exclude<T, null>>;\ntype Clean<T> = UnCo<NonNullable<T>>;\n\nexport type DepthsIn<\n V,\n DepthLimit extends number = 5,\n CurrentDepth extends number[] = [],\n> =\n | (DepthLimit extends CurrentDepth[\"length\"]\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any\n : // Basically V extends CoList - but if we used that we'd introduce circularity into the definition of CoList itself\n V extends Array<infer Item>\n ?\n | [DepthsIn<UnCoNotNull<Item>, DepthLimit, [0, ...CurrentDepth]>]\n | never[]\n : // Basically V extends CoMap | Group | Account - but if we used that we'd introduce circularity into the definition of CoMap itself\n V extends { _type: \"CoMap\" | \"Group\" | \"Account\" }\n ?\n | {\n [Key in CoKeys<V> as Clean<V[Key]> extends CoValue\n ? Key\n : never]?: DepthsIn<\n Clean<V[Key]>,\n DepthLimit,\n [0, ...CurrentDepth]\n >;\n }\n | (ItemsSym extends keyof V\n ? [\n DepthsIn<\n Clean<V[ItemsSym]>,\n DepthLimit,\n [0, ...CurrentDepth]\n >,\n ]\n : never)\n | never[]\n : V extends {\n _type: \"CoStream\";\n byMe: CoFeedEntry<infer Item> | undefined;\n }\n ?\n | [\n DepthsIn<\n UnCoNotNull<Item>,\n DepthLimit,\n [0, ...CurrentDepth]\n >,\n ]\n | never[]\n : never[])\n | never[];\n\nexport type DeeplyLoaded<\n V,\n Depth,\n DepthLimit extends number = 5,\n CurrentDepth extends number[] = [],\n> = DepthLimit extends CurrentDepth[\"length\"]\n ? V\n : // Basically V extends CoList - but if we used that we'd introduce circularity into the definition of CoList itself\n [V] extends [Array<infer Item>]\n ? Depth extends never[] // []\n ? V\n : UnCoNotNull<Item> extends CoValue\n ? Depth extends Array<infer ItemDepth> // [item-depth]\n ? (UnCoNotNull<Item> &\n DeeplyLoaded<\n UnCoNotNull<Item>,\n ItemDepth,\n DepthLimit,\n [0, ...CurrentDepth]\n >)[] &\n V\n : never\n : V\n : // Basically V extends CoMap | Group | Account - but if we used that we'd introduce circularity into the definition of CoMap itself\n [V] extends [{ _type: \"CoMap\" | \"Group\" | \"Account\" }]\n ? Depth extends never[]\n ? V\n : Depth extends Array<infer ItemDepth>\n ? ItemsSym extends keyof V\n ? V & {\n [key: string]: DeeplyLoaded<\n Clean<V[ItemsSym]>,\n ItemDepth,\n DepthLimit,\n [0, ...CurrentDepth]\n >;\n }\n : never\n : keyof Depth extends never\n ? V\n : {\n [Key in keyof Depth]-?: Key extends CoKeys<V>\n ? Clean<V[Key]> extends CoValue\n ?\n | DeeplyLoaded<\n Clean<V[Key]>,\n Depth[Key],\n DepthLimit,\n [0, ...CurrentDepth]\n >\n | (undefined extends V[Key] ? undefined : never)\n : never\n : never;\n } & V\n : [V] extends [\n {\n _type: \"CoStream\";\n byMe: CoFeedEntry<infer Item> | undefined;\n },\n ]\n ? Depth extends never[]\n ? V\n : V & {\n byMe?: { value: UnCoNotNull<Item> };\n inCurrentSession?: { value: UnCoNotNull<Item> };\n perSession: {\n [key: SessionID]: { value: UnCoNotNull<Item> };\n };\n } & { [key: ID<Account>]: { value: UnCoNotNull<Item> } }\n : [V] extends [\n {\n _type: \"BinaryCoStream\";\n },\n ]\n ? V\n : never;\n","import {\n AgentSecret,\n CoID,\n ControlledAgent,\n CryptoProvider,\n LocalNode,\n Peer,\n RawAccount,\n RawAccountID,\n SessionID,\n} from \"cojson\";\nimport { type Account, type AccountClass } from \"../coValues/account.js\";\nimport { RegisteredSchemas } from \"../coValues/registeredSchemas.js\";\nimport type { ID } from \"../internal.js\";\nimport { AnonymousJazzAgent } from \"./anonymousJazzAgent.js\";\n\nexport type Credentials = {\n accountID: ID<Account>;\n secret: AgentSecret;\n};\n\nexport type AuthResult =\n | {\n type: \"existing\";\n credentials: Credentials;\n saveCredentials?: (credentials: Credentials) => Promise<void>;\n onSuccess: () => void;\n onError: (error: string | Error) => void;\n logOut: () => void;\n }\n | {\n type: \"new\";\n creationProps: { name: string };\n initialSecret?: AgentSecret;\n saveCredentials: (credentials: Credentials) => Promise<void>;\n onSuccess: () => void;\n onError: (error: string | Error) => void;\n logOut: () => void;\n };\n\nexport interface AuthMethod {\n start(crypto: CryptoProvider): Promise<AuthResult>;\n}\n\nexport const fixedCredentialsAuth = (credentials: {\n accountID: ID<Account>;\n secret: AgentSecret;\n}): AuthMethod => {\n return {\n start: async () => ({\n type: \"existing\",\n credentials,\n saveCredentials: async () => {},\n onSuccess: () => {},\n onError: () => {},\n logOut: () => {},\n }),\n };\n};\n\nexport const ephemeralCredentialsAuth = (): AuthMethod => {\n return {\n start: async () => ({\n type: \"new\",\n creationProps: { name: \"Ephemeral\" },\n saveCredentials: async () => {},\n onSuccess: () => {},\n onError: () => {},\n logOut: () => {},\n }),\n };\n};\n\nexport async function randomSessionProvider(\n accountID: ID<Account>,\n crypto: CryptoProvider,\n) {\n return {\n sessionID: crypto.newRandomSessionID(accountID as unknown as RawAccountID),\n sessionDone: () => {},\n };\n}\n\ntype ContextParamsWithAuth<Acc extends Account> = {\n AccountSchema?: AccountClass<Acc>;\n auth: AuthMethod;\n sessionProvider: (\n accountID: ID<Account>,\n crypto: CryptoProvider,\n ) => Promise<{ sessionID: SessionID; sessionDone: () => void }>;\n} & BaseContextParams;\n\ntype BaseContextParams = {\n peersToLoadFrom: Peer[];\n crypto: CryptoProvider;\n};\n\nexport type JazzContextWithAccount<Acc extends Account> = {\n account: Acc;\n done: () => void;\n logOut: () => void;\n};\n\nexport type JazzContextWithAgent = {\n agent: AnonymousJazzAgent;\n done: () => void;\n logOut: () => void;\n};\n\nexport type JazzContext<Acc extends Account> =\n | JazzContextWithAccount<Acc>\n | JazzContextWithAgent;\n\nexport async function createJazzContext<Acc extends Account>({\n AccountSchema,\n auth,\n sessionProvider,\n peersToLoadFrom,\n crypto,\n}: ContextParamsWithAuth<Acc>): Promise<JazzContextWithAccount<Acc>>;\nexport async function createJazzContext({\n peersToLoadFrom,\n crypto,\n}: BaseContextParams): Promise<JazzContextWithAgent>;\nexport async function createJazzContext<Acc extends Account>(\n options: ContextParamsWithAuth<Acc> | BaseContextParams,\n): Promise<JazzContext<Acc>>;\nexport async function createJazzContext<Acc extends Account>(\n options: ContextParamsWithAuth<Acc> | BaseContextParams,\n): Promise<JazzContext<Acc>> {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (!(\"auth\" in options)) {\n return createAnonymousJazzContext({\n peersToLoadFrom: options.peersToLoadFrom,\n crypto: options.crypto,\n });\n }\n\n const { auth, sessionProvider, peersToLoadFrom, crypto } = options;\n const AccountSchema =\n options.AccountSchema ??\n (RegisteredSchemas[\"Account\"] as unknown as AccountClass<Acc>);\n let authResult: AuthResult;\n try {\n authResult = await auth.start(crypto);\n } catch (e) {\n console.error(\"error\", e);\n throw e;\n }\n\n if (authResult.type === \"existing\") {\n try {\n const { sessionID, sessionDone } = await sessionProvider(\n authResult.credentials.accountID,\n crypto,\n );\n\n try {\n const node = await LocalNode.withLoadedAccount({\n accountID: authResult.credentials\n .accountID as unknown as CoID<RawAccount>,\n accountSecret: authResult.credentials.secret,\n sessionID: sessionID,\n peersToLoadFrom: peersToLoadFrom,\n crypto: crypto,\n migration: async (rawAccount, _node, creationProps) => {\n const account = new AccountSchema({\n fromRaw: rawAccount,\n }) as Acc;\n\n await account.applyMigration(creationProps);\n },\n });\n\n const account = AccountSchema.fromNode(node);\n\n if (authResult.saveCredentials) {\n await authResult.saveCredentials({\n accountID: node.account.id as unknown as ID<Account>,\n secret: node.account.agentSecret,\n });\n }\n\n authResult.onSuccess();\n\n return {\n account,\n done: () => {\n node.gracefulShutdown();\n sessionDone();\n },\n logOut: () => {\n node.gracefulShutdown();\n sessionDone();\n authResult.logOut();\n },\n };\n } catch (e) {\n authResult.onError(new Error(\"Error loading account\", { cause: e }));\n sessionDone();\n }\n } catch (e) {\n authResult.onError(\n new Error(\"Error acquiring sessionID\", { cause: e }),\n );\n }\n } else if (authResult.type === \"new\") {\n try {\n // TODO: figure out a way to not \"waste\" the first SessionID\n const { node } = await LocalNode.withNewlyCreatedAccount({\n creationProps: authResult.creationProps,\n peersToLoadFrom: peersToLoadFrom,\n crypto: crypto,\n initialAgentSecret: authResult.initialSecret,\n migration: async (rawAccount, _node, creationProps) => {\n const account = new AccountSchema({\n fromRaw: rawAccount,\n }) as Acc;\n\n await account.applyMigration(creationProps);\n },\n });\n\n const account = AccountSchema.fromNode(node);\n\n await authResult.saveCredentials({\n accountID: node.account.id as unknown as ID<Account>,\n secret: node.account.agentSecret,\n });\n\n authResult.onSuccess();\n return {\n account,\n done: () => {\n node.gracefulShutdown();\n },\n logOut: () => {\n node.gracefulShutdown();\n authResult.logOut();\n },\n };\n } catch (e) {\n authResult.onError(new Error(\"Error creating account\", { cause: e }));\n }\n }\n }\n}\n\nexport async function createAnonymousJazzContext({\n peersToLoadFrom,\n crypto,\n}: {\n peersToLoadFrom: Peer[];\n crypto: CryptoProvider;\n}): Promise<JazzContextWithAgent> {\n const agentSecret = crypto.newRandomAgentSecret();\n const rawAgent = new ControlledAgent(agentSecret, crypto);\n\n const node = new LocalNode(\n rawAgent,\n crypto.newRandomSessionID(rawAgent.id),\n crypto,\n );\n\n for (const peer of peersToLoadFrom) {\n node.syncManager.addPeer(peer);\n }\n\n return {\n agent: new AnonymousJazzAgent(node),\n done: () => {},\n logOut: () => {},\n };\n}\n","import type { Account } from \"./account.js\";\nimport type { CoMap } from \"./coMap.js\";\nimport type { Group } from \"./group.js\";\n\n/**\n * Regisering schemas into this Record to avoid circular dependencies.\n */\nexport const RegisteredSchemas = {} as {\n Account: typeof Account;\n Group: typeof Group;\n CoMap: typeof CoMap;\n};\n","/* istanbul ignore file -- @preserve */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ItemsSym } from \"./symbols.js\";\n\n(globalThis as any).devtoolsFormatters = [\n {\n header: (object: any) => {\n if (object._type === \"CoMap\") {\n return [\"div\", {}, [\"span\", {}, object.constructor.name]];\n } else if (object._type === \"CoList\") {\n return [\n \"div\",\n {},\n [\"span\", {}, object.constructor.name + \"(\" + object.length + \") \"],\n ];\n } else if (object._type === \"Account\") {\n return [\n \"div\",\n {},\n [\n \"span\",\n {},\n object.constructor.name +\n \"(\" +\n object._refs.profile.value?.name +\n (object.isMe ? \" ME\" : \"\") +\n \")\",\n ],\n ];\n } else {\n return null;\n }\n },\n hasBody: function () {\n return true;\n },\n body: function (object: any) {\n if (object._type === \"CoMap\" || object._type === \"Account\") {\n return [\n \"div\",\n { style: \"margin-left: 15px\" },\n [\"div\", \"id: \", [\"object\", { object: object.id }]],\n ...Object.entries(object).map(([k, v]) => [\n \"div\",\n { style: \"white-space: nowrap;\" },\n [\"span\", { style: \"font-weight: bold; opacity: 0.6\" }, k, \": \"],\n [\"object\", { object: v }],\n ...(typeof object._schema[k] === \"function\"\n ? v === null\n ? [\n [\n \"span\",\n { style: \"opacity: 0.5\" },\n ` (pending ${object._schema[k].name} `,\n [\"object\", { object: object._refs[k] }],\n \")\",\n ],\n ]\n : []\n : []),\n ]),\n ];\n } else if (object._type === \"CoList\") {\n return [\n \"div\",\n { style: \"margin-left: 15px\" },\n [\"div\", \"id: \", [\"object\", { object: object.id }]],\n ...(object as any[]).map((v, i) => [\n \"div\",\n { style: \"white-space: nowrap;\" },\n [\"span\", { style: \"font-weight: bold; opacity: 0.6\" }, i, \": \"],\n [\"object\", { object: v }],\n ...(typeof object._schema[ItemsSym] === \"function\"\n ? v === null\n ? [\n [\n \"span\",\n { style: \"opacity: 0.5\" },\n ` (pending ${object._schema[ItemsSym].name} `,\n [\"object\", { object: object._refs[i] }],\n \")\",\n ],\n ]\n : []\n : []),\n ]),\n ];\n }\n },\n },\n];\n","import {\n CoID,\n InviteSecret,\n RawAccount,\n RawCoMap,\n RawControlledAccount,\n SessionID,\n} from \"cojson\";\nimport { CoStreamItem, RawCoStream } from \"cojson\";\nimport { type Account } from \"./account.js\";\nimport { CoValue, CoValueClass, ID, loadCoValue } from \"./interfaces.js\";\n\nexport type InboxInvite = `${CoID<MessagesStream>}/${InviteSecret}`;\ntype TxKey = `${SessionID}/${number}`;\n\ntype MessagesStream = RawCoStream<CoID<InboxMessage<CoValue, any>>>;\ntype FailedMessagesStream = RawCoStream<{\n errors: string[];\n value: CoID<InboxMessage<CoValue, any>>;\n}>;\ntype TxKeyStream = RawCoStream<TxKey>;\nexport type InboxRoot = RawCoMap<{\n messages: CoID<MessagesStream>;\n processed: CoID<TxKeyStream>;\n failed: CoID<FailedMessagesStream>;\n inviteLink: InboxInvite;\n}>;\n\nexport function createInboxRoot(account: Account) {\n if (!account.isMe) {\n throw new Error(\"Account is not controlled\");\n }\n\n const rawAccount = account._raw as RawControlledAccount;\n\n const group = rawAccount.createGroup();\n const messagesFeed = group.createStream<MessagesStream>();\n\n const inboxRoot = rawAccount.createMap<InboxRoot>();\n const processedFeed = rawAccount.createStream<TxKeyStream>();\n const failedFeed = rawAccount.createStream<FailedMessagesStream>();\n\n const inviteLink =\n `${messagesFeed.id}/${group.createInvite(\"writeOnly\")}` as const;\n\n inboxRoot.set(\"messages\", messagesFeed.id);\n inboxRoot.set(\"processed\", processedFeed.id);\n inboxRoot.set(\"failed\", failedFeed.id);\n\n return {\n id: inboxRoot.id,\n inviteLink,\n };\n}\n\ntype InboxMessage<I extends CoValue, O extends CoValue | undefined> = RawCoMap<{\n payload: ID<I>;\n result: ID<O> | undefined;\n processed: boolean;\n error: string | undefined;\n}>;\n\nfunction createInboxMessage<I extends CoValue, O extends CoValue | undefined>(\n payload: I,\n inboxOwner: RawAccount,\n) {\n const group = payload._raw.group;\n\n if (group instanceof RawAccount) {\n throw new Error(\"Inbox messages should be owned by a group\");\n }\n\n group.addMember(inboxOwner, \"writer\");\n\n const message = group.createMap<InboxMessage<I, O>>({\n payload: payload.id,\n result: undefined,\n processed: false,\n error: undefined,\n });\n\n return message;\n}\n\nexport class Inbox {\n account: Account;\n messages: MessagesStream;\n processed: TxKeyStream;\n failed: FailedMessagesStream;\n root: InboxRoot;\n processing = new Set<`${SessionID}/${number}`>();\n\n private constructor(\n account: Account,\n root: InboxRoot,\n messages: MessagesStream,\n processed: TxKeyStream,\n failed: FailedMessagesStream,\n ) {\n this.account = account;\n this.root = root;\n this.messages = messages;\n this.processed = processed;\n this.failed = failed;\n }\n\n subscribe<I extends CoValue, O extends CoValue | undefined>(\n Schema: CoValueClass<I>,\n callback: (\n message: I,\n senderAccountID: ID<Account>,\n ) => Promise<O | undefined | void>,\n options: { retries?: number } = {},\n ) {\n const processed = new Set<`${SessionID}/${number}`>();\n const failed = new Map<`${SessionID}/${number}`, string[]>();\n const node = this.account._raw.core.node;\n\n this.processed.subscribe((stream) => {\n for (const items of Object.values(stream.items)) {\n for (const item of items) {\n processed.add(item.value as TxKey);\n }\n }\n });\n\n const { account } = this;\n const { retries = 3 } = options;\n\n let failTimer: ReturnType<typeof setTimeout> | number | undefined =\n undefined;\n\n const clearFailTimer = () => {\n clearTimeout(failTimer);\n failTimer = undefined;\n };\n\n const handleNewMessages = (stream: MessagesStream) => {\n clearFailTimer(); // Stop the failure timers, we're going to process the failed entries anyway\n\n for (const [sessionID, items] of Object.entries(stream.items) as [\n SessionID,\n CoStreamItem<CoID<InboxMessage<I, O>>>[],\n ][]) {\n const accountID = getAccountIDfromSessionID(sessionID);\n\n if (!accountID) {\n console.warn(\"Received message from unknown account\", sessionID);\n continue;\n }\n\n for (const item of items) {\n const txKey = `${sessionID}/${item.tx.txIndex}` as const;\n\n if (!processed.has(txKey) && !this.processing.has(txKey)) {\n this.processing.add(txKey);\n\n const id = item.value;\n\n node\n .load(id)\n .then((message) => {\n if (message === \"unavailable\") {\n return Promise.reject(\n new Error(\"Unable to load inbox message \" + id),\n );\n }\n\n return loadCoValue(\n Schema,\n message.get(\"payload\") as ID<I>,\n account,\n [],\n );\n })\n .then((value) => {\n if (!value) {\n return Promise.reject(\n new Error(\"Unable to load inbox message \" + id),\n );\n }\n\n return callback(value, accountID);\n })\n .then((result) => {\n const inboxMessage = node\n .expectCoValueLoaded(item.value)\n .getCurrentContent() as RawCoMap;\n\n if (result) {\n inboxMessage.set(\"result\", result.id);\n }\n\n inboxMessage.set(\"processed\", true);\n\n this.processed.push(txKey);\n this.processing.delete(txKey);\n })\n .catch((error) => {\n console.error(\"Error processing inbox message\", error);\n this.processing.delete(txKey);\n const errors = failed.get(txKey) ?? [];\n\n const stringifiedError = String(error);\n errors.push(stringifiedError);\n\n const inboxMessage = node\n .expectCoValueLoaded(item.value)\n .getCurrentContent() as RawCoMap;\n\n inboxMessage.set(\"error\", stringifiedError);\n\n if (errors.length > retries) {\n inboxMessage.set(\"processed\", true);\n this.processed.push(txKey);\n this.failed.push({ errors, value: item.value });\n } else {\n failed.set(txKey, errors);\n if (!failTimer) {\n failTimer = setTimeout(\n () => handleNewMessages(stream),\n 100,\n );\n }\n }\n });\n }\n }\n }\n };\n\n return this.messages.subscribe(handleNewMessages);\n }\n\n static async load(account: Account) {\n const profile = account.profile;\n\n if (!profile) {\n throw new Error(\"Account profile should already be loaded\");\n }\n\n if (!profile.inbox) {\n throw new Error(\"The account has not set up their inbox\");\n }\n\n const node = account._raw.core.node;\n\n const root = await node.load(profile.inbox as CoID<InboxRoot>);\n\n if (root === \"unavailable\") {\n throw new Error(\"Inbox not found\");\n }\n\n const [messages, processed, failed] = await Promise.all([\n node.load(root.get(\"messages\")!),\n node.load(root.get(\"processed\")!),\n node.load(root.get(\"failed\")!),\n ]);\n\n if (\n messages === \"unavailable\" ||\n processed === \"unavailable\" ||\n failed === \"unavailable\"\n ) {\n throw new Error(\"Inbox not found\");\n }\n\n return new Inbox(account, root, messages, processed, failed);\n }\n}\n\nexport class InboxSender<I extends CoValue, O extends CoValue | undefined> {\n currentAccount: Account;\n owner: RawAccount;\n messages: MessagesStream;\n\n private constructor(\n currentAccount: Account,\n owner: RawAccount,\n messages: MessagesStream,\n ) {\n this.currentAccount = currentAccount;\n this.owner = owner;\n this.messages = messages;\n }\n\n getOwnerAccount() {\n return this.owner;\n }\n\n sendMessage(message: I): Promise<O extends CoValue ? ID<O> : undefined> {\n const inboxMessage = createInboxMessage<I, O>(message, this.owner);\n\n this.messages.push(inboxMessage.id);\n\n return new Promise((resolve, reject) => {\n inboxMessage.subscribe((message) => {\n if (message.get(\"processed\")) {\n const error = message.get(\"error\");\n if (error) {\n reject(new Error(error));\n } else {\n resolve(\n message.get(\"result\") as O extends CoValue ? ID<O> : undefined,\n );\n }\n }\n });\n });\n }\n\n static async load<\n I extends CoValue,\n O extends CoValue | undefined = undefined,\n >(inboxOwnerID: ID<Account>, currentAccount: Account) {\n const node = currentAccount._raw.core.node;\n\n const inboxOwnerRaw = await node.load(\n inboxOwnerID as unknown as CoID<RawAccount>,\n );\n\n if (inboxOwnerRaw === \"unavailable\") {\n throw new Error(\"Failed to load the inbox owner\");\n }\n\n const inboxOwnerProfileRaw = await node.load(inboxOwnerRaw.get(\"profile\")!);\n\n if (inboxOwnerProfileRaw === \"unavailable\") {\n throw new Error(\"Failed to load the inbox owner profile\");\n }\n\n const inboxInvite = inboxOwnerProfileRaw.get(\"inboxInvite\");\n\n if (!inboxInvite) {\n throw new Error(\"The user has not set up their inbox\");\n }\n\n const id = await acceptInvite(inboxInvite as InboxInvite, currentAccount);\n\n const messages = await node.load(id);\n\n if (messages === \"unavailable\") {\n throw new Error(\"Inbox not found\");\n }\n\n return new InboxSender<I, O>(currentAccount, inboxOwnerRaw, messages);\n }\n}\n\nasync function acceptInvite(invite: string, account: Account) {\n const id = invite.slice(0, invite.indexOf(\"/\")) as CoID<MessagesStream>;\n\n const inviteSecret = invite.slice(invite.indexOf(\"/\") + 1) as InviteSecret;\n\n if (!id?.startsWith(\"co_z\") || !inviteSecret.startsWith(\"inviteSecret_\")) {\n throw new Error(\"Invalid inbox ticket\");\n }\n\n if (!account.isMe) {\n throw new Error(\"Account is not controlled\");\n }\n\n await (account._raw as RawControlledAccount).acceptInvite(id, inviteSecret);\n\n return id;\n}\n\nfunction getAccountIDfromSessionID(sessionID: SessionID) {\n const until = sessionID.indexOf(\"_session\");\n const accountID = sessionID.slice(0, until);\n\n if (accountID.startsWith(\"co_z\")) {\n return accountID as ID<Account>;\n }\n\n return;\n}\n","import {\n AgentID,\n type CoValueUniqueness,\n CojsonInternalTypes,\n type JsonValue,\n RawAccountID,\n type RawCoMap,\n cojsonInternals,\n} from \"cojson\";\nimport type {\n AnonymousJazzAgent,\n CoValue,\n CoValueClass,\n DeeplyLoaded,\n DepthsIn,\n ID,\n IfCo,\n RefEncoded,\n RefIfCoValue,\n Schema,\n co,\n} from \"../internal.js\";\nimport {\n CoValueBase,\n ItemsSym,\n Ref,\n SchemaInit,\n ensureCoValueLoaded,\n inspect,\n isRefEncoded,\n loadCoValue,\n makeRefs,\n subscribeToCoValue,\n subscribeToExistingCoValue,\n subscriptionsScopes,\n} from \"../internal.js\";\nimport { type Account } from \"./account.js\";\nimport { type Group } from \"./group.js\";\nimport { RegisteredSchemas } from \"./registeredSchemas.js\";\n\ntype CoMapEdit<V> = {\n value?: V;\n ref?: RefIfCoValue<V>;\n by?: Account;\n madeAt: Date;\n};\n\ntype LastAndAllCoMapEdits<V> = CoMapEdit<V> & { all: CoMapEdit<V>[] };\n\nexport type Simplify<A> = {\n [K in keyof A]: A[K];\n} extends infer B\n ? B\n : never;\n\n/**\n * CoMaps are collaborative versions of plain objects, mapping string-like keys to values.\n *\n * @categoryDescription Declaration\n * Declare your own CoMap schemas by subclassing `CoMap` and assigning field schemas with `co`.\n *\n * Optional `co.ref(...)` fields must be marked with `{ optional: true }`.\n *\n * ```ts\n * import { co, CoMap } from \"jazz-tools\";\n *\n * class Person extends CoMap {\n * name = co.string;\n * age = co.number;\n * pet = co.ref(Animal);\n * car = co.ref(Car, { optional: true });\n * }\n * ```\n *\n * @categoryDescription Content\n * You can access properties you declare on a `CoMap` (using `co`) as if they were normal properties on a plain object, using dot notation, `Object.keys()`, etc.\n *\n * ```ts\n * person.name;\n * person[\"age\"];\n * person.age = 42;\n * person.pet?.name;\n * Object.keys(person);\n * // => [\"name\", \"age\", \"pet\"]\n * ```\n *\n * @category CoValues\n * */\nexport class CoMap extends CoValueBase implements CoValue {\n /**\n * The ID of this `CoMap`\n * @category Content */\n declare id: ID<this>;\n /** @category Type Helpers */\n declare _type: \"CoMap\";\n static {\n this.prototype._type = \"CoMap\";\n }\n /** @category Internals */\n declare _raw: RawCoMap;\n\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static _schema: any;\n /** @internal */\n get _schema() {\n return (this.constructor as typeof CoMap)._schema as {\n [key: string]: Schema;\n } & { [ItemsSym]?: Schema };\n }\n\n /**\n * If property `prop` is a `co.ref(...)`, you can use `coMaps._refs.prop` to access\n * the `Ref` instead of the potentially loaded/null value.\n *\n * This allows you to always get the ID or load the value manually.\n *\n * @example\n * ```ts\n * person._refs.pet.id; // => ID<Animal>\n * person._refs.pet.value;\n * // => Animal | null\n * const pet = await person._refs.pet.load();\n * ```\n *\n * @category Content\n **/\n get _refs(): {\n [Key in CoKeys<this>]: IfCo<this[Key], RefIfCoValue<this[Key]>>;\n } {\n return makeRefs<CoKeys<this>>(\n (key) => this._raw.get(key as string) as unknown as ID<CoValue>,\n () => {\n const keys = this._raw.keys().filter((key) => {\n const schema =\n this._schema[key as keyof typeof this._schema] ||\n (this._schema[ItemsSym] as Schema | undefined);\n return schema && schema !== \"json\" && isRefEncoded(schema);\n }) as CoKeys<this>[];\n\n return keys;\n },\n this._loadedAs,\n (key) =>\n (this._schema[key] || this._schema[ItemsSym]) as RefEncoded<CoValue>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n }\n\n /** @internal */\n private getEditFromRaw(\n target: CoMap,\n rawEdit: {\n by: RawAccountID | AgentID;\n tx: CojsonInternalTypes.TransactionID;\n at: Date;\n value?: JsonValue | undefined;\n },\n descriptor: Schema,\n key: string,\n ) {\n return {\n value:\n descriptor === \"json\"\n ? rawEdit.value\n : \"encoded\" in descriptor\n ? rawEdit.value === null || rawEdit.value === undefined\n ? rawEdit.value\n : descriptor.encoded.decode(rawEdit.value)\n : new Ref(\n rawEdit.value as ID<CoValue>,\n target._loadedAs,\n descriptor,\n ).accessFrom(target, \"_edits.\" + key + \".value\"),\n ref:\n descriptor !== \"json\" && isRefEncoded(descriptor)\n ? new Ref(rawEdit.value as ID<CoValue>, target._loadedAs, descriptor)\n : undefined,\n by:\n rawEdit.by &&\n new Ref<Account>(rawEdit.by as ID<Account>, target._loadedAs, {\n ref: RegisteredSchemas[\"Account\"],\n optional: false,\n }).accessFrom(target, \"_edits.\" + key + \".by\"),\n madeAt: rawEdit.at,\n };\n }\n\n /** @category Collaboration */\n get _edits() {\n const map = this;\n return new Proxy(\n {},\n {\n get(_target, key) {\n const rawEdit = map._raw.lastEditAt(key as string);\n if (!rawEdit) return undefined;\n\n const descriptor = map._schema[\n key as keyof typeof map._schema\n ] as Schema;\n\n return {\n ...map.getEditFromRaw(map, rawEdit, descriptor, key as string),\n get all() {\n return [...map._raw.editsAt(key as string)].map((rawEdit) =>\n map.getEditFromRaw(map, rawEdit, descriptor, key as string),\n );\n },\n };\n },\n ownKeys(_target) {\n return map._raw.keys();\n },\n getOwnPropertyDescriptor(target, key) {\n return {\n value: Reflect.get(target, key),\n writable: false,\n enumerable: true,\n configurable: true,\n };\n },\n },\n ) as {\n [Key in CoKeys<this>]: IfCo<this[Key], LastAndAllCoMapEdits<this[Key]>>;\n };\n }\n\n /** @internal */\n constructor(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: { fromRaw: RawCoMap } | undefined,\n ) {\n super();\n\n if (options) {\n if (\"fromRaw\" in options) {\n Object.defineProperties(this, {\n id: {\n value: options.fromRaw.id as unknown as ID<this>,\n enumerable: false,\n },\n _raw: { value: options.fromRaw, enumerable: false },\n });\n } else {\n throw new Error(\"Invalid CoMap constructor arguments\");\n }\n }\n\n return new Proxy(this, CoMapProxyHandler as ProxyHandler<this>);\n }\n\n /**\n * Create a new CoMap with the given initial values and owner.\n *\n * The owner (a Group or Account) determines access rights to the CoMap.\n *\n * The CoMap will immediately be persisted and synced to connected peers.\n *\n * @example\n * ```ts\n * const person = Person.create({\n * name: \"Alice\",\n * age: 42,\n * pet: cat,\n * }, { owner: friendGroup });\n * ```\n *\n * @category Creation\n **/\n static create<M extends CoMap>(\n this: CoValueClass<M>,\n init: Simplify<CoMapInit<M>>,\n options: {\n owner: Account | Group;\n unique?: CoValueUniqueness[\"uniqueness\"];\n },\n ) {\n const instance = new this();\n const raw = instance.rawFromInit(\n init,\n options.owner,\n options.unique === undefined ? undefined : { uniqueness: options.unique },\n );\n Object.defineProperties(instance, {\n id: {\n value: raw.id,\n enumerable: false,\n },\n _raw: { value: raw, enumerable: false },\n });\n return instance;\n }\n\n /**\n * Return a JSON representation of the `CoMap`\n * @category Content\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(_key?: string, seenAbove?: ID<CoValue>[]): any[] {\n const jsonedFields = this._raw.keys().map((key) => {\n const tKey = key as CoKeys<this>;\n const descriptor = (this._schema[tKey] ||\n this._schema[ItemsSym]) as Schema;\n\n if (descriptor == \"json\" || \"encode\" in descriptor) {\n return [key, this._raw.get(key)];\n } else if (isRefEncoded(descriptor)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (seenAbove?.includes((this as any)[tKey]?.id)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return [key, { _circular: (this as any)[tKey]?.id }];\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const jsonedRef = (this as any)[tKey]?.toJSON(tKey, [\n ...(seenAbove || []),\n this.id,\n ]);\n return [key, jsonedRef];\n } else {\n return [key, undefined];\n }\n });\n\n return {\n id: this.id,\n _type: this._type,\n ...Object.fromEntries(jsonedFields),\n };\n }\n\n [inspect]() {\n return this.toJSON();\n }\n\n /**\n * Create a new `RawCoMap` from an initialization object\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rawFromInit<Fields extends object = Record<string, any>>(\n init: Simplify<CoMapInit<Fields>> | undefined,\n owner: Account | Group,\n uniqueness?: CoValueUniqueness,\n ) {\n const rawOwner = owner._raw;\n\n const rawInit = {} as {\n [key in keyof Fields]: JsonValue | undefined;\n };\n\n if (init)\n for (const key of Object.keys(init) as (keyof Fields)[]) {\n const initValue = init[key as keyof typeof init];\n\n const descriptor = (this._schema[key as keyof typeof this._schema] ||\n this._schema[ItemsSym]) as Schema;\n\n if (!descriptor) {\n continue;\n }\n\n if (descriptor === \"json\") {\n rawInit[key] = initValue as JsonValue;\n } else if (isRefEncoded(descriptor)) {\n if (initValue) {\n rawInit[key] = (initValue as unknown as CoValue).id;\n }\n } else if (\"encoded\" in descriptor) {\n rawInit[key] = descriptor.encoded.encode(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n initValue as any,\n );\n }\n }\n\n return rawOwner.createMap(rawInit, null, \"private\", uniqueness);\n }\n\n /**\n * Declare a Record-like CoMap schema, by extending `CoMap.Record(...)` and passing the value schema using `co`. Keys are always `string`.\n *\n * @example\n * ```ts\n * import { co, CoMap } from \"jazz-tools\";\n *\n * class ColorToFruitMap extends CoMap.Record(\n * co.ref(Fruit)\n * ) {}\n *\n * // assume we have map: ColorToFruitMap\n * // and strawberry: Fruit\n * map[\"red\"] = strawberry;\n * ```\n *\n * @category Declaration\n */\n static Record<Value>(value: IfCo<Value, Value>) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\n class RecordLikeCoMap extends CoMap {\n [ItemsSym] = value;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\n interface RecordLikeCoMap extends Record<string, Value> {}\n\n return RecordLikeCoMap;\n }\n\n /**\n * Load a `CoMap` with a given ID, as a given account.\n *\n * `depth` specifies which (if any) fields that reference other CoValues to load as well before resolving.\n * The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.\n *\n * You can pass `[]` or `{}` for shallowly loading only this CoMap, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.\n *\n * Check out the `load` methods on `CoMap`/`CoList`/`CoFeed`/`Group`/`Account` to see which depth structures are valid to nest.\n *\n * @example\n * ```ts\n * const person = await Person.load(\n * \"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax\",\n * me,\n * { pet: {} }\n * );\n * ```\n *\n * @category Subscription & Loading\n */\n static load<M extends CoMap, Depth>(\n this: CoValueClass<M>,\n id: ID<M>,\n as: Account,\n depth: Depth & DepthsIn<M>,\n ): Promise<DeeplyLoaded<M, Depth> | undefined> {\n return loadCoValue(this, id, as, depth);\n }\n\n /**\n * Load and subscribe to a `CoMap` with a given ID, as a given account.\n *\n * Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.\n *\n * `depth` specifies which (if any) fields that reference other CoValues to load as well before calling `listener` for the first time.\n * The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.\n *\n * You can pass `[]` or `{}` for shallowly loading only this CoMap, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.\n *\n * Check out the `load` methods on `CoMap`/`CoList`/`CoFeed`/`Group`/`Account` to see which depth structures are valid to nest.\n *\n * Returns an unsubscribe function that you should call when you no longer need updates.\n *\n * Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.\n *\n * @example\n * ```ts\n * const unsub = Person.subscribe(\n * \"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax\",\n * me,\n * { pet: {} },\n * (person) => console.log(person)\n * );\n * ```\n *\n * @category Subscription & Loading\n */\n static subscribe<M extends CoMap, Depth>(\n this: CoValueClass<M>,\n id: ID<M>,\n as: Account,\n depth: Depth & DepthsIn<M>,\n listener: (value: DeeplyLoaded<M, Depth>) => void,\n ): () => void {\n return subscribeToCoValue<M, Depth>(this, id, as, depth, listener);\n }\n\n static findUnique<M extends CoMap>(\n this: CoValueClass<M>,\n unique: CoValueUniqueness[\"uniqueness\"],\n ownerID: ID<Account> | ID<Group>,\n as: Account | Group | AnonymousJazzAgent,\n ) {\n const header = {\n type: \"comap\" as const,\n ruleset: {\n type: \"ownedByGroup\" as const,\n group: ownerID,\n },\n meta: null,\n uniqueness: unique,\n };\n const crypto =\n as._type === \"Anonymous\" ? as.node.crypto : as._raw.core.crypto;\n return cojsonInternals.idforHeader(header, crypto) as ID<M>;\n }\n\n /**\n * Given an already loaded `CoMap`, ensure that the specified fields are loaded to the specified depth.\n *\n * Works like `CoMap.load()`, but you don't need to pass the ID or the account to load as again.\n *\n * @category Subscription & Loading\n */\n ensureLoaded<M extends CoMap, Depth>(\n this: M,\n depth: Depth & DepthsIn<M>,\n ): Promise<DeeplyLoaded<M, Depth> | undefined> {\n return ensureCoValueLoaded(this, depth);\n }\n\n /**\n * Given an already loaded `CoMap`, subscribe to updates to the `CoMap` and ensure that the specified fields are loaded to the specified depth.\n *\n * Works like `CoMap.subscribe()`, but you don't need to pass the ID or the account to load as again.\n *\n * Returns an unsubscribe function that you should call when you no longer need updates.\n *\n * @category Subscription & Loading\n **/\n subscribe<M extends CoMap, Depth>(\n this: M,\n depth: Depth & DepthsIn<M>,\n listener: (value: DeeplyLoaded<M, Depth>) => void,\n ): () => void {\n return subscribeToExistingCoValue(this, depth, listener);\n }\n\n applyDiff<N extends Partial<CoMapInit<this>>>(newValues: N) {\n for (const key in newValues) {\n if (Object.prototype.hasOwnProperty.call(newValues, key)) {\n const tKey = key as keyof typeof newValues & keyof this;\n const descriptor = (this._schema[tKey as string] ||\n this._schema[ItemsSym]) as Schema;\n\n if (tKey in this._schema) {\n const newValue = newValues[tKey];\n const currentValue = (this as unknown as N)[tKey];\n\n if (descriptor === \"json\" || \"encoded\" in descriptor) {\n if (currentValue !== newValue) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any)[tKey] = newValue;\n }\n } else if (isRefEncoded(descriptor)) {\n const currentId = (currentValue as CoValue | undefined)?.id;\n const newId = (newValue as CoValue | undefined)?.id;\n if (currentId !== newId) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any)[tKey] = newValue;\n }\n }\n }\n }\n }\n return this;\n }\n\n /**\n * Wait for the `CoMap` to be uploaded to the other peers.\n *\n * @category Subscription & Loading\n */\n waitForSync(options?: { timeout?: number }) {\n return this._raw.core.waitForSync(options);\n }\n}\n\nexport type CoKeys<Map extends object> = Exclude<\n keyof Map & string,\n keyof CoMap\n>;\n\n/**\n * Force required ref fields to be non nullable\n *\n * Considering that:\n * - Optional refs are typed as co<InstanceType<CoValueClass> | null | undefined>\n * - Required refs are typed as co<InstanceType<CoValueClass> | null>\n *\n * This type works in two steps:\n * - Remove the null from both types\n * - Then we check if the input type accepts undefined, if positive we put the null union back\n *\n * So the optional refs stays unchanged while we safely remove the null union\n * from required refs\n *\n * This way required refs can be marked as required in the CoMapInit while\n * staying a nullable property for value access.\n *\n * Example:\n *\n * const map = MyCoMap.create({\n * requiredRef: NestedMap.create({}) // null is not valid here\n * })\n *\n * map.requiredRef // this value is still nullable\n */\ntype ForceRequiredRef<V> = V extends co<InstanceType<CoValueClass> | null>\n ? NonNullable<V>\n : V extends co<InstanceType<CoValueClass> | undefined>\n ? V | null\n : V;\n\nexport type CoMapInit<Map extends object> = {\n [Key in CoKeys<Map> as undefined extends Map[Key]\n ? never\n : IfCo<Map[Key], Key>]: ForceRequiredRef<Map[Key]>;\n} & {\n [Key in CoKeys<Map> as IfCo<Map[Key], Key>]?: ForceRequiredRef<Map[Key]>;\n};\n\n// TODO: cache handlers per descriptor for performance?\nconst CoMapProxyHandler: ProxyHandler<CoMap> = {\n get(target, key, receiver) {\n if (key === \"_schema\") {\n return Reflect.get(target, key);\n } else if (key in target) {\n return Reflect.get(target, key, receiver);\n } else {\n const schema = target._schema;\n\n if (!schema) {\n return undefined;\n }\n\n const descriptor = (schema[key as keyof CoMap[\"_schema\"]] ||\n schema[ItemsSym]) as Schema;\n if (descriptor && typeof key === \"string\") {\n const raw = target._raw.get(key);\n\n if (descriptor === \"json\") {\n return raw;\n } else if (\"encoded\" in descriptor) {\n return raw === undefined ? undefined : descriptor.encoded.decode(raw);\n } else if (isRefEncoded(descriptor)) {\n return raw === undefined\n ? undefined\n : new Ref(\n raw as unknown as ID<CoValue>,\n target._loadedAs,\n descriptor,\n ).accessFrom(receiver, key);\n }\n } else {\n return undefined;\n }\n }\n },\n set(target, key, value, receiver) {\n if (\n (typeof key === \"string\" || ItemsSym) &&\n typeof value === \"object\" &&\n value !== null &&\n SchemaInit in value\n ) {\n (target.constructor as typeof CoMap)._schema ||= {};\n (target.constructor as typeof CoMap)._schema[key] = value[SchemaInit];\n return true;\n }\n\n const descriptor = (target._schema[key as keyof CoMap[\"_schema\"]] ||\n target._schema[ItemsSym]) as Schema;\n if (descriptor && typeof key === \"string\") {\n if (descriptor === \"json\") {\n target._raw.set(key, value);\n } else if (\"encoded\" in descriptor) {\n target._raw.set(key, descriptor.encoded.encode(value));\n } else if (isRefEncoded(descriptor)) {\n if (value === null) {\n if (descriptor.optional) {\n target._raw.set(key, null);\n } else {\n throw new Error(`Cannot set required reference ${key} to null`);\n }\n } else {\n target._raw.set(key, value.id);\n subscriptionsScopes\n .get(target)\n ?.onRefAccessedOrSet(target.id, value.id);\n }\n }\n return true;\n } else {\n return Reflect.set(target, key, value, receiver);\n }\n },\n defineProperty(target, key, attributes) {\n if (\n \"value\" in attributes &&\n typeof attributes.value === \"object\" &&\n SchemaInit in attributes.value\n ) {\n (target.constructor as typeof CoMap)._schema ||= {};\n (target.constructor as typeof CoMap)._schema[key as string] =\n attributes.value[SchemaInit];\n return true;\n } else {\n return Reflect.defineProperty(target, key, attributes);\n }\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target).filter((k) => k !== ItemsSym);\n // for (const key of Reflect.ownKeys(target._schema)) {\n // if (key !== ItemsSym && !keys.includes(key)) {\n // keys.push(key);\n // }\n // }\n for (const key of target._raw.keys()) {\n if (!keys.includes(key)) {\n keys.push(key);\n }\n }\n\n return keys;\n },\n getOwnPropertyDescriptor(target, key) {\n if (key in target) {\n return Reflect.getOwnPropertyDescriptor(target, key);\n } else {\n const descriptor = (target._schema[key as keyof CoMap[\"_schema\"]] ||\n target._schema[ItemsSym]) as Schema;\n if (descriptor || key in target._raw.latest) {\n return {\n enumerable: true,\n configurable: true,\n writable: true,\n };\n }\n }\n },\n has(target, key) {\n const descriptor = (target._schema?.[key as keyof CoMap[\"_schema\"]] ||\n target._schema?.[ItemsSym]) as Schema;\n\n if (target._raw && typeof key === \"string\" && descriptor) {\n return target._raw.get(key) !== undefined;\n } else {\n return Reflect.has(target, key);\n }\n },\n deleteProperty(target, key) {\n const descriptor = (target._schema[key as keyof CoMap[\"_schema\"]] ||\n target._schema[ItemsSym]) as Schema;\n if (typeof key === \"string\" && descriptor) {\n target._raw.delete(key);\n return true;\n } else {\n return Reflect.deleteProperty(target, key);\n }\n },\n};\n\nRegisteredSchemas[\"CoMap\"] = CoMap;\n","import { CoID } from \"cojson\";\nimport { co } from \"../internal.js\";\nimport { CoMap } from \"./coMap.js\";\nimport { InboxInvite, InboxRoot } from \"./inbox.js\";\n\n/** @category Identity & Permissions */\nexport class Profile extends CoMap {\n name = co.string;\n inbox = co.optional.json<CoID<InboxRoot>>();\n inboxInvite = co.optional.json<InboxInvite>();\n}\n","import {\n AgentSecret,\n CoID,\n CryptoProvider,\n InviteSecret,\n LocalNode,\n Peer,\n RawAccount,\n RawCoMap,\n RawCoValue,\n RawControlledAccount,\n SessionID,\n cojsonInternals,\n} from \"cojson\";\nimport {\n AnonymousJazzAgent,\n type CoValue,\n CoValueBase,\n CoValueClass,\n DeeplyLoaded,\n DepthsIn,\n ID,\n MembersSym,\n Ref,\n type RefEncoded,\n RefIfCoValue,\n type Schema,\n SchemaInit,\n ensureCoValueLoaded,\n inspect,\n loadCoValue,\n subscribeToCoValue,\n subscribeToExistingCoValue,\n subscriptionsScopes,\n} from \"../internal.js\";\nimport { coValuesCache } from \"../lib/cache.js\";\nimport { type CoMap } from \"./coMap.js\";\nimport { type Group } from \"./group.js\";\nimport { createInboxRoot } from \"./inbox.js\";\nimport { Profile } from \"./profile.js\";\nimport { RegisteredSchemas } from \"./registeredSchemas.js\";\n\n/** @category Identity & Permissions */\nexport class Account extends CoValueBase implements CoValue {\n declare id: ID<this>;\n declare _type: \"Account\";\n declare _raw: RawAccount | RawControlledAccount;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static _schema: any;\n get _schema(): {\n profile: Schema;\n root: Schema;\n } {\n return (this.constructor as typeof Account)._schema;\n }\n static {\n this._schema = {\n profile: {\n ref: () => Profile,\n optional: false,\n } satisfies RefEncoded<Profile>,\n root: {\n ref: () => RegisteredSchemas[\"CoMap\"],\n optional: true,\n } satisfies RefEncoded<CoMap>,\n };\n }\n\n get _owner(): Account {\n return this as Account;\n }\n get _loadedAs(): Account | AnonymousJazzAgent {\n if (this.isMe) return this;\n\n const rawAccount = this._raw.core.node.account;\n\n if (rawAccount instanceof RawAccount) {\n return coValuesCache.get(rawAccount, () => Account.fromRaw(rawAccount));\n }\n\n return new AnonymousJazzAgent(this._raw.core.node);\n }\n\n declare profile: Profile | null;\n declare root: CoMap | null;\n\n get _refs(): {\n profile: RefIfCoValue<Profile> | undefined;\n root: RefIfCoValue<CoMap> | undefined;\n } {\n const profileID = this._raw.get(\"profile\") as unknown as\n | ID<NonNullable<this[\"profile\"]>>\n | undefined;\n const rootID = this._raw.get(\"root\") as unknown as\n | ID<NonNullable<this[\"root\"]>>\n | undefined;\n\n return {\n profile:\n profileID &&\n (new Ref(\n profileID,\n this._loadedAs,\n this._schema.profile as RefEncoded<\n NonNullable<this[\"profile\"]> & CoValue\n >,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any as RefIfCoValue<this[\"profile\"]>),\n root:\n rootID &&\n (new Ref(\n rootID,\n this._loadedAs,\n this._schema.root as RefEncoded<NonNullable<this[\"root\"]> & CoValue>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any as RefIfCoValue<this[\"root\"]>),\n };\n }\n\n isMe: boolean;\n sessionID: SessionID | undefined;\n\n constructor(options: { fromRaw: RawAccount | RawControlledAccount }) {\n super();\n if (!(\"fromRaw\" in options)) {\n throw new Error(\"Can only construct account from raw or with .create()\");\n }\n this.isMe = options.fromRaw.id == options.fromRaw.core.node.account.id;\n\n Object.defineProperties(this, {\n id: {\n value: options.fromRaw.id,\n enumerable: false,\n },\n _raw: { value: options.fromRaw, enumerable: false },\n _type: { value: \"Account\", enumerable: false },\n });\n\n if (this.isMe) {\n this.sessionID = options.fromRaw.core.node.currentSessionID;\n }\n\n return new Proxy(this, AccountAndGroupProxyHandler as ProxyHandler<this>);\n }\n\n myRole(): \"admin\" | undefined {\n if (this.isMe) {\n return \"admin\";\n }\n }\n\n async acceptInvite<V extends CoValue>(\n valueID: ID<V>,\n inviteSecret: InviteSecret,\n coValueClass: CoValueClass<V>,\n ) {\n if (!this.isMe) {\n throw new Error(\"Only a controlled account can accept invites\");\n }\n\n await (this._raw as RawControlledAccount).acceptInvite(\n valueID as unknown as CoID<RawCoValue>,\n inviteSecret,\n );\n\n return loadCoValue(coValueClass, valueID, this as Account, []);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }\n\n /** @private */\n static async create<A extends Account>(\n this: CoValueClass<A> & typeof Account,\n options: {\n creationProps: { name: string };\n initialAgentSecret?: AgentSecret;\n peersToLoadFrom?: Peer[];\n crypto: CryptoProvider;\n },\n ): Promise<A> {\n const { node } = await LocalNode.withNewlyCreatedAccount({\n ...options,\n migration: async (rawAccount, _node, creationProps) => {\n const account = new this({\n fromRaw: rawAccount,\n }) as A;\n\n await account.applyMigration?.(creationProps);\n },\n });\n\n return this.fromNode(node) as A;\n }\n\n static async createAs<A extends Account>(\n this: CoValueClass<A> & typeof Account,\n as: Account,\n options: {\n creationProps: { name: string };\n },\n ) {\n // TODO: is there a cleaner way to do this?\n const connectedPeers = cojsonInternals.connectedPeers(\n \"creatingAccount\",\n \"createdAccount\",\n { peer1role: \"server\", peer2role: \"client\" },\n );\n\n as._raw.core.node.syncManager.addPeer(connectedPeers[1]);\n\n return this.create<A>({\n creationProps: options.creationProps,\n crypto: as._raw.core.node.crypto,\n peersToLoadFrom: [connectedPeers[0]],\n });\n }\n\n static fromNode<A extends Account>(\n this: CoValueClass<A>,\n node: LocalNode,\n ): A {\n return new this({\n fromRaw: node.account as RawControlledAccount,\n }) as A;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(): object | any[] {\n return {\n id: this.id,\n _type: this._type,\n };\n }\n\n [inspect]() {\n return this.toJSON();\n }\n\n async applyMigration(creationProps?: { name: string }) {\n if (creationProps) {\n const profileGroup = RegisteredSchemas[\"Group\"].create({ owner: this });\n profileGroup.addMember(\"everyone\", \"reader\");\n this.profile = Profile.create(\n { name: creationProps.name },\n { owner: profileGroup },\n );\n }\n\n const node = this._raw.core.node;\n const profile = node\n .expectCoValueLoaded(this._raw.get(\"profile\")!)\n .getCurrentContent() as RawCoMap;\n\n if (!profile.get(\"inbox\")) {\n const inboxRoot = createInboxRoot(this);\n profile.set(\"inbox\", inboxRoot.id);\n profile.set(\"inboxInvite\", inboxRoot.inviteLink);\n }\n\n await this.migrate(creationProps);\n }\n\n // Placeholder method for subclasses to override\n migrate(creationProps?: { name: string }) {\n creationProps; // To avoid unused parameter warning\n }\n\n /** @category Subscription & Loading */\n static load<A extends Account, Depth>(\n this: CoValueClass<A>,\n id: ID<A>,\n as: Account,\n depth: Depth & DepthsIn<A>,\n ): Promise<DeeplyLoaded<A, Depth> | undefined> {\n return loadCoValue(this, id, as, depth);\n }\n\n /** @category Subscription & Loading */\n static subscribe<A extends Account, Depth>(\n this: CoValueClass<A>,\n id: ID<A>,\n as: Account,\n depth: Depth & DepthsIn<A>,\n listener: (value: DeeplyLoaded<A, Depth>) => void,\n ): () => void {\n return subscribeToCoValue<A, Depth>(this, id, as, depth, listener);\n }\n\n /** @category Subscription & Loading */\n ensureLoaded<A extends Account, Depth>(\n this: A,\n depth: Depth & DepthsIn<A>,\n ): Promise<DeeplyLoaded<A, Depth> | undefined> {\n return ensureCoValueLoaded(this, depth);\n }\n\n /** @category Subscription & Loading */\n subscribe<A extends Account, Depth>(\n this: A,\n depth: Depth & DepthsIn<A>,\n listener: (value: DeeplyLoaded<A, Depth>) => void,\n ): () => void {\n return subscribeToExistingCoValue(this, depth, listener);\n }\n\n /**\n * Wait for the `Account` to be uploaded to the other peers.\n *\n * @category Subscription & Loading\n */\n waitForSync(options?: {\n timeout?: number;\n }) {\n return this._raw.core.waitForSync(options);\n }\n\n /**\n * Wait for all the available `CoValues` to be uploaded to the other peers.\n *\n * @category Subscription & Loading\n */\n waitForAllCoValuesSync(options?: {\n timeout?: number;\n }) {\n return this._raw.core.node.syncManager.waitForAllCoValuesSync(\n options?.timeout,\n );\n }\n}\n\nexport const AccountAndGroupProxyHandler: ProxyHandler<Account | Group> = {\n get(target, key, receiver) {\n if (key === \"profile\") {\n const ref = target._refs.profile;\n return ref\n ? ref.accessFrom(receiver, \"profile\")\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (undefined as any);\n } else if (key === \"root\") {\n const ref = target._refs.root;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return ref ? ref.accessFrom(receiver, \"root\") : (undefined as any);\n } else {\n return Reflect.get(target, key, receiver);\n }\n },\n set(target, key, value, receiver) {\n if (\n (key === \"profile\" || key === \"root\" || key === MembersSym) &&\n typeof value === \"object\" &&\n SchemaInit in value\n ) {\n (target.constructor as typeof CoMap)._schema ||= {};\n (target.constructor as typeof CoMap)._schema[key] = value[SchemaInit];\n return true;\n } else if (key === \"profile\") {\n if (value) {\n target._raw.set(\n \"profile\",\n value.id as unknown as CoID<RawCoMap>,\n \"trusting\",\n );\n }\n subscriptionsScopes\n .get(receiver)\n ?.onRefAccessedOrSet(target.id, value.id);\n return true;\n } else if (key === \"root\") {\n if (value) {\n target._raw.set(\"root\", value.id as unknown as CoID<RawCoMap>);\n }\n subscriptionsScopes\n .get(receiver)\n ?.onRefAccessedOrSet(target.id, value.id);\n return true;\n } else {\n return Reflect.set(target, key, value, receiver);\n }\n },\n defineProperty(target, key, descriptor) {\n if (\n (key === \"profile\" || key === \"root\" || key === MembersSym) &&\n typeof descriptor.value === \"object\" &&\n SchemaInit in descriptor.value\n ) {\n (target.constructor as typeof CoMap)._schema ||= {};\n (target.constructor as typeof CoMap)._schema[key] =\n descriptor.value[SchemaInit];\n return true;\n } else {\n return Reflect.defineProperty(target, key, descriptor);\n }\n },\n};\n\n/** @category Identity & Permissions */\nexport function isControlledAccount(account: Account): account is Account & {\n isMe: true;\n sessionID: SessionID;\n _raw: RawControlledAccount;\n} {\n return account.isMe;\n}\n\nexport type AccountClass<Acc extends Account> = CoValueClass<Acc> & {\n fromNode: (typeof Account)[\"fromNode\"];\n};\n\nRegisteredSchemas[\"Account\"] = Account;\n","import type { Everyone, RawAccountID, RawGroup, Role } from \"cojson\";\nimport type {\n CoValue,\n CoValueClass,\n DeeplyLoaded,\n DepthsIn,\n ID,\n RefEncoded,\n Schema,\n} from \"../internal.js\";\nimport {\n CoValueBase,\n MembersSym,\n Ref,\n ensureCoValueLoaded,\n loadCoValue,\n subscribeToCoValue,\n subscribeToExistingCoValue,\n} from \"../internal.js\";\nimport { AccountAndGroupProxyHandler, isControlledAccount } from \"./account.js\";\nimport { type Account } from \"./account.js\";\nimport { type CoMap } from \"./coMap.js\";\nimport { type Profile } from \"./profile.js\";\nimport { RegisteredSchemas } from \"./registeredSchemas.js\";\n\n/** @category Identity & Permissions */\nexport class Group extends CoValueBase implements CoValue {\n declare id: ID<this>;\n declare _type: \"Group\";\n static {\n this.prototype._type = \"Group\";\n }\n declare _raw: RawGroup;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static _schema: any;\n get _schema(): {\n profile: Schema;\n root: Schema;\n [MembersSym]: RefEncoded<Account>;\n } {\n return (this.constructor as typeof Group)._schema;\n }\n static {\n this._schema = {\n profile: \"json\" satisfies Schema,\n root: \"json\" satisfies Schema,\n [MembersSym]: {\n ref: () => RegisteredSchemas[\"Account\"],\n optional: false,\n } satisfies RefEncoded<Account>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any;\n Object.defineProperty(this.prototype, \"_schema\", {\n get: () => this._schema,\n });\n }\n\n declare profile: Profile | null;\n declare root: CoMap | null;\n declare [MembersSym]: Account | null;\n\n get _refs(): {\n profile: Ref<Profile> | undefined;\n root: Ref<CoMap> | undefined;\n } {\n const profileID = this._raw.get(\"profile\") as unknown as\n | ID<NonNullable<this[\"profile\"]>>\n | undefined;\n const rootID = this._raw.get(\"root\") as unknown as\n | ID<NonNullable<this[\"root\"]>>\n | undefined;\n return {\n profile:\n profileID &&\n (new Ref(\n profileID,\n this._loadedAs,\n this._schema.profile as RefEncoded<NonNullable<this[\"profile\"]>>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any as this[\"profile\"] extends Profile\n ? Ref<this[\"profile\"]>\n : never),\n root:\n rootID &&\n (new Ref(\n rootID,\n this._loadedAs,\n this._schema.root as RefEncoded<NonNullable<this[\"root\"]>>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any as this[\"root\"] extends CoMap ? Ref<this[\"root\"]> : never),\n };\n }\n\n /** @deprecated Don't use constructor directly, use .create */\n constructor(options: { fromRaw: RawGroup } | { owner: Account | Group }) {\n super();\n let raw: RawGroup;\n\n if (options && \"fromRaw\" in options) {\n raw = options.fromRaw;\n } else {\n const initOwner = options.owner;\n if (!initOwner) throw new Error(\"No owner provided\");\n if (initOwner._type === \"Account\" && isControlledAccount(initOwner)) {\n const rawOwner = initOwner._raw;\n raw = rawOwner.createGroup();\n } else {\n throw new Error(\"Can only construct group as a controlled account\");\n }\n }\n\n Object.defineProperties(this, {\n id: {\n value: raw.id,\n enumerable: false,\n },\n _raw: { value: raw, enumerable: false },\n });\n\n return new Proxy(this, AccountAndGroupProxyHandler as ProxyHandler<this>);\n }\n\n static create<G extends Group>(\n this: CoValueClass<G>,\n options: { owner: Account },\n ) {\n return new this(options);\n }\n\n myRole(): Role | undefined {\n return this._raw.myRole();\n }\n\n addMember(member: Everyone | Account, role: Role) {\n this._raw.addMember(member === \"everyone\" ? member : member._raw, role);\n return this;\n }\n\n removeMember(member: Everyone | Account) {\n this._raw.removeMember(member === \"everyone\" ? member : member._raw);\n return this;\n }\n\n get members() {\n return this._raw\n .keys()\n .filter((key) => {\n return key === \"everyone\" || key.startsWith(\"co_\");\n })\n .map((id) => {\n const role = this._raw.get(id as Everyone | RawAccountID);\n const accountID =\n id === \"everyone\" ? undefined : (id as unknown as ID<Account>);\n const ref =\n accountID &&\n new Ref<NonNullable<this[MembersSym]>>(\n accountID,\n this._loadedAs,\n this._schema[MembersSym],\n );\n const accessRef = () => ref?.accessFrom(this, \"members.\" + id);\n\n return {\n id: id as unknown as Everyone | ID<this[MembersSym]>,\n role,\n ref,\n get account() {\n return accessRef();\n },\n };\n });\n }\n\n extend(parent: Group) {\n this._raw.extend(parent._raw);\n return this;\n }\n\n /** @category Subscription & Loading */\n static load<G extends Group, Depth>(\n this: CoValueClass<G>,\n id: ID<G>,\n as: Account,\n depth: Depth & DepthsIn<G>,\n ): Promise<DeeplyLoaded<G, Depth> | undefined> {\n return loadCoValue(this, id, as, depth);\n }\n\n /** @category Subscription & Loading */\n static subscribe<G extends Group, Depth>(\n this: CoValueClass<G>,\n id: ID<G>,\n as: Account,\n depth: Depth & DepthsIn<G>,\n listener: (value: DeeplyLoaded<G, Depth>) => void,\n ): () => void {\n return subscribeToCoValue<G, Depth>(this, id, as, depth, listener);\n }\n\n /** @category Subscription & Loading */\n ensureLoaded<G extends Group, Depth>(\n this: G,\n depth: Depth & DepthsIn<G>,\n ): Promise<DeeplyLoaded<G, Depth> | undefined> {\n return ensureCoValueLoaded(this, depth);\n }\n\n /** @category Subscription & Loading */\n subscribe<G extends Group, Depth>(\n this: G,\n depth: Depth & DepthsIn<G>,\n listener: (value: DeeplyLoaded<G, Depth>) => void,\n ): () => void {\n return subscribeToExistingCoValue(this, depth, listener);\n }\n\n /**\n * Wait for the `Group` to be uploaded to the other peers.\n *\n * @category Subscription & Loading\n */\n waitForSync(options?: { timeout?: number }) {\n return this._raw.core.waitForSync(options);\n }\n}\n\nRegisteredSchemas[\"Group\"] = Group;\n","/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport type {\n AgentID,\n BinaryStreamInfo,\n CojsonInternalTypes,\n JsonValue,\n RawAccountID,\n RawBinaryCoStream,\n RawCoStream,\n SessionID,\n} from \"cojson\";\nimport { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from \"cojson\";\nimport type {\n AnonymousJazzAgent,\n CoValue,\n CoValueClass,\n DeeplyLoaded,\n DepthsIn,\n ID,\n IfCo,\n Schema,\n SchemaFor,\n UnCo,\n} from \"../internal.js\";\nimport {\n CoValueBase,\n ItemsSym,\n Ref,\n SchemaInit,\n co,\n ensureCoValueLoaded,\n inspect,\n isRefEncoded,\n loadCoValue,\n subscribeToCoValue,\n subscribeToExistingCoValue,\n} from \"../internal.js\";\nimport { type Account } from \"./account.js\";\nimport { type Group } from \"./group.js\";\nimport { RegisteredSchemas } from \"./registeredSchemas.js\";\n\n/** @deprecated Use CoFeedEntry instead */\nexport type CoStreamEntry<Item> = CoFeedEntry<Item>;\n\nexport type CoFeedEntry<Item> = SingleCoFeedEntry<Item> & {\n all: IterableIterator<SingleCoFeedEntry<Item>>;\n};\n\n/** @deprecated Use SingleCoFeedEntry instead */\nexport type SingleCoStreamEntry<Item> = SingleCoFeedEntry<Item>;\n\nexport type SingleCoFeedEntry<Item> = {\n value: NonNullable<Item> extends CoValue ? NonNullable<Item> | null : Item;\n ref: NonNullable<Item> extends CoValue ? Ref<NonNullable<Item>> : never;\n by?: Account | null;\n madeAt: Date;\n tx: CojsonInternalTypes.TransactionID;\n};\n\n/** @deprecated Use CoFeed instead */\nexport { CoFeed as CoStream };\n\n/**\n * CoFeeds are collaborative logs of data.\n *\n * @categoryDescription Content\n * They are similar to `CoList`s, but with a few key differences:\n * - They are append-only\n * - They consist of several internal append-only logs, one per account session (tab, device, app instance, etc.)\n * - They expose those as a per-account aggregated view (default) or a precise per-session view\n *\n * ```ts\n * favDog.push(\"Poodle\");\n * favDog.push(\"Schnowzer\");\n * ```\n *\n * @category CoValues\n */\nexport class CoFeed<Item = any> extends CoValueBase implements CoValue {\n /**\n * Declare a `CoFeed` by subclassing `CoFeed.Of(...)` and passing the item schema using a `co` primitive or a `co.ref`.\n *\n * @example\n * ```ts\n * class ColorFeed extends CoFeed.Of(co.string) {}\n * class AnimalFeed extends CoFeed.Of(co.ref(Animal)) {}\n * ```\n *\n * @category Declaration\n */\n static Of<Item>(item: IfCo<Item, Item>): typeof CoFeed<Item> {\n return class CoFeedOf extends CoFeed<Item> {\n [co.items] = item;\n };\n }\n\n /**\n * The ID of this `CoFeed`\n * @category Content */\n declare id: ID<this>;\n /** @category Type Helpers */\n declare _type: \"CoStream\";\n static {\n this.prototype._type = \"CoStream\";\n }\n /** @category Internals */\n declare _raw: RawCoStream;\n\n /** @internal This is only a marker type and doesn't exist at runtime */\n [ItemsSym]!: Item;\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static _schema: any;\n /** @internal */\n get _schema(): {\n [ItemsSym]: SchemaFor<Item>;\n } {\n return (this.constructor as typeof CoFeed)._schema;\n }\n\n /**\n * The per-account view of this `CoFeed`\n *\n * @example\n * ```ts\n * // Access entries directly by account ID\n * const aliceEntries = feed[aliceAccount.id];\n * console.log(aliceEntries.value); // Latest value from Alice\n *\n * // Iterate through all accounts' entries\n * for (const [accountId, entries] of Object.entries(feed)) {\n * console.log(`Latest entry from ${accountId}:`, entries.value);\n *\n * // Access all entries from this account\n * for (const entry of entries.all) {\n * console.log(`Entry made at ${entry.madeAt}:`, entry.value);\n * }\n * }\n * ```\n *\n * @category Content\n */\n [key: ID<Account>]: CoFeedEntry<Item>;\n\n /**\n * The current account's view of this `CoFeed`\n * @category Content\n */\n get byMe(): CoFeedEntry<Item> | undefined {\n if (this._loadedAs._type === \"Account\") {\n return this[this._loadedAs.id];\n } else {\n return undefined;\n }\n }\n\n /**\n * The per-session view of this `CoFeed`\n * @category Content\n */\n perSession!: {\n [key: SessionID]: CoFeedEntry<Item>;\n };\n\n /**\n * The current session's view of this `CoFeed`\n *\n * This is a shortcut for `this.perSession` where the session ID is the current session ID.\n *\n * @category Content\n */\n get inCurrentSession(): CoFeedEntry<Item> | undefined {\n if (this._loadedAs._type === \"Account\") {\n return this.perSession[this._loadedAs.sessionID!];\n } else {\n return undefined;\n }\n }\n\n constructor(\n options:\n | { init: Item[]; owner: Account | Group }\n | { fromRaw: RawCoStream },\n ) {\n super();\n\n if (options && \"fromRaw\" in options) {\n Object.defineProperties(this, {\n id: {\n value: options.fromRaw.id,\n enumerable: false,\n },\n _raw: { value: options.fromRaw, enumerable: false },\n });\n }\n\n return new Proxy(this, CoStreamProxyHandler as ProxyHandler<this>);\n }\n\n /**\n * Create a new `CoFeed`\n * @category Creation\n */\n static create<S extends CoFeed>(\n this: CoValueClass<S>,\n init: S extends CoFeed<infer Item> ? UnCo<Item>[] : never,\n options: { owner: Account | Group },\n ) {\n const instance = new this({ init, owner: options.owner });\n const raw = options.owner._raw.createStream();\n\n Object.defineProperties(instance, {\n id: {\n value: raw.id,\n enumerable: false,\n },\n _raw: { value: raw, enumerable: false },\n });\n\n if (init) {\n instance.push(...init);\n }\n return instance;\n }\n\n /**\n * Push items to this `CoFeed`\n *\n * Items are appended to the current session's log. Each session (tab, device, app instance)\n * maintains its own append-only log, which is then aggregated into the per-account view.\n *\n * @example\n * ```ts\n * // Adds items to current session's log\n * feed.push(\"item1\", \"item2\");\n *\n * // View items from current session\n * console.log(feed.inCurrentSession);\n *\n * // View aggregated items from all sessions for current account\n * console.log(feed.byMe);\n * ```\n *\n * @category Content\n */\n push(...items: Item[]) {\n for (const item of items) {\n this.pushItem(item);\n }\n }\n\n private pushItem(item: Item) {\n const itemDescriptor = this._schema[ItemsSym] as Schema;\n\n if (itemDescriptor === \"json\") {\n this._raw.push(item as JsonValue);\n } else if (\"encoded\" in itemDescriptor) {\n this._raw.push(itemDescriptor.encoded.encode(item));\n } else if (isRefEncoded(itemDescriptor)) {\n this._raw.push((item as unknown as CoValue).id);\n }\n }\n\n /**\n * Get a JSON representation of the `CoFeed`\n * @category\n */\n toJSON(): {\n id: string;\n _type: \"CoStream\";\n [key: string]: unknown;\n in: { [key: string]: unknown };\n } {\n const itemDescriptor = this._schema[ItemsSym] as Schema;\n const mapper =\n itemDescriptor === \"json\"\n ? (v: unknown) => v\n : \"encoded\" in itemDescriptor\n ? itemDescriptor.encoded.encode\n : (v: unknown) => v && (v as CoValue).id;\n\n return {\n id: this.id,\n _type: this._type,\n ...Object.fromEntries(\n Object.entries(this).map(([account, entry]) => [\n account,\n mapper(entry.value),\n ]),\n ),\n in: Object.fromEntries(\n Object.entries(this.perSession).map(([session, entry]) => [\n session,\n mapper(entry.value),\n ]),\n ),\n };\n }\n\n /** @internal */\n [inspect](): {\n id: string;\n _type: \"CoStream\";\n [key: string]: unknown;\n in: { [key: string]: unknown };\n } {\n return this.toJSON();\n }\n\n /** @internal */\n static schema<V extends CoFeed>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: { new (...args: any): V } & typeof CoFeed,\n def: { [ItemsSym]: V[\"_schema\"][ItemsSym] },\n ) {\n this._schema ||= {};\n Object.assign(this._schema, def);\n }\n\n /**\n * Load a `CoFeed`\n * @category Subscription & Loading\n */\n static load<S extends CoFeed, Depth>(\n this: CoValueClass<S>,\n id: ID<S>,\n as: Account,\n depth: Depth & DepthsIn<S>,\n ): Promise<DeeplyLoaded<S, Depth> | undefined> {\n return loadCoValue(this, id, as, depth);\n }\n\n /**\n * Subscribe to a `CoFeed`, when you have an ID but don't have a `CoFeed` instance yet\n * @category Subscription & Loading\n */\n static subscribe<S extends CoFeed, Depth>(\n this: CoValueClass<S>,\n id: ID<S>,\n as: Account,\n depth: Depth & DepthsIn<S>,\n listener: (value: DeeplyLoaded<S, Depth>) => void,\n ): () => void {\n return subscribeToCoValue<S, Depth>(this, id, as, depth, listener);\n }\n\n /**\n * Ensure a `CoFeed` is loaded to the specified depth\n *\n * @returns A new instance of the same CoFeed that's loaded to the specified depth,\n * or undefined if it cannot be loaded that deeply\n * @category Subscription & Loading\n */\n ensureLoaded<S extends CoFeed, Depth>(\n this: S,\n depth: Depth & DepthsIn<S>,\n ): Promise<DeeplyLoaded<S, Depth> | undefined> {\n return ensureCoValueLoaded(this, depth);\n }\n\n /**\n * An instance method to subscribe to an existing `CoFeed`\n *\n * No need to provide an ID or Account since they're already part of the instance.\n * @category Subscription & Loading\n */\n subscribe<S extends CoFeed, Depth>(\n this: S,\n depth: Depth & DepthsIn<S>,\n listener: (value: DeeplyLoaded<S, Depth>) => void,\n ): () => void {\n return subscribeToExistingCoValue(this, depth, listener);\n }\n\n /**\n * Wait for the `CoFeed` to be uploaded to the other peers.\n *\n * @category Subscription & Loading\n */\n waitForSync(options?: {\n timeout?: number;\n }) {\n return this._raw.core.waitForSync(options);\n }\n}\n\n/**\n * Converts a raw stream entry into a formatted CoFeed entry with proper typing and accessors.\n * @internal\n */\nfunction entryFromRawEntry<Item>(\n accessFrom: CoValue,\n rawEntry: {\n by: RawAccountID | AgentID;\n tx: CojsonInternalTypes.TransactionID;\n at: Date;\n value: JsonValue;\n },\n loadedAs: Account | AnonymousJazzAgent,\n accountID: ID<Account> | undefined,\n itemField: Schema,\n): Omit<CoFeedEntry<Item>, \"all\"> {\n return {\n get value(): NonNullable<Item> extends CoValue\n ? (CoValue & Item) | null\n : Item {\n if (itemField === \"json\") {\n return rawEntry.value as NonNullable<Item> extends CoValue\n ? (CoValue & Item) | null\n : Item;\n } else if (\"encoded\" in itemField) {\n return itemField.encoded.decode(rawEntry.value);\n } else if (isRefEncoded(itemField)) {\n return this.ref?.accessFrom(\n accessFrom,\n rawEntry.by + rawEntry.tx.sessionID + rawEntry.tx.txIndex + \".value\",\n ) as NonNullable<Item> extends CoValue ? (CoValue & Item) | null : Item;\n } else {\n throw new Error(\"Invalid item field schema\");\n }\n },\n get ref(): NonNullable<Item> extends CoValue\n ? Ref<NonNullable<Item>>\n : never {\n if (itemField !== \"json\" && isRefEncoded(itemField)) {\n const rawId = rawEntry.value;\n return new Ref(\n rawId as unknown as ID<CoValue>,\n loadedAs,\n itemField,\n ) as NonNullable<Item> extends CoValue ? Ref<NonNullable<Item>> : never;\n } else {\n return undefined as never;\n }\n },\n get by() {\n return (\n accountID &&\n new Ref<Account>(accountID as unknown as ID<Account>, loadedAs, {\n ref: RegisteredSchemas[\"Account\"],\n optional: false,\n })?.accessFrom(\n accessFrom,\n rawEntry.by + rawEntry.tx.sessionID + rawEntry.tx.txIndex + \".by\",\n )\n );\n },\n madeAt: rawEntry.at,\n tx: rawEntry.tx,\n };\n}\n\n/**\n * The proxy handler for `CoFeed` instances\n * @internal\n */\nexport const CoStreamProxyHandler: ProxyHandler<CoFeed> = {\n get(target, key, receiver) {\n if (typeof key === \"string\" && key.startsWith(\"co_\")) {\n const rawEntry = target._raw.lastItemBy(key as RawAccountID);\n\n if (!rawEntry) return;\n const entry = entryFromRawEntry(\n receiver,\n rawEntry,\n target._loadedAs,\n key as unknown as ID<Account>,\n target._schema[ItemsSym],\n );\n\n Object.defineProperty(entry, \"all\", {\n get: () => {\n const allRawEntries = target._raw.itemsBy(key as RawAccountID);\n return (function* () {\n while (true) {\n const rawEntry = allRawEntries.next();\n if (rawEntry.done) return;\n yield entryFromRawEntry(\n receiver,\n rawEntry.value,\n target._loadedAs,\n key as unknown as ID<Account>,\n target._schema[ItemsSym],\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n })() satisfies IterableIterator<SingleCoFeedEntry<any>>;\n },\n });\n\n return entry;\n } else if (key === \"perSession\") {\n return new Proxy({}, CoStreamPerSessionProxyHandler(target, receiver));\n } else {\n return Reflect.get(target, key, receiver);\n }\n },\n set(target, key, value, receiver) {\n if (key === ItemsSym && typeof value === \"object\" && SchemaInit in value) {\n (target.constructor as typeof CoFeed)._schema ||= {};\n (target.constructor as typeof CoFeed)._schema[ItemsSym] =\n value[SchemaInit];\n return true;\n } else {\n return Reflect.set(target, key, value, receiver);\n }\n },\n defineProperty(target, key, descriptor) {\n if (\n descriptor.value &&\n key === ItemsSym &&\n typeof descriptor.value === \"object\" &&\n SchemaInit in descriptor.value\n ) {\n (target.constructor as typeof CoFeed)._schema ||= {};\n (target.constructor as typeof CoFeed)._schema[ItemsSym] =\n descriptor.value[SchemaInit];\n return true;\n } else {\n return Reflect.defineProperty(target, key, descriptor);\n }\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n\n for (const accountID of target._raw.accounts()) {\n keys.push(accountID);\n }\n\n return keys;\n },\n getOwnPropertyDescriptor(target, key) {\n if (typeof key === \"string\" && key.startsWith(\"co_\")) {\n return {\n configurable: true,\n enumerable: true,\n writable: false,\n };\n } else {\n return Reflect.getOwnPropertyDescriptor(target, key);\n }\n },\n};\n\n/**\n * The proxy handler for the per-session view of a `CoFeed`\n * @internal\n */\nconst CoStreamPerSessionProxyHandler = (\n innerTarget: CoFeed,\n accessFrom: CoFeed,\n): ProxyHandler<Record<string, never>> => ({\n get(_target, key, receiver) {\n if (typeof key === \"string\" && key.includes(\"session\")) {\n const sessionID = key as SessionID;\n const rawEntry = innerTarget._raw.lastItemIn(sessionID);\n\n if (!rawEntry) return;\n const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);\n\n const entry = entryFromRawEntry(\n accessFrom,\n rawEntry,\n innerTarget._loadedAs,\n cojsonInternals.isAccountID(by)\n ? (by as unknown as ID<Account>)\n : undefined,\n innerTarget._schema[ItemsSym],\n );\n\n Object.defineProperty(entry, \"all\", {\n get: () => {\n const allRawEntries = innerTarget._raw.itemsIn(sessionID);\n return (function* () {\n while (true) {\n const rawEntry = allRawEntries.next();\n if (rawEntry.done) return;\n yield entryFromRawEntry(\n accessFrom,\n rawEntry.value,\n innerTarget._loadedAs,\n cojsonInternals.isAccountID(by)\n ? (by as unknown as ID<Account>)\n : undefined,\n innerTarget._schema[ItemsSym],\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n })() satisfies IterableIterator<SingleCoFeedEntry<any>>;\n },\n });\n\n return entry;\n } else {\n return Reflect.get(innerTarget, key, receiver);\n }\n },\n ownKeys() {\n return innerTarget._raw.sessions();\n },\n getOwnPropertyDescriptor(target, key) {\n if (typeof key === \"string\" && key.startsWith(\"co_\")) {\n return {\n configurable: true,\n enumerable: true,\n writable: false,\n };\n } else {\n return Reflect.getOwnPropertyDescriptor(target, key);\n }\n },\n});\n\n/** @deprecated Use FileStream instead */\nexport { FileStream as BinaryCoStream };\n\n/**\n * FileStreams are `CoFeed`s that contain binary data, collaborative versions of `Blob`s.\n *\n * @categoryDescription Declaration\n * `FileStream` can be referenced in schemas.\n *\n * ```ts\n * import { co, FileStream } from \"jazz-tools\";\n *\n * class MyCoMap extends CoMap {\n * file = co.ref(FileStream);\n * }\n * ```\n *\n * @category CoValues\n */\nexport class FileStream extends CoValueBase implements CoValue {\n /**\n * The ID of this `FileStream`\n * @category Content\n */\n declare id: ID<this>;\n /** @category Type Helpers */\n declare _type: \"BinaryCoStream\";\n /** @internal */\n declare _raw: RawBinaryCoStream;\n\n constructor(\n options:\n | {\n owner: Account | Group;\n }\n | {\n fromRaw: RawBinaryCoStream;\n },\n ) {\n super();\n\n let raw: RawBinaryCoStream;\n\n if (\"fromRaw\" in options) {\n raw = options.fromRaw;\n } else {\n const rawOwner = options.owner._raw;\n raw = rawOwner.createBinaryStream();\n }\n\n Object.defineProperties(this, {\n id: {\n value: raw.id,\n enumerable: false,\n },\n _type: { value: \"BinaryCoStream\", enumerable: false },\n _raw: { value: raw, enumerable: false },\n });\n }\n\n static create<S extends FileStream>(\n this: CoValueClass<S>,\n options: { owner: Account | Group },\n ) {\n return new this(options);\n }\n\n getChunks(options?: {\n allowUnfinished?: boolean;\n }):\n | (BinaryStreamInfo & { chunks: Uint8Array[]; finished: boolean })\n | undefined {\n return this._raw.getBinaryChunks(options?.allowUnfinished);\n }\n\n isBinaryStreamEnded(): boolean {\n return this._raw.isBinaryStreamEnded();\n }\n\n start(options: BinaryStreamInfo): void {\n this._raw.startBinaryStream(options);\n }\n\n push(data: Uint8Array): void {\n this._raw.pushBinaryStreamChunk(data);\n }\n\n end(): void {\n this._raw.endBinaryStream();\n }\n\n toBlob(options?: { allowUnfinished?: boolean }): Blob | undefined {\n const chunks = this.getChunks({\n allowUnfinished: options?.allowUnfinished,\n });\n\n if (!chunks) {\n return undefined;\n }\n\n // @ts-ignore\n return new Blob(chunks.chunks, { type: chunks.mimeType });\n }\n\n /**\n * Load a `FileStream` as a `Blob`\n *\n * @category Content\n */\n static async loadAsBlob(\n id: ID<FileStream>,\n as: Account,\n options?: {\n allowUnfinished?: boolean;\n },\n ): Promise<Blob | undefined> {\n let stream = await this.load(id, as, []);\n\n /**\n * If the user hasn't requested an incomplete blob and the\n * stream isn't complete wait for the stream download before progressing\n */\n if (!options?.allowUnfinished && !stream?.isBinaryStreamEnded()) {\n stream = await new Promise<FileStream>((resolve) => {\n const unsubscribe = subscribeToCoValue(this, id, as, [], (value) => {\n if (value.isBinaryStreamEnded()) {\n unsubscribe();\n resolve(value);\n }\n });\n });\n }\n\n return stream?.toBlob({\n allowUnfinished: options?.allowUnfinished,\n });\n }\n\n /**\n * Create a `FileStream` from a `Blob` or `File`\n *\n * @example\n * ```ts\n * import { co, FileStream } from \"jazz-tools\";\n *\n * const fileStream = await FileStream.createFromBlob(file, {owner: group})\n * ```\n * @category Content\n */\n static async createFromBlob(\n blob: Blob | File,\n options: {\n owner: Group | Account;\n onProgress?: (progress: number) => void;\n },\n ): Promise<FileStream> {\n const stream = this.create({ owner: options.owner });\n\n const start = Date.now();\n\n const data = new Uint8Array(await blob.arrayBuffer());\n stream.start({\n mimeType: blob.type,\n totalSizeBytes: blob.size,\n fileName: blob instanceof File ? blob.name : undefined,\n });\n const chunkSize = MAX_RECOMMENDED_TX_SIZE;\n\n let lastProgressUpdate = Date.now();\n\n for (let idx = 0; idx < data.length; idx += chunkSize) {\n stream.push(data.slice(idx, idx + chunkSize));\n\n if (Date.now() - lastProgressUpdate > 100) {\n options.onProgress?.(idx / data.length);\n lastProgressUpdate = Date.now();\n }\n\n await new Promise((resolve) => setTimeout(resolve, 0));\n }\n stream.end();\n const end = Date.now();\n\n console.debug(\n \"Finished creating binary stream in\",\n (end - start) / 1000,\n \"s - Throughput in MB/s\",\n (1000 * (blob.size / (end - start))) / (1024 * 1024),\n );\n options.onProgress?.(1);\n\n return stream;\n }\n\n /**\n * Get a JSON representation of the `FileStream`\n * @category Content\n */\n toJSON(): {\n id: string;\n _type: \"BinaryCoStream\";\n mimeType?: string;\n totalSizeBytes?: number;\n fileName?: string;\n chunks?: Uint8Array[];\n finished?: boolean;\n } {\n return {\n id: this.id,\n _type: this._type,\n ...this.getChunks(),\n };\n }\n\n /** @internal */\n [inspect]() {\n return this.toJSON();\n }\n\n /**\n * Load a `FileStream`\n * @category Subscription & Loading\n */\n static load<B extends FileStream, Depth>(\n this: CoValueClass<B>,\n id: ID<B>,\n as: Account,\n depth: Depth & DepthsIn<B>,\n ): Promise<DeeplyLoaded<B, Depth> | undefined> {\n return loadCoValue(this, id, as, depth);\n }\n\n /**\n * Subscribe to a `FileStream`, when you have an ID but don't have a `FileStream` instance yet\n * @category Subscription & Loading\n */\n static subscribe<B extends FileStream, Depth>(\n this: CoValueClass<B>,\n id: ID<B>,\n as: Account,\n depth: Depth & DepthsIn<B>,\n listener: (value: DeeplyLoaded<B, Depth>) => void,\n ): () => void {\n return subscribeToCoValue<B, Depth>(this, id, as, depth, listener);\n }\n\n ensureLoaded<B extends FileStream, Depth>(\n this: B,\n depth: Depth & DepthsIn<B>,\n ): Promise<DeeplyLoaded<B, Depth> | undefined> {\n return ensureCoValueLoaded(this, depth);\n }\n\n /**\n * An instance method to subscribe to an existing `FileStream`\n * @category Subscription & Loading\n */\n subscribe<B extends FileStream, Depth>(\n this: B,\n depth: Depth & DepthsIn<B>,\n listener: (value: DeeplyLoaded<B, Depth>) => void,\n ): () => void {\n return subscribeToExistingCoValue(this, depth, listener);\n }\n\n /**\n * Wait for the `FileStream` to be uploaded to the other peers.\n *\n * @category Subscription & Loading\n */\n waitForSync(options?: { timeout?: number }) {\n return this._raw.core.waitForSync(options);\n }\n}\n","import type { JsonValue, RawCoList } from \"cojson\";\nimport { RawAccount } from \"cojson\";\nimport type {\n CoValue,\n CoValueClass,\n CoValueFromRaw,\n DeeplyLoaded,\n DepthsIn,\n ID,\n RefEncoded,\n Schema,\n SchemaFor,\n UnCo,\n} from \"../internal.js\";\nimport {\n AnonymousJazzAgent,\n ItemsSym,\n Ref,\n SchemaInit,\n co,\n ensureCoValueLoaded,\n inspect,\n isRefEncoded,\n loadCoValue,\n makeRefs,\n subscribeToCoValue,\n subscribeToExistingCoValue,\n subscriptionsScopes,\n} from \"../internal.js\";\nimport { coValuesCache } from \"../lib/cache.js\";\nimport { type Account } from \"./account.js\";\nimport { type Group } from \"./group.js\";\nimport { RegisteredSchemas } from \"./registeredSchemas.js\";\n\n/**\n * CoLists are collaborative versions of plain arrays.\n *\n * @categoryDescription Content\n * You can access items on a `CoList` as if they were normal items on a plain array, using `[]` notation, etc.\n *\n * Since `CoList` is a subclass of `Array`, you can use all the normal array methods like `push`, `pop`, `splice`, etc.\n *\n * ```ts\n * colorList[0];\n * colorList[3] = \"yellow\";\n * colorList.push(\"Kawazaki Green\");\n * colorList.splice(1, 1);\n * ```\n *\n * @category CoValues\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class CoList<Item = any> extends Array<Item> implements CoValue {\n /**\n * Declare a `CoList` by subclassing `CoList.Of(...)` and passing the item schema using `co`.\n *\n * @example\n * ```ts\n * class ColorList extends CoList.Of(\n * co.string\n * ) {}\n * class AnimalList extends CoList.Of(\n * co.ref(Animal)\n * ) {}\n * ```\n *\n * @category Declaration\n */\n static Of<Item>(item: Item): typeof CoList<Item> {\n // TODO: cache superclass for item class\n return class CoListOf extends CoList<Item> {\n [co.items] = item;\n };\n }\n\n /**\n * @ignore\n * @deprecated Use UPPERCASE `CoList.Of` instead! */\n static of(..._args: never): never {\n throw new Error(\"Can't use Array.of with CoLists\");\n }\n\n /**\n * The ID of this `CoList`\n * @category Content */\n declare id: ID<this>;\n /** @category Type Helpers */\n declare _type: \"CoList\";\n static {\n this.prototype._type = \"CoList\";\n }\n /** @category Internals */\n declare _raw: RawCoList;\n /** @category Internals */\n declare _instanceID: string;\n\n /** @internal This is only a marker type and doesn't exist at runtime */\n [ItemsSym]!: Item;\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static _schema: any;\n /** @internal */\n get _schema(): {\n [ItemsSym]: SchemaFor<Item>;\n } {\n return (this.constructor as typeof CoList)._schema;\n }\n\n /** @category Collaboration */\n get _owner(): Account | Group {\n return this._raw.group instanceof RawAccount\n ? RegisteredSchemas[\"Account\"].fromRaw(this._raw.group)\n : RegisteredSchemas[\"Group\"].fromRaw(this._raw.group);\n }\n\n /**\n * If a `CoList`'s items are a `co.ref(...)`, you can use `coList._refs[i]` to access\n * the `Ref` instead of the potentially loaded/null value.\n *\n * This allows you to always get the ID or load the value manually.\n *\n * @example\n * ```ts\n * animals._refs[0].id; // => ID<Animal>\n * animals._refs[0].value;\n * // => Animal | null\n * const animal = await animals._refs[0].load();\n * ```\n *\n * @category Content\n **/\n get _refs(): {\n [idx: number]: Exclude<Item, null> extends CoValue\n ? Ref<UnCo<Exclude<Item, null>>>\n : never;\n } & {\n length: number;\n [Symbol.iterator](): IterableIterator<\n Exclude<Item, null> extends CoValue ? Ref<Exclude<Item, null>> : never\n >;\n } {\n return makeRefs<number>(\n (idx) => this._raw.get(idx) as unknown as ID<CoValue>,\n () => Array.from({ length: this._raw.entries().length }, (_, idx) => idx),\n this._loadedAs,\n (_idx) => this._schema[ItemsSym] as RefEncoded<CoValue>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n }\n\n get _edits(): {\n [idx: number]: {\n value?: Item;\n ref?: Item extends CoValue ? Ref<Item> : never;\n by?: Account;\n madeAt: Date;\n };\n } {\n throw new Error(\"Not implemented\");\n }\n\n get _loadedAs() {\n const rawAccount = this._raw.core.node.account;\n\n if (rawAccount instanceof RawAccount) {\n return coValuesCache.get(rawAccount, () =>\n RegisteredSchemas[\"Account\"].fromRaw(rawAccount),\n );\n }\n\n return new AnonymousJazzAgent(this._raw.core.node);\n }\n\n static get [Symbol.species]() {\n return Array;\n }\n\n constructor(options: { fromRaw: RawCoList } | undefined) {\n super();\n\n Object.defineProperty(this, \"_instanceID\", {\n value: `instance-${Math.random().toString(36).slice(2)}`,\n enumerable: false,\n });\n\n if (options && \"fromRaw\" in options) {\n Object.defineProperties(this, {\n id: {\n value: options.fromRaw.id,\n enumerable: false,\n },\n _raw: { value: options.fromRaw, enumerable: false },\n });\n }\n\n return new Proxy(this, CoListProxyHandler as ProxyHandler<this>);\n }\n\n /**\n * Create a new CoList with the given initial values and owner.\n *\n * The owner (a Group or Account) determines access rights to the CoMap.\n *\n * The CoList will immediately be persisted and synced to connected peers.\n *\n * @example\n * ```ts\n * const colours = ColorList.create(\n * [\"red\", \"green\", \"blue\"],\n * { owner: me }\n * );\n * const animals = AnimalList.create(\n * [cat, dog, fish],\n * { owner: me }\n * );\n * ```\n *\n * @category Creation\n **/\n static create<L extends CoList>(\n this: CoValueClass<L>,\n items: UnCo<L[number]>[],\n options: { owner: Account | Group },\n ) {\n const instance = new this({ init: items, owner: options.owner });\n const raw = options.owner._raw.createList(\n toRawItems(items, instance._schema[ItemsSym]),\n );\n\n Object.defineProperties(instance, {\n id: {\n value: raw.id,\n enumerable: false,\n },\n _raw: { value: raw, enumerable: false },\n });\n\n return instance;\n }\n\n push(...items: Item[]): number {\n for (const item of toRawItems(items as Item[], this._schema[ItemsSym])) {\n this._raw.append(item);\n }\n\n return this._raw.entries().length;\n }\n\n unshift(...items: Item[]): number {\n for (const item of toRawItems(items as Item[], this._schema[ItemsSym])) {\n this._raw.prepend(item);\n }\n\n return this._raw.entries().length;\n }\n\n pop(): Item | undefined {\n const last = this[this.length - 1];\n\n this._raw.delete(this.length - 1);\n\n return last;\n }\n\n shift(): Item | undefined {\n const first = this[0];\n\n this._raw.delete(0);\n\n return first;\n }\n\n splice(start: number, deleteCount: number, ...items: Item[]): Item[] {\n const deleted = this.slice(start, start + deleteCount);\n\n for (\n let idxToDelete = start + deleteCount - 1;\n idxToDelete >= start;\n idxToDelete--\n ) {\n this._raw.delete(idxToDelete);\n }\n\n let appendAfter = Math.max(start - 1, 0);\n for (const item of toRawItems(items as Item[], this._schema[ItemsSym])) {\n console.log(this._raw.asArray(), appendAfter);\n this._raw.append(item, appendAfter);\n appendAfter++;\n }\n\n return deleted;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(_key?: string, seenAbove?: ID<CoValue>[]): any[] {\n const itemDescriptor = this._schema[ItemsSym] as Schema;\n if (itemDescriptor === \"json\") {\n return this._raw.asArray();\n } else if (\"encoded\" in itemDescriptor) {\n return this._raw.asArray().map((e) => itemDescriptor.encoded.encode(e));\n } else if (isRefEncoded(itemDescriptor)) {\n return this.map((item, idx) =>\n seenAbove?.includes((item as CoValue)?.id)\n ? { _circular: (item as CoValue).id }\n : (item as unknown as CoValue)?.toJSON(idx + \"\", [\n ...(seenAbove || []),\n this.id,\n ]),\n );\n } else {\n return [];\n }\n }\n\n [inspect]() {\n return this.toJSON();\n }\n\n /** @category Internals */\n static fromRaw<V extends CoList>(\n this: CoValueClass<V> & typeof CoList,\n raw: RawCoList,\n ) {\n return new this({ fromRaw: raw });\n }\n\n /** @internal */\n static schema<V extends CoList>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: { new (...args: any): V } & typeof CoList,\n def: { [ItemsSym]: V[\"_schema\"][ItemsSym] },\n ) {\n this._schema ||= {};\n Object.assign(this._schema, def);\n }\n\n /**\n * Load a `CoList` with a given ID, as a given account.\n *\n * `depth` specifies if item CoValue references should be loaded as well before resolving.\n * The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.\n *\n * You can pass `[]` or for shallowly loading only this CoList, or `[itemDepth]` for recursively loading referenced CoValues.\n *\n * Check out the `load` methods on `CoMap`/`CoList`/`CoFeed`/`Group`/`Account` to see which depth structures are valid to nest.\n *\n * @example\n * ```ts\n * const animalsWithVets =\n * await ListOfAnimals.load(\n * \"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax\",\n * me,\n * [{ vet: {} }]\n * );\n * ```\n *\n * @category Subscription & Loading\n */\n static load<L extends CoList, Depth>(\n this: CoValueClass<L>,\n id: ID<L>,\n as: Account,\n depth: Depth & DepthsIn<L>,\n ): Promise<DeeplyLoaded<L, Depth> | undefined> {\n return loadCoValue(this, id, as, depth);\n }\n\n /**\n * Load and subscribe to a `CoList` with a given ID, as a given account.\n *\n * Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.\n *\n * `depth` specifies if item CoValue references should be loaded as well before calling `listener` for the first time.\n * The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.\n *\n * You can pass `[]` or for shallowly loading only this CoList, or `[itemDepth]` for recursively loading referenced CoValues.\n *\n * Check out the `load` methods on `CoMap`/`CoList`/`CoFeed`/`Group`/`Account` to see which depth structures are valid to nest.\n *\n * Returns an unsubscribe function that you should call when you no longer need updates.\n *\n * Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.\n *\n * @example\n * ```ts\n * const unsub = ListOfAnimals.subscribe(\n * \"co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax\",\n * me,\n * { vet: {} },\n * (animalsWithVets) => console.log(animalsWithVets)\n * );\n * ```\n *\n * @category Subscription & Loading\n */\n static subscribe<L extends CoList, Depth>(\n this: CoValueClass<L>,\n id: ID<L>,\n as: Account,\n depth: Depth & DepthsIn<L>,\n listener: (value: DeeplyLoaded<L, Depth>) => void,\n ): () => void {\n return subscribeToCoValue<L, Depth>(this, id, as, depth, listener);\n }\n\n /**\n * Given an already loaded `CoList`, ensure that items are loaded to the specified depth.\n *\n * Works like `CoList.load()`, but you don't need to pass the ID or the account to load as again.\n *\n * @category Subscription & Loading\n */\n ensureLoaded<L extends CoList, Depth>(\n this: L,\n depth: Depth & DepthsIn<L>,\n ): Promise<DeeplyLoaded<L, Depth> | undefined> {\n return ensureCoValueLoaded(this, depth);\n }\n\n /**\n * Given an already loaded `CoList`, subscribe to updates to the `CoList` and ensure that items are loaded to the specified depth.\n *\n * Works like `CoList.subscribe()`, but you don't need to pass the ID or the account to load as again.\n *\n * Returns an unsubscribe function that you should call when you no longer need updates.\n *\n * @category Subscription & Loading\n **/\n subscribe<L extends CoList, Depth>(\n this: L,\n depth: Depth & DepthsIn<L>,\n listener: (value: DeeplyLoaded<L, Depth>) => void,\n ): () => void {\n return subscribeToExistingCoValue(this, depth, listener);\n }\n\n /** @category Type Helpers */\n castAs<Cl extends CoValueClass & CoValueFromRaw<CoValue>>(\n cl: Cl,\n ): InstanceType<Cl> {\n const casted = cl.fromRaw(this._raw) as InstanceType<Cl>;\n const subscriptionScope = subscriptionsScopes.get(this);\n if (subscriptionScope) {\n subscriptionsScopes.set(casted, subscriptionScope);\n }\n return casted;\n }\n\n /**\n * Wait for the `CoList` to be uploaded to the other peers.\n *\n * @category Subscription & Loading\n */\n waitForSync(options?: { timeout?: number }) {\n return this._raw.core.waitForSync(options);\n }\n}\n\nfunction toRawItems<Item>(items: Item[], itemDescriptor: Schema) {\n const rawItems =\n itemDescriptor === \"json\"\n ? (items as JsonValue[])\n : \"encoded\" in itemDescriptor\n ? items?.map((e) => itemDescriptor.encoded.encode(e))\n : isRefEncoded(itemDescriptor)\n ? items?.map((v) => (v as unknown as CoValue).id)\n : (() => {\n throw new Error(\"Invalid element descriptor\");\n })();\n return rawItems;\n}\n\nconst CoListProxyHandler: ProxyHandler<CoList> = {\n get(target, key, receiver) {\n if (typeof key === \"string\" && !isNaN(+key)) {\n const itemDescriptor = target._schema[ItemsSym] as Schema;\n const rawValue = target._raw.get(Number(key));\n if (itemDescriptor === \"json\") {\n return rawValue;\n } else if (\"encoded\" in itemDescriptor) {\n return rawValue === undefined\n ? undefined\n : itemDescriptor.encoded.decode(rawValue);\n } else if (isRefEncoded(itemDescriptor)) {\n return rawValue === undefined\n ? undefined\n : new Ref(\n rawValue as unknown as ID<CoValue>,\n target._loadedAs,\n itemDescriptor,\n ).accessFrom(receiver, Number(key));\n }\n } else if (key === \"length\") {\n return target._raw.entries().length;\n } else {\n return Reflect.get(target, key, receiver);\n }\n },\n set(target, key, value, receiver) {\n if (key === ItemsSym && typeof value === \"object\" && SchemaInit in value) {\n (target.constructor as typeof CoList)._schema ||= {};\n (target.constructor as typeof CoList)._schema[ItemsSym] =\n value[SchemaInit];\n return true;\n }\n if (typeof key === \"string\" && !isNaN(+key)) {\n const itemDescriptor = target._schema[ItemsSym] as Schema;\n let rawValue;\n if (itemDescriptor === \"json\") {\n rawValue = value;\n } else if (\"encoded\" in itemDescriptor) {\n rawValue = itemDescriptor.encoded.encode(value);\n } else if (isRefEncoded(itemDescriptor)) {\n rawValue = value.id;\n }\n target._raw.replace(Number(key), rawValue);\n return true;\n } else {\n return Reflect.set(target, key, value, receiver);\n }\n },\n defineProperty(target, key, descriptor) {\n if (\n descriptor.value &&\n key === ItemsSym &&\n typeof descriptor.value === \"object\" &&\n SchemaInit in descriptor.value\n ) {\n (target.constructor as typeof CoList)._schema ||= {};\n (target.constructor as typeof CoList)._schema[ItemsSym] =\n descriptor.value[SchemaInit];\n return true;\n } else {\n return Reflect.defineProperty(target, key, descriptor);\n }\n },\n has(target, key) {\n if (typeof key === \"string\" && !isNaN(+key)) {\n return Number(key) < target._raw.entries().length;\n } else {\n return Reflect.has(target, key);\n }\n },\n};\n","import { co, subscriptionsScopes } from \"../../internal.js\";\nimport { FileStream } from \"../coFeed.js\";\nimport { CoMap } from \"../coMap.js\";\n\n/** @category Media */\nexport class ImageDefinition extends CoMap {\n originalSize = co.json<[number, number]>();\n placeholderDataURL? = co.string;\n\n [co.items] = co.ref(FileStream);\n [res: `${number}x${number}`]: co<FileStream | null>;\n\n highestResAvailable(options?: {\n maxWidth?: number;\n }): { res: `${number}x${number}`; stream: FileStream } | undefined {\n if (!subscriptionsScopes.get(this)) {\n console.warn(\n \"highestResAvailable() only makes sense when used within a subscription.\",\n );\n }\n\n const resolutions = Object.keys(this).filter(\n (key) =>\n key.match(/^\\d+x\\d+$/) &&\n (options?.maxWidth === undefined ||\n Number(key.split(\"x\")[0]) <= options.maxWidth),\n ) as `${number}x${number}`[];\n\n resolutions.sort((a, b) => {\n const aWidth = Number(a.split(\"x\")[0]);\n const bWidth = Number(b.split(\"x\")[0]);\n return aWidth - bWidth;\n });\n\n let highestAvailableResolution: `${number}x${number}` | undefined;\n\n for (const resolution of resolutions) {\n if (this[resolution] && this[resolution]?.getChunks()) {\n highestAvailableResolution = resolution;\n } else {\n return (\n highestAvailableResolution && {\n res: highestAvailableResolution,\n stream: this[highestAvailableResolution]!,\n }\n );\n }\n }\n return (\n highestAvailableResolution && {\n res: highestAvailableResolution,\n stream: this[highestAvailableResolution]!,\n }\n );\n }\n}\n","import {\n CoValue,\n CoValueBase,\n CoValueClass,\n CoValueFromRaw,\n} from \"../internal.js\";\n\n/**\n * SchemaUnion allows you to create union types of CoValues that can be discriminated at runtime.\n *\n * @categoryDescription Declaration\n * Declare your union types by extending `SchemaUnion.Of(...)` and passing a discriminator function that determines which concrete type to use based on the raw data.\n *\n * ```ts\n * import { SchemaUnion, CoMap } from \"jazz-tools\";\n *\n * class BaseWidget extends CoMap {\n * type = co.string;\n * }\n *\n * class ButtonWidget extends BaseWidget {\n * type = co.literal(\"button\");\n * label = co.string;\n * }\n *\n * class SliderWidget extends BaseWidget {\n * type = co.literal(\"slider\");\n * min = co.number;\n * max = co.number;\n * }\n *\n * const WidgetUnion = SchemaUnion.Of<BaseWidget>((raw) => {\n * switch (raw.get(\"type\")) {\n * case \"button\": return ButtonWidget;\n * case \"slider\": return SliderWidget;\n * default: throw new Error(\"Unknown widget type\");\n * }\n * });\n * ```\n *\n * @category CoValues\n */\nexport abstract class SchemaUnion extends CoValueBase implements CoValue {\n /**\n * Create a new union type from a discriminator function.\n *\n * The discriminator function receives the raw data and should return the appropriate concrete class to use for that data.\n *\n * When loading a SchemaUnion, the correct subclass will be instantiated based on the discriminator.\n *\n * @param discriminator - Function that determines which concrete type to use\n * @returns A new class that can create/load instances of the union type\n *\n * @example\n * ```ts\n * const WidgetUnion = SchemaUnion.Of<BaseWidget>((raw) => {\n * switch (raw.get(\"type\")) {\n * case \"button\": return ButtonWidget;\n * case \"slider\": return SliderWidget;\n * default: throw new Error(\"Unknown widget type\");\n * }\n * });\n *\n * const widget = await loadCoValue(WidgetUnion, id, me, {});\n *\n * // You can narrow the returned instance to a subclass by using `instanceof`\n * if (widget instanceof ButtonWidget) {\n * console.log(widget.label);\n * } else if (widget instanceof SliderWidget) {\n * console.log(widget.min, widget.max);\n * }\n * ```\n *\n * @category Declaration\n **/\n static Of<V extends CoValue>(\n discriminator: (raw: V[\"_raw\"]) => CoValueClass<V> & CoValueFromRaw<V>,\n ): CoValueClass<V> & typeof SchemaUnion {\n return class SchemaUnionClass extends SchemaUnion {\n static override fromRaw<T extends CoValue>(\n this: CoValueClass<T> & CoValueFromRaw<T>,\n raw: T[\"_raw\"],\n ): T {\n const ResolvedClass = discriminator(\n raw as V[\"_raw\"],\n ) as unknown as CoValueClass<T> & CoValueFromRaw<T>;\n return ResolvedClass.fromRaw(raw);\n }\n } as unknown as CoValueClass<V> & typeof SchemaUnion;\n }\n\n /**\n * Create an instance from raw data. This is called internally and should not be used directly.\n * Use {@link SchemaUnion.Of} to create a union type instead.\n *\n * @internal\n */\n // @ts-ignore\n static fromRaw<V extends CoValue>(this: CoValueClass<V>, raw: V[\"_raw\"]): V {\n throw new Error(\"Not implemented\");\n }\n}\n"],"mappings":";AAEO,IAAM,qBAAN,MAAyB;AAAA,EAE9B,YAAmB,MAAiB;AAAjB;AADnB,iBAAQ;AAAA,EAC6B;AACvC;;;ACJA,SAAS,cAAAA,mBAAkB;;;ACDpB,IAAM,aAAa,OAAO,IAAI,YAAY;AAG1C,IAAM,WAAW,OAAO,IAAI,OAAO;AAGnC,IAAM,aAAa,OAAO,IAAI,SAAS;;;ACNvC,IAAM,UAAU,OAAO,IAAI,4BAA4B;;;ACG9D,IAAM,UAAU,oBAAI,QAA6B;AAE1C,IAAM,gBAAgB;AAAA,EAC3B,KAAK,CAAoB,KAAiB,YAAqB;AAC7D,UAAM,SAAS,QAAQ,IAAI,GAAG;AAC9B,QAAI,QAAQ;AACV,aAAO;AAAA,IACT;AACA,UAAM,WAAW,QAAQ;AACzB,YAAQ,IAAI,KAAK,QAAQ;AACzB,WAAO;AAAA,EACT;AACF;;;ACCA,IAAM,iBAAiB;AAEhB,IAAM,MAAN,MAAM,KAA2B;AAAA,EACtC,YACW,IACA,mBACA,QACT;AAHS;AACA;AACA;AAET,QAAI,CAAC,aAAa,MAAM,GAAG;AACzB,YAAM,IAAI,MAAM,2CAA2C;AAAA,IAC7D;AAAA,EACF;AAAA,EAEA,IAAI,QAAQ;AACV,UAAM,OACJ,UAAU,KAAK,oBACX,KAAK,kBAAkB,OACvB,KAAK,kBAAkB,KAAK,KAAK;AACvC,UAAM,MAAM,KAAK,UAAU,KAAK,EAAiC;AACjE,QAAI,KAAK;AACP,aAAO,cAAc;AAAA,QAAI;AAAA,QAAK,MAC5B,sBAAsB,KAAK,QAAQ,GAAG;AAAA,MACxC;AAAA,IACF,OAAO;AACL,aAAO;AAAA,IACT;AAAA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AA,EAiCvE,OAAO,GACL,eACsC;AACtC,WAAO,MAAM,yBAAyB,aAAY;AAAA,MAChD,OAAgB,QAEd,KACG;AACH,cAAM,gBAAgB;AAAA,UACpB;AAAA,QACF;AACA,eAAO,cAAc,QAAQ,GAAG;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,OAAO,QAAkD,KAAmB;AAC1E,UAAM,IAAI,MAAM,iBAAiB;AAAA,EACnC;AACF;","names":["RawAccount","key","account","RawAccount","ref","RawAccount","RawAccount","message","rawEdit","_a","_b","LocalNode","RawAccount","cojsonInternals","RawAccount","LocalNode","cojsonInternals","ref","ref","cojsonInternals","_a","_b","rawEntry","cojsonInternals","RawAccount","_a","_b","RawAccount"]}
|
package/dist/index.native.js
CHANGED
package/dist/index.web.js
CHANGED