@lunora/vue 1.0.0-alpha.7 → 1.0.0-alpha.71

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 (44) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +2 -0
  3. package/dist/index.d.mts +825 -188
  4. package/dist/index.d.ts +825 -188
  5. package/dist/index.mjs +1 -11
  6. package/dist/packem_shared/AuthLoading-CST_mkXL.mjs +1 -0
  7. package/dist/packem_shared/LUNORA_INJECTION_KEY-CswQb5zb.mjs +1 -0
  8. package/dist/packem_shared/hydratePreloaded-C-yIiam2.mjs +1 -0
  9. package/dist/packem_shared/is-browser-BEdfLJHK.mjs +1 -0
  10. package/dist/packem_shared/scope-dispose-Dn0gQ2SS.mjs +1 -0
  11. package/dist/packem_shared/stable-key-BSG0zK_E.mjs +1 -0
  12. package/dist/packem_shared/subscribeToQuery-Sz46o9Xt.mjs +1 -0
  13. package/dist/packem_shared/useAgent-CeAYhGZA.mjs +1 -0
  14. package/dist/packem_shared/useAgentChat-B5mq0x66.mjs +1 -0
  15. package/dist/packem_shared/useAgentState-Cs1VcKQj.mjs +1 -0
  16. package/dist/packem_shared/useAgentToolEvents-BhjZrNSJ.mjs +1 -0
  17. package/dist/packem_shared/useAuth-DwDFjvto.mjs +1 -0
  18. package/dist/packem_shared/useConnectionStatus-1brbiHgc.mjs +1 -0
  19. package/dist/packem_shared/useFlag-Bxoq8mH9.mjs +1 -0
  20. package/dist/packem_shared/useInfiniteQuery-CD_dnvES.mjs +1 -0
  21. package/dist/packem_shared/useMutation-MdgW9pRE.mjs +1 -0
  22. package/dist/packem_shared/useMutator-DRVDOhcj.mjs +1 -0
  23. package/dist/packem_shared/usePresence-D2d4BqBJ.mjs +1 -0
  24. package/dist/packem_shared/useRateLimit-z8EUFuYJ.mjs +1 -0
  25. package/dist/packem_shared/useStream-CYkKEcDf.mjs +1 -0
  26. package/dist/packem_shared/useSubscription-3X8pNJ6P.mjs +1 -0
  27. package/dist/packem_shared/useVoiceAgent-1gtd9RU3.mjs +1 -0
  28. package/dist/server.mjs +1 -1
  29. package/dist/upload.d.mts +2 -0
  30. package/dist/upload.d.ts +2 -0
  31. package/dist/upload.mjs +1 -0
  32. package/dist/worker.mjs +1 -1
  33. package/package.json +10 -4
  34. package/dist/packem_shared/AuthLoading-_6-uOycE.mjs +0 -29
  35. package/dist/packem_shared/LUNORA_INJECTION_KEY-DtFXLDQ_.mjs +0 -22
  36. package/dist/packem_shared/hydratePreloaded-rVY68iFv.mjs +0 -14
  37. package/dist/packem_shared/subscribeToQuery-Cv5YL-SI.mjs +0 -51
  38. package/dist/packem_shared/useAuth-C2aEzXXH.mjs +0 -28
  39. package/dist/packem_shared/useConnectionStatus-CDgduQYe.mjs +0 -20
  40. package/dist/packem_shared/useInfiniteQuery-CEfbw7Nw.mjs +0 -199
  41. package/dist/packem_shared/useMutation-DWubV5pv.mjs +0 -29
  42. package/dist/packem_shared/usePresence-BeN5xaZM.mjs +0 -59
  43. package/dist/packem_shared/useRateLimit-DlPWjcX1.mjs +0 -67
  44. package/dist/packem_shared/useSubscription-Ol0AZFUv.mjs +0 -47
@@ -1,59 +0,0 @@
1
- import { shallowRef, onScopeDispose } from 'vue';
2
- import { useLunora } from './LUNORA_INJECTION_KEY-DtFXLDQ_.mjs';
3
-
4
- const makeSessionId = () => {
5
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
6
- return crypto.randomUUID();
7
- }
8
- return `sess-${Math.random().toString(36).slice(2)}-${String(Date.now())}`;
9
- };
10
- const DEFAULT_INTERVAL_MS = 1e4;
11
- const usePresence = (roomId, options) => {
12
- const client = useLunora();
13
- const { heartbeat, intervalMs = DEFAULT_INTERVAL_MS, listPresent, shardKey } = options;
14
- const sessionId = options.sessionId ?? makeSessionId();
15
- const present = shallowRef(void 0);
16
- let latestData = options.data;
17
- const sendHeartbeat = () => {
18
- const args = {
19
- roomId,
20
- sessionId,
21
- ...latestData === void 0 ? {} : { data: latestData }
22
- };
23
- client.mutation(heartbeat, args, { shardKey }).catch(() => void 0);
24
- };
25
- const setData = (next) => {
26
- latestData = next;
27
- sendHeartbeat();
28
- };
29
- sendHeartbeat();
30
- const intervalHandle = setInterval(sendHeartbeat, intervalMs);
31
- const onVisible = () => {
32
- if (typeof document !== "undefined" && document.visibilityState === "visible") {
33
- sendHeartbeat();
34
- }
35
- };
36
- if (typeof document !== "undefined") {
37
- document.addEventListener("visibilitychange", onVisible);
38
- }
39
- const releaseConnectionContext = client.acquireConnectionContext({ roomId, sessionId }, { shardKey });
40
- const unsubscribe = client.subscribe(
41
- listPresent,
42
- { roomId },
43
- (value) => {
44
- present.value = value;
45
- },
46
- { shardKey }
47
- );
48
- onScopeDispose(() => {
49
- clearInterval(intervalHandle);
50
- if (typeof document !== "undefined") {
51
- document.removeEventListener("visibilitychange", onVisible);
52
- }
53
- releaseConnectionContext();
54
- unsubscribe();
55
- });
56
- return { present, sessionId, setData };
57
- };
58
-
59
- export { usePresence };
@@ -1,67 +0,0 @@
1
- import { evaluate } from '@lunora/ratelimit';
2
- import { shallowRef, toValue, watchEffect, onScopeDispose, computed } from 'vue';
3
-
4
- const useRateLimit = (config, options = {}) => {
5
- const now = options.now ?? Date.now;
6
- const tickMs = options.tickMs ?? 1e3;
7
- let value;
8
- const epoch = shallowRef(0);
9
- const bump = () => {
10
- epoch.value += 1;
11
- };
12
- const status = shallowRef(evaluate(toValue(config), value, { consume: false, count: 1, now: now(), reserve: false }).status);
13
- const stopStatusEffect = watchEffect(
14
- () => {
15
- status.value = evaluate(toValue(config), value, { consume: false, count: 1, now: now(), reserve: false }).status;
16
- },
17
- { flush: "sync" }
18
- );
19
- let intervalHandle;
20
- const stopInterval = () => {
21
- if (intervalHandle !== void 0) {
22
- clearInterval(intervalHandle);
23
- intervalHandle = void 0;
24
- }
25
- };
26
- const startIntervalIfThrottled = () => {
27
- if (status.value.ok || intervalHandle !== void 0) {
28
- return;
29
- }
30
- intervalHandle = setInterval(() => {
31
- bump();
32
- if (status.value.ok) {
33
- stopInterval();
34
- }
35
- }, tickMs);
36
- };
37
- onScopeDispose(() => {
38
- stopInterval();
39
- stopStatusEffect();
40
- });
41
- startIntervalIfThrottled();
42
- const consume = (count = 1) => {
43
- const result = evaluate(toValue(config), value, { consume: true, count, now: now(), reserve: false });
44
- if (result.value !== void 0) {
45
- value = result.value;
46
- }
47
- bump();
48
- startIntervalIfThrottled();
49
- return result.status;
50
- };
51
- const check = (count = 1) => evaluate(toValue(config), value, { consume: false, count, now: now(), reserve: false }).status.ok;
52
- const reset = () => {
53
- value = void 0;
54
- stopInterval();
55
- bump();
56
- };
57
- return {
58
- check,
59
- consume,
60
- disabled: computed(() => !status.value.ok),
61
- ok: computed(() => status.value.ok),
62
- reset,
63
- retryAfter: computed(() => status.value.retryAfter)
64
- };
65
- };
66
-
67
- export { useRateLimit };
@@ -1,47 +0,0 @@
1
- import { createQuerySubscription } from '@lunora/client/query';
2
- import { ref, watch, toValue, onScopeDispose } from 'vue';
3
- import { useLunora } from './LUNORA_INJECTION_KEY-DtFXLDQ_.mjs';
4
-
5
- const useSubscription = (function_, args, options = {}) => {
6
- const client = useLunora();
7
- const data = ref(void 0);
8
- const error = ref(void 0);
9
- watch(
10
- () => toValue(args),
11
- (currentArgs, _previous, onCleanup) => {
12
- if (currentArgs === "skip") {
13
- data.value = void 0;
14
- error.value = void 0;
15
- return;
16
- }
17
- const unsubscribe = createQuerySubscription(
18
- client,
19
- function_,
20
- currentArgs,
21
- {
22
- onData: (value) => {
23
- data.value = value;
24
- error.value = void 0;
25
- },
26
- onError: (subscriptionError) => {
27
- error.value = new Error(subscriptionError.message);
28
- data.value = void 0;
29
- },
30
- onReset: () => {
31
- data.value = void 0;
32
- }
33
- },
34
- { shardKey: options.shardKey }
35
- );
36
- onCleanup(unsubscribe);
37
- },
38
- { immediate: true }
39
- );
40
- onScopeDispose(() => {
41
- data.value = void 0;
42
- error.value = void 0;
43
- });
44
- return { data, error };
45
- };
46
-
47
- export { useSubscription };