@@ -47,22 +47,18 @@ static luarequire_NavigateResult storePathResult(RequireCtx* reqCtx, PathResult
47
47
48
48
static bool is_require_allowed (lua_State* L, void * ctx, const char * requirer_chunkname)
49
49
{
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;
59
55
}
60
56
61
57
static luarequire_NavigateResult reset (lua_State* L, void * ctx, const char * requirer_chunkname)
62
58
{
63
59
RequireCtx* reqCtx = static_cast <RequireCtx*>(ctx);
64
60
65
- std::string chunkname = reqCtx-> sourceOverride ? *reqCtx-> sourceOverride : requirer_chunkname;
61
+ std::string chunkname = requirer_chunkname;
66
62
reqCtx->atFakeRoot = false ;
67
63
68
64
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
91
87
{
92
88
RequireCtx* reqCtx = static_cast <RequireCtx*>(ctx);
93
89
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
-
106
90
if (std::string_view (path) == " $std" )
107
91
{
108
92
reqCtx->atFakeRoot = false ;
@@ -150,36 +134,19 @@ static luarequire_NavigateResult to_child(lua_State* L, void* ctx, const char* n
150
134
static bool is_module_present (lua_State* L, void * ctx)
151
135
{
152
136
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
-
159
137
return isFilePresent (reqCtx->currentVFSType , reqCtx->absPath , reqCtx->suffix );
160
138
}
161
139
162
140
static luarequire_WriteResult get_contents (lua_State* L, void * ctx, char * buffer, size_t buffer_size, size_t * size_out)
163
141
{
164
142
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
-
171
143
return write (getFileContents (reqCtx->currentVFSType , reqCtx->absPath , reqCtx->suffix ), buffer, buffer_size, size_out);
172
144
}
173
145
174
146
static luarequire_WriteResult get_chunkname (lua_State* L, void * ctx, char * buffer, size_t buffer_size, size_t * size_out)
175
147
{
176
148
RequireCtx* reqCtx = static_cast <RequireCtx*>(ctx);
177
149
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
-
183
150
if (reqCtx->currentVFSType == VFSType::Std)
184
151
return write (" @" + reqCtx->absPath , buffer, buffer_size, size_out);
185
152
@@ -198,11 +165,6 @@ static bool is_config_present(lua_State* L, void* ctx)
198
165
if (reqCtx->atFakeRoot )
199
166
return true ;
200
167
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
-
206
168
return isFilePresent (reqCtx->currentVFSType , reqCtx->absPath , " /.luaurc" );
207
169
}
208
170
@@ -214,7 +176,6 @@ static luarequire_WriteResult get_config(lua_State* L, void* ctx, char* buffer,
214
176
std::string globalConfig = " {\n "
215
177
" \" aliases\" : {\n "
216
178
" \" std\" : \" $std\" ,\n "
217
- " \" lute\" : \" $lute\" ,\n "
218
179
" }\n "
219
180
" }\n " ;
220
181
return write (globalConfig, buffer, buffer_size, size_out);
@@ -223,24 +184,15 @@ static luarequire_WriteResult get_config(lua_State* L, void* ctx, char* buffer,
223
184
return write (getFileContents (reqCtx->currentVFSType , reqCtx->absPath , " /.luaurc" ), buffer, buffer_size, size_out);
224
185
}
225
186
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)
227
188
{
228
- std::string_view chunknameView = chunkname ;
189
+ std::string_view pathView = path ;
229
190
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 )
233
192
{
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);
244
196
}
245
197
246
198
// 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
266
218
267
219
if (status == 0 )
268
220
{
269
- const std::string prefix = " module " + std::string (chunknameView. substr ( 1 ) ) + " must" ;
221
+ const std::string prefix = " module " + std::string (pathView ) + " must" ;
270
222
271
223
if (lua_gettop (ML) == 0 )
272
224
lua_pushstring (ML, (prefix + " return a value, if it has no return value, you should explicitly return `nil`\n " ).c_str ());
0 commit comments