@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.
- package/.github/workflows/build.yml +65 -0
- package/.github/workflows/release.yml +0 -0
- package/.vscode/settings.json +5 -0
- package/LICENSE +21 -0
- package/README.md +8 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.js +1056 -0
- package/eslint.config.js +85 -0
- package/index.html +22 -0
- package/package.json +58 -0
- package/src/lib/components/hexboard/Hexboard.vue +865 -0
- package/src/lib/components/hexboard/constants.ts +389 -0
- package/src/lib/components/hexboard/dom.ts +19 -0
- package/src/lib/components/hexboard/geometry.ts +59 -0
- package/src/lib/components/hexboard/haptics.ts +56 -0
- package/src/lib/components/hexboard/pieces/Celtic.vue +22 -0
- package/src/lib/components/hexboard/pieces/Fantasy.vue +22 -0
- package/src/lib/components/hexboard/pieces/Gioco.vue +22 -0
- package/src/lib/components/hexboard/pieces/Spatial.vue +22 -0
- package/src/lib/components/hexboard/pieces/index.ts +4 -0
- package/src/lib/components/hexboard/types.ts +28 -0
- package/src/lib/index.ts +1 -0
- package/src/sandbox/App.vue +28 -0
- package/src/sandbox/components/Button.vue +8 -0
- package/src/sandbox/components/icons/Github.vue +3 -0
- package/src/sandbox/components/icons/Menu.vue +3 -0
- package/src/sandbox/components/icons/X.vue +3 -0
- package/src/sandbox/index.ts +5 -0
- package/src/sandbox/tailwind.css +59 -0
- package/src/sandbox/views/HomeToolbar.vue +80 -0
- package/src/tests/example.test.tsx +18 -0
- package/src/tests/hexboard.test.tsx +832 -0
- package/src/tests/utils.ts +26 -0
- package/tsconfig.json +30 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +42 -0
- package/vite.sandbox.config.ts +21 -0
- package/vitest.config.ts +35 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { position } from '@bedard/hexchess'
|
|
2
|
+
import { San } from '@bedard/hexchess'
|
|
3
|
+
import type { BrowserPage } from 'vitest/browser'
|
|
4
|
+
import { render } from 'vitest-browser-vue'
|
|
5
|
+
import { nextTick } from 'vue'
|
|
6
|
+
|
|
7
|
+
/** make a move on the hexboard */
|
|
8
|
+
export async function makeMove(
|
|
9
|
+
page: BrowserPage,
|
|
10
|
+
...sans: string[]
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
for (const str of sans) {
|
|
13
|
+
const san = San.from(str)
|
|
14
|
+
|
|
15
|
+
await page.getByTestId(`position-${position(san.from)}`).click()
|
|
16
|
+
await nextTick()
|
|
17
|
+
|
|
18
|
+
await page.getByTestId(`position-${position(san.to)}`).click()
|
|
19
|
+
await nextTick()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** setup a component */
|
|
24
|
+
export function setup(setup: () => any): ReturnType<typeof render> {
|
|
25
|
+
return render({ setup })
|
|
26
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"paths": {
|
|
5
|
+
"lib/*": ["src/lib/*"],
|
|
6
|
+
"sandbox/*": ["src/sandbox/*"]
|
|
7
|
+
},
|
|
8
|
+
"allowImportingTsExtensions": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"jsx": "preserve",
|
|
13
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
14
|
+
"module": "ESNext",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": true,
|
|
20
|
+
"outDir": "dist",
|
|
21
|
+
"resolveJsonModule": true,
|
|
22
|
+
"rootDir": "src",
|
|
23
|
+
"skipLibCheck": true,
|
|
24
|
+
"strict": true,
|
|
25
|
+
"target": "ES2020",
|
|
26
|
+
"useDefineForClassFields": true
|
|
27
|
+
},
|
|
28
|
+
"include": ["src"],
|
|
29
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
30
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
|
|
4
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
5
|
+
import vue from '@vitejs/plugin-vue'
|
|
6
|
+
import { defineConfig } from 'vite'
|
|
7
|
+
import dts from 'vite-plugin-dts'
|
|
8
|
+
|
|
9
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
10
|
+
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
build: {
|
|
13
|
+
lib: {
|
|
14
|
+
entry: resolve(__dirname, 'src/lib/index.ts'),
|
|
15
|
+
fileName: 'index',
|
|
16
|
+
formats: ['es'],
|
|
17
|
+
name: '@bedard/hexboard',
|
|
18
|
+
},
|
|
19
|
+
rollupOptions: {
|
|
20
|
+
external: ['@bedard/hexchess', 'vue'],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
plugins: [
|
|
24
|
+
dts({
|
|
25
|
+
include: ['src/**/*'],
|
|
26
|
+
outDir: 'dist',
|
|
27
|
+
rollupTypes: true,
|
|
28
|
+
}),
|
|
29
|
+
tailwindcss(),
|
|
30
|
+
vue(),
|
|
31
|
+
],
|
|
32
|
+
resolve: {
|
|
33
|
+
alias: {
|
|
34
|
+
lib: resolve(__dirname, 'src/lib'),
|
|
35
|
+
sandbox: resolve(__dirname, 'src/sandbox'),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
server: {
|
|
39
|
+
open: true,
|
|
40
|
+
port: 3000,
|
|
41
|
+
},
|
|
42
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
|
|
4
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
5
|
+
import vue from '@vitejs/plugin-vue'
|
|
6
|
+
import { defineConfig } from 'vite'
|
|
7
|
+
|
|
8
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
build: {
|
|
12
|
+
outDir: 'dist-sandbox',
|
|
13
|
+
},
|
|
14
|
+
plugins: [tailwindcss(), vue()],
|
|
15
|
+
resolve: {
|
|
16
|
+
alias: {
|
|
17
|
+
lib: resolve(__dirname, 'src/lib'),
|
|
18
|
+
sandbox: resolve(__dirname, 'src/sandbox'),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
|
|
4
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
5
|
+
import vue from '@vitejs/plugin-vue'
|
|
6
|
+
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
7
|
+
import { playwright } from '@vitest/browser-playwright'
|
|
8
|
+
import { defineConfig } from 'vitest/config'
|
|
9
|
+
|
|
10
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
11
|
+
|
|
12
|
+
// Get browser from environment variable, default to chromium
|
|
13
|
+
const browser = (process.env.VITEST_BROWSER || 'chromium') as
|
|
14
|
+
| 'chromium'
|
|
15
|
+
| 'firefox'
|
|
16
|
+
| 'webkit'
|
|
17
|
+
|
|
18
|
+
export default defineConfig({
|
|
19
|
+
plugins: [tailwindcss(), vue(), vueJsx()],
|
|
20
|
+
test: {
|
|
21
|
+
browser: {
|
|
22
|
+
provider: playwright(),
|
|
23
|
+
enabled: true,
|
|
24
|
+
instances: [{ browser }],
|
|
25
|
+
},
|
|
26
|
+
environment: 'jsdom',
|
|
27
|
+
testTimeout: 3000,
|
|
28
|
+
},
|
|
29
|
+
resolve: {
|
|
30
|
+
alias: {
|
|
31
|
+
lib: resolve(__dirname, 'src/lib'),
|
|
32
|
+
sandbox: resolve(__dirname, 'src/sandbox'),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
})
|