@lichess-org/chessground 9.2.3
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/LICENSE +674 -0
- package/README.md +110 -0
- package/assets/chessground.base.css +224 -0
- package/assets/chessground.brown.css +62 -0
- package/assets/chessground.cburnett.css +37 -0
- package/dist/anim.d.ts +17 -0
- package/dist/anim.js +99 -0
- package/dist/anim.js.map +1 -0
- package/dist/api.d.ts +28 -0
- package/dist/api.js +98 -0
- package/dist/api.js.map +1 -0
- package/dist/autoPieces.d.ts +3 -0
- package/dist/autoPieces.js +38 -0
- package/dist/autoPieces.js.map +1 -0
- package/dist/board.d.ts +25 -0
- package/dist/board.js +331 -0
- package/dist/board.js.map +1 -0
- package/dist/chessground.d.ts +7 -0
- package/dist/chessground.js +63 -0
- package/dist/chessground.js.map +1 -0
- package/dist/chessground.min.js +1 -0
- package/dist/config.d.ts +87 -0
- package/dist/config.js +64 -0
- package/dist/config.js.map +1 -0
- package/dist/drag.d.ts +20 -0
- package/dist/drag.js +208 -0
- package/dist/drag.js.map +1 -0
- package/dist/draw.d.ts +65 -0
- package/dist/draw.js +90 -0
- package/dist/draw.js.map +1 -0
- package/dist/drop.d.ts +5 -0
- package/dist/drop.js +31 -0
- package/dist/drop.js.map +1 -0
- package/dist/events.d.ts +4 -0
- package/dist/events.js +72 -0
- package/dist/events.js.map +1 -0
- package/dist/explosion.d.ts +3 -0
- package/dist/explosion.js +18 -0
- package/dist/explosion.js.map +1 -0
- package/dist/fen.d.ts +4 -0
- package/dist/fen.js +79 -0
- package/dist/fen.js.map +1 -0
- package/dist/premove.d.ts +6 -0
- package/dist/premove.js +57 -0
- package/dist/premove.js.map +1 -0
- package/dist/render.d.ts +4 -0
- package/dist/render.js +235 -0
- package/dist/render.js.map +1 -0
- package/dist/state.d.ts +100 -0
- package/dist/state.js +92 -0
- package/dist/state.js.map +1 -0
- package/dist/svg.d.ts +8 -0
- package/dist/svg.js +348 -0
- package/dist/svg.js.map +1 -0
- package/dist/sync.d.ts +8 -0
- package/dist/sync.js +27 -0
- package/dist/sync.js.map +1 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +20 -0
- package/dist/util.js +89 -0
- package/dist/util.js.map +1 -0
- package/dist/wrap.d.ts +3 -0
- package/dist/wrap.js +90 -0
- package/dist/wrap.js.map +1 -0
- package/package.json +58 -0
- package/src/anim.ts +139 -0
- package/src/api.ts +187 -0
- package/src/autoPieces.ts +47 -0
- package/src/board.ts +371 -0
- package/src/chessground.ts +67 -0
- package/src/config.ts +165 -0
- package/src/drag.ts +223 -0
- package/src/draw.ts +154 -0
- package/src/drop.ts +36 -0
- package/src/events.ts +86 -0
- package/src/explosion.ts +19 -0
- package/src/fen.ts +78 -0
- package/src/premove.ts +76 -0
- package/src/render.ts +262 -0
- package/src/state.ts +199 -0
- package/src/svg.ts +441 -0
- package/src/sync.ts +36 -0
- package/src/types.ts +110 -0
- package/src/util.ts +105 -0
- package/src/wrap.ts +111 -0
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { AnimCurrent } from './anim.js';
|
|
2
|
+
import { DragCurrent } from './drag.js';
|
|
3
|
+
import { Drawable } from './draw.js';
|
|
4
|
+
import * as cg from './types.js';
|
|
5
|
+
export interface HeadlessState {
|
|
6
|
+
pieces: cg.Pieces;
|
|
7
|
+
orientation: cg.Color;
|
|
8
|
+
turnColor: cg.Color;
|
|
9
|
+
check?: cg.Key;
|
|
10
|
+
lastMove?: cg.Key[];
|
|
11
|
+
selected?: cg.Key;
|
|
12
|
+
coordinates: boolean;
|
|
13
|
+
coordinatesOnSquares: boolean;
|
|
14
|
+
ranksPosition: cg.RanksPosition;
|
|
15
|
+
autoCastle: boolean;
|
|
16
|
+
viewOnly: boolean;
|
|
17
|
+
disableContextMenu: boolean;
|
|
18
|
+
addPieceZIndex: boolean;
|
|
19
|
+
addDimensionsCssVarsTo?: HTMLElement;
|
|
20
|
+
blockTouchScroll: boolean;
|
|
21
|
+
pieceKey: boolean;
|
|
22
|
+
trustAllEvents?: boolean;
|
|
23
|
+
highlight: {
|
|
24
|
+
lastMove: boolean;
|
|
25
|
+
check: boolean;
|
|
26
|
+
custom?: cg.SquareClasses;
|
|
27
|
+
};
|
|
28
|
+
animation: {
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
duration: number;
|
|
31
|
+
current?: AnimCurrent;
|
|
32
|
+
};
|
|
33
|
+
movable: {
|
|
34
|
+
free: boolean;
|
|
35
|
+
color?: cg.Color | 'both';
|
|
36
|
+
dests?: cg.Dests;
|
|
37
|
+
showDests: boolean;
|
|
38
|
+
events: {
|
|
39
|
+
after?: (orig: cg.Key, dest: cg.Key, metadata: cg.MoveMetadata) => void;
|
|
40
|
+
afterNewPiece?: (role: cg.Role, key: cg.Key, metadata: cg.MoveMetadata) => void;
|
|
41
|
+
};
|
|
42
|
+
rookCastle: boolean;
|
|
43
|
+
};
|
|
44
|
+
premovable: {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
showDests: boolean;
|
|
47
|
+
castle: boolean;
|
|
48
|
+
dests?: cg.Key[];
|
|
49
|
+
customDests?: cg.Dests;
|
|
50
|
+
current?: cg.KeyPair;
|
|
51
|
+
events: {
|
|
52
|
+
set?: (orig: cg.Key, dest: cg.Key, metadata?: cg.SetPremoveMetadata) => void;
|
|
53
|
+
unset?: () => void;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
predroppable: {
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
current?: {
|
|
59
|
+
role: cg.Role;
|
|
60
|
+
key: cg.Key;
|
|
61
|
+
};
|
|
62
|
+
events: {
|
|
63
|
+
set?: (role: cg.Role, key: cg.Key) => void;
|
|
64
|
+
unset?: () => void;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
draggable: {
|
|
68
|
+
enabled: boolean;
|
|
69
|
+
distance: number;
|
|
70
|
+
autoDistance: boolean;
|
|
71
|
+
showGhost: boolean;
|
|
72
|
+
deleteOnDropOff: boolean;
|
|
73
|
+
current?: DragCurrent;
|
|
74
|
+
};
|
|
75
|
+
dropmode: {
|
|
76
|
+
active: boolean;
|
|
77
|
+
piece?: cg.Piece;
|
|
78
|
+
};
|
|
79
|
+
selectable: {
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
};
|
|
82
|
+
stats: {
|
|
83
|
+
dragged: boolean;
|
|
84
|
+
ctrlKey?: boolean;
|
|
85
|
+
};
|
|
86
|
+
events: {
|
|
87
|
+
change?: () => void;
|
|
88
|
+
move?: (orig: cg.Key, dest: cg.Key, capturedPiece?: cg.Piece) => void;
|
|
89
|
+
dropNewPiece?: (piece: cg.Piece, key: cg.Key) => void;
|
|
90
|
+
select?: (key: cg.Key) => void;
|
|
91
|
+
insert?: (elements: cg.Elements) => void;
|
|
92
|
+
};
|
|
93
|
+
drawable: Drawable;
|
|
94
|
+
exploding?: cg.Exploding;
|
|
95
|
+
hold: cg.Timer;
|
|
96
|
+
}
|
|
97
|
+
export interface State extends HeadlessState {
|
|
98
|
+
dom: cg.Dom;
|
|
99
|
+
}
|
|
100
|
+
export declare function defaults(): HeadlessState;
|
package/dist/state.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as fen from './fen.js';
|
|
2
|
+
import { timer } from './util.js';
|
|
3
|
+
export function defaults() {
|
|
4
|
+
return {
|
|
5
|
+
pieces: fen.read(fen.initial),
|
|
6
|
+
orientation: 'white',
|
|
7
|
+
turnColor: 'white',
|
|
8
|
+
coordinates: true,
|
|
9
|
+
coordinatesOnSquares: false,
|
|
10
|
+
ranksPosition: 'right',
|
|
11
|
+
autoCastle: true,
|
|
12
|
+
viewOnly: false,
|
|
13
|
+
disableContextMenu: false,
|
|
14
|
+
addPieceZIndex: false,
|
|
15
|
+
blockTouchScroll: false,
|
|
16
|
+
pieceKey: false,
|
|
17
|
+
trustAllEvents: false,
|
|
18
|
+
highlight: {
|
|
19
|
+
lastMove: true,
|
|
20
|
+
check: true,
|
|
21
|
+
},
|
|
22
|
+
animation: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
duration: 200,
|
|
25
|
+
},
|
|
26
|
+
movable: {
|
|
27
|
+
free: true,
|
|
28
|
+
color: 'both',
|
|
29
|
+
showDests: true,
|
|
30
|
+
events: {},
|
|
31
|
+
rookCastle: true,
|
|
32
|
+
},
|
|
33
|
+
premovable: {
|
|
34
|
+
enabled: true,
|
|
35
|
+
showDests: true,
|
|
36
|
+
castle: true,
|
|
37
|
+
events: {},
|
|
38
|
+
},
|
|
39
|
+
predroppable: {
|
|
40
|
+
enabled: false,
|
|
41
|
+
events: {},
|
|
42
|
+
},
|
|
43
|
+
draggable: {
|
|
44
|
+
enabled: true,
|
|
45
|
+
distance: 3,
|
|
46
|
+
autoDistance: true,
|
|
47
|
+
showGhost: true,
|
|
48
|
+
deleteOnDropOff: false,
|
|
49
|
+
},
|
|
50
|
+
dropmode: {
|
|
51
|
+
active: false,
|
|
52
|
+
},
|
|
53
|
+
selectable: {
|
|
54
|
+
enabled: true,
|
|
55
|
+
},
|
|
56
|
+
stats: {
|
|
57
|
+
// on touchscreen, default to "tap-tap" moves
|
|
58
|
+
// instead of drag
|
|
59
|
+
dragged: !('ontouchstart' in window),
|
|
60
|
+
},
|
|
61
|
+
events: {},
|
|
62
|
+
drawable: {
|
|
63
|
+
enabled: true, // can draw
|
|
64
|
+
visible: true, // can view
|
|
65
|
+
defaultSnapToValidMove: true,
|
|
66
|
+
eraseOnClick: true,
|
|
67
|
+
shapes: [],
|
|
68
|
+
autoShapes: [],
|
|
69
|
+
brushes: {
|
|
70
|
+
green: { key: 'g', color: '#15781B', opacity: 1, lineWidth: 10 },
|
|
71
|
+
red: { key: 'r', color: '#882020', opacity: 1, lineWidth: 10 },
|
|
72
|
+
blue: { key: 'b', color: '#003088', opacity: 1, lineWidth: 10 },
|
|
73
|
+
yellow: { key: 'y', color: '#e68f00', opacity: 1, lineWidth: 10 },
|
|
74
|
+
paleBlue: { key: 'pb', color: '#003088', opacity: 0.4, lineWidth: 15 },
|
|
75
|
+
paleGreen: { key: 'pg', color: '#15781B', opacity: 0.4, lineWidth: 15 },
|
|
76
|
+
paleRed: { key: 'pr', color: '#882020', opacity: 0.4, lineWidth: 15 },
|
|
77
|
+
paleGrey: {
|
|
78
|
+
key: 'pgr',
|
|
79
|
+
color: '#4a4a4a',
|
|
80
|
+
opacity: 0.35,
|
|
81
|
+
lineWidth: 15,
|
|
82
|
+
},
|
|
83
|
+
purple: { key: 'purple', color: '#68217a', opacity: 0.65, lineWidth: 10 },
|
|
84
|
+
pink: { key: 'pink', color: '#ee2080', opacity: 0.5, lineWidth: 10 },
|
|
85
|
+
white: { key: 'white', color: 'white', opacity: 1, lineWidth: 10 },
|
|
86
|
+
},
|
|
87
|
+
prevSvgHash: '',
|
|
88
|
+
},
|
|
89
|
+
hold: timer(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AA0GlC,MAAM,UAAU,QAAQ;IACtB,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAC7B,WAAW,EAAE,OAAO;QACpB,SAAS,EAAE,OAAO;QAClB,WAAW,EAAE,IAAI;QACjB,oBAAoB,EAAE,KAAK;QAC3B,aAAa,EAAE,OAAO;QACtB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,KAAK;QACf,kBAAkB,EAAE,KAAK;QACzB,cAAc,EAAE,KAAK;QACrB,gBAAgB,EAAE,KAAK;QACvB,QAAQ,EAAE,KAAK;QACf,cAAc,EAAE,KAAK;QACrB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.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { State } from './state.js';
|
|
2
|
+
export { createElement, setAttributes };
|
|
3
|
+
export declare function createDefs(): Element;
|
|
4
|
+
export declare function renderSvg(state: State, shapesEl: SVGElement, customsEl: SVGElement): void;
|
|
5
|
+
declare function createElement(tagName: string): SVGElement;
|
|
6
|
+
declare function setAttributes(el: SVGElement, attrs: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}): SVGElement;
|
package/dist/svg.js
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { key2pos } from './util.js';
|
|
2
|
+
const hilites = {
|
|
3
|
+
hilitePrimary: { key: 'hilitePrimary', color: '#3291ff', opacity: 1, lineWidth: 1 },
|
|
4
|
+
hiliteWhite: { key: 'hiliteWhite', color: '#ffffff', opacity: 1, lineWidth: 1 },
|
|
5
|
+
};
|
|
6
|
+
export { createElement, setAttributes };
|
|
7
|
+
export function createDefs() {
|
|
8
|
+
const defs = createElement('defs');
|
|
9
|
+
const filter = setAttributes(createElement('filter'), { id: 'cg-filter-blur' });
|
|
10
|
+
filter.appendChild(setAttributes(createElement('feGaussianBlur'), { stdDeviation: '0.019' }));
|
|
11
|
+
defs.appendChild(filter);
|
|
12
|
+
return defs;
|
|
13
|
+
}
|
|
14
|
+
export function renderSvg(state, shapesEl, customsEl) {
|
|
15
|
+
var _a;
|
|
16
|
+
const d = state.drawable, curD = d.current, cur = curD && curD.mouseSq ? curD : undefined, dests = new Map(), bounds = state.dom.bounds(), nonPieceAutoShapes = d.autoShapes.filter(autoShape => !autoShape.piece);
|
|
17
|
+
for (const s of d.shapes.concat(nonPieceAutoShapes).concat(cur ? [cur] : [])) {
|
|
18
|
+
if (!s.dest)
|
|
19
|
+
continue;
|
|
20
|
+
const sources = (_a = dests.get(s.dest)) !== null && _a !== void 0 ? _a : new Set(), from = pos2user(orient(key2pos(s.orig), state.orientation), bounds), to = pos2user(orient(key2pos(s.dest), state.orientation), bounds);
|
|
21
|
+
sources.add(moveAngle(from, to));
|
|
22
|
+
dests.set(s.dest, sources);
|
|
23
|
+
}
|
|
24
|
+
const shapes = d.shapes.concat(nonPieceAutoShapes).map((s) => {
|
|
25
|
+
return {
|
|
26
|
+
shape: s,
|
|
27
|
+
current: false,
|
|
28
|
+
hash: shapeHash(s, isShort(s.dest, dests), false, bounds),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
if (cur)
|
|
32
|
+
shapes.push({
|
|
33
|
+
shape: cur,
|
|
34
|
+
current: true,
|
|
35
|
+
hash: shapeHash(cur, isShort(cur.dest, dests), true, bounds),
|
|
36
|
+
});
|
|
37
|
+
const fullHash = shapes.map(sc => sc.hash).join(';');
|
|
38
|
+
if (fullHash === state.drawable.prevSvgHash)
|
|
39
|
+
return;
|
|
40
|
+
state.drawable.prevSvgHash = fullHash;
|
|
41
|
+
/*
|
|
42
|
+
-- DOM hierarchy --
|
|
43
|
+
<svg class="cg-shapes"> (<= svg)
|
|
44
|
+
<defs>
|
|
45
|
+
...(for brushes)...
|
|
46
|
+
</defs>
|
|
47
|
+
<g>
|
|
48
|
+
...(for arrows and circles)...
|
|
49
|
+
</g>
|
|
50
|
+
</svg>
|
|
51
|
+
<svg class="cg-custom-svgs"> (<= customSvg)
|
|
52
|
+
<g>
|
|
53
|
+
...(for custom svgs)...
|
|
54
|
+
</g>
|
|
55
|
+
</svg>
|
|
56
|
+
*/
|
|
57
|
+
const defsEl = shapesEl.querySelector('defs');
|
|
58
|
+
syncDefs(d, shapes, defsEl);
|
|
59
|
+
syncShapes(shapes, shapesEl.querySelector('g'), customsEl.querySelector('g'), s => renderShape(state, s, d.brushes, dests, bounds));
|
|
60
|
+
}
|
|
61
|
+
// append only. Don't try to update/remove.
|
|
62
|
+
function syncDefs(d, shapes, defsEl) {
|
|
63
|
+
var _a;
|
|
64
|
+
const brushes = new Map();
|
|
65
|
+
let brush;
|
|
66
|
+
for (const s of shapes.filter(s => s.shape.dest && s.shape.brush)) {
|
|
67
|
+
brush = makeCustomBrush(d.brushes[s.shape.brush], s.shape.modifiers);
|
|
68
|
+
if ((_a = s.shape.modifiers) === null || _a === void 0 ? void 0 : _a.hilite)
|
|
69
|
+
brushes.set(hilite(brush).key, hilite(brush));
|
|
70
|
+
brushes.set(brush.key, brush);
|
|
71
|
+
}
|
|
72
|
+
const keysInDom = new Set();
|
|
73
|
+
let el = defsEl.firstElementChild;
|
|
74
|
+
while (el) {
|
|
75
|
+
keysInDom.add(el.getAttribute('cgKey'));
|
|
76
|
+
el = el.nextElementSibling;
|
|
77
|
+
}
|
|
78
|
+
for (const [key, brush] of brushes.entries()) {
|
|
79
|
+
if (!keysInDom.has(key))
|
|
80
|
+
defsEl.appendChild(renderMarker(brush));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function syncShapes(syncables, shapes, customs, renderShape) {
|
|
84
|
+
const hashesInDom = new Map();
|
|
85
|
+
for (const sc of syncables)
|
|
86
|
+
hashesInDom.set(sc.hash, false);
|
|
87
|
+
for (const root of [shapes, customs]) {
|
|
88
|
+
const toRemove = [];
|
|
89
|
+
let el = root.firstElementChild, elHash;
|
|
90
|
+
while (el) {
|
|
91
|
+
elHash = el.getAttribute('cgHash');
|
|
92
|
+
if (hashesInDom.has(elHash))
|
|
93
|
+
hashesInDom.set(elHash, true);
|
|
94
|
+
else
|
|
95
|
+
toRemove.push(el);
|
|
96
|
+
el = el.nextElementSibling;
|
|
97
|
+
}
|
|
98
|
+
for (const el of toRemove)
|
|
99
|
+
root.removeChild(el);
|
|
100
|
+
}
|
|
101
|
+
// insert shapes that are not yet in dom
|
|
102
|
+
for (const sc of syncables.filter(s => !hashesInDom.get(s.hash))) {
|
|
103
|
+
for (const svg of renderShape(sc)) {
|
|
104
|
+
if (svg.isCustom)
|
|
105
|
+
customs.appendChild(svg.el);
|
|
106
|
+
else
|
|
107
|
+
shapes.appendChild(svg.el);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label }, shorten, current, bounds) {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
// a shape and an overlay svg share a lifetime and have the same cgHash attribute
|
|
114
|
+
return [
|
|
115
|
+
bounds.width,
|
|
116
|
+
bounds.height,
|
|
117
|
+
current,
|
|
118
|
+
orig,
|
|
119
|
+
dest,
|
|
120
|
+
brush,
|
|
121
|
+
shorten && '-',
|
|
122
|
+
piece && pieceHash(piece),
|
|
123
|
+
modifiers && modifiersHash(modifiers),
|
|
124
|
+
customSvg && `custom-${textHash(customSvg.html)},${(_b = (_a = customSvg.center) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 'o'}`,
|
|
125
|
+
label && `label-${textHash(label.text)}`,
|
|
126
|
+
]
|
|
127
|
+
.filter(x => x)
|
|
128
|
+
.join(',');
|
|
129
|
+
}
|
|
130
|
+
function pieceHash(piece) {
|
|
131
|
+
return [piece.color, piece.role, piece.scale].filter(x => x).join(',');
|
|
132
|
+
}
|
|
133
|
+
function modifiersHash(m) {
|
|
134
|
+
return [m.lineWidth, m.hilite && '*'].filter(x => x).join(',');
|
|
135
|
+
}
|
|
136
|
+
function textHash(s) {
|
|
137
|
+
// Rolling hash with base 31 (cf. https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript)
|
|
138
|
+
let h = 0;
|
|
139
|
+
for (let i = 0; i < s.length; i++) {
|
|
140
|
+
h = ((h << 5) - h + s.charCodeAt(i)) >>> 0;
|
|
141
|
+
}
|
|
142
|
+
return h.toString();
|
|
143
|
+
}
|
|
144
|
+
function renderShape(state, { shape, current, hash }, brushes, dests, bounds) {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
const from = pos2user(orient(key2pos(shape.orig), state.orientation), bounds), to = shape.dest ? pos2user(orient(key2pos(shape.dest), state.orientation), bounds) : from, brush = shape.brush && makeCustomBrush(brushes[shape.brush], shape.modifiers), slots = dests.get(shape.dest), svgs = [];
|
|
147
|
+
if (brush) {
|
|
148
|
+
const el = setAttributes(createElement('g'), { cgHash: hash });
|
|
149
|
+
svgs.push({ el });
|
|
150
|
+
if (from[0] !== to[0] || from[1] !== to[1])
|
|
151
|
+
el.appendChild(renderArrow(shape, brush, from, to, current, isShort(shape.dest, dests)));
|
|
152
|
+
else
|
|
153
|
+
el.appendChild(renderCircle(brushes[shape.brush], from, current, bounds));
|
|
154
|
+
}
|
|
155
|
+
if (shape.label) {
|
|
156
|
+
const label = shape.label;
|
|
157
|
+
(_a = label.fill) !== null && _a !== void 0 ? _a : (label.fill = shape.brush && brushes[shape.brush].color);
|
|
158
|
+
const corner = shape.brush ? undefined : 'tr';
|
|
159
|
+
svgs.push({ el: renderLabel(label, hash, from, to, slots, corner), isCustom: true });
|
|
160
|
+
}
|
|
161
|
+
if (shape.customSvg) {
|
|
162
|
+
const on = (_b = shape.customSvg.center) !== null && _b !== void 0 ? _b : 'orig';
|
|
163
|
+
const [x, y] = on === 'label' ? labelCoords(from, to, slots).map(c => c - 0.5) : on === 'dest' ? to : from;
|
|
164
|
+
const el = setAttributes(createElement('g'), { transform: `translate(${x},${y})`, cgHash: hash });
|
|
165
|
+
el.innerHTML = `<svg width="1" height="1" viewBox="0 0 100 100">${shape.customSvg.html}</svg>`;
|
|
166
|
+
svgs.push({ el, isCustom: true });
|
|
167
|
+
}
|
|
168
|
+
return svgs;
|
|
169
|
+
}
|
|
170
|
+
function renderCircle(brush, at, current, bounds) {
|
|
171
|
+
const widths = circleWidth(), radius = (bounds.width + bounds.height) / (4 * Math.max(bounds.width, bounds.height));
|
|
172
|
+
return setAttributes(createElement('circle'), {
|
|
173
|
+
stroke: brush.color,
|
|
174
|
+
'stroke-width': widths[current ? 0 : 1],
|
|
175
|
+
fill: 'none',
|
|
176
|
+
opacity: opacity(brush, current),
|
|
177
|
+
cx: at[0],
|
|
178
|
+
cy: at[1],
|
|
179
|
+
r: radius - widths[1] / 2,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function hilite(brush) {
|
|
183
|
+
return ['#ffffff', '#fff', 'white'].includes(brush.color)
|
|
184
|
+
? hilites['hilitePrimary']
|
|
185
|
+
: hilites['hiliteWhite'];
|
|
186
|
+
}
|
|
187
|
+
function renderArrow(s, brush, from, to, current, shorten) {
|
|
188
|
+
var _a;
|
|
189
|
+
function renderLine(isHilite) {
|
|
190
|
+
var _a;
|
|
191
|
+
const m = arrowMargin(shorten && !current), dx = to[0] - from[0], dy = to[1] - from[1], angle = Math.atan2(dy, dx), xo = Math.cos(angle) * m, yo = Math.sin(angle) * m;
|
|
192
|
+
return setAttributes(createElement('line'), {
|
|
193
|
+
stroke: isHilite ? hilite(brush).color : brush.color,
|
|
194
|
+
'stroke-width': lineWidth(brush, current) + (isHilite ? 0.04 : 0),
|
|
195
|
+
'stroke-linecap': 'round',
|
|
196
|
+
'marker-end': `url(#arrowhead-${isHilite ? hilite(brush).key : brush.key})`,
|
|
197
|
+
opacity: ((_a = s.modifiers) === null || _a === void 0 ? void 0 : _a.hilite) ? 1 : opacity(brush, current),
|
|
198
|
+
x1: from[0],
|
|
199
|
+
y1: from[1],
|
|
200
|
+
x2: to[0] - xo,
|
|
201
|
+
y2: to[1] - yo,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (!((_a = s.modifiers) === null || _a === void 0 ? void 0 : _a.hilite))
|
|
205
|
+
return renderLine(false);
|
|
206
|
+
const g = createElement('g');
|
|
207
|
+
const blurred = setAttributes(createElement('g'), { filter: 'url(#cg-filter-blur)' });
|
|
208
|
+
blurred.appendChild(filterBox(from, to));
|
|
209
|
+
blurred.appendChild(renderLine(true));
|
|
210
|
+
g.appendChild(blurred);
|
|
211
|
+
g.appendChild(renderLine(false));
|
|
212
|
+
return g;
|
|
213
|
+
}
|
|
214
|
+
function renderMarker(brush) {
|
|
215
|
+
const marker = setAttributes(createElement('marker'), {
|
|
216
|
+
id: 'arrowhead-' + brush.key,
|
|
217
|
+
orient: 'auto',
|
|
218
|
+
overflow: 'visible',
|
|
219
|
+
markerWidth: 4,
|
|
220
|
+
markerHeight: 4,
|
|
221
|
+
refX: brush.key.startsWith('hilite') ? 1.86 : 2.05,
|
|
222
|
+
refY: 2,
|
|
223
|
+
});
|
|
224
|
+
marker.appendChild(setAttributes(createElement('path'), {
|
|
225
|
+
d: 'M0,0 V4 L3,2 Z',
|
|
226
|
+
fill: brush.color,
|
|
227
|
+
}));
|
|
228
|
+
marker.setAttribute('cgKey', brush.key);
|
|
229
|
+
return marker;
|
|
230
|
+
}
|
|
231
|
+
function renderLabel(label, hash, from, to, slots, corner) {
|
|
232
|
+
var _a;
|
|
233
|
+
const labelSize = 0.4, fontSize = labelSize * 0.75 ** label.text.length, at = labelCoords(from, to, slots), cornerOff = corner === 'tr' ? 0.4 : 0, g = setAttributes(createElement('g'), {
|
|
234
|
+
transform: `translate(${at[0] + cornerOff},${at[1] - cornerOff})`,
|
|
235
|
+
cgHash: hash,
|
|
236
|
+
});
|
|
237
|
+
g.appendChild(setAttributes(createElement('circle'), {
|
|
238
|
+
r: labelSize / 2,
|
|
239
|
+
'fill-opacity': corner ? 1.0 : 0.8,
|
|
240
|
+
'stroke-opacity': corner ? 1.0 : 0.7,
|
|
241
|
+
'stroke-width': 0.03,
|
|
242
|
+
fill: (_a = label.fill) !== null && _a !== void 0 ? _a : '#666',
|
|
243
|
+
stroke: 'white',
|
|
244
|
+
}));
|
|
245
|
+
const labelEl = setAttributes(createElement('text'), {
|
|
246
|
+
'font-size': fontSize,
|
|
247
|
+
'font-family': 'Noto Sans',
|
|
248
|
+
'text-anchor': 'middle',
|
|
249
|
+
fill: 'white',
|
|
250
|
+
y: 0.13 * 0.75 ** label.text.length,
|
|
251
|
+
});
|
|
252
|
+
labelEl.innerHTML = label.text;
|
|
253
|
+
g.appendChild(labelEl);
|
|
254
|
+
return g;
|
|
255
|
+
}
|
|
256
|
+
function orient(pos, color) {
|
|
257
|
+
return color === 'white' ? pos : [7 - pos[0], 7 - pos[1]];
|
|
258
|
+
}
|
|
259
|
+
function isShort(dest, dests) {
|
|
260
|
+
return true === (dest && dests.has(dest) && dests.get(dest).size > 1);
|
|
261
|
+
}
|
|
262
|
+
function createElement(tagName) {
|
|
263
|
+
return document.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
264
|
+
}
|
|
265
|
+
function setAttributes(el, attrs) {
|
|
266
|
+
for (const key in attrs) {
|
|
267
|
+
if (Object.prototype.hasOwnProperty.call(attrs, key))
|
|
268
|
+
el.setAttribute(key, attrs[key]);
|
|
269
|
+
}
|
|
270
|
+
return el;
|
|
271
|
+
}
|
|
272
|
+
function makeCustomBrush(base, modifiers) {
|
|
273
|
+
return !modifiers
|
|
274
|
+
? base
|
|
275
|
+
: {
|
|
276
|
+
color: base.color,
|
|
277
|
+
opacity: Math.round(base.opacity * 10) / 10,
|
|
278
|
+
lineWidth: Math.round(modifiers.lineWidth || base.lineWidth),
|
|
279
|
+
key: [base.key, modifiers.lineWidth].filter(x => x).join(''),
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function circleWidth() {
|
|
283
|
+
return [3 / 64, 4 / 64];
|
|
284
|
+
}
|
|
285
|
+
function lineWidth(brush, current) {
|
|
286
|
+
return ((brush.lineWidth || 10) * (current ? 0.85 : 1)) / 64;
|
|
287
|
+
}
|
|
288
|
+
function opacity(brush, current) {
|
|
289
|
+
return (brush.opacity || 1) * (current ? 0.9 : 1);
|
|
290
|
+
}
|
|
291
|
+
function arrowMargin(shorten) {
|
|
292
|
+
return (shorten ? 20 : 10) / 64;
|
|
293
|
+
}
|
|
294
|
+
function pos2user(pos, bounds) {
|
|
295
|
+
const xScale = Math.min(1, bounds.width / bounds.height);
|
|
296
|
+
const yScale = Math.min(1, bounds.height / bounds.width);
|
|
297
|
+
return [(pos[0] - 3.5) * xScale, (3.5 - pos[1]) * yScale];
|
|
298
|
+
}
|
|
299
|
+
function filterBox(from, to) {
|
|
300
|
+
// lines/arrows are considered to be one dimensional for the purposes of SVG filters,
|
|
301
|
+
// so we add a transparent bounding box to ensure they apply to the 2nd dimension
|
|
302
|
+
const box = {
|
|
303
|
+
from: [Math.floor(Math.min(from[0], to[0])), Math.floor(Math.min(from[1], to[1]))],
|
|
304
|
+
to: [Math.ceil(Math.max(from[0], to[0])), Math.ceil(Math.max(from[1], to[1]))],
|
|
305
|
+
};
|
|
306
|
+
return setAttributes(createElement('rect'), {
|
|
307
|
+
x: box.from[0],
|
|
308
|
+
y: box.from[1],
|
|
309
|
+
width: box.to[0] - box.from[0],
|
|
310
|
+
height: box.to[1] - box.from[1],
|
|
311
|
+
fill: 'none',
|
|
312
|
+
stroke: 'none',
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function moveAngle(from, to, asSlot = true) {
|
|
316
|
+
const angle = Math.atan2(to[1] - from[1], to[0] - from[0]) + Math.PI;
|
|
317
|
+
return asSlot ? (Math.round((angle * 8) / Math.PI) + 16) % 16 : angle;
|
|
318
|
+
}
|
|
319
|
+
function dist(from, to) {
|
|
320
|
+
return Math.sqrt([from[0] - to[0], from[1] - to[1]].reduce((acc, x) => acc + x * x, 0));
|
|
321
|
+
}
|
|
322
|
+
/*
|
|
323
|
+
try to place label at the junction of the destination shaft and arrowhead. if there's more than
|
|
324
|
+
1 arrow pointing to a square, the arrow shortens by 10 / 64 units so the label must move as well.
|
|
325
|
+
|
|
326
|
+
if the angle between two incoming arrows is pi / 8, such as when an adjacent knight and bishop
|
|
327
|
+
attack the same square, the knight's label is slid further down the shaft by an amount equal to
|
|
328
|
+
our label size to avoid collision
|
|
329
|
+
*/
|
|
330
|
+
function labelCoords(from, to, slots) {
|
|
331
|
+
let mag = dist(from, to);
|
|
332
|
+
//if (mag === 0) return [from[0], from[1]];
|
|
333
|
+
const angle = moveAngle(from, to, false);
|
|
334
|
+
if (slots) {
|
|
335
|
+
mag -= 33 / 64; // reduce by arrowhead length
|
|
336
|
+
if (slots.size > 1) {
|
|
337
|
+
mag -= 10 / 64; // reduce by shortening factor
|
|
338
|
+
const slot = moveAngle(from, to);
|
|
339
|
+
if (slots.has((slot + 1) % 16) || slots.has((slot + 15) % 16)) {
|
|
340
|
+
if (slot & 1)
|
|
341
|
+
mag -= 0.4;
|
|
342
|
+
// and by label size for the knight if another arrow is within pi / 8.
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return [from[0] - Math.cos(angle) * mag, from[1] - Math.sin(angle) * mag].map(c => c + 0.5);
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=svg.js.map
|
package/dist/svg.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,MAAM,OAAO,GAAkC;IAC7C,aAAa,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;IACnF,WAAW,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;CAChF,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAExC,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAChF,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC9F,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,SAAS,C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AC,IAAI,GAAG,CAAC,EAAE,CAAC;YACnB,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,8BAA8B;YAC9C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACjC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;gBAC9D,IAAI,IAAI,GAAG,CAAC;oBAAE,GAAG,IAAI,GAAG,CAAC;gBACzB,sEAAsE;YACxE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAC3E,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CACI,CAAC;AACrB,CAAC"}
|
package/dist/sync.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DrawShape } from './draw';
|
|
2
|
+
export interface SyncableShape {
|
|
3
|
+
shape: DrawShape;
|
|
4
|
+
current: boolean;
|
|
5
|
+
hash: Hash;
|
|
6
|
+
}
|
|
7
|
+
export type Hash = string;
|
|
8
|
+
export declare function syncShapes(shapes: SyncableShape[], root: HTMLElement | SVGElement, renderShape: (shape: SyncableShape) => HTMLElement | SVGElement): void;
|
package/dist/sync.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// append and remove only. No updates.
|
|
2
|
+
export function syncShapes(shapes, root, renderShape) {
|
|
3
|
+
const hashesInDom = new Map(), // by hash
|
|
4
|
+
toRemove = [];
|
|
5
|
+
for (const sc of shapes)
|
|
6
|
+
hashesInDom.set(sc.hash, false);
|
|
7
|
+
let el = root.firstElementChild, elHash;
|
|
8
|
+
while (el) {
|
|
9
|
+
elHash = el.getAttribute('cgHash');
|
|
10
|
+
// found a shape element that's here to stay
|
|
11
|
+
if (hashesInDom.has(elHash))
|
|
12
|
+
hashesInDom.set(elHash, true);
|
|
13
|
+
// or remove it
|
|
14
|
+
else
|
|
15
|
+
toRemove.push(el);
|
|
16
|
+
el = el.nextElementSibling;
|
|
17
|
+
}
|
|
18
|
+
// remove old shapes
|
|
19
|
+
for (const el of toRemove)
|
|
20
|
+
root.removeChild(el);
|
|
21
|
+
// insert shapes that are not yet in dom
|
|
22
|
+
for (const sc of shapes) {
|
|
23
|
+
if (!hashesInDom.get(sc.hash))
|
|
24
|
+
root.appendChild(renderShape(sc));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=sync.js.map
|
package/dist/sync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAUA,sCAAsC;AACtC,MAAM,UAAU,UAAU,CACxB,MAAuB,EACvB,IAA8B,EAC9B,WAA+D;IAE/D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,EAAE,UAAU;IACvC,QAAQ,GAAiB,EAAE,CAAC;IAC9B,KAAK,MAAM,EAAE,IAAI,MAAM;QAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzD,IAAI,EAAE,GAA2B,IAAI,CAAC,iBAA+B,EACnE,MAAmB,CAAC;IACtB,OAAO,EAAE,EAAE,CAAC;QACV,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAS,CAAC;QAC3C,4CAA4C;QAC5C,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC3D,eAAe;;YACV,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvB,EAAE,GAAG,EAAE,CAAC,kBAA4C,CAAC;IACvD,CAAC;IACD,oBAAoB;IACpB,KAAK,MAAM,EAAE,IAAI,QAAQ;QAAE,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAChD,wCAAwC;IACxC,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;QACxB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC;YAAE,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;AACH,CAAC"}
|