@@ -47,22 +47,18 @@ static luarequire_NavigateResult storePathResult(RequireCtx* reqCtx, PathResult
4747
4848static bool is_require_allowed (lua_State* L, void * ctx, const char * requirer_chunkname)
4949{
50- // FIXME: this is a temporary workaround until Luau.Require provides a way
51- // to perform proxy requires.
52- return true ;
53-
54- // std::string_view chunkname = requirer_chunkname;
55- // bool isStdin = (chunkname == "=stdin");
56- // bool isFile = (!chunkname.empty() && chunkname[0] == '@');
57- // bool isStdLibFile = (chunkname.size() >= 6 && chunkname.substr(0, 6) == "@@std/");
58- // return isStdin || isFile || isStdLibFile;
50+ std::string_view chunkname = requirer_chunkname;
51+ bool isStdin = (chunkname == " =stdin" );
52+ bool isFile = (!chunkname.empty () && chunkname[0 ] == ' @' );
53+ bool isStdLibFile = (chunkname.size () >= 6 && chunkname.substr (0 , 6 ) == " @@std/" );
54+ return isStdin || isFile || isStdLibFile;
5955}
6056
6157static luarequire_NavigateResult reset (lua_State* L, void * ctx, const char * requirer_chunkname)
6258{
6359 RequireCtx* reqCtx = static_cast <RequireCtx*>(ctx);
6460
65- std::string chunkname = reqCtx-> sourceOverride ? *reqCtx-> sourceOverride : requirer_chunkname;
61+ std::string chunkname = requirer_chunkname;
6662 reqCtx->atFakeRoot = false ;
6763
6864 if ((chunkname.size () >= 6 && chunkname.substr (0 , 6 ) == " @@std/" ))
@@ -91,18 +87,6 @@ static luarequire_NavigateResult jump_to_alias(lua_State* L, void* ctx, const ch
9187{
9288 RequireCtx* reqCtx = static_cast <RequireCtx*>(ctx);
9389
94- // FIXME: this is a temporary workaround until Luau.Require provides an
95- // API for registering the @lute/* libraries.
96- if (std::string_view (path) == " $lute" )
97- {
98- reqCtx->atFakeRoot = false ;
99- reqCtx->currentVFSType = VFSType::Lute;
100- reqCtx->absPath = " @lute" ;
101- reqCtx->relPath = " " ;
102- reqCtx->suffix = " " ;
103- return NAVIGATE_SUCCESS;
104- }
105-
10690 if (std::string_view (path) == " $std" )
10791 {
10892 reqCtx->atFakeRoot = false ;
@@ -150,36 +134,19 @@ static luarequire_NavigateResult to_child(lua_State* L, void* ctx, const char* n
150134static bool is_module_present (lua_State* L, void * ctx)
151135{
152136 RequireCtx* reqCtx = static_cast <RequireCtx*>(ctx);
153-
154- // FIXME: this is a temporary workaround until Luau.Require provides an
155- // API for registering the @lute/* libraries.
156- if (reqCtx->currentVFSType == VFSType::Lute)
157- return true ;
158-
159137 return isFilePresent (reqCtx->currentVFSType , reqCtx->absPath , reqCtx->suffix );
160138}
161139
162140static luarequire_WriteResult get_contents (lua_State* L, void * ctx, char * buffer, size_t buffer_size, size_t * size_out)
163141{
164142 RequireCtx* reqCtx = static_cast <RequireCtx*>(ctx);
165-
166- // FIXME: this is a temporary workaround until Luau.Require provides an
167- // API for registering the @lute/* libraries.
168- if (reqCtx->currentVFSType == VFSType::Lute)
169- return write (" " , buffer, buffer_size, size_out);
170-
171143 return write (getFileContents (reqCtx->currentVFSType , reqCtx->absPath , reqCtx->suffix ), buffer, buffer_size, size_out);
172144}
173145
174146static luarequire_WriteResult get_chunkname (lua_State* L, void * ctx, char * buffer, size_t buffer_size, size_t * size_out)
175147{
176148 RequireCtx* reqCtx = static_cast <RequireCtx*>(ctx);
177149
178- // FIXME: this is a temporary workaround until Luau.Require provides an
179- // API for registering the @lute/* libraries.
180- if (reqCtx->currentVFSType == VFSType::Lute)
181- return write (" @" + reqCtx->absPath , buffer, buffer_size, size_out);
182-
183150 if (reqCtx->currentVFSType == VFSType::Std)
184151 return write (" @" + reqCtx->absPath , buffer, buffer_size, size_out);
185152
@@ -198,11 +165,6 @@ static bool is_config_present(lua_State* L, void* ctx)
198165 if (reqCtx->atFakeRoot )
199166 return true ;
200167
201- // FIXME: this is a temporary workaround until Luau.Require provides an
202- // API for registering the @lute/* libraries.
203- if (reqCtx->currentVFSType == VFSType::Lute)
204- return false ;
205-
206168 return isFilePresent (reqCtx->currentVFSType , reqCtx->absPath , " /.luaurc" );
207169}
208170
@@ -214,7 +176,6 @@ static luarequire_WriteResult get_config(lua_State* L, void* ctx, char* buffer,
214176 std::string globalConfig = " {\n "
215177 " \" aliases\" : {\n "
216178 " \" std\" : \" $std\" ,\n "
217- " \" lute\" : \" $lute\" ,\n "
218179 " }\n "
219180 " }\n " ;
220181 return write (globalConfig, buffer, buffer_size, size_out);
@@ -223,24 +184,15 @@ static luarequire_WriteResult get_config(lua_State* L, void* ctx, char* buffer,
223184 return write (getFileContents (reqCtx->currentVFSType , reqCtx->absPath , " /.luaurc" ), buffer, buffer_size, size_out);
224185}
225186
226- static int load (lua_State* L, void * ctx, const char * chunkname, const char * contents)
187+ static int load (lua_State* L, void * ctx, const char * path, const char * chunkname, const char * contents)
227188{
228- std::string_view chunknameView = chunkname ;
189+ std::string_view pathView = path ;
229190
230- // FIXME: this is a temporary workaround until Luau.Require provides an
231- // API for registering the @lute/* libraries.
232- if (chunknameView.rfind (" @@lute/" , 0 ) == 0 )
191+ if (pathView.rfind (" @lute/" , 0 ) == 0 )
233192 {
234- lua_getfield (L, LUA_REGISTRYINDEX, " _MODULES" );
235- lua_getfield (L, -1 , chunknameView.substr (1 ).data ());
236-
237- if (lua_isnil (L, -1 ))
238- {
239- lua_pop (L, 1 );
240- luaL_error (L, " no luau runtime library: %s" , &chunkname[1 ]);
241- }
242-
243- return 1 ;
193+ // @lute library tables are registered into require-by-string directly
194+ // and are not loaded here.
195+ luaL_error (L, " no luau runtime library: %s" , path);
244196 }
245197
246198 // module needs to run in a new thread, isolated from the rest
@@ -266,7 +218,7 @@ static int load(lua_State* L, void* ctx, const char* chunkname, const char* cont
266218
267219 if (status == 0 )
268220 {
269- const std::string prefix = " module " + std::string (chunknameView. substr ( 1 ) ) + " must" ;
221+ const std::string prefix = " module " + std::string (pathView ) + " must" ;
270222
271223 if (lua_gettop (ML) == 0 )
272224 lua_pushstring (ML, (prefix + " return a value, if it has no return value, you should explicitly return `nil`\n " ).c_str ());
0 commit comments