@lunora/svelte 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 (42) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +2 -0
  3. package/dist/index.d.mts +897 -168
  4. package/dist/index.d.ts +897 -168
  5. package/dist/index.mjs +1 -10
  6. package/dist/packem_shared/agent-CddTbgxO.mjs +1 -0
  7. package/dist/packem_shared/agentChat-BmvA3u8B.mjs +1 -0
  8. package/dist/packem_shared/agentState-fc7KRCp9.mjs +1 -0
  9. package/dist/packem_shared/agentToolEvents-sOUvSZsy.mjs +1 -0
  10. package/dist/packem_shared/auth-BWCPnv0n.mjs +1 -0
  11. package/dist/packem_shared/connectionStatus-BHVAskxU.mjs +1 -0
  12. package/dist/packem_shared/flag-5trRaaSv.mjs +1 -0
  13. package/dist/packem_shared/getLunoraClient-DU7BmZy1.mjs +1 -0
  14. package/dist/packem_shared/hydratePreloaded-Bbm6vwbA.mjs +1 -0
  15. package/dist/packem_shared/infiniteQuery-s_5r8MQZ.mjs +1 -0
  16. package/dist/packem_shared/is-browser-BEdfLJHK.mjs +1 -0
  17. package/dist/packem_shared/is-function-reference-ByqJF30w.mjs +1 -0
  18. package/dist/packem_shared/mutation-fa0Bj5Bo.mjs +1 -0
  19. package/dist/packem_shared/mutator-cvH3UrNm.mjs +1 -0
  20. package/dist/packem_shared/presence-C2YC1KOc.mjs +1 -0
  21. package/dist/packem_shared/query-BEQBdOJ2.mjs +1 -0
  22. package/dist/packem_shared/rateLimit-DtykU7F_.mjs +1 -0
  23. package/dist/packem_shared/stream-DItOnXt6.mjs +1 -0
  24. package/dist/packem_shared/subscription-Dbz9sy8N.mjs +1 -0
  25. package/dist/packem_shared/voiceAgent-CPQvbrxT.mjs +1 -0
  26. package/dist/server.mjs +1 -1
  27. package/dist/upload.d.mts +2 -0
  28. package/dist/upload.d.ts +2 -0
  29. package/dist/upload.mjs +1 -0
  30. package/dist/worker.mjs +1 -1
  31. package/package.json +10 -4
  32. package/dist/packem_shared/auth-DLPf_bK9.mjs +0 -28
  33. package/dist/packem_shared/connectionStatus-CRsOMeYl.mjs +0 -14
  34. package/dist/packem_shared/getLunoraClient--bwSz7F6.mjs +0 -16
  35. package/dist/packem_shared/hydratePreloaded-D5rUJdXy.mjs +0 -21
  36. package/dist/packem_shared/infiniteQuery-jPMQw8Vz.mjs +0 -196
  37. package/dist/packem_shared/is-function-reference-ycLAcI79.mjs +0 -3
  38. package/dist/packem_shared/mutation-CnDkAaLH.mjs +0 -31
  39. package/dist/packem_shared/presence-BQWixJ2T.mjs +0 -66
  40. package/dist/packem_shared/query-D8Pct9Qe.mjs +0 -36
  41. package/dist/packem_shared/rateLimit-Cdw1kp8t.mjs +0 -66
  42. package/dist/packem_shared/subscription-twuBT_Wb.mjs +0 -46
@@ -1,66 +0,0 @@
1
- import { evaluate } from '@lunora/ratelimit';
2
- import { writable, derived } from 'svelte/store';
3
-
4
- const rateLimit = (config, options = {}) => {
5
- const now = options.now ?? Date.now;
6
- const tickMs = options.tickMs ?? 1e3;
7
- let value;
8
- const epoch = writable(0);
9
- const bump = () => {
10
- epoch.update((n) => n + 1);
11
- };
12
- const status = derived(epoch, () => evaluate(config, value, { consume: false, count: 1, now: now(), reserve: false }).status);
13
- let intervalHandle;
14
- const stopInterval = () => {
15
- if (intervalHandle !== void 0) {
16
- clearInterval(intervalHandle);
17
- intervalHandle = void 0;
18
- }
19
- };
20
- let latestOk = true;
21
- const unsubStatus = status.subscribe((s) => {
22
- latestOk = s.ok;
23
- });
24
- const startIntervalIfThrottled = () => {
25
- if (latestOk || intervalHandle !== void 0) {
26
- return;
27
- }
28
- intervalHandle = setInterval(() => {
29
- bump();
30
- if (latestOk) {
31
- stopInterval();
32
- }
33
- }, tickMs);
34
- };
35
- startIntervalIfThrottled();
36
- const consume = (count = 1) => {
37
- const result = evaluate(config, value, { consume: true, count, now: now(), reserve: false });
38
- if (result.value !== void 0) {
39
- value = result.value;
40
- }
41
- bump();
42
- startIntervalIfThrottled();
43
- return result.status;
44
- };
45
- const check = (count = 1) => evaluate(config, value, { consume: false, count, now: now(), reserve: false }).status.ok;
46
- const reset = () => {
47
- value = void 0;
48
- stopInterval();
49
- bump();
50
- };
51
- const teardown = () => {
52
- stopInterval();
53
- unsubStatus();
54
- };
55
- return {
56
- check,
57
- consume,
58
- disabled: derived(status, (s) => !s.ok),
59
- ok: derived(status, (s) => s.ok),
60
- reset,
61
- retryAfter: derived(status, (s) => s.retryAfter),
62
- teardown
63
- };
64
- };
65
-
66
- export { rateLimit };
@@ -1,46 +0,0 @@
1
- import { createQuerySubscription } from '@lunora/client/query';
2
- import { writable, readable } from 'svelte/store';
3
- import { getLunoraClient } from './getLunoraClient--bwSz7F6.mjs';
4
- import { i as isFunctionReference } from './is-function-reference-ycLAcI79.mjs';
5
-
6
- function subscription(clientOrFunction, functionOrArgs, argsOrOptions, maybeOptions) {
7
- const hasExplicitClient = !isFunctionReference(clientOrFunction);
8
- const client = hasExplicitClient ? clientOrFunction : getLunoraClient();
9
- const functionRef = hasExplicitClient ? functionOrArgs : clientOrFunction;
10
- const args = hasExplicitClient ? argsOrOptions : functionOrArgs;
11
- const options = (hasExplicitClient ? maybeOptions : argsOrOptions) ?? {};
12
- const { shardKey, onError } = options;
13
- const errorStore = writable();
14
- const data = readable(void 0, (set) => {
15
- if (args === "skip") {
16
- return () => void 0;
17
- }
18
- const unsubscribe = createQuerySubscription(
19
- client,
20
- functionRef,
21
- args,
22
- {
23
- onData: (value) => {
24
- set(value);
25
- errorStore.set(void 0);
26
- },
27
- onError: (subscriptionError) => {
28
- const error = new Error(subscriptionError.message);
29
- errorStore.set(error);
30
- onError?.(error);
31
- },
32
- onReset: () => {
33
- set(void 0);
34
- }
35
- },
36
- { shardKey }
37
- );
38
- return () => {
39
- unsubscribe();
40
- errorStore.set(void 0);
41
- };
42
- });
43
- return { data, error: { subscribe: errorStore.subscribe } };
44
- }
45
-
46
- export { subscription };