From ddc45233b895b9dc9f88ab2bb280efd691fdb055 Mon Sep 17 00:00:00 2001 From: South Drifted Date: Mon, 25 Nov 2024 20:33:23 +0000 Subject: [PATCH] [fix] JSX Fragment props type [optimize] update Upstream packages --- package.json | 8 +-- pnpm-lock.yaml | 114 +++++++++++++++++++++--------------------- source/dist/VDOM.ts | 6 ++- source/jsx-runtime.ts | 5 +- 4 files changed, 67 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index 5183f32..a4929cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dom-renderer", - "version": "2.6.0", + "version": "2.6.1", "license": "LGPL-3.0-or-later", "author": "shiy2008@gmail.com", "description": "A light-weight DOM Renderer supports Web components standard & TypeScript language", @@ -36,7 +36,7 @@ "devDependencies": { "@happy-dom/jest-environment": "^14.12.3", "@types/jest": "^29.5.14", - "@types/node": "^20.17.6", + "@types/node": "^20.17.7", "happy-dom": "^14.12.3", "husky": "^9.1.7", "jest": "^29.7.0", @@ -45,8 +45,8 @@ "prettier": "^3.3.3", "ts-jest": "^29.2.5", "typedoc": "^0.26.11", - "typedoc-plugin-mdn-links": "^3.3.8", - "typescript": "~5.6.3" + "typedoc-plugin-mdn-links": "^4.0.1", + "typescript": "~5.7.2" }, "prettier": { "singleQuote": true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e973a6..2691895 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: declarative-shadow-dom-polyfill: specifier: ^0.4.0 - version: 0.4.0(typescript@5.6.3) + version: 0.4.0(typescript@5.7.2) scheduler-polyfill: specifier: ^1.3.0 version: 1.3.0 @@ -22,7 +22,7 @@ importers: version: 4.0.0 web-utility: specifier: ^4.4.2 - version: 4.4.2(typescript@5.6.3) + version: 4.4.2(typescript@5.7.2) devDependencies: '@happy-dom/jest-environment': specifier: ^14.12.3 @@ -31,8 +31,8 @@ importers: specifier: ^29.5.14 version: 29.5.14 '@types/node': - specifier: ^20.17.6 - version: 20.17.6 + specifier: ^20.17.7 + version: 20.17.7 happy-dom: specifier: ^14.12.3 version: 14.12.3 @@ -41,7 +41,7 @@ importers: version: 9.1.7 jest: specifier: ^29.7.0 - version: 29.7.0(@types/node@20.17.6) + version: 29.7.0(@types/node@20.17.7) lint-staged: specifier: ^15.2.10 version: 15.2.10 @@ -53,16 +53,16 @@ importers: version: 3.3.3 ts-jest: specifier: ^29.2.5 - version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.6))(typescript@5.6.3) + version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.7))(typescript@5.7.2) typedoc: specifier: ^0.26.11 - version: 0.26.11(typescript@5.6.3) + version: 0.26.11(typescript@5.7.2) typedoc-plugin-mdn-links: - specifier: ^3.3.8 - version: 3.3.8(typedoc@0.26.11(typescript@5.6.3)) + specifier: ^4.0.1 + version: 4.0.1(typedoc@0.26.11(typescript@5.7.2)) typescript: - specifier: ~5.6.3 - version: 5.6.3 + specifier: ~5.7.2 + version: 5.7.2 packages: @@ -390,8 +390,8 @@ packages: '@types/mdast@4.0.4': resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==} - '@types/node@20.17.6': - resolution: {integrity: sha512-VEI7OdvK2wP7XHnsuXbAJnEpEkF6NjSN45QJlL4VGqZSXsnicpesdTWsg9RISeSdYd3yeRj/y3k5KGjUXYnFwQ==} + '@types/node@20.17.7': + resolution: {integrity: sha512-sZXXnpBFMKbao30dUAvzKbdwA2JM1fwUtVEq/kxKuPI5mMwZiRElCpTXb0Biq/LMEVpXDZL5G5V0RPnxKeyaYg==} '@types/stack-utils@2.0.3': resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} @@ -1572,10 +1572,10 @@ packages: resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} engines: {node: '>=12.20'} - typedoc-plugin-mdn-links@3.3.8: - resolution: {integrity: sha512-Aewg+SW7hBdffRpT6WnpRwWthoaF9irlzXDKRyvcDVekPZSFujOlh690SV6eCgqrtP7GBJmN0TVeJUq6+6rb1w==} + typedoc-plugin-mdn-links@4.0.1: + resolution: {integrity: sha512-vt0+5VHvAhdZ02OvfD3O7NySoU+cDEUc5XjApBN4dxCR7CcLk2FqgzKHlDiJjzcsFkLZRvc4Znj2sV8m9AuDsg==} peerDependencies: - typedoc: '>= 0.23.14 || 0.24.x || 0.25.x || 0.26.x' + typedoc: 0.26.x || 0.27.x typedoc@0.26.11: resolution: {integrity: sha512-sFEgRRtrcDl2FxVP58Ze++ZK2UQAEvtvvH8rRlig1Ja3o7dDaMHmaBfvJmdGnNEFaLTpQsN8dpvZaTqJSu/Ugw==} @@ -1584,8 +1584,8 @@ packages: peerDependencies: typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x - typescript@5.6.3: - resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==} + typescript@5.7.2: + resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==} engines: {node: '>=14.17'} hasBin: true @@ -1921,7 +1921,7 @@ snapshots: '@jest/console@29.7.0': dependencies: '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 @@ -1934,14 +1934,14 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.17.6) + jest-config: 29.7.0(@types/node@20.17.7) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -1966,7 +1966,7 @@ snapshots: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 jest-mock: 29.7.0 '@jest/expect-utils@29.7.0': @@ -1984,7 +1984,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 20.17.6 + '@types/node': 20.17.7 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -2006,7 +2006,7 @@ snapshots: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.25 - '@types/node': 20.17.6 + '@types/node': 20.17.7 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -2076,7 +2076,7 @@ snapshots: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 20.17.6 + '@types/node': 20.17.7 '@types/yargs': 17.0.33 chalk: 4.1.2 @@ -2163,7 +2163,7 @@ snapshots: '@types/graceful-fs@4.1.9': dependencies: - '@types/node': 20.17.6 + '@types/node': 20.17.7 '@types/hast@3.0.4': dependencies: @@ -2188,7 +2188,7 @@ snapshots: dependencies: '@types/unist': 3.0.3 - '@types/node@20.17.6': + '@types/node@20.17.7': dependencies: undici-types: 6.19.8 @@ -2390,13 +2390,13 @@ snapshots: convert-source-map@2.0.0: {} - create-jest@29.7.0(@types/node@20.17.6): + create-jest@29.7.0(@types/node@20.17.7): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.17.6) + jest-config: 29.7.0(@types/node@20.17.7) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -2419,9 +2419,9 @@ snapshots: dependencies: ms: 2.1.3 - declarative-shadow-dom-polyfill@0.4.0(typescript@5.6.3): + declarative-shadow-dom-polyfill@0.4.0(typescript@5.7.2): dependencies: - typescript: 5.6.3 + typescript: 5.7.2 dedent@1.5.3: {} @@ -2719,7 +2719,7 @@ snapshots: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.3 @@ -2739,16 +2739,16 @@ snapshots: - babel-plugin-macros - supports-color - jest-cli@29.7.0(@types/node@20.17.6): + jest-cli@29.7.0(@types/node@20.17.7): dependencies: '@jest/core': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.17.6) + create-jest: 29.7.0(@types/node@20.17.7) exit: 0.1.2 import-local: 3.2.0 - jest-config: 29.7.0(@types/node@20.17.6) + jest-config: 29.7.0(@types/node@20.17.7) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -2758,7 +2758,7 @@ snapshots: - supports-color - ts-node - jest-config@29.7.0(@types/node@20.17.6): + jest-config@29.7.0(@types/node@20.17.7): dependencies: '@babel/core': 7.26.0 '@jest/test-sequencer': 29.7.0 @@ -2783,7 +2783,7 @@ snapshots: slash: 3.0.0 strip-json-comments: 3.1.1 optionalDependencies: - '@types/node': 20.17.6 + '@types/node': 20.17.7 transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -2812,7 +2812,7 @@ snapshots: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -2822,7 +2822,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.9 - '@types/node': 20.17.6 + '@types/node': 20.17.7 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -2861,7 +2861,7 @@ snapshots: jest-mock@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 jest-util: 29.7.0 jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): @@ -2896,7 +2896,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -2924,7 +2924,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 chalk: 4.1.2 cjs-module-lexer: 1.4.1 collect-v8-coverage: 1.0.2 @@ -2970,7 +2970,7 @@ snapshots: jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -2989,7 +2989,7 @@ snapshots: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.17.6 + '@types/node': 20.17.7 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -2998,17 +2998,17 @@ snapshots: jest-worker@29.7.0: dependencies: - '@types/node': 20.17.6 + '@types/node': 20.17.7 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 - jest@29.7.0(@types/node@20.17.6): + jest@29.7.0(@types/node@20.17.7): dependencies: '@jest/core': 29.7.0 '@jest/types': 29.6.3 import-local: 3.2.0 - jest-cli: 29.7.0(@types/node@20.17.6) + jest-cli: 29.7.0(@types/node@20.17.7) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -3462,18 +3462,18 @@ snapshots: trim-lines@3.0.1: {} - ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.6))(typescript@5.6.3): + ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.7))(typescript@5.7.2): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@20.17.6) + jest: 29.7.0(@types/node@20.17.7) jest-util: 29.7.0 json5: 2.2.3 lodash.memoize: 4.1.2 make-error: 1.3.6 semver: 7.6.3 - typescript: 5.6.3 + typescript: 5.7.2 yargs-parser: 21.1.1 optionalDependencies: '@babel/core': 7.26.0 @@ -3491,20 +3491,20 @@ snapshots: type-fest@2.19.0: {} - typedoc-plugin-mdn-links@3.3.8(typedoc@0.26.11(typescript@5.6.3)): + typedoc-plugin-mdn-links@4.0.1(typedoc@0.26.11(typescript@5.7.2)): dependencies: - typedoc: 0.26.11(typescript@5.6.3) + typedoc: 0.26.11(typescript@5.7.2) - typedoc@0.26.11(typescript@5.6.3): + typedoc@0.26.11(typescript@5.7.2): dependencies: lunr: 2.3.9 markdown-it: 14.1.0 minimatch: 9.0.5 shiki: 1.22.1 - typescript: 5.6.3 + typescript: 5.7.2 yaml: 2.6.0 - typescript@5.6.3: {} + typescript@5.7.2: {} uc.micro@2.1.0: {} @@ -3567,12 +3567,12 @@ snapshots: web-streams-polyfill@4.0.0: {} - web-utility@4.4.2(typescript@5.6.3): + web-utility@4.4.2(typescript@5.7.2): dependencies: '@swc/helpers': 0.5.13 element-internals-polyfill: 1.3.12 regenerator-runtime: 0.14.1 - typescript: 5.6.3 + typescript: 5.7.2 webidl-conversions@7.0.0: {} diff --git a/source/dist/VDOM.ts b/source/dist/VDOM.ts index 23f7c89..c85773a 100644 --- a/source/dist/VDOM.ts +++ b/source/dist/VDOM.ts @@ -27,16 +27,18 @@ export class VNodeMeta { props?: DataObject; style?: VNodeStyle; parent?: VNode; - children?: VNode[] = []; + children?: JsxChildren = []; node?: Node; } export class VNode extends VNodeMeta { + children?: VNode[] = []; + constructor({ children, ...meta }: VNodeMeta) { super(); Object.assign(this, meta); - for (const vNode of children || []) + for (const vNode of (children as VNode[]) || []) this.children.push(...(VNode.isFragment(vNode) ? vNode.children || [] : [vNode])); for (const child of this.children) child.parent = this; diff --git a/source/jsx-runtime.ts b/source/jsx-runtime.ts index 24a09fa..f60fe7a 100644 --- a/source/jsx-runtime.ts +++ b/source/jsx-runtime.ts @@ -11,8 +11,7 @@ export function jsx( { ref, is, style, children, ...props }: DataObject, key?: IndexKey ): VNode { - if (typeof type === 'function' && isHTMLElementClass(type)) - type = tagNameOf(type); + if (typeof type === 'function' && isHTMLElementClass(type)) type = tagNameOf(type); children = [children] .flat(Infinity) @@ -45,7 +44,7 @@ export const Fragment = ({ style, children, ...props -}: VNode['props'] & Omit) => +}: VNode['props'] & Omit) => new VNode({ key, ref,