@sylphx/lens-solid 1.0.2

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/dist/index.js ADDED
@@ -0,0 +1,765 @@
1
+ // ../../node_modules/.bun/solid-js@1.9.10/node_modules/solid-js/dist/dev.js
2
+ var IS_DEV = true;
3
+ var equalFn = (a, b) => a === b;
4
+ var $PROXY = Symbol("solid-proxy");
5
+ var $TRACK = Symbol("solid-track");
6
+ var $DEVCOMP = Symbol("solid-dev-component");
7
+ var signalOptions = {
8
+ equals: equalFn
9
+ };
10
+ var ERROR = null;
11
+ var runEffects = runQueue;
12
+ var STALE = 1;
13
+ var PENDING = 2;
14
+ var UNOWNED = {
15
+ owned: null,
16
+ cleanups: null,
17
+ context: null,
18
+ owner: null
19
+ };
20
+ var Owner = null;
21
+ var Transition = null;
22
+ var Scheduler = null;
23
+ var ExternalSourceConfig = null;
24
+ var Listener = null;
25
+ var Updates = null;
26
+ var Effects = null;
27
+ var ExecCount = 0;
28
+ var DevHooks = {
29
+ afterUpdate: null,
30
+ afterCreateOwner: null,
31
+ afterCreateSignal: null,
32
+ afterRegisterGraph: null
33
+ };
34
+ function createSignal(value, options) {
35
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
36
+ const s = {
37
+ value,
38
+ observers: null,
39
+ observerSlots: null,
40
+ comparator: options.equals || undefined
41
+ };
42
+ {
43
+ if (options.name)
44
+ s.name = options.name;
45
+ if (options.internal) {
46
+ s.internal = true;
47
+ } else {
48
+ registerGraph(s);
49
+ if (DevHooks.afterCreateSignal)
50
+ DevHooks.afterCreateSignal(s);
51
+ }
52
+ }
53
+ const setter = (value2) => {
54
+ if (typeof value2 === "function") {
55
+ if (Transition && Transition.running && Transition.sources.has(s))
56
+ value2 = value2(s.tValue);
57
+ else
58
+ value2 = value2(s.value);
59
+ }
60
+ return writeSignal(s, value2);
61
+ };
62
+ return [readSignal.bind(s), setter];
63
+ }
64
+ function createRenderEffect(fn, value, options) {
65
+ const c = createComputation(fn, value, false, STALE, options);
66
+ if (Scheduler && Transition && Transition.running)
67
+ Updates.push(c);
68
+ else
69
+ updateComputation(c);
70
+ }
71
+ function createMemo(fn, value, options) {
72
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
73
+ const c = createComputation(fn, value, true, 0, options);
74
+ c.observers = null;
75
+ c.observerSlots = null;
76
+ c.comparator = options.equals || undefined;
77
+ if (Scheduler && Transition && Transition.running) {
78
+ c.tState = STALE;
79
+ Updates.push(c);
80
+ } else
81
+ updateComputation(c);
82
+ return readSignal.bind(c);
83
+ }
84
+ function untrack(fn) {
85
+ if (!ExternalSourceConfig && Listener === null)
86
+ return fn();
87
+ const listener = Listener;
88
+ Listener = null;
89
+ try {
90
+ if (ExternalSourceConfig)
91
+ return ExternalSourceConfig.untrack(fn);
92
+ return fn();
93
+ } finally {
94
+ Listener = listener;
95
+ }
96
+ }
97
+ function onCleanup(fn) {
98
+ if (Owner === null)
99
+ console.warn("cleanups created outside a `createRoot` or `render` will never be run");
100
+ else if (Owner.cleanups === null)
101
+ Owner.cleanups = [fn];
102
+ else
103
+ Owner.cleanups.push(fn);
104
+ return fn;
105
+ }
106
+ function startTransition(fn) {
107
+ if (Transition && Transition.running) {
108
+ fn();
109
+ return Transition.done;
110
+ }
111
+ const l = Listener;
112
+ const o = Owner;
113
+ return Promise.resolve().then(() => {
114
+ Listener = l;
115
+ Owner = o;
116
+ let t;
117
+ if (Scheduler || SuspenseContext) {
118
+ t = Transition || (Transition = {
119
+ sources: new Set,
120
+ effects: [],
121
+ promises: new Set,
122
+ disposed: new Set,
123
+ queue: new Set,
124
+ running: true
125
+ });
126
+ t.done || (t.done = new Promise((res) => t.resolve = res));
127
+ t.running = true;
128
+ }
129
+ runUpdates(fn, false);
130
+ Listener = Owner = null;
131
+ return t ? t.done : undefined;
132
+ });
133
+ }
134
+ var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false);
135
+ function registerGraph(value) {
136
+ if (Owner) {
137
+ if (Owner.sourceMap)
138
+ Owner.sourceMap.push(value);
139
+ else
140
+ Owner.sourceMap = [value];
141
+ value.graph = Owner;
142
+ }
143
+ if (DevHooks.afterRegisterGraph)
144
+ DevHooks.afterRegisterGraph(value);
145
+ }
146
+ function createContext(defaultValue, options) {
147
+ const id = Symbol("context");
148
+ return {
149
+ id,
150
+ Provider: createProvider(id, options),
151
+ defaultValue
152
+ };
153
+ }
154
+ function useContext(context) {
155
+ let value;
156
+ return Owner && Owner.context && (value = Owner.context[context.id]) !== undefined ? value : context.defaultValue;
157
+ }
158
+ function children(fn) {
159
+ const children2 = createMemo(fn);
160
+ const memo = createMemo(() => resolveChildren(children2()), undefined, {
161
+ name: "children"
162
+ });
163
+ memo.toArray = () => {
164
+ const c = memo();
165
+ return Array.isArray(c) ? c : c != null ? [c] : [];
166
+ };
167
+ return memo;
168
+ }
169
+ var SuspenseContext;
170
+ function readSignal() {
171
+ const runningTransition = Transition && Transition.running;
172
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
173
+ if ((runningTransition ? this.tState : this.state) === STALE)
174
+ updateComputation(this);
175
+ else {
176
+ const updates = Updates;
177
+ Updates = null;
178
+ runUpdates(() => lookUpstream(this), false);
179
+ Updates = updates;
180
+ }
181
+ }
182
+ if (Listener) {
183
+ const sSlot = this.observers ? this.observers.length : 0;
184
+ if (!Listener.sources) {
185
+ Listener.sources = [this];
186
+ Listener.sourceSlots = [sSlot];
187
+ } else {
188
+ Listener.sources.push(this);
189
+ Listener.sourceSlots.push(sSlot);
190
+ }
191
+ if (!this.observers) {
192
+ this.observers = [Listener];
193
+ this.observerSlots = [Listener.sources.length - 1];
194
+ } else {
195
+ this.observers.push(Listener);
196
+ this.observerSlots.push(Listener.sources.length - 1);
197
+ }
198
+ }
199
+ if (runningTransition && Transition.sources.has(this))
200
+ return this.tValue;
201
+ return this.value;
202
+ }
203
+ function writeSignal(node, value, isComp) {
204
+ let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
205
+ if (!node.comparator || !node.comparator(current, value)) {
206
+ if (Transition) {
207
+ const TransitionRunning = Transition.running;
208
+ if (TransitionRunning || !isComp && Transition.sources.has(node)) {
209
+ Transition.sources.add(node);
210
+ node.tValue = value;
211
+ }
212
+ if (!TransitionRunning)
213
+ node.value = value;
214
+ } else
215
+ node.value = value;
216
+ if (node.observers && node.observers.length) {
217
+ runUpdates(() => {
218
+ for (let i = 0;i < node.observers.length; i += 1) {
219
+ const o = node.observers[i];
220
+ const TransitionRunning = Transition && Transition.running;
221
+ if (TransitionRunning && Transition.disposed.has(o))
222
+ continue;
223
+ if (TransitionRunning ? !o.tState : !o.state) {
224
+ if (o.pure)
225
+ Updates.push(o);
226
+ else
227
+ Effects.push(o);
228
+ if (o.observers)
229
+ markDownstream(o);
230
+ }
231
+ if (!TransitionRunning)
232
+ o.state = STALE;
233
+ else
234
+ o.tState = STALE;
235
+ }
236
+ if (Updates.length > 1e6) {
237
+ Updates = [];
238
+ if (IS_DEV)
239
+ throw new Error("Potential Infinite Loop Detected.");
240
+ throw new Error;
241
+ }
242
+ }, false);
243
+ }
244
+ }
245
+ return value;
246
+ }
247
+ function updateComputation(node) {
248
+ if (!node.fn)
249
+ return;
250
+ cleanNode(node);
251
+ const time = ExecCount;
252
+ runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
253
+ if (Transition && !Transition.running && Transition.sources.has(node)) {
254
+ queueMicrotask(() => {
255
+ runUpdates(() => {
256
+ Transition && (Transition.running = true);
257
+ Listener = Owner = node;
258
+ runComputation(node, node.tValue, time);
259
+ Listener = Owner = null;
260
+ }, false);
261
+ });
262
+ }
263
+ }
264
+ function runComputation(node, value, time) {
265
+ let nextValue;
266
+ const owner = Owner, listener = Listener;
267
+ Listener = Owner = node;
268
+ try {
269
+ nextValue = node.fn(value);
270
+ } catch (err) {
271
+ if (node.pure) {
272
+ if (Transition && Transition.running) {
273
+ node.tState = STALE;
274
+ node.tOwned && node.tOwned.forEach(cleanNode);
275
+ node.tOwned = undefined;
276
+ } else {
277
+ node.state = STALE;
278
+ node.owned && node.owned.forEach(cleanNode);
279
+ node.owned = null;
280
+ }
281
+ }
282
+ node.updatedAt = time + 1;
283
+ return handleError(err);
284
+ } finally {
285
+ Listener = listener;
286
+ Owner = owner;
287
+ }
288
+ if (!node.updatedAt || node.updatedAt <= time) {
289
+ if (node.updatedAt != null && "observers" in node) {
290
+ writeSignal(node, nextValue, true);
291
+ } else if (Transition && Transition.running && node.pure) {
292
+ Transition.sources.add(node);
293
+ node.tValue = nextValue;
294
+ } else
295
+ node.value = nextValue;
296
+ node.updatedAt = time;
297
+ }
298
+ }
299
+ function createComputation(fn, init, pure, state = STALE, options) {
300
+ const c = {
301
+ fn,
302
+ state,
303
+ updatedAt: null,
304
+ owned: null,
305
+ sources: null,
306
+ sourceSlots: null,
307
+ cleanups: null,
308
+ value: init,
309
+ owner: Owner,
310
+ context: Owner ? Owner.context : null,
311
+ pure
312
+ };
313
+ if (Transition && Transition.running) {
314
+ c.state = 0;
315
+ c.tState = state;
316
+ }
317
+ if (Owner === null)
318
+ console.warn("computations created outside a `createRoot` or `render` will never be disposed");
319
+ else if (Owner !== UNOWNED) {
320
+ if (Transition && Transition.running && Owner.pure) {
321
+ if (!Owner.tOwned)
322
+ Owner.tOwned = [c];
323
+ else
324
+ Owner.tOwned.push(c);
325
+ } else {
326
+ if (!Owner.owned)
327
+ Owner.owned = [c];
328
+ else
329
+ Owner.owned.push(c);
330
+ }
331
+ }
332
+ if (options && options.name)
333
+ c.name = options.name;
334
+ if (ExternalSourceConfig && c.fn) {
335
+ const [track, trigger] = createSignal(undefined, {
336
+ equals: false
337
+ });
338
+ const ordinary = ExternalSourceConfig.factory(c.fn, trigger);
339
+ onCleanup(() => ordinary.dispose());
340
+ const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
341
+ const inTransition = ExternalSourceConfig.factory(c.fn, triggerInTransition);
342
+ c.fn = (x) => {
343
+ track();
344
+ return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
345
+ };
346
+ }
347
+ DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(c);
348
+ return c;
349
+ }
350
+ function runTop(node) {
351
+ const runningTransition = Transition && Transition.running;
352
+ if ((runningTransition ? node.tState : node.state) === 0)
353
+ return;
354
+ if ((runningTransition ? node.tState : node.state) === PENDING)
355
+ return lookUpstream(node);
356
+ if (node.suspense && untrack(node.suspense.inFallback))
357
+ return node.suspense.effects.push(node);
358
+ const ancestors = [node];
359
+ while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
360
+ if (runningTransition && Transition.disposed.has(node))
361
+ return;
362
+ if (runningTransition ? node.tState : node.state)
363
+ ancestors.push(node);
364
+ }
365
+ for (let i = ancestors.length - 1;i >= 0; i--) {
366
+ node = ancestors[i];
367
+ if (runningTransition) {
368
+ let top = node, prev = ancestors[i + 1];
369
+ while ((top = top.owner) && top !== prev) {
370
+ if (Transition.disposed.has(top))
371
+ return;
372
+ }
373
+ }
374
+ if ((runningTransition ? node.tState : node.state) === STALE) {
375
+ updateComputation(node);
376
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
377
+ const updates = Updates;
378
+ Updates = null;
379
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
380
+ Updates = updates;
381
+ }
382
+ }
383
+ }
384
+ function runUpdates(fn, init) {
385
+ if (Updates)
386
+ return fn();
387
+ let wait = false;
388
+ if (!init)
389
+ Updates = [];
390
+ if (Effects)
391
+ wait = true;
392
+ else
393
+ Effects = [];
394
+ ExecCount++;
395
+ try {
396
+ const res = fn();
397
+ completeUpdates(wait);
398
+ return res;
399
+ } catch (err) {
400
+ if (!wait)
401
+ Effects = null;
402
+ Updates = null;
403
+ handleError(err);
404
+ }
405
+ }
406
+ function completeUpdates(wait) {
407
+ if (Updates) {
408
+ if (Scheduler && Transition && Transition.running)
409
+ scheduleQueue(Updates);
410
+ else
411
+ runQueue(Updates);
412
+ Updates = null;
413
+ }
414
+ if (wait)
415
+ return;
416
+ let res;
417
+ if (Transition) {
418
+ if (!Transition.promises.size && !Transition.queue.size) {
419
+ const sources = Transition.sources;
420
+ const disposed = Transition.disposed;
421
+ Effects.push.apply(Effects, Transition.effects);
422
+ res = Transition.resolve;
423
+ for (const e2 of Effects) {
424
+ "tState" in e2 && (e2.state = e2.tState);
425
+ delete e2.tState;
426
+ }
427
+ Transition = null;
428
+ runUpdates(() => {
429
+ for (const d of disposed)
430
+ cleanNode(d);
431
+ for (const v of sources) {
432
+ v.value = v.tValue;
433
+ if (v.owned) {
434
+ for (let i = 0, len = v.owned.length;i < len; i++)
435
+ cleanNode(v.owned[i]);
436
+ }
437
+ if (v.tOwned)
438
+ v.owned = v.tOwned;
439
+ delete v.tValue;
440
+ delete v.tOwned;
441
+ v.tState = 0;
442
+ }
443
+ setTransPending(false);
444
+ }, false);
445
+ } else if (Transition.running) {
446
+ Transition.running = false;
447
+ Transition.effects.push.apply(Transition.effects, Effects);
448
+ Effects = null;
449
+ setTransPending(true);
450
+ return;
451
+ }
452
+ }
453
+ const e = Effects;
454
+ Effects = null;
455
+ if (e.length)
456
+ runUpdates(() => runEffects(e), false);
457
+ else
458
+ DevHooks.afterUpdate && DevHooks.afterUpdate();
459
+ if (res)
460
+ res();
461
+ }
462
+ function runQueue(queue) {
463
+ for (let i = 0;i < queue.length; i++)
464
+ runTop(queue[i]);
465
+ }
466
+ function scheduleQueue(queue) {
467
+ for (let i = 0;i < queue.length; i++) {
468
+ const item = queue[i];
469
+ const tasks = Transition.queue;
470
+ if (!tasks.has(item)) {
471
+ tasks.add(item);
472
+ Scheduler(() => {
473
+ tasks.delete(item);
474
+ runUpdates(() => {
475
+ Transition.running = true;
476
+ runTop(item);
477
+ }, false);
478
+ Transition && (Transition.running = false);
479
+ });
480
+ }
481
+ }
482
+ }
483
+ function lookUpstream(node, ignore) {
484
+ const runningTransition = Transition && Transition.running;
485
+ if (runningTransition)
486
+ node.tState = 0;
487
+ else
488
+ node.state = 0;
489
+ for (let i = 0;i < node.sources.length; i += 1) {
490
+ const source = node.sources[i];
491
+ if (source.sources) {
492
+ const state = runningTransition ? source.tState : source.state;
493
+ if (state === STALE) {
494
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
495
+ runTop(source);
496
+ } else if (state === PENDING)
497
+ lookUpstream(source, ignore);
498
+ }
499
+ }
500
+ }
501
+ function markDownstream(node) {
502
+ const runningTransition = Transition && Transition.running;
503
+ for (let i = 0;i < node.observers.length; i += 1) {
504
+ const o = node.observers[i];
505
+ if (runningTransition ? !o.tState : !o.state) {
506
+ if (runningTransition)
507
+ o.tState = PENDING;
508
+ else
509
+ o.state = PENDING;
510
+ if (o.pure)
511
+ Updates.push(o);
512
+ else
513
+ Effects.push(o);
514
+ o.observers && markDownstream(o);
515
+ }
516
+ }
517
+ }
518
+ function cleanNode(node) {
519
+ let i;
520
+ if (node.sources) {
521
+ while (node.sources.length) {
522
+ const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
523
+ if (obs && obs.length) {
524
+ const n = obs.pop(), s = source.observerSlots.pop();
525
+ if (index < obs.length) {
526
+ n.sourceSlots[s] = index;
527
+ obs[index] = n;
528
+ source.observerSlots[index] = s;
529
+ }
530
+ }
531
+ }
532
+ }
533
+ if (node.tOwned) {
534
+ for (i = node.tOwned.length - 1;i >= 0; i--)
535
+ cleanNode(node.tOwned[i]);
536
+ delete node.tOwned;
537
+ }
538
+ if (Transition && Transition.running && node.pure) {
539
+ reset(node, true);
540
+ } else if (node.owned) {
541
+ for (i = node.owned.length - 1;i >= 0; i--)
542
+ cleanNode(node.owned[i]);
543
+ node.owned = null;
544
+ }
545
+ if (node.cleanups) {
546
+ for (i = node.cleanups.length - 1;i >= 0; i--)
547
+ node.cleanups[i]();
548
+ node.cleanups = null;
549
+ }
550
+ if (Transition && Transition.running)
551
+ node.tState = 0;
552
+ else
553
+ node.state = 0;
554
+ delete node.sourceMap;
555
+ }
556
+ function reset(node, top) {
557
+ if (!top) {
558
+ node.tState = 0;
559
+ Transition.disposed.add(node);
560
+ }
561
+ if (node.owned) {
562
+ for (let i = 0;i < node.owned.length; i++)
563
+ reset(node.owned[i]);
564
+ }
565
+ }
566
+ function castError(err) {
567
+ if (err instanceof Error)
568
+ return err;
569
+ return new Error(typeof err === "string" ? err : "Unknown error", {
570
+ cause: err
571
+ });
572
+ }
573
+ function runErrors(err, fns, owner) {
574
+ try {
575
+ for (const f of fns)
576
+ f(err);
577
+ } catch (e) {
578
+ handleError(e, owner && owner.owner || null);
579
+ }
580
+ }
581
+ function handleError(err, owner = Owner) {
582
+ const fns = ERROR && owner && owner.context && owner.context[ERROR];
583
+ const error = castError(err);
584
+ if (!fns)
585
+ throw error;
586
+ if (Effects)
587
+ Effects.push({
588
+ fn() {
589
+ runErrors(error, fns, owner);
590
+ },
591
+ state: STALE
592
+ });
593
+ else
594
+ runErrors(error, fns, owner);
595
+ }
596
+ function resolveChildren(children2) {
597
+ if (typeof children2 === "function" && !children2.length)
598
+ return resolveChildren(children2());
599
+ if (Array.isArray(children2)) {
600
+ const results = [];
601
+ for (let i = 0;i < children2.length; i++) {
602
+ const result = resolveChildren(children2[i]);
603
+ Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
604
+ }
605
+ return results;
606
+ }
607
+ return children2;
608
+ }
609
+ function createProvider(id, options) {
610
+ return function provider(props) {
611
+ let res;
612
+ createRenderEffect(() => res = untrack(() => {
613
+ Owner.context = {
614
+ ...Owner.context,
615
+ [id]: props.value
616
+ };
617
+ return children(() => props.children);
618
+ }), undefined, options);
619
+ return res;
620
+ };
621
+ }
622
+ var FALLBACK = Symbol("fallback");
623
+ if (globalThis) {
624
+ if (!globalThis.Solid$$)
625
+ globalThis.Solid$$ = true;
626
+ else
627
+ console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
628
+ }
629
+
630
+ // src/context.tsx
631
+ var LensClientContext = createContext();
632
+ var LensProvider = (props) => {
633
+ return /* @__PURE__ */ React.createElement(LensClientContext.Provider, {
634
+ value: props.client
635
+ }, props.children);
636
+ };
637
+ function useLensClient() {
638
+ const client = useContext(LensClientContext);
639
+ if (!client) {
640
+ throw new Error("useLensClient must be used within a <LensProvider>. " + "Make sure to wrap your app with <LensProvider client={client}>.");
641
+ }
642
+ return client;
643
+ }
644
+ // src/primitives.ts
645
+ function createQuery(queryFn, options) {
646
+ const [data, setData] = createSignal(null);
647
+ const [loading, setLoading] = createSignal(!options?.skip);
648
+ const [error, setError] = createSignal(null);
649
+ let unsubscribe = null;
650
+ const executeQuery = () => {
651
+ if (options?.skip) {
652
+ setLoading(false);
653
+ return;
654
+ }
655
+ const queryResult = queryFn();
656
+ unsubscribe = queryResult.subscribe((value) => {
657
+ setData(() => value);
658
+ setLoading(false);
659
+ setError(null);
660
+ });
661
+ queryResult.then((value) => {
662
+ setData(() => value);
663
+ setLoading(false);
664
+ setError(null);
665
+ }, (err) => {
666
+ const queryError = err instanceof Error ? err : new Error(String(err));
667
+ setError(queryError);
668
+ setLoading(false);
669
+ });
670
+ };
671
+ executeQuery();
672
+ onCleanup(() => {
673
+ if (unsubscribe) {
674
+ unsubscribe();
675
+ unsubscribe = null;
676
+ }
677
+ });
678
+ const refetch = () => {
679
+ if (unsubscribe) {
680
+ unsubscribe();
681
+ unsubscribe = null;
682
+ }
683
+ setLoading(true);
684
+ setError(null);
685
+ executeQuery();
686
+ };
687
+ return {
688
+ data,
689
+ loading,
690
+ error,
691
+ refetch
692
+ };
693
+ }
694
+ function createMutation(mutationFn) {
695
+ const [data, setData] = createSignal(null);
696
+ const [loading, setLoading] = createSignal(false);
697
+ const [error, setError] = createSignal(null);
698
+ const mutate = async (input) => {
699
+ setLoading(true);
700
+ setError(null);
701
+ try {
702
+ const result = await mutationFn(input);
703
+ setData(() => result.data);
704
+ setLoading(false);
705
+ return result;
706
+ } catch (err) {
707
+ const mutationError = err instanceof Error ? err : new Error(String(err));
708
+ setError(mutationError);
709
+ setLoading(false);
710
+ throw mutationError;
711
+ }
712
+ };
713
+ const reset2 = () => {
714
+ setData(null);
715
+ setLoading(false);
716
+ setError(null);
717
+ };
718
+ return {
719
+ data,
720
+ loading,
721
+ error,
722
+ mutate,
723
+ reset: reset2
724
+ };
725
+ }
726
+ function createLazyQuery(queryFn) {
727
+ const [data, setData] = createSignal(null);
728
+ const [loading, setLoading] = createSignal(false);
729
+ const [error, setError] = createSignal(null);
730
+ const execute = async () => {
731
+ setLoading(true);
732
+ setError(null);
733
+ try {
734
+ const queryResult = queryFn();
735
+ const result = await queryResult;
736
+ setData(() => result);
737
+ setLoading(false);
738
+ return result;
739
+ } catch (err) {
740
+ const queryError = err instanceof Error ? err : new Error(String(err));
741
+ setError(queryError);
742
+ setLoading(false);
743
+ throw queryError;
744
+ }
745
+ };
746
+ const reset2 = () => {
747
+ setData(null);
748
+ setLoading(false);
749
+ setError(null);
750
+ };
751
+ return {
752
+ data,
753
+ loading,
754
+ error,
755
+ execute,
756
+ reset: reset2
757
+ };
758
+ }
759
+ export {
760
+ useLensClient,
761
+ createQuery,
762
+ createMutation,
763
+ createLazyQuery,
764
+ LensProvider
765
+ };