Repository navigation
refactor(targets): share the resolved target format vocabulary #12165
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9bf5320
refactor(targets): share the resolved target format vocabulary
morluto 479db6e
test(targets): verify each format kind at compile time
morluto 6fa501b
Merge remote-tracking branch 'origin/main' into audit/parser-target-v…
morluto 65f8b11
refactor(targets): share Evidence and explicit format vocabulary (#12…
morluto 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
Next
Next commit
refactor(targets): share the resolved target format vocabulary
- Loading branch information
commit 9bf53200820f1078e091931e1c5fa266429bcb34
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { | ||
| ZIP_PACKAGE_FORMATS, | ||
| type ZipPackageFormat, | ||
| } from "./zipPackageFormat.js"; | ||
|
|
||
| /** Canonical classification of resolved binary targets. */ | ||
| export const BINARY_TARGET_FORMAT_KINDS = { | ||
| "analysis-database": "database", | ||
| "mach-o": "executable", | ||
| "mach-o-universal": "executable", | ||
| elf: "executable", | ||
| pe: "executable", | ||
| "dos-mz": "executable", | ||
| "dos-com": "executable", | ||
| "raw-binary": "executable", | ||
| "gamecube-dol": "executable", | ||
| ...(Object.fromEntries( | ||
| ZIP_PACKAGE_FORMATS.map((format) => [format, "archive"]), | ||
| ) as Record<ZipPackageFormat, "archive">), | ||
| asar: "archive", | ||
| ines: "archive", | ||
| "godot-pck": "archive", | ||
| unityfs: "archive", | ||
| wxapkg: "archive", | ||
| uimage: "archive", | ||
| "android-boot-image": "archive", | ||
| "android-ota-payload": "archive", | ||
| dmg: "archive", | ||
| pkg: "archive", | ||
| "intel-hex": "archive", | ||
| srec: "archive", | ||
| "esp-image": "archive", | ||
| uf2: "archive", | ||
| dfuse: "archive", | ||
| "esp-flash-image": "archive", | ||
| fit: "archive", | ||
| "ntfs-mft": "archive", | ||
| plist: "artifact", | ||
| javascript: "artifact", | ||
| "source-map": "artifact", | ||
| } as const; | ||
|
|
||
| export type TargetFormat = keyof typeof BINARY_TARGET_FORMAT_KINDS; | ||
| type TargetKind = (typeof BINARY_TARGET_FORMAT_KINDS)[TargetFormat]; | ||
| export type TargetFormatsOfKind<Kind extends TargetKind> = { | ||
| [ | ||
| Format in TargetFormat | ||
| ]: (typeof BINARY_TARGET_FORMAT_KINDS)[Format] extends Kind ? Format : never; | ||
| }[TargetFormat]; | ||
|
|
||
| export const BINARY_TARGET_FORMATS = Object.keys( | ||
| BINARY_TARGET_FORMAT_KINDS, | ||
| ) as readonly TargetFormat[]; | ||
|
|
||
| export const targetFormatsOfKind = <Kind extends TargetKind>( | ||
| kind: Kind, | ||
| ): TargetFormatsOfKind<Kind>[] => | ||
| BINARY_TARGET_FORMATS.filter( | ||
| (format): format is TargetFormatsOfKind<Kind> => | ||
| BINARY_TARGET_FORMAT_KINDS[format] === kind, | ||
| ); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.