terminal-pilot 0.0.37 → 0.0.38

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.
Files changed (204) hide show
  1. package/dist/cli.js +152 -2
  2. package/dist/cli.js.map +3 -3
  3. package/dist/commands/close-session.js +1 -1
  4. package/dist/commands/close-session.js.map +2 -2
  5. package/dist/commands/create-session.js +1 -1
  6. package/dist/commands/create-session.js.map +2 -2
  7. package/dist/commands/daemon-runtime.js +1 -1
  8. package/dist/commands/daemon-runtime.js.map +2 -2
  9. package/dist/commands/fill.js +1 -1
  10. package/dist/commands/fill.js.map +2 -2
  11. package/dist/commands/get-session.js +1 -1
  12. package/dist/commands/get-session.js.map +2 -2
  13. package/dist/commands/index.js +145 -1
  14. package/dist/commands/index.js.map +3 -3
  15. package/dist/commands/install.js +145 -1
  16. package/dist/commands/install.js.map +3 -3
  17. package/dist/commands/installer.js +145 -1
  18. package/dist/commands/installer.js.map +3 -3
  19. package/dist/commands/list-sessions.js +1 -1
  20. package/dist/commands/list-sessions.js.map +2 -2
  21. package/dist/commands/press-key.js +1 -1
  22. package/dist/commands/press-key.js.map +2 -2
  23. package/dist/commands/read-history.js +1 -1
  24. package/dist/commands/read-history.js.map +2 -2
  25. package/dist/commands/read-screen.js +1 -1
  26. package/dist/commands/read-screen.js.map +2 -2
  27. package/dist/commands/resize.js +1 -1
  28. package/dist/commands/resize.js.map +2 -2
  29. package/dist/commands/runtime.js +1 -1
  30. package/dist/commands/runtime.js.map +2 -2
  31. package/dist/commands/screenshot.js +1 -1
  32. package/dist/commands/screenshot.js.map +2 -2
  33. package/dist/commands/send-signal.js +1 -1
  34. package/dist/commands/send-signal.js.map +2 -2
  35. package/dist/commands/type.js +1 -1
  36. package/dist/commands/type.js.map +2 -2
  37. package/dist/commands/uninstall.js +145 -1
  38. package/dist/commands/uninstall.js.map +3 -3
  39. package/dist/commands/wait-for-exit.js +1 -1
  40. package/dist/commands/wait-for-exit.js.map +2 -2
  41. package/dist/commands/wait-for.js +1 -1
  42. package/dist/commands/wait-for.js.map +2 -2
  43. package/dist/testing/cli-repl.js +152 -2
  44. package/dist/testing/cli-repl.js.map +3 -3
  45. package/dist/testing/qa-cli.js +152 -2
  46. package/dist/testing/qa-cli.js.map +3 -3
  47. package/node_modules/toolcraft-design/README.md +187 -5
  48. package/node_modules/toolcraft-design/dist/brand.d.ts +2 -0
  49. package/node_modules/toolcraft-design/dist/brand.js +1 -0
  50. package/node_modules/toolcraft-design/dist/brands.d.ts +2 -0
  51. package/node_modules/toolcraft-design/dist/brands.js +1 -0
  52. package/node_modules/toolcraft-design/dist/cancel.d.ts +1 -0
  53. package/node_modules/toolcraft-design/dist/cancel.js +1 -0
  54. package/node_modules/toolcraft-design/dist/color.d.ts +2 -0
  55. package/node_modules/toolcraft-design/dist/color.js +1 -0
  56. package/node_modules/toolcraft-design/dist/configure-theme.d.ts +1 -0
  57. package/node_modules/toolcraft-design/dist/configure-theme.js +1 -0
  58. package/node_modules/toolcraft-design/dist/confirm-or-cancel.d.ts +2 -0
  59. package/node_modules/toolcraft-design/dist/confirm-or-cancel.js +1 -0
  60. package/node_modules/toolcraft-design/dist/confirm.d.ts +2 -0
  61. package/node_modules/toolcraft-design/dist/confirm.js +1 -0
  62. package/node_modules/toolcraft-design/dist/create-dashboard.d.ts +2 -0
  63. package/node_modules/toolcraft-design/dist/create-dashboard.js +1 -0
  64. package/node_modules/toolcraft-design/dist/create-logger.d.ts +2 -0
  65. package/node_modules/toolcraft-design/dist/create-logger.js +1 -0
  66. package/node_modules/toolcraft-design/dist/dark.d.ts +2 -0
  67. package/node_modules/toolcraft-design/dist/dark.js +1 -0
  68. package/node_modules/toolcraft-design/dist/format-columns.d.ts +2 -0
  69. package/node_modules/toolcraft-design/dist/format-columns.js +1 -0
  70. package/node_modules/toolcraft-design/dist/format-command-list.d.ts +2 -0
  71. package/node_modules/toolcraft-design/dist/format-command-list.js +1 -0
  72. package/node_modules/toolcraft-design/dist/format-command-not-found-panel.d.ts +1 -0
  73. package/node_modules/toolcraft-design/dist/format-command-not-found-panel.js +1 -0
  74. package/node_modules/toolcraft-design/dist/format-command-not-found.d.ts +1 -0
  75. package/node_modules/toolcraft-design/dist/format-command-not-found.js +1 -0
  76. package/node_modules/toolcraft-design/dist/format-command.d.ts +1 -0
  77. package/node_modules/toolcraft-design/dist/format-command.js +1 -0
  78. package/node_modules/toolcraft-design/dist/format-option-list.d.ts +2 -0
  79. package/node_modules/toolcraft-design/dist/format-option-list.js +1 -0
  80. package/node_modules/toolcraft-design/dist/format-option.d.ts +1 -0
  81. package/node_modules/toolcraft-design/dist/format-option.js +1 -0
  82. package/node_modules/toolcraft-design/dist/format-usage.d.ts +1 -0
  83. package/node_modules/toolcraft-design/dist/format-usage.js +1 -0
  84. package/node_modules/toolcraft-design/dist/get-template-partial-names.d.ts +1 -0
  85. package/node_modules/toolcraft-design/dist/get-template-partial-names.js +1 -0
  86. package/node_modules/toolcraft-design/dist/get-theme-config.d.ts +1 -0
  87. package/node_modules/toolcraft-design/dist/get-theme-config.js +1 -0
  88. package/node_modules/toolcraft-design/dist/get-theme.d.ts +2 -0
  89. package/node_modules/toolcraft-design/dist/get-theme.js +1 -0
  90. package/node_modules/toolcraft-design/dist/help-formatter-plain.d.ts +2 -0
  91. package/node_modules/toolcraft-design/dist/help-formatter-plain.js +2 -0
  92. package/node_modules/toolcraft-design/dist/help-formatter.d.ts +2 -0
  93. package/node_modules/toolcraft-design/dist/help-formatter.js +1 -0
  94. package/node_modules/toolcraft-design/dist/index.d.ts +2 -2
  95. package/node_modules/toolcraft-design/dist/index.js +1 -1
  96. package/node_modules/toolcraft-design/dist/intro-plain.d.ts +1 -0
  97. package/node_modules/toolcraft-design/dist/intro-plain.js +1 -0
  98. package/node_modules/toolcraft-design/dist/intro.d.ts +1 -0
  99. package/node_modules/toolcraft-design/dist/intro.js +1 -0
  100. package/node_modules/toolcraft-design/dist/is-cancel.d.ts +1 -0
  101. package/node_modules/toolcraft-design/dist/is-cancel.js +1 -0
  102. package/node_modules/toolcraft-design/dist/light.d.ts +2 -0
  103. package/node_modules/toolcraft-design/dist/light.js +1 -0
  104. package/node_modules/toolcraft-design/dist/log.d.ts +1 -0
  105. package/node_modules/toolcraft-design/dist/log.js +1 -0
  106. package/node_modules/toolcraft-design/dist/logger.d.ts +2 -0
  107. package/node_modules/toolcraft-design/dist/logger.js +1 -0
  108. package/node_modules/toolcraft-design/dist/multiselect.d.ts +2 -0
  109. package/node_modules/toolcraft-design/dist/multiselect.js +1 -0
  110. package/node_modules/toolcraft-design/dist/note.d.ts +1 -0
  111. package/node_modules/toolcraft-design/dist/note.js +1 -0
  112. package/node_modules/toolcraft-design/dist/open-external.d.ts +1 -0
  113. package/node_modules/toolcraft-design/dist/open-external.js +1 -0
  114. package/node_modules/toolcraft-design/dist/outro.d.ts +1 -0
  115. package/node_modules/toolcraft-design/dist/outro.js +1 -0
  116. package/node_modules/toolcraft-design/dist/parse.d.ts +2 -0
  117. package/node_modules/toolcraft-design/dist/parse.js +1 -0
  118. package/node_modules/toolcraft-design/dist/password.d.ts +2 -0
  119. package/node_modules/toolcraft-design/dist/password.js +1 -0
  120. package/node_modules/toolcraft-design/dist/prompt-cancelled-error.d.ts +1 -0
  121. package/node_modules/toolcraft-design/dist/prompt-cancelled-error.js +1 -0
  122. package/node_modules/toolcraft-design/dist/prompt-text.d.ts +2 -0
  123. package/node_modules/toolcraft-design/dist/prompt-text.js +1 -0
  124. package/node_modules/toolcraft-design/dist/prompt-theme.d.ts +1 -0
  125. package/node_modules/toolcraft-design/dist/prompt-theme.js +1 -0
  126. package/node_modules/toolcraft-design/dist/render-catalog.d.ts +2 -0
  127. package/node_modules/toolcraft-design/dist/render-catalog.js +1 -0
  128. package/node_modules/toolcraft-design/dist/render-detail-card.d.ts +2 -0
  129. package/node_modules/toolcraft-design/dist/render-detail-card.js +1 -0
  130. package/node_modules/toolcraft-design/dist/render-html.d.ts +2 -0
  131. package/node_modules/toolcraft-design/dist/render-html.js +1 -0
  132. package/node_modules/toolcraft-design/dist/render-inspector-card.d.ts +2 -0
  133. package/node_modules/toolcraft-design/dist/render-inspector-card.js +1 -0
  134. package/node_modules/toolcraft-design/dist/render-markdown-html.d.ts +2 -0
  135. package/node_modules/toolcraft-design/dist/render-markdown-html.js +1 -0
  136. package/node_modules/toolcraft-design/dist/render-markdown.d.ts +2 -0
  137. package/node_modules/toolcraft-design/dist/render-markdown.js +1 -0
  138. package/node_modules/toolcraft-design/dist/render-menu.d.ts +2 -0
  139. package/node_modules/toolcraft-design/dist/render-menu.js +1 -0
  140. package/node_modules/toolcraft-design/dist/render-resource-browser.d.ts +2 -0
  141. package/node_modules/toolcraft-design/dist/render-resource-browser.js +1 -0
  142. package/node_modules/toolcraft-design/dist/render-spinner-frame.d.ts +2 -0
  143. package/node_modules/toolcraft-design/dist/render-spinner-frame.js +1 -0
  144. package/node_modules/toolcraft-design/dist/render-spinner-stopped.d.ts +2 -0
  145. package/node_modules/toolcraft-design/dist/render-spinner-stopped.js +1 -0
  146. package/node_modules/toolcraft-design/dist/render-table.d.ts +2 -0
  147. package/node_modules/toolcraft-design/dist/render-table.js +1 -0
  148. package/node_modules/toolcraft-design/dist/render-template.d.ts +2 -0
  149. package/node_modules/toolcraft-design/dist/render-template.js +1 -0
  150. package/node_modules/toolcraft-design/dist/render.d.ts +2 -0
  151. package/node_modules/toolcraft-design/dist/render.js +1 -0
  152. package/node_modules/toolcraft-design/dist/reset-output-format-cache.d.ts +1 -0
  153. package/node_modules/toolcraft-design/dist/reset-output-format-cache.js +1 -0
  154. package/node_modules/toolcraft-design/dist/reset-theme-cache.d.ts +1 -0
  155. package/node_modules/toolcraft-design/dist/reset-theme-cache.js +1 -0
  156. package/node_modules/toolcraft-design/dist/reset-theme.d.ts +1 -0
  157. package/node_modules/toolcraft-design/dist/reset-theme.js +1 -0
  158. package/node_modules/toolcraft-design/dist/resolve-output-format.d.ts +2 -0
  159. package/node_modules/toolcraft-design/dist/resolve-output-format.js +1 -0
  160. package/node_modules/toolcraft-design/dist/resolve-template-partials.d.ts +1 -0
  161. package/node_modules/toolcraft-design/dist/resolve-template-partials.js +1 -0
  162. package/node_modules/toolcraft-design/dist/resolve-theme-name.d.ts +2 -0
  163. package/node_modules/toolcraft-design/dist/resolve-theme-name.js +1 -0
  164. package/node_modules/toolcraft-design/dist/run-explorer.d.ts +2 -0
  165. package/node_modules/toolcraft-design/dist/run-explorer.js +1 -0
  166. package/node_modules/toolcraft-design/dist/run-two-pane-explorer.d.ts +2 -0
  167. package/node_modules/toolcraft-design/dist/run-two-pane-explorer.js +1 -0
  168. package/node_modules/toolcraft-design/dist/select.d.ts +2 -0
  169. package/node_modules/toolcraft-design/dist/select.js +1 -0
  170. package/node_modules/toolcraft-design/dist/should-use-interactive-dashboard.d.ts +1 -0
  171. package/node_modules/toolcraft-design/dist/should-use-interactive-dashboard.js +1 -0
  172. package/node_modules/toolcraft-design/dist/single-detail.d.ts +2 -0
  173. package/node_modules/toolcraft-design/dist/single-detail.js +1 -0
  174. package/node_modules/toolcraft-design/dist/spacing.d.ts +1 -0
  175. package/node_modules/toolcraft-design/dist/spacing.js +1 -0
  176. package/node_modules/toolcraft-design/dist/spinner-frames.d.ts +1 -0
  177. package/node_modules/toolcraft-design/dist/spinner-frames.js +1 -0
  178. package/node_modules/toolcraft-design/dist/spinner.d.ts +2 -0
  179. package/node_modules/toolcraft-design/dist/spinner.js +1 -0
  180. package/node_modules/toolcraft-design/dist/strip-ansi.d.ts +1 -0
  181. package/node_modules/toolcraft-design/dist/strip-ansi.js +1 -0
  182. package/node_modules/toolcraft-design/dist/symbols.d.ts +1 -0
  183. package/node_modules/toolcraft-design/dist/symbols.js +1 -0
  184. package/node_modules/toolcraft-design/dist/terminal-markdown/ast.d.ts +6 -0
  185. package/node_modules/toolcraft-design/dist/terminal-markdown/html-renderer.d.ts +7 -0
  186. package/node_modules/toolcraft-design/dist/terminal-markdown/html-renderer.js +366 -0
  187. package/node_modules/toolcraft-design/dist/terminal-markdown/index.d.ts +5 -1
  188. package/node_modules/toolcraft-design/dist/terminal-markdown/index.js +6 -0
  189. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/code-highlight.d.ts +4 -0
  190. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/code-highlight.js +1357 -0
  191. package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.d.ts +1 -0
  192. package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.js +63 -1
  193. package/node_modules/toolcraft-design/dist/text.d.ts +1 -0
  194. package/node_modules/toolcraft-design/dist/text.js +1 -0
  195. package/node_modules/toolcraft-design/dist/typography.d.ts +1 -0
  196. package/node_modules/toolcraft-design/dist/typography.js +1 -0
  197. package/node_modules/toolcraft-design/dist/widths.d.ts +1 -0
  198. package/node_modules/toolcraft-design/dist/widths.js +1 -0
  199. package/node_modules/toolcraft-design/dist/with-output-format.d.ts +2 -0
  200. package/node_modules/toolcraft-design/dist/with-output-format.js +1 -0
  201. package/node_modules/toolcraft-design/dist/with-spinner.d.ts +2 -0
  202. package/node_modules/toolcraft-design/dist/with-spinner.js +1 -0
  203. package/node_modules/toolcraft-design/package.json +4 -0
  204. package/package.json +1 -1
@@ -0,0 +1,1357 @@
1
+ const cStyleBlockComments = [{ start: "/*", end: "*/" }];
2
+ const codeLanguages = [
3
+ {
4
+ id: "javascript",
5
+ aliases: ["js", "javascript", "mjs", "cjs", "es6"],
6
+ family: "lexical",
7
+ spec: "javascript"
8
+ },
9
+ { id: "javascriptreact", aliases: ["jsx"], family: "lexical", spec: "javascript" },
10
+ {
11
+ id: "typescript",
12
+ aliases: ["ts", "typescript", "mts", "cts"],
13
+ family: "lexical",
14
+ spec: "typescript"
15
+ },
16
+ { id: "typescriptreact", aliases: ["tsx"], family: "lexical", spec: "typescript" },
17
+ { id: "json", aliases: ["json"], family: "data", spec: "json" },
18
+ { id: "jsonc", aliases: ["jsonc"], family: "data", spec: "jsonc" },
19
+ { id: "jsonl", aliases: ["jsonl"], family: "data", spec: "json" },
20
+ { id: "yaml", aliases: ["yaml", "yml"], family: "data", spec: "yaml" },
21
+ { id: "css", aliases: ["css"], family: "style", spec: "css" },
22
+ { id: "scss", aliases: ["scss"], family: "style", spec: "css" },
23
+ { id: "sass", aliases: ["sass"], family: "style", spec: "css" },
24
+ { id: "less", aliases: ["less"], family: "style", spec: "css" },
25
+ { id: "postcss", aliases: ["postcss"], family: "style", spec: "css" },
26
+ { id: "shellscript", aliases: ["sh", "bash", "shell", "shellscript", "zsh", "fish"], family: "lexical", spec: "shell" },
27
+ { id: "python", aliases: ["py", "python"], family: "lexical", spec: "python" },
28
+ { id: "sql", aliases: ["sql", "ddl", "dml"], family: "lexical", spec: "sql" },
29
+ { id: "html", aliases: ["html"], family: "markup", spec: "html" },
30
+ { id: "xml", aliases: ["xml", "svg"], family: "markup", spec: "xml" },
31
+ { id: "markdown", aliases: ["md", "markdown"], family: "line", spec: "markdown" },
32
+ { id: "diff", aliases: ["diff", "patch"], family: "line", spec: "diff" },
33
+ { id: "dockerfile", aliases: ["dockerfile", "docker"], family: "line", spec: "dockerfile" },
34
+ { id: "ini", aliases: ["ini", "properties"], family: "data", spec: "ini" },
35
+ { id: "toml", aliases: ["toml"], family: "data", spec: "toml" },
36
+ { id: "plaintext", aliases: ["text", "txt", "plain", "plaintext"], plain: true },
37
+ { id: "ruby", aliases: ["rb", "ruby"], family: "lexical", spec: "ruby" },
38
+ { id: "go", aliases: ["go", "golang"], family: "lexical", spec: "go" },
39
+ { id: "java", aliases: ["java"], family: "lexical", spec: "java" },
40
+ { id: "kotlin", aliases: ["kt", "kotlin", "kts"], family: "lexical", spec: "kotlin" },
41
+ { id: "swift", aliases: ["swift"], family: "lexical", spec: "swift" },
42
+ { id: "dart", aliases: ["dart"], family: "lexical", spec: "dart" },
43
+ { id: "scala", aliases: ["scala", "sc"], family: "lexical", spec: "scala" },
44
+ { id: "groovy", aliases: ["groovy", "gvy", "gy", "gsp"], family: "lexical", spec: "groovy" },
45
+ { id: "c", aliases: ["c"], family: "lexical", spec: "c" },
46
+ { id: "cpp", aliases: ["cpp", "c++", "cc", "cxx"], family: "lexical", spec: "cpp" },
47
+ { id: "csharp", aliases: ["cs", "csharp", "c#"], family: "lexical", spec: "csharp" },
48
+ { id: "objective-c", aliases: ["objc", "objectivec", "objective-c", "m", "mm"], family: "lexical", spec: "objectivec" },
49
+ { id: "rust", aliases: ["rs", "rust"], family: "lexical", spec: "rust" },
50
+ { id: "php", aliases: ["php"], family: "lexical", spec: "php" },
51
+ { id: "lua", aliases: ["lua"], family: "lexical", spec: "lua" },
52
+ { id: "perl", aliases: ["pl", "perl", "pm"], family: "lexical", spec: "perl" },
53
+ { id: "r", aliases: ["r", "rscript"], family: "lexical", spec: "r" },
54
+ { id: "powershell", aliases: ["ps1", "powershell", "pwsh"], family: "lexical", spec: "powershell" },
55
+ { id: "elixir", aliases: ["ex", "exs", "elixir"], family: "lexical", spec: "elixir" },
56
+ { id: "erlang", aliases: ["erl", "erlang", "hrl"], family: "lexical", spec: "erlang" },
57
+ { id: "haskell", aliases: ["hs", "haskell"], family: "lexical", spec: "haskell" },
58
+ { id: "clojure", aliases: ["clj", "cljs", "cljc", "clojure"], family: "lexical", spec: "clojure" },
59
+ { id: "fsharp", aliases: ["fs", "fsi", "fsx", "fsharp"], family: "lexical", spec: "fsharp" },
60
+ { id: "vb", aliases: ["vb", "vbnet"], family: "lexical", spec: "vb" },
61
+ { id: "graphql", aliases: ["graphql", "gql"], family: "lexical", spec: "graphql" },
62
+ { id: "protobuf", aliases: ["proto", "protobuf"], family: "lexical", spec: "protobuf" },
63
+ { id: "hcl", aliases: ["hcl", "tf", "terraform"], family: "lexical", spec: "hcl" },
64
+ { id: "nginx", aliases: ["nginx", "nginxconf"], family: "lexical", spec: "nginx" },
65
+ { id: "makefile", aliases: ["makefile", "mk"], family: "lexical", spec: "makefile" },
66
+ { id: "cmake", aliases: ["cmake"], family: "lexical", spec: "cmake" },
67
+ { id: "gradle", aliases: ["gradle"], family: "lexical", spec: "groovy" },
68
+ { id: "env", aliases: ["env", "dotenv"], family: "data", spec: "ini" },
69
+ { id: "vue", aliases: ["vue"], family: "markup", spec: "html" },
70
+ { id: "svelte", aliases: ["svelte"], family: "markup", spec: "html" }
71
+ ];
72
+ const languageByAlias = new Map();
73
+ for (const language of codeLanguages) {
74
+ languageByAlias.set(language.id.toLowerCase(), language);
75
+ for (const alias of language.aliases) {
76
+ languageByAlias.set(alias.toLowerCase(), language);
77
+ }
78
+ }
79
+ const jsKeywords = new Set([
80
+ "as",
81
+ "async",
82
+ "await",
83
+ "break",
84
+ "case",
85
+ "catch",
86
+ "class",
87
+ "const",
88
+ "continue",
89
+ "debugger",
90
+ "default",
91
+ "delete",
92
+ "do",
93
+ "else",
94
+ "export",
95
+ "extends",
96
+ "finally",
97
+ "for",
98
+ "from",
99
+ "function",
100
+ "get",
101
+ "if",
102
+ "import",
103
+ "in",
104
+ "instanceof",
105
+ "let",
106
+ "new",
107
+ "of",
108
+ "return",
109
+ "set",
110
+ "static",
111
+ "super",
112
+ "switch",
113
+ "throw",
114
+ "try",
115
+ "typeof",
116
+ "var",
117
+ "void",
118
+ "while",
119
+ "with",
120
+ "yield"
121
+ ]);
122
+ const tsKeywords = new Set([
123
+ ...jsKeywords,
124
+ "abstract",
125
+ "declare",
126
+ "enum",
127
+ "implements",
128
+ "interface",
129
+ "keyof",
130
+ "namespace",
131
+ "private",
132
+ "protected",
133
+ "public",
134
+ "readonly",
135
+ "satisfies",
136
+ "type"
137
+ ]);
138
+ const tsTypes = new Set([
139
+ "any",
140
+ "bigint",
141
+ "boolean",
142
+ "never",
143
+ "number",
144
+ "object",
145
+ "string",
146
+ "symbol",
147
+ "unknown",
148
+ "void"
149
+ ]);
150
+ const jsConstants = new Set(["true", "false", "null", "undefined", "NaN", "Infinity"]);
151
+ const pythonKeywords = new Set([
152
+ "and",
153
+ "as",
154
+ "assert",
155
+ "async",
156
+ "await",
157
+ "break",
158
+ "case",
159
+ "class",
160
+ "continue",
161
+ "def",
162
+ "del",
163
+ "elif",
164
+ "else",
165
+ "except",
166
+ "finally",
167
+ "for",
168
+ "from",
169
+ "global",
170
+ "if",
171
+ "import",
172
+ "in",
173
+ "is",
174
+ "lambda",
175
+ "match",
176
+ "nonlocal",
177
+ "not",
178
+ "or",
179
+ "pass",
180
+ "raise",
181
+ "return",
182
+ "try",
183
+ "while",
184
+ "with",
185
+ "yield"
186
+ ]);
187
+ const pythonTypes = new Set(["Any", "Callable", "Iterable", "None", "Protocol", "Self", "TypeVar", "bool", "bytes", "dict", "float", "int", "list", "object", "set", "str", "tuple"]);
188
+ const pythonBooleans = new Set(["True", "False"]);
189
+ const pythonNulls = new Set(["None", "NotImplemented", "Ellipsis"]);
190
+ const shellKeywords = new Set(["case", "do", "done", "elif", "else", "esac", "fi", "for", "function", "if", "in", "select", "then", "until", "while"]);
191
+ const shellCommands = new Set(["awk", "cat", "cd", "chmod", "cp", "echo", "env", "export", "find", "grep", "mkdir", "mv", "printf", "pwd", "rm", "sed", "test"]);
192
+ const sqlKeywords = new Set([
193
+ "add",
194
+ "alter",
195
+ "and",
196
+ "as",
197
+ "by",
198
+ "case",
199
+ "create",
200
+ "delete",
201
+ "desc",
202
+ "distinct",
203
+ "drop",
204
+ "else",
205
+ "end",
206
+ "exists",
207
+ "from",
208
+ "group",
209
+ "having",
210
+ "in",
211
+ "insert",
212
+ "into",
213
+ "is",
214
+ "join",
215
+ "left",
216
+ "limit",
217
+ "not",
218
+ "null",
219
+ "on",
220
+ "or",
221
+ "order",
222
+ "outer",
223
+ "primary",
224
+ "references",
225
+ "right",
226
+ "select",
227
+ "set",
228
+ "table",
229
+ "then",
230
+ "union",
231
+ "update",
232
+ "values",
233
+ "when",
234
+ "where"
235
+ ]);
236
+ const rubyKeywords = new Set(["alias", "and", "begin", "break", "case", "class", "def", "defined?", "do", "else", "elsif", "end", "ensure", "false", "for", "if", "in", "module", "next", "nil", "not", "or", "redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless", "until", "when", "while", "yield"]);
237
+ const rubyBooleans = new Set(["true", "false"]);
238
+ const rubyNulls = new Set(["nil"]);
239
+ const goKeywords = new Set(["break", "case", "chan", "const", "continue", "default", "defer", "else", "fallthrough", "for", "func", "go", "goto", "if", "import", "interface", "map", "package", "range", "return", "select", "struct", "switch", "type", "var"]);
240
+ const goTypes = new Set(["any", "bool", "byte", "complex128", "complex64", "error", "float32", "float64", "int", "int16", "int32", "int64", "int8", "rune", "string", "uint", "uint16", "uint32", "uint64", "uint8", "uintptr"]);
241
+ const goBooleans = new Set(["true", "false"]);
242
+ const goNulls = new Set(["nil"]);
243
+ const javaKeywords = new Set(["abstract", "assert", "break", "case", "catch", "class", "const", "continue", "default", "do", "else", "enum", "extends", "final", "finally", "for", "if", "implements", "import", "instanceof", "interface", "native", "new", "package", "private", "protected", "public", "return", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "try", "volatile", "while"]);
244
+ const javaTypes = new Set(["Boolean", "Byte", "Character", "Double", "Float", "Integer", "Long", "Object", "Optional", "Short", "String", "Void", "boolean", "byte", "char", "double", "float", "int", "long", "short", "void"]);
245
+ const javaBooleans = new Set(["true", "false"]);
246
+ const javaNulls = new Set(["null"]);
247
+ const kotlinKeywords = new Set(["as", "break", "by", "catch", "class", "companion", "constructor", "continue", "data", "do", "else", "enum", "expect", "finally", "for", "fun", "if", "import", "in", "interface", "internal", "is", "object", "out", "override", "package", "private", "protected", "public", "return", "sealed", "suspend", "throw", "try", "typealias", "val", "var", "when", "where", "while"]);
248
+ const kotlinTypes = new Set(["Any", "Boolean", "Byte", "Char", "Double", "Float", "Int", "List", "Long", "Map", "Nothing", "Set", "Short", "String", "Unit"]);
249
+ const swiftKeywords = new Set(["actor", "as", "associatedtype", "async", "await", "break", "case", "catch", "class", "continue", "defer", "deinit", "do", "else", "enum", "extension", "fallthrough", "for", "func", "guard", "if", "import", "in", "init", "inout", "let", "nil", "operator", "private", "protocol", "public", "repeat", "return", "self", "Self", "static", "struct", "subscript", "super", "switch", "throw", "throws", "try", "typealias", "var", "where", "while"]);
250
+ const swiftTypes = new Set(["Any", "Array", "Bool", "Character", "Dictionary", "Double", "Float", "Int", "Optional", "Result", "Set", "String", "UInt", "Void"]);
251
+ const dartKeywords = new Set(["abstract", "as", "assert", "async", "await", "base", "break", "case", "catch", "class", "const", "continue", "covariant", "default", "deferred", "do", "else", "enum", "export", "extends", "extension", "external", "factory", "false", "final", "finally", "for", "function", "get", "hide", "if", "implements", "import", "in", "interface", "is", "late", "library", "mixin", "new", "null", "on", "operator", "part", "required", "return", "sealed", "set", "show", "static", "super", "switch", "sync", "this", "throw", "true", "try", "typedef", "var", "void", "when", "while", "with", "yield"]);
252
+ const dartTypes = new Set(["BigInt", "bool", "DateTime", "double", "Duration", "dynamic", "Future", "int", "Iterable", "List", "Map", "Never", "num", "Object", "Pattern", "Record", "Set", "Stream", "String", "Symbol", "Uri", "void"]);
253
+ const scalaKeywords = new Set(["abstract", "case", "catch", "class", "def", "do", "else", "enum", "export", "extends", "false", "final", "finally", "for", "forSome", "given", "if", "implicit", "import", "lazy", "macro", "match", "new", "null", "object", "override", "package", "private", "protected", "return", "sealed", "super", "then", "this", "throw", "trait", "true", "try", "type", "val", "var", "while", "with", "yield"]);
254
+ const scalaTypes = new Set(["Any", "Boolean", "Byte", "Char", "Double", "Either", "Float", "Int", "List", "Long", "Map", "None", "Option", "Seq", "Set", "Short", "Some", "String", "Unit"]);
255
+ const groovyKeywords = new Set(["abstract", "as", "assert", "break", "case", "catch", "class", "const", "continue", "def", "default", "do", "else", "enum", "extends", "false", "final", "finally", "for", "goto", "if", "implements", "import", "in", "instanceof", "interface", "new", "null", "package", "private", "protected", "public", "return", "static", "super", "switch", "this", "throw", "throws", "trait", "true", "try", "var", "void", "while"]);
256
+ const groovyTypes = new Set(["BigDecimal", "Boolean", "Closure", "Date", "Integer", "List", "Map", "Object", "String", "boolean", "def", "int", "long", "void"]);
257
+ const cKeywords = new Set(["auto", "break", "case", "const", "continue", "default", "do", "else", "enum", "extern", "for", "goto", "if", "inline", "register", "restrict", "return", "sizeof", "static", "struct", "switch", "typedef", "union", "volatile", "while"]);
258
+ const cTypes = new Set(["bool", "char", "double", "float", "int", "int16_t", "int32_t", "int64_t", "int8_t", "long", "short", "size_t", "uint16_t", "uint32_t", "uint64_t", "uint8_t", "void"]);
259
+ const cppKeywords = new Set([...cKeywords, "alignas", "alignof", "and", "bitand", "bitor", "catch", "class", "concept", "constexpr", "consteval", "constinit", "decltype", "delete", "explicit", "export", "friend", "mutable", "namespace", "new", "noexcept", "not", "operator", "or", "private", "protected", "public", "requires", "template", "this", "throw", "try", "typename", "using", "virtual", "xor"]);
260
+ const cppTypes = new Set([...cTypes, "auto", "bool", "char16_t", "char32_t", "std", "string", "wstring"]);
261
+ const cppBooleans = new Set(["true", "false"]);
262
+ const cppNulls = new Set(["nullptr", "NULL"]);
263
+ const csharpKeywords = new Set(["abstract", "as", "base", "break", "case", "catch", "checked", "class", "const", "continue", "default", "delegate", "do", "else", "enum", "event", "explicit", "extern", "finally", "fixed", "for", "foreach", "if", "implicit", "in", "interface", "internal", "is", "lock", "namespace", "new", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "record", "ref", "return", "sealed", "sizeof", "stackalloc", "static", "struct", "switch", "this", "throw", "try", "typeof", "unchecked", "unsafe", "using", "virtual", "void", "volatile", "while"]);
264
+ const csharpTypes = new Set(["bool", "byte", "char", "decimal", "double", "dynamic", "float", "int", "long", "nint", "nuint", "object", "sbyte", "short", "string", "uint", "ulong", "ushort", "var"]);
265
+ const objectiveCKeywords = new Set([...cKeywords, "@autoreleasepool", "@catch", "@class", "@dynamic", "@end", "@finally", "@implementation", "@import", "@interface", "@optional", "@package", "@private", "@property", "@protected", "@protocol", "@public", "@selector", "@synthesize", "@throw", "@try", "YES", "NO", "nil", "self", "super"]);
266
+ const objectiveCTypes = new Set([...cTypes, "BOOL", "Class", "CGFloat", "NSInteger", "NSObject", "NSString", "NSUInteger", "SEL", "id"]);
267
+ const rustKeywords = new Set(["as", "async", "await", "box", "break", "const", "continue", "crate", "dyn", "else", "enum", "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe", "use", "where", "while"]);
268
+ const rustTypes = new Set(["Box", "Option", "Result", "Some", "String", "Vec", "bool", "char", "f32", "f64", "i128", "i16", "i32", "i64", "i8", "isize", "str", "u128", "u16", "u32", "u64", "u8", "usize"]);
269
+ const rustBooleans = new Set(["true", "false"]);
270
+ const rustNulls = new Set(["None"]);
271
+ const phpKeywords = new Set(["abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "enum", "extends", "final", "finally", "fn", "for", "foreach", "function", "global", "if", "implements", "include", "instanceof", "interface", "isset", "match", "namespace", "new", "or", "private", "protected", "public", "readonly", "require", "return", "static", "switch", "throw", "trait", "try", "use", "var", "while", "xor", "yield"]);
272
+ const phpTypes = new Set(["array", "bool", "callable", "false", "float", "int", "iterable", "mixed", "never", "null", "object", "self", "static", "string", "true", "void"]);
273
+ const luaKeywords = new Set(["and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while"]);
274
+ const perlKeywords = new Set(["continue", "do", "else", "elsif", "for", "foreach", "given", "if", "last", "local", "my", "next", "our", "package", "redo", "require", "return", "state", "sub", "unless", "until", "use", "when", "while"]);
275
+ const rKeywords = new Set(["break", "else", "FALSE", "for", "function", "if", "Inf", "in", "NA", "NaN", "next", "NULL", "repeat", "return", "TRUE", "while"]);
276
+ const powershellKeywords = new Set(["begin", "break", "catch", "class", "continue", "data", "default", "do", "dynamicparam", "else", "elseif", "end", "enum", "exit", "filter", "finally", "for", "foreach", "from", "function", "if", "in", "param", "process", "return", "switch", "throw", "trap", "try", "until", "using", "var", "while"]);
277
+ const elixirKeywords = new Set(["after", "alias", "and", "case", "catch", "cond", "def", "defdelegate", "defexception", "defimpl", "defmacro", "defmodule", "defp", "defprotocol", "defstruct", "do", "else", "end", "false", "fn", "for", "if", "import", "in", "nil", "not", "or", "quote", "raise", "receive", "require", "rescue", "super", "throw", "true", "try", "unless", "unquote", "use", "when", "with"]);
278
+ const erlangKeywords = new Set(["after", "and", "andalso", "band", "begin", "bnot", "bor", "bsl", "bsr", "bxor", "case", "catch", "cond", "div", "end", "fun", "if", "let", "not", "of", "or", "orelse", "receive", "rem", "try", "when", "xor"]);
279
+ const haskellKeywords = new Set(["as", "case", "class", "data", "default", "deriving", "do", "else", "family", "forall", "foreign", "hiding", "if", "import", "in", "infix", "infixl", "infixr", "instance", "let", "module", "newtype", "of", "qualified", "then", "type", "where"]);
280
+ const clojureKeywords = new Set(["def", "defmacro", "defmethod", "defmulti", "defn", "defonce", "do", "doseq", "false", "fn", "for", "if", "let", "loop", "nil", "ns", "quote", "recur", "require", "true", "try", "when"]);
281
+ const fsharpKeywords = new Set(["abstract", "and", "as", "assert", "base", "begin", "class", "default", "delegate", "do", "done", "downcast", "downto", "elif", "else", "end", "exception", "extern", "false", "finally", "for", "fun", "function", "global", "if", "in", "inherit", "inline", "interface", "internal", "lazy", "let", "match", "member", "module", "mutable", "namespace", "new", "null", "of", "open", "or", "override", "private", "public", "rec", "return", "static", "struct", "then", "to", "true", "try", "type", "upcast", "use", "val", "void", "when", "while", "with", "yield"]);
282
+ const vbKeywords = new Set(["AddHandler", "And", "As", "Boolean", "ByRef", "Byte", "ByVal", "Call", "Case", "Catch", "Class", "Const", "Continue", "Date", "Decimal", "Dim", "Do", "Double", "Each", "Else", "ElseIf", "End", "Enum", "Erase", "Error", "Event", "Exit", "False", "Finally", "For", "Friend", "Function", "Get", "Global", "GoTo", "Handles", "If", "Implements", "Imports", "In", "Inherits", "Integer", "Interface", "Is", "Let", "Lib", "Like", "Long", "Loop", "Me", "Mod", "Module", "MustInherit", "MustOverride", "MyBase", "Namespace", "New", "Next", "Not", "Nothing", "Object", "Of", "On", "Option", "Or", "Overloads", "Overrides", "ParamArray", "Partial", "Private", "Property", "Protected", "Public", "RaiseEvent", "ReadOnly", "ReDim", "REM", "RemoveHandler", "Resume", "Return", "Select", "Set", "Shadows", "Shared", "Short", "Single", "Static", "Step", "Stop", "String", "Structure", "Sub", "SyncLock", "Then", "Throw", "To", "True", "Try", "Using", "Variant", "Wend", "When", "While", "With", "WithEvents", "WriteOnly"]);
283
+ const graphqlKeywords = new Set(["directive", "enum", "extend", "false", "fragment", "implements", "input", "interface", "mutation", "null", "on", "query", "repeatable", "scalar", "schema", "subscription", "true", "type", "union"]);
284
+ const protobufKeywords = new Set(["bool", "bytes", "double", "enum", "false", "fixed32", "fixed64", "float", "import", "int32", "int64", "map", "message", "oneof", "optional", "package", "proto2", "proto3", "public", "repeated", "reserved", "returns", "rpc", "service", "sfixed32", "sfixed64", "sint32", "sint64", "stream", "string", "syntax", "to", "true", "uint32", "uint64"]);
285
+ const hclKeywords = new Set(["and", "bool", "data", "dynamic", "false", "for", "if", "in", "locals", "module", "null", "number", "or", "output", "provider", "resource", "string", "terraform", "true", "variable"]);
286
+ const nginxKeywords = new Set(["access_log", "add_header", "deny", "error_log", "events", "fastcgi_pass", "gzip", "http", "include", "index", "listen", "location", "log_format", "proxy_pass", "return", "rewrite", "root", "server", "server_name", "try_files", "upstream"]);
287
+ const makefileKeywords = new Set(["define", "else", "endef", "endif", "export", "ifneq", "ifeq", "ifdef", "ifndef", "include", "override", "private", "sinclude", "undefine", "unexport", "vpath"]);
288
+ const cmakeKeywords = new Set(["add_compile_definitions", "add_custom_command", "add_custom_target", "add_executable", "add_library", "cmake_minimum_required", "else", "elseif", "endforeach", "endif", "endfunction", "endmacro", "find_package", "foreach", "function", "if", "include", "macro", "message", "option", "project", "return", "set", "target_compile_features", "target_include_directories", "target_link_libraries"]);
289
+ const lexicalSpecs = {
290
+ javascript: {
291
+ keywords: jsKeywords,
292
+ constants: jsConstants,
293
+ booleans: new Set(["true", "false"]),
294
+ nulls: new Set(["null"]),
295
+ lineComments: ["//"],
296
+ blockComments: cStyleBlockComments,
297
+ stringQuotes: ['"', "'"],
298
+ templateQuotes: true,
299
+ decorators: true
300
+ },
301
+ typescript: {
302
+ keywords: tsKeywords,
303
+ types: tsTypes,
304
+ constants: jsConstants,
305
+ booleans: new Set(["true", "false"]),
306
+ nulls: new Set(["null"]),
307
+ lineComments: ["//"],
308
+ blockComments: cStyleBlockComments,
309
+ stringQuotes: ['"', "'"],
310
+ templateQuotes: true,
311
+ decorators: true
312
+ },
313
+ shell: {
314
+ keywords: shellKeywords,
315
+ commands: shellCommands,
316
+ lineComments: ["#"],
317
+ stringQuotes: ['"', "'"],
318
+ variablePrefix: "$",
319
+ flags: true
320
+ },
321
+ python: {
322
+ keywords: pythonKeywords,
323
+ types: pythonTypes,
324
+ booleans: pythonBooleans,
325
+ nulls: pythonNulls,
326
+ lineComments: ["#"],
327
+ stringQuotes: ['"', "'"],
328
+ tripleStringQuotes: true,
329
+ decorators: true
330
+ },
331
+ sql: {
332
+ keywords: sqlKeywords,
333
+ booleans: new Set(["true", "false"]),
334
+ nulls: new Set(["null"]),
335
+ lineComments: ["--"],
336
+ blockComments: cStyleBlockComments,
337
+ stringQuotes: ['"', "'"],
338
+ caseInsensitive: true
339
+ },
340
+ ruby: {
341
+ keywords: rubyKeywords,
342
+ booleans: rubyBooleans,
343
+ nulls: rubyNulls,
344
+ lineComments: ["#"],
345
+ stringQuotes: ['"', "'"]
346
+ },
347
+ go: {
348
+ keywords: goKeywords,
349
+ types: goTypes,
350
+ booleans: goBooleans,
351
+ nulls: goNulls,
352
+ lineComments: ["//"],
353
+ blockComments: cStyleBlockComments,
354
+ stringQuotes: ['"', "'", "`"]
355
+ },
356
+ java: {
357
+ keywords: javaKeywords,
358
+ types: javaTypes,
359
+ booleans: javaBooleans,
360
+ nulls: javaNulls,
361
+ lineComments: ["//"],
362
+ blockComments: cStyleBlockComments,
363
+ stringQuotes: ['"', "'"],
364
+ decorators: true
365
+ },
366
+ kotlin: {
367
+ keywords: kotlinKeywords,
368
+ types: kotlinTypes,
369
+ booleans: javaBooleans,
370
+ nulls: javaNulls,
371
+ lineComments: ["//"],
372
+ blockComments: cStyleBlockComments,
373
+ stringQuotes: ['"', "'"],
374
+ templateQuotes: true,
375
+ decorators: true
376
+ },
377
+ swift: {
378
+ keywords: swiftKeywords,
379
+ types: swiftTypes,
380
+ booleans: cppBooleans,
381
+ nulls: new Set(["nil"]),
382
+ lineComments: ["//"],
383
+ blockComments: cStyleBlockComments,
384
+ stringQuotes: ['"', "'"],
385
+ decorators: true
386
+ },
387
+ dart: {
388
+ keywords: dartKeywords,
389
+ types: dartTypes,
390
+ booleans: javaBooleans,
391
+ nulls: javaNulls,
392
+ lineComments: ["//"],
393
+ blockComments: cStyleBlockComments,
394
+ stringQuotes: ['"', "'"],
395
+ decorators: true
396
+ },
397
+ scala: {
398
+ keywords: scalaKeywords,
399
+ types: scalaTypes,
400
+ booleans: javaBooleans,
401
+ nulls: javaNulls,
402
+ lineComments: ["//"],
403
+ blockComments: cStyleBlockComments,
404
+ stringQuotes: ['"', "'"],
405
+ decorators: true
406
+ },
407
+ groovy: {
408
+ keywords: groovyKeywords,
409
+ types: groovyTypes,
410
+ booleans: javaBooleans,
411
+ nulls: javaNulls,
412
+ lineComments: ["//"],
413
+ blockComments: cStyleBlockComments,
414
+ stringQuotes: ['"', "'"],
415
+ decorators: true
416
+ },
417
+ c: {
418
+ keywords: cKeywords,
419
+ types: cTypes,
420
+ booleans: cppBooleans,
421
+ nulls: cppNulls,
422
+ lineComments: ["//"],
423
+ blockComments: cStyleBlockComments,
424
+ stringQuotes: ['"', "'"]
425
+ },
426
+ cpp: {
427
+ keywords: cppKeywords,
428
+ types: cppTypes,
429
+ booleans: cppBooleans,
430
+ nulls: cppNulls,
431
+ lineComments: ["//"],
432
+ blockComments: cStyleBlockComments,
433
+ stringQuotes: ['"', "'"]
434
+ },
435
+ csharp: {
436
+ keywords: csharpKeywords,
437
+ types: csharpTypes,
438
+ booleans: cppBooleans,
439
+ nulls: javaNulls,
440
+ lineComments: ["//"],
441
+ blockComments: cStyleBlockComments,
442
+ stringQuotes: ['"', "'"],
443
+ decorators: true
444
+ },
445
+ objectivec: {
446
+ keywords: objectiveCKeywords,
447
+ types: objectiveCTypes,
448
+ booleans: new Set(["YES", "NO", "true", "false"]),
449
+ nulls: new Set(["nil", "NULL", "nullptr"]),
450
+ lineComments: ["//"],
451
+ blockComments: cStyleBlockComments,
452
+ stringQuotes: ['"', "'"],
453
+ decorators: true
454
+ },
455
+ rust: {
456
+ keywords: rustKeywords,
457
+ types: rustTypes,
458
+ booleans: rustBooleans,
459
+ nulls: rustNulls,
460
+ lineComments: ["//"],
461
+ blockComments: cStyleBlockComments,
462
+ stringQuotes: ['"', "'"],
463
+ rustAttributes: true
464
+ },
465
+ php: {
466
+ keywords: phpKeywords,
467
+ types: phpTypes,
468
+ booleans: new Set(["true", "false"]),
469
+ nulls: new Set(["null"]),
470
+ lineComments: ["//", "#"],
471
+ blockComments: cStyleBlockComments,
472
+ stringQuotes: ['"', "'"],
473
+ variablePrefix: "$"
474
+ },
475
+ lua: {
476
+ keywords: luaKeywords,
477
+ booleans: new Set(["true", "false"]),
478
+ nulls: new Set(["nil"]),
479
+ lineComments: ["--"],
480
+ stringQuotes: ['"', "'"]
481
+ },
482
+ perl: {
483
+ keywords: perlKeywords,
484
+ booleans: new Set(["true", "false"]),
485
+ nulls: new Set(["undef"]),
486
+ lineComments: ["#"],
487
+ stringQuotes: ['"', "'"],
488
+ variablePrefix: "$"
489
+ },
490
+ r: {
491
+ keywords: rKeywords,
492
+ booleans: new Set(["TRUE", "FALSE", "T", "F"]),
493
+ nulls: new Set(["NULL", "NA", "NaN"]),
494
+ lineComments: ["#"],
495
+ stringQuotes: ['"', "'"]
496
+ },
497
+ powershell: {
498
+ keywords: powershellKeywords,
499
+ booleans: new Set(["$true", "$false", "true", "false"]),
500
+ nulls: new Set(["$null", "null"]),
501
+ commands: new Set(["Get-ChildItem", "Get-Content", "Invoke-Run", "Join-Path", "New-Item", "Remove-Item", "Set-Content", "Test-Path", "Write-Host", "Write-Output"]),
502
+ lineComments: ["#"],
503
+ blockComments: [{ start: "<#", end: "#>" }],
504
+ stringQuotes: ['"', "'"],
505
+ variablePrefix: "$",
506
+ flags: true
507
+ },
508
+ elixir: {
509
+ keywords: elixirKeywords,
510
+ booleans: new Set(["true", "false"]),
511
+ nulls: new Set(["nil"]),
512
+ lineComments: ["#"],
513
+ stringQuotes: ['"', "'"]
514
+ },
515
+ erlang: {
516
+ keywords: erlangKeywords,
517
+ booleans: new Set(["true", "false"]),
518
+ lineComments: ["%"],
519
+ stringQuotes: ['"', "'"]
520
+ },
521
+ haskell: {
522
+ keywords: haskellKeywords,
523
+ types: new Set(["Bool", "Char", "Double", "Either", "False", "Float", "IO", "Int", "Integer", "Maybe", "Nothing", "String", "True"]),
524
+ booleans: new Set(["True", "False"]),
525
+ nulls: new Set(["Nothing"]),
526
+ lineComments: ["--"],
527
+ blockComments: [{ start: "{-", end: "-}" }],
528
+ stringQuotes: ['"', "'"]
529
+ },
530
+ clojure: {
531
+ keywords: clojureKeywords,
532
+ booleans: new Set(["true", "false"]),
533
+ nulls: new Set(["nil"]),
534
+ lineComments: [";"],
535
+ stringQuotes: ['"']
536
+ },
537
+ fsharp: {
538
+ keywords: fsharpKeywords,
539
+ types: new Set(["Async", "bool", "decimal", "float", "int", "list", "Map", "option", "Result", "seq", "string", "unit"]),
540
+ booleans: new Set(["true", "false"]),
541
+ nulls: new Set(["null", "None"]),
542
+ lineComments: ["//"],
543
+ blockComments: [{ start: "(*", end: "*)" }],
544
+ stringQuotes: ['"', "'"],
545
+ decorators: true
546
+ },
547
+ vb: {
548
+ keywords: vbKeywords,
549
+ types: new Set(["Boolean", "Byte", "Date", "Decimal", "Double", "Integer", "Long", "Object", "Short", "Single", "String"]),
550
+ booleans: new Set(["True", "False"]),
551
+ nulls: new Set(["Nothing", "Null"]),
552
+ lineComments: ["'"],
553
+ stringQuotes: ['"'],
554
+ caseInsensitive: true
555
+ },
556
+ graphql: {
557
+ keywords: graphqlKeywords,
558
+ booleans: javaBooleans,
559
+ nulls: javaNulls,
560
+ lineComments: ["#"],
561
+ stringQuotes: ['"']
562
+ },
563
+ protobuf: {
564
+ keywords: protobufKeywords,
565
+ types: new Set(["Any", "Duration", "Timestamp"]),
566
+ booleans: javaBooleans,
567
+ nulls: javaNulls,
568
+ lineComments: ["//"],
569
+ blockComments: cStyleBlockComments,
570
+ stringQuotes: ['"', "'"]
571
+ },
572
+ hcl: {
573
+ keywords: hclKeywords,
574
+ booleans: javaBooleans,
575
+ nulls: javaNulls,
576
+ lineComments: ["#", "//"],
577
+ blockComments: cStyleBlockComments,
578
+ stringQuotes: ['"', "'"]
579
+ },
580
+ nginx: {
581
+ keywords: nginxKeywords,
582
+ lineComments: ["#"],
583
+ stringQuotes: ['"', "'"]
584
+ },
585
+ makefile: {
586
+ keywords: makefileKeywords,
587
+ commands: shellCommands,
588
+ lineComments: ["#"],
589
+ stringQuotes: ['"', "'"],
590
+ variablePrefix: "$",
591
+ flags: true
592
+ },
593
+ cmake: {
594
+ keywords: cmakeKeywords,
595
+ booleans: new Set(["ON", "OFF", "TRUE", "FALSE"]),
596
+ nulls: new Set(["NOTFOUND"]),
597
+ lineComments: ["#"],
598
+ stringQuotes: ['"', "'"],
599
+ caseInsensitive: true
600
+ }
601
+ };
602
+ const tokenizers = {
603
+ lexical: tokenizeLexical,
604
+ data: tokenizeData,
605
+ style: tokenizeStyle,
606
+ line: tokenizeLine,
607
+ markup: tokenizeMarkup
608
+ };
609
+ export function highlightCodeBlock(node) {
610
+ if (node.tokens !== undefined) {
611
+ return node.tokens;
612
+ }
613
+ const language = resolveCodeLanguage(node.lang);
614
+ if (language === undefined ||
615
+ language.plain === true ||
616
+ language.family === undefined ||
617
+ node.value.length === 0) {
618
+ return undefined;
619
+ }
620
+ const tokenize = tokenizers[language.family];
621
+ const tokens = tokenize(node.value, language);
622
+ return tokens.some((token) => token.kind !== "plain") ? tokens : undefined;
623
+ }
624
+ function resolveCodeLanguage(lang) {
625
+ if (lang === undefined || lang.length === 0) {
626
+ return undefined;
627
+ }
628
+ return languageByAlias.get(lang.toLowerCase());
629
+ }
630
+ function tokenizeLexical(source, language) {
631
+ const spec = lexicalSpecs[language.spec ?? ""];
632
+ if (spec === undefined) {
633
+ return [{ kind: "plain", value: source }];
634
+ }
635
+ const emitter = createEmitter(source);
636
+ let index = 0;
637
+ while (index < source.length) {
638
+ const start = index;
639
+ const char = source[index];
640
+ index = readWhitespace(source, index);
641
+ if (index > start) {
642
+ emitter.pushPlain(start, index);
643
+ continue;
644
+ }
645
+ const lineCommentEnd = readAnyLineComment(source, index, spec.lineComments ?? []);
646
+ if (lineCommentEnd > index) {
647
+ emitter.push("comment", index, lineCommentEnd);
648
+ index = lineCommentEnd;
649
+ continue;
650
+ }
651
+ const blockCommentEnd = readAnyBlockComment(source, index, spec.blockComments ?? []);
652
+ if (blockCommentEnd > index) {
653
+ emitter.push("comment", index, blockCommentEnd);
654
+ index = blockCommentEnd;
655
+ continue;
656
+ }
657
+ if (spec.rustAttributes === true && source.startsWith("#[", index)) {
658
+ index = readUntil(source, index + 2, "]");
659
+ emitter.push("decorator", start, index);
660
+ continue;
661
+ }
662
+ if (spec.decorators === true && char === "@" && isIdentifierStart(source[index + 1] ?? "")) {
663
+ index = readIdentifier(source, index + 1);
664
+ emitter.push("decorator", start, index);
665
+ continue;
666
+ }
667
+ if (spec.variablePrefix === "$" && char === "$" && isIdentifierStart(source[index + 1] ?? "")) {
668
+ index = readIdentifier(source, index + 1);
669
+ const variableKind = classifyLexicalWord(source.slice(start, index), spec);
670
+ emitter.push(variableKind === "plain" ? "variable" : variableKind, start, index);
671
+ continue;
672
+ }
673
+ const commandEnd = readCommandIdentifier(source, index);
674
+ if (commandEnd > index) {
675
+ const commandKind = classifyLexicalWord(source.slice(start, commandEnd), spec);
676
+ if (commandKind === "command") {
677
+ emitter.push("command", start, commandEnd);
678
+ index = commandEnd;
679
+ continue;
680
+ }
681
+ }
682
+ if (spec.flags === true && char === "-" && isFlagStart(source[index + 1] ?? "")) {
683
+ index = readFlag(source, index + 1);
684
+ emitter.push("flag", start, index);
685
+ continue;
686
+ }
687
+ if (spec.tripleStringQuotes === true &&
688
+ (char === '"' || char === "'") &&
689
+ source.startsWith(char.repeat(3), index)) {
690
+ index = readTripleQuotedString(source, index, char);
691
+ emitter.push("string", start, index);
692
+ continue;
693
+ }
694
+ if ((spec.stringQuotes ?? []).includes(char)) {
695
+ index = readQuotedString(source, index, char);
696
+ emitter.push("string", start, index);
697
+ continue;
698
+ }
699
+ if (spec.templateQuotes === true && char === "`") {
700
+ index = readQuotedString(source, index, "`");
701
+ emitter.push("template", start, index);
702
+ continue;
703
+ }
704
+ index = readNumber(source, index);
705
+ if (index > start) {
706
+ emitter.push("number", start, index);
707
+ continue;
708
+ }
709
+ index = readIdentifier(source, index);
710
+ if (index > start) {
711
+ emitter.push(classifyLexicalWord(source.slice(start, index), spec), start, index);
712
+ continue;
713
+ }
714
+ emitter.pushPlain(start, start + 1);
715
+ index = start + 1;
716
+ }
717
+ return emitter.tokens;
718
+ }
719
+ function tokenizeData(source, language) {
720
+ if (language.spec === "toml" || language.spec === "ini") {
721
+ return tokenizeConfig(source);
722
+ }
723
+ return language.spec === "yaml" ? tokenizeYaml(source) : tokenizeJsonLike(source, language.spec === "jsonc");
724
+ }
725
+ function tokenizeJsonLike(source, allowComments) {
726
+ const emitter = createEmitter(source);
727
+ let index = 0;
728
+ while (index < source.length) {
729
+ const start = index;
730
+ index = readWhitespace(source, index);
731
+ if (index > start) {
732
+ emitter.pushPlain(start, index);
733
+ continue;
734
+ }
735
+ if (allowComments) {
736
+ const lineCommentEnd = readAnyLineComment(source, index, ["//"]);
737
+ if (lineCommentEnd > index) {
738
+ emitter.push("comment", index, lineCommentEnd);
739
+ index = lineCommentEnd;
740
+ continue;
741
+ }
742
+ const blockCommentEnd = readAnyBlockComment(source, index, cStyleBlockComments);
743
+ if (blockCommentEnd > index) {
744
+ emitter.push("comment", index, blockCommentEnd);
745
+ index = blockCommentEnd;
746
+ continue;
747
+ }
748
+ }
749
+ if (source[index] === '"') {
750
+ index = readQuotedString(source, index, '"');
751
+ emitter.push(isJsonKey(source, index) ? "key" : "string", start, index);
752
+ continue;
753
+ }
754
+ index = readNumber(source, index);
755
+ if (index > start) {
756
+ emitter.push("number", start, index);
757
+ continue;
758
+ }
759
+ index = readIdentifier(source, index);
760
+ if (index > start) {
761
+ emitter.push(classifyDataWord(source.slice(start, index)), start, index);
762
+ continue;
763
+ }
764
+ emitter.pushPlain(start, start + 1);
765
+ index = start + 1;
766
+ }
767
+ return emitter.tokens;
768
+ }
769
+ function tokenizeYaml(source) {
770
+ const emitter = createEmitter(source);
771
+ let index = 0;
772
+ let atLineStart = true;
773
+ while (index < source.length) {
774
+ const start = index;
775
+ if (source[index] === "\n") {
776
+ emitter.pushPlain(index, index + 1);
777
+ index += 1;
778
+ atLineStart = true;
779
+ continue;
780
+ }
781
+ const whitespaceEnd = readSpacesAndTabs(source, index);
782
+ if (whitespaceEnd > index) {
783
+ emitter.pushPlain(index, whitespaceEnd);
784
+ index = whitespaceEnd;
785
+ continue;
786
+ }
787
+ if (source[index] === "#") {
788
+ index = readUntilLineEnd(source, index);
789
+ emitter.push("comment", start, index);
790
+ atLineStart = false;
791
+ continue;
792
+ }
793
+ if (source[index] === '"' || source[index] === "'") {
794
+ const quote = source[index];
795
+ index = readQuotedString(source, index, quote);
796
+ emitter.push("string", start, index);
797
+ atLineStart = false;
798
+ continue;
799
+ }
800
+ if (atLineStart) {
801
+ const keyEnd = readYamlKey(source, index);
802
+ if (keyEnd > index) {
803
+ emitter.push("key", index, keyEnd);
804
+ index = keyEnd;
805
+ atLineStart = false;
806
+ continue;
807
+ }
808
+ }
809
+ index = readNumber(source, index);
810
+ if (index > start) {
811
+ emitter.push("number", start, index);
812
+ atLineStart = false;
813
+ continue;
814
+ }
815
+ index = readIdentifier(source, index);
816
+ if (index > start) {
817
+ emitter.push(classifyDataWord(source.slice(start, index)), start, index);
818
+ atLineStart = false;
819
+ continue;
820
+ }
821
+ emitter.pushPlain(start, start + 1);
822
+ index = start + 1;
823
+ atLineStart = false;
824
+ }
825
+ return emitter.tokens;
826
+ }
827
+ function tokenizeStyle(source) {
828
+ const emitter = createEmitter(source);
829
+ let index = 0;
830
+ while (index < source.length) {
831
+ const start = index;
832
+ index = readWhitespace(source, index);
833
+ if (index > start) {
834
+ emitter.pushPlain(start, index);
835
+ continue;
836
+ }
837
+ const blockCommentEnd = readAnyBlockComment(source, index, cStyleBlockComments);
838
+ if (blockCommentEnd > index) {
839
+ emitter.push("comment", index, blockCommentEnd);
840
+ index = blockCommentEnd;
841
+ continue;
842
+ }
843
+ if (source[index] === "@") {
844
+ index = readCssName(source, index + 1);
845
+ if (index > start + 1) {
846
+ emitter.push("at-rule", start, index);
847
+ continue;
848
+ }
849
+ }
850
+ if (source[index] === "#" && isHex(source[index + 1] ?? "")) {
851
+ index = readCssColor(source, index + 1);
852
+ emitter.push("color", start, index);
853
+ continue;
854
+ }
855
+ if (source.startsWith("!important", index)) {
856
+ index += "!important".length;
857
+ emitter.push("important", start, index);
858
+ continue;
859
+ }
860
+ if (source[index] === '"' || source[index] === "'") {
861
+ const quote = source[index];
862
+ index = readQuotedString(source, index, quote);
863
+ emitter.push("string", start, index);
864
+ continue;
865
+ }
866
+ index = readNumber(source, index);
867
+ if (index > start) {
868
+ emitter.push("number", start, index);
869
+ continue;
870
+ }
871
+ index = readCssName(source, index);
872
+ if (index > start) {
873
+ emitter.push(isCssProperty(source, index) ? "property" : "selector", start, index);
874
+ continue;
875
+ }
876
+ emitter.pushPlain(start, start + 1);
877
+ index = start + 1;
878
+ }
879
+ return emitter.tokens;
880
+ }
881
+ function tokenizeConfig(source) {
882
+ const emitter = createEmitter(source);
883
+ let index = 0;
884
+ let atLineStart = true;
885
+ while (index < source.length) {
886
+ const start = index;
887
+ if (source[index] === "\n") {
888
+ emitter.pushPlain(index, index + 1);
889
+ index += 1;
890
+ atLineStart = true;
891
+ continue;
892
+ }
893
+ index = readSpacesAndTabs(source, index);
894
+ if (index > start) {
895
+ emitter.pushPlain(start, index);
896
+ continue;
897
+ }
898
+ if (source[index] === "#" || source[index] === ";") {
899
+ index = readUntilLineEnd(source, index);
900
+ emitter.push("comment", start, index);
901
+ atLineStart = false;
902
+ continue;
903
+ }
904
+ if (atLineStart && source[index] === "[") {
905
+ index = readUntil(source, index + 1, "]");
906
+ emitter.push("selector", start, index);
907
+ atLineStart = false;
908
+ continue;
909
+ }
910
+ if (atLineStart) {
911
+ const keyEnd = readConfigKey(source, index);
912
+ if (keyEnd > index) {
913
+ emitter.push("key", index, keyEnd);
914
+ index = keyEnd;
915
+ atLineStart = false;
916
+ continue;
917
+ }
918
+ }
919
+ if (source[index] === '"' || source[index] === "'") {
920
+ const quote = source[index];
921
+ index = readQuotedString(source, index, quote);
922
+ emitter.push("string", start, index);
923
+ atLineStart = false;
924
+ continue;
925
+ }
926
+ index = readNumber(source, index);
927
+ if (index > start) {
928
+ emitter.push("number", start, index);
929
+ atLineStart = false;
930
+ continue;
931
+ }
932
+ index = readIdentifier(source, index);
933
+ if (index > start) {
934
+ emitter.push(classifyDataWord(source.slice(start, index)), start, index);
935
+ atLineStart = false;
936
+ continue;
937
+ }
938
+ emitter.pushPlain(start, start + 1);
939
+ index = start + 1;
940
+ atLineStart = false;
941
+ }
942
+ return emitter.tokens;
943
+ }
944
+ function tokenizeLine(source, language) {
945
+ const emitter = createEmitter(source);
946
+ let index = 0;
947
+ let atLineStart = true;
948
+ while (index < source.length) {
949
+ const start = index;
950
+ if (source[index] === "\n") {
951
+ emitter.pushPlain(index, index + 1);
952
+ index += 1;
953
+ atLineStart = true;
954
+ continue;
955
+ }
956
+ if (atLineStart && language.spec === "diff" && (source[index] === "+" || source[index] === "-")) {
957
+ index = readUntilLineEnd(source, index);
958
+ emitter.push(source[start] === "+" ? "string" : "important", start, index);
959
+ atLineStart = false;
960
+ continue;
961
+ }
962
+ if (atLineStart && language.spec === "markdown" && source[index] === "#") {
963
+ index = readUntilLineEnd(source, index);
964
+ emitter.push("keyword", start, index);
965
+ atLineStart = false;
966
+ continue;
967
+ }
968
+ if (atLineStart && language.spec === "dockerfile") {
969
+ const directiveEnd = readIdentifier(source, index);
970
+ if (directiveEnd > index) {
971
+ emitter.push("directive", index, directiveEnd);
972
+ index = directiveEnd;
973
+ atLineStart = false;
974
+ continue;
975
+ }
976
+ }
977
+ if (source[index] === "#" && language.spec !== "diff") {
978
+ index = readUntilLineEnd(source, index);
979
+ emitter.push("comment", start, index);
980
+ atLineStart = false;
981
+ continue;
982
+ }
983
+ if (source[index] === '"' || source[index] === "'") {
984
+ const quote = source[index];
985
+ index = readQuotedString(source, index, quote);
986
+ emitter.push("string", start, index);
987
+ atLineStart = false;
988
+ continue;
989
+ }
990
+ index = readNumber(source, index);
991
+ if (index > start) {
992
+ emitter.push("number", start, index);
993
+ atLineStart = false;
994
+ continue;
995
+ }
996
+ emitter.pushPlain(start, start + 1);
997
+ index = start + 1;
998
+ atLineStart = false;
999
+ }
1000
+ return emitter.tokens;
1001
+ }
1002
+ function tokenizeMarkup(source) {
1003
+ const emitter = createEmitter(source);
1004
+ let index = 0;
1005
+ while (index < source.length) {
1006
+ const start = index;
1007
+ if (source.startsWith("<!--", index)) {
1008
+ index = readUntil(source, index + 4, "-->");
1009
+ emitter.push("comment", start, index);
1010
+ continue;
1011
+ }
1012
+ if (source[index] === "<") {
1013
+ emitter.push("punctuation", index, index + 1);
1014
+ index += 1;
1015
+ if (source[index] === "/") {
1016
+ emitter.push("punctuation", index, index + 1);
1017
+ index += 1;
1018
+ }
1019
+ const tagStart = index;
1020
+ index = readIdentifier(source, index);
1021
+ if (index > tagStart) {
1022
+ emitter.push("tag", tagStart, index);
1023
+ }
1024
+ while (index < source.length && source[index] !== ">") {
1025
+ const innerStart = index;
1026
+ index = readWhitespace(source, index);
1027
+ if (index > innerStart) {
1028
+ emitter.pushPlain(innerStart, index);
1029
+ continue;
1030
+ }
1031
+ if (source[index] === '"' || source[index] === "'") {
1032
+ const quote = source[index];
1033
+ index = readQuotedString(source, index, quote);
1034
+ emitter.push("string", innerStart, index);
1035
+ continue;
1036
+ }
1037
+ index = readIdentifier(source, index);
1038
+ if (index > innerStart) {
1039
+ emitter.push("attribute", innerStart, index);
1040
+ continue;
1041
+ }
1042
+ emitter.push("punctuation", innerStart, innerStart + 1);
1043
+ index = innerStart + 1;
1044
+ }
1045
+ if (source[index] === ">") {
1046
+ emitter.push("punctuation", index, index + 1);
1047
+ index += 1;
1048
+ }
1049
+ continue;
1050
+ }
1051
+ emitter.pushPlain(start, start + 1);
1052
+ index = start + 1;
1053
+ }
1054
+ return emitter.tokens;
1055
+ }
1056
+ function createEmitter(source) {
1057
+ const tokens = [];
1058
+ return {
1059
+ tokens,
1060
+ push(kind, start, end) {
1061
+ pushToken(tokens, source, kind, start, end);
1062
+ },
1063
+ pushPlain(start, end) {
1064
+ pushToken(tokens, source, "plain", start, end);
1065
+ }
1066
+ };
1067
+ }
1068
+ function pushToken(tokens, source, kind, start, end) {
1069
+ if (end <= start) {
1070
+ return;
1071
+ }
1072
+ const value = source.slice(start, end);
1073
+ const previous = tokens[tokens.length - 1];
1074
+ if (previous?.kind === kind) {
1075
+ previous.value += value;
1076
+ return;
1077
+ }
1078
+ tokens.push({ kind, value });
1079
+ }
1080
+ function classifyLexicalWord(word, spec) {
1081
+ const lookup = spec.caseInsensitive === true ? word.toLowerCase() : word;
1082
+ if (spec.booleans?.has(lookup) === true || spec.booleans?.has(word) === true) {
1083
+ return "boolean";
1084
+ }
1085
+ if (spec.nulls?.has(lookup) === true || spec.nulls?.has(word) === true) {
1086
+ return "null";
1087
+ }
1088
+ if (spec.keywords?.has(lookup) === true || spec.keywords?.has(word) === true) {
1089
+ return "keyword";
1090
+ }
1091
+ if (spec.types?.has(lookup) === true || spec.types?.has(word) === true) {
1092
+ return "type";
1093
+ }
1094
+ if (spec.commands?.has(lookup) === true || spec.commands?.has(word) === true) {
1095
+ return "command";
1096
+ }
1097
+ if (spec.constants?.has(lookup) === true || spec.constants?.has(word) === true) {
1098
+ return "number";
1099
+ }
1100
+ return "plain";
1101
+ }
1102
+ function classifyDataWord(word) {
1103
+ switch (word) {
1104
+ case "true":
1105
+ case "false":
1106
+ return "boolean";
1107
+ case "null":
1108
+ case "Null":
1109
+ case "NULL":
1110
+ case "~":
1111
+ return "null";
1112
+ default:
1113
+ return "plain";
1114
+ }
1115
+ }
1116
+ function readWhitespace(source, index) {
1117
+ while (index < source.length && isWhitespace(source[index])) {
1118
+ index += 1;
1119
+ }
1120
+ return index;
1121
+ }
1122
+ function readSpacesAndTabs(source, index) {
1123
+ while (index < source.length && (source[index] === " " || source[index] === "\t")) {
1124
+ index += 1;
1125
+ }
1126
+ return index;
1127
+ }
1128
+ function readIdentifier(source, index) {
1129
+ if (!isIdentifierStart(source[index] ?? "")) {
1130
+ return index;
1131
+ }
1132
+ index += 1;
1133
+ while (index < source.length && isIdentifierPart(source[index])) {
1134
+ index += 1;
1135
+ }
1136
+ return index;
1137
+ }
1138
+ function readCommandIdentifier(source, index) {
1139
+ if (!isIdentifierStart(source[index] ?? "")) {
1140
+ return index;
1141
+ }
1142
+ index += 1;
1143
+ while (index < source.length && (isIdentifierPart(source[index]) || source[index] === "-")) {
1144
+ index += 1;
1145
+ }
1146
+ return index;
1147
+ }
1148
+ function readCssName(source, index) {
1149
+ if (!isCssNameStart(source[index] ?? "")) {
1150
+ return index;
1151
+ }
1152
+ index += 1;
1153
+ while (index < source.length && isCssNamePart(source[index])) {
1154
+ index += 1;
1155
+ }
1156
+ return index;
1157
+ }
1158
+ function readNumber(source, index) {
1159
+ const start = index;
1160
+ if (source[index] === "-") {
1161
+ index += 1;
1162
+ }
1163
+ let hasDigit = false;
1164
+ while (index < source.length && isDigit(source[index])) {
1165
+ index += 1;
1166
+ hasDigit = true;
1167
+ }
1168
+ if (source[index] === "." && isDigit(source[index + 1] ?? "")) {
1169
+ index += 1;
1170
+ while (index < source.length && isDigit(source[index])) {
1171
+ index += 1;
1172
+ hasDigit = true;
1173
+ }
1174
+ }
1175
+ if (!hasDigit) {
1176
+ return start;
1177
+ }
1178
+ if ((source[index] === "e" || source[index] === "E") && isExponentStart(source[index + 1] ?? "")) {
1179
+ const exponentStart = index;
1180
+ index += 1;
1181
+ if (source[index] === "+" || source[index] === "-") {
1182
+ index += 1;
1183
+ }
1184
+ const digitsStart = index;
1185
+ while (index < source.length && isDigit(source[index])) {
1186
+ index += 1;
1187
+ }
1188
+ if (index === digitsStart) {
1189
+ return exponentStart;
1190
+ }
1191
+ }
1192
+ return index;
1193
+ }
1194
+ function readQuotedString(source, index, quote) {
1195
+ index += 1;
1196
+ while (index < source.length) {
1197
+ const char = source[index];
1198
+ index += 1;
1199
+ if (char === "\\") {
1200
+ index = Math.min(source.length, index + 1);
1201
+ continue;
1202
+ }
1203
+ if (char === quote) {
1204
+ return index;
1205
+ }
1206
+ }
1207
+ return index;
1208
+ }
1209
+ function readTripleQuotedString(source, index, quote) {
1210
+ const marker = quote.repeat(3);
1211
+ index += marker.length;
1212
+ while (index < source.length) {
1213
+ if (source.startsWith(marker, index)) {
1214
+ return index + marker.length;
1215
+ }
1216
+ if (source[index] === "\\") {
1217
+ index = Math.min(source.length, index + 2);
1218
+ continue;
1219
+ }
1220
+ index += 1;
1221
+ }
1222
+ return index;
1223
+ }
1224
+ function readAnyLineComment(source, index, markers) {
1225
+ for (const marker of markers) {
1226
+ if (source.startsWith(marker, index)) {
1227
+ return readUntilLineEnd(source, index);
1228
+ }
1229
+ }
1230
+ return index;
1231
+ }
1232
+ function readAnyBlockComment(source, index, delimiters) {
1233
+ for (const delimiter of delimiters) {
1234
+ if (source.startsWith(delimiter.start, index)) {
1235
+ return readDelimitedBlock(source, index + delimiter.start.length, delimiter.end);
1236
+ }
1237
+ }
1238
+ return index;
1239
+ }
1240
+ function readDelimitedBlock(source, index, endMarker) {
1241
+ while (index < source.length) {
1242
+ if (source.startsWith(endMarker, index)) {
1243
+ return index + endMarker.length;
1244
+ }
1245
+ index += 1;
1246
+ }
1247
+ return source.length;
1248
+ }
1249
+ function readUntilLineEnd(source, index) {
1250
+ while (index < source.length && source[index] !== "\n") {
1251
+ index += 1;
1252
+ }
1253
+ return index;
1254
+ }
1255
+ function readUntil(source, index, marker) {
1256
+ while (index < source.length) {
1257
+ if (source.startsWith(marker, index)) {
1258
+ return index + marker.length;
1259
+ }
1260
+ index += 1;
1261
+ }
1262
+ return index;
1263
+ }
1264
+ function readYamlKey(source, index) {
1265
+ const start = index;
1266
+ while (index < source.length) {
1267
+ const char = source[index];
1268
+ if (char === ":") {
1269
+ return index > start ? index : start;
1270
+ }
1271
+ if (char === "\n" || char === "#" || char === "{" || char === "}" || char === "[" || char === "]") {
1272
+ return start;
1273
+ }
1274
+ index += 1;
1275
+ }
1276
+ return start;
1277
+ }
1278
+ function readConfigKey(source, index) {
1279
+ const start = index;
1280
+ while (index < source.length) {
1281
+ const char = source[index];
1282
+ if (char === "=" || char === ":") {
1283
+ return trimRightIndex(source, start, index);
1284
+ }
1285
+ if (char === "\n" || char === "#" || char === ";") {
1286
+ return start;
1287
+ }
1288
+ index += 1;
1289
+ }
1290
+ return start;
1291
+ }
1292
+ function readFlag(source, index) {
1293
+ while (index < source.length && isFlagPart(source[index])) {
1294
+ index += 1;
1295
+ }
1296
+ return index;
1297
+ }
1298
+ function trimRightIndex(source, start, end) {
1299
+ while (end > start && (source[end - 1] === " " || source[end - 1] === "\t")) {
1300
+ end -= 1;
1301
+ }
1302
+ return end;
1303
+ }
1304
+ function readCssColor(source, index) {
1305
+ let count = 0;
1306
+ while (index < source.length && isHex(source[index]) && count < 8) {
1307
+ index += 1;
1308
+ count += 1;
1309
+ }
1310
+ return index;
1311
+ }
1312
+ function isJsonKey(source, index) {
1313
+ index = readWhitespace(source, index);
1314
+ return source[index] === ":";
1315
+ }
1316
+ function isCssProperty(source, index) {
1317
+ index = readWhitespace(source, index);
1318
+ return source[index] === ":";
1319
+ }
1320
+ function isWhitespace(char) {
1321
+ return char === " " || char === "\n" || char === "\r" || char === "\t";
1322
+ }
1323
+ function isIdentifierStart(char) {
1324
+ return isAlpha(char) || char === "_" || char === "$";
1325
+ }
1326
+ function isIdentifierPart(char) {
1327
+ return isIdentifierStart(char) || isDigit(char);
1328
+ }
1329
+ function isCssNameStart(char) {
1330
+ return isAlpha(char) || char === "_" || char === "-" || char === ".";
1331
+ }
1332
+ function isCssNamePart(char) {
1333
+ return isCssNameStart(char) || isDigit(char);
1334
+ }
1335
+ function isFlagStart(char) {
1336
+ return isAlpha(char) || char === "-";
1337
+ }
1338
+ function isFlagPart(char) {
1339
+ return isAlpha(char) || isDigit(char) || char === "-";
1340
+ }
1341
+ function isExponentStart(char) {
1342
+ return isDigit(char) || char === "+" || char === "-";
1343
+ }
1344
+ function isAlpha(char) {
1345
+ const code = char.charCodeAt(0);
1346
+ return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
1347
+ }
1348
+ function isDigit(char) {
1349
+ const code = char.charCodeAt(0);
1350
+ return code >= 48 && code <= 57;
1351
+ }
1352
+ function isHex(char) {
1353
+ const code = char.charCodeAt(0);
1354
+ return ((code >= 48 && code <= 57) ||
1355
+ (code >= 65 && code <= 70) ||
1356
+ (code >= 97 && code <= 102));
1357
+ }