@depup/typedoc 0.28.17-depup.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 +201 -0
- package/README.md +34 -0
- package/bin/package.json +3 -0
- package/bin/typedoc +24 -0
- package/changes.json +22 -0
- package/dist/browser-locales/de.d.ts +2 -0
- package/dist/browser-locales/de.js +62 -0
- package/dist/browser-locales/en.d.ts +2 -0
- package/dist/browser-locales/en.js +62 -0
- package/dist/browser-locales/ja.d.ts +2 -0
- package/dist/browser-locales/ja.js +62 -0
- package/dist/browser-locales/ko.d.ts +2 -0
- package/dist/browser-locales/ko.js +62 -0
- package/dist/browser-locales/zh.d.ts +2 -0
- package/dist/browser-locales/zh.js +62 -0
- package/dist/browser-utils.d.ts +3 -0
- package/dist/browser-utils.js +3 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +46 -0
- package/dist/lib/application-events.d.ts +5 -0
- package/dist/lib/application-events.js +5 -0
- package/dist/lib/application.d.ts +195 -0
- package/dist/lib/application.js +715 -0
- package/dist/lib/cli.d.ts +1 -0
- package/dist/lib/cli.js +111 -0
- package/dist/lib/converter/comments/blockLexer.d.ts +4 -0
- package/dist/lib/converter/comments/blockLexer.js +391 -0
- package/dist/lib/converter/comments/declarationReferenceResolver.d.ts +3 -0
- package/dist/lib/converter/comments/declarationReferenceResolver.js +218 -0
- package/dist/lib/converter/comments/discovery.d.ts +14 -0
- package/dist/lib/converter/comments/discovery.js +563 -0
- package/dist/lib/converter/comments/index.d.ts +37 -0
- package/dist/lib/converter/comments/index.js +241 -0
- package/dist/lib/converter/comments/lexer.d.ts +17 -0
- package/dist/lib/converter/comments/lexer.js +10 -0
- package/dist/lib/converter/comments/lineLexer.d.ts +3 -0
- package/dist/lib/converter/comments/lineLexer.js +279 -0
- package/dist/lib/converter/comments/linkResolver.d.ts +20 -0
- package/dist/lib/converter/comments/linkResolver.js +186 -0
- package/dist/lib/converter/comments/parser.d.ts +18 -0
- package/dist/lib/converter/comments/parser.js +538 -0
- package/dist/lib/converter/comments/rawLexer.d.ts +8 -0
- package/dist/lib/converter/comments/rawLexer.js +218 -0
- package/dist/lib/converter/comments/tagName.d.ts +8 -0
- package/dist/lib/converter/comments/tagName.js +58 -0
- package/dist/lib/converter/comments/textParser.d.ts +33 -0
- package/dist/lib/converter/comments/textParser.js +372 -0
- package/dist/lib/converter/components.d.ts +4 -0
- package/dist/lib/converter/components.js +3 -0
- package/dist/lib/converter/context.d.ts +101 -0
- package/dist/lib/converter/context.js +311 -0
- package/dist/lib/converter/convert-expression.d.ts +9 -0
- package/dist/lib/converter/convert-expression.js +58 -0
- package/dist/lib/converter/converter-events.d.ts +13 -0
- package/dist/lib/converter/converter-events.js +13 -0
- package/dist/lib/converter/converter.d.ts +238 -0
- package/dist/lib/converter/converter.js +705 -0
- package/dist/lib/converter/factories/index-signature.d.ts +3 -0
- package/dist/lib/converter/factories/index-signature.js +50 -0
- package/dist/lib/converter/factories/signature.d.ts +14 -0
- package/dist/lib/converter/factories/signature.js +353 -0
- package/dist/lib/converter/factories/symbol-id.d.ts +3 -0
- package/dist/lib/converter/factories/symbol-id.js +47 -0
- package/dist/lib/converter/index.d.ts +5 -0
- package/dist/lib/converter/index.js +3 -0
- package/dist/lib/converter/jsdoc.d.ts +4 -0
- package/dist/lib/converter/jsdoc.js +135 -0
- package/dist/lib/converter/plugins/CategoryPlugin.d.ts +48 -0
- package/dist/lib/converter/plugins/CategoryPlugin.js +278 -0
- package/dist/lib/converter/plugins/CommentPlugin.d.ts +128 -0
- package/dist/lib/converter/plugins/CommentPlugin.js +770 -0
- package/dist/lib/converter/plugins/GroupPlugin.d.ts +48 -0
- package/dist/lib/converter/plugins/GroupPlugin.js +281 -0
- package/dist/lib/converter/plugins/ImplementsPlugin.d.ts +42 -0
- package/dist/lib/converter/plugins/ImplementsPlugin.js +438 -0
- package/dist/lib/converter/plugins/IncludePlugin.d.ts +14 -0
- package/dist/lib/converter/plugins/IncludePlugin.js +254 -0
- package/dist/lib/converter/plugins/InheritDocPlugin.d.ts +32 -0
- package/dist/lib/converter/plugins/InheritDocPlugin.js +220 -0
- package/dist/lib/converter/plugins/LinkResolverPlugin.d.ts +13 -0
- package/dist/lib/converter/plugins/LinkResolverPlugin.js +88 -0
- package/dist/lib/converter/plugins/MergeModuleWithPlugin.d.ts +12 -0
- package/dist/lib/converter/plugins/MergeModuleWithPlugin.js +50 -0
- package/dist/lib/converter/plugins/PackagePlugin.d.ts +31 -0
- package/dist/lib/converter/plugins/PackagePlugin.js +188 -0
- package/dist/lib/converter/plugins/SourcePlugin.d.ts +36 -0
- package/dist/lib/converter/plugins/SourcePlugin.js +215 -0
- package/dist/lib/converter/plugins/TypePlugin.d.ts +16 -0
- package/dist/lib/converter/plugins/TypePlugin.js +108 -0
- package/dist/lib/converter/plugins/index.d.ts +10 -0
- package/dist/lib/converter/plugins/index.js +10 -0
- package/dist/lib/converter/symbols.d.ts +3 -0
- package/dist/lib/converter/symbols.js +861 -0
- package/dist/lib/converter/types.d.ts +10 -0
- package/dist/lib/converter/types.js +833 -0
- package/dist/lib/converter/utils/nodes.d.ts +7 -0
- package/dist/lib/converter/utils/nodes.js +26 -0
- package/dist/lib/converter/utils/reflections.d.ts +2 -0
- package/dist/lib/converter/utils/reflections.js +17 -0
- package/dist/lib/converter/utils/repository.d.ts +96 -0
- package/dist/lib/converter/utils/repository.js +295 -0
- package/dist/lib/converter/utils/symbols.d.ts +2 -0
- package/dist/lib/converter/utils/symbols.js +12 -0
- package/dist/lib/debug/index.d.ts +2 -0
- package/dist/lib/debug/index.js +2 -0
- package/dist/lib/debug/reflectionLifetimes.d.ts +3 -0
- package/dist/lib/debug/reflectionLifetimes.js +27 -0
- package/dist/lib/debug/rendererUrls.d.ts +6 -0
- package/dist/lib/debug/rendererUrls.js +68 -0
- package/dist/lib/internationalization/index.d.ts +7 -0
- package/dist/lib/internationalization/index.js +7 -0
- package/dist/lib/internationalization/internationalization.d.ts +65 -0
- package/dist/lib/internationalization/internationalization.js +64 -0
- package/dist/lib/internationalization/locale-utils.cjs +8 -0
- package/dist/lib/internationalization/locale-utils.d.cts +8 -0
- package/dist/lib/internationalization/locales/de.cjs +401 -0
- package/dist/lib/internationalization/locales/de.d.cts +368 -0
- package/dist/lib/internationalization/locales/en.cjs +411 -0
- package/dist/lib/internationalization/locales/en.d.cts +380 -0
- package/dist/lib/internationalization/locales/ja.cjs +320 -0
- package/dist/lib/internationalization/locales/ja.d.cts +307 -0
- package/dist/lib/internationalization/locales/ko.cjs +233 -0
- package/dist/lib/internationalization/locales/ko.d.cts +221 -0
- package/dist/lib/internationalization/locales/zh.cjs +488 -0
- package/dist/lib/internationalization/locales/zh.d.cts +452 -0
- package/dist/lib/internationalization/translatable.d.ts +21 -0
- package/dist/lib/internationalization/translatable.js +8 -0
- package/dist/lib/models/Comment.d.ts +241 -0
- package/dist/lib/models/Comment.js +534 -0
- package/dist/lib/models/ContainerReflection.d.ts +56 -0
- package/dist/lib/models/ContainerReflection.js +159 -0
- package/dist/lib/models/DeclarationReflection.d.ts +149 -0
- package/dist/lib/models/DeclarationReflection.js +287 -0
- package/dist/lib/models/DocumentReflection.d.ts +32 -0
- package/dist/lib/models/DocumentReflection.js +66 -0
- package/dist/lib/models/FileRegistry.d.ts +46 -0
- package/dist/lib/models/FileRegistry.js +133 -0
- package/dist/lib/models/ParameterReflection.d.ts +21 -0
- package/dist/lib/models/ParameterReflection.js +39 -0
- package/dist/lib/models/ProjectReflection.d.ts +112 -0
- package/dist/lib/models/ProjectReflection.js +417 -0
- package/dist/lib/models/ReferenceReflection.d.ts +49 -0
- package/dist/lib/models/ReferenceReflection.js +85 -0
- package/dist/lib/models/Reflection.d.ts +229 -0
- package/dist/lib/models/Reflection.js +495 -0
- package/dist/lib/models/ReflectionCategory.d.ts +31 -0
- package/dist/lib/models/ReflectionCategory.js +56 -0
- package/dist/lib/models/ReflectionGroup.d.ts +38 -0
- package/dist/lib/models/ReflectionGroup.js +72 -0
- package/dist/lib/models/ReflectionSymbolId.d.ts +63 -0
- package/dist/lib/models/ReflectionSymbolId.js +85 -0
- package/dist/lib/models/SignatureReflection.d.ts +50 -0
- package/dist/lib/models/SignatureReflection.js +96 -0
- package/dist/lib/models/SourceReference.d.ts +33 -0
- package/dist/lib/models/SourceReference.js +50 -0
- package/dist/lib/models/TypeParameterReflection.d.ts +30 -0
- package/dist/lib/models/TypeParameterReflection.js +45 -0
- package/dist/lib/models/index.d.ts +19 -0
- package/dist/lib/models/index.js +19 -0
- package/dist/lib/models/kind.d.ts +84 -0
- package/dist/lib/models/kind.js +231 -0
- package/dist/lib/models/types.d.ts +553 -0
- package/dist/lib/models/types.js +1296 -0
- package/dist/lib/models/utils.d.ts +1 -0
- package/dist/lib/models/utils.js +26 -0
- package/dist/lib/models/variant.d.ts +21 -0
- package/dist/lib/models/variant.js +1 -0
- package/dist/lib/output/components.d.ts +53 -0
- package/dist/lib/output/components.js +133 -0
- package/dist/lib/output/events.d.ts +175 -0
- package/dist/lib/output/events.js +195 -0
- package/dist/lib/output/formatter.d.ts +88 -0
- package/dist/lib/output/formatter.js +660 -0
- package/dist/lib/output/index.d.ts +9 -0
- package/dist/lib/output/index.js +7 -0
- package/dist/lib/output/output.d.ts +14 -0
- package/dist/lib/output/output.js +92 -0
- package/dist/lib/output/plugins/AssetsPlugin.d.ts +20 -0
- package/dist/lib/output/plugins/AssetsPlugin.js +160 -0
- package/dist/lib/output/plugins/HierarchyPlugin.d.ts +7 -0
- package/dist/lib/output/plugins/HierarchyPlugin.js +65 -0
- package/dist/lib/output/plugins/IconsPlugin.d.ts +12 -0
- package/dist/lib/output/plugins/IconsPlugin.js +54 -0
- package/dist/lib/output/plugins/JavascriptIndexPlugin.d.ts +22 -0
- package/dist/lib/output/plugins/JavascriptIndexPlugin.js +222 -0
- package/dist/lib/output/plugins/NavigationPlugin.d.ts +7 -0
- package/dist/lib/output/plugins/NavigationPlugin.js +23 -0
- package/dist/lib/output/plugins/SitemapPlugin.d.ts +8 -0
- package/dist/lib/output/plugins/SitemapPlugin.js +82 -0
- package/dist/lib/output/plugins/index.d.ts +7 -0
- package/dist/lib/output/plugins/index.js +7 -0
- package/dist/lib/output/renderer.d.ts +227 -0
- package/dist/lib/output/renderer.js +387 -0
- package/dist/lib/output/router.d.ts +187 -0
- package/dist/lib/output/router.js +520 -0
- package/dist/lib/output/theme.d.ts +22 -0
- package/dist/lib/output/theme.js +17 -0
- package/dist/lib/output/themes/MarkedPlugin.d.ts +62 -0
- package/dist/lib/output/themes/MarkedPlugin.js +461 -0
- package/dist/lib/output/themes/default/DefaultTheme.d.ts +72 -0
- package/dist/lib/output/themes/default/DefaultTheme.js +367 -0
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.d.ts +105 -0
- package/dist/lib/output/themes/default/DefaultThemeRenderContext.js +151 -0
- package/dist/lib/output/themes/default/Slugger.d.ts +13 -0
- package/dist/lib/output/themes/default/Slugger.js +60 -0
- package/dist/lib/output/themes/default/layouts/default.d.ts +6 -0
- package/dist/lib/output/themes/default/layouts/default.js +89 -0
- package/dist/lib/output/themes/default/partials/anchor-icon.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/anchor-icon.js +9 -0
- package/dist/lib/output/themes/default/partials/breadcrumb.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/breadcrumb.js +11 -0
- package/dist/lib/output/themes/default/partials/comment.d.ts +8 -0
- package/dist/lib/output/themes/default/partials/comment.js +80 -0
- package/dist/lib/output/themes/default/partials/footer.d.ts +3 -0
- package/dist/lib/output/themes/default/partials/footer.js +37 -0
- package/dist/lib/output/themes/default/partials/header.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/header.js +39 -0
- package/dist/lib/output/themes/default/partials/hierarchy.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/hierarchy.js +32 -0
- package/dist/lib/output/themes/default/partials/icon.d.ts +20 -0
- package/dist/lib/output/themes/default/partials/icon.js +101 -0
- package/dist/lib/output/themes/default/partials/index.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/index.js +24 -0
- package/dist/lib/output/themes/default/partials/member.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.declaration.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.declaration.js +35 -0
- package/dist/lib/output/themes/default/partials/member.getterSetter.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.getterSetter.js +12 -0
- package/dist/lib/output/themes/default/partials/member.js +36 -0
- package/dist/lib/output/themes/default/partials/member.signature.body.d.ts +6 -0
- package/dist/lib/output/themes/default/partials/member.signature.body.js +33 -0
- package/dist/lib/output/themes/default/partials/member.signature.title.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/member.signature.title.js +9 -0
- package/dist/lib/output/themes/default/partials/member.signatures.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.signatures.js +9 -0
- package/dist/lib/output/themes/default/partials/member.sources.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/member.sources.js +55 -0
- package/dist/lib/output/themes/default/partials/members.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/members.js +17 -0
- package/dist/lib/output/themes/default/partials/moduleReflection.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/moduleReflection.js +68 -0
- package/dist/lib/output/themes/default/partials/navigation.d.ts +10 -0
- package/dist/lib/output/themes/default/partials/navigation.js +144 -0
- package/dist/lib/output/themes/default/partials/reflectionPreview.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/reflectionPreview.js +26 -0
- package/dist/lib/output/themes/default/partials/toolbar.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/toolbar.js +13 -0
- package/dist/lib/output/themes/default/partials/type.d.ts +5 -0
- package/dist/lib/output/themes/default/partials/type.js +9 -0
- package/dist/lib/output/themes/default/partials/typeAndParent.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/typeAndParent.js +28 -0
- package/dist/lib/output/themes/default/partials/typeDetails.d.ts +8 -0
- package/dist/lib/output/themes/default/partials/typeDetails.js +284 -0
- package/dist/lib/output/themes/default/partials/typeParameters.d.ts +4 -0
- package/dist/lib/output/themes/default/partials/typeParameters.js +26 -0
- package/dist/lib/output/themes/default/templates/document.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/document.js +3 -0
- package/dist/lib/output/themes/default/templates/hierarchy.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/hierarchy.js +31 -0
- package/dist/lib/output/themes/default/templates/index.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/index.js +3 -0
- package/dist/lib/output/themes/default/templates/reflection.d.ts +5 -0
- package/dist/lib/output/themes/default/templates/reflection.js +53 -0
- package/dist/lib/output/themes/lib.d.ts +44 -0
- package/dist/lib/output/themes/lib.js +218 -0
- package/dist/lib/serialization/components.d.ts +22 -0
- package/dist/lib/serialization/components.js +1 -0
- package/dist/lib/serialization/deserializer.d.ts +70 -0
- package/dist/lib/serialization/deserializer.js +235 -0
- package/dist/lib/serialization/events.d.ts +17 -0
- package/dist/lib/serialization/events.js +18 -0
- package/dist/lib/serialization/index.d.ts +5 -0
- package/dist/lib/serialization/index.js +4 -0
- package/dist/lib/serialization/schema.d.ts +283 -0
- package/dist/lib/serialization/schema.js +32 -0
- package/dist/lib/serialization/serializer.d.ts +52 -0
- package/dist/lib/serialization/serializer.js +65 -0
- package/dist/lib/utils/ValidatingFileRegistry.d.ts +12 -0
- package/dist/lib/utils/ValidatingFileRegistry.js +52 -0
- package/dist/lib/utils/component.d.ts +38 -0
- package/dist/lib/utils/component.js +41 -0
- package/dist/lib/utils/compress.d.ts +7 -0
- package/dist/lib/utils/compress.js +13 -0
- package/dist/lib/utils/declaration-maps.d.ts +3 -0
- package/dist/lib/utils/declaration-maps.js +51 -0
- package/dist/lib/utils/entry-point.d.ts +50 -0
- package/dist/lib/utils/entry-point.js +330 -0
- package/dist/lib/utils/fs.d.ts +65 -0
- package/dist/lib/utils/fs.js +372 -0
- package/dist/lib/utils/general.d.ts +4 -0
- package/dist/lib/utils/general.js +25 -0
- package/dist/lib/utils/highlighter.d.ts +9 -0
- package/dist/lib/utils/highlighter.js +150 -0
- package/dist/lib/utils/html-entities.d.ts +8926 -0
- package/dist/lib/utils/html-entities.js +2329 -0
- package/dist/lib/utils/html.d.ts +67 -0
- package/dist/lib/utils/html.js +635 -0
- package/dist/lib/utils/index.d.ts +17 -0
- package/dist/lib/utils/index.js +15 -0
- package/dist/lib/utils/loggers.d.ts +10 -0
- package/dist/lib/utils/loggers.js +71 -0
- package/dist/lib/utils/options/declaration.d.ts +514 -0
- package/dist/lib/utils/options/declaration.js +443 -0
- package/dist/lib/utils/options/defaults.d.ts +20 -0
- package/dist/lib/utils/options/defaults.js +104 -0
- package/dist/lib/utils/options/help.d.ts +7 -0
- package/dist/lib/utils/options/help.js +63 -0
- package/dist/lib/utils/options/index.d.ts +6 -0
- package/dist/lib/utils/options/index.js +4 -0
- package/dist/lib/utils/options/options.d.ts +199 -0
- package/dist/lib/utils/options/options.js +273 -0
- package/dist/lib/utils/options/readers/arguments.d.ts +15 -0
- package/dist/lib/utils/options/readers/arguments.js +109 -0
- package/dist/lib/utils/options/readers/index.d.ts +4 -0
- package/dist/lib/utils/options/readers/index.js +4 -0
- package/dist/lib/utils/options/readers/package-json.d.ts +9 -0
- package/dist/lib/utils/options/readers/package-json.js +40 -0
- package/dist/lib/utils/options/readers/tsconfig.d.ts +14 -0
- package/dist/lib/utils/options/readers/tsconfig.js +172 -0
- package/dist/lib/utils/options/readers/typedoc.d.ts +33 -0
- package/dist/lib/utils/options/readers/typedoc.js +136 -0
- package/dist/lib/utils/options/sources/index.d.ts +1 -0
- package/dist/lib/utils/options/sources/index.js +1 -0
- package/dist/lib/utils/options/sources/typedoc.d.ts +2 -0
- package/dist/lib/utils/options/sources/typedoc.js +876 -0
- package/dist/lib/utils/options/tsdoc-defaults.d.ts +6 -0
- package/dist/lib/utils/options/tsdoc-defaults.js +94 -0
- package/dist/lib/utils/package-manifest.d.ts +11 -0
- package/dist/lib/utils/package-manifest.js +84 -0
- package/dist/lib/utils/paths.d.ts +27 -0
- package/dist/lib/utils/paths.js +127 -0
- package/dist/lib/utils/perf.d.ts +6 -0
- package/dist/lib/utils/perf.js +86 -0
- package/dist/lib/utils/plugins.d.ts +3 -0
- package/dist/lib/utils/plugins.js +61 -0
- package/dist/lib/utils/reflections.d.ts +5 -0
- package/dist/lib/utils/reflections.js +64 -0
- package/dist/lib/utils/sort.d.ts +11 -0
- package/dist/lib/utils/sort.js +153 -0
- package/dist/lib/utils/tsconfig.d.ts +5 -0
- package/dist/lib/utils/tsconfig.js +60 -0
- package/dist/lib/utils/tsutils.d.ts +3 -0
- package/dist/lib/utils/tsutils.js +23 -0
- package/dist/lib/utils-common/array.d.ts +57 -0
- package/dist/lib/utils-common/array.js +152 -0
- package/dist/lib/utils-common/declarationReference.d.ts +42 -0
- package/dist/lib/utils-common/declarationReference.js +341 -0
- package/dist/lib/utils-common/enum.d.ts +9 -0
- package/dist/lib/utils-common/enum.js +27 -0
- package/dist/lib/utils-common/events.d.ts +29 -0
- package/dist/lib/utils-common/events.js +49 -0
- package/dist/lib/utils-common/general.d.ts +40 -0
- package/dist/lib/utils-common/general.js +22 -0
- package/dist/lib/utils-common/hooks.d.ts +51 -0
- package/dist/lib/utils-common/hooks.js +90 -0
- package/dist/lib/utils-common/i18n.d.ts +18 -0
- package/dist/lib/utils-common/i18n.js +39 -0
- package/dist/lib/utils-common/index.d.ts +16 -0
- package/dist/lib/utils-common/index.js +17 -0
- package/dist/lib/utils-common/jsx.d.ts +53 -0
- package/dist/lib/utils-common/jsx.elements.d.ts +949 -0
- package/dist/lib/utils-common/jsx.elements.js +3 -0
- package/dist/lib/utils-common/jsx.js +187 -0
- package/dist/lib/utils-common/logger.d.ts +97 -0
- package/dist/lib/utils-common/logger.js +129 -0
- package/dist/lib/utils-common/map.d.ts +23 -0
- package/dist/lib/utils-common/map.js +63 -0
- package/dist/lib/utils-common/minimalSourceFile.d.ts +12 -0
- package/dist/lib/utils-common/minimalSourceFile.js +43 -0
- package/dist/lib/utils-common/path.d.ts +42 -0
- package/dist/lib/utils-common/path.js +130 -0
- package/dist/lib/utils-common/set.d.ts +3 -0
- package/dist/lib/utils-common/set.js +23 -0
- package/dist/lib/utils-common/string.d.ts +11 -0
- package/dist/lib/utils-common/string.js +84 -0
- package/dist/lib/utils-common/validation.d.ts +33 -0
- package/dist/lib/utils-common/validation.js +50 -0
- package/dist/lib/validation/documentation.d.ts +3 -0
- package/dist/lib/validation/documentation.js +91 -0
- package/dist/lib/validation/exports.d.ts +3 -0
- package/dist/lib/validation/exports.js +65 -0
- package/dist/lib/validation/links.d.ts +3 -0
- package/dist/lib/validation/links.js +78 -0
- package/dist/lib/validation/unusedMergeModuleWith.d.ts +3 -0
- package/dist/lib/validation/unusedMergeModuleWith.js +12 -0
- package/package.json +161 -0
- package/static/main.js +58 -0
- package/static/style.css +1633 -0
- package/tsdoc.json +247 -0
- package/typedoc-config.schema.json +941 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { promises as fsp } from "fs";
|
|
3
|
+
import { Minimatch } from "minimatch";
|
|
4
|
+
import { dirname, join, relative, resolve } from "path";
|
|
5
|
+
import { escapeRegExp, Validation } from "#utils";
|
|
6
|
+
import { normalizePath } from "./paths.js";
|
|
7
|
+
import { ok } from "assert";
|
|
8
|
+
export function isFile(file) {
|
|
9
|
+
try {
|
|
10
|
+
return fs.statSync(file).isFile();
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function isDir(path) {
|
|
17
|
+
try {
|
|
18
|
+
return fs.statSync(path).isDirectory();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Load the given file and return its contents.
|
|
26
|
+
*
|
|
27
|
+
* @param file The path of the file to read.
|
|
28
|
+
* @returns The files contents.
|
|
29
|
+
*/
|
|
30
|
+
export function readFile(file) {
|
|
31
|
+
const buffer = fs.readFileSync(file);
|
|
32
|
+
switch (buffer[0]) {
|
|
33
|
+
case 0xfe:
|
|
34
|
+
if (buffer[1] === 0xff) {
|
|
35
|
+
let i = 0;
|
|
36
|
+
while (i + 1 < buffer.length) {
|
|
37
|
+
const temp = buffer[i];
|
|
38
|
+
buffer[i] = buffer[i + 1];
|
|
39
|
+
buffer[i + 1] = temp;
|
|
40
|
+
i += 2;
|
|
41
|
+
}
|
|
42
|
+
return buffer.toString("ucs2", 2);
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case 0xff:
|
|
46
|
+
if (buffer[1] === 0xfe) {
|
|
47
|
+
return buffer.toString("ucs2", 2);
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
case 0xef:
|
|
51
|
+
if (buffer[1] === 0xbb) {
|
|
52
|
+
return buffer.toString("utf8", 3);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return buffer.toString("utf8", 0);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Write a file to disc.
|
|
59
|
+
*
|
|
60
|
+
* If the containing directory does not exist it will be created.
|
|
61
|
+
*
|
|
62
|
+
* @param fileName The name of the file that should be written.
|
|
63
|
+
* @param data The contents of the file.
|
|
64
|
+
*/
|
|
65
|
+
export function writeFileSync(fileName, data) {
|
|
66
|
+
fs.mkdirSync(dirname(normalizePath(fileName)), { recursive: true });
|
|
67
|
+
fs.writeFileSync(normalizePath(fileName), data);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Write a file to disc.
|
|
71
|
+
*
|
|
72
|
+
* If the containing directory does not exist it will be created.
|
|
73
|
+
*
|
|
74
|
+
* @param fileName The name of the file that should be written.
|
|
75
|
+
* @param data The contents of the file.
|
|
76
|
+
*/
|
|
77
|
+
export async function writeFile(fileName, data) {
|
|
78
|
+
await fsp.mkdir(dirname(normalizePath(fileName)), {
|
|
79
|
+
recursive: true,
|
|
80
|
+
});
|
|
81
|
+
await fsp.writeFile(normalizePath(fileName), data);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Copy a file or directory recursively.
|
|
85
|
+
*/
|
|
86
|
+
export async function copy(src, dest) {
|
|
87
|
+
const stat = await fsp.stat(src);
|
|
88
|
+
if (stat.isDirectory()) {
|
|
89
|
+
const contained = await fsp.readdir(src);
|
|
90
|
+
await Promise.all(contained.map((file) => copy(join(src, file), join(dest, file))));
|
|
91
|
+
}
|
|
92
|
+
else if (stat.isFile()) {
|
|
93
|
+
await fsp.mkdir(dirname(dest), { recursive: true });
|
|
94
|
+
await fsp.copyFile(src, dest);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Do nothing for FIFO, special devices.
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function copySync(src, dest) {
|
|
101
|
+
const stat = fs.statSync(src);
|
|
102
|
+
if (stat.isDirectory()) {
|
|
103
|
+
const contained = fs.readdirSync(src);
|
|
104
|
+
contained.forEach((file) => copySync(join(src, file), join(dest, file)));
|
|
105
|
+
}
|
|
106
|
+
else if (stat.isFile()) {
|
|
107
|
+
fs.mkdirSync(dirname(dest), { recursive: true });
|
|
108
|
+
fs.copyFileSync(src, dest);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
// Do nothing for FIFO, special devices.
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// cache of fs.realpathSync results to avoid extra I/O
|
|
115
|
+
const realpathCache = new Map();
|
|
116
|
+
export function discoverFiles(rootDir, controller) {
|
|
117
|
+
const result = [];
|
|
118
|
+
const dirs = [normalizePath(rootDir).split("/")];
|
|
119
|
+
// cache of real paths to avoid infinite recursion
|
|
120
|
+
const symlinkTargetsSeen = new Set();
|
|
121
|
+
const { matchDirectories = false, followSymlinks = false } = controller;
|
|
122
|
+
let dir = dirs.shift();
|
|
123
|
+
const handleFile = (path) => {
|
|
124
|
+
const childPath = [...dir, path].join("/");
|
|
125
|
+
if (controller.matches(childPath)) {
|
|
126
|
+
result.push(childPath);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const handleDirectory = (path) => {
|
|
130
|
+
const childPath = [...dir, path];
|
|
131
|
+
if (controller.shouldRecurse(childPath)) {
|
|
132
|
+
dirs.push(childPath);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const handleSymlink = (path) => {
|
|
136
|
+
const childPath = [...dir, path].join("/");
|
|
137
|
+
let realpath;
|
|
138
|
+
try {
|
|
139
|
+
realpath = realpathCache.get(childPath) ?? fs.realpathSync(childPath);
|
|
140
|
+
realpathCache.set(childPath, realpath);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (symlinkTargetsSeen.has(realpath)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
symlinkTargetsSeen.add(realpath);
|
|
149
|
+
try {
|
|
150
|
+
const stats = fs.statSync(realpath);
|
|
151
|
+
if (stats.isDirectory()) {
|
|
152
|
+
handleDirectory(path);
|
|
153
|
+
}
|
|
154
|
+
else if (stats.isFile()) {
|
|
155
|
+
handleFile(path);
|
|
156
|
+
}
|
|
157
|
+
else if (stats.isSymbolicLink()) {
|
|
158
|
+
const dirpath = dir.join("/");
|
|
159
|
+
if (dirpath === realpath) {
|
|
160
|
+
// special case: real path of symlink is the directory we're currently traversing
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const targetPath = relative(dirpath, realpath);
|
|
164
|
+
handleSymlink(targetPath);
|
|
165
|
+
} // everything else should be ignored
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
// invalid symbolic link; ignore
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
while (dir) {
|
|
172
|
+
if (matchDirectories && controller.matches(dir.join("/"))) {
|
|
173
|
+
result.push(dir.join("/"));
|
|
174
|
+
}
|
|
175
|
+
for (const child of fs.readdirSync(dir.join("/"), {
|
|
176
|
+
withFileTypes: true,
|
|
177
|
+
})) {
|
|
178
|
+
if (child.isFile()) {
|
|
179
|
+
handleFile(child.name);
|
|
180
|
+
}
|
|
181
|
+
else if (child.isDirectory()) {
|
|
182
|
+
handleDirectory(child.name);
|
|
183
|
+
}
|
|
184
|
+
else if (followSymlinks && child.isSymbolicLink()) {
|
|
185
|
+
handleSymlink(child.name);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
dir = dirs.shift();
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Simpler version of `glob.sync` that only covers our use cases, always ignoring node_modules.
|
|
194
|
+
*/
|
|
195
|
+
export function glob(pattern, root, options = {}) {
|
|
196
|
+
const mini = new Minimatch(pattern);
|
|
197
|
+
const shouldIncludeNodeModules = pattern.includes("node_modules");
|
|
198
|
+
const controller = {
|
|
199
|
+
matches(path) {
|
|
200
|
+
return mini.match(path);
|
|
201
|
+
},
|
|
202
|
+
shouldRecurse(childPath) {
|
|
203
|
+
// if we _specifically asked_ for something in node_modules, fine, otherwise ignore it
|
|
204
|
+
// to avoid globs like '**/*.ts' finding all the .d.ts files in node_modules.
|
|
205
|
+
// however, if the pattern is something like `!**/node_modules/**`, this will also
|
|
206
|
+
// cause node_modules to be considered, though it will be discarded by minimatch.
|
|
207
|
+
if (childPath[childPath.length - 1] === "node_modules" &&
|
|
208
|
+
!shouldIncludeNodeModules) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
return mini.set.some((row) => mini.matchOne(childPath, row, /* partial */ true));
|
|
212
|
+
},
|
|
213
|
+
matchDirectories: options.includeDirectories,
|
|
214
|
+
followSymlinks: options.followSymlinks,
|
|
215
|
+
};
|
|
216
|
+
return discoverFiles(root, controller);
|
|
217
|
+
}
|
|
218
|
+
export function hasTsExtension(path) {
|
|
219
|
+
return /\.[cm]?ts$|\.tsx$/.test(path);
|
|
220
|
+
}
|
|
221
|
+
export function hasDeclarationFileExtension(path) {
|
|
222
|
+
return /\.d\.[cm]?ts$/.test(path);
|
|
223
|
+
}
|
|
224
|
+
export function discoverInParentDirExactMatch(name, dir, read, usedFile) {
|
|
225
|
+
if (!isDir(dir))
|
|
226
|
+
return;
|
|
227
|
+
const reachedTopDirectory = (dirName) => dirName === resolve(join(dirName, ".."));
|
|
228
|
+
while (!reachedTopDirectory(dir)) {
|
|
229
|
+
usedFile?.(join(dir, name));
|
|
230
|
+
try {
|
|
231
|
+
const content = read(readFile(join(dir, name)));
|
|
232
|
+
if (content != null) {
|
|
233
|
+
return { file: join(dir, name), content };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Ignore, file didn't pass validation
|
|
238
|
+
}
|
|
239
|
+
dir = resolve(join(dir, ".."));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
export function discoverPackageJson(dir, usedFile) {
|
|
243
|
+
return discoverInParentDirExactMatch("package.json", dir, (content) => {
|
|
244
|
+
const pkg = JSON.parse(content);
|
|
245
|
+
if (Validation.validate({ name: String, version: Validation.optional(String) }, pkg)) {
|
|
246
|
+
return pkg;
|
|
247
|
+
}
|
|
248
|
+
}, usedFile);
|
|
249
|
+
}
|
|
250
|
+
// dir -> package info
|
|
251
|
+
const packageCache = new Map();
|
|
252
|
+
export function findPackageForPath(sourcePath) {
|
|
253
|
+
// Attempt to decide package name from path if it contains "node_modules"
|
|
254
|
+
let startIndex = sourcePath.lastIndexOf("node_modules/");
|
|
255
|
+
if (startIndex !== -1) {
|
|
256
|
+
startIndex += "node_modules/".length;
|
|
257
|
+
let stopIndex = sourcePath.indexOf("/", startIndex);
|
|
258
|
+
// Scoped package, e.g. `@types/node`
|
|
259
|
+
if (sourcePath[startIndex] === "@") {
|
|
260
|
+
stopIndex = sourcePath.indexOf("/", stopIndex + 1);
|
|
261
|
+
}
|
|
262
|
+
const packageName = sourcePath.substring(startIndex, stopIndex);
|
|
263
|
+
return [packageName, sourcePath.substring(0, stopIndex)];
|
|
264
|
+
}
|
|
265
|
+
const dir = dirname(sourcePath);
|
|
266
|
+
const cache = packageCache.get(dir);
|
|
267
|
+
if (cache) {
|
|
268
|
+
return cache;
|
|
269
|
+
}
|
|
270
|
+
const packageJson = discoverPackageJson(dir);
|
|
271
|
+
if (packageJson) {
|
|
272
|
+
packageCache.set(dir, [packageJson.content.name, dirname(packageJson.file)]);
|
|
273
|
+
return [packageJson.content.name, dirname(packageJson.file)];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
export function inferPackageEntryPointPaths(packagePath) {
|
|
277
|
+
const packageDir = normalizePath(dirname(packagePath));
|
|
278
|
+
const packageJson = JSON.parse(readFile(packagePath));
|
|
279
|
+
const exports = packageJson.exports;
|
|
280
|
+
if (typeof exports === "string") {
|
|
281
|
+
return resolveExport(packageDir, ".", exports, false);
|
|
282
|
+
}
|
|
283
|
+
if (!exports || typeof exports !== "object") {
|
|
284
|
+
if (typeof packageJson.main === "string") {
|
|
285
|
+
return [[".", resolve(packageDir, packageJson.main)]];
|
|
286
|
+
}
|
|
287
|
+
return [];
|
|
288
|
+
}
|
|
289
|
+
const results = [];
|
|
290
|
+
if (Array.isArray(exports)) {
|
|
291
|
+
results.push(...resolveExport(packageDir, ".", exports, true));
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
for (const [importPath, exp] of Object.entries(exports)) {
|
|
295
|
+
results.push(...resolveExport(packageDir, importPath, exp, false));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return results;
|
|
299
|
+
}
|
|
300
|
+
function resolveExport(packageDir, name, exportDeclaration, validatePath) {
|
|
301
|
+
if (typeof exportDeclaration === "string") {
|
|
302
|
+
return resolveStarredExport(packageDir, name, exportDeclaration, validatePath);
|
|
303
|
+
}
|
|
304
|
+
if (Array.isArray(exportDeclaration)) {
|
|
305
|
+
for (const item of exportDeclaration) {
|
|
306
|
+
const result = resolveExport(packageDir, name, item, true);
|
|
307
|
+
if (result.length) {
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
const EXPORT_CONDITIONS = ["typedoc", "types", "import", "node", "default"];
|
|
314
|
+
for (const cond in exportDeclaration) {
|
|
315
|
+
if (EXPORT_CONDITIONS.includes(cond)) {
|
|
316
|
+
return resolveExport(packageDir, name, exportDeclaration[cond], false);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
// No recognized export condition
|
|
320
|
+
return [];
|
|
321
|
+
}
|
|
322
|
+
function isWildcardName(name) {
|
|
323
|
+
let starCount = 0;
|
|
324
|
+
for (let i = 0; i < name.length; ++i) {
|
|
325
|
+
if (name[i] === "*") {
|
|
326
|
+
++starCount;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return starCount === 1;
|
|
330
|
+
}
|
|
331
|
+
function resolveStarredExport(packageDir, name, exportDeclaration, validatePath) {
|
|
332
|
+
// Wildcards only do something if there is exactly one star in the name
|
|
333
|
+
// If there isn't any star in the destination, all entries map to one file
|
|
334
|
+
// so don't bother enumerating possible files.
|
|
335
|
+
if (isWildcardName(name) && exportDeclaration.includes("*")) {
|
|
336
|
+
// Construct a pattern which we can use to determine if a wildcard matches
|
|
337
|
+
// This will look something like: /^/app\/package\/(.*).js$/
|
|
338
|
+
// The destination may have multiple wildcards, in which case they should
|
|
339
|
+
// contain the same text, so we replace "*" with backreferences for all
|
|
340
|
+
// but the first occurrence.
|
|
341
|
+
let first = true;
|
|
342
|
+
const matcher = new RegExp("^" +
|
|
343
|
+
escapeRegExp(normalizePath(packageDir) +
|
|
344
|
+
"/" +
|
|
345
|
+
exportDeclaration.replace(/^\.\//, "")).replaceAll("\\*", () => {
|
|
346
|
+
if (first) {
|
|
347
|
+
first = false;
|
|
348
|
+
return "(.*)";
|
|
349
|
+
}
|
|
350
|
+
return "\\1";
|
|
351
|
+
}) +
|
|
352
|
+
"$");
|
|
353
|
+
const matchedFiles = discoverFiles(packageDir, {
|
|
354
|
+
matches(path) {
|
|
355
|
+
return matcher.test(path);
|
|
356
|
+
},
|
|
357
|
+
shouldRecurse(path) {
|
|
358
|
+
return path[path.length - 1] !== "node_modules";
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
return matchedFiles.flatMap((path) => {
|
|
362
|
+
const starContent = path.match(matcher);
|
|
363
|
+
ok(starContent, "impossible, discoverFiles uses matcher");
|
|
364
|
+
return [[name.replace("*", starContent[1]), path]];
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
const exportPath = resolve(packageDir, exportDeclaration);
|
|
368
|
+
if (validatePath && !fs.existsSync(exportPath)) {
|
|
369
|
+
return [];
|
|
370
|
+
}
|
|
371
|
+
return [[name, exportPath]];
|
|
372
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { dirname } from "path";
|
|
2
|
+
import url from "url";
|
|
3
|
+
import { url as debuggerUrl } from "inspector";
|
|
4
|
+
// transform /abs/path/to/typedoc/dist/lib/utils/general -> /abs/path/to/typedoc
|
|
5
|
+
export const TYPEDOC_ROOT = dirname(dirname(dirname(dirname(url.fileURLToPath(import.meta.url)))));
|
|
6
|
+
/**
|
|
7
|
+
* This is a hack to make it possible to detect and warn about installation setups
|
|
8
|
+
* which result in TypeDoc being installed multiple times. If TypeDoc has been loaded
|
|
9
|
+
* multiple times, then parts of it will not work as expected.
|
|
10
|
+
*/
|
|
11
|
+
const loadSymbol = Symbol.for("typedoc_loads");
|
|
12
|
+
const pathSymbol = Symbol.for("typedoc_paths");
|
|
13
|
+
const g = globalThis;
|
|
14
|
+
g[loadSymbol] = (g[loadSymbol] || 0) + 1;
|
|
15
|
+
g[pathSymbol] ||= [];
|
|
16
|
+
g[pathSymbol].push(TYPEDOC_ROOT);
|
|
17
|
+
export function hasBeenLoadedMultipleTimes() {
|
|
18
|
+
return g[loadSymbol] !== 1;
|
|
19
|
+
}
|
|
20
|
+
export function getLoadedPaths() {
|
|
21
|
+
return g[pathSymbol] || [];
|
|
22
|
+
}
|
|
23
|
+
export function isDebugging() {
|
|
24
|
+
return !!debuggerUrl();
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as shiki from "@gerrit0/mini-shiki";
|
|
2
|
+
export declare function loadTestHighlighter(): void;
|
|
3
|
+
export declare function loadHighlighter(lightTheme: shiki.BundledTheme, darkTheme: shiki.BundledTheme, langs: shiki.BundledLanguage[], ignoredLangs: string[] | undefined): Promise<void>;
|
|
4
|
+
export declare function isSupportedLanguage(lang: string): boolean;
|
|
5
|
+
export declare function getSupportedLanguages(): string[];
|
|
6
|
+
export declare function getSupportedThemes(): string[];
|
|
7
|
+
export declare function isLoadedLanguage(lang: string): boolean;
|
|
8
|
+
export declare function highlight(code: string, lang: string): string;
|
|
9
|
+
export declare function getStyles(): string;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as shiki from "@gerrit0/mini-shiki";
|
|
2
|
+
import { JSX, unique } from "#utils";
|
|
3
|
+
import assert from "assert";
|
|
4
|
+
const tsAliases = [["mts", "typescript"], ["cts", "typescript"]];
|
|
5
|
+
const aliases = new Map(tsAliases);
|
|
6
|
+
for (const lang of shiki.bundledLanguagesInfo) {
|
|
7
|
+
for (const alias of lang.aliases || []) {
|
|
8
|
+
aliases.set(alias, lang.id);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const plaintextLanguages = ["txt", "text"];
|
|
12
|
+
const supportedLanguages = unique([
|
|
13
|
+
...plaintextLanguages,
|
|
14
|
+
...aliases.keys(),
|
|
15
|
+
...shiki.bundledLanguagesInfo.map((lang) => lang.id),
|
|
16
|
+
]).sort();
|
|
17
|
+
const supportedThemes = Object.keys(shiki.bundledThemes);
|
|
18
|
+
class ShikiHighlighter {
|
|
19
|
+
highlighter;
|
|
20
|
+
light;
|
|
21
|
+
dark;
|
|
22
|
+
schemes = new Map();
|
|
23
|
+
constructor(highlighter, light, dark) {
|
|
24
|
+
this.highlighter = highlighter;
|
|
25
|
+
this.light = light;
|
|
26
|
+
this.dark = dark;
|
|
27
|
+
}
|
|
28
|
+
supports(lang) {
|
|
29
|
+
return this.highlighter.getLoadedLanguages().includes(lang);
|
|
30
|
+
}
|
|
31
|
+
highlight(code, lang) {
|
|
32
|
+
const tokens = shiki.codeToTokensWithThemes(this.highlighter, code, {
|
|
33
|
+
themes: { light: this.light, dark: this.dark },
|
|
34
|
+
lang: lang,
|
|
35
|
+
});
|
|
36
|
+
const docEls = [];
|
|
37
|
+
for (const line of tokens) {
|
|
38
|
+
for (const token of line) {
|
|
39
|
+
docEls.push(JSX.createElement("span", { class: this.getClass(token.variants) }, token.content));
|
|
40
|
+
}
|
|
41
|
+
docEls.push(JSX.createElement("br", null));
|
|
42
|
+
}
|
|
43
|
+
docEls.pop(); // Remove last <br>
|
|
44
|
+
docEls.pop(); // Remove last <br>
|
|
45
|
+
return JSX.renderElement(JSX.createElement(JSX.Fragment, null, docEls));
|
|
46
|
+
}
|
|
47
|
+
getStyles() {
|
|
48
|
+
const style = [":root {"];
|
|
49
|
+
const lightRules = [];
|
|
50
|
+
const darkRules = [];
|
|
51
|
+
let i = 0;
|
|
52
|
+
for (const key of this.schemes.keys()) {
|
|
53
|
+
const [light, dark] = key.split(" | ");
|
|
54
|
+
style.push(` --light-hl-${i}: ${light};`);
|
|
55
|
+
style.push(` --dark-hl-${i}: ${dark};`);
|
|
56
|
+
lightRules.push(` --hl-${i}: var(--light-hl-${i});`);
|
|
57
|
+
darkRules.push(` --hl-${i}: var(--dark-hl-${i});`);
|
|
58
|
+
i++;
|
|
59
|
+
}
|
|
60
|
+
style.push(` --light-code-background: ${this.highlighter.getTheme(this.light).bg};`);
|
|
61
|
+
style.push(` --dark-code-background: ${this.highlighter.getTheme(this.dark).bg};`);
|
|
62
|
+
lightRules.push(` --code-background: var(--light-code-background);`);
|
|
63
|
+
darkRules.push(` --code-background: var(--dark-code-background);`);
|
|
64
|
+
style.push("}", "");
|
|
65
|
+
style.push("@media (prefers-color-scheme: light) { :root {");
|
|
66
|
+
style.push(...lightRules);
|
|
67
|
+
style.push("} }", "");
|
|
68
|
+
style.push("@media (prefers-color-scheme: dark) { :root {");
|
|
69
|
+
style.push(...darkRules);
|
|
70
|
+
style.push("} }", "");
|
|
71
|
+
style.push(":root[data-theme='light'] {");
|
|
72
|
+
style.push(...lightRules);
|
|
73
|
+
style.push("}", "");
|
|
74
|
+
style.push(":root[data-theme='dark'] {");
|
|
75
|
+
style.push(...darkRules);
|
|
76
|
+
style.push("}", "");
|
|
77
|
+
for (i = 0; i < this.schemes.size; i++) {
|
|
78
|
+
style.push(`.hl-${i} { color: var(--hl-${i}); }`);
|
|
79
|
+
}
|
|
80
|
+
style.push("pre, code { background: var(--code-background); }", "");
|
|
81
|
+
return style.join("\n");
|
|
82
|
+
}
|
|
83
|
+
getClass(variants) {
|
|
84
|
+
const key = `${variants["light"].color} | ${variants["dark"].color}`;
|
|
85
|
+
let scheme = this.schemes.get(key);
|
|
86
|
+
if (scheme == null) {
|
|
87
|
+
scheme = `hl-${this.schemes.size}`;
|
|
88
|
+
this.schemes.set(key, scheme);
|
|
89
|
+
}
|
|
90
|
+
return scheme;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class TestHighlighter {
|
|
94
|
+
supports() {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
highlight(code) {
|
|
98
|
+
return code;
|
|
99
|
+
}
|
|
100
|
+
getStyles() {
|
|
101
|
+
return "";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
let shikiEngine;
|
|
105
|
+
let highlighter;
|
|
106
|
+
let ignoredLanguages;
|
|
107
|
+
export function loadTestHighlighter() {
|
|
108
|
+
highlighter = new TestHighlighter();
|
|
109
|
+
}
|
|
110
|
+
export async function loadHighlighter(lightTheme, darkTheme, langs, ignoredLangs) {
|
|
111
|
+
if (highlighter)
|
|
112
|
+
return;
|
|
113
|
+
ignoredLanguages = ignoredLangs;
|
|
114
|
+
if (!shikiEngine) {
|
|
115
|
+
await shiki.loadBuiltinWasm();
|
|
116
|
+
shikiEngine = await shiki.createOnigurumaEngine();
|
|
117
|
+
}
|
|
118
|
+
const hl = await shiki.createShikiInternal({
|
|
119
|
+
engine: shikiEngine,
|
|
120
|
+
themes: [shiki.bundledThemes[lightTheme], shiki.bundledThemes[darkTheme]],
|
|
121
|
+
langs: langs.map((lang) => shiki.bundledLanguages[lang]),
|
|
122
|
+
});
|
|
123
|
+
highlighter = new ShikiHighlighter(hl, lightTheme, darkTheme);
|
|
124
|
+
}
|
|
125
|
+
function isPlainLanguage(lang) {
|
|
126
|
+
return ignoredLanguages?.includes(lang) || plaintextLanguages.includes(lang);
|
|
127
|
+
}
|
|
128
|
+
export function isSupportedLanguage(lang) {
|
|
129
|
+
return isPlainLanguage(lang) || supportedLanguages.includes(lang);
|
|
130
|
+
}
|
|
131
|
+
export function getSupportedLanguages() {
|
|
132
|
+
return supportedLanguages;
|
|
133
|
+
}
|
|
134
|
+
export function getSupportedThemes() {
|
|
135
|
+
return supportedThemes;
|
|
136
|
+
}
|
|
137
|
+
export function isLoadedLanguage(lang) {
|
|
138
|
+
return isPlainLanguage(lang) || highlighter?.supports(lang) || false;
|
|
139
|
+
}
|
|
140
|
+
export function highlight(code, lang) {
|
|
141
|
+
assert(highlighter, "Tried to highlight with an uninitialized highlighter");
|
|
142
|
+
if (plaintextLanguages.includes(lang) || ignoredLanguages?.includes(lang)) {
|
|
143
|
+
return JSX.renderElement(JSX.createElement(JSX.Fragment, null, code));
|
|
144
|
+
}
|
|
145
|
+
return highlighter.highlight(code, aliases.get(lang) ?? lang);
|
|
146
|
+
}
|
|
147
|
+
export function getStyles() {
|
|
148
|
+
assert(highlighter, "Tried to highlight with an uninitialized highlighter");
|
|
149
|
+
return highlighter.getStyles();
|
|
150
|
+
}
|