|
|
@ -1260,29 +1260,32 @@ export function unwrap(value) {
|
|
|
|
if (DEV) {
|
|
|
|
if (DEV) {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {string} rune
|
|
|
|
* @param {string} rune
|
|
|
|
* @param {string[]} [variants]
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function throw_rune_error(rune, variants = []) {
|
|
|
|
function throw_rune_error(rune) {
|
|
|
|
if (!(rune in globalThis)) {
|
|
|
|
if (!(rune in globalThis)) {
|
|
|
|
// TODO if people start adjusting the "this can contain runes" config through v-p-s more, adjust this message
|
|
|
|
// TODO if people start adjusting the "this can contain runes" config through v-p-s more, adjust this message
|
|
|
|
// @ts-ignore
|
|
|
|
/** @type {any} */
|
|
|
|
globalThis[rune] = () => {
|
|
|
|
let value; // let's hope noone modifies this global, but belts and braces
|
|
|
|
throw new Error(`${rune}() is only available inside .svelte and .svelte.js/ts files`);
|
|
|
|
Object.defineProperty(globalThis, rune, {
|
|
|
|
};
|
|
|
|
configurable: true,
|
|
|
|
for (const variant of variants) {
|
|
|
|
get: () => {
|
|
|
|
// @ts-ignore
|
|
|
|
if (value !== undefined) {
|
|
|
|
globalThis[rune][variant] = () => {
|
|
|
|
return value;
|
|
|
|
|
|
|
|
}
|
|
|
|
throw new Error(
|
|
|
|
throw new Error(
|
|
|
|
`${rune}.${variant}() is only available inside .svelte and .svelte.js/ts files`
|
|
|
|
`The ${rune} rune is only available inside .svelte and .svelte.js/ts files`
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}
|
|
|
|
set: (v) => {
|
|
|
|
|
|
|
|
value = v;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
throw_rune_error('$state', ['frozen']);
|
|
|
|
throw_rune_error('$state');
|
|
|
|
throw_rune_error('$effect', ['pre', 'root', 'active']);
|
|
|
|
throw_rune_error('$effect');
|
|
|
|
throw_rune_error('$derived', ['by']);
|
|
|
|
throw_rune_error('$derived');
|
|
|
|
throw_rune_error('$inspect');
|
|
|
|
throw_rune_error('$inspect');
|
|
|
|
throw_rune_error('$props');
|
|
|
|
throw_rune_error('$props');
|
|
|
|
throw_rune_error('$bindable');
|
|
|
|
throw_rune_error('$bindable');
|
|
|
|