tinybase 4.3.11 → 4.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/cjs/persisters/persister-partykit-client.cjs +1 -1
  2. package/lib/cjs/persisters/persister-partykit-client.cjs.gz +0 -0
  3. package/lib/cjs/persisters/persister-partykit-server.cjs +1 -1
  4. package/lib/cjs/persisters/persister-partykit-server.cjs.gz +0 -0
  5. package/lib/cjs-es6/persisters/persister-partykit-client.cjs +1 -1
  6. package/lib/cjs-es6/persisters/persister-partykit-client.cjs.gz +0 -0
  7. package/lib/cjs-es6/persisters/persister-partykit-server.cjs +1 -1
  8. package/lib/cjs-es6/persisters/persister-partykit-server.cjs.gz +0 -0
  9. package/lib/debug/persisters/persister-partykit-client.js +29 -19
  10. package/lib/debug/persisters/persister-partykit-server.js +155 -64
  11. package/lib/es6/persisters/persister-partykit-client.js +1 -1
  12. package/lib/es6/persisters/persister-partykit-client.js.gz +0 -0
  13. package/lib/es6/persisters/persister-partykit-server.js +1 -1
  14. package/lib/es6/persisters/persister-partykit-server.js.gz +0 -0
  15. package/lib/persisters/persister-partykit-client.js +1 -1
  16. package/lib/persisters/persister-partykit-client.js.gz +0 -0
  17. package/lib/persisters/persister-partykit-server.js +1 -1
  18. package/lib/persisters/persister-partykit-server.js.gz +0 -0
  19. package/lib/types/persisters/persister-indexed-db.d.ts +4 -5
  20. package/lib/types/persisters/persister-partykit-client.d.ts +18 -7
  21. package/lib/types/persisters/persister-partykit-server.d.ts +335 -7
  22. package/lib/types/tools.d.ts +4 -6
  23. package/lib/types/ui-react.d.ts +4 -4
  24. package/lib/types/with-schemas/persisters/persister-indexed-db.d.ts +4 -5
  25. package/lib/types/with-schemas/persisters/persister-partykit-client.d.ts +18 -7
  26. package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +359 -7
  27. package/lib/types/with-schemas/tools.d.ts +4 -6
  28. package/lib/types/with-schemas/ui-react.d.ts +4 -4
  29. package/lib/umd/persisters/persister-partykit-client.js +1 -1
  30. package/lib/umd/persisters/persister-partykit-client.js.gz +0 -0
  31. package/lib/umd/persisters/persister-partykit-server.js +1 -1
  32. package/lib/umd/persisters/persister-partykit-server.js.gz +0 -0
  33. package/lib/umd-es6/persisters/persister-partykit-client.js +1 -1
  34. package/lib/umd-es6/persisters/persister-partykit-client.js.gz +0 -0
  35. package/lib/umd-es6/persisters/persister-partykit-server.js +1 -1
  36. package/lib/umd-es6/persisters/persister-partykit-server.js.gz +0 -0
  37. package/package.json +8 -8
  38. package/readme.md +2 -2
@@ -18,7 +18,9 @@
18
18
  * @since 4.3.0
19
19
  */
20
20
 
21
+ import {Cell, NoTablesSchema, NoValuesSchema, Value} from '../store';
21
22
  import {Connection, Party, Request, Server} from 'partykit/server';
23
+ import {Id} from '../common';
22
24
 
23
25
  /**
24
26
  * The TinyBasePartyKitServerConfig type describes the configuration of a
@@ -38,13 +40,13 @@ import {Connection, Party, Request, Server} from 'partykit/server';
38
40
  * 'tinybase_' in case you are worried about colliding with other data stored
39
41
  * in the room.
40
42
  *
41
- * ```js yolo
42
- * export default class extends TinyBasePartyServer {
43
+ * ```js
44
+ * class MyServer extends TinyBasePartyKitServer {
43
45
  * readonly config: TinyBasePartyKitServerConfig = {
44
46
  * storePath: '/my_tinybase',
45
47
  * storagePrefix: 'tinybase_',
46
48
  * };
47
- * };
49
+ * }
48
50
  * ```
49
51
  * @category Configuration
50
52
  * @since v4.3.9
@@ -56,6 +58,14 @@ export type TinyBasePartyKitServerConfig = {
56
58
  * on the client. Both default to '/store'.
57
59
  */
58
60
  storePath?: string;
61
+ /**
62
+ * The prefix at the beginning of the web socket messages between the client
63
+ * and the server when synchronizing the Store. Use this to make sure they do
64
+ * not collide with any other message syntax that your room is using. This
65
+ * must match the messagePrefix property of the PartyKitPersisterConfig object
66
+ * used on the client. Both default to an empty string.
67
+ */
68
+ messagePrefix?: string;
59
69
  /**
60
70
  * The prefix used before all the keys in the server's durable storage. Use
61
71
  * this in case you are worried about the Store data colliding with other data
@@ -98,7 +108,7 @@ export type TinyBasePartyKitServerConfig = {
98
108
  * ```js
99
109
  * // This is your PartyKit server entry point.
100
110
  *
101
- * export default class extends TinyBasePartyServer {
111
+ * class MyServer extends TinyBasePartyKitServer {
102
112
  * constructor(party) {
103
113
  * super(party);
104
114
  * // custom constructor code
@@ -124,6 +134,8 @@ export type TinyBasePartyKitServerConfig = {
124
134
  * See the [PartyKit server API
125
135
  * documentation](https://docs.partykit.io/reference/partyserver-api/) for
126
136
  * more details.
137
+ * @category Creation
138
+ * @since v4.3.0
127
139
  */
128
140
  export class TinyBasePartyKitServer implements Server {
129
141
  constructor(party: Party);
@@ -132,6 +144,8 @@ export class TinyBasePartyKitServer implements Server {
132
144
  * object of the TinyBasePartyKitServerConfig type.
133
145
  *
134
146
  * See the documentation for that type for more details.
147
+ * @category Configuration
148
+ * @since v4.3.9
135
149
  */
136
150
  readonly config: TinyBasePartyKitServerConfig;
137
151
  /**
@@ -143,7 +157,7 @@ export class TinyBasePartyKitServer implements Server {
143
157
  * synchronization stays supported:
144
158
  *
145
159
  * ```js
146
- * export default class extends TinyBasePartyServer {
160
+ * class MyServer extends TinyBasePartyKitServer {
147
161
  * async onRequest(request) {
148
162
  * // custom onRequest code, else:
149
163
  * return await super.onRequest(request);
@@ -154,6 +168,8 @@ export class TinyBasePartyKitServer implements Server {
154
168
  * See the [PartyKit server API
155
169
  * documentation](https://docs.partykit.io/reference/partyserver-api/) for
156
170
  * more details.
171
+ * @category Connection
172
+ * @since v4.3.0
157
173
  */
158
174
  onRequest(request: Request): Promise<Response>;
159
175
  /**
@@ -165,7 +181,7 @@ export class TinyBasePartyKitServer implements Server {
165
181
  * synchronization stays supported:
166
182
  *
167
183
  * ```js
168
- * export default class extends TinyBasePartyServer {
184
+ * class MyServer extends TinyBasePartyKitServer {
169
185
  * async onMessage(message, client) {
170
186
  * await super.onMessage(message, client);
171
187
  * // custom onMessage code
@@ -176,6 +192,342 @@ export class TinyBasePartyKitServer implements Server {
176
192
  * See the [PartyKit server API
177
193
  * documentation](https://docs.partykit.io/reference/partyserver-api/) for
178
194
  * more details.
195
+ * @category Connection
196
+ * @since v4.3.0
197
+ */
198
+ onMessage(message: string, client: Connection): Promise<void>;
199
+ /**
200
+ * The canSetTable method lets you allow or disallow any changes to a Table
201
+ * stored on the server, as sent from a client.
202
+ *
203
+ * This is one of the functions use to sanitize the data that is being sent
204
+ * from a client. Perhaps you might want to make sure the server-stored data
205
+ * adheres to a particular schema, or you might want to make certain data
206
+ * read-only. Remember that you cannot trust the client to only send data that
207
+ * the server considers valid or safe.
208
+ *
209
+ * This method is passed the Table Id that the client is trying to change. The
210
+ * `initialSave` parameter distinguishes between the first bulk save of the
211
+ * Store to the PartyKit room over HTTP (`true`), and subsequent incremental
212
+ * updates over a web sockets (`false`).
213
+ *
214
+ * The final `requestOrConnection` parameter will either be the HTTP(S)
215
+ * request or the web socket connection, in those two cases respectively. You
216
+ * can, for instance, use this to distinguish between different users.
217
+ *
218
+ * Return `false` from this method to disallow changes to this Table on the
219
+ * server, or `true` to allow them (subject to subsequent canSetRow method,
220
+ * canDelRow method, canSetCell method, and canSetCell method checks). The
221
+ * default implementation returns `true` to allow all changes.
222
+ * @example
223
+ * The following implementation will strip out any attempts by the client to
224
+ * update any 'user' tabular data after the initial save:
225
+ *
226
+ * ```js
227
+ * class MyServer extends TinyBasePartyKitServer {
228
+ * canSetTable(tableId, initialSave) {
229
+ * return initialSave || tableId != 'user';
230
+ * }
231
+ * }
232
+ * ```
233
+ * @category Sanitization
234
+ * @since v4.3.12
235
+ */
236
+ canSetTable(
237
+ tableId: Id,
238
+ initialSave: boolean,
239
+ requestOrConnection: Request | Connection,
240
+ ): boolean;
241
+ /**
242
+ * The canDelTable method lets you allow or disallow deletions of a Table
243
+ * stored on the server, as sent from a client.
244
+ *
245
+ * This is one of the functions use to sanitize the data that is being sent
246
+ * from a client. Perhaps you might want to make sure the server-stored data
247
+ * adheres to a particular schema, or you might want to make certain data
248
+ * read-only. Remember that you cannot trust the client to only send data that
249
+ * the server considers valid or safe.
250
+ *
251
+ * This method is passed the Table Id that the client is trying to delete. The
252
+ * `connection` parameter will be the web socket connection of that client.
253
+ * You can, for instance, use this to distinguish between different users.
254
+ *
255
+ * Return `false` from this method to disallow this Table from being deleted
256
+ * on the server, or `true` to allow it. The default implementation returns
257
+ * `true` to allow deletion.
258
+ * @example
259
+ * The following implementation will strip out any attempts by the client to
260
+ * delete the 'user' Table:
261
+ *
262
+ * ```js
263
+ * class MyServer extends TinyBasePartyKitServer {
264
+ * canDelTable(tableId) {
265
+ * return tableId != 'user';
266
+ * }
267
+ * }
268
+ * ```
269
+ * @category Sanitization
270
+ * @since v4.3.12
271
+ */
272
+ canDelTable(tableId: Id, connection: Connection): boolean;
273
+ /**
274
+ * The canSetRow method lets you allow or disallow any changes to a Row stored
275
+ * on the server, as sent from a client.
276
+ *
277
+ * This is one of the functions use to sanitize the data that is being sent
278
+ * from a client. Perhaps you might want to make sure the server-stored data
279
+ * adheres to a particular schema, or you might want to make certain data
280
+ * read-only. Remember that you cannot trust the client to only send data that
281
+ * the server considers valid or safe.
282
+ *
283
+ * This method is passed the Table Id and Row Id that the client is trying to
284
+ * change. The `initialSave` parameter distinguishes between the first bulk
285
+ * save of the Store to the PartyKit room over HTTP (`true`), and subsequent
286
+ * incremental updates over a web sockets (`false`).
287
+ *
288
+ * The final `requestOrConnection` parameter will either be the HTTP(S)
289
+ * request or the web socket connection, in those two cases respectively. You
290
+ * can, for instance, use this to distinguish between different users.
291
+ *
292
+ * Return `false` from this method to disallow changes to this Row on the
293
+ * server, or `true` to allow them (subject to subsequent canSetCell method
294
+ * and canSetCell method checks). The default implementation returns `true` to
295
+ * allow all changes.
296
+ * @example
297
+ * The following implementation will strip out any attempts by the client to
298
+ * update the 'me' Row of the 'user' Table after the initial save:
299
+ *
300
+ * ```js
301
+ * class MyServer extends TinyBasePartyKitServer {
302
+ * canSetRow(tableId, rowId, initialSave) {
303
+ * return initialSave || tableId != 'user' || rowId != 'me';
304
+ * }
305
+ * }
306
+ * ```
307
+ * @category Sanitization
308
+ * @since v4.3.12
309
+ */
310
+ canSetRow(
311
+ tableId: Id,
312
+ rowId: Id,
313
+ initialSave: boolean,
314
+ requestOrConnection: Request | Connection,
315
+ ): boolean;
316
+ /**
317
+ * The canDelRow method lets you allow or disallow deletions of a Row stored
318
+ * on the server, as sent from a client.
319
+ *
320
+ * This is one of the functions use to sanitize the data that is being sent
321
+ * from a client. Perhaps you might want to make sure the server-stored data
322
+ * adheres to a particular schema, or you might want to make certain data
323
+ * read-only. Remember that you cannot trust the client to only send data that
324
+ * the server considers valid or safe.
325
+ *
326
+ * This method is passed the Table Id and Row Id that the client is trying to
327
+ * delete. The `connection` parameter will be the web socket connection of
328
+ * that client. You can, for instance, use this to distinguish between
329
+ * different users.
330
+ *
331
+ * Return `false` from this method to disallow this Row from being deleted
332
+ * on the server, or `true` to allow it. The default implementation returns
333
+ * `true` to allow deletion.
334
+ * @example
335
+ * The following implementation will strip out any attempts by the client to
336
+ * delete the 'me' Row of the 'user' Table:
337
+ *
338
+ * ```js
339
+ * class MyServer extends TinyBasePartyKitServer {
340
+ * canDelRow(tableId, rowId) {
341
+ * return tableId != 'user' || rowId != 'me';
342
+ * }
343
+ * }
344
+ * ```
345
+ * @category Sanitization
346
+ * @since v4.3.12
347
+ */
348
+ canDelRow(tableId: Id, rowId: Id, connection: Connection): boolean;
349
+ /**
350
+ * The canSetCell method lets you allow or disallow any changes to a Cell
351
+ * stored on the server, as sent from a client.
352
+ *
353
+ * This has schema-based typing. The following is a simplified representation:
354
+ *
355
+ * ```ts override
356
+ * canSetCell(
357
+ * tableId: Id,
358
+ * rowId: Id,
359
+ * cellId: Id,
360
+ * cell: Cell,
361
+ * initialSave: boolean,
362
+ * requestOrConnection: Request | Connection,
363
+ * ): boolean;
364
+ * ```
365
+ *
366
+ * This is one of the functions use to sanitize the data that is being sent
367
+ * from a client. Perhaps you might want to make sure the server-stored data
368
+ * adheres to a particular schema, or you might want to make certain data
369
+ * read-only. Remember that you cannot trust the client to only send data that
370
+ * the server considers valid or safe.
371
+ *
372
+ * This method is passed the Table Id, Row Id, and Cell Id that the client is
373
+ * trying to change - as well as the Cell value itself. The `initialSave`
374
+ * parameter distinguishes between the first bulk save of the Store to the
375
+ * PartyKit room over HTTP (`true`), and subsequent incremental updates over a
376
+ * web sockets (`false`).
377
+ *
378
+ * The final `requestOrConnection` parameter will either be the HTTP(S)
379
+ * request or the web socket connection, in those two cases respectively. You
380
+ * can, for instance, use this to distinguish between different users.
381
+ *
382
+ * Return `false` from this method to disallow changes to this Cell on the
383
+ * server, or `true` to allow them. The default implementation returns `true`
384
+ * to allow all changes.
385
+ * @example
386
+ * The following implementation will strip out any attempts by the client to
387
+ * update the 'name' Cell of the 'me' Row of the 'user' Table after the
388
+ * initial save:
389
+ *
390
+ * ```js
391
+ * class MyServer extends TinyBasePartyKitServer {
392
+ * canSetCell(tableId, rowId, cellId, cell, initialSave) {
393
+ * return (
394
+ * initialSave || tableId != 'user' || rowId != 'me' || cellId != 'name'
395
+ * );
396
+ * }
397
+ * }
398
+ * ```
399
+ * @category Sanitization
400
+ * @since v4.3.12
401
+ */
402
+ canSetCell(
403
+ tableId: Id,
404
+ rowId: Id,
405
+ cellId: Id,
406
+ cell: Cell<NoTablesSchema, Id, Id>,
407
+ initialSave: boolean,
408
+ requestOrConnection: Request | Connection,
409
+ ): boolean;
410
+ /**
411
+ * The canDelCell method lets you allow or disallow deletions of a Cell stored
412
+ * on the server, as sent from a client.
413
+ *
414
+ * This is one of the functions use to sanitize the data that is being sent
415
+ * from a client. Perhaps you might want to make sure the server-stored data
416
+ * adheres to a particular schema, or you might want to make certain data
417
+ * read-only. Remember that you cannot trust the client to only send data that
418
+ * the server considers valid or safe.
419
+ *
420
+ * This method is passed the Table Id, Row Id, and Cell Id that the client is
421
+ * trying to delete. The `connection` parameter will be the web socket
422
+ * connection of that client. You can, for instance, use this to distinguish
423
+ * between different users.
424
+ *
425
+ * Return `false` from this method to disallow this Cell from being deleted on
426
+ * the server, or `true` to allow it. The default implementation returns
427
+ * `true` to allow deletion.
428
+ * @example
429
+ * The following implementation will strip out any attempts by the client to
430
+ * delete the 'name' Cell of the 'me' Row of the 'user' Table:
431
+ *
432
+ * ```js
433
+ * class MyServer extends TinyBasePartyKitServer {
434
+ * canDelCell(tableId, rowId, cellId) {
435
+ * return tableId != 'user' || rowId != 'me' || cellId != 'name';
436
+ * }
437
+ * }
438
+ * ```
439
+ * @category Sanitization
440
+ * @since v4.3.12
441
+ */
442
+ canDelCell(
443
+ tableId: Id,
444
+ rowId: Id,
445
+ cellId: Id,
446
+ connection: Connection,
447
+ ): boolean;
448
+ /**
449
+ * The canSetValue method lets you allow or disallow any changes to a Value
450
+ * stored on the server, as sent from a client.
451
+ *
452
+ * This has schema-based typing. The following is a simplified representation:
453
+ *
454
+ * ```ts override
455
+ * canSetValue(
456
+ * valueId: Id,
457
+ * value: Value,
458
+ * initialSave: boolean,
459
+ * requestOrConnection: Request | Connection,
460
+ * ): boolean;
461
+ * ```
462
+ *
463
+ * This is one of the functions use to sanitize the data that is being sent
464
+ * from a client. Perhaps you might want to make sure the server-stored data
465
+ * adheres to a particular schema, or you might want to make certain data
466
+ * read-only. Remember that you cannot trust the client to only send data that
467
+ * the server considers valid or safe.
468
+ *
469
+ * This method is passed the Value Id that the client is trying to change - as
470
+ * well as the Value itself. The `initialSave` parameter distinguishes between
471
+ * the first bulk save of the Store to the PartyKit room over HTTP (`true`),
472
+ * and subsequent incremental updates over a web sockets (`false`).
473
+ *
474
+ * The final `requestOrConnection` parameter will either be the HTTP(S)
475
+ * request or the web socket connection, in those two cases respectively. You
476
+ * can, for instance, use this to distinguish between different users.
477
+ *
478
+ * Return `false` from this method to disallow changes to this Value on the
479
+ * server, or `true` to allow them. The default implementation returns `true`
480
+ * to allow all changes.
481
+ * @example
482
+ * The following implementation will strip out any attempts by the client to
483
+ * update the 'userId' Value after the initial save:
484
+ *
485
+ * ```js
486
+ * class MyServer extends TinyBasePartyKitServer {
487
+ * canSetValue(valueId, value, initialSave) {
488
+ * return initialSave || userId != 'userId';
489
+ * }
490
+ * }
491
+ * ```
492
+ * @category Sanitization
493
+ * @since v4.3.12
494
+ */
495
+ canSetValue(
496
+ valueId: Id,
497
+ value: Value<NoValuesSchema, Id>,
498
+ initialSave: boolean,
499
+ requestOrConnection: Request | Connection,
500
+ ): boolean;
501
+ /**
502
+ * The canDelValue method lets you allow or disallow deletions of a Value
503
+ * stored on the server, as sent from a client.
504
+ *
505
+ * This is one of the functions use to sanitize the data that is being sent
506
+ * from a client. Perhaps you might want to make sure the server-stored data
507
+ * adheres to a particular schema, or you might want to make certain data
508
+ * read-only. Remember that you cannot trust the client to only send data that
509
+ * the server considers valid or safe.
510
+ *
511
+ * This method is passed the Value Id that the client is trying to delete. The
512
+ * `connection` parameter will be the web socket connection of that client.
513
+ * You can, for instance, use this to distinguish between different users.
514
+ *
515
+ * Return `false` from this method to disallow this Value from being deleted
516
+ * on the server, or `true` to allow it. The default implementation returns
517
+ * `true` to allow deletion.
518
+ * @example
519
+ * The following implementation will strip out any attempts by the client to
520
+ * delete the 'userId' Value:
521
+ *
522
+ * ```js
523
+ * class MyServer extends TinyBasePartyKitServer {
524
+ * canDelValue(valueId) {
525
+ * return valueId != 'userId';
526
+ * }
527
+ * }
528
+ * ```
529
+ * @category Sanitization
530
+ * @since v4.3.12
179
531
  */
180
- onMessage(message: string, client: Connection): void;
532
+ canDelValue(valueId: Id, connection: Connection): boolean;
181
533
  }
@@ -412,9 +412,8 @@ export interface Tools<in out Schemas extends OptionalSchemas> {
412
412
  * },
413
413
  * });
414
414
  * const tools = createTools(store);
415
- * const [dTs, ts, uiReactDTs, uiReactTsx] = await createTools(
416
- * store,
417
- * ).getPrettyStoreApi('shop');
415
+ * const [dTs, ts, uiReactDTs, uiReactTsx] =
416
+ * await createTools(store).getPrettyStoreApi('shop');
418
417
  *
419
418
  * const dTsLines = dTs.split('\n');
420
419
  * console.log(dTsLines[17]);
@@ -433,9 +432,8 @@ export interface Tools<in out Schemas extends OptionalSchemas> {
433
432
  * felix: {price: 4},
434
433
  * });
435
434
  * const tools = createTools(store);
436
- * const [dTs, ts, uiReactDTs, uiReactTsx] = await createTools(
437
- * store,
438
- * ).getPrettyStoreApi('shop');
435
+ * const [dTs, ts, uiReactDTs, uiReactTsx] =
436
+ * await createTools(store).getPrettyStoreApi('shop');
439
437
  *
440
438
  * const dTsLines = dTs.split('\n');
441
439
  * console.log(dTsLines[17]);
@@ -4393,8 +4393,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
4393
4393
  * </Provider>
4394
4394
  * );
4395
4395
  * const Pane = () => {
4396
- * useWillFinishTransactionListener(
4397
- * () => console.log('Will finish transaction'),
4396
+ * useWillFinishTransactionListener(() =>
4397
+ * console.log('Will finish transaction'),
4398
4398
  * );
4399
4399
  * return <span>App</span>;
4400
4400
  * };
@@ -4462,8 +4462,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
4462
4462
  * </Provider>
4463
4463
  * );
4464
4464
  * const Pane = () => {
4465
- * useDidFinishTransactionListener(
4466
- * () => console.log('Did finish transaction'),
4465
+ * useDidFinishTransactionListener(() =>
4466
+ * console.log('Did finish transaction'),
4467
4467
  * );
4468
4468
  * return <span>App</span>;
4469
4469
  * };
@@ -1 +1 @@
1
- var t,e;t=this,e=function(t){"use strict";const e=t=>typeof t,a=e(""),s=(t,e)=>t instanceof e,o=t=>null==t,n=t=>e(t)==a,r=Object,i=r.keys,c=r.freeze,d=t=>(t=>s(t,r)&&t.constructor==r)(t)&&0==(t=>i(t).length)(t),y=t=>JSON.stringify(t,((t,e)=>s(e,Map)?r.fromEntries([...e]):e)),u=JSON.parse,h=t=>new Map(t),l=(t,e)=>t?.get(e),f=(t,e,a)=>{return o(a)?(s=t,n=e,s?.delete(n),t):t?.set(e,a);var s,n},p=(t,e,a)=>{var s,o;return s=t,o=e,s?.has(o)||f(t,e,a()),l(t,e)},v=h(),w=h(),g="message",m={storeProtocol:"https",storePath:"/store"};t.createPartyKitPersister=(t,e,a,s)=>{const{host:r,room:i}=e.partySocketOptions,{storeProtocol:h,storePath:P}={...m,...n(a)?{storeProtocol:a}:a},S=h+"://"+r+"/parties/"+(e.name??"main")+"/"+i+P,A=async t=>await(await fetch(S,{...t?{method:"PUT",body:y(t)}:{},mode:"cors",cache:"no-store"})).json();return((t,e,a,s,n,r,i=[])=>{let y,u,h,g=0,m=0;p(v,i,(()=>0)),p(w,i,(()=>[]));const P=async t=>(2!=g&&(g=1,await S.schedule((async()=>{await t(),g=0}))),S),S={load:async(a,s)=>await P((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},o={})=>(S.stopAutoLoad(),await S.load(a,o),m=1,h=s((async(a,s)=>{if(s){const e=s();await P((async()=>t.setTransactionChanges(e)))}else await P((async()=>{try{t.setContent(a?.()??await e())}catch(t){r?.(t)}}))})),S),stopAutoLoad:()=>(m&&(n(h),h=void 0,m=0),S),save:async e=>(1!=g&&(g=2,await S.schedule((async()=>{try{await a(t.getContent,e)}catch(t){r?.(t)}g=0}))),S),startAutoSave:async()=>(await S.stopAutoSave().save(),y=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();d(a)&&d(s)||S.save((()=>[a,s]))})),S),stopAutoSave:()=>{var e,a;return e=y,a=t.delListener,o(e)||a(e),S},schedule:async(...t)=>(((t,...e)=>{t.push(...e)})(l(w,i),...t),await(async()=>{if(!l(v,i)){for(f(v,i,1);!o((t=l(w,i),u=t.shift()));)try{await u()}catch(t){r?.(t)}f(v,i,0)}var t})(),S),getStore:()=>t,destroy:()=>S.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c(S)})(t,(async()=>await A()),(async(t,a)=>{var s;a?e.send((s=a(),"s"+(n(s)?s:y(s)))):await A(t())}),(t=>{const a=e=>{const[a,s]=[(i=e.data)[0],u((o=i,n=1,o.slice(n,r)))];var o,n,r,i;"s"==a&&t(void 0,(()=>s))};return e.addEventListener(g,a),a}),(t=>{e.removeEventListener(g,t)}),s)}},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterPartyKitClient={});
1
+ var t,e;t=this,e=function(t){"use strict";const e=t=>typeof t,a="",s=e(a),o=(t,e)=>t instanceof e,n=t=>null==t,r=(t,e,a)=>n(t)?a?.():e(t),i=t=>e(t)==s,c=t=>t.length,d=Object,y=d.keys,u=d.freeze,f=t=>(t=>o(t,d)&&t.constructor==d)(t)&&0==(t=>c(y(t)))(t),h=t=>JSON.stringify(t,((t,e)=>o(e,Map)?d.fromEntries([...e]):e)),l=JSON.parse,p="/store",v=t=>new Map(t),w=(t,e)=>t?.get(e),g=(t,e,a)=>{return n(a)?(s=t,o=e,s?.delete(o),t):t?.set(e,a);var s,o},m=(t,e,a)=>{var s,o;return s=t,o=e,s?.has(o)||g(t,e,a()),w(t,e)},P=v(),S=v(),A="message";t.createPartyKitPersister=(t,e,s,o)=>{const{host:d,room:y}=e.partySocketOptions,{storeProtocol:v="https",storePath:L=p,messagePrefix:C=a}={...i(s)?{storeProtocol:s}:s},T=v+"://"+d+"/parties/"+(e.name??"main")+"/"+y+L,b=async t=>await(await fetch(T,{...t?{method:"PUT",body:h(t)}:{},mode:"cors",cache:"no-store"})).json();return((t,e,a,s,o,i,c=[])=>{let d,y,h,l=0,p=0;m(P,c,(()=>0)),m(S,c,(()=>[]));const v=async t=>(2!=l&&(l=1,await A.schedule((async()=>{await t(),l=0}))),A),A={load:async(a,s)=>await v((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},o={})=>(A.stopAutoLoad(),await A.load(a,o),p=1,h=s((async(a,s)=>{if(s){const e=s();await v((async()=>t.setTransactionChanges(e)))}else await v((async()=>{try{t.setContent(a?.()??await e())}catch(t){i?.(t)}}))})),A),stopAutoLoad:()=>(p&&(o(h),h=void 0,p=0),A),save:async e=>(1!=l&&(l=2,await A.schedule((async()=>{try{await a(t.getContent,e)}catch(t){i?.(t)}l=0}))),A),startAutoSave:async()=>(await A.stopAutoSave().save(),d=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();f(a)&&f(s)||A.save((()=>[a,s]))})),A),stopAutoSave:()=>(r(d,t.delListener),A),schedule:async(...t)=>(((t,...e)=>{t.push(...e)})(w(S,c),...t),await(async()=>{if(!w(P,c)){for(g(P,c,1);!n((t=w(S,c),y=t.shift()));)try{await y()}catch(t){i?.(t)}g(P,c,0)}var t})(),A),getStore:()=>t,destroy:()=>A.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return u(A)})(t,(async()=>await b()),(async(t,a)=>{var s,o;a?e.send((s=C,o=a(),s+"s"+(i(o)?o:h(o)))):await b(t())}),(t=>{const a=e=>r(((t,e,a)=>{const s=c(t);return((t,e)=>t.startsWith(e))(e,t)?[e[s],l((o=e,n=s+1,o.slice(n,void 0)))]:void 0;var o,n})(C,e.data),(([e,a])=>{"s"==e&&t(void 0,(()=>a))}));return e.addEventListener(A,a),a}),(t=>{e.removeEventListener(A,t)}),o)}},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterPartyKitClient={});
@@ -1 +1 @@
1
- var t,e;t=this,e=function(t){"use strict";const e=t=>typeof t,s=e(""),a="t",i=Promise,n=t=>null==t,r=(t,e,s)=>t.slice(e,s),o=t=>t.length,c=(t,e)=>t.map(e),h=(t,...e)=>t.push(...e),f=Object,p=(t=[])=>f.fromEntries(t),l=(t,e)=>c(f.entries(t),(([t,s])=>e(s,t))),y=(t,e,s)=>(((t,e)=>!n(((t,e)=>{return a=t=>t[e],n(s=t)?void 0:a(s);var s,a})(t,e)))(t,e)||(t[e]=s()),t[e]),u=t=>JSON.stringify(t,((t,e)=>e instanceof Map?f.fromEntries([...e]):e)),d=JSON.parse,g=(t,e)=>[t[0],e?d(r(t,1)):r(t,1)],w=(t,e)=>((t,e)=>t?.forEach(e))(t,((t,s)=>e(s,t))),m="hasStore",v=p(c(["Origin","Methods","Headers"],(t=>["Access-Control-Allow-"+t,"*"]))),P=async(t,e)=>await t.get(e+m),R=async(t,e,s)=>{const r=[t.put(e+m,1)],c=[];l(s[0],((s,i)=>n(s)?((t,...e)=>t.unshift(...e))(c,e+x(a,i)):l(s,((s,o)=>n(s)?h(c,e+x(a,i,o)):l(s,((s,n)=>b(r,t,e+x(a,i,o,n),s))))))),l(s[1],((s,a)=>b(r,t,e+"v"+a,s))),0!=o(c)&&w(await t.list(),(e=>c.every((s=>!e.startsWith(s)||b(r,t,e)&&!1)))),await(async t=>i.all(t))(r)},x=(t,...e)=>t+r(u(e),1,-1),b=(t,e,s,a)=>h(t,n(a)?e.delete(s):e.put(s,a));t.TinyBasePartyKitServer=class{constructor(t){this.party=t,this.config={},this.createResponse=(t,e=null)=>new Response(e,{status:t,headers:this.config.responseHeaders??v})}async onRequest(t){const e=this.party.storage,s=this.config.storagePrefix??"",i=this.config.storePath??"/store";if(new URL(t.url).pathname.endsWith(i)){const i=await P(e,s),n=await t.text();return"PUT"==t.method?i?this.createResponse(205):(await R(e,s,d(n)),this.createResponse(201)):this.createResponse(200,i?u(await(async(t,e)=>{const s={},i={};return w(await t.list(),((t,n)=>{if(t.startsWith(e)){t=r(t,o(e));const[c,h]=g(t);if(c==a){const[t,e,a]=d("["+h+"]");y(y(s,t,p),e,p)[a]=n}else"v"==c&&(i[h]=n)}})),[s,i]})(e,s)):"")}return this.createResponse(404)}async onMessage(t,a){const i=this.party.storage,n=this.config.storagePrefix??"",[r,o]=g(t,1);"s"==r&&await P(i,n)&&(await R(i,n,o),this.party.broadcast(((t,a)=>"s"+(e(a)==s?a:u(a)))(0,o),[a.id]))}}},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterPartyKitServer={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,a="",s=t(a),n="t",r=(e,t)=>e.startsWith(t),i=Promise,o=e=>null==e,c=(e,t,a)=>o(e)?a?.():t(e),l=(e,t,a)=>e.slice(t,a),u=e=>e.length,f=(e,t)=>e.map(t),h=(e,...t)=>e.push(...t),y=Object,p=(e=[])=>y.fromEntries(e),g=(e,t)=>f(y.entries(e),(([e,a])=>t(a,e))),d=(e,t,a)=>(((e,t)=>!o(((e,t)=>c(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=a()),e[t]),w=e=>JSON.stringify(e,((e,t)=>t instanceof Map?y.fromEntries([...t]):t)),S=JSON.parse,P=(e,a,n)=>e+a+(t(n)==s?n:w(n)),b=(e,t,a)=>{const s=u(e);return r(t,e)?[t[s],(a?S:String)(l(t,s+1))]:void 0},m=(e,t)=>((e,t)=>e?.forEach(t))(e,((e,a)=>t(a,e))),T="hasStore",v=p(f(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),x=async e=>await e.party.storage.get((e.config.storagePrefix??a)+T),D=async(e,t,s,c)=>{const l=e.party.storage,f=e.config.storagePrefix??a,y=[l.put(f+T,1)],p=[];g(t[0],((t,a)=>o(t)?!s&&e.canDelTable(a,c)&&((e,...t)=>e.unshift(...t))(p,R(f,n,a)):e.canSetTable(a,s,c)&&g(t,((t,r)=>o(t)?!s&&e.canDelRow(a,r,c)&&h(p,R(f,n,a,r)):e.canSetRow(a,r,s,c)&&g(t,((t,i)=>o(t)?!s&&e.canDelCell(a,r,i,c)&&h(y,l.delete(R(f,n,a,r,i))):e.canSetCell(a,r,i,t,s,c)&&h(y,l.put(R(f,n,a,r,i),t)))))))),g(t[1],((t,a)=>o(t)?!s&&e.canDelValue(a,c)&&h(y,l.delete(f+"v"+a)):e.canSetValue(a,t,s,c)&&h(y,l.put(f+"v"+a,t)))),0!=u(p)&&m(await l.list(),(e=>p.every((t=>!r(e,t)||h(y,l.delete(e))&&0)))),await(async e=>i.all(e))(y)},R=(e,t,...a)=>P(e,t,l(w(a),1,-1)),C=async(e,t,a=null)=>new Response(a,{status:t,headers:e.config.responseHeaders??v});e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={}}async onRequest(e){const t=this.config.storePath??"/store";if(new URL(e.url).pathname.endsWith(t)){const t=await x(this),s=await e.text();return"PUT"==e.method?t?C(this,205):(await D(this,S(s),!0,e),C(this,201)):C(this,200,t?w(await(async e=>{const t={},s={},r=e.config.storagePrefix??a;return m(await e.party.storage.list(),((e,a)=>c(b(r,e),(([e,r])=>{if(e==n){const[e,s,n]=S("["+r+"]");d(d(t,e,p),s,p)[n]=a}else"v"==e&&(s[r]=a)})))),[t,s]})(this)):a)}return C(this,404)}async onMessage(e,t){const s=this.config.messagePrefix??a;await c(b(s,e,1),(async([e,a])=>{"s"==e&&await x(this)&&(await D(this,a,!1,t),this.party.broadcast(P(s,"s",a)))}))}canSetTable(e,t,a){return!0}canDelTable(e,t){return!0}canSetRow(e,t,a,s){return!0}canDelRow(e,t,a){return!0}canSetCell(e,t,a,s,n,r){return!0}canDelCell(e,t,a,s){return!0}canSetValue(e,t,a,s){return!0}canDelValue(e,t){return!0}}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n=t(""),o=(e,t)=>e instanceof t,r=e=>null==e,l=e=>t(e)==n,i=Object,s=i.keys,u=i.freeze,a=e=>(e=>o(e,i)&&e.constructor==i)(e)&&0==(e=>s(e).length)(e),c=e=>JSON.stringify(e,((e,t)=>o(t,Map)?i.fromEntries([...t]):t)),d=JSON.parse,v=e=>new Map(e),y=(e,t)=>null==e?void 0:e.get(t),f=(e,t,n)=>{return r(n)?(l=t,null==(o=e)||o.delete(l),e):null==e?void 0:e.set(t,n);var o,l},p=(e,t,n)=>{var o,r,l;return r=t,null!=(l=null==(o=e)?void 0:o.has(r))&&l||f(e,t,n()),y(e,t)};var h=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{s(n.next(e))}catch(e){r(e)}},i=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);s((n=n.apply(e,t)).next())}));const P=v(),m=v();var b=Object.defineProperty,g=Object.defineProperties,O=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,A=(e,t,n)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,L=(e,t)=>{for(var n in t||(t={}))j.call(t,n)&&A(e,n,t[n]);if(S)for(var n of S(t))w.call(t,n)&&A(e,n,t[n]);return e},x=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{s(n.next(e))}catch(e){r(e)}},i=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);s((n=n.apply(e,t)).next())}));const C="message",T={storeProtocol:"https",storePath:"/store"};e.createPartyKitPersister=(e,t,n,o)=>{var i;const{host:s,room:v}=t.partySocketOptions,{storeProtocol:b,storePath:S}=L(L({},T),l(n)?{storeProtocol:n}:n),j=b+"://"+s+"/parties/"+(null!=(i=t.name)?i:"main")+"/"+v+S,w=e=>x(void 0,null,(function*(){return yield(yield fetch(j,(t=L({},e?{method:"PUT",body:c(e)}:{}),n={mode:"cors",cache:"no-store"},g(t,O(n))))).json();var t,n}));return((e,t,n,o,l,i,s=[])=>{let c,d,v,b=0,g=0;p(P,s,(()=>0)),p(m,s,(()=>[]));const O=e=>h(void 0,null,(function*(){return 2!=b&&(b=1,yield S.schedule((()=>h(void 0,null,(function*(){yield e(),b=0}))))),S})),S={load:(n,o)=>h(void 0,null,(function*(){return yield O((()=>h(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>h(void 0,[...n],(function*(n={},r={}){return S.stopAutoLoad(),yield S.load(n,r),g=1,v=o(((n,o)=>h(void 0,null,(function*(){if(o){const t=o();yield O((()=>h(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield O((()=>h(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==i||i(e)}}))))})))),S})),stopAutoLoad:()=>(g&&(l(v),v=void 0,g=0),S),save:t=>h(void 0,null,(function*(){return 1!=b&&(b=2,yield S.schedule((()=>h(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==i||i(e)}b=0}))))),S})),startAutoSave:()=>h(void 0,null,(function*(){return yield S.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();a(n)&&a(o)||S.save((()=>[n,o]))})),S})),stopAutoSave:()=>{var t,n;return t=c,n=e.delListener,!!r(t)||n(t),S},schedule:(...e)=>h(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(y(m,s),...e),yield h(void 0,null,(function*(){if(!y(P,s)){for(f(P,s,1);!r((e=y(m,s),d=e.shift()));)try{yield d()}catch(e){null==i||i(e)}f(P,s,0)}var e})),S})),getStore:()=>e,destroy:()=>S.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return u(S)})(e,(()=>x(void 0,null,(function*(){return yield w()}))),((e,n)=>x(void 0,null,(function*(){var o;n?t.send((o=n(),"s"+(l(o)?o:c(o)))):yield w(e())}))),(e=>{const n=t=>{const[n,o]=[(s=t.data)[0],d((r=s,l=1,r.slice(l,i)))];var r,l,i,s;"s"==n&&e(void 0,(()=>o))};return t.addEventListener(C,n),n}),(e=>{t.removeEventListener(C,e)}),o)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitClient={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",o=t(n),r=(e,t)=>e instanceof t,l=e=>null==e,i=(e,t,n)=>l(e)?null==n?void 0:n():t(e),s=e=>t(e)==o,u=e=>e.length,a=Object,d=a.keys,c=a.freeze,v=e=>(e=>r(e,a)&&e.constructor==a)(e)&&0==(e=>u(d(e)))(e),y=e=>JSON.stringify(e,((e,t)=>r(t,Map)?a.fromEntries([...t]):t)),f=JSON.parse,p="/store",h=e=>new Map(e),m=(e,t)=>null==e?void 0:e.get(t),P=(e,t,n)=>{return l(n)?(r=t,null==(o=e)||o.delete(r),e):null==e?void 0:e.set(t,n);var o,r},b=(e,t,n)=>{var o,r,l;return r=t,null!=(l=null==(o=e)?void 0:o.has(r))&&l||P(e,t,n()),m(e,t)};var g=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{s(n.next(e))}catch(e){r(e)}},i=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);s((n=n.apply(e,t)).next())}));const O=h(),S=h();var j=Object.defineProperty,w=Object.defineProperties,x=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,T=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))L.call(t,n)&&T(e,n,t[n]);if(A)for(var n of A(t))C.call(t,n)&&T(e,n,t[n]);return e},k=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{s(n.next(e))}catch(e){r(e)}},i=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);s((n=n.apply(e,t)).next())}));const D="message";e.createPartyKitPersister=(e,t,o,r)=>{var a;const{host:d,room:h}=t.partySocketOptions,{storeProtocol:j="https",storePath:A=p,messagePrefix:L=n}=E({},s(o)?{storeProtocol:o}:o),C=j+"://"+d+"/parties/"+(null!=(a=t.name)?a:"main")+"/"+h+A,T=e=>k(void 0,null,(function*(){return yield(yield fetch(C,(t=E({},e?{method:"PUT",body:y(e)}:{}),n={mode:"cors",cache:"no-store"},w(t,x(n))))).json();var t,n}));return((e,t,n,o,r,s,u=[])=>{let a,d,y,f=0,p=0;b(O,u,(()=>0)),b(S,u,(()=>[]));const h=e=>g(void 0,null,(function*(){return 2!=f&&(f=1,yield j.schedule((()=>g(void 0,null,(function*(){yield e(),f=0}))))),j})),j={load:(n,o)=>g(void 0,null,(function*(){return yield h((()=>g(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>g(void 0,[...n],(function*(n={},r={}){return j.stopAutoLoad(),yield j.load(n,r),p=1,y=o(((n,o)=>g(void 0,null,(function*(){if(o){const t=o();yield h((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield h((()=>g(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==s||s(e)}}))))})))),j})),stopAutoLoad:()=>(p&&(r(y),y=void 0,p=0),j),save:t=>g(void 0,null,(function*(){return 1!=f&&(f=2,yield j.schedule((()=>g(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==s||s(e)}f=0}))))),j})),startAutoSave:()=>g(void 0,null,(function*(){return yield j.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||j.save((()=>[n,o]))})),j})),stopAutoSave:()=>(i(a,e.delListener),j),schedule:(...e)=>g(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(m(S,u),...e),yield g(void 0,null,(function*(){if(!m(O,u)){for(P(O,u,1);!l((e=m(S,u),d=e.shift()));)try{yield d()}catch(e){null==s||s(e)}P(O,u,0)}var e})),j})),getStore:()=>e,destroy:()=>j.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c(j)})(e,(()=>k(void 0,null,(function*(){return yield T()}))),((e,n)=>k(void 0,null,(function*(){var o,r;n?t.send((o=L,r=n(),o+"s"+(s(r)?r:y(r)))):yield T(e())}))),(e=>{const n=t=>i(((e,t,n)=>{const o=u(e);return((e,t)=>e.startsWith(t))(t,e)?[t[o],f((r=t,l=o+1,r.slice(l,void 0)))]:void 0;var r,l})(L,t.data),(([t,n])=>{"s"==t&&e(void 0,(()=>n))}));return t.addEventListener(D,n),n}),(e=>{t.removeEventListener(D,e)}),r)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitClient={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s=t(""),n="t",r=Promise,i=e=>null==e,o=(e,t,s)=>e.slice(t,s),l=e=>e.length,a=(e,t)=>e.map(t),c=(e,...t)=>e.push(...t),u=Object,h=(e=[])=>u.fromEntries(e),d=(e,t)=>a(u.entries(e),(([e,s])=>t(s,e))),f=(e,t,s)=>(((e,t)=>!i(((e,t)=>{return n=e=>e[t],i(s=e)?void 0:n(s);var s,n})(e,t)))(e,t)||(e[t]=s()),e[t]),y=e=>JSON.stringify(e,((e,t)=>t instanceof Map?u.fromEntries([...t]):t)),p=JSON.parse,v=(e,t)=>[e[0],t?p(o(e,1)):o(e,1)],g=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,s)=>t(s,e)));var m=(e,t,s)=>new Promise(((n,r)=>{var i=e=>{try{l(s.next(e))}catch(e){r(e)}},o=e=>{try{l(s.throw(e))}catch(e){r(e)}},l=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,o);l((s=s.apply(e,t)).next())}));const P="hasStore",x=h(a(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),R=(e,t)=>m(void 0,null,(function*(){return yield e.get(t+P)})),w=(e,t,s)=>m(void 0,null,(function*(){const o=[e.put(t+P,1)],a=[];d(s[0],((s,r)=>i(s)?((e,...t)=>e.unshift(...t))(a,t+b(n,r)):d(s,((s,l)=>i(s)?c(a,t+b(n,r,l)):d(s,((s,i)=>S(o,e,t+b(n,r,l,i),s))))))),d(s[1],((s,n)=>S(o,e,t+"v"+n,s))),0!=l(a)&&g(yield e.list(),(t=>a.every((s=>!t.startsWith(s)||S(o,e,t)&&!1)))),yield(e=>{return t=function*(){return r.all(e)},new Promise(((e,s)=>{var n=e=>{try{i(t.next(e))}catch(e){s(e)}},r=e=>{try{i(t.throw(e))}catch(e){s(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,r);i((t=t.apply(void 0,null)).next())}));var t})(o)})),b=(e,...t)=>e+o(y(t),1,-1),S=(e,t,s,n)=>c(e,i(n)?t.delete(s):t.put(s,n));e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={},this.createResponse=(e,t=null)=>{var s;return new Response(t,{status:e,headers:null!=(s=this.config.responseHeaders)?s:x})}}onRequest(e){return m(this,null,(function*(){var t,s;const r=this.party.storage,i=null!=(t=this.config.storagePrefix)?t:"",a=null!=(s=this.config.storePath)?s:"/store";if(new URL(e.url).pathname.endsWith(a)){const t=yield R(r,i),s=yield e.text();return"PUT"==e.method?t?this.createResponse(205):(yield w(r,i,p(s)),this.createResponse(201)):this.createResponse(200,t?y(yield((e,t)=>m(void 0,null,(function*(){const s={},r={};return g(yield e.list(),((e,i)=>{if(e.startsWith(t)){e=o(e,l(t));const[a,c]=v(e);if(a==n){const[e,t,n]=p("["+c+"]");f(f(s,e,h),t,h)[n]=i}else"v"==a&&(r[c]=i)}})),[s,r]})))(r,i)):"")}return this.createResponse(404)}))}onMessage(e,n){return m(this,null,(function*(){var r;const i=this.party.storage,o=null!=(r=this.config.storagePrefix)?r:"",[l,a]=v(e,1);"s"==l&&(yield R(i,o))&&(yield w(i,o,a),this.party.broadcast(((e,n)=>"s"+(t(n)==s?n:y(n)))(0,a),[n.id]))}))}}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",r=t(n),l="t",i=(e,t)=>e.startsWith(t),s=Promise,o=e=>null==e,a=(e,t,n)=>o(e)?null==n?void 0:n():t(e),u=(e,t,n)=>e.slice(t,n),c=e=>e.length,d=(e,t)=>e.map(t),f=(e,...t)=>e.push(...t),h=Object,y=(e=[])=>h.fromEntries(e),v=(e,t)=>d(h.entries(e),(([e,n])=>t(n,e))),p=(e,t,n)=>(((e,t)=>!o(((e,t)=>a(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),g=e=>JSON.stringify(e,((e,t)=>t instanceof Map?h.fromEntries([...t]):t)),P=JSON.parse,S=(e,n,l)=>e+n+(t(l)==r?l:g(l)),m=(e,t,n)=>{const r=c(e);return i(t,e)?[t[r],(n?P:String)(u(t,r+1))]:void 0},x=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var w=(e,t,n)=>new Promise(((r,l)=>{var i=e=>{try{o(n.next(e))}catch(e){l(e)}},s=e=>{try{o(n.throw(e))}catch(e){l(e)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,s);o((n=n.apply(e,t)).next())}));const b="hasStore",T=y(d(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),D=e=>w(void 0,null,(function*(){var t;return yield e.party.storage.get((null!=(t=e.config.storagePrefix)?t:n)+b)})),R=(e,t,r,a)=>w(void 0,null,(function*(){var u;const d=e.party.storage,h=null!=(u=e.config.storagePrefix)?u:n,y=[d.put(h+b,1)],p=[];v(t[0],((t,n)=>o(t)?!r&&e.canDelTable(n,a)&&((e,...t)=>e.unshift(...t))(p,C(h,l,n)):e.canSetTable(n,r,a)&&v(t,((t,i)=>o(t)?!r&&e.canDelRow(n,i,a)&&f(p,C(h,l,n,i)):e.canSetRow(n,i,r,a)&&v(t,((t,s)=>o(t)?!r&&e.canDelCell(n,i,s,a)&&f(y,d.delete(C(h,l,n,i,s))):e.canSetCell(n,i,s,t,r,a)&&f(y,d.put(C(h,l,n,i,s),t)))))))),v(t[1],((t,n)=>o(t)?!r&&e.canDelValue(n,a)&&f(y,d.delete(h+"v"+n)):e.canSetValue(n,t,r,a)&&f(y,d.put(h+"v"+n,t)))),0!=c(p)&&x(yield d.list(),(e=>p.every((t=>!i(e,t)||f(y,d.delete(e))&&0)))),yield(e=>{return t=function*(){return s.all(e)},new Promise(((e,n)=>{var r=e=>{try{i(t.next(e))}catch(e){n(e)}},l=e=>{try{i(t.throw(e))}catch(e){n(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,l);i((t=t.apply(void 0,null)).next())}));var t})(y)})),C=(e,t,...n)=>S(e,t,u(g(n),1,-1)),O=(e,t,n=null)=>w(void 0,null,(function*(){var r;return new Response(n,{status:t,headers:null!=(r=e.config.responseHeaders)?r:T})}));e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={}}onRequest(e){return w(this,null,(function*(){var t;const r=null!=(t=this.config.storePath)?t:"/store";if(new URL(e.url).pathname.endsWith(r)){const t=yield D(this),r=yield e.text();return"PUT"==e.method?t?O(this,205):(yield R(this,P(r),!0,e),O(this,201)):O(this,200,t?g(yield(i=this,w(void 0,null,(function*(){var e;const t={},r={},s=null!=(e=i.config.storagePrefix)?e:n;return x(yield i.party.storage.list(),((e,n)=>a(m(s,e),(([e,i])=>{if(e==l){const[e,r,l]=P("["+i+"]");p(p(t,e,y),r,y)[l]=n}else"v"==e&&(r[i]=n)})))),[t,r]})))):n)}var i;return O(this,404)}))}onMessage(e,t){return w(this,null,(function*(){var r;const l=null!=(r=this.config.messagePrefix)?r:n;yield a(m(l,e,1),(e=>w(this,[e],(function*([e,n]){"s"==e&&(yield D(this))&&(yield R(this,n,!1,t),this.party.broadcast(S(l,"s",n)))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,r){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,r,l,i){return!0}canDelCell(e,t,n,r){return!0}canSetValue(e,t,n,r){return!0}canDelValue(e,t){return!0}}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.3.11",
3
+ "version": "4.3.12",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -228,14 +228,14 @@
228
228
  "@types/jest": "^29.5.5",
229
229
  "@types/jest-environment-puppeteer": "^5.0.4",
230
230
  "@types/less": "^3.0.4",
231
- "@types/node": "^20.8.0",
231
+ "@types/node": "^20.8.2",
232
232
  "@types/puppeteer": "^5.4.7",
233
- "@types/react": "^18.2.24",
234
- "@types/react-dom": "^18.2.8",
233
+ "@types/react": "^18.2.25",
234
+ "@types/react-dom": "^18.2.10",
235
235
  "@types/react-test-renderer": "^18.0.3",
236
236
  "@types/tmp": "^0.2.4",
237
- "@typescript-eslint/eslint-plugin": "^6.7.3",
238
- "@typescript-eslint/parser": "^6.7.3",
237
+ "@typescript-eslint/eslint-plugin": "^6.7.4",
238
+ "@typescript-eslint/parser": "^6.7.4",
239
239
  "@vlcn.io/crsqlite-wasm": "^0.15.2",
240
240
  "asciichart": "^1.5.25",
241
241
  "automerge-repo": "^0.1.0",
@@ -265,7 +265,7 @@
265
265
  "jest-fetch-mock": "^3.0.3",
266
266
  "jest-puppeteer": "^9.0.1",
267
267
  "less": "^4.2.0",
268
- "partykit": "^0.0.25",
268
+ "partykit": "^0.0.27",
269
269
  "partysocket": "^0.0.8",
270
270
  "prettier": "^3.0.3",
271
271
  "puppeteer": "21.1.1",
@@ -289,7 +289,7 @@
289
289
  "@sqlite.org/sqlite-wasm": "^3.43.1-build1",
290
290
  "@vlcn.io/crsqlite-wasm": "^0.15.2",
291
291
  "automerge-repo": "^0.1.0",
292
- "partykit": "^0.0.25",
292
+ "partykit": "^0.0.27",
293
293
  "partysocket": "^0.0.8",
294
294
  "prettier": "^3.0.3",
295
295
  "react": "^18.2.0",