-
Notifications
You must be signed in to change notification settings - Fork 10
feat(website): show supported/total count per runtime at table bottom #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
2u841r
wants to merge
1
commit into
unjs:main
Choose a base branch
from
2u841r:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: unjs/runtime-compat
Length of output: 91
🏁 Script executed:
Repository: unjs/runtime-compat
Length of output: 101
🏁 Script executed:
Repository: unjs/runtime-compat
Length of output: 270
🏁 Script executed:
Repository: unjs/runtime-compat
Length of output: 5937
🏁 Script executed:
Repository: unjs/runtime-compat
Length of output: 151
🏁 Script executed:
Repository: unjs/runtime-compat
Length of output: 1001
🏁 Script executed:
Repository: unjs/runtime-compat
Length of output: 2172
🏁 Script executed:
Repository: unjs/runtime-compat
Length of output: 3586
Support ratio aggregation is incomplete and undercounts due to shallow iteration.
The loop at lines 99-105 iterates only the immediate children of
apiDatausingObject.entries(apiData). However, the runtime-compat-data contains 15 APIs with nested identifiers at depth > 1 (e.g.,AbortControllerhas nested properties). This means deeply nested identifiers are skipped, causingtotalRowsto be undercounted.Additionally, the type definition allows
SupportStatementto be either aSimpleSupportStatementor an arraySimpleSupportStatement[], but the code checksvalue.version_addeddirectly, which would not work for array values.💡 Suggested fix (recursive walk + normalized support check)
const computedData = computed(() => { const data: Record<string, Identifier | CompatStatement> = {} const winterCGCoverage: Record<string, number> = Object.fromEntries(runtimes.map(runtime => [runtime, 0])) const runtimeSupport: Record<string, number> = Object.fromEntries(runtimes.map(runtime => [runtime, 0])) let winterCGCount = 0; let totalCount = 0; let totalRows = 0; + + const hasVersionAdded = (value: any): boolean => { + if (Array.isArray(value)) { + return value.some(v => Boolean(v?.version_added)) + } + return Boolean(value?.version_added) + } + + const accumulateSupport = (node: Identifier | CompatStatement) => { + const compat = (node as CompatStatement).support + ? (node as CompatStatement) + : (node as Identifier).__compat + + if (compat?.support) { + totalRows++ + for (const [runtime, value] of Object.entries(compat.support) as [string, any][]) { + if (runtime in runtimeSupport && hasVersionAdded(value)) { + runtimeSupport[runtime]++ + } + } + } + + for (const [key, child] of Object.entries(node as Identifier)) { + if (key === '__compat') continue + accumulateSupport(child as Identifier | CompatStatement) + } + } for (const [api, apiData] of Object.entries({ ...runtimeCompatData.api, WebAssembly: runtimeCompatData.webassembly.api })) { const isWinterCGApi = winterCGAPIs.includes(api) if (!winterCGOnly.value || isWinterCGApi) { data[api] = apiData winterCGCount++ if (isWinterCGApi) { Object.entries(apiData.support ?? apiData.__compat?.support ?? {}).forEach(([runtime, value]) => { if (value.version_added) { winterCGCoverage[runtime]++ } }) } - for (const [, subData] of Object.entries(apiData)) { - totalRows++ - const support = (subData as any).support ?? (subData as any).__compat?.support ?? {} - for (const [runtime, value] of Object.entries(support) as [string, any][]) { - if (value.version_added) runtimeSupport[runtime]++ - } - } + accumulateSupport(apiData) } totalCount++ } return { data, winterCGCount, totalCount, winterCGCoverage, runtimeSupport, totalRows } })🤖 Prompt for AI Agents