diff --git a/packages/qwik/src/core/state/common.ts b/packages/qwik/src/core/state/common.ts index 0478dbd893a..bb7d5fbc3ee 100644 --- a/packages/qwik/src/core/state/common.ts +++ b/packages/qwik/src/core/state/common.ts @@ -290,8 +290,9 @@ export const serializeSubscription = (sub: Subscriptions, getObjId: GetObjID) => } if (type <= SubscriptionType.PROP_MUTABLE) { key = sub[SubscriptionProp.ELEMENT_PROP]; - base += ` ${signalID} ${must(getObjId(sub[SubscriptionProp.ELEMENT]))} ${sub[SubscriptionProp.ELEMENT_PROP] - }`; + base += ` ${signalID} ${must(getObjId(sub[SubscriptionProp.ELEMENT]))} ${ + sub[SubscriptionProp.ELEMENT_PROP] + }`; } else if (type <= SubscriptionType.TEXT_MUTABLE) { key = sub.length > SubscriptionProp.ELEMENT_PROP ? sub[SubscriptionProp.ELEMENT_PROP] : undefined; @@ -493,7 +494,7 @@ export class LocalSubscriptionManager { if (type == SubscriptionType.HOST) { if (isTask(host)) { if (isComputedTask(host)) { - scheduler(ChoreType.COMPUTED, host); + // scheduler(ChoreType.COMPUTED, host); } else if (isResourceTask(host)) { scheduler(ChoreType.RESOURCE, host); } else { diff --git a/packages/qwik/src/core/state/store.ts b/packages/qwik/src/core/state/store.ts index 83eb87c3cb6..08c8b60b4ff 100644 --- a/packages/qwik/src/core/state/store.ts +++ b/packages/qwik/src/core/state/store.ts @@ -197,7 +197,7 @@ export class ReadWriteProxyHandler implements ProxyHandler { set(target: TargetType, prop: string | symbol, newValue: any): boolean { // we need deserializer proxy only to get the value, not to set it - target = unwrapDeserializerProxy(target) as TargetType; + // target = unwrapDeserializerProxy(target) as TargetType; if (typeof prop === 'symbol') { target[prop] = newValue; return true; diff --git a/packages/qwik/src/core/use/use-task.ts b/packages/qwik/src/core/use/use-task.ts index 7ce8ba2ee96..66ee94772dd 100644 --- a/packages/qwik/src/core/use/use-task.ts +++ b/packages/qwik/src/core/use/use-task.ts @@ -28,7 +28,7 @@ import { ComputedEvent, ResourceEvent, TaskEvent } from '../util/markers'; import { delay, isPromise, safeCall } from '../util/promises'; import { isFunction, isObject, type ValueOrPromise } from '../util/types'; import { ChoreType } from '../v2/shared/scheduler'; -import { isContainer2, type Container2, type HostElement, type fixMeAny } from '../v2/shared/types'; +import { type Container2, type HostElement, type fixMeAny } from '../v2/shared/types'; import { ComputedSignal2, EffectProperty, throwIfQRLNotResolved } from '../v2/signal/v2-signal'; import { type ReadonlySignal2, type Signal2 } from '../v2/signal/v2-signal.public'; import { invoke, newInvokeContext, untrack, waitAndRun } from './use-core'; diff --git a/packages/qwik/src/core/v2/client/vnode-diff.ts b/packages/qwik/src/core/v2/client/vnode-diff.ts index 66d05ae3630..1cec5f6c2d1 100644 --- a/packages/qwik/src/core/v2/client/vnode-diff.ts +++ b/packages/qwik/src/core/v2/client/vnode-diff.ts @@ -762,7 +762,7 @@ export const vnode_diff = ( if (key === 'ref') { const element = vnode_getNode(vnode) as Element; - if (isSignal(value)) { + if (isSignal2(value)) { value.value = element; return; } else if (typeof value === 'function') { diff --git a/packages/qwik/src/core/v2/shared/shared-serialization.ts b/packages/qwik/src/core/v2/shared/shared-serialization.ts index b305c08f5b5..02493c472b6 100644 --- a/packages/qwik/src/core/v2/shared/shared-serialization.ts +++ b/packages/qwik/src/core/v2/shared/shared-serialization.ts @@ -26,7 +26,6 @@ import { _CONST_PROPS, _VAR_PROPS } from '../../state/constants'; import { Task, isTask, type ResourceReturnInternal } from '../../use/use-task'; import { EMPTY_OBJ } from '../../util/flyweight'; import { throwErrorAndStop } from '../../util/log'; -import { ELEMENT_ID } from '../../util/markers'; import { isPromise } from '../../util/promises'; import { isSerializableObject, type ValueOrPromise } from '../../util/types'; import { type DomContainer } from '../client/dom-container'; @@ -42,6 +41,7 @@ import { Store2, createStore2, getStoreHandler2, + getStoreTarget2, unwrapStore2, type StoreHandler, } from '../signal/v2-store'; @@ -97,7 +97,7 @@ class DeserializationHandler implements ProxyHandler { if (property === SERIALIZER_PROXY_UNWRAP) { return target; } - if (getProxyTarget(target) !== undefined) { + if (getStoreTarget2(target) !== undefined) { /** * If we modify string value by for example `+=` operator, we need to get the old value first. * If the target is a store proxy, we need to unwrap it and get the real object. This is @@ -109,7 +109,7 @@ class DeserializationHandler implements ProxyHandler { * constant character, we need to have the SerializationConstant.String_CHAR prefix character. * Otherwise the system will try to deserialize the value again. */ - const unwrapped = unwrapDeserializerProxy(unwrapProxy(target)) as object; + const unwrapped = unwrapDeserializerProxy(unwrapStore2(target)) as object; const unwrappedPropValue = Reflect.get(unwrapped, property, receiver); if ( typeof unwrappedPropValue === 'string' && @@ -311,7 +311,7 @@ const inflate = (container: DeserializeContainer, target: any, needsInflationDat break; case SerializationConstant.Store_VALUE: const storeHandler = getStoreHandler2(target)!; - storeHandler.$container$ = container; + storeHandler.$container$ = container as DomContainer; storeHandler.$target$ = container.$getObjectById$(restInt()); storeHandler.$flags$ = restInt(); const effectProps = rest.substring(restIdx).split('|'); @@ -703,12 +703,15 @@ export const createSerializationContext = ( const unwrapObj = unwrapStore2(obj); if (unwrapObj !== obj) { discoveredValues.push(unwrapObj); - const manager = getSubscriptionManager(obj as object)!; - - // add subscription host to the discovered values - for (const sub of manager.$subs$) { - for (let i = SubscriptionProp.HOST; i < sub.length; i++) { - discoveredValues.push(sub[i]); + const storeHandler = getStoreHandler2(obj as object); + const effects = storeHandler?.$effects$; + + if (effects) { + // add effect to the discovered values + for (const propName in effects) { + for (const effect of effects[propName]) { + discoveredValues.push(effect); + } } } } else if (id === undefined || isRoot) { @@ -1138,12 +1141,12 @@ function serializeDerivedFn( function deserializeSignal2( signal: Signal2, - container: DomContainer, + container: DeserializeContainer, data: string, readFn: boolean, readQrl: boolean ) { - signal.$container$ = container; + signal.$container$ = container as DomContainer; const parts = data.substring(1).split(';'); let idx = 0; if (readFn) { @@ -1175,7 +1178,7 @@ function deserializeSignal2( function deserializeSignal2Effect( idx: number, parts: string[], - container: DomContainer, + container: DeserializeContainer, effects: EffectSubscriptions[] ) { while (idx < parts.length) { @@ -1385,11 +1388,8 @@ function createDeserializeContainer( const fn = () => {}; return fn; }, - $subsManager$: null!, element: null, }; - const subsManager = createSubscriptionManager(container as fixMeAny); - container.$subsManager$ = subsManager; if (element) { container.element = element; } diff --git a/packages/qwik/src/core/v2/shared/types.ts b/packages/qwik/src/core/v2/shared/types.ts index 822a32c5386..b9e7ac1bdce 100644 --- a/packages/qwik/src/core/v2/shared/types.ts +++ b/packages/qwik/src/core/v2/shared/types.ts @@ -13,7 +13,6 @@ export type fixMeAny = any; export interface DeserializeContainer { $getObjectById$: (id: number | string) => unknown; - $subsManager$: SubscriptionManager; element: HTMLElement | null; getSyncFn: (id: number) => (...args: unknown[]) => unknown; }