From 24505397b3101a8550f1513228ad6c040ffa58e3 Mon Sep 17 00:00:00 2001 From: GrandSchtroumpf Date: Thu, 10 Oct 2024 09:47:48 +0200 Subject: [PATCH 1/7] feat(state) expose unwrapProxy as low level API --- packages/qwik/src/core/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/qwik/src/core/index.ts b/packages/qwik/src/core/index.ts index cdddcb46581..51b3fe0d958 100644 --- a/packages/qwik/src/core/index.ts +++ b/packages/qwik/src/core/index.ts @@ -124,7 +124,7 @@ export type { ErrorBoundaryStore } from './render/error-handling'; export type { ValueOrPromise } from './util/types'; export type { Signal, ReadonlySignal } from './state/signal'; export type { NoSerialize } from './state/common'; -export { noSerialize } from './state/common'; +export { noSerialize, unwrapProxy } from './state/common'; export { isSignal } from './state/signal'; export { version } from './version'; From 13d7936d8bd443b685682cd4c846b7377fa568b8 Mon Sep 17 00:00:00 2001 From: GrandSchtroumpf Date: Thu, 10 Oct 2024 09:52:29 +0200 Subject: [PATCH 2/7] update jsdoc --- packages/qwik/src/core/state/common.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/qwik/src/core/state/common.ts b/packages/qwik/src/core/state/common.ts index 23ccff1b208..05149a24c79 100644 --- a/packages/qwik/src/core/state/common.ts +++ b/packages/qwik/src/core/state/common.ts @@ -170,7 +170,12 @@ export const isConnected = (sub: SubscriberEffect | SubscriberHost): boolean => } }; -/** @public */ +/** + * Get the target value of the Proxy. Useful if you want to clone a store (structureClone, + * IndexedDB,...) + * + * @public + */ export const unwrapProxy = (proxy: T): T => { return isObject(proxy) ? (getProxyTarget(proxy) ?? proxy) : proxy; }; From 6b9917dd8357054d1dc69b42cecac2c988e26e1a Mon Sep 17 00:00:00 2001 From: GrandSchtroumpf Date: Thu, 10 Oct 2024 09:55:18 +0200 Subject: [PATCH 3/7] run api.upate --- packages/docs/src/routes/api/qwik/api.json | 14 ++++++++ packages/docs/src/routes/api/qwik/index.md | 39 ++++++++++++++++++++++ packages/qwik/src/core/api.md | 3 ++ 3 files changed, 56 insertions(+) diff --git a/packages/docs/src/routes/api/qwik/api.json b/packages/docs/src/routes/api/qwik/api.json index c0ea1e399df..15f616b1530 100644 --- a/packages/docs/src/routes/api/qwik/api.json +++ b/packages/docs/src/routes/api/qwik/api.json @@ -3010,6 +3010,20 @@ "editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-core.ts", "mdFile": "qwik.untrack.md" }, + { + "name": "unwrapProxy", + "id": "unwrapproxy", + "hierarchy": [ + { + "name": "unwrapProxy", + "id": "unwrapproxy" + } + ], + "kind": "Function", + "content": "Get the target value of the Proxy. Useful if you want to clone a store (structureClone, IndexedDB,...)\n\n\n```typescript\nunwrapProxy: (proxy: T) => T\n```\n\n\n\n\n
\n\nParameter\n\n\n\n\nType\n\n\n\n\nDescription\n\n\n
\n\nproxy\n\n\n\n\nT\n\n\n\n\n\n
\n**Returns:**\n\nT", + "editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/state/common.ts", + "mdFile": "qwik.unwrapproxy.md" + }, { "name": "useComputed$", "id": "usecomputed_", diff --git a/packages/docs/src/routes/api/qwik/index.md b/packages/docs/src/routes/api/qwik/index.md index 62e1aa35218..c52b33c86fa 100644 --- a/packages/docs/src/routes/api/qwik/index.md +++ b/packages/docs/src/routes/api/qwik/index.md @@ -10119,6 +10119,45 @@ T [Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-core.ts) +## unwrapProxy + +Get the target value of the Proxy. Useful if you want to clone a store (structureClone, IndexedDB,...) + +```typescript +unwrapProxy: (proxy: T) => T; +``` + + + +
+ +Parameter + + + +Type + + + +Description + +
+ +proxy + + + +T + + + +
+**Returns:** + +T + +[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/state/common.ts) + ## useComputed$ Hook that returns a read-only signal that updates when signals used in the `ComputedFn` change. diff --git a/packages/qwik/src/core/api.md b/packages/qwik/src/core/api.md index 82e20f25229..6b76db77b62 100644 --- a/packages/qwik/src/core/api.md +++ b/packages/qwik/src/core/api.md @@ -1627,6 +1627,9 @@ export interface TrackHTMLAttributes extends Attrs<'track', T // @public export const untrack: (fn: () => T) => T; +// @public +export const unwrapProxy: (proxy: T) => T; + // @public export const useComputed$: (qrl: ComputedFn) => Signal>; From 20214ef94b5304d091dd94dfe07a95dc08a1c666 Mon Sep 17 00:00:00 2001 From: GrandSchtroumpf Date: Thu, 10 Oct 2024 10:11:50 +0200 Subject: [PATCH 4/7] run pnpm change --- .changeset/short-cycles-bake.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/short-cycles-bake.md diff --git a/.changeset/short-cycles-bake.md b/.changeset/short-cycles-bake.md new file mode 100644 index 00000000000..eb4705c636a --- /dev/null +++ b/.changeset/short-cycles-bake.md @@ -0,0 +1,5 @@ +--- +'@builder.io/qwik': patch +--- + +Expose unwrapProxy as a low level API From ca377f9e176970adc1b76e3f9813b1197b41b026 Mon Sep 17 00:00:00 2001 From: GrandSchtroumpf Date: Mon, 14 Oct 2024 10:01:48 +0200 Subject: [PATCH 5/7] change export to unwrapStore --- packages/docs/src/routes/api/qwik/api.json | 10 +++++----- packages/docs/src/routes/api/qwik/index.md | 2 +- packages/qwik/src/core/api.md | 2 +- packages/qwik/src/core/index.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/docs/src/routes/api/qwik/api.json b/packages/docs/src/routes/api/qwik/api.json index 15f616b1530..72c5a93de0c 100644 --- a/packages/docs/src/routes/api/qwik/api.json +++ b/packages/docs/src/routes/api/qwik/api.json @@ -3011,18 +3011,18 @@ "mdFile": "qwik.untrack.md" }, { - "name": "unwrapProxy", - "id": "unwrapproxy", + "name": "unwrapStore", + "id": "unwrapstore", "hierarchy": [ { - "name": "unwrapProxy", - "id": "unwrapproxy" + "name": "unwrapStore", + "id": "unwrapstore" } ], "kind": "Function", "content": "Get the target value of the Proxy. Useful if you want to clone a store (structureClone, IndexedDB,...)\n\n\n```typescript\nunwrapProxy: (proxy: T) => T\n```\n\n\n\n\n
\n\nParameter\n\n\n\n\nType\n\n\n\n\nDescription\n\n\n
\n\nproxy\n\n\n\n\nT\n\n\n\n\n\n
\n**Returns:**\n\nT", "editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/state/common.ts", - "mdFile": "qwik.unwrapproxy.md" + "mdFile": "qwik.unwrapstore.md" }, { "name": "useComputed$", diff --git a/packages/docs/src/routes/api/qwik/index.md b/packages/docs/src/routes/api/qwik/index.md index c52b33c86fa..69a948f1463 100644 --- a/packages/docs/src/routes/api/qwik/index.md +++ b/packages/docs/src/routes/api/qwik/index.md @@ -10119,7 +10119,7 @@ T [Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-core.ts) -## unwrapProxy +## unwrapStore Get the target value of the Proxy. Useful if you want to clone a store (structureClone, IndexedDB,...) diff --git a/packages/qwik/src/core/api.md b/packages/qwik/src/core/api.md index 6b76db77b62..430b1328f75 100644 --- a/packages/qwik/src/core/api.md +++ b/packages/qwik/src/core/api.md @@ -1628,7 +1628,7 @@ export interface TrackHTMLAttributes extends Attrs<'track', T export const untrack: (fn: () => T) => T; // @public -export const unwrapProxy: (proxy: T) => T; +export const unwrapStore: (proxy: T) => T; // @public export const useComputed$: (qrl: ComputedFn) => Signal>; diff --git a/packages/qwik/src/core/index.ts b/packages/qwik/src/core/index.ts index 51b3fe0d958..e3bb1fe01de 100644 --- a/packages/qwik/src/core/index.ts +++ b/packages/qwik/src/core/index.ts @@ -124,7 +124,7 @@ export type { ErrorBoundaryStore } from './render/error-handling'; export type { ValueOrPromise } from './util/types'; export type { Signal, ReadonlySignal } from './state/signal'; export type { NoSerialize } from './state/common'; -export { noSerialize, unwrapProxy } from './state/common'; +export { noSerialize, unwrapProxy as unwrapStore } from './state/common'; export { isSignal } from './state/signal'; export { version } from './version'; From f248246af4b2ba3c19e38deb3518e8eaa3d2b506 Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Tue, 29 Oct 2024 13:58:52 +0100 Subject: [PATCH 6/7] update changeset --- .changeset/short-cycles-bake.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/short-cycles-bake.md b/.changeset/short-cycles-bake.md index eb4705c636a..b674ffa3633 100644 --- a/.changeset/short-cycles-bake.md +++ b/.changeset/short-cycles-bake.md @@ -2,4 +2,4 @@ '@builder.io/qwik': patch --- -Expose unwrapProxy as a low level API +Expose unwrapStore as a low level API From 39fd36ddef591c46b7718775535c6f45e522c538 Mon Sep 17 00:00:00 2001 From: Shai Reznik Date: Wed, 30 Oct 2024 01:51:07 +0200 Subject: [PATCH 7/7] modified changesets for unwrapStore --- .changeset/short-cycles-bake.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.changeset/short-cycles-bake.md b/.changeset/short-cycles-bake.md index b674ffa3633..c85570c16b2 100644 --- a/.changeset/short-cycles-bake.md +++ b/.changeset/short-cycles-bake.md @@ -1,5 +1,7 @@ --- -'@builder.io/qwik': patch +'@builder.io/qwik': minor --- -Expose unwrapStore as a low level API +FEAT: Expose `unwrapStore` as a low level AP + +This enables developers to clone the content of a `useStore()` using `structureClone` or IndexedDB