razor.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. define("vs/basic-languages/razor/razor",[],()=>{
  8. var moduleExports = (() => {
  9. var __create = Object.create;
  10. var __defProp = Object.defineProperty;
  11. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  12. var __getOwnPropNames = Object.getOwnPropertyNames;
  13. var __getProtoOf = Object.getPrototypeOf;
  14. var __hasOwnProp = Object.prototype.hasOwnProperty;
  15. var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
  16. var __commonJS = (cb, mod) => function __require() {
  17. return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  18. };
  19. var __export = (target, all) => {
  20. __markAsModule(target);
  21. for (var name in all)
  22. __defProp(target, name, { get: all[name], enumerable: true });
  23. };
  24. var __reExport = (target, module, desc) => {
  25. if (module && typeof module === "object" || typeof module === "function") {
  26. for (let key of __getOwnPropNames(module))
  27. if (!__hasOwnProp.call(target, key) && key !== "default")
  28. __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
  29. }
  30. return target;
  31. };
  32. var __toModule = (module) => {
  33. return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
  34. };
  35. // build/fillers/monaco-editor-core-amd.ts
  36. var require_monaco_editor_core_amd = __commonJS({
  37. "build/fillers/monaco-editor-core-amd.ts"(exports, module) {
  38. module.exports = self.monaco;
  39. }
  40. });
  41. // src/basic-languages/razor/razor.ts
  42. var razor_exports = {};
  43. __export(razor_exports, {
  44. conf: () => conf,
  45. language: () => language
  46. });
  47. // src/fillers/monaco-editor-core.ts
  48. var monaco_editor_core_exports = {};
  49. __markAsModule(monaco_editor_core_exports);
  50. __reExport(monaco_editor_core_exports, __toModule(require_monaco_editor_core_amd()));
  51. // src/basic-languages/razor/razor.ts
  52. var EMPTY_ELEMENTS = [
  53. "area",
  54. "base",
  55. "br",
  56. "col",
  57. "embed",
  58. "hr",
  59. "img",
  60. "input",
  61. "keygen",
  62. "link",
  63. "menuitem",
  64. "meta",
  65. "param",
  66. "source",
  67. "track",
  68. "wbr"
  69. ];
  70. var conf = {
  71. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
  72. comments: {
  73. blockComment: ["<!--", "-->"]
  74. },
  75. brackets: [
  76. ["<!--", "-->"],
  77. ["<", ">"],
  78. ["{", "}"],
  79. ["(", ")"]
  80. ],
  81. autoClosingPairs: [
  82. { open: "{", close: "}" },
  83. { open: "[", close: "]" },
  84. { open: "(", close: ")" },
  85. { open: '"', close: '"' },
  86. { open: "'", close: "'" }
  87. ],
  88. surroundingPairs: [
  89. { open: '"', close: '"' },
  90. { open: "'", close: "'" },
  91. { open: "<", close: ">" }
  92. ],
  93. onEnterRules: [
  94. {
  95. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  96. afterText: /^<\/(\w[\w\d]*)\s*>$/i,
  97. action: {
  98. indentAction: monaco_editor_core_exports.languages.IndentAction.IndentOutdent
  99. }
  100. },
  101. {
  102. beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join("|")}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, "i"),
  103. action: { indentAction: monaco_editor_core_exports.languages.IndentAction.Indent }
  104. }
  105. ]
  106. };
  107. var language = {
  108. defaultToken: "",
  109. tokenPostfix: "",
  110. tokenizer: {
  111. root: [
  112. [/@@@@/],
  113. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.root" }],
  114. [/<!DOCTYPE/, "metatag.html", "@doctype"],
  115. [/<!--/, "comment.html", "@comment"],
  116. [/(<)([\w\-]+)(\/>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  117. [/(<)(script)/, ["delimiter.html", { token: "tag.html", next: "@script" }]],
  118. [/(<)(style)/, ["delimiter.html", { token: "tag.html", next: "@style" }]],
  119. [/(<)([:\w\-]+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  120. [/(<\/)([\w\-]+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  121. [/</, "delimiter.html"],
  122. [/[ \t\r\n]+/],
  123. [/[^<@]+/]
  124. ],
  125. doctype: [
  126. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.comment" }],
  127. [/[^>]+/, "metatag.content.html"],
  128. [/>/, "metatag.html", "@pop"]
  129. ],
  130. comment: [
  131. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.comment" }],
  132. [/-->/, "comment.html", "@pop"],
  133. [/[^-]+/, "comment.content.html"],
  134. [/./, "comment.content.html"]
  135. ],
  136. otherTag: [
  137. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.otherTag" }],
  138. [/\/?>/, "delimiter.html", "@pop"],
  139. [/"([^"]*)"/, "attribute.value"],
  140. [/'([^']*)'/, "attribute.value"],
  141. [/[\w\-]+/, "attribute.name"],
  142. [/=/, "delimiter"],
  143. [/[ \t\r\n]+/]
  144. ],
  145. script: [
  146. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.script" }],
  147. [/type/, "attribute.name", "@scriptAfterType"],
  148. [/"([^"]*)"/, "attribute.value"],
  149. [/'([^']*)'/, "attribute.value"],
  150. [/[\w\-]+/, "attribute.name"],
  151. [/=/, "delimiter"],
  152. [
  153. />/,
  154. {
  155. token: "delimiter.html",
  156. next: "@scriptEmbedded.text/javascript",
  157. nextEmbedded: "text/javascript"
  158. }
  159. ],
  160. [/[ \t\r\n]+/],
  161. [
  162. /(<\/)(script\s*)(>)/,
  163. ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]
  164. ]
  165. ],
  166. scriptAfterType: [
  167. [
  168. /@[^@]/,
  169. {
  170. token: "@rematch",
  171. switchTo: "@razorInSimpleState.scriptAfterType"
  172. }
  173. ],
  174. [/=/, "delimiter", "@scriptAfterTypeEquals"],
  175. [
  176. />/,
  177. {
  178. token: "delimiter.html",
  179. next: "@scriptEmbedded.text/javascript",
  180. nextEmbedded: "text/javascript"
  181. }
  182. ],
  183. [/[ \t\r\n]+/],
  184. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  185. ],
  186. scriptAfterTypeEquals: [
  187. [
  188. /@[^@]/,
  189. {
  190. token: "@rematch",
  191. switchTo: "@razorInSimpleState.scriptAfterTypeEquals"
  192. }
  193. ],
  194. [
  195. /"([^"]*)"/,
  196. {
  197. token: "attribute.value",
  198. switchTo: "@scriptWithCustomType.$1"
  199. }
  200. ],
  201. [
  202. /'([^']*)'/,
  203. {
  204. token: "attribute.value",
  205. switchTo: "@scriptWithCustomType.$1"
  206. }
  207. ],
  208. [
  209. />/,
  210. {
  211. token: "delimiter.html",
  212. next: "@scriptEmbedded.text/javascript",
  213. nextEmbedded: "text/javascript"
  214. }
  215. ],
  216. [/[ \t\r\n]+/],
  217. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  218. ],
  219. scriptWithCustomType: [
  220. [
  221. /@[^@]/,
  222. {
  223. token: "@rematch",
  224. switchTo: "@razorInSimpleState.scriptWithCustomType.$S2"
  225. }
  226. ],
  227. [
  228. />/,
  229. {
  230. token: "delimiter.html",
  231. next: "@scriptEmbedded.$S2",
  232. nextEmbedded: "$S2"
  233. }
  234. ],
  235. [/"([^"]*)"/, "attribute.value"],
  236. [/'([^']*)'/, "attribute.value"],
  237. [/[\w\-]+/, "attribute.name"],
  238. [/=/, "delimiter"],
  239. [/[ \t\r\n]+/],
  240. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  241. ],
  242. scriptEmbedded: [
  243. [
  244. /@[^@]/,
  245. {
  246. token: "@rematch",
  247. switchTo: "@razorInEmbeddedState.scriptEmbedded.$S2",
  248. nextEmbedded: "@pop"
  249. }
  250. ],
  251. [/<\/script/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]
  252. ],
  253. style: [
  254. [/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.style" }],
  255. [/type/, "attribute.name", "@styleAfterType"],
  256. [/"([^"]*)"/, "attribute.value"],
  257. [/'([^']*)'/, "attribute.value"],
  258. [/[\w\-]+/, "attribute.name"],
  259. [/=/, "delimiter"],
  260. [
  261. />/,
  262. {
  263. token: "delimiter.html",
  264. next: "@styleEmbedded.text/css",
  265. nextEmbedded: "text/css"
  266. }
  267. ],
  268. [/[ \t\r\n]+/],
  269. [
  270. /(<\/)(style\s*)(>)/,
  271. ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]
  272. ]
  273. ],
  274. styleAfterType: [
  275. [
  276. /@[^@]/,
  277. {
  278. token: "@rematch",
  279. switchTo: "@razorInSimpleState.styleAfterType"
  280. }
  281. ],
  282. [/=/, "delimiter", "@styleAfterTypeEquals"],
  283. [
  284. />/,
  285. {
  286. token: "delimiter.html",
  287. next: "@styleEmbedded.text/css",
  288. nextEmbedded: "text/css"
  289. }
  290. ],
  291. [/[ \t\r\n]+/],
  292. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  293. ],
  294. styleAfterTypeEquals: [
  295. [
  296. /@[^@]/,
  297. {
  298. token: "@rematch",
  299. switchTo: "@razorInSimpleState.styleAfterTypeEquals"
  300. }
  301. ],
  302. [
  303. /"([^"]*)"/,
  304. {
  305. token: "attribute.value",
  306. switchTo: "@styleWithCustomType.$1"
  307. }
  308. ],
  309. [
  310. /'([^']*)'/,
  311. {
  312. token: "attribute.value",
  313. switchTo: "@styleWithCustomType.$1"
  314. }
  315. ],
  316. [
  317. />/,
  318. {
  319. token: "delimiter.html",
  320. next: "@styleEmbedded.text/css",
  321. nextEmbedded: "text/css"
  322. }
  323. ],
  324. [/[ \t\r\n]+/],
  325. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  326. ],
  327. styleWithCustomType: [
  328. [
  329. /@[^@]/,
  330. {
  331. token: "@rematch",
  332. switchTo: "@razorInSimpleState.styleWithCustomType.$S2"
  333. }
  334. ],
  335. [
  336. />/,
  337. {
  338. token: "delimiter.html",
  339. next: "@styleEmbedded.$S2",
  340. nextEmbedded: "$S2"
  341. }
  342. ],
  343. [/"([^"]*)"/, "attribute.value"],
  344. [/'([^']*)'/, "attribute.value"],
  345. [/[\w\-]+/, "attribute.name"],
  346. [/=/, "delimiter"],
  347. [/[ \t\r\n]+/],
  348. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  349. ],
  350. styleEmbedded: [
  351. [
  352. /@[^@]/,
  353. {
  354. token: "@rematch",
  355. switchTo: "@razorInEmbeddedState.styleEmbedded.$S2",
  356. nextEmbedded: "@pop"
  357. }
  358. ],
  359. [/<\/style/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]
  360. ],
  361. razorInSimpleState: [
  362. [/@\*/, "comment.cs", "@razorBlockCommentTopLevel"],
  363. [/@[{(]/, "metatag.cs", "@razorRootTopLevel"],
  364. [/(@)(\s*[\w]+)/, ["metatag.cs", { token: "identifier.cs", switchTo: "@$S2.$S3" }]],
  365. [/[})]/, { token: "metatag.cs", switchTo: "@$S2.$S3" }],
  366. [/\*@/, { token: "comment.cs", switchTo: "@$S2.$S3" }]
  367. ],
  368. razorInEmbeddedState: [
  369. [/@\*/, "comment.cs", "@razorBlockCommentTopLevel"],
  370. [/@[{(]/, "metatag.cs", "@razorRootTopLevel"],
  371. [
  372. /(@)(\s*[\w]+)/,
  373. [
  374. "metatag.cs",
  375. {
  376. token: "identifier.cs",
  377. switchTo: "@$S2.$S3",
  378. nextEmbedded: "$S3"
  379. }
  380. ]
  381. ],
  382. [
  383. /[})]/,
  384. {
  385. token: "metatag.cs",
  386. switchTo: "@$S2.$S3",
  387. nextEmbedded: "$S3"
  388. }
  389. ],
  390. [
  391. /\*@/,
  392. {
  393. token: "comment.cs",
  394. switchTo: "@$S2.$S3",
  395. nextEmbedded: "$S3"
  396. }
  397. ]
  398. ],
  399. razorBlockCommentTopLevel: [
  400. [/\*@/, "@rematch", "@pop"],
  401. [/[^*]+/, "comment.cs"],
  402. [/./, "comment.cs"]
  403. ],
  404. razorBlockComment: [
  405. [/\*@/, "comment.cs", "@pop"],
  406. [/[^*]+/, "comment.cs"],
  407. [/./, "comment.cs"]
  408. ],
  409. razorRootTopLevel: [
  410. [/\{/, "delimiter.bracket.cs", "@razorRoot"],
  411. [/\(/, "delimiter.parenthesis.cs", "@razorRoot"],
  412. [/[})]/, "@rematch", "@pop"],
  413. { include: "razorCommon" }
  414. ],
  415. razorRoot: [
  416. [/\{/, "delimiter.bracket.cs", "@razorRoot"],
  417. [/\(/, "delimiter.parenthesis.cs", "@razorRoot"],
  418. [/\}/, "delimiter.bracket.cs", "@pop"],
  419. [/\)/, "delimiter.parenthesis.cs", "@pop"],
  420. { include: "razorCommon" }
  421. ],
  422. razorCommon: [
  423. [
  424. /[a-zA-Z_]\w*/,
  425. {
  426. cases: {
  427. "@razorKeywords": { token: "keyword.cs" },
  428. "@default": "identifier.cs"
  429. }
  430. }
  431. ],
  432. [/[\[\]]/, "delimiter.array.cs"],
  433. [/[ \t\r\n]+/],
  434. [/\/\/.*$/, "comment.cs"],
  435. [/@\*/, "comment.cs", "@razorBlockComment"],
  436. [/"([^"]*)"/, "string.cs"],
  437. [/'([^']*)'/, "string.cs"],
  438. [/(<)([\w\-]+)(\/>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  439. [/(<)([\w\-]+)(>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  440. [/(<\/)([\w\-]+)(>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  441. [/[\+\-\*\%\&\|\^\~\!\=\<\>\/\?\;\:\.\,]/, "delimiter.cs"],
  442. [/\d*\d+[eE]([\-+]?\d+)?/, "number.float.cs"],
  443. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float.cs"],
  444. [/0[xX][0-9a-fA-F']*[0-9a-fA-F]/, "number.hex.cs"],
  445. [/0[0-7']*[0-7]/, "number.octal.cs"],
  446. [/0[bB][0-1']*[0-1]/, "number.binary.cs"],
  447. [/\d[\d']*/, "number.cs"],
  448. [/\d/, "number.cs"]
  449. ]
  450. },
  451. razorKeywords: [
  452. "abstract",
  453. "as",
  454. "async",
  455. "await",
  456. "base",
  457. "bool",
  458. "break",
  459. "by",
  460. "byte",
  461. "case",
  462. "catch",
  463. "char",
  464. "checked",
  465. "class",
  466. "const",
  467. "continue",
  468. "decimal",
  469. "default",
  470. "delegate",
  471. "do",
  472. "double",
  473. "descending",
  474. "explicit",
  475. "event",
  476. "extern",
  477. "else",
  478. "enum",
  479. "false",
  480. "finally",
  481. "fixed",
  482. "float",
  483. "for",
  484. "foreach",
  485. "from",
  486. "goto",
  487. "group",
  488. "if",
  489. "implicit",
  490. "in",
  491. "int",
  492. "interface",
  493. "internal",
  494. "into",
  495. "is",
  496. "lock",
  497. "long",
  498. "nameof",
  499. "new",
  500. "null",
  501. "namespace",
  502. "object",
  503. "operator",
  504. "out",
  505. "override",
  506. "orderby",
  507. "params",
  508. "private",
  509. "protected",
  510. "public",
  511. "readonly",
  512. "ref",
  513. "return",
  514. "switch",
  515. "struct",
  516. "sbyte",
  517. "sealed",
  518. "short",
  519. "sizeof",
  520. "stackalloc",
  521. "static",
  522. "string",
  523. "select",
  524. "this",
  525. "throw",
  526. "true",
  527. "try",
  528. "typeof",
  529. "uint",
  530. "ulong",
  531. "unchecked",
  532. "unsafe",
  533. "ushort",
  534. "using",
  535. "var",
  536. "virtual",
  537. "volatile",
  538. "void",
  539. "when",
  540. "while",
  541. "where",
  542. "yield",
  543. "model",
  544. "inject"
  545. ],
  546. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/
  547. };
  548. return razor_exports;
  549. })();
  550. return moduleExports;
  551. });