Skip to content

feat: export isStore and isTask functions; update API documentation #7716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 25, 2025
3 changes: 3 additions & 0 deletions packages/qwik/src/core/client/util-mapArray.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assertTrue } from '../shared/error/assert';

/** @internal */
export const mapApp_findIndx = <T>(array: (T | null)[], key: string, start: number): number => {
assertTrue(start % 2 === 0, 'Expecting even number.');
let bottom = (start as number) >> 1;
Expand All @@ -19,6 +20,7 @@ export const mapApp_findIndx = <T>(array: (T | null)[], key: string, start: numb
return (bottom << 1) ^ -1;
};

/** @internal */
export const mapArray_set = <T>(
array: (T | null)[],
key: string,
Expand Down Expand Up @@ -48,6 +50,7 @@ export const mapApp_remove = <T>(array: (T | null)[], key: string, start: number
return value;
};

/** @internal */
export const mapArray_get = <T>(array: (T | null)[], key: string, start: number): T | null => {
const indx = mapApp_findIndx(array, key, start);
if (indx >= 0) {
Expand Down
10 changes: 10 additions & 0 deletions packages/qwik/src/core/client/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export const vnode_isElementOrVirtualVNode = (
return (flag & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) !== 0;
};

/** @internal */
export const vnode_isMaterialized = (vNode: VNode): boolean => {
assertDefined(vNode, 'Missing vNode');
const flag = (vNode as VNode)[VNodeProps.flags];
Expand All @@ -327,12 +328,14 @@ export const vnode_isMaterialized = (vNode: VNode): boolean => {
);
};

/** @internal */
export const vnode_isTextVNode = (vNode: VNode): vNode is TextVNode => {
assertDefined(vNode, 'Missing vNode');
const flag = (vNode as VNode)[VNodeProps.flags];
return (flag & VNodeFlags.Text) === VNodeFlags.Text;
};

/** @internal */
export const vnode_isVirtualVNode = (vNode: VNode): vNode is VirtualVNode => {
assertDefined(vNode, 'Missing vNode');
const flag = (vNode as VNode)[VNodeProps.flags];
Expand Down Expand Up @@ -384,6 +387,7 @@ export const vnode_getNodeTypeName = (vNode: VNode): string => {
return '<unknown>';
};

/** @internal */
export const vnode_ensureElementInflated = (vnode: VNode) => {
const flags = vnode[VNodeProps.flags];
if ((flags & VNodeFlags.INFLATED_TYPE_MASK) === VNodeFlags.Element) {
Expand Down Expand Up @@ -1233,6 +1237,7 @@ export const vnode_setText = (journal: VNodeJournal, textVNode: TextVNode, text:
journal.push(VNodeJournalOpCode.SetText, textNode, (textVNode[TextVNodeProps.text] = text));
};

/** @internal */
export const vnode_getFirstChild = (vnode: VNode): VNode | null => {
if (vnode_isTextVNode(vnode)) {
return null;
Expand Down Expand Up @@ -1592,6 +1597,7 @@ const processVNodeData = (
}
};

/** @internal */
export const vnode_getNextSibling = (vnode: VNode): VNode | null => {
return vnode[VNodeProps.nextSibling];
};
Expand All @@ -1600,6 +1606,7 @@ export const vnode_getPreviousSibling = (vnode: VNode): VNode | null => {
return vnode[VNodeProps.previousSibling];
};

/** @internal */
export const vnode_getAttrKeys = (vnode: ElementVNode | VirtualVNode): string[] => {
const type = vnode[VNodeProps.flags];
if ((type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) !== 0) {
Expand Down Expand Up @@ -1651,6 +1658,7 @@ export const vnode_setAttr = (
}
};

/** @internal */
export const vnode_getAttr = (vnode: VNode, key: string): string | null => {
const type = vnode[VNodeProps.flags];
if ((type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) !== 0) {
Expand Down Expand Up @@ -1693,6 +1701,7 @@ export const vnode_setProp = (vnode: VirtualVNode | ElementVNode, key: string, v
}
};

/** @internal */
export const vnode_getPropStartIndex = (vnode: VNode): number => {
const type = vnode[VNodeProps.flags] & VNodeFlags.TYPE_MASK;
if (type === VNodeFlags.Element) {
Expand All @@ -1703,6 +1712,7 @@ export const vnode_getPropStartIndex = (vnode: VNode): number => {
throw qError(QError.invalidVNodeType, [type]);
};

/** @internal */
export const vnode_getProps = (vnode: VNode): unknown[] => {
return vnode[vnode_getPropStartIndex(vnode)] as unknown[];
};
Expand Down
23 changes: 21 additions & 2 deletions packages/qwik/src/core/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,25 @@ export type {
VNode as _VNode,
VNodeFlags as _VNodeFlags,
} from './client/types';
export { vnode_toString as _vnode_toString } from './client/vnode';
export {
vnode_toString as _vnode_toString,
vnode_getPropStartIndex as _vnode_getPropStartIndex,
vnode_getProps as _vnode_getProps,
vnode_isTextVNode as _vnode_isTextVNode,
vnode_isVirtualVNode as _vnode_isVirtualVNode,
vnode_getFirstChild as _vnode_getFirstChild,
vnode_isMaterialized as _vnode_isMaterialized,
vnode_getNextSibling as _vnode_getNextSibling,
vnode_ensureElementInflated as _vnode_ensureElementInflated,
vnode_getAttrKeys as _vnode_getAttrKeys,
vnode_getAttr as _vnode_getAttr,
} from './client/vnode';
export {
mapApp_findIndx as _mapApp_findIndx,
mapArray_get as _mapArray_get,
mapArray_set as _mapArray_set,
} from './client/util-mapArray';

export { _wrapProp, _wrapSignal } from './reactive-primitives/internal-api';
export { SubscriptionData as _SubscriptionData } from './reactive-primitives/subscription-data';
export { _EFFECT_BACK_REF } from './reactive-primitives/types';
Expand Down Expand Up @@ -52,5 +70,6 @@ export {
_jsxBranch,
_waitUntilRendered,
} from './use/use-core';
export { scheduleTask as _task } from './use/use-task';
export { scheduleTask as _task, isTask as _isTask } from './use/use-task';
export { isStore as _isStore } from './reactive-primitives/impl/store';
export { _resolveContextWithoutSequentialScope } from './use/use-context';
49 changes: 49 additions & 0 deletions packages/qwik/src/core/qwik.core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,19 @@ export interface ISsrComponentFrame {
scopedStyleIds: Set<string>;
}

// Warning: (ae-forgotten-export) The symbol "StoreTarget" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
export const _isStore: (value: StoreTarget) => boolean;

// @internal (undocumented)
export function _isStringifiable(value: unknown): value is _Stringifiable;

// Warning: (ae-forgotten-export) The symbol "Task" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
export const _isTask: (value: any) => value is Task;

// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
//
// @public
Expand Down Expand Up @@ -501,6 +511,15 @@ export type JSXTagName = keyof HTMLElementTagNameMap | Omit<string, keyof HTMLEl
// @public
export type KnownEventNames = LiteralUnion<AllEventKeys, string>;

// @internal (undocumented)
export const _mapApp_findIndx: <T>(array: (T | null)[], key: string, start: number) => number;

// @internal (undocumented)
export const _mapArray_get: <T>(array: (T | null)[], key: string, start: number) => T | null;

// @internal (undocumented)
export const _mapArray_set: <T>(array: (T | null)[], key: string, value: T | null, start: number) => void;

// @public @deprecated (undocumented)
export type NativeAnimationEvent = AnimationEvent;

Expand Down Expand Up @@ -1828,6 +1847,36 @@ export type VisibleTaskStrategy = 'intersection-observer' | 'document-ready' | '
// @internal (undocumented)
export type _VNode = _ElementVNode | _TextVNode | _VirtualVNode;

// @internal (undocumented)
export const _vnode_ensureElementInflated: (vnode: _VNode) => void;

// @internal (undocumented)
export const _vnode_getAttr: (vnode: _VNode, key: string) => string | null;

// @internal (undocumented)
export const _vnode_getAttrKeys: (vnode: _ElementVNode | _VirtualVNode) => string[];

// @internal (undocumented)
export const _vnode_getFirstChild: (vnode: _VNode) => _VNode | null;

// @internal (undocumented)
export const _vnode_getNextSibling: (vnode: _VNode) => _VNode | null;

// @internal (undocumented)
export const _vnode_getProps: (vnode: _VNode) => unknown[];

// @internal (undocumented)
export const _vnode_getPropStartIndex: (vnode: _VNode) => number;

// @internal (undocumented)
export const _vnode_isMaterialized: (vNode: _VNode) => boolean;

// @internal (undocumented)
export const _vnode_isTextVNode: (vNode: _VNode) => vNode is _TextVNode;

// @internal (undocumented)
export const _vnode_isVirtualVNode: (vNode: _VNode) => vNode is _VirtualVNode;

// @internal (undocumented)
export function _vnode_toString(this: _VNode | null, depth?: number, offset?: string, materialize?: boolean, siblings?: boolean, colorize?: boolean): string;

Expand Down
1 change: 1 addition & 0 deletions packages/qwik/src/core/reactive-primitives/impl/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const unwrapStore = <T>(value: T): T => {
return getStoreTarget<any>(value) || value;
};

/** @internal */
export const isStore = (value: StoreTarget): boolean => {
return STORE_TARGET in value;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from './signal-api';
import type { ComputedReturnType } from '../use/use-computed';
import type { AsyncComputedReturnType } from '../use/use-async-computed';

export { isSignal } from './utils';

/** @public */
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 @@ -220,7 +220,7 @@ export class Task<T = unknown, B = T>
super();
}
}

/** @internal */
export const isTask = (value: any): value is Task => {
return value instanceof Task;
};
Expand Down
Loading