@ng-doc/app 22.0.0 → 22.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/fesm2022/ng-doc-app-classes-content-controller.mjs +22 -4
- package/fesm2022/ng-doc-app-classes-content-controller.mjs.map +1 -1
- package/fesm2022/ng-doc-app-classes-default-search-engine.mjs +36 -12
- package/fesm2022/ng-doc-app-classes-default-search-engine.mjs.map +1 -1
- package/fesm2022/ng-doc-app-classes-root-page.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-api-list.mjs +7 -5
- package/fesm2022/ng-doc-app-components-api-list.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-breadcrumb.mjs +5 -3
- package/fesm2022/ng-doc-app-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-code.mjs +6 -4
- package/fesm2022/ng-doc-app-components-code.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-command-palette.mjs +35 -27
- package/fesm2022/ng-doc-app-components-command-palette.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-copy-button.mjs +6 -4
- package/fesm2022/ng-doc-app-components-copy-button.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-demo-displayer.mjs +19 -4
- package/fesm2022/ng-doc-app-components-demo-displayer.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-demo-frame.mjs +279 -0
- package/fesm2022/ng-doc-app-components-demo-frame.mjs.map +1 -0
- package/fesm2022/ng-doc-app-components-demo-pane.mjs +2 -2
- package/fesm2022/ng-doc-app-components-demo-pane.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-demo.mjs +97 -14
- package/fesm2022/ng-doc-app-components-demo.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-fullscreen-button.mjs +5 -3
- package/fesm2022/ng-doc-app-components-fullscreen-button.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-fullscreen-toggle.mjs +4 -2
- package/fesm2022/ng-doc-app-components-fullscreen-toggle.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-heading-anchor.mjs +5 -3
- package/fesm2022/ng-doc-app-components-heading-anchor.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-image-viewer.mjs +5 -3
- package/fesm2022/ng-doc-app-components-image-viewer.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-navbar.mjs +4 -2
- package/fesm2022/ng-doc-app-components-navbar.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-page-navigation.mjs +5 -3
- package/fesm2022/ng-doc-app-components-page-navigation.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-page-wrapper.mjs +2 -2
- package/fesm2022/ng-doc-app-components-page-wrapper.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-page.mjs +83 -16
- package/fesm2022/ng-doc-app-components-page.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-playground.mjs +838 -141
- package/fesm2022/ng-doc-app-components-playground.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-root.mjs +51 -4
- package/fesm2022/ng-doc-app-components-root.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-search-result.mjs +8 -6
- package/fesm2022/ng-doc-app-components-search-result.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-search.mjs +7 -5
- package/fesm2022/ng-doc-app-components-search.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-sidebar.mjs +4 -3
- package/fesm2022/ng-doc-app-components-sidebar.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-tabs.mjs +21 -3
- package/fesm2022/ng-doc-app-components-tabs.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-theme-toggle.mjs +7 -5
- package/fesm2022/ng-doc-app-components-theme-toggle.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components-toc.mjs +4 -2
- package/fesm2022/ng-doc-app-components-toc.mjs.map +1 -1
- package/fesm2022/ng-doc-app-components.mjs +1 -0
- package/fesm2022/ng-doc-app-components.mjs.map +1 -1
- package/fesm2022/ng-doc-app-constants.mjs +11 -1
- package/fesm2022/ng-doc-app-constants.mjs.map +1 -1
- package/fesm2022/ng-doc-app-demo-app.mjs +779 -0
- package/fesm2022/ng-doc-app-demo-app.mjs.map +1 -0
- package/fesm2022/ng-doc-app-helpers.mjs +147 -7
- package/fesm2022/ng-doc-app-helpers.mjs.map +1 -1
- package/fesm2022/ng-doc-app-processors-processors.mjs +30 -9
- package/fesm2022/ng-doc-app-processors-processors.mjs.map +1 -1
- package/fesm2022/ng-doc-app-providers-ng-doc-app.mjs +29 -18
- package/fesm2022/ng-doc-app-providers-ng-doc-app.mjs.map +1 -1
- package/fesm2022/ng-doc-app-providers-texts.mjs +53 -0
- package/fesm2022/ng-doc-app-providers-texts.mjs.map +1 -0
- package/fesm2022/ng-doc-app-providers-title.mjs +129 -0
- package/fesm2022/ng-doc-app-providers-title.mjs.map +1 -0
- package/fesm2022/ng-doc-app-providers.mjs +2 -0
- package/fesm2022/ng-doc-app-providers.mjs.map +1 -1
- package/fesm2022/ng-doc-app-services-content-scroll-intent.mjs +27 -2
- package/fesm2022/ng-doc-app-services-content-scroll-intent.mjs.map +1 -1
- package/fesm2022/ng-doc-app-services-highlighter.mjs +23 -16
- package/fesm2022/ng-doc-app-services-highlighter.mjs.map +1 -1
- package/fesm2022/ng-doc-app-services-route-preloader.mjs +34 -10
- package/fesm2022/ng-doc-app-services-route-preloader.mjs.map +1 -1
- package/fesm2022/ng-doc-app-services-shortcuts.mjs +38 -4
- package/fesm2022/ng-doc-app-services-shortcuts.mjs.map +1 -1
- package/fesm2022/ng-doc-app-texts-ar.mjs +238 -0
- package/fesm2022/ng-doc-app-texts-ar.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-de.mjs +205 -0
- package/fesm2022/ng-doc-app-texts-de.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-es.mjs +205 -0
- package/fesm2022/ng-doc-app-texts-es.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-fr.mjs +205 -0
- package/fesm2022/ng-doc-app-texts-fr.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-hi.mjs +219 -0
- package/fesm2022/ng-doc-app-texts-hi.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-ja.mjs +205 -0
- package/fesm2022/ng-doc-app-texts-ja.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-ko.mjs +205 -0
- package/fesm2022/ng-doc-app-texts-ko.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-pt-br.mjs +205 -0
- package/fesm2022/ng-doc-app-texts-pt-br.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-ru.mjs +231 -0
- package/fesm2022/ng-doc-app-texts-ru.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-uk.mjs +231 -0
- package/fesm2022/ng-doc-app-texts-uk.mjs.map +1 -0
- package/fesm2022/ng-doc-app-texts-zh.mjs +205 -0
- package/fesm2022/ng-doc-app-texts-zh.mjs.map +1 -0
- package/fesm2022/ng-doc-app-tokens.mjs +214 -1
- package/fesm2022/ng-doc-app-tokens.mjs.map +1 -1
- package/fesm2022/ng-doc-app-type-controls-json-control.mjs +90 -0
- package/fesm2022/ng-doc-app-type-controls-json-control.mjs.map +1 -0
- package/fesm2022/ng-doc-app-type-controls-list-control.mjs +792 -0
- package/fesm2022/ng-doc-app-type-controls-list-control.mjs.map +1 -0
- package/fesm2022/ng-doc-app-type-controls-type-alias-control.mjs +45 -8
- package/fesm2022/ng-doc-app-type-controls-type-alias-control.mjs.map +1 -1
- package/fesm2022/ng-doc-app-type-controls.mjs +2 -0
- package/fesm2022/ng-doc-app-type-controls.mjs.map +1 -1
- package/package.json +73 -4
- package/styles/global.css +4 -0
- package/styles/main.css +4 -0
- package/styles/themes/dark.css +10 -0
- package/types/ng-doc-app-classes-default-search-engine.d.ts +11 -0
- package/types/ng-doc-app-classes-root-page.d.ts +13 -0
- package/types/ng-doc-app-components-api-list.d.ts +3 -1
- package/types/ng-doc-app-components-breadcrumb.d.ts +2 -1
- package/types/ng-doc-app-components-code.d.ts +2 -0
- package/types/ng-doc-app-components-command-palette.d.ts +3 -1
- package/types/ng-doc-app-components-copy-button.d.ts +3 -1
- package/types/ng-doc-app-components-demo-displayer.d.ts +13 -1
- package/types/ng-doc-app-components-demo-frame.d.ts +107 -0
- package/types/ng-doc-app-components-demo.d.ts +47 -10
- package/types/ng-doc-app-components-fullscreen-button.d.ts +2 -0
- package/types/ng-doc-app-components-fullscreen-toggle.d.ts +2 -0
- package/types/ng-doc-app-components-heading-anchor.d.ts +2 -0
- package/types/ng-doc-app-components-image-viewer.d.ts +2 -0
- package/types/ng-doc-app-components-navbar.d.ts +2 -0
- package/types/ng-doc-app-components-page-navigation.d.ts +2 -1
- package/types/ng-doc-app-components-page.d.ts +10 -1
- package/types/ng-doc-app-components-playground.d.ts +260 -42
- package/types/ng-doc-app-components-root.d.ts +18 -0
- package/types/ng-doc-app-components-search-result.d.ts +2 -0
- package/types/ng-doc-app-components-search.d.ts +2 -0
- package/types/ng-doc-app-components-sidebar.d.ts +2 -1
- package/types/ng-doc-app-components-tabs.d.ts +13 -3
- package/types/ng-doc-app-components-theme-toggle.d.ts +4 -1
- package/types/ng-doc-app-components-toc.d.ts +2 -1
- package/types/ng-doc-app-components.d.ts +1 -0
- package/types/ng-doc-app-constants.d.ts +11 -1
- package/types/ng-doc-app-demo-app.d.ts +297 -0
- package/types/ng-doc-app-helpers.d.ts +75 -4
- package/types/ng-doc-app-interfaces.d.ts +635 -6
- package/types/ng-doc-app-processors-processors.d.ts +5 -0
- package/types/ng-doc-app-providers-ng-doc-app.d.ts +7 -1
- package/types/ng-doc-app-providers-texts.d.ts +28 -0
- package/types/ng-doc-app-providers-title.d.ts +59 -0
- package/types/ng-doc-app-providers.d.ts +2 -0
- package/types/ng-doc-app-services-content-scroll-intent.d.ts +11 -1
- package/types/ng-doc-app-services-highlighter.d.ts +15 -6
- package/types/ng-doc-app-services-route-preloader.d.ts +13 -1
- package/types/ng-doc-app-services-shortcuts.d.ts +16 -0
- package/types/ng-doc-app-texts-ar.d.ts +13 -0
- package/types/ng-doc-app-texts-de.d.ts +12 -0
- package/types/ng-doc-app-texts-es.d.ts +12 -0
- package/types/ng-doc-app-texts-fr.d.ts +12 -0
- package/types/ng-doc-app-texts-hi.d.ts +12 -0
- package/types/ng-doc-app-texts-ja.d.ts +12 -0
- package/types/ng-doc-app-texts-ko.d.ts +12 -0
- package/types/ng-doc-app-texts-pt-br.d.ts +12 -0
- package/types/ng-doc-app-texts-ru.d.ts +12 -0
- package/types/ng-doc-app-texts-uk.d.ts +12 -0
- package/types/ng-doc-app-texts-zh.d.ts +12 -0
- package/types/ng-doc-app-tokens.d.ts +21 -2
- package/types/ng-doc-app-type-controls-json-control.d.ts +38 -0
- package/types/ng-doc-app-type-controls-list-control.d.ts +313 -0
- package/types/ng-doc-app-type-controls-type-alias-control.d.ts +28 -5
- package/types/ng-doc-app-type-controls.d.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-doc-app-processors-processors.mjs","sources":["../../../../libs/app/processors/processors/blockquote.processor.ts","../../../../libs/app/processors/processors/code.processor.ts","../../../../libs/app/processors/processors/demo.processor.ts","../../../../libs/app/processors/processors/demo-pane.processor.ts","../../../../libs/app/processors/processors/heading-anchor.processor.ts","../../../../libs/app/processors/processors/icon.processor.ts","../../../../libs/app/processors/processors/image.processor.ts","../../../../libs/app/processors/processors/members.processor.ts","../../../../libs/app/processors/processors/mermaid.processor.ts","../../../../libs/app/processors/processors/playground.processor.ts","../../../../libs/app/processors/processors/tabs.processor.ts","../../../../libs/app/processors/processors/ng-doc-app-processors-processors.ts"],"sourcesContent":["import { NgDocPageProcessor } from '@ng-doc/app/interfaces';\nimport { NgDocBlockquoteComponent, NgDocBlockquoteType } from '@ng-doc/ui-kit';\n\nexport const blockquoteProcessor: NgDocPageProcessor<NgDocBlockquoteComponent> = {\n component: NgDocBlockquoteComponent,\n selector: 'ng-doc-blockquote',\n extractOptions: (element: Element) => ({\n content: [Array.from(element.childNodes)],\n inputs: {\n type: (element.getAttribute('type') as NgDocBlockquoteType) || 'default',\n icon: element.getAttribute('icon') ?? undefined,\n label: element.getAttribute('label') ?? undefined,\n },\n }),\n};\n","import { NgDocCodeComponent } from '@ng-doc/app/components/code';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const codeProcessor: NgDocPageProcessor<NgDocCodeComponent> = {\n component: NgDocCodeComponent,\n selector: 'pre code',\n nodeToReplace: (element: Element) => element.closest('pre') ?? element,\n extractOptions: (element: Element) => ({\n inputs: {\n name: element.parentElement?.getAttribute('name') || undefined,\n icon: element.parentElement?.getAttribute('icon') || undefined,\n },\n content: [[element.closest('pre') ?? element]],\n }),\n};\n","import { NgDocDemoComponent } from '@ng-doc/app/components/demo';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const demoProcessor: NgDocPageProcessor<NgDocDemoComponent> = {\n component: NgDocDemoComponent,\n selector: 'ng-doc-demo',\n extractOptions: (element: Element) => ({\n inputs: {\n componentName: element.getAttribute('componentName') || undefined,\n options: JSON.parse(element.querySelector('#options')?.textContent ?? '{}'),\n },\n }),\n};\n","import { NgDocDemoPaneComponent } from '@ng-doc/app/components/demo-pane';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const demoPaneProcessor: NgDocPageProcessor<NgDocDemoPaneComponent> = {\n\tcomponent: NgDocDemoPaneComponent,\n\tselector: 'ng-doc-demo-pane',\n\textractOptions: (element: Element) => ({\n\t\tinputs: {\n\t\t\tcomponentName: element.getAttribute('componentName') || undefined,\n\t\t\toptions: JSON.parse(element.querySelector('#options')?.textContent ?? '') || {},\n\t\t},\n\t}),\n};\n","import { NgDocHeadingAnchorComponent } from '@ng-doc/app/components/heading-anchor';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const headingAnchorProcessor: NgDocPageProcessor<NgDocHeadingAnchorComponent> = {\n component: NgDocHeadingAnchorComponent,\n selector: 'ng-doc-heading-anchor',\n extractOptions: (element: Element) => ({\n inputs: {\n classes: element.getAttribute('class')?.split(' ') || [],\n anchor: element.getAttribute('anchor') || '',\n },\n }),\n};\n","import { NgDocPageProcessor } from '@ng-doc/app/interfaces';\nimport { NgDocIconComponent, NgDocIconSize } from '@ng-doc/ui-kit';\n\nexport const iconProcessor: NgDocPageProcessor<NgDocIconComponent> = {\n\tcomponent: NgDocIconComponent,\n\tselector: 'ng-doc-icon',\n\textractOptions: (element: Element) => ({\n\t\tinputs: {\n\t\t\ticon: element.getAttribute('icon') ?? '',\n\t\t\tsize: (Number(element.getAttribute('size')) as NgDocIconSize) || 16,\n\t\t},\n\t}),\n};\n","import { Injector, Renderer2 } from '@angular/core';\nimport { NgDocImageViewerComponent } from '@ng-doc/app/components/image-viewer';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const imageProcessor: NgDocPageProcessor<NgDocImageViewerComponent> = {\n component: NgDocImageViewerComponent,\n selector: 'img:not([zoom=\"false\"])',\n nodeToReplace: (element: Element, injector: Injector) => {\n const renderer: Renderer2 = injector.get(Renderer2);\n const anchor: Element = renderer.createElement('div');\n\n return element.parentNode?.insertBefore(anchor, element) ?? element;\n },\n extractOptions: (element: Element) => ({\n inputs: {\n src: element.getAttribute('src') ?? '',\n alt: element.getAttribute('alt') ?? '',\n },\n content: [[element]],\n }),\n};\n","import { NgDocMembersComponent } from '@ng-doc/app/components/members';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\n/** Adds the member filter to the members table of an API page (`<ng-doc-members>`). */\nexport const membersProcessor: NgDocPageProcessor<NgDocMembersComponent> = {\n component: NgDocMembersComponent,\n selector: 'ng-doc-members',\n extractOptions: (element: Element) => ({\n content: [Array.from(element.childNodes)],\n }),\n};\n","import { NgDocMermaidViewerComponent } from '@ng-doc/app/components/mermaid-viewer';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const mermaidProcessor: NgDocPageProcessor<NgDocMermaidViewerComponent> = {\n component: NgDocMermaidViewerComponent,\n selector: 'pre.mermaid',\n extractOptions: (element: Element) => ({\n inputs: {\n graph: element.textContent ?? '',\n },\n }),\n};\n","import { NgDocPlaygroundComponent } from '@ng-doc/app/components/playground';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\nimport { isPresent } from '@ng-doc/core/helpers/is-present';\n\nexport const playgroundProcessor: NgDocPageProcessor<NgDocPlaygroundComponent> = {\n component: NgDocPlaygroundComponent,\n selector: 'ng-doc-playground',\n extractOptions: (element: Element) => ({\n inputs: {\n id: element.getAttribute('id') || undefined,\n properties:\n JSON.parse(element.querySelector('#data')?.textContent?.replace(/\\n/g, '\\\\n') ?? '') ||\n undefined,\n pipeName: element.querySelector('#pipeName')?.textContent || undefined,\n selectors: (element.querySelector('#selectors')?.textContent || '')\n .split(',')\n .map((selector: string) => selector.trim())\n .filter(isPresent),\n options: JSON.parse(element.querySelector('#options')?.textContent ?? '') || {},\n },\n }),\n};\n","import { Injector, Renderer2 } from '@angular/core';\nimport { NgDocTabsComponent } from '@ng-doc/app/components/tabs';\nimport { NgDocPageProcessor, NgDocTab } from '@ng-doc/app/interfaces';\n\nexport const tabsProcessor: NgDocPageProcessor<NgDocTabsComponent> = {\n\tcomponent: NgDocTabsComponent,\n\tselector: 'ng-doc-tab',\n\tnodeToReplace: (element: Element, injector: Injector) => {\n\t\tconst renderer: Renderer2 = injector.get(Renderer2);\n\t\tconst anchor: Element = renderer.createElement('div');\n\n\t\treturn element.parentNode?.insertBefore(anchor, element) ?? element;\n\t},\n\textractOptions: (element: Element, root: Element) => {\n\t\tconst group: string | null = element.getAttribute('group') ?? '';\n\t\tconst tabs: Element[] = Array.from(root.querySelectorAll(`ng-doc-tab[group=\"${group}\"]`));\n\t\tconst mappedTabs: NgDocTab[] = tabs.map((tab: Element) => ({\n\t\t\ttitle: tab.getAttribute('name') ?? '',\n\t\t\tcontent: tab,\n\t\t\ticon: tab.getAttribute('icon') || undefined,\n\t\t\tactive: tab.hasAttribute('active'),\n\t\t}));\n\n\t\ttabs.forEach((tab: Element) => tab.remove());\n\n\t\treturn {\n\t\t\tinputs: {\n\t\t\t\ttabs: mappedTabs,\n\t\t\t},\n\t\t};\n\t},\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGO,MAAM,mBAAmB,GAAiD;AAC/E,IAAA,SAAS,EAAE,wBAAwB;AACnC,IAAA,QAAQ,EAAE,mBAAmB;AAC7B,IAAA,cAAc,EAAE,CAAC,OAAgB,MAAM;QACrC,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACzC,QAAA,MAAM,EAAE;YACN,IAAI,EAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAyB,IAAI,SAAS;YACxE,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,SAAS;YAC/C,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,SAAS;AAClD,SAAA;KACF,CAAC;;;ACVG,MAAM,aAAa,GAA2C;AACnE,IAAA,SAAS,EAAE,kBAAkB;AAC7B,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,aAAa,EAAE,CAAC,OAAgB,KAAK,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO;AACtE,IAAA,cAAc,EAAE,CAAC,OAAgB,MAAM;AACrC,QAAA,MAAM,EAAE;YACN,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,SAAS;YAC9D,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,SAAS;AAC/D,SAAA;AACD,QAAA,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC;KAC/C,CAAC;;;ACVG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,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,OAAO;IACpE,CAAC;AACD,IAAA,cAAc,EAAE,CAAC,OAAgB,EAAE,IAAa,KAAI;QACnD,MAAM,KAAK,GAAkB,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE;AAChE,QAAA,MAAM,IAAI,GAAc,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA,kBAAA,EAAqB,KAAK,CAAA,EAAA,CAAI,CAAC,CAAC;QACzF,MAAM,UAAU,GAAe,IAAI,CAAC,GAAG,CAAC,CAAC,GAAY,MAAM;YAC1D,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE;AACrC,YAAA,OAAO,EAAE,GAAG;YACZ,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,SAAS;AAC3C,YAAA,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC;AAClC,SAAA,CAAC,CAAC;AAEH,QAAA,IAAI,CAAC,OAAO,CAAC,CAAC,GAAY,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;QAE5C,OAAO;AACN,YAAA,MAAM,EAAE;AACP,gBAAA,IAAI,EAAE,UAAU;AAChB,aAAA;SACD;IACF,CAAC;;;AC9BF;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-doc-app-processors-processors.mjs","sources":["../../../../libs/app/processors/processors/blockquote.processor.ts","../../../../libs/app/processors/processors/code.processor.ts","../../../../libs/app/processors/processors/demo.processor.ts","../../../../libs/app/processors/processors/demo-pane.processor.ts","../../../../libs/app/processors/processors/heading-anchor.processor.ts","../../../../libs/app/processors/processors/icon.processor.ts","../../../../libs/app/processors/processors/image.processor.ts","../../../../libs/app/processors/processors/members.processor.ts","../../../../libs/app/processors/processors/mermaid.processor.ts","../../../../libs/app/processors/processors/playground.processor.ts","../../../../libs/app/processors/processors/tabs.processor.ts","../../../../libs/app/processors/processors/ng-doc-app-processors-processors.ts"],"sourcesContent":["import { NgDocPageProcessor } from '@ng-doc/app/interfaces';\nimport { NgDocBlockquoteComponent, NgDocBlockquoteType } from '@ng-doc/ui-kit';\n\nexport const blockquoteProcessor: NgDocPageProcessor<NgDocBlockquoteComponent> = {\n component: NgDocBlockquoteComponent,\n selector: 'ng-doc-blockquote',\n extractOptions: (element: Element) => ({\n content: [Array.from(element.childNodes)],\n inputs: {\n type: (element.getAttribute('type') as NgDocBlockquoteType) || 'default',\n icon: element.getAttribute('icon') ?? undefined,\n label: element.getAttribute('label') ?? undefined,\n },\n }),\n};\n","import { NgDocCodeComponent } from '@ng-doc/app/components/code';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const codeProcessor: NgDocPageProcessor<NgDocCodeComponent> = {\n component: NgDocCodeComponent,\n selector: 'pre code',\n nodeToReplace: (element: Element) => element.closest('pre') ?? element,\n extractOptions: (element: Element) => ({\n inputs: {\n name: element.parentElement?.getAttribute('name') || undefined,\n icon: element.parentElement?.getAttribute('icon') || undefined,\n },\n content: [[element.closest('pre') ?? element]],\n }),\n};\n","import { NgDocDemoComponent } from '@ng-doc/app/components/demo';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const demoProcessor: NgDocPageProcessor<NgDocDemoComponent> = {\n component: NgDocDemoComponent,\n selector: 'ng-doc-demo',\n extractOptions: (element: Element) => ({\n inputs: {\n componentName: element.getAttribute('componentName') || undefined,\n options: JSON.parse(element.querySelector('#options')?.textContent ?? '{}'),\n },\n }),\n};\n","import { NgDocDemoPaneComponent } from '@ng-doc/app/components/demo-pane';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const demoPaneProcessor: NgDocPageProcessor<NgDocDemoPaneComponent> = {\n\tcomponent: NgDocDemoPaneComponent,\n\tselector: 'ng-doc-demo-pane',\n\textractOptions: (element: Element) => ({\n\t\tinputs: {\n\t\t\tcomponentName: element.getAttribute('componentName') || undefined,\n\t\t\toptions: JSON.parse(element.querySelector('#options')?.textContent ?? '') || {},\n\t\t},\n\t}),\n};\n","import { NgDocHeadingAnchorComponent } from '@ng-doc/app/components/heading-anchor';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const headingAnchorProcessor: NgDocPageProcessor<NgDocHeadingAnchorComponent> = {\n component: NgDocHeadingAnchorComponent,\n selector: 'ng-doc-heading-anchor',\n extractOptions: (element: Element) => ({\n inputs: {\n classes: element.getAttribute('class')?.split(' ') || [],\n anchor: element.getAttribute('anchor') || '',\n },\n }),\n};\n","import { NgDocPageProcessor } from '@ng-doc/app/interfaces';\nimport { NgDocIconComponent, NgDocIconSize } from '@ng-doc/ui-kit';\n\nexport const iconProcessor: NgDocPageProcessor<NgDocIconComponent> = {\n\tcomponent: NgDocIconComponent,\n\tselector: 'ng-doc-icon',\n\textractOptions: (element: Element) => ({\n\t\tinputs: {\n\t\t\ticon: element.getAttribute('icon') ?? '',\n\t\t\tsize: (Number(element.getAttribute('size')) as NgDocIconSize) || 16,\n\t\t},\n\t}),\n};\n","import { Injector, Renderer2 } from '@angular/core';\nimport { NgDocImageViewerComponent } from '@ng-doc/app/components/image-viewer';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const imageProcessor: NgDocPageProcessor<NgDocImageViewerComponent> = {\n component: NgDocImageViewerComponent,\n selector: 'img:not([zoom=\"false\"])',\n nodeToReplace: (element: Element, injector: Injector) => {\n const renderer: Renderer2 = injector.get(Renderer2);\n const anchor: Element = renderer.createElement('div');\n\n return element.parentNode?.insertBefore(anchor, element) ?? element;\n },\n extractOptions: (element: Element) => ({\n inputs: {\n src: element.getAttribute('src') ?? '',\n alt: element.getAttribute('alt') ?? '',\n },\n content: [[element]],\n }),\n};\n","import { NgDocMembersComponent } from '@ng-doc/app/components/members';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\n/** Adds the member filter to the members table of an API page (`<ng-doc-members>`). */\nexport const membersProcessor: NgDocPageProcessor<NgDocMembersComponent> = {\n component: NgDocMembersComponent,\n selector: 'ng-doc-members',\n extractOptions: (element: Element) => ({\n content: [Array.from(element.childNodes)],\n }),\n};\n","import { NgDocMermaidViewerComponent } from '@ng-doc/app/components/mermaid-viewer';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\n\nexport const mermaidProcessor: NgDocPageProcessor<NgDocMermaidViewerComponent> = {\n component: NgDocMermaidViewerComponent,\n selector: 'pre.mermaid',\n extractOptions: (element: Element) => ({\n inputs: {\n graph: element.textContent ?? '',\n },\n }),\n};\n","import { NgDocPlaygroundComponent } from '@ng-doc/app/components/playground';\nimport { NgDocPageProcessor } from '@ng-doc/app/interfaces';\nimport { isPresent } from '@ng-doc/core/helpers/is-present';\n\nexport const playgroundProcessor: NgDocPageProcessor<NgDocPlaygroundComponent> = {\n component: NgDocPlaygroundComponent,\n selector: 'ng-doc-playground',\n extractOptions: (element: Element) => ({\n inputs: {\n id: element.getAttribute('id') || undefined,\n properties:\n JSON.parse(element.querySelector('#data')?.textContent?.replace(/\\n/g, '\\\\n') ?? '') ||\n undefined,\n pipeName: element.querySelector('#pipeName')?.textContent || undefined,\n selectors: (element.querySelector('#selectors')?.textContent || '')\n .split(',')\n .map((selector: string) => selector.trim())\n .filter(isPresent),\n options: JSON.parse(element.querySelector('#options')?.textContent ?? '') || {},\n },\n }),\n};\n","import { Injector, Renderer2 } from '@angular/core';\nimport { NgDocTabsComponent } from '@ng-doc/app/components/tabs';\nimport { NgDocPageProcessor, NgDocTab } from '@ng-doc/app/interfaces';\n\n/**\n * Turns the `<ng-doc-tab group=\"…\" name=\"…\">` elements of a page into tabs: every tab of a group\n * becomes one `NgDocTabsComponent`, where the first tab of the group was. Code groups are made of\n * them, and Markdown can wrap any content in them.\n */\nexport const tabsProcessor: NgDocPageProcessor<NgDocTabsComponent> = {\n component: NgDocTabsComponent,\n selector: 'ng-doc-tab',\n nodeToReplace: (element: Element, injector: Injector) => {\n const renderer: Renderer2 = injector.get(Renderer2);\n const anchor: Element = renderer.createElement('div');\n\n return element.parentNode?.insertBefore(anchor, element) ?? element;\n },\n extractOptions: (element: Element, root: Element) => {\n const group: string = element.getAttribute('group') ?? '';\n const tabs: Element[] = Array.from(root.querySelectorAll('ng-doc-tab')).filter(\n (tab: Element) => (tab.getAttribute('group') ?? '') === group,\n );\n\n if (!tabs.includes(element)) {\n tabs.unshift(element);\n }\n\n // The tabs stay on the page until the component first renders (`NgDocTabsComponent`), so\n // the processors after this one, the page's own included, still reach their content. The\n // page processor skips elements that have left the page, so the other tabs of the group are\n // swapped for copies that hold their content: otherwise each would get tabs of its own.\n const contents: Element[] = tabs.map((tab: Element) => {\n if (tab === element || !tab.parentNode) {\n return tab;\n }\n\n const copy: Element = tab.cloneNode(false) as Element;\n\n while (tab.firstChild) {\n copy.appendChild(tab.firstChild);\n }\n tab.parentNode.replaceChild(copy, tab);\n\n return copy;\n });\n\n return {\n inputs: {\n tabs: tabs.map((tab: Element, index: number) => ({\n title: tab.getAttribute('name') ?? '',\n content: contents[index],\n icon: tab.getAttribute('icon') || undefined,\n active: tab.hasAttribute('active'),\n })) satisfies NgDocTab[],\n },\n };\n },\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGO,MAAM,mBAAmB,GAAiD;AAC/E,IAAA,SAAS,EAAE,wBAAwB;AACnC,IAAA,QAAQ,EAAE,mBAAmB;AAC7B,IAAA,cAAc,EAAE,CAAC,OAAgB,MAAM;QACrC,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACzC,QAAA,MAAM,EAAE;YACN,IAAI,EAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAyB,IAAI,SAAS;YACxE,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,SAAS;YAC/C,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC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,GAAG,CAAC,UAAU,EAAE;AACtC,gBAAA,OAAO,GAAG;YACZ;YAEA,MAAM,IAAI,GAAY,GAAG,CAAC,SAAS,CAAC,KAAK,CAAY;AAErD,YAAA,OAAO,GAAG,CAAC,UAAU,EAAE;AACrB,gBAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC;YAClC;YACA,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC;AAEtC,YAAA,OAAO,IAAI;AACb,QAAA,CAAC,CAAC;QAEF,OAAO;AACL,YAAA,MAAM,EAAE;AACN,gBAAA,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAY,EAAE,KAAa,MAAM;oBAC/C,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE;AACrC,oBAAA,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC;oBACxB,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,SAAS;AAC3C,oBAAA,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC;AACnC,iBAAA,CAAC,CAAsB;AACzB,aAAA;SACF;IACH,CAAC;;;ACzDH;;AAEG;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { isPlatformBrowser
|
|
2
|
-
import {
|
|
1
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { provideEnvironmentInitializer, inject, PLATFORM_ID, DOCUMENT, PendingTasks } from '@angular/core';
|
|
3
3
|
import { ɵcaptureNgDocHydrationSnapshots as _captureNgDocHydrationSnapshots } from '@ng-doc/app/helpers';
|
|
4
|
+
import { NgDocApiListIndexService } from '@ng-doc/app/services';
|
|
4
5
|
import { NgDocContentScrollIntent } from '@ng-doc/app/services/content-scroll-intent';
|
|
5
6
|
import { NgDocHighlighterService } from '@ng-doc/app/services/highlighter';
|
|
6
7
|
import { NG_DOC_SHORTCUTS, NgDocShortcutsService } from '@ng-doc/app/services/shortcuts';
|
|
@@ -9,6 +10,12 @@ import { provideNgDocUiKitConfig } from '@ng-doc/ui-kit';
|
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Provides the NgDoc application configuration.
|
|
13
|
+
*
|
|
14
|
+
* Add it to the application's providers, or to the `providers` of the route that holds the
|
|
15
|
+
* documentation, together with the other NgDoc providers: then NgDoc starts only when the reader
|
|
16
|
+
* opens the documentation, and its code stays out of the application's initial bundle. It starts
|
|
17
|
+
* with environment initializers, which run where it is provided. The server render waits until
|
|
18
|
+
* the code highlighter of playgrounds has loaded.
|
|
12
19
|
* @param config - The optional application configuration.
|
|
13
20
|
*/
|
|
14
21
|
function provideNgDocApp(config) {
|
|
@@ -18,33 +25,37 @@ function provideNgDocApp(config) {
|
|
|
18
25
|
provide: NG_DOC_CONTENT_SCROLL_POSITION_RESTORATION,
|
|
19
26
|
useValue: config?.contentScrollPositionRestoration ?? 'disabled',
|
|
20
27
|
},
|
|
28
|
+
{ provide: NG_DOC_SHORTCUTS, useValue: config?.shortcuts ?? true },
|
|
29
|
+
/* --- Services --- */
|
|
30
|
+
// Provided where the configuration is, so that they read the NgDoc providers of a lazy route
|
|
31
|
+
// (the generated context, the shortcuts option): an instance in the root injector could not
|
|
32
|
+
// see them. In the root injector this is the instance `providedIn: 'root'` gives.
|
|
33
|
+
NgDocHighlighterService,
|
|
34
|
+
NgDocShortcutsService,
|
|
35
|
+
NgDocApiListIndexService,
|
|
21
36
|
...(config?.contentAnchorScrolling || config?.contentScrollPositionRestoration === 'enabled'
|
|
22
37
|
? [
|
|
23
|
-
|
|
38
|
+
provideEnvironmentInitializer(() => {
|
|
24
39
|
inject(NgDocContentScrollIntent).start();
|
|
25
40
|
}),
|
|
26
41
|
]
|
|
27
42
|
: []),
|
|
28
43
|
/* --- Hydration --- */
|
|
29
|
-
// Before the
|
|
30
|
-
// server-rendered content until their own is rendered, instead of a blank page.
|
|
31
|
-
|
|
44
|
+
// Before the documentation renders: the pages and headers that skip hydration show their
|
|
45
|
+
// server-rendered content until their own is rendered, instead of a blank page. A lazy route
|
|
46
|
+
// creates its injector before it creates its components, so this also runs in time when the
|
|
47
|
+
// documentation is the first route the browser hydrates.
|
|
48
|
+
provideEnvironmentInitializer(() => {
|
|
32
49
|
if (isPlatformBrowser(inject(PLATFORM_ID)))
|
|
33
50
|
_captureNgDocHydrationSnapshots(inject(DOCUMENT));
|
|
34
51
|
}),
|
|
35
|
-
/* --- Keyboard shortcuts --- */
|
|
36
|
-
{ provide: NG_DOC_SHORTCUTS, useValue: config?.shortcuts ?? true },
|
|
37
|
-
// Created at start-up so the built-in shortcuts work on every page.
|
|
38
|
-
provideAppInitializer(() => {
|
|
39
|
-
inject(NgDocShortcutsService);
|
|
40
|
-
}),
|
|
41
|
-
/* --- Viewport Scroller --- */
|
|
42
|
-
provideAppInitializer(() => {
|
|
43
|
-
inject(ViewportScroller).setOffset([0, 120]);
|
|
44
|
-
}),
|
|
45
52
|
/* --- Shiki --- */
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
// Started with the documentation instead of blocking the application's start: the playgrounds
|
|
54
|
+
// highlight their code once it is ready, and the application stays unstable until then, so the
|
|
55
|
+
// server renders the highlighted code.
|
|
56
|
+
provideEnvironmentInitializer(() => {
|
|
57
|
+
const highlighter = inject(NgDocHighlighterService);
|
|
58
|
+
inject(PendingTasks).run(() => highlighter.initialize(config?.shiki));
|
|
48
59
|
}),
|
|
49
60
|
/* --- UiKit --- */
|
|
50
61
|
...provideNgDocUiKitConfig(config?.uiKit),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-doc-app-providers-ng-doc-app.mjs","sources":["../../../../libs/app/providers/ng-doc-app/provide-ng-doc-app.ts","../../../../libs/app/providers/ng-doc-app/ng-doc-app-providers-ng-doc-app.ts"],"sourcesContent":["import { isPlatformBrowser
|
|
1
|
+
{"version":3,"file":"ng-doc-app-providers-ng-doc-app.mjs","sources":["../../../../libs/app/providers/ng-doc-app/provide-ng-doc-app.ts","../../../../libs/app/providers/ng-doc-app/ng-doc-app-providers-ng-doc-app.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport {\n DOCUMENT,\n EnvironmentProviders,\n inject,\n PendingTasks,\n PLATFORM_ID,\n provideEnvironmentInitializer,\n Provider,\n} from '@angular/core';\nimport { ɵcaptureNgDocHydrationSnapshots } from '@ng-doc/app/helpers';\nimport { NgDocApiListIndexService } from '@ng-doc/app/services';\nimport { NgDocContentScrollIntent } from '@ng-doc/app/services/content-scroll-intent';\nimport type { NgDocHighlighterConfig } from '@ng-doc/app/services/highlighter';\nimport { NgDocHighlighterService } from '@ng-doc/app/services/highlighter';\nimport { NG_DOC_SHORTCUTS, NgDocShortcutsService } from '@ng-doc/app/services/shortcuts';\nimport type { NgDocContentScrollPositionRestoration } from '@ng-doc/app/tokens';\nimport {\n NG_DOC_CONTENT_ANCHOR_SCROLLING,\n NG_DOC_CONTENT_SCROLL_POSITION_RESTORATION,\n} from '@ng-doc/app/tokens';\nimport type { NgDocUiConfig } from '@ng-doc/ui-kit';\nimport { provideNgDocUiKitConfig } from '@ng-doc/ui-kit';\n\n/**\n * NgDoc application config.\n */\nexport interface NgDocApplicationConfig {\n /**\n * Replays a router anchor scroll once asynchronous NgDoc content has been processed.\n * Enable this beside Angular router anchor scrolling.\n */\n contentAnchorScrolling?: boolean;\n /**\n * Replays a saved router position after asynchronous NgDoc content is processed.\n * Select the same intent as Angular router scroll position restoration.\n */\n contentScrollPositionRestoration?: NgDocContentScrollPositionRestoration;\n /**\n * UI Kit configuration.\n */\n uiKit?: NgDocUiConfig;\n /**\n * Extra Shiki themes and languages for the code that the browser highlights.\n */\n shiki?: NgDocHighlighterConfig;\n /**\n * Whether single-key shortcuts (slash, the square brackets, F, L and T) are on for readers who\n * have not turned them on or off themselves. Readers can always change it with the switch in\n * the search palette. Command+K (Control+K) opens the search either way. Defaults to true.\n */\n shortcuts?: boolean;\n}\n\n/**\n * Provides the NgDoc application configuration.\n *\n * Add it to the application's providers, or to the `providers` of the route that holds the\n * documentation, together with the other NgDoc providers: then NgDoc starts only when the reader\n * opens the documentation, and its code stays out of the application's initial bundle. It starts\n * with environment initializers, which run where it is provided. The server render waits until\n * the code highlighter of playgrounds has loaded.\n * @param config - The optional application configuration.\n */\nexport function provideNgDocApp(\n config?: NgDocApplicationConfig,\n): Array<EnvironmentProviders | Provider> {\n return [\n { provide: NG_DOC_CONTENT_ANCHOR_SCROLLING, useValue: config?.contentAnchorScrolling ?? false },\n {\n provide: NG_DOC_CONTENT_SCROLL_POSITION_RESTORATION,\n useValue: config?.contentScrollPositionRestoration ?? 'disabled',\n },\n { provide: NG_DOC_SHORTCUTS, useValue: config?.shortcuts ?? true },\n\n /* --- Services --- */\n // Provided where the configuration is, so that they read the NgDoc providers of a lazy route\n // (the generated context, the shortcuts option): an instance in the root injector could not\n // see them. In the root injector this is the instance `providedIn: 'root'` gives.\n NgDocHighlighterService,\n NgDocShortcutsService,\n NgDocApiListIndexService,\n\n ...(config?.contentAnchorScrolling || config?.contentScrollPositionRestoration === 'enabled'\n ? [\n provideEnvironmentInitializer(() => {\n inject(NgDocContentScrollIntent).start();\n }),\n ]\n : []),\n\n /* --- Hydration --- */\n // Before the documentation renders: the pages and headers that skip hydration show their\n // server-rendered content until their own is rendered, instead of a blank page. A lazy route\n // creates its injector before it creates its components, so this also runs in time when the\n // documentation is the first route the browser hydrates.\n provideEnvironmentInitializer(() => {\n if (isPlatformBrowser(inject(PLATFORM_ID))) ɵcaptureNgDocHydrationSnapshots(inject(DOCUMENT));\n }),\n\n /* --- Shiki --- */\n // Started with the documentation instead of blocking the application's start: the playgrounds\n // highlight their code once it is ready, and the application stays unstable until then, so the\n // server renders the highlighted code.\n provideEnvironmentInitializer(() => {\n const highlighter = inject(NgDocHighlighterService);\n\n inject(PendingTasks).run(() => highlighter.initialize(config?.shiki));\n }),\n\n /* --- UiKit --- */\n ...provideNgDocUiKitConfig(config?.u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|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { InjectionToken, inject } from '@angular/core';
|
|
2
|
+
import { NG_DOC_TEXTS, mergeNgDocTexts, NG_DOC_DEFAULT_TEXTS } from '@ng-doc/app/tokens';
|
|
3
|
+
import { NG_DOC_UI_KIT_TEXTS } from '@ng-doc/ui-kit/texts';
|
|
4
|
+
|
|
5
|
+
/** The changes of every `provideNgDocTexts` call of one injector, in the order of the calls. */
|
|
6
|
+
const NG_DOC_TEXTS_OVERRIDES = new InjectionToken('NG_DOC_TEXTS_OVERRIDES');
|
|
7
|
+
/**
|
|
8
|
+
* Changes the texts NgDoc shows to readers, for example to translate them. Pass the groups and
|
|
9
|
+
* texts to change; every other text keeps its English default (`NG_DOC_DEFAULT_TEXTS`). NgDoc
|
|
10
|
+
* ships complete translations in entry points of their own, such as `NG_DOC_TEXTS_DE` from
|
|
11
|
+
* `@ng-doc/app/texts/de`; pass one first and your changes after it.
|
|
12
|
+
*
|
|
13
|
+
* Calls and arguments add up: in one injector they apply in order, so a later one wins for a
|
|
14
|
+
* text both set, and the providers of a child injector (a lazy route, for example) apply on top of the
|
|
15
|
+
* texts of its parent. The texts are read when a component is created, so they are fixed per
|
|
16
|
+
* injector: switch the language by reloading the application, not at run time.
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* provideNgDocTexts(NG_DOC_TEXTS_DE, { search: { placeholder: 'Handbuch durchsuchen…' } });
|
|
20
|
+
*
|
|
21
|
+
* provideNgDocTexts({
|
|
22
|
+
* search: { placeholder: 'Dokumentation durchsuchen…' },
|
|
23
|
+
* searchPalette: { noResults: ({ query }) => `Keine Ergebnisse für „${query}“` },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
* @param texts - The texts to change, by group, in the order they apply.
|
|
27
|
+
* @returns The providers to add to the application, a route or a page.
|
|
28
|
+
*/
|
|
29
|
+
function provideNgDocTexts(...texts) {
|
|
30
|
+
return [
|
|
31
|
+
...texts.map((overrides) => ({
|
|
32
|
+
provide: NG_DOC_TEXTS_OVERRIDES,
|
|
33
|
+
useValue: overrides,
|
|
34
|
+
multi: true,
|
|
35
|
+
})),
|
|
36
|
+
{ provide: NG_DOC_TEXTS, useFactory: resolveTexts },
|
|
37
|
+
// The ui-kit components read their own token: NgDocTexts extends NgDocUiKitTexts, so the
|
|
38
|
+
// same object serves both and the two libraries always show the same texts.
|
|
39
|
+
{ provide: NG_DOC_UI_KIT_TEXTS, useFactory: () => inject(NG_DOC_TEXTS) },
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
/** The texts of the parent injector, or the defaults, with this injector's changes on top. */
|
|
43
|
+
function resolveTexts() {
|
|
44
|
+
const parent = inject(NG_DOC_TEXTS, { skipSelf: true, optional: true });
|
|
45
|
+
return mergeNgDocTexts(parent ?? NG_DOC_DEFAULT_TEXTS, ...inject(NG_DOC_TEXTS_OVERRIDES, { self: true }));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Generated bundle index. Do not edit.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
export { provideNgDocTexts };
|
|
53
|
+
//# sourceMappingURL=ng-doc-app-providers-texts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-doc-app-providers-texts.mjs","sources":["../../../../libs/app/providers/texts/provide-ng-doc-texts.ts","../../../../libs/app/providers/texts/ng-doc-app-providers-texts.ts"],"sourcesContent":["import { inject, InjectionToken, Provider } from '@angular/core';\nimport type { NgDocTexts, NgDocTextsOverrides } from '@ng-doc/app/interfaces';\nimport { mergeNgDocTexts, NG_DOC_DEFAULT_TEXTS, NG_DOC_TEXTS } from '@ng-doc/app/tokens';\nimport { NG_DOC_UI_KIT_TEXTS } from '@ng-doc/ui-kit/texts';\n\n/** The changes of every `provideNgDocTexts` call of one injector, in the order of the calls. */\nconst NG_DOC_TEXTS_OVERRIDES = new InjectionToken<NgDocTextsOverrides[]>('NG_DOC_TEXTS_OVERRIDES');\n\n/**\n * Changes the texts NgDoc shows to readers, for example to translate them. Pass the groups and\n * texts to change; every other text keeps its English default (`NG_DOC_DEFAULT_TEXTS`). NgDoc\n * ships complete translations in entry points of their own, such as `NG_DOC_TEXTS_DE` from\n * `@ng-doc/app/texts/de`; pass one first and your changes after it.\n *\n * Calls and arguments add up: in one injector they apply in order, so a later one wins for a\n * text both set, and the providers of a child injector (a lazy route, for example) apply on top of the\n * texts of its parent. The texts are read when a component is created, so they are fixed per\n * injector: switch the language by reloading the application, not at run time.\n * @example\n * ```typescript\n * provideNgDocTexts(NG_DOC_TEXTS_DE, { search: { placeholder: 'Handbuch durchsuchen…' } });\n *\n * provideNgDocTexts({\n * search: { placeholder: 'Dokumentation durchsuchen…' },\n * searchPalette: { noResults: ({ query }) => `Keine Ergebnisse für „${query}“` },\n * });\n * ```\n * @param texts - The texts to change, by group, in the order they apply.\n * @returns The providers to add to the application, a route or a page.\n */\nexport function provideNgDocTexts(...texts: NgDocTextsOverrides[]): Provider[] {\n return [\n ...texts.map((overrides: NgDocTextsOverrides) => ({\n provide: NG_DOC_TEXTS_OVERRIDES,\n useValue: overrides,\n multi: true,\n })),\n { provide: NG_DOC_TEXTS, useFactory: resolveTexts },\n // The ui-kit components read their own token: NgDocTexts extends NgDocUiKitTexts, so the\n // same object serves both and the two libraries always show the same texts.\n { provide: NG_DOC_UI_KIT_TEXTS, useFactory: () => inject(NG_DOC_TEXTS) },\n ];\n}\n\n/** The texts of the parent injector, or the defaults, with this injector's changes on top. */\nfunction resolveTexts(): NgDocTexts {\n const parent: NgDocTexts | null = inject(NG_DOC_TEXTS, { skipSelf: true, optional: true });\n\n return mergeNgDocTexts(\n parent ?? NG_DOC_DEFAULT_TEXTS,\n ...inject(NG_DOC_TEXTS_OVERRIDES, { self: true }),\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAKA;AACA,MAAM,sBAAsB,GAAG,IAAI,cAAc,CAAwB,wBAAwB,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;;AAqBG;AACG,SAAU,iBAAiB,CAAC,GAAG,KAA4B,EAAA;IAC/D,OAAO;QACL,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,SAA8B,MAAM;AAChD,YAAA,OAAO,EAAE,sBAAsB;AAC/B,YAAA,QAAQ,EAAE,SAAS;AACnB,YAAA,KAAK,EAAE,IAAI;AACZ,SAAA,CAAC,CAAC;AACH,QAAA,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE;;;AAGnD,QAAA,EAAE,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE;KACzE;AACH;AAEA;AACA,SAAS,YAAY,GAAA;AACnB,IAAA,MAAM,MAAM,GAAsB,MAAM,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAE1F,IAAA,OAAO,eAAe,CACpB,MAAM,IAAI,oBAAoB,EAC9B,GAAG,MAAM,CAAC,sBAAsB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAClD;AACH;;ACpDA;;AAEG;;;;"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, EnvironmentInjector, runInInjectionContext, Injectable, makeEnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { Title } from '@angular/platform-browser';
|
|
4
|
+
import { TitleStrategy } from '@angular/router';
|
|
5
|
+
|
|
6
|
+
/** Route data key that names what a generated route's title belongs to. */
|
|
7
|
+
const TITLE_KIND_DATA = 'ngDocTitle';
|
|
8
|
+
/** Route data key of a page route that names the page type (`guide` or `api`). */
|
|
9
|
+
const PAGE_TYPE_DATA = 'ngDocPageType';
|
|
10
|
+
/** The function that `provideNgDocTitle` was given. */
|
|
11
|
+
const NG_DOC_TITLE_FN = new InjectionToken('NG_DOC_TITLE_FN');
|
|
12
|
+
/**
|
|
13
|
+
* Title strategy that builds the document title with the function given to `provideNgDocTitle`,
|
|
14
|
+
* from the categories, page, tab and API declaration of the current route. It stays internal:
|
|
15
|
+
* `provideNgDocTitle` is the public way to set it.
|
|
16
|
+
*/
|
|
17
|
+
class NgDocTitleStrategy extends TitleStrategy {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.title = inject(Title);
|
|
21
|
+
this.injector = inject(EnvironmentInjector);
|
|
22
|
+
this.titleFn = inject(NG_DOC_TITLE_FN);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sets the document title for the router state.
|
|
26
|
+
* @param snapshot - The router state after a navigation.
|
|
27
|
+
*/
|
|
28
|
+
updateTitle(snapshot) {
|
|
29
|
+
const title = runInInjectionContext(this.injector, () => this.titleFn(this.buildContext(snapshot)));
|
|
30
|
+
if (title !== undefined) {
|
|
31
|
+
this.title.setTitle(title);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Collects the titles of the router state by what they belong to.
|
|
36
|
+
* @param snapshot - The router state after a navigation.
|
|
37
|
+
*/
|
|
38
|
+
buildContext(snapshot) {
|
|
39
|
+
const categories = [];
|
|
40
|
+
let page;
|
|
41
|
+
let tab;
|
|
42
|
+
let ownTitle;
|
|
43
|
+
let isApi = false;
|
|
44
|
+
for (let route = snapshot.root; route; route = route.firstChild) {
|
|
45
|
+
const config = route.routeConfig;
|
|
46
|
+
if (config?.data?.[PAGE_TYPE_DATA] === 'api') {
|
|
47
|
+
isApi = true;
|
|
48
|
+
}
|
|
49
|
+
// Only a route's own title counts: routes without one inherit the title of their parent,
|
|
50
|
+
// which would repeat it.
|
|
51
|
+
if (config?.title === undefined) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const title = this.getResolvedTitleForRoute(route);
|
|
55
|
+
if (typeof title !== 'string') {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
switch (config.data?.[TITLE_KIND_DATA]) {
|
|
59
|
+
case 'category':
|
|
60
|
+
categories.push(title);
|
|
61
|
+
break;
|
|
62
|
+
case 'page':
|
|
63
|
+
page = title;
|
|
64
|
+
break;
|
|
65
|
+
case 'tab':
|
|
66
|
+
// A page with one tab shows no tabs, and the tab's title is the page's.
|
|
67
|
+
if ((route.parent?.routeConfig?.children?.length ?? 0) > 1) {
|
|
68
|
+
tab = title;
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
default:
|
|
72
|
+
// A title below the page comes from the page's own `route`, and wins over the
|
|
73
|
+
// generated one. Titles above the documentation belong to the application.
|
|
74
|
+
if (page !== undefined) {
|
|
75
|
+
ownTitle = title;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// The first tab of a page usually has no title of its own and shows the page's.
|
|
80
|
+
if (tab === page) {
|
|
81
|
+
tab = undefined;
|
|
82
|
+
}
|
|
83
|
+
page = ownTitle ?? page;
|
|
84
|
+
return {
|
|
85
|
+
title: this.buildTitle(snapshot),
|
|
86
|
+
categories,
|
|
87
|
+
page: isApi ? undefined : page,
|
|
88
|
+
tab,
|
|
89
|
+
api: isApi ? page : undefined,
|
|
90
|
+
snapshot,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: NgDocTitleStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
94
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: NgDocTitleStrategy }); }
|
|
95
|
+
}
|
|
96
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.1", ngImport: i0, type: NgDocTitleStrategy, decorators: [{
|
|
97
|
+
type: Injectable
|
|
98
|
+
}] });
|
|
99
|
+
/**
|
|
100
|
+
* Builds the browser tab title of every navigation with a function that receives the categories,
|
|
101
|
+
* the page, the tab and the API declaration of the route, so titles like
|
|
102
|
+
* "Installation · Getting started | NgDoc" need no parsing of route titles.
|
|
103
|
+
*
|
|
104
|
+
* Without it, Angular sets the title of the deepest route: the page's (or its tab's) title.
|
|
105
|
+
* @param titleFn - Builds the title; `undefined` keeps the current title.
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* provideNgDocTitle(({ categories, page, tab, api, title }) => {
|
|
109
|
+
* const name = api ?? page;
|
|
110
|
+
*
|
|
111
|
+
* return name
|
|
112
|
+
* ? [tab, name, ...[...categories].reverse()].filter(Boolean).join(' · ') + ' | My library'
|
|
113
|
+
* : (title ?? 'My library');
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
function provideNgDocTitle(titleFn) {
|
|
118
|
+
return makeEnvironmentProviders([
|
|
119
|
+
{ provide: NG_DOC_TITLE_FN, useValue: titleFn },
|
|
120
|
+
{ provide: TitleStrategy, useClass: NgDocTitleStrategy },
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Generated bundle index. Do not edit.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
export { provideNgDocTitle };
|
|
129
|
+
//# sourceMappingURL=ng-doc-app-providers-title.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-doc-app-providers-title.mjs","sources":["../../../../libs/app/providers/title/provide-ng-doc-title.ts","../../../../libs/app/providers/title/ng-doc-app-providers-title.ts"],"sourcesContent":["import {\n EnvironmentInjector,\n EnvironmentProviders,\n inject,\n Injectable,\n InjectionToken,\n makeEnvironmentProviders,\n runInInjectionContext,\n} from '@angular/core';\nimport { Title } from '@angular/platform-browser';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot, TitleStrategy } from '@angular/router';\n\n/**\n * What the title of a route belongs to. NgDoc writes it as `ngDocTitle` into the `data` of the\n * routes it generates.\n */\ntype NgDocTitleKind = 'category' | 'page' | 'tab';\n\n/** Route data key that names what a generated route's title belongs to. */\nconst TITLE_KIND_DATA: string = 'ngDocTitle';\n\n/** Route data key of a page route that names the page type (`guide` or `api`). */\nconst PAGE_TYPE_DATA: string = 'ngDocPageType';\n\n/**\n * The parts of the current route that `provideNgDocTitle` passes to its function.\n *\n * Outside the documentation (a landing page, for example), `categories` is empty and `page`,\n * `tab` and `api` are not set.\n */\nexport interface NgDocTitleContext {\n /**\n * The title Angular sets by default: the title of the deepest route that has one. It is not set\n * when no route of the navigation has a title.\n */\n readonly title: string | undefined;\n /** Titles of the categories that contain the page, the outermost category first. */\n readonly categories: readonly string[];\n /**\n * Title of the guide or the API list. A title in the page's own route replaces it. Not set on\n * an API page, which sets `api` instead.\n */\n readonly page: string | undefined;\n /**\n * Title of the active tab, when the page has more than one tab. Not set on a tab titled like\n * the page, usually its first one.\n */\n readonly tab: string | undefined;\n /** Name of the API declaration, on an API page. */\n readonly api: string | undefined;\n /** The router state the title is for. */\n readonly snapshot: RouterStateSnapshot;\n}\n\n/**\n * Builds the browser tab title from the parts of the current route. It runs in an injection\n * context, so it can call `inject()`. When it returns `undefined`, the title stays as it is.\n */\nexport type NgDocTitleFn = (context: NgDocTitleContext) => string | undefined;\n\n/** The function that `provideNgDocTitle` was given. */\nconst NG_DOC_TITLE_FN = new InjectionToken<NgDocTitleFn>('NG_DOC_TITLE_FN');\n\n/**\n * Title strategy that builds the document title with the function given to `provideNgDocTitle`,\n * from the categories, page, tab and API declaration of the current route. It stays internal:\n * `provideNgDocTitle` is the public way to set it.\n */\n@Injectable()\nclass NgDocTitleStrategy extends TitleStrategy {\n private readonly title = inject(Title);\n private readonly injector = inject(EnvironmentInjector);\n private readonly titleFn = inject(NG_DOC_TITLE_FN);\n\n /**\n * Sets the document title for the router state.\n * @param snapshot - The router state after a navigation.\n */\n override updateTitle(snapshot: RouterStateSnapshot): void {\n const title = runInInjectionContext(this.injector, () =>\n this.titleFn(this.buildContext(snapshot)),\n );\n\n if (title !== undefined) {\n this.title.setTitle(title);\n }\n }\n\n /**\n * Collects the titles of the router state by what they belong to.\n * @param snapshot - The router state after a navigation.\n */\n buildContext(snapshot: RouterStateSnapshot): NgDocTitleContext {\n const categories: string[] = [];\n let page: string | undefined;\n let tab: string | undefined;\n let ownTitle: string | undefined;\n let isApi = false;\n\n for (\n let route: ActivatedRouteSnapshot | null = snapshot.root;\n route;\n route = route.firstChild\n ) {\n const config = route.routeConfig;\n\n if (config?.data?.[PAGE_TYPE_DATA] === 'api') {\n isApi = true;\n }\n\n // Only a route's own title counts: routes without one inherit the title of their parent,\n // which would repeat it.\n if (config?.title === undefined) {\n continue;\n }\n\n const title = this.getResolvedTitleForRoute(route);\n\n if (typeof title !== 'string') {\n continue;\n }\n\n switch (config.data?.[TITLE_KIND_DATA] as NgDocTitleKind | undefined) {\n case 'category':\n categories.push(title);\n break;\n case 'page':\n page = title;\n break;\n case 'tab':\n // A page with one tab shows no tabs, and the tab's title is the page's.\n if ((route.parent?.routeConfig?.children?.length ?? 0) > 1) {\n tab = title;\n }\n break;\n default:\n // A title below the page comes from the page's own `route`, and wins over the\n // generated one. Titles above the documentation belong to the application.\n if (page !== undefined) {\n ownTitle = title;\n }\n }\n }\n\n // The first tab of a page usually has no title of its own and shows the page's.\n if (tab === page) {\n tab = undefined;\n }\n\n page = ownTitle ?? page;\n\n return {\n title: this.buildTitle(snapshot),\n categories,\n page: isApi ? undefined : page,\n tab,\n api: isApi ? page : undefined,\n snapshot,\n };\n }\n}\n\n/**\n * Builds the browser tab title of every navigation with a function that receives the categories,\n * the page, the tab and the API declaration of the route, so titles like\n * \"Installation · Getting started | NgDoc\" need no parsing of route titles.\n *\n * Without it, Angular sets the title of the deepest route: the page's (or its tab's) title.\n * @param titleFn - Builds the title; `undefined` keeps the current title.\n * @example\n * ```ts\n * provideNgDocTitle(({ categories, page, tab, api, title }) => {\n * const name = api ?? page;\n *\n * return name\n * ? [tab, name, ...[...categories].reverse()].filter(Boolean).join(' · ') + ' | My library'\n * : (title ?? 'My library');\n * });\n * ```\n */\nexport function provideNgDocTitle(titleFn: NgDocTitleFn): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: NG_DOC_TITLE_FN, useValue: titleFn },\n { provide: TitleStrategy, useClass: NgDocTitleStrategy },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAkBA;AACA,MAAM,eAAe,GAAW,YAAY;AAE5C;AACA,MAAM,cAAc,GAAW,eAAe;AAsC9C;AACA,MAAM,eAAe,GAAG,IAAI,cAAc,CAAe,iBAAiB,CAAC;AAE3E;;;;AAIG;AACH,MACM,kBAAmB,SAAQ,aAAa,CAAA;AAD9C,IAAA,WAAA,GAAA;;AAEmB,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AACrB,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,mBAAmB,CAAC;AACtC,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC;AAwFnD,IAAA;AAtFC;;;AAGG;AACM,IAAA,WAAW,CAAC,QAA6B,EAAA;QAChD,MAAM,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,MACjD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAC1C;AAED,QAAA,IAAI,KAAK,KAAK,SAAS,EAAE;AACvB,YAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC5B;IACF;AAEA;;;AAGG;AACH,IAAA,YAAY,CAAC,QAA6B,EAAA;QACxC,MAAM,UAAU,GAAa,EAAE;AAC/B,QAAA,IAAI,IAAwB;AAC5B,QAAA,IAAI,GAAuB;AAC3B,QAAA,IAAI,QAA4B;QAChC,IAAI,KAAK,GAAG,KAAK;AAEjB,QA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8GA1FI,kBAAkB,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;kHAAlB,kBAAkB,EAAA,CAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBADvB;;AA8FD;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,iBAAiB,CAAC,OAAqB,EAAA;AACrD,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC/C,QAAA,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,kBAAkB,EAAE;AACzD,KAAA,CAAC;AACJ;;ACzLA;;AAEG;;;;"}
|
|
@@ -3,6 +3,8 @@ export * from '@ng-doc/app/providers/ng-doc-app';
|
|
|
3
3
|
export * from '@ng-doc/app/providers/page-skeleton';
|
|
4
4
|
export * from '@ng-doc/app/providers/playground-demo';
|
|
5
5
|
export * from '@ng-doc/app/providers/search-engine';
|
|
6
|
+
export * from '@ng-doc/app/providers/texts';
|
|
7
|
+
export * from '@ng-doc/app/providers/title';
|
|
6
8
|
export * from '@ng-doc/app/providers/type-control';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-doc-app-providers.mjs","sources":["../../../../libs/app/providers/ng-doc-app-providers.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ng-doc-app-providers.mjs","sources":["../../../../libs/app/providers/ng-doc-app-providers.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;AAEG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPlatformBrowser } from '@angular/common';
|
|
1
|
+
import { isPlatformBrowser, Location } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { inject, PLATFORM_ID, signal, DestroyRef, Service } from '@angular/core';
|
|
4
4
|
import { Router, NavigationStart, NavigationEnd, Scroll, NavigationCancel, NavigationError, NavigationSkipped } from '@angular/router';
|
|
@@ -8,6 +8,7 @@ class NgDocContentScrollIntent {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
this.browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
10
10
|
this.router = inject(Router);
|
|
11
|
+
this.location = inject(Location);
|
|
11
12
|
this.listeners = new Set();
|
|
12
13
|
this.started = false;
|
|
13
14
|
this.successful = false;
|
|
@@ -19,11 +20,15 @@ class NgDocContentScrollIntent {
|
|
|
19
20
|
this.currentIntent = this.intentState.asReadonly();
|
|
20
21
|
inject(DestroyRef).onDestroy(() => this.destroy());
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Starts following router events. Does nothing on the server or when already started. Started
|
|
25
|
+
* during a navigation, it follows that navigation too.
|
|
26
|
+
*/
|
|
23
27
|
start() {
|
|
24
28
|
if (this.started || !this.browser)
|
|
25
29
|
return;
|
|
26
30
|
this.started = true;
|
|
31
|
+
this.followCurrentNavigation();
|
|
27
32
|
this.subscription = this.router.events.subscribe((event) => {
|
|
28
33
|
if (event instanceof NavigationStart)
|
|
29
34
|
this.navigationStarted(event);
|
|
@@ -73,6 +78,26 @@ class NgDocContentScrollIntent {
|
|
|
73
78
|
navigation.extras.scroll !== 'manual',
|
|
74
79
|
};
|
|
75
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Takes the navigation in progress as the candidate. The providers of a lazy route start the
|
|
83
|
+
* intent while the router loads that route, after the first navigation has started, and its
|
|
84
|
+
* fragment must still be replayed.
|
|
85
|
+
*/
|
|
86
|
+
followCurrentNavigation() {
|
|
87
|
+
const navigation = this.router.currentNavigation();
|
|
88
|
+
if (!navigation)
|
|
89
|
+
return;
|
|
90
|
+
// The router restores the history state of the first navigation, as `restoredState` of its
|
|
91
|
+
// NavigationStart, when that state has a navigation id.
|
|
92
|
+
const state = this.location.getState();
|
|
93
|
+
this.candidate = {
|
|
94
|
+
navigationId: navigation.id,
|
|
95
|
+
eligible: navigation.trigger === 'imperative' &&
|
|
96
|
+
navigation.previousNavigation === null &&
|
|
97
|
+
!state?.navigationId &&
|
|
98
|
+
navigation.extras.scroll !== 'manual',
|
|
99
|
+
};
|
|
100
|
+
}
|
|
76
101
|
navigationEnded(event) {
|
|
77
102
|
const candidate = this.candidate;
|
|
78
103
|
this.candidate = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-doc-app-services-content-scroll-intent.mjs","sources":["../../../../libs/app/services/content-scroll-intent/content-scroll-intent.service.ts","../../../../libs/app/services/content-scroll-intent/ng-doc-app-services-content-scroll-intent.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, inject, PLATFORM_ID, Service, Signal, signal } from '@angular/core';\nimport {\n NavigationCancel,\n NavigationEnd,\n NavigationError,\n NavigationSkipped,\n NavigationStart,\n Router,\n Scroll,\n} from '@angular/router';\nimport { Subscription } from 'rxjs';\n\n/** The fragment of the application's first navigation, kept until a page replays or drops it. */\nexport interface NgDocInitialContentScrollIntent {\n /** The decoded fragment of the navigation. */\n readonly anchor: string;\n /** Id of the navigation that produced the fragment. */\n readonly navigationId: number;\n /** The URL after redirects. */\n readonly url: string;\n}\n\n/** Captures the public initial-navigation facts that are unavailable after component activation. */\n@Service()\nexport class NgDocContentScrollIntent {\n private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly router = inject(Router);\n private candidate?: { eligible: boolean; navigationId: number };\n private intent?: NgDocInitialContentScrollIntent;\n private readonly listeners = new Set<\n (intent: NgDocInitialContentScrollIntent | undefined) => void\n >();\n private started = false;\n private successful = false;\n private subscription?: Subscription;\n private readonly intentState = signal<NgDocInitialContentScrollIntent | undefined>(undefined);\n\n /**\n * The pending initial intent as a signal, the same value `subscribe()` listeners receive.\n */\n readonly currentIntent: Signal<NgDocInitialContentScrollIntent | undefined> =\n this.intentState.asReadonly();\n\n constructor() {\n inject(DestroyRef).onDestroy(() => this.destroy());\n }\n\n /** Starts following router events. Does nothing on the server or when already started. */\n start(): void {\n if (this.started || !this.browser) return;\n this.started = true;\n this.subscription = this.router.events.subscribe((event) => {\n if (event instanceof NavigationStart) this.navigationStarted(event);\n else if (event instanceof NavigationEnd) this.navigationEnded(event);\n else if (event instanceof Scroll) this.scrolled(event);\n else if (\n event instanceof NavigationCancel ||\n event instanceof NavigationError ||\n event instanceof NavigationSkipped\n ) {\n if (this.candidate && event.id >= this.candidate.navigationId) this.candidate = undefined;\n if (this.intent && event.id >= this.intent.navigationId) this.publish(undefined);\n }\n });\n }\n\n /**\n * Calls the listener with every change of the intent, and at once with the pending one.\n * @param listener - Receives the intent, or `undefined` once it is consumed or cancelled.\n * @returns A function that removes the listener.\n */\n subscribe(listener: (intent: NgDocInitialContentScrollIntent | undefined) => void): () => void {\n this.listeners.add(listener);\n if (this.intent) listener(this.intent);\n return () => this.listeners.delete(listener);\n }\n\n /**\n * Consumes the current fallback after its page has either replayed or explicitly yielded it.\n * @param navigationId - The navigation of the intent to consume.\n */\n settle(navigationId: number): void {\n if (this.intent?.navigationId === navigationId) this.publish(undefined);\n }\n\n private navigationStarted(event: NavigationStart): void {\n this.publish(undefined);\n const navigation = this.router.currentNavigation();\n this.candidate = {\n navigationId: event.id,\n eligible:\n !this.successful &&\n event.navigationTrigger === 'imperative' &&\n event.restoredState == null &&\n navigation?.id === event.id &&\n navigation.previousNavigation === null &&\n navigation.extras.scroll !== 'manual',\n };\n }\n\n private navigationEnded(event: NavigationEnd): void {\n const candidate = this.candidate;\n this.candidate = undefined;\n this.successful = true;\n if (!candidate?.eligible || candidate.navigationId !== event.id) return;\n const anchor = this.router.parseUrl(event.urlAfterRedirects).fragment;\n if (anchor) {\n this.publish({ anchor, navigationId: event.id, url: event.urlAfterRedirects });\n }\n }\n\n private scrolled(event: Scroll): void {\n if (this.intent && event.routerEvent.id >= this.intent.navigationId) this.publish(undefined);\n if (this.candidate && event.routerEvent.id >= this.candidate.navigationId) {\n this.candidate = undefined;\n }\n }\n\n private publish(intent: NgDocInitialContentScrollIntent | undefined): void {\n if (this.intent === intent) return;\n this.intent = intent;\n this.intentState.set(intent);\n for (const listener of [...this.listeners]) listener(intent);\n }\n\n private destroy(): void {\n this.subscription?.unsubscribe();\n this.subscription = undefined;\n this.candidate = undefined;\n this.intent = undefined;\n this.intentState.set(undefined);\n this.listeners.clear();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAuBA;MAEa,wBAAwB,CAAA;AAmBnC,IAAA,WAAA,GAAA;QAlBiB,IAAA,CAAA,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAChD,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAGvB,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,GAAG,EAEjC;QACK,IAAA,CAAA,OAAO,GAAG,KAAK;QACf,IAAA,CAAA,UAAU,GAAG,KAAK;QAET,IAAA,CAAA,WAAW,GAAG,MAAM,CAA8C,SAAS;wFAAC;AAE7F;;AAEG;AACM,QAAA,IAAA,CAAA,aAAa,GACpB,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;AAG7B,QAAA,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACpD;;IAGA,KAAK,GAAA;AACH,QAAA,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE;AACnC,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI;AACnB,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,KAAI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E,YAAA,IAAI,CAAC,SAAS,GAAG,SAAS;QAC5B;IACF;AAEQ,IAAA,OAAO,CAAC,MAAmD,EAAA;AACjE,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;YAAE;AAC5B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;QAC5B,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;YAAE,QAAQ,CAAC,MAAM,CAAC;IAC9D;IAEQ,OAAO,GAAA;AACb,QAAA,IAAI,CAAC,YAAY,EAAE,WAAW,EAAE;AAChC,QAAA,IAAI,CAAC,YAAY,GAAG,SAAS;AAC7B,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;AAC1B,QAAA,IAAI,CAAC,MAAM,GAAG,SAAS;AACvB,QAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;AAC/B,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;IACxB;8GA5GW,wBAAwB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,OAAA,EAAA,CAAA,CAAA;+GAAxB,wBAAwB,EAAA,CAAA,CAAA;;2FAAxB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBADpC;;;ACxBD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-doc-app-services-content-scroll-intent.mjs","sources":["../../../../libs/app/services/content-scroll-intent/content-scroll-intent.service.ts","../../../../libs/app/services/content-scroll-intent/ng-doc-app-services-content-scroll-intent.ts"],"sourcesContent":["import { isPlatformBrowser, Location } from '@angular/common';\nimport { DestroyRef, inject, PLATFORM_ID, Service, Signal, signal } from '@angular/core';\nimport {\n NavigationCancel,\n NavigationEnd,\n NavigationError,\n NavigationSkipped,\n NavigationStart,\n Router,\n Scroll,\n} from '@angular/router';\nimport { Subscription } from 'rxjs';\n\n/** The fragment of the application's first navigation, kept until a page replays or drops it. */\nexport interface NgDocInitialContentScrollIntent {\n /** The decoded fragment of the navigation. */\n readonly anchor: string;\n /** Id of the navigation that produced the fragment. */\n readonly navigationId: number;\n /** The URL after redirects. */\n readonly url: string;\n}\n\n/** Captures the public initial-navigation facts that are unavailable after component activation. */\n@Service()\nexport class NgDocContentScrollIntent {\n private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly router = inject(Router);\n private readonly location = inject(Location);\n private candidate?: { eligible: boolean; navigationId: number };\n private intent?: NgDocInitialContentScrollIntent;\n private readonly listeners = new Set<\n (intent: NgDocInitialContentScrollIntent | undefined) => void\n >();\n private started = false;\n private successful = false;\n private subscription?: Subscription;\n private readonly intentState = signal<NgDocInitialContentScrollIntent | undefined>(undefined);\n\n /**\n * The pending initial intent as a signal, the same value `subscribe()` listeners receive.\n */\n readonly currentIntent: Signal<NgDocInitialContentScrollIntent | undefined> =\n this.intentState.asReadonly();\n\n constructor() {\n inject(DestroyRef).onDestroy(() => this.destroy());\n }\n\n /**\n * Starts following router events. Does nothing on the server or when already started. Started\n * during a navigation, it follows that navigation too.\n */\n start(): void {\n if (this.started || !this.browser) return;\n this.started = true;\n this.followCurrentNavigation();\n this.subscription = this.router.events.subscribe((event) => {\n if (event instanceof NavigationStart) this.navigationStarted(event);\n else if (event instanceof NavigationEnd) this.navigationEnded(event);\n else if (event instanceof Scroll) this.scrolled(event);\n else if (\n event instanceof NavigationCancel ||\n event instanceof NavigationError ||\n event instanceof NavigationSkipped\n ) {\n if (this.candidate && event.id >= this.candidate.navigationId) this.candidate = undefined;\n if (this.intent && event.id >= this.intent.navigationId) this.publish(undefined);\n }\n });\n }\n\n /**\n * Calls the listener with every change of the intent, and at once with the pending one.\n * @param listener - Receives the intent, or `undefined` once it is consumed or cancelled.\n * @returns A function that removes the listener.\n */\n subscribe(listener: (intent: NgDocInitialContentScrollIntent | undefined) => void): () => void {\n this.listeners.add(listener);\n if (this.intent) listener(this.intent);\n return () => this.listeners.delete(listener);\n }\n\n /**\n * Consumes the current fallback after its page has either replayed or explicitly yielded it.\n * @param navigationId - The navigation of the intent to consume.\n */\n settle(navigationId: number): void {\n if (this.intent?.navigationId === navigationId) this.publish(undefined);\n }\n\n private navigationStarted(event: NavigationStart): void {\n this.publish(undefined);\n const navigation = this.router.currentNavigation();\n this.candidate = {\n navigationId: event.id,\n eligible:\n !this.successful &&\n event.navigationTrigger === 'imperative' &&\n event.restoredState == null &&\n navigation?.id === event.id &&\n navigation.previousNavigation === null &&\n navigation.extras.scroll !== 'manual',\n };\n }\n\n /**\n * Takes the navigation in progress as the candidate. The providers of a lazy route start the\n * intent while the router loads that route, after the first navigation has started, and its\n * fragment must still be replayed.\n */\n private followCurrentNavigation(): void {\n const navigation = this.router.currentNavigation();\n\n if (!navigation) return;\n\n // The router restores the history state of the first navigation, as `restoredState` of its\n // NavigationStart, when that state has a navigation id.\n const state = this.location.getState() as { navigationId?: unknown } | null;\n\n this.candidate = {\n navigationId: navigation.id,\n eligible:\n navigation.trigger === 'imperative' &&\n navigation.previousNavigation === null &&\n !state?.navigationId &&\n navigation.extras.scroll !== 'manual',\n };\n }\n\n private navigationEnded(event: NavigationEnd): void {\n const candidate = this.candidate;\n this.candidate = undefined;\n this.successful = true;\n if (!candidate?.eligible || candidate.navigationId !== event.id) return;\n const anchor = this.router.parseUrl(event.urlAfterRedirects).fragment;\n if (anchor) {\n this.publish({ anchor, navigationId: event.id, url: event.urlAfterRedirects });\n }\n }\n\n private scrolled(event: Scroll): void {\n if (this.intent && event.routerEvent.id >= this.intent.navigationId) this.publish(undefined);\n if (this.candidate && event.routerEvent.id >= this.candidate.navigationId) {\n this.candidate = undefined;\n }\n }\n\n private publish(intent: NgDocInitialContentScrollIntent | undefined): void {\n if (this.intent === intent) return;\n this.intent = intent;\n this.intentState.set(intent);\n for (const listener of [...this.listeners]) listener(intent);\n }\n\n private destroy(): void {\n this.subscription?.unsubscribe();\n this.subscription = undefined;\n this.candidate = undefined;\n this.intent = undefined;\n this.intentState.set(undefined);\n this.listeners.clear();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAuBA;MAEa,wBAAwB,CAAA;AAoBnC,IAAA,WAAA,GAAA;QAnBiB,IAAA,CAAA,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAChD,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAG3B,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,GAAG,EAEjC;QACK,IAAA,CAAA,OAAO,GAAG,KAAK;QACf,IAAA,CAAA,UAAU,GAAG,KAAK;QAET,IAAA,CAAA,WAAW,GAAG,MAAM,CAA8C,SAAS;wFAAC;AAE7F;;AAEG;AACM,QAAA,IAAA,CAAA,aAAa,GACpB,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;AAG7B,QAAA,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACpD;AAEA;;;AAGG;IACH,KAAK,GAAA;AACH,QAAA,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE;AACnC,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI;QACnB,IAAI,CAAC,uBAAuB,EAAE;AAC9B,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,KAAI;YACzD,IAAI,KAAK,YAAY,eAAe;AAAE,gBAAA,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;iBAC9D,IAAI,KAAK,YAAY,aAAa;AAAE,gBAAA,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;iBAC/D,IAAI,KAAK,YAAY,MAAM;AAAE,gBA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|
import { NG_DOC_SHIKI_THEME } from '@ng-doc/app/tokens';
|
|
4
4
|
import { ngDocSyntaxTheme } from '@ng-doc/core/constants/syntax-theme';
|
|
5
|
-
import { createHighlighterCore } from 'shiki/core';
|
|
6
|
-
import getWasm from 'shiki/wasm';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
|
-
* Highlights code with Shiki. `provideNgDocApp`
|
|
7
|
+
* Highlights code with Shiki. `provideNgDocApp` starts its initialization where it is provided (the
|
|
8
|
+
* application, or the route that holds the documentation), and the server render waits for it.
|
|
9
|
+
* Shiki is loaded on demand: `initialize()` imports it.
|
|
10
10
|
*/
|
|
11
11
|
class NgDocHighlighterService {
|
|
12
12
|
constructor() {
|
|
@@ -23,9 +23,9 @@ class NgDocHighlighterService {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Loads Shiki with the built-in themes (`github-light`, `ayu-dark` and NgDoc's `css-variables`)
|
|
26
|
-
* and the given ones. Concurrent and repeated calls share one
|
|
27
|
-
* be retried.
|
|
28
|
-
* @param config - Custom Shiki themes to load.
|
|
26
|
+
* and the given ones, and the given languages. Concurrent and repeated calls share one
|
|
27
|
+
* initialization; a failed one can be retried.
|
|
28
|
+
* @param config - Custom Shiki themes and languages to load.
|
|
29
29
|
*/
|
|
30
30
|
initialize(config) {
|
|
31
31
|
if (this.destroyed) {
|
|
@@ -39,11 +39,11 @@ class NgDocHighlighterService {
|
|
|
39
39
|
'`shiki.themes` of `ng-doc.config.ts`: NgDoc uses them for the code blocks and the ' +
|
|
40
40
|
'code that the browser highlights.');
|
|
41
41
|
}
|
|
42
|
-
// Only immutable built-in themes are shared across SSR applications. Custom
|
|
43
|
-
//
|
|
44
|
-
this.ownsHighlighter = Boolean(config?.themes?.length);
|
|
42
|
+
// Only immutable built-in themes and languages are shared across SSR applications. Custom
|
|
43
|
+
// ones may reuse names with other definitions, or be asynchronous getters.
|
|
44
|
+
this.ownsHighlighter = Boolean(config?.themes?.length || config?.langs?.length);
|
|
45
45
|
const creation = this.ownsHighlighter
|
|
46
|
-
? NgDocHighlighterService.create(config?.themes)
|
|
46
|
+
? NgDocHighlighterService.create(config?.themes, config?.langs)
|
|
47
47
|
: (NgDocHighlighterService.defaultInitialization ??= NgDocHighlighterService.create().catch((error) => {
|
|
48
48
|
NgDocHighlighterService.defaultInitialization = undefined;
|
|
49
49
|
throw error;
|
|
@@ -65,7 +65,7 @@ class NgDocHighlighterService {
|
|
|
65
65
|
});
|
|
66
66
|
return this.initialization;
|
|
67
67
|
}
|
|
68
|
-
/** Disposes the highlighter this service created for custom themes. */
|
|
68
|
+
/** Disposes the highlighter this service created for custom themes or languages. */
|
|
69
69
|
ngOnDestroy() {
|
|
70
70
|
this.destroyed = true;
|
|
71
71
|
this.readyState.set(false);
|
|
@@ -74,8 +74,12 @@ class NgDocHighlighterService {
|
|
|
74
74
|
}
|
|
75
75
|
this.highlighter = undefined;
|
|
76
76
|
}
|
|
77
|
-
static async create(themes = []) {
|
|
78
|
-
|
|
77
|
+
static async create(themes = [], langs = []) {
|
|
78
|
+
const [{ createHighlighterCore }, { createOnigurumaEngine }] = await Promise.all([
|
|
79
|
+
import('shiki/core'),
|
|
80
|
+
import('shiki/engine/oniguruma'),
|
|
81
|
+
]);
|
|
82
|
+
return createHighlighterCore({
|
|
79
83
|
themes: [
|
|
80
84
|
import('shiki/themes/github-light.mjs'),
|
|
81
85
|
import('shiki/themes/ayu-dark.mjs'),
|
|
@@ -83,9 +87,12 @@ class NgDocHighlighterService {
|
|
|
83
87
|
ngDocSyntaxTheme(),
|
|
84
88
|
...themes,
|
|
85
89
|
],
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
// Later registrations of a name replace earlier ones, so the given languages win.
|
|
91
|
+
langs: [import('shiki/langs/angular-html.mjs'), ...langs],
|
|
92
|
+
// The Oniguruma engine, as at build time, so that the browser tokenizes code as the code
|
|
93
|
+
// blocks were tokenized.
|
|
94
|
+
engine: createOnigurumaEngine(import('shiki/wasm')),
|
|
95
|
+
});
|
|
89
96
|
}
|
|
90
97
|
/**
|
|
91
98
|
* Returns the code as highlighted HTML, or an empty string before `initialize()` has
|