From cf35a4a285584de00d14f0c5596020fc8f41933c Mon Sep 17 00:00:00 2001 From: Wout Mertens Date: Wed, 28 Aug 2024 14:31:41 +0200 Subject: [PATCH] feat: add v1 compatibility functions _jsx* --- packages/docs/src/routes/api/qwik/api.json | 4 ++-- packages/docs/src/routes/api/qwik/index.md | 4 ++-- packages/qwik/src/core/api.md | 9 +++++++++ packages/qwik/src/core/index.ts | 3 +++ packages/qwik/src/core/render/jsx/jsx-runtime.ts | 15 +++++++++++++++ packages/qwik/src/testing/vdom-diff.unit-util.ts | 2 +- 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/packages/docs/src/routes/api/qwik/api.json b/packages/docs/src/routes/api/qwik/api.json index 4b1404899be..56a9934abb5 100644 --- a/packages/docs/src/routes/api/qwik/api.json +++ b/packages/docs/src/routes/api/qwik/api.json @@ -1718,7 +1718,7 @@ } ], "kind": "Function", - "content": "> This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.\n> \n\nLoad the prefetch graph for the container.\n\nEach Qwik container needs to include its own prefetch graph.\n\n\n```typescript\nPrefetchGraph: (opts?: {\n base?: string;\n manifestHash?: string;\n manifestURL?: string;\n nonce?: string;\n}) => JSXNode\n```\n\n\n\n\n
\n\nParameter\n\n\n\n\nType\n\n\n\n\nDescription\n\n\n
\n\nopts\n\n\n\n\n{ base?: string; manifestHash?: string; manifestURL?: string; nonce?: string; }\n\n\n\n\n_(Optional)_ Options for the loading prefetch graph.\n\n- `base` - Base of the graph. For a default installation this will default to the q:base value `/build/`. But if more than one MFE is installed on the page, then each MFE needs to have its own base. - `manifestHash` - Hash of the manifest file to load. If not provided the hash will be extracted from the container attribute `q:manifest-hash` and assume the default build file `${base}/q-bundle-graph-${manifestHash}.json`. - `manifestURL` - URL of the manifest file to load if non-standard bundle graph location name.\n\n\n
\n**Returns:**\n\nJSXNode<string>", + "content": "> This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.\n> \n\nLoad the prefetch graph for the container.\n\nEach Qwik container needs to include its own prefetch graph.\n\n\n```typescript\nPrefetchGraph: (opts?: {\n base?: string;\n manifestHash?: string;\n manifestURL?: string;\n nonce?: string;\n}) => JSXNode\n```\n\n\n\n\n
\n\nParameter\n\n\n\n\nType\n\n\n\n\nDescription\n\n\n
\n\nopts\n\n\n\n\n{ base?: string; manifestHash?: string; manifestURL?: string; nonce?: string; }\n\n\n\n\n_(Optional)_ Options for the loading prefetch graph.\n\n- `base` - Base of the graph. For a default installation this will default to the q:base value `/build/`. But if more than one MFE is installed on the page, then each MFE needs to have its own base. - `manifestHash` - Hash of the manifest file to load. If not provided the hash will be extracted from the container attribute `q:manifest-hash` and assume the default build file `${base}/q-bundle-graph-${manifestHash}.json`. - `manifestURL` - URL of the manifest file to load if non-standard bundle graph location name.\n\n\n
\n**Returns:**\n\n[JSXNode](#jsxnode)<string>", "editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts", "mdFile": "qwik.prefetchgraph.md" }, @@ -1732,7 +1732,7 @@ } ], "kind": "Function", - "content": "> This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.\n> \n\nInstall a service worker which will prefetch the bundles.\n\nThere can only be one service worker per page. Because there can be many separate Qwik Containers on the page each container needs to load its prefetch graph using `PrefetchGraph` component.\n\n\n```typescript\nPrefetchServiceWorker: (opts: {\n base?: string;\n scope?: string;\n path?: string;\n verbose?: boolean;\n fetchBundleGraph?: boolean;\n nonce?: string;\n}) => JSXNode<'script'>\n```\n\n\n\n\n
\n\nParameter\n\n\n\n\nType\n\n\n\n\nDescription\n\n\n
\n\nopts\n\n\n\n\n{ base?: string; scope?: string; path?: string; verbose?: boolean; fetchBundleGraph?: boolean; nonce?: string; }\n\n\n\n\nOptions for the prefetch service worker.\n\n- `base` - Base URL for the service worker. Default is `import.meta.env.BASE_URL`, which is defined by Vite's `config.base` and defaults to `/`. - `scope` - Base URL for when the service-worker will activate. Default is `/` - `path` - Path to the service worker. Default is `qwik-prefetch-service-worker.js` unless you pass a path that starts with a `/` then the base is ignored. Default is `qwik-prefetch-service-worker.js` - `verbose` - Verbose logging for the service worker installation. Default is `false` - `nonce` - Optional nonce value for security purposes, defaults to `undefined`.\n\n\n
\n**Returns:**\n\nJSXNode<'script'>", + "content": "> This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.\n> \n\nInstall a service worker which will prefetch the bundles.\n\nThere can only be one service worker per page. Because there can be many separate Qwik Containers on the page each container needs to load its prefetch graph using `PrefetchGraph` component.\n\n\n```typescript\nPrefetchServiceWorker: (opts: {\n base?: string;\n scope?: string;\n path?: string;\n verbose?: boolean;\n fetchBundleGraph?: boolean;\n nonce?: string;\n}) => JSXNode<'script'>\n```\n\n\n\n\n
\n\nParameter\n\n\n\n\nType\n\n\n\n\nDescription\n\n\n
\n\nopts\n\n\n\n\n{ base?: string; scope?: string; path?: string; verbose?: boolean; fetchBundleGraph?: boolean; nonce?: string; }\n\n\n\n\nOptions for the prefetch service worker.\n\n- `base` - Base URL for the service worker. Default is `import.meta.env.BASE_URL`, which is defined by Vite's `config.base` and defaults to `/`. - `scope` - Base URL for when the service-worker will activate. Default is `/` - `path` - Path to the service worker. Default is `qwik-prefetch-service-worker.js` unless you pass a path that starts with a `/` then the base is ignored. Default is `qwik-prefetch-service-worker.js` - `verbose` - Verbose logging for the service worker installation. Default is `false` - `nonce` - Optional nonce value for security purposes, defaults to `undefined`.\n\n\n
\n**Returns:**\n\n[JSXNode](#jsxnode)<'script'>", "editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts", "mdFile": "qwik.prefetchserviceworker.md" }, diff --git a/packages/docs/src/routes/api/qwik/index.md b/packages/docs/src/routes/api/qwik/index.md index ec541a7aa66..63bbb4a3d19 100644 --- a/packages/docs/src/routes/api/qwik/index.md +++ b/packages/docs/src/routes/api/qwik/index.md @@ -3528,7 +3528,7 @@ _(Optional)_ Options for the loading prefetch graph. **Returns:** -JSXNode<string> +[JSXNode](#jsxnode)<string> [Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts) @@ -3582,7 +3582,7 @@ Options for the prefetch service worker. **Returns:** -JSXNode<'script'> +[JSXNode](#jsxnode)<'script'> [Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts) diff --git a/packages/qwik/src/core/api.md b/packages/qwik/src/core/api.md index d23a5b97f55..6fb22388cd9 100644 --- a/packages/qwik/src/core/api.md +++ b/packages/qwik/src/core/api.md @@ -537,6 +537,9 @@ export { jsx as jsxs } // @internal (undocumented) export const _jsxBranch: (input?: T) => T | undefined; +// @internal @deprecated (undocumented) +export const _jsxC: (type: any, mutable: any, _flags: any, key: any) => JSXNode; + // @public (undocumented) export type JSXChildren = string | number | boolean | null | undefined | Function | RegExp | JSXChildren[] | Promise | Signal | JSXNode; @@ -570,6 +573,12 @@ export interface JSXNode JSXNode; + +// @internal @deprecated (undocumented) +export const _jsxS: (type: any, mutable: any, immutable: any, _flags: any, key: any) => JSXNode; + // @internal export const _jsxSorted: (type: T, varProps: Props | null, constProps: Props | null, children: JSXChildren | null, flags: number, key: string | number | null | undefined, dev?: DevJSX) => JSXNode; diff --git a/packages/qwik/src/core/index.ts b/packages/qwik/src/core/index.ts index 1c03ea337ca..6de30fb83a4 100644 --- a/packages/qwik/src/core/index.ts +++ b/packages/qwik/src/core/index.ts @@ -62,6 +62,9 @@ export { jsxs, h, h as createElement, + _jsxC, + _jsxS, + _jsxQ, } from './render/jsx/jsx-runtime'; export type * from './render/jsx/types/jsx-generated'; export type { diff --git a/packages/qwik/src/core/render/jsx/jsx-runtime.ts b/packages/qwik/src/core/render/jsx/jsx-runtime.ts index 13b4a3310b6..52cb41e51a3 100644 --- a/packages/qwik/src/core/render/jsx/jsx-runtime.ts +++ b/packages/qwik/src/core/render/jsx/jsx-runtime.ts @@ -127,6 +127,21 @@ export const _jsxSplit = >( return _jsxSorted(type, sortedProps, constProps, children, flags, key, dev); }; +/** @internal @deprecated v1 compat */ +export const _jsxC = (type: any, mutable: any, _flags: any, key: any) => jsx(type, mutable, key); +/** @internal @deprecated v1 compat */ +export const _jsxS = (type: any, mutable: any, immutable: any, _flags: any, key: any) => + jsx(type, { ...immutable, ...mutable }, key); +/** @internal @deprecated v1 compat */ +export const _jsxQ = ( + type: any, + mutable: any, + immutable: any, + children: any, + _flags: any, + key: any +) => jsx(type, { ...immutable, ...mutable, children }, key); + /** * @public * Used by the JSX transpilers to create a JSXNode. diff --git a/packages/qwik/src/testing/vdom-diff.unit-util.ts b/packages/qwik/src/testing/vdom-diff.unit-util.ts index 5f2ac3e6d7d..90dd88a470b 100644 --- a/packages/qwik/src/testing/vdom-diff.unit-util.ts +++ b/packages/qwik/src/testing/vdom-diff.unit-util.ts @@ -110,7 +110,7 @@ function diffJsxVNode(received: _VNode, expected: JSXNode | string, path: string receivedElement?.getAttribute(prop) || receivedElement?.getAttribute(propLowerCased); let expectedValue = - prop === 'key' || prop === 'q:key' ? expected.key ?? receivedValue : expected.props[prop]; + prop === 'key' || prop === 'q:key' ? (expected.key ?? receivedValue) : expected.props[prop]; if (typeof receivedValue === 'boolean' || typeof receivedValue === 'number') { receivedValue = serializeBooleanOrNumberAttribute(receivedValue); }