@mborecki/crossword 0.0.2
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/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/index-CwHIXXW5.js +61 -0
- package/dist/cjs/index-TyGpRn4d.js +3159 -0
- package/dist/cjs/index.cjs.js +9 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/mb-crossword.cjs.entry.js +323 -0
- package/dist/cjs/mb-crossword.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/crossword/cell.js +8 -0
- package/dist/collection/components/crossword/clue.js +6 -0
- package/dist/collection/components/crossword/mb-crossword.css +57 -0
- package/dist/collection/components/crossword/mb-crossword.js +405 -0
- package/dist/collection/components/crossword/types.js +1 -0
- package/dist/collection/index.js +10 -0
- package/dist/collection/utils/utils.js +15 -0
- package/dist/collection/utils/utils.test.js +52 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/mb-crossword.d.ts +11 -0
- package/dist/components/mb-crossword.js +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/index-0i8AYf_G.js +56 -0
- package/dist/esm/index-B4XIBYtu.js +3152 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/mb-crossword.entry.js +321 -0
- package/dist/esm/mb-crossword.js +21 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/mb-crossword/index.esm.js +1 -0
- package/dist/mb-crossword/mb-crossword.esm.js +1 -0
- package/dist/mb-crossword/p-0i8AYf_G.js +1 -0
- package/dist/mb-crossword/p-5b227b8e.entry.js +1 -0
- package/dist/mb-crossword/p-B4XIBYtu.js +2 -0
- package/dist/mb-crossword/p-DQuL1Twl.js +1 -0
- package/dist/types/components/crossword/cell.d.ts +7 -0
- package/dist/types/components/crossword/clue.d.ts +7 -0
- package/dist/types/components/crossword/mb-crossword.d.ts +40 -0
- package/dist/types/components/crossword/types.d.ts +20 -0
- package/dist/types/components.d.ts +50 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/roboczy/mb-puzzle/apps/crossword/.stencil/apps/crossword/vitest.config.d.ts +2 -0
- package/dist/types/roboczy/mb-puzzle/apps/crossword/.stencil/shared/vec2/src/vec2.d.ts +17 -0
- package/dist/types/roboczy/mb-puzzle/apps/crossword/.stencil/shared/vec2/src/vec2.test.d.ts +1 -0
- package/dist/types/roboczy/mb-puzzle/apps/crossword/.stencil/shared/vec2/vitest.config.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +1839 -0
- package/dist/types/utils/utils.d.ts +4 -0
- package/dist/types/utils/utils.test.d.ts +1 -0
- package/dist/vitest.config.js +4 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +53 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class Vec2 {
|
|
4
|
+
x;
|
|
5
|
+
y;
|
|
6
|
+
get 0() {
|
|
7
|
+
return this.x;
|
|
8
|
+
}
|
|
9
|
+
set 0(x) {
|
|
10
|
+
this.x = x;
|
|
11
|
+
}
|
|
12
|
+
get 1() {
|
|
13
|
+
return this.y;
|
|
14
|
+
}
|
|
15
|
+
set 1(y) {
|
|
16
|
+
this.y = y;
|
|
17
|
+
}
|
|
18
|
+
get xy() {
|
|
19
|
+
return [this.x, this.y];
|
|
20
|
+
}
|
|
21
|
+
*[Symbol.iterator]() {
|
|
22
|
+
yield this.x;
|
|
23
|
+
yield this.y;
|
|
24
|
+
}
|
|
25
|
+
constructor(x, y) {
|
|
26
|
+
this.x = x;
|
|
27
|
+
this.y = y;
|
|
28
|
+
}
|
|
29
|
+
static from(source) {
|
|
30
|
+
if (typeof source === 'number') {
|
|
31
|
+
return new Vec2(source, source);
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(source)) {
|
|
34
|
+
return new Vec2(source[0], source[1]);
|
|
35
|
+
}
|
|
36
|
+
if (typeof source === 'object' && typeof source.x === 'number' && typeof source.y === 'number') {
|
|
37
|
+
return new Vec2(source.x, source.y);
|
|
38
|
+
}
|
|
39
|
+
throw new Error('Wrong Vec2 source');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Vec2fromIndex(index, width) {
|
|
44
|
+
const x = index % width;
|
|
45
|
+
const y = Math.floor(index / width);
|
|
46
|
+
return new Vec2(x, y);
|
|
47
|
+
}
|
|
48
|
+
function indexFromXY(v, width) {
|
|
49
|
+
return v.y * width + v.x;
|
|
50
|
+
}
|
|
51
|
+
function isKeyboardEventLetter(event) {
|
|
52
|
+
if (event.key.length !== 1)
|
|
53
|
+
return false;
|
|
54
|
+
const key = event.key.toLowerCase();
|
|
55
|
+
return /[0-9a-zA-Z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u024F]/.test(key);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.Vec2 = Vec2;
|
|
59
|
+
exports.Vec2fromIndex = Vec2fromIndex;
|
|
60
|
+
exports.indexFromXY = indexFromXY;
|
|
61
|
+
exports.isKeyboardEventLetter = isKeyboardEventLetter;
|