@lunora/solid 1.0.0-alpha.23 → 1.0.0-alpha.230

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/README.md +25 -17
  2. package/dist/index.d.mts +1039 -236
  3. package/dist/index.d.ts +1039 -236
  4. package/dist/index.mjs +1 -13
  5. package/dist/packem_shared/AuthLoading-DjUnIaP5.mjs +1 -0
  6. package/dist/packem_shared/LunoraContext-BWsj_3CK.mjs +1 -0
  7. package/dist/packem_shared/LunoraProvider-DMhpuxvx.mjs +1 -0
  8. package/dist/packem_shared/createAction-BZkayM2R.mjs +1 -0
  9. package/dist/packem_shared/createAgent-BN_C_ztD.mjs +1 -0
  10. package/dist/packem_shared/createAgentChat-BWtnorVh.mjs +1 -0
  11. package/dist/packem_shared/createAgentState-Cl09r0tX.mjs +1 -0
  12. package/dist/packem_shared/createAgentToolEvents-on8XD92W.mjs +1 -0
  13. package/dist/packem_shared/createConnectionStatus-D8bC05Jn.mjs +1 -0
  14. package/dist/packem_shared/createFlag-Bww9WQUu.mjs +1 -0
  15. package/dist/packem_shared/createInfiniteQuery-CwGPFeuc.mjs +1 -0
  16. package/dist/packem_shared/createMutation-DM2mXpq3.mjs +1 -0
  17. package/dist/packem_shared/createMutator-q9cMjGKv.mjs +1 -0
  18. package/dist/packem_shared/createPresence-DkTotieP.mjs +1 -0
  19. package/dist/packem_shared/createQuery-oNQqVGjE.mjs +1 -0
  20. package/dist/packem_shared/createRateLimit-CIVWrD5H.mjs +1 -0
  21. package/dist/packem_shared/createStream-CCAOb9q1.mjs +1 -0
  22. package/dist/packem_shared/createSubscription-DiyhxkoK.mjs +1 -0
  23. package/dist/packem_shared/createVoiceAgent-BtRfW4lS.mjs +1 -0
  24. package/dist/packem_shared/hydratePreloaded-DCi296oW.mjs +1 -0
  25. package/dist/packem_shared/reactive-args-qKMBsFpd.mjs +1 -0
  26. package/dist/packem_shared/solid-compat-ByG5HD_F.mjs +1 -0
  27. package/dist/server.mjs +1 -1
  28. package/dist/upload.d.mts +2 -0
  29. package/dist/upload.d.ts +2 -0
  30. package/dist/upload.mjs +1 -0
  31. package/package.json +11 -5
  32. package/dist/packem_shared/AuthLoading-u5QJoV-J.mjs +0 -73
  33. package/dist/packem_shared/LunoraContext-C59PzHhN.mjs +0 -13
  34. package/dist/packem_shared/LunoraProvider-CzB3zGhy.mjs +0 -17
  35. package/dist/packem_shared/createConnectionStatus-1poqwqR9.mjs +0 -14
  36. package/dist/packem_shared/createFlag-Bu9YfzcJ.mjs +0 -78
  37. package/dist/packem_shared/createInfiniteQuery-Dy9k7Px2.mjs +0 -216
  38. package/dist/packem_shared/createMutation-LkrbhItI.mjs +0 -36
  39. package/dist/packem_shared/createMutator-foSnPJPt.mjs +0 -24
  40. package/dist/packem_shared/createPresence-DM2cVkiG.mjs +0 -85
  41. package/dist/packem_shared/createQuery-BUldvZXj.mjs +0 -28
  42. package/dist/packem_shared/createRateLimit-BA2f8XyF.mjs +0 -76
  43. package/dist/packem_shared/createSubscription-D3HbChGe.mjs +0 -41
  44. package/dist/packem_shared/hydratePreloaded-CWny5-2J.mjs +0 -25
  45. package/dist/packem_shared/stable-key-CGp4e2Ux.mjs +0 -38
@@ -1,24 +0,0 @@
1
- import { createMutatorRunner } from '@lunora/client';
2
- import { createSignal } from 'solid-js';
3
-
4
- const createMutator = (handle) => {
5
- const [error, setError] = createSignal(void 0);
6
- const [pending, setPending] = createSignal(false);
7
- const {
8
- mutate,
9
- reset
10
- } = createMutatorRunner(handle, {
11
- setError,
12
- setPending
13
- });
14
- const isError = () => error() !== void 0;
15
- return {
16
- error,
17
- isError,
18
- mutate,
19
- pending,
20
- reset
21
- };
22
- };
23
-
24
- export { createMutator };
@@ -1,85 +0,0 @@
1
- import { createSignal, onMount, onCleanup } from 'solid-js';
2
- import { useLunora } from './LunoraContext-C59PzHhN.mjs';
3
-
4
- const randomSessionId = (prefix = "sess") => {
5
- if (typeof crypto !== "undefined") {
6
- if (typeof crypto.randomUUID === "function") {
7
- return crypto.randomUUID();
8
- }
9
- if (typeof crypto.getRandomValues === "function") {
10
- const bytes = crypto.getRandomValues(new Uint8Array(16));
11
- return `${prefix}-${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
12
- }
13
- }
14
- return `${prefix}-${Date.now().toString(36)}`;
15
- };
16
-
17
- const DEFAULT_INTERVAL_MS = 1e4;
18
- const createPresence = (roomId, options) => {
19
- const client = useLunora();
20
- const {
21
- heartbeat,
22
- intervalMs = DEFAULT_INTERVAL_MS,
23
- listPresent,
24
- shardKey
25
- } = options;
26
- const sessionId = options.sessionId ?? randomSessionId();
27
- const [present, setPresent] = createSignal(void 0);
28
- let latestData = options.data;
29
- const sendHeartbeat = () => {
30
- const args = {
31
- roomId,
32
- sessionId,
33
- ...latestData === void 0 ? {} : {
34
- data: latestData
35
- }
36
- };
37
- client.mutation(heartbeat, args, {
38
- shardKey
39
- }).catch(() => void 0);
40
- };
41
- const setData = (next) => {
42
- latestData = next;
43
- sendHeartbeat();
44
- };
45
- onMount(() => {
46
- sendHeartbeat();
47
- const intervalHandle = setInterval(sendHeartbeat, intervalMs);
48
- const onVisible = () => {
49
- if (typeof document !== "undefined" && document.visibilityState === "visible") {
50
- sendHeartbeat();
51
- }
52
- };
53
- if (typeof document !== "undefined") {
54
- document.addEventListener("visibilitychange", onVisible);
55
- }
56
- const releaseConnectionContext = client.acquireConnectionContext({
57
- roomId,
58
- sessionId
59
- }, {
60
- shardKey
61
- });
62
- const unsubscribe = client.subscribe(listPresent, {
63
- roomId
64
- }, (value) => {
65
- setPresent(() => value);
66
- }, {
67
- shardKey
68
- });
69
- onCleanup(() => {
70
- clearInterval(intervalHandle);
71
- if (typeof document !== "undefined") {
72
- document.removeEventListener("visibilitychange", onVisible);
73
- }
74
- releaseConnectionContext();
75
- unsubscribe();
76
- });
77
- });
78
- return {
79
- present,
80
- sessionId,
81
- setData
82
- };
83
- };
84
-
85
- export { createPresence };
@@ -1,28 +0,0 @@
1
- import { createQuerySubscription } from '@lunora/client/query';
2
- import { createSignal, createEffect, on, onCleanup } from 'solid-js';
3
- import { useLunora } from './LunoraContext-C59PzHhN.mjs';
4
-
5
- const createQuery = (function_, args, options = {}) => {
6
- const client = useLunora();
7
- const {
8
- shardKey
9
- } = options;
10
- const [value, setValue] = createSignal(void 0);
11
- const resolveArgs = () => typeof args === "function" ? args() : args;
12
- createEffect(on(resolveArgs, (current) => {
13
- const unsubscribe = createQuerySubscription(client, function_, current, {
14
- onData: (next) => {
15
- setValue(() => next);
16
- },
17
- onReset: () => {
18
- setValue(() => void 0);
19
- }
20
- }, {
21
- shardKey
22
- });
23
- onCleanup(unsubscribe);
24
- }));
25
- return value;
26
- };
27
-
28
- export { createQuery };
@@ -1,76 +0,0 @@
1
- import { evaluate } from '@lunora/ratelimit';
2
- import { createSignal, createMemo, onCleanup } from 'solid-js';
3
-
4
- const createRateLimit = (config, options = {}) => {
5
- const now = options.now ?? Date.now;
6
- const tickMs = options.tickMs ?? 1e3;
7
- let value;
8
- const [epoch, setEpoch] = createSignal(0);
9
- const bump = () => {
10
- setEpoch((n) => n + 1);
11
- };
12
- const status = createMemo(() => {
13
- const ts = now() + epoch() * 0;
14
- return evaluate(config, value, {
15
- consume: false,
16
- count: 1,
17
- now: ts,
18
- reserve: false
19
- }).status;
20
- });
21
- let intervalHandle;
22
- const stopInterval = () => {
23
- if (intervalHandle !== void 0) {
24
- clearInterval(intervalHandle);
25
- intervalHandle = void 0;
26
- }
27
- };
28
- const startIntervalIfThrottled = () => {
29
- if (status().ok || intervalHandle !== void 0) {
30
- return;
31
- }
32
- intervalHandle = setInterval(() => {
33
- bump();
34
- if (status().ok) {
35
- stopInterval();
36
- }
37
- }, tickMs);
38
- };
39
- onCleanup(stopInterval);
40
- startIntervalIfThrottled();
41
- const consume = (count = 1) => {
42
- const result = evaluate(config, value, {
43
- consume: true,
44
- count,
45
- now: now(),
46
- reserve: false
47
- });
48
- if (result.value !== void 0) {
49
- value = result.value;
50
- }
51
- bump();
52
- startIntervalIfThrottled();
53
- return result.status;
54
- };
55
- const check = (count = 1) => evaluate(config, value, {
56
- consume: false,
57
- count,
58
- now: now(),
59
- reserve: false
60
- }).status.ok;
61
- const reset = () => {
62
- value = void 0;
63
- stopInterval();
64
- bump();
65
- };
66
- return {
67
- check,
68
- consume,
69
- disabled: () => !status().ok,
70
- ok: () => status().ok,
71
- reset,
72
- retryAfter: () => status().retryAfter
73
- };
74
- };
75
-
76
- export { createRateLimit };
@@ -1,41 +0,0 @@
1
- import { createQuerySubscription } from '@lunora/client/query';
2
- import { LunoraError } from '@lunora/errors';
3
- import { createSignal, createEffect, on, onCleanup } from 'solid-js';
4
- import { useLunora } from './LunoraContext-C59PzHhN.mjs';
5
-
6
- const createSubscription = (function_, args, options = {}) => {
7
- const client = useLunora();
8
- const [data, setData] = createSignal(void 0);
9
- const [error, setError] = createSignal(void 0);
10
- const resolveArgs = typeof args === "function" ? args : () => args;
11
- createEffect(on(resolveArgs, (currentArgs) => {
12
- if (currentArgs === "skip") {
13
- setData(() => void 0);
14
- setError(() => void 0);
15
- return;
16
- }
17
- const unsubscribe = createQuerySubscription(client, function_, currentArgs, {
18
- onData: (value) => {
19
- setData(() => value);
20
- setError(() => void 0);
21
- },
22
- onError: (subscriptionError) => {
23
- const normalized = subscriptionError.code ? new LunoraError(subscriptionError.code, subscriptionError.message) : new Error(subscriptionError.message);
24
- setError(() => normalized);
25
- setData(() => void 0);
26
- },
27
- onReset: () => {
28
- setData(() => void 0);
29
- }
30
- }, {
31
- shardKey: options.shardKey
32
- });
33
- onCleanup(unsubscribe);
34
- }));
35
- return {
36
- data,
37
- error
38
- };
39
- };
40
-
41
- export { createSubscription };
@@ -1,25 +0,0 @@
1
- import { createSignal, createEffect, onCleanup } from 'solid-js';
2
- import { useLunora } from './LunoraContext-C59PzHhN.mjs';
3
-
4
- const hydratePreloaded = (preloaded) => {
5
- const client = useLunora();
6
- const {
7
- args,
8
- functionPath,
9
- shardKey,
10
- value
11
- } = preloaded;
12
- const [data, setData] = createSignal(value);
13
- const functionRef = {
14
- __lunoraRef: functionPath
15
- };
16
- createEffect(() => {
17
- const unsubscribe = client.subscribe(functionRef, args, (next) => setData(() => next), {
18
- shardKey
19
- });
20
- onCleanup(unsubscribe);
21
- });
22
- return data;
23
- };
24
-
25
- export { hydratePreloaded as default };
@@ -1,38 +0,0 @@
1
- const compareKeys = (a, b) => {
2
- if (a < b) {
3
- return -1;
4
- }
5
- return a > b ? 1 : 0;
6
- };
7
- const stableStringify = (value) => {
8
- if (value === void 0) {
9
- return "null";
10
- }
11
- if (typeof value === "bigint") {
12
- throw new TypeError("stableStringify: cannot use a bigint in a cache key (query/subscription/shape args) — pass it as a string");
13
- }
14
- if (value === null || typeof value !== "object") {
15
- return JSON.stringify(value);
16
- }
17
- if (Array.isArray(value)) {
18
- return `[${value.map((item) => stableStringify(item)).join(",")}]`;
19
- }
20
- const proto = Object.getPrototypeOf(value);
21
- if (proto !== null && proto !== Object.prototype) {
22
- const name = value.constructor?.name ?? "value";
23
- throw new TypeError(`stableStringify: cannot use a ${name} in a cache key (query/subscription/shape args) — only plain objects, arrays, and JSON primitives are supported`);
24
- }
25
- const record = value;
26
- const keys = Object.keys(record).toSorted(compareKeys);
27
- const parts = [];
28
- for (const key of keys) {
29
- const raw = record[key];
30
- if (raw === void 0) {
31
- continue;
32
- }
33
- parts.push(`${JSON.stringify(key)}:${stableStringify(raw)}`);
34
- }
35
- return `{${parts.join(",")}}`;
36
- };
37
-
38
- export { stableStringify as s };