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,203 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Object_defineProperty,
|
|
3
|
+
Number_isSafeInteger,
|
|
4
|
+
Error,
|
|
5
|
+
} from "@/shared/snapshot";
|
|
6
|
+
import { SCRAMJETCLIENT, SCRAMJETCLIENTNAME } from "@/symbols";
|
|
7
|
+
import { ProxyCtx, ScramjetClient } from "@client/index";
|
|
8
|
+
|
|
9
|
+
enum RewriteType {
|
|
10
|
+
Insert = 0,
|
|
11
|
+
Replace = 1,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Rewrite = {
|
|
15
|
+
start: number;
|
|
16
|
+
} & (
|
|
17
|
+
| {
|
|
18
|
+
type: RewriteType.Insert;
|
|
19
|
+
size: number;
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
type: RewriteType.Replace;
|
|
23
|
+
end: number;
|
|
24
|
+
str: string;
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export type SourceMaps = Record<string, Rewrite[]>;
|
|
29
|
+
|
|
30
|
+
function getEnd(rewrite: Rewrite): number {
|
|
31
|
+
if (rewrite.type === RewriteType.Insert) {
|
|
32
|
+
return rewrite.start + rewrite.size;
|
|
33
|
+
} else if (rewrite.type === RewriteType.Replace) {
|
|
34
|
+
return rewrite.end;
|
|
35
|
+
}
|
|
36
|
+
throw "unreachable";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function registerRewrites(
|
|
40
|
+
client: ScramjetClient,
|
|
41
|
+
buf: Array<number>,
|
|
42
|
+
tag: string
|
|
43
|
+
) {
|
|
44
|
+
const sourcemap = Uint8Array.from(buf);
|
|
45
|
+
const view = new DataView(sourcemap.buffer);
|
|
46
|
+
const decoder = new TextDecoder("utf-8");
|
|
47
|
+
|
|
48
|
+
const rewrites: Rewrite[] = [];
|
|
49
|
+
|
|
50
|
+
const rewritelen = view.getUint32(0, true);
|
|
51
|
+
let cursor = 4;
|
|
52
|
+
for (let i = 0; i < rewritelen; i++) {
|
|
53
|
+
const start = view.getUint32(cursor, true);
|
|
54
|
+
cursor += 4;
|
|
55
|
+
const size = view.getUint32(cursor, true);
|
|
56
|
+
cursor += 4;
|
|
57
|
+
|
|
58
|
+
const type = view.getUint8(cursor) as RewriteType;
|
|
59
|
+
cursor += 1;
|
|
60
|
+
|
|
61
|
+
if (type == RewriteType.Insert) {
|
|
62
|
+
rewrites.push({ type, start, size });
|
|
63
|
+
} else if (type == RewriteType.Replace) {
|
|
64
|
+
const end = start + size;
|
|
65
|
+
|
|
66
|
+
const oldLen = view.getUint32(cursor, true);
|
|
67
|
+
cursor += 4;
|
|
68
|
+
|
|
69
|
+
const oldStr = decoder.decode(
|
|
70
|
+
sourcemap.subarray(cursor, cursor + oldLen)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
rewrites.push({ type, start, end, str: oldStr });
|
|
74
|
+
cursor += oldLen;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
client.box.sourcemaps[tag] = rewrites;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const SCRAMTAG = "/*scramtag ";
|
|
82
|
+
|
|
83
|
+
function extractTag(fn: string): [string, number, number] | null {
|
|
84
|
+
// every function rewritten will have a scramtag comment
|
|
85
|
+
// it will look like this:
|
|
86
|
+
// function name()[possible whitespace]/*scramtag [index] [tag]*/[possible whitespace]{ ... }
|
|
87
|
+
|
|
88
|
+
const start = fn.indexOf(SCRAMTAG);
|
|
89
|
+
// no scramtag, probably native function or stolen from scramjet
|
|
90
|
+
if (start === -1) return null;
|
|
91
|
+
|
|
92
|
+
const end = fn.indexOf("*/", start);
|
|
93
|
+
if (end === -1) {
|
|
94
|
+
dbg.error("unreachable", fn, start, end);
|
|
95
|
+
throw new Error("unreachable");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const tag = fn.substring(start + 2, end).split(" ");
|
|
99
|
+
|
|
100
|
+
if (
|
|
101
|
+
tag.length !== 3 ||
|
|
102
|
+
tag[0] !== "scramtag" ||
|
|
103
|
+
!Number_isSafeInteger(+tag[1])
|
|
104
|
+
) {
|
|
105
|
+
dbg.error("invalid tag", fn, start, end, tag);
|
|
106
|
+
throw new Error("invalid tag");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return [tag[2], start, +tag[1]];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function doUnrewrite(
|
|
113
|
+
client: ScramjetClient,
|
|
114
|
+
ctx: ProxyCtx<"Function.prototype.toString", "apply">
|
|
115
|
+
) {
|
|
116
|
+
const stringified: string = ctx.fn.call(ctx.this);
|
|
117
|
+
|
|
118
|
+
const extracted = extractTag(stringified);
|
|
119
|
+
if (!extracted) return ctx.return(stringified);
|
|
120
|
+
const [tag, tagOffset, tagStart] = extracted;
|
|
121
|
+
|
|
122
|
+
const fnStart = tagStart - tagOffset;
|
|
123
|
+
const fnEnd = fnStart + stringified.length;
|
|
124
|
+
const rewrites = client.box.sourcemaps[tag];
|
|
125
|
+
|
|
126
|
+
if (!rewrites) {
|
|
127
|
+
dbg.warn("failed to get rewrites for tag", tag);
|
|
128
|
+
|
|
129
|
+
return ctx.return(stringified);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let i = 0;
|
|
133
|
+
// skip all rewrites in the file before the fn
|
|
134
|
+
while (i < rewrites.length) {
|
|
135
|
+
if (rewrites[i].start < fnStart) i++;
|
|
136
|
+
else break;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let end = i;
|
|
140
|
+
while (end < rewrites.length) {
|
|
141
|
+
if (getEnd(rewrites[end]) < fnEnd) end++;
|
|
142
|
+
else break;
|
|
143
|
+
}
|
|
144
|
+
const fnrewrites = rewrites.slice(i, end);
|
|
145
|
+
|
|
146
|
+
let newString = "";
|
|
147
|
+
let lastpos = 0;
|
|
148
|
+
|
|
149
|
+
for (const rewrite of fnrewrites) {
|
|
150
|
+
newString += stringified.slice(lastpos, rewrite.start - fnStart);
|
|
151
|
+
|
|
152
|
+
if (rewrite.type === RewriteType.Insert) {
|
|
153
|
+
lastpos = rewrite.start + rewrite.size - fnStart;
|
|
154
|
+
} else if (rewrite.type === RewriteType.Replace) {
|
|
155
|
+
newString += rewrite.str;
|
|
156
|
+
lastpos = rewrite.end - fnStart;
|
|
157
|
+
} else {
|
|
158
|
+
throw "unreachable";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
newString += stringified.slice(lastpos);
|
|
163
|
+
newString = newString.replace(`${SCRAMTAG}${tagStart} ${tag}*/`, "");
|
|
164
|
+
|
|
165
|
+
return ctx.return(newString);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const enabled = (client: ScramjetClient) =>
|
|
169
|
+
client.flagEnabled("sourcemaps");
|
|
170
|
+
|
|
171
|
+
export default function (client: ScramjetClient, self: Self) {
|
|
172
|
+
// every script will push a sourcemap
|
|
173
|
+
Object_defineProperty(self, client.config.globals.pushsourcemapfn, {
|
|
174
|
+
value: (buf: Array<number>, tag: string) => {
|
|
175
|
+
// const before = performance.now();
|
|
176
|
+
registerRewrites(client, buf, tag);
|
|
177
|
+
// if (client.flagEnabled("rewriterLogs")) {
|
|
178
|
+
// dbg.time(client.meta, before, `scramtag parse for ${tag}`);
|
|
179
|
+
// }
|
|
180
|
+
},
|
|
181
|
+
enumerable: false,
|
|
182
|
+
writable: false,
|
|
183
|
+
configurable: false,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// when we rewrite javascript it will make function.toString leak internals
|
|
187
|
+
// this can lead to double rewrites which is bad
|
|
188
|
+
client.Proxy("Function.prototype.toString", {
|
|
189
|
+
apply(ctx) {
|
|
190
|
+
if (client.box.unproxy.has(ctx.this)) {
|
|
191
|
+
// toString is being called on a proxy of a native function
|
|
192
|
+
// `this` will then be the proxy, which has the wrong [[SourceText]]
|
|
193
|
+
// unproxy so it passes through
|
|
194
|
+
ctx.this = client.box.unproxy.get(ctx.this)!;
|
|
195
|
+
// since we know it's a native function, no need to unrewrite
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
// const before = performance.now();
|
|
199
|
+
doUnrewrite(client, ctx);
|
|
200
|
+
// dbg.time(client.meta, before, `scramtag unrewrite for ${ctx.fn.name}`);
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ScramjetClient } from "@client/index";
|
|
2
|
+
|
|
3
|
+
export default function (client: ScramjetClient, _self: GlobalThis) {
|
|
4
|
+
client.Proxy("Worker", {
|
|
5
|
+
construct(ctx) {
|
|
6
|
+
ctx.args[0] = client.rewriteUrl(ctx.args[0], {
|
|
7
|
+
destination: "worker",
|
|
8
|
+
isModule: ctx.args[1]?.type === "module",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const worker = ctx.call();
|
|
12
|
+
// const conn = new BareMuxConnection();
|
|
13
|
+
|
|
14
|
+
// (async () => {
|
|
15
|
+
// const port = await conn.getInnerPort();
|
|
16
|
+
// client.natives.call(
|
|
17
|
+
// "Worker.prototype.postMessage",
|
|
18
|
+
// worker,
|
|
19
|
+
// {
|
|
20
|
+
// $scramjet$type: "baremuxinit",
|
|
21
|
+
// port,
|
|
22
|
+
// },
|
|
23
|
+
// [port]
|
|
24
|
+
// );
|
|
25
|
+
// })();
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// sharedworkers can only be constructed from window
|
|
30
|
+
client.Proxy("SharedWorker", {
|
|
31
|
+
construct(ctx) {
|
|
32
|
+
const isModule =
|
|
33
|
+
typeof ctx.args[1] === "object" && ctx.args[1]?.type === "module";
|
|
34
|
+
|
|
35
|
+
ctx.args[0] = client.rewriteUrl(ctx.args[0], {
|
|
36
|
+
destination: "sharedworker",
|
|
37
|
+
isModule,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (ctx.args[1] && typeof ctx.args[1] === "string")
|
|
41
|
+
ctx.args[1] = `${client.url.origin}@${ctx.args[1]}`;
|
|
42
|
+
|
|
43
|
+
if (ctx.args[1] && typeof ctx.args[1] === "object") {
|
|
44
|
+
if (ctx.args[1].name) {
|
|
45
|
+
ctx.args[1].name = `${client.url.origin}@${ctx.args[1].name}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const worker = ctx.call();
|
|
50
|
+
// const conn = new BareMuxConnection();
|
|
51
|
+
|
|
52
|
+
// (async () => {
|
|
53
|
+
// const port = await conn.getInnerPort();
|
|
54
|
+
// client.natives.call(
|
|
55
|
+
// "MessagePort.prototype.postMessage",
|
|
56
|
+
// worker.port,
|
|
57
|
+
// {
|
|
58
|
+
// $scramjet$type: "baremuxinit",
|
|
59
|
+
// port,
|
|
60
|
+
// },
|
|
61
|
+
// [port]
|
|
62
|
+
// );
|
|
63
|
+
// })();
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
client.Proxy("Worklet.prototype.addModule", {
|
|
68
|
+
apply(ctx) {
|
|
69
|
+
if (ctx.args[0]) ctx.args[0] = client.rewriteUrl(ctx.args[0]);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { iswindow } from "@client/entry";
|
|
2
|
+
import { SCRAMJETCLIENT } from "@/symbols";
|
|
3
|
+
import { ScramjetClient } from "@client/index";
|
|
4
|
+
// import { argdbg } from "@client/shared/err";
|
|
5
|
+
import { indirectEval } from "@client/shared/eval";
|
|
6
|
+
import { Object_defineProperty } from "@/shared/snapshot";
|
|
7
|
+
|
|
8
|
+
export function createWrapFn(client: ScramjetClient, self: GlobalThis) {
|
|
9
|
+
let wrappedParent: GlobalThis | null = null;
|
|
10
|
+
let wrappedTop: GlobalThis | null = null;
|
|
11
|
+
if (iswindow) {
|
|
12
|
+
try {
|
|
13
|
+
if (SCRAMJETCLIENT in self.parent) {
|
|
14
|
+
// ... then we're in a subframe, and the parent frame is also in a proxy context, so we should return its proxy
|
|
15
|
+
wrappedParent = self.parent;
|
|
16
|
+
} else {
|
|
17
|
+
// ... then we should pretend we aren't nested and return the current window
|
|
18
|
+
wrappedParent = self;
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
// accessing self.parent can throw if it's cross-origin, in which case we should also pretend we aren't nested
|
|
22
|
+
wrappedParent = self;
|
|
23
|
+
}
|
|
24
|
+
// instead of returning top, we need to return the uppermost parent that's inside a scramjet context
|
|
25
|
+
let current = self;
|
|
26
|
+
for (;;) {
|
|
27
|
+
const test = current.parent.self;
|
|
28
|
+
if (test === current) break; // there is no parent, actual or emulated.
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
// ... then `test` represents a window outside of the proxy context, and therefore `current` is the topmost window in the proxy context
|
|
32
|
+
if (!(SCRAMJETCLIENT in test)) break;
|
|
33
|
+
} catch {
|
|
34
|
+
// accessing test can throw if it's cross-origin, in which case we should also break
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
// test is also insde a proxy, so we should continue up the chain
|
|
38
|
+
current = test;
|
|
39
|
+
}
|
|
40
|
+
wrappedTop = current;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return function (identifier: any, strict: boolean) {
|
|
44
|
+
if (identifier === self.location) return client.locationProxy;
|
|
45
|
+
if (identifier === self.eval) {
|
|
46
|
+
// TODO: make this per-client, don't regen every time
|
|
47
|
+
const bound = indirectEval.bind(client, strict);
|
|
48
|
+
client.box.unproxy.set(bound, self.eval);
|
|
49
|
+
return bound;
|
|
50
|
+
}
|
|
51
|
+
if (iswindow) {
|
|
52
|
+
if (identifier === self.parent) {
|
|
53
|
+
return wrappedParent;
|
|
54
|
+
} else if (identifier === self.top) {
|
|
55
|
+
return wrappedTop;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return identifier;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const order = 4;
|
|
63
|
+
export default function (client: ScramjetClient, self: GlobalThis) {
|
|
64
|
+
Object_defineProperty(self, client.config.globals.wrapfn, {
|
|
65
|
+
value: client.wrapfn,
|
|
66
|
+
writable: false,
|
|
67
|
+
configurable: false,
|
|
68
|
+
enumerable: false,
|
|
69
|
+
});
|
|
70
|
+
Object_defineProperty(self, client.config.globals.wrappropertyfn, {
|
|
71
|
+
value: function (str) {
|
|
72
|
+
if (
|
|
73
|
+
str === "location" ||
|
|
74
|
+
str === "parent" ||
|
|
75
|
+
str === "top" ||
|
|
76
|
+
str === "eval"
|
|
77
|
+
)
|
|
78
|
+
return client.config.globals.wrappropertybase + str;
|
|
79
|
+
|
|
80
|
+
return str;
|
|
81
|
+
},
|
|
82
|
+
writable: false,
|
|
83
|
+
configurable: false,
|
|
84
|
+
enumerable: false,
|
|
85
|
+
});
|
|
86
|
+
Object_defineProperty(self, client.config.globals.cleanrestfn, {
|
|
87
|
+
value: function (obj) {
|
|
88
|
+
// TODO
|
|
89
|
+
},
|
|
90
|
+
writable: false,
|
|
91
|
+
configurable: false,
|
|
92
|
+
enumerable: false,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
Object_defineProperty(
|
|
96
|
+
self.Object.prototype,
|
|
97
|
+
client.config.globals.wrappropertybase + "location",
|
|
98
|
+
{
|
|
99
|
+
get: function () {
|
|
100
|
+
// if (this.location.constructor.toString().includes("Location")) {
|
|
101
|
+
|
|
102
|
+
if (this === self || this === self.document) {
|
|
103
|
+
return client.locationProxy;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return this.location;
|
|
107
|
+
},
|
|
108
|
+
set(value: any) {
|
|
109
|
+
if (this === self || this === self.document) {
|
|
110
|
+
client.url = value;
|
|
111
|
+
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.location = value;
|
|
115
|
+
},
|
|
116
|
+
configurable: false,
|
|
117
|
+
enumerable: false,
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
Object_defineProperty(
|
|
121
|
+
self.Object.prototype,
|
|
122
|
+
client.config.globals.wrappropertybase + "parent",
|
|
123
|
+
{
|
|
124
|
+
get: function () {
|
|
125
|
+
return client.wrapfn(this.parent, false);
|
|
126
|
+
},
|
|
127
|
+
set(value: any) {
|
|
128
|
+
// i guess??
|
|
129
|
+
this.parent = value;
|
|
130
|
+
},
|
|
131
|
+
configurable: false,
|
|
132
|
+
enumerable: false,
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
Object_defineProperty(
|
|
136
|
+
self.Object.prototype,
|
|
137
|
+
client.config.globals.wrappropertybase + "top",
|
|
138
|
+
{
|
|
139
|
+
get: function () {
|
|
140
|
+
return client.wrapfn(this.top, false);
|
|
141
|
+
},
|
|
142
|
+
set(value: any) {
|
|
143
|
+
this.top = value;
|
|
144
|
+
},
|
|
145
|
+
configurable: false,
|
|
146
|
+
enumerable: false,
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
Object_defineProperty(
|
|
150
|
+
self.Object.prototype,
|
|
151
|
+
client.config.globals.wrappropertybase + "eval",
|
|
152
|
+
{
|
|
153
|
+
get: function () {
|
|
154
|
+
return client.wrapfn(this.eval, true);
|
|
155
|
+
},
|
|
156
|
+
set(value: any) {
|
|
157
|
+
this.eval = value;
|
|
158
|
+
},
|
|
159
|
+
configurable: false,
|
|
160
|
+
enumerable: false,
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
self.$scramitize = function (v) {
|
|
165
|
+
const t = typeof v;
|
|
166
|
+
if (t === "object" && v !== null) {
|
|
167
|
+
if (v === location) debugger;
|
|
168
|
+
if (iswindow) {
|
|
169
|
+
// if (v === self.parent) debugger;
|
|
170
|
+
if (v === self.top) debugger;
|
|
171
|
+
}
|
|
172
|
+
} else if (t === "string") {
|
|
173
|
+
if (v.includes("scramjet")) debugger;
|
|
174
|
+
if (v.includes("~/sj")) debugger;
|
|
175
|
+
if (v.includes(location.origin)) debugger;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return v;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// location = "..." can't be rewritten as wrapfn(location) = ..., so instead it will actually be rewritten as
|
|
182
|
+
// ((t)=>$scramjet$tryset(location,"+=",t)||location+=t)(...);
|
|
183
|
+
// it has to be a discrete function because there's always the possibility that "location" is a local variable
|
|
184
|
+
// we have to use an IIFE to avoid duplicating side-effects in the getter
|
|
185
|
+
Object_defineProperty(self, client.config.globals.trysetfn, {
|
|
186
|
+
value: function (lhs: any, op: string, rhs: any) {
|
|
187
|
+
if (client.box.locations.has(lhs)) {
|
|
188
|
+
lhs.href = rhs;
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return false;
|
|
193
|
+
},
|
|
194
|
+
writable: false,
|
|
195
|
+
configurable: false,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IncrementalHtmlRewriter } from "@/shared";
|
|
2
|
+
import { ScramjetClient } from "./client";
|
|
3
|
+
import { SourceMaps } from "./shared/sourcemaps";
|
|
4
|
+
import {
|
|
5
|
+
Object_getOwnPropertyNames,
|
|
6
|
+
Object_getOwnPropertyDescriptor,
|
|
7
|
+
} from "@/shared/snapshot";
|
|
8
|
+
|
|
9
|
+
export class SingletonBox {
|
|
10
|
+
clients: ScramjetClient[] = [];
|
|
11
|
+
globals: Map<Self, ScramjetClient> = new Map();
|
|
12
|
+
documents: Map<Document, ScramjetClient> = new Map();
|
|
13
|
+
histories: Map<History, ScramjetClient> = new Map();
|
|
14
|
+
locations: Map<Location, ScramjetClient> = new Map();
|
|
15
|
+
writeRewriters = new WeakMap<Document, IncrementalHtmlRewriter>();
|
|
16
|
+
unproxy = new Map<any, any>();
|
|
17
|
+
|
|
18
|
+
ctors: Record<string, Function[]> = {};
|
|
19
|
+
|
|
20
|
+
sourcemaps: SourceMaps = {};
|
|
21
|
+
|
|
22
|
+
constructor(public ownerclient: ScramjetClient) {}
|
|
23
|
+
|
|
24
|
+
registerClient(client: ScramjetClient, global: Self) {
|
|
25
|
+
this.clients.push(client);
|
|
26
|
+
this.globals.set(global, client);
|
|
27
|
+
this.documents.set(global.document, client);
|
|
28
|
+
this.locations.set(global.location, client);
|
|
29
|
+
this.histories.set(global.history, client);
|
|
30
|
+
|
|
31
|
+
Object_getOwnPropertyNames(global).forEach((prop) => {
|
|
32
|
+
const desc = Object_getOwnPropertyDescriptor(global, prop);
|
|
33
|
+
if (desc && typeof desc.value === "function") {
|
|
34
|
+
if (!this.ctors[prop]) this.ctors[prop] = [];
|
|
35
|
+
this.ctors[prop].push(desc.value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
instanceof(obj: any, name: string): boolean {
|
|
41
|
+
const ctors = this.ctors[name];
|
|
42
|
+
if (!ctors) {
|
|
43
|
+
dbg.error(`No constructors for ${name} found`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
for (const ctor of ctors) {
|
|
47
|
+
// eslint-disable-next-line scramjet-core/no-instanceof
|
|
48
|
+
if (obj instanceof ctor) return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ScramjetClient } from "@client/index";
|
|
2
|
+
import { String } from "@/shared/snapshot";
|
|
3
|
+
|
|
4
|
+
export default function (client: ScramjetClient) {
|
|
5
|
+
client.Proxy("importScripts", {
|
|
6
|
+
apply(ctx) {
|
|
7
|
+
for (const i in ctx.args) {
|
|
8
|
+
const url = String(ctx.args[i]);
|
|
9
|
+
ctx.args[i] = client.rewriteUrl(url);
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { BareResponse } from "@mercuryworkshop/proxy-transports";
|
|
2
|
+
import {
|
|
3
|
+
BodyType,
|
|
4
|
+
ScramjetFetchHandler,
|
|
5
|
+
ScramjetFetchParsed,
|
|
6
|
+
ScramjetFetchRequest,
|
|
7
|
+
} from ".";
|
|
8
|
+
import {
|
|
9
|
+
flagEnabled,
|
|
10
|
+
isHtmlMimeType,
|
|
11
|
+
isJavascriptMimeType,
|
|
12
|
+
rewriteCss,
|
|
13
|
+
rewriteHtml,
|
|
14
|
+
rewriteJs,
|
|
15
|
+
rewriteWorkers,
|
|
16
|
+
} from "@/shared";
|
|
17
|
+
import { sniffEncoding } from "@/shared/sniffEncoding";
|
|
18
|
+
import { _TextDecoder } from "@/shared/snapshot";
|
|
19
|
+
|
|
20
|
+
export async function rewriteBody(
|
|
21
|
+
handler: ScramjetFetchHandler,
|
|
22
|
+
request: ScramjetFetchRequest,
|
|
23
|
+
parsed: ScramjetFetchParsed,
|
|
24
|
+
response: BareResponse
|
|
25
|
+
): Promise<BodyType> {
|
|
26
|
+
switch (parsed.destination) {
|
|
27
|
+
case "iframe":
|
|
28
|
+
case "document":
|
|
29
|
+
if (isHtmlMimeType(response.headers.get("content-type") ?? "")) {
|
|
30
|
+
const buf = await response.arrayBuffer();
|
|
31
|
+
const bytes = new Uint8Array(buf);
|
|
32
|
+
const encoding = sniffEncoding(
|
|
33
|
+
bytes,
|
|
34
|
+
response.headers.get("content-type")
|
|
35
|
+
);
|
|
36
|
+
const htmlContent = new _TextDecoder(encoding).decode(bytes);
|
|
37
|
+
|
|
38
|
+
return rewriteHtml(htmlContent, handler.context, parsed.meta, {
|
|
39
|
+
loadScripts: true,
|
|
40
|
+
inline: true,
|
|
41
|
+
source: parsed.url.href,
|
|
42
|
+
headers: response.rawHeaders,
|
|
43
|
+
// reasonably confident that a document fetch is impossible without a client
|
|
44
|
+
history: parsed.trackedClient!.history,
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
return response.body;
|
|
48
|
+
}
|
|
49
|
+
case "script": {
|
|
50
|
+
// do not attempt to rewrite a 404 response
|
|
51
|
+
if (response.ok) {
|
|
52
|
+
const ct = response.headers.get("content-type");
|
|
53
|
+
// don't rewrite invalid module scripts when the server declares a non-JS type
|
|
54
|
+
if (parsed.isModule && ct && !isJavascriptMimeType(ct)) {
|
|
55
|
+
return response.body;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let rewritten = rewriteJs(
|
|
59
|
+
new Uint8Array(await response.arrayBuffer()),
|
|
60
|
+
response.url,
|
|
61
|
+
handler.context,
|
|
62
|
+
parsed.meta,
|
|
63
|
+
parsed.isModule
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (
|
|
67
|
+
flagEnabled("debugSourceURL", handler.context, parsed.meta.origin)
|
|
68
|
+
) {
|
|
69
|
+
if (rewritten instanceof Uint8Array) {
|
|
70
|
+
rewritten = new TextDecoder().decode(rewritten);
|
|
71
|
+
}
|
|
72
|
+
rewritten += `\n//# sourceURL=${parsed.url.href}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return rewritten as unknown as ArrayBuffer;
|
|
76
|
+
}
|
|
77
|
+
return response.body;
|
|
78
|
+
}
|
|
79
|
+
case "style":
|
|
80
|
+
return rewriteCss(await response.text(), handler.context, parsed.meta);
|
|
81
|
+
case "sharedworker":
|
|
82
|
+
case "worker":
|
|
83
|
+
return rewriteWorkers(
|
|
84
|
+
new Uint8Array(await response.arrayBuffer()),
|
|
85
|
+
response.url,
|
|
86
|
+
handler.context,
|
|
87
|
+
parsed.meta,
|
|
88
|
+
parsed.isModule
|
|
89
|
+
);
|
|
90
|
+
default:
|
|
91
|
+
return response.body;
|
|
92
|
+
}
|
|
93
|
+
}
|