jazz-tools 0.7.0-alpha.9 → 0.7.1
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 +298 -0
- package/README.md +10 -2
- package/dist/coValues/account.js +59 -41
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +49 -46
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +143 -44
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +144 -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 +49 -13
- package/dist/coValues/group.js.map +1 -1
- package/dist/coValues/interfaces.js +70 -31
- 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 +3 -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 +113 -125
- package/src/coValues/coList.ts +87 -103
- package/src/coValues/coMap.ts +200 -147
- package/src/coValues/coStream.ts +264 -80
- package/src/coValues/deepLoading.ts +229 -0
- package/src/coValues/extensions/imageDef.ts +17 -13
- package/src/coValues/group.ts +92 -58
- package/src/coValues/interfaces.ts +215 -115
- 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 +138 -0
- package/src/implementation/subscriptionScope.ts +48 -12
- package/src/implementation/symbols.ts +11 -0
- package/src/index.ts +12 -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 +301 -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, } 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 coValueClass.load(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,35 @@ 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
|
+
}
|
101
108
|
}
|
102
109
|
_a = Account;
|
103
110
|
(() => {
|
104
|
-
_a.
|
105
|
-
profile: { ref: () => Profile },
|
106
|
-
root:
|
111
|
+
_a._schema = {
|
112
|
+
profile: { ref: () => Profile, optional: false },
|
113
|
+
root: "json",
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
107
115
|
};
|
108
116
|
})();
|
109
117
|
export const AccountAndGroupProxyHandler = {
|
110
118
|
get(target, key, receiver) {
|
111
119
|
if (key === "profile") {
|
112
120
|
const ref = target._refs.profile;
|
113
|
-
return ref
|
121
|
+
return ref
|
122
|
+
? ref.accessFrom(receiver, "profile")
|
123
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
124
|
+
undefined;
|
114
125
|
}
|
115
126
|
else if (key === "root") {
|
116
127
|
const ref = target._refs.root;
|
117
|
-
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
129
|
+
return ref ? ref.accessFrom(receiver, "root") : undefined;
|
118
130
|
}
|
119
131
|
else {
|
120
132
|
return Reflect.get(target, key, receiver);
|
@@ -122,26 +134,30 @@ export const AccountAndGroupProxyHandler = {
|
|
122
134
|
},
|
123
135
|
set(target, key, value, receiver) {
|
124
136
|
var _b;
|
125
|
-
if ((key === "profile" || key === "root") &&
|
137
|
+
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
126
138
|
typeof value === "object" &&
|
127
139
|
SchemaInit in value) {
|
128
|
-
(_b = target.constructor).
|
129
|
-
target.constructor.
|
140
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
141
|
+
target.constructor._schema[key] =
|
130
142
|
value[SchemaInit];
|
131
143
|
return true;
|
132
144
|
}
|
133
145
|
else if (key === "profile") {
|
134
146
|
if (value) {
|
135
|
-
target._raw.set("profile", value.id);
|
147
|
+
target._raw.set("profile", value.id, "trusting");
|
136
148
|
}
|
137
|
-
subscriptionsScopes
|
149
|
+
subscriptionsScopes
|
150
|
+
.get(receiver)
|
151
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
138
152
|
return true;
|
139
153
|
}
|
140
154
|
else if (key === "root") {
|
141
155
|
if (value) {
|
142
156
|
target._raw.set("root", value.id);
|
143
157
|
}
|
144
|
-
subscriptionsScopes
|
158
|
+
subscriptionsScopes
|
159
|
+
.get(receiver)
|
160
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
145
161
|
return true;
|
146
162
|
}
|
147
163
|
else {
|
@@ -150,11 +166,11 @@ export const AccountAndGroupProxyHandler = {
|
|
150
166
|
},
|
151
167
|
defineProperty(target, key, descriptor) {
|
152
168
|
var _b;
|
153
|
-
if ((key === "profile" || key === "root") &&
|
169
|
+
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
154
170
|
typeof descriptor.value === "object" &&
|
155
171
|
SchemaInit in descriptor.value) {
|
156
|
-
(_b = target.constructor).
|
157
|
-
target.constructor.
|
172
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
173
|
+
target.constructor._schema[key] =
|
158
174
|
descriptor.value[SchemaInit];
|
159
175
|
return true;
|
160
176
|
}
|
@@ -163,8 +179,10 @@ export const AccountAndGroupProxyHandler = {
|
|
163
179
|
}
|
164
180
|
},
|
165
181
|
};
|
182
|
+
/** @category Identity & Permissions */
|
166
183
|
export class AccountCtx extends Context.Tag("Account")() {
|
167
184
|
}
|
185
|
+
/** @category Identity & Permissions */
|
168
186
|
export function isControlledAccount(account) {
|
169
187
|
return account.isMe;
|
170
188
|
}
|
@@ -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,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AC;IACD,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU;;QAClC,IACI,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,UAAU,CAAC;YAC3D,OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ;YACpC,UAAU,IAAI,UAAU,CAAC,KAAK,EAChC,CAAC;YACC,MAAC,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,EAAuB;CAAG;AAEhF,uCAAuC;AACvC,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAKhD,OAAO,OAAO,CAAC,IAAI,CAAC;AACxB,CAAC"}
|
package/dist/coValues/coList.js
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
var _a;
|
2
2
|
import { RawAccount } from "cojson";
|
3
|
-
import { Account, CoValueBase, Group, InitValues, ItemsSym, Ref, SchemaInit,
|
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
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,27 @@ 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 });
|
119
128
|
}
|
120
|
-
static
|
121
|
-
this.
|
122
|
-
Object.assign(this.
|
129
|
+
static schema(def) {
|
130
|
+
this._schema || (this._schema = {});
|
131
|
+
Object.assign(this._schema, def);
|
123
132
|
}
|
124
133
|
}
|
125
134
|
_a = CoList;
|
126
135
|
(() => {
|
127
136
|
_a.prototype._type = "CoList";
|
128
137
|
})();
|
129
|
-
(() => {
|
130
|
-
_a.prototype.subscribe = CoValueBase.prototype.subscribe;
|
131
|
-
})();
|
132
|
-
(() => {
|
133
|
-
_a.prototype.subscribeEf = CoValueBase.prototype.subscribeEf;
|
134
|
-
})();
|
135
|
-
CoList.loadEf = CoValueBase.loadEf;
|
136
138
|
CoList.load = CoValueBase.load;
|
137
|
-
CoList.
|
139
|
+
CoList.loadEf = CoValueBase.loadEf;
|
138
140
|
CoList.subscribe = CoValueBase.subscribe;
|
141
|
+
CoList.subscribeEf = CoValueBase.subscribeEf;
|
139
142
|
function toRawItems(items, itemDescriptor) {
|
140
143
|
const rawItems = itemDescriptor === "json"
|
141
144
|
? items
|
142
145
|
: "encoded" in itemDescriptor
|
143
|
-
? items?.map((e) =>
|
144
|
-
:
|
146
|
+
? items?.map((e) => encodeSync(itemDescriptor.encoded)(e))
|
147
|
+
: isRefEncoded(itemDescriptor)
|
145
148
|
? items?.map((v) => v.id)
|
146
149
|
: (() => {
|
147
150
|
throw new Error("Invalid element descriptor");
|
@@ -151,7 +154,7 @@ function toRawItems(items, itemDescriptor) {
|
|
151
154
|
function init(list) {
|
152
155
|
if (list[InitValues]) {
|
153
156
|
const { init, owner } = list[InitValues];
|
154
|
-
const raw = owner._raw.createList(toRawItems(init, list.
|
157
|
+
const raw = owner._raw.createList(toRawItems(init, list._schema[ItemsSym]));
|
155
158
|
Object.defineProperties(list, {
|
156
159
|
id: {
|
157
160
|
value: raw.id,
|
@@ -165,7 +168,7 @@ function init(list) {
|
|
165
168
|
const CoListProxyHandler = {
|
166
169
|
get(target, key, receiver) {
|
167
170
|
if (typeof key === "string" && !isNaN(+key)) {
|
168
|
-
const itemDescriptor = target.
|
171
|
+
const itemDescriptor = target._schema[ItemsSym];
|
169
172
|
const rawValue = target._raw.get(Number(key));
|
170
173
|
if (itemDescriptor === "json") {
|
171
174
|
return rawValue;
|
@@ -173,12 +176,12 @@ const CoListProxyHandler = {
|
|
173
176
|
else if ("encoded" in itemDescriptor) {
|
174
177
|
return rawValue === undefined
|
175
178
|
? undefined
|
176
|
-
:
|
179
|
+
: decodeSync(itemDescriptor.encoded)(rawValue);
|
177
180
|
}
|
178
|
-
else if (
|
181
|
+
else if (isRefEncoded(itemDescriptor)) {
|
179
182
|
return rawValue === undefined
|
180
183
|
? undefined
|
181
|
-
: new Ref(rawValue, target._loadedAs, itemDescriptor).accessFrom(receiver);
|
184
|
+
: new Ref(rawValue, target._loadedAs, itemDescriptor).accessFrom(receiver, Number(key));
|
182
185
|
}
|
183
186
|
}
|
184
187
|
else if (key === "length") {
|
@@ -193,22 +196,22 @@ const CoListProxyHandler = {
|
|
193
196
|
if (key === ItemsSym &&
|
194
197
|
typeof value === "object" &&
|
195
198
|
SchemaInit in value) {
|
196
|
-
(_b = target.constructor).
|
197
|
-
target.constructor.
|
199
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
200
|
+
target.constructor._schema[ItemsSym] =
|
198
201
|
value[SchemaInit];
|
199
202
|
init(target);
|
200
203
|
return true;
|
201
204
|
}
|
202
205
|
if (typeof key === "string" && !isNaN(+key)) {
|
203
|
-
const itemDescriptor = target.
|
206
|
+
const itemDescriptor = target._schema[ItemsSym];
|
204
207
|
let rawValue;
|
205
208
|
if (itemDescriptor === "json") {
|
206
209
|
rawValue = value;
|
207
210
|
}
|
208
211
|
else if ("encoded" in itemDescriptor) {
|
209
|
-
rawValue =
|
212
|
+
rawValue = encodeSync(itemDescriptor.encoded)(value);
|
210
213
|
}
|
211
|
-
else if (
|
214
|
+
else if (isRefEncoded(itemDescriptor)) {
|
212
215
|
rawValue = value.id;
|
213
216
|
}
|
214
217
|
target._raw.replace(Number(key), rawValue);
|
@@ -224,8 +227,8 @@ const CoListProxyHandler = {
|
|
224
227
|
key === ItemsSym &&
|
225
228
|
typeof descriptor.value === "object" &&
|
226
229
|
SchemaInit in descriptor.value) {
|
227
|
-
(_b = target.constructor).
|
228
|
-
target.constructor.
|
230
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
231
|
+
target.constructor._schema[ItemsSym] =
|
229
232
|
descriptor.value[SchemaInit];
|
230
233
|
init(target);
|
231
234
|
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;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;AACzB,8DAA8D;AAC9D,MAAM,OAAO,MACT,SAAQ,KAAW;IAGnB,MAAM,CAAC,EAAE,CAAO,IAAU;;QACtB,wCAAwC;QACxC,YAAO,MAAM,QAAS,SAAQ,EAAY;gBAAnC;;oBACH,QAAU,GAAG,IAAI,CAAC;gBACtB,CAA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