|
|
|
@ -1,5 +1,5 @@
|
|
|
|
/** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
|
|
|
|
/** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
|
|
|
|
import { DIRTY, MAYBE_DIRTY } from '../internal/client/constants.js';
|
|
|
|
import { DIRTY, LEGACY_PROPS, MAYBE_DIRTY } from '../internal/client/constants.js';
|
|
|
|
import { user_pre_effect } from '../internal/client/reactivity/effects.js';
|
|
|
|
import { user_pre_effect } from '../internal/client/reactivity/effects.js';
|
|
|
|
import { mutable_source, set } from '../internal/client/reactivity/sources.js';
|
|
|
|
import { mutable_source, set } from '../internal/client/reactivity/sources.js';
|
|
|
|
import { hydrate, mount, unmount } from '../internal/client/render.js';
|
|
|
|
import { hydrate, mount, unmount } from '../internal/client/render.js';
|
|
|
|
@ -89,7 +89,7 @@ class Svelte4Component {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Replicate coarse-grained props through a proxy that has a version source for
|
|
|
|
// Replicate coarse-grained props through a proxy that has a version source for
|
|
|
|
// each property, which is increment on updates to the property itself. Do not
|
|
|
|
// each property, which is incremented on updates to the property itself. Do not
|
|
|
|
// use our $state proxy because that one has fine-grained reactivity.
|
|
|
|
// use our $state proxy because that one has fine-grained reactivity.
|
|
|
|
const props = new Proxy(
|
|
|
|
const props = new Proxy(
|
|
|
|
{ ...(options.props || {}), $$events: {} },
|
|
|
|
{ ...(options.props || {}), $$events: {} },
|
|
|
|
@ -98,26 +98,15 @@ class Svelte4Component {
|
|
|
|
return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
|
|
return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
has(target, prop) {
|
|
|
|
has(target, prop) {
|
|
|
|
|
|
|
|
// Necessary to not throw "invalid binding" validation errors on the component side
|
|
|
|
|
|
|
|
if (prop === LEGACY_PROPS) return true;
|
|
|
|
|
|
|
|
|
|
|
|
get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
|
|
get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
|
|
return Reflect.has(target, prop);
|
|
|
|
return Reflect.has(target, prop);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
set(target, prop, value) {
|
|
|
|
set(target, prop, value) {
|
|
|
|
set(sources.get(prop) ?? add_source(prop, value), value);
|
|
|
|
set(sources.get(prop) ?? add_source(prop, value), value);
|
|
|
|
return Reflect.set(target, prop, value);
|
|
|
|
return Reflect.set(target, prop, value);
|
|
|
|
},
|
|
|
|
|
|
|
|
getOwnPropertyDescriptor(target, prop) {
|
|
|
|
|
|
|
|
// TODO this throws "invalid binding" errors on the component side
|
|
|
|
|
|
|
|
const desc = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
|
|
|
|
|
|
if (!desc?.configurable) return desc;
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
get: () => get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop))),
|
|
|
|
|
|
|
|
set: (value) => {
|
|
|
|
|
|
|
|
set(sources.get(prop) ?? add_source(prop, value), value);
|
|
|
|
|
|
|
|
return Reflect.set(target, prop, value);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
enumerable: desc.enumerable,
|
|
|
|
|
|
|
|
configurable: desc.configurable
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|