github-url-detection 8.1.1 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  export declare const is404: () => boolean;
2
2
  export declare const is500: () => boolean;
3
3
  export declare const isPasswordConfirmation: () => boolean;
4
+ export declare const isLoggedIn: () => boolean;
4
5
  export declare const isBlame: (url?: URL | HTMLAnchorElement | Location) => boolean;
5
6
  export declare const isCommit: (url?: URL | HTMLAnchorElement | Location) => boolean;
6
7
  export declare const isCommitList: (url?: URL | HTMLAnchorElement | Location) => boolean;
@@ -289,6 +289,7 @@ const exists = (selector) => Boolean($(selector));
289
289
  const is404 = () => /^(Page|File) not found · GitHub/.test(document.title);
290
290
  const is500 = () => document.title === "Server Error · GitHub" || document.title === "Unicorn! · GitHub" || document.title === "504 Gateway Time-out";
291
291
  const isPasswordConfirmation = () => document.title === "Confirm password" || document.title === "Confirm access";
292
+ const isLoggedIn = () => exists("body.logged-in");
292
293
  const isBlame = (url = location) => Boolean(getRepo(url)?.path.startsWith("blame/"));
293
294
  const isCommit = (url = location) => isSingleCommit(url) || isPRCommit(url);
294
295
  const isCommitList = (url = location) => isRepoCommitList(url) || isPRCommitList(url);
@@ -419,7 +420,7 @@ const isUserTheOrganizationOwner = () => isOrganizationProfile() && exists('[ari
419
420
  const canUserEditRepo = () => isRepo() && exists('.reponav-item[href$="/settings"], [data-tab-item$="settings-tab"]');
420
421
  const isNewRepo = (url = location) => url.pathname === "/new" || /^organizations\/[^/]+\/repositories\/new$/.test(getCleanPathname(url));
421
422
  const isNewRepoTemplate = (url = location) => Boolean(url.pathname.split("/")[3] === "generate");
422
- const getUsername = () => $('meta[name="user-login"]')?.getAttribute("content");
423
+ const getUsername = () => $('meta[name="user-login"]')?.getAttribute("content") ?? void 0;
423
424
  const getCleanPathname = (url = location) => url.pathname.replaceAll(/\/+/g, "/").slice(1, url.pathname.endsWith("/") ? -1 : void 0);
424
425
  const getCleanGistPathname = (url = location) => {
425
426
  const pathname = getCleanPathname(url);
@@ -513,6 +514,7 @@ export {
513
514
  isIssue,
514
515
  isIssueOrPRList,
515
516
  isLabelList,
517
+ isLoggedIn,
516
518
  isMarketplaceAction,
517
519
  isMergedPR,
518
520
  isMilestone,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-url-detection",
3
- "version": "8.1.1",
3
+ "version": "8.2.0",
4
4
  "description": "Which GitHub page are you on? Is it an issue? Is it a list? Perfect for your WebExtension or userscript.",
5
5
  "keywords": [
6
6
  "github",
@@ -27,15 +27,15 @@
27
27
  "build": "run-p build:*",
28
28
  "build:vite": "vite build",
29
29
  "build:typescript": "tsc --declaration --emitDeclarationOnly",
30
- "demo:build": "vite build demo",
31
- "demo:test": "svelte-check",
32
- "demo:watch": "vite preview demo & vite build demo --watch # vite serve isn't real",
30
+ "build:demo": "vite build demo",
33
31
  "prepack": "npm run build",
34
- "test": "run-p build test:unit xo",
35
- "test:unit": "bun test",
36
- "watch": "run-p watch:typescript demo:watch # vite watch doesn’t generate the lib, so just use the demo",
32
+ "test": "run-p build test:* xo",
33
+ "test:unit": "vitest",
34
+ "test:demo": "svelte-check",
35
+ "watch": "run-p watch:*",
37
36
  "watch:typescript": "tsc --watch --noEmit",
38
- "watch:test:unit": "run-p 'test:unit -- --watch' 'watch:typescript -- --watch'",
37
+ "watch:test:unit": "npm run test:unit -- --watch",
38
+ "watch:demo": "vite preview demo & npm run build:demo -- --watch # vite serve isn't real",
39
39
  "xo": "xo"
40
40
  },
41
41
  "xo": {
@@ -49,32 +49,23 @@
49
49
  ],
50
50
  "rules": {
51
51
  "@typescript-eslint/triple-slash-reference": "off",
52
- "@typescript-eslint/dot-notation": "off",
53
- "@typescript-eslint/no-non-null-assertion": "off",
54
- "@typescript-eslint/no-unsafe-member-access": "off",
55
- "@typescript-eslint/no-non-null-asserted-optional-chain": "off",
56
- "@typescript-eslint/naming-convention": "off",
57
- "n/prefer-global/process": "off"
52
+ "@typescript-eslint/naming-convention": "off"
58
53
  }
59
54
  }
60
- ],
61
- "rules": {
62
- "camelcase": "off"
63
- }
55
+ ]
64
56
  },
65
57
  "devDependencies": {
66
- "@sindresorhus/tsconfig": "^4.0.0",
67
- "@sveltejs/vite-plugin-svelte": "^2.4.6",
68
- "bun": "^1.0.3",
69
- "bun-types": "^1.0.3",
58
+ "@sindresorhus/tsconfig": "^5.0.0",
59
+ "@sveltejs/vite-plugin-svelte": "^3.1.1",
70
60
  "github-reserved-names": "^2.0.5",
71
61
  "npm-run-all": "^4.1.5",
72
62
  "strip-indent": "^4.0.0",
73
- "svelte": "^4.2.1",
74
- "svelte-check": "^3.5.2",
75
- "typescript": "^5.2.2",
76
- "vite": "^4.4.9",
77
- "xo": "^0.56.0"
63
+ "svelte": "^4.2.17",
64
+ "svelte-check": "^3.8.0",
65
+ "typescript": "^5.4.5",
66
+ "vite": "^5.2.12",
67
+ "vitest": "^1.6.0",
68
+ "xo": "^0.58.0"
78
69
  },
79
70
  "engines": {
80
71
  "node": ">=18"