@joystyk/cards-ui 0.0.0-stage → 0.2.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.
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/NOTICE +36 -0
- package/README.md +32 -2
- package/dist/controller.d.ts +110 -0
- package/dist/controller.js +449 -0
- package/dist/controller.js.map +1 -0
- package/dist/face-styles.d.ts +1 -0
- package/dist/face-styles.js +106 -0
- package/dist/face-styles.js.map +1 -0
- package/dist/faces.d.ts +11 -0
- package/dist/faces.js +403 -0
- package/dist/faces.js.map +1 -0
- package/dist/hand-styles.d.ts +1 -0
- package/dist/hand-styles.js +121 -0
- package/dist/hand-styles.js.map +1 -0
- package/dist/hand.d.ts +100 -0
- package/dist/hand.js +480 -0
- package/dist/hand.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/layout.d.ts +122 -0
- package/dist/layout.js +35 -0
- package/dist/layout.js.map +1 -0
- package/dist/solitaire.d.ts +155 -0
- package/dist/solitaire.js +1508 -0
- package/dist/solitaire.js.map +1 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.js +452 -0
- package/dist/styles.js.map +1 -0
- package/dist/table.d.ts +28 -0
- package/dist/table.js +629 -0
- package/dist/table.js.map +1 -0
- package/dist/tiles.d.ts +3 -0
- package/dist/tiles.js +157 -0
- package/dist/tiles.js.map +1 -0
- package/dist/worker-setup.d.ts +7 -0
- package/dist/worker-setup.js +45 -0
- package/dist/worker-setup.js.map +1 -0
- package/package.json +67 -3
package/dist/tiles.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import "@gyral/core";
|
|
2
|
+
import { compiled, compiledSvg } from "@gyral/core/compiled";
|
|
3
|
+
import { tileName } from "@joystyk/kit/tiles";
|
|
4
|
+
//#region src/tiles.ts
|
|
5
|
+
var _gyral$t0 = {
|
|
6
|
+
"id": "ihzfmgdi6r",
|
|
7
|
+
"html": "<g><!----></g>",
|
|
8
|
+
"parts": [[
|
|
9
|
+
2,
|
|
10
|
+
[0],
|
|
11
|
+
0
|
|
12
|
+
], [0, [0]]],
|
|
13
|
+
"svg": true,
|
|
14
|
+
"segments": [
|
|
15
|
+
"<g>",
|
|
16
|
+
{
|
|
17
|
+
"k": "child",
|
|
18
|
+
"in": "g",
|
|
19
|
+
"svg": true
|
|
20
|
+
},
|
|
21
|
+
"<!---->",
|
|
22
|
+
{
|
|
23
|
+
"k": "child",
|
|
24
|
+
"in": "g",
|
|
25
|
+
"svg": true
|
|
26
|
+
},
|
|
27
|
+
"</g>"
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
var _gyral$t1 = {
|
|
31
|
+
"id": "16cs87es1ze",
|
|
32
|
+
"html": "<circle r=\"3.1\" fill=\"#25251f\"/>",
|
|
33
|
+
"parts": [[
|
|
34
|
+
3,
|
|
35
|
+
[0],
|
|
36
|
+
"cx"
|
|
37
|
+
], [
|
|
38
|
+
3,
|
|
39
|
+
[0],
|
|
40
|
+
"cy"
|
|
41
|
+
]],
|
|
42
|
+
"svg": true,
|
|
43
|
+
"segments": [
|
|
44
|
+
"<circle r=\"3.1\" fill=\"#25251f\"",
|
|
45
|
+
{
|
|
46
|
+
"k": "attr",
|
|
47
|
+
"name": "cx"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"k": "attr",
|
|
51
|
+
"name": "cy"
|
|
52
|
+
},
|
|
53
|
+
"/>"
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
var _gyral$t2 = {
|
|
57
|
+
"id": "27i9zkfukhm",
|
|
58
|
+
"html": "<text x=\"3\" fill=\"#25251f\" font-size=\"8\" font-family=\"system-ui\"></text>",
|
|
59
|
+
"parts": [[
|
|
60
|
+
3,
|
|
61
|
+
[0],
|
|
62
|
+
"y"
|
|
63
|
+
], [1, [0]]],
|
|
64
|
+
"svg": true,
|
|
65
|
+
"segments": [
|
|
66
|
+
"<text x=\"3\" fill=\"#25251f\" font-size=\"8\" font-family=\"system-ui\"",
|
|
67
|
+
{
|
|
68
|
+
"k": "attr",
|
|
69
|
+
"name": "y"
|
|
70
|
+
},
|
|
71
|
+
">",
|
|
72
|
+
{
|
|
73
|
+
"k": "child",
|
|
74
|
+
"in": "text",
|
|
75
|
+
"svg": true
|
|
76
|
+
},
|
|
77
|
+
"</text>"
|
|
78
|
+
]
|
|
79
|
+
};
|
|
80
|
+
var _gyral$t3 = {
|
|
81
|
+
"id": "2zzmg40rk0",
|
|
82
|
+
"html": "<svg viewBox=\"0 0 40 80\" role=\"img\" width=\"100%\" height=\"100%\"><rect x=\"1\" y=\"1\" width=\"38\" height=\"78\" rx=\"4\" fill=\"#f6efd9\" stroke=\"#454438\" stroke-width=\"2\"/><path d=\"M4 40H36\" stroke=\"#454438\"/><circle cx=\"20\" cy=\"40\" r=\"1.5\" fill=\"#80703d\"/><!----></svg>",
|
|
83
|
+
"parts": [
|
|
84
|
+
[
|
|
85
|
+
3,
|
|
86
|
+
[0],
|
|
87
|
+
"aria-label"
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
2,
|
|
91
|
+
[0],
|
|
92
|
+
3
|
|
93
|
+
],
|
|
94
|
+
[0, [0]]
|
|
95
|
+
],
|
|
96
|
+
"segments": [
|
|
97
|
+
"<svg viewBox=\"0 0 40 80\" role=\"img\" width=\"100%\" height=\"100%\"",
|
|
98
|
+
{
|
|
99
|
+
"k": "attr",
|
|
100
|
+
"name": "aria-label"
|
|
101
|
+
},
|
|
102
|
+
"><rect x=\"1\" y=\"1\" width=\"38\" height=\"78\" rx=\"4\" fill=\"#f6efd9\" stroke=\"#454438\" stroke-width=\"2\"/><path d=\"M4 40H36\" stroke=\"#454438\"/><circle cx=\"20\" cy=\"40\" r=\"1.5\" fill=\"#80703d\"/>",
|
|
103
|
+
{
|
|
104
|
+
"k": "child",
|
|
105
|
+
"in": "svg",
|
|
106
|
+
"svg": true
|
|
107
|
+
},
|
|
108
|
+
"<!---->",
|
|
109
|
+
{
|
|
110
|
+
"k": "child",
|
|
111
|
+
"in": "svg",
|
|
112
|
+
"svg": true
|
|
113
|
+
},
|
|
114
|
+
"</svg>"
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
var spots = [
|
|
118
|
+
[],
|
|
119
|
+
[4],
|
|
120
|
+
[0, 8],
|
|
121
|
+
[
|
|
122
|
+
0,
|
|
123
|
+
4,
|
|
124
|
+
8
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
0,
|
|
128
|
+
2,
|
|
129
|
+
6,
|
|
130
|
+
8
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
0,
|
|
134
|
+
2,
|
|
135
|
+
4,
|
|
136
|
+
6,
|
|
137
|
+
8
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
0,
|
|
141
|
+
2,
|
|
142
|
+
3,
|
|
143
|
+
5,
|
|
144
|
+
6,
|
|
145
|
+
8
|
|
146
|
+
]
|
|
147
|
+
];
|
|
148
|
+
var half = (n, y, numbers) => compiledSvg(_gyral$t0, [spots[n].map((i) => compiledSvg(_gyral$t1, [10 + i % 3 * 10, y + 10 + Math.floor(i / 3) * 10])), numbers ? compiledSvg(_gyral$t2, [y + 9, n]) : null]);
|
|
149
|
+
var tileFace = (tile, numbers = false) => compiled(_gyral$t3, [
|
|
150
|
+
tileName(tile),
|
|
151
|
+
half(tile.a, 0, numbers),
|
|
152
|
+
half(tile.b, 40, numbers)
|
|
153
|
+
]);
|
|
154
|
+
//#endregion
|
|
155
|
+
export { tileFace };
|
|
156
|
+
|
|
157
|
+
//# sourceMappingURL=tiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiles.js","names":["_gyral$compiledSvg","_gyral$compiled1"],"sources":["../src/tiles.ts"],"sourcesContent":["import { svg, html, type ChildValue } from '@gyral/core';\nimport { tileName, type TileFace } from '@joystyk/kit/tiles';\nconst spots: readonly (readonly number[])[] = [\n [],\n [4],\n [0, 8],\n [0, 4, 8],\n [0, 2, 6, 8],\n [0, 2, 4, 6, 8],\n [0, 2, 3, 5, 6, 8],\n];\nconst half = (n: number, y: number, numbers: boolean): ChildValue =>\n svg`<g>${spots[n]!.map((i) => svg`<circle cx=${10 + (i % 3) * 10} cy=${y + 10 + Math.floor(i / 3) * 10} r=\"3.1\" fill=\"#25251f\"/>`)}${numbers ? svg`<text x=\"3\" y=${y + 9} fill=\"#25251f\" font-size=\"8\" font-family=\"system-ui\">${n}</text>` : null}</g>`;\nexport const tileFace = (tile: TileFace, numbers = false): ChildValue =>\n html`<svg viewBox=\"0 0 40 80\" role=\"img\" aria-label=${tileName(tile)} width=\"100%\" height=\"100%\"><rect x=\"1\" y=\"1\" width=\"38\" height=\"78\" rx=\"4\" fill=\"#f6efd9\" stroke=\"#454438\" stroke-width=\"2\"/><path d=\"M4 40H36\" stroke=\"#454438\"/><circle cx=\"20\" cy=\"40\" r=\"1.5\" fill=\"#80703d\"/>${half(tile.a, 0, numbers)}${half(tile.b, 40, numbers)}</svg>`;\n"],"mappings":";;;;AAAA,IAAA,YAAA;CAAA,MAAA;CAAA,QAAA;CAAA,SAAA,CAAA;EAAA;EAAA,CAAA,CAAA;EAAA;CAAA,GAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA;CAAA,OAAA;CAAA,YAAA;EAAA;EAAA;GAAA,KAAA;GAAA,MAAA;GAAA,OAAA;EAAA;EAAA;EAAA;GAAA,KAAA;GAAA,MAAA;GAAA,OAAA;EAAA;EAAA;CAAA;AAAA;AAAA,IAAA,YAAA;CAAA,MAAA;CAAA,QAAA;CAAA,SAAA,CAAA;EAAA;EAAA,CAAA,CAAA;EAAA;CAAA,GAAA;EAAA;EAAA,CAAA,CAAA;EAAA;CAAA,CAAA;CAAA,OAAA;CAAA,YAAA;EAAA;EAAA;GAAA,KAAA;GAAA,QAAA;EAAA;EAAA;GAAA,KAAA;GAAA,QAAA;EAAA;EAAA;CAAA;AAAA;AAAA,IAAA,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AAA,KAAA,GAAA,IAAA,OAAA;AAAyB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Json, Validator } from '@joystyk/contracts';
|
|
2
|
+
/** A short-lived certification worker per request. Every reply is parsed; disposal stops
|
|
3
|
+
* outstanding work and prevents a finished proof from changing an unmounted game. */
|
|
4
|
+
export declare const workerSetup: <C extends Json>(make: () => Worker, schema: Validator<C>) => {
|
|
5
|
+
prepare: (command: Json) => Promise<Json>;
|
|
6
|
+
dispose: () => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { decode } from "./solitaire.js";
|
|
2
|
+
//#region src/worker-setup.ts
|
|
3
|
+
/** A short-lived certification worker per request. Every reply is parsed; disposal stops
|
|
4
|
+
* outstanding work and prevents a finished proof from changing an unmounted game. */
|
|
5
|
+
var workerSetup = (make, schema) => {
|
|
6
|
+
const active = /* @__PURE__ */ new Map();
|
|
7
|
+
let disposed = false;
|
|
8
|
+
return {
|
|
9
|
+
prepare: (command) => new Promise((resolve, reject) => {
|
|
10
|
+
if (disposed) {
|
|
11
|
+
reject(/* @__PURE__ */ new Error("Disposed"));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const worker = make();
|
|
15
|
+
const stop = () => {
|
|
16
|
+
worker.terminate();
|
|
17
|
+
active.delete(worker);
|
|
18
|
+
};
|
|
19
|
+
active.set(worker, reject);
|
|
20
|
+
worker.addEventListener("message", (event) => {
|
|
21
|
+
stop();
|
|
22
|
+
const reply = decode(schema, event.data);
|
|
23
|
+
if (reply === null) reject(/* @__PURE__ */ new Error("Invalid preparation reply"));
|
|
24
|
+
else resolve(reply);
|
|
25
|
+
});
|
|
26
|
+
worker.addEventListener("error", () => {
|
|
27
|
+
stop();
|
|
28
|
+
reject(/* @__PURE__ */ new Error("The preparation worker failed"));
|
|
29
|
+
});
|
|
30
|
+
worker.postMessage(command);
|
|
31
|
+
}),
|
|
32
|
+
dispose: () => {
|
|
33
|
+
disposed = true;
|
|
34
|
+
for (const [worker, reject] of active) {
|
|
35
|
+
worker.terminate();
|
|
36
|
+
reject(/* @__PURE__ */ new Error("Disposed"));
|
|
37
|
+
}
|
|
38
|
+
active.clear();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { workerSetup };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=worker-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-setup.js","names":[],"sources":["../src/worker-setup.ts"],"sourcesContent":["import type { Json, Validator } from '@joystyk/contracts';\nimport { decode } from './solitaire.ts';\n/** A short-lived certification worker per request. Every reply is parsed; disposal stops\n * outstanding work and prevents a finished proof from changing an unmounted game. */\nexport const workerSetup = <C extends Json>(make: () => Worker, schema: Validator<C>) => {\n const active = new Map<Worker, (reason: Error) => void>();\n let disposed = false;\n return {\n prepare: (command: Json): Promise<Json> =>\n new Promise((resolve, reject) => {\n if (disposed) {\n reject(new Error('Disposed'));\n return;\n }\n const worker = make();\n const stop = () => {\n worker.terminate();\n active.delete(worker);\n };\n active.set(worker, reject);\n worker.addEventListener('message', (event: MessageEvent<unknown>) => {\n stop();\n const reply = decode(schema, event.data);\n if (reply === null) reject(new Error('Invalid preparation reply'));\n else resolve(reply);\n });\n worker.addEventListener('error', () => {\n stop();\n reject(new Error('The preparation worker failed'));\n });\n worker.postMessage(command);\n }),\n dispose: () => {\n disposed = true;\n for (const [worker, reject] of active) {\n worker.terminate();\n reject(new Error('Disposed'));\n }\n active.clear();\n },\n };\n};\n"],"mappings":";;;;AAIA,IAAa,eAA+B,MAAoB,WAAyB;CACvF,MAAM,yBAAS,IAAI,IAAqC;CACxD,IAAI,WAAW;CACf,OAAO;EACL,UAAU,YACR,IAAI,SAAS,SAAS,WAAW;GAC/B,IAAI,UAAU;IACZ,uBAAO,IAAI,MAAM,UAAU,CAAC;IAC5B;GACF;GACA,MAAM,SAAS,KAAK;GACpB,MAAM,aAAa;IACjB,OAAO,UAAU;IACjB,OAAO,OAAO,MAAM;GACtB;GACA,OAAO,IAAI,QAAQ,MAAM;GACzB,OAAO,iBAAiB,YAAY,UAAiC;IACnE,KAAK;IACL,MAAM,QAAQ,OAAO,QAAQ,MAAM,IAAI;IACvC,IAAI,UAAU,MAAM,uBAAO,IAAI,MAAM,2BAA2B,CAAC;SAC5D,QAAQ,KAAK;GACpB,CAAC;GACD,OAAO,iBAAiB,eAAe;IACrC,KAAK;IACL,uBAAO,IAAI,MAAM,+BAA+B,CAAC;GACnD,CAAC;GACD,OAAO,YAAY,OAAO;EAC5B,CAAC;EACH,eAAe;GACb,WAAW;GACX,KAAK,MAAM,CAAC,QAAQ,WAAW,QAAQ;IACrC,OAAO,UAAU;IACjB,uBAAO,IAAI,MAAM,UAAU,CAAC;GAC9B;GACA,OAAO,MAAM;EACf;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joystyk/cards-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Shared card-game UI: original card faces and backs, pile layouts, <jy-card-table>, the pointer and keyboard controller for solitaire and other card games, and <jy-card-hand>, the hand widget for multiplayer card games.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"**/index.[jt]s",
|
|
9
|
+
"**/table.[jt]s",
|
|
10
|
+
"**/hand.[jt]s",
|
|
11
|
+
"**/solitaire.[jt]s"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./controller": {
|
|
19
|
+
"types": "./dist/controller.d.ts",
|
|
20
|
+
"default": "./dist/controller.js"
|
|
21
|
+
},
|
|
22
|
+
"./layout": {
|
|
23
|
+
"types": "./dist/layout.d.ts",
|
|
24
|
+
"default": "./dist/layout.js"
|
|
25
|
+
},
|
|
26
|
+
"./solitaire": {
|
|
27
|
+
"types": "./dist/solitaire.d.ts",
|
|
28
|
+
"default": "./dist/solitaire.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@gyral/core": "0.3.1",
|
|
33
|
+
"@joystyk/contracts": "0.2.0",
|
|
34
|
+
"@joystyk/kit": "0.2.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@gyral/testing": "0.3.1",
|
|
38
|
+
"typescript": "5.9.3",
|
|
39
|
+
"vite": "8.3.3",
|
|
40
|
+
"vitest": "4.1.11",
|
|
41
|
+
"@joystyk/ui": "0.2.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"README.md",
|
|
49
|
+
"LICENSE",
|
|
50
|
+
"NOTICE",
|
|
51
|
+
"CHANGELOG.md"
|
|
52
|
+
],
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=24.15.0"
|
|
55
|
+
},
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/joystyk-games/game-libraries.git",
|
|
60
|
+
"directory": "packages/cards-ui"
|
|
61
|
+
},
|
|
62
|
+
"homepage": "https://github.com/joystyk-games/game-libraries/tree/main/packages/cards-ui#readme",
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://github.com/joystyk-games/game-libraries/issues"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"typecheck": "tsc --noEmit",
|
|
68
|
+
"build": "node ../../scripts/build-package.ts"
|
|
69
|
+
}
|
|
6
70
|
}
|