@vinaverse/client 0.1.0-alpha.7 → 0.1.0-alpha.9

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 (41) hide show
  1. package/README.md +3 -1
  2. package/dist/agent/index.cjs +24 -5
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +3 -3
  5. package/dist/agent/index.d.ts +3 -3
  6. package/dist/agent/index.js +1 -1
  7. package/dist/backend/index.cjs.map +1 -1
  8. package/dist/backend/index.d.cts +3 -3
  9. package/dist/backend/index.d.ts +3 -3
  10. package/dist/backend/index.js +1 -1
  11. package/dist/{chunk-3BLRAWNC.js → chunk-O3NLAZGZ.js} +26 -7
  12. package/dist/chunk-O3NLAZGZ.js.map +1 -0
  13. package/dist/chunk-YNUHXJD6.js +9 -0
  14. package/dist/{chunk-VSJDVLCP.js.map → chunk-YNUHXJD6.js.map} +1 -1
  15. package/dist/contract-DmQs8amJ.d.cts +6 -0
  16. package/dist/contract-DmQs8amJ.d.ts +6 -0
  17. package/dist/conversation/index.cjs +2 -2
  18. package/dist/conversation/index.cjs.map +1 -1
  19. package/dist/conversation/index.d.cts +5 -5
  20. package/dist/conversation/index.d.ts +5 -5
  21. package/dist/conversation/index.js +1 -1
  22. package/dist/index.cjs +2 -2
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +1 -1
  27. package/dist/{runtime-CZ1hLvAl.d.ts → runtime-CISPp9nJ.d.cts} +24 -4
  28. package/dist/{runtime-C3ZknHdG.d.cts → runtime-Z1RI10lU.d.ts} +24 -4
  29. package/dist/{session-8W3fRNeb.d.cts → session-CPz4pcPu.d.cts} +246 -7
  30. package/dist/{session-8W3fRNeb.d.ts → session-CPz4pcPu.d.ts} +246 -7
  31. package/dist/{store-7WU1kD9W.d.cts → store-BxiicOKG.d.cts} +1 -1
  32. package/dist/{store-DrXSPHu6.d.ts → store-DZka9T2-.d.ts} +1 -1
  33. package/dist/testing/index.cjs.map +1 -1
  34. package/dist/testing/index.d.cts +3 -3
  35. package/dist/testing/index.d.ts +3 -3
  36. package/dist/testing/index.js +1 -1
  37. package/package.json +22 -2
  38. package/dist/chunk-3BLRAWNC.js.map +0 -1
  39. package/dist/chunk-VSJDVLCP.js +0 -9
  40. package/dist/contract-_NMdPjgN.d.cts +0 -6
  41. package/dist/contract-_NMdPjgN.d.ts +0 -6
package/README.md CHANGED
@@ -128,7 +128,9 @@ History's "Continue" is `continue(key, conversationId)`: the key goes on with th
128
128
  is said as `ended` (your backend throws `AgentRefusal('ended', { code })` on a 404 or 410). A session must have an id
129
129
  and a secret, and `wss://` and `https://` addresses whatever transport you supply (a wrapper adding headers or logging
130
130
  still gets only secure ones). `insecureAddresses: { realtime, turns }` allows plaintext for one leg: dangerous, for mocks
131
- and local development only, and the runtime warns outside `__DEV__` (through `onWarning`, your logger, else `console.warn`).
131
+ and local development only, and the runtime warns outside `__DEV__` (through `onWarning(message, { code })`, your
132
+ logger, else `console.warn`; `code` is `insecure_addresses`, `callback_threw` with the `callback` that threw, or
133
+ `events_dropped`).
132
134
  A UI binding reads the key's conversation with `peek(key)`, which ends nothing (a render must not): one past its
133
135
  session's end is ended when it is next shown, and `subscribe` then tells the binding to read the next one. One no view
134
136
  shows ends at its session's end while the app's timers run, and on `sweep()` (the React Native parts call it when the
@@ -2594,7 +2594,8 @@ function warnInsecure(insecure, warn) {
2594
2594
  if (!(insecure.realtime || insecure.turns)) return;
2595
2595
  if (globalThis.__DEV__ === true) return;
2596
2596
  warn(
2597
- "@vinaverse/client/agent: insecureAddresses lets sessions use plaintext ws:// or http:// addresses. For mocks and local development only."
2597
+ "@vinaverse/client/agent: insecureAddresses lets sessions use plaintext ws:// or http:// addresses. For mocks and local development only.",
2598
+ { code: "insecure_addresses" }
2598
2599
  );
2599
2600
  }
2600
2601
  var OPEN_KEPT_MS = 24 * 36e5;
@@ -2615,6 +2616,16 @@ function createAgentRuntime(options) {
2615
2616
  const listeners = /* @__PURE__ */ new Set();
2616
2617
  let status = null;
2617
2618
  let reading = null;
2619
+ const NO_STATUS = {
2620
+ status: null,
2621
+ reading: false,
2622
+ failed: false
2623
+ };
2624
+ let statusState = NO_STATUS;
2625
+ const setStatusState = (next) => {
2626
+ statusState = { status: status?.value ?? null, ...next };
2627
+ changed();
2628
+ };
2618
2629
  let sessionName = null;
2619
2630
  let generation = 0;
2620
2631
  const keyOf = (key) => agentKey(key, options.agent ?? null);
@@ -2635,7 +2646,8 @@ function createAgentRuntime(options) {
2635
2646
  call();
2636
2647
  } catch (error) {
2637
2648
  warn(
2638
- `@vinaverse/client/agent: the app's ${what} threw (${error instanceof Error ? error.message : String(error)}); the conversation went on.`
2649
+ `@vinaverse/client/agent: the app's ${what} threw (${error instanceof Error ? error.message : String(error)}); the conversation went on.`,
2650
+ { code: "callback_threw", callback: what }
2639
2651
  );
2640
2652
  }
2641
2653
  };
@@ -2678,7 +2690,8 @@ function createAgentRuntime(options) {
2678
2690
  waiting.shift();
2679
2691
  if (!dropping)
2680
2692
  warn(
2681
- "@vinaverse/client/agent: the analytics salt is still being read from storage; the oldest events are dropped."
2693
+ "@vinaverse/client/agent: the analytics salt is still being read from storage; the oldest events are dropped.",
2694
+ { code: "events_dropped" }
2682
2695
  );
2683
2696
  dropping = true;
2684
2697
  }
@@ -2792,6 +2805,7 @@ function createAgentRuntime(options) {
2792
2805
  sessionName = null;
2793
2806
  status = null;
2794
2807
  reading = null;
2808
+ statusState = NO_STATUS;
2795
2809
  changed();
2796
2810
  const pairs = [];
2797
2811
  await Promise.all([
@@ -3095,18 +3109,23 @@ function createAgentRuntime(options) {
3095
3109
  if (asked !== generation) return value;
3096
3110
  reading = null;
3097
3111
  status = { value, at: clock.now() };
3098
- changed();
3112
+ setStatusState({ reading: false, failed: false });
3099
3113
  return value;
3100
3114
  },
3101
3115
  (error) => {
3102
- if (asked === generation) reading = null;
3116
+ if (asked === generation) {
3117
+ reading = null;
3118
+ setStatusState({ reading: false, failed: true });
3119
+ }
3103
3120
  throw error;
3104
3121
  }
3105
3122
  );
3106
3123
  reading = read;
3124
+ setStatusState({ reading: true, failed: statusState.failed });
3107
3125
  return read;
3108
3126
  },
3109
3127
  getStatus: () => status?.value ?? null,
3128
+ getStatusState: () => statusState,
3110
3129
  getName: () => sessionName ?? status?.value.displayName ?? null,
3111
3130
  subscribe(listener) {
3112
3131
  listeners.add(listener);