next-chessground 0.13.10 → 0.13.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +72 -36
- package/dist/index.js +72 -36
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import React, { createContext, useState, useContext, useEffect, forwardRef } from 'react';
|
|
2
2
|
import require$$1 from 'react-dom';
|
|
3
3
|
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
} else {
|
|
13
|
-
obj[key] = value;
|
|
14
|
-
}
|
|
15
|
-
return obj;
|
|
4
|
+
function _defineProperty(e, r, t) {
|
|
5
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
6
|
+
value: t,
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
configurable: !0,
|
|
9
|
+
writable: !0
|
|
10
|
+
}) : e[r] = t, e;
|
|
16
11
|
}
|
|
17
12
|
function _extends() {
|
|
18
|
-
_extends = Object.assign
|
|
19
|
-
for (var
|
|
20
|
-
var
|
|
21
|
-
for (var
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
23
|
-
target[key] = source[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
13
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
14
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
15
|
+
var t = arguments[e];
|
|
16
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
26
17
|
}
|
|
27
|
-
return
|
|
28
|
-
};
|
|
29
|
-
|
|
18
|
+
return n;
|
|
19
|
+
}, _extends.apply(null, arguments);
|
|
20
|
+
}
|
|
21
|
+
function _toPrimitive(t, r) {
|
|
22
|
+
if ("object" != typeof t || !t) return t;
|
|
23
|
+
var e = t[Symbol.toPrimitive];
|
|
24
|
+
if (void 0 !== e) {
|
|
25
|
+
var i = e.call(t, r || "default");
|
|
26
|
+
if ("object" != typeof i) return i;
|
|
27
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
28
|
+
}
|
|
29
|
+
return ("string" === r ? String : Number)(t);
|
|
30
|
+
}
|
|
31
|
+
function _toPropertyKey(t) {
|
|
32
|
+
var i = _toPrimitive(t, "string");
|
|
33
|
+
return "symbol" == typeof i ? i : i + "";
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
const ThemeContext = /*#__PURE__*/createContext({
|
|
@@ -70,9 +74,10 @@ function commonjsRequire () {
|
|
|
70
74
|
var store2 = createCommonjsModule(function (module) {
|
|
71
75
|
(function (window, define) {
|
|
72
76
|
var _ = {
|
|
73
|
-
version: "2.
|
|
77
|
+
version: "2.14.4",
|
|
74
78
|
areas: {},
|
|
75
79
|
apis: {},
|
|
80
|
+
nsdelim: '.',
|
|
76
81
|
// utilities
|
|
77
82
|
inherit: function (api, o) {
|
|
78
83
|
for (var p in api) {
|
|
@@ -82,8 +87,8 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
82
87
|
}
|
|
83
88
|
return o;
|
|
84
89
|
},
|
|
85
|
-
stringify: function (d) {
|
|
86
|
-
return d === undefined || typeof d === "function" ? d + '' : JSON.stringify(d);
|
|
90
|
+
stringify: function (d, fn) {
|
|
91
|
+
return d === undefined || typeof d === "function" ? d + '' : JSON.stringify(d, fn || _.replace);
|
|
87
92
|
},
|
|
88
93
|
parse: function (s, fn) {
|
|
89
94
|
// if it doesn't parse, return as is
|
|
@@ -171,14 +176,16 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
171
176
|
}
|
|
172
177
|
return store;
|
|
173
178
|
},
|
|
174
|
-
namespace: function (namespace, singleArea) {
|
|
179
|
+
namespace: function (namespace, singleArea, delim) {
|
|
180
|
+
delim = delim || this._delim || _.nsdelim;
|
|
175
181
|
if (!namespace) {
|
|
176
|
-
return this._ns ? this._ns.substring(0, this._ns.length -
|
|
182
|
+
return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : '';
|
|
177
183
|
}
|
|
178
184
|
var ns = namespace,
|
|
179
185
|
store = this[ns];
|
|
180
186
|
if (!store || !store.namespace) {
|
|
181
|
-
store = _.Store(this._id, this._area, this._ns + ns +
|
|
187
|
+
store = _.Store(this._id, this._area, this._ns + ns + delim); //new namespaced api
|
|
188
|
+
store._delim = delim;
|
|
182
189
|
if (!this[ns]) {
|
|
183
190
|
this[ns] = store;
|
|
184
191
|
}
|
|
@@ -190,7 +197,13 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
190
197
|
}
|
|
191
198
|
return store;
|
|
192
199
|
},
|
|
193
|
-
isFake: function () {
|
|
200
|
+
isFake: function (force) {
|
|
201
|
+
if (force) {
|
|
202
|
+
this._real = this._area;
|
|
203
|
+
this._area = _.storage('fake');
|
|
204
|
+
} else if (force === false) {
|
|
205
|
+
this._area = this._real || this._area;
|
|
206
|
+
}
|
|
194
207
|
return this._area.name === 'fake';
|
|
195
208
|
},
|
|
196
209
|
toString: function () {
|
|
@@ -248,11 +261,16 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
248
261
|
return this;
|
|
249
262
|
},
|
|
250
263
|
set: function (key, data, overwrite) {
|
|
251
|
-
var d = this.get(key)
|
|
264
|
+
var d = this.get(key),
|
|
265
|
+
replacer;
|
|
252
266
|
if (d != null && overwrite === false) {
|
|
253
267
|
return data;
|
|
254
268
|
}
|
|
255
|
-
|
|
269
|
+
if (typeof overwrite === "function") {
|
|
270
|
+
replacer = overwrite;
|
|
271
|
+
overwrite = undefined;
|
|
272
|
+
}
|
|
273
|
+
return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
|
|
256
274
|
},
|
|
257
275
|
setAll: function (data, overwrite) {
|
|
258
276
|
var changed, val;
|
|
@@ -264,7 +282,7 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
264
282
|
}
|
|
265
283
|
return changed;
|
|
266
284
|
},
|
|
267
|
-
add: function (key, data) {
|
|
285
|
+
add: function (key, data, replacer) {
|
|
268
286
|
var d = this.get(key);
|
|
269
287
|
if (d instanceof Array) {
|
|
270
288
|
data = d.concat(data);
|
|
@@ -279,7 +297,7 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
279
297
|
data = d + data;
|
|
280
298
|
}
|
|
281
299
|
}
|
|
282
|
-
_.set(this._area, this._in(key), _.stringify(data));
|
|
300
|
+
_.set(this._area, this._in(key), _.stringify(data, replacer));
|
|
283
301
|
return data;
|
|
284
302
|
},
|
|
285
303
|
remove: function (key, alt) {
|
|
@@ -5566,6 +5584,19 @@ const useDisclosure = (initialState = false) => {
|
|
|
5566
5584
|
};
|
|
5567
5585
|
};
|
|
5568
5586
|
|
|
5587
|
+
const cleanShapes = shapes => {
|
|
5588
|
+
try {
|
|
5589
|
+
// Iterate over each shape and remove the ']' character from the dest string
|
|
5590
|
+
shapes.forEach(shape => {
|
|
5591
|
+
// Use a regular expression to remove all occurrences of ']'
|
|
5592
|
+
shape.dest = shape.dest.replace(/\]/g, '');
|
|
5593
|
+
});
|
|
5594
|
+
return shapes;
|
|
5595
|
+
} catch {
|
|
5596
|
+
return shapes;
|
|
5597
|
+
}
|
|
5598
|
+
};
|
|
5599
|
+
|
|
5569
5600
|
const cgProps = props => {
|
|
5570
5601
|
const cgProps = {};
|
|
5571
5602
|
|
|
@@ -5593,6 +5624,11 @@ const cgProps = props => {
|
|
|
5593
5624
|
};
|
|
5594
5625
|
}
|
|
5595
5626
|
|
|
5627
|
+
// fix shapes
|
|
5628
|
+
if (cgProps.shapes) {
|
|
5629
|
+
cgProps.shapes = cleanShapes(cgProps.shapes);
|
|
5630
|
+
}
|
|
5631
|
+
|
|
5596
5632
|
// helper for Chessground editing mode
|
|
5597
5633
|
if (props.editing) {
|
|
5598
5634
|
cgProps.movable = {
|
|
@@ -6125,12 +6161,12 @@ const NextEditor = (props, ref) => {
|
|
|
6125
6161
|
var NextEditor$1 = /*#__PURE__*/forwardRef(NextEditor);
|
|
6126
6162
|
|
|
6127
6163
|
class Stockfish {
|
|
6128
|
-
constructor() {
|
|
6164
|
+
constructor(path) {
|
|
6129
6165
|
if (typeof window === 'undefined') {
|
|
6130
6166
|
return false;
|
|
6131
6167
|
}
|
|
6132
6168
|
if (!window.chessEngineWorker) {
|
|
6133
|
-
const worker = process.env.STOCKFISH_PATH;
|
|
6169
|
+
const worker = path ?? process.env.STOCKFISH_PATH;
|
|
6134
6170
|
window.chessEngineWorker = new Worker(worker);
|
|
6135
6171
|
}
|
|
6136
6172
|
this.skillLevel = 20;
|
package/dist/index.js
CHANGED
|
@@ -10,32 +10,36 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
11
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
12
12
|
|
|
13
|
-
function _defineProperty(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
} else {
|
|
22
|
-
obj[key] = value;
|
|
23
|
-
}
|
|
24
|
-
return obj;
|
|
13
|
+
function _defineProperty(e, r, t) {
|
|
14
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
15
|
+
value: t,
|
|
16
|
+
enumerable: !0,
|
|
17
|
+
configurable: !0,
|
|
18
|
+
writable: !0
|
|
19
|
+
}) : e[r] = t, e;
|
|
25
20
|
}
|
|
26
21
|
function _extends() {
|
|
27
|
-
_extends = Object.assign
|
|
28
|
-
for (var
|
|
29
|
-
var
|
|
30
|
-
for (var
|
|
31
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
32
|
-
target[key] = source[key];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
22
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
23
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
24
|
+
var t = arguments[e];
|
|
25
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
35
26
|
}
|
|
36
|
-
return
|
|
37
|
-
};
|
|
38
|
-
|
|
27
|
+
return n;
|
|
28
|
+
}, _extends.apply(null, arguments);
|
|
29
|
+
}
|
|
30
|
+
function _toPrimitive(t, r) {
|
|
31
|
+
if ("object" != typeof t || !t) return t;
|
|
32
|
+
var e = t[Symbol.toPrimitive];
|
|
33
|
+
if (void 0 !== e) {
|
|
34
|
+
var i = e.call(t, r || "default");
|
|
35
|
+
if ("object" != typeof i) return i;
|
|
36
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
37
|
+
}
|
|
38
|
+
return ("string" === r ? String : Number)(t);
|
|
39
|
+
}
|
|
40
|
+
function _toPropertyKey(t) {
|
|
41
|
+
var i = _toPrimitive(t, "string");
|
|
42
|
+
return "symbol" == typeof i ? i : i + "";
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
const ThemeContext = /*#__PURE__*/React.createContext({
|
|
@@ -79,9 +83,10 @@ function commonjsRequire () {
|
|
|
79
83
|
var store2 = createCommonjsModule(function (module) {
|
|
80
84
|
(function (window, define) {
|
|
81
85
|
var _ = {
|
|
82
|
-
version: "2.
|
|
86
|
+
version: "2.14.4",
|
|
83
87
|
areas: {},
|
|
84
88
|
apis: {},
|
|
89
|
+
nsdelim: '.',
|
|
85
90
|
// utilities
|
|
86
91
|
inherit: function (api, o) {
|
|
87
92
|
for (var p in api) {
|
|
@@ -91,8 +96,8 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
91
96
|
}
|
|
92
97
|
return o;
|
|
93
98
|
},
|
|
94
|
-
stringify: function (d) {
|
|
95
|
-
return d === undefined || typeof d === "function" ? d + '' : JSON.stringify(d);
|
|
99
|
+
stringify: function (d, fn) {
|
|
100
|
+
return d === undefined || typeof d === "function" ? d + '' : JSON.stringify(d, fn || _.replace);
|
|
96
101
|
},
|
|
97
102
|
parse: function (s, fn) {
|
|
98
103
|
// if it doesn't parse, return as is
|
|
@@ -180,14 +185,16 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
180
185
|
}
|
|
181
186
|
return store;
|
|
182
187
|
},
|
|
183
|
-
namespace: function (namespace, singleArea) {
|
|
188
|
+
namespace: function (namespace, singleArea, delim) {
|
|
189
|
+
delim = delim || this._delim || _.nsdelim;
|
|
184
190
|
if (!namespace) {
|
|
185
|
-
return this._ns ? this._ns.substring(0, this._ns.length -
|
|
191
|
+
return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : '';
|
|
186
192
|
}
|
|
187
193
|
var ns = namespace,
|
|
188
194
|
store = this[ns];
|
|
189
195
|
if (!store || !store.namespace) {
|
|
190
|
-
store = _.Store(this._id, this._area, this._ns + ns +
|
|
196
|
+
store = _.Store(this._id, this._area, this._ns + ns + delim); //new namespaced api
|
|
197
|
+
store._delim = delim;
|
|
191
198
|
if (!this[ns]) {
|
|
192
199
|
this[ns] = store;
|
|
193
200
|
}
|
|
@@ -199,7 +206,13 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
199
206
|
}
|
|
200
207
|
return store;
|
|
201
208
|
},
|
|
202
|
-
isFake: function () {
|
|
209
|
+
isFake: function (force) {
|
|
210
|
+
if (force) {
|
|
211
|
+
this._real = this._area;
|
|
212
|
+
this._area = _.storage('fake');
|
|
213
|
+
} else if (force === false) {
|
|
214
|
+
this._area = this._real || this._area;
|
|
215
|
+
}
|
|
203
216
|
return this._area.name === 'fake';
|
|
204
217
|
},
|
|
205
218
|
toString: function () {
|
|
@@ -257,11 +270,16 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
257
270
|
return this;
|
|
258
271
|
},
|
|
259
272
|
set: function (key, data, overwrite) {
|
|
260
|
-
var d = this.get(key)
|
|
273
|
+
var d = this.get(key),
|
|
274
|
+
replacer;
|
|
261
275
|
if (d != null && overwrite === false) {
|
|
262
276
|
return data;
|
|
263
277
|
}
|
|
264
|
-
|
|
278
|
+
if (typeof overwrite === "function") {
|
|
279
|
+
replacer = overwrite;
|
|
280
|
+
overwrite = undefined;
|
|
281
|
+
}
|
|
282
|
+
return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
|
|
265
283
|
},
|
|
266
284
|
setAll: function (data, overwrite) {
|
|
267
285
|
var changed, val;
|
|
@@ -273,7 +291,7 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
273
291
|
}
|
|
274
292
|
return changed;
|
|
275
293
|
},
|
|
276
|
-
add: function (key, data) {
|
|
294
|
+
add: function (key, data, replacer) {
|
|
277
295
|
var d = this.get(key);
|
|
278
296
|
if (d instanceof Array) {
|
|
279
297
|
data = d.concat(data);
|
|
@@ -288,7 +306,7 @@ var store2 = createCommonjsModule(function (module) {
|
|
|
288
306
|
data = d + data;
|
|
289
307
|
}
|
|
290
308
|
}
|
|
291
|
-
_.set(this._area, this._in(key), _.stringify(data));
|
|
309
|
+
_.set(this._area, this._in(key), _.stringify(data, replacer));
|
|
292
310
|
return data;
|
|
293
311
|
},
|
|
294
312
|
remove: function (key, alt) {
|
|
@@ -5575,6 +5593,19 @@ const useDisclosure = (initialState = false) => {
|
|
|
5575
5593
|
};
|
|
5576
5594
|
};
|
|
5577
5595
|
|
|
5596
|
+
const cleanShapes = shapes => {
|
|
5597
|
+
try {
|
|
5598
|
+
// Iterate over each shape and remove the ']' character from the dest string
|
|
5599
|
+
shapes.forEach(shape => {
|
|
5600
|
+
// Use a regular expression to remove all occurrences of ']'
|
|
5601
|
+
shape.dest = shape.dest.replace(/\]/g, '');
|
|
5602
|
+
});
|
|
5603
|
+
return shapes;
|
|
5604
|
+
} catch {
|
|
5605
|
+
return shapes;
|
|
5606
|
+
}
|
|
5607
|
+
};
|
|
5608
|
+
|
|
5578
5609
|
const cgProps = props => {
|
|
5579
5610
|
const cgProps = {};
|
|
5580
5611
|
|
|
@@ -5602,6 +5633,11 @@ const cgProps = props => {
|
|
|
5602
5633
|
};
|
|
5603
5634
|
}
|
|
5604
5635
|
|
|
5636
|
+
// fix shapes
|
|
5637
|
+
if (cgProps.shapes) {
|
|
5638
|
+
cgProps.shapes = cleanShapes(cgProps.shapes);
|
|
5639
|
+
}
|
|
5640
|
+
|
|
5605
5641
|
// helper for Chessground editing mode
|
|
5606
5642
|
if (props.editing) {
|
|
5607
5643
|
cgProps.movable = {
|
|
@@ -6134,12 +6170,12 @@ const NextEditor = (props, ref) => {
|
|
|
6134
6170
|
var NextEditor$1 = /*#__PURE__*/React.forwardRef(NextEditor);
|
|
6135
6171
|
|
|
6136
6172
|
class Stockfish {
|
|
6137
|
-
constructor() {
|
|
6173
|
+
constructor(path) {
|
|
6138
6174
|
if (typeof window === 'undefined') {
|
|
6139
6175
|
return false;
|
|
6140
6176
|
}
|
|
6141
6177
|
if (!window.chessEngineWorker) {
|
|
6142
|
-
const worker = process.env.STOCKFISH_PATH;
|
|
6178
|
+
const worker = path ?? process.env.STOCKFISH_PATH;
|
|
6143
6179
|
window.chessEngineWorker = new Worker(worker);
|
|
6144
6180
|
}
|
|
6145
6181
|
this.skillLevel = 20;
|
package/package.json
CHANGED