Skip to content

Commit

Permalink
after merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Varixo committed Aug 10, 2024
1 parent 54aa838 commit 9f3c4ee
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
7 changes: 4 additions & 3 deletions packages/qwik/src/core/state/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class ReadWriteProxyHandler implements ProxyHandler<TargetType> {

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;
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/use/use-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/v2/client/vnode-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
32 changes: 16 additions & 16 deletions packages/qwik/src/core/v2/shared/shared-serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -42,6 +41,7 @@ import {
Store2,
createStore2,
getStoreHandler2,
getStoreTarget2,
unwrapStore2,
type StoreHandler,
} from '../signal/v2-store';
Expand Down Expand Up @@ -97,7 +97,7 @@ class DeserializationHandler implements ProxyHandler<object> {
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
Expand All @@ -109,7 +109,7 @@ class DeserializationHandler implements ProxyHandler<object> {
* 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' &&
Expand Down Expand Up @@ -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('|');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1175,7 +1178,7 @@ function deserializeSignal2(
function deserializeSignal2Effect(
idx: number,
parts: string[],
container: DomContainer,
container: DeserializeContainer,
effects: EffectSubscriptions[]
) {
while (idx < parts.length) {
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion packages/qwik/src/core/v2/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9f3c4ee

Please sign in to comment.