Debian Codegraph @

inst/lib/prism-code-editor/prism/languages/javascript.js

raw
1 import { r as rest, l as languages } from "../../index-C1_GGQ8y.js";
2 import { b as boolean, c as clikeString, a as clikeComment } from "../../patterns-Cp3h1ylA.js";
3 var js = {};
4 languages.js = languages.javascript = Object.assign(js, {
5 "doc-comment": {
6 pattern: /\/\*\*(?!\/)[^]*?(?:\*\/|$)/g,
7 greedy: true,
8 alias: "comment",
9 inside: "jsdoc"
10 },
11 "comment": clikeComment(),
12 "hashbang": {
13 pattern: /^#!.*/g,
14 greedy: true,
15 alias: "comment"
16 },
17 "template-string": {
18 pattern: /`(?:\\[^]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})*\}|(?!\$\{)[^\\`])*`/g,
19 greedy: true,
20 inside: {
21 "template-punctuation": {
22 pattern: /^`|`$/,
23 alias: "string"
24 },
25 "interpolation": {
26 pattern: /((?:^|[^\\])(?:\\\\)*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})*\}/,
27 lookbehind: true,
28 inside: {
29 "interpolation-punctuation": {
30 pattern: /^\$\{|\}$/,
31 alias: "punctuation"
32 },
33 [rest]: js
34 }
35 },
36 "string": /[^]+/
37 }
38 },
39 "string-property": {
40 pattern: /((?:^|[,{])[ ]*)(["'])(?:\\[^]|(?!\2)[^\\\n])*\2(?=\s*:)/mg,
41 lookbehind: true,
42 greedy: true,
43 alias: "property"
44 },
45 "string": clikeString(),
46 "regex": {
47 pattern: /((?:^|[^$\w\xa0-\uffff"'`.)\]\s]|\b(?:return|yield))\s*)\/(?:(?:\[(?:\\.|[^\\\n\]])*\]|\\.|[^\\\n/[])+\/[dgimyus]{0,7}|(?:\[(?:\\.|[^\\\n[\]]|\[(?:\\.|[^\\\n[\]]|\[(?:\\.|[^\\\n[\]])*\])*\])*\]|\\.|[^\\\n/[])+\/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?!\/\*|[^()[\]{}.,:;?`\n%&|^!=<>/*+-]))/g,
48 lookbehind: true,
49 greedy: true,
50 inside: {
51 "regex-flags": /\w+$/,
52 "regex-delimiter": /^\/|\/$/,
53 "regex-source": {
54 pattern: /.+/,
55 alias: "language-regex",
56 inside: "regex"
57 }
58 }
59 },
60 "class-name": [
61 {
62 pattern: /(\b(?:class|extends|implements|instanceof|interface|new)\s+)(?!\d)(?:(?!\s)[$\w\xa0-\uffff.])+/,
63 lookbehind: true,
64 inside: {
65 "punctuation": /\./
66 }
67 },
68 {
69 pattern: /(^|[^$\w\xa0-\uffff]|\s)(?![a-z\d])(?:(?!\s)[$\w\xa0-\uffff])+(?=\.(?:constructor|prototype)\b)/,
70 lookbehind: true
71 }
72 ],
73 // This must be declared before keyword because we use "function" inside the look-forward
74 "function-variable": {
75 pattern: /#?(?!\d)(?:(?!\s)[$\w\xa0-\uffff])+(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^)]*\))*\)|(?!\d)(?:(?!\s)[$\w\xa0-\uffff])+)\s*=>))/,
76 alias: "function",
77 inside: {
78 "maybe-class-name": /^[A-Z].*/
79 }
80 },
81 "parameter": [
82 /(function(?:\s+(?!\d)(?:(?!\s)[$\w\xa0-\uffff])+)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
83 /(^|[^$\w\xa0-\uffff]|\s)(?!\d)(?:(?!\s)[$\w\xa0-\uffff])+(?=\s*=>)/,
84 /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
85 /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while|yield|class|const|debugger|delete|enum|extends|function|[gs]et|export|from|import|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with)(?![$\w\xa0-\uffff]))(?:(?!\d)(?:(?!\s)[$\w\xa0-\uffff])+\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/
86 ].map((pattern) => ({
87 pattern,
88 lookbehind: true,
89 inside: js
90 })),
91 "constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/,
92 "keyword": [
93 {
94 pattern: /(^|[^.]|\.{3}\s*)\b(?:as|assert(?=\s*\{)|export|from(?!\s*[^\s"'])|import)\b/,
95 alias: "module",
96 lookbehind: true
97 },
98 {
99 pattern: /(^|[^.]|\.{3}\s*)\b(?:await|break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while|yield)\b/,
100 alias: "control-flow",
101 lookbehind: true
102 },
103 {
104 pattern: /(^|[^.]|\.{3}\s*)\b(?:async(?!\s*[^\s($\w\xa0-\uffff])|class|const|debugger|delete|enum|extends|function|[gs]et(?!\s*[^\s#[$\w\xa0-\uffff])|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with)\b/,
105 lookbehind: true
106 }
107 ],
108 "boolean": boolean,
109 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
110 "function": {
111 pattern: /#?(?!\d)(?:(?!\s)[$\w\xa0-\uffff])+(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
112 inside: {
113 "maybe-class-name": /^[A-Z].*/
114 }
115 },
116 "number": {
117 pattern: /(^|[^$\w])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][a-fA-F\d]+(?:_[a-fA-F\d]+)*n?|\d+(?:_\d+)*n|(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?)(?![$\w])/,
118 lookbehind: true
119 },
120 "literal-property": {
121 pattern: /([\n,{][ ]*)(?!\d)(?:(?!\s)[$\w\xa0-\uffff])+(?=\s*:)/,
122 lookbehind: true,
123 alias: "property"
124 },
125 "operator": [
126 {
127 pattern: /=>/,
128 alias: "arrow"
129 },
130 /--|\+\+|(?:\*\*|&&|\|\||[!=]=|>>>?|<<|[%&|^!=<>/*+-]|\?\?)=?|\.{3}|\?(?!\.)|~|:/
131 ],
132 "property-access": {
133 pattern: /(\.\s*)#?(?!\d)(?:(?!\s)[$\w\xa0-\uffff])+/,
134 lookbehind: true,
135 inside: {
136 "maybe-class-name": /^[A-Z].*/
137 }
138 },
139 "maybe-class-name": {
140 pattern: /(^|[^$\w\xa0-\uffff])[A-Z][$\w\xa0-\uffff]+/,
141 lookbehind: true
142 },
143 "punctuation": /\?\.|[()[\]{}.,:;]/
144 });
145 //# sourceMappingURL=javascript.js.map