@prosopo/procaptcha-puzzle 2.10.39 → 2.10.41
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/.turbo/turbo-build$colon$cjs.log +13 -11
- package/.turbo/turbo-build$colon$tsc.log +19 -19
- package/.turbo/turbo-build.log +15 -12
- package/CHANGELOG.md +41 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/components/ProcaptchaPuzzle.cjs +6 -9
- package/dist/cjs/components/ProcaptchaWidget.cjs +191 -213
- package/dist/cjs/components/PuzzleCanvas.cjs +228 -270
- package/dist/cjs/index.cjs +2 -4
- package/dist/cjs/services/Manager.cjs +209 -289
- package/dist/components/ProcaptchaPuzzle.js +6 -8
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
- package/dist/components/ProcaptchaWidget.js +190 -212
- package/dist/components/ProcaptchaWidget.js.map +1 -1
- package/dist/components/PuzzleCanvas.js +229 -271
- package/dist/index.js +2 -4
- package/dist/services/Manager.d.ts.map +1 -1
- package/dist/services/Manager.js +205 -286
- package/dist/services/Manager.js.map +1 -1
- package/dist/tests/manager.unit.test.d.ts +2 -0
- package/dist/tests/manager.unit.test.d.ts.map +1 -0
- package/dist/tests/manager.unit.test.js +506 -0
- package/dist/tests/manager.unit.test.js.map +1 -0
- package/dist/tests/managerHarness.d.ts +20 -0
- package/dist/tests/managerHarness.d.ts.map +1 -0
- package/dist/tests/managerHarness.js +86 -0
- package/dist/tests/managerHarness.js.map +1 -0
- package/dist/tests/procaptchaPuzzle.test-d.d.ts +2 -0
- package/dist/tests/procaptchaPuzzle.test-d.d.ts.map +1 -0
- package/dist/tests/procaptchaPuzzle.test-d.js +97 -0
- package/dist/tests/procaptchaPuzzle.test-d.js.map +1 -0
- package/dist/tests/procaptchaPuzzle.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaPuzzle.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaPuzzle.unit.test.js +81 -0
- package/dist/tests/procaptchaPuzzle.unit.test.js.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.js +547 -0
- package/dist/tests/procaptchaWidget.unit.test.js.map +1 -0
- package/dist/tests/puzzleCanvas.unit.test.d.ts +2 -0
- package/dist/tests/puzzleCanvas.unit.test.d.ts.map +1 -0
- package/dist/tests/puzzleCanvas.unit.test.js +312 -0
- package/dist/tests/puzzleCanvas.unit.test.js.map +1 -0
- package/dist/tests/setup.d.ts +5 -0
- package/dist/tests/setup.d.ts.map +1 -0
- package/dist/tests/setup.js +3 -0
- package/dist/tests/setup.js.map +1 -0
- package/package.json +17 -12
- package/src/components/ProcaptchaWidget.tsx +17 -6
- package/src/services/Manager.ts +14 -10
- package/src/tests/manager.unit.test.ts +763 -0
- package/src/tests/managerHarness.ts +169 -0
- package/src/tests/procaptchaPuzzle.test-d.ts +191 -0
- package/src/tests/procaptchaPuzzle.unit.test.ts +123 -0
- package/src/tests/procaptchaWidget.unit.test.ts +789 -0
- package/src/tests/puzzleCanvas.unit.test.ts +418 -0
- package/src/tests/setup.ts +26 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.test.config.ts +27 -0
|
@@ -1,278 +1,236 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
3
|
+
//#region src/components/PuzzleCanvas.tsx
|
|
4
|
+
var CONTAINER_WIDTH = 300;
|
|
5
|
+
var CONTAINER_HEIGHT = 200;
|
|
6
|
+
var TARGET_SIZE = 30;
|
|
7
|
+
var PIECE_SIZE = 24;
|
|
8
|
+
var SHAKE_KEYFRAMES = `
|
|
8
9
|
@keyframes prosopo-puzzle-shake {
|
|
9
10
|
0%, 100% { transform: translateX(0); }
|
|
10
11
|
10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
|
|
11
12
|
20%, 40%, 60%, 80% { transform: translateX(4px); }
|
|
12
13
|
}
|
|
13
14
|
`;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
left: `${targetX - TARGET_SIZE / 2}px`,
|
|
234
|
-
top: `${targetY - TARGET_SIZE / 2}px`,
|
|
235
|
-
width: `${TARGET_SIZE}px`,
|
|
236
|
-
height: `${TARGET_SIZE}px`,
|
|
237
|
-
borderRadius: "50%",
|
|
238
|
-
border: "2px dashed rgba(74, 144, 217, 0.6)",
|
|
239
|
-
backgroundColor: "rgba(74, 144, 217, 0.08)",
|
|
240
|
-
boxSizing: "border-box"
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
),
|
|
244
|
-
/* @__PURE__ */ jsx(
|
|
245
|
-
"div",
|
|
246
|
-
{
|
|
247
|
-
...process.env.NODE_ENV !== "production" && {
|
|
248
|
-
"data-cy": "prosopo-puzzle-piece"
|
|
249
|
-
},
|
|
250
|
-
onMouseDown: handlePieceMouseDown,
|
|
251
|
-
onTouchStart: handlePieceTouchStart,
|
|
252
|
-
style: {
|
|
253
|
-
position: "absolute",
|
|
254
|
-
left: `${posX - PIECE_SIZE / 2}px`,
|
|
255
|
-
top: `${posY - PIECE_SIZE / 2}px`,
|
|
256
|
-
width: `${PIECE_SIZE}px`,
|
|
257
|
-
height: `${PIECE_SIZE}px`,
|
|
258
|
-
borderRadius: "50%",
|
|
259
|
-
background: "radial-gradient(circle at 40% 40%, #6ab0ff, #4a90d9)",
|
|
260
|
-
cursor: submitting ? "default" : isDragging.current ? "grabbing" : "grab",
|
|
261
|
-
boxShadow: isDragging.current ? "0 4px 12px rgba(74, 144, 217, 0.5)" : "0 2px 6px rgba(74, 144, 217, 0.3)",
|
|
262
|
-
transition: isDragging.current ? "none" : "box-shadow 0.2s ease, left 0.3s ease, top 0.3s ease"
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
]
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
]
|
|
270
|
-
}
|
|
271
|
-
)
|
|
272
|
-
]
|
|
273
|
-
}
|
|
274
|
-
);
|
|
275
|
-
};
|
|
276
|
-
export {
|
|
277
|
-
PuzzleCanvas
|
|
15
|
+
var PuzzleCanvas = ({ originX, originY, targetX, targetY, onComplete, showRetry, submitting }) => {
|
|
16
|
+
const [posX, setPosX] = useState(originX);
|
|
17
|
+
const [posY, setPosY] = useState(originY);
|
|
18
|
+
const isDragging = useRef(false);
|
|
19
|
+
const puzzleEvents = useRef([]);
|
|
20
|
+
const containerRef = useRef(null);
|
|
21
|
+
const offsetRef = useRef({
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0
|
|
24
|
+
});
|
|
25
|
+
const [visible, setVisible] = useState(false);
|
|
26
|
+
const [shaking, setShaking] = useState(false);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setPosX(originX);
|
|
29
|
+
setPosY(originY);
|
|
30
|
+
}, [originX, originY]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const frame = requestAnimationFrame(() => setVisible(true));
|
|
33
|
+
return () => cancelAnimationFrame(frame);
|
|
34
|
+
}, []);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (showRetry) {
|
|
37
|
+
setShaking(true);
|
|
38
|
+
const timer = setTimeout(() => setShaking(false), 500);
|
|
39
|
+
return () => clearTimeout(timer);
|
|
40
|
+
}
|
|
41
|
+
return () => {};
|
|
42
|
+
}, [showRetry]);
|
|
43
|
+
const clamp = useCallback((value, min, max) => {
|
|
44
|
+
return Math.max(min, Math.min(max, value));
|
|
45
|
+
}, []);
|
|
46
|
+
const getContainerOffset = useCallback(() => {
|
|
47
|
+
if (containerRef.current) {
|
|
48
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
49
|
+
return {
|
|
50
|
+
x: rect.left,
|
|
51
|
+
y: rect.top
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0
|
|
57
|
+
};
|
|
58
|
+
}, []);
|
|
59
|
+
const handleMoveEvent = useCallback((clientX, clientY) => {
|
|
60
|
+
if (!isDragging.current) return;
|
|
61
|
+
const containerOffset = getContainerOffset();
|
|
62
|
+
const newX = clamp(clientX - containerOffset.x - offsetRef.current.x, 0, CONTAINER_WIDTH);
|
|
63
|
+
const newY = clamp(clientY - containerOffset.y - offsetRef.current.y, 0, CONTAINER_HEIGHT);
|
|
64
|
+
setPosX(newX);
|
|
65
|
+
setPosY(newY);
|
|
66
|
+
puzzleEvents.current.push({
|
|
67
|
+
x: newX,
|
|
68
|
+
y: newY,
|
|
69
|
+
t: Date.now()
|
|
70
|
+
});
|
|
71
|
+
}, [clamp, getContainerOffset]);
|
|
72
|
+
const handleEndEvent = useCallback(() => {
|
|
73
|
+
if (!isDragging.current) return;
|
|
74
|
+
isDragging.current = false;
|
|
75
|
+
const currentEvents = [...puzzleEvents.current];
|
|
76
|
+
const lastEvent = currentEvents[currentEvents.length - 1];
|
|
77
|
+
onComplete(lastEvent ? lastEvent.x : originX, lastEvent ? lastEvent.y : originY, currentEvents);
|
|
78
|
+
}, [
|
|
79
|
+
onComplete,
|
|
80
|
+
originX,
|
|
81
|
+
originY
|
|
82
|
+
]);
|
|
83
|
+
const handleMouseMove = useCallback((event) => {
|
|
84
|
+
handleMoveEvent(event.clientX, event.clientY);
|
|
85
|
+
}, [handleMoveEvent]);
|
|
86
|
+
const handleTouchMove = useCallback((event) => {
|
|
87
|
+
const touch = event.touches[0];
|
|
88
|
+
if (touch) handleMoveEvent(touch.clientX, touch.clientY);
|
|
89
|
+
}, [handleMoveEvent]);
|
|
90
|
+
const handleMouseUp = useCallback(() => {
|
|
91
|
+
handleEndEvent();
|
|
92
|
+
}, [handleEndEvent]);
|
|
93
|
+
const handleTouchEnd = useCallback(() => {
|
|
94
|
+
handleEndEvent();
|
|
95
|
+
}, [handleEndEvent]);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
98
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
99
|
+
document.addEventListener("touchmove", handleTouchMove);
|
|
100
|
+
document.addEventListener("touchend", handleTouchEnd);
|
|
101
|
+
return () => {
|
|
102
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
103
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
104
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
105
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
106
|
+
};
|
|
107
|
+
}, [
|
|
108
|
+
handleMouseMove,
|
|
109
|
+
handleMouseUp,
|
|
110
|
+
handleTouchMove,
|
|
111
|
+
handleTouchEnd
|
|
112
|
+
]);
|
|
113
|
+
const handlePieceMouseDown = useCallback((event) => {
|
|
114
|
+
if (submitting) return;
|
|
115
|
+
isDragging.current = true;
|
|
116
|
+
puzzleEvents.current = [];
|
|
117
|
+
const containerOffset = getContainerOffset();
|
|
118
|
+
offsetRef.current = {
|
|
119
|
+
x: event.clientX - containerOffset.x - posX,
|
|
120
|
+
y: event.clientY - containerOffset.y - posY
|
|
121
|
+
};
|
|
122
|
+
}, [
|
|
123
|
+
getContainerOffset,
|
|
124
|
+
posX,
|
|
125
|
+
posY,
|
|
126
|
+
submitting
|
|
127
|
+
]);
|
|
128
|
+
const handlePieceTouchStart = useCallback((event) => {
|
|
129
|
+
if (submitting) return;
|
|
130
|
+
const touch = event.touches[0];
|
|
131
|
+
if (touch) {
|
|
132
|
+
isDragging.current = true;
|
|
133
|
+
puzzleEvents.current = [];
|
|
134
|
+
const containerOffset = getContainerOffset();
|
|
135
|
+
offsetRef.current = {
|
|
136
|
+
x: touch.clientX - containerOffset.x - posX,
|
|
137
|
+
y: touch.clientY - containerOffset.y - posY
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}, [
|
|
141
|
+
getContainerOffset,
|
|
142
|
+
posX,
|
|
143
|
+
posY,
|
|
144
|
+
submitting
|
|
145
|
+
]);
|
|
146
|
+
const instructionText = showRetry ? "Not quite — try again" : "Drag the piece to the target";
|
|
147
|
+
const headerBorderColor = showRetry ? "rgba(220, 53, 69, 0.4)" : "transparent";
|
|
148
|
+
const headerTextColor = showRetry ? "#dc3545" : "#333";
|
|
149
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
150
|
+
style: {
|
|
151
|
+
position: "fixed",
|
|
152
|
+
inset: 0,
|
|
153
|
+
zIndex: 2147483646,
|
|
154
|
+
display: "flex",
|
|
155
|
+
alignItems: "center",
|
|
156
|
+
justifyContent: "center",
|
|
157
|
+
backgroundColor: visible ? "rgba(0, 0, 0, 0.4)" : "rgba(0, 0, 0, 0)",
|
|
158
|
+
transition: "background-color 0.3s ease"
|
|
159
|
+
},
|
|
160
|
+
children: [/* @__PURE__ */ jsx("style", { children: SHAKE_KEYFRAMES }), /* @__PURE__ */ jsxs("div", {
|
|
161
|
+
style: {
|
|
162
|
+
display: "flex",
|
|
163
|
+
flexDirection: "column",
|
|
164
|
+
alignItems: "center",
|
|
165
|
+
gap: "0",
|
|
166
|
+
zIndex: 2147483647,
|
|
167
|
+
opacity: visible ? 1 : 0,
|
|
168
|
+
transform: visible ? "scale(1)" : "scale(0.9)",
|
|
169
|
+
transition: "opacity 0.3s ease, transform 0.3s ease",
|
|
170
|
+
animation: shaking ? "prosopo-puzzle-shake 0.5s ease" : "none"
|
|
171
|
+
},
|
|
172
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
173
|
+
style: {
|
|
174
|
+
backgroundColor: "#fff",
|
|
175
|
+
borderRadius: "8px 8px 0 0",
|
|
176
|
+
padding: "12px 20px",
|
|
177
|
+
width: `${CONTAINER_WIDTH}px`,
|
|
178
|
+
boxSizing: "border-box",
|
|
179
|
+
textAlign: "center",
|
|
180
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif",
|
|
181
|
+
fontSize: "14px",
|
|
182
|
+
fontWeight: 500,
|
|
183
|
+
color: headerTextColor,
|
|
184
|
+
borderBottom: `2px solid ${headerBorderColor}`,
|
|
185
|
+
boxShadow: "0px 11px 15px -7px rgba(0,0,0,0.2), 0px 24px 38px 3px rgba(0,0,0,0.14), 0px 9px 46px 8px rgba(0,0,0,0.12)",
|
|
186
|
+
transition: "color 0.3s ease, border-color 0.3s ease"
|
|
187
|
+
},
|
|
188
|
+
children: instructionText
|
|
189
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
190
|
+
ref: containerRef,
|
|
191
|
+
style: {
|
|
192
|
+
position: "relative",
|
|
193
|
+
width: `${CONTAINER_WIDTH}px`,
|
|
194
|
+
height: `${CONTAINER_HEIGHT}px`,
|
|
195
|
+
background: "linear-gradient(135deg, #e8eaf6 0%, #c5cae9 50%, #e8eaf6 100%)",
|
|
196
|
+
borderRadius: "0 0 8px 8px",
|
|
197
|
+
overflow: "hidden",
|
|
198
|
+
userSelect: "none",
|
|
199
|
+
boxShadow: "0px 11px 15px -7px rgba(0,0,0,0.2), 0px 24px 38px 3px rgba(0,0,0,0.14), 0px 9px 46px 8px rgba(0,0,0,0.12)",
|
|
200
|
+
opacity: submitting ? .6 : 1,
|
|
201
|
+
pointerEvents: submitting ? "none" : "auto",
|
|
202
|
+
transition: "opacity 0.2s ease"
|
|
203
|
+
},
|
|
204
|
+
children: [/* @__PURE__ */ jsx("div", { style: {
|
|
205
|
+
position: "absolute",
|
|
206
|
+
left: `${targetX - TARGET_SIZE / 2}px`,
|
|
207
|
+
top: `${targetY - TARGET_SIZE / 2}px`,
|
|
208
|
+
width: `${TARGET_SIZE}px`,
|
|
209
|
+
height: `${TARGET_SIZE}px`,
|
|
210
|
+
borderRadius: "50%",
|
|
211
|
+
border: "2px dashed rgba(74, 144, 217, 0.6)",
|
|
212
|
+
backgroundColor: "rgba(74, 144, 217, 0.08)",
|
|
213
|
+
boxSizing: "border-box"
|
|
214
|
+
} }), /* @__PURE__ */ jsx("div", {
|
|
215
|
+
...process.env.NODE_ENV !== "production" && { "data-cy": "prosopo-puzzle-piece" },
|
|
216
|
+
onMouseDown: handlePieceMouseDown,
|
|
217
|
+
onTouchStart: handlePieceTouchStart,
|
|
218
|
+
style: {
|
|
219
|
+
position: "absolute",
|
|
220
|
+
left: `${posX - PIECE_SIZE / 2}px`,
|
|
221
|
+
top: `${posY - PIECE_SIZE / 2}px`,
|
|
222
|
+
width: `${PIECE_SIZE}px`,
|
|
223
|
+
height: `${PIECE_SIZE}px`,
|
|
224
|
+
borderRadius: "50%",
|
|
225
|
+
background: "radial-gradient(circle at 40% 40%, #6ab0ff, #4a90d9)",
|
|
226
|
+
cursor: submitting ? "default" : isDragging.current ? "grabbing" : "grab",
|
|
227
|
+
boxShadow: isDragging.current ? "0 4px 12px rgba(74, 144, 217, 0.5)" : "0 2px 6px rgba(74, 144, 217, 0.3)",
|
|
228
|
+
transition: isDragging.current ? "none" : "box-shadow 0.2s ease, left 0.3s ease, top 0.3s ease"
|
|
229
|
+
}
|
|
230
|
+
})]
|
|
231
|
+
})]
|
|
232
|
+
})]
|
|
233
|
+
});
|
|
278
234
|
};
|
|
235
|
+
//#endregion
|
|
236
|
+
export { PuzzleCanvas };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/services/Manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/services/Manager.ts"],"names":[],"mappings":"AA0BA,OAAO,EAIN,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAEhC,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAEhB,MAAM,gBAAgB,CAAC;AAIxB,UAAU,mBAAmB;IAC5B,KAAK,EAAE,CACN,CAAC,CAAC,EAAE,MAAM,EACV,CAAC,CAAC,EAAE,MAAM,KACN,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAAC;IACnD,cAAc,EAAE,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,WAAW,EAAE,KACvB,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,UAAU,EAAE,CAAC,mBAAmB,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACvD;AAED,eAAO,MAAM,OAAO,gBACN,2BAA2B,SACjC,eAAe,iBACP,uBAAuB,aAC3B,mBAAmB,sBACV,iBAAiB,qBAGlB,MAAM,MAAM,GAAG,SAAS,KACzC,mBAmZF,CAAC"}
|