/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment' ; import siteConfig from '@generated/docusaurus.config' ; const prismIncludeLanguages = ( PrismObject ) => { if ( ExecutionEnvironment . canUseDOM ) { const { themeConfig : { prism : { additionalLanguages = [ ] } = { } } , } = siteConfig ; window . Prism = PrismObject ; additionalLanguages . forEach ( ( lang ) => { require ( `prismjs/components/prism-${ lang }` ) ; } ) ; require ( `prismjs/components/prism-bash` ) ; require ( "prismjs/plugins/command-line/prism-command-line" ) ; require ( "prismjs/plugins/command-line/prism-command-line.css" ) ; delete PrismObject . languages . jsx ; delete PrismObject . languages . typescript ; delete PrismObject . languages . tsx ; require ( `prismjs/components/prism-js-extras` ) ; require ( 'prismjs/components/prism-typescript' ) ; ( function ( Prism ) { Prism . languages . insertBefore ( 'typescript' , 'constant' , { 'known-class-name' : [ { pattern : /\b(?:(?:(?:Uint|Int)(?:8|16|32)|Uint8Clamped|Float(?:32|64))?Array|ArrayBuffer|BigInt|Boolean|DataView|Date|Error|Function|Intl|JSON|Math|Number|Object|Promise|Proxy|Reflect|RegExp|String|Symbol|(?:Weak)?(?:Set|Map)|WebAssembly)\b/ , alias : 'class-name' } , { pattern : /\b(?:[A-Z]\w*)Error\b/ , alias : 'class-name' } ] } ) ; param { string } source param { string } flags returns { RegExp } function withId ( source , flags ) { return RegExp ( source . replace ( /<ID>/g , function ( ) { return /(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/ . source ; } ) , flags ) ; } Prism . languages . insertBefore ( 'typescript' , 'keyword' , { 'imports' : { pattern : withId ( /(\bimport\b\s*)(?:<ID>(?:\s*,\s*(?:\*\s*as\s+<ID>|\{[^{}]*\}))?|\*\s*as\s+<ID>|\{[^{}]*\})(?=\s*\bfrom\b)/ . source ) , lookbehind : true , inside : Prism . languages . typescript } , 'exports' : { pattern : withId ( /(\bexport\b\s*)(?:\*(?:\s*as\s+<ID>)?(?=\s*\bfrom\b)|\{[^{}]*\})/ . source ) , lookbehind : true , inside : Prism . languages . typescript } } ) ; Prism . languages . typescript [ 'keyword' ] = [ { pattern : /\b(?:as|default|export|from|import)\b/ , alias : 'module' } , { pattern : /\b(?:await|break|catch|continue|do|else|for|finally|if|return|switch|throw|try|while|yield)\b/ , alias : 'control-flow' } , { pattern : /\bnull\b/ , alias : [ 'null' , 'nil' ] } , { pattern : /\bundefined\b/ , alias : 'nil' } , { pattern : /\b(?:abstract|as|asserts|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|undefined|var|void|while|with|yield)\b/ , alias : 'keyword' , } , ] ; Prism . languages . insertBefore ( 'typescript' , 'operator' , { 'spread' : { pattern : /\.{3}/ , alias : 'operator' } , 'arrow' : { pattern : /=>/ , alias : 'operator' } } ) ; Prism . languages . insertBefore ( 'typescript' , 'punctuation' , { 'property-access' : { pattern : withId ( /(\.\s*)#?<ID>/ . source ) , lookbehind : true } , 'dom' : { pattern : /\b(?:document|location|navigator|performance|(?:local|session)Storage|window)\b/ , alias : 'variable' } , 'console' : { pattern : /\bconsole(?=\s*\.)/ , alias : 'class-name' } } ) ; } ( PrismObject ) ) ; require ( `prismjs/components/prism-jsx` ) ; require ( `prismjs/components/prism-tsx` ) ; delete window . Prism ; } } ; export default prismIncludeLanguages ;