move events library implementation to core:internal/events & disable access to core:internal modules outside of stdlib
This commit is contained in:
@@ -550,6 +550,8 @@ function reload_module(name)
|
||||
end
|
||||
end
|
||||
|
||||
local internal_locked = false
|
||||
|
||||
-- Load script with caching
|
||||
--
|
||||
-- path - script path `contentpack:filename`.
|
||||
@@ -559,6 +561,11 @@ end
|
||||
function __load_script(path, nocache)
|
||||
local packname, filename = parse_path(path)
|
||||
|
||||
if internal_locked and (packname == "res" or packname == "core")
|
||||
and filename:starts_with("modules/internal") then
|
||||
error("access to core:internal modules outside of [core]")
|
||||
end
|
||||
|
||||
-- __cached_scripts used in condition because cached result may be nil
|
||||
if not nocache and __cached_scripts[path] ~= nil then
|
||||
return package.loaded[path]
|
||||
@@ -579,6 +586,10 @@ function __load_script(path, nocache)
|
||||
return result
|
||||
end
|
||||
|
||||
function __vc_lock_internal_modules()
|
||||
internal_locked = true
|
||||
end
|
||||
|
||||
function require(path)
|
||||
if not string.find(path, ':') then
|
||||
local prefix, _ = parse_path(_debug_getinfo(2).source)
|
||||
|
||||
Reference in New Issue
Block a user