samengine 1.9.1 → 1.10.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.
Files changed (93) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +168 -0
  3. package/dist/config/buildconfig.d.ts +146 -0
  4. package/dist/config/buildconfig.js +115 -0
  5. package/dist/config/index.d.ts +9 -0
  6. package/dist/config/index.js +1 -0
  7. package/dist/core.d.ts +17 -0
  8. package/dist/core.js +24 -0
  9. package/dist/html.d.ts +29 -0
  10. package/dist/html.js +20 -0
  11. package/dist/input.d.ts +51 -0
  12. package/dist/input.js +44 -3
  13. package/dist/keys.d.ts +6 -0
  14. package/dist/keys.js +6 -2
  15. package/dist/logger.d.ts +8 -0
  16. package/dist/logger.js +8 -1
  17. package/dist/nonbrowser/getversion.d.ts +13 -0
  18. package/dist/nonbrowser/getversion.js +35 -0
  19. package/dist/nonbrowser/ghresolver.d.ts +1 -0
  20. package/dist/nonbrowser/ghresolver.js +7 -0
  21. package/dist/nonbrowser/index.d.ts +9 -0
  22. package/dist/nonbrowser/index.js +9 -0
  23. package/dist/nonbrowser/internal/buildhelper.d.ts +42 -0
  24. package/dist/nonbrowser/internal/buildhelper.js +144 -0
  25. package/dist/nonbrowser/internal/cli/argparser.d.ts +20 -0
  26. package/dist/nonbrowser/internal/cli/argparser.js +36 -0
  27. package/dist/nonbrowser/internal/cli/main.d.ts +13 -0
  28. package/dist/nonbrowser/internal/cli/main.js +262 -0
  29. package/dist/nonbrowser/internal/config.d.ts +9 -0
  30. package/dist/nonbrowser/internal/config.js +40 -0
  31. package/dist/nonbrowser/internal/exporthtml.d.ts +37 -0
  32. package/dist/nonbrowser/internal/exporthtml.js +622 -0
  33. package/dist/nonbrowser/internal/projcreator/downloadZip.d.ts +4 -0
  34. package/dist/nonbrowser/internal/projcreator/downloadZip.js +83 -0
  35. package/dist/nonbrowser/internal/projcreator/main.d.ts +1 -0
  36. package/dist/nonbrowser/internal/projcreator/main.js +81 -0
  37. package/dist/nonbrowser/utils.d.ts +8 -0
  38. package/dist/nonbrowser/utils.js +18 -0
  39. package/dist/physics/collision.d.ts +33 -0
  40. package/dist/physics/collision.js +27 -0
  41. package/dist/physics/physicsEngine.d.ts +18 -0
  42. package/dist/physics/physicsEngine.js +18 -0
  43. package/dist/physics/physicsObject.d.ts +20 -0
  44. package/dist/physics/physicsObject.js +20 -0
  45. package/dist/renderer.d.ts +78 -0
  46. package/dist/renderer.js +72 -9
  47. package/dist/samegui/index.d.ts +29 -0
  48. package/dist/samegui/index.js +26 -0
  49. package/dist/save.d.ts +12 -0
  50. package/dist/save.js +10 -0
  51. package/dist/sound/audioplayer.d.ts +39 -0
  52. package/dist/sound/audioplayer.js +39 -5
  53. package/dist/storage/index.d.ts +40 -2
  54. package/dist/storage/index.js +34 -3
  55. package/dist/text/index.d.ts +14 -0
  56. package/dist/text/index.js +58 -0
  57. package/dist/texture.d.ts +100 -0
  58. package/dist/texture.js +75 -41
  59. package/dist/types/button.d.ts +25 -0
  60. package/dist/types/button.js +22 -0
  61. package/dist/types/circle.d.ts +26 -0
  62. package/dist/types/circle.js +21 -7
  63. package/dist/types/color.d.ts +17 -0
  64. package/dist/types/color.js +11 -1
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/types/index.js +1 -1
  67. package/dist/types/rectangle.d.ts +29 -0
  68. package/dist/types/rectangle.js +23 -7
  69. package/dist/types/triangle.d.ts +23 -0
  70. package/dist/types/triangle.js +20 -6
  71. package/dist/types/vector2d.d.ts +42 -0
  72. package/dist/types/vector2d.js +39 -11
  73. package/dist/types/vector3d.d.ts +38 -0
  74. package/dist/types/vector3d.js +35 -11
  75. package/dist/utils/index.d.ts +11 -4
  76. package/dist/utils/index.js +11 -4
  77. package/dist/utils/logger/index.d.ts +24 -0
  78. package/dist/utils/logger/index.js +44 -0
  79. package/dist/utils/math.d.ts +18 -0
  80. package/dist/utils/math.js +18 -4
  81. package/package.json +36 -11
  82. package/dist/utils/csv/index.d.ts +0 -3
  83. package/dist/utils/csv/index.js +0 -2
  84. package/dist/utils/csv/parser.d.ts +0 -25
  85. package/dist/utils/csv/parser.js +0 -212
  86. package/dist/utils/csv/stringifier.d.ts +0 -30
  87. package/dist/utils/csv/stringifier.js +0 -130
  88. package/dist/utils/csv/types.d.ts +0 -63
  89. package/dist/utils/csv/types.js +0 -1
  90. package/dist/utils/jsonc-parser.d.ts +0 -4
  91. package/dist/utils/jsonc-parser.js +0 -166
  92. package/dist/utils/markdown.d.ts +0 -41
  93. package/dist/utils/markdown.js +0 -699
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Shadowdara
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Samengine 🎮
2
2
 
3
+ [![Build Packages Test](https://github.com/ShadowDara/samengine/actions/workflows/package-build-test.yml/badge.svg)](https://github.com/ShadowDara/samengine/actions/workflows/package-build-test.yml)
4
+ [![Tauri Release (Webtools Desktop)](https://github.com/ShadowDara/samengine/actions/workflows/tauri-release.yml/badge.svg)](https://github.com/ShadowDara/samengine/actions/workflows/tauri-release.yml)
5
+ [![Release Samtool](https://github.com/ShadowDara/samengine/actions/workflows/release-samtool.yml/badge.svg)](https://github.com/ShadowDara/samengine/actions/workflows/release-samtool.yml)
6
+
3
7
  A lightweight, TypeScript-first web game engine framework for building
4
8
  2D games *and maybe 3D Games in the Future*.
5
9
 
@@ -181,6 +185,170 @@ MIT
181
185
  The tags which are ending with `-build` are for the `samengine-build` Tool and the
182
186
  which end with `-cli` are for the `samengine-cli` package.
183
187
 
188
+
189
+ # Samengine CLI Tools
190
+
191
+ Build, export, and development-server tooling for games built with
192
+ [samengine](https://github.com/ShadowDara/samengine).
193
+
194
+ The package provides the `samengine-build` CLI. It bundles the code from the
195
+ `game` folder, generates a playable `index.html`, copies or embeds assets from
196
+ `resources`, and starts a local development server with automatic rebuilds in
197
+ development mode.
198
+
199
+ ## What This Package Does
200
+
201
+ - Creates new game projects with `--new` or `--new-empty`.
202
+ - Loads `samengine.config.ts` and uses it as the source of truth for build
203
+ options.
204
+ - Bundles the game entry from `game/<entryname>` with esbuild.
205
+ - Generates the HTML start page with title, description, author, version,
206
+ optional fullscreen button, optional settings menu, and Markdown notes.
207
+ - Copies resources from `resources` to `dist/resources` in normal multi-file
208
+ builds.
209
+ - Can embed used resources directly into the generated HTML as Data URIs in
210
+ single-file mode.
211
+ - Minifies release builds.
212
+ - Starts a local HTTP server in development mode and rebuilds when files in
213
+ `game`, `resources`, or `samengine.config.ts` change.
214
+
215
+ ## Installation
216
+
217
+ ```bash
218
+ npm install samengine
219
+ ```
220
+
221
+ Add these scripts to the `package.json` of your game project:
222
+
223
+ ```json
224
+ {
225
+ "scripts": {
226
+ "dev": "samengine",
227
+ "build": "samengine --release"
228
+ }
229
+ }
230
+ ```
231
+
232
+ You can also run the CLI directly with `npx samengine`.
233
+
234
+ ## Project Structure
235
+
236
+ ```text
237
+ game/
238
+ main.ts Game entry point
239
+ resources/
240
+ ... Images, audio, JSON, and other assets
241
+ samengine.config.ts Build configuration
242
+ dist/
243
+ index.html Generated build output
244
+ main.js Bundled game, except in single-file mode
245
+ ```
246
+
247
+ ## CLI
248
+
249
+ ```bash
250
+ samengine
251
+ ```
252
+
253
+ Runs a development build, writes `dist/index.html`, starts the development
254
+ server, and watches project files.
255
+
256
+ ```bash
257
+ samengine --release
258
+ ```
259
+
260
+ Runs a release build. The output directory is recreated, JavaScript and HTML are
261
+ minified, and no development server is started.
262
+
263
+ ```bash
264
+ samengine --new MyGame
265
+ ```
266
+
267
+ Creates a new project with an example game.
268
+
269
+ ```bash
270
+ samengine --new-empty MyGame
271
+ ```
272
+
273
+ Creates a new project with an empty starter game.
274
+
275
+ ## Configuration
276
+
277
+ A typical `samengine.config.ts` looks like this:
278
+
279
+ ```ts
280
+ import type { buildconfig } from "samengine/config";
281
+ import { new_buildconfig } from "samengine/config";
282
+
283
+ export default function defineConfig(): buildconfig {
284
+ const config = new_buildconfig();
285
+ config.title = "My Game";
286
+ config.description = "Short game description";
287
+ config.gameauthor = "Your Name";
288
+ return config;
289
+ }
290
+ ```
291
+
292
+ Important options:
293
+
294
+ - `title`: Browser title and start-screen title.
295
+ - `description`: Description shown on the start screen.
296
+ - `version`: Game version shown on the start screen.
297
+ - `entryname`: Entry file inside the `game` folder, defaults to `main`.
298
+ - `outdir`: Build output folder, defaults to `dist`.
299
+ - `show_fullscreen_button`: Adds a fullscreen button to the generated page.
300
+ - `enable_audio`: Unlocks the browser AudioContext after the start click.
301
+ - `markdown_notes`: Shows collapsible Markdown notes before the game starts.
302
+ - `htmlMenu`: Configures an optional settings menu.
303
+ - `devMode.singlefile`: Generates a single HTML file in development mode.
304
+ - `releaseMode.singlefile`: Generates a single HTML file in release mode.
305
+ - `dev_server_port`: Initial port for the local development server.
306
+
307
+ ## Single-File Builds
308
+
309
+ When `devMode.singlefile` or `releaseMode.singlefile` is enabled, the tool reads
310
+ the bundled JavaScript and scans the `resources` folder. Assets whose filename or
311
+ relative path appears in the bundle are written into the HTML file as Base64
312
+ Data URIs. In the browser, they are available through `window.__getResource(path)`
313
+ and `window.__loadResource(path)`.
314
+
315
+ ## Code Exports
316
+
317
+ The main package entry exports build types and factory functions:
318
+
319
+ ```ts
320
+ import {
321
+ new_buildconfig,
322
+ newHTMLMenu,
323
+ newMarkdownStyle,
324
+ type buildconfig,
325
+ } from "samengine/config";
326
+ ```
327
+
328
+ Additional utilities are available from `samengine/nonbrowser`:
329
+
330
+ ```ts
331
+ import { compressHTML } from "samengine/nonbrowser";
332
+ ```
333
+
334
+ Learn more about samengine on
335
+ [GitHub](https://github.com/ShadowDara/samengine) or
336
+ [NPM](https://www.npmjs.com/package/samengine).
337
+
338
+
339
+ ## Project Templates
340
+
341
+ Project Templates can be found [here](https://github.com/ShadowDara/samengine-project-templates)
342
+
343
+ ## Webtools
344
+
345
+ - releases are made on tags which are starting with `webtools-v*`
346
+
347
+ ## IGN
348
+
349
+ Git ignore Adder Infos are [here](crates/easy-git-ignore/README.md)
350
+
351
+
184
352
  <!--
185
353
 
186
354
  IDEAS
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Central build configuration types and defaults for samengine-build.
3
+ *
4
+ * Game projects usually import `new_buildconfig` in `samengine.config.ts`,
5
+ * change the fields they need, and return the resulting object. The CLI loads
6
+ * that object before every build and uses it to decide how HTML, assets,
7
+ * development mode, and release mode should behave.
8
+ *
9
+ * Documentation:
10
+ * https://samengine.vercel.app/docs/config
11
+ */
12
+ export interface buildconfig {
13
+ /** Custom HTML inserted into the generated document `<head>`. */
14
+ htmlhead: string;
15
+ /** Game title used in the browser tab and on the generated start screen. */
16
+ title: string;
17
+ /** Short description shown on the start screen. */
18
+ description: string;
19
+ /** Game version shown on the start screen. */
20
+ version: string;
21
+ /** Adds the generated fullscreen button when enabled. */
22
+ show_fullscreen_button: boolean;
23
+ /** Entry file name inside the `game` folder, usually `main`. */
24
+ entryname: string;
25
+ /** Output folder for the generated build, usually `dist`. */
26
+ outdir: string;
27
+ /** Optional collapsible Markdown notes shown before the game starts. */
28
+ markdown_notes: Paragraph[];
29
+ /** Author name written to the start screen and generated build comments. */
30
+ gameauthor: string;
31
+ /** First port tried by the local development server. */
32
+ dev_server_port: number;
33
+ /** Options for samengine UI helpers outside the game canvas. */
34
+ samegui: SameGUI;
35
+ /** Unlocks the browser AudioContext after the player clicks the start button. */
36
+ enable_audio: boolean;
37
+ /** Optional HTML settings menu and start-button styling. */
38
+ htmlMenu: HTMLMenu;
39
+ /** Reserved flag for mobile CSS behavior. It is not currently consumed. */
40
+ enable_mobile_css: boolean;
41
+ /** Build behavior used by the development command. */
42
+ devMode: profile;
43
+ /** Build behavior used by the release command. */
44
+ releaseMode: profile;
45
+ }
46
+ /** Options for samengine GUI helpers that may be rendered outside the game. */
47
+ export interface SameGUI {
48
+ /** Shows the samengine GUI button when the engine supports it. */
49
+ show_button: boolean;
50
+ }
51
+ /** Creates default options for `samegui`. */
52
+ export declare function newSameGUI(): SameGUI;
53
+ /** A single Markdown note shown on the generated start screen. */
54
+ export interface Paragraph {
55
+ /** The visible summary/title of the collapsible note. */
56
+ title: string;
57
+ /** Markdown content rendered inside the note. */
58
+ content: string;
59
+ /** Per-note color styling. */
60
+ style: MarkdownStyle;
61
+ }
62
+ /** Color values used by generated Markdown notes. */
63
+ export interface MarkdownStyle {
64
+ /** Text color of the note. */
65
+ color: string;
66
+ /** Background color of the note. */
67
+ bg: string;
68
+ }
69
+ /** Creates the default Markdown note colors. */
70
+ export declare function newMarkdownStyle(): MarkdownStyle;
71
+ /**
72
+ * Creates a complete build configuration with safe defaults.
73
+ *
74
+ * This is the recommended starting point for `samengine.config.ts`. Keeping
75
+ * defaults centralized here makes new options easier to add without forcing
76
+ * every game project to define every field manually.
77
+ */
78
+ export declare function new_buildconfig(): buildconfig;
79
+ /** Default favicon as SVG text. `new_buildconfig` embeds it as a Data URI. */
80
+ export declare const svgfile = "<svg width=\"512\" height=\"512\" viewBox=\"0 0 512 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <style>\n .bg {\n fill: #0f1115;\n }\n .shape {\n fill: none;\n stroke: #e6e6e6;\n stroke-width: 18;\n stroke-linecap: round;\n stroke-linejoin: round;\n }\n .fill {\n fill: #e6e6e6;\n }\n </style>\n\n <!-- Background -->\n <rect width=\"512\" height=\"512\" class=\"bg\"/>\n\n <!-- Outer hexagon (tech / engine frame) -->\n <path class=\"shape\"\n d=\"M256 80 L390 160 L390 352 L256 432 L122 352 L122 160 Z\" />\n\n <!-- Inner rotated square (system core) -->\n <rect x=\"176\" y=\"176\" width=\"160\" height=\"160\"\n class=\"shape\" transform=\"rotate(45 256 256)\" />\n\n <!-- Core node -->\n <circle cx=\"256\" cy=\"256\" r=\"18\" class=\"fill\"/>\n\n <!-- Connection points -->\n <circle cx=\"256\" cy=\"110\" r=\"10\" class=\"fill\"/>\n <circle cx=\"256\" cy=\"402\" r=\"10\" class=\"fill\"/>\n <circle cx=\"110\" cy=\"256\" r=\"10\" class=\"fill\"/>\n <circle cx=\"402\" cy=\"256\" r=\"10\" class=\"fill\"/>\n</svg>";
81
+ /** One selectable value in an HTML menu setting. */
82
+ export interface HTMLMenuSettingOption {
83
+ /** Button label shown to the player. */
84
+ text: string;
85
+ /** Value written into `window.__GAMESETTINGS__[setting.id]`. */
86
+ value: string;
87
+ }
88
+ /** A group of related settings, such as graphics quality or sound mode. */
89
+ export interface HTMLMenuSetting {
90
+ /** Technical key used in `window.__GAMESETTINGS__`. */
91
+ id: string;
92
+ /** Visible title displayed above the option buttons. */
93
+ title: string;
94
+ /** Initial value selected when the page loads. */
95
+ default_value: string;
96
+ /** All selectable values for this setting. */
97
+ options: HTMLMenuSettingOption[];
98
+ }
99
+ /** Colors used by the generated start button and settings menu. */
100
+ export interface HTMLMenuStyle {
101
+ bgcolor: string;
102
+ color: string;
103
+ settingsmenu_popup_bgcolor: string;
104
+ settingsmenu_bgcolor: string;
105
+ settingsmenu_button: string;
106
+ settingsmenu_button_clicked: string;
107
+ settingsmenu_button_txt: string;
108
+ settingsmenu_button_txt_hover: string;
109
+ settingsmenu_button_hover: string;
110
+ startbutton_bgcolor: string;
111
+ startbutton_bgc_hover: string;
112
+ }
113
+ /** Customizable text used by generated HTML menu controls. */
114
+ export interface HTMLMenuText {
115
+ /** Label of the button that starts the game. */
116
+ startbutton: string;
117
+ }
118
+ /**
119
+ * Optional generated settings menu.
120
+ *
121
+ * Selected values are exposed globally, for example:
122
+ * `window.__GAMESETTINGS__.graphics` or `window.__GAMESETTINGS__.sound`.
123
+ */
124
+ export interface HTMLMenu {
125
+ /** Enables the generated settings menu. */
126
+ enable_menu: boolean;
127
+ /** Settings groups rendered inside the popup. */
128
+ settings: HTMLMenuSetting[];
129
+ /** Visual styling for the menu. */
130
+ style: HTMLMenuStyle;
131
+ /** Customizable visible text. */
132
+ text: HTMLMenuText;
133
+ }
134
+ /** Creates the default configuration for the optional HTML settings menu. */
135
+ export declare function newHTMLMenu(): HTMLMenu;
136
+ /** Build profile used by development and release modes. */
137
+ export interface profile {
138
+ /** Whether the profile represents a release build. */
139
+ release: boolean;
140
+ /** Embeds the bundle and used resources into one generated HTML file. */
141
+ singlefile: boolean;
142
+ }
143
+ /** Default development profile: multi-file output, no release minification. */
144
+ export declare function newDevProfile(): profile;
145
+ /** Default release profile: release mode enabled, still multi-file by default. */
146
+ export declare function newReleaseProfile(): profile;
@@ -0,0 +1,115 @@
1
+ /** Creates default options for `samegui`. */
2
+ export function newSameGUI() {
3
+ return {
4
+ show_button: false,
5
+ };
6
+ }
7
+ /** Creates the default Markdown note colors. */
8
+ export function newMarkdownStyle() {
9
+ return {
10
+ color: "#38bdf8",
11
+ bg: "#0f172a",
12
+ };
13
+ }
14
+ /**
15
+ * Creates a complete build configuration with safe defaults.
16
+ *
17
+ * This is the recommended starting point for `samengine.config.ts`. Keeping
18
+ * defaults centralized here makes new options easier to add without forcing
19
+ * every game project to define every field manually.
20
+ */
21
+ export function new_buildconfig() {
22
+ return {
23
+ title: "My new Game",
24
+ description: "Your Game Description",
25
+ version: "Your Game Version",
26
+ show_fullscreen_button: true,
27
+ entryname: "main",
28
+ outdir: "dist",
29
+ markdown_notes: [],
30
+ gameauthor: "DEV",
31
+ htmlhead: `<link rel="icon" href="data:image/svg+xml;base64,${btoa(svgfile)}">`,
32
+ dev_server_port: 3001,
33
+ samegui: newSameGUI(),
34
+ enable_audio: false,
35
+ htmlMenu: newHTMLMenu(),
36
+ enable_mobile_css: false,
37
+ devMode: newDevProfile(),
38
+ releaseMode: newReleaseProfile(),
39
+ };
40
+ }
41
+ /** Default favicon as SVG text. `new_buildconfig` embeds it as a Data URI. */
42
+ export const svgfile = `<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
43
+ <style>
44
+ .bg {
45
+ fill: #0f1115;
46
+ }
47
+ .shape {
48
+ fill: none;
49
+ stroke: #e6e6e6;
50
+ stroke-width: 18;
51
+ stroke-linecap: round;
52
+ stroke-linejoin: round;
53
+ }
54
+ .fill {
55
+ fill: #e6e6e6;
56
+ }
57
+ </style>
58
+
59
+ <!-- Background -->
60
+ <rect width="512" height="512" class="bg"/>
61
+
62
+ <!-- Outer hexagon (tech / engine frame) -->
63
+ <path class="shape"
64
+ d="M256 80 L390 160 L390 352 L256 432 L122 352 L122 160 Z" />
65
+
66
+ <!-- Inner rotated square (system core) -->
67
+ <rect x="176" y="176" width="160" height="160"
68
+ class="shape" transform="rotate(45 256 256)" />
69
+
70
+ <!-- Core node -->
71
+ <circle cx="256" cy="256" r="18" class="fill"/>
72
+
73
+ <!-- Connection points -->
74
+ <circle cx="256" cy="110" r="10" class="fill"/>
75
+ <circle cx="256" cy="402" r="10" class="fill"/>
76
+ <circle cx="110" cy="256" r="10" class="fill"/>
77
+ <circle cx="402" cy="256" r="10" class="fill"/>
78
+ </svg>`;
79
+ /** Creates the default configuration for the optional HTML settings menu. */
80
+ export function newHTMLMenu() {
81
+ return {
82
+ enable_menu: false,
83
+ settings: [],
84
+ style: {
85
+ bgcolor: "#0f172a",
86
+ color: "white",
87
+ settingsmenu_popup_bgcolor: "rgba(0,0,0,0.85)",
88
+ settingsmenu_bgcolor: "#111827",
89
+ settingsmenu_button: "#1f2937",
90
+ settingsmenu_button_clicked: "#22c55e",
91
+ settingsmenu_button_txt: "#ffffff",
92
+ settingsmenu_button_txt_hover: "",
93
+ settingsmenu_button_hover: "",
94
+ startbutton_bgcolor: "#22c55e",
95
+ startbutton_bgc_hover: "#16a34a",
96
+ },
97
+ text: {
98
+ startbutton: "Start",
99
+ }
100
+ };
101
+ }
102
+ /** Default development profile: multi-file output, no release minification. */
103
+ export function newDevProfile() {
104
+ return {
105
+ release: false,
106
+ singlefile: false,
107
+ };
108
+ }
109
+ /** Default release profile: release mode enabled, still multi-file by default. */
110
+ export function newReleaseProfile() {
111
+ return {
112
+ release: true,
113
+ singlefile: false,
114
+ };
115
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Public package API for configuration files.
3
+ *
4
+ * Game projects import these types and factory functions from
5
+ * `samengine-build` when defining `samengine.config.ts`. The executable CLI is
6
+ * separate from this entry point and lives under `src/cli`.
7
+ */
8
+ export type { buildconfig, Paragraph, MarkdownStyle, SameGUI, HTMLMenuSettingOption, HTMLMenuSetting, HTMLMenu, HTMLMenuStyle, HTMLMenuText, } from "./buildconfig.js";
9
+ export { newSameGUI, new_buildconfig, svgfile, newHTMLMenu, newDevProfile, newReleaseProfile, newMarkdownStyle } from "./buildconfig.js";
@@ -0,0 +1 @@
1
+ export { newSameGUI, new_buildconfig, svgfile, newHTMLMenu, newDevProfile, newReleaseProfile, newMarkdownStyle } from "./buildconfig.js";
package/dist/core.d.ts CHANGED
@@ -1,3 +1,20 @@
1
1
  type GameLoop = (dt: number) => void;
2
+ /**
3
+ * Starts the central game loop of samengine.
4
+ *
5
+ * The `start` callback is executed once before the first frame. Use it for
6
+ * setup work such as creating objects, loading initial state, or configuring
7
+ * input. After that, `gameLoop` is called every animation frame with `dt`, the
8
+ * elapsed time in seconds since the previous frame.
9
+ *
10
+ * `dt` should be used for frame-rate independent movement:
11
+ *
12
+ * ```ts
13
+ * player.x += player.speed * dt;
14
+ * ```
15
+ *
16
+ * @param start Function that runs once before the loop starts.
17
+ * @param gameLoop Function that runs every frame. Receives delta time in seconds.
18
+ */
2
19
  export declare function startEngine(start: () => void, gameLoop: GameLoop): void;
3
20
  export {};