littlejsengine 1.19.3 → 1.20.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 (50) hide show
  1. package/FAQ.md +841 -820
  2. package/README.md +29 -25
  3. package/dist/littlejs.d.ts +2455 -935
  4. package/dist/littlejs.esm.js +30344 -21110
  5. package/dist/littlejs.esm.min.js +4 -3
  6. package/dist/littlejs.js +30259 -21052
  7. package/dist/littlejs.min.js +2 -2
  8. package/dist/littlejs.release.js +26567 -20455
  9. package/package.json +10 -5
  10. package/plugins/audioEffects.js +28 -24
  11. package/plugins/box2d.js +2516 -2073
  12. package/plugins/drawUtilities.js +206 -31
  13. package/plugins/gltf.js +740 -0
  14. package/plugins/jsconfig.json +19 -0
  15. package/plugins/lightSystem.js +719 -332
  16. package/plugins/math3d.js +58 -17
  17. package/plugins/medalSystem.js +326 -280
  18. package/plugins/newgrounds.js +400 -199
  19. package/plugins/pathFinder.js +208 -175
  20. package/plugins/pluginExport.js +15 -0
  21. package/plugins/postProcess.js +56 -13
  22. package/plugins/render3d.js +1643 -1577
  23. package/plugins/render3dDebug.js +109 -0
  24. package/plugins/render3dExtras.js +1754 -0
  25. package/plugins/render3dVoxels.js +502 -0
  26. package/plugins/textureSheet.js +496 -458
  27. package/plugins/threejs.js +183 -163
  28. package/plugins/tweakables.js +411 -0
  29. package/plugins/tweenSystem.js +263 -145
  30. package/plugins/uiSystem.js +2024 -1687
  31. package/plugins/zzfxm.js +159 -159
  32. package/src/engine.js +191 -75
  33. package/src/engineAudio.js +229 -125
  34. package/src/engineBuild.mjs +289 -256
  35. package/src/engineDebug.js +912 -742
  36. package/src/engineDraw.js +295 -193
  37. package/src/engineEditor.js +2431 -0
  38. package/src/engineExport.js +12 -0
  39. package/src/engineInput.js +1462 -1293
  40. package/src/engineMath.js +1274 -1252
  41. package/src/engineObject.js +194 -80
  42. package/src/engineParticles.js +583 -532
  43. package/src/engineRelease.js +67 -45
  44. package/src/engineSettings.js +77 -29
  45. package/src/engineTileLayer.js +995 -741
  46. package/src/engineUtilities.js +19 -13
  47. package/src/engineWebGL.js +239 -82
  48. package/src/jsconfig.json +17 -13
  49. package/plugins/box2d.wasm.js +0 -630
  50. package/plugins/box2d.wasm.wasm +0 -0
@@ -1,257 +1,290 @@
1
- /**
2
- * LittleJS Build System
3
- * - Concatenates engine source files into distributable bundles
4
- * - Generates multiple output formats (standard, ES6 module, minified)
5
- * - Creates debug and release builds (with/without debug code)
6
- * - Produces TypeScript definition file (.d.ts)
7
- * - Includes plugin files in builds
8
- * - Validates code and checks for errors
9
- * - Outputs to dist/ folder
10
- */
11
-
12
- import fs from 'node:fs';
13
- import { execSync } from 'node:child_process';
14
- import { fileURLToPath } from 'node:url';
15
- import { basename, dirname, join } from 'node:path';
16
-
17
- const __filename = fileURLToPath(import.meta.url);
18
- const __dirname = dirname(__filename);
19
- const ROOT_DIR = join(__dirname, '..');
20
-
21
- const ENGINE_NAME = 'littlejs';
22
- const BUILD_FOLDER = join(ROOT_DIR, 'dist');
23
- const SOURCE_FOLDER = join(ROOT_DIR, 'src');
24
- const PLUGIN_FOLDER = join(ROOT_DIR, 'plugins');
25
- const engineSourceFiles =
26
- [
27
- `${SOURCE_FOLDER}/engineMath.js`,
28
- `${SOURCE_FOLDER}/engineUtilities.js`,
29
- `${SOURCE_FOLDER}/engineSettings.js`,
30
- `${SOURCE_FOLDER}/engineObject.js`,
31
- `${SOURCE_FOLDER}/engineDraw.js`,
32
- `${SOURCE_FOLDER}/engineInput.js`,
33
- `${SOURCE_FOLDER}/engineAudio.js`,
34
- `${SOURCE_FOLDER}/engineTileLayer.js`,
35
- `${SOURCE_FOLDER}/engineParticles.js`,
36
- `${SOURCE_FOLDER}/engineWebGL.js`,
37
- `${SOURCE_FOLDER}/engineLogo.js`,
38
- ];
39
- const enginePluginFiles =
40
- [
41
- `${PLUGIN_FOLDER}/medalSystem.js`,
42
- `${PLUGIN_FOLDER}/newgrounds.js`,
43
- `${PLUGIN_FOLDER}/postProcess.js`,
44
- `${PLUGIN_FOLDER}/lightSystem.js`,
45
- `${PLUGIN_FOLDER}/zzfxm.js`,
46
- `${PLUGIN_FOLDER}/audioEffects.js`,
47
- `${PLUGIN_FOLDER}/uiSystem.js`,
48
- `${PLUGIN_FOLDER}/box2d.js`,
49
- `${PLUGIN_FOLDER}/drawUtilities.js`,
50
- `${PLUGIN_FOLDER}/textureSheet.js`,
51
- `${PLUGIN_FOLDER}/tweenSystem.js`,
52
- `${PLUGIN_FOLDER}/pathFinder.js`,
53
- `${PLUGIN_FOLDER}/math3d.js`,
54
- `${PLUGIN_FOLDER}/render3d.js`,
55
- `${PLUGIN_FOLDER}/threejs.js`,
56
- ];
57
- const engineExtraFiles =
58
- [
59
- `${PLUGIN_FOLDER}/box2d.wasm.js`,
60
- `${PLUGIN_FOLDER}/box2d.wasm.wasm`,
61
- ];
62
- const asciiArt =`
63
- ~~~~°°°°ooo°oOo°ooOooOooOo.
64
- __________ ________ ____'°oO.
65
- |LittleJS| |Engine| |[]|_._Y
66
- .|________|_._|______|_._|__|_|_|}
67
- OOO OOO OO OO OO=OO-oo\\
68
- `;
69
- const license = '// LittleJS Engine - MIT License - Copyright 2021 Frank Force\n'+
70
- '// https://github.com/KilledByAPixel/LittleJS\n\n';
71
-
72
- console.log(asciiArt);
73
- console.log('Choo Choo... Building LittleJS Engine!');
74
- const startTime = Date.now();
75
-
76
- try
77
- {
78
- // Setup build folder
79
- fs.rmSync(BUILD_FOLDER, { recursive: true, force: true });
80
- fs.mkdirSync(BUILD_FOLDER);
81
-
82
- // copy extra files to build folder
83
- for (const file of engineExtraFiles)
84
- fs.copyFileSync(file, join(BUILD_FOLDER, basename(file)));
85
-
86
- }
87
- catch (e) { handleError(e, 'Failed to create build folder!'); }
88
-
89
- // Build all versions
90
- await buildAll();
91
-
92
- console.log(`Engine built in ${((Date.now() - startTime)/1e3).toFixed(2)} seconds! ✨`);
93
-
94
- ///////////////////////////////////////////////////////////////////////////////
95
-
96
- async function buildAll()
97
- {
98
- // Build independent base versions in parallel
99
- await Promise.all([
100
- Build
101
- (
102
- 'Build Engine -- all',
103
- `${BUILD_FOLDER}/${ENGINE_NAME}.js`,
104
- [
105
- `${SOURCE_FOLDER}/engine.js`,
106
- `${SOURCE_FOLDER}/engineDebug.js`,
107
- ...engineSourceFiles,
108
- ...enginePluginFiles
109
- ],
110
- [], true
111
- ),
112
- Build
113
- (
114
- 'Build Engine -- release',
115
- `${BUILD_FOLDER}/${ENGINE_NAME}.release.js`,
116
- [
117
- `${SOURCE_FOLDER}/engine.js`,
118
- `${SOURCE_FOLDER}/engineRelease.js`,
119
- ...engineSourceFiles,
120
- ...enginePluginFiles
121
- ],
122
- [], true
123
- )
124
- ]);
125
-
126
- // Build dependent versions in parallel
127
- await Promise.all([
128
- Build
129
- (
130
- 'Build Engine -- minified',
131
- `${BUILD_FOLDER}/${ENGINE_NAME}.min.js`,
132
- [`${BUILD_FOLDER}/${ENGINE_NAME}.release.js`],
133
- [closureCompilerStep, uglifyBuildStep, addLicenseStep]
134
- ),
135
- Build
136
- (
137
- 'Build Engine -- ESM',
138
- `${BUILD_FOLDER}/${ENGINE_NAME}.esm.js`,
139
- [
140
- `${BUILD_FOLDER}/${ENGINE_NAME}.js`,
141
- `${SOURCE_FOLDER}/engineExport.js`,
142
- `${PLUGIN_FOLDER}/pluginExport.js`
143
- ],
144
- [typeScriptBuildStep]
145
- ),
146
- Build
147
- (
148
- 'Build Engine -- ESM minified release',
149
- `${BUILD_FOLDER}/${ENGINE_NAME}.esm.min.js`,
150
- [
151
- `${BUILD_FOLDER}/${ENGINE_NAME}.release.js`,
152
- `${SOURCE_FOLDER}/engineExport.js`,
153
- `${PLUGIN_FOLDER}/pluginExport.js`
154
- ],
155
- [uglifyBuildStep, addLicenseStep]
156
- )
157
- ]);
158
- }
159
-
160
- ///////////////////////////////////////////////////////////////////////////////
161
-
162
- // A single build with its own source files, build steps, and output file
163
- // - each build step is a callback that accepts a single filename
164
- async function Build(message, outputFile, files=[], buildSteps=[], isPrimaryBuild)
165
- {
166
- console.log(message);
167
-
168
- // copy files into a buffer
169
- let buffer = '';
170
- if (isPrimaryBuild)
171
- {
172
- // add license and strict mode to top
173
- buffer += license;
174
- buffer += `'use strict';\n\n`;
175
- }
176
-
177
- for (const file of files)
178
- {
179
- // get file content
180
- let fileContent = fs.readFileSync(file) + '\n';
181
-
182
- // remove first 'use strict' and surrounding new lines
183
- if (isPrimaryBuild)
184
- fileContent = fileContent.replace(/'use strict';\s*\n/g, '');
185
-
186
- // add it to the buffer
187
- buffer += fileContent;
188
- }
189
-
190
- // output file
191
- fs.writeFileSync(outputFile, buffer, {flag: 'w+'});
192
-
193
- // execute build steps in order
194
- for (const buildStep of buildSteps)
195
- buildStep(outputFile);
196
- }
197
-
198
- // Process with Closure Compiler to minify and check for errors
199
- function closureCompilerStep(filename)
200
- {
201
- const filenameTemp = filename + '.tmp';
202
- fs.copyFileSync(filename, filenameTemp);
203
- try
204
- {
205
- execSync(`npx google-closure-compiler --js=${filenameTemp} --js_output_file=${filename} --jscomp_off=*`);
206
- fs.rmSync(filenameTemp);
207
- }
208
- catch (e) { handleError(e, 'Failed to run Closure Compiler step!'); }
209
- }
210
-
211
- // Process with Uglify to minify
212
- function uglifyBuildStep(filename)
213
- {
214
- try
215
- {
216
- execSync(`npx uglifyjs ${filename} -o ${filename}`);
217
- }
218
- catch (e) { handleError(e,'Failed to run Uglify minification step!'); }
219
- };
220
-
221
- // Add license to top of file
222
- function addLicenseStep(filename)
223
- {
224
- try
225
- {
226
- // add license to top of minified file
227
- let fileContent = fs.readFileSync(filename, 'utf8');
228
- fileContent = license + fileContent;
229
- fs.writeFileSync(filename, fileContent);
230
- }
231
- catch (e) { handleError(e, 'Failed to add license to minified file!'); }
232
- };
233
-
234
- // Build TypeScript definitions
235
- function typeScriptBuildStep(filename)
236
- {
237
- try
238
- {
239
- const tsFilename = join(BUILD_FOLDER, `${ENGINE_NAME}.d.ts`);
240
- execSync(`npx -p typescript tsc ${filename} --declaration --allowJs --emitDeclarationOnly --outFile ${tsFilename}`);
241
-
242
- // Make declare module part use the package name littlejsengine
243
- let fileContent = fs.readFileSync(tsFilename, 'utf8');
244
- fileContent = fileContent.replace(`${ENGINE_NAME}\.esm`, 'littlejsengine')
245
- fs.writeFileSync(tsFilename, fileContent);
246
-
247
- }
248
- catch (e) { handleError(e, 'Failed to run TypeScript build step!'); }
249
- };
250
-
251
- // display the error and exit
252
- function handleError(e,message)
253
- {
254
- console.error(e);
255
- console.error(message);
256
- process.exit(1);
1
+ /**
2
+ * LittleJS Build System
3
+ * - Concatenates engine source files into distributable bundles
4
+ * - Generates multiple output formats (standard, ES6 module, minified)
5
+ * - Creates debug and release builds (with/without debug code)
6
+ * - Produces TypeScript definition file (.d.ts)
7
+ * - Includes plugin files in builds
8
+ * - Validates code and checks for errors
9
+ * - Outputs to dist/ folder
10
+ */
11
+
12
+ import fs from 'node:fs';
13
+ import { execSync } from 'node:child_process';
14
+ import { fileURLToPath } from 'node:url';
15
+ import { basename, dirname, join } from 'node:path';
16
+
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+ const ROOT_DIR = join(__dirname, '..');
20
+
21
+ const ENGINE_NAME = 'littlejs';
22
+ const BUILD_FOLDER = join(ROOT_DIR, 'dist');
23
+ const SOURCE_FOLDER = join(ROOT_DIR, 'src');
24
+ const PLUGIN_FOLDER = join(ROOT_DIR, 'plugins');
25
+ const engineSourceFiles =
26
+ [
27
+ `${SOURCE_FOLDER}/engineMath.js`,
28
+ `${SOURCE_FOLDER}/engineUtilities.js`,
29
+ `${SOURCE_FOLDER}/engineSettings.js`,
30
+ `${SOURCE_FOLDER}/engineObject.js`,
31
+ `${SOURCE_FOLDER}/engineDraw.js`,
32
+ `${SOURCE_FOLDER}/engineInput.js`,
33
+ `${SOURCE_FOLDER}/engineAudio.js`,
34
+ `${SOURCE_FOLDER}/engineTileLayer.js`,
35
+ `${SOURCE_FOLDER}/engineParticles.js`,
36
+ `${SOURCE_FOLDER}/engineWebGL.js`,
37
+ `${SOURCE_FOLDER}/engineLogo.js`,
38
+ ];
39
+ const enginePluginFiles =
40
+ [
41
+ `${PLUGIN_FOLDER}/medalSystem.js`,
42
+ `${PLUGIN_FOLDER}/newgrounds.js`,
43
+ `${PLUGIN_FOLDER}/postProcess.js`,
44
+ `${PLUGIN_FOLDER}/lightSystem.js`,
45
+ `${PLUGIN_FOLDER}/zzfxm.js`,
46
+ `${PLUGIN_FOLDER}/audioEffects.js`,
47
+ `${PLUGIN_FOLDER}/uiSystem.js`,
48
+ `${PLUGIN_FOLDER}/box2d.js`,
49
+ `${PLUGIN_FOLDER}/drawUtilities.js`,
50
+ `${PLUGIN_FOLDER}/textureSheet.js`,
51
+ `${PLUGIN_FOLDER}/tweenSystem.js`,
52
+ `${PLUGIN_FOLDER}/pathFinder.js`,
53
+ `${PLUGIN_FOLDER}/math3d.js`,
54
+ `${PLUGIN_FOLDER}/render3d.js`,
55
+ `${PLUGIN_FOLDER}/render3dExtras.js`,
56
+ `${PLUGIN_FOLDER}/render3dVoxels.js`,
57
+ `${PLUGIN_FOLDER}/gltf.js`,
58
+ `${PLUGIN_FOLDER}/threejs.js`,
59
+ ];
60
+ // debug only, the release build has stubs for these in engineRelease.js and none of their code
61
+ const engineDebugFiles =
62
+ [
63
+ `${PLUGIN_FOLDER}/tweakables.js`,
64
+ `${PLUGIN_FOLDER}/render3dDebug.js`,
65
+ `${SOURCE_FOLDER}/engineEditor.js`,
66
+ ];
67
+ const engineExtraFiles =
68
+ [
69
+ `${PLUGIN_FOLDER}/box2d.wasm.js`,
70
+ `${PLUGIN_FOLDER}/box2d.wasm.wasm`,
71
+ ];
72
+ const asciiArt =`
73
+ ~~~~°°°°ooo°oOo°ooOooOooOo.
74
+ __________ ________ ____'°oO.
75
+ |LittleJS| |Engine| |[]|_._Y
76
+ .|________|_._|______|_._|__|_|_|}
77
+ OOO OOO OO OO OO=OO-oo\\
78
+ `;
79
+ const license = '// LittleJS Engine - MIT License - Copyright 2021 Frank Force\n'+
80
+ '// https://github.com/KilledByAPixel/LittleJS\n\n';
81
+
82
+ console.log(asciiArt);
83
+ console.log('Choo Choo... Building LittleJS Engine!');
84
+ const startTime = Date.now();
85
+
86
+ try
87
+ {
88
+ // Setup build folder
89
+ fs.rmSync(BUILD_FOLDER, { recursive: true, force: true });
90
+ fs.mkdirSync(BUILD_FOLDER);
91
+
92
+ // copy extra files to build folder
93
+ for (const file of engineExtraFiles)
94
+ fs.copyFileSync(file, join(BUILD_FOLDER, basename(file)));
95
+
96
+ }
97
+ catch (e) { handleError(e, 'Failed to create build folder!'); }
98
+
99
+ // Build all versions
100
+ await buildAll();
101
+
102
+ console.log(`Engine built in ${((Date.now() - startTime)/1e3).toFixed(2)} seconds! ✨`);
103
+
104
+ ///////////////////////////////////////////////////////////////////////////////
105
+
106
+ async function buildAll()
107
+ {
108
+ // Build independent base versions
109
+ await Promise.all([
110
+ Build
111
+ (
112
+ 'Build Engine -- all',
113
+ `${BUILD_FOLDER}/${ENGINE_NAME}.js`,
114
+ [
115
+ `${SOURCE_FOLDER}/engine.js`,
116
+ `${SOURCE_FOLDER}/engineDebug.js`,
117
+ ...engineSourceFiles,
118
+ ...enginePluginFiles,
119
+ ...engineDebugFiles
120
+ ],
121
+ [], true
122
+ ),
123
+ Build
124
+ (
125
+ 'Build Engine -- release',
126
+ `${BUILD_FOLDER}/${ENGINE_NAME}.release.js`,
127
+ [
128
+ `${SOURCE_FOLDER}/engine.js`,
129
+ `${SOURCE_FOLDER}/engineRelease.js`,
130
+ ...engineSourceFiles,
131
+ ...enginePluginFiles
132
+ ],
133
+ [stripDebugCallsStep], true
134
+ )
135
+ ]);
136
+
137
+ // Build dependent versions
138
+ await Promise.all([
139
+ Build
140
+ (
141
+ 'Build Engine -- minified',
142
+ `${BUILD_FOLDER}/${ENGINE_NAME}.min.js`,
143
+ [`${BUILD_FOLDER}/${ENGINE_NAME}.release.js`],
144
+ [closureCompilerStep, uglifyBuildStep, addLicenseStep]
145
+ ),
146
+ Build
147
+ (
148
+ 'Build Engine -- ESM',
149
+ `${BUILD_FOLDER}/${ENGINE_NAME}.esm.js`,
150
+ [
151
+ `${BUILD_FOLDER}/${ENGINE_NAME}.js`,
152
+ `${SOURCE_FOLDER}/engineExport.js`,
153
+ `${PLUGIN_FOLDER}/pluginExport.js`
154
+ ],
155
+ [typeScriptBuildStep]
156
+ ),
157
+ Build
158
+ (
159
+ 'Build Engine -- ESM minified release',
160
+ `${BUILD_FOLDER}/${ENGINE_NAME}.esm.min.js`,
161
+ [
162
+ `${BUILD_FOLDER}/${ENGINE_NAME}.release.js`,
163
+ `${SOURCE_FOLDER}/engineExport.js`,
164
+ `${PLUGIN_FOLDER}/pluginExport.js`
165
+ ],
166
+ [uglifyModuleBuildStep, addLicenseStep]
167
+ )
168
+ ]);
169
+ }
170
+
171
+ ///////////////////////////////////////////////////////////////////////////////
172
+
173
+ // A single build with its own source files, build steps, and output file
174
+ // - each build step is a callback that accepts a single filename
175
+ async function Build(message, outputFile, files=[], buildSteps=[], isPrimaryBuild)
176
+ {
177
+ console.log(message);
178
+
179
+ // copy files into a buffer
180
+ let buffer = '';
181
+ if (isPrimaryBuild)
182
+ {
183
+ // add license and strict mode to top
184
+ buffer += license;
185
+ buffer += `'use strict';\n\n`;
186
+ }
187
+
188
+ for (const file of files)
189
+ {
190
+ // get file content
191
+ let fileContent = fs.readFileSync(file) + '\n';
192
+
193
+ // remove first 'use strict' and surrounding new lines
194
+ if (isPrimaryBuild)
195
+ fileContent = fileContent.replace(/'use strict';\s*\n/g, '');
196
+
197
+ // add it to the buffer
198
+ buffer += fileContent;
199
+ }
200
+
201
+ // output file
202
+ fs.writeFileSync(outputFile, buffer, {flag: 'w+'});
203
+
204
+ // execute build steps in order
205
+ for (const buildStep of buildSteps)
206
+ buildStep(outputFile);
207
+ }
208
+
209
+ // Process with Closure Compiler to minify and check for errors
210
+ function closureCompilerStep(filename)
211
+ {
212
+ const filenameTemp = filename + '.tmp';
213
+ fs.copyFileSync(filename, filenameTemp);
214
+ try
215
+ {
216
+ execSync(`npx google-closure-compiler --js="${filenameTemp}" --js_output_file="${filename}" --jscomp_off=*`);
217
+ fs.rmSync(filenameTemp);
218
+ }
219
+ catch (e) { handleError(e, 'Failed to run Closure Compiler step!'); }
220
+ }
221
+
222
+ // Process with Uglify to minify
223
+ function uglifyBuildStep(filename)
224
+ {
225
+ try
226
+ {
227
+ execSync(`npx uglifyjs "${filename}" -o "${filename}"`);
228
+ }
229
+ catch (e) { handleError(e,'Failed to run Uglify minification step!'); }
230
+ };
231
+
232
+ // Process an ES module with Uglify, compressed so the guarded debug calls are dropped, Closure does that for the
233
+ // script build before its Uglify step
234
+ function uglifyModuleBuildStep(filename)
235
+ {
236
+ try
237
+ {
238
+ execSync(`npx uglifyjs "${filename}" -c --module -o "${filename}"`);
239
+ }
240
+ catch (e) { handleError(e,'Failed to run Uglify minification step!'); }
241
+ };
242
+
243
+ // Guard every ASSERT and LOG call in the release build so its arguments are never evaluated
244
+ // - engineRelease.js makes them empty functions, but a call still evaluates its arguments first,
245
+ // so isVector3 checks and message strings would run in release; false&& short circuits them
246
+ // and the minifiers then drop the dead calls entirely
247
+ // - The helpers like ASSERT_VECTOR3_VALID are guarded the same way, their definitions are skipped by name
248
+ function stripDebugCallsStep(filename)
249
+ {
250
+ const source = fs.readFileSync(filename, 'utf8');
251
+ fs.writeFileSync(filename, source.replace(/(?<!function )\b(ASSERT\w*|LOG)\(/g, 'false&&$1('), {flag: 'w+'});
252
+ }
253
+
254
+ // Add license to top of file
255
+ function addLicenseStep(filename)
256
+ {
257
+ try
258
+ {
259
+ // add license to top of minified file
260
+ let fileContent = fs.readFileSync(filename, 'utf8');
261
+ fileContent = license + fileContent;
262
+ fs.writeFileSync(filename, fileContent);
263
+ }
264
+ catch (e) { handleError(e, 'Failed to add license to minified file!'); }
265
+ };
266
+
267
+ // Build TypeScript definitions
268
+ function typeScriptBuildStep(filename)
269
+ {
270
+ try
271
+ {
272
+ const tsFilename = join(BUILD_FOLDER, `${ENGINE_NAME}.d.ts`);
273
+ execSync(`npx -p typescript tsc "${filename}" --declaration --allowJs --emitDeclarationOnly --outFile "${tsFilename}"`);
274
+
275
+ // Make declare module part use the package name littlejsengine
276
+ let fileContent = fs.readFileSync(tsFilename, 'utf8');
277
+ fileContent = fileContent.replace(`${ENGINE_NAME}\.esm`, 'littlejsengine')
278
+ fs.writeFileSync(tsFilename, fileContent);
279
+
280
+ }
281
+ catch (e) { handleError(e, 'Failed to run TypeScript build step!'); }
282
+ };
283
+
284
+ // display the error and exit
285
+ function handleError(e,message)
286
+ {
287
+ console.error(e);
288
+ console.error(message);
289
+ process.exit(1);
257
290
  }