@flemo/core 1.2.0 → 1.4.0

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.mjs CHANGED
@@ -1,1051 +1,837 @@
1
- import { create as w } from "zustand";
2
- import { pathToRegexp as v, match as B } from "path-to-regexp";
3
- class Q {
4
- tasks = /* @__PURE__ */ new Map();
5
- instanceId = Date.now().toString();
6
- isLocked = !1;
7
- currentTaskId = null;
8
- taskQueue = Promise.resolve();
9
- signalListeners = /* @__PURE__ */ new Map();
10
- pendingTaskQueue = [];
11
- isProcessingPending = !1;
12
- async acquireLock(t) {
13
- for (let a = 0; a < 10; a++) {
14
- if (!this.isLocked)
15
- return this.isLocked = !0, this.currentTaskId = t, !0;
16
- await new Promise((r) => setTimeout(r, 100));
17
- }
18
- return !1;
19
- }
20
- releaseLock(t) {
21
- this.currentTaskId === t && (this.isLocked = !1, this.currentTaskId = null);
22
- }
23
- generateTaskId() {
24
- return `${this.instanceId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
25
- }
26
- emitSignal(t) {
27
- const e = this.signalListeners.get(t);
28
- e && (e.forEach((s) => {
29
- this.resolveTask(s);
30
- }), this.signalListeners.delete(t));
31
- }
32
- // 대기 중인 태스크들을 처리하는 메서드
33
- async processPendingTasks() {
34
- if (!(this.isProcessingPending || this.pendingTaskQueue.length === 0)) {
35
- this.isProcessingPending = !0;
36
- try {
37
- for (; this.pendingTaskQueue.length > 0; ) {
38
- const t = this.pendingTaskQueue[0];
39
- if (t.status === "COMPLETED" || t.status === "FAILED" || t.status === "ROLLEDBACK") {
40
- this.pendingTaskQueue.shift();
41
- continue;
42
- }
43
- if (t.status === "MANUAL_PENDING" || t.status === "SIGNAL_PENDING" || t.status === "PROCESSING" || t.status === "PENDING")
44
- break;
45
- }
46
- } finally {
47
- this.isProcessingPending = !1;
48
- }
49
- }
50
- }
51
- // 모든 대기 중인 태스크가 완료될 때까지 대기
52
- async waitForPendingTasks() {
53
- return new Promise((t) => {
54
- const e = () => {
55
- this.pendingTaskQueue.filter(
56
- (a) => a.status === "MANUAL_PENDING" || a.status === "SIGNAL_PENDING"
57
- ).length === 0 ? t() : setTimeout(e, 100);
58
- };
59
- e();
60
- });
61
- }
62
- // 태스크 상태 변경 대기 큐 처리
63
- async onTaskStatusChange(t, e) {
64
- (e === "COMPLETED" || e === "FAILED" || e === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((s) => s.id !== t), await this.processPendingTasks());
65
- }
66
- async addTask(t, e = {}) {
67
- const s = e.id || this.generateTaskId();
68
- return new Promise((a, r) => {
69
- this.taskQueue = this.taskQueue.then(async () => {
70
- try {
71
- const { control: o, validate: c, rollback: l, dependencies: u = [], delay: d } = e, p = new AbortController(), i = {
72
- id: s,
73
- execute: t,
74
- timestamp: Date.now(),
75
- retryCount: 0,
76
- status: "PENDING",
77
- dependencies: u,
78
- instanceId: this.instanceId,
79
- validate: c,
80
- rollback: l,
81
- control: o,
82
- abortController: p
83
- };
84
- this.tasks.set(i.id, i), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(i), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((P) => P.id !== i.id));
85
- try {
86
- if (!await this.acquireLock(i.id))
87
- throw i.status = "FAILED", new Error("FAILED");
88
- try {
89
- i.status = "PROCESSING";
90
- for (const f of i.dependencies) {
91
- const y = this.tasks.get(f);
92
- if (!y || y.status !== "COMPLETED")
93
- throw i.status = "FAILED", new Error("FAILED");
94
- }
95
- if (i.validate && !await i.validate())
96
- throw i.status = "FAILED", new Error("FAILED");
97
- d && d > 0 && await new Promise((f) => setTimeout(f, d));
98
- const h = await i.execute(i.abortController);
99
- if (i.abortController.signal.aborted) {
100
- i.status = "COMPLETED", await this.onTaskStatusChange(i.id, "COMPLETED"), a({
101
- success: !0,
102
- result: void 0,
103
- taskId: i.id,
104
- timestamp: Date.now(),
105
- instanceId: this.instanceId
106
- });
107
- return;
108
- }
109
- if (e.control) {
110
- const f = e.control;
111
- if (f.delay && f.delay > 0 && await new Promise((y) => setTimeout(y, f.delay)), f.manual) {
112
- i.status = "MANUAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "MANUAL_PENDING");
113
- return;
114
- }
115
- if (f.signal) {
116
- i.status = "SIGNAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.signalListeners.has(f.signal) || this.signalListeners.set(f.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(f.signal).add(i.id), this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "SIGNAL_PENDING");
117
- return;
118
- }
119
- if (f.condition && !await f.condition()) {
120
- i.status = "MANUAL_PENDING", i.manualResolver = { resolve: a, reject: r, result: h }, this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "MANUAL_PENDING");
121
- return;
122
- }
123
- }
124
- i.status = "COMPLETED", await this.onTaskStatusChange(i.id, "COMPLETED"), a({
125
- success: !0,
126
- result: h,
127
- taskId: i.id,
128
- timestamp: Date.now(),
129
- instanceId: this.instanceId
130
- });
131
- } catch (h) {
132
- if (i.status = "FAILED", i.rollback)
133
- try {
134
- await i.rollback(), i.status = "ROLLEDBACK";
135
- } catch {
136
- }
137
- throw await this.onTaskStatusChange(i.id, i.status), h;
138
- } finally {
139
- this.releaseLock(i.id);
140
- }
141
- } catch (P) {
142
- r(P);
143
- }
144
- } catch (o) {
145
- r(o);
146
- }
147
- }).catch(r);
148
- });
149
- }
150
- async resolveTask(t) {
151
- const e = this.tasks.get(t);
152
- if (!e || e.status !== "MANUAL_PENDING" && e.status !== "SIGNAL_PENDING")
153
- return !1;
154
- if (e.manualResolver) {
155
- if (e.control?.condition && !await e.control.condition())
156
- return !1;
157
- e.status = "COMPLETED";
158
- const s = e.manualResolver;
159
- return s.resolve({
160
- success: !0,
161
- result: s.result,
162
- taskId: e.id,
163
- timestamp: Date.now(),
164
- instanceId: this.instanceId
165
- }), delete e.manualResolver, await this.onTaskStatusChange(t, "COMPLETED"), !0;
166
- }
167
- return !1;
168
- }
169
- async resolveAllPending() {
170
- const t = Array.from(this.tasks.values()).filter(
171
- (e) => ["PENDING", "MANUAL_PENDING", "SIGNAL_PENDING"].includes(e.status)
172
- );
173
- await Promise.all(t.map((e) => this.resolveTask(e.id)));
174
- }
1
+ import { createStore as e } from "zustand/vanilla";
2
+ import { match as t, pathToRegexp as n } from "path-to-regexp";
3
+ var r = new class {
4
+ tasks = /* @__PURE__ */ new Map();
5
+ instanceId = Date.now().toString();
6
+ isLocked = !1;
7
+ currentTaskId = null;
8
+ taskQueue = Promise.resolve();
9
+ signalListeners = /* @__PURE__ */ new Map();
10
+ pendingTaskQueue = [];
11
+ isProcessingPending = !1;
12
+ async acquireLock(e) {
13
+ for (let t = 0; t < 10; t++) {
14
+ if (!this.isLocked) return this.isLocked = !0, this.currentTaskId = e, !0;
15
+ await new Promise((e) => setTimeout(e, 100));
16
+ }
17
+ return !1;
18
+ }
19
+ releaseLock(e) {
20
+ this.currentTaskId === e && (this.isLocked = !1, this.currentTaskId = null);
21
+ }
22
+ generateTaskId() {
23
+ return `${this.instanceId}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
24
+ }
25
+ emitSignal(e) {
26
+ let t = this.signalListeners.get(e);
27
+ t && (t.forEach((e) => {
28
+ this.resolveTask(e);
29
+ }), this.signalListeners.delete(e));
30
+ }
31
+ async processPendingTasks() {
32
+ if (!(this.isProcessingPending || this.pendingTaskQueue.length === 0)) {
33
+ this.isProcessingPending = !0;
34
+ try {
35
+ for (; this.pendingTaskQueue.length > 0;) {
36
+ let e = this.pendingTaskQueue[0];
37
+ if (e.status === "COMPLETED" || e.status === "FAILED" || e.status === "ROLLEDBACK") {
38
+ this.pendingTaskQueue.shift();
39
+ continue;
40
+ }
41
+ if (e.status === "MANUAL_PENDING" || e.status === "SIGNAL_PENDING" || e.status === "PROCESSING" || e.status === "PENDING") break;
42
+ }
43
+ } finally {
44
+ this.isProcessingPending = !1;
45
+ }
46
+ }
47
+ }
48
+ async waitForPendingTasks() {
49
+ return new Promise((e) => {
50
+ let t = () => {
51
+ this.pendingTaskQueue.filter((e) => e.status === "MANUAL_PENDING" || e.status === "SIGNAL_PENDING").length === 0 ? e() : setTimeout(t, 100);
52
+ };
53
+ t();
54
+ });
55
+ }
56
+ async onTaskStatusChange(e, t) {
57
+ (t === "COMPLETED" || t === "FAILED" || t === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((t) => t.id !== e), await this.processPendingTasks());
58
+ }
59
+ async addTask(e, t = {}) {
60
+ let n = t.id || this.generateTaskId();
61
+ return new Promise((r, i) => {
62
+ this.taskQueue = this.taskQueue.then(async () => {
63
+ try {
64
+ let { control: a, validate: o, rollback: s, dependencies: c = [], delay: l } = t, u = new AbortController(), d = {
65
+ id: n,
66
+ execute: e,
67
+ timestamp: Date.now(),
68
+ retryCount: 0,
69
+ status: "PENDING",
70
+ dependencies: c,
71
+ instanceId: this.instanceId,
72
+ validate: o,
73
+ rollback: s,
74
+ control: a,
75
+ abortController: u
76
+ };
77
+ this.tasks.set(d.id, d), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(d), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((e) => e.id !== d.id));
78
+ try {
79
+ if (!await this.acquireLock(d.id)) throw d.status = "FAILED", Error("FAILED");
80
+ try {
81
+ d.status = "PROCESSING";
82
+ for (let e of d.dependencies) {
83
+ let t = this.tasks.get(e);
84
+ if (!t || t.status !== "COMPLETED") throw d.status = "FAILED", Error("FAILED");
85
+ }
86
+ if (d.validate && !await d.validate()) throw d.status = "FAILED", Error("FAILED");
87
+ l && l > 0 && await new Promise((e) => setTimeout(e, l));
88
+ let e = await d.execute(d.abortController);
89
+ if (d.abortController.signal.aborted) {
90
+ d.status = "COMPLETED", await this.onTaskStatusChange(d.id, "COMPLETED"), r({
91
+ success: !0,
92
+ result: void 0,
93
+ taskId: d.id,
94
+ timestamp: Date.now(),
95
+ instanceId: this.instanceId
96
+ });
97
+ return;
98
+ }
99
+ if (t.control) {
100
+ let n = t.control;
101
+ if (n.delay && n.delay > 0 && await new Promise((e) => setTimeout(e, n.delay)), n.manual) {
102
+ d.status = "MANUAL_PENDING", d.manualResolver = {
103
+ resolve: r,
104
+ reject: i,
105
+ result: e
106
+ }, this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
107
+ return;
108
+ }
109
+ if (n.signal) {
110
+ d.status = "SIGNAL_PENDING", d.manualResolver = {
111
+ resolve: r,
112
+ reject: i,
113
+ result: e
114
+ }, this.signalListeners.has(n.signal) || this.signalListeners.set(n.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(n.signal).add(d.id), this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "SIGNAL_PENDING");
115
+ return;
116
+ }
117
+ if (n.condition && !await n.condition()) {
118
+ d.status = "MANUAL_PENDING", d.manualResolver = {
119
+ resolve: r,
120
+ reject: i,
121
+ result: e
122
+ }, this.pendingTaskQueue.push(d), await this.onTaskStatusChange(d.id, "MANUAL_PENDING");
123
+ return;
124
+ }
125
+ }
126
+ d.status = "COMPLETED", await this.onTaskStatusChange(d.id, "COMPLETED"), r({
127
+ success: !0,
128
+ result: e,
129
+ taskId: d.id,
130
+ timestamp: Date.now(),
131
+ instanceId: this.instanceId
132
+ });
133
+ } catch (e) {
134
+ if (d.status = "FAILED", d.rollback) try {
135
+ await d.rollback(), d.status = "ROLLEDBACK";
136
+ } catch {}
137
+ throw await this.onTaskStatusChange(d.id, d.status), e;
138
+ } finally {
139
+ this.releaseLock(d.id);
140
+ }
141
+ } catch (e) {
142
+ i(e);
143
+ }
144
+ } catch (e) {
145
+ i(e);
146
+ }
147
+ }).catch(i);
148
+ });
149
+ }
150
+ async resolveTask(e) {
151
+ let t = this.tasks.get(e);
152
+ if (!t || t.status !== "MANUAL_PENDING" && t.status !== "SIGNAL_PENDING") return !1;
153
+ if (t.manualResolver) {
154
+ if (t.control?.condition && !await t.control.condition()) return !1;
155
+ t.status = "COMPLETED";
156
+ let n = t.manualResolver;
157
+ return n.resolve({
158
+ success: !0,
159
+ result: n.result,
160
+ taskId: t.id,
161
+ timestamp: Date.now(),
162
+ instanceId: this.instanceId
163
+ }), delete t.manualResolver, await this.onTaskStatusChange(e, "COMPLETED"), !0;
164
+ }
165
+ return !1;
166
+ }
167
+ async resolveAllPending() {
168
+ let e = Array.from(this.tasks.values()).filter((e) => [
169
+ "PENDING",
170
+ "MANUAL_PENDING",
171
+ "SIGNAL_PENDING"
172
+ ].includes(e.status));
173
+ await Promise.all(e.map((e) => this.resolveTask(e.id)));
174
+ }
175
+ }();
176
+ //#endregion
177
+ //#region src/history/store.ts
178
+ function i(t = [], n = -1) {
179
+ return e((e) => ({
180
+ index: n,
181
+ histories: t,
182
+ addHistory: (t) => e((e) => ({
183
+ index: e.index + 1,
184
+ histories: e.histories.concat(t)
185
+ })),
186
+ replaceHistory: (t) => e((e) => (e.histories.splice(t, 1), {
187
+ index: e.index - 1,
188
+ histories: e.histories
189
+ })),
190
+ popHistory: (t) => e((e) => ({
191
+ index: e.index - 1,
192
+ histories: e.histories.filter((e, n) => n !== t)
193
+ })),
194
+ popHistories: (t) => {
195
+ t <= 0 || e((e) => {
196
+ let n = e.index;
197
+ return {
198
+ index: e.index - t,
199
+ histories: e.histories.filter((e, r) => r < n - t || r >= n)
200
+ };
201
+ });
202
+ },
203
+ setTransitionName: (t, n) => e((e) => {
204
+ let r = e.histories[t];
205
+ if (!r || r.transitionName === n) return {};
206
+ let i = e.histories.slice();
207
+ return i[t] = {
208
+ ...r,
209
+ transitionName: n
210
+ }, { histories: i };
211
+ })
212
+ }));
175
213
  }
176
- const yt = new Q(), Pt = w((n) => ({
177
- index: -1,
178
- histories: [],
179
- addHistory: (t) => n((e) => ({
180
- index: e.index + 1,
181
- histories: e.histories.concat(t)
182
- })),
183
- replaceHistory: (t) => n((e) => (e.histories.splice(t, 1), {
184
- index: e.index - 1,
185
- histories: e.histories
186
- })),
187
- popHistory: (t) => n((e) => ({
188
- index: e.index - 1,
189
- histories: e.histories.filter((s, a) => a !== t)
190
- })),
191
- // Drop `count` entries sitting directly below the current top, keeping the
192
- // top itself. Used by pop(n) to remove the screens it skips over in the same
193
- // synchronous block that starts the transition — so they never paint — while
194
- // the leaving top stays mounted to drive and resolve the animation.
195
- popHistories: (t) => {
196
- t <= 0 || n((e) => {
197
- const s = e.index;
198
- return {
199
- index: e.index - t,
200
- histories: e.histories.filter((a, r) => r < s - t || r >= s)
201
- };
202
- });
203
- }
204
- })), gt = w((n) => ({
205
- status: "IDLE",
206
- transitionTaskId: null,
207
- setStatus: (t) => n({ status: t }),
208
- setTransitionTaskId: (t) => n({ transitionTaskId: t })
209
- }));
210
- let L = 0;
211
- function It() {
212
- L += 1;
214
+ //#endregion
215
+ //#region src/navigate/store.ts
216
+ function a() {
217
+ return e((e) => ({
218
+ status: "IDLE",
219
+ transitionTaskId: null,
220
+ setStatus: (t) => e({ status: t }),
221
+ setTransitionTaskId: (t) => e({ transitionTaskId: t })
222
+ }));
213
223
  }
214
- function Et() {
215
- return L > 0 ? (L -= 1, !0) : !1;
224
+ //#endregion
225
+ //#region src/navigate/selfPopGuard.ts
226
+ var o = 0;
227
+ function s() {
228
+ o += 1;
216
229
  }
217
- function T({
218
- name: n,
219
- initial: t,
220
- idle: e,
221
- enter: s,
222
- enterBack: a,
223
- exit: r,
224
- exitBack: o,
225
- options: c
226
- }) {
227
- return {
228
- name: n,
229
- initial: t,
230
- variants: {
231
- "IDLE-true": e,
232
- "IDLE-false": e,
233
- "PUSHING-false": r,
234
- "PUSHING-true": s,
235
- "REPLACING-false": r,
236
- "REPLACING-true": s,
237
- "POPPING-false": o,
238
- "POPPING-true": a,
239
- "COMPLETED-false": r,
240
- "COMPLETED-true": s
241
- },
242
- ...c
243
- };
230
+ function c() {
231
+ return o > 0 ? (--o, !0) : !1;
244
232
  }
245
- function kt({
246
- name: n,
247
- initial: t,
248
- idle: e,
249
- pushOnEnter: s,
250
- pushOnExit: a,
251
- replaceOnEnter: r,
252
- replaceOnExit: o,
253
- popOnEnter: c,
254
- popOnExit: l,
255
- completedOnExit: u,
256
- completedOnEnter: d,
257
- options: p
258
- }) {
259
- return {
260
- name: n,
261
- initial: t,
262
- variants: {
263
- "IDLE-true": e,
264
- "IDLE-false": e,
265
- "PUSHING-false": a,
266
- "PUSHING-true": s,
267
- "REPLACING-false": o,
268
- "REPLACING-true": r,
269
- "POPPING-false": l,
270
- "POPPING-true": c,
271
- "COMPLETED-false": u,
272
- "COMPLETED-true": d
273
- },
274
- ...p
275
- };
233
+ //#endregion
234
+ //#region src/transition/createTransition.ts
235
+ function l({ name: e, initial: t, idle: n, enter: r, enterBack: i, exit: a, exitBack: o, options: s }) {
236
+ return {
237
+ name: e,
238
+ initial: t,
239
+ variants: {
240
+ "IDLE-true": n,
241
+ "IDLE-false": n,
242
+ "PUSHING-false": a,
243
+ "PUSHING-true": r,
244
+ "REPLACING-false": a,
245
+ "REPLACING-true": r,
246
+ "POPPING-false": o,
247
+ "POPPING-true": i,
248
+ "COMPLETED-false": a,
249
+ "COMPLETED-true": r
250
+ },
251
+ ...s
252
+ };
276
253
  }
277
- const X = (n, t, e) => {
278
- const [s, a] = t, [r, o] = e;
279
- if (a === s) return r;
280
- const c = (n - s) / (a - s);
281
- return r + c * (o - r);
282
- }, F = T({
283
- name: "cupertino",
284
- initial: {
285
- x: "100%"
286
- },
287
- idle: {
288
- value: {
289
- x: 0
290
- },
291
- options: {
292
- duration: 0
293
- }
294
- },
295
- enter: {
296
- value: {
297
- x: 0
298
- },
299
- options: {
300
- duration: 0.7,
301
- ease: [0.32, 0.72, 0, 1]
302
- }
303
- },
304
- enterBack: {
305
- value: {
306
- x: "100%"
307
- },
308
- options: {
309
- duration: 0.6,
310
- ease: [0.32, 0.72, 0, 1]
311
- }
312
- },
313
- exit: {
314
- value: {
315
- x: "-30%"
316
- },
317
- options: {
318
- duration: 0.7,
319
- ease: [0.32, 0.72, 0, 1]
320
- }
321
- },
322
- exitBack: {
323
- value: {
324
- x: 0
325
- },
326
- options: {
327
- duration: 0.6,
328
- ease: [0.32, 0.72, 0, 1]
329
- }
330
- },
331
- options: {
332
- decoratorName: "overlay",
333
- swipeDirection: "x",
334
- onSwipeStart: async () => !0,
335
- onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
336
- const { offset: o } = t, c = o.x, l = X(c, [0, window.innerWidth], [0, 100]);
337
- return r?.(!0, l), e(
338
- s,
339
- {
340
- x: Math.max(0, c)
341
- },
342
- {
343
- duration: 0
344
- }
345
- ), e(
346
- a,
347
- {
348
- x: `${-30 + l * 0.3}%`
349
- },
350
- {
351
- duration: 0
352
- }
353
- ), l;
354
- },
355
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
356
- const { offset: o, velocity: c } = t, u = o.x > 50 || c.x > 20;
357
- return r?.(u), await Promise.all([
358
- e(
359
- s,
360
- {
361
- x: u ? "100%" : 0
362
- },
363
- {
364
- duration: 0.3,
365
- ease: [0.32, 0.72, 0, 1]
366
- }
367
- ),
368
- e(
369
- a,
370
- {
371
- x: u ? 0 : "-30%"
372
- },
373
- {
374
- duration: 0.3,
375
- ease: [0.32, 0.72, 0, 1]
376
- }
377
- )
378
- ]), u;
379
- }
380
- }
381
- }), z = (n, t, e) => {
382
- const [s, a] = t, [r, o] = e;
383
- if (a === s) return r;
384
- const c = (n - s) / (a - s);
385
- return r + c * (o - r);
386
- }, V = T({
387
- name: "layout",
388
- initial: {
389
- opacity: 0.97
390
- },
391
- idle: {
392
- value: {
393
- opacity: 1
394
- },
395
- options: {
396
- duration: 0.3
397
- }
398
- },
399
- enter: {
400
- value: {
401
- opacity: 1
402
- },
403
- options: {
404
- duration: 0.3
405
- }
406
- },
407
- enterBack: {
408
- value: {
409
- opacity: 0.97
410
- },
411
- options: {
412
- duration: 0.3
413
- }
414
- },
415
- exit: {
416
- value: {
417
- opacity: 0.97
418
- },
419
- options: {
420
- duration: 0.3
421
- }
422
- },
423
- exitBack: {
424
- value: {
425
- opacity: 1
426
- },
427
- options: {
428
- duration: 0.3
429
- }
430
- },
431
- options: {
432
- decoratorName: "overlay",
433
- swipeDirection: "y",
434
- onSwipeStart: async () => !0,
435
- onSwipe: (n, t, { animate: e, currentScreen: s, onProgress: a }) => {
436
- const { offset: r } = t, o = r.y, c = Math.max(0, Math.min(56, o)), l = z(c, [0, 56], [1, 0.96]), u = Math.max(0, o - 56), d = Math.min(1, u / 160), p = Math.sqrt(d) * 12, i = Math.max(0, c + p), m = Math.min(56, i);
437
- return a?.(!0, 100), e(
438
- s,
439
- {
440
- y: i,
441
- opacity: l
442
- },
443
- {
444
- duration: 0
445
- }
446
- ), m;
447
- },
448
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
449
- const { offset: o, velocity: c } = t, u = o.y > 56 || c.y > 20;
450
- return r?.(u), await Promise.all([
451
- e(
452
- s,
453
- {
454
- y: u ? "100%" : 0,
455
- opacity: u ? 0.96 : 1
456
- },
457
- {
458
- duration: 0.3
459
- }
460
- ),
461
- e(
462
- a,
463
- {
464
- y: 0,
465
- opacity: u ? 1 : 0.97
466
- },
467
- {
468
- duration: 0.3
469
- }
470
- )
471
- ]), u;
472
- }
473
- }
474
- }), Z = T({
475
- name: "material",
476
- initial: {
477
- y: "100%"
478
- },
479
- idle: {
480
- value: {
481
- y: 0,
482
- opacity: 1
483
- },
484
- options: {
485
- duration: 0
486
- }
487
- },
488
- enter: {
489
- value: {
490
- y: 0
491
- },
492
- options: {
493
- duration: 0.35,
494
- ease: [0, 0, 0.2, 1]
495
- }
496
- },
497
- enterBack: {
498
- value: {
499
- y: "100%"
500
- },
501
- options: {
502
- duration: 0.25,
503
- ease: [0.4, 0, 1, 1]
504
- }
505
- },
506
- exit: {
507
- value: {
508
- y: -56,
509
- opacity: 0
510
- },
511
- options: {
512
- duration: 0.35,
513
- ease: [0.4, 0, 1, 1]
514
- }
515
- },
516
- exitBack: {
517
- value: {
518
- y: 0,
519
- opacity: 1
520
- },
521
- options: {
522
- duration: 0.25,
523
- ease: [0, 0, 0.2, 1]
524
- }
525
- },
526
- options: {
527
- swipeDirection: "y",
528
- onSwipeStart: async () => !0,
529
- onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
530
- const { offset: o } = t, c = o.y, l = Math.max(0, Math.min(56, c)), u = Math.max(0, c - 56), d = Math.min(1, u / 160), p = Math.sqrt(d) * 12, i = Math.max(0, l + p), m = Math.min(56, i);
531
- return r?.(!0, m), e(
532
- s,
533
- {
534
- y: i
535
- },
536
- {
537
- duration: 0
538
- }
539
- ), e(
540
- a,
541
- {
542
- y: -56 + m,
543
- opacity: m / 56
544
- },
545
- { duration: 0 }
546
- ), m;
547
- },
548
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
549
- const { offset: o, velocity: c } = t, u = o.y > 56 || c.y > 20;
550
- return r?.(u), await Promise.all([
551
- e(
552
- s,
553
- {
554
- y: u ? "100%" : 0
555
- },
556
- {
557
- duration: u ? 0.22 : 0.24,
558
- ease: u ? [0.4, 0, 1, 1] : [0, 0, 0.2, 1]
559
- }
560
- ),
561
- e(
562
- a,
563
- {
564
- y: u ? 0 : -56,
565
- opacity: u ? 1 : 0
566
- },
567
- {
568
- duration: u ? 0.22 : 0.24,
569
- ease: u ? [0, 0, 0.2, 1] : [0.4, 0, 1, 1]
570
- }
571
- )
572
- ]), u;
573
- }
574
- }
575
- }), j = T({
576
- name: "none",
577
- initial: {},
578
- idle: {
579
- value: {},
580
- options: {
581
- duration: 0
582
- }
583
- },
584
- enter: {
585
- value: {},
586
- options: {
587
- duration: 0
588
- }
589
- },
590
- enterBack: {
591
- value: {},
592
- options: {
593
- duration: 0
594
- }
595
- },
596
- exit: {
597
- value: {},
598
- options: {
599
- duration: 0
600
- }
601
- },
602
- exitBack: {
603
- value: {},
604
- options: {
605
- duration: 0
606
- }
607
- }
608
- }), Tt = /* @__PURE__ */ new Map([
609
- ["none", j],
610
- ["cupertino", F],
611
- ["material", Z],
612
- ["layout", V]
613
- ]), Nt = w((n) => ({
614
- defaultTransitionName: "cupertino",
615
- setDefaultTransitionName: (t) => n({ defaultTransitionName: t })
616
- }));
617
- function K({
618
- name: n,
619
- initial: t,
620
- idle: e,
621
- enter: s,
622
- exit: a,
623
- options: r
624
- }) {
625
- return {
626
- name: n,
627
- initial: t,
628
- variants: {
629
- "IDLE-true": e,
630
- "IDLE-false": e,
631
- "PUSHING-true": e,
632
- "PUSHING-false": s,
633
- "REPLACING-true": e,
634
- "REPLACING-false": s,
635
- "POPPING-true": e,
636
- "POPPING-false": a,
637
- "COMPLETED-true": e,
638
- "COMPLETED-false": s
639
- },
640
- ...r
641
- };
254
+ //#endregion
255
+ //#region src/transition/createRawTransition.ts
256
+ function u({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnExit: l, completedOnEnter: u, options: d }) {
257
+ return {
258
+ name: e,
259
+ initial: t,
260
+ variants: {
261
+ "IDLE-true": n,
262
+ "IDLE-false": n,
263
+ "PUSHING-false": i,
264
+ "PUSHING-true": r,
265
+ "REPLACING-false": o,
266
+ "REPLACING-true": a,
267
+ "POPPING-false": c,
268
+ "POPPING-true": s,
269
+ "COMPLETED-false": l,
270
+ "COMPLETED-true": u
271
+ },
272
+ ...d
273
+ };
642
274
  }
643
- function Lt({
644
- name: n,
645
- initial: t,
646
- idle: e,
647
- pushOnEnter: s,
648
- pushOnExit: a,
649
- replaceOnEnter: r,
650
- replaceOnExit: o,
651
- popOnEnter: c,
652
- popOnExit: l,
653
- completedOnEnter: u,
654
- completedOnExit: d,
655
- options: p
656
- }) {
657
- return {
658
- name: n,
659
- initial: t,
660
- variants: {
661
- "IDLE-true": e,
662
- "IDLE-false": e,
663
- "PUSHING-false": a,
664
- "PUSHING-true": s,
665
- "REPLACING-false": o,
666
- "REPLACING-true": r,
667
- "POPPING-false": l,
668
- "POPPING-true": c,
669
- "COMPLETED-false": d,
670
- "COMPLETED-true": u
671
- },
672
- ...p
673
- };
275
+ //#endregion
276
+ //#region src/transition/cupertino.ts
277
+ var d = (e, t, n) => {
278
+ let [r, i] = t, [a, o] = n;
279
+ return i === r ? a : a + (e - r) / (i - r) * (o - a);
280
+ }, f = l({
281
+ name: "cupertino",
282
+ initial: { x: "100%" },
283
+ idle: {
284
+ value: { x: 0 },
285
+ options: { duration: 0 }
286
+ },
287
+ enter: {
288
+ value: { x: 0 },
289
+ options: {
290
+ duration: .7,
291
+ ease: [
292
+ .32,
293
+ .72,
294
+ 0,
295
+ 1
296
+ ]
297
+ }
298
+ },
299
+ enterBack: {
300
+ value: { x: "100%" },
301
+ options: {
302
+ duration: .6,
303
+ ease: [
304
+ .32,
305
+ .72,
306
+ 0,
307
+ 1
308
+ ]
309
+ }
310
+ },
311
+ exit: {
312
+ value: { x: "-30%" },
313
+ options: {
314
+ duration: .7,
315
+ ease: [
316
+ .32,
317
+ .72,
318
+ 0,
319
+ 1
320
+ ]
321
+ }
322
+ },
323
+ exitBack: {
324
+ value: { x: 0 },
325
+ options: {
326
+ duration: .6,
327
+ ease: [
328
+ .32,
329
+ .72,
330
+ 0,
331
+ 1
332
+ ]
333
+ }
334
+ },
335
+ options: {
336
+ decoratorName: "overlay",
337
+ swipeDirection: "x",
338
+ onSwipeStart: async () => !0,
339
+ onSwipe: (e, t, { animate: n, currentScreen: r, prevScreen: i, onProgress: a }) => {
340
+ let { offset: o } = t, s = o.x, c = d(s, [0, window.innerWidth], [0, 100]);
341
+ return a?.(!0, c), n(r, { x: Math.max(0, s) }, { duration: 0 }), n(i, { x: `${-30 + c * .3}%` }, { duration: 0 }), c;
342
+ },
343
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
344
+ let { offset: o, velocity: s } = t, c = o.x > 50 || s.x > 20;
345
+ return a?.(c), await Promise.all([n(r, { x: c ? "100%" : 0 }, {
346
+ duration: .3,
347
+ ease: [
348
+ .32,
349
+ .72,
350
+ 0,
351
+ 1
352
+ ]
353
+ }), n(i, { x: c ? 0 : "-30%" }, {
354
+ duration: .3,
355
+ ease: [
356
+ .32,
357
+ .72,
358
+ 0,
359
+ 1
360
+ ]
361
+ })]), c;
362
+ }
363
+ }
364
+ }), p = (e, t, n) => {
365
+ let [r, i] = t, [a, o] = n;
366
+ return i === r ? a : a + (e - r) / (i - r) * (o - a);
367
+ }, m = l({
368
+ name: "layout",
369
+ initial: { opacity: .97 },
370
+ idle: {
371
+ value: { opacity: 1 },
372
+ options: { duration: .3 }
373
+ },
374
+ enter: {
375
+ value: { opacity: 1 },
376
+ options: { duration: .3 }
377
+ },
378
+ enterBack: {
379
+ value: { opacity: .97 },
380
+ options: { duration: .3 }
381
+ },
382
+ exit: {
383
+ value: { opacity: .97 },
384
+ options: { duration: .3 }
385
+ },
386
+ exitBack: {
387
+ value: { opacity: 1 },
388
+ options: { duration: .3 }
389
+ },
390
+ options: {
391
+ decoratorName: "overlay",
392
+ swipeDirection: "y",
393
+ onSwipeStart: async () => !0,
394
+ onSwipe: (e, t, { animate: n, currentScreen: r, onProgress: i }) => {
395
+ let { offset: a } = t, o = a.y, s = Math.max(0, Math.min(56, o)), c = p(s, [0, 56], [1, .96]), l = Math.max(0, o - 56), u = Math.min(1, l / 160), d = Math.sqrt(u) * 12, f = Math.max(0, s + d), m = Math.min(56, f);
396
+ return i?.(!0, 100), n(r, {
397
+ y: f,
398
+ opacity: c
399
+ }, { duration: 0 }), m;
400
+ },
401
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
402
+ let { offset: o, velocity: s } = t, c = o.y > 56 || s.y > 20;
403
+ return a?.(c), await Promise.all([n(r, {
404
+ y: c ? "100%" : 0,
405
+ opacity: c ? .96 : 1
406
+ }, { duration: .3 }), n(i, {
407
+ y: 0,
408
+ opacity: c ? 1 : .97
409
+ }, { duration: .3 })]), c;
410
+ }
411
+ }
412
+ }), h = l({
413
+ name: "material",
414
+ initial: { y: "100%" },
415
+ idle: {
416
+ value: {
417
+ y: 0,
418
+ opacity: 1
419
+ },
420
+ options: { duration: 0 }
421
+ },
422
+ enter: {
423
+ value: { y: 0 },
424
+ options: {
425
+ duration: .35,
426
+ ease: [
427
+ 0,
428
+ 0,
429
+ .2,
430
+ 1
431
+ ]
432
+ }
433
+ },
434
+ enterBack: {
435
+ value: { y: "100%" },
436
+ options: {
437
+ duration: .25,
438
+ ease: [
439
+ .4,
440
+ 0,
441
+ 1,
442
+ 1
443
+ ]
444
+ }
445
+ },
446
+ exit: {
447
+ value: {
448
+ y: -56,
449
+ opacity: 0
450
+ },
451
+ options: {
452
+ duration: .35,
453
+ ease: [
454
+ .4,
455
+ 0,
456
+ 1,
457
+ 1
458
+ ]
459
+ }
460
+ },
461
+ exitBack: {
462
+ value: {
463
+ y: 0,
464
+ opacity: 1
465
+ },
466
+ options: {
467
+ duration: .25,
468
+ ease: [
469
+ 0,
470
+ 0,
471
+ .2,
472
+ 1
473
+ ]
474
+ }
475
+ },
476
+ options: {
477
+ swipeDirection: "y",
478
+ onSwipeStart: async () => !0,
479
+ onSwipe: (e, t, { animate: n, currentScreen: r, prevScreen: i, onProgress: a }) => {
480
+ let { offset: o } = t, s = o.y, c = Math.max(0, Math.min(56, s)), l = Math.max(0, s - 56), u = Math.min(1, l / 160), d = Math.sqrt(u) * 12, f = Math.max(0, c + d), p = Math.min(56, f);
481
+ return a?.(!0, p), n(r, { y: f }, { duration: 0 }), n(i, {
482
+ y: -56 + p,
483
+ opacity: p / 56
484
+ }, { duration: 0 }), p;
485
+ },
486
+ onSwipeEnd: async (e, t, { animate: n, currentScreen: r, prevScreen: i, onStart: a }) => {
487
+ let { offset: o, velocity: s } = t, c = o.y > 56 || s.y > 20;
488
+ return a?.(c), await Promise.all([n(r, { y: c ? "100%" : 0 }, {
489
+ duration: c ? .22 : .24,
490
+ ease: c ? [
491
+ .4,
492
+ 0,
493
+ 1,
494
+ 1
495
+ ] : [
496
+ 0,
497
+ 0,
498
+ .2,
499
+ 1
500
+ ]
501
+ }), n(i, {
502
+ y: c ? 0 : -56,
503
+ opacity: +!!c
504
+ }, {
505
+ duration: c ? .22 : .24,
506
+ ease: c ? [
507
+ 0,
508
+ 0,
509
+ .2,
510
+ 1
511
+ ] : [
512
+ .4,
513
+ 0,
514
+ 1,
515
+ 1
516
+ ]
517
+ })]), c;
518
+ }
519
+ }
520
+ }), g = l({
521
+ name: "none",
522
+ initial: {},
523
+ idle: {
524
+ value: {},
525
+ options: { duration: 0 }
526
+ },
527
+ enter: {
528
+ value: {},
529
+ options: { duration: 0 }
530
+ },
531
+ enterBack: {
532
+ value: {},
533
+ options: { duration: 0 }
534
+ },
535
+ exit: {
536
+ value: {},
537
+ options: { duration: 0 }
538
+ },
539
+ exitBack: {
540
+ value: {},
541
+ options: { duration: 0 }
542
+ }
543
+ }), _ = new Map([
544
+ ["none", g],
545
+ ["cupertino", f],
546
+ ["material", h],
547
+ ["layout", m]
548
+ ]);
549
+ //#endregion
550
+ //#region src/transition/store.ts
551
+ function v(t = "cupertino") {
552
+ return e((e) => ({
553
+ defaultTransitionName: t,
554
+ setDefaultTransitionName: (t) => e({ defaultTransitionName: t })
555
+ }));
674
556
  }
675
- const I = "rgba(0, 0, 0, 0.3)", q = K({
676
- name: "overlay",
677
- initial: {
678
- opacity: 0,
679
- backgroundColor: I
680
- },
681
- idle: {
682
- value: {
683
- opacity: 0,
684
- backgroundColor: I
685
- },
686
- options: {
687
- duration: 0
688
- }
689
- },
690
- // Visible dim — applied when this screen is the one going behind / sitting
691
- // behind a new active screen (PUSHING-false / REPLACING-false / COMPLETED-false).
692
- // Duration matches cupertino's enter so the dim resolves in lockstep with the
693
- // underlying screen slide (and there's no animation-vs-hold-by-fill window for
694
- // the rest-rule handoff to race against — that's a function of duration + fill,
695
- // not the curve). Easing is intentionally left at the default: this animates
696
- // `opacity` (a luminance channel), not position, so cupertino's positional
697
- // decelerate curve would front-load the darkening into an abrupt step with a
698
- // long invisible tail. The default ease spreads the perceived dim evenly across
699
- // the duration, matching this decorator's linear-perceived-ramp design (see the
700
- // DIM_COLOR note above).
701
- enter: {
702
- value: {
703
- opacity: 1,
704
- backgroundColor: I
705
- },
706
- options: {
707
- duration: 0.7
708
- }
709
- },
710
- // POPPING-false target: the previously-behind screen is returning to active.
711
- // Fades from `enter` (visible dim) back to invisible so the overlay clears
712
- // before the screen lands at COMPLETED-true (= idle). Mirrors cupertino's
713
- // enterBack (the returning screen's slide-in) duration.
714
- exit: {
715
- value: {
716
- opacity: 0,
717
- backgroundColor: I
718
- },
719
- options: {
720
- duration: 0.6
721
- }
722
- },
723
- options: {
724
- onSwipeStart: (n, { animate: t, prevDecorator: e }) => t(
725
- e,
726
- {
727
- opacity: n ? 1 : 0
728
- },
729
- {
730
- duration: 0.3
731
- }
732
- ),
733
- onSwipe: (n, t, { animate: e, prevDecorator: s }) => e(
734
- s,
735
- {
736
- opacity: Math.max(0, 1 - t / 100)
737
- },
738
- {
739
- duration: 0
740
- }
741
- ),
742
- onSwipeEnd: (n, { animate: t, prevDecorator: e }) => t(
743
- e,
744
- {
745
- opacity: n ? 0 : 1
746
- },
747
- {
748
- duration: 0.3
749
- }
750
- )
751
- }
752
- }), Dt = /* @__PURE__ */ new Map([["overlay", q]]), k = {
753
- "IDLE-true": "self",
754
- "IDLE-false": "self",
755
- "PUSHING-true": "initial",
756
- "PUSHING-false": "IDLE-true",
757
- "REPLACING-true": "initial",
758
- "REPLACING-false": "IDLE-true",
759
- "POPPING-true": "IDLE-true",
760
- "POPPING-false": "PUSHING-false",
761
- "COMPLETED-true": "self",
762
- "COMPLETED-false": "self"
763
- }, O = Object.keys(k), W = O, J = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), b = (n) => typeof n == "object" && n !== null && !Array.isArray(n), tt = /* @__PURE__ */ new Set([
764
- "opacity",
765
- "scale",
766
- "scaleX",
767
- "scaleY",
768
- "scaleZ",
769
- "aspectRatio",
770
- "columnCount",
771
- "columns",
772
- "flex",
773
- "flexGrow",
774
- "flexShrink",
775
- "fontWeight",
776
- "gridArea",
777
- "gridColumn",
778
- "gridColumnEnd",
779
- "gridColumnStart",
780
- "gridRow",
781
- "gridRowEnd",
782
- "gridRowStart",
783
- "lineHeight",
784
- "lineClamp",
785
- "order",
786
- "orphans",
787
- "tabSize",
788
- "widows",
789
- "zIndex",
790
- "zoom",
791
- // SVG numerics
792
- "fillOpacity",
793
- "floodOpacity",
794
- "stopOpacity",
795
- "strokeOpacity",
796
- "strokeDasharray",
797
- "strokeDashoffset",
798
- "strokeMiterlimit",
799
- "strokeWidth"
800
- ]), et = (n, t) => t.startsWith("--") ? `${n}` : tt.has(t) ? `${n}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${n}deg` : `${n}px`, $ = (n, t) => typeof t == "number" ? et(t, n) : typeof t == "string" ? t : "", R = (n) => n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`), _ = /* @__PURE__ */ new Set([
801
- "x",
802
- "y",
803
- "z",
804
- "scale",
805
- "scaleX",
806
- "scaleY",
807
- "rotate",
808
- "rotateX",
809
- "rotateY",
810
- "rotateZ"
811
- ]), nt = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, st = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, at = /^1(\.0+)?$/, rt = (n, t) => n === "scale" || n === "scaleX" || n === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? at.test(t.trim()) : !1 : n === "rotate" || n === "rotateX" || n === "rotateY" || n === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? st.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? nt.test(t.trim()) : !1, ot = (n, t) => {
812
- switch (n) {
813
- case "x":
814
- return `translateX(${t})`;
815
- case "y":
816
- return `translateY(${t})`;
817
- case "z":
818
- return `translateZ(${t})`;
819
- case "scale":
820
- return `scale(${t})`;
821
- case "scaleX":
822
- return `scaleX(${t})`;
823
- case "scaleY":
824
- return `scaleY(${t})`;
825
- case "rotate":
826
- case "rotateZ":
827
- return `rotate(${t})`;
828
- case "rotateX":
829
- return `rotateX(${t})`;
830
- case "rotateY":
831
- return `rotateY(${t})`;
832
- default:
833
- return "";
834
- }
835
- }, wt = (n) => {
836
- const t = /* @__PURE__ */ new Set();
837
- let e = !1;
838
- const s = (a) => {
839
- if (b(a))
840
- for (const r of Object.keys(a)) {
841
- const o = a[r];
842
- $(r, o) !== "" && (_.has(r) ? e = !0 : t.add(R(r)));
843
- }
844
- };
845
- s(n.initial);
846
- for (const a of Object.values(n.variants))
847
- s(a.value);
848
- return e && t.add("transform"), Array.from(t);
849
- }, g = (n) => {
850
- if (!b(n)) return [];
851
- const t = [];
852
- let e = !0;
853
- const s = [];
854
- for (const a of Object.keys(n)) {
855
- const r = n[a], o = $(a, r);
856
- o !== "" && (_.has(a) ? (t.push(ot(a, o)), rt(a, r) || (e = !1)) : s.push({ property: R(a), value: o }));
857
- }
858
- return t.length > 0 && s.push({
859
- property: "transform",
860
- value: e ? "none" : t.join(" ")
861
- }), s;
862
- }, E = (n) => n.map((t) => ` ${t.property}: ${t.value};`).join(`
863
- `), it = (n) => Array.isArray(n) ? n.length === 4 && n.every((t) => typeof t == "number") ? `cubic-bezier(${n.join(", ")})` : "linear" : typeof n == "string" ? {
864
- linear: "linear",
865
- easeIn: "ease-in",
866
- easeOut: "ease-out",
867
- easeInOut: "ease-in-out",
868
- circIn: "cubic-bezier(0, 0.55, 0.45, 1)",
869
- circOut: "cubic-bezier(0.55, 0, 1, 0.45)",
870
- backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
871
- backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
872
- anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
873
- }[n] ?? "ease" : "ease", H = (n) => {
874
- if (!n) return 0;
875
- const t = n.duration;
876
- return typeof t == "number" && t >= 0 ? t : 0;
877
- }, U = (n) => n && typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, A = (n, t) => {
878
- const [e, s] = t.split("-");
879
- return `[data-flemo-screen][data-flemo-transition="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
880
- }, M = (n, t) => {
881
- const [e, s] = t.split("-");
882
- return `[data-flemo-decorator][data-flemo-decorator-name="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
883
- }, ct = (n, t) => {
884
- const [e, s] = t.split("-");
885
- return `[data-flemo-bar][data-flemo-bar-transition="${n}"][data-flemo-bar-status="${e}"][data-flemo-bar-active="${s}"][data-flemo-bar-riding="true"]`;
886
- }, ut = (n, t, e) => `flemo-${n}-${J(t)}-${e}`, x = (n, t, e, s, a, r) => {
887
- const o = g(s), c = g(a.value), l = H(a.options), u = U(a.options), d = it(a.options?.ease), p = r(t, e), i = n === "screen" ? `${p},
888
- ${ct(t, e)}` : p;
889
- if (c.length === 0 && o.length === 0)
890
- return "";
891
- if (l <= 0 && u <= 0)
892
- return c.length === 0 ? "" : `${i} {
893
- ${E(c)}
894
- animation: none;
895
- }`;
896
- const m = ut(n, t, e), P = [
897
- `@keyframes ${m} {`,
898
- " from {",
899
- E(o).replace(/^/gm, " "),
900
- " }",
901
- " to {",
902
- E(c).replace(/^/gm, " "),
903
- " }",
904
- "}"
905
- ].join(`
906
- `), h = [
907
- `${m}`,
908
- `${l}s`,
909
- d,
910
- u > 0 ? `${u}s` : null,
911
- "both"
912
- ].filter(Boolean).join(" "), f = Array.from(
913
- /* @__PURE__ */ new Set([...o.map((N) => N.property), ...c.map((N) => N.property)])
914
- ), y = f.length > 0 ? ` will-change: ${f.join(", ")};
915
- ` : "", S = e.split("-")[0], Y = `${i} {
916
- animation: ${h};
917
- ${y}${S === "PUSHING" || S === "REPLACING" ? ` contain: layout;
918
- pointer-events: none;
919
- ` : ""}}`;
920
- return `${P}
921
- ${Y}`;
922
- }, C = (n, t, e, s) => {
923
- const a = g(s.value);
924
- return a.length === 0 ? "" : `${n(t, e)} {
925
- ${E(a)}
926
- }`;
927
- }, St = (n, t) => {
928
- const e = [];
929
- for (const s of n) {
930
- const a = s.name;
931
- for (const r of O) {
932
- const o = s.variants[r], c = k[r];
933
- if (c === "self") {
934
- e.push(C(A, a, r, o));
935
- continue;
936
- }
937
- const l = c === "initial" ? s.initial : s.variants[c].value;
938
- e.push(
939
- x("screen", a, r, l, o, A)
940
- );
941
- }
942
- }
943
- for (const s of t) {
944
- const a = s.name;
945
- for (const r of W) {
946
- const o = s.variants[r], c = k[r];
947
- if (c === "self") {
948
- e.push(C(M, a, r, o));
949
- continue;
950
- }
951
- const l = c === "initial" ? s.initial : s.variants[c].value;
952
- e.push(
953
- x(
954
- "decorator",
955
- a,
956
- r,
957
- l,
958
- o,
959
- M
960
- )
961
- );
962
- }
963
- }
964
- return e.filter((s) => s.length > 0).join(`
965
-
966
- `);
967
- }, vt = (n, t) => {
968
- const e = k[t];
969
- if (e === "self") return !1;
970
- const s = n.variants[t], a = H(s.options), r = U(s.options);
971
- if (a <= 0 && r <= 0) return !1;
972
- const o = e === "initial" ? n.initial : n.variants[e].value, c = g(o), l = g(s.value);
973
- return c.length > 0 || l.length > 0;
557
+ //#endregion
558
+ //#region src/transition/decorator/createDecorator.ts
559
+ function y({ name: e, initial: t, idle: n, enter: r, exit: i, options: a }) {
560
+ return {
561
+ name: e,
562
+ initial: t,
563
+ variants: {
564
+ "IDLE-true": n,
565
+ "IDLE-false": n,
566
+ "PUSHING-true": n,
567
+ "PUSHING-false": r,
568
+ "REPLACING-true": n,
569
+ "REPLACING-false": r,
570
+ "POPPING-true": n,
571
+ "POPPING-false": i,
572
+ "COMPLETED-true": n,
573
+ "COMPLETED-false": r
574
+ },
575
+ ...a
576
+ };
577
+ }
578
+ //#endregion
579
+ //#region src/transition/decorator/createRawDecorator.ts
580
+ function ee({ name: e, initial: t, idle: n, pushOnEnter: r, pushOnExit: i, replaceOnEnter: a, replaceOnExit: o, popOnEnter: s, popOnExit: c, completedOnEnter: l, completedOnExit: u, options: d }) {
581
+ return {
582
+ name: e,
583
+ initial: t,
584
+ variants: {
585
+ "IDLE-true": n,
586
+ "IDLE-false": n,
587
+ "PUSHING-false": i,
588
+ "PUSHING-true": r,
589
+ "REPLACING-false": o,
590
+ "REPLACING-true": a,
591
+ "POPPING-false": c,
592
+ "POPPING-true": s,
593
+ "COMPLETED-false": u,
594
+ "COMPLETED-true": l
595
+ },
596
+ ...d
597
+ };
598
+ }
599
+ //#endregion
600
+ //#region src/transition/decorator/overlay.ts
601
+ var b = "rgba(0, 0, 0, 0.3)", x = y({
602
+ name: "overlay",
603
+ initial: {
604
+ opacity: 0,
605
+ backgroundColor: b
606
+ },
607
+ idle: {
608
+ value: {
609
+ opacity: 0,
610
+ backgroundColor: b
611
+ },
612
+ options: { duration: 0 }
613
+ },
614
+ enter: {
615
+ value: {
616
+ opacity: 1,
617
+ backgroundColor: b
618
+ },
619
+ options: { duration: .7 }
620
+ },
621
+ exit: {
622
+ value: {
623
+ opacity: 0,
624
+ backgroundColor: b
625
+ },
626
+ options: { duration: .6 }
627
+ },
628
+ options: {
629
+ onSwipeStart: (e, { animate: t, prevDecorator: n }) => t(n, { opacity: +!!e }, { duration: .3 }),
630
+ onSwipe: (e, t, { animate: n, prevDecorator: r }) => n(r, { opacity: Math.max(0, 1 - t / 100) }, { duration: 0 }),
631
+ onSwipeEnd: (e, { animate: t, prevDecorator: n }) => t(n, { opacity: +!e }, { duration: .3 })
632
+ }
633
+ }), te = new Map([["overlay", x]]), S = {
634
+ "IDLE-true": "self",
635
+ "IDLE-false": "self",
636
+ "PUSHING-true": "initial",
637
+ "PUSHING-false": "IDLE-true",
638
+ "REPLACING-true": "initial",
639
+ "REPLACING-false": "IDLE-true",
640
+ "POPPING-true": "IDLE-true",
641
+ "POPPING-false": "PUSHING-false",
642
+ "COMPLETED-true": "self",
643
+ "COMPLETED-false": "self"
644
+ }, C = Object.keys(S), w = C, ne = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_"), T = (e) => typeof e == "object" && !!e && !Array.isArray(e), E = new Set(/* @__PURE__ */ "opacity.scale.scaleX.scaleY.scaleZ.aspectRatio.columnCount.columns.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineHeight.lineClamp.order.orphans.tabSize.widows.zIndex.zoom.fillOpacity.floodOpacity.stopOpacity.strokeOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeWidth".split(".")), D = (e, t) => t.startsWith("--") || E.has(t) ? `${e}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${e}deg` : `${e}px`, O = (e, t) => typeof t == "number" ? D(t, e) : typeof t == "string" ? t : "", k = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), A = new Set([
645
+ "x",
646
+ "y",
647
+ "z",
648
+ "scale",
649
+ "scaleX",
650
+ "scaleY",
651
+ "rotate",
652
+ "rotateX",
653
+ "rotateY",
654
+ "rotateZ"
655
+ ]), j = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, M = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, N = /^1(\.0+)?$/, P = (e, t) => e === "scale" || e === "scaleX" || e === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? N.test(t.trim()) : !1 : e === "rotate" || e === "rotateX" || e === "rotateY" || e === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? M.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? j.test(t.trim()) : !1, F = (e, t) => {
656
+ switch (e) {
657
+ case "x": return `translateX(${t})`;
658
+ case "y": return `translateY(${t})`;
659
+ case "z": return `translateZ(${t})`;
660
+ case "scale": return `scale(${t})`;
661
+ case "scaleX": return `scaleX(${t})`;
662
+ case "scaleY": return `scaleY(${t})`;
663
+ case "rotate":
664
+ case "rotateZ": return `rotate(${t})`;
665
+ case "rotateX": return `rotateX(${t})`;
666
+ case "rotateY": return `rotateY(${t})`;
667
+ default: return "";
668
+ }
669
+ }, I = (e) => {
670
+ let t = /* @__PURE__ */ new Set(), n = !1, r = (e) => {
671
+ if (T(e)) for (let r of Object.keys(e)) {
672
+ let i = e[r];
673
+ O(r, i) !== "" && (A.has(r) ? n = !0 : t.add(k(r)));
674
+ }
675
+ };
676
+ r(e.initial);
677
+ for (let t of Object.values(e.variants)) r(t.value);
678
+ return n && t.add("transform"), Array.from(t);
679
+ }, L = (e) => {
680
+ if (!T(e)) return [];
681
+ let t = [], n = !0, r = [];
682
+ for (let i of Object.keys(e)) {
683
+ let a = e[i], o = O(i, a);
684
+ o !== "" && (A.has(i) ? (t.push(F(i, o)), P(i, a) || (n = !1)) : r.push({
685
+ property: k(i),
686
+ value: o
687
+ }));
688
+ }
689
+ return t.length > 0 && r.push({
690
+ property: "transform",
691
+ value: n ? "none" : t.join(" ")
692
+ }), r;
693
+ }, R = (e) => e.map((e) => ` ${e.property}: ${e.value};`).join("\n"), z = (e) => Array.isArray(e) ? e.length === 4 && e.every((e) => typeof e == "number") ? `cubic-bezier(${e.join(", ")})` : "linear" : typeof e == "string" ? {
694
+ linear: "linear",
695
+ easeIn: "ease-in",
696
+ easeOut: "ease-out",
697
+ easeInOut: "ease-in-out",
698
+ circIn: "cubic-bezier(0, 0.55, 0.45, 1)",
699
+ circOut: "cubic-bezier(0.55, 0, 1, 0.45)",
700
+ backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
701
+ backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
702
+ anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
703
+ }[e] ?? "ease" : "ease", B = (e) => {
704
+ if (!e) return 0;
705
+ let t = e.duration;
706
+ return typeof t == "number" && t >= 0 ? t : 0;
707
+ }, V = (e) => e && typeof e.delay == "number" && e.delay > 0 ? e.delay : 0, H = (e, t) => {
708
+ let [n, r] = t.split("-");
709
+ return `[data-flemo-screen][data-flemo-transition="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
710
+ }, U = (e, t) => {
711
+ let [n, r] = t.split("-");
712
+ return `[data-flemo-decorator][data-flemo-decorator-name="${e}"][data-flemo-status="${n}"][data-flemo-active="${r}"]`;
713
+ }, W = (e, t) => {
714
+ let [n, r] = t.split("-");
715
+ return `[data-flemo-bar][data-flemo-bar-transition="${e}"][data-flemo-bar-status="${n}"][data-flemo-bar-active="${r}"][data-flemo-bar-riding="true"]`;
716
+ }, G = (e, t, n) => `flemo-${e}-${ne(t)}-${n}`, K = (e, t, n, r, i, a) => {
717
+ let o = L(r), s = L(i.value), c = B(i.options), l = V(i.options), u = z(i.options?.ease), d = a(t, n), f = e === "screen" ? `${d},\n${W(t, n)}` : d;
718
+ if (s.length === 0 && o.length === 0) return "";
719
+ if (c <= 0 && l <= 0) return s.length === 0 ? "" : `${f} {\n${R(s)}\n animation: none;\n}`;
720
+ let p = G(e, t, n), m = [
721
+ `@keyframes ${p} {`,
722
+ " from {",
723
+ R(o).replace(/^/gm, " "),
724
+ " }",
725
+ " to {",
726
+ R(s).replace(/^/gm, " "),
727
+ " }",
728
+ "}"
729
+ ].join("\n"), h = [
730
+ `${p}`,
731
+ `${c}s`,
732
+ u,
733
+ l > 0 ? `${l}s` : null,
734
+ "both"
735
+ ].filter(Boolean).join(" "), g = Array.from(new Set([...o.map((e) => e.property), ...s.map((e) => e.property)])), _ = g.length > 0 ? ` will-change: ${g.join(", ")};\n` : "", v = n.split("-")[0];
736
+ return `${m}\n${`${f} {\n animation: ${h};\n${_}${v === "PUSHING" || v === "REPLACING" ? " contain: layout;\n pointer-events: none;\n" : ""}}`}`;
737
+ }, q = (e, t, n, r) => {
738
+ let i = L(r.value);
739
+ return i.length === 0 ? "" : `${e(t, n)} {\n${R(i)}\n}`;
740
+ }, J = (e, t) => {
741
+ let n = [];
742
+ for (let t of e) {
743
+ let e = t.name;
744
+ for (let r of C) {
745
+ let i = t.variants[r], a = S[r];
746
+ if (a === "self") {
747
+ n.push(q(H, e, r, i));
748
+ continue;
749
+ }
750
+ let o = a === "initial" ? t.initial : t.variants[a].value;
751
+ n.push(K("screen", e, r, o, i, H));
752
+ }
753
+ }
754
+ for (let e of t) {
755
+ let t = e.name;
756
+ for (let r of w) {
757
+ let i = e.variants[r], a = S[r];
758
+ if (a === "self") {
759
+ n.push(q(U, t, r, i));
760
+ continue;
761
+ }
762
+ let o = a === "initial" ? e.initial : e.variants[a].value;
763
+ n.push(K("decorator", t, r, o, i, U));
764
+ }
765
+ }
766
+ return n.filter((e) => e.length > 0).join("\n\n");
767
+ }, Y = (e, t) => {
768
+ let n = S[t];
769
+ if (n === "self") return !1;
770
+ let r = e.variants[t], i = B(r.options), a = V(r.options);
771
+ if (i <= 0 && a <= 0) return !1;
772
+ let o = L(n === "initial" ? e.initial : e.variants[n].value), s = L(r.value);
773
+ return o.length > 0 || s.length > 0;
974
774
  };
975
- function At() {
976
- return typeof document > "u";
775
+ //#endregion
776
+ //#region src/utils/isServer.ts
777
+ function X() {
778
+ return typeof document > "u";
977
779
  }
978
- function lt(n, t) {
979
- return Array.isArray(n) ? n.find((e) => v(e).regexp.test(t)) ?? "" : v(n).regexp.test(t) ? n : "";
780
+ //#endregion
781
+ //#region src/utils/getMatchedPathPattern.ts
782
+ function Z(e, t) {
783
+ return Array.isArray(e) ? e.find((e) => n(e).regexp.test(t)) ?? "" : n(e).regexp.test(t) ? e : "";
980
784
  }
981
- function Mt(n, t, e) {
982
- const s = lt(n, t), a = B(s)(t), r = new URLSearchParams(e), o = Object.fromEntries(r.entries());
983
- return a ? { ...a.params, ...o } : {};
785
+ //#endregion
786
+ //#region src/utils/getParams.ts
787
+ function re(e, n, r) {
788
+ let i = t(Z(e, n))(n), a = new URLSearchParams(r), o = Object.fromEntries(a.entries());
789
+ return i ? {
790
+ ...i.params,
791
+ ...o
792
+ } : {};
984
793
  }
985
- function xt(n, t) {
986
- const {
987
- direction: e = "x",
988
- markerSelector: s = "[data-swipe-at-edge]",
989
- depthLimit: a = 24,
990
- verifyByScroll: r = !1
991
- } = t ?? {}, o = ft(n);
992
- if (!o) return { element: null, hasMarker: !1 };
993
- const c = o.closest?.(s);
994
- if (c instanceof HTMLElement && D(c, e) && (!r || G(c, e)))
995
- return { element: c, hasMarker: !0 };
996
- let l = o, u = 0;
997
- for (; l && u < a; ) {
998
- if (D(l, e) && (!r || G(l, e)))
999
- return { element: l, hasMarker: !1 };
1000
- l = l.parentElement, u++;
1001
- }
1002
- return { element: null, hasMarker: !1 };
794
+ //#endregion
795
+ //#region src/utils/findScrollable.ts
796
+ function ie(e, t) {
797
+ let { direction: n = "x", markerSelector: r = "[data-swipe-at-edge]", depthLimit: i = 24, verifyByScroll: a = !1 } = t ?? {}, o = ae(e);
798
+ if (!o) return {
799
+ element: null,
800
+ hasMarker: !1
801
+ };
802
+ let s = o.closest?.(r);
803
+ if (s instanceof HTMLElement && Q(s, n) && (!a || $(s, n))) return {
804
+ element: s,
805
+ hasMarker: !0
806
+ };
807
+ let c = o, l = 0;
808
+ for (; c && l < i;) {
809
+ if (Q(c, n) && (!a || $(c, n))) return {
810
+ element: c,
811
+ hasMarker: !1
812
+ };
813
+ c = c.parentElement, l++;
814
+ }
815
+ return {
816
+ element: null,
817
+ hasMarker: !1
818
+ };
1003
819
  }
1004
- function ft(n) {
1005
- if (!n) return null;
1006
- const t = n, e = typeof t.composedPath == "function" ? t.composedPath() : void 0;
1007
- if (e && e.length) {
1008
- for (const s of e)
1009
- if (s instanceof HTMLElement) return s;
1010
- }
1011
- return n instanceof HTMLElement ? n : null;
820
+ function ae(e) {
821
+ if (!e) return null;
822
+ let t = e, n = typeof t.composedPath == "function" ? t.composedPath() : void 0;
823
+ if (n && n.length) {
824
+ for (let e of n) if (e instanceof HTMLElement) return e;
825
+ }
826
+ return e instanceof HTMLElement ? e : null;
1012
827
  }
1013
- function D(n, t) {
1014
- return t === "y" ? n.scrollHeight - n.clientHeight > 1 : n.scrollWidth - n.clientWidth > 1;
828
+ function Q(e, t) {
829
+ return t === "y" ? e.scrollHeight - e.clientHeight > 1 : e.scrollWidth - e.clientWidth > 1;
1015
830
  }
1016
- function G(n, t) {
1017
- if (!D(n, t) || typeof window > "u") return !1;
1018
- const e = window.getComputedStyle(n), s = t === "y" ? e.overflowY : e.overflowX;
1019
- return s === "auto" || s === "scroll" || s === "overlay";
831
+ function $(e, t) {
832
+ if (!Q(e, t) || typeof window > "u") return !1;
833
+ let n = window.getComputedStyle(e), r = t === "y" ? n.overflowY : n.overflowX;
834
+ return r === "auto" || r === "scroll" || r === "overlay";
1020
835
  }
1021
- export {
1022
- yt as TaskManger,
1023
- ut as animationName,
1024
- G as canProgrammaticallyScroll,
1025
- wt as collectAnimatedProperties,
1026
- St as compileTransitionStyles,
1027
- Et as consumeSelfInducedPop,
1028
- K as createDecorator,
1029
- Lt as createRawDecorator,
1030
- kt as createRawTransition,
1031
- T as createTransition,
1032
- F as cupertino,
1033
- Dt as decoratorMap,
1034
- it as easingToCss,
1035
- xt as findScrollable,
1036
- lt as getMatchedPathPattern,
1037
- Mt as getParams,
1038
- At as isServer,
1039
- V as layout,
1040
- It as markSelfInducedPop,
1041
- Z as material,
1042
- j as none,
1043
- D as overflowsAxis,
1044
- q as overlay,
1045
- g as targetToDecls,
1046
- Tt as transitionMap,
1047
- Pt as useHistoryStore,
1048
- gt as useNavigateStore,
1049
- Nt as useTransitionStore,
1050
- vt as variantHasAnimation
1051
- };
836
+ //#endregion
837
+ export { r as TaskManger, G as animationName, $ as canProgrammaticallyScroll, I as collectAnimatedProperties, J as compileTransitionStyles, c as consumeSelfInducedPop, y as createDecorator, i as createHistoryStore, a as createNavigateStore, ee as createRawDecorator, u as createRawTransition, l as createTransition, v as createTransitionStore, f as cupertino, te as decoratorMap, z as easingToCss, ie as findScrollable, Z as getMatchedPathPattern, re as getParams, X as isServer, m as layout, s as markSelfInducedPop, h as material, g as none, Q as overflowsAxis, x as overlay, L as targetToDecls, _ as transitionMap, Y as variantHasAnimation };