jazz-tools 0.8.44 → 0.8.45
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +16 -10
- package/CHANGELOG.md +12 -0
- package/dist/chunk-5WLKIDKU.js +2844 -0
- package/dist/chunk-5WLKIDKU.js.map +1 -0
- package/dist/index.native.js +63 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.web.js +61 -0
- package/dist/index.web.js.map +1 -0
- package/package.json +9 -12
- package/src/coValues/account.ts +21 -9
- package/src/coValues/coFeed.ts +4 -3
- package/src/coValues/coList.ts +8 -5
- package/src/coValues/coMap.ts +6 -3
- package/src/coValues/deepLoading.ts +6 -12
- package/src/coValues/extensions/imageDef.ts +3 -1
- package/src/coValues/group.ts +8 -11
- package/src/coValues/inbox.ts +377 -0
- package/src/coValues/interfaces.ts +9 -6
- package/src/coValues/profile.ts +11 -0
- package/src/coValues/registeredSchemas.ts +12 -0
- package/src/exports.ts +21 -15
- package/src/implementation/anonymousJazzAgent.ts +6 -0
- package/src/implementation/createContext.ts +6 -7
- package/src/implementation/refs.ts +1 -1
- package/src/implementation/subscriptionScope.ts +1 -1
- package/src/index.native.ts +0 -1
- package/src/internal.ts +1 -9
- package/src/tests/account.test.ts +2 -2
- package/src/tests/coFeed.test.ts +0 -9
- package/src/tests/coMap.test.ts +2 -2
- package/src/tests/groupsAndAccounts.test.ts +1 -1
- package/src/tests/inbox.test.ts +256 -0
- package/src/tests/schemaUnion.test.ts +1 -1
- package/src/tests/utils.ts +14 -0
- package/tsup.config.ts +13 -0
- package/dist/native/coValues/account.js +0 -221
- package/dist/native/coValues/account.js.map +0 -1
- package/dist/native/coValues/coFeed.js +0 -571
- package/dist/native/coValues/coFeed.js.map +0 -1
- package/dist/native/coValues/coList.js +0 -404
- package/dist/native/coValues/coList.js.map +0 -1
- package/dist/native/coValues/coMap.js +0 -537
- package/dist/native/coValues/coMap.js.map +0 -1
- package/dist/native/coValues/deepLoading.js +0 -63
- package/dist/native/coValues/deepLoading.js.map +0 -1
- package/dist/native/coValues/extensions/imageDef.js +0 -42
- package/dist/native/coValues/extensions/imageDef.js.map +0 -1
- package/dist/native/coValues/group.js +0 -136
- package/dist/native/coValues/group.js.map +0 -1
- package/dist/native/coValues/interfaces.js +0 -135
- package/dist/native/coValues/interfaces.js.map +0 -1
- package/dist/native/coValues/schemaUnion.js +0 -89
- package/dist/native/coValues/schemaUnion.js.map +0 -1
- package/dist/native/exports.js +0 -5
- package/dist/native/exports.js.map +0 -1
- package/dist/native/implementation/createContext.js +0 -157
- package/dist/native/implementation/createContext.js.map +0 -1
- package/dist/native/implementation/devtoolsFormatters.js +0 -95
- package/dist/native/implementation/devtoolsFormatters.js.map +0 -1
- package/dist/native/implementation/errors.js +0 -2
- package/dist/native/implementation/errors.js.map +0 -1
- package/dist/native/implementation/inspect.js +0 -2
- package/dist/native/implementation/inspect.js.map +0 -1
- package/dist/native/implementation/refs.js +0 -115
- package/dist/native/implementation/refs.js.map +0 -1
- package/dist/native/implementation/schema.js +0 -96
- package/dist/native/implementation/schema.js.map +0 -1
- package/dist/native/implementation/subscriptionScope.js +0 -91
- package/dist/native/implementation/subscriptionScope.js.map +0 -1
- package/dist/native/implementation/symbols.js +0 -4
- package/dist/native/implementation/symbols.js.map +0 -1
- package/dist/native/index.native.js +0 -3
- package/dist/native/index.native.js.map +0 -1
- package/dist/native/internal.js +0 -18
- package/dist/native/internal.js.map +0 -1
- package/dist/native/lib/cache.js +0 -13
- package/dist/native/lib/cache.js.map +0 -1
- package/dist/native/lib/cache.test.js +0 -52
- package/dist/native/lib/cache.test.js.map +0 -1
- package/dist/web/coValues/account.js +0 -221
- package/dist/web/coValues/account.js.map +0 -1
- package/dist/web/coValues/coFeed.js +0 -571
- package/dist/web/coValues/coFeed.js.map +0 -1
- package/dist/web/coValues/coList.js +0 -404
- package/dist/web/coValues/coList.js.map +0 -1
- package/dist/web/coValues/coMap.js +0 -537
- package/dist/web/coValues/coMap.js.map +0 -1
- package/dist/web/coValues/deepLoading.js +0 -63
- package/dist/web/coValues/deepLoading.js.map +0 -1
- package/dist/web/coValues/extensions/imageDef.js +0 -42
- package/dist/web/coValues/extensions/imageDef.js.map +0 -1
- package/dist/web/coValues/group.js +0 -136
- package/dist/web/coValues/group.js.map +0 -1
- package/dist/web/coValues/interfaces.js +0 -135
- package/dist/web/coValues/interfaces.js.map +0 -1
- package/dist/web/coValues/schemaUnion.js +0 -89
- package/dist/web/coValues/schemaUnion.js.map +0 -1
- package/dist/web/exports.js +0 -5
- package/dist/web/exports.js.map +0 -1
- package/dist/web/implementation/createContext.js +0 -157
- package/dist/web/implementation/createContext.js.map +0 -1
- package/dist/web/implementation/devtoolsFormatters.js +0 -95
- package/dist/web/implementation/devtoolsFormatters.js.map +0 -1
- package/dist/web/implementation/errors.js +0 -2
- package/dist/web/implementation/errors.js.map +0 -1
- package/dist/web/implementation/inspect.js +0 -2
- package/dist/web/implementation/inspect.js.map +0 -1
- package/dist/web/implementation/refs.js +0 -115
- package/dist/web/implementation/refs.js.map +0 -1
- package/dist/web/implementation/schema.js +0 -96
- package/dist/web/implementation/schema.js.map +0 -1
- package/dist/web/implementation/subscriptionScope.js +0 -91
- package/dist/web/implementation/subscriptionScope.js.map +0 -1
- package/dist/web/implementation/symbols.js +0 -4
- package/dist/web/implementation/symbols.js.map +0 -1
- package/dist/web/index.web.js +0 -3
- package/dist/web/index.web.js.map +0 -1
- package/dist/web/internal.js +0 -18
- package/dist/web/internal.js.map +0 -1
- package/dist/web/lib/cache.js +0 -13
- package/dist/web/lib/cache.js.map +0 -1
- package/dist/web/lib/cache.test.js +0 -52
- package/dist/web/lib/cache.test.js.map +0 -1
@@ -1,571 +0,0 @@
|
|
1
|
-
var _a;
|
2
|
-
import { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from "cojson";
|
3
|
-
import { Account, CoValueBase, ItemsSym, Ref, SchemaInit, co, ensureCoValueLoaded, inspect, isRefEncoded, loadCoValue, subscribeToCoValue, subscribeToExistingCoValue, } from "../internal.js";
|
4
|
-
/** @deprecated Use CoFeed instead */
|
5
|
-
export { CoFeed as CoStream };
|
6
|
-
/**
|
7
|
-
* CoFeeds are collaborative logs of data.
|
8
|
-
*
|
9
|
-
* @categoryDescription Content
|
10
|
-
* They are similar to `CoList`s, but with a few key differences:
|
11
|
-
* - They are append-only
|
12
|
-
* - They consist of several internal append-only logs, one per account session (tab, device, app instance, etc.)
|
13
|
-
* - They expose those as a per-account aggregated view (default) or a precise per-session view
|
14
|
-
*
|
15
|
-
* ```ts
|
16
|
-
* favDog.push("Poodle");
|
17
|
-
* favDog.push("Schnowzer");
|
18
|
-
* ```
|
19
|
-
*
|
20
|
-
* @category CoValues
|
21
|
-
*/
|
22
|
-
export class CoFeed extends CoValueBase {
|
23
|
-
/**
|
24
|
-
* Declare a `CoFeed` by subclassing `CoFeed.Of(...)` and passing the item schema using a `co` primitive or a `co.ref`.
|
25
|
-
*
|
26
|
-
* @example
|
27
|
-
* ```ts
|
28
|
-
* class ColorFeed extends CoFeed.Of(co.string) {}
|
29
|
-
* class AnimalFeed extends CoFeed.Of(co.ref(Animal)) {}
|
30
|
-
* ```
|
31
|
-
*
|
32
|
-
* @category Declaration
|
33
|
-
*/
|
34
|
-
static Of(item) {
|
35
|
-
var _b, _c;
|
36
|
-
return _c = class CoFeedOf extends _a {
|
37
|
-
constructor() {
|
38
|
-
super(...arguments);
|
39
|
-
this[_b] = item;
|
40
|
-
}
|
41
|
-
},
|
42
|
-
_b = co.items,
|
43
|
-
_c;
|
44
|
-
}
|
45
|
-
/** @internal */
|
46
|
-
get _schema() {
|
47
|
-
return this.constructor._schema;
|
48
|
-
}
|
49
|
-
/**
|
50
|
-
* The current account's view of this `CoFeed`
|
51
|
-
* @category Content
|
52
|
-
*/
|
53
|
-
get byMe() {
|
54
|
-
if (this._loadedAs._type === "Account") {
|
55
|
-
return this[this._loadedAs.id];
|
56
|
-
}
|
57
|
-
else {
|
58
|
-
return undefined;
|
59
|
-
}
|
60
|
-
}
|
61
|
-
/**
|
62
|
-
* The current session's view of this `CoFeed`
|
63
|
-
*
|
64
|
-
* This is a shortcut for `this.perSession` where the session ID is the current session ID.
|
65
|
-
*
|
66
|
-
* @category Content
|
67
|
-
*/
|
68
|
-
get inCurrentSession() {
|
69
|
-
if (this._loadedAs._type === "Account") {
|
70
|
-
return this.perSession[this._loadedAs.sessionID];
|
71
|
-
}
|
72
|
-
else {
|
73
|
-
return undefined;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
constructor(options) {
|
77
|
-
super();
|
78
|
-
if (options && "fromRaw" in options) {
|
79
|
-
Object.defineProperties(this, {
|
80
|
-
id: {
|
81
|
-
value: options.fromRaw.id,
|
82
|
-
enumerable: false,
|
83
|
-
},
|
84
|
-
_raw: { value: options.fromRaw, enumerable: false },
|
85
|
-
});
|
86
|
-
}
|
87
|
-
return new Proxy(this, CoStreamProxyHandler);
|
88
|
-
}
|
89
|
-
/**
|
90
|
-
* Create a new `CoFeed`
|
91
|
-
* @category Creation
|
92
|
-
*/
|
93
|
-
static create(init, options) {
|
94
|
-
const instance = new this({ init, owner: options.owner });
|
95
|
-
const raw = options.owner._raw.createStream();
|
96
|
-
Object.defineProperties(instance, {
|
97
|
-
id: {
|
98
|
-
value: raw.id,
|
99
|
-
enumerable: false,
|
100
|
-
},
|
101
|
-
_raw: { value: raw, enumerable: false },
|
102
|
-
});
|
103
|
-
if (init) {
|
104
|
-
instance.push(...init);
|
105
|
-
}
|
106
|
-
return instance;
|
107
|
-
}
|
108
|
-
/**
|
109
|
-
* Push items to this `CoFeed`
|
110
|
-
*
|
111
|
-
* Items are appended to the current session's log. Each session (tab, device, app instance)
|
112
|
-
* maintains its own append-only log, which is then aggregated into the per-account view.
|
113
|
-
*
|
114
|
-
* @example
|
115
|
-
* ```ts
|
116
|
-
* // Adds items to current session's log
|
117
|
-
* feed.push("item1", "item2");
|
118
|
-
*
|
119
|
-
* // View items from current session
|
120
|
-
* console.log(feed.inCurrentSession);
|
121
|
-
*
|
122
|
-
* // View aggregated items from all sessions for current account
|
123
|
-
* console.log(feed.byMe);
|
124
|
-
* ```
|
125
|
-
*
|
126
|
-
* @category Content
|
127
|
-
*/
|
128
|
-
push(...items) {
|
129
|
-
for (const item of items) {
|
130
|
-
this.pushItem(item);
|
131
|
-
}
|
132
|
-
}
|
133
|
-
pushItem(item) {
|
134
|
-
const itemDescriptor = this._schema[ItemsSym];
|
135
|
-
if (itemDescriptor === "json") {
|
136
|
-
this._raw.push(item);
|
137
|
-
}
|
138
|
-
else if ("encoded" in itemDescriptor) {
|
139
|
-
this._raw.push(itemDescriptor.encoded.encode(item));
|
140
|
-
}
|
141
|
-
else if (isRefEncoded(itemDescriptor)) {
|
142
|
-
this._raw.push(item.id);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
/**
|
146
|
-
* Get a JSON representation of the `CoFeed`
|
147
|
-
* @category
|
148
|
-
*/
|
149
|
-
toJSON() {
|
150
|
-
const itemDescriptor = this._schema[ItemsSym];
|
151
|
-
const mapper = itemDescriptor === "json"
|
152
|
-
? (v) => v
|
153
|
-
: "encoded" in itemDescriptor
|
154
|
-
? itemDescriptor.encoded.encode
|
155
|
-
: (v) => v && v.id;
|
156
|
-
return {
|
157
|
-
id: this.id,
|
158
|
-
_type: this._type,
|
159
|
-
...Object.fromEntries(Object.entries(this).map(([account, entry]) => [
|
160
|
-
account,
|
161
|
-
mapper(entry.value),
|
162
|
-
])),
|
163
|
-
in: Object.fromEntries(Object.entries(this.perSession).map(([session, entry]) => [
|
164
|
-
session,
|
165
|
-
mapper(entry.value),
|
166
|
-
])),
|
167
|
-
};
|
168
|
-
}
|
169
|
-
/** @internal */
|
170
|
-
[inspect]() {
|
171
|
-
return this.toJSON();
|
172
|
-
}
|
173
|
-
/** @internal */
|
174
|
-
static schema(def) {
|
175
|
-
this._schema ||= {};
|
176
|
-
Object.assign(this._schema, def);
|
177
|
-
}
|
178
|
-
/**
|
179
|
-
* Load a `CoFeed`
|
180
|
-
* @category Subscription & Loading
|
181
|
-
*/
|
182
|
-
static load(id, as, depth) {
|
183
|
-
return loadCoValue(this, id, as, depth);
|
184
|
-
}
|
185
|
-
/**
|
186
|
-
* Subscribe to a `CoFeed`, when you have an ID but don't have a `CoFeed` instance yet
|
187
|
-
* @category Subscription & Loading
|
188
|
-
*/
|
189
|
-
static subscribe(id, as, depth, listener) {
|
190
|
-
return subscribeToCoValue(this, id, as, depth, listener);
|
191
|
-
}
|
192
|
-
/**
|
193
|
-
* Ensure a `CoFeed` is loaded to the specified depth
|
194
|
-
*
|
195
|
-
* @returns A new instance of the same CoFeed that's loaded to the specified depth,
|
196
|
-
* or undefined if it cannot be loaded that deeply
|
197
|
-
* @category Subscription & Loading
|
198
|
-
*/
|
199
|
-
ensureLoaded(depth) {
|
200
|
-
return ensureCoValueLoaded(this, depth);
|
201
|
-
}
|
202
|
-
/**
|
203
|
-
* An instance method to subscribe to an existing `CoFeed`
|
204
|
-
*
|
205
|
-
* No need to provide an ID or Account since they're already part of the instance.
|
206
|
-
* @category Subscription & Loading
|
207
|
-
*/
|
208
|
-
subscribe(depth, listener) {
|
209
|
-
return subscribeToExistingCoValue(this, depth, listener);
|
210
|
-
}
|
211
|
-
/**
|
212
|
-
* Wait for the `CoFeed` to be uploaded to the other peers.
|
213
|
-
*
|
214
|
-
* @category Subscription & Loading
|
215
|
-
*/
|
216
|
-
waitForSync(options) {
|
217
|
-
return this._raw.core.waitForSync(options);
|
218
|
-
}
|
219
|
-
}
|
220
|
-
_a = CoFeed;
|
221
|
-
(() => {
|
222
|
-
_a.prototype._type = "CoStream";
|
223
|
-
})();
|
224
|
-
/**
|
225
|
-
* Converts a raw stream entry into a formatted CoFeed entry with proper typing and accessors.
|
226
|
-
* @internal
|
227
|
-
*/
|
228
|
-
function entryFromRawEntry(accessFrom, rawEntry, loadedAs, accountID, itemField) {
|
229
|
-
return {
|
230
|
-
get value() {
|
231
|
-
if (itemField === "json") {
|
232
|
-
return rawEntry.value;
|
233
|
-
}
|
234
|
-
else if ("encoded" in itemField) {
|
235
|
-
return itemField.encoded.decode(rawEntry.value);
|
236
|
-
}
|
237
|
-
else if (isRefEncoded(itemField)) {
|
238
|
-
return this.ref?.accessFrom(accessFrom, rawEntry.by + rawEntry.tx.sessionID + rawEntry.tx.txIndex + ".value");
|
239
|
-
}
|
240
|
-
else {
|
241
|
-
throw new Error("Invalid item field schema");
|
242
|
-
}
|
243
|
-
},
|
244
|
-
get ref() {
|
245
|
-
if (itemField !== "json" && isRefEncoded(itemField)) {
|
246
|
-
const rawId = rawEntry.value;
|
247
|
-
return new Ref(rawId, loadedAs, itemField);
|
248
|
-
}
|
249
|
-
else {
|
250
|
-
return undefined;
|
251
|
-
}
|
252
|
-
},
|
253
|
-
get by() {
|
254
|
-
return (accountID &&
|
255
|
-
new Ref(accountID, loadedAs, {
|
256
|
-
ref: Account,
|
257
|
-
optional: false,
|
258
|
-
})?.accessFrom(accessFrom, rawEntry.by + rawEntry.tx.sessionID + rawEntry.tx.txIndex + ".by"));
|
259
|
-
},
|
260
|
-
madeAt: rawEntry.at,
|
261
|
-
tx: rawEntry.tx,
|
262
|
-
};
|
263
|
-
}
|
264
|
-
/**
|
265
|
-
* The proxy handler for `CoFeed` instances
|
266
|
-
* @internal
|
267
|
-
*/
|
268
|
-
export const CoStreamProxyHandler = {
|
269
|
-
get(target, key, receiver) {
|
270
|
-
if (typeof key === "string" && key.startsWith("co_")) {
|
271
|
-
const rawEntry = target._raw.lastItemBy(key);
|
272
|
-
if (!rawEntry)
|
273
|
-
return;
|
274
|
-
const entry = entryFromRawEntry(receiver, rawEntry, target._loadedAs, key, target._schema[ItemsSym]);
|
275
|
-
Object.defineProperty(entry, "all", {
|
276
|
-
get: () => {
|
277
|
-
const allRawEntries = target._raw.itemsBy(key);
|
278
|
-
return (function* () {
|
279
|
-
while (true) {
|
280
|
-
const rawEntry = allRawEntries.next();
|
281
|
-
if (rawEntry.done)
|
282
|
-
return;
|
283
|
-
yield entryFromRawEntry(receiver, rawEntry.value, target._loadedAs, key, target._schema[ItemsSym]);
|
284
|
-
}
|
285
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
286
|
-
})();
|
287
|
-
},
|
288
|
-
});
|
289
|
-
return entry;
|
290
|
-
}
|
291
|
-
else if (key === "perSession") {
|
292
|
-
return new Proxy({}, CoStreamPerSessionProxyHandler(target, receiver));
|
293
|
-
}
|
294
|
-
else {
|
295
|
-
return Reflect.get(target, key, receiver);
|
296
|
-
}
|
297
|
-
},
|
298
|
-
set(target, key, value, receiver) {
|
299
|
-
if (key === ItemsSym && typeof value === "object" && SchemaInit in value) {
|
300
|
-
target.constructor._schema ||= {};
|
301
|
-
target.constructor._schema[ItemsSym] =
|
302
|
-
value[SchemaInit];
|
303
|
-
return true;
|
304
|
-
}
|
305
|
-
else {
|
306
|
-
return Reflect.set(target, key, value, receiver);
|
307
|
-
}
|
308
|
-
},
|
309
|
-
defineProperty(target, key, descriptor) {
|
310
|
-
if (descriptor.value &&
|
311
|
-
key === ItemsSym &&
|
312
|
-
typeof descriptor.value === "object" &&
|
313
|
-
SchemaInit in descriptor.value) {
|
314
|
-
target.constructor._schema ||= {};
|
315
|
-
target.constructor._schema[ItemsSym] =
|
316
|
-
descriptor.value[SchemaInit];
|
317
|
-
return true;
|
318
|
-
}
|
319
|
-
else {
|
320
|
-
return Reflect.defineProperty(target, key, descriptor);
|
321
|
-
}
|
322
|
-
},
|
323
|
-
ownKeys(target) {
|
324
|
-
const keys = Reflect.ownKeys(target);
|
325
|
-
for (const accountID of target._raw.accounts()) {
|
326
|
-
keys.push(accountID);
|
327
|
-
}
|
328
|
-
return keys;
|
329
|
-
},
|
330
|
-
getOwnPropertyDescriptor(target, key) {
|
331
|
-
if (typeof key === "string" && key.startsWith("co_")) {
|
332
|
-
return {
|
333
|
-
configurable: true,
|
334
|
-
enumerable: true,
|
335
|
-
writable: false,
|
336
|
-
};
|
337
|
-
}
|
338
|
-
else {
|
339
|
-
return Reflect.getOwnPropertyDescriptor(target, key);
|
340
|
-
}
|
341
|
-
},
|
342
|
-
};
|
343
|
-
/**
|
344
|
-
* The proxy handler for the per-session view of a `CoFeed`
|
345
|
-
* @internal
|
346
|
-
*/
|
347
|
-
const CoStreamPerSessionProxyHandler = (innerTarget, accessFrom) => ({
|
348
|
-
get(_target, key, receiver) {
|
349
|
-
if (typeof key === "string" && key.includes("session")) {
|
350
|
-
const sessionID = key;
|
351
|
-
const rawEntry = innerTarget._raw.lastItemIn(sessionID);
|
352
|
-
if (!rawEntry)
|
353
|
-
return;
|
354
|
-
const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);
|
355
|
-
const entry = entryFromRawEntry(accessFrom, rawEntry, innerTarget._loadedAs, cojsonInternals.isAccountID(by)
|
356
|
-
? by
|
357
|
-
: undefined, innerTarget._schema[ItemsSym]);
|
358
|
-
Object.defineProperty(entry, "all", {
|
359
|
-
get: () => {
|
360
|
-
const allRawEntries = innerTarget._raw.itemsIn(sessionID);
|
361
|
-
return (function* () {
|
362
|
-
while (true) {
|
363
|
-
const rawEntry = allRawEntries.next();
|
364
|
-
if (rawEntry.done)
|
365
|
-
return;
|
366
|
-
yield entryFromRawEntry(accessFrom, rawEntry.value, innerTarget._loadedAs, cojsonInternals.isAccountID(by)
|
367
|
-
? by
|
368
|
-
: undefined, innerTarget._schema[ItemsSym]);
|
369
|
-
}
|
370
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
371
|
-
})();
|
372
|
-
},
|
373
|
-
});
|
374
|
-
return entry;
|
375
|
-
}
|
376
|
-
else {
|
377
|
-
return Reflect.get(innerTarget, key, receiver);
|
378
|
-
}
|
379
|
-
},
|
380
|
-
ownKeys() {
|
381
|
-
return innerTarget._raw.sessions();
|
382
|
-
},
|
383
|
-
getOwnPropertyDescriptor(target, key) {
|
384
|
-
if (typeof key === "string" && key.startsWith("co_")) {
|
385
|
-
return {
|
386
|
-
configurable: true,
|
387
|
-
enumerable: true,
|
388
|
-
writable: false,
|
389
|
-
};
|
390
|
-
}
|
391
|
-
else {
|
392
|
-
return Reflect.getOwnPropertyDescriptor(target, key);
|
393
|
-
}
|
394
|
-
},
|
395
|
-
});
|
396
|
-
/** @deprecated Use FileStream instead */
|
397
|
-
export { FileStream as BinaryCoStream };
|
398
|
-
/**
|
399
|
-
* FileStreams are `CoFeed`s that contain binary data, collaborative versions of `Blob`s.
|
400
|
-
*
|
401
|
-
* @categoryDescription Declaration
|
402
|
-
* `FileStream` can be referenced in schemas.
|
403
|
-
*
|
404
|
-
* ```ts
|
405
|
-
* import { co, FileStream } from "jazz-tools";
|
406
|
-
*
|
407
|
-
* class MyCoMap extends CoMap {
|
408
|
-
* file = co.ref(FileStream);
|
409
|
-
* }
|
410
|
-
* ```
|
411
|
-
*
|
412
|
-
* @category CoValues
|
413
|
-
*/
|
414
|
-
export class FileStream extends CoValueBase {
|
415
|
-
constructor(options) {
|
416
|
-
super();
|
417
|
-
let raw;
|
418
|
-
if ("fromRaw" in options) {
|
419
|
-
raw = options.fromRaw;
|
420
|
-
}
|
421
|
-
else {
|
422
|
-
const rawOwner = options.owner._raw;
|
423
|
-
raw = rawOwner.createBinaryStream();
|
424
|
-
}
|
425
|
-
Object.defineProperties(this, {
|
426
|
-
id: {
|
427
|
-
value: raw.id,
|
428
|
-
enumerable: false,
|
429
|
-
},
|
430
|
-
_type: { value: "BinaryCoStream", enumerable: false },
|
431
|
-
_raw: { value: raw, enumerable: false },
|
432
|
-
});
|
433
|
-
}
|
434
|
-
static create(options) {
|
435
|
-
return new this(options);
|
436
|
-
}
|
437
|
-
getChunks(options) {
|
438
|
-
return this._raw.getBinaryChunks(options?.allowUnfinished);
|
439
|
-
}
|
440
|
-
isBinaryStreamEnded() {
|
441
|
-
return this._raw.isBinaryStreamEnded();
|
442
|
-
}
|
443
|
-
start(options) {
|
444
|
-
this._raw.startBinaryStream(options);
|
445
|
-
}
|
446
|
-
push(data) {
|
447
|
-
this._raw.pushBinaryStreamChunk(data);
|
448
|
-
}
|
449
|
-
end() {
|
450
|
-
this._raw.endBinaryStream();
|
451
|
-
}
|
452
|
-
toBlob(options) {
|
453
|
-
const chunks = this.getChunks({
|
454
|
-
allowUnfinished: options?.allowUnfinished,
|
455
|
-
});
|
456
|
-
if (!chunks) {
|
457
|
-
return undefined;
|
458
|
-
}
|
459
|
-
// @ts-ignore
|
460
|
-
return new Blob(chunks.chunks, { type: chunks.mimeType });
|
461
|
-
}
|
462
|
-
/**
|
463
|
-
* Load a `FileStream` as a `Blob`
|
464
|
-
*
|
465
|
-
* @category Content
|
466
|
-
*/
|
467
|
-
static async loadAsBlob(id, as, options) {
|
468
|
-
let stream = await this.load(id, as, []);
|
469
|
-
/**
|
470
|
-
* If the user hasn't requested an incomplete blob and the
|
471
|
-
* stream isn't complete wait for the stream download before progressing
|
472
|
-
*/
|
473
|
-
if (!options?.allowUnfinished && !stream?.isBinaryStreamEnded()) {
|
474
|
-
stream = await new Promise((resolve) => {
|
475
|
-
const unsubscribe = subscribeToCoValue(this, id, as, [], (value) => {
|
476
|
-
if (value.isBinaryStreamEnded()) {
|
477
|
-
unsubscribe();
|
478
|
-
resolve(value);
|
479
|
-
}
|
480
|
-
});
|
481
|
-
});
|
482
|
-
}
|
483
|
-
return stream?.toBlob({
|
484
|
-
allowUnfinished: options?.allowUnfinished,
|
485
|
-
});
|
486
|
-
}
|
487
|
-
/**
|
488
|
-
* Create a `FileStream` from a `Blob` or `File`
|
489
|
-
*
|
490
|
-
* @example
|
491
|
-
* ```ts
|
492
|
-
* import { co, FileStream } from "jazz-tools";
|
493
|
-
*
|
494
|
-
* const fileStream = await FileStream.createFromBlob(file, {owner: group})
|
495
|
-
* ```
|
496
|
-
* @category Content
|
497
|
-
*/
|
498
|
-
static async createFromBlob(blob, options) {
|
499
|
-
const stream = this.create({ owner: options.owner });
|
500
|
-
const start = Date.now();
|
501
|
-
const data = new Uint8Array(await blob.arrayBuffer());
|
502
|
-
stream.start({
|
503
|
-
mimeType: blob.type,
|
504
|
-
totalSizeBytes: blob.size,
|
505
|
-
fileName: blob instanceof File ? blob.name : undefined,
|
506
|
-
});
|
507
|
-
const chunkSize = MAX_RECOMMENDED_TX_SIZE;
|
508
|
-
let lastProgressUpdate = Date.now();
|
509
|
-
for (let idx = 0; idx < data.length; idx += chunkSize) {
|
510
|
-
stream.push(data.slice(idx, idx + chunkSize));
|
511
|
-
if (Date.now() - lastProgressUpdate > 100) {
|
512
|
-
options.onProgress?.(idx / data.length);
|
513
|
-
lastProgressUpdate = Date.now();
|
514
|
-
}
|
515
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
516
|
-
}
|
517
|
-
stream.end();
|
518
|
-
const end = Date.now();
|
519
|
-
console.debug("Finished creating binary stream in", (end - start) / 1000, "s - Throughput in MB/s", (1000 * (blob.size / (end - start))) / (1024 * 1024));
|
520
|
-
options.onProgress?.(1);
|
521
|
-
return stream;
|
522
|
-
}
|
523
|
-
/**
|
524
|
-
* Get a JSON representation of the `FileStream`
|
525
|
-
* @category Content
|
526
|
-
*/
|
527
|
-
toJSON() {
|
528
|
-
return {
|
529
|
-
id: this.id,
|
530
|
-
_type: this._type,
|
531
|
-
...this.getChunks(),
|
532
|
-
};
|
533
|
-
}
|
534
|
-
/** @internal */
|
535
|
-
[inspect]() {
|
536
|
-
return this.toJSON();
|
537
|
-
}
|
538
|
-
/**
|
539
|
-
* Load a `FileStream`
|
540
|
-
* @category Subscription & Loading
|
541
|
-
*/
|
542
|
-
static load(id, as, depth) {
|
543
|
-
return loadCoValue(this, id, as, depth);
|
544
|
-
}
|
545
|
-
/**
|
546
|
-
* Subscribe to a `FileStream`, when you have an ID but don't have a `FileStream` instance yet
|
547
|
-
* @category Subscription & Loading
|
548
|
-
*/
|
549
|
-
static subscribe(id, as, depth, listener) {
|
550
|
-
return subscribeToCoValue(this, id, as, depth, listener);
|
551
|
-
}
|
552
|
-
ensureLoaded(depth) {
|
553
|
-
return ensureCoValueLoaded(this, depth);
|
554
|
-
}
|
555
|
-
/**
|
556
|
-
* An instance method to subscribe to an existing `FileStream`
|
557
|
-
* @category Subscription & Loading
|
558
|
-
*/
|
559
|
-
subscribe(depth, listener) {
|
560
|
-
return subscribeToExistingCoValue(this, depth, listener);
|
561
|
-
}
|
562
|
-
/**
|
563
|
-
* Wait for the `FileStream` to be uploaded to the other peers.
|
564
|
-
*
|
565
|
-
* @category Subscription & Loading
|
566
|
-
*/
|
567
|
-
waitForSync(options) {
|
568
|
-
return this._raw.core.waitForSync(options);
|
569
|
-
}
|
570
|
-
}
|
571
|
-
//# sourceMappingURL=coFeed.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"coFeed.js","sourceRoot":"","sources":["../../../src/coValues/coFeed.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAclE,OAAO,EACL,OAAO,EACP,WAAW,EACX,QAAQ,EACR,GAAG,EACH,UAAU,EACV,EAAE,EACF,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAoBxB,qCAAqC;AACrC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,CAAC;AAE9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,MAAmB,SAAQ,WAAW;IACjD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAO,IAAsB;;QACpC,YAAO,MAAM,QAAS,SAAQ,EAAY;gBAAnC;;oBACL,QAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;aAAA;iBADE,EAAE,CAAC,KAAK;eACT;IACJ,CAAC;IAmBD,gBAAgB;IAChB,IAAI,OAAO;QAGT,OAAQ,IAAI,CAAC,WAA6B,CAAC,OAAO,CAAC;IACrD,CAAC;IA0BD;;;OAGG;IACH,IAAI,IAAI;QACN,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC,IAAI,CAAC,SAA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