Skip to content

Commit

Permalink
add backward compatibility with v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Varixo committed Aug 29, 2024
1 parent 3b6ae17 commit 6534092
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/qwik/src/core/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ export interface IframeHTMLAttributes<T extends Element> extends Attrs<'iframe',
export interface ImgHTMLAttributes<T extends Element> extends Attrs<'img', T> {
}

// @internal @deprecated (undocumented)
export const _IMMUTABLE: unique symbol;

// @public
export const implicit$FirstArg: <FIRST, REST extends any[], RET>(fn: (qrl: QRL<FIRST>, ...rest: REST) => RET) => ((qrl: FIRST, ...rest: REST) => RET);

Expand Down Expand Up @@ -2105,6 +2108,9 @@ export function withLocale<T>(locale: string, fn: () => T): T;
// @internal (undocumented)
export const _wrapProp: <T extends Record<any, any>, P extends keyof T>(obj: T, prop?: P | undefined) => any;

// @internal @deprecated (undocumented)
export const _wrapSignal: <T extends Record<any, any>, P extends keyof T>(obj: T, prop: P) => any;

// (No @packageDocumentation comment for this package)

```
3 changes: 0 additions & 3 deletions packages/qwik/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ export {
jsxs,
h,
h as createElement,
_jsxC,
_jsxS,
_jsxQ,
} from './render/jsx/jsx-runtime';
export type * from './render/jsx/types/jsx-generated';
export type {
Expand Down
4 changes: 3 additions & 1 deletion packages/qwik/src/core/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ export { _renderSSR } from './render/ssr/render-ssr';
export { _walkJSX } from './v2/ssr/ssr-render-jsx';
export { _SharedContainer } from './v2/shared/shared-container';
export { _hW } from './render/dom/notify-render';
export { _wrapProp } from './state/signal';
export { _wrapSignal, _wrapProp } from './state/signal';
export { _restProps } from './state/store';
export { _IMMUTABLE } from './state/constants';
export { _CONST_PROPS, _VAR_PROPS } from './state/constants';
export { _weakSerialize } from './state/common';
export { verifySerializable as _verifySerializable } from './state/common';
Expand Down Expand Up @@ -36,3 +37,4 @@ export {
} from './v2/client/dom-container';
export { EMPTY_ARRAY as _EMPTY_ARRAY } from '../core/util/flyweight';
export { _serialize, _deserialize } from './v2/shared/shared-serialization';
export { _jsxQ, _jsxC, _jsxS } from './render/jsx/jsx-runtime';
5 changes: 5 additions & 0 deletions packages/qwik/src/core/state/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export const _CONST_PROPS = Symbol('CONST');
/** @internal */
export const _VAR_PROPS = Symbol('VAR');

/** @internal @deprecated v1 compat */
export const _IMMUTABLE = Symbol('IMMUTABLE');
/** @deprecated */
export const _IMMUTABLE_PREFIX = '$$';

/**
* @internal
* Key for the virtual element stored on qv comments
Expand Down
14 changes: 13 additions & 1 deletion packages/qwik/src/core/state/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
type SubscriptionManager,
type Subscriptions,
} from './common';
import { QObjectManagerSymbol, _CONST_PROPS } from './constants';
import { QObjectManagerSymbol, _CONST_PROPS, _IMMUTABLE } from './constants';

/**
* A signal is a reactive value which can be read and written. When the signal is written, all tasks
Expand Down Expand Up @@ -236,3 +236,15 @@ export const _wrapProp = <T extends Record<any, any>, P extends keyof T>(
// We need to forward the access to the original object
return new SignalDerived(getProp, [obj, prop as string]);
};

/** @internal @deprecated v1 compat */
export const _wrapSignal = <T extends Record<any, any>, P extends keyof T>(
obj: T,
prop: P
): any => {
const r = _wrapProp(obj, prop);
if (r === _IMMUTABLE) {
return obj[prop];
}
return r;
};

0 comments on commit 6534092

Please sign in to comment.