jazz-tools 0.7.0-alpha.4 → 0.7.0-alpha.42
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 +3 -19
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +140 -0
- package/CHANGELOG.md +252 -0
- package/README.md +10 -2
- package/dist/coValues/account.js +104 -50
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +165 -112
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +243 -163
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +256 -73
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/deepLoading.js +57 -0
- package/dist/coValues/deepLoading.js.map +1 -0
- package/dist/coValues/extensions/imageDef.js +14 -8
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +49 -38
- package/dist/coValues/group.js.map +1 -1
- package/dist/coValues/interfaces.js +66 -26
- 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 +60 -19
- package/dist/implementation/refs.js.map +1 -1
- package/dist/implementation/schema.js +44 -1
- package/dist/implementation/schema.js.map +1 -1
- 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 +4 -1
- package/dist/internal.js.map +1 -1
- package/dist/tests/coList.test.js +51 -52
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +196 -75
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +95 -85
- 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 +184 -153
- package/src/coValues/coList.ts +220 -173
- package/src/coValues/coMap.ts +322 -312
- package/src/coValues/coStream.ts +397 -135
- package/src/coValues/deepLoading.ts +215 -0
- package/src/coValues/extensions/imageDef.ts +16 -17
- package/src/coValues/group.ts +95 -111
- package/src/coValues/interfaces.ts +217 -115
- package/src/implementation/devtoolsFormatters.ts +110 -0
- package/src/implementation/inspect.ts +1 -1
- package/src/implementation/refs.ts +91 -38
- package/src/implementation/schema.ts +87 -46
- package/src/implementation/subscriptionScope.ts +44 -12
- package/src/implementation/symbols.ts +11 -0
- package/src/index.ts +13 -9
- package/src/internal.ts +6 -2
- package/src/tests/coList.test.ts +67 -66
- package/src/tests/coMap.test.ts +226 -123
- package/src/tests/coStream.test.ts +141 -131
- package/src/tests/deepLoading.test.ts +301 -0
- package/src/tests/groupsAndAccounts.test.ts +91 -0
package/dist/coValues/account.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
var _a;
|
2
2
|
import { LocalNode } from "cojson";
|
3
3
|
import { Context } from "effect";
|
4
|
-
import { CoValueBase, Profile,
|
4
|
+
import { Group, CoValueBase, MembersSym, Profile, Ref, SchemaInit, inspect, subscriptionsScopes, } 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;
|
@@ -18,22 +19,14 @@ export class Account extends CoValueBase {
|
|
18
19
|
const profileID = this._raw.get("profile");
|
19
20
|
const rootID = this._raw.get("root");
|
20
21
|
return {
|
21
|
-
profile: profileID &&
|
22
|
+
profile: profileID &&
|
23
|
+
new Ref(profileID, this._loadedAs, this._schema.profile),
|
22
24
|
root: rootID &&
|
23
|
-
new
|
25
|
+
new Ref(rootID, this._loadedAs, this._schema.root),
|
24
26
|
};
|
25
27
|
}
|
26
|
-
constructor(
|
28
|
+
constructor(options) {
|
27
29
|
super();
|
28
|
-
this.acceptInvite = (async (valueID, inviteSecret, coValueClass) => {
|
29
|
-
if (!this.isMe) {
|
30
|
-
throw new Error("Only a controlled account can accept invites");
|
31
|
-
}
|
32
|
-
await this._raw.acceptInvite(valueID, inviteSecret);
|
33
|
-
return coValueClass.load(valueID, {
|
34
|
-
as: this,
|
35
|
-
});
|
36
|
-
});
|
37
30
|
if (!("fromRaw" in options)) {
|
38
31
|
throw new Error("Can only construct account from raw or with .create()");
|
39
32
|
}
|
@@ -44,47 +37,35 @@ export class Account extends CoValueBase {
|
|
44
37
|
enumerable: false,
|
45
38
|
},
|
46
39
|
_raw: { value: options.fromRaw, enumerable: false },
|
47
|
-
|
48
|
-
get: () => {
|
49
|
-
const ref = this._refs.profile;
|
50
|
-
return ref ? ref.accessFrom(this) : undefined;
|
51
|
-
},
|
52
|
-
set: (value) => {
|
53
|
-
if (value) {
|
54
|
-
this._raw.set("profile", value.id);
|
55
|
-
}
|
56
|
-
},
|
57
|
-
},
|
58
|
-
root: {
|
59
|
-
get: () => {
|
60
|
-
const ref = this._refs.root;
|
61
|
-
return ref ? ref.accessFrom(this) : undefined;
|
62
|
-
},
|
63
|
-
set: (value) => {
|
64
|
-
if (value) {
|
65
|
-
this._raw.set("root", value.id);
|
66
|
-
}
|
67
|
-
},
|
68
|
-
},
|
40
|
+
_type: { value: "Account", enumerable: false },
|
69
41
|
});
|
70
42
|
if (this.isMe) {
|
71
43
|
this.sessionID =
|
72
44
|
options.fromRaw.core.node.currentSessionID;
|
73
45
|
}
|
46
|
+
return new Proxy(this, AccountAndGroupProxyHandler);
|
74
47
|
}
|
75
48
|
myRole() {
|
76
49
|
if (this.isMe) {
|
77
50
|
return "admin";
|
78
51
|
}
|
79
52
|
}
|
53
|
+
async acceptInvite(valueID, inviteSecret, coValueClass) {
|
54
|
+
if (!this.isMe) {
|
55
|
+
throw new Error("Only a controlled account can accept invites");
|
56
|
+
}
|
57
|
+
await this._raw.acceptInvite(valueID, inviteSecret);
|
58
|
+
return coValueClass.load(valueID, this, []);
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
60
|
+
}
|
80
61
|
static async create(options) {
|
81
62
|
const { node } = await LocalNode.withNewlyCreatedAccount({
|
82
63
|
...options,
|
83
|
-
migration: async (rawAccount) => {
|
84
|
-
const account = new this(
|
64
|
+
migration: async (rawAccount, _node, creationProps) => {
|
65
|
+
const account = new this({
|
85
66
|
fromRaw: rawAccount,
|
86
67
|
});
|
87
|
-
await account.migrate?.();
|
68
|
+
await account.migrate?.(creationProps);
|
88
69
|
},
|
89
70
|
});
|
90
71
|
return this.fromNode(node);
|
@@ -95,20 +76,22 @@ export class Account extends CoValueBase {
|
|
95
76
|
accountSecret: options.accountSecret,
|
96
77
|
sessionID: options.sessionID,
|
97
78
|
peersToLoadFrom: options.peersToLoadFrom,
|
98
|
-
|
99
|
-
|
79
|
+
crypto: options.crypto,
|
80
|
+
migration: async (rawAccount, _node, creationProps) => {
|
81
|
+
const account = new this({
|
100
82
|
fromRaw: rawAccount,
|
101
83
|
});
|
102
|
-
await account.migrate?.();
|
84
|
+
await account.migrate?.(creationProps);
|
103
85
|
},
|
104
86
|
});
|
105
87
|
return this.fromNode(node);
|
106
88
|
}
|
107
89
|
static fromNode(node) {
|
108
|
-
return new this(
|
90
|
+
return new this({
|
109
91
|
fromRaw: node.account,
|
110
92
|
});
|
111
93
|
}
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
112
95
|
toJSON() {
|
113
96
|
return {
|
114
97
|
id: this.id,
|
@@ -118,20 +101,91 @@ export class Account extends CoValueBase {
|
|
118
101
|
[inspect]() {
|
119
102
|
return this.toJSON();
|
120
103
|
}
|
121
|
-
|
122
|
-
|
123
|
-
|
104
|
+
migrate(creationProps) {
|
105
|
+
if (creationProps) {
|
106
|
+
const profileGroup = Group.create({ owner: this });
|
107
|
+
profileGroup.addMember("everyone", "reader");
|
108
|
+
this.profile = Profile.create({ name: creationProps.name }, { owner: profileGroup });
|
109
|
+
}
|
124
110
|
}
|
125
111
|
}
|
126
112
|
_a = Account;
|
127
113
|
(() => {
|
128
|
-
_a.
|
129
|
-
profile:
|
130
|
-
root:
|
114
|
+
_a._schema = {
|
115
|
+
profile: () => Profile,
|
116
|
+
root: "json",
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
131
118
|
};
|
132
119
|
})();
|
120
|
+
export const AccountAndGroupProxyHandler = {
|
121
|
+
get(target, key, receiver) {
|
122
|
+
if (key === "profile") {
|
123
|
+
const ref = target._refs.profile;
|
124
|
+
return ref
|
125
|
+
? ref.accessFrom(receiver, "profile")
|
126
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
127
|
+
undefined;
|
128
|
+
}
|
129
|
+
else if (key === "root") {
|
130
|
+
const ref = target._refs.root;
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
132
|
+
return ref ? ref.accessFrom(receiver, "root") : undefined;
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
return Reflect.get(target, key, receiver);
|
136
|
+
}
|
137
|
+
},
|
138
|
+
set(target, key, value, receiver) {
|
139
|
+
var _b;
|
140
|
+
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
141
|
+
typeof value === "object" &&
|
142
|
+
SchemaInit in value) {
|
143
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
144
|
+
target.constructor._schema[key] =
|
145
|
+
value[SchemaInit];
|
146
|
+
return true;
|
147
|
+
}
|
148
|
+
else if (key === "profile") {
|
149
|
+
if (value) {
|
150
|
+
target._raw.set("profile", value.id, "trusting");
|
151
|
+
}
|
152
|
+
subscriptionsScopes
|
153
|
+
.get(receiver)
|
154
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
155
|
+
return true;
|
156
|
+
}
|
157
|
+
else if (key === "root") {
|
158
|
+
if (value) {
|
159
|
+
target._raw.set("root", value.id);
|
160
|
+
}
|
161
|
+
subscriptionsScopes
|
162
|
+
.get(receiver)
|
163
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
164
|
+
return true;
|
165
|
+
}
|
166
|
+
else {
|
167
|
+
return Reflect.set(target, key, value, receiver);
|
168
|
+
}
|
169
|
+
},
|
170
|
+
defineProperty(target, key, descriptor) {
|
171
|
+
var _b;
|
172
|
+
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
173
|
+
typeof descriptor.value === "object" &&
|
174
|
+
SchemaInit in descriptor.value) {
|
175
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
176
|
+
target.constructor._schema[key] =
|
177
|
+
descriptor.value[SchemaInit];
|
178
|
+
return true;
|
179
|
+
}
|
180
|
+
else {
|
181
|
+
return Reflect.defineProperty(target, key, descriptor);
|
182
|
+
}
|
183
|
+
},
|
184
|
+
};
|
185
|
+
/** @category Identity & Permissions */
|
133
186
|
export class AccountCtx extends Context.Tag("Account")() {
|
134
187
|
}
|
188
|
+
/** @category Identity & Permissions */
|
135
189
|
export function isControlledAccount(account) {
|
136
190
|
return account.isMe;
|
137
191
|
}
|
@@ -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,EAAE,MAAM,QAAQ,CAAC;AAWjC,OAAO,EACH,KAAK,EACL,WAAW,EACX,UAAU,EACV,OAAO,EACP,GAAG,EACH,UAAU,EACV,OAAO,EACP,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB,uCAAuC;AACvC,MAAM,OAAO,O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MAAM,CAAC,WAA4B,EAAC,OAAO,QAAP,OAAO,GAAK,EAAE,EAAC;YACnD,MAAM,CAAC,WAA4B,CAAC,OAAO,CAAC,GAAG,CAAC;gBAC7C,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACjC,OAAO,IAAI,CAAC;QAChB,CAAC;aAAM,CAAC;YACJ,OAAO,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;CACJ,CAAC;AAEF,uCAAuC;AACvC,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAGnD;CAAG;AAEN,uCAAuC;AACvC,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAKhD,OAAO,OAAO,CAAC,IAAI,CAAC;AACxB,CAAC"}
|
package/dist/coValues/coList.js
CHANGED
@@ -1,18 +1,37 @@
|
|
1
1
|
var _a;
|
2
2
|
import { RawAccount } from "cojson";
|
3
|
-
import { Account, CoValueBase, Group,
|
4
|
-
import {
|
3
|
+
import { Account, CoValueBase, Group, InitValues, ItemsSym, Ref, SchemaInit, co, inspect, isRefEncoded, makeRefs, } 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
|
-
|
7
|
-
|
8
|
+
static Of(item) {
|
9
|
+
var _b, _c;
|
10
|
+
// TODO: cache superclass for item class
|
11
|
+
return _c = class CoListOf extends _a {
|
12
|
+
constructor() {
|
13
|
+
super(...arguments);
|
14
|
+
this[_b] = item;
|
15
|
+
}
|
16
|
+
},
|
17
|
+
_b = co.items,
|
18
|
+
_c;
|
19
|
+
}
|
20
|
+
/** @deprecated Use UPPERCASE `CoList.Of` instead! */
|
21
|
+
static of(..._args) {
|
22
|
+
throw new Error("Can't use Array.of with CoLists");
|
23
|
+
}
|
24
|
+
get _schema() {
|
25
|
+
return this.constructor._schema;
|
8
26
|
}
|
9
27
|
get _owner() {
|
10
28
|
return this._raw.group instanceof RawAccount
|
11
29
|
? Account.fromRaw(this._raw.group)
|
12
30
|
: Group.fromRaw(this._raw.group);
|
13
31
|
}
|
32
|
+
/** @category Content */
|
14
33
|
get _refs() {
|
15
|
-
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]);
|
16
35
|
}
|
17
36
|
get _edits() {
|
18
37
|
throw new Error("Not implemented");
|
@@ -20,56 +39,43 @@ export class CoList extends Array {
|
|
20
39
|
get _loadedAs() {
|
21
40
|
return Account.fromNode(this._raw.core.node);
|
22
41
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
28
|
-
return new Array(init);
|
29
|
-
}
|
42
|
+
static get [Symbol.species]() {
|
43
|
+
return Array;
|
44
|
+
}
|
45
|
+
constructor(options) {
|
30
46
|
super();
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
if ("
|
36
|
-
|
47
|
+
Object.defineProperty(this, "_instanceID", {
|
48
|
+
value: `instance-${Math.random().toString(36).slice(2)}`,
|
49
|
+
enumerable: false,
|
50
|
+
});
|
51
|
+
if ("owner" in options) {
|
52
|
+
this[InitValues] = {
|
53
|
+
init: options.init,
|
54
|
+
owner: options.owner,
|
55
|
+
};
|
37
56
|
}
|
38
|
-
else {
|
39
|
-
|
40
|
-
|
41
|
-
|
57
|
+
else if ("fromRaw" in options) {
|
58
|
+
Object.defineProperties(this, {
|
59
|
+
id: {
|
60
|
+
value: options.fromRaw.id,
|
61
|
+
enumerable: false,
|
62
|
+
},
|
63
|
+
_raw: { value: options.fromRaw, enumerable: false },
|
64
|
+
});
|
42
65
|
}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
},
|
48
|
-
_raw: { value: raw, enumerable: false },
|
49
|
-
});
|
50
|
-
return new Proxy(this, CoListProxyHandler(this._encoding._item));
|
51
|
-
}
|
52
|
-
toRawItems(items) {
|
53
|
-
const itemDescriptor = this._encoding._item;
|
54
|
-
const rawItems = itemDescriptor === "json"
|
55
|
-
? items
|
56
|
-
: "encoded" in itemDescriptor
|
57
|
-
? items?.map((e) => Schema.encodeSync(itemDescriptor.encoded)(e))
|
58
|
-
: "ref" in itemDescriptor
|
59
|
-
? items?.map((v) => v.id)
|
60
|
-
: (() => {
|
61
|
-
throw new Error("Invalid element descriptor");
|
62
|
-
})();
|
63
|
-
return rawItems;
|
66
|
+
return new Proxy(this, CoListProxyHandler);
|
67
|
+
}
|
68
|
+
static create(items, options) {
|
69
|
+
return new this({ init: items, owner: options.owner });
|
64
70
|
}
|
65
71
|
push(...items) {
|
66
|
-
for (const item of
|
72
|
+
for (const item of toRawItems(items, this._schema[ItemsSym])) {
|
67
73
|
this._raw.append(item);
|
68
74
|
}
|
69
75
|
return this._raw.entries().length;
|
70
76
|
}
|
71
77
|
unshift(...items) {
|
72
|
-
for (const item of
|
78
|
+
for (const item of toRawItems(items, this._schema[ItemsSym])) {
|
73
79
|
this._raw.prepend(item);
|
74
80
|
}
|
75
81
|
return this._raw.entries().length;
|
@@ -86,27 +92,28 @@ export class CoList extends Array {
|
|
86
92
|
}
|
87
93
|
splice(start, deleteCount, ...items) {
|
88
94
|
const deleted = this.slice(start, start + deleteCount);
|
89
|
-
for (let idxToDelete = start + deleteCount; idxToDelete
|
95
|
+
for (let idxToDelete = start + deleteCount - 1; idxToDelete >= start; idxToDelete--) {
|
90
96
|
this._raw.delete(idxToDelete);
|
91
97
|
}
|
92
|
-
let appendAfter = start;
|
93
|
-
for (const item of
|
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);
|
94
101
|
this._raw.append(item, appendAfter);
|
95
102
|
appendAfter++;
|
96
103
|
}
|
97
104
|
return deleted;
|
98
105
|
}
|
99
106
|
toJSON() {
|
100
|
-
const itemDescriptor = this.
|
107
|
+
const itemDescriptor = this._schema[ItemsSym];
|
101
108
|
if (itemDescriptor === "json") {
|
102
109
|
return this._raw.asArray();
|
103
110
|
}
|
104
111
|
else if ("encoded" in itemDescriptor) {
|
105
112
|
return this._raw
|
106
113
|
.asArray()
|
107
|
-
.map((e) =>
|
114
|
+
.map((e) => encodeSync(itemDescriptor.encoded)(e));
|
108
115
|
}
|
109
|
-
else if (
|
116
|
+
else if (isRefEncoded(itemDescriptor)) {
|
110
117
|
return this.map((item) => item?.toJSON());
|
111
118
|
}
|
112
119
|
else {
|
@@ -117,80 +124,126 @@ export class CoList extends Array {
|
|
117
124
|
return this.toJSON();
|
118
125
|
}
|
119
126
|
static fromRaw(raw) {
|
120
|
-
return new this(
|
127
|
+
return new this({ fromRaw: raw });
|
121
128
|
}
|
122
|
-
static
|
123
|
-
this.
|
124
|
-
Object.assign(this.
|
129
|
+
static schema(def) {
|
130
|
+
this._schema || (this._schema = {});
|
131
|
+
Object.assign(this._schema, def);
|
125
132
|
}
|
126
133
|
}
|
127
134
|
_a = CoList;
|
128
135
|
(() => {
|
129
136
|
_a.prototype._type = "CoList";
|
130
137
|
})();
|
131
|
-
(() => {
|
132
|
-
_a.prototype.subscribe = CoValueBase.prototype.subscribe;
|
133
|
-
})();
|
134
|
-
(() => {
|
135
|
-
_a.prototype.subscribeEf = CoValueBase.prototype.subscribeEf;
|
136
|
-
})();
|
137
|
-
CoList.loadEf = CoValueBase.loadEf;
|
138
138
|
CoList.load = CoValueBase.load;
|
139
|
-
CoList.
|
139
|
+
CoList.loadEf = CoValueBase.loadEf;
|
140
140
|
CoList.subscribe = CoValueBase.subscribe;
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
141
|
+
CoList.subscribeEf = CoValueBase.subscribeEf;
|
142
|
+
function toRawItems(items, itemDescriptor) {
|
143
|
+
const rawItems = itemDescriptor === "json"
|
144
|
+
? items
|
145
|
+
: "encoded" in itemDescriptor
|
146
|
+
? items?.map((e) => encodeSync(itemDescriptor.encoded)(e))
|
147
|
+
: isRefEncoded(itemDescriptor)
|
148
|
+
? items?.map((v) => v.id)
|
149
|
+
: (() => {
|
150
|
+
throw new Error("Invalid element descriptor");
|
151
|
+
})();
|
152
|
+
return rawItems;
|
153
|
+
}
|
154
|
+
function init(list) {
|
155
|
+
if (list[InitValues]) {
|
156
|
+
const { init, owner } = list[InitValues];
|
157
|
+
const raw = owner._raw.createList(toRawItems(init, list._schema[ItemsSym]));
|
158
|
+
Object.defineProperties(list, {
|
159
|
+
id: {
|
160
|
+
value: raw.id,
|
161
|
+
enumerable: false,
|
162
|
+
},
|
163
|
+
_raw: { value: raw, enumerable: false },
|
164
|
+
});
|
165
|
+
delete list[InitValues];
|
166
|
+
}
|
167
|
+
}
|
168
|
+
const CoListProxyHandler = {
|
169
|
+
get(target, key, receiver) {
|
170
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
171
|
+
const itemDescriptor = target._schema[ItemsSym];
|
172
|
+
const rawValue = target._raw.get(Number(key));
|
173
|
+
if (itemDescriptor === "json") {
|
174
|
+
return rawValue;
|
162
175
|
}
|
163
|
-
else {
|
164
|
-
return
|
176
|
+
else if ("encoded" in itemDescriptor) {
|
177
|
+
return rawValue === undefined
|
178
|
+
? undefined
|
179
|
+
: decodeSync(itemDescriptor.encoded)(rawValue);
|
165
180
|
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
if (itemDescriptor === "json") {
|
171
|
-
rawValue = value;
|
172
|
-
}
|
173
|
-
else if ("encoded" in itemDescriptor) {
|
174
|
-
rawValue = Schema.encodeSync(itemDescriptor.encoded)(value);
|
175
|
-
}
|
176
|
-
else if ("ref" in itemDescriptor) {
|
177
|
-
rawValue = value.id;
|
178
|
-
}
|
179
|
-
target._raw.replace(Number(key), rawValue);
|
180
|
-
return true;
|
181
|
+
else if (isRefEncoded(itemDescriptor)) {
|
182
|
+
return rawValue === undefined
|
183
|
+
? undefined
|
184
|
+
: new Ref(rawValue, target._loadedAs, itemDescriptor).accessFrom(receiver, Number(key));
|
181
185
|
}
|
182
|
-
|
183
|
-
|
186
|
+
}
|
187
|
+
else if (key === "length") {
|
188
|
+
return target._raw.entries().length;
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
return Reflect.get(target, key, receiver);
|
192
|
+
}
|
193
|
+
},
|
194
|
+
set(target, key, value, receiver) {
|
195
|
+
var _b;
|
196
|
+
if (key === ItemsSym &&
|
197
|
+
typeof value === "object" &&
|
198
|
+
SchemaInit in value) {
|
199
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
200
|
+
target.constructor._schema[ItemsSym] =
|
201
|
+
value[SchemaInit];
|
202
|
+
init(target);
|
203
|
+
return true;
|
204
|
+
}
|
205
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
206
|
+
const itemDescriptor = target._schema[ItemsSym];
|
207
|
+
let rawValue;
|
208
|
+
if (itemDescriptor === "json") {
|
209
|
+
rawValue = value;
|
184
210
|
}
|
185
|
-
|
186
|
-
|
187
|
-
if (typeof key === "string" && !isNaN(+key)) {
|
188
|
-
return Number(key) < target._raw.entries().length;
|
211
|
+
else if ("encoded" in itemDescriptor) {
|
212
|
+
rawValue = encodeSync(itemDescriptor.encoded)(value);
|
189
213
|
}
|
190
|
-
else {
|
191
|
-
|
214
|
+
else if (isRefEncoded(itemDescriptor)) {
|
215
|
+
rawValue = value.id;
|
192
216
|
}
|
193
|
-
|
194
|
-
|
195
|
-
}
|
217
|
+
target._raw.replace(Number(key), rawValue);
|
218
|
+
return true;
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
return Reflect.set(target, key, value, receiver);
|
222
|
+
}
|
223
|
+
},
|
224
|
+
defineProperty(target, key, descriptor) {
|
225
|
+
var _b;
|
226
|
+
if (descriptor.value &&
|
227
|
+
key === ItemsSym &&
|
228
|
+
typeof descriptor.value === "object" &&
|
229
|
+
SchemaInit in descriptor.value) {
|
230
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
231
|
+
target.constructor._schema[ItemsSym] =
|
232
|
+
descriptor.value[SchemaInit];
|
233
|
+
init(target);
|
234
|
+
return true;
|
235
|
+
}
|
236
|
+
else {
|
237
|
+
return Reflect.defineProperty(target, key, descriptor);
|
238
|
+
}
|
239
|
+
},
|
240
|
+
has(target, key) {
|
241
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
242
|
+
return Number(key) < target._raw.entries().length;
|
243
|
+
}
|
244
|
+
else {
|
245
|
+
return Reflect.has(target, key);
|
246
|
+
}
|
247
|
+
},
|
248
|
+
};
|
196
249
|
//# sourceMappingURL=coList.js.map
|
@@ -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;AAWpC,OAAO,EACH,OAAO,EACP,WAAW,EACX,KAAK,EACL,UAAU,EACV,QAAQ,EACR,GAAG,EACH,UAAU,EACV,EAAE,EACF,OAAO,EACP,YAAY,EACZ,QAAQ,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE/D,yBAAyB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