diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e05db03..a77d629 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,7 +55,13 @@ jobs: # Block publishing when checked-in artifacts don't match the regenerated # output (i.e. publishing unreviewed content). - name: Verify checked-in generated artifacts - run: git diff --exit-code -- derived/current generated/current + run: | + git diff --exit-code -- derived/current generated/current + status="$(git status --porcelain --untracked-files=all -- derived/current generated/current)" + if [[ -n "$status" ]]; then + printf '%s\n' "$status" + exit 1 + fi - name: Run validation and smoke tests run: npm test diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index c3ee397..80a9a9a 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -40,7 +40,13 @@ jobs: run: npm run generate - name: Verify checked-in generated artifacts - run: git diff --exit-code -- derived/current generated/current + run: | + git diff --exit-code -- derived/current generated/current + status="$(git status --porcelain --untracked-files=all -- derived/current generated/current)" + if [[ -n "$status" ]]; then + printf '%s\n' "$status" + exit 1 + fi - name: Run standalone validation run: npm test diff --git a/README.md b/README.md index dd93d8f..3ad9dbe 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,28 @@ npm install --save-dev typescript-baseline-lib Now only the supported Baseline widely available JavaScript surfaces type-check. APIs that haven't reached Baseline yet (`Promise.withResolvers`, `Array.fromAsync` until it promotes, and so on) are reported as errors. The end goal is first-class `--lib baseline` support upstream in TypeScript. +## Allow a polyfilled feature + +When the runtime loads an audited polyfill, add its generated web-features entry after the base package. For example, core-js can provide `Promise.withResolvers` at runtime: + +```ts +import "core-js/proposals/promise-with-resolvers"; +``` + +```json +{ + "compilerOptions": { + "noLib": true, + "types": [ + "typescript-baseline-lib", + "typescript-baseline-lib/allow/promise-withresolvers" + ] + } +} +``` + +Only entries approved in `registry/allowlist.json` are public. The registry is a permanent path contract: after every registered compat key becomes Baseline widely available, the same entry remains as an alias to the base package. Limited availability features with `baselineStatus: false` are rejected. + ## Current contract - Target is `baseline` only. diff --git a/deploy/package-lib.mjs b/deploy/package-lib.mjs index 0f794ce..08aeea7 100644 --- a/deploy/package-lib.mjs +++ b/deploy/package-lib.mjs @@ -191,7 +191,7 @@ async function createPackageStage(packageConfig, snapshot, versionOverride, stag for (const file of packageConfig.generatedFiles) { const destinationPath = path.join(stageDirectory, file.to); await mkdir(path.dirname(destinationPath), { recursive: true }); - await cp(file.from, destinationPath); + await cp(file.from, destinationPath, { recursive: true }); } const packageVersion = versionOverride ?? await resolveNextPackageVersion(packageConfig); @@ -231,10 +231,16 @@ async function createPackageStage(packageConfig, snapshot, versionOverride, stag }, keywords: packageConfig.keywords, types: "./index.d.ts", + typesVersions: { + "*": { + "allow/*": ["allow/*/index.d.ts"], + }, + }, files: [ "index.d.ts", "baseline.d.ts", "snapshot.json", + "allow/", "reports/", "README.md", "LICENSE", @@ -306,6 +312,11 @@ async function buildReleasePlan(stageSummary) { } const removedFiles = [...publishedPaths].sort(compareStrings); + assertNoRemovedAllowEntries(removedFiles); + assertAllowEntryContractsPreserved( + published.snapshot.get("reports/generation.json"), + stagedSnapshot.get("reports/generation.json"), + ); const changed = !published.version || changedFiles.length > 0 || removedFiles.length > 0; return { @@ -327,6 +338,60 @@ async function buildReleasePlan(stageSummary) { }; } +/** + * @param {string[]} removedFiles + */ +export function assertNoRemovedAllowEntries(removedFiles) { + const removedEntries = removedFiles.filter(relativePath => /^allow\/[^/]+\/index\.d\.ts$/.test(relativePath)); + if (removedEntries.length) { + throw new Error(`Published allow entry paths cannot be removed: ${removedEntries.join(", ")}`); + } +} + +/** + * @param {string | undefined} publishedReportText + * @param {string | undefined} stagedReportText + */ +export function assertAllowEntryContractsPreserved(publishedReportText, stagedReportText) { + if (!publishedReportText) { + return; + } + if (!stagedReportText) { + throw new Error("The staged package is missing reports/generation.json"); + } + + const publishedEntries = readAllowEntryContracts(publishedReportText, "published"); + const stagedEntries = readAllowEntryContracts(stagedReportText, "staged"); + for (const [entryName, publishedCompatKeys] of publishedEntries) { + const stagedCompatKeys = stagedEntries.get(entryName); + if (!stagedCompatKeys || JSON.stringify(stagedCompatKeys) !== JSON.stringify(publishedCompatKeys)) { + throw new Error(`Published allow entry contract changed: allow/${entryName}`); + } + } +} + +/** + * @param {string} reportText + * @param {string} label + */ +function readAllowEntryContracts(reportText, label) { + /** @type {{ allowEntries?: Array<{ entryName?: unknown; compatKeys?: unknown; }>; }} */ + const report = JSON.parse(reportText); + const contracts = new Map(); + for (const entry of report.allowEntries ?? []) { + if ( + typeof entry.entryName !== "string" + || !Array.isArray(entry.compatKeys) + || entry.compatKeys.some(compatKey => typeof compatKey !== "string") + || contracts.has(entry.entryName) + ) { + throw new Error(`Invalid ${label} allow entry contract report`); + } + contracts.set(entry.entryName, [...entry.compatKeys].sort(compareStrings)); + } + return contracts; +} + /** * @param {PackageRegistryEntry} packageConfig */ @@ -430,8 +495,10 @@ async function fetchPackageMetadata(packageName) { * @param {string} directoryPath */ export async function createPackageTarball(directoryPath) { - await mkdir(path.join(repoRoot, ".tmp", "release-tarballs"), { recursive: true }); - const packOutput = execFileSync("npm", ["pack", directoryPath, "--pack-destination", path.join(repoRoot, ".tmp", "release-tarballs"), "--silent"], { + const tarballRoot = path.join(repoRoot, ".tmp", "release-tarballs"); + await mkdir(tarballRoot, { recursive: true }); + const tarballDirectory = await mkdtemp(path.join(tarballRoot, "pack-")); + const packOutput = execFileSync("npm", ["pack", directoryPath, "--pack-destination", tarballDirectory, "--silent"], { cwd: repoRoot, encoding: "utf8", }).trim(); @@ -439,7 +506,7 @@ export async function createPackageTarball(directoryPath) { if (!tarballName) { throw new Error(`npm pack did not return a tarball name for ${directoryPath}`); } - return path.join(repoRoot, ".tmp", "release-tarballs", tarballName); + return path.join(tarballDirectory, tarballName); } /** diff --git a/deploy/package-registry.mjs b/deploy/package-registry.mjs index d51f284..23973fe 100644 --- a/deploy/package-registry.mjs +++ b/deploy/package-registry.mjs @@ -32,6 +32,10 @@ export const baselinePackage = { from: path.join(repoRoot, "generated", "current", "baseline.d.ts"), to: "baseline.d.ts", }, + { + from: path.join(repoRoot, "generated", "current", "allow"), + to: "allow", + }, { from: path.join(repoRoot, "derived", "current", "classification.json"), to: path.join("reports", "classification.json"), diff --git a/deploy/readmes/baseline.md b/deploy/readmes/baseline.md index 68f268c..92b4010 100644 --- a/deploy/readmes/baseline.md +++ b/deploy/readmes/baseline.md @@ -38,8 +38,31 @@ The same snapshot facts are available to tools through `{{PACKAGE_NAME}}/snapsho Now only the supported Baseline widely available JavaScript surfaces type-check; APIs that haven't reached Baseline yet are reported as errors. +## Allow a polyfilled feature + +When the runtime loads an audited polyfill, add its generated web-features entry after the base package. For example, core-js can provide `Promise.withResolvers` at runtime: + +```ts +import "core-js/proposals/promise-with-resolvers"; +``` + +```json +{ + "compilerOptions": { + "noLib": true, + "types": [ + "{{PACKAGE_NAME}}", + "{{PACKAGE_NAME}}/allow/promise-withresolvers" + ] + } +} +``` + +Only explicitly audited entries are public. Published entry paths remain valid after all of their compat keys become Baseline widely available and move into the base package. Limited availability features with `baselineStatus: false` are rejected. + ## Notes -- The public surface is a single `baseline` lib. +- The base public surface is a single `baseline` lib. +- Audited `allow/*` entrypoints are optional additions for explicitly polyfilled APIs. - The current scope is `javascript.builtins.*` plus the `arguments` object. - The generated declarations are derived from the npm `typescript` package and preserve the upstream Microsoft license notice inside `baseline.d.ts`. diff --git a/derived/current/generation.json b/derived/current/generation.json index abce9db..5683edb 100644 --- a/derived/current/generation.json +++ b/derived/current/generation.json @@ -21,7 +21,10 @@ "completeContainerCount": 178, "excludedUnitCount": 381, "preservedTypeOnlyUnitCount": 29, - "transformedUnitCount": 2 + "transformedUnitCount": 2, + "allowEntryCount": 15, + "allowEntryUnitCount": 126, + "allowSupportUnitCount": 79 }, "sourceLibs": [ { @@ -533,6 +536,86 @@ { "kind": "top-level-lib", "outputPath": "generated/current/baseline.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/array-fromasync/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/array-group/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/atomics-pause/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/atomics-wait-async/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/float16array/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/getorinsert/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/intl-duration-format/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/intl-segmenter/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/promise-try/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/promise-withresolvers/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/regexp-escape/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/resizable-buffers/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/set-methods/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/transferable-arraybuffer/index.d.ts" + }, + { + "kind": "allow-entry", + "outputPath": "generated/current/allow/uint8array-base64-hex/index.d.ts" + }, + { + "kind": "allow-support", + "outputPath": "generated/current/allow/_support/array-fromasync.d.ts" + }, + { + "kind": "allow-support", + "outputPath": "generated/current/allow/_support/intl-duration-format.d.ts" + }, + { + "kind": "allow-support", + "outputPath": "generated/current/allow/_support/intl-segmenter.d.ts" + }, + { + "kind": "allow-support", + "outputPath": "generated/current/allow/_support/promise-withresolvers.d.ts" + }, + { + "kind": "allow-support", + "outputPath": "generated/current/allow/_support/set-methods.d.ts" } ], "preservedTypeOnlyUnits": [ @@ -570,6 +653,423 @@ "lib.es2024.arraybuffer.d.ts::ArrayBufferConstructor.::10", "lib.es2024.sharedmemory.d.ts::SharedArrayBufferConstructor.::11" ], + "allowEntries": [ + { + "kind": "active", + "entryName": "array-fromasync", + "outputPath": "generated/current/allow/array-fromasync/index.d.ts", + "compatKeys": [ + "javascript.builtins.Array.fromAsync" + ], + "unitIds": [ + "lib.esnext.array.d.ts::ArrayConstructor.fromAsync::2", + "lib.esnext.array.d.ts::ArrayConstructor.fromAsync::3" + ], + "supportUnitIds": [ + "lib.es2018.asynciterable.d.ts::AsyncIterable.@@asyncIterator::10", + "lib.es2018.asynciterable.d.ts::AsyncIterable::9" + ] + }, + { + "kind": "active", + "entryName": "array-group", + "outputPath": "generated/current/allow/array-group/index.d.ts", + "compatKeys": [ + "javascript.builtins.Map.groupBy", + "javascript.builtins.Object.groupBy" + ], + "unitIds": [ + "lib.es2024.collection.d.ts::MapConstructor.groupBy::2", + "lib.es2024.object.d.ts::ObjectConstructor.groupBy::2" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "atomics-pause", + "outputPath": "generated/current/allow/atomics-pause/index.d.ts", + "compatKeys": [ + "javascript.builtins.Atomics.pause" + ], + "unitIds": [ + "lib.esnext.sharedmemory.d.ts::Atomics.pause::2" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "atomics-wait-async", + "outputPath": "generated/current/allow/atomics-wait-async/index.d.ts", + "compatKeys": [ + "javascript.builtins.Atomics.waitAsync" + ], + "unitIds": [ + "lib.es2024.sharedmemory.d.ts::Atomics.waitAsync::2", + "lib.es2024.sharedmemory.d.ts::Atomics.waitAsync::3" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "float16array", + "outputPath": "generated/current/allow/float16array/index.d.ts", + "compatKeys": [ + "javascript.builtins.DataView.getFloat16", + "javascript.builtins.DataView.setFloat16", + "javascript.builtins.Float16Array", + "javascript.builtins.Float16Array.Float16Array", + "javascript.builtins.Math.f16round" + ], + "unitIds": [ + "lib.es2025.float16.d.ts::DataView.getFloat16::67", + "lib.es2025.float16.d.ts::DataView.setFloat16::68", + "lib.es2025.float16.d.ts::Float16Array.::41", + "lib.es2025.float16.d.ts::Float16Array.@@iterator::42", + "lib.es2025.float16.d.ts::Float16Array.@@toStringTag::46", + "lib.es2025.float16.d.ts::Float16Array.BYTES_PER_ELEMENT::2", + "lib.es2025.float16.d.ts::Float16Array.at::6", + "lib.es2025.float16.d.ts::Float16Array.buffer::3", + "lib.es2025.float16.d.ts::Float16Array.byteLength::4", + "lib.es2025.float16.d.ts::Float16Array.byteOffset::5", + "lib.es2025.float16.d.ts::Float16Array.copyWithin::7", + "lib.es2025.float16.d.ts::Float16Array.entries::43", + "lib.es2025.float16.d.ts::Float16Array.every::8", + "lib.es2025.float16.d.ts::Float16Array.fill::9", + "lib.es2025.float16.d.ts::Float16Array.filter::10", + "lib.es2025.float16.d.ts::Float16Array.find::11", + "lib.es2025.float16.d.ts::Float16Array.findIndex::12", + "lib.es2025.float16.d.ts::Float16Array.findLast::13", + "lib.es2025.float16.d.ts::Float16Array.findLast::14", + "lib.es2025.float16.d.ts::Float16Array.findLastIndex::15", + "lib.es2025.float16.d.ts::Float16Array.forEach::16", + "lib.es2025.float16.d.ts::Float16Array.includes::17", + "lib.es2025.float16.d.ts::Float16Array.indexOf::18", + "lib.es2025.float16.d.ts::Float16Array.join::19", + "lib.es2025.float16.d.ts::Float16Array.keys::44", + "lib.es2025.float16.d.ts::Float16Array.lastIndexOf::20", + "lib.es2025.float16.d.ts::Float16Array.length::21", + "lib.es2025.float16.d.ts::Float16Array.map::22", + "lib.es2025.float16.d.ts::Float16Array.reduce::23", + "lib.es2025.float16.d.ts::Float16Array.reduce::24", + "lib.es2025.float16.d.ts::Float16Array.reduce::25", + "lib.es2025.float16.d.ts::Float16Array.reduceRight::26", + "lib.es2025.float16.d.ts::Float16Array.reduceRight::27", + "lib.es2025.float16.d.ts::Float16Array.reduceRight::28", + "lib.es2025.float16.d.ts::Float16Array.reverse::29", + "lib.es2025.float16.d.ts::Float16Array.set::30", + "lib.es2025.float16.d.ts::Float16Array.slice::31", + "lib.es2025.float16.d.ts::Float16Array.some::32", + "lib.es2025.float16.d.ts::Float16Array.sort::33", + "lib.es2025.float16.d.ts::Float16Array.subarray::34", + "lib.es2025.float16.d.ts::Float16Array.toLocaleString::35", + "lib.es2025.float16.d.ts::Float16Array.toReversed::36", + "lib.es2025.float16.d.ts::Float16Array.toSorted::37", + "lib.es2025.float16.d.ts::Float16Array.toString::38", + "lib.es2025.float16.d.ts::Float16Array.valueOf::39", + "lib.es2025.float16.d.ts::Float16Array.values::45", + "lib.es2025.float16.d.ts::Float16Array.with::40", + "lib.es2025.float16.d.ts::Float16Array::1", + "lib.es2025.float16.d.ts::Float16Array::61", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.::50", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.::51", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.::52", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.::53", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.::54", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.BYTES_PER_ELEMENT::55", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.from::57", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.from::58", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.from::59", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.from::60", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.of::56", + "lib.es2025.float16.d.ts::Float16ArrayConstructor.prototype::49", + "lib.es2025.float16.d.ts::Float16ArrayConstructor::48", + "lib.es2025.float16.d.ts::Math.f16round::64" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "getorinsert", + "outputPath": "generated/current/allow/getorinsert/index.d.ts", + "compatKeys": [ + "javascript.builtins.Map.getOrInsert", + "javascript.builtins.Map.getOrInsertComputed", + "javascript.builtins.WeakMap.getOrInsert", + "javascript.builtins.WeakMap.getOrInsertComputed" + ], + "unitIds": [ + "lib.esnext.collection.d.ts::Map.getOrInsert::2", + "lib.esnext.collection.d.ts::Map.getOrInsertComputed::3", + "lib.esnext.collection.d.ts::WeakMap.getOrInsert::6", + "lib.esnext.collection.d.ts::WeakMap.getOrInsertComputed::7" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "intl-duration-format", + "outputPath": "generated/current/allow/intl-duration-format/index.d.ts", + "compatKeys": [ + "javascript.builtins.Intl.DurationFormat", + "javascript.builtins.Intl.DurationFormat.DurationFormat", + "javascript.builtins.Intl.DurationFormat.format", + "javascript.builtins.Intl.DurationFormat.formatToParts", + "javascript.builtins.Intl.DurationFormat.resolvedOptions", + "javascript.builtins.Intl.DurationFormat.supportedLocalesOf" + ], + "unitIds": [ + "lib.es2025.intl.d.ts::Intl.DurationFormat.::68", + "lib.es2025.intl.d.ts::Intl.DurationFormat.format::36", + "lib.es2025.intl.d.ts::Intl.DurationFormat.formatToParts::37", + "lib.es2025.intl.d.ts::Intl.DurationFormat.prototype::67", + "lib.es2025.intl.d.ts::Intl.DurationFormat.resolvedOptions::38", + "lib.es2025.intl.d.ts::Intl.DurationFormat.supportedLocalesOf::69", + "lib.es2025.intl.d.ts::Intl.DurationFormat::35", + "lib.es2025.intl.d.ts::Intl.DurationFormat::66" + ], + "supportUnitIds": [ + "lib.es2025.intl.d.ts::Intl.DurationFormatDisplayOption::4", + "lib.es2025.intl.d.ts::Intl.DurationFormatLocaleMatcher::2", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.days::19", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.daysDisplay::20", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.fractionalDigits::33", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.hours::21", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.hoursDisplay::22", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.localeMatcher::10", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.microseconds::29", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.microsecondsDisplay::30", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.milliseconds::27", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.millisecondsDisplay::28", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.minutes::23", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.minutesDisplay::24", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.months::15", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.monthsDisplay::16", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.nanoseconds::31", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.nanosecondsDisplay::32", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.numberingSystem::11", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.seconds::25", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.secondsDisplay::26", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.style::12", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.weeks::17", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.weeksDisplay::18", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.years::13", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions.yearsDisplay::14", + "lib.es2025.intl.d.ts::Intl.DurationFormatOptions::9", + "lib.es2025.intl.d.ts::Intl.DurationFormatPart::7", + "lib.es2025.intl.d.ts::Intl.DurationFormatStyle::3", + "lib.es2025.intl.d.ts::Intl.DurationFormatUnit::5", + "lib.es2025.intl.d.ts::Intl.DurationFormatUnitSingular::6", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.days::50", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.daysDisplay::51", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.fractionalDigits::64", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.hours::52", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.hoursDisplay::53", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.locale::41", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.microseconds::60", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.microsecondsDisplay::61", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.milliseconds::58", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.millisecondsDisplay::59", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.minutes::54", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.minutesDisplay::55", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.months::46", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.monthsDisplay::47", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.nanoseconds::62", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.nanosecondsDisplay::63", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.numberingSystem::42", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.seconds::56", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.secondsDisplay::57", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.style::43", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.weeks::48", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.weeksDisplay::49", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.years::44", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions.yearsDisplay::45", + "lib.es2025.intl.d.ts::Intl.ResolvedDurationFormatOptions::40" + ] + }, + { + "kind": "active", + "entryName": "intl-segmenter", + "outputPath": "generated/current/allow/intl-segmenter/index.d.ts", + "compatKeys": [ + "javascript.builtins.Intl.Segmenter", + "javascript.builtins.Intl.Segmenter.Segmenter", + "javascript.builtins.Intl.Segmenter.resolvedOptions", + "javascript.builtins.Intl.Segmenter.segment", + "javascript.builtins.Intl.Segmenter.supportedLocalesOf", + "javascript.builtins.Intl.Segments", + "javascript.builtins.Intl.Segments.@@iterator", + "javascript.builtins.Intl.Segments.containing" + ], + "unitIds": [ + "lib.es2022.intl.d.ts::Intl.Segmenter.::30", + "lib.es2022.intl.d.ts::Intl.Segmenter.prototype::29", + "lib.es2022.intl.d.ts::Intl.Segmenter.resolvedOptions::9", + "lib.es2022.intl.d.ts::Intl.Segmenter.segment::8", + "lib.es2022.intl.d.ts::Intl.Segmenter.supportedLocalesOf::31", + "lib.es2022.intl.d.ts::Intl.Segmenter::28", + "lib.es2022.intl.d.ts::Intl.Segmenter::7", + "lib.es2022.intl.d.ts::Intl.Segments.@@iterator::20", + "lib.es2022.intl.d.ts::Intl.Segments.containing::19", + "lib.es2022.intl.d.ts::Intl.Segments::18" + ], + "supportUnitIds": [ + "lib.es2022.intl.d.ts::Intl.ResolvedSegmenterOptions.granularity::13", + "lib.es2022.intl.d.ts::Intl.ResolvedSegmenterOptions.locale::12", + "lib.es2022.intl.d.ts::Intl.ResolvedSegmenterOptions::11", + "lib.es2022.intl.d.ts::Intl.SegmentData.index::24", + "lib.es2022.intl.d.ts::Intl.SegmentData.input::25", + "lib.es2022.intl.d.ts::Intl.SegmentData.isWordLike::26", + "lib.es2022.intl.d.ts::Intl.SegmentData.segment::23", + "lib.es2022.intl.d.ts::Intl.SegmentData::22", + "lib.es2022.intl.d.ts::Intl.SegmentIterator.@@iterator::16", + "lib.es2022.intl.d.ts::Intl.SegmentIterator::15", + "lib.es2022.intl.d.ts::Intl.SegmenterOptions.granularity::5", + "lib.es2022.intl.d.ts::Intl.SegmenterOptions.localeMatcher::4", + "lib.es2022.intl.d.ts::Intl.SegmenterOptions::3" + ] + }, + { + "kind": "active", + "entryName": "promise-try", + "outputPath": "generated/current/allow/promise-try/index.d.ts", + "compatKeys": [ + "javascript.builtins.Promise.try" + ], + "unitIds": [ + "lib.es2025.promise.d.ts::PromiseConstructor.try::2" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "promise-withresolvers", + "outputPath": "generated/current/allow/promise-withresolvers/index.d.ts", + "compatKeys": [ + "javascript.builtins.Promise.withResolvers" + ], + "unitIds": [ + "lib.es2024.promise.d.ts::PromiseConstructor.withResolvers::7" + ], + "supportUnitIds": [ + "lib.es2024.promise.d.ts::PromiseWithResolvers.promise::2", + "lib.es2024.promise.d.ts::PromiseWithResolvers.reject::4", + "lib.es2024.promise.d.ts::PromiseWithResolvers.resolve::3", + "lib.es2024.promise.d.ts::PromiseWithResolvers::1" + ] + }, + { + "kind": "active", + "entryName": "regexp-escape", + "outputPath": "generated/current/allow/regexp-escape/index.d.ts", + "compatKeys": [ + "javascript.builtins.RegExp.escape" + ], + "unitIds": [ + "lib.es2025.regexp.d.ts::RegExpConstructor.escape::2" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "resizable-buffers", + "outputPath": "generated/current/allow/resizable-buffers/index.d.ts", + "compatKeys": [ + "javascript.builtins.ArrayBuffer.ArrayBuffer.maxByteLength_option", + "javascript.builtins.ArrayBuffer.maxByteLength", + "javascript.builtins.ArrayBuffer.resizable", + "javascript.builtins.ArrayBuffer.resize", + "javascript.builtins.SharedArrayBuffer.SharedArrayBuffer.maxByteLength_option", + "javascript.builtins.SharedArrayBuffer.grow", + "javascript.builtins.SharedArrayBuffer.growable", + "javascript.builtins.SharedArrayBuffer.maxByteLength" + ], + "unitIds": [ + "lib.es2024.arraybuffer.d.ts::ArrayBuffer.maxByteLength::2", + "lib.es2024.arraybuffer.d.ts::ArrayBuffer.resizable::3", + "lib.es2024.arraybuffer.d.ts::ArrayBuffer.resize::4", + "lib.es2024.arraybuffer.d.ts::ArrayBufferConstructor.::10", + "lib.es2024.sharedmemory.d.ts::SharedArrayBuffer.grow::8", + "lib.es2024.sharedmemory.d.ts::SharedArrayBuffer.growable::6", + "lib.es2024.sharedmemory.d.ts::SharedArrayBuffer.maxByteLength::7", + "lib.es2024.sharedmemory.d.ts::SharedArrayBufferConstructor.::11" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "set-methods", + "outputPath": "generated/current/allow/set-methods/index.d.ts", + "compatKeys": [ + "javascript.builtins.Set.difference", + "javascript.builtins.Set.intersection", + "javascript.builtins.Set.isDisjointFrom", + "javascript.builtins.Set.isSubsetOf", + "javascript.builtins.Set.isSupersetOf", + "javascript.builtins.Set.symmetricDifference", + "javascript.builtins.Set.union" + ], + "unitIds": [ + "lib.es2025.collection.d.ts::ReadonlySet.difference::18", + "lib.es2025.collection.d.ts::ReadonlySet.intersection::17", + "lib.es2025.collection.d.ts::ReadonlySet.isDisjointFrom::22", + "lib.es2025.collection.d.ts::ReadonlySet.isSubsetOf::20", + "lib.es2025.collection.d.ts::ReadonlySet.isSupersetOf::21", + "lib.es2025.collection.d.ts::ReadonlySet.symmetricDifference::19", + "lib.es2025.collection.d.ts::ReadonlySet.union::16", + "lib.es2025.collection.d.ts::Set.difference::9", + "lib.es2025.collection.d.ts::Set.intersection::8", + "lib.es2025.collection.d.ts::Set.isDisjointFrom::13", + "lib.es2025.collection.d.ts::Set.isSubsetOf::11", + "lib.es2025.collection.d.ts::Set.isSupersetOf::12", + "lib.es2025.collection.d.ts::Set.symmetricDifference::10", + "lib.es2025.collection.d.ts::Set.union::7" + ], + "supportUnitIds": [ + "lib.es2025.collection.d.ts::ReadonlySetLike.has::3", + "lib.es2025.collection.d.ts::ReadonlySetLike.keys::2", + "lib.es2025.collection.d.ts::ReadonlySetLike.size::4", + "lib.es2025.collection.d.ts::ReadonlySetLike::1" + ] + }, + { + "kind": "active", + "entryName": "transferable-arraybuffer", + "outputPath": "generated/current/allow/transferable-arraybuffer/index.d.ts", + "compatKeys": [ + "javascript.builtins.ArrayBuffer.detached", + "javascript.builtins.ArrayBuffer.transfer", + "javascript.builtins.ArrayBuffer.transferToFixedLength" + ], + "unitIds": [ + "lib.es2024.arraybuffer.d.ts::ArrayBuffer.detached::5", + "lib.es2024.arraybuffer.d.ts::ArrayBuffer.transfer::6", + "lib.es2024.arraybuffer.d.ts::ArrayBuffer.transferToFixedLength::7" + ], + "supportUnitIds": [] + }, + { + "kind": "active", + "entryName": "uint8array-base64-hex", + "outputPath": "generated/current/allow/uint8array-base64-hex/index.d.ts", + "compatKeys": [ + "javascript.builtins.Uint8Array.fromBase64", + "javascript.builtins.Uint8Array.fromHex", + "javascript.builtins.Uint8Array.setFromBase64", + "javascript.builtins.Uint8Array.setFromHex", + "javascript.builtins.Uint8Array.toBase64", + "javascript.builtins.Uint8Array.toHex" + ], + "unitIds": [ + "lib.esnext.typedarrays.d.ts::Uint8Array.setFromBase64::3", + "lib.esnext.typedarrays.d.ts::Uint8Array.setFromHex::5", + "lib.esnext.typedarrays.d.ts::Uint8Array.toBase64::2", + "lib.esnext.typedarrays.d.ts::Uint8Array.toHex::4", + "lib.esnext.typedarrays.d.ts::Uint8ArrayConstructor.fromBase64::8", + "lib.esnext.typedarrays.d.ts::Uint8ArrayConstructor.fromHex::9" + ], + "supportUnitIds": [] + } + ], "excludedUnits": [ { "unitId": "lib.es2015.core.d.ts::String.anchor::83", diff --git a/generated/current/allow/_support/array-fromasync.d.ts b/generated/current/allow/_support/array-fromasync.d.ts new file mode 100644 index 0000000..682a2dd --- /dev/null +++ b/generated/current/allow/_support/array-fromasync.d.ts @@ -0,0 +1,27 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2018.asynciterable.d.ts +///////////////////////////// +interface AsyncIterable { + [Symbol.asyncIterator](): AsyncIterator; +} diff --git a/generated/current/allow/_support/intl-duration-format.d.ts b/generated/current/allow/_support/intl-duration-format.d.ts new file mode 100644 index 0000000..a21cf8a --- /dev/null +++ b/generated/current/allow/_support/intl-duration-format.d.ts @@ -0,0 +1,198 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2025.intl.d.ts +///////////////////////////// +declare namespace Intl { + /** + * The locale matching algorithm to use. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). + */ + type DurationFormatLocaleMatcher = "lookup" | "best fit"; + + /** + * The style of the formatted duration. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#style). + */ + type DurationFormatStyle = "long" | "short" | "narrow" | "digital"; + + /** + * Whether to always display a unit, or only if it is non-zero. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#display). + */ + type DurationFormatDisplayOption = "always" | "auto"; + + /** + * Value of the `unit` property in duration objects + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format#duration). + */ + type DurationFormatUnit = + | "years" + | "months" + | "weeks" + | "days" + | "hours" + | "minutes" + | "seconds" + | "milliseconds" + | "microseconds" + | "nanoseconds"; + + type DurationFormatUnitSingular = + | "year" + | "month" + | "week" + | "day" + | "hour" + | "minute" + | "second" + | "millisecond" + | "microsecond" + | "nanosecond"; + + /** + * An object representing the relative time format in parts + * that can be used for custom locale-aware formatting. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts). + */ + type DurationFormatPart = + | { + type: "literal"; + value: string; + unit?: DurationFormatUnitSingular; + } + | { + type: Exclude; + value: string; + unit: DurationFormatUnitSingular; + }; + + /** + * An object with some or all properties of the `Intl.DurationFormat` constructor `options` parameter. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#parameters) + */ + interface DurationFormatOptions { + localeMatcher?: DurationFormatLocaleMatcher | undefined; + + numberingSystem?: string | undefined; + + style?: DurationFormatStyle | undefined; + + years?: "long" | "short" | "narrow" | undefined; + + yearsDisplay?: DurationFormatDisplayOption | undefined; + + months?: "long" | "short" | "narrow" | undefined; + + monthsDisplay?: DurationFormatDisplayOption | undefined; + + weeks?: "long" | "short" | "narrow" | undefined; + + weeksDisplay?: DurationFormatDisplayOption | undefined; + + days?: "long" | "short" | "narrow" | undefined; + + daysDisplay?: DurationFormatDisplayOption | undefined; + + hours?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined; + + hoursDisplay?: DurationFormatDisplayOption | undefined; + + minutes?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined; + + minutesDisplay?: DurationFormatDisplayOption | undefined; + + seconds?: "long" | "short" | "narrow" | "numeric" | "2-digit" | undefined; + + secondsDisplay?: DurationFormatDisplayOption | undefined; + + milliseconds?: "long" | "short" | "narrow" | "numeric" | undefined; + + millisecondsDisplay?: DurationFormatDisplayOption | undefined; + + microseconds?: "long" | "short" | "narrow" | "numeric" | undefined; + + microsecondsDisplay?: DurationFormatDisplayOption | undefined; + + nanoseconds?: "long" | "short" | "narrow" | "numeric" | undefined; + + nanosecondsDisplay?: DurationFormatDisplayOption | undefined; + + fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined; + } + + interface ResolvedDurationFormatOptions { + locale: UnicodeBCP47LocaleIdentifier; + + numberingSystem: string; + + style: DurationFormatStyle; + + years: "long" | "short" | "narrow"; + + yearsDisplay: DurationFormatDisplayOption; + + months: "long" | "short" | "narrow"; + + monthsDisplay: DurationFormatDisplayOption; + + weeks: "long" | "short" | "narrow"; + + weeksDisplay: DurationFormatDisplayOption; + + days: "long" | "short" | "narrow"; + + daysDisplay: DurationFormatDisplayOption; + + hours: "long" | "short" | "narrow" | "numeric" | "2-digit"; + + hoursDisplay: DurationFormatDisplayOption; + + minutes: "long" | "short" | "narrow" | "numeric" | "2-digit"; + + minutesDisplay: DurationFormatDisplayOption; + + seconds: "long" | "short" | "narrow" | "numeric" | "2-digit"; + + secondsDisplay: DurationFormatDisplayOption; + + milliseconds: "long" | "short" | "narrow" | "numeric"; + + millisecondsDisplay: DurationFormatDisplayOption; + + microseconds: "long" | "short" | "narrow" | "numeric"; + + microsecondsDisplay: DurationFormatDisplayOption; + + nanoseconds: "long" | "short" | "narrow" | "numeric"; + + nanosecondsDisplay: DurationFormatDisplayOption; + + fractionalDigits?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + } +} diff --git a/generated/current/allow/_support/intl-segmenter.d.ts b/generated/current/allow/_support/intl-segmenter.d.ts new file mode 100644 index 0000000..276807e --- /dev/null +++ b/generated/current/allow/_support/intl-segmenter.d.ts @@ -0,0 +1,65 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2022.intl.d.ts +///////////////////////////// +declare namespace Intl { + /** + * An object with some or all properties of the `Intl.Segmenter` constructor `options` parameter. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters) + */ + interface SegmenterOptions { + /** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */ + localeMatcher?: "best fit" | "lookup" | undefined; + + /** The type of input to be split */ + granularity?: "grapheme" | "word" | "sentence" | undefined; + } + + interface ResolvedSegmenterOptions { + locale: string; + + granularity: "grapheme" | "word" | "sentence"; + } + + interface SegmentIterator extends IteratorObject { + [Symbol.iterator](): SegmentIterator; + } + + interface SegmentData { + /** A string containing the segment extracted from the original input string. */ + segment: string; + + /** The code unit index in the original input string at which the segment begins. */ + index: number; + + /** The complete input string that was segmented. */ + input: string; + + /** + * A boolean value only if granularity is "word"; otherwise, undefined. + * If granularity is "word", then isWordLike is true when the segment is word-like (i.e., consists of letters/numbers/ideographs/etc.); otherwise, false. + */ + isWordLike?: boolean; + } +} diff --git a/generated/current/allow/_support/promise-withresolvers.d.ts b/generated/current/allow/_support/promise-withresolvers.d.ts new file mode 100644 index 0000000..3cdea54 --- /dev/null +++ b/generated/current/allow/_support/promise-withresolvers.d.ts @@ -0,0 +1,31 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2024.promise.d.ts +///////////////////////////// +interface PromiseWithResolvers { + promise: Promise; + + resolve: (value: T | PromiseLike) => void; + + reject: (reason?: any) => void; +} diff --git a/generated/current/allow/_support/set-methods.d.ts b/generated/current/allow/_support/set-methods.d.ts new file mode 100644 index 0000000..5f2e830 --- /dev/null +++ b/generated/current/allow/_support/set-methods.d.ts @@ -0,0 +1,40 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2025.collection.d.ts +///////////////////////////// +interface ReadonlySetLike { + /** + * Despite its name, returns an iterator of the values in the set-like. + */ + keys(): Iterator; + + /** + * @returns a boolean indicating whether an element with the specified value exists in the set-like or not. + */ + has(value: T): boolean; + + /** + * @returns the number of (unique) elements in the set-like. + */ + readonly size: number; +} diff --git a/generated/current/allow/array-fromasync/index.d.ts b/generated/current/allow/array-fromasync/index.d.ts new file mode 100644 index 0000000..1cc018e --- /dev/null +++ b/generated/current/allow/array-fromasync/index.d.ts @@ -0,0 +1,43 @@ +/// + +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.esnext.array.d.ts +///////////////////////////// +interface ArrayConstructor { + /** + * Creates an array from an async iterator or iterable object. + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + */ + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable> | ArrayLike>): Promise; + + /** + * Creates an array from an async iterator or iterable object. + * + * @param iterableOrArrayLike An async iterator or array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of itarableOrArrayLike. + * Each return value is awaited before being added to result array. + * @param thisArg Value of 'this' used when executing mapfn. + */ + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited, index: number) => U, thisArg?: any): Promise[]>; +} diff --git a/generated/current/allow/array-group/index.d.ts b/generated/current/allow/array-group/index.d.ts new file mode 100644 index 0000000..bd4782a --- /dev/null +++ b/generated/current/allow/array-group/index.d.ts @@ -0,0 +1,50 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2024.collection.d.ts +///////////////////////////// +interface MapConstructor { + /** + * Groups members of an iterable according to the return value of the passed callback. + * @param items An iterable. + * @param keySelector A callback which will be invoked for each item in items. + */ + groupBy( + items: Iterable, + keySelector: (item: T, index: number) => K, + ): Map; +} + +///////////////////////////// +// lib.es2024.object.d.ts +///////////////////////////// +interface ObjectConstructor { + /** + * Groups members of an iterable according to the return value of the passed callback. + * @param items An iterable. + * @param keySelector A callback which will be invoked for each item in items. + */ + groupBy( + items: Iterable, + keySelector: (item: T, index: number) => K, + ): Partial>; +} diff --git a/generated/current/allow/atomics-pause/index.d.ts b/generated/current/allow/atomics-pause/index.d.ts new file mode 100644 index 0000000..67815ef --- /dev/null +++ b/generated/current/allow/atomics-pause/index.d.ts @@ -0,0 +1,31 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.esnext.sharedmemory.d.ts +///////////////////////////// +interface Atomics { + /** + * Performs a finite-time microwait by signaling to the operating system or + * CPU that the current executing code is in a spin-wait loop. + */ + pause(n?: number): void; +} diff --git a/generated/current/allow/atomics-wait-async/index.d.ts b/generated/current/allow/atomics-wait-async/index.d.ts new file mode 100644 index 0000000..5f95cda --- /dev/null +++ b/generated/current/allow/atomics-wait-async/index.d.ts @@ -0,0 +1,45 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2024.sharedmemory.d.ts +///////////////////////////// +interface Atomics { + /** + * A non-blocking, asynchronous version of wait which is usable on the main thread. + * Waits asynchronously on a shared memory location and returns a Promise + * @param typedArray A shared Int32Array or BigInt64Array. + * @param index The position in the typedArray to wait on. + * @param value The expected value to test. + * @param [timeout] The expected value to test. + */ + waitAsync(typedArray: Int32Array, index: number, value: number, timeout?: number): { async: false; value: "not-equal" | "timed-out"; } | { async: true; value: Promise<"ok" | "timed-out">; }; + + /** + * A non-blocking, asynchronous version of wait which is usable on the main thread. + * Waits asynchronously on a shared memory location and returns a Promise + * @param typedArray A shared Int32Array or BigInt64Array. + * @param index The position in the typedArray to wait on. + * @param value The expected value to test. + * @param [timeout] The expected value to test. + */ + waitAsync(typedArray: BigInt64Array, index: number, value: bigint, timeout?: number): { async: false; value: "not-equal" | "timed-out"; } | { async: true; value: Promise<"ok" | "timed-out">; }; +} diff --git a/generated/current/allow/float16array/index.d.ts b/generated/current/allow/float16array/index.d.ts new file mode 100644 index 0000000..71cd573 --- /dev/null +++ b/generated/current/allow/float16array/index.d.ts @@ -0,0 +1,457 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2025.float16.d.ts +///////////////////////////// +/** + * A typed array of 16-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float16Array { + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: TArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly byteOffset: number; + + /** + * Returns the item located at the specified index. + * @param index The zero-based index of the desired code unit. A negative index will count back from the last item. + */ + at(index: number): number | undefined; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param predicate A function that accepts up to three arguments. The every method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): boolean; + + /** + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): this; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param predicate A function that accepts up to three arguments. The filter method calls + * the predicate function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(predicate: (value: number, index: number, array: this) => any, thisArg?: any): Float16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: this) => boolean, thisArg?: any): number | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number, index: number, obj: this) => boolean, thisArg?: any): number; + + /** + * Returns the value of the last element in the array where predicate is true, and undefined + * otherwise. + * @param predicate findLast calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, findLast + * immediately returns that element value. Otherwise, findLast returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findLast( + predicate: ( + value: number, + index: number, + array: this, + ) => value is S, + thisArg?: any, + ): S | undefined; + + findLast( + predicate: ( + value: number, + index: number, + array: this, + ) => unknown, + thisArg?: any, + ): number | undefined; + + /** + * Returns the index of the last element in the array where predicate is true, and -1 + * otherwise. + * @param predicate findLastIndex calls predicate once for each element of the array, in descending + * order, until it finds one where predicate returns true. If such an element is found, + * findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findLastIndex( + predicate: ( + value: number, + index: number, + array: this, + ) => unknown, + thisArg?: any, + ): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void; + + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: this) => number, thisArg?: any): Float16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: this) => number): number; + + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: this) => number, initialValue: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: this) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: this) => number): number; + + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: this) => number, initialValue: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: this) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): this; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ + slice(start?: number, end?: number): Float16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param predicate A function that accepts up to three arguments. The some method calls + * the predicate function for each element in the array until the predicate returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the predicate function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(predicate: (value: number, index: number, array: this) => unknown, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ + sort(compareFn?: (a: number, b: number) => number): this; + + /** + * Gets a new Float16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Float16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions): string; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Float16Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending order. + * ```ts + * const myNums = Float16Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float16Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Float16Array; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): this; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Float16Array; + + [index: number]: number; + + [Symbol.iterator](): ArrayIterator; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): ArrayIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): ArrayIterator; + + /** + * Returns an list of values in the array + */ + values(): ArrayIterator; + + readonly [Symbol.toStringTag]: "Float16Array"; +} + +interface Float16ArrayConstructor { + readonly prototype: Float16Array; + + new (length?: number): Float16Array; + + new (array: ArrayLike | Iterable): Float16Array; + + new (buffer: TArrayBuffer, byteOffset?: number, length?: number): Float16Array; + + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float16Array; + + new (array: ArrayLike | ArrayBuffer): Float16Array; + + /** + * The size in bytes of each element in the array. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Float16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param elements An iterable object to convert to an array. + */ + from(elements: Iterable): Float16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param elements An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(elements: Iterable, mapfn?: (v: T, k: number) => number, thisArg?: any): Float16Array; +} + +declare var Float16Array: Float16ArrayConstructor; + +interface Math { + /** + * Returns the nearest half precision float representation of a number. + * @param x A numeric expression. + */ + f16round(x: number): number; +} + +interface DataView { + /** + * Gets the Float16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. + */ + getFloat16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written. + */ + setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; +} diff --git a/generated/current/allow/getorinsert/index.d.ts b/generated/current/allow/getorinsert/index.d.ts new file mode 100644 index 0000000..205bd8b --- /dev/null +++ b/generated/current/allow/getorinsert/index.d.ts @@ -0,0 +1,55 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.esnext.collection.d.ts +///////////////////////////// +interface Map { + /** + * Returns a specified element from the Map object. + * If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the Map and returned. + * @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed. + */ + getOrInsert(key: K, defaultValue: V): V; + + /** + * Returns a specified element from the Map object. + * If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the Map and returned. + * @returns The element associated with the specific key, which will be the newly computed value if no element previously existed. + */ + getOrInsertComputed(key: K, callback: (key: K) => V): V; +} + +interface WeakMap { + /** + * Returns a specified element from the WeakMap object. + * If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the WeakMap and returned. + * @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed. + */ + getOrInsert(key: K, defaultValue: V): V; + + /** + * Returns a specified element from the WeakMap object. + * If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the WeakMap and returned. + * @returns The element associated with the specific key, which will be the newly computed value if no element previously existed. + */ + getOrInsertComputed(key: K, callback: (key: K) => V): V; +} diff --git a/generated/current/allow/intl-duration-format/index.d.ts b/generated/current/allow/intl-duration-format/index.d.ts new file mode 100644 index 0000000..733a1f0 --- /dev/null +++ b/generated/current/allow/intl-duration-format/index.d.ts @@ -0,0 +1,83 @@ +/// + +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2025.intl.d.ts +///////////////////////////// +declare namespace Intl { + /** + * The Intl.DurationFormat object enables language-sensitive duration formatting. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat) + */ + interface DurationFormat { + /** + * @param duration The duration object to be formatted. It should include some or all of the following properties: months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/format). + */ + format(duration: Partial>): string; + + /** + * @param duration The duration object to be formatted. It should include some or all of the following properties: months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/formatToParts). + */ + formatToParts(duration: Partial>): DurationFormatPart[]; + + /** + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions). + */ + resolvedOptions(): ResolvedDurationFormatOptions; + } + + const DurationFormat: { + prototype: DurationFormat; + + /** + * @param locales A string with a BCP 47 language tag, or an array of such strings. + * For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation) + * page. + * + * @param options An object for setting up a duration format. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat). + */ + new (locales?: LocalesArgument, options?: DurationFormatOptions): DurationFormat; + + /** + * Returns an array containing those of the provided locales that are supported in display names without having to fall back to the runtime's default locale. + * + * @param locales A string with a BCP 47 language tag, or an array of such strings. + * For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation) + * page. + * + * @param options An object with a locale matcher. + * + * @returns An array of strings representing a subset of the given locale tags that are supported in display names without having to fall back to the runtime's default locale. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/supportedLocalesOf). + */ + supportedLocalesOf(locales?: LocalesArgument, options?: { localeMatcher?: DurationFormatLocaleMatcher; }): UnicodeBCP47LocaleIdentifier[]; + }; +} diff --git a/generated/current/allow/intl-segmenter/index.d.ts b/generated/current/allow/intl-segmenter/index.d.ts new file mode 100644 index 0000000..07ac9bb --- /dev/null +++ b/generated/current/allow/intl-segmenter/index.d.ts @@ -0,0 +1,110 @@ +/// + +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2022.intl.d.ts +///////////////////////////// +declare namespace Intl { + /** + * The `Intl.Segmenter` object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) + */ + interface Segmenter { + /** + * Returns `Segments` object containing the segments of the input string, using the segmenter's locale and granularity. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment) + * + * @param input - The text to be segmented as a `string`. + * + * @returns A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity. + */ + segment(input: string): Segments; + + /** + * The `resolvedOptions()` method of `Intl.Segmenter` instances returns a new object with properties reflecting the options computed during initialization of this `Segmenter` object. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions) + */ + resolvedOptions(): ResolvedSegmenterOptions; + } + + /** + * A `Segments` object is an iterable collection of the segments of a text string. It is returned by a call to the `segment()` method of an `Intl.Segmenter` object. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments) + */ + interface Segments { + /** + * Returns an object describing the segment in the original string that includes the code unit at a specified index. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments/containing) + * + * @param codeUnitIndex - A number specifying the index of the code unit in the original input string. If the value is omitted, it defaults to `0`. + */ + containing(codeUnitIndex?: number): SegmentData | undefined; + + /** Returns an iterator to iterate over the segments. */ + [Symbol.iterator](): SegmentIterator; + } + + /** + * The `Intl.Segmenter` object enables locale-sensitive text segmentation, enabling you to get meaningful items (graphemes, words or sentences) from a string. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) + */ + const Segmenter: { + prototype: Segmenter; + + /** + * Creates a new `Intl.Segmenter` object. + * + * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings. + * For the general form and interpretation of the `locales` argument, + * see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation). + * + * @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#parameters) + * with some or all options of `SegmenterOptions`. + * + * @returns [Intl.Segmenter](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments) object. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter). + */ + new (locales?: LocalesArgument, options?: SegmenterOptions): Segmenter; + + /** + * Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale. + * + * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings. + * For the general form and interpretation of the `locales` argument, + * see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation). + * + * @param options An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf#parameters). + * with some or all possible options. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf) + */ + supportedLocalesOf(locales: LocalesArgument, options?: Pick): UnicodeBCP47LocaleIdentifier[]; + }; +} diff --git a/generated/current/allow/promise-try/index.d.ts b/generated/current/allow/promise-try/index.d.ts new file mode 100644 index 0000000..ceca03a --- /dev/null +++ b/generated/current/allow/promise-try/index.d.ts @@ -0,0 +1,40 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2025.promise.d.ts +///////////////////////////// +interface PromiseConstructor { + /** + * Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result + * in a Promise. + * + * @param callbackFn A function that is called synchronously. It can do anything: either return + * a value, throw an error, or return a promise. + * @param args Additional arguments, that will be passed to the callback. + * + * @returns A Promise that is: + * - Already fulfilled, if the callback synchronously returns a value. + * - Already rejected, if the callback synchronously throws an error. + * - Asynchronously fulfilled or rejected, if the callback returns a promise. + */ + try(callbackFn: (...args: U) => T | PromiseLike, ...args: U): Promise>; +} diff --git a/generated/current/allow/promise-withresolvers/index.d.ts b/generated/current/allow/promise-withresolvers/index.d.ts new file mode 100644 index 0000000..5a0003a --- /dev/null +++ b/generated/current/allow/promise-withresolvers/index.d.ts @@ -0,0 +1,37 @@ +/// + +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2024.promise.d.ts +///////////////////////////// +interface PromiseConstructor { + /** + * Creates a new Promise and returns it in an object, along with its resolve and reject functions. + * @returns An object with the properties `promise`, `resolve`, and `reject`. + * + * ```ts + * const { promise, resolve, reject } = Promise.withResolvers(); + * ``` + */ + withResolvers(): PromiseWithResolvers; +} diff --git a/generated/current/allow/regexp-escape/index.d.ts b/generated/current/allow/regexp-escape/index.d.ts new file mode 100644 index 0000000..7d61840 --- /dev/null +++ b/generated/current/allow/regexp-escape/index.d.ts @@ -0,0 +1,38 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2025.regexp.d.ts +///////////////////////////// +interface RegExpConstructor { + /** + * Escapes any RegExp syntax characters in the input string, returning a + * new string that can be safely interpolated into a RegExp as a literal + * string to match. + * @example + * ```ts + * const regExp = new RegExp(RegExp.escape("foo.bar")); + * regExp.test("foo.bar"); // true + * regExp.test("foo!bar"); // false + * ``` + */ + escape(string: string): string; +} diff --git a/generated/current/allow/resizable-buffers/index.d.ts b/generated/current/allow/resizable-buffers/index.d.ts new file mode 100644 index 0000000..27eb3d8 --- /dev/null +++ b/generated/current/allow/resizable-buffers/index.d.ts @@ -0,0 +1,80 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2024.arraybuffer.d.ts +///////////////////////////// +interface ArrayBuffer { + /** + * If this ArrayBuffer is resizable, returns the maximum byte length given during construction; returns the byte length if not. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/maxByteLength) + */ + get maxByteLength(): number; + + /** + * Returns true if this ArrayBuffer can be resized. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resizable) + */ + get resizable(): boolean; + + /** + * Resizes the ArrayBuffer to the specified size (in bytes). + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resize) + */ + resize(newByteLength?: number): void; +} + +interface ArrayBufferConstructor { + new (byteLength: number, options?: { maxByteLength?: number; }): ArrayBuffer; +} + +///////////////////////////// +// lib.es2024.sharedmemory.d.ts +///////////////////////////// +interface SharedArrayBuffer { + /** + * Returns true if this SharedArrayBuffer can be grown. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/growable) + */ + get growable(): boolean; + + /** + * If this SharedArrayBuffer is growable, returns the maximum byte length given during construction; returns the byte length if not. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/maxByteLength) + */ + get maxByteLength(): number; + + /** + * Grows the SharedArrayBuffer to the specified size (in bytes). + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/grow) + */ + grow(newByteLength?: number): void; +} + +interface SharedArrayBufferConstructor { + new (byteLength: number, options?: { maxByteLength?: number; }): SharedArrayBuffer; +} diff --git a/generated/current/allow/set-methods/index.d.ts b/generated/current/allow/set-methods/index.d.ts new file mode 100644 index 0000000..16d6c95 --- /dev/null +++ b/generated/current/allow/set-methods/index.d.ts @@ -0,0 +1,99 @@ +/// + +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2025.collection.d.ts +///////////////////////////// +interface Set { + /** + * @returns a new Set containing all the elements in this Set and also all the elements in the argument. + */ + union(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements which are both in this Set and in the argument. + */ + intersection(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements in this Set which are not also in the argument. + */ + difference(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. + */ + symmetricDifference(other: ReadonlySetLike): Set; + + /** + * @returns a boolean indicating whether all the elements in this Set are also in the argument. + */ + isSubsetOf(other: ReadonlySetLike): boolean; + + /** + * @returns a boolean indicating whether all the elements in the argument are also in this Set. + */ + isSupersetOf(other: ReadonlySetLike): boolean; + + /** + * @returns a boolean indicating whether this Set has no elements in common with the argument. + */ + isDisjointFrom(other: ReadonlySetLike): boolean; +} + +interface ReadonlySet { + /** + * @returns a new Set containing all the elements in this Set and also all the elements in the argument. + */ + union(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements which are both in this Set and in the argument. + */ + intersection(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements in this Set which are not also in the argument. + */ + difference(other: ReadonlySetLike): Set; + + /** + * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. + */ + symmetricDifference(other: ReadonlySetLike): Set; + + /** + * @returns a boolean indicating whether all the elements in this Set are also in the argument. + */ + isSubsetOf(other: ReadonlySetLike): boolean; + + /** + * @returns a boolean indicating whether all the elements in the argument are also in this Set. + */ + isSupersetOf(other: ReadonlySetLike): boolean; + + /** + * @returns a boolean indicating whether this Set has no elements in common with the argument. + */ + isDisjointFrom(other: ReadonlySetLike): boolean; +} diff --git a/generated/current/allow/transferable-arraybuffer/index.d.ts b/generated/current/allow/transferable-arraybuffer/index.d.ts new file mode 100644 index 0000000..a72ca74 --- /dev/null +++ b/generated/current/allow/transferable-arraybuffer/index.d.ts @@ -0,0 +1,46 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.es2024.arraybuffer.d.ts +///////////////////////////// +interface ArrayBuffer { + /** + * Returns a boolean indicating whether or not this buffer has been detached (transferred). + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/detached) + */ + get detached(): boolean; + + /** + * Creates a new ArrayBuffer with the same byte content as this buffer, then detaches this buffer. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer) + */ + transfer(newByteLength?: number): ArrayBuffer; + + /** + * Creates a new non-resizable ArrayBuffer with the same byte content as this buffer, then detaches this buffer. + * + * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transferToFixedLength) + */ + transferToFixedLength(newByteLength?: number): ArrayBuffer; +} diff --git a/generated/current/allow/uint8array-base64-hex/index.d.ts b/generated/current/allow/uint8array-base64-hex/index.d.ts new file mode 100644 index 0000000..4bd3e3c --- /dev/null +++ b/generated/current/allow/uint8array-base64-hex/index.d.ts @@ -0,0 +1,98 @@ +/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */ +// +// Generated by TypeScript Baseline Lib Generator from TypeScript lib declaration files. +// Source declarations are derived from the npm `typescript` package. +// Do not edit this file directly. +// + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABILITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +///////////////////////////// +// lib.esnext.typedarrays.d.ts +///////////////////////////// +interface Uint8Array { + /** + * Converts the `Uint8Array` to a base64-encoded string. + * @param options If provided, sets the alphabet and padding behavior used. + * @returns A base64-encoded string. + */ + toBase64( + options?: { + alphabet?: "base64" | "base64url" | undefined; + omitPadding?: boolean | undefined; + }, + ): string; + + /** + * Sets the `Uint8Array` from a base64-encoded string. + * @param string The base64-encoded string. + * @param options If provided, specifies the alphabet and handling of the last chunk. + * @returns An object containing the number of bytes read and written. + * @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last + * chunk is inconsistent with the `lastChunkHandling` option. + */ + setFromBase64( + string: string, + options?: { + alphabet?: "base64" | "base64url" | undefined; + lastChunkHandling?: "loose" | "strict" | "stop-before-partial" | undefined; + }, + ): { + read: number; + written: number; + }; + + /** + * Converts the `Uint8Array` to a base16-encoded string. + * @returns A base16-encoded string. + */ + toHex(): string; + + /** + * Sets the `Uint8Array` from a base16-encoded string. + * @param string The base16-encoded string. + * @returns An object containing the number of bytes read and written. + */ + setFromHex(string: string): { + read: number; + written: number; + }; +} + +interface Uint8ArrayConstructor { + /** + * Creates a new `Uint8Array` from a base64-encoded string. + * @param string The base64-encoded string. + * @param options If provided, specifies the alphabet and handling of the last chunk. + * @returns A new `Uint8Array` instance. + * @throws {SyntaxError} If the input string contains characters outside the specified alphabet, or if the last + * chunk is inconsistent with the `lastChunkHandling` option. + */ + fromBase64( + string: string, + options?: { + alphabet?: "base64" | "base64url" | undefined; + lastChunkHandling?: "loose" | "strict" | "stop-before-partial" | undefined; + }, + ): Uint8Array; + + /** + * Creates a new `Uint8Array` from a base16-encoded string. + * @returns A new `Uint8Array` instance. + */ + fromHex( + string: string, + ): Uint8Array; +} diff --git a/lib/allowlist-registry.mjs b/lib/allowlist-registry.mjs new file mode 100644 index 0000000..c62bb9d --- /dev/null +++ b/lib/allowlist-registry.mjs @@ -0,0 +1,63 @@ +// @ts-check + +import { readFile } from "node:fs/promises"; +import { compareStringsCaseSensitive } from "./shared.mjs"; + +const ENTRY_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/; + +/** + * @param {string} registryPath + * @returns {Promise} + */ +export async function loadAllowlistRegistry(registryPath) { + const registry = JSON.parse(await readFile(registryPath, "utf8")); + if (registry.schemaVersion !== 1 || !Array.isArray(registry.entries)) { + throw new Error(`Invalid allowlist registry ${registryPath}`); + } + + const entryNames = new Set(); + const compatKeys = new Set(); + for (const entry of registry.entries) { + if ( + !entry + || typeof entry !== "object" + || Object.keys(entry).sort().join(",") !== "compatKeys,entryName" + || typeof entry.entryName !== "string" + || !ENTRY_NAME_PATTERN.test(entry.entryName) + || !Array.isArray(entry.compatKeys) + || !entry.compatKeys.length + || entry.compatKeys.some((/** @type {unknown} */ compatKey) => typeof compatKey !== "string" || !compatKey) + ) { + throw new Error(`Invalid allowlist entry in ${registryPath}`); + } + if (entryNames.has(entry.entryName) || new Set(entry.compatKeys).size !== entry.compatKeys.length) { + throw new Error(`Duplicate allowlist entry data in ${registryPath}: ${entry.entryName}`); + } + for (const compatKey of entry.compatKeys) { + if (compatKeys.has(compatKey)) { + throw new Error(`Allowlist compat key is assigned to multiple entries: ${compatKey}`); + } + compatKeys.add(compatKey); + } + const sortedCompatKeys = [...entry.compatKeys].sort(compareStringsCaseSensitive); + if (JSON.stringify(sortedCompatKeys) !== JSON.stringify(entry.compatKeys)) { + throw new Error(`Allowlist compat keys must be sorted for ${entry.entryName}`); + } + entryNames.add(entry.entryName); + } + + const sortedEntries = [...registry.entries].sort((left, right) => + compareStringsCaseSensitive(left.entryName, right.entryName) + ); + if (JSON.stringify(sortedEntries) !== JSON.stringify(registry.entries)) { + throw new Error(`Allowlist entries in ${registryPath} must be sorted by entryName`); + } + return registry; +} + +/** + * @typedef {{ + * schemaVersion: 1; + * entries: Array<{ entryName: string; compatKeys: string[]; }>; + * }} AllowlistRegistry + */ diff --git a/lib/generator.mjs b/lib/generator.mjs index 64f1dda..97b23ee 100644 --- a/lib/generator.mjs +++ b/lib/generator.mjs @@ -6,6 +6,7 @@ import { rm, writeFile, } from "node:fs/promises"; +import { createHash } from "node:crypto"; import path from "node:path"; // TypeScript 7 (tsgo) has a different JS API than Strada, so parse .d.ts and // self-check with the frozen final Strada line (npm alias: typescript-strada). @@ -29,8 +30,11 @@ import { getPreferredDeclarationUnits, getRootSurface, } from "./surface-inventory.mjs"; +import { loadAllowlistRegistry } from "./allowlist-registry.mjs"; const RUNTIME_DECLARATION_KINDS = new Set(["var", "function", "class", "enum", "namespace"]); +const NON_MERGEABLE_ALLOW_CONTAINER_KINDS = new Set(["class", "type-literal-var"]); +const BASELINE_SURFACE = Symbol("baseline"); // Resolution kinds where resolvedUnitIds points at the declaration surface of // the feature itself. Units from excluded rows (includeInTarget: false) with @@ -263,6 +267,15 @@ async function createGenerationPlan({ manifestPath, repoRoot }) { } const topLevelOutputPath = path.resolve(path.dirname(manifestPath), manifest.firstClassLib.outputFile); + const allowOutputDirectory = path.resolve( + path.dirname(manifestPath), + manifest.firstClassLib.allowDirectory ?? path.join(path.dirname(manifest.firstClassLib.outputFile), "allow"), + ); + if (!manifest.allowlistRegistry) { + throw new Error(`Manifest ${manifestPath} is missing allowlistRegistry`); + } + const allowlistRegistryPath = path.resolve(path.dirname(manifestPath), manifest.allowlistRegistry); + const allowlistRegistry = await loadAllowlistRegistry(allowlistRegistryPath); const generationOutputPath = resolveOutputPath(manifest.generationOutput, manifestPath, "generation.json"); const inventoryOutputPath = resolveOutputPath(manifest.inventoryOutput, manifestPath, "inventory.json"); @@ -343,6 +356,29 @@ async function createGenerationPlan({ manifestPath, repoRoot }) { excludedRowsByUnitId, }); + const emittedBaselineUnitIds = collectEmittedUnitIds({ + inventory, + selectedUnitIds, + completeContainerUnitIds, + excludedUnitIds, + }); + + const allowEntries = createAllowEntries({ + classification, + inventory, + emittedBaselineUnitIds, + completeContainerUnitIds, + excludedUnitIds, + allowOutputDirectory, + registryEntries: allowlistRegistry.entries, + }); + assertAllowEntryIsolation({ + allowEntries, + baselineUnitIds: emittedBaselineUnitIds, + inventory, + }); + const allowSupportArtifacts = createAllowSupportArtifacts(allowEntries, allowOutputDirectory); + return { manifest, manifestPath, @@ -354,6 +390,9 @@ async function createGenerationPlan({ manifestPath, repoRoot }) { generationOutputPath, compatManagementOutputPath: classification.compatManagementOutputPath, topLevelOutputPath, + allowOutputDirectory, + allowEntries, + allowSupportArtifacts, selectedUnitIds, completeContainerUnitIds, excludedUnitIds, @@ -365,10 +404,347 @@ async function createGenerationPlan({ manifestPath, repoRoot }) { kind: "top-level-lib", outputPath: topLevelOutputPath, }, + ...allowEntries.map(entry => ({ + kind: "allow-entry", + outputPath: entry.outputPath, + })), + ...allowSupportArtifacts.map(artifact => ({ + kind: "allow-support", + outputPath: artifact.outputPath, + })), ], }; } +/** + * Include units emitted through complete-container selection in the baseline set. + * + * @param {{ + * inventory: import("./surface-inventory.mjs").SurfaceInventory; + * selectedUnitIds: string[]; + * completeContainerUnitIds: Set; + * excludedUnitIds: Set; + * }} options + */ +function collectEmittedUnitIds(options) { + const emittedUnitIds = new Set(options.selectedUnitIds); + + /** @param {string} unitId */ + function includeUnit(unitId) { + if (options.excludedUnitIds.has(unitId)) { + return; + } + emittedUnitIds.add(unitId); + const unit = options.inventory.unitById.get(unitId); + if (!unit?.containerId) { + return; + } + for (const child of options.inventory.units.filter(candidate => candidate.parentContainerId === unit.containerId)) { + includeUnit(child.id); + } + } + + for (const unitId of options.completeContainerUnitIds) { + includeUnit(unitId); + } + return emittedUnitIds; +} + +/** + * @param {{ + * classification: Awaited>; + * inventory: import("./surface-inventory.mjs").SurfaceInventory; + * emittedBaselineUnitIds: Set; + * completeContainerUnitIds: Set; + * excludedUnitIds: Set; + * allowOutputDirectory: string; + * registryEntries: Array<{ entryName: string; compatKeys: string[]; }>; + * }} options + */ +function createAllowEntries(options) { + const rowByCompatKey = new Map( + options.classification.classifiedCompatRows.map(row => [row.compatKey, row]), + ); + /** @type {Map>} */ + const claimsByUnitId = new Map(); + for (const row of options.classification.classifiedCompatRows) { + for (const unitId of [ + ...row.resolvedUnitIds, + ...row.transforms.map(transform => transform.unitId), + ]) { + const claims = claimsByUnitId.get(unitId) ?? []; + claims.push({ compatKey: row.compatKey, baselineStatus: row.baselineStatus }); + claimsByUnitId.set(unitId, claims); + } + } + + return options.registryEntries.map(registryEntry => { + const rows = registryEntry.compatKeys.map(compatKey => { + const row = rowByCompatKey.get(compatKey); + if (!row) { + throw new Error(`Allow entry ${registryEntry.entryName} references missing compat key ${compatKey}`); + } + if (row.baselineStatus !== "high" && row.baselineStatus !== "low") { + throw new Error( + `Allow entry ${registryEntry.entryName} references a compat key that is not Baseline: ${compatKey}`, + ); + } + return row; + }); + const highRows = rows.filter(row => row.baselineStatus === "high"); + for (const row of highRows) { + const rowUnitIds = [ + ...row.resolvedUnitIds, + ...row.transforms.map(transform => transform.unitId), + ]; + if ( + ["already-excluded-upstream", "behavioral", "not-modeled-upstream"].includes(row.resolutionKind) + || !rowUnitIds.length + || rowUnitIds.some(unitId => !options.emittedBaselineUnitIds.has(unitId)) + ) { + throw new Error( + `Allow entry ${registryEntry.entryName} cannot alias ${row.compatKey}; ` + + "the baseline artifact does not emit its declaration surface", + ); + } + } + const lowRows = rows.filter(row => row.baselineStatus === "low"); + const outputPath = path.join(options.allowOutputDirectory, registryEntry.entryName, "index.d.ts"); + if (!lowRows.length) { + return { + kind: "alias", + entryName: registryEntry.entryName, + compatKeys: registryEntry.compatKeys, + unitIds: [], + supportUnitIds: [], + outputPath, + }; + } + + const unitIds = new Set(); + for (const row of lowRows) { + if (["already-excluded-upstream", "behavioral", "not-modeled-upstream"].includes(row.resolutionKind)) { + throw new Error( + `Allow entry ${registryEntry.entryName} cannot emit ${row.compatKey} (${row.resolutionKind})`, + ); + } + const rowUnitIds = new Set(); + for (const unitId of row.resolvedUnitIds) { + if (options.excludedUnitIds.has(unitId)) { + rowUnitIds.add(unitId); + } + if (row.resolutionKind !== "root-availability") { + continue; + } + const rootUnit = options.inventory.unitById.get(unitId); + if (!rootUnit?.containerId) { + continue; + } + for (const childUnit of options.inventory.units) { + if ( + childUnit.parentContainerId === rootUnit.containerId + && !options.emittedBaselineUnitIds.has(childUnit.id) + && !options.excludedUnitIds.has(childUnit.id) + ) { + rowUnitIds.add(childUnit.id); + } + } + } + for (const transform of row.transforms) { + rowUnitIds.add(transform.unitId); + } + if (!rowUnitIds.size) { + throw new Error( + `Allow entry ${registryEntry.entryName} does not emit declarations for ${row.compatKey}`, + ); + } + for (const unitId of rowUnitIds) { + unitIds.add(unitId); + } + } + + if (!unitIds.size) { + throw new Error(`Allow entry ${registryEntry.entryName} does not emit any declarations`); + } + + const registeredCompatKeys = new Set(registryEntry.compatKeys); + for (const unitId of unitIds) { + for (const claim of claimsByUnitId.get(unitId) ?? []) { + if ( + claim.baselineStatus !== "high" + && (claim.baselineStatus !== "low" || !registeredCompatKeys.has(claim.compatKey)) + ) { + throw new Error( + `Allow entry ${registryEntry.entryName} cannot safely emit shared unit ${unitId}; ` + + `it also belongs to ${claim.compatKey} (${String(claim.baselineStatus)})`, + ); + } + } + } + + const selectedWithEntry = new Set([...options.emittedBaselineUnitIds, ...unitIds]); + const blockedUnitIds = new Set(options.excludedUnitIds); + for (const unitId of unitIds) { + blockedUnitIds.delete(unitId); + } + const resolvedUnitIds = resolveDependencyClosure({ + inventory: options.inventory, + initiallySelectedUnitIds: selectedWithEntry, + completeContainerUnitIds: new Set(options.completeContainerUnitIds), + excludedUnitIds: blockedUnitIds, + }); + const supportUnitIds = resolvedUnitIds + .filter(unitId => !selectedWithEntry.has(unitId)) + .sort(compareStringsCaseSensitive); + return { + kind: "active", + entryName: registryEntry.entryName, + compatKeys: registryEntry.compatKeys, + unitIds: [...unitIds].sort(compareStringsCaseSensitive), + supportUnitIds, + outputPath, + }; + }); +} + +/** + * @param {{ + * allowEntries: Array<{ kind: string; entryName: string; unitIds: string[]; supportUnitIds: string[]; }>; + * baselineUnitIds: Iterable; + * inventory: import("./surface-inventory.mjs").SurfaceInventory; + * }} options + */ +function assertAllowEntryIsolation(options) { + /** @type {Map} */ + const primaryEntryByUnitId = new Map(); + /** @type {Map>} */ + const supportEntriesByUnitId = new Map(); + /** @type {Map>} */ + const surfaceIdsByContainerId = new Map(); + + /** + * @param {string | symbol} surfaceId + * @param {Iterable} unitIds + */ + function recordNonMergeableContainers(surfaceId, unitIds) { + for (const unitId of new Set(unitIds)) { + const unit = options.inventory.unitById.get(unitId); + if (!unit) { + throw new Error(`Unknown generated declaration unit ${unitId}`); + } + let containerId = unit.containerId ?? unit.parentContainerId; + while (containerId) { + const container = options.inventory.containerById.get(containerId); + if (!container) { + throw new Error(`Unknown generated declaration container ${containerId}`); + } + if (NON_MERGEABLE_ALLOW_CONTAINER_KINDS.has(container.containerKind)) { + const surfaceIds = surfaceIdsByContainerId.get(containerId) ?? new Set(); + surfaceIds.add(surfaceId); + surfaceIdsByContainerId.set(containerId, surfaceIds); + } + containerId = container.parentContainerId; + } + } + } + + recordNonMergeableContainers(BASELINE_SURFACE, options.baselineUnitIds); + + for (const entry of options.allowEntries) { + if (entry.kind !== "active") { + continue; + } + for (const unitId of entry.unitIds) { + const existingEntryName = primaryEntryByUnitId.get(unitId); + if (existingEntryName && existingEntryName !== entry.entryName) { + throw new Error( + `Allow declaration unit ${unitId} belongs to multiple entries: ` + + `${existingEntryName}, ${entry.entryName}`, + ); + } + primaryEntryByUnitId.set(unitId, entry.entryName); + } + for (const unitId of entry.supportUnitIds) { + const entryNames = supportEntriesByUnitId.get(unitId) ?? new Set(); + entryNames.add(entry.entryName); + supportEntriesByUnitId.set(unitId, entryNames); + } + recordNonMergeableContainers(entry.entryName, [...entry.unitIds, ...entry.supportUnitIds]); + } + + for (const [unitId, primaryEntryName] of primaryEntryByUnitId) { + const conflictingEntryNames = [...supportEntriesByUnitId.get(unitId) ?? []] + .filter(entryName => entryName !== primaryEntryName) + .sort(compareStringsCaseSensitive); + if (conflictingEntryNames.length) { + throw new Error( + `Allow declaration unit ${unitId} is primary in ${primaryEntryName} ` + + `and support in ${conflictingEntryNames.join(", ")}`, + ); + } + } + + for (const [containerId, surfaceIds] of surfaceIdsByContainerId) { + const sortedSurfaceNames = [...surfaceIds] + .map(surfaceId => typeof surfaceId === "string" ? surfaceId : "baseline") + .sort(compareStringsCaseSensitive); + if (sortedSurfaceNames.length > 1) { + const container = options.inventory.containerById.get(containerId); + throw new Error( + `Non-mergeable declaration container ${container?.symbolName ?? containerId} ` + + `cannot span generated surfaces: ${sortedSurfaceNames.join(", ")}`, + ); + } + } +} + +/** + * @param {Array<{ entryName: string; supportUnitIds: string[]; }>} allowEntries + * @param {string} allowOutputDirectory + */ +function createAllowSupportArtifacts(allowEntries, allowOutputDirectory) { + /** @type {Map>} */ + const entryNamesByUnitId = new Map(); + for (const entry of allowEntries) { + for (const unitId of entry.supportUnitIds) { + const entryNames = entryNamesByUnitId.get(unitId) ?? new Set(); + entryNames.add(entry.entryName); + entryNamesByUnitId.set(unitId, entryNames); + } + } + + /** @type {Map} */ + const groups = new Map(); + for (const [unitId, entryNames] of entryNamesByUnitId) { + const sortedEntryNames = [...entryNames].sort(compareStringsCaseSensitive); + const groupKey = sortedEntryNames.join("\0"); + const group = groups.get(groupKey) ?? { + entryNames: sortedEntryNames, + unitIds: [], + }; + group.unitIds.push(unitId); + groups.set(groupKey, group); + } + + const fileNames = new Set(); + return [...groups.values()].map(group => { + group.unitIds.sort(compareStringsCaseSensitive); + const fileName = group.entryNames.length === 1 + ? `${group.entryNames[0]}.d.ts` + : `shared-${createHash("sha256").update(group.entryNames.join("\0")).digest("hex").slice(0, 16)}.d.ts`; + if (fileNames.has(fileName)) { + throw new Error(`Allow support filename collision: ${fileName}`); + } + fileNames.add(fileName); + return { + entryNames: group.entryNames, + unitIds: group.unitIds, + fileName, + outputPath: path.join(allowOutputDirectory, "_support", fileName), + }; + }).sort((left, right) => compareStringsCaseSensitive(left.fileName, right.fileName)); +} + /** * @param {GenerationPlan} plan */ @@ -393,6 +769,55 @@ async function publishGenerationPlan(plan) { await mkdir(path.dirname(plan.topLevelOutputPath), { recursive: true }); await writeFile(plan.topLevelOutputPath, topLevelContents); + await rm(plan.allowOutputDirectory, { recursive: true, force: true }); + /** @type {Map} */ + const supportArtifactsByEntryName = new Map(); + for (const artifact of plan.allowSupportArtifacts) { + const contents = emitSelectedUnits({ + inventory: plan.inventory, + selectedUnitIds: artifact.unitIds, + }); + await mkdir(path.dirname(artifact.outputPath), { recursive: true }); + await writeFile(artifact.outputPath, contents); + for (const entryName of artifact.entryNames) { + const artifacts = supportArtifactsByEntryName.get(entryName) ?? []; + artifacts.push(artifact); + supportArtifactsByEntryName.set(entryName, artifacts); + } + } + for (const entry of plan.allowEntries) { + if (entry.kind === "alias") { + const relativePath = path.relative(path.dirname(entry.outputPath), plan.topLevelOutputPath) + .split(path.sep) + .join(path.posix.sep); + await mkdir(path.dirname(entry.outputPath), { recursive: true }); + await writeFile(entry.outputPath, `/// \n`); + continue; + } + const declarations = emitSelectedUnits({ + inventory: plan.inventory, + selectedUnitIds: entry.unitIds, + }); + const supportArtifacts = supportArtifactsByEntryName.get(entry.entryName) ?? []; + const coveredSupportUnitIds = new Set(supportArtifacts.flatMap(artifact => artifact.unitIds)); + for (const unitId of entry.supportUnitIds) { + if (!coveredSupportUnitIds.has(unitId)) { + throw new Error(`Missing allow support artifact for unit ${unitId}`); + } + } + const references = supportArtifacts.map(artifact => { + const relativePath = path.relative(path.dirname(entry.outputPath), artifact.outputPath) + .split(path.sep) + .join(path.posix.sep); + return `/// `; + }); + const contents = references.length + ? `${references.join("\n")}\n\n${declarations}` + : declarations; + await mkdir(path.dirname(entry.outputPath), { recursive: true }); + await writeFile(entry.outputPath, contents); + } + await mkdir(path.dirname(plan.generationOutputPath), { recursive: true }); await writeFile(plan.generationOutputPath, `${JSON.stringify(getGenerationReport(plan), undefined, 2)}\n`); } @@ -834,6 +1259,9 @@ function getGenerationReport(plan) { excludedUnitCount: plan.excludedUnitIds.size, preservedTypeOnlyUnitCount: plan.typeOnlyUnitIds.length, transformedUnitCount: plan.unitTextOverrides.size, + allowEntryCount: plan.allowEntries.length, + allowEntryUnitCount: plan.allowEntries.reduce((count, entry) => count + entry.unitIds.length, 0), + allowSupportUnitCount: new Set(plan.allowSupportArtifacts.flatMap(artifact => artifact.unitIds)).size, }, // Record sourcePath in canonical form (/lib/). Don't // write the real path of the platform-specific package: it's @@ -851,6 +1279,14 @@ function getGenerationReport(plan) { })), preservedTypeOnlyUnits: [...plan.typeOnlyUnitIds].sort(compareStringsCaseSensitive), transformedUnits: [...plan.unitTextOverrides.keys()].sort(compareStringsCaseSensitive), + allowEntries: plan.allowEntries.map(entry => ({ + kind: entry.kind, + entryName: entry.entryName, + outputPath: formatPathForReport(plan.repoRoot, entry.outputPath), + compatKeys: entry.compatKeys, + unitIds: entry.unitIds, + supportUnitIds: entry.supportUnitIds, + })), // For audit: which compat rows block which units from the artifact. excludedUnits: [...plan.excludedRowsByUnitId.entries()] .sort(([left], [right]) => compareStringsCaseSensitive(left, right)) @@ -907,6 +1343,21 @@ async function readManifest(manifestPath) { * generationOutputPath: string; * compatManagementOutputPath: string; * topLevelOutputPath: string; + * allowOutputDirectory: string; + * allowEntries: Array<{ + * kind: string; + * entryName: string; + * compatKeys: string[]; + * unitIds: string[]; + * supportUnitIds: string[]; + * outputPath: string; + * }>; + * allowSupportArtifacts: Array<{ + * entryNames: string[]; + * unitIds: string[]; + * fileName: string; + * outputPath: string; + * }>; * selectedUnitIds: string[]; * completeContainerUnitIds: Set; * excludedUnitIds: Set; diff --git a/manifests/baseline-js.json b/manifests/baseline-js.json index 4d16c5c..7355231 100644 --- a/manifests/baseline-js.json +++ b/manifests/baseline-js.json @@ -21,13 +21,15 @@ "baselineTarget": "high", "dataset": "../datasets/web-features-js-compat.json", "compatManagementRegistry": "../registry/compat-management.json", + "allowlistRegistry": "../registry/allowlist.json", "classificationOutput": "../derived/current/classification.json", "compatManagementOutput": "../derived/current/compat-management-report.json", "inventoryOutput": "../derived/current/inventory.json", "generationOutput": "../derived/current/generation.json", "firstClassLib": { "libName": "baseline", - "outputFile": "../generated/current/baseline.d.ts" + "outputFile": "../generated/current/baseline.d.ts", + "allowDirectory": "../generated/current/allow" }, "libSource": { "basePackage": "typescript", diff --git a/registry/allowlist.json b/registry/allowlist.json new file mode 100644 index 0000000..c545d15 --- /dev/null +++ b/registry/allowlist.json @@ -0,0 +1,135 @@ +{ + "schemaVersion": 1, + "entries": [ + { + "entryName": "array-fromasync", + "compatKeys": [ + "javascript.builtins.Array.fromAsync" + ] + }, + { + "entryName": "array-group", + "compatKeys": [ + "javascript.builtins.Map.groupBy", + "javascript.builtins.Object.groupBy" + ] + }, + { + "entryName": "atomics-pause", + "compatKeys": [ + "javascript.builtins.Atomics.pause" + ] + }, + { + "entryName": "atomics-wait-async", + "compatKeys": [ + "javascript.builtins.Atomics.waitAsync" + ] + }, + { + "entryName": "float16array", + "compatKeys": [ + "javascript.builtins.DataView.getFloat16", + "javascript.builtins.DataView.setFloat16", + "javascript.builtins.Float16Array", + "javascript.builtins.Float16Array.Float16Array", + "javascript.builtins.Math.f16round" + ] + }, + { + "entryName": "getorinsert", + "compatKeys": [ + "javascript.builtins.Map.getOrInsert", + "javascript.builtins.Map.getOrInsertComputed", + "javascript.builtins.WeakMap.getOrInsert", + "javascript.builtins.WeakMap.getOrInsertComputed" + ] + }, + { + "entryName": "intl-duration-format", + "compatKeys": [ + "javascript.builtins.Intl.DurationFormat", + "javascript.builtins.Intl.DurationFormat.DurationFormat", + "javascript.builtins.Intl.DurationFormat.format", + "javascript.builtins.Intl.DurationFormat.formatToParts", + "javascript.builtins.Intl.DurationFormat.resolvedOptions", + "javascript.builtins.Intl.DurationFormat.supportedLocalesOf" + ] + }, + { + "entryName": "intl-segmenter", + "compatKeys": [ + "javascript.builtins.Intl.Segmenter", + "javascript.builtins.Intl.Segmenter.Segmenter", + "javascript.builtins.Intl.Segmenter.resolvedOptions", + "javascript.builtins.Intl.Segmenter.segment", + "javascript.builtins.Intl.Segmenter.supportedLocalesOf", + "javascript.builtins.Intl.Segments", + "javascript.builtins.Intl.Segments.@@iterator", + "javascript.builtins.Intl.Segments.containing" + ] + }, + { + "entryName": "promise-try", + "compatKeys": [ + "javascript.builtins.Promise.try" + ] + }, + { + "entryName": "promise-withresolvers", + "compatKeys": [ + "javascript.builtins.Promise.withResolvers" + ] + }, + { + "entryName": "regexp-escape", + "compatKeys": [ + "javascript.builtins.RegExp.escape" + ] + }, + { + "entryName": "resizable-buffers", + "compatKeys": [ + "javascript.builtins.ArrayBuffer.ArrayBuffer.maxByteLength_option", + "javascript.builtins.ArrayBuffer.maxByteLength", + "javascript.builtins.ArrayBuffer.resizable", + "javascript.builtins.ArrayBuffer.resize", + "javascript.builtins.SharedArrayBuffer.SharedArrayBuffer.maxByteLength_option", + "javascript.builtins.SharedArrayBuffer.grow", + "javascript.builtins.SharedArrayBuffer.growable", + "javascript.builtins.SharedArrayBuffer.maxByteLength" + ] + }, + { + "entryName": "set-methods", + "compatKeys": [ + "javascript.builtins.Set.difference", + "javascript.builtins.Set.intersection", + "javascript.builtins.Set.isDisjointFrom", + "javascript.builtins.Set.isSubsetOf", + "javascript.builtins.Set.isSupersetOf", + "javascript.builtins.Set.symmetricDifference", + "javascript.builtins.Set.union" + ] + }, + { + "entryName": "transferable-arraybuffer", + "compatKeys": [ + "javascript.builtins.ArrayBuffer.detached", + "javascript.builtins.ArrayBuffer.transfer", + "javascript.builtins.ArrayBuffer.transferToFixedLength" + ] + }, + { + "entryName": "uint8array-base64-hex", + "compatKeys": [ + "javascript.builtins.Uint8Array.fromBase64", + "javascript.builtins.Uint8Array.fromHex", + "javascript.builtins.Uint8Array.setFromBase64", + "javascript.builtins.Uint8Array.setFromHex", + "javascript.builtins.Uint8Array.toBase64", + "javascript.builtins.Uint8Array.toHex" + ] + } + ] +} diff --git a/scripts/write-update-pr-body.mjs b/scripts/write-update-pr-body.mjs index 2d91f8d..c83e9e3 100644 --- a/scripts/write-update-pr-body.mjs +++ b/scripts/write-update-pr-body.mjs @@ -147,6 +147,9 @@ function buildUpdateSummary(options) { const previousClassificationSummary = previousState?.classification?.summary; const previousGenerationSummary = previousState?.generation?.summary; const previousCompatRegistry = previousState?.compatManagement?.registry; + const currentAllowEntries = currentState.generation.allowEntries ?? []; + const previousAllowEntries = previousState?.generation?.allowEntries ?? []; + const allowEntryChanges = compareAllowEntries(previousAllowEntries, currentAllowEntries); /** @type {string[]} */ const reviewFlags = []; @@ -159,6 +162,9 @@ function buildUpdateSummary(options) { if ((delta(currentCompatSummary.managedUpstreamStateCounts.actionable, previousState?.compatManagement?.summary?.managedUpstreamStateCounts?.actionable) ?? 0) !== 0) { reviewFlags.push("Actionable upstream-gap count changed. Confirm whether a new or updated `microsoft/TypeScript` or `web-features` action item is needed."); } + if (allowEntryChanges.length) { + reviewFlags.push("Allow entry state or compat contract changed. Verify the polyfill contract and generated declaration diff before merging."); + } if (!reviewFlags.length) { reviewFlags.push("No special review flags beyond the normal generated diff review."); } @@ -182,6 +188,17 @@ function buildUpdateSummary(options) { selectedUnitCount: delta(currentGenerationSummary.selectedUnitCount, previousGenerationSummary?.selectedUnitCount), transformedUnitCount: delta(currentGenerationSummary.transformedUnitCount, previousGenerationSummary?.transformedUnitCount), }, + allowEntries: { + activeCount: currentAllowEntries.filter( + /** @param {{ kind?: string; }} entry */ + entry => entry.kind === "active", + ).length, + aliasCount: currentAllowEntries.filter( + /** @param {{ kind?: string; }} entry */ + entry => entry.kind === "alias", + ).length, + changes: allowEntryChanges, + }, reviewFlags, }; } @@ -217,6 +234,8 @@ function renderMarkdown(summary) { `- Included high rows: ${formatCountWithDelta(currentClassificationSummary.includedCompatCount, summary.deltas.includedCompatCount)}`, `- Selected declaration units: ${formatCountWithDelta(currentGenerationSummary.selectedUnitCount, summary.deltas.selectedUnitCount)}`, `- Transformed units: ${formatCountWithDelta(currentGenerationSummary.transformedUnitCount, summary.deltas.transformedUnitCount)}`, + `- Allow entries: ${summary.allowEntries.activeCount} active, ${summary.allowEntries.aliasCount} aliases`, + `- Allow entry changes: ${summary.allowEntries.changes.length ? summary.allowEntries.changes.join("; ") : "none"}`, "", "## Compat Management", `- Registry hash: \`${summary.currentState.compatManagement.registry.sourceHash}\``, @@ -239,6 +258,39 @@ function renderMarkdown(summary) { ].join("\n"); } +/** + * @param {Array<{ entryName: string; kind?: string; compatKeys?: string[]; }>} previousEntries + * @param {Array<{ entryName: string; kind?: string; compatKeys?: string[]; }>} currentEntries + */ +function compareAllowEntries(previousEntries, currentEntries) { + const previousByName = new Map(previousEntries.map(entry => [entry.entryName, entry])); + const currentByName = new Map(currentEntries.map(entry => [entry.entryName, entry])); + const names = [...new Set([...previousByName.keys(), ...currentByName.keys()])].sort(); + const changes = []; + + for (const name of names) { + const previous = previousByName.get(name); + const current = currentByName.get(name); + if (!previous) { + changes.push(`added allow/${name} (${current?.kind ?? "unknown"})`); + continue; + } + if (!current) { + changes.push(`removed allow/${name}`); + continue; + } + if (previous.kind !== current.kind) { + changes.push(`allow/${name}: ${previous.kind ?? "unknown"} -> ${current.kind ?? "unknown"}`); + } + const previousCompatKeys = [...(previous.compatKeys ?? [])].sort(); + const currentCompatKeys = [...(current.compatKeys ?? [])].sort(); + if (JSON.stringify(previousCompatKeys) !== JSON.stringify(currentCompatKeys)) { + changes.push(`allow/${name}: compat contract changed`); + } + } + return changes; +} + /** * @param {string} filePath */ diff --git a/test/allowlist.test.mjs b/test/allowlist.test.mjs new file mode 100644 index 0000000..0db0af3 --- /dev/null +++ b/test/allowlist.test.mjs @@ -0,0 +1,695 @@ +// @ts-check + +import assert from "node:assert/strict"; +import fs from "node:fs"; +import path from "node:path"; +import test from "node:test"; +import { + assertAllowEntryContractsPreserved, + assertNoRemovedAllowEntries, +} from "../deploy/package-lib.mjs"; +import { baselinePackageName } from "../deploy/package-registry.mjs"; +import { loadAllowlistRegistry } from "../lib/allowlist-registry.mjs"; +import { + cleanupTempDirectories, + createBaselinePackageTarball, + createManifest, + createTempDirectory, + readJsonFile, + repoAllowlistRegistryPath, + repoDatasetPath, + runGenerate, + runGenerateExpectFailure, + runNpm, + runTsc, + runTscExpectFailure, + runTscStrada, + runTscStradaExpectFailure, + writeJsonFile, + writeTextFile, +} from "./helpers.mjs"; + +/** @type {Record} */ +const ALLOW_ENTRY_PROBES = { + "array-fromasync": "Array.fromAsync([1, 2, 3]);\n", + "array-group": [ + "Object.groupBy([1, 2, 3], value => String(value));", + "Map.groupBy([1, 2, 3], value => value % 2);", + "", + ].join("\n"), + "atomics-pause": "Atomics.pause();\n", + "atomics-wait-async": "Atomics.waitAsync(new Int32Array(new SharedArrayBuffer(4)), 0, 0);\n", + float16array: [ + "const float16 = new Float16Array(2);", + "const float16View = new DataView(new ArrayBuffer(4));", + "float16View.getFloat16(0);", + "float16View.setFloat16(0, Math.f16round(1));", + "float16.length;", + "float16.map(value => value);", + "Float16Array.from([1, 2, 3]);", + "", + ].join("\n"), + getorinsert: [ + "const map = new Map();", + "map.getOrInsert(\"key\", 1);", + "map.getOrInsertComputed(\"key\", () => 1);", + "const weakMap = new WeakMap();", + "weakMap.getOrInsert({}, 1);", + "weakMap.getOrInsertComputed({}, () => 1);", + "", + ].join("\n"), + "intl-duration-format": [ + "const durationFormat = new Intl.DurationFormat(\"en\");", + "durationFormat.format({ seconds: 1 });", + "durationFormat.formatToParts({ seconds: 1 });", + "durationFormat.resolvedOptions();", + "Intl.DurationFormat.supportedLocalesOf([\"en\"]);", + "", + ].join("\n"), + "intl-segmenter": [ + "const segmenter = new Intl.Segmenter(\"en\");", + "const segments = segmenter.segment(\"text\");", + "segments.containing(0);", + "segments[Symbol.iterator]();", + "segmenter.resolvedOptions();", + "Intl.Segmenter.supportedLocalesOf([\"en\"]);", + "", + ].join("\n"), + "promise-try": "Promise.try(() => 1);\n", + "promise-withresolvers": "Promise.withResolvers();\n", + "regexp-escape": "RegExp.escape(\"a.b\");\n", + "resizable-buffers": [ + "const resizable = new ArrayBuffer(8, { maxByteLength: 16 });", + "resizable.maxByteLength;", + "resizable.resizable;", + "resizable.resize(12);", + "const growable = new SharedArrayBuffer(8, { maxByteLength: 16 });", + "growable.maxByteLength;", + "growable.growable;", + "growable.grow(12);", + "", + ].join("\n"), + "set-methods": [ + "const left = new Set([1]);", + "const right = new Set([2]);", + "left.union(right);", + "left.intersection(right);", + "left.difference(right);", + "left.symmetricDifference(right);", + "left.isSubsetOf(right);", + "left.isSupersetOf(right);", + "left.isDisjointFrom(right);", + "", + ].join("\n"), + "transferable-arraybuffer": [ + "const transferable = new ArrayBuffer(8);", + "transferable.detached;", + "transferable.transfer();", + "transferable.transferToFixedLength();", + "", + ].join("\n"), + "uint8array-base64-hex": [ + "const bytes = Uint8Array.fromBase64(\"AA==\");", + "Uint8Array.fromHex(\"00\");", + "bytes.setFromBase64(\"AA==\");", + "bytes.setFromHex(\"00\");", + "bytes.toBase64();", + "bytes.toHex();", + "", + ].join("\n"), +}; + +/** @type {string[]} */ +const tempDirectories = []; + +test.afterEach(() => { + cleanupTempDirectories(tempDirectories); +}); + +test("every registered allow entry exposes its complete API surface under TypeScript 6 and 7", async () => { + const tempDirectory = createTempDirectory(tempDirectories); + const consumerDirectory = path.join(tempDirectory, "consumer"); + const { stageDirectory, tarballPath } = await createBaselinePackageTarball({ tempDirectories }); + const registry = await loadAllowlistRegistry(repoAllowlistRegistryPath); + const stagedPackageJson = readJsonFile(path.join(stageDirectory, "package.json")); + const stagedGeneration = readJsonFile(path.join(stageDirectory, "reports", "generation.json")); + const generationEntryByName = new Map(stagedGeneration.allowEntries.map( + /** @param {{ entryName: string; kind: string; }} entry */ + entry => [entry.entryName, entry], + )); + + assert.deepEqual( + Object.keys(ALLOW_ENTRY_PROBES).sort(), + registry.entries.map(entry => entry.entryName), + ); + assert.deepEqual(stagedPackageJson.typesVersions["*"]["allow/*"], ["allow/*/index.d.ts"]); + assert.equal(stagedPackageJson.exports, undefined); + + writeJsonFile(path.join(consumerDirectory, "package.json"), { + name: "baseline-allow-consumer-fixture", + private: true, + }); + runNpm(["install", "--no-package-lock", "--no-save", tarballPath], { cwd: consumerDirectory }); + + for (const entry of registry.entries) { + writeTextFile(path.join(consumerDirectory, `${entry.entryName}.ts`), ALLOW_ENTRY_PROBES[entry.entryName]); + writeConsumerConfig(consumerDirectory, entry.entryName, [ + baselinePackageName, + `${baselinePackageName}/allow/${entry.entryName}`, + ]); + const configPath = path.join(consumerDirectory, `tsconfig.${entry.entryName}.json`); + runTsc(["-p", configPath], { cwd: consumerDirectory }); + runTscStrada(["-p", configPath], { cwd: consumerDirectory }); + + const baseName = `base-${entry.entryName}`; + writeTextFile(path.join(consumerDirectory, `${baseName}.ts`), ALLOW_ENTRY_PROBES[entry.entryName]); + writeConsumerConfig(consumerDirectory, baseName, [baselinePackageName]); + const baseConfigPath = path.join(consumerDirectory, `tsconfig.${baseName}.json`); + if (generationEntryByName.get(entry.entryName)?.kind === "active") { + assert.equal(runTscExpectFailure(["-p", baseConfigPath], { cwd: consumerDirectory }).ok, false); + assert.equal(runTscStradaExpectFailure(["-p", baseConfigPath], { cwd: consumerDirectory }).ok, false); + } + else { + runTsc(["-p", baseConfigPath], { cwd: consumerDirectory }); + runTscStrada(["-p", baseConfigPath], { cwd: consumerDirectory }); + } + } +}); + +test("allow entries preserve isolation under TypeScript 6 and 7", async () => { + const tempDirectory = createTempDirectory(tempDirectories); + const consumerDirectory = path.join(tempDirectory, "consumer"); + const { tarballPath } = await createBaselinePackageTarball({ tempDirectories }); + const promiseEntry = `${baselinePackageName}/allow/promise-withresolvers`; + + writeJsonFile(path.join(consumerDirectory, "package.json"), { + name: "baseline-allow-isolation-fixture", + private: true, + }); + runNpm(["install", "--no-package-lock", "--no-save", tarballPath], { cwd: consumerDirectory }); + + writeTextFile(path.join(consumerDirectory, "promise-only-fail.ts"), "Array.fromAsync([1, 2, 3]);\n"); + writeConsumerConfig(consumerDirectory, "promise-only-fail", [baselinePackageName, promiseEntry]); + assertCompilerFailuresContain(consumerDirectory, "promise-only-fail", /fromAsync/); + + writeTextFile(path.join(consumerDirectory, "limited-fail.ts"), "\"legacy\".substr(1);\n"); + writeConsumerConfig(consumerDirectory, "limited-fail", [baselinePackageName, promiseEntry]); + assertCompilerFailuresContain(consumerDirectory, "limited-fail", /substr/); +}); + +test("generation is registry-bound, non-empty, safe, and deterministic", async () => { + const tempDirectory = createTempDirectory(tempDirectories); + const fixture = createManifest(tempDirectory); + const registry = await loadAllowlistRegistry(repoAllowlistRegistryPath); + + runGenerate(fixture.manifestPath); + const firstSnapshot = readDirectorySnapshot(path.join(fixture.outputRoot, "generated", "allow")); + const generation = readJsonFile(fixture.generationOutputPath); + + assert.deepEqual( + generation.allowEntries.map( + /** @param {{ entryName: string; }} entry */ + entry => entry.entryName, + ), + registry.entries.map(entry => entry.entryName), + ); + assert.ok(generation.allowEntries.every( + /** @param {{ kind: string; unitIds: string[]; }} entry */ + entry => entry.kind === "alias" || entry.unitIds.length > 0, + )); + assert.deepEqual( + generation.allowEntries.filter( + /** @param {{ entryName: string; }} entry */ + entry => ["iterator-concat", "iterator-methods", "json-raw", "math-sum-precise", "weak-references", "weakmap", "weakset"] + .includes(entry.entryName), + ), + [], + ); + + const supportDirectory = path.join(fixture.outputRoot, "generated", "allow", "_support"); + const supportFiles = fs.existsSync(supportDirectory) + ? fs.readdirSync(supportDirectory).sort() + : []; + /** @type {Map>} */ + const consumersByUnitId = new Map(); + for (const entry of generation.allowEntries) { + for (const unitId of entry.supportUnitIds) { + const consumers = consumersByUnitId.get(unitId) ?? new Set(); + consumers.add(entry.entryName); + consumersByUnitId.set(unitId, consumers); + } + } + const consumerGroups = new Set( + [...consumersByUnitId.values()].map(consumers => [...consumers].sort().join("\0")), + ); + assert.equal(supportFiles.length, consumerGroups.size); + for (const group of consumerGroups) { + const entryNames = group.split("\0"); + if (entryNames.length === 1) { + assert.ok(supportFiles.includes(`${entryNames[0]}.d.ts`)); + } + } + + const referencedSupportFiles = new Set(); + for (const entry of generation.allowEntries) { + const source = fs.readFileSync( + path.join(fixture.outputRoot, "generated", "allow", entry.entryName, "index.d.ts"), + "utf8", + ); + for (const match of source.matchAll(/^\/\/\/ $/gm)) { + assert.ok(supportFiles.includes(match[1])); + referencedSupportFiles.add(match[1]); + } + } + assert.deepEqual([...referencedSupportFiles].sort(), supportFiles); + + runGenerate(fixture.manifestPath); + const secondSnapshot = readDirectorySnapshot(path.join(fixture.outputRoot, "generated", "allow")); + assert.deepEqual(secondSnapshot, firstSnapshot); +}); + +test("shared support bundles preserve entry isolation and composition under TypeScript 6 and 7", () => { + const tempDirectory = createTempDirectory(tempDirectories); + const allowlistRegistryPath = path.join(tempDirectory, "allowlist.json"); + writeJsonFile(allowlistRegistryPath, { + schemaVersion: 1, + entries: [ + { + entryName: "duration-core", + compatKeys: [ + "javascript.builtins.Intl.DurationFormat", + "javascript.builtins.Intl.DurationFormat.DurationFormat", + "javascript.builtins.Intl.DurationFormat.format", + ], + }, + { + entryName: "duration-details", + compatKeys: [ + "javascript.builtins.Intl.DurationFormat.formatToParts", + "javascript.builtins.Intl.DurationFormat.resolvedOptions", + ], + }, + ], + }); + const fixture = createManifest(tempDirectory, { allowlistRegistryPath }); + runGenerate(fixture.manifestPath); + + const coreEntryPath = path.join(fixture.outputRoot, "generated", "allow", "duration-core", "index.d.ts"); + const detailsEntryPath = path.join(fixture.outputRoot, "generated", "allow", "duration-details", "index.d.ts"); + const coreSupportFiles = readSupportReferences(coreEntryPath); + const detailsSupportFiles = readSupportReferences(detailsEntryPath); + const sharedSupportFiles = coreSupportFiles.filter(fileName => detailsSupportFiles.includes(fileName)); + assert.ok(sharedSupportFiles.length > 0); + assert.ok(sharedSupportFiles.every(fileName => /^shared-[0-9a-f]{16}\.d\.ts$/.test(fileName))); + + const cases = [ + { + name: "core", + entries: [coreEntryPath], + source: [ + "const formatter = new Intl.DurationFormat(\"en\");", + "formatter.format({ seconds: 1 });", + "", + ].join("\n"), + }, + { + name: "details", + entries: [detailsEntryPath], + source: [ + "declare const formatter: Intl.DurationFormat;", + "formatter.formatToParts({ seconds: 1 });", + "formatter.resolvedOptions();", + "", + ].join("\n"), + }, + { + name: "combined", + entries: [coreEntryPath, detailsEntryPath], + source: [ + "const formatter = new Intl.DurationFormat(\"en\");", + "formatter.format({ seconds: 1 });", + "formatter.formatToParts({ seconds: 1 });", + "formatter.resolvedOptions();", + "", + ].join("\n"), + }, + ]; + for (const compilerCase of cases) { + const configPath = writeDirectConsumerConfig({ + directory: tempDirectory, + name: compilerCase.name, + source: compilerCase.source, + declarationFiles: [fixture.topLevelOutputPath, ...compilerCase.entries], + }); + runTsc(["-p", configPath], { cwd: tempDirectory }); + runTscStrada(["-p", configPath], { cwd: tempDirectory }); + } + + const coreIsolationConfig = writeDirectConsumerConfig({ + directory: tempDirectory, + name: "core-isolation", + source: [ + "const formatter = new Intl.DurationFormat(\"en\");", + "formatter.formatToParts({ seconds: 1 });", + "", + ].join("\n"), + declarationFiles: [fixture.topLevelOutputPath, coreEntryPath], + }); + assert.match(runTscExpectFailure(["-p", coreIsolationConfig], { cwd: tempDirectory }).output, /formatToParts/); + assert.match(runTscStradaExpectFailure(["-p", coreIsolationConfig], { cwd: tempDirectory }).output, /formatToParts/); + + const detailsIsolationConfig = writeDirectConsumerConfig({ + directory: tempDirectory, + name: "details-isolation", + source: "new Intl.DurationFormat(\"en\");\n", + declarationFiles: [fixture.topLevelOutputPath, detailsEntryPath], + }); + assert.match(runTscExpectFailure(["-p", detailsIsolationConfig], { cwd: tempDirectory }).output, /DurationFormat/); + assert.match(runTscStradaExpectFailure(["-p", detailsIsolationConfig], { cwd: tempDirectory }).output, /DurationFormat/); +}); + +test("non-mergeable declaration containers cannot span allow entries", () => { + const tempDirectory = createTempDirectory(tempDirectories); + const allowlistRegistryPath = path.join(tempDirectory, "allowlist.json"); + writeJsonFile(allowlistRegistryPath, { + schemaVersion: 1, + entries: [ + { + entryName: "duration-core", + compatKeys: [ + "javascript.builtins.Intl.DurationFormat", + "javascript.builtins.Intl.DurationFormat.DurationFormat", + "javascript.builtins.Intl.DurationFormat.format", + ], + }, + { + entryName: "duration-details", + compatKeys: [ + "javascript.builtins.Intl.DurationFormat.formatToParts", + "javascript.builtins.Intl.DurationFormat.resolvedOptions", + "javascript.builtins.Intl.DurationFormat.supportedLocalesOf", + ], + }, + ], + }); + const fixture = createManifest(tempDirectory, { allowlistRegistryPath }); + + const failure = runGenerateExpectFailure(fixture.manifestPath); + assert.match( + failure, + /Non-mergeable declaration container Intl\.DurationFormat cannot span generated surfaces: duration-core, duration-details/, + ); +}); + +test("partial Baseline promotion cannot split a non-mergeable container from its allow entry", () => { + const tempDirectory = createTempDirectory(tempDirectories); + const datasetPath = path.join(tempDirectory, "dataset.json"); + const allowlistRegistryPath = path.join(tempDirectory, "allowlist.json"); + const dataset = readJsonFile(repoDatasetPath); + const promotedCompatKeys = new Set([ + "javascript.builtins.Intl.DurationFormat", + "javascript.builtins.Intl.DurationFormat.DurationFormat", + "javascript.builtins.Intl.DurationFormat.format", + ]); + for (const row of dataset.compatRows) { + if (promotedCompatKeys.has(row.compatKey)) { + row.baselineStatus = "high"; + } + } + writeJsonFile(datasetPath, dataset); + const durationFormatCompatKeys = [ + "javascript.builtins.Intl.DurationFormat", + "javascript.builtins.Intl.DurationFormat.DurationFormat", + "javascript.builtins.Intl.DurationFormat.format", + "javascript.builtins.Intl.DurationFormat.formatToParts", + "javascript.builtins.Intl.DurationFormat.resolvedOptions", + "javascript.builtins.Intl.DurationFormat.supportedLocalesOf", + ]; + + for (const entryName of ["intl-duration-format", "baseline"]) { + writeJsonFile(allowlistRegistryPath, { + schemaVersion: 1, + entries: [{ entryName, compatKeys: durationFormatCompatKeys }], + }); + const fixture = createManifest(tempDirectory, { datasetPath, allowlistRegistryPath }); + const failure = runGenerateExpectFailure(fixture.manifestPath); + const expectedSurfaces = entryName === "baseline" + ? "baseline, baseline" + : "baseline, intl-duration-format"; + assert.match( + failure, + new RegExp( + `Non-mergeable declaration container Intl\\.DurationFormat ` + + `cannot span generated surfaces: ${expectedSurfaces}`, + ), + ); + } +}); + +test("a registered path becomes a permanent baseline alias after promotion", () => { + const tempDirectory = createTempDirectory(tempDirectories); + const datasetPath = path.join(tempDirectory, "dataset.json"); + const allowlistRegistryPath = path.join(tempDirectory, "allowlist.json"); + const dataset = readJsonFile(repoDatasetPath); + const compatKey = "javascript.builtins.Promise.withResolvers"; + writeJsonFile(datasetPath, dataset); + writeJsonFile(allowlistRegistryPath, { + schemaVersion: 1, + entries: [{ entryName: "promise-withresolvers", compatKeys: [compatKey] }], + }); + const fixture = createManifest(tempDirectory, { datasetPath, allowlistRegistryPath }); + + runGenerate(fixture.manifestPath); + const activeGeneration = readJsonFile(fixture.generationOutputPath); + assert.equal(activeGeneration.allowEntries[0].kind, "active"); + assert.ok(activeGeneration.allowEntries[0].unitIds.length); + + const compatRow = dataset.compatRows.find( + /** @param {{ compatKey: string; }} row */ + row => row.compatKey === compatKey, + ); + assert.ok(compatRow); + compatRow.baselineStatus = "high"; + writeJsonFile(datasetPath, dataset); + runGenerate(fixture.manifestPath); + + const promotedGeneration = readJsonFile(fixture.generationOutputPath); + assert.deepEqual(promotedGeneration.allowEntries[0], { + kind: "alias", + entryName: "promise-withresolvers", + outputPath: path.join(fixture.outputRoot, "generated", "allow", "promise-withresolvers", "index.d.ts"), + compatKeys: [compatKey], + unitIds: [], + supportUnitIds: [], + }); + assert.equal( + fs.readFileSync(path.join(fixture.outputRoot, "generated", "allow", "promise-withresolvers", "index.d.ts"), "utf8"), + "/// \n", + ); + + const consumerDirectory = path.join(tempDirectory, "promoted-consumer"); + const aliasPath = path.join(fixture.outputRoot, "generated", "allow", "promise-withresolvers", "index.d.ts"); + writeTextFile(path.join(consumerDirectory, "pass.ts"), "Promise.withResolvers();\n"); + writeJsonFile(path.join(consumerDirectory, "tsconfig.pass.json"), { + compilerOptions: { noLib: true, strict: true }, + files: ["pass.ts", aliasPath], + }); + runTsc(["-p", path.join(consumerDirectory, "tsconfig.pass.json")], { cwd: consumerDirectory }); + runTscStrada(["-p", path.join(consumerDirectory, "tsconfig.pass.json")], { cwd: consumerDirectory }); + + writeTextFile(path.join(consumerDirectory, "fail.ts"), "Array.fromAsync([1, 2, 3]);\n"); + writeJsonFile(path.join(consumerDirectory, "tsconfig.fail.json"), { + compilerOptions: { noLib: true, strict: true }, + files: ["fail.ts", aliasPath], + }); + assertCompilerFailuresContain(consumerDirectory, "fail", /fromAsync/); +}); + +test("shared declaration units cannot unlock unregistered or Limited availability behavior", () => { + const tempDirectory = createTempDirectory(tempDirectories); + const allowlistRegistryPath = path.join(tempDirectory, "allowlist.json"); + writeJsonFile(allowlistRegistryPath, { + schemaVersion: 1, + entries: [{ + entryName: "weakmap", + compatKeys: ["javascript.builtins.WeakMap.symbol_as_keys"], + }], + }); + const fixture = createManifest(tempDirectory, { allowlistRegistryPath }); + + const failure = runGenerateExpectFailure(fixture.manifestPath); + assert.match(failure, /cannot safely emit shared unit/); +}); + +test("every compat key in an active entry must emit declaration surface", () => { + const tempDirectory = createTempDirectory(tempDirectories); + const datasetPath = path.join(tempDirectory, "dataset.json"); + const allowlistRegistryPath = path.join(tempDirectory, "allowlist.json"); + const dataset = readJsonFile(repoDatasetPath); + const behavioralCompatKey = "javascript.builtins.AggregateError.serializable_object"; + const behavioralRow = dataset.compatRows.find( + /** @param {{ compatKey: string; }} row */ + row => row.compatKey === behavioralCompatKey, + ); + assert.ok(behavioralRow); + behavioralRow.baselineStatus = "low"; + delete behavioralRow.baselineHighDate; + writeJsonFile(datasetPath, dataset); + writeJsonFile(allowlistRegistryPath, { + schemaVersion: 1, + entries: [{ + entryName: "mixed-entry", + compatKeys: [ + behavioralCompatKey, + "javascript.builtins.Promise.withResolvers", + ], + }], + }); + const fixture = createManifest(tempDirectory, { datasetPath, allowlistRegistryPath }); + + const failure = runGenerateExpectFailure(fixture.manifestPath); + assert.match(failure, /cannot emit .* \(behavioral\)/); +}); + +test("an alias requires declaration-backed surface in the baseline artifact", () => { + const tempDirectory = createTempDirectory(tempDirectories); + const allowlistRegistryPath = path.join(tempDirectory, "allowlist.json"); + writeJsonFile(allowlistRegistryPath, { + schemaVersion: 1, + entries: [{ + entryName: "intl-pluralrules-selectrange", + compatKeys: ["javascript.builtins.Intl.PluralRules.selectRange"], + }], + }); + const fixture = createManifest(tempDirectory, { allowlistRegistryPath }); + + const failure = runGenerateExpectFailure(fixture.manifestPath); + assert.match(failure, /baseline artifact does not emit its declaration surface/); +}); + +test("allowlist registry assigns each compat key to one permanent entry", async () => { + const tempDirectory = createTempDirectory(tempDirectories); + const allowlistRegistryPath = path.join(tempDirectory, "allowlist.json"); + writeJsonFile(allowlistRegistryPath, { + schemaVersion: 1, + entries: [ + { entryName: "first", compatKeys: ["javascript.builtins.Promise.withResolvers"] }, + { entryName: "second", compatKeys: ["javascript.builtins.Promise.withResolvers"] }, + ], + }); + + await assert.rejects( + loadAllowlistRegistry(allowlistRegistryPath), + /Allowlist compat key is assigned to multiple entries/, + ); +}); + +test("release planning preserves published paths and exact compat contracts", () => { + assert.doesNotThrow(() => assertNoRemovedAllowEntries([ + "reports/generation.json", + "allow/_support/deadbeef.d.ts", + ])); + assert.throws( + () => assertNoRemovedAllowEntries(["allow/promise-withresolvers/index.d.ts"]), + /Published allow entry paths cannot be removed/, + ); + + const published = JSON.stringify({ + allowEntries: [{ + entryName: "promise-withresolvers", + compatKeys: ["javascript.builtins.Promise.withResolvers"], + }], + }); + const unchanged = JSON.stringify({ + allowEntries: [{ + kind: "alias", + entryName: "promise-withresolvers", + compatKeys: ["javascript.builtins.Promise.withResolvers"], + }], + }); + assert.doesNotThrow(() => assertAllowEntryContractsPreserved(published, unchanged)); + assert.throws( + () => assertAllowEntryContractsPreserved(published, JSON.stringify({ + allowEntries: [{ + entryName: "promise-withresolvers", + compatKeys: [ + "javascript.builtins.Promise.withResolvers", + "javascript.builtins.RegExp.escape", + ], + }], + })), + /Published allow entry contract changed/, + ); + assert.throws( + () => assertAllowEntryContractsPreserved(published, JSON.stringify({ allowEntries: [] })), + /Published allow entry contract changed/, + ); +}); + +/** + * @param {string} consumerDirectory + * @param {string} name + * @param {string[]} types + */ +function writeConsumerConfig(consumerDirectory, name, types) { + writeJsonFile(path.join(consumerDirectory, `tsconfig.${name}.json`), { + compilerOptions: { + noLib: true, + strict: true, + types, + }, + files: [`${name}.ts`], + }); +} + +/** + * @param {string} consumerDirectory + * @param {string} name + * @param {RegExp} expectedError + */ +function assertCompilerFailuresContain(consumerDirectory, name, expectedError) { + const configPath = path.join(consumerDirectory, `tsconfig.${name}.json`); + for (const failure of [ + runTscExpectFailure(["-p", configPath], { cwd: consumerDirectory }), + runTscStradaExpectFailure(["-p", configPath], { cwd: consumerDirectory }), + ]) { + assert.match(failure.output, expectedError); + } +} + +/** + * @param {string} entryPath + */ +function readSupportReferences(entryPath) { + return [...fs.readFileSync(entryPath, "utf8").matchAll( + /^\/\/\/ $/gm, + )].map(match => match[1]); +} + +/** + * @param {{ directory: string; name: string; source: string; declarationFiles: string[]; }} options + */ +function writeDirectConsumerConfig(options) { + const sourcePath = path.join(options.directory, `${options.name}.ts`); + const configPath = path.join(options.directory, `tsconfig.${options.name}.json`); + writeTextFile(sourcePath, options.source); + writeJsonFile(configPath, { + compilerOptions: { noLib: true, strict: true }, + files: [sourcePath, ...options.declarationFiles], + }); + return configPath; +} + +/** + * @param {string} directory + */ +function readDirectorySnapshot(directory) { + return fs.readdirSync(directory, { recursive: true, withFileTypes: true }) + .filter(entry => entry.isFile()) + .map(entry => path.join(entry.parentPath, entry.name)) + .sort() + .map(filePath => ({ + path: path.relative(directory, filePath), + contents: fs.readFileSync(filePath, "base64"), + })); +} diff --git a/test/helpers.mjs b/test/helpers.mjs index 2a9f5e8..1cd47b1 100644 --- a/test/helpers.mjs +++ b/test/helpers.mjs @@ -19,6 +19,7 @@ export const repoManifestPath = path.join(repoRoot, "manifests", "baseline-js.js export const repoManifest = JSON.parse(fs.readFileSync(repoManifestPath, "utf8")); export const repoDatasetPath = path.join(repoRoot, "datasets", "web-features-js-compat.json"); export const repoRegistryPath = path.join(repoRoot, "registry", "compat-management.json"); +export const repoAllowlistRegistryPath = path.join(repoRoot, "registry", "allowlist.json"); export const repoGeneratedLibPath = path.join(repoRoot, "generated", "current", "baseline.d.ts"); export const repoClassificationPath = path.join(repoRoot, "derived", "current", "classification.json"); @@ -80,7 +81,7 @@ export function readJsonFile(filePath) { /** * @param {string} tempDirectory - * @param {{ registryPath?: string; datasetPath?: string; generatedOutputPath?: string; }} [options] + * @param {{ registryPath?: string; allowlistRegistryPath?: string; datasetPath?: string; generatedOutputPath?: string; }} [options] */ export function createManifest(tempDirectory, options = {}) { const outputRoot = path.join(tempDirectory, "out"); @@ -90,6 +91,10 @@ export function createManifest(tempDirectory, options = {}) { manifest.dataset = toPosixRelativePath(manifestDirectory, options.datasetPath ?? repoDatasetPath); manifest.compatManagementRegistry = toPosixRelativePath(manifestDirectory, options.registryPath ?? repoRegistryPath); + manifest.allowlistRegistry = toPosixRelativePath( + manifestDirectory, + options.allowlistRegistryPath ?? repoAllowlistRegistryPath, + ); manifest.classificationOutput = path.join(outputRoot, "derived", "classification.json"); manifest.compatManagementOutput = path.join(outputRoot, "derived", "compat-management-report.json"); manifest.inventoryOutput = path.join(outputRoot, "derived", "inventory.json"); @@ -97,6 +102,7 @@ export function createManifest(tempDirectory, options = {}) { manifest.firstClassLib = { libName: "baseline", outputFile: path.join(outputRoot, "generated", "baseline.d.ts"), + allowDirectory: path.join(outputRoot, "generated", "allow"), }; if (options.generatedOutputPath) { manifest.firstClassLib.outputFile = toPosixRelativePath(manifestDirectory, options.generatedOutputPath); @@ -236,6 +242,7 @@ export async function stageBaselinePackage(options = {}) { export async function createBaselinePackageTarball(options = {}) { const summary = await stageBaselinePackage(options); const tarballPath = await createPackageTarball(summary.stageDirectory); + options.tempDirectories?.push(path.dirname(tarballPath)); return { ...summary, tarballPath, diff --git a/test/packed-consumer-smoke.test.mjs b/test/packed-consumer-smoke.test.mjs index d6b439e..c41327e 100644 --- a/test/packed-consumer-smoke.test.mjs +++ b/test/packed-consumer-smoke.test.mjs @@ -40,7 +40,7 @@ test("packed consumer smoke: npm-packed baseline package typechecks through comp compilerOptions: { noLib: true, strict: true, - types: [baselinePackageName], + types: [baselinePackageName, `${baselinePackageName}/allow/promise-withresolvers`], }, files: ["consumer-pass.ts"], }); @@ -60,7 +60,9 @@ test("packed consumer smoke: npm-packed baseline package typechecks through comp writeTextFile(path.join(consumerDirectory, "consumer-pass.ts"), [ "const reversed = [1, 2, 3].toReversed();", "const values = Intl.supportedValuesOf(\"currency\");", + "const result = Promise.withResolvers();", "reversed.length + values.length;", + "result.promise;", "", ].join("\n"));