gigaboard 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{board-model-BvJOtwQ3.d.cts → board-model-BMtkLQvL.d.cts} +29 -1
- package/dist/{board-model-BvJOtwQ3.d.ts → board-model-BMtkLQvL.d.ts} +29 -1
- package/dist/{chunk-OQZ7MNMY.js → chunk-BNJKX6K7.js} +5 -5
- package/dist/chunk-BNJKX6K7.js.map +1 -0
- package/dist/{chunk-VYTDPENJ.cjs → chunk-K7D2C72S.cjs} +5 -5
- package/dist/chunk-K7D2C72S.cjs.map +1 -0
- package/dist/core.cjs +44 -44
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +1 -1
- package/dist/{gigachess-DolQlR82.d.ts → gigachess-C08uAeFw.d.ts} +1 -1
- package/dist/{gigachess-3BDD--yT.d.cts → gigachess-Dr5gCN68.d.cts} +1 -1
- package/dist/index.cjs +401 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +361 -47
- package/dist/index.js.map +1 -1
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/{types-D5eBJGzj.d.ts → types-CcOgT5ov.d.ts} +1 -1
- package/dist/{types-Bg2xiUHE.d.cts → types-DfqRXtbD.d.cts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-OQZ7MNMY.js.map +0 -1
- package/dist/chunk-VYTDPENJ.cjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as ChessboardProps, T as Theme, O as Orientation, A as AnimationOptions, R as ResolvedArrowPalette, U as UseChessGameOptions, P as PieceRenderer } from './types-
|
|
3
|
-
export { a as ArrowColors, D as DEFAULT_MOVE_HAPTIC_PATTERNS, b as DEFAULT_MOVE_SOUND_SOURCES, H as HapticFeedbackOptions, L as LegalTargetStyle, M as MoveFeedbackKey, c as MoveHapticKey, d as MoveHapticOptions, e as MoveHapticPatterns, f as MoveSoundKey, g as MoveSoundOptions, h as MoveSoundSources, i as PositionTransition, j as PromotionContext, k as RanksPosition, S as SquareContext, l as TriggerMoveHaptic, m as TriggerMoveSound, n as classifyMoveFeedback, t as triggerHaptic, o as triggerMoveHaptic, u as useMoveHaptics, p as useMoveSound, w as warmupHaptics } from './types-
|
|
4
|
-
export { c as createGigachessAdapter, p as preloadGigachessAdapter } from './gigachess-
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
2
|
+
import { C as ChessboardProps, T as Theme, O as Orientation, A as AnimationOptions, R as ResolvedArrowPalette, U as UseChessGameOptions, P as PieceRenderer } from './types-DfqRXtbD.cjs';
|
|
3
|
+
export { a as ArrowColors, D as DEFAULT_MOVE_HAPTIC_PATTERNS, b as DEFAULT_MOVE_SOUND_SOURCES, H as HapticFeedbackOptions, L as LegalTargetStyle, M as MoveFeedbackKey, c as MoveHapticKey, d as MoveHapticOptions, e as MoveHapticPatterns, f as MoveSoundKey, g as MoveSoundOptions, h as MoveSoundSources, i as PositionTransition, j as PromotionContext, k as RanksPosition, S as SquareContext, l as TriggerMoveHaptic, m as TriggerMoveSound, n as classifyMoveFeedback, t as triggerHaptic, o as triggerMoveHaptic, u as useMoveHaptics, p as useMoveSound, w as warmupHaptics } from './types-DfqRXtbD.cjs';
|
|
4
|
+
export { c as createGigachessAdapter, p as preloadGigachessAdapter } from './gigachess-Dr5gCN68.cjs';
|
|
5
|
+
import { v as BoardModel, x as BoardSnapshot, S as SquareIndex, w as BoardModelOptions, P as PackedMove, u as BoardCell } from './board-model-BMtkLQvL.cjs';
|
|
6
|
+
export { D as Color, E as EngineAdapter, a as PieceType, Z as ZobristKey, _ as createBoardModel, a5 as packMove, a7 as unpackMove } from './board-model-BMtkLQvL.cjs';
|
|
7
7
|
import { RefObject, ReactNode } from 'react';
|
|
8
8
|
export { HapticInput, TriggerOptions } from 'web-haptics';
|
|
9
9
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as ChessboardProps, T as Theme, O as Orientation, A as AnimationOptions, R as ResolvedArrowPalette, U as UseChessGameOptions, P as PieceRenderer } from './types-
|
|
3
|
-
export { a as ArrowColors, D as DEFAULT_MOVE_HAPTIC_PATTERNS, b as DEFAULT_MOVE_SOUND_SOURCES, H as HapticFeedbackOptions, L as LegalTargetStyle, M as MoveFeedbackKey, c as MoveHapticKey, d as MoveHapticOptions, e as MoveHapticPatterns, f as MoveSoundKey, g as MoveSoundOptions, h as MoveSoundSources, i as PositionTransition, j as PromotionContext, k as RanksPosition, S as SquareContext, l as TriggerMoveHaptic, m as TriggerMoveSound, n as classifyMoveFeedback, t as triggerHaptic, o as triggerMoveHaptic, u as useMoveHaptics, p as useMoveSound, w as warmupHaptics } from './types-
|
|
4
|
-
export { c as createGigachessAdapter, p as preloadGigachessAdapter } from './gigachess-
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
2
|
+
import { C as ChessboardProps, T as Theme, O as Orientation, A as AnimationOptions, R as ResolvedArrowPalette, U as UseChessGameOptions, P as PieceRenderer } from './types-CcOgT5ov.js';
|
|
3
|
+
export { a as ArrowColors, D as DEFAULT_MOVE_HAPTIC_PATTERNS, b as DEFAULT_MOVE_SOUND_SOURCES, H as HapticFeedbackOptions, L as LegalTargetStyle, M as MoveFeedbackKey, c as MoveHapticKey, d as MoveHapticOptions, e as MoveHapticPatterns, f as MoveSoundKey, g as MoveSoundOptions, h as MoveSoundSources, i as PositionTransition, j as PromotionContext, k as RanksPosition, S as SquareContext, l as TriggerMoveHaptic, m as TriggerMoveSound, n as classifyMoveFeedback, t as triggerHaptic, o as triggerMoveHaptic, u as useMoveHaptics, p as useMoveSound, w as warmupHaptics } from './types-CcOgT5ov.js';
|
|
4
|
+
export { c as createGigachessAdapter, p as preloadGigachessAdapter } from './gigachess-C08uAeFw.js';
|
|
5
|
+
import { v as BoardModel, x as BoardSnapshot, S as SquareIndex, w as BoardModelOptions, P as PackedMove, u as BoardCell } from './board-model-BMtkLQvL.js';
|
|
6
|
+
export { D as Color, E as EngineAdapter, a as PieceType, Z as ZobristKey, _ as createBoardModel, a5 as packMove, a7 as unpackMove } from './board-model-BMtkLQvL.js';
|
|
7
7
|
import { RefObject, ReactNode } from 'react';
|
|
8
8
|
export { HapticInput, TriggerOptions } from 'web-haptics';
|
|
9
9
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PieceType, Color, createDragController, createGigachessAdapter, createBoardModel, isEmptyCell, pieceTypeOf, colorOf, encodeBoardCell, decodePackedMove } from './chunk-
|
|
2
|
-
export { Color, PieceType, createBoardModel, createGigachessAdapter, packMove, preloadGigachessAdapter, unpackMove } from './chunk-
|
|
1
|
+
import { PieceType, Color, createDragController, createGigachessAdapter, createBoardModel, isEmptyCell, pieceTypeOf, colorOf, encodeBoardCell, decodePackedMove } from './chunk-BNJKX6K7.js';
|
|
2
|
+
export { Color, PieceType, createBoardModel, createGigachessAdapter, packMove, preloadGigachessAdapter, unpackMove } from './chunk-BNJKX6K7.js';
|
|
3
3
|
import { CSS_VARS, defaultTheme, defaultPieces, parseFenPlacement, defaultArrowColors, DEFAULT_ILLEGAL_FLASH_TINT, DEFAULT_PREMOVE_TINT } from './chunk-EJUGH25P.js';
|
|
4
4
|
export { CSS_VARS, DEFAULT_ILLEGAL_FLASH_TINT, DEFAULT_PREMOVE_TINT, defaultArrowColors, defaultPieces, defaultTheme } from './chunk-EJUGH25P.js';
|
|
5
5
|
import './chunk-OQLY5GJF.js';
|
|
@@ -142,6 +142,7 @@ function redraw(canvas, arrows, preview, orientation, palette) {
|
|
|
142
142
|
ctx.clearRect(0, 0, cssWidth, cssHeight);
|
|
143
143
|
const sqSize = cssWidth / 8;
|
|
144
144
|
for (const arrow of arrows) {
|
|
145
|
+
if (arrow.label?.background !== void 0) continue;
|
|
145
146
|
drawArrow(ctx, arrow.from, arrow.to, resolveColor(arrow, palette), sqSize, orientation, false);
|
|
146
147
|
}
|
|
147
148
|
if (preview !== null) {
|
|
@@ -155,6 +156,243 @@ function anchorPct(from, to, orientation, center) {
|
|
|
155
156
|
if (center === "dest") return b;
|
|
156
157
|
return { cx: (a.cx + b.cx) / 2, cy: (a.cy + b.cy) / 2 };
|
|
157
158
|
}
|
|
159
|
+
function computeDynamicAeroGeometry(text, style, fontSize, isTerminal = true) {
|
|
160
|
+
const resolvedStyle = style ?? "aero_chisel";
|
|
161
|
+
const hasText = Boolean(text && text.trim().length > 0);
|
|
162
|
+
if (!hasText) {
|
|
163
|
+
const tipX = 2.8;
|
|
164
|
+
const shoulderX = 0.2;
|
|
165
|
+
const rearX = -1.2;
|
|
166
|
+
const dockX2 = -1.8;
|
|
167
|
+
const halfH2 = 2.2;
|
|
168
|
+
const path2 = `M ${rearX},${-halfH2} L ${shoulderX},${-halfH2} L ${tipX},0 L ${shoulderX},${halfH2} L ${rearX},${halfH2} C ${dockX2},${halfH2} ${dockX2},${-halfH2} ${rearX},${-halfH2} Z`;
|
|
169
|
+
return {
|
|
170
|
+
path: path2,
|
|
171
|
+
tipLen: tipX,
|
|
172
|
+
dockLen: -dockX2,
|
|
173
|
+
frontLen: tipX,
|
|
174
|
+
cabinW: 0
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const charWidth = fontSize * 0.6;
|
|
178
|
+
const textWidth = text.length * charWidth;
|
|
179
|
+
const halfTextW = textWidth / 2;
|
|
180
|
+
const padX = 0.75;
|
|
181
|
+
const cabinW = Math.max(3.2, halfTextW + padX);
|
|
182
|
+
const halfH = Math.max(2.3, fontSize * 0.9);
|
|
183
|
+
const rearInset = 0.65;
|
|
184
|
+
const dockX = -cabinW - rearInset;
|
|
185
|
+
let frontLen = 0;
|
|
186
|
+
let path = "";
|
|
187
|
+
if (resolvedStyle === "aero_chisel") {
|
|
188
|
+
if (isTerminal) {
|
|
189
|
+
const noseLead = 1.25;
|
|
190
|
+
const tipX = cabinW + noseLead;
|
|
191
|
+
frontLen = tipX;
|
|
192
|
+
path = `M ${-cabinW},${-halfH} L ${cabinW},${-halfH} L ${tipX},0 L ${cabinW},${halfH} L ${-cabinW},${halfH} C ${dockX},${halfH} ${dockX},${-halfH} ${-cabinW},${-halfH} Z`;
|
|
193
|
+
} else {
|
|
194
|
+
frontLen = cabinW + rearInset;
|
|
195
|
+
path = `M ${-cabinW},${-halfH} L ${cabinW},${-halfH} C ${frontLen},${-halfH} ${frontLen},${halfH} ${cabinW},${halfH} L ${-cabinW},${halfH} C ${dockX},${halfH} ${dockX},${-halfH} ${-cabinW},${-halfH} Z`;
|
|
196
|
+
}
|
|
197
|
+
} else if (resolvedStyle === "chamfer_arrow") {
|
|
198
|
+
if (isTerminal) {
|
|
199
|
+
const tipX = cabinW + 1.4;
|
|
200
|
+
frontLen = tipX;
|
|
201
|
+
path = `M ${-cabinW},-1.2 L ${-cabinW + 1.2},${-halfH} L ${cabinW},${-halfH} L ${tipX},0 L ${cabinW},${halfH} L ${-cabinW + 1.2},${halfH} L ${-cabinW},1.2 Z`;
|
|
202
|
+
} else {
|
|
203
|
+
frontLen = cabinW + 0.8;
|
|
204
|
+
path = `M ${-cabinW},-1.2 L ${-cabinW + 1.2},${-halfH} L ${cabinW - 1.2},${-halfH} L ${cabinW},-1.2 L ${cabinW},1.2 L ${cabinW - 1.2},${halfH} L ${-cabinW + 1.2},${halfH} L ${-cabinW},1.2 Z`;
|
|
205
|
+
}
|
|
206
|
+
} else if (resolvedStyle === "blunt_wedge") {
|
|
207
|
+
if (isTerminal) {
|
|
208
|
+
const tipX = cabinW + 1.1;
|
|
209
|
+
frontLen = tipX;
|
|
210
|
+
path = `M ${-cabinW},${-halfH} L ${cabinW},${-halfH} L ${tipX},${-halfH * 0.35} L ${tipX},${halfH * 0.35} L ${cabinW},${halfH} L ${-cabinW},${halfH} C ${dockX},${halfH} ${dockX},${-halfH} ${-cabinW},${-halfH} Z`;
|
|
211
|
+
} else {
|
|
212
|
+
frontLen = cabinW + rearInset;
|
|
213
|
+
path = `M ${-cabinW},${-halfH} L ${cabinW},${-halfH} C ${frontLen},${-halfH} ${frontLen},${halfH} ${cabinW},${halfH} L ${-cabinW},${halfH} C ${dockX},${halfH} ${dockX},${-halfH} ${-cabinW},${-halfH} Z`;
|
|
214
|
+
}
|
|
215
|
+
} else if (resolvedStyle === "stealth") {
|
|
216
|
+
const wingBack = cabinW + 2.3;
|
|
217
|
+
const wingY = halfH + 0.35;
|
|
218
|
+
const shoulderX = cabinW * 0.35;
|
|
219
|
+
const tipX = cabinW + 3.6;
|
|
220
|
+
frontLen = tipX;
|
|
221
|
+
path = `M ${dockX.toFixed(2)},0 L ${(-wingBack).toFixed(2)},${(-wingY).toFixed(2)} L ${(-cabinW).toFixed(2)},${(-halfH).toFixed(2)} L ${shoulderX.toFixed(2)},${(-halfH).toFixed(2)} L ${tipX.toFixed(2)},0 L ${shoulderX.toFixed(2)},${halfH.toFixed(2)} L ${(-cabinW).toFixed(2)},${halfH.toFixed(2)} L ${(-wingBack).toFixed(2)},${wingY.toFixed(2)} Z`;
|
|
222
|
+
} else {
|
|
223
|
+
const noseLead = 1.25;
|
|
224
|
+
const tipX = cabinW + noseLead;
|
|
225
|
+
frontLen = tipX;
|
|
226
|
+
path = `M ${-cabinW},${-halfH} L ${cabinW},${-halfH} L ${tipX},0 L ${cabinW},${halfH} L ${-cabinW},${halfH} C ${dockX},${halfH} ${dockX},${-halfH} ${-cabinW},${-halfH} Z`;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
path,
|
|
230
|
+
tipLen: frontLen,
|
|
231
|
+
dockLen: -dockX,
|
|
232
|
+
frontLen,
|
|
233
|
+
cabinW
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function chooseKnightCorner(fromIndex, toIndex, allArrows, orientation) {
|
|
237
|
+
const a = squareCentrePct(fromIndex, orientation);
|
|
238
|
+
const b = squareCentrePct(toIndex, orientation);
|
|
239
|
+
const dx = b.cx - a.cx;
|
|
240
|
+
const dy = b.cy - a.cy;
|
|
241
|
+
const corner1 = { x: b.cx, y: a.cy };
|
|
242
|
+
const corner2 = { x: a.cx, y: b.cy };
|
|
243
|
+
const fromFile = fromIndex & 7;
|
|
244
|
+
const hasColinearArrowOnFile = allArrows.some(
|
|
245
|
+
(other) => other.from !== fromIndex && (other.from & 7) === fromFile
|
|
246
|
+
);
|
|
247
|
+
if (hasColinearArrowOnFile) {
|
|
248
|
+
return corner1;
|
|
249
|
+
}
|
|
250
|
+
return Math.abs(dx) > Math.abs(dy) ? corner1 : corner2;
|
|
251
|
+
}
|
|
252
|
+
function computeIntegratedArrowVectors(arrow, orientation, allArrows) {
|
|
253
|
+
const label = arrow.label;
|
|
254
|
+
if (!label || label.background === void 0) return null;
|
|
255
|
+
const a = squareCentrePct(arrow.from, orientation);
|
|
256
|
+
const b = squareCentrePct(arrow.to, orientation);
|
|
257
|
+
if (arrow.from === arrow.to) return null;
|
|
258
|
+
const isKnight = isKnightMove(arrow.from, arrow.to);
|
|
259
|
+
const fontSize = label.fontSize ?? 2.45;
|
|
260
|
+
const geom = computeDynamicAeroGeometry(label.text, label.headStyle, fontSize, true);
|
|
261
|
+
let startUnit;
|
|
262
|
+
let finalUnit;
|
|
263
|
+
let corner = null;
|
|
264
|
+
if (!isKnight) {
|
|
265
|
+
const u = unitVector({ x: a.cx, y: a.cy }, { x: b.cx, y: b.cy });
|
|
266
|
+
if (u === null) return null;
|
|
267
|
+
startUnit = u;
|
|
268
|
+
finalUnit = u;
|
|
269
|
+
} else {
|
|
270
|
+
corner = chooseKnightCorner(arrow.from, arrow.to, allArrows, orientation);
|
|
271
|
+
startUnit = unitVector({ x: a.cx, y: a.cy }, corner);
|
|
272
|
+
finalUnit = unitVector(corner, { x: b.cx, y: b.cy });
|
|
273
|
+
if (startUnit === null || finalUnit === null) return null;
|
|
274
|
+
}
|
|
275
|
+
const tip = {
|
|
276
|
+
x: b.cx + finalUnit.x * 2.08,
|
|
277
|
+
y: b.cy + finalUnit.y * 2.08
|
|
278
|
+
};
|
|
279
|
+
const headCenter = {
|
|
280
|
+
x: tip.x - finalUnit.x * geom.frontLen,
|
|
281
|
+
y: tip.y - finalUnit.y * geom.frontLen
|
|
282
|
+
};
|
|
283
|
+
const shaftEnd = {
|
|
284
|
+
x: headCenter.x - finalUnit.x * geom.dockLen,
|
|
285
|
+
y: headCenter.y - finalUnit.y * geom.dockLen
|
|
286
|
+
};
|
|
287
|
+
const dist = Math.hypot(b.cx - a.cx, b.cy - a.cy);
|
|
288
|
+
const startOffset = dist < 18 ? 0.5 : 2.4;
|
|
289
|
+
const shaftStart = {
|
|
290
|
+
x: a.cx + startUnit.x * startOffset,
|
|
291
|
+
y: a.cy + startUnit.y * startOffset
|
|
292
|
+
};
|
|
293
|
+
const angleRad = Math.atan2(finalUnit.y, finalUnit.x);
|
|
294
|
+
const angleDeg = angleRad * 180 / Math.PI;
|
|
295
|
+
let textRot = 0;
|
|
296
|
+
const rotMode = label.textRotation ?? "auto";
|
|
297
|
+
if (rotMode === "flat") {
|
|
298
|
+
textRot = -angleDeg;
|
|
299
|
+
} else if (rotMode === "auto") {
|
|
300
|
+
const norm = (angleDeg % 360 + 360) % 360;
|
|
301
|
+
if (norm > 90 && norm < 270) {
|
|
302
|
+
textRot = 180;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const shaftD = corner !== null ? `M ${shaftStart.x} ${shaftStart.y} L ${corner.x} ${corner.y} L ${shaftEnd.x} ${shaftEnd.y}` : `M ${shaftStart.x} ${shaftStart.y} L ${shaftEnd.x} ${shaftEnd.y}`;
|
|
306
|
+
const shaftLen = (shaftEnd.x - shaftStart.x) * startUnit.x + (shaftEnd.y - shaftStart.y) * startUnit.y;
|
|
307
|
+
const showShaft = isKnight || shaftLen > 0.2;
|
|
308
|
+
return {
|
|
309
|
+
label,
|
|
310
|
+
fontSize,
|
|
311
|
+
geom,
|
|
312
|
+
headCenter,
|
|
313
|
+
shaftD,
|
|
314
|
+
showShaft,
|
|
315
|
+
angleDeg,
|
|
316
|
+
textRot
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function renderIntegratedShaft(arrow, color, orientation, key, allArrows) {
|
|
320
|
+
const v = computeIntegratedArrowVectors(arrow, orientation, allArrows);
|
|
321
|
+
if (v === null || !v.showShaft) return null;
|
|
322
|
+
const is3d = v.label.style3d !== false;
|
|
323
|
+
const filterId = is3d ? "url(#gb-apple-elevation)" : "url(#gb-arrow-shadow)";
|
|
324
|
+
return /* @__PURE__ */ jsxs("g", { filter: filterId, children: [
|
|
325
|
+
/* @__PURE__ */ jsx(
|
|
326
|
+
"path",
|
|
327
|
+
{
|
|
328
|
+
d: v.shaftD,
|
|
329
|
+
fill: "none",
|
|
330
|
+
stroke: is3d ? "rgba(44, 27, 20, 0.75)" : color,
|
|
331
|
+
strokeWidth: is3d ? "3.2" : "2.2",
|
|
332
|
+
strokeLinecap: "round",
|
|
333
|
+
strokeLinejoin: "round"
|
|
334
|
+
}
|
|
335
|
+
),
|
|
336
|
+
/* @__PURE__ */ jsx(
|
|
337
|
+
"path",
|
|
338
|
+
{
|
|
339
|
+
d: v.shaftD,
|
|
340
|
+
fill: "none",
|
|
341
|
+
stroke: color,
|
|
342
|
+
strokeWidth: "2.1",
|
|
343
|
+
strokeLinecap: "round",
|
|
344
|
+
strokeLinejoin: "round"
|
|
345
|
+
}
|
|
346
|
+
),
|
|
347
|
+
is3d && /* @__PURE__ */ jsx(
|
|
348
|
+
"path",
|
|
349
|
+
{
|
|
350
|
+
d: v.shaftD,
|
|
351
|
+
fill: "none",
|
|
352
|
+
stroke: "rgba(255, 255, 255, 0.3)",
|
|
353
|
+
strokeWidth: "0.6",
|
|
354
|
+
strokeLinecap: "round",
|
|
355
|
+
strokeLinejoin: "round"
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
] }, `${key}-shaft`);
|
|
359
|
+
}
|
|
360
|
+
function renderIntegratedHead(arrow, _color, orientation, key, allArrows) {
|
|
361
|
+
const v = computeIntegratedArrowVectors(arrow, orientation, allArrows);
|
|
362
|
+
if (v === null) return null;
|
|
363
|
+
const is3d = v.label.style3d !== false;
|
|
364
|
+
const filterId = is3d ? "url(#gb-apple-elevation)" : "url(#gb-arrow-shadow)";
|
|
365
|
+
const headFill = v.label.background === "#F59E0B" && is3d ? "url(#gb-apple-amber-grad)" : v.label.background;
|
|
366
|
+
const headStroke = v.label.borderColor ?? "#78350F";
|
|
367
|
+
return /* @__PURE__ */ jsx("g", { filter: filterId, children: /* @__PURE__ */ jsxs("g", { transform: `translate(${v.headCenter.x}, ${v.headCenter.y}) rotate(${v.angleDeg})`, children: [
|
|
368
|
+
/* @__PURE__ */ jsx(
|
|
369
|
+
"path",
|
|
370
|
+
{
|
|
371
|
+
d: v.geom.path,
|
|
372
|
+
fill: headFill,
|
|
373
|
+
stroke: headStroke,
|
|
374
|
+
strokeWidth: "0.7",
|
|
375
|
+
strokeLinejoin: "round"
|
|
376
|
+
}
|
|
377
|
+
),
|
|
378
|
+
Boolean(v.label.text && v.label.text.trim().length > 0) && /* @__PURE__ */ jsx(
|
|
379
|
+
"text",
|
|
380
|
+
{
|
|
381
|
+
x: 0,
|
|
382
|
+
y: 0,
|
|
383
|
+
transform: v.textRot !== 0 ? `rotate(${v.textRot})` : void 0,
|
|
384
|
+
fill: v.label.fill ?? "#000000",
|
|
385
|
+
fontSize: v.fontSize,
|
|
386
|
+
fontWeight: "800",
|
|
387
|
+
fontFamily: "'JetBrains Mono', ui-monospace, monospace",
|
|
388
|
+
textAnchor: "middle",
|
|
389
|
+
dominantBaseline: "central",
|
|
390
|
+
style: { userSelect: "none" },
|
|
391
|
+
children: v.label.text
|
|
392
|
+
}
|
|
393
|
+
)
|
|
394
|
+
] }) }, `${key}-head`);
|
|
395
|
+
}
|
|
158
396
|
var ArrowsLayer = memo(
|
|
159
397
|
forwardRef(function ArrowsLayer2({ model, orientation, palette, below = false }, handle) {
|
|
160
398
|
const canvasRef = useRef(null);
|
|
@@ -213,7 +451,7 @@ var ArrowsLayer = memo(
|
|
|
213
451
|
}
|
|
214
452
|
}
|
|
215
453
|
),
|
|
216
|
-
hasDecorations ? /* @__PURE__ */
|
|
454
|
+
hasDecorations ? /* @__PURE__ */ jsxs(
|
|
217
455
|
"svg",
|
|
218
456
|
{
|
|
219
457
|
"data-layer": below ? "arrows-below-decor" : "arrows-decor",
|
|
@@ -229,50 +467,126 @@ var ArrowsLayer = memo(
|
|
|
229
467
|
// Decorations share the z-plane of the canvas they annotate.
|
|
230
468
|
...layerZIndex !== void 0 ? { zIndex: layerZIndex } : {}
|
|
231
469
|
},
|
|
232
|
-
children:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
"
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
470
|
+
children: [
|
|
471
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
472
|
+
/* @__PURE__ */ jsx(
|
|
473
|
+
"filter",
|
|
474
|
+
{
|
|
475
|
+
id: "gb-arrow-shadow",
|
|
476
|
+
filterUnits: "userSpaceOnUse",
|
|
477
|
+
x: "-20",
|
|
478
|
+
y: "-20",
|
|
479
|
+
width: "140",
|
|
480
|
+
height: "140",
|
|
481
|
+
children: /* @__PURE__ */ jsx(
|
|
482
|
+
"feDropShadow",
|
|
483
|
+
{
|
|
484
|
+
dx: "0",
|
|
485
|
+
dy: "1.2",
|
|
486
|
+
stdDeviation: "1.2",
|
|
487
|
+
floodColor: "#000000",
|
|
488
|
+
floodOpacity: "0.55"
|
|
489
|
+
}
|
|
490
|
+
)
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
/* @__PURE__ */ jsxs(
|
|
494
|
+
"filter",
|
|
495
|
+
{
|
|
496
|
+
id: "gb-apple-elevation",
|
|
497
|
+
filterUnits: "userSpaceOnUse",
|
|
498
|
+
x: "-20",
|
|
499
|
+
y: "-20",
|
|
500
|
+
width: "140",
|
|
501
|
+
height: "140",
|
|
502
|
+
children: [
|
|
503
|
+
/* @__PURE__ */ jsx(
|
|
504
|
+
"feDropShadow",
|
|
505
|
+
{
|
|
506
|
+
dx: "0",
|
|
507
|
+
dy: "2.8",
|
|
508
|
+
stdDeviation: "2.2",
|
|
509
|
+
floodColor: "#000000",
|
|
510
|
+
floodOpacity: "0.4"
|
|
511
|
+
}
|
|
512
|
+
),
|
|
513
|
+
/* @__PURE__ */ jsx(
|
|
514
|
+
"feDropShadow",
|
|
515
|
+
{
|
|
516
|
+
dx: "0",
|
|
517
|
+
dy: "1.0",
|
|
518
|
+
stdDeviation: "0.7",
|
|
519
|
+
floodColor: "#000000",
|
|
520
|
+
floodOpacity: "0.6"
|
|
521
|
+
}
|
|
522
|
+
)
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
),
|
|
526
|
+
/* @__PURE__ */ jsxs("linearGradient", { id: "gb-apple-amber-grad", x1: "0%", y1: "0%", x2: "0%", y2: "100%", children: [
|
|
527
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "#FBBF24", stopOpacity: "1" }),
|
|
528
|
+
/* @__PURE__ */ jsx("stop", { offset: "60%", stopColor: "#F59E0B", stopOpacity: "1" }),
|
|
529
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "#D97706", stopOpacity: "1" })
|
|
530
|
+
] })
|
|
531
|
+
] }),
|
|
532
|
+
arrows.map((arrow) => {
|
|
533
|
+
if (arrow.label?.background === void 0) return null;
|
|
534
|
+
const key = `${arrow.from}-${arrow.to}-${arrow.color}-${arrow.brush ?? ""}`;
|
|
535
|
+
const color = resolveColor(arrow, palette);
|
|
536
|
+
return renderIntegratedShaft(arrow, color, orientation, key, arrows);
|
|
537
|
+
}),
|
|
538
|
+
arrows.map((arrow) => {
|
|
539
|
+
if (arrow.label?.background === void 0) return null;
|
|
540
|
+
const key = `${arrow.from}-${arrow.to}-${arrow.color}-${arrow.brush ?? ""}`;
|
|
541
|
+
const color = resolveColor(arrow, palette);
|
|
542
|
+
return renderIntegratedHead(arrow, color, orientation, key, arrows);
|
|
543
|
+
}),
|
|
544
|
+
arrows.map((arrow) => {
|
|
545
|
+
if (arrow.label?.background !== void 0) return null;
|
|
546
|
+
const key = `${arrow.from}-${arrow.to}-${arrow.color}-${arrow.brush ?? ""}`;
|
|
547
|
+
const color = resolveColor(arrow, palette);
|
|
548
|
+
const nodes = [];
|
|
549
|
+
if (arrow.label !== void 0) {
|
|
550
|
+
const { cx, cy } = anchorPct(arrow.from, arrow.to, orientation, "label");
|
|
551
|
+
nodes.push(
|
|
552
|
+
/* @__PURE__ */ jsx(
|
|
553
|
+
"text",
|
|
554
|
+
{
|
|
555
|
+
x: cx,
|
|
556
|
+
y: cy,
|
|
557
|
+
fill: arrow.label.fill ?? color,
|
|
558
|
+
fontSize: "4",
|
|
559
|
+
fontWeight: "700",
|
|
560
|
+
textAnchor: "middle",
|
|
561
|
+
dominantBaseline: "central",
|
|
562
|
+
style: { userSelect: "none" },
|
|
563
|
+
children: arrow.label.text
|
|
564
|
+
},
|
|
565
|
+
`${key}-label`
|
|
566
|
+
)
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
if (arrow.customSvg !== void 0) {
|
|
570
|
+
const { cx, cy } = anchorPct(
|
|
571
|
+
arrow.from,
|
|
572
|
+
arrow.to,
|
|
573
|
+
orientation,
|
|
574
|
+
arrow.customSvg.center ?? "dest"
|
|
575
|
+
);
|
|
576
|
+
nodes.push(
|
|
577
|
+
/* @__PURE__ */ jsx(
|
|
578
|
+
"g",
|
|
579
|
+
{
|
|
580
|
+
transform: `translate(${cx}, ${cy})`,
|
|
581
|
+
dangerouslySetInnerHTML: { __html: arrow.customSvg.html }
|
|
582
|
+
},
|
|
583
|
+
`${key}-svg`
|
|
584
|
+
)
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
return nodes.length === 0 ? null : /* @__PURE__ */ jsx("g", { children: nodes }, key);
|
|
588
|
+
})
|
|
589
|
+
]
|
|
276
590
|
}
|
|
277
591
|
) : null
|
|
278
592
|
] });
|