jazz-tools 0.7.0-alpha.9 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +3 -10
- package/.prettierrc.js +9 -0
- package/.turbo/turbo-build.log +14 -15
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +140 -0
- package/CHANGELOG.md +331 -27
- package/LICENSE.txt +1 -1
- package/README.md +10 -2
- package/dist/coValues/account.js +86 -41
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +75 -48
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +167 -44
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +192 -35
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/deepLoading.js +60 -0
- package/dist/coValues/deepLoading.js.map +1 -0
- package/dist/coValues/extensions/imageDef.js +10 -7
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +73 -13
- package/dist/coValues/group.js.map +1 -1
- package/dist/coValues/interfaces.js +58 -35
- package/dist/coValues/interfaces.js.map +1 -1
- package/dist/implementation/devtoolsFormatters.js +114 -0
- package/dist/implementation/devtoolsFormatters.js.map +1 -0
- package/dist/implementation/refs.js +58 -18
- package/dist/implementation/refs.js.map +1 -1
- package/dist/implementation/schema.js +58 -0
- package/dist/implementation/schema.js.map +1 -0
- package/dist/implementation/subscriptionScope.js +19 -1
- package/dist/implementation/subscriptionScope.js.map +1 -1
- package/dist/implementation/symbols.js +5 -0
- package/dist/implementation/symbols.js.map +1 -0
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.js +5 -2
- package/dist/internal.js.map +1 -1
- package/dist/tests/coList.test.js +51 -48
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +131 -74
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +56 -41
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/deepLoading.test.js +188 -0
- package/dist/tests/deepLoading.test.js.map +1 -0
- package/dist/tests/groupsAndAccounts.test.js +83 -0
- package/dist/tests/groupsAndAccounts.test.js.map +1 -0
- package/package.json +17 -9
- package/src/coValues/account.ts +186 -128
- package/src/coValues/coList.ts +156 -107
- package/src/coValues/coMap.ts +272 -148
- package/src/coValues/coStream.ts +388 -87
- package/src/coValues/deepLoading.ts +229 -0
- package/src/coValues/extensions/imageDef.ts +17 -13
- package/src/coValues/group.ts +166 -59
- package/src/coValues/interfaces.ts +189 -160
- package/src/implementation/devtoolsFormatters.ts +110 -0
- package/src/implementation/inspect.ts +1 -1
- package/src/implementation/refs.ts +80 -28
- package/src/implementation/schema.ts +141 -0
- package/src/implementation/subscriptionScope.ts +48 -12
- package/src/implementation/symbols.ts +11 -0
- package/src/index.ts +19 -8
- package/src/internal.ts +7 -3
- package/src/tests/coList.test.ts +77 -62
- package/src/tests/coMap.test.ts +201 -114
- package/src/tests/coStream.test.ts +113 -84
- package/src/tests/deepLoading.test.ts +304 -0
- package/src/tests/groupsAndAccounts.test.ts +91 -0
- package/dist/implementation/encoding.js +0 -26
- package/dist/implementation/encoding.js.map +0 -1
- package/src/implementation/encoding.ts +0 -105
package/dist/coValues/account.js
CHANGED
@@ -1,40 +1,30 @@
|
|
1
1
|
var _a;
|
2
2
|
import { LocalNode } from "cojson";
|
3
3
|
import { Context } from "effect";
|
4
|
-
import { CoValueBase, Profile, Ref, SchemaInit, inspect, subscriptionsScopes, } from "../internal.js";
|
4
|
+
import { Group, CoValueBase, MembersSym, Profile, Ref, SchemaInit, inspect, subscriptionsScopes, loadCoValue, loadCoValueEf, subscribeToCoValue, subscribeToCoValueEf, ensureCoValueLoaded, subscribeToExistingCoValue, } from "../internal.js";
|
5
|
+
/** @category Identity & Permissions */
|
5
6
|
export class Account extends CoValueBase {
|
6
|
-
get
|
7
|
-
return this.constructor.
|
7
|
+
get _schema() {
|
8
|
+
return this.constructor._schema;
|
8
9
|
}
|
9
10
|
get _owner() {
|
10
11
|
return this;
|
11
12
|
}
|
12
13
|
get _loadedAs() {
|
13
|
-
return this.isMe
|
14
|
-
? this
|
15
|
-
: _a.fromNode(this._raw.core.node);
|
14
|
+
return this.isMe ? this : _a.fromNode(this._raw.core.node);
|
16
15
|
}
|
17
16
|
get _refs() {
|
18
17
|
const profileID = this._raw.get("profile");
|
19
18
|
const rootID = this._raw.get("root");
|
20
19
|
return {
|
21
20
|
profile: profileID &&
|
22
|
-
new Ref(profileID, this._loadedAs, this.
|
21
|
+
new Ref(profileID, this._loadedAs, this._schema.profile),
|
23
22
|
root: rootID &&
|
24
|
-
new Ref(rootID, this._loadedAs, this.
|
23
|
+
new Ref(rootID, this._loadedAs, this._schema.root),
|
25
24
|
};
|
26
25
|
}
|
27
|
-
constructor(
|
26
|
+
constructor(options) {
|
28
27
|
super();
|
29
|
-
this.acceptInvite = (async (valueID, inviteSecret, coValueClass) => {
|
30
|
-
if (!this.isMe) {
|
31
|
-
throw new Error("Only a controlled account can accept invites");
|
32
|
-
}
|
33
|
-
await this._raw.acceptInvite(valueID, inviteSecret);
|
34
|
-
return coValueClass.load(valueID, {
|
35
|
-
as: this,
|
36
|
-
});
|
37
|
-
});
|
38
28
|
if (!("fromRaw" in options)) {
|
39
29
|
throw new Error("Can only construct account from raw or with .create()");
|
40
30
|
}
|
@@ -45,10 +35,10 @@ export class Account extends CoValueBase {
|
|
45
35
|
enumerable: false,
|
46
36
|
},
|
47
37
|
_raw: { value: options.fromRaw, enumerable: false },
|
38
|
+
_type: { value: "Account", enumerable: false },
|
48
39
|
});
|
49
40
|
if (this.isMe) {
|
50
|
-
this.sessionID =
|
51
|
-
options.fromRaw.core.node.currentSessionID;
|
41
|
+
this.sessionID = options.fromRaw.core.node.currentSessionID;
|
52
42
|
}
|
53
43
|
return new Proxy(this, AccountAndGroupProxyHandler);
|
54
44
|
}
|
@@ -57,14 +47,22 @@ export class Account extends CoValueBase {
|
|
57
47
|
return "admin";
|
58
48
|
}
|
59
49
|
}
|
50
|
+
async acceptInvite(valueID, inviteSecret, coValueClass) {
|
51
|
+
if (!this.isMe) {
|
52
|
+
throw new Error("Only a controlled account can accept invites");
|
53
|
+
}
|
54
|
+
await this._raw.acceptInvite(valueID, inviteSecret);
|
55
|
+
return loadCoValue(coValueClass, valueID, this, []);
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
57
|
+
}
|
60
58
|
static async create(options) {
|
61
59
|
const { node } = await LocalNode.withNewlyCreatedAccount({
|
62
60
|
...options,
|
63
|
-
migration: async (rawAccount) => {
|
64
|
-
const account = new this(
|
61
|
+
migration: async (rawAccount, _node, creationProps) => {
|
62
|
+
const account = new this({
|
65
63
|
fromRaw: rawAccount,
|
66
64
|
});
|
67
|
-
await account.migrate?.();
|
65
|
+
await account.migrate?.(creationProps);
|
68
66
|
},
|
69
67
|
});
|
70
68
|
return this.fromNode(node);
|
@@ -75,20 +73,22 @@ export class Account extends CoValueBase {
|
|
75
73
|
accountSecret: options.accountSecret,
|
76
74
|
sessionID: options.sessionID,
|
77
75
|
peersToLoadFrom: options.peersToLoadFrom,
|
78
|
-
|
79
|
-
|
76
|
+
crypto: options.crypto,
|
77
|
+
migration: async (rawAccount, _node, creationProps) => {
|
78
|
+
const account = new this({
|
80
79
|
fromRaw: rawAccount,
|
81
80
|
});
|
82
|
-
await account.migrate?.();
|
81
|
+
await account.migrate?.(creationProps);
|
83
82
|
},
|
84
83
|
});
|
85
84
|
return this.fromNode(node);
|
86
85
|
}
|
87
86
|
static fromNode(node) {
|
88
|
-
return new this(
|
87
|
+
return new this({
|
89
88
|
fromRaw: node.account,
|
90
89
|
});
|
91
90
|
}
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
92
92
|
toJSON() {
|
93
93
|
return {
|
94
94
|
id: this.id,
|
@@ -98,23 +98,62 @@ export class Account extends CoValueBase {
|
|
98
98
|
[inspect]() {
|
99
99
|
return this.toJSON();
|
100
100
|
}
|
101
|
+
migrate(creationProps) {
|
102
|
+
if (creationProps) {
|
103
|
+
const profileGroup = Group.create({ owner: this });
|
104
|
+
profileGroup.addMember("everyone", "reader");
|
105
|
+
this.profile = Profile.create({ name: creationProps.name }, { owner: profileGroup });
|
106
|
+
}
|
107
|
+
}
|
108
|
+
/** @category Subscription & Loading */
|
109
|
+
static load(id, as, depth) {
|
110
|
+
return loadCoValue(this, id, as, depth);
|
111
|
+
}
|
112
|
+
/** @category Subscription & Loading */
|
113
|
+
static loadEf(id, depth) {
|
114
|
+
return loadCoValueEf(this, id, depth);
|
115
|
+
}
|
116
|
+
/** @category Subscription & Loading */
|
117
|
+
static subscribe(id, as, depth, listener) {
|
118
|
+
return subscribeToCoValue(this, id, as, depth, listener);
|
119
|
+
}
|
120
|
+
/** @category Subscription & Loading */
|
121
|
+
static subscribeEf(id, depth) {
|
122
|
+
return subscribeToCoValueEf(this, id, depth);
|
123
|
+
}
|
124
|
+
/** @category Subscription & Loading */
|
125
|
+
ensureLoaded(depth) {
|
126
|
+
return ensureCoValueLoaded(this, depth);
|
127
|
+
}
|
128
|
+
/** @category Subscription & Loading */
|
129
|
+
subscribe(depth, listener) {
|
130
|
+
return subscribeToExistingCoValue(this, depth, listener);
|
131
|
+
}
|
101
132
|
}
|
102
133
|
_a = Account;
|
103
134
|
(() => {
|
104
|
-
_a.
|
105
|
-
profile: {
|
106
|
-
|
135
|
+
_a._schema = {
|
136
|
+
profile: {
|
137
|
+
ref: () => Profile,
|
138
|
+
optional: false,
|
139
|
+
},
|
140
|
+
root: "json",
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
107
142
|
};
|
108
143
|
})();
|
109
144
|
export const AccountAndGroupProxyHandler = {
|
110
145
|
get(target, key, receiver) {
|
111
146
|
if (key === "profile") {
|
112
147
|
const ref = target._refs.profile;
|
113
|
-
return ref
|
148
|
+
return ref
|
149
|
+
? ref.accessFrom(receiver, "profile")
|
150
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
151
|
+
undefined;
|
114
152
|
}
|
115
153
|
else if (key === "root") {
|
116
154
|
const ref = target._refs.root;
|
117
|
-
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
156
|
+
return ref ? ref.accessFrom(receiver, "root") : undefined;
|
118
157
|
}
|
119
158
|
else {
|
120
159
|
return Reflect.get(target, key, receiver);
|
@@ -122,26 +161,30 @@ export const AccountAndGroupProxyHandler = {
|
|
122
161
|
},
|
123
162
|
set(target, key, value, receiver) {
|
124
163
|
var _b;
|
125
|
-
if ((key === "profile" || key === "root") &&
|
164
|
+
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
126
165
|
typeof value === "object" &&
|
127
166
|
SchemaInit in value) {
|
128
|
-
(_b = target.constructor).
|
129
|
-
target.constructor.
|
167
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
168
|
+
target.constructor._schema[key] =
|
130
169
|
value[SchemaInit];
|
131
170
|
return true;
|
132
171
|
}
|
133
172
|
else if (key === "profile") {
|
134
173
|
if (value) {
|
135
|
-
target._raw.set("profile", value.id);
|
174
|
+
target._raw.set("profile", value.id, "trusting");
|
136
175
|
}
|
137
|
-
subscriptionsScopes
|
176
|
+
subscriptionsScopes
|
177
|
+
.get(receiver)
|
178
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
138
179
|
return true;
|
139
180
|
}
|
140
181
|
else if (key === "root") {
|
141
182
|
if (value) {
|
142
183
|
target._raw.set("root", value.id);
|
143
184
|
}
|
144
|
-
subscriptionsScopes
|
185
|
+
subscriptionsScopes
|
186
|
+
.get(receiver)
|
187
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
145
188
|
return true;
|
146
189
|
}
|
147
190
|
else {
|
@@ -150,11 +193,11 @@ export const AccountAndGroupProxyHandler = {
|
|
150
193
|
},
|
151
194
|
defineProperty(target, key, descriptor) {
|
152
195
|
var _b;
|
153
|
-
if ((key === "profile" || key === "root") &&
|
196
|
+
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
154
197
|
typeof descriptor.value === "object" &&
|
155
198
|
SchemaInit in descriptor.value) {
|
156
|
-
(_b = target.constructor).
|
157
|
-
target.constructor.
|
199
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
200
|
+
target.constructor._schema[key] =
|
158
201
|
descriptor.value[SchemaInit];
|
159
202
|
return true;
|
160
203
|
}
|
@@ -163,8 +206,10 @@ export const AccountAndGroupProxyHandler = {
|
|
163
206
|
}
|
164
207
|
},
|
165
208
|
};
|
209
|
+
/** @category Identity & Permissions */
|
166
210
|
export class AccountCtx extends Context.Tag("Account")() {
|
167
211
|
}
|
212
|
+
/** @category Identity & Permissions */
|
168
213
|
export function isControlledAccount(account) {
|
169
214
|
return account.isMe;
|
170
215
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAanC,OAAO,EAAE,OAAO,EAAkB,MAAM,QAAQ,CAAC;AAajD,OAAO,EACH,KAAK,EACL,WAAW,EACX,UAAU,EACV,OAAO,EACP,GAAG,EACH,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,GAC7B,MAAM,gBAAgB,CAAC;AAExB,uCAAuC;AACvC,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAOpC,IAAI,OAAO;QAIP,OAAQ,IAAI,CAAC,WAA8B,CAAC,OAAO,CAAC;IACxD,CAAC;IAYD,IAAI,MAAM;QACN,OAAO,IAAe,CAAC;IAC3B,CAAC;IACD,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAA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}
|
package/dist/coValues/coList.js
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
var _a;
|
2
2
|
import { RawAccount } from "cojson";
|
3
|
-
import { Account,
|
4
|
-
import {
|
3
|
+
import { Account, Group, InitValues, ItemsSym, Ref, SchemaInit, co, ensureCoValueLoaded, inspect, isRefEncoded, loadCoValue, loadCoValueEf, makeRefs, subscribeToCoValue, subscribeToCoValueEf, subscribeToExistingCoValue, } from "../internal.js";
|
4
|
+
import { encodeSync, decodeSync } from "@effect/schema/Schema";
|
5
|
+
/** @category CoValues */
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5
7
|
export class CoList extends Array {
|
6
8
|
static Of(item) {
|
7
9
|
var _b, _c;
|
10
|
+
// TODO: cache superclass for item class
|
8
11
|
return _c = class CoListOf extends _a {
|
9
12
|
constructor() {
|
10
13
|
super(...arguments);
|
11
14
|
this[_b] = item;
|
12
15
|
}
|
13
16
|
},
|
14
|
-
_b =
|
17
|
+
_b = co.items,
|
15
18
|
_c;
|
16
19
|
}
|
17
20
|
/** @deprecated Use UPPERCASE `CoList.Of` instead! */
|
18
21
|
static of(..._args) {
|
19
22
|
throw new Error("Can't use Array.of with CoLists");
|
20
23
|
}
|
21
|
-
get
|
22
|
-
return this.constructor.
|
24
|
+
get _schema() {
|
25
|
+
return this.constructor._schema;
|
23
26
|
}
|
24
27
|
get _owner() {
|
25
28
|
return this._raw.group instanceof RawAccount
|
26
29
|
? Account.fromRaw(this._raw.group)
|
27
30
|
: Group.fromRaw(this._raw.group);
|
28
31
|
}
|
32
|
+
/** @category Content */
|
29
33
|
get _refs() {
|
30
|
-
return makeRefs((idx) => this._raw.get(idx), () => Array.from({ length: this._raw.entries().length }, (_, idx) => idx), this._loadedAs, (_idx) => this.
|
34
|
+
return makeRefs((idx) => this._raw.get(idx), () => Array.from({ length: this._raw.entries().length }, (_, idx) => idx), this._loadedAs, (_idx) => this._schema[ItemsSym]);
|
31
35
|
}
|
32
36
|
get _edits() {
|
33
37
|
throw new Error("Not implemented");
|
@@ -38,14 +42,15 @@ export class CoList extends Array {
|
|
38
42
|
static get [Symbol.species]() {
|
39
43
|
return Array;
|
40
44
|
}
|
41
|
-
constructor(
|
45
|
+
constructor(options) {
|
42
46
|
super();
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
Object.defineProperty(this, "_instanceID", {
|
48
|
+
value: `instance-${Math.random().toString(36).slice(2)}`,
|
49
|
+
enumerable: false,
|
50
|
+
});
|
51
|
+
if ("owner" in options) {
|
47
52
|
this[InitValues] = {
|
48
|
-
init,
|
53
|
+
init: options.init,
|
49
54
|
owner: options.owner,
|
50
55
|
};
|
51
56
|
}
|
@@ -60,14 +65,17 @@ export class CoList extends Array {
|
|
60
65
|
}
|
61
66
|
return new Proxy(this, CoListProxyHandler);
|
62
67
|
}
|
68
|
+
static create(items, options) {
|
69
|
+
return new this({ init: items, owner: options.owner });
|
70
|
+
}
|
63
71
|
push(...items) {
|
64
|
-
for (const item of toRawItems(items, this.
|
72
|
+
for (const item of toRawItems(items, this._schema[ItemsSym])) {
|
65
73
|
this._raw.append(item);
|
66
74
|
}
|
67
75
|
return this._raw.entries().length;
|
68
76
|
}
|
69
77
|
unshift(...items) {
|
70
|
-
for (const item of toRawItems(items, this.
|
78
|
+
for (const item of toRawItems(items, this._schema[ItemsSym])) {
|
71
79
|
this._raw.prepend(item);
|
72
80
|
}
|
73
81
|
return this._raw.entries().length;
|
@@ -84,27 +92,28 @@ export class CoList extends Array {
|
|
84
92
|
}
|
85
93
|
splice(start, deleteCount, ...items) {
|
86
94
|
const deleted = this.slice(start, start + deleteCount);
|
87
|
-
for (let idxToDelete = start + deleteCount; idxToDelete
|
95
|
+
for (let idxToDelete = start + deleteCount - 1; idxToDelete >= start; idxToDelete--) {
|
88
96
|
this._raw.delete(idxToDelete);
|
89
97
|
}
|
90
|
-
let appendAfter = start;
|
91
|
-
for (const item of toRawItems(items, this.
|
98
|
+
let appendAfter = Math.max(start - 1, 0);
|
99
|
+
for (const item of toRawItems(items, this._schema[ItemsSym])) {
|
100
|
+
console.log(this._raw.asArray(), appendAfter);
|
92
101
|
this._raw.append(item, appendAfter);
|
93
102
|
appendAfter++;
|
94
103
|
}
|
95
104
|
return deleted;
|
96
105
|
}
|
97
106
|
toJSON() {
|
98
|
-
const itemDescriptor = this.
|
107
|
+
const itemDescriptor = this._schema[ItemsSym];
|
99
108
|
if (itemDescriptor === "json") {
|
100
109
|
return this._raw.asArray();
|
101
110
|
}
|
102
111
|
else if ("encoded" in itemDescriptor) {
|
103
112
|
return this._raw
|
104
113
|
.asArray()
|
105
|
-
.map((e) =>
|
114
|
+
.map((e) => encodeSync(itemDescriptor.encoded)(e));
|
106
115
|
}
|
107
|
-
else if (
|
116
|
+
else if (isRefEncoded(itemDescriptor)) {
|
108
117
|
return this.map((item) => item?.toJSON());
|
109
118
|
}
|
110
119
|
else {
|
@@ -115,33 +124,51 @@ export class CoList extends Array {
|
|
115
124
|
return this.toJSON();
|
116
125
|
}
|
117
126
|
static fromRaw(raw) {
|
118
|
-
return new this(
|
127
|
+
return new this({ fromRaw: raw });
|
128
|
+
}
|
129
|
+
static schema(def) {
|
130
|
+
this._schema || (this._schema = {});
|
131
|
+
Object.assign(this._schema, def);
|
132
|
+
}
|
133
|
+
/** @category Subscription & Loading */
|
134
|
+
static load(id, as, depth) {
|
135
|
+
return loadCoValue(this, id, as, depth);
|
136
|
+
}
|
137
|
+
/** @category Subscription & Loading */
|
138
|
+
static loadEf(id, depth) {
|
139
|
+
return loadCoValueEf(this, id, depth);
|
140
|
+
}
|
141
|
+
/** @category Subscription & Loading */
|
142
|
+
static subscribe(id, as, depth, listener) {
|
143
|
+
return subscribeToCoValue(this, id, as, depth, listener);
|
119
144
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
145
|
+
/** @category Subscription & Loading */
|
146
|
+
static subscribeEf(id, depth) {
|
147
|
+
return subscribeToCoValueEf(this, id, depth);
|
148
|
+
}
|
149
|
+
/** @category Subscription & Loading */
|
150
|
+
ensureLoaded(depth) {
|
151
|
+
return ensureCoValueLoaded(this, depth);
|
152
|
+
}
|
153
|
+
/** @category Subscription & Loading */
|
154
|
+
subscribe(depth, listener) {
|
155
|
+
return subscribeToExistingCoValue(this, depth, listener);
|
156
|
+
}
|
157
|
+
/** @category Type Helpers */
|
158
|
+
castAs(cl) {
|
159
|
+
return cl.fromRaw(this._raw);
|
123
160
|
}
|
124
161
|
}
|
125
162
|
_a = CoList;
|
126
163
|
(() => {
|
127
164
|
_a.prototype._type = "CoList";
|
128
165
|
})();
|
129
|
-
(() => {
|
130
|
-
_a.prototype.subscribe = CoValueBase.prototype.subscribe;
|
131
|
-
})();
|
132
|
-
(() => {
|
133
|
-
_a.prototype.subscribeEf = CoValueBase.prototype.subscribeEf;
|
134
|
-
})();
|
135
|
-
CoList.loadEf = CoValueBase.loadEf;
|
136
|
-
CoList.load = CoValueBase.load;
|
137
|
-
CoList.subscribeEf = CoValueBase.subscribeEf;
|
138
|
-
CoList.subscribe = CoValueBase.subscribe;
|
139
166
|
function toRawItems(items, itemDescriptor) {
|
140
167
|
const rawItems = itemDescriptor === "json"
|
141
168
|
? items
|
142
169
|
: "encoded" in itemDescriptor
|
143
|
-
? items?.map((e) =>
|
144
|
-
:
|
170
|
+
? items?.map((e) => encodeSync(itemDescriptor.encoded)(e))
|
171
|
+
: isRefEncoded(itemDescriptor)
|
145
172
|
? items?.map((v) => v.id)
|
146
173
|
: (() => {
|
147
174
|
throw new Error("Invalid element descriptor");
|
@@ -151,7 +178,7 @@ function toRawItems(items, itemDescriptor) {
|
|
151
178
|
function init(list) {
|
152
179
|
if (list[InitValues]) {
|
153
180
|
const { init, owner } = list[InitValues];
|
154
|
-
const raw = owner._raw.createList(toRawItems(init, list.
|
181
|
+
const raw = owner._raw.createList(toRawItems(init, list._schema[ItemsSym]));
|
155
182
|
Object.defineProperties(list, {
|
156
183
|
id: {
|
157
184
|
value: raw.id,
|
@@ -165,7 +192,7 @@ function init(list) {
|
|
165
192
|
const CoListProxyHandler = {
|
166
193
|
get(target, key, receiver) {
|
167
194
|
if (typeof key === "string" && !isNaN(+key)) {
|
168
|
-
const itemDescriptor = target.
|
195
|
+
const itemDescriptor = target._schema[ItemsSym];
|
169
196
|
const rawValue = target._raw.get(Number(key));
|
170
197
|
if (itemDescriptor === "json") {
|
171
198
|
return rawValue;
|
@@ -173,12 +200,12 @@ const CoListProxyHandler = {
|
|
173
200
|
else if ("encoded" in itemDescriptor) {
|
174
201
|
return rawValue === undefined
|
175
202
|
? undefined
|
176
|
-
:
|
203
|
+
: decodeSync(itemDescriptor.encoded)(rawValue);
|
177
204
|
}
|
178
|
-
else if (
|
205
|
+
else if (isRefEncoded(itemDescriptor)) {
|
179
206
|
return rawValue === undefined
|
180
207
|
? undefined
|
181
|
-
: new Ref(rawValue, target._loadedAs, itemDescriptor).accessFrom(receiver);
|
208
|
+
: new Ref(rawValue, target._loadedAs, itemDescriptor).accessFrom(receiver, Number(key));
|
182
209
|
}
|
183
210
|
}
|
184
211
|
else if (key === "length") {
|
@@ -193,22 +220,22 @@ const CoListProxyHandler = {
|
|
193
220
|
if (key === ItemsSym &&
|
194
221
|
typeof value === "object" &&
|
195
222
|
SchemaInit in value) {
|
196
|
-
(_b = target.constructor).
|
197
|
-
target.constructor.
|
223
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
224
|
+
target.constructor._schema[ItemsSym] =
|
198
225
|
value[SchemaInit];
|
199
226
|
init(target);
|
200
227
|
return true;
|
201
228
|
}
|
202
229
|
if (typeof key === "string" && !isNaN(+key)) {
|
203
|
-
const itemDescriptor = target.
|
230
|
+
const itemDescriptor = target._schema[ItemsSym];
|
204
231
|
let rawValue;
|
205
232
|
if (itemDescriptor === "json") {
|
206
233
|
rawValue = value;
|
207
234
|
}
|
208
235
|
else if ("encoded" in itemDescriptor) {
|
209
|
-
rawValue =
|
236
|
+
rawValue = encodeSync(itemDescriptor.encoded)(value);
|
210
237
|
}
|
211
|
-
else if (
|
238
|
+
else if (isRefEncoded(itemDescriptor)) {
|
212
239
|
rawValue = value.id;
|
213
240
|
}
|
214
241
|
target._raw.replace(Number(key), rawValue);
|
@@ -224,8 +251,8 @@ const CoListProxyHandler = {
|
|
224
251
|
key === ItemsSym &&
|
225
252
|
typeof descriptor.value === "object" &&
|
226
253
|
SchemaInit in descriptor.value) {
|
227
|
-
(_b = target.constructor).
|
228
|
-
target.constructor.
|
254
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
255
|
+
target.constructor._schema[ItemsSym] =
|
229
256
|
descriptor.value[SchemaInit];
|
230
257
|
init(target);
|
231
258
|
return true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coList.js","sourceRoot":"","sources":["../../src/coValues/coList.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"coList.js","sourceRoot":"","sources":["../../src/coValues/coList.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAepC,OAAO,EACH,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,UAAU,EACV,EAAE,EACF,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,WAAW,EACX,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAG/D,yBAAyB;AACzB,8DAA8D;AAC9D,MAAM,OAAO,MAAmB,SAAQ,KAAW;IAC/C,MAAM,CAAC,EAAE,CAAO,IAAU;;QACtB,wCAAwC;QACxC,YAAO,MAAM,QAAS,SAAQ,EAAY;gBAAnC;;oBACH,QAAU,GAAG,IAAI,CAAC;gBACtB,CAAC;aAAA;iBADI,EAAE,CAAC,KAAK;eACX;IACN,CAAC;IAED,qDAAqD;I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