@al8b/runtime 0.1.12 → 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 +46 -50
|
@@ -26,29 +26,14 @@ __export(error_handler_exports, {
|
|
|
26
26
|
reportWarnings: () => reportWarnings
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(error_handler_exports);
|
|
29
|
-
var import_diagnostics = require("@al8b/diagnostics");
|
|
30
29
|
function formatRuntimeError(error) {
|
|
31
30
|
if (error.code || error.context || error.suggestions) {
|
|
32
31
|
return error;
|
|
33
32
|
}
|
|
34
|
-
const code = error.code || "E2005";
|
|
35
|
-
const diagnostic = (0, import_diagnostics.createDiagnostic)(code, {
|
|
36
|
-
file: error.file,
|
|
37
|
-
line: error.line,
|
|
38
|
-
column: error.column,
|
|
39
|
-
context: error.context,
|
|
40
|
-
suggestions: error.suggestions,
|
|
41
|
-
related: error.related,
|
|
42
|
-
stackTrace: error.stackTrace,
|
|
43
|
-
data: {
|
|
44
|
-
error: error.error || error.message
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
const formattedMessage = (0, import_diagnostics.formatForBrowser)(diagnostic);
|
|
48
33
|
return {
|
|
49
34
|
...error,
|
|
50
|
-
|
|
51
|
-
formatted:
|
|
35
|
+
code: error.code || "E2005",
|
|
36
|
+
formatted: error.message || String(error)
|
|
52
37
|
};
|
|
53
38
|
}
|
|
54
39
|
__name(formatRuntimeError, "formatRuntimeError");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/error-handler.ts"],"sourcesContent":["/**\n * Error Handler - Error formatting and reporting for the runtime\n */\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/core/error-handler.ts"],"sourcesContent":["/**\n * Error Handler - Error formatting and reporting for the runtime\n */\n\nimport type { RuntimeListener } from \"../types\";\nimport type { L8BVM } from \"@al8b/vm\";\n\n/**\n * Format error message\n */\nexport function formatRuntimeError(error: any): any {\n\tif (error.code || error.context || error.suggestions) {\n\t\treturn error;\n\t}\n\n\treturn {\n\t\t...error,\n\t\tcode: error.code || \"E2005\",\n\t\tformatted: error.message || String(error),\n\t};\n}\n\n/**\n * Report error to listener with enhanced formatting\n */\nexport function reportError(listener: RuntimeListener, error: any): void {\n\tif (listener.reportError) {\n\t\tconst formatted = formatRuntimeError(error);\n\t\tlistener.reportError(formatted);\n\t}\n}\n\n/**\n * Report warnings from VM context (invoking_non_function, using_undefined_variable)\n */\nexport function reportWarnings(vm: L8BVM | null, listener: RuntimeListener): void {\n\tif (!vm) return;\n\n\tconst warnings = vm.context?.warnings;\n\tif (!warnings) return;\n\n\tif (warnings.invoking_non_function) {\n\t\tfor (const value of Object.values(warnings.invoking_non_function)) {\n\t\t\tconst warning = value as any;\n\t\t\tif (!warning.reported) {\n\t\t\t\twarning.reported = true;\n\t\t\t\treportError(listener, {\n\t\t\t\t\terror: \"\",\n\t\t\t\t\ttype: \"non_function\",\n\t\t\t\t\texpression: warning.expression,\n\t\t\t\t\tline: warning.line,\n\t\t\t\t\tcolumn: warning.column,\n\t\t\t\t\tfile: warning.file,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tif (warnings.using_undefined_variable) {\n\t\tfor (const value of Object.values(warnings.using_undefined_variable)) {\n\t\t\tconst warning = value as any;\n\t\t\tif (!warning.reported) {\n\t\t\t\twarning.reported = true;\n\t\t\t\treportError(listener, {\n\t\t\t\t\terror: \"\",\n\t\t\t\t\ttype: \"undefined_variable\",\n\t\t\t\t\texpression: warning.expression,\n\t\t\t\t\tline: warning.line,\n\t\t\t\t\tcolumn: warning.column,\n\t\t\t\t\tfile: warning.file,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAUO,SAASA,mBAAmBC,OAAU;AAC5C,MAAIA,MAAMC,QAAQD,MAAME,WAAWF,MAAMG,aAAa;AACrD,WAAOH;EACR;AAEA,SAAO;IACN,GAAGA;IACHC,MAAMD,MAAMC,QAAQ;IACpBG,WAAWJ,MAAMK,WAAWC,OAAON,KAAAA;EACpC;AACD;AAVgBD;AAeT,SAASQ,YAAYC,UAA2BR,OAAU;AAChE,MAAIQ,SAASD,aAAa;AACzB,UAAMH,YAAYL,mBAAmBC,KAAAA;AACrCQ,aAASD,YAAYH,SAAAA;EACtB;AACD;AALgBG;AAUT,SAASE,eAAeC,IAAkBF,UAAyB;AACzE,MAAI,CAACE,GAAI;AAET,QAAMC,WAAWD,GAAGR,SAASS;AAC7B,MAAI,CAACA,SAAU;AAEf,MAAIA,SAASC,uBAAuB;AACnC,eAAWC,SAASC,OAAOC,OAAOJ,SAASC,qBAAqB,GAAG;AAClE,YAAMI,UAAUH;AAChB,UAAI,CAACG,QAAQC,UAAU;AACtBD,gBAAQC,WAAW;AACnBV,oBAAYC,UAAU;UACrBR,OAAO;UACPkB,MAAM;UACNC,YAAYH,QAAQG;UACpBC,MAAMJ,QAAQI;UACdC,QAAQL,QAAQK;UAChBC,MAAMN,QAAQM;QACf,CAAA;MACD;IACD;EACD;AAEA,MAAIX,SAASY,0BAA0B;AACtC,eAAWV,SAASC,OAAOC,OAAOJ,SAASY,wBAAwB,GAAG;AACrE,YAAMP,UAAUH;AAChB,UAAI,CAACG,QAAQC,UAAU;AACtBD,gBAAQC,WAAW;AACnBV,oBAAYC,UAAU;UACrBR,OAAO;UACPkB,MAAM;UACNC,YAAYH,QAAQG;UACpBC,MAAMJ,QAAQI;UACdC,QAAQL,QAAQK;UAChBC,MAAMN,QAAQM;QACf,CAAA;MACD;IACD;EACD;AACD;AAvCgBb;","names":["formatRuntimeError","error","code","context","suggestions","formatted","message","String","reportError","listener","reportWarnings","vm","warnings","invoking_non_function","value","Object","values","warning","reported","type","expression","line","column","file","using_undefined_variable"]}
|
|
@@ -2,29 +2,14 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/core/error-handler.ts
|
|
5
|
-
import { createDiagnostic, formatForBrowser } from "@al8b/diagnostics";
|
|
6
5
|
function formatRuntimeError(error) {
|
|
7
6
|
if (error.code || error.context || error.suggestions) {
|
|
8
7
|
return error;
|
|
9
8
|
}
|
|
10
|
-
const code = error.code || "E2005";
|
|
11
|
-
const diagnostic = createDiagnostic(code, {
|
|
12
|
-
file: error.file,
|
|
13
|
-
line: error.line,
|
|
14
|
-
column: error.column,
|
|
15
|
-
context: error.context,
|
|
16
|
-
suggestions: error.suggestions,
|
|
17
|
-
related: error.related,
|
|
18
|
-
stackTrace: error.stackTrace,
|
|
19
|
-
data: {
|
|
20
|
-
error: error.error || error.message
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const formattedMessage = formatForBrowser(diagnostic);
|
|
24
9
|
return {
|
|
25
10
|
...error,
|
|
26
|
-
|
|
27
|
-
formatted:
|
|
11
|
+
code: error.code || "E2005",
|
|
12
|
+
formatted: error.message || String(error)
|
|
28
13
|
};
|
|
29
14
|
}
|
|
30
15
|
__name(formatRuntimeError, "formatRuntimeError");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/error-handler.ts"],"sourcesContent":["/**\n * Error Handler - Error formatting and reporting for the runtime\n */\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/core/error-handler.ts"],"sourcesContent":["/**\n * Error Handler - Error formatting and reporting for the runtime\n */\n\nimport type { RuntimeListener } from \"../types\";\nimport type { L8BVM } from \"@al8b/vm\";\n\n/**\n * Format error message\n */\nexport function formatRuntimeError(error: any): any {\n\tif (error.code || error.context || error.suggestions) {\n\t\treturn error;\n\t}\n\n\treturn {\n\t\t...error,\n\t\tcode: error.code || \"E2005\",\n\t\tformatted: error.message || String(error),\n\t};\n}\n\n/**\n * Report error to listener with enhanced formatting\n */\nexport function reportError(listener: RuntimeListener, error: any): void {\n\tif (listener.reportError) {\n\t\tconst formatted = formatRuntimeError(error);\n\t\tlistener.reportError(formatted);\n\t}\n}\n\n/**\n * Report warnings from VM context (invoking_non_function, using_undefined_variable)\n */\nexport function reportWarnings(vm: L8BVM | null, listener: RuntimeListener): void {\n\tif (!vm) return;\n\n\tconst warnings = vm.context?.warnings;\n\tif (!warnings) return;\n\n\tif (warnings.invoking_non_function) {\n\t\tfor (const value of Object.values(warnings.invoking_non_function)) {\n\t\t\tconst warning = value as any;\n\t\t\tif (!warning.reported) {\n\t\t\t\twarning.reported = true;\n\t\t\t\treportError(listener, {\n\t\t\t\t\terror: \"\",\n\t\t\t\t\ttype: \"non_function\",\n\t\t\t\t\texpression: warning.expression,\n\t\t\t\t\tline: warning.line,\n\t\t\t\t\tcolumn: warning.column,\n\t\t\t\t\tfile: warning.file,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tif (warnings.using_undefined_variable) {\n\t\tfor (const value of Object.values(warnings.using_undefined_variable)) {\n\t\t\tconst warning = value as any;\n\t\t\tif (!warning.reported) {\n\t\t\t\twarning.reported = true;\n\t\t\t\treportError(listener, {\n\t\t\t\t\terror: \"\",\n\t\t\t\t\ttype: \"undefined_variable\",\n\t\t\t\t\texpression: warning.expression,\n\t\t\t\t\tline: warning.line,\n\t\t\t\t\tcolumn: warning.column,\n\t\t\t\t\tfile: warning.file,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAUO,SAASA,mBAAmBC,OAAU;AAC5C,MAAIA,MAAMC,QAAQD,MAAME,WAAWF,MAAMG,aAAa;AACrD,WAAOH;EACR;AAEA,SAAO;IACN,GAAGA;IACHC,MAAMD,MAAMC,QAAQ;IACpBG,WAAWJ,MAAMK,WAAWC,OAAON,KAAAA;EACpC;AACD;AAVgBD;AAeT,SAASQ,YAAYC,UAA2BR,OAAU;AAChE,MAAIQ,SAASD,aAAa;AACzB,UAAMH,YAAYL,mBAAmBC,KAAAA;AACrCQ,aAASD,YAAYH,SAAAA;EACtB;AACD;AALgBG;AAUT,SAASE,eAAeC,IAAkBF,UAAyB;AACzE,MAAI,CAACE,GAAI;AAET,QAAMC,WAAWD,GAAGR,SAASS;AAC7B,MAAI,CAACA,SAAU;AAEf,MAAIA,SAASC,uBAAuB;AACnC,eAAWC,SAASC,OAAOC,OAAOJ,SAASC,qBAAqB,GAAG;AAClE,YAAMI,UAAUH;AAChB,UAAI,CAACG,QAAQC,UAAU;AACtBD,gBAAQC,WAAW;AACnBV,oBAAYC,UAAU;UACrBR,OAAO;UACPkB,MAAM;UACNC,YAAYH,QAAQG;UACpBC,MAAMJ,QAAQI;UACdC,QAAQL,QAAQK;UAChBC,MAAMN,QAAQM;QACf,CAAA;MACD;IACD;EACD;AAEA,MAAIX,SAASY,0BAA0B;AACtC,eAAWV,SAASC,OAAOC,OAAOJ,SAASY,wBAAwB,GAAG;AACrE,YAAMP,UAAUH;AAChB,UAAI,CAACG,QAAQC,UAAU;AACtBD,gBAAQC,WAAW;AACnBV,oBAAYC,UAAU;UACrBR,OAAO;UACPkB,MAAM;UACNC,YAAYH,QAAQG;UACpBC,MAAMJ,QAAQI;UACdC,QAAQL,QAAQK;UAChBC,MAAMN,QAAQM;QACf,CAAA;MACD;IACD;EACD;AACD;AAvCgBb;","names":["formatRuntimeError","error","code","context","suggestions","formatted","message","String","reportError","listener","reportWarnings","vm","warnings","invoking_non_function","value","Object","values","warning","reported","type","expression","line","column","file","using_undefined_variable"]}
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { RuntimeController, createRuntime } from './controller.mjs';
|
|
2
2
|
import '@al8b/audio';
|
|
3
3
|
import '@al8b/player';
|
|
4
|
-
import '@al8b/scene';
|
|
5
4
|
import '@al8b/screen';
|
|
6
5
|
import '@al8b/time';
|
|
7
6
|
import '@al8b/vm';
|
|
@@ -10,5 +9,4 @@ import '@al8b/input';
|
|
|
10
9
|
import '../system/api.mjs';
|
|
11
10
|
import '../types/runtime.mjs';
|
|
12
11
|
import '../types/assets.mjs';
|
|
13
|
-
import '@al8b/framework-shared';
|
|
14
12
|
import '../types/bridge.mjs';
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { RuntimeController, createRuntime } from './controller.js';
|
|
2
2
|
import '@al8b/audio';
|
|
3
3
|
import '@al8b/player';
|
|
4
|
-
import '@al8b/scene';
|
|
5
4
|
import '@al8b/screen';
|
|
6
5
|
import '@al8b/time';
|
|
7
6
|
import '@al8b/vm';
|
|
@@ -10,5 +9,4 @@ import '@al8b/input';
|
|
|
10
9
|
import '../system/api.js';
|
|
11
10
|
import '../types/runtime.js';
|
|
12
11
|
import '../types/assets.js';
|
|
13
|
-
import '@al8b/framework-shared';
|
|
14
12
|
import '../types/bridge.js';
|
package/dist/core/index.js
CHANGED
|
@@ -28,7 +28,6 @@ module.exports = __toCommonJS(core_exports);
|
|
|
28
28
|
// src/core/controller.ts
|
|
29
29
|
var import_audio3 = require("@al8b/audio");
|
|
30
30
|
var import_player = require("@al8b/player");
|
|
31
|
-
var import_scene = require("@al8b/scene");
|
|
32
31
|
var import_screen = require("@al8b/screen");
|
|
33
32
|
var import_time = require("@al8b/time");
|
|
34
33
|
var import_vm2 = require("@al8b/vm");
|
|
@@ -749,29 +748,14 @@ function shallowEqual(obj1, obj2) {
|
|
|
749
748
|
__name(shallowEqual, "shallowEqual");
|
|
750
749
|
|
|
751
750
|
// src/core/error-handler.ts
|
|
752
|
-
var import_diagnostics = require("@al8b/diagnostics");
|
|
753
751
|
function formatRuntimeError(error) {
|
|
754
752
|
if (error.code || error.context || error.suggestions) {
|
|
755
753
|
return error;
|
|
756
754
|
}
|
|
757
|
-
const code = error.code || "E2005";
|
|
758
|
-
const diagnostic = (0, import_diagnostics.createDiagnostic)(code, {
|
|
759
|
-
file: error.file,
|
|
760
|
-
line: error.line,
|
|
761
|
-
column: error.column,
|
|
762
|
-
context: error.context,
|
|
763
|
-
suggestions: error.suggestions,
|
|
764
|
-
related: error.related,
|
|
765
|
-
stackTrace: error.stackTrace,
|
|
766
|
-
data: {
|
|
767
|
-
error: error.error || error.message
|
|
768
|
-
}
|
|
769
|
-
});
|
|
770
|
-
const formattedMessage = (0, import_diagnostics.formatForBrowser)(diagnostic);
|
|
771
755
|
return {
|
|
772
756
|
...error,
|
|
773
|
-
|
|
774
|
-
formatted:
|
|
757
|
+
code: error.code || "E2005",
|
|
758
|
+
formatted: error.message || String(error)
|
|
775
759
|
};
|
|
776
760
|
}
|
|
777
761
|
__name(formatRuntimeError, "formatRuntimeError");
|
|
@@ -1003,12 +987,6 @@ function createRuntimeGlobalApi(context) {
|
|
|
1003
987
|
session,
|
|
1004
988
|
memory,
|
|
1005
989
|
system: context.system.getAPI(),
|
|
1006
|
-
scene: /* @__PURE__ */ __name((name, definition) => {
|
|
1007
|
-
const convertedDefinition = convertSceneDefinition(asSceneDefinition(definition), context.getVM(), context.listener);
|
|
1008
|
-
context.sceneManager.registerScene(name, convertedDefinition);
|
|
1009
|
-
}, "scene"),
|
|
1010
|
-
route: /* @__PURE__ */ __name((path, sceneName) => context.sceneManager.registerRoute(path, sceneName), "route"),
|
|
1011
|
-
router: context.sceneManager.router.getInterface(),
|
|
1012
990
|
Image: import_image.Image,
|
|
1013
991
|
Sprite: import_sprites.Sprite,
|
|
1014
992
|
TileMap: import_map.TileMap,
|
|
@@ -1019,40 +997,27 @@ function createRuntimeGlobalApi(context) {
|
|
|
1019
997
|
};
|
|
1020
998
|
}
|
|
1021
999
|
__name(createRuntimeGlobalApi, "createRuntimeGlobalApi");
|
|
1022
|
-
function convertSceneDefinition(definition, vm, listener) {
|
|
1023
|
-
if (!vm?.runner?.main_thread?.processor) {
|
|
1024
|
-
listener.log?.("[RuntimeController] VM not ready for scene conversion. Scene functions may not work correctly.");
|
|
1025
|
-
return definition;
|
|
1026
|
-
}
|
|
1027
|
-
const processor = vm.runner.main_thread.processor;
|
|
1028
|
-
const context = vm.context;
|
|
1029
|
-
const converted = {};
|
|
1030
|
-
for (const [key, value] of Object.entries(definition)) {
|
|
1031
|
-
if (value instanceof import_vm.Routine) {
|
|
1032
|
-
converted[key] = processor.routineAsFunction(value, context);
|
|
1033
|
-
continue;
|
|
1034
|
-
}
|
|
1035
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1036
|
-
converted[key] = convertSceneDefinition(value, vm, listener);
|
|
1037
|
-
continue;
|
|
1038
|
-
}
|
|
1039
|
-
converted[key] = value;
|
|
1040
|
-
}
|
|
1041
|
-
return converted;
|
|
1042
|
-
}
|
|
1043
|
-
__name(convertSceneDefinition, "convertSceneDefinition");
|
|
1044
|
-
function asSceneDefinition(definition) {
|
|
1045
|
-
if (!definition || typeof definition !== "object" || Array.isArray(definition)) {
|
|
1046
|
-
throw new Error("Scene definition must be an object.");
|
|
1047
|
-
}
|
|
1048
|
-
return definition;
|
|
1049
|
-
}
|
|
1050
|
-
__name(asSceneDefinition, "asSceneDefinition");
|
|
1051
1000
|
function cloneValue(value) {
|
|
1052
1001
|
if (value == null) {
|
|
1053
1002
|
return value;
|
|
1054
1003
|
}
|
|
1055
|
-
|
|
1004
|
+
if (value instanceof Date) {
|
|
1005
|
+
return new Date(value);
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1008
|
+
return value;
|
|
1009
|
+
}
|
|
1010
|
+
if (Array.isArray(value)) {
|
|
1011
|
+
return value.map((entry) => cloneValue(entry));
|
|
1012
|
+
}
|
|
1013
|
+
if (typeof value === "object") {
|
|
1014
|
+
const clone = {};
|
|
1015
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1016
|
+
clone[key] = cloneValue(entry);
|
|
1017
|
+
}
|
|
1018
|
+
return clone;
|
|
1019
|
+
}
|
|
1020
|
+
return null;
|
|
1056
1021
|
}
|
|
1057
1022
|
__name(cloneValue, "cloneValue");
|
|
1058
1023
|
|
|
@@ -1085,7 +1050,6 @@ var RuntimeControllerImpl = class {
|
|
|
1085
1050
|
input;
|
|
1086
1051
|
system;
|
|
1087
1052
|
playerService;
|
|
1088
|
-
sceneManager;
|
|
1089
1053
|
vm = null;
|
|
1090
1054
|
timeMachine = null;
|
|
1091
1055
|
constructor(options = {}) {
|
|
@@ -1112,7 +1076,6 @@ var RuntimeControllerImpl = class {
|
|
|
1112
1076
|
this.system.getAPI().update_rate = rate;
|
|
1113
1077
|
}, "setUpdateRate")
|
|
1114
1078
|
});
|
|
1115
|
-
this.sceneManager = new import_scene.SceneManager();
|
|
1116
1079
|
this.assetLoader = new AssetLoader(options.url || "", options.resources || {}, this.audio, this.listener);
|
|
1117
1080
|
this.logStep("RuntimeController constructed", {
|
|
1118
1081
|
width: this.screen.width,
|
|
@@ -1200,15 +1163,10 @@ var RuntimeControllerImpl = class {
|
|
|
1200
1163
|
}
|
|
1201
1164
|
exportSnapshot() {
|
|
1202
1165
|
const global = this.vm?.context?.global;
|
|
1203
|
-
const routerState = this.sceneManager.router.getState();
|
|
1204
1166
|
return {
|
|
1205
1167
|
version: 1,
|
|
1206
1168
|
global: global ? serializeGlobalSnapshot(global) : {},
|
|
1207
1169
|
session: this.getSession(),
|
|
1208
|
-
router: {
|
|
1209
|
-
path: routerState.path,
|
|
1210
|
-
sceneName: this.sceneManager.getCurrentSceneName()
|
|
1211
|
-
},
|
|
1212
1170
|
system: {
|
|
1213
1171
|
updateRate: this.system.getAPI().update_rate
|
|
1214
1172
|
}
|
|
@@ -1224,11 +1182,6 @@ var RuntimeControllerImpl = class {
|
|
|
1224
1182
|
if (snapshot.session) {
|
|
1225
1183
|
this.sessionSnapshot = cloneSnapshot(snapshot.session);
|
|
1226
1184
|
}
|
|
1227
|
-
if (snapshot.router.path) {
|
|
1228
|
-
this.sceneManager.router.replace(snapshot.router.path);
|
|
1229
|
-
} else if (snapshot.router.sceneName) {
|
|
1230
|
-
this.sceneManager.setActiveScene(snapshot.router.sceneName);
|
|
1231
|
-
}
|
|
1232
1185
|
}
|
|
1233
1186
|
updateSource(file, src, reinit = false) {
|
|
1234
1187
|
if (!this.sourceUpdater) return false;
|
|
@@ -1282,7 +1235,6 @@ var RuntimeControllerImpl = class {
|
|
|
1282
1235
|
input: this.input,
|
|
1283
1236
|
system: this.system,
|
|
1284
1237
|
playerService: this.playerService,
|
|
1285
|
-
sceneManager: this.sceneManager,
|
|
1286
1238
|
assets: this.assetRegistry,
|
|
1287
1239
|
bridge: this.options.bridge,
|
|
1288
1240
|
getVM: /* @__PURE__ */ __name(() => this.vm, "getVM"),
|
|
@@ -1306,7 +1258,6 @@ var RuntimeControllerImpl = class {
|
|
|
1306
1258
|
});
|
|
1307
1259
|
});
|
|
1308
1260
|
this.loadPrograms();
|
|
1309
|
-
this.initializeScenesAndRouter();
|
|
1310
1261
|
this.emitBridgeEvent("runtime.started", {});
|
|
1311
1262
|
}
|
|
1312
1263
|
loadPrograms() {
|
|
@@ -1360,21 +1311,6 @@ var RuntimeControllerImpl = class {
|
|
|
1360
1311
|
});
|
|
1361
1312
|
}
|
|
1362
1313
|
}
|
|
1363
|
-
initializeScenesAndRouter() {
|
|
1364
|
-
const registeredScenes = this.sceneManager.registry.getNames();
|
|
1365
|
-
this.logStep("router: initializing", {
|
|
1366
|
-
registeredScenes: registeredScenes.length,
|
|
1367
|
-
sceneNames: registeredScenes
|
|
1368
|
-
});
|
|
1369
|
-
this.sceneManager.router.init();
|
|
1370
|
-
const activeScene = this.sceneManager.hasActiveScene() ? this.sceneManager.getCurrentSceneName?.() || "unknown" : null;
|
|
1371
|
-
const routerState = this.sceneManager.router.getState();
|
|
1372
|
-
this.logStep("router: initialized", {
|
|
1373
|
-
activeScene: activeScene || "none",
|
|
1374
|
-
path: routerState.path,
|
|
1375
|
-
hasActiveScene: this.sceneManager.hasActiveScene()
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1378
1314
|
startGameLoop() {
|
|
1379
1315
|
this.logStep("loop: creating game loop");
|
|
1380
1316
|
this.gameLoop = new GameLoop({
|
|
@@ -1428,12 +1364,8 @@ var RuntimeControllerImpl = class {
|
|
|
1428
1364
|
this.updateGameLoopUpdateRate();
|
|
1429
1365
|
}
|
|
1430
1366
|
try {
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
} else {
|
|
1434
|
-
this.vm.call("update");
|
|
1435
|
-
this.vm.runner.tick();
|
|
1436
|
-
}
|
|
1367
|
+
this.vm.call("update");
|
|
1368
|
+
this.vm.runner.tick();
|
|
1437
1369
|
if (this.vm.error_info) {
|
|
1438
1370
|
const err = Object.assign({}, this.vm.error_info);
|
|
1439
1371
|
err.type = "update";
|
|
@@ -1452,12 +1384,8 @@ var RuntimeControllerImpl = class {
|
|
|
1452
1384
|
try {
|
|
1453
1385
|
this.screen.initDraw();
|
|
1454
1386
|
this.screen.updateInterface();
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
} else {
|
|
1458
|
-
this.vm.call("draw");
|
|
1459
|
-
this.vm.runner.tick();
|
|
1460
|
-
}
|
|
1387
|
+
this.vm.call("draw");
|
|
1388
|
+
this.vm.runner.tick();
|
|
1461
1389
|
reportWarnings(this.vm, this.listener);
|
|
1462
1390
|
if (this.vm.error_info) {
|
|
1463
1391
|
const err = Object.assign({}, this.vm.error_info);
|
|
@@ -1683,8 +1611,6 @@ var RuntimeControllerImpl = class {
|
|
|
1683
1611
|
this.frameCount = 0;
|
|
1684
1612
|
this.lastUpdateRate = -1;
|
|
1685
1613
|
this.isStopped = false;
|
|
1686
|
-
this.sceneManager.registry.clear();
|
|
1687
|
-
this.sceneManager.routeManager.clear();
|
|
1688
1614
|
}
|
|
1689
1615
|
logStep(message, payload) {
|
|
1690
1616
|
if (!this.options.debug?.lifecycle) return;
|
|
@@ -1770,7 +1696,6 @@ function isRuntimeSnapshot(value) {
|
|
|
1770
1696
|
if (!isRecord(value)) return false;
|
|
1771
1697
|
if (value.version !== 1) return false;
|
|
1772
1698
|
if (!isRecord(value.global)) return false;
|
|
1773
|
-
if (!("router" in value)) return false;
|
|
1774
1699
|
if (!("session" in value)) return false;
|
|
1775
1700
|
return true;
|
|
1776
1701
|
}
|