From 29bace4b72d55e8d812e2fd96e6dfcaf7688fd9d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:18:47 +0000 Subject: [PATCH 01/19] Initial plan From 4f5a347feae7de0f91f58fd79b20531e6468b8f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:25:14 +0000 Subject: [PATCH 02/19] Add script to include example URLs in JSDocs for index.d.ts - Created add-examples-to-dts.ts script that runs after build - Script imports index.ts to populate test data - Extracts example URLs using getTests from collector.ts - Adds @example JSDoc comments to each exported function in index.d.ts - Updated build script to run the new script after TypeScript compilation Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- add-examples-to-dts.ts | 48 ++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 add-examples-to-dts.ts diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts new file mode 100644 index 00000000..1f85fcfb --- /dev/null +++ b/add-examples-to-dts.ts @@ -0,0 +1,48 @@ +#!/usr/bin/env tsx +import {readFileSync, writeFileSync} from 'node:fs'; +// Import index.ts first to populate the test data +import './index.ts'; +import {getTests} from './collector.ts'; + +// Read the generated .d.ts file +const dtsPath = './distribution/index.d.ts'; +const dtsContent = readFileSync(dtsPath, 'utf8'); + +// Process each exported function +const lines = dtsContent.split('\n'); +const outputLines: string[] = []; + +for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + + // Check if this is a function declaration + const match = line.match(/^export declare const (\w+):/); + if (match) { + const functionName = match[1]; + + // Get the tests/examples for this function + const examples = getTests(functionName); + + // Only add examples if they exist and aren't just references to other functions + if (examples && examples.length > 0 && examples[0] !== 'combinedTestOnly') { + // Filter to only include actual URLs (not references to other functions) + const urlExamples = examples.filter(url => url.startsWith('http')); + + if (urlExamples.length > 0) { + // Add JSDoc comment with examples before the declaration + outputLines.push('/**'); + for (const url of urlExamples) { + outputLines.push(` * @example ${url}`); + } + outputLines.push(' */'); + } + } + } + + outputLines.push(line); +} + +// Write the modified content back +writeFileSync(dtsPath, outputLines.join('\n'), 'utf8'); + +console.log('✓ Added example URLs to index.d.ts'); diff --git a/package.json b/package.json index ca8e3b20..0a377211 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "distribution/index.d.ts" ], "scripts": { - "build": "run-p build:*", + "build": "run-p build:esbuild build:typescript build:demo && npx tsx add-examples-to-dts.ts", "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST", "build:typescript": "tsc --declaration --emitDeclarationOnly", "build:demo": "vite build demo", From a6156afbe770f23742aad28702ca3d4d00ff63b4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:28:19 +0000 Subject: [PATCH 03/19] Fix linting issues in add-examples-to-dts.ts script Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- add-examples-to-dts.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts index 1f85fcfb..42a0c971 100644 --- a/add-examples-to-dts.ts +++ b/add-examples-to-dts.ts @@ -1,7 +1,9 @@ #!/usr/bin/env tsx import {readFileSync, writeFileSync} from 'node:fs'; -// Import index.ts first to populate the test data +// Import index.ts to populate the test data via side effect +// eslint-disable-next-line import/no-unassigned-import, n/file-extension-in-import import './index.ts'; +// eslint-disable-next-line n/file-extension-in-import import {getTests} from './collector.ts'; // Read the generated .d.ts file @@ -12,33 +14,32 @@ const dtsContent = readFileSync(dtsPath, 'utf8'); const lines = dtsContent.split('\n'); const outputLines: string[] = []; -for (let i = 0; i < lines.length; i++) { - const line = lines[i]; - +for (const line of lines) { // Check if this is a function declaration - const match = line.match(/^export declare const (\w+):/); + const match = /^export declare const (\w+):/.exec(line); if (match) { const functionName = match[1]; - + // Get the tests/examples for this function const examples = getTests(functionName); - + // Only add examples if they exist and aren't just references to other functions if (examples && examples.length > 0 && examples[0] !== 'combinedTestOnly') { // Filter to only include actual URLs (not references to other functions) - const urlExamples = examples.filter(url => url.startsWith('http')); - + const urlExamples = examples.filter((url: string) => url.startsWith('http')); + if (urlExamples.length > 0) { // Add JSDoc comment with examples before the declaration outputLines.push('/**'); for (const url of urlExamples) { outputLines.push(` * @example ${url}`); } + outputLines.push(' */'); } } } - + outputLines.push(line); } From 41cf558aab06fac57c5e9275b625560521f68cd7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:30:18 +0000 Subject: [PATCH 04/19] Address code review feedback: add tsx as devDependency and improve comments Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- add-examples-to-dts.ts | 4 +- package-lock.json | 505 +++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- 3 files changed, 510 insertions(+), 2 deletions(-) diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts index 42a0c971..0090a5ce 100644 --- a/add-examples-to-dts.ts +++ b/add-examples-to-dts.ts @@ -23,9 +23,11 @@ for (const line of lines) { // Get the tests/examples for this function const examples = getTests(functionName); - // Only add examples if they exist and aren't just references to other functions + // Only add examples if they exist and aren't the special 'combinedTestOnly' marker + // 'combinedTestOnly' is used to skip tests for combined functions (e.g., isPageA() || isPageB()) if (examples && examples.length > 0 && examples[0] !== 'combinedTestOnly') { // Filter to only include actual URLs (not references to other functions) + // getTests() recursively expands function references, so we just need to filter the final list const urlExamples = examples.filter((url: string) => url.startsWith('http')); if (urlExamples.length > 0) { diff --git a/package-lock.json b/package-lock.json index 1d85c52c..e0bdfe86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "strip-indent": "^4.0.0", "svelte": "^4.2.18", "svelte-check": "^3.8.5", + "tsx": "^4.21.0", "typescript": "^5.5.4", "vite": "^5.4.2", "vitest": "^2.0.5", @@ -374,6 +375,23 @@ "node": ">=18" } }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.2.tgz", + "integrity": "sha512-Kj6DiBlwXrPsCRDeRvGAUb/LNrBASrfqAIok+xB0LxK8CHqxZ037viF13ugfsIpePH93mX7xfJp97cyDuTZ3cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/netbsd-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", @@ -425,6 +443,23 @@ "node": ">=18" } }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.2.tgz", + "integrity": "sha512-LRBbCmiU51IXfeXk59csuX/aSaToeG7w48nMwA6049Y4J4+VbWALAuXcs+qcD04rHDuSCSRKdmY63sruDS5qag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/sunos-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", @@ -8088,6 +8123,476 @@ "dev": true, "license": "0BSD" }, + "node_modules/tsx": { + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", + "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.27.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/tsx/node_modules/@esbuild/aix-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz", + "integrity": "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.2.tgz", + "integrity": "sha512-DVNI8jlPa7Ujbr1yjU2PfUSRtAUZPG9I1RwW4F4xFB1Imiu2on0ADiI/c3td+KmDtVKNbi+nffGDQMfcIMkwIA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.2.tgz", + "integrity": "sha512-pvz8ZZ7ot/RBphf8fv60ljmaoydPU12VuXHImtAs0XhLLw+EXBi2BLe3OYSBslR4rryHvweW5gmkKFwTiFy6KA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.2.tgz", + "integrity": "sha512-z8Ank4Byh4TJJOh4wpz8g2vDy75zFL0TlZlkUkEwYXuPSgX8yzep596n6mT7905kA9uHZsf/o2OJZubl2l3M7A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.2.tgz", + "integrity": "sha512-davCD2Zc80nzDVRwXTcQP/28fiJbcOwvdolL0sOiOsbwBa72kegmVU0Wrh1MYrbuCL98Omp5dVhQFWRKR2ZAlg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.2.tgz", + "integrity": "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.2.tgz", + "integrity": "sha512-lS/9CN+rgqQ9czogxlMcBMGd+l8Q3Nj1MFQwBZJyoEKI50XGxwuzznYdwcav6lpOGv5BqaZXqvBSiB/kJ5op+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.2.tgz", + "integrity": "sha512-tAfqtNYb4YgPnJlEFu4c212HYjQWSO/w/h/lQaBK7RbwGIkBOuNKQI9tqWzx7Wtp7bTPaGC6MJvWI608P3wXYA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.2.tgz", + "integrity": "sha512-vWfq4GaIMP9AIe4yj1ZUW18RDhx6EPQKjwe7n8BbIecFtCQG4CfHGaHuh7fdfq+y3LIA2vGS/o9ZBGVxIDi9hw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.2.tgz", + "integrity": "sha512-hYxN8pr66NsCCiRFkHUAsxylNOcAQaxSSkHMMjcpx0si13t1LHFphxJZUiGwojB1a/Hd5OiPIqDdXONia6bhTw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.2.tgz", + "integrity": "sha512-MJt5BRRSScPDwG2hLelYhAAKh9imjHK5+NE/tvnRLbIqUWa+0E9N4WNMjmp/kXXPHZGqPLxggwVhz7QP8CTR8w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-loong64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.2.tgz", + "integrity": "sha512-lugyF1atnAT463aO6KPshVCJK5NgRnU4yb3FUumyVz+cGvZbontBgzeGFO1nF+dPueHD367a2ZXe1NtUkAjOtg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-mips64el": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.2.tgz", + "integrity": "sha512-nlP2I6ArEBewvJ2gjrrkESEZkB5mIoaTswuqNFRv/WYd+ATtUpe9Y09RnJvgvdag7he0OWgEZWhviS1OTOKixw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.2.tgz", + "integrity": "sha512-C92gnpey7tUQONqg1n6dKVbx3vphKtTHJaNG2Ok9lGwbZil6DrfyecMsp9CrmXGQJmZ7iiVXvvZH6Ml5hL6XdQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-riscv64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.2.tgz", + "integrity": "sha512-B5BOmojNtUyN8AXlK0QJyvjEZkWwy/FKvakkTDCziX95AowLZKR6aCDhG7LeF7uMCXEJqwa8Bejz5LTPYm8AvA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-s390x": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.2.tgz", + "integrity": "sha512-p4bm9+wsPwup5Z8f4EpfN63qNagQ47Ua2znaqGH6bqLlmJ4bx97Y9JdqxgGZ6Y8xVTixUnEkoKSHcpRlDnNr5w==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.2.tgz", + "integrity": "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/netbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.2.tgz", + "integrity": "sha512-HwGDZ0VLVBY3Y+Nw0JexZy9o/nUAWq9MlV7cahpaXKW6TOzfVno3y3/M8Ga8u8Yr7GldLOov27xiCnqRZf0tCA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.2.tgz", + "integrity": "sha512-DNIHH2BPQ5551A7oSHD0CKbwIA/Ox7+78/AWkbS5QoRzaqlev2uFayfSxq68EkonB+IKjiuxBFoV8ESJy8bOHA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.2.tgz", + "integrity": "sha512-/it7w9Nb7+0KFIzjalNJVR5bOzA9Vay+yIPLVHfIQYG/j+j9VTH84aNB8ExGKPU4AzfaEvN9/V4HV+F+vo8OEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/sunos-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.2.tgz", + "integrity": "sha512-kMtx1yqJHTmqaqHPAzKCAkDaKsffmXkPHThSfRwZGyuqyIeBvf08KSsYXl+abf5HDAPMJIPnbBfXvP2ZC2TfHg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.2.tgz", + "integrity": "sha512-Yaf78O/B3Kkh+nKABUF++bvJv5Ijoy9AN1ww904rOXZFLWVc5OLOfL56W+C8F9xn5JQZa3UX6m+IktJnIb1Jjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.2.tgz", + "integrity": "sha512-Iuws0kxo4yusk7sw70Xa2E2imZU5HoixzxfGCdxwBdhiDgt9vX9VUCBhqcwY7/uh//78A1hMkkROMJq9l27oLQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.2.tgz", + "integrity": "sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/esbuild": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", + "integrity": "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.2", + "@esbuild/android-arm": "0.27.2", + "@esbuild/android-arm64": "0.27.2", + "@esbuild/android-x64": "0.27.2", + "@esbuild/darwin-arm64": "0.27.2", + "@esbuild/darwin-x64": "0.27.2", + "@esbuild/freebsd-arm64": "0.27.2", + "@esbuild/freebsd-x64": "0.27.2", + "@esbuild/linux-arm": "0.27.2", + "@esbuild/linux-arm64": "0.27.2", + "@esbuild/linux-ia32": "0.27.2", + "@esbuild/linux-loong64": "0.27.2", + "@esbuild/linux-mips64el": "0.27.2", + "@esbuild/linux-ppc64": "0.27.2", + "@esbuild/linux-riscv64": "0.27.2", + "@esbuild/linux-s390x": "0.27.2", + "@esbuild/linux-x64": "0.27.2", + "@esbuild/netbsd-arm64": "0.27.2", + "@esbuild/netbsd-x64": "0.27.2", + "@esbuild/openbsd-arm64": "0.27.2", + "@esbuild/openbsd-x64": "0.27.2", + "@esbuild/openharmony-arm64": "0.27.2", + "@esbuild/sunos-x64": "0.27.2", + "@esbuild/win32-arm64": "0.27.2", + "@esbuild/win32-ia32": "0.27.2", + "@esbuild/win32-x64": "0.27.2" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index 0a377211..ff430a36 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "distribution/index.d.ts" ], "scripts": { - "build": "run-p build:esbuild build:typescript build:demo && npx tsx add-examples-to-dts.ts", + "build": "run-p build:esbuild build:typescript build:demo && tsx add-examples-to-dts.ts", "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST", "build:typescript": "tsc --declaration --emitDeclarationOnly", "build:demo": "vite build demo", @@ -69,6 +69,7 @@ "strip-indent": "^4.0.0", "svelte": "^4.2.18", "svelte-check": "^3.8.5", + "tsx": "^4.21.0", "typescript": "^5.5.4", "vite": "^5.4.2", "vitest": "^2.0.5", From 8d749709bfcdb793087de4c1cf32a63eb83a3c14 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:43:35 +0000 Subject: [PATCH 05/19] Use node --import tsx instead of tsx directly, add as postbuild:typescript script - Changed build script to use postbuild:typescript hook instead of appending to main build - Use 'node --import tsx' to run TypeScript files with modern Node.js - Script now runs automatically after TypeScript compilation completes Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- collector.d.ts | 5 ++ index.d.ts | 159 ++++++++++++++++++++++++++++++++++++++++++++++++ index.test.d.ts | 1 + package.json | 3 +- 4 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 collector.d.ts create mode 100644 index.d.ts create mode 100644 index.test.d.ts diff --git a/collector.d.ts b/collector.d.ts new file mode 100644 index 00000000..ebfacbad --- /dev/null +++ b/collector.d.ts @@ -0,0 +1,5 @@ +/** @file This needs to be in a separate file so it can bee tree-shaken before being published, while still being importable by tests */ +export declare const testableUrls: any; +export declare function addTests(test: string, urls: string[]): void; +export declare function getTests(detectName: string): string[]; +export declare function getAllUrls(): Set; diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..d93fb9ee --- /dev/null +++ b/index.d.ts @@ -0,0 +1,159 @@ +export declare const is404: () => boolean; +export declare const is500: () => boolean; +export declare const isPasswordConfirmation: () => boolean; +export declare const isLoggedIn: () => boolean; +export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isOrganizationProfile: () => boolean; +export declare const isOrganizationRepo: () => boolean; +export declare const isTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isOwnUserProfile: () => boolean; +export declare const isOwnOrganizationProfile: () => boolean; +export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isNewDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */ +export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isPRCommit404: () => boolean; +export declare const isPRFile404: () => boolean; +export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isMergedPR: () => boolean; +export declare const isDraftPR: () => boolean; +export declare const isOpenConversation: () => boolean; +export declare const isClosedConversation: () => boolean; +export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isSingleReleaseOrTag: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isEmptyRepoRoot: () => boolean; +export declare const isEmptyRepo: () => boolean; +export declare const isPublicRepo: () => boolean; +export declare const isArchivedRepo: () => boolean; +export declare const isBlank: () => boolean; +export declare const isRepoTaxonomyIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean; +export type RepoExplorerInfo = { + nameWithOwner: string; + branch: string; + filePath: string; +}; +export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepliesSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isUserSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoTree: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoWiki: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea + * @example https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx + */ +export declare const isRepoFile404: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isForkedRepo: () => boolean; +export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isGistProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isUserProfile: () => boolean; +export declare const isPrivateUserProfile: () => boolean; +export declare const isUserProfileMainTab: () => boolean; +export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isProfileRepoList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** Static code, not the code editor */ +export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** Covers blob, trees and blame pages */ +export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** Has a list of files */ +export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isUserTheOrganizationOwner: () => boolean; +export declare const canUserAdminRepo: () => boolean; +/** @deprecated Use `canUserAdminRepo` */ +export declare const canUserEditRepo: () => boolean; +export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean; +export type NameWithOwner = `${string}/${string}`; +export type RepositoryInfo = { + /** The repo owner/user */ + owner: string; + /** The repo name */ + name: string; + /** The 'user/repo' part from an URL */ + nameWithOwner: NameWithOwner; + /** A repo's subpage + @example '/user/repo/issues/' -> 'issues' + @example '/user/repo/' -> '' + @example '/settings/token/' -> undefined */ + path: string; +}; +export declare const utils: { + getOrg: (url?: URL | HTMLAnchorElement | Location) => { + name: string; + path: string; + } | undefined; + /** @deprecated Use `getLoggedInUser` */ + getUsername: () => string | undefined; + getLoggedInUser: () => string | undefined; + getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string; + getCleanGistPathname: (url?: URL | HTMLAnchorElement | Location) => string | undefined; + getRepositoryInfo: (url?: URL | HTMLAnchorElement | Location | string) => RepositoryInfo | undefined; + parseRepoExplorerTitle: (pathname: string, title: string) => RepoExplorerInfo | undefined; +}; diff --git a/index.test.d.ts b/index.test.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/index.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/package.json b/package.json index ff430a36..f425cd66 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,10 @@ "distribution/index.d.ts" ], "scripts": { - "build": "run-p build:esbuild build:typescript build:demo && tsx add-examples-to-dts.ts", + "build": "run-p build:*", "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST", "build:typescript": "tsc --declaration --emitDeclarationOnly", + "postbuild:typescript": "node --import tsx add-examples-to-dts.ts", "build:demo": "vite build demo", "try": "esbuild index.ts --bundle --global-name=x --format=iife | pbcopy && echo 'Copied to clipboard'", "fix": "xo --fix", From 04a039d8837932dc70647a47ef06e293e75f8ad3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:45:22 +0000 Subject: [PATCH 06/19] Remove accidentally committed build artifacts (.d.ts files) Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- collector.d.ts | 5 -- index.d.ts | 159 ------------------------------------------------ index.test.d.ts | 1 - 3 files changed, 165 deletions(-) delete mode 100644 collector.d.ts delete mode 100644 index.d.ts delete mode 100644 index.test.d.ts diff --git a/collector.d.ts b/collector.d.ts deleted file mode 100644 index ebfacbad..00000000 --- a/collector.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** @file This needs to be in a separate file so it can bee tree-shaken before being published, while still being importable by tests */ -export declare const testableUrls: any; -export declare function addTests(test: string, urls: string[]): void; -export declare function getTests(detectName: string): string[]; -export declare function getAllUrls(): Set; diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index d93fb9ee..00000000 --- a/index.d.ts +++ /dev/null @@ -1,159 +0,0 @@ -export declare const is404: () => boolean; -export declare const is500: () => boolean; -export declare const isPasswordConfirmation: () => boolean; -export declare const isLoggedIn: () => boolean; -export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isOrganizationProfile: () => boolean; -export declare const isOrganizationRepo: () => boolean; -export declare const isTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isOwnUserProfile: () => boolean; -export declare const isOwnOrganizationProfile: () => boolean; -export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */ -export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRCommit404: () => boolean; -export declare const isPRFile404: () => boolean; -export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isMergedPR: () => boolean; -export declare const isDraftPR: () => boolean; -export declare const isOpenConversation: () => boolean; -export declare const isClosedConversation: () => boolean; -export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isSingleReleaseOrTag: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEmptyRepoRoot: () => boolean; -export declare const isEmptyRepo: () => boolean; -export declare const isPublicRepo: () => boolean; -export declare const isArchivedRepo: () => boolean; -export declare const isBlank: () => boolean; -export declare const isRepoTaxonomyIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean; -export type RepoExplorerInfo = { - nameWithOwner: string; - branch: string; - filePath: string; -}; -export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepliesSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoTree: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoWiki: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea - * @example https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx - */ -export declare const isRepoFile404: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isForkedRepo: () => boolean; -export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGistProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserProfile: () => boolean; -export declare const isPrivateUserProfile: () => boolean; -export declare const isUserProfileMainTab: () => boolean; -export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isProfileRepoList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Static code, not the code editor */ -export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Covers blob, trees and blame pages */ -export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Has a list of files */ -export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserTheOrganizationOwner: () => boolean; -export declare const canUserAdminRepo: () => boolean; -/** @deprecated Use `canUserAdminRepo` */ -export declare const canUserEditRepo: () => boolean; -export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean; -export type NameWithOwner = `${string}/${string}`; -export type RepositoryInfo = { - /** The repo owner/user */ - owner: string; - /** The repo name */ - name: string; - /** The 'user/repo' part from an URL */ - nameWithOwner: NameWithOwner; - /** A repo's subpage - @example '/user/repo/issues/' -> 'issues' - @example '/user/repo/' -> '' - @example '/settings/token/' -> undefined */ - path: string; -}; -export declare const utils: { - getOrg: (url?: URL | HTMLAnchorElement | Location) => { - name: string; - path: string; - } | undefined; - /** @deprecated Use `getLoggedInUser` */ - getUsername: () => string | undefined; - getLoggedInUser: () => string | undefined; - getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string; - getCleanGistPathname: (url?: URL | HTMLAnchorElement | Location) => string | undefined; - getRepositoryInfo: (url?: URL | HTMLAnchorElement | Location | string) => RepositoryInfo | undefined; - parseRepoExplorerTitle: (pathname: string, title: string) => RepoExplorerInfo | undefined; -}; diff --git a/index.test.d.ts b/index.test.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/index.test.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; From 6bc42f0af1ffc12bafbf79a778d52fd4386f2d37 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 11 Jan 2026 11:13:39 +0000 Subject: [PATCH 07/19] Remove tsx, use Node's native TypeScript execution, commit distribution files - Removed tsx dependency from devDependencies - Changed postbuild:typescript to use node --experimental-strip-types (requires Node 22.18+) - Removed distribution folder from .gitignore - Added distribution folder with generated files to version control Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- .gitignore | 1 - add-examples-to-dts.ts | 2 +- distribution/collector.d.ts | 5 + distribution/index.d.ts | 629 +++++++++++++++++++++++++++++++++++ distribution/index.js | 354 ++++++++++++++++++++ distribution/index.test.d.ts | 1 + package-lock.json | 505 ---------------------------- package.json | 3 +- 8 files changed, 991 insertions(+), 509 deletions(-) create mode 100644 distribution/collector.d.ts create mode 100644 distribution/index.d.ts create mode 100644 distribution/index.js create mode 100644 distribution/index.test.d.ts diff --git a/.gitignore b/.gitignore index 46cb338c..03721dd4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ Thumbs.db *.log logs *.map -distribution dist .cache .parcel-cache diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts index 0090a5ce..23901826 100644 --- a/add-examples-to-dts.ts +++ b/add-examples-to-dts.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env tsx +#!/usr/bin/env node --experimental-strip-types import {readFileSync, writeFileSync} from 'node:fs'; // Import index.ts to populate the test data via side effect // eslint-disable-next-line import/no-unassigned-import, n/file-extension-in-import diff --git a/distribution/collector.d.ts b/distribution/collector.d.ts new file mode 100644 index 00000000..86aafcc7 --- /dev/null +++ b/distribution/collector.d.ts @@ -0,0 +1,5 @@ +/** @file This needs to be in a separate file so it can bee tree-shaken before being published, while still being importable by tests */ +export declare const testableUrls: Map; +export declare function addTests(test: string, urls: string[]): void; +export declare function getTests(detectName: string): string[]; +export declare function getAllUrls(): Set; diff --git a/distribution/index.d.ts b/distribution/index.d.ts new file mode 100644 index 00000000..f50f0461 --- /dev/null +++ b/distribution/index.d.ts @@ -0,0 +1,629 @@ +export declare const is404: () => boolean; +export declare const is500: () => boolean; +export declare const isPasswordConfirmation: () => boolean; +export declare const isLoggedIn: () => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/blame/master/package.json + */ +export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/commit/5b614b9035f2035b839f48b4db7bd5c3298d526f + * @example https://github.com/sindresorhus/refined-github/commit/5b614 + * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 + * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d79 + * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 + * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d79 + */ +export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/commits/master?page=2 + * @example https://github.com/sindresorhus/refined-github/commits/test-branch + * @example https://github.com/sindresorhus/refined-github/commits/0.13.0 + * @example https://github.com/sindresorhus/refined-github/commits/230c2 + * @example https://github.com/sindresorhus/refined-github/commits/230c2935fc5aea9a681174ddbeba6255ca040d63 + * @example https://github.com/sindresorhus/refined-github/commits?author=fregante + * @example https://github.com/sindresorhus/runs/commits/ + */ +export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/compare + * @example https://github.com/sindresorhus/refined-github/compare/ + * @example https://github.com/sindresorhus/refined-github/compare/master...branch-name + * @example https://github.com/sindresorhus/refined-github/compare/master...branch-name?quick_pull=1 + * @example https://github.com/sindresorhus/refined-github/compare/branch-1...branch-2?quick_pull=1 + * @example https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1 + */ +export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/brookhong/Surfingkeys/wiki/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d + * @example https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d + */ +export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/// + * @example https://github.com// + * @example https://github.com/ + * @example https://github.com + * @example https://github.com/orgs/test/dashboard + * @example https://github.com/dashboard/index/2 + * @example https://github.com//dashboard + * @example https://github.com/dashboard + * @example https://github.com/orgs/edit/dashboard + * @example https://github.big-corp.com/ + * @example https://not-github.com/ + * @example https://my-little-hub.com/ + * @example https://github.com/?tab=repositories + * @example https://github.com/?tab=stars + * @example https://github.com/?tab=followers + * @example https://github.com/?tab=following + * @example https://github.com/?tab=overview + * @example https://github.com?search=1 + * @example https://github.com/dashboard-feed + */ +export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.big-corp.com/ + * @example https://not-github.com/ + * @example https://my-little-hub.com/ + * @example https://my-little-hub.com/gist + * @example https://my-little-hub.com/gist/in-fragrante + * @example https://gist.my-little-hub.com/in-fragrante + */ +export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://gist.github.com + * @example http://gist.github.com + * @example https://gist.github.com/new + * @example https://gist.github.com/fregante/2205329b71218fa2c1d3 + * @example https://gist.github.com/fregante/2205329b71218fa2c1d3/d1ebf7d9cfaba4d4596d2ea9174e202479a5f9ad + * @example https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064 + * @example https://my-little-hub.com/gist + * @example https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions + * @example https://gist.github.com/fregante + * @example https://gist.github.com/github + * @example https://gist.github.com/babel + * @example https://my-little-hub.com/gist/in-fragrante + * @example https://gist.my-little-hub.com/in-fragrante + */ +export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/issues + * @example https://github.com/issues?q=is%3Apr+is%3Aopen + * @example https://github.com/issues/assigned + * @example https://github.com/issues/mentioned + * @example https://github.com/pulls + * @example https://github.com/pulls?q=issues + * @example https://github.com/pulls/assigned + * @example https://github.com/pulls/mentioned + * @example https://github.com/pulls/review-requested + */ +export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/search?q=refined-github&ref=opensearch + */ +export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/issues/146 + */ +export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/labels + * @example https://github.com/sindresorhus/refined-github/labels/ + */ +export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/kubernetes/kubernetes/milestone/56 + */ +export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/milestones + */ +export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/new/main + */ +export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/issues/new + */ +export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/releases/new + */ +export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/tooomm/wikitest/wiki/_new + */ +export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/notifications + */ +export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isOrganizationProfile: () => boolean; +export declare const isOrganizationRepo: () => boolean; +/** + * @example https://github.com/orgs/refined-github/teams/core-team/discussions?pinned=1 + * @example https://github.com/orgs/refined-github/teams/core-team/discussions/1 + * @example https://github.com/orgs/refined-github/teams/core-team + */ +export declare const isTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isOwnUserProfile: () => boolean; +export declare const isOwnOrganizationProfile: () => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/projects/3 + * @example https://github.com/orgs/RSSNext/projects/3 + */ +export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/projects + */ +export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/tophf/mpiv/discussions/50 + * @example https://github.com/orgs/community/discussions/11202 + */ +export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/withastro/roadmap/discussions/new?category=proposal + * @example https://github.com/orgs/community/discussions/new?category=pull-requests + */ +export declare const isNewDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/tophf/mpiv/discussions + * @example https://github.com/orgs/community/discussions + */ +export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 + * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d79 + * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 + * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d79 + * @example https://github.com/sindresorhus/refined-github/pull/148/files + * @example https://github.com/sindresorhus/refined-github/pull/148/files/e1aba6f + * @example https://github.com/sindresorhus/refined-github/pull/148/files/1e27d799..e1aba6f + * @example https://github.com/refined-github/refined-github/pull/148/changes + * @example https://github.com/refined-github/refined-github/pull/148/changes/1e27d799..e1aba6f + * @example https://github.com/refined-github/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641..e1aba6febb3fe38aafd1137cff28b536eeeabe7e + * @example https://github.com/sindresorhus/refined-github/pull/148/commits + * @example https://github.com/sindresorhus/refined-github/pull/148 + */ +export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/pull/148/conflicts + */ +export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */ +/** + * @example https://github.com/pulls + * @example https://github.com/pulls?q=issues + * @example https://github.com/sindresorhus/refined-github/pulls + * @example https://github.com/sindresorhus/refined-github/pulls/ + * @example https://github.com/sindresorhus/refined-github/pulls?q=is%3Aopen+is%3Apr + * @example https://github.com/sindresorhus/refined-github/pulls?q=is%3Apr+is%3Aclosed + */ +export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 + * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d79 + * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 + * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d79 + */ +export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isPRCommit404: () => boolean; +export declare const isPRFile404: () => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/pull/148 + */ +export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/pull/148/commits + */ +export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 + * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d79 + * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 + * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d79 + * @example https://github.com/sindresorhus/refined-github/pull/148/files + * @example https://github.com/sindresorhus/refined-github/pull/148/files/e1aba6f + * @example https://github.com/sindresorhus/refined-github/pull/148/files/1e27d799..e1aba6f + * @example https://github.com/refined-github/refined-github/pull/148/changes + * @example https://github.com/refined-github/refined-github/pull/148/changes/1e27d799..e1aba6f + * @example https://github.com/refined-github/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641..e1aba6febb3fe38aafd1137cff28b536eeeabe7e + */ +export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/compare/master...branch-name?quick_pull=1 + * @example https://github.com/sindresorhus/refined-github/compare/branch-1...branch-2?quick_pull=1 + * @example https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1 + */ +export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isMergedPR: () => boolean; +export declare const isDraftPR: () => boolean; +export declare const isOpenConversation: () => boolean; +export declare const isClosedConversation: () => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/releases + * @example https://github.com/sindresorhus/refined-github/releases?page=2 + */ +export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/tags + * @example https://github.com/sindresorhus/refined-github/tags?after=21.8.1 + */ +export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/refined-github/refined-github/releases/tag/1.20.1 + * @example https://github.com/refined-github/refined-github/releases/tag/23.7.25 + */ +export declare const isSingleReleaseOrTag: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/releases + * @example https://github.com/sindresorhus/refined-github/releases?page=2 + * @example https://github.com/sindresorhus/refined-github/tags + * @example https://github.com/sindresorhus/refined-github/tags?after=21.8.1 + */ +export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/delete/master/readme.md + * @example https://github.com/sindresorhus/refined-github/delete/ghe-injection/source/background.ts + */ +export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/edit/master/readme.md + * @example https://github.com/sindresorhus/refined-github/edit/ghe-injection/source/background.ts + */ +export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/releases/edit/v1.2.3 + */ +export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/tooomm/wikitest/wiki/Getting-Started/_edit + */ +export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/blame/master/package.json + * @example https://github.com/sindresorhus/refined-github/issues/146 + * @example https://github.com/sindresorhus/notifications/ + * @example https://github.com/sindresorhus/refined-github/pull/148 + * @example https://github.com/sindresorhus/refined-github/milestones/new + * @example https://github.com/sindresorhus/refined-github/milestones/1/edit + * @example https://github.com/sindresorhus/refined-github/issues/new/choose + * @example https://github.com/sindresorhus/refined-github/issues/templates/edit + */ +export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isEmptyRepoRoot: () => boolean; +export declare const isEmptyRepo: () => boolean; +export declare const isPublicRepo: () => boolean; +export declare const isArchivedRepo: () => boolean; +export declare const isBlank: () => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/labels/bug + * @example https://github.com/sindresorhus/refined-github/labels/implemented%20by%20github + * @example https://github.com/sindresorhus/refined-github/labels/%3Adollar%3A%20Funded%20on%20Issuehunt + * @example https://github.com/sindresorhus/refined-github/milestones/1 + */ +export declare const isRepoTaxonomyIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isRepoIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/pulls + * @example https://github.com/sindresorhus/refined-github/pulls/ + * @example https://github.com/sindresorhus/refined-github/pulls?q=is%3Aopen+is%3Apr + * @example https://github.com/sindresorhus/refined-github/pulls?q=is%3Apr+is%3Aclosed + */ +export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example http://github.com/sindresorhus/ava/issues + * @example https://github.com/sindresorhus/refined-github/issues + * @example https://github.com/sindresorhus/refined-github/issues/fregante + * @example https://github.com/sindresorhus/refined-github/issues/newton + * @example https://github.com/sindresorhus/refined-github/issues/wptemplates + * @example https://github.com/sindresorhus/refined-github/issues?q=is%3Aclosed+sort%3Aupdated-desc + * @example https://github.com/sindresorhus/refined-github/labels/bug + * @example https://github.com/sindresorhus/refined-github/labels/implemented%20by%20github + * @example https://github.com/sindresorhus/refined-github/labels/%3Adollar%3A%20Funded%20on%20Issuehunt + */ +export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github + * @example https://github.com/sindresorhus/refined-github/ + * @example https://github.com/sindresorhus/notifications/ + * @example https://github.com/sindresorhus/edit + * @example https://github.com/sindresorhus///edit + * @example https://github.com/sindresorhus/search + * @example https://github.com/sindresorhus/branches + * @example https://github.com/sindresorhus/refined-github?files=1 + */ +export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean; +export type RepoExplorerInfo = { + nameWithOwner: string; + branch: string; + filePath: string; +}; +/** + * @example https://github.com/sindresorhus/refined-github + * @example https://github.com/sindresorhus/refined-github/ + * @example https://github.com/sindresorhus/notifications/ + * @example https://github.com/sindresorhus/edit + * @example https://github.com/sindresorhus///edit + * @example https://github.com/sindresorhus/search + * @example https://github.com/sindresorhus/branches + * @example https://github.com/sindresorhus/refined-github?files=1 + * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons + * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/ + * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6 + * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6/ + * @example https://github.com/sindresorhus/refined-github/tree/57bf4 + * @example https://github.com/sindresorhus/refined-github/tree/master?files=1 + */ +export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/search?q=diff + * @example https://github.com/sindresorhus/refined-github/search?q=diff&unscoped_q=diff&type=Issues + * @example https://github.com/sindresorhus/refined-github/search + */ +export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/settings + * @example https://github.com/sindresorhus/refined-github/settings/branches + */ +export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/settings + */ +export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/settings/replies + * @example https://github.com/settings/replies/88491/edit + */ +export declare const isRepliesSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/settings/profile + * @example https://github.com/settings/replies + * @example https://github.com/settings/replies/88491/edit + */ +export declare const isUserSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github + * @example https://github.com/sindresorhus/refined-github/ + * @example https://github.com/sindresorhus/notifications/ + * @example https://github.com/sindresorhus/edit + * @example https://github.com/sindresorhus///edit + * @example https://github.com/sindresorhus/search + * @example https://github.com/sindresorhus/branches + * @example https://github.com/sindresorhus/refined-github?files=1 + * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons + * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/ + * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6 + * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6/ + * @example https://github.com/sindresorhus/refined-github/tree/57bf4 + * @example https://github.com/sindresorhus/refined-github/tree/master?files=1 + * @example https://github.com/sindresorhus/refined-github/tree/main/source + * @example https://github.com/sindresorhus/refined-github/tree/0.13.0/extension + * @example https://github.com/sindresorhus/refined-github/tree/57bf435ee12d14b482df0bbd88013a2814c7512e/extension + * @example https://github.com/sindresorhus/refined-github?search=1 + */ +export declare const isRepoTree: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/lukesampson/scoop/wiki + * @example https://github.com/tooomm/wikitest/wiki/_new + * @example https://github.com/tooomm/wikitest/wiki/Getting-Started/_edit + * @example https://github.com/brookhong/Surfingkeys/wiki/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d + * @example https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d + */ +export declare const isRepoWiki: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/commit/5b614b9035f2035b839f48b4db7bd5c3298d526f + * @example https://github.com/sindresorhus/refined-github/commit/5b614 + */ +export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes + * @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css + * @example https://github.com/sindresorhus/refined-github/blob/master/edit.txt + */ +export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/find/master + */ +export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea + * @example https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx + */ +export declare const isRepoFile404: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/network/members + */ +export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/network + */ +export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isForkedRepo: () => boolean; +/** + * @example https://github.com/refined-github/refined-github/fork + */ +export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://gist.github.com/fregante/2205329b71218fa2c1d3 + * @example https://gist.github.com/fregante/2205329b71218fa2c1d3/d1ebf7d9cfaba4d4596d2ea9174e202479a5f9ad + * @example https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064 + */ +export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions + */ +export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/trending + * @example https://github.com/trending/developers + * @example https://github.com/trending/unknown + */ +export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/branches + */ +export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/fregante + * @example https://github.com/github + * @example https://github.com/babel + * @example https://github.com/fregante?tab=repositories + * @example https://github.com/fregante?tab=repositories&type=source + * @example https://github.com/fregante?tab=repositories&q=&type=source&language=css&sort= + * @example https://github.com/fregante?tab=stars + * @example https://github.com/fregante?direction=desc&sort=updated&tab=stars + * @example https://github.com/fregante?tab=followers + * @example https://github.com/sindresorhus?tab=followers + * @example https://github.com/fregante?tab=following + * @example https://github.com/sindresorhus?tab=following + */ +export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://gist.github.com/fregante + * @example https://gist.github.com/github + * @example https://gist.github.com/babel + * @example https://my-little-hub.com/gist/in-fragrante + * @example https://gist.my-little-hub.com/in-fragrante + */ +export declare const isGistProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isUserProfile: () => boolean; +export declare const isPrivateUserProfile: () => boolean; +export declare const isUserProfileMainTab: () => boolean; +/** + * @example https://github.com/fregante?tab=repositories + * @example https://github.com/fregante?tab=repositories&type=source + * @example https://github.com/fregante?tab=repositories&q=&type=source&language=css&sort= + */ +export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/fregante?tab=stars + * @example https://github.com/fregante?direction=desc&sort=updated&tab=stars + */ +export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/fregante?tab=followers + * @example https://github.com/sindresorhus?tab=followers + */ +export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/fregante?tab=following + * @example https://github.com/sindresorhus?tab=following + */ +export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/fregante?tab=repositories + * @example https://github.com/fregante?tab=repositories&type=source + * @example https://github.com/fregante?tab=repositories&q=&type=source&language=css&sort= + * @example https://github.com/orgs/refined-github/repositories + * @example https://github.com/orgs/refined-github/repositories?q=&type=private&language=&sort= + */ +export declare const isProfileRepoList: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** Static code, not the code editor */ +export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** Covers blob, trees and blame pages */ +/** + * @example https://github.com/sindresorhus/refined-github + * @example https://github.com/sindresorhus/refined-github/ + * @example https://github.com/sindresorhus/notifications/ + * @example https://github.com/sindresorhus/edit + * @example https://github.com/sindresorhus///edit + * @example https://github.com/sindresorhus/search + * @example https://github.com/sindresorhus/branches + * @example https://github.com/sindresorhus/refined-github?files=1 + * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons + * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/ + * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6 + * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6/ + * @example https://github.com/sindresorhus/refined-github/tree/57bf4 + * @example https://github.com/sindresorhus/refined-github/tree/master?files=1 + * @example https://github.com/sindresorhus/refined-github/tree/main/source + * @example https://github.com/sindresorhus/refined-github/tree/0.13.0/extension + * @example https://github.com/sindresorhus/refined-github/tree/57bf435ee12d14b482df0bbd88013a2814c7512e/extension + * @example https://github.com/sindresorhus/refined-github?search=1 + * @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes + * @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css + * @example https://github.com/sindresorhus/refined-github/blob/master/edit.txt + * @example https://github.com/sindresorhus/refined-github/blame/master/package.json + */ +export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** Has a list of files */ +export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/marketplace/actions/urlchecker-action + * @example https://github.com/marketplace/actions/github-action-for-assignee-to-reviewer + * @example https://github.com/marketplace/actions/hugo-actions + */ +export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/runs/639481849 + * @example https://github.com/refined-github/github-url-detection/runs/1224552520?check_suite_focus=true + */ +export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/runs/639481849 + * @example https://github.com/refined-github/github-url-detection/runs/1224552520?check_suite_focus=true + * @example https://github.com/refined-github/github-url-detection/actions/runs/294962314 + */ +export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/sindresorhus/refined-github/actions/new + */ +export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/refined-github/github-url-detection/actions + * @example https://github.com/refined-github/github-url-detection/actions/workflows/demo.yml + * @example https://github.com/refined-github/github-url-detection/actions/workflows/esm-lint.yml + */ +export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean; +export declare const isUserTheOrganizationOwner: () => boolean; +export declare const canUserAdminRepo: () => boolean; +/** @deprecated Use `canUserAdminRepo` */ +export declare const canUserEditRepo: () => boolean; +/** + * @example https://github.com/new + * @example https://github.com/organizations/npmhub/repositories/new + */ +export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; +/** + * @example https://github.com/fregante/browser-extension-template/generate + */ +export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean; +export type NameWithOwner = `${string}/${string}`; +export type RepositoryInfo = { + /** The repo owner/user */ + owner: string; + /** The repo name */ + name: string; + /** The 'user/repo' part from an URL */ + nameWithOwner: NameWithOwner; + /** A repo's subpage + @example '/user/repo/issues/' -> 'issues' + @example '/user/repo/' -> '' + @example '/settings/token/' -> undefined */ + path: string; +}; +export declare const utils: { + getOrg: (url?: URL | HTMLAnchorElement | Location) => { + name: string; + path: string; + } | undefined; + /** @deprecated Use `getLoggedInUser` */ + getUsername: () => string | undefined; + getLoggedInUser: () => string | undefined; + getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string; + getCleanGistPathname: (url?: URL | HTMLAnchorElement | Location) => string | undefined; + getRepositoryInfo: (url?: URL | HTMLAnchorElement | Location | string) => RepositoryInfo | undefined; + parseRepoExplorerTitle: (pathname: string, title: string) => RepoExplorerInfo | undefined; +}; diff --git a/distribution/index.js b/distribution/index.js new file mode 100644 index 00000000..97df5827 --- /dev/null +++ b/distribution/index.js @@ -0,0 +1,354 @@ +// index.ts +import reservedNames from "github-reserved-names/reserved-names.json" with { type: "json" }; +var $ = (selector) => document.querySelector(selector); +var exists = (selector) => Boolean($(selector)); +var is404 = () => /^(Page|File) not found · GitHub/.test(document.title); +var is500 = () => document.title === "Server Error \xB7 GitHub" || document.title === "Unicorn! \xB7 GitHub" || document.title === "504 Gateway Time-out"; +var isPasswordConfirmation = () => document.title === "Confirm password" || document.title === "Confirm access"; +var isLoggedIn = () => exists("body.logged-in"); +var isBlame = (url = location) => Boolean(getRepo(url)?.path.startsWith("blame/")); +var isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url); +var isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url); +var isRepoCommitList = (url = location) => Boolean(getRepo(url)?.path.startsWith("commits")); +var isCompare = (url = location) => Boolean(getRepo(url)?.path.startsWith("compare")); +var isCompareWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).split("/").slice(3, 5).includes("_compare"); +var isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url)); +var isEnterprise = (url = location) => url.hostname !== "github.com" && url.hostname !== "gist.github.com"; +var isGist = (url = location) => typeof getCleanGistPathname(url) === "string"; +var isGlobalIssueOrPRList = (url = location) => ["issues", "pulls"].includes(url.pathname.split("/", 2)[1]); +var isGlobalSearchResults = (url = location) => url.pathname === "/search" && new URLSearchParams(url.search).get("q") !== null; +var isIssue = (url = location) => /^issues\/\d+/.test(getRepo(url)?.path) && document.title !== "GitHub \xB7 Where software is built"; +var isIssueOrPRList = (url = location) => isGlobalIssueOrPRList(url) || isRepoIssueOrPRList(url) || isMilestone(url); +var isConversation = (url = location) => isIssue(url) || isPRConversation(url); +var isLabelList = (url = location) => getRepo(url)?.path === "labels"; +var isMilestone = (url = location) => /^milestone\/\d+/.test(getRepo(url)?.path); +var isMilestoneList = (url = location) => getRepo(url)?.path === "milestones"; +var isNewFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("new")); +var isNewIssue = (url = location) => getRepo(url)?.path === "issues/new"; +var isNewRelease = (url = location) => getRepo(url)?.path === "releases/new"; +var isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_new"); +var isNotifications = (url = location) => getCleanPathname(url) === "notifications"; +var isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]'); +var isOrganizationRepo = () => exists('.AppHeader-context-full [data-hovercard-type="organization"]'); +var isTeamDiscussion = (url = location) => Boolean(getOrg(url)?.path.startsWith("teams")); +var isOwnUserProfile = () => getCleanPathname() === getLoggedInUser(); +var isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]'); +var isProject = (url = location) => /^projects\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path); +var isProjects = (url = location) => getRepo(url)?.path === "projects"; +var isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path); +var isNewDiscussion = (url = location) => getRepo(url)?.path === "discussions/new" || getOrg(url)?.path === "discussions/new"; +var isDiscussionList = (url = location) => getRepo(url)?.path === "discussions" || getOrg(url)?.path === "discussions"; +var isPR = (url = location) => /^pull\/\d+/.test(getRepo(url)?.path) && !isPRConflicts(url); +var isPRConflicts = (url = location) => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path); +var isPRList = (url = location) => url.pathname === "/pulls" || getRepo(url)?.path === "pulls"; +var isPRCommit = (url = location) => /^pull\/\d+\/(commits|changes)\/[\da-f]{7,40}$/.test(getRepo(url)?.path); +var isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found \xB7 Pull Request"); +var isPRFile404 = () => isPRFiles() && document.title.startsWith("Commit range not found \xB7 Pull Request"); +var isPRConversation = (url = location) => /^pull\/\d+$/.test(getRepo(url)?.path); +var isPRCommitList = (url = location) => /^pull\/\d+\/commits$/.test(getRepo(url)?.path); +var isPRFiles = (url = location) => /^pull\/\d+\/(files|(changes(\/[\da-f]{7,40}..[\da-f]{7,40})?$))/.test(getRepo(url)?.path) || isPRCommit(url); +var isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search); +var getStateLabel = () => $([ + ".State", + // Old view + '[class^="StateLabel"]' + // React version +].join(","))?.textContent?.trim(); +var isMergedPR = () => getStateLabel() === "Merged"; +var isDraftPR = () => getStateLabel() === "Draft"; +var isOpenConversation = () => { + const status = getStateLabel(); + return status === "Open" || status === "Draft"; +}; +var isClosedConversation = () => { + const status = getStateLabel(); + return status === "Closed" || status === "Closed as not planned" || status === "Merged"; +}; +var isReleases = (url = location) => getRepo(url)?.path === "releases"; +var isTags = (url = location) => getRepo(url)?.path === "tags"; +var isSingleReleaseOrTag = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/tag")); +var isReleasesOrTags = (url = location) => isReleases(url) || isTags(url); +var isDeletingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("delete")); +var isEditingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("edit")); +var hasFileEditor = (url = location) => isEditingFile(url) || isNewFile(url) || isDeletingFile(url); +var isEditingRelease = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/edit")); +var hasReleaseEditor = (url = location) => isEditingRelease(url) || isNewRelease(url); +var isEditingWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_edit"); +var hasWikiPageEditor = (url = location) => isEditingWikiPage(url) || isNewWikiPage(url); +var isRepo = (url = location) => { + const [user, repo, extra] = getCleanPathname(url).split("/"); + return Boolean( + user && repo && !reservedNames.includes(user) && !url.hostname.startsWith("gist.") && extra !== "generate" + // Like isNewRepoTemplate but inlined for performance + ); +}; +var hasRepoHeader = (url = location) => isRepo(url) && !isRepoSearch(url); +var isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]'); +var isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]'); +var isPublicRepo = () => exists('meta[name="octolytics-dimension-repository_public"][content="true"]'); +var isArchivedRepo = () => Boolean(isRepo() && $("main > .flash-warn")?.textContent.includes("archived")); +var isBlank = () => exists("main .blankslate:not([hidden] .blankslate)"); +var isRepoTaxonomyIssueOrPRList = (url = location) => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path); +var isRepoIssueOrPRList = (url = location) => isRepoPRList(url) || isRepoIssueList(url) || isRepoTaxonomyIssueOrPRList(url); +var isRepoPRList = (url = location) => Boolean(getRepo(url)?.path.startsWith("pulls")); +var isRepoIssueList = (url = location) => ( + // `issues/fregante` is a list but `issues/1`, `issues/new`, `issues/new/choose`, `issues/templates/edit` aren’t + /^labels\/|^issues(?!\/(\d+|new|templates)($|\/))/.test(getRepo(url)?.path) +); +var hasSearchParameter = (url) => new URLSearchParams(url.search).get("search") === "1"; +var isRepoHome = (url = location) => getRepo(url)?.path === "" && !hasSearchParameter(url); +var titleParseRegex = /^(?:(?[^ ]+) at (?[^ ]+)|[^/ ]+(?:\/(?[^ ]*))? at (?[^ ]+)(?: · (?[^ ]+))?)$/; +var parseRepoExplorerTitle = (pathname, title) => { + const match = titleParseRegex.exec(title); + if (!match?.groups) { + return; + } + let { nameWithOwner, branch, filePath, nameWithOwner2, branch2 } = match.groups; + nameWithOwner ??= nameWithOwner2; + branch ??= branch2; + filePath ??= ""; + if (!nameWithOwner || !branch || !pathname.startsWith(`/${nameWithOwner}/tree/`)) { + return; + } + return { nameWithOwner, branch, filePath }; +}; +var _isRepoRoot = (url) => { + const repository = getRepo(url ?? location); + if (!repository) { + return false; + } + const path = repository.path ? repository.path.split("/") : []; + switch (path.length) { + case 0: { + return true; + } + case 2: { + return path[0] === "tree"; + } + default: { + if (url) { + return false; + } + const titleInfo = parseRepoExplorerTitle(location.pathname, document.title); + return titleInfo?.filePath === ""; + } + } +}; +var isRepoRoot = (url) => !hasSearchParameter(url ?? location) && _isRepoRoot(url); +var isRepoSearch = (url = location) => getRepo(url)?.path === "search"; +var isRepoSettings = (url = location) => Boolean(getRepo(url)?.path.startsWith("settings")); +var isRepoMainSettings = (url = location) => getRepo(url)?.path === "settings"; +var isRepliesSettings = (url = location) => url.pathname.startsWith("/settings/replies"); +var isUserSettings = (url = location) => url.pathname.startsWith("/settings/"); +var isRepoTree = (url = location) => _isRepoRoot(url) || Boolean(getRepo(url)?.path.startsWith("tree/")); +var isRepoWiki = (url = location) => Boolean(getRepo(url)?.path.startsWith("wiki")); +var isSingleCommit = (url = location) => /^commit\/[\da-f]{5,40}$/.test(getRepo(url)?.path); +var isSingleFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("blob/")); +var isFileFinder = (url = location) => Boolean(getRepo(url)?.path.startsWith("find/")); +var isRepoFile404 = (url = location) => (isSingleFile(url) || isRepoTree(url)) && document.title.startsWith("File not found"); +var isRepoForksList = (url = location) => getRepo(url)?.path === "network/members"; +var isRepoNetworkGraph = (url = location) => getRepo(url)?.path === "network"; +var isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is_fork"][content="true"]'); +var isForkingRepo = (url = location) => getRepo(url)?.path === "fork"; +var isSingleGist = (url = location) => /^[^/]+\/[\da-f]{20,32}(\/[\da-f]{40})?$/.test(getCleanGistPathname(url)); +var isGistRevision = (url = location) => /^[^/]+\/[\da-f]{20,32}\/revisions$/.test(getCleanGistPathname(url)); +var isTrending = (url = location) => url.pathname === "/trending" || url.pathname.startsWith("/trending/"); +var isBranches = (url = location) => Boolean(getRepo(url)?.path.startsWith("branches")); +var doesLookLikeAProfile = (string) => typeof string === "string" && string.length > 0 && !string.includes("/") && !string.includes(".") && !reservedNames.includes(string); +var isProfile = (url = location) => !isGist(url) && doesLookLikeAProfile(getCleanPathname(url)); +var isGistProfile = (url = location) => doesLookLikeAProfile(getCleanGistPathname(url)); +var isUserProfile = () => isProfile() && !isOrganizationProfile(); +var isPrivateUserProfile = () => isUserProfile() && !exists('.UnderlineNav-item[href$="tab=stars"]'); +var isUserProfileMainTab = () => isUserProfile() && !new URLSearchParams(location.search).has("tab"); +var isUserProfileRepoTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "repositories"; +var isUserProfileStarsTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "stars"; +var isUserProfileFollowersTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "followers"; +var isUserProfileFollowingTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "following"; +var isProfileRepoList = (url = location) => isUserProfileRepoTab(url) || getOrg(url)?.path === "repositories"; +var hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isTeamDiscussion(url) || isSingleGist(url); +var hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url) || isNewDiscussion(url); +var hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isRepoSearch(url) || isGlobalSearchResults(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isCompareWikiPage(url) || isBlame(url); +var isRepoGitObject = (url = location) => isRepo(url) && [void 0, "blob", "tree", "blame"].includes(getCleanPathname(url).split("/")[2]); +var hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url); +var isMarketplaceAction = (url = location) => url.pathname.startsWith("/marketplace/actions/"); +var isActionJobRun = (url = location) => Boolean(getRepo(url)?.path.startsWith("runs/")); +var isActionRun = (url = location) => /^(actions\/)?runs/.test(getRepo(url)?.path); +var isNewAction = (url = location) => getRepo(url)?.path === "actions/new"; +var isRepositoryActions = (url = location) => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path); +var isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]'); +var canUserAdminRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]'); +var canUserEditRepo = canUserAdminRepo; +var isNewRepo = (url = location) => !isGist(url) && (url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url))); +var isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate"); +var getLoggedInUser = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0; +var getCleanPathname = (url = location) => url.pathname.replaceAll(/\/\/+/g, "/").replace(/\/$/, "").slice(1); +var getCleanGistPathname = (url = location) => { + const pathname = getCleanPathname(url); + if (url.hostname.startsWith("gist.")) { + return pathname; + } + const [gist, ...parts] = pathname.split("/"); + return gist === "gist" ? parts.join("/") : void 0; +}; +var getOrg = (url = location) => { + const [orgs, name, ...path] = getCleanPathname(url).split("/"); + if (orgs === "orgs" && name) { + return { name, path: path.join("/") }; + } + return void 0; +}; +var getRepo = (url) => { + if (!url) { + const canonical = $('[property="og:url"]'); + if (canonical) { + const canonicalUrl = new URL(canonical.content, location.origin); + if (getCleanPathname(canonicalUrl).toLowerCase() === getCleanPathname(location).toLowerCase()) { + url = canonicalUrl; + } + } + } + if (typeof url === "string") { + url = new URL(url, location.origin); + } + if (!isRepo(url)) { + return; + } + const [owner, name, ...path] = getCleanPathname(url).split("/"); + return { + owner, + name, + nameWithOwner: `${owner}/${name}`, + path: path.join("/") + }; +}; +var utils = { + getOrg, + /** @deprecated Use `getLoggedInUser` */ + getUsername: getLoggedInUser, + getLoggedInUser, + getCleanPathname, + getCleanGistPathname, + getRepositoryInfo: getRepo, + parseRepoExplorerTitle +}; +export { + canUserAdminRepo, + canUserEditRepo, + hasCode, + hasComments, + hasFileEditor, + hasFiles, + hasReleaseEditor, + hasRepoHeader, + hasRichTextEditor, + hasWikiPageEditor, + is404, + is500, + isActionJobRun, + isActionRun, + isArchivedRepo, + isBlame, + isBlank, + isBranches, + isClosedConversation, + isCommit, + isCommitList, + isCompare, + isCompareWikiPage, + isConversation, + isDashboard, + isDeletingFile, + isDiscussion, + isDiscussionList, + isDraftPR, + isEditingFile, + isEditingRelease, + isEditingWikiPage, + isEmptyRepo, + isEmptyRepoRoot, + isEnterprise, + isFileFinder, + isForkedRepo, + isForkingRepo, + isGist, + isGistProfile, + isGistRevision, + isGlobalIssueOrPRList, + isGlobalSearchResults, + isIssue, + isIssueOrPRList, + isLabelList, + isLoggedIn, + isMarketplaceAction, + isMergedPR, + isMilestone, + isMilestoneList, + isNewAction, + isNewDiscussion, + isNewFile, + isNewIssue, + isNewRelease, + isNewRepo, + isNewRepoTemplate, + isNewWikiPage, + isNotifications, + isOpenConversation, + isOrganizationProfile, + isOrganizationRepo, + isOwnOrganizationProfile, + isOwnUserProfile, + isPR, + isPRCommit, + isPRCommit404, + isPRCommitList, + isPRConflicts, + isPRConversation, + isPRFile404, + isPRFiles, + isPRList, + isPasswordConfirmation, + isPrivateUserProfile, + isProfile, + isProfileRepoList, + isProject, + isProjects, + isPublicRepo, + isQuickPR, + isReleases, + isReleasesOrTags, + isRepliesSettings, + isRepo, + isRepoCommitList, + isRepoFile404, + isRepoForksList, + isRepoGitObject, + isRepoHome, + isRepoIssueList, + isRepoIssueOrPRList, + isRepoMainSettings, + isRepoNetworkGraph, + isRepoPRList, + isRepoRoot, + isRepoSearch, + isRepoSettings, + isRepoTaxonomyIssueOrPRList, + isRepoTree, + isRepoWiki, + isRepositoryActions, + isSingleCommit, + isSingleFile, + isSingleGist, + isSingleReleaseOrTag, + isTags, + isTeamDiscussion, + isTrending, + isUserProfile, + isUserProfileFollowersTab, + isUserProfileFollowingTab, + isUserProfileMainTab, + isUserProfileRepoTab, + isUserProfileStarsTab, + isUserSettings, + isUserTheOrganizationOwner, + utils +}; diff --git a/distribution/index.test.d.ts b/distribution/index.test.d.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/distribution/index.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/package-lock.json b/package-lock.json index e0bdfe86..1d85c52c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,6 @@ "strip-indent": "^4.0.0", "svelte": "^4.2.18", "svelte-check": "^3.8.5", - "tsx": "^4.21.0", "typescript": "^5.5.4", "vite": "^5.4.2", "vitest": "^2.0.5", @@ -375,23 +374,6 @@ "node": ">=18" } }, - "node_modules/@esbuild/netbsd-arm64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.2.tgz", - "integrity": "sha512-Kj6DiBlwXrPsCRDeRvGAUb/LNrBASrfqAIok+xB0LxK8CHqxZ037viF13ugfsIpePH93mX7xfJp97cyDuTZ3cw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, "node_modules/@esbuild/netbsd-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", @@ -443,23 +425,6 @@ "node": ">=18" } }, - "node_modules/@esbuild/openharmony-arm64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.2.tgz", - "integrity": "sha512-LRBbCmiU51IXfeXk59csuX/aSaToeG7w48nMwA6049Y4J4+VbWALAuXcs+qcD04rHDuSCSRKdmY63sruDS5qag==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ], - "engines": { - "node": ">=18" - } - }, "node_modules/@esbuild/sunos-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", @@ -8123,476 +8088,6 @@ "dev": true, "license": "0BSD" }, - "node_modules/tsx": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", - "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", - "dev": true, - "license": "MIT", - "dependencies": { - "esbuild": "~0.27.0", - "get-tsconfig": "^4.7.5" - }, - "bin": { - "tsx": "dist/cli.mjs" - }, - "engines": { - "node": ">=18.0.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - } - }, - "node_modules/tsx/node_modules/@esbuild/aix-ppc64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz", - "integrity": "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/android-arm": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.2.tgz", - "integrity": "sha512-DVNI8jlPa7Ujbr1yjU2PfUSRtAUZPG9I1RwW4F4xFB1Imiu2on0ADiI/c3td+KmDtVKNbi+nffGDQMfcIMkwIA==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/android-arm64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.2.tgz", - "integrity": "sha512-pvz8ZZ7ot/RBphf8fv60ljmaoydPU12VuXHImtAs0XhLLw+EXBi2BLe3OYSBslR4rryHvweW5gmkKFwTiFy6KA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/android-x64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.2.tgz", - "integrity": "sha512-z8Ank4Byh4TJJOh4wpz8g2vDy75zFL0TlZlkUkEwYXuPSgX8yzep596n6mT7905kA9uHZsf/o2OJZubl2l3M7A==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/darwin-arm64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.2.tgz", - "integrity": "sha512-davCD2Zc80nzDVRwXTcQP/28fiJbcOwvdolL0sOiOsbwBa72kegmVU0Wrh1MYrbuCL98Omp5dVhQFWRKR2ZAlg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/darwin-x64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.2.tgz", - "integrity": "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/freebsd-arm64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.2.tgz", - "integrity": "sha512-lS/9CN+rgqQ9czogxlMcBMGd+l8Q3Nj1MFQwBZJyoEKI50XGxwuzznYdwcav6lpOGv5BqaZXqvBSiB/kJ5op+g==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/freebsd-x64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.2.tgz", - "integrity": "sha512-tAfqtNYb4YgPnJlEFu4c212HYjQWSO/w/h/lQaBK7RbwGIkBOuNKQI9tqWzx7Wtp7bTPaGC6MJvWI608P3wXYA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-arm": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.2.tgz", - "integrity": "sha512-vWfq4GaIMP9AIe4yj1ZUW18RDhx6EPQKjwe7n8BbIecFtCQG4CfHGaHuh7fdfq+y3LIA2vGS/o9ZBGVxIDi9hw==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-arm64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.2.tgz", - "integrity": "sha512-hYxN8pr66NsCCiRFkHUAsxylNOcAQaxSSkHMMjcpx0si13t1LHFphxJZUiGwojB1a/Hd5OiPIqDdXONia6bhTw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-ia32": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.2.tgz", - "integrity": "sha512-MJt5BRRSScPDwG2hLelYhAAKh9imjHK5+NE/tvnRLbIqUWa+0E9N4WNMjmp/kXXPHZGqPLxggwVhz7QP8CTR8w==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-loong64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.2.tgz", - "integrity": "sha512-lugyF1atnAT463aO6KPshVCJK5NgRnU4yb3FUumyVz+cGvZbontBgzeGFO1nF+dPueHD367a2ZXe1NtUkAjOtg==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-mips64el": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.2.tgz", - "integrity": "sha512-nlP2I6ArEBewvJ2gjrrkESEZkB5mIoaTswuqNFRv/WYd+ATtUpe9Y09RnJvgvdag7he0OWgEZWhviS1OTOKixw==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-ppc64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.2.tgz", - "integrity": "sha512-C92gnpey7tUQONqg1n6dKVbx3vphKtTHJaNG2Ok9lGwbZil6DrfyecMsp9CrmXGQJmZ7iiVXvvZH6Ml5hL6XdQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-riscv64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.2.tgz", - "integrity": "sha512-B5BOmojNtUyN8AXlK0QJyvjEZkWwy/FKvakkTDCziX95AowLZKR6aCDhG7LeF7uMCXEJqwa8Bejz5LTPYm8AvA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-s390x": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.2.tgz", - "integrity": "sha512-p4bm9+wsPwup5Z8f4EpfN63qNagQ47Ua2znaqGH6bqLlmJ4bx97Y9JdqxgGZ6Y8xVTixUnEkoKSHcpRlDnNr5w==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-x64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.2.tgz", - "integrity": "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/netbsd-x64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.2.tgz", - "integrity": "sha512-HwGDZ0VLVBY3Y+Nw0JexZy9o/nUAWq9MlV7cahpaXKW6TOzfVno3y3/M8Ga8u8Yr7GldLOov27xiCnqRZf0tCA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/openbsd-arm64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.2.tgz", - "integrity": "sha512-DNIHH2BPQ5551A7oSHD0CKbwIA/Ox7+78/AWkbS5QoRzaqlev2uFayfSxq68EkonB+IKjiuxBFoV8ESJy8bOHA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/openbsd-x64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.2.tgz", - "integrity": "sha512-/it7w9Nb7+0KFIzjalNJVR5bOzA9Vay+yIPLVHfIQYG/j+j9VTH84aNB8ExGKPU4AzfaEvN9/V4HV+F+vo8OEg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/sunos-x64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.2.tgz", - "integrity": "sha512-kMtx1yqJHTmqaqHPAzKCAkDaKsffmXkPHThSfRwZGyuqyIeBvf08KSsYXl+abf5HDAPMJIPnbBfXvP2ZC2TfHg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/win32-arm64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.2.tgz", - "integrity": "sha512-Yaf78O/B3Kkh+nKABUF++bvJv5Ijoy9AN1ww904rOXZFLWVc5OLOfL56W+C8F9xn5JQZa3UX6m+IktJnIb1Jjg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/win32-ia32": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.2.tgz", - "integrity": "sha512-Iuws0kxo4yusk7sw70Xa2E2imZU5HoixzxfGCdxwBdhiDgt9vX9VUCBhqcwY7/uh//78A1hMkkROMJq9l27oLQ==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/win32-x64": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.2.tgz", - "integrity": "sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/esbuild": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", - "integrity": "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.27.2", - "@esbuild/android-arm": "0.27.2", - "@esbuild/android-arm64": "0.27.2", - "@esbuild/android-x64": "0.27.2", - "@esbuild/darwin-arm64": "0.27.2", - "@esbuild/darwin-x64": "0.27.2", - "@esbuild/freebsd-arm64": "0.27.2", - "@esbuild/freebsd-x64": "0.27.2", - "@esbuild/linux-arm": "0.27.2", - "@esbuild/linux-arm64": "0.27.2", - "@esbuild/linux-ia32": "0.27.2", - "@esbuild/linux-loong64": "0.27.2", - "@esbuild/linux-mips64el": "0.27.2", - "@esbuild/linux-ppc64": "0.27.2", - "@esbuild/linux-riscv64": "0.27.2", - "@esbuild/linux-s390x": "0.27.2", - "@esbuild/linux-x64": "0.27.2", - "@esbuild/netbsd-arm64": "0.27.2", - "@esbuild/netbsd-x64": "0.27.2", - "@esbuild/openbsd-arm64": "0.27.2", - "@esbuild/openbsd-x64": "0.27.2", - "@esbuild/openharmony-arm64": "0.27.2", - "@esbuild/sunos-x64": "0.27.2", - "@esbuild/win32-arm64": "0.27.2", - "@esbuild/win32-ia32": "0.27.2", - "@esbuild/win32-x64": "0.27.2" - } - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index f425cd66..708188b1 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "build": "run-p build:*", "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST", "build:typescript": "tsc --declaration --emitDeclarationOnly", - "postbuild:typescript": "node --import tsx add-examples-to-dts.ts", + "postbuild:typescript": "node --experimental-strip-types add-examples-to-dts.ts", "build:demo": "vite build demo", "try": "esbuild index.ts --bundle --global-name=x --format=iife | pbcopy && echo 'Copied to clipboard'", "fix": "xo --fix", @@ -70,7 +70,6 @@ "strip-indent": "^4.0.0", "svelte": "^4.2.18", "svelte-check": "^3.8.5", - "tsx": "^4.21.0", "typescript": "^5.5.4", "vite": "^5.4.2", "vitest": "^2.0.5", From 730d74978767a08c8c4ffa2f6d6e397bb08e320d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 08:17:25 +0000 Subject: [PATCH 08/19] Extend existing JSDoc blocks and add validations to add-examples-to-dts.ts - Script now detects and extends existing JSDoc comments (both single-line and multi-line) - Added marker to prevent running script twice on the same file - Added validation that at least some examples were added - Added TypeScript validation after modification to ensure file is still valid - Exits with error if any validation fails - Updated distribution files with properly extended JSDoc blocks Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- add-examples-to-dts.ts | 122 +++++++++++++++++++++++++++++++++++++--- distribution/index.d.ts | 5 +- 2 files changed, 116 insertions(+), 11 deletions(-) diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts index 23901826..78bd6e08 100644 --- a/add-examples-to-dts.ts +++ b/add-examples-to-dts.ts @@ -1,5 +1,7 @@ #!/usr/bin/env node --experimental-strip-types +/* eslint-disable n/prefer-global/process */ import {readFileSync, writeFileSync} from 'node:fs'; +import {execSync} from 'node:child_process'; // Import index.ts to populate the test data via side effect // eslint-disable-next-line import/no-unassigned-import, n/file-extension-in-import import './index.ts'; @@ -10,9 +12,17 @@ import {getTests} from './collector.ts'; const dtsPath = './distribution/index.d.ts'; const dtsContent = readFileSync(dtsPath, 'utf8'); +// Check if script has already been run +const marker = '/* Examples added by add-examples-to-dts.ts */'; +if (dtsContent.includes(marker)) { + console.error('❌ Error: Examples have already been added to this file'); + process.exit(1); +} + // Process each exported function const lines = dtsContent.split('\n'); const outputLines: string[] = []; +let examplesAdded = 0; for (const line of lines) { // Check if this is a function declaration @@ -24,20 +34,91 @@ for (const line of lines) { const examples = getTests(functionName); // Only add examples if they exist and aren't the special 'combinedTestOnly' marker - // 'combinedTestOnly' is used to skip tests for combined functions (e.g., isPageA() || isPageB()) if (examples && examples.length > 0 && examples[0] !== 'combinedTestOnly') { // Filter to only include actual URLs (not references to other functions) - // getTests() recursively expands function references, so we just need to filter the final list const urlExamples = examples.filter((url: string) => url.startsWith('http')); if (urlExamples.length > 0) { - // Add JSDoc comment with examples before the declaration - outputLines.push('/**'); - for (const url of urlExamples) { - outputLines.push(` * @example ${url}`); + // Check if there's an existing JSDoc block immediately before this line + let jsDocumentEndIndex = -1; + let jsDocumentStartIndex = -1; + let isSingleLineJsDocument = false; + + // Look backwards from outputLines to find JSDoc + for (let index = outputLines.length - 1; index >= 0; index--) { + const previousLine = outputLines[index]; + const trimmed = previousLine.trim(); + + if (trimmed === '') { + continue; // Skip empty lines + } + + // Check for single-line JSDoc: /** ... */ + if (trimmed.startsWith('/**') && trimmed.endsWith('*/') && trimmed.length > 5) { + jsDocumentStartIndex = index; + jsDocumentEndIndex = index; + isSingleLineJsDocument = true; + break; + } + + // Check for multi-line JSDoc ending + if (trimmed === '*/') { + jsDocumentEndIndex = index; + // Now find the start of this JSDoc + for (let k = index - 1; k >= 0; k--) { + if (outputLines[k].trim().startsWith('/**')) { + jsDocumentStartIndex = k; + break; + } + } + + break; + } + + // If we hit a non-JSDoc line, there's no JSDoc block + break; } - outputLines.push(' */'); + if (jsDocumentStartIndex >= 0 && jsDocumentEndIndex >= 0) { + // Extend existing JSDoc block + if (isSingleLineJsDocument) { + // Convert single-line to multi-line and add examples + const singleLineContent = outputLines[jsDocumentStartIndex]; + // Extract the comment text without /** and */ + const commentText = singleLineContent.trim().slice(3, -2).trim(); + + // Replace the single line with multi-line format + outputLines[jsDocumentStartIndex] = '/**'; + if (commentText) { + outputLines.splice(jsDocumentStartIndex + 1, 0, ` * ${commentText}`); + } + + // Add examples after the existing content + const insertIndex = jsDocumentStartIndex + (commentText ? 2 : 1); + for (const url of urlExamples) { + outputLines.splice(insertIndex + urlExamples.indexOf(url), 0, ` * @example ${url}`); + } + + outputLines.splice(insertIndex + urlExamples.length, 0, ' */'); + examplesAdded += urlExamples.length; + } else { + // Insert @example lines before the closing */ + for (const url of urlExamples) { + outputLines.splice(jsDocumentEndIndex, 0, ` * @example ${url}`); + } + + examplesAdded += urlExamples.length; + } + } else { + // Add new JSDoc comment with examples before the declaration + outputLines.push('/**'); + for (const url of urlExamples) { + outputLines.push(` * @example ${url}`); + } + + outputLines.push(' */'); + examplesAdded += urlExamples.length; + } } } } @@ -45,7 +126,30 @@ for (const line of lines) { outputLines.push(line); } +// Add marker at the beginning +const finalContent = `${marker}\n${outputLines.join('\n')}`; + +// Validate that we added some examples +if (examplesAdded === 0) { + console.error('❌ Error: No examples were added. This likely indicates a problem with the script.'); + process.exit(1); +} + // Write the modified content back -writeFileSync(dtsPath, outputLines.join('\n'), 'utf8'); +writeFileSync(dtsPath, finalContent, 'utf8'); -console.log('✓ Added example URLs to index.d.ts'); +console.log(`✓ Added ${examplesAdded} example URLs to index.d.ts`); + +// Validate with TypeScript +try { + execSync('npx tsc --noEmit distribution/index.d.ts', { + cwd: process.cwd(), + stdio: 'pipe', + }); + console.log('✓ TypeScript validation passed'); +} catch (error: unknown) { + console.error('❌ TypeScript validation failed:'); + const execError = error as {stdout?: Uint8Array; stderr?: Uint8Array; message?: string}; + console.error(execError.stdout?.toString() ?? execError.stderr?.toString() ?? execError.message); + process.exit(1); +} diff --git a/distribution/index.d.ts b/distribution/index.d.ts index f50f0461..39ace3d7 100644 --- a/distribution/index.d.ts +++ b/distribution/index.d.ts @@ -1,3 +1,4 @@ +/* Examples added by add-examples-to-dts.ts */ export declare const is404: () => boolean; export declare const is500: () => boolean; export declare const isPasswordConfirmation: () => boolean; @@ -195,8 +196,8 @@ export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean * @example https://github.com/sindresorhus/refined-github/pull/148/conflicts */ export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */ /** + * Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown * @example https://github.com/pulls * @example https://github.com/pulls?q=issues * @example https://github.com/sindresorhus/refined-github/pulls @@ -532,8 +533,8 @@ export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; /** Static code, not the code editor */ export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Covers blob, trees and blame pages */ /** + * Covers blob, trees and blame pages * @example https://github.com/sindresorhus/refined-github * @example https://github.com/sindresorhus/refined-github/ * @example https://github.com/sindresorhus/notifications/ From 0513c340435f3a1cb0a0d04a5f97ae414ae87253 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 08:53:01 +0000 Subject: [PATCH 09/19] Remove --experimental-strip-types flag and hashbang - Removed hashbang from add-examples-to-dts.ts - Removed --experimental-strip-types flag from postbuild:typescript script - Node 22.18+ handles TypeScript natively without explicit flags Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- add-examples-to-dts.ts | 1 - distribution/index.d.ts | 480 +--------------------------------------- distribution/index.js | 5 +- package-lock.json | 2 +- package.json | 2 +- 5 files changed, 12 insertions(+), 478 deletions(-) diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts index 78bd6e08..5105c303 100644 --- a/add-examples-to-dts.ts +++ b/add-examples-to-dts.ts @@ -1,4 +1,3 @@ -#!/usr/bin/env node --experimental-strip-types /* eslint-disable n/prefer-global/process */ import {readFileSync, writeFileSync} from 'node:fs'; import {execSync} from 'node:child_process'; diff --git a/distribution/index.d.ts b/distribution/index.d.ts index 39ace3d7..c0a29955 100644 --- a/distribution/index.d.ts +++ b/distribution/index.d.ts @@ -1,304 +1,65 @@ -/* Examples added by add-examples-to-dts.ts */ export declare const is404: () => boolean; export declare const is500: () => boolean; export declare const isPasswordConfirmation: () => boolean; export declare const isLoggedIn: () => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/blame/master/package.json - */ export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/commit/5b614b9035f2035b839f48b4db7bd5c3298d526f - * @example https://github.com/sindresorhus/refined-github/commit/5b614 - * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 - * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d79 - * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 - * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d79 - */ export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/commits/master?page=2 - * @example https://github.com/sindresorhus/refined-github/commits/test-branch - * @example https://github.com/sindresorhus/refined-github/commits/0.13.0 - * @example https://github.com/sindresorhus/refined-github/commits/230c2 - * @example https://github.com/sindresorhus/refined-github/commits/230c2935fc5aea9a681174ddbeba6255ca040d63 - * @example https://github.com/sindresorhus/refined-github/commits?author=fregante - * @example https://github.com/sindresorhus/runs/commits/ - */ export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/compare - * @example https://github.com/sindresorhus/refined-github/compare/ - * @example https://github.com/sindresorhus/refined-github/compare/master...branch-name - * @example https://github.com/sindresorhus/refined-github/compare/master...branch-name?quick_pull=1 - * @example https://github.com/sindresorhus/refined-github/compare/branch-1...branch-2?quick_pull=1 - * @example https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1 - */ export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/brookhong/Surfingkeys/wiki/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d - * @example https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d - */ export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/// - * @example https://github.com// - * @example https://github.com/ - * @example https://github.com - * @example https://github.com/orgs/test/dashboard - * @example https://github.com/dashboard/index/2 - * @example https://github.com//dashboard - * @example https://github.com/dashboard - * @example https://github.com/orgs/edit/dashboard - * @example https://github.big-corp.com/ - * @example https://not-github.com/ - * @example https://my-little-hub.com/ - * @example https://github.com/?tab=repositories - * @example https://github.com/?tab=stars - * @example https://github.com/?tab=followers - * @example https://github.com/?tab=following - * @example https://github.com/?tab=overview - * @example https://github.com?search=1 - * @example https://github.com/dashboard-feed - */ export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.big-corp.com/ - * @example https://not-github.com/ - * @example https://my-little-hub.com/ - * @example https://my-little-hub.com/gist - * @example https://my-little-hub.com/gist/in-fragrante - * @example https://gist.my-little-hub.com/in-fragrante - */ export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://gist.github.com - * @example http://gist.github.com - * @example https://gist.github.com/new - * @example https://gist.github.com/fregante/2205329b71218fa2c1d3 - * @example https://gist.github.com/fregante/2205329b71218fa2c1d3/d1ebf7d9cfaba4d4596d2ea9174e202479a5f9ad - * @example https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064 - * @example https://my-little-hub.com/gist - * @example https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions - * @example https://gist.github.com/fregante - * @example https://gist.github.com/github - * @example https://gist.github.com/babel - * @example https://my-little-hub.com/gist/in-fragrante - * @example https://gist.my-little-hub.com/in-fragrante - */ export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/issues - * @example https://github.com/issues?q=is%3Apr+is%3Aopen - * @example https://github.com/issues/assigned - * @example https://github.com/issues/mentioned - * @example https://github.com/pulls - * @example https://github.com/pulls?q=issues - * @example https://github.com/pulls/assigned - * @example https://github.com/pulls/mentioned - * @example https://github.com/pulls/review-requested - */ export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/search?q=refined-github&ref=opensearch - */ export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/issues/146 - */ export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/labels - * @example https://github.com/sindresorhus/refined-github/labels/ - */ export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/kubernetes/kubernetes/milestone/56 - */ export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/milestones - */ export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/new/main - */ export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/issues/new - */ export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/releases/new - */ export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/tooomm/wikitest/wiki/_new - */ export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/notifications - */ export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isOrganizationProfile: () => boolean; export declare const isOrganizationRepo: () => boolean; -/** - * @example https://github.com/orgs/refined-github/teams/core-team/discussions?pinned=1 - * @example https://github.com/orgs/refined-github/teams/core-team/discussions/1 - * @example https://github.com/orgs/refined-github/teams/core-team - */ export declare const isTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isOwnUserProfile: () => boolean; export declare const isOwnOrganizationProfile: () => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/projects/3 - * @example https://github.com/orgs/RSSNext/projects/3 - */ export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/projects - */ export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/tophf/mpiv/discussions/50 - * @example https://github.com/orgs/community/discussions/11202 - */ export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/withastro/roadmap/discussions/new?category=proposal - * @example https://github.com/orgs/community/discussions/new?category=pull-requests - */ export declare const isNewDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/tophf/mpiv/discussions - * @example https://github.com/orgs/community/discussions - */ export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 - * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d79 - * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 - * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d79 - * @example https://github.com/sindresorhus/refined-github/pull/148/files - * @example https://github.com/sindresorhus/refined-github/pull/148/files/e1aba6f - * @example https://github.com/sindresorhus/refined-github/pull/148/files/1e27d799..e1aba6f - * @example https://github.com/refined-github/refined-github/pull/148/changes - * @example https://github.com/refined-github/refined-github/pull/148/changes/1e27d799..e1aba6f - * @example https://github.com/refined-github/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641..e1aba6febb3fe38aafd1137cff28b536eeeabe7e - * @example https://github.com/sindresorhus/refined-github/pull/148/commits - * @example https://github.com/sindresorhus/refined-github/pull/148 - */ export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/pull/148/conflicts - */ export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown - * @example https://github.com/pulls - * @example https://github.com/pulls?q=issues - * @example https://github.com/sindresorhus/refined-github/pulls - * @example https://github.com/sindresorhus/refined-github/pulls/ - * @example https://github.com/sindresorhus/refined-github/pulls?q=is%3Aopen+is%3Apr - * @example https://github.com/sindresorhus/refined-github/pulls?q=is%3Apr+is%3Aclosed - */ +/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */ export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 - * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d79 - * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 - * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d79 - */ export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isPRCommit404: () => boolean; export declare const isPRFile404: () => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/pull/148 - */ export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/pull/148/commits - */ export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 - * @example https://github.com/sindresorhus/refined-github/pull/148/commits/1e27d79 - * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641 - * @example https://github.com/sindresorhus/refined-github/pull/148/changes/1e27d79 - * @example https://github.com/sindresorhus/refined-github/pull/148/files - * @example https://github.com/sindresorhus/refined-github/pull/148/files/e1aba6f - * @example https://github.com/sindresorhus/refined-github/pull/148/files/1e27d799..e1aba6f - * @example https://github.com/refined-github/refined-github/pull/148/changes - * @example https://github.com/refined-github/refined-github/pull/148/changes/1e27d799..e1aba6f - * @example https://github.com/refined-github/refined-github/pull/148/changes/1e27d7998afdd3608d9fc3bf95ccf27fa5010641..e1aba6febb3fe38aafd1137cff28b536eeeabe7e - */ export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/compare/master...branch-name?quick_pull=1 - * @example https://github.com/sindresorhus/refined-github/compare/branch-1...branch-2?quick_pull=1 - * @example https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1 - */ export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isMergedPR: () => boolean; export declare const isDraftPR: () => boolean; export declare const isOpenConversation: () => boolean; export declare const isClosedConversation: () => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/releases - * @example https://github.com/sindresorhus/refined-github/releases?page=2 - */ export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/tags - * @example https://github.com/sindresorhus/refined-github/tags?after=21.8.1 - */ export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/refined-github/refined-github/releases/tag/1.20.1 - * @example https://github.com/refined-github/refined-github/releases/tag/23.7.25 - */ export declare const isSingleReleaseOrTag: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/releases - * @example https://github.com/sindresorhus/refined-github/releases?page=2 - * @example https://github.com/sindresorhus/refined-github/tags - * @example https://github.com/sindresorhus/refined-github/tags?after=21.8.1 - */ export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/delete/master/readme.md - * @example https://github.com/sindresorhus/refined-github/delete/ghe-injection/source/background.ts - */ export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/edit/master/readme.md - * @example https://github.com/sindresorhus/refined-github/edit/ghe-injection/source/background.ts - */ export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/releases/edit/v1.2.3 - */ export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/tooomm/wikitest/wiki/Getting-Started/_edit - */ export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/blame/master/package.json - * @example https://github.com/sindresorhus/refined-github/issues/146 - * @example https://github.com/sindresorhus/notifications/ - * @example https://github.com/sindresorhus/refined-github/pull/148 - * @example https://github.com/sindresorhus/refined-github/milestones/new - * @example https://github.com/sindresorhus/refined-github/milestones/1/edit - * @example https://github.com/sindresorhus/refined-github/issues/new/choose - * @example https://github.com/sindresorhus/refined-github/issues/templates/edit - */ export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isEmptyRepoRoot: () => boolean; @@ -306,300 +67,68 @@ export declare const isEmptyRepo: () => boolean; export declare const isPublicRepo: () => boolean; export declare const isArchivedRepo: () => boolean; export declare const isBlank: () => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/labels/bug - * @example https://github.com/sindresorhus/refined-github/labels/implemented%20by%20github - * @example https://github.com/sindresorhus/refined-github/labels/%3Adollar%3A%20Funded%20on%20Issuehunt - * @example https://github.com/sindresorhus/refined-github/milestones/1 - */ export declare const isRepoTaxonomyIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isRepoIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/pulls - * @example https://github.com/sindresorhus/refined-github/pulls/ - * @example https://github.com/sindresorhus/refined-github/pulls?q=is%3Aopen+is%3Apr - * @example https://github.com/sindresorhus/refined-github/pulls?q=is%3Apr+is%3Aclosed - */ export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example http://github.com/sindresorhus/ava/issues - * @example https://github.com/sindresorhus/refined-github/issues - * @example https://github.com/sindresorhus/refined-github/issues/fregante - * @example https://github.com/sindresorhus/refined-github/issues/newton - * @example https://github.com/sindresorhus/refined-github/issues/wptemplates - * @example https://github.com/sindresorhus/refined-github/issues?q=is%3Aclosed+sort%3Aupdated-desc - * @example https://github.com/sindresorhus/refined-github/labels/bug - * @example https://github.com/sindresorhus/refined-github/labels/implemented%20by%20github - * @example https://github.com/sindresorhus/refined-github/labels/%3Adollar%3A%20Funded%20on%20Issuehunt - */ export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github - * @example https://github.com/sindresorhus/refined-github/ - * @example https://github.com/sindresorhus/notifications/ - * @example https://github.com/sindresorhus/edit - * @example https://github.com/sindresorhus///edit - * @example https://github.com/sindresorhus/search - * @example https://github.com/sindresorhus/branches - * @example https://github.com/sindresorhus/refined-github?files=1 - */ export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean; export type RepoExplorerInfo = { nameWithOwner: string; branch: string; filePath: string; }; -/** - * @example https://github.com/sindresorhus/refined-github - * @example https://github.com/sindresorhus/refined-github/ - * @example https://github.com/sindresorhus/notifications/ - * @example https://github.com/sindresorhus/edit - * @example https://github.com/sindresorhus///edit - * @example https://github.com/sindresorhus/search - * @example https://github.com/sindresorhus/branches - * @example https://github.com/sindresorhus/refined-github?files=1 - * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons - * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/ - * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6 - * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6/ - * @example https://github.com/sindresorhus/refined-github/tree/57bf4 - * @example https://github.com/sindresorhus/refined-github/tree/master?files=1 - */ export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/search?q=diff - * @example https://github.com/sindresorhus/refined-github/search?q=diff&unscoped_q=diff&type=Issues - * @example https://github.com/sindresorhus/refined-github/search - */ export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/settings - * @example https://github.com/sindresorhus/refined-github/settings/branches - */ export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/settings - */ export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/settings/replies - * @example https://github.com/settings/replies/88491/edit - */ export declare const isRepliesSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/settings/profile - * @example https://github.com/settings/replies - * @example https://github.com/settings/replies/88491/edit - */ export declare const isUserSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github - * @example https://github.com/sindresorhus/refined-github/ - * @example https://github.com/sindresorhus/notifications/ - * @example https://github.com/sindresorhus/edit - * @example https://github.com/sindresorhus///edit - * @example https://github.com/sindresorhus/search - * @example https://github.com/sindresorhus/branches - * @example https://github.com/sindresorhus/refined-github?files=1 - * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons - * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/ - * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6 - * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6/ - * @example https://github.com/sindresorhus/refined-github/tree/57bf4 - * @example https://github.com/sindresorhus/refined-github/tree/master?files=1 - * @example https://github.com/sindresorhus/refined-github/tree/main/source - * @example https://github.com/sindresorhus/refined-github/tree/0.13.0/extension - * @example https://github.com/sindresorhus/refined-github/tree/57bf435ee12d14b482df0bbd88013a2814c7512e/extension - * @example https://github.com/sindresorhus/refined-github?search=1 - */ export declare const isRepoTree: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/lukesampson/scoop/wiki - * @example https://github.com/tooomm/wikitest/wiki/_new - * @example https://github.com/tooomm/wikitest/wiki/Getting-Started/_edit - * @example https://github.com/brookhong/Surfingkeys/wiki/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d - * @example https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d - */ export declare const isRepoWiki: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/commit/5b614b9035f2035b839f48b4db7bd5c3298d526f - * @example https://github.com/sindresorhus/refined-github/commit/5b614 - */ export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes - * @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css - * @example https://github.com/sindresorhus/refined-github/blob/master/edit.txt - */ export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/find/master - */ export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean; /** * @example https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea * @example https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx */ export declare const isRepoFile404: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/network/members - */ export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/network - */ export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isForkedRepo: () => boolean; -/** - * @example https://github.com/refined-github/refined-github/fork - */ export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://gist.github.com/fregante/2205329b71218fa2c1d3 - * @example https://gist.github.com/fregante/2205329b71218fa2c1d3/d1ebf7d9cfaba4d4596d2ea9174e202479a5f9ad - * @example https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064 - */ export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions - */ export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/trending - * @example https://github.com/trending/developers - * @example https://github.com/trending/unknown - */ export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/branches - */ export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/fregante - * @example https://github.com/github - * @example https://github.com/babel - * @example https://github.com/fregante?tab=repositories - * @example https://github.com/fregante?tab=repositories&type=source - * @example https://github.com/fregante?tab=repositories&q=&type=source&language=css&sort= - * @example https://github.com/fregante?tab=stars - * @example https://github.com/fregante?direction=desc&sort=updated&tab=stars - * @example https://github.com/fregante?tab=followers - * @example https://github.com/sindresorhus?tab=followers - * @example https://github.com/fregante?tab=following - * @example https://github.com/sindresorhus?tab=following - */ export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://gist.github.com/fregante - * @example https://gist.github.com/github - * @example https://gist.github.com/babel - * @example https://my-little-hub.com/gist/in-fragrante - * @example https://gist.my-little-hub.com/in-fragrante - */ export declare const isGistProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isUserProfile: () => boolean; export declare const isPrivateUserProfile: () => boolean; export declare const isUserProfileMainTab: () => boolean; -/** - * @example https://github.com/fregante?tab=repositories - * @example https://github.com/fregante?tab=repositories&type=source - * @example https://github.com/fregante?tab=repositories&q=&type=source&language=css&sort= - */ export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/fregante?tab=stars - * @example https://github.com/fregante?direction=desc&sort=updated&tab=stars - */ export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/fregante?tab=followers - * @example https://github.com/sindresorhus?tab=followers - */ export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/fregante?tab=following - * @example https://github.com/sindresorhus?tab=following - */ export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/fregante?tab=repositories - * @example https://github.com/fregante?tab=repositories&type=source - * @example https://github.com/fregante?tab=repositories&q=&type=source&language=css&sort= - * @example https://github.com/orgs/refined-github/repositories - * @example https://github.com/orgs/refined-github/repositories?q=&type=private&language=&sort= - */ export declare const isProfileRepoList: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; /** Static code, not the code editor */ export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * Covers blob, trees and blame pages - * @example https://github.com/sindresorhus/refined-github - * @example https://github.com/sindresorhus/refined-github/ - * @example https://github.com/sindresorhus/notifications/ - * @example https://github.com/sindresorhus/edit - * @example https://github.com/sindresorhus///edit - * @example https://github.com/sindresorhus/search - * @example https://github.com/sindresorhus/branches - * @example https://github.com/sindresorhus/refined-github?files=1 - * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons - * @example https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/ - * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6 - * @example https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6/ - * @example https://github.com/sindresorhus/refined-github/tree/57bf4 - * @example https://github.com/sindresorhus/refined-github/tree/master?files=1 - * @example https://github.com/sindresorhus/refined-github/tree/main/source - * @example https://github.com/sindresorhus/refined-github/tree/0.13.0/extension - * @example https://github.com/sindresorhus/refined-github/tree/57bf435ee12d14b482df0bbd88013a2814c7512e/extension - * @example https://github.com/sindresorhus/refined-github?search=1 - * @example https://github.com/sindresorhus/refined-github/blob/master/.gitattributes - * @example https://github.com/sindresorhus/refined-github/blob/fix-narrow-diff/distribution/content.css - * @example https://github.com/sindresorhus/refined-github/blob/master/edit.txt - * @example https://github.com/sindresorhus/refined-github/blame/master/package.json - */ +/** Covers blob, trees and blame pages */ export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean; /** Has a list of files */ export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/marketplace/actions/urlchecker-action - * @example https://github.com/marketplace/actions/github-action-for-assignee-to-reviewer - * @example https://github.com/marketplace/actions/hugo-actions - */ export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/runs/639481849 - * @example https://github.com/refined-github/github-url-detection/runs/1224552520?check_suite_focus=true - */ export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/runs/639481849 - * @example https://github.com/refined-github/github-url-detection/runs/1224552520?check_suite_focus=true - * @example https://github.com/refined-github/github-url-detection/actions/runs/294962314 - */ export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/sindresorhus/refined-github/actions/new - */ export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/refined-github/github-url-detection/actions - * @example https://github.com/refined-github/github-url-detection/actions/workflows/demo.yml - * @example https://github.com/refined-github/github-url-detection/actions/workflows/esm-lint.yml - */ export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean; export declare const isUserTheOrganizationOwner: () => boolean; export declare const canUserAdminRepo: () => boolean; /** @deprecated Use `canUserAdminRepo` */ export declare const canUserEditRepo: () => boolean; -/** - * @example https://github.com/new - * @example https://github.com/organizations/npmhub/repositories/new - */ export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/fregante/browser-extension-template/generate - */ export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean; export type NameWithOwner = `${string}/${string}`; export type RepositoryInfo = { @@ -614,6 +143,11 @@ export type RepositoryInfo = { @example '/user/repo/' -> '' @example '/settings/token/' -> undefined */ path: string; + /** The `path` segments + @example '/user/repo/' -> [] + @example '/user/repo/issues/' -> ['issues'] + @example '/user/repo/issues/new' -> ['issues', 'new'] */ + pathParts: string[]; }; export declare const utils: { getOrg: (url?: URL | HTMLAnchorElement | Location) => { diff --git a/distribution/index.js b/distribution/index.js index 97df5827..68830218 100644 --- a/distribution/index.js +++ b/distribution/index.js @@ -213,12 +213,13 @@ var getRepo = (url) => { if (!isRepo(url)) { return; } - const [owner, name, ...path] = getCleanPathname(url).split("/"); + const [owner, name, ...pathParts] = getCleanPathname(url).split("/"); return { owner, name, + pathParts, nameWithOwner: `${owner}/${name}`, - path: path.join("/") + path: pathParts.join("/") }; }; var utils = { diff --git a/package-lock.json b/package-lock.json index a258a20e..5c4fb505 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "xo": "^0.59.3" }, "engines": { - "node": ">=20.10" + "node": ">=22.18" }, "funding": { "url": "https://github.com/sponsors/fregante" diff --git a/package.json b/package.json index 9061e57c..41811e1b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "build": "run-p build:*", "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST", "build:typescript": "tsc --declaration --emitDeclarationOnly", - "postbuild:typescript": "node --experimental-strip-types add-examples-to-dts.ts", + "postbuild:typescript": "node add-examples-to-dts.ts", "build:demo": "vite build demo", "try": "esbuild index.ts --bundle --global-name=x --format=iife | pbcopy && echo 'Copied to clipboard'", "fix": "xo --fix", From 34ebeb41277d24c1e3ec03d6f8a503f153c56450 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Jan 2026 08:57:28 +0000 Subject: [PATCH 10/19] Add actions/setup-node with node-version-file to all workflow jobs - Added actions/setup-node@v4 with node-version-file: package.json to ci.yml Build job - Added actions/setup-node@v4 with node-version-file: artifact/package.json to all esm-lint.yml jobs that run npm/npx commands - Added actions/setup-node@v4 with node-version-file: package.json to demo.yml build job - Ensures all jobs use the correct Node version as specified in package.json engines field Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- .github/workflows/ci.yml | 3 +++ .github/workflows/demo.yml | 3 +++ .github/workflows/esm-lint.yml | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fab2b83e..c5378b6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: package.json - run: npm ci - run: npm run build - name: Ensure that test URLs aren't included in the built file diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 63446901..763db826 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -16,6 +16,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: package.json - run: npm ci - run: npm run build:demo - run: npm run test:demo diff --git a/.github/workflows/esm-lint.yml b/.github/workflows/esm-lint.yml index f104f124..d8c2c09e 100644 --- a/.github/workflows/esm-lint.yml +++ b/.github/workflows/esm-lint.yml @@ -19,6 +19,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: package.json - run: npm install - run: npm run build --if-present - run: npm pack --dry-run @@ -31,12 +34,18 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: artifact/package.json - run: npx publint ./artifact Webpack: runs-on: ubuntu-latest needs: Pack steps: - uses: actions/download-artifact@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: artifact/package.json - run: npm install --omit=dev ./artifact - run: echo "$IMPORT_STATEMENT" > index.js - run: webpack --entry ./index.js @@ -46,6 +55,9 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: artifact/package.json - run: npm install --omit=dev ./artifact - run: echo "$IMPORT_STATEMENT" > index.js - run: > @@ -58,6 +70,9 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: artifact/package.json - run: npm install --omit=dev ./artifact rollup@4 @rollup/plugin-json @rollup/plugin-node-resolve - run: echo "$IMPORT_STATEMENT" > index.js - run: npx rollup -p node-resolve -p @rollup/plugin-json index.js @@ -66,6 +81,9 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: artifact/package.json - run: npm install --omit=dev ./artifact - run: echo '' > index.html - run: npx vite build @@ -75,6 +93,9 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: artifact/package.json - run: echo '{}' > package.json - run: echo "$IMPORT_STATEMENT" > index.js - run: npm install --omit=dev ./artifact @@ -84,6 +105,9 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: artifact/package.json - run: echo '{"type":"module"}' > package.json - run: npm install --omit=dev ./artifact @sindresorhus/tsconfig - run: echo "$IMPORT_STATEMENT" > index.ts From 99b8c15da6a18f93e9dabcdb67f42b9d5906e64f Mon Sep 17 00:00:00 2001 From: fregante Date: Mon, 12 Jan 2026 19:51:05 +0700 Subject: [PATCH 11/19] Discard changes to .github/workflows/esm-lint.yml --- .github/workflows/esm-lint.yml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.github/workflows/esm-lint.yml b/.github/workflows/esm-lint.yml index d8c2c09e..f104f124 100644 --- a/.github/workflows/esm-lint.yml +++ b/.github/workflows/esm-lint.yml @@ -19,9 +19,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: package.json - run: npm install - run: npm run build --if-present - run: npm pack --dry-run @@ -34,18 +31,12 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: artifact/package.json - run: npx publint ./artifact Webpack: runs-on: ubuntu-latest needs: Pack steps: - uses: actions/download-artifact@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: artifact/package.json - run: npm install --omit=dev ./artifact - run: echo "$IMPORT_STATEMENT" > index.js - run: webpack --entry ./index.js @@ -55,9 +46,6 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: artifact/package.json - run: npm install --omit=dev ./artifact - run: echo "$IMPORT_STATEMENT" > index.js - run: > @@ -70,9 +58,6 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: artifact/package.json - run: npm install --omit=dev ./artifact rollup@4 @rollup/plugin-json @rollup/plugin-node-resolve - run: echo "$IMPORT_STATEMENT" > index.js - run: npx rollup -p node-resolve -p @rollup/plugin-json index.js @@ -81,9 +66,6 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: artifact/package.json - run: npm install --omit=dev ./artifact - run: echo '' > index.html - run: npx vite build @@ -93,9 +75,6 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: artifact/package.json - run: echo '{}' > package.json - run: echo "$IMPORT_STATEMENT" > index.js - run: npm install --omit=dev ./artifact @@ -105,9 +84,6 @@ jobs: needs: Pack steps: - uses: actions/download-artifact@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: artifact/package.json - run: echo '{"type":"module"}' > package.json - run: npm install --omit=dev ./artifact @sindresorhus/tsconfig - run: echo "$IMPORT_STATEMENT" > index.ts From 6d38ee726a8d82082d578d25298950eadf1b2649 Mon Sep 17 00:00:00 2001 From: fregante Date: Mon, 12 Jan 2026 19:51:12 +0700 Subject: [PATCH 12/19] Discard changes to .github/workflows/demo.yml --- .github/workflows/demo.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 763db826..63446901 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -16,9 +16,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: package.json - run: npm ci - run: npm run build:demo - run: npm run test:demo From 65e3e42d33ae2376c86c3fe0c2903c5a591aee9e Mon Sep 17 00:00:00 2001 From: fregante Date: Mon, 12 Jan 2026 19:52:12 +0700 Subject: [PATCH 13/19] Discard changes to .github/workflows/ci.yml --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5378b6f..fab2b83e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: package.json - run: npm ci - run: npm run build - name: Ensure that test URLs aren't included in the built file From 3e9eb424f4d5b552f1fb4c708266ace46f3f0020 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 03:33:43 +0000 Subject: [PATCH 14/19] Add distribution folder back to .gitignore and remove tracked files - Added 'distribution' back to .gitignore - Removed distribution files from git tracking (using git rm --cached) - Distribution files will be generated during build but not committed to version control Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- .gitignore | 1 + distribution/collector.d.ts | 5 - distribution/index.d.ts | 164 ---------------- distribution/index.js | 355 ----------------------------------- distribution/index.test.d.ts | 1 - 5 files changed, 1 insertion(+), 525 deletions(-) delete mode 100644 distribution/collector.d.ts delete mode 100644 distribution/index.d.ts delete mode 100644 distribution/index.js delete mode 100644 distribution/index.test.d.ts diff --git a/.gitignore b/.gitignore index 03721dd4..46cb338c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ Thumbs.db *.log logs *.map +distribution dist .cache .parcel-cache diff --git a/distribution/collector.d.ts b/distribution/collector.d.ts deleted file mode 100644 index 86aafcc7..00000000 --- a/distribution/collector.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** @file This needs to be in a separate file so it can bee tree-shaken before being published, while still being importable by tests */ -export declare const testableUrls: Map; -export declare function addTests(test: string, urls: string[]): void; -export declare function getTests(detectName: string): string[]; -export declare function getAllUrls(): Set; diff --git a/distribution/index.d.ts b/distribution/index.d.ts deleted file mode 100644 index c0a29955..00000000 --- a/distribution/index.d.ts +++ /dev/null @@ -1,164 +0,0 @@ -export declare const is404: () => boolean; -export declare const is500: () => boolean; -export declare const isPasswordConfirmation: () => boolean; -export declare const isLoggedIn: () => boolean; -export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isCompare: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isCompareWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isDashboard: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEnterprise: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGist: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGlobalIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGlobalSearchResults: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isLabelList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isMilestone: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isMilestoneList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewIssue: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNotifications: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isOrganizationProfile: () => boolean; -export declare const isOrganizationRepo: () => boolean; -export declare const isTeamDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isOwnUserProfile: () => boolean; -export declare const isOwnOrganizationProfile: () => boolean; -export declare const isProject: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isProjects: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewDiscussion: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isDiscussionList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPR: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRConflicts: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */ -export declare const isPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRCommit404: () => boolean; -export declare const isPRFile404: () => boolean; -export declare const isPRConversation: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isPRFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isQuickPR: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isMergedPR: () => boolean; -export declare const isDraftPR: () => boolean; -export declare const isOpenConversation: () => boolean; -export declare const isClosedConversation: () => boolean; -export declare const isReleases: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isTags: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isSingleReleaseOrTag: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isReleasesOrTags: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isDeletingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEditingFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasFileEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEditingRelease: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasReleaseEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEditingWikiPage: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasWikiPageEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasRepoHeader: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isEmptyRepoRoot: () => boolean; -export declare const isEmptyRepo: () => boolean; -export declare const isPublicRepo: () => boolean; -export declare const isArchivedRepo: () => boolean; -export declare const isBlank: () => boolean; -export declare const isRepoTaxonomyIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoIssueOrPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoPRList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoIssueList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoHome: (url?: URL | HTMLAnchorElement | Location) => boolean; -export type RepoExplorerInfo = { - nameWithOwner: string; - branch: string; - filePath: string; -}; -export declare const isRepoRoot: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoSearch: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoMainSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepliesSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserSettings: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoTree: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoWiki: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isSingleCommit: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isSingleFile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isFileFinder: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** - * @example https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea - * @example https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx - */ -export declare const isRepoFile404: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoForksList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepoNetworkGraph: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isForkedRepo: () => boolean; -export declare const isForkingRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isSingleGist: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGistRevision: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isTrending: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isBranches: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isGistProfile: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserProfile: () => boolean; -export declare const isPrivateUserProfile: () => boolean; -export declare const isUserProfileMainTab: () => boolean; -export declare const isUserProfileRepoTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserProfileStarsTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserProfileFollowersTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserProfileFollowingTab: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isProfileRepoList: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasComments: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const hasRichTextEditor: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Static code, not the code editor */ -export declare const hasCode: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Covers blob, trees and blame pages */ -export declare const isRepoGitObject: (url?: URL | HTMLAnchorElement | Location) => boolean; -/** Has a list of files */ -export declare const hasFiles: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isMarketplaceAction: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isActionJobRun: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isActionRun: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewAction: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isRepositoryActions: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isUserTheOrganizationOwner: () => boolean; -export declare const canUserAdminRepo: () => boolean; -/** @deprecated Use `canUserAdminRepo` */ -export declare const canUserEditRepo: () => boolean; -export declare const isNewRepo: (url?: URL | HTMLAnchorElement | Location) => boolean; -export declare const isNewRepoTemplate: (url?: URL | HTMLAnchorElement | Location) => boolean; -export type NameWithOwner = `${string}/${string}`; -export type RepositoryInfo = { - /** The repo owner/user */ - owner: string; - /** The repo name */ - name: string; - /** The 'user/repo' part from an URL */ - nameWithOwner: NameWithOwner; - /** A repo's subpage - @example '/user/repo/issues/' -> 'issues' - @example '/user/repo/' -> '' - @example '/settings/token/' -> undefined */ - path: string; - /** The `path` segments - @example '/user/repo/' -> [] - @example '/user/repo/issues/' -> ['issues'] - @example '/user/repo/issues/new' -> ['issues', 'new'] */ - pathParts: string[]; -}; -export declare const utils: { - getOrg: (url?: URL | HTMLAnchorElement | Location) => { - name: string; - path: string; - } | undefined; - /** @deprecated Use `getLoggedInUser` */ - getUsername: () => string | undefined; - getLoggedInUser: () => string | undefined; - getCleanPathname: (url?: URL | HTMLAnchorElement | Location) => string; - getCleanGistPathname: (url?: URL | HTMLAnchorElement | Location) => string | undefined; - getRepositoryInfo: (url?: URL | HTMLAnchorElement | Location | string) => RepositoryInfo | undefined; - parseRepoExplorerTitle: (pathname: string, title: string) => RepoExplorerInfo | undefined; -}; diff --git a/distribution/index.js b/distribution/index.js deleted file mode 100644 index 68830218..00000000 --- a/distribution/index.js +++ /dev/null @@ -1,355 +0,0 @@ -// index.ts -import reservedNames from "github-reserved-names/reserved-names.json" with { type: "json" }; -var $ = (selector) => document.querySelector(selector); -var exists = (selector) => Boolean($(selector)); -var is404 = () => /^(Page|File) not found · GitHub/.test(document.title); -var is500 = () => document.title === "Server Error \xB7 GitHub" || document.title === "Unicorn! \xB7 GitHub" || document.title === "504 Gateway Time-out"; -var isPasswordConfirmation = () => document.title === "Confirm password" || document.title === "Confirm access"; -var isLoggedIn = () => exists("body.logged-in"); -var isBlame = (url = location) => Boolean(getRepo(url)?.path.startsWith("blame/")); -var isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url); -var isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url); -var isRepoCommitList = (url = location) => Boolean(getRepo(url)?.path.startsWith("commits")); -var isCompare = (url = location) => Boolean(getRepo(url)?.path.startsWith("compare")); -var isCompareWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).split("/").slice(3, 5).includes("_compare"); -var isDashboard = (url = location) => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url)); -var isEnterprise = (url = location) => url.hostname !== "github.com" && url.hostname !== "gist.github.com"; -var isGist = (url = location) => typeof getCleanGistPathname(url) === "string"; -var isGlobalIssueOrPRList = (url = location) => ["issues", "pulls"].includes(url.pathname.split("/", 2)[1]); -var isGlobalSearchResults = (url = location) => url.pathname === "/search" && new URLSearchParams(url.search).get("q") !== null; -var isIssue = (url = location) => /^issues\/\d+/.test(getRepo(url)?.path) && document.title !== "GitHub \xB7 Where software is built"; -var isIssueOrPRList = (url = location) => isGlobalIssueOrPRList(url) || isRepoIssueOrPRList(url) || isMilestone(url); -var isConversation = (url = location) => isIssue(url) || isPRConversation(url); -var isLabelList = (url = location) => getRepo(url)?.path === "labels"; -var isMilestone = (url = location) => /^milestone\/\d+/.test(getRepo(url)?.path); -var isMilestoneList = (url = location) => getRepo(url)?.path === "milestones"; -var isNewFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("new")); -var isNewIssue = (url = location) => getRepo(url)?.path === "issues/new"; -var isNewRelease = (url = location) => getRepo(url)?.path === "releases/new"; -var isNewWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_new"); -var isNotifications = (url = location) => getCleanPathname(url) === "notifications"; -var isOrganizationProfile = () => exists('meta[name="hovercard-subject-tag"][content^="organization"]'); -var isOrganizationRepo = () => exists('.AppHeader-context-full [data-hovercard-type="organization"]'); -var isTeamDiscussion = (url = location) => Boolean(getOrg(url)?.path.startsWith("teams")); -var isOwnUserProfile = () => getCleanPathname() === getLoggedInUser(); -var isOwnOrganizationProfile = () => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]'); -var isProject = (url = location) => /^projects\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path); -var isProjects = (url = location) => getRepo(url)?.path === "projects"; -var isDiscussion = (url = location) => /^discussions\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path); -var isNewDiscussion = (url = location) => getRepo(url)?.path === "discussions/new" || getOrg(url)?.path === "discussions/new"; -var isDiscussionList = (url = location) => getRepo(url)?.path === "discussions" || getOrg(url)?.path === "discussions"; -var isPR = (url = location) => /^pull\/\d+/.test(getRepo(url)?.path) && !isPRConflicts(url); -var isPRConflicts = (url = location) => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path); -var isPRList = (url = location) => url.pathname === "/pulls" || getRepo(url)?.path === "pulls"; -var isPRCommit = (url = location) => /^pull\/\d+\/(commits|changes)\/[\da-f]{7,40}$/.test(getRepo(url)?.path); -var isPRCommit404 = () => isPRCommit() && document.title.startsWith("Commit range not found \xB7 Pull Request"); -var isPRFile404 = () => isPRFiles() && document.title.startsWith("Commit range not found \xB7 Pull Request"); -var isPRConversation = (url = location) => /^pull\/\d+$/.test(getRepo(url)?.path); -var isPRCommitList = (url = location) => /^pull\/\d+\/commits$/.test(getRepo(url)?.path); -var isPRFiles = (url = location) => /^pull\/\d+\/(files|(changes(\/[\da-f]{7,40}..[\da-f]{7,40})?$))/.test(getRepo(url)?.path) || isPRCommit(url); -var isQuickPR = (url = location) => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search); -var getStateLabel = () => $([ - ".State", - // Old view - '[class^="StateLabel"]' - // React version -].join(","))?.textContent?.trim(); -var isMergedPR = () => getStateLabel() === "Merged"; -var isDraftPR = () => getStateLabel() === "Draft"; -var isOpenConversation = () => { - const status = getStateLabel(); - return status === "Open" || status === "Draft"; -}; -var isClosedConversation = () => { - const status = getStateLabel(); - return status === "Closed" || status === "Closed as not planned" || status === "Merged"; -}; -var isReleases = (url = location) => getRepo(url)?.path === "releases"; -var isTags = (url = location) => getRepo(url)?.path === "tags"; -var isSingleReleaseOrTag = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/tag")); -var isReleasesOrTags = (url = location) => isReleases(url) || isTags(url); -var isDeletingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("delete")); -var isEditingFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("edit")); -var hasFileEditor = (url = location) => isEditingFile(url) || isNewFile(url) || isDeletingFile(url); -var isEditingRelease = (url = location) => Boolean(getRepo(url)?.path.startsWith("releases/edit")); -var hasReleaseEditor = (url = location) => isEditingRelease(url) || isNewRelease(url); -var isEditingWikiPage = (url = location) => isRepoWiki(url) && getCleanPathname(url).endsWith("/_edit"); -var hasWikiPageEditor = (url = location) => isEditingWikiPage(url) || isNewWikiPage(url); -var isRepo = (url = location) => { - const [user, repo, extra] = getCleanPathname(url).split("/"); - return Boolean( - user && repo && !reservedNames.includes(user) && !url.hostname.startsWith("gist.") && extra !== "generate" - // Like isNewRepoTemplate but inlined for performance - ); -}; -var hasRepoHeader = (url = location) => isRepo(url) && !isRepoSearch(url); -var isEmptyRepoRoot = () => isRepoHome() && !exists('link[rel="canonical"]'); -var isEmptyRepo = () => exists('[aria-label="Cannot fork because repository is empty."]'); -var isPublicRepo = () => exists('meta[name="octolytics-dimension-repository_public"][content="true"]'); -var isArchivedRepo = () => Boolean(isRepo() && $("main > .flash-warn")?.textContent.includes("archived")); -var isBlank = () => exists("main .blankslate:not([hidden] .blankslate)"); -var isRepoTaxonomyIssueOrPRList = (url = location) => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path); -var isRepoIssueOrPRList = (url = location) => isRepoPRList(url) || isRepoIssueList(url) || isRepoTaxonomyIssueOrPRList(url); -var isRepoPRList = (url = location) => Boolean(getRepo(url)?.path.startsWith("pulls")); -var isRepoIssueList = (url = location) => ( - // `issues/fregante` is a list but `issues/1`, `issues/new`, `issues/new/choose`, `issues/templates/edit` aren’t - /^labels\/|^issues(?!\/(\d+|new|templates)($|\/))/.test(getRepo(url)?.path) -); -var hasSearchParameter = (url) => new URLSearchParams(url.search).get("search") === "1"; -var isRepoHome = (url = location) => getRepo(url)?.path === "" && !hasSearchParameter(url); -var titleParseRegex = /^(?:(?[^ ]+) at (?[^ ]+)|[^/ ]+(?:\/(?[^ ]*))? at (?[^ ]+)(?: · (?[^ ]+))?)$/; -var parseRepoExplorerTitle = (pathname, title) => { - const match = titleParseRegex.exec(title); - if (!match?.groups) { - return; - } - let { nameWithOwner, branch, filePath, nameWithOwner2, branch2 } = match.groups; - nameWithOwner ??= nameWithOwner2; - branch ??= branch2; - filePath ??= ""; - if (!nameWithOwner || !branch || !pathname.startsWith(`/${nameWithOwner}/tree/`)) { - return; - } - return { nameWithOwner, branch, filePath }; -}; -var _isRepoRoot = (url) => { - const repository = getRepo(url ?? location); - if (!repository) { - return false; - } - const path = repository.path ? repository.path.split("/") : []; - switch (path.length) { - case 0: { - return true; - } - case 2: { - return path[0] === "tree"; - } - default: { - if (url) { - return false; - } - const titleInfo = parseRepoExplorerTitle(location.pathname, document.title); - return titleInfo?.filePath === ""; - } - } -}; -var isRepoRoot = (url) => !hasSearchParameter(url ?? location) && _isRepoRoot(url); -var isRepoSearch = (url = location) => getRepo(url)?.path === "search"; -var isRepoSettings = (url = location) => Boolean(getRepo(url)?.path.startsWith("settings")); -var isRepoMainSettings = (url = location) => getRepo(url)?.path === "settings"; -var isRepliesSettings = (url = location) => url.pathname.startsWith("/settings/replies"); -var isUserSettings = (url = location) => url.pathname.startsWith("/settings/"); -var isRepoTree = (url = location) => _isRepoRoot(url) || Boolean(getRepo(url)?.path.startsWith("tree/")); -var isRepoWiki = (url = location) => Boolean(getRepo(url)?.path.startsWith("wiki")); -var isSingleCommit = (url = location) => /^commit\/[\da-f]{5,40}$/.test(getRepo(url)?.path); -var isSingleFile = (url = location) => Boolean(getRepo(url)?.path.startsWith("blob/")); -var isFileFinder = (url = location) => Boolean(getRepo(url)?.path.startsWith("find/")); -var isRepoFile404 = (url = location) => (isSingleFile(url) || isRepoTree(url)) && document.title.startsWith("File not found"); -var isRepoForksList = (url = location) => getRepo(url)?.path === "network/members"; -var isRepoNetworkGraph = (url = location) => getRepo(url)?.path === "network"; -var isForkedRepo = () => exists('meta[name="octolytics-dimension-repository_is_fork"][content="true"]'); -var isForkingRepo = (url = location) => getRepo(url)?.path === "fork"; -var isSingleGist = (url = location) => /^[^/]+\/[\da-f]{20,32}(\/[\da-f]{40})?$/.test(getCleanGistPathname(url)); -var isGistRevision = (url = location) => /^[^/]+\/[\da-f]{20,32}\/revisions$/.test(getCleanGistPathname(url)); -var isTrending = (url = location) => url.pathname === "/trending" || url.pathname.startsWith("/trending/"); -var isBranches = (url = location) => Boolean(getRepo(url)?.path.startsWith("branches")); -var doesLookLikeAProfile = (string) => typeof string === "string" && string.length > 0 && !string.includes("/") && !string.includes(".") && !reservedNames.includes(string); -var isProfile = (url = location) => !isGist(url) && doesLookLikeAProfile(getCleanPathname(url)); -var isGistProfile = (url = location) => doesLookLikeAProfile(getCleanGistPathname(url)); -var isUserProfile = () => isProfile() && !isOrganizationProfile(); -var isPrivateUserProfile = () => isUserProfile() && !exists('.UnderlineNav-item[href$="tab=stars"]'); -var isUserProfileMainTab = () => isUserProfile() && !new URLSearchParams(location.search).has("tab"); -var isUserProfileRepoTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "repositories"; -var isUserProfileStarsTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "stars"; -var isUserProfileFollowersTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "followers"; -var isUserProfileFollowingTab = (url = location) => isProfile(url) && new URLSearchParams(url.search).get("tab") === "following"; -var isProfileRepoList = (url = location) => isUserProfileRepoTab(url) || getOrg(url)?.path === "repositories"; -var hasComments = (url = location) => isPR(url) || isIssue(url) || isCommit(url) || isTeamDiscussion(url) || isSingleGist(url); -var hasRichTextEditor = (url = location) => hasComments(url) || isNewIssue(url) || isCompare(url) || isRepliesSettings(url) || hasReleaseEditor(url) || isDiscussion(url) || isNewDiscussion(url); -var hasCode = (url = location) => hasComments(url) || isRepoTree(url) || isRepoSearch(url) || isGlobalSearchResults(url) || isSingleFile(url) || isGist(url) || isCompare(url) || isCompareWikiPage(url) || isBlame(url); -var isRepoGitObject = (url = location) => isRepo(url) && [void 0, "blob", "tree", "blame"].includes(getCleanPathname(url).split("/")[2]); -var hasFiles = (url = location) => isCommit(url) || isCompare(url) || isPRFiles(url); -var isMarketplaceAction = (url = location) => url.pathname.startsWith("/marketplace/actions/"); -var isActionJobRun = (url = location) => Boolean(getRepo(url)?.path.startsWith("runs/")); -var isActionRun = (url = location) => /^(actions\/)?runs/.test(getRepo(url)?.path); -var isNewAction = (url = location) => getRepo(url)?.path === "actions/new"; -var isRepositoryActions = (url = location) => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path); -var isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[aria-label="Organization"] [data-tab-item="org-header-settings-tab"]'); -var canUserAdminRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]'); -var canUserEditRepo = canUserAdminRepo; -var isNewRepo = (url = location) => !isGist(url) && (url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url))); -var isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate"); -var getLoggedInUser = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0; -var getCleanPathname = (url = location) => url.pathname.replaceAll(/\/\/+/g, "/").replace(/\/$/, "").slice(1); -var getCleanGistPathname = (url = location) => { - const pathname = getCleanPathname(url); - if (url.hostname.startsWith("gist.")) { - return pathname; - } - const [gist, ...parts] = pathname.split("/"); - return gist === "gist" ? parts.join("/") : void 0; -}; -var getOrg = (url = location) => { - const [orgs, name, ...path] = getCleanPathname(url).split("/"); - if (orgs === "orgs" && name) { - return { name, path: path.join("/") }; - } - return void 0; -}; -var getRepo = (url) => { - if (!url) { - const canonical = $('[property="og:url"]'); - if (canonical) { - const canonicalUrl = new URL(canonical.content, location.origin); - if (getCleanPathname(canonicalUrl).toLowerCase() === getCleanPathname(location).toLowerCase()) { - url = canonicalUrl; - } - } - } - if (typeof url === "string") { - url = new URL(url, location.origin); - } - if (!isRepo(url)) { - return; - } - const [owner, name, ...pathParts] = getCleanPathname(url).split("/"); - return { - owner, - name, - pathParts, - nameWithOwner: `${owner}/${name}`, - path: pathParts.join("/") - }; -}; -var utils = { - getOrg, - /** @deprecated Use `getLoggedInUser` */ - getUsername: getLoggedInUser, - getLoggedInUser, - getCleanPathname, - getCleanGistPathname, - getRepositoryInfo: getRepo, - parseRepoExplorerTitle -}; -export { - canUserAdminRepo, - canUserEditRepo, - hasCode, - hasComments, - hasFileEditor, - hasFiles, - hasReleaseEditor, - hasRepoHeader, - hasRichTextEditor, - hasWikiPageEditor, - is404, - is500, - isActionJobRun, - isActionRun, - isArchivedRepo, - isBlame, - isBlank, - isBranches, - isClosedConversation, - isCommit, - isCommitList, - isCompare, - isCompareWikiPage, - isConversation, - isDashboard, - isDeletingFile, - isDiscussion, - isDiscussionList, - isDraftPR, - isEditingFile, - isEditingRelease, - isEditingWikiPage, - isEmptyRepo, - isEmptyRepoRoot, - isEnterprise, - isFileFinder, - isForkedRepo, - isForkingRepo, - isGist, - isGistProfile, - isGistRevision, - isGlobalIssueOrPRList, - isGlobalSearchResults, - isIssue, - isIssueOrPRList, - isLabelList, - isLoggedIn, - isMarketplaceAction, - isMergedPR, - isMilestone, - isMilestoneList, - isNewAction, - isNewDiscussion, - isNewFile, - isNewIssue, - isNewRelease, - isNewRepo, - isNewRepoTemplate, - isNewWikiPage, - isNotifications, - isOpenConversation, - isOrganizationProfile, - isOrganizationRepo, - isOwnOrganizationProfile, - isOwnUserProfile, - isPR, - isPRCommit, - isPRCommit404, - isPRCommitList, - isPRConflicts, - isPRConversation, - isPRFile404, - isPRFiles, - isPRList, - isPasswordConfirmation, - isPrivateUserProfile, - isProfile, - isProfileRepoList, - isProject, - isProjects, - isPublicRepo, - isQuickPR, - isReleases, - isReleasesOrTags, - isRepliesSettings, - isRepo, - isRepoCommitList, - isRepoFile404, - isRepoForksList, - isRepoGitObject, - isRepoHome, - isRepoIssueList, - isRepoIssueOrPRList, - isRepoMainSettings, - isRepoNetworkGraph, - isRepoPRList, - isRepoRoot, - isRepoSearch, - isRepoSettings, - isRepoTaxonomyIssueOrPRList, - isRepoTree, - isRepoWiki, - isRepositoryActions, - isSingleCommit, - isSingleFile, - isSingleGist, - isSingleReleaseOrTag, - isTags, - isTeamDiscussion, - isTrending, - isUserProfile, - isUserProfileFollowersTab, - isUserProfileFollowingTab, - isUserProfileMainTab, - isUserProfileRepoTab, - isUserProfileStarsTab, - isUserSettings, - isUserTheOrganizationOwner, - utils -}; diff --git a/distribution/index.test.d.ts b/distribution/index.test.d.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/distribution/index.test.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; From 8a4d8b58d0aa897ad45f90ed3ef8a3f4ac3e01c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 03:38:59 +0000 Subject: [PATCH 15/19] Add actions/setup-node to esm-lint Pack job only - Added actions/setup-node@v6 with node-version-file: package.json to the Pack job in esm-lint.yml - This ensures the Pack job uses Node 22.18+ as required for native TypeScript execution - Other jobs in esm-lint.yml remain unchanged as they download the pre-built artifact - Lint job in ci.yml already has setup-node configured correctly Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- .github/workflows/esm-lint.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/esm-lint.yml b/.github/workflows/esm-lint.yml index c6ee3154..fc82114a 100644 --- a/.github/workflows/esm-lint.yml +++ b/.github/workflows/esm-lint.yml @@ -19,6 +19,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version-file: package.json - run: npm install - run: npm run build --if-present - run: npm pack --dry-run From 05a2e67de80fb61a12e0feeb73c61e086b3d5c94 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 04:09:26 +0000 Subject: [PATCH 16/19] Fix build and lint errors for Node 24 compatibility - Changed imports in add-examples-to-dts.ts from .ts to .js extensions (required for Node's native TypeScript support) - Fixed ESLint errors: added unicorn/no-process-exit to disabled rules, updated import-x/no-unassigned-import rule - Removed index.test.ts from tsconfig.json include array to prevent TypeScript compilation errors with node:assert/strict - Test file doesn't need to be included in declaration generation since it's only used by vitest Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- add-examples-to-dts.ts | 8 ++++---- tsconfig.json | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts index 5105c303..7079b8be 100644 --- a/add-examples-to-dts.ts +++ b/add-examples-to-dts.ts @@ -1,11 +1,11 @@ -/* eslint-disable n/prefer-global/process */ +/* eslint-disable n/prefer-global/process, unicorn/no-process-exit */ import {readFileSync, writeFileSync} from 'node:fs'; import {execSync} from 'node:child_process'; // Import index.ts to populate the test data via side effect -// eslint-disable-next-line import/no-unassigned-import, n/file-extension-in-import -import './index.ts'; +// eslint-disable-next-line n/file-extension-in-import, import-x/no-unassigned-import +import './index.js'; // eslint-disable-next-line n/file-extension-in-import -import {getTests} from './collector.ts'; +import {getTests} from './collector.js'; // Read the generated .d.ts file const dtsPath = './distribution/index.d.ts'; diff --git a/tsconfig.json b/tsconfig.json index abfa2ba1..f1a1e0d1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,6 @@ }, "include": [ "index.ts", - "index.test.ts", "global.d.ts", "collector.ts" ] From 4d8dadc1f6941b03fcdf472eb9307557beee570f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 13 Jan 2026 04:47:20 +0000 Subject: [PATCH 17/19] Revert incorrect changes and properly fix ESLint issues - Reverted imports back to .ts extensions (Node's TypeScript support requires .ts extensions, not .js) - Re-added index.test.ts to tsconfig.json include array for proper type checking - Fixed ESLint issues: changed import/no-unassigned-import to import-x/no-unassigned-import and added unicorn/no-process-exit to disabled rules - Re-added --experimental-strip-types flag to postbuild:typescript script (required for Node 22+ to run TypeScript files) Co-authored-by: fregante <1402241+fregante@users.noreply.github.com> --- add-examples-to-dts.ts | 6 +++--- package.json | 2 +- tsconfig.json | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts index 7079b8be..9132a7e3 100644 --- a/add-examples-to-dts.ts +++ b/add-examples-to-dts.ts @@ -2,10 +2,10 @@ import {readFileSync, writeFileSync} from 'node:fs'; import {execSync} from 'node:child_process'; // Import index.ts to populate the test data via side effect -// eslint-disable-next-line n/file-extension-in-import, import-x/no-unassigned-import -import './index.js'; +// eslint-disable-next-line import-x/no-unassigned-import, n/file-extension-in-import +import './index.ts'; // eslint-disable-next-line n/file-extension-in-import -import {getTests} from './collector.js'; +import {getTests} from './collector.ts'; // Read the generated .d.ts file const dtsPath = './distribution/index.d.ts'; diff --git a/package.json b/package.json index 2e35f891..32edec99 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "build": "run-p build:*", "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST", "build:typescript": "tsc --declaration --emitDeclarationOnly", - "postbuild:typescript": "node add-examples-to-dts.ts", + "postbuild:typescript": "node --experimental-strip-types add-examples-to-dts.ts", "build:demo": "vite build demo", "try": "esbuild index.ts --bundle --global-name=x --format=iife | pbcopy && echo 'Copied to clipboard'", "fix": "xo --fix", diff --git a/tsconfig.json b/tsconfig.json index f1a1e0d1..abfa2ba1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ }, "include": [ "index.ts", + "index.test.ts", "global.d.ts", "collector.ts" ] From dbbf8838f86096b8c1be2c0f9ed8609d66fef5eb Mon Sep 17 00:00:00 2001 From: Federico Date: Wed, 14 Jan 2026 14:46:28 +0700 Subject: [PATCH 18/19] Fix what copilot couldn't --- add-examples-to-dts.ts | 3 +-- index.ts | 2 +- package.json | 4 ++-- tsconfig.json | 6 ++---- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/add-examples-to-dts.ts b/add-examples-to-dts.ts index 9132a7e3..4c03c060 100644 --- a/add-examples-to-dts.ts +++ b/add-examples-to-dts.ts @@ -2,9 +2,8 @@ import {readFileSync, writeFileSync} from 'node:fs'; import {execSync} from 'node:child_process'; // Import index.ts to populate the test data via side effect -// eslint-disable-next-line import-x/no-unassigned-import, n/file-extension-in-import +// eslint-disable-next-line import-x/no-unassigned-import import './index.ts'; -// eslint-disable-next-line n/file-extension-in-import import {getTests} from './collector.ts'; // Read the generated .d.ts file diff --git a/index.ts b/index.ts index 7e688a9e..18bfef0a 100644 --- a/index.ts +++ b/index.ts @@ -1,5 +1,5 @@ import reservedNames from 'github-reserved-names/reserved-names.json' with {type: 'json'}; -import {addTests} from './collector.js'; +import {addTests} from './collector.ts'; const $ = (selector: string) => document.querySelector(selector); const exists = (selector: string) => Boolean($(selector)); diff --git a/package.json b/package.json index 32edec99..c681b19f 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ "scripts": { "build": "run-p build:*", "build:esbuild": "esbuild index.ts --bundle --external:github-reserved-names --outdir=distribution --format=esm --drop-labels=TEST", - "build:typescript": "tsc --declaration --emitDeclarationOnly", - "postbuild:typescript": "node --experimental-strip-types add-examples-to-dts.ts", + "build:typescript": "tsc", + "postbuild:typescript": "node add-examples-to-dts.ts", "build:demo": "vite build demo", "try": "esbuild index.ts --bundle --global-name=x --format=iife | pbcopy && echo 'Copied to clipboard'", "fix": "xo --fix", diff --git a/tsconfig.json b/tsconfig.json index abfa2ba1..5a0a8aee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,8 @@ { "extends": "@sindresorhus/tsconfig", "compilerOptions": { - // TODO: Drop after https://github.com/sindresorhus/tsconfig/issues/29 - "resolveJsonModule": true, - "moduleResolution": "Node", - "module": "Preserve" + "emitDeclarationOnly": true, + "allowImportingTsExtensions": true }, "include": [ "index.ts", From 38539999d41b497113998fbeb079c912eade7cda Mon Sep 17 00:00:00 2001 From: Federico Date: Wed, 14 Jan 2026 14:50:31 +0700 Subject: [PATCH 19/19] Anytime now --- package-lock.json | 13 +++++-------- package.json | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7cd8b844..2ab4f431 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "devDependencies": { "@sindresorhus/tsconfig": "^8.1.0", "@sveltejs/vite-plugin-svelte": "^6.2.4", + "@types/node": "^25.0.8", "esbuild": "^0.27.2", "globals": "^17.0.0", "npm-run-all": "^4.1.5", @@ -1439,13 +1440,11 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "25.0.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.6.tgz", - "integrity": "sha512-NNu0sjyNxpoiW3YuVFfNz7mxSQ+S4X2G28uqg2s+CzoqoQjLPsWSbsFFyztIAqt2vb8kfEAsJNepMGPTxFDx3Q==", + "version": "25.0.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.8.tgz", + "integrity": "sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg==", "dev": true, "license": "MIT", - "optional": true, - "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -8189,9 +8188,7 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true, - "license": "MIT", - "optional": true, - "peer": true + "license": "MIT" }, "node_modules/unicorn-magic": { "version": "0.3.0", diff --git a/package.json b/package.json index c681b19f..65067444 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "devDependencies": { "@sindresorhus/tsconfig": "^8.1.0", "@sveltejs/vite-plugin-svelte": "^6.2.4", + "@types/node": "^25.0.8", "esbuild": "^0.27.2", "globals": "^17.0.0", "npm-run-all": "^4.1.5",