@@ -1260,29 +1260,32 @@ export function unwrap(value) {
1260
1260
if ( DEV ) {
1261
1261
/**
1262
1262
* @param {string } rune
1263
- * @param {string[] } [variants]
1264
1263
*/
1265
- function throw_rune_error ( rune , variants = [ ] ) {
1264
+ function throw_rune_error ( rune ) {
1266
1265
if ( ! ( rune in globalThis ) ) {
1267
1266
// TODO if people start adjusting the "this can contain runes" config through v-p-s more, adjust this message
1268
- // @ts -ignore
1269
- globalThis [ rune ] = ( ) => {
1270
- throw new Error ( `${ rune } () is only available inside .svelte and .svelte.js/ts files` ) ;
1271
- } ;
1272
- for ( const variant of variants ) {
1273
- // @ts -ignore
1274
- globalThis [ rune ] [ variant ] = ( ) => {
1267
+ /** @type {any } */
1268
+ let value ; // let's hope noone modifies this global, but belts and braces
1269
+ Object . defineProperty ( globalThis , rune , {
1270
+ configurable : true ,
1271
+ get : ( ) => {
1272
+ if ( value !== undefined ) {
1273
+ return value ;
1274
+ }
1275
1275
throw new Error (
1276
- `${ rune } . ${ variant } () is only available inside .svelte and .svelte.js/ts files`
1276
+ `The ${ rune } rune is only available inside .svelte and .svelte.js/ts files`
1277
1277
) ;
1278
- } ;
1279
- }
1278
+ } ,
1279
+ set : ( v ) => {
1280
+ value = v ;
1281
+ }
1282
+ } ) ;
1280
1283
}
1281
1284
}
1282
1285
1283
- throw_rune_error ( '$state' , [ 'frozen' ] ) ;
1284
- throw_rune_error ( '$effect' , [ 'pre' , 'root' , 'active' ] ) ;
1285
- throw_rune_error ( '$derived' , [ 'by' ] ) ;
1286
+ throw_rune_error ( '$state' ) ;
1287
+ throw_rune_error ( '$effect' ) ;
1288
+ throw_rune_error ( '$derived' ) ;
1286
1289
throw_rune_error ( '$inspect' ) ;
1287
1290
throw_rune_error ( '$props' ) ;
1288
1291
throw_rune_error ( '$bindable' ) ;
0 commit comments