Skip to content

Commit e07af2b

Browse files
committed
feat(cursors): fix import cycles
1 parent cf982e8 commit e07af2b

File tree

12 files changed

+36
-45
lines changed

12 files changed

+36
-45
lines changed

packages/qwik/src/core/client/vnode-impl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import {
77
type VNodeJournal,
88
} from './vnode';
99
import type { ChoreArray } from './chore-array';
10-
import { _EFFECT_BACK_REF } from '../reactive-primitives/types';
11-
import { BackRef } from '../reactive-primitives/cleanup';
1210
import { isDev } from '@qwik.dev/core/build';
1311
import type { QElement } from '../shared/types';
12+
import { BackRef } from '../reactive-primitives/backref';
1413

1514
/** @internal */
1615
export abstract class VNode extends BackRef {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** @internal */
2+
export const _EFFECT_BACK_REF = Symbol('backRef');
3+
4+
/** Class for back reference to the EffectSubscription */
5+
export abstract class BackRef {
6+
[_EFFECT_BACK_REF]: Map<any, any> | undefined = undefined;
7+
}

packages/qwik/src/core/reactive-primitives/cleanup.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
// import { ensureMaterialized, vnode_isElementVNode, vnode_isVNode } from '../client/vnode';
2-
// import type { Container } from '../shared/types';
3-
// import { SignalImpl } from './impl/signal-impl';
4-
// import { WrappedSignalImpl } from './impl/wrapped-signal-impl';
5-
// import { StoreHandler, getStoreHandler } from './impl/store';
6-
// import { AsyncComputedSignalImpl } from './impl/async-computed-signal-impl';
7-
// import { _PROPS_HANDLER } from '../shared/utils/constants';
8-
import {
9-
EffectSubscriptionProp,
10-
_EFFECT_BACK_REF,
11-
type Consumer,
12-
type EffectProperty,
13-
type EffectSubscription,
14-
} from './types';
1+
import { ensureMaterialized, vnode_isElementVNode, vnode_isVNode } from '../client/vnode';
2+
import type { Container } from '../shared/types';
3+
import { SignalImpl } from './impl/signal-impl';
4+
import { WrappedSignalImpl } from './impl/wrapped-signal-impl';
5+
import { StoreHandler, getStoreHandler } from './impl/store';
6+
import { AsyncComputedSignalImpl } from './impl/async-computed-signal-impl';
7+
import { _PROPS_HANDLER } from '../shared/utils/constants';
8+
import { BackRef, _EFFECT_BACK_REF } from './backref';
9+
import { EffectSubscriptionProp, type Consumer, type EffectSubscription } from './types';
1510
import { isPropsProxy, type PropsProxyHandler } from '../shared/jsx/props-proxy';
1611

17-
/** Class for back reference to the EffectSubscription */
18-
export abstract class BackRef {
19-
[_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | undefined = undefined;
20-
}
21-
2212
export function clearAllEffects(container: Container, consumer: Consumer): void {
2313
if (vnode_isVNode(consumer) && vnode_isElementVNode(consumer)) {
2414
ensureMaterialized(consumer);

packages/qwik/src/core/reactive-primitives/impl/async-computed-signal-impl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import type { Container } from '../../shared/types';
44
import { isPromise, retryOnPromise } from '../../shared/utils/promises';
55
import { cleanupDestroyable } from '../../use/utils/destroyable';
66
import { cleanupFn, trackFn } from '../../use/utils/tracker';
7-
import type { BackRef } from '../cleanup';
7+
import { _EFFECT_BACK_REF, type BackRef } from '../backref';
88
import {
9-
_EFFECT_BACK_REF,
109
AsyncComputeQRL,
1110
EffectProperty,
1211
EffectSubscription,

packages/qwik/src/core/reactive-primitives/impl/computed-signal-impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import type { Container } from '../../shared/types';
55
import { isPromise } from '../../shared/utils/promises';
66
import { tryGetInvokeContext } from '../../use/use-core';
77
import { scheduleEffects, throwIfQRLNotResolved } from '../utils';
8-
import type { BackRef } from '../cleanup';
98
import { getSubscriber } from '../subscriber';
109
import { SerializationSignalFlags, ComputeQRL, EffectSubscription } from '../types';
11-
import { _EFFECT_BACK_REF, EffectProperty, NEEDS_COMPUTATION, SignalFlags } from '../types';
10+
import { EffectProperty, NEEDS_COMPUTATION, SignalFlags } from '../types';
1211
import { SignalImpl } from './signal-impl';
1312
import type { QRLInternal } from '../../shared/qrl/qrl-class';
13+
import { _EFFECT_BACK_REF, type BackRef } from '../backref';
1414

1515
const DEBUG = false;
1616
// eslint-disable-next-line no-console

packages/qwik/src/core/reactive-primitives/impl/wrapped-signal-impl.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@ import type { Container, HostElement } from '../../shared/types';
55
import { HOST_EFFECTS } from '../../shared/utils/markers';
66
import { ChoreBits } from '../../shared/vnode/enums/chore-bits.enum';
77
import { trackSignal } from '../../use/use-core';
8-
import type { BackRef } from '../cleanup';
98
import { getValueProp } from '../internal-api';
109
import type { AllSignalFlags, EffectSubscription } from '../types';
11-
import {
12-
_EFFECT_BACK_REF,
13-
EffectProperty,
14-
NEEDS_COMPUTATION,
15-
SignalFlags,
16-
WrappedSignalFlags,
17-
} from '../types';
10+
import { EffectProperty, NEEDS_COMPUTATION, SignalFlags, WrappedSignalFlags } from '../types';
1811
import { isSignal, scheduleEffects } from '../utils';
1912
import { SignalImpl } from './signal-impl';
2013
import { markVNodeDirty } from '../../shared/vnode/vnode-dirty';
14+
import { _EFFECT_BACK_REF, type BackRef } from '../backref';
2115

2216
export class WrappedSignalImpl<T> extends SignalImpl<T> implements BackRef {
2317
$args$: any[];

packages/qwik/src/core/reactive-primitives/subscriber.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { isServer } from '@qwik.dev/core/build';
22
import { QBackRefs } from '../shared/utils/markers';
33
import type { ISsrNode } from '../ssr/ssr-types';
4-
import { BackRef } from './cleanup';
54
import type { Consumer, EffectProperty, EffectSubscription } from './types';
6-
import { _EFFECT_BACK_REF, EffectSubscriptionProp } from './types';
5+
import { EffectSubscriptionProp } from './types';
6+
import { _EFFECT_BACK_REF, type BackRef } from './backref';
77

88
export function getSubscriber(
99
effect: Consumer,

packages/qwik/src/core/reactive-primitives/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ import type { VNode } from '../shared/vnode/vnode';
2323
*/
2424
export const NEEDS_COMPUTATION: any = Symbol('invalid');
2525

26-
/** @internal */
27-
export const _EFFECT_BACK_REF = Symbol('backRef');
28-
2926
export interface InternalReadonlySignal<T = unknown> extends ReadonlySignal<T> {
3027
readonly untrackedValue: T;
3128
}

packages/qwik/src/core/shared/serdes/serialization-context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export let isDomRef = (obj: unknown): obj is DomRef => false;
3030
* A back reference to a previously serialized object. Before deserialization, all backrefs are
3131
* swapped with their original locations.
3232
*/
33-
export class BackRef {
33+
export class SerializationBackRef {
3434
constructor(
3535
/** The path from root to the original object */
3636
public $path$: string
@@ -156,7 +156,7 @@ export const createSerializationContext = (
156156
if (index === undefined) {
157157
index = roots.length;
158158
}
159-
roots[index] = new BackRef(path);
159+
roots[index] = new SerializationBackRef(path);
160160
ref.$parent$ = null;
161161
ref.$index$ = index;
162162
};

packages/qwik/src/core/shared/serdes/serialize.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ import { isPromise, maybeThen } from '../utils/promises';
3838
import { fastSkipSerialize, SerializerSymbol } from './verify';
3939
import { Constants, TypeIds } from './constants';
4040
import { qrlToString } from './qrl-to-string';
41-
import { BackRef, type SeenRef, type SerializationContext } from './serialization-context';
41+
import {
42+
SerializationBackRef,
43+
type SeenRef,
44+
type SerializationContext,
45+
} from './serialization-context';
4246

4347
/**
4448
* Format:
@@ -169,7 +173,7 @@ export async function serialize(serializationContext: SerializationContext): Pro
169173
}
170174

171175
// Now we know it's a root and we should output a RootRef
172-
const rootIdx = value instanceof BackRef ? value.$path$ : seen.$index$;
176+
const rootIdx = value instanceof SerializationBackRef ? value.$path$ : seen.$index$;
173177

174178
// But make sure we do output ourselves
175179
if (!parent && rootIdx === index) {
@@ -280,7 +284,7 @@ export async function serialize(serializationContext: SerializationContext): Pro
280284
output(TypeIds.Constant, Constants.EMPTY_OBJ);
281285
} else if (value === null) {
282286
output(TypeIds.Constant, Constants.Null);
283-
} else if (value instanceof BackRef) {
287+
} else if (value instanceof SerializationBackRef) {
284288
output(TypeIds.RootRef, value.$path$);
285289
} else {
286290
const newSeenRef = getSeenRefOrOutput(value, index);

0 commit comments

Comments
 (0)