@kazuhi-ra/turnbox-core 0.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.
@@ -0,0 +1,79 @@
1
+ type Axis = "X" | "Y";
2
+ type Direction = "positive" | "negative";
3
+ type AnimationType = "real" | "repeat" | "skip";
4
+ declare const VIRTUAL_PREV_WRAP: 0;
5
+ declare const VIRTUAL_NEXT_WRAP: 5;
6
+ type VirtualWrapFace = typeof VIRTUAL_PREV_WRAP | typeof VIRTUAL_NEXT_WRAP;
7
+ type Transition = {
8
+ kind: "noop";
9
+ } | {
10
+ kind: "step";
11
+ to: number;
12
+ doAnimate: boolean;
13
+ hasAdjust: boolean;
14
+ } | {
15
+ kind: "virtual-wrap";
16
+ via: VirtualWrapFace;
17
+ landAt: 1 | 4;
18
+ doAnimate: boolean;
19
+ } | {
20
+ kind: "direct-wrap";
21
+ to: number;
22
+ doAnimate: boolean;
23
+ };
24
+ type RotationDeg = -360 | -270 | -180 | -90 | 0 | 90 | 180 | 270 | 360;
25
+ type FaceVisibility = "front" | "side" | "hidden";
26
+ type FaceParity = "odd" | "even";
27
+ type Geometry = {
28
+ kind: "fixed";
29
+ axis: Axis;
30
+ length: number;
31
+ } | {
32
+ kind: "variable";
33
+ axis: Axis;
34
+ length: number;
35
+ even: number;
36
+ };
37
+ type FaceCount = 2 | 3 | 4;
38
+ type TurnBoxOptions = {
39
+ faces: FaceCount;
40
+ axis?: Axis;
41
+ direction?: Direction;
42
+ type?: AnimationType;
43
+ duration?: number;
44
+ delay?: number;
45
+ width?: number;
46
+ height?: number;
47
+ even?: number;
48
+ onChange?: (face: number) => void;
49
+ onAnimationEnd?: (face: number) => void;
50
+ };
51
+ type NormalizedOptions = {
52
+ faces: FaceCount;
53
+ direction: Direction;
54
+ type: AnimationType;
55
+ duration: number;
56
+ delay: number;
57
+ geometry: Geometry;
58
+ };
59
+ type FaceTransform = {
60
+ axis: Axis;
61
+ deg: RotationDeg;
62
+ x: number;
63
+ y: number;
64
+ z: number;
65
+ zIndex: number;
66
+ transformOrigin: string;
67
+ };
68
+
69
+ declare const MAX_FACE_PCS = 4;
70
+ declare const DEFAULT_DURATION = 800;
71
+ declare const DEFAULT_DELAY = 50;
72
+ declare const DEFAULT_SIZE = 200;
73
+ declare const normalizeOptions: (options: TurnBoxOptions) => NormalizedOptions;
74
+
75
+ declare const getFaceParity: (faceNum: number) => FaceParity;
76
+ declare const calcFaceTransform: (currentFace: number, faceNum: number, options: NormalizedOptions) => FaceTransform;
77
+ declare const calcAdjustFaceTransform: (currentFace: number, faceNum: number, options: NormalizedOptions) => FaceTransform;
78
+
79
+ export { type AnimationType as A, DEFAULT_DELAY as D, type FaceCount as F, type Geometry as G, MAX_FACE_PCS as M, type NormalizedOptions as N, type RotationDeg as R, type Transition as T, VIRTUAL_NEXT_WRAP as V, type Axis as a, DEFAULT_DURATION as b, DEFAULT_SIZE as c, type Direction as d, type FaceParity as e, type FaceTransform as f, type FaceVisibility as g, type TurnBoxOptions as h, VIRTUAL_PREV_WRAP as i, type VirtualWrapFace as j, calcAdjustFaceTransform as k, calcFaceTransform as l, getFaceParity as m, normalizeOptions as n };
@@ -0,0 +1,79 @@
1
+ type Axis = "X" | "Y";
2
+ type Direction = "positive" | "negative";
3
+ type AnimationType = "real" | "repeat" | "skip";
4
+ declare const VIRTUAL_PREV_WRAP: 0;
5
+ declare const VIRTUAL_NEXT_WRAP: 5;
6
+ type VirtualWrapFace = typeof VIRTUAL_PREV_WRAP | typeof VIRTUAL_NEXT_WRAP;
7
+ type Transition = {
8
+ kind: "noop";
9
+ } | {
10
+ kind: "step";
11
+ to: number;
12
+ doAnimate: boolean;
13
+ hasAdjust: boolean;
14
+ } | {
15
+ kind: "virtual-wrap";
16
+ via: VirtualWrapFace;
17
+ landAt: 1 | 4;
18
+ doAnimate: boolean;
19
+ } | {
20
+ kind: "direct-wrap";
21
+ to: number;
22
+ doAnimate: boolean;
23
+ };
24
+ type RotationDeg = -360 | -270 | -180 | -90 | 0 | 90 | 180 | 270 | 360;
25
+ type FaceVisibility = "front" | "side" | "hidden";
26
+ type FaceParity = "odd" | "even";
27
+ type Geometry = {
28
+ kind: "fixed";
29
+ axis: Axis;
30
+ length: number;
31
+ } | {
32
+ kind: "variable";
33
+ axis: Axis;
34
+ length: number;
35
+ even: number;
36
+ };
37
+ type FaceCount = 2 | 3 | 4;
38
+ type TurnBoxOptions = {
39
+ facePcs: FaceCount;
40
+ axis?: Axis;
41
+ direction?: Direction;
42
+ type?: AnimationType;
43
+ duration?: number;
44
+ delay?: number;
45
+ width?: number;
46
+ height?: number;
47
+ even?: number;
48
+ onChange?: (face: number) => void;
49
+ onAnimationEnd?: (face: number) => void;
50
+ };
51
+ type NormalizedOptions = {
52
+ facePcs: FaceCount;
53
+ direction: Direction;
54
+ type: AnimationType;
55
+ duration: number;
56
+ delay: number;
57
+ geometry: Geometry;
58
+ };
59
+ type FaceTransform = {
60
+ axis: Axis;
61
+ deg: RotationDeg;
62
+ x: number;
63
+ y: number;
64
+ z: number;
65
+ zIndex: number;
66
+ transformOrigin: string;
67
+ };
68
+
69
+ declare const MAX_FACE_PCS = 4;
70
+ declare const DEFAULT_DURATION = 800;
71
+ declare const DEFAULT_DELAY = 50;
72
+ declare const DEFAULT_SIZE = 200;
73
+ declare const normalizeOptions: (options: TurnBoxOptions) => NormalizedOptions;
74
+
75
+ declare const getFaceParity: (faceNum: number) => FaceParity;
76
+ declare const calcFaceTransform: (currentFace: number, faceNum: number, options: NormalizedOptions) => FaceTransform;
77
+ declare const calcAdjustFaceTransform: (currentFace: number, faceNum: number, options: NormalizedOptions) => FaceTransform;
78
+
79
+ export { type AnimationType as A, DEFAULT_DELAY as D, type FaceCount as F, type Geometry as G, MAX_FACE_PCS as M, type NormalizedOptions as N, type RotationDeg as R, type Transition as T, VIRTUAL_NEXT_WRAP as V, type Axis as a, DEFAULT_DURATION as b, DEFAULT_SIZE as c, type Direction as d, type FaceParity as e, type FaceTransform as f, type FaceVisibility as g, type TurnBoxOptions as h, VIRTUAL_PREV_WRAP as i, type VirtualWrapFace as j, calcAdjustFaceTransform as k, calcFaceTransform as l, getFaceParity as m, normalizeOptions as n };
@@ -0,0 +1,87 @@
1
+ type Axis = "X" | "Y";
2
+ type Direction = "positive" | "negative";
3
+ type AnimationType = "real" | "repeat" | "skip";
4
+ declare const VIRTUAL_PREV_WRAP: 0;
5
+ declare const VIRTUAL_NEXT_WRAP: 5;
6
+ type VirtualWrapFace = typeof VIRTUAL_PREV_WRAP | typeof VIRTUAL_NEXT_WRAP;
7
+ type Transition = {
8
+ kind: "noop";
9
+ } | {
10
+ kind: "step";
11
+ to: number;
12
+ doAnimate: boolean;
13
+ hasAdjust: boolean;
14
+ } | {
15
+ kind: "virtual-wrap";
16
+ via: VirtualWrapFace;
17
+ landAt: 1 | 4;
18
+ doAnimate: boolean;
19
+ } | {
20
+ kind: "direct-wrap";
21
+ to: number;
22
+ doAnimate: boolean;
23
+ };
24
+ type RotationDeg = -360 | -270 | -180 | -90 | 0 | 90 | 180 | 270 | 360;
25
+ type FaceVisibility = "front" | "side" | "hidden";
26
+ type FaceParity = "odd" | "even";
27
+ type Geometry = {
28
+ kind: "fixed";
29
+ axis: Axis;
30
+ length: number;
31
+ } | {
32
+ kind: "variable";
33
+ axis: Axis;
34
+ length: number;
35
+ even: number;
36
+ };
37
+ type FaceCount = 2 | 3 | 4;
38
+ type TurnBoxOptions = {
39
+ faces: FaceCount;
40
+ axis?: Axis;
41
+ direction?: Direction;
42
+ type?: AnimationType;
43
+ duration?: number;
44
+ delay?: number;
45
+ easing?: string;
46
+ perspective?: number;
47
+ width?: number;
48
+ height?: number;
49
+ even?: number;
50
+ onChange?: (face: number) => void;
51
+ onAnimationEnd?: (face: number) => void;
52
+ };
53
+ type NormalizedOptions = {
54
+ faces: FaceCount;
55
+ direction: Direction;
56
+ type: AnimationType;
57
+ duration: number;
58
+ delay: number;
59
+ easing: string;
60
+ perspective: number;
61
+ geometry: Geometry;
62
+ };
63
+ type FaceTransform = {
64
+ axis: Axis;
65
+ deg: RotationDeg;
66
+ x: number;
67
+ y: number;
68
+ z: number;
69
+ zIndex: number;
70
+ transformOrigin: string;
71
+ };
72
+
73
+ declare const MAX_FACE_PCS = 4;
74
+ declare const DEFAULT_DURATION = 200;
75
+ declare const DEFAULT_DELAY = 0;
76
+ declare const DEFAULT_EASING = "linear";
77
+ declare const DEFAULT_PERSPECTIVE = 800;
78
+ declare const DEFAULT_SIZE = 200;
79
+ declare const DEFAULT_HEIGHT = 50;
80
+ declare const normalizeOptions: (options: TurnBoxOptions) => NormalizedOptions;
81
+
82
+ declare const getFaceParity: (faceNum: number) => FaceParity;
83
+ declare const calcFaceTransform: (currentFace: number, faceNum: number, options: NormalizedOptions) => FaceTransform;
84
+ declare const calcAdjustFaceTransform: (currentFace: number, faceNum: number, options: NormalizedOptions) => FaceTransform;
85
+ declare const calcPrePositionTransform: (via: VirtualWrapFace, opts: NormalizedOptions) => string;
86
+
87
+ export { type AnimationType as A, DEFAULT_DELAY as D, type FaceCount as F, type Geometry as G, MAX_FACE_PCS as M, type NormalizedOptions as N, type RotationDeg as R, type Transition as T, VIRTUAL_NEXT_WRAP as V, type Axis as a, DEFAULT_DURATION as b, DEFAULT_EASING as c, DEFAULT_HEIGHT as d, DEFAULT_PERSPECTIVE as e, DEFAULT_SIZE as f, type Direction as g, type FaceParity as h, type FaceTransform as i, type FaceVisibility as j, type TurnBoxOptions as k, VIRTUAL_PREV_WRAP as l, type VirtualWrapFace as m, calcAdjustFaceTransform as n, calcFaceTransform as o, calcPrePositionTransform as p, getFaceParity as q, normalizeOptions as r };
@@ -0,0 +1,107 @@
1
+ type Axis = "X" | "Y";
2
+ type Direction = "positive" | "negative";
3
+ type AnimationType = "real" | "repeat" | "skip";
4
+ declare const VIRTUAL_PREV_WRAP: 0;
5
+ declare const VIRTUAL_NEXT_WRAP: 5;
6
+ type VirtualWrapFace = typeof VIRTUAL_PREV_WRAP | typeof VIRTUAL_NEXT_WRAP;
7
+ type Transition =
8
+ | {
9
+ kind: "noop";
10
+ }
11
+ | {
12
+ kind: "step";
13
+ to: number;
14
+ doAnimate: boolean;
15
+ hasAdjust: boolean;
16
+ }
17
+ | {
18
+ kind: "virtual-wrap";
19
+ via: VirtualWrapFace;
20
+ landAt: 1 | 4;
21
+ doAnimate: boolean;
22
+ }
23
+ | {
24
+ kind: "direct-wrap";
25
+ to: number;
26
+ doAnimate: boolean;
27
+ };
28
+ type RotationDeg = -360 | -270 | -180 | -90 | 0 | 90 | 180 | 270 | 360;
29
+ type FaceVisibility = "front" | "side" | "hidden";
30
+ type FaceParity = "odd" | "even";
31
+ type Geometry =
32
+ | {
33
+ kind: "fixed";
34
+ axis: Axis;
35
+ length: number;
36
+ }
37
+ | {
38
+ kind: "variable";
39
+ axis: Axis;
40
+ length: number;
41
+ even: number;
42
+ };
43
+ type FaceCount = 2 | 3 | 4;
44
+ type TurnBoxOptions = {
45
+ facePcs: FaceCount;
46
+ axis?: Axis;
47
+ direction?: Direction;
48
+ type?: AnimationType;
49
+ duration?: number;
50
+ delay?: number;
51
+ width?: number;
52
+ height?: number;
53
+ even?: number;
54
+ onChange?: (face: number) => void;
55
+ onAnimationEnd?: (face: number) => void;
56
+ };
57
+ type NormalizedOptions = {
58
+ facePcs: FaceCount;
59
+ direction: Direction;
60
+ type: AnimationType;
61
+ duration: number;
62
+ delay: number;
63
+ geometry: Geometry;
64
+ };
65
+ type FaceTransform = {
66
+ axis: Axis;
67
+ deg: RotationDeg;
68
+ x: number;
69
+ y: number;
70
+ z: number;
71
+ zIndex: number;
72
+ transformOrigin: string;
73
+ };
74
+
75
+ declare const MAX_FACE_PCS = 4;
76
+ declare const normalizeOptions: (options: TurnBoxOptions) => NormalizedOptions;
77
+
78
+ declare const getFaceParity: (faceNum: number) => FaceParity;
79
+ declare const calcFaceTransform: (currentFace: number, faceNum: number, options: NormalizedOptions) => FaceTransform;
80
+ declare const calcAdjustFaceTransform: (
81
+ currentFace: number,
82
+ faceNum: number,
83
+ options: NormalizedOptions,
84
+ ) => FaceTransform;
85
+
86
+ export {
87
+ type AnimationType as A,
88
+ type Direction as D,
89
+ type FaceCount as F,
90
+ type Geometry as G,
91
+ MAX_FACE_PCS as M,
92
+ type NormalizedOptions as N,
93
+ type RotationDeg as R,
94
+ type Transition as T,
95
+ VIRTUAL_NEXT_WRAP as V,
96
+ type Axis as a,
97
+ type FaceParity as b,
98
+ type FaceTransform as c,
99
+ type FaceVisibility as d,
100
+ type TurnBoxOptions as e,
101
+ VIRTUAL_PREV_WRAP as f,
102
+ type VirtualWrapFace as g,
103
+ calcAdjustFaceTransform as h,
104
+ calcFaceTransform as i,
105
+ getFaceParity as j,
106
+ normalizeOptions as n,
107
+ };
@@ -0,0 +1,105 @@
1
+ type Axis = "X" | "Y";
2
+ type Direction = "positive" | "negative";
3
+ type AnimationType = "real" | "repeat" | "skip";
4
+ declare const VIRTUAL_PREV_WRAP: 0;
5
+ declare const VIRTUAL_NEXT_WRAP: 5;
6
+ type VirtualWrapFace = typeof VIRTUAL_PREV_WRAP | typeof VIRTUAL_NEXT_WRAP;
7
+ type Transition =
8
+ | {
9
+ kind: "noop";
10
+ }
11
+ | {
12
+ kind: "step";
13
+ to: number;
14
+ doAnimate: boolean;
15
+ hasAdjust: boolean;
16
+ }
17
+ | {
18
+ kind: "virtual-wrap";
19
+ via: VirtualWrapFace;
20
+ landAt: 1 | 4;
21
+ doAnimate: boolean;
22
+ }
23
+ | {
24
+ kind: "direct-wrap";
25
+ to: number;
26
+ doAnimate: boolean;
27
+ };
28
+ type RotationDeg = -360 | -270 | -180 | -90 | 0 | 90 | 180 | 270 | 360;
29
+ type FaceVisibility = "front" | "side" | "hidden";
30
+ type FaceParity = "odd" | "even";
31
+ type Geometry =
32
+ | {
33
+ kind: "fixed";
34
+ axis: Axis;
35
+ length: number;
36
+ }
37
+ | {
38
+ kind: "variable";
39
+ axis: Axis;
40
+ length: number;
41
+ even: number;
42
+ };
43
+ type FaceCount = 2 | 3 | 4;
44
+ type TurnBoxOptions = {
45
+ facePcs: FaceCount;
46
+ axis?: Axis;
47
+ direction?: Direction;
48
+ type?: AnimationType;
49
+ duration?: number;
50
+ delay?: number;
51
+ width?: number;
52
+ height?: number;
53
+ even?: number;
54
+ };
55
+ type NormalizedOptions = {
56
+ facePcs: FaceCount;
57
+ direction: Direction;
58
+ type: AnimationType;
59
+ duration: number;
60
+ delay: number;
61
+ geometry: Geometry;
62
+ };
63
+ type FaceTransform = {
64
+ axis: Axis;
65
+ deg: RotationDeg;
66
+ x: number;
67
+ y: number;
68
+ z: number;
69
+ zIndex: number;
70
+ transformOrigin: string;
71
+ };
72
+
73
+ declare const MAX_FACE_PCS = 4;
74
+ declare const normalizeOptions: (options: TurnBoxOptions) => NormalizedOptions;
75
+
76
+ declare const getFaceParity: (faceNum: number) => FaceParity;
77
+ declare const calcFaceTransform: (currentFace: number, faceNum: number, options: NormalizedOptions) => FaceTransform;
78
+ declare const calcAdjustFaceTransform: (
79
+ currentFace: number,
80
+ faceNum: number,
81
+ options: NormalizedOptions,
82
+ ) => FaceTransform;
83
+
84
+ export {
85
+ type AnimationType as A,
86
+ type Direction as D,
87
+ type FaceCount as F,
88
+ type Geometry as G,
89
+ MAX_FACE_PCS as M,
90
+ type NormalizedOptions as N,
91
+ type RotationDeg as R,
92
+ type Transition as T,
93
+ VIRTUAL_NEXT_WRAP as V,
94
+ type Axis as a,
95
+ type FaceParity as b,
96
+ type FaceTransform as c,
97
+ type FaceVisibility as d,
98
+ type TurnBoxOptions as e,
99
+ VIRTUAL_PREV_WRAP as f,
100
+ type VirtualWrapFace as g,
101
+ calcAdjustFaceTransform as h,
102
+ calcFaceTransform as i,
103
+ getFaceParity as j,
104
+ normalizeOptions as n,
105
+ };
@@ -0,0 +1 @@
1
+ export { A as AnimationType, a as Axis, D as DEFAULT_DELAY, b as DEFAULT_DURATION, c as DEFAULT_EASING, d as DEFAULT_HEIGHT, e as DEFAULT_PERSPECTIVE, f as DEFAULT_SIZE, g as Direction, F as FaceCount, i as FaceTransform, G as Geometry, N as NormalizedOptions, k as TurnBoxOptions, o as calcFaceTransform, r as normalizeOptions } from './index-D9SfBqGh.js';
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ import {
2
+ DEFAULT_DELAY,
3
+ DEFAULT_DURATION,
4
+ DEFAULT_EASING,
5
+ DEFAULT_HEIGHT,
6
+ DEFAULT_PERSPECTIVE,
7
+ DEFAULT_SIZE,
8
+ calcFaceTransform,
9
+ normalizeOptions
10
+ } from "./chunk-EJXTWUUK.js";
11
+ export {
12
+ DEFAULT_DELAY,
13
+ DEFAULT_DURATION,
14
+ DEFAULT_EASING,
15
+ DEFAULT_HEIGHT,
16
+ DEFAULT_PERSPECTIVE,
17
+ DEFAULT_SIZE,
18
+ calcFaceTransform,
19
+ normalizeOptions
20
+ };
@@ -0,0 +1,7 @@
1
+ import { N as NormalizedOptions, T as Transition } from './index-D9SfBqGh.js';
2
+ export { A as AnimationType, a as Axis, D as DEFAULT_DELAY, b as DEFAULT_DURATION, c as DEFAULT_EASING, d as DEFAULT_HEIGHT, e as DEFAULT_PERSPECTIVE, f as DEFAULT_SIZE, g as Direction, F as FaceCount, h as FaceParity, i as FaceTransform, j as FaceVisibility, G as Geometry, M as MAX_FACE_PCS, R as RotationDeg, k as TurnBoxOptions, V as VIRTUAL_NEXT_WRAP, l as VIRTUAL_PREV_WRAP, m as VirtualWrapFace, n as calcAdjustFaceTransform, o as calcFaceTransform, p as calcPrePositionTransform, q as getFaceParity, r as normalizeOptions } from './index-D9SfBqGh.js';
3
+
4
+ declare const shouldAnimate: (currentFace: number, targetFace: number, options: NormalizedOptions, animationFlag?: boolean) => boolean;
5
+ declare const resolveTransition: (from: number, rawTarget: number, opts: NormalizedOptions, animationFlag: boolean) => Transition;
6
+
7
+ export { NormalizedOptions, Transition, resolveTransition, shouldAnimate };
@@ -0,0 +1,121 @@
1
+ import {
2
+ DEFAULT_DELAY,
3
+ DEFAULT_DURATION,
4
+ DEFAULT_EASING,
5
+ DEFAULT_HEIGHT,
6
+ DEFAULT_PERSPECTIVE,
7
+ DEFAULT_SIZE,
8
+ MAX_FACE_PCS,
9
+ VIRTUAL_NEXT_WRAP,
10
+ VIRTUAL_PREV_WRAP,
11
+ calcAdjustFaceTransform,
12
+ calcFaceTransform,
13
+ calcPrePositionTransform,
14
+ getFaceParity,
15
+ normalizeOptions
16
+ } from "./chunk-EJXTWUUK.js";
17
+
18
+ // src/navigation.ts
19
+ var shouldAnimate = (currentFace, targetFace, options, animationFlag = true) => {
20
+ if (!animationFlag) return false;
21
+ if (currentFace === targetFace) return false;
22
+ const diff = Math.abs(targetFace - currentFace);
23
+ if (options.type !== "skip" && diff > 1) return false;
24
+ return true;
25
+ };
26
+ var isVirtualWrapFace = (f) => f === VIRTUAL_PREV_WRAP || f === VIRTUAL_NEXT_WRAP;
27
+ var resolveVirtualLanding = (via) => via === VIRTUAL_PREV_WRAP ? 4 : 1;
28
+ var ADJUST_PAIRS = {
29
+ positive: [
30
+ [2, 3],
31
+ [3, 2]
32
+ ],
33
+ negative: [
34
+ [1, 2],
35
+ [2, 1],
36
+ [3, 4],
37
+ [4, 3]
38
+ ]
39
+ };
40
+ var resolveVirtualWrapVia = (from, to, opts) => {
41
+ if (opts.type !== "real" || opts.faces !== MAX_FACE_PCS) return null;
42
+ if (from === 1 && to === opts.faces) return VIRTUAL_PREV_WRAP;
43
+ if (from === opts.faces && to === 1) return VIRTUAL_NEXT_WRAP;
44
+ return null;
45
+ };
46
+ var needsAdjust = (from, to, opts) => {
47
+ if (opts.geometry.kind === "fixed" || opts.type !== "real") return false;
48
+ return ADJUST_PAIRS[opts.direction].some(([c, t]) => c === from && t === to);
49
+ };
50
+ var resolveBoundary = (rawTarget, opts) => {
51
+ if (opts.faces === MAX_FACE_PCS) {
52
+ if (opts.type === "real") {
53
+ if (rawTarget < 0) return { kind: "noop" };
54
+ return {
55
+ kind: "resolved",
56
+ to: rawTarget > 5 ? opts.faces : rawTarget,
57
+ isDirectWrap: false
58
+ };
59
+ }
60
+ if (opts.type === "repeat" || opts.type === "skip") {
61
+ if (rawTarget === opts.faces + 1) return { kind: "resolved", to: 1, isDirectWrap: true };
62
+ if (rawTarget === 0) return { kind: "resolved", to: opts.faces, isDirectWrap: true };
63
+ if (rawTarget < 1 || rawTarget > opts.faces) return { kind: "noop" };
64
+ return { kind: "resolved", to: rawTarget, isDirectWrap: false };
65
+ }
66
+ if (rawTarget < 1 || rawTarget > opts.faces) return { kind: "noop" };
67
+ return { kind: "resolved", to: rawTarget, isDirectWrap: false };
68
+ }
69
+ if (rawTarget < 1) return { kind: "noop" };
70
+ return { kind: "resolved", to: Math.min(rawTarget, opts.faces), isDirectWrap: false };
71
+ };
72
+ var resolveTransition = (from, rawTarget, opts, animationFlag) => {
73
+ const boundary = resolveBoundary(rawTarget, opts);
74
+ if (boundary.kind === "noop" || from === boundary.to) return { kind: "noop" };
75
+ const { to, isDirectWrap } = boundary;
76
+ if (isDirectWrap) {
77
+ const doAnimate = opts.type === "repeat" ? animationFlag : shouldAnimate(from, to, opts, animationFlag);
78
+ return { kind: "direct-wrap", to, doAnimate };
79
+ }
80
+ if (isVirtualWrapFace(to)) {
81
+ return {
82
+ kind: "virtual-wrap",
83
+ via: to,
84
+ landAt: resolveVirtualLanding(to),
85
+ doAnimate: shouldAnimate(from, to, opts, animationFlag)
86
+ };
87
+ }
88
+ const virtualVia = resolveVirtualWrapVia(from, to, opts);
89
+ if (virtualVia !== null) {
90
+ return {
91
+ kind: "virtual-wrap",
92
+ via: virtualVia,
93
+ landAt: resolveVirtualLanding(virtualVia),
94
+ doAnimate: shouldAnimate(from, virtualVia, opts, animationFlag)
95
+ };
96
+ }
97
+ return {
98
+ kind: "step",
99
+ to,
100
+ doAnimate: shouldAnimate(from, to, opts, animationFlag),
101
+ hasAdjust: needsAdjust(from, to, opts)
102
+ };
103
+ };
104
+ export {
105
+ DEFAULT_DELAY,
106
+ DEFAULT_DURATION,
107
+ DEFAULT_EASING,
108
+ DEFAULT_HEIGHT,
109
+ DEFAULT_PERSPECTIVE,
110
+ DEFAULT_SIZE,
111
+ MAX_FACE_PCS,
112
+ VIRTUAL_NEXT_WRAP,
113
+ VIRTUAL_PREV_WRAP,
114
+ calcAdjustFaceTransform,
115
+ calcFaceTransform,
116
+ calcPrePositionTransform,
117
+ getFaceParity,
118
+ normalizeOptions,
119
+ resolveTransition,
120
+ shouldAnimate
121
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@kazuhi-ra/turnbox-core",
3
+ "version": "0.1.0",
4
+ "description": "Core logic for TurnBox — pure functions for 3D box animation geometry, state, and transitions (no DOM dependency)",
5
+ "keywords": [
6
+ "3d",
7
+ "animation",
8
+ "css3",
9
+ "transform",
10
+ "turnbox",
11
+ "pure"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "kazuhi-ra",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/kazuhi-ra/turnbox.git",
18
+ "directory": "packages/core"
19
+ },
20
+ "homepage": "https://github.com/kazuhi-ra/turnbox#readme",
21
+ "bugs": {
22
+ "url": "https://github.com/kazuhi-ra/turnbox/issues"
23
+ },
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "import": "./dist/index.js",
28
+ "types": "./dist/index.d.ts"
29
+ },
30
+ "./internal": {
31
+ "import": "./dist/internal.js",
32
+ "types": "./dist/internal.d.ts"
33
+ }
34
+ },
35
+ "main": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
+ "sideEffects": false,
38
+ "files": [
39
+ "dist",
40
+ "LICENSE"
41
+ ],
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup src/index.ts src/internal.ts --format esm --dts --out-dir dist"
47
+ }
48
+ }