Skip to content

Commit bc9b6d3

Browse files
committed
fix(router): don't use mangled qwik method
1 parent f404787 commit bc9b6d3

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

packages/qwik-router/src/runtime/src/route-loaders.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { implicit$FirstArg, isDev, isServer, type QRL } from '@qwik.dev/core';
22
import {
33
_deserialize,
44
_getContextEvent,
5+
_injectAsyncSignalValue,
56
_resolveContextWithoutSequentialScope,
67
_verifySerializable,
78
createAsync$,
@@ -438,13 +439,14 @@ export const ensureRouteLoaderSignals = (
438439
};
439440

440441
/**
441-
* Inject a pre-loaded value into an AsyncSignal while preserving track() subscriptions. Uses
442-
* invalidate({ __v }) + $computeIfNeeded$() so the compute function runs synchronously, registers
443-
* subscriptions via track(), and returns the pre-loaded value without fetching.
442+
* Inject a pre-loaded value into an AsyncSignal while preserving track() subscriptions. Delegates
443+
* to the core helper which calls invalidate({ __v }) + $computeIfNeeded$() so the compute function
444+
* runs synchronously, registers subscriptions via track(), and returns the pre-loaded value without
445+
* fetching. Must go through the core helper because $computeIfNeeded$ is mangled in core builds and
446+
* not directly callable from this package.
444447
*/
445448
export const setLoaderSignalValue = (signal: AsyncSignal<unknown>, value: unknown) => {
446-
signal.invalidate({ __v: value });
447-
(signal as any).$computeIfNeeded$();
449+
_injectAsyncSignalValue(signal, value);
448450
};
449451

450452
export const resolveRouteLoaderByHash = (

packages/qwik/src/core/internal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export { isTask as _isTask, scheduleTask as _task, Task as _Task } from './use/u
8484
export { _captures } from './shared/qrl/qrl-class';
8585
export { _rsc } from './use/use-resource';
8686
export type { AsyncSignalImpl as _AsyncSignalImpl } from './reactive-primitives/impl/async-signal-impl';
87+
export { _injectAsyncSignalValue } from './reactive-primitives/impl/async-signal-impl';
8788
export {
8889
EffectProperty as _EffectProperty,
8990
StoreFlags as _StoreFlags,

packages/qwik/src/core/qwik.core.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ export const _IMMUTABLE: unique symbol;
572572
// @public
573573
export const implicit$FirstArg: <FIRST, REST extends any[], RET>(fn: (qrl: QRL<FIRST>, ...rest: REST) => RET) => ((qrl: FIRST, ...rest: REST) => RET);
574574

575+
// @internal
576+
export const _injectAsyncSignalValue: (signal: AsyncSignal<unknown>, value: unknown) => void;
577+
575578
// @public
576579
export const inlinedQrl: <T>(symbol: T | null, symbolName: string, lexicalScopeCapture?: Readonly<unknown[]>) => QRL<T>;
577580

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,17 @@ export class AsyncSignalImpl<T>
561561
this.$computeIfNeeded$();
562562
}
563563
}
564+
565+
/**
566+
* Inject a pre-loaded value into an AsyncSignal while preserving track() subscriptions. Calls
567+
* `invalidate({ __v })` so the compute function reads the value from `info`, then triggers an
568+
* immediate synchronous compute via the private $computeIfNeeded$() method (which is mangled in
569+
* core builds, so callers from other packages must go through this helper).
570+
*
571+
* @internal
572+
*/
573+
export const _injectAsyncSignalValue = (signal: AsyncSignal<unknown>, value: unknown) => {
574+
const impl = signal as AsyncSignalImpl<unknown>;
575+
impl.invalidate({ __v: value });
576+
impl.$computeIfNeeded$();
577+
};

0 commit comments

Comments
 (0)