@flemo/core 1.0.1 → 1.1.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
@@ -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
@@ -186,7 +186,7 @@ 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
191
  })), ht = D((n) => ({
192
192
  status: "IDLE",
@@ -205,10 +205,10 @@ 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,13 +218,13 @@ 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
  };
@@ -233,10 +233,10 @@ function gt({
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,
@@ -262,10 +262,10 @@ function gt({
262
262
  };
263
263
  }
264
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);
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
269
  }, Q = k({
270
270
  name: "cupertino",
271
271
  initial: {
@@ -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 = B(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
  },
@@ -366,10 +366,10 @@ const B = (n, t, e) => {
366
366
  }
367
367
  }
368
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);
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
373
  }, F = k({
374
374
  name: "layout",
375
375
  initial: {
@@ -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 = X(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
@@ -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
  },
@@ -599,9 +599,10 @@ const B = (n, t, e) => {
599
599
  function Z({
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
625
  function It({
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,
@@ -659,19 +660,33 @@ const j = Z({
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
  },
@@ -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
+ ]), tt = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, et = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, nt = /^1(\.0+)?$/, at = (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, st = (n, t) => {
769
784
  switch (n) {
770
785
  case "x":
771
786
  return `translateX(${t})`;
@@ -792,30 +807,30 @@ const j = Z({
792
807
  }, Tt = (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 (G(s))
812
+ for (const r of Object.keys(s)) {
813
+ const o = s[r];
814
+ O(r, o) !== "" && ($.has(r) ? e = !0 : t.add(b(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
822
  if (!G(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 = O(s, r);
828
+ o !== "" && ($.has(s) ? (t.push(st(s, o)), at(s, r) || (e = !1)) : a.push({ property: b(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
835
  `), rt = (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",
@@ -832,28 +847,28 @@ const j = Z({
832
847
  const t = n.duration;
833
848
  return typeof t == "number" && t >= 0 ? t : 0;
834
849
  }, _ = (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}"]`;
850
+ const [e, a] = t.split("-");
851
+ return `[data-flemo-screen][data-flemo-transition="${n}"][data-flemo-status="${e}"][data-flemo-active="${a}"]`;
837
852
  }, 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}"]`;
840
- }, 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},
845
- ${it(t, e)}` : m;
846
- if (c.length === 0 && i.length === 0)
853
+ const [e, a] = t.split("-");
854
+ return `[data-flemo-decorator][data-flemo-decorator-name="${n}"][data-flemo-status="${e}"][data-flemo-active="${a}"]`;
855
+ }, ot = (n, t) => {
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
+ }, it = (n, t, e) => `flemo-${n}-${q(t)}-${e}`, A = (n, t, e, a, s, r) => {
859
+ const o = P(a), c = P(s.value), l = R(s.options), u = _(s.options), d = rt(s.options?.ease), m = r(t, e), i = n === "screen" ? `${m},
860
+ ${ot(t, e)}` : m;
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 = it(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,64 +882,64 @@ ${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
+ ` : "", H = `${i} {
873
888
  animation: ${p};
874
889
  ${y}}`;
875
890
  return `${g}
876
891
  ${H}`;
877
- }, M = (n, t, e, s) => {
878
- const a = P(s.value);
879
- return a.length === 0 ? "" : `${n(t, e)} {
880
- ${E(a)}
892
+ }, M = (n, t, e, a) => {
893
+ const s = P(a.value);
894
+ return s.length === 0 ? "" : `${n(t, e)} {
895
+ ${E(s)}
881
896
  }`;
882
897
  }, Nt = (n, t) => {
883
898
  const e = [];
884
- for (const s of n) {
885
- const a = s.name;
899
+ for (const a of n) {
900
+ const s = a.name;
886
901
  for (const r of C) {
887
- const i = s.variants[r], c = I[r];
902
+ const o = a.variants[r], c = I[r];
888
903
  if (c === "self") {
889
- e.push(M(S, a, r, i));
904
+ e.push(M(S, s, r, o));
890
905
  continue;
891
906
  }
892
- const l = c === "initial" ? s.initial : s.variants[c].value;
907
+ const l = c === "initial" ? a.initial : a.variants[c].value;
893
908
  e.push(
894
- A("screen", a, r, l, i, S)
909
+ A("screen", s, r, l, o, S)
895
910
  );
896
911
  }
897
912
  }
898
- for (const s of t) {
899
- const a = s.name;
913
+ for (const a of t) {
914
+ const s = a.name;
900
915
  for (const r of K) {
901
- const i = s.variants[r], c = I[r];
916
+ const o = a.variants[r], c = I[r];
902
917
  if (c === "self") {
903
- e.push(M(v, a, r, i));
918
+ e.push(M(v, s, r, o));
904
919
  continue;
905
920
  }
906
- const l = c === "initial" ? s.initial : s.variants[c].value;
921
+ const l = c === "initial" ? a.initial : a.variants[c].value;
907
922
  e.push(
908
923
  A(
909
924
  "decorator",
910
- a,
925
+ s,
911
926
  r,
912
927
  l,
913
- i,
928
+ o,
914
929
  v
915
930
  )
916
931
  );
917
932
  }
918
933
  }
919
- return e.filter((s) => s.length > 0).join(`
934
+ return e.filter((a) => a.length > 0).join(`
920
935
 
921
936
  `);
922
937
  }, Lt = (n, t) => {
923
938
  const e = I[t];
924
939
  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);
940
+ const a = n.variants[t], s = R(a.options), r = _(a.options);
941
+ if (s <= 0 && r <= 0) return !1;
942
+ const o = e === "initial" ? n.initial : n.variants[e].value, c = P(o), l = P(a.value);
928
943
  return c.length > 0 || l.length > 0;
929
944
  };
930
945
  function Dt() {
@@ -934,22 +949,22 @@ function ct(n, t) {
934
949
  return Array.isArray(n) ? n.find((e) => w(e).regexp.test(t)) ?? "" : w(n).regexp.test(t) ? n : "";
935
950
  }
936
951
  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 } : {};
952
+ const a = ct(n, t), s = U(a)(t), r = new URLSearchParams(e), o = Object.fromEntries(r.entries());
953
+ return s ? { ...s.params, ...o } : {};
939
954
  }
940
955
  function St(n, t) {
941
956
  const {
942
957
  direction: e = "x",
943
- markerSelector: s = "[data-swipe-at-edge]",
944
- depthLimit: a = 24,
958
+ markerSelector: a = "[data-swipe-at-edge]",
959
+ depthLimit: s = 24,
945
960
  verifyByScroll: r = !1
946
- } = t ?? {}, i = ut(n);
947
- if (!i) return { element: null, hasMarker: !1 };
948
- const c = i.closest?.(s);
961
+ } = t ?? {}, o = ut(n);
962
+ if (!o) return { element: null, hasMarker: !1 };
963
+ const c = o.closest?.(a);
949
964
  if (c instanceof HTMLElement && L(c, e) && (!r || x(c, e)))
950
965
  return { element: c, hasMarker: !0 };
951
- let l = i, u = 0;
952
- for (; l && u < a; ) {
966
+ let l = o, u = 0;
967
+ for (; l && u < s; ) {
953
968
  if (L(l, e) && (!r || x(l, e)))
954
969
  return { element: l, hasMarker: !1 };
955
970
  l = l.parentElement, u++;
@@ -960,8 +975,8 @@ function ut(n) {
960
975
  if (!n) return null;
961
976
  const t = n, e = typeof t.composedPath == "function" ? t.composedPath() : void 0;
962
977
  if (e && e.length) {
963
- for (const s of e)
964
- if (s instanceof HTMLElement) return s;
978
+ for (const a of e)
979
+ if (a instanceof HTMLElement) return a;
965
980
  }
966
981
  return n instanceof HTMLElement ? n : null;
967
982
  }
@@ -970,12 +985,12 @@ function L(n, t) {
970
985
  }
971
986
  function x(n, t) {
972
987
  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";
988
+ const e = window.getComputedStyle(n), a = t === "y" ? e.overflowY : e.overflowX;
989
+ return a === "auto" || a === "scroll" || a === "overlay";
975
990
  }
976
991
  export {
977
992
  dt as TaskManger,
978
- ot as animationName,
993
+ it as animationName,
979
994
  x as canProgrammaticallyScroll,
980
995
  Tt as collectAnimatedProperties,
981
996
  Nt as compileTransitionStyles,
@@ -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.1",
3
+ "version": "1.1.0",
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",
@@ -29,7 +29,7 @@
29
29
  "url": "https://github.com/kimjh96/flemo/issues",
30
30
  "email": "kimjhs@kakao.com"
31
31
  },
32
- "homepage": "https://flemo-web.vercel.app",
32
+ "homepage": "https://flemo.dev",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
35
  "path-to-regexp": "^8.2.0",
@@ -37,6 +37,7 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^24.3.0",
40
+ "@vitest/coverage-v8": "^2.1.8",
40
41
  "csstype": "^3.2.3",
41
42
  "eslint": "^9.33.0",
42
43
  "jsdom": "^25.0.1",
@@ -57,6 +58,7 @@
57
58
  "lint": "eslint \"**/*.{js,mjs,ts,jsx,tsx,mts}\"",
58
59
  "typecheck": "tsc --noEmit",
59
60
  "test": "vitest run",
61
+ "test:coverage": "vitest run --coverage",
60
62
  "test:watch": "vitest",
61
63
  "clean": "rm -rf dist .turbo"
62
64
  }