diff --git a/.github/workflows/es-yearly-globals.yml b/.github/workflows/es-yearly-globals.yml index 8cdf329..65d1b8c 100644 --- a/.github/workflows/es-yearly-globals.yml +++ b/.github/workflows/es-yearly-globals.yml @@ -6,6 +6,10 @@ on: # “At 00:00 on day-of-month 1 in July.” https://crontab.guru/#0_0_1_7_* - cron: "0 0 1 7 *" +permissions: + pull-requests: write + contents: write + jobs: update: if: github.event_name != 'schedule' || github.repository == 'sindresorhus/globals' diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index d62f4aa..a596715 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -6,10 +6,55 @@ on: # “At 00:00 on day-of-month 1.” https://crontab.guru/#0_0_1_*_* - cron: "0 0 1 * *" +permissions: + pull-requests: write + contents: write + jobs: - update: + update-on-macos: + if: github.event_name != 'schedule' || github.repository == 'sindresorhus/globals' + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + check-latest: true + node-version: latest + - run: npm install + - run: npm run update + - uses: actions/upload-artifact@v4 + with: + name: data + path: data + if-no-files-found: error + + update-on-windows: + if: github.event_name != 'schedule' || github.repository == 'sindresorhus/globals' + runs-on: windows-latest + needs: [update-on-macos] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + check-latest: true + node-version: latest + - run: npm install + - uses: actions/download-artifact@v4 + with: + name: data + path: data + - run: npm run update + - uses: actions/upload-artifact@v4 + with: + name: data + path: data + if-no-files-found: error + overwrite: true + + update-on-linux: if: github.event_name != 'schedule' || github.repository == 'sindresorhus/globals' runs-on: ubuntu-latest + needs: [update-on-windows] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -17,8 +62,12 @@ jobs: check-latest: true node-version: latest - run: npm install + - uses: actions/download-artifact@v4 + with: + name: data + path: data - run: npm run update - - uses: peter-evans/create-pull-request@v6 + - uses: peter-evans/create-pull-request@v7 with: commit-message: Update globals branch: automated-update diff --git a/data/browser.mjs b/data/browser.mjs index 3c5c031..e725771 100644 --- a/data/browser.mjs +++ b/data/browser.mjs @@ -45,6 +45,7 @@ export default { BackgroundFetchManager: false, BackgroundFetchRecord: false, BackgroundFetchRegistration: false, + BarcodeDetector: false, BarProp: false, BaseAudioContext: false, BatteryManager: false, @@ -132,6 +133,7 @@ export default { CSSKeywordValue: false, CSSLayerBlockRule: false, CSSLayerStatementRule: false, + CSSMarginRule: false, CSSMathClamp: false, CSSMathInvert: false, CSSMathMax: false, @@ -143,6 +145,7 @@ export default { CSSMatrixComponent: false, CSSMediaRule: false, CSSNamespaceRule: false, + CSSNestedDeclarations: false, CSSNumericArray: false, CSSNumericValue: false, CSSPageDescriptors: false, @@ -443,7 +446,6 @@ export default { IntersectionObserver: false, IntersectionObserverEntry: false, isSecureContext: false, - Iterator: false, Keyboard: false, KeyboardEvent: false, KeyboardLayoutMap: false, @@ -648,6 +650,8 @@ export default { onresize: true, onscroll: true, onscrollend: true, + onscrollsnapchange: true, + onscrollsnapchanging: true, onsearch: true, onsecuritypolicyviolation: true, onseeked: true, @@ -839,6 +843,7 @@ export default { showDirectoryPicker: false, showOpenFilePicker: false, showSaveFilePicker: false, + SnapEvent: false, SourceBuffer: false, SourceBufferList: false, speechSynthesis: false, @@ -1094,12 +1099,15 @@ export default { XRDepthInformation: false, XRDOMOverlayState: false, XRFrame: false, + XRHand: false, XRHitTestResult: false, XRHitTestSource: false, XRInputSource: false, XRInputSourceArray: false, XRInputSourceEvent: false, XRInputSourcesChangeEvent: false, + XRJointPose: false, + XRJointSpace: false, XRLayer: false, XRLightEstimate: false, XRLightProbe: false, diff --git a/data/builtin.mjs b/data/builtin.mjs index b499a19..eb95f16 100644 --- a/data/builtin.mjs +++ b/data/builtin.mjs @@ -32,6 +32,7 @@ export default { Intl: false, isFinite: false, isNaN: false, + Iterator: false, JSON: false, Map: false, Math: false, diff --git a/data/es2025.mjs b/data/es2025.mjs index 792b73e..fa55293 100644 --- a/data/es2025.mjs +++ b/data/es2025.mjs @@ -1 +1,6 @@ -export {default} from './es2024.mjs'; +import {mergeGlobals} from '../utilities.mjs'; +import es2024Globals from './es2024.mjs'; + +export default mergeGlobals(es2024Globals, { + Iterator: false, +}); diff --git a/data/es3.mjs b/data/es3.mjs new file mode 100644 index 0000000..4031803 --- /dev/null +++ b/data/es3.mjs @@ -0,0 +1,32 @@ +export default { + Array: false, + Boolean: false, + Date: false, + decodeURI: false, + decodeURIComponent: false, + encodeURI: false, + encodeURIComponent: false, + Error: false, + escape: false, + eval: false, + EvalError: false, + Function: false, + Infinity: false, + isFinite: false, + isNaN: false, + Math: false, + NaN: false, + Number: false, + Object: false, + parseFloat: false, + parseInt: false, + RangeError: false, + ReferenceError: false, + RegExp: false, + String: false, + SyntaxError: false, + TypeError: false, + undefined: false, + unescape: false, + URIError: false, +}; diff --git a/data/es5.mjs b/data/es5.mjs index 8d05b23..a925874 100644 --- a/data/es5.mjs +++ b/data/es5.mjs @@ -1,33 +1,6 @@ -export default { - Array: false, - Boolean: false, - Date: false, - decodeURI: false, - decodeURIComponent: false, - encodeURI: false, - encodeURIComponent: false, - Error: false, - escape: false, - eval: false, - EvalError: false, - Function: false, - Infinity: false, - isFinite: false, - isNaN: false, +import {mergeGlobals} from '../utilities.mjs'; +import es3Globals from './es3.mjs'; + +export default mergeGlobals(es3Globals, { JSON: false, - Math: false, - NaN: false, - Number: false, - Object: false, - parseFloat: false, - parseInt: false, - RangeError: false, - ReferenceError: false, - RegExp: false, - String: false, - SyntaxError: false, - TypeError: false, - undefined: false, - unescape: false, - URIError: false, -}; +}); diff --git a/data/nodeBuiltin.mjs b/data/nodeBuiltin.mjs index 40638ca..c194c98 100644 --- a/data/nodeBuiltin.mjs +++ b/data/nodeBuiltin.mjs @@ -13,6 +13,7 @@ export default { clearImmediate: false, clearInterval: false, clearTimeout: false, + CloseEvent: false, CompressionStream: false, console: false, CountQueuingStrategy: false, @@ -29,7 +30,6 @@ export default { FormData: false, global: false, Headers: false, - Iterator: false, MessageChannel: false, MessageEvent: false, MessagePort: false, diff --git a/data/vitest.mjs b/data/vitest.mjs new file mode 100644 index 0000000..2127d6f --- /dev/null +++ b/data/vitest.mjs @@ -0,0 +1,21 @@ +// This file is autogenerated by scripts +// Do NOT modify this file manually + +export default { + afterAll: false, + afterEach: false, + assert: false, + assertType: false, + beforeAll: false, + beforeEach: false, + describe: false, + expect: false, + expectTypeOf: false, + it: false, + onTestFailed: false, + onTestFinished: false, + suite: false, + test: false, + vi: false, + vitest: false, +}; diff --git a/data/worker.mjs b/data/worker.mjs index 014225f..9faf2f2 100644 --- a/data/worker.mjs +++ b/data/worker.mjs @@ -13,6 +13,7 @@ export default { BackgroundFetchManager: false, BackgroundFetchRecord: false, BackgroundFetchRegistration: false, + BarcodeDetector: false, Blob: false, BroadcastChannel: false, btoa: false, @@ -111,6 +112,10 @@ export default { GPUUncapturedErrorEvent: false, GPUValidationError: false, Headers: false, + HID: false, + HIDConnectionEvent: false, + HIDDevice: false, + HIDInputReportEvent: false, IDBCursor: false, IDBCursorWithValue: false, IDBDatabase: false, @@ -132,7 +137,6 @@ export default { importScripts: false, indexedDB: false, isSecureContext: false, - Iterator: false, location: false, Lock: false, LockManager: false, @@ -192,6 +196,7 @@ export default { Request: false, requestAnimationFrame: false, Response: false, + RTCDataChannel: false, RTCEncodedAudioFrame: false, RTCEncodedVideoFrame: false, scheduler: false, diff --git a/globals.json b/globals.json index 05b9b39..8a0b08c 100644 --- a/globals.json +++ b/globals.json @@ -70,6 +70,7 @@ "BackgroundFetchManager": false, "BackgroundFetchRecord": false, "BackgroundFetchRegistration": false, + "BarcodeDetector": false, "BarProp": false, "BaseAudioContext": false, "BatteryManager": false, @@ -157,6 +158,7 @@ "CSSKeywordValue": false, "CSSLayerBlockRule": false, "CSSLayerStatementRule": false, + "CSSMarginRule": false, "CSSMathClamp": false, "CSSMathInvert": false, "CSSMathMax": false, @@ -168,6 +170,7 @@ "CSSMatrixComponent": false, "CSSMediaRule": false, "CSSNamespaceRule": false, + "CSSNestedDeclarations": false, "CSSNumericArray": false, "CSSNumericValue": false, "CSSPageDescriptors": false, @@ -468,7 +471,6 @@ "IntersectionObserver": false, "IntersectionObserverEntry": false, "isSecureContext": false, - "Iterator": false, "Keyboard": false, "KeyboardEvent": false, "KeyboardLayoutMap": false, @@ -673,6 +675,8 @@ "onresize": true, "onscroll": true, "onscrollend": true, + "onscrollsnapchange": true, + "onscrollsnapchanging": true, "onsearch": true, "onsecuritypolicyviolation": true, "onseeked": true, @@ -864,6 +868,7 @@ "showDirectoryPicker": false, "showOpenFilePicker": false, "showSaveFilePicker": false, + "SnapEvent": false, "SourceBuffer": false, "SourceBufferList": false, "speechSynthesis": false, @@ -1119,12 +1124,15 @@ "XRDepthInformation": false, "XRDOMOverlayState": false, "XRFrame": false, + "XRHand": false, "XRHitTestResult": false, "XRHitTestSource": false, "XRInputSource": false, "XRInputSourceArray": false, "XRInputSourceEvent": false, "XRInputSourcesChangeEvent": false, + "XRJointPose": false, + "XRJointSpace": false, "XRLayer": false, "XRLightEstimate": false, "XRLightProbe": false, @@ -1179,6 +1187,7 @@ "Intl": false, "isFinite": false, "isNaN": false, + "Iterator": false, "JSON": false, "Map": false, "Math": false, @@ -1890,6 +1899,7 @@ "Intl": false, "isFinite": false, "isNaN": false, + "Iterator": false, "JSON": false, "Map": false, "Math": false, @@ -1921,6 +1931,38 @@ "WeakRef": false, "WeakSet": false }, + "es3": { + "Array": false, + "Boolean": false, + "Date": false, + "decodeURI": false, + "decodeURIComponent": false, + "encodeURI": false, + "encodeURIComponent": false, + "Error": false, + "escape": false, + "eval": false, + "EvalError": false, + "Function": false, + "Infinity": false, + "isFinite": false, + "isNaN": false, + "Math": false, + "NaN": false, + "Number": false, + "Object": false, + "parseFloat": false, + "parseInt": false, + "RangeError": false, + "ReferenceError": false, + "RegExp": false, + "String": false, + "SyntaxError": false, + "TypeError": false, + "undefined": false, + "unescape": false, + "URIError": false + }, "es5": { "Array": false, "Boolean": false, @@ -2157,6 +2199,7 @@ "clearImmediate": false, "clearInterval": false, "clearTimeout": false, + "CloseEvent": false, "CompressionStream": false, "console": false, "CountQueuingStrategy": false, @@ -2174,7 +2217,6 @@ "FormData": false, "global": false, "Headers": false, - "Iterator": false, "MessageChannel": false, "MessageEvent": false, "MessagePort": false, @@ -2231,6 +2273,7 @@ "clearImmediate": false, "clearInterval": false, "clearTimeout": false, + "CloseEvent": false, "CompressionStream": false, "console": false, "CountQueuingStrategy": false, @@ -2247,7 +2290,6 @@ "FormData": false, "global": false, "Headers": false, - "Iterator": false, "MessageChannel": false, "MessageEvent": false, "MessagePort": false, @@ -2524,6 +2566,7 @@ "ByteLengthQueuingStrategy": false, "clearInterval": false, "clearTimeout": false, + "CloseEvent": false, "CompressionStream": false, "console": false, "CountQueuingStrategy": false, @@ -2539,7 +2582,6 @@ "File": false, "FormData": false, "Headers": false, - "Iterator": false, "MessageChannel": false, "MessageEvent": false, "MessagePort": false, @@ -2614,6 +2656,24 @@ "uniq": false, "which": false }, + "vitest": { + "afterAll": false, + "afterEach": false, + "assert": false, + "assertType": false, + "beforeAll": false, + "beforeEach": false, + "describe": false, + "expect": false, + "expectTypeOf": false, + "it": false, + "onTestFailed": false, + "onTestFinished": false, + "suite": false, + "test": false, + "vi": false, + "vitest": false + }, "webextensions": { "browser": false, "chrome": false, @@ -2631,6 +2691,7 @@ "BackgroundFetchManager": false, "BackgroundFetchRecord": false, "BackgroundFetchRegistration": false, + "BarcodeDetector": false, "Blob": false, "BroadcastChannel": false, "btoa": false, @@ -2729,6 +2790,10 @@ "GPUUncapturedErrorEvent": false, "GPUValidationError": false, "Headers": false, + "HID": false, + "HIDConnectionEvent": false, + "HIDDevice": false, + "HIDInputReportEvent": false, "IDBCursor": false, "IDBCursorWithValue": false, "IDBDatabase": false, @@ -2750,7 +2815,6 @@ "importScripts": false, "indexedDB": false, "isSecureContext": false, - "Iterator": false, "location": false, "Lock": false, "LockManager": false, @@ -2810,6 +2874,7 @@ "Request": false, "requestAnimationFrame": false, "Response": false, + "RTCDataChannel": false, "RTCEncodedAudioFrame": false, "RTCEncodedVideoFrame": false, "scheduler": false, diff --git a/package.json b/package.json index acea53b..8567d05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "globals", - "version": "15.9.0", + "version": "15.14.0", "description": "Global identifiers from different JavaScript environments", "license": "MIT", "repository": "sindresorhus/globals", @@ -24,6 +24,7 @@ "update:worker": "node scripts/update.mjs --environment=worker", "update:shelljs": "node scripts/update.mjs --environment=shelljs", "update:jest": "node scripts/update.mjs --environment=jest", + "update:vitest": "node scripts/update.mjs --environment=vitest", "build": "run-s build:data build:types", "build:data": "node scripts/generate-data.mjs", "build:types": "node scripts/generate-types.mjs" @@ -44,18 +45,19 @@ "environments" ], "devDependencies": { - "ava": "^6.1.1", + "@vitest/eslint-plugin": "^1.1.18", + "ava": "^6.1.3", "cheerio": "^1.0.0-rc.12", - "eslint-plugin-jest": "^27.9.0", - "execa": "^8.0.1", - "get-port": "^7.0.0", - "npm-run-all2": "^6.1.2", + "eslint-plugin-jest": "^28.8.3", + "execa": "^9.4.0", + "get-port": "^7.1.0", + "npm-run-all2": "^6.2.3", "outdent": "^0.8.0", - "puppeteer": "^22.1.0", + "puppeteer": "^23.4.1", "shelljs": "^0.8.5", - "tsd": "^0.30.4", - "type-fest": "^4.10.2", - "xo": "^0.57.0" + "tsd": "^0.31.2", + "type-fest": "^4.26.1", + "xo": "^0.59.3" }, "xo": { "rules": { @@ -79,6 +81,14 @@ } ] } + }, + { + "files": [ + "scripts/*.mjs" + ], + "rules": { + "n/no-unsupported-features/node-builtins": "off" + } } ] }, diff --git a/puppeteer.config.cjs b/puppeteer.config.cjs index 241323a..891c175 100644 --- a/puppeteer.config.cjs +++ b/puppeteer.config.cjs @@ -3,4 +3,13 @@ // Will download when execute module.exports = { skipDownload: true, + chrome: { + skipDownload: false, + }, + 'chrome-headless-shell': { + skipDownload: false, + }, + firefox: { + skipDownload: false, + }, }; diff --git a/scripts/get-browser-globals.mjs b/scripts/get-browser-globals.mjs index c82f7e6..c23cc85 100644 --- a/scripts/get-browser-globals.mjs +++ b/scripts/get-browser-globals.mjs @@ -76,7 +76,7 @@ const isWritable = name => || name.startsWith('on'); async function downloadBrowser({product} = {}) { - const {downloadBrowser} = await import('puppeteer/internal/node/install.js'); + const {downloadBrowsers} = await import('puppeteer/internal/node/install.js'); const originalEnv = {...process.env}; try { process.env.PUPPETEER_SKIP_DOWNLOAD = JSON.stringify(false); @@ -84,9 +84,12 @@ async function downloadBrowser({product} = {}) { process.env.PUPPETEER_PRODUCT = product; } - await downloadBrowser(); + await downloadBrowsers(); } finally { - for (const env of ['PUPPETEER_SKIP_DOWNLOAD', 'PUPPETEER_PRODUCT']) { + for (const env of [ + 'PUPPETEER_PRODUCT', + 'PUPPETEER_SKIP_DOWNLOAD', + ]) { if (Object.hasOwn(originalEnv)) { process.env[env] = originalEnv[env]; } else { diff --git a/scripts/get-vitest-globals.mjs b/scripts/get-vitest-globals.mjs new file mode 100644 index 0000000..5010d38 --- /dev/null +++ b/scripts/get-vitest-globals.mjs @@ -0,0 +1,6 @@ +import vitest from '@vitest/eslint-plugin'; + +// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/src/index.ts#L269-L285 +export default function getVitestGlobals() { + return Object.fromEntries(Object.keys(vitest.environments.env.globals).map(name => [name, false])); +} diff --git a/scripts/update.mjs b/scripts/update.mjs index 48fda83..3de05fc 100644 --- a/scripts/update.mjs +++ b/scripts/update.mjs @@ -1,4 +1,4 @@ -import util from 'node:util'; +import {parseArgs} from 'node:util'; import {outdent} from 'outdent'; import {execaCommand} from 'execa'; import getBuiltinGlobals from './get-builtin-globals.mjs'; @@ -7,6 +7,7 @@ import {getBrowserGlobals, getWebWorkerGlobals} from './get-browser-globals.mjs' import getShelljsGlobals from './get-shelljs-globals.mjs'; import getJestGlobals from './get-jest-globals.mjs'; import {updateGlobals} from './utilities.mjs'; +import getVitestGlobals from './get-vitest-globals.mjs'; const ALL_JOBS = [ { @@ -36,6 +37,11 @@ const ALL_JOBS = [ getGlobals: getJestGlobals, incremental: false, }, + { + environment: 'vitest', + getGlobals: getVitestGlobals, + incremental: false, + }, ]; async function run(options) { @@ -92,7 +98,7 @@ async function run(options) { const { values: options, -} = util.parseArgs({ +} = parseArgs({ options: { environment: { type: 'string', diff --git a/test.mjs b/test.mjs index 932dac9..8c0c118 100644 --- a/test.mjs +++ b/test.mjs @@ -62,7 +62,10 @@ test('should not contain builtins', t => { test('es versions', t => { const builtins = new Map(Object.entries(globals.builtin)); - const esVersions = ['es5', ...Array.from({length: 2024 - 2015 + 1}, (_, index) => `es${2015 + index}`)]; + const esVersions = Object.keys(globals) + .filter(key => /^es(?:3|5|\d{4})$/.test(key)) + .sort((versionA, versionB) => Number(versionA.slice(2)) - Number(versionB.slice(2))); + let previousVersion; for (const esVersion of esVersions) {