local-operator-ui 0.4.6 → 0.5.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.
@@ -0,0 +1,405 @@
1
+ import { javascript } from "./javascript-C3MnDRiU.js";
2
+ var ATTRS_NEST = {
3
+ "{": "}",
4
+ "(": ")",
5
+ "[": "]"
6
+ };
7
+ function defaultCopyState(state) {
8
+ if (typeof state != "object") return state;
9
+ let newState = {};
10
+ for (let prop in state) {
11
+ let val = state[prop];
12
+ newState[prop] = val instanceof Array ? val.slice() : val;
13
+ }
14
+ return newState;
15
+ }
16
+ class State {
17
+ constructor(indentUnit) {
18
+ this.indentUnit = indentUnit;
19
+ this.javaScriptLine = false;
20
+ this.javaScriptLineExcludesColon = false;
21
+ this.javaScriptArguments = false;
22
+ this.javaScriptArgumentsDepth = 0;
23
+ this.isInterpolating = false;
24
+ this.interpolationNesting = 0;
25
+ this.jsState = javascript.startState(indentUnit);
26
+ this.restOfLine = "";
27
+ this.isIncludeFiltered = false;
28
+ this.isEach = false;
29
+ this.lastTag = "";
30
+ this.isAttrs = false;
31
+ this.attrsNest = [];
32
+ this.inAttributeName = true;
33
+ this.attributeIsType = false;
34
+ this.attrValue = "";
35
+ this.indentOf = Infinity;
36
+ this.indentToken = "";
37
+ }
38
+ copy() {
39
+ var res = new State(this.indentUnit);
40
+ res.javaScriptLine = this.javaScriptLine;
41
+ res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon;
42
+ res.javaScriptArguments = this.javaScriptArguments;
43
+ res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth;
44
+ res.isInterpolating = this.isInterpolating;
45
+ res.interpolationNesting = this.interpolationNesting;
46
+ res.jsState = (javascript.copyState || defaultCopyState)(this.jsState);
47
+ res.restOfLine = this.restOfLine;
48
+ res.isIncludeFiltered = this.isIncludeFiltered;
49
+ res.isEach = this.isEach;
50
+ res.lastTag = this.lastTag;
51
+ res.isAttrs = this.isAttrs;
52
+ res.attrsNest = this.attrsNest.slice();
53
+ res.inAttributeName = this.inAttributeName;
54
+ res.attributeIsType = this.attributeIsType;
55
+ res.attrValue = this.attrValue;
56
+ res.indentOf = this.indentOf;
57
+ res.indentToken = this.indentToken;
58
+ return res;
59
+ }
60
+ }
61
+ function javaScript(stream, state) {
62
+ if (stream.sol()) {
63
+ state.javaScriptLine = false;
64
+ state.javaScriptLineExcludesColon = false;
65
+ }
66
+ if (state.javaScriptLine) {
67
+ if (state.javaScriptLineExcludesColon && stream.peek() === ":") {
68
+ state.javaScriptLine = false;
69
+ state.javaScriptLineExcludesColon = false;
70
+ return;
71
+ }
72
+ var tok = javascript.token(stream, state.jsState);
73
+ if (stream.eol()) state.javaScriptLine = false;
74
+ return tok || true;
75
+ }
76
+ }
77
+ function javaScriptArguments(stream, state) {
78
+ if (state.javaScriptArguments) {
79
+ if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== "(") {
80
+ state.javaScriptArguments = false;
81
+ return;
82
+ }
83
+ if (stream.peek() === "(") {
84
+ state.javaScriptArgumentsDepth++;
85
+ } else if (stream.peek() === ")") {
86
+ state.javaScriptArgumentsDepth--;
87
+ }
88
+ if (state.javaScriptArgumentsDepth === 0) {
89
+ state.javaScriptArguments = false;
90
+ return;
91
+ }
92
+ var tok = javascript.token(stream, state.jsState);
93
+ return tok || true;
94
+ }
95
+ }
96
+ function yieldStatement(stream) {
97
+ if (stream.match(/^yield\b/)) {
98
+ return "keyword";
99
+ }
100
+ }
101
+ function doctype(stream) {
102
+ if (stream.match(/^(?:doctype) *([^\n]+)?/)) return "meta";
103
+ }
104
+ function interpolation(stream, state) {
105
+ if (stream.match("#{")) {
106
+ state.isInterpolating = true;
107
+ state.interpolationNesting = 0;
108
+ return "punctuation";
109
+ }
110
+ }
111
+ function interpolationContinued(stream, state) {
112
+ if (state.isInterpolating) {
113
+ if (stream.peek() === "}") {
114
+ state.interpolationNesting--;
115
+ if (state.interpolationNesting < 0) {
116
+ stream.next();
117
+ state.isInterpolating = false;
118
+ return "punctuation";
119
+ }
120
+ } else if (stream.peek() === "{") {
121
+ state.interpolationNesting++;
122
+ }
123
+ return javascript.token(stream, state.jsState) || true;
124
+ }
125
+ }
126
+ function caseStatement(stream, state) {
127
+ if (stream.match(/^case\b/)) {
128
+ state.javaScriptLine = true;
129
+ return "keyword";
130
+ }
131
+ }
132
+ function when(stream, state) {
133
+ if (stream.match(/^when\b/)) {
134
+ state.javaScriptLine = true;
135
+ state.javaScriptLineExcludesColon = true;
136
+ return "keyword";
137
+ }
138
+ }
139
+ function defaultStatement(stream) {
140
+ if (stream.match(/^default\b/)) {
141
+ return "keyword";
142
+ }
143
+ }
144
+ function extendsStatement(stream, state) {
145
+ if (stream.match(/^extends?\b/)) {
146
+ state.restOfLine = "string";
147
+ return "keyword";
148
+ }
149
+ }
150
+ function append(stream, state) {
151
+ if (stream.match(/^append\b/)) {
152
+ state.restOfLine = "variable";
153
+ return "keyword";
154
+ }
155
+ }
156
+ function prepend(stream, state) {
157
+ if (stream.match(/^prepend\b/)) {
158
+ state.restOfLine = "variable";
159
+ return "keyword";
160
+ }
161
+ }
162
+ function block(stream, state) {
163
+ if (stream.match(/^block\b *(?:(prepend|append)\b)?/)) {
164
+ state.restOfLine = "variable";
165
+ return "keyword";
166
+ }
167
+ }
168
+ function include(stream, state) {
169
+ if (stream.match(/^include\b/)) {
170
+ state.restOfLine = "string";
171
+ return "keyword";
172
+ }
173
+ }
174
+ function includeFiltered(stream, state) {
175
+ if (stream.match(/^include:([a-zA-Z0-9\-]+)/, false) && stream.match("include")) {
176
+ state.isIncludeFiltered = true;
177
+ return "keyword";
178
+ }
179
+ }
180
+ function includeFilteredContinued(stream, state) {
181
+ if (state.isIncludeFiltered) {
182
+ var tok = filter(stream, state);
183
+ state.isIncludeFiltered = false;
184
+ state.restOfLine = "string";
185
+ return tok;
186
+ }
187
+ }
188
+ function mixin(stream, state) {
189
+ if (stream.match(/^mixin\b/)) {
190
+ state.javaScriptLine = true;
191
+ return "keyword";
192
+ }
193
+ }
194
+ function call(stream, state) {
195
+ if (stream.match(/^\+([-\w]+)/)) {
196
+ if (!stream.match(/^\( *[-\w]+ *=/, false)) {
197
+ state.javaScriptArguments = true;
198
+ state.javaScriptArgumentsDepth = 0;
199
+ }
200
+ return "variable";
201
+ }
202
+ if (stream.match("+#{", false)) {
203
+ stream.next();
204
+ state.mixinCallAfter = true;
205
+ return interpolation(stream, state);
206
+ }
207
+ }
208
+ function callArguments(stream, state) {
209
+ if (state.mixinCallAfter) {
210
+ state.mixinCallAfter = false;
211
+ if (!stream.match(/^\( *[-\w]+ *=/, false)) {
212
+ state.javaScriptArguments = true;
213
+ state.javaScriptArgumentsDepth = 0;
214
+ }
215
+ return true;
216
+ }
217
+ }
218
+ function conditional(stream, state) {
219
+ if (stream.match(/^(if|unless|else if|else)\b/)) {
220
+ state.javaScriptLine = true;
221
+ return "keyword";
222
+ }
223
+ }
224
+ function each(stream, state) {
225
+ if (stream.match(/^(- *)?(each|for)\b/)) {
226
+ state.isEach = true;
227
+ return "keyword";
228
+ }
229
+ }
230
+ function eachContinued(stream, state) {
231
+ if (state.isEach) {
232
+ if (stream.match(/^ in\b/)) {
233
+ state.javaScriptLine = true;
234
+ state.isEach = false;
235
+ return "keyword";
236
+ } else if (stream.sol() || stream.eol()) {
237
+ state.isEach = false;
238
+ } else if (stream.next()) {
239
+ while (!stream.match(/^ in\b/, false) && stream.next()) {
240
+ }
241
+ return "variable";
242
+ }
243
+ }
244
+ }
245
+ function whileStatement(stream, state) {
246
+ if (stream.match(/^while\b/)) {
247
+ state.javaScriptLine = true;
248
+ return "keyword";
249
+ }
250
+ }
251
+ function tag(stream, state) {
252
+ var captures;
253
+ if (captures = stream.match(/^(\w(?:[-:\w]*\w)?)\/?/)) {
254
+ state.lastTag = captures[1].toLowerCase();
255
+ return "tag";
256
+ }
257
+ }
258
+ function filter(stream, state) {
259
+ if (stream.match(/^:([\w\-]+)/)) {
260
+ setStringMode(stream, state);
261
+ return "atom";
262
+ }
263
+ }
264
+ function code(stream, state) {
265
+ if (stream.match(/^(!?=|-)/)) {
266
+ state.javaScriptLine = true;
267
+ return "punctuation";
268
+ }
269
+ }
270
+ function id(stream) {
271
+ if (stream.match(/^#([\w-]+)/)) {
272
+ return "builtin";
273
+ }
274
+ }
275
+ function className(stream) {
276
+ if (stream.match(/^\.([\w-]+)/)) {
277
+ return "className";
278
+ }
279
+ }
280
+ function attrs(stream, state) {
281
+ if (stream.peek() == "(") {
282
+ stream.next();
283
+ state.isAttrs = true;
284
+ state.attrsNest = [];
285
+ state.inAttributeName = true;
286
+ state.attrValue = "";
287
+ state.attributeIsType = false;
288
+ return "punctuation";
289
+ }
290
+ }
291
+ function attrsContinued(stream, state) {
292
+ if (state.isAttrs) {
293
+ if (ATTRS_NEST[stream.peek()]) {
294
+ state.attrsNest.push(ATTRS_NEST[stream.peek()]);
295
+ }
296
+ if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) {
297
+ state.attrsNest.pop();
298
+ } else if (stream.eat(")")) {
299
+ state.isAttrs = false;
300
+ return "punctuation";
301
+ }
302
+ if (state.inAttributeName && stream.match(/^[^=,\)!]+/)) {
303
+ if (stream.peek() === "=" || stream.peek() === "!") {
304
+ state.inAttributeName = false;
305
+ state.jsState = javascript.startState(2);
306
+ if (state.lastTag === "script" && stream.current().trim().toLowerCase() === "type") {
307
+ state.attributeIsType = true;
308
+ } else {
309
+ state.attributeIsType = false;
310
+ }
311
+ }
312
+ return "attribute";
313
+ }
314
+ var tok = javascript.token(stream, state.jsState);
315
+ if (state.attrsNest.length === 0 && (tok === "string" || tok === "variable" || tok === "keyword")) {
316
+ try {
317
+ Function("", "var x " + state.attrValue.replace(/,\s*$/, "").replace(/^!/, ""));
318
+ state.inAttributeName = true;
319
+ state.attrValue = "";
320
+ stream.backUp(stream.current().length);
321
+ return attrsContinued(stream, state);
322
+ } catch (ex) {
323
+ }
324
+ }
325
+ state.attrValue += stream.current();
326
+ return tok || true;
327
+ }
328
+ }
329
+ function attributesBlock(stream, state) {
330
+ if (stream.match(/^&attributes\b/)) {
331
+ state.javaScriptArguments = true;
332
+ state.javaScriptArgumentsDepth = 0;
333
+ return "keyword";
334
+ }
335
+ }
336
+ function indent(stream) {
337
+ if (stream.sol() && stream.eatSpace()) {
338
+ return "indent";
339
+ }
340
+ }
341
+ function comment(stream, state) {
342
+ if (stream.match(/^ *\/\/(-)?([^\n]*)/)) {
343
+ state.indentOf = stream.indentation();
344
+ state.indentToken = "comment";
345
+ return "comment";
346
+ }
347
+ }
348
+ function colon(stream) {
349
+ if (stream.match(/^: */)) {
350
+ return "colon";
351
+ }
352
+ }
353
+ function text(stream, state) {
354
+ if (stream.match(/^(?:\| ?| )([^\n]+)/)) {
355
+ return "string";
356
+ }
357
+ if (stream.match(/^(<[^\n]*)/, false)) {
358
+ setStringMode(stream, state);
359
+ stream.skipToEnd();
360
+ return state.indentToken;
361
+ }
362
+ }
363
+ function dot(stream, state) {
364
+ if (stream.eat(".")) {
365
+ setStringMode(stream, state);
366
+ return "dot";
367
+ }
368
+ }
369
+ function fail(stream) {
370
+ stream.next();
371
+ return null;
372
+ }
373
+ function setStringMode(stream, state) {
374
+ state.indentOf = stream.indentation();
375
+ state.indentToken = "string";
376
+ }
377
+ function restOfLine(stream, state) {
378
+ if (stream.sol()) {
379
+ state.restOfLine = "";
380
+ }
381
+ if (state.restOfLine) {
382
+ stream.skipToEnd();
383
+ var tok = state.restOfLine;
384
+ state.restOfLine = "";
385
+ return tok;
386
+ }
387
+ }
388
+ function startState(indentUnit) {
389
+ return new State(indentUnit);
390
+ }
391
+ function copyState(state) {
392
+ return state.copy();
393
+ }
394
+ function nextToken(stream, state) {
395
+ var tok = restOfLine(stream, state) || interpolationContinued(stream, state) || includeFilteredContinued(stream, state) || eachContinued(stream, state) || attrsContinued(stream, state) || javaScript(stream, state) || javaScriptArguments(stream, state) || callArguments(stream, state) || yieldStatement(stream) || doctype(stream) || interpolation(stream, state) || caseStatement(stream, state) || when(stream, state) || defaultStatement(stream) || extendsStatement(stream, state) || append(stream, state) || prepend(stream, state) || block(stream, state) || include(stream, state) || includeFiltered(stream, state) || mixin(stream, state) || call(stream, state) || conditional(stream, state) || each(stream, state) || whileStatement(stream, state) || tag(stream, state) || filter(stream, state) || code(stream, state) || id(stream) || className(stream) || attrs(stream, state) || attributesBlock(stream, state) || indent(stream) || text(stream, state) || comment(stream, state) || colon(stream) || dot(stream, state) || fail(stream);
396
+ return tok === true ? null : tok;
397
+ }
398
+ const pug = {
399
+ startState,
400
+ copyState,
401
+ token: nextToken
402
+ };
403
+ export {
404
+ pug
405
+ };