@flamingo-stack/openframe-frontend-core 0.0.194 → 0.0.195-snapshot.20260519151313

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 (51) hide show
  1. package/dist/{chunk-PJ5KFD2V.js → chunk-4ML3NA2L.js} +75 -1
  2. package/dist/{chunk-PJ5KFD2V.js.map → chunk-4ML3NA2L.js.map} +1 -1
  3. package/dist/{chunk-C5VTN2SB.js → chunk-BXPH5SOL.js} +748 -359
  4. package/dist/chunk-BXPH5SOL.js.map +1 -0
  5. package/dist/{chunk-56JS47IQ.cjs → chunk-E6AWU7EI.cjs} +794 -405
  6. package/dist/chunk-E6AWU7EI.cjs.map +1 -0
  7. package/dist/{chunk-CVMSC7M4.cjs → chunk-OII2IERE.cjs} +77 -3
  8. package/dist/chunk-OII2IERE.cjs.map +1 -0
  9. package/dist/components/chat/hooks/index.d.ts +1 -0
  10. package/dist/components/chat/hooks/index.d.ts.map +1 -1
  11. package/dist/components/chat/hooks/use-jetstream-dialog-subscription.d.ts +15 -0
  12. package/dist/components/chat/hooks/use-jetstream-dialog-subscription.d.ts.map +1 -0
  13. package/dist/components/chat/types/api.types.d.ts +43 -0
  14. package/dist/components/chat/types/api.types.d.ts.map +1 -1
  15. package/dist/components/chat/types/network.types.d.ts +4 -0
  16. package/dist/components/chat/types/network.types.d.ts.map +1 -1
  17. package/dist/components/chat/utils/message-segment-accumulator.d.ts +16 -0
  18. package/dist/components/chat/utils/message-segment-accumulator.d.ts.map +1 -1
  19. package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
  20. package/dist/components/features/index.cjs +3 -3
  21. package/dist/components/features/index.js +2 -2
  22. package/dist/components/index.cjs +5 -3
  23. package/dist/components/index.cjs.map +1 -1
  24. package/dist/components/index.js +4 -2
  25. package/dist/components/navigation/index.cjs +3 -3
  26. package/dist/components/navigation/index.js +2 -2
  27. package/dist/components/ui/index.cjs +5 -3
  28. package/dist/components/ui/index.cjs.map +1 -1
  29. package/dist/components/ui/index.js +4 -2
  30. package/dist/hooks/index.cjs +2 -2
  31. package/dist/hooks/index.js +1 -1
  32. package/dist/index.cjs +5 -3
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.js +4 -2
  35. package/dist/nats/index.cjs +73 -0
  36. package/dist/nats/index.cjs.map +1 -1
  37. package/dist/nats/index.js +73 -0
  38. package/dist/nats/index.js.map +1 -1
  39. package/dist/nats/nats.d.ts +22 -1
  40. package/dist/nats/nats.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/components/chat/hooks/index.ts +1 -0
  43. package/src/components/chat/hooks/use-jetstream-dialog-subscription.ts +474 -0
  44. package/src/components/chat/types/api.types.ts +45 -0
  45. package/src/components/chat/types/network.types.ts +4 -0
  46. package/src/components/chat/utils/message-segment-accumulator.ts +28 -0
  47. package/src/components/chat/utils/process-historical-messages.ts +23 -5
  48. package/src/nats/nats.ts +117 -0
  49. package/dist/chunk-56JS47IQ.cjs.map +0 -1
  50. package/dist/chunk-C5VTN2SB.js.map +0 -1
  51. package/dist/chunk-CVMSC7M4.cjs.map +0 -1
@@ -2992,6 +2992,79 @@ function createNatsClient(options) {
2992
2992
  opts
2993
2993
  );
2994
2994
  }
2995
+ async function subscribeJetStreamOrdered(onMessage, opts) {
2996
+ const conn = requireConnection();
2997
+ if (opts.signal?.aborted) {
2998
+ return { unsubscribe() {
2999
+ } };
3000
+ }
3001
+ const nats = await importNats();
3002
+ if (opts.signal?.aborted) {
3003
+ return { unsubscribe() {
3004
+ } };
3005
+ }
3006
+ const inactiveThresholdNs = (opts.inactiveThresholdMs ?? 5 * 6e4) * 1e6;
3007
+ const js = conn.jetstream();
3008
+ const consumer = await js.consumers.get(opts.streamName, {
3009
+ filterSubjects: opts.filterSubject,
3010
+ deliver_policy: nats.DeliverPolicy.StartSequence,
3011
+ opt_start_seq: opts.optStartSeq ?? 0,
3012
+ inactive_threshold: inactiveThresholdNs
3013
+ });
3014
+ const iterRef = { current: null };
3015
+ let closed = false;
3016
+ const onAbort = () => {
3017
+ void teardown();
3018
+ };
3019
+ opts.signal?.addEventListener("abort", onAbort, { once: true });
3020
+ async function teardown() {
3021
+ if (closed) return;
3022
+ closed = true;
3023
+ opts.signal?.removeEventListener("abort", onAbort);
3024
+ const iter = iterRef.current;
3025
+ iterRef.current = null;
3026
+ if (iter) {
3027
+ try {
3028
+ await iter.close();
3029
+ } catch {
3030
+ }
3031
+ }
3032
+ }
3033
+ if (opts.signal?.aborted) {
3034
+ void teardown();
3035
+ return { unsubscribe() {
3036
+ } };
3037
+ }
3038
+ ;
3039
+ (async () => {
3040
+ try {
3041
+ const iter = await consumer.consume();
3042
+ if (closed) {
3043
+ try {
3044
+ await iter.close();
3045
+ } catch {
3046
+ }
3047
+ return;
3048
+ }
3049
+ iterRef.current = iter;
3050
+ for await (const msg of iter) {
3051
+ if (closed) break;
3052
+ try {
3053
+ await onMessage(msg);
3054
+ } catch (e) {
3055
+ emitStatus({ status: "error", data: e });
3056
+ }
3057
+ }
3058
+ } catch (e) {
3059
+ if (!closed) emitStatus({ status: "error", data: e });
3060
+ }
3061
+ })().catch((e) => emitStatus({ status: "error", data: e }));
3062
+ return {
3063
+ unsubscribe() {
3064
+ void teardown();
3065
+ }
3066
+ };
3067
+ }
2995
3068
  function onStatus(listener) {
2996
3069
  statusListeners.add(listener);
2997
3070
  return () => statusListeners.delete(listener);
@@ -3009,6 +3082,7 @@ function createNatsClient(options) {
3009
3082
  subscribeBytes,
3010
3083
  subscribeString,
3011
3084
  subscribeJson,
3085
+ subscribeJetStreamOrdered,
3012
3086
  onStatus
3013
3087
  };
3014
3088
  }
@@ -3194,4 +3268,4 @@ export {
3194
3268
  useNatsClient,
3195
3269
  useNearViewport
3196
3270
  };
3197
- //# sourceMappingURL=chunk-PJ5KFD2V.js.map
3271
+ //# sourceMappingURL=chunk-4ML3NA2L.js.map