@lunora/solid 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (29) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +2 -0
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/index.d.mts +813 -175
  5. package/dist/index.d.ts +813 -175
  6. package/dist/index.mjs +18 -10
  7. package/dist/packem_shared/{AuthLoading-RMT5Q_eE.mjs → AuthLoading-u5QJoV-J.mjs} +1 -1
  8. package/dist/packem_shared/{LunoraContext-C9SpKj54.mjs → LunoraContext-C59PzHhN.mjs} +2 -1
  9. package/dist/packem_shared/{LunoraProvider-B5BJFk3K.mjs → LunoraProvider-CzB3zGhy.mjs} +1 -1
  10. package/dist/packem_shared/createAgent-D7EZBeql.mjs +55 -0
  11. package/dist/packem_shared/createAgentChat-Bq-wzSxv.mjs +166 -0
  12. package/dist/packem_shared/createAgentState-DckYu3G8.mjs +21 -0
  13. package/dist/packem_shared/createAgentToolEvents-UavTO16u.mjs +99 -0
  14. package/dist/packem_shared/{createConnectionStatus-D8GPatZX.mjs → createConnectionStatus-1poqwqR9.mjs} +1 -1
  15. package/dist/packem_shared/createFlag-DQoGdUMB.mjs +78 -0
  16. package/dist/packem_shared/{createInfiniteQuery-DyMvQ2Qy.mjs → createInfiniteQuery-CD2GT1_O.mjs} +148 -5
  17. package/dist/packem_shared/{createMutation-C7BxzO0y.mjs → createMutation-LkrbhItI.mjs} +1 -1
  18. package/dist/packem_shared/createMutator-foSnPJPt.mjs +24 -0
  19. package/dist/packem_shared/{createPresence-DiAak1Jw.mjs → createPresence-DM2cVkiG.mjs} +13 -6
  20. package/dist/packem_shared/{createQuery-D8mdHfyQ.mjs → createQuery-BUldvZXj.mjs} +1 -1
  21. package/dist/packem_shared/createStream-D9ONbGAw.mjs +70 -0
  22. package/dist/packem_shared/{createSubscription-BM2fw8hw.mjs → createSubscription-D3HbChGe.mjs} +4 -2
  23. package/dist/packem_shared/createVoiceAgent-hu59SaDl.mjs +418 -0
  24. package/dist/packem_shared/{hydratePreloaded-CaT1kDBH.mjs → hydratePreloaded-CWny5-2J.mjs} +1 -1
  25. package/dist/packem_shared/stable-key-DePnevIy.mjs +38 -0
  26. package/dist/upload.d.mts +2 -0
  27. package/dist/upload.d.ts +2 -0
  28. package/dist/upload.mjs +2 -0
  29. package/package.json +10 -4
@@ -1,6 +1,6 @@
1
1
  import { createMutationRunner } from '@lunora/client';
2
2
  import { createSignal } from 'solid-js';
3
- import { useLunora } from './LunoraContext-C9SpKj54.mjs';
3
+ import { useLunora } from './LunoraContext-C59PzHhN.mjs';
4
4
 
5
5
  const createMutationForClient = (client, function_) => {
6
6
  const [data, setData] = createSignal(void 0);
@@ -0,0 +1,24 @@
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,12 +1,19 @@
1
1
  import { createSignal, onMount, onCleanup } from 'solid-js';
2
- import { useLunora } from './LunoraContext-C9SpKj54.mjs';
2
+ import { useLunora } from './LunoraContext-C59PzHhN.mjs';
3
3
 
4
- const makeSessionId = () => {
5
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
6
- return crypto.randomUUID();
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
+ }
7
13
  }
8
- return `sess-${Math.random().toString(36).slice(2)}-${String(Date.now())}`;
14
+ return `${prefix}-${Date.now().toString(36)}`;
9
15
  };
16
+
10
17
  const DEFAULT_INTERVAL_MS = 1e4;
11
18
  const createPresence = (roomId, options) => {
12
19
  const client = useLunora();
@@ -16,7 +23,7 @@ const createPresence = (roomId, options) => {
16
23
  listPresent,
17
24
  shardKey
18
25
  } = options;
19
- const sessionId = options.sessionId ?? makeSessionId();
26
+ const sessionId = options.sessionId ?? randomSessionId();
20
27
  const [present, setPresent] = createSignal(void 0);
21
28
  let latestData = options.data;
22
29
  const sendHeartbeat = () => {
@@ -1,6 +1,6 @@
1
1
  import { createQuerySubscription } from '@lunora/client/query';
2
2
  import { createSignal, createEffect, on, onCleanup } from 'solid-js';
3
- import { useLunora } from './LunoraContext-C9SpKj54.mjs';
3
+ import { useLunora } from './LunoraContext-C59PzHhN.mjs';
4
4
 
5
5
  const createQuery = (function_, args, options = {}) => {
6
6
  const client = useLunora();
@@ -0,0 +1,70 @@
1
+ import { createSignal, createEffect, on, onCleanup } from 'solid-js';
2
+ import { useLunora } from './LunoraContext-C59PzHhN.mjs';
3
+
4
+ const createStream = (function_, args, options = {}) => {
5
+ const client = useLunora();
6
+ const [chunks, setChunks] = createSignal([]);
7
+ const [error, setError] = createSignal(void 0);
8
+ const [status, setStatus] = createSignal("idle");
9
+ const resolveArgs = typeof args === "function" ? args : () => args;
10
+ let cancelCurrent;
11
+ const cancel = () => {
12
+ cancelCurrent?.();
13
+ };
14
+ createEffect(on(resolveArgs, (currentArgs) => {
15
+ setChunks(() => []);
16
+ setError(() => void 0);
17
+ if (currentArgs === "skip") {
18
+ setStatus("idle");
19
+ return;
20
+ }
21
+ setStatus("streaming");
22
+ let active = true;
23
+ const iterable = client.stream(function_, currentArgs, {
24
+ maxBuffer: options.maxBuffer,
25
+ shardKey: options.shardKey
26
+ });
27
+ const cancelIterable = () => {
28
+ iterable.cancel();
29
+ };
30
+ cancelCurrent = cancelIterable;
31
+ (async () => {
32
+ try {
33
+ for await (const chunk of iterable) {
34
+ if (!active) {
35
+ return;
36
+ }
37
+ setChunks((previous) => [...previous, chunk]);
38
+ }
39
+ if (active) {
40
+ setStatus("complete");
41
+ }
42
+ } catch (streamError) {
43
+ if (!active) {
44
+ return;
45
+ }
46
+ setError(() => streamError instanceof Error ? streamError : new Error(String(streamError)));
47
+ setStatus("error");
48
+ }
49
+ })().catch(() => {
50
+ });
51
+ onCleanup(() => {
52
+ active = false;
53
+ cancelIterable();
54
+ if (cancelCurrent === cancelIterable) {
55
+ cancelCurrent = void 0;
56
+ }
57
+ });
58
+ }));
59
+ onCleanup(() => {
60
+ cancel();
61
+ });
62
+ return {
63
+ cancel,
64
+ chunks,
65
+ error,
66
+ status
67
+ };
68
+ };
69
+
70
+ export { createStream };
@@ -1,6 +1,7 @@
1
1
  import { createQuerySubscription } from '@lunora/client/query';
2
+ import { LunoraError } from '@lunora/errors';
2
3
  import { createSignal, createEffect, on, onCleanup } from 'solid-js';
3
- import { useLunora } from './LunoraContext-C9SpKj54.mjs';
4
+ import { useLunora } from './LunoraContext-C59PzHhN.mjs';
4
5
 
5
6
  const createSubscription = (function_, args, options = {}) => {
6
7
  const client = useLunora();
@@ -19,7 +20,8 @@ const createSubscription = (function_, args, options = {}) => {
19
20
  setError(() => void 0);
20
21
  },
21
22
  onError: (subscriptionError) => {
22
- setError(() => new Error(subscriptionError.message));
23
+ const normalized = subscriptionError.code ? new LunoraError(subscriptionError.code, subscriptionError.message) : new Error(subscriptionError.message);
24
+ setError(() => normalized);
23
25
  setData(() => void 0);
24
26
  },
25
27
  onReset: () => {
@@ -0,0 +1,418 @@
1
+ import { createSignal, onCleanup } from 'solid-js';
2
+ import { useLunora } from './LunoraContext-C59PzHhN.mjs';
3
+ import { resolveMaybe } from './createAgent-D7EZBeql.mjs';
4
+
5
+ const TARGET_SAMPLE_RATE = 16e3;
6
+ const blockRms = (samples) => {
7
+ if (samples.length === 0) {
8
+ return 0;
9
+ }
10
+ let sum = 0;
11
+ for (const sample of samples) {
12
+ sum += sample * sample;
13
+ }
14
+ return Math.sqrt(sum / samples.length);
15
+ };
16
+ const toPcm16 = (samples, inputSampleRate) => {
17
+ const ratio = inputSampleRate / TARGET_SAMPLE_RATE;
18
+ const outLength = ratio > 1 ? Math.floor(samples.length / ratio) : samples.length;
19
+ const buffer = new ArrayBuffer(outLength * 2);
20
+ const view = new DataView(buffer);
21
+ for (let index = 0; index < outLength; index += 1) {
22
+ const sample = samples[Math.floor(index * ratio)] ?? 0;
23
+ const clamped = Math.max(-1, Math.min(1, sample));
24
+ view.setInt16(index * 2, clamped < 0 ? clamped * 32768 : clamped * 32767, true);
25
+ }
26
+ return new Uint8Array(buffer);
27
+ };
28
+ const createBrowserMicrophone = async (config) => {
29
+ const media = globalThis;
30
+ const getUserMedia = media.navigator?.mediaDevices?.getUserMedia.bind(media.navigator.mediaDevices);
31
+ const AudioContextClass = media.AudioContext ?? media.webkitAudioContext;
32
+ if (!getUserMedia || !AudioContextClass) {
33
+ throw new Error("createVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");
34
+ }
35
+ const stream = await getUserMedia({
36
+ audio: {
37
+ channelCount: 1,
38
+ echoCancellation: true,
39
+ noiseSuppression: true
40
+ }
41
+ });
42
+ const context = new AudioContextClass();
43
+ const source = context.createMediaStreamSource(stream);
44
+ const processor = context.createScriptProcessor(4096, 1, 1);
45
+ let muted = false;
46
+ let sawSpeech = false;
47
+ let silentFor = 0;
48
+ let loudChunks = 0;
49
+ processor.onaudioprocess = (event) => {
50
+ const samples = event.inputBuffer.getChannelData(0);
51
+ const rms = muted ? 0 : blockRms(samples);
52
+ config.onLevel(rms);
53
+ if (muted) {
54
+ return;
55
+ }
56
+ config.onAudio(toPcm16(samples, context.sampleRate));
57
+ if (config.isSpeaking()) {
58
+ loudChunks = rms >= config.interruptThreshold ? loudChunks + 1 : 0;
59
+ if (loudChunks >= config.interruptChunks) {
60
+ loudChunks = 0;
61
+ config.onInterrupt();
62
+ }
63
+ return;
64
+ }
65
+ loudChunks = 0;
66
+ const chunkMs = samples.length / context.sampleRate * 1e3;
67
+ if (rms >= config.silenceThreshold) {
68
+ sawSpeech = true;
69
+ silentFor = 0;
70
+ return;
71
+ }
72
+ if (sawSpeech) {
73
+ silentFor += chunkMs;
74
+ if (silentFor >= config.silenceDurationMs) {
75
+ sawSpeech = false;
76
+ silentFor = 0;
77
+ config.onSilence();
78
+ }
79
+ }
80
+ };
81
+ source.connect(processor);
82
+ processor.connect(context.destination);
83
+ return {
84
+ setMuted: (next) => {
85
+ muted = next;
86
+ },
87
+ stop: () => {
88
+ processor.disconnect();
89
+ source.disconnect();
90
+ for (const track of stream.getTracks()) {
91
+ track.stop();
92
+ }
93
+ void context.close();
94
+ }
95
+ };
96
+ };
97
+ const createBrowserSpeaker = () => {
98
+ const media = globalThis;
99
+ const AudioContextClass = media.AudioContext ?? media.webkitAudioContext;
100
+ if (!AudioContextClass) {
101
+ throw new Error("createVoiceAgent: audio playback requires AudioContext (no browser audio available)");
102
+ }
103
+ const context = new AudioContextClass();
104
+ const sources = /* @__PURE__ */ new Set();
105
+ let playHead = 0;
106
+ let chain = Promise.resolve();
107
+ let generation = 0;
108
+ const scheduleChunk = async (bytes, scheduledGeneration) => {
109
+ if (scheduledGeneration !== generation) {
110
+ return;
111
+ }
112
+ let decoded;
113
+ try {
114
+ decoded = await context.decodeAudioData(bytes.buffer);
115
+ } catch {
116
+ return;
117
+ }
118
+ if (scheduledGeneration !== generation) {
119
+ return;
120
+ }
121
+ const node = context.createBufferSource();
122
+ node.buffer = decoded;
123
+ node.connect(context.destination);
124
+ const startAt = Math.max(context.currentTime, playHead);
125
+ node.start(startAt);
126
+ playHead = startAt + decoded.duration;
127
+ sources.add(node);
128
+ node.onended = () => {
129
+ sources.delete(node);
130
+ };
131
+ };
132
+ const enqueue = (audio) => {
133
+ const bytes = Uint8Array.from(audio);
134
+ const scheduledGeneration = generation;
135
+ chain = chain.then(() => scheduleChunk(bytes, scheduledGeneration));
136
+ };
137
+ const interrupt = () => {
138
+ generation += 1;
139
+ for (const node of sources) {
140
+ try {
141
+ node.stop();
142
+ } catch {
143
+ }
144
+ }
145
+ sources.clear();
146
+ playHead = context.currentTime;
147
+ };
148
+ return {
149
+ enqueue,
150
+ interrupt,
151
+ stop: () => {
152
+ interrupt();
153
+ void context.close();
154
+ }
155
+ };
156
+ };
157
+
158
+ const WS_OPEN = 1;
159
+ const DEFAULT_SILENCE_THRESHOLD = 0.01;
160
+ const DEFAULT_SILENCE_DURATION_MS = 1200;
161
+ const DEFAULT_INTERRUPT_THRESHOLD = 0.15;
162
+ const DEFAULT_INTERRUPT_CHUNKS = 3;
163
+ const deriveWebSocketUrl = (url) => {
164
+ if (url.startsWith("https://")) {
165
+ return `wss://${url.slice("https://".length)}`;
166
+ }
167
+ if (url.startsWith("http://")) {
168
+ return `ws://${url.slice("http://".length)}`;
169
+ }
170
+ return url;
171
+ };
172
+ const agentNameFromReference = (voice) => {
173
+ const reference = voice["__lunoraRef"];
174
+ const withoutNamespace = reference.startsWith("agents:") ? reference.slice("agents:".length) : reference;
175
+ return withoutNamespace.endsWith("Voice") ? withoutNamespace.slice(0, -"Voice".length) : withoutNamespace;
176
+ };
177
+ const voiceSocketUrl = (baseUrl, agent, threadKey) => {
178
+ const base = deriveWebSocketUrl(baseUrl);
179
+ const trimmed = base.endsWith("/") ? base.slice(0, -1) : base;
180
+ const search = new URLSearchParams({
181
+ threadKey
182
+ });
183
+ return `${trimmed}/_lunora/voice/${encodeURIComponent(agent)}?${search.toString()}`;
184
+ };
185
+ const createVoiceAgent = (options) => {
186
+ const {
187
+ createMicrophone = createBrowserMicrophone,
188
+ createSpeaker = createBrowserSpeaker,
189
+ createSocket,
190
+ interruptChunks = DEFAULT_INTERRUPT_CHUNKS,
191
+ interruptThreshold = DEFAULT_INTERRUPT_THRESHOLD,
192
+ silenceDurationMs = DEFAULT_SILENCE_DURATION_MS,
193
+ silenceThreshold = DEFAULT_SILENCE_THRESHOLD,
194
+ threadKey,
195
+ voice
196
+ } = options;
197
+ const client = useLunora();
198
+ const [status, setStatus] = createSignal("idle");
199
+ const [connected, setConnected] = createSignal(false);
200
+ const [transcript, setTranscript] = createSignal("");
201
+ const [interimTranscript, setInterimTranscript] = createSignal("");
202
+ const [audioLevel, setAudioLevel] = createSignal(0);
203
+ const [isMuted, setIsMuted] = createSignal(false);
204
+ const [error, setError] = createSignal(void 0);
205
+ let current;
206
+ let starting = false;
207
+ const sendFrame = (frame) => {
208
+ const socket = current?.socket;
209
+ if (socket?.readyState === WS_OPEN) {
210
+ socket.send(JSON.stringify(frame));
211
+ return true;
212
+ }
213
+ return false;
214
+ };
215
+ const teardown = () => {
216
+ const connection = current;
217
+ current = void 0;
218
+ if (connection) {
219
+ connection.microphone?.stop();
220
+ connection.speaker?.stop();
221
+ try {
222
+ connection.socket.close();
223
+ } catch {
224
+ }
225
+ }
226
+ starting = false;
227
+ setConnected(false);
228
+ setStatus("idle");
229
+ setAudioLevel(0);
230
+ };
231
+ const endCall = () => {
232
+ teardown();
233
+ };
234
+ const handleServerFrame = (frame) => {
235
+ const connection = current;
236
+ switch (frame.type) {
237
+ case "assistant_delta": {
238
+ if (connection) {
239
+ connection.speaking = true;
240
+ }
241
+ setStatus("speaking");
242
+ setInterimTranscript((previous) => previous + frame.text);
243
+ break;
244
+ }
245
+ case "assistant_done": {
246
+ if (connection) {
247
+ connection.speaking = false;
248
+ }
249
+ setInterimTranscript(frame.text);
250
+ setStatus("listening");
251
+ break;
252
+ }
253
+ case "error": {
254
+ if (connection) {
255
+ connection.speaking = false;
256
+ }
257
+ setError(new Error(frame.message));
258
+ setStatus("listening");
259
+ break;
260
+ }
261
+ case "interrupted": {
262
+ if (connection) {
263
+ connection.speaking = false;
264
+ connection.suppressAudio = false;
265
+ }
266
+ connection?.speaker?.interrupt();
267
+ setStatus("listening");
268
+ break;
269
+ }
270
+ case "ready": {
271
+ if (connection) {
272
+ connection.audioFormat = frame.audioFormat;
273
+ connection.suppressAudio = false;
274
+ }
275
+ setConnected(true);
276
+ setStatus("listening");
277
+ break;
278
+ }
279
+ case "user_transcript": {
280
+ if (connection) {
281
+ connection.suppressAudio = false;
282
+ }
283
+ setTranscript(frame.text);
284
+ setInterimTranscript("");
285
+ setStatus("thinking");
286
+ break;
287
+ }
288
+ }
289
+ };
290
+ const handleAudioChunk = (audio) => {
291
+ const connection = current;
292
+ if (!connection || connection.suppressAudio) {
293
+ return;
294
+ }
295
+ connection.speaker ??= createSpeaker({
296
+ audioFormat: connection.audioFormat
297
+ });
298
+ connection.speaking = true;
299
+ setStatus("speaking");
300
+ connection.speaker.enqueue(audio);
301
+ };
302
+ const startCall = async () => {
303
+ if (current || starting) {
304
+ return;
305
+ }
306
+ starting = true;
307
+ setError(void 0);
308
+ setTranscript("");
309
+ setInterimTranscript("");
310
+ try {
311
+ const url = voiceSocketUrl(client.url, agentNameFromReference(voice), resolveMaybe(threadKey));
312
+ const openSocket = createSocket ?? ((target) => new globalThis.WebSocket(target));
313
+ const socket = openSocket(url);
314
+ socket.binaryType = "arraybuffer";
315
+ const connection = {
316
+ audioFormat: "mp3",
317
+ microphone: void 0,
318
+ socket,
319
+ speaker: void 0,
320
+ speaking: false,
321
+ suppressAudio: false
322
+ };
323
+ current = connection;
324
+ socket.onmessage = (event) => {
325
+ if (typeof event.data === "string") {
326
+ try {
327
+ handleServerFrame(JSON.parse(event.data));
328
+ } catch {
329
+ }
330
+ return;
331
+ }
332
+ handleAudioChunk(new Uint8Array(event.data));
333
+ };
334
+ socket.onerror = () => {
335
+ setError(new Error("createVoiceAgent: voice socket error"));
336
+ };
337
+ socket.onclose = () => {
338
+ if (current === connection) {
339
+ teardown();
340
+ }
341
+ };
342
+ const microphone = await createMicrophone({
343
+ interruptChunks,
344
+ interruptThreshold,
345
+ isSpeaking: () => current?.speaking ?? false,
346
+ onAudio: (pcm) => {
347
+ if (socket.readyState === WS_OPEN) {
348
+ socket.send(pcm);
349
+ }
350
+ },
351
+ onInterrupt: () => {
352
+ sendFrame({
353
+ type: "interrupt"
354
+ });
355
+ current?.speaker?.interrupt();
356
+ if (current) {
357
+ current.speaking = false;
358
+ current.suppressAudio = true;
359
+ }
360
+ setStatus("listening");
361
+ },
362
+ onLevel: (rms) => {
363
+ setAudioLevel(rms);
364
+ },
365
+ onSilence: () => {
366
+ sendFrame({
367
+ type: "commit"
368
+ });
369
+ setStatus("thinking");
370
+ },
371
+ silenceDurationMs,
372
+ silenceThreshold
373
+ });
374
+ if (current === connection) {
375
+ connection.microphone = microphone;
376
+ setIsMuted(false);
377
+ setStatus("listening");
378
+ } else {
379
+ microphone.stop();
380
+ }
381
+ } catch (error_) {
382
+ setError(error_ instanceof Error ? error_ : new Error(String(error_)));
383
+ teardown();
384
+ } finally {
385
+ starting = false;
386
+ }
387
+ };
388
+ const toggleMute = () => {
389
+ const next = !isMuted();
390
+ current?.microphone?.setMuted(next);
391
+ setIsMuted(next);
392
+ return next;
393
+ };
394
+ const sendText = (text) => {
395
+ if (sendFrame({
396
+ text,
397
+ type: "text"
398
+ })) {
399
+ setStatus("thinking");
400
+ }
401
+ };
402
+ onCleanup(teardown);
403
+ return {
404
+ audioLevel,
405
+ connected,
406
+ endCall,
407
+ error,
408
+ interimTranscript,
409
+ isMuted,
410
+ sendText,
411
+ startCall,
412
+ status,
413
+ toggleMute,
414
+ transcript
415
+ };
416
+ };
417
+
418
+ export { createVoiceAgent };
@@ -1,5 +1,5 @@
1
1
  import { createSignal, createEffect, onCleanup } from 'solid-js';
2
- import { useLunora } from './LunoraContext-C9SpKj54.mjs';
2
+ import { useLunora } from './LunoraContext-C59PzHhN.mjs';
3
3
 
4
4
  const hydratePreloaded = (preloaded) => {
5
5
  const client = useLunora();
@@ -0,0 +1,38 @@
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 stable JSON cache key — pass it as a string, or use stableWireKey");
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 stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`);
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 };
@@ -0,0 +1,2 @@
1
+ export { RestrictionError, UploadControl, UploadError, type UploadMethod, type UploadRestrictions, type UploadResult } from '@visulima/storage-client';
2
+ export { type CreateChunkedRestUploadOptions, type CreateChunkedRestUploadReturn, type CreateFileInputOptions, type CreateFileInputReturn, type CreateMultipartUploadOptions, type CreateMultipartUploadReturn, type CreatePasteUploadOptions, type CreatePasteUploadReturn, type CreateTusUploadOptions, type CreateTusUploadReturn, type CreateUploadOptions, type CreateUploadReturn, createChunkedRestUpload, createFileInput, createMultipartUpload, createPasteUpload, createTusUpload, createUpload } from '@visulima/storage-client/solid';
@@ -0,0 +1,2 @@
1
+ export { RestrictionError, UploadControl, UploadError, type UploadMethod, type UploadRestrictions, type UploadResult } from '@visulima/storage-client';
2
+ export { type CreateChunkedRestUploadOptions, type CreateChunkedRestUploadReturn, type CreateFileInputOptions, type CreateFileInputReturn, type CreateMultipartUploadOptions, type CreateMultipartUploadReturn, type CreatePasteUploadOptions, type CreatePasteUploadReturn, type CreateTusUploadOptions, type CreateTusUploadReturn, type CreateUploadOptions, type CreateUploadReturn, createChunkedRestUpload, createFileInput, createMultipartUpload, createPasteUpload, createTusUpload, createUpload } from '@visulima/storage-client/solid';
@@ -0,0 +1,2 @@
1
+ export { RestrictionError, UploadControl, UploadError } from '@visulima/storage-client';
2
+ export { createChunkedRestUpload, createFileInput, createMultipartUpload, createPasteUpload, createTusUpload, createUpload } from '@visulima/storage-client/solid';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/solid",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.30",
4
4
  "description": "SolidJS adapter for Lunora — live queries, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -25,7 +25,7 @@
25
25
  "directory": "packages/solid"
26
26
  },
27
27
  "files": [
28
- "dist",
28
+ "./dist",
29
29
  "README.md",
30
30
  "LICENSE.md",
31
31
  "__assets__"
@@ -44,14 +44,20 @@
44
44
  "types": "./dist/server.d.ts",
45
45
  "import": "./dist/server.mjs"
46
46
  },
47
+ "./upload": {
48
+ "types": "./dist/upload.d.ts",
49
+ "import": "./dist/upload.mjs"
50
+ },
47
51
  "./package.json": "./package.json"
48
52
  },
49
53
  "publishConfig": {
50
54
  "access": "public"
51
55
  },
52
56
  "dependencies": {
53
- "@lunora/client": "1.0.0-alpha.2",
54
- "@lunora/ratelimit": "1.0.0-alpha.2"
57
+ "@lunora/client": "1.0.0-alpha.28",
58
+ "@lunora/errors": "1.0.0-alpha.8",
59
+ "@lunora/ratelimit": "1.0.0-alpha.10",
60
+ "@visulima/storage-client": "1.0.0"
55
61
  },
56
62
  "peerDependencies": {
57
63
  "solid-js": "^1.9.0"