Skip to content

Commit cf35a4a

Browse files
committed
feat: add v1 compatibility functions _jsx*
1 parent 7c7af32 commit cf35a4a

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

packages/docs/src/routes/api/qwik/api.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@
17181718
}
17191719
],
17201720
"kind": "Function",
1721-
"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<string>\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nopts\n\n\n</td><td>\n\n{ base?: string; manifestHash?: string; manifestURL?: string; nonce?: string; }\n\n\n</td><td>\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</td></tr>\n</tbody></table>\n**Returns:**\n\nJSXNode&lt;string&gt;",
1721+
"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<string>\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nopts\n\n\n</td><td>\n\n{ base?: string; manifestHash?: string; manifestURL?: string; nonce?: string; }\n\n\n</td><td>\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</td></tr>\n</tbody></table>\n**Returns:**\n\n[JSXNode](#jsxnode)<!-- -->&lt;string&gt;",
17221722
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts",
17231723
"mdFile": "qwik.prefetchgraph.md"
17241724
},
@@ -1732,7 +1732,7 @@
17321732
}
17331733
],
17341734
"kind": "Function",
1735-
"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<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nopts\n\n\n</td><td>\n\n{ base?: string; scope?: string; path?: string; verbose?: boolean; fetchBundleGraph?: boolean; nonce?: string; }\n\n\n</td><td>\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</td></tr>\n</tbody></table>\n**Returns:**\n\nJSXNode&lt;'script'&gt;",
1735+
"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<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nopts\n\n\n</td><td>\n\n{ base?: string; scope?: string; path?: string; verbose?: boolean; fetchBundleGraph?: boolean; nonce?: string; }\n\n\n</td><td>\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</td></tr>\n</tbody></table>\n**Returns:**\n\n[JSXNode](#jsxnode)<!-- -->&lt;'script'&gt;",
17361736
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts",
17371737
"mdFile": "qwik.prefetchserviceworker.md"
17381738
},

packages/docs/src/routes/api/qwik/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3528,7 +3528,7 @@ _(Optional)_ Options for the loading prefetch graph.
35283528
</tbody></table>
35293529
**Returns:**
35303530
3531-
JSXNode&lt;string&gt;
3531+
[JSXNode](#jsxnode)&lt;string&gt;
35323532
35333533
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts)
35343534
@@ -3582,7 +3582,7 @@ Options for the prefetch service worker.
35823582
</tbody></table>
35833583
**Returns:**
35843584
3585-
JSXNode&lt;'script'&gt;
3585+
[JSXNode](#jsxnode)&lt;'script'&gt;
35863586
35873587
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/components/prefetch.ts)
35883588

packages/qwik/src/core/api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ export { jsx as jsxs }
537537
// @internal (undocumented)
538538
export const _jsxBranch: <T>(input?: T) => T | undefined;
539539

540+
// @internal @deprecated (undocumented)
541+
export const _jsxC: (type: any, mutable: any, _flags: any, key: any) => JSXNode<any>;
542+
540543
// @public (undocumented)
541544
export type JSXChildren = string | number | boolean | null | undefined | Function | RegExp | JSXChildren[] | Promise<JSXChildren> | Signal<JSXChildren> | JSXNode;
542545

@@ -570,6 +573,12 @@ export interface JSXNode<T extends string | FunctionComponent | unknown = unknow
570573
// @public
571574
export type JSXOutput = JSXNode | string | number | boolean | null | undefined | JSXOutput[];
572575

576+
// @internal @deprecated (undocumented)
577+
export const _jsxQ: (type: any, mutable: any, immutable: any, children: any, _flags: any, key: any) => JSXNode<any>;
578+
579+
// @internal @deprecated (undocumented)
580+
export const _jsxS: (type: any, mutable: any, immutable: any, _flags: any, key: any) => JSXNode<any>;
581+
573582
// @internal
574583
export const _jsxSorted: <T>(type: T, varProps: Props | null, constProps: Props | null, children: JSXChildren | null, flags: number, key: string | number | null | undefined, dev?: DevJSX) => JSXNode<T>;
575584

packages/qwik/src/core/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export {
6262
jsxs,
6363
h,
6464
h as createElement,
65+
_jsxC,
66+
_jsxS,
67+
_jsxQ,
6568
} from './render/jsx/jsx-runtime';
6669
export type * from './render/jsx/types/jsx-generated';
6770
export type {

packages/qwik/src/core/render/jsx/jsx-runtime.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ export const _jsxSplit = <T extends string | FunctionComponent<any>>(
127127
return _jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
128128
};
129129

130+
/** @internal @deprecated v1 compat */
131+
export const _jsxC = (type: any, mutable: any, _flags: any, key: any) => jsx(type, mutable, key);
132+
/** @internal @deprecated v1 compat */
133+
export const _jsxS = (type: any, mutable: any, immutable: any, _flags: any, key: any) =>
134+
jsx(type, { ...immutable, ...mutable }, key);
135+
/** @internal @deprecated v1 compat */
136+
export const _jsxQ = (
137+
type: any,
138+
mutable: any,
139+
immutable: any,
140+
children: any,
141+
_flags: any,
142+
key: any
143+
) => jsx(type, { ...immutable, ...mutable, children }, key);
144+
130145
/**
131146
* @public
132147
* Used by the JSX transpilers to create a JSXNode.

packages/qwik/src/testing/vdom-diff.unit-util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function diffJsxVNode(received: _VNode, expected: JSXNode | string, path: string
110110
receivedElement?.getAttribute(prop) ||
111111
receivedElement?.getAttribute(propLowerCased);
112112
let expectedValue =
113-
prop === 'key' || prop === 'q:key' ? expected.key ?? receivedValue : expected.props[prop];
113+
prop === 'key' || prop === 'q:key' ? (expected.key ?? receivedValue) : expected.props[prop];
114114
if (typeof receivedValue === 'boolean' || typeof receivedValue === 'number') {
115115
receivedValue = serializeBooleanOrNumberAttribute(receivedValue);
116116
}

0 commit comments

Comments
 (0)