@akanjs/next 0.0.39 → 0.0.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.
Files changed (46) hide show
  1. package/csrTypes-B6ATv9-y.d.ts +88 -0
  2. package/index.d.ts +33 -0
  3. package/index.js +20 -2723
  4. package/package.json +2 -35
  5. package/src/bootCsr.d.ts +3 -0
  6. package/src/bootCsr.js +206 -0
  7. package/src/createNextMiddleware.d.ts +5 -0
  8. package/src/createNextMiddleware.js +88 -0
  9. package/src/createRobotPage.d.ts +5 -0
  10. package/src/createRobotPage.js +39 -0
  11. package/src/createSitemapPage.d.ts +5 -0
  12. package/src/createSitemapPage.js +34 -0
  13. package/src/index.d.ts +33 -0
  14. package/src/index.js +82 -0
  15. package/src/lazy.d.ts +8 -0
  16. package/src/lazy.js +40 -0
  17. package/src/makePageProto.d.ts +42 -0
  18. package/src/makePageProto.js +147 -0
  19. package/src/types.d.ts +9 -0
  20. package/src/types.js +15 -0
  21. package/src/useCamera.d.ts +11 -0
  22. package/src/useCamera.js +114 -0
  23. package/src/useCodepush.d.ts +51 -0
  24. package/src/useCodepush.js +115 -0
  25. package/src/useContact.d.ts +10 -0
  26. package/src/useContact.js +73 -0
  27. package/src/useCsrValues.d.ts +44 -0
  28. package/src/useCsrValues.js +924 -0
  29. package/src/useDebounce.d.ts +3 -0
  30. package/src/useDebounce.js +42 -0
  31. package/src/useFetch.d.ts +8 -0
  32. package/src/useFetch.js +54 -0
  33. package/src/useGeoLocation.d.ts +12 -0
  34. package/src/useGeoLocation.js +51 -0
  35. package/src/useHistory.d.ts +24 -0
  36. package/src/useHistory.js +88 -0
  37. package/src/useInterval.d.ts +5 -0
  38. package/src/useInterval.js +49 -0
  39. package/src/useLocation.d.ts +12 -0
  40. package/src/useLocation.js +92 -0
  41. package/src/usePurchase.d.ts +20 -0
  42. package/src/usePurchase.js +139 -0
  43. package/src/usePushNoti.d.ts +8 -0
  44. package/src/usePushNoti.js +68 -0
  45. package/src/useThrottle.d.ts +3 -0
  46. package/src/useThrottle.js +44 -0
@@ -0,0 +1,924 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var useCsrValues_exports = {};
21
+ __export(useCsrValues_exports, {
22
+ useCsrValues: () => useCsrValues
23
+ });
24
+ module.exports = __toCommonJS(useCsrValues_exports);
25
+ var import_client = require("@akanjs/client");
26
+ var import_app = require("@capacitor/app");
27
+ var import_web = require("@react-spring/web");
28
+ var import_react = require("@use-gesture/react");
29
+ var import_react2 = require("react");
30
+ var import_useHistory = require("./useHistory");
31
+ var import_useLocation = require("./useLocation");
32
+ const useNoneTrans = /* @__PURE__ */ __name(({ clientHeight, location, prevLocation }) => {
33
+ const transDirection = "none";
34
+ const transUnit = (0, import_web.useSpringValue)(0, {
35
+ config: {
36
+ clamp: true
37
+ }
38
+ });
39
+ const transUnitRange = (0, import_react2.useMemo)(() => [
40
+ 0,
41
+ 0
42
+ ], []);
43
+ const transProgress = transUnit.to((unit) => 1);
44
+ const transPercent = transUnit.to((unit) => 100);
45
+ const pageState = location.pathRoute.pageState;
46
+ const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
47
+ const csrTranstionStyles = {
48
+ topSafeArea: {
49
+ containerStyle: {
50
+ height: pageState.topSafeArea
51
+ }
52
+ },
53
+ bottomSafeArea: {
54
+ containerStyle: {
55
+ top: clientHeight - pageState.bottomSafeArea,
56
+ height: pageState.bottomSafeArea
57
+ }
58
+ },
59
+ page: {
60
+ containerStyle: {},
61
+ contentStyle: {
62
+ paddingTop: pageState.topSafeArea + pageState.topInset,
63
+ paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
64
+ height: clientHeight
65
+ }
66
+ },
67
+ prevPage: {
68
+ containerStyle: {
69
+ paddingTop: prevPageState.topSafeArea + prevPageState.topInset
70
+ },
71
+ contentStyle: {
72
+ opacity: 0
73
+ }
74
+ },
75
+ topInset: {
76
+ containerStyle: {
77
+ top: pageState.topSafeArea,
78
+ height: pageState.topInset
79
+ },
80
+ contentStyle: {
81
+ opacity: 1
82
+ },
83
+ prevContentStyle: {
84
+ opacity: 0
85
+ }
86
+ },
87
+ topLeftAction: {
88
+ containerStyle: {
89
+ top: pageState.topSafeArea,
90
+ height: pageState.topInset
91
+ },
92
+ contentStyle: {
93
+ opacity: 1
94
+ },
95
+ prevContentStyle: {
96
+ opacity: 0
97
+ }
98
+ },
99
+ bottomInset: {
100
+ containerStyle: {
101
+ height: pageState.bottomInset,
102
+ top: clientHeight - pageState.bottomInset - pageState.bottomSafeArea
103
+ },
104
+ contentStyle: {
105
+ opacity: 1
106
+ },
107
+ prevContentStyle: {
108
+ opacity: 0
109
+ }
110
+ }
111
+ };
112
+ const useCsrTransition = {
113
+ ...csrTranstionStyles,
114
+ pageBind: /* @__PURE__ */ __name(() => ({}), "pageBind"),
115
+ pageClassName: "touch-pan-y",
116
+ transDirection,
117
+ transUnitRange,
118
+ transUnit,
119
+ transPercent,
120
+ transProgress
121
+ };
122
+ return useCsrTransition;
123
+ }, "useNoneTrans");
124
+ const useFadeTrans = /* @__PURE__ */ __name(({ clientHeight, location, prevLocation, onBack, history }) => {
125
+ const transDirection = "none";
126
+ const transUnit = (0, import_web.useSpringValue)(1, {
127
+ config: {
128
+ clamp: true
129
+ }
130
+ });
131
+ const transUnitRange = (0, import_react2.useMemo)(() => [
132
+ 0,
133
+ 1
134
+ ], []);
135
+ const transProgress = transUnit.to((unit) => unit);
136
+ const transPercent = transUnit.to([
137
+ 0,
138
+ 1
139
+ ], [
140
+ 0,
141
+ 100
142
+ ], "clamp");
143
+ const pageState = location.pathRoute.pageState;
144
+ const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
145
+ (0, import_react2.useEffect)(() => {
146
+ onBack.current.fade = async () => {
147
+ await transUnit.start(transUnitRange[0]);
148
+ };
149
+ }, []);
150
+ (0, import_react2.useEffect)(() => {
151
+ if (history.current.type === "forward") {
152
+ void transUnit.start(transUnitRange[0], {
153
+ immediate: true
154
+ });
155
+ void transUnit.start(transUnitRange[1], {
156
+ config: {
157
+ duration: 150
158
+ }
159
+ });
160
+ } else {
161
+ void transUnit.start(transUnitRange[1], {
162
+ immediate: true
163
+ });
164
+ return;
165
+ }
166
+ }, [
167
+ location.pathname
168
+ ]);
169
+ const csrTranstionStyles = {
170
+ topSafeArea: {
171
+ containerStyle: {
172
+ height: transProgress.to([
173
+ 0,
174
+ 1
175
+ ], [
176
+ prevPageState.topSafeArea,
177
+ pageState.topSafeArea
178
+ ])
179
+ }
180
+ },
181
+ bottomSafeArea: {
182
+ containerStyle: {
183
+ top: transProgress.to([
184
+ 0,
185
+ 1
186
+ ], [
187
+ clientHeight - prevPageState.bottomSafeArea,
188
+ clientHeight - pageState.bottomSafeArea
189
+ ]),
190
+ height: transProgress.to([
191
+ 0,
192
+ 1
193
+ ], [
194
+ prevPageState.bottomSafeArea,
195
+ pageState.bottomSafeArea
196
+ ])
197
+ }
198
+ },
199
+ page: {
200
+ containerStyle: {},
201
+ contentStyle: {
202
+ paddingTop: pageState.topSafeArea + pageState.topInset,
203
+ paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
204
+ opacity: transUnit,
205
+ height: clientHeight
206
+ }
207
+ },
208
+ prevPage: {
209
+ containerStyle: {
210
+ paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
211
+ opacity: transProgress.to((progress) => 1 - progress)
212
+ },
213
+ contentStyle: {}
214
+ },
215
+ topInset: {
216
+ containerStyle: {
217
+ top: transProgress.to([
218
+ 0,
219
+ 1
220
+ ], [
221
+ prevPageState.topSafeArea,
222
+ pageState.topSafeArea
223
+ ]),
224
+ height: transProgress.to([
225
+ 0,
226
+ 1
227
+ ], [
228
+ prevPageState.topInset,
229
+ pageState.topInset
230
+ ])
231
+ },
232
+ contentStyle: {
233
+ opacity: transProgress
234
+ },
235
+ prevContentStyle: {
236
+ opacity: transProgress.to((progress) => 1 - progress)
237
+ }
238
+ },
239
+ topLeftAction: {
240
+ containerStyle: {
241
+ top: transProgress.to([
242
+ 0,
243
+ 1
244
+ ], [
245
+ prevPageState.topSafeArea,
246
+ pageState.topSafeArea
247
+ ]),
248
+ height: transProgress.to([
249
+ 0,
250
+ 1
251
+ ], [
252
+ prevPageState.topInset,
253
+ pageState.topInset
254
+ ])
255
+ },
256
+ contentStyle: {
257
+ opacity: transProgress.to((progress) => progress)
258
+ },
259
+ prevContentStyle: {
260
+ opacity: transProgress.to((progress) => 1 - progress)
261
+ }
262
+ },
263
+ bottomInset: {
264
+ containerStyle: {
265
+ height: transProgress.to([
266
+ 0,
267
+ 1
268
+ ], [
269
+ prevPageState.bottomInset,
270
+ pageState.bottomInset
271
+ ]),
272
+ top: transProgress.to([
273
+ 0,
274
+ 1
275
+ ], [
276
+ clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
277
+ clientHeight - pageState.bottomInset - pageState.bottomSafeArea
278
+ ])
279
+ },
280
+ contentStyle: {
281
+ top: transProgress.to([
282
+ 0,
283
+ 1
284
+ ], [
285
+ 0,
286
+ -(pageState.bottomInset - prevPageState.bottomInset) * 2
287
+ ]),
288
+ opacity: transProgress.to((progress) => progress)
289
+ },
290
+ prevContentStyle: {
291
+ top: transProgress.to([
292
+ 0,
293
+ 1
294
+ ], [
295
+ 0,
296
+ -(pageState.bottomInset - prevPageState.bottomInset) * 2
297
+ ]),
298
+ opacity: transProgress.to((progress) => 1 - progress)
299
+ }
300
+ }
301
+ };
302
+ const useCsrTransition = {
303
+ ...csrTranstionStyles,
304
+ pageBind: /* @__PURE__ */ __name(() => ({}), "pageBind"),
305
+ pageClassName: "",
306
+ transDirection,
307
+ transUnitRange,
308
+ transUnit,
309
+ transPercent,
310
+ transProgress
311
+ };
312
+ return useCsrTransition;
313
+ }, "useFadeTrans");
314
+ const useStackTrans = /* @__PURE__ */ __name(({ clientWidth, clientHeight, location, prevLocation, history, onBack }) => {
315
+ const transDirection = "horizontal";
316
+ const transUnit = (0, import_web.useSpringValue)(0, {
317
+ config: {
318
+ clamp: true
319
+ }
320
+ });
321
+ const transUnitRange = (0, import_react2.useMemo)(() => [
322
+ clientWidth,
323
+ 0
324
+ ], []);
325
+ const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
326
+ const transUnitRangeReversed = (0, import_react2.useMemo)(() => [
327
+ 0,
328
+ clientWidth
329
+ ], []);
330
+ const transProgress = transUnitReversed.to(transUnitRangeReversed, [
331
+ 0,
332
+ 1
333
+ ], "clamp");
334
+ const transPercent = transUnitReversed.to(transUnitRangeReversed, [
335
+ 0,
336
+ 100
337
+ ], "clamp");
338
+ const initThreshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth), []);
339
+ const threshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 3), []);
340
+ const pageState = location.pathRoute.pageState;
341
+ const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
342
+ const pageClassName = "touch-pan-y";
343
+ (0, import_react2.useEffect)(() => {
344
+ onBack.current.stack = async () => {
345
+ await transUnit.start(transUnitRange[0]);
346
+ };
347
+ }, []);
348
+ (0, import_react2.useEffect)(() => {
349
+ if (history.current.type === "forward") {
350
+ void transUnit.start(transUnitRange[0], {
351
+ immediate: true
352
+ });
353
+ void transUnit.start(transUnitRange[1], {
354
+ config: {
355
+ duration: 150
356
+ }
357
+ });
358
+ } else {
359
+ void transUnit.start(transUnitRange[1], {
360
+ immediate: true
361
+ });
362
+ return;
363
+ }
364
+ }, [
365
+ location.pathname
366
+ ]);
367
+ const pageBind = (0, import_react.useDrag)(({ first, down, last, movement: [mx], initial: [ix], cancel }) => {
368
+ if (first) void import_client.device.hideKeyboard();
369
+ if (ix > initThreshold) {
370
+ cancel();
371
+ return;
372
+ }
373
+ if (mx < transUnitRange[1]) void transUnit.start(transUnitRange[1], {
374
+ immediate: true
375
+ });
376
+ else if (mx > transUnitRange[0]) void transUnit.start(transUnitRange[0], {
377
+ immediate: true
378
+ });
379
+ else if (!last) void transUnit.start(mx, {
380
+ immediate: true
381
+ });
382
+ else if (mx < threshold) void transUnit.start(transUnitRange[1]);
383
+ if (last && mx > threshold) import_client.router.back();
384
+ }, {
385
+ axis: "x",
386
+ filterTaps: true
387
+ });
388
+ const csrTranstionStyles = {
389
+ topSafeArea: {
390
+ containerStyle: {
391
+ height: transProgress.to([
392
+ 0,
393
+ 1
394
+ ], [
395
+ prevPageState.topSafeArea,
396
+ pageState.topSafeArea
397
+ ])
398
+ }
399
+ },
400
+ bottomSafeArea: {
401
+ containerStyle: {
402
+ top: transProgress.to([
403
+ 0,
404
+ 1
405
+ ], [
406
+ clientHeight - prevPageState.bottomSafeArea,
407
+ clientHeight - pageState.bottomSafeArea
408
+ ]),
409
+ height: transProgress.to([
410
+ 0,
411
+ 1
412
+ ], [
413
+ prevPageState.bottomSafeArea,
414
+ pageState.bottomSafeArea
415
+ ])
416
+ }
417
+ },
418
+ page: {
419
+ containerStyle: {},
420
+ contentStyle: {
421
+ paddingTop: pageState.topSafeArea + pageState.topInset,
422
+ paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
423
+ translateX: transUnit,
424
+ height: clientHeight
425
+ }
426
+ },
427
+ prevPage: {
428
+ containerStyle: {
429
+ paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
430
+ translateX: transUnit.to((unit) => (unit - clientWidth) / 5)
431
+ },
432
+ contentStyle: {
433
+ opacity: transProgress.to((progress) => 1 - progress / 2)
434
+ }
435
+ },
436
+ topInset: {
437
+ containerStyle: {
438
+ top: transProgress.to([
439
+ 0,
440
+ 1
441
+ ], [
442
+ prevPageState.topSafeArea,
443
+ pageState.topSafeArea
444
+ ]),
445
+ height: transProgress.to([
446
+ 0,
447
+ 1
448
+ ], [
449
+ prevPageState.topInset,
450
+ pageState.topInset
451
+ ])
452
+ },
453
+ contentStyle: {
454
+ opacity: transProgress.to((progress) => progress),
455
+ translateX: transProgress.to([
456
+ 0,
457
+ 1
458
+ ], [
459
+ clientWidth / 5,
460
+ 0
461
+ ])
462
+ },
463
+ prevContentStyle: {
464
+ opacity: transProgress.to((progress) => 1 - progress),
465
+ translateX: transProgress.to([
466
+ 0,
467
+ 1
468
+ ], [
469
+ 0,
470
+ -clientWidth / 5
471
+ ])
472
+ }
473
+ },
474
+ topLeftAction: {
475
+ containerStyle: {
476
+ top: transProgress.to([
477
+ 0,
478
+ 1
479
+ ], [
480
+ prevPageState.topSafeArea,
481
+ pageState.topSafeArea
482
+ ]),
483
+ height: transProgress.to([
484
+ 0,
485
+ 1
486
+ ], [
487
+ prevPageState.topInset,
488
+ pageState.topInset
489
+ ]),
490
+ minWidth: transProgress.to([
491
+ 0,
492
+ 1
493
+ ], [
494
+ prevPageState.topInset,
495
+ pageState.topInset
496
+ ])
497
+ },
498
+ contentStyle: {
499
+ opacity: transProgress.to((progress) => progress)
500
+ },
501
+ prevContentStyle: {
502
+ opacity: transProgress.to((progress) => 1 - progress)
503
+ }
504
+ },
505
+ bottomInset: {
506
+ containerStyle: {
507
+ height: transProgress.to([
508
+ 0,
509
+ 1
510
+ ], [
511
+ prevPageState.bottomInset,
512
+ pageState.bottomInset
513
+ ]),
514
+ top: transProgress.to([
515
+ 0,
516
+ 1
517
+ ], [
518
+ clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
519
+ clientHeight - pageState.bottomInset - pageState.bottomSafeArea
520
+ ])
521
+ },
522
+ contentStyle: {
523
+ top: transProgress.to([
524
+ 0,
525
+ 1
526
+ ], [
527
+ 0,
528
+ -(pageState.bottomInset - prevPageState.bottomInset) * 2
529
+ ]),
530
+ opacity: transProgress.to((progress) => progress)
531
+ },
532
+ prevContentStyle: {
533
+ top: transProgress.to([
534
+ 0,
535
+ 1
536
+ ], [
537
+ 0,
538
+ -(pageState.bottomInset - prevPageState.bottomInset) * 2
539
+ ]),
540
+ opacity: transProgress.to((progress) => 1 - progress)
541
+ }
542
+ }
543
+ };
544
+ const useCsrTransition = {
545
+ ...csrTranstionStyles,
546
+ pageBind,
547
+ pageClassName,
548
+ transDirection,
549
+ transUnitRange,
550
+ transUnit,
551
+ transPercent,
552
+ transProgress
553
+ };
554
+ return useCsrTransition;
555
+ }, "useStackTrans");
556
+ const useBottomUpTrans = /* @__PURE__ */ __name(({ clientWidth, clientHeight, history, location, prevLocation, onBack }) => {
557
+ const transDirection = "vertical";
558
+ const transUnit = (0, import_web.useSpringValue)(0, {
559
+ config: {
560
+ clamp: true
561
+ }
562
+ });
563
+ const transUnitRange = (0, import_react2.useMemo)(() => [
564
+ clientHeight,
565
+ 0
566
+ ], []);
567
+ const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
568
+ const transUnitRangeReversed = (0, import_react2.useMemo)(() => [
569
+ 0,
570
+ clientWidth
571
+ ], []);
572
+ const transProgress = transUnitReversed.to(transUnitRangeReversed, [
573
+ 0,
574
+ 1
575
+ ], "clamp");
576
+ const transPercent = transUnitReversed.to(transUnitRangeReversed, [
577
+ 0,
578
+ 100
579
+ ], "clamp");
580
+ const initThreshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 3), []);
581
+ const threshold = (0, import_react2.useMemo)(() => Math.floor(clientWidth / 2), []);
582
+ const pageState = location.pathRoute.pageState;
583
+ const prevPageState = prevLocation?.pathRoute.pageState ?? import_client.defaultPageState;
584
+ (0, import_react2.useEffect)(() => {
585
+ onBack.current.bottomUp = async () => {
586
+ await transUnit.start(transUnitRange[0]);
587
+ };
588
+ }, []);
589
+ (0, import_react2.useEffect)(() => {
590
+ if (history.current.type === "forward") {
591
+ void transUnit.start(transUnitRange[0], {
592
+ immediate: true
593
+ });
594
+ void transUnit.start(transUnitRange[1], {
595
+ config: {
596
+ duration: 150
597
+ }
598
+ });
599
+ } else {
600
+ void transUnit.start(transUnitRange[1], {
601
+ immediate: true
602
+ });
603
+ return;
604
+ }
605
+ }, [
606
+ location.pathname
607
+ ]);
608
+ const pageBind = (0, import_react.useDrag)(({ first, last, movement: [, my], initial: [, iy], cancel }) => {
609
+ if (first) void import_client.device.hideKeyboard();
610
+ if (iy > initThreshold) {
611
+ cancel();
612
+ return;
613
+ }
614
+ if (my < transUnitRange[1]) void transUnit.start(transUnitRange[1], {
615
+ immediate: true
616
+ });
617
+ else if (my > transUnitRange[0]) void transUnit.start(transUnitRange[0], {
618
+ immediate: true
619
+ });
620
+ else if (!last) void transUnit.start(my, {
621
+ immediate: true
622
+ });
623
+ else if (my < threshold) void transUnit.start(transUnitRange[1]);
624
+ if (last && my > threshold) import_client.router.back();
625
+ }, {
626
+ axis: "y",
627
+ filterTaps: true,
628
+ threshold: 10
629
+ });
630
+ const csrTranstionStyles = {
631
+ topSafeArea: {
632
+ containerStyle: {
633
+ height: transProgress.to([
634
+ 0,
635
+ 1
636
+ ], [
637
+ prevPageState.topSafeArea,
638
+ pageState.topSafeArea
639
+ ])
640
+ }
641
+ },
642
+ bottomSafeArea: {
643
+ containerStyle: {
644
+ top: transProgress.to([
645
+ 0,
646
+ 1
647
+ ], [
648
+ clientHeight - prevPageState.bottomSafeArea,
649
+ clientHeight - pageState.bottomSafeArea
650
+ ]),
651
+ height: transProgress.to([
652
+ 0,
653
+ 1
654
+ ], [
655
+ prevPageState.bottomSafeArea,
656
+ pageState.bottomSafeArea
657
+ ])
658
+ }
659
+ },
660
+ page: {
661
+ containerStyle: {},
662
+ contentStyle: {
663
+ paddingTop: pageState.topSafeArea + pageState.topInset,
664
+ paddingBottom: pageState.bottomInset + pageState.bottomSafeArea,
665
+ translateY: transUnit,
666
+ height: clientHeight
667
+ }
668
+ },
669
+ prevPage: {
670
+ containerStyle: {
671
+ paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
672
+ translateY: 0
673
+ },
674
+ contentStyle: {
675
+ opacity: transProgress.to((progress) => 1 - progress / 2)
676
+ }
677
+ },
678
+ topInset: {
679
+ containerStyle: {
680
+ top: transProgress.to([
681
+ 0,
682
+ 1
683
+ ], [
684
+ prevPageState.topSafeArea,
685
+ pageState.topSafeArea
686
+ ]),
687
+ height: transProgress.to([
688
+ 0,
689
+ 1
690
+ ], [
691
+ prevPageState.topInset,
692
+ pageState.topInset
693
+ ])
694
+ },
695
+ contentStyle: {
696
+ opacity: transProgress.to((progress) => progress)
697
+ },
698
+ prevContentStyle: {
699
+ opacity: transProgress.to((progress) => 1 - progress)
700
+ }
701
+ },
702
+ topLeftAction: {
703
+ containerStyle: {
704
+ top: transProgress.to([
705
+ 0,
706
+ 1
707
+ ], [
708
+ prevPageState.topSafeArea,
709
+ pageState.topSafeArea
710
+ ]),
711
+ height: transProgress.to([
712
+ 0,
713
+ 1
714
+ ], [
715
+ prevPageState.topInset,
716
+ pageState.topInset
717
+ ])
718
+ },
719
+ contentStyle: {
720
+ opacity: transProgress.to((progress) => progress)
721
+ },
722
+ prevContentStyle: {
723
+ opacity: transProgress.to((progress) => 1 - progress)
724
+ }
725
+ },
726
+ bottomInset: {
727
+ containerStyle: {
728
+ height: transProgress.to([
729
+ 0,
730
+ 1
731
+ ], [
732
+ prevPageState.bottomInset,
733
+ pageState.bottomInset
734
+ ]),
735
+ top: transProgress.to([
736
+ 0,
737
+ 1
738
+ ], [
739
+ clientHeight - prevPageState.bottomInset - prevPageState.bottomSafeArea,
740
+ clientHeight - pageState.bottomInset - pageState.bottomSafeArea
741
+ ])
742
+ },
743
+ contentStyle: {
744
+ top: transProgress.to([
745
+ 0,
746
+ 1
747
+ ], [
748
+ 0,
749
+ -(pageState.bottomInset - prevPageState.bottomInset) * 2
750
+ ]),
751
+ opacity: transProgress.to((progress) => progress)
752
+ },
753
+ prevContentStyle: {
754
+ top: transProgress.to([
755
+ 0,
756
+ 1
757
+ ], [
758
+ 0,
759
+ -(pageState.bottomInset - prevPageState.bottomInset) * 2
760
+ ]),
761
+ opacity: transProgress.to((progress) => 1 - progress)
762
+ }
763
+ }
764
+ };
765
+ const useCsrTransition = {
766
+ ...csrTranstionStyles,
767
+ pageBind,
768
+ pageClassName: "touch-pan-x",
769
+ transDirection,
770
+ transUnitRange,
771
+ transUnit,
772
+ transPercent,
773
+ transProgress
774
+ };
775
+ return useCsrTransition;
776
+ }, "useBottomUpTrans");
777
+ const useCsrValues = /* @__PURE__ */ __name((rootRouteGuide, pathRoutes) => {
778
+ const clientWidth = (0, import_react2.useRef)(window.innerWidth);
779
+ const clientHeight = (0, import_react2.useRef)(window.innerHeight);
780
+ const topSafeAreaRef = (0, import_react2.useRef)(null);
781
+ const bottomSafeAreaRef = (0, import_react2.useRef)(null);
782
+ const pageContentRef = (0, import_react2.useRef)(null);
783
+ const prevPageContentRef = (0, import_react2.useRef)(null);
784
+ const onBack = (0, import_react2.useRef)({});
785
+ const frameRootRef = (0, import_react2.useRef)(null);
786
+ const { getLocation } = (0, import_useLocation.useLocation)({
787
+ rootRouteGuide
788
+ });
789
+ const { history, setHistoryForward, setHistoryBack, getCurrentLocation, getPrevLocation, getScrollTop } = (0, import_useHistory.useHistory)([
790
+ getLocation(window.location.pathname)
791
+ ]);
792
+ const [{ location, prevLocation }, setLocationState] = (0, import_react2.useState)({
793
+ location: getCurrentLocation(),
794
+ prevLocation: getPrevLocation()
795
+ });
796
+ const getRouter = (0, import_react2.useCallback)(() => {
797
+ const router3 = {
798
+ push: /* @__PURE__ */ __name((href) => {
799
+ const location2 = getCurrentLocation();
800
+ const scrollTop = pageContentRef.current?.scrollTop ?? 0;
801
+ setHistoryForward({
802
+ type: "push",
803
+ location: getLocation(href),
804
+ scrollTop
805
+ });
806
+ setLocationState({
807
+ location: getCurrentLocation(),
808
+ prevLocation: location2
809
+ });
810
+ window.history.pushState({}, "", href);
811
+ }, "push"),
812
+ replace: /* @__PURE__ */ __name((href) => {
813
+ const scrollTop = pageContentRef.current?.scrollTop ?? 0;
814
+ setHistoryForward({
815
+ type: "replace",
816
+ location: getLocation(href),
817
+ scrollTop
818
+ });
819
+ setLocationState({
820
+ location: getCurrentLocation(),
821
+ prevLocation
822
+ });
823
+ window.history.replaceState({}, "", href);
824
+ }, "replace"),
825
+ refresh: /* @__PURE__ */ __name(() => {
826
+ window.location.reload();
827
+ }, "refresh"),
828
+ back: /* @__PURE__ */ __name(async () => {
829
+ const location2 = getCurrentLocation();
830
+ await onBack.current[location2.pathRoute.pageState.transition]?.();
831
+ const scrollTop = pageContentRef.current?.scrollTop ?? 0;
832
+ setHistoryBack({
833
+ type: "back",
834
+ location: location2,
835
+ scrollTop
836
+ });
837
+ setLocationState({
838
+ location: getCurrentLocation(),
839
+ prevLocation: getPrevLocation()
840
+ });
841
+ window.history.back();
842
+ }, "back")
843
+ };
844
+ window.onpopstate = async (ev) => {
845
+ const routeType = window.location.pathname === getCurrentLocation().pathname && history.current.type !== "back" ? "forward" : window.location.pathname === getPrevLocation()?.pathname ? "back" : null;
846
+ const scrollTop = pageContentRef.current?.scrollTop ?? 0;
847
+ if (!routeType) return;
848
+ if (routeType === "forward") {
849
+ const location2 = getCurrentLocation();
850
+ setHistoryForward({
851
+ type: "popForward",
852
+ location: location2,
853
+ scrollTop
854
+ });
855
+ setLocationState({
856
+ location: getCurrentLocation(),
857
+ prevLocation: location2
858
+ });
859
+ } else {
860
+ const location2 = getCurrentLocation();
861
+ await onBack.current[location2.pathRoute.pageState.transition]?.();
862
+ setHistoryBack({
863
+ type: "popBack",
864
+ location: location2,
865
+ scrollTop
866
+ });
867
+ setLocationState({
868
+ location: getCurrentLocation(),
869
+ prevLocation: getPrevLocation()
870
+ });
871
+ }
872
+ };
873
+ return router3;
874
+ }, [
875
+ location
876
+ ]);
877
+ const router2 = getRouter();
878
+ const routeState = {
879
+ clientWidth: clientWidth.current,
880
+ clientHeight: clientHeight.current,
881
+ location,
882
+ prevLocation,
883
+ history,
884
+ topSafeAreaRef,
885
+ bottomSafeAreaRef,
886
+ prevPageContentRef,
887
+ pageContentRef,
888
+ frameRootRef,
889
+ onBack,
890
+ router: router2,
891
+ pathRoutes
892
+ };
893
+ const useNonTransition = useNoneTrans(routeState);
894
+ const useFadeTransition = useFadeTrans(routeState);
895
+ const useStackTransition = useStackTrans(routeState);
896
+ const useBottomUpTransition = useBottomUpTrans(routeState);
897
+ const useCsrTransitionMap = {
898
+ none: useNonTransition,
899
+ fade: useFadeTransition,
900
+ stack: useStackTransition,
901
+ bottomUp: useBottomUpTransition,
902
+ scaleOut: useNonTransition
903
+ };
904
+ (0, import_react2.useEffect)(() => {
905
+ if (pageContentRef.current) pageContentRef.current.scrollTop = getScrollTop(location.pathname);
906
+ if (prevPageContentRef.current) prevPageContentRef.current.scrollTop = prevLocation ? getScrollTop(prevLocation.pathname) : 0;
907
+ void import_app.App.addListener("backButton", () => {
908
+ router2.back();
909
+ });
910
+ return () => {
911
+ void import_app.App.removeAllListeners();
912
+ };
913
+ }, [
914
+ location.pathname
915
+ ]);
916
+ return {
917
+ ...routeState,
918
+ ...useCsrTransitionMap[location.pathRoute.pageState.transition]
919
+ };
920
+ }, "useCsrValues");
921
+ // Annotate the CommonJS export names for ESM import in node:
922
+ 0 && (module.exports = {
923
+ useCsrValues
924
+ });