@flemo/core 1.0.2 → 1.1.1

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,6 +1,6 @@
1
1
  import { create as D } from "zustand";
2
- import { pathToRegexp as w, match as U } from "path-to-regexp";
3
- class Y {
2
+ import { pathToRegexp as S, match as Y } from "path-to-regexp";
3
+ class B {
4
4
  tasks = /* @__PURE__ */ new Map();
5
5
  instanceId = Date.now().toString();
6
6
  isLocked = !1;
@@ -10,7 +10,7 @@ class Y {
10
10
  pendingTaskQueue = [];
11
11
  isProcessingPending = !1;
12
12
  async acquireLock(t) {
13
- for (let a = 0; a < 10; a++) {
13
+ for (let s = 0; s < 10; s++) {
14
14
  if (!this.isLocked)
15
15
  return this.isLocked = !0, this.currentTaskId = t, !0;
16
16
  await new Promise((r) => setTimeout(r, 100));
@@ -25,8 +25,8 @@ class Y {
25
25
  }
26
26
  emitSignal(t) {
27
27
  const e = this.signalListeners.get(t);
28
- e && (e.forEach((s) => {
29
- this.resolveTask(s);
28
+ e && (e.forEach((a) => {
29
+ this.resolveTask(a);
30
30
  }), this.signalListeners.delete(t));
31
31
  }
32
32
  // 대기 중인 태스크들을 처리하는 메서드
@@ -53,7 +53,7 @@ class Y {
53
53
  return new Promise((t) => {
54
54
  const e = () => {
55
55
  this.pendingTaskQueue.filter(
56
- (a) => a.status === "MANUAL_PENDING" || a.status === "SIGNAL_PENDING"
56
+ (s) => s.status === "MANUAL_PENDING" || s.status === "SIGNAL_PENDING"
57
57
  ).length === 0 ? t() : setTimeout(e, 100);
58
58
  };
59
59
  e();
@@ -61,15 +61,15 @@ class Y {
61
61
  }
62
62
  // 태스크 상태 변경 시 대기 큐 처리
63
63
  async onTaskStatusChange(t, e) {
64
- (e === "COMPLETED" || e === "FAILED" || e === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((s) => s.id !== t), await this.processPendingTasks());
64
+ (e === "COMPLETED" || e === "FAILED" || e === "ROLLEDBACK") && (this.pendingTaskQueue = this.pendingTaskQueue.filter((a) => a.id !== t), await this.processPendingTasks());
65
65
  }
66
66
  async addTask(t, e = {}) {
67
- const s = e.id || this.generateTaskId();
68
- return new Promise((a, r) => {
67
+ const a = e.id || this.generateTaskId();
68
+ return new Promise((s, r) => {
69
69
  this.taskQueue = this.taskQueue.then(async () => {
70
70
  try {
71
- const { control: i, validate: c, rollback: l, dependencies: u = [], delay: d } = e, m = new AbortController(), o = {
72
- id: s,
71
+ const { control: o, validate: c, rollback: l, dependencies: u = [], delay: d } = e, m = new AbortController(), i = {
72
+ id: a,
73
73
  execute: t,
74
74
  timestamp: Date.now(),
75
75
  retryCount: 0,
@@ -78,29 +78,29 @@ class Y {
78
78
  instanceId: this.instanceId,
79
79
  validate: c,
80
80
  rollback: l,
81
- control: i,
81
+ control: o,
82
82
  abortController: m
83
83
  };
84
- this.tasks.set(o.id, o), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(o), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((g) => g.id !== o.id));
84
+ this.tasks.set(i.id, i), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(i), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((g) => g.id !== i.id));
85
85
  try {
86
- if (!await this.acquireLock(o.id))
87
- throw o.status = "FAILED", new Error("FAILED");
86
+ if (!await this.acquireLock(i.id))
87
+ throw i.status = "FAILED", new Error("FAILED");
88
88
  try {
89
- o.status = "PROCESSING";
90
- for (const f of o.dependencies) {
89
+ i.status = "PROCESSING";
90
+ for (const f of i.dependencies) {
91
91
  const y = this.tasks.get(f);
92
92
  if (!y || y.status !== "COMPLETED")
93
- throw o.status = "FAILED", new Error("FAILED");
93
+ throw i.status = "FAILED", new Error("FAILED");
94
94
  }
95
- if (o.validate && !await o.validate())
96
- throw o.status = "FAILED", new Error("FAILED");
95
+ if (i.validate && !await i.validate())
96
+ throw i.status = "FAILED", new Error("FAILED");
97
97
  d && d > 0 && await new Promise((f) => setTimeout(f, d));
98
- const p = await o.execute(o.abortController);
99
- if (o.abortController.signal.aborted) {
100
- o.status = "COMPLETED", await this.onTaskStatusChange(o.id, "COMPLETED"), a({
98
+ const p = await i.execute(i.abortController);
99
+ if (i.abortController.signal.aborted) {
100
+ i.status = "COMPLETED", await this.onTaskStatusChange(i.id, "COMPLETED"), s({
101
101
  success: !0,
102
102
  result: void 0,
103
- taskId: o.id,
103
+ taskId: i.id,
104
104
  timestamp: Date.now(),
105
105
  instanceId: this.instanceId
106
106
  });
@@ -109,40 +109,40 @@ class Y {
109
109
  if (e.control) {
110
110
  const f = e.control;
111
111
  if (f.delay && f.delay > 0 && await new Promise((y) => setTimeout(y, f.delay)), f.manual) {
112
- o.status = "MANUAL_PENDING", o.manualResolver = { resolve: a, reject: r, result: p }, this.pendingTaskQueue.push(o), await this.onTaskStatusChange(o.id, "MANUAL_PENDING");
112
+ i.status = "MANUAL_PENDING", i.manualResolver = { resolve: s, reject: r, result: p }, this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "MANUAL_PENDING");
113
113
  return;
114
114
  }
115
115
  if (f.signal) {
116
- o.status = "SIGNAL_PENDING", o.manualResolver = { resolve: a, reject: r, result: p }, this.signalListeners.has(f.signal) || this.signalListeners.set(f.signal, /* @__PURE__ */ new Set()), this.signalListeners.get(f.signal).add(o.id), this.pendingTaskQueue.push(o), await this.onTaskStatusChange(o.id, "SIGNAL_PENDING");
116
+ i.status = "SIGNAL_PENDING", i.manualResolver = { resolve: s, reject: r, result: p }, 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
117
  return;
118
118
  }
119
119
  if (f.condition && !await f.condition()) {
120
- o.status = "MANUAL_PENDING", o.manualResolver = { resolve: a, reject: r, result: p }, this.pendingTaskQueue.push(o), await this.onTaskStatusChange(o.id, "MANUAL_PENDING");
120
+ i.status = "MANUAL_PENDING", i.manualResolver = { resolve: s, reject: r, result: p }, this.pendingTaskQueue.push(i), await this.onTaskStatusChange(i.id, "MANUAL_PENDING");
121
121
  return;
122
122
  }
123
123
  }
124
- o.status = "COMPLETED", await this.onTaskStatusChange(o.id, "COMPLETED"), a({
124
+ i.status = "COMPLETED", await this.onTaskStatusChange(i.id, "COMPLETED"), s({
125
125
  success: !0,
126
126
  result: p,
127
- taskId: o.id,
127
+ taskId: i.id,
128
128
  timestamp: Date.now(),
129
129
  instanceId: this.instanceId
130
130
  });
131
131
  } catch (p) {
132
- if (o.status = "FAILED", o.rollback)
132
+ if (i.status = "FAILED", i.rollback)
133
133
  try {
134
- await o.rollback(), o.status = "ROLLEDBACK";
134
+ await i.rollback(), i.status = "ROLLEDBACK";
135
135
  } catch {
136
136
  }
137
- throw await this.onTaskStatusChange(o.id, o.status), p;
137
+ throw await this.onTaskStatusChange(i.id, i.status), p;
138
138
  } finally {
139
- this.releaseLock(o.id);
139
+ this.releaseLock(i.id);
140
140
  }
141
141
  } catch (g) {
142
142
  r(g);
143
143
  }
144
- } catch (i) {
145
- r(i);
144
+ } catch (o) {
145
+ r(o);
146
146
  }
147
147
  }).catch(r);
148
148
  });
@@ -155,10 +155,10 @@ class Y {
155
155
  if (e.control?.condition && !await e.control.condition())
156
156
  return !1;
157
157
  e.status = "COMPLETED";
158
- const s = e.manualResolver;
159
- return s.resolve({
158
+ const a = e.manualResolver;
159
+ return a.resolve({
160
160
  success: !0,
161
- result: s.result,
161
+ result: a.result,
162
162
  taskId: e.id,
163
163
  timestamp: Date.now(),
164
164
  instanceId: this.instanceId
@@ -173,7 +173,7 @@ class Y {
173
173
  await Promise.all(t.map((e) => this.resolveTask(e.id)));
174
174
  }
175
175
  }
176
- const dt = new Y(), mt = D((n) => ({
176
+ const pt = new B(), yt = D((n) => ({
177
177
  index: -1,
178
178
  histories: [],
179
179
  addHistory: (t) => n((e) => ({
@@ -186,29 +186,29 @@ const dt = new Y(), mt = D((n) => ({
186
186
  })),
187
187
  popHistory: (t) => n((e) => ({
188
188
  index: e.index - 1,
189
- histories: e.histories.filter((s, a) => a !== t)
189
+ histories: e.histories.filter((a, s) => s !== t)
190
190
  }))
191
- })), ht = D((n) => ({
191
+ })), gt = D((n) => ({
192
192
  status: "IDLE",
193
193
  transitionTaskId: null,
194
194
  setStatus: (t) => n({ status: t }),
195
195
  setTransitionTaskId: (t) => n({ transitionTaskId: t })
196
196
  }));
197
197
  let N = 0;
198
- function pt() {
198
+ function Pt() {
199
199
  N += 1;
200
200
  }
201
- function yt() {
201
+ function Et() {
202
202
  return N > 0 ? (N -= 1, !0) : !1;
203
203
  }
204
204
  function k({
205
205
  name: n,
206
206
  initial: t,
207
207
  idle: e,
208
- enter: s,
209
- enterBack: a,
208
+ enter: a,
209
+ enterBack: s,
210
210
  exit: r,
211
- exitBack: i,
211
+ exitBack: o,
212
212
  options: c
213
213
  }) {
214
214
  return {
@@ -218,25 +218,25 @@ function k({
218
218
  "IDLE-true": e,
219
219
  "IDLE-false": e,
220
220
  "PUSHING-false": r,
221
- "PUSHING-true": s,
221
+ "PUSHING-true": a,
222
222
  "REPLACING-false": r,
223
- "REPLACING-true": s,
224
- "POPPING-false": i,
225
- "POPPING-true": a,
223
+ "REPLACING-true": a,
224
+ "POPPING-false": o,
225
+ "POPPING-true": s,
226
226
  "COMPLETED-false": r,
227
- "COMPLETED-true": s
227
+ "COMPLETED-true": a
228
228
  },
229
229
  ...c
230
230
  };
231
231
  }
232
- function gt({
232
+ function It({
233
233
  name: n,
234
234
  initial: t,
235
235
  idle: e,
236
- pushOnEnter: s,
237
- pushOnExit: a,
236
+ pushOnEnter: a,
237
+ pushOnExit: s,
238
238
  replaceOnEnter: r,
239
- replaceOnExit: i,
239
+ replaceOnExit: o,
240
240
  popOnEnter: c,
241
241
  popOnExit: l,
242
242
  completedOnExit: u,
@@ -249,9 +249,9 @@ function gt({
249
249
  variants: {
250
250
  "IDLE-true": e,
251
251
  "IDLE-false": e,
252
- "PUSHING-false": a,
253
- "PUSHING-true": s,
254
- "REPLACING-false": i,
252
+ "PUSHING-false": s,
253
+ "PUSHING-true": a,
254
+ "REPLACING-false": o,
255
255
  "REPLACING-true": r,
256
256
  "POPPING-false": l,
257
257
  "POPPING-true": c,
@@ -261,12 +261,12 @@ function gt({
261
261
  ...m
262
262
  };
263
263
  }
264
- const B = (n, t, e) => {
265
- const [s, a] = t, [r, i] = e;
266
- if (a === s) return r;
267
- const c = (n - s) / (a - s);
268
- return r + c * (i - r);
269
- }, Q = k({
264
+ const Q = (n, t, e) => {
265
+ const [a, s] = t, [r, o] = e;
266
+ if (s === a) return r;
267
+ const c = (n - a) / (s - a);
268
+ return r + c * (o - r);
269
+ }, X = k({
270
270
  name: "cupertino",
271
271
  initial: {
272
272
  x: "100%"
@@ -319,10 +319,10 @@ const B = (n, t, e) => {
319
319
  decoratorName: "overlay",
320
320
  swipeDirection: "x",
321
321
  onSwipeStart: async () => !0,
322
- onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
323
- const { offset: i } = t, c = i.x, l = B(c, [0, window.innerWidth], [0, 100]);
322
+ onSwipe: (n, t, { animate: e, currentScreen: a, prevScreen: s, onProgress: r }) => {
323
+ const { offset: o } = t, c = o.x, l = Q(c, [0, window.innerWidth], [0, 100]);
324
324
  return r?.(!0, l), e(
325
- s,
325
+ a,
326
326
  {
327
327
  x: Math.max(0, c)
328
328
  },
@@ -330,7 +330,7 @@ const B = (n, t, e) => {
330
330
  duration: 0
331
331
  }
332
332
  ), e(
333
- a,
333
+ s,
334
334
  {
335
335
  x: -100 + l
336
336
  },
@@ -339,11 +339,11 @@ const B = (n, t, e) => {
339
339
  }
340
340
  ), l;
341
341
  },
342
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
343
- const { offset: i, velocity: c } = t, u = i.x > 50 || c.x > 20;
342
+ onSwipeEnd: async (n, t, { animate: e, currentScreen: a, prevScreen: s, onStart: r }) => {
343
+ const { offset: o, velocity: c } = t, u = o.x > 50 || c.x > 20;
344
344
  return r?.(u), await Promise.all([
345
345
  e(
346
- s,
346
+ a,
347
347
  {
348
348
  x: u ? "100%" : 0
349
349
  },
@@ -353,7 +353,7 @@ const B = (n, t, e) => {
353
353
  }
354
354
  ),
355
355
  e(
356
- a,
356
+ s,
357
357
  {
358
358
  x: u ? 0 : -100
359
359
  },
@@ -365,12 +365,12 @@ const B = (n, t, e) => {
365
365
  ]), u;
366
366
  }
367
367
  }
368
- }), X = (n, t, e) => {
369
- const [s, a] = t, [r, i] = e;
370
- if (a === s) return r;
371
- const c = (n - s) / (a - s);
372
- return r + c * (i - r);
373
- }, F = k({
368
+ }), F = (n, t, e) => {
369
+ const [a, s] = t, [r, o] = e;
370
+ if (s === a) return r;
371
+ const c = (n - a) / (s - a);
372
+ return r + c * (o - r);
373
+ }, z = k({
374
374
  name: "layout",
375
375
  initial: {
376
376
  opacity: 0.97
@@ -419,12 +419,12 @@ const B = (n, t, e) => {
419
419
  decoratorName: "overlay",
420
420
  swipeDirection: "y",
421
421
  onSwipeStart: async () => !0,
422
- onSwipe: (n, t, { animate: e, currentScreen: s, onProgress: a }) => {
423
- const { offset: r } = t, i = r.y, c = Math.max(0, Math.min(56, i)), l = X(c, [0, 56], [1, 0.96]), u = Math.max(0, i - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, o = Math.max(0, c + m), h = Math.min(56, o);
424
- return a?.(!0, 100), e(
425
- s,
422
+ onSwipe: (n, t, { animate: e, currentScreen: a, onProgress: s }) => {
423
+ const { offset: r } = t, o = r.y, c = Math.max(0, Math.min(56, o)), l = F(c, [0, 56], [1, 0.96]), u = Math.max(0, o - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, i = Math.max(0, c + m), h = Math.min(56, i);
424
+ return s?.(!0, 100), e(
425
+ a,
426
426
  {
427
- y: o,
427
+ y: i,
428
428
  opacity: l
429
429
  },
430
430
  {
@@ -432,11 +432,11 @@ const B = (n, t, e) => {
432
432
  }
433
433
  ), h;
434
434
  },
435
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
436
- const { offset: i, velocity: c } = t, u = i.y > 56 || c.y > 20;
435
+ onSwipeEnd: async (n, t, { animate: e, currentScreen: a, prevScreen: s, onStart: r }) => {
436
+ const { offset: o, velocity: c } = t, u = o.y > 56 || c.y > 20;
437
437
  return r?.(u), await Promise.all([
438
438
  e(
439
- s,
439
+ a,
440
440
  {
441
441
  y: u ? "100%" : 0,
442
442
  opacity: u ? 0.96 : 1
@@ -446,7 +446,7 @@ const B = (n, t, e) => {
446
446
  }
447
447
  ),
448
448
  e(
449
- a,
449
+ s,
450
450
  {
451
451
  y: 0,
452
452
  opacity: u ? 1 : 0.97
@@ -458,7 +458,7 @@ const B = (n, t, e) => {
458
458
  ]), u;
459
459
  }
460
460
  }
461
- }), z = k({
461
+ }), V = k({
462
462
  name: "material",
463
463
  initial: {
464
464
  y: "100%"
@@ -510,29 +510,29 @@ const B = (n, t, e) => {
510
510
  options: {
511
511
  swipeDirection: "y",
512
512
  onSwipeStart: async () => !0,
513
- onSwipe: (n, t, { animate: e, currentScreen: s, prevScreen: a, onProgress: r }) => {
514
- const { offset: i } = t, c = i.y, l = Math.max(0, Math.min(56, c)), u = Math.max(0, c - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, o = Math.max(0, l + m), h = Math.min(56, o);
513
+ onSwipe: (n, t, { animate: e, currentScreen: a, prevScreen: s, onProgress: r }) => {
514
+ 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), m = Math.sqrt(d) * 12, i = Math.max(0, l + m), h = Math.min(56, i);
515
515
  return r?.(!0, h), e(
516
- s,
516
+ a,
517
517
  {
518
- y: o
518
+ y: i
519
519
  },
520
520
  {
521
521
  duration: 0
522
522
  }
523
523
  ), e(
524
- a,
524
+ s,
525
525
  {
526
526
  y: -56 + h
527
527
  },
528
528
  { duration: 0 }
529
529
  ), h;
530
530
  },
531
- onSwipeEnd: async (n, t, { animate: e, currentScreen: s, prevScreen: a, onStart: r }) => {
532
- const { offset: i, velocity: c } = t, u = i.y > 56 || c.y > 20;
531
+ onSwipeEnd: async (n, t, { animate: e, currentScreen: a, prevScreen: s, onStart: r }) => {
532
+ const { offset: o, velocity: c } = t, u = o.y > 56 || c.y > 20;
533
533
  return r?.(u), await Promise.all([
534
534
  e(
535
- s,
535
+ a,
536
536
  {
537
537
  y: u ? "100%" : 0
538
538
  },
@@ -542,7 +542,7 @@ const B = (n, t, e) => {
542
542
  }
543
543
  ),
544
544
  e(
545
- a,
545
+ s,
546
546
  {
547
547
  y: u ? 0 : -56
548
548
  },
@@ -554,7 +554,7 @@ const B = (n, t, e) => {
554
554
  ]), u;
555
555
  }
556
556
  }
557
- }), V = k({
557
+ }), Z = k({
558
558
  name: "none",
559
559
  initial: {},
560
560
  idle: {
@@ -587,21 +587,22 @@ const B = (n, t, e) => {
587
587
  duration: 0
588
588
  }
589
589
  }
590
- }), Pt = /* @__PURE__ */ new Map([
591
- ["none", V],
592
- ["cupertino", Q],
593
- ["material", z],
594
- ["layout", F]
595
- ]), Et = D((n) => ({
590
+ }), kt = /* @__PURE__ */ new Map([
591
+ ["none", Z],
592
+ ["cupertino", X],
593
+ ["material", V],
594
+ ["layout", z]
595
+ ]), Tt = D((n) => ({
596
596
  defaultTransitionName: "cupertino",
597
597
  setDefaultTransitionName: (t) => n({ defaultTransitionName: t })
598
598
  }));
599
- function Z({
599
+ function j({
600
600
  name: n,
601
601
  initial: t,
602
- enter: e,
602
+ idle: e,
603
+ enter: a,
603
604
  exit: s,
604
- options: a
605
+ options: r
605
606
  }) {
606
607
  return {
607
608
  name: n,
@@ -609,26 +610,26 @@ function Z({
609
610
  variants: {
610
611
  "IDLE-true": e,
611
612
  "IDLE-false": e,
612
- "PUSHING-false": s,
613
613
  "PUSHING-true": e,
614
- "REPLACING-false": s,
614
+ "PUSHING-false": a,
615
615
  "REPLACING-true": e,
616
- "POPPING-false": e,
616
+ "REPLACING-false": a,
617
617
  "POPPING-true": e,
618
- "COMPLETED-false": s,
619
- "COMPLETED-true": e
618
+ "POPPING-false": s,
619
+ "COMPLETED-true": e,
620
+ "COMPLETED-false": a
620
621
  },
621
- ...a
622
+ ...r
622
623
  };
623
624
  }
624
- function It({
625
+ function Nt({
625
626
  name: n,
626
627
  initial: t,
627
628
  idle: e,
628
- pushOnEnter: s,
629
- pushOnExit: a,
629
+ pushOnEnter: a,
630
+ pushOnExit: s,
630
631
  replaceOnEnter: r,
631
- replaceOnExit: i,
632
+ replaceOnExit: o,
632
633
  popOnEnter: c,
633
634
  popOnExit: l,
634
635
  completedOnEnter: u,
@@ -641,9 +642,9 @@ function It({
641
642
  variants: {
642
643
  "IDLE-true": e,
643
644
  "IDLE-false": e,
644
- "PUSHING-false": a,
645
- "PUSHING-true": s,
646
- "REPLACING-false": i,
645
+ "PUSHING-false": s,
646
+ "PUSHING-true": a,
647
+ "REPLACING-false": o,
647
648
  "REPLACING-true": r,
648
649
  "POPPING-false": l,
649
650
  "POPPING-true": c,
@@ -653,25 +654,39 @@ function It({
653
654
  ...m
654
655
  };
655
656
  }
656
- const j = Z({
657
+ const K = j({
657
658
  name: "overlay",
658
659
  initial: {
659
660
  opacity: 0,
660
661
  backgroundColor: "rgba(0, 0, 0, 0)"
661
662
  },
662
- enter: {
663
+ idle: {
663
664
  value: {
664
665
  opacity: 0,
666
+ backgroundColor: "rgba(0, 0, 0, 0)"
667
+ },
668
+ options: {
669
+ duration: 0
670
+ }
671
+ },
672
+ // Visible dim — applied when this screen is the one going behind / sitting
673
+ // behind a new active screen (PUSHING-false / REPLACING-false / COMPLETED-false).
674
+ enter: {
675
+ value: {
676
+ opacity: 1,
665
677
  backgroundColor: "rgba(0, 0, 0, 0.3)"
666
678
  },
667
679
  options: {
668
680
  duration: 0.3
669
681
  }
670
682
  },
683
+ // POPPING-false target: the previously-behind screen is returning to active.
684
+ // Fades from `enter` (visible dim) back to invisible so the overlay clears
685
+ // before the screen lands at COMPLETED-true (= idle).
671
686
  exit: {
672
687
  value: {
673
- opacity: 1,
674
- backgroundColor: "rgba(0, 0, 0, 0.3)"
688
+ opacity: 0,
689
+ backgroundColor: "rgba(0, 0, 0, 0)"
675
690
  },
676
691
  options: {
677
692
  duration: 0.3
@@ -687,8 +702,8 @@ const j = Z({
687
702
  duration: 0.3
688
703
  }
689
704
  ),
690
- onSwipe: (n, t, { animate: e, prevDecorator: s }) => e(
691
- s,
705
+ onSwipe: (n, t, { animate: e, prevDecorator: a }) => e(
706
+ a,
692
707
  {
693
708
  opacity: Math.max(0, 1 - t / 100)
694
709
  },
@@ -706,7 +721,7 @@ const j = Z({
706
721
  }
707
722
  )
708
723
  }
709
- }), kt = /* @__PURE__ */ new Map([["overlay", j]]), I = {
724
+ }), Lt = /* @__PURE__ */ new Map([["overlay", K]]), I = {
710
725
  "IDLE-true": "self",
711
726
  "IDLE-false": "self",
712
727
  "PUSHING-true": "initial",
@@ -717,7 +732,7 @@ const j = Z({
717
732
  "POPPING-false": "PUSHING-false",
718
733
  "COMPLETED-true": "self",
719
734
  "COMPLETED-false": "self"
720
- }, C = Object.keys(I), K = C, q = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), G = (n) => typeof n == "object" && n !== null && !Array.isArray(n), W = /* @__PURE__ */ new Set([
735
+ }, G = Object.keys(I), q = G, W = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), O = (n) => typeof n == "object" && n !== null && !Array.isArray(n), J = /* @__PURE__ */ new Set([
721
736
  "opacity",
722
737
  "scale",
723
738
  "scaleX",
@@ -754,7 +769,7 @@ const j = Z({
754
769
  "strokeDashoffset",
755
770
  "strokeMiterlimit",
756
771
  "strokeWidth"
757
- ]), J = (n, t) => t.startsWith("--") ? `${n}` : W.has(t) ? `${n}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${n}deg` : `${n}px`, O = (n, t) => typeof t == "number" ? J(t, n) : typeof t == "string" ? t : "", b = (n) => n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`), $ = /* @__PURE__ */ new Set([
772
+ ]), tt = (n, t) => t.startsWith("--") ? `${n}` : J.has(t) ? `${n}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${n}deg` : `${n}px`, b = (n, t) => typeof t == "number" ? tt(t, n) : typeof t == "string" ? t : "", $ = (n) => n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`), R = /* @__PURE__ */ new Set([
758
773
  "x",
759
774
  "y",
760
775
  "z",
@@ -765,7 +780,7 @@ const j = Z({
765
780
  "rotateX",
766
781
  "rotateY",
767
782
  "rotateZ"
768
- ]), tt = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, et = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, nt = /^1(\.0+)?$/, st = (n, t) => n === "scale" || n === "scaleX" || n === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? nt.test(t.trim()) : !1 : n === "rotate" || n === "rotateX" || n === "rotateY" || n === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? et.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? tt.test(t.trim()) : !1, at = (n, t) => {
783
+ ]), et = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, nt = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, at = /^1(\.0+)?$/, st = (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" ? nt.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? et.test(t.trim()) : !1, rt = (n, t) => {
769
784
  switch (n) {
770
785
  case "x":
771
786
  return `translateX(${t})`;
@@ -789,35 +804,35 @@ const j = Z({
789
804
  default:
790
805
  return "";
791
806
  }
792
- }, Tt = (n) => {
807
+ }, Dt = (n) => {
793
808
  const t = /* @__PURE__ */ new Set();
794
809
  let e = !1;
795
- const s = (a) => {
796
- if (G(a))
797
- for (const r of Object.keys(a)) {
798
- const i = a[r];
799
- O(r, i) !== "" && ($.has(r) ? e = !0 : t.add(b(r)));
810
+ const a = (s) => {
811
+ if (O(s))
812
+ for (const r of Object.keys(s)) {
813
+ const o = s[r];
814
+ b(r, o) !== "" && (R.has(r) ? e = !0 : t.add($(r)));
800
815
  }
801
816
  };
802
- s(n.initial);
803
- for (const a of Object.values(n.variants))
804
- s(a.value);
817
+ a(n.initial);
818
+ for (const s of Object.values(n.variants))
819
+ a(s.value);
805
820
  return e && t.add("transform"), Array.from(t);
806
821
  }, P = (n) => {
807
- if (!G(n)) return [];
822
+ if (!O(n)) return [];
808
823
  const t = [];
809
824
  let e = !0;
810
- const s = [];
811
- for (const a of Object.keys(n)) {
812
- const r = n[a], i = O(a, r);
813
- i !== "" && ($.has(a) ? (t.push(at(a, i)), st(a, r) || (e = !1)) : s.push({ property: b(a), value: i }));
825
+ const a = [];
826
+ for (const s of Object.keys(n)) {
827
+ const r = n[s], o = b(s, r);
828
+ o !== "" && (R.has(s) ? (t.push(rt(s, o)), st(s, r) || (e = !1)) : a.push({ property: $(s), value: o }));
814
829
  }
815
- return t.length > 0 && s.push({
830
+ return t.length > 0 && a.push({
816
831
  property: "transform",
817
832
  value: e ? "none" : t.join(" ")
818
- }), s;
833
+ }), a;
819
834
  }, E = (n) => n.map((t) => ` ${t.property}: ${t.value};`).join(`
820
- `), rt = (n) => Array.isArray(n) ? n.length === 4 && n.every((t) => typeof t == "number") ? `cubic-bezier(${n.join(", ")})` : "linear" : typeof n == "string" ? {
835
+ `), ot = (n) => Array.isArray(n) ? n.length === 4 && n.every((t) => typeof t == "number") ? `cubic-bezier(${n.join(", ")})` : "linear" : typeof n == "string" ? {
821
836
  linear: "linear",
822
837
  easeIn: "ease-in",
823
838
  easeOut: "ease-out",
@@ -827,33 +842,33 @@ const j = Z({
827
842
  backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
828
843
  backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
829
844
  anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
830
- }[n] ?? "ease" : "ease", R = (n) => {
845
+ }[n] ?? "ease" : "ease", _ = (n) => {
831
846
  if (!n) return 0;
832
847
  const t = n.duration;
833
848
  return typeof t == "number" && t >= 0 ? t : 0;
834
- }, _ = (n) => n && typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, S = (n, t) => {
835
- const [e, s] = t.split("-");
836
- return `[data-flemo-screen][data-flemo-transition="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
837
- }, v = (n, t) => {
838
- const [e, s] = t.split("-");
839
- return `[data-flemo-decorator][data-flemo-decorator-name="${n}"][data-flemo-status="${e}"][data-flemo-active="${s}"]`;
849
+ }, H = (n) => n && typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, v = (n, t) => {
850
+ const [e, a] = t.split("-");
851
+ return `[data-flemo-screen][data-flemo-transition="${n}"][data-flemo-status="${e}"][data-flemo-active="${a}"]`;
852
+ }, A = (n, t) => {
853
+ const [e, a] = t.split("-");
854
+ return `[data-flemo-decorator][data-flemo-decorator-name="${n}"][data-flemo-status="${e}"][data-flemo-active="${a}"]`;
840
855
  }, it = (n, t) => {
841
- const [e, s] = t.split("-");
842
- return `[data-flemo-bar][data-flemo-bar-transition="${n}"][data-flemo-bar-status="${e}"][data-flemo-bar-active="${s}"][data-flemo-bar-riding="true"]`;
843
- }, ot = (n, t, e) => `flemo-${n}-${q(t)}-${e}`, A = (n, t, e, s, a, r) => {
844
- const i = P(s), c = P(a.value), l = R(a.options), u = _(a.options), d = rt(a.options?.ease), m = r(t, e), o = n === "screen" ? `${m},
856
+ const [e, a] = t.split("-");
857
+ return `[data-flemo-bar][data-flemo-bar-transition="${n}"][data-flemo-bar-status="${e}"][data-flemo-bar-active="${a}"][data-flemo-bar-riding="true"]`;
858
+ }, ct = (n, t, e) => `flemo-${n}-${W(t)}-${e}`, M = (n, t, e, a, s, r) => {
859
+ const o = P(a), c = P(s.value), l = _(s.options), u = H(s.options), d = ot(s.options?.ease), m = r(t, e), i = n === "screen" ? `${m},
845
860
  ${it(t, e)}` : m;
846
- if (c.length === 0 && i.length === 0)
861
+ if (c.length === 0 && o.length === 0)
847
862
  return "";
848
863
  if (l <= 0 && u <= 0)
849
- return c.length === 0 ? "" : `${o} {
864
+ return c.length === 0 ? "" : `${i} {
850
865
  ${E(c)}
851
866
  animation: none;
852
867
  }`;
853
- const h = ot(n, t, e), g = [
868
+ const h = ct(n, t, e), g = [
854
869
  `@keyframes ${h} {`,
855
870
  " from {",
856
- E(i).replace(/^/gm, " "),
871
+ E(o).replace(/^/gm, " "),
857
872
  " }",
858
873
  " to {",
859
874
  E(c).replace(/^/gm, " "),
@@ -867,140 +882,142 @@ ${E(c)}
867
882
  u > 0 ? `${u}s` : null,
868
883
  "both"
869
884
  ].filter(Boolean).join(" "), f = Array.from(
870
- /* @__PURE__ */ new Set([...i.map((T) => T.property), ...c.map((T) => T.property)])
885
+ /* @__PURE__ */ new Set([...o.map((T) => T.property), ...c.map((T) => T.property)])
871
886
  ), y = f.length > 0 ? ` will-change: ${f.join(", ")};
872
- ` : "", H = `${o} {
887
+ ` : "", w = e.split("-")[0], U = `${i} {
873
888
  animation: ${p};
874
- ${y}}`;
889
+ ${y}${w === "PUSHING" || w === "REPLACING" ? ` contain: layout;
890
+ pointer-events: none;
891
+ ` : ""}}`;
875
892
  return `${g}
876
- ${H}`;
877
- }, M = (n, t, e, s) => {
878
- const a = P(s.value);
879
- return a.length === 0 ? "" : `${n(t, e)} {
880
- ${E(a)}
893
+ ${U}`;
894
+ }, x = (n, t, e, a) => {
895
+ const s = P(a.value);
896
+ return s.length === 0 ? "" : `${n(t, e)} {
897
+ ${E(s)}
881
898
  }`;
882
- }, Nt = (n, t) => {
899
+ }, wt = (n, t) => {
883
900
  const e = [];
884
- for (const s of n) {
885
- const a = s.name;
886
- for (const r of C) {
887
- const i = s.variants[r], c = I[r];
901
+ for (const a of n) {
902
+ const s = a.name;
903
+ for (const r of G) {
904
+ const o = a.variants[r], c = I[r];
888
905
  if (c === "self") {
889
- e.push(M(S, a, r, i));
906
+ e.push(x(v, s, r, o));
890
907
  continue;
891
908
  }
892
- const l = c === "initial" ? s.initial : s.variants[c].value;
909
+ const l = c === "initial" ? a.initial : a.variants[c].value;
893
910
  e.push(
894
- A("screen", a, r, l, i, S)
911
+ M("screen", s, r, l, o, v)
895
912
  );
896
913
  }
897
914
  }
898
- for (const s of t) {
899
- const a = s.name;
900
- for (const r of K) {
901
- const i = s.variants[r], c = I[r];
915
+ for (const a of t) {
916
+ const s = a.name;
917
+ for (const r of q) {
918
+ const o = a.variants[r], c = I[r];
902
919
  if (c === "self") {
903
- e.push(M(v, a, r, i));
920
+ e.push(x(A, s, r, o));
904
921
  continue;
905
922
  }
906
- const l = c === "initial" ? s.initial : s.variants[c].value;
923
+ const l = c === "initial" ? a.initial : a.variants[c].value;
907
924
  e.push(
908
- A(
925
+ M(
909
926
  "decorator",
910
- a,
927
+ s,
911
928
  r,
912
929
  l,
913
- i,
914
- v
930
+ o,
931
+ A
915
932
  )
916
933
  );
917
934
  }
918
935
  }
919
- return e.filter((s) => s.length > 0).join(`
936
+ return e.filter((a) => a.length > 0).join(`
920
937
 
921
938
  `);
922
- }, Lt = (n, t) => {
939
+ }, St = (n, t) => {
923
940
  const e = I[t];
924
941
  if (e === "self") return !1;
925
- const s = n.variants[t], a = R(s.options), r = _(s.options);
926
- if (a <= 0 && r <= 0) return !1;
927
- const i = e === "initial" ? n.initial : n.variants[e].value, c = P(i), l = P(s.value);
942
+ const a = n.variants[t], s = _(a.options), r = H(a.options);
943
+ if (s <= 0 && r <= 0) return !1;
944
+ const o = e === "initial" ? n.initial : n.variants[e].value, c = P(o), l = P(a.value);
928
945
  return c.length > 0 || l.length > 0;
929
946
  };
930
- function Dt() {
947
+ function vt() {
931
948
  return typeof document > "u";
932
949
  }
933
- function ct(n, t) {
934
- return Array.isArray(n) ? n.find((e) => w(e).regexp.test(t)) ?? "" : w(n).regexp.test(t) ? n : "";
950
+ function ut(n, t) {
951
+ return Array.isArray(n) ? n.find((e) => S(e).regexp.test(t)) ?? "" : S(n).regexp.test(t) ? n : "";
935
952
  }
936
- function wt(n, t, e) {
937
- const s = ct(n, t), a = U(s)(t), r = new URLSearchParams(e), i = Object.fromEntries(r.entries());
938
- return a ? { ...a.params, ...i } : {};
953
+ function At(n, t, e) {
954
+ const a = ut(n, t), s = Y(a)(t), r = new URLSearchParams(e), o = Object.fromEntries(r.entries());
955
+ return s ? { ...s.params, ...o } : {};
939
956
  }
940
- function St(n, t) {
957
+ function Mt(n, t) {
941
958
  const {
942
959
  direction: e = "x",
943
- markerSelector: s = "[data-swipe-at-edge]",
944
- depthLimit: a = 24,
960
+ markerSelector: a = "[data-swipe-at-edge]",
961
+ depthLimit: s = 24,
945
962
  verifyByScroll: r = !1
946
- } = t ?? {}, i = ut(n);
947
- if (!i) return { element: null, hasMarker: !1 };
948
- const c = i.closest?.(s);
949
- if (c instanceof HTMLElement && L(c, e) && (!r || x(c, e)))
963
+ } = t ?? {}, o = lt(n);
964
+ if (!o) return { element: null, hasMarker: !1 };
965
+ const c = o.closest?.(a);
966
+ if (c instanceof HTMLElement && L(c, e) && (!r || C(c, e)))
950
967
  return { element: c, hasMarker: !0 };
951
- let l = i, u = 0;
952
- for (; l && u < a; ) {
953
- if (L(l, e) && (!r || x(l, e)))
968
+ let l = o, u = 0;
969
+ for (; l && u < s; ) {
970
+ if (L(l, e) && (!r || C(l, e)))
954
971
  return { element: l, hasMarker: !1 };
955
972
  l = l.parentElement, u++;
956
973
  }
957
974
  return { element: null, hasMarker: !1 };
958
975
  }
959
- function ut(n) {
976
+ function lt(n) {
960
977
  if (!n) return null;
961
978
  const t = n, e = typeof t.composedPath == "function" ? t.composedPath() : void 0;
962
979
  if (e && e.length) {
963
- for (const s of e)
964
- if (s instanceof HTMLElement) return s;
980
+ for (const a of e)
981
+ if (a instanceof HTMLElement) return a;
965
982
  }
966
983
  return n instanceof HTMLElement ? n : null;
967
984
  }
968
985
  function L(n, t) {
969
986
  return t === "y" ? n.scrollHeight - n.clientHeight > 1 : n.scrollWidth - n.clientWidth > 1;
970
987
  }
971
- function x(n, t) {
988
+ function C(n, t) {
972
989
  if (!L(n, t) || typeof window > "u") return !1;
973
- const e = window.getComputedStyle(n), s = t === "y" ? e.overflowY : e.overflowX;
974
- return s === "auto" || s === "scroll" || s === "overlay";
990
+ const e = window.getComputedStyle(n), a = t === "y" ? e.overflowY : e.overflowX;
991
+ return a === "auto" || a === "scroll" || a === "overlay";
975
992
  }
976
993
  export {
977
- dt as TaskManger,
978
- ot as animationName,
979
- x as canProgrammaticallyScroll,
980
- Tt as collectAnimatedProperties,
981
- Nt as compileTransitionStyles,
982
- yt as consumeSelfInducedPop,
983
- Z as createDecorator,
984
- It as createRawDecorator,
985
- gt as createRawTransition,
994
+ pt as TaskManger,
995
+ ct as animationName,
996
+ C as canProgrammaticallyScroll,
997
+ Dt as collectAnimatedProperties,
998
+ wt as compileTransitionStyles,
999
+ Et as consumeSelfInducedPop,
1000
+ j as createDecorator,
1001
+ Nt as createRawDecorator,
1002
+ It as createRawTransition,
986
1003
  k as createTransition,
987
- Q as cupertino,
988
- kt as decoratorMap,
989
- rt as easingToCss,
990
- St as findScrollable,
991
- ct as getMatchedPathPattern,
992
- wt as getParams,
993
- Dt as isServer,
994
- F as layout,
995
- pt as markSelfInducedPop,
996
- z as material,
997
- V as none,
1004
+ X as cupertino,
1005
+ Lt as decoratorMap,
1006
+ ot as easingToCss,
1007
+ Mt as findScrollable,
1008
+ ut as getMatchedPathPattern,
1009
+ At as getParams,
1010
+ vt as isServer,
1011
+ z as layout,
1012
+ Pt as markSelfInducedPop,
1013
+ V as material,
1014
+ Z as none,
998
1015
  L as overflowsAxis,
999
- j as overlay,
1016
+ K as overlay,
1000
1017
  P as targetToDecls,
1001
- Pt as transitionMap,
1002
- mt as useHistoryStore,
1003
- ht as useNavigateStore,
1004
- Et as useTransitionStore,
1005
- Lt as variantHasAnimation
1018
+ kt as transitionMap,
1019
+ yt as useHistoryStore,
1020
+ gt as useNavigateStore,
1021
+ Tt as useTransitionStore,
1022
+ St as variantHasAnimation
1006
1023
  };
@@ -8,4 +8,9 @@ declare module '../typing' {
8
8
  "custom-css-vars": "custom-css-vars";
9
9
  }
10
10
  }
11
+ declare module '../decorator/typing' {
12
+ interface RegisterDecorator {
13
+ "rich-deco": "rich-deco";
14
+ }
15
+ }
11
16
  export {};
@@ -4,9 +4,10 @@ import { DecoratorName, Decorator, DecoratorOptions } from './typing';
4
4
  interface CreateDecoratorProps {
5
5
  name: DecoratorName;
6
6
  initial: InitialTarget;
7
+ idle: TransitionVariantValue;
7
8
  enter: TransitionVariantValue;
8
9
  exit: TransitionVariantValue;
9
10
  options?: DecoratorOptions;
10
11
  }
11
- export default function createDecorator({ name, initial, enter, exit, options }: CreateDecoratorProps): Decorator;
12
+ export default function createDecorator({ name, initial, idle, enter, exit, options }: CreateDecoratorProps): Decorator;
12
13
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemo/core",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "Framework-agnostic primitives for flemo: history, navigation, transitions, task manager.",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",