From 36acc68ac4b821d6c5aa87bd6795042527e80d59 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 5 Jan 2023 17:13:36 +0800 Subject: [PATCH 01/57] refactor: disable useInspector for prod --- src/containers/StateInspector.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/containers/StateInspector.tsx b/src/containers/StateInspector.tsx index 7680d51..a3b3aea 100644 --- a/src/containers/StateInspector.tsx +++ b/src/containers/StateInspector.tsx @@ -1,6 +1,7 @@ import { PropsWithChildren, ReactIO } from 'common' import { IN_PRODUCTION_MODE } from 'env' import * as React from 'react' +import { noop } from 'utils/general' import { useStateIO } from 'utils/hooks/useStateIO' export type InspectorContextShape = ReactIO @@ -57,9 +58,11 @@ export const InspectorContextWrapper = IN_PRODUCTION_MODE ) } -export function useInspector(key: string, value: JSONValue) { - const $ = React.useContext(InspectorContext) - React.useEffect(() => { - $?.onChange(prev => ({ ...prev, [key]: value })) - }, [key, value]) // eslint-disable-line react-hooks/exhaustive-deps -} +export const useInspector = IN_PRODUCTION_MODE + ? noop + : function useInspector(key: string, value: JSONValue) { + const $ = React.useContext(InspectorContext) + React.useEffect(() => { + $?.onChange(prev => ({ ...prev, [key]: value })) + }, [key, value]) // eslint-disable-line react-hooks/exhaustive-deps + } From cb57e95e79fac73ef82aec753b7a483ba6227e69 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 5 Jan 2023 18:36:59 +0800 Subject: [PATCH 02/57] test: add empty project case --- __tests__/cases/non-parallel/empty-project.ts | 13 +++++++++++++ __tests__/cases/non-parallel/pjax.general.ts | 7 ++----- __tests__/utils.ts | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 __tests__/cases/non-parallel/empty-project.ts diff --git a/__tests__/cases/non-parallel/empty-project.ts b/__tests__/cases/non-parallel/empty-project.ts new file mode 100644 index 0000000..2f430f8 --- /dev/null +++ b/__tests__/cases/non-parallel/empty-project.ts @@ -0,0 +1,13 @@ +import { getTextContent, sleep } from '../../utils' + +describe(`in Gitako project page`, () => { + beforeAll(() => page.goto('https://github.com/GitakoExtension/test-empty')) + + it('should render error message', async () => { + await sleep(5000) + + expect(await getTextContent('#gitako-logo-mount-point .error-message')).toBe( + 'This project seems to be empty.', + ) + }) +}) diff --git a/__tests__/cases/non-parallel/pjax.general.ts b/__tests__/cases/non-parallel/pjax.general.ts index a30f51a..b827634 100644 --- a/__tests__/cases/non-parallel/pjax.general.ts +++ b/__tests__/cases/non-parallel/pjax.general.ts @@ -1,6 +1,7 @@ import { collapseFloatModeSidebar, expandFloatModeSidebar, + getTextContent, patientClick, selectFileTreeItem, sleep, @@ -32,10 +33,6 @@ describe(`in Gitako project page`, () => { page.goBack() await sleep(1000) - expect( - await page.evaluate( - () => document.querySelector('.final-path')?.textContent === 'analytics.ts', - ), - ).toBe(true) + expect(await getTextContent('.final-path')).toBe('analytics.ts') }) }) diff --git a/__tests__/utils.ts b/__tests__/utils.ts index 0e8dc1e..1a1278b 100644 --- a/__tests__/utils.ts +++ b/__tests__/utils.ts @@ -119,3 +119,7 @@ export async function collapseFloatModeSidebar() { }) await sleep(500) } + +export function getTextContent(query: string) { + return page.evaluate(query => document.querySelector(query)?.textContent, query) +} From 4982b9a1ca59bdd77ad19262d15906b7a98f00bc Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 5 Jan 2023 18:37:37 +0800 Subject: [PATCH 03/57] feat: add platform error parser --- src/platforms/Gitee/index.ts | 6 +++++- src/platforms/platform.d.ts | 1 + src/utils/hooks/useHandleNetworkError.ts | 17 +++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/platforms/Gitee/index.ts b/src/platforms/Gitee/index.ts index 0409b48..b65d2ba 100644 --- a/src/platforms/Gitee/index.ts +++ b/src/platforms/Gitee/index.ts @@ -1,6 +1,6 @@ import { GITEE_OAUTH } from 'env' import { Base64 } from 'js-base64' -import { platform } from 'platforms' +import { errors, platform } from 'platforms' import * as React from 'react' import { resolveGitModules } from 'utils/gitSubmodule' import { useAfterRedirect } from 'utils/hooks/useFastRedirect' @@ -180,6 +180,10 @@ export const Gitee: Platform = { usePlatformHooks() { useProgressBar() }, + mapErrorMessage: (error: Error) => + ({ + ['Only signed in user is allowed to call APIs.']: errors.BAD_CREDENTIALS, + }[error.message]), } export function useGiteeAttachCopySnippetButton(copySnippetButton: boolean) { diff --git a/src/platforms/platform.d.ts b/src/platforms/platform.d.ts index e47cac0..c5356e9 100644 --- a/src/platforms/platform.d.ts +++ b/src/platforms/platform.d.ts @@ -29,4 +29,5 @@ type Platform = { | void loadWithFastRedirect?(url: string, element: HTMLElement): boolean | void usePlatformHooks?(): void + mapErrorMessage?: (error: Error) => string | void } diff --git a/src/utils/hooks/useHandleNetworkError.ts b/src/utils/hooks/useHandleNetworkError.ts index 2e768ad..2138ed8 100644 --- a/src/utils/hooks/useHandleNetworkError.ts +++ b/src/utils/hooks/useHandleNetworkError.ts @@ -1,5 +1,5 @@ import { useConfigs } from 'containers/ConfigsContext' -import { errors, platformName } from 'platforms' +import { errors, platform, platformName } from 'platforms' import { useCallback } from 'react' import { useLoadedContext } from 'utils/hooks/useLoadedContext' import { SideBarErrorContext } from '../../containers/ErrorContext' @@ -12,33 +12,34 @@ export function useHandleNetworkError() { return useCallback( function handleNetworkError(err: Error) { - if (err.message === errors.EMPTY_PROJECT) { + const message = platform.mapErrorMessage?.(err) || err.message + if (message === errors.EMPTY_PROJECT) { changeErrorContext('This project seems to be empty.') return } - if (err.message === errors.BLOCKED_PROJECT) { + if (message === errors.BLOCKED_PROJECT) { changeErrorContext('Access to the project is blocked.') return } if ( - err.message === errors.NOT_FOUND || - err.message === errors.BAD_CREDENTIALS || - err.message === errors.API_RATE_LIMIT + message === errors.NOT_FOUND || + message === errors.BAD_CREDENTIALS || + message === errors.API_RATE_LIMIT ) { changeStateContext('error-due-to-auth') return } - if (err.message === errors.CONNECTION_BLOCKED) { + if (message === errors.CONNECTION_BLOCKED) { if (accessToken) changeErrorContext(`Cannot connect to ${platformName}.`) else changeStateContext('error-due-to-auth') return } - if (err.message === errors.SERVER_FAULT) { + if (message === errors.SERVER_FAULT) { changeErrorContext(`${platformName} server went down.`) return } From a1853ec3d24449672f5f7926566bc35c4c0306e0 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 5 Jan 2023 18:38:04 +0800 Subject: [PATCH 04/57] fix: disallow expand on error --- src/components/SideBar.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/SideBar.tsx b/src/components/SideBar.tsx index cdc2179..d6c88fa 100644 --- a/src/components/SideBar.tsx +++ b/src/components/SideBar.tsx @@ -278,18 +278,21 @@ function useCollapseOnNoPermissionWhenTokenHasBeenSet( function useShouldExpand() { const getDerivedExpansion = useGetDerivedExpansion() + const error = useLoadedContext(SideBarErrorContext).value const [shouldExpand, setShouldExpand] = React.useState(getDerivedExpansion) const toggleShowSideBar = React.useCallback( () => setShouldExpand(show => !show), [setShouldExpand], ) - useSaveExpandStateOnToggle(shouldExpand) - useUpdateBodyIndentOnStateUpdate(shouldExpand) + const $shouldExpand = error ? false : shouldExpand + + useSaveExpandStateOnToggle($shouldExpand) + useUpdateBodyIndentOnStateUpdate($shouldExpand) useUpdateBodyIndentAfterRedirect(setShouldExpand) useCollapseOnNoPermissionWhenTokenHasBeenSet(setShouldExpand) - return [shouldExpand, setShouldExpand, toggleShowSideBar] as const + return [$shouldExpand, setShouldExpand, toggleShowSideBar] as const } function useShowSidebarKeyboard( From 593ba275579c49f3fa78090f5109e7b891bb6fa5 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 5 Jan 2023 18:39:00 +0800 Subject: [PATCH 05/57] refactor: raise error context higher than state context fixes #275 --- src/components/Gitako.tsx | 8 ++--- src/components/SideBar.tsx | 46 ++++++++++++++++++----------- src/components/ToggleShowButton.tsx | 7 +++-- src/containers/SideBarState.tsx | 22 ++++++++++---- 4 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/components/Gitako.tsx b/src/components/Gitako.tsx index b3ce0ad..3151b60 100644 --- a/src/components/Gitako.tsx +++ b/src/components/Gitako.tsx @@ -18,15 +18,15 @@ export function Gitako() { - - + + - - + + diff --git a/src/components/SideBar.tsx b/src/components/SideBar.tsx index d6c88fa..8c30f9e 100644 --- a/src/components/SideBar.tsx +++ b/src/components/SideBar.tsx @@ -65,24 +65,12 @@ export function SideBar() { return ( + - - {() => { - const logoContainerElement = useLogoContainerElement() - return ( - - setShouldExpand(true) : undefined} - onClick={toggleShowSideBar} - /> - - ) - }} -
> + toggleShowSideBar: () => void +}) { + const logoContainerElement = useLogoContainerElement() + const { sidebarToggleMode } = useConfigs().value + return ( + + setShouldExpand(true) : undefined} + onClick={toggleShowSideBar} + /> + + ) +} + function useFocusSidebarOnExpand(shouldExpand: boolean) { React.useEffect(() => { // prevent keeping focus within Gitako diff --git a/src/components/ToggleShowButton.tsx b/src/components/ToggleShowButton.tsx index 5e23d19..11f83b4 100644 --- a/src/components/ToggleShowButton.tsx +++ b/src/components/ToggleShowButton.tsx @@ -1,15 +1,16 @@ import { SyncIcon } from '@primer/octicons-react' import iconURL from 'assets/icons/Gitako.png' import { useConfigs } from 'containers/ConfigsContext' +import { SideBarErrorContext } from 'containers/ErrorContext' import { ReloadContext } from 'containers/ReloadContext' import * as React from 'react' import { useDebounce, useWindowSize } from 'react-use' import { cx } from 'utils/cx' +import { useLoadedContext } from 'utils/hooks/useLoadedContext' import { useResizeHandler } from 'utils/hooks/useResizeHandler' import { RoundIconButton } from './RoundIconButton' type Props = { - error?: string | null className?: React.HTMLAttributes['className'] onHover?: React.HTMLAttributes['onMouseEnter'] onClick?: (e: PointerEvent) => void @@ -21,8 +22,10 @@ function getSafeDistance(y: number, height: number) { return Math.max(0, Math.min(y, height - buttonHeight)) } -export function ToggleShowButton({ error, className, onClick, onHover }: Props) { +export function ToggleShowButton({ className, onClick, onHover }: Props) { const reload = React.useContext(ReloadContext) + const error = useLoadedContext(SideBarErrorContext).value + const ref = React.useRef(null) const config = useConfigs() const [distance, setDistance] = React.useState(config.value.toggleButtonVerticalDistance) diff --git a/src/containers/SideBarState.tsx b/src/containers/SideBarState.tsx index d70816e..6030adf 100644 --- a/src/containers/SideBarState.tsx +++ b/src/containers/SideBarState.tsx @@ -1,6 +1,8 @@ import { PropsWithChildren } from 'common' import * as React from 'react' +import { useLoadedContext } from 'utils/hooks/useLoadedContext' import { useStateIO } from 'utils/hooks/useStateIO' +import { SideBarErrorContext } from './ErrorContext' import { useInspector } from './StateInspector' export type SideBarState = @@ -13,7 +15,8 @@ export type SideBarState = | 'tree-rendering' | 'tree-rendered' | 'idle' - | 'error-due-to-auth' + | 'error' // when error occurs, sidebar should never expand + | 'error-due-to-auth' // this is a special error, user can expand sidebar and set token to fix the error export type SideBarStateContextShape = IO @@ -22,10 +25,17 @@ export const SideBarStateContext = React.createContext('disabled') useInspector('SideBarStateContext', $state.value) - - return ( - - {$state.value !== null && children} - + const error = useLoadedContext(SideBarErrorContext).value + const $$state: IO = React.useMemo( + () => + error && $state.value !== 'error' + ? { + ...$state, + value: 'error', + } + : $state, + [$state, error], ) + + return {children} } From 9745d18b64a1313a5fb9f08ff721082b184b58c2 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Wed, 25 Jan 2023 22:33:01 +0800 Subject: [PATCH 06/57] build: upgrade formatter --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9c9d2b8..e4d4071 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "json-loader": "^0.5.7", "lint-staged": "^13.0.3", "mini-css-extract-plugin": "^0.9.0", - "prettier": "^2.7.1", + "prettier": "^2.8.3", "puppeteer": "^10.1.0", "raw-loader": "^4.0.0", "sass": "^1.26.2", diff --git a/yarn.lock b/yarn.lock index 116d425..56197ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9726,10 +9726,10 @@ prepend-http@^1.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= -prettier@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" - integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +prettier@^2.8.3: + version "2.8.3" + resolved "https://registry.npmmirror.com/prettier/-/prettier-2.8.3.tgz#ab697b1d3dd46fb4626fbe2f543afe0cc98d8632" + integrity sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw== pretty-format@^27.0.2, pretty-format@^27.5.1: version "27.5.1" From a9fb8b85b1da05d895f142881773dff9579d1550 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Wed, 25 Jan 2023 22:34:47 +0800 Subject: [PATCH 07/57] 3.10.1 --- Safari/Gitako/Gitako.xcodeproj/project.pbxproj | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Safari/Gitako/Gitako.xcodeproj/project.pbxproj b/Safari/Gitako/Gitako.xcodeproj/project.pbxproj index 7aba918..cc6bd8d 100644 --- a/Safari/Gitako/Gitako.xcodeproj/project.pbxproj +++ b/Safari/Gitako/Gitako.xcodeproj/project.pbxproj @@ -579,7 +579,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.0; + MARKETING_VERSION = 3.10.1; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako.Extension; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -604,7 +604,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.0; + MARKETING_VERSION = 3.10.1; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako.Extension; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -631,7 +631,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.0; + MARKETING_VERSION = 3.10.1; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Developer Sign for Distribution"; @@ -657,7 +657,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.0; + MARKETING_VERSION = 3.10.1; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Developer Sign for Distribution"; diff --git a/package.json b/package.json index e4d4071..8e4a526 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitako", - "version": "3.10.0", + "version": "3.10.1", "description": "File tree for GitHub, and more than that.", "repository": "https://github.com/EnixCoda/Gitako", "author": "EnixCoda", From c786222486038e7eaeea4aebf80d79c97274de06 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 26 Jan 2023 20:54:45 +0800 Subject: [PATCH 08/57] fix: take token for gitea --- src/platforms/Gitea/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/Gitea/index.ts b/src/platforms/Gitea/index.ts index 5b80c41..81b10a0 100644 --- a/src/platforms/Gitea/index.ts +++ b/src/platforms/Gitea/index.ts @@ -117,7 +117,7 @@ export const Gitea: Platform = { }, async getTreeData(metaData, path, recursive, accessToken) { const { userName, repoName, branchName } = metaData - const treeData = await API.getTreeData(userName, repoName, branchName, recursive) + const treeData = await API.getTreeData(userName, repoName, branchName, recursive, accessToken) const root = processTree( treeData.tree.map(item => ({ From 156c8c913e04155f92fc36baeb20aa4a74b72fc8 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Thu, 26 Jan 2023 20:59:27 +0800 Subject: [PATCH 09/57] 3.10.2 --- Safari/Gitako/Gitako.xcodeproj/project.pbxproj | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Safari/Gitako/Gitako.xcodeproj/project.pbxproj b/Safari/Gitako/Gitako.xcodeproj/project.pbxproj index cc6bd8d..d200176 100644 --- a/Safari/Gitako/Gitako.xcodeproj/project.pbxproj +++ b/Safari/Gitako/Gitako.xcodeproj/project.pbxproj @@ -579,7 +579,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.1; + MARKETING_VERSION = 3.10.2; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako.Extension; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -604,7 +604,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.1; + MARKETING_VERSION = 3.10.2; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako.Extension; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -631,7 +631,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.1; + MARKETING_VERSION = 3.10.2; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Developer Sign for Distribution"; @@ -657,7 +657,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.1; + MARKETING_VERSION = 3.10.2; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Developer Sign for Distribution"; diff --git a/package.json b/package.json index 8e4a526..14f6a89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitako", - "version": "3.10.1", + "version": "3.10.2", "description": "File tree for GitHub, and more than that.", "repository": "https://github.com/EnixCoda/Gitako", "author": "EnixCoda", From e5becfd4e2f453ba100196cd6fa76b26f9b9ef0e Mon Sep 17 00:00:00 2001 From: Enix Date: Sun, 29 Jan 2023 17:08:49 +0800 Subject: [PATCH 10/57] fix: try fragment selectors in order --- src/platforms/GitHub/API.ts | 6 +++--- src/platforms/GitHub/utils.ts | 26 +++++++++++++++----------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/platforms/GitHub/API.ts b/src/platforms/GitHub/API.ts index 7dbf825..3bc7ac0 100644 --- a/src/platforms/GitHub/API.ts +++ b/src/platforms/GitHub/API.ts @@ -2,7 +2,7 @@ import { errors } from 'platforms' import { isEnterprise } from '.' import { is } from '../../utils/is' import { gitakoServiceHost } from '../../utils/networkService' -import { continuousLoadPages, getDOM, resolveHeaderLink } from './utils' +import { continuousLoadFragmentedPages, getDOM, resolveHeaderLink } from './utils' function isAPIRateLimitExceeded(content: JSONValue) { return ( @@ -147,7 +147,7 @@ export async function getPullPageDocuments( document?: Document, ): Promise { // Response of this API contains view of few files but is not complete. - return continuousLoadPages( + return continuousLoadFragmentedPages( document || (await getDOM(`${window.location.origin}/${userName}/${repoName}/pull/${pullId}/files`)), ) @@ -158,7 +158,7 @@ export async function getCommitPageDocuments(): Promise { repoName: string, commitId: string, */ // arguments are not used because info are collected from DOM directly - return continuousLoadPages(document) + return continuousLoadFragmentedPages(document) } export async function getBlobData( diff --git a/src/platforms/GitHub/utils.ts b/src/platforms/GitHub/utils.ts index 7fdb54b..1852ed6 100644 --- a/src/platforms/GitHub/utils.ts +++ b/src/platforms/GitHub/utils.ts @@ -78,7 +78,7 @@ export async function getDOM(url: string) { return new DOMParser().parseFromString(await (await fetch(url)).text(), 'text/html') } -export async function continuousLoadPages(doc: Document, onReceivePage?: (doc: Document) => void) { +export async function continuousLoadFragmentedPages(doc: Document) { /** * doc.querySelector(selector)) + if (selector) { + // eslint-disable-next-line no-constant-condition + while (true) { + const fragment = doc.querySelector(selector) + if (!(fragment instanceof HTMLElement)) break + const src = fragment.getAttribute('src') + if (!src) break + // Using `src` without origin below would fail in Firefox if the src is an absolute path + doc = await getDOM(new URL(src, window.location.origin).href) + documents.push(doc) + } } return documents } From 13d4805bea0726d1830bd8600c6953ee38b85600 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Mon, 30 Jan 2023 11:18:40 +0800 Subject: [PATCH 11/57] 3.10.3 --- Safari/Gitako/Gitako.xcodeproj/project.pbxproj | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Safari/Gitako/Gitako.xcodeproj/project.pbxproj b/Safari/Gitako/Gitako.xcodeproj/project.pbxproj index d200176..facd676 100644 --- a/Safari/Gitako/Gitako.xcodeproj/project.pbxproj +++ b/Safari/Gitako/Gitako.xcodeproj/project.pbxproj @@ -579,7 +579,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.2; + MARKETING_VERSION = 3.10.3; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako.Extension; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -604,7 +604,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.2; + MARKETING_VERSION = 3.10.3; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako.Extension; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -631,7 +631,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.2; + MARKETING_VERSION = 3.10.3; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Developer Sign for Distribution"; @@ -657,7 +657,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 3.10.2; + MARKETING_VERSION = 3.10.3; PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "Developer Sign for Distribution"; diff --git a/package.json b/package.json index 14f6a89..a34597d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitako", - "version": "3.10.2", + "version": "3.10.3", "description": "File tree for GitHub, and more than that.", "repository": "https://github.com/EnixCoda/Gitako", "author": "EnixCoda", From 6c5328e6f34f2b515fa84fad26bbe42ceda248e8 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sat, 11 Feb 2023 00:03:06 +0800 Subject: [PATCH 12/57] chore: add shortcut hint for revealing search result in file tree --- src/components/FileExplorer/hooks/useNodeRenderers.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/FileExplorer/hooks/useNodeRenderers.tsx b/src/components/FileExplorer/hooks/useNodeRenderers.tsx index 58552e4..a65aefd 100644 --- a/src/components/FileExplorer/hooks/useNodeRenderers.tsx +++ b/src/components/FileExplorer/hooks/useNodeRenderers.tsx @@ -266,7 +266,7 @@ export function useRenderGoToButton(searched: boolean, goTo: (path: string[]) => ? function renderGoToButton(node: TreeNode): React.ReactNode { return (