@bedard/hexboard 0.0.1

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.
Files changed (38) hide show
  1. package/.github/workflows/build.yml +65 -0
  2. package/.github/workflows/release.yml +0 -0
  3. package/.vscode/settings.json +5 -0
  4. package/LICENSE +21 -0
  5. package/README.md +8 -0
  6. package/dist/index.d.ts +127 -0
  7. package/dist/index.js +1056 -0
  8. package/eslint.config.js +85 -0
  9. package/index.html +22 -0
  10. package/package.json +58 -0
  11. package/src/lib/components/hexboard/Hexboard.vue +865 -0
  12. package/src/lib/components/hexboard/constants.ts +389 -0
  13. package/src/lib/components/hexboard/dom.ts +19 -0
  14. package/src/lib/components/hexboard/geometry.ts +59 -0
  15. package/src/lib/components/hexboard/haptics.ts +56 -0
  16. package/src/lib/components/hexboard/pieces/Celtic.vue +22 -0
  17. package/src/lib/components/hexboard/pieces/Fantasy.vue +22 -0
  18. package/src/lib/components/hexboard/pieces/Gioco.vue +22 -0
  19. package/src/lib/components/hexboard/pieces/Spatial.vue +22 -0
  20. package/src/lib/components/hexboard/pieces/index.ts +4 -0
  21. package/src/lib/components/hexboard/types.ts +28 -0
  22. package/src/lib/index.ts +1 -0
  23. package/src/sandbox/App.vue +28 -0
  24. package/src/sandbox/components/Button.vue +8 -0
  25. package/src/sandbox/components/icons/Github.vue +3 -0
  26. package/src/sandbox/components/icons/Menu.vue +3 -0
  27. package/src/sandbox/components/icons/X.vue +3 -0
  28. package/src/sandbox/index.ts +5 -0
  29. package/src/sandbox/tailwind.css +59 -0
  30. package/src/sandbox/views/HomeToolbar.vue +80 -0
  31. package/src/tests/example.test.tsx +18 -0
  32. package/src/tests/hexboard.test.tsx +832 -0
  33. package/src/tests/utils.ts +26 -0
  34. package/tsconfig.json +30 -0
  35. package/tsconfig.node.json +10 -0
  36. package/vite.config.ts +42 -0
  37. package/vite.sandbox.config.ts +21 -0
  38. package/vitest.config.ts +35 -0
@@ -0,0 +1,65 @@
1
+ name: Build
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup pnpm
18
+ uses: pnpm/action-setup@v4
19
+ with:
20
+ version: latest
21
+
22
+ - name: Setup Node.js
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: 22
26
+ cache: pnpm
27
+
28
+ - name: Install dependencies
29
+ run: pnpm install --frozen-lockfile
30
+
31
+ - name: Lint
32
+ run: pnpm lint
33
+
34
+ - name: Build library
35
+ run: pnpm build
36
+
37
+ - name: Build sandbox
38
+ run: pnpm build:sandbox
39
+
40
+ test:
41
+ name: ${{ matrix.browser }}
42
+ runs-on: ubuntu-latest
43
+ strategy:
44
+ matrix:
45
+ browser: [chromium, firefox, webkit]
46
+ steps:
47
+ - name: Checkout
48
+ uses: actions/checkout@v4
49
+ - name: Setup pnpm
50
+ uses: pnpm/action-setup@v4
51
+ with:
52
+ version: latest
53
+ - name: Setup Node.js
54
+ uses: actions/setup-node@v4
55
+ with:
56
+ node-version: 22
57
+ cache: pnpm
58
+ - name: Install dependencies
59
+ run: pnpm install --frozen-lockfile
60
+ - name: Install Playwright browsers
61
+ run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
62
+ - name: Test
63
+ env:
64
+ VITEST_BROWSER: ${{ matrix.browser }}
65
+ run: pnpm test
File without changes
@@ -0,0 +1,5 @@
1
+ {
2
+ "editor.codeActionsOnSave": {
3
+ "source.fixAll.eslint": "explicit"
4
+ }
5
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025-present, Scott Bedard.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # `<Hexboard />`
2
+
3
+ [![Build](https://github.com/scottbedard/hexboard/actions/workflows/build.yml/badge.svg)](https://github.com/scottbedard/hexboard/actions/workflows/build.yml)
4
+ [![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/scottbedard/hexboard/blob/main/LICENSE)
5
+
6
+ User interfaces for [hexchess.club](https://hexchess.club).
7
+
8
+ [Visit sandbox &rarr;](https://hexboard.vercel.app/)
@@ -0,0 +1,127 @@
1
+ import { Color } from '@bedard/hexchess';
2
+ import { Component } from 'vue';
3
+ import { ComponentOptionsMixin } from 'vue';
4
+ import { ComponentProvideOptions } from 'vue';
5
+ import { DefineComponent } from 'vue';
6
+ import { Hexchess } from '@bedard/hexchess';
7
+ import { PublicProps } from 'vue';
8
+ import { RendererElement } from 'vue';
9
+ import { RendererNode } from 'vue';
10
+ import { San } from '@bedard/hexchess';
11
+ import { VNode } from 'vue';
12
+
13
+ declare const __VLS_component: DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
14
+ clickPosition: (position: number) => any;
15
+ move: (san: San) => any;
16
+ "update:mouseover-position": (value: number | null) => any;
17
+ "update:selected": (value: number | null) => any;
18
+ "update:targets": (value: number[]) => any;
19
+ }, string, PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
+ onClickPosition?: ((position: number) => any) | undefined;
21
+ onMove?: ((san: San) => any) | undefined;
22
+ "onUpdate:mouseover-position"?: ((value: number | null) => any) | undefined;
23
+ "onUpdate:selected"?: ((value: number | null) => any) | undefined;
24
+ "onUpdate:targets"?: ((value: number[]) => any) | undefined;
25
+ }>, {
26
+ active: boolean;
27
+ autoselect: boolean;
28
+ flipped: boolean;
29
+ hexchess: Hexchess;
30
+ highlight: number[];
31
+ ignoreTurn: boolean;
32
+ options: Partial<HexboardOptions>;
33
+ pieces: Component;
34
+ playing: Color | boolean;
35
+ position: string;
36
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
37
+ svgEl: SVGSVGElement;
38
+ selectedEl: SVGPathElement;
39
+ }, HTMLDivElement>;
40
+
41
+ declare type __VLS_Props = {
42
+ active?: boolean;
43
+ autoselect?: boolean;
44
+ flipped?: boolean;
45
+ hexchess?: Hexchess;
46
+ highlight?: number[];
47
+ ignoreTurn?: boolean;
48
+ options?: Partial<HexboardOptions>;
49
+ pieces?: Component;
50
+ playing?: Color | boolean;
51
+ position?: string;
52
+ };
53
+
54
+ declare type __VLS_PublicProps = {
55
+ 'mouseover-position'?: number | null;
56
+ 'selected'?: number | null;
57
+ 'targets'?: number[];
58
+ } & __VLS_Props;
59
+
60
+ declare function __VLS_template(): {
61
+ attrs: Partial<{}>;
62
+ slots: {
63
+ promotion?(_: {
64
+ b: (attrs: Record<string, unknown>) => VNode<RendererNode, RendererElement, {
65
+ [key: string]: any;
66
+ }>;
67
+ cancel: typeof cancelPromotion;
68
+ file: string;
69
+ n: (attrs: Record<string, unknown>) => VNode<RendererNode, RendererElement, {
70
+ [key: string]: any;
71
+ }>;
72
+ promote: typeof promote;
73
+ q: (attrs: Record<string, unknown>) => VNode<RendererNode, RendererElement, {
74
+ [key: string]: any;
75
+ }>;
76
+ r: (attrs: Record<string, unknown>) => VNode<RendererNode, RendererElement, {
77
+ [key: string]: any;
78
+ }>;
79
+ rank: number;
80
+ }): any;
81
+ };
82
+ refs: {
83
+ svgEl: SVGSVGElement;
84
+ selectedEl: SVGPathElement;
85
+ };
86
+ rootEl: HTMLDivElement;
87
+ };
88
+
89
+ declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
90
+
91
+ declare type __VLS_WithTemplateSlots<T, S> = T & {
92
+ new (): {
93
+ $slots: S;
94
+ };
95
+ };
96
+
97
+ /** cancel promotion and restore original selection */
98
+ declare function cancelPromotion(): void;
99
+
100
+ export declare const Hexboard: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
101
+
102
+ /** hexboard options */
103
+ declare interface HexboardOptions {
104
+ /** position colors */
105
+ colors: [string, string, string];
106
+ /** haptic feedback vibrations */
107
+ haptics: boolean;
108
+ /** color of highlighted position */
109
+ highlightColor: string;
110
+ /** color of active label relative to mouseover */
111
+ labelActiveColor: string;
112
+ /** label color */
113
+ labelColor: string;
114
+ /** fill color of inactive label relative to mouseover */
115
+ labelInactiveColor: string;
116
+ /** show labels */
117
+ labels: boolean;
118
+ /** color of target circles */
119
+ targetColor: string;
120
+ /** color of selected position */
121
+ selectedColor: string;
122
+ }
123
+
124
+ /** promote piece */
125
+ declare function promote(promotion: 'n' | 'b' | 'r' | 'q'): void;
126
+
127
+ export { }