waitroom 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/README.md +62 -0
- package/dist/chunk-3RJ542WD.js +130 -0
- package/dist/chunk-3RJ542WD.js.map +1 -0
- package/dist/chunk-4DE2IREA.cjs +9 -0
- package/dist/chunk-4DE2IREA.cjs.map +1 -0
- package/dist/chunk-5AUPIR2C.cjs +90 -0
- package/dist/chunk-5AUPIR2C.cjs.map +1 -0
- package/dist/chunk-ARXVTVP4.js +55 -0
- package/dist/chunk-ARXVTVP4.js.map +1 -0
- package/dist/chunk-C5XPYOJI.js +137 -0
- package/dist/chunk-C5XPYOJI.js.map +1 -0
- package/dist/chunk-DEQZY4AM.js +58 -0
- package/dist/chunk-DEQZY4AM.js.map +1 -0
- package/dist/chunk-FH3QBC6T.cjs +139 -0
- package/dist/chunk-FH3QBC6T.cjs.map +1 -0
- package/dist/chunk-GEBKOXLQ.cjs +255 -0
- package/dist/chunk-GEBKOXLQ.cjs.map +1 -0
- package/dist/chunk-JG5ZMB2Y.cjs +142 -0
- package/dist/chunk-JG5ZMB2Y.cjs.map +1 -0
- package/dist/chunk-MAWVAR3Q.cjs +135 -0
- package/dist/chunk-MAWVAR3Q.cjs.map +1 -0
- package/dist/chunk-MMNQMDV3.js +39 -0
- package/dist/chunk-MMNQMDV3.js.map +1 -0
- package/dist/chunk-O6CAFCTV.js +140 -0
- package/dist/chunk-O6CAFCTV.js.map +1 -0
- package/dist/chunk-P6NO27XB.cjs +74 -0
- package/dist/chunk-P6NO27XB.cjs.map +1 -0
- package/dist/chunk-PKRYY3X6.cjs +60 -0
- package/dist/chunk-PKRYY3X6.cjs.map +1 -0
- package/dist/chunk-PUR7CO53.js +72 -0
- package/dist/chunk-PUR7CO53.js.map +1 -0
- package/dist/chunk-R5V2UBE7.js +88 -0
- package/dist/chunk-R5V2UBE7.js.map +1 -0
- package/dist/chunk-SSP4S4NY.cjs +57 -0
- package/dist/chunk-SSP4S4NY.cjs.map +1 -0
- package/dist/chunk-SUJCEDVR.js +251 -0
- package/dist/chunk-SUJCEDVR.js.map +1 -0
- package/dist/chunk-V4RO47V6.cjs +41 -0
- package/dist/chunk-V4RO47V6.cjs.map +1 -0
- package/dist/chunk-V5DABI44.cjs +172 -0
- package/dist/chunk-V5DABI44.cjs.map +1 -0
- package/dist/chunk-V6TY7KAL.js +7 -0
- package/dist/chunk-V6TY7KAL.js.map +1 -0
- package/dist/chunk-VKSLYTRF.js +170 -0
- package/dist/chunk-VKSLYTRF.js.map +1 -0
- package/dist/core/index.cjs +30 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +23 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/doodle/basic-canvas.cjs +13 -0
- package/dist/doodle/basic-canvas.cjs.map +1 -0
- package/dist/doodle/basic-canvas.d.cts +5 -0
- package/dist/doodle/basic-canvas.d.ts +5 -0
- package/dist/doodle/basic-canvas.js +4 -0
- package/dist/doodle/basic-canvas.js.map +1 -0
- package/dist/doodle/index.cjs +13 -0
- package/dist/doodle/index.cjs.map +1 -0
- package/dist/doodle/index.d.cts +2 -0
- package/dist/doodle/index.d.ts +2 -0
- package/dist/doodle/index.js +4 -0
- package/dist/doodle/index.js.map +1 -0
- package/dist/engine--hGQ4LNR.d.ts +16 -0
- package/dist/engine-DdHCpfbk.d.cts +16 -0
- package/dist/facts/dev-tips.cjs +13 -0
- package/dist/facts/dev-tips.cjs.map +1 -0
- package/dist/facts/dev-tips.d.cts +5 -0
- package/dist/facts/dev-tips.d.ts +5 -0
- package/dist/facts/dev-tips.js +4 -0
- package/dist/facts/dev-tips.js.map +1 -0
- package/dist/facts/index.cjs +23 -0
- package/dist/facts/index.cjs.map +1 -0
- package/dist/facts/index.d.cts +4 -0
- package/dist/facts/index.d.ts +4 -0
- package/dist/facts/index.js +6 -0
- package/dist/facts/index.js.map +1 -0
- package/dist/facts/programming-trivia.cjs +13 -0
- package/dist/facts/programming-trivia.cjs.map +1 -0
- package/dist/facts/programming-trivia.d.cts +5 -0
- package/dist/facts/programming-trivia.d.ts +5 -0
- package/dist/facts/programming-trivia.js +4 -0
- package/dist/facts/programming-trivia.js.map +1 -0
- package/dist/facts/tech-stats.cjs +13 -0
- package/dist/facts/tech-stats.cjs.map +1 -0
- package/dist/facts/tech-stats.d.cts +5 -0
- package/dist/facts/tech-stats.d.ts +5 -0
- package/dist/facts/tech-stats.js +4 -0
- package/dist/facts/tech-stats.js.map +1 -0
- package/dist/games/click-counter.cjs +13 -0
- package/dist/games/click-counter.cjs.map +1 -0
- package/dist/games/click-counter.d.cts +5 -0
- package/dist/games/click-counter.d.ts +5 -0
- package/dist/games/click-counter.js +4 -0
- package/dist/games/click-counter.js.map +1 -0
- package/dist/games/index.cjs +23 -0
- package/dist/games/index.cjs.map +1 -0
- package/dist/games/index.d.cts +4 -0
- package/dist/games/index.d.ts +4 -0
- package/dist/games/index.js +6 -0
- package/dist/games/index.js.map +1 -0
- package/dist/games/memory.cjs +13 -0
- package/dist/games/memory.cjs.map +1 -0
- package/dist/games/memory.d.cts +5 -0
- package/dist/games/memory.d.ts +5 -0
- package/dist/games/memory.js +4 -0
- package/dist/games/memory.js.map +1 -0
- package/dist/games/snake.cjs +13 -0
- package/dist/games/snake.cjs.map +1 -0
- package/dist/games/snake.d.cts +5 -0
- package/dist/games/snake.d.ts +5 -0
- package/dist/games/snake.js +4 -0
- package/dist/games/snake.js.map +1 -0
- package/dist/index.cjs +43 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +22 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +24 -0
- package/dist/react/index.d.ts +24 -0
- package/dist/react/index.js +5 -0
- package/dist/react/index.js.map +1 -0
- package/dist/types-vBwPFyxq.d.cts +101 -0
- package/dist/types-vBwPFyxq.d.ts +101 -0
- package/package.json +64 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk4DE2IREA_cjs = require('./chunk-4DE2IREA.cjs');
|
|
4
|
+
|
|
5
|
+
// src/games/snake.ts
|
|
6
|
+
var SnakeInstance = class {
|
|
7
|
+
constructor(container, state) {
|
|
8
|
+
chunk4DE2IREA_cjs.__publicField(this, "container");
|
|
9
|
+
chunk4DE2IREA_cjs.__publicField(this, "state");
|
|
10
|
+
chunk4DE2IREA_cjs.__publicField(this, "canvas");
|
|
11
|
+
chunk4DE2IREA_cjs.__publicField(this, "ctx");
|
|
12
|
+
chunk4DE2IREA_cjs.__publicField(this, "loopId", null);
|
|
13
|
+
chunk4DE2IREA_cjs.__publicField(this, "snake", []);
|
|
14
|
+
chunk4DE2IREA_cjs.__publicField(this, "food", { x: 0, y: 0 });
|
|
15
|
+
chunk4DE2IREA_cjs.__publicField(this, "direction", { x: 1, y: 0 });
|
|
16
|
+
chunk4DE2IREA_cjs.__publicField(this, "gridSize", 10);
|
|
17
|
+
chunk4DE2IREA_cjs.__publicField(this, "tiles", 20);
|
|
18
|
+
chunk4DE2IREA_cjs.__publicField(this, "lastTime", 0);
|
|
19
|
+
this.container = container;
|
|
20
|
+
this.state = state;
|
|
21
|
+
this.canvas = document.createElement("canvas");
|
|
22
|
+
this.canvas.height = 150;
|
|
23
|
+
this.canvas.style.border = "1px solid #333";
|
|
24
|
+
this.canvas.style.display = "block";
|
|
25
|
+
this.canvas.style.margin = "0 auto";
|
|
26
|
+
const title = document.createElement("h3");
|
|
27
|
+
title.innerText = "Snake";
|
|
28
|
+
title.style.margin = "0 0 5px 0";
|
|
29
|
+
title.style.textAlign = "center";
|
|
30
|
+
title.style.fontFamily = "sans-serif";
|
|
31
|
+
this.container.appendChild(title);
|
|
32
|
+
const helper = document.createElement("div");
|
|
33
|
+
helper.innerText = "Use arrow keys to move";
|
|
34
|
+
helper.style.fontSize = "0.8em";
|
|
35
|
+
helper.style.color = "#888";
|
|
36
|
+
helper.style.marginBottom = "5px";
|
|
37
|
+
helper.style.textAlign = "center";
|
|
38
|
+
helper.style.fontFamily = "sans-serif";
|
|
39
|
+
this.container.appendChild(helper);
|
|
40
|
+
this.container.style.display = "flex";
|
|
41
|
+
this.container.style.flexDirection = "column";
|
|
42
|
+
this.container.style.alignItems = "center";
|
|
43
|
+
this.container.appendChild(this.canvas);
|
|
44
|
+
this.canvas.style.width = "90%";
|
|
45
|
+
this.canvas.style.flex = "1";
|
|
46
|
+
this.canvas.style.minHeight = "0";
|
|
47
|
+
this.canvas.style.border = "1px solid #333";
|
|
48
|
+
this.canvas.style.marginTop = "10px";
|
|
49
|
+
this.canvas.style.background = "#222";
|
|
50
|
+
this.ctx = this.canvas.getContext("2d");
|
|
51
|
+
this.reset();
|
|
52
|
+
this.setupInput();
|
|
53
|
+
const observer = new ResizeObserver(() => this.resize());
|
|
54
|
+
observer.observe(this.canvas);
|
|
55
|
+
this.resize();
|
|
56
|
+
this.loopId = requestAnimationFrame(this.loop.bind(this));
|
|
57
|
+
}
|
|
58
|
+
resize() {
|
|
59
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
60
|
+
this.canvas.width = rect.width;
|
|
61
|
+
this.canvas.height = rect.height;
|
|
62
|
+
this.tiles = Math.floor(rect.width / this.gridSize);
|
|
63
|
+
}
|
|
64
|
+
reset() {
|
|
65
|
+
this.snake = [{ x: 10, y: 10 }];
|
|
66
|
+
this.direction = { x: 1, y: 0 };
|
|
67
|
+
this.placeFood();
|
|
68
|
+
}
|
|
69
|
+
placeFood() {
|
|
70
|
+
this.food = {
|
|
71
|
+
x: Math.floor(Math.random() * this.tiles),
|
|
72
|
+
y: Math.floor(Math.random() * (this.canvas.height / this.gridSize))
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
setupInput() {
|
|
76
|
+
window.addEventListener("keydown", this.handleKey.bind(this));
|
|
77
|
+
}
|
|
78
|
+
handleKey(e) {
|
|
79
|
+
switch (e.key) {
|
|
80
|
+
case "ArrowUp":
|
|
81
|
+
if (this.direction.y === 0) this.direction = { x: 0, y: -1 };
|
|
82
|
+
break;
|
|
83
|
+
case "ArrowDown":
|
|
84
|
+
if (this.direction.y === 0) this.direction = { x: 0, y: 1 };
|
|
85
|
+
break;
|
|
86
|
+
case "ArrowLeft":
|
|
87
|
+
if (this.direction.x === 0) this.direction = { x: -1, y: 0 };
|
|
88
|
+
break;
|
|
89
|
+
case "ArrowRight":
|
|
90
|
+
if (this.direction.x === 0) this.direction = { x: 1, y: 0 };
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
update() {
|
|
95
|
+
const head = {
|
|
96
|
+
x: this.snake[0].x + this.direction.x,
|
|
97
|
+
y: this.snake[0].y + this.direction.y
|
|
98
|
+
};
|
|
99
|
+
if (head.x < 0) head.x = this.tiles - 1;
|
|
100
|
+
if (head.x >= this.tiles) head.x = 0;
|
|
101
|
+
if (head.y < 0) head.y = Math.floor(this.canvas.height / this.gridSize) - 1;
|
|
102
|
+
if (head.y >= Math.floor(this.canvas.height / this.gridSize)) head.y = 0;
|
|
103
|
+
for (const part of this.snake) {
|
|
104
|
+
if (part.x === head.x && part.y === head.y) {
|
|
105
|
+
this.reset();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
this.snake.unshift(head);
|
|
110
|
+
if (head.x === this.food.x && head.y === this.food.y) {
|
|
111
|
+
this.placeFood();
|
|
112
|
+
this.state.progress = {
|
|
113
|
+
...this.state.progress,
|
|
114
|
+
score: (this.state.progress?.score || 0) + 10
|
|
115
|
+
};
|
|
116
|
+
} else {
|
|
117
|
+
this.snake.pop();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
draw() {
|
|
121
|
+
this.ctx.fillStyle = "#222";
|
|
122
|
+
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
123
|
+
this.ctx.fillStyle = "#4CAF50";
|
|
124
|
+
for (const part of this.snake) {
|
|
125
|
+
this.ctx.fillRect(
|
|
126
|
+
part.x * this.gridSize,
|
|
127
|
+
part.y * this.gridSize,
|
|
128
|
+
this.gridSize - 1,
|
|
129
|
+
this.gridSize - 1
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
this.ctx.fillStyle = "#FF5722";
|
|
133
|
+
this.ctx.fillRect(
|
|
134
|
+
this.food.x * this.gridSize,
|
|
135
|
+
this.food.y * this.gridSize,
|
|
136
|
+
this.gridSize - 1,
|
|
137
|
+
this.gridSize - 1
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
loop(time) {
|
|
141
|
+
if (!this.loopId) return;
|
|
142
|
+
if (time - this.lastTime > 100) {
|
|
143
|
+
this.update();
|
|
144
|
+
this.draw();
|
|
145
|
+
this.lastTime = time;
|
|
146
|
+
}
|
|
147
|
+
this.loopId = requestAnimationFrame(this.loop.bind(this));
|
|
148
|
+
}
|
|
149
|
+
getState() {
|
|
150
|
+
return this.state;
|
|
151
|
+
}
|
|
152
|
+
setState(newState) {
|
|
153
|
+
this.state = { ...this.state, ...newState };
|
|
154
|
+
}
|
|
155
|
+
destroy() {
|
|
156
|
+
if (this.loopId) cancelAnimationFrame(this.loopId);
|
|
157
|
+
this.loopId = null;
|
|
158
|
+
window.removeEventListener("keydown", this.handleKey.bind(this));
|
|
159
|
+
this.canvas.remove();
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
var SnakeGame = {
|
|
163
|
+
id: "snake",
|
|
164
|
+
name: "Snake",
|
|
165
|
+
description: "Classic Snake Game",
|
|
166
|
+
renderMini: (container, state) => new SnakeInstance(container, state),
|
|
167
|
+
renderFull: (container, state) => new SnakeInstance(container, state)
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
exports.SnakeGame = SnakeGame;
|
|
171
|
+
//# sourceMappingURL=chunk-V5DABI44.cjs.map
|
|
172
|
+
//#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AAO;AACZ,MAAA,IAAA,CAAK,IAAA,EAAK;AACV,MAAA,IAAA,CAAK,QAAA,GAAW,IAAA;AAAA,IAClB;AAEA,IAAA,IAAA,CAAK,SAAS,qBAAA,CAAsB,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,EAC1D;AAAA,EAEO,QAAA,GAAW;AAChB,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA,EAEO,SAAS,QAAA,EAA8B;AAC5C,IAAA,IAAA,CAAK,QAAQ,EAAE,GAAG,IAAA,CAAK,KAAA,EAAO,GAAG,QAAA,EAAS;AAAA,EAC5C;AAAA,EAEO,OAAA,GAAU;AACf,IAAA,IAAI,IAAA,CAAK,MAAA,EAAQ,oBAAA,CAAqB,IAAA,CAAK,MAAM,CAAA;AACjD,IAAA,IAAA,CAAK,MAAA,GAAS,IAAA;AACd,IAAA,MAAA,CAAO,oBAAoB,SAAA,EAAW,IAAA,CAAK,SAAA,CAAU,IAAA,CAAK,IAAI,CAAC,CAAA;AAC/D,IAAA,IAAA,CAAK,OAAO,MAAA,EAAO;AAAA,EACrB;AACF,CAAA;AAEO,IAAM,SAAA,GAAwB;AAAA,EACnC,EAAA,EAAI,OAAA;AAAA,EACJ,IAAA,EAAM,OAAA;AAAA,EACN,WAAA,EAAa,oBAAA;AAAA,EAEb,YAAY,CAAC,SAAA,EAAW,UAAU,IAAI,aAAA,CAAc,WAAW,KAAK,CAAA;AAAA,EACpE,YAAY,CAAC,SAAA,EAAW,UAAU,IAAI,aAAA,CAAc,WAAW,KAAK;AACtE","file":"chunk-V5DABI44.cjs","sourcesContent":["import { GamePlugin, GameInstance, GameState } from \"../core/types\";\n\nclass SnakeInstance implements GameInstance {\n private container: HTMLElement;\n private state: Partial<GameState>;\n private canvas: HTMLCanvasElement;\n private ctx: CanvasRenderingContext2D;\n private loopId: number | null = null;\n private snake: { x: number; y: number }[] = [];\n private food: { x: number; y: number } = { x: 0, y: 0 };\n private direction = { x: 1, y: 0 };\n private gridSize = 10;\n private tiles = 20;\n\n constructor(container: HTMLElement, state: Partial<GameState>) {\n this.container = container;\n this.state = state;\n this.canvas = document.createElement(\"canvas\");\n this.canvas.height = 150;\n this.canvas.style.border = \"1px solid #333\";\n this.canvas.style.display = \"block\";\n this.canvas.style.margin = \"0 auto\"; // Center canvas\n\n // Title\n const title = document.createElement(\"h3\");\n title.innerText = \"Snake\";\n title.style.margin = \"0 0 5px 0\";\n title.style.textAlign = \"center\";\n title.style.fontFamily = \"sans-serif\";\n this.container.appendChild(title);\n\n // Helper\n const helper = document.createElement(\"div\");\n helper.innerText = \"Use arrow keys to move\";\n helper.style.fontSize = \"0.8em\";\n helper.style.color = \"#888\";\n helper.style.marginBottom = \"5px\";\n helper.style.textAlign = \"center\";\n helper.style.fontFamily = \"sans-serif\";\n this.container.appendChild(helper);\n\n this.container.style.display = \"flex\";\n this.container.style.flexDirection = \"column\";\n this.container.style.alignItems = \"center\";\n this.container.appendChild(this.canvas);\n\n // Canvas CSS Layout\n this.canvas.style.width = \"90%\"; // Leave some margins\n this.canvas.style.flex = \"1\"; // Take remaining vertical space\n this.canvas.style.minHeight = \"0\"; // Allow shrinking in flex container\n this.canvas.style.border = \"1px solid #333\";\n this.canvas.style.marginTop = \"10px\";\n this.canvas.style.background = \"#222\";\n\n this.ctx = this.canvas.getContext(\"2d\")!;\n\n this.reset();\n this.setupInput();\n\n // Resize observer to handle dynamic sizing\n const observer = new ResizeObserver(() => this.resize());\n observer.observe(this.canvas);\n\n this.resize();\n\n this.loopId = requestAnimationFrame(this.loop.bind(this));\n }\n\n private resize() {\n // Fit to internal resolution to displayed size\n const rect = this.canvas.getBoundingClientRect();\n this.canvas.width = rect.width;\n this.canvas.height = rect.height;\n\n // Ensure grid alignment\n this.tiles = Math.floor(rect.width / this.gridSize);\n }\n\n private reset() {\n this.snake = [{ x: 10, y: 10 }];\n this.direction = { x: 1, y: 0 };\n this.placeFood();\n }\n\n private placeFood() {\n this.food = {\n x: Math.floor(Math.random() * this.tiles),\n y: Math.floor(Math.random() * (this.canvas.height / this.gridSize)),\n };\n }\n\n private setupInput() {\n window.addEventListener(\"keydown\", this.handleKey.bind(this));\n }\n\n private handleKey(e: KeyboardEvent) {\n switch (e.key) {\n case \"ArrowUp\":\n if (this.direction.y === 0) this.direction = { x: 0, y: -1 };\n break;\n case \"ArrowDown\":\n if (this.direction.y === 0) this.direction = { x: 0, y: 1 };\n break;\n case \"ArrowLeft\":\n if (this.direction.x === 0) this.direction = { x: -1, y: 0 };\n break;\n case \"ArrowRight\":\n if (this.direction.x === 0) this.direction = { x: 1, y: 0 };\n break;\n }\n }\n\n private update() {\n const head = {\n x: this.snake[0].x + this.direction.x,\n y: this.snake[0].y + this.direction.y,\n };\n\n // Wrap around\n if (head.x < 0) head.x = this.tiles - 1;\n if (head.x >= this.tiles) head.x = 0;\n if (head.y < 0) head.y = Math.floor(this.canvas.height / this.gridSize) - 1;\n if (head.y >= Math.floor(this.canvas.height / this.gridSize)) head.y = 0;\n\n // Self collision\n for (const part of this.snake) {\n if (part.x === head.x && part.y === head.y) {\n this.reset();\n return;\n }\n }\n\n this.snake.unshift(head);\n\n // Eat food\n if (head.x === this.food.x && head.y === this.food.y) {\n this.placeFood();\n // Update score in state\n this.state.progress = {\n ...this.state.progress,\n score: (this.state.progress?.score || 0) + 10,\n } as any;\n } else {\n this.snake.pop();\n }\n }\n\n private draw() {\n this.ctx.fillStyle = \"#222\";\n this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);\n\n this.ctx.fillStyle = \"#4CAF50\";\n for (const part of this.snake) {\n this.ctx.fillRect(\n part.x * this.gridSize,\n part.y * this.gridSize,\n this.gridSize - 1,\n this.gridSize - 1\n );\n }\n\n this.ctx.fillStyle = \"#FF5722\";\n this.ctx.fillRect(\n this.food.x * this.gridSize,\n this.food.y * this.gridSize,\n this.gridSize - 1,\n this.gridSize - 1\n );\n }\n\n private lastTime = 0;\n private loop(time: number) {\n if (!this.loopId) return;\n\n if (time - this.lastTime > 100) {\n // 10 FPS\n this.update();\n this.draw();\n this.lastTime = time;\n }\n\n this.loopId = requestAnimationFrame(this.loop.bind(this));\n }\n\n public getState() {\n return this.state as GameState;\n }\n\n public setState(newState: Partial<GameState>) {\n this.state = { ...this.state, ...newState };\n }\n\n public destroy() {\n if (this.loopId) cancelAnimationFrame(this.loopId);\n this.loopId = null;\n window.removeEventListener(\"keydown\", this.handleKey.bind(this));\n this.canvas.remove();\n }\n}\n\nexport const SnakeGame: GamePlugin = {\n id: \"snake\",\n name: \"Snake\",\n description: \"Classic Snake Game\",\n\n renderMini: (container, state) => new SnakeInstance(container, state),\n renderFull: (container, state) => new SnakeInstance(container, state),\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
export { __publicField };
|
|
6
|
+
//# sourceMappingURL=chunk-V6TY7KAL.js.map
|
|
7
|
+
//# sourceMappingURL=chunk-V6TY7KAL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-V6TY7KAL.js"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { __publicField } from './chunk-V6TY7KAL.js';
|
|
2
|
+
|
|
3
|
+
// src/games/snake.ts
|
|
4
|
+
var SnakeInstance = class {
|
|
5
|
+
constructor(container, state) {
|
|
6
|
+
__publicField(this, "container");
|
|
7
|
+
__publicField(this, "state");
|
|
8
|
+
__publicField(this, "canvas");
|
|
9
|
+
__publicField(this, "ctx");
|
|
10
|
+
__publicField(this, "loopId", null);
|
|
11
|
+
__publicField(this, "snake", []);
|
|
12
|
+
__publicField(this, "food", { x: 0, y: 0 });
|
|
13
|
+
__publicField(this, "direction", { x: 1, y: 0 });
|
|
14
|
+
__publicField(this, "gridSize", 10);
|
|
15
|
+
__publicField(this, "tiles", 20);
|
|
16
|
+
__publicField(this, "lastTime", 0);
|
|
17
|
+
this.container = container;
|
|
18
|
+
this.state = state;
|
|
19
|
+
this.canvas = document.createElement("canvas");
|
|
20
|
+
this.canvas.height = 150;
|
|
21
|
+
this.canvas.style.border = "1px solid #333";
|
|
22
|
+
this.canvas.style.display = "block";
|
|
23
|
+
this.canvas.style.margin = "0 auto";
|
|
24
|
+
const title = document.createElement("h3");
|
|
25
|
+
title.innerText = "Snake";
|
|
26
|
+
title.style.margin = "0 0 5px 0";
|
|
27
|
+
title.style.textAlign = "center";
|
|
28
|
+
title.style.fontFamily = "sans-serif";
|
|
29
|
+
this.container.appendChild(title);
|
|
30
|
+
const helper = document.createElement("div");
|
|
31
|
+
helper.innerText = "Use arrow keys to move";
|
|
32
|
+
helper.style.fontSize = "0.8em";
|
|
33
|
+
helper.style.color = "#888";
|
|
34
|
+
helper.style.marginBottom = "5px";
|
|
35
|
+
helper.style.textAlign = "center";
|
|
36
|
+
helper.style.fontFamily = "sans-serif";
|
|
37
|
+
this.container.appendChild(helper);
|
|
38
|
+
this.container.style.display = "flex";
|
|
39
|
+
this.container.style.flexDirection = "column";
|
|
40
|
+
this.container.style.alignItems = "center";
|
|
41
|
+
this.container.appendChild(this.canvas);
|
|
42
|
+
this.canvas.style.width = "90%";
|
|
43
|
+
this.canvas.style.flex = "1";
|
|
44
|
+
this.canvas.style.minHeight = "0";
|
|
45
|
+
this.canvas.style.border = "1px solid #333";
|
|
46
|
+
this.canvas.style.marginTop = "10px";
|
|
47
|
+
this.canvas.style.background = "#222";
|
|
48
|
+
this.ctx = this.canvas.getContext("2d");
|
|
49
|
+
this.reset();
|
|
50
|
+
this.setupInput();
|
|
51
|
+
const observer = new ResizeObserver(() => this.resize());
|
|
52
|
+
observer.observe(this.canvas);
|
|
53
|
+
this.resize();
|
|
54
|
+
this.loopId = requestAnimationFrame(this.loop.bind(this));
|
|
55
|
+
}
|
|
56
|
+
resize() {
|
|
57
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
58
|
+
this.canvas.width = rect.width;
|
|
59
|
+
this.canvas.height = rect.height;
|
|
60
|
+
this.tiles = Math.floor(rect.width / this.gridSize);
|
|
61
|
+
}
|
|
62
|
+
reset() {
|
|
63
|
+
this.snake = [{ x: 10, y: 10 }];
|
|
64
|
+
this.direction = { x: 1, y: 0 };
|
|
65
|
+
this.placeFood();
|
|
66
|
+
}
|
|
67
|
+
placeFood() {
|
|
68
|
+
this.food = {
|
|
69
|
+
x: Math.floor(Math.random() * this.tiles),
|
|
70
|
+
y: Math.floor(Math.random() * (this.canvas.height / this.gridSize))
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
setupInput() {
|
|
74
|
+
window.addEventListener("keydown", this.handleKey.bind(this));
|
|
75
|
+
}
|
|
76
|
+
handleKey(e) {
|
|
77
|
+
switch (e.key) {
|
|
78
|
+
case "ArrowUp":
|
|
79
|
+
if (this.direction.y === 0) this.direction = { x: 0, y: -1 };
|
|
80
|
+
break;
|
|
81
|
+
case "ArrowDown":
|
|
82
|
+
if (this.direction.y === 0) this.direction = { x: 0, y: 1 };
|
|
83
|
+
break;
|
|
84
|
+
case "ArrowLeft":
|
|
85
|
+
if (this.direction.x === 0) this.direction = { x: -1, y: 0 };
|
|
86
|
+
break;
|
|
87
|
+
case "ArrowRight":
|
|
88
|
+
if (this.direction.x === 0) this.direction = { x: 1, y: 0 };
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
update() {
|
|
93
|
+
const head = {
|
|
94
|
+
x: this.snake[0].x + this.direction.x,
|
|
95
|
+
y: this.snake[0].y + this.direction.y
|
|
96
|
+
};
|
|
97
|
+
if (head.x < 0) head.x = this.tiles - 1;
|
|
98
|
+
if (head.x >= this.tiles) head.x = 0;
|
|
99
|
+
if (head.y < 0) head.y = Math.floor(this.canvas.height / this.gridSize) - 1;
|
|
100
|
+
if (head.y >= Math.floor(this.canvas.height / this.gridSize)) head.y = 0;
|
|
101
|
+
for (const part of this.snake) {
|
|
102
|
+
if (part.x === head.x && part.y === head.y) {
|
|
103
|
+
this.reset();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
this.snake.unshift(head);
|
|
108
|
+
if (head.x === this.food.x && head.y === this.food.y) {
|
|
109
|
+
this.placeFood();
|
|
110
|
+
this.state.progress = {
|
|
111
|
+
...this.state.progress,
|
|
112
|
+
score: (this.state.progress?.score || 0) + 10
|
|
113
|
+
};
|
|
114
|
+
} else {
|
|
115
|
+
this.snake.pop();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
draw() {
|
|
119
|
+
this.ctx.fillStyle = "#222";
|
|
120
|
+
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
121
|
+
this.ctx.fillStyle = "#4CAF50";
|
|
122
|
+
for (const part of this.snake) {
|
|
123
|
+
this.ctx.fillRect(
|
|
124
|
+
part.x * this.gridSize,
|
|
125
|
+
part.y * this.gridSize,
|
|
126
|
+
this.gridSize - 1,
|
|
127
|
+
this.gridSize - 1
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
this.ctx.fillStyle = "#FF5722";
|
|
131
|
+
this.ctx.fillRect(
|
|
132
|
+
this.food.x * this.gridSize,
|
|
133
|
+
this.food.y * this.gridSize,
|
|
134
|
+
this.gridSize - 1,
|
|
135
|
+
this.gridSize - 1
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
loop(time) {
|
|
139
|
+
if (!this.loopId) return;
|
|
140
|
+
if (time - this.lastTime > 100) {
|
|
141
|
+
this.update();
|
|
142
|
+
this.draw();
|
|
143
|
+
this.lastTime = time;
|
|
144
|
+
}
|
|
145
|
+
this.loopId = requestAnimationFrame(this.loop.bind(this));
|
|
146
|
+
}
|
|
147
|
+
getState() {
|
|
148
|
+
return this.state;
|
|
149
|
+
}
|
|
150
|
+
setState(newState) {
|
|
151
|
+
this.state = { ...this.state, ...newState };
|
|
152
|
+
}
|
|
153
|
+
destroy() {
|
|
154
|
+
if (this.loopId) cancelAnimationFrame(this.loopId);
|
|
155
|
+
this.loopId = null;
|
|
156
|
+
window.removeEventListener("keydown", this.handleKey.bind(this));
|
|
157
|
+
this.canvas.remove();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var SnakeGame = {
|
|
161
|
+
id: "snake",
|
|
162
|
+
name: "Snake",
|
|
163
|
+
description: "Classic Snake Game",
|
|
164
|
+
renderMini: (container, state) => new SnakeInstance(container, state),
|
|
165
|
+
renderFull: (container, state) => new SnakeInstance(container, state)
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export { SnakeGame };
|
|
169
|
+
//# sourceMappingURL=chunk-VKSLYTRF.js.map
|
|
170
|
+
//# sourceMappingURL=chunk-VKSLYTRF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/games/snake.ts"],"names":[],"mappings":";;;AAEA,IAAM,gBAAN,MAA4C;AAAA,EAY1C,WAAA,CAAY,WAAwB,KAAA,EAA2B;AAX/D,IAAA,aAAA,CAAA,IAAA,EAAQ,WAAA,CAAA;AACR,IAAA,aAAA,CAAA,IAAA,EAAQ,OAAA,CAAA;AACR,IAAA,aAAA,CAAA,IAAA,EAAQ,QAAA,CAAA;AACR,IAAA,aAAA,CAAA,IAAA,EAAQ,KAAA,CAAA;AACR,IAAA,aAAA,CAAA,IAAA,EAAQ,QAAA,EAAwB,IAAA,CAAA;AAChC,IAAA,aAAA,CAAA,IAAA,EAAQ,SAAoC,EAAC,CAAA;AAC7C,IAAA,aAAA,CAAA,IAAA,EAAQ,MAAA,EAAiC,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAE,CAAA;AACtD,IAAA,aAAA,CAAA,IAAA,EAAQ,WAAA,EAAY,EAAE,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AO;AAAA,EACrB;AACF,CAAA;AAEO,IAAM,SAAA,GAAwB;AAAA,EACnC,EAAA,EAAI,OAAA;AAAA,EACJ,IAAA,EAAM,OAAA;AAAA,EACN,WAAA,EAAa,oBAAA;AAAA,EAEb,YAAY,CAAC,SAAA,EAAW,UAAU,IAAI,aAAA,CAAc,WAAW,KAAK,CAAA;AAAA,EACpE,YAAY,CAAC,SAAA,EAAW,UAAU,IAAI,aAAA,CAAc,WAAW,KAAK;AACtE","file":"chunk-VKSLYTRF.js","sourcesContent":["import { GamePlugin, GameInstance, GameState } from \"../core/types\";\n\nclass SnakeInstance implements GameInstance {\n private container: HTMLElement;\n private state: Partial<GameState>;\n private canvas: HTMLCanvasElement;\n private ctx: CanvasRenderingContext2D;\n private loopId: number | null = null;\n private snake: { x: number; y: number }[] = [];\n private food: { x: number; y: number } = { x: 0, y: 0 };\n private direction = { x: 1, y: 0 };\n private gridSize = 10;\n private tiles = 20;\n\n constructor(container: HTMLElement, state: Partial<GameState>) {\n this.container = container;\n this.state = state;\n this.canvas = document.createElement(\"canvas\");\n this.canvas.height = 150;\n this.canvas.style.border = \"1px solid #333\";\n this.canvas.style.display = \"block\";\n this.canvas.style.margin = \"0 auto\"; // Center canvas\n\n // Title\n const title = document.createElement(\"h3\");\n title.innerText = \"Snake\";\n title.style.margin = \"0 0 5px 0\";\n title.style.textAlign = \"center\";\n title.style.fontFamily = \"sans-serif\";\n this.container.appendChild(title);\n\n // Helper\n const helper = document.createElement(\"div\");\n helper.innerText = \"Use arrow keys to move\";\n helper.style.fontSize = \"0.8em\";\n helper.style.color = \"#888\";\n helper.style.marginBottom = \"5px\";\n helper.style.textAlign = \"center\";\n helper.style.fontFamily = \"sans-serif\";\n this.container.appendChild(helper);\n\n this.container.style.display = \"flex\";\n this.container.style.flexDirection = \"column\";\n this.container.style.alignItems = \"center\";\n this.container.appendChild(this.canvas);\n\n // Canvas CSS Layout\n this.canvas.style.width = \"90%\"; // Leave some margins\n this.canvas.style.flex = \"1\"; // Take remaining vertical space\n this.canvas.style.minHeight = \"0\"; // Allow shrinking in flex container\n this.canvas.style.border = \"1px solid #333\";\n this.canvas.style.marginTop = \"10px\";\n this.canvas.style.background = \"#222\";\n\n this.ctx = this.canvas.getContext(\"2d\")!;\n\n this.reset();\n this.setupInput();\n\n // Resize observer to handle dynamic sizing\n const observer = new ResizeObserver(() => this.resize());\n observer.observe(this.canvas);\n\n this.resize();\n\n this.loopId = requestAnimationFrame(this.loop.bind(this));\n }\n\n private resize() {\n // Fit to internal resolution to displayed size\n const rect = this.canvas.getBoundingClientRect();\n this.canvas.width = rect.width;\n this.canvas.height = rect.height;\n\n // Ensure grid alignment\n this.tiles = Math.floor(rect.width / this.gridSize);\n }\n\n private reset() {\n this.snake = [{ x: 10, y: 10 }];\n this.direction = { x: 1, y: 0 };\n this.placeFood();\n }\n\n private placeFood() {\n this.food = {\n x: Math.floor(Math.random() * this.tiles),\n y: Math.floor(Math.random() * (this.canvas.height / this.gridSize)),\n };\n }\n\n private setupInput() {\n window.addEventListener(\"keydown\", this.handleKey.bind(this));\n }\n\n private handleKey(e: KeyboardEvent) {\n switch (e.key) {\n case \"ArrowUp\":\n if (this.direction.y === 0) this.direction = { x: 0, y: -1 };\n break;\n case \"ArrowDown\":\n if (this.direction.y === 0) this.direction = { x: 0, y: 1 };\n break;\n case \"ArrowLeft\":\n if (this.direction.x === 0) this.direction = { x: -1, y: 0 };\n break;\n case \"ArrowRight\":\n if (this.direction.x === 0) this.direction = { x: 1, y: 0 };\n break;\n }\n }\n\n private update() {\n const head = {\n x: this.snake[0].x + this.direction.x,\n y: this.snake[0].y + this.direction.y,\n };\n\n // Wrap around\n if (head.x < 0) head.x = this.tiles - 1;\n if (head.x >= this.tiles) head.x = 0;\n if (head.y < 0) head.y = Math.floor(this.canvas.height / this.gridSize) - 1;\n if (head.y >= Math.floor(this.canvas.height / this.gridSize)) head.y = 0;\n\n // Self collision\n for (const part of this.snake) {\n if (part.x === head.x && part.y === head.y) {\n this.reset();\n return;\n }\n }\n\n this.snake.unshift(head);\n\n // Eat food\n if (head.x === this.food.x && head.y === this.food.y) {\n this.placeFood();\n // Update score in state\n this.state.progress = {\n ...this.state.progress,\n score: (this.state.progress?.score || 0) + 10,\n } as any;\n } else {\n this.snake.pop();\n }\n }\n\n private draw() {\n this.ctx.fillStyle = \"#222\";\n this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);\n\n this.ctx.fillStyle = \"#4CAF50\";\n for (const part of this.snake) {\n this.ctx.fillRect(\n part.x * this.gridSize,\n part.y * this.gridSize,\n this.gridSize - 1,\n this.gridSize - 1\n );\n }\n\n this.ctx.fillStyle = \"#FF5722\";\n this.ctx.fillRect(\n this.food.x * this.gridSize,\n this.food.y * this.gridSize,\n this.gridSize - 1,\n this.gridSize - 1\n );\n }\n\n private lastTime = 0;\n private loop(time: number) {\n if (!this.loopId) return;\n\n if (time - this.lastTime > 100) {\n // 10 FPS\n this.update();\n this.draw();\n this.lastTime = time;\n }\n\n this.loopId = requestAnimationFrame(this.loop.bind(this));\n }\n\n public getState() {\n return this.state as GameState;\n }\n\n public setState(newState: Partial<GameState>) {\n this.state = { ...this.state, ...newState };\n }\n\n public destroy() {\n if (this.loopId) cancelAnimationFrame(this.loopId);\n this.loopId = null;\n window.removeEventListener(\"keydown\", this.handleKey.bind(this));\n this.canvas.remove();\n }\n}\n\nexport const SnakeGame: GamePlugin = {\n id: \"snake\",\n name: \"Snake\",\n description: \"Classic Snake Game\",\n\n renderMini: (container, state) => new SnakeInstance(container, state),\n renderFull: (container, state) => new SnakeInstance(container, state),\n};\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkSSP4S4NY_cjs = require('../chunk-SSP4S4NY.cjs');
|
|
4
|
+
var chunkMAWVAR3Q_cjs = require('../chunk-MAWVAR3Q.cjs');
|
|
5
|
+
require('../chunk-4DE2IREA.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "PortalSystem", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkSSP4S4NY_cjs.PortalSystem; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "LoadingEngine", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkMAWVAR3Q_cjs.LoadingEngine; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "StateManager", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkMAWVAR3Q_cjs.StateManager; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "createLoadingInteraction", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkMAWVAR3Q_cjs.createLoadingInteraction; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "stateManager", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkMAWVAR3Q_cjs.stateManager; }
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
30
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { G as GameState, I as InteractionMode } from '../types-vBwPFyxq.cjs';
|
|
2
|
+
export { D as DoodleConfig, g as DoodleInstance, h as DoodlePlugin, F as Fact, d as FactsConfig, e as FactsInstance, f as FactsPlugin, b as GameInstance, c as GamePlugin, a as InteractionConfig } from '../types-vBwPFyxq.cjs';
|
|
3
|
+
export { L as LoadingEngine, c as createLoadingInteraction } from '../engine-DdHCpfbk.cjs';
|
|
4
|
+
|
|
5
|
+
declare class StateManager {
|
|
6
|
+
private static instance;
|
|
7
|
+
private constructor();
|
|
8
|
+
static getInstance(): StateManager;
|
|
9
|
+
getGameState(gameId: string): Partial<GameState> | null;
|
|
10
|
+
saveGameState(gameId: string, state: Partial<GameState>): void;
|
|
11
|
+
getPreferredMode(): InteractionMode | null;
|
|
12
|
+
savePreferredMode(mode: InteractionMode): void;
|
|
13
|
+
}
|
|
14
|
+
declare const stateManager: StateManager;
|
|
15
|
+
|
|
16
|
+
declare class PortalSystem {
|
|
17
|
+
private overlay;
|
|
18
|
+
constructor();
|
|
19
|
+
open(contentRenderer: (container: HTMLElement) => void, onClose: () => void): void;
|
|
20
|
+
close(): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { GameState, InteractionMode, PortalSystem, StateManager, stateManager };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { G as GameState, I as InteractionMode } from '../types-vBwPFyxq.js';
|
|
2
|
+
export { D as DoodleConfig, g as DoodleInstance, h as DoodlePlugin, F as Fact, d as FactsConfig, e as FactsInstance, f as FactsPlugin, b as GameInstance, c as GamePlugin, a as InteractionConfig } from '../types-vBwPFyxq.js';
|
|
3
|
+
export { L as LoadingEngine, c as createLoadingInteraction } from '../engine--hGQ4LNR.js';
|
|
4
|
+
|
|
5
|
+
declare class StateManager {
|
|
6
|
+
private static instance;
|
|
7
|
+
private constructor();
|
|
8
|
+
static getInstance(): StateManager;
|
|
9
|
+
getGameState(gameId: string): Partial<GameState> | null;
|
|
10
|
+
saveGameState(gameId: string, state: Partial<GameState>): void;
|
|
11
|
+
getPreferredMode(): InteractionMode | null;
|
|
12
|
+
savePreferredMode(mode: InteractionMode): void;
|
|
13
|
+
}
|
|
14
|
+
declare const stateManager: StateManager;
|
|
15
|
+
|
|
16
|
+
declare class PortalSystem {
|
|
17
|
+
private overlay;
|
|
18
|
+
constructor();
|
|
19
|
+
open(contentRenderer: (container: HTMLElement) => void, onClose: () => void): void;
|
|
20
|
+
close(): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { GameState, InteractionMode, PortalSystem, StateManager, stateManager };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkJG5ZMB2Y_cjs = require('../chunk-JG5ZMB2Y.cjs');
|
|
4
|
+
require('../chunk-4DE2IREA.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "BasicDoodle", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkJG5ZMB2Y_cjs.BasicDoodle; }
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=basic-canvas.cjs.map
|
|
13
|
+
//# sourceMappingURL=basic-canvas.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"basic-canvas.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"basic-canvas.js"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkJG5ZMB2Y_cjs = require('../chunk-JG5ZMB2Y.cjs');
|
|
4
|
+
require('../chunk-4DE2IREA.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "BasicDoodle", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkJG5ZMB2Y_cjs.BasicDoodle; }
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=index.cjs.map
|
|
13
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as InteractionConfig, I as InteractionMode } from './types-vBwPFyxq.js';
|
|
2
|
+
|
|
3
|
+
declare class LoadingEngine {
|
|
4
|
+
private config;
|
|
5
|
+
private container;
|
|
6
|
+
private currentInstance;
|
|
7
|
+
private activeMode;
|
|
8
|
+
constructor(container: HTMLElement, config: InteractionConfig);
|
|
9
|
+
init(): void;
|
|
10
|
+
setMode(mode: InteractionMode): void;
|
|
11
|
+
private render;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
declare function createLoadingInteraction(container: HTMLElement, config: InteractionConfig): LoadingEngine;
|
|
15
|
+
|
|
16
|
+
export { LoadingEngine as L, createLoadingInteraction as c };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as InteractionConfig, I as InteractionMode } from './types-vBwPFyxq.cjs';
|
|
2
|
+
|
|
3
|
+
declare class LoadingEngine {
|
|
4
|
+
private config;
|
|
5
|
+
private container;
|
|
6
|
+
private currentInstance;
|
|
7
|
+
private activeMode;
|
|
8
|
+
constructor(container: HTMLElement, config: InteractionConfig);
|
|
9
|
+
init(): void;
|
|
10
|
+
setMode(mode: InteractionMode): void;
|
|
11
|
+
private render;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
declare function createLoadingInteraction(container: HTMLElement, config: InteractionConfig): LoadingEngine;
|
|
15
|
+
|
|
16
|
+
export { LoadingEngine as L, createLoadingInteraction as c };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5AUPIR2C_cjs = require('../chunk-5AUPIR2C.cjs');
|
|
4
|
+
require('../chunk-4DE2IREA.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "DevTipsFacts", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunk5AUPIR2C_cjs.DevTipsFacts; }
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=dev-tips.cjs.map
|
|
13
|
+
//# sourceMappingURL=dev-tips.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"dev-tips.cjs"}
|