@browserless.io/browserless 2.0.0-beta-1
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/CHANGELOG.md +674 -0
- package/LICENSE +6 -0
- package/README.md +132 -0
- package/assets/logo.png +0 -0
- package/bin/browserless.js +227 -0
- package/browser.json +7 -0
- package/build/browserless.d.ts +33 -0
- package/build/browserless.js +146 -0
- package/build/browsers/cdp-chromium.d.ts +41 -0
- package/build/browsers/cdp-chromium.js +287 -0
- package/build/browsers/index.d.ts +26 -0
- package/build/browsers/index.js +183 -0
- package/build/browsers/playwright-chromium.d.ts +34 -0
- package/build/browsers/playwright-chromium.js +106 -0
- package/build/browsers/playwright-firefox.d.ts +34 -0
- package/build/browsers/playwright-firefox.js +101 -0
- package/build/browsers/playwright-webkit.d.ts +34 -0
- package/build/browsers/playwright-webkit.js +101 -0
- package/build/config.d.ts +138 -0
- package/build/config.js +349 -0
- package/build/constants.d.ts +4 -0
- package/build/constants.js +4 -0
- package/build/data/classes.json +1 -0
- package/build/data/selectors.json +1 -0
- package/build/exports.d.ts +20 -0
- package/build/exports.js +22 -0
- package/build/file-system.d.ts +24 -0
- package/build/file-system.js +46 -0
- package/build/hooks.d.ts +5 -0
- package/build/hooks.js +20 -0
- package/build/http.d.ts +175 -0
- package/build/http.js +104 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +39 -0
- package/build/limiter.d.ts +24 -0
- package/build/limiter.js +147 -0
- package/build/limiter.spec.d.ts +1 -0
- package/build/limiter.spec.js +241 -0
- package/build/metrics.d.ts +24 -0
- package/build/metrics.js +86 -0
- package/build/metrics.spec.d.ts +1 -0
- package/build/metrics.spec.js +35 -0
- package/build/mime-types.d.ts +1 -0
- package/build/mime-types.js +328 -0
- package/build/monitoring.d.ts +13 -0
- package/build/monitoring.js +38 -0
- package/build/routes/chromium/http/content-post.body.json +514 -0
- package/build/routes/chromium/http/content-post.d.ts +34 -0
- package/build/routes/chromium/http/content-post.js +109 -0
- package/build/routes/chromium/http/content-post.query.json +183 -0
- package/build/routes/chromium/http/content-post.response.json +5 -0
- package/build/routes/chromium/http/download-post.body.json +32 -0
- package/build/routes/chromium/http/download-post.d.ts +16 -0
- package/build/routes/chromium/http/download-post.js +92 -0
- package/build/routes/chromium/http/download-post.query.json +120 -0
- package/build/routes/chromium/http/download-post.response.json +4 -0
- package/build/routes/chromium/http/function-post.body.json +32 -0
- package/build/routes/chromium/http/function-post.d.ts +18 -0
- package/build/routes/chromium/http/function-post.js +53 -0
- package/build/routes/chromium/http/function-post.query.json +120 -0
- package/build/routes/chromium/http/function-post.response.json +4 -0
- package/build/routes/chromium/http/pdf-post.body.json +654 -0
- package/build/routes/chromium/http/pdf-post.d.ts +35 -0
- package/build/routes/chromium/http/pdf-post.js +107 -0
- package/build/routes/chromium/http/pdf-post.query.json +120 -0
- package/build/routes/chromium/http/pdf-post.response.json +5 -0
- package/build/routes/chromium/http/performance.body.json +26 -0
- package/build/routes/chromium/http/performance.d.ts +17 -0
- package/build/routes/chromium/http/performance.js +30 -0
- package/build/routes/chromium/http/performance.query.json +120 -0
- package/build/routes/chromium/http/performance.response.json +7 -0
- package/build/routes/chromium/http/scrape-post.body.json +561 -0
- package/build/routes/chromium/http/scrape-post.d.ts +106 -0
- package/build/routes/chromium/http/scrape-post.js +205 -0
- package/build/routes/chromium/http/scrape-post.query.json +183 -0
- package/build/routes/chromium/http/scrape-post.response.json +325 -0
- package/build/routes/chromium/http/screenshot-post.body.json +604 -0
- package/build/routes/chromium/http/screenshot-post.d.ts +37 -0
- package/build/routes/chromium/http/screenshot-post.js +124 -0
- package/build/routes/chromium/http/screenshot-post.query.json +120 -0
- package/build/routes/chromium/http/screenshot-post.response.json +5 -0
- package/build/routes/chromium/tests/content.spec.d.ts +1 -0
- package/build/routes/chromium/tests/content.spec.js +285 -0
- package/build/routes/chromium/tests/download.spec.d.ts +1 -0
- package/build/routes/chromium/tests/download.spec.js +67 -0
- package/build/routes/chromium/tests/function.spec.d.ts +1 -0
- package/build/routes/chromium/tests/function.spec.js +245 -0
- package/build/routes/chromium/tests/pdf.spec.d.ts +1 -0
- package/build/routes/chromium/tests/pdf.spec.js +333 -0
- package/build/routes/chromium/tests/performance.spec.d.ts +1 -0
- package/build/routes/chromium/tests/performance.spec.js +124 -0
- package/build/routes/chromium/tests/scrape.spec.d.ts +1 -0
- package/build/routes/chromium/tests/scrape.spec.js +354 -0
- package/build/routes/chromium/tests/screenshot.spec.d.ts +1 -0
- package/build/routes/chromium/tests/screenshot.spec.js +339 -0
- package/build/routes/chromium/tests/websocket.spec.d.ts +1 -0
- package/build/routes/chromium/tests/websocket.spec.js +309 -0
- package/build/routes/chromium/utils/function/client.d.ts +26 -0
- package/build/routes/chromium/utils/function/client.js +66 -0
- package/build/routes/chromium/utils/function/handler.d.ts +18 -0
- package/build/routes/chromium/utils/function/handler.js +95 -0
- package/build/routes/chromium/utils/performance/child.d.ts +1 -0
- package/build/routes/chromium/utils/performance/child.js +29 -0
- package/build/routes/chromium/utils/performance/main.d.ts +3 -0
- package/build/routes/chromium/utils/performance/main.js +65 -0
- package/build/routes/chromium/utils/performance/types.d.ts +21 -0
- package/build/routes/chromium/utils/performance/types.js +1 -0
- package/build/routes/chromium/ws/browser.d.ts +6 -0
- package/build/routes/chromium/ws/browser.js +11 -0
- package/build/routes/chromium/ws/browser.query.json +120 -0
- package/build/routes/chromium/ws/cdp-chromium.d.ts +6 -0
- package/build/routes/chromium/ws/cdp-chromium.js +11 -0
- package/build/routes/chromium/ws/cdp-chromium.query.json +120 -0
- package/build/routes/chromium/ws/page.d.ts +6 -0
- package/build/routes/chromium/ws/page.js +11 -0
- package/build/routes/chromium/ws/page.query.json +120 -0
- package/build/routes/chromium/ws/playwright-chromium.d.ts +6 -0
- package/build/routes/chromium/ws/playwright-chromium.js +19 -0
- package/build/routes/chromium/ws/playwright-chromium.query.json +100 -0
- package/build/routes/firefox/tests/websocket.spec.d.ts +1 -0
- package/build/routes/firefox/tests/websocket.spec.js +104 -0
- package/build/routes/firefox/ws/playwright-firefox.d.ts +6 -0
- package/build/routes/firefox/ws/playwright-firefox.js +19 -0
- package/build/routes/firefox/ws/playwright-firefox.query.json +100 -0
- package/build/routes/management/http/config-get.d.ts +25 -0
- package/build/routes/management/http/config-get.js +43 -0
- package/build/routes/management/http/config-get.response.json +107 -0
- package/build/routes/management/http/metrics-get.d.ts +4 -0
- package/build/routes/management/http/metrics-get.js +24 -0
- package/build/routes/management/http/metrics-get.response.json +94 -0
- package/build/routes/management/http/metrics-total-get.d.ts +4 -0
- package/build/routes/management/http/metrics-total-get.js +60 -0
- package/build/routes/management/http/metrics-total-get.response.json +72 -0
- package/build/routes/management/http/sessions-get.d.ts +4 -0
- package/build/routes/management/http/sessions-get.js +21 -0
- package/build/routes/management/http/sessions-get.response.json +221 -0
- package/build/routes/management/http/static-get.d.ts +3 -0
- package/build/routes/management/http/static-get.js +67 -0
- package/build/routes/management/tests/management.spec.d.ts +1 -0
- package/build/routes/management/tests/management.spec.js +41 -0
- package/build/routes/webkit/tests/websocket.spec.d.ts +1 -0
- package/build/routes/webkit/tests/websocket.spec.js +104 -0
- package/build/routes/webkit/ws/playwright-webkit.d.ts +6 -0
- package/build/routes/webkit/ws/playwright-webkit.js +19 -0
- package/build/routes/webkit/ws/playwright-webkit.query.json +100 -0
- package/build/server.d.ts +38 -0
- package/build/server.js +365 -0
- package/build/shim.d.ts +9 -0
- package/build/shim.js +54 -0
- package/build/shim.spec.d.ts +1 -0
- package/build/shim.spec.js +114 -0
- package/build/types.d.ts +360 -0
- package/build/types.js +6 -0
- package/build/utils.d.ts +111 -0
- package/build/utils.js +570 -0
- package/build/webhooks.d.ts +11 -0
- package/build/webhooks.js +43 -0
- package/docker/base/.dockerignore +16 -0
- package/docker/base/Dockerfile +70 -0
- package/docker/chrome/.dockerignore +16 -0
- package/docker/chrome/Dockerfile +40 -0
- package/docker/firefox/.dockerignore +16 -0
- package/docker/firefox/Dockerfile +39 -0
- package/docker/multi/.dockerignore +16 -0
- package/docker/multi/Dockerfile +37 -0
- package/docker/sdk/.dockerignore +16 -0
- package/docker/sdk/Dockerfile +34 -0
- package/docker/webkit/.dockerignore +16 -0
- package/docker/webkit/Dockerfile +40 -0
- package/extensions/screencast/background.js +143 -0
- package/extensions/screencast/content_script.js +18 -0
- package/extensions/screencast/manifest.json +19 -0
- package/extensions/ublock/1p-filters.html +69 -0
- package/extensions/ublock/3p-filters.html +119 -0
- package/extensions/ublock/LICENSE.txt +674 -0
- package/extensions/ublock/_locales/ar/messages.json +1290 -0
- package/extensions/ublock/_locales/az/messages.json +1290 -0
- package/extensions/ublock/_locales/be/messages.json +1290 -0
- package/extensions/ublock/_locales/bg/messages.json +1290 -0
- package/extensions/ublock/_locales/bn/messages.json +1290 -0
- package/extensions/ublock/_locales/br_FR/messages.json +1290 -0
- package/extensions/ublock/_locales/bs/messages.json +1290 -0
- package/extensions/ublock/_locales/ca/messages.json +1290 -0
- package/extensions/ublock/_locales/cs/messages.json +1290 -0
- package/extensions/ublock/_locales/cv/messages.json +1290 -0
- package/extensions/ublock/_locales/da/messages.json +1290 -0
- package/extensions/ublock/_locales/de/messages.json +1290 -0
- package/extensions/ublock/_locales/el/messages.json +1290 -0
- package/extensions/ublock/_locales/en/messages.json +1292 -0
- package/extensions/ublock/_locales/en_GB/messages.json +1290 -0
- package/extensions/ublock/_locales/eo/messages.json +1290 -0
- package/extensions/ublock/_locales/es/messages.json +1290 -0
- package/extensions/ublock/_locales/et/messages.json +1290 -0
- package/extensions/ublock/_locales/eu/messages.json +1290 -0
- package/extensions/ublock/_locales/fa/messages.json +1290 -0
- package/extensions/ublock/_locales/fi/messages.json +1290 -0
- package/extensions/ublock/_locales/fil/messages.json +1290 -0
- package/extensions/ublock/_locales/fr/messages.json +1290 -0
- package/extensions/ublock/_locales/fy/messages.json +1290 -0
- package/extensions/ublock/_locales/gl/messages.json +1290 -0
- package/extensions/ublock/_locales/gu/messages.json +1290 -0
- package/extensions/ublock/_locales/he/messages.json +1290 -0
- package/extensions/ublock/_locales/hi/messages.json +1290 -0
- package/extensions/ublock/_locales/hr/messages.json +1290 -0
- package/extensions/ublock/_locales/hu/messages.json +1290 -0
- package/extensions/ublock/_locales/hy/messages.json +1290 -0
- package/extensions/ublock/_locales/id/messages.json +1290 -0
- package/extensions/ublock/_locales/it/messages.json +1290 -0
- package/extensions/ublock/_locales/ja/messages.json +1290 -0
- package/extensions/ublock/_locales/ka/messages.json +1290 -0
- package/extensions/ublock/_locales/kk/messages.json +1290 -0
- package/extensions/ublock/_locales/kn/messages.json +1290 -0
- package/extensions/ublock/_locales/ko/messages.json +1290 -0
- package/extensions/ublock/_locales/ku/messages.json +1290 -0
- package/extensions/ublock/_locales/lt/messages.json +1290 -0
- package/extensions/ublock/_locales/lv/messages.json +1290 -0
- package/extensions/ublock/_locales/mk/messages.json +1290 -0
- package/extensions/ublock/_locales/ml/messages.json +1290 -0
- package/extensions/ublock/_locales/mr/messages.json +1290 -0
- package/extensions/ublock/_locales/ms/messages.json +1290 -0
- package/extensions/ublock/_locales/nb/messages.json +1290 -0
- package/extensions/ublock/_locales/nl/messages.json +1290 -0
- package/extensions/ublock/_locales/no/messages.json +1290 -0
- package/extensions/ublock/_locales/oc/messages.json +1290 -0
- package/extensions/ublock/_locales/pa/messages.json +1290 -0
- package/extensions/ublock/_locales/pl/messages.json +1290 -0
- package/extensions/ublock/_locales/pt_BR/messages.json +1290 -0
- package/extensions/ublock/_locales/pt_PT/messages.json +1290 -0
- package/extensions/ublock/_locales/ro/messages.json +1290 -0
- package/extensions/ublock/_locales/ru/messages.json +1290 -0
- package/extensions/ublock/_locales/si/messages.json +1290 -0
- package/extensions/ublock/_locales/sk/messages.json +1290 -0
- package/extensions/ublock/_locales/sl/messages.json +1290 -0
- package/extensions/ublock/_locales/so/messages.json +1290 -0
- package/extensions/ublock/_locales/sq/messages.json +1290 -0
- package/extensions/ublock/_locales/sr/messages.json +1290 -0
- package/extensions/ublock/_locales/sv/messages.json +1290 -0
- package/extensions/ublock/_locales/sw/messages.json +1290 -0
- package/extensions/ublock/_locales/ta/messages.json +1290 -0
- package/extensions/ublock/_locales/te/messages.json +1290 -0
- package/extensions/ublock/_locales/th/messages.json +1290 -0
- package/extensions/ublock/_locales/tr/messages.json +1290 -0
- package/extensions/ublock/_locales/uk/messages.json +1290 -0
- package/extensions/ublock/_locales/ur/messages.json +1290 -0
- package/extensions/ublock/_locales/vi/messages.json +1290 -0
- package/extensions/ublock/_locales/zh_CN/messages.json +1290 -0
- package/extensions/ublock/_locales/zh_TW/messages.json +1290 -0
- package/extensions/ublock/about.html +63 -0
- package/extensions/ublock/advanced-settings.html +42 -0
- package/extensions/ublock/asset-viewer.html +50 -0
- package/extensions/ublock/assets/assets.json +903 -0
- package/extensions/ublock/assets/resources/scriptlets.js +4255 -0
- package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +65576 -0
- package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +33219 -0
- package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/README.md +29 -0
- package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +3732 -0
- package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +15431 -0
- package/extensions/ublock/assets/thirdparties/urlhaus-filter/LICENSE.md +42 -0
- package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +1970 -0
- package/extensions/ublock/assets/ublock/badlists.txt +77 -0
- package/extensions/ublock/assets/ublock/badware.min.txt +3033 -0
- package/extensions/ublock/assets/ublock/filters.min.txt +23419 -0
- package/extensions/ublock/assets/ublock/privacy.min.txt +575 -0
- package/extensions/ublock/assets/ublock/quick-fixes.min.txt +99 -0
- package/extensions/ublock/assets/ublock/unbreak.min.txt +2448 -0
- package/extensions/ublock/background.html +12 -0
- package/extensions/ublock/cloud-ui.html +23 -0
- package/extensions/ublock/code-viewer.html +53 -0
- package/extensions/ublock/css/1p-filters.css +26 -0
- package/extensions/ublock/css/3p-filters.css +250 -0
- package/extensions/ublock/css/about.css +3 -0
- package/extensions/ublock/css/advanced-settings.css +26 -0
- package/extensions/ublock/css/asset-viewer.css +79 -0
- package/extensions/ublock/css/click2load.css +53 -0
- package/extensions/ublock/css/cloud-ui.css +104 -0
- package/extensions/ublock/css/code-viewer.css +67 -0
- package/extensions/ublock/css/codemirror.css +326 -0
- package/extensions/ublock/css/common.css +347 -0
- package/extensions/ublock/css/dashboard-common.css +55 -0
- package/extensions/ublock/css/dashboard.css +115 -0
- package/extensions/ublock/css/devtools.css +22 -0
- package/extensions/ublock/css/document-blocked.css +146 -0
- package/extensions/ublock/css/dyna-rules.css +79 -0
- package/extensions/ublock/css/epicker-ui.css +270 -0
- package/extensions/ublock/css/fa-icons.css +149 -0
- package/extensions/ublock/css/fonts/Inter/Inter-Regular.woff2 +0 -0
- package/extensions/ublock/css/fonts/Inter/Inter-SemiBold.woff2 +0 -0
- package/extensions/ublock/css/fonts/Inter/LICENSE.txt +93 -0
- package/extensions/ublock/css/fonts/Metropolis/Metropolis-Regular.woff2 +0 -0
- package/extensions/ublock/css/fonts/Metropolis/Metropolis-SemiBold.woff2 +0 -0
- package/extensions/ublock/css/fonts/Metropolis/README.md +25 -0
- package/extensions/ublock/css/fonts/Metropolis/UNLICENSE +24 -0
- package/extensions/ublock/css/logger-ui-inspector.css +116 -0
- package/extensions/ublock/css/logger-ui.css +978 -0
- package/extensions/ublock/css/popup-fenix.css +778 -0
- package/extensions/ublock/css/settings.css +74 -0
- package/extensions/ublock/css/support.css +110 -0
- package/extensions/ublock/css/themes/default.css +526 -0
- package/extensions/ublock/css/whitelist.css +22 -0
- package/extensions/ublock/dashboard.html +47 -0
- package/extensions/ublock/devtools.html +58 -0
- package/extensions/ublock/document-blocked.html +64 -0
- package/extensions/ublock/dyna-rules.html +67 -0
- package/extensions/ublock/img/cloud.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/README +9 -0
- package/extensions/ublock/img/flags-of-the-world/ad.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ae.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/af.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ag.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ai.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/al.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/am.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ao.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/aq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ar.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/as.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/at.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/au.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/aw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ax.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/az.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ba.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bb.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bd.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/be.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bi.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bo.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/br.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bs.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/by.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ca.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cd.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ch.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ci.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ck.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/co.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cx.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cy.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/de.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/dj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/dk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/dm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/do.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/dz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ec.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ee.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/eg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/eh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/er.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/es.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/et.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fi.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fo.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ga.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb-eng.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb-nir.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb-sct.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb-wls.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gd.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ge.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gi.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gp.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gs.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gy.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ht.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/id.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ie.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/il.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/im.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/in.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/io.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/iq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ir.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/is.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/it.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/je.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/jm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/jo.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/jp.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ke.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ki.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/km.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kp.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ky.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/la.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lb.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/li.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ls.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ly.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ma.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/md.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/me.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ml.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mo.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mp.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ms.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mx.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/my.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/na.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ne.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ng.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ni.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/no.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/np.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/om.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pa.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pe.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ph.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ps.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/py.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/qa.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/re.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ro.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/rs.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ru.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/rw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sa.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sb.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sd.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/se.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/si.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/so.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ss.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/st.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sx.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sy.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/td.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/th.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/to.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ua.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ug.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/um.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/us.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/uy.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/uz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/va.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ve.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vi.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/wf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ws.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/xk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ye.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/yt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/za.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/zm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/zw.png +0 -0
- package/extensions/ublock/img/fontawesome/LICENSE.txt +25 -0
- package/extensions/ublock/img/fontawesome/fontawesome-defs.svg +79 -0
- package/extensions/ublock/img/help16.png +0 -0
- package/extensions/ublock/img/icon_128.png +0 -0
- package/extensions/ublock/img/icon_16-loading.png +0 -0
- package/extensions/ublock/img/icon_16-off.png +0 -0
- package/extensions/ublock/img/icon_16.png +0 -0
- package/extensions/ublock/img/icon_32-loading.png +0 -0
- package/extensions/ublock/img/icon_32-off.png +0 -0
- package/extensions/ublock/img/icon_32.png +0 -0
- package/extensions/ublock/img/icon_64-loading.png +0 -0
- package/extensions/ublock/img/icon_64-off.png +0 -0
- package/extensions/ublock/img/icon_64.png +0 -0
- package/extensions/ublock/img/material-design.svg +16 -0
- package/extensions/ublock/img/photon.svg +16 -0
- package/extensions/ublock/img/ublock-defs.svg +27 -0
- package/extensions/ublock/img/ublock.svg +44 -0
- package/extensions/ublock/is-webrtc-supported.html +9 -0
- package/extensions/ublock/js/1p-filters.js +336 -0
- package/extensions/ublock/js/3p-filters.js +867 -0
- package/extensions/ublock/js/about.js +34 -0
- package/extensions/ublock/js/advanced-settings.js +194 -0
- package/extensions/ublock/js/asset-viewer.js +112 -0
- package/extensions/ublock/js/assets.js +1448 -0
- package/extensions/ublock/js/background.js +404 -0
- package/extensions/ublock/js/base64-custom.js +246 -0
- package/extensions/ublock/js/benchmarks.js +421 -0
- package/extensions/ublock/js/biditrie.js +947 -0
- package/extensions/ublock/js/cachestorage.js +510 -0
- package/extensions/ublock/js/click2load.js +60 -0
- package/extensions/ublock/js/cloud-ui.js +238 -0
- package/extensions/ublock/js/code-viewer.js +311 -0
- package/extensions/ublock/js/codemirror/search-thread.js +199 -0
- package/extensions/ublock/js/codemirror/search.js +504 -0
- package/extensions/ublock/js/codemirror/ubo-dynamic-filtering.js +239 -0
- package/extensions/ublock/js/codemirror/ubo-static-filtering.js +1126 -0
- package/extensions/ublock/js/commands.js +181 -0
- package/extensions/ublock/js/console.js +59 -0
- package/extensions/ublock/js/contentscript-extra.js +662 -0
- package/extensions/ublock/js/contentscript.js +1366 -0
- package/extensions/ublock/js/contextmenu.js +270 -0
- package/extensions/ublock/js/cosmetic-filtering.js +983 -0
- package/extensions/ublock/js/dashboard-common.js +215 -0
- package/extensions/ublock/js/dashboard.js +166 -0
- package/extensions/ublock/js/devtools.js +184 -0
- package/extensions/ublock/js/diff-updater.js +288 -0
- package/extensions/ublock/js/document-blocked.js +230 -0
- package/extensions/ublock/js/dom.js +213 -0
- package/extensions/ublock/js/dyna-rules.js +678 -0
- package/extensions/ublock/js/dynamic-net-filtering.js +488 -0
- package/extensions/ublock/js/epicker-ui.js +924 -0
- package/extensions/ublock/js/fa-icons.js +129 -0
- package/extensions/ublock/js/filtering-context.js +461 -0
- package/extensions/ublock/js/filtering-engines.js +50 -0
- package/extensions/ublock/js/hnswitches.js +289 -0
- package/extensions/ublock/js/hntrie.js +780 -0
- package/extensions/ublock/js/html-filtering.js +465 -0
- package/extensions/ublock/js/httpheader-filtering.js +213 -0
- package/extensions/ublock/js/i18n.js +346 -0
- package/extensions/ublock/js/is-webrtc-supported.js +52 -0
- package/extensions/ublock/js/logger-ui-inspector.js +652 -0
- package/extensions/ublock/js/logger-ui.js +3028 -0
- package/extensions/ublock/js/logger.js +84 -0
- package/extensions/ublock/js/lz4.js +190 -0
- package/extensions/ublock/js/messaging.js +2095 -0
- package/extensions/ublock/js/pagestore.js +1140 -0
- package/extensions/ublock/js/popup-fenix.js +1529 -0
- package/extensions/ublock/js/redirect-engine.js +494 -0
- package/extensions/ublock/js/redirect-resources.js +193 -0
- package/extensions/ublock/js/reverselookup-worker.js +287 -0
- package/extensions/ublock/js/reverselookup.js +223 -0
- package/extensions/ublock/js/scriptlet-filtering.js +556 -0
- package/extensions/ublock/js/scriptlets/cosmetic-logger.js +376 -0
- package/extensions/ublock/js/scriptlets/cosmetic-off.js +48 -0
- package/extensions/ublock/js/scriptlets/cosmetic-on.js +48 -0
- package/extensions/ublock/js/scriptlets/cosmetic-report.js +142 -0
- package/extensions/ublock/js/scriptlets/dom-inspector.js +906 -0
- package/extensions/ublock/js/scriptlets/dom-survey-elements.js +72 -0
- package/extensions/ublock/js/scriptlets/dom-survey-scripts.js +126 -0
- package/extensions/ublock/js/scriptlets/epicker.js +1365 -0
- package/extensions/ublock/js/scriptlets/load-3p-css.js +67 -0
- package/extensions/ublock/js/scriptlets/load-large-media-all.js +62 -0
- package/extensions/ublock/js/scriptlets/load-large-media-interactive.js +299 -0
- package/extensions/ublock/js/scriptlets/noscript-spoof.js +89 -0
- package/extensions/ublock/js/scriptlets/should-inject-contentscript.js +40 -0
- package/extensions/ublock/js/scriptlets/subscriber.js +113 -0
- package/extensions/ublock/js/scriptlets/updater.js +101 -0
- package/extensions/ublock/js/settings.js +317 -0
- package/extensions/ublock/js/start.js +509 -0
- package/extensions/ublock/js/static-dnr-filtering.js +497 -0
- package/extensions/ublock/js/static-ext-filtering-db.js +171 -0
- package/extensions/ublock/js/static-ext-filtering.js +184 -0
- package/extensions/ublock/js/static-filtering-io.js +144 -0
- package/extensions/ublock/js/static-filtering-parser.js +4459 -0
- package/extensions/ublock/js/static-net-filtering.js +5631 -0
- package/extensions/ublock/js/storage.js +1683 -0
- package/extensions/ublock/js/support.js +335 -0
- package/extensions/ublock/js/tab.js +1178 -0
- package/extensions/ublock/js/tasks.js +42 -0
- package/extensions/ublock/js/text-encode.js +275 -0
- package/extensions/ublock/js/text-utils.js +107 -0
- package/extensions/ublock/js/theme.js +151 -0
- package/extensions/ublock/js/traffic.js +1260 -0
- package/extensions/ublock/js/ublock.js +696 -0
- package/extensions/ublock/js/uri-utils.js +175 -0
- package/extensions/ublock/js/url-net-filtering.js +336 -0
- package/extensions/ublock/js/utils.js +208 -0
- package/extensions/ublock/js/vapi-background-ext.js +254 -0
- package/extensions/ublock/js/vapi-background.js +1802 -0
- package/extensions/ublock/js/vapi-client-extra.js +312 -0
- package/extensions/ublock/js/vapi-client.js +280 -0
- package/extensions/ublock/js/vapi-common.js +308 -0
- package/extensions/ublock/js/vapi.js +89 -0
- package/extensions/ublock/js/wasm/README.md +24 -0
- package/extensions/ublock/js/wasm/biditrie.wasm +0 -0
- package/extensions/ublock/js/wasm/biditrie.wat +728 -0
- package/extensions/ublock/js/wasm/hntrie.wasm +0 -0
- package/extensions/ublock/js/wasm/hntrie.wat +724 -0
- package/extensions/ublock/js/webext.js +164 -0
- package/extensions/ublock/js/whitelist.js +258 -0
- package/extensions/ublock/lib/codemirror/LICENSE +21 -0
- package/extensions/ublock/lib/codemirror/README.md +47 -0
- package/extensions/ublock/lib/codemirror/addon/comment/comment.js +211 -0
- package/extensions/ublock/lib/codemirror/addon/display/panel.js +133 -0
- package/extensions/ublock/lib/codemirror/addon/edit/closebrackets.js +201 -0
- package/extensions/ublock/lib/codemirror/addon/edit/matchbrackets.js +160 -0
- package/extensions/ublock/lib/codemirror/addon/fold/foldcode.js +157 -0
- package/extensions/ublock/lib/codemirror/addon/fold/foldgutter.css +20 -0
- package/extensions/ublock/lib/codemirror/addon/fold/foldgutter.js +163 -0
- package/extensions/ublock/lib/codemirror/addon/hint/show-hint.css +36 -0
- package/extensions/ublock/lib/codemirror/addon/hint/show-hint.js +509 -0
- package/extensions/ublock/lib/codemirror/addon/merge/merge.css +119 -0
- package/extensions/ublock/lib/codemirror/addon/merge/merge.js +1006 -0
- package/extensions/ublock/lib/codemirror/addon/scroll/annotatescrollbar.js +128 -0
- package/extensions/ublock/lib/codemirror/addon/search/matchesonscrollbar.css +8 -0
- package/extensions/ublock/lib/codemirror/addon/search/searchcursor.js +296 -0
- package/extensions/ublock/lib/codemirror/addon/selection/active-line.js +72 -0
- package/extensions/ublock/lib/codemirror/lib/codemirror.css +350 -0
- package/extensions/ublock/lib/codemirror/lib/codemirror.js +9800 -0
- package/extensions/ublock/lib/codemirror/mode/css/css.js +864 -0
- package/extensions/ublock/lib/codemirror/mode/htmlmixed/htmlmixed.js +153 -0
- package/extensions/ublock/lib/codemirror/mode/javascript/javascript.js +942 -0
- package/extensions/ublock/lib/codemirror/mode/xml/xml.js +413 -0
- package/extensions/ublock/lib/codemirror/theme/night.css +27 -0
- package/extensions/ublock/lib/csstree/LICENSE +19 -0
- package/extensions/ublock/lib/csstree/css-tree.js +17 -0
- package/extensions/ublock/lib/diff/README.md +34 -0
- package/extensions/ublock/lib/diff/swatinem_diff.js +272 -0
- package/extensions/ublock/lib/hsluv/LICENSE +20 -0
- package/extensions/ublock/lib/hsluv/README +3 -0
- package/extensions/ublock/lib/hsluv/hsluv-0.1.0.min.js +8 -0
- package/extensions/ublock/lib/js-beautify/LICENSE +9 -0
- package/extensions/ublock/lib/js-beautify/README +5 -0
- package/extensions/ublock/lib/js-beautify/beautifier.min.js +2 -0
- package/extensions/ublock/lib/lz4/README.md +52 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec-any.js +151 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec-js.js +297 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec-wasm.js +195 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec.wasm +0 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec.wat +745 -0
- package/extensions/ublock/lib/publicsuffixlist/publicsuffixlist.js +641 -0
- package/extensions/ublock/lib/publicsuffixlist/wasm/README.md +29 -0
- package/extensions/ublock/lib/publicsuffixlist/wasm/publicsuffixlist.wasm +0 -0
- package/extensions/ublock/lib/publicsuffixlist/wasm/publicsuffixlist.wat +322 -0
- package/extensions/ublock/lib/punycode.js +493 -0
- package/extensions/ublock/lib/regexanalyzer/CHANGES.md +15 -0
- package/extensions/ublock/lib/regexanalyzer/README.md +14 -0
- package/extensions/ublock/lib/regexanalyzer/regex.js +2276 -0
- package/extensions/ublock/logger-ui.html +232 -0
- package/extensions/ublock/managed_storage.json +73 -0
- package/extensions/ublock/manifest.json +115 -0
- package/extensions/ublock/no-dashboard.html +27 -0
- package/extensions/ublock/popup-fenix.html +114 -0
- package/extensions/ublock/settings.html +98 -0
- package/extensions/ublock/support.html +131 -0
- package/extensions/ublock/web_accessible_resources/1x1.gif +0 -0
- package/extensions/ublock/web_accessible_resources/2x2.png +0 -0
- package/extensions/ublock/web_accessible_resources/32x32.png +0 -0
- package/extensions/ublock/web_accessible_resources/3x2.png +0 -0
- package/extensions/ublock/web_accessible_resources/README.txt +11 -0
- package/extensions/ublock/web_accessible_resources/addthis_widget.js +39 -0
- package/extensions/ublock/web_accessible_resources/amazon_ads.js +70 -0
- package/extensions/ublock/web_accessible_resources/amazon_apstag.js +62 -0
- package/extensions/ublock/web_accessible_resources/ampproject_v0.js +34 -0
- package/extensions/ublock/web_accessible_resources/chartbeat.js +30 -0
- package/extensions/ublock/web_accessible_resources/click2load.html +28 -0
- package/extensions/ublock/web_accessible_resources/doubleclick_instream_ad_status.js +1 -0
- package/extensions/ublock/web_accessible_resources/empty +0 -0
- package/extensions/ublock/web_accessible_resources/epicker-ui.html +76 -0
- package/extensions/ublock/web_accessible_resources/fingerprint2.js +55 -0
- package/extensions/ublock/web_accessible_resources/fingerprint3.js +45 -0
- package/extensions/ublock/web_accessible_resources/google-analytics_analytics.js +110 -0
- package/extensions/ublock/web_accessible_resources/google-analytics_cx_api.js +36 -0
- package/extensions/ublock/web_accessible_resources/google-analytics_ga.js +130 -0
- package/extensions/ublock/web_accessible_resources/google-analytics_inpage_linkid.js +28 -0
- package/extensions/ublock/web_accessible_resources/google-ima.js +855 -0
- package/extensions/ublock/web_accessible_resources/googlesyndication_adsbygoogle.js +56 -0
- package/extensions/ublock/web_accessible_resources/googletagmanager_gtm.js +43 -0
- package/extensions/ublock/web_accessible_resources/googletagservices_gpt.js +153 -0
- package/extensions/ublock/web_accessible_resources/hd-main.js +46 -0
- package/extensions/ublock/web_accessible_resources/ligatus_angular-tag.js +29 -0
- package/extensions/ublock/web_accessible_resources/monkeybroker.js +43 -0
- package/extensions/ublock/web_accessible_resources/mxpnl_mixpanel.js +51 -0
- package/extensions/ublock/web_accessible_resources/nobab.js +87 -0
- package/extensions/ublock/web_accessible_resources/nobab2.js +42 -0
- package/extensions/ublock/web_accessible_resources/noeval-silent.js +28 -0
- package/extensions/ublock/web_accessible_resources/noeval.js +30 -0
- package/extensions/ublock/web_accessible_resources/nofab.js +67 -0
- package/extensions/ublock/web_accessible_resources/noop-0.1s.mp3 +0 -0
- package/extensions/ublock/web_accessible_resources/noop-0.5s.mp3 +0 -0
- package/extensions/ublock/web_accessible_resources/noop-1s.mp4 +0 -0
- package/extensions/ublock/web_accessible_resources/noop-vmap1.0.xml +1 -0
- package/extensions/ublock/web_accessible_resources/noop.css +1 -0
- package/extensions/ublock/web_accessible_resources/noop.html +5 -0
- package/extensions/ublock/web_accessible_resources/noop.js +3 -0
- package/extensions/ublock/web_accessible_resources/noop.json +1 -0
- package/extensions/ublock/web_accessible_resources/noop.txt +1 -0
- package/extensions/ublock/web_accessible_resources/outbrain-widget.js +72 -0
- package/extensions/ublock/web_accessible_resources/popads-dummy.js +30 -0
- package/extensions/ublock/web_accessible_resources/popads.js +40 -0
- package/extensions/ublock/web_accessible_resources/prebid-ads.js +26 -0
- package/extensions/ublock/web_accessible_resources/scorecardresearch_beacon.js +31 -0
- package/extensions/ublock/whitelist.html +63 -0
- package/external/.gitkeep +0 -0
- package/fonts/Calibri Bold Italic.ttf +0 -0
- package/fonts/Calibri Bold.TTF +0 -0
- package/fonts/Calibri Italic.ttf +0 -0
- package/fonts/Calibri Light Italic.ttf +0 -0
- package/fonts/Calibri Light.ttf +0 -0
- package/fonts/Calibri Regular.ttf +0 -0
- package/fonts/Emoji.ttf +0 -0
- package/fonts/SegoeUI-Bold.ttf +0 -0
- package/fonts/SegoeUI-Light.ttf +0 -0
- package/fonts/SegoeUI-Regular.ttf +0 -0
- package/fonts/SegoeUI-Semibold.ttf +0 -0
- package/fonts/SegoeUI-Semilight.ttf +0 -0
- package/fonts/Tahoma Bold.ttf +0 -0
- package/fonts/Tahoma.ttf +0 -0
- package/fonts/fonts.conf +21 -0
- package/package.json +177 -0
- package/scripts/build-function.js +18 -0
- package/scripts/build-open-api.js +274 -0
- package/scripts/build-schemas.js +86 -0
- package/scripts/build-selectors.js +36 -0
- package/scripts/clean.js +7 -0
- package/scripts/install-adblock.js +45 -0
- package/scripts/install-cdp-json.js +37 -0
- package/scripts/start.sh +30 -0
- package/scripts/test.sh +17 -0
- package/src/browserless.ts +253 -0
- package/src/browsers/cdp-chromium.ts +422 -0
- package/src/browsers/index.ts +296 -0
- package/src/browsers/playwright-chromium.ts +168 -0
- package/src/browsers/playwright-firefox.ts +161 -0
- package/src/browsers/playwright-webkit.ts +161 -0
- package/src/config.ts +426 -0
- package/src/constants.ts +4 -0
- package/src/exports.ts +23 -0
- package/src/file-system.ts +54 -0
- package/src/hooks.ts +37 -0
- package/src/http.ts +157 -0
- package/src/index.ts +41 -0
- package/src/limiter.spec.ts +365 -0
- package/src/limiter.ts +225 -0
- package/src/metrics.spec.ts +49 -0
- package/src/metrics.ts +108 -0
- package/src/mime-types.ts +332 -0
- package/src/monitoring.ts +53 -0
- package/src/routes/chromium/http/content-post.ts +238 -0
- package/src/routes/chromium/http/download-post.ts +162 -0
- package/src/routes/chromium/http/function-post.ts +98 -0
- package/src/routes/chromium/http/pdf-post.ts +234 -0
- package/src/routes/chromium/http/performance.ts +71 -0
- package/src/routes/chromium/http/scrape-post.ts +439 -0
- package/src/routes/chromium/http/screenshot-post.ts +262 -0
- package/src/routes/chromium/tests/content.spec.ts +340 -0
- package/src/routes/chromium/tests/download.spec.ts +77 -0
- package/src/routes/chromium/tests/function.spec.ts +279 -0
- package/src/routes/chromium/tests/pdf.spec.ts +375 -0
- package/src/routes/chromium/tests/performance.spec.ts +155 -0
- package/src/routes/chromium/tests/scrape.spec.ts +414 -0
- package/src/routes/chromium/tests/screenshot.spec.ts +387 -0
- package/src/routes/chromium/tests/websocket.spec.ts +407 -0
- package/src/routes/chromium/utils/function/client.ts +99 -0
- package/src/routes/chromium/utils/function/handler.ts +172 -0
- package/src/routes/chromium/utils/performance/child.ts +38 -0
- package/src/routes/chromium/utils/performance/main.ts +90 -0
- package/src/routes/chromium/utils/performance/types.ts +24 -0
- package/src/routes/chromium/ws/browser.ts +31 -0
- package/src/routes/chromium/ws/cdp-chromium.ts +31 -0
- package/src/routes/chromium/ws/page.ts +31 -0
- package/src/routes/chromium/ws/playwright-chromium.ts +44 -0
- package/src/routes/firefox/tests/websocket.spec.ts +146 -0
- package/src/routes/firefox/ws/playwright-firefox.ts +44 -0
- package/src/routes/management/http/config-get.ts +82 -0
- package/src/routes/management/http/metrics-get.ts +43 -0
- package/src/routes/management/http/metrics-total-get.ts +89 -0
- package/src/routes/management/http/sessions-get.ts +39 -0
- package/src/routes/management/http/static-get.ts +109 -0
- package/src/routes/management/tests/management.spec.ts +71 -0
- package/src/routes/webkit/tests/websocket.spec.ts +146 -0
- package/src/routes/webkit/ws/playwright-webkit.ts +44 -0
- package/src/server.ts +609 -0
- package/src/shim.spec.ts +154 -0
- package/src/shim.ts +78 -0
- package/src/types.ts +470 -0
- package/src/utils.ts +787 -0
- package/src/webhooks.ts +50 -0
- package/static/docs/browserless-logo.png +0 -0
- package/static/docs/docs.js +2 -0
- package/static/docs/index.html +71 -0
- package/static/docs/swagger.json +4232 -0
- package/static/favicon-32x32.png +0 -0
- package/static/function/client.js +31623 -0
- package/static/function/index.html +12 -0
- package/tsconfig.json +31 -0
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
/*******************************************************************************
|
|
2
|
+
|
|
3
|
+
uBlock Origin - a browser extension to block requests.
|
|
4
|
+
Copyright (C) 2017-present Raymond Hill
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU General Public License
|
|
17
|
+
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
|
18
|
+
|
|
19
|
+
Home: https://github.com/gorhill/uBlock
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/* globals WebAssembly */
|
|
23
|
+
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
/*******************************************************************************
|
|
27
|
+
|
|
28
|
+
The original prototype was to develop an idea I had about using jump indices
|
|
29
|
+
in a TypedArray for quickly matching hostnames (or more generally strings)[1].
|
|
30
|
+
Once I had a working, un-optimized prototype, I realized I had ended up
|
|
31
|
+
with something formally named a "trie": <https://en.wikipedia.org/wiki/Trie>,
|
|
32
|
+
hence the name. I have no idea whether the implementation here or one
|
|
33
|
+
resembling it has been done elsewhere.
|
|
34
|
+
|
|
35
|
+
"HN" in HNTrieContainer stands for "HostName", because the trie is
|
|
36
|
+
specialized to deal with matching hostnames -- which is a bit more
|
|
37
|
+
complicated than matching plain strings.
|
|
38
|
+
|
|
39
|
+
For example, `www.abc.com` is deemed matching `abc.com`, because the former
|
|
40
|
+
is a subdomain of the latter. The opposite is of course not true.
|
|
41
|
+
|
|
42
|
+
The resulting read-only tries created as a result of using HNTrieContainer
|
|
43
|
+
are simply just typed arrays filled with integers. The matching algorithm is
|
|
44
|
+
just a matter of reading/comparing these integers, and further using them as
|
|
45
|
+
indices in the array as a way to move around in the trie.
|
|
46
|
+
|
|
47
|
+
[1] To solve <https://github.com/gorhill/uBlock/issues/3193>
|
|
48
|
+
|
|
49
|
+
Since this trie is specialized for matching hostnames, the stored
|
|
50
|
+
strings are reversed internally, because of hostname comparison logic:
|
|
51
|
+
|
|
52
|
+
Correct matching:
|
|
53
|
+
index 0123456
|
|
54
|
+
abc.com
|
|
55
|
+
|
|
|
56
|
+
www.abc.com
|
|
57
|
+
index 01234567890
|
|
58
|
+
|
|
59
|
+
Incorrect matching (typically used for plain strings):
|
|
60
|
+
index 0123456
|
|
61
|
+
abc.com
|
|
62
|
+
|
|
|
63
|
+
www.abc.com
|
|
64
|
+
index 01234567890
|
|
65
|
+
|
|
66
|
+
------------------------------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
1st iteration:
|
|
69
|
+
- https://github.com/gorhill/uBlock/blob/ff58107dac3a32607f8113e39ed5015584506813/src/js/hntrie.js
|
|
70
|
+
- Suitable for small to medium set of hostnames
|
|
71
|
+
- One buffer per trie
|
|
72
|
+
|
|
73
|
+
2nd iteration: goal was to make matches() method wasm-able
|
|
74
|
+
- https://github.com/gorhill/uBlock/blob/c3b0fd31f64bd7ffecdd282fb1208fe07aac3eb0/src/js/hntrie.js
|
|
75
|
+
- Suitable for small to medium set of hostnames
|
|
76
|
+
- Distinct tries all share same buffer:
|
|
77
|
+
- Reduced memory footprint
|
|
78
|
+
- https://stackoverflow.com/questions/45803829/memory-overhead-of-typed-arrays-vs-strings/45808835#45808835
|
|
79
|
+
- Reusing needle character lookups for all tries
|
|
80
|
+
- This significantly reduce the number of String.charCodeAt() calls
|
|
81
|
+
- Slightly improved creation time
|
|
82
|
+
|
|
83
|
+
This is the 3rd iteration: goal was to make add() method wasm-able and
|
|
84
|
+
further improve memory/CPU efficiency.
|
|
85
|
+
|
|
86
|
+
This 3rd iteration has the following new traits:
|
|
87
|
+
- Suitable for small to large set of hostnames
|
|
88
|
+
- Support multiple trie containers (instanciable)
|
|
89
|
+
- Designed to hold large number of hostnames
|
|
90
|
+
- Hostnames can be added at any time (instead of all at once)
|
|
91
|
+
- This means pre-sorting is no longer a requirement
|
|
92
|
+
- The trie is always compact
|
|
93
|
+
- There is no longer a need for a `vacuum` method
|
|
94
|
+
- This makes the add() method wasm-able
|
|
95
|
+
- It can return the exact hostname which caused the match
|
|
96
|
+
- serializable/unserializable available for fast loading
|
|
97
|
+
- Distinct trie reference support the iteration protocol, thus allowing
|
|
98
|
+
to extract all the hostnames in the trie
|
|
99
|
+
|
|
100
|
+
Its primary purpose is to replace the use of Set() as a mean to hold
|
|
101
|
+
large number of hostnames (ex. FilterHostnameDict in static filtering
|
|
102
|
+
engine).
|
|
103
|
+
|
|
104
|
+
A HNTrieContainer is mostly a large buffer in which distinct but related
|
|
105
|
+
tries are stored. The memory layout of the buffer is as follow:
|
|
106
|
+
|
|
107
|
+
0-254: needle being processed
|
|
108
|
+
255: length of needle
|
|
109
|
+
256-259: offset to start of trie data section (=> trie0)
|
|
110
|
+
260-263: offset to end of trie data section (=> trie1)
|
|
111
|
+
264-267: offset to start of character data section (=> char0)
|
|
112
|
+
268-271: offset to end of character data section (=> char1)
|
|
113
|
+
272: start of trie data section
|
|
114
|
+
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
const PAGE_SIZE = 65536;
|
|
118
|
+
// i32 / i8
|
|
119
|
+
const TRIE0_SLOT = 256 >>> 2; // 64 / 256
|
|
120
|
+
const TRIE1_SLOT = TRIE0_SLOT + 1; // 65 / 260
|
|
121
|
+
const CHAR0_SLOT = TRIE0_SLOT + 2; // 66 / 264
|
|
122
|
+
const CHAR1_SLOT = TRIE0_SLOT + 3; // 67 / 268
|
|
123
|
+
const TRIE0_START = TRIE0_SLOT + 4 << 2; // 272
|
|
124
|
+
|
|
125
|
+
const roundToPageSize = v => (v + PAGE_SIZE-1) & ~(PAGE_SIZE-1);
|
|
126
|
+
|
|
127
|
+
class HNTrieContainer {
|
|
128
|
+
|
|
129
|
+
constructor() {
|
|
130
|
+
const len = PAGE_SIZE * 2;
|
|
131
|
+
this.buf = new Uint8Array(len);
|
|
132
|
+
this.buf32 = new Uint32Array(this.buf.buffer);
|
|
133
|
+
this.needle = '';
|
|
134
|
+
this.buf32[TRIE0_SLOT] = TRIE0_START;
|
|
135
|
+
this.buf32[TRIE1_SLOT] = this.buf32[TRIE0_SLOT];
|
|
136
|
+
this.buf32[CHAR0_SLOT] = len >>> 1;
|
|
137
|
+
this.buf32[CHAR1_SLOT] = this.buf32[CHAR0_SLOT];
|
|
138
|
+
this.wasmMemory = null;
|
|
139
|
+
|
|
140
|
+
this.lastStored = '';
|
|
141
|
+
this.lastStoredLen = this.lastStoredIndex = 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//--------------------------------------------------------------------------
|
|
145
|
+
// Public methods
|
|
146
|
+
//--------------------------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
reset(details) {
|
|
149
|
+
if (
|
|
150
|
+
details instanceof Object &&
|
|
151
|
+
typeof details.byteLength === 'number' &&
|
|
152
|
+
typeof details.char0 === 'number'
|
|
153
|
+
) {
|
|
154
|
+
if ( details.byteLength > this.buf.byteLength ) {
|
|
155
|
+
this.reallocateBuf(details.byteLength);
|
|
156
|
+
}
|
|
157
|
+
this.buf32[CHAR0_SLOT] = details.char0;
|
|
158
|
+
}
|
|
159
|
+
this.buf32[TRIE1_SLOT] = this.buf32[TRIE0_SLOT];
|
|
160
|
+
this.buf32[CHAR1_SLOT] = this.buf32[CHAR0_SLOT];
|
|
161
|
+
|
|
162
|
+
this.lastStored = '';
|
|
163
|
+
this.lastStoredLen = this.lastStoredIndex = 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
setNeedle(needle) {
|
|
167
|
+
if ( needle !== this.needle ) {
|
|
168
|
+
const buf = this.buf;
|
|
169
|
+
let i = needle.length;
|
|
170
|
+
if ( i > 255 ) { i = 255; }
|
|
171
|
+
buf[255] = i;
|
|
172
|
+
while ( i-- ) {
|
|
173
|
+
buf[i] = needle.charCodeAt(i);
|
|
174
|
+
}
|
|
175
|
+
this.needle = needle;
|
|
176
|
+
}
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
matchesJS(iroot) {
|
|
181
|
+
const buf32 = this.buf32;
|
|
182
|
+
const buf8 = this.buf;
|
|
183
|
+
const char0 = buf32[CHAR0_SLOT];
|
|
184
|
+
let ineedle = buf8[255];
|
|
185
|
+
let icell = buf32[iroot+0];
|
|
186
|
+
if ( icell === 0 ) { return -1; }
|
|
187
|
+
let c = 0, v = 0, i0 = 0, n = 0;
|
|
188
|
+
for (;;) {
|
|
189
|
+
if ( ineedle === 0 ) { return -1; }
|
|
190
|
+
ineedle -= 1;
|
|
191
|
+
c = buf8[ineedle];
|
|
192
|
+
// find first segment with a first-character match
|
|
193
|
+
for (;;) {
|
|
194
|
+
v = buf32[icell+2];
|
|
195
|
+
i0 = char0 + (v >>> 8);
|
|
196
|
+
if ( buf8[i0] === c ) { break; }
|
|
197
|
+
icell = buf32[icell+0];
|
|
198
|
+
if ( icell === 0 ) { return -1; }
|
|
199
|
+
}
|
|
200
|
+
// all characters in segment must match
|
|
201
|
+
n = v & 0x7F;
|
|
202
|
+
if ( n > 1 ) {
|
|
203
|
+
n -= 1;
|
|
204
|
+
if ( n > ineedle ) { return -1; }
|
|
205
|
+
i0 += 1;
|
|
206
|
+
const i1 = i0 + n;
|
|
207
|
+
do {
|
|
208
|
+
ineedle -= 1;
|
|
209
|
+
if ( buf8[i0] !== buf8[ineedle] ) { return -1; }
|
|
210
|
+
i0 += 1;
|
|
211
|
+
} while ( i0 < i1 );
|
|
212
|
+
}
|
|
213
|
+
// boundary at end of segment?
|
|
214
|
+
if ( (v & 0x80) !== 0 ) {
|
|
215
|
+
if ( ineedle === 0 || buf8[ineedle-1] === 0x2E /* '.' */ ) {
|
|
216
|
+
return ineedle;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// next segment
|
|
220
|
+
icell = buf32[icell+1];
|
|
221
|
+
if ( icell === 0 ) { break; }
|
|
222
|
+
}
|
|
223
|
+
return -1;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
createTrie() {
|
|
227
|
+
// grow buffer if needed
|
|
228
|
+
if ( (this.buf32[CHAR0_SLOT] - this.buf32[TRIE1_SLOT]) < 12 ) {
|
|
229
|
+
this.growBuf(12, 0);
|
|
230
|
+
}
|
|
231
|
+
const iroot = this.buf32[TRIE1_SLOT] >>> 2;
|
|
232
|
+
this.buf32[TRIE1_SLOT] += 12;
|
|
233
|
+
this.buf32[iroot+0] = 0;
|
|
234
|
+
this.buf32[iroot+1] = 0;
|
|
235
|
+
this.buf32[iroot+2] = 0;
|
|
236
|
+
return iroot;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
createTrieFromIterable(hostnames) {
|
|
240
|
+
const itrie = this.createTrie();
|
|
241
|
+
for ( const hn of hostnames ) {
|
|
242
|
+
if ( hn === '' ) { continue; }
|
|
243
|
+
this.setNeedle(hn).add(itrie);
|
|
244
|
+
}
|
|
245
|
+
return itrie;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
createTrieFromStoredDomainOpt(i, n) {
|
|
249
|
+
const itrie = this.createTrie();
|
|
250
|
+
const jend = i + n;
|
|
251
|
+
let j = i, offset = 0, k = 0, c = 0;
|
|
252
|
+
while ( j !== jend ) {
|
|
253
|
+
offset = this.buf32[CHAR0_SLOT]; // Important
|
|
254
|
+
k = 0;
|
|
255
|
+
for (;;) {
|
|
256
|
+
if ( j === jend ) { break; }
|
|
257
|
+
c = this.buf[offset+j];
|
|
258
|
+
j += 1;
|
|
259
|
+
if ( c === 0x7C /* '|' */ ) { break; }
|
|
260
|
+
if ( k === 255 ) { continue; }
|
|
261
|
+
this.buf[k] = c;
|
|
262
|
+
k += 1;
|
|
263
|
+
}
|
|
264
|
+
if ( k !== 0 ) {
|
|
265
|
+
this.buf[255] = k;
|
|
266
|
+
this.add(itrie);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
this.needle = ''; // Important
|
|
270
|
+
this.buf[255] = 0; // Important
|
|
271
|
+
return itrie;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
dumpTrie(iroot) {
|
|
275
|
+
let hostnames = Array.from(this.trieIterator(iroot));
|
|
276
|
+
if ( String.prototype.padStart instanceof Function ) {
|
|
277
|
+
const maxlen = Math.min(
|
|
278
|
+
hostnames.reduce((maxlen, hn) => Math.max(maxlen, hn.length), 0),
|
|
279
|
+
64
|
|
280
|
+
);
|
|
281
|
+
hostnames = hostnames.map(hn => hn.padStart(maxlen));
|
|
282
|
+
}
|
|
283
|
+
for ( const hn of hostnames ) {
|
|
284
|
+
console.log(hn);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
trieIterator(iroot) {
|
|
289
|
+
return {
|
|
290
|
+
value: undefined,
|
|
291
|
+
done: false,
|
|
292
|
+
next() {
|
|
293
|
+
if ( this.icell === 0 ) {
|
|
294
|
+
if ( this.forks.length === 0 ) {
|
|
295
|
+
this.value = undefined;
|
|
296
|
+
this.done = true;
|
|
297
|
+
return this;
|
|
298
|
+
}
|
|
299
|
+
this.charPtr = this.forks.pop();
|
|
300
|
+
this.icell = this.forks.pop();
|
|
301
|
+
}
|
|
302
|
+
for (;;) {
|
|
303
|
+
const idown = this.container.buf32[this.icell+0];
|
|
304
|
+
if ( idown !== 0 ) {
|
|
305
|
+
this.forks.push(idown, this.charPtr);
|
|
306
|
+
}
|
|
307
|
+
const v = this.container.buf32[this.icell+2];
|
|
308
|
+
let i0 = this.container.buf32[CHAR0_SLOT] + (v >>> 8);
|
|
309
|
+
const i1 = i0 + (v & 0x7F);
|
|
310
|
+
while ( i0 < i1 ) {
|
|
311
|
+
this.charPtr -= 1;
|
|
312
|
+
this.charBuf[this.charPtr] = this.container.buf[i0];
|
|
313
|
+
i0 += 1;
|
|
314
|
+
}
|
|
315
|
+
this.icell = this.container.buf32[this.icell+1];
|
|
316
|
+
if ( (v & 0x80) !== 0 ) {
|
|
317
|
+
return this.toHostname();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
toHostname() {
|
|
322
|
+
this.value = this.textDecoder.decode(
|
|
323
|
+
new Uint8Array(this.charBuf.buffer, this.charPtr)
|
|
324
|
+
);
|
|
325
|
+
return this;
|
|
326
|
+
},
|
|
327
|
+
container: this,
|
|
328
|
+
icell: this.buf32[iroot],
|
|
329
|
+
charBuf: new Uint8Array(256),
|
|
330
|
+
charPtr: 256,
|
|
331
|
+
forks: [],
|
|
332
|
+
textDecoder: new TextDecoder(),
|
|
333
|
+
[Symbol.iterator]() { return this; },
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// TODO:
|
|
338
|
+
// Rework code to add from a string already present in the character
|
|
339
|
+
// buffer, i.e. not having to go through setNeedle() when adding a new
|
|
340
|
+
// hostname to a trie. This will require much work though, and probably
|
|
341
|
+
// changing the order in which string segments are stored in the
|
|
342
|
+
// character buffer.
|
|
343
|
+
addJS(iroot) {
|
|
344
|
+
let lhnchar = this.buf[255];
|
|
345
|
+
if ( lhnchar === 0 ) { return 0; }
|
|
346
|
+
// grow buffer if needed
|
|
347
|
+
if (
|
|
348
|
+
(this.buf32[CHAR0_SLOT] - this.buf32[TRIE1_SLOT]) < 24 ||
|
|
349
|
+
(this.buf.length - this.buf32[CHAR1_SLOT]) < 256
|
|
350
|
+
) {
|
|
351
|
+
this.growBuf(24, 256);
|
|
352
|
+
}
|
|
353
|
+
let icell = this.buf32[iroot+0];
|
|
354
|
+
// special case: first node in trie
|
|
355
|
+
if ( icell === 0 ) {
|
|
356
|
+
this.buf32[iroot+0] = this.addLeafCell(lhnchar);
|
|
357
|
+
return 1;
|
|
358
|
+
}
|
|
359
|
+
//
|
|
360
|
+
const char0 = this.buf32[CHAR0_SLOT];
|
|
361
|
+
let isegchar, lsegchar, boundaryBit, inext;
|
|
362
|
+
// find a matching cell: move down
|
|
363
|
+
for (;;) {
|
|
364
|
+
const v = this.buf32[icell+2];
|
|
365
|
+
let isegchar0 = char0 + (v >>> 8);
|
|
366
|
+
// if first character is no match, move to next descendant
|
|
367
|
+
if ( this.buf[isegchar0] !== this.buf[lhnchar-1] ) {
|
|
368
|
+
inext = this.buf32[icell+0];
|
|
369
|
+
if ( inext === 0 ) {
|
|
370
|
+
this.buf32[icell+0] = this.addLeafCell(lhnchar);
|
|
371
|
+
return 1;
|
|
372
|
+
}
|
|
373
|
+
icell = inext;
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
// 1st character was tested
|
|
377
|
+
isegchar = 1;
|
|
378
|
+
lhnchar -= 1;
|
|
379
|
+
// find 1st mismatch in rest of segment
|
|
380
|
+
lsegchar = v & 0x7F;
|
|
381
|
+
if ( lsegchar !== 1 ) {
|
|
382
|
+
for (;;) {
|
|
383
|
+
if ( isegchar === lsegchar ) { break; }
|
|
384
|
+
if ( lhnchar === 0 ) { break; }
|
|
385
|
+
if ( this.buf[isegchar0+isegchar] !== this.buf[lhnchar-1] ) { break; }
|
|
386
|
+
isegchar += 1;
|
|
387
|
+
lhnchar -= 1;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
boundaryBit = v & 0x80;
|
|
391
|
+
// all segment characters matched
|
|
392
|
+
if ( isegchar === lsegchar ) {
|
|
393
|
+
// needle remainder: no
|
|
394
|
+
if ( lhnchar === 0 ) {
|
|
395
|
+
// boundary: yes, already present
|
|
396
|
+
if ( boundaryBit !== 0 ) { return 0; }
|
|
397
|
+
// boundary: no, mark as boundary
|
|
398
|
+
this.buf32[icell+2] = v | 0x80;
|
|
399
|
+
}
|
|
400
|
+
// needle remainder: yes
|
|
401
|
+
else {
|
|
402
|
+
// remainder is at label boundary? if yes, no need to add
|
|
403
|
+
// the rest since the shortest match is always reported
|
|
404
|
+
if ( boundaryBit !== 0 ) {
|
|
405
|
+
if ( this.buf[lhnchar-1] === 0x2E /* '.' */ ) { return -1; }
|
|
406
|
+
}
|
|
407
|
+
inext = this.buf32[icell+1];
|
|
408
|
+
if ( inext !== 0 ) {
|
|
409
|
+
icell = inext;
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
// add needle remainder
|
|
413
|
+
this.buf32[icell+1] = this.addLeafCell(lhnchar);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
// some segment characters matched
|
|
417
|
+
else {
|
|
418
|
+
// split current cell
|
|
419
|
+
isegchar0 -= char0;
|
|
420
|
+
this.buf32[icell+2] = isegchar0 << 8 | isegchar;
|
|
421
|
+
inext = this.addCell(
|
|
422
|
+
0,
|
|
423
|
+
this.buf32[icell+1],
|
|
424
|
+
isegchar0 + isegchar << 8 | boundaryBit | lsegchar - isegchar
|
|
425
|
+
);
|
|
426
|
+
this.buf32[icell+1] = inext;
|
|
427
|
+
// needle remainder: yes, need new cell for remaining characters
|
|
428
|
+
if ( lhnchar !== 0 ) {
|
|
429
|
+
this.buf32[inext+0] = this.addLeafCell(lhnchar);
|
|
430
|
+
}
|
|
431
|
+
// needle remainder: no, need boundary cell
|
|
432
|
+
else {
|
|
433
|
+
this.buf32[icell+2] |= 0x80;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return 1;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
optimize() {
|
|
441
|
+
this.shrinkBuf();
|
|
442
|
+
return {
|
|
443
|
+
byteLength: this.buf.byteLength,
|
|
444
|
+
char0: this.buf32[CHAR0_SLOT],
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
serialize(encoder) {
|
|
449
|
+
if ( encoder instanceof Object ) {
|
|
450
|
+
return encoder.encode(
|
|
451
|
+
this.buf32.buffer,
|
|
452
|
+
this.buf32[CHAR1_SLOT]
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
return Array.from(
|
|
456
|
+
new Uint32Array(
|
|
457
|
+
this.buf32.buffer,
|
|
458
|
+
0,
|
|
459
|
+
this.buf32[CHAR1_SLOT] + 3 >>> 2
|
|
460
|
+
)
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
unserialize(selfie, decoder) {
|
|
465
|
+
this.needle = '';
|
|
466
|
+
const shouldDecode = typeof selfie === 'string';
|
|
467
|
+
let byteLength = shouldDecode
|
|
468
|
+
? decoder.decodeSize(selfie)
|
|
469
|
+
: selfie.length << 2;
|
|
470
|
+
if ( byteLength === 0 ) { return false; }
|
|
471
|
+
byteLength = roundToPageSize(byteLength);
|
|
472
|
+
if ( this.wasmMemory !== null ) {
|
|
473
|
+
const pageCountBefore = this.buf.length >>> 16;
|
|
474
|
+
const pageCountAfter = byteLength >>> 16;
|
|
475
|
+
if ( pageCountAfter > pageCountBefore ) {
|
|
476
|
+
this.wasmMemory.grow(pageCountAfter - pageCountBefore);
|
|
477
|
+
this.buf = new Uint8Array(this.wasmMemory.buffer);
|
|
478
|
+
this.buf32 = new Uint32Array(this.buf.buffer);
|
|
479
|
+
}
|
|
480
|
+
} else if ( byteLength > this.buf.length ) {
|
|
481
|
+
this.buf = new Uint8Array(byteLength);
|
|
482
|
+
this.buf32 = new Uint32Array(this.buf.buffer);
|
|
483
|
+
}
|
|
484
|
+
if ( shouldDecode ) {
|
|
485
|
+
decoder.decode(selfie, this.buf.buffer);
|
|
486
|
+
} else {
|
|
487
|
+
this.buf32.set(selfie);
|
|
488
|
+
}
|
|
489
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/2925
|
|
490
|
+
this.buf[255] = 0;
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// The following *Hostname() methods can be used to store hostname strings
|
|
495
|
+
// outside the trie. This is useful to store/match hostnames which are
|
|
496
|
+
// not part of a collection, and yet still benefit from storing the strings
|
|
497
|
+
// into a trie container's character buffer.
|
|
498
|
+
// TODO: WASM version of matchesHostname()
|
|
499
|
+
|
|
500
|
+
storeHostname(hn) {
|
|
501
|
+
let n = hn.length;
|
|
502
|
+
if ( n > 255 ) {
|
|
503
|
+
hn = hn.slice(-255);
|
|
504
|
+
n = 255;
|
|
505
|
+
}
|
|
506
|
+
if ( n === this.lastStoredLen && hn === this.lastStored ) {
|
|
507
|
+
return this.lastStoredIndex;
|
|
508
|
+
}
|
|
509
|
+
this.lastStored = hn;
|
|
510
|
+
this.lastStoredLen = n;
|
|
511
|
+
if ( (this.buf.length - this.buf32[CHAR1_SLOT]) < n ) {
|
|
512
|
+
this.growBuf(0, n);
|
|
513
|
+
}
|
|
514
|
+
const offset = this.buf32[CHAR1_SLOT];
|
|
515
|
+
this.buf32[CHAR1_SLOT] = offset + n;
|
|
516
|
+
const buf8 = this.buf;
|
|
517
|
+
for ( let i = 0; i < n; i++ ) {
|
|
518
|
+
buf8[offset+i] = hn.charCodeAt(i);
|
|
519
|
+
}
|
|
520
|
+
return (this.lastStoredIndex = offset - this.buf32[CHAR0_SLOT]);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
extractHostname(i, n) {
|
|
524
|
+
const textDecoder = new TextDecoder();
|
|
525
|
+
const offset = this.buf32[CHAR0_SLOT] + i;
|
|
526
|
+
return textDecoder.decode(this.buf.subarray(offset, offset + n));
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
storeDomainOpt(s) {
|
|
530
|
+
let n = s.length;
|
|
531
|
+
if ( n === this.lastStoredLen && s === this.lastStored ) {
|
|
532
|
+
return this.lastStoredIndex;
|
|
533
|
+
}
|
|
534
|
+
this.lastStored = s;
|
|
535
|
+
this.lastStoredLen = n;
|
|
536
|
+
if ( (this.buf.length - this.buf32[CHAR1_SLOT]) < n ) {
|
|
537
|
+
this.growBuf(0, n);
|
|
538
|
+
}
|
|
539
|
+
const offset = this.buf32[CHAR1_SLOT];
|
|
540
|
+
this.buf32[CHAR1_SLOT] = offset + n;
|
|
541
|
+
const buf8 = this.buf;
|
|
542
|
+
for ( let i = 0; i < n; i++ ) {
|
|
543
|
+
buf8[offset+i] = s.charCodeAt(i);
|
|
544
|
+
}
|
|
545
|
+
return (this.lastStoredIndex = offset - this.buf32[CHAR0_SLOT]);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
extractDomainOpt(i, n) {
|
|
549
|
+
const textDecoder = new TextDecoder();
|
|
550
|
+
const offset = this.buf32[CHAR0_SLOT] + i;
|
|
551
|
+
return textDecoder.decode(this.buf.subarray(offset, offset + n));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
matchesHostname(hn, i, n) {
|
|
555
|
+
this.setNeedle(hn);
|
|
556
|
+
const buf8 = this.buf;
|
|
557
|
+
const hr = buf8[255];
|
|
558
|
+
if ( n > hr ) { return false; }
|
|
559
|
+
const hl = hr - n;
|
|
560
|
+
const nl = this.buf32[CHAR0_SLOT] + i;
|
|
561
|
+
for ( let j = 0; j < n; j++ ) {
|
|
562
|
+
if ( buf8[nl+j] !== buf8[hl+j] ) { return false; }
|
|
563
|
+
}
|
|
564
|
+
return n === hr || hn.charCodeAt(hl-1) === 0x2E /* '.' */;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
async enableWASM(wasmModuleFetcher, path) {
|
|
568
|
+
if ( typeof WebAssembly === 'undefined' ) { return false; }
|
|
569
|
+
if ( this.wasmMemory instanceof WebAssembly.Memory ) { return true; }
|
|
570
|
+
const module = await getWasmModule(wasmModuleFetcher, path);
|
|
571
|
+
if ( module instanceof WebAssembly.Module === false ) { return false; }
|
|
572
|
+
const memory = new WebAssembly.Memory({ initial: 2 });
|
|
573
|
+
const instance = await WebAssembly.instantiate(module, {
|
|
574
|
+
imports: {
|
|
575
|
+
memory,
|
|
576
|
+
growBuf: this.growBuf.bind(this, 24, 256)
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
if ( instance instanceof WebAssembly.Instance === false ) { return false; }
|
|
580
|
+
this.wasmMemory = memory;
|
|
581
|
+
const curPageCount = memory.buffer.byteLength >>> 16;
|
|
582
|
+
const newPageCount = roundToPageSize(this.buf.byteLength) >>> 16;
|
|
583
|
+
if ( newPageCount > curPageCount ) {
|
|
584
|
+
memory.grow(newPageCount - curPageCount);
|
|
585
|
+
}
|
|
586
|
+
const buf = new Uint8Array(memory.buffer);
|
|
587
|
+
buf.set(this.buf);
|
|
588
|
+
this.buf = buf;
|
|
589
|
+
this.buf32 = new Uint32Array(this.buf.buffer);
|
|
590
|
+
this.matches = this.matchesWASM = instance.exports.matches;
|
|
591
|
+
this.add = this.addWASM = instance.exports.add;
|
|
592
|
+
return true;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
dumpInfo() {
|
|
596
|
+
return [
|
|
597
|
+
`Buffer size (Uint8Array): ${this.buf32[CHAR1_SLOT].toLocaleString('en')}`,
|
|
598
|
+
`WASM: ${this.wasmMemory === null ? 'disabled' : 'enabled'}`,
|
|
599
|
+
].join('\n');
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
//--------------------------------------------------------------------------
|
|
603
|
+
// Private methods
|
|
604
|
+
//--------------------------------------------------------------------------
|
|
605
|
+
|
|
606
|
+
addCell(idown, iright, v) {
|
|
607
|
+
let icell = this.buf32[TRIE1_SLOT];
|
|
608
|
+
this.buf32[TRIE1_SLOT] = icell + 12;
|
|
609
|
+
icell >>>= 2;
|
|
610
|
+
this.buf32[icell+0] = idown;
|
|
611
|
+
this.buf32[icell+1] = iright;
|
|
612
|
+
this.buf32[icell+2] = v;
|
|
613
|
+
return icell;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
addLeafCell(lsegchar) {
|
|
617
|
+
const r = this.buf32[TRIE1_SLOT] >>> 2;
|
|
618
|
+
let i = r;
|
|
619
|
+
while ( lsegchar > 127 ) {
|
|
620
|
+
this.buf32[i+0] = 0;
|
|
621
|
+
this.buf32[i+1] = i + 3;
|
|
622
|
+
this.buf32[i+2] = this.addSegment(lsegchar, lsegchar - 127);
|
|
623
|
+
lsegchar -= 127;
|
|
624
|
+
i += 3;
|
|
625
|
+
}
|
|
626
|
+
this.buf32[i+0] = 0;
|
|
627
|
+
this.buf32[i+1] = 0;
|
|
628
|
+
this.buf32[i+2] = this.addSegment(lsegchar, 0) | 0x80;
|
|
629
|
+
this.buf32[TRIE1_SLOT] = i + 3 << 2;
|
|
630
|
+
return r;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
addSegment(lsegchar, lsegend) {
|
|
634
|
+
if ( lsegchar === 0 ) { return 0; }
|
|
635
|
+
let char1 = this.buf32[CHAR1_SLOT];
|
|
636
|
+
const isegchar = char1 - this.buf32[CHAR0_SLOT];
|
|
637
|
+
let i = lsegchar;
|
|
638
|
+
do {
|
|
639
|
+
this.buf[char1++] = this.buf[--i];
|
|
640
|
+
} while ( i !== lsegend );
|
|
641
|
+
this.buf32[CHAR1_SLOT] = char1;
|
|
642
|
+
return isegchar << 8 | lsegchar - lsegend;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
growBuf(trieGrow, charGrow) {
|
|
646
|
+
const char0 = Math.max(
|
|
647
|
+
roundToPageSize(this.buf32[TRIE1_SLOT] + trieGrow),
|
|
648
|
+
this.buf32[CHAR0_SLOT]
|
|
649
|
+
);
|
|
650
|
+
const char1 = char0 + this.buf32[CHAR1_SLOT] - this.buf32[CHAR0_SLOT];
|
|
651
|
+
const bufLen = Math.max(
|
|
652
|
+
roundToPageSize(char1 + charGrow),
|
|
653
|
+
this.buf.length
|
|
654
|
+
);
|
|
655
|
+
this.resizeBuf(bufLen, char0);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
shrinkBuf() {
|
|
659
|
+
// Can't shrink WebAssembly.Memory
|
|
660
|
+
if ( this.wasmMemory !== null ) { return; }
|
|
661
|
+
const char0 = this.buf32[TRIE1_SLOT] + 24;
|
|
662
|
+
const char1 = char0 + this.buf32[CHAR1_SLOT] - this.buf32[CHAR0_SLOT];
|
|
663
|
+
const bufLen = char1 + 256;
|
|
664
|
+
this.resizeBuf(bufLen, char0);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
resizeBuf(bufLen, char0) {
|
|
668
|
+
bufLen = roundToPageSize(bufLen);
|
|
669
|
+
if ( bufLen === this.buf.length && char0 === this.buf32[CHAR0_SLOT] ) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const charDataLen = this.buf32[CHAR1_SLOT] - this.buf32[CHAR0_SLOT];
|
|
673
|
+
if ( this.wasmMemory !== null ) {
|
|
674
|
+
const pageCount = (bufLen >>> 16) - (this.buf.byteLength >>> 16);
|
|
675
|
+
if ( pageCount > 0 ) {
|
|
676
|
+
this.wasmMemory.grow(pageCount);
|
|
677
|
+
this.buf = new Uint8Array(this.wasmMemory.buffer);
|
|
678
|
+
this.buf32 = new Uint32Array(this.wasmMemory.buffer);
|
|
679
|
+
}
|
|
680
|
+
} else if ( bufLen !== this.buf.length ) {
|
|
681
|
+
const newBuf = new Uint8Array(bufLen);
|
|
682
|
+
newBuf.set(
|
|
683
|
+
new Uint8Array(
|
|
684
|
+
this.buf.buffer,
|
|
685
|
+
0,
|
|
686
|
+
this.buf32[TRIE1_SLOT]
|
|
687
|
+
),
|
|
688
|
+
0
|
|
689
|
+
);
|
|
690
|
+
newBuf.set(
|
|
691
|
+
new Uint8Array(
|
|
692
|
+
this.buf.buffer,
|
|
693
|
+
this.buf32[CHAR0_SLOT],
|
|
694
|
+
charDataLen
|
|
695
|
+
),
|
|
696
|
+
char0
|
|
697
|
+
);
|
|
698
|
+
this.buf = newBuf;
|
|
699
|
+
this.buf32 = new Uint32Array(this.buf.buffer);
|
|
700
|
+
this.buf32[CHAR0_SLOT] = char0;
|
|
701
|
+
this.buf32[CHAR1_SLOT] = char0 + charDataLen;
|
|
702
|
+
}
|
|
703
|
+
if ( char0 !== this.buf32[CHAR0_SLOT] ) {
|
|
704
|
+
this.buf.set(
|
|
705
|
+
new Uint8Array(
|
|
706
|
+
this.buf.buffer,
|
|
707
|
+
this.buf32[CHAR0_SLOT],
|
|
708
|
+
charDataLen
|
|
709
|
+
),
|
|
710
|
+
char0
|
|
711
|
+
);
|
|
712
|
+
this.buf32[CHAR0_SLOT] = char0;
|
|
713
|
+
this.buf32[CHAR1_SLOT] = char0 + charDataLen;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
reallocateBuf(newSize) {
|
|
718
|
+
newSize = roundToPageSize(newSize);
|
|
719
|
+
if ( newSize === this.buf.length ) { return; }
|
|
720
|
+
if ( this.wasmMemory === null ) {
|
|
721
|
+
const newBuf = new Uint8Array(newSize);
|
|
722
|
+
newBuf.set(
|
|
723
|
+
newBuf.length < this.buf.length
|
|
724
|
+
? this.buf.subarray(0, newBuf.length)
|
|
725
|
+
: this.buf
|
|
726
|
+
);
|
|
727
|
+
this.buf = newBuf;
|
|
728
|
+
} else {
|
|
729
|
+
const growBy =
|
|
730
|
+
((newSize + 0xFFFF) >>> 16) - (this.buf.length >>> 16);
|
|
731
|
+
if ( growBy <= 0 ) { return; }
|
|
732
|
+
this.wasmMemory.grow(growBy);
|
|
733
|
+
this.buf = new Uint8Array(this.wasmMemory.buffer);
|
|
734
|
+
}
|
|
735
|
+
this.buf32 = new Uint32Array(this.buf.buffer);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
HNTrieContainer.prototype.matches = HNTrieContainer.prototype.matchesJS;
|
|
740
|
+
HNTrieContainer.prototype.matchesWASM = null;
|
|
741
|
+
|
|
742
|
+
HNTrieContainer.prototype.add = HNTrieContainer.prototype.addJS;
|
|
743
|
+
HNTrieContainer.prototype.addWASM = null;
|
|
744
|
+
|
|
745
|
+
/******************************************************************************/
|
|
746
|
+
|
|
747
|
+
// Code below is to attempt to load a WASM module which implements:
|
|
748
|
+
//
|
|
749
|
+
// - HNTrieContainer.add()
|
|
750
|
+
// - HNTrieContainer.matches()
|
|
751
|
+
//
|
|
752
|
+
// The WASM module is entirely optional, the JS implementations will be
|
|
753
|
+
// used should the WASM module be unavailable for whatever reason.
|
|
754
|
+
|
|
755
|
+
const getWasmModule = (( ) => {
|
|
756
|
+
let wasmModulePromise;
|
|
757
|
+
|
|
758
|
+
return async function(wasmModuleFetcher, path) {
|
|
759
|
+
if ( wasmModulePromise instanceof Promise ) {
|
|
760
|
+
return wasmModulePromise;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// The wasm module will work only if CPU is natively little-endian,
|
|
764
|
+
// as we use native uint32 array in our js code.
|
|
765
|
+
const uint32s = new Uint32Array(1);
|
|
766
|
+
const uint8s = new Uint8Array(uint32s.buffer);
|
|
767
|
+
uint32s[0] = 1;
|
|
768
|
+
if ( uint8s[0] !== 1 ) { return; }
|
|
769
|
+
|
|
770
|
+
wasmModulePromise = wasmModuleFetcher(`${path}hntrie`).catch(reason => {
|
|
771
|
+
console.info(reason);
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
return wasmModulePromise;
|
|
775
|
+
};
|
|
776
|
+
})();
|
|
777
|
+
|
|
778
|
+
/******************************************************************************/
|
|
779
|
+
|
|
780
|
+
export default HNTrieContainer;
|