@lunora/solid 1.0.0-alpha.6 → 1.0.0-alpha.60
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.
- package/LICENSE.md +6 -0
- package/README.md +4 -0
- package/dist/index.d.mts +926 -213
- package/dist/index.d.ts +926 -213
- package/dist/index.mjs +1 -12
- package/dist/packem_shared/AuthLoading-6vueEnV0.mjs +1 -0
- package/dist/packem_shared/LunoraContext-dPcjtn6R.mjs +1 -0
- package/dist/packem_shared/LunoraProvider-BKWckcDR.mjs +1 -0
- package/dist/packem_shared/createAction-M4s8XBXV.mjs +1 -0
- package/dist/packem_shared/createAgent-DTUKko5X.mjs +1 -0
- package/dist/packem_shared/createAgentChat-BjVMwDVY.mjs +1 -0
- package/dist/packem_shared/createAgentState-DIknFZyn.mjs +1 -0
- package/dist/packem_shared/createAgentToolEvents-BZDqkzK6.mjs +1 -0
- package/dist/packem_shared/createConnectionStatus-BnlXYWeE.mjs +1 -0
- package/dist/packem_shared/createFlag-l_riySES.mjs +1 -0
- package/dist/packem_shared/createInfiniteQuery-CAU4Yr4Z.mjs +1 -0
- package/dist/packem_shared/createMutation-DcSsIbGF.mjs +1 -0
- package/dist/packem_shared/createMutator-q9cMjGKv.mjs +1 -0
- package/dist/packem_shared/createPresence-Da_DdL7L.mjs +1 -0
- package/dist/packem_shared/createQuery-DnfKuyeU.mjs +1 -0
- package/dist/packem_shared/createRateLimit-CIVWrD5H.mjs +1 -0
- package/dist/packem_shared/createStream-B10b3ijV.mjs +1 -0
- package/dist/packem_shared/createSubscription-D9e8lT1C.mjs +1 -0
- package/dist/packem_shared/createVoiceAgent-BjL6DH05.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-CnJNitir.mjs +1 -0
- package/dist/packem_shared/solid-compat-ByG5HD_F.mjs +1 -0
- package/dist/packem_shared/stable-key-ITGZkfuz.mjs +1 -0
- package/dist/server.mjs +1 -1
- package/dist/upload.d.mts +2 -0
- package/dist/upload.d.ts +2 -0
- package/dist/upload.mjs +1 -0
- package/package.json +10 -4
- package/dist/packem_shared/AuthLoading-RMT5Q_eE.mjs +0 -73
- package/dist/packem_shared/LunoraContext-C9SpKj54.mjs +0 -12
- package/dist/packem_shared/LunoraProvider-B5BJFk3K.mjs +0 -17
- package/dist/packem_shared/createConnectionStatus-D8GPatZX.mjs +0 -14
- package/dist/packem_shared/createFlag-BDunYuaH.mjs +0 -106
- package/dist/packem_shared/createInfiniteQuery-DyMvQ2Qy.mjs +0 -196
- package/dist/packem_shared/createMutation-C7BxzO0y.mjs +0 -36
- package/dist/packem_shared/createPresence-DiAak1Jw.mjs +0 -78
- package/dist/packem_shared/createQuery-D8mdHfyQ.mjs +0 -28
- package/dist/packem_shared/createRateLimit-BA2f8XyF.mjs +0 -76
- package/dist/packem_shared/createSubscription-BM2fw8hw.mjs +0 -39
- package/dist/packem_shared/hydratePreloaded-CaT1kDBH.mjs +0 -25
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createMutationRunner } from '@lunora/client';
|
|
2
|
-
import { createSignal } from 'solid-js';
|
|
3
|
-
import { useLunora } from './LunoraContext-C9SpKj54.mjs';
|
|
4
|
-
|
|
5
|
-
const createMutationForClient = (client, function_) => {
|
|
6
|
-
const [data, setData] = createSignal(void 0);
|
|
7
|
-
const [error, setError] = createSignal(void 0);
|
|
8
|
-
const [pending, setPending] = createSignal(false);
|
|
9
|
-
const mutate = createMutationRunner(client, function_, {
|
|
10
|
-
setError,
|
|
11
|
-
setPending,
|
|
12
|
-
setResult: (result) => {
|
|
13
|
-
setData(() => result);
|
|
14
|
-
setError(void 0);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
const reset = () => {
|
|
18
|
-
setData(() => void 0);
|
|
19
|
-
setError(void 0);
|
|
20
|
-
};
|
|
21
|
-
return {
|
|
22
|
-
data,
|
|
23
|
-
error,
|
|
24
|
-
mutate,
|
|
25
|
-
pending,
|
|
26
|
-
reset
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
const createMutation = (function_) => {
|
|
30
|
-
const client = useLunora();
|
|
31
|
-
return createMutationForClient({
|
|
32
|
-
mutation: (reference, args, options) => client.mutation(reference, args, options)
|
|
33
|
-
}, function_);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { createMutation, createMutationForClient };
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { createSignal, onMount, onCleanup } from 'solid-js';
|
|
2
|
-
import { useLunora } from './LunoraContext-C9SpKj54.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 createPresence = (roomId, options) => {
|
|
12
|
-
const client = useLunora();
|
|
13
|
-
const {
|
|
14
|
-
heartbeat,
|
|
15
|
-
intervalMs = DEFAULT_INTERVAL_MS,
|
|
16
|
-
listPresent,
|
|
17
|
-
shardKey
|
|
18
|
-
} = options;
|
|
19
|
-
const sessionId = options.sessionId ?? makeSessionId();
|
|
20
|
-
const [present, setPresent] = createSignal(void 0);
|
|
21
|
-
let latestData = options.data;
|
|
22
|
-
const sendHeartbeat = () => {
|
|
23
|
-
const args = {
|
|
24
|
-
roomId,
|
|
25
|
-
sessionId,
|
|
26
|
-
...latestData === void 0 ? {} : {
|
|
27
|
-
data: latestData
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
client.mutation(heartbeat, args, {
|
|
31
|
-
shardKey
|
|
32
|
-
}).catch(() => void 0);
|
|
33
|
-
};
|
|
34
|
-
const setData = (next) => {
|
|
35
|
-
latestData = next;
|
|
36
|
-
sendHeartbeat();
|
|
37
|
-
};
|
|
38
|
-
onMount(() => {
|
|
39
|
-
sendHeartbeat();
|
|
40
|
-
const intervalHandle = setInterval(sendHeartbeat, intervalMs);
|
|
41
|
-
const onVisible = () => {
|
|
42
|
-
if (typeof document !== "undefined" && document.visibilityState === "visible") {
|
|
43
|
-
sendHeartbeat();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
if (typeof document !== "undefined") {
|
|
47
|
-
document.addEventListener("visibilitychange", onVisible);
|
|
48
|
-
}
|
|
49
|
-
const releaseConnectionContext = client.acquireConnectionContext({
|
|
50
|
-
roomId,
|
|
51
|
-
sessionId
|
|
52
|
-
}, {
|
|
53
|
-
shardKey
|
|
54
|
-
});
|
|
55
|
-
const unsubscribe = client.subscribe(listPresent, {
|
|
56
|
-
roomId
|
|
57
|
-
}, (value) => {
|
|
58
|
-
setPresent(() => value);
|
|
59
|
-
}, {
|
|
60
|
-
shardKey
|
|
61
|
-
});
|
|
62
|
-
onCleanup(() => {
|
|
63
|
-
clearInterval(intervalHandle);
|
|
64
|
-
if (typeof document !== "undefined") {
|
|
65
|
-
document.removeEventListener("visibilitychange", onVisible);
|
|
66
|
-
}
|
|
67
|
-
releaseConnectionContext();
|
|
68
|
-
unsubscribe();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
present,
|
|
73
|
-
sessionId,
|
|
74
|
-
setData
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
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-C9SpKj54.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,39 +0,0 @@
|
|
|
1
|
-
import { createQuerySubscription } from '@lunora/client/query';
|
|
2
|
-
import { createSignal, createEffect, on, onCleanup } from 'solid-js';
|
|
3
|
-
import { useLunora } from './LunoraContext-C9SpKj54.mjs';
|
|
4
|
-
|
|
5
|
-
const createSubscription = (function_, args, options = {}) => {
|
|
6
|
-
const client = useLunora();
|
|
7
|
-
const [data, setData] = createSignal(void 0);
|
|
8
|
-
const [error, setError] = createSignal(void 0);
|
|
9
|
-
const resolveArgs = typeof args === "function" ? args : () => args;
|
|
10
|
-
createEffect(on(resolveArgs, (currentArgs) => {
|
|
11
|
-
if (currentArgs === "skip") {
|
|
12
|
-
setData(() => void 0);
|
|
13
|
-
setError(() => void 0);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const unsubscribe = createQuerySubscription(client, function_, currentArgs, {
|
|
17
|
-
onData: (value) => {
|
|
18
|
-
setData(() => value);
|
|
19
|
-
setError(() => void 0);
|
|
20
|
-
},
|
|
21
|
-
onError: (subscriptionError) => {
|
|
22
|
-
setError(() => new Error(subscriptionError.message));
|
|
23
|
-
setData(() => void 0);
|
|
24
|
-
},
|
|
25
|
-
onReset: () => {
|
|
26
|
-
setData(() => void 0);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
shardKey: options.shardKey
|
|
30
|
-
});
|
|
31
|
-
onCleanup(unsubscribe);
|
|
32
|
-
}));
|
|
33
|
-
return {
|
|
34
|
-
data,
|
|
35
|
-
error
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { createSubscription };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createSignal, createEffect, onCleanup } from 'solid-js';
|
|
2
|
-
import { useLunora } from './LunoraContext-C9SpKj54.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 };
|