@ -3,6 +3,7 @@ import { subscribe_to_store } from '../../store/utils.js';
import { EMPTY _FUNC , run _all } from '../common.js' ;
import { EMPTY _FUNC , run _all } from '../common.js' ;
import { get _descriptor , get _descriptors , is _array } from './utils.js' ;
import { get _descriptor , get _descriptors , is _array } from './utils.js' ;
import { PROPS _CALL _DEFAULT _VALUE , PROPS _IS _IMMUTABLE , PROPS _IS _RUNES } from '../../constants.js' ;
import { PROPS _CALL _DEFAULT _VALUE , PROPS _IS _IMMUTABLE , PROPS _IS _RUNES } from '../../constants.js' ;
import { readonly } from './proxy/readonly.js' ;
export const SOURCE = 1 ;
export const SOURCE = 1 ;
export const DERIVED = 1 << 1 ;
export const DERIVED = 1 << 1 ;
@ -1422,13 +1423,14 @@ export function is_store(val) {
export function prop _source ( props _obj , key , flags , default _value ) {
export function prop _source ( props _obj , key , flags , default _value ) {
const call _default _value = ( flags & PROPS _CALL _DEFAULT _VALUE ) !== 0 ;
const call _default _value = ( flags & PROPS _CALL _DEFAULT _VALUE ) !== 0 ;
const immutable = ( flags & PROPS _IS _IMMUTABLE ) !== 0 ;
const immutable = ( flags & PROPS _IS _IMMUTABLE ) !== 0 ;
const runes = ( flags & PROPS _IS _RUNES ) !== 0 ;
const props = is _signal ( props _obj ) ? get ( props _obj ) : props _obj ;
const props = is _signal ( props _obj ) ? get ( props _obj ) : props _obj ;
const update _bound _prop = get _descriptor ( props , key ) ? . set ;
const update _bound _prop = get _descriptor ( props , key ) ? . set ;
let value = props [ key ] ;
let value = props [ key ] ;
const should _set _default _value = value === undefined && default _value !== undefined ;
const should _set _default _value = value === undefined && default _value !== undefined ;
if ( update _bound _prop && default_value !== undefined && ( flags & PROPS _IS _RUNES ) !== 0 ) {
if ( update _bound _prop && runes && default_value !== undefined ) {
// TODO consolidate all these random runtime errors
// TODO consolidate all these random runtime errors
throw new Error ( 'Cannot use fallback values with bind:' ) ;
throw new Error ( 'Cannot use fallback values with bind:' ) ;
}
}
@ -1437,6 +1439,10 @@ export function prop_source(props_obj, key, flags, default_value) {
value =
value =
// @ts-expect-error would need a cumbersome method overload to type this
// @ts-expect-error would need a cumbersome method overload to type this
call _default _value ? default _value ( ) : default _value ;
call _default _value ? default _value ( ) : default _value ;
if ( DEV && runes ) {
value = readonly ( /** @type {any} */ ( value ) ) ;
}
}
}
const source _signal = immutable ? source ( value ) : mutable _source ( value ) ;
const source _signal = immutable ? source ( value ) : mutable _source ( value ) ;