@ -113,6 +113,26 @@ export let current_component_context = null;
/** @param {import('#client').ComponentContext | null} context */
export function set _current _component _context ( context ) {
current _component _context = context ;
if ( DEV ) {
dev _current _component _function = context ? . function ;
}
}
/ * *
* The current component function . Different from current component context :
* ` ` ` html
* <!-- App . svelte -- >
* < Foo >
* < Bar / > <!-- context == Foo . svelte , function == App . svelte -- >
* < / F o o >
* ` ` `
* @ type { import ( '#client' ) . ComponentContext [ 'function' ] }
* /
export let dev _current _component _function = null ;
/** @param {import('#client').ComponentContext['function']} fn */
export function set _dev _current _component _function ( fn ) {
dev _current _component _function = fn ;
}
/** @returns {boolean} */
@ -400,7 +420,7 @@ export function execute_effect(effect) {
var previous _component _context = current _component _context ;
current _effect = effect ;
current_component _context = component _context ;
set_current _component _context ( component _context ) ;
try {
if ( ( flags & BLOCK _EFFECT ) === 0 ) {
@ -412,7 +432,7 @@ export function execute_effect(effect) {
effect . teardown = typeof teardown === 'function' ? teardown : null ;
} finally {
current _effect = previous _effect ;
current_component _context = previous _component _context ;
set_current _component _context ( previous _component _context ) ;
}
}
@ -885,8 +905,8 @@ export function getContext(key) {
const result = /** @type {T} */ ( context _map . get ( key ) ) ;
if ( DEV ) {
// @ts-expect-error
const fn = current _component _context . function ;
const fn = /** @type {import('#client').ComponentContext} */ ( current _component _context )
. function ;
if ( fn ) {
add _owner ( result , fn , true ) ;
}
@ -940,7 +960,6 @@ export function getAllContexts() {
const context _map = get _or _init _context _map ( 'getAllContexts' ) ;
if ( DEV ) {
// @ts-expect-error
const fn = current _component _context ? . function ;
if ( fn ) {
for ( const value of context _map . values ( ) ) {
@ -1066,8 +1085,8 @@ export function push(props, runes = false, fn) {
if ( DEV ) {
// component function
// @ts-expect-error
current _component _context . function = fn ;
dev _current _component _function = fn ;
}
}
@ -1089,7 +1108,7 @@ export function pop(component) {
effect ( effects [ i ] ) ;
}
}
current_component _context = context _stack _item . p ;
set_current _component _context ( context _stack _item . p ) ;
context _stack _item . m = true ;
}
// Micro-optimization: Don't set .a above to the empty object