@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,947 @@
|
|
|
1
|
+
/*******************************************************************************
|
|
2
|
+
|
|
3
|
+
uBlock Origin - a browser extension to block requests.
|
|
4
|
+
Copyright (C) 2019-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, vAPI */
|
|
23
|
+
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
/*******************************************************************************
|
|
27
|
+
|
|
28
|
+
A BidiTrieContainer is mostly a large buffer in which distinct but related
|
|
29
|
+
tries are stored. The memory layout of the buffer is as follow:
|
|
30
|
+
|
|
31
|
+
0-2047: haystack section
|
|
32
|
+
2048-2051: number of significant characters in the haystack
|
|
33
|
+
2052-2055: offset to start of trie data section (=> trie0)
|
|
34
|
+
2056-2059: offset to end of trie data section (=> trie1)
|
|
35
|
+
2060-2063: offset to start of character data section (=> char0)
|
|
36
|
+
2064-2067: offset to end of character data section (=> char1)
|
|
37
|
+
2068: start of trie data section
|
|
38
|
+
|
|
39
|
+
+--------------+
|
|
40
|
+
Normal cell: | And | If "Segment info" matches:
|
|
41
|
+
(aka CELL) +--------------+ Goto "And"
|
|
42
|
+
| Or | Else
|
|
43
|
+
+--------------+ Goto "Or"
|
|
44
|
+
| Segment info |
|
|
45
|
+
+--------------+
|
|
46
|
+
|
|
47
|
+
+--------------+
|
|
48
|
+
Boundary cell: | Right And | "Right And" and/or "Left And"
|
|
49
|
+
(aka BCELL) +--------------+ can be 0 in last-segment condition.
|
|
50
|
+
| Left And |
|
|
51
|
+
+--------------+
|
|
52
|
+
| 0 |
|
|
53
|
+
+--------------+
|
|
54
|
+
|
|
55
|
+
Given following filters and assuming token is "ad" for all of them:
|
|
56
|
+
|
|
57
|
+
-images/ad-
|
|
58
|
+
/google_ad.
|
|
59
|
+
/images_ad.
|
|
60
|
+
_images/ad.
|
|
61
|
+
|
|
62
|
+
We get the following internal representation:
|
|
63
|
+
|
|
64
|
+
+-----------+ +-----------+ +---+
|
|
65
|
+
| |---->| |---->| 0 |
|
|
66
|
+
+-----------+ +-----------+ +---+ +-----------+
|
|
67
|
+
| 0 | +--| | | |---->| 0 |
|
|
68
|
+
+-----------+ | +-----------+ +---+ +-----------+
|
|
69
|
+
| ad | | | - | | 0 | | 0 |
|
|
70
|
+
+-----------+ | +-----------+ +---+ +-----------+
|
|
71
|
+
| | -images/ |
|
|
72
|
+
| +-----------+ +---+ +-----------+
|
|
73
|
+
+->| |---->| 0 |
|
|
74
|
+
+-----------+ +---+ +-----------+ +-----------+
|
|
75
|
+
| 0 | | |---->| |---->| 0 |
|
|
76
|
+
+-----------+ +---+ +-----------+ +-----------+
|
|
77
|
+
| . | | 0 | +--| | +--| |
|
|
78
|
+
+-----------+ +---+ | +-----------+ | +-----------+
|
|
79
|
+
| | _ | | | /google |
|
|
80
|
+
| +-----------+ | +-----------+
|
|
81
|
+
| |
|
|
82
|
+
| | +-----------+
|
|
83
|
+
| +->| 0 |
|
|
84
|
+
| +-----------+
|
|
85
|
+
| | 0 |
|
|
86
|
+
| +-----------+
|
|
87
|
+
| | /images |
|
|
88
|
+
| +-----------+
|
|
89
|
+
|
|
|
90
|
+
| +-----------+
|
|
91
|
+
+->| 0 |
|
|
92
|
+
+-----------+
|
|
93
|
+
| 0 |
|
|
94
|
+
+-----------+
|
|
95
|
+
| _images/ |
|
|
96
|
+
+-----------+
|
|
97
|
+
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
const PAGE_SIZE = 65536*2;
|
|
101
|
+
const HAYSTACK_START = 0;
|
|
102
|
+
const HAYSTACK_SIZE = 2048; // i32 / i8
|
|
103
|
+
const HAYSTACK_SIZE_SLOT = HAYSTACK_SIZE >>> 2; // 512 / 2048
|
|
104
|
+
const TRIE0_SLOT = HAYSTACK_SIZE_SLOT + 1; // 513 / 2052
|
|
105
|
+
const TRIE1_SLOT = HAYSTACK_SIZE_SLOT + 2; // 514 / 2056
|
|
106
|
+
const CHAR0_SLOT = HAYSTACK_SIZE_SLOT + 3; // 515 / 2060
|
|
107
|
+
const CHAR1_SLOT = HAYSTACK_SIZE_SLOT + 4; // 516 / 2064
|
|
108
|
+
const RESULT_L_SLOT = HAYSTACK_SIZE_SLOT + 5; // 517 / 2068
|
|
109
|
+
const RESULT_R_SLOT = HAYSTACK_SIZE_SLOT + 6; // 518 / 2072
|
|
110
|
+
const RESULT_IU_SLOT = HAYSTACK_SIZE_SLOT + 7; // 519 / 2076
|
|
111
|
+
const TRIE0_START = HAYSTACK_SIZE_SLOT + 8 << 2; // 2080
|
|
112
|
+
|
|
113
|
+
const CELL_BYTE_LENGTH = 12;
|
|
114
|
+
const MIN_FREE_CELL_BYTE_LENGTH = CELL_BYTE_LENGTH * 8;
|
|
115
|
+
|
|
116
|
+
const CELL_AND = 0;
|
|
117
|
+
const CELL_OR = 1;
|
|
118
|
+
const SEGMENT_INFO = 2;
|
|
119
|
+
const BCELL_NEXT_AND = 0;
|
|
120
|
+
const BCELL_ALT_AND = 1;
|
|
121
|
+
const BCELL_EXTRA = 2;
|
|
122
|
+
const BCELL_EXTRA_MAX = 0x00FFFFFF;
|
|
123
|
+
|
|
124
|
+
const toSegmentInfo = (aL, l, r) => ((r - l) << 24) | (aL + l);
|
|
125
|
+
const roundToPageSize = v => (v + PAGE_SIZE-1) & ~(PAGE_SIZE-1);
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class BidiTrieContainer {
|
|
129
|
+
|
|
130
|
+
constructor(extraHandler) {
|
|
131
|
+
const len = PAGE_SIZE * 4;
|
|
132
|
+
this.buf8 = new Uint8Array(len);
|
|
133
|
+
this.buf32 = new Uint32Array(this.buf8.buffer);
|
|
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.haystack = this.buf8.subarray(
|
|
139
|
+
HAYSTACK_START,
|
|
140
|
+
HAYSTACK_START + HAYSTACK_SIZE
|
|
141
|
+
);
|
|
142
|
+
this.extraHandler = extraHandler;
|
|
143
|
+
this.textDecoder = null;
|
|
144
|
+
this.wasmMemory = null;
|
|
145
|
+
|
|
146
|
+
this.lastStored = '';
|
|
147
|
+
this.lastStoredLen = this.lastStoredIndex = 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//--------------------------------------------------------------------------
|
|
151
|
+
// Public methods
|
|
152
|
+
//--------------------------------------------------------------------------
|
|
153
|
+
|
|
154
|
+
get haystackLen() {
|
|
155
|
+
return this.buf32[HAYSTACK_SIZE_SLOT];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
set haystackLen(v) {
|
|
159
|
+
this.buf32[HAYSTACK_SIZE_SLOT] = v;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
reset(details) {
|
|
163
|
+
if (
|
|
164
|
+
details instanceof Object &&
|
|
165
|
+
typeof details.byteLength === 'number' &&
|
|
166
|
+
typeof details.char0 === 'number'
|
|
167
|
+
) {
|
|
168
|
+
if ( details.byteLength > this.buf8.byteLength ) {
|
|
169
|
+
this.reallocateBuf(details.byteLength);
|
|
170
|
+
}
|
|
171
|
+
this.buf32[CHAR0_SLOT] = details.char0;
|
|
172
|
+
}
|
|
173
|
+
this.buf32[TRIE1_SLOT] = this.buf32[TRIE0_SLOT];
|
|
174
|
+
this.buf32[CHAR1_SLOT] = this.buf32[CHAR0_SLOT];
|
|
175
|
+
|
|
176
|
+
this.lastStored = '';
|
|
177
|
+
this.lastStoredLen = this.lastStoredIndex = 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
createTrie() {
|
|
181
|
+
// grow buffer if needed
|
|
182
|
+
if ( (this.buf32[CHAR0_SLOT] - this.buf32[TRIE1_SLOT]) < CELL_BYTE_LENGTH ) {
|
|
183
|
+
this.growBuf(CELL_BYTE_LENGTH, 0);
|
|
184
|
+
}
|
|
185
|
+
const iroot = this.buf32[TRIE1_SLOT] >>> 2;
|
|
186
|
+
this.buf32[TRIE1_SLOT] += CELL_BYTE_LENGTH;
|
|
187
|
+
this.buf32[iroot+CELL_OR] = 0;
|
|
188
|
+
this.buf32[iroot+CELL_AND] = 0;
|
|
189
|
+
this.buf32[iroot+SEGMENT_INFO] = 0;
|
|
190
|
+
return iroot;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
matches(icell, ai) {
|
|
194
|
+
const buf32 = this.buf32;
|
|
195
|
+
const buf8 = this.buf8;
|
|
196
|
+
const char0 = buf32[CHAR0_SLOT];
|
|
197
|
+
const aR = buf32[HAYSTACK_SIZE_SLOT];
|
|
198
|
+
let al = ai, x = 0, y = 0;
|
|
199
|
+
for (;;) {
|
|
200
|
+
x = buf8[al];
|
|
201
|
+
al += 1;
|
|
202
|
+
// find matching segment
|
|
203
|
+
for (;;) {
|
|
204
|
+
y = buf32[icell+SEGMENT_INFO];
|
|
205
|
+
let bl = char0 + (y & 0x00FFFFFF);
|
|
206
|
+
if ( buf8[bl] === x ) {
|
|
207
|
+
y = (y >>> 24) - 1;
|
|
208
|
+
if ( y !== 0 ) {
|
|
209
|
+
x = al + y;
|
|
210
|
+
if ( x > aR ) { return 0; }
|
|
211
|
+
for (;;) {
|
|
212
|
+
bl += 1;
|
|
213
|
+
if ( buf8[bl] !== buf8[al] ) { return 0; }
|
|
214
|
+
al += 1;
|
|
215
|
+
if ( al === x ) { break; }
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
icell = buf32[icell+CELL_OR];
|
|
221
|
+
if ( icell === 0 ) { return 0; }
|
|
222
|
+
}
|
|
223
|
+
// next segment
|
|
224
|
+
icell = buf32[icell+CELL_AND];
|
|
225
|
+
x = buf32[icell+BCELL_EXTRA];
|
|
226
|
+
if ( x <= BCELL_EXTRA_MAX ) {
|
|
227
|
+
if ( x !== 0 && this.matchesExtra(ai, al, x) !== 0 ) {
|
|
228
|
+
return 1;
|
|
229
|
+
}
|
|
230
|
+
x = buf32[icell+BCELL_ALT_AND];
|
|
231
|
+
if ( x !== 0 && this.matchesLeft(x, ai, al) !== 0 ) {
|
|
232
|
+
return 1;
|
|
233
|
+
}
|
|
234
|
+
icell = buf32[icell+BCELL_NEXT_AND];
|
|
235
|
+
if ( icell === 0 ) { return 0; }
|
|
236
|
+
}
|
|
237
|
+
if ( al === aR ) { return 0; }
|
|
238
|
+
}
|
|
239
|
+
return 0; // eslint-disable-line no-unreachable
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
matchesLeft(icell, ar, r) {
|
|
243
|
+
const buf32 = this.buf32;
|
|
244
|
+
const buf8 = this.buf8;
|
|
245
|
+
const char0 = buf32[CHAR0_SLOT];
|
|
246
|
+
let x = 0, y = 0;
|
|
247
|
+
for (;;) {
|
|
248
|
+
if ( ar === 0 ) { return 0; }
|
|
249
|
+
ar -= 1;
|
|
250
|
+
x = buf8[ar];
|
|
251
|
+
// find first segment with a first-character match
|
|
252
|
+
for (;;) {
|
|
253
|
+
y = buf32[icell+SEGMENT_INFO];
|
|
254
|
+
let br = char0 + (y & 0x00FFFFFF);
|
|
255
|
+
y = (y >>> 24) - 1;
|
|
256
|
+
br += y;
|
|
257
|
+
if ( buf8[br] === x ) { // all characters in segment must match
|
|
258
|
+
if ( y !== 0 ) {
|
|
259
|
+
x = ar - y;
|
|
260
|
+
if ( x < 0 ) { return 0; }
|
|
261
|
+
for (;;) {
|
|
262
|
+
ar -= 1; br -= 1;
|
|
263
|
+
if ( buf8[ar] !== buf8[br] ) { return 0; }
|
|
264
|
+
if ( ar === x ) { break; }
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
icell = buf32[icell+CELL_OR];
|
|
270
|
+
if ( icell === 0 ) { return 0; }
|
|
271
|
+
}
|
|
272
|
+
// next segment
|
|
273
|
+
icell = buf32[icell+CELL_AND];
|
|
274
|
+
x = buf32[icell+BCELL_EXTRA];
|
|
275
|
+
if ( x <= BCELL_EXTRA_MAX ) {
|
|
276
|
+
if ( x !== 0 && this.matchesExtra(ar, r, x) !== 0 ) {
|
|
277
|
+
return 1;
|
|
278
|
+
}
|
|
279
|
+
icell = buf32[icell+BCELL_NEXT_AND];
|
|
280
|
+
if ( icell === 0 ) { return 0; }
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return 0; // eslint-disable-line no-unreachable
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
matchesExtra(l, r, ix) {
|
|
287
|
+
let iu = 0;
|
|
288
|
+
if ( ix !== 1 ) {
|
|
289
|
+
iu = this.extraHandler(l, r, ix);
|
|
290
|
+
if ( iu === 0 ) { return 0; }
|
|
291
|
+
} else {
|
|
292
|
+
iu = -1;
|
|
293
|
+
}
|
|
294
|
+
this.buf32[RESULT_IU_SLOT] = iu;
|
|
295
|
+
this.buf32[RESULT_L_SLOT] = l;
|
|
296
|
+
this.buf32[RESULT_R_SLOT] = r;
|
|
297
|
+
return 1;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
get $l() { return this.buf32[RESULT_L_SLOT] | 0; }
|
|
301
|
+
get $r() { return this.buf32[RESULT_R_SLOT] | 0; }
|
|
302
|
+
get $iu() { return this.buf32[RESULT_IU_SLOT] | 0; }
|
|
303
|
+
|
|
304
|
+
add(iroot, aL0, n, pivot = 0) {
|
|
305
|
+
const aR = n;
|
|
306
|
+
if ( aR === 0 ) { return 0; }
|
|
307
|
+
// Grow buffer if needed. The characters are already in our character
|
|
308
|
+
// data buffer, so we do not need to grow character data buffer.
|
|
309
|
+
if (
|
|
310
|
+
(this.buf32[CHAR0_SLOT] - this.buf32[TRIE1_SLOT]) <
|
|
311
|
+
MIN_FREE_CELL_BYTE_LENGTH
|
|
312
|
+
) {
|
|
313
|
+
this.growBuf(MIN_FREE_CELL_BYTE_LENGTH, 0);
|
|
314
|
+
}
|
|
315
|
+
const buf32 = this.buf32;
|
|
316
|
+
const char0 = buf32[CHAR0_SLOT];
|
|
317
|
+
let icell = iroot;
|
|
318
|
+
let aL = char0 + aL0;
|
|
319
|
+
// special case: first node in trie
|
|
320
|
+
if ( buf32[icell+SEGMENT_INFO] === 0 ) {
|
|
321
|
+
buf32[icell+SEGMENT_INFO] = toSegmentInfo(aL0, pivot, aR);
|
|
322
|
+
return this.addLeft(icell, aL0, pivot);
|
|
323
|
+
}
|
|
324
|
+
const buf8 = this.buf8;
|
|
325
|
+
let al = pivot;
|
|
326
|
+
let inext;
|
|
327
|
+
// find a matching cell: move down
|
|
328
|
+
for (;;) {
|
|
329
|
+
const binfo = buf32[icell+SEGMENT_INFO];
|
|
330
|
+
// length of segment
|
|
331
|
+
const bR = binfo >>> 24;
|
|
332
|
+
// skip boundary cells
|
|
333
|
+
if ( bR === 0 ) {
|
|
334
|
+
icell = buf32[icell+BCELL_NEXT_AND];
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
let bl = char0 + (binfo & 0x00FFFFFF);
|
|
338
|
+
// if first character is no match, move to next descendant
|
|
339
|
+
if ( buf8[bl] !== buf8[aL+al] ) {
|
|
340
|
+
inext = buf32[icell+CELL_OR];
|
|
341
|
+
if ( inext === 0 ) {
|
|
342
|
+
inext = this.addCell(0, 0, toSegmentInfo(aL0, al, aR));
|
|
343
|
+
buf32[icell+CELL_OR] = inext;
|
|
344
|
+
return this.addLeft(inext, aL0, pivot);
|
|
345
|
+
}
|
|
346
|
+
icell = inext;
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
// 1st character was tested
|
|
350
|
+
let bi = 1;
|
|
351
|
+
al += 1;
|
|
352
|
+
// find 1st mismatch in rest of segment
|
|
353
|
+
if ( bR !== 1 ) {
|
|
354
|
+
for (;;) {
|
|
355
|
+
if ( bi === bR ) { break; }
|
|
356
|
+
if ( al === aR ) { break; }
|
|
357
|
+
if ( buf8[bl+bi] !== buf8[aL+al] ) { break; }
|
|
358
|
+
bi += 1;
|
|
359
|
+
al += 1;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
// all segment characters matched
|
|
363
|
+
if ( bi === bR ) {
|
|
364
|
+
// needle remainder: no
|
|
365
|
+
if ( al === aR ) {
|
|
366
|
+
return this.addLeft(icell, aL0, pivot);
|
|
367
|
+
}
|
|
368
|
+
// needle remainder: yes
|
|
369
|
+
inext = buf32[icell+CELL_AND];
|
|
370
|
+
if ( buf32[inext+CELL_AND] !== 0 ) {
|
|
371
|
+
icell = inext;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
// add needle remainder
|
|
375
|
+
icell = this.addCell(0, 0, toSegmentInfo(aL0, al, aR));
|
|
376
|
+
buf32[inext+CELL_AND] = icell;
|
|
377
|
+
return this.addLeft(icell, aL0, pivot);
|
|
378
|
+
}
|
|
379
|
+
// some characters matched
|
|
380
|
+
// split current segment
|
|
381
|
+
bl -= char0;
|
|
382
|
+
buf32[icell+SEGMENT_INFO] = bi << 24 | bl;
|
|
383
|
+
inext = this.addCell(
|
|
384
|
+
buf32[icell+CELL_AND], 0, bR - bi << 24 | bl + bi
|
|
385
|
+
);
|
|
386
|
+
buf32[icell+CELL_AND] = inext;
|
|
387
|
+
// needle remainder: no = need boundary cell
|
|
388
|
+
if ( al === aR ) {
|
|
389
|
+
return this.addLeft(icell, aL0, pivot);
|
|
390
|
+
}
|
|
391
|
+
// needle remainder: yes = need new cell for remaining characters
|
|
392
|
+
icell = this.addCell(0, 0, toSegmentInfo(aL0, al, aR));
|
|
393
|
+
buf32[inext+CELL_OR] = icell;
|
|
394
|
+
return this.addLeft(icell, aL0, pivot);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
addLeft(icell, aL0, pivot) {
|
|
399
|
+
const buf32 = this.buf32;
|
|
400
|
+
const char0 = buf32[CHAR0_SLOT];
|
|
401
|
+
let aL = aL0 + char0;
|
|
402
|
+
// fetch boundary cell
|
|
403
|
+
let iboundary = buf32[icell+CELL_AND];
|
|
404
|
+
// add boundary cell if none exist
|
|
405
|
+
if (
|
|
406
|
+
iboundary === 0 ||
|
|
407
|
+
buf32[iboundary+SEGMENT_INFO] > BCELL_EXTRA_MAX
|
|
408
|
+
) {
|
|
409
|
+
const inext = iboundary;
|
|
410
|
+
iboundary = this.allocateCell();
|
|
411
|
+
buf32[icell+CELL_AND] = iboundary;
|
|
412
|
+
buf32[iboundary+BCELL_NEXT_AND] = inext;
|
|
413
|
+
if ( pivot === 0 ) { return iboundary; }
|
|
414
|
+
}
|
|
415
|
+
// shortest match with no extra conditions will always win
|
|
416
|
+
if ( buf32[iboundary+BCELL_EXTRA] === 1 ) {
|
|
417
|
+
return iboundary;
|
|
418
|
+
}
|
|
419
|
+
// bail out if no left segment
|
|
420
|
+
if ( pivot === 0 ) { return iboundary; }
|
|
421
|
+
// fetch root cell of left segment
|
|
422
|
+
icell = buf32[iboundary+BCELL_ALT_AND];
|
|
423
|
+
if ( icell === 0 ) {
|
|
424
|
+
icell = this.allocateCell();
|
|
425
|
+
buf32[iboundary+BCELL_ALT_AND] = icell;
|
|
426
|
+
}
|
|
427
|
+
// special case: first node in trie
|
|
428
|
+
if ( buf32[icell+SEGMENT_INFO] === 0 ) {
|
|
429
|
+
buf32[icell+SEGMENT_INFO] = toSegmentInfo(aL0, 0, pivot);
|
|
430
|
+
iboundary = this.allocateCell();
|
|
431
|
+
buf32[icell+CELL_AND] = iboundary;
|
|
432
|
+
return iboundary;
|
|
433
|
+
}
|
|
434
|
+
const buf8 = this.buf8;
|
|
435
|
+
let ar = pivot, inext;
|
|
436
|
+
// find a matching cell: move down
|
|
437
|
+
for (;;) {
|
|
438
|
+
const binfo = buf32[icell+SEGMENT_INFO];
|
|
439
|
+
// skip boundary cells
|
|
440
|
+
if ( binfo <= BCELL_EXTRA_MAX ) {
|
|
441
|
+
inext = buf32[icell+CELL_AND];
|
|
442
|
+
if ( inext !== 0 ) {
|
|
443
|
+
icell = inext;
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
iboundary = this.allocateCell();
|
|
447
|
+
buf32[icell+CELL_AND] =
|
|
448
|
+
this.addCell(iboundary, 0, toSegmentInfo(aL0, 0, ar));
|
|
449
|
+
// TODO: boundary cell might be last
|
|
450
|
+
// add remainder + boundary cell
|
|
451
|
+
return iboundary;
|
|
452
|
+
}
|
|
453
|
+
const bL = char0 + (binfo & 0x00FFFFFF);
|
|
454
|
+
const bR = bL + (binfo >>> 24);
|
|
455
|
+
let br = bR;
|
|
456
|
+
// if first character is no match, move to next descendant
|
|
457
|
+
if ( buf8[br-1] !== buf8[aL+ar-1] ) {
|
|
458
|
+
inext = buf32[icell+CELL_OR];
|
|
459
|
+
if ( inext === 0 ) {
|
|
460
|
+
iboundary = this.allocateCell();
|
|
461
|
+
inext = this.addCell(
|
|
462
|
+
iboundary, 0, toSegmentInfo(aL0, 0, ar)
|
|
463
|
+
);
|
|
464
|
+
buf32[icell+CELL_OR] = inext;
|
|
465
|
+
return iboundary;
|
|
466
|
+
}
|
|
467
|
+
icell = inext;
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
// 1st character was tested
|
|
471
|
+
br -= 1;
|
|
472
|
+
ar -= 1;
|
|
473
|
+
// find 1st mismatch in rest of segment
|
|
474
|
+
if ( br !== bL ) {
|
|
475
|
+
for (;;) {
|
|
476
|
+
if ( br === bL ) { break; }
|
|
477
|
+
if ( ar === 0 ) { break; }
|
|
478
|
+
if ( buf8[br-1] !== buf8[aL+ar-1] ) { break; }
|
|
479
|
+
br -= 1;
|
|
480
|
+
ar -= 1;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
// all segment characters matched
|
|
484
|
+
// a: ...vvvvvvv
|
|
485
|
+
// b: vvvvvvv
|
|
486
|
+
if ( br === bL ) {
|
|
487
|
+
inext = buf32[icell+CELL_AND];
|
|
488
|
+
// needle remainder: no
|
|
489
|
+
// a: vvvvvvv
|
|
490
|
+
// b: vvvvvvv
|
|
491
|
+
// r: 0 & vvvvvvv
|
|
492
|
+
if ( ar === 0 ) {
|
|
493
|
+
// boundary cell already present
|
|
494
|
+
if ( buf32[inext+BCELL_EXTRA] <= BCELL_EXTRA_MAX ) {
|
|
495
|
+
return inext;
|
|
496
|
+
}
|
|
497
|
+
// need boundary cell
|
|
498
|
+
iboundary = this.allocateCell();
|
|
499
|
+
buf32[iboundary+CELL_AND] = inext;
|
|
500
|
+
buf32[icell+CELL_AND] = iboundary;
|
|
501
|
+
return iboundary;
|
|
502
|
+
}
|
|
503
|
+
// needle remainder: yes
|
|
504
|
+
// a: yyyyyyyvvvvvvv
|
|
505
|
+
// b: vvvvvvv
|
|
506
|
+
else {
|
|
507
|
+
if ( inext !== 0 ) {
|
|
508
|
+
icell = inext;
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
// TODO: we should never reach here because there will
|
|
512
|
+
// always be a boundary cell.
|
|
513
|
+
// eslint-disable-next-line no-debugger
|
|
514
|
+
debugger; // jshint ignore:line
|
|
515
|
+
// boundary cell + needle remainder
|
|
516
|
+
inext = this.addCell(0, 0, 0);
|
|
517
|
+
buf32[icell+CELL_AND] = inext;
|
|
518
|
+
buf32[inext+CELL_AND] =
|
|
519
|
+
this.addCell(0, 0, toSegmentInfo(aL0, 0, ar));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
// some segment characters matched
|
|
523
|
+
// a: ...vvvvvvv
|
|
524
|
+
// b: yyyyyyyvvvvvvv
|
|
525
|
+
else {
|
|
526
|
+
// split current cell
|
|
527
|
+
buf32[icell+SEGMENT_INFO] = (bR - br) << 24 | (br - char0);
|
|
528
|
+
inext = this.addCell(
|
|
529
|
+
buf32[icell+CELL_AND],
|
|
530
|
+
0,
|
|
531
|
+
(br - bL) << 24 | (bL - char0)
|
|
532
|
+
);
|
|
533
|
+
// needle remainder: no = need boundary cell
|
|
534
|
+
// a: vvvvvvv
|
|
535
|
+
// b: yyyyyyyvvvvvvv
|
|
536
|
+
// r: yyyyyyy & 0 & vvvvvvv
|
|
537
|
+
if ( ar === 0 ) {
|
|
538
|
+
iboundary = this.allocateCell();
|
|
539
|
+
buf32[icell+CELL_AND] = iboundary;
|
|
540
|
+
buf32[iboundary+CELL_AND] = inext;
|
|
541
|
+
return iboundary;
|
|
542
|
+
}
|
|
543
|
+
// needle remainder: yes = need new cell for remaining
|
|
544
|
+
// characters
|
|
545
|
+
// a: wwwwvvvvvvv
|
|
546
|
+
// b: yyyyyyyvvvvvvv
|
|
547
|
+
// r: (0 & wwww | yyyyyyy) & vvvvvvv
|
|
548
|
+
else {
|
|
549
|
+
buf32[icell+CELL_AND] = inext;
|
|
550
|
+
iboundary = this.allocateCell();
|
|
551
|
+
buf32[inext+CELL_OR] = this.addCell(
|
|
552
|
+
iboundary, 0, toSegmentInfo(aL0, 0, ar)
|
|
553
|
+
);
|
|
554
|
+
return iboundary;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
//debugger; // jshint ignore:line
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
getExtra(iboundary) {
|
|
562
|
+
return this.buf32[iboundary+BCELL_EXTRA];
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
setExtra(iboundary, v) {
|
|
566
|
+
this.buf32[iboundary+BCELL_EXTRA] = v;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
optimize(shrink = false) {
|
|
570
|
+
if ( shrink ) {
|
|
571
|
+
this.shrinkBuf();
|
|
572
|
+
}
|
|
573
|
+
return {
|
|
574
|
+
byteLength: this.buf8.byteLength,
|
|
575
|
+
char0: this.buf32[CHAR0_SLOT],
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
serialize(encoder) {
|
|
580
|
+
if ( encoder instanceof Object ) {
|
|
581
|
+
return encoder.encode(
|
|
582
|
+
this.buf32.buffer,
|
|
583
|
+
this.buf32[CHAR1_SLOT]
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
return Array.from(
|
|
587
|
+
new Uint32Array(
|
|
588
|
+
this.buf32.buffer,
|
|
589
|
+
0,
|
|
590
|
+
this.buf32[CHAR1_SLOT] + 3 >>> 2
|
|
591
|
+
)
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
unserialize(selfie, decoder) {
|
|
596
|
+
const shouldDecode = typeof selfie === 'string';
|
|
597
|
+
let byteLength = shouldDecode
|
|
598
|
+
? decoder.decodeSize(selfie)
|
|
599
|
+
: selfie.length << 2;
|
|
600
|
+
if ( byteLength === 0 ) { return false; }
|
|
601
|
+
this.reallocateBuf(byteLength);
|
|
602
|
+
if ( shouldDecode ) {
|
|
603
|
+
decoder.decode(selfie, this.buf8.buffer);
|
|
604
|
+
} else {
|
|
605
|
+
this.buf32.set(selfie);
|
|
606
|
+
}
|
|
607
|
+
return true;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
storeString(s) {
|
|
611
|
+
const n = s.length;
|
|
612
|
+
if ( n === this.lastStoredLen && s === this.lastStored ) {
|
|
613
|
+
return this.lastStoredIndex;
|
|
614
|
+
}
|
|
615
|
+
this.lastStored = s;
|
|
616
|
+
this.lastStoredLen = n;
|
|
617
|
+
if ( (this.buf8.length - this.buf32[CHAR1_SLOT]) < n ) {
|
|
618
|
+
this.growBuf(0, n);
|
|
619
|
+
}
|
|
620
|
+
const offset = this.buf32[CHAR1_SLOT];
|
|
621
|
+
this.buf32[CHAR1_SLOT] = offset + n;
|
|
622
|
+
const buf8 = this.buf8;
|
|
623
|
+
for ( let i = 0; i < n; i++ ) {
|
|
624
|
+
buf8[offset+i] = s.charCodeAt(i);
|
|
625
|
+
}
|
|
626
|
+
return (this.lastStoredIndex = offset - this.buf32[CHAR0_SLOT]);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
extractString(i, n) {
|
|
630
|
+
if ( this.textDecoder === null ) {
|
|
631
|
+
this.textDecoder = new TextDecoder();
|
|
632
|
+
}
|
|
633
|
+
const offset = this.buf32[CHAR0_SLOT] + i;
|
|
634
|
+
return this.textDecoder.decode(
|
|
635
|
+
this.buf8.subarray(offset, offset + n)
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// WASMable.
|
|
640
|
+
startsWith(haystackLeft, haystackRight, needleLeft, needleLen) {
|
|
641
|
+
if ( haystackLeft < 0 || (haystackLeft + needleLen) > haystackRight ) {
|
|
642
|
+
return 0;
|
|
643
|
+
}
|
|
644
|
+
const charCodes = this.buf8;
|
|
645
|
+
needleLeft += this.buf32[CHAR0_SLOT];
|
|
646
|
+
const needleRight = needleLeft + needleLen;
|
|
647
|
+
while ( charCodes[haystackLeft] === charCodes[needleLeft] ) {
|
|
648
|
+
needleLeft += 1;
|
|
649
|
+
if ( needleLeft === needleRight ) { return 1; }
|
|
650
|
+
haystackLeft += 1;
|
|
651
|
+
}
|
|
652
|
+
return 0;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// Find the left-most instance of substring in main string
|
|
656
|
+
// WASMable.
|
|
657
|
+
indexOf(haystackLeft, haystackEnd, needleLeft, needleLen) {
|
|
658
|
+
if ( needleLen === 0 ) { return haystackLeft; }
|
|
659
|
+
haystackEnd -= needleLen;
|
|
660
|
+
if ( haystackEnd < haystackLeft ) { return -1; }
|
|
661
|
+
needleLeft += this.buf32[CHAR0_SLOT];
|
|
662
|
+
const needleRight = needleLeft + needleLen;
|
|
663
|
+
const charCodes = this.buf8;
|
|
664
|
+
for (;;) {
|
|
665
|
+
let i = haystackLeft;
|
|
666
|
+
let j = needleLeft;
|
|
667
|
+
while ( charCodes[i] === charCodes[j] ) {
|
|
668
|
+
j += 1;
|
|
669
|
+
if ( j === needleRight ) { return haystackLeft; }
|
|
670
|
+
i += 1;
|
|
671
|
+
}
|
|
672
|
+
haystackLeft += 1;
|
|
673
|
+
if ( haystackLeft > haystackEnd ) { break; }
|
|
674
|
+
}
|
|
675
|
+
return -1;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// Find the right-most instance of substring in main string.
|
|
679
|
+
// WASMable.
|
|
680
|
+
lastIndexOf(haystackBeg, haystackEnd, needleLeft, needleLen) {
|
|
681
|
+
if ( needleLen === 0 ) { return haystackBeg; }
|
|
682
|
+
let haystackLeft = haystackEnd - needleLen;
|
|
683
|
+
if ( haystackLeft < haystackBeg ) { return -1; }
|
|
684
|
+
needleLeft += this.buf32[CHAR0_SLOT];
|
|
685
|
+
const needleRight = needleLeft + needleLen;
|
|
686
|
+
const charCodes = this.buf8;
|
|
687
|
+
for (;;) {
|
|
688
|
+
let i = haystackLeft;
|
|
689
|
+
let j = needleLeft;
|
|
690
|
+
while ( charCodes[i] === charCodes[j] ) {
|
|
691
|
+
j += 1;
|
|
692
|
+
if ( j === needleRight ) { return haystackLeft; }
|
|
693
|
+
i += 1;
|
|
694
|
+
}
|
|
695
|
+
if ( haystackLeft === haystackBeg ) { break; }
|
|
696
|
+
haystackLeft -= 1;
|
|
697
|
+
}
|
|
698
|
+
return -1;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
dumpTrie(iroot) {
|
|
702
|
+
for ( const s of this.trieIterator(iroot) ) {
|
|
703
|
+
console.log(s);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
trieIterator(iroot) {
|
|
708
|
+
return {
|
|
709
|
+
value: undefined,
|
|
710
|
+
done: false,
|
|
711
|
+
next() {
|
|
712
|
+
if ( this.icell === 0 ) {
|
|
713
|
+
if ( this.forks.length === 0 ) {
|
|
714
|
+
this.value = undefined;
|
|
715
|
+
this.done = true;
|
|
716
|
+
return this;
|
|
717
|
+
}
|
|
718
|
+
this.pattern = this.forks.pop();
|
|
719
|
+
this.dir = this.forks.pop();
|
|
720
|
+
this.icell = this.forks.pop();
|
|
721
|
+
}
|
|
722
|
+
const buf32 = this.container.buf32;
|
|
723
|
+
const buf8 = this.container.buf8;
|
|
724
|
+
for (;;) {
|
|
725
|
+
const ialt = buf32[this.icell+CELL_OR];
|
|
726
|
+
const v = buf32[this.icell+SEGMENT_INFO];
|
|
727
|
+
const offset = v & 0x00FFFFFF;
|
|
728
|
+
let i0 = buf32[CHAR0_SLOT] + offset;
|
|
729
|
+
const len = v >>> 24;
|
|
730
|
+
for ( let i = 0; i < len; i++ ) {
|
|
731
|
+
this.charBuf[i] = buf8[i0+i];
|
|
732
|
+
}
|
|
733
|
+
if ( len !== 0 && ialt !== 0 ) {
|
|
734
|
+
this.forks.push(ialt, this.dir, this.pattern);
|
|
735
|
+
}
|
|
736
|
+
const inext = buf32[this.icell+CELL_AND];
|
|
737
|
+
if ( len !== 0 ) {
|
|
738
|
+
const s = this.textDecoder.decode(
|
|
739
|
+
new Uint8Array(this.charBuf.buffer, 0, len)
|
|
740
|
+
);
|
|
741
|
+
if ( this.dir > 0 ) {
|
|
742
|
+
this.pattern += s;
|
|
743
|
+
} else if ( this.dir < 0 ) {
|
|
744
|
+
this.pattern = s + this.pattern;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
this.icell = inext;
|
|
748
|
+
if ( len !== 0 ) { continue; }
|
|
749
|
+
// boundary cell
|
|
750
|
+
if ( ialt !== 0 ) {
|
|
751
|
+
if ( inext === 0 ) {
|
|
752
|
+
this.icell = ialt;
|
|
753
|
+
this.dir = -1;
|
|
754
|
+
} else {
|
|
755
|
+
this.forks.push(ialt, -1, this.pattern);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
if ( offset !== 0 ) {
|
|
759
|
+
this.value = { pattern: this.pattern, iextra: offset };
|
|
760
|
+
return this;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
container: this,
|
|
765
|
+
icell: iroot,
|
|
766
|
+
charBuf: new Uint8Array(256),
|
|
767
|
+
pattern: '',
|
|
768
|
+
dir: 1,
|
|
769
|
+
forks: [],
|
|
770
|
+
textDecoder: new TextDecoder(),
|
|
771
|
+
[Symbol.iterator]() { return this; },
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
async enableWASM(wasmModuleFetcher, path) {
|
|
776
|
+
if ( typeof WebAssembly !== 'object' ) { return false; }
|
|
777
|
+
if ( this.wasmMemory instanceof WebAssembly.Memory ) { return true; }
|
|
778
|
+
const module = await getWasmModule(wasmModuleFetcher, path);
|
|
779
|
+
if ( module instanceof WebAssembly.Module === false ) { return false; }
|
|
780
|
+
const memory = new WebAssembly.Memory({
|
|
781
|
+
initial: roundToPageSize(this.buf8.length) >>> 16
|
|
782
|
+
});
|
|
783
|
+
const instance = await WebAssembly.instantiate(module, {
|
|
784
|
+
imports: { memory, extraHandler: this.extraHandler }
|
|
785
|
+
});
|
|
786
|
+
if ( instance instanceof WebAssembly.Instance === false ) {
|
|
787
|
+
return false;
|
|
788
|
+
}
|
|
789
|
+
this.wasmMemory = memory;
|
|
790
|
+
const curPageCount = memory.buffer.byteLength >>> 16;
|
|
791
|
+
const newPageCount = roundToPageSize(this.buf8.byteLength) >>> 16;
|
|
792
|
+
if ( newPageCount > curPageCount ) {
|
|
793
|
+
memory.grow(newPageCount - curPageCount);
|
|
794
|
+
}
|
|
795
|
+
const buf8 = new Uint8Array(memory.buffer);
|
|
796
|
+
buf8.set(this.buf8);
|
|
797
|
+
this.buf8 = buf8;
|
|
798
|
+
this.buf32 = new Uint32Array(this.buf8.buffer);
|
|
799
|
+
this.haystack = this.buf8.subarray(
|
|
800
|
+
HAYSTACK_START,
|
|
801
|
+
HAYSTACK_START + HAYSTACK_SIZE
|
|
802
|
+
);
|
|
803
|
+
this.matches = instance.exports.matches;
|
|
804
|
+
this.startsWith = instance.exports.startsWith;
|
|
805
|
+
this.indexOf = instance.exports.indexOf;
|
|
806
|
+
this.lastIndexOf = instance.exports.lastIndexOf;
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
dumpInfo() {
|
|
811
|
+
return [
|
|
812
|
+
`Buffer size (Uint8Array): ${this.buf32[CHAR1_SLOT].toLocaleString('en')}`,
|
|
813
|
+
`WASM: ${this.wasmMemory === null ? 'disabled' : 'enabled'}`,
|
|
814
|
+
].join('\n');
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
//--------------------------------------------------------------------------
|
|
818
|
+
// Private methods
|
|
819
|
+
//--------------------------------------------------------------------------
|
|
820
|
+
|
|
821
|
+
allocateCell() {
|
|
822
|
+
let icell = this.buf32[TRIE1_SLOT];
|
|
823
|
+
this.buf32[TRIE1_SLOT] = icell + CELL_BYTE_LENGTH;
|
|
824
|
+
icell >>>= 2;
|
|
825
|
+
this.buf32[icell+0] = 0;
|
|
826
|
+
this.buf32[icell+1] = 0;
|
|
827
|
+
this.buf32[icell+2] = 0;
|
|
828
|
+
return icell;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
addCell(iand, ior, v) {
|
|
832
|
+
const icell = this.allocateCell();
|
|
833
|
+
this.buf32[icell+CELL_AND] = iand;
|
|
834
|
+
this.buf32[icell+CELL_OR] = ior;
|
|
835
|
+
this.buf32[icell+SEGMENT_INFO] = v;
|
|
836
|
+
return icell;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
growBuf(trieGrow, charGrow) {
|
|
840
|
+
const char0 = Math.max(
|
|
841
|
+
roundToPageSize(this.buf32[TRIE1_SLOT] + trieGrow),
|
|
842
|
+
this.buf32[CHAR0_SLOT]
|
|
843
|
+
);
|
|
844
|
+
const char1 = char0 + this.buf32[CHAR1_SLOT] - this.buf32[CHAR0_SLOT];
|
|
845
|
+
const bufLen = Math.max(
|
|
846
|
+
roundToPageSize(char1 + charGrow),
|
|
847
|
+
this.buf8.length
|
|
848
|
+
);
|
|
849
|
+
if ( bufLen > this.buf8.length ) {
|
|
850
|
+
this.reallocateBuf(bufLen);
|
|
851
|
+
}
|
|
852
|
+
if ( char0 !== this.buf32[CHAR0_SLOT] ) {
|
|
853
|
+
this.buf8.copyWithin(
|
|
854
|
+
char0,
|
|
855
|
+
this.buf32[CHAR0_SLOT],
|
|
856
|
+
this.buf32[CHAR1_SLOT]
|
|
857
|
+
);
|
|
858
|
+
this.buf32[CHAR0_SLOT] = char0;
|
|
859
|
+
this.buf32[CHAR1_SLOT] = char1;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
shrinkBuf() {
|
|
864
|
+
const char0 = this.buf32[TRIE1_SLOT] + MIN_FREE_CELL_BYTE_LENGTH;
|
|
865
|
+
const char1 = char0 + this.buf32[CHAR1_SLOT] - this.buf32[CHAR0_SLOT];
|
|
866
|
+
const bufLen = char1 + 256;
|
|
867
|
+
if ( char0 !== this.buf32[CHAR0_SLOT] ) {
|
|
868
|
+
this.buf8.copyWithin(
|
|
869
|
+
char0,
|
|
870
|
+
this.buf32[CHAR0_SLOT],
|
|
871
|
+
this.buf32[CHAR1_SLOT]
|
|
872
|
+
);
|
|
873
|
+
this.buf32[CHAR0_SLOT] = char0;
|
|
874
|
+
this.buf32[CHAR1_SLOT] = char1;
|
|
875
|
+
}
|
|
876
|
+
if ( bufLen < this.buf8.length ) {
|
|
877
|
+
this.reallocateBuf(bufLen);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
reallocateBuf(newSize) {
|
|
882
|
+
newSize = roundToPageSize(newSize);
|
|
883
|
+
if ( newSize === this.buf8.length ) { return; }
|
|
884
|
+
if ( this.wasmMemory === null ) {
|
|
885
|
+
const newBuf = new Uint8Array(newSize);
|
|
886
|
+
newBuf.set(
|
|
887
|
+
newBuf.length < this.buf8.length
|
|
888
|
+
? this.buf8.subarray(0, newBuf.length)
|
|
889
|
+
: this.buf8
|
|
890
|
+
);
|
|
891
|
+
this.buf8 = newBuf;
|
|
892
|
+
} else {
|
|
893
|
+
const growBy =
|
|
894
|
+
((newSize + 0xFFFF) >>> 16) - (this.buf8.length >>> 16);
|
|
895
|
+
if ( growBy <= 0 ) { return; }
|
|
896
|
+
this.wasmMemory.grow(growBy);
|
|
897
|
+
this.buf8 = new Uint8Array(this.wasmMemory.buffer);
|
|
898
|
+
}
|
|
899
|
+
this.buf32 = new Uint32Array(this.buf8.buffer);
|
|
900
|
+
this.haystack = this.buf8.subarray(
|
|
901
|
+
HAYSTACK_START,
|
|
902
|
+
HAYSTACK_START + HAYSTACK_SIZE
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/******************************************************************************/
|
|
908
|
+
|
|
909
|
+
// Code below is to attempt to load a WASM module which implements:
|
|
910
|
+
//
|
|
911
|
+
// - BidiTrieContainer.startsWith()
|
|
912
|
+
//
|
|
913
|
+
// The WASM module is entirely optional, the JS implementations will be
|
|
914
|
+
// used should the WASM module be unavailable for whatever reason.
|
|
915
|
+
|
|
916
|
+
const getWasmModule = (( ) => {
|
|
917
|
+
let wasmModulePromise;
|
|
918
|
+
|
|
919
|
+
return async function(wasmModuleFetcher, path) {
|
|
920
|
+
if ( wasmModulePromise instanceof Promise ) {
|
|
921
|
+
return wasmModulePromise;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
if ( typeof WebAssembly !== 'object' ) { return; }
|
|
925
|
+
|
|
926
|
+
// Soft-dependency on vAPI so that the code here can be used outside of
|
|
927
|
+
// uBO (i.e. tests, benchmarks)
|
|
928
|
+
if ( typeof vAPI === 'object' && vAPI.canWASM !== true ) { return; }
|
|
929
|
+
|
|
930
|
+
// The wasm module will work only if CPU is natively little-endian,
|
|
931
|
+
// as we use native uint32 array in our js code.
|
|
932
|
+
const uint32s = new Uint32Array(1);
|
|
933
|
+
const uint8s = new Uint8Array(uint32s.buffer);
|
|
934
|
+
uint32s[0] = 1;
|
|
935
|
+
if ( uint8s[0] !== 1 ) { return; }
|
|
936
|
+
|
|
937
|
+
wasmModulePromise = wasmModuleFetcher(`${path}biditrie`).catch(reason => {
|
|
938
|
+
console.info(reason);
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
return wasmModulePromise;
|
|
942
|
+
};
|
|
943
|
+
})();
|
|
944
|
+
|
|
945
|
+
/******************************************************************************/
|
|
946
|
+
|
|
947
|
+
export default BidiTrieContainer;
|