@hep-code-runner/react 3.2.0 → 3.2.1
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 +1 -535
- package/dist/index.mjs +3321 -569
- package/package.json +5 -3
package/dist/index.mjs
CHANGED
|
@@ -1,59 +1,2438 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import require$$0, { useRef, useMemo, useCallback, useEffect, useState, forwardRef, useImperativeHandle } from "react";
|
|
2
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
3
|
+
function getDefaultExportFromCjs(x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
5
|
+
}
|
|
6
|
+
var jsxRuntime = { exports: {} };
|
|
7
|
+
var reactJsxRuntime_production_min = {};
|
|
8
|
+
/**
|
|
9
|
+
* @license React
|
|
10
|
+
* react-jsx-runtime.production.min.js
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/
|
|
17
|
+
var hasRequiredReactJsxRuntime_production_min;
|
|
18
|
+
function requireReactJsxRuntime_production_min() {
|
|
19
|
+
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
20
|
+
hasRequiredReactJsxRuntime_production_min = 1;
|
|
21
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m2 = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
22
|
+
function q(c2, a, g) {
|
|
23
|
+
var b, d = {}, e = null, h = null;
|
|
24
|
+
void 0 !== g && (e = "" + g);
|
|
25
|
+
void 0 !== a.key && (e = "" + a.key);
|
|
26
|
+
void 0 !== a.ref && (h = a.ref);
|
|
27
|
+
for (b in a) m2.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
28
|
+
if (c2 && c2.defaultProps) for (b in a = c2.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
|
|
29
|
+
return { $$typeof: k, type: c2, key: e, ref: h, props: d, _owner: n.current };
|
|
30
|
+
}
|
|
31
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
32
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
33
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
34
|
+
return reactJsxRuntime_production_min;
|
|
35
|
+
}
|
|
36
|
+
var reactJsxRuntime_development = {};
|
|
37
|
+
/**
|
|
38
|
+
* @license React
|
|
39
|
+
* react-jsx-runtime.development.js
|
|
40
|
+
*
|
|
41
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
42
|
+
*
|
|
43
|
+
* This source code is licensed under the MIT license found in the
|
|
44
|
+
* LICENSE file in the root directory of this source tree.
|
|
45
|
+
*/
|
|
46
|
+
var hasRequiredReactJsxRuntime_development;
|
|
47
|
+
function requireReactJsxRuntime_development() {
|
|
48
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
49
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
50
|
+
if (process.env.NODE_ENV !== "production") {
|
|
51
|
+
(function() {
|
|
52
|
+
var React = require$$0;
|
|
53
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
|
|
54
|
+
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
|
55
|
+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
56
|
+
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
|
57
|
+
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
58
|
+
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
|
|
59
|
+
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
|
60
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
|
61
|
+
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
62
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
|
|
63
|
+
var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
|
64
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
65
|
+
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
|
|
66
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
67
|
+
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
|
68
|
+
function getIteratorFn(maybeIterable) {
|
|
69
|
+
if (maybeIterable === null || typeof maybeIterable !== "object") {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
73
|
+
if (typeof maybeIterator === "function") {
|
|
74
|
+
return maybeIterator;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
79
|
+
function error(format) {
|
|
80
|
+
{
|
|
81
|
+
{
|
|
82
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
83
|
+
args[_key2 - 1] = arguments[_key2];
|
|
84
|
+
}
|
|
85
|
+
printWarning("error", format, args);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function printWarning(level, format, args) {
|
|
90
|
+
{
|
|
91
|
+
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
92
|
+
var stack = ReactDebugCurrentFrame2.getStackAddendum();
|
|
93
|
+
if (stack !== "") {
|
|
94
|
+
format += "%s";
|
|
95
|
+
args = args.concat([stack]);
|
|
96
|
+
}
|
|
97
|
+
var argsWithFormat = args.map(function(item) {
|
|
98
|
+
return String(item);
|
|
99
|
+
});
|
|
100
|
+
argsWithFormat.unshift("Warning: " + format);
|
|
101
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
var enableScopeAPI = false;
|
|
105
|
+
var enableCacheElement = false;
|
|
106
|
+
var enableTransitionTracing = false;
|
|
107
|
+
var enableLegacyHidden = false;
|
|
108
|
+
var enableDebugTracing = false;
|
|
109
|
+
var REACT_MODULE_REFERENCE;
|
|
110
|
+
{
|
|
111
|
+
REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
|
|
112
|
+
}
|
|
113
|
+
function isValidElementType(type) {
|
|
114
|
+
if (typeof type === "string" || typeof type === "function") {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
if (typeof type === "object" && type !== null) {
|
|
121
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
122
|
+
// types supported by any Flight configuration anywhere since
|
|
123
|
+
// we don't know which Flight build this will end up being used
|
|
124
|
+
// with.
|
|
125
|
+
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
132
|
+
var displayName = outerType.displayName;
|
|
133
|
+
if (displayName) {
|
|
134
|
+
return displayName;
|
|
135
|
+
}
|
|
136
|
+
var functionName = innerType.displayName || innerType.name || "";
|
|
137
|
+
return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
|
|
138
|
+
}
|
|
139
|
+
function getContextName(type) {
|
|
140
|
+
return type.displayName || "Context";
|
|
141
|
+
}
|
|
142
|
+
function getComponentNameFromType(type) {
|
|
143
|
+
if (type == null) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
{
|
|
147
|
+
if (typeof type.tag === "number") {
|
|
148
|
+
error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (typeof type === "function") {
|
|
152
|
+
return type.displayName || type.name || null;
|
|
153
|
+
}
|
|
154
|
+
if (typeof type === "string") {
|
|
155
|
+
return type;
|
|
156
|
+
}
|
|
157
|
+
switch (type) {
|
|
158
|
+
case REACT_FRAGMENT_TYPE:
|
|
159
|
+
return "Fragment";
|
|
160
|
+
case REACT_PORTAL_TYPE:
|
|
161
|
+
return "Portal";
|
|
162
|
+
case REACT_PROFILER_TYPE:
|
|
163
|
+
return "Profiler";
|
|
164
|
+
case REACT_STRICT_MODE_TYPE:
|
|
165
|
+
return "StrictMode";
|
|
166
|
+
case REACT_SUSPENSE_TYPE:
|
|
167
|
+
return "Suspense";
|
|
168
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
169
|
+
return "SuspenseList";
|
|
170
|
+
}
|
|
171
|
+
if (typeof type === "object") {
|
|
172
|
+
switch (type.$$typeof) {
|
|
173
|
+
case REACT_CONTEXT_TYPE:
|
|
174
|
+
var context = type;
|
|
175
|
+
return getContextName(context) + ".Consumer";
|
|
176
|
+
case REACT_PROVIDER_TYPE:
|
|
177
|
+
var provider = type;
|
|
178
|
+
return getContextName(provider._context) + ".Provider";
|
|
179
|
+
case REACT_FORWARD_REF_TYPE:
|
|
180
|
+
return getWrappedName(type, type.render, "ForwardRef");
|
|
181
|
+
case REACT_MEMO_TYPE:
|
|
182
|
+
var outerName = type.displayName || null;
|
|
183
|
+
if (outerName !== null) {
|
|
184
|
+
return outerName;
|
|
185
|
+
}
|
|
186
|
+
return getComponentNameFromType(type.type) || "Memo";
|
|
187
|
+
case REACT_LAZY_TYPE: {
|
|
188
|
+
var lazyComponent = type;
|
|
189
|
+
var payload = lazyComponent._payload;
|
|
190
|
+
var init = lazyComponent._init;
|
|
191
|
+
try {
|
|
192
|
+
return getComponentNameFromType(init(payload));
|
|
193
|
+
} catch (x) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
var assign = Object.assign;
|
|
202
|
+
var disabledDepth = 0;
|
|
203
|
+
var prevLog;
|
|
204
|
+
var prevInfo;
|
|
205
|
+
var prevWarn;
|
|
206
|
+
var prevError;
|
|
207
|
+
var prevGroup;
|
|
208
|
+
var prevGroupCollapsed;
|
|
209
|
+
var prevGroupEnd;
|
|
210
|
+
function disabledLog() {
|
|
211
|
+
}
|
|
212
|
+
disabledLog.__reactDisabledLog = true;
|
|
213
|
+
function disableLogs() {
|
|
214
|
+
{
|
|
215
|
+
if (disabledDepth === 0) {
|
|
216
|
+
prevLog = console.log;
|
|
217
|
+
prevInfo = console.info;
|
|
218
|
+
prevWarn = console.warn;
|
|
219
|
+
prevError = console.error;
|
|
220
|
+
prevGroup = console.group;
|
|
221
|
+
prevGroupCollapsed = console.groupCollapsed;
|
|
222
|
+
prevGroupEnd = console.groupEnd;
|
|
223
|
+
var props = {
|
|
224
|
+
configurable: true,
|
|
225
|
+
enumerable: true,
|
|
226
|
+
value: disabledLog,
|
|
227
|
+
writable: true
|
|
228
|
+
};
|
|
229
|
+
Object.defineProperties(console, {
|
|
230
|
+
info: props,
|
|
231
|
+
log: props,
|
|
232
|
+
warn: props,
|
|
233
|
+
error: props,
|
|
234
|
+
group: props,
|
|
235
|
+
groupCollapsed: props,
|
|
236
|
+
groupEnd: props
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
disabledDepth++;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function reenableLogs() {
|
|
243
|
+
{
|
|
244
|
+
disabledDepth--;
|
|
245
|
+
if (disabledDepth === 0) {
|
|
246
|
+
var props = {
|
|
247
|
+
configurable: true,
|
|
248
|
+
enumerable: true,
|
|
249
|
+
writable: true
|
|
250
|
+
};
|
|
251
|
+
Object.defineProperties(console, {
|
|
252
|
+
log: assign({}, props, {
|
|
253
|
+
value: prevLog
|
|
254
|
+
}),
|
|
255
|
+
info: assign({}, props, {
|
|
256
|
+
value: prevInfo
|
|
257
|
+
}),
|
|
258
|
+
warn: assign({}, props, {
|
|
259
|
+
value: prevWarn
|
|
260
|
+
}),
|
|
261
|
+
error: assign({}, props, {
|
|
262
|
+
value: prevError
|
|
263
|
+
}),
|
|
264
|
+
group: assign({}, props, {
|
|
265
|
+
value: prevGroup
|
|
266
|
+
}),
|
|
267
|
+
groupCollapsed: assign({}, props, {
|
|
268
|
+
value: prevGroupCollapsed
|
|
269
|
+
}),
|
|
270
|
+
groupEnd: assign({}, props, {
|
|
271
|
+
value: prevGroupEnd
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (disabledDepth < 0) {
|
|
276
|
+
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
281
|
+
var prefix;
|
|
282
|
+
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
283
|
+
{
|
|
284
|
+
if (prefix === void 0) {
|
|
285
|
+
try {
|
|
286
|
+
throw Error();
|
|
287
|
+
} catch (x) {
|
|
288
|
+
var match = x.stack.trim().match(/\n( *(at )?)/);
|
|
289
|
+
prefix = match && match[1] || "";
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return "\n" + prefix + name;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
var reentry = false;
|
|
296
|
+
var componentFrameCache;
|
|
297
|
+
{
|
|
298
|
+
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
|
|
299
|
+
componentFrameCache = new PossiblyWeakMap();
|
|
300
|
+
}
|
|
301
|
+
function describeNativeComponentFrame(fn, construct) {
|
|
302
|
+
if (!fn || reentry) {
|
|
303
|
+
return "";
|
|
304
|
+
}
|
|
305
|
+
{
|
|
306
|
+
var frame = componentFrameCache.get(fn);
|
|
307
|
+
if (frame !== void 0) {
|
|
308
|
+
return frame;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
var control;
|
|
312
|
+
reentry = true;
|
|
313
|
+
var previousPrepareStackTrace = Error.prepareStackTrace;
|
|
314
|
+
Error.prepareStackTrace = void 0;
|
|
315
|
+
var previousDispatcher;
|
|
316
|
+
{
|
|
317
|
+
previousDispatcher = ReactCurrentDispatcher.current;
|
|
318
|
+
ReactCurrentDispatcher.current = null;
|
|
319
|
+
disableLogs();
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
if (construct) {
|
|
323
|
+
var Fake = function() {
|
|
324
|
+
throw Error();
|
|
325
|
+
};
|
|
326
|
+
Object.defineProperty(Fake.prototype, "props", {
|
|
327
|
+
set: function() {
|
|
328
|
+
throw Error();
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
if (typeof Reflect === "object" && Reflect.construct) {
|
|
332
|
+
try {
|
|
333
|
+
Reflect.construct(Fake, []);
|
|
334
|
+
} catch (x) {
|
|
335
|
+
control = x;
|
|
336
|
+
}
|
|
337
|
+
Reflect.construct(fn, [], Fake);
|
|
338
|
+
} else {
|
|
339
|
+
try {
|
|
340
|
+
Fake.call();
|
|
341
|
+
} catch (x) {
|
|
342
|
+
control = x;
|
|
343
|
+
}
|
|
344
|
+
fn.call(Fake.prototype);
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
try {
|
|
348
|
+
throw Error();
|
|
349
|
+
} catch (x) {
|
|
350
|
+
control = x;
|
|
351
|
+
}
|
|
352
|
+
fn();
|
|
353
|
+
}
|
|
354
|
+
} catch (sample) {
|
|
355
|
+
if (sample && control && typeof sample.stack === "string") {
|
|
356
|
+
var sampleLines = sample.stack.split("\n");
|
|
357
|
+
var controlLines = control.stack.split("\n");
|
|
358
|
+
var s = sampleLines.length - 1;
|
|
359
|
+
var c2 = controlLines.length - 1;
|
|
360
|
+
while (s >= 1 && c2 >= 0 && sampleLines[s] !== controlLines[c2]) {
|
|
361
|
+
c2--;
|
|
362
|
+
}
|
|
363
|
+
for (; s >= 1 && c2 >= 0; s--, c2--) {
|
|
364
|
+
if (sampleLines[s] !== controlLines[c2]) {
|
|
365
|
+
if (s !== 1 || c2 !== 1) {
|
|
366
|
+
do {
|
|
367
|
+
s--;
|
|
368
|
+
c2--;
|
|
369
|
+
if (c2 < 0 || sampleLines[s] !== controlLines[c2]) {
|
|
370
|
+
var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
|
|
371
|
+
if (fn.displayName && _frame.includes("<anonymous>")) {
|
|
372
|
+
_frame = _frame.replace("<anonymous>", fn.displayName);
|
|
373
|
+
}
|
|
374
|
+
{
|
|
375
|
+
if (typeof fn === "function") {
|
|
376
|
+
componentFrameCache.set(fn, _frame);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return _frame;
|
|
380
|
+
}
|
|
381
|
+
} while (s >= 1 && c2 >= 0);
|
|
382
|
+
}
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
} finally {
|
|
388
|
+
reentry = false;
|
|
389
|
+
{
|
|
390
|
+
ReactCurrentDispatcher.current = previousDispatcher;
|
|
391
|
+
reenableLogs();
|
|
392
|
+
}
|
|
393
|
+
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
394
|
+
}
|
|
395
|
+
var name = fn ? fn.displayName || fn.name : "";
|
|
396
|
+
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
|
|
397
|
+
{
|
|
398
|
+
if (typeof fn === "function") {
|
|
399
|
+
componentFrameCache.set(fn, syntheticFrame);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return syntheticFrame;
|
|
403
|
+
}
|
|
404
|
+
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
405
|
+
{
|
|
406
|
+
return describeNativeComponentFrame(fn, false);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function shouldConstruct(Component) {
|
|
410
|
+
var prototype = Component.prototype;
|
|
411
|
+
return !!(prototype && prototype.isReactComponent);
|
|
412
|
+
}
|
|
413
|
+
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
414
|
+
if (type == null) {
|
|
415
|
+
return "";
|
|
416
|
+
}
|
|
417
|
+
if (typeof type === "function") {
|
|
418
|
+
{
|
|
419
|
+
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (typeof type === "string") {
|
|
423
|
+
return describeBuiltInComponentFrame(type);
|
|
424
|
+
}
|
|
425
|
+
switch (type) {
|
|
426
|
+
case REACT_SUSPENSE_TYPE:
|
|
427
|
+
return describeBuiltInComponentFrame("Suspense");
|
|
428
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
429
|
+
return describeBuiltInComponentFrame("SuspenseList");
|
|
430
|
+
}
|
|
431
|
+
if (typeof type === "object") {
|
|
432
|
+
switch (type.$$typeof) {
|
|
433
|
+
case REACT_FORWARD_REF_TYPE:
|
|
434
|
+
return describeFunctionComponentFrame(type.render);
|
|
435
|
+
case REACT_MEMO_TYPE:
|
|
436
|
+
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
437
|
+
case REACT_LAZY_TYPE: {
|
|
438
|
+
var lazyComponent = type;
|
|
439
|
+
var payload = lazyComponent._payload;
|
|
440
|
+
var init = lazyComponent._init;
|
|
441
|
+
try {
|
|
442
|
+
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
443
|
+
} catch (x) {
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return "";
|
|
449
|
+
}
|
|
450
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
451
|
+
var loggedTypeFailures = {};
|
|
452
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
453
|
+
function setCurrentlyValidatingElement(element) {
|
|
454
|
+
{
|
|
455
|
+
if (element) {
|
|
456
|
+
var owner = element._owner;
|
|
457
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
458
|
+
ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
|
459
|
+
} else {
|
|
460
|
+
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
465
|
+
{
|
|
466
|
+
var has = Function.call.bind(hasOwnProperty);
|
|
467
|
+
for (var typeSpecName in typeSpecs) {
|
|
468
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
469
|
+
var error$1 = void 0;
|
|
470
|
+
try {
|
|
471
|
+
if (typeof typeSpecs[typeSpecName] !== "function") {
|
|
472
|
+
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
473
|
+
err.name = "Invariant Violation";
|
|
474
|
+
throw err;
|
|
475
|
+
}
|
|
476
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
477
|
+
} catch (ex) {
|
|
478
|
+
error$1 = ex;
|
|
479
|
+
}
|
|
480
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
|
481
|
+
setCurrentlyValidatingElement(element);
|
|
482
|
+
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
|
483
|
+
setCurrentlyValidatingElement(null);
|
|
484
|
+
}
|
|
485
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
486
|
+
loggedTypeFailures[error$1.message] = true;
|
|
487
|
+
setCurrentlyValidatingElement(element);
|
|
488
|
+
error("Failed %s type: %s", location, error$1.message);
|
|
489
|
+
setCurrentlyValidatingElement(null);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
var isArrayImpl = Array.isArray;
|
|
496
|
+
function isArray(a) {
|
|
497
|
+
return isArrayImpl(a);
|
|
498
|
+
}
|
|
499
|
+
function typeName(value) {
|
|
500
|
+
{
|
|
501
|
+
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
|
|
502
|
+
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
503
|
+
return type;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function willCoercionThrow(value) {
|
|
507
|
+
{
|
|
508
|
+
try {
|
|
509
|
+
testStringCoercion(value);
|
|
510
|
+
return false;
|
|
511
|
+
} catch (e) {
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
function testStringCoercion(value) {
|
|
517
|
+
return "" + value;
|
|
518
|
+
}
|
|
519
|
+
function checkKeyStringCoercion(value) {
|
|
520
|
+
{
|
|
521
|
+
if (willCoercionThrow(value)) {
|
|
522
|
+
error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
|
|
523
|
+
return testStringCoercion(value);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
528
|
+
var RESERVED_PROPS = {
|
|
529
|
+
key: true,
|
|
530
|
+
ref: true,
|
|
531
|
+
__self: true,
|
|
532
|
+
__source: true
|
|
533
|
+
};
|
|
534
|
+
var specialPropKeyWarningShown;
|
|
535
|
+
var specialPropRefWarningShown;
|
|
536
|
+
function hasValidRef(config) {
|
|
537
|
+
{
|
|
538
|
+
if (hasOwnProperty.call(config, "ref")) {
|
|
539
|
+
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
|
|
540
|
+
if (getter && getter.isReactWarning) {
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return config.ref !== void 0;
|
|
546
|
+
}
|
|
547
|
+
function hasValidKey(config) {
|
|
548
|
+
{
|
|
549
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
550
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
551
|
+
if (getter && getter.isReactWarning) {
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return config.key !== void 0;
|
|
557
|
+
}
|
|
558
|
+
function warnIfStringRefCannotBeAutoConverted(config, self2) {
|
|
559
|
+
{
|
|
560
|
+
if (typeof config.ref === "string" && ReactCurrentOwner.current && self2) ;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
564
|
+
{
|
|
565
|
+
var warnAboutAccessingKey = function() {
|
|
566
|
+
if (!specialPropKeyWarningShown) {
|
|
567
|
+
specialPropKeyWarningShown = true;
|
|
568
|
+
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
572
|
+
Object.defineProperty(props, "key", {
|
|
573
|
+
get: warnAboutAccessingKey,
|
|
574
|
+
configurable: true
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function defineRefPropWarningGetter(props, displayName) {
|
|
579
|
+
{
|
|
580
|
+
var warnAboutAccessingRef = function() {
|
|
581
|
+
if (!specialPropRefWarningShown) {
|
|
582
|
+
specialPropRefWarningShown = true;
|
|
583
|
+
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
587
|
+
Object.defineProperty(props, "ref", {
|
|
588
|
+
get: warnAboutAccessingRef,
|
|
589
|
+
configurable: true
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
var ReactElement = function(type, key, ref, self2, source, owner, props) {
|
|
594
|
+
var element = {
|
|
595
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
596
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
597
|
+
// Built-in properties that belong on the element
|
|
598
|
+
type,
|
|
599
|
+
key,
|
|
600
|
+
ref,
|
|
601
|
+
props,
|
|
602
|
+
// Record the component responsible for creating this element.
|
|
603
|
+
_owner: owner
|
|
604
|
+
};
|
|
605
|
+
{
|
|
606
|
+
element._store = {};
|
|
607
|
+
Object.defineProperty(element._store, "validated", {
|
|
608
|
+
configurable: false,
|
|
609
|
+
enumerable: false,
|
|
610
|
+
writable: true,
|
|
611
|
+
value: false
|
|
612
|
+
});
|
|
613
|
+
Object.defineProperty(element, "_self", {
|
|
614
|
+
configurable: false,
|
|
615
|
+
enumerable: false,
|
|
616
|
+
writable: false,
|
|
617
|
+
value: self2
|
|
618
|
+
});
|
|
619
|
+
Object.defineProperty(element, "_source", {
|
|
620
|
+
configurable: false,
|
|
621
|
+
enumerable: false,
|
|
622
|
+
writable: false,
|
|
623
|
+
value: source
|
|
624
|
+
});
|
|
625
|
+
if (Object.freeze) {
|
|
626
|
+
Object.freeze(element.props);
|
|
627
|
+
Object.freeze(element);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return element;
|
|
631
|
+
};
|
|
632
|
+
function jsxDEV(type, config, maybeKey, source, self2) {
|
|
633
|
+
{
|
|
634
|
+
var propName;
|
|
635
|
+
var props = {};
|
|
636
|
+
var key = null;
|
|
637
|
+
var ref = null;
|
|
638
|
+
if (maybeKey !== void 0) {
|
|
639
|
+
{
|
|
640
|
+
checkKeyStringCoercion(maybeKey);
|
|
641
|
+
}
|
|
642
|
+
key = "" + maybeKey;
|
|
643
|
+
}
|
|
644
|
+
if (hasValidKey(config)) {
|
|
645
|
+
{
|
|
646
|
+
checkKeyStringCoercion(config.key);
|
|
647
|
+
}
|
|
648
|
+
key = "" + config.key;
|
|
649
|
+
}
|
|
650
|
+
if (hasValidRef(config)) {
|
|
651
|
+
ref = config.ref;
|
|
652
|
+
warnIfStringRefCannotBeAutoConverted(config, self2);
|
|
653
|
+
}
|
|
654
|
+
for (propName in config) {
|
|
655
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
656
|
+
props[propName] = config[propName];
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (type && type.defaultProps) {
|
|
660
|
+
var defaultProps = type.defaultProps;
|
|
661
|
+
for (propName in defaultProps) {
|
|
662
|
+
if (props[propName] === void 0) {
|
|
663
|
+
props[propName] = defaultProps[propName];
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (key || ref) {
|
|
668
|
+
var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
|
|
669
|
+
if (key) {
|
|
670
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
671
|
+
}
|
|
672
|
+
if (ref) {
|
|
673
|
+
defineRefPropWarningGetter(props, displayName);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
return ReactElement(type, key, ref, self2, source, ReactCurrentOwner.current, props);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
680
|
+
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
681
|
+
function setCurrentlyValidatingElement$1(element) {
|
|
682
|
+
{
|
|
683
|
+
if (element) {
|
|
684
|
+
var owner = element._owner;
|
|
685
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
686
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
687
|
+
} else {
|
|
688
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
var propTypesMisspellWarningShown;
|
|
693
|
+
{
|
|
694
|
+
propTypesMisspellWarningShown = false;
|
|
695
|
+
}
|
|
696
|
+
function isValidElement(object) {
|
|
697
|
+
{
|
|
698
|
+
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function getDeclarationErrorAddendum() {
|
|
702
|
+
{
|
|
703
|
+
if (ReactCurrentOwner$1.current) {
|
|
704
|
+
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
|
|
705
|
+
if (name) {
|
|
706
|
+
return "\n\nCheck the render method of `" + name + "`.";
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return "";
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function getSourceInfoErrorAddendum(source) {
|
|
713
|
+
{
|
|
714
|
+
return "";
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
var ownerHasKeyUseWarning = {};
|
|
718
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
719
|
+
{
|
|
720
|
+
var info = getDeclarationErrorAddendum();
|
|
721
|
+
if (!info) {
|
|
722
|
+
var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
|
|
723
|
+
if (parentName) {
|
|
724
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
return info;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function validateExplicitKey(element, parentType) {
|
|
731
|
+
{
|
|
732
|
+
if (!element._store || element._store.validated || element.key != null) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
element._store.validated = true;
|
|
736
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
737
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
|
741
|
+
var childOwner = "";
|
|
742
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
743
|
+
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
|
744
|
+
}
|
|
745
|
+
setCurrentlyValidatingElement$1(element);
|
|
746
|
+
error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
747
|
+
setCurrentlyValidatingElement$1(null);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
function validateChildKeys(node, parentType) {
|
|
751
|
+
{
|
|
752
|
+
if (typeof node !== "object") {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
if (isArray(node)) {
|
|
756
|
+
for (var i = 0; i < node.length; i++) {
|
|
757
|
+
var child = node[i];
|
|
758
|
+
if (isValidElement(child)) {
|
|
759
|
+
validateExplicitKey(child, parentType);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
} else if (isValidElement(node)) {
|
|
763
|
+
if (node._store) {
|
|
764
|
+
node._store.validated = true;
|
|
765
|
+
}
|
|
766
|
+
} else if (node) {
|
|
767
|
+
var iteratorFn = getIteratorFn(node);
|
|
768
|
+
if (typeof iteratorFn === "function") {
|
|
769
|
+
if (iteratorFn !== node.entries) {
|
|
770
|
+
var iterator = iteratorFn.call(node);
|
|
771
|
+
var step;
|
|
772
|
+
while (!(step = iterator.next()).done) {
|
|
773
|
+
if (isValidElement(step.value)) {
|
|
774
|
+
validateExplicitKey(step.value, parentType);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function validatePropTypes(element) {
|
|
783
|
+
{
|
|
784
|
+
var type = element.type;
|
|
785
|
+
if (type === null || type === void 0 || typeof type === "string") {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
var propTypes;
|
|
789
|
+
if (typeof type === "function") {
|
|
790
|
+
propTypes = type.propTypes;
|
|
791
|
+
} else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
792
|
+
// Inner props are checked in the reconciler.
|
|
793
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
794
|
+
propTypes = type.propTypes;
|
|
795
|
+
} else {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
if (propTypes) {
|
|
799
|
+
var name = getComponentNameFromType(type);
|
|
800
|
+
checkPropTypes(propTypes, element.props, "prop", name, element);
|
|
801
|
+
} else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
|
|
802
|
+
propTypesMisspellWarningShown = true;
|
|
803
|
+
var _name = getComponentNameFromType(type);
|
|
804
|
+
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
|
|
805
|
+
}
|
|
806
|
+
if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
|
|
807
|
+
error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function validateFragmentProps(fragment) {
|
|
812
|
+
{
|
|
813
|
+
var keys = Object.keys(fragment.props);
|
|
814
|
+
for (var i = 0; i < keys.length; i++) {
|
|
815
|
+
var key = keys[i];
|
|
816
|
+
if (key !== "children" && key !== "key") {
|
|
817
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
818
|
+
error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
|
|
819
|
+
setCurrentlyValidatingElement$1(null);
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
if (fragment.ref !== null) {
|
|
824
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
825
|
+
error("Invalid attribute `ref` supplied to `React.Fragment`.");
|
|
826
|
+
setCurrentlyValidatingElement$1(null);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
var didWarnAboutKeySpread = {};
|
|
831
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self2) {
|
|
832
|
+
{
|
|
833
|
+
var validType = isValidElementType(type);
|
|
834
|
+
if (!validType) {
|
|
835
|
+
var info = "";
|
|
836
|
+
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
|
|
837
|
+
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
|
838
|
+
}
|
|
839
|
+
var sourceInfo = getSourceInfoErrorAddendum();
|
|
840
|
+
if (sourceInfo) {
|
|
841
|
+
info += sourceInfo;
|
|
842
|
+
} else {
|
|
843
|
+
info += getDeclarationErrorAddendum();
|
|
844
|
+
}
|
|
845
|
+
var typeString;
|
|
846
|
+
if (type === null) {
|
|
847
|
+
typeString = "null";
|
|
848
|
+
} else if (isArray(type)) {
|
|
849
|
+
typeString = "array";
|
|
850
|
+
} else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
851
|
+
typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
|
|
852
|
+
info = " Did you accidentally export a JSX literal instead of a component?";
|
|
853
|
+
} else {
|
|
854
|
+
typeString = typeof type;
|
|
855
|
+
}
|
|
856
|
+
error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
|
|
857
|
+
}
|
|
858
|
+
var element = jsxDEV(type, props, key, source, self2);
|
|
859
|
+
if (element == null) {
|
|
860
|
+
return element;
|
|
861
|
+
}
|
|
862
|
+
if (validType) {
|
|
863
|
+
var children = props.children;
|
|
864
|
+
if (children !== void 0) {
|
|
865
|
+
if (isStaticChildren) {
|
|
866
|
+
if (isArray(children)) {
|
|
867
|
+
for (var i = 0; i < children.length; i++) {
|
|
868
|
+
validateChildKeys(children[i], type);
|
|
869
|
+
}
|
|
870
|
+
if (Object.freeze) {
|
|
871
|
+
Object.freeze(children);
|
|
872
|
+
}
|
|
873
|
+
} else {
|
|
874
|
+
error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
875
|
+
}
|
|
876
|
+
} else {
|
|
877
|
+
validateChildKeys(children, type);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
{
|
|
882
|
+
if (hasOwnProperty.call(props, "key")) {
|
|
883
|
+
var componentName = getComponentNameFromType(type);
|
|
884
|
+
var keys = Object.keys(props).filter(function(k) {
|
|
885
|
+
return k !== "key";
|
|
886
|
+
});
|
|
887
|
+
var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
888
|
+
if (!didWarnAboutKeySpread[componentName + beforeExample]) {
|
|
889
|
+
var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
|
|
890
|
+
error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
|
|
891
|
+
didWarnAboutKeySpread[componentName + beforeExample] = true;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
896
|
+
validateFragmentProps(element);
|
|
897
|
+
} else {
|
|
898
|
+
validatePropTypes(element);
|
|
899
|
+
}
|
|
900
|
+
return element;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
function jsxWithValidationStatic(type, props, key) {
|
|
904
|
+
{
|
|
905
|
+
return jsxWithValidation(type, props, key, true);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function jsxWithValidationDynamic(type, props, key) {
|
|
909
|
+
{
|
|
910
|
+
return jsxWithValidation(type, props, key, false);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
var jsx = jsxWithValidationDynamic;
|
|
914
|
+
var jsxs = jsxWithValidationStatic;
|
|
915
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
916
|
+
reactJsxRuntime_development.jsx = jsx;
|
|
917
|
+
reactJsxRuntime_development.jsxs = jsxs;
|
|
918
|
+
})();
|
|
919
|
+
}
|
|
920
|
+
return reactJsxRuntime_development;
|
|
921
|
+
}
|
|
922
|
+
if (process.env.NODE_ENV === "production") {
|
|
923
|
+
jsxRuntime.exports = requireReactJsxRuntime_production_min();
|
|
924
|
+
} else {
|
|
925
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
926
|
+
}
|
|
927
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
928
|
+
var prism = { exports: {} };
|
|
929
|
+
(function(module) {
|
|
930
|
+
var _self = typeof window !== "undefined" ? window : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
|
|
931
|
+
/**
|
|
932
|
+
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
933
|
+
*
|
|
934
|
+
* @license MIT <https://opensource.org/licenses/MIT>
|
|
935
|
+
* @author Lea Verou <https://lea.verou.me>
|
|
936
|
+
* @namespace
|
|
937
|
+
* @public
|
|
938
|
+
*/
|
|
939
|
+
var Prism2 = function(_self2) {
|
|
940
|
+
var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
|
|
941
|
+
var uniqueId = 0;
|
|
942
|
+
var plainTextGrammar = {};
|
|
943
|
+
var _ = {
|
|
944
|
+
/**
|
|
945
|
+
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
946
|
+
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
947
|
+
* additional languages or plugins yourself.
|
|
948
|
+
*
|
|
949
|
+
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
|
950
|
+
*
|
|
951
|
+
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
|
952
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
953
|
+
*
|
|
954
|
+
* ```js
|
|
955
|
+
* window.Prism = window.Prism || {};
|
|
956
|
+
* Prism.manual = true;
|
|
957
|
+
* // add a new <script> to load Prism's script
|
|
958
|
+
* ```
|
|
959
|
+
*
|
|
960
|
+
* @default false
|
|
961
|
+
* @type {boolean}
|
|
962
|
+
* @memberof Prism
|
|
963
|
+
* @public
|
|
964
|
+
*/
|
|
965
|
+
manual: _self2.Prism && _self2.Prism.manual,
|
|
966
|
+
/**
|
|
967
|
+
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
968
|
+
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
969
|
+
* own worker, you don't want it to do this.
|
|
970
|
+
*
|
|
971
|
+
* By setting this value to `true`, Prism will not add its own listeners to the worker.
|
|
972
|
+
*
|
|
973
|
+
* You obviously have to change this value before Prism executes. To do this, you can add an
|
|
974
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
975
|
+
*
|
|
976
|
+
* ```js
|
|
977
|
+
* window.Prism = window.Prism || {};
|
|
978
|
+
* Prism.disableWorkerMessageHandler = true;
|
|
979
|
+
* // Load Prism's script
|
|
980
|
+
* ```
|
|
981
|
+
*
|
|
982
|
+
* @default false
|
|
983
|
+
* @type {boolean}
|
|
984
|
+
* @memberof Prism
|
|
985
|
+
* @public
|
|
986
|
+
*/
|
|
987
|
+
disableWorkerMessageHandler: _self2.Prism && _self2.Prism.disableWorkerMessageHandler,
|
|
988
|
+
/**
|
|
989
|
+
* A namespace for utility methods.
|
|
990
|
+
*
|
|
991
|
+
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
992
|
+
* change or disappear at any time.
|
|
993
|
+
*
|
|
994
|
+
* @namespace
|
|
995
|
+
* @memberof Prism
|
|
996
|
+
*/
|
|
997
|
+
util: {
|
|
998
|
+
encode: function encode(tokens) {
|
|
999
|
+
if (tokens instanceof Token) {
|
|
1000
|
+
return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
|
1001
|
+
} else if (Array.isArray(tokens)) {
|
|
1002
|
+
return tokens.map(encode);
|
|
1003
|
+
} else {
|
|
1004
|
+
return tokens.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
/**
|
|
1008
|
+
* Returns the name of the type of the given value.
|
|
1009
|
+
*
|
|
1010
|
+
* @param {any} o
|
|
1011
|
+
* @returns {string}
|
|
1012
|
+
* @example
|
|
1013
|
+
* type(null) === 'Null'
|
|
1014
|
+
* type(undefined) === 'Undefined'
|
|
1015
|
+
* type(123) === 'Number'
|
|
1016
|
+
* type('foo') === 'String'
|
|
1017
|
+
* type(true) === 'Boolean'
|
|
1018
|
+
* type([1, 2]) === 'Array'
|
|
1019
|
+
* type({}) === 'Object'
|
|
1020
|
+
* type(String) === 'Function'
|
|
1021
|
+
* type(/abc+/) === 'RegExp'
|
|
1022
|
+
*/
|
|
1023
|
+
type: function(o) {
|
|
1024
|
+
return Object.prototype.toString.call(o).slice(8, -1);
|
|
1025
|
+
},
|
|
1026
|
+
/**
|
|
1027
|
+
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
1028
|
+
*
|
|
1029
|
+
* @param {Object} obj
|
|
1030
|
+
* @returns {number}
|
|
1031
|
+
*/
|
|
1032
|
+
objId: function(obj) {
|
|
1033
|
+
if (!obj["__id"]) {
|
|
1034
|
+
Object.defineProperty(obj, "__id", { value: ++uniqueId });
|
|
1035
|
+
}
|
|
1036
|
+
return obj["__id"];
|
|
1037
|
+
},
|
|
1038
|
+
/**
|
|
1039
|
+
* Creates a deep clone of the given object.
|
|
1040
|
+
*
|
|
1041
|
+
* The main intended use of this function is to clone language definitions.
|
|
1042
|
+
*
|
|
1043
|
+
* @param {T} o
|
|
1044
|
+
* @param {Record<number, any>} [visited]
|
|
1045
|
+
* @returns {T}
|
|
1046
|
+
* @template T
|
|
1047
|
+
*/
|
|
1048
|
+
clone: function deepClone(o, visited) {
|
|
1049
|
+
visited = visited || {};
|
|
1050
|
+
var clone;
|
|
1051
|
+
var id;
|
|
1052
|
+
switch (_.util.type(o)) {
|
|
1053
|
+
case "Object":
|
|
1054
|
+
id = _.util.objId(o);
|
|
1055
|
+
if (visited[id]) {
|
|
1056
|
+
return visited[id];
|
|
1057
|
+
}
|
|
1058
|
+
clone = /** @type {Record<string, any>} */
|
|
1059
|
+
{};
|
|
1060
|
+
visited[id] = clone;
|
|
1061
|
+
for (var key in o) {
|
|
1062
|
+
if (o.hasOwnProperty(key)) {
|
|
1063
|
+
clone[key] = deepClone(o[key], visited);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return (
|
|
1067
|
+
/** @type {any} */
|
|
1068
|
+
clone
|
|
1069
|
+
);
|
|
1070
|
+
case "Array":
|
|
1071
|
+
id = _.util.objId(o);
|
|
1072
|
+
if (visited[id]) {
|
|
1073
|
+
return visited[id];
|
|
1074
|
+
}
|
|
1075
|
+
clone = [];
|
|
1076
|
+
visited[id] = clone;
|
|
1077
|
+
/** @type {Array} */
|
|
1078
|
+
/** @type {any} */
|
|
1079
|
+
o.forEach(function(v, i) {
|
|
1080
|
+
clone[i] = deepClone(v, visited);
|
|
1081
|
+
});
|
|
1082
|
+
return (
|
|
1083
|
+
/** @type {any} */
|
|
1084
|
+
clone
|
|
1085
|
+
);
|
|
1086
|
+
default:
|
|
1087
|
+
return o;
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
/**
|
|
1091
|
+
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
|
1092
|
+
*
|
|
1093
|
+
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
|
1094
|
+
*
|
|
1095
|
+
* @param {Element} element
|
|
1096
|
+
* @returns {string}
|
|
1097
|
+
*/
|
|
1098
|
+
getLanguage: function(element) {
|
|
1099
|
+
while (element) {
|
|
1100
|
+
var m2 = lang.exec(element.className);
|
|
1101
|
+
if (m2) {
|
|
1102
|
+
return m2[1].toLowerCase();
|
|
1103
|
+
}
|
|
1104
|
+
element = element.parentElement;
|
|
1105
|
+
}
|
|
1106
|
+
return "none";
|
|
1107
|
+
},
|
|
1108
|
+
/**
|
|
1109
|
+
* Sets the Prism `language-xxxx` class of the given element.
|
|
1110
|
+
*
|
|
1111
|
+
* @param {Element} element
|
|
1112
|
+
* @param {string} language
|
|
1113
|
+
* @returns {void}
|
|
1114
|
+
*/
|
|
1115
|
+
setLanguage: function(element, language) {
|
|
1116
|
+
element.className = element.className.replace(RegExp(lang, "gi"), "");
|
|
1117
|
+
element.classList.add("language-" + language);
|
|
1118
|
+
},
|
|
1119
|
+
/**
|
|
1120
|
+
* Returns the script element that is currently executing.
|
|
1121
|
+
*
|
|
1122
|
+
* This does __not__ work for line script element.
|
|
1123
|
+
*
|
|
1124
|
+
* @returns {HTMLScriptElement | null}
|
|
1125
|
+
*/
|
|
1126
|
+
currentScript: function() {
|
|
1127
|
+
if (typeof document === "undefined") {
|
|
1128
|
+
return null;
|
|
1129
|
+
}
|
|
1130
|
+
if (document.currentScript && document.currentScript.tagName === "SCRIPT" && 1 < 2) {
|
|
1131
|
+
return (
|
|
1132
|
+
/** @type {any} */
|
|
1133
|
+
document.currentScript
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
try {
|
|
1137
|
+
throw new Error();
|
|
1138
|
+
} catch (err) {
|
|
1139
|
+
var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
|
|
1140
|
+
if (src) {
|
|
1141
|
+
var scripts = document.getElementsByTagName("script");
|
|
1142
|
+
for (var i in scripts) {
|
|
1143
|
+
if (scripts[i].src == src) {
|
|
1144
|
+
return scripts[i];
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
return null;
|
|
1149
|
+
}
|
|
1150
|
+
},
|
|
1151
|
+
/**
|
|
1152
|
+
* Returns whether a given class is active for `element`.
|
|
1153
|
+
*
|
|
1154
|
+
* The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
|
|
1155
|
+
* if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
|
|
1156
|
+
* given class is just the given class with a `no-` prefix.
|
|
1157
|
+
*
|
|
1158
|
+
* Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
|
|
1159
|
+
* closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
|
|
1160
|
+
* ancestors have the given class or the negated version of it, then the default activation will be returned.
|
|
1161
|
+
*
|
|
1162
|
+
* In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
|
|
1163
|
+
* version of it, the class is considered active.
|
|
1164
|
+
*
|
|
1165
|
+
* @param {Element} element
|
|
1166
|
+
* @param {string} className
|
|
1167
|
+
* @param {boolean} [defaultActivation=false]
|
|
1168
|
+
* @returns {boolean}
|
|
1169
|
+
*/
|
|
1170
|
+
isActive: function(element, className, defaultActivation) {
|
|
1171
|
+
var no = "no-" + className;
|
|
1172
|
+
while (element) {
|
|
1173
|
+
var classList = element.classList;
|
|
1174
|
+
if (classList.contains(className)) {
|
|
1175
|
+
return true;
|
|
1176
|
+
}
|
|
1177
|
+
if (classList.contains(no)) {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
element = element.parentElement;
|
|
1181
|
+
}
|
|
1182
|
+
return !!defaultActivation;
|
|
1183
|
+
}
|
|
1184
|
+
},
|
|
1185
|
+
/**
|
|
1186
|
+
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
|
1187
|
+
*
|
|
1188
|
+
* @namespace
|
|
1189
|
+
* @memberof Prism
|
|
1190
|
+
* @public
|
|
1191
|
+
*/
|
|
1192
|
+
languages: {
|
|
1193
|
+
/**
|
|
1194
|
+
* The grammar for plain, unformatted text.
|
|
1195
|
+
*/
|
|
1196
|
+
plain: plainTextGrammar,
|
|
1197
|
+
plaintext: plainTextGrammar,
|
|
1198
|
+
text: plainTextGrammar,
|
|
1199
|
+
txt: plainTextGrammar,
|
|
1200
|
+
/**
|
|
1201
|
+
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
1202
|
+
*
|
|
1203
|
+
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
|
1204
|
+
* will be overwritten at its original position.
|
|
1205
|
+
*
|
|
1206
|
+
* ## Best practices
|
|
1207
|
+
*
|
|
1208
|
+
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
|
1209
|
+
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
|
1210
|
+
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
|
1211
|
+
*
|
|
1212
|
+
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
|
1213
|
+
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
|
1214
|
+
*
|
|
1215
|
+
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
|
1216
|
+
* @param {Grammar} redef The new tokens to append.
|
|
1217
|
+
* @returns {Grammar} The new language created.
|
|
1218
|
+
* @public
|
|
1219
|
+
* @example
|
|
1220
|
+
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
|
1221
|
+
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
|
1222
|
+
* // at its original position
|
|
1223
|
+
* 'comment': { ... },
|
|
1224
|
+
* // CSS doesn't have a 'color' token, so this token will be appended
|
|
1225
|
+
* 'color': /\b(?:red|green|blue)\b/
|
|
1226
|
+
* });
|
|
1227
|
+
*/
|
|
1228
|
+
extend: function(id, redef) {
|
|
1229
|
+
var lang2 = _.util.clone(_.languages[id]);
|
|
1230
|
+
for (var key in redef) {
|
|
1231
|
+
lang2[key] = redef[key];
|
|
1232
|
+
}
|
|
1233
|
+
return lang2;
|
|
1234
|
+
},
|
|
1235
|
+
/**
|
|
1236
|
+
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
1237
|
+
*
|
|
1238
|
+
* ## Usage
|
|
1239
|
+
*
|
|
1240
|
+
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
|
1241
|
+
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
|
1242
|
+
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
|
1243
|
+
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
|
1244
|
+
* this:
|
|
1245
|
+
*
|
|
1246
|
+
* ```js
|
|
1247
|
+
* Prism.languages.markup.style = {
|
|
1248
|
+
* // token
|
|
1249
|
+
* };
|
|
1250
|
+
* ```
|
|
1251
|
+
*
|
|
1252
|
+
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
|
1253
|
+
* before existing tokens. For the CSS example above, you would use it like this:
|
|
1254
|
+
*
|
|
1255
|
+
* ```js
|
|
1256
|
+
* Prism.languages.insertBefore('markup', 'cdata', {
|
|
1257
|
+
* 'style': {
|
|
1258
|
+
* // token
|
|
1259
|
+
* }
|
|
1260
|
+
* });
|
|
1261
|
+
* ```
|
|
1262
|
+
*
|
|
1263
|
+
* ## Special cases
|
|
1264
|
+
*
|
|
1265
|
+
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
|
1266
|
+
* will be ignored.
|
|
1267
|
+
*
|
|
1268
|
+
* This behavior can be used to insert tokens after `before`:
|
|
1269
|
+
*
|
|
1270
|
+
* ```js
|
|
1271
|
+
* Prism.languages.insertBefore('markup', 'comment', {
|
|
1272
|
+
* 'comment': Prism.languages.markup.comment,
|
|
1273
|
+
* // tokens after 'comment'
|
|
1274
|
+
* });
|
|
1275
|
+
* ```
|
|
1276
|
+
*
|
|
1277
|
+
* ## Limitations
|
|
1278
|
+
*
|
|
1279
|
+
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
|
1280
|
+
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
|
1281
|
+
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
|
1282
|
+
* deleting properties which is necessary to insert at arbitrary positions.
|
|
1283
|
+
*
|
|
1284
|
+
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
|
1285
|
+
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
|
1286
|
+
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
|
1287
|
+
*
|
|
1288
|
+
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
|
1289
|
+
* you hold the target object in a variable, then the value of the variable will not change.
|
|
1290
|
+
*
|
|
1291
|
+
* ```js
|
|
1292
|
+
* var oldMarkup = Prism.languages.markup;
|
|
1293
|
+
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
|
1294
|
+
*
|
|
1295
|
+
* assert(oldMarkup !== Prism.languages.markup);
|
|
1296
|
+
* assert(newMarkup === Prism.languages.markup);
|
|
1297
|
+
* ```
|
|
1298
|
+
*
|
|
1299
|
+
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
|
1300
|
+
* object to be modified.
|
|
1301
|
+
* @param {string} before The key to insert before.
|
|
1302
|
+
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
|
1303
|
+
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
|
1304
|
+
* object to be modified.
|
|
1305
|
+
*
|
|
1306
|
+
* Defaults to `Prism.languages`.
|
|
1307
|
+
* @returns {Grammar} The new grammar object.
|
|
1308
|
+
* @public
|
|
1309
|
+
*/
|
|
1310
|
+
insertBefore: function(inside, before, insert, root) {
|
|
1311
|
+
root = root || /** @type {any} */
|
|
1312
|
+
_.languages;
|
|
1313
|
+
var grammar = root[inside];
|
|
1314
|
+
var ret = {};
|
|
1315
|
+
for (var token in grammar) {
|
|
1316
|
+
if (grammar.hasOwnProperty(token)) {
|
|
1317
|
+
if (token == before) {
|
|
1318
|
+
for (var newToken in insert) {
|
|
1319
|
+
if (insert.hasOwnProperty(newToken)) {
|
|
1320
|
+
ret[newToken] = insert[newToken];
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
if (!insert.hasOwnProperty(token)) {
|
|
1325
|
+
ret[token] = grammar[token];
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
var old = root[inside];
|
|
1330
|
+
root[inside] = ret;
|
|
1331
|
+
_.languages.DFS(_.languages, function(key, value) {
|
|
1332
|
+
if (value === old && key != inside) {
|
|
1333
|
+
this[key] = ret;
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
return ret;
|
|
1337
|
+
},
|
|
1338
|
+
// Traverse a language definition with Depth First Search
|
|
1339
|
+
DFS: function DFS(o, callback, type, visited) {
|
|
1340
|
+
visited = visited || {};
|
|
1341
|
+
var objId = _.util.objId;
|
|
1342
|
+
for (var i in o) {
|
|
1343
|
+
if (o.hasOwnProperty(i)) {
|
|
1344
|
+
callback.call(o, i, o[i], type || i);
|
|
1345
|
+
var property = o[i];
|
|
1346
|
+
var propertyType = _.util.type(property);
|
|
1347
|
+
if (propertyType === "Object" && !visited[objId(property)]) {
|
|
1348
|
+
visited[objId(property)] = true;
|
|
1349
|
+
DFS(property, callback, null, visited);
|
|
1350
|
+
} else if (propertyType === "Array" && !visited[objId(property)]) {
|
|
1351
|
+
visited[objId(property)] = true;
|
|
1352
|
+
DFS(property, callback, i, visited);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
},
|
|
1358
|
+
plugins: {},
|
|
1359
|
+
/**
|
|
1360
|
+
* This is the most high-level function in Prism’s API.
|
|
1361
|
+
* It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
|
|
1362
|
+
* each one of them.
|
|
1363
|
+
*
|
|
1364
|
+
* This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
|
|
1365
|
+
*
|
|
1366
|
+
* @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
|
|
1367
|
+
* @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
|
|
1368
|
+
* @memberof Prism
|
|
1369
|
+
* @public
|
|
1370
|
+
*/
|
|
1371
|
+
highlightAll: function(async, callback) {
|
|
1372
|
+
_.highlightAllUnder(document, async, callback);
|
|
1373
|
+
},
|
|
1374
|
+
/**
|
|
1375
|
+
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
1376
|
+
* {@link Prism.highlightElement} on each one of them.
|
|
1377
|
+
*
|
|
1378
|
+
* The following hooks will be run:
|
|
1379
|
+
* 1. `before-highlightall`
|
|
1380
|
+
* 2. `before-all-elements-highlight`
|
|
1381
|
+
* 3. All hooks of {@link Prism.highlightElement} for each element.
|
|
1382
|
+
*
|
|
1383
|
+
* @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
|
|
1384
|
+
* @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
|
|
1385
|
+
* @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
|
|
1386
|
+
* @memberof Prism
|
|
1387
|
+
* @public
|
|
1388
|
+
*/
|
|
1389
|
+
highlightAllUnder: function(container, async, callback) {
|
|
1390
|
+
var env = {
|
|
1391
|
+
callback,
|
|
1392
|
+
container,
|
|
1393
|
+
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
1394
|
+
};
|
|
1395
|
+
_.hooks.run("before-highlightall", env);
|
|
1396
|
+
env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
|
|
1397
|
+
_.hooks.run("before-all-elements-highlight", env);
|
|
1398
|
+
for (var i = 0, element; element = env.elements[i++]; ) {
|
|
1399
|
+
_.highlightElement(element, async === true, env.callback);
|
|
1400
|
+
}
|
|
1401
|
+
},
|
|
1402
|
+
/**
|
|
1403
|
+
* Highlights the code inside a single element.
|
|
1404
|
+
*
|
|
1405
|
+
* The following hooks will be run:
|
|
1406
|
+
* 1. `before-sanity-check`
|
|
1407
|
+
* 2. `before-highlight`
|
|
1408
|
+
* 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
|
|
1409
|
+
* 4. `before-insert`
|
|
1410
|
+
* 5. `after-highlight`
|
|
1411
|
+
* 6. `complete`
|
|
1412
|
+
*
|
|
1413
|
+
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
|
|
1414
|
+
* the element's language.
|
|
1415
|
+
*
|
|
1416
|
+
* @param {Element} element The element containing the code.
|
|
1417
|
+
* It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
|
|
1418
|
+
* @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
|
|
1419
|
+
* to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
|
|
1420
|
+
* [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
|
|
1421
|
+
*
|
|
1422
|
+
* Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
|
|
1423
|
+
* asynchronous highlighting to work. You can build your own bundle on the
|
|
1424
|
+
* [Download page](https://prismjs.com/download.html).
|
|
1425
|
+
* @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
|
|
1426
|
+
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
|
|
1427
|
+
* @memberof Prism
|
|
1428
|
+
* @public
|
|
1429
|
+
*/
|
|
1430
|
+
highlightElement: function(element, async, callback) {
|
|
1431
|
+
var language = _.util.getLanguage(element);
|
|
1432
|
+
var grammar = _.languages[language];
|
|
1433
|
+
_.util.setLanguage(element, language);
|
|
1434
|
+
var parent = element.parentElement;
|
|
1435
|
+
if (parent && parent.nodeName.toLowerCase() === "pre") {
|
|
1436
|
+
_.util.setLanguage(parent, language);
|
|
1437
|
+
}
|
|
1438
|
+
var code = element.textContent;
|
|
1439
|
+
var env = {
|
|
1440
|
+
element,
|
|
1441
|
+
language,
|
|
1442
|
+
grammar,
|
|
1443
|
+
code
|
|
1444
|
+
};
|
|
1445
|
+
function insertHighlightedCode(highlightedCode) {
|
|
1446
|
+
env.highlightedCode = highlightedCode;
|
|
1447
|
+
_.hooks.run("before-insert", env);
|
|
1448
|
+
env.element.innerHTML = env.highlightedCode;
|
|
1449
|
+
_.hooks.run("after-highlight", env);
|
|
1450
|
+
_.hooks.run("complete", env);
|
|
1451
|
+
callback && callback.call(env.element);
|
|
1452
|
+
}
|
|
1453
|
+
_.hooks.run("before-sanity-check", env);
|
|
1454
|
+
parent = env.element.parentElement;
|
|
1455
|
+
if (parent && parent.nodeName.toLowerCase() === "pre" && !parent.hasAttribute("tabindex")) {
|
|
1456
|
+
parent.setAttribute("tabindex", "0");
|
|
1457
|
+
}
|
|
1458
|
+
if (!env.code) {
|
|
1459
|
+
_.hooks.run("complete", env);
|
|
1460
|
+
callback && callback.call(env.element);
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
_.hooks.run("before-highlight", env);
|
|
1464
|
+
if (!env.grammar) {
|
|
1465
|
+
insertHighlightedCode(_.util.encode(env.code));
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
if (async && _self2.Worker) {
|
|
1469
|
+
var worker = new Worker(_.filename);
|
|
1470
|
+
worker.onmessage = function(evt) {
|
|
1471
|
+
insertHighlightedCode(evt.data);
|
|
1472
|
+
};
|
|
1473
|
+
worker.postMessage(JSON.stringify({
|
|
1474
|
+
language: env.language,
|
|
1475
|
+
code: env.code,
|
|
1476
|
+
immediateClose: true
|
|
1477
|
+
}));
|
|
1478
|
+
} else {
|
|
1479
|
+
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
|
|
1480
|
+
}
|
|
1481
|
+
},
|
|
1482
|
+
/**
|
|
1483
|
+
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
1484
|
+
* and the language definitions to use, and returns a string with the HTML produced.
|
|
1485
|
+
*
|
|
1486
|
+
* The following hooks will be run:
|
|
1487
|
+
* 1. `before-tokenize`
|
|
1488
|
+
* 2. `after-tokenize`
|
|
1489
|
+
* 3. `wrap`: On each {@link Token}.
|
|
1490
|
+
*
|
|
1491
|
+
* @param {string} text A string with the code to be highlighted.
|
|
1492
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
1493
|
+
*
|
|
1494
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
1495
|
+
* @param {string} language The name of the language definition passed to `grammar`.
|
|
1496
|
+
* @returns {string} The highlighted HTML.
|
|
1497
|
+
* @memberof Prism
|
|
1498
|
+
* @public
|
|
1499
|
+
* @example
|
|
1500
|
+
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
1501
|
+
*/
|
|
1502
|
+
highlight: function(text, grammar, language) {
|
|
1503
|
+
var env = {
|
|
1504
|
+
code: text,
|
|
1505
|
+
grammar,
|
|
1506
|
+
language
|
|
1507
|
+
};
|
|
1508
|
+
_.hooks.run("before-tokenize", env);
|
|
1509
|
+
if (!env.grammar) {
|
|
1510
|
+
throw new Error('The language "' + env.language + '" has no grammar.');
|
|
1511
|
+
}
|
|
1512
|
+
env.tokens = _.tokenize(env.code, env.grammar);
|
|
1513
|
+
_.hooks.run("after-tokenize", env);
|
|
1514
|
+
return Token.stringify(_.util.encode(env.tokens), env.language);
|
|
1515
|
+
},
|
|
1516
|
+
/**
|
|
1517
|
+
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
1518
|
+
* and the language definitions to use, and returns an array with the tokenized code.
|
|
1519
|
+
*
|
|
1520
|
+
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
|
1521
|
+
*
|
|
1522
|
+
* This method could be useful in other contexts as well, as a very crude parser.
|
|
1523
|
+
*
|
|
1524
|
+
* @param {string} text A string with the code to be highlighted.
|
|
1525
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
1526
|
+
*
|
|
1527
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
1528
|
+
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
|
1529
|
+
* @memberof Prism
|
|
1530
|
+
* @public
|
|
1531
|
+
* @example
|
|
1532
|
+
* let code = `var foo = 0;`;
|
|
1533
|
+
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
|
1534
|
+
* tokens.forEach(token => {
|
|
1535
|
+
* if (token instanceof Prism.Token && token.type === 'number') {
|
|
1536
|
+
* console.log(`Found numeric literal: ${token.content}`);
|
|
1537
|
+
* }
|
|
1538
|
+
* });
|
|
1539
|
+
*/
|
|
1540
|
+
tokenize: function(text, grammar) {
|
|
1541
|
+
var rest = grammar.rest;
|
|
1542
|
+
if (rest) {
|
|
1543
|
+
for (var token in rest) {
|
|
1544
|
+
grammar[token] = rest[token];
|
|
1545
|
+
}
|
|
1546
|
+
delete grammar.rest;
|
|
1547
|
+
}
|
|
1548
|
+
var tokenList = new LinkedList();
|
|
1549
|
+
addAfter(tokenList, tokenList.head, text);
|
|
1550
|
+
matchGrammar(text, tokenList, grammar, tokenList.head, 0);
|
|
1551
|
+
return toArray(tokenList);
|
|
1552
|
+
},
|
|
1553
|
+
/**
|
|
1554
|
+
* @namespace
|
|
1555
|
+
* @memberof Prism
|
|
1556
|
+
* @public
|
|
1557
|
+
*/
|
|
1558
|
+
hooks: {
|
|
1559
|
+
all: {},
|
|
1560
|
+
/**
|
|
1561
|
+
* Adds the given callback to the list of callbacks for the given hook.
|
|
1562
|
+
*
|
|
1563
|
+
* The callback will be invoked when the hook it is registered for is run.
|
|
1564
|
+
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
|
1565
|
+
*
|
|
1566
|
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
1567
|
+
*
|
|
1568
|
+
* @param {string} name The name of the hook.
|
|
1569
|
+
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
1570
|
+
* @public
|
|
1571
|
+
*/
|
|
1572
|
+
add: function(name, callback) {
|
|
1573
|
+
var hooks = _.hooks.all;
|
|
1574
|
+
hooks[name] = hooks[name] || [];
|
|
1575
|
+
hooks[name].push(callback);
|
|
1576
|
+
},
|
|
1577
|
+
/**
|
|
1578
|
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
1579
|
+
*
|
|
1580
|
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
1581
|
+
*
|
|
1582
|
+
* @param {string} name The name of the hook.
|
|
1583
|
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
1584
|
+
* @public
|
|
1585
|
+
*/
|
|
1586
|
+
run: function(name, env) {
|
|
1587
|
+
var callbacks = _.hooks.all[name];
|
|
1588
|
+
if (!callbacks || !callbacks.length) {
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1591
|
+
for (var i = 0, callback; callback = callbacks[i++]; ) {
|
|
1592
|
+
callback(env);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
},
|
|
1596
|
+
Token
|
|
1597
|
+
};
|
|
1598
|
+
_self2.Prism = _;
|
|
1599
|
+
function Token(type, content, alias, matchedStr) {
|
|
1600
|
+
this.type = type;
|
|
1601
|
+
this.content = content;
|
|
1602
|
+
this.alias = alias;
|
|
1603
|
+
this.length = (matchedStr || "").length | 0;
|
|
1604
|
+
}
|
|
1605
|
+
Token.stringify = function stringify(o, language) {
|
|
1606
|
+
if (typeof o == "string") {
|
|
1607
|
+
return o;
|
|
1608
|
+
}
|
|
1609
|
+
if (Array.isArray(o)) {
|
|
1610
|
+
var s = "";
|
|
1611
|
+
o.forEach(function(e) {
|
|
1612
|
+
s += stringify(e, language);
|
|
1613
|
+
});
|
|
1614
|
+
return s;
|
|
1615
|
+
}
|
|
1616
|
+
var env = {
|
|
1617
|
+
type: o.type,
|
|
1618
|
+
content: stringify(o.content, language),
|
|
1619
|
+
tag: "span",
|
|
1620
|
+
classes: ["token", o.type],
|
|
1621
|
+
attributes: {},
|
|
1622
|
+
language
|
|
1623
|
+
};
|
|
1624
|
+
var aliases = o.alias;
|
|
1625
|
+
if (aliases) {
|
|
1626
|
+
if (Array.isArray(aliases)) {
|
|
1627
|
+
Array.prototype.push.apply(env.classes, aliases);
|
|
1628
|
+
} else {
|
|
1629
|
+
env.classes.push(aliases);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
_.hooks.run("wrap", env);
|
|
1633
|
+
var attributes = "";
|
|
1634
|
+
for (var name in env.attributes) {
|
|
1635
|
+
attributes += " " + name + '="' + (env.attributes[name] || "").replace(/"/g, """) + '"';
|
|
1636
|
+
}
|
|
1637
|
+
return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + attributes + ">" + env.content + "</" + env.tag + ">";
|
|
1638
|
+
};
|
|
1639
|
+
function matchPattern(pattern, pos, text, lookbehind) {
|
|
1640
|
+
pattern.lastIndex = pos;
|
|
1641
|
+
var match = pattern.exec(text);
|
|
1642
|
+
if (match && lookbehind && match[1]) {
|
|
1643
|
+
var lookbehindLength = match[1].length;
|
|
1644
|
+
match.index += lookbehindLength;
|
|
1645
|
+
match[0] = match[0].slice(lookbehindLength);
|
|
1646
|
+
}
|
|
1647
|
+
return match;
|
|
1648
|
+
}
|
|
1649
|
+
function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
|
1650
|
+
for (var token in grammar) {
|
|
1651
|
+
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
|
1652
|
+
continue;
|
|
1653
|
+
}
|
|
1654
|
+
var patterns = grammar[token];
|
|
1655
|
+
patterns = Array.isArray(patterns) ? patterns : [patterns];
|
|
1656
|
+
for (var j2 = 0; j2 < patterns.length; ++j2) {
|
|
1657
|
+
if (rematch && rematch.cause == token + "," + j2) {
|
|
1658
|
+
return;
|
|
1659
|
+
}
|
|
1660
|
+
var patternObj = patterns[j2];
|
|
1661
|
+
var inside = patternObj.inside;
|
|
1662
|
+
var lookbehind = !!patternObj.lookbehind;
|
|
1663
|
+
var greedy = !!patternObj.greedy;
|
|
1664
|
+
var alias = patternObj.alias;
|
|
1665
|
+
if (greedy && !patternObj.pattern.global) {
|
|
1666
|
+
var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
|
|
1667
|
+
patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
|
|
1668
|
+
}
|
|
1669
|
+
var pattern = patternObj.pattern || patternObj;
|
|
1670
|
+
for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
|
|
1671
|
+
if (rematch && pos >= rematch.reach) {
|
|
1672
|
+
break;
|
|
1673
|
+
}
|
|
1674
|
+
var str = currentNode.value;
|
|
1675
|
+
if (tokenList.length > text.length) {
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
if (str instanceof Token) {
|
|
1679
|
+
continue;
|
|
1680
|
+
}
|
|
1681
|
+
var removeCount = 1;
|
|
1682
|
+
var match;
|
|
1683
|
+
if (greedy) {
|
|
1684
|
+
match = matchPattern(pattern, pos, text, lookbehind);
|
|
1685
|
+
if (!match || match.index >= text.length) {
|
|
1686
|
+
break;
|
|
1687
|
+
}
|
|
1688
|
+
var from = match.index;
|
|
1689
|
+
var to = match.index + match[0].length;
|
|
1690
|
+
var p = pos;
|
|
1691
|
+
p += currentNode.value.length;
|
|
1692
|
+
while (from >= p) {
|
|
1693
|
+
currentNode = currentNode.next;
|
|
1694
|
+
p += currentNode.value.length;
|
|
1695
|
+
}
|
|
1696
|
+
p -= currentNode.value.length;
|
|
1697
|
+
pos = p;
|
|
1698
|
+
if (currentNode.value instanceof Token) {
|
|
1699
|
+
continue;
|
|
1700
|
+
}
|
|
1701
|
+
for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
|
|
1702
|
+
removeCount++;
|
|
1703
|
+
p += k.value.length;
|
|
1704
|
+
}
|
|
1705
|
+
removeCount--;
|
|
1706
|
+
str = text.slice(pos, p);
|
|
1707
|
+
match.index -= pos;
|
|
1708
|
+
} else {
|
|
1709
|
+
match = matchPattern(pattern, 0, str, lookbehind);
|
|
1710
|
+
if (!match) {
|
|
1711
|
+
continue;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
var from = match.index;
|
|
1715
|
+
var matchStr = match[0];
|
|
1716
|
+
var before = str.slice(0, from);
|
|
1717
|
+
var after = str.slice(from + matchStr.length);
|
|
1718
|
+
var reach = pos + str.length;
|
|
1719
|
+
if (rematch && reach > rematch.reach) {
|
|
1720
|
+
rematch.reach = reach;
|
|
1721
|
+
}
|
|
1722
|
+
var removeFrom = currentNode.prev;
|
|
1723
|
+
if (before) {
|
|
1724
|
+
removeFrom = addAfter(tokenList, removeFrom, before);
|
|
1725
|
+
pos += before.length;
|
|
1726
|
+
}
|
|
1727
|
+
removeRange(tokenList, removeFrom, removeCount);
|
|
1728
|
+
var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
|
|
1729
|
+
currentNode = addAfter(tokenList, removeFrom, wrapped);
|
|
1730
|
+
if (after) {
|
|
1731
|
+
addAfter(tokenList, currentNode, after);
|
|
1732
|
+
}
|
|
1733
|
+
if (removeCount > 1) {
|
|
1734
|
+
var nestedRematch = {
|
|
1735
|
+
cause: token + "," + j2,
|
|
1736
|
+
reach
|
|
1737
|
+
};
|
|
1738
|
+
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
|
|
1739
|
+
if (rematch && nestedRematch.reach > rematch.reach) {
|
|
1740
|
+
rematch.reach = nestedRematch.reach;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
function LinkedList() {
|
|
1748
|
+
var head = { value: null, prev: null, next: null };
|
|
1749
|
+
var tail = { value: null, prev: head, next: null };
|
|
1750
|
+
head.next = tail;
|
|
1751
|
+
this.head = head;
|
|
1752
|
+
this.tail = tail;
|
|
1753
|
+
this.length = 0;
|
|
1754
|
+
}
|
|
1755
|
+
function addAfter(list, node, value) {
|
|
1756
|
+
var next = node.next;
|
|
1757
|
+
var newNode = { value, prev: node, next };
|
|
1758
|
+
node.next = newNode;
|
|
1759
|
+
next.prev = newNode;
|
|
1760
|
+
list.length++;
|
|
1761
|
+
return newNode;
|
|
1762
|
+
}
|
|
1763
|
+
function removeRange(list, node, count) {
|
|
1764
|
+
var next = node.next;
|
|
1765
|
+
for (var i = 0; i < count && next !== list.tail; i++) {
|
|
1766
|
+
next = next.next;
|
|
1767
|
+
}
|
|
1768
|
+
node.next = next;
|
|
1769
|
+
next.prev = node;
|
|
1770
|
+
list.length -= i;
|
|
1771
|
+
}
|
|
1772
|
+
function toArray(list) {
|
|
1773
|
+
var array = [];
|
|
1774
|
+
var node = list.head.next;
|
|
1775
|
+
while (node !== list.tail) {
|
|
1776
|
+
array.push(node.value);
|
|
1777
|
+
node = node.next;
|
|
1778
|
+
}
|
|
1779
|
+
return array;
|
|
1780
|
+
}
|
|
1781
|
+
if (!_self2.document) {
|
|
1782
|
+
if (!_self2.addEventListener) {
|
|
1783
|
+
return _;
|
|
1784
|
+
}
|
|
1785
|
+
if (!_.disableWorkerMessageHandler) {
|
|
1786
|
+
_self2.addEventListener("message", function(evt) {
|
|
1787
|
+
var message = JSON.parse(evt.data);
|
|
1788
|
+
var lang2 = message.language;
|
|
1789
|
+
var code = message.code;
|
|
1790
|
+
var immediateClose = message.immediateClose;
|
|
1791
|
+
_self2.postMessage(_.highlight(code, _.languages[lang2], lang2));
|
|
1792
|
+
if (immediateClose) {
|
|
1793
|
+
_self2.close();
|
|
1794
|
+
}
|
|
1795
|
+
}, false);
|
|
1796
|
+
}
|
|
1797
|
+
return _;
|
|
1798
|
+
}
|
|
1799
|
+
var script = _.util.currentScript();
|
|
1800
|
+
if (script) {
|
|
1801
|
+
_.filename = script.src;
|
|
1802
|
+
if (script.hasAttribute("data-manual")) {
|
|
1803
|
+
_.manual = true;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
function highlightAutomaticallyCallback() {
|
|
1807
|
+
if (!_.manual) {
|
|
1808
|
+
_.highlightAll();
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
if (!_.manual) {
|
|
1812
|
+
var readyState = document.readyState;
|
|
1813
|
+
if (readyState === "loading" || readyState === "interactive" && script && script.defer) {
|
|
1814
|
+
document.addEventListener("DOMContentLoaded", highlightAutomaticallyCallback);
|
|
1815
|
+
} else {
|
|
1816
|
+
if (window.requestAnimationFrame) {
|
|
1817
|
+
window.requestAnimationFrame(highlightAutomaticallyCallback);
|
|
1818
|
+
} else {
|
|
1819
|
+
window.setTimeout(highlightAutomaticallyCallback, 16);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
return _;
|
|
1824
|
+
}(_self);
|
|
1825
|
+
if (module.exports) {
|
|
1826
|
+
module.exports = Prism2;
|
|
1827
|
+
}
|
|
1828
|
+
if (typeof commonjsGlobal !== "undefined") {
|
|
1829
|
+
commonjsGlobal.Prism = Prism2;
|
|
1830
|
+
}
|
|
1831
|
+
Prism2.languages.markup = {
|
|
1832
|
+
"comment": {
|
|
1833
|
+
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
1834
|
+
greedy: true
|
|
1835
|
+
},
|
|
1836
|
+
"prolog": {
|
|
1837
|
+
pattern: /<\?[\s\S]+?\?>/,
|
|
1838
|
+
greedy: true
|
|
1839
|
+
},
|
|
1840
|
+
"doctype": {
|
|
1841
|
+
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
1842
|
+
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
1843
|
+
greedy: true,
|
|
1844
|
+
inside: {
|
|
1845
|
+
"internal-subset": {
|
|
1846
|
+
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
1847
|
+
lookbehind: true,
|
|
1848
|
+
greedy: true,
|
|
1849
|
+
inside: null
|
|
1850
|
+
// see below
|
|
1851
|
+
},
|
|
1852
|
+
"string": {
|
|
1853
|
+
pattern: /"[^"]*"|'[^']*'/,
|
|
1854
|
+
greedy: true
|
|
1855
|
+
},
|
|
1856
|
+
"punctuation": /^<!|>$|[[\]]/,
|
|
1857
|
+
"doctype-tag": /^DOCTYPE/i,
|
|
1858
|
+
"name": /[^\s<>'"]+/
|
|
1859
|
+
}
|
|
1860
|
+
},
|
|
1861
|
+
"cdata": {
|
|
1862
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1863
|
+
greedy: true
|
|
1864
|
+
},
|
|
1865
|
+
"tag": {
|
|
1866
|
+
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
1867
|
+
greedy: true,
|
|
1868
|
+
inside: {
|
|
1869
|
+
"tag": {
|
|
1870
|
+
pattern: /^<\/?[^\s>\/]+/,
|
|
1871
|
+
inside: {
|
|
1872
|
+
"punctuation": /^<\/?/,
|
|
1873
|
+
"namespace": /^[^\s>\/:]+:/
|
|
1874
|
+
}
|
|
1875
|
+
},
|
|
1876
|
+
"special-attr": [],
|
|
1877
|
+
"attr-value": {
|
|
1878
|
+
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
1879
|
+
inside: {
|
|
1880
|
+
"punctuation": [
|
|
1881
|
+
{
|
|
1882
|
+
pattern: /^=/,
|
|
1883
|
+
alias: "attr-equals"
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
pattern: /^(\s*)["']|["']$/,
|
|
1887
|
+
lookbehind: true
|
|
1888
|
+
}
|
|
1889
|
+
]
|
|
1890
|
+
}
|
|
1891
|
+
},
|
|
1892
|
+
"punctuation": /\/?>/,
|
|
1893
|
+
"attr-name": {
|
|
1894
|
+
pattern: /[^\s>\/]+/,
|
|
1895
|
+
inside: {
|
|
1896
|
+
"namespace": /^[^\s>\/:]+:/
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
},
|
|
1901
|
+
"entity": [
|
|
1902
|
+
{
|
|
1903
|
+
pattern: /&[\da-z]{1,8};/i,
|
|
1904
|
+
alias: "named-entity"
|
|
1905
|
+
},
|
|
1906
|
+
/&#x?[\da-f]{1,8};/i
|
|
1907
|
+
]
|
|
1908
|
+
};
|
|
1909
|
+
Prism2.languages.markup["tag"].inside["attr-value"].inside["entity"] = Prism2.languages.markup["entity"];
|
|
1910
|
+
Prism2.languages.markup["doctype"].inside["internal-subset"].inside = Prism2.languages.markup;
|
|
1911
|
+
Prism2.hooks.add("wrap", function(env) {
|
|
1912
|
+
if (env.type === "entity") {
|
|
1913
|
+
env.attributes["title"] = env.content.replace(/&/, "&");
|
|
1914
|
+
}
|
|
1915
|
+
});
|
|
1916
|
+
Object.defineProperty(Prism2.languages.markup.tag, "addInlined", {
|
|
1917
|
+
/**
|
|
1918
|
+
* Adds an inlined language to markup.
|
|
1919
|
+
*
|
|
1920
|
+
* An example of an inlined language is CSS with `<style>` tags.
|
|
1921
|
+
*
|
|
1922
|
+
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
|
1923
|
+
* case insensitive.
|
|
1924
|
+
* @param {string} lang The language key.
|
|
1925
|
+
* @example
|
|
1926
|
+
* addInlined('style', 'css');
|
|
1927
|
+
*/
|
|
1928
|
+
value: function addInlined(tagName, lang) {
|
|
1929
|
+
var includedCdataInside = {};
|
|
1930
|
+
includedCdataInside["language-" + lang] = {
|
|
1931
|
+
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1932
|
+
lookbehind: true,
|
|
1933
|
+
inside: Prism2.languages[lang]
|
|
1934
|
+
};
|
|
1935
|
+
includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
|
|
1936
|
+
var inside = {
|
|
1937
|
+
"included-cdata": {
|
|
1938
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1939
|
+
inside: includedCdataInside
|
|
1940
|
+
}
|
|
1941
|
+
};
|
|
1942
|
+
inside["language-" + lang] = {
|
|
1943
|
+
pattern: /[\s\S]+/,
|
|
1944
|
+
inside: Prism2.languages[lang]
|
|
1945
|
+
};
|
|
1946
|
+
var def = {};
|
|
1947
|
+
def[tagName] = {
|
|
1948
|
+
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1949
|
+
return tagName;
|
|
1950
|
+
}), "i"),
|
|
1951
|
+
lookbehind: true,
|
|
1952
|
+
greedy: true,
|
|
1953
|
+
inside
|
|
1954
|
+
};
|
|
1955
|
+
Prism2.languages.insertBefore("markup", "cdata", def);
|
|
1956
|
+
}
|
|
1957
|
+
});
|
|
1958
|
+
Object.defineProperty(Prism2.languages.markup.tag, "addAttribute", {
|
|
1959
|
+
/**
|
|
1960
|
+
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
1961
|
+
*
|
|
1962
|
+
* An example of an inlined language is CSS with `style` attributes.
|
|
1963
|
+
*
|
|
1964
|
+
* @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
|
|
1965
|
+
* case insensitive.
|
|
1966
|
+
* @param {string} lang The language key.
|
|
1967
|
+
* @example
|
|
1968
|
+
* addAttribute('style', 'css');
|
|
1969
|
+
*/
|
|
1970
|
+
value: function(attrName, lang) {
|
|
1971
|
+
Prism2.languages.markup.tag.inside["special-attr"].push({
|
|
1972
|
+
pattern: RegExp(
|
|
1973
|
+
/(^|["'\s])/.source + "(?:" + attrName + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1974
|
+
"i"
|
|
1975
|
+
),
|
|
1976
|
+
lookbehind: true,
|
|
1977
|
+
inside: {
|
|
1978
|
+
"attr-name": /^[^\s=]+/,
|
|
1979
|
+
"attr-value": {
|
|
1980
|
+
pattern: /=[\s\S]+/,
|
|
1981
|
+
inside: {
|
|
1982
|
+
"value": {
|
|
1983
|
+
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1984
|
+
lookbehind: true,
|
|
1985
|
+
alias: [lang, "language-" + lang],
|
|
1986
|
+
inside: Prism2.languages[lang]
|
|
1987
|
+
},
|
|
1988
|
+
"punctuation": [
|
|
1989
|
+
{
|
|
1990
|
+
pattern: /^=/,
|
|
1991
|
+
alias: "attr-equals"
|
|
1992
|
+
},
|
|
1993
|
+
/"|'/
|
|
1994
|
+
]
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
Prism2.languages.html = Prism2.languages.markup;
|
|
2002
|
+
Prism2.languages.mathml = Prism2.languages.markup;
|
|
2003
|
+
Prism2.languages.svg = Prism2.languages.markup;
|
|
2004
|
+
Prism2.languages.xml = Prism2.languages.extend("markup", {});
|
|
2005
|
+
Prism2.languages.ssml = Prism2.languages.xml;
|
|
2006
|
+
Prism2.languages.atom = Prism2.languages.xml;
|
|
2007
|
+
Prism2.languages.rss = Prism2.languages.xml;
|
|
2008
|
+
(function(Prism3) {
|
|
2009
|
+
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
2010
|
+
Prism3.languages.css = {
|
|
2011
|
+
"comment": /\/\*[\s\S]*?\*\//,
|
|
2012
|
+
"atrule": {
|
|
2013
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + string.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
2014
|
+
inside: {
|
|
2015
|
+
"rule": /^@[\w-]+/,
|
|
2016
|
+
"selector-function-argument": {
|
|
2017
|
+
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
2018
|
+
lookbehind: true,
|
|
2019
|
+
alias: "selector"
|
|
2020
|
+
},
|
|
2021
|
+
"keyword": {
|
|
2022
|
+
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
2023
|
+
lookbehind: true
|
|
2024
|
+
}
|
|
2025
|
+
// See rest below
|
|
2026
|
+
}
|
|
2027
|
+
},
|
|
2028
|
+
"url": {
|
|
2029
|
+
// https://drafts.csswg.org/css-values-3/#urls
|
|
2030
|
+
pattern: RegExp("\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
2031
|
+
greedy: true,
|
|
2032
|
+
inside: {
|
|
2033
|
+
"function": /^url/i,
|
|
2034
|
+
"punctuation": /^\(|\)$/,
|
|
2035
|
+
"string": {
|
|
2036
|
+
pattern: RegExp("^" + string.source + "$"),
|
|
2037
|
+
alias: "url"
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
},
|
|
2041
|
+
"selector": {
|
|
2042
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + string.source + ")*(?=\\s*\\{)"),
|
|
2043
|
+
lookbehind: true
|
|
2044
|
+
},
|
|
2045
|
+
"string": {
|
|
2046
|
+
pattern: string,
|
|
2047
|
+
greedy: true
|
|
2048
|
+
},
|
|
2049
|
+
"property": {
|
|
2050
|
+
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
2051
|
+
lookbehind: true
|
|
2052
|
+
},
|
|
2053
|
+
"important": /!important\b/i,
|
|
2054
|
+
"function": {
|
|
2055
|
+
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
2056
|
+
lookbehind: true
|
|
2057
|
+
},
|
|
2058
|
+
"punctuation": /[(){};:,]/
|
|
2059
|
+
};
|
|
2060
|
+
Prism3.languages.css["atrule"].inside.rest = Prism3.languages.css;
|
|
2061
|
+
var markup = Prism3.languages.markup;
|
|
2062
|
+
if (markup) {
|
|
2063
|
+
markup.tag.addInlined("style", "css");
|
|
2064
|
+
markup.tag.addAttribute("style", "css");
|
|
2065
|
+
}
|
|
2066
|
+
})(Prism2);
|
|
2067
|
+
Prism2.languages.clike = {
|
|
2068
|
+
"comment": [
|
|
2069
|
+
{
|
|
2070
|
+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2071
|
+
lookbehind: true,
|
|
2072
|
+
greedy: true
|
|
2073
|
+
},
|
|
2074
|
+
{
|
|
2075
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
2076
|
+
lookbehind: true,
|
|
2077
|
+
greedy: true
|
|
2078
|
+
}
|
|
2079
|
+
],
|
|
2080
|
+
"string": {
|
|
2081
|
+
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
2082
|
+
greedy: true
|
|
2083
|
+
},
|
|
2084
|
+
"class-name": {
|
|
2085
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
2086
|
+
lookbehind: true,
|
|
2087
|
+
inside: {
|
|
2088
|
+
"punctuation": /[.\\]/
|
|
2089
|
+
}
|
|
2090
|
+
},
|
|
2091
|
+
"keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
2092
|
+
"boolean": /\b(?:false|true)\b/,
|
|
2093
|
+
"function": /\b\w+(?=\()/,
|
|
2094
|
+
"number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
2095
|
+
"operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
2096
|
+
"punctuation": /[{}[\];(),.:]/
|
|
2097
|
+
};
|
|
2098
|
+
Prism2.languages.javascript = Prism2.languages.extend("clike", {
|
|
2099
|
+
"class-name": [
|
|
2100
|
+
Prism2.languages.clike["class-name"],
|
|
2101
|
+
{
|
|
2102
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
2103
|
+
lookbehind: true
|
|
2104
|
+
}
|
|
2105
|
+
],
|
|
2106
|
+
"keyword": [
|
|
2107
|
+
{
|
|
2108
|
+
pattern: /((?:^|\})\s*)catch\b/,
|
|
2109
|
+
lookbehind: true
|
|
2110
|
+
},
|
|
2111
|
+
{
|
|
2112
|
+
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/,
|
|
2113
|
+
lookbehind: true
|
|
2114
|
+
}
|
|
2115
|
+
],
|
|
2116
|
+
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
2117
|
+
"function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
2118
|
+
"number": {
|
|
2119
|
+
pattern: RegExp(
|
|
2120
|
+
/(^|[^\w$])/.source + "(?:" + // constant
|
|
2121
|
+
(/NaN|Infinity/.source + "|" + // binary integer
|
|
2122
|
+
/0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
|
|
2123
|
+
/0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
|
|
2124
|
+
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
|
|
2125
|
+
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
2126
|
+
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
2127
|
+
),
|
|
2128
|
+
lookbehind: true
|
|
2129
|
+
},
|
|
2130
|
+
"operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
2131
|
+
});
|
|
2132
|
+
Prism2.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
2133
|
+
Prism2.languages.insertBefore("javascript", "keyword", {
|
|
2134
|
+
"regex": {
|
|
2135
|
+
pattern: RegExp(
|
|
2136
|
+
// lookbehind
|
|
2137
|
+
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
2138
|
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
|
|
2139
|
+
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
|
2140
|
+
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
|
2141
|
+
// with the only syntax, so we have to define 2 different regex patterns.
|
|
2142
|
+
/\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
|
|
2143
|
+
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
2144
|
+
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
2145
|
+
),
|
|
2146
|
+
lookbehind: true,
|
|
2147
|
+
greedy: true,
|
|
2148
|
+
inside: {
|
|
2149
|
+
"regex-source": {
|
|
2150
|
+
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
2151
|
+
lookbehind: true,
|
|
2152
|
+
alias: "language-regex",
|
|
2153
|
+
inside: Prism2.languages.regex
|
|
2154
|
+
},
|
|
2155
|
+
"regex-delimiter": /^\/|\/$/,
|
|
2156
|
+
"regex-flags": /^[a-z]+$/
|
|
2157
|
+
}
|
|
2158
|
+
},
|
|
2159
|
+
// This must be declared before keyword because we use "function" inside the look-forward
|
|
2160
|
+
"function-variable": {
|
|
2161
|
+
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*=>))/,
|
|
2162
|
+
alias: "function"
|
|
2163
|
+
},
|
|
2164
|
+
"parameter": [
|
|
2165
|
+
{
|
|
2166
|
+
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
2167
|
+
lookbehind: true,
|
|
2168
|
+
inside: Prism2.languages.javascript
|
|
2169
|
+
},
|
|
2170
|
+
{
|
|
2171
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
2172
|
+
lookbehind: true,
|
|
2173
|
+
inside: Prism2.languages.javascript
|
|
2174
|
+
},
|
|
2175
|
+
{
|
|
2176
|
+
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
2177
|
+
lookbehind: true,
|
|
2178
|
+
inside: Prism2.languages.javascript
|
|
2179
|
+
},
|
|
2180
|
+
{
|
|
2181
|
+
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*\{)/,
|
|
2182
|
+
lookbehind: true,
|
|
2183
|
+
inside: Prism2.languages.javascript
|
|
2184
|
+
}
|
|
2185
|
+
],
|
|
2186
|
+
"constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
2187
|
+
});
|
|
2188
|
+
Prism2.languages.insertBefore("javascript", "string", {
|
|
2189
|
+
"hashbang": {
|
|
2190
|
+
pattern: /^#!.*/,
|
|
2191
|
+
greedy: true,
|
|
2192
|
+
alias: "comment"
|
|
2193
|
+
},
|
|
2194
|
+
"template-string": {
|
|
2195
|
+
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
2196
|
+
greedy: true,
|
|
2197
|
+
inside: {
|
|
2198
|
+
"template-punctuation": {
|
|
2199
|
+
pattern: /^`|`$/,
|
|
2200
|
+
alias: "string"
|
|
2201
|
+
},
|
|
2202
|
+
"interpolation": {
|
|
2203
|
+
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
2204
|
+
lookbehind: true,
|
|
2205
|
+
inside: {
|
|
2206
|
+
"interpolation-punctuation": {
|
|
2207
|
+
pattern: /^\$\{|\}$/,
|
|
2208
|
+
alias: "punctuation"
|
|
2209
|
+
},
|
|
2210
|
+
rest: Prism2.languages.javascript
|
|
2211
|
+
}
|
|
2212
|
+
},
|
|
2213
|
+
"string": /[\s\S]+/
|
|
2214
|
+
}
|
|
2215
|
+
},
|
|
2216
|
+
"string-property": {
|
|
2217
|
+
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
2218
|
+
lookbehind: true,
|
|
2219
|
+
greedy: true,
|
|
2220
|
+
alias: "property"
|
|
2221
|
+
}
|
|
2222
|
+
});
|
|
2223
|
+
Prism2.languages.insertBefore("javascript", "operator", {
|
|
2224
|
+
"literal-property": {
|
|
2225
|
+
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
2226
|
+
lookbehind: true,
|
|
2227
|
+
alias: "property"
|
|
2228
|
+
}
|
|
2229
|
+
});
|
|
2230
|
+
if (Prism2.languages.markup) {
|
|
2231
|
+
Prism2.languages.markup.tag.addInlined("script", "javascript");
|
|
2232
|
+
Prism2.languages.markup.tag.addAttribute(
|
|
2233
|
+
/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,
|
|
2234
|
+
"javascript"
|
|
2235
|
+
);
|
|
2236
|
+
}
|
|
2237
|
+
Prism2.languages.js = Prism2.languages.javascript;
|
|
2238
|
+
(function() {
|
|
2239
|
+
if (typeof Prism2 === "undefined" || typeof document === "undefined") {
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
2242
|
+
if (!Element.prototype.matches) {
|
|
2243
|
+
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
2244
|
+
}
|
|
2245
|
+
var LOADING_MESSAGE = "Loading…";
|
|
2246
|
+
var FAILURE_MESSAGE = function(status, message) {
|
|
2247
|
+
return "✖ Error " + status + " while fetching file: " + message;
|
|
2248
|
+
};
|
|
2249
|
+
var FAILURE_EMPTY_MESSAGE = "✖ Error: File does not exist or is empty";
|
|
2250
|
+
var EXTENSIONS = {
|
|
2251
|
+
"js": "javascript",
|
|
2252
|
+
"py": "python",
|
|
2253
|
+
"rb": "ruby",
|
|
2254
|
+
"ps1": "powershell",
|
|
2255
|
+
"psm1": "powershell",
|
|
2256
|
+
"sh": "bash",
|
|
2257
|
+
"bat": "batch",
|
|
2258
|
+
"h": "c",
|
|
2259
|
+
"tex": "latex"
|
|
2260
|
+
};
|
|
2261
|
+
var STATUS_ATTR = "data-src-status";
|
|
2262
|
+
var STATUS_LOADING = "loading";
|
|
2263
|
+
var STATUS_LOADED = "loaded";
|
|
2264
|
+
var STATUS_FAILED = "failed";
|
|
2265
|
+
var SELECTOR = "pre[data-src]:not([" + STATUS_ATTR + '="' + STATUS_LOADED + '"]):not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
|
|
2266
|
+
function loadFile(src, success, error) {
|
|
2267
|
+
var xhr = new XMLHttpRequest();
|
|
2268
|
+
xhr.open("GET", src, true);
|
|
2269
|
+
xhr.onreadystatechange = function() {
|
|
2270
|
+
if (xhr.readyState == 4) {
|
|
2271
|
+
if (xhr.status < 400 && xhr.responseText) {
|
|
2272
|
+
success(xhr.responseText);
|
|
2273
|
+
} else {
|
|
2274
|
+
if (xhr.status >= 400) {
|
|
2275
|
+
error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
|
|
2276
|
+
} else {
|
|
2277
|
+
error(FAILURE_EMPTY_MESSAGE);
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
};
|
|
2282
|
+
xhr.send(null);
|
|
2283
|
+
}
|
|
2284
|
+
function parseRange(range) {
|
|
2285
|
+
var m2 = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || "");
|
|
2286
|
+
if (m2) {
|
|
2287
|
+
var start = Number(m2[1]);
|
|
2288
|
+
var comma = m2[2];
|
|
2289
|
+
var end = m2[3];
|
|
2290
|
+
if (!comma) {
|
|
2291
|
+
return [start, start];
|
|
2292
|
+
}
|
|
2293
|
+
if (!end) {
|
|
2294
|
+
return [start, void 0];
|
|
2295
|
+
}
|
|
2296
|
+
return [start, Number(end)];
|
|
2297
|
+
}
|
|
2298
|
+
return void 0;
|
|
2299
|
+
}
|
|
2300
|
+
Prism2.hooks.add("before-highlightall", function(env) {
|
|
2301
|
+
env.selector += ", " + SELECTOR;
|
|
2302
|
+
});
|
|
2303
|
+
Prism2.hooks.add("before-sanity-check", function(env) {
|
|
2304
|
+
var pre = (
|
|
2305
|
+
/** @type {HTMLPreElement} */
|
|
2306
|
+
env.element
|
|
2307
|
+
);
|
|
2308
|
+
if (pre.matches(SELECTOR)) {
|
|
2309
|
+
env.code = "";
|
|
2310
|
+
pre.setAttribute(STATUS_ATTR, STATUS_LOADING);
|
|
2311
|
+
var code = pre.appendChild(document.createElement("CODE"));
|
|
2312
|
+
code.textContent = LOADING_MESSAGE;
|
|
2313
|
+
var src = pre.getAttribute("data-src");
|
|
2314
|
+
var language = env.language;
|
|
2315
|
+
if (language === "none") {
|
|
2316
|
+
var extension = (/\.(\w+)$/.exec(src) || [, "none"])[1];
|
|
2317
|
+
language = EXTENSIONS[extension] || extension;
|
|
2318
|
+
}
|
|
2319
|
+
Prism2.util.setLanguage(code, language);
|
|
2320
|
+
Prism2.util.setLanguage(pre, language);
|
|
2321
|
+
var autoloader = Prism2.plugins.autoloader;
|
|
2322
|
+
if (autoloader) {
|
|
2323
|
+
autoloader.loadLanguages(language);
|
|
2324
|
+
}
|
|
2325
|
+
loadFile(
|
|
2326
|
+
src,
|
|
2327
|
+
function(text) {
|
|
2328
|
+
pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
|
|
2329
|
+
var range = parseRange(pre.getAttribute("data-range"));
|
|
2330
|
+
if (range) {
|
|
2331
|
+
var lines = text.split(/\r\n?|\n/g);
|
|
2332
|
+
var start = range[0];
|
|
2333
|
+
var end = range[1] == null ? lines.length : range[1];
|
|
2334
|
+
if (start < 0) {
|
|
2335
|
+
start += lines.length;
|
|
2336
|
+
}
|
|
2337
|
+
start = Math.max(0, Math.min(start - 1, lines.length));
|
|
2338
|
+
if (end < 0) {
|
|
2339
|
+
end += lines.length;
|
|
2340
|
+
}
|
|
2341
|
+
end = Math.max(0, Math.min(end, lines.length));
|
|
2342
|
+
text = lines.slice(start, end).join("\n");
|
|
2343
|
+
if (!pre.hasAttribute("data-start")) {
|
|
2344
|
+
pre.setAttribute("data-start", String(start + 1));
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
code.textContent = text;
|
|
2348
|
+
Prism2.highlightElement(code);
|
|
2349
|
+
},
|
|
2350
|
+
function(error) {
|
|
2351
|
+
pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
|
|
2352
|
+
code.textContent = error;
|
|
2353
|
+
}
|
|
2354
|
+
);
|
|
2355
|
+
}
|
|
2356
|
+
});
|
|
2357
|
+
Prism2.plugins.fileHighlight = {
|
|
2358
|
+
/**
|
|
2359
|
+
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
2360
|
+
*
|
|
2361
|
+
* Note: Elements which are already loaded or currently loading will not be touched by this method.
|
|
2362
|
+
*
|
|
2363
|
+
* @param {ParentNode} [container=document]
|
|
2364
|
+
*/
|
|
2365
|
+
highlight: function highlight(container) {
|
|
2366
|
+
var elements = (container || document).querySelectorAll(SELECTOR);
|
|
2367
|
+
for (var i = 0, element; element = elements[i++]; ) {
|
|
2368
|
+
Prism2.highlightElement(element);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
var logged = false;
|
|
2373
|
+
Prism2.fileHighlight = function() {
|
|
2374
|
+
if (!logged) {
|
|
2375
|
+
console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.");
|
|
2376
|
+
logged = true;
|
|
2377
|
+
}
|
|
2378
|
+
Prism2.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
2379
|
+
};
|
|
2380
|
+
})();
|
|
2381
|
+
})(prism);
|
|
2382
|
+
var prismExports = prism.exports;
|
|
2383
|
+
const Prism$1 = /* @__PURE__ */ getDefaultExportFromCjs(prismExports);
|
|
5
2384
|
Prism.languages.clike = {
|
|
6
|
-
comment: [
|
|
2385
|
+
"comment": [
|
|
7
2386
|
{
|
|
8
2387
|
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
9
|
-
lookbehind:
|
|
10
|
-
greedy:
|
|
2388
|
+
lookbehind: true,
|
|
2389
|
+
greedy: true
|
|
11
2390
|
},
|
|
12
2391
|
{
|
|
13
2392
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
14
|
-
lookbehind:
|
|
15
|
-
greedy:
|
|
2393
|
+
lookbehind: true,
|
|
2394
|
+
greedy: true
|
|
16
2395
|
}
|
|
17
2396
|
],
|
|
18
|
-
string: {
|
|
2397
|
+
"string": {
|
|
19
2398
|
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
20
|
-
greedy:
|
|
2399
|
+
greedy: true
|
|
21
2400
|
},
|
|
22
2401
|
"class-name": {
|
|
23
2402
|
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
24
|
-
lookbehind:
|
|
2403
|
+
lookbehind: true,
|
|
25
2404
|
inside: {
|
|
26
|
-
punctuation: /[.\\]/
|
|
2405
|
+
"punctuation": /[.\\]/
|
|
27
2406
|
}
|
|
28
2407
|
},
|
|
29
|
-
keyword: /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
30
|
-
boolean: /\b(?:false|true)\b/,
|
|
31
|
-
function: /\b\w+(?=\()/,
|
|
32
|
-
number: /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
33
|
-
operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
34
|
-
punctuation: /[{}[\];(),.:]/
|
|
2408
|
+
"keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
2409
|
+
"boolean": /\b(?:false|true)\b/,
|
|
2410
|
+
"function": /\b\w+(?=\()/,
|
|
2411
|
+
"number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
2412
|
+
"operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
2413
|
+
"punctuation": /[{}[\];(),.:]/
|
|
35
2414
|
};
|
|
36
2415
|
Prism.languages.javascript = Prism.languages.extend("clike", {
|
|
37
2416
|
"class-name": [
|
|
38
2417
|
Prism.languages.clike["class-name"],
|
|
39
2418
|
{
|
|
40
2419
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
41
|
-
lookbehind:
|
|
2420
|
+
lookbehind: true
|
|
42
2421
|
}
|
|
43
2422
|
],
|
|
44
|
-
keyword: [
|
|
2423
|
+
"keyword": [
|
|
45
2424
|
{
|
|
46
2425
|
pattern: /((?:^|\})\s*)catch\b/,
|
|
47
|
-
lookbehind:
|
|
2426
|
+
lookbehind: true
|
|
48
2427
|
},
|
|
49
2428
|
{
|
|
50
2429
|
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/,
|
|
51
|
-
lookbehind:
|
|
2430
|
+
lookbehind: true
|
|
52
2431
|
}
|
|
53
2432
|
],
|
|
54
2433
|
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
55
|
-
function: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
56
|
-
number: {
|
|
2434
|
+
"function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
2435
|
+
"number": {
|
|
57
2436
|
pattern: RegExp(
|
|
58
2437
|
/(^|[^\w$])/.source + "(?:" + // constant
|
|
59
2438
|
(/NaN|Infinity/.source + "|" + // binary integer
|
|
@@ -63,13 +2442,13 @@ Prism.languages.javascript = Prism.languages.extend("clike", {
|
|
|
63
2442
|
/\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
|
|
64
2443
|
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
|
|
65
2444
|
),
|
|
66
|
-
lookbehind:
|
|
2445
|
+
lookbehind: true
|
|
67
2446
|
},
|
|
68
|
-
operator: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
2447
|
+
"operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
69
2448
|
});
|
|
70
2449
|
Prism.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
71
2450
|
Prism.languages.insertBefore("javascript", "keyword", {
|
|
72
|
-
regex: {
|
|
2451
|
+
"regex": {
|
|
73
2452
|
pattern: RegExp(
|
|
74
2453
|
// lookbehind
|
|
75
2454
|
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
@@ -81,12 +2460,12 @@ Prism.languages.insertBefore("javascript", "keyword", {
|
|
|
81
2460
|
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
|
|
82
2461
|
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
83
2462
|
),
|
|
84
|
-
lookbehind:
|
|
85
|
-
greedy:
|
|
2463
|
+
lookbehind: true,
|
|
2464
|
+
greedy: true,
|
|
86
2465
|
inside: {
|
|
87
2466
|
"regex-source": {
|
|
88
2467
|
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
89
|
-
lookbehind:
|
|
2468
|
+
lookbehind: true,
|
|
90
2469
|
alias: "language-regex",
|
|
91
2470
|
inside: Prism.languages.regex
|
|
92
2471
|
},
|
|
@@ -99,47 +2478,47 @@ Prism.languages.insertBefore("javascript", "keyword", {
|
|
|
99
2478
|
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*=>))/,
|
|
100
2479
|
alias: "function"
|
|
101
2480
|
},
|
|
102
|
-
parameter: [
|
|
2481
|
+
"parameter": [
|
|
103
2482
|
{
|
|
104
2483
|
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
105
|
-
lookbehind:
|
|
2484
|
+
lookbehind: true,
|
|
106
2485
|
inside: Prism.languages.javascript
|
|
107
2486
|
},
|
|
108
2487
|
{
|
|
109
2488
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
110
|
-
lookbehind:
|
|
2489
|
+
lookbehind: true,
|
|
111
2490
|
inside: Prism.languages.javascript
|
|
112
2491
|
},
|
|
113
2492
|
{
|
|
114
2493
|
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
115
|
-
lookbehind:
|
|
2494
|
+
lookbehind: true,
|
|
116
2495
|
inside: Prism.languages.javascript
|
|
117
2496
|
},
|
|
118
2497
|
{
|
|
119
2498
|
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*\{)/,
|
|
120
|
-
lookbehind:
|
|
2499
|
+
lookbehind: true,
|
|
121
2500
|
inside: Prism.languages.javascript
|
|
122
2501
|
}
|
|
123
2502
|
],
|
|
124
|
-
constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
2503
|
+
"constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
125
2504
|
});
|
|
126
2505
|
Prism.languages.insertBefore("javascript", "string", {
|
|
127
|
-
hashbang: {
|
|
2506
|
+
"hashbang": {
|
|
128
2507
|
pattern: /^#!.*/,
|
|
129
|
-
greedy:
|
|
2508
|
+
greedy: true,
|
|
130
2509
|
alias: "comment"
|
|
131
2510
|
},
|
|
132
2511
|
"template-string": {
|
|
133
2512
|
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
134
|
-
greedy:
|
|
2513
|
+
greedy: true,
|
|
135
2514
|
inside: {
|
|
136
2515
|
"template-punctuation": {
|
|
137
2516
|
pattern: /^`|`$/,
|
|
138
2517
|
alias: "string"
|
|
139
2518
|
},
|
|
140
|
-
interpolation: {
|
|
2519
|
+
"interpolation": {
|
|
141
2520
|
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
142
|
-
lookbehind:
|
|
2521
|
+
lookbehind: true,
|
|
143
2522
|
inside: {
|
|
144
2523
|
"interpolation-punctuation": {
|
|
145
2524
|
pattern: /^\$\{|\}$/,
|
|
@@ -148,46 +2527,49 @@ Prism.languages.insertBefore("javascript", "string", {
|
|
|
148
2527
|
rest: Prism.languages.javascript
|
|
149
2528
|
}
|
|
150
2529
|
},
|
|
151
|
-
string: /[\s\S]+/
|
|
2530
|
+
"string": /[\s\S]+/
|
|
152
2531
|
}
|
|
153
2532
|
},
|
|
154
2533
|
"string-property": {
|
|
155
2534
|
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
156
|
-
lookbehind:
|
|
157
|
-
greedy:
|
|
2535
|
+
lookbehind: true,
|
|
2536
|
+
greedy: true,
|
|
158
2537
|
alias: "property"
|
|
159
2538
|
}
|
|
160
2539
|
});
|
|
161
2540
|
Prism.languages.insertBefore("javascript", "operator", {
|
|
162
2541
|
"literal-property": {
|
|
163
2542
|
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
164
|
-
lookbehind:
|
|
2543
|
+
lookbehind: true,
|
|
165
2544
|
alias: "property"
|
|
166
2545
|
}
|
|
167
2546
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
))
|
|
2547
|
+
if (Prism.languages.markup) {
|
|
2548
|
+
Prism.languages.markup.tag.addInlined("script", "javascript");
|
|
2549
|
+
Prism.languages.markup.tag.addAttribute(
|
|
2550
|
+
/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,
|
|
2551
|
+
"javascript"
|
|
2552
|
+
);
|
|
2553
|
+
}
|
|
172
2554
|
Prism.languages.js = Prism.languages.javascript;
|
|
173
2555
|
Prism.languages.python = {
|
|
174
|
-
comment: {
|
|
2556
|
+
"comment": {
|
|
175
2557
|
pattern: /(^|[^\\])#.*/,
|
|
176
|
-
lookbehind:
|
|
177
|
-
greedy:
|
|
2558
|
+
lookbehind: true,
|
|
2559
|
+
greedy: true
|
|
178
2560
|
},
|
|
179
2561
|
"string-interpolation": {
|
|
180
2562
|
pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
|
181
|
-
greedy:
|
|
2563
|
+
greedy: true,
|
|
182
2564
|
inside: {
|
|
183
|
-
interpolation: {
|
|
2565
|
+
"interpolation": {
|
|
184
2566
|
// "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
|
185
2567
|
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
186
|
-
lookbehind:
|
|
2568
|
+
lookbehind: true,
|
|
187
2569
|
inside: {
|
|
188
2570
|
"format-spec": {
|
|
189
2571
|
pattern: /(:)[^:(){}]+(?=\}$)/,
|
|
190
|
-
lookbehind:
|
|
2572
|
+
lookbehind: true
|
|
191
2573
|
},
|
|
192
2574
|
"conversion-option": {
|
|
193
2575
|
pattern: //,
|
|
@@ -196,52 +2578,52 @@ Prism.languages.python = {
|
|
|
196
2578
|
rest: null
|
|
197
2579
|
}
|
|
198
2580
|
},
|
|
199
|
-
string: /[\s\S]+/
|
|
2581
|
+
"string": /[\s\S]+/
|
|
200
2582
|
}
|
|
201
2583
|
},
|
|
202
2584
|
"triple-quoted-string": {
|
|
203
2585
|
pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
|
204
|
-
greedy:
|
|
2586
|
+
greedy: true,
|
|
205
2587
|
alias: "string"
|
|
206
2588
|
},
|
|
207
|
-
string: {
|
|
2589
|
+
"string": {
|
|
208
2590
|
pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
|
209
|
-
greedy:
|
|
2591
|
+
greedy: true
|
|
210
2592
|
},
|
|
211
|
-
function: {
|
|
2593
|
+
"function": {
|
|
212
2594
|
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
|
213
|
-
lookbehind:
|
|
2595
|
+
lookbehind: true
|
|
214
2596
|
},
|
|
215
2597
|
"class-name": {
|
|
216
2598
|
pattern: /(\bclass\s+)\w+/i,
|
|
217
|
-
lookbehind:
|
|
2599
|
+
lookbehind: true
|
|
218
2600
|
},
|
|
219
|
-
decorator: {
|
|
2601
|
+
"decorator": {
|
|
220
2602
|
pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
|
221
|
-
lookbehind:
|
|
2603
|
+
lookbehind: true,
|
|
222
2604
|
alias: ["annotation", "punctuation"],
|
|
223
2605
|
inside: {
|
|
224
|
-
punctuation: /\./
|
|
2606
|
+
"punctuation": /\./
|
|
225
2607
|
}
|
|
226
2608
|
},
|
|
227
|
-
keyword: /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
|
228
|
-
builtin: /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
|
229
|
-
boolean: /\b(?:False|None|True)\b/,
|
|
230
|
-
number: /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
231
|
-
operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
232
|
-
punctuation: /[{}[\];(),.:]/
|
|
2609
|
+
"keyword": /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
|
2610
|
+
"builtin": /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
|
2611
|
+
"boolean": /\b(?:False|None|True)\b/,
|
|
2612
|
+
"number": /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
2613
|
+
"operator": /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
2614
|
+
"punctuation": /[{}[\];(),.:]/
|
|
233
2615
|
};
|
|
234
|
-
Prism.languages.python["string-interpolation"].inside
|
|
2616
|
+
Prism.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism.languages.python;
|
|
235
2617
|
Prism.languages.py = Prism.languages.python;
|
|
236
2618
|
Prism.languages.go = Prism.languages.extend("clike", {
|
|
237
|
-
string: {
|
|
2619
|
+
"string": {
|
|
238
2620
|
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
|
|
239
|
-
lookbehind:
|
|
240
|
-
greedy:
|
|
2621
|
+
lookbehind: true,
|
|
2622
|
+
greedy: true
|
|
241
2623
|
},
|
|
242
|
-
keyword: /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
|
243
|
-
boolean: /\b(?:_|false|iota|nil|true)\b/,
|
|
244
|
-
number: [
|
|
2624
|
+
"keyword": /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
|
2625
|
+
"boolean": /\b(?:_|false|iota|nil|true)\b/,
|
|
2626
|
+
"number": [
|
|
245
2627
|
// binary and octal integers
|
|
246
2628
|
/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
|
|
247
2629
|
// hexadecimal integers and floats
|
|
@@ -249,195 +2631,199 @@ Prism.languages.go = Prism.languages.extend("clike", {
|
|
|
249
2631
|
// decimal integers and floats
|
|
250
2632
|
/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
|
|
251
2633
|
],
|
|
252
|
-
operator: /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
253
|
-
builtin: /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
|
|
2634
|
+
"operator": /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
|
2635
|
+
"builtin": /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
|
|
254
2636
|
});
|
|
255
2637
|
Prism.languages.insertBefore("go", "string", {
|
|
256
|
-
char: {
|
|
2638
|
+
"char": {
|
|
257
2639
|
pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
|
|
258
|
-
greedy:
|
|
2640
|
+
greedy: true
|
|
259
2641
|
}
|
|
260
2642
|
});
|
|
261
2643
|
delete Prism.languages.go["class-name"];
|
|
262
|
-
(function(
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
|
|
2644
|
+
(function(Prism2) {
|
|
2645
|
+
var keywords = /\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/;
|
|
2646
|
+
var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
|
|
2647
|
+
var className = {
|
|
2648
|
+
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
|
|
2649
|
+
lookbehind: true,
|
|
266
2650
|
inside: {
|
|
267
|
-
namespace: {
|
|
2651
|
+
"namespace": {
|
|
268
2652
|
pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
|
|
269
2653
|
inside: {
|
|
270
|
-
punctuation: /\./
|
|
2654
|
+
"punctuation": /\./
|
|
271
2655
|
}
|
|
272
2656
|
},
|
|
273
|
-
punctuation: /\./
|
|
2657
|
+
"punctuation": /\./
|
|
274
2658
|
}
|
|
275
2659
|
};
|
|
276
|
-
|
|
277
|
-
string: {
|
|
2660
|
+
Prism2.languages.java = Prism2.languages.extend("clike", {
|
|
2661
|
+
"string": {
|
|
278
2662
|
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
|
|
279
|
-
lookbehind:
|
|
280
|
-
greedy:
|
|
2663
|
+
lookbehind: true,
|
|
2664
|
+
greedy: true
|
|
281
2665
|
},
|
|
282
2666
|
"class-name": [
|
|
283
|
-
|
|
2667
|
+
className,
|
|
284
2668
|
{
|
|
285
2669
|
// variables, parameters, and constructor references
|
|
286
2670
|
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
287
|
-
pattern: RegExp(/(^|[^\w.])/.source +
|
|
288
|
-
lookbehind:
|
|
289
|
-
inside:
|
|
2671
|
+
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
|
|
2672
|
+
lookbehind: true,
|
|
2673
|
+
inside: className.inside
|
|
290
2674
|
},
|
|
291
2675
|
{
|
|
292
2676
|
// class names based on keyword
|
|
293
2677
|
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
294
|
-
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source +
|
|
295
|
-
lookbehind:
|
|
296
|
-
inside:
|
|
2678
|
+
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
|
|
2679
|
+
lookbehind: true,
|
|
2680
|
+
inside: className.inside
|
|
297
2681
|
}
|
|
298
2682
|
],
|
|
299
|
-
keyword:
|
|
300
|
-
function: [
|
|
301
|
-
|
|
2683
|
+
"keyword": keywords,
|
|
2684
|
+
"function": [
|
|
2685
|
+
Prism2.languages.clike.function,
|
|
302
2686
|
{
|
|
303
2687
|
pattern: /(::\s*)[a-z_]\w*/,
|
|
304
|
-
lookbehind:
|
|
2688
|
+
lookbehind: true
|
|
305
2689
|
}
|
|
306
2690
|
],
|
|
307
|
-
number: /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
|
|
308
|
-
operator: {
|
|
2691
|
+
"number": /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
|
|
2692
|
+
"operator": {
|
|
309
2693
|
pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
|
310
|
-
lookbehind:
|
|
2694
|
+
lookbehind: true
|
|
311
2695
|
},
|
|
312
|
-
constant: /\b[A-Z][A-Z_\d]+\b/
|
|
313
|
-
})
|
|
2696
|
+
"constant": /\b[A-Z][A-Z_\d]+\b/
|
|
2697
|
+
});
|
|
2698
|
+
Prism2.languages.insertBefore("java", "string", {
|
|
314
2699
|
"triple-quoted-string": {
|
|
315
2700
|
// http://openjdk.java.net/jeps/355#Description
|
|
316
2701
|
pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
|
317
|
-
greedy:
|
|
2702
|
+
greedy: true,
|
|
318
2703
|
alias: "string"
|
|
319
2704
|
},
|
|
320
|
-
char: {
|
|
2705
|
+
"char": {
|
|
321
2706
|
pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
|
|
322
|
-
greedy:
|
|
2707
|
+
greedy: true
|
|
323
2708
|
}
|
|
324
|
-
})
|
|
325
|
-
|
|
2709
|
+
});
|
|
2710
|
+
Prism2.languages.insertBefore("java", "class-name", {
|
|
2711
|
+
"annotation": {
|
|
326
2712
|
pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
|
|
327
|
-
lookbehind:
|
|
2713
|
+
lookbehind: true,
|
|
328
2714
|
alias: "punctuation"
|
|
329
2715
|
},
|
|
330
|
-
generics: {
|
|
2716
|
+
"generics": {
|
|
331
2717
|
pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
|
|
332
2718
|
inside: {
|
|
333
|
-
"class-name":
|
|
334
|
-
keyword:
|
|
335
|
-
punctuation: /[<>(),.:]/,
|
|
336
|
-
operator: /[?&|]/
|
|
2719
|
+
"class-name": className,
|
|
2720
|
+
"keyword": keywords,
|
|
2721
|
+
"punctuation": /[<>(),.:]/,
|
|
2722
|
+
"operator": /[?&|]/
|
|
337
2723
|
}
|
|
338
2724
|
},
|
|
339
|
-
import: [
|
|
2725
|
+
"import": [
|
|
340
2726
|
{
|
|
341
|
-
pattern: RegExp(/(\bimport\s+)/.source +
|
|
342
|
-
lookbehind:
|
|
2727
|
+
pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
|
|
2728
|
+
lookbehind: true,
|
|
343
2729
|
inside: {
|
|
344
|
-
namespace:
|
|
345
|
-
punctuation: /\./,
|
|
346
|
-
operator: /\*/,
|
|
2730
|
+
"namespace": className.inside.namespace,
|
|
2731
|
+
"punctuation": /\./,
|
|
2732
|
+
"operator": /\*/,
|
|
347
2733
|
"class-name": /\w+/
|
|
348
2734
|
}
|
|
349
2735
|
},
|
|
350
2736
|
{
|
|
351
|
-
pattern: RegExp(/(\bimport\s+static\s+)/.source +
|
|
352
|
-
lookbehind:
|
|
2737
|
+
pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
|
|
2738
|
+
lookbehind: true,
|
|
353
2739
|
alias: "static",
|
|
354
2740
|
inside: {
|
|
355
|
-
namespace:
|
|
356
|
-
static: /\b\w+$/,
|
|
357
|
-
punctuation: /\./,
|
|
358
|
-
operator: /\*/,
|
|
2741
|
+
"namespace": className.inside.namespace,
|
|
2742
|
+
"static": /\b\w+$/,
|
|
2743
|
+
"punctuation": /\./,
|
|
2744
|
+
"operator": /\*/,
|
|
359
2745
|
"class-name": /\w+/
|
|
360
2746
|
}
|
|
361
2747
|
}
|
|
362
2748
|
],
|
|
363
|
-
namespace: {
|
|
2749
|
+
"namespace": {
|
|
364
2750
|
pattern: RegExp(
|
|
365
2751
|
/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g, function() {
|
|
366
|
-
return
|
|
2752
|
+
return keywords.source;
|
|
367
2753
|
})
|
|
368
2754
|
),
|
|
369
|
-
lookbehind:
|
|
2755
|
+
lookbehind: true,
|
|
370
2756
|
inside: {
|
|
371
|
-
punctuation: /\./
|
|
2757
|
+
"punctuation": /\./
|
|
372
2758
|
}
|
|
373
2759
|
}
|
|
374
2760
|
});
|
|
375
2761
|
})(Prism);
|
|
376
2762
|
Prism.languages.c = Prism.languages.extend("clike", {
|
|
377
|
-
comment: {
|
|
2763
|
+
"comment": {
|
|
378
2764
|
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
379
|
-
greedy:
|
|
2765
|
+
greedy: true
|
|
380
2766
|
},
|
|
381
|
-
string: {
|
|
2767
|
+
"string": {
|
|
382
2768
|
// https://en.cppreference.com/w/c/language/string_literal
|
|
383
2769
|
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
384
|
-
greedy:
|
|
2770
|
+
greedy: true
|
|
385
2771
|
},
|
|
386
2772
|
"class-name": {
|
|
387
2773
|
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
|
388
|
-
lookbehind:
|
|
2774
|
+
lookbehind: true
|
|
389
2775
|
},
|
|
390
|
-
keyword: /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
|
|
391
|
-
function: /\b[a-z_]\w*(?=\s*\()/i,
|
|
392
|
-
number: /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
393
|
-
operator: />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
2776
|
+
"keyword": /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
|
|
2777
|
+
"function": /\b[a-z_]\w*(?=\s*\()/i,
|
|
2778
|
+
"number": /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
2779
|
+
"operator": />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
394
2780
|
});
|
|
395
2781
|
Prism.languages.insertBefore("c", "string", {
|
|
396
|
-
char: {
|
|
2782
|
+
"char": {
|
|
397
2783
|
// https://en.cppreference.com/w/c/language/character_constant
|
|
398
2784
|
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
399
|
-
greedy:
|
|
2785
|
+
greedy: true
|
|
400
2786
|
}
|
|
401
2787
|
});
|
|
402
2788
|
Prism.languages.insertBefore("c", "string", {
|
|
403
|
-
macro: {
|
|
2789
|
+
"macro": {
|
|
404
2790
|
// allow for multiline macro definitions
|
|
405
2791
|
// spaces after the # character compile fine with gcc
|
|
406
2792
|
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
407
|
-
lookbehind:
|
|
408
|
-
greedy:
|
|
2793
|
+
lookbehind: true,
|
|
2794
|
+
greedy: true,
|
|
409
2795
|
alias: "property",
|
|
410
2796
|
inside: {
|
|
411
|
-
string: [
|
|
2797
|
+
"string": [
|
|
412
2798
|
{
|
|
413
2799
|
// highlight the path of the include statement as a string
|
|
414
2800
|
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
415
|
-
lookbehind:
|
|
2801
|
+
lookbehind: true
|
|
416
2802
|
},
|
|
417
|
-
Prism.languages.c
|
|
2803
|
+
Prism.languages.c["string"]
|
|
418
2804
|
],
|
|
419
|
-
char: Prism.languages.c
|
|
420
|
-
comment: Prism.languages.c
|
|
2805
|
+
"char": Prism.languages.c["char"],
|
|
2806
|
+
"comment": Prism.languages.c["comment"],
|
|
421
2807
|
"macro-name": [
|
|
422
2808
|
{
|
|
423
2809
|
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
|
424
|
-
lookbehind:
|
|
2810
|
+
lookbehind: true
|
|
425
2811
|
},
|
|
426
2812
|
{
|
|
427
2813
|
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
|
428
|
-
lookbehind:
|
|
2814
|
+
lookbehind: true,
|
|
429
2815
|
alias: "function"
|
|
430
2816
|
}
|
|
431
2817
|
],
|
|
432
2818
|
// highlight macro directives as keywords
|
|
433
|
-
directive: {
|
|
2819
|
+
"directive": {
|
|
434
2820
|
pattern: /^(#\s*)[a-z]+/,
|
|
435
|
-
lookbehind:
|
|
2821
|
+
lookbehind: true,
|
|
436
2822
|
alias: "keyword"
|
|
437
2823
|
},
|
|
438
2824
|
"directive-hash": /^#/,
|
|
439
|
-
punctuation: /##|\\(?=[\r\n])/,
|
|
440
|
-
expression: {
|
|
2825
|
+
"punctuation": /##|\\(?=[\r\n])/,
|
|
2826
|
+
"expression": {
|
|
441
2827
|
pattern: /\S[\s\S]*/,
|
|
442
2828
|
inside: Prism.languages.c
|
|
443
2829
|
}
|
|
@@ -446,51 +2832,54 @@ Prism.languages.insertBefore("c", "string", {
|
|
|
446
2832
|
});
|
|
447
2833
|
Prism.languages.insertBefore("c", "function", {
|
|
448
2834
|
// highlight predefined macros as constants
|
|
449
|
-
constant: /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
2835
|
+
"constant": /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
450
2836
|
});
|
|
451
|
-
delete Prism.languages.c
|
|
452
|
-
(function(
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
2837
|
+
delete Prism.languages.c["boolean"];
|
|
2838
|
+
(function(Prism2) {
|
|
2839
|
+
var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
|
|
2840
|
+
for (var i = 0; i < 2; i++) {
|
|
2841
|
+
multilineComment = multilineComment.replace(/<self>/g, function() {
|
|
2842
|
+
return multilineComment;
|
|
456
2843
|
});
|
|
457
|
-
|
|
2844
|
+
}
|
|
2845
|
+
multilineComment = multilineComment.replace(/<self>/g, function() {
|
|
458
2846
|
return /[^\s\S]/.source;
|
|
459
|
-
})
|
|
460
|
-
|
|
2847
|
+
});
|
|
2848
|
+
Prism2.languages.rust = {
|
|
2849
|
+
"comment": [
|
|
461
2850
|
{
|
|
462
|
-
pattern: RegExp(/(^|[^\\])/.source +
|
|
463
|
-
lookbehind:
|
|
464
|
-
greedy:
|
|
2851
|
+
pattern: RegExp(/(^|[^\\])/.source + multilineComment),
|
|
2852
|
+
lookbehind: true,
|
|
2853
|
+
greedy: true
|
|
465
2854
|
},
|
|
466
2855
|
{
|
|
467
2856
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
468
|
-
lookbehind:
|
|
469
|
-
greedy:
|
|
2857
|
+
lookbehind: true,
|
|
2858
|
+
greedy: true
|
|
470
2859
|
}
|
|
471
2860
|
],
|
|
472
|
-
string: {
|
|
2861
|
+
"string": {
|
|
473
2862
|
pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
|
|
474
|
-
greedy:
|
|
2863
|
+
greedy: true
|
|
475
2864
|
},
|
|
476
|
-
char: {
|
|
2865
|
+
"char": {
|
|
477
2866
|
pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
|
|
478
|
-
greedy:
|
|
2867
|
+
greedy: true
|
|
479
2868
|
},
|
|
480
|
-
attribute: {
|
|
2869
|
+
"attribute": {
|
|
481
2870
|
pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
|
|
482
|
-
greedy:
|
|
2871
|
+
greedy: true,
|
|
483
2872
|
alias: "attr-name",
|
|
484
2873
|
inside: {
|
|
485
|
-
string: null
|
|
2874
|
+
"string": null
|
|
486
2875
|
// see below
|
|
487
2876
|
}
|
|
488
2877
|
},
|
|
489
2878
|
// Closure params should not be confused with bitwise OR |
|
|
490
2879
|
"closure-params": {
|
|
491
2880
|
pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
|
|
492
|
-
lookbehind:
|
|
493
|
-
greedy:
|
|
2881
|
+
lookbehind: true,
|
|
2882
|
+
greedy: true,
|
|
494
2883
|
inside: {
|
|
495
2884
|
"closure-punctuation": {
|
|
496
2885
|
pattern: /^\||\|$/,
|
|
@@ -506,36 +2895,36 @@ delete Prism.languages.c.boolean;
|
|
|
506
2895
|
},
|
|
507
2896
|
"fragment-specifier": {
|
|
508
2897
|
pattern: /(\$\w+:)[a-z]+/,
|
|
509
|
-
lookbehind:
|
|
2898
|
+
lookbehind: true,
|
|
510
2899
|
alias: "punctuation"
|
|
511
2900
|
},
|
|
512
|
-
variable: /\$\w+/,
|
|
2901
|
+
"variable": /\$\w+/,
|
|
513
2902
|
"function-definition": {
|
|
514
2903
|
pattern: /(\bfn\s+)\w+/,
|
|
515
|
-
lookbehind:
|
|
2904
|
+
lookbehind: true,
|
|
516
2905
|
alias: "function"
|
|
517
2906
|
},
|
|
518
2907
|
"type-definition": {
|
|
519
2908
|
pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
|
|
520
|
-
lookbehind:
|
|
2909
|
+
lookbehind: true,
|
|
521
2910
|
alias: "class-name"
|
|
522
2911
|
},
|
|
523
2912
|
"module-declaration": [
|
|
524
2913
|
{
|
|
525
2914
|
pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
|
|
526
|
-
lookbehind:
|
|
2915
|
+
lookbehind: true,
|
|
527
2916
|
alias: "namespace"
|
|
528
2917
|
},
|
|
529
2918
|
{
|
|
530
2919
|
pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
|
|
531
|
-
lookbehind:
|
|
2920
|
+
lookbehind: true,
|
|
532
2921
|
alias: "namespace",
|
|
533
2922
|
inside: {
|
|
534
|
-
punctuation: /::/
|
|
2923
|
+
"punctuation": /::/
|
|
535
2924
|
}
|
|
536
2925
|
}
|
|
537
2926
|
],
|
|
538
|
-
keyword: [
|
|
2927
|
+
"keyword": [
|
|
539
2928
|
// https://github.com/rust-lang/reference/blob/master/src/keywords.md
|
|
540
2929
|
/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
|
|
541
2930
|
// primitives and str
|
|
@@ -545,112 +2934,116 @@ delete Prism.languages.c.boolean;
|
|
|
545
2934
|
// functions can technically start with an upper-case letter, but this will introduce a lot of false positives
|
|
546
2935
|
// and Rust's naming conventions recommend snake_case anyway.
|
|
547
2936
|
// https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
|
|
548
|
-
function: /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
|
|
549
|
-
macro: {
|
|
2937
|
+
"function": /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
|
|
2938
|
+
"macro": {
|
|
550
2939
|
pattern: /\b\w+!/,
|
|
551
2940
|
alias: "property"
|
|
552
2941
|
},
|
|
553
|
-
constant: /\b[A-Z_][A-Z_\d]+\b/,
|
|
2942
|
+
"constant": /\b[A-Z_][A-Z_\d]+\b/,
|
|
554
2943
|
"class-name": /\b[A-Z]\w*\b/,
|
|
555
|
-
namespace: {
|
|
2944
|
+
"namespace": {
|
|
556
2945
|
pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
|
|
557
2946
|
inside: {
|
|
558
|
-
punctuation: /::/
|
|
2947
|
+
"punctuation": /::/
|
|
559
2948
|
}
|
|
560
2949
|
},
|
|
561
2950
|
// Hex, oct, bin, dec numbers with visual separators and type suffix
|
|
562
|
-
number: /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
|
|
563
|
-
boolean: /\b(?:false|true)\b/,
|
|
564
|
-
punctuation: /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
565
|
-
operator: /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
|
566
|
-
}
|
|
2951
|
+
"number": /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
|
|
2952
|
+
"boolean": /\b(?:false|true)\b/,
|
|
2953
|
+
"punctuation": /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
|
|
2954
|
+
"operator": /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
|
|
2955
|
+
};
|
|
2956
|
+
Prism2.languages.rust["closure-params"].inside.rest = Prism2.languages.rust;
|
|
2957
|
+
Prism2.languages.rust["attribute"].inside["string"] = Prism2.languages.rust["string"];
|
|
567
2958
|
})(Prism);
|
|
568
2959
|
Prism.languages.sql = {
|
|
569
|
-
comment: {
|
|
2960
|
+
"comment": {
|
|
570
2961
|
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
|
|
571
|
-
lookbehind:
|
|
2962
|
+
lookbehind: true
|
|
572
2963
|
},
|
|
573
|
-
variable: [
|
|
2964
|
+
"variable": [
|
|
574
2965
|
{
|
|
575
2966
|
pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
|
|
576
|
-
greedy:
|
|
2967
|
+
greedy: true
|
|
577
2968
|
},
|
|
578
2969
|
/@[\w.$]+/
|
|
579
2970
|
],
|
|
580
|
-
string: {
|
|
2971
|
+
"string": {
|
|
581
2972
|
pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
|
|
582
|
-
greedy:
|
|
583
|
-
lookbehind:
|
|
2973
|
+
greedy: true,
|
|
2974
|
+
lookbehind: true
|
|
584
2975
|
},
|
|
585
|
-
identifier: {
|
|
2976
|
+
"identifier": {
|
|
586
2977
|
pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
|
|
587
|
-
greedy:
|
|
588
|
-
lookbehind:
|
|
2978
|
+
greedy: true,
|
|
2979
|
+
lookbehind: true,
|
|
589
2980
|
inside: {
|
|
590
|
-
punctuation: /^`|`$/
|
|
2981
|
+
"punctuation": /^`|`$/
|
|
591
2982
|
}
|
|
592
2983
|
},
|
|
593
|
-
function: /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
|
2984
|
+
"function": /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
|
|
594
2985
|
// Should we highlight user defined functions too?
|
|
595
|
-
keyword: /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
|
|
596
|
-
boolean: /\b(?:FALSE|NULL|TRUE)\b/i,
|
|
597
|
-
number: /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
|
598
|
-
operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
599
|
-
punctuation: /[;[\]()`,.]/
|
|
2986
|
+
"keyword": /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
|
|
2987
|
+
"boolean": /\b(?:FALSE|NULL|TRUE)\b/i,
|
|
2988
|
+
"number": /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
|
|
2989
|
+
"operator": /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
2990
|
+
"punctuation": /[;[\]()`,.]/
|
|
600
2991
|
};
|
|
601
|
-
(function(
|
|
602
|
-
var
|
|
2992
|
+
(function(Prism2) {
|
|
2993
|
+
var envVars = "\\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";
|
|
2994
|
+
var commandAfterHeredoc = {
|
|
603
2995
|
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
604
|
-
lookbehind:
|
|
2996
|
+
lookbehind: true,
|
|
605
2997
|
alias: "punctuation",
|
|
606
2998
|
// this looks reasonably well in all themes
|
|
607
2999
|
inside: null
|
|
608
3000
|
// see below
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
3001
|
+
};
|
|
3002
|
+
var insideString = {
|
|
3003
|
+
"bash": commandAfterHeredoc,
|
|
3004
|
+
"environment": {
|
|
3005
|
+
pattern: RegExp("\\$" + envVars),
|
|
613
3006
|
alias: "constant"
|
|
614
3007
|
},
|
|
615
|
-
variable: [
|
|
3008
|
+
"variable": [
|
|
616
3009
|
// [0]: Arithmetic Environment
|
|
617
3010
|
{
|
|
618
3011
|
pattern: /\$?\(\([\s\S]+?\)\)/,
|
|
619
|
-
greedy:
|
|
3012
|
+
greedy: true,
|
|
620
3013
|
inside: {
|
|
621
3014
|
// If there is a $ sign at the beginning highlight $(( and )) as variable
|
|
622
|
-
variable: [
|
|
3015
|
+
"variable": [
|
|
623
3016
|
{
|
|
624
3017
|
pattern: /(^\$\(\([\s\S]+)\)\)/,
|
|
625
|
-
lookbehind:
|
|
3018
|
+
lookbehind: true
|
|
626
3019
|
},
|
|
627
3020
|
/^\$\(\(/
|
|
628
3021
|
],
|
|
629
|
-
number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
3022
|
+
"number": /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
630
3023
|
// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
|
|
631
|
-
operator: /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
3024
|
+
"operator": /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
632
3025
|
// If there is no $ sign at the beginning highlight (( and )) as punctuation
|
|
633
|
-
punctuation: /\(\(?|\)\)?|,|;/
|
|
3026
|
+
"punctuation": /\(\(?|\)\)?|,|;/
|
|
634
3027
|
}
|
|
635
3028
|
},
|
|
636
3029
|
// [1]: Command Substitution
|
|
637
3030
|
{
|
|
638
3031
|
pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
|
639
|
-
greedy:
|
|
3032
|
+
greedy: true,
|
|
640
3033
|
inside: {
|
|
641
|
-
variable: /^\$\(|^`|\)$|`$/
|
|
3034
|
+
"variable": /^\$\(|^`|\)$|`$/
|
|
642
3035
|
}
|
|
643
3036
|
},
|
|
644
3037
|
// [2]: Brace expansion
|
|
645
3038
|
{
|
|
646
3039
|
pattern: /\$\{[^}]+\}/,
|
|
647
|
-
greedy:
|
|
3040
|
+
greedy: true,
|
|
648
3041
|
inside: {
|
|
649
|
-
operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
650
|
-
punctuation: /[\[\]]/,
|
|
651
|
-
environment: {
|
|
652
|
-
pattern: RegExp("(\\{)" +
|
|
653
|
-
lookbehind:
|
|
3042
|
+
"operator": /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
3043
|
+
"punctuation": /[\[\]]/,
|
|
3044
|
+
"environment": {
|
|
3045
|
+
pattern: RegExp("(\\{)" + envVars),
|
|
3046
|
+
lookbehind: true,
|
|
654
3047
|
alias: "constant"
|
|
655
3048
|
}
|
|
656
3049
|
}
|
|
@@ -658,16 +3051,16 @@ Prism.languages.sql = {
|
|
|
658
3051
|
/\$(?:\w+|[#?*!@$])/
|
|
659
3052
|
],
|
|
660
3053
|
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
661
|
-
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})/
|
|
3054
|
+
"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})/
|
|
662
3055
|
};
|
|
663
|
-
|
|
664
|
-
shebang: {
|
|
3056
|
+
Prism2.languages.bash = {
|
|
3057
|
+
"shebang": {
|
|
665
3058
|
pattern: /^#!\s*\/.*/,
|
|
666
3059
|
alias: "important"
|
|
667
3060
|
},
|
|
668
|
-
comment: {
|
|
3061
|
+
"comment": {
|
|
669
3062
|
pattern: /(^|[^"{\\$])#.*/,
|
|
670
|
-
lookbehind:
|
|
3063
|
+
lookbehind: true
|
|
671
3064
|
},
|
|
672
3065
|
"function-name": [
|
|
673
3066
|
// a) function foo {
|
|
@@ -677,7 +3070,7 @@ Prism.languages.sql = {
|
|
|
677
3070
|
{
|
|
678
3071
|
// a) and c)
|
|
679
3072
|
pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
|
680
|
-
lookbehind:
|
|
3073
|
+
lookbehind: true,
|
|
681
3074
|
alias: "function"
|
|
682
3075
|
},
|
|
683
3076
|
{
|
|
@@ -690,98 +3083,98 @@ Prism.languages.sql = {
|
|
|
690
3083
|
"for-or-select": {
|
|
691
3084
|
pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
|
692
3085
|
alias: "variable",
|
|
693
|
-
lookbehind:
|
|
3086
|
+
lookbehind: true
|
|
694
3087
|
},
|
|
695
3088
|
// Highlight variable names as variables in the left-hand part
|
|
696
3089
|
// of assignments (“=” and “+=”).
|
|
697
3090
|
"assign-left": {
|
|
698
3091
|
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
699
3092
|
inside: {
|
|
700
|
-
environment: {
|
|
701
|
-
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" +
|
|
702
|
-
lookbehind:
|
|
3093
|
+
"environment": {
|
|
3094
|
+
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
|
|
3095
|
+
lookbehind: true,
|
|
703
3096
|
alias: "constant"
|
|
704
3097
|
}
|
|
705
3098
|
},
|
|
706
3099
|
alias: "variable",
|
|
707
|
-
lookbehind:
|
|
3100
|
+
lookbehind: true
|
|
708
3101
|
},
|
|
709
3102
|
// Highlight parameter names as variables
|
|
710
|
-
parameter: {
|
|
3103
|
+
"parameter": {
|
|
711
3104
|
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
|
|
712
3105
|
alias: "variable",
|
|
713
|
-
lookbehind:
|
|
3106
|
+
lookbehind: true
|
|
714
3107
|
},
|
|
715
|
-
string: [
|
|
3108
|
+
"string": [
|
|
716
3109
|
// Support for Here-documents https://en.wikipedia.org/wiki/Here_document
|
|
717
3110
|
{
|
|
718
3111
|
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
719
|
-
lookbehind:
|
|
720
|
-
greedy:
|
|
721
|
-
inside:
|
|
3112
|
+
lookbehind: true,
|
|
3113
|
+
greedy: true,
|
|
3114
|
+
inside: insideString
|
|
722
3115
|
},
|
|
723
3116
|
// Here-document with quotes around the tag
|
|
724
3117
|
// → No expansion (so no “inside”).
|
|
725
3118
|
{
|
|
726
3119
|
pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
|
|
727
|
-
lookbehind:
|
|
728
|
-
greedy:
|
|
3120
|
+
lookbehind: true,
|
|
3121
|
+
greedy: true,
|
|
729
3122
|
inside: {
|
|
730
|
-
bash:
|
|
3123
|
+
"bash": commandAfterHeredoc
|
|
731
3124
|
}
|
|
732
3125
|
},
|
|
733
3126
|
// “Normal” string
|
|
734
3127
|
{
|
|
735
3128
|
// https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
|
|
736
3129
|
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
737
|
-
lookbehind:
|
|
738
|
-
greedy:
|
|
739
|
-
inside:
|
|
3130
|
+
lookbehind: true,
|
|
3131
|
+
greedy: true,
|
|
3132
|
+
inside: insideString
|
|
740
3133
|
},
|
|
741
3134
|
{
|
|
742
3135
|
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
743
3136
|
pattern: /(^|[^$\\])'[^']*'/,
|
|
744
|
-
lookbehind:
|
|
745
|
-
greedy:
|
|
3137
|
+
lookbehind: true,
|
|
3138
|
+
greedy: true
|
|
746
3139
|
},
|
|
747
3140
|
{
|
|
748
3141
|
// https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
|
|
749
3142
|
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
750
|
-
greedy:
|
|
3143
|
+
greedy: true,
|
|
751
3144
|
inside: {
|
|
752
|
-
entity:
|
|
3145
|
+
"entity": insideString.entity
|
|
753
3146
|
}
|
|
754
3147
|
}
|
|
755
3148
|
],
|
|
756
|
-
environment: {
|
|
757
|
-
pattern: RegExp("\\$?" +
|
|
3149
|
+
"environment": {
|
|
3150
|
+
pattern: RegExp("\\$?" + envVars),
|
|
758
3151
|
alias: "constant"
|
|
759
3152
|
},
|
|
760
|
-
variable:
|
|
761
|
-
function: {
|
|
3153
|
+
"variable": insideString.variable,
|
|
3154
|
+
"function": {
|
|
762
3155
|
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;|&])/,
|
|
763
|
-
lookbehind:
|
|
3156
|
+
lookbehind: true
|
|
764
3157
|
},
|
|
765
|
-
keyword: {
|
|
3158
|
+
"keyword": {
|
|
766
3159
|
pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
|
|
767
|
-
lookbehind:
|
|
3160
|
+
lookbehind: true
|
|
768
3161
|
},
|
|
769
3162
|
// https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
|
|
770
|
-
builtin: {
|
|
3163
|
+
"builtin": {
|
|
771
3164
|
pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
|
|
772
|
-
lookbehind:
|
|
3165
|
+
lookbehind: true,
|
|
773
3166
|
// Alias added to make those easier to distinguish from strings.
|
|
774
3167
|
alias: "class-name"
|
|
775
3168
|
},
|
|
776
|
-
boolean: {
|
|
3169
|
+
"boolean": {
|
|
777
3170
|
pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
|
|
778
|
-
lookbehind:
|
|
3171
|
+
lookbehind: true
|
|
779
3172
|
},
|
|
780
3173
|
"file-descriptor": {
|
|
781
3174
|
pattern: /\B&\d\b/,
|
|
782
3175
|
alias: "important"
|
|
783
3176
|
},
|
|
784
|
-
operator: {
|
|
3177
|
+
"operator": {
|
|
785
3178
|
// Lots of redirections here, but not just that.
|
|
786
3179
|
pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
|
|
787
3180
|
inside: {
|
|
@@ -791,13 +3184,14 @@ Prism.languages.sql = {
|
|
|
791
3184
|
}
|
|
792
3185
|
}
|
|
793
3186
|
},
|
|
794
|
-
punctuation: /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
795
|
-
number: {
|
|
3187
|
+
"punctuation": /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
3188
|
+
"number": {
|
|
796
3189
|
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
797
|
-
lookbehind:
|
|
3190
|
+
lookbehind: true
|
|
798
3191
|
}
|
|
799
|
-
}
|
|
800
|
-
|
|
3192
|
+
};
|
|
3193
|
+
commandAfterHeredoc.inside = Prism2.languages.bash;
|
|
3194
|
+
var toBeCopied = [
|
|
801
3195
|
"comment",
|
|
802
3196
|
"function-name",
|
|
803
3197
|
"for-or-select",
|
|
@@ -813,36 +3207,40 @@ Prism.languages.sql = {
|
|
|
813
3207
|
"operator",
|
|
814
3208
|
"punctuation",
|
|
815
3209
|
"number"
|
|
816
|
-
]
|
|
817
|
-
|
|
818
|
-
|
|
3210
|
+
];
|
|
3211
|
+
var inside = insideString.variable[1].inside;
|
|
3212
|
+
for (var i = 0; i < toBeCopied.length; i++) {
|
|
3213
|
+
inside[toBeCopied[i]] = Prism2.languages.bash[toBeCopied[i]];
|
|
3214
|
+
}
|
|
3215
|
+
Prism2.languages.sh = Prism2.languages.bash;
|
|
3216
|
+
Prism2.languages.shell = Prism2.languages.bash;
|
|
819
3217
|
})(Prism);
|
|
820
3218
|
Prism.languages.json = {
|
|
821
|
-
property: {
|
|
3219
|
+
"property": {
|
|
822
3220
|
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
823
|
-
lookbehind:
|
|
824
|
-
greedy:
|
|
3221
|
+
lookbehind: true,
|
|
3222
|
+
greedy: true
|
|
825
3223
|
},
|
|
826
|
-
string: {
|
|
3224
|
+
"string": {
|
|
827
3225
|
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
|
|
828
|
-
lookbehind:
|
|
829
|
-
greedy:
|
|
3226
|
+
lookbehind: true,
|
|
3227
|
+
greedy: true
|
|
830
3228
|
},
|
|
831
|
-
comment: {
|
|
3229
|
+
"comment": {
|
|
832
3230
|
pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
833
|
-
greedy:
|
|
3231
|
+
greedy: true
|
|
834
3232
|
},
|
|
835
|
-
number: /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
|
836
|
-
punctuation: /[{}[\],]/,
|
|
837
|
-
operator: /:/,
|
|
838
|
-
boolean: /\b(?:false|true)\b/,
|
|
839
|
-
null: {
|
|
3233
|
+
"number": /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
|
|
3234
|
+
"punctuation": /[{}[\],]/,
|
|
3235
|
+
"operator": /:/,
|
|
3236
|
+
"boolean": /\b(?:false|true)\b/,
|
|
3237
|
+
"null": {
|
|
840
3238
|
pattern: /\bnull\b/,
|
|
841
3239
|
alias: "keyword"
|
|
842
3240
|
}
|
|
843
3241
|
};
|
|
844
3242
|
Prism.languages.webmanifest = Prism.languages.json;
|
|
845
|
-
const
|
|
3243
|
+
const prismDarkTheme = `
|
|
846
3244
|
/* 默认代码颜色 */
|
|
847
3245
|
.hep-cr-editor .hep-cr-highlight code,
|
|
848
3246
|
.hep-cr-editor .hep-cr-highlight pre {
|
|
@@ -926,7 +3324,8 @@ const Re = `
|
|
|
926
3324
|
.hep-cr-editor .token.console {
|
|
927
3325
|
color: #f8f8f2 !important;
|
|
928
3326
|
}
|
|
929
|
-
|
|
3327
|
+
`;
|
|
3328
|
+
const prismLightTheme = `
|
|
930
3329
|
/* 默认代码颜色 */
|
|
931
3330
|
.hep-cr-editor .hep-cr-highlight code,
|
|
932
3331
|
.hep-cr-editor .hep-cr-highlight pre {
|
|
@@ -1004,15 +3403,21 @@ const Re = `
|
|
|
1004
3403
|
color: #333 !important;
|
|
1005
3404
|
}
|
|
1006
3405
|
`;
|
|
1007
|
-
window.Prism =
|
|
1008
|
-
function
|
|
1009
|
-
if (typeof document
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1013
|
-
|
|
3406
|
+
window.Prism = Prism$1;
|
|
3407
|
+
function loadPrismTheme(theme) {
|
|
3408
|
+
if (typeof document === "undefined") return;
|
|
3409
|
+
const styleId = "hep-cr-prism-styles";
|
|
3410
|
+
const oldStyleEl = document.getElementById(styleId);
|
|
3411
|
+
const themeContent = theme === "dark" ? prismDarkTheme : prismLightTheme;
|
|
3412
|
+
if (oldStyleEl) {
|
|
3413
|
+
oldStyleEl.remove();
|
|
3414
|
+
}
|
|
3415
|
+
const styleEl = document.createElement("style");
|
|
3416
|
+
styleEl.id = styleId;
|
|
3417
|
+
styleEl.textContent = themeContent;
|
|
3418
|
+
document.head.appendChild(styleEl);
|
|
1014
3419
|
}
|
|
1015
|
-
const
|
|
3420
|
+
const languageMap = {
|
|
1016
3421
|
javascript: "javascript",
|
|
1017
3422
|
js: "javascript",
|
|
1018
3423
|
typescript: "typescript",
|
|
@@ -1044,74 +3449,106 @@ const Le = {
|
|
|
1044
3449
|
markdown: "markdown",
|
|
1045
3450
|
md: "markdown"
|
|
1046
3451
|
};
|
|
1047
|
-
function
|
|
1048
|
-
const
|
|
1049
|
-
|
|
3452
|
+
function escapeHtml(text) {
|
|
3453
|
+
const div = document.createElement("div");
|
|
3454
|
+
div.textContent = text;
|
|
3455
|
+
return div.innerHTML;
|
|
1050
3456
|
}
|
|
1051
|
-
const
|
|
1052
|
-
value
|
|
1053
|
-
language
|
|
1054
|
-
theme
|
|
1055
|
-
disabled
|
|
1056
|
-
onChange
|
|
1057
|
-
onCodeChange
|
|
3457
|
+
const CodeEditor = ({
|
|
3458
|
+
value,
|
|
3459
|
+
language,
|
|
3460
|
+
theme = "dark",
|
|
3461
|
+
disabled = false,
|
|
3462
|
+
onChange,
|
|
3463
|
+
onCodeChange
|
|
1058
3464
|
}) => {
|
|
1059
|
-
const
|
|
3465
|
+
const textareaRef = useRef(null);
|
|
3466
|
+
const highlightRef = useRef(null);
|
|
3467
|
+
const changeTimerRef = useRef(null);
|
|
3468
|
+
const prismLanguage = useMemo(() => {
|
|
3469
|
+
return languageMap[language.toLowerCase()] || "javascript";
|
|
3470
|
+
}, [language]);
|
|
3471
|
+
const editorBackground = theme === "dark" ? "#1e1e1e" : "#fafafa";
|
|
3472
|
+
const highlightedCode = useMemo(() => {
|
|
1060
3473
|
try {
|
|
1061
|
-
const
|
|
1062
|
-
if (
|
|
1063
|
-
return
|
|
1064
|
-
|
|
3474
|
+
const grammar = Prism$1.languages[prismLanguage];
|
|
3475
|
+
if (grammar) {
|
|
3476
|
+
return Prism$1.highlight(value || "", grammar, prismLanguage);
|
|
3477
|
+
}
|
|
3478
|
+
} catch (e) {
|
|
3479
|
+
}
|
|
3480
|
+
return escapeHtml(value || "");
|
|
3481
|
+
}, [value, prismLanguage]);
|
|
3482
|
+
const emitChange = useCallback((newValue) => {
|
|
3483
|
+
if (changeTimerRef.current) {
|
|
3484
|
+
clearTimeout(changeTimerRef.current);
|
|
1065
3485
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
y.current && clearTimeout(y.current), y.current = setTimeout(() => {
|
|
1069
|
-
u == null || u(l);
|
|
3486
|
+
changeTimerRef.current = setTimeout(() => {
|
|
3487
|
+
onCodeChange == null ? void 0 : onCodeChange(newValue);
|
|
1070
3488
|
}, 500);
|
|
1071
|
-
}, [
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
3489
|
+
}, [onCodeChange]);
|
|
3490
|
+
const handleInput = (e) => {
|
|
3491
|
+
const newValue = e.target.value;
|
|
3492
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
3493
|
+
emitChange(newValue);
|
|
3494
|
+
};
|
|
3495
|
+
const handleScroll = () => {
|
|
3496
|
+
if (textareaRef.current && highlightRef.current) {
|
|
3497
|
+
highlightRef.current.scrollTop = textareaRef.current.scrollTop;
|
|
3498
|
+
highlightRef.current.scrollLeft = textareaRef.current.scrollLeft;
|
|
3499
|
+
}
|
|
3500
|
+
};
|
|
3501
|
+
const handleKeyDown = (e) => {
|
|
3502
|
+
if (e.key === "Tab") {
|
|
3503
|
+
e.preventDefault();
|
|
3504
|
+
const target = e.target;
|
|
3505
|
+
const start = target.selectionStart;
|
|
3506
|
+
const end = target.selectionEnd;
|
|
3507
|
+
const newValue = value.substring(0, start) + " " + value.substring(end);
|
|
3508
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
3509
|
+
emitChange(newValue);
|
|
3510
|
+
requestAnimationFrame(() => {
|
|
3511
|
+
target.selectionStart = target.selectionEnd = start + 2;
|
|
1082
3512
|
});
|
|
1083
3513
|
}
|
|
1084
3514
|
};
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
3515
|
+
useEffect(() => {
|
|
3516
|
+
return () => {
|
|
3517
|
+
if (changeTimerRef.current) {
|
|
3518
|
+
clearTimeout(changeTimerRef.current);
|
|
3519
|
+
}
|
|
3520
|
+
};
|
|
3521
|
+
}, []);
|
|
3522
|
+
useEffect(() => {
|
|
3523
|
+
loadPrismTheme(theme);
|
|
3524
|
+
}, [theme]);
|
|
3525
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `hep-cr-editor theme-${theme}`, style: { background: editorBackground }, children: [
|
|
3526
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1091
3527
|
"pre",
|
|
1092
3528
|
{
|
|
1093
|
-
ref:
|
|
1094
|
-
className: `hep-cr-highlight language-${
|
|
3529
|
+
ref: highlightRef,
|
|
3530
|
+
className: `hep-cr-highlight language-${prismLanguage}`,
|
|
1095
3531
|
"aria-hidden": "true",
|
|
1096
|
-
children: /* @__PURE__ */
|
|
3532
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("code", { dangerouslySetInnerHTML: { __html: highlightedCode } })
|
|
1097
3533
|
}
|
|
1098
3534
|
),
|
|
1099
|
-
/* @__PURE__ */
|
|
3535
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1100
3536
|
"textarea",
|
|
1101
3537
|
{
|
|
1102
|
-
ref:
|
|
3538
|
+
ref: textareaRef,
|
|
1103
3539
|
className: "hep-cr-input",
|
|
1104
|
-
value
|
|
1105
|
-
disabled
|
|
1106
|
-
onChange:
|
|
1107
|
-
onScroll:
|
|
1108
|
-
onKeyDown:
|
|
1109
|
-
spellCheck:
|
|
3540
|
+
value,
|
|
3541
|
+
disabled,
|
|
3542
|
+
onChange: handleInput,
|
|
3543
|
+
onScroll: handleScroll,
|
|
3544
|
+
onKeyDown: handleKeyDown,
|
|
3545
|
+
spellCheck: false,
|
|
1110
3546
|
placeholder: "Write your code here..."
|
|
1111
3547
|
}
|
|
1112
3548
|
)
|
|
1113
3549
|
] });
|
|
1114
|
-
}
|
|
3550
|
+
};
|
|
3551
|
+
const styles = `
|
|
1115
3552
|
.hep-cr-editor {
|
|
1116
3553
|
position: relative;
|
|
1117
3554
|
flex: 1;
|
|
@@ -1169,179 +3606,482 @@ const Fe = ({
|
|
|
1169
3606
|
caret-color: #333333;
|
|
1170
3607
|
}
|
|
1171
3608
|
`;
|
|
1172
|
-
if (typeof document
|
|
1173
|
-
const
|
|
1174
|
-
if (!document.getElementById(
|
|
1175
|
-
const
|
|
1176
|
-
|
|
3609
|
+
if (typeof document !== "undefined") {
|
|
3610
|
+
const styleId = "hep-cr-editor-styles";
|
|
3611
|
+
if (!document.getElementById(styleId)) {
|
|
3612
|
+
const styleEl = document.createElement("style");
|
|
3613
|
+
styleEl.id = styleId;
|
|
3614
|
+
styleEl.textContent = styles;
|
|
3615
|
+
document.head.appendChild(styleEl);
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
var w = Object.defineProperty;
|
|
3619
|
+
var y = (o, e, t) => e in o ? w(o, e, { enumerable: true, configurable: true, writable: true, value: t }) : o[e] = t;
|
|
3620
|
+
var c = (o, e, t) => y(o, typeof e != "symbol" ? e + "" : e, t);
|
|
3621
|
+
let u = null;
|
|
3622
|
+
class W {
|
|
3623
|
+
constructor(e = {}) {
|
|
3624
|
+
c(this, "baseUrl");
|
|
3625
|
+
c(this, "timeout");
|
|
3626
|
+
this.baseUrl = e.pistonUrl || "/api/piston", this.timeout = e.timeout || 3e3;
|
|
3627
|
+
}
|
|
3628
|
+
async getRuntimes(e = false) {
|
|
3629
|
+
if (u && !e)
|
|
3630
|
+
return u;
|
|
3631
|
+
try {
|
|
3632
|
+
const t = await fetch(`${this.baseUrl}/runtimes`, {
|
|
3633
|
+
method: "GET",
|
|
3634
|
+
headers: {
|
|
3635
|
+
"Content-Type": "application/json"
|
|
3636
|
+
}
|
|
3637
|
+
});
|
|
3638
|
+
if (!t.ok)
|
|
3639
|
+
throw new Error(`Failed to fetch runtimes: ${t.statusText}`);
|
|
3640
|
+
const n = await t.json();
|
|
3641
|
+
return u = n, n;
|
|
3642
|
+
} catch (t) {
|
|
3643
|
+
throw console.error("Failed to fetch runtimes:", t), t;
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
async execute(e, t, n = {}) {
|
|
3647
|
+
const l = (await this.getRuntimes()).find(
|
|
3648
|
+
(a) => {
|
|
3649
|
+
var r;
|
|
3650
|
+
return a.language.toLowerCase() === e.toLowerCase() || ((r = a.aliases) == null ? void 0 : r.some((i) => i.toLowerCase() === e.toLowerCase()));
|
|
3651
|
+
}
|
|
3652
|
+
);
|
|
3653
|
+
if (!l)
|
|
3654
|
+
throw new Error(`Language '${e}' is not supported`);
|
|
3655
|
+
const p = this.getFileName(e), h = {
|
|
3656
|
+
language: l.language,
|
|
3657
|
+
version: n.version || l.version,
|
|
3658
|
+
files: [
|
|
3659
|
+
{
|
|
3660
|
+
name: p,
|
|
3661
|
+
content: t
|
|
3662
|
+
}
|
|
3663
|
+
],
|
|
3664
|
+
stdin: n.stdin || "",
|
|
3665
|
+
args: n.args || [],
|
|
3666
|
+
run_timeout: n.runTimeout || this.timeout,
|
|
3667
|
+
compile_timeout: this.timeout
|
|
3668
|
+
}, d = Date.now();
|
|
3669
|
+
try {
|
|
3670
|
+
const a = await fetch(`${this.baseUrl}/execute`, {
|
|
3671
|
+
method: "POST",
|
|
3672
|
+
headers: {
|
|
3673
|
+
"Content-Type": "application/json"
|
|
3674
|
+
},
|
|
3675
|
+
body: JSON.stringify(h)
|
|
3676
|
+
});
|
|
3677
|
+
if (!a.ok)
|
|
3678
|
+
throw new Error(`Execute failed: ${a.statusText}`);
|
|
3679
|
+
const r = await a.json(), i = Date.now() - d, g = r.run.stdout || "", f = r.run.stderr || "";
|
|
3680
|
+
return {
|
|
3681
|
+
success: r.run.code === 0,
|
|
3682
|
+
output: g,
|
|
3683
|
+
stderr: f,
|
|
3684
|
+
code: r.run.code,
|
|
3685
|
+
executionTime: i,
|
|
3686
|
+
compile: r.compile ? {
|
|
3687
|
+
stdout: r.compile.stdout || "",
|
|
3688
|
+
stderr: r.compile.stderr || "",
|
|
3689
|
+
code: r.compile.code
|
|
3690
|
+
} : void 0
|
|
3691
|
+
};
|
|
3692
|
+
} catch (a) {
|
|
3693
|
+
return {
|
|
3694
|
+
success: false,
|
|
3695
|
+
output: "",
|
|
3696
|
+
stderr: a instanceof Error ? a.message : "Unknown error",
|
|
3697
|
+
code: -1,
|
|
3698
|
+
executionTime: Date.now() - d
|
|
3699
|
+
};
|
|
3700
|
+
}
|
|
1177
3701
|
}
|
|
3702
|
+
getFileName(e) {
|
|
3703
|
+
return {
|
|
3704
|
+
javascript: "main.js",
|
|
3705
|
+
typescript: "main.ts",
|
|
3706
|
+
python: "main.py",
|
|
3707
|
+
python3: "main.py",
|
|
3708
|
+
go: "main.go",
|
|
3709
|
+
rust: "main.rs",
|
|
3710
|
+
java: "Main.java",
|
|
3711
|
+
c: "main.c",
|
|
3712
|
+
cpp: "main.cpp",
|
|
3713
|
+
csharp: "Main.cs",
|
|
3714
|
+
ruby: "main.rb",
|
|
3715
|
+
php: "main.php",
|
|
3716
|
+
bash: "main.sh",
|
|
3717
|
+
shell: "main.sh",
|
|
3718
|
+
perl: "main.pl",
|
|
3719
|
+
lua: "main.lua",
|
|
3720
|
+
swift: "main.swift",
|
|
3721
|
+
kotlin: "Main.kt",
|
|
3722
|
+
scala: "Main.scala",
|
|
3723
|
+
haskell: "main.hs",
|
|
3724
|
+
dart: "main.dart",
|
|
3725
|
+
html: "index.html",
|
|
3726
|
+
css: "style.css",
|
|
3727
|
+
sql: "query.sql",
|
|
3728
|
+
markdown: "readme.md"
|
|
3729
|
+
}[e.toLowerCase()] || `main.${e}`;
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
const m = {
|
|
3733
|
+
javascript: 'console.log("Hello, World!");',
|
|
3734
|
+
typescript: 'console.log("Hello, World!");',
|
|
3735
|
+
python: 'print("Hello, World!")',
|
|
3736
|
+
python3: 'print("Hello, World!")',
|
|
3737
|
+
go: `package main
|
|
3738
|
+
|
|
3739
|
+
import "fmt"
|
|
3740
|
+
|
|
3741
|
+
func main() {
|
|
3742
|
+
fmt.Println("Hello, World!")
|
|
3743
|
+
}`,
|
|
3744
|
+
rust: `fn main() {
|
|
3745
|
+
println!("Hello, World!");
|
|
3746
|
+
}`,
|
|
3747
|
+
java: `public class Main {
|
|
3748
|
+
public static void main(String[] args) {
|
|
3749
|
+
System.out.println("Hello, World!");
|
|
3750
|
+
}
|
|
3751
|
+
}`,
|
|
3752
|
+
c: `#include <stdio.h>
|
|
3753
|
+
|
|
3754
|
+
int main() {
|
|
3755
|
+
printf("Hello, World!\\n");
|
|
3756
|
+
return 0;
|
|
3757
|
+
}`,
|
|
3758
|
+
cpp: `#include <iostream>
|
|
3759
|
+
|
|
3760
|
+
int main() {
|
|
3761
|
+
std::cout << "Hello, World!" << std::endl;
|
|
3762
|
+
return 0;
|
|
3763
|
+
}`,
|
|
3764
|
+
csharp: `using System;
|
|
3765
|
+
|
|
3766
|
+
class Main {
|
|
3767
|
+
static void Main() {
|
|
3768
|
+
Console.WriteLine("Hello, World!");
|
|
3769
|
+
}
|
|
3770
|
+
}`,
|
|
3771
|
+
ruby: 'puts "Hello, World!"',
|
|
3772
|
+
php: `<?php
|
|
3773
|
+
echo "Hello, World!";
|
|
3774
|
+
?>`,
|
|
3775
|
+
bash: 'echo "Hello, World!"',
|
|
3776
|
+
shell: 'echo "Hello, World!"',
|
|
3777
|
+
perl: 'print "Hello, World!\\n";',
|
|
3778
|
+
lua: 'print("Hello, World!")',
|
|
3779
|
+
r: 'print("Hello, World!")',
|
|
3780
|
+
swift: 'print("Hello, World!")',
|
|
3781
|
+
kotlin: `fun main() {
|
|
3782
|
+
println("Hello, World!")
|
|
3783
|
+
}`,
|
|
3784
|
+
scala: `object Main extends App {
|
|
3785
|
+
println("Hello, World!")
|
|
3786
|
+
}`,
|
|
3787
|
+
haskell: 'main = putStrLn "Hello, World!"',
|
|
3788
|
+
elixir: 'IO.puts "Hello, World!"',
|
|
3789
|
+
erlang: 'main() -> io:fwrite("Hello, World!~n").',
|
|
3790
|
+
clojure: '(println "Hello, World!")',
|
|
3791
|
+
fsharp: 'printfn "Hello, World!"',
|
|
3792
|
+
dart: `void main() {
|
|
3793
|
+
print("Hello, World!");
|
|
3794
|
+
}`,
|
|
3795
|
+
assembly: `section .data
|
|
3796
|
+
msg db 'Hello, World!', 0
|
|
3797
|
+
section .text
|
|
3798
|
+
global _start
|
|
3799
|
+
_start:
|
|
3800
|
+
mov rax, 1
|
|
3801
|
+
mov rdi, 1
|
|
3802
|
+
mov rsi, msg
|
|
3803
|
+
mov rdx, 13
|
|
3804
|
+
syscall
|
|
3805
|
+
mov rax, 60
|
|
3806
|
+
xor rdi, rdi
|
|
3807
|
+
syscall`,
|
|
3808
|
+
html: `<!DOCTYPE html>
|
|
3809
|
+
<html>
|
|
3810
|
+
<head>
|
|
3811
|
+
<title>Hello</title>
|
|
3812
|
+
</head>
|
|
3813
|
+
<body>
|
|
3814
|
+
<h1>Hello, World!</h1>
|
|
3815
|
+
</body>
|
|
3816
|
+
</html>`,
|
|
3817
|
+
css: `body {
|
|
3818
|
+
background-color: #f0f0f0;
|
|
3819
|
+
font-family: Arial, sans-serif;
|
|
3820
|
+
}
|
|
3821
|
+
|
|
3822
|
+
h1 {
|
|
3823
|
+
color: #333;
|
|
3824
|
+
}`,
|
|
3825
|
+
sql: "SELECT 'Hello, World!' AS message;",
|
|
3826
|
+
markdown: `# Hello, World!
|
|
3827
|
+
|
|
3828
|
+
This is a sample markdown document.`
|
|
3829
|
+
};
|
|
3830
|
+
function j(o) {
|
|
3831
|
+
const e = o.toLowerCase();
|
|
3832
|
+
return m[e] || `// ${o}
|
|
3833
|
+
// Write your code here`;
|
|
1178
3834
|
}
|
|
1179
|
-
const
|
|
1180
|
-
pistonUrl
|
|
1181
|
-
language
|
|
1182
|
-
theme
|
|
1183
|
-
themeColor
|
|
1184
|
-
showLanguageSelector
|
|
1185
|
-
showEditor
|
|
1186
|
-
editable
|
|
1187
|
-
defaultCode
|
|
1188
|
-
executorLabel
|
|
1189
|
-
onExecuteStart
|
|
1190
|
-
onExecuteEnd
|
|
1191
|
-
onLanguageChange
|
|
1192
|
-
onChange
|
|
3835
|
+
const CodeRunner = ({
|
|
3836
|
+
pistonUrl = "/api/piston",
|
|
3837
|
+
language = "javascript",
|
|
3838
|
+
theme = "light",
|
|
3839
|
+
themeColor = "",
|
|
3840
|
+
showLanguageSelector = true,
|
|
3841
|
+
showEditor = true,
|
|
3842
|
+
editable = true,
|
|
3843
|
+
defaultCode = "",
|
|
3844
|
+
executorLabel = "运行",
|
|
3845
|
+
onExecuteStart,
|
|
3846
|
+
onExecuteEnd,
|
|
3847
|
+
onLanguageChange,
|
|
3848
|
+
onChange
|
|
1193
3849
|
}) => {
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
3850
|
+
const STORAGE_KEY = "hep-cr-default-language";
|
|
3851
|
+
const getStoredLanguage = () => {
|
|
3852
|
+
if (typeof window === "undefined") return language;
|
|
3853
|
+
return localStorage.getItem(STORAGE_KEY) || language;
|
|
3854
|
+
};
|
|
3855
|
+
const [runtimes, setRuntimes] = useState([]);
|
|
3856
|
+
const [currentLanguage, setCurrentLanguage] = useState(getStoredLanguage());
|
|
3857
|
+
const [currentTheme, setTheme] = useState(theme);
|
|
3858
|
+
const [code, setCode] = useState(defaultCode);
|
|
3859
|
+
const [output, setOutput] = useState("");
|
|
3860
|
+
const [stderr, setStderr] = useState("");
|
|
3861
|
+
const [isRunning, setIsRunning] = useState(false);
|
|
3862
|
+
const [executionTime, setExecutionTime] = useState(null);
|
|
3863
|
+
const [activeTab, setActiveTab] = useState("stdout");
|
|
3864
|
+
const [error, setError] = useState(null);
|
|
3865
|
+
const [runtimesLoading, setRuntimesLoading] = useState(true);
|
|
3866
|
+
const [editorWidth, setEditorWidth] = useState(60);
|
|
3867
|
+
const [copiedEditor, setCopiedEditor] = useState(false);
|
|
3868
|
+
const [copiedOutput, setCopiedOutput] = useState(false);
|
|
3869
|
+
const hasEmittedLanguageChange = useRef(false);
|
|
3870
|
+
const client = useMemo(() => new W({ pistonUrl }), [pistonUrl]);
|
|
3871
|
+
const languageOptions = useMemo(() => {
|
|
3872
|
+
return runtimes.map((r) => ({
|
|
3873
|
+
value: `${r.language}:${r.version}`,
|
|
3874
|
+
label: `${r.language.charAt(0).toUpperCase() + r.language.slice(1)} ${r.version}`
|
|
3875
|
+
}));
|
|
3876
|
+
}, [runtimes]);
|
|
3877
|
+
const themeStyle = useMemo(() => {
|
|
3878
|
+
if (!themeColor) return {};
|
|
3879
|
+
const isDark = theme === "dark";
|
|
3880
|
+
const adjustColor = (hex, percent) => {
|
|
3881
|
+
const num = parseInt(hex.replace("#", ""), 16);
|
|
3882
|
+
const amt = Math.round(2.55 * percent);
|
|
3883
|
+
const R = Math.min(255, Math.max(0, (num >> 16) + amt));
|
|
3884
|
+
const G = Math.min(255, Math.max(0, (num >> 8 & 255) + amt));
|
|
3885
|
+
const B = Math.min(255, Math.max(0, (num & 255) + amt));
|
|
3886
|
+
return "#" + (16777216 + R * 65536 + G * 256 + B).toString(16).slice(1);
|
|
3887
|
+
};
|
|
3888
|
+
const isColorLight = (hex) => {
|
|
3889
|
+
const num = parseInt(hex.replace("#", ""), 16);
|
|
3890
|
+
const r = num >> 16 & 255;
|
|
3891
|
+
const g = num >> 8 & 255;
|
|
3892
|
+
const b = num & 255;
|
|
3893
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
3894
|
+
return luminance > 0.5;
|
|
3895
|
+
};
|
|
3896
|
+
const isLightColor = isColorLight(themeColor);
|
|
3897
|
+
const textColor = isLightColor ? "#000" : "#fff";
|
|
1206
3898
|
return {
|
|
1207
|
-
"--hep-cr-theme-color":
|
|
1208
|
-
"--hep-cr-theme-color-hover":
|
|
1209
|
-
"--hep-cr-tab-active-color":
|
|
3899
|
+
"--hep-cr-theme-color": themeColor,
|
|
3900
|
+
"--hep-cr-theme-color-hover": isDark ? adjustColor(themeColor, 20) : adjustColor(themeColor, -20),
|
|
3901
|
+
"--hep-cr-tab-active-color": textColor
|
|
1210
3902
|
};
|
|
1211
|
-
}, [
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
3903
|
+
}, [themeColor, theme]);
|
|
3904
|
+
const languageName = useMemo(() => {
|
|
3905
|
+
return currentLanguage.includes(":") ? currentLanguage.split(":")[0] : currentLanguage;
|
|
3906
|
+
}, [currentLanguage]);
|
|
3907
|
+
useEffect(() => {
|
|
3908
|
+
async function loadRuntimes() {
|
|
3909
|
+
setRuntimesLoading(true);
|
|
3910
|
+
setError(null);
|
|
1215
3911
|
try {
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
} catch (
|
|
1219
|
-
|
|
3912
|
+
const data = await client.getRuntimes();
|
|
3913
|
+
setRuntimes(data);
|
|
3914
|
+
} catch (e) {
|
|
3915
|
+
setError(e instanceof Error ? e.message : "Failed to load runtimes");
|
|
1220
3916
|
} finally {
|
|
1221
|
-
|
|
3917
|
+
setRuntimesLoading(false);
|
|
1222
3918
|
}
|
|
1223
3919
|
}
|
|
1224
|
-
|
|
1225
|
-
}, [
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
output: "",
|
|
1251
|
-
stderr: c,
|
|
1252
|
-
code: -1
|
|
1253
|
-
});
|
|
1254
|
-
} finally {
|
|
1255
|
-
re(!1);
|
|
3920
|
+
loadRuntimes();
|
|
3921
|
+
}, [client]);
|
|
3922
|
+
useEffect(() => {
|
|
3923
|
+
if (!code && runtimes.length > 0) {
|
|
3924
|
+
setCode(defaultCode || j(languageName));
|
|
3925
|
+
}
|
|
3926
|
+
}, [runtimes, code, defaultCode, languageName]);
|
|
3927
|
+
useEffect(() => {
|
|
3928
|
+
onChange == null ? void 0 : onChange(code);
|
|
3929
|
+
}, []);
|
|
3930
|
+
useEffect(() => {
|
|
3931
|
+
if (!runtimesLoading && runtimes.length > 0 && onLanguageChange && !hasEmittedLanguageChange.current) {
|
|
3932
|
+
hasEmittedLanguageChange.current = true;
|
|
3933
|
+
onLanguageChange(languageName, code);
|
|
3934
|
+
}
|
|
3935
|
+
}, [runtimesLoading, runtimes.length]);
|
|
3936
|
+
const handleLanguageChange = useCallback(
|
|
3937
|
+
(e) => {
|
|
3938
|
+
const newLang = e.target.value;
|
|
3939
|
+
const langName = newLang.includes(":") ? newLang.split(":")[0] : newLang;
|
|
3940
|
+
setCurrentLanguage(newLang);
|
|
3941
|
+
const newCode = j(langName);
|
|
3942
|
+
setCode(newCode);
|
|
3943
|
+
onLanguageChange == null ? void 0 : onLanguageChange(langName, newCode);
|
|
3944
|
+
if (typeof window !== "undefined") {
|
|
3945
|
+
localStorage.setItem(STORAGE_KEY, newLang);
|
|
1256
3946
|
}
|
|
3947
|
+
},
|
|
3948
|
+
[onLanguageChange]
|
|
3949
|
+
);
|
|
3950
|
+
const execute = useCallback(async () => {
|
|
3951
|
+
if (isRunning) return;
|
|
3952
|
+
setIsRunning(true);
|
|
3953
|
+
setOutput("");
|
|
3954
|
+
setStderr("");
|
|
3955
|
+
setExecutionTime(null);
|
|
3956
|
+
setError(null);
|
|
3957
|
+
setActiveTab("stdout");
|
|
3958
|
+
onExecuteStart == null ? void 0 : onExecuteStart();
|
|
3959
|
+
try {
|
|
3960
|
+
const result = await client.execute(languageName, code);
|
|
3961
|
+
setOutput(result.output);
|
|
3962
|
+
setStderr(result.stderr);
|
|
3963
|
+
setExecutionTime(result.executionTime || null);
|
|
3964
|
+
setActiveTab(result.stderr ? "stderr" : "stdout");
|
|
3965
|
+
onExecuteEnd == null ? void 0 : onExecuteEnd(result);
|
|
3966
|
+
} catch (e) {
|
|
3967
|
+
const errorMsg = e instanceof Error ? e.message : "Execution failed";
|
|
3968
|
+
setError(errorMsg);
|
|
3969
|
+
onExecuteEnd == null ? void 0 : onExecuteEnd({
|
|
3970
|
+
success: false,
|
|
3971
|
+
output: "",
|
|
3972
|
+
stderr: errorMsg,
|
|
3973
|
+
code: -1
|
|
3974
|
+
});
|
|
3975
|
+
} finally {
|
|
3976
|
+
setIsRunning(false);
|
|
1257
3977
|
}
|
|
1258
|
-
}, [
|
|
1259
|
-
|
|
1260
|
-
|
|
3978
|
+
}, [isRunning, currentLanguage, code, client, onExecuteStart, onExecuteEnd]);
|
|
3979
|
+
const copyCode = useCallback(async () => {
|
|
3980
|
+
await navigator.clipboard.writeText(code);
|
|
3981
|
+
setCopiedEditor(true);
|
|
3982
|
+
setTimeout(() => {
|
|
3983
|
+
setCopiedEditor(false);
|
|
1261
3984
|
}, 2e3);
|
|
1262
|
-
}, [
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
3985
|
+
}, [code]);
|
|
3986
|
+
const copyOutput = useCallback(async () => {
|
|
3987
|
+
const text = activeTab === "stdout" ? output : stderr;
|
|
3988
|
+
await navigator.clipboard.writeText(text);
|
|
3989
|
+
setCopiedOutput(true);
|
|
3990
|
+
setTimeout(() => {
|
|
3991
|
+
setCopiedOutput(false);
|
|
1266
3992
|
}, 2e3);
|
|
1267
|
-
}, [
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
3993
|
+
}, [activeTab, output, stderr]);
|
|
3994
|
+
const resetCode = useCallback(() => {
|
|
3995
|
+
setCode(j(languageName));
|
|
3996
|
+
}, [currentLanguage]);
|
|
3997
|
+
const isDragging = useRef(false);
|
|
3998
|
+
const startDrag = useCallback((e) => {
|
|
3999
|
+
isDragging.current = true;
|
|
4000
|
+
document.addEventListener("mousemove", onDrag);
|
|
4001
|
+
document.addEventListener("mouseup", stopDrag);
|
|
4002
|
+
document.body.style.cursor = "col-resize";
|
|
4003
|
+
document.body.style.userSelect = "none";
|
|
4004
|
+
}, []);
|
|
4005
|
+
const onDrag = useCallback((e) => {
|
|
4006
|
+
if (!isDragging.current) return;
|
|
4007
|
+
const container = document.querySelector(".hep-cr-main");
|
|
4008
|
+
if (!container) return;
|
|
4009
|
+
const rect = container.getBoundingClientRect();
|
|
4010
|
+
const newWidth = (e.clientX - rect.left) / rect.width * 100;
|
|
4011
|
+
setEditorWidth(Math.max(20, Math.min(80, newWidth)));
|
|
4012
|
+
}, []);
|
|
4013
|
+
const stopDrag = useCallback(() => {
|
|
4014
|
+
isDragging.current = false;
|
|
4015
|
+
document.removeEventListener("mousemove", onDrag);
|
|
4016
|
+
document.removeEventListener("mouseup", stopDrag);
|
|
4017
|
+
document.body.style.cursor = "";
|
|
4018
|
+
document.body.style.userSelect = "";
|
|
4019
|
+
}, [onDrag]);
|
|
4020
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `hep-cr-runner hep-cr-runner-${currentTheme}`, style: themeStyle, children: [
|
|
4021
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-header", children: [
|
|
4022
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hep-cr-controls", children: showLanguageSelector && /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1283
4023
|
"select",
|
|
1284
4024
|
{
|
|
1285
|
-
value:
|
|
1286
|
-
onChange:
|
|
4025
|
+
value: currentLanguage,
|
|
4026
|
+
onChange: handleLanguageChange,
|
|
1287
4027
|
className: "hep-cr-language-select",
|
|
1288
|
-
disabled:
|
|
4028
|
+
disabled: isRunning,
|
|
1289
4029
|
children: [
|
|
1290
|
-
|
|
1291
|
-
|
|
4030
|
+
runtimesLoading && /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "加载中..." }),
|
|
4031
|
+
languageOptions.map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: option.value, children: option.label }, option.value))
|
|
1292
4032
|
]
|
|
1293
4033
|
}
|
|
1294
4034
|
) }) }),
|
|
1295
|
-
/* @__PURE__ */
|
|
1296
|
-
/* @__PURE__ */
|
|
4035
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-actions", children: [
|
|
4036
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1297
4037
|
"button",
|
|
1298
4038
|
{
|
|
1299
4039
|
className: "hep-cr-btn hep-cr-btn-run",
|
|
1300
|
-
disabled:
|
|
1301
|
-
onClick:
|
|
4040
|
+
disabled: isRunning || runtimesLoading,
|
|
4041
|
+
onClick: execute,
|
|
1302
4042
|
children: [
|
|
1303
|
-
|
|
1304
|
-
|
|
4043
|
+
isRunning ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hep-cr-spinner" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hep-cr-run-icon", children: "▶" }),
|
|
4044
|
+
isRunning ? "运行中..." : executorLabel
|
|
1305
4045
|
]
|
|
1306
4046
|
}
|
|
1307
4047
|
),
|
|
1308
|
-
|
|
1309
|
-
/* @__PURE__ */
|
|
4048
|
+
showEditor && editable && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "hep-cr-btn hep-cr-btn-reset", onClick: resetCode, children: "重置" }),
|
|
4049
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1310
4050
|
"button",
|
|
1311
4051
|
{
|
|
1312
4052
|
className: "hep-cr-btn hep-cr-btn-theme",
|
|
1313
|
-
onClick: () =>
|
|
1314
|
-
title:
|
|
1315
|
-
children:
|
|
1316
|
-
/* @__PURE__ */
|
|
1317
|
-
/* @__PURE__ */
|
|
1318
|
-
/* @__PURE__ */
|
|
1319
|
-
/* @__PURE__ */
|
|
1320
|
-
/* @__PURE__ */
|
|
1321
|
-
/* @__PURE__ */
|
|
1322
|
-
/* @__PURE__ */
|
|
1323
|
-
/* @__PURE__ */
|
|
1324
|
-
/* @__PURE__ */
|
|
4053
|
+
onClick: () => setTheme(currentTheme === "light" ? "dark" : "light"),
|
|
4054
|
+
title: currentTheme === "light" ? "Switch to dark mode" : "Switch to light mode",
|
|
4055
|
+
children: currentTheme === "light" ? /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
4056
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "12", cy: "12", r: "5" }),
|
|
4057
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "1", x2: "12", y2: "3" }),
|
|
4058
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "21", x2: "12", y2: "23" }),
|
|
4059
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "4.22", y1: "4.22", x2: "5.64", y2: "5.64" }),
|
|
4060
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "18.36", y1: "18.36", x2: "19.78", y2: "19.78" }),
|
|
4061
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "1", y1: "12", x2: "3", y2: "12" }),
|
|
4062
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "21", y1: "12", x2: "23", y2: "12" }),
|
|
4063
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "4.22", y1: "19.78", x2: "5.64", y2: "18.36" }),
|
|
4064
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "18.36", y1: "5.64", x2: "19.78", y2: "4.22" })
|
|
1325
4065
|
] })
|
|
1326
4066
|
}
|
|
1327
4067
|
)
|
|
1328
4068
|
] })
|
|
1329
4069
|
] }),
|
|
1330
|
-
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
-
|
|
1333
|
-
/* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1335
|
-
/* @__PURE__ */
|
|
1336
|
-
/* @__PURE__ */
|
|
1337
|
-
/* @__PURE__ */
|
|
4070
|
+
error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hep-cr-error-message", children: error }),
|
|
4071
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-main", children: [
|
|
4072
|
+
showEditor && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-editor-panel", style: { width: `${editorWidth}%` }, children: [
|
|
4073
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-panel-header", children: [
|
|
4074
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hep-cr-panel-title", children: "编辑器" }),
|
|
4075
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-output-actions", children: [
|
|
4076
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hep-cr-language-badge", children: languageName }),
|
|
4077
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1338
4078
|
"button",
|
|
1339
4079
|
{
|
|
1340
|
-
className: `hep-cr-btn-icon ${
|
|
1341
|
-
disabled:
|
|
1342
|
-
onClick:
|
|
1343
|
-
title:
|
|
1344
|
-
children:
|
|
4080
|
+
className: `hep-cr-btn-icon ${copiedEditor ? "hep-cr-btn-copied" : ""}`,
|
|
4081
|
+
disabled: copiedEditor,
|
|
4082
|
+
onClick: copyCode,
|
|
4083
|
+
title: copiedEditor ? "已复制" : "复制",
|
|
4084
|
+
children: !copiedEditor ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1345
4085
|
"svg",
|
|
1346
4086
|
{
|
|
1347
4087
|
width: "14",
|
|
@@ -1351,66 +4091,66 @@ const Ce = ({
|
|
|
1351
4091
|
stroke: "currentColor",
|
|
1352
4092
|
strokeWidth: "2",
|
|
1353
4093
|
children: [
|
|
1354
|
-
/* @__PURE__ */
|
|
1355
|
-
/* @__PURE__ */
|
|
4094
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
4095
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
1356
4096
|
]
|
|
1357
4097
|
}
|
|
1358
|
-
)
|
|
4098
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hep-cr-copied-text", children: "已复制" })
|
|
1359
4099
|
}
|
|
1360
4100
|
)
|
|
1361
4101
|
] })
|
|
1362
4102
|
] }),
|
|
1363
|
-
/* @__PURE__ */
|
|
1364
|
-
|
|
4103
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4104
|
+
CodeEditor,
|
|
1365
4105
|
{
|
|
1366
|
-
value:
|
|
1367
|
-
language:
|
|
1368
|
-
theme:
|
|
1369
|
-
disabled: !
|
|
1370
|
-
onChange:
|
|
1371
|
-
onCodeChange:
|
|
4106
|
+
value: code,
|
|
4107
|
+
language: languageName,
|
|
4108
|
+
theme: currentTheme,
|
|
4109
|
+
disabled: !editable || isRunning,
|
|
4110
|
+
onChange: setCode,
|
|
4111
|
+
onCodeChange: onChange
|
|
1372
4112
|
}
|
|
1373
4113
|
)
|
|
1374
4114
|
] }),
|
|
1375
|
-
|
|
1376
|
-
/* @__PURE__ */
|
|
4115
|
+
showEditor && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hep-cr-resize-handle", onMouseDown: startDrag, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hep-cr-resize-line" }) }),
|
|
4116
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1377
4117
|
"div",
|
|
1378
4118
|
{
|
|
1379
4119
|
className: "hep-cr-output-panel",
|
|
1380
|
-
style: { width:
|
|
4120
|
+
style: { width: showEditor ? `${100 - editorWidth}%` : "100%" },
|
|
1381
4121
|
children: [
|
|
1382
|
-
/* @__PURE__ */
|
|
1383
|
-
/* @__PURE__ */
|
|
1384
|
-
/* @__PURE__ */
|
|
4122
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-panel-header", children: [
|
|
4123
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-output-tabs", children: [
|
|
4124
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1385
4125
|
"button",
|
|
1386
4126
|
{
|
|
1387
|
-
className: `hep-cr-tab ${
|
|
1388
|
-
onClick: () =>
|
|
4127
|
+
className: `hep-cr-tab ${activeTab === "stdout" ? "active" : ""}`,
|
|
4128
|
+
onClick: () => setActiveTab("stdout"),
|
|
1389
4129
|
children: "输出"
|
|
1390
4130
|
}
|
|
1391
4131
|
),
|
|
1392
|
-
|
|
4132
|
+
stderr && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1393
4133
|
"button",
|
|
1394
4134
|
{
|
|
1395
|
-
className: `hep-cr-tab hep-cr-tab-error ${
|
|
1396
|
-
onClick: () =>
|
|
4135
|
+
className: `hep-cr-tab hep-cr-tab-error ${activeTab === "stderr" ? "active" : ""}`,
|
|
4136
|
+
onClick: () => setActiveTab("stderr"),
|
|
1397
4137
|
children: "错误"
|
|
1398
4138
|
}
|
|
1399
4139
|
)
|
|
1400
4140
|
] }),
|
|
1401
|
-
/* @__PURE__ */
|
|
1402
|
-
|
|
1403
|
-
|
|
4141
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-output-actions", children: [
|
|
4142
|
+
executionTime !== null && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "hep-cr-execution-time", children: [
|
|
4143
|
+
executionTime,
|
|
1404
4144
|
"ms"
|
|
1405
4145
|
] }),
|
|
1406
|
-
/* @__PURE__ */
|
|
4146
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1407
4147
|
"button",
|
|
1408
4148
|
{
|
|
1409
|
-
className: `hep-cr-btn-icon ${
|
|
1410
|
-
disabled:
|
|
1411
|
-
onClick:
|
|
1412
|
-
title:
|
|
1413
|
-
children:
|
|
4149
|
+
className: `hep-cr-btn-icon ${copiedOutput ? "hep-cr-btn-copied" : ""}`,
|
|
4150
|
+
disabled: copiedOutput,
|
|
4151
|
+
onClick: copyOutput,
|
|
4152
|
+
title: copiedOutput ? "已复制" : "复制",
|
|
4153
|
+
children: !copiedOutput ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1414
4154
|
"svg",
|
|
1415
4155
|
{
|
|
1416
4156
|
width: "14",
|
|
@@ -1420,21 +4160,21 @@ const Ce = ({
|
|
|
1420
4160
|
stroke: "currentColor",
|
|
1421
4161
|
strokeWidth: "2",
|
|
1422
4162
|
children: [
|
|
1423
|
-
/* @__PURE__ */
|
|
1424
|
-
/* @__PURE__ */
|
|
4163
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
4164
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
1425
4165
|
]
|
|
1426
4166
|
}
|
|
1427
|
-
)
|
|
4167
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hep-cr-copied-text", children: "已复制" })
|
|
1428
4168
|
}
|
|
1429
4169
|
)
|
|
1430
4170
|
] })
|
|
1431
4171
|
] }),
|
|
1432
|
-
/* @__PURE__ */
|
|
4172
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hep-cr-output-content", children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { children: activeTab === "stdout" ? isRunning ? "代码执行中..." : output || '点击"运行"执行代码' : stderr }) })
|
|
1433
4173
|
]
|
|
1434
4174
|
}
|
|
1435
4175
|
)
|
|
1436
4176
|
] }),
|
|
1437
|
-
/* @__PURE__ */
|
|
4177
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("style", { children: `
|
|
1438
4178
|
.hep-cr-runner {
|
|
1439
4179
|
display: flex;
|
|
1440
4180
|
flex-direction: column;
|
|
@@ -1664,35 +4404,47 @@ const Ce = ({
|
|
|
1664
4404
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
1665
4405
|
` })
|
|
1666
4406
|
] });
|
|
1667
|
-
}
|
|
4407
|
+
};
|
|
4408
|
+
const CodeRunnerDialog = forwardRef(
|
|
1668
4409
|
({
|
|
1669
|
-
open
|
|
1670
|
-
defaultOpen
|
|
1671
|
-
title
|
|
1672
|
-
width
|
|
1673
|
-
onClose
|
|
1674
|
-
footer
|
|
1675
|
-
theme
|
|
1676
|
-
...
|
|
1677
|
-
},
|
|
1678
|
-
const [
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
4410
|
+
open,
|
|
4411
|
+
defaultOpen = false,
|
|
4412
|
+
title = "代码执行器",
|
|
4413
|
+
width = 800,
|
|
4414
|
+
onClose,
|
|
4415
|
+
footer,
|
|
4416
|
+
theme = "light",
|
|
4417
|
+
...codeRunnerProps
|
|
4418
|
+
}, ref) => {
|
|
4419
|
+
const [localOpen, setLocalOpen] = useState(defaultOpen);
|
|
4420
|
+
const isControlled = open !== void 0;
|
|
4421
|
+
const isVisible = isControlled ? open : localOpen;
|
|
4422
|
+
useEffect(() => {
|
|
4423
|
+
if (isControlled && open !== localOpen) {
|
|
4424
|
+
setLocalOpen(open);
|
|
4425
|
+
}
|
|
4426
|
+
}, [open, isControlled]);
|
|
4427
|
+
const close = useCallback(() => {
|
|
4428
|
+
if (!isControlled) {
|
|
4429
|
+
setLocalOpen(false);
|
|
4430
|
+
}
|
|
4431
|
+
onClose == null ? void 0 : onClose();
|
|
4432
|
+
}, [isControlled, onClose]);
|
|
4433
|
+
const handleOverlayClick = (e) => {
|
|
4434
|
+
if (e.target === e.currentTarget) {
|
|
4435
|
+
close();
|
|
4436
|
+
}
|
|
1686
4437
|
};
|
|
1687
|
-
|
|
1688
|
-
close
|
|
4438
|
+
useImperativeHandle(ref, () => ({
|
|
4439
|
+
close
|
|
1689
4440
|
}));
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
/* @__PURE__ */
|
|
4441
|
+
const dialogWidth = typeof width === "number" ? `${width}px` : width;
|
|
4442
|
+
if (!isVisible) return null;
|
|
4443
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-dialog-overlay", onClick: handleOverlayClick, children: [
|
|
4444
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-dialog-container", style: { width: dialogWidth }, children: [
|
|
4445
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "hep-cr-dialog-header", children: [
|
|
4446
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "hep-cr-dialog-title", children: title }),
|
|
4447
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "hep-cr-dialog-close", onClick: close, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1696
4448
|
"svg",
|
|
1697
4449
|
{
|
|
1698
4450
|
width: "16",
|
|
@@ -1702,16 +4454,16 @@ const Ce = ({
|
|
|
1702
4454
|
stroke: "currentColor",
|
|
1703
4455
|
strokeWidth: "2",
|
|
1704
4456
|
children: [
|
|
1705
|
-
/* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
4457
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
4458
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1707
4459
|
]
|
|
1708
4460
|
}
|
|
1709
4461
|
) })
|
|
1710
4462
|
] }),
|
|
1711
|
-
/* @__PURE__ */
|
|
1712
|
-
|
|
4463
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hep-cr-dialog-body", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CodeRunner, { theme, ...codeRunnerProps }) }),
|
|
4464
|
+
footer && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hep-cr-dialog-footer", children: footer })
|
|
1713
4465
|
] }),
|
|
1714
|
-
/* @__PURE__ */
|
|
4466
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("style", { children: `
|
|
1715
4467
|
.hep-cr-dialog-overlay {
|
|
1716
4468
|
position: fixed;
|
|
1717
4469
|
top: 0;
|
|
@@ -1800,12 +4552,12 @@ const Ce = ({
|
|
|
1800
4552
|
to { transform: scale(1); }
|
|
1801
4553
|
}
|
|
1802
4554
|
` })
|
|
1803
|
-
] })
|
|
4555
|
+
] });
|
|
1804
4556
|
}
|
|
1805
4557
|
);
|
|
1806
|
-
|
|
4558
|
+
CodeRunnerDialog.displayName = "CodeRunnerDialog";
|
|
1807
4559
|
export {
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
4560
|
+
CodeRunner,
|
|
4561
|
+
CodeRunnerDialog,
|
|
4562
|
+
CodeRunner as default
|
|
1811
4563
|
};
|