@palbase/web 3.0.0 → 4.0.1

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 (45) hide show
  1. package/dist/_mls-wasm.cjs +32 -0
  2. package/dist/_mls-wasm.cjs.map +1 -0
  3. package/dist/_mls-wasm.js +11 -0
  4. package/dist/_mls-wasm.js.map +1 -0
  5. package/dist/{analytics-facade-BOxQ8IP2.d.cts → analytics-facade-DwOtlXPP.d.cts} +5 -87
  6. package/dist/{analytics-facade-yfMJ69vw.d.ts → analytics-facade-Nk6J9Ncm.d.ts} +5 -87
  7. package/dist/{chunk-S7NAY3MW.js → chunk-NXEPAEF5.js} +1 -8
  8. package/dist/{chunk-S7NAY3MW.js.map → chunk-NXEPAEF5.js.map} +1 -1
  9. package/dist/chunk-PZ5AY32C.js +10 -0
  10. package/dist/chunk-PZ5AY32C.js.map +1 -0
  11. package/dist/{chunk-3HVTEZ7N.js → chunk-TGDS6VMT.js} +51 -36
  12. package/dist/chunk-TGDS6VMT.js.map +1 -0
  13. package/dist/gen/cli.js +2 -1
  14. package/dist/gen/cli.js.map +1 -1
  15. package/dist/index.cjs +59 -37
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +3 -4
  18. package/dist/index.d.ts +3 -4
  19. package/dist/index.js +3 -2
  20. package/dist/internal.cjs +56 -34
  21. package/dist/internal.cjs.map +1 -1
  22. package/dist/internal.d.cts +4 -16
  23. package/dist/internal.d.ts +4 -16
  24. package/dist/internal.js +3 -2
  25. package/dist/next/client.cjs +56 -34
  26. package/dist/next/client.cjs.map +1 -1
  27. package/dist/next/client.js +3 -2
  28. package/dist/next/client.js.map +1 -1
  29. package/dist/next/index.cjs +46 -34
  30. package/dist/next/index.cjs.map +1 -1
  31. package/dist/next/index.d.cts +2 -3
  32. package/dist/next/index.d.ts +2 -3
  33. package/dist/next/index.js +3 -2
  34. package/dist/next/index.js.map +1 -1
  35. package/dist/{pb-B3h3NIPE.d.cts → pb-C9v5dEO6.d.cts} +1 -1
  36. package/dist/{pb-QRISxPd1.d.ts → pb-FG_nV7NR.d.ts} +1 -1
  37. package/dist/react/index.cjs +1 -1
  38. package/dist/react/index.cjs.map +1 -1
  39. package/dist/react/index.d.cts +1 -2
  40. package/dist/react/index.d.ts +1 -2
  41. package/dist/react/index.js +3 -2
  42. package/dist/react/index.js.map +1 -1
  43. package/package.json +9 -2
  44. package/dist/chunk-3HVTEZ7N.js.map +0 -1
  45. package/dist/pkg/palbe_mls_bg.wasm +0 -0
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,11 +17,19 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
31
+ var src_exports = {};
32
+ __export(src_exports, {
23
33
  BackendError: () => BackendError,
24
34
  PalbeAnalytics: () => PalbeAnalytics,
25
35
  PalbeAuth: () => PalbeAuth,
@@ -35,7 +45,7 @@ __export(index_exports, {
35
45
  memorySessionStorage: () => memorySessionStorage,
36
46
  pb: () => pb
37
47
  });
38
- module.exports = __toCommonJS(index_exports);
48
+ module.exports = __toCommonJS(src_exports);
39
49
 
40
50
  // ../core/dist/index.js
41
51
  var CACHE_TTL_MS = 5 * 60 * 1e3;
@@ -765,19 +775,29 @@ var PalbeAuth = class {
765
775
 
766
776
  // src/calls/facade.ts
767
777
  var import_livekit_client = require("livekit-client");
768
- var Call = class {
778
+ var Call = class _Call {
769
779
  id;
770
780
  _state = "connecting";
771
781
  _participants = /* @__PURE__ */ new Map();
772
782
  _listeners = /* @__PURE__ */ new Set();
773
783
  _room;
774
784
  _keyProvider;
775
- /** @internal obtain via PalbeCalls.start() / .accept() */
785
+ // PRIVATE constructor + `@internal` factory: the media-engine types (`Room`,
786
+ // `ExternalE2EEKeyProvider`) appear ONLY on a private constructor and an
787
+ // `@internal` static factory, both of which `stripInternal` (set in this
788
+ // package's tsconfig) removes from the emitted public `.d.ts`. So no engine type
789
+ // ever reaches the public API surface — the same "no engine type in the public
790
+ // interface" contract the iOS SDK enforces. Consumers obtain a `Call` only
791
+ // through `pb.calls.start()` / `.accept()`.
776
792
  constructor(callId, room, keyProvider) {
777
793
  this.id = callId;
778
794
  this._room = room;
779
795
  this._keyProvider = keyProvider;
780
- this._wireRoomEvents();
796
+ this._wireMediaEvents();
797
+ }
798
+ /** @internal — facade-only factory; stripped from the public `.d.ts`. */
799
+ static _create(callId, room, keyProvider) {
800
+ return new _Call(callId, room, keyProvider);
781
801
  }
782
802
  // ─── State ──────────────────────────────────────────────────────────────
783
803
  get state() {
@@ -787,9 +807,9 @@ var Call = class {
787
807
  get participants() {
788
808
  return Array.from(this._participants.values());
789
809
  }
790
- get localParticipant() {
791
- return this._room.localParticipant;
792
- }
810
+ // (No `localParticipant` accessor: it would return a raw media-engine participant
811
+ // object and leak the engine type onto the public API. Local mic/camera control is
812
+ // exposed engine-agnostically via `mute()` / `setCamera()` below.)
793
813
  // ─── Subscribe ──────────────────────────────────────────────────────────
794
814
  /**
795
815
  * Subscribe to call changes (state + participant updates).
@@ -813,7 +833,7 @@ var Call = class {
813
833
  /**
814
834
  * Set a raw frame encryption key (ArrayBuffer) for this call.
815
835
  * Design seam for SP-1.x web-MLS: call this with the MLS exporter secret
816
- * to enable frame-level E2EE via ExternalE2EEKeyProvider.
836
+ * to enable frame-level E2EE via the media engine's external key provider.
817
837
  *
818
838
  * NOTE: The room must have been opened with `e2ee` options for this to take
819
839
  * effect. Currently calls connect WITHOUT e2ee — see module docstring.
@@ -823,7 +843,7 @@ var Call = class {
823
843
  async setMediaKey(key) {
824
844
  await this._keyProvider.setKey(key);
825
845
  }
826
- /** Leave the call and disconnect from the LiveKit room. */
846
+ /** Leave the call and disconnect from the media room. */
827
847
  async leave() {
828
848
  await this._room.disconnect();
829
849
  this._setState("ended");
@@ -865,7 +885,7 @@ var Call = class {
865
885
  }
866
886
  this._emit();
867
887
  }
868
- _wireRoomEvents() {
888
+ _wireMediaEvents() {
869
889
  this._room.on(import_livekit_client.RoomEvent.Connected, () => {
870
890
  this._setState("active");
871
891
  }).on(
@@ -906,9 +926,9 @@ var PalbeCalls = class {
906
926
  *
907
927
  * @param groupId - Messaging group display-id (`grp_<uuidv7>`)
908
928
  * @param media - Which media tracks to publish (default: audio + video)
909
- * @returns A `Call` in `connecting` state; transitions to `active` once LiveKit connects.
929
+ * @returns A `Call` in `connecting` state; transitions to `active` once the media room connects.
910
930
  *
911
- * @throws BackendError('network', { code: 'call_service_unavailable' }) if LiveKit SFU is down (503)
931
+ * @throws BackendError('network', { code: 'call_service_unavailable' }) if the SFU is down (503)
912
932
  * @throws BackendError('forbidden', { code: 'not_group_member' }) if the caller is not a member (403)
913
933
  * @throws BackendError('conflict', { code: 'call_room_full' }) if the room is full (409)
914
934
  */
@@ -965,7 +985,7 @@ var PalbeCalls = class {
965
985
  adaptiveStream: true,
966
986
  dynacast: true
967
987
  });
968
- const call = new Call(callId, room, keyProvider);
988
+ const call = Call._create(callId, room, keyProvider);
969
989
  await room.connect(edgeUrl, token);
970
990
  if (media.includes("audio")) {
971
991
  await room.localParticipant.setMicrophoneEnabled(true);
@@ -5448,31 +5468,29 @@ function date_now() {
5448
5468
  }
5449
5469
 
5450
5470
  // src/messaging/wasm/loader.ts
5451
- var import_meta = {};
5452
5471
  var GLUE_MODULE = "./palbe_mls_bg.js";
5453
5472
  var SNIPPET_MODULE = "./snippets/mls-rs-core-f99cdecbb456b09c/inline0.js";
5454
5473
  var inflight = null;
5455
5474
  var ready = null;
5456
- async function loadWasmModule() {
5457
- const wasmUrl = new URL("./pkg/palbe_mls_bg.wasm", import_meta.url);
5458
- if (wasmUrl.protocol === "file:") {
5459
- const fsSpecifier = ["node", "fs/promises"].join(":");
5460
- const { readFile } = await import(
5461
- /* webpackIgnore: true */
5462
- fsSpecifier
5463
- );
5464
- const bytes = await readFile(wasmUrl);
5465
- return WebAssembly.compile(bytes);
5475
+ function decodeBase64(encoded) {
5476
+ if (typeof encoded !== "string" || encoded.length === 0 || typeof globalThis.atob !== "function") {
5477
+ throw new Error("palbe-mls WASM asset is invalid");
5466
5478
  }
5467
- const response = await fetch(wasmUrl);
5468
- if (typeof WebAssembly.compileStreaming === "function") {
5469
- try {
5470
- return await WebAssembly.compileStreaming(Promise.resolve(response));
5471
- } catch {
5472
- }
5479
+ let binary;
5480
+ try {
5481
+ binary = globalThis.atob(encoded);
5482
+ } catch {
5483
+ throw new Error("palbe-mls WASM asset is invalid");
5484
+ }
5485
+ const bytes = new Uint8Array(binary.length);
5486
+ for (let index = 0; index < binary.length; index += 1) {
5487
+ bytes[index] = binary.charCodeAt(index);
5473
5488
  }
5474
- const buffer = await response.arrayBuffer();
5475
- return WebAssembly.compile(buffer);
5489
+ return bytes.buffer;
5490
+ }
5491
+ async function loadWasmModule() {
5492
+ const asset = await import("#palbase-mls-wasm");
5493
+ return WebAssembly.compile(decodeBase64(asset.default));
5476
5494
  }
5477
5495
  function buildImports() {
5478
5496
  return {
@@ -5483,7 +5501,7 @@ function buildImports() {
5483
5501
  function initMls() {
5484
5502
  if (ready) return Promise.resolve(ready);
5485
5503
  if (inflight) return inflight;
5486
- inflight = (async () => {
5504
+ const attempt = (async () => {
5487
5505
  const module2 = await loadWasmModule();
5488
5506
  const instance = await WebAssembly.instantiate(module2, buildImports());
5489
5507
  const setWasm = __wbg_set_wasm;
@@ -5502,7 +5520,11 @@ function initMls() {
5502
5520
  ready = g;
5503
5521
  return g;
5504
5522
  })();
5505
- return inflight;
5523
+ inflight = attempt;
5524
+ void attempt.catch(() => {
5525
+ if (inflight === attempt) inflight = null;
5526
+ });
5527
+ return attempt;
5506
5528
  }
5507
5529
  function requireMls() {
5508
5530
  if (!ready) {
@@ -7611,7 +7633,7 @@ function localStorageSessionStorage(key = DEFAULT_KEY) {
7611
7633
  }
7612
7634
 
7613
7635
  // src/version.ts
7614
- var VERSION = "3.0.0";
7636
+ var VERSION = "4.0.1";
7615
7637
 
7616
7638
  // src/internal.ts
7617
7639
  function getRuntime() {