hyperchess-board-ui 0.1.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.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Framework-agnostic custom element wrapping a HyperChess board.
3
+ *
4
+ * Usage: `<hyperchess-board-ui hfen="..." theme="modern"></hyperchess-board-ui>`
5
+ *
6
+ * Importing this module has a side effect: the element is registered as
7
+ * `hyperchess-board-ui` at the bottom of the file, guarded so a duplicate import
8
+ * cannot throw. Markup and styles live in an open shadow root, so page CSS does
9
+ * not leak in and the element can be styled only through its `:host` and any
10
+ * custom properties it inherits.
11
+ *
12
+ * Board rendering itself is still a placeholder; only the attribute plumbing and
13
+ * shadow-root scaffolding are implemented.
14
+ */
15
+ export declare class HyperchessBoard extends HTMLElement {
16
+ private hfen;
17
+ private theme;
18
+ private root;
19
+ /**
20
+ * Attach the shadow root. Per the custom-element spec no attributes may be
21
+ * read here, so the defaults above stand until `connectedCallback` runs.
22
+ */
23
+ constructor();
24
+ /**
25
+ * Adopt the `hfen` and `theme` attributes, if present, and paint for the first
26
+ * time. Absent or empty attributes leave the defaults in place.
27
+ */
28
+ connectedCallback(): void;
29
+ /** Attributes that trigger `attributeChangedCallback`; anything not listed
30
+ * here is inert after the element is connected. */
31
+ static get observedAttributes(): string[];
32
+ /**
33
+ * Re-render when a watched attribute changes, skipping no-op writes so that
34
+ * re-setting an attribute to its current value does not cost a repaint.
35
+ *
36
+ * @param name - Attribute that changed; one of `observedAttributes`.
37
+ * @param oldValue - Previous value, `null` if the attribute was absent.
38
+ * @param newValue - Incoming value.
39
+ */
40
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
41
+ /**
42
+ * Rebuild the shadow root's contents from scratch.
43
+ *
44
+ * Replacing `innerHTML` wholesale discards any existing nodes, so nothing may
45
+ * hold a reference to a rendered square across a render.
46
+ */
47
+ private render;
48
+ }
49
+ //# sourceMappingURL=hyperchess-board.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperchess-board.d.ts","sourceRoot":"","sources":["../../src/web-component/hyperchess-board.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,OAAO,CAAC,IAAI,CAAsG;IAClH,OAAO,CAAC,KAAK,CAAoB;IAKjC,OAAO,CAAC,IAAI,CAAa;IAEzB;;;OAGG;;IAMH;;;OAGG;IACH,iBAAiB;IAOjB;uDACmD;IACnD,MAAM,KAAK,kBAAkB,aAE5B;IAED;;;;;;;OAOG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAYzE;;;;;OAKG;IACH,OAAO,CAAC,MAAM;CA0Bf"}
@@ -0,0 +1,102 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ // HyperChess Core — hyperchess-board-ui
3
+ // File: packages/board/src/web-component/hyperchess-board-ui.ts
4
+ // Version: 1.0.0
5
+ // Copyright (c) 2026 HyperChess Developer Team
6
+ /**
7
+ * Framework-agnostic custom element wrapping a HyperChess board.
8
+ *
9
+ * Usage: `<hyperchess-board-ui hfen="..." theme="modern"></hyperchess-board-ui>`
10
+ *
11
+ * Importing this module has a side effect: the element is registered as
12
+ * `hyperchess-board-ui` at the bottom of the file, guarded so a duplicate import
13
+ * cannot throw. Markup and styles live in an open shadow root, so page CSS does
14
+ * not leak in and the element can be styled only through its `:host` and any
15
+ * custom properties it inherits.
16
+ *
17
+ * Board rendering itself is still a placeholder; only the attribute plumbing and
18
+ * shadow-root scaffolding are implemented.
19
+ */
20
+ export class HyperchessBoard extends HTMLElement {
21
+ /**
22
+ * Attach the shadow root. Per the custom-element spec no attributes may be
23
+ * read here, so the defaults above stand until `connectedCallback` runs.
24
+ */
25
+ constructor() {
26
+ super();
27
+ this.hfen = '12/abcdefghijkl/mnopqrstuvwx/12/12/12/12/12/12/MNOPQRSTUVWX/ABCDEFGHIJKL/12 w KQkq - 0 1';
28
+ this.theme = 'modern';
29
+ this.root = this.attachShadow({ mode: 'open' });
30
+ }
31
+ /**
32
+ * Adopt the `hfen` and `theme` attributes, if present, and paint for the first
33
+ * time. Absent or empty attributes leave the defaults in place.
34
+ */
35
+ connectedCallback() {
36
+ this.hfen = this.getAttribute('hfen') || this.hfen;
37
+ this.theme = this.getAttribute('theme') || this.theme;
38
+ this.render();
39
+ }
40
+ /** Attributes that trigger `attributeChangedCallback`; anything not listed
41
+ * here is inert after the element is connected. */
42
+ static get observedAttributes() {
43
+ return ['hfen', 'theme'];
44
+ }
45
+ /**
46
+ * Re-render when a watched attribute changes, skipping no-op writes so that
47
+ * re-setting an attribute to its current value does not cost a repaint.
48
+ *
49
+ * @param name - Attribute that changed; one of `observedAttributes`.
50
+ * @param oldValue - Previous value, `null` if the attribute was absent.
51
+ * @param newValue - Incoming value.
52
+ */
53
+ attributeChangedCallback(name, oldValue, newValue) {
54
+ if (oldValue === newValue)
55
+ return;
56
+ if (name === 'hfen') {
57
+ this.hfen = newValue;
58
+ this.render();
59
+ }
60
+ else if (name === 'theme') {
61
+ this.theme = newValue;
62
+ this.render();
63
+ }
64
+ }
65
+ /**
66
+ * Rebuild the shadow root's contents from scratch.
67
+ *
68
+ * Replacing `innerHTML` wholesale discards any existing nodes, so nothing may
69
+ * hold a reference to a rendered square across a render.
70
+ */
71
+ render() {
72
+ this.root.innerHTML = `
73
+ <style>
74
+ :host {
75
+ display: block;
76
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
77
+ }
78
+
79
+ .board {
80
+ display: grid;
81
+ grid-template-columns: repeat(12, 1fr);
82
+ gap: 0;
83
+ aspect-ratio: 1;
84
+ background: #f0d9b5;
85
+ border: 1px solid #999;
86
+ }
87
+ </style>
88
+
89
+ <div class="board">
90
+ <!-- Board rendering coming in Phase 3.0.4 -->
91
+ <div style="grid-column: 1 / -1; padding: 20px; text-align: center;">
92
+ Board rendering coming soon
93
+ </div>
94
+ </div>
95
+ `;
96
+ }
97
+ }
98
+ // Register the custom element
99
+ if (!customElements.get('hyperchess-board-ui')) {
100
+ customElements.define('hyperchess-board-ui', HyperchessBoard);
101
+ }
102
+ //# sourceMappingURL=hyperchess-board.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperchess-board.js","sourceRoot":"","sources":["../../src/web-component/hyperchess-board.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,wCAAwC;AACxC,gEAAgE;AAChE,iBAAiB;AACjB,+CAA+C;AAE/C;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAS9C;;;OAGG;IACH;QACE,KAAK,EAAE,CAAC;QAbF,SAAI,GAAW,0FAA0F,CAAC;QAC1G,UAAK,GAAW,QAAQ,CAAC;QAa/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACH,iBAAiB;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;QACnD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC;QAEtD,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED;uDACmD;IACnD,MAAM,KAAK,kBAAkB;QAC3B,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,wBAAwB,CAAC,IAAY,EAAE,QAAgB,EAAE,QAAgB;QACvE,IAAI,QAAQ,KAAK,QAAQ;YAAE,OAAO;QAElC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;YACrB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;aAAM,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;YACtB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACK,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;KAuBrB,CAAC;IACJ,CAAC;CACF;AAED,8BAA8B;AAC9B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC;IAC/C,cAAc,CAAC,MAAM,CAAC,qBAAqB,EAAE,eAAe,CAAC,CAAC;AAChE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "hyperchess-board-ui",
3
+ "version": "0.1.0",
4
+ "description": "HyperChess 2D board component for all frameworks",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./react": {
14
+ "import": "./dist/React/index.js",
15
+ "types": "./dist/React/index.d.ts"
16
+ },
17
+ "./vue": {
18
+ "import": "./dist/Vue/index.js",
19
+ "types": "./dist/Vue/index.d.ts"
20
+ },
21
+ "./web-component": {
22
+ "import": "./dist/web-component/index.js",
23
+ "types": "./dist/web-component/index.d.ts"
24
+ }
25
+ },
26
+ "peerDependencies": {
27
+ "react": ">=18.0.0",
28
+ "vue": ">=3.0.0"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "react": {
32
+ "optional": true
33
+ },
34
+ "vue": {
35
+ "optional": true
36
+ }
37
+ },
38
+ "dependencies": {
39
+ "hyperchess-core": "0.1.0",
40
+ "hyperchess-theme": "0.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "typescript": "^5.2.0",
44
+ "vitest": "^0.34.0"
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "README.md"
49
+ ],
50
+ "keywords": [
51
+ "hyperchess",
52
+ "chess",
53
+ "board",
54
+ "component",
55
+ "react",
56
+ "vue",
57
+ "web-component"
58
+ ],
59
+ "author": "HyperChess Contributors",
60
+ "license": "GPL-3.0-or-later",
61
+ "repository": {
62
+ "type": "git",
63
+ "url": "git+https://github.com/KyrpyDev/hyperchess-core.git",
64
+ "directory": "packages/board"
65
+ },
66
+ "homepage": "https://github.com/KyrpyDev/hyperchess-core#readme",
67
+ "bugs": {
68
+ "url": "https://github.com/KyrpyDev/hyperchess-core/issues"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ },
73
+ "engines": {
74
+ "node": ">=18"
75
+ },
76
+ "scripts": {
77
+ "build": "tsc",
78
+ "test": "vitest run",
79
+ "test:watch": "vitest"
80
+ }
81
+ }