@aleph-alpha/chat-kit 5.13.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/{CkHistory.vue_vue_type_script_setup_true_lang-BNcJURkq.js → CkHistory.vue_vue_type_script_setup_true_lang-Cr8vF94e.js} +221 -115
  2. package/dist/adapters/responses-api.d.ts +1 -1
  3. package/dist/adapters/responses-api.d.ts.map +1 -1
  4. package/dist/adapters/responses-api.js +9 -7
  5. package/dist/apl-fqmucPXA.js +140 -0
  6. package/dist/asciiarmor-DucZyvP0.js +56 -0
  7. package/dist/asn1-BnOEsgAm.js +144 -0
  8. package/dist/asterisk-QAlztEwS.js +345 -0
  9. package/dist/brainfuck-DZVCuF_t.js +53 -0
  10. package/dist/chat-kit.css +1177 -12
  11. package/dist/clike-CTYGlS6x.js +799 -0
  12. package/dist/clojure-BhXMqnxz.js +849 -0
  13. package/dist/cmake-BGaNd9E7.js +71 -0
  14. package/dist/cobol-4yqQntpt.js +120 -0
  15. package/dist/coffeescript-D2dXvhEc.js +308 -0
  16. package/dist/commonlisp-CF_VNHQR.js +130 -0
  17. package/dist/components/base/CkHistoryItem/CkHistoryItem.vue.d.ts.map +1 -1
  18. package/dist/components/base/CkHistoryWrapper/CkHistoryWrapper.vue.d.ts.map +1 -1
  19. package/dist/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.d.ts.map +1 -1
  20. package/dist/components/base/CkMilkdownEditor/CkMilkdownEditor.stories.d.ts +41 -0
  21. package/dist/components/base/CkMilkdownEditor/CkMilkdownEditor.stories.d.ts.map +1 -0
  22. package/dist/components/base/CkMilkdownEditor/CkMilkdownEditor.vue.d.ts +26 -0
  23. package/dist/components/base/CkMilkdownEditor/CkMilkdownEditor.vue.d.ts.map +1 -0
  24. package/dist/components/base/CkMilkdownEditor/codeMirrorTheme.d.ts +20 -0
  25. package/dist/components/base/CkMilkdownEditor/codeMirrorTheme.d.ts.map +1 -0
  26. package/dist/components/base/CkMilkdownEditor/createCrepeEditor.d.ts +42 -0
  27. package/dist/components/base/CkMilkdownEditor/createCrepeEditor.d.ts.map +1 -0
  28. package/dist/components/base/CkMilkdownEditor/crepeIcons.d.ts +33 -0
  29. package/dist/components/base/CkMilkdownEditor/crepeIcons.d.ts.map +1 -0
  30. package/dist/components/base/CkMilkdownEditor/index.d.ts +3 -0
  31. package/dist/components/base/CkMilkdownEditor/index.d.ts.map +1 -0
  32. package/dist/components/base/CkMilkdownEditor/markdownClassAttrs.d.ts +16 -0
  33. package/dist/components/base/CkMilkdownEditor/markdownClassAttrs.d.ts.map +1 -0
  34. package/dist/components/base/CkMilkdownEditor/types.d.ts +98 -0
  35. package/dist/components/base/CkMilkdownEditor/types.d.ts.map +1 -0
  36. package/dist/components/base/index.d.ts +2 -0
  37. package/dist/components/base/index.d.ts.map +1 -1
  38. package/dist/components/index.d.ts +2 -2
  39. package/dist/components/index.d.ts.map +1 -1
  40. package/dist/components/index.js +12 -11
  41. package/dist/composables/fileUpload/useFileUpload.d.ts.map +1 -1
  42. package/dist/composables/index.js +1 -1
  43. package/dist/composables/useChat.d.ts.map +1 -1
  44. package/dist/composables/useConversations.d.ts.map +1 -1
  45. package/dist/createCrepeEditor-CFbvSH3s.js +74141 -0
  46. package/dist/crystal-DyuLTqLs.js +398 -0
  47. package/dist/css-DkSyTW67.js +1772 -0
  48. package/dist/cypher-Dlu_3r4V.js +121 -0
  49. package/dist/d-UURgV0Ux.js +179 -0
  50. package/dist/diff-B_Bi2Crb.js +25 -0
  51. package/dist/dockerfile-Bvk733Ga.js +201 -0
  52. package/dist/dtd-Dy74G54E.js +114 -0
  53. package/dist/dylan-TSb-Nfix.js +314 -0
  54. package/dist/ebnf-4fKAGW3a.js +140 -0
  55. package/dist/ecl-B59qGGVg.js +178 -0
  56. package/dist/eiffel-Dze7nlu3.js +134 -0
  57. package/dist/elm-DG7jkhNZ.js +176 -0
  58. package/dist/erlang-BO6gOnGA.js +674 -0
  59. package/dist/factor-CMxFHDqz.js +65 -0
  60. package/dist/fcl-CDDUNjTj.js +141 -0
  61. package/dist/forth-B9D2JCeE.js +116 -0
  62. package/dist/fortran-CAG2BFbe.js +467 -0
  63. package/dist/gas-0Aw8zDr5.js +293 -0
  64. package/dist/gherkin-DhZlEZiy.js +115 -0
  65. package/dist/groovy-CpwJiBl7.js +223 -0
  66. package/dist/handlers/index.js +1 -1
  67. package/dist/handlers/useChatKitLabels.d.ts +62 -1
  68. package/dist/handlers/useChatKitLabels.d.ts.map +1 -1
  69. package/dist/haskell-ySd-OUo8.js +459 -0
  70. package/dist/haxe-7MlzfeYV.js +514 -0
  71. package/dist/http-BqypyemW.js +79 -0
  72. package/dist/idl-4HIGJlDI.js +985 -0
  73. package/dist/index-A5rWjRtZ.js +689 -0
  74. package/dist/index-B0ldhzaj.js +385 -0
  75. package/dist/index-BVOjyn3y.js +2490 -0
  76. package/dist/index-BWvkps_G.js +309 -0
  77. package/dist/index-BaS8OW8V.js +151 -0
  78. package/dist/index-BlHHEbV-.js +406 -0
  79. package/dist/index-BoqzHVNB.js +82 -0
  80. package/dist/index-C6zYjwIQ.js +704 -0
  81. package/dist/{index-Dn4ctxk8.js → index-C72e57-5.js} +48 -24
  82. package/dist/index-CMJGuXap.js +330 -0
  83. package/dist/index-CRfGWVdQ.js +116 -0
  84. package/dist/index-C_gTb50u.js +81 -0
  85. package/dist/index-DSU7cBGz.js +178 -0
  86. package/dist/index-DSq3gvqU.js +1767 -0
  87. package/dist/index-Da3777l2.js +289 -0
  88. package/dist/index-DdlzabmR.js +1021 -0
  89. package/dist/index-DhY_9bdS.js +61 -0
  90. package/dist/index-Dm6C1blN.js +1052 -0
  91. package/dist/index-Tj3pzx-E.js +327 -0
  92. package/dist/index-ZeRS5rER.js +97 -0
  93. package/dist/index-gzleljO6.js +157 -0
  94. package/dist/index-naWlQpaL.js +642 -0
  95. package/dist/index-sKO1lHHC.js +312 -0
  96. package/dist/index.d.ts +2 -2
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +15 -14
  99. package/dist/javascript-Bt8B7yTi.js +992 -0
  100. package/dist/julia-Bs6JJhYG.js +407 -0
  101. package/dist/livescript-DmzgM3Yt.js +296 -0
  102. package/dist/lua-Cvg8VrAA.js +256 -0
  103. package/dist/mathematica-DNLOL9PQ.js +110 -0
  104. package/dist/mbox-Ga7d4MMN.js +117 -0
  105. package/dist/mirc-Dma3B8rS.js +107 -0
  106. package/dist/mllike-DHn7xckP.js +334 -0
  107. package/dist/modelica-0d55jYY0.js +147 -0
  108. package/dist/mscgen-DdqZYINH.js +135 -0
  109. package/dist/mumps-Btr8VblO.js +93 -0
  110. package/dist/nginx-DTDtBDVN.js +141 -0
  111. package/dist/nsis-CyKBdPWp.js +62 -0
  112. package/dist/ntriples-CvgOYMpL.js +153 -0
  113. package/dist/octave-DYBj3-tl.js +200 -0
  114. package/dist/oz-R_e8WMIi.js +231 -0
  115. package/dist/pascal-GD8iposT.js +105 -0
  116. package/dist/perl-DL9mHpoi.js +1105 -0
  117. package/dist/pig-C_4T4YIV.js +101 -0
  118. package/dist/powershell-B0suO7Vd.js +328 -0
  119. package/dist/properties-BR-vP1aU.js +58 -0
  120. package/dist/protobuf-BxgpyhoW.js +77 -0
  121. package/dist/pug-vHnWR0UE.js +405 -0
  122. package/dist/puppet-Bdao66PW.js +137 -0
  123. package/dist/python-BFGRmuZ9.js +426 -0
  124. package/dist/q-CrbCVq4a.js +131 -0
  125. package/dist/r-V7nswm59.js +170 -0
  126. package/dist/rpm-C-DLY-If.js +109 -0
  127. package/dist/ruby-CQTpZw6f.js +331 -0
  128. package/dist/sas-D2UG-yhZ.js +207 -0
  129. package/dist/scheme-BKzrkGJD.js +222 -0
  130. package/dist/shell-BlsXDxCn.js +222 -0
  131. package/dist/sieve-CjwBwOY5.js +135 -0
  132. package/dist/simple-mode-DMneyfDu.js +130 -0
  133. package/dist/smalltalk-BOIGQuhN.js +121 -0
  134. package/dist/solr-CwD7U71z.js +69 -0
  135. package/dist/sparql-DYskk2vE.js +249 -0
  136. package/dist/spreadsheet-Bgtt3oLP.js +87 -0
  137. package/dist/sql-Cei9CMfk.js +342 -0
  138. package/dist/stex-C1nZSzAw.js +230 -0
  139. package/dist/stylus-BkS-boTH.js +565 -0
  140. package/dist/swift-FRZi1uvB.js +291 -0
  141. package/dist/tcl-CUcaCdmq.js +114 -0
  142. package/dist/test-utils/createTextPlugin.d.ts +7 -1
  143. package/dist/test-utils/createTextPlugin.d.ts.map +1 -1
  144. package/dist/textile-BnFpjsrl.js +414 -0
  145. package/dist/tiddlywiki-CjprD-Qp.js +218 -0
  146. package/dist/tiki-DK9DOeWn.js +268 -0
  147. package/dist/toml-BOuWGMcf.js +76 -0
  148. package/dist/troff-E1bJ0PPL.js +61 -0
  149. package/dist/ttcn-cfg-Dc39-fIP.js +133 -0
  150. package/dist/ttcn-tKd4HLu4.js +192 -0
  151. package/dist/turtle-Dq7-1WAf.js +124 -0
  152. package/dist/{useChatKitLabels-CMOr3Kjq.js → useChatKitLabels-Ww1Q7xUr.js} +26 -3
  153. package/dist/vb-Dp90gtsv.js +196 -0
  154. package/dist/vbscript-Bfn8O8I7.js +478 -0
  155. package/dist/velocity-BwIZK1TH.js +149 -0
  156. package/dist/verilog-CnT9bMk0.js +429 -0
  157. package/dist/vhdl-DCkMIyT9.js +158 -0
  158. package/dist/webidl-BTLTThCm.js +204 -0
  159. package/dist/xquery-BrBUuxMR.js +525 -0
  160. package/dist/yacas-b5lAVEIl.js +130 -0
  161. package/dist/z80-ClgwfNdB.js +92 -0
  162. package/package.json +11 -5
  163. package/src/adapters/responses-api.spec.ts +86 -0
  164. package/src/adapters/responses-api.ts +13 -9
  165. package/src/components/base/CkCitationCard/CkCitationCard.vue +1 -1
  166. package/src/components/base/CkCitationLabel/CkCitationLabel.vue +1 -1
  167. package/src/components/base/CkConversationLayout/CkConversationLayout.spec.ts +1 -5
  168. package/src/components/base/CkCopyMessageButton/CkCopyMessageButton.spec.ts +1 -1
  169. package/src/components/base/CkFeedbackButton/CkFeedbackButton.vue +3 -3
  170. package/src/components/base/CkFeedbackDialog/CkFeedbackDialog.vue +9 -9
  171. package/src/components/base/CkHistoryItem/CkHistoryItem.vue +5 -7
  172. package/src/components/base/CkHistoryWrapper/CkHistoryWrapper.vue +2 -1
  173. package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.stories.ts +9 -4
  174. package/src/components/base/CkMarkdownRenderer/CkMarkdownRenderer.vue +1 -1
  175. package/src/components/base/CkMilkdownEditor/CkMilkdownEditor.spec.ts +221 -0
  176. package/src/components/base/CkMilkdownEditor/CkMilkdownEditor.stories.ts +274 -0
  177. package/src/components/base/CkMilkdownEditor/CkMilkdownEditor.vue +151 -0
  178. package/src/components/base/CkMilkdownEditor/codeMirrorTheme.ts +132 -0
  179. package/src/components/base/CkMilkdownEditor/createCrepeEditor.ts +192 -0
  180. package/src/components/base/CkMilkdownEditor/crepeIcons.ts +77 -0
  181. package/src/components/base/CkMilkdownEditor/index.ts +2 -0
  182. package/src/components/base/CkMilkdownEditor/markdownClassAttrs.ts +64 -0
  183. package/src/components/base/CkMilkdownEditor/milkdown-theme.css +441 -0
  184. package/src/components/base/CkMilkdownEditor/types.ts +100 -0
  185. package/src/components/base/CkModelSelector/CkModelSelector.vue +3 -3
  186. package/src/components/base/CkPromptInputDisclaimer/CkPromptInputDisclaimer.stories.ts +2 -2
  187. package/src/components/base/index.ts +6 -0
  188. package/src/components/index.ts +4 -0
  189. package/src/composables/fileUpload/useFileUpload.ts +45 -30
  190. package/src/composables/fileUpload/useFileUploadWrapper.spec.ts +1 -1
  191. package/src/composables/fileUpload/useFileUploadWrapper.ts +3 -3
  192. package/src/composables/useChat.ts +3 -1
  193. package/src/composables/useConversations.ts +8 -5
  194. package/src/handlers/useChatKitLabels.spec.ts +0 -1
  195. package/src/handlers/useChatKitLabels.ts +29 -2
  196. package/src/handlers/useMarkdownParser.ts +1 -1
  197. package/src/index.ts +4 -0
  198. package/src/test-setup.ts +3 -3
  199. package/src/test-utils/createTextPlugin.ts +11 -3
@@ -0,0 +1,170 @@
1
+ function wordObj(words) {
2
+ var res = {};
3
+ for (var i = 0; i < words.length; ++i) res[words[i]] = true;
4
+ return res;
5
+ }
6
+ var commonAtoms = ["NULL", "NA", "Inf", "NaN", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_", "TRUE", "FALSE"];
7
+ var commonBuiltins = ["list", "quote", "bquote", "eval", "return", "call", "parse", "deparse"];
8
+ var commonKeywords = ["if", "else", "repeat", "while", "function", "for", "in", "next", "break"];
9
+ var commonBlockKeywords = ["if", "else", "repeat", "while", "function", "for"];
10
+ var atoms = wordObj(commonAtoms);
11
+ var builtins = wordObj(commonBuiltins);
12
+ var keywords = wordObj(commonKeywords);
13
+ var blockkeywords = wordObj(commonBlockKeywords);
14
+ var opChars = /[+\-*\/^<>=!&|~$:]/;
15
+ var curPunc;
16
+ function tokenBase(stream, state) {
17
+ curPunc = null;
18
+ var ch = stream.next();
19
+ if (ch == "#") {
20
+ stream.skipToEnd();
21
+ return "comment";
22
+ } else if (ch == "0" && stream.eat("x")) {
23
+ stream.eatWhile(/[\da-f]/i);
24
+ return "number";
25
+ } else if (ch == "." && stream.eat(/\d/)) {
26
+ stream.match(/\d*(?:e[+\-]?\d+)?/);
27
+ return "number";
28
+ } else if (/\d/.test(ch)) {
29
+ stream.match(/\d*(?:\.\d+)?(?:e[+\-]\d+)?L?/);
30
+ return "number";
31
+ } else if (ch == "'" || ch == '"') {
32
+ state.tokenize = tokenString(ch);
33
+ return "string";
34
+ } else if (ch == "`") {
35
+ stream.match(/[^`]+`/);
36
+ return "string.special";
37
+ } else if (ch == "." && stream.match(/.(?:[.]|\d+)/)) {
38
+ return "keyword";
39
+ } else if (/[a-zA-Z\.]/.test(ch)) {
40
+ stream.eatWhile(/[\w\.]/);
41
+ var word = stream.current();
42
+ if (atoms.propertyIsEnumerable(word)) return "atom";
43
+ if (keywords.propertyIsEnumerable(word)) {
44
+ if (blockkeywords.propertyIsEnumerable(word) && !stream.match(/\s*if(\s+|$)/, false))
45
+ curPunc = "block";
46
+ return "keyword";
47
+ }
48
+ if (builtins.propertyIsEnumerable(word)) return "builtin";
49
+ return "variable";
50
+ } else if (ch == "%") {
51
+ if (stream.skipTo("%")) stream.next();
52
+ return "variableName.special";
53
+ } else if (ch == "<" && stream.eat("-") || ch == "<" && stream.match("<-") || ch == "-" && stream.match(/>>?/)) {
54
+ return "operator";
55
+ } else if (ch == "=" && state.ctx.argList) {
56
+ return "operator";
57
+ } else if (opChars.test(ch)) {
58
+ if (ch == "$") return "operator";
59
+ stream.eatWhile(opChars);
60
+ return "operator";
61
+ } else if (/[\(\){}\[\];]/.test(ch)) {
62
+ curPunc = ch;
63
+ if (ch == ";") return "punctuation";
64
+ return null;
65
+ } else {
66
+ return null;
67
+ }
68
+ }
69
+ function tokenString(quote) {
70
+ return function(stream, state) {
71
+ if (stream.eat("\\")) {
72
+ var ch = stream.next();
73
+ if (ch == "x") stream.match(/^[a-f0-9]{2}/i);
74
+ else if ((ch == "u" || ch == "U") && stream.eat("{") && stream.skipTo("}")) stream.next();
75
+ else if (ch == "u") stream.match(/^[a-f0-9]{4}/i);
76
+ else if (ch == "U") stream.match(/^[a-f0-9]{8}/i);
77
+ else if (/[0-7]/.test(ch)) stream.match(/^[0-7]{1,2}/);
78
+ return "string.special";
79
+ } else {
80
+ var next;
81
+ while ((next = stream.next()) != null) {
82
+ if (next == quote) {
83
+ state.tokenize = tokenBase;
84
+ break;
85
+ }
86
+ if (next == "\\") {
87
+ stream.backUp(1);
88
+ break;
89
+ }
90
+ }
91
+ return "string";
92
+ }
93
+ };
94
+ }
95
+ var ALIGN_YES = 1, ALIGN_NO = 2, BRACELESS = 4;
96
+ function push(state, type, stream) {
97
+ state.ctx = {
98
+ type,
99
+ indent: state.indent,
100
+ flags: 0,
101
+ column: stream.column(),
102
+ prev: state.ctx
103
+ };
104
+ }
105
+ function setFlag(state, flag) {
106
+ var ctx = state.ctx;
107
+ state.ctx = {
108
+ type: ctx.type,
109
+ indent: ctx.indent,
110
+ flags: ctx.flags | flag,
111
+ column: ctx.column,
112
+ prev: ctx.prev
113
+ };
114
+ }
115
+ function pop(state) {
116
+ state.indent = state.ctx.indent;
117
+ state.ctx = state.ctx.prev;
118
+ }
119
+ const r = {
120
+ name: "r",
121
+ startState: function(indentUnit) {
122
+ return {
123
+ tokenize: tokenBase,
124
+ ctx: {
125
+ type: "top",
126
+ indent: -indentUnit,
127
+ flags: ALIGN_NO
128
+ },
129
+ indent: 0,
130
+ afterIdent: false
131
+ };
132
+ },
133
+ token: function(stream, state) {
134
+ if (stream.sol()) {
135
+ if ((state.ctx.flags & 3) == 0) state.ctx.flags |= ALIGN_NO;
136
+ if (state.ctx.flags & BRACELESS) pop(state);
137
+ state.indent = stream.indentation();
138
+ }
139
+ if (stream.eatSpace()) return null;
140
+ var style = state.tokenize(stream, state);
141
+ if (style != "comment" && (state.ctx.flags & ALIGN_NO) == 0) setFlag(state, ALIGN_YES);
142
+ if ((curPunc == ";" || curPunc == "{" || curPunc == "}") && state.ctx.type == "block") pop(state);
143
+ if (curPunc == "{") push(state, "}", stream);
144
+ else if (curPunc == "(") {
145
+ push(state, ")", stream);
146
+ if (state.afterIdent) state.ctx.argList = true;
147
+ } else if (curPunc == "[") push(state, "]", stream);
148
+ else if (curPunc == "block") push(state, "block", stream);
149
+ else if (curPunc == state.ctx.type) pop(state);
150
+ else if (state.ctx.type == "block" && style != "comment") setFlag(state, BRACELESS);
151
+ state.afterIdent = style == "variable" || style == "keyword";
152
+ return style;
153
+ },
154
+ indent: function(state, textAfter, cx) {
155
+ if (state.tokenize != tokenBase) return 0;
156
+ var firstChar = textAfter && textAfter.charAt(0), ctx = state.ctx, closing = firstChar == ctx.type;
157
+ if (ctx.flags & BRACELESS) ctx = ctx.prev;
158
+ if (ctx.type == "block") return ctx.indent + (firstChar == "{" ? 0 : cx.unit);
159
+ else if (ctx.flags & ALIGN_YES) return ctx.column + (closing ? 0 : 1);
160
+ else return ctx.indent + (closing ? 0 : cx.unit);
161
+ },
162
+ languageData: {
163
+ wordChars: ".",
164
+ commentTokens: { line: "#" },
165
+ autocomplete: commonAtoms.concat(commonBuiltins, commonKeywords)
166
+ }
167
+ };
168
+ export {
169
+ r
170
+ };
@@ -0,0 +1,109 @@
1
+ var headerSeparator = /^-+$/;
2
+ var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /;
3
+ var simpleEmail = /^[\w+.-]+@[\w.-]+/;
4
+ const rpmChanges = {
5
+ name: "rpmchanges",
6
+ token: function(stream) {
7
+ if (stream.sol()) {
8
+ if (stream.match(headerSeparator)) {
9
+ return "tag";
10
+ }
11
+ if (stream.match(headerLine)) {
12
+ return "tag";
13
+ }
14
+ }
15
+ if (stream.match(simpleEmail)) {
16
+ return "string";
17
+ }
18
+ stream.next();
19
+ return null;
20
+ }
21
+ };
22
+ var arch = /^(i386|i586|i686|x86_64|ppc64le|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
23
+ var preamble = /^[a-zA-Z0-9()]+:/;
24
+ var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pretrans|posttrans|pre|post|triggerin|triggerun|verifyscript|check|triggerpostun|triggerprein|trigger)/;
25
+ var control_flow_complex = /^%(ifnarch|ifarch|if)/;
26
+ var control_flow_simple = /^%(else|endif)/;
27
+ var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/;
28
+ const rpmSpec = {
29
+ name: "rpmspec",
30
+ startState: function() {
31
+ return {
32
+ controlFlow: false,
33
+ macroParameters: false,
34
+ section: false
35
+ };
36
+ },
37
+ token: function(stream, state) {
38
+ var ch = stream.peek();
39
+ if (ch == "#") {
40
+ stream.skipToEnd();
41
+ return "comment";
42
+ }
43
+ if (stream.sol()) {
44
+ if (stream.match(preamble)) {
45
+ return "header";
46
+ }
47
+ if (stream.match(section)) {
48
+ return "atom";
49
+ }
50
+ }
51
+ if (stream.match(/^\$\w+/)) {
52
+ return "def";
53
+ }
54
+ if (stream.match(/^\$\{\w+\}/)) {
55
+ return "def";
56
+ }
57
+ if (stream.match(control_flow_simple)) {
58
+ return "keyword";
59
+ }
60
+ if (stream.match(control_flow_complex)) {
61
+ state.controlFlow = true;
62
+ return "keyword";
63
+ }
64
+ if (state.controlFlow) {
65
+ if (stream.match(operators)) {
66
+ return "operator";
67
+ }
68
+ if (stream.match(/^(\d+)/)) {
69
+ return "number";
70
+ }
71
+ if (stream.eol()) {
72
+ state.controlFlow = false;
73
+ }
74
+ }
75
+ if (stream.match(arch)) {
76
+ if (stream.eol()) {
77
+ state.controlFlow = false;
78
+ }
79
+ return "number";
80
+ }
81
+ if (stream.match(/^%[\w]+/)) {
82
+ if (stream.match("(")) {
83
+ state.macroParameters = true;
84
+ }
85
+ return "keyword";
86
+ }
87
+ if (state.macroParameters) {
88
+ if (stream.match(/^\d+/)) {
89
+ return "number";
90
+ }
91
+ if (stream.match(")")) {
92
+ state.macroParameters = false;
93
+ return "keyword";
94
+ }
95
+ }
96
+ if (stream.match(/^%\{\??[\w \-\:\!]+\}/)) {
97
+ if (stream.eol()) {
98
+ state.controlFlow = false;
99
+ }
100
+ return "def";
101
+ }
102
+ stream.next();
103
+ return null;
104
+ }
105
+ };
106
+ export {
107
+ rpmChanges,
108
+ rpmSpec
109
+ };
@@ -0,0 +1,331 @@
1
+ function wordObj(words) {
2
+ var o = {};
3
+ for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
4
+ return o;
5
+ }
6
+ var keywordList = [
7
+ "alias",
8
+ "and",
9
+ "BEGIN",
10
+ "begin",
11
+ "break",
12
+ "case",
13
+ "class",
14
+ "def",
15
+ "defined?",
16
+ "do",
17
+ "else",
18
+ "elsif",
19
+ "END",
20
+ "end",
21
+ "ensure",
22
+ "false",
23
+ "for",
24
+ "if",
25
+ "in",
26
+ "module",
27
+ "next",
28
+ "not",
29
+ "or",
30
+ "redo",
31
+ "rescue",
32
+ "retry",
33
+ "return",
34
+ "self",
35
+ "super",
36
+ "then",
37
+ "true",
38
+ "undef",
39
+ "unless",
40
+ "until",
41
+ "when",
42
+ "while",
43
+ "yield",
44
+ "nil",
45
+ "raise",
46
+ "throw",
47
+ "catch",
48
+ "fail",
49
+ "loop",
50
+ "callcc",
51
+ "caller",
52
+ "lambda",
53
+ "proc",
54
+ "public",
55
+ "protected",
56
+ "private",
57
+ "require",
58
+ "load",
59
+ "require_relative",
60
+ "extend",
61
+ "autoload",
62
+ "__END__",
63
+ "__FILE__",
64
+ "__LINE__",
65
+ "__dir__"
66
+ ], keywords = wordObj(keywordList);
67
+ var indentWords = wordObj([
68
+ "def",
69
+ "class",
70
+ "case",
71
+ "for",
72
+ "while",
73
+ "until",
74
+ "module",
75
+ "catch",
76
+ "loop",
77
+ "proc",
78
+ "begin"
79
+ ]);
80
+ var dedentWords = wordObj(["end", "until"]);
81
+ var opening = { "[": "]", "{": "}", "(": ")" };
82
+ var closing = { "]": "[", "}": "{", ")": "(" };
83
+ var curPunc;
84
+ function chain(newtok, stream, state) {
85
+ state.tokenize.push(newtok);
86
+ return newtok(stream, state);
87
+ }
88
+ function tokenBase(stream, state) {
89
+ if (stream.sol() && stream.match("=begin") && stream.eol()) {
90
+ state.tokenize.push(readBlockComment);
91
+ return "comment";
92
+ }
93
+ if (stream.eatSpace()) return null;
94
+ var ch = stream.next(), m;
95
+ if (ch == "`" || ch == "'" || ch == '"') {
96
+ return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
97
+ } else if (ch == "/") {
98
+ if (regexpAhead(stream))
99
+ return chain(readQuoted(ch, "string.special", true), stream, state);
100
+ else
101
+ return "operator";
102
+ } else if (ch == "%") {
103
+ var style = "string", embed = true;
104
+ if (stream.eat("s")) style = "atom";
105
+ else if (stream.eat(/[WQ]/)) style = "string";
106
+ else if (stream.eat(/[r]/)) style = "string.special";
107
+ else if (stream.eat(/[wxq]/)) {
108
+ style = "string";
109
+ embed = false;
110
+ }
111
+ var delim = stream.eat(/[^\w\s=]/);
112
+ if (!delim) return "operator";
113
+ if (opening.propertyIsEnumerable(delim)) delim = opening[delim];
114
+ return chain(readQuoted(delim, style, embed, true), stream, state);
115
+ } else if (ch == "#") {
116
+ stream.skipToEnd();
117
+ return "comment";
118
+ } else if (ch == "<" && (m = stream.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
119
+ return chain(readHereDoc(m[2], m[1]), stream, state);
120
+ } else if (ch == "0") {
121
+ if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
122
+ else if (stream.eat("b")) stream.eatWhile(/[01]/);
123
+ else if (stream.eat(".")) stream.eat(/[\d_]*(?:[eE][+\-]?[\d_]+)?/);
124
+ else stream.eatWhile(/[0-7]/);
125
+ return "number";
126
+ } else if (/\d/.test(ch)) {
127
+ stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/);
128
+ return "number";
129
+ } else if (ch == "?") {
130
+ while (stream.match(/^\\[CM]-/)) {
131
+ }
132
+ if (stream.eat("\\")) stream.eatWhile(/\w/);
133
+ else stream.next();
134
+ return "string";
135
+ } else if (ch == ":") {
136
+ if (stream.eat("'")) return chain(readQuoted("'", "atom", false), stream, state);
137
+ if (stream.eat('"')) return chain(readQuoted('"', "atom", true), stream, state);
138
+ if (stream.eat(/[\<\>]/)) {
139
+ stream.eat(/[\<\>]/);
140
+ return "atom";
141
+ }
142
+ if (stream.eat(/[\+\-\*\/\&\|\:\!]/)) {
143
+ return "atom";
144
+ }
145
+ if (stream.eat(/[a-zA-Z$@_\xa1-\uffff]/)) {
146
+ stream.eatWhile(/[\w$\xa1-\uffff]/);
147
+ stream.eat(/[\?\!\=]/);
148
+ return "atom";
149
+ }
150
+ return "operator";
151
+ } else if (ch == "@" && stream.match(/^@?[a-zA-Z_\xa1-\uffff]/)) {
152
+ stream.eat("@");
153
+ stream.eatWhile(/[\w\xa1-\uffff]/);
154
+ return "propertyName";
155
+ } else if (ch == "$") {
156
+ if (stream.eat(/[a-zA-Z_]/)) {
157
+ stream.eatWhile(/[\w]/);
158
+ } else if (stream.eat(/\d/)) {
159
+ stream.eat(/\d/);
160
+ } else {
161
+ stream.next();
162
+ }
163
+ return "variableName.special";
164
+ } else if (/[a-zA-Z_\xa1-\uffff]/.test(ch)) {
165
+ stream.eatWhile(/[\w\xa1-\uffff]/);
166
+ stream.eat(/[\?\!]/);
167
+ if (stream.eat(":")) return "atom";
168
+ return "variable";
169
+ } else if (ch == "|" && (state.varList || state.lastTok == "{" || state.lastTok == "do")) {
170
+ curPunc = "|";
171
+ return null;
172
+ } else if (/[\(\)\[\]{}\\;]/.test(ch)) {
173
+ curPunc = ch;
174
+ return null;
175
+ } else if (ch == "-" && stream.eat(">")) {
176
+ return "operator";
177
+ } else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) {
178
+ var more = stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
179
+ if (ch == "." && !more) curPunc = ".";
180
+ return "operator";
181
+ } else {
182
+ return null;
183
+ }
184
+ }
185
+ function regexpAhead(stream) {
186
+ var start = stream.pos, depth = 0, next, found = false, escaped = false;
187
+ while ((next = stream.next()) != null) {
188
+ if (!escaped) {
189
+ if ("[{(".indexOf(next) > -1) {
190
+ depth++;
191
+ } else if ("]})".indexOf(next) > -1) {
192
+ depth--;
193
+ if (depth < 0) break;
194
+ } else if (next == "/" && depth == 0) {
195
+ found = true;
196
+ break;
197
+ }
198
+ escaped = next == "\\";
199
+ } else {
200
+ escaped = false;
201
+ }
202
+ }
203
+ stream.backUp(stream.pos - start);
204
+ return found;
205
+ }
206
+ function tokenBaseUntilBrace(depth) {
207
+ if (!depth) depth = 1;
208
+ return function(stream, state) {
209
+ if (stream.peek() == "}") {
210
+ if (depth == 1) {
211
+ state.tokenize.pop();
212
+ return state.tokenize[state.tokenize.length - 1](stream, state);
213
+ } else {
214
+ state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth - 1);
215
+ }
216
+ } else if (stream.peek() == "{") {
217
+ state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth + 1);
218
+ }
219
+ return tokenBase(stream, state);
220
+ };
221
+ }
222
+ function tokenBaseOnce() {
223
+ var alreadyCalled = false;
224
+ return function(stream, state) {
225
+ if (alreadyCalled) {
226
+ state.tokenize.pop();
227
+ return state.tokenize[state.tokenize.length - 1](stream, state);
228
+ }
229
+ alreadyCalled = true;
230
+ return tokenBase(stream, state);
231
+ };
232
+ }
233
+ function readQuoted(quote, style, embed, unescaped) {
234
+ return function(stream, state) {
235
+ var escaped = false, ch;
236
+ if (state.context.type === "read-quoted-paused") {
237
+ state.context = state.context.prev;
238
+ stream.eat("}");
239
+ }
240
+ while ((ch = stream.next()) != null) {
241
+ if (ch == quote && (unescaped || !escaped)) {
242
+ state.tokenize.pop();
243
+ break;
244
+ }
245
+ if (embed && ch == "#" && !escaped) {
246
+ if (stream.eat("{")) {
247
+ if (quote == "}") {
248
+ state.context = { prev: state.context, type: "read-quoted-paused" };
249
+ }
250
+ state.tokenize.push(tokenBaseUntilBrace());
251
+ break;
252
+ } else if (/[@\$]/.test(stream.peek())) {
253
+ state.tokenize.push(tokenBaseOnce());
254
+ break;
255
+ }
256
+ }
257
+ escaped = !escaped && ch == "\\";
258
+ }
259
+ return style;
260
+ };
261
+ }
262
+ function readHereDoc(phrase, mayIndent) {
263
+ return function(stream, state) {
264
+ if (mayIndent) stream.eatSpace();
265
+ if (stream.match(phrase)) state.tokenize.pop();
266
+ else stream.skipToEnd();
267
+ return "string";
268
+ };
269
+ }
270
+ function readBlockComment(stream, state) {
271
+ if (stream.sol() && stream.match("=end") && stream.eol())
272
+ state.tokenize.pop();
273
+ stream.skipToEnd();
274
+ return "comment";
275
+ }
276
+ const ruby = {
277
+ name: "ruby",
278
+ startState: function(indentUnit) {
279
+ return {
280
+ tokenize: [tokenBase],
281
+ indented: 0,
282
+ context: { type: "top", indented: -indentUnit },
283
+ continuedLine: false,
284
+ lastTok: null,
285
+ varList: false
286
+ };
287
+ },
288
+ token: function(stream, state) {
289
+ curPunc = null;
290
+ if (stream.sol()) state.indented = stream.indentation();
291
+ var style = state.tokenize[state.tokenize.length - 1](stream, state), kwtype;
292
+ var thisTok = curPunc;
293
+ if (style == "variable") {
294
+ var word = stream.current();
295
+ style = state.lastTok == "." ? "property" : keywords.propertyIsEnumerable(stream.current()) ? "keyword" : /^[A-Z]/.test(word) ? "tag" : state.lastTok == "def" || state.lastTok == "class" || state.varList ? "def" : "variable";
296
+ if (style == "keyword") {
297
+ thisTok = word;
298
+ if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
299
+ else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
300
+ else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
301
+ kwtype = "indent";
302
+ else if (word == "do" && state.context.indented < state.indented)
303
+ kwtype = "indent";
304
+ }
305
+ }
306
+ if (curPunc || style && style != "comment") state.lastTok = thisTok;
307
+ if (curPunc == "|") state.varList = !state.varList;
308
+ if (kwtype == "indent" || /[\(\[\{]/.test(curPunc))
309
+ state.context = { prev: state.context, type: curPunc || style, indented: state.indented };
310
+ else if ((kwtype == "dedent" || /[\)\]\}]/.test(curPunc)) && state.context.prev)
311
+ state.context = state.context.prev;
312
+ if (stream.eol())
313
+ state.continuedLine = curPunc == "\\" || style == "operator";
314
+ return style;
315
+ },
316
+ indent: function(state, textAfter, cx) {
317
+ if (state.tokenize[state.tokenize.length - 1] != tokenBase) return null;
318
+ var firstChar = textAfter && textAfter.charAt(0);
319
+ var ct = state.context;
320
+ var closed = ct.type == closing[firstChar] || ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
321
+ return ct.indented + (closed ? 0 : cx.unit) + (state.continuedLine ? cx.unit : 0);
322
+ },
323
+ languageData: {
324
+ indentOnInput: /^\s*(?:end|rescue|elsif|else|\})$/,
325
+ commentTokens: { line: "#" },
326
+ autocomplete: keywordList
327
+ }
328
+ };
329
+ export {
330
+ ruby
331
+ };