samengine 1.9.1 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) 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 +18 -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 +265 -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/utils.d.ts +8 -0
  34. package/dist/nonbrowser/utils.js +18 -0
  35. package/dist/physics/collision.d.ts +33 -0
  36. package/dist/physics/collision.js +27 -0
  37. package/dist/physics/physicsEngine.d.ts +18 -0
  38. package/dist/physics/physicsEngine.js +18 -0
  39. package/dist/physics/physicsObject.d.ts +20 -0
  40. package/dist/physics/physicsObject.js +20 -0
  41. package/dist/renderer.d.ts +78 -0
  42. package/dist/renderer.js +72 -9
  43. package/dist/samegui/index.d.ts +29 -0
  44. package/dist/samegui/index.js +26 -0
  45. package/dist/save.d.ts +12 -0
  46. package/dist/save.js +10 -0
  47. package/dist/sound/audioplayer.d.ts +39 -0
  48. package/dist/sound/audioplayer.js +39 -5
  49. package/dist/storage/index.d.ts +40 -2
  50. package/dist/storage/index.js +34 -3
  51. package/dist/text/index.d.ts +14 -0
  52. package/dist/text/index.js +58 -0
  53. package/dist/texture.d.ts +100 -0
  54. package/dist/texture.js +75 -41
  55. package/dist/types/button.d.ts +25 -0
  56. package/dist/types/button.js +22 -0
  57. package/dist/types/circle.d.ts +26 -0
  58. package/dist/types/circle.js +21 -7
  59. package/dist/types/color.d.ts +17 -0
  60. package/dist/types/color.js +11 -1
  61. package/dist/types/index.d.ts +1 -1
  62. package/dist/types/index.js +1 -1
  63. package/dist/types/rectangle.d.ts +29 -0
  64. package/dist/types/rectangle.js +23 -7
  65. package/dist/types/triangle.d.ts +23 -0
  66. package/dist/types/triangle.js +20 -6
  67. package/dist/types/vector2d.d.ts +42 -0
  68. package/dist/types/vector2d.js +39 -11
  69. package/dist/types/vector3d.d.ts +38 -0
  70. package/dist/types/vector3d.js +35 -11
  71. package/dist/utils/index.d.ts +11 -4
  72. package/dist/utils/index.js +11 -4
  73. package/dist/utils/logger/index.d.ts +24 -0
  74. package/dist/utils/logger/index.js +44 -0
  75. package/dist/utils/math.d.ts +18 -0
  76. package/dist/utils/math.js +18 -4
  77. package/package.json +29 -11
  78. package/dist/utils/csv/index.d.ts +0 -3
  79. package/dist/utils/csv/index.js +0 -2
  80. package/dist/utils/csv/parser.d.ts +0 -25
  81. package/dist/utils/csv/parser.js +0 -212
  82. package/dist/utils/csv/stringifier.d.ts +0 -30
  83. package/dist/utils/csv/stringifier.js +0 -130
  84. package/dist/utils/csv/types.d.ts +0 -63
  85. package/dist/utils/csv/types.js +0 -1
  86. package/dist/utils/jsonc-parser.d.ts +0 -4
  87. package/dist/utils/jsonc-parser.js +0 -166
  88. package/dist/utils/markdown.d.ts +0 -41
  89. package/dist/utils/markdown.js +0 -699
@@ -1,130 +0,0 @@
1
- const DEFAULT_ESCAPE_RULES = {
2
- quote: true,
3
- newline: true,
4
- delimiter: true,
5
- backslash: false,
6
- nullByte: false,
7
- };
8
- const DEFAULT_OPTIONS = {
9
- delimiter: ",",
10
- quoteChar: '"',
11
- lineEnding: "\r\n",
12
- escapeRules: DEFAULT_ESCAPE_RULES,
13
- alwaysQuote: false,
14
- columns: [],
15
- writeHeader: true,
16
- nullAsEmpty: true,
17
- };
18
- /**
19
- * Serialisiert JavaScript-Objekte zu einem validen CSV-String.
20
- *
21
- * Unterstützt:
22
- * - RFC 4180 Doppelquote-Escaping: " → ""
23
- * - Optionales Backslash-Escaping: \ → \\
24
- * - Optionales Null-Byte-Escaping: \0 → \\0
25
- * - Automatisches Quoting bei Sonderzeichen
26
- * - Konfigurierbare Spaltenreihenfolge
27
- * - Wahlweise immer quoten (alwaysQuote)
28
- */
29
- export class CSVStringifier {
30
- constructor(options = {}) {
31
- this.opts = {
32
- ...DEFAULT_OPTIONS,
33
- ...options,
34
- escapeRules: {
35
- ...DEFAULT_ESCAPE_RULES,
36
- ...(options.escapeRules ?? {}),
37
- },
38
- };
39
- this.escapeRules = this.opts.escapeRules;
40
- if (this.opts.delimiter.length !== 1) {
41
- throw new Error("delimiter muss genau ein Zeichen lang sein.");
42
- }
43
- if (this.opts.quoteChar.length !== 1) {
44
- throw new Error("quoteChar muss genau ein Zeichen lang sein.");
45
- }
46
- }
47
- /**
48
- * Serialisiert ein Array von Objekten zu einem CSV-String.
49
- */
50
- stringify(records) {
51
- if (records.length === 0)
52
- return "";
53
- const columns = this.opts.columns.length > 0
54
- ? this.opts.columns
55
- : Object.keys(records[0]);
56
- const lines = [];
57
- if (this.opts.writeHeader) {
58
- lines.push(columns.map((h) => this.escapeField(h)).join(this.opts.delimiter));
59
- }
60
- for (const record of records) {
61
- const row = columns.map((col) => {
62
- const value = record[col];
63
- if ((value === null || value === undefined) && this.opts.nullAsEmpty) {
64
- return "";
65
- }
66
- return this.escapeField(String(value ?? ""));
67
- });
68
- lines.push(row.join(this.opts.delimiter));
69
- }
70
- return lines.join(this.opts.lineEnding);
71
- }
72
- /**
73
- * Serialisiert ein einzelnes Feld mit korrektem Escaping.
74
- * Öffentlich, damit einzelne Werte unabhängig escaped werden können.
75
- */
76
- escapeField(raw) {
77
- const { delimiter, quoteChar, alwaysQuote } = this.opts;
78
- const rules = this.escapeRules;
79
- let value = raw;
80
- let needsQuoting = alwaysQuote;
81
- // 1. Backslash escapen (muss vor allen anderen stehen)
82
- if (rules.backslash && value.includes("\\")) {
83
- value = value.replace(/\\/g, "\\\\");
84
- needsQuoting = true;
85
- }
86
- // 2. Null-Byte escapen
87
- if (rules.nullByte && value.includes("\0")) {
88
- value = value.replace(/\0/g, "\\0");
89
- needsQuoting = true;
90
- }
91
- // 3. Anführungszeichen escapen (RFC 4180: "" Verdopplung)
92
- if (rules.quote && value.includes(quoteChar)) {
93
- // Needs ES2021
94
- // value = value.replaceAll(quoteChar, quoteChar + quoteChar);
95
- value = value.split(quoteChar).join(quoteChar + quoteChar);
96
- needsQuoting = true;
97
- }
98
- // 4. Zeilenumbrüche → brauchen Quoting
99
- if (rules.newline && (value.includes("\n") || value.includes("\r"))) {
100
- needsQuoting = true;
101
- }
102
- // 5. Trennzeichen im Wert → braucht Quoting
103
- if (rules.delimiter && value.includes(delimiter)) {
104
- needsQuoting = true;
105
- }
106
- if (needsQuoting) {
107
- return `${quoteChar}${value}${quoteChar}`;
108
- }
109
- return value;
110
- }
111
- /**
112
- * Streamt Records zeilenweise als Generator (speicherschonend für große Dateien).
113
- */
114
- *stream(records, columns) {
115
- const { delimiter, lineEnding, writeHeader } = this.opts;
116
- if (writeHeader) {
117
- yield columns.map((h) => this.escapeField(h)).join(delimiter) + lineEnding;
118
- }
119
- for (const record of records) {
120
- const row = columns.map((col) => {
121
- const value = record[col];
122
- if ((value === null || value === undefined) && this.opts.nullAsEmpty) {
123
- return "";
124
- }
125
- return this.escapeField(String(value ?? ""));
126
- });
127
- yield row.join(delimiter) + lineEnding;
128
- }
129
- }
130
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * Regeln, welche Zeichen escaped werden sollen.
3
- */
4
- export interface EscapeRules {
5
- /** Verdoppelt Anführungszeichen innerhalb von Feldern: " → "" */
6
- quote?: boolean;
7
- /** Felder mit Zeilenumbrüchen werden gequotet */
8
- newline?: boolean;
9
- /** Felder, die das Trennzeichen enthalten, werden gequotet */
10
- delimiter?: boolean;
11
- /** Backslashes werden escaped: \ → \\ */
12
- backslash?: boolean;
13
- /** Null-Bytes werden escaped: \0 → \\0 */
14
- nullByte?: boolean;
15
- }
16
- export interface CSVParserOptions {
17
- /** Trennzeichen (Standard: ",") */
18
- delimiter?: string;
19
- /** Anführungszeichen-Zeichen (Standard: '"') */
20
- quoteChar?: string;
21
- /** Escape-Zeichen für Backslash-Escaping (Standard: kein Backslash-Escape) */
22
- escapeChar?: string;
23
- /** Erste Zeile als Header interpretieren (Standard: true) */
24
- hasHeader?: boolean;
25
- /** Führende/nachfolgende Leerzeichen in Feldern trimmen (Standard: false) */
26
- trimFields?: boolean;
27
- /** Leere Zeilen überspringen (Standard: true) */
28
- skipEmptyLines?: boolean;
29
- /** Kommentare überspringen (z. B. "#") — leer = deaktiviert */
30
- commentChar?: string;
31
- }
32
- export interface CSVStringifierOptions {
33
- /** Trennzeichen (Standard: ",") */
34
- delimiter?: string;
35
- /** Anführungszeichen-Zeichen (Standard: '"') */
36
- quoteChar?: string;
37
- /** Zeilenende (Standard: "\r\n" per RFC 4180) */
38
- lineEnding?: "\r\n" | "\n" | "\r";
39
- /** Escape-Regeln */
40
- escapeRules?: EscapeRules;
41
- /** Alle Felder immer quoten, unabhängig vom Inhalt (Standard: false) */
42
- alwaysQuote?: boolean;
43
- /** Spaltenreihenfolge (Standard: Reihenfolge der Keys im ersten Objekt) */
44
- columns?: string[];
45
- /** Header-Zeile schreiben (Standard: true) */
46
- writeHeader?: boolean;
47
- /** Null / undefined als leeres Feld ausgeben (Standard: true) */
48
- nullAsEmpty?: boolean;
49
- }
50
- export interface ParseResult<T = Record<string, string>> {
51
- /** Geparste Datensätze als Array von Objekten */
52
- records: T[];
53
- /** Header-Zeile (falls hasHeader = true) */
54
- headers: string[];
55
- /** Rohe Zeilen als String-Arrays (inkl. Header) */
56
- rawRows: string[][];
57
- /** Warnungen (z. B. ungleich viele Felder) */
58
- warnings: ParseWarning[];
59
- }
60
- export interface ParseWarning {
61
- row: number;
62
- message: string;
63
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export type JSONValue = string | number | boolean | null | JSONValue[] | {
2
- [key: string]: JSONValue;
3
- };
4
- export declare function parseJSONC(input: string): JSONValue;
@@ -1,166 +0,0 @@
1
- // jsonc-parser.ts
2
- // JSON with comments (// and /* */) parser in TypeScript
3
- export function parseJSONC(input) {
4
- let i = 0;
5
- function error(msg) {
6
- throw new SyntaxError(`${msg} at position ${i}`);
7
- }
8
- function peek(offset = 0) {
9
- return input[i + offset];
10
- }
11
- function consume() {
12
- return input[i++];
13
- }
14
- function skipWhitespaceAndComments() {
15
- while (i < input.length) {
16
- // whitespace
17
- if (/\s/.test(peek())) {
18
- i++;
19
- continue;
20
- }
21
- // line comment //
22
- if (peek() === '/' && peek(1) === '/') {
23
- i += 2;
24
- while (i < input.length && peek() !== '\n')
25
- i++;
26
- continue;
27
- }
28
- // block comment /* */
29
- if (peek() === '/' && peek(1) === '*') {
30
- i += 2;
31
- while (i < input.length && !(peek() === '*' && peek(1) === '/')) {
32
- i++;
33
- }
34
- if (i >= input.length)
35
- error("Unterminated block comment");
36
- i += 2;
37
- continue;
38
- }
39
- break;
40
- }
41
- }
42
- function parseValue() {
43
- skipWhitespaceAndComments();
44
- const ch = peek();
45
- if (ch === '"')
46
- return parseString();
47
- if (ch === '{')
48
- return parseObject();
49
- if (ch === '[')
50
- return parseArray();
51
- if (ch === '-' || /[0-9]/.test(ch))
52
- return parseNumber();
53
- if (input.startsWith("true", i)) {
54
- i += 4;
55
- return true;
56
- }
57
- if (input.startsWith("false", i)) {
58
- i += 5;
59
- return false;
60
- }
61
- if (input.startsWith("null", i)) {
62
- i += 4;
63
- return null;
64
- }
65
- error("Unexpected token");
66
- }
67
- function parseString() {
68
- consume(); // "
69
- let result = "";
70
- while (i < input.length) {
71
- const ch = consume();
72
- if (ch === '"')
73
- return result;
74
- if (ch === '\\') {
75
- const next = consume();
76
- if (next === 'n')
77
- result += '\n';
78
- else if (next === 't')
79
- result += '\t';
80
- else if (next === 'r')
81
- result += '\r';
82
- else
83
- result += next;
84
- }
85
- else {
86
- result += ch;
87
- }
88
- }
89
- error("Unterminated string");
90
- }
91
- function parseNumber() {
92
- let num = "";
93
- while (/[-+0-9.eE]/.test(peek())) {
94
- num += consume();
95
- }
96
- const value = Number(num);
97
- if (Number.isNaN(value))
98
- error("Invalid number");
99
- return value;
100
- }
101
- function parseArray() {
102
- consume(); // [
103
- const arr = [];
104
- skipWhitespaceAndComments();
105
- if (peek() === ']') {
106
- consume();
107
- return arr;
108
- }
109
- while (true) {
110
- arr.push(parseValue());
111
- skipWhitespaceAndComments();
112
- const ch = consume();
113
- if (ch === ']')
114
- break;
115
- if (ch !== ',')
116
- error("Expected ',' or ']'");
117
- skipWhitespaceAndComments();
118
- if (peek() === ']') {
119
- consume();
120
- break;
121
- }
122
- }
123
- return arr;
124
- }
125
- function parseObject() {
126
- consume(); // {
127
- const obj = {};
128
- skipWhitespaceAndComments();
129
- if (peek() === '}') {
130
- consume();
131
- return obj;
132
- }
133
- while (true) {
134
- skipWhitespaceAndComments();
135
- const key = parseKey();
136
- skipWhitespaceAndComments();
137
- if (consume() !== ':')
138
- error("Expected ':'");
139
- const value = parseValue();
140
- obj[key] = value;
141
- skipWhitespaceAndComments();
142
- const ch = consume();
143
- if (ch === '}')
144
- break;
145
- if (ch !== ',')
146
- error("Expected ',' or '}'");
147
- skipWhitespaceAndComments();
148
- if (peek() === '}') {
149
- consume();
150
- break;
151
- }
152
- }
153
- return obj;
154
- }
155
- function parseKey() {
156
- skipWhitespaceAndComments();
157
- if (peek() === '"')
158
- return parseString();
159
- error("Keys must be strings in JSONC");
160
- }
161
- const result = parseValue();
162
- skipWhitespaceAndComments();
163
- if (i < input.length)
164
- error("Unexpected trailing input");
165
- return result;
166
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * markdown-parser.ts
3
- * Ein vollständiger Markdown → HTML Parser in TypeScript.
4
- * Unterstützt: Überschriften, Absätze, Fett/Kursiv/Durchgestrichen,
5
- * Inline-Code, Code-Blöcke (mit Sprach-Tag), Blockquotes (verschachtelt),
6
- * geordnete & ungeordnete Listen (verschachtelt), Aufgabenlisten,
7
- * horizontale Linien, Links, Bilder, Tabellen, Fußnoten, HTML-Entities.
8
- */
9
- export interface ParseOptions {
10
- /** Fügt target="_blank" rel="noopener noreferrer" zu externen Links hinzu */
11
- externalLinks?: boolean;
12
- /** Bricht einfache Zeilenumbrüche in <br> um */
13
- breaks?: boolean;
14
- /** Gibt typographische Anführungszeichen zurück (Smartquotes) */
15
- smartypants?: boolean;
16
- /** Sanitisiert rohes HTML im Quelltext */
17
- sanitize?: boolean;
18
- }
19
- /**
20
- * Konvertiert Markdown-Text in HTML.
21
- *
22
- * @param markdown Eingabe-Markdown
23
- * @param options Optionale Parser-Einstellungen
24
- * @returns Gerendertes HTML
25
- *
26
- * @example
27
- * ```ts
28
- * import { parse } from "./markdown-parser";
29
- * const html = parse("# Hallo Welt\n\nDas ist **Markdown**.");
30
- * ```
31
- */
32
- export declare function parse(markdown: string, options?: ParseOptions): string;
33
- /**
34
- * Gibt ein vollständiges HTML-Dokument zurück (optional mit eigenem CSS).
35
- */
36
- export declare function parseToDocument(markdown: string, options?: ParseOptions & {
37
- title?: string;
38
- css?: string;
39
- header?: string;
40
- }): string;
41
- export declare function exportcss(): string;