jazz-tools 0.7.35-unique.2 → 0.7.35
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-test.log +44 -57
- package/CHANGELOG.md +8 -10
- package/dist/coValues/account.js +35 -20
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +19 -14
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +33 -32
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +37 -15
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/extensions/imageDef.js +8 -3
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +23 -20
- package/dist/coValues/group.js.map +1 -1
- package/dist/implementation/devtoolsFormatters.js +1 -0
- package/dist/implementation/devtoolsFormatters.js.map +1 -1
- package/dist/implementation/refs.js +0 -3
- package/dist/implementation/refs.js.map +1 -1
- package/dist/implementation/schema.js.map +1 -1
- package/dist/implementation/subscriptionScope.js +5 -8
- package/dist/implementation/subscriptionScope.js.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.js +0 -1
- package/dist/internal.js.map +1 -1
- package/dist/tests/coList.test.js +15 -23
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +216 -75
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +59 -26
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/deepLoading.test.js +41 -28
- package/dist/tests/deepLoading.test.js.map +1 -1
- package/dist/tests/groupsAndAccounts.test.js +22 -8
- package/dist/tests/groupsAndAccounts.test.js.map +1 -1
- package/package.json +3 -3
- package/src/coValues/account.ts +28 -5
- package/src/coValues/coList.ts +4 -4
- package/src/coValues/coMap.ts +54 -46
- package/src/coValues/coStream.ts +30 -5
- package/src/coValues/group.ts +2 -2
- package/src/coValues/interfaces.ts +4 -4
- package/src/implementation/devtoolsFormatters.ts +1 -0
- package/src/implementation/schema.ts +1 -0
- package/src/index.ts +1 -9
- package/src/internal.ts +0 -2
- package/src/tests/coList.test.ts +14 -30
- package/src/tests/coMap.test.ts +158 -49
- package/src/tests/coStream.test.ts +74 -27
- package/src/tests/deepLoading.test.ts +18 -22
- package/tsconfig.json +1 -1
- package/dist/implementation/createContext.js +0 -94
- package/dist/implementation/createContext.js.map +0 -1
- package/src/implementation/createContext.ts +0 -162
package/.turbo/turbo-build.log
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.7.
|
2
|
+
> jazz-tools@0.7.34 build /Users/anselm/jazz/jazz/packages/jazz-tools
|
3
3
|
> npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
|
4
4
|
|
5
5
|
|
6
|
-
> jazz-tools@0.7.
|
6
|
+
> jazz-tools@0.7.34 lint
|
7
7
|
> eslint . --ext ts,tsx
|
8
8
|
|
package/.turbo/turbo-test.log
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.7.35-
|
2
|
+
> jazz-tools@0.7.35-unique.2 test /Users/anselm/jazz/jazz/packages/jazz-tools
|
3
3
|
> vitest --run
|
4
4
|
|
5
5
|
|
6
6
|
RUN v0.34.6 /Users/anselm/jazz/jazz/packages/jazz-tools
|
7
7
|
|
8
|
-
✓ src/tests/groupsAndAccounts.test.ts (1 test)
|
9
|
-
❯ src/tests/coMap.test.ts (0 test)
|
8
|
+
✓ src/tests/groupsAndAccounts.test.ts (1 test) 64ms
|
10
9
|
stdout | unknown test
|
11
10
|
TestMap schema [90mundefined[39m
|
12
|
-
{ uniqueness: { name: [32m'Alice'[39m } }
|
13
11
|
|
14
|
-
✓ src/tests/deepLoading.test.ts (3 tests)
|
15
|
-
✓ src/tests/coList.test.ts (10 tests) 80ms
|
12
|
+
✓ src/tests/deepLoading.test.ts (3 tests) 83ms
|
16
13
|
stdout | src/tests/coList.test.ts > Simple CoList operations > Mutation > splice
|
17
14
|
[ [32m'bread'[39m, [32m'onion'[39m ] [33m0[39m
|
18
15
|
[ [32m'bread'[39m, [32m'salt'[39m, [32m'onion'[39m ] [33m1[39m
|
@@ -25,15 +22,15 @@ subscribedList?.[0]?.[0]?.[0] x
|
|
25
22
|
subscribedList?.[0]?.[0]?.[0] y
|
26
23
|
subscribedList?.[0]?.[0]?.[0] w
|
27
24
|
|
28
|
-
✓ src/tests/
|
25
|
+
✓ src/tests/coList.test.ts (10 tests) 190ms
|
29
26
|
stdout | src/tests/coStream.test.ts > CoStream resolution > Subscription & auto-resolution
|
30
27
|
subscribedStream[me.id] {
|
31
28
|
value: [36m[Getter][39m,
|
32
29
|
ref: [36m[Getter][39m,
|
33
30
|
by: [36m[Getter][39m,
|
34
|
-
madeAt: [35m2024-09-
|
31
|
+
madeAt: [35m2024-09-05T17:35:38.414Z[39m,
|
35
32
|
tx: {
|
36
|
-
sessionID: [32m'
|
33
|
+
sessionID: [32m'co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_ziAMdGVstAxF'[39m,
|
37
34
|
txIndex: [33m0[39m
|
38
35
|
}
|
39
36
|
}
|
@@ -43,9 +40,9 @@ subscribedStream[me.id] {
|
|
43
40
|
value: [36m[Getter][39m,
|
44
41
|
ref: [36m[Getter][39m,
|
45
42
|
by: [36m[Getter][39m,
|
46
|
-
madeAt: [35m2024-09-
|
43
|
+
madeAt: [35m2024-09-05T17:35:38.414Z[39m,
|
47
44
|
tx: {
|
48
|
-
sessionID: [32m'
|
45
|
+
sessionID: [32m'co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_ziAMdGVstAxF'[39m,
|
49
46
|
txIndex: [33m0[39m
|
50
47
|
}
|
51
48
|
}
|
@@ -55,38 +52,38 @@ subscribedStream[me.id] {
|
|
55
52
|
value: [36m[Getter][39m,
|
56
53
|
ref: [36m[Getter][39m,
|
57
54
|
by: [36m[Getter][39m,
|
58
|
-
madeAt: [35m2024-09-
|
55
|
+
madeAt: [35m2024-09-05T17:35:38.414Z[39m,
|
59
56
|
tx: {
|
60
|
-
sessionID: [32m'
|
57
|
+
sessionID: [32m'co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_ziAMdGVstAxF'[39m,
|
61
58
|
txIndex: [33m0[39m
|
62
59
|
}
|
63
60
|
}
|
64
61
|
subscribedStream[me.id]?.value?.[me.id]?.value {
|
65
|
-
id: [32m'
|
62
|
+
id: [32m'co_zHELVqRmAN6YuGDpKqVrSXJ5qe1'[39m,
|
66
63
|
_type: [32m'CoStream'[39m,
|
67
64
|
perSession: [90mundefined[39m,
|
68
|
-
|
69
|
-
in: {
|
65
|
+
co_zURWEpvoH1e35FGHVxadgXKU8Ri: [32m'milk'[39m,
|
66
|
+
in: { co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_ziAMdGVstAxF: [32m'milk'[39m }
|
70
67
|
}
|
71
68
|
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value milk
|
72
69
|
subscribedStream[me.id] {
|
73
70
|
value: [36m[Getter][39m,
|
74
71
|
ref: [36m[Getter][39m,
|
75
72
|
by: [36m[Getter][39m,
|
76
|
-
madeAt: [35m2024-09-
|
73
|
+
madeAt: [35m2024-09-05T17:35:38.414Z[39m,
|
77
74
|
tx: {
|
78
|
-
sessionID: [32m'
|
75
|
+
sessionID: [32m'co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_ziAMdGVstAxF'[39m,
|
79
76
|
txIndex: [33m0[39m
|
80
77
|
}
|
81
78
|
}
|
82
79
|
subscribedStream[me.id]?.value?.[me.id]?.value {
|
83
|
-
id: [32m'
|
80
|
+
id: [32m'co_zHELVqRmAN6YuGDpKqVrSXJ5qe1'[39m,
|
84
81
|
_type: [32m'CoStream'[39m,
|
85
82
|
perSession: [90mundefined[39m,
|
86
|
-
|
83
|
+
co_zURWEpvoH1e35FGHVxadgXKU8Ri: [32m'bread'[39m,
|
87
84
|
in: {
|
88
|
-
|
89
|
-
|
85
|
+
co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_ziAMdGVstAxF: [32m'milk'[39m,
|
86
|
+
co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_zgik2JjD86Qa: [32m'bread'[39m
|
90
87
|
}
|
91
88
|
}
|
92
89
|
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value bread
|
@@ -94,64 +91,54 @@ subscribedStream[me.id] {
|
|
94
91
|
value: [36m[Getter][39m,
|
95
92
|
ref: [36m[Getter][39m,
|
96
93
|
by: [36m[Getter][39m,
|
97
|
-
madeAt: [35m2024-09-
|
94
|
+
madeAt: [35m2024-09-05T17:35:38.424Z[39m,
|
98
95
|
tx: {
|
99
|
-
sessionID: [32m'
|
96
|
+
sessionID: [32m'co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_zgik2JjD86Qa'[39m,
|
100
97
|
txIndex: [33m0[39m
|
101
98
|
}
|
102
99
|
}
|
103
100
|
subscribedStream[me.id]?.value?.[me.id]?.value {
|
104
|
-
id: [32m'
|
101
|
+
id: [32m'co_zJmdvJY15XJkWF3n3rwPgGfebxa'[39m,
|
105
102
|
_type: [32m'CoStream'[39m,
|
106
103
|
perSession: [90mundefined[39m,
|
107
|
-
|
108
|
-
in: {
|
104
|
+
co_zURWEpvoH1e35FGHVxadgXKU8Ri: [32m'butter'[39m,
|
105
|
+
in: { co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_zgik2JjD86Qa: [32m'butter'[39m }
|
109
106
|
}
|
110
107
|
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value butter
|
111
108
|
subscribedStream[me.id] {
|
112
109
|
value: [36m[Getter][39m,
|
113
110
|
ref: [36m[Getter][39m,
|
114
111
|
by: [36m[Getter][39m,
|
115
|
-
madeAt: [35m2024-09-
|
112
|
+
madeAt: [35m2024-09-05T17:35:38.424Z[39m,
|
116
113
|
tx: {
|
117
|
-
sessionID: [32m'
|
114
|
+
sessionID: [32m'co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_zgik2JjD86Qa'[39m,
|
118
115
|
txIndex: [33m0[39m
|
119
116
|
}
|
120
117
|
}
|
121
118
|
subscribedStream[me.id]?.value?.[me.id]?.value {
|
122
|
-
id: [32m'
|
119
|
+
id: [32m'co_zJmdvJY15XJkWF3n3rwPgGfebxa'[39m,
|
123
120
|
_type: [32m'CoStream'[39m,
|
124
121
|
perSession: [90mundefined[39m,
|
125
|
-
|
126
|
-
in: {
|
122
|
+
co_zURWEpvoH1e35FGHVxadgXKU8Ri: [32m'jam'[39m,
|
123
|
+
in: { co_zURWEpvoH1e35FGHVxadgXKU8Ri_session_zgik2JjD86Qa: [32m'jam'[39m }
|
127
124
|
}
|
128
125
|
subscribedStream[me.id]?.value?.[me.id]?.value?.[me.id]?.value jam
|
129
126
|
|
127
|
+
✓ src/tests/coStream.test.ts (10 tests) 205ms
|
128
|
+
stdout | src/tests/coMap.test.ts > CoMap resolution > Subscription & auto-resolution
|
129
|
+
subscribedMap.nested?.twiceNested?.taste [90mundefined[39m
|
130
|
+
subscribedMap.nested?.twiceNested?.taste [90mundefined[39m
|
131
|
+
subscribedMap.nested?.twiceNested?.taste sour
|
132
|
+
subscribedMap.nested?.twiceNested?.taste sour
|
133
|
+
subscribedMap.nested?.twiceNested?.taste sweet
|
134
|
+
subscribedMap.nested?.twiceNested?.taste sweet
|
135
|
+
subscribedMap.nested?.twiceNested?.taste salty
|
136
|
+
subscribedMap.nested?.twiceNested?.taste umami
|
130
137
|
|
131
|
-
|
138
|
+
✓ src/tests/coMap.test.ts (20 tests) 257ms
|
132
139
|
|
133
|
-
|
134
|
-
|
140
|
+
Test Files 5 passed (5)
|
141
|
+
Tests 44 passed (44)
|
142
|
+
Start at 18:35:37
|
143
|
+
Duration 929ms (transform 419ms, setup 0ms, collect 2.29s, tests 799ms, environment 0ms, prepare 298ms)
|
135
144
|
|
136
|
-
- Expected
|
137
|
-
+ Received
|
138
|
-
|
139
|
-
- co_zgryUM2xk2PqvUuyfZjQHs7umXm
|
140
|
-
+ co_zaQaTtTxJoCWMFtuph2MUA5Y89B
|
141
|
-
|
142
|
-
❯ src/tests/coMap.test.ts:762:24
|
143
|
-
760| }, me.id, me);
|
144
|
-
761|
|
145
|
-
762| expect(foundAlice).toEqual(alice.id);
|
146
|
-
| ^
|
147
|
-
763| });
|
148
|
-
764|
|
149
|
-
|
150
|
-
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
|
151
|
-
|
152
|
-
Test Files 1 failed | 4 passed (5)
|
153
|
-
Tests 24 passed (24)
|
154
|
-
Start at 16:58:36
|
155
|
-
Duration 801ms (transform 547ms, setup 0ms, collect 1.78s, tests 275ms, environment 1ms, prepare 400ms)
|
156
|
-
|
157
|
-
ELIFECYCLE Test failed. See above for more details.
|
package/CHANGELOG.md
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
# jazz-autosub
|
2
2
|
|
3
|
-
## 0.7.35
|
3
|
+
## 0.7.35
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
-
-
|
8
|
-
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- Implement new top-level context creation and auth method API
|
7
|
+
- 49a8b54: Fix on CoMapInit to not allow null values on required refs
|
8
|
+
- 6f80282: fix: handle null values for co.refs
|
9
|
+
- 35bbcd9: Fix loadAsBlob resolving too early
|
10
|
+
- f350e90: Added a priority system for the sync messages
|
11
|
+
- Updated dependencies [35bbcd9]
|
12
|
+
- Updated dependencies [f350e90]
|
13
|
+
- cojson@0.7.35
|
16
14
|
|
17
15
|
## 0.7.34
|
18
16
|
|
package/dist/coValues/account.js
CHANGED
@@ -1,30 +1,17 @@
|
|
1
|
+
var _a;
|
1
2
|
import { LocalNode, cojsonInternals } from "cojson";
|
2
3
|
import { CoMap, } from "../internal.js";
|
3
4
|
import { Group, CoValueBase, MembersSym, Profile, Ref, SchemaInit, inspect, subscriptionsScopes, loadCoValue, subscribeToCoValue, ensureCoValueLoaded, subscribeToExistingCoValue, } from "../internal.js";
|
4
5
|
/** @category Identity & Permissions */
|
5
6
|
export class Account extends CoValueBase {
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7
|
-
static _schema;
|
8
7
|
get _schema() {
|
9
8
|
return this.constructor._schema;
|
10
9
|
}
|
11
|
-
static {
|
12
|
-
this._schema = {
|
13
|
-
profile: {
|
14
|
-
ref: () => Profile,
|
15
|
-
optional: false,
|
16
|
-
},
|
17
|
-
root: {
|
18
|
-
ref: () => CoMap,
|
19
|
-
optional: true,
|
20
|
-
},
|
21
|
-
};
|
22
|
-
}
|
23
10
|
get _owner() {
|
24
11
|
return this;
|
25
12
|
}
|
26
13
|
get _loadedAs() {
|
27
|
-
return this.isMe ? this :
|
14
|
+
return this.isMe ? this : _a.fromNode(this._raw.core.node);
|
28
15
|
}
|
29
16
|
get _refs() {
|
30
17
|
const profileID = this._raw.get("profile");
|
@@ -36,8 +23,6 @@ export class Account extends CoValueBase {
|
|
36
23
|
new Ref(rootID, this._loadedAs, this._schema.root),
|
37
24
|
};
|
38
25
|
}
|
39
|
-
isMe;
|
40
|
-
sessionID;
|
41
26
|
constructor(options) {
|
42
27
|
super();
|
43
28
|
if (!("fromRaw" in options)) {
|
@@ -70,7 +55,6 @@ export class Account extends CoValueBase {
|
|
70
55
|
return loadCoValue(coValueClass, valueID, this, []);
|
71
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
72
57
|
}
|
73
|
-
/** @private */
|
74
58
|
static async create(options) {
|
75
59
|
const { node } = await LocalNode.withNewlyCreatedAccount({
|
76
60
|
...options,
|
@@ -83,6 +67,22 @@ export class Account extends CoValueBase {
|
|
83
67
|
});
|
84
68
|
return this.fromNode(node);
|
85
69
|
}
|
70
|
+
static async become(options) {
|
71
|
+
const node = await LocalNode.withLoadedAccount({
|
72
|
+
accountID: options.accountID,
|
73
|
+
accountSecret: options.accountSecret,
|
74
|
+
sessionID: options.sessionID,
|
75
|
+
peersToLoadFrom: options.peersToLoadFrom,
|
76
|
+
crypto: options.crypto,
|
77
|
+
migration: async (rawAccount, _node, creationProps) => {
|
78
|
+
const account = new this({
|
79
|
+
fromRaw: rawAccount,
|
80
|
+
});
|
81
|
+
await account.migrate?.(creationProps);
|
82
|
+
},
|
83
|
+
});
|
84
|
+
return this.fromNode(node);
|
85
|
+
}
|
86
86
|
static async createAs(as, options) {
|
87
87
|
// TODO: is there a cleaner way to do this?
|
88
88
|
const connectedPeers = cojsonInternals.connectedPeers("creatingAccount", "createdAccount", { peer1role: "server", peer2role: "client" });
|
@@ -132,6 +132,19 @@ export class Account extends CoValueBase {
|
|
132
132
|
return subscribeToExistingCoValue(this, depth, listener);
|
133
133
|
}
|
134
134
|
}
|
135
|
+
_a = Account;
|
136
|
+
(() => {
|
137
|
+
_a._schema = {
|
138
|
+
profile: {
|
139
|
+
ref: () => Profile,
|
140
|
+
optional: false,
|
141
|
+
},
|
142
|
+
root: {
|
143
|
+
ref: () => CoMap,
|
144
|
+
optional: true,
|
145
|
+
},
|
146
|
+
};
|
147
|
+
})();
|
135
148
|
export const AccountAndGroupProxyHandler = {
|
136
149
|
get(target, key, receiver) {
|
137
150
|
if (key === "profile") {
|
@@ -151,10 +164,11 @@ export const AccountAndGroupProxyHandler = {
|
|
151
164
|
}
|
152
165
|
},
|
153
166
|
set(target, key, value, receiver) {
|
167
|
+
var _b;
|
154
168
|
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
155
169
|
typeof value === "object" &&
|
156
170
|
SchemaInit in value) {
|
157
|
-
target.constructor._schema
|
171
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
158
172
|
target.constructor._schema[key] =
|
159
173
|
value[SchemaInit];
|
160
174
|
return true;
|
@@ -182,10 +196,11 @@ export const AccountAndGroupProxyHandler = {
|
|
182
196
|
}
|
183
197
|
},
|
184
198
|
defineProperty(target, key, descriptor) {
|
199
|
+
var _b;
|
185
200
|
if ((key === "profile" || key === "root" || key === MembersSym) &&
|
186
201
|
typeof descriptor.value === "object" &&
|
187
202
|
SchemaInit in descriptor.value) {
|
188
|
-
target.constructor._schema
|
203
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
189
204
|
target.constructor._schema[key] =
|
190
205
|
descriptor.value[SchemaInit];
|
191
206
|
return true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAapD,OAAO,EACH,KAAK,GASR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,KAAK,EACL,WAAW,EACX,UAAU,EACV,OAAO,EACP,GAAG,EACH,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,GAC7B,MAAM,gBAAgB,CAAC;AAExB,uCAAuC;AACvC,MAAM,OAAO,OAAQ,SAAQ,WAAW;
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAapD,OAAO,EACH,KAAK,GASR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,KAAK,EACL,WAAW,EACX,UAAU,EACV,OAAO,EACP,GAAG,EACH,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,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;IAcD,IAAI,MAAM;QACN,OAAO,IAAe,CAAC;IAC3B,CAAC;IACD,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,IAAI,CA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C,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,UAAU,mBAAmB,CAAC,OAAgB;IAKhD,OAAO,OAAO,CAAC,IAAI,CAAC;AACxB,CAAC"}
|
package/dist/coValues/coList.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
var _a;
|
1
2
|
import { RawAccount } from "cojson";
|
2
3
|
import { Account, Group, ItemsSym, Ref, SchemaInit, co, ensureCoValueLoaded, inspect, isRefEncoded, loadCoValue, makeRefs, subscribeToCoValue, subscribeToExistingCoValue, subscriptionsScopes, } from "../internal.js";
|
3
4
|
/**
|
@@ -35,10 +36,16 @@ export class CoList extends Array {
|
|
35
36
|
* @category Declaration
|
36
37
|
*/
|
37
38
|
static Of(item) {
|
39
|
+
var _b, _c;
|
38
40
|
// TODO: cache superclass for item class
|
39
|
-
return class CoListOf extends
|
40
|
-
|
41
|
-
|
41
|
+
return _c = class CoListOf extends _a {
|
42
|
+
constructor() {
|
43
|
+
super(...arguments);
|
44
|
+
this[_b] = item;
|
45
|
+
}
|
46
|
+
},
|
47
|
+
_b = co.items,
|
48
|
+
_c;
|
42
49
|
}
|
43
50
|
/**
|
44
51
|
* @ignore
|
@@ -46,14 +53,6 @@ export class CoList extends Array {
|
|
46
53
|
static of(..._args) {
|
47
54
|
throw new Error("Can't use Array.of with CoLists");
|
48
55
|
}
|
49
|
-
static {
|
50
|
-
this.prototype._type = "CoList";
|
51
|
-
}
|
52
|
-
/** @internal This is only a marker type and doesn't exist at runtime */
|
53
|
-
[ItemsSym];
|
54
|
-
/** @internal */
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
56
|
-
static _schema;
|
57
56
|
/** @internal */
|
58
57
|
get _schema() {
|
59
58
|
return this.constructor._schema;
|
@@ -209,7 +208,7 @@ export class CoList extends Array {
|
|
209
208
|
}
|
210
209
|
/** @internal */
|
211
210
|
static schema(def) {
|
212
|
-
this._schema
|
211
|
+
this._schema || (this._schema = {});
|
213
212
|
Object.assign(this._schema, def);
|
214
213
|
}
|
215
214
|
/**
|
@@ -300,6 +299,10 @@ export class CoList extends Array {
|
|
300
299
|
return casted;
|
301
300
|
}
|
302
301
|
}
|
302
|
+
_a = CoList;
|
303
|
+
(() => {
|
304
|
+
_a.prototype._type = "CoList";
|
305
|
+
})();
|
303
306
|
function toRawItems(items, itemDescriptor) {
|
304
307
|
const rawItems = itemDescriptor === "json"
|
305
308
|
? items
|
@@ -339,10 +342,11 @@ const CoListProxyHandler = {
|
|
339
342
|
}
|
340
343
|
},
|
341
344
|
set(target, key, value, receiver) {
|
345
|
+
var _b;
|
342
346
|
if (key === ItemsSym &&
|
343
347
|
typeof value === "object" &&
|
344
348
|
SchemaInit in value) {
|
345
|
-
target.constructor._schema
|
349
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
346
350
|
target.constructor._schema[ItemsSym] =
|
347
351
|
value[SchemaInit];
|
348
352
|
return true;
|
@@ -367,11 +371,12 @@ const CoListProxyHandler = {
|
|
367
371
|
}
|
368
372
|
},
|
369
373
|
defineProperty(target, key, descriptor) {
|
374
|
+
var _b;
|
370
375
|
if (descriptor.value &&
|
371
376
|
key === ItemsSym &&
|
372
377
|
typeof descriptor.value === "object" &&
|
373
378
|
SchemaInit in descriptor.value) {
|
374
|
-
target.constructor._schema
|
379
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
375
380
|
target.constructor._schema[ItemsSym] =
|
376
381
|
descriptor.value[SchemaInit];
|
377
382
|
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;AAapC,OAAO,EACH,OAAO,EACP,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C,MAAM,CAAC;QACtD,CAAC;aAAM,CAAC;YACJ,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC;IACL,CAAC;CACJ,CAAC"}
|
package/dist/coValues/coMap.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
var _a;
|
2
2
|
import { Account, CoValueBase, Ref, SchemaInit, inspect, makeRefs, subscriptionsScopes, ItemsSym, isRefEncoded, loadCoValue, subscribeToCoValue, ensureCoValueLoaded, subscribeToExistingCoValue, } from "../internal.js";
|
3
3
|
/**
|
4
4
|
* CoMaps are collaborative versions of plain objects, mapping string-like keys to values.
|
@@ -34,12 +34,6 @@ import { Account, CoValueBase, Ref, SchemaInit, inspect, makeRefs, subscriptions
|
|
34
34
|
* @category CoValues
|
35
35
|
* */
|
36
36
|
export class CoMap extends CoValueBase {
|
37
|
-
static {
|
38
|
-
this.prototype._type = "CoMap";
|
39
|
-
}
|
40
|
-
/** @internal */
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
42
|
-
static _schema;
|
43
37
|
/** @internal */
|
44
38
|
get _schema() {
|
45
39
|
return this.constructor._schema;
|
@@ -143,9 +137,7 @@ export class CoMap extends CoValueBase {
|
|
143
137
|
**/
|
144
138
|
static create(init, options) {
|
145
139
|
const instance = new this();
|
146
|
-
const raw = instance.rawFromInit(init, options.owner
|
147
|
-
? undefined
|
148
|
-
: { uniqueness: options.unique });
|
140
|
+
const raw = instance.rawFromInit(init, options.owner);
|
149
141
|
Object.defineProperties(instance, {
|
150
142
|
id: {
|
151
143
|
value: raw.id,
|
@@ -192,7 +184,7 @@ export class CoMap extends CoValueBase {
|
|
192
184
|
}
|
193
185
|
/** @internal */
|
194
186
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
195
|
-
rawFromInit(init, owner
|
187
|
+
rawFromInit(init, owner) {
|
196
188
|
const rawOwner = owner._raw;
|
197
189
|
const rawInit = {};
|
198
190
|
if (init)
|
@@ -216,7 +208,7 @@ export class CoMap extends CoValueBase {
|
|
216
208
|
initValue);
|
217
209
|
}
|
218
210
|
}
|
219
|
-
return rawOwner.createMap(rawInit
|
211
|
+
return rawOwner.createMap(rawInit);
|
220
212
|
}
|
221
213
|
/**
|
222
214
|
* Declare a Record-like CoMap schema, by extending `CoMap.Record(...)` and passing the value schema using `co`. Keys are always `string`.
|
@@ -237,10 +229,15 @@ export class CoMap extends CoValueBase {
|
|
237
229
|
* @category Declaration
|
238
230
|
*/
|
239
231
|
static Record(value) {
|
232
|
+
var _b;
|
240
233
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
241
|
-
class RecordLikeCoMap extends
|
242
|
-
|
234
|
+
class RecordLikeCoMap extends _a {
|
235
|
+
constructor() {
|
236
|
+
super(...arguments);
|
237
|
+
this[_b] = value;
|
238
|
+
}
|
243
239
|
}
|
240
|
+
_b = ItemsSym;
|
244
241
|
return RecordLikeCoMap;
|
245
242
|
}
|
246
243
|
/**
|
@@ -298,18 +295,6 @@ export class CoMap extends CoValueBase {
|
|
298
295
|
static subscribe(id, as, depth, listener) {
|
299
296
|
return subscribeToCoValue(this, id, as, depth, listener);
|
300
297
|
}
|
301
|
-
static findUnique(unique, ownerID, as) {
|
302
|
-
const header = {
|
303
|
-
type: "comap",
|
304
|
-
ruleset: {
|
305
|
-
type: "ownedByGroup",
|
306
|
-
group: ownerID,
|
307
|
-
},
|
308
|
-
meta: null,
|
309
|
-
uniqueness: unique,
|
310
|
-
};
|
311
|
-
return cojsonInternals.idforHeader(header, as._raw.core.crypto);
|
312
|
-
}
|
313
298
|
/**
|
314
299
|
* Given an already loaded `CoMap`, ensure that the specified fields are loaded to the specified depth.
|
315
300
|
*
|
@@ -362,6 +347,10 @@ export class CoMap extends CoValueBase {
|
|
362
347
|
return this;
|
363
348
|
}
|
364
349
|
}
|
350
|
+
_a = CoMap;
|
351
|
+
(() => {
|
352
|
+
_a.prototype._type = "CoMap";
|
353
|
+
})();
|
365
354
|
// TODO: cache handlers per descriptor for performance?
|
366
355
|
const CoMapProxyHandler = {
|
367
356
|
get(target, key, receiver) {
|
@@ -396,11 +385,12 @@ const CoMapProxyHandler = {
|
|
396
385
|
}
|
397
386
|
},
|
398
387
|
set(target, key, value, receiver) {
|
388
|
+
var _b;
|
399
389
|
if ((typeof key === "string" || ItemsSym) &&
|
400
390
|
typeof value === "object" &&
|
401
391
|
value !== null &&
|
402
392
|
SchemaInit in value) {
|
403
|
-
target.constructor._schema
|
393
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
404
394
|
target.constructor._schema[key] =
|
405
395
|
value[SchemaInit];
|
406
396
|
return true;
|
@@ -415,10 +405,20 @@ const CoMapProxyHandler = {
|
|
415
405
|
target._raw.set(key, descriptor.encoded.encode(value));
|
416
406
|
}
|
417
407
|
else if (isRefEncoded(descriptor)) {
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
408
|
+
if (value === null) {
|
409
|
+
if (descriptor.optional) {
|
410
|
+
target._raw.set(key, null);
|
411
|
+
}
|
412
|
+
else {
|
413
|
+
throw new Error(`Cannot set required reference ${key} to null`);
|
414
|
+
}
|
415
|
+
}
|
416
|
+
else {
|
417
|
+
target._raw.set(key, value.id);
|
418
|
+
subscriptionsScopes
|
419
|
+
.get(target)
|
420
|
+
?.onRefAccessedOrSet(target.id, value.id);
|
421
|
+
}
|
422
422
|
}
|
423
423
|
return true;
|
424
424
|
}
|
@@ -427,10 +427,11 @@ const CoMapProxyHandler = {
|
|
427
427
|
}
|
428
428
|
},
|
429
429
|
defineProperty(target, key, attributes) {
|
430
|
+
var _b;
|
430
431
|
if ("value" in attributes &&
|
431
432
|
typeof attributes.value === "object" &&
|
432
433
|
SchemaInit in attributes.value) {
|
433
|
-
target.constructor._schema
|
434
|
+
(_b = target.constructor)._schema || (_b._schema = {});
|
434
435
|
target.constructor._schema[key] =
|
435
436
|
attributes.value[SchemaInit];
|
436
437
|
return true;
|