@limetech/kompendium 1.1.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/LICENSE +21 -0
- package/README.md +313 -0
- package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +13 -0
- package/dist/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
- package/dist/cjs/anchor-scroll-BmplAyR0.js +69 -0
- package/dist/cjs/anchor-scroll-BmplAyR0.js.map +1 -0
- package/dist/cjs/index-DYiJ6dQL.js +1866 -0
- package/dist/cjs/index-DYiJ6dQL.js.map +1 -0
- package/dist/cjs/index.cjs.js +3 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/kompendium-app.kompendium-darkmode-switch.kompendium-navigation.kompendium-search.stencil-route.stencil-route-switch.stencil-router.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-app_7.cjs.entry.js +2924 -0
- package/dist/cjs/kompendium-code.cjs.entry.js +2724 -0
- package/dist/cjs/kompendium-code.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-component.cjs.entry.js +207 -0
- package/dist/cjs/kompendium-component.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-debug.cjs.entry.js +47 -0
- package/dist/cjs/kompendium-debug.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-example-code.cjs.entry.js +20 -0
- package/dist/cjs/kompendium-example-code.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-example-markdown.cjs.entry.js +165 -0
- package/dist/cjs/kompendium-example-markdown.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-guide.cjs.entry.js +33 -0
- package/dist/cjs/kompendium-guide.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-markdown.cjs.entry.js +48923 -0
- package/dist/cjs/kompendium-markdown.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-playground.cjs.entry.js +89 -0
- package/dist/cjs/kompendium-playground.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-proplist.kompendium-taglist.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium-proplist_2.cjs.entry.js +49 -0
- package/dist/cjs/kompendium-type.cjs.entry.js +83 -0
- package/dist/cjs/kompendium-type.entry.cjs.js.map +1 -0
- package/dist/cjs/kompendium.cjs.js +25 -0
- package/dist/cjs/kompendium.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/markdown-types-B884tLd-.js +15 -0
- package/dist/cjs/markdown-types-B884tLd-.js.map +1 -0
- package/dist/cjs/methods-DoA78dOH.js +97 -0
- package/dist/cjs/methods-DoA78dOH.js.map +1 -0
- package/dist/cjs/types-SjA7Kcy_.js +8 -0
- package/dist/cjs/types-SjA7Kcy_.js.map +1 -0
- package/dist/collection/assets/favicon.svg +65 -0
- package/dist/collection/assets/icons/bookmark-fill.svg +1 -0
- package/dist/collection/assets/icons/danger.svg +1 -0
- package/dist/collection/assets/icons/debug.svg +1 -0
- package/dist/collection/assets/icons/important.svg +1 -0
- package/dist/collection/assets/icons/info.svg +1 -0
- package/dist/collection/assets/icons/logo.svg +1 -0
- package/dist/collection/assets/icons/note.svg +1 -0
- package/dist/collection/assets/icons/search.svg +1 -0
- package/dist/collection/assets/icons/tip.svg +1 -0
- package/dist/collection/assets/icons/warning.svg +1 -0
- package/dist/collection/assets/logotype.svg +64 -0
- package/dist/collection/collection-manifest.json +35 -0
- package/dist/collection/components/anchor-scroll.js +61 -0
- package/dist/collection/components/anchor-scroll.js.map +1 -0
- package/dist/collection/components/app/app.css +125 -0
- package/dist/collection/components/app/app.js +149 -0
- package/dist/collection/components/app/app.js.map +1 -0
- package/dist/collection/components/code/code.css +250 -0
- package/dist/collection/components/code/code.js +82 -0
- package/dist/collection/components/code/code.js.map +1 -0
- package/dist/collection/components/code/examples/code.js +14 -0
- package/dist/collection/components/code/examples/code.js.map +1 -0
- package/dist/collection/components/component/component.css +383 -0
- package/dist/collection/components/component/component.js +191 -0
- package/dist/collection/components/component/component.js.map +1 -0
- package/dist/collection/components/component/templates/events.js +32 -0
- package/dist/collection/components/component/templates/events.js.map +1 -0
- package/dist/collection/components/component/templates/examples.js +17 -0
- package/dist/collection/components/component/templates/examples.js.map +1 -0
- package/dist/collection/components/component/templates/methods.js +54 -0
- package/dist/collection/components/component/templates/methods.js.map +1 -0
- package/dist/collection/components/component/templates/props.js +36 -0
- package/dist/collection/components/component/templates/props.js.map +1 -0
- package/dist/collection/components/component/templates/slots.js +14 -0
- package/dist/collection/components/component/templates/slots.js.map +1 -0
- package/dist/collection/components/component/templates/style.js +14 -0
- package/dist/collection/components/component/templates/style.js.map +1 -0
- package/dist/collection/components/darkmode-switch/darkmode-switch.css +141 -0
- package/dist/collection/components/darkmode-switch/darkmode-switch.js +90 -0
- package/dist/collection/components/darkmode-switch/darkmode-switch.js.map +1 -0
- package/dist/collection/components/darkmode-switch/types.js +2 -0
- package/dist/collection/components/darkmode-switch/types.js.map +1 -0
- package/dist/collection/components/debug/debug.js +146 -0
- package/dist/collection/components/debug/debug.js.map +1 -0
- package/dist/collection/components/guide/guide.js +61 -0
- package/dist/collection/components/guide/guide.js.map +1 -0
- package/dist/collection/components/markdown/examples/markdown-example.js +150 -0
- package/dist/collection/components/markdown/examples/markdown-example.js.map +1 -0
- package/dist/collection/components/markdown/examples/markdown.js +14 -0
- package/dist/collection/components/markdown/examples/markdown.js.map +1 -0
- package/dist/collection/components/markdown/markdown-types.js +8 -0
- package/dist/collection/components/markdown/markdown-types.js.map +1 -0
- package/dist/collection/components/markdown/markdown.css +660 -0
- package/dist/collection/components/markdown/markdown.js +83 -0
- package/dist/collection/components/markdown/markdown.js.map +1 -0
- package/dist/collection/components/navigation/navigation.css +403 -0
- package/dist/collection/components/navigation/navigation.js +184 -0
- package/dist/collection/components/navigation/navigation.js.map +1 -0
- package/dist/collection/components/playground/playground.css +198 -0
- package/dist/collection/components/playground/playground.js +174 -0
- package/dist/collection/components/playground/playground.js.map +1 -0
- package/dist/collection/components/playground/playground.types.js +2 -0
- package/dist/collection/components/playground/playground.types.js.map +1 -0
- package/dist/collection/components/proplist/proplist.css +334 -0
- package/dist/collection/components/proplist/proplist.js +53 -0
- package/dist/collection/components/proplist/proplist.js.map +1 -0
- package/dist/collection/components/search/search.css +183 -0
- package/dist/collection/components/search/search.js +76 -0
- package/dist/collection/components/search/search.js.map +1 -0
- package/dist/collection/components/taglist/taglist.css +58 -0
- package/dist/collection/components/taglist/taglist.js +82 -0
- package/dist/collection/components/taglist/taglist.js.map +1 -0
- package/dist/collection/components/type/templates/alias.js +11 -0
- package/dist/collection/components/type/templates/alias.js.map +1 -0
- package/dist/collection/components/type/templates/enum.js +25 -0
- package/dist/collection/components/type/templates/enum.js.map +1 -0
- package/dist/collection/components/type/templates/interface.js +13 -0
- package/dist/collection/components/type/templates/interface.js.map +1 -0
- package/dist/collection/components/type/type.js +97 -0
- package/dist/collection/components/type/type.js.map +1 -0
- package/dist/collection/index.js +4 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/kompendium/config.js +7 -0
- package/dist/collection/kompendium/config.js.map +1 -0
- package/dist/collection/kompendium/filesystem.js +9 -0
- package/dist/collection/kompendium/filesystem.js.map +1 -0
- package/dist/collection/kompendium/generator.js +217 -0
- package/dist/collection/kompendium/generator.js.map +1 -0
- package/dist/collection/kompendium/guides.js +30 -0
- package/dist/collection/kompendium/guides.js.map +1 -0
- package/dist/collection/kompendium/index.js +2 -0
- package/dist/collection/kompendium/index.js.map +1 -0
- package/dist/collection/kompendium/markdown-admonitions.js +82 -0
- package/dist/collection/kompendium/markdown-admonitions.js.map +1 -0
- package/dist/collection/kompendium/markdown-code.js +40 -0
- package/dist/collection/kompendium/markdown-code.js.map +1 -0
- package/dist/collection/kompendium/markdown-frontmatter.js +12 -0
- package/dist/collection/kompendium/markdown-frontmatter.js.map +1 -0
- package/dist/collection/kompendium/markdown-nodes.js +10 -0
- package/dist/collection/kompendium/markdown-nodes.js.map +1 -0
- package/dist/collection/kompendium/markdown-typelinks.js +115 -0
- package/dist/collection/kompendium/markdown-typelinks.js.map +1 -0
- package/dist/collection/kompendium/markdown.js +35 -0
- package/dist/collection/kompendium/markdown.js.map +1 -0
- package/dist/collection/kompendium/menu.js +149 -0
- package/dist/collection/kompendium/menu.js.map +1 -0
- package/dist/collection/kompendium/schema.js +167 -0
- package/dist/collection/kompendium/schema.js.map +1 -0
- package/dist/collection/kompendium/search.js +144 -0
- package/dist/collection/kompendium/search.js.map +1 -0
- package/dist/collection/kompendium/source.js +81 -0
- package/dist/collection/kompendium/source.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/basic.js +48 -0
- package/dist/collection/kompendium/test/fixtures/basic.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/example-type.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/example-type.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/node-modules-type.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/node-modules-type.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/private-types.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/private-types.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/stencil-component-types.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/stencil-component-types.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/test-helper-type.js +2 -0
- package/dist/collection/kompendium/test/fixtures/filtering/test-helper-type.js.map +1 -0
- package/dist/collection/kompendium/test/fixtures/filtering/valid-types.js +29 -0
- package/dist/collection/kompendium/test/fixtures/filtering/valid-types.js.map +1 -0
- package/dist/collection/kompendium/typedoc.js +481 -0
- package/dist/collection/kompendium/typedoc.js.map +1 -0
- package/dist/collection/kompendium/watch.js +9 -0
- package/dist/collection/kompendium/watch.js.map +1 -0
- package/dist/collection/types.js +2 -0
- package/dist/collection/types.js.map +1 -0
- package/dist/config.ts +8 -0
- package/dist/esm/_commonjsHelpers-BFTU3MAI.js +10 -0
- package/dist/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
- package/dist/esm/anchor-scroll-BAGXN2n6.js +65 -0
- package/dist/esm/anchor-scroll-BAGXN2n6.js.map +1 -0
- package/dist/esm/index-9UrzenzW.js +1857 -0
- package/dist/esm/index-9UrzenzW.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/kompendium-app.kompendium-darkmode-switch.kompendium-navigation.kompendium-search.stencil-route.stencil-route-switch.stencil-router.entry.js.map +1 -0
- package/dist/esm/kompendium-app_7.entry.js +2916 -0
- package/dist/esm/kompendium-code.entry.js +2722 -0
- package/dist/esm/kompendium-code.entry.js.map +1 -0
- package/dist/esm/kompendium-component.entry.js +205 -0
- package/dist/esm/kompendium-component.entry.js.map +1 -0
- package/dist/esm/kompendium-debug.entry.js +45 -0
- package/dist/esm/kompendium-debug.entry.js.map +1 -0
- package/dist/esm/kompendium-example-code.entry.js +18 -0
- package/dist/esm/kompendium-example-code.entry.js.map +1 -0
- package/dist/esm/kompendium-example-markdown.entry.js +163 -0
- package/dist/esm/kompendium-example-markdown.entry.js.map +1 -0
- package/dist/esm/kompendium-guide.entry.js +31 -0
- package/dist/esm/kompendium-guide.entry.js.map +1 -0
- package/dist/esm/kompendium-markdown.entry.js +48921 -0
- package/dist/esm/kompendium-markdown.entry.js.map +1 -0
- package/dist/esm/kompendium-playground.entry.js +87 -0
- package/dist/esm/kompendium-playground.entry.js.map +1 -0
- package/dist/esm/kompendium-proplist.kompendium-taglist.entry.js.map +1 -0
- package/dist/esm/kompendium-proplist_2.entry.js +46 -0
- package/dist/esm/kompendium-type.entry.js +81 -0
- package/dist/esm/kompendium-type.entry.js.map +1 -0
- package/dist/esm/kompendium.js +21 -0
- package/dist/esm/kompendium.js.map +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/markdown-types-Ajsawr_9.js +12 -0
- package/dist/esm/markdown-types-Ajsawr_9.js.map +1 -0
- package/dist/esm/methods-BAjd6f7g.js +94 -0
- package/dist/esm/methods-BAjd6f7g.js.map +1 -0
- package/dist/esm/types-BIPLEi1G.js +6 -0
- package/dist/esm/types-BIPLEi1G.js.map +1 -0
- package/dist/filesystem.ts +9 -0
- package/dist/generator.ts +302 -0
- package/dist/guides.ts +49 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/index.ts +1 -0
- package/dist/kompendium/index.esm.js +2 -0
- package/dist/kompendium/index.esm.js.map +1 -0
- package/dist/kompendium/kompendium-app.kompendium-darkmode-switch.kompendium-navigation.kompendium-search.stencil-route.stencil-route-switch.stencil-router.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-code.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-component.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-debug.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-example-code.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-example-markdown.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-guide.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-markdown.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-playground.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-proplist.kompendium-taglist.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium-type.entry.esm.js.map +1 -0
- package/dist/kompendium/kompendium.css +47 -0
- package/dist/kompendium/kompendium.esm.js +2 -0
- package/dist/kompendium/kompendium.esm.js.map +1 -0
- package/dist/kompendium/loader.esm.js.map +1 -0
- package/dist/kompendium/p-15e4b2c0.entry.js +2 -0
- package/dist/kompendium/p-15e4b2c0.entry.js.map +1 -0
- package/dist/kompendium/p-1cf0168f.entry.js +2 -0
- package/dist/kompendium/p-1cf0168f.entry.js.map +1 -0
- package/dist/kompendium/p-29c23c89.entry.js +2 -0
- package/dist/kompendium/p-29c23c89.entry.js.map +1 -0
- package/dist/kompendium/p-3981d11f.entry.js +2 -0
- package/dist/kompendium/p-3981d11f.entry.js.map +1 -0
- package/dist/kompendium/p-93f0548d.entry.js +2 -0
- package/dist/kompendium/p-93f0548d.entry.js.map +1 -0
- package/dist/kompendium/p-97b02575.entry.js +2 -0
- package/dist/kompendium/p-97b02575.entry.js.map +1 -0
- package/dist/kompendium/p-9UrzenzW.js +3 -0
- package/dist/kompendium/p-9UrzenzW.js.map +1 -0
- package/dist/kompendium/p-Ajsawr_9.js +2 -0
- package/dist/kompendium/p-Ajsawr_9.js.map +1 -0
- package/dist/kompendium/p-BAGXN2n6.js +2 -0
- package/dist/kompendium/p-BAGXN2n6.js.map +1 -0
- package/dist/kompendium/p-BFTU3MAI.js +2 -0
- package/dist/kompendium/p-BFTU3MAI.js.map +1 -0
- package/dist/kompendium/p-BIPLEi1G.js +2 -0
- package/dist/kompendium/p-BIPLEi1G.js.map +1 -0
- package/dist/kompendium/p-CnQEA7KO.js +2 -0
- package/dist/kompendium/p-CnQEA7KO.js.map +1 -0
- package/dist/kompendium/p-b0f95bd6.entry.js +2 -0
- package/dist/kompendium/p-b0f95bd6.entry.js.map +1 -0
- package/dist/kompendium/p-d9bcc473.entry.js +10 -0
- package/dist/kompendium/p-d9bcc473.entry.js.map +1 -0
- package/dist/kompendium/p-e36f3f1e.entry.js +2 -0
- package/dist/kompendium/p-e36f3f1e.entry.js.map +1 -0
- package/dist/kompendium/p-e52a2f57.entry.js +2 -0
- package/dist/kompendium/p-e52a2f57.entry.js.map +1 -0
- package/dist/kompendium/p-ec5861de.entry.js +2 -0
- package/dist/kompendium/p-ec5861de.entry.js.map +1 -0
- package/dist/markdown-admonitions.ts +112 -0
- package/dist/markdown-code.ts +51 -0
- package/dist/markdown-frontmatter.ts +19 -0
- package/dist/markdown-nodes.ts +23 -0
- package/dist/markdown-typelinks.ts +166 -0
- package/dist/markdown.ts +49 -0
- package/dist/menu.ts +189 -0
- package/dist/schema.ts +233 -0
- package/dist/search.ts +197 -0
- package/dist/source.ts +129 -0
- package/dist/typedoc.ts +665 -0
- package/dist/types/components/anchor-scroll.d.ts +36 -0
- package/dist/types/components/app/app.d.ts +22 -0
- package/dist/types/components/code/code.d.ts +26 -0
- package/dist/types/components/code/examples/code.d.ts +3 -0
- package/dist/types/components/component/component.d.ts +32 -0
- package/dist/types/components/component/templates/events.d.ts +5 -0
- package/dist/types/components/component/templates/examples.d.ts +9 -0
- package/dist/types/components/component/templates/methods.d.ts +5 -0
- package/dist/types/components/component/templates/props.d.ts +5 -0
- package/dist/types/components/component/templates/slots.d.ts +5 -0
- package/dist/types/components/component/templates/style.d.ts +5 -0
- package/dist/types/components/darkmode-switch/darkmode-switch.d.ts +18 -0
- package/dist/types/components/darkmode-switch/types.d.ts +2 -0
- package/dist/types/components/debug/debug.d.ts +24 -0
- package/dist/types/components/guide/guide.d.ts +14 -0
- package/dist/types/components/markdown/examples/markdown-example.d.ts +1 -0
- package/dist/types/components/markdown/examples/markdown.d.ts +7 -0
- package/dist/types/components/markdown/markdown-types.d.ts +2 -0
- package/dist/types/components/markdown/markdown.d.ts +20 -0
- package/dist/types/components/navigation/navigation.d.ts +35 -0
- package/dist/types/components/playground/playground.d.ts +32 -0
- package/dist/types/components/playground/playground.types.d.ts +1 -0
- package/dist/types/components/proplist/proplist.d.ts +12 -0
- package/dist/types/components/search/search.d.ts +15 -0
- package/dist/types/components/taglist/taglist.d.ts +16 -0
- package/dist/types/components/type/templates/alias.d.ts +4 -0
- package/dist/types/components/type/templates/enum.d.ts +4 -0
- package/dist/types/components/type/templates/interface.d.ts +4 -0
- package/dist/types/components/type/type.d.ts +15 -0
- package/dist/types/components.d.ts +517 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/kompendium/config.d.ts +2 -0
- package/dist/types/kompendium/filesystem.d.ts +1 -0
- package/dist/types/kompendium/generator.d.ts +4 -0
- package/dist/types/kompendium/guides.d.ts +9 -0
- package/dist/types/kompendium/index.d.ts +1 -0
- package/dist/types/kompendium/markdown-admonitions.d.ts +3 -0
- package/dist/types/kompendium/markdown-code.d.ts +2 -0
- package/dist/types/kompendium/markdown-frontmatter.d.ts +6 -0
- package/dist/types/kompendium/markdown-nodes.d.ts +12 -0
- package/dist/types/kompendium/markdown-typelinks.d.ts +21 -0
- package/dist/types/kompendium/markdown.d.ts +8 -0
- package/dist/types/kompendium/menu.d.ts +12 -0
- package/dist/types/kompendium/schema.d.ts +9 -0
- package/dist/types/kompendium/search.d.ts +3 -0
- package/dist/types/kompendium/source.d.ts +10 -0
- package/dist/types/kompendium/test/fixtures/basic.d.ts +65 -0
- package/dist/types/kompendium/test/fixtures/filtering/example-type.d.ts +8 -0
- package/dist/types/kompendium/test/fixtures/filtering/node-modules-type.d.ts +8 -0
- package/dist/types/kompendium/test/fixtures/filtering/private-types.d.ts +23 -0
- package/dist/types/kompendium/test/fixtures/filtering/stencil-component-types.d.ts +19 -0
- package/dist/types/kompendium/test/fixtures/filtering/test-helper-type.d.ts +8 -0
- package/dist/types/kompendium/test/fixtures/filtering/valid-types.d.ts +42 -0
- package/dist/types/kompendium/typedoc.d.ts +2 -0
- package/dist/types/kompendium/watch.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1746 -0
- package/dist/types/types.d.ts +119 -0
- package/dist/watch.ts +14 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +116 -0
|
@@ -0,0 +1,2924 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DYiJ6dQL.js');
|
|
4
|
+
var markdownTypes = require('./markdown-types-B884tLd-.js');
|
|
5
|
+
var types = require('./types-SjA7Kcy_.js');
|
|
6
|
+
var _commonjsHelpers = require('./_commonjsHelpers-BJu3ubxk.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Fuse.js v6.4.6 - Lightweight fuzzy-search (http://fusejs.io)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2021 Kiro Risk (http://kiro.me)
|
|
12
|
+
* All Rights Reserved. Apache Software License 2.0
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
function isArray(value) {
|
|
18
|
+
return !Array.isArray
|
|
19
|
+
? getTag(value) === '[object Array]'
|
|
20
|
+
: Array.isArray(value)
|
|
21
|
+
}
|
|
22
|
+
function baseToString(value) {
|
|
23
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
24
|
+
if (typeof value == 'string') {
|
|
25
|
+
return value
|
|
26
|
+
}
|
|
27
|
+
let result = value + '';
|
|
28
|
+
return result == '0' && 1 / value == -Infinity ? '-0' : result
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function toString(value) {
|
|
32
|
+
return value == null ? '' : baseToString(value)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isString(value) {
|
|
36
|
+
return typeof value === 'string'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isNumber(value) {
|
|
40
|
+
return typeof value === 'number'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
|
|
44
|
+
function isBoolean(value) {
|
|
45
|
+
return (
|
|
46
|
+
value === true ||
|
|
47
|
+
value === false ||
|
|
48
|
+
(isObjectLike(value) && getTag(value) == '[object Boolean]')
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function isObject(value) {
|
|
53
|
+
return typeof value === 'object'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Checks if `value` is object-like.
|
|
57
|
+
function isObjectLike(value) {
|
|
58
|
+
return isObject(value) && value !== null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isDefined(value) {
|
|
62
|
+
return value !== undefined && value !== null
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isBlank(value) {
|
|
66
|
+
return !value.trim().length
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Gets the `toStringTag` of `value`.
|
|
70
|
+
// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
|
|
71
|
+
function getTag(value) {
|
|
72
|
+
return value == null
|
|
73
|
+
? value === undefined
|
|
74
|
+
? '[object Undefined]'
|
|
75
|
+
: '[object Null]'
|
|
76
|
+
: Object.prototype.toString.call(value)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
|
|
80
|
+
|
|
81
|
+
const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) =>
|
|
82
|
+
`Invalid value for key ${key}`;
|
|
83
|
+
|
|
84
|
+
const PATTERN_LENGTH_TOO_LARGE = (max) =>
|
|
85
|
+
`Pattern length exceeds max of ${max}.`;
|
|
86
|
+
|
|
87
|
+
const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
|
|
88
|
+
|
|
89
|
+
const INVALID_KEY_WEIGHT_VALUE = (key) =>
|
|
90
|
+
`Property 'weight' in key '${key}' must be a positive integer`;
|
|
91
|
+
|
|
92
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
93
|
+
|
|
94
|
+
class KeyStore {
|
|
95
|
+
constructor(keys) {
|
|
96
|
+
this._keys = [];
|
|
97
|
+
this._keyMap = {};
|
|
98
|
+
|
|
99
|
+
let totalWeight = 0;
|
|
100
|
+
|
|
101
|
+
keys.forEach((key) => {
|
|
102
|
+
let obj = createKey(key);
|
|
103
|
+
|
|
104
|
+
totalWeight += obj.weight;
|
|
105
|
+
|
|
106
|
+
this._keys.push(obj);
|
|
107
|
+
this._keyMap[obj.id] = obj;
|
|
108
|
+
|
|
109
|
+
totalWeight += obj.weight;
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Normalize weights so that their sum is equal to 1
|
|
113
|
+
this._keys.forEach((key) => {
|
|
114
|
+
key.weight /= totalWeight;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
get(keyId) {
|
|
118
|
+
return this._keyMap[keyId]
|
|
119
|
+
}
|
|
120
|
+
keys() {
|
|
121
|
+
return this._keys
|
|
122
|
+
}
|
|
123
|
+
toJSON() {
|
|
124
|
+
return JSON.stringify(this._keys)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function createKey(key) {
|
|
129
|
+
let path = null;
|
|
130
|
+
let id = null;
|
|
131
|
+
let src = null;
|
|
132
|
+
let weight = 1;
|
|
133
|
+
|
|
134
|
+
if (isString(key) || isArray(key)) {
|
|
135
|
+
src = key;
|
|
136
|
+
path = createKeyPath(key);
|
|
137
|
+
id = createKeyId(key);
|
|
138
|
+
} else {
|
|
139
|
+
if (!hasOwn.call(key, 'name')) {
|
|
140
|
+
throw new Error(MISSING_KEY_PROPERTY('name'))
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const name = key.name;
|
|
144
|
+
src = name;
|
|
145
|
+
|
|
146
|
+
if (hasOwn.call(key, 'weight')) {
|
|
147
|
+
weight = key.weight;
|
|
148
|
+
|
|
149
|
+
if (weight <= 0) {
|
|
150
|
+
throw new Error(INVALID_KEY_WEIGHT_VALUE(name))
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
path = createKeyPath(name);
|
|
155
|
+
id = createKeyId(name);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return { path, id, weight, src }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function createKeyPath(key) {
|
|
162
|
+
return isArray(key) ? key : key.split('.')
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function createKeyId(key) {
|
|
166
|
+
return isArray(key) ? key.join('.') : key
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function get(obj, path) {
|
|
170
|
+
let list = [];
|
|
171
|
+
let arr = false;
|
|
172
|
+
|
|
173
|
+
const deepGet = (obj, path, index) => {
|
|
174
|
+
if (!isDefined(obj)) {
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
if (!path[index]) {
|
|
178
|
+
// If there's no path left, we've arrived at the object we care about.
|
|
179
|
+
list.push(obj);
|
|
180
|
+
} else {
|
|
181
|
+
let key = path[index];
|
|
182
|
+
|
|
183
|
+
const value = obj[key];
|
|
184
|
+
|
|
185
|
+
if (!isDefined(value)) {
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// If we're at the last value in the path, and if it's a string/number/bool,
|
|
190
|
+
// add it to the list
|
|
191
|
+
if (
|
|
192
|
+
index === path.length - 1 &&
|
|
193
|
+
(isString(value) || isNumber(value) || isBoolean(value))
|
|
194
|
+
) {
|
|
195
|
+
list.push(toString(value));
|
|
196
|
+
} else if (isArray(value)) {
|
|
197
|
+
arr = true;
|
|
198
|
+
// Search each item in the array.
|
|
199
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
200
|
+
deepGet(value[i], path, index + 1);
|
|
201
|
+
}
|
|
202
|
+
} else if (path.length) {
|
|
203
|
+
// An object. Recurse further.
|
|
204
|
+
deepGet(value, path, index + 1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// Backwards compatibility (since path used to be a string)
|
|
210
|
+
deepGet(obj, isString(path) ? path.split('.') : path, 0);
|
|
211
|
+
|
|
212
|
+
return arr ? list : list[0]
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const MatchOptions = {
|
|
216
|
+
// Whether the matches should be included in the result set. When `true`, each record in the result
|
|
217
|
+
// set will include the indices of the matched characters.
|
|
218
|
+
// These can consequently be used for highlighting purposes.
|
|
219
|
+
includeMatches: false,
|
|
220
|
+
// When `true`, the matching function will continue to the end of a search pattern even if
|
|
221
|
+
// a perfect match has already been located in the string.
|
|
222
|
+
findAllMatches: false,
|
|
223
|
+
// Minimum number of characters that must be matched before a result is considered a match
|
|
224
|
+
minMatchCharLength: 1
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const BasicOptions = {
|
|
228
|
+
// When `true`, the algorithm continues searching to the end of the input even if a perfect
|
|
229
|
+
// match is found before the end of the same input.
|
|
230
|
+
isCaseSensitive: false,
|
|
231
|
+
// When true, the matching function will continue to the end of a search pattern even if
|
|
232
|
+
includeScore: false,
|
|
233
|
+
// List of properties that will be searched. This also supports nested properties.
|
|
234
|
+
keys: [],
|
|
235
|
+
// Whether to sort the result list, by score
|
|
236
|
+
shouldSort: true,
|
|
237
|
+
// Default sort function: sort by ascending score, ascending index
|
|
238
|
+
sortFn: (a, b) =>
|
|
239
|
+
a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const FuzzyOptions = {
|
|
243
|
+
// Approximately where in the text is the pattern expected to be found?
|
|
244
|
+
location: 0,
|
|
245
|
+
// At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
|
|
246
|
+
// (of both letters and location), a threshold of '1.0' would match anything.
|
|
247
|
+
threshold: 0.6,
|
|
248
|
+
// Determines how close the match must be to the fuzzy location (specified above).
|
|
249
|
+
// An exact letter match which is 'distance' characters away from the fuzzy location
|
|
250
|
+
// would score as a complete mismatch. A distance of '0' requires the match be at
|
|
251
|
+
// the exact location specified, a threshold of '1000' would require a perfect match
|
|
252
|
+
// to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
|
|
253
|
+
distance: 100
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const AdvancedOptions = {
|
|
257
|
+
// When `true`, it enables the use of unix-like search commands
|
|
258
|
+
useExtendedSearch: false,
|
|
259
|
+
// The get function to use when fetching an object's properties.
|
|
260
|
+
// The default will search nested paths *ie foo.bar.baz*
|
|
261
|
+
getFn: get,
|
|
262
|
+
// When `true`, search will ignore `location` and `distance`, so it won't matter
|
|
263
|
+
// where in the string the pattern appears.
|
|
264
|
+
// More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
|
|
265
|
+
ignoreLocation: false,
|
|
266
|
+
// When `true`, the calculation for the relevance score (used for sorting) will
|
|
267
|
+
// ignore the field-length norm.
|
|
268
|
+
// More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
|
|
269
|
+
ignoreFieldNorm: false
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
var Config = {
|
|
273
|
+
...BasicOptions,
|
|
274
|
+
...MatchOptions,
|
|
275
|
+
...FuzzyOptions,
|
|
276
|
+
...AdvancedOptions
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const SPACE = /[^ ]+/g;
|
|
280
|
+
|
|
281
|
+
// Field-length norm: the shorter the field, the higher the weight.
|
|
282
|
+
// Set to 3 decimals to reduce index size.
|
|
283
|
+
function norm(mantissa = 3) {
|
|
284
|
+
const cache = new Map();
|
|
285
|
+
const m = Math.pow(10, mantissa);
|
|
286
|
+
|
|
287
|
+
return {
|
|
288
|
+
get(value) {
|
|
289
|
+
const numTokens = value.match(SPACE).length;
|
|
290
|
+
|
|
291
|
+
if (cache.has(numTokens)) {
|
|
292
|
+
return cache.get(numTokens)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const norm = 1 / Math.sqrt(numTokens);
|
|
296
|
+
|
|
297
|
+
// In place of `toFixed(mantissa)`, for faster computation
|
|
298
|
+
const n = parseFloat(Math.round(norm * m) / m);
|
|
299
|
+
|
|
300
|
+
cache.set(numTokens, n);
|
|
301
|
+
|
|
302
|
+
return n
|
|
303
|
+
},
|
|
304
|
+
clear() {
|
|
305
|
+
cache.clear();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
class FuseIndex {
|
|
311
|
+
constructor({ getFn = Config.getFn } = {}) {
|
|
312
|
+
this.norm = norm(3);
|
|
313
|
+
this.getFn = getFn;
|
|
314
|
+
this.isCreated = false;
|
|
315
|
+
|
|
316
|
+
this.setIndexRecords();
|
|
317
|
+
}
|
|
318
|
+
setSources(docs = []) {
|
|
319
|
+
this.docs = docs;
|
|
320
|
+
}
|
|
321
|
+
setIndexRecords(records = []) {
|
|
322
|
+
this.records = records;
|
|
323
|
+
}
|
|
324
|
+
setKeys(keys = []) {
|
|
325
|
+
this.keys = keys;
|
|
326
|
+
this._keysMap = {};
|
|
327
|
+
keys.forEach((key, idx) => {
|
|
328
|
+
this._keysMap[key.id] = idx;
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
create() {
|
|
332
|
+
if (this.isCreated || !this.docs.length) {
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
this.isCreated = true;
|
|
337
|
+
|
|
338
|
+
// List is Array<String>
|
|
339
|
+
if (isString(this.docs[0])) {
|
|
340
|
+
this.docs.forEach((doc, docIndex) => {
|
|
341
|
+
this._addString(doc, docIndex);
|
|
342
|
+
});
|
|
343
|
+
} else {
|
|
344
|
+
// List is Array<Object>
|
|
345
|
+
this.docs.forEach((doc, docIndex) => {
|
|
346
|
+
this._addObject(doc, docIndex);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
this.norm.clear();
|
|
351
|
+
}
|
|
352
|
+
// Adds a doc to the end of the index
|
|
353
|
+
add(doc) {
|
|
354
|
+
const idx = this.size();
|
|
355
|
+
|
|
356
|
+
if (isString(doc)) {
|
|
357
|
+
this._addString(doc, idx);
|
|
358
|
+
} else {
|
|
359
|
+
this._addObject(doc, idx);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
// Removes the doc at the specified index of the index
|
|
363
|
+
removeAt(idx) {
|
|
364
|
+
this.records.splice(idx, 1);
|
|
365
|
+
|
|
366
|
+
// Change ref index of every subsquent doc
|
|
367
|
+
for (let i = idx, len = this.size(); i < len; i += 1) {
|
|
368
|
+
this.records[i].i -= 1;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
getValueForItemAtKeyId(item, keyId) {
|
|
372
|
+
return item[this._keysMap[keyId]]
|
|
373
|
+
}
|
|
374
|
+
size() {
|
|
375
|
+
return this.records.length
|
|
376
|
+
}
|
|
377
|
+
_addString(doc, docIndex) {
|
|
378
|
+
if (!isDefined(doc) || isBlank(doc)) {
|
|
379
|
+
return
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
let record = {
|
|
383
|
+
v: doc,
|
|
384
|
+
i: docIndex,
|
|
385
|
+
n: this.norm.get(doc)
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
this.records.push(record);
|
|
389
|
+
}
|
|
390
|
+
_addObject(doc, docIndex) {
|
|
391
|
+
let record = { i: docIndex, $: {} };
|
|
392
|
+
|
|
393
|
+
// Iterate over every key (i.e, path), and fetch the value at that key
|
|
394
|
+
this.keys.forEach((key, keyIndex) => {
|
|
395
|
+
// console.log(key)
|
|
396
|
+
let value = this.getFn(doc, key.path);
|
|
397
|
+
|
|
398
|
+
if (!isDefined(value)) {
|
|
399
|
+
return
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (isArray(value)) {
|
|
403
|
+
let subRecords = [];
|
|
404
|
+
const stack = [{ nestedArrIndex: -1, value }];
|
|
405
|
+
|
|
406
|
+
while (stack.length) {
|
|
407
|
+
const { nestedArrIndex, value } = stack.pop();
|
|
408
|
+
|
|
409
|
+
if (!isDefined(value)) {
|
|
410
|
+
continue
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (isString(value) && !isBlank(value)) {
|
|
414
|
+
let subRecord = {
|
|
415
|
+
v: value,
|
|
416
|
+
i: nestedArrIndex,
|
|
417
|
+
n: this.norm.get(value)
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
subRecords.push(subRecord);
|
|
421
|
+
} else if (isArray(value)) {
|
|
422
|
+
value.forEach((item, k) => {
|
|
423
|
+
stack.push({
|
|
424
|
+
nestedArrIndex: k,
|
|
425
|
+
value: item
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
record.$[keyIndex] = subRecords;
|
|
431
|
+
} else if (!isBlank(value)) {
|
|
432
|
+
let subRecord = {
|
|
433
|
+
v: value,
|
|
434
|
+
n: this.norm.get(value)
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
record.$[keyIndex] = subRecord;
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
this.records.push(record);
|
|
442
|
+
}
|
|
443
|
+
toJSON() {
|
|
444
|
+
return {
|
|
445
|
+
keys: this.keys,
|
|
446
|
+
records: this.records
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function createIndex(keys, docs, { getFn = Config.getFn } = {}) {
|
|
452
|
+
const myIndex = new FuseIndex({ getFn });
|
|
453
|
+
myIndex.setKeys(keys.map(createKey));
|
|
454
|
+
myIndex.setSources(docs);
|
|
455
|
+
myIndex.create();
|
|
456
|
+
return myIndex
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function parseIndex(data, { getFn = Config.getFn } = {}) {
|
|
460
|
+
const { keys, records } = data;
|
|
461
|
+
const myIndex = new FuseIndex({ getFn });
|
|
462
|
+
myIndex.setKeys(keys);
|
|
463
|
+
myIndex.setIndexRecords(records);
|
|
464
|
+
return myIndex
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function computeScore(
|
|
468
|
+
pattern,
|
|
469
|
+
{
|
|
470
|
+
errors = 0,
|
|
471
|
+
currentLocation = 0,
|
|
472
|
+
expectedLocation = 0,
|
|
473
|
+
distance = Config.distance,
|
|
474
|
+
ignoreLocation = Config.ignoreLocation
|
|
475
|
+
} = {}
|
|
476
|
+
) {
|
|
477
|
+
const accuracy = errors / pattern.length;
|
|
478
|
+
|
|
479
|
+
if (ignoreLocation) {
|
|
480
|
+
return accuracy
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
const proximity = Math.abs(expectedLocation - currentLocation);
|
|
484
|
+
|
|
485
|
+
if (!distance) {
|
|
486
|
+
// Dodge divide by zero error.
|
|
487
|
+
return proximity ? 1.0 : accuracy
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return accuracy + proximity / distance
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function convertMaskToIndices(
|
|
494
|
+
matchmask = [],
|
|
495
|
+
minMatchCharLength = Config.minMatchCharLength
|
|
496
|
+
) {
|
|
497
|
+
let indices = [];
|
|
498
|
+
let start = -1;
|
|
499
|
+
let end = -1;
|
|
500
|
+
let i = 0;
|
|
501
|
+
|
|
502
|
+
for (let len = matchmask.length; i < len; i += 1) {
|
|
503
|
+
let match = matchmask[i];
|
|
504
|
+
if (match && start === -1) {
|
|
505
|
+
start = i;
|
|
506
|
+
} else if (!match && start !== -1) {
|
|
507
|
+
end = i - 1;
|
|
508
|
+
if (end - start + 1 >= minMatchCharLength) {
|
|
509
|
+
indices.push([start, end]);
|
|
510
|
+
}
|
|
511
|
+
start = -1;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// (i-1 - start) + 1 => i - start
|
|
516
|
+
if (matchmask[i - 1] && i - start >= minMatchCharLength) {
|
|
517
|
+
indices.push([start, i - 1]);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return indices
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Machine word size
|
|
524
|
+
const MAX_BITS = 32;
|
|
525
|
+
|
|
526
|
+
function search(
|
|
527
|
+
text,
|
|
528
|
+
pattern,
|
|
529
|
+
patternAlphabet,
|
|
530
|
+
{
|
|
531
|
+
location = Config.location,
|
|
532
|
+
distance = Config.distance,
|
|
533
|
+
threshold = Config.threshold,
|
|
534
|
+
findAllMatches = Config.findAllMatches,
|
|
535
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
536
|
+
includeMatches = Config.includeMatches,
|
|
537
|
+
ignoreLocation = Config.ignoreLocation
|
|
538
|
+
} = {}
|
|
539
|
+
) {
|
|
540
|
+
if (pattern.length > MAX_BITS) {
|
|
541
|
+
throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS))
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
const patternLen = pattern.length;
|
|
545
|
+
// Set starting location at beginning text and initialize the alphabet.
|
|
546
|
+
const textLen = text.length;
|
|
547
|
+
// Handle the case when location > text.length
|
|
548
|
+
const expectedLocation = Math.max(0, Math.min(location, textLen));
|
|
549
|
+
// Highest score beyond which we give up.
|
|
550
|
+
let currentThreshold = threshold;
|
|
551
|
+
// Is there a nearby exact match? (speedup)
|
|
552
|
+
let bestLocation = expectedLocation;
|
|
553
|
+
|
|
554
|
+
// Performance: only computer matches when the minMatchCharLength > 1
|
|
555
|
+
// OR if `includeMatches` is true.
|
|
556
|
+
const computeMatches = minMatchCharLength > 1 || includeMatches;
|
|
557
|
+
// A mask of the matches, used for building the indices
|
|
558
|
+
const matchMask = computeMatches ? Array(textLen) : [];
|
|
559
|
+
|
|
560
|
+
let index;
|
|
561
|
+
|
|
562
|
+
// Get all exact matches, here for speed up
|
|
563
|
+
while ((index = text.indexOf(pattern, bestLocation)) > -1) {
|
|
564
|
+
let score = computeScore(pattern, {
|
|
565
|
+
currentLocation: index,
|
|
566
|
+
expectedLocation,
|
|
567
|
+
distance,
|
|
568
|
+
ignoreLocation
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
currentThreshold = Math.min(score, currentThreshold);
|
|
572
|
+
bestLocation = index + patternLen;
|
|
573
|
+
|
|
574
|
+
if (computeMatches) {
|
|
575
|
+
let i = 0;
|
|
576
|
+
while (i < patternLen) {
|
|
577
|
+
matchMask[index + i] = 1;
|
|
578
|
+
i += 1;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// Reset the best location
|
|
584
|
+
bestLocation = -1;
|
|
585
|
+
|
|
586
|
+
let lastBitArr = [];
|
|
587
|
+
let finalScore = 1;
|
|
588
|
+
let binMax = patternLen + textLen;
|
|
589
|
+
|
|
590
|
+
const mask = 1 << (patternLen - 1);
|
|
591
|
+
|
|
592
|
+
for (let i = 0; i < patternLen; i += 1) {
|
|
593
|
+
// Scan for the best match; each iteration allows for one more error.
|
|
594
|
+
// Run a binary search to determine how far from the match location we can stray
|
|
595
|
+
// at this error level.
|
|
596
|
+
let binMin = 0;
|
|
597
|
+
let binMid = binMax;
|
|
598
|
+
|
|
599
|
+
while (binMin < binMid) {
|
|
600
|
+
const score = computeScore(pattern, {
|
|
601
|
+
errors: i,
|
|
602
|
+
currentLocation: expectedLocation + binMid,
|
|
603
|
+
expectedLocation,
|
|
604
|
+
distance,
|
|
605
|
+
ignoreLocation
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
if (score <= currentThreshold) {
|
|
609
|
+
binMin = binMid;
|
|
610
|
+
} else {
|
|
611
|
+
binMax = binMid;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
binMid = Math.floor((binMax - binMin) / 2 + binMin);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// Use the result from this iteration as the maximum for the next.
|
|
618
|
+
binMax = binMid;
|
|
619
|
+
|
|
620
|
+
let start = Math.max(1, expectedLocation - binMid + 1);
|
|
621
|
+
let finish = findAllMatches
|
|
622
|
+
? textLen
|
|
623
|
+
: Math.min(expectedLocation + binMid, textLen) + patternLen;
|
|
624
|
+
|
|
625
|
+
// Initialize the bit array
|
|
626
|
+
let bitArr = Array(finish + 2);
|
|
627
|
+
|
|
628
|
+
bitArr[finish + 1] = (1 << i) - 1;
|
|
629
|
+
|
|
630
|
+
for (let j = finish; j >= start; j -= 1) {
|
|
631
|
+
let currentLocation = j - 1;
|
|
632
|
+
let charMatch = patternAlphabet[text.charAt(currentLocation)];
|
|
633
|
+
|
|
634
|
+
if (computeMatches) {
|
|
635
|
+
// Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
|
|
636
|
+
matchMask[currentLocation] = +!!charMatch;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// First pass: exact match
|
|
640
|
+
bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch;
|
|
641
|
+
|
|
642
|
+
// Subsequent passes: fuzzy match
|
|
643
|
+
if (i) {
|
|
644
|
+
bitArr[j] |=
|
|
645
|
+
((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1];
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if (bitArr[j] & mask) {
|
|
649
|
+
finalScore = computeScore(pattern, {
|
|
650
|
+
errors: i,
|
|
651
|
+
currentLocation,
|
|
652
|
+
expectedLocation,
|
|
653
|
+
distance,
|
|
654
|
+
ignoreLocation
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
// This match will almost certainly be better than any existing match.
|
|
658
|
+
// But check anyway.
|
|
659
|
+
if (finalScore <= currentThreshold) {
|
|
660
|
+
// Indeed it is
|
|
661
|
+
currentThreshold = finalScore;
|
|
662
|
+
bestLocation = currentLocation;
|
|
663
|
+
|
|
664
|
+
// Already passed `loc`, downhill from here on in.
|
|
665
|
+
if (bestLocation <= expectedLocation) {
|
|
666
|
+
break
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
|
|
670
|
+
start = Math.max(1, 2 * expectedLocation - bestLocation);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// No hope for a (better) match at greater error levels.
|
|
676
|
+
const score = computeScore(pattern, {
|
|
677
|
+
errors: i + 1,
|
|
678
|
+
currentLocation: expectedLocation,
|
|
679
|
+
expectedLocation,
|
|
680
|
+
distance,
|
|
681
|
+
ignoreLocation
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
if (score > currentThreshold) {
|
|
685
|
+
break
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
lastBitArr = bitArr;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
const result = {
|
|
692
|
+
isMatch: bestLocation >= 0,
|
|
693
|
+
// Count exact matches (those with a score of 0) to be "almost" exact
|
|
694
|
+
score: Math.max(0.001, finalScore)
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
if (computeMatches) {
|
|
698
|
+
const indices = convertMaskToIndices(matchMask, minMatchCharLength);
|
|
699
|
+
if (!indices.length) {
|
|
700
|
+
result.isMatch = false;
|
|
701
|
+
} else if (includeMatches) {
|
|
702
|
+
result.indices = indices;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return result
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function createPatternAlphabet(pattern) {
|
|
710
|
+
let mask = {};
|
|
711
|
+
|
|
712
|
+
for (let i = 0, len = pattern.length; i < len; i += 1) {
|
|
713
|
+
const char = pattern.charAt(i);
|
|
714
|
+
mask[char] = (mask[char] || 0) | (1 << (len - i - 1));
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
return mask
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
class BitapSearch {
|
|
721
|
+
constructor(
|
|
722
|
+
pattern,
|
|
723
|
+
{
|
|
724
|
+
location = Config.location,
|
|
725
|
+
threshold = Config.threshold,
|
|
726
|
+
distance = Config.distance,
|
|
727
|
+
includeMatches = Config.includeMatches,
|
|
728
|
+
findAllMatches = Config.findAllMatches,
|
|
729
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
730
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
731
|
+
ignoreLocation = Config.ignoreLocation
|
|
732
|
+
} = {}
|
|
733
|
+
) {
|
|
734
|
+
this.options = {
|
|
735
|
+
location,
|
|
736
|
+
threshold,
|
|
737
|
+
distance,
|
|
738
|
+
includeMatches,
|
|
739
|
+
findAllMatches,
|
|
740
|
+
minMatchCharLength,
|
|
741
|
+
isCaseSensitive,
|
|
742
|
+
ignoreLocation
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
746
|
+
|
|
747
|
+
this.chunks = [];
|
|
748
|
+
|
|
749
|
+
if (!this.pattern.length) {
|
|
750
|
+
return
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
const addChunk = (pattern, startIndex) => {
|
|
754
|
+
this.chunks.push({
|
|
755
|
+
pattern,
|
|
756
|
+
alphabet: createPatternAlphabet(pattern),
|
|
757
|
+
startIndex
|
|
758
|
+
});
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
const len = this.pattern.length;
|
|
762
|
+
|
|
763
|
+
if (len > MAX_BITS) {
|
|
764
|
+
let i = 0;
|
|
765
|
+
const remainder = len % MAX_BITS;
|
|
766
|
+
const end = len - remainder;
|
|
767
|
+
|
|
768
|
+
while (i < end) {
|
|
769
|
+
addChunk(this.pattern.substr(i, MAX_BITS), i);
|
|
770
|
+
i += MAX_BITS;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
if (remainder) {
|
|
774
|
+
const startIndex = len - MAX_BITS;
|
|
775
|
+
addChunk(this.pattern.substr(startIndex), startIndex);
|
|
776
|
+
}
|
|
777
|
+
} else {
|
|
778
|
+
addChunk(this.pattern, 0);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
searchIn(text) {
|
|
783
|
+
const { isCaseSensitive, includeMatches } = this.options;
|
|
784
|
+
|
|
785
|
+
if (!isCaseSensitive) {
|
|
786
|
+
text = text.toLowerCase();
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// Exact match
|
|
790
|
+
if (this.pattern === text) {
|
|
791
|
+
let result = {
|
|
792
|
+
isMatch: true,
|
|
793
|
+
score: 0
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
if (includeMatches) {
|
|
797
|
+
result.indices = [[0, text.length - 1]];
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
return result
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// Otherwise, use Bitap algorithm
|
|
804
|
+
const {
|
|
805
|
+
location,
|
|
806
|
+
distance,
|
|
807
|
+
threshold,
|
|
808
|
+
findAllMatches,
|
|
809
|
+
minMatchCharLength,
|
|
810
|
+
ignoreLocation
|
|
811
|
+
} = this.options;
|
|
812
|
+
|
|
813
|
+
let allIndices = [];
|
|
814
|
+
let totalScore = 0;
|
|
815
|
+
let hasMatches = false;
|
|
816
|
+
|
|
817
|
+
this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
|
|
818
|
+
const { isMatch, score, indices } = search(text, pattern, alphabet, {
|
|
819
|
+
location: location + startIndex,
|
|
820
|
+
distance,
|
|
821
|
+
threshold,
|
|
822
|
+
findAllMatches,
|
|
823
|
+
minMatchCharLength,
|
|
824
|
+
includeMatches,
|
|
825
|
+
ignoreLocation
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
if (isMatch) {
|
|
829
|
+
hasMatches = true;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
totalScore += score;
|
|
833
|
+
|
|
834
|
+
if (isMatch && indices) {
|
|
835
|
+
allIndices = [...allIndices, ...indices];
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
let result = {
|
|
840
|
+
isMatch: hasMatches,
|
|
841
|
+
score: hasMatches ? totalScore / this.chunks.length : 1
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
if (hasMatches && includeMatches) {
|
|
845
|
+
result.indices = allIndices;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
return result
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
class BaseMatch {
|
|
853
|
+
constructor(pattern) {
|
|
854
|
+
this.pattern = pattern;
|
|
855
|
+
}
|
|
856
|
+
static isMultiMatch(pattern) {
|
|
857
|
+
return getMatch(pattern, this.multiRegex)
|
|
858
|
+
}
|
|
859
|
+
static isSingleMatch(pattern) {
|
|
860
|
+
return getMatch(pattern, this.singleRegex)
|
|
861
|
+
}
|
|
862
|
+
search(/*text*/) {}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
function getMatch(pattern, exp) {
|
|
866
|
+
const matches = pattern.match(exp);
|
|
867
|
+
return matches ? matches[1] : null
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// Token: 'file
|
|
871
|
+
|
|
872
|
+
class ExactMatch extends BaseMatch {
|
|
873
|
+
constructor(pattern) {
|
|
874
|
+
super(pattern);
|
|
875
|
+
}
|
|
876
|
+
static get type() {
|
|
877
|
+
return 'exact'
|
|
878
|
+
}
|
|
879
|
+
static get multiRegex() {
|
|
880
|
+
return /^="(.*)"$/
|
|
881
|
+
}
|
|
882
|
+
static get singleRegex() {
|
|
883
|
+
return /^=(.*)$/
|
|
884
|
+
}
|
|
885
|
+
search(text) {
|
|
886
|
+
const isMatch = text === this.pattern;
|
|
887
|
+
|
|
888
|
+
return {
|
|
889
|
+
isMatch,
|
|
890
|
+
score: isMatch ? 0 : 1,
|
|
891
|
+
indices: [0, this.pattern.length - 1]
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// Token: !fire
|
|
897
|
+
|
|
898
|
+
class InverseExactMatch extends BaseMatch {
|
|
899
|
+
constructor(pattern) {
|
|
900
|
+
super(pattern);
|
|
901
|
+
}
|
|
902
|
+
static get type() {
|
|
903
|
+
return 'inverse-exact'
|
|
904
|
+
}
|
|
905
|
+
static get multiRegex() {
|
|
906
|
+
return /^!"(.*)"$/
|
|
907
|
+
}
|
|
908
|
+
static get singleRegex() {
|
|
909
|
+
return /^!(.*)$/
|
|
910
|
+
}
|
|
911
|
+
search(text) {
|
|
912
|
+
const index = text.indexOf(this.pattern);
|
|
913
|
+
const isMatch = index === -1;
|
|
914
|
+
|
|
915
|
+
return {
|
|
916
|
+
isMatch,
|
|
917
|
+
score: isMatch ? 0 : 1,
|
|
918
|
+
indices: [0, text.length - 1]
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// Token: ^file
|
|
924
|
+
|
|
925
|
+
class PrefixExactMatch extends BaseMatch {
|
|
926
|
+
constructor(pattern) {
|
|
927
|
+
super(pattern);
|
|
928
|
+
}
|
|
929
|
+
static get type() {
|
|
930
|
+
return 'prefix-exact'
|
|
931
|
+
}
|
|
932
|
+
static get multiRegex() {
|
|
933
|
+
return /^\^"(.*)"$/
|
|
934
|
+
}
|
|
935
|
+
static get singleRegex() {
|
|
936
|
+
return /^\^(.*)$/
|
|
937
|
+
}
|
|
938
|
+
search(text) {
|
|
939
|
+
const isMatch = text.startsWith(this.pattern);
|
|
940
|
+
|
|
941
|
+
return {
|
|
942
|
+
isMatch,
|
|
943
|
+
score: isMatch ? 0 : 1,
|
|
944
|
+
indices: [0, this.pattern.length - 1]
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// Token: !^fire
|
|
950
|
+
|
|
951
|
+
class InversePrefixExactMatch extends BaseMatch {
|
|
952
|
+
constructor(pattern) {
|
|
953
|
+
super(pattern);
|
|
954
|
+
}
|
|
955
|
+
static get type() {
|
|
956
|
+
return 'inverse-prefix-exact'
|
|
957
|
+
}
|
|
958
|
+
static get multiRegex() {
|
|
959
|
+
return /^!\^"(.*)"$/
|
|
960
|
+
}
|
|
961
|
+
static get singleRegex() {
|
|
962
|
+
return /^!\^(.*)$/
|
|
963
|
+
}
|
|
964
|
+
search(text) {
|
|
965
|
+
const isMatch = !text.startsWith(this.pattern);
|
|
966
|
+
|
|
967
|
+
return {
|
|
968
|
+
isMatch,
|
|
969
|
+
score: isMatch ? 0 : 1,
|
|
970
|
+
indices: [0, text.length - 1]
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// Token: .file$
|
|
976
|
+
|
|
977
|
+
class SuffixExactMatch extends BaseMatch {
|
|
978
|
+
constructor(pattern) {
|
|
979
|
+
super(pattern);
|
|
980
|
+
}
|
|
981
|
+
static get type() {
|
|
982
|
+
return 'suffix-exact'
|
|
983
|
+
}
|
|
984
|
+
static get multiRegex() {
|
|
985
|
+
return /^"(.*)"\$$/
|
|
986
|
+
}
|
|
987
|
+
static get singleRegex() {
|
|
988
|
+
return /^(.*)\$$/
|
|
989
|
+
}
|
|
990
|
+
search(text) {
|
|
991
|
+
const isMatch = text.endsWith(this.pattern);
|
|
992
|
+
|
|
993
|
+
return {
|
|
994
|
+
isMatch,
|
|
995
|
+
score: isMatch ? 0 : 1,
|
|
996
|
+
indices: [text.length - this.pattern.length, text.length - 1]
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// Token: !.file$
|
|
1002
|
+
|
|
1003
|
+
class InverseSuffixExactMatch extends BaseMatch {
|
|
1004
|
+
constructor(pattern) {
|
|
1005
|
+
super(pattern);
|
|
1006
|
+
}
|
|
1007
|
+
static get type() {
|
|
1008
|
+
return 'inverse-suffix-exact'
|
|
1009
|
+
}
|
|
1010
|
+
static get multiRegex() {
|
|
1011
|
+
return /^!"(.*)"\$$/
|
|
1012
|
+
}
|
|
1013
|
+
static get singleRegex() {
|
|
1014
|
+
return /^!(.*)\$$/
|
|
1015
|
+
}
|
|
1016
|
+
search(text) {
|
|
1017
|
+
const isMatch = !text.endsWith(this.pattern);
|
|
1018
|
+
return {
|
|
1019
|
+
isMatch,
|
|
1020
|
+
score: isMatch ? 0 : 1,
|
|
1021
|
+
indices: [0, text.length - 1]
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
class FuzzyMatch extends BaseMatch {
|
|
1027
|
+
constructor(
|
|
1028
|
+
pattern,
|
|
1029
|
+
{
|
|
1030
|
+
location = Config.location,
|
|
1031
|
+
threshold = Config.threshold,
|
|
1032
|
+
distance = Config.distance,
|
|
1033
|
+
includeMatches = Config.includeMatches,
|
|
1034
|
+
findAllMatches = Config.findAllMatches,
|
|
1035
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
1036
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
1037
|
+
ignoreLocation = Config.ignoreLocation
|
|
1038
|
+
} = {}
|
|
1039
|
+
) {
|
|
1040
|
+
super(pattern);
|
|
1041
|
+
this._bitapSearch = new BitapSearch(pattern, {
|
|
1042
|
+
location,
|
|
1043
|
+
threshold,
|
|
1044
|
+
distance,
|
|
1045
|
+
includeMatches,
|
|
1046
|
+
findAllMatches,
|
|
1047
|
+
minMatchCharLength,
|
|
1048
|
+
isCaseSensitive,
|
|
1049
|
+
ignoreLocation
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
static get type() {
|
|
1053
|
+
return 'fuzzy'
|
|
1054
|
+
}
|
|
1055
|
+
static get multiRegex() {
|
|
1056
|
+
return /^"(.*)"$/
|
|
1057
|
+
}
|
|
1058
|
+
static get singleRegex() {
|
|
1059
|
+
return /^(.*)$/
|
|
1060
|
+
}
|
|
1061
|
+
search(text) {
|
|
1062
|
+
return this._bitapSearch.searchIn(text)
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// Token: 'file
|
|
1067
|
+
|
|
1068
|
+
class IncludeMatch extends BaseMatch {
|
|
1069
|
+
constructor(pattern) {
|
|
1070
|
+
super(pattern);
|
|
1071
|
+
}
|
|
1072
|
+
static get type() {
|
|
1073
|
+
return 'include'
|
|
1074
|
+
}
|
|
1075
|
+
static get multiRegex() {
|
|
1076
|
+
return /^'"(.*)"$/
|
|
1077
|
+
}
|
|
1078
|
+
static get singleRegex() {
|
|
1079
|
+
return /^'(.*)$/
|
|
1080
|
+
}
|
|
1081
|
+
search(text) {
|
|
1082
|
+
let location = 0;
|
|
1083
|
+
let index;
|
|
1084
|
+
|
|
1085
|
+
const indices = [];
|
|
1086
|
+
const patternLen = this.pattern.length;
|
|
1087
|
+
|
|
1088
|
+
// Get all exact matches
|
|
1089
|
+
while ((index = text.indexOf(this.pattern, location)) > -1) {
|
|
1090
|
+
location = index + patternLen;
|
|
1091
|
+
indices.push([index, location - 1]);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
const isMatch = !!indices.length;
|
|
1095
|
+
|
|
1096
|
+
return {
|
|
1097
|
+
isMatch,
|
|
1098
|
+
score: isMatch ? 0 : 1,
|
|
1099
|
+
indices
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
// ❗Order is important. DO NOT CHANGE.
|
|
1105
|
+
const searchers = [
|
|
1106
|
+
ExactMatch,
|
|
1107
|
+
IncludeMatch,
|
|
1108
|
+
PrefixExactMatch,
|
|
1109
|
+
InversePrefixExactMatch,
|
|
1110
|
+
InverseSuffixExactMatch,
|
|
1111
|
+
SuffixExactMatch,
|
|
1112
|
+
InverseExactMatch,
|
|
1113
|
+
FuzzyMatch
|
|
1114
|
+
];
|
|
1115
|
+
|
|
1116
|
+
const searchersLen = searchers.length;
|
|
1117
|
+
|
|
1118
|
+
// Regex to split by spaces, but keep anything in quotes together
|
|
1119
|
+
const SPACE_RE = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;
|
|
1120
|
+
const OR_TOKEN = '|';
|
|
1121
|
+
|
|
1122
|
+
// Return a 2D array representation of the query, for simpler parsing.
|
|
1123
|
+
// Example:
|
|
1124
|
+
// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
|
|
1125
|
+
function parseQuery(pattern, options = {}) {
|
|
1126
|
+
return pattern.split(OR_TOKEN).map((item) => {
|
|
1127
|
+
let query = item
|
|
1128
|
+
.trim()
|
|
1129
|
+
.split(SPACE_RE)
|
|
1130
|
+
.filter((item) => item && !!item.trim());
|
|
1131
|
+
|
|
1132
|
+
let results = [];
|
|
1133
|
+
for (let i = 0, len = query.length; i < len; i += 1) {
|
|
1134
|
+
const queryItem = query[i];
|
|
1135
|
+
|
|
1136
|
+
// 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
|
|
1137
|
+
let found = false;
|
|
1138
|
+
let idx = -1;
|
|
1139
|
+
while (!found && ++idx < searchersLen) {
|
|
1140
|
+
const searcher = searchers[idx];
|
|
1141
|
+
let token = searcher.isMultiMatch(queryItem);
|
|
1142
|
+
if (token) {
|
|
1143
|
+
results.push(new searcher(token, options));
|
|
1144
|
+
found = true;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
if (found) {
|
|
1149
|
+
continue
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// 2. Handle single query matches (i.e, once that are *not* quoted)
|
|
1153
|
+
idx = -1;
|
|
1154
|
+
while (++idx < searchersLen) {
|
|
1155
|
+
const searcher = searchers[idx];
|
|
1156
|
+
let token = searcher.isSingleMatch(queryItem);
|
|
1157
|
+
if (token) {
|
|
1158
|
+
results.push(new searcher(token, options));
|
|
1159
|
+
break
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
return results
|
|
1165
|
+
})
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
// These extended matchers can return an array of matches, as opposed
|
|
1169
|
+
// to a singl match
|
|
1170
|
+
const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* Command-like searching
|
|
1174
|
+
* ======================
|
|
1175
|
+
*
|
|
1176
|
+
* Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
|
|
1177
|
+
* search in a given text.
|
|
1178
|
+
*
|
|
1179
|
+
* Search syntax:
|
|
1180
|
+
*
|
|
1181
|
+
* | Token | Match type | Description |
|
|
1182
|
+
* | ----------- | -------------------------- | -------------------------------------- |
|
|
1183
|
+
* | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
|
|
1184
|
+
* | `=scheme` | exact-match | Items that are `scheme` |
|
|
1185
|
+
* | `'python` | include-match | Items that include `python` |
|
|
1186
|
+
* | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
|
|
1187
|
+
* | `^java` | prefix-exact-match | Items that start with `java` |
|
|
1188
|
+
* | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
|
|
1189
|
+
* | `.js$` | suffix-exact-match | Items that end with `.js` |
|
|
1190
|
+
* | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
|
|
1191
|
+
*
|
|
1192
|
+
* A single pipe character acts as an OR operator. For example, the following
|
|
1193
|
+
* query matches entries that start with `core` and end with either`go`, `rb`,
|
|
1194
|
+
* or`py`.
|
|
1195
|
+
*
|
|
1196
|
+
* ```
|
|
1197
|
+
* ^core go$ | rb$ | py$
|
|
1198
|
+
* ```
|
|
1199
|
+
*/
|
|
1200
|
+
class ExtendedSearch {
|
|
1201
|
+
constructor(
|
|
1202
|
+
pattern,
|
|
1203
|
+
{
|
|
1204
|
+
isCaseSensitive = Config.isCaseSensitive,
|
|
1205
|
+
includeMatches = Config.includeMatches,
|
|
1206
|
+
minMatchCharLength = Config.minMatchCharLength,
|
|
1207
|
+
ignoreLocation = Config.ignoreLocation,
|
|
1208
|
+
findAllMatches = Config.findAllMatches,
|
|
1209
|
+
location = Config.location,
|
|
1210
|
+
threshold = Config.threshold,
|
|
1211
|
+
distance = Config.distance
|
|
1212
|
+
} = {}
|
|
1213
|
+
) {
|
|
1214
|
+
this.query = null;
|
|
1215
|
+
this.options = {
|
|
1216
|
+
isCaseSensitive,
|
|
1217
|
+
includeMatches,
|
|
1218
|
+
minMatchCharLength,
|
|
1219
|
+
findAllMatches,
|
|
1220
|
+
ignoreLocation,
|
|
1221
|
+
location,
|
|
1222
|
+
threshold,
|
|
1223
|
+
distance
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
|
|
1227
|
+
this.query = parseQuery(this.pattern, this.options);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
static condition(_, options) {
|
|
1231
|
+
return options.useExtendedSearch
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
searchIn(text) {
|
|
1235
|
+
const query = this.query;
|
|
1236
|
+
|
|
1237
|
+
if (!query) {
|
|
1238
|
+
return {
|
|
1239
|
+
isMatch: false,
|
|
1240
|
+
score: 1
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
const { includeMatches, isCaseSensitive } = this.options;
|
|
1245
|
+
|
|
1246
|
+
text = isCaseSensitive ? text : text.toLowerCase();
|
|
1247
|
+
|
|
1248
|
+
let numMatches = 0;
|
|
1249
|
+
let allIndices = [];
|
|
1250
|
+
let totalScore = 0;
|
|
1251
|
+
|
|
1252
|
+
// ORs
|
|
1253
|
+
for (let i = 0, qLen = query.length; i < qLen; i += 1) {
|
|
1254
|
+
const searchers = query[i];
|
|
1255
|
+
|
|
1256
|
+
// Reset indices
|
|
1257
|
+
allIndices.length = 0;
|
|
1258
|
+
numMatches = 0;
|
|
1259
|
+
|
|
1260
|
+
// ANDs
|
|
1261
|
+
for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
|
|
1262
|
+
const searcher = searchers[j];
|
|
1263
|
+
const { isMatch, indices, score } = searcher.search(text);
|
|
1264
|
+
|
|
1265
|
+
if (isMatch) {
|
|
1266
|
+
numMatches += 1;
|
|
1267
|
+
totalScore += score;
|
|
1268
|
+
if (includeMatches) {
|
|
1269
|
+
const type = searcher.constructor.type;
|
|
1270
|
+
if (MultiMatchSet.has(type)) {
|
|
1271
|
+
allIndices = [...allIndices, ...indices];
|
|
1272
|
+
} else {
|
|
1273
|
+
allIndices.push(indices);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
} else {
|
|
1277
|
+
totalScore = 0;
|
|
1278
|
+
numMatches = 0;
|
|
1279
|
+
allIndices.length = 0;
|
|
1280
|
+
break
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
// OR condition, so if TRUE, return
|
|
1285
|
+
if (numMatches) {
|
|
1286
|
+
let result = {
|
|
1287
|
+
isMatch: true,
|
|
1288
|
+
score: totalScore / numMatches
|
|
1289
|
+
};
|
|
1290
|
+
|
|
1291
|
+
if (includeMatches) {
|
|
1292
|
+
result.indices = allIndices;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
return result
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// Nothing was matched
|
|
1300
|
+
return {
|
|
1301
|
+
isMatch: false,
|
|
1302
|
+
score: 1
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
const registeredSearchers = [];
|
|
1308
|
+
|
|
1309
|
+
function register(...args) {
|
|
1310
|
+
registeredSearchers.push(...args);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
function createSearcher(pattern, options) {
|
|
1314
|
+
for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
|
|
1315
|
+
let searcherClass = registeredSearchers[i];
|
|
1316
|
+
if (searcherClass.condition(pattern, options)) {
|
|
1317
|
+
return new searcherClass(pattern, options)
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
return new BitapSearch(pattern, options)
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
const LogicalOperator = {
|
|
1325
|
+
AND: '$and',
|
|
1326
|
+
OR: '$or'
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1329
|
+
const KeyType = {
|
|
1330
|
+
PATH: '$path',
|
|
1331
|
+
PATTERN: '$val'
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
const isExpression = (query) =>
|
|
1335
|
+
!!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
|
|
1336
|
+
|
|
1337
|
+
const isPath = (query) => !!query[KeyType.PATH];
|
|
1338
|
+
|
|
1339
|
+
const isLeaf = (query) =>
|
|
1340
|
+
!isArray(query) && isObject(query) && !isExpression(query);
|
|
1341
|
+
|
|
1342
|
+
const convertToExplicit = (query) => ({
|
|
1343
|
+
[LogicalOperator.AND]: Object.keys(query).map((key) => ({
|
|
1344
|
+
[key]: query[key]
|
|
1345
|
+
}))
|
|
1346
|
+
});
|
|
1347
|
+
|
|
1348
|
+
// When `auto` is `true`, the parse function will infer and initialize and add
|
|
1349
|
+
// the appropriate `Searcher` instance
|
|
1350
|
+
function parse(query, options, { auto = true } = {}) {
|
|
1351
|
+
const next = (query) => {
|
|
1352
|
+
let keys = Object.keys(query);
|
|
1353
|
+
|
|
1354
|
+
const isQueryPath = isPath(query);
|
|
1355
|
+
|
|
1356
|
+
if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
|
|
1357
|
+
return next(convertToExplicit(query))
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
if (isLeaf(query)) {
|
|
1361
|
+
const key = isQueryPath ? query[KeyType.PATH] : keys[0];
|
|
1362
|
+
|
|
1363
|
+
const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
|
|
1364
|
+
|
|
1365
|
+
if (!isString(pattern)) {
|
|
1366
|
+
throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key))
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
const obj = {
|
|
1370
|
+
keyId: createKeyId(key),
|
|
1371
|
+
pattern
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
if (auto) {
|
|
1375
|
+
obj.searcher = createSearcher(pattern, options);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
return obj
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
let node = {
|
|
1382
|
+
children: [],
|
|
1383
|
+
operator: keys[0]
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1386
|
+
keys.forEach((key) => {
|
|
1387
|
+
const value = query[key];
|
|
1388
|
+
|
|
1389
|
+
if (isArray(value)) {
|
|
1390
|
+
value.forEach((item) => {
|
|
1391
|
+
node.children.push(next(item));
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
});
|
|
1395
|
+
|
|
1396
|
+
return node
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1399
|
+
if (!isExpression(query)) {
|
|
1400
|
+
query = convertToExplicit(query);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
return next(query)
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// Practical scoring function
|
|
1407
|
+
function computeScore$1(
|
|
1408
|
+
results,
|
|
1409
|
+
{ ignoreFieldNorm = Config.ignoreFieldNorm }
|
|
1410
|
+
) {
|
|
1411
|
+
results.forEach((result) => {
|
|
1412
|
+
let totalScore = 1;
|
|
1413
|
+
|
|
1414
|
+
result.matches.forEach(({ key, norm, score }) => {
|
|
1415
|
+
const weight = key ? key.weight : null;
|
|
1416
|
+
|
|
1417
|
+
totalScore *= Math.pow(
|
|
1418
|
+
score === 0 && weight ? Number.EPSILON : score,
|
|
1419
|
+
(weight || 1) * (ignoreFieldNorm ? 1 : norm)
|
|
1420
|
+
);
|
|
1421
|
+
});
|
|
1422
|
+
|
|
1423
|
+
result.score = totalScore;
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
function transformMatches(result, data) {
|
|
1428
|
+
const matches = result.matches;
|
|
1429
|
+
data.matches = [];
|
|
1430
|
+
|
|
1431
|
+
if (!isDefined(matches)) {
|
|
1432
|
+
return
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
matches.forEach((match) => {
|
|
1436
|
+
if (!isDefined(match.indices) || !match.indices.length) {
|
|
1437
|
+
return
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
const { indices, value } = match;
|
|
1441
|
+
|
|
1442
|
+
let obj = {
|
|
1443
|
+
indices,
|
|
1444
|
+
value
|
|
1445
|
+
};
|
|
1446
|
+
|
|
1447
|
+
if (match.key) {
|
|
1448
|
+
obj.key = match.key.src;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
if (match.idx > -1) {
|
|
1452
|
+
obj.refIndex = match.idx;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
data.matches.push(obj);
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
function transformScore(result, data) {
|
|
1460
|
+
data.score = result.score;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
function format(
|
|
1464
|
+
results,
|
|
1465
|
+
docs,
|
|
1466
|
+
{
|
|
1467
|
+
includeMatches = Config.includeMatches,
|
|
1468
|
+
includeScore = Config.includeScore
|
|
1469
|
+
} = {}
|
|
1470
|
+
) {
|
|
1471
|
+
const transformers = [];
|
|
1472
|
+
|
|
1473
|
+
if (includeMatches) transformers.push(transformMatches);
|
|
1474
|
+
if (includeScore) transformers.push(transformScore);
|
|
1475
|
+
|
|
1476
|
+
return results.map((result) => {
|
|
1477
|
+
const { idx } = result;
|
|
1478
|
+
|
|
1479
|
+
const data = {
|
|
1480
|
+
item: docs[idx],
|
|
1481
|
+
refIndex: idx
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
if (transformers.length) {
|
|
1485
|
+
transformers.forEach((transformer) => {
|
|
1486
|
+
transformer(result, data);
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
return data
|
|
1491
|
+
})
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
class Fuse {
|
|
1495
|
+
constructor(docs, options = {}, index) {
|
|
1496
|
+
this.options = { ...Config, ...options };
|
|
1497
|
+
|
|
1498
|
+
this._keyStore = new KeyStore(this.options.keys);
|
|
1499
|
+
|
|
1500
|
+
this.setCollection(docs, index);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
setCollection(docs, index) {
|
|
1504
|
+
this._docs = docs;
|
|
1505
|
+
|
|
1506
|
+
if (index && !(index instanceof FuseIndex)) {
|
|
1507
|
+
throw new Error(INCORRECT_INDEX_TYPE)
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
this._myIndex =
|
|
1511
|
+
index ||
|
|
1512
|
+
createIndex(this.options.keys, this._docs, {
|
|
1513
|
+
getFn: this.options.getFn
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
add(doc) {
|
|
1518
|
+
if (!isDefined(doc)) {
|
|
1519
|
+
return
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
this._docs.push(doc);
|
|
1523
|
+
this._myIndex.add(doc);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
remove(predicate = (/* doc, idx */) => false) {
|
|
1527
|
+
const results = [];
|
|
1528
|
+
|
|
1529
|
+
for (let i = 0, len = this._docs.length; i < len; i += 1) {
|
|
1530
|
+
const doc = this._docs[i];
|
|
1531
|
+
if (predicate(doc, i)) {
|
|
1532
|
+
this.removeAt(i);
|
|
1533
|
+
i -= 1;
|
|
1534
|
+
len -= 1;
|
|
1535
|
+
|
|
1536
|
+
results.push(doc);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
return results
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
removeAt(idx) {
|
|
1544
|
+
this._docs.splice(idx, 1);
|
|
1545
|
+
this._myIndex.removeAt(idx);
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
getIndex() {
|
|
1549
|
+
return this._myIndex
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
search(query, { limit = -1 } = {}) {
|
|
1553
|
+
const {
|
|
1554
|
+
includeMatches,
|
|
1555
|
+
includeScore,
|
|
1556
|
+
shouldSort,
|
|
1557
|
+
sortFn,
|
|
1558
|
+
ignoreFieldNorm
|
|
1559
|
+
} = this.options;
|
|
1560
|
+
|
|
1561
|
+
let results = isString(query)
|
|
1562
|
+
? isString(this._docs[0])
|
|
1563
|
+
? this._searchStringList(query)
|
|
1564
|
+
: this._searchObjectList(query)
|
|
1565
|
+
: this._searchLogical(query);
|
|
1566
|
+
|
|
1567
|
+
computeScore$1(results, { ignoreFieldNorm });
|
|
1568
|
+
|
|
1569
|
+
if (shouldSort) {
|
|
1570
|
+
results.sort(sortFn);
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
if (isNumber(limit) && limit > -1) {
|
|
1574
|
+
results = results.slice(0, limit);
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
return format(results, this._docs, {
|
|
1578
|
+
includeMatches,
|
|
1579
|
+
includeScore
|
|
1580
|
+
})
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
_searchStringList(query) {
|
|
1584
|
+
const searcher = createSearcher(query, this.options);
|
|
1585
|
+
const { records } = this._myIndex;
|
|
1586
|
+
const results = [];
|
|
1587
|
+
|
|
1588
|
+
// Iterate over every string in the index
|
|
1589
|
+
records.forEach(({ v: text, i: idx, n: norm }) => {
|
|
1590
|
+
if (!isDefined(text)) {
|
|
1591
|
+
return
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
1595
|
+
|
|
1596
|
+
if (isMatch) {
|
|
1597
|
+
results.push({
|
|
1598
|
+
item: text,
|
|
1599
|
+
idx,
|
|
1600
|
+
matches: [{ score, value: text, norm, indices }]
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
|
|
1605
|
+
return results
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
_searchLogical(query) {
|
|
1609
|
+
|
|
1610
|
+
const expression = parse(query, this.options);
|
|
1611
|
+
|
|
1612
|
+
const evaluate = (node, item, idx) => {
|
|
1613
|
+
if (!node.children) {
|
|
1614
|
+
const { keyId, searcher } = node;
|
|
1615
|
+
|
|
1616
|
+
const matches = this._findMatches({
|
|
1617
|
+
key: this._keyStore.get(keyId),
|
|
1618
|
+
value: this._myIndex.getValueForItemAtKeyId(item, keyId),
|
|
1619
|
+
searcher
|
|
1620
|
+
});
|
|
1621
|
+
|
|
1622
|
+
if (matches && matches.length) {
|
|
1623
|
+
return [
|
|
1624
|
+
{
|
|
1625
|
+
idx,
|
|
1626
|
+
item,
|
|
1627
|
+
matches
|
|
1628
|
+
}
|
|
1629
|
+
]
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
return []
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/*eslint indent: [2, 2, {"SwitchCase": 1}]*/
|
|
1636
|
+
switch (node.operator) {
|
|
1637
|
+
case LogicalOperator.AND: {
|
|
1638
|
+
const res = [];
|
|
1639
|
+
for (let i = 0, len = node.children.length; i < len; i += 1) {
|
|
1640
|
+
const child = node.children[i];
|
|
1641
|
+
const result = evaluate(child, item, idx);
|
|
1642
|
+
if (result.length) {
|
|
1643
|
+
res.push(...result);
|
|
1644
|
+
} else {
|
|
1645
|
+
return []
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return res
|
|
1649
|
+
}
|
|
1650
|
+
case LogicalOperator.OR: {
|
|
1651
|
+
const res = [];
|
|
1652
|
+
for (let i = 0, len = node.children.length; i < len; i += 1) {
|
|
1653
|
+
const child = node.children[i];
|
|
1654
|
+
const result = evaluate(child, item, idx);
|
|
1655
|
+
if (result.length) {
|
|
1656
|
+
res.push(...result);
|
|
1657
|
+
break
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
return res
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
|
|
1665
|
+
const records = this._myIndex.records;
|
|
1666
|
+
const resultMap = {};
|
|
1667
|
+
const results = [];
|
|
1668
|
+
|
|
1669
|
+
records.forEach(({ $: item, i: idx }) => {
|
|
1670
|
+
if (isDefined(item)) {
|
|
1671
|
+
let expResults = evaluate(expression, item, idx);
|
|
1672
|
+
|
|
1673
|
+
if (expResults.length) {
|
|
1674
|
+
// Dedupe when adding
|
|
1675
|
+
if (!resultMap[idx]) {
|
|
1676
|
+
resultMap[idx] = { idx, item, matches: [] };
|
|
1677
|
+
results.push(resultMap[idx]);
|
|
1678
|
+
}
|
|
1679
|
+
expResults.forEach(({ matches }) => {
|
|
1680
|
+
resultMap[idx].matches.push(...matches);
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
|
|
1686
|
+
return results
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
_searchObjectList(query) {
|
|
1690
|
+
const searcher = createSearcher(query, this.options);
|
|
1691
|
+
const { keys, records } = this._myIndex;
|
|
1692
|
+
const results = [];
|
|
1693
|
+
|
|
1694
|
+
// List is Array<Object>
|
|
1695
|
+
records.forEach(({ $: item, i: idx }) => {
|
|
1696
|
+
if (!isDefined(item)) {
|
|
1697
|
+
return
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
let matches = [];
|
|
1701
|
+
|
|
1702
|
+
// Iterate over every key (i.e, path), and fetch the value at that key
|
|
1703
|
+
keys.forEach((key, keyIndex) => {
|
|
1704
|
+
matches.push(
|
|
1705
|
+
...this._findMatches({
|
|
1706
|
+
key,
|
|
1707
|
+
value: item[keyIndex],
|
|
1708
|
+
searcher
|
|
1709
|
+
})
|
|
1710
|
+
);
|
|
1711
|
+
});
|
|
1712
|
+
|
|
1713
|
+
if (matches.length) {
|
|
1714
|
+
results.push({
|
|
1715
|
+
idx,
|
|
1716
|
+
item,
|
|
1717
|
+
matches
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
|
|
1722
|
+
return results
|
|
1723
|
+
}
|
|
1724
|
+
_findMatches({ key, value, searcher }) {
|
|
1725
|
+
if (!isDefined(value)) {
|
|
1726
|
+
return []
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
let matches = [];
|
|
1730
|
+
|
|
1731
|
+
if (isArray(value)) {
|
|
1732
|
+
value.forEach(({ v: text, i: idx, n: norm }) => {
|
|
1733
|
+
if (!isDefined(text)) {
|
|
1734
|
+
return
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
1738
|
+
|
|
1739
|
+
if (isMatch) {
|
|
1740
|
+
matches.push({
|
|
1741
|
+
score,
|
|
1742
|
+
key,
|
|
1743
|
+
value: text,
|
|
1744
|
+
idx,
|
|
1745
|
+
norm,
|
|
1746
|
+
indices
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
});
|
|
1750
|
+
} else {
|
|
1751
|
+
const { v: text, n: norm } = value;
|
|
1752
|
+
|
|
1753
|
+
const { isMatch, score, indices } = searcher.searchIn(text);
|
|
1754
|
+
|
|
1755
|
+
if (isMatch) {
|
|
1756
|
+
matches.push({ score, key, value: text, norm, indices });
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
return matches
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
Fuse.version = '6.4.6';
|
|
1765
|
+
Fuse.createIndex = createIndex;
|
|
1766
|
+
Fuse.parseIndex = parseIndex;
|
|
1767
|
+
Fuse.config = Config;
|
|
1768
|
+
|
|
1769
|
+
{
|
|
1770
|
+
Fuse.parseQuery = parse;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
{
|
|
1774
|
+
register(ExtendedSearch);
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
const appCss = "*,*::before,*::after{box-sizing:border-box}ul[class],ol[class]{padding:0}body,h1,h2,h3,h4,p,ul[class],ol[class],li,figure,figcaption,blockquote,dl,dd{margin:0}ul[class],ol[class]{list-style:none}a:not([class]){text-decoration-skip-ink:auto}img{max-width:100%}input,button,textarea,select{font:inherit}@media (prefers-reduced-motion: reduce){*{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:root{--width-nav-panel:16rem}@keyframes spin{to{transform:rotate(360deg)}}.loading-screen{display:flex;flex-direction:row;align-items:center;justify-content:center;position:absolute;top:0;right:0;bottom:0;left:0}.loading-screen-icon{animation:spin 0.35s linear infinite;border-radius:50%;border-style:solid;border-width:0.125rem;border-color:rgb(var(--kompendium-color-blue-default));border-top-color:transparent;display:inline-block;height:1.25rem;width:1.25rem}.loading-screen-text{padding-left:0.75rem;color:rgb(var(--kompendium-contrast-1100))}:host{display:block;margin:0;padding:0}main{padding:1.25rem 2rem;margin-left:var(--width-nav-panel)}main kompendium-guide{display:block;width:100%;max-width:60rem}@media (max-width: 1000px){main{padding-top:2.625rem;margin-left:0}}";
|
|
1778
|
+
|
|
1779
|
+
const App = class {
|
|
1780
|
+
constructor(hostRef) {
|
|
1781
|
+
index.registerInstance(this, hostRef);
|
|
1782
|
+
/**
|
|
1783
|
+
* Path to `kompendium.json`
|
|
1784
|
+
*/
|
|
1785
|
+
this.path = '/kompendium.json';
|
|
1786
|
+
this.onMessage = this.onMessage.bind(this);
|
|
1787
|
+
}
|
|
1788
|
+
componentWillLoad() {
|
|
1789
|
+
this.createWebSocket();
|
|
1790
|
+
this.fetchData();
|
|
1791
|
+
}
|
|
1792
|
+
watchData() {
|
|
1793
|
+
const options = {
|
|
1794
|
+
includeScore: true,
|
|
1795
|
+
includeMatches: true,
|
|
1796
|
+
ignoreLocation: true,
|
|
1797
|
+
threshold: 0.4,
|
|
1798
|
+
};
|
|
1799
|
+
const index = Fuse.parseIndex(this.data.index.data);
|
|
1800
|
+
this.index = new Fuse(this.data.index.documents, options, index);
|
|
1801
|
+
}
|
|
1802
|
+
createWebSocket() {
|
|
1803
|
+
if (this.socket) {
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1806
|
+
const url = getSocketUrl(location);
|
|
1807
|
+
this.socket = new WebSocket(url);
|
|
1808
|
+
this.socket.addEventListener('message', this.onMessage);
|
|
1809
|
+
}
|
|
1810
|
+
onMessage(event) {
|
|
1811
|
+
var _a;
|
|
1812
|
+
try {
|
|
1813
|
+
const data = JSON.parse(event.data);
|
|
1814
|
+
if (((_a = data.buildLog) === null || _a === void 0 ? void 0 : _a.progress) === 1) {
|
|
1815
|
+
this.fetchData();
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
catch (e) {
|
|
1819
|
+
// eslint-disable-next-line no-console
|
|
1820
|
+
console.error(e);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
async fetchData() {
|
|
1824
|
+
const data = await fetch(this.path);
|
|
1825
|
+
this.data = await data.json();
|
|
1826
|
+
const typeNames = this.data.types.map((type) => type.name);
|
|
1827
|
+
markdownTypes.setTypes(typeNames);
|
|
1828
|
+
}
|
|
1829
|
+
render() {
|
|
1830
|
+
if (!this.data) {
|
|
1831
|
+
return (index.h("div", { class: "loading-screen" }, index.h("div", { class: "loading-screen-icon" }), index.h("div", { class: "loading-screen-text" }, "Loading...")));
|
|
1832
|
+
}
|
|
1833
|
+
return (index.h("div", { class: "kompendium-body" }, index.h("kompendium-navigation", { menu: this.data.menu, header: this.data.title, logo: this.data.logo, index: this.index }), index.h("main", { role: "main" }, index.h("stencil-router", null, index.h("stencil-route-switch", { scrollTopOffset: 0 }, index.h("stencil-route", { url: "/", component: "kompendium-markdown", componentProps: {
|
|
1834
|
+
text: this.data.readme,
|
|
1835
|
+
} }), index.h("stencil-route", { url: "/component/:name/:section?", component: "kompendium-component", componentProps: {
|
|
1836
|
+
docs: this.data.docs,
|
|
1837
|
+
schemas: this.data.schemas,
|
|
1838
|
+
examplePropsFactory: this.examplePropsFactory,
|
|
1839
|
+
} }), index.h("stencil-route", { url: "/type/:name", component: "kompendium-type", componentProps: {
|
|
1840
|
+
types: this.data.types,
|
|
1841
|
+
} }), index.h("stencil-route", { url: "/debug/:name", component: "kompendium-debug", componentProps: {
|
|
1842
|
+
docs: this.data.docs,
|
|
1843
|
+
schemas: this.data.schemas,
|
|
1844
|
+
examplePropsFactory: this.examplePropsFactory,
|
|
1845
|
+
} }), index.h("stencil-route", { component: "kompendium-guide", componentProps: {
|
|
1846
|
+
data: this.data,
|
|
1847
|
+
} }))))));
|
|
1848
|
+
}
|
|
1849
|
+
static get watchers() { return {
|
|
1850
|
+
"data": ["watchData"]
|
|
1851
|
+
}; }
|
|
1852
|
+
};
|
|
1853
|
+
function getSocketUrl(location) {
|
|
1854
|
+
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
1855
|
+
return `${protocol}//${location.hostname}:${location.port}/`;
|
|
1856
|
+
}
|
|
1857
|
+
App.style = appCss;
|
|
1858
|
+
|
|
1859
|
+
const darkmodeSwitchCss = ":host{--toggle-size:1.25rem}:host *{box-sizing:border-box}.mode-toggle{margin:0.75rem;position:relative;width:var(--toggle-size);height:var(--toggle-size);transition:opacity 0.3s ease;opacity:0.7}.mode-toggle:hover{opacity:1}.mode-visualization{pointer-events:none;position:absolute;width:var(--toggle-size);height:var(--toggle-size)}.circle{transition:background-color 0.6s ease;border-radius:50%;width:var(--toggle-size);height:var(--toggle-size);overflow:hidden;display:flex;align-items:center;justify-content:center;transform:translate3d(0, 0, 0)}.circle:after{transition:transform 0.7s ease, background-color 0.4s ease;content:\"\";display:block;border-radius:50%;width:calc(var(--toggle-size) - 0.25rem);height:calc(var(--toggle-size) - 0.25rem)}.ray{transition:opacity 0.6s ease, transform 0.6s cubic-bezier(0.37, -0.03, 0.4, 1.18);position:absolute;top:0;left:0;width:var(--toggle-size);height:var(--toggle-size)}.ray:before,.ray:after{content:\"\";display:block;height:0.375rem;width:0.125rem;border-radius:var(--toggle-size);background-color:rgba(var(--kompendium-color-orange-light), 1);position:absolute;left:0;right:0;margin:auto}.ray:before{top:-0.5rem}.ray:after{bottom:-0.5rem}.ray.three:before,.ray.three:after,.ray.four:before,.ray.four:after{height:0.25rem}input[type=checkbox]{-webkit-appearance:none;position:absolute;width:100%;height:100%;margin:0;cursor:pointer;border-radius:0.125rem}input[type=checkbox]:focus{outline:none}input[type=checkbox]:focus-visible{outline:none;box-shadow:var(--kompendium-shadow-depth-8-focused)}input[type=checkbox]:not(:checked)+.mode-visualization .circle{background-color:rgba(var(--kompendium-color-orange-default), 1);box-shadow:0 0 0.5rem 0.125rem rgba(var(--kompendium-color-orange-light), 0.8), 0 0 0.25rem 0.1875rem rgb(var(--kompendium-color-white))}input[type=checkbox]:not(:checked)+.mode-visualization .circle:after{background-color:rgba(var(--kompendium-color-orange-default), 1);transform:translate3d(1rem, -1rem, 0)}input[type=checkbox]:not(:checked)+.mode-visualization .ray{opacity:0.6}input[type=checkbox]:not(:checked)+.mode-visualization .ray.three,input[type=checkbox]:not(:checked)+.mode-visualization .ray.four{opacity:0.4}input[type=checkbox]:not(:checked)+.mode-visualization .ray.one{transform:rotate(0deg) scale(1)}input[type=checkbox]:not(:checked)+.mode-visualization .ray.two{transform:rotate(90deg) scale(1)}input[type=checkbox]:not(:checked)+.mode-visualization .ray.three{transform:rotate(45deg) scale(1)}input[type=checkbox]:not(:checked)+.mode-visualization .ray.four{transform:rotate(-45deg) scale(1)}input[type=checkbox]:checked+.mode-visualization .circle{background-color:rgba(var(--kompendium-contrast-1700), 0.7);box-shadow:0 0 0.5rem 0.125rem rgba(var(--kompendium-color-white), 0.4), 0 0 0.25rem 0.125rem rgb(var(--kompendium-color-black))}input[type=checkbox]:checked+.mode-visualization .circle:after{transform:translate3d(0.25rem, -0.25rem, 0);background-color:rgb(var(--kompendium-contrast-400))}input[type=checkbox]:checked+.mode-visualization .ray{opacity:0}input[type=checkbox]:checked+.mode-visualization .ray.one{transform:rotate(60deg) scale(0.5)}input[type=checkbox]:checked+.mode-visualization .ray.two{transform:rotate(150deg) scale(0.5)}input[type=checkbox]:checked+.mode-visualization .ray.three{transform:rotate(105deg) scale(0.5)}input[type=checkbox]:checked+.mode-visualization .ray.four{transform:rotate(15deg) scale(0.5)}";
|
|
1860
|
+
|
|
1861
|
+
const DEFAULT = 'system-default';
|
|
1862
|
+
const LIGHT = 'force-light';
|
|
1863
|
+
const DARK = 'force-dark';
|
|
1864
|
+
const CHECKBOX_LIGHT = false;
|
|
1865
|
+
const CHECKBOX_DARK = true;
|
|
1866
|
+
const LOCALSTORAGE_KEY = 'kompendium-theme';
|
|
1867
|
+
const DarkmodeSwitch = class {
|
|
1868
|
+
constructor(hostRef) {
|
|
1869
|
+
index.registerInstance(this, hostRef);
|
|
1870
|
+
this.theme = 'system-default';
|
|
1871
|
+
this.getSelectRef = (element) => {
|
|
1872
|
+
this.checkbox = element;
|
|
1873
|
+
};
|
|
1874
|
+
this.handleSystemThemeChange = (e) => {
|
|
1875
|
+
this.systemSettingIsDark = !!e.matches;
|
|
1876
|
+
if (this.theme === DEFAULT) {
|
|
1877
|
+
this.checkbox.checked = !this.checkbox.checked;
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
this.handleThemeChange = () => {
|
|
1881
|
+
const checkboxValue = !!this.checkbox.checked;
|
|
1882
|
+
let newTheme = DEFAULT;
|
|
1883
|
+
if (this.systemSettingIsDark) {
|
|
1884
|
+
if (checkboxValue === CHECKBOX_LIGHT) {
|
|
1885
|
+
newTheme = LIGHT;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
else {
|
|
1889
|
+
if (checkboxValue === CHECKBOX_DARK) {
|
|
1890
|
+
newTheme = DARK;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
this.setTheme(newTheme);
|
|
1894
|
+
document.dispatchEvent(new CustomEvent(types.THEME_EVENT_NAME, { detail: newTheme }));
|
|
1895
|
+
};
|
|
1896
|
+
this.setTheme = (value) => {
|
|
1897
|
+
this.theme = value;
|
|
1898
|
+
document.querySelector('html').dataset.theme = value;
|
|
1899
|
+
localStorage.setItem(LOCALSTORAGE_KEY, value);
|
|
1900
|
+
};
|
|
1901
|
+
const colorSchemeMediaQueryFallback = {
|
|
1902
|
+
addEventListener: () => { },
|
|
1903
|
+
matches: false,
|
|
1904
|
+
};
|
|
1905
|
+
this.colorSchemeMediaQuery =
|
|
1906
|
+
(window.matchMedia &&
|
|
1907
|
+
window.matchMedia('(prefers-color-scheme: dark)')) ||
|
|
1908
|
+
colorSchemeMediaQueryFallback;
|
|
1909
|
+
}
|
|
1910
|
+
connectedCallback() {
|
|
1911
|
+
this.colorSchemeMediaQuery.addEventListener('change', this.handleSystemThemeChange);
|
|
1912
|
+
}
|
|
1913
|
+
disconnectedCallback() {
|
|
1914
|
+
this.colorSchemeMediaQuery.removeEventListener('change', this.handleSystemThemeChange);
|
|
1915
|
+
}
|
|
1916
|
+
componentWillLoad() {
|
|
1917
|
+
this.systemSettingIsDark = this.colorSchemeMediaQuery.matches;
|
|
1918
|
+
this.setTheme((localStorage.getItem(LOCALSTORAGE_KEY) || DEFAULT));
|
|
1919
|
+
}
|
|
1920
|
+
render() {
|
|
1921
|
+
const props = {
|
|
1922
|
+
checked: this.theme === DARK ||
|
|
1923
|
+
(this.theme === DEFAULT && this.systemSettingIsDark),
|
|
1924
|
+
};
|
|
1925
|
+
return (index.h("div", { key: '72bb10f37127840f1e310943a35a6f653bd3859d', class: "mode-toggle" }, index.h("input", { key: '5869df8eadeb50a5e6c7fe41e0ec6f7dfe8be233', type: "checkbox", onChange: this.handleThemeChange, ref: this.getSelectRef, ...props }), index.h("div", { key: '4ca3d61f92b73c9239820eadf411fbb9f4eaab7f', class: "mode-visualization" }, index.h("div", { key: 'e4d99bd1a90298a2a6c634cd2d3cb859c3bbd1bc', class: "circle" }), index.h("div", { key: '4a7e9b0d7d5bfc4c85db8cd50e6200899d81a6fb', class: "ray one" }), index.h("div", { key: 'c489f612cabd963e3ebae26996dd7a71f242e0de', class: "ray two" }), index.h("div", { key: '83288239cf2c67c0ad314728c6c65ffee67f9c1e', class: "ray three" }), index.h("div", { key: '013b3c4c16e8f49d396a7a3e903108304ad17dfe', class: "ray four" }))));
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
DarkmodeSwitch.style = darkmodeSwitchCss;
|
|
1929
|
+
|
|
1930
|
+
const navigationCss = "*,*::before,*::after{box-sizing:border-box}ul[class],ol[class]{padding:0}body,h1,h2,h3,h4,p,ul[class],ol[class],li,figure,figcaption,blockquote,dl,dd{margin:0}ul[class],ol[class]{list-style:none}a:not([class]){text-decoration-skip-ink:auto}img{max-width:100%}input,button,textarea,select{font:inherit}@media (prefers-reduced-motion: reduce){*{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:root{--width-nav-panel:16rem}:host{display:block;font-family:var(--kompendium-font-primary);--size-show-nav-panel-button:2.25rem}header a{text-decoration:none;color:unset}.nav-panel-scrim{display:none;z-index:99;position:fixed;top:0;right:0;bottom:0;left:0}.nav-panel{transition:transform 0.44s cubic-bezier(1, 0.12, 0.2, 0.88), background-color 0.3s ease;width:var(--width-nav-panel);height:100vh;position:fixed;background-color:rgb(var(--kompendium-contrast-400));display:flex;flex-direction:column}.nav-panel .panel-header{transition:border 0.3s ease;flex-direction:row;padding:1rem;border-bottom:1px solid rgb(var(--kompendium-contrast-600));margin-bottom:0.5rem}.nav-panel .panel-list{overflow-y:auto;list-style:none}.nav-panel .panel-list:not(.chapters){padding:0 0.75rem 2rem 0.75rem}.nav-panel .panel-list li{margin-left:0}.nav-panel .panel-list li::before{content:none;display:none}.nav-panel.display-nav-panel{z-index:100}.branding-and-mode{display:flex;align-items:center;margin-bottom:0.75rem}.branding-and-mode h1{all:unset;font-size:1rem;font-weight:normal;color:rgb(var(--kompendium-contrast-900));flex-grow:1;line-height:1}.branding-and-mode a{border-radius:0.125rem}.branding-and-mode a:focus{outline:none}.branding-and-mode a:focus-visible{outline:none;box-shadow:var(--kompendium-shadow-depth-8-focused)}.branding-and-mode kompendium-darkmode-switch{position:relative;flex-shrink:0;margin-left:0.75rem;padding-left:0.5rem}.branding-and-mode kompendium-darkmode-switch:before{transition:background-color 0.3s ease;content:\"\";position:absolute;background-color:rgb(var(--kompendium-contrast-600));border-radius:0.5rem;height:1.25rem;width:0.125rem;left:0.0625rem;top:0;bottom:0;margin:auto}.powered-by{position:absolute;bottom:0;left:0;font-size:0.75rem;padding:0.5rem 0.75rem;background-color:rgba(var(--kompendium-contrast-100), 0.4);backdrop-filter:blur(0.25rem);width:100%}.powered-by p{padding-left:1.75rem;font-size:0.75rem;background-image:url('data:image/svg+xml;utf8,<svg viewBox=\"0 0 148 80\" xmlns=\"http://www.w3.org/2000/svg\" fill-rule=\"evenodd\" clip-rule=\"evenodd\" stroke-linejoin=\"round\" stroke-miterlimit=\"2\"><path fill=\"none\" d=\"M-.003 0h148v80h-148z\"/><path d=\"M148.008 20c0-11.038-8.96-20-19.999-20H19.977c-11.038 0-20 8.962-20 20v40c0 11.038 8.962 20 20 20H128.01c11.038 0 20-8.962 20-20V20z\" fill=\"rgb(36,71,88)\"/><path d=\"M26.564 43.651v14.604H19.26V43.65h7.304zm0-7.302H19.26V21.745h7.304V36.35z\" fill=\"rgb(255,160,0)\"/><path d=\"M106.82 58.254v-7.303h7.304V43.65h7.304v-7.301h-7.304v-7.303h-7.304v-7.302h7.304v7.302h7.304v7.303h7.293v7.301h-7.293v7.302h-7.304v7.303h-7.304zm-43.812 0v-7.303h7.304V43.65h7.304v-7.301h7.303v-7.303h7.293v-7.302h7.304v7.302h-7.304v7.303H84.92v7.301h-7.303v7.302h-7.304v7.303h-7.304zm-14.597 0v-7.303h-7.304V43.65h-7.304v-7.301h7.304v-7.303h7.304v-7.302h7.293v7.302H48.41v7.303h-7.304v7.301h7.304v7.302h7.293v7.303H48.41z\" fill=\"rgb(0,200,82)\"/></svg>');background-position:left center;background-repeat:no-repeat;background-size:1.5rem}.powered-by a{transition:color 0.2s ease;color:rgb(var(--kompendium-color-blue-default));text-decoration:none;font-size:0.75rem}.powered-by a:hover{color:rgb(var(--kompendium-color-blue-light))}.nav-panel__responsive-menu{transition:background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease-out;box-shadow:var(--kompendium-button-shadow-normal)}.nav-panel__responsive-menu:hover{box-shadow:var(--kompendium-button-shadow-hovered)}.nav-panel__responsive-menu:active{box-shadow:var(--kompendium-button-shadow-pressed);transform:translate3d(0, 0.08rem, 0)}.nav-panel__responsive-menu:focus{outline:none}.nav-panel__responsive-menu:focus-visible{outline:none;box-shadow:var(--kompendium-shadow-depth-8-focused)}.nav-panel__responsive-menu{transition:all 0.2s ease;display:none;cursor:pointer;position:absolute;top:0.75rem;right:calc(var(--size-show-nav-panel-button) * -1 - 1rem);width:var(--size-show-nav-panel-button);height:var(--size-show-nav-panel-button);margin:0.25rem;border-radius:50%;text-align:center;font-weight:bold;background-color:rgba(var(--kompendium-contrast-200), 0.7);backdrop-filter:blur(0.25rem);color:rgb(var(--kompendium-contrast-900))}.nav-panel__responsive-menu span{transition:background-color 0.2s ease, transform 0.2s ease 0.3s, opacity 0.15s ease 0.3s;display:block;position:absolute;left:0;right:0;margin:auto;height:0.125rem;width:1rem;border-radius:0.25rem;background-color:rgb(var(--kompendium-contrast-900))}.nav-panel__responsive-menu span:nth-child(1){top:0.75rem}.nav-panel__responsive-menu span:nth-child(2),.nav-panel__responsive-menu span:nth-child(3){top:0;bottom:0}.nav-panel__responsive-menu span:nth-child(4){bottom:0.75rem}.nav-panel__responsive-menu:hover span{background-color:rgb(var(--kompendium-contrast-1200))}@media (max-width: 1000px){.nav-panel-scrim.display-nav-panel{display:block}.nav-panel{transform:translate3d(calc(var(--width-nav-panel) * -1), 0, 0)}.nav-panel.display-nav-panel{transform:translate3d(0, 0, 0);box-shadow:0 0.09375rem 0.225rem 0 rgba(0, 0, 0, 0.232), 0 0.01875rem 0.05625rem 0 rgba(0, 0, 0, 0.208)}.nav-panel.display-nav-panel .nav-panel__responsive-menu{right:calc(var(--size-show-nav-panel-button) * -1 - 0.3125rem);border-radius:0 0.5rem 0.5rem 0}.nav-panel.display-nav-panel .nav-panel__responsive-menu span:nth-child(1),.nav-panel.display-nav-panel .nav-panel__responsive-menu span:nth-child(4){transform:scaleX(0);opacity:0}.nav-panel.display-nav-panel .nav-panel__responsive-menu span:nth-child(2){transform:rotate(45deg)}.nav-panel.display-nav-panel .nav-panel__responsive-menu span:nth-child(3){transform:rotate(-45deg)}.nav-panel__responsive-menu{display:block}}.panel-item{transition:opacity 0.2s ease;width:100%;border-radius:0.375rem}.panel-item.active{background-color:rgb(var(--kompendium-contrast-100), 0.5)}.panel-link{display:grid;grid-auto-flow:column;grid-template-columns:1fr 1.75rem;line-height:1.75rem;color:rgb(var(--kompendium-contrast-900));text-decoration:none;border-radius:0.375rem}.panel-link:hover,.panel-link.active{color:rgb(var(--kompendium-color-blue-default))}.panel-link.active svg{transform:scale(0.64) rotate(-90deg)}.panel-link:focus{outline:none}.panel-link:focus-visible{outline:none;box-shadow:var(--kompendium-shadow-depth-8-focused)}.panel-link svg{visibility:hidden;transition:transform 0.2s ease;transform:scale(0.64) rotate(90deg);height:2rem}.panel-link.has-children svg{visibility:visible}.link-text{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:100%;padding-left:0.5rem}.chapters{height:0}.chapters>.panel-item{padding:0 0.5rem}.chapters:not(.active){visibility:hidden}.chapters.active{transition:height 0.2s ease;height:100%}.chapters.active .panel-item{opacity:1;transition-delay:0.2s}.chapters.active .panel-item:nth-child(1){transition-delay:0s}.chapters.active .panel-item:nth-child(2){transition-delay:0.04s}.chapters.active .panel-item:nth-child(3){transition-delay:0.06s}.chapters.active .panel-item:nth-child(4){transition-delay:0.08s}.chapters.active .panel-item:nth-child(5){transition-delay:0.1s}.chapters.active .panel-item:nth-child(6){transition-delay:0.12s}.chapters.active .panel-item:nth-child(7){transition-delay:0.14s}.chapters.active .panel-item:nth-child(8){transition-delay:0.15s}.chapters.active .panel-item:nth-child(9){transition-delay:0.16s}.chapters.active .panel-item:nth-child(10){transition-delay:0.17s}.chapters.active .panel-item:nth-child(11){transition-delay:0.18s}.chapters.active .panel-item:nth-child(12){transition-delay:0.19s}.chapters.active .panel-item:last-child{margin-bottom:0.5rem}.chapters .panel-link.has-children svg{visibility:hidden}.chapters .panel-item{opacity:0}.chapters .panel-item .chapters{font-size:0.8125rem;padding-left:0.5rem}.chapters .panel-item .chapters:first-child{margin-top:0.25rem}";
|
|
1931
|
+
|
|
1932
|
+
const Navigation = class {
|
|
1933
|
+
constructor(hostRef) {
|
|
1934
|
+
index.registerInstance(this, hostRef);
|
|
1935
|
+
this.route = '';
|
|
1936
|
+
this.displayNavPanel = false;
|
|
1937
|
+
this.toggleMenu = () => {
|
|
1938
|
+
this.displayNavPanel = !this.displayNavPanel;
|
|
1939
|
+
};
|
|
1940
|
+
this.stopPropagationOfNavClick = (event) => {
|
|
1941
|
+
event.stopPropagation();
|
|
1942
|
+
};
|
|
1943
|
+
this.setRoute = this.setRoute.bind(this);
|
|
1944
|
+
this.renderMenuItem = this.renderMenuItem.bind(this);
|
|
1945
|
+
}
|
|
1946
|
+
connectedCallback() {
|
|
1947
|
+
window.addEventListener('hashchange', this.setRoute);
|
|
1948
|
+
this.setRoute();
|
|
1949
|
+
}
|
|
1950
|
+
disconnectedCallback() {
|
|
1951
|
+
window.removeEventListener('hashchange', this.setRoute);
|
|
1952
|
+
}
|
|
1953
|
+
setRoute() {
|
|
1954
|
+
this.route = location.hash.substr(1);
|
|
1955
|
+
}
|
|
1956
|
+
render() {
|
|
1957
|
+
return [
|
|
1958
|
+
index.h("div", { key: '0abf57dba46d2c55f777e6b0a62756f1531b716a', class: {
|
|
1959
|
+
'nav-panel-scrim': true,
|
|
1960
|
+
'display-nav-panel': this.displayNavPanel,
|
|
1961
|
+
}, onClick: this.toggleMenu }),
|
|
1962
|
+
index.h("nav", { key: '47f1e62abae92f0ee5a90a980f79b5cec0508364', class: {
|
|
1963
|
+
'nav-panel': true,
|
|
1964
|
+
'display-nav-panel': this.displayNavPanel,
|
|
1965
|
+
}, onClick: this.stopPropagationOfNavClick }, index.h("a", { key: '25fd2d738007fc596447cf4ac0a2bbbcf92df332', class: "nav-panel__responsive-menu", onClick: this.toggleMenu }, index.h("span", { key: '2b4056f7793e879a86bd0ed40ce45366d891cf5a' }), index.h("span", { key: 'c2174de261be61fa807e8b6dadcf6b7119bbec30' }), index.h("span", { key: 'd755597e3c961b057f7ed4cb042aa45c8ca336c1' }), index.h("span", { key: 'a3442946e847e5b870afc0dcce8baf47cc4fb03a' })), index.h("header", { key: '46a15de390a19d9cb9b0bd8973e82b4c33bb6d62', class: "panel-header" }, index.h("div", { key: '3c280f8409cef9848c3e58c6ac907a4e6ae53a8e', class: "branding-and-mode" }, index.h("h1", { key: 'c38675cafe5bdf1a119a3e06cdca78f5d5ad5b25' }, this.renderHeader()), index.h("kompendium-darkmode-switch", { key: 'ec6564ee68633fffabc3deecf34a09d431d7634a' })), index.h("kompendium-search", { key: '8aa459ff257cc6a1adb726ca4b6b4cdf397ccb57', index: this.index })), this.renderChapters(this.menu)),
|
|
1966
|
+
];
|
|
1967
|
+
}
|
|
1968
|
+
renderHeader() {
|
|
1969
|
+
let content = this.header;
|
|
1970
|
+
if (this.logo) {
|
|
1971
|
+
content = index.h("img", { alt: this.header, src: this.logo });
|
|
1972
|
+
}
|
|
1973
|
+
return index.h("a", { href: "#" }, content);
|
|
1974
|
+
}
|
|
1975
|
+
renderChapters(menu) {
|
|
1976
|
+
if (!menu || !menu.length) {
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
return (index.h("ul", { class: "panel-list" }, menu.map(this.renderMenuItem), index.h("div", { class: "powered-by" }, index.h("p", null, "Powered by\u00A0", index.h("a", { href: "https://github.com/jgroth/kompendium" }, "Kompendium")))));
|
|
1980
|
+
}
|
|
1981
|
+
renderMenuItem(item) {
|
|
1982
|
+
const itemClassList = {
|
|
1983
|
+
active: this.isRouteActive(item.path),
|
|
1984
|
+
'panel-item': true,
|
|
1985
|
+
};
|
|
1986
|
+
const chapterClassList = {
|
|
1987
|
+
active: this.isRouteActive(item.path),
|
|
1988
|
+
chapters: true,
|
|
1989
|
+
'panel-list': true,
|
|
1990
|
+
};
|
|
1991
|
+
const chapters = item.children || [];
|
|
1992
|
+
const anchorClassList = {
|
|
1993
|
+
'panel-link': true,
|
|
1994
|
+
active: this.isRouteActive(item.path),
|
|
1995
|
+
'has-children': !!chapters.length,
|
|
1996
|
+
};
|
|
1997
|
+
const anchorAdditionalProps = {};
|
|
1998
|
+
if (!chapters.length) {
|
|
1999
|
+
anchorAdditionalProps.onClick = this.toggleMenu;
|
|
2000
|
+
}
|
|
2001
|
+
return (index.h("li", { class: itemClassList }, index.h("a", { class: anchorClassList, href: '#' + item.path, ...anchorAdditionalProps }, index.h("span", { class: "link-text" }, item.title), index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24" }, index.h("path", { fill: "none", d: "M0 0h24v24H0z" }), index.h("path", { id: "arrow", d: "M13.172 12l-4.95-4.95 1.414-1.414L16 12l-6.364 6.364-1.414-1.414z", fill: "currentColor" }))), index.h("ul", { class: chapterClassList }, chapters.map(this.renderMenuItem))));
|
|
2002
|
+
}
|
|
2003
|
+
isRouteActive(route) {
|
|
2004
|
+
return this.route.startsWith(route);
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
Navigation.style = navigationCss;
|
|
2008
|
+
|
|
2009
|
+
/**
|
|
2010
|
+
* Checks if `value` is the
|
|
2011
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
2012
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
2013
|
+
*
|
|
2014
|
+
* @static
|
|
2015
|
+
* @memberOf _
|
|
2016
|
+
* @since 0.1.0
|
|
2017
|
+
* @category Lang
|
|
2018
|
+
* @param {*} value The value to check.
|
|
2019
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
2020
|
+
* @example
|
|
2021
|
+
*
|
|
2022
|
+
* _.isObject({});
|
|
2023
|
+
* // => true
|
|
2024
|
+
*
|
|
2025
|
+
* _.isObject([1, 2, 3]);
|
|
2026
|
+
* // => true
|
|
2027
|
+
*
|
|
2028
|
+
* _.isObject(_.noop);
|
|
2029
|
+
* // => true
|
|
2030
|
+
*
|
|
2031
|
+
* _.isObject(null);
|
|
2032
|
+
* // => false
|
|
2033
|
+
*/
|
|
2034
|
+
|
|
2035
|
+
var isObject_1;
|
|
2036
|
+
var hasRequiredIsObject;
|
|
2037
|
+
|
|
2038
|
+
function requireIsObject () {
|
|
2039
|
+
if (hasRequiredIsObject) return isObject_1;
|
|
2040
|
+
hasRequiredIsObject = 1;
|
|
2041
|
+
function isObject(value) {
|
|
2042
|
+
var type = typeof value;
|
|
2043
|
+
return value != null && (type == 'object' || type == 'function');
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
isObject_1 = isObject;
|
|
2047
|
+
return isObject_1;
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
/** Detect free variable `global` from Node.js. */
|
|
2051
|
+
|
|
2052
|
+
var _freeGlobal;
|
|
2053
|
+
var hasRequired_freeGlobal;
|
|
2054
|
+
|
|
2055
|
+
function require_freeGlobal () {
|
|
2056
|
+
if (hasRequired_freeGlobal) return _freeGlobal;
|
|
2057
|
+
hasRequired_freeGlobal = 1;
|
|
2058
|
+
var freeGlobal = typeof _commonjsHelpers.commonjsGlobal == 'object' && _commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.Object === Object && _commonjsHelpers.commonjsGlobal;
|
|
2059
|
+
|
|
2060
|
+
_freeGlobal = freeGlobal;
|
|
2061
|
+
return _freeGlobal;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
var _root;
|
|
2065
|
+
var hasRequired_root;
|
|
2066
|
+
|
|
2067
|
+
function require_root () {
|
|
2068
|
+
if (hasRequired_root) return _root;
|
|
2069
|
+
hasRequired_root = 1;
|
|
2070
|
+
var freeGlobal = require_freeGlobal();
|
|
2071
|
+
|
|
2072
|
+
/** Detect free variable `self`. */
|
|
2073
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
2074
|
+
|
|
2075
|
+
/** Used as a reference to the global object. */
|
|
2076
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
2077
|
+
|
|
2078
|
+
_root = root;
|
|
2079
|
+
return _root;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
var now_1;
|
|
2083
|
+
var hasRequiredNow;
|
|
2084
|
+
|
|
2085
|
+
function requireNow () {
|
|
2086
|
+
if (hasRequiredNow) return now_1;
|
|
2087
|
+
hasRequiredNow = 1;
|
|
2088
|
+
var root = require_root();
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
2092
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
2093
|
+
*
|
|
2094
|
+
* @static
|
|
2095
|
+
* @memberOf _
|
|
2096
|
+
* @since 2.4.0
|
|
2097
|
+
* @category Date
|
|
2098
|
+
* @returns {number} Returns the timestamp.
|
|
2099
|
+
* @example
|
|
2100
|
+
*
|
|
2101
|
+
* _.defer(function(stamp) {
|
|
2102
|
+
* console.log(_.now() - stamp);
|
|
2103
|
+
* }, _.now());
|
|
2104
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
2105
|
+
*/
|
|
2106
|
+
var now = function() {
|
|
2107
|
+
return root.Date.now();
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
now_1 = now;
|
|
2111
|
+
return now_1;
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
/** Used to match a single whitespace character. */
|
|
2115
|
+
|
|
2116
|
+
var _trimmedEndIndex;
|
|
2117
|
+
var hasRequired_trimmedEndIndex;
|
|
2118
|
+
|
|
2119
|
+
function require_trimmedEndIndex () {
|
|
2120
|
+
if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
|
|
2121
|
+
hasRequired_trimmedEndIndex = 1;
|
|
2122
|
+
var reWhitespace = /\s/;
|
|
2123
|
+
|
|
2124
|
+
/**
|
|
2125
|
+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
2126
|
+
* character of `string`.
|
|
2127
|
+
*
|
|
2128
|
+
* @private
|
|
2129
|
+
* @param {string} string The string to inspect.
|
|
2130
|
+
* @returns {number} Returns the index of the last non-whitespace character.
|
|
2131
|
+
*/
|
|
2132
|
+
function trimmedEndIndex(string) {
|
|
2133
|
+
var index = string.length;
|
|
2134
|
+
|
|
2135
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
2136
|
+
return index;
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
_trimmedEndIndex = trimmedEndIndex;
|
|
2140
|
+
return _trimmedEndIndex;
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
var _baseTrim;
|
|
2144
|
+
var hasRequired_baseTrim;
|
|
2145
|
+
|
|
2146
|
+
function require_baseTrim () {
|
|
2147
|
+
if (hasRequired_baseTrim) return _baseTrim;
|
|
2148
|
+
hasRequired_baseTrim = 1;
|
|
2149
|
+
var trimmedEndIndex = require_trimmedEndIndex();
|
|
2150
|
+
|
|
2151
|
+
/** Used to match leading whitespace. */
|
|
2152
|
+
var reTrimStart = /^\s+/;
|
|
2153
|
+
|
|
2154
|
+
/**
|
|
2155
|
+
* The base implementation of `_.trim`.
|
|
2156
|
+
*
|
|
2157
|
+
* @private
|
|
2158
|
+
* @param {string} string The string to trim.
|
|
2159
|
+
* @returns {string} Returns the trimmed string.
|
|
2160
|
+
*/
|
|
2161
|
+
function baseTrim(string) {
|
|
2162
|
+
return string
|
|
2163
|
+
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
2164
|
+
: string;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
_baseTrim = baseTrim;
|
|
2168
|
+
return _baseTrim;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
var _Symbol;
|
|
2172
|
+
var hasRequired_Symbol;
|
|
2173
|
+
|
|
2174
|
+
function require_Symbol () {
|
|
2175
|
+
if (hasRequired_Symbol) return _Symbol;
|
|
2176
|
+
hasRequired_Symbol = 1;
|
|
2177
|
+
var root = require_root();
|
|
2178
|
+
|
|
2179
|
+
/** Built-in value references. */
|
|
2180
|
+
var Symbol = root.Symbol;
|
|
2181
|
+
|
|
2182
|
+
_Symbol = Symbol;
|
|
2183
|
+
return _Symbol;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
var _getRawTag;
|
|
2187
|
+
var hasRequired_getRawTag;
|
|
2188
|
+
|
|
2189
|
+
function require_getRawTag () {
|
|
2190
|
+
if (hasRequired_getRawTag) return _getRawTag;
|
|
2191
|
+
hasRequired_getRawTag = 1;
|
|
2192
|
+
var Symbol = require_Symbol();
|
|
2193
|
+
|
|
2194
|
+
/** Used for built-in method references. */
|
|
2195
|
+
var objectProto = Object.prototype;
|
|
2196
|
+
|
|
2197
|
+
/** Used to check objects for own properties. */
|
|
2198
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2199
|
+
|
|
2200
|
+
/**
|
|
2201
|
+
* Used to resolve the
|
|
2202
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
2203
|
+
* of values.
|
|
2204
|
+
*/
|
|
2205
|
+
var nativeObjectToString = objectProto.toString;
|
|
2206
|
+
|
|
2207
|
+
/** Built-in value references. */
|
|
2208
|
+
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
2209
|
+
|
|
2210
|
+
/**
|
|
2211
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
2212
|
+
*
|
|
2213
|
+
* @private
|
|
2214
|
+
* @param {*} value The value to query.
|
|
2215
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
2216
|
+
*/
|
|
2217
|
+
function getRawTag(value) {
|
|
2218
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag),
|
|
2219
|
+
tag = value[symToStringTag];
|
|
2220
|
+
|
|
2221
|
+
try {
|
|
2222
|
+
value[symToStringTag] = undefined;
|
|
2223
|
+
var unmasked = true;
|
|
2224
|
+
} catch (e) {}
|
|
2225
|
+
|
|
2226
|
+
var result = nativeObjectToString.call(value);
|
|
2227
|
+
if (unmasked) {
|
|
2228
|
+
if (isOwn) {
|
|
2229
|
+
value[symToStringTag] = tag;
|
|
2230
|
+
} else {
|
|
2231
|
+
delete value[symToStringTag];
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
return result;
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
_getRawTag = getRawTag;
|
|
2238
|
+
return _getRawTag;
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
/** Used for built-in method references. */
|
|
2242
|
+
|
|
2243
|
+
var _objectToString;
|
|
2244
|
+
var hasRequired_objectToString;
|
|
2245
|
+
|
|
2246
|
+
function require_objectToString () {
|
|
2247
|
+
if (hasRequired_objectToString) return _objectToString;
|
|
2248
|
+
hasRequired_objectToString = 1;
|
|
2249
|
+
var objectProto = Object.prototype;
|
|
2250
|
+
|
|
2251
|
+
/**
|
|
2252
|
+
* Used to resolve the
|
|
2253
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
2254
|
+
* of values.
|
|
2255
|
+
*/
|
|
2256
|
+
var nativeObjectToString = objectProto.toString;
|
|
2257
|
+
|
|
2258
|
+
/**
|
|
2259
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
2260
|
+
*
|
|
2261
|
+
* @private
|
|
2262
|
+
* @param {*} value The value to convert.
|
|
2263
|
+
* @returns {string} Returns the converted string.
|
|
2264
|
+
*/
|
|
2265
|
+
function objectToString(value) {
|
|
2266
|
+
return nativeObjectToString.call(value);
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
_objectToString = objectToString;
|
|
2270
|
+
return _objectToString;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
var _baseGetTag;
|
|
2274
|
+
var hasRequired_baseGetTag;
|
|
2275
|
+
|
|
2276
|
+
function require_baseGetTag () {
|
|
2277
|
+
if (hasRequired_baseGetTag) return _baseGetTag;
|
|
2278
|
+
hasRequired_baseGetTag = 1;
|
|
2279
|
+
var Symbol = require_Symbol(),
|
|
2280
|
+
getRawTag = require_getRawTag(),
|
|
2281
|
+
objectToString = require_objectToString();
|
|
2282
|
+
|
|
2283
|
+
/** `Object#toString` result references. */
|
|
2284
|
+
var nullTag = '[object Null]',
|
|
2285
|
+
undefinedTag = '[object Undefined]';
|
|
2286
|
+
|
|
2287
|
+
/** Built-in value references. */
|
|
2288
|
+
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
2289
|
+
|
|
2290
|
+
/**
|
|
2291
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
2292
|
+
*
|
|
2293
|
+
* @private
|
|
2294
|
+
* @param {*} value The value to query.
|
|
2295
|
+
* @returns {string} Returns the `toStringTag`.
|
|
2296
|
+
*/
|
|
2297
|
+
function baseGetTag(value) {
|
|
2298
|
+
if (value == null) {
|
|
2299
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
2300
|
+
}
|
|
2301
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
2302
|
+
? getRawTag(value)
|
|
2303
|
+
: objectToString(value);
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
_baseGetTag = baseGetTag;
|
|
2307
|
+
return _baseGetTag;
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
/**
|
|
2311
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
2312
|
+
* and has a `typeof` result of "object".
|
|
2313
|
+
*
|
|
2314
|
+
* @static
|
|
2315
|
+
* @memberOf _
|
|
2316
|
+
* @since 4.0.0
|
|
2317
|
+
* @category Lang
|
|
2318
|
+
* @param {*} value The value to check.
|
|
2319
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
2320
|
+
* @example
|
|
2321
|
+
*
|
|
2322
|
+
* _.isObjectLike({});
|
|
2323
|
+
* // => true
|
|
2324
|
+
*
|
|
2325
|
+
* _.isObjectLike([1, 2, 3]);
|
|
2326
|
+
* // => true
|
|
2327
|
+
*
|
|
2328
|
+
* _.isObjectLike(_.noop);
|
|
2329
|
+
* // => false
|
|
2330
|
+
*
|
|
2331
|
+
* _.isObjectLike(null);
|
|
2332
|
+
* // => false
|
|
2333
|
+
*/
|
|
2334
|
+
|
|
2335
|
+
var isObjectLike_1;
|
|
2336
|
+
var hasRequiredIsObjectLike;
|
|
2337
|
+
|
|
2338
|
+
function requireIsObjectLike () {
|
|
2339
|
+
if (hasRequiredIsObjectLike) return isObjectLike_1;
|
|
2340
|
+
hasRequiredIsObjectLike = 1;
|
|
2341
|
+
function isObjectLike(value) {
|
|
2342
|
+
return value != null && typeof value == 'object';
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
isObjectLike_1 = isObjectLike;
|
|
2346
|
+
return isObjectLike_1;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
var isSymbol_1;
|
|
2350
|
+
var hasRequiredIsSymbol;
|
|
2351
|
+
|
|
2352
|
+
function requireIsSymbol () {
|
|
2353
|
+
if (hasRequiredIsSymbol) return isSymbol_1;
|
|
2354
|
+
hasRequiredIsSymbol = 1;
|
|
2355
|
+
var baseGetTag = require_baseGetTag(),
|
|
2356
|
+
isObjectLike = requireIsObjectLike();
|
|
2357
|
+
|
|
2358
|
+
/** `Object#toString` result references. */
|
|
2359
|
+
var symbolTag = '[object Symbol]';
|
|
2360
|
+
|
|
2361
|
+
/**
|
|
2362
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
2363
|
+
*
|
|
2364
|
+
* @static
|
|
2365
|
+
* @memberOf _
|
|
2366
|
+
* @since 4.0.0
|
|
2367
|
+
* @category Lang
|
|
2368
|
+
* @param {*} value The value to check.
|
|
2369
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
2370
|
+
* @example
|
|
2371
|
+
*
|
|
2372
|
+
* _.isSymbol(Symbol.iterator);
|
|
2373
|
+
* // => true
|
|
2374
|
+
*
|
|
2375
|
+
* _.isSymbol('abc');
|
|
2376
|
+
* // => false
|
|
2377
|
+
*/
|
|
2378
|
+
function isSymbol(value) {
|
|
2379
|
+
return typeof value == 'symbol' ||
|
|
2380
|
+
(isObjectLike(value) && baseGetTag(value) == symbolTag);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
isSymbol_1 = isSymbol;
|
|
2384
|
+
return isSymbol_1;
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
var toNumber_1;
|
|
2388
|
+
var hasRequiredToNumber;
|
|
2389
|
+
|
|
2390
|
+
function requireToNumber () {
|
|
2391
|
+
if (hasRequiredToNumber) return toNumber_1;
|
|
2392
|
+
hasRequiredToNumber = 1;
|
|
2393
|
+
var baseTrim = require_baseTrim(),
|
|
2394
|
+
isObject = requireIsObject(),
|
|
2395
|
+
isSymbol = requireIsSymbol();
|
|
2396
|
+
|
|
2397
|
+
/** Used as references for various `Number` constants. */
|
|
2398
|
+
var NAN = 0 / 0;
|
|
2399
|
+
|
|
2400
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
2401
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
2402
|
+
|
|
2403
|
+
/** Used to detect binary string values. */
|
|
2404
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
2405
|
+
|
|
2406
|
+
/** Used to detect octal string values. */
|
|
2407
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
2408
|
+
|
|
2409
|
+
/** Built-in method references without a dependency on `root`. */
|
|
2410
|
+
var freeParseInt = parseInt;
|
|
2411
|
+
|
|
2412
|
+
/**
|
|
2413
|
+
* Converts `value` to a number.
|
|
2414
|
+
*
|
|
2415
|
+
* @static
|
|
2416
|
+
* @memberOf _
|
|
2417
|
+
* @since 4.0.0
|
|
2418
|
+
* @category Lang
|
|
2419
|
+
* @param {*} value The value to process.
|
|
2420
|
+
* @returns {number} Returns the number.
|
|
2421
|
+
* @example
|
|
2422
|
+
*
|
|
2423
|
+
* _.toNumber(3.2);
|
|
2424
|
+
* // => 3.2
|
|
2425
|
+
*
|
|
2426
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
2427
|
+
* // => 5e-324
|
|
2428
|
+
*
|
|
2429
|
+
* _.toNumber(Infinity);
|
|
2430
|
+
* // => Infinity
|
|
2431
|
+
*
|
|
2432
|
+
* _.toNumber('3.2');
|
|
2433
|
+
* // => 3.2
|
|
2434
|
+
*/
|
|
2435
|
+
function toNumber(value) {
|
|
2436
|
+
if (typeof value == 'number') {
|
|
2437
|
+
return value;
|
|
2438
|
+
}
|
|
2439
|
+
if (isSymbol(value)) {
|
|
2440
|
+
return NAN;
|
|
2441
|
+
}
|
|
2442
|
+
if (isObject(value)) {
|
|
2443
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
2444
|
+
value = isObject(other) ? (other + '') : other;
|
|
2445
|
+
}
|
|
2446
|
+
if (typeof value != 'string') {
|
|
2447
|
+
return value === 0 ? value : +value;
|
|
2448
|
+
}
|
|
2449
|
+
value = baseTrim(value);
|
|
2450
|
+
var isBinary = reIsBinary.test(value);
|
|
2451
|
+
return (isBinary || reIsOctal.test(value))
|
|
2452
|
+
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
2453
|
+
: (reIsBadHex.test(value) ? NAN : +value);
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
toNumber_1 = toNumber;
|
|
2457
|
+
return toNumber_1;
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
var debounce_1;
|
|
2461
|
+
var hasRequiredDebounce;
|
|
2462
|
+
|
|
2463
|
+
function requireDebounce () {
|
|
2464
|
+
if (hasRequiredDebounce) return debounce_1;
|
|
2465
|
+
hasRequiredDebounce = 1;
|
|
2466
|
+
var isObject = requireIsObject(),
|
|
2467
|
+
now = requireNow(),
|
|
2468
|
+
toNumber = requireToNumber();
|
|
2469
|
+
|
|
2470
|
+
/** Error message constants. */
|
|
2471
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
2472
|
+
|
|
2473
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
2474
|
+
var nativeMax = Math.max,
|
|
2475
|
+
nativeMin = Math.min;
|
|
2476
|
+
|
|
2477
|
+
/**
|
|
2478
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
2479
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
2480
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
2481
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
2482
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
2483
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
2484
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
2485
|
+
* calls to the debounced function return the result of the last `func`
|
|
2486
|
+
* invocation.
|
|
2487
|
+
*
|
|
2488
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
2489
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
2490
|
+
* is invoked more than once during the `wait` timeout.
|
|
2491
|
+
*
|
|
2492
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
2493
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
2494
|
+
*
|
|
2495
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
2496
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
2497
|
+
*
|
|
2498
|
+
* @static
|
|
2499
|
+
* @memberOf _
|
|
2500
|
+
* @since 0.1.0
|
|
2501
|
+
* @category Function
|
|
2502
|
+
* @param {Function} func The function to debounce.
|
|
2503
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
2504
|
+
* @param {Object} [options={}] The options object.
|
|
2505
|
+
* @param {boolean} [options.leading=false]
|
|
2506
|
+
* Specify invoking on the leading edge of the timeout.
|
|
2507
|
+
* @param {number} [options.maxWait]
|
|
2508
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
2509
|
+
* @param {boolean} [options.trailing=true]
|
|
2510
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
2511
|
+
* @returns {Function} Returns the new debounced function.
|
|
2512
|
+
* @example
|
|
2513
|
+
*
|
|
2514
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
2515
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
2516
|
+
*
|
|
2517
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
2518
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
2519
|
+
* 'leading': true,
|
|
2520
|
+
* 'trailing': false
|
|
2521
|
+
* }));
|
|
2522
|
+
*
|
|
2523
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
2524
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
2525
|
+
* var source = new EventSource('/stream');
|
|
2526
|
+
* jQuery(source).on('message', debounced);
|
|
2527
|
+
*
|
|
2528
|
+
* // Cancel the trailing debounced invocation.
|
|
2529
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
2530
|
+
*/
|
|
2531
|
+
function debounce(func, wait, options) {
|
|
2532
|
+
var lastArgs,
|
|
2533
|
+
lastThis,
|
|
2534
|
+
maxWait,
|
|
2535
|
+
result,
|
|
2536
|
+
timerId,
|
|
2537
|
+
lastCallTime,
|
|
2538
|
+
lastInvokeTime = 0,
|
|
2539
|
+
leading = false,
|
|
2540
|
+
maxing = false,
|
|
2541
|
+
trailing = true;
|
|
2542
|
+
|
|
2543
|
+
if (typeof func != 'function') {
|
|
2544
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
2545
|
+
}
|
|
2546
|
+
wait = toNumber(wait) || 0;
|
|
2547
|
+
if (isObject(options)) {
|
|
2548
|
+
leading = !!options.leading;
|
|
2549
|
+
maxing = 'maxWait' in options;
|
|
2550
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
2551
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
function invokeFunc(time) {
|
|
2555
|
+
var args = lastArgs,
|
|
2556
|
+
thisArg = lastThis;
|
|
2557
|
+
|
|
2558
|
+
lastArgs = lastThis = undefined;
|
|
2559
|
+
lastInvokeTime = time;
|
|
2560
|
+
result = func.apply(thisArg, args);
|
|
2561
|
+
return result;
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
function leadingEdge(time) {
|
|
2565
|
+
// Reset any `maxWait` timer.
|
|
2566
|
+
lastInvokeTime = time;
|
|
2567
|
+
// Start the timer for the trailing edge.
|
|
2568
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2569
|
+
// Invoke the leading edge.
|
|
2570
|
+
return leading ? invokeFunc(time) : result;
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
function remainingWait(time) {
|
|
2574
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
2575
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
|
2576
|
+
timeWaiting = wait - timeSinceLastCall;
|
|
2577
|
+
|
|
2578
|
+
return maxing
|
|
2579
|
+
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
2580
|
+
: timeWaiting;
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
function shouldInvoke(time) {
|
|
2584
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
2585
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
|
2586
|
+
|
|
2587
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
2588
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
2589
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
2590
|
+
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
2591
|
+
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
function timerExpired() {
|
|
2595
|
+
var time = now();
|
|
2596
|
+
if (shouldInvoke(time)) {
|
|
2597
|
+
return trailingEdge(time);
|
|
2598
|
+
}
|
|
2599
|
+
// Restart the timer.
|
|
2600
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
function trailingEdge(time) {
|
|
2604
|
+
timerId = undefined;
|
|
2605
|
+
|
|
2606
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
2607
|
+
// debounced at least once.
|
|
2608
|
+
if (trailing && lastArgs) {
|
|
2609
|
+
return invokeFunc(time);
|
|
2610
|
+
}
|
|
2611
|
+
lastArgs = lastThis = undefined;
|
|
2612
|
+
return result;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
function cancel() {
|
|
2616
|
+
if (timerId !== undefined) {
|
|
2617
|
+
clearTimeout(timerId);
|
|
2618
|
+
}
|
|
2619
|
+
lastInvokeTime = 0;
|
|
2620
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
function flush() {
|
|
2624
|
+
return timerId === undefined ? result : trailingEdge(now());
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
function debounced() {
|
|
2628
|
+
var time = now(),
|
|
2629
|
+
isInvoking = shouldInvoke(time);
|
|
2630
|
+
|
|
2631
|
+
lastArgs = arguments;
|
|
2632
|
+
lastThis = this;
|
|
2633
|
+
lastCallTime = time;
|
|
2634
|
+
|
|
2635
|
+
if (isInvoking) {
|
|
2636
|
+
if (timerId === undefined) {
|
|
2637
|
+
return leadingEdge(lastCallTime);
|
|
2638
|
+
}
|
|
2639
|
+
if (maxing) {
|
|
2640
|
+
// Handle invocations in a tight loop.
|
|
2641
|
+
clearTimeout(timerId);
|
|
2642
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2643
|
+
return invokeFunc(lastCallTime);
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
if (timerId === undefined) {
|
|
2647
|
+
timerId = setTimeout(timerExpired, wait);
|
|
2648
|
+
}
|
|
2649
|
+
return result;
|
|
2650
|
+
}
|
|
2651
|
+
debounced.cancel = cancel;
|
|
2652
|
+
debounced.flush = flush;
|
|
2653
|
+
return debounced;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
debounce_1 = debounce;
|
|
2657
|
+
return debounce_1;
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
var debounceExports = requireDebounce();
|
|
2661
|
+
var debounce = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(debounceExports);
|
|
2662
|
+
|
|
2663
|
+
const searchCss = "*,*::before,*::after{box-sizing:border-box}ul[class],ol[class]{padding:0}body,h1,h2,h3,h4,p,ul[class],ol[class],li,figure,figcaption,blockquote,dl,dd{margin:0}ul[class],ol[class]{list-style:none}a:not([class]){text-decoration-skip-ink:auto}img{max-width:100%}input,button,textarea,select{font:inherit}@media (prefers-reduced-motion: reduce){*{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{display:block}:host(:focus) .result.has-results,:host(:focus-within) .result.has-results{display:block}@keyframes display-search-results{0%{opacity:0;transform:translate3d(0, -1.25rem, -1rem) rotateX(10deg)}50%{opacity:1}100%{transform:translate3d(0, 0, 0) rotateX(0)}}.search-box{z-index:1;display:flex;flex-direction:column;position:relative;perspective:60rem}.search-box .result.has-results{animation:display-search-results 0.28s ease-out forwards;position:absolute;background:rgb(var(--kompendium-contrast-200));padding:0.5rem;margin-top:2rem;width:100%;border-radius:5px;box-shadow:var(--kompendium-shadow-depth-16);display:none;max-height:calc(100vh - 6rem);overflow-y:auto}.search-box .result.has-results li a{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease-out}.search-box .result.has-results li a:hover{box-shadow:var(--kompendium-button-shadow-hovered)}.search-box .result.has-results li a:active{box-shadow:var(--kompendium-button-shadow-pressed);transform:translate3d(0, 0.08rem, 0)}.search-box .result.has-results li a:focus{outline:none}.search-box .result.has-results li a:focus-visible{outline:none;box-shadow:var(--kompendium-shadow-depth-8-focused)}.search-box .result.has-results li a{display:block;width:100%;padding:0.5rem 0.75rem;border-radius:0.25rem}.search-box .result.has-results li:hover a{background:rgb(var(--kompendium-contrast-100))}input{transition:background-color 0.2s ease;border:0;border-radius:0.25rem;padding:0 0.25rem 0 2.25rem;color:rgb(var(--kompendium-contrast-1200));height:2rem;line-height:2rem;-webkit-appearance:textfield;background-color:rgb(var(--kompendium-contrast-300));background-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" fill-rule=\"evenodd\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-miterlimit=\"1.5\" clip-rule=\"evenodd\" viewBox=\"0 0 400 400\"><defs/><path fill=\"none\" d=\"M0 0h400v400H0z\"/><path d=\"M275.621 258.31l-16.962 16.979 50.965 50.964.008.009c4.637 4.637 12.268 4.637 16.905 0l.032-.033c4.687-4.687 4.642-12.33.025-16.946l-50.964-50.965-.009-.008z\" fill=\"rgb(48,48,66)\"/><circle cx=\"200\" cy=\"200\" r=\"99.5\" fill=\"rgb(33,150,243)\" fill-opacity=\".3\" stroke=\"rgb(48,48,66)\" stroke-width=\"13.27\" transform=\"translate(19.096 19.096) scale(.90452)\"/><ellipse cx=\"163.443\" cy=\"186.777\" rx=\"32.324\" ry=\"22.133\" fill=\"rgb(255,255,255)\" fill-opacity=\".3\" transform=\"rotate(-45 128.405 173.5)\"/></svg>');background-repeat:no-repeat;background-position:left center}input::placeholder{color:rgb(var(--kompendium-contrast-800))}input:active,input:focus,input:hover{background-color:rgb(var(--kompendium-contrast-200))}input:focus{outline:none}input::-webkit-search-cancel-button{-webkit-appearance:none;transition:background-color 0.2s ease;height:1.25rem;width:1.25rem;border-radius:50%;cursor:pointer;background-color:rgb(var(--kompendium-contrast-800));background-repeat:no-repeat;background-position:center;background-size:0.75rem;background-image:url(\"data:image/svg+xml; utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><defs/><path fill='rgb(255,255,255)' d='M7.219 5.781L5.78 7.22 14.563 16 5.78 24.781 7.22 26.22 16 17.437l8.781 8.782 1.438-1.438L17.437 16l8.782-8.781L24.78 5.78 16 14.563z'/></svg>\")}input::-webkit-search-cancel-button:hover{background-color:rgb(var(--kompendium-contrast-1000))}a{text-decoration:none;color:unset}a:hover,a.active{color:rgb(var(--kompendium-color-blue-default))}";
|
|
2664
|
+
|
|
2665
|
+
const Search = class {
|
|
2666
|
+
constructor(hostRef) {
|
|
2667
|
+
index.registerInstance(this, hostRef);
|
|
2668
|
+
this.documents = [];
|
|
2669
|
+
this.renderDocument = (document) => {
|
|
2670
|
+
return (index.h("li", null, index.h("a", { href: '#' + document.path, onClick: this.handleLinkClick }, index.h("span", { class: "link-text" }, document.title))));
|
|
2671
|
+
};
|
|
2672
|
+
this.handleChangeInput = (event) => {
|
|
2673
|
+
const query = event.target.value;
|
|
2674
|
+
this.search(query);
|
|
2675
|
+
};
|
|
2676
|
+
this.handleLinkClick = () => {
|
|
2677
|
+
var _a;
|
|
2678
|
+
(_a = this.host.shadowRoot.activeElement) === null || _a === void 0 ? void 0 : _a.blur();
|
|
2679
|
+
};
|
|
2680
|
+
this.search = debounce(this.search, 300);
|
|
2681
|
+
}
|
|
2682
|
+
componentDidLoad() {
|
|
2683
|
+
this.host.shadowRoot.querySelector('input').focus();
|
|
2684
|
+
}
|
|
2685
|
+
render() {
|
|
2686
|
+
const classList = {
|
|
2687
|
+
result: true,
|
|
2688
|
+
'has-results': this.documents.length > 0,
|
|
2689
|
+
};
|
|
2690
|
+
return (index.h("div", { key: '8085f45b0d1f5e7b50d20de0df3aa95068598fa2', class: "search-box" }, index.h("input", { key: 'cc001b093b727306c6ea4e8ac078a4f408a0a6c9', type: "search", autoFocus: true, placeholder: "Search", onInput: this.handleChangeInput }), index.h("ul", { key: '7b293d633cd2493c85db58d84f8308e98061ab42', class: classList }, this.documents.map(this.renderDocument))));
|
|
2691
|
+
}
|
|
2692
|
+
search(query) {
|
|
2693
|
+
const index = this.index;
|
|
2694
|
+
const result = index.search(query);
|
|
2695
|
+
this.documents = result.map((doc) => doc.item).slice(0, 10);
|
|
2696
|
+
}
|
|
2697
|
+
get host() { return index.getElement(this); }
|
|
2698
|
+
};
|
|
2699
|
+
Search.style = searchCss;
|
|
2700
|
+
|
|
2701
|
+
/**
|
|
2702
|
+
* Cache for parsed route patterns to avoid redundant regex compilation
|
|
2703
|
+
*/
|
|
2704
|
+
const routeCache = new Map();
|
|
2705
|
+
/**
|
|
2706
|
+
* Parse route URL pattern into regex and parameter names
|
|
2707
|
+
* @param {string} pattern - Route pattern with optional parameters (e.g., "/component/:name")
|
|
2708
|
+
* @returns {{regex: RegExp, params: string[]}} Regex and parameter names
|
|
2709
|
+
*/
|
|
2710
|
+
function parseRoute(pattern) {
|
|
2711
|
+
const params = [];
|
|
2712
|
+
// First, collect all parameters in order they appear
|
|
2713
|
+
// Match both required (:param) and optional (:param?) parameters
|
|
2714
|
+
const paramMatches = pattern.match(/:(\w+)\??/g) || [];
|
|
2715
|
+
paramMatches.forEach((match) => {
|
|
2716
|
+
const paramName = match.replace(/^:|[?]/g, '');
|
|
2717
|
+
params.push(paramName);
|
|
2718
|
+
});
|
|
2719
|
+
// Then build the regex pattern
|
|
2720
|
+
// Process optional params with their slashes first (before escaping slashes)
|
|
2721
|
+
// This makes both the slash AND the parameter value optional
|
|
2722
|
+
const regexPattern = pattern
|
|
2723
|
+
.replace(/\/:(\w+)\?/g, '___OPTIONAL_PARAM_$1___') // Mark optional params with slash
|
|
2724
|
+
.replace(/\//g, '\\/') // Escape remaining slashes
|
|
2725
|
+
.replace(/___OPTIONAL_PARAM_(\w+)___/g, '(?:\\/([^/]*))?') // Optional slash + param
|
|
2726
|
+
.replace(/:(\w+)/g, '([^/]+)'); // Required param
|
|
2727
|
+
const regex = new RegExp(`^${regexPattern}\\/?$`);
|
|
2728
|
+
return { regex: regex, params: params };
|
|
2729
|
+
}
|
|
2730
|
+
/**
|
|
2731
|
+
* Match a path against a route pattern
|
|
2732
|
+
* @param {string} path - Current path to match
|
|
2733
|
+
* @param {string} pattern - Route pattern to match against
|
|
2734
|
+
* @returns {MatchResults | null} Match results with parameters or null if no match
|
|
2735
|
+
*/
|
|
2736
|
+
function matchRoute(path, pattern) {
|
|
2737
|
+
if (!pattern) {
|
|
2738
|
+
return { params: {} };
|
|
2739
|
+
}
|
|
2740
|
+
// Check cache first, or parse and cache if not found
|
|
2741
|
+
let parsed = routeCache.get(pattern);
|
|
2742
|
+
if (!parsed) {
|
|
2743
|
+
parsed = parseRoute(pattern);
|
|
2744
|
+
routeCache.set(pattern, parsed);
|
|
2745
|
+
}
|
|
2746
|
+
const { regex, params } = parsed;
|
|
2747
|
+
const match = path.match(regex);
|
|
2748
|
+
if (!match) {
|
|
2749
|
+
return null;
|
|
2750
|
+
}
|
|
2751
|
+
const matchParams = {};
|
|
2752
|
+
params.forEach((param, index) => {
|
|
2753
|
+
matchParams[param] = match[index + 1] || '';
|
|
2754
|
+
});
|
|
2755
|
+
return { params: matchParams };
|
|
2756
|
+
}
|
|
2757
|
+
/**
|
|
2758
|
+
* Get current hash path
|
|
2759
|
+
* @returns {string} Current hash path from URL
|
|
2760
|
+
*/
|
|
2761
|
+
function getHashPath() {
|
|
2762
|
+
return location.hash.substring(1) || '/';
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
/**
|
|
2766
|
+
* Type guard to check if an element is a route element
|
|
2767
|
+
* @param {Element} element - The element to check
|
|
2768
|
+
* @returns {boolean} True if the element is a stencil-route
|
|
2769
|
+
*/
|
|
2770
|
+
function isRouteElement(element) {
|
|
2771
|
+
return element.tagName.toLowerCase() === 'stencil-route';
|
|
2772
|
+
}
|
|
2773
|
+
/**
|
|
2774
|
+
* Check if any previous sibling route matches the current path
|
|
2775
|
+
* Used by route-switch to implement first-match-wins behavior
|
|
2776
|
+
* @param {HTMLElement} currentElement - The current route element
|
|
2777
|
+
* @param {string} currentPath - The current path to match
|
|
2778
|
+
* @returns {boolean} True if a previous sibling route matches
|
|
2779
|
+
*/
|
|
2780
|
+
function hasPreviousMatchingSibling(currentElement, currentPath) {
|
|
2781
|
+
const parent = currentElement.parentElement;
|
|
2782
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.tagName.toLowerCase()) !== 'stencil-route-switch') {
|
|
2783
|
+
return false;
|
|
2784
|
+
}
|
|
2785
|
+
const siblings = Array.from(parent.children);
|
|
2786
|
+
const myIndex = siblings.indexOf(currentElement);
|
|
2787
|
+
// Check all previous siblings
|
|
2788
|
+
for (let i = 0; i < myIndex; i++) {
|
|
2789
|
+
const sibling = siblings[i];
|
|
2790
|
+
// Use type guard to ensure element has expected route properties
|
|
2791
|
+
if (!isRouteElement(sibling)) {
|
|
2792
|
+
continue;
|
|
2793
|
+
}
|
|
2794
|
+
// Access sibling's URL property with type safety
|
|
2795
|
+
const siblingUrl = sibling.url;
|
|
2796
|
+
// Check if sibling matches current path
|
|
2797
|
+
let siblingMatch;
|
|
2798
|
+
if (siblingUrl) {
|
|
2799
|
+
siblingMatch = matchRoute(currentPath, siblingUrl);
|
|
2800
|
+
}
|
|
2801
|
+
else {
|
|
2802
|
+
siblingMatch = { params: {} }; // Routes without URL are catch-all
|
|
2803
|
+
}
|
|
2804
|
+
if (siblingMatch) {
|
|
2805
|
+
return true;
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
return false;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
/**
|
|
2812
|
+
* Generate a stable key from route parameters for component recreation
|
|
2813
|
+
* Keys are deterministic - same params always produce same key
|
|
2814
|
+
* Used to force Stencil component recreation when route params change
|
|
2815
|
+
* @param {Record<string, string>} params - Route parameters
|
|
2816
|
+
* @returns {string} A stable, deterministic key
|
|
2817
|
+
*/
|
|
2818
|
+
function generateComponentKey(params) {
|
|
2819
|
+
return Object.keys(params)
|
|
2820
|
+
.sort()
|
|
2821
|
+
.map((k) => `${k}=${params[k]}`)
|
|
2822
|
+
.join('&');
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
const StencilRoute = class {
|
|
2826
|
+
constructor(hostRef) {
|
|
2827
|
+
index.registerInstance(this, hostRef);
|
|
2828
|
+
this.currentPath = '/';
|
|
2829
|
+
this.handleHashChange = this.handleHashChange.bind(this);
|
|
2830
|
+
}
|
|
2831
|
+
connectedCallback() {
|
|
2832
|
+
window.addEventListener('hashchange', this.handleHashChange);
|
|
2833
|
+
this.handleHashChange();
|
|
2834
|
+
}
|
|
2835
|
+
disconnectedCallback() {
|
|
2836
|
+
window.removeEventListener('hashchange', this.handleHashChange);
|
|
2837
|
+
}
|
|
2838
|
+
handleHashChange() {
|
|
2839
|
+
this.currentPath = getHashPath();
|
|
2840
|
+
}
|
|
2841
|
+
render() {
|
|
2842
|
+
// Element should always be available in render, but guard defensively
|
|
2843
|
+
if (!this.el) {
|
|
2844
|
+
return null;
|
|
2845
|
+
}
|
|
2846
|
+
// Check if a previous sibling route matches (first-match wins)
|
|
2847
|
+
if (hasPreviousMatchingSibling(this.el, this.currentPath)) {
|
|
2848
|
+
return null;
|
|
2849
|
+
}
|
|
2850
|
+
// Check if this route matches
|
|
2851
|
+
let match;
|
|
2852
|
+
if (this.url) {
|
|
2853
|
+
match = matchRoute(this.currentPath, this.url);
|
|
2854
|
+
}
|
|
2855
|
+
else {
|
|
2856
|
+
match = { params: {} }; // Catch-all route
|
|
2857
|
+
}
|
|
2858
|
+
if (!match) {
|
|
2859
|
+
return null;
|
|
2860
|
+
}
|
|
2861
|
+
// Render the matched route
|
|
2862
|
+
if (this.routeRender) {
|
|
2863
|
+
return this.routeRender({ match: match });
|
|
2864
|
+
}
|
|
2865
|
+
if (this.component) {
|
|
2866
|
+
const props = Object.assign(Object.assign({}, this.componentProps), { match: match });
|
|
2867
|
+
// Create element dynamically using h() with string tag name
|
|
2868
|
+
// Use match params as key to force recreation when params change
|
|
2869
|
+
const key = generateComponentKey(match.params);
|
|
2870
|
+
return index.h(this.component, Object.assign({ key: key }, props));
|
|
2871
|
+
}
|
|
2872
|
+
return index.h("slot", null);
|
|
2873
|
+
}
|
|
2874
|
+
get el() { return index.getElement(this); }
|
|
2875
|
+
};
|
|
2876
|
+
|
|
2877
|
+
const StencilRouteSwitch = class {
|
|
2878
|
+
constructor(hostRef) {
|
|
2879
|
+
index.registerInstance(this, hostRef);
|
|
2880
|
+
this.scrollTopOffset = 0;
|
|
2881
|
+
this.currentPath = '/';
|
|
2882
|
+
this.handleHashChange = this.handleHashChange.bind(this);
|
|
2883
|
+
}
|
|
2884
|
+
connectedCallback() {
|
|
2885
|
+
window.addEventListener('hashchange', this.handleHashChange);
|
|
2886
|
+
this.handleHashChange();
|
|
2887
|
+
}
|
|
2888
|
+
disconnectedCallback() {
|
|
2889
|
+
window.removeEventListener('hashchange', this.handleHashChange);
|
|
2890
|
+
}
|
|
2891
|
+
handleHashChange() {
|
|
2892
|
+
const newPath = getHashPath();
|
|
2893
|
+
if (newPath !== this.currentPath) {
|
|
2894
|
+
this.currentPath = newPath;
|
|
2895
|
+
if (this.scrollTopOffset !== undefined) {
|
|
2896
|
+
window.scrollTo(0, this.scrollTopOffset);
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
render() {
|
|
2901
|
+
// Simply render child routes
|
|
2902
|
+
// The @State currentPath will trigger re-render when hash changes
|
|
2903
|
+
// Each route component will re-render and check if it matches
|
|
2904
|
+
return index.h("slot", { key: '140c65d5b8e395cebfe132763f26a304d217863e' });
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
|
|
2908
|
+
const StencilRouter = class {
|
|
2909
|
+
constructor(hostRef) {
|
|
2910
|
+
index.registerInstance(this, hostRef);
|
|
2911
|
+
}
|
|
2912
|
+
render() {
|
|
2913
|
+
return index.h("slot", { key: '6e145f4a847376de82972e4b1420d28cb86f4f8c' });
|
|
2914
|
+
}
|
|
2915
|
+
};
|
|
2916
|
+
|
|
2917
|
+
exports.kompendium_app = App;
|
|
2918
|
+
exports.kompendium_darkmode_switch = DarkmodeSwitch;
|
|
2919
|
+
exports.kompendium_navigation = Navigation;
|
|
2920
|
+
exports.kompendium_search = Search;
|
|
2921
|
+
exports.stencil_route = StencilRoute;
|
|
2922
|
+
exports.stencil_route_switch = StencilRouteSwitch;
|
|
2923
|
+
exports.stencil_router = StencilRouter;
|
|
2924
|
+
//# sourceMappingURL=kompendium-app.kompendium-darkmode-switch.kompendium-navigation.kompendium-search.stencil-route.stencil-route-switch.stencil-router.entry.cjs.js.map
|