|
|
@@ -13,6 +13,7 @@
|
|
|
#include "WallpaperEngine/Render/CObject.h"
|
|
|
#include "WallpaperEngine/Render/Objects/CSound.h"
|
|
|
#include "WallpaperEngine/Render/Wallpapers/CScene.h"
|
|
|
+#include "WallpaperEngine/Scripting/Builtins.generated.h"
|
|
|
#include "quickjs.h"
|
|
|
|
|
|
#include <algorithm>
|
|
|
@@ -442,27 +443,10 @@ void ScriptEngine::installBuiltins () {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- static constexpr const char* builtins = R"JS(
|
|
|
-globalThis.__intervals = Object.create(null);
|
|
|
-globalThis.localStorage = globalThis.localStorage || {
|
|
|
- __data: Object.create(null),
|
|
|
- get(key) {
|
|
|
- key = String(key);
|
|
|
- return Object.prototype.hasOwnProperty.call(this.__data, key) ? this.__data[key] : null;
|
|
|
- },
|
|
|
- set(key, value) { this.__data[String(key)] = String(value); },
|
|
|
- remove(key) { delete this.__data[String(key)]; },
|
|
|
- clear() { this.__data = Object.create(null); }
|
|
|
-};
|
|
|
-globalThis.MediaPlaybackEvent = globalThis.MediaPlaybackEvent || {
|
|
|
- PLAYBACK_STOPPED: 0,
|
|
|
- PLAYBACK_PLAYING: 1,
|
|
|
- PLAYBACK_PAUSED: 2
|
|
|
-};
|
|
|
-)JS";
|
|
|
-
|
|
|
- JSValue result
|
|
|
- = JS_Eval (this->m_context, builtins, strlen (builtins), "<scene-script-builtins>", JS_EVAL_TYPE_GLOBAL);
|
|
|
+ JSValue result = JS_Eval (
|
|
|
+ this->m_context, SCENE_SCRIPT_BUILTINS, strlen (SCENE_SCRIPT_BUILTINS), "<scene-script-builtins>",
|
|
|
+ JS_EVAL_TYPE_GLOBAL
|
|
|
+ );
|
|
|
if (JS_IsException (result)) {
|
|
|
logJSException (this->m_context, "installBuiltins");
|
|
|
}
|