roxxie-proxy-u-prod 0.1.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.
- package/LICENSE +661 -0
- package/README.md +123 -0
- package/SOURCE.md +29 -0
- package/THIRD_PARTY_NOTICES.md +24 -0
- package/dist/assets/filters-Bu_3nHVy.bin +0 -0
- package/dist/assets/index-BdRlQ7d_.css +1 -0
- package/dist/assets/index-DcvPYWS3.js +3621 -0
- package/dist/assets/inject-BnVzMVpl.js +40 -0
- package/dist/assets/scramjet-C9HLwI-y.wasm +0 -0
- package/dist/defaultfavicon.png +0 -0
- package/dist/icon.png +0 -0
- package/dist/roxxie-icon.svg +12 -0
- package/embed.js +70 -0
- package/examples/single-page.html +25 -0
- package/package.json +42 -0
- package/runtime/controller.sw.js +273 -0
- package/runtime/index.html +18 -0
- package/runtime/localcontrollersw.js +7 -0
- package/runtime/roxxie-network.json +13 -0
- package/runtime/sw.js +6 -0
- package/scripts/build.mjs +344 -0
- package/scripts/smoke.mjs +123 -0
- package/scripts/verify.mjs +122 -0
- package/source/external/dreamlandjs/LICENSE +21 -0
- package/source/external/dreamlandjs/README.md +22 -0
- package/source/external/dreamlandjs/dist/core.d.ts +167 -0
- package/source/external/dreamlandjs/dist/core.js +2 -0
- package/source/external/dreamlandjs/dist/core.js.map +1 -0
- package/source/external/dreamlandjs/dist/core.size.html +4950 -0
- package/source/external/dreamlandjs/dist/js-runtime.d.ts +3 -0
- package/source/external/dreamlandjs/dist/js-runtime.js +2 -0
- package/source/external/dreamlandjs/dist/js-runtime.js.map +1 -0
- package/source/external/dreamlandjs/dist/jsx-runtime.d.ts +1 -0
- package/source/external/dreamlandjs/dist/jsx-runtime.js +2 -0
- package/source/external/dreamlandjs/dist/jsx-runtime.js.map +1 -0
- package/source/external/dreamlandjs/dist/motion.d.ts +19 -0
- package/source/external/dreamlandjs/dist/motion.js +2 -0
- package/source/external/dreamlandjs/dist/motion.js.map +1 -0
- package/source/external/dreamlandjs/dist/router.d.ts +48 -0
- package/source/external/dreamlandjs/dist/router.js +2 -0
- package/source/external/dreamlandjs/dist/router.js.map +1 -0
- package/source/external/dreamlandjs/dist/ssr.client.d.ts +3 -0
- package/source/external/dreamlandjs/dist/ssr.client.js +2 -0
- package/source/external/dreamlandjs/dist/ssr.client.js.map +1 -0
- package/source/external/dreamlandjs/dist/ssr.client.size.html +4950 -0
- package/source/external/dreamlandjs/dist/ssr.hybrid.d.ts +7 -0
- package/source/external/dreamlandjs/dist/ssr.hybrid.js +2 -0
- package/source/external/dreamlandjs/dist/ssr.hybrid.js.map +1 -0
- package/source/external/dreamlandjs/dist/ssr.hybrid.size.html +4950 -0
- package/source/external/dreamlandjs/dist/ssr.server.d.ts +11 -0
- package/source/external/dreamlandjs/dist/ssr.server.js +2373 -0
- package/source/external/dreamlandjs/dist/ssr.server.js.map +1 -0
- package/source/external/dreamlandjs/dist/types/core/consts.d.ts +16 -0
- package/source/external/dreamlandjs/dist/types/core/css/index.d.ts +11 -0
- package/source/external/dreamlandjs/dist/types/core/css/selectorParser.d.ts +50 -0
- package/source/external/dreamlandjs/dist/types/core/delegate.d.ts +10 -0
- package/source/external/dreamlandjs/dist/types/core/index.d.ts +9 -0
- package/source/external/dreamlandjs/dist/types/core/jsx/child.d.ts +2 -0
- package/source/external/dreamlandjs/dist/types/core/jsx/definitions.d.ts +76 -0
- package/source/external/dreamlandjs/dist/types/core/jsx/dom.d.ts +28 -0
- package/source/external/dreamlandjs/dist/types/core/jsx/index.d.ts +14 -0
- package/source/external/dreamlandjs/dist/types/core/state/index.d.ts +1 -0
- package/source/external/dreamlandjs/dist/types/core/state/pointers.d.ts +37 -0
- package/source/external/dreamlandjs/dist/types/core/state/state.d.ts +13 -0
- package/source/external/dreamlandjs/dist/types/core/state/use.d.ts +11 -0
- package/source/external/dreamlandjs/dist/types/core/utils.d.ts +4 -0
- package/source/external/dreamlandjs/dist/types/js-runtime/index.d.ts +1 -0
- package/source/external/dreamlandjs/dist/types/jsx-runtime/index.d.ts +2 -0
- package/source/external/dreamlandjs/dist/types/motion/index.d.ts +15 -0
- package/source/external/dreamlandjs/dist/types/router/index.d.ts +45 -0
- package/source/external/dreamlandjs/dist/types/ssr/client/index.d.ts +1 -0
- package/source/external/dreamlandjs/dist/types/ssr/common/consts.d.ts +4 -0
- package/source/external/dreamlandjs/dist/types/ssr/common/serialize.d.ts +4 -0
- package/source/external/dreamlandjs/dist/types/ssr/common/types.d.ts +21 -0
- package/source/external/dreamlandjs/dist/types/ssr/hybrid/index.d.ts +4 -0
- package/source/external/dreamlandjs/dist/types/ssr/server/index.d.ts +7 -0
- package/source/external/dreamlandjs/dist/types/ssr/server/vdom.d.ts +71 -0
- package/source/external/dreamlandjs/dist/types/util/index.d.ts +1 -0
- package/source/external/dreamlandjs/dist/types/util/store.d.ts +26 -0
- package/source/external/dreamlandjs/dist/types/vite/css-minifier.d.ts +7 -0
- package/source/external/dreamlandjs/dist/types/vite/index.d.ts +11 -0
- package/source/external/dreamlandjs/dist/util.d.ts +29 -0
- package/source/external/dreamlandjs/dist/util.js +2 -0
- package/source/external/dreamlandjs/dist/util.js.map +1 -0
- package/source/external/dreamlandjs/dist/vite.d.ts +19 -0
- package/source/external/dreamlandjs/dist/vite.js +2 -0
- package/source/external/dreamlandjs/dist/vite.js.map +1 -0
- package/source/external/dreamlandjs/package.json +101 -0
- package/source/external/dreamlandjs/rollup.config.ts +302 -0
- package/source/external/dreamlandjs/rollup.plugins.ts +1134 -0
- package/source/external/dreamlandjs/src/core/consts.d.ts +16 -0
- package/source/external/dreamlandjs/src/core/consts.js +18 -0
- package/source/external/dreamlandjs/src/core/css/index.ts +111 -0
- package/source/external/dreamlandjs/src/core/css/selectorParser.ts +313 -0
- package/source/external/dreamlandjs/src/core/delegate.ts +28 -0
- package/source/external/dreamlandjs/src/core/index.ts +31 -0
- package/source/external/dreamlandjs/src/core/jsx/child.ts +91 -0
- package/source/external/dreamlandjs/src/core/jsx/definitions.ts +125 -0
- package/source/external/dreamlandjs/src/core/jsx/dom.ts +49 -0
- package/source/external/dreamlandjs/src/core/jsx/index.ts +289 -0
- package/source/external/dreamlandjs/src/core/state/index.ts +1 -0
- package/source/external/dreamlandjs/src/core/state/pointers.ts +310 -0
- package/source/external/dreamlandjs/src/core/state/state.ts +112 -0
- package/source/external/dreamlandjs/src/core/state/use.ts +82 -0
- package/source/external/dreamlandjs/src/core/utils.ts +48 -0
- package/source/external/dreamlandjs/src/js-runtime/index.ts +4 -0
- package/source/external/dreamlandjs/src/jsx-runtime/index.ts +3 -0
- package/source/external/dreamlandjs/src/motion/index.ts +156 -0
- package/source/external/dreamlandjs/src/router/index.tsx +394 -0
- package/source/external/dreamlandjs/src/router/tsconfig.json +9 -0
- package/source/external/dreamlandjs/src/ssr/client/index.ts +193 -0
- package/source/external/dreamlandjs/src/ssr/common/consts.ts +5 -0
- package/source/external/dreamlandjs/src/ssr/common/serialize.ts +115 -0
- package/source/external/dreamlandjs/src/ssr/common/types.ts +28 -0
- package/source/external/dreamlandjs/src/ssr/hybrid/index.ts +144 -0
- package/source/external/dreamlandjs/src/ssr/server/index.ts +157 -0
- package/source/external/dreamlandjs/src/ssr/server/tsconfig.json +7 -0
- package/source/external/dreamlandjs/src/ssr/server/vdom.ts +285 -0
- package/source/external/dreamlandjs/src/util/index.ts +10 -0
- package/source/external/dreamlandjs/src/util/store.ts +134 -0
- package/source/external/dreamlandjs/src/vite/css-minifier.ts +222 -0
- package/source/external/dreamlandjs/src/vite/index.ts +60 -0
- package/source/external/dreamlandjs/src/vite/tsconfig.json +7 -0
- package/source/external/dreamlandjs/tsconfig.json +15 -0
- package/source/package.json +48 -0
- package/source/packages/adrift-protocol/package.json +31 -0
- package/source/packages/adrift-protocol/src/index.ts +348 -0
- package/source/packages/adrift-protocol/tsconfig.json +18 -0
- package/source/packages/cdp/LICENSE +21 -0
- package/source/packages/cdp/README.md +47 -0
- package/source/packages/cdp/dist/chobitsu.js +2 -0
- package/source/packages/cdp/dist/chobitsu.js.map +1 -0
- package/source/packages/cdp/package.json +73 -0
- package/source/packages/cdp/script/build.js +15 -0
- package/source/packages/cdp/src/Chobitsu.ts +110 -0
- package/source/packages/cdp/src/domains/CSS.ts +378 -0
- package/source/packages/cdp/src/domains/CacheStorage.ts +8 -0
- package/source/packages/cdp/src/domains/DOM.ts +487 -0
- package/source/packages/cdp/src/domains/DOMDebugger.ts +109 -0
- package/source/packages/cdp/src/domains/DOMStorage.ts +122 -0
- package/source/packages/cdp/src/domains/Debugger.ts +25 -0
- package/source/packages/cdp/src/domains/IndexedDB.ts +207 -0
- package/source/packages/cdp/src/domains/Input.ts +177 -0
- package/source/packages/cdp/src/domains/Network.ts +251 -0
- package/source/packages/cdp/src/domains/Overlay.ts +230 -0
- package/source/packages/cdp/src/domains/Page.ts +296 -0
- package/source/packages/cdp/src/domains/Runtime.ts +273 -0
- package/source/packages/cdp/src/domains/Storage.ts +71 -0
- package/source/packages/cdp/src/index.d.ts +8 -0
- package/source/packages/cdp/src/index.ts +153 -0
- package/source/packages/cdp/src/lib/connector.ts +15 -0
- package/source/packages/cdp/src/lib/constants.ts +1 -0
- package/source/packages/cdp/src/lib/evaluate.ts +59 -0
- package/source/packages/cdp/src/lib/mutationObserver.ts +39 -0
- package/source/packages/cdp/src/lib/nodeManager.ts +142 -0
- package/source/packages/cdp/src/lib/objManager.ts +422 -0
- package/source/packages/cdp/src/lib/request.ts +313 -0
- package/source/packages/cdp/src/lib/resources.ts +59 -0
- package/source/packages/cdp/src/lib/scriptMananger.ts +62 -0
- package/source/packages/cdp/src/lib/stylesheet.ts +146 -0
- package/source/packages/cdp/src/lib/util.ts +105 -0
- package/source/packages/cdp/tsconfig.json +16 -0
- package/source/packages/cdp/webpack.config.js +48 -0
- package/source/packages/chrome/index.html +17 -0
- package/source/packages/chrome/package.json +41 -0
- package/source/packages/chrome/public/ROXXIE_NETWORK.md +22 -0
- package/source/packages/chrome/public/controller.sw.js +273 -0
- package/source/packages/chrome/public/defaultfavicon.png +0 -0
- package/source/packages/chrome/public/icon.png +0 -0
- package/source/packages/chrome/public/localcontrollersw.js +7 -0
- package/source/packages/chrome/public/roxxie-icon.svg +12 -0
- package/source/packages/chrome/public/roxxie-network.json +13 -0
- package/source/packages/chrome/public/sw.js +6 -0
- package/source/packages/chrome/src/App.tsx +269 -0
- package/source/packages/chrome/src/CDP.ts +285 -0
- package/source/packages/chrome/src/Tab/History.ts +186 -0
- package/source/packages/chrome/src/Tab/Tab.tsx +219 -0
- package/source/packages/chrome/src/Tab/screenshot.ts +66 -0
- package/source/packages/chrome/src/Tab/serialize.ts +221 -0
- package/source/packages/chrome/src/adblock/AdBlockPlugin.test.ts +159 -0
- package/source/packages/chrome/src/adblock/AdBlockPlugin.ts +232 -0
- package/source/packages/chrome/src/adblock/AdBlockService.test.ts +148 -0
- package/source/packages/chrome/src/adblock/AdBlockService.ts +166 -0
- package/source/packages/chrome/src/adblock/NOTICE.md +14 -0
- package/source/packages/chrome/src/adblock/assets/filters.bin +0 -0
- package/source/packages/chrome/src/adblock/index.ts +18 -0
- package/source/packages/chrome/src/assets/favicon.ts +4 -0
- package/source/packages/chrome/src/components/BookmarkPopup.tsx +101 -0
- package/source/packages/chrome/src/components/BookmarksStrip.tsx +150 -0
- package/source/packages/chrome/src/components/Button.tsx +99 -0
- package/source/packages/chrome/src/components/Checkbox.tsx +89 -0
- package/source/packages/chrome/src/components/DownloadsPopup.tsx +230 -0
- package/source/packages/chrome/src/components/Favicon.tsx +65 -0
- package/source/packages/chrome/src/components/Icon.tsx +29 -0
- package/source/packages/chrome/src/components/Input.tsx +82 -0
- package/source/packages/chrome/src/components/Menu.tsx +287 -0
- package/source/packages/chrome/src/components/Omnibar/BookmarkButton.tsx +73 -0
- package/source/packages/chrome/src/components/Omnibar/CircularProgress.tsx +83 -0
- package/source/packages/chrome/src/components/Omnibar/Omnibar.tsx +455 -0
- package/source/packages/chrome/src/components/Omnibar/OmnibarButton.tsx +48 -0
- package/source/packages/chrome/src/components/Omnibar/Omnibox.tsx +466 -0
- package/source/packages/chrome/src/components/Omnibar/SiteOptionsButton.tsx +52 -0
- package/source/packages/chrome/src/components/Omnibar/Suggestion.tsx +186 -0
- package/source/packages/chrome/src/components/Omnibar/UrlInput.tsx +198 -0
- package/source/packages/chrome/src/components/Omnibar/suggestions.ts +468 -0
- package/source/packages/chrome/src/components/Omnibar/utils.ts +11 -0
- package/source/packages/chrome/src/components/ReportBrokenSiteModal.tsx +279 -0
- package/source/packages/chrome/src/components/Shell.tsx +191 -0
- package/source/packages/chrome/src/components/SiteInformationPopup.tsx +96 -0
- package/source/packages/chrome/src/components/SmallIconButton.tsx +36 -0
- package/source/packages/chrome/src/components/StartScreen.tsx +386 -0
- package/source/packages/chrome/src/components/TabStrip/DragTab.tsx +546 -0
- package/source/packages/chrome/src/components/TabStrip/Sidebar.tsx +820 -0
- package/source/packages/chrome/src/components/TabStrip/TabHoverCard.tsx +87 -0
- package/source/packages/chrome/src/components/TabStrip/TabStrip.tsx +510 -0
- package/source/packages/chrome/src/components/TopSiteButton.tsx +234 -0
- package/source/packages/chrome/src/consts.ts +3 -0
- package/source/packages/chrome/src/icons.ts +70 -0
- package/source/packages/chrome/src/index.ts +168 -0
- package/source/packages/chrome/src/migrations/0-from-legacy.ts +6 -0
- package/source/packages/chrome/src/migrations/1-vertical-tab-settings.ts +15 -0
- package/source/packages/chrome/src/migrations/index.ts +42 -0
- package/source/packages/chrome/src/pages/AboutPage.tsx +37 -0
- package/source/packages/chrome/src/pages/DownloadsPage.tsx +133 -0
- package/source/packages/chrome/src/pages/HistoryPage.tsx +99 -0
- package/source/packages/chrome/src/pages/NewTabPage.tsx +264 -0
- package/source/packages/chrome/src/pages/PlaygroundPage.tsx +43 -0
- package/source/packages/chrome/src/pages/SettingsPage.tsx +1931 -0
- package/source/packages/chrome/src/proxy/Controller.ts +331 -0
- package/source/packages/chrome/src/proxy/ProxyFrame.ts +26 -0
- package/source/packages/chrome/src/proxy/cache.ts +487 -0
- package/source/packages/chrome/src/proxy/codec.ts +11 -0
- package/source/packages/chrome/src/proxy/contextitems.ts +180 -0
- package/source/packages/chrome/src/proxy/index.ts +5 -0
- package/source/packages/chrome/src/proxy/roxxie.ts +85 -0
- package/source/packages/chrome/src/proxy/scramjet.ts +642 -0
- package/source/packages/chrome/src/reset.css +124 -0
- package/source/packages/chrome/src/runtime-base.ts +16 -0
- package/source/packages/chrome/src/sentry.tsx +45 -0
- package/source/packages/chrome/src/services/DownloadsService.ts +136 -0
- package/source/packages/chrome/src/services/FaviconService.ts +161 -0
- package/source/packages/chrome/src/services/KVWrapper.ts +169 -0
- package/source/packages/chrome/src/services/ProfileService.ts +94 -0
- package/source/packages/chrome/src/services/Service.ts +10 -0
- package/source/packages/chrome/src/services/SettingsService.ts +108 -0
- package/source/packages/chrome/src/services/TabsService.ts +161 -0
- package/source/packages/chrome/src/startup.test.ts +129 -0
- package/source/packages/chrome/src/startup.ts +161 -0
- package/source/packages/chrome/src/style.css +229 -0
- package/source/packages/chrome/src/themes.ts +756 -0
- package/source/packages/chrome/src/util/StatefulClass.ts +31 -0
- package/source/packages/chrome/src/util/index.ts +74 -0
- package/source/packages/chrome/src/util/memoize.ts +13 -0
- package/source/packages/chrome/src/vite-env.d.ts +16 -0
- package/source/packages/chrome/tsconfig.json +30 -0
- package/source/packages/chrome/vite.config.ts +47 -0
- package/source/packages/inject/package.json +20 -0
- package/source/packages/inject/src/context.ts +194 -0
- package/source/packages/inject/src/emulators/alwaysLastBubble.ts +168 -0
- package/source/packages/inject/src/emulators/anchors.ts +55 -0
- package/source/packages/inject/src/emulators/contextmenu.ts +46 -0
- package/source/packages/inject/src/emulators/history.ts +51 -0
- package/source/packages/inject/src/emulators/titlewatcher.ts +42 -0
- package/source/packages/inject/src/emulators/windowopen.ts +134 -0
- package/source/packages/inject/src/errorpage/errorpage.css +234 -0
- package/source/packages/inject/src/errorpage/errorpage.html +29 -0
- package/source/packages/inject/src/errorpage/errorpage.ts +76 -0
- package/source/packages/inject/src/index.ts +62 -0
- package/source/packages/inject/src/transport.ts +97 -0
- package/source/packages/inject/src/types.d.ts +136 -0
- package/source/packages/roxxie-transport/package.json +36 -0
- package/source/packages/roxxie-transport/src/binary.ts +398 -0
- package/source/packages/roxxie-transport/src/config.ts +254 -0
- package/source/packages/roxxie-transport/src/connection.ts +767 -0
- package/source/packages/roxxie-transport/src/index.ts +5 -0
- package/source/packages/roxxie-transport/src/tracker.ts +651 -0
- package/source/packages/roxxie-transport/src/transport.ts +414 -0
- package/source/packages/roxxie-transport/tsconfig.json +18 -0
- package/source/packages/scramjet/packages/controller/package.json +37 -0
- package/source/packages/scramjet/packages/controller/src/index.ts +861 -0
- package/source/packages/scramjet/packages/controller/src/inject.ts +365 -0
- package/source/packages/scramjet/packages/controller/src/sw.ts +231 -0
- package/source/packages/scramjet/packages/controller/src/symbols.ts +1 -0
- package/source/packages/scramjet/packages/controller/src/types.d.ts +140 -0
- package/source/packages/scramjet/packages/controller/src/typesEntry.ts +6 -0
- package/source/packages/scramjet/packages/controller/src/version.ts +30 -0
- package/source/packages/scramjet/packages/controller/tsconfig.json +24 -0
- package/source/packages/scramjet/packages/core/dist/scramjet-external.mjs +57 -0
- package/source/packages/scramjet/packages/core/dist/scramjet.js +13599 -0
- package/source/packages/scramjet/packages/core/dist/scramjet.js.map +1 -0
- package/source/packages/scramjet/packages/core/dist/scramjet.mjs +13649 -0
- package/source/packages/scramjet/packages/core/dist/scramjet.mjs.map +1 -0
- package/source/packages/scramjet/packages/core/dist/scramjet.wasm +0 -0
- package/source/packages/scramjet/packages/core/dist/scramjet_bundled.js +13601 -0
- package/source/packages/scramjet/packages/core/dist/scramjet_bundled.js.map +1 -0
- package/source/packages/scramjet/packages/core/dist/scramjet_bundled.mjs +13651 -0
- package/source/packages/scramjet/packages/core/dist/scramjet_bundled.mjs.map +1 -0
- package/source/packages/scramjet/packages/core/dist/temp-types-build/index.js +23 -0
- package/source/packages/scramjet/packages/core/dist/temp-types-build/index.js.map +1 -0
- package/source/packages/scramjet/packages/core/dist/types/Tap.d.ts +39 -0
- package/source/packages/scramjet/packages/core/dist/types/client/client.d.ts +115 -0
- package/source/packages/scramjet/packages/core/dist/types/client/entry.d.ts +5 -0
- package/source/packages/scramjet/packages/core/dist/types/client/events.d.ts +10 -0
- package/source/packages/scramjet/packages/core/dist/types/client/helpers.d.ts +1 -0
- package/source/packages/scramjet/packages/core/dist/types/client/index.d.ts +7 -0
- package/source/packages/scramjet/packages/core/dist/types/client/location.d.ts +2 -0
- package/source/packages/scramjet/packages/core/dist/types/client/shared/eval.d.ts +3 -0
- package/source/packages/scramjet/packages/core/dist/types/client/shared/sourcemaps.d.ts +19 -0
- package/source/packages/scramjet/packages/core/dist/types/client/shared/wrap.d.ts +4 -0
- package/source/packages/scramjet/packages/core/dist/types/client/singletonbox.d.ts +18 -0
- package/source/packages/scramjet/packages/core/dist/types/fetch/body.d.ts +3 -0
- package/source/packages/scramjet/packages/core/dist/types/fetch/fetch.d.ts +7 -0
- package/source/packages/scramjet/packages/core/dist/types/fetch/headers.d.ts +19 -0
- package/source/packages/scramjet/packages/core/dist/types/fetch/index.d.ts +128 -0
- package/source/packages/scramjet/packages/core/dist/types/fetch/parse.d.ts +23 -0
- package/source/packages/scramjet/packages/core/dist/types/fetch/util.d.ts +7 -0
- package/source/packages/scramjet/packages/core/dist/types/index.d.ts +12 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/cookie.d.ts +26 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/headers.d.ts +13 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/htmlRules.d.ts +6 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/index.d.ts +50 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/mime.d.ts +53 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/refresh.d.ts +7 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/rewriters/css.d.ts +4 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/rewriters/html.d.ts +33 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/rewriters/index.d.ts +6 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/rewriters/js.d.ts +11 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/rewriters/url.d.ts +24 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/rewriters/wasm.d.ts +7 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/rewriters/worker.d.ts +3 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/set-cookie-parser.d.ts +20 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/snapshot.d.ts +186 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/sniffEncoding.d.ts +65 -0
- package/source/packages/scramjet/packages/core/dist/types/shared/util.d.ts +2 -0
- package/source/packages/scramjet/packages/core/dist/types/symbols.d.ts +6 -0
- package/source/packages/scramjet/packages/core/dist/types/types.d.ts +60 -0
- package/source/packages/scramjet/packages/core/dist/types/typesEntry.d.ts +5 -0
- package/source/packages/scramjet/packages/core/lib/index.cjs +7 -0
- package/source/packages/scramjet/packages/core/lib/index.d.ts +8 -0
- package/source/packages/scramjet/packages/core/package.json +69 -0
- package/source/packages/scramjet/packages/core/rewriter/Cargo.lock +1985 -0
- package/source/packages/scramjet/packages/core/rewriter/Cargo.toml +20 -0
- package/source/packages/scramjet/packages/core/rewriter/coverage-macro/Cargo.toml +15 -0
- package/source/packages/scramjet/packages/core/rewriter/coverage-macro/src/analyze.rs +1118 -0
- package/source/packages/scramjet/packages/core/rewriter/coverage-macro/src/ast_table.rs +927 -0
- package/source/packages/scramjet/packages/core/rewriter/coverage-macro/src/helper_index.rs +556 -0
- package/source/packages/scramjet/packages/core/rewriter/coverage-macro/src/lib.rs +455 -0
- package/source/packages/scramjet/packages/core/rewriter/coverage-macro/src/reachability.rs +85 -0
- package/source/packages/scramjet/packages/core/rewriter/coverage-macro/src/templates.rs +192 -0
- package/source/packages/scramjet/packages/core/rewriter/coverage-macro/src/witness.rs +597 -0
- package/source/packages/scramjet/packages/core/rewriter/js/Cargo.toml +18 -0
- package/source/packages/scramjet/packages/core/rewriter/js/src/cfg.rs +45 -0
- package/source/packages/scramjet/packages/core/rewriter/js/src/changes.rs +379 -0
- package/source/packages/scramjet/packages/core/rewriter/js/src/lib.rs +171 -0
- package/source/packages/scramjet/packages/core/rewriter/js/src/rewrite.rs +290 -0
- package/source/packages/scramjet/packages/core/rewriter/js/src/visitor.rs +967 -0
- package/source/packages/scramjet/packages/core/rewriter/native/Cargo.toml +22 -0
- package/source/packages/scramjet/packages/core/rewriter/native/src/main.rs +166 -0
- package/source/packages/scramjet/packages/core/rewriter/native/src/rewriter.rs +161 -0
- package/source/packages/scramjet/packages/core/rewriter/native/src/test_runner.rs +156 -0
- package/source/packages/scramjet/packages/core/rewriter/rust-toolchain.toml +5 -0
- package/source/packages/scramjet/packages/core/rewriter/rustfmt.toml +2 -0
- package/source/packages/scramjet/packages/core/rewriter/transform/Cargo.toml +16 -0
- package/source/packages/scramjet/packages/core/rewriter/transform/src/lib.rs +242 -0
- package/source/packages/scramjet/packages/core/rewriter/transform/src/transform.rs +123 -0
- package/source/packages/scramjet/packages/core/rewriter/wasm/Cargo.toml +22 -0
- package/source/packages/scramjet/packages/core/rewriter/wasm/build.sh +128 -0
- package/source/packages/scramjet/packages/core/rewriter/wasm/src/error.rs +56 -0
- package/source/packages/scramjet/packages/core/rewriter/wasm/src/jsr.rs +125 -0
- package/source/packages/scramjet/packages/core/rewriter/wasm/src/lib.rs +144 -0
- package/source/packages/scramjet/packages/core/src/Tap.ts +166 -0
- package/source/packages/scramjet/packages/core/src/client/client.ts +916 -0
- package/source/packages/scramjet/packages/core/src/client/dom/attr.ts +94 -0
- package/source/packages/scramjet/packages/core/src/client/dom/beacon.ts +11 -0
- package/source/packages/scramjet/packages/core/src/client/dom/cookie.ts +21 -0
- package/source/packages/scramjet/packages/core/src/client/dom/css.ts +106 -0
- package/source/packages/scramjet/packages/core/src/client/dom/document.ts +140 -0
- package/source/packages/scramjet/packages/core/src/client/dom/element.ts +783 -0
- package/source/packages/scramjet/packages/core/src/client/dom/fontface.ts +11 -0
- package/source/packages/scramjet/packages/core/src/client/dom/fragments.ts +32 -0
- package/source/packages/scramjet/packages/core/src/client/dom/history.ts +35 -0
- package/source/packages/scramjet/packages/core/src/client/dom/open.ts +59 -0
- package/source/packages/scramjet/packages/core/src/client/dom/origin.ts +13 -0
- package/source/packages/scramjet/packages/core/src/client/dom/performance.ts +50 -0
- package/source/packages/scramjet/packages/core/src/client/dom/protocol.ts +17 -0
- package/source/packages/scramjet/packages/core/src/client/dom/storage.ts +107 -0
- package/source/packages/scramjet/packages/core/src/client/entry.ts +12 -0
- package/source/packages/scramjet/packages/core/src/client/events.ts +10 -0
- package/source/packages/scramjet/packages/core/src/client/helpers.ts +7 -0
- package/source/packages/scramjet/packages/core/src/client/index.ts +7 -0
- package/source/packages/scramjet/packages/core/src/client/location.ts +139 -0
- package/source/packages/scramjet/packages/core/src/client/shared/antiantidebugger.ts +20 -0
- package/source/packages/scramjet/packages/core/src/client/shared/blob.ts +35 -0
- package/source/packages/scramjet/packages/core/src/client/shared/caches.ts +31 -0
- package/source/packages/scramjet/packages/core/src/client/shared/chrome.ts +90 -0
- package/source/packages/scramjet/packages/core/src/client/shared/err.ts +55 -0
- package/source/packages/scramjet/packages/core/src/client/shared/error.ts +42 -0
- package/source/packages/scramjet/packages/core/src/client/shared/eval.ts +40 -0
- package/source/packages/scramjet/packages/core/src/client/shared/event.ts +215 -0
- package/source/packages/scramjet/packages/core/src/client/shared/function.ts +59 -0
- package/source/packages/scramjet/packages/core/src/client/shared/import.ts +46 -0
- package/source/packages/scramjet/packages/core/src/client/shared/indexeddb.ts +18 -0
- package/source/packages/scramjet/packages/core/src/client/shared/opfs.ts +27 -0
- package/source/packages/scramjet/packages/core/src/client/shared/postmessage.ts +113 -0
- package/source/packages/scramjet/packages/core/src/client/shared/realm.ts +26 -0
- package/source/packages/scramjet/packages/core/src/client/shared/requests/eventsource.ts +17 -0
- package/source/packages/scramjet/packages/core/src/client/shared/requests/fetch.ts +67 -0
- package/source/packages/scramjet/packages/core/src/client/shared/requests/websocket.ts +389 -0
- package/source/packages/scramjet/packages/core/src/client/shared/requests/xmlhttprequest.ts +163 -0
- package/source/packages/scramjet/packages/core/src/client/shared/settimeout.ts +20 -0
- package/source/packages/scramjet/packages/core/src/client/shared/sourcemaps.ts +203 -0
- package/source/packages/scramjet/packages/core/src/client/shared/worker.ts +72 -0
- package/source/packages/scramjet/packages/core/src/client/shared/wrap.ts +197 -0
- package/source/packages/scramjet/packages/core/src/client/singletonbox.ts +52 -0
- package/source/packages/scramjet/packages/core/src/client/worker/importScripts.ts +13 -0
- package/source/packages/scramjet/packages/core/src/fetch/body.ts +93 -0
- package/source/packages/scramjet/packages/core/src/fetch/fetch.ts +323 -0
- package/source/packages/scramjet/packages/core/src/fetch/headers.ts +528 -0
- package/source/packages/scramjet/packages/core/src/fetch/index.ts +198 -0
- package/source/packages/scramjet/packages/core/src/fetch/parse.ts +149 -0
- package/source/packages/scramjet/packages/core/src/fetch/util.ts +81 -0
- package/source/packages/scramjet/packages/core/src/global.d.ts +32 -0
- package/source/packages/scramjet/packages/core/src/index.ts +78 -0
- package/source/packages/scramjet/packages/core/src/log.ts +117 -0
- package/source/packages/scramjet/packages/core/src/shared/cookie.ts +199 -0
- package/source/packages/scramjet/packages/core/src/shared/headers.ts +76 -0
- package/source/packages/scramjet/packages/core/src/shared/htmlRules.ts +154 -0
- package/source/packages/scramjet/packages/core/src/shared/index.ts +79 -0
- package/source/packages/scramjet/packages/core/src/shared/mime.ts +234 -0
- package/source/packages/scramjet/packages/core/src/shared/refresh.ts +164 -0
- package/source/packages/scramjet/packages/core/src/shared/rewriters/css.ts +67 -0
- package/source/packages/scramjet/packages/core/src/shared/rewriters/html.ts +603 -0
- package/source/packages/scramjet/packages/core/src/shared/rewriters/index.ts +6 -0
- package/source/packages/scramjet/packages/core/src/shared/rewriters/js.ts +158 -0
- package/source/packages/scramjet/packages/core/src/shared/rewriters/url.ts +248 -0
- package/source/packages/scramjet/packages/core/src/shared/rewriters/wasm.ts +58 -0
- package/source/packages/scramjet/packages/core/src/shared/rewriters/worker.ts +37 -0
- package/source/packages/scramjet/packages/core/src/shared/set-cookie-parser.ts +195 -0
- package/source/packages/scramjet/packages/core/src/shared/snapshot.ts +245 -0
- package/source/packages/scramjet/packages/core/src/shared/sniffEncoding.ts +1061 -0
- package/source/packages/scramjet/packages/core/src/shared/util.ts +35 -0
- package/source/packages/scramjet/packages/core/src/symbols.ts +9 -0
- package/source/packages/scramjet/packages/core/src/sync.ts +63 -0
- package/source/packages/scramjet/packages/core/src/types.ts +66 -0
- package/source/packages/scramjet/packages/core/src/typesEntry.ts +6 -0
- package/source/packages/scramjet/packages/core/tsconfig.json +21 -0
- package/source/packages/scramjet/packages/rpc/index.ts +100 -0
- package/source/packages/scramjet/packages/rpc/package.json +7 -0
- package/source/packages/scramjet/packages/utils/package.json +39 -0
- package/source/packages/scramjet/packages/utils/src/alwaysLastBubble.ts +172 -0
- package/source/packages/scramjet/packages/utils/src/catch-escaped-links.ts +34 -0
- package/source/packages/scramjet/packages/utils/src/event-handler-plugin.ts +86 -0
- package/source/packages/scramjet/packages/utils/src/global.d.ts +8 -0
- package/source/packages/scramjet/packages/utils/src/http-cache-plugin.ts +475 -0
- package/source/packages/scramjet/packages/utils/src/index.ts +26 -0
- package/source/packages/scramjet/packages/utils/src/link-handler-plugin.ts +75 -0
- package/source/packages/scramjet/packages/utils/src/typesEntry.ts +5 -0
- package/source/packages/scramjet/packages/utils/src/url-watcher.ts +37 -0
- package/source/packages/scramjet/packages/utils/src/version.ts +40 -0
- package/source/packages/scramjet/packages/utils/tsconfig.json +11 -0
- package/source/packages/scramjet/patches/htmlparser2@12.0.0.patch +124 -0
- package/source/packages/scramjet/rspack.config.ts +613 -0
- package/source/packages/scramjet/tsconfig.json +11 -0
- package/source/packages/tracker-protocol/package.json +31 -0
- package/source/packages/tracker-protocol/src/index.ts +745 -0
- package/source/packages/tracker-protocol/tsconfig.json +18 -0
- package/source/pnpm-lock.yaml +12018 -0
- package/source/pnpm-workspace.yaml +31 -0
- package/source/rspack.config.ts +103 -0
- package/source/scripts/update-adblock-assets.mjs +164 -0
- package/third_party/filter-lists/LICENSE-CC-BY-SA-3.0.txt +359 -0
- package/third_party/filter-lists/LICENSE-GPL-3.0.txt +674 -0
- package/third_party/filter-lists/LICENSE-MPL-2.0.txt +375 -0
- package/third_party/filter-lists/README.md +24 -0
- package/third_party/filter-lists/easylist.txt +83088 -0
- package/third_party/filter-lists/easyprivacy.txt +56361 -0
- package/third_party/filter-lists/manifest.json +56 -0
- package/third_party/filter-lists/ublock-filters.txt +10937 -0
- package/third_party/filter-lists/ublock-privacy.txt +3209 -0
- package/third_party/filter-lists/ublock-resources.json +1852 -0
- package/third_party/filter-lists/ublock-unbreak.txt +6026 -0
|
@@ -0,0 +1,820 @@
|
|
|
1
|
+
import { css, type FC } from "dreamland/core";
|
|
2
|
+
import type { Tab } from "../../Tab/Tab";
|
|
3
|
+
import {
|
|
4
|
+
createMiddleClickCloseHandler,
|
|
5
|
+
DragTab,
|
|
6
|
+
VerticalPinTile,
|
|
7
|
+
} from "./DragTab";
|
|
8
|
+
import { TabHoverCard } from "@components/TabStrip/TabHoverCard";
|
|
9
|
+
import { Icon } from "@components/Icon";
|
|
10
|
+
import { iconAdd } from "../../icons";
|
|
11
|
+
import { requestUnfocusFrames } from "@components/Shell";
|
|
12
|
+
import { settingsService, tabsService } from "../..";
|
|
13
|
+
|
|
14
|
+
type VisualTab = {
|
|
15
|
+
tab: Tab;
|
|
16
|
+
root: HTMLElement;
|
|
17
|
+
dragoffset: number;
|
|
18
|
+
dragpos: number;
|
|
19
|
+
startdragpos: number;
|
|
20
|
+
closing: boolean;
|
|
21
|
+
height: number;
|
|
22
|
+
pos: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function Sidebar(
|
|
26
|
+
this: FC<
|
|
27
|
+
{
|
|
28
|
+
layout: "horizontal" | "bottom" | "hybrid" | "vertical" | "compact";
|
|
29
|
+
justify: "left" | "right";
|
|
30
|
+
tabs: Tab[];
|
|
31
|
+
activetab: Tab;
|
|
32
|
+
destroyTab: (tab: Tab) => void;
|
|
33
|
+
addTab: () => void;
|
|
34
|
+
sidebarWidth: number;
|
|
35
|
+
setSidebarWidth: (width: number) => void;
|
|
36
|
+
topContent?: any;
|
|
37
|
+
bottomContent?: any;
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
visualtabs: VisualTab[];
|
|
41
|
+
container: HTMLElement;
|
|
42
|
+
topEl: HTMLElement;
|
|
43
|
+
bottomEl: HTMLElement;
|
|
44
|
+
afterEl: HTMLElement;
|
|
45
|
+
currentlydragging: string | null;
|
|
46
|
+
currentlyHovered: Tab | null;
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
) {
|
|
50
|
+
this.currentlydragging = null;
|
|
51
|
+
this.currentlyHovered = this.tabs[0] ?? null;
|
|
52
|
+
this.visualtabs = [];
|
|
53
|
+
|
|
54
|
+
const [lock, unlock] = requestUnfocusFrames();
|
|
55
|
+
const SIDEBAR_MIN_WIDTH = this.layout === "vertical" ? 190 : 48;
|
|
56
|
+
const SIDEBAR_MAX_WIDTH = 520;
|
|
57
|
+
|
|
58
|
+
const TAB_TRANSITION = "225ms cubic-bezier(.43,.52,0,1.15)";
|
|
59
|
+
const TAB_STAGGER_STEP = 18;
|
|
60
|
+
const TAB_STAGGER_MAX = 144;
|
|
61
|
+
|
|
62
|
+
let transitioningTabs = 0;
|
|
63
|
+
|
|
64
|
+
const getRemAbsoluteSize = (size: number) =>
|
|
65
|
+
size * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
66
|
+
|
|
67
|
+
const getRootHeight = () => {
|
|
68
|
+
const style = getComputedStyle(this.container);
|
|
69
|
+
const padding =
|
|
70
|
+
parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
|
|
71
|
+
const border =
|
|
72
|
+
parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
|
73
|
+
const top = this.topEl.offsetHeight;
|
|
74
|
+
const bottom = this.bottomEl.offsetHeight;
|
|
75
|
+
const after = this.afterEl.offsetHeight;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
this.container.offsetHeight - padding - border - top - bottom - after
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const getRootWidth = () => {
|
|
83
|
+
const style = getComputedStyle(this.container);
|
|
84
|
+
const padding =
|
|
85
|
+
parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
|
86
|
+
const border =
|
|
87
|
+
parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
|
|
88
|
+
|
|
89
|
+
return this.container.offsetWidth - padding - border;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const getAbsoluteStart = () => {
|
|
93
|
+
const rect = this.container.getBoundingClientRect();
|
|
94
|
+
const style = getComputedStyle(this.container);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
rect.top + parseFloat(style.paddingTop) + parseFloat(style.borderTopWidth)
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const getLayoutStart = () => {
|
|
102
|
+
return this.topEl.offsetHeight;
|
|
103
|
+
};
|
|
104
|
+
const getTabPadding = () => {
|
|
105
|
+
return getRemAbsoluteSize(
|
|
106
|
+
parseFloat(
|
|
107
|
+
getComputedStyle(document.documentElement).getPropertyValue(
|
|
108
|
+
"--space-xxs"
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const getTabHeight = () => {
|
|
115
|
+
// Measure the inner `.main` row rather than the tab root. When a tab
|
|
116
|
+
// opens (notably a freshly-unpinned tab, which `unpinTab` inserts at the
|
|
117
|
+
// front of the list so it becomes `firstVisible`), its `.dragroot`
|
|
118
|
+
// wrapper is height-animated from 0 with `overflow: hidden`, so the root
|
|
119
|
+
// briefly reports a near-zero height. `.main` keeps its `--tab-height`
|
|
120
|
+
// throughout that animation, so measuring it avoids reading a transient
|
|
121
|
+
// height and collapsing the spacing of every tab.
|
|
122
|
+
const firstVisible = this.visualtabs.find((tab) => !tab.closing);
|
|
123
|
+
if (firstVisible) {
|
|
124
|
+
const main = firstVisible.root.querySelector(
|
|
125
|
+
".main"
|
|
126
|
+
) as HTMLElement | null;
|
|
127
|
+
const measured = main?.offsetHeight ?? 0;
|
|
128
|
+
if (measured > 0) return measured;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const cssHeight = getRemAbsoluteSize(
|
|
132
|
+
parseFloat(
|
|
133
|
+
getComputedStyle(document.documentElement).getPropertyValue(
|
|
134
|
+
"--space-xs"
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
return Number.isFinite(cssHeight) && cssHeight > 0 ? cssHeight : 36;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const reorderTabs = () => {
|
|
142
|
+
this.visualtabs.sort((a, b) => {
|
|
143
|
+
const aCenter = a.pos + a.height / 2;
|
|
144
|
+
|
|
145
|
+
const bTop = b.pos;
|
|
146
|
+
const bBottom = b.pos + b.height;
|
|
147
|
+
const bCenter =
|
|
148
|
+
Math.abs(aCenter - bTop) > Math.abs(aCenter - bBottom) ? bBottom : bTop;
|
|
149
|
+
|
|
150
|
+
return aCenter - bCenter;
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const layoutTabs = (transition: boolean) => {
|
|
155
|
+
const height = getTabHeight();
|
|
156
|
+
const width = getRootWidth();
|
|
157
|
+
const tabPadding = getTabPadding();
|
|
158
|
+
console.log(height, width, tabPadding);
|
|
159
|
+
|
|
160
|
+
reorderTabs();
|
|
161
|
+
|
|
162
|
+
let dragpos = -1;
|
|
163
|
+
let currpos = getLayoutStart();
|
|
164
|
+
let staggerIndex = 0;
|
|
165
|
+
let movedTabs = 0;
|
|
166
|
+
for (const tab of this.visualtabs) {
|
|
167
|
+
if (tab.closing) {
|
|
168
|
+
const tabPos = tab.dragpos != -1 ? tab.dragpos : tab.pos;
|
|
169
|
+
tab.root.style.transform = `translateY(${tabPos}px)`;
|
|
170
|
+
tab.pos = tabPos;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
tab.root.style.width = width + "px";
|
|
175
|
+
tab.root.style.height = height + "px";
|
|
176
|
+
|
|
177
|
+
const tabPos = tab.dragpos != -1 ? tab.dragpos : currpos;
|
|
178
|
+
tab.root.style.transform = `translateY(${tabPos}px)`;
|
|
179
|
+
if (transition && tab.dragpos == -1 && tab.pos != tabPos) {
|
|
180
|
+
const delay = Math.min(
|
|
181
|
+
staggerIndex * TAB_STAGGER_STEP,
|
|
182
|
+
TAB_STAGGER_MAX
|
|
183
|
+
);
|
|
184
|
+
tab.root.style.transition = `transform ${TAB_TRANSITION} ${delay}ms`;
|
|
185
|
+
transitioningTabs++;
|
|
186
|
+
movedTabs++;
|
|
187
|
+
}
|
|
188
|
+
dragpos = Math.max(dragpos, tab.dragpos + height + tabPadding);
|
|
189
|
+
|
|
190
|
+
tab.pos = tabPos;
|
|
191
|
+
tab.height = height;
|
|
192
|
+
currpos += height + tabPadding;
|
|
193
|
+
staggerIndex++;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const afterpos = Math.max(dragpos, currpos);
|
|
197
|
+
if (transition) {
|
|
198
|
+
const afterDelay = Math.min(
|
|
199
|
+
Math.max(staggerIndex, movedTabs > 0 ? staggerIndex : 1) *
|
|
200
|
+
TAB_STAGGER_STEP,
|
|
201
|
+
TAB_STAGGER_MAX
|
|
202
|
+
);
|
|
203
|
+
this.afterEl.style.transition = `transform ${TAB_TRANSITION} ${afterDelay}ms`;
|
|
204
|
+
}
|
|
205
|
+
this.afterEl.style.transform = `translateY(${afterpos}px)`;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const getMaxDragPos = () => {
|
|
209
|
+
return getLayoutStart() + getRootHeight();
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const calcDragPos = (e: MouseEvent, tab: VisualTab) => {
|
|
213
|
+
const maxPos = getMaxDragPos() - tab.root.offsetHeight;
|
|
214
|
+
|
|
215
|
+
const pos = e.clientY - tab.dragoffset - getAbsoluteStart();
|
|
216
|
+
|
|
217
|
+
tab.dragpos = Math.min(Math.max(getLayoutStart(), pos), maxPos);
|
|
218
|
+
layoutTabs(true);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const mouseMoveHandler = (e: MouseEvent) => {
|
|
222
|
+
if (this.currentlydragging === null) return;
|
|
223
|
+
calcDragPos(
|
|
224
|
+
e,
|
|
225
|
+
this.visualtabs.find((tab) => tab.tab.id === this.currentlydragging)!
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const mouseUpHandler = () => {
|
|
230
|
+
if (this.currentlydragging === null) return;
|
|
231
|
+
const tab = this.visualtabs.find(
|
|
232
|
+
(tab) => tab.tab.id === this.currentlydragging
|
|
233
|
+
)!;
|
|
234
|
+
const dragroot = tab.root.querySelector(".dragroot") as HTMLElement;
|
|
235
|
+
|
|
236
|
+
dragroot.style.width = "";
|
|
237
|
+
dragroot.style.position = "unset";
|
|
238
|
+
tab.dragoffset = -1;
|
|
239
|
+
tab.dragpos = -1;
|
|
240
|
+
layoutTabs(true);
|
|
241
|
+
if (!tab.root.style.transition) {
|
|
242
|
+
tab.root.style.zIndex = "0";
|
|
243
|
+
}
|
|
244
|
+
this.currentlydragging = null;
|
|
245
|
+
unlock();
|
|
246
|
+
window.removeEventListener("mousemove", mouseMoveHandler);
|
|
247
|
+
window.removeEventListener("mouseup", mouseUpHandler);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const mouseDown = (e: MouseEvent, tab: VisualTab) => {
|
|
251
|
+
if (e.button != 0) return;
|
|
252
|
+
this.currentlydragging = tab.tab.id;
|
|
253
|
+
lock();
|
|
254
|
+
|
|
255
|
+
const rect = tab.root.getBoundingClientRect();
|
|
256
|
+
tab.root.style.transition = "";
|
|
257
|
+
tab.root.style.zIndex = "100";
|
|
258
|
+
const dragroot = tab.root.querySelector(".dragroot") as HTMLElement;
|
|
259
|
+
dragroot.style.width = rect.width + "px";
|
|
260
|
+
dragroot.style.position = "absolute";
|
|
261
|
+
tab.dragoffset = e.clientY - rect.top;
|
|
262
|
+
tab.startdragpos = rect.top;
|
|
263
|
+
|
|
264
|
+
if (tab.dragoffset < 0) throw new Error("dragoffset must be positive");
|
|
265
|
+
|
|
266
|
+
calcDragPos(e, tab);
|
|
267
|
+
|
|
268
|
+
if (this.activetab != tab.tab) {
|
|
269
|
+
this.activetab = tab.tab;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
window.addEventListener("mousemove", mouseMoveHandler);
|
|
273
|
+
window.addEventListener("mouseup", mouseUpHandler);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const clampSidebarWidth = (width: number) => {
|
|
277
|
+
const viewportMax = Math.max(SIDEBAR_MIN_WIDTH, window.innerWidth - 140);
|
|
278
|
+
return Math.min(
|
|
279
|
+
Math.max(Math.round(width), SIDEBAR_MIN_WIDTH),
|
|
280
|
+
Math.min(SIDEBAR_MAX_WIDTH, viewportMax)
|
|
281
|
+
);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const sidebarResizeMouseDown = (e: MouseEvent) => {
|
|
285
|
+
if (e.button !== 0) return;
|
|
286
|
+
|
|
287
|
+
lock();
|
|
288
|
+
document.body.style.cursor = "ew-resize";
|
|
289
|
+
|
|
290
|
+
const mouseMoveHandler = (moveEvent: MouseEvent) => {
|
|
291
|
+
const { left } = this.container.getBoundingClientRect();
|
|
292
|
+
if (this.justify === "right") {
|
|
293
|
+
this.setSidebarWidth(
|
|
294
|
+
clampSidebarWidth(
|
|
295
|
+
left + this.container.offsetWidth - moveEvent.clientX
|
|
296
|
+
)
|
|
297
|
+
);
|
|
298
|
+
} else {
|
|
299
|
+
this.setSidebarWidth(clampSidebarWidth(moveEvent.clientX - left));
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
const mouseUpHandler = () => {
|
|
304
|
+
unlock();
|
|
305
|
+
document.body.style.cursor = "";
|
|
306
|
+
window.removeEventListener("mousemove", mouseMoveHandler);
|
|
307
|
+
window.removeEventListener("mouseup", mouseUpHandler);
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
window.addEventListener("mousemove", mouseMoveHandler);
|
|
311
|
+
window.addEventListener("mouseup", mouseUpHandler);
|
|
312
|
+
|
|
313
|
+
e.preventDefault();
|
|
314
|
+
e.stopPropagation();
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const transitionend = () => {
|
|
318
|
+
transitioningTabs = Math.max(transitioningTabs - 1, 0);
|
|
319
|
+
if (transitioningTabs == 0) {
|
|
320
|
+
this.afterEl.style.transition = "";
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
use(this.tabs).listen(() => {
|
|
325
|
+
let newvisualtabs: VisualTab[] = [];
|
|
326
|
+
|
|
327
|
+
// Both sidebar layouts render pinned tabs in the Arc-style grid
|
|
328
|
+
// (VerticalPinList) instead of the linear list, so skip them here.
|
|
329
|
+
const usesPinnedGrid =
|
|
330
|
+
this.layout === "vertical" || this.layout === "hybrid";
|
|
331
|
+
for (let index = 0; index < this.tabs.length; index++) {
|
|
332
|
+
let tab = this.tabs[index];
|
|
333
|
+
|
|
334
|
+
if (tab.pinned && usesPinnedGrid) continue;
|
|
335
|
+
|
|
336
|
+
let visualtab = this.visualtabs.find((t) => t.tab === tab);
|
|
337
|
+
|
|
338
|
+
if (!visualtab) {
|
|
339
|
+
let dt = (
|
|
340
|
+
<DragTab
|
|
341
|
+
id={tab.id}
|
|
342
|
+
tab={tab}
|
|
343
|
+
orientation="vertical"
|
|
344
|
+
active={use(this.activetab).map((x) => x === tab)}
|
|
345
|
+
mousedown={(e) => mouseDown(e, visualtab!)}
|
|
346
|
+
mouseover={() => {
|
|
347
|
+
this.currentlyHovered = tab;
|
|
348
|
+
}}
|
|
349
|
+
destroy={() => {
|
|
350
|
+
this.destroyTab(tab);
|
|
351
|
+
}}
|
|
352
|
+
transitionend={transitionend}
|
|
353
|
+
/>
|
|
354
|
+
);
|
|
355
|
+
const tabHeight = getTabHeight();
|
|
356
|
+
const previousTab = newvisualtabs[newvisualtabs.length - 1];
|
|
357
|
+
const nextTab = this.visualtabs.find(
|
|
358
|
+
(candidate) =>
|
|
359
|
+
!candidate.closing && !newvisualtabs.includes(candidate)
|
|
360
|
+
);
|
|
361
|
+
const initialPos = previousTab
|
|
362
|
+
? previousTab.pos + previousTab.height + getTabPadding()
|
|
363
|
+
: (nextTab?.pos ?? getLayoutStart());
|
|
364
|
+
|
|
365
|
+
// Absolute-positioned tabs need their slot before the mount animation runs.
|
|
366
|
+
dt.style.transform = `translateY(${initialPos}px)`;
|
|
367
|
+
visualtab = {
|
|
368
|
+
tab,
|
|
369
|
+
root: dt,
|
|
370
|
+
dragoffset: -1,
|
|
371
|
+
dragpos: -1,
|
|
372
|
+
startdragpos: -1,
|
|
373
|
+
closing: false,
|
|
374
|
+
height: tabHeight,
|
|
375
|
+
pos: initialPos,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
newvisualtabs.push(visualtab);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
for (let vtab of this.visualtabs) {
|
|
383
|
+
if (!newvisualtabs.includes(vtab)) {
|
|
384
|
+
let indexof = this.visualtabs.indexOf(vtab);
|
|
385
|
+
vtab.closing = true;
|
|
386
|
+
newvisualtabs.splice(indexof, 0, vtab);
|
|
387
|
+
let anim = vtab.root.animate(
|
|
388
|
+
[
|
|
389
|
+
{},
|
|
390
|
+
{
|
|
391
|
+
height: "0px",
|
|
392
|
+
},
|
|
393
|
+
],
|
|
394
|
+
{
|
|
395
|
+
duration: 150,
|
|
396
|
+
easing: "cubic-bezier(.29,.44,.3,.94)",
|
|
397
|
+
fill: "forwards",
|
|
398
|
+
}
|
|
399
|
+
);
|
|
400
|
+
anim.addEventListener(
|
|
401
|
+
"finish",
|
|
402
|
+
() => {
|
|
403
|
+
this.visualtabs = this.visualtabs.filter((t) => t !== vtab);
|
|
404
|
+
layoutTabs(false);
|
|
405
|
+
},
|
|
406
|
+
{ once: true }
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
this.visualtabs = newvisualtabs;
|
|
412
|
+
setTimeout(() => layoutTabs(true), 10);
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// force sync when density profile changes
|
|
416
|
+
use(settingsService.settings.uiProfile).listen(() => {
|
|
417
|
+
this.tabs = [...this.tabs];
|
|
418
|
+
layoutTabs(true);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
this.cx.mount = () => {
|
|
422
|
+
if (
|
|
423
|
+
this.sidebarWidth < SIDEBAR_MIN_WIDTH ||
|
|
424
|
+
this.sidebarWidth > SIDEBAR_MAX_WIDTH
|
|
425
|
+
) {
|
|
426
|
+
this.setSidebarWidth(
|
|
427
|
+
Math.min(
|
|
428
|
+
Math.max(this.sidebarWidth, SIDEBAR_MIN_WIDTH),
|
|
429
|
+
Math.min(SIDEBAR_MAX_WIDTH, window.innerWidth - 140)
|
|
430
|
+
)
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
requestAnimationFrame(() => layoutTabs(false));
|
|
435
|
+
let resizeObserver: ResizeObserver | null = new ResizeObserver(() => {
|
|
436
|
+
if (!this.root.isConnected) {
|
|
437
|
+
resizeObserver?.disconnect();
|
|
438
|
+
resizeObserver = null;
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
layoutTabs(false);
|
|
442
|
+
});
|
|
443
|
+
resizeObserver.observe(this.container);
|
|
444
|
+
resizeObserver.observe(this.topEl);
|
|
445
|
+
resizeObserver.observe(this.bottomEl);
|
|
446
|
+
resizeObserver.observe(this.afterEl);
|
|
447
|
+
|
|
448
|
+
// Force an initial sync for newly-mounted strips after mode switches.
|
|
449
|
+
this.tabs = [...this.tabs];
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
return (
|
|
453
|
+
<div
|
|
454
|
+
id="tabstrip"
|
|
455
|
+
this={use(this.container)}
|
|
456
|
+
on:auxclick={createMiddleClickCloseHandler(
|
|
457
|
+
() => this.visualtabs,
|
|
458
|
+
(tab) => this.destroyTab(tab)
|
|
459
|
+
)}
|
|
460
|
+
style={use(this.sidebarWidth).map(
|
|
461
|
+
(width) =>
|
|
462
|
+
`--sidebar-width: ${width}px; min-width: ${width}px; flex: 0 0 ${width}px;`
|
|
463
|
+
)}
|
|
464
|
+
>
|
|
465
|
+
<div class="extra top" this={use(this.topEl)}>
|
|
466
|
+
{this.topContent}
|
|
467
|
+
</div>
|
|
468
|
+
{use(this.visualtabs).mapEach((tab) => tab.root)}
|
|
469
|
+
<div class="extra after" this={use(this.afterEl)}>
|
|
470
|
+
<button class="new-tab" on:click={this.addTab}>
|
|
471
|
+
<Icon icon={iconAdd} />
|
|
472
|
+
</button>
|
|
473
|
+
</div>
|
|
474
|
+
<div class="extra bottom" this={use(this.bottomEl)}>
|
|
475
|
+
{this.bottomContent}
|
|
476
|
+
</div>
|
|
477
|
+
<div
|
|
478
|
+
class="sidebar-resizer"
|
|
479
|
+
on:mousedown={(e: MouseEvent) => sidebarResizeMouseDown(e)}
|
|
480
|
+
></div>
|
|
481
|
+
<TabHoverCard hoveredTab={use(this.currentlyHovered)} />
|
|
482
|
+
</div>
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
Sidebar.style = css`
|
|
487
|
+
:scope {
|
|
488
|
+
--sidebar-width: 250px;
|
|
489
|
+
display: block;
|
|
490
|
+
position: relative;
|
|
491
|
+
padding: var(--space-md);
|
|
492
|
+
background: var(--frame);
|
|
493
|
+
height: 100%;
|
|
494
|
+
z-index: 2;
|
|
495
|
+
border-right: 1px solid var(--text-15);
|
|
496
|
+
width: var(--sidebar-width);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
:global(.sidebar-right *) > :scope {
|
|
500
|
+
border-right: none;
|
|
501
|
+
border-left: 1px solid var(--text-15);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.extra {
|
|
505
|
+
left: 0;
|
|
506
|
+
width: 100%;
|
|
507
|
+
position: absolute;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
.top,
|
|
511
|
+
.bottom,
|
|
512
|
+
.after {
|
|
513
|
+
display: flex;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.top,
|
|
517
|
+
.bottom {
|
|
518
|
+
padding-inline: var(--space-md);
|
|
519
|
+
padding-top: var(--space-md);
|
|
520
|
+
flex-direction: column;
|
|
521
|
+
align-items: stretch;
|
|
522
|
+
justify-content: flex-start;
|
|
523
|
+
gap: var(--space-md);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.top {
|
|
527
|
+
top: 0;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.top:empty,
|
|
531
|
+
.bottom:empty {
|
|
532
|
+
padding: 0;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.bottom {
|
|
536
|
+
bottom: 0;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.after {
|
|
540
|
+
align-items: center;
|
|
541
|
+
justify-content: center;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.new-tab {
|
|
545
|
+
border: none;
|
|
546
|
+
color: var(--toolbar_text);
|
|
547
|
+
border-radius: var(--radius-md);
|
|
548
|
+
height: var(--tab-height);
|
|
549
|
+
width: calc(100% - calc(var(--space-md) * 2));
|
|
550
|
+
cursor: pointer;
|
|
551
|
+
display: flex;
|
|
552
|
+
align-items: center;
|
|
553
|
+
justify-content: center;
|
|
554
|
+
margin-top: var(--space-xs);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.new-tab:is(:hover, :active, :focus) {
|
|
558
|
+
background: var(--toolbar);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.sidebar-resizer {
|
|
562
|
+
position: absolute;
|
|
563
|
+
top: 0;
|
|
564
|
+
right: -4px;
|
|
565
|
+
width: 8px;
|
|
566
|
+
height: 100%;
|
|
567
|
+
cursor: ew-resize;
|
|
568
|
+
z-index: 3;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
:global(.sidebar-right *) > :scope .sidebar-resizer {
|
|
572
|
+
left: -4px;
|
|
573
|
+
right: auto;
|
|
574
|
+
}
|
|
575
|
+
`;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Arc-style grid of pinned tabs for the vertical and hybrid sidebars. Renders
|
|
579
|
+
* each pinned tab as a square favicon tile ({@link VerticalPinTile}) in a
|
|
580
|
+
* responsive grid. Clicking a tile activates that tab.
|
|
581
|
+
*
|
|
582
|
+
* Rendered by App (between the omnibar and bookmarks in the vertical header, and
|
|
583
|
+
* at the top of the hybrid sidebar) rather than by {@link Sidebar} itself, so it
|
|
584
|
+
* can sit inside the vertical header between those two pieces. The horizontal
|
|
585
|
+
* tab strip has its own pin rendering, so this list is sidebar-only.
|
|
586
|
+
*/
|
|
587
|
+
export function VerticalPinList(
|
|
588
|
+
this: FC<{
|
|
589
|
+
tabs: Tab[];
|
|
590
|
+
activetab: Tab;
|
|
591
|
+
destroyTab: (tab: Tab) => void;
|
|
592
|
+
}>
|
|
593
|
+
) {
|
|
594
|
+
// Cache tile elements per-tab so reordering/repinning doesn't recreate DOM
|
|
595
|
+
// nodes (which would reset their context menus and favicon listeners).
|
|
596
|
+
const tiles = new Map<Tab, HTMLElement>();
|
|
597
|
+
|
|
598
|
+
const getTile = (tab: Tab) => {
|
|
599
|
+
let cached = tiles.get(tab);
|
|
600
|
+
if (cached) return cached;
|
|
601
|
+
|
|
602
|
+
const tile = (
|
|
603
|
+
<VerticalPinTile
|
|
604
|
+
tab={tab}
|
|
605
|
+
active={use(this.activetab).map((active) => active === tab)}
|
|
606
|
+
dragStart={(e: MouseEvent) => beginPointerTracking(tab, e)}
|
|
607
|
+
destroy={() => this.destroyTab(tab)}
|
|
608
|
+
/>
|
|
609
|
+
) as HTMLElement;
|
|
610
|
+
|
|
611
|
+
tiles.set(tab, tile);
|
|
612
|
+
return tile;
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
// --- Drag-to-reorder for pinned tabs -----------------------------------
|
|
616
|
+
//
|
|
617
|
+
// The pin grid is a 2D auto-fit grid, so we drag with manual pointer events
|
|
618
|
+
// (matching the rest of the tab UI, which avoids the native HTML5 DnD API).
|
|
619
|
+
// During a drag the underlying `tabsService.tabs` is left untouched and the
|
|
620
|
+
// reflow is done purely with CSS transforms computed from the tiles' initial
|
|
621
|
+
// layout rects; the real reorder is committed once on drop. This keeps the
|
|
622
|
+
// drag self-contained (no reactive churn in the other tab strips) and lets us
|
|
623
|
+
// position siblings deterministically without re-measuring after each move.
|
|
624
|
+
|
|
625
|
+
const [lock, unlock] = requestUnfocusFrames();
|
|
626
|
+
const DRAG_THRESHOLD = 4;
|
|
627
|
+
const REFLOW_TRANSITION = "transform 200ms cubic-bezier(.43,.52,0,1.15)";
|
|
628
|
+
|
|
629
|
+
type DragState = {
|
|
630
|
+
tab: Tab;
|
|
631
|
+
tile: HTMLElement;
|
|
632
|
+
pointerStart: { x: number; y: number };
|
|
633
|
+
grabOffset: { x: number; y: number };
|
|
634
|
+
order: Tab[];
|
|
635
|
+
rects: DOMRect[];
|
|
636
|
+
fromIndex: number;
|
|
637
|
+
targetIndex: number;
|
|
638
|
+
started: boolean;
|
|
639
|
+
};
|
|
640
|
+
let drag: DragState | null = null;
|
|
641
|
+
|
|
642
|
+
const beginPointerTracking = (tab: Tab, e: MouseEvent) => {
|
|
643
|
+
// Activate on press (also makes a plain click select the tab, matching the
|
|
644
|
+
// tab strips). The actual drag only starts once the pointer moves past the
|
|
645
|
+
// threshold.
|
|
646
|
+
this.activetab = tab;
|
|
647
|
+
|
|
648
|
+
drag = {
|
|
649
|
+
tab,
|
|
650
|
+
tile: getTile(tab),
|
|
651
|
+
pointerStart: { x: e.clientX, y: e.clientY },
|
|
652
|
+
grabOffset: { x: 0, y: 0 },
|
|
653
|
+
order: [],
|
|
654
|
+
rects: [],
|
|
655
|
+
fromIndex: -1,
|
|
656
|
+
targetIndex: -1,
|
|
657
|
+
started: false,
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
window.addEventListener("mousemove", onPointerMove);
|
|
661
|
+
window.addEventListener("mouseup", onPointerUp);
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
const startDrag = () => {
|
|
665
|
+
if (!drag) return;
|
|
666
|
+
const pinned = this.tabs.filter((t) => t.pinned);
|
|
667
|
+
drag.order = pinned;
|
|
668
|
+
drag.rects = pinned.map((t) => getTile(t).getBoundingClientRect());
|
|
669
|
+
drag.fromIndex = pinned.indexOf(drag.tab);
|
|
670
|
+
drag.targetIndex = drag.fromIndex;
|
|
671
|
+
|
|
672
|
+
const startRect = drag.rects[drag.fromIndex];
|
|
673
|
+
drag.grabOffset = {
|
|
674
|
+
x: drag.pointerStart.x - startRect.left,
|
|
675
|
+
y: drag.pointerStart.y - startRect.top,
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
drag.started = true;
|
|
679
|
+
lock();
|
|
680
|
+
document.body.style.cursor = "grabbing";
|
|
681
|
+
drag.tile.classList.add("dragging");
|
|
682
|
+
drag.tile.style.transition = "transform 0s";
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
// Nearest tile-center wins; reliable for a small, uniform icon grid.
|
|
686
|
+
const computeTargetIndex = (e: MouseEvent) => {
|
|
687
|
+
if (!drag) return 0;
|
|
688
|
+
let best = 0;
|
|
689
|
+
let bestDist = Infinity;
|
|
690
|
+
for (let i = 0; i < drag.rects.length; i++) {
|
|
691
|
+
const r = drag.rects[i];
|
|
692
|
+
const cx = r.left + r.width / 2;
|
|
693
|
+
const cy = r.top + r.height / 2;
|
|
694
|
+
const dist = (e.clientX - cx) ** 2 + (e.clientY - cy) ** 2;
|
|
695
|
+
if (dist < bestDist) {
|
|
696
|
+
bestDist = dist;
|
|
697
|
+
best = i;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return best;
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
// Slide every non-dragged tile from its original slot to the slot it would
|
|
704
|
+
// occupy if the dragged tab were dropped at `targetIndex`.
|
|
705
|
+
const applyReflow = () => {
|
|
706
|
+
if (!drag) return;
|
|
707
|
+
const visual = drag.order.filter((t) => t !== drag!.tab);
|
|
708
|
+
visual.splice(drag.targetIndex, 0, drag.tab);
|
|
709
|
+
|
|
710
|
+
for (let slot = 0; slot < visual.length; slot++) {
|
|
711
|
+
const tab = visual[slot];
|
|
712
|
+
if (tab === drag.tab) continue;
|
|
713
|
+
const el = getTile(tab);
|
|
714
|
+
const fromRect = drag.rects[drag.order.indexOf(tab)];
|
|
715
|
+
const toRect = drag.rects[slot];
|
|
716
|
+
const dx = toRect.left - fromRect.left;
|
|
717
|
+
const dy = toRect.top - fromRect.top;
|
|
718
|
+
el.style.transition = REFLOW_TRANSITION;
|
|
719
|
+
el.style.transform = dx || dy ? `translate(${dx}px, ${dy}px)` : "";
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
const followCursor = (e: MouseEvent) => {
|
|
724
|
+
if (!drag) return;
|
|
725
|
+
const base = drag.rects[drag.fromIndex];
|
|
726
|
+
const tx = e.clientX - drag.grabOffset.x - base.left;
|
|
727
|
+
const ty = e.clientY - drag.grabOffset.y - base.top;
|
|
728
|
+
drag.tile.style.transform = `translate(${tx}px, ${ty}px)`;
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
const onPointerMove = (e: MouseEvent) => {
|
|
732
|
+
if (!drag) return;
|
|
733
|
+
if (!drag.started) {
|
|
734
|
+
const dist = Math.hypot(
|
|
735
|
+
e.clientX - drag.pointerStart.x,
|
|
736
|
+
e.clientY - drag.pointerStart.y
|
|
737
|
+
);
|
|
738
|
+
if (dist < DRAG_THRESHOLD) return;
|
|
739
|
+
startDrag();
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
const target = computeTargetIndex(e);
|
|
743
|
+
if (target !== drag.targetIndex) {
|
|
744
|
+
drag.targetIndex = target;
|
|
745
|
+
applyReflow();
|
|
746
|
+
}
|
|
747
|
+
followCursor(e);
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
const onPointerUp = () => {
|
|
751
|
+
window.removeEventListener("mousemove", onPointerMove);
|
|
752
|
+
window.removeEventListener("mouseup", onPointerUp);
|
|
753
|
+
if (!drag) return;
|
|
754
|
+
|
|
755
|
+
if (drag.started) {
|
|
756
|
+
const { tab, fromIndex, targetIndex } = drag;
|
|
757
|
+
// Clear all inline drag styling, then commit the reorder in the same
|
|
758
|
+
// synchronous tick so the reactive re-render lands without a flash.
|
|
759
|
+
for (const t of drag.order) {
|
|
760
|
+
const el = getTile(t);
|
|
761
|
+
el.style.transition = "";
|
|
762
|
+
el.style.transform = "";
|
|
763
|
+
}
|
|
764
|
+
drag.tile.classList.remove("dragging");
|
|
765
|
+
document.body.style.cursor = "";
|
|
766
|
+
unlock();
|
|
767
|
+
|
|
768
|
+
if (targetIndex !== fromIndex) {
|
|
769
|
+
const pinned = this.tabs.filter((t) => t.pinned);
|
|
770
|
+
const from = pinned.indexOf(tab);
|
|
771
|
+
const to = Math.max(0, Math.min(targetIndex, pinned.length - 1));
|
|
772
|
+
// Guard against the dragged tab having been unpinned/closed mid-drag
|
|
773
|
+
// (from === -1) and against a no-op move (from === to). Either way we
|
|
774
|
+
// still fall through to `drag = null` below so drag state is cleared.
|
|
775
|
+
if (from !== -1 && from !== to) {
|
|
776
|
+
pinned.splice(from, 1);
|
|
777
|
+
pinned.splice(to, 0, tab);
|
|
778
|
+
tabsService.tabs = [...pinned, ...this.tabs.filter((t) => !t.pinned)];
|
|
779
|
+
tabsService.markDirty();
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
drag = null;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
// Drop cached tiles for tabs that are no longer pinned or were closed.
|
|
788
|
+
use(this.tabs).listen((tabs) => {
|
|
789
|
+
const pinned = new Set(tabs.filter((tab) => tab.pinned));
|
|
790
|
+
for (const tab of [...tiles.keys()]) {
|
|
791
|
+
if (!pinned.has(tab)) tiles.delete(tab);
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
return (
|
|
796
|
+
<div
|
|
797
|
+
class="pinned-tabs"
|
|
798
|
+
class:empty={use(this.tabs).map((tabs) => !tabs.some((t) => t.pinned))}
|
|
799
|
+
>
|
|
800
|
+
{use(this.tabs)
|
|
801
|
+
.map((tabs) => tabs.filter((tab) => tab.pinned))
|
|
802
|
+
.mapEach((tab) => getTile(tab))}
|
|
803
|
+
</div>
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
VerticalPinList.style = css`
|
|
808
|
+
:scope {
|
|
809
|
+
display: grid;
|
|
810
|
+
grid-template-columns: repeat(
|
|
811
|
+
auto-fit,
|
|
812
|
+
minmax(calc(var(--omnibar-height) + var(--space-xs)), 1fr)
|
|
813
|
+
);
|
|
814
|
+
gap: var(--space-sm);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
:scope.empty {
|
|
818
|
+
display: none;
|
|
819
|
+
}
|
|
820
|
+
`;
|