feat(rbxl): XML-������ ������ .rbxl + Day/Night + Tool/Mouse/Backpack flow #38
@ -58,7 +58,7 @@ function makeSignal() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
sig.fire = sig.Fire;
|
sig.fire = sig.Fire;
|
||||||
sig.Wait = () => null;
|
sig.Wait = () => undefined;
|
||||||
sig.wait = sig.Wait;
|
sig.wait = sig.Wait;
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ function makeStubCallable() {
|
|||||||
fn.connect = fn.Connect;
|
fn.connect = fn.Connect;
|
||||||
fn.Fire = function () {};
|
fn.Fire = function () {};
|
||||||
fn.fire = fn.Fire;
|
fn.fire = fn.Fire;
|
||||||
fn.Wait = function () { return null; };
|
fn.Wait = function () { return undefined; };
|
||||||
fn.wait = fn.Wait;
|
fn.wait = fn.Wait;
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
@ -1403,7 +1403,13 @@ export function registerRobloxShim(lua, opts) {
|
|||||||
function __rbxl_drain_handler(fn, a1, a2, a3, a4)
|
function __rbxl_drain_handler(fn, a1, a2, a3, a4)
|
||||||
__rbxl_next_handler_id = __rbxl_next_handler_id + 1
|
__rbxl_next_handler_id = __rbxl_next_handler_id + 1
|
||||||
local handlerId = "handler_" .. __rbxl_next_handler_id
|
local handlerId = "handler_" .. __rbxl_next_handler_id
|
||||||
local co = coroutine.create(function() fn(a1, a2, a3, a4) end)
|
-- Оборачиваем call в pcall чтобы поглотить return value handler'а
|
||||||
|
-- (RayGun возвращает :connect(...) объект как последнее выражение,
|
||||||
|
-- что приводит к wasmoon promise-detection crash). pcall возвращает
|
||||||
|
-- (ok, ret1, ret2, ...) — мы их не используем.
|
||||||
|
local co = coroutine.create(function()
|
||||||
|
pcall(fn, a1, a2, a3, a4)
|
||||||
|
end)
|
||||||
__rbxl_register_coroutine(handlerId, co)
|
__rbxl_register_coroutine(handlerId, co)
|
||||||
local ok, ret = coroutine.resume(co)
|
local ok, ret = coroutine.resume(co)
|
||||||
if not ok then
|
if not ok then
|
||||||
@ -1414,6 +1420,7 @@ export function registerRobloxShim(lua, opts) {
|
|||||||
elseif coroutine.status(co) == 'dead' then
|
elseif coroutine.status(co) == 'dead' then
|
||||||
__rbxl_unregister_coroutine(handlerId)
|
__rbxl_unregister_coroutine(handlerId)
|
||||||
end
|
end
|
||||||
|
-- Явно ничего не возвращаем чтобы wasmoon не оборачивал nil
|
||||||
end
|
end
|
||||||
`);
|
`);
|
||||||
// Кешируем ссылку на Lua-функцию запуска handler'а
|
// Кешируем ссылку на Lua-функцию запуска handler'а
|
||||||
@ -1469,8 +1476,14 @@ export function registerRobloxShim(lua, opts) {
|
|||||||
const queue = _pendingHandlerQueue.splice(0, _pendingHandlerQueue.length);
|
const queue = _pendingHandlerQueue.splice(0, _pendingHandlerQueue.length);
|
||||||
for (const h of queue) {
|
for (const h of queue) {
|
||||||
try {
|
try {
|
||||||
|
// Только реальное число аргументов. wasmoon не любит
|
||||||
|
// undefined/null — может попытаться обернуть как promise.
|
||||||
const a = h.args || [];
|
const a = h.args || [];
|
||||||
luaDrainHandler(h.fn, a[0], a[1], a[2], a[3]);
|
if (a.length === 0) luaDrainHandler(h.fn);
|
||||||
|
else if (a.length === 1) luaDrainHandler(h.fn, a[0]);
|
||||||
|
else if (a.length === 2) luaDrainHandler(h.fn, a[0], a[1]);
|
||||||
|
else if (a.length === 3) luaDrainHandler(h.fn, a[0], a[1], a[2]);
|
||||||
|
else luaDrainHandler(h.fn, a[0], a[1], a[2], a[3]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[handler-drain]', e);
|
console.error('[handler-drain]', e);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user