jazz-tools 0.8.1 → 0.8.3
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/CHANGELOG.md +13 -0
- package/dist/native/coValues/account.js.map +1 -0
- package/dist/native/coValues/coList.js.map +1 -0
- package/dist/native/coValues/coMap.js.map +1 -0
- package/dist/{coValues → native/coValues}/coStream.js +1 -0
- package/dist/native/coValues/coStream.js.map +1 -0
- package/dist/native/coValues/deepLoading.js.map +1 -0
- package/dist/native/coValues/extensions/imageDef.js.map +1 -0
- package/dist/native/coValues/group.js.map +1 -0
- package/dist/native/coValues/interfaces.js.map +1 -0
- package/dist/{implementation → native/implementation}/createContext.js +8 -1
- package/dist/native/implementation/createContext.js.map +1 -0
- package/dist/native/implementation/devtoolsFormatters.js.map +1 -0
- package/dist/{implementation → native/implementation}/errors.js.map +1 -1
- package/dist/native/implementation/inspect.js.map +1 -0
- package/dist/native/implementation/refs.js.map +1 -0
- package/dist/native/implementation/schema.js.map +1 -0
- package/dist/{implementation → native/implementation}/subscriptionScope.js +1 -7
- package/dist/native/implementation/subscriptionScope.js.map +1 -0
- package/dist/native/implementation/symbols.js.map +1 -0
- package/dist/native/index.native.js +12 -0
- package/dist/native/index.native.js.map +1 -0
- package/dist/native/internal.js.map +1 -0
- package/dist/web/coValues/account.js +208 -0
- package/dist/web/coValues/account.js.map +1 -0
- package/dist/web/coValues/coList.js +395 -0
- package/dist/web/coValues/coList.js.map +1 -0
- package/dist/web/coValues/coMap.js +501 -0
- package/dist/web/coValues/coMap.js.map +1 -0
- package/dist/web/coValues/coStream.js +413 -0
- package/dist/web/coValues/coStream.js.map +1 -0
- package/dist/web/coValues/deepLoading.js +60 -0
- package/dist/web/coValues/deepLoading.js.map +1 -0
- package/dist/web/coValues/extensions/imageDef.js +37 -0
- package/dist/web/coValues/extensions/imageDef.js.map +1 -0
- package/dist/web/coValues/group.js +120 -0
- package/dist/web/coValues/group.js.map +1 -0
- package/dist/web/coValues/interfaces.js +109 -0
- package/dist/web/coValues/interfaces.js.map +1 -0
- package/dist/web/implementation/createContext.js +151 -0
- package/dist/web/implementation/createContext.js.map +1 -0
- package/dist/web/implementation/devtoolsFormatters.js +115 -0
- package/dist/web/implementation/devtoolsFormatters.js.map +1 -0
- package/dist/web/implementation/errors.js +2 -0
- package/dist/web/implementation/errors.js.map +1 -0
- package/dist/web/implementation/inspect.js +2 -0
- package/dist/web/implementation/inspect.js.map +1 -0
- package/dist/web/implementation/refs.js +127 -0
- package/dist/web/implementation/refs.js.map +1 -0
- package/dist/web/implementation/schema.js +91 -0
- package/dist/web/implementation/schema.js.map +1 -0
- package/dist/web/implementation/subscriptionScope.js +97 -0
- package/dist/web/implementation/subscriptionScope.js.map +1 -0
- package/dist/web/implementation/symbols.js +4 -0
- package/dist/web/implementation/symbols.js.map +1 -0
- package/dist/{index.js → web/index.web.js} +3 -3
- package/dist/{index.js.map → web/index.web.js.map} +1 -1
- package/dist/web/internal.js +17 -0
- package/dist/web/internal.js.map +1 -0
- package/package.json +27 -9
- package/src/coValues/account.ts +4 -1
- package/src/coValues/coStream.ts +26 -4
- package/src/coValues/group.ts +4 -1
- package/src/implementation/createContext.ts +12 -10
- package/src/implementation/subscriptionScope.ts +1 -7
- package/src/{index.ts → index.native.ts} +2 -3
- package/src/index.web.ts +36 -0
- package/src/tests/coList.test.ts +2 -2
- package/src/tests/coMap.test.ts +11 -9
- package/src/tests/coStream.test.ts +2 -2
- package/src/tests/deepLoading.test.ts +2 -2
- package/src/tests/groupsAndAccounts.test.ts +1 -1
- package/tsconfig.json +5 -4
- package/tsconfig.native.json +11 -0
- package/tsconfig.web.json +11 -0
- package/dist/coValues/account.js.map +0 -1
- package/dist/coValues/coList.js.map +0 -1
- package/dist/coValues/coMap.js.map +0 -1
- package/dist/coValues/coStream.js.map +0 -1
- package/dist/coValues/deepLoading.js.map +0 -1
- package/dist/coValues/extensions/imageDef.js.map +0 -1
- package/dist/coValues/group.js.map +0 -1
- package/dist/coValues/interfaces.js.map +0 -1
- package/dist/implementation/createContext.js.map +0 -1
- package/dist/implementation/devtoolsFormatters.js.map +0 -1
- package/dist/implementation/inspect.js.map +0 -1
- package/dist/implementation/refs.js.map +0 -1
- package/dist/implementation/schema.js.map +0 -1
- package/dist/implementation/subscriptionScope.js.map +0 -1
- package/dist/implementation/symbols.js.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/tests/coList.test.js +0 -221
- package/dist/tests/coList.test.js.map +0 -1
- package/dist/tests/coMap.test.js +0 -615
- package/dist/tests/coMap.test.js.map +0 -1
- package/dist/tests/coStream.test.js +0 -324
- package/dist/tests/coStream.test.js.map +0 -1
- package/dist/tests/deepLoading.test.js +0 -175
- package/dist/tests/deepLoading.test.js.map +0 -1
- package/dist/tests/groupsAndAccounts.test.js +0 -69
- package/dist/tests/groupsAndAccounts.test.js.map +0 -1
- /package/dist/{coValues → native/coValues}/account.js +0 -0
- /package/dist/{coValues → native/coValues}/coList.js +0 -0
- /package/dist/{coValues → native/coValues}/coMap.js +0 -0
- /package/dist/{coValues → native/coValues}/deepLoading.js +0 -0
- /package/dist/{coValues → native/coValues}/extensions/imageDef.js +0 -0
- /package/dist/{coValues → native/coValues}/group.js +0 -0
- /package/dist/{coValues → native/coValues}/interfaces.js +0 -0
- /package/dist/{implementation → native/implementation}/devtoolsFormatters.js +0 -0
- /package/dist/{implementation → native/implementation}/errors.js +0 -0
- /package/dist/{implementation → native/implementation}/inspect.js +0 -0
- /package/dist/{implementation → native/implementation}/refs.js +0 -0
- /package/dist/{implementation → native/implementation}/schema.js +0 -0
- /package/dist/{implementation → native/implementation}/symbols.js +0 -0
- /package/dist/{internal.js → native/internal.js} +0 -0
@@ -0,0 +1,395 @@
|
|
1
|
+
import { RawAccount } from "cojson";
|
2
|
+
import { Account, AnonymousJazzAgent, Group, ItemsSym, Ref, SchemaInit, co, ensureCoValueLoaded, inspect, isRefEncoded, loadCoValue, makeRefs, subscribeToCoValue, subscribeToExistingCoValue, subscriptionsScopes, } from "../internal.js";
|
3
|
+
/**
|
4
|
+
* CoLists are collaborative versions of plain arrays.
|
5
|
+
*
|
6
|
+
* * @categoryDescription Content
|
7
|
+
* You can access items on a `CoList` as if they were normal items on a plain array, using `[]` notation, etc.
|
8
|
+
*
|
9
|
+
* Since `CoList` is a subclass of `Array`, you can use all the normal array methods like `push`, `pop`, `splice`, etc.
|
10
|
+
*
|
11
|
+
* ```ts
|
12
|
+
* colorList[0];
|
13
|
+
* colorList[3] = "yellow";
|
14
|
+
* colorList.push("Kawazaki Green");
|
15
|
+
* colorList.splice(1, 1);
|
16
|
+
* ```
|
17
|
+
*
|
18
|
+
* @category CoValues
|
19
|
+
*/
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
21
|
+
export class CoList extends Array {
|
22
|
+
/**
|
23
|
+
* Declare a `CoList` by subclassing `CoList.Of(...)` and passing the item schema using `co`.
|
24
|
+
*
|
25
|
+
* @example
|
26
|
+
* ```ts
|
27
|
+
* class ColorList extends CoList.Of(
|
28
|
+
* co.string
|
29
|
+
* ) {}
|
30
|
+
* class AnimalList extends CoList.Of(
|
31
|
+
* co.ref(Animal)
|
32
|
+
* ) {}
|
33
|
+
* ```
|
34
|
+
*
|
35
|
+
* @category Declaration
|
36
|
+
*/
|
37
|
+
static Of(item) {
|
38
|
+
// TODO: cache superclass for item class
|
39
|
+
return class CoListOf extends CoList {
|
40
|
+
[co.items] = item;
|
41
|
+
};
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* @ignore
|
45
|
+
* @deprecated Use UPPERCASE `CoList.Of` instead! */
|
46
|
+
static of(..._args) {
|
47
|
+
throw new Error("Can't use Array.of with CoLists");
|
48
|
+
}
|
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
|
+
/** @internal */
|
58
|
+
get _schema() {
|
59
|
+
return this.constructor._schema;
|
60
|
+
}
|
61
|
+
/** @category Collaboration */
|
62
|
+
get _owner() {
|
63
|
+
return this._raw.group instanceof RawAccount
|
64
|
+
? Account.fromRaw(this._raw.group)
|
65
|
+
: Group.fromRaw(this._raw.group);
|
66
|
+
}
|
67
|
+
/**
|
68
|
+
* If a `CoList`'s items are a `co.ref(...)`, you can use `coList._refs[i]` to access
|
69
|
+
* the `Ref` instead of the potentially loaded/null value.
|
70
|
+
*
|
71
|
+
* This allows you to always get the ID or load the value manually.
|
72
|
+
*
|
73
|
+
* @example
|
74
|
+
* ```ts
|
75
|
+
* animals._refs[0].id; // => ID<Animal>
|
76
|
+
* animals._refs[0].value;
|
77
|
+
* // => Animal | null
|
78
|
+
* const animal = await animals._refs[0].load();
|
79
|
+
* ```
|
80
|
+
*
|
81
|
+
* @category Content
|
82
|
+
**/
|
83
|
+
get _refs() {
|
84
|
+
return makeRefs((idx) => this._raw.get(idx), () => Array.from({ length: this._raw.entries().length }, (_, idx) => idx), this._loadedAs, (_idx) => this._schema[ItemsSym]);
|
85
|
+
}
|
86
|
+
get _edits() {
|
87
|
+
throw new Error("Not implemented");
|
88
|
+
}
|
89
|
+
get _loadedAs() {
|
90
|
+
if (this._raw.core.node.account instanceof RawAccount) {
|
91
|
+
return Account.fromRaw(this._raw.core.node.account);
|
92
|
+
}
|
93
|
+
return new AnonymousJazzAgent(this._raw.core.node);
|
94
|
+
}
|
95
|
+
static get [Symbol.species]() {
|
96
|
+
return Array;
|
97
|
+
}
|
98
|
+
constructor(options) {
|
99
|
+
super();
|
100
|
+
Object.defineProperty(this, "_instanceID", {
|
101
|
+
value: `instance-${Math.random().toString(36).slice(2)}`,
|
102
|
+
enumerable: false,
|
103
|
+
});
|
104
|
+
if (options && "fromRaw" in options) {
|
105
|
+
Object.defineProperties(this, {
|
106
|
+
id: {
|
107
|
+
value: options.fromRaw.id,
|
108
|
+
enumerable: false,
|
109
|
+
},
|
110
|
+
_raw: { value: options.fromRaw, enumerable: false },
|
111
|
+
});
|
112
|
+
}
|
113
|
+
return new Proxy(this, CoListProxyHandler);
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Create a new CoList with the given initial values and owner.
|
117
|
+
*
|
118
|
+
* The owner (a Group or Account) determines access rights to the CoMap.
|
119
|
+
*
|
120
|
+
* The CoList will immediately be persisted and synced to connected peers.
|
121
|
+
*
|
122
|
+
* @example
|
123
|
+
* ```ts
|
124
|
+
* const colours = ColorList.create(
|
125
|
+
* ["red", "green", "blue"],
|
126
|
+
* { owner: me }
|
127
|
+
* );
|
128
|
+
* const animals = AnimalList.create(
|
129
|
+
* [cat, dog, fish],
|
130
|
+
* { owner: me }
|
131
|
+
* );
|
132
|
+
* ```
|
133
|
+
*
|
134
|
+
* @category Creation
|
135
|
+
**/
|
136
|
+
static create(items, options) {
|
137
|
+
const instance = new this({ init: items, owner: options.owner });
|
138
|
+
const raw = options.owner._raw.createList(toRawItems(items, instance._schema[ItemsSym]));
|
139
|
+
Object.defineProperties(instance, {
|
140
|
+
id: {
|
141
|
+
value: raw.id,
|
142
|
+
enumerable: false,
|
143
|
+
},
|
144
|
+
_raw: { value: raw, enumerable: false },
|
145
|
+
});
|
146
|
+
return instance;
|
147
|
+
}
|
148
|
+
push(...items) {
|
149
|
+
for (const item of toRawItems(items, this._schema[ItemsSym])) {
|
150
|
+
this._raw.append(item);
|
151
|
+
}
|
152
|
+
return this._raw.entries().length;
|
153
|
+
}
|
154
|
+
unshift(...items) {
|
155
|
+
for (const item of toRawItems(items, this._schema[ItemsSym])) {
|
156
|
+
this._raw.prepend(item);
|
157
|
+
}
|
158
|
+
return this._raw.entries().length;
|
159
|
+
}
|
160
|
+
pop() {
|
161
|
+
const last = this[this.length - 1];
|
162
|
+
this._raw.delete(this.length - 1);
|
163
|
+
return last;
|
164
|
+
}
|
165
|
+
shift() {
|
166
|
+
const first = this[0];
|
167
|
+
this._raw.delete(0);
|
168
|
+
return first;
|
169
|
+
}
|
170
|
+
splice(start, deleteCount, ...items) {
|
171
|
+
const deleted = this.slice(start, start + deleteCount);
|
172
|
+
for (let idxToDelete = start + deleteCount - 1; idxToDelete >= start; idxToDelete--) {
|
173
|
+
this._raw.delete(idxToDelete);
|
174
|
+
}
|
175
|
+
let appendAfter = Math.max(start - 1, 0);
|
176
|
+
for (const item of toRawItems(items, this._schema[ItemsSym])) {
|
177
|
+
console.log(this._raw.asArray(), appendAfter);
|
178
|
+
this._raw.append(item, appendAfter);
|
179
|
+
appendAfter++;
|
180
|
+
}
|
181
|
+
return deleted;
|
182
|
+
}
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
184
|
+
toJSON(_key, seenAbove) {
|
185
|
+
const itemDescriptor = this._schema[ItemsSym];
|
186
|
+
if (itemDescriptor === "json") {
|
187
|
+
return this._raw.asArray();
|
188
|
+
}
|
189
|
+
else if ("encoded" in itemDescriptor) {
|
190
|
+
return this._raw
|
191
|
+
.asArray()
|
192
|
+
.map((e) => itemDescriptor.encoded.encode(e));
|
193
|
+
}
|
194
|
+
else if (isRefEncoded(itemDescriptor)) {
|
195
|
+
return this.map((item, idx) => seenAbove?.includes(item?.id)
|
196
|
+
? { _circular: item.id }
|
197
|
+
: item?.toJSON(idx + "", [
|
198
|
+
...(seenAbove || []),
|
199
|
+
this.id,
|
200
|
+
]));
|
201
|
+
}
|
202
|
+
else {
|
203
|
+
return [];
|
204
|
+
}
|
205
|
+
}
|
206
|
+
[inspect]() {
|
207
|
+
return this.toJSON();
|
208
|
+
}
|
209
|
+
/** @category Internals */
|
210
|
+
static fromRaw(raw) {
|
211
|
+
return new this({ fromRaw: raw });
|
212
|
+
}
|
213
|
+
/** @internal */
|
214
|
+
static schema(def) {
|
215
|
+
this._schema ||= {};
|
216
|
+
Object.assign(this._schema, def);
|
217
|
+
}
|
218
|
+
/**
|
219
|
+
* Load a `CoList` with a given ID, as a given account.
|
220
|
+
*
|
221
|
+
* `depth` specifies if item CoValue references should be loaded as well before resolving.
|
222
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
223
|
+
*
|
224
|
+
* You can pass `[]` or for shallowly loading only this CoList, or `[itemDepth]` for recursively loading referenced CoValues.
|
225
|
+
*
|
226
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
227
|
+
*
|
228
|
+
* @example
|
229
|
+
* ```ts
|
230
|
+
* const animalsWithVets =
|
231
|
+
* await ListOfAnimals.load(
|
232
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
233
|
+
* me,
|
234
|
+
* [{ vet: {} }]
|
235
|
+
* );
|
236
|
+
* ```
|
237
|
+
*
|
238
|
+
* @category Subscription & Loading
|
239
|
+
*/
|
240
|
+
static load(id, as, depth) {
|
241
|
+
return loadCoValue(this, id, as, depth);
|
242
|
+
}
|
243
|
+
/**
|
244
|
+
* Load and subscribe to a `CoList` with a given ID, as a given account.
|
245
|
+
*
|
246
|
+
* Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.
|
247
|
+
*
|
248
|
+
* `depth` specifies if item CoValue references should be loaded as well before calling `listener` for the first time.
|
249
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
250
|
+
*
|
251
|
+
* You can pass `[]` or for shallowly loading only this CoList, or `[itemDepth]` for recursively loading referenced CoValues.
|
252
|
+
*
|
253
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
254
|
+
*
|
255
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
256
|
+
*
|
257
|
+
* Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.
|
258
|
+
*
|
259
|
+
* @example
|
260
|
+
* ```ts
|
261
|
+
* const unsub = ListOfAnimals.subscribe(
|
262
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
263
|
+
* me,
|
264
|
+
* { vet: {} },
|
265
|
+
* (animalsWithVets) => console.log(animalsWithVets)
|
266
|
+
* );
|
267
|
+
* ```
|
268
|
+
*
|
269
|
+
* @category Subscription & Loading
|
270
|
+
*/
|
271
|
+
static subscribe(id, as, depth, listener) {
|
272
|
+
return subscribeToCoValue(this, id, as, depth, listener);
|
273
|
+
}
|
274
|
+
/**
|
275
|
+
* Given an already loaded `CoList`, ensure that items are loaded to the specified depth.
|
276
|
+
*
|
277
|
+
* Works like `CoList.load()`, but you don't need to pass the ID or the account to load as again.
|
278
|
+
*
|
279
|
+
* @category Subscription & Loading
|
280
|
+
*/
|
281
|
+
ensureLoaded(depth) {
|
282
|
+
return ensureCoValueLoaded(this, depth);
|
283
|
+
}
|
284
|
+
/**
|
285
|
+
* Given an already loaded `CoList`, subscribe to updates to the `CoList` and ensure that items are loaded to the specified depth.
|
286
|
+
*
|
287
|
+
* Works like `CoList.subscribe()`, but you don't need to pass the ID or the account to load as again.
|
288
|
+
*
|
289
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
290
|
+
*
|
291
|
+
* @category Subscription & Loading
|
292
|
+
**/
|
293
|
+
subscribe(depth, listener) {
|
294
|
+
return subscribeToExistingCoValue(this, depth, listener);
|
295
|
+
}
|
296
|
+
/** @category Type Helpers */
|
297
|
+
castAs(cl) {
|
298
|
+
const casted = cl.fromRaw(this._raw);
|
299
|
+
const subscriptionScope = subscriptionsScopes.get(this);
|
300
|
+
if (subscriptionScope) {
|
301
|
+
subscriptionsScopes.set(casted, subscriptionScope);
|
302
|
+
}
|
303
|
+
return casted;
|
304
|
+
}
|
305
|
+
}
|
306
|
+
function toRawItems(items, itemDescriptor) {
|
307
|
+
const rawItems = itemDescriptor === "json"
|
308
|
+
? items
|
309
|
+
: "encoded" in itemDescriptor
|
310
|
+
? items?.map((e) => itemDescriptor.encoded.encode(e))
|
311
|
+
: isRefEncoded(itemDescriptor)
|
312
|
+
? items?.map((v) => v.id)
|
313
|
+
: (() => {
|
314
|
+
throw new Error("Invalid element descriptor");
|
315
|
+
})();
|
316
|
+
return rawItems;
|
317
|
+
}
|
318
|
+
const CoListProxyHandler = {
|
319
|
+
get(target, key, receiver) {
|
320
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
321
|
+
const itemDescriptor = target._schema[ItemsSym];
|
322
|
+
const rawValue = target._raw.get(Number(key));
|
323
|
+
if (itemDescriptor === "json") {
|
324
|
+
return rawValue;
|
325
|
+
}
|
326
|
+
else if ("encoded" in itemDescriptor) {
|
327
|
+
return rawValue === undefined
|
328
|
+
? undefined
|
329
|
+
: itemDescriptor.encoded.decode(rawValue);
|
330
|
+
}
|
331
|
+
else if (isRefEncoded(itemDescriptor)) {
|
332
|
+
return rawValue === undefined
|
333
|
+
? undefined
|
334
|
+
: new Ref(rawValue, target._loadedAs, itemDescriptor).accessFrom(receiver, Number(key));
|
335
|
+
}
|
336
|
+
}
|
337
|
+
else if (key === "length") {
|
338
|
+
return target._raw.entries().length;
|
339
|
+
}
|
340
|
+
else {
|
341
|
+
return Reflect.get(target, key, receiver);
|
342
|
+
}
|
343
|
+
},
|
344
|
+
set(target, key, value, receiver) {
|
345
|
+
if (key === ItemsSym &&
|
346
|
+
typeof value === "object" &&
|
347
|
+
SchemaInit in value) {
|
348
|
+
target.constructor._schema ||= {};
|
349
|
+
target.constructor._schema[ItemsSym] =
|
350
|
+
value[SchemaInit];
|
351
|
+
return true;
|
352
|
+
}
|
353
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
354
|
+
const itemDescriptor = target._schema[ItemsSym];
|
355
|
+
let rawValue;
|
356
|
+
if (itemDescriptor === "json") {
|
357
|
+
rawValue = value;
|
358
|
+
}
|
359
|
+
else if ("encoded" in itemDescriptor) {
|
360
|
+
rawValue = itemDescriptor.encoded.encode(value);
|
361
|
+
}
|
362
|
+
else if (isRefEncoded(itemDescriptor)) {
|
363
|
+
rawValue = value.id;
|
364
|
+
}
|
365
|
+
target._raw.replace(Number(key), rawValue);
|
366
|
+
return true;
|
367
|
+
}
|
368
|
+
else {
|
369
|
+
return Reflect.set(target, key, value, receiver);
|
370
|
+
}
|
371
|
+
},
|
372
|
+
defineProperty(target, key, descriptor) {
|
373
|
+
if (descriptor.value &&
|
374
|
+
key === ItemsSym &&
|
375
|
+
typeof descriptor.value === "object" &&
|
376
|
+
SchemaInit in descriptor.value) {
|
377
|
+
target.constructor._schema ||= {};
|
378
|
+
target.constructor._schema[ItemsSym] =
|
379
|
+
descriptor.value[SchemaInit];
|
380
|
+
return true;
|
381
|
+
}
|
382
|
+
else {
|
383
|
+
return Reflect.defineProperty(target, key, descriptor);
|
384
|
+
}
|
385
|
+
},
|
386
|
+
has(target, key) {
|
387
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
388
|
+
return Number(key) < target._raw.entries().length;
|
389
|
+
}
|
390
|
+
else {
|
391
|
+
return Reflect.has(target, key);
|
392
|
+
}
|
393
|
+
},
|
394
|
+
};
|
395
|
+
//# sourceMappingURL=coList.js.map
|
@@ -0,0 +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,kBAAkB,EAClB,KAAK,EACL,QAAQ,EACR,GAAG,EACH,UAAU,EACV,EAAE,EACF,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;GAgBG;AACH,8DAA8D;AAC9D,MAAM,OAAO,MAAmB,SAAQ,KAAW;IAC/C;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,EAAE,CAAO,IAAU;QACtB,wCAAwC;QACxC,OAAO,MAAM,QAAS,SAAQ,MAAY;YACtC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,I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