@akanjs/next 0.0.4

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.
@@ -0,0 +1,615 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useCsrValues_exports = {};
20
+ __export(useCsrValues_exports, {
21
+ useCsrValues: () => useCsrValues
22
+ });
23
+ module.exports = __toCommonJS(useCsrValues_exports);
24
+ var import_client = require("@akanjs/client");
25
+ var import_app = require("@capacitor/app");
26
+ var import_web = require("@react-spring/web");
27
+ var import_react = require("@use-gesture/react");
28
+ var import_react2 = require("react");
29
+ var import_useHistory = require("./useHistory");
30
+ var import_useLocation = require("./useLocation");
31
+ const useNoneTrans = ({ clientHeight, location, prevLocation }) => {
32
+ const transDirection = "none";
33
+ const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
34
+ const transUnitRange = (0, import_react2.useMemo)(() => [0, 0], []);
35
+ const transProgress = transUnit.to((unit) => 1);
36
+ const transPercent = transUnit.to((unit) => 100);
37
+ const pageState = location.pathRoute.pageState;
38
+ const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
39
+ const csrTranstionStyles = {
40
+ topSafeArea: {
41
+ containerStyle: {
42
+ height: pageState.topSafeArea
43
+ }
44
+ },
45
+ bottomSafeArea: {
46
+ containerStyle: {
47
+ top: clientHeight - pageState.bottomSafeArea,
48
+ height: pageState.bottomSafeArea
49
+ }
50
+ },
51
+ page: {
52
+ containerStyle: {},
53
+ contentStyle: {
54
+ paddingTop: pageState.topSafeArea + pageState.topInset,
55
+ paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
56
+ height: clientHeight
57
+ }
58
+ },
59
+ prevPage: {
60
+ containerStyle: {
61
+ paddingTop: prevPageState.topSafeArea + prevPageState.topInset
62
+ },
63
+ contentStyle: { opacity: 0 }
64
+ },
65
+ topInset: {
66
+ containerStyle: {
67
+ top: pageState.topSafeArea,
68
+ height: pageState.topInset
69
+ },
70
+ contentStyle: { opacity: 1 },
71
+ prevContentStyle: { opacity: 0 }
72
+ },
73
+ topLeftAction: {
74
+ containerStyle: {
75
+ top: pageState.topSafeArea,
76
+ height: pageState.topInset
77
+ },
78
+ contentStyle: { opacity: 1 },
79
+ prevContentStyle: { opacity: 0 }
80
+ },
81
+ bottomInset: {
82
+ containerStyle: {
83
+ height: pageState.bottomInset,
84
+ top: clientHeight - pageState.bottomInset - pageState.bottomSafeArea
85
+ },
86
+ contentStyle: { opacity: 1 },
87
+ prevContentStyle: { opacity: 0 }
88
+ }
89
+ };
90
+ const useCsrTransition = {
91
+ ...csrTranstionStyles,
92
+ pageBind: () => ({}),
93
+ pageClassName: "touch-pan-y",
94
+ transDirection,
95
+ transUnitRange,
96
+ transUnit,
97
+ transPercent,
98
+ transProgress
99
+ };
100
+ return useCsrTransition;
101
+ };
102
+ const useFadeTrans = ({ clientHeight, location, prevLocation, onBack, history }) => {
103
+ const transDirection = "none";
104
+ const transUnit = (0, import_web.useSpringValue)(1, { config: { clamp: true } });
105
+ const transUnitRange = (0, import_react2.useMemo)(() => [0, 1], []);
106
+ const transProgress = transUnit.to((unit) => unit);
107
+ const transPercent = transUnit.to([0, 1], [0, 100], "clamp");
108
+ const pageState = location.pathRoute.pageState;
109
+ const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
110
+ (0, import_react2.useEffect)(() => {
111
+ onBack.current.fade = async () => {
112
+ await transUnit.start(transUnitRange[0]);
113
+ };
114
+ }, []);
115
+ (0, import_react2.useEffect)(() => {
116
+ if (history.current.type === "forward") {
117
+ void transUnit.start(transUnitRange[0], { immediate: true });
118
+ void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
119
+ } else {
120
+ void transUnit.start(transUnitRange[1], { immediate: true });
121
+ return;
122
+ }
123
+ }, [location.pathname]);
124
+ const csrTranstionStyles = {
125
+ topSafeArea: {
126
+ containerStyle: {
127
+ height: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea])
128
+ }
129
+ },
130
+ bottomSafeArea: {
131
+ containerStyle: {
132
+ top: transProgress.to(
133
+ [0, 1],
134
+ [clientHeight - prevPageState.bottomSafeArea, clientHeight - pageState.bottomSafeArea]
135
+ ),
136
+ height: transProgress.to([0, 1], [prevPageState.bottomSafeArea, pageState.bottomSafeArea])
137
+ }
138
+ },
139
+ page: {
140
+ containerStyle: {},
141
+ contentStyle: {
142
+ paddingTop: pageState.topSafeArea + pageState.topInset,
143
+ paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
144
+ opacity: transUnit,
145
+ height: clientHeight
146
+ }
147
+ },
148
+ prevPage: {
149
+ containerStyle: {
150
+ paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
151
+ opacity: transProgress.to((progress) => 1 - progress)
152
+ },
153
+ contentStyle: {}
154
+ },
155
+ topInset: {
156
+ containerStyle: {
157
+ top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
158
+ height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
159
+ },
160
+ contentStyle: {
161
+ opacity: transProgress
162
+ },
163
+ prevContentStyle: {
164
+ opacity: transProgress.to((progress) => 1 - progress)
165
+ }
166
+ },
167
+ topLeftAction: {
168
+ containerStyle: {
169
+ top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
170
+ height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
171
+ },
172
+ contentStyle: {
173
+ opacity: transProgress.to((progress) => progress)
174
+ },
175
+ prevContentStyle: {
176
+ opacity: transProgress.to((progress) => 1 - progress)
177
+ }
178
+ },
179
+ bottomInset: {
180
+ containerStyle: {
181
+ height: transProgress.to([0, 1], [prevPageState.bottomInset, pageState.bottomInset]),
182
+ top: transProgress.to(
183
+ [0, 1],
184
+ [
185
+ clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
186
+ clientHeight - pageState.bottomInset - pageState.bottomSafeArea
187
+ ]
188
+ )
189
+ },
190
+ contentStyle: {
191
+ top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
192
+ opacity: transProgress.to((progress) => progress)
193
+ },
194
+ prevContentStyle: {
195
+ top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
196
+ opacity: transProgress.to((progress) => 1 - progress)
197
+ }
198
+ }
199
+ };
200
+ const useCsrTransition = {
201
+ ...csrTranstionStyles,
202
+ pageBind: () => ({}),
203
+ pageClassName: "",
204
+ transDirection,
205
+ transUnitRange,
206
+ transUnit,
207
+ transPercent,
208
+ transProgress
209
+ };
210
+ return useCsrTransition;
211
+ };
212
+ const useStackTrans = ({
213
+ clientWidth,
214
+ clientHeight,
215
+ location,
216
+ prevLocation,
217
+ history,
218
+ onBack
219
+ }) => {
220
+ const transDirection = "horizontal";
221
+ const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
222
+ const transUnitRange = (0, import_react2.useMemo)(() => [clientWidth, 0], []);
223
+ const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
224
+ const transUnitRangeReversed = (0, import_react2.useMemo)(() => [0, clientWidth], []);
225
+ const transProgress = transUnitReversed.to(transUnitRangeReversed, [0, 1], "clamp");
226
+ const transPercent = transUnitReversed.to(transUnitRangeReversed, [0, 100], "clamp");
227
+ const initThreshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth), []);
228
+ const threshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 3), []);
229
+ const pageState = location.pathRoute.pageState;
230
+ const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
231
+ const pageClassName = "touch-pan-y";
232
+ (0, import_react2.useEffect)(() => {
233
+ onBack.current.stack = async () => {
234
+ await transUnit.start(transUnitRange[0]);
235
+ };
236
+ }, []);
237
+ (0, import_react2.useEffect)(() => {
238
+ if (history.current.type === "forward") {
239
+ void transUnit.start(transUnitRange[0], { immediate: true });
240
+ void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
241
+ } else {
242
+ void transUnit.start(transUnitRange[1], { immediate: true });
243
+ return;
244
+ }
245
+ }, [location.pathname]);
246
+ const pageBind = (0, import_react.useDrag)(
247
+ ({ first, down, last, movement: [mx], initial: [ix], cancel }) => {
248
+ if (first)
249
+ void import_client.device.hideKeyboard();
250
+ if (ix > initThreshold) {
251
+ cancel();
252
+ return;
253
+ }
254
+ if (mx < transUnitRange[1])
255
+ void transUnit.start(transUnitRange[1], { immediate: true });
256
+ else if (mx > transUnitRange[0])
257
+ void transUnit.start(transUnitRange[0], { immediate: true });
258
+ else if (!last)
259
+ void transUnit.start(mx, { immediate: true });
260
+ else if (mx < threshold)
261
+ void transUnit.start(transUnitRange[1]);
262
+ if (last && mx > threshold)
263
+ import_client.router.back();
264
+ },
265
+ { axis: "x", filterTaps: true }
266
+ );
267
+ const csrTranstionStyles = {
268
+ topSafeArea: {
269
+ containerStyle: {
270
+ height: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea])
271
+ }
272
+ },
273
+ bottomSafeArea: {
274
+ containerStyle: {
275
+ top: transProgress.to(
276
+ [0, 1],
277
+ [clientHeight - prevPageState.bottomSafeArea, clientHeight - pageState.bottomSafeArea]
278
+ ),
279
+ height: transProgress.to([0, 1], [prevPageState.bottomSafeArea, pageState.bottomSafeArea])
280
+ }
281
+ },
282
+ page: {
283
+ containerStyle: {},
284
+ contentStyle: {
285
+ paddingTop: pageState.topSafeArea + pageState.topInset,
286
+ paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
287
+ translateX: transUnit,
288
+ height: clientHeight
289
+ }
290
+ },
291
+ prevPage: {
292
+ containerStyle: {
293
+ paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
294
+ translateX: transUnit.to((unit) => (unit - clientWidth) / 5)
295
+ },
296
+ contentStyle: {
297
+ opacity: transProgress.to((progress) => 1 - progress / 2)
298
+ }
299
+ },
300
+ topInset: {
301
+ containerStyle: {
302
+ top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
303
+ height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
304
+ },
305
+ contentStyle: {
306
+ opacity: transProgress.to((progress) => progress),
307
+ translateX: transProgress.to([0, 1], [clientWidth / 5, 0])
308
+ },
309
+ prevContentStyle: {
310
+ opacity: transProgress.to((progress) => 1 - progress),
311
+ translateX: transProgress.to([0, 1], [0, -clientWidth / 5])
312
+ }
313
+ },
314
+ topLeftAction: {
315
+ containerStyle: {
316
+ top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
317
+ height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset]),
318
+ minWidth: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
319
+ },
320
+ contentStyle: {
321
+ opacity: transProgress.to((progress) => progress)
322
+ },
323
+ prevContentStyle: {
324
+ opacity: transProgress.to((progress) => 1 - progress)
325
+ }
326
+ },
327
+ bottomInset: {
328
+ containerStyle: {
329
+ height: transProgress.to([0, 1], [prevPageState.bottomInset, pageState.bottomInset]),
330
+ top: transProgress.to(
331
+ [0, 1],
332
+ [
333
+ clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
334
+ clientHeight - pageState.bottomInset - pageState.bottomSafeArea
335
+ ]
336
+ )
337
+ },
338
+ contentStyle: {
339
+ top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
340
+ opacity: transProgress.to((progress) => progress)
341
+ },
342
+ prevContentStyle: {
343
+ top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
344
+ opacity: transProgress.to((progress) => 1 - progress)
345
+ }
346
+ }
347
+ };
348
+ const useCsrTransition = {
349
+ ...csrTranstionStyles,
350
+ pageBind,
351
+ pageClassName,
352
+ transDirection,
353
+ transUnitRange,
354
+ transUnit,
355
+ transPercent,
356
+ transProgress
357
+ };
358
+ return useCsrTransition;
359
+ };
360
+ const useBottomUpTrans = ({
361
+ clientWidth,
362
+ clientHeight,
363
+ history,
364
+ location,
365
+ prevLocation,
366
+ onBack
367
+ }) => {
368
+ const transDirection = "vertical";
369
+ const transUnit = (0, import_web.useSpringValue)(0, { config: { clamp: true } });
370
+ const transUnitRange = (0, import_react2.useMemo)(() => [clientHeight, 0], []);
371
+ const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
372
+ const transUnitRangeReversed = (0, import_react2.useMemo)(() => [0, clientWidth], []);
373
+ const transProgress = transUnitReversed.to(transUnitRangeReversed, [0, 1], "clamp");
374
+ const transPercent = transUnitReversed.to(transUnitRangeReversed, [0, 100], "clamp");
375
+ const initThreshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 3), []);
376
+ const threshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 2), []);
377
+ const pageState = location.pathRoute.pageState;
378
+ const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
379
+ (0, import_react2.useEffect)(() => {
380
+ onBack.current.bottomUp = async () => {
381
+ await transUnit.start(transUnitRange[0]);
382
+ };
383
+ }, []);
384
+ (0, import_react2.useEffect)(() => {
385
+ if (history.current.type === "forward") {
386
+ void transUnit.start(transUnitRange[0], { immediate: true });
387
+ void transUnit.start(transUnitRange[1], { config: { duration: 150 } });
388
+ } else {
389
+ void transUnit.start(transUnitRange[1], { immediate: true });
390
+ return;
391
+ }
392
+ }, [location.pathname]);
393
+ const pageBind = (0, import_react.useDrag)(
394
+ ({ first, last, movement: [, my], initial: [, iy], cancel }) => {
395
+ if (first)
396
+ void import_client.device.hideKeyboard();
397
+ if (iy > initThreshold) {
398
+ cancel();
399
+ return;
400
+ }
401
+ if (my < transUnitRange[1])
402
+ void transUnit.start(transUnitRange[1], { immediate: true });
403
+ else if (my > transUnitRange[0])
404
+ void transUnit.start(transUnitRange[0], { immediate: true });
405
+ else if (!last)
406
+ void transUnit.start(my, { immediate: true });
407
+ else if (my < threshold)
408
+ void transUnit.start(transUnitRange[1]);
409
+ if (last && my > threshold)
410
+ import_client.router.back();
411
+ },
412
+ { axis: "y", filterTaps: true, threshold: 10 }
413
+ );
414
+ const csrTranstionStyles = {
415
+ topSafeArea: {
416
+ containerStyle: {
417
+ height: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea])
418
+ }
419
+ },
420
+ bottomSafeArea: {
421
+ containerStyle: {
422
+ top: transProgress.to(
423
+ [0, 1],
424
+ [clientHeight - prevPageState.bottomSafeArea, clientHeight - pageState.bottomSafeArea]
425
+ ),
426
+ height: transProgress.to([0, 1], [prevPageState.bottomSafeArea, pageState.bottomSafeArea])
427
+ }
428
+ },
429
+ page: {
430
+ containerStyle: {},
431
+ contentStyle: {
432
+ paddingTop: pageState.topSafeArea + pageState.topInset,
433
+ paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
434
+ translateY: transUnit,
435
+ height: clientHeight
436
+ }
437
+ },
438
+ prevPage: {
439
+ containerStyle: {
440
+ paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
441
+ translateY: 0
442
+ },
443
+ contentStyle: {
444
+ opacity: transProgress.to((progress) => 1 - progress / 2)
445
+ }
446
+ },
447
+ topInset: {
448
+ containerStyle: {
449
+ top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
450
+ height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
451
+ },
452
+ contentStyle: {
453
+ opacity: transProgress.to((progress) => progress)
454
+ // translateX: transProgress.to([0, 1], [clientWidth / 5, 0]),
455
+ },
456
+ prevContentStyle: {
457
+ opacity: transProgress.to((progress) => 1 - progress)
458
+ // translateX: transProgress.to([0, 1], [0, -clientWidth / 5]),
459
+ }
460
+ },
461
+ topLeftAction: {
462
+ containerStyle: {
463
+ top: transProgress.to([0, 1], [prevPageState.topSafeArea, pageState.topSafeArea]),
464
+ height: transProgress.to([0, 1], [prevPageState.topInset, pageState.topInset])
465
+ },
466
+ contentStyle: {
467
+ opacity: transProgress.to((progress) => progress)
468
+ },
469
+ prevContentStyle: {
470
+ opacity: transProgress.to((progress) => 1 - progress)
471
+ }
472
+ },
473
+ bottomInset: {
474
+ containerStyle: {
475
+ height: transProgress.to([0, 1], [prevPageState.bottomInset, pageState.bottomInset]),
476
+ top: transProgress.to(
477
+ [0, 1],
478
+ [
479
+ clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
480
+ clientHeight - pageState.bottomInset - pageState.bottomSafeArea
481
+ ]
482
+ )
483
+ },
484
+ contentStyle: {
485
+ top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
486
+ opacity: transProgress.to((progress) => progress)
487
+ },
488
+ prevContentStyle: {
489
+ top: transProgress.to([0, 1], [0, -(pageState.bottomInset - prevPageState.bottomInset) * 2]),
490
+ opacity: transProgress.to((progress) => 1 - progress)
491
+ }
492
+ }
493
+ };
494
+ const useCsrTransition = {
495
+ ...csrTranstionStyles,
496
+ pageBind,
497
+ pageClassName: "touch-pan-x",
498
+ transDirection,
499
+ transUnitRange,
500
+ transUnit,
501
+ transPercent,
502
+ transProgress
503
+ };
504
+ return useCsrTransition;
505
+ };
506
+ const useCsrValues = (rootRouteGuide, pathRoutes) => {
507
+ const clientWidth = (0, import_react2.useRef)(window.innerWidth);
508
+ const clientHeight = (0, import_react2.useRef)(window.innerHeight);
509
+ const topSafeAreaRef = (0, import_react2.useRef)(null);
510
+ const bottomSafeAreaRef = (0, import_react2.useRef)(null);
511
+ const pageContentRef = (0, import_react2.useRef)(null);
512
+ const prevPageContentRef = (0, import_react2.useRef)(null);
513
+ const onBack = (0, import_react2.useRef)({});
514
+ const frameRootRef = (0, import_react2.useRef)(null);
515
+ const { getLocation } = (0, import_useLocation.useLocation)({ rootRouteGuide });
516
+ const { history, setHistoryForward, setHistoryBack, getCurrentLocation, getPrevLocation, getScrollTop } = (0, import_useHistory.useHistory)([
517
+ getLocation(window.location.pathname)
518
+ ]);
519
+ const [{ location, prevLocation }, setLocationState] = (0, import_react2.useState)({
520
+ location: getCurrentLocation(),
521
+ prevLocation: getPrevLocation()
522
+ });
523
+ const getRouter = (0, import_react2.useCallback)(() => {
524
+ const router3 = {
525
+ push: (href) => {
526
+ const location2 = getCurrentLocation();
527
+ const scrollTop = pageContentRef.current?.scrollTop ?? 0;
528
+ setHistoryForward({ type: "push", location: getLocation(href), scrollTop });
529
+ setLocationState({ location: getCurrentLocation(), prevLocation: location2 });
530
+ window.history.pushState({}, "", href);
531
+ },
532
+ replace: (href) => {
533
+ const scrollTop = pageContentRef.current?.scrollTop ?? 0;
534
+ setHistoryForward({ type: "replace", location: getLocation(href), scrollTop });
535
+ setLocationState({ location: getCurrentLocation(), prevLocation });
536
+ window.history.replaceState({}, "", href);
537
+ },
538
+ refresh: () => {
539
+ window.location.reload();
540
+ },
541
+ back: async () => {
542
+ const location2 = getCurrentLocation();
543
+ await onBack.current[location2.pathRoute.pageState.transition]?.();
544
+ const scrollTop = pageContentRef.current?.scrollTop ?? 0;
545
+ setHistoryBack({ type: "back", location: location2, scrollTop });
546
+ setLocationState({ location: getCurrentLocation(), prevLocation: getPrevLocation() });
547
+ window.history.back();
548
+ }
549
+ };
550
+ window.onpopstate = async (ev) => {
551
+ const routeType = window.location.pathname === getCurrentLocation().pathname ? "forward" : window.location.pathname === getPrevLocation()?.pathname ? "back" : null;
552
+ const scrollTop = pageContentRef.current?.scrollTop ?? 0;
553
+ if (!routeType)
554
+ return;
555
+ if (routeType === "forward") {
556
+ const location2 = getCurrentLocation();
557
+ setHistoryForward({ type: "popForward", location: location2, scrollTop });
558
+ setLocationState({ location: getCurrentLocation(), prevLocation: location2 });
559
+ } else {
560
+ const location2 = getCurrentLocation();
561
+ await onBack.current[location2.pathRoute.pageState.transition]?.();
562
+ setHistoryBack({ type: "popBack", location: location2, scrollTop });
563
+ setLocationState({ location: getCurrentLocation(), prevLocation: getPrevLocation() });
564
+ }
565
+ };
566
+ return router3;
567
+ }, [location]);
568
+ const router2 = getRouter();
569
+ const routeState = {
570
+ clientWidth: clientWidth.current,
571
+ clientHeight: clientHeight.current,
572
+ location,
573
+ prevLocation,
574
+ history,
575
+ topSafeAreaRef,
576
+ bottomSafeAreaRef,
577
+ prevPageContentRef,
578
+ pageContentRef,
579
+ frameRootRef,
580
+ onBack,
581
+ router: router2,
582
+ pathRoutes
583
+ };
584
+ const useNonTransition = useNoneTrans(routeState);
585
+ const useFadeTransition = useFadeTrans(routeState);
586
+ const useStackTransition = useStackTrans(routeState);
587
+ const useBottomUpTransition = useBottomUpTrans(routeState);
588
+ const useCsrTransitionMap = {
589
+ none: useNonTransition,
590
+ fade: useFadeTransition,
591
+ stack: useStackTransition,
592
+ bottomUp: useBottomUpTransition,
593
+ scaleOut: useNonTransition
594
+ };
595
+ (0, import_react2.useEffect)(() => {
596
+ if (pageContentRef.current)
597
+ pageContentRef.current.scrollTop = getScrollTop(location.pathname);
598
+ if (prevPageContentRef.current)
599
+ prevPageContentRef.current.scrollTop = prevLocation ? getScrollTop(prevLocation.pathname) : 0;
600
+ void import_app.App.addListener("backButton", () => {
601
+ router2.back();
602
+ });
603
+ return () => {
604
+ void import_app.App.removeAllListeners();
605
+ };
606
+ }, [location.pathname]);
607
+ return {
608
+ ...routeState,
609
+ ...useCsrTransitionMap[location.pathRoute.pageState.transition]
610
+ };
611
+ };
612
+ // Annotate the CommonJS export names for ESM import in node:
613
+ 0 && (module.exports = {
614
+ useCsrValues
615
+ });
@@ -0,0 +1 @@
1
+ export declare const useDebounce: <Callback extends (...args: any) => any>(callback: Callback, states?: any[], wait?: number) => Callback;
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useDebounce_exports = {};
20
+ __export(useDebounce_exports, {
21
+ useDebounce: () => useDebounce
22
+ });
23
+ module.exports = __toCommonJS(useDebounce_exports);
24
+ var import_react = require("react");
25
+ const debounce = (callback, wait = 500) => {
26
+ let timer;
27
+ return (...args) => {
28
+ clearTimeout(timer);
29
+ timer = setTimeout(() => {
30
+ callback(...args);
31
+ }, wait);
32
+ };
33
+ };
34
+ const useDebounce = (callback, states = [], wait = 100) => {
35
+ const fn = (0, import_react.useCallback)(debounce(callback, wait), states);
36
+ return fn;
37
+ };
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ useDebounce
41
+ });
@@ -0,0 +1,6 @@
1
+ export declare const useFetch: <Return>(fnOrPromise: Promise<Return> | Return, { onError }?: {
2
+ onError?: (err: string) => void;
3
+ }) => {
4
+ fulfilled: boolean;
5
+ value: Return | null;
6
+ };