@diaryx/wasm-node 1.4.4 → 1.4.5-dev.57dd844
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.
- package/README.md +17 -0
- package/diaryx_wasm.d.ts +80 -2
- package/diaryx_wasm.js +382 -7
- package/diaryx_wasm_bg.wasm +0 -0
- package/diaryx_wasm_bg.wasm.d.ts +22 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,23 @@ To build the WebAssembly module:
|
|
|
20
20
|
wasm-pack build --target web --out-dir ../../apps/web/src/lib/wasm
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
Or via xtask (recommended, runs `wasm-opt -Oz` afterwards):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
cargo xtask build-wasm # production (smallest binary)
|
|
27
|
+
cargo xtask build-wasm --panic-hook # dev (enables console_error_panic_hook)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Cargo features
|
|
31
|
+
|
|
32
|
+
- `browser` (default) — enable OPFS, IndexedDB, and File System Access
|
|
33
|
+
Storage backends plus the `web-sys` APIs they need.
|
|
34
|
+
- `panic-hook` (off by default) — install `console_error_panic_hook` so
|
|
35
|
+
Rust panics render readable stack traces in the browser devtools. Adds a
|
|
36
|
+
small amount of WASM code, so it's opt-in and only recommended for
|
|
37
|
+
debug/dev builds. Pass `--features panic-hook` to `wasm-pack` or
|
|
38
|
+
`--panic-hook` to `cargo xtask build-wasm`.
|
|
39
|
+
|
|
23
40
|
## Testing
|
|
24
41
|
|
|
25
42
|
Run browser filesystem integration tests (wasm + browser):
|
package/diaryx_wasm.d.ts
CHANGED
|
@@ -305,6 +305,64 @@ export class JsAsyncFileSystem {
|
|
|
305
305
|
constructor(callbacks: any);
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Namespace client exposed to JavaScript.
|
|
310
|
+
*
|
|
311
|
+
* Wraps [`diaryx_core::namespace`] free functions with a
|
|
312
|
+
* [`WasmAuthenticatedClient`] backend. All methods return JSON strings on
|
|
313
|
+
* success and throw a JavaScript `Error` carrying a `statusCode` property
|
|
314
|
+
* on failure (mirroring [`crate::auth::AuthClient`]).
|
|
315
|
+
*/
|
|
316
|
+
export class NamespaceClient {
|
|
317
|
+
free(): void;
|
|
318
|
+
[Symbol.dispose](): void;
|
|
319
|
+
addSubscriber(id: string, audience: string, email: string): Promise<any>;
|
|
320
|
+
bulkImportSubscribers(id: string, audience: string, emails: string[]): Promise<any>;
|
|
321
|
+
claimSubdomain(id: string, subdomain: string, default_audience?: string | null): Promise<any>;
|
|
322
|
+
/**
|
|
323
|
+
* Create a new namespace. `id` is optional (server-assigned when null);
|
|
324
|
+
* `metadata` is an arbitrary JSON value stored verbatim.
|
|
325
|
+
*/
|
|
326
|
+
createNamespace(id: string | null | undefined, metadata: any): Promise<any>;
|
|
327
|
+
/**
|
|
328
|
+
* Delete a namespace on the server.
|
|
329
|
+
*
|
|
330
|
+
* Treats 404 as an idempotent success (see
|
|
331
|
+
* [`diaryx_core::namespace::delete_namespace`]).
|
|
332
|
+
*/
|
|
333
|
+
deleteNamespace(id: string): Promise<void>;
|
|
334
|
+
getAudienceToken(id: string, name: string): Promise<any>;
|
|
335
|
+
/**
|
|
336
|
+
* Fetch metadata for a single namespace.
|
|
337
|
+
*/
|
|
338
|
+
getNamespace(id: string): Promise<any>;
|
|
339
|
+
listAudiences(id: string): Promise<any>;
|
|
340
|
+
listDomains(id: string): Promise<any>;
|
|
341
|
+
listSubscribers(id: string, audience: string): Promise<any>;
|
|
342
|
+
/**
|
|
343
|
+
* Create a new namespace client targeting the given server URL.
|
|
344
|
+
*
|
|
345
|
+
* `callbacks` is the same `AuthCallbacks` interface [`AuthClient`] uses
|
|
346
|
+
* (see module docs) — only the `fetch` callback is actually invoked by
|
|
347
|
+
* namespace operations.
|
|
348
|
+
*/
|
|
349
|
+
constructor(server_url: string, callbacks: AuthCallbacks);
|
|
350
|
+
registerDomain(id: string, domain: string, audience_name: string): Promise<any>;
|
|
351
|
+
releaseSubdomain(id: string): Promise<void>;
|
|
352
|
+
removeDomain(id: string, domain: string): Promise<void>;
|
|
353
|
+
removeSubscriber(id: string, audience: string, contact_id: string): Promise<void>;
|
|
354
|
+
rotateAudiencePassword(id: string, name: string, password: string): Promise<any>;
|
|
355
|
+
setAudience(id: string, name: string, access: string): Promise<void>;
|
|
356
|
+
/**
|
|
357
|
+
* Replace the `metadata` blob on an existing namespace.
|
|
358
|
+
*/
|
|
359
|
+
updateNamespaceMetadata(id: string, metadata: any): Promise<any>;
|
|
360
|
+
/**
|
|
361
|
+
* Server URL this client targets.
|
|
362
|
+
*/
|
|
363
|
+
readonly serverUrl: string;
|
|
364
|
+
}
|
|
365
|
+
|
|
308
366
|
/**
|
|
309
367
|
* Initialize the WASM module. Called automatically on module load.
|
|
310
368
|
*/
|
|
@@ -358,12 +416,32 @@ export interface InitOutput {
|
|
|
358
416
|
readonly diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
|
|
359
417
|
readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
|
|
360
418
|
readonly jsasyncfilesystem_new: (a: any) => number;
|
|
419
|
+
readonly namespaceclient_addSubscriber: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
420
|
+
readonly namespaceclient_bulkImportSubscribers: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
421
|
+
readonly namespaceclient_claimSubdomain: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
422
|
+
readonly namespaceclient_createNamespace: (a: number, b: number, c: number, d: any) => any;
|
|
423
|
+
readonly namespaceclient_deleteNamespace: (a: number, b: number, c: number) => any;
|
|
424
|
+
readonly namespaceclient_getAudienceToken: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
425
|
+
readonly namespaceclient_getNamespace: (a: number, b: number, c: number) => any;
|
|
426
|
+
readonly namespaceclient_listAudiences: (a: number, b: number, c: number) => any;
|
|
427
|
+
readonly namespaceclient_listDomains: (a: number, b: number, c: number) => any;
|
|
428
|
+
readonly namespaceclient_listSubscribers: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
429
|
+
readonly namespaceclient_registerDomain: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
430
|
+
readonly namespaceclient_releaseSubdomain: (a: number, b: number, c: number) => any;
|
|
431
|
+
readonly namespaceclient_removeDomain: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
432
|
+
readonly namespaceclient_removeSubscriber: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
433
|
+
readonly namespaceclient_rotateAudiencePassword: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
434
|
+
readonly namespaceclient_serverUrl: (a: number) => [number, number];
|
|
435
|
+
readonly namespaceclient_setAudience: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
436
|
+
readonly namespaceclient_updateNamespaceMetadata: (a: number, b: number, c: number, d: any) => any;
|
|
361
437
|
readonly now_timestamp: () => [number, number];
|
|
362
438
|
readonly today_formatted: (a: number, b: number) => [number, number];
|
|
363
439
|
readonly init: () => void;
|
|
364
440
|
readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
365
|
-
readonly
|
|
366
|
-
readonly
|
|
441
|
+
readonly namespaceclient_new: (a: number, b: number, c: any) => number;
|
|
442
|
+
readonly __wbg_namespaceclient_free: (a: number, b: number) => void;
|
|
443
|
+
readonly wasm_bindgen__convert__closures_____invoke__h7174ba9de949bff3: (a: number, b: number, c: any) => [number, number];
|
|
444
|
+
readonly wasm_bindgen__convert__closures_____invoke__h377ea917efd328e8: (a: number, b: number, c: any, d: any) => void;
|
|
367
445
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
368
446
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
369
447
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/diaryx_wasm.js
CHANGED
|
@@ -487,6 +487,292 @@ export class JsAsyncFileSystem {
|
|
|
487
487
|
}
|
|
488
488
|
if (Symbol.dispose) JsAsyncFileSystem.prototype[Symbol.dispose] = JsAsyncFileSystem.prototype.free;
|
|
489
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Namespace client exposed to JavaScript.
|
|
492
|
+
*
|
|
493
|
+
* Wraps [`diaryx_core::namespace`] free functions with a
|
|
494
|
+
* [`WasmAuthenticatedClient`] backend. All methods return JSON strings on
|
|
495
|
+
* success and throw a JavaScript `Error` carrying a `statusCode` property
|
|
496
|
+
* on failure (mirroring [`crate::auth::AuthClient`]).
|
|
497
|
+
*/
|
|
498
|
+
export class NamespaceClient {
|
|
499
|
+
__destroy_into_raw() {
|
|
500
|
+
const ptr = this.__wbg_ptr;
|
|
501
|
+
this.__wbg_ptr = 0;
|
|
502
|
+
NamespaceClientFinalization.unregister(this);
|
|
503
|
+
return ptr;
|
|
504
|
+
}
|
|
505
|
+
free() {
|
|
506
|
+
const ptr = this.__destroy_into_raw();
|
|
507
|
+
wasm.__wbg_namespaceclient_free(ptr, 0);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* @param {string} id
|
|
511
|
+
* @param {string} audience
|
|
512
|
+
* @param {string} email
|
|
513
|
+
* @returns {Promise<any>}
|
|
514
|
+
*/
|
|
515
|
+
addSubscriber(id, audience, email) {
|
|
516
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
517
|
+
const len0 = WASM_VECTOR_LEN;
|
|
518
|
+
const ptr1 = passStringToWasm0(audience, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
519
|
+
const len1 = WASM_VECTOR_LEN;
|
|
520
|
+
const ptr2 = passStringToWasm0(email, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
521
|
+
const len2 = WASM_VECTOR_LEN;
|
|
522
|
+
const ret = wasm.namespaceclient_addSubscriber(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
523
|
+
return ret;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* @param {string} id
|
|
527
|
+
* @param {string} audience
|
|
528
|
+
* @param {string[]} emails
|
|
529
|
+
* @returns {Promise<any>}
|
|
530
|
+
*/
|
|
531
|
+
bulkImportSubscribers(id, audience, emails) {
|
|
532
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
533
|
+
const len0 = WASM_VECTOR_LEN;
|
|
534
|
+
const ptr1 = passStringToWasm0(audience, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
535
|
+
const len1 = WASM_VECTOR_LEN;
|
|
536
|
+
const ptr2 = passArrayJsValueToWasm0(emails, wasm.__wbindgen_malloc);
|
|
537
|
+
const len2 = WASM_VECTOR_LEN;
|
|
538
|
+
const ret = wasm.namespaceclient_bulkImportSubscribers(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
539
|
+
return ret;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* @param {string} id
|
|
543
|
+
* @param {string} subdomain
|
|
544
|
+
* @param {string | null} [default_audience]
|
|
545
|
+
* @returns {Promise<any>}
|
|
546
|
+
*/
|
|
547
|
+
claimSubdomain(id, subdomain, default_audience) {
|
|
548
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
549
|
+
const len0 = WASM_VECTOR_LEN;
|
|
550
|
+
const ptr1 = passStringToWasm0(subdomain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
551
|
+
const len1 = WASM_VECTOR_LEN;
|
|
552
|
+
var ptr2 = isLikeNone(default_audience) ? 0 : passStringToWasm0(default_audience, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
553
|
+
var len2 = WASM_VECTOR_LEN;
|
|
554
|
+
const ret = wasm.namespaceclient_claimSubdomain(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
555
|
+
return ret;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Create a new namespace. `id` is optional (server-assigned when null);
|
|
559
|
+
* `metadata` is an arbitrary JSON value stored verbatim.
|
|
560
|
+
* @param {string | null | undefined} id
|
|
561
|
+
* @param {any} metadata
|
|
562
|
+
* @returns {Promise<any>}
|
|
563
|
+
*/
|
|
564
|
+
createNamespace(id, metadata) {
|
|
565
|
+
var ptr0 = isLikeNone(id) ? 0 : passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
566
|
+
var len0 = WASM_VECTOR_LEN;
|
|
567
|
+
const ret = wasm.namespaceclient_createNamespace(this.__wbg_ptr, ptr0, len0, metadata);
|
|
568
|
+
return ret;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Delete a namespace on the server.
|
|
572
|
+
*
|
|
573
|
+
* Treats 404 as an idempotent success (see
|
|
574
|
+
* [`diaryx_core::namespace::delete_namespace`]).
|
|
575
|
+
* @param {string} id
|
|
576
|
+
* @returns {Promise<void>}
|
|
577
|
+
*/
|
|
578
|
+
deleteNamespace(id) {
|
|
579
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
580
|
+
const len0 = WASM_VECTOR_LEN;
|
|
581
|
+
const ret = wasm.namespaceclient_deleteNamespace(this.__wbg_ptr, ptr0, len0);
|
|
582
|
+
return ret;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* @param {string} id
|
|
586
|
+
* @param {string} name
|
|
587
|
+
* @returns {Promise<any>}
|
|
588
|
+
*/
|
|
589
|
+
getAudienceToken(id, name) {
|
|
590
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
591
|
+
const len0 = WASM_VECTOR_LEN;
|
|
592
|
+
const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
593
|
+
const len1 = WASM_VECTOR_LEN;
|
|
594
|
+
const ret = wasm.namespaceclient_getAudienceToken(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
595
|
+
return ret;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Fetch metadata for a single namespace.
|
|
599
|
+
* @param {string} id
|
|
600
|
+
* @returns {Promise<any>}
|
|
601
|
+
*/
|
|
602
|
+
getNamespace(id) {
|
|
603
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
604
|
+
const len0 = WASM_VECTOR_LEN;
|
|
605
|
+
const ret = wasm.namespaceclient_getNamespace(this.__wbg_ptr, ptr0, len0);
|
|
606
|
+
return ret;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* @param {string} id
|
|
610
|
+
* @returns {Promise<any>}
|
|
611
|
+
*/
|
|
612
|
+
listAudiences(id) {
|
|
613
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
614
|
+
const len0 = WASM_VECTOR_LEN;
|
|
615
|
+
const ret = wasm.namespaceclient_listAudiences(this.__wbg_ptr, ptr0, len0);
|
|
616
|
+
return ret;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* @param {string} id
|
|
620
|
+
* @returns {Promise<any>}
|
|
621
|
+
*/
|
|
622
|
+
listDomains(id) {
|
|
623
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
624
|
+
const len0 = WASM_VECTOR_LEN;
|
|
625
|
+
const ret = wasm.namespaceclient_listDomains(this.__wbg_ptr, ptr0, len0);
|
|
626
|
+
return ret;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* @param {string} id
|
|
630
|
+
* @param {string} audience
|
|
631
|
+
* @returns {Promise<any>}
|
|
632
|
+
*/
|
|
633
|
+
listSubscribers(id, audience) {
|
|
634
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
635
|
+
const len0 = WASM_VECTOR_LEN;
|
|
636
|
+
const ptr1 = passStringToWasm0(audience, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
637
|
+
const len1 = WASM_VECTOR_LEN;
|
|
638
|
+
const ret = wasm.namespaceclient_listSubscribers(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
639
|
+
return ret;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Create a new namespace client targeting the given server URL.
|
|
643
|
+
*
|
|
644
|
+
* `callbacks` is the same `AuthCallbacks` interface [`AuthClient`] uses
|
|
645
|
+
* (see module docs) — only the `fetch` callback is actually invoked by
|
|
646
|
+
* namespace operations.
|
|
647
|
+
* @param {string} server_url
|
|
648
|
+
* @param {AuthCallbacks} callbacks
|
|
649
|
+
*/
|
|
650
|
+
constructor(server_url, callbacks) {
|
|
651
|
+
const ptr0 = passStringToWasm0(server_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
652
|
+
const len0 = WASM_VECTOR_LEN;
|
|
653
|
+
const ret = wasm.namespaceclient_new(ptr0, len0, callbacks);
|
|
654
|
+
this.__wbg_ptr = ret >>> 0;
|
|
655
|
+
NamespaceClientFinalization.register(this, this.__wbg_ptr, this);
|
|
656
|
+
return this;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* @param {string} id
|
|
660
|
+
* @param {string} domain
|
|
661
|
+
* @param {string} audience_name
|
|
662
|
+
* @returns {Promise<any>}
|
|
663
|
+
*/
|
|
664
|
+
registerDomain(id, domain, audience_name) {
|
|
665
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
666
|
+
const len0 = WASM_VECTOR_LEN;
|
|
667
|
+
const ptr1 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
668
|
+
const len1 = WASM_VECTOR_LEN;
|
|
669
|
+
const ptr2 = passStringToWasm0(audience_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
670
|
+
const len2 = WASM_VECTOR_LEN;
|
|
671
|
+
const ret = wasm.namespaceclient_registerDomain(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
672
|
+
return ret;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* @param {string} id
|
|
676
|
+
* @returns {Promise<void>}
|
|
677
|
+
*/
|
|
678
|
+
releaseSubdomain(id) {
|
|
679
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
680
|
+
const len0 = WASM_VECTOR_LEN;
|
|
681
|
+
const ret = wasm.namespaceclient_releaseSubdomain(this.__wbg_ptr, ptr0, len0);
|
|
682
|
+
return ret;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* @param {string} id
|
|
686
|
+
* @param {string} domain
|
|
687
|
+
* @returns {Promise<void>}
|
|
688
|
+
*/
|
|
689
|
+
removeDomain(id, domain) {
|
|
690
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
691
|
+
const len0 = WASM_VECTOR_LEN;
|
|
692
|
+
const ptr1 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
693
|
+
const len1 = WASM_VECTOR_LEN;
|
|
694
|
+
const ret = wasm.namespaceclient_removeDomain(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
695
|
+
return ret;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* @param {string} id
|
|
699
|
+
* @param {string} audience
|
|
700
|
+
* @param {string} contact_id
|
|
701
|
+
* @returns {Promise<void>}
|
|
702
|
+
*/
|
|
703
|
+
removeSubscriber(id, audience, contact_id) {
|
|
704
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
705
|
+
const len0 = WASM_VECTOR_LEN;
|
|
706
|
+
const ptr1 = passStringToWasm0(audience, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
707
|
+
const len1 = WASM_VECTOR_LEN;
|
|
708
|
+
const ptr2 = passStringToWasm0(contact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
709
|
+
const len2 = WASM_VECTOR_LEN;
|
|
710
|
+
const ret = wasm.namespaceclient_removeSubscriber(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
711
|
+
return ret;
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* @param {string} id
|
|
715
|
+
* @param {string} name
|
|
716
|
+
* @param {string} password
|
|
717
|
+
* @returns {Promise<any>}
|
|
718
|
+
*/
|
|
719
|
+
rotateAudiencePassword(id, name, password) {
|
|
720
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
721
|
+
const len0 = WASM_VECTOR_LEN;
|
|
722
|
+
const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
723
|
+
const len1 = WASM_VECTOR_LEN;
|
|
724
|
+
const ptr2 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
725
|
+
const len2 = WASM_VECTOR_LEN;
|
|
726
|
+
const ret = wasm.namespaceclient_rotateAudiencePassword(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
727
|
+
return ret;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Server URL this client targets.
|
|
731
|
+
* @returns {string}
|
|
732
|
+
*/
|
|
733
|
+
get serverUrl() {
|
|
734
|
+
let deferred1_0;
|
|
735
|
+
let deferred1_1;
|
|
736
|
+
try {
|
|
737
|
+
const ret = wasm.namespaceclient_serverUrl(this.__wbg_ptr);
|
|
738
|
+
deferred1_0 = ret[0];
|
|
739
|
+
deferred1_1 = ret[1];
|
|
740
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
741
|
+
} finally {
|
|
742
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* @param {string} id
|
|
747
|
+
* @param {string} name
|
|
748
|
+
* @param {string} access
|
|
749
|
+
* @returns {Promise<void>}
|
|
750
|
+
*/
|
|
751
|
+
setAudience(id, name, access) {
|
|
752
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
753
|
+
const len0 = WASM_VECTOR_LEN;
|
|
754
|
+
const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
755
|
+
const len1 = WASM_VECTOR_LEN;
|
|
756
|
+
const ptr2 = passStringToWasm0(access, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
757
|
+
const len2 = WASM_VECTOR_LEN;
|
|
758
|
+
const ret = wasm.namespaceclient_setAudience(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
759
|
+
return ret;
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Replace the `metadata` blob on an existing namespace.
|
|
763
|
+
* @param {string} id
|
|
764
|
+
* @param {any} metadata
|
|
765
|
+
* @returns {Promise<any>}
|
|
766
|
+
*/
|
|
767
|
+
updateNamespaceMetadata(id, metadata) {
|
|
768
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
769
|
+
const len0 = WASM_VECTOR_LEN;
|
|
770
|
+
const ret = wasm.namespaceclient_updateNamespaceMetadata(this.__wbg_ptr, ptr0, len0, metadata);
|
|
771
|
+
return ret;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (Symbol.dispose) NamespaceClient.prototype[Symbol.dispose] = NamespaceClient.prototype.free;
|
|
775
|
+
|
|
490
776
|
/**
|
|
491
777
|
* Initialize the WASM module. Called automatically on module load.
|
|
492
778
|
*/
|
|
@@ -538,6 +824,13 @@ function __wbg_get_imports() {
|
|
|
538
824
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
539
825
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
540
826
|
},
|
|
827
|
+
__wbg___wbindgen_debug_string_ab4b34d23d6778bd: function(arg0, arg1) {
|
|
828
|
+
const ret = debugString(arg1);
|
|
829
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
830
|
+
const len1 = WASM_VECTOR_LEN;
|
|
831
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
832
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
833
|
+
},
|
|
541
834
|
__wbg___wbindgen_is_function_3baa9db1a987f47d: function(arg0) {
|
|
542
835
|
const ret = typeof(arg0) === 'function';
|
|
543
836
|
return ret;
|
|
@@ -695,7 +988,7 @@ function __wbg_get_imports() {
|
|
|
695
988
|
const a = state0.a;
|
|
696
989
|
state0.a = 0;
|
|
697
990
|
try {
|
|
698
|
-
return
|
|
991
|
+
return wasm_bindgen__convert__closures_____invoke__h377ea917efd328e8(a, state0.b, arg0, arg1);
|
|
699
992
|
} finally {
|
|
700
993
|
state0.a = a;
|
|
701
994
|
}
|
|
@@ -755,6 +1048,10 @@ function __wbg_get_imports() {
|
|
|
755
1048
|
const ret = typeof window === 'undefined' ? null : window;
|
|
756
1049
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
757
1050
|
},
|
|
1051
|
+
__wbg_stringify_91082ed7a5a5769e: function() { return handleError(function (arg0) {
|
|
1052
|
+
const ret = JSON.stringify(arg0);
|
|
1053
|
+
return ret;
|
|
1054
|
+
}, arguments); },
|
|
758
1055
|
__wbg_then_792e0c862b060889: function(arg0, arg1, arg2) {
|
|
759
1056
|
const ret = arg0.then(arg1, arg2);
|
|
760
1057
|
return ret;
|
|
@@ -771,8 +1068,8 @@ function __wbg_get_imports() {
|
|
|
771
1068
|
console.warn(arg0, arg1, arg2, arg3);
|
|
772
1069
|
},
|
|
773
1070
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
774
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
775
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1071
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 701, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1072
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h7174ba9de949bff3);
|
|
776
1073
|
return ret;
|
|
777
1074
|
},
|
|
778
1075
|
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
@@ -801,15 +1098,15 @@ function __wbg_get_imports() {
|
|
|
801
1098
|
};
|
|
802
1099
|
}
|
|
803
1100
|
|
|
804
|
-
function
|
|
805
|
-
const ret = wasm.
|
|
1101
|
+
function wasm_bindgen__convert__closures_____invoke__h7174ba9de949bff3(arg0, arg1, arg2) {
|
|
1102
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h7174ba9de949bff3(arg0, arg1, arg2);
|
|
806
1103
|
if (ret[1]) {
|
|
807
1104
|
throw takeFromExternrefTable0(ret[0]);
|
|
808
1105
|
}
|
|
809
1106
|
}
|
|
810
1107
|
|
|
811
|
-
function
|
|
812
|
-
wasm.
|
|
1108
|
+
function wasm_bindgen__convert__closures_____invoke__h377ea917efd328e8(arg0, arg1, arg2, arg3) {
|
|
1109
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h377ea917efd328e8(arg0, arg1, arg2, arg3);
|
|
813
1110
|
}
|
|
814
1111
|
|
|
815
1112
|
const AuthClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -821,6 +1118,9 @@ const DiaryxBackendFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
821
1118
|
const JsAsyncFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
822
1119
|
? { register: () => {}, unregister: () => {} }
|
|
823
1120
|
: new FinalizationRegistry(ptr => wasm.__wbg_jsasyncfilesystem_free(ptr >>> 0, 1));
|
|
1121
|
+
const NamespaceClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1122
|
+
? { register: () => {}, unregister: () => {} }
|
|
1123
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_namespaceclient_free(ptr >>> 0, 1));
|
|
824
1124
|
|
|
825
1125
|
function addToExternrefTable0(obj) {
|
|
826
1126
|
const idx = wasm.__externref_table_alloc();
|
|
@@ -832,6 +1132,71 @@ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
|
832
1132
|
? { register: () => {}, unregister: () => {} }
|
|
833
1133
|
: new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
|
|
834
1134
|
|
|
1135
|
+
function debugString(val) {
|
|
1136
|
+
// primitive types
|
|
1137
|
+
const type = typeof val;
|
|
1138
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
1139
|
+
return `${val}`;
|
|
1140
|
+
}
|
|
1141
|
+
if (type == 'string') {
|
|
1142
|
+
return `"${val}"`;
|
|
1143
|
+
}
|
|
1144
|
+
if (type == 'symbol') {
|
|
1145
|
+
const description = val.description;
|
|
1146
|
+
if (description == null) {
|
|
1147
|
+
return 'Symbol';
|
|
1148
|
+
} else {
|
|
1149
|
+
return `Symbol(${description})`;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
if (type == 'function') {
|
|
1153
|
+
const name = val.name;
|
|
1154
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
1155
|
+
return `Function(${name})`;
|
|
1156
|
+
} else {
|
|
1157
|
+
return 'Function';
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
// objects
|
|
1161
|
+
if (Array.isArray(val)) {
|
|
1162
|
+
const length = val.length;
|
|
1163
|
+
let debug = '[';
|
|
1164
|
+
if (length > 0) {
|
|
1165
|
+
debug += debugString(val[0]);
|
|
1166
|
+
}
|
|
1167
|
+
for(let i = 1; i < length; i++) {
|
|
1168
|
+
debug += ', ' + debugString(val[i]);
|
|
1169
|
+
}
|
|
1170
|
+
debug += ']';
|
|
1171
|
+
return debug;
|
|
1172
|
+
}
|
|
1173
|
+
// Test for built-in
|
|
1174
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
1175
|
+
let className;
|
|
1176
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
1177
|
+
className = builtInMatches[1];
|
|
1178
|
+
} else {
|
|
1179
|
+
// Failed to match the standard '[object ClassName]'
|
|
1180
|
+
return toString.call(val);
|
|
1181
|
+
}
|
|
1182
|
+
if (className == 'Object') {
|
|
1183
|
+
// we're a user defined class or Object
|
|
1184
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
1185
|
+
// easier than looping through ownProperties of `val`.
|
|
1186
|
+
try {
|
|
1187
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
1188
|
+
} catch (_) {
|
|
1189
|
+
return 'Object';
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
// errors
|
|
1193
|
+
if (val instanceof Error) {
|
|
1194
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
1195
|
+
}
|
|
1196
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
1197
|
+
return className;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
835
1200
|
function getArrayU8FromWasm0(ptr, len) {
|
|
836
1201
|
ptr = ptr >>> 0;
|
|
837
1202
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -899,6 +1264,16 @@ function makeMutClosure(arg0, arg1, f) {
|
|
|
899
1264
|
return real;
|
|
900
1265
|
}
|
|
901
1266
|
|
|
1267
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1268
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1269
|
+
for (let i = 0; i < array.length; i++) {
|
|
1270
|
+
const add = addToExternrefTable0(array[i]);
|
|
1271
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1272
|
+
}
|
|
1273
|
+
WASM_VECTOR_LEN = array.length;
|
|
1274
|
+
return ptr;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
902
1277
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
903
1278
|
if (realloc === undefined) {
|
|
904
1279
|
const buf = cachedTextEncoder.encode(arg);
|
package/diaryx_wasm_bg.wasm
CHANGED
|
Binary file
|
package/diaryx_wasm_bg.wasm.d.ts
CHANGED
|
@@ -35,12 +35,32 @@ export const diaryxbackend_setCrdtEnabled: (a: number, b: number) => void;
|
|
|
35
35
|
export const diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
|
|
36
36
|
export const jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
|
|
37
37
|
export const jsasyncfilesystem_new: (a: any) => number;
|
|
38
|
+
export const namespaceclient_addSubscriber: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
39
|
+
export const namespaceclient_bulkImportSubscribers: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
40
|
+
export const namespaceclient_claimSubdomain: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
41
|
+
export const namespaceclient_createNamespace: (a: number, b: number, c: number, d: any) => any;
|
|
42
|
+
export const namespaceclient_deleteNamespace: (a: number, b: number, c: number) => any;
|
|
43
|
+
export const namespaceclient_getAudienceToken: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
44
|
+
export const namespaceclient_getNamespace: (a: number, b: number, c: number) => any;
|
|
45
|
+
export const namespaceclient_listAudiences: (a: number, b: number, c: number) => any;
|
|
46
|
+
export const namespaceclient_listDomains: (a: number, b: number, c: number) => any;
|
|
47
|
+
export const namespaceclient_listSubscribers: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
48
|
+
export const namespaceclient_registerDomain: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
49
|
+
export const namespaceclient_releaseSubdomain: (a: number, b: number, c: number) => any;
|
|
50
|
+
export const namespaceclient_removeDomain: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
51
|
+
export const namespaceclient_removeSubscriber: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
52
|
+
export const namespaceclient_rotateAudiencePassword: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
53
|
+
export const namespaceclient_serverUrl: (a: number) => [number, number];
|
|
54
|
+
export const namespaceclient_setAudience: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
55
|
+
export const namespaceclient_updateNamespaceMetadata: (a: number, b: number, c: number, d: any) => any;
|
|
38
56
|
export const now_timestamp: () => [number, number];
|
|
39
57
|
export const today_formatted: (a: number, b: number) => [number, number];
|
|
40
58
|
export const init: () => void;
|
|
41
59
|
export const diaryxbackend_isCrdtEnabled: (a: number) => number;
|
|
42
|
-
export const
|
|
43
|
-
export const
|
|
60
|
+
export const namespaceclient_new: (a: number, b: number, c: any) => number;
|
|
61
|
+
export const __wbg_namespaceclient_free: (a: number, b: number) => void;
|
|
62
|
+
export const wasm_bindgen__convert__closures_____invoke__h7174ba9de949bff3: (a: number, b: number, c: any) => [number, number];
|
|
63
|
+
export const wasm_bindgen__convert__closures_____invoke__h377ea917efd328e8: (a: number, b: number, c: any, d: any) => void;
|
|
44
64
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
45
65
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
46
66
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/package.json
CHANGED