@diaryx/wasm-node 1.4.5-dev.5f8049f → 1.4.5-dev.beb1356

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 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,63 @@ 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
+ setAudience(id: string, name: string, access: string): Promise<void>;
355
+ /**
356
+ * Replace the `metadata` blob on an existing namespace.
357
+ */
358
+ updateNamespaceMetadata(id: string, metadata: any): Promise<any>;
359
+ /**
360
+ * Server URL this client targets.
361
+ */
362
+ readonly serverUrl: string;
363
+ }
364
+
308
365
  /**
309
366
  * Initialize the WASM module. Called automatically on module load.
310
367
  */
@@ -358,10 +415,29 @@ export interface InitOutput {
358
415
  readonly diaryxbackend_writeBinary: (a: number, b: number, c: number, d: any) => any;
359
416
  readonly jsasyncfilesystem_has_callback: (a: number, b: number, c: number) => number;
360
417
  readonly jsasyncfilesystem_new: (a: any) => number;
418
+ readonly namespaceclient_addSubscriber: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
419
+ readonly namespaceclient_bulkImportSubscribers: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
420
+ readonly namespaceclient_claimSubdomain: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
421
+ readonly namespaceclient_createNamespace: (a: number, b: number, c: number, d: any) => any;
422
+ readonly namespaceclient_deleteNamespace: (a: number, b: number, c: number) => any;
423
+ readonly namespaceclient_getAudienceToken: (a: number, b: number, c: number, d: number, e: number) => any;
424
+ readonly namespaceclient_getNamespace: (a: number, b: number, c: number) => any;
425
+ readonly namespaceclient_listAudiences: (a: number, b: number, c: number) => any;
426
+ readonly namespaceclient_listDomains: (a: number, b: number, c: number) => any;
427
+ readonly namespaceclient_listSubscribers: (a: number, b: number, c: number, d: number, e: number) => any;
428
+ readonly namespaceclient_registerDomain: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
429
+ readonly namespaceclient_releaseSubdomain: (a: number, b: number, c: number) => any;
430
+ readonly namespaceclient_removeDomain: (a: number, b: number, c: number, d: number, e: number) => any;
431
+ readonly namespaceclient_removeSubscriber: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
432
+ readonly namespaceclient_serverUrl: (a: number) => [number, number];
433
+ readonly namespaceclient_setAudience: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
434
+ readonly namespaceclient_updateNamespaceMetadata: (a: number, b: number, c: number, d: any) => any;
361
435
  readonly now_timestamp: () => [number, number];
362
436
  readonly today_formatted: (a: number, b: number) => [number, number];
363
437
  readonly init: () => void;
364
438
  readonly diaryxbackend_isCrdtEnabled: (a: number) => number;
439
+ readonly namespaceclient_new: (a: number, b: number, c: any) => number;
440
+ readonly __wbg_namespaceclient_free: (a: number, b: number) => void;
365
441
  readonly wasm_bindgen__convert__closures_____invoke__h7174ba9de949bff3: (a: number, b: number, c: any) => [number, number];
366
442
  readonly wasm_bindgen__convert__closures_____invoke__h377ea917efd328e8: (a: number, b: number, c: any, d: any) => void;
367
443
  readonly __wbindgen_malloc: (a: number, b: number) => number;
package/diaryx_wasm.js CHANGED
@@ -487,6 +487,276 @@ 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
+ * Server URL this client targets.
715
+ * @returns {string}
716
+ */
717
+ get serverUrl() {
718
+ let deferred1_0;
719
+ let deferred1_1;
720
+ try {
721
+ const ret = wasm.namespaceclient_serverUrl(this.__wbg_ptr);
722
+ deferred1_0 = ret[0];
723
+ deferred1_1 = ret[1];
724
+ return getStringFromWasm0(ret[0], ret[1]);
725
+ } finally {
726
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
727
+ }
728
+ }
729
+ /**
730
+ * @param {string} id
731
+ * @param {string} name
732
+ * @param {string} access
733
+ * @returns {Promise<void>}
734
+ */
735
+ setAudience(id, name, access) {
736
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
737
+ const len0 = WASM_VECTOR_LEN;
738
+ const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
739
+ const len1 = WASM_VECTOR_LEN;
740
+ const ptr2 = passStringToWasm0(access, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
741
+ const len2 = WASM_VECTOR_LEN;
742
+ const ret = wasm.namespaceclient_setAudience(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
743
+ return ret;
744
+ }
745
+ /**
746
+ * Replace the `metadata` blob on an existing namespace.
747
+ * @param {string} id
748
+ * @param {any} metadata
749
+ * @returns {Promise<any>}
750
+ */
751
+ updateNamespaceMetadata(id, metadata) {
752
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
753
+ const len0 = WASM_VECTOR_LEN;
754
+ const ret = wasm.namespaceclient_updateNamespaceMetadata(this.__wbg_ptr, ptr0, len0, metadata);
755
+ return ret;
756
+ }
757
+ }
758
+ if (Symbol.dispose) NamespaceClient.prototype[Symbol.dispose] = NamespaceClient.prototype.free;
759
+
490
760
  /**
491
761
  * Initialize the WASM module. Called automatically on module load.
492
762
  */
@@ -538,6 +808,13 @@ function __wbg_get_imports() {
538
808
  const ret = typeof(v) === 'boolean' ? v : undefined;
539
809
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
540
810
  },
811
+ __wbg___wbindgen_debug_string_ab4b34d23d6778bd: function(arg0, arg1) {
812
+ const ret = debugString(arg1);
813
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
814
+ const len1 = WASM_VECTOR_LEN;
815
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
816
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
817
+ },
541
818
  __wbg___wbindgen_is_function_3baa9db1a987f47d: function(arg0) {
542
819
  const ret = typeof(arg0) === 'function';
543
820
  return ret;
@@ -755,6 +1032,10 @@ function __wbg_get_imports() {
755
1032
  const ret = typeof window === 'undefined' ? null : window;
756
1033
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
757
1034
  },
1035
+ __wbg_stringify_91082ed7a5a5769e: function() { return handleError(function (arg0) {
1036
+ const ret = JSON.stringify(arg0);
1037
+ return ret;
1038
+ }, arguments); },
758
1039
  __wbg_then_792e0c862b060889: function(arg0, arg1, arg2) {
759
1040
  const ret = arg0.then(arg1, arg2);
760
1041
  return ret;
@@ -771,7 +1052,7 @@ function __wbg_get_imports() {
771
1052
  console.warn(arg0, arg1, arg2, arg3);
772
1053
  },
773
1054
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
774
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 597, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1055
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 688, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
775
1056
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h7174ba9de949bff3);
776
1057
  return ret;
777
1058
  },
@@ -821,6 +1102,9 @@ const DiaryxBackendFinalization = (typeof FinalizationRegistry === 'undefined')
821
1102
  const JsAsyncFileSystemFinalization = (typeof FinalizationRegistry === 'undefined')
822
1103
  ? { register: () => {}, unregister: () => {} }
823
1104
  : new FinalizationRegistry(ptr => wasm.__wbg_jsasyncfilesystem_free(ptr >>> 0, 1));
1105
+ const NamespaceClientFinalization = (typeof FinalizationRegistry === 'undefined')
1106
+ ? { register: () => {}, unregister: () => {} }
1107
+ : new FinalizationRegistry(ptr => wasm.__wbg_namespaceclient_free(ptr >>> 0, 1));
824
1108
 
825
1109
  function addToExternrefTable0(obj) {
826
1110
  const idx = wasm.__externref_table_alloc();
@@ -832,6 +1116,71 @@ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
832
1116
  ? { register: () => {}, unregister: () => {} }
833
1117
  : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
834
1118
 
1119
+ function debugString(val) {
1120
+ // primitive types
1121
+ const type = typeof val;
1122
+ if (type == 'number' || type == 'boolean' || val == null) {
1123
+ return `${val}`;
1124
+ }
1125
+ if (type == 'string') {
1126
+ return `"${val}"`;
1127
+ }
1128
+ if (type == 'symbol') {
1129
+ const description = val.description;
1130
+ if (description == null) {
1131
+ return 'Symbol';
1132
+ } else {
1133
+ return `Symbol(${description})`;
1134
+ }
1135
+ }
1136
+ if (type == 'function') {
1137
+ const name = val.name;
1138
+ if (typeof name == 'string' && name.length > 0) {
1139
+ return `Function(${name})`;
1140
+ } else {
1141
+ return 'Function';
1142
+ }
1143
+ }
1144
+ // objects
1145
+ if (Array.isArray(val)) {
1146
+ const length = val.length;
1147
+ let debug = '[';
1148
+ if (length > 0) {
1149
+ debug += debugString(val[0]);
1150
+ }
1151
+ for(let i = 1; i < length; i++) {
1152
+ debug += ', ' + debugString(val[i]);
1153
+ }
1154
+ debug += ']';
1155
+ return debug;
1156
+ }
1157
+ // Test for built-in
1158
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1159
+ let className;
1160
+ if (builtInMatches && builtInMatches.length > 1) {
1161
+ className = builtInMatches[1];
1162
+ } else {
1163
+ // Failed to match the standard '[object ClassName]'
1164
+ return toString.call(val);
1165
+ }
1166
+ if (className == 'Object') {
1167
+ // we're a user defined class or Object
1168
+ // JSON.stringify avoids problems with cycles, and is generally much
1169
+ // easier than looping through ownProperties of `val`.
1170
+ try {
1171
+ return 'Object(' + JSON.stringify(val) + ')';
1172
+ } catch (_) {
1173
+ return 'Object';
1174
+ }
1175
+ }
1176
+ // errors
1177
+ if (val instanceof Error) {
1178
+ return `${val.name}: ${val.message}\n${val.stack}`;
1179
+ }
1180
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1181
+ return className;
1182
+ }
1183
+
835
1184
  function getArrayU8FromWasm0(ptr, len) {
836
1185
  ptr = ptr >>> 0;
837
1186
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -899,6 +1248,16 @@ function makeMutClosure(arg0, arg1, f) {
899
1248
  return real;
900
1249
  }
901
1250
 
1251
+ function passArrayJsValueToWasm0(array, malloc) {
1252
+ const ptr = malloc(array.length * 4, 4) >>> 0;
1253
+ for (let i = 0; i < array.length; i++) {
1254
+ const add = addToExternrefTable0(array[i]);
1255
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
1256
+ }
1257
+ WASM_VECTOR_LEN = array.length;
1258
+ return ptr;
1259
+ }
1260
+
902
1261
  function passStringToWasm0(arg, malloc, realloc) {
903
1262
  if (realloc === undefined) {
904
1263
  const buf = cachedTextEncoder.encode(arg);
Binary file
@@ -35,10 +35,29 @@ 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_serverUrl: (a: number) => [number, number];
53
+ export const namespaceclient_setAudience: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
54
+ export const namespaceclient_updateNamespaceMetadata: (a: number, b: number, c: number, d: any) => any;
38
55
  export const now_timestamp: () => [number, number];
39
56
  export const today_formatted: (a: number, b: number) => [number, number];
40
57
  export const init: () => void;
41
58
  export const diaryxbackend_isCrdtEnabled: (a: number) => number;
59
+ export const namespaceclient_new: (a: number, b: number, c: any) => number;
60
+ export const __wbg_namespaceclient_free: (a: number, b: number) => void;
42
61
  export const wasm_bindgen__convert__closures_____invoke__h7174ba9de949bff3: (a: number, b: number, c: any) => [number, number];
43
62
  export const wasm_bindgen__convert__closures_____invoke__h377ea917efd328e8: (a: number, b: number, c: any, d: any) => void;
44
63
  export const __wbindgen_malloc: (a: number, b: number) => number;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@diaryx/wasm-node",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for Diaryx core functionality",
5
- "version": "1.4.5-dev.5f8049f",
5
+ "version": "1.4.5-dev.beb1356",
6
6
  "license": "SEE LICENSE IN ../../LICENSE.md",
7
7
  "repository": {
8
8
  "type": "git",