@hep-code-runner/vue2 2.1.10 → 2.2.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.
- package/dist/index.js +3 -77
- package/dist/index.mjs +174 -1548
- package/package.json +4 -5
package/dist/index.mjs
CHANGED
|
@@ -1,1379 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class se {
|
|
4
|
-
constructor(e = {}) {
|
|
5
|
-
q(this, "baseUrl"), q(this, "timeout"), this.baseUrl = e.pistonUrl || "/api/piston", this.timeout = e.timeout || 3e3;
|
|
6
|
-
}
|
|
7
|
-
async getRuntimes(e = !1) {
|
|
8
|
-
if (z && !e)
|
|
9
|
-
return z;
|
|
10
|
-
try {
|
|
11
|
-
const t = await fetch(`${this.baseUrl}/runtimes`, {
|
|
12
|
-
method: "GET",
|
|
13
|
-
headers: {
|
|
14
|
-
"Content-Type": "application/json"
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
if (!t.ok)
|
|
18
|
-
throw new Error(`Failed to fetch runtimes: ${t.statusText}`);
|
|
19
|
-
const l = await t.json();
|
|
20
|
-
return z = l, l;
|
|
21
|
-
} catch (t) {
|
|
22
|
-
throw console.error("Failed to fetch runtimes:", t), t;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async execute(e, t, l = {}) {
|
|
26
|
-
const p = (await this.getRuntimes()).find(
|
|
27
|
-
(g) => {
|
|
28
|
-
var E;
|
|
29
|
-
return g.language.toLowerCase() === e.toLowerCase() || ((E = g.aliases) == null ? void 0 : E.some((w) => w.toLowerCase() === e.toLowerCase()));
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
if (!p)
|
|
33
|
-
throw new Error(`Language '${e}' is not supported`);
|
|
34
|
-
const f = this.getFileName(e), m = {
|
|
35
|
-
language: p.language,
|
|
36
|
-
version: l.version || p.version,
|
|
37
|
-
files: [
|
|
38
|
-
{
|
|
39
|
-
name: f,
|
|
40
|
-
content: t
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
stdin: l.stdin || "",
|
|
44
|
-
args: l.args || [],
|
|
45
|
-
run_timeout: l.runTimeout || this.timeout,
|
|
46
|
-
compile_timeout: this.timeout
|
|
47
|
-
}, u = Date.now();
|
|
48
|
-
try {
|
|
49
|
-
const g = await fetch(`${this.baseUrl}/execute`, {
|
|
50
|
-
method: "POST",
|
|
51
|
-
headers: {
|
|
52
|
-
"Content-Type": "application/json"
|
|
53
|
-
},
|
|
54
|
-
body: JSON.stringify(m)
|
|
55
|
-
});
|
|
56
|
-
if (!g.ok)
|
|
57
|
-
throw new Error(`Execute failed: ${g.statusText}`);
|
|
58
|
-
const E = await g.json(), w = Date.now() - u, k = E.run.stdout || "", x = E.run.stderr || "";
|
|
59
|
-
return {
|
|
60
|
-
success: E.run.code === 0,
|
|
61
|
-
output: k,
|
|
62
|
-
stderr: x,
|
|
63
|
-
code: E.run.code,
|
|
64
|
-
executionTime: w,
|
|
65
|
-
compile: E.compile ? {
|
|
66
|
-
stdout: E.compile.stdout || "",
|
|
67
|
-
stderr: E.compile.stderr || "",
|
|
68
|
-
code: E.compile.code
|
|
69
|
-
} : void 0
|
|
70
|
-
};
|
|
71
|
-
} catch (g) {
|
|
72
|
-
return {
|
|
73
|
-
success: !1,
|
|
74
|
-
output: "",
|
|
75
|
-
stderr: g instanceof Error ? g.message : "Unknown error",
|
|
76
|
-
code: -1,
|
|
77
|
-
executionTime: Date.now() - u
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
getFileName(e) {
|
|
82
|
-
return {
|
|
83
|
-
javascript: "main.js",
|
|
84
|
-
typescript: "main.ts",
|
|
85
|
-
python: "main.py",
|
|
86
|
-
python3: "main.py",
|
|
87
|
-
go: "main.go",
|
|
88
|
-
rust: "main.rs",
|
|
89
|
-
java: "Main.java",
|
|
90
|
-
c: "main.c",
|
|
91
|
-
cpp: "main.cpp",
|
|
92
|
-
csharp: "Main.cs",
|
|
93
|
-
ruby: "main.rb",
|
|
94
|
-
php: "main.php",
|
|
95
|
-
bash: "main.sh",
|
|
96
|
-
shell: "main.sh",
|
|
97
|
-
perl: "main.pl",
|
|
98
|
-
lua: "main.lua",
|
|
99
|
-
swift: "main.swift",
|
|
100
|
-
kotlin: "Main.kt",
|
|
101
|
-
scala: "Main.scala",
|
|
102
|
-
haskell: "main.hs",
|
|
103
|
-
dart: "main.dart",
|
|
104
|
-
html: "index.html",
|
|
105
|
-
css: "style.css",
|
|
106
|
-
sql: "query.sql",
|
|
107
|
-
markdown: "readme.md"
|
|
108
|
-
}[e.toLowerCase()] || `main.${e}`;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const oe = {
|
|
112
|
-
javascript: 'console.log("Hello, World!");',
|
|
113
|
-
typescript: 'console.log("Hello, World!");',
|
|
114
|
-
python: 'print("Hello, World!")',
|
|
115
|
-
python3: 'print("Hello, World!")',
|
|
116
|
-
go: `package main
|
|
117
|
-
|
|
118
|
-
import "fmt"
|
|
119
|
-
|
|
120
|
-
func main() {
|
|
121
|
-
fmt.Println("Hello, World!")
|
|
122
|
-
}`,
|
|
123
|
-
rust: `fn main() {
|
|
124
|
-
println!("Hello, World!");
|
|
125
|
-
}`,
|
|
126
|
-
java: `public class Main {
|
|
127
|
-
public static void main(String[] args) {
|
|
128
|
-
System.out.println("Hello, World!");
|
|
129
|
-
}
|
|
130
|
-
}`,
|
|
131
|
-
c: `#include <stdio.h>
|
|
132
|
-
|
|
133
|
-
int main() {
|
|
134
|
-
printf("Hello, World!\\n");
|
|
135
|
-
return 0;
|
|
136
|
-
}`,
|
|
137
|
-
cpp: `#include <iostream>
|
|
138
|
-
|
|
139
|
-
int main() {
|
|
140
|
-
std::cout << "Hello, World!" << std::endl;
|
|
141
|
-
return 0;
|
|
142
|
-
}`,
|
|
143
|
-
csharp: `using System;
|
|
144
|
-
|
|
145
|
-
class Main {
|
|
146
|
-
static void Main() {
|
|
147
|
-
Console.WriteLine("Hello, World!");
|
|
148
|
-
}
|
|
149
|
-
}`,
|
|
150
|
-
ruby: 'puts "Hello, World!"',
|
|
151
|
-
php: `<?php
|
|
152
|
-
echo "Hello, World!";
|
|
153
|
-
?>`,
|
|
154
|
-
bash: 'echo "Hello, World!"',
|
|
155
|
-
shell: 'echo "Hello, World!"',
|
|
156
|
-
perl: 'print "Hello, World!\\n";',
|
|
157
|
-
lua: 'print("Hello, World!")',
|
|
158
|
-
r: 'print("Hello, World!")',
|
|
159
|
-
swift: 'print("Hello, World!")',
|
|
160
|
-
kotlin: `fun main() {
|
|
161
|
-
println("Hello, World!")
|
|
162
|
-
}`,
|
|
163
|
-
scala: `object Main extends App {
|
|
164
|
-
println("Hello, World!")
|
|
165
|
-
}`,
|
|
166
|
-
haskell: 'main = putStrLn "Hello, World!"',
|
|
167
|
-
elixir: 'IO.puts "Hello, World!"',
|
|
168
|
-
erlang: 'main() -> io:fwrite("Hello, World!~n").',
|
|
169
|
-
clojure: '(println "Hello, World!")',
|
|
170
|
-
fsharp: 'printfn "Hello, World!"',
|
|
171
|
-
dart: `void main() {
|
|
172
|
-
print("Hello, World!");
|
|
173
|
-
}`,
|
|
174
|
-
assembly: `section .data
|
|
175
|
-
msg db 'Hello, World!', 0
|
|
176
|
-
section .text
|
|
177
|
-
global _start
|
|
178
|
-
_start:
|
|
179
|
-
mov rax, 1
|
|
180
|
-
mov rdi, 1
|
|
181
|
-
mov rsi, msg
|
|
182
|
-
mov rdx, 13
|
|
183
|
-
syscall
|
|
184
|
-
mov rax, 60
|
|
185
|
-
xor rdi, rdi
|
|
186
|
-
syscall`,
|
|
187
|
-
html: `<!DOCTYPE html>
|
|
188
|
-
<html>
|
|
189
|
-
<head>
|
|
190
|
-
<title>Hello</title>
|
|
191
|
-
</head>
|
|
192
|
-
<body>
|
|
193
|
-
<h1>Hello, World!</h1>
|
|
194
|
-
</body>
|
|
195
|
-
</html>`,
|
|
196
|
-
css: `body {
|
|
197
|
-
background-color: #f0f0f0;
|
|
198
|
-
font-family: Arial, sans-serif;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
h1 {
|
|
202
|
-
color: #333;
|
|
203
|
-
}`,
|
|
204
|
-
sql: "SELECT 'Hello, World!' AS message;",
|
|
205
|
-
markdown: `# Hello, World!
|
|
206
|
-
|
|
207
|
-
This is a sample markdown document.`
|
|
208
|
-
};
|
|
209
|
-
function W(r) {
|
|
210
|
-
const e = r.toLowerCase();
|
|
211
|
-
return oe[e] || `// ${r}
|
|
212
|
-
// Write your code here`;
|
|
213
|
-
}
|
|
214
|
-
var J = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
215
|
-
function le(r) {
|
|
216
|
-
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
217
|
-
}
|
|
218
|
-
var Q = { exports: {} };
|
|
219
|
-
(function(r) {
|
|
220
|
-
var e = typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {};
|
|
221
|
-
/**
|
|
222
|
-
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
223
|
-
*
|
|
224
|
-
* @license MIT <https://opensource.org/licenses/MIT>
|
|
225
|
-
* @author Lea Verou <https://lea.verou.me>
|
|
226
|
-
* @namespace
|
|
227
|
-
* @public
|
|
228
|
-
*/
|
|
229
|
-
var t = function(l) {
|
|
230
|
-
var p = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, f = 0, m = {}, u = {
|
|
231
|
-
/**
|
|
232
|
-
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
233
|
-
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
234
|
-
* additional languages or plugins yourself.
|
|
235
|
-
*
|
|
236
|
-
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
|
237
|
-
*
|
|
238
|
-
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
|
239
|
-
* empty Prism object into the global scope before loading the Prism script like this:
|
|
240
|
-
*
|
|
241
|
-
* ```js
|
|
242
|
-
* window.Prism = window.Prism || {};
|
|
243
|
-
* Prism.manual = true;
|
|
244
|
-
* // add a new <script> to load Prism's script
|
|
245
|
-
* ```
|
|
246
|
-
*
|
|
247
|
-
* @default false
|
|
248
|
-
* @type {boolean}
|
|
249
|
-
* @memberof Prism
|
|
250
|
-
* @public
|
|
251
|
-
*/
|
|
252
|
-
manual: l.Prism && l.Prism.manual,
|
|
253
|
-
/**
|
|
254
|
-
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
255
|
-
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
256
|
-
* own worker, you don't want it to do this.
|
|
257
|
-
*
|
|
258
|
-
* By setting this value to `true`, Prism will not add its own listeners to the worker.
|
|
259
|
-
*
|
|
260
|
-
* You obviously have to change this value before Prism executes. To do this, you can add an
|
|
261
|
-
* empty Prism object into the global scope before loading the Prism script like this:
|
|
262
|
-
*
|
|
263
|
-
* ```js
|
|
264
|
-
* window.Prism = window.Prism || {};
|
|
265
|
-
* Prism.disableWorkerMessageHandler = true;
|
|
266
|
-
* // Load Prism's script
|
|
267
|
-
* ```
|
|
268
|
-
*
|
|
269
|
-
* @default false
|
|
270
|
-
* @type {boolean}
|
|
271
|
-
* @memberof Prism
|
|
272
|
-
* @public
|
|
273
|
-
*/
|
|
274
|
-
disableWorkerMessageHandler: l.Prism && l.Prism.disableWorkerMessageHandler,
|
|
275
|
-
/**
|
|
276
|
-
* A namespace for utility methods.
|
|
277
|
-
*
|
|
278
|
-
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
279
|
-
* change or disappear at any time.
|
|
280
|
-
*
|
|
281
|
-
* @namespace
|
|
282
|
-
* @memberof Prism
|
|
283
|
-
*/
|
|
284
|
-
util: {
|
|
285
|
-
encode: function a(n) {
|
|
286
|
-
return n instanceof g ? new g(n.type, a(n.content), n.alias) : Array.isArray(n) ? n.map(a) : n.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
287
|
-
},
|
|
288
|
-
/**
|
|
289
|
-
* Returns the name of the type of the given value.
|
|
290
|
-
*
|
|
291
|
-
* @param {any} o
|
|
292
|
-
* @returns {string}
|
|
293
|
-
* @example
|
|
294
|
-
* type(null) === 'Null'
|
|
295
|
-
* type(undefined) === 'Undefined'
|
|
296
|
-
* type(123) === 'Number'
|
|
297
|
-
* type('foo') === 'String'
|
|
298
|
-
* type(true) === 'Boolean'
|
|
299
|
-
* type([1, 2]) === 'Array'
|
|
300
|
-
* type({}) === 'Object'
|
|
301
|
-
* type(String) === 'Function'
|
|
302
|
-
* type(/abc+/) === 'RegExp'
|
|
303
|
-
*/
|
|
304
|
-
type: function(a) {
|
|
305
|
-
return Object.prototype.toString.call(a).slice(8, -1);
|
|
306
|
-
},
|
|
307
|
-
/**
|
|
308
|
-
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
309
|
-
*
|
|
310
|
-
* @param {Object} obj
|
|
311
|
-
* @returns {number}
|
|
312
|
-
*/
|
|
313
|
-
objId: function(a) {
|
|
314
|
-
return a.__id || Object.defineProperty(a, "__id", { value: ++f }), a.__id;
|
|
315
|
-
},
|
|
316
|
-
/**
|
|
317
|
-
* Creates a deep clone of the given object.
|
|
318
|
-
*
|
|
319
|
-
* The main intended use of this function is to clone language definitions.
|
|
320
|
-
*
|
|
321
|
-
* @param {T} o
|
|
322
|
-
* @param {Record<number, any>} [visited]
|
|
323
|
-
* @returns {T}
|
|
324
|
-
* @template T
|
|
325
|
-
*/
|
|
326
|
-
clone: function a(n, i) {
|
|
327
|
-
i = i || {};
|
|
328
|
-
var s, o;
|
|
329
|
-
switch (u.util.type(n)) {
|
|
330
|
-
case "Object":
|
|
331
|
-
if (o = u.util.objId(n), i[o])
|
|
332
|
-
return i[o];
|
|
333
|
-
s = /** @type {Record<string, any>} */
|
|
334
|
-
{}, i[o] = s;
|
|
335
|
-
for (var d in n)
|
|
336
|
-
n.hasOwnProperty(d) && (s[d] = a(n[d], i));
|
|
337
|
-
return (
|
|
338
|
-
/** @type {any} */
|
|
339
|
-
s
|
|
340
|
-
);
|
|
341
|
-
case "Array":
|
|
342
|
-
return o = u.util.objId(n), i[o] ? i[o] : (s = [], i[o] = s, /** @type {Array} */
|
|
343
|
-
/** @type {any} */
|
|
344
|
-
n.forEach(function(h, c) {
|
|
345
|
-
s[c] = a(h, i);
|
|
346
|
-
}), /** @type {any} */
|
|
347
|
-
s);
|
|
348
|
-
default:
|
|
349
|
-
return n;
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
/**
|
|
353
|
-
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
|
354
|
-
*
|
|
355
|
-
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
|
356
|
-
*
|
|
357
|
-
* @param {Element} element
|
|
358
|
-
* @returns {string}
|
|
359
|
-
*/
|
|
360
|
-
getLanguage: function(a) {
|
|
361
|
-
for (; a; ) {
|
|
362
|
-
var n = p.exec(a.className);
|
|
363
|
-
if (n)
|
|
364
|
-
return n[1].toLowerCase();
|
|
365
|
-
a = a.parentElement;
|
|
366
|
-
}
|
|
367
|
-
return "none";
|
|
368
|
-
},
|
|
369
|
-
/**
|
|
370
|
-
* Sets the Prism `language-xxxx` class of the given element.
|
|
371
|
-
*
|
|
372
|
-
* @param {Element} element
|
|
373
|
-
* @param {string} language
|
|
374
|
-
* @returns {void}
|
|
375
|
-
*/
|
|
376
|
-
setLanguage: function(a, n) {
|
|
377
|
-
a.className = a.className.replace(RegExp(p, "gi"), ""), a.classList.add("language-" + n);
|
|
378
|
-
},
|
|
379
|
-
/**
|
|
380
|
-
* Returns the script element that is currently executing.
|
|
381
|
-
*
|
|
382
|
-
* This does __not__ work for line script element.
|
|
383
|
-
*
|
|
384
|
-
* @returns {HTMLScriptElement | null}
|
|
385
|
-
*/
|
|
386
|
-
currentScript: function() {
|
|
387
|
-
if (typeof document > "u")
|
|
388
|
-
return null;
|
|
389
|
-
if (document.currentScript && document.currentScript.tagName === "SCRIPT")
|
|
390
|
-
return (
|
|
391
|
-
/** @type {any} */
|
|
392
|
-
document.currentScript
|
|
393
|
-
);
|
|
394
|
-
try {
|
|
395
|
-
throw new Error();
|
|
396
|
-
} catch (s) {
|
|
397
|
-
var a = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(s.stack) || [])[1];
|
|
398
|
-
if (a) {
|
|
399
|
-
var n = document.getElementsByTagName("script");
|
|
400
|
-
for (var i in n)
|
|
401
|
-
if (n[i].src == a)
|
|
402
|
-
return n[i];
|
|
403
|
-
}
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
},
|
|
407
|
-
/**
|
|
408
|
-
* Returns whether a given class is active for `element`.
|
|
409
|
-
*
|
|
410
|
-
* The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
|
|
411
|
-
* if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
|
|
412
|
-
* given class is just the given class with a `no-` prefix.
|
|
413
|
-
*
|
|
414
|
-
* Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
|
|
415
|
-
* closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
|
|
416
|
-
* ancestors have the given class or the negated version of it, then the default activation will be returned.
|
|
417
|
-
*
|
|
418
|
-
* In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
|
|
419
|
-
* version of it, the class is considered active.
|
|
420
|
-
*
|
|
421
|
-
* @param {Element} element
|
|
422
|
-
* @param {string} className
|
|
423
|
-
* @param {boolean} [defaultActivation=false]
|
|
424
|
-
* @returns {boolean}
|
|
425
|
-
*/
|
|
426
|
-
isActive: function(a, n, i) {
|
|
427
|
-
for (var s = "no-" + n; a; ) {
|
|
428
|
-
var o = a.classList;
|
|
429
|
-
if (o.contains(n))
|
|
430
|
-
return !0;
|
|
431
|
-
if (o.contains(s))
|
|
432
|
-
return !1;
|
|
433
|
-
a = a.parentElement;
|
|
434
|
-
}
|
|
435
|
-
return !!i;
|
|
436
|
-
}
|
|
437
|
-
},
|
|
438
|
-
/**
|
|
439
|
-
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
|
440
|
-
*
|
|
441
|
-
* @namespace
|
|
442
|
-
* @memberof Prism
|
|
443
|
-
* @public
|
|
444
|
-
*/
|
|
445
|
-
languages: {
|
|
446
|
-
/**
|
|
447
|
-
* The grammar for plain, unformatted text.
|
|
448
|
-
*/
|
|
449
|
-
plain: m,
|
|
450
|
-
plaintext: m,
|
|
451
|
-
text: m,
|
|
452
|
-
txt: m,
|
|
453
|
-
/**
|
|
454
|
-
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
455
|
-
*
|
|
456
|
-
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
|
457
|
-
* will be overwritten at its original position.
|
|
458
|
-
*
|
|
459
|
-
* ## Best practices
|
|
460
|
-
*
|
|
461
|
-
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
|
462
|
-
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
|
463
|
-
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
|
464
|
-
*
|
|
465
|
-
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
|
466
|
-
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
|
467
|
-
*
|
|
468
|
-
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
|
469
|
-
* @param {Grammar} redef The new tokens to append.
|
|
470
|
-
* @returns {Grammar} The new language created.
|
|
471
|
-
* @public
|
|
472
|
-
* @example
|
|
473
|
-
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
|
474
|
-
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
|
475
|
-
* // at its original position
|
|
476
|
-
* 'comment': { ... },
|
|
477
|
-
* // CSS doesn't have a 'color' token, so this token will be appended
|
|
478
|
-
* 'color': /\b(?:red|green|blue)\b/
|
|
479
|
-
* });
|
|
480
|
-
*/
|
|
481
|
-
extend: function(a, n) {
|
|
482
|
-
var i = u.util.clone(u.languages[a]);
|
|
483
|
-
for (var s in n)
|
|
484
|
-
i[s] = n[s];
|
|
485
|
-
return i;
|
|
486
|
-
},
|
|
487
|
-
/**
|
|
488
|
-
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
489
|
-
*
|
|
490
|
-
* ## Usage
|
|
491
|
-
*
|
|
492
|
-
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
|
493
|
-
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
|
494
|
-
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
|
495
|
-
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
|
496
|
-
* this:
|
|
497
|
-
*
|
|
498
|
-
* ```js
|
|
499
|
-
* Prism.languages.markup.style = {
|
|
500
|
-
* // token
|
|
501
|
-
* };
|
|
502
|
-
* ```
|
|
503
|
-
*
|
|
504
|
-
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
|
505
|
-
* before existing tokens. For the CSS example above, you would use it like this:
|
|
506
|
-
*
|
|
507
|
-
* ```js
|
|
508
|
-
* Prism.languages.insertBefore('markup', 'cdata', {
|
|
509
|
-
* 'style': {
|
|
510
|
-
* // token
|
|
511
|
-
* }
|
|
512
|
-
* });
|
|
513
|
-
* ```
|
|
514
|
-
*
|
|
515
|
-
* ## Special cases
|
|
516
|
-
*
|
|
517
|
-
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
|
518
|
-
* will be ignored.
|
|
519
|
-
*
|
|
520
|
-
* This behavior can be used to insert tokens after `before`:
|
|
521
|
-
*
|
|
522
|
-
* ```js
|
|
523
|
-
* Prism.languages.insertBefore('markup', 'comment', {
|
|
524
|
-
* 'comment': Prism.languages.markup.comment,
|
|
525
|
-
* // tokens after 'comment'
|
|
526
|
-
* });
|
|
527
|
-
* ```
|
|
528
|
-
*
|
|
529
|
-
* ## Limitations
|
|
530
|
-
*
|
|
531
|
-
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
|
532
|
-
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
|
533
|
-
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
|
534
|
-
* deleting properties which is necessary to insert at arbitrary positions.
|
|
535
|
-
*
|
|
536
|
-
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
|
537
|
-
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
|
538
|
-
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
|
539
|
-
*
|
|
540
|
-
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
|
541
|
-
* you hold the target object in a variable, then the value of the variable will not change.
|
|
542
|
-
*
|
|
543
|
-
* ```js
|
|
544
|
-
* var oldMarkup = Prism.languages.markup;
|
|
545
|
-
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
|
546
|
-
*
|
|
547
|
-
* assert(oldMarkup !== Prism.languages.markup);
|
|
548
|
-
* assert(newMarkup === Prism.languages.markup);
|
|
549
|
-
* ```
|
|
550
|
-
*
|
|
551
|
-
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
|
552
|
-
* object to be modified.
|
|
553
|
-
* @param {string} before The key to insert before.
|
|
554
|
-
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
|
555
|
-
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
|
556
|
-
* object to be modified.
|
|
557
|
-
*
|
|
558
|
-
* Defaults to `Prism.languages`.
|
|
559
|
-
* @returns {Grammar} The new grammar object.
|
|
560
|
-
* @public
|
|
561
|
-
*/
|
|
562
|
-
insertBefore: function(a, n, i, s) {
|
|
563
|
-
s = s || /** @type {any} */
|
|
564
|
-
u.languages;
|
|
565
|
-
var o = s[a], d = {};
|
|
566
|
-
for (var h in o)
|
|
567
|
-
if (o.hasOwnProperty(h)) {
|
|
568
|
-
if (h == n)
|
|
569
|
-
for (var c in i)
|
|
570
|
-
i.hasOwnProperty(c) && (d[c] = i[c]);
|
|
571
|
-
i.hasOwnProperty(h) || (d[h] = o[h]);
|
|
572
|
-
}
|
|
573
|
-
var v = s[a];
|
|
574
|
-
return s[a] = d, u.languages.DFS(u.languages, function(A, R) {
|
|
575
|
-
R === v && A != a && (this[A] = d);
|
|
576
|
-
}), d;
|
|
577
|
-
},
|
|
578
|
-
// Traverse a language definition with Depth First Search
|
|
579
|
-
DFS: function a(n, i, s, o) {
|
|
580
|
-
o = o || {};
|
|
581
|
-
var d = u.util.objId;
|
|
582
|
-
for (var h in n)
|
|
583
|
-
if (n.hasOwnProperty(h)) {
|
|
584
|
-
i.call(n, h, n[h], s || h);
|
|
585
|
-
var c = n[h], v = u.util.type(c);
|
|
586
|
-
v === "Object" && !o[d(c)] ? (o[d(c)] = !0, a(c, i, null, o)) : v === "Array" && !o[d(c)] && (o[d(c)] = !0, a(c, i, h, o));
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
},
|
|
590
|
-
plugins: {},
|
|
591
|
-
/**
|
|
592
|
-
* This is the most high-level function in Prism’s API.
|
|
593
|
-
* It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
|
|
594
|
-
* each one of them.
|
|
595
|
-
*
|
|
596
|
-
* This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
|
|
597
|
-
*
|
|
598
|
-
* @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
|
|
599
|
-
* @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
|
|
600
|
-
* @memberof Prism
|
|
601
|
-
* @public
|
|
602
|
-
*/
|
|
603
|
-
highlightAll: function(a, n) {
|
|
604
|
-
u.highlightAllUnder(document, a, n);
|
|
605
|
-
},
|
|
606
|
-
/**
|
|
607
|
-
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
608
|
-
* {@link Prism.highlightElement} on each one of them.
|
|
609
|
-
*
|
|
610
|
-
* The following hooks will be run:
|
|
611
|
-
* 1. `before-highlightall`
|
|
612
|
-
* 2. `before-all-elements-highlight`
|
|
613
|
-
* 3. All hooks of {@link Prism.highlightElement} for each element.
|
|
614
|
-
*
|
|
615
|
-
* @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
|
|
616
|
-
* @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
|
|
617
|
-
* @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
|
|
618
|
-
* @memberof Prism
|
|
619
|
-
* @public
|
|
620
|
-
*/
|
|
621
|
-
highlightAllUnder: function(a, n, i) {
|
|
622
|
-
var s = {
|
|
623
|
-
callback: i,
|
|
624
|
-
container: a,
|
|
625
|
-
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
626
|
-
};
|
|
627
|
-
u.hooks.run("before-highlightall", s), s.elements = Array.prototype.slice.apply(s.container.querySelectorAll(s.selector)), u.hooks.run("before-all-elements-highlight", s);
|
|
628
|
-
for (var o = 0, d; d = s.elements[o++]; )
|
|
629
|
-
u.highlightElement(d, n === !0, s.callback);
|
|
630
|
-
},
|
|
631
|
-
/**
|
|
632
|
-
* Highlights the code inside a single element.
|
|
633
|
-
*
|
|
634
|
-
* The following hooks will be run:
|
|
635
|
-
* 1. `before-sanity-check`
|
|
636
|
-
* 2. `before-highlight`
|
|
637
|
-
* 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
|
|
638
|
-
* 4. `before-insert`
|
|
639
|
-
* 5. `after-highlight`
|
|
640
|
-
* 6. `complete`
|
|
641
|
-
*
|
|
642
|
-
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
|
|
643
|
-
* the element's language.
|
|
644
|
-
*
|
|
645
|
-
* @param {Element} element The element containing the code.
|
|
646
|
-
* It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
|
|
647
|
-
* @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
|
|
648
|
-
* to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
|
|
649
|
-
* [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
|
|
650
|
-
*
|
|
651
|
-
* Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
|
|
652
|
-
* asynchronous highlighting to work. You can build your own bundle on the
|
|
653
|
-
* [Download page](https://prismjs.com/download.html).
|
|
654
|
-
* @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
|
|
655
|
-
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
|
|
656
|
-
* @memberof Prism
|
|
657
|
-
* @public
|
|
658
|
-
*/
|
|
659
|
-
highlightElement: function(a, n, i) {
|
|
660
|
-
var s = u.util.getLanguage(a), o = u.languages[s];
|
|
661
|
-
u.util.setLanguage(a, s);
|
|
662
|
-
var d = a.parentElement;
|
|
663
|
-
d && d.nodeName.toLowerCase() === "pre" && u.util.setLanguage(d, s);
|
|
664
|
-
var h = a.textContent, c = {
|
|
665
|
-
element: a,
|
|
666
|
-
language: s,
|
|
667
|
-
grammar: o,
|
|
668
|
-
code: h
|
|
669
|
-
};
|
|
670
|
-
function v(R) {
|
|
671
|
-
c.highlightedCode = R, u.hooks.run("before-insert", c), c.element.innerHTML = c.highlightedCode, u.hooks.run("after-highlight", c), u.hooks.run("complete", c), i && i.call(c.element);
|
|
672
|
-
}
|
|
673
|
-
if (u.hooks.run("before-sanity-check", c), d = c.element.parentElement, d && d.nodeName.toLowerCase() === "pre" && !d.hasAttribute("tabindex") && d.setAttribute("tabindex", "0"), !c.code) {
|
|
674
|
-
u.hooks.run("complete", c), i && i.call(c.element);
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
if (u.hooks.run("before-highlight", c), !c.grammar) {
|
|
678
|
-
v(u.util.encode(c.code));
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
if (n && l.Worker) {
|
|
682
|
-
var A = new Worker(u.filename);
|
|
683
|
-
A.onmessage = function(R) {
|
|
684
|
-
v(R.data);
|
|
685
|
-
}, A.postMessage(JSON.stringify({
|
|
686
|
-
language: c.language,
|
|
687
|
-
code: c.code,
|
|
688
|
-
immediateClose: !0
|
|
689
|
-
}));
|
|
690
|
-
} else
|
|
691
|
-
v(u.highlight(c.code, c.grammar, c.language));
|
|
692
|
-
},
|
|
693
|
-
/**
|
|
694
|
-
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
695
|
-
* and the language definitions to use, and returns a string with the HTML produced.
|
|
696
|
-
*
|
|
697
|
-
* The following hooks will be run:
|
|
698
|
-
* 1. `before-tokenize`
|
|
699
|
-
* 2. `after-tokenize`
|
|
700
|
-
* 3. `wrap`: On each {@link Token}.
|
|
701
|
-
*
|
|
702
|
-
* @param {string} text A string with the code to be highlighted.
|
|
703
|
-
* @param {Grammar} grammar An object containing the tokens to use.
|
|
704
|
-
*
|
|
705
|
-
* Usually a language definition like `Prism.languages.markup`.
|
|
706
|
-
* @param {string} language The name of the language definition passed to `grammar`.
|
|
707
|
-
* @returns {string} The highlighted HTML.
|
|
708
|
-
* @memberof Prism
|
|
709
|
-
* @public
|
|
710
|
-
* @example
|
|
711
|
-
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
712
|
-
*/
|
|
713
|
-
highlight: function(a, n, i) {
|
|
714
|
-
var s = {
|
|
715
|
-
code: a,
|
|
716
|
-
grammar: n,
|
|
717
|
-
language: i
|
|
718
|
-
};
|
|
719
|
-
if (u.hooks.run("before-tokenize", s), !s.grammar)
|
|
720
|
-
throw new Error('The language "' + s.language + '" has no grammar.');
|
|
721
|
-
return s.tokens = u.tokenize(s.code, s.grammar), u.hooks.run("after-tokenize", s), g.stringify(u.util.encode(s.tokens), s.language);
|
|
722
|
-
},
|
|
723
|
-
/**
|
|
724
|
-
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
725
|
-
* and the language definitions to use, and returns an array with the tokenized code.
|
|
726
|
-
*
|
|
727
|
-
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
|
728
|
-
*
|
|
729
|
-
* This method could be useful in other contexts as well, as a very crude parser.
|
|
730
|
-
*
|
|
731
|
-
* @param {string} text A string with the code to be highlighted.
|
|
732
|
-
* @param {Grammar} grammar An object containing the tokens to use.
|
|
733
|
-
*
|
|
734
|
-
* Usually a language definition like `Prism.languages.markup`.
|
|
735
|
-
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
|
736
|
-
* @memberof Prism
|
|
737
|
-
* @public
|
|
738
|
-
* @example
|
|
739
|
-
* let code = `var foo = 0;`;
|
|
740
|
-
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
|
741
|
-
* tokens.forEach(token => {
|
|
742
|
-
* if (token instanceof Prism.Token && token.type === 'number') {
|
|
743
|
-
* console.log(`Found numeric literal: ${token.content}`);
|
|
744
|
-
* }
|
|
745
|
-
* });
|
|
746
|
-
*/
|
|
747
|
-
tokenize: function(a, n) {
|
|
748
|
-
var i = n.rest;
|
|
749
|
-
if (i) {
|
|
750
|
-
for (var s in i)
|
|
751
|
-
n[s] = i[s];
|
|
752
|
-
delete n.rest;
|
|
753
|
-
}
|
|
754
|
-
var o = new k();
|
|
755
|
-
return x(o, o.head, a), w(a, o, n, o.head, 0), O(o);
|
|
756
|
-
},
|
|
757
|
-
/**
|
|
758
|
-
* @namespace
|
|
759
|
-
* @memberof Prism
|
|
760
|
-
* @public
|
|
761
|
-
*/
|
|
762
|
-
hooks: {
|
|
763
|
-
all: {},
|
|
764
|
-
/**
|
|
765
|
-
* Adds the given callback to the list of callbacks for the given hook.
|
|
766
|
-
*
|
|
767
|
-
* The callback will be invoked when the hook it is registered for is run.
|
|
768
|
-
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
|
769
|
-
*
|
|
770
|
-
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
771
|
-
*
|
|
772
|
-
* @param {string} name The name of the hook.
|
|
773
|
-
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
774
|
-
* @public
|
|
775
|
-
*/
|
|
776
|
-
add: function(a, n) {
|
|
777
|
-
var i = u.hooks.all;
|
|
778
|
-
i[a] = i[a] || [], i[a].push(n);
|
|
779
|
-
},
|
|
780
|
-
/**
|
|
781
|
-
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
782
|
-
*
|
|
783
|
-
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
784
|
-
*
|
|
785
|
-
* @param {string} name The name of the hook.
|
|
786
|
-
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
787
|
-
* @public
|
|
788
|
-
*/
|
|
789
|
-
run: function(a, n) {
|
|
790
|
-
var i = u.hooks.all[a];
|
|
791
|
-
if (!(!i || !i.length))
|
|
792
|
-
for (var s = 0, o; o = i[s++]; )
|
|
793
|
-
o(n);
|
|
794
|
-
}
|
|
795
|
-
},
|
|
796
|
-
Token: g
|
|
797
|
-
};
|
|
798
|
-
l.Prism = u;
|
|
799
|
-
function g(a, n, i, s) {
|
|
800
|
-
this.type = a, this.content = n, this.alias = i, this.length = (s || "").length | 0;
|
|
801
|
-
}
|
|
802
|
-
g.stringify = function a(n, i) {
|
|
803
|
-
if (typeof n == "string")
|
|
804
|
-
return n;
|
|
805
|
-
if (Array.isArray(n)) {
|
|
806
|
-
var s = "";
|
|
807
|
-
return n.forEach(function(v) {
|
|
808
|
-
s += a(v, i);
|
|
809
|
-
}), s;
|
|
810
|
-
}
|
|
811
|
-
var o = {
|
|
812
|
-
type: n.type,
|
|
813
|
-
content: a(n.content, i),
|
|
814
|
-
tag: "span",
|
|
815
|
-
classes: ["token", n.type],
|
|
816
|
-
attributes: {},
|
|
817
|
-
language: i
|
|
818
|
-
}, d = n.alias;
|
|
819
|
-
d && (Array.isArray(d) ? Array.prototype.push.apply(o.classes, d) : o.classes.push(d)), u.hooks.run("wrap", o);
|
|
820
|
-
var h = "";
|
|
821
|
-
for (var c in o.attributes)
|
|
822
|
-
h += " " + c + '="' + (o.attributes[c] || "").replace(/"/g, """) + '"';
|
|
823
|
-
return "<" + o.tag + ' class="' + o.classes.join(" ") + '"' + h + ">" + o.content + "</" + o.tag + ">";
|
|
824
|
-
};
|
|
825
|
-
function E(a, n, i, s) {
|
|
826
|
-
a.lastIndex = n;
|
|
827
|
-
var o = a.exec(i);
|
|
828
|
-
if (o && s && o[1]) {
|
|
829
|
-
var d = o[1].length;
|
|
830
|
-
o.index += d, o[0] = o[0].slice(d);
|
|
831
|
-
}
|
|
832
|
-
return o;
|
|
833
|
-
}
|
|
834
|
-
function w(a, n, i, s, o, d) {
|
|
835
|
-
for (var h in i)
|
|
836
|
-
if (!(!i.hasOwnProperty(h) || !i[h])) {
|
|
837
|
-
var c = i[h];
|
|
838
|
-
c = Array.isArray(c) ? c : [c];
|
|
839
|
-
for (var v = 0; v < c.length; ++v) {
|
|
840
|
-
if (d && d.cause == h + "," + v)
|
|
841
|
-
return;
|
|
842
|
-
var A = c[v], R = A.inside, X = !!A.lookbehind, Z = !!A.greedy, ee = A.alias;
|
|
843
|
-
if (Z && !A.pattern.global) {
|
|
844
|
-
var te = A.pattern.toString().match(/[imsuy]*$/)[0];
|
|
845
|
-
A.pattern = RegExp(A.pattern.source, te + "g");
|
|
846
|
-
}
|
|
847
|
-
for (var K = A.pattern || A, T = s.next, I = o; T !== n.tail && !(d && I >= d.reach); I += T.value.length, T = T.next) {
|
|
848
|
-
var C = T.value;
|
|
849
|
-
if (n.length > a.length)
|
|
850
|
-
return;
|
|
851
|
-
if (!(C instanceof g)) {
|
|
852
|
-
var N = 1, _;
|
|
853
|
-
if (Z) {
|
|
854
|
-
if (_ = E(K, I, a, X), !_ || _.index >= a.length)
|
|
855
|
-
break;
|
|
856
|
-
var D = _.index, re = _.index + _[0].length, F = I;
|
|
857
|
-
for (F += T.value.length; D >= F; )
|
|
858
|
-
T = T.next, F += T.value.length;
|
|
859
|
-
if (F -= T.value.length, I = F, T.value instanceof g)
|
|
860
|
-
continue;
|
|
861
|
-
for (var L = T; L !== n.tail && (F < re || typeof L.value == "string"); L = L.next)
|
|
862
|
-
N++, F += L.value.length;
|
|
863
|
-
N--, C = a.slice(I, F), _.index -= I;
|
|
864
|
-
} else if (_ = E(K, 0, C, X), !_)
|
|
865
|
-
continue;
|
|
866
|
-
var D = _.index, P = _[0], H = C.slice(0, D), V = C.slice(D + P.length), B = I + C.length;
|
|
867
|
-
d && B > d.reach && (d.reach = B);
|
|
868
|
-
var $ = T.prev;
|
|
869
|
-
H && ($ = x(n, $, H), I += H.length), U(n, $, N);
|
|
870
|
-
var ne = new g(h, R ? u.tokenize(P, R) : P, ee, P);
|
|
871
|
-
if (T = x(n, $, ne), V && x(n, T, V), N > 1) {
|
|
872
|
-
var G = {
|
|
873
|
-
cause: h + "," + v,
|
|
874
|
-
reach: B
|
|
875
|
-
};
|
|
876
|
-
w(a, n, i, T.prev, I, G), d && G.reach > d.reach && (d.reach = G.reach);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
function k() {
|
|
884
|
-
var a = { value: null, prev: null, next: null }, n = { value: null, prev: a, next: null };
|
|
885
|
-
a.next = n, this.head = a, this.tail = n, this.length = 0;
|
|
886
|
-
}
|
|
887
|
-
function x(a, n, i) {
|
|
888
|
-
var s = n.next, o = { value: i, prev: n, next: s };
|
|
889
|
-
return n.next = o, s.prev = o, a.length++, o;
|
|
890
|
-
}
|
|
891
|
-
function U(a, n, i) {
|
|
892
|
-
for (var s = n.next, o = 0; o < i && s !== a.tail; o++)
|
|
893
|
-
s = s.next;
|
|
894
|
-
n.next = s, s.prev = n, a.length -= o;
|
|
895
|
-
}
|
|
896
|
-
function O(a) {
|
|
897
|
-
for (var n = [], i = a.head.next; i !== a.tail; )
|
|
898
|
-
n.push(i.value), i = i.next;
|
|
899
|
-
return n;
|
|
900
|
-
}
|
|
901
|
-
if (!l.document)
|
|
902
|
-
return l.addEventListener && (u.disableWorkerMessageHandler || l.addEventListener("message", function(a) {
|
|
903
|
-
var n = JSON.parse(a.data), i = n.language, s = n.code, o = n.immediateClose;
|
|
904
|
-
l.postMessage(u.highlight(s, u.languages[i], i)), o && l.close();
|
|
905
|
-
}, !1)), u;
|
|
906
|
-
var y = u.util.currentScript();
|
|
907
|
-
y && (u.filename = y.src, y.hasAttribute("data-manual") && (u.manual = !0));
|
|
908
|
-
function b() {
|
|
909
|
-
u.manual || u.highlightAll();
|
|
910
|
-
}
|
|
911
|
-
if (!u.manual) {
|
|
912
|
-
var S = document.readyState;
|
|
913
|
-
S === "loading" || S === "interactive" && y && y.defer ? document.addEventListener("DOMContentLoaded", b) : window.requestAnimationFrame ? window.requestAnimationFrame(b) : window.setTimeout(b, 16);
|
|
914
|
-
}
|
|
915
|
-
return u;
|
|
916
|
-
}(e);
|
|
917
|
-
r.exports && (r.exports = t), typeof J < "u" && (J.Prism = t), t.languages.markup = {
|
|
918
|
-
comment: {
|
|
919
|
-
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
920
|
-
greedy: !0
|
|
921
|
-
},
|
|
922
|
-
prolog: {
|
|
923
|
-
pattern: /<\?[\s\S]+?\?>/,
|
|
924
|
-
greedy: !0
|
|
925
|
-
},
|
|
926
|
-
doctype: {
|
|
927
|
-
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
928
|
-
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
929
|
-
greedy: !0,
|
|
930
|
-
inside: {
|
|
931
|
-
"internal-subset": {
|
|
932
|
-
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
933
|
-
lookbehind: !0,
|
|
934
|
-
greedy: !0,
|
|
935
|
-
inside: null
|
|
936
|
-
// see below
|
|
937
|
-
},
|
|
938
|
-
string: {
|
|
939
|
-
pattern: /"[^"]*"|'[^']*'/,
|
|
940
|
-
greedy: !0
|
|
941
|
-
},
|
|
942
|
-
punctuation: /^<!|>$|[[\]]/,
|
|
943
|
-
"doctype-tag": /^DOCTYPE/i,
|
|
944
|
-
name: /[^\s<>'"]+/
|
|
945
|
-
}
|
|
946
|
-
},
|
|
947
|
-
cdata: {
|
|
948
|
-
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
949
|
-
greedy: !0
|
|
950
|
-
},
|
|
951
|
-
tag: {
|
|
952
|
-
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
953
|
-
greedy: !0,
|
|
954
|
-
inside: {
|
|
955
|
-
tag: {
|
|
956
|
-
pattern: /^<\/?[^\s>\/]+/,
|
|
957
|
-
inside: {
|
|
958
|
-
punctuation: /^<\/?/,
|
|
959
|
-
namespace: /^[^\s>\/:]+:/
|
|
960
|
-
}
|
|
961
|
-
},
|
|
962
|
-
"special-attr": [],
|
|
963
|
-
"attr-value": {
|
|
964
|
-
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
965
|
-
inside: {
|
|
966
|
-
punctuation: [
|
|
967
|
-
{
|
|
968
|
-
pattern: /^=/,
|
|
969
|
-
alias: "attr-equals"
|
|
970
|
-
},
|
|
971
|
-
{
|
|
972
|
-
pattern: /^(\s*)["']|["']$/,
|
|
973
|
-
lookbehind: !0
|
|
974
|
-
}
|
|
975
|
-
]
|
|
976
|
-
}
|
|
977
|
-
},
|
|
978
|
-
punctuation: /\/?>/,
|
|
979
|
-
"attr-name": {
|
|
980
|
-
pattern: /[^\s>\/]+/,
|
|
981
|
-
inside: {
|
|
982
|
-
namespace: /^[^\s>\/:]+:/
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
},
|
|
987
|
-
entity: [
|
|
988
|
-
{
|
|
989
|
-
pattern: /&[\da-z]{1,8};/i,
|
|
990
|
-
alias: "named-entity"
|
|
991
|
-
},
|
|
992
|
-
/&#x?[\da-f]{1,8};/i
|
|
993
|
-
]
|
|
994
|
-
}, t.languages.markup.tag.inside["attr-value"].inside.entity = t.languages.markup.entity, t.languages.markup.doctype.inside["internal-subset"].inside = t.languages.markup, t.hooks.add("wrap", function(l) {
|
|
995
|
-
l.type === "entity" && (l.attributes.title = l.content.replace(/&/, "&"));
|
|
996
|
-
}), Object.defineProperty(t.languages.markup.tag, "addInlined", {
|
|
997
|
-
/**
|
|
998
|
-
* Adds an inlined language to markup.
|
|
999
|
-
*
|
|
1000
|
-
* An example of an inlined language is CSS with `<style>` tags.
|
|
1001
|
-
*
|
|
1002
|
-
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
|
1003
|
-
* case insensitive.
|
|
1004
|
-
* @param {string} lang The language key.
|
|
1005
|
-
* @example
|
|
1006
|
-
* addInlined('style', 'css');
|
|
1007
|
-
*/
|
|
1008
|
-
value: function(p, f) {
|
|
1009
|
-
var m = {};
|
|
1010
|
-
m["language-" + f] = {
|
|
1011
|
-
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1012
|
-
lookbehind: !0,
|
|
1013
|
-
inside: t.languages[f]
|
|
1014
|
-
}, m.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
1015
|
-
var u = {
|
|
1016
|
-
"included-cdata": {
|
|
1017
|
-
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1018
|
-
inside: m
|
|
1019
|
-
}
|
|
1020
|
-
};
|
|
1021
|
-
u["language-" + f] = {
|
|
1022
|
-
pattern: /[\s\S]+/,
|
|
1023
|
-
inside: t.languages[f]
|
|
1024
|
-
};
|
|
1025
|
-
var g = {};
|
|
1026
|
-
g[p] = {
|
|
1027
|
-
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1028
|
-
return p;
|
|
1029
|
-
}), "i"),
|
|
1030
|
-
lookbehind: !0,
|
|
1031
|
-
greedy: !0,
|
|
1032
|
-
inside: u
|
|
1033
|
-
}, t.languages.insertBefore("markup", "cdata", g);
|
|
1034
|
-
}
|
|
1035
|
-
}), Object.defineProperty(t.languages.markup.tag, "addAttribute", {
|
|
1036
|
-
/**
|
|
1037
|
-
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
1038
|
-
*
|
|
1039
|
-
* An example of an inlined language is CSS with `style` attributes.
|
|
1040
|
-
*
|
|
1041
|
-
* @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
|
|
1042
|
-
* case insensitive.
|
|
1043
|
-
* @param {string} lang The language key.
|
|
1044
|
-
* @example
|
|
1045
|
-
* addAttribute('style', 'css');
|
|
1046
|
-
*/
|
|
1047
|
-
value: function(l, p) {
|
|
1048
|
-
t.languages.markup.tag.inside["special-attr"].push({
|
|
1049
|
-
pattern: RegExp(
|
|
1050
|
-
/(^|["'\s])/.source + "(?:" + l + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1051
|
-
"i"
|
|
1052
|
-
),
|
|
1053
|
-
lookbehind: !0,
|
|
1054
|
-
inside: {
|
|
1055
|
-
"attr-name": /^[^\s=]+/,
|
|
1056
|
-
"attr-value": {
|
|
1057
|
-
pattern: /=[\s\S]+/,
|
|
1058
|
-
inside: {
|
|
1059
|
-
value: {
|
|
1060
|
-
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1061
|
-
lookbehind: !0,
|
|
1062
|
-
alias: [p, "language-" + p],
|
|
1063
|
-
inside: t.languages[p]
|
|
1064
|
-
},
|
|
1065
|
-
punctuation: [
|
|
1066
|
-
{
|
|
1067
|
-
pattern: /^=/,
|
|
1068
|
-
alias: "attr-equals"
|
|
1069
|
-
},
|
|
1070
|
-
/"|'/
|
|
1071
|
-
]
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
}), t.languages.html = t.languages.markup, t.languages.mathml = t.languages.markup, t.languages.svg = t.languages.markup, t.languages.xml = t.languages.extend("markup", {}), t.languages.ssml = t.languages.xml, t.languages.atom = t.languages.xml, t.languages.rss = t.languages.xml, function(l) {
|
|
1078
|
-
var p = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1079
|
-
l.languages.css = {
|
|
1080
|
-
comment: /\/\*[\s\S]*?\*\//,
|
|
1081
|
-
atrule: {
|
|
1082
|
-
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + p.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1083
|
-
inside: {
|
|
1084
|
-
rule: /^@[\w-]+/,
|
|
1085
|
-
"selector-function-argument": {
|
|
1086
|
-
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
1087
|
-
lookbehind: !0,
|
|
1088
|
-
alias: "selector"
|
|
1089
|
-
},
|
|
1090
|
-
keyword: {
|
|
1091
|
-
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
1092
|
-
lookbehind: !0
|
|
1093
|
-
}
|
|
1094
|
-
// See rest below
|
|
1095
|
-
}
|
|
1096
|
-
},
|
|
1097
|
-
url: {
|
|
1098
|
-
// https://drafts.csswg.org/css-values-3/#urls
|
|
1099
|
-
pattern: RegExp("\\burl\\((?:" + p.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1100
|
-
greedy: !0,
|
|
1101
|
-
inside: {
|
|
1102
|
-
function: /^url/i,
|
|
1103
|
-
punctuation: /^\(|\)$/,
|
|
1104
|
-
string: {
|
|
1105
|
-
pattern: RegExp("^" + p.source + "$"),
|
|
1106
|
-
alias: "url"
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
},
|
|
1110
|
-
selector: {
|
|
1111
|
-
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + p.source + ")*(?=\\s*\\{)"),
|
|
1112
|
-
lookbehind: !0
|
|
1113
|
-
},
|
|
1114
|
-
string: {
|
|
1115
|
-
pattern: p,
|
|
1116
|
-
greedy: !0
|
|
1117
|
-
},
|
|
1118
|
-
property: {
|
|
1119
|
-
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
1120
|
-
lookbehind: !0
|
|
1121
|
-
},
|
|
1122
|
-
important: /!important\b/i,
|
|
1123
|
-
function: {
|
|
1124
|
-
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
1125
|
-
lookbehind: !0
|
|
1126
|
-
},
|
|
1127
|
-
punctuation: /[(){};:,]/
|
|
1128
|
-
}, l.languages.css.atrule.inside.rest = l.languages.css;
|
|
1129
|
-
var f = l.languages.markup;
|
|
1130
|
-
f && (f.tag.addInlined("style", "css"), f.tag.addAttribute("style", "css"));
|
|
1131
|
-
}(t), t.languages.clike = {
|
|
1132
|
-
comment: [
|
|
1133
|
-
{
|
|
1134
|
-
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1135
|
-
lookbehind: !0,
|
|
1136
|
-
greedy: !0
|
|
1137
|
-
},
|
|
1138
|
-
{
|
|
1139
|
-
pattern: /(^|[^\\:])\/\/.*/,
|
|
1140
|
-
lookbehind: !0,
|
|
1141
|
-
greedy: !0
|
|
1142
|
-
}
|
|
1143
|
-
],
|
|
1144
|
-
string: {
|
|
1145
|
-
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
1146
|
-
greedy: !0
|
|
1147
|
-
},
|
|
1148
|
-
"class-name": {
|
|
1149
|
-
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
1150
|
-
lookbehind: !0,
|
|
1151
|
-
inside: {
|
|
1152
|
-
punctuation: /[.\\]/
|
|
1153
|
-
}
|
|
1154
|
-
},
|
|
1155
|
-
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
1156
|
-
boolean: /\b(?:false|true)\b/,
|
|
1157
|
-
function: /\b\w+(?=\()/,
|
|
1158
|
-
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
1159
|
-
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
1160
|
-
punctuation: /[{}[\];(),.:]/
|
|
1161
|
-
}, t.languages.javascript = t.languages.extend("clike", {
|
|
1162
|
-
"class-name": [
|
|
1163
|
-
t.languages.clike["class-name"],
|
|
1164
|
-
{
|
|
1165
|
-
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
1166
|
-
lookbehind: !0
|
|
1167
|
-
}
|
|
1168
|
-
],
|
|
1169
|
-
keyword: [
|
|
1170
|
-
{
|
|
1171
|
-
pattern: /((?:^|\})\s*)catch\b/,
|
|
1172
|
-
lookbehind: !0
|
|
1173
|
-
},
|
|
1174
|
-
{
|
|
1175
|
-
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
|
1176
|
-
lookbehind: !0
|
|
1177
|
-
}
|
|
1178
|
-
],
|
|
1179
|
-
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
1180
|
-
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1181
|
-
number: {
|
|
1182
|
-
pattern: RegExp(
|
|
1183
|
-
/(^|[^\w$])/.source + "(?:" + // constant
|
|
1184
|
-
(/NaN|Infinity/.source + "|" + // binary integer
|
|
1185
|
-
/0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
|
|
1186
|
-
/0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
|
|
1187
|
-
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
|
|
1188
|
-
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
1189
|
-
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
1190
|
-
),
|
|
1191
|
-
lookbehind: !0
|
|
1192
|
-
},
|
|
1193
|
-
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
1194
|
-
}), t.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/, t.languages.insertBefore("javascript", "keyword", {
|
|
1195
|
-
regex: {
|
|
1196
|
-
pattern: RegExp(
|
|
1197
|
-
// lookbehind
|
|
1198
|
-
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
1199
|
-
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
|
|
1200
|
-
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
|
1201
|
-
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
|
1202
|
-
// with the only syntax, so we have to define 2 different regex patterns.
|
|
1203
|
-
/\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
|
|
1204
|
-
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
1205
|
-
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
1206
|
-
),
|
|
1207
|
-
lookbehind: !0,
|
|
1208
|
-
greedy: !0,
|
|
1209
|
-
inside: {
|
|
1210
|
-
"regex-source": {
|
|
1211
|
-
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1212
|
-
lookbehind: !0,
|
|
1213
|
-
alias: "language-regex",
|
|
1214
|
-
inside: t.languages.regex
|
|
1215
|
-
},
|
|
1216
|
-
"regex-delimiter": /^\/|\/$/,
|
|
1217
|
-
"regex-flags": /^[a-z]+$/
|
|
1218
|
-
}
|
|
1219
|
-
},
|
|
1220
|
-
// This must be declared before keyword because we use "function" inside the look-forward
|
|
1221
|
-
"function-variable": {
|
|
1222
|
-
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
1223
|
-
alias: "function"
|
|
1224
|
-
},
|
|
1225
|
-
parameter: [
|
|
1226
|
-
{
|
|
1227
|
-
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
1228
|
-
lookbehind: !0,
|
|
1229
|
-
inside: t.languages.javascript
|
|
1230
|
-
},
|
|
1231
|
-
{
|
|
1232
|
-
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
1233
|
-
lookbehind: !0,
|
|
1234
|
-
inside: t.languages.javascript
|
|
1235
|
-
},
|
|
1236
|
-
{
|
|
1237
|
-
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
1238
|
-
lookbehind: !0,
|
|
1239
|
-
inside: t.languages.javascript
|
|
1240
|
-
},
|
|
1241
|
-
{
|
|
1242
|
-
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
1243
|
-
lookbehind: !0,
|
|
1244
|
-
inside: t.languages.javascript
|
|
1245
|
-
}
|
|
1246
|
-
],
|
|
1247
|
-
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
1248
|
-
}), t.languages.insertBefore("javascript", "string", {
|
|
1249
|
-
hashbang: {
|
|
1250
|
-
pattern: /^#!.*/,
|
|
1251
|
-
greedy: !0,
|
|
1252
|
-
alias: "comment"
|
|
1253
|
-
},
|
|
1254
|
-
"template-string": {
|
|
1255
|
-
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
1256
|
-
greedy: !0,
|
|
1257
|
-
inside: {
|
|
1258
|
-
"template-punctuation": {
|
|
1259
|
-
pattern: /^`|`$/,
|
|
1260
|
-
alias: "string"
|
|
1261
|
-
},
|
|
1262
|
-
interpolation: {
|
|
1263
|
-
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
1264
|
-
lookbehind: !0,
|
|
1265
|
-
inside: {
|
|
1266
|
-
"interpolation-punctuation": {
|
|
1267
|
-
pattern: /^\$\{|\}$/,
|
|
1268
|
-
alias: "punctuation"
|
|
1269
|
-
},
|
|
1270
|
-
rest: t.languages.javascript
|
|
1271
|
-
}
|
|
1272
|
-
},
|
|
1273
|
-
string: /[\s\S]+/
|
|
1274
|
-
}
|
|
1275
|
-
},
|
|
1276
|
-
"string-property": {
|
|
1277
|
-
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
1278
|
-
lookbehind: !0,
|
|
1279
|
-
greedy: !0,
|
|
1280
|
-
alias: "property"
|
|
1281
|
-
}
|
|
1282
|
-
}), t.languages.insertBefore("javascript", "operator", {
|
|
1283
|
-
"literal-property": {
|
|
1284
|
-
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
1285
|
-
lookbehind: !0,
|
|
1286
|
-
alias: "property"
|
|
1287
|
-
}
|
|
1288
|
-
}), t.languages.markup && (t.languages.markup.tag.addInlined("script", "javascript"), t.languages.markup.tag.addAttribute(
|
|
1289
|
-
/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
|
|
1290
|
-
"javascript"
|
|
1291
|
-
)), t.languages.js = t.languages.javascript, function() {
|
|
1292
|
-
if (typeof t > "u" || typeof document > "u")
|
|
1293
|
-
return;
|
|
1294
|
-
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1295
|
-
var l = "Loading…", p = function(y, b) {
|
|
1296
|
-
return "✖ Error " + y + " while fetching file: " + b;
|
|
1297
|
-
}, f = "✖ Error: File does not exist or is empty", m = {
|
|
1298
|
-
js: "javascript",
|
|
1299
|
-
py: "python",
|
|
1300
|
-
rb: "ruby",
|
|
1301
|
-
ps1: "powershell",
|
|
1302
|
-
psm1: "powershell",
|
|
1303
|
-
sh: "bash",
|
|
1304
|
-
bat: "batch",
|
|
1305
|
-
h: "c",
|
|
1306
|
-
tex: "latex"
|
|
1307
|
-
}, u = "data-src-status", g = "loading", E = "loaded", w = "failed", k = "pre[data-src]:not([" + u + '="' + E + '"]):not([' + u + '="' + g + '"])';
|
|
1308
|
-
function x(y, b, S) {
|
|
1309
|
-
var a = new XMLHttpRequest();
|
|
1310
|
-
a.open("GET", y, !0), a.onreadystatechange = function() {
|
|
1311
|
-
a.readyState == 4 && (a.status < 400 && a.responseText ? b(a.responseText) : a.status >= 400 ? S(p(a.status, a.statusText)) : S(f));
|
|
1312
|
-
}, a.send(null);
|
|
1313
|
-
}
|
|
1314
|
-
function U(y) {
|
|
1315
|
-
var b = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(y || "");
|
|
1316
|
-
if (b) {
|
|
1317
|
-
var S = Number(b[1]), a = b[2], n = b[3];
|
|
1318
|
-
return a ? n ? [S, Number(n)] : [S, void 0] : [S, S];
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
t.hooks.add("before-highlightall", function(y) {
|
|
1322
|
-
y.selector += ", " + k;
|
|
1323
|
-
}), t.hooks.add("before-sanity-check", function(y) {
|
|
1324
|
-
var b = (
|
|
1325
|
-
/** @type {HTMLPreElement} */
|
|
1326
|
-
y.element
|
|
1327
|
-
);
|
|
1328
|
-
if (b.matches(k)) {
|
|
1329
|
-
y.code = "", b.setAttribute(u, g);
|
|
1330
|
-
var S = b.appendChild(document.createElement("CODE"));
|
|
1331
|
-
S.textContent = l;
|
|
1332
|
-
var a = b.getAttribute("data-src"), n = y.language;
|
|
1333
|
-
if (n === "none") {
|
|
1334
|
-
var i = (/\.(\w+)$/.exec(a) || [, "none"])[1];
|
|
1335
|
-
n = m[i] || i;
|
|
1336
|
-
}
|
|
1337
|
-
t.util.setLanguage(S, n), t.util.setLanguage(b, n);
|
|
1338
|
-
var s = t.plugins.autoloader;
|
|
1339
|
-
s && s.loadLanguages(n), x(
|
|
1340
|
-
a,
|
|
1341
|
-
function(o) {
|
|
1342
|
-
b.setAttribute(u, E);
|
|
1343
|
-
var d = U(b.getAttribute("data-range"));
|
|
1344
|
-
if (d) {
|
|
1345
|
-
var h = o.split(/\r\n?|\n/g), c = d[0], v = d[1] == null ? h.length : d[1];
|
|
1346
|
-
c < 0 && (c += h.length), c = Math.max(0, Math.min(c - 1, h.length)), v < 0 && (v += h.length), v = Math.max(0, Math.min(v, h.length)), o = h.slice(c, v).join(`
|
|
1347
|
-
`), b.hasAttribute("data-start") || b.setAttribute("data-start", String(c + 1));
|
|
1348
|
-
}
|
|
1349
|
-
S.textContent = o, t.highlightElement(S);
|
|
1350
|
-
},
|
|
1351
|
-
function(o) {
|
|
1352
|
-
b.setAttribute(u, w), S.textContent = o;
|
|
1353
|
-
}
|
|
1354
|
-
);
|
|
1355
|
-
}
|
|
1356
|
-
}), t.plugins.fileHighlight = {
|
|
1357
|
-
/**
|
|
1358
|
-
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
1359
|
-
*
|
|
1360
|
-
* Note: Elements which are already loaded or currently loading will not be touched by this method.
|
|
1361
|
-
*
|
|
1362
|
-
* @param {ParentNode} [container=document]
|
|
1363
|
-
*/
|
|
1364
|
-
highlight: function(b) {
|
|
1365
|
-
for (var S = (b || document).querySelectorAll(k), a = 0, n; n = S[a++]; )
|
|
1366
|
-
t.highlightElement(n);
|
|
1367
|
-
}
|
|
1368
|
-
};
|
|
1369
|
-
var O = !1;
|
|
1370
|
-
t.fileHighlight = function() {
|
|
1371
|
-
O || (console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."), O = !0), t.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1372
|
-
};
|
|
1373
|
-
}();
|
|
1374
|
-
})(Q);
|
|
1375
|
-
var ue = Q.exports;
|
|
1376
|
-
const j = /* @__PURE__ */ le(ue);
|
|
1
|
+
import { getSnippet as h, PistonClient as E } from "@hep-code-runner/core";
|
|
2
|
+
import g from "prismjs";
|
|
1377
3
|
Prism.languages.clike = {
|
|
1378
4
|
comment: [
|
|
1379
5
|
{
|
|
@@ -1631,9 +257,9 @@ Prism.languages.insertBefore("go", "string", {
|
|
|
1631
257
|
}
|
|
1632
258
|
});
|
|
1633
259
|
delete Prism.languages.go["class-name"];
|
|
1634
|
-
(function(
|
|
1635
|
-
var e = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,
|
|
1636
|
-
pattern: RegExp(/(^|[^\w.])/.source +
|
|
260
|
+
(function(t) {
|
|
261
|
+
var e = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/, r = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source, n = {
|
|
262
|
+
pattern: RegExp(/(^|[^\w.])/.source + r + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
|
|
1637
263
|
lookbehind: !0,
|
|
1638
264
|
inside: {
|
|
1639
265
|
namespace: {
|
|
@@ -1645,32 +271,32 @@ delete Prism.languages.go["class-name"];
|
|
|
1645
271
|
punctuation: /\./
|
|
1646
272
|
}
|
|
1647
273
|
};
|
|
1648
|
-
|
|
274
|
+
t.languages.java = t.languages.extend("clike", {
|
|
1649
275
|
string: {
|
|
1650
276
|
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
|
|
1651
277
|
lookbehind: !0,
|
|
1652
278
|
greedy: !0
|
|
1653
279
|
},
|
|
1654
280
|
"class-name": [
|
|
1655
|
-
|
|
281
|
+
n,
|
|
1656
282
|
{
|
|
1657
283
|
// variables, parameters, and constructor references
|
|
1658
284
|
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
1659
|
-
pattern: RegExp(/(^|[^\w.])/.source +
|
|
285
|
+
pattern: RegExp(/(^|[^\w.])/.source + r + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
|
|
1660
286
|
lookbehind: !0,
|
|
1661
|
-
inside:
|
|
287
|
+
inside: n.inside
|
|
1662
288
|
},
|
|
1663
289
|
{
|
|
1664
290
|
// class names based on keyword
|
|
1665
291
|
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
1666
|
-
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source +
|
|
292
|
+
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + r + /[A-Z]\w*\b/.source),
|
|
1667
293
|
lookbehind: !0,
|
|
1668
|
-
inside:
|
|
294
|
+
inside: n.inside
|
|
1669
295
|
}
|
|
1670
296
|
],
|
|
1671
297
|
keyword: e,
|
|
1672
298
|
function: [
|
|
1673
|
-
|
|
299
|
+
t.languages.clike.function,
|
|
1674
300
|
{
|
|
1675
301
|
pattern: /(::\s*)[a-z_]\w*/,
|
|
1676
302
|
lookbehind: !0
|
|
@@ -1682,7 +308,7 @@ delete Prism.languages.go["class-name"];
|
|
|
1682
308
|
lookbehind: !0
|
|
1683
309
|
},
|
|
1684
310
|
constant: /\b[A-Z][A-Z_\d]+\b/
|
|
1685
|
-
}),
|
|
311
|
+
}), t.languages.insertBefore("java", "string", {
|
|
1686
312
|
"triple-quoted-string": {
|
|
1687
313
|
// http://openjdk.java.net/jeps/355#Description
|
|
1688
314
|
pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
|
@@ -1693,7 +319,7 @@ delete Prism.languages.go["class-name"];
|
|
|
1693
319
|
pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
|
|
1694
320
|
greedy: !0
|
|
1695
321
|
}
|
|
1696
|
-
}),
|
|
322
|
+
}), t.languages.insertBefore("java", "class-name", {
|
|
1697
323
|
annotation: {
|
|
1698
324
|
pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
|
|
1699
325
|
lookbehind: !0,
|
|
@@ -1702,7 +328,7 @@ delete Prism.languages.go["class-name"];
|
|
|
1702
328
|
generics: {
|
|
1703
329
|
pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
|
|
1704
330
|
inside: {
|
|
1705
|
-
"class-name":
|
|
331
|
+
"class-name": n,
|
|
1706
332
|
keyword: e,
|
|
1707
333
|
punctuation: /[<>(),.:]/,
|
|
1708
334
|
operator: /[?&|]/
|
|
@@ -1710,21 +336,21 @@ delete Prism.languages.go["class-name"];
|
|
|
1710
336
|
},
|
|
1711
337
|
import: [
|
|
1712
338
|
{
|
|
1713
|
-
pattern: RegExp(/(\bimport\s+)/.source +
|
|
339
|
+
pattern: RegExp(/(\bimport\s+)/.source + r + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
|
|
1714
340
|
lookbehind: !0,
|
|
1715
341
|
inside: {
|
|
1716
|
-
namespace:
|
|
342
|
+
namespace: n.inside.namespace,
|
|
1717
343
|
punctuation: /\./,
|
|
1718
344
|
operator: /\*/,
|
|
1719
345
|
"class-name": /\w+/
|
|
1720
346
|
}
|
|
1721
347
|
},
|
|
1722
348
|
{
|
|
1723
|
-
pattern: RegExp(/(\bimport\s+static\s+)/.source +
|
|
349
|
+
pattern: RegExp(/(\bimport\s+static\s+)/.source + r + /(?:\w+|\*)(?=\s*;)/.source),
|
|
1724
350
|
lookbehind: !0,
|
|
1725
351
|
alias: "static",
|
|
1726
352
|
inside: {
|
|
1727
|
-
namespace:
|
|
353
|
+
namespace: n.inside.namespace,
|
|
1728
354
|
static: /\b\w+$/,
|
|
1729
355
|
punctuation: /\./,
|
|
1730
356
|
operator: /\*/,
|
|
@@ -1821,14 +447,14 @@ Prism.languages.insertBefore("c", "function", {
|
|
|
1821
447
|
constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
1822
448
|
});
|
|
1823
449
|
delete Prism.languages.c.boolean;
|
|
1824
|
-
(function(
|
|
1825
|
-
for (var e = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source,
|
|
450
|
+
(function(t) {
|
|
451
|
+
for (var e = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source, r = 0; r < 2; r++)
|
|
1826
452
|
e = e.replace(/<self>/g, function() {
|
|
1827
453
|
return e;
|
|
1828
454
|
});
|
|
1829
455
|
e = e.replace(/<self>/g, function() {
|
|
1830
456
|
return /[^\s\S]/.source;
|
|
1831
|
-
}),
|
|
457
|
+
}), t.languages.rust = {
|
|
1832
458
|
comment: [
|
|
1833
459
|
{
|
|
1834
460
|
pattern: RegExp(/(^|[^\\])/.source + e),
|
|
@@ -1935,7 +561,7 @@ delete Prism.languages.c.boolean;
|
|
|
1935
561
|
boolean: /\b(?:false|true)\b/,
|
|
1936
562
|
punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
1937
563
|
operator: /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
|
1938
|
-
},
|
|
564
|
+
}, t.languages.rust["closure-params"].inside.rest = t.languages.rust, t.languages.rust.attribute.inside.string = t.languages.rust.string;
|
|
1939
565
|
})(Prism);
|
|
1940
566
|
Prism.languages.sql = {
|
|
1941
567
|
comment: {
|
|
@@ -1970,16 +596,16 @@ Prism.languages.sql = {
|
|
|
1970
596
|
operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
1971
597
|
punctuation: /[;[\]()`,.]/
|
|
1972
598
|
};
|
|
1973
|
-
(function(
|
|
1974
|
-
var e = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",
|
|
599
|
+
(function(t) {
|
|
600
|
+
var e = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b", r = {
|
|
1975
601
|
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
1976
602
|
lookbehind: !0,
|
|
1977
603
|
alias: "punctuation",
|
|
1978
604
|
// this looks reasonably well in all themes
|
|
1979
605
|
inside: null
|
|
1980
606
|
// see below
|
|
1981
|
-
},
|
|
1982
|
-
bash:
|
|
607
|
+
}, n = {
|
|
608
|
+
bash: r,
|
|
1983
609
|
environment: {
|
|
1984
610
|
pattern: RegExp("\\$" + e),
|
|
1985
611
|
alias: "constant"
|
|
@@ -2032,7 +658,7 @@ Prism.languages.sql = {
|
|
|
2032
658
|
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
2033
659
|
entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
|
2034
660
|
};
|
|
2035
|
-
|
|
661
|
+
t.languages.bash = {
|
|
2036
662
|
shebang: {
|
|
2037
663
|
pattern: /^#!\s*\/.*/,
|
|
2038
664
|
alias: "important"
|
|
@@ -2090,7 +716,7 @@ Prism.languages.sql = {
|
|
|
2090
716
|
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
2091
717
|
lookbehind: !0,
|
|
2092
718
|
greedy: !0,
|
|
2093
|
-
inside:
|
|
719
|
+
inside: n
|
|
2094
720
|
},
|
|
2095
721
|
// Here-document with quotes around the tag
|
|
2096
722
|
// → No expansion (so no “inside”).
|
|
@@ -2099,7 +725,7 @@ Prism.languages.sql = {
|
|
|
2099
725
|
lookbehind: !0,
|
|
2100
726
|
greedy: !0,
|
|
2101
727
|
inside: {
|
|
2102
|
-
bash:
|
|
728
|
+
bash: r
|
|
2103
729
|
}
|
|
2104
730
|
},
|
|
2105
731
|
// “Normal” string
|
|
@@ -2108,7 +734,7 @@ Prism.languages.sql = {
|
|
|
2108
734
|
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
2109
735
|
lookbehind: !0,
|
|
2110
736
|
greedy: !0,
|
|
2111
|
-
inside:
|
|
737
|
+
inside: n
|
|
2112
738
|
},
|
|
2113
739
|
{
|
|
2114
740
|
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
@@ -2121,7 +747,7 @@ Prism.languages.sql = {
|
|
|
2121
747
|
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
2122
748
|
greedy: !0,
|
|
2123
749
|
inside: {
|
|
2124
|
-
entity:
|
|
750
|
+
entity: n.entity
|
|
2125
751
|
}
|
|
2126
752
|
}
|
|
2127
753
|
],
|
|
@@ -2129,7 +755,7 @@ Prism.languages.sql = {
|
|
|
2129
755
|
pattern: RegExp("\\$?" + e),
|
|
2130
756
|
alias: "constant"
|
|
2131
757
|
},
|
|
2132
|
-
variable:
|
|
758
|
+
variable: n.variable,
|
|
2133
759
|
function: {
|
|
2134
760
|
pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
|
|
2135
761
|
lookbehind: !0
|
|
@@ -2168,8 +794,8 @@ Prism.languages.sql = {
|
|
|
2168
794
|
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
2169
795
|
lookbehind: !0
|
|
2170
796
|
}
|
|
2171
|
-
},
|
|
2172
|
-
for (var
|
|
797
|
+
}, r.inside = t.languages.bash;
|
|
798
|
+
for (var a = [
|
|
2173
799
|
"comment",
|
|
2174
800
|
"function-name",
|
|
2175
801
|
"for-or-select",
|
|
@@ -2185,9 +811,9 @@ Prism.languages.sql = {
|
|
|
2185
811
|
"operator",
|
|
2186
812
|
"punctuation",
|
|
2187
813
|
"number"
|
|
2188
|
-
],
|
|
2189
|
-
|
|
2190
|
-
|
|
814
|
+
], i = n.variable[1].inside, o = 0; o < a.length; o++)
|
|
815
|
+
i[a[o]] = t.languages.bash[a[o]];
|
|
816
|
+
t.languages.sh = t.languages.bash, t.languages.shell = t.languages.bash;
|
|
2191
817
|
})(Prism);
|
|
2192
818
|
Prism.languages.json = {
|
|
2193
819
|
property: {
|
|
@@ -2214,7 +840,7 @@ Prism.languages.json = {
|
|
|
2214
840
|
}
|
|
2215
841
|
};
|
|
2216
842
|
Prism.languages.webmanifest = Prism.languages.json;
|
|
2217
|
-
const
|
|
843
|
+
const b = `
|
|
2218
844
|
/* 默认代码颜色 */
|
|
2219
845
|
.hep-cr-editor .hep-cr-highlight code,
|
|
2220
846
|
.hep-cr-editor .hep-cr-highlight pre {
|
|
@@ -2298,7 +924,7 @@ const ce = `
|
|
|
2298
924
|
.hep-cr-editor .token.console {
|
|
2299
925
|
color: #f8f8f2 !important;
|
|
2300
926
|
}
|
|
2301
|
-
`,
|
|
927
|
+
`, S = `
|
|
2302
928
|
/* 默认代码颜色 */
|
|
2303
929
|
.hep-cr-editor .hep-cr-highlight code,
|
|
2304
930
|
.hep-cr-editor .hep-cr-highlight pre {
|
|
@@ -2376,15 +1002,15 @@ const ce = `
|
|
|
2376
1002
|
color: #333 !important;
|
|
2377
1003
|
}
|
|
2378
1004
|
`;
|
|
2379
|
-
function
|
|
2380
|
-
var
|
|
2381
|
-
return e && (
|
|
2382
|
-
exports:
|
|
2383
|
-
options:
|
|
1005
|
+
function m(t, e, r, n, a, i, o, l) {
|
|
1006
|
+
var s = typeof t == "function" ? t.options : t;
|
|
1007
|
+
return e && (s.render = e, s.staticRenderFns = r, s._compiled = !0), i && (s._scopeId = "data-v-" + i), {
|
|
1008
|
+
exports: t,
|
|
1009
|
+
options: s
|
|
2384
1010
|
};
|
|
2385
1011
|
}
|
|
2386
|
-
typeof window < "u" && (window.Prism =
|
|
2387
|
-
const
|
|
1012
|
+
typeof window < "u" && (window.Prism = g);
|
|
1013
|
+
const T = {
|
|
2388
1014
|
name: "CodeEditor",
|
|
2389
1015
|
props: {
|
|
2390
1016
|
value: {
|
|
@@ -2414,8 +1040,8 @@ const pe = {
|
|
|
2414
1040
|
this.loadPrismTheme(this.theme);
|
|
2415
1041
|
},
|
|
2416
1042
|
watch: {
|
|
2417
|
-
theme(
|
|
2418
|
-
this.loadPrismTheme(
|
|
1043
|
+
theme(t) {
|
|
1044
|
+
this.loadPrismTheme(t);
|
|
2419
1045
|
}
|
|
2420
1046
|
},
|
|
2421
1047
|
computed: {
|
|
@@ -2461,11 +1087,11 @@ const pe = {
|
|
|
2461
1087
|
},
|
|
2462
1088
|
highlightedCode: function() {
|
|
2463
1089
|
try {
|
|
2464
|
-
var
|
|
2465
|
-
if (
|
|
2466
|
-
return
|
|
1090
|
+
var t = g.languages[this.prismLanguage];
|
|
1091
|
+
if (t)
|
|
1092
|
+
return g.highlight(
|
|
2467
1093
|
this.value || "",
|
|
2468
|
-
|
|
1094
|
+
t,
|
|
2469
1095
|
this.prismLanguage
|
|
2470
1096
|
);
|
|
2471
1097
|
} catch {
|
|
@@ -2474,34 +1100,34 @@ const pe = {
|
|
|
2474
1100
|
}
|
|
2475
1101
|
},
|
|
2476
1102
|
methods: {
|
|
2477
|
-
loadPrismTheme(
|
|
2478
|
-
const e = "hep-cr-prism-styles",
|
|
2479
|
-
|
|
2480
|
-
const
|
|
2481
|
-
|
|
1103
|
+
loadPrismTheme(t) {
|
|
1104
|
+
const e = "hep-cr-prism-styles", r = document.getElementById(e), n = t === "dark" ? b : S;
|
|
1105
|
+
r && r.remove();
|
|
1106
|
+
const a = document.createElement("style");
|
|
1107
|
+
a.id = e, a.textContent = n, document.head.appendChild(a);
|
|
2482
1108
|
},
|
|
2483
|
-
escapeHtml: function(
|
|
1109
|
+
escapeHtml: function(t) {
|
|
2484
1110
|
var e = document.createElement("div");
|
|
2485
|
-
return e.textContent =
|
|
1111
|
+
return e.textContent = t, e.innerHTML;
|
|
2486
1112
|
},
|
|
2487
|
-
handleInput: function(
|
|
2488
|
-
this.$emit("input",
|
|
1113
|
+
handleInput: function(t) {
|
|
1114
|
+
this.$emit("input", t.target.value), this.$emit("update:value", t.target.value), this.emitChange(t.target.value);
|
|
2489
1115
|
},
|
|
2490
|
-
handleScroll: function(
|
|
1116
|
+
handleScroll: function(t) {
|
|
2491
1117
|
var e = this.$refs.highlightRef;
|
|
2492
|
-
e && (e.scrollTop =
|
|
1118
|
+
e && (e.scrollTop = t.target.scrollTop, e.scrollLeft = t.target.scrollLeft);
|
|
2493
1119
|
},
|
|
2494
|
-
handleKeydown: function(
|
|
2495
|
-
if (
|
|
2496
|
-
|
|
2497
|
-
var e =
|
|
2498
|
-
e.value =
|
|
1120
|
+
handleKeydown: function(t) {
|
|
1121
|
+
if (t.key === "Tab") {
|
|
1122
|
+
t.preventDefault();
|
|
1123
|
+
var e = t.target, r = e.selectionStart, n = e.selectionEnd, a = e.value;
|
|
1124
|
+
e.value = a.substring(0, r) + " " + a.substring(n), e.selectionStart = e.selectionEnd = r + 2, this.$emit("input", e.value), this.$emit("update:value", e.value), this.emitChange(e.value);
|
|
2499
1125
|
}
|
|
2500
1126
|
},
|
|
2501
|
-
emitChange: function(
|
|
1127
|
+
emitChange: function(t) {
|
|
2502
1128
|
var e = this;
|
|
2503
1129
|
e.changeTimer && clearTimeout(e.changeTimer), e.changeTimer = setTimeout(function() {
|
|
2504
|
-
e.$emit("change",
|
|
1130
|
+
e.$emit("change", t);
|
|
2505
1131
|
}, 500);
|
|
2506
1132
|
}
|
|
2507
1133
|
},
|
|
@@ -2509,21 +1135,21 @@ const pe = {
|
|
|
2509
1135
|
this.changeTimer && clearTimeout(this.changeTimer);
|
|
2510
1136
|
}
|
|
2511
1137
|
};
|
|
2512
|
-
var
|
|
2513
|
-
var e = this,
|
|
2514
|
-
return
|
|
2515
|
-
},
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
1138
|
+
var v = function() {
|
|
1139
|
+
var e = this, r = e._self._c;
|
|
1140
|
+
return r("div", { staticClass: "hep-cr-editor", class: "hep-cr-theme-" + e.theme, style: { background: e.editorBackground } }, [r("pre", { ref: "highlightRef", staticClass: "hep-cr-highlight", class: "language-" + e.prismLanguage, attrs: { "aria-hidden": "true" } }, [r("code", { domProps: { innerHTML: e._s(e.highlightedCode) } })]), r("textarea", { staticClass: "hep-cr-input", attrs: { disabled: e.disabled, spellcheck: "false", placeholder: "Write your code here..." }, domProps: { value: e.value }, on: { input: e.handleInput, scroll: e.handleScroll, keydown: e.handleKeydown } })]);
|
|
1141
|
+
}, _ = [], A = /* @__PURE__ */ m(
|
|
1142
|
+
T,
|
|
1143
|
+
v,
|
|
1144
|
+
_,
|
|
2519
1145
|
!1,
|
|
2520
1146
|
null,
|
|
2521
1147
|
"525880d3"
|
|
2522
1148
|
);
|
|
2523
|
-
const
|
|
1149
|
+
const k = A.exports, y = {
|
|
2524
1150
|
name: "CodeRunner",
|
|
2525
1151
|
components: {
|
|
2526
|
-
CodeEditor:
|
|
1152
|
+
CodeEditor: k
|
|
2527
1153
|
},
|
|
2528
1154
|
props: {
|
|
2529
1155
|
pistonUrl: {
|
|
@@ -2537,8 +1163,8 @@ const me = fe.exports, be = {
|
|
|
2537
1163
|
theme: {
|
|
2538
1164
|
type: String,
|
|
2539
1165
|
default: "light",
|
|
2540
|
-
validator: function(
|
|
2541
|
-
return ["light", "dark"].indexOf(
|
|
1166
|
+
validator: function(t) {
|
|
1167
|
+
return ["light", "dark"].indexOf(t) !== -1;
|
|
2542
1168
|
}
|
|
2543
1169
|
},
|
|
2544
1170
|
themeColor: {
|
|
@@ -2567,12 +1193,12 @@ const me = fe.exports, be = {
|
|
|
2567
1193
|
}
|
|
2568
1194
|
},
|
|
2569
1195
|
data: function() {
|
|
2570
|
-
var
|
|
1196
|
+
var t = this, e = typeof window < "u" && localStorage.getItem("hep-cr-default-language") || null, r = e || t.language || "javascript";
|
|
2571
1197
|
return {
|
|
2572
1198
|
runtimes: [],
|
|
2573
|
-
currentLanguage:
|
|
2574
|
-
currentTheme:
|
|
2575
|
-
code:
|
|
1199
|
+
currentLanguage: r,
|
|
1200
|
+
currentTheme: t.theme,
|
|
1201
|
+
code: t.defaultCode || h(r.split(":")[0]),
|
|
2576
1202
|
output: "",
|
|
2577
1203
|
stderr: "",
|
|
2578
1204
|
isRunning: !1,
|
|
@@ -2592,142 +1218,142 @@ const me = fe.exports, be = {
|
|
|
2592
1218
|
},
|
|
2593
1219
|
themeStyle: function() {
|
|
2594
1220
|
if (!this.themeColor) return {};
|
|
2595
|
-
var
|
|
2596
|
-
var
|
|
2597
|
-
return "#" + (16777216 +
|
|
2598
|
-
},
|
|
2599
|
-
var
|
|
2600
|
-
return
|
|
2601
|
-
},
|
|
1221
|
+
var t = this.currentTheme === "dark", e = this.themeColor, r = function(o, l) {
|
|
1222
|
+
var s = parseInt(o.replace("#", ""), 16), c = Math.round(2.55 * l), d = Math.min(255, Math.max(0, (s >> 16) + c)), p = Math.min(255, Math.max(0, (s >> 8 & 255) + c)), f = Math.min(255, Math.max(0, (s & 255) + c));
|
|
1223
|
+
return "#" + (16777216 + d * 65536 + p * 256 + f).toString(16).slice(1);
|
|
1224
|
+
}, n = function(o) {
|
|
1225
|
+
var l = parseInt(o.replace("#", ""), 16), s = l >> 16 & 255, c = l >> 8 & 255, d = l & 255, p = (0.299 * s + 0.587 * c + 0.114 * d) / 255;
|
|
1226
|
+
return p > 0.5;
|
|
1227
|
+
}, a = n(e), i = a ? "#000" : "#fff";
|
|
2602
1228
|
return {
|
|
2603
1229
|
"--hep-cr-theme-color": e,
|
|
2604
|
-
"--hep-cr-theme-color-hover":
|
|
2605
|
-
"--hep-cr-tab-active-color":
|
|
1230
|
+
"--hep-cr-theme-color-hover": t ? r(e, 20) : r(e, -20),
|
|
1231
|
+
"--hep-cr-tab-active-color": i
|
|
2606
1232
|
};
|
|
2607
1233
|
},
|
|
2608
1234
|
languageOptions: function() {
|
|
2609
|
-
return this.runtimes.map(function(
|
|
1235
|
+
return this.runtimes.map(function(t) {
|
|
2610
1236
|
return {
|
|
2611
|
-
value:
|
|
2612
|
-
label:
|
|
1237
|
+
value: t.language + ":" + t.version,
|
|
1238
|
+
label: t.language.charAt(0).toUpperCase() + t.language.slice(1) + " " + t.version
|
|
2613
1239
|
};
|
|
2614
1240
|
});
|
|
2615
1241
|
},
|
|
2616
1242
|
languageName: function() {
|
|
2617
|
-
var
|
|
2618
|
-
return
|
|
1243
|
+
var t = this.currentLanguage;
|
|
1244
|
+
return t.includes(":") ? t.split(":")[0] : t;
|
|
2619
1245
|
}
|
|
2620
1246
|
},
|
|
2621
1247
|
watch: {
|
|
2622
|
-
currentLanguage: function(
|
|
2623
|
-
var e =
|
|
2624
|
-
this.code =
|
|
1248
|
+
currentLanguage: function(t) {
|
|
1249
|
+
var e = t.includes(":") ? t.split(":")[0] : t;
|
|
1250
|
+
this.code = h(e), this.$emit("language-change", e, this.code), typeof window < "u" && localStorage.setItem("hep-cr-default-language", t);
|
|
2625
1251
|
}
|
|
2626
1252
|
},
|
|
2627
1253
|
mounted: function() {
|
|
2628
|
-
this.client = new
|
|
1254
|
+
this.client = new E({ pistonUrl: this.pistonUrl }), this.loadRuntimes(), this.$emit("change", this.code);
|
|
2629
1255
|
},
|
|
2630
1256
|
methods: {
|
|
2631
1257
|
getStoredLanguage: function() {
|
|
2632
1258
|
return typeof window > "u" ? this.language : localStorage.getItem("hep-cr-default-language") || this.language;
|
|
2633
1259
|
},
|
|
2634
1260
|
loadRuntimes: function() {
|
|
2635
|
-
var
|
|
1261
|
+
var t = this;
|
|
2636
1262
|
this.runtimesLoading = !0, this.error = null, this.client.getRuntimes().then(function(e) {
|
|
2637
|
-
|
|
2638
|
-
var
|
|
2639
|
-
return
|
|
1263
|
+
t.runtimes = e;
|
|
1264
|
+
var r = t.currentLanguage.split(":")[0], n = e.find(function(a) {
|
|
1265
|
+
return a.language === r;
|
|
2640
1266
|
});
|
|
2641
|
-
|
|
1267
|
+
n && !t.currentLanguage.includes(":") && (t.currentLanguage = r + ":" + n.version), t.$emit("language-change", r, t.code);
|
|
2642
1268
|
}).catch(function(e) {
|
|
2643
|
-
|
|
1269
|
+
t.error = e.message || "Failed to load runtimes";
|
|
2644
1270
|
}).finally(function() {
|
|
2645
|
-
|
|
1271
|
+
t.runtimesLoading = !1;
|
|
2646
1272
|
});
|
|
2647
1273
|
},
|
|
2648
1274
|
execute: function() {
|
|
2649
|
-
var
|
|
1275
|
+
var t = this;
|
|
2650
1276
|
this.isRunning || (this.isRunning = !0, this.output = "", this.stderr = "", this.executionTime = null, this.error = null, this.activeTab = "stdout", this.$emit("execute-start"), this.client.execute(this.languageName, this.code).then(function(e) {
|
|
2651
|
-
|
|
1277
|
+
t.output = e.output, t.stderr = e.stderr, t.executionTime = e.executionTime || null, t.activeTab = e.stderr ? "stderr" : "stdout", t.$emit("execute-end", e);
|
|
2652
1278
|
}).catch(function(e) {
|
|
2653
|
-
|
|
1279
|
+
t.error = e.message || "Execution failed", t.$emit("execute-end", {
|
|
2654
1280
|
success: !1,
|
|
2655
1281
|
output: "",
|
|
2656
|
-
stderr:
|
|
1282
|
+
stderr: t.error,
|
|
2657
1283
|
code: -1
|
|
2658
1284
|
});
|
|
2659
1285
|
}).finally(function() {
|
|
2660
|
-
|
|
1286
|
+
t.isRunning = !1;
|
|
2661
1287
|
}));
|
|
2662
1288
|
},
|
|
2663
1289
|
clearOutput: function() {
|
|
2664
1290
|
this.output = "", this.stderr = "", this.executionTime = null, this.error = null;
|
|
2665
1291
|
},
|
|
2666
1292
|
copyCode: function() {
|
|
2667
|
-
var
|
|
1293
|
+
var t = this;
|
|
2668
1294
|
navigator.clipboard.writeText(this.code), this.copiedEditor = !0, setTimeout(function() {
|
|
2669
|
-
|
|
1295
|
+
t.copiedEditor = !1;
|
|
2670
1296
|
}, 2e3);
|
|
2671
1297
|
},
|
|
2672
1298
|
copyOutput: function() {
|
|
2673
|
-
var
|
|
1299
|
+
var t = this, e = this.activeTab === "stdout" ? this.output : this.stderr;
|
|
2674
1300
|
navigator.clipboard.writeText(e), this.copiedOutput = !0, setTimeout(function() {
|
|
2675
|
-
|
|
1301
|
+
t.copiedOutput = !1;
|
|
2676
1302
|
}, 2e3);
|
|
2677
1303
|
},
|
|
2678
1304
|
resetCode: function() {
|
|
2679
|
-
this.code =
|
|
1305
|
+
this.code = h(this.languageName);
|
|
2680
1306
|
},
|
|
2681
1307
|
toggleTheme: function() {
|
|
2682
1308
|
this.currentTheme = this.currentTheme === "light" ? "dark" : "light";
|
|
2683
1309
|
},
|
|
2684
|
-
startDrag: function(
|
|
2685
|
-
var e = this,
|
|
2686
|
-
if (
|
|
2687
|
-
var
|
|
2688
|
-
var
|
|
2689
|
-
e.editorWidth = Math.max(20, Math.min(80,
|
|
2690
|
-
},
|
|
2691
|
-
document.removeEventListener("mousemove",
|
|
1310
|
+
startDrag: function(t) {
|
|
1311
|
+
var e = this, r = document.querySelector(".hep-cr-runner-main");
|
|
1312
|
+
if (r) {
|
|
1313
|
+
var n = function(i) {
|
|
1314
|
+
var o = r.getBoundingClientRect(), l = (i.clientX - o.left) / o.width * 100;
|
|
1315
|
+
e.editorWidth = Math.max(20, Math.min(80, l));
|
|
1316
|
+
}, a = function() {
|
|
1317
|
+
document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", a), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
2692
1318
|
};
|
|
2693
|
-
document.addEventListener("mousemove",
|
|
1319
|
+
document.addEventListener("mousemove", n), document.addEventListener("mouseup", a), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
2694
1320
|
}
|
|
2695
1321
|
}
|
|
2696
1322
|
}
|
|
2697
1323
|
};
|
|
2698
|
-
var
|
|
2699
|
-
var e = this,
|
|
2700
|
-
return
|
|
2701
|
-
var
|
|
2702
|
-
return
|
|
2703
|
-
}).map(function(
|
|
2704
|
-
var
|
|
2705
|
-
return
|
|
1324
|
+
var I = function() {
|
|
1325
|
+
var e = this, r = e._self._c;
|
|
1326
|
+
return r("div", { class: ["hep-cr-runner", e.themeClass], style: e.themeStyle }, [r("div", { staticClass: "hep-cr-runner-header" }, [r("div", { staticClass: "hep-cr-runner-controls" }, [e.showLanguageSelector ? r("select", { directives: [{ name: "model", rawName: "v-model", value: e.currentLanguage, expression: "currentLanguage" }], staticClass: "hep-cr-language-select", attrs: { disabled: e.isRunning }, on: { change: function(n) {
|
|
1327
|
+
var a = Array.prototype.filter.call(n.target.options, function(i) {
|
|
1328
|
+
return i.selected;
|
|
1329
|
+
}).map(function(i) {
|
|
1330
|
+
var o = "_value" in i ? i._value : i.value;
|
|
1331
|
+
return o;
|
|
2706
1332
|
});
|
|
2707
|
-
e.currentLanguage =
|
|
2708
|
-
} } }, [e.runtimesLoading ?
|
|
2709
|
-
return
|
|
2710
|
-
})], 2) : e._e()]),
|
|
2711
|
-
e.code =
|
|
2712
|
-
}, change: function(
|
|
2713
|
-
return e.$emit("change",
|
|
2714
|
-
} } })], 1) : e._e(), e.showEditor ?
|
|
1333
|
+
e.currentLanguage = n.target.multiple ? a : a[0];
|
|
1334
|
+
} } }, [e.runtimesLoading ? r("option", { attrs: { value: "" } }, [e._v("加载中...")]) : e._e(), e._l(e.languageOptions, function(n) {
|
|
1335
|
+
return r("option", { key: n.value, domProps: { value: n.value } }, [e._v(" " + e._s(n.label) + " ")]);
|
|
1336
|
+
})], 2) : e._e()]), r("div", { staticClass: "hep-cr-runner-actions" }, [r("button", { staticClass: "hep-cr-btn hep-cr-btn-run", attrs: { disabled: e.isRunning || e.runtimesLoading }, on: { click: e.execute } }, [e.isRunning ? r("span", { staticClass: "hep-cr-spinner" }) : r("span", { staticClass: "hep-cr-run-icon" }, [e._v("▶")]), e._v(" " + e._s(e.isRunning ? "运行中..." : e.executorLabel) + " ")]), e.showEditor && e.editable ? r("button", { staticClass: "hep-cr-btn hep-cr-btn-reset", on: { click: e.resetCode } }, [e._v(" 重置 ")]) : e._e(), r("button", { staticClass: "hep-cr-btn hep-cr-btn-theme", attrs: { title: e.currentTheme === "light" ? "Switch to dark mode" : "Switch to light mode" }, on: { click: e.toggleTheme } }, [e.currentTheme === "light" ? r("svg", { attrs: { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" } }, [r("path", { attrs: { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" } })]) : r("svg", { attrs: { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" } }, [r("circle", { attrs: { cx: "12", cy: "12", r: "5" } }), r("line", { attrs: { x1: "12", y1: "1", x2: "12", y2: "3" } }), r("line", { attrs: { x1: "12", y1: "21", x2: "12", y2: "23" } }), r("line", { attrs: { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" } }), r("line", { attrs: { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" } }), r("line", { attrs: { x1: "1", y1: "12", x2: "3", y2: "12" } }), r("line", { attrs: { x1: "21", y1: "12", x2: "23", y2: "12" } }), r("line", { attrs: { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" } }), r("line", { attrs: { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" } })])])])]), e.error ? r("div", { staticClass: "hep-cr-error-message" }, [e._v(" " + e._s(e.error) + " ")]) : e._e(), r("div", { staticClass: "hep-cr-runner-main" }, [e.showEditor ? r("div", { staticClass: "hep-cr-editor-panel", style: { width: e.editorWidth + "%" } }, [r("div", { staticClass: "hep-cr-panel-header" }, [r("span", { staticClass: "hep-cr-panel-title" }, [e._v("编辑器")]), r("div", { staticClass: "hep-cr-output-actions" }, [r("span", { staticClass: "hep-cr-language-badge" }, [e._v(e._s(e.languageName))]), r("button", { staticClass: "hep-cr-btn-icon", class: { "hep-cr-btn-copied": e.copiedEditor }, attrs: { disabled: e.copiedEditor, title: e.copiedEditor ? "已复制" : "复制" }, on: { click: e.copyCode } }, [e.copiedEditor ? r("span", { staticClass: "hep-cr-copied-text" }, [e._v("已复制")]) : r("svg", { attrs: { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" } }, [r("rect", { attrs: { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" } }), r("path", { attrs: { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" } })])])])]), r("CodeEditor", { attrs: { value: e.code, language: e.languageName, theme: e.currentTheme, disabled: !e.editable || e.isRunning }, on: { input: function(n) {
|
|
1337
|
+
e.code = n;
|
|
1338
|
+
}, change: function(n) {
|
|
1339
|
+
return e.$emit("change", n);
|
|
1340
|
+
} } })], 1) : e._e(), e.showEditor ? r("div", { staticClass: "hep-cr-resize-handle", on: { mousedown: e.startDrag } }, [r("div", { staticClass: "hep-cr-resize-line" })]) : e._e(), r("div", { staticClass: "hep-cr-output-panel", style: { width: e.showEditor ? 100 - e.editorWidth + "%" : "100%" } }, [r("div", { staticClass: "hep-cr-panel-header" }, [r("div", { staticClass: "hep-cr-output-tabs" }, [r("button", { class: ["hep-cr-tab", { active: e.activeTab === "stdout" }], on: { click: function(n) {
|
|
2715
1341
|
e.activeTab = "stdout";
|
|
2716
|
-
} } }, [e._v(" 输出 ")]), e.stderr ?
|
|
1342
|
+
} } }, [e._v(" 输出 ")]), e.stderr ? r("button", { class: ["hep-cr-tab", "hep-cr-tab-error", { active: e.activeTab === "stderr" }], on: { click: function(n) {
|
|
2717
1343
|
e.activeTab = "stderr";
|
|
2718
|
-
} } }, [e._v(" 错误 ")]) : e._e()]),
|
|
2719
|
-
},
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
1344
|
+
} } }, [e._v(" 错误 ")]) : e._e()]), r("div", { staticClass: "hep-cr-output-actions" }, [e.executionTime !== null ? r("span", { staticClass: "hep-cr-execution-time" }, [e._v(" " + e._s(e.executionTime) + "ms ")]) : e._e(), r("button", { staticClass: "hep-cr-btn-icon", class: { "hep-cr-btn-copied": e.copiedOutput }, attrs: { disabled: e.copiedOutput, title: e.copiedOutput ? "已复制" : "复制" }, on: { click: e.copyOutput } }, [e.copiedOutput ? r("span", { staticClass: "hep-cr-copied-text" }, [e._v("已复制")]) : r("svg", { attrs: { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" } }, [r("rect", { attrs: { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" } }), r("path", { attrs: { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" } })])])])]), r("div", { staticClass: "hep-cr-output-content" }, [e.activeTab === "stdout" ? r("pre", [e._v(e._s(e.isRunning ? "代码执行中..." : e.output || '点击"运行"执行代码'))]) : r("pre", { staticClass: "hep-cr-stderr" }, [e._v(e._s(e.stderr))])])])])]);
|
|
1345
|
+
}, R = [], N = /* @__PURE__ */ m(
|
|
1346
|
+
y,
|
|
1347
|
+
I,
|
|
1348
|
+
R,
|
|
2723
1349
|
!1,
|
|
2724
1350
|
null,
|
|
2725
1351
|
"b9693b7c"
|
|
2726
1352
|
);
|
|
2727
|
-
const
|
|
1353
|
+
const u = N.exports, C = {
|
|
2728
1354
|
name: "CodeRunnerDialog",
|
|
2729
1355
|
components: {
|
|
2730
|
-
CodeRunner:
|
|
1356
|
+
CodeRunner: u
|
|
2731
1357
|
},
|
|
2732
1358
|
props: {
|
|
2733
1359
|
value: {
|
|
@@ -2758,42 +1384,42 @@ const M = ye.exports, Se = {
|
|
|
2758
1384
|
}
|
|
2759
1385
|
},
|
|
2760
1386
|
watch: {
|
|
2761
|
-
value(
|
|
2762
|
-
this.localVisible =
|
|
1387
|
+
value(t) {
|
|
1388
|
+
this.localVisible = t;
|
|
2763
1389
|
}
|
|
2764
1390
|
},
|
|
2765
1391
|
methods: {
|
|
2766
1392
|
close() {
|
|
2767
1393
|
this.localVisible = !1, this.$emit("input", !1), this.$emit("update:value", !1), this.$emit("close");
|
|
2768
1394
|
},
|
|
2769
|
-
handleOverlayClick(
|
|
2770
|
-
|
|
1395
|
+
handleOverlayClick(t) {
|
|
1396
|
+
t.target === t.currentTarget && this.close();
|
|
2771
1397
|
}
|
|
2772
1398
|
},
|
|
2773
1399
|
expose: ["close"]
|
|
2774
1400
|
};
|
|
2775
|
-
var
|
|
2776
|
-
var e = this,
|
|
2777
|
-
return e.localVisible ?
|
|
2778
|
-
},
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
1401
|
+
var w = function() {
|
|
1402
|
+
var e = this, r = e._self._c;
|
|
1403
|
+
return e.localVisible ? r("div", { staticClass: "hep-cr-dialog-overlay", on: { click: e.handleOverlayClick } }, [r("div", { staticClass: "hep-cr-dialog-container", style: { width: e.dialogWidth } }, [r("div", { staticClass: "hep-cr-dialog-header" }, [r("h3", { staticClass: "hep-cr-dialog-title" }, [e._v(e._s(e.title))]), r("button", { staticClass: "hep-cr-dialog-close", on: { click: e.close } }, [r("svg", { attrs: { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" } }, [r("line", { attrs: { x1: "18", y1: "6", x2: "6", y2: "18" } }), r("line", { attrs: { x1: "6", y1: "6", x2: "18", y2: "18" } })])])]), r("div", { staticClass: "hep-cr-dialog-body" }, [r("CodeRunner", e._g(e._b({}, "CodeRunner", e.$attrs, !1), e.$listeners))], 1), r("div", { staticClass: "hep-cr-dialog-footer" }, [e._t("footer", null, { close: e.close })], 2)])]) : e._e();
|
|
1404
|
+
}, O = [], L = /* @__PURE__ */ m(
|
|
1405
|
+
C,
|
|
1406
|
+
w,
|
|
1407
|
+
O,
|
|
2782
1408
|
!1,
|
|
2783
1409
|
null,
|
|
2784
1410
|
"518c34f1"
|
|
2785
1411
|
);
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2788
|
-
|
|
1412
|
+
const D = L.exports;
|
|
1413
|
+
u.install = (t) => {
|
|
1414
|
+
t.component("CodeRunner", u);
|
|
2789
1415
|
};
|
|
2790
|
-
const
|
|
2791
|
-
install(
|
|
2792
|
-
|
|
1416
|
+
const P = {
|
|
1417
|
+
install(t) {
|
|
1418
|
+
t.component("CodeRunner", u);
|
|
2793
1419
|
}
|
|
2794
1420
|
};
|
|
2795
1421
|
export {
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
1422
|
+
u as CodeRunner,
|
|
1423
|
+
D as CodeRunnerDialog,
|
|
1424
|
+
P as default
|
|
2799
1425
|
};
|