@al8b/runtime 0.1.13 → 0.1.14
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/dist/assets/index.d.mts +0 -1
- package/dist/assets/index.d.ts +0 -1
- package/dist/assets/loader.d.mts +0 -1
- package/dist/assets/loader.d.ts +0 -1
- package/dist/browser/index.js +780 -2681
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.min.js +27 -39
- package/dist/core/api-factory.d.mts +1 -5
- package/dist/core/api-factory.d.ts +1 -5
- package/dist/core/api-factory.js +17 -38
- package/dist/core/api-factory.js.map +1 -1
- package/dist/core/api-factory.mjs +18 -38
- package/dist/core/api-factory.mjs.map +1 -1
- package/dist/core/controller.d.mts +0 -5
- package/dist/core/controller.d.ts +0 -5
- package/dist/core/controller.js +23 -98
- package/dist/core/controller.js.map +1 -1
- package/dist/core/controller.mjs +24 -99
- package/dist/core/controller.mjs.map +1 -1
- package/dist/core/debug-logger.d.mts +0 -1
- package/dist/core/debug-logger.d.ts +0 -1
- package/dist/core/error-handler.d.mts +1 -2
- package/dist/core/error-handler.d.ts +1 -2
- package/dist/core/error-handler.js +2 -17
- package/dist/core/error-handler.js.map +1 -1
- package/dist/core/error-handler.mjs +2 -17
- package/dist/core/error-handler.mjs.map +1 -1
- package/dist/core/index.d.mts +0 -2
- package/dist/core/index.d.ts +0 -2
- package/dist/core/index.js +23 -98
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +24 -99
- package/dist/core/index.mjs.map +1 -1
- package/dist/hot-reload/index.d.mts +0 -1
- package/dist/hot-reload/index.d.ts +0 -1
- package/dist/hot-reload/index.js.map +1 -1
- package/dist/hot-reload/index.mjs.map +1 -1
- package/dist/hot-reload/updater.d.mts +0 -1
- package/dist/hot-reload/updater.d.ts +0 -1
- package/dist/hot-reload/updater.js.map +1 -1
- package/dist/hot-reload/updater.mjs.map +1 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +23 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -99
- package/dist/index.mjs.map +1 -1
- package/dist/types/bridge.d.mts +0 -4
- package/dist/types/bridge.d.ts +0 -4
- package/dist/types/bridge.js.map +1 -1
- package/dist/types/index.d.mts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/runtime.d.mts +13 -2
- package/dist/types/runtime.d.ts +13 -2
- package/dist/types/runtime.js.map +1 -1
- package/package.json +12 -16
package/dist/index.mjs
CHANGED
|
@@ -243,7 +243,6 @@ var AssetLoader = class {
|
|
|
243
243
|
// src/core/controller.ts
|
|
244
244
|
import { AudioCore } from "@al8b/audio";
|
|
245
245
|
import { PlayerService } from "@al8b/player";
|
|
246
|
-
import { SceneManager } from "@al8b/scene";
|
|
247
246
|
import { Screen } from "@al8b/screen";
|
|
248
247
|
import { StatePlayer, TimeMachine } from "@al8b/time";
|
|
249
248
|
import { L8BVM } from "@al8b/vm";
|
|
@@ -725,29 +724,14 @@ function shallowEqual(obj1, obj2) {
|
|
|
725
724
|
__name(shallowEqual, "shallowEqual");
|
|
726
725
|
|
|
727
726
|
// src/core/error-handler.ts
|
|
728
|
-
import { createDiagnostic, formatForBrowser } from "@al8b/diagnostics";
|
|
729
727
|
function formatRuntimeError(error) {
|
|
730
728
|
if (error.code || error.context || error.suggestions) {
|
|
731
729
|
return error;
|
|
732
730
|
}
|
|
733
|
-
const code = error.code || "E2005";
|
|
734
|
-
const diagnostic = createDiagnostic(code, {
|
|
735
|
-
file: error.file,
|
|
736
|
-
line: error.line,
|
|
737
|
-
column: error.column,
|
|
738
|
-
context: error.context,
|
|
739
|
-
suggestions: error.suggestions,
|
|
740
|
-
related: error.related,
|
|
741
|
-
stackTrace: error.stackTrace,
|
|
742
|
-
data: {
|
|
743
|
-
error: error.error || error.message
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
const formattedMessage = formatForBrowser(diagnostic);
|
|
747
731
|
return {
|
|
748
732
|
...error,
|
|
749
|
-
|
|
750
|
-
formatted:
|
|
733
|
+
code: error.code || "E2005",
|
|
734
|
+
formatted: error.message || String(error)
|
|
751
735
|
};
|
|
752
736
|
}
|
|
753
737
|
__name(formatRuntimeError, "formatRuntimeError");
|
|
@@ -834,7 +818,7 @@ var RuntimeAssetsRegistry = class {
|
|
|
834
818
|
|
|
835
819
|
// src/core/api-factory.ts
|
|
836
820
|
import { Palette } from "@al8b/palette";
|
|
837
|
-
import { Random
|
|
821
|
+
import { Random } from "@al8b/vm";
|
|
838
822
|
|
|
839
823
|
// src/utils/object-pool.ts
|
|
840
824
|
var ObjectPool = class {
|
|
@@ -979,12 +963,6 @@ function createRuntimeGlobalApi(context) {
|
|
|
979
963
|
session,
|
|
980
964
|
memory,
|
|
981
965
|
system: context.system.getAPI(),
|
|
982
|
-
scene: /* @__PURE__ */ __name((name, definition) => {
|
|
983
|
-
const convertedDefinition = convertSceneDefinition(asSceneDefinition(definition), context.getVM(), context.listener);
|
|
984
|
-
context.sceneManager.registerScene(name, convertedDefinition);
|
|
985
|
-
}, "scene"),
|
|
986
|
-
route: /* @__PURE__ */ __name((path, sceneName) => context.sceneManager.registerRoute(path, sceneName), "route"),
|
|
987
|
-
router: context.sceneManager.router.getInterface(),
|
|
988
966
|
Image,
|
|
989
967
|
Sprite,
|
|
990
968
|
TileMap,
|
|
@@ -995,40 +973,27 @@ function createRuntimeGlobalApi(context) {
|
|
|
995
973
|
};
|
|
996
974
|
}
|
|
997
975
|
__name(createRuntimeGlobalApi, "createRuntimeGlobalApi");
|
|
998
|
-
function convertSceneDefinition(definition, vm, listener) {
|
|
999
|
-
if (!vm?.runner?.main_thread?.processor) {
|
|
1000
|
-
listener.log?.("[RuntimeController] VM not ready for scene conversion. Scene functions may not work correctly.");
|
|
1001
|
-
return definition;
|
|
1002
|
-
}
|
|
1003
|
-
const processor = vm.runner.main_thread.processor;
|
|
1004
|
-
const context = vm.context;
|
|
1005
|
-
const converted = {};
|
|
1006
|
-
for (const [key, value] of Object.entries(definition)) {
|
|
1007
|
-
if (value instanceof Routine) {
|
|
1008
|
-
converted[key] = processor.routineAsFunction(value, context);
|
|
1009
|
-
continue;
|
|
1010
|
-
}
|
|
1011
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1012
|
-
converted[key] = convertSceneDefinition(value, vm, listener);
|
|
1013
|
-
continue;
|
|
1014
|
-
}
|
|
1015
|
-
converted[key] = value;
|
|
1016
|
-
}
|
|
1017
|
-
return converted;
|
|
1018
|
-
}
|
|
1019
|
-
__name(convertSceneDefinition, "convertSceneDefinition");
|
|
1020
|
-
function asSceneDefinition(definition) {
|
|
1021
|
-
if (!definition || typeof definition !== "object" || Array.isArray(definition)) {
|
|
1022
|
-
throw new Error("Scene definition must be an object.");
|
|
1023
|
-
}
|
|
1024
|
-
return definition;
|
|
1025
|
-
}
|
|
1026
|
-
__name(asSceneDefinition, "asSceneDefinition");
|
|
1027
976
|
function cloneValue(value) {
|
|
1028
977
|
if (value == null) {
|
|
1029
978
|
return value;
|
|
1030
979
|
}
|
|
1031
|
-
|
|
980
|
+
if (value instanceof Date) {
|
|
981
|
+
return new Date(value);
|
|
982
|
+
}
|
|
983
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
984
|
+
return value;
|
|
985
|
+
}
|
|
986
|
+
if (Array.isArray(value)) {
|
|
987
|
+
return value.map((entry) => cloneValue(entry));
|
|
988
|
+
}
|
|
989
|
+
if (typeof value === "object") {
|
|
990
|
+
const clone = {};
|
|
991
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
992
|
+
clone[key] = cloneValue(entry);
|
|
993
|
+
}
|
|
994
|
+
return clone;
|
|
995
|
+
}
|
|
996
|
+
return null;
|
|
1032
997
|
}
|
|
1033
998
|
__name(cloneValue, "cloneValue");
|
|
1034
999
|
|
|
@@ -1061,7 +1026,6 @@ var RuntimeControllerImpl = class {
|
|
|
1061
1026
|
input;
|
|
1062
1027
|
system;
|
|
1063
1028
|
playerService;
|
|
1064
|
-
sceneManager;
|
|
1065
1029
|
vm = null;
|
|
1066
1030
|
timeMachine = null;
|
|
1067
1031
|
constructor(options = {}) {
|
|
@@ -1088,7 +1052,6 @@ var RuntimeControllerImpl = class {
|
|
|
1088
1052
|
this.system.getAPI().update_rate = rate;
|
|
1089
1053
|
}, "setUpdateRate")
|
|
1090
1054
|
});
|
|
1091
|
-
this.sceneManager = new SceneManager();
|
|
1092
1055
|
this.assetLoader = new AssetLoader(options.url || "", options.resources || {}, this.audio, this.listener);
|
|
1093
1056
|
this.logStep("RuntimeController constructed", {
|
|
1094
1057
|
width: this.screen.width,
|
|
@@ -1176,15 +1139,10 @@ var RuntimeControllerImpl = class {
|
|
|
1176
1139
|
}
|
|
1177
1140
|
exportSnapshot() {
|
|
1178
1141
|
const global = this.vm?.context?.global;
|
|
1179
|
-
const routerState = this.sceneManager.router.getState();
|
|
1180
1142
|
return {
|
|
1181
1143
|
version: 1,
|
|
1182
1144
|
global: global ? serializeGlobalSnapshot(global) : {},
|
|
1183
1145
|
session: this.getSession(),
|
|
1184
|
-
router: {
|
|
1185
|
-
path: routerState.path,
|
|
1186
|
-
sceneName: this.sceneManager.getCurrentSceneName()
|
|
1187
|
-
},
|
|
1188
1146
|
system: {
|
|
1189
1147
|
updateRate: this.system.getAPI().update_rate
|
|
1190
1148
|
}
|
|
@@ -1200,11 +1158,6 @@ var RuntimeControllerImpl = class {
|
|
|
1200
1158
|
if (snapshot.session) {
|
|
1201
1159
|
this.sessionSnapshot = cloneSnapshot(snapshot.session);
|
|
1202
1160
|
}
|
|
1203
|
-
if (snapshot.router.path) {
|
|
1204
|
-
this.sceneManager.router.replace(snapshot.router.path);
|
|
1205
|
-
} else if (snapshot.router.sceneName) {
|
|
1206
|
-
this.sceneManager.setActiveScene(snapshot.router.sceneName);
|
|
1207
|
-
}
|
|
1208
1161
|
}
|
|
1209
1162
|
updateSource(file, src, reinit = false) {
|
|
1210
1163
|
if (!this.sourceUpdater) return false;
|
|
@@ -1258,7 +1211,6 @@ var RuntimeControllerImpl = class {
|
|
|
1258
1211
|
input: this.input,
|
|
1259
1212
|
system: this.system,
|
|
1260
1213
|
playerService: this.playerService,
|
|
1261
|
-
sceneManager: this.sceneManager,
|
|
1262
1214
|
assets: this.assetRegistry,
|
|
1263
1215
|
bridge: this.options.bridge,
|
|
1264
1216
|
getVM: /* @__PURE__ */ __name(() => this.vm, "getVM"),
|
|
@@ -1282,7 +1234,6 @@ var RuntimeControllerImpl = class {
|
|
|
1282
1234
|
});
|
|
1283
1235
|
});
|
|
1284
1236
|
this.loadPrograms();
|
|
1285
|
-
this.initializeScenesAndRouter();
|
|
1286
1237
|
this.emitBridgeEvent("runtime.started", {});
|
|
1287
1238
|
}
|
|
1288
1239
|
loadPrograms() {
|
|
@@ -1336,21 +1287,6 @@ var RuntimeControllerImpl = class {
|
|
|
1336
1287
|
});
|
|
1337
1288
|
}
|
|
1338
1289
|
}
|
|
1339
|
-
initializeScenesAndRouter() {
|
|
1340
|
-
const registeredScenes = this.sceneManager.registry.getNames();
|
|
1341
|
-
this.logStep("router: initializing", {
|
|
1342
|
-
registeredScenes: registeredScenes.length,
|
|
1343
|
-
sceneNames: registeredScenes
|
|
1344
|
-
});
|
|
1345
|
-
this.sceneManager.router.init();
|
|
1346
|
-
const activeScene = this.sceneManager.hasActiveScene() ? this.sceneManager.getCurrentSceneName?.() || "unknown" : null;
|
|
1347
|
-
const routerState = this.sceneManager.router.getState();
|
|
1348
|
-
this.logStep("router: initialized", {
|
|
1349
|
-
activeScene: activeScene || "none",
|
|
1350
|
-
path: routerState.path,
|
|
1351
|
-
hasActiveScene: this.sceneManager.hasActiveScene()
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
1290
|
startGameLoop() {
|
|
1355
1291
|
this.logStep("loop: creating game loop");
|
|
1356
1292
|
this.gameLoop = new GameLoop({
|
|
@@ -1404,12 +1340,8 @@ var RuntimeControllerImpl = class {
|
|
|
1404
1340
|
this.updateGameLoopUpdateRate();
|
|
1405
1341
|
}
|
|
1406
1342
|
try {
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
} else {
|
|
1410
|
-
this.vm.call("update");
|
|
1411
|
-
this.vm.runner.tick();
|
|
1412
|
-
}
|
|
1343
|
+
this.vm.call("update");
|
|
1344
|
+
this.vm.runner.tick();
|
|
1413
1345
|
if (this.vm.error_info) {
|
|
1414
1346
|
const err = Object.assign({}, this.vm.error_info);
|
|
1415
1347
|
err.type = "update";
|
|
@@ -1428,12 +1360,8 @@ var RuntimeControllerImpl = class {
|
|
|
1428
1360
|
try {
|
|
1429
1361
|
this.screen.initDraw();
|
|
1430
1362
|
this.screen.updateInterface();
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
} else {
|
|
1434
|
-
this.vm.call("draw");
|
|
1435
|
-
this.vm.runner.tick();
|
|
1436
|
-
}
|
|
1363
|
+
this.vm.call("draw");
|
|
1364
|
+
this.vm.runner.tick();
|
|
1437
1365
|
reportWarnings(this.vm, this.listener);
|
|
1438
1366
|
if (this.vm.error_info) {
|
|
1439
1367
|
const err = Object.assign({}, this.vm.error_info);
|
|
@@ -1659,8 +1587,6 @@ var RuntimeControllerImpl = class {
|
|
|
1659
1587
|
this.frameCount = 0;
|
|
1660
1588
|
this.lastUpdateRate = -1;
|
|
1661
1589
|
this.isStopped = false;
|
|
1662
|
-
this.sceneManager.registry.clear();
|
|
1663
|
-
this.sceneManager.routeManager.clear();
|
|
1664
1590
|
}
|
|
1665
1591
|
logStep(message, payload) {
|
|
1666
1592
|
if (!this.options.debug?.lifecycle) return;
|
|
@@ -1746,7 +1672,6 @@ function isRuntimeSnapshot(value) {
|
|
|
1746
1672
|
if (!isRecord(value)) return false;
|
|
1747
1673
|
if (value.version !== 1) return false;
|
|
1748
1674
|
if (!isRecord(value.global)) return false;
|
|
1749
|
-
if (!("router" in value)) return false;
|
|
1750
1675
|
if (!("session" in value)) return false;
|
|
1751
1676
|
return true;
|
|
1752
1677
|
}
|