@lunora/solid 1.0.0-alpha.4 → 1.0.0-alpha.40
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 +2 -0
- package/dist/index.d.mts +813 -175
- package/dist/index.d.ts +813 -175
- package/dist/index.mjs +1 -11
- package/dist/packem_shared/AuthLoading-D6A1mBRs.mjs +1 -0
- package/dist/packem_shared/LunoraContext-CVOsskhY.mjs +1 -0
- package/dist/packem_shared/LunoraProvider-cifsrLab.mjs +1 -0
- package/dist/packem_shared/createAgent-BbHVxEpf.mjs +1 -0
- package/dist/packem_shared/createAgentChat-B79ZiHfq.mjs +1 -0
- package/dist/packem_shared/createAgentState-CbE2MP_H.mjs +1 -0
- package/dist/packem_shared/createAgentToolEvents-DOU_J3JT.mjs +1 -0
- package/dist/packem_shared/createConnectionStatus-B9ly5m1x.mjs +1 -0
- package/dist/packem_shared/createFlag-qBxuQ5hP.mjs +1 -0
- package/dist/packem_shared/createInfiniteQuery-EM9Tio0U.mjs +1 -0
- package/dist/packem_shared/createMutation-9i34uh8U.mjs +1 -0
- package/dist/packem_shared/createMutator-zzxMk2QQ.mjs +1 -0
- package/dist/packem_shared/createPresence-DNVSvTzP.mjs +1 -0
- package/dist/packem_shared/createQuery-CFb7mUGW.mjs +1 -0
- package/dist/packem_shared/createRateLimit-BdVo3eNW.mjs +1 -0
- package/dist/packem_shared/createStream-DozkYNOc.mjs +1 -0
- package/dist/packem_shared/createSubscription-KbQk0ohZ.mjs +1 -0
- package/dist/packem_shared/createVoiceAgent-CzXF9acz.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-BbGFlPEb.mjs +1 -0
- package/dist/packem_shared/stable-key-BSG0zK_E.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 +9 -3
- 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/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,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 };
|