ai-error-assistant-pro 0.0.6 → 0.0.8
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/components/demo/api/index.js +27 -4
- package/components/demo/src/chat-tools.vue +5 -1
- package/components/demo/src/chat.vue +131 -33
- package/components/demo/src/error-chat.vue +18 -4
- package/components/demo/src/main.vue +58 -25
- package/components/demo/utils/config.js +15 -11
- package/components/demo/utils/request.js +9 -7
- package/dist/ai-error-assistant-pro.common.js +3127 -401
- package/dist/ai-error-assistant-pro.common.js.map +1 -1
- package/dist/ai-error-assistant-pro.css +1 -1
- package/dist/ai-error-assistant-pro.umd.js +3127 -401
- package/dist/ai-error-assistant-pro.umd.js.map +1 -1
- package/dist/ai-error-assistant-pro.umd.min.js +4 -4
- package/dist/ai-error-assistant-pro.umd.min.js.map +1 -1
- package/package.json +8 -5
|
@@ -6564,7 +6564,7 @@ if (typeof window !== 'undefined') {
|
|
|
6564
6564
|
// Indicate to webpack that this file can be concatenated
|
|
6565
6565
|
/* harmony default export */ var setPublicPath = (null);
|
|
6566
6566
|
|
|
6567
|
-
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=template&id=
|
|
6567
|
+
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=template&id=4661f078&scoped=true
|
|
6568
6568
|
var render = function render() {
|
|
6569
6569
|
var _vm = this,
|
|
6570
6570
|
_c = _vm._self._c;
|
|
@@ -6581,7 +6581,11 @@ var render = function render() {
|
|
|
6581
6581
|
}
|
|
6582
6582
|
}, [_c('i', {
|
|
6583
6583
|
staticClass: "el-icon-close"
|
|
6584
|
-
})])]), _c('div', {
|
|
6584
|
+
})])]), !_vm.courseFlag ? _c('div', {
|
|
6585
|
+
staticClass: "message-wrap"
|
|
6586
|
+
}, [_c('div', {
|
|
6587
|
+
staticClass: "message-line"
|
|
6588
|
+
}, [_vm._v(_vm._s(_vm.message))])]) : [_c('div', {
|
|
6585
6589
|
staticClass: "ai-main-content"
|
|
6586
6590
|
}, [_c('chat', {
|
|
6587
6591
|
ref: "chatRef",
|
|
@@ -6636,9 +6640,7 @@ var render = function render() {
|
|
|
6636
6640
|
"src": __webpack_require__(951),
|
|
6637
6641
|
"alt": ""
|
|
6638
6642
|
}
|
|
6639
|
-
})])], 1),
|
|
6640
|
-
staticClass: "disclaimer"
|
|
6641
|
-
}, [_vm._v(" 此功能公测期间对正式版用户开放 ")])]) : _vm._e();
|
|
6643
|
+
})])], 1)]], 2) : _vm._e();
|
|
6642
6644
|
};
|
|
6643
6645
|
var staticRenderFns = [function () {
|
|
6644
6646
|
var _vm = this,
|
|
@@ -6659,10 +6661,10 @@ var staticRenderFns = [function () {
|
|
|
6659
6661
|
}, [_vm._v("智能解析")])]);
|
|
6660
6662
|
}];
|
|
6661
6663
|
|
|
6662
|
-
;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=template&id=
|
|
6664
|
+
;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=template&id=4661f078&scoped=true
|
|
6663
6665
|
|
|
6664
|
-
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=template&id=
|
|
6665
|
-
var
|
|
6666
|
+
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=template&id=d21026be&scoped=true
|
|
6667
|
+
var chatvue_type_template_id_d21026be_scoped_true_render = function render() {
|
|
6666
6668
|
var _vm = this,
|
|
6667
6669
|
_c = _vm._self._c;
|
|
6668
6670
|
return _c('div', {
|
|
@@ -6699,9 +6701,9 @@ var chatvue_type_template_id_8e426b78_scoped_true_render = function render() {
|
|
|
6699
6701
|
}
|
|
6700
6702
|
}), list.type === 'robot' && list.links.length > 0 ? _c('div', {
|
|
6701
6703
|
staticClass: "link"
|
|
6702
|
-
}, [_c('div', {
|
|
6704
|
+
}, [!list.allIdWithStart ? _c('div', [_c('div', {
|
|
6703
6705
|
staticClass: "link-title"
|
|
6704
|
-
}, [_vm._v("
|
|
6706
|
+
}, [_vm._v("参考文件")]), _c('div', {
|
|
6705
6707
|
staticClass: "link-content"
|
|
6706
6708
|
}, [_vm._l(list.links, function (item) {
|
|
6707
6709
|
return [!item.title.startsWith(_vm.chatMajorId) ? _c('div', {
|
|
@@ -6712,11 +6714,43 @@ var chatvue_type_template_id_8e426b78_scoped_true_render = function render() {
|
|
|
6712
6714
|
"target": "_blank"
|
|
6713
6715
|
}
|
|
6714
6716
|
}, [_c('span', [_vm._v(_vm._s(item.title))])])]) : _vm._e()];
|
|
6715
|
-
})], 2)]) : _vm._e(), list.type === 'robot' ? _c('
|
|
6717
|
+
})], 2)]) : _vm._e()]) : _vm._e(), list.type === 'robot' && list.connectUrl.length > 0 ? _c('div', {
|
|
6718
|
+
staticClass: "link"
|
|
6719
|
+
}, [_c('div', {
|
|
6720
|
+
staticClass: "link-title"
|
|
6721
|
+
}, [_vm._v("相关链接")]), _c('div', {
|
|
6722
|
+
staticClass: "link-content"
|
|
6723
|
+
}, [_vm._l(list.connectUrl, function (item) {
|
|
6724
|
+
return [_c('div', {
|
|
6725
|
+
staticClass: "links"
|
|
6726
|
+
}, [_c('a', {
|
|
6727
|
+
attrs: {
|
|
6728
|
+
"href": item.iaUrl,
|
|
6729
|
+
"target": "_blank"
|
|
6730
|
+
}
|
|
6731
|
+
}, [_c('span', [_vm._v(_vm._s(item.iaUrlName))])])])];
|
|
6732
|
+
})], 2)]) : _vm._e(), list.type === 'robot' && _vm.finish && list.followUps && list.followUps.length > 0 ? _c('div', [_c('div', {
|
|
6733
|
+
staticClass: "link-title"
|
|
6734
|
+
}, [_vm._v("智能追问")]), _c('div', {
|
|
6735
|
+
staticClass: "link-content"
|
|
6736
|
+
}, _vm._l(list.followUps, function (list, index) {
|
|
6737
|
+
return _c('div', {
|
|
6738
|
+
key: index,
|
|
6739
|
+
staticClass: "hot-list",
|
|
6740
|
+
on: {
|
|
6741
|
+
"click": function ($event) {
|
|
6742
|
+
return _vm.selectModule(list);
|
|
6743
|
+
}
|
|
6744
|
+
}
|
|
6745
|
+
}, [_vm._v(" " + _vm._s(list) + " "), _c('i', {
|
|
6746
|
+
staticClass: "el-icon-arrow-right go-icon"
|
|
6747
|
+
})]);
|
|
6748
|
+
}), 0)]) : _vm._e(), list.type === 'robot' ? _c('chat-tools', {
|
|
6716
6749
|
attrs: {
|
|
6717
6750
|
"chatId": _vm.chatId,
|
|
6718
6751
|
"detail-data": list,
|
|
6719
|
-
"sending": list.sending
|
|
6752
|
+
"sending": list.sending,
|
|
6753
|
+
"is-last": index === _vm.messageData.length - 1
|
|
6720
6754
|
},
|
|
6721
6755
|
on: {
|
|
6722
6756
|
"on-reanswer": list => _vm.reanswer(list, index),
|
|
@@ -6725,7 +6759,7 @@ var chatvue_type_template_id_8e426b78_scoped_true_render = function render() {
|
|
|
6725
6759
|
}) : _vm._e()], 1)]);
|
|
6726
6760
|
})], 2);
|
|
6727
6761
|
};
|
|
6728
|
-
var
|
|
6762
|
+
var chatvue_type_template_id_d21026be_scoped_true_staticRenderFns = [];
|
|
6729
6763
|
|
|
6730
6764
|
;// CONCATENATED MODULE: ./node_modules/axios/lib/helpers/bind.js
|
|
6731
6765
|
|
|
@@ -6966,9 +7000,10 @@ const trim = str => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uF
|
|
|
6966
7000
|
* @param {Boolean} [allOwnKeys = false]
|
|
6967
7001
|
* @returns {any}
|
|
6968
7002
|
*/
|
|
6969
|
-
function forEach(obj, fn
|
|
6970
|
-
|
|
6971
|
-
|
|
7003
|
+
function forEach(obj, fn) {
|
|
7004
|
+
let {
|
|
7005
|
+
allOwnKeys = false
|
|
7006
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
6972
7007
|
// Don't bother if no value provided
|
|
6973
7008
|
if (obj === null || typeof obj === 'undefined') {
|
|
6974
7009
|
return;
|
|
@@ -7069,9 +7104,10 @@ function merge( /* obj1, obj2, obj3, ... */
|
|
|
7069
7104
|
* @param {Boolean} [allOwnKeys]
|
|
7070
7105
|
* @returns {Object} The resulting value of object a
|
|
7071
7106
|
*/
|
|
7072
|
-
const extend = (a, b, thisArg
|
|
7073
|
-
|
|
7074
|
-
|
|
7107
|
+
const extend = function (a, b, thisArg) {
|
|
7108
|
+
let {
|
|
7109
|
+
allOwnKeys
|
|
7110
|
+
} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
7075
7111
|
forEach(b, (val, key) => {
|
|
7076
7112
|
if (thisArg && isFunction(val)) {
|
|
7077
7113
|
a[key] = bind(val, thisArg);
|
|
@@ -7246,9 +7282,12 @@ const toCamelCase = str => {
|
|
|
7246
7282
|
};
|
|
7247
7283
|
|
|
7248
7284
|
/* Creating a function that will check if an object has a property. */
|
|
7249
|
-
const utils_hasOwnProperty = (
|
|
7250
|
-
|
|
7251
|
-
|
|
7285
|
+
const utils_hasOwnProperty = (_ref => {
|
|
7286
|
+
let {
|
|
7287
|
+
hasOwnProperty
|
|
7288
|
+
} = _ref;
|
|
7289
|
+
return (obj, prop) => hasOwnProperty.call(obj, prop);
|
|
7290
|
+
})(Object.prototype);
|
|
7252
7291
|
|
|
7253
7292
|
/**
|
|
7254
7293
|
* Determine if a value is a RegExp object
|
|
@@ -7316,7 +7355,9 @@ const ALPHABET = {
|
|
|
7316
7355
|
ALPHA,
|
|
7317
7356
|
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
|
7318
7357
|
};
|
|
7319
|
-
const generateString = (
|
|
7358
|
+
const generateString = function () {
|
|
7359
|
+
let size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
|
7360
|
+
let alphabet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ALPHABET.ALPHA_DIGIT;
|
|
7320
7361
|
let str = '';
|
|
7321
7362
|
const {
|
|
7322
7363
|
length
|
|
@@ -7370,10 +7411,11 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
7370
7411
|
return setImmediate;
|
|
7371
7412
|
}
|
|
7372
7413
|
return postMessageSupported ? ((token, callbacks) => {
|
|
7373
|
-
_global.addEventListener("message",
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7414
|
+
_global.addEventListener("message", _ref2 => {
|
|
7415
|
+
let {
|
|
7416
|
+
source,
|
|
7417
|
+
data
|
|
7418
|
+
} = _ref2;
|
|
7377
7419
|
if (source === _global && data === token) {
|
|
7378
7420
|
callbacks.length && callbacks.shift()();
|
|
7379
7421
|
}
|
|
@@ -8413,7 +8455,10 @@ class AxiosHeaders {
|
|
|
8413
8455
|
});
|
|
8414
8456
|
return this;
|
|
8415
8457
|
}
|
|
8416
|
-
concat(
|
|
8458
|
+
concat() {
|
|
8459
|
+
for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8460
|
+
targets[_key] = arguments[_key];
|
|
8461
|
+
}
|
|
8417
8462
|
return this.constructor.concat(this, ...targets);
|
|
8418
8463
|
}
|
|
8419
8464
|
toJSON(asStrings) {
|
|
@@ -8427,7 +8472,10 @@ class AxiosHeaders {
|
|
|
8427
8472
|
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
8428
8473
|
}
|
|
8429
8474
|
toString() {
|
|
8430
|
-
return Object.entries(this.toJSON()).map(
|
|
8475
|
+
return Object.entries(this.toJSON()).map(_ref => {
|
|
8476
|
+
let [header, value] = _ref;
|
|
8477
|
+
return header + ': ' + value;
|
|
8478
|
+
}).join('\n');
|
|
8431
8479
|
}
|
|
8432
8480
|
get [Symbol.toStringTag]() {
|
|
8433
8481
|
return 'AxiosHeaders';
|
|
@@ -8435,8 +8483,11 @@ class AxiosHeaders {
|
|
|
8435
8483
|
static from(thing) {
|
|
8436
8484
|
return thing instanceof this ? thing : new this(thing);
|
|
8437
8485
|
}
|
|
8438
|
-
static concat(first
|
|
8486
|
+
static concat(first) {
|
|
8439
8487
|
const computed = new this(first);
|
|
8488
|
+
for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
8489
|
+
targets[_key2 - 1] = arguments[_key2];
|
|
8490
|
+
}
|
|
8440
8491
|
targets.forEach(target => computed.set(target));
|
|
8441
8492
|
return computed;
|
|
8442
8493
|
}
|
|
@@ -8460,9 +8511,10 @@ class AxiosHeaders {
|
|
|
8460
8511
|
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
8461
8512
|
|
|
8462
8513
|
// reserved names hotfix
|
|
8463
|
-
utils.reduceDescriptors(AxiosHeaders.prototype, ({
|
|
8464
|
-
|
|
8465
|
-
|
|
8514
|
+
utils.reduceDescriptors(AxiosHeaders.prototype, (_ref2, key) => {
|
|
8515
|
+
let {
|
|
8516
|
+
value
|
|
8517
|
+
} = _ref2;
|
|
8466
8518
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
8467
8519
|
return {
|
|
8468
8520
|
get: () => value,
|
|
@@ -8613,7 +8665,8 @@ function throttle(fn, freq) {
|
|
|
8613
8665
|
let threshold = 1000 / freq;
|
|
8614
8666
|
let lastArgs;
|
|
8615
8667
|
let timer;
|
|
8616
|
-
const invoke = (args
|
|
8668
|
+
const invoke = function (args) {
|
|
8669
|
+
let now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
|
|
8617
8670
|
timestamp = now;
|
|
8618
8671
|
lastArgs = null;
|
|
8619
8672
|
if (timer) {
|
|
@@ -8622,9 +8675,12 @@ function throttle(fn, freq) {
|
|
|
8622
8675
|
}
|
|
8623
8676
|
fn.apply(null, args);
|
|
8624
8677
|
};
|
|
8625
|
-
const throttled = (
|
|
8678
|
+
const throttled = function () {
|
|
8626
8679
|
const now = Date.now();
|
|
8627
8680
|
const passed = now - timestamp;
|
|
8681
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8682
|
+
args[_key] = arguments[_key];
|
|
8683
|
+
}
|
|
8628
8684
|
if (passed >= threshold) {
|
|
8629
8685
|
invoke(args, now);
|
|
8630
8686
|
} else {
|
|
@@ -8645,7 +8701,8 @@ function throttle(fn, freq) {
|
|
|
8645
8701
|
|
|
8646
8702
|
|
|
8647
8703
|
|
|
8648
|
-
const progressEventReducer = (listener, isDownloadStream
|
|
8704
|
+
const progressEventReducer = function (listener, isDownloadStream) {
|
|
8705
|
+
let freq = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
|
|
8649
8706
|
let bytesNotified = 0;
|
|
8650
8707
|
const _speedometer = helpers_speedometer(50, 250);
|
|
8651
8708
|
return helpers_throttle(e => {
|
|
@@ -8677,7 +8734,12 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
8677
8734
|
loaded
|
|
8678
8735
|
}), throttled[1]];
|
|
8679
8736
|
};
|
|
8680
|
-
const asyncDecorator = fn =>
|
|
8737
|
+
const asyncDecorator = fn => function () {
|
|
8738
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8739
|
+
args[_key] = arguments[_key];
|
|
8740
|
+
}
|
|
8741
|
+
return utils.asap(() => fn(...args));
|
|
8742
|
+
};
|
|
8681
8743
|
;// CONCATENATED MODULE: ./node_modules/axios/lib/helpers/isURLSameOrigin.js
|
|
8682
8744
|
|
|
8683
8745
|
|
|
@@ -9270,8 +9332,11 @@ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream ===
|
|
|
9270
9332
|
|
|
9271
9333
|
// used only inside the fetch adapter
|
|
9272
9334
|
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? (encoder => str => encoder.encode(str))(new TextEncoder()) : async str => new Uint8Array(await new Response(str).arrayBuffer()));
|
|
9273
|
-
const test = (fn
|
|
9335
|
+
const test = function (fn) {
|
|
9274
9336
|
try {
|
|
9337
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
9338
|
+
args[_key - 1] = arguments[_key];
|
|
9339
|
+
}
|
|
9275
9340
|
return !!fn(...args);
|
|
9276
9341
|
} catch (e) {
|
|
9277
9342
|
return false;
|
|
@@ -9468,7 +9533,10 @@ const isResolvedHandle = adapter => utils.isFunction(adapter) || adapter === nul
|
|
|
9468
9533
|
rejectedReasons[id || '#' + i] = adapter;
|
|
9469
9534
|
}
|
|
9470
9535
|
if (!adapter) {
|
|
9471
|
-
const reasons = Object.entries(rejectedReasons).map(
|
|
9536
|
+
const reasons = Object.entries(rejectedReasons).map(_ref => {
|
|
9537
|
+
let [id, state] = _ref;
|
|
9538
|
+
return `adapter ${id} ` + (state === false ? 'is not supported by the environment' : 'is not available in the build');
|
|
9539
|
+
});
|
|
9472
9540
|
let s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
|
|
9473
9541
|
throw new core_AxiosError(`There is no suitable adapter to dispatch the request ` + s, 'ERR_NOT_SUPPORT');
|
|
9474
9542
|
}
|
|
@@ -10037,7 +10105,8 @@ const HttpStatusCode = {
|
|
|
10037
10105
|
NotExtended: 510,
|
|
10038
10106
|
NetworkAuthenticationRequired: 511
|
|
10039
10107
|
};
|
|
10040
|
-
Object.entries(HttpStatusCode).forEach(
|
|
10108
|
+
Object.entries(HttpStatusCode).forEach(_ref => {
|
|
10109
|
+
let [key, value] = _ref;
|
|
10041
10110
|
HttpStatusCode[value] = key;
|
|
10042
10111
|
});
|
|
10043
10112
|
/* harmony default export */ var helpers_HttpStatusCode = (HttpStatusCode);
|
|
@@ -10232,49 +10301,58 @@ const _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
|
|
|
10232
10301
|
const _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
|
|
10233
10302
|
const b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
10234
10303
|
const b64chs = Array.prototype.slice.call(b64ch);
|
|
10235
|
-
const b64tab = (a => {
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10304
|
+
const b64tab = ((a) => {
|
|
10305
|
+
let tab = {};
|
|
10306
|
+
a.forEach((c, i) => tab[c] = i);
|
|
10307
|
+
return tab;
|
|
10239
10308
|
})(b64chs);
|
|
10240
10309
|
const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
10241
10310
|
const _fromCC = String.fromCharCode.bind(String);
|
|
10242
|
-
const _U8Afrom = typeof Uint8Array.from === 'function'
|
|
10243
|
-
|
|
10244
|
-
|
|
10311
|
+
const _U8Afrom = typeof Uint8Array.from === 'function'
|
|
10312
|
+
? Uint8Array.from.bind(Uint8Array)
|
|
10313
|
+
: (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
|
|
10314
|
+
const _mkUriSafe = (src) => src
|
|
10315
|
+
.replace(/=/g, '').replace(/[+\/]/g, (m0) => m0 == '+' ? '-' : '_');
|
|
10316
|
+
const _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, '');
|
|
10245
10317
|
/**
|
|
10246
10318
|
* polyfill version of `btoa`
|
|
10247
10319
|
*/
|
|
10248
|
-
const btoaPolyfill = bin => {
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10320
|
+
const btoaPolyfill = (bin) => {
|
|
10321
|
+
// console.log('polyfilled');
|
|
10322
|
+
let u32, c0, c1, c2, asc = '';
|
|
10323
|
+
const pad = bin.length % 3;
|
|
10324
|
+
for (let i = 0; i < bin.length;) {
|
|
10325
|
+
if ((c0 = bin.charCodeAt(i++)) > 255 ||
|
|
10326
|
+
(c1 = bin.charCodeAt(i++)) > 255 ||
|
|
10327
|
+
(c2 = bin.charCodeAt(i++)) > 255)
|
|
10328
|
+
throw new TypeError('invalid character found');
|
|
10329
|
+
u32 = (c0 << 16) | (c1 << 8) | c2;
|
|
10330
|
+
asc += b64chs[u32 >> 18 & 63]
|
|
10331
|
+
+ b64chs[u32 >> 12 & 63]
|
|
10332
|
+
+ b64chs[u32 >> 6 & 63]
|
|
10333
|
+
+ b64chs[u32 & 63];
|
|
10334
|
+
}
|
|
10335
|
+
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
|
|
10262
10336
|
};
|
|
10263
10337
|
/**
|
|
10264
10338
|
* does what `window.btoa` of web browsers do.
|
|
10265
10339
|
* @param {String} bin binary string
|
|
10266
10340
|
* @returns {string} Base64-encoded string
|
|
10267
10341
|
*/
|
|
10268
|
-
const _btoa = typeof btoa === 'function' ?
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10342
|
+
const _btoa = typeof btoa === 'function' ? (bin) => btoa(bin)
|
|
10343
|
+
: _hasBuffer ? (bin) => Buffer.from(bin, 'binary').toString('base64')
|
|
10344
|
+
: btoaPolyfill;
|
|
10345
|
+
const _fromUint8Array = _hasBuffer
|
|
10346
|
+
? (u8a) => Buffer.from(u8a).toString('base64')
|
|
10347
|
+
: (u8a) => {
|
|
10348
|
+
// cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
|
|
10349
|
+
const maxargs = 0x1000;
|
|
10350
|
+
let strs = [];
|
|
10351
|
+
for (let i = 0, l = u8a.length; i < l; i += maxargs) {
|
|
10352
|
+
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
|
|
10353
|
+
}
|
|
10354
|
+
return _btoa(strs.join(''));
|
|
10355
|
+
};
|
|
10278
10356
|
/**
|
|
10279
10357
|
* converts a Uint8Array to a Base64 string.
|
|
10280
10358
|
* @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5
|
|
@@ -10284,14 +10362,25 @@ const fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8
|
|
|
10284
10362
|
// This trick is found broken https://github.com/dankogai/js-base64/issues/130
|
|
10285
10363
|
// const utob = (src: string) => unescape(encodeURIComponent(src));
|
|
10286
10364
|
// reverting good old fationed regexp
|
|
10287
|
-
const cb_utob = c => {
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10365
|
+
const cb_utob = (c) => {
|
|
10366
|
+
if (c.length < 2) {
|
|
10367
|
+
var cc = c.charCodeAt(0);
|
|
10368
|
+
return cc < 0x80 ? c
|
|
10369
|
+
: cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6))
|
|
10370
|
+
+ _fromCC(0x80 | (cc & 0x3f)))
|
|
10371
|
+
: (_fromCC(0xe0 | ((cc >>> 12) & 0x0f))
|
|
10372
|
+
+ _fromCC(0x80 | ((cc >>> 6) & 0x3f))
|
|
10373
|
+
+ _fromCC(0x80 | (cc & 0x3f)));
|
|
10374
|
+
}
|
|
10375
|
+
else {
|
|
10376
|
+
var cc = 0x10000
|
|
10377
|
+
+ (c.charCodeAt(0) - 0xD800) * 0x400
|
|
10378
|
+
+ (c.charCodeAt(1) - 0xDC00);
|
|
10379
|
+
return (_fromCC(0xf0 | ((cc >>> 18) & 0x07))
|
|
10380
|
+
+ _fromCC(0x80 | ((cc >>> 12) & 0x3f))
|
|
10381
|
+
+ _fromCC(0x80 | ((cc >>> 6) & 0x3f))
|
|
10382
|
+
+ _fromCC(0x80 | (cc & 0x3f)));
|
|
10383
|
+
}
|
|
10295
10384
|
};
|
|
10296
10385
|
const re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
|
10297
10386
|
/**
|
|
@@ -10299,163 +10388,168 @@ const re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
|
|
10299
10388
|
* @param {string} src UTF-8 string
|
|
10300
10389
|
* @returns {string} UTF-16 string
|
|
10301
10390
|
*/
|
|
10302
|
-
const utob = u => u.replace(re_utob, cb_utob);
|
|
10391
|
+
const utob = (u) => u.replace(re_utob, cb_utob);
|
|
10303
10392
|
//
|
|
10304
|
-
const _encode = _hasBuffer
|
|
10393
|
+
const _encode = _hasBuffer
|
|
10394
|
+
? (s) => Buffer.from(s, 'utf8').toString('base64')
|
|
10395
|
+
: _TE
|
|
10396
|
+
? (s) => _fromUint8Array(_TE.encode(s))
|
|
10397
|
+
: (s) => _btoa(utob(s));
|
|
10305
10398
|
/**
|
|
10306
10399
|
* converts a UTF-8-encoded string to a Base64 string.
|
|
10307
10400
|
* @param {boolean} [urlsafe] if `true` make the result URL-safe
|
|
10308
10401
|
* @returns {string} Base64 string
|
|
10309
10402
|
*/
|
|
10310
|
-
const base64_encode = (src, urlsafe = false) => urlsafe
|
|
10403
|
+
const base64_encode = (src, urlsafe = false) => urlsafe
|
|
10404
|
+
? _mkUriSafe(_encode(src))
|
|
10405
|
+
: _encode(src);
|
|
10311
10406
|
/**
|
|
10312
10407
|
* converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.
|
|
10313
10408
|
* @returns {string} Base64 string
|
|
10314
10409
|
*/
|
|
10315
|
-
const base64_encodeURI = src => base64_encode(src, true);
|
|
10410
|
+
const base64_encodeURI = (src) => base64_encode(src, true);
|
|
10316
10411
|
// This trick is found broken https://github.com/dankogai/js-base64/issues/130
|
|
10317
10412
|
// const btou = (src: string) => decodeURIComponent(escape(src));
|
|
10318
10413
|
// reverting good old fationed regexp
|
|
10319
10414
|
const re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
|
10320
|
-
const cb_btou = cccc => {
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10415
|
+
const cb_btou = (cccc) => {
|
|
10416
|
+
switch (cccc.length) {
|
|
10417
|
+
case 4:
|
|
10418
|
+
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
|
|
10419
|
+
| ((0x3f & cccc.charCodeAt(1)) << 12)
|
|
10420
|
+
| ((0x3f & cccc.charCodeAt(2)) << 6)
|
|
10421
|
+
| (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000;
|
|
10422
|
+
return (_fromCC((offset >>> 10) + 0xD800)
|
|
10423
|
+
+ _fromCC((offset & 0x3FF) + 0xDC00));
|
|
10424
|
+
case 3:
|
|
10425
|
+
return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12)
|
|
10426
|
+
| ((0x3f & cccc.charCodeAt(1)) << 6)
|
|
10427
|
+
| (0x3f & cccc.charCodeAt(2)));
|
|
10428
|
+
default:
|
|
10429
|
+
return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6)
|
|
10430
|
+
| (0x3f & cccc.charCodeAt(1)));
|
|
10431
|
+
}
|
|
10331
10432
|
};
|
|
10332
10433
|
/**
|
|
10333
10434
|
* @deprecated should have been internal use only.
|
|
10334
10435
|
* @param {string} src UTF-16 string
|
|
10335
10436
|
* @returns {string} UTF-8 string
|
|
10336
10437
|
*/
|
|
10337
|
-
const btou = b => b.replace(re_btou, cb_btou);
|
|
10438
|
+
const btou = (b) => b.replace(re_btou, cb_btou);
|
|
10338
10439
|
/**
|
|
10339
10440
|
* polyfill version of `atob`
|
|
10340
10441
|
*/
|
|
10341
|
-
const atobPolyfill = asc => {
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
bin = '',
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10442
|
+
const atobPolyfill = (asc) => {
|
|
10443
|
+
// console.log('polyfilled');
|
|
10444
|
+
asc = asc.replace(/\s+/g, '');
|
|
10445
|
+
if (!b64re.test(asc))
|
|
10446
|
+
throw new TypeError('malformed base64.');
|
|
10447
|
+
asc += '=='.slice(2 - (asc.length & 3));
|
|
10448
|
+
let u24, bin = '', r1, r2;
|
|
10449
|
+
for (let i = 0; i < asc.length;) {
|
|
10450
|
+
u24 = b64tab[asc.charAt(i++)] << 18
|
|
10451
|
+
| b64tab[asc.charAt(i++)] << 12
|
|
10452
|
+
| (r1 = b64tab[asc.charAt(i++)]) << 6
|
|
10453
|
+
| (r2 = b64tab[asc.charAt(i++)]);
|
|
10454
|
+
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255)
|
|
10455
|
+
: r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255)
|
|
10456
|
+
: _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
|
|
10457
|
+
}
|
|
10458
|
+
return bin;
|
|
10355
10459
|
};
|
|
10356
10460
|
/**
|
|
10357
10461
|
* does what `window.atob` of web browsers do.
|
|
10358
10462
|
* @param {String} asc Base64-encoded string
|
|
10359
10463
|
* @returns {string} binary string
|
|
10360
10464
|
*/
|
|
10361
|
-
const _atob = typeof atob === 'function' ? asc => atob(_tidyB64(asc))
|
|
10465
|
+
const _atob = typeof atob === 'function' ? (asc) => atob(_tidyB64(asc))
|
|
10466
|
+
: _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary')
|
|
10467
|
+
: atobPolyfill;
|
|
10362
10468
|
//
|
|
10363
|
-
const _toUint8Array = _hasBuffer
|
|
10469
|
+
const _toUint8Array = _hasBuffer
|
|
10470
|
+
? (a) => _U8Afrom(Buffer.from(a, 'base64'))
|
|
10471
|
+
: (a) => _U8Afrom(_atob(a).split('').map(c => c.charCodeAt(0)));
|
|
10364
10472
|
/**
|
|
10365
10473
|
* converts a Base64 string to a Uint8Array.
|
|
10366
10474
|
*/
|
|
10367
|
-
const toUint8Array = a => _toUint8Array(_unURI(a));
|
|
10475
|
+
const toUint8Array = (a) => _toUint8Array(_unURI(a));
|
|
10368
10476
|
//
|
|
10369
|
-
const _decode = _hasBuffer
|
|
10370
|
-
|
|
10477
|
+
const _decode = _hasBuffer
|
|
10478
|
+
? (a) => Buffer.from(a, 'base64').toString('utf8')
|
|
10479
|
+
: _TD
|
|
10480
|
+
? (a) => _TD.decode(_toUint8Array(a))
|
|
10481
|
+
: (a) => btou(_atob(a));
|
|
10482
|
+
const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == '-' ? '+' : '/'));
|
|
10371
10483
|
/**
|
|
10372
10484
|
* converts a Base64 string to a UTF-8 string.
|
|
10373
10485
|
* @param {String} src Base64 string. Both normal and URL-safe are supported
|
|
10374
10486
|
* @returns {string} UTF-8 string
|
|
10375
10487
|
*/
|
|
10376
|
-
const decode = src => _decode(_unURI(src));
|
|
10488
|
+
const decode = (src) => _decode(_unURI(src));
|
|
10377
10489
|
/**
|
|
10378
10490
|
* check if a value is a valid Base64 string
|
|
10379
10491
|
* @param {String} src a value to check
|
|
10380
10492
|
*/
|
|
10381
|
-
const isValid = src => {
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10493
|
+
const isValid = (src) => {
|
|
10494
|
+
if (typeof src !== 'string')
|
|
10495
|
+
return false;
|
|
10496
|
+
const s = src.replace(/\s+/g, '').replace(/={0,2}$/, '');
|
|
10497
|
+
return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
|
|
10385
10498
|
};
|
|
10386
10499
|
//
|
|
10387
|
-
const _noEnum = v => {
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
writable: true,
|
|
10392
|
-
configurable: true
|
|
10393
|
-
};
|
|
10500
|
+
const _noEnum = (v) => {
|
|
10501
|
+
return {
|
|
10502
|
+
value: v, enumerable: false, writable: true, configurable: true
|
|
10503
|
+
};
|
|
10394
10504
|
};
|
|
10395
10505
|
/**
|
|
10396
10506
|
* extend String.prototype with relevant methods
|
|
10397
10507
|
*/
|
|
10398
10508
|
const extendString = function () {
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
return
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
return
|
|
10405
|
-
});
|
|
10406
|
-
_add('toBase64URI', function () {
|
|
10407
|
-
return base64_encode(this, true);
|
|
10408
|
-
});
|
|
10409
|
-
_add('toBase64URL', function () {
|
|
10410
|
-
return base64_encode(this, true);
|
|
10411
|
-
});
|
|
10412
|
-
_add('toUint8Array', function () {
|
|
10413
|
-
return toUint8Array(this);
|
|
10414
|
-
});
|
|
10509
|
+
const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
|
|
10510
|
+
_add('fromBase64', function () { return decode(this); });
|
|
10511
|
+
_add('toBase64', function (urlsafe) { return base64_encode(this, urlsafe); });
|
|
10512
|
+
_add('toBase64URI', function () { return base64_encode(this, true); });
|
|
10513
|
+
_add('toBase64URL', function () { return base64_encode(this, true); });
|
|
10514
|
+
_add('toUint8Array', function () { return toUint8Array(this); });
|
|
10415
10515
|
};
|
|
10416
10516
|
/**
|
|
10417
10517
|
* extend Uint8Array.prototype with relevant methods
|
|
10418
10518
|
*/
|
|
10419
10519
|
const extendUint8Array = function () {
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
return fromUint8Array(this,
|
|
10423
|
-
|
|
10424
|
-
_add('toBase64URI', function () {
|
|
10425
|
-
return fromUint8Array(this, true);
|
|
10426
|
-
});
|
|
10427
|
-
_add('toBase64URL', function () {
|
|
10428
|
-
return fromUint8Array(this, true);
|
|
10429
|
-
});
|
|
10520
|
+
const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
|
|
10521
|
+
_add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); });
|
|
10522
|
+
_add('toBase64URI', function () { return fromUint8Array(this, true); });
|
|
10523
|
+
_add('toBase64URL', function () { return fromUint8Array(this, true); });
|
|
10430
10524
|
};
|
|
10431
10525
|
/**
|
|
10432
10526
|
* extend Builtin prototypes with relevant methods
|
|
10433
10527
|
*/
|
|
10434
10528
|
const extendBuiltins = () => {
|
|
10435
|
-
|
|
10436
|
-
|
|
10529
|
+
extendString();
|
|
10530
|
+
extendUint8Array();
|
|
10437
10531
|
};
|
|
10438
10532
|
const gBase64 = {
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10533
|
+
version: version,
|
|
10534
|
+
VERSION: base64_VERSION,
|
|
10535
|
+
atob: _atob,
|
|
10536
|
+
atobPolyfill: atobPolyfill,
|
|
10537
|
+
btoa: _btoa,
|
|
10538
|
+
btoaPolyfill: btoaPolyfill,
|
|
10539
|
+
fromBase64: decode,
|
|
10540
|
+
toBase64: base64_encode,
|
|
10541
|
+
encode: base64_encode,
|
|
10542
|
+
encodeURI: base64_encodeURI,
|
|
10543
|
+
encodeURL: base64_encodeURI,
|
|
10544
|
+
utob: utob,
|
|
10545
|
+
btou: btou,
|
|
10546
|
+
decode: decode,
|
|
10547
|
+
isValid: isValid,
|
|
10548
|
+
fromUint8Array: fromUint8Array,
|
|
10549
|
+
toUint8Array: toUint8Array,
|
|
10550
|
+
extendString: extendString,
|
|
10551
|
+
extendUint8Array: extendUint8Array,
|
|
10552
|
+
extendBuiltins: extendBuiltins
|
|
10459
10553
|
};
|
|
10460
10554
|
// makecjs:CUT //
|
|
10461
10555
|
|
|
@@ -10480,6 +10574,7 @@ const gBase64 = {
|
|
|
10480
10574
|
|
|
10481
10575
|
// and finally,
|
|
10482
10576
|
|
|
10577
|
+
|
|
10483
10578
|
;// CONCATENATED MODULE: ./components/demo/utils/aes-utils.js
|
|
10484
10579
|
|
|
10485
10580
|
|
|
@@ -10500,17 +10595,17 @@ const iv = crypto_js_default().enc.Utf8.parse(n);
|
|
|
10500
10595
|
// 解密方法
|
|
10501
10596
|
function decrypt(word) {
|
|
10502
10597
|
const stringToEncode = 'Hello, World!'; // 要进行 Base64 编码的字符串
|
|
10503
|
-
const encodedString =
|
|
10504
|
-
const decodedString =
|
|
10598
|
+
const encodedString = Base64.encode(stringToEncode); // 进行 Base64 编码
|
|
10599
|
+
const decodedString = Base64.decode(encodedString); // 进行 Base64 解码
|
|
10505
10600
|
|
|
10506
|
-
let base64 =
|
|
10507
|
-
let src =
|
|
10508
|
-
let decrypt =
|
|
10601
|
+
let base64 = CryptoJS.enc.Base64.parse(word);
|
|
10602
|
+
let src = CryptoJS.enc.Base64.stringify(base64);
|
|
10603
|
+
let decrypt = CryptoJS.AES.decrypt(src, key, {
|
|
10509
10604
|
iv: iv,
|
|
10510
|
-
mode:
|
|
10511
|
-
padding:
|
|
10605
|
+
mode: CryptoJS.mode.CBC,
|
|
10606
|
+
padding: CryptoJS.pad.Pkcs7
|
|
10512
10607
|
});
|
|
10513
|
-
let decryptedStr = decrypt.toString(
|
|
10608
|
+
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
|
|
10514
10609
|
return decryptedStr.toString();
|
|
10515
10610
|
}
|
|
10516
10611
|
;// CONCATENATED MODULE: ./components/demo/utils/constants.js
|
|
@@ -10544,7 +10639,9 @@ const service = lib_axios.create({
|
|
|
10544
10639
|
});
|
|
10545
10640
|
service.interceptors.request.use(config => {
|
|
10546
10641
|
if (cache.session.getJSON('SRKJ_TOKEN_CACHE')) {
|
|
10547
|
-
config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
10642
|
+
// config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
10643
|
+
if (!config.params) config.params = {};
|
|
10644
|
+
config.params.token = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
10548
10645
|
}
|
|
10549
10646
|
// 是否需要防止数据重复提交
|
|
10550
10647
|
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
|
|
@@ -10577,12 +10674,12 @@ service.interceptors.response.use(res => {
|
|
|
10577
10674
|
return res.data;
|
|
10578
10675
|
}
|
|
10579
10676
|
let srkjData = res.data;
|
|
10580
|
-
if (srkjData) {
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
}
|
|
10677
|
+
// if (srkjData) {
|
|
10678
|
+
// const respData = decrypt(srkjData);
|
|
10679
|
+
// try {
|
|
10680
|
+
// srkjData = JSON.parse(respData);
|
|
10681
|
+
// } catch (e) {}
|
|
10682
|
+
// }
|
|
10586
10683
|
if (res.status === 401) {
|
|
10587
10684
|
external_element_ui_.Message.warning(srkjData.message.description);
|
|
10588
10685
|
return;
|
|
@@ -10592,7 +10689,7 @@ service.interceptors.response.use(res => {
|
|
|
10592
10689
|
}
|
|
10593
10690
|
return srkjData.queryData || srkjData.data || srkjData.token;
|
|
10594
10691
|
});
|
|
10595
|
-
/* harmony default export */ var
|
|
10692
|
+
/* harmony default export */ var utils_request = (service);
|
|
10596
10693
|
;// CONCATENATED MODULE: ./node_modules/@microsoft/fetch-event-source/lib/esm/parse.js
|
|
10597
10694
|
async function getBytes(stream, onChunk) {
|
|
10598
10695
|
const reader = stream.getReader();
|
|
@@ -10798,11 +10895,14 @@ function defaultOnOpen(response) {
|
|
|
10798
10895
|
|
|
10799
10896
|
|
|
10800
10897
|
|
|
10898
|
+
|
|
10801
10899
|
const baseURL = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_BASE_URL') || constants.publicPath;
|
|
10802
|
-
|
|
10900
|
+
let prefix = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_PRE_FIX') || constants.publicPrefix;
|
|
10803
10901
|
|
|
10902
|
+
// 0.0.7 版本接口升级
|
|
10903
|
+
prefix += '/plugin/v2';
|
|
10804
10904
|
const ssoAuth = token => {
|
|
10805
|
-
return
|
|
10905
|
+
return utils_request({
|
|
10806
10906
|
url: prefix + '/sso/assistant',
|
|
10807
10907
|
method: 'get',
|
|
10808
10908
|
params: {
|
|
@@ -10818,14 +10918,14 @@ const authUser = headers => {
|
|
|
10818
10918
|
});
|
|
10819
10919
|
};
|
|
10820
10920
|
const erranalysis = data => {
|
|
10821
|
-
return
|
|
10921
|
+
return utils_request({
|
|
10822
10922
|
url: prefix + '/erranalysis/send',
|
|
10823
10923
|
method: 'post',
|
|
10824
10924
|
data
|
|
10825
10925
|
});
|
|
10826
10926
|
};
|
|
10827
10927
|
const retryAnalysis = errId => {
|
|
10828
|
-
return
|
|
10928
|
+
return utils_request({
|
|
10829
10929
|
url: prefix + '/erranalysis/retry',
|
|
10830
10930
|
method: 'post',
|
|
10831
10931
|
params: {
|
|
@@ -10834,39 +10934,58 @@ const retryAnalysis = errId => {
|
|
|
10834
10934
|
});
|
|
10835
10935
|
};
|
|
10836
10936
|
const chatEvaluateAdd = params => {
|
|
10837
|
-
return
|
|
10937
|
+
return utils_request({
|
|
10838
10938
|
url: prefix + `/assistant/chatEvaluateAdd`,
|
|
10839
10939
|
method: 'post',
|
|
10840
10940
|
data: params
|
|
10841
10941
|
});
|
|
10842
10942
|
};
|
|
10843
10943
|
const stopChat = chatId => {
|
|
10844
|
-
return
|
|
10944
|
+
return utils_request({
|
|
10845
10945
|
url: prefix + `/assistant/stop/${chatId}`,
|
|
10846
10946
|
method: 'post'
|
|
10847
10947
|
});
|
|
10848
10948
|
};
|
|
10849
10949
|
const chatEvaluateCancel = params => {
|
|
10850
|
-
return
|
|
10950
|
+
return utils_request({
|
|
10851
10951
|
url: prefix + `/assistant/chatEvaluateCancel`,
|
|
10852
10952
|
method: 'post',
|
|
10853
10953
|
data: params
|
|
10854
10954
|
});
|
|
10855
10955
|
};
|
|
10856
10956
|
const chartClear = chatId => {
|
|
10857
|
-
return
|
|
10957
|
+
return utils_request({
|
|
10858
10958
|
url: prefix + `/assistant/chartClear/${chatId}`,
|
|
10859
10959
|
method: 'post'
|
|
10860
10960
|
});
|
|
10861
10961
|
};
|
|
10962
|
+
const checkCourseIdIsExist = resId => {
|
|
10963
|
+
return utils_request({
|
|
10964
|
+
url: prefix + `/ia/hasPermission?courseId=${resId}`,
|
|
10965
|
+
method: 'get'
|
|
10966
|
+
});
|
|
10967
|
+
};
|
|
10968
|
+
|
|
10969
|
+
/**
|
|
10970
|
+
* 自动追问
|
|
10971
|
+
* @param iaId 请求参数id
|
|
10972
|
+
* @param message 对话对
|
|
10973
|
+
* @returns 返回节点详情数据
|
|
10974
|
+
*/
|
|
10975
|
+
async function getAutoQuestioning(iaId, message) {
|
|
10976
|
+
return utils_request.post(`${prefix}/ia/autoFollowUp`, {
|
|
10977
|
+
iaId,
|
|
10978
|
+
messages: message
|
|
10979
|
+
});
|
|
10980
|
+
}
|
|
10862
10981
|
async function sendMessageEventSource(params, signal, onmessage) {
|
|
10863
|
-
return fetchEventSource(`${baseURL}${prefix}/assistant/conversation`, {
|
|
10982
|
+
return fetchEventSource(`${baseURL}${prefix}/assistant/conversation?token=${cache.session.getJSON('SRKJ_TOKEN_CACHE')}`, {
|
|
10864
10983
|
method: 'POST',
|
|
10865
10984
|
signal: signal,
|
|
10866
10985
|
openWhenHidden: true,
|
|
10867
10986
|
headers: {
|
|
10868
|
-
'Content-Type': 'application/json'
|
|
10869
|
-
'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE')
|
|
10987
|
+
'Content-Type': 'application/json'
|
|
10988
|
+
// 'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE'),
|
|
10870
10989
|
},
|
|
10871
10990
|
body: JSON.stringify(params),
|
|
10872
10991
|
onmessage
|
|
@@ -10874,7 +10993,7 @@ async function sendMessageEventSource(params, signal, onmessage) {
|
|
|
10874
10993
|
}
|
|
10875
10994
|
;// CONCATENATED MODULE: ./components/demo/utils/config.js
|
|
10876
10995
|
|
|
10877
|
-
|
|
10996
|
+
// import constants from '../utils/constants';
|
|
10878
10997
|
|
|
10879
10998
|
const errorList = [{
|
|
10880
10999
|
name: "格式问题",
|
|
@@ -10934,25 +11053,29 @@ const cacheMessageList = [{
|
|
|
10934
11053
|
// studentAnswer: '错误的简答题简答题错误错误的简答题简答题错误错误的简答题简答题错误错误的简答题简答题错误',
|
|
10935
11054
|
// }
|
|
10936
11055
|
|
|
11056
|
+
// export const getUserInfo = async (token) => {
|
|
11057
|
+
// const ssoRes = await ssoAuth(token);
|
|
11058
|
+
// const userRes = await authUser({
|
|
11059
|
+
// 'X-Auth-User': encodeURIComponent(ssoRes.name),
|
|
11060
|
+
// 'X-Auth-Token': ssoRes.password,
|
|
11061
|
+
// 'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
|
|
11062
|
+
// 'X-App-Id': `${constants['X-App-Id']}`,
|
|
11063
|
+
// 'X-App-Secret': `${constants['X-App-Secret']}`,
|
|
11064
|
+
// 'X-Auth-User-Type': '1',
|
|
11065
|
+
// });
|
|
11066
|
+
// cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
|
|
11067
|
+
// }
|
|
10937
11068
|
const getUserInfo = async token => {
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
'X-Auth-User': encodeURIComponent(ssoRes.name),
|
|
10941
|
-
'X-Auth-Token': ssoRes.password,
|
|
10942
|
-
'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
|
|
10943
|
-
'X-App-Id': `${constants['X-App-Id']}`,
|
|
10944
|
-
'X-App-Secret': `${constants['X-App-Secret']}`,
|
|
10945
|
-
'X-Auth-User-Type': '1'
|
|
10946
|
-
});
|
|
10947
|
-
cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
|
|
11069
|
+
await ssoAuth(token);
|
|
11070
|
+
cache.session.setJSON('SRKJ_TOKEN_CACHE', token);
|
|
10948
11071
|
};
|
|
10949
|
-
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=template&id=
|
|
10950
|
-
var
|
|
11072
|
+
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=template&id=a40a67cc&scoped=true
|
|
11073
|
+
var chat_toolsvue_type_template_id_a40a67cc_scoped_true_render = function render() {
|
|
10951
11074
|
var _vm = this,
|
|
10952
11075
|
_c = _vm._self._c;
|
|
10953
11076
|
return _vm.listData ? _c('div', {
|
|
10954
11077
|
staticClass: "robot-tools"
|
|
10955
|
-
}, [_vm.listData.stop || _vm.listData.finish || _vm.type === 'error' && !_vm.sending ? _c('div', {
|
|
11078
|
+
}, [(_vm.listData.stop || _vm.listData.finish || _vm.type === 'error' && !_vm.sending) && _vm.isLast ? _c('div', {
|
|
10956
11079
|
staticClass: "robot-reanswer",
|
|
10957
11080
|
staticStyle: {
|
|
10958
11081
|
"margin-bottom": "8px"
|
|
@@ -11109,9 +11232,9 @@ var chat_toolsvue_type_template_id_65c1d3ae_scoped_true_render = function render
|
|
|
11109
11232
|
}
|
|
11110
11233
|
}, [_vm._v("提交")])], 1)], 1)])])], 1)]) : _vm._e();
|
|
11111
11234
|
};
|
|
11112
|
-
var
|
|
11235
|
+
var chat_toolsvue_type_template_id_a40a67cc_scoped_true_staticRenderFns = [];
|
|
11113
11236
|
|
|
11114
|
-
;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=template&id=
|
|
11237
|
+
;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=template&id=a40a67cc&scoped=true
|
|
11115
11238
|
|
|
11116
11239
|
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=script&lang=js
|
|
11117
11240
|
|
|
@@ -11134,6 +11257,10 @@ var chat_toolsvue_type_template_id_65c1d3ae_scoped_true_staticRenderFns = [];
|
|
|
11134
11257
|
sending: {
|
|
11135
11258
|
type: Boolean,
|
|
11136
11259
|
default: false
|
|
11260
|
+
},
|
|
11261
|
+
isLast: {
|
|
11262
|
+
type: Boolean,
|
|
11263
|
+
default: false
|
|
11137
11264
|
}
|
|
11138
11265
|
},
|
|
11139
11266
|
data() {
|
|
@@ -11208,10 +11335,10 @@ var chat_toolsvue_type_template_id_65c1d3ae_scoped_true_staticRenderFns = [];
|
|
|
11208
11335
|
});
|
|
11209
11336
|
;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=script&lang=js
|
|
11210
11337
|
/* harmony default export */ var src_chat_toolsvue_type_script_lang_js = (chat_toolsvue_type_script_lang_js);
|
|
11211
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=
|
|
11338
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=a40a67cc&prod&lang=scss&scoped=true
|
|
11212
11339
|
// extracted by mini-css-extract-plugin
|
|
11213
11340
|
|
|
11214
|
-
;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=
|
|
11341
|
+
;// CONCATENATED MODULE: ./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=a40a67cc&prod&lang=scss&scoped=true
|
|
11215
11342
|
|
|
11216
11343
|
;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
|
|
11217
11344
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
@@ -11322,18 +11449,18 @@ function normalizeComponent(
|
|
|
11322
11449
|
|
|
11323
11450
|
var component = normalizeComponent(
|
|
11324
11451
|
src_chat_toolsvue_type_script_lang_js,
|
|
11325
|
-
|
|
11326
|
-
|
|
11452
|
+
chat_toolsvue_type_template_id_a40a67cc_scoped_true_render,
|
|
11453
|
+
chat_toolsvue_type_template_id_a40a67cc_scoped_true_staticRenderFns,
|
|
11327
11454
|
false,
|
|
11328
11455
|
null,
|
|
11329
|
-
"
|
|
11456
|
+
"a40a67cc",
|
|
11330
11457
|
null
|
|
11331
11458
|
|
|
11332
11459
|
)
|
|
11333
11460
|
|
|
11334
11461
|
/* harmony default export */ var chat_tools = (component.exports);
|
|
11335
|
-
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=template&id=
|
|
11336
|
-
var
|
|
11462
|
+
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=template&id=72bccb65&scoped=true
|
|
11463
|
+
var error_chatvue_type_template_id_72bccb65_scoped_true_render = function render() {
|
|
11337
11464
|
var _vm = this,
|
|
11338
11465
|
_c = _vm._self._c;
|
|
11339
11466
|
return _c('div', {
|
|
@@ -11449,9 +11576,9 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_render = function render
|
|
|
11449
11576
|
domProps: {
|
|
11450
11577
|
"innerHTML": _vm._s(_vm.analysisData.reason)
|
|
11451
11578
|
}
|
|
11452
|
-
}), _vm.analysisData.recommend && _vm.analysisData.recommend.length > 0 ? _c('div', {
|
|
11579
|
+
}), _vm.analysisData.recommend && _vm.analysisData.recommend.length > 0 && !_vm.allIdWithStart ? _c('div', {
|
|
11453
11580
|
staticClass: "title-label"
|
|
11454
|
-
}, [_vm._v("推荐资料")]) : _vm._e(), _c('div', {
|
|
11581
|
+
}, [_vm._v(" 推荐资料 ")]) : _vm._e(), _c('div', {
|
|
11455
11582
|
staticClass: "answer-content"
|
|
11456
11583
|
}, _vm._l(_vm.analysisData.recommend, function (list, index) {
|
|
11457
11584
|
return _c('div', {
|
|
@@ -11459,12 +11586,12 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_render = function render
|
|
|
11459
11586
|
staticStyle: {
|
|
11460
11587
|
"margin-bottom": "8px"
|
|
11461
11588
|
}
|
|
11462
|
-
}, [_c('a', {
|
|
11589
|
+
}, [!list.title.startsWith(_vm.chatMajorId) ? _c('a', {
|
|
11463
11590
|
attrs: {
|
|
11464
11591
|
"href": 'https://ai-yuliao.hep.com.cn' + list.url,
|
|
11465
11592
|
"target": "_blank"
|
|
11466
11593
|
}
|
|
11467
|
-
}, [_vm._v(_vm._s(list.title))])]);
|
|
11594
|
+
}, [_vm._v(_vm._s(list.title) + " ")]) : _vm._e()]);
|
|
11468
11595
|
}), 0), _c('chat-tools', {
|
|
11469
11596
|
attrs: {
|
|
11470
11597
|
"type": "error",
|
|
@@ -11476,7 +11603,7 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_render = function render
|
|
|
11476
11603
|
}
|
|
11477
11604
|
})], 1)]);
|
|
11478
11605
|
};
|
|
11479
|
-
var
|
|
11606
|
+
var error_chatvue_type_template_id_72bccb65_scoped_true_staticRenderFns = [function () {
|
|
11480
11607
|
var _vm = this,
|
|
11481
11608
|
_c = _vm._self._c;
|
|
11482
11609
|
return _c('div', {
|
|
@@ -11495,7 +11622,7 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
|
|
|
11495
11622
|
})]);
|
|
11496
11623
|
}];
|
|
11497
11624
|
|
|
11498
|
-
;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=template&id=
|
|
11625
|
+
;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=template&id=72bccb65&scoped=true
|
|
11499
11626
|
|
|
11500
11627
|
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=script&lang=js
|
|
11501
11628
|
|
|
@@ -11514,7 +11641,11 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
|
|
|
11514
11641
|
// 记录页面点赞 踩情况
|
|
11515
11642
|
analysisData: {},
|
|
11516
11643
|
// 记录页面点赞 踩情况
|
|
11517
|
-
chatId: ''
|
|
11644
|
+
chatId: '',
|
|
11645
|
+
// 对话id
|
|
11646
|
+
chatMajorId: '',
|
|
11647
|
+
// 智能体id
|
|
11648
|
+
allIdWithStart: true // 智能体id
|
|
11518
11649
|
};
|
|
11519
11650
|
},
|
|
11520
11651
|
watch: {
|
|
@@ -11548,6 +11679,7 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
|
|
|
11548
11679
|
}],
|
|
11549
11680
|
xhModelDetailVoList
|
|
11550
11681
|
} = analysisRes;
|
|
11682
|
+
if (xhModelDetailVoList) this.chatMajorId = xhModelDetailVoList[0].chatMajorId;
|
|
11551
11683
|
// 传入工具中的值
|
|
11552
11684
|
this.chatId = chatId;
|
|
11553
11685
|
this.detailData = {
|
|
@@ -11559,6 +11691,11 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
|
|
|
11559
11691
|
try {
|
|
11560
11692
|
this.analysisData = JSON.parse(content);
|
|
11561
11693
|
this.detailData.errId = errId;
|
|
11694
|
+
for (let item of this.analysisData.recommend) {
|
|
11695
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
11696
|
+
this.allIdWithStart = false;
|
|
11697
|
+
}
|
|
11698
|
+
}
|
|
11562
11699
|
} catch (e) {
|
|
11563
11700
|
this.$message.warning('解析失败' + e);
|
|
11564
11701
|
this.analysisData = {
|
|
@@ -11567,7 +11704,7 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
|
|
|
11567
11704
|
console.log(e);
|
|
11568
11705
|
}
|
|
11569
11706
|
} catch (e) {
|
|
11570
|
-
|
|
11707
|
+
throw new Error(e);
|
|
11571
11708
|
}
|
|
11572
11709
|
},
|
|
11573
11710
|
async reanswer(list) {
|
|
@@ -11610,10 +11747,10 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
|
|
|
11610
11747
|
});
|
|
11611
11748
|
;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=script&lang=js
|
|
11612
11749
|
/* harmony default export */ var src_error_chatvue_type_script_lang_js = (error_chatvue_type_script_lang_js);
|
|
11613
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=style&index=0&id=
|
|
11750
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/error-chat.vue?vue&type=style&index=0&id=72bccb65&prod&lang=scss&scoped=true
|
|
11614
11751
|
// extracted by mini-css-extract-plugin
|
|
11615
11752
|
|
|
11616
|
-
;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=style&index=0&id=
|
|
11753
|
+
;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue?vue&type=style&index=0&id=72bccb65&prod&lang=scss&scoped=true
|
|
11617
11754
|
|
|
11618
11755
|
;// CONCATENATED MODULE: ./components/demo/src/error-chat.vue
|
|
11619
11756
|
|
|
@@ -11626,140 +11763,2653 @@ var error_chatvue_type_template_id_3c02c55c_scoped_true_staticRenderFns = [funct
|
|
|
11626
11763
|
|
|
11627
11764
|
var error_chat_component = normalizeComponent(
|
|
11628
11765
|
src_error_chatvue_type_script_lang_js,
|
|
11629
|
-
|
|
11630
|
-
|
|
11766
|
+
error_chatvue_type_template_id_72bccb65_scoped_true_render,
|
|
11767
|
+
error_chatvue_type_template_id_72bccb65_scoped_true_staticRenderFns,
|
|
11631
11768
|
false,
|
|
11632
11769
|
null,
|
|
11633
|
-
"
|
|
11770
|
+
"72bccb65",
|
|
11634
11771
|
null
|
|
11635
11772
|
|
|
11636
11773
|
)
|
|
11637
11774
|
|
|
11638
11775
|
/* harmony default export */ var error_chat = (error_chat_component.exports);
|
|
11639
|
-
;// CONCATENATED MODULE: ./node_modules/
|
|
11640
|
-
|
|
11776
|
+
;// CONCATENATED MODULE: ./node_modules/marked/lib/marked.esm.js
|
|
11777
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11778
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11779
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11780
|
+
/**
|
|
11781
|
+
* marked v14.1.2 - a markdown parser
|
|
11782
|
+
* Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
|
|
11783
|
+
* https://github.com/markedjs/marked
|
|
11784
|
+
*/
|
|
11641
11785
|
|
|
11786
|
+
/**
|
|
11787
|
+
* DO NOT EDIT THIS FILE
|
|
11788
|
+
* The code in this file is generated from files in ./src/
|
|
11789
|
+
*/
|
|
11642
11790
|
|
|
11791
|
+
/**
|
|
11792
|
+
* Gets the original marked default options.
|
|
11793
|
+
*/
|
|
11794
|
+
function _getDefaults() {
|
|
11795
|
+
return {
|
|
11796
|
+
async: false,
|
|
11797
|
+
breaks: false,
|
|
11798
|
+
extensions: null,
|
|
11799
|
+
gfm: true,
|
|
11800
|
+
hooks: null,
|
|
11801
|
+
pedantic: false,
|
|
11802
|
+
renderer: null,
|
|
11803
|
+
silent: false,
|
|
11804
|
+
tokenizer: null,
|
|
11805
|
+
walkTokens: null
|
|
11806
|
+
};
|
|
11807
|
+
}
|
|
11808
|
+
let _defaults = _getDefaults();
|
|
11809
|
+
function changeDefaults(newDefaults) {
|
|
11810
|
+
_defaults = newDefaults;
|
|
11811
|
+
}
|
|
11643
11812
|
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11813
|
+
/**
|
|
11814
|
+
* Helpers
|
|
11815
|
+
*/
|
|
11816
|
+
const escapeTest = /[&<>"']/;
|
|
11817
|
+
const escapeReplace = new RegExp(escapeTest.source, 'g');
|
|
11818
|
+
const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
|
|
11819
|
+
const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
|
|
11820
|
+
const escapeReplacements = {
|
|
11821
|
+
'&': '&',
|
|
11822
|
+
'<': '<',
|
|
11823
|
+
'>': '>',
|
|
11824
|
+
'"': '"',
|
|
11825
|
+
"'": '''
|
|
11826
|
+
};
|
|
11827
|
+
const getEscapeReplacement = ch => escapeReplacements[ch];
|
|
11828
|
+
function escape$1(html, encode) {
|
|
11829
|
+
if (encode) {
|
|
11830
|
+
if (escapeTest.test(html)) {
|
|
11831
|
+
return html.replace(escapeReplace, getEscapeReplacement);
|
|
11832
|
+
}
|
|
11833
|
+
} else {
|
|
11834
|
+
if (escapeTestNoEncode.test(html)) {
|
|
11835
|
+
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
11836
|
+
}
|
|
11837
|
+
}
|
|
11838
|
+
return html;
|
|
11839
|
+
}
|
|
11840
|
+
const caret = /(^|[^\[])\^/g;
|
|
11841
|
+
function edit(regex, opt) {
|
|
11842
|
+
let source = typeof regex === 'string' ? regex : regex.source;
|
|
11843
|
+
opt = opt || '';
|
|
11844
|
+
const obj = {
|
|
11845
|
+
replace: (name, val) => {
|
|
11846
|
+
let valSource = typeof val === 'string' ? val : val.source;
|
|
11847
|
+
valSource = valSource.replace(caret, '$1');
|
|
11848
|
+
source = source.replace(name, valSource);
|
|
11849
|
+
return obj;
|
|
11661
11850
|
},
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
default: ''
|
|
11851
|
+
getRegex: () => {
|
|
11852
|
+
return new RegExp(source, opt);
|
|
11665
11853
|
}
|
|
11666
|
-
}
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11854
|
+
};
|
|
11855
|
+
return obj;
|
|
11856
|
+
}
|
|
11857
|
+
function cleanUrl(href) {
|
|
11858
|
+
try {
|
|
11859
|
+
href = encodeURI(href).replace(/%25/g, '%');
|
|
11860
|
+
} catch {
|
|
11861
|
+
return null;
|
|
11862
|
+
}
|
|
11863
|
+
return href;
|
|
11864
|
+
}
|
|
11865
|
+
const noopTest = {
|
|
11866
|
+
exec: () => null
|
|
11867
|
+
};
|
|
11868
|
+
function splitCells(tableRow, count) {
|
|
11869
|
+
// ensure that every cell-delimiting pipe has a space
|
|
11870
|
+
// before it to distinguish it from an escaped pipe
|
|
11871
|
+
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
11872
|
+
let escaped = false;
|
|
11873
|
+
let curr = offset;
|
|
11874
|
+
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
|
|
11875
|
+
if (escaped) {
|
|
11876
|
+
// odd number of slashes means | is escaped
|
|
11877
|
+
// so we leave it alone
|
|
11878
|
+
return '|';
|
|
11879
|
+
} else {
|
|
11880
|
+
// add space before unescaped |
|
|
11881
|
+
return ' |';
|
|
11882
|
+
}
|
|
11883
|
+
}),
|
|
11884
|
+
cells = row.split(/ \|/);
|
|
11885
|
+
let i = 0;
|
|
11886
|
+
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
11887
|
+
if (!cells[0].trim()) {
|
|
11888
|
+
cells.shift();
|
|
11889
|
+
}
|
|
11890
|
+
if (cells.length > 0 && !cells[cells.length - 1].trim()) {
|
|
11891
|
+
cells.pop();
|
|
11892
|
+
}
|
|
11893
|
+
if (count) {
|
|
11894
|
+
if (cells.length > count) {
|
|
11895
|
+
cells.splice(count);
|
|
11896
|
+
} else {
|
|
11897
|
+
while (cells.length < count) cells.push('');
|
|
11898
|
+
}
|
|
11899
|
+
}
|
|
11900
|
+
for (; i < cells.length; i++) {
|
|
11901
|
+
// leading or trailing whitespace is ignored per the gfm spec
|
|
11902
|
+
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
11903
|
+
}
|
|
11904
|
+
return cells;
|
|
11905
|
+
}
|
|
11906
|
+
/**
|
|
11907
|
+
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
11908
|
+
* /c*$/ is vulnerable to REDOS.
|
|
11909
|
+
*
|
|
11910
|
+
* @param str
|
|
11911
|
+
* @param c
|
|
11912
|
+
* @param invert Remove suffix of non-c chars instead. Default falsey.
|
|
11913
|
+
*/
|
|
11914
|
+
function rtrim(str, c, invert) {
|
|
11915
|
+
const l = str.length;
|
|
11916
|
+
if (l === 0) {
|
|
11917
|
+
return '';
|
|
11918
|
+
}
|
|
11919
|
+
// Length of suffix matching the invert condition.
|
|
11920
|
+
let suffLen = 0;
|
|
11921
|
+
// Step left until we fail to match the invert condition.
|
|
11922
|
+
while (suffLen < l) {
|
|
11923
|
+
const currChar = str.charAt(l - suffLen - 1);
|
|
11924
|
+
if (currChar === c && !invert) {
|
|
11925
|
+
suffLen++;
|
|
11926
|
+
} else if (currChar !== c && invert) {
|
|
11927
|
+
suffLen++;
|
|
11928
|
+
} else {
|
|
11929
|
+
break;
|
|
11930
|
+
}
|
|
11931
|
+
}
|
|
11932
|
+
return str.slice(0, l - suffLen);
|
|
11933
|
+
}
|
|
11934
|
+
function findClosingBracket(str, b) {
|
|
11935
|
+
if (str.indexOf(b[1]) === -1) {
|
|
11936
|
+
return -1;
|
|
11937
|
+
}
|
|
11938
|
+
let level = 0;
|
|
11939
|
+
for (let i = 0; i < str.length; i++) {
|
|
11940
|
+
if (str[i] === '\\') {
|
|
11941
|
+
i++;
|
|
11942
|
+
} else if (str[i] === b[0]) {
|
|
11943
|
+
level++;
|
|
11944
|
+
} else if (str[i] === b[1]) {
|
|
11945
|
+
level--;
|
|
11946
|
+
if (level < 0) {
|
|
11947
|
+
return i;
|
|
11948
|
+
}
|
|
11949
|
+
}
|
|
11950
|
+
}
|
|
11951
|
+
return -1;
|
|
11952
|
+
}
|
|
11953
|
+
function outputLink(cap, link, raw, lexer) {
|
|
11954
|
+
const href = link.href;
|
|
11955
|
+
const title = link.title ? escape$1(link.title) : null;
|
|
11956
|
+
const text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
11957
|
+
if (cap[0].charAt(0) !== '!') {
|
|
11958
|
+
lexer.state.inLink = true;
|
|
11959
|
+
const token = {
|
|
11960
|
+
type: 'link',
|
|
11961
|
+
raw,
|
|
11962
|
+
href,
|
|
11963
|
+
title,
|
|
11964
|
+
text,
|
|
11965
|
+
tokens: lexer.inlineTokens(text)
|
|
11679
11966
|
};
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11967
|
+
lexer.state.inLink = false;
|
|
11968
|
+
return token;
|
|
11969
|
+
}
|
|
11970
|
+
return {
|
|
11971
|
+
type: 'image',
|
|
11972
|
+
raw,
|
|
11973
|
+
href,
|
|
11974
|
+
title,
|
|
11975
|
+
text: escape$1(text)
|
|
11976
|
+
};
|
|
11977
|
+
}
|
|
11978
|
+
function indentCodeCompensation(raw, text) {
|
|
11979
|
+
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
11980
|
+
if (matchIndentToCode === null) {
|
|
11981
|
+
return text;
|
|
11982
|
+
}
|
|
11983
|
+
const indentToCode = matchIndentToCode[1];
|
|
11984
|
+
return text.split('\n').map(node => {
|
|
11985
|
+
const matchIndentInNode = node.match(/^\s+/);
|
|
11986
|
+
if (matchIndentInNode === null) {
|
|
11987
|
+
return node;
|
|
11988
|
+
}
|
|
11989
|
+
const [indentInNode] = matchIndentInNode;
|
|
11990
|
+
if (indentInNode.length >= indentToCode.length) {
|
|
11991
|
+
return node.slice(indentToCode.length);
|
|
11992
|
+
}
|
|
11993
|
+
return node;
|
|
11994
|
+
}).join('\n');
|
|
11995
|
+
}
|
|
11996
|
+
/**
|
|
11997
|
+
* Tokenizer
|
|
11998
|
+
*/
|
|
11999
|
+
class _Tokenizer {
|
|
12000
|
+
// set by the lexer
|
|
12001
|
+
constructor(options) {
|
|
12002
|
+
_defineProperty(this, "options", void 0);
|
|
12003
|
+
_defineProperty(this, "rules", void 0);
|
|
12004
|
+
// set by the lexer
|
|
12005
|
+
_defineProperty(this, "lexer", void 0);
|
|
12006
|
+
this.options = options || _defaults;
|
|
12007
|
+
}
|
|
12008
|
+
space(src) {
|
|
12009
|
+
const cap = this.rules.block.newline.exec(src);
|
|
12010
|
+
if (cap && cap[0].length > 0) {
|
|
12011
|
+
return {
|
|
12012
|
+
type: 'space',
|
|
12013
|
+
raw: cap[0]
|
|
12014
|
+
};
|
|
11684
12015
|
}
|
|
11685
|
-
}
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
12016
|
+
}
|
|
12017
|
+
code(src) {
|
|
12018
|
+
const cap = this.rules.block.code.exec(src);
|
|
12019
|
+
if (cap) {
|
|
12020
|
+
const text = cap[0].replace(/^(?: {1,4}| {0,3}\t)/gm, '');
|
|
12021
|
+
return {
|
|
12022
|
+
type: 'code',
|
|
12023
|
+
raw: cap[0],
|
|
12024
|
+
codeBlockStyle: 'indented',
|
|
12025
|
+
text: !this.options.pedantic ? rtrim(text, '\n') : text
|
|
12026
|
+
};
|
|
11695
12027
|
}
|
|
11696
|
-
}
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
this.
|
|
12028
|
+
}
|
|
12029
|
+
fences(src) {
|
|
12030
|
+
const cap = this.rules.block.fences.exec(src);
|
|
12031
|
+
if (cap) {
|
|
12032
|
+
const raw = cap[0];
|
|
12033
|
+
const text = indentCodeCompensation(raw, cap[3] || '');
|
|
12034
|
+
return {
|
|
12035
|
+
type: 'code',
|
|
12036
|
+
raw,
|
|
12037
|
+
lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
|
|
12038
|
+
text
|
|
12039
|
+
};
|
|
12040
|
+
}
|
|
12041
|
+
}
|
|
12042
|
+
heading(src) {
|
|
12043
|
+
const cap = this.rules.block.heading.exec(src);
|
|
12044
|
+
if (cap) {
|
|
12045
|
+
let text = cap[2].trim();
|
|
12046
|
+
// remove trailing #s
|
|
12047
|
+
if (/#$/.test(text)) {
|
|
12048
|
+
const trimmed = rtrim(text, '#');
|
|
12049
|
+
if (this.options.pedantic) {
|
|
12050
|
+
text = trimmed.trim();
|
|
12051
|
+
} else if (!trimmed || / $/.test(trimmed)) {
|
|
12052
|
+
// CommonMark requires space before trailing #s
|
|
12053
|
+
text = trimmed.trim();
|
|
12054
|
+
}
|
|
11718
12055
|
}
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
parentMsgId: parentMsgId || undefined,
|
|
11726
|
-
...reanswerParams
|
|
11727
|
-
}]
|
|
12056
|
+
return {
|
|
12057
|
+
type: 'heading',
|
|
12058
|
+
raw: cap[0],
|
|
12059
|
+
depth: cap[1].length,
|
|
12060
|
+
text,
|
|
12061
|
+
tokens: this.lexer.inline(text)
|
|
11728
12062
|
};
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
12063
|
+
}
|
|
12064
|
+
}
|
|
12065
|
+
hr(src) {
|
|
12066
|
+
const cap = this.rules.block.hr.exec(src);
|
|
12067
|
+
if (cap) {
|
|
12068
|
+
return {
|
|
12069
|
+
type: 'hr',
|
|
12070
|
+
raw: rtrim(cap[0], '\n')
|
|
12071
|
+
};
|
|
12072
|
+
}
|
|
12073
|
+
}
|
|
12074
|
+
blockquote(src) {
|
|
12075
|
+
const cap = this.rules.block.blockquote.exec(src);
|
|
12076
|
+
if (cap) {
|
|
12077
|
+
let lines = rtrim(cap[0], '\n').split('\n');
|
|
12078
|
+
let raw = '';
|
|
12079
|
+
let text = '';
|
|
12080
|
+
const tokens = [];
|
|
12081
|
+
while (lines.length > 0) {
|
|
12082
|
+
let inBlockquote = false;
|
|
12083
|
+
const currentLines = [];
|
|
12084
|
+
let i;
|
|
12085
|
+
for (i = 0; i < lines.length; i++) {
|
|
12086
|
+
// get lines up to a continuation
|
|
12087
|
+
if (/^ {0,3}>/.test(lines[i])) {
|
|
12088
|
+
currentLines.push(lines[i]);
|
|
12089
|
+
inBlockquote = true;
|
|
12090
|
+
} else if (!inBlockquote) {
|
|
12091
|
+
currentLines.push(lines[i]);
|
|
12092
|
+
} else {
|
|
12093
|
+
break;
|
|
12094
|
+
}
|
|
12095
|
+
}
|
|
12096
|
+
lines = lines.slice(i);
|
|
12097
|
+
const currentRaw = currentLines.join('\n');
|
|
12098
|
+
const currentText = currentRaw
|
|
12099
|
+
// precede setext continuation with 4 spaces so it isn't a setext
|
|
12100
|
+
.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, '\n $1').replace(/^ {0,3}>[ \t]?/gm, '');
|
|
12101
|
+
raw = raw ? `${raw}\n${currentRaw}` : currentRaw;
|
|
12102
|
+
text = text ? `${text}\n${currentText}` : currentText;
|
|
12103
|
+
// parse blockquote lines as top level tokens
|
|
12104
|
+
// merge paragraphs if this is a continuation
|
|
12105
|
+
const top = this.lexer.state.top;
|
|
12106
|
+
this.lexer.state.top = true;
|
|
12107
|
+
this.lexer.blockTokens(currentText, tokens, true);
|
|
12108
|
+
this.lexer.state.top = top;
|
|
12109
|
+
// if there is no continuation then we are done
|
|
12110
|
+
if (lines.length === 0) {
|
|
12111
|
+
break;
|
|
12112
|
+
}
|
|
12113
|
+
const lastToken = tokens[tokens.length - 1];
|
|
12114
|
+
if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.type) === 'code') {
|
|
12115
|
+
// blockquote continuation cannot be preceded by a code block
|
|
12116
|
+
break;
|
|
12117
|
+
} else if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.type) === 'blockquote') {
|
|
12118
|
+
// include continuation in nested blockquote
|
|
12119
|
+
const oldToken = lastToken;
|
|
12120
|
+
const newText = oldToken.raw + '\n' + lines.join('\n');
|
|
12121
|
+
const newToken = this.blockquote(newText);
|
|
12122
|
+
tokens[tokens.length - 1] = newToken;
|
|
12123
|
+
raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
|
|
12124
|
+
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
|
|
12125
|
+
break;
|
|
12126
|
+
} else if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.type) === 'list') {
|
|
12127
|
+
// include continuation in nested list
|
|
12128
|
+
const oldToken = lastToken;
|
|
12129
|
+
const newText = oldToken.raw + '\n' + lines.join('\n');
|
|
12130
|
+
const newToken = this.list(newText);
|
|
12131
|
+
tokens[tokens.length - 1] = newToken;
|
|
12132
|
+
raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
|
|
12133
|
+
text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
|
|
12134
|
+
lines = newText.substring(tokens[tokens.length - 1].raw.length).split('\n');
|
|
12135
|
+
continue;
|
|
12136
|
+
}
|
|
11746
12137
|
}
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
12138
|
+
return {
|
|
12139
|
+
type: 'blockquote',
|
|
12140
|
+
raw,
|
|
12141
|
+
tokens,
|
|
12142
|
+
text
|
|
12143
|
+
};
|
|
12144
|
+
}
|
|
12145
|
+
}
|
|
12146
|
+
list(src) {
|
|
12147
|
+
let cap = this.rules.block.list.exec(src);
|
|
12148
|
+
if (cap) {
|
|
12149
|
+
let bull = cap[1].trim();
|
|
12150
|
+
const isordered = bull.length > 1;
|
|
12151
|
+
const list = {
|
|
12152
|
+
type: 'list',
|
|
12153
|
+
raw: '',
|
|
12154
|
+
ordered: isordered,
|
|
12155
|
+
start: isordered ? +bull.slice(0, -1) : '',
|
|
12156
|
+
loose: false,
|
|
12157
|
+
items: []
|
|
12158
|
+
};
|
|
12159
|
+
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
12160
|
+
if (this.options.pedantic) {
|
|
12161
|
+
bull = isordered ? bull : '[*+-]';
|
|
12162
|
+
}
|
|
12163
|
+
// Get next list item
|
|
12164
|
+
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
|
|
12165
|
+
let endsWithBlankLine = false;
|
|
12166
|
+
// Check if current bullet point can start a new List Item
|
|
12167
|
+
while (src) {
|
|
12168
|
+
let endEarly = false;
|
|
12169
|
+
let raw = '';
|
|
12170
|
+
let itemContents = '';
|
|
12171
|
+
if (!(cap = itemRegex.exec(src))) {
|
|
12172
|
+
break;
|
|
12173
|
+
}
|
|
12174
|
+
if (this.rules.block.hr.test(src)) {
|
|
12175
|
+
// End list if bullet was actually HR (possibly move into itemRegex?)
|
|
12176
|
+
break;
|
|
12177
|
+
}
|
|
12178
|
+
raw = cap[0];
|
|
12179
|
+
src = src.substring(raw.length);
|
|
12180
|
+
let line = cap[2].split('\n', 1)[0].replace(/^\t+/, t => ' '.repeat(3 * t.length));
|
|
12181
|
+
let nextLine = src.split('\n', 1)[0];
|
|
12182
|
+
let blankLine = !line.trim();
|
|
12183
|
+
let indent = 0;
|
|
12184
|
+
if (this.options.pedantic) {
|
|
12185
|
+
indent = 2;
|
|
12186
|
+
itemContents = line.trimStart();
|
|
12187
|
+
} else if (blankLine) {
|
|
12188
|
+
indent = cap[1].length + 1;
|
|
12189
|
+
} else {
|
|
12190
|
+
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
12191
|
+
indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
|
|
12192
|
+
itemContents = line.slice(indent);
|
|
12193
|
+
indent += cap[1].length;
|
|
12194
|
+
}
|
|
12195
|
+
if (blankLine && /^[ \t]*$/.test(nextLine)) {
|
|
12196
|
+
// Items begin with at most one blank line
|
|
12197
|
+
raw += nextLine + '\n';
|
|
12198
|
+
src = src.substring(nextLine.length + 1);
|
|
12199
|
+
endEarly = true;
|
|
12200
|
+
}
|
|
12201
|
+
if (!endEarly) {
|
|
12202
|
+
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
|
|
12203
|
+
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
12204
|
+
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
|
|
12205
|
+
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
|
|
12206
|
+
const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, 'i');
|
|
12207
|
+
// Check if following lines should be included in List Item
|
|
12208
|
+
while (src) {
|
|
12209
|
+
const rawLine = src.split('\n', 1)[0];
|
|
12210
|
+
let nextLineWithoutTabs;
|
|
12211
|
+
nextLine = rawLine;
|
|
12212
|
+
// Re-align to follow commonmark nesting rules
|
|
12213
|
+
if (this.options.pedantic) {
|
|
12214
|
+
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
|
|
12215
|
+
nextLineWithoutTabs = nextLine;
|
|
12216
|
+
} else {
|
|
12217
|
+
nextLineWithoutTabs = nextLine.replace(/\t/g, ' ');
|
|
12218
|
+
}
|
|
12219
|
+
// End list item if found code fences
|
|
12220
|
+
if (fencesBeginRegex.test(nextLine)) {
|
|
12221
|
+
break;
|
|
12222
|
+
}
|
|
12223
|
+
// End list item if found start of new heading
|
|
12224
|
+
if (headingBeginRegex.test(nextLine)) {
|
|
12225
|
+
break;
|
|
12226
|
+
}
|
|
12227
|
+
// End list item if found start of html block
|
|
12228
|
+
if (htmlBeginRegex.test(nextLine)) {
|
|
12229
|
+
break;
|
|
12230
|
+
}
|
|
12231
|
+
// End list item if found start of new bullet
|
|
12232
|
+
if (nextBulletRegex.test(nextLine)) {
|
|
12233
|
+
break;
|
|
12234
|
+
}
|
|
12235
|
+
// Horizontal rule found
|
|
12236
|
+
if (hrRegex.test(nextLine)) {
|
|
12237
|
+
break;
|
|
12238
|
+
}
|
|
12239
|
+
if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLine.trim()) {
|
|
12240
|
+
// Dedent if possible
|
|
12241
|
+
itemContents += '\n' + nextLineWithoutTabs.slice(indent);
|
|
12242
|
+
} else {
|
|
12243
|
+
// not enough indentation
|
|
12244
|
+
if (blankLine) {
|
|
12245
|
+
break;
|
|
12246
|
+
}
|
|
12247
|
+
// paragraph continuation unless last line was a different block level element
|
|
12248
|
+
if (line.replace(/\t/g, ' ').search(/[^ ]/) >= 4) {
|
|
12249
|
+
// indented code block
|
|
12250
|
+
break;
|
|
12251
|
+
}
|
|
12252
|
+
if (fencesBeginRegex.test(line)) {
|
|
12253
|
+
break;
|
|
12254
|
+
}
|
|
12255
|
+
if (headingBeginRegex.test(line)) {
|
|
12256
|
+
break;
|
|
12257
|
+
}
|
|
12258
|
+
if (hrRegex.test(line)) {
|
|
12259
|
+
break;
|
|
12260
|
+
}
|
|
12261
|
+
itemContents += '\n' + nextLine;
|
|
12262
|
+
}
|
|
12263
|
+
if (!blankLine && !nextLine.trim()) {
|
|
12264
|
+
// Check if current line is blank
|
|
12265
|
+
blankLine = true;
|
|
12266
|
+
}
|
|
12267
|
+
raw += rawLine + '\n';
|
|
12268
|
+
src = src.substring(rawLine.length + 1);
|
|
12269
|
+
line = nextLineWithoutTabs.slice(indent);
|
|
12270
|
+
}
|
|
12271
|
+
}
|
|
12272
|
+
if (!list.loose) {
|
|
12273
|
+
// If the previous item ended with a blank line, the list is loose
|
|
12274
|
+
if (endsWithBlankLine) {
|
|
12275
|
+
list.loose = true;
|
|
12276
|
+
} else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
|
|
12277
|
+
endsWithBlankLine = true;
|
|
12278
|
+
}
|
|
12279
|
+
}
|
|
12280
|
+
let istask = null;
|
|
12281
|
+
let ischecked;
|
|
12282
|
+
// Check for task list items
|
|
12283
|
+
if (this.options.gfm) {
|
|
12284
|
+
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
12285
|
+
if (istask) {
|
|
12286
|
+
ischecked = istask[0] !== '[ ] ';
|
|
12287
|
+
itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
|
|
12288
|
+
}
|
|
12289
|
+
}
|
|
12290
|
+
list.items.push({
|
|
12291
|
+
type: 'list_item',
|
|
12292
|
+
raw,
|
|
12293
|
+
task: !!istask,
|
|
12294
|
+
checked: ischecked,
|
|
12295
|
+
loose: false,
|
|
12296
|
+
text: itemContents,
|
|
12297
|
+
tokens: []
|
|
12298
|
+
});
|
|
12299
|
+
list.raw += raw;
|
|
12300
|
+
}
|
|
12301
|
+
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
12302
|
+
list.items[list.items.length - 1].raw = list.items[list.items.length - 1].raw.trimEnd();
|
|
12303
|
+
list.items[list.items.length - 1].text = list.items[list.items.length - 1].text.trimEnd();
|
|
12304
|
+
list.raw = list.raw.trimEnd();
|
|
12305
|
+
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
12306
|
+
for (let i = 0; i < list.items.length; i++) {
|
|
12307
|
+
this.lexer.state.top = false;
|
|
12308
|
+
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
12309
|
+
if (!list.loose) {
|
|
12310
|
+
// Check if list should be loose
|
|
12311
|
+
const spacers = list.items[i].tokens.filter(t => t.type === 'space');
|
|
12312
|
+
const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => /\n.*\n/.test(t.raw));
|
|
12313
|
+
list.loose = hasMultipleLineBreaks;
|
|
12314
|
+
}
|
|
12315
|
+
}
|
|
12316
|
+
// Set all items to loose if list is loose
|
|
12317
|
+
if (list.loose) {
|
|
12318
|
+
for (let i = 0; i < list.items.length; i++) {
|
|
12319
|
+
list.items[i].loose = true;
|
|
12320
|
+
}
|
|
12321
|
+
}
|
|
12322
|
+
return list;
|
|
12323
|
+
}
|
|
12324
|
+
}
|
|
12325
|
+
html(src) {
|
|
12326
|
+
const cap = this.rules.block.html.exec(src);
|
|
12327
|
+
if (cap) {
|
|
12328
|
+
const token = {
|
|
12329
|
+
type: 'html',
|
|
12330
|
+
block: true,
|
|
12331
|
+
raw: cap[0],
|
|
12332
|
+
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
|
|
12333
|
+
text: cap[0]
|
|
12334
|
+
};
|
|
12335
|
+
return token;
|
|
12336
|
+
}
|
|
12337
|
+
}
|
|
12338
|
+
def(src) {
|
|
12339
|
+
const cap = this.rules.block.def.exec(src);
|
|
12340
|
+
if (cap) {
|
|
12341
|
+
const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
12342
|
+
const href = cap[2] ? cap[2].replace(/^<(.*)>$/, '$1').replace(this.rules.inline.anyPunctuation, '$1') : '';
|
|
12343
|
+
const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, '$1') : cap[3];
|
|
12344
|
+
return {
|
|
12345
|
+
type: 'def',
|
|
12346
|
+
tag,
|
|
12347
|
+
raw: cap[0],
|
|
12348
|
+
href,
|
|
12349
|
+
title
|
|
12350
|
+
};
|
|
12351
|
+
}
|
|
12352
|
+
}
|
|
12353
|
+
table(src) {
|
|
12354
|
+
const cap = this.rules.block.table.exec(src);
|
|
12355
|
+
if (!cap) {
|
|
12356
|
+
return;
|
|
12357
|
+
}
|
|
12358
|
+
if (!/[:|]/.test(cap[2])) {
|
|
12359
|
+
// delimiter row must have a pipe (|) or colon (:) otherwise it is a setext heading
|
|
12360
|
+
return;
|
|
12361
|
+
}
|
|
12362
|
+
const headers = splitCells(cap[1]);
|
|
12363
|
+
const aligns = cap[2].replace(/^\||\| *$/g, '').split('|');
|
|
12364
|
+
const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : [];
|
|
12365
|
+
const item = {
|
|
12366
|
+
type: 'table',
|
|
12367
|
+
raw: cap[0],
|
|
12368
|
+
header: [],
|
|
12369
|
+
align: [],
|
|
12370
|
+
rows: []
|
|
12371
|
+
};
|
|
12372
|
+
if (headers.length !== aligns.length) {
|
|
12373
|
+
// header and align columns must be equal, rows can be different.
|
|
12374
|
+
return;
|
|
12375
|
+
}
|
|
12376
|
+
for (const align of aligns) {
|
|
12377
|
+
if (/^ *-+: *$/.test(align)) {
|
|
12378
|
+
item.align.push('right');
|
|
12379
|
+
} else if (/^ *:-+: *$/.test(align)) {
|
|
12380
|
+
item.align.push('center');
|
|
12381
|
+
} else if (/^ *:-+ *$/.test(align)) {
|
|
12382
|
+
item.align.push('left');
|
|
12383
|
+
} else {
|
|
12384
|
+
item.align.push(null);
|
|
12385
|
+
}
|
|
12386
|
+
}
|
|
12387
|
+
for (let i = 0; i < headers.length; i++) {
|
|
12388
|
+
item.header.push({
|
|
12389
|
+
text: headers[i],
|
|
12390
|
+
tokens: this.lexer.inline(headers[i]),
|
|
12391
|
+
header: true,
|
|
12392
|
+
align: item.align[i]
|
|
12393
|
+
});
|
|
12394
|
+
}
|
|
12395
|
+
for (const row of rows) {
|
|
12396
|
+
item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
|
|
12397
|
+
return {
|
|
12398
|
+
text: cell,
|
|
12399
|
+
tokens: this.lexer.inline(cell),
|
|
12400
|
+
header: false,
|
|
12401
|
+
align: item.align[i]
|
|
12402
|
+
};
|
|
12403
|
+
}));
|
|
12404
|
+
}
|
|
12405
|
+
return item;
|
|
12406
|
+
}
|
|
12407
|
+
lheading(src) {
|
|
12408
|
+
const cap = this.rules.block.lheading.exec(src);
|
|
12409
|
+
if (cap) {
|
|
12410
|
+
return {
|
|
12411
|
+
type: 'heading',
|
|
12412
|
+
raw: cap[0],
|
|
12413
|
+
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
12414
|
+
text: cap[1],
|
|
12415
|
+
tokens: this.lexer.inline(cap[1])
|
|
12416
|
+
};
|
|
12417
|
+
}
|
|
12418
|
+
}
|
|
12419
|
+
paragraph(src) {
|
|
12420
|
+
const cap = this.rules.block.paragraph.exec(src);
|
|
12421
|
+
if (cap) {
|
|
12422
|
+
const text = cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1];
|
|
12423
|
+
return {
|
|
12424
|
+
type: 'paragraph',
|
|
12425
|
+
raw: cap[0],
|
|
12426
|
+
text,
|
|
12427
|
+
tokens: this.lexer.inline(text)
|
|
12428
|
+
};
|
|
12429
|
+
}
|
|
12430
|
+
}
|
|
12431
|
+
text(src) {
|
|
12432
|
+
const cap = this.rules.block.text.exec(src);
|
|
12433
|
+
if (cap) {
|
|
12434
|
+
return {
|
|
12435
|
+
type: 'text',
|
|
12436
|
+
raw: cap[0],
|
|
12437
|
+
text: cap[0],
|
|
12438
|
+
tokens: this.lexer.inline(cap[0])
|
|
12439
|
+
};
|
|
12440
|
+
}
|
|
12441
|
+
}
|
|
12442
|
+
escape(src) {
|
|
12443
|
+
const cap = this.rules.inline.escape.exec(src);
|
|
12444
|
+
if (cap) {
|
|
12445
|
+
return {
|
|
12446
|
+
type: 'escape',
|
|
12447
|
+
raw: cap[0],
|
|
12448
|
+
text: escape$1(cap[1])
|
|
12449
|
+
};
|
|
12450
|
+
}
|
|
12451
|
+
}
|
|
12452
|
+
tag(src) {
|
|
12453
|
+
const cap = this.rules.inline.tag.exec(src);
|
|
12454
|
+
if (cap) {
|
|
12455
|
+
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
12456
|
+
this.lexer.state.inLink = true;
|
|
12457
|
+
} else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
|
|
12458
|
+
this.lexer.state.inLink = false;
|
|
12459
|
+
}
|
|
12460
|
+
if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
12461
|
+
this.lexer.state.inRawBlock = true;
|
|
12462
|
+
} else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
12463
|
+
this.lexer.state.inRawBlock = false;
|
|
12464
|
+
}
|
|
12465
|
+
return {
|
|
12466
|
+
type: 'html',
|
|
12467
|
+
raw: cap[0],
|
|
12468
|
+
inLink: this.lexer.state.inLink,
|
|
12469
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
12470
|
+
block: false,
|
|
12471
|
+
text: cap[0]
|
|
12472
|
+
};
|
|
12473
|
+
}
|
|
12474
|
+
}
|
|
12475
|
+
link(src) {
|
|
12476
|
+
const cap = this.rules.inline.link.exec(src);
|
|
12477
|
+
if (cap) {
|
|
12478
|
+
const trimmedUrl = cap[2].trim();
|
|
12479
|
+
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
12480
|
+
// commonmark requires matching angle brackets
|
|
12481
|
+
if (!/>$/.test(trimmedUrl)) {
|
|
12482
|
+
return;
|
|
12483
|
+
}
|
|
12484
|
+
// ending angle bracket cannot be escaped
|
|
12485
|
+
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
12486
|
+
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
12487
|
+
return;
|
|
12488
|
+
}
|
|
12489
|
+
} else {
|
|
12490
|
+
// find closing parenthesis
|
|
12491
|
+
const lastParenIndex = findClosingBracket(cap[2], '()');
|
|
12492
|
+
if (lastParenIndex > -1) {
|
|
12493
|
+
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
12494
|
+
const linkLen = start + cap[1].length + lastParenIndex;
|
|
12495
|
+
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
12496
|
+
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
12497
|
+
cap[3] = '';
|
|
12498
|
+
}
|
|
12499
|
+
}
|
|
12500
|
+
let href = cap[2];
|
|
12501
|
+
let title = '';
|
|
12502
|
+
if (this.options.pedantic) {
|
|
12503
|
+
// split pedantic href and title
|
|
12504
|
+
const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
12505
|
+
if (link) {
|
|
12506
|
+
href = link[1];
|
|
12507
|
+
title = link[3];
|
|
12508
|
+
}
|
|
12509
|
+
} else {
|
|
12510
|
+
title = cap[3] ? cap[3].slice(1, -1) : '';
|
|
12511
|
+
}
|
|
12512
|
+
href = href.trim();
|
|
12513
|
+
if (/^</.test(href)) {
|
|
12514
|
+
if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
|
|
12515
|
+
// pedantic allows starting angle bracket without ending angle bracket
|
|
12516
|
+
href = href.slice(1);
|
|
12517
|
+
} else {
|
|
12518
|
+
href = href.slice(1, -1);
|
|
12519
|
+
}
|
|
12520
|
+
}
|
|
12521
|
+
return outputLink(cap, {
|
|
12522
|
+
href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
|
|
12523
|
+
title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title
|
|
12524
|
+
}, cap[0], this.lexer);
|
|
12525
|
+
}
|
|
12526
|
+
}
|
|
12527
|
+
reflink(src, links) {
|
|
12528
|
+
let cap;
|
|
12529
|
+
if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
|
12530
|
+
const linkString = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
|
12531
|
+
const link = links[linkString.toLowerCase()];
|
|
12532
|
+
if (!link) {
|
|
12533
|
+
const text = cap[0].charAt(0);
|
|
12534
|
+
return {
|
|
12535
|
+
type: 'text',
|
|
12536
|
+
raw: text,
|
|
12537
|
+
text
|
|
12538
|
+
};
|
|
12539
|
+
}
|
|
12540
|
+
return outputLink(cap, link, cap[0], this.lexer);
|
|
12541
|
+
}
|
|
12542
|
+
}
|
|
12543
|
+
emStrong(src, maskedSrc) {
|
|
12544
|
+
let prevChar = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
12545
|
+
let match = this.rules.inline.emStrongLDelim.exec(src);
|
|
12546
|
+
if (!match) return;
|
|
12547
|
+
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
12548
|
+
if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) return;
|
|
12549
|
+
const nextChar = match[1] || match[2] || '';
|
|
12550
|
+
if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
|
|
12551
|
+
// unicode Regex counts emoji as 1 char; spread into array for proper count (used multiple times below)
|
|
12552
|
+
const lLength = [...match[0]].length - 1;
|
|
12553
|
+
let rDelim,
|
|
12554
|
+
rLength,
|
|
12555
|
+
delimTotal = lLength,
|
|
12556
|
+
midDelimTotal = 0;
|
|
12557
|
+
const endReg = match[0][0] === '*' ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
12558
|
+
endReg.lastIndex = 0;
|
|
12559
|
+
// Clip maskedSrc to same section of string as src (move to lexer?)
|
|
12560
|
+
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
12561
|
+
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
12562
|
+
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
12563
|
+
if (!rDelim) continue; // skip single * in __abc*abc__
|
|
12564
|
+
rLength = [...rDelim].length;
|
|
12565
|
+
if (match[3] || match[4]) {
|
|
12566
|
+
// found another Left Delim
|
|
12567
|
+
delimTotal += rLength;
|
|
12568
|
+
continue;
|
|
12569
|
+
} else if (match[5] || match[6]) {
|
|
12570
|
+
// either Left or Right Delim
|
|
12571
|
+
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
12572
|
+
midDelimTotal += rLength;
|
|
12573
|
+
continue; // CommonMark Emphasis Rules 9-10
|
|
12574
|
+
}
|
|
12575
|
+
}
|
|
12576
|
+
delimTotal -= rLength;
|
|
12577
|
+
if (delimTotal > 0) continue; // Haven't found enough closing delimiters
|
|
12578
|
+
// Remove extra characters. *a*** -> *a*
|
|
12579
|
+
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
12580
|
+
// char length can be >1 for unicode characters;
|
|
12581
|
+
const lastCharLength = [...match[0]][0].length;
|
|
12582
|
+
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
|
|
12583
|
+
// Create `em` if smallest delimiter has odd char count. *a***
|
|
12584
|
+
if (Math.min(lLength, rLength) % 2) {
|
|
12585
|
+
const text = raw.slice(1, -1);
|
|
12586
|
+
return {
|
|
12587
|
+
type: 'em',
|
|
12588
|
+
raw,
|
|
12589
|
+
text,
|
|
12590
|
+
tokens: this.lexer.inlineTokens(text)
|
|
12591
|
+
};
|
|
12592
|
+
}
|
|
12593
|
+
// Create 'strong' if smallest delimiter has even char count. **a***
|
|
12594
|
+
const text = raw.slice(2, -2);
|
|
12595
|
+
return {
|
|
12596
|
+
type: 'strong',
|
|
12597
|
+
raw,
|
|
12598
|
+
text,
|
|
12599
|
+
tokens: this.lexer.inlineTokens(text)
|
|
12600
|
+
};
|
|
12601
|
+
}
|
|
12602
|
+
}
|
|
12603
|
+
}
|
|
12604
|
+
codespan(src) {
|
|
12605
|
+
const cap = this.rules.inline.code.exec(src);
|
|
12606
|
+
if (cap) {
|
|
12607
|
+
let text = cap[2].replace(/\n/g, ' ');
|
|
12608
|
+
const hasNonSpaceChars = /[^ ]/.test(text);
|
|
12609
|
+
const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
12610
|
+
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
12611
|
+
text = text.substring(1, text.length - 1);
|
|
12612
|
+
}
|
|
12613
|
+
text = escape$1(text, true);
|
|
12614
|
+
return {
|
|
12615
|
+
type: 'codespan',
|
|
12616
|
+
raw: cap[0],
|
|
12617
|
+
text
|
|
12618
|
+
};
|
|
12619
|
+
}
|
|
12620
|
+
}
|
|
12621
|
+
br(src) {
|
|
12622
|
+
const cap = this.rules.inline.br.exec(src);
|
|
12623
|
+
if (cap) {
|
|
12624
|
+
return {
|
|
12625
|
+
type: 'br',
|
|
12626
|
+
raw: cap[0]
|
|
12627
|
+
};
|
|
12628
|
+
}
|
|
12629
|
+
}
|
|
12630
|
+
del(src) {
|
|
12631
|
+
const cap = this.rules.inline.del.exec(src);
|
|
12632
|
+
if (cap) {
|
|
12633
|
+
return {
|
|
12634
|
+
type: 'del',
|
|
12635
|
+
raw: cap[0],
|
|
12636
|
+
text: cap[2],
|
|
12637
|
+
tokens: this.lexer.inlineTokens(cap[2])
|
|
12638
|
+
};
|
|
12639
|
+
}
|
|
12640
|
+
}
|
|
12641
|
+
autolink(src) {
|
|
12642
|
+
const cap = this.rules.inline.autolink.exec(src);
|
|
12643
|
+
if (cap) {
|
|
12644
|
+
let text, href;
|
|
12645
|
+
if (cap[2] === '@') {
|
|
12646
|
+
text = escape$1(cap[1]);
|
|
12647
|
+
href = 'mailto:' + text;
|
|
12648
|
+
} else {
|
|
12649
|
+
text = escape$1(cap[1]);
|
|
12650
|
+
href = text;
|
|
12651
|
+
}
|
|
12652
|
+
return {
|
|
12653
|
+
type: 'link',
|
|
12654
|
+
raw: cap[0],
|
|
12655
|
+
text,
|
|
12656
|
+
href,
|
|
12657
|
+
tokens: [{
|
|
12658
|
+
type: 'text',
|
|
12659
|
+
raw: text,
|
|
12660
|
+
text
|
|
12661
|
+
}]
|
|
12662
|
+
};
|
|
12663
|
+
}
|
|
12664
|
+
}
|
|
12665
|
+
url(src) {
|
|
12666
|
+
let cap;
|
|
12667
|
+
if (cap = this.rules.inline.url.exec(src)) {
|
|
12668
|
+
let text, href;
|
|
12669
|
+
if (cap[2] === '@') {
|
|
12670
|
+
text = escape$1(cap[0]);
|
|
12671
|
+
href = 'mailto:' + text;
|
|
12672
|
+
} else {
|
|
12673
|
+
// do extended autolink path validation
|
|
12674
|
+
let prevCapZero;
|
|
12675
|
+
do {
|
|
12676
|
+
var _this$rules$inline$_b, _this$rules$inline$_b2;
|
|
12677
|
+
prevCapZero = cap[0];
|
|
12678
|
+
cap[0] = (_this$rules$inline$_b = (_this$rules$inline$_b2 = this.rules.inline._backpedal.exec(cap[0])) === null || _this$rules$inline$_b2 === void 0 ? void 0 : _this$rules$inline$_b2[0]) !== null && _this$rules$inline$_b !== void 0 ? _this$rules$inline$_b : '';
|
|
12679
|
+
} while (prevCapZero !== cap[0]);
|
|
12680
|
+
text = escape$1(cap[0]);
|
|
12681
|
+
if (cap[1] === 'www.') {
|
|
12682
|
+
href = 'http://' + cap[0];
|
|
12683
|
+
} else {
|
|
12684
|
+
href = cap[0];
|
|
12685
|
+
}
|
|
12686
|
+
}
|
|
12687
|
+
return {
|
|
12688
|
+
type: 'link',
|
|
12689
|
+
raw: cap[0],
|
|
12690
|
+
text,
|
|
12691
|
+
href,
|
|
12692
|
+
tokens: [{
|
|
12693
|
+
type: 'text',
|
|
12694
|
+
raw: text,
|
|
12695
|
+
text
|
|
12696
|
+
}]
|
|
12697
|
+
};
|
|
12698
|
+
}
|
|
12699
|
+
}
|
|
12700
|
+
inlineText(src) {
|
|
12701
|
+
const cap = this.rules.inline.text.exec(src);
|
|
12702
|
+
if (cap) {
|
|
12703
|
+
let text;
|
|
12704
|
+
if (this.lexer.state.inRawBlock) {
|
|
12705
|
+
text = cap[0];
|
|
12706
|
+
} else {
|
|
12707
|
+
text = escape$1(cap[0]);
|
|
12708
|
+
}
|
|
12709
|
+
return {
|
|
12710
|
+
type: 'text',
|
|
12711
|
+
raw: cap[0],
|
|
12712
|
+
text
|
|
12713
|
+
};
|
|
12714
|
+
}
|
|
12715
|
+
}
|
|
12716
|
+
}
|
|
12717
|
+
|
|
12718
|
+
/**
|
|
12719
|
+
* Block-Level Grammar
|
|
12720
|
+
*/
|
|
12721
|
+
const newline = /^(?:[ \t]*(?:\n|$))+/;
|
|
12722
|
+
const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
12723
|
+
const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
12724
|
+
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
12725
|
+
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
12726
|
+
const bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
12727
|
+
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet) // lists can interrupt
|
|
12728
|
+
.replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
|
|
12729
|
+
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
|
|
12730
|
+
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
|
|
12731
|
+
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
|
|
12732
|
+
.replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
|
|
12733
|
+
.getRegex();
|
|
12734
|
+
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
12735
|
+
const blockText = /^[^\n]+/;
|
|
12736
|
+
const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
12737
|
+
const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace('label', _blockLabel).replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
12738
|
+
const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
|
|
12739
|
+
const _tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + '|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title' + '|tr|track|ul';
|
|
12740
|
+
const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
12741
|
+
const html = edit('^ {0,3}(?:' // optional indentation
|
|
12742
|
+
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
12743
|
+
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
12744
|
+
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
12745
|
+
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
12746
|
+
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
12747
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
|
|
12748
|
+
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
|
|
12749
|
+
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
|
|
12750
|
+
+ ')', 'i').replace('comment', _comment).replace('tag', _tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
12751
|
+
const paragraph = edit(_paragraph).replace('hr', hr).replace('heading', ' {0,3}#{1,6}(?:\\s|$)').replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
|
|
12752
|
+
.replace('|table', '').replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
12753
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', _tag) // pars can be interrupted by type (6) html blocks
|
|
12754
|
+
.getRegex();
|
|
12755
|
+
const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace('paragraph', paragraph).getRegex();
|
|
12756
|
+
/**
|
|
12757
|
+
* Normal Block Grammar
|
|
12758
|
+
*/
|
|
12759
|
+
const blockNormal = {
|
|
12760
|
+
blockquote,
|
|
12761
|
+
code: blockCode,
|
|
12762
|
+
def,
|
|
12763
|
+
fences,
|
|
12764
|
+
heading,
|
|
12765
|
+
hr,
|
|
12766
|
+
html,
|
|
12767
|
+
lheading,
|
|
12768
|
+
list,
|
|
12769
|
+
newline,
|
|
12770
|
+
paragraph,
|
|
12771
|
+
table: noopTest,
|
|
12772
|
+
text: blockText
|
|
12773
|
+
};
|
|
12774
|
+
/**
|
|
12775
|
+
* GFM Block Grammar
|
|
12776
|
+
*/
|
|
12777
|
+
const gfmTable = edit('^ *([^\\n ].*)\\n' // Header
|
|
12778
|
+
+ ' {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)' // Align
|
|
12779
|
+
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)') // Cells
|
|
12780
|
+
.replace('hr', hr).replace('heading', ' {0,3}#{1,6}(?:\\s|$)').replace('blockquote', ' {0,3}>').replace('code', '(?: {4}| {0,3}\t)[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
12781
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', _tag) // tables can be interrupted by type (6) html blocks
|
|
12782
|
+
.getRegex();
|
|
12783
|
+
const blockGfm = {
|
|
12784
|
+
...blockNormal,
|
|
12785
|
+
table: gfmTable,
|
|
12786
|
+
paragraph: edit(_paragraph).replace('hr', hr).replace('heading', ' {0,3}#{1,6}(?:\\s|$)').replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
|
|
12787
|
+
.replace('table', gfmTable) // interrupt paragraphs with table
|
|
12788
|
+
.replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
12789
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', _tag) // pars can be interrupted by type (6) html blocks
|
|
12790
|
+
.getRegex()
|
|
12791
|
+
};
|
|
12792
|
+
/**
|
|
12793
|
+
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
12794
|
+
*/
|
|
12795
|
+
const blockPedantic = {
|
|
12796
|
+
...blockNormal,
|
|
12797
|
+
html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
12798
|
+
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))').replace('comment', _comment).replace(/tag/g, '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b').getRegex(),
|
|
12799
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
12800
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
12801
|
+
fences: noopTest,
|
|
12802
|
+
// fences not supported
|
|
12803
|
+
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
12804
|
+
paragraph: edit(_paragraph).replace('hr', hr).replace('heading', ' *#{1,6} *[^\n]').replace('lheading', lheading).replace('|table', '').replace('blockquote', ' {0,3}>').replace('|fences', '').replace('|list', '').replace('|html', '').replace('|tag', '').getRegex()
|
|
12805
|
+
};
|
|
12806
|
+
/**
|
|
12807
|
+
* Inline-Level Grammar
|
|
12808
|
+
*/
|
|
12809
|
+
const marked_esm_escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
12810
|
+
const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
12811
|
+
const br = /^( {2,}|\\)\n(?!\s*$)/;
|
|
12812
|
+
const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
12813
|
+
// list of unicode punctuation marks, plus any missing characters from CommonMark spec
|
|
12814
|
+
const _punctuation = '\\p{P}\\p{S}';
|
|
12815
|
+
const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u').replace(/punctuation/g, _punctuation).getRegex();
|
|
12816
|
+
// sequences em should skip over [title](link), `code`, <html>
|
|
12817
|
+
const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
|
|
12818
|
+
const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u').replace(/punct/g, _punctuation).getRegex();
|
|
12819
|
+
const emStrongRDelimAst = edit('^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
|
|
12820
|
+
+ '|[^*]+(?=[^*])' // Consume to delim
|
|
12821
|
+
+ '|(?!\\*)[punct](\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
|
|
12822
|
+
+ '|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)' // (2) a***#, a*** can only be a Right Delimiter
|
|
12823
|
+
+ '|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])' // (3) #***a, ***a can only be Left Delimiter
|
|
12824
|
+
+ '|[\\s](\\*+)(?!\\*)(?=[punct])' // (4) ***# can only be Left Delimiter
|
|
12825
|
+
+ '|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])' // (5) #***# can be either Left or Right Delimiter
|
|
12826
|
+
+ '|[^punct\\s](\\*+)(?=[^punct\\s])', 'gu') // (6) a***a can be either Left or Right Delimiter
|
|
12827
|
+
.replace(/punct/g, _punctuation).getRegex();
|
|
12828
|
+
// (6) Not allowed for _
|
|
12829
|
+
const emStrongRDelimUnd = edit('^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong
|
|
12830
|
+
+ '|[^_]+(?=[^_])' // Consume to delim
|
|
12831
|
+
+ '|(?!_)[punct](_+)(?=[\\s]|$)' // (1) #___ can only be a Right Delimiter
|
|
12832
|
+
+ '|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)' // (2) a___#, a___ can only be a Right Delimiter
|
|
12833
|
+
+ '|(?!_)[punct\\s](_+)(?=[^punct\\s])' // (3) #___a, ___a can only be Left Delimiter
|
|
12834
|
+
+ '|[\\s](_+)(?!_)(?=[punct])' // (4) ___# can only be Left Delimiter
|
|
12835
|
+
+ '|(?!_)[punct](_+)(?!_)(?=[punct])', 'gu') // (5) #___# can be either Left or Right Delimiter
|
|
12836
|
+
.replace(/punct/g, _punctuation).getRegex();
|
|
12837
|
+
const anyPunctuation = edit(/\\([punct])/, 'gu').replace(/punct/g, _punctuation).getRegex();
|
|
12838
|
+
const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace('scheme', /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace('email', /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
12839
|
+
const _inlineComment = edit(_comment).replace('(?:-->|$)', '-->').getRegex();
|
|
12840
|
+
const tag = edit('^comment' + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
12841
|
+
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
12842
|
+
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
12843
|
+
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
12844
|
+
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>') // CDATA section
|
|
12845
|
+
.replace('comment', _inlineComment).replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
12846
|
+
const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
12847
|
+
const marked_esm_link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace('label', _inlineLabel).replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
12848
|
+
const reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace('label', _inlineLabel).replace('ref', _blockLabel).getRegex();
|
|
12849
|
+
const nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace('ref', _blockLabel).getRegex();
|
|
12850
|
+
const reflinkSearch = edit('reflink|nolink(?!\\()', 'g').replace('reflink', reflink).replace('nolink', nolink).getRegex();
|
|
12851
|
+
/**
|
|
12852
|
+
* Normal Inline Grammar
|
|
12853
|
+
*/
|
|
12854
|
+
const inlineNormal = {
|
|
12855
|
+
_backpedal: noopTest,
|
|
12856
|
+
// only used for GFM url
|
|
12857
|
+
anyPunctuation,
|
|
12858
|
+
autolink,
|
|
12859
|
+
blockSkip,
|
|
12860
|
+
br,
|
|
12861
|
+
code: inlineCode,
|
|
12862
|
+
del: noopTest,
|
|
12863
|
+
emStrongLDelim,
|
|
12864
|
+
emStrongRDelimAst,
|
|
12865
|
+
emStrongRDelimUnd,
|
|
12866
|
+
escape: marked_esm_escape,
|
|
12867
|
+
link: marked_esm_link,
|
|
12868
|
+
nolink,
|
|
12869
|
+
punctuation,
|
|
12870
|
+
reflink,
|
|
12871
|
+
reflinkSearch,
|
|
12872
|
+
tag,
|
|
12873
|
+
text: inlineText,
|
|
12874
|
+
url: noopTest
|
|
12875
|
+
};
|
|
12876
|
+
/**
|
|
12877
|
+
* Pedantic Inline Grammar
|
|
12878
|
+
*/
|
|
12879
|
+
const inlinePedantic = {
|
|
12880
|
+
...inlineNormal,
|
|
12881
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/).replace('label', _inlineLabel).getRegex(),
|
|
12882
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace('label', _inlineLabel).getRegex()
|
|
12883
|
+
};
|
|
12884
|
+
/**
|
|
12885
|
+
* GFM Inline Grammar
|
|
12886
|
+
*/
|
|
12887
|
+
const inlineGfm = {
|
|
12888
|
+
...inlineNormal,
|
|
12889
|
+
escape: edit(marked_esm_escape).replace('])', '~|])').getRegex(),
|
|
12890
|
+
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i').replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
|
|
12891
|
+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
12892
|
+
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
12893
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
12894
|
+
};
|
|
12895
|
+
/**
|
|
12896
|
+
* GFM + Line Breaks Inline Grammar
|
|
12897
|
+
*/
|
|
12898
|
+
const inlineBreaks = {
|
|
12899
|
+
...inlineGfm,
|
|
12900
|
+
br: edit(br).replace('{2,}', '*').getRegex(),
|
|
12901
|
+
text: edit(inlineGfm.text).replace('\\b_', '\\b_| {2,}\\n').replace(/\{2,\}/g, '*').getRegex()
|
|
12902
|
+
};
|
|
12903
|
+
/**
|
|
12904
|
+
* exports
|
|
12905
|
+
*/
|
|
12906
|
+
const block = {
|
|
12907
|
+
normal: blockNormal,
|
|
12908
|
+
gfm: blockGfm,
|
|
12909
|
+
pedantic: blockPedantic
|
|
12910
|
+
};
|
|
12911
|
+
const inline = {
|
|
12912
|
+
normal: inlineNormal,
|
|
12913
|
+
gfm: inlineGfm,
|
|
12914
|
+
breaks: inlineBreaks,
|
|
12915
|
+
pedantic: inlinePedantic
|
|
12916
|
+
};
|
|
12917
|
+
|
|
12918
|
+
/**
|
|
12919
|
+
* Block Lexer
|
|
12920
|
+
*/
|
|
12921
|
+
class _Lexer {
|
|
12922
|
+
constructor(options) {
|
|
12923
|
+
_defineProperty(this, "tokens", void 0);
|
|
12924
|
+
_defineProperty(this, "options", void 0);
|
|
12925
|
+
_defineProperty(this, "state", void 0);
|
|
12926
|
+
_defineProperty(this, "tokenizer", void 0);
|
|
12927
|
+
_defineProperty(this, "inlineQueue", void 0);
|
|
12928
|
+
// TokenList cannot be created in one go
|
|
12929
|
+
this.tokens = [];
|
|
12930
|
+
this.tokens.links = Object.create(null);
|
|
12931
|
+
this.options = options || _defaults;
|
|
12932
|
+
this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
|
|
12933
|
+
this.tokenizer = this.options.tokenizer;
|
|
12934
|
+
this.tokenizer.options = this.options;
|
|
12935
|
+
this.tokenizer.lexer = this;
|
|
12936
|
+
this.inlineQueue = [];
|
|
12937
|
+
this.state = {
|
|
12938
|
+
inLink: false,
|
|
12939
|
+
inRawBlock: false,
|
|
12940
|
+
top: true
|
|
12941
|
+
};
|
|
12942
|
+
const rules = {
|
|
12943
|
+
block: block.normal,
|
|
12944
|
+
inline: inline.normal
|
|
12945
|
+
};
|
|
12946
|
+
if (this.options.pedantic) {
|
|
12947
|
+
rules.block = block.pedantic;
|
|
12948
|
+
rules.inline = inline.pedantic;
|
|
12949
|
+
} else if (this.options.gfm) {
|
|
12950
|
+
rules.block = block.gfm;
|
|
12951
|
+
if (this.options.breaks) {
|
|
12952
|
+
rules.inline = inline.breaks;
|
|
12953
|
+
} else {
|
|
12954
|
+
rules.inline = inline.gfm;
|
|
12955
|
+
}
|
|
12956
|
+
}
|
|
12957
|
+
this.tokenizer.rules = rules;
|
|
12958
|
+
}
|
|
12959
|
+
/**
|
|
12960
|
+
* Expose Rules
|
|
12961
|
+
*/
|
|
12962
|
+
static get rules() {
|
|
12963
|
+
return {
|
|
12964
|
+
block,
|
|
12965
|
+
inline
|
|
12966
|
+
};
|
|
12967
|
+
}
|
|
12968
|
+
/**
|
|
12969
|
+
* Static Lex Method
|
|
12970
|
+
*/
|
|
12971
|
+
static lex(src, options) {
|
|
12972
|
+
const lexer = new _Lexer(options);
|
|
12973
|
+
return lexer.lex(src);
|
|
12974
|
+
}
|
|
12975
|
+
/**
|
|
12976
|
+
* Static Lex Inline Method
|
|
12977
|
+
*/
|
|
12978
|
+
static lexInline(src, options) {
|
|
12979
|
+
const lexer = new _Lexer(options);
|
|
12980
|
+
return lexer.inlineTokens(src);
|
|
12981
|
+
}
|
|
12982
|
+
/**
|
|
12983
|
+
* Preprocessing
|
|
12984
|
+
*/
|
|
12985
|
+
lex(src) {
|
|
12986
|
+
src = src.replace(/\r\n|\r/g, '\n');
|
|
12987
|
+
this.blockTokens(src, this.tokens);
|
|
12988
|
+
for (let i = 0; i < this.inlineQueue.length; i++) {
|
|
12989
|
+
const next = this.inlineQueue[i];
|
|
12990
|
+
this.inlineTokens(next.src, next.tokens);
|
|
12991
|
+
}
|
|
12992
|
+
this.inlineQueue = [];
|
|
12993
|
+
return this.tokens;
|
|
12994
|
+
}
|
|
12995
|
+
blockTokens(src) {
|
|
12996
|
+
let tokens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
12997
|
+
let lastParagraphClipped = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
12998
|
+
if (this.options.pedantic) {
|
|
12999
|
+
src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
|
|
13000
|
+
}
|
|
13001
|
+
let token;
|
|
13002
|
+
let lastToken;
|
|
13003
|
+
let cutSrc;
|
|
13004
|
+
while (src) {
|
|
13005
|
+
if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some(extTokenizer => {
|
|
13006
|
+
if (token = extTokenizer.call({
|
|
13007
|
+
lexer: this
|
|
13008
|
+
}, src, tokens)) {
|
|
13009
|
+
src = src.substring(token.raw.length);
|
|
13010
|
+
tokens.push(token);
|
|
13011
|
+
return true;
|
|
13012
|
+
}
|
|
13013
|
+
return false;
|
|
13014
|
+
})) {
|
|
13015
|
+
continue;
|
|
13016
|
+
}
|
|
13017
|
+
// newline
|
|
13018
|
+
if (token = this.tokenizer.space(src)) {
|
|
13019
|
+
src = src.substring(token.raw.length);
|
|
13020
|
+
if (token.raw.length === 1 && tokens.length > 0) {
|
|
13021
|
+
// if there's a single \n as a spacer, it's terminating the last line,
|
|
13022
|
+
// so move it there so that we don't get unnecessary paragraph tags
|
|
13023
|
+
tokens[tokens.length - 1].raw += '\n';
|
|
13024
|
+
} else {
|
|
13025
|
+
tokens.push(token);
|
|
13026
|
+
}
|
|
13027
|
+
continue;
|
|
13028
|
+
}
|
|
13029
|
+
// code
|
|
13030
|
+
if (token = this.tokenizer.code(src)) {
|
|
13031
|
+
src = src.substring(token.raw.length);
|
|
13032
|
+
lastToken = tokens[tokens.length - 1];
|
|
13033
|
+
// An indented code block cannot interrupt a paragraph.
|
|
13034
|
+
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
13035
|
+
lastToken.raw += '\n' + token.raw;
|
|
13036
|
+
lastToken.text += '\n' + token.text;
|
|
13037
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
13038
|
+
} else {
|
|
13039
|
+
tokens.push(token);
|
|
13040
|
+
}
|
|
13041
|
+
continue;
|
|
13042
|
+
}
|
|
13043
|
+
// fences
|
|
13044
|
+
if (token = this.tokenizer.fences(src)) {
|
|
13045
|
+
src = src.substring(token.raw.length);
|
|
13046
|
+
tokens.push(token);
|
|
13047
|
+
continue;
|
|
13048
|
+
}
|
|
13049
|
+
// heading
|
|
13050
|
+
if (token = this.tokenizer.heading(src)) {
|
|
13051
|
+
src = src.substring(token.raw.length);
|
|
13052
|
+
tokens.push(token);
|
|
13053
|
+
continue;
|
|
13054
|
+
}
|
|
13055
|
+
// hr
|
|
13056
|
+
if (token = this.tokenizer.hr(src)) {
|
|
13057
|
+
src = src.substring(token.raw.length);
|
|
13058
|
+
tokens.push(token);
|
|
13059
|
+
continue;
|
|
13060
|
+
}
|
|
13061
|
+
// blockquote
|
|
13062
|
+
if (token = this.tokenizer.blockquote(src)) {
|
|
13063
|
+
src = src.substring(token.raw.length);
|
|
13064
|
+
tokens.push(token);
|
|
13065
|
+
continue;
|
|
13066
|
+
}
|
|
13067
|
+
// list
|
|
13068
|
+
if (token = this.tokenizer.list(src)) {
|
|
13069
|
+
src = src.substring(token.raw.length);
|
|
13070
|
+
tokens.push(token);
|
|
13071
|
+
continue;
|
|
13072
|
+
}
|
|
13073
|
+
// html
|
|
13074
|
+
if (token = this.tokenizer.html(src)) {
|
|
13075
|
+
src = src.substring(token.raw.length);
|
|
13076
|
+
tokens.push(token);
|
|
13077
|
+
continue;
|
|
13078
|
+
}
|
|
13079
|
+
// def
|
|
13080
|
+
if (token = this.tokenizer.def(src)) {
|
|
13081
|
+
src = src.substring(token.raw.length);
|
|
13082
|
+
lastToken = tokens[tokens.length - 1];
|
|
13083
|
+
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
13084
|
+
lastToken.raw += '\n' + token.raw;
|
|
13085
|
+
lastToken.text += '\n' + token.raw;
|
|
13086
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
13087
|
+
} else if (!this.tokens.links[token.tag]) {
|
|
13088
|
+
this.tokens.links[token.tag] = {
|
|
13089
|
+
href: token.href,
|
|
13090
|
+
title: token.title
|
|
13091
|
+
};
|
|
13092
|
+
}
|
|
13093
|
+
continue;
|
|
13094
|
+
}
|
|
13095
|
+
// table (gfm)
|
|
13096
|
+
if (token = this.tokenizer.table(src)) {
|
|
13097
|
+
src = src.substring(token.raw.length);
|
|
13098
|
+
tokens.push(token);
|
|
13099
|
+
continue;
|
|
13100
|
+
}
|
|
13101
|
+
// lheading
|
|
13102
|
+
if (token = this.tokenizer.lheading(src)) {
|
|
13103
|
+
src = src.substring(token.raw.length);
|
|
13104
|
+
tokens.push(token);
|
|
13105
|
+
continue;
|
|
13106
|
+
}
|
|
13107
|
+
// top-level paragraph
|
|
13108
|
+
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
13109
|
+
cutSrc = src;
|
|
13110
|
+
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
13111
|
+
let startIndex = Infinity;
|
|
13112
|
+
const tempSrc = src.slice(1);
|
|
13113
|
+
let tempStart;
|
|
13114
|
+
this.options.extensions.startBlock.forEach(getStartIndex => {
|
|
13115
|
+
tempStart = getStartIndex.call({
|
|
13116
|
+
lexer: this
|
|
13117
|
+
}, tempSrc);
|
|
13118
|
+
if (typeof tempStart === 'number' && tempStart >= 0) {
|
|
13119
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
13120
|
+
}
|
|
13121
|
+
});
|
|
13122
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
13123
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
13124
|
+
}
|
|
13125
|
+
}
|
|
13126
|
+
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
13127
|
+
var _lastToken;
|
|
13128
|
+
lastToken = tokens[tokens.length - 1];
|
|
13129
|
+
if (lastParagraphClipped && ((_lastToken = lastToken) === null || _lastToken === void 0 ? void 0 : _lastToken.type) === 'paragraph') {
|
|
13130
|
+
lastToken.raw += '\n' + token.raw;
|
|
13131
|
+
lastToken.text += '\n' + token.text;
|
|
13132
|
+
this.inlineQueue.pop();
|
|
13133
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
13134
|
+
} else {
|
|
13135
|
+
tokens.push(token);
|
|
13136
|
+
}
|
|
13137
|
+
lastParagraphClipped = cutSrc.length !== src.length;
|
|
13138
|
+
src = src.substring(token.raw.length);
|
|
13139
|
+
continue;
|
|
13140
|
+
}
|
|
13141
|
+
// text
|
|
13142
|
+
if (token = this.tokenizer.text(src)) {
|
|
13143
|
+
src = src.substring(token.raw.length);
|
|
13144
|
+
lastToken = tokens[tokens.length - 1];
|
|
13145
|
+
if (lastToken && lastToken.type === 'text') {
|
|
13146
|
+
lastToken.raw += '\n' + token.raw;
|
|
13147
|
+
lastToken.text += '\n' + token.text;
|
|
13148
|
+
this.inlineQueue.pop();
|
|
13149
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
13150
|
+
} else {
|
|
13151
|
+
tokens.push(token);
|
|
13152
|
+
}
|
|
13153
|
+
continue;
|
|
13154
|
+
}
|
|
13155
|
+
if (src) {
|
|
13156
|
+
const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
13157
|
+
if (this.options.silent) {
|
|
13158
|
+
console.error(errMsg);
|
|
13159
|
+
break;
|
|
13160
|
+
} else {
|
|
13161
|
+
throw new Error(errMsg);
|
|
13162
|
+
}
|
|
13163
|
+
}
|
|
13164
|
+
}
|
|
13165
|
+
this.state.top = true;
|
|
13166
|
+
return tokens;
|
|
13167
|
+
}
|
|
13168
|
+
inline(src) {
|
|
13169
|
+
let tokens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
13170
|
+
this.inlineQueue.push({
|
|
13171
|
+
src,
|
|
13172
|
+
tokens
|
|
13173
|
+
});
|
|
13174
|
+
return tokens;
|
|
13175
|
+
}
|
|
13176
|
+
/**
|
|
13177
|
+
* Lexing/Compiling
|
|
13178
|
+
*/
|
|
13179
|
+
inlineTokens(src) {
|
|
13180
|
+
let tokens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
13181
|
+
let token, lastToken, cutSrc;
|
|
13182
|
+
// String with links masked to avoid interference with em and strong
|
|
13183
|
+
let maskedSrc = src;
|
|
13184
|
+
let match;
|
|
13185
|
+
let keepPrevChar, prevChar;
|
|
13186
|
+
// Mask out reflinks
|
|
13187
|
+
if (this.tokens.links) {
|
|
13188
|
+
const links = Object.keys(this.tokens.links);
|
|
13189
|
+
if (links.length > 0) {
|
|
13190
|
+
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
13191
|
+
if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
|
13192
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
13193
|
+
}
|
|
13194
|
+
}
|
|
13195
|
+
}
|
|
13196
|
+
}
|
|
13197
|
+
// Mask out other blocks
|
|
13198
|
+
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
13199
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
13200
|
+
}
|
|
13201
|
+
// Mask out escaped characters
|
|
13202
|
+
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
|
|
13203
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
13204
|
+
}
|
|
13205
|
+
while (src) {
|
|
13206
|
+
if (!keepPrevChar) {
|
|
13207
|
+
prevChar = '';
|
|
13208
|
+
}
|
|
13209
|
+
keepPrevChar = false;
|
|
13210
|
+
// extensions
|
|
13211
|
+
if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some(extTokenizer => {
|
|
13212
|
+
if (token = extTokenizer.call({
|
|
13213
|
+
lexer: this
|
|
13214
|
+
}, src, tokens)) {
|
|
13215
|
+
src = src.substring(token.raw.length);
|
|
13216
|
+
tokens.push(token);
|
|
13217
|
+
return true;
|
|
13218
|
+
}
|
|
13219
|
+
return false;
|
|
13220
|
+
})) {
|
|
13221
|
+
continue;
|
|
13222
|
+
}
|
|
13223
|
+
// escape
|
|
13224
|
+
if (token = this.tokenizer.escape(src)) {
|
|
13225
|
+
src = src.substring(token.raw.length);
|
|
13226
|
+
tokens.push(token);
|
|
13227
|
+
continue;
|
|
13228
|
+
}
|
|
13229
|
+
// tag
|
|
13230
|
+
if (token = this.tokenizer.tag(src)) {
|
|
13231
|
+
src = src.substring(token.raw.length);
|
|
13232
|
+
lastToken = tokens[tokens.length - 1];
|
|
13233
|
+
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
13234
|
+
lastToken.raw += token.raw;
|
|
13235
|
+
lastToken.text += token.text;
|
|
13236
|
+
} else {
|
|
13237
|
+
tokens.push(token);
|
|
13238
|
+
}
|
|
13239
|
+
continue;
|
|
13240
|
+
}
|
|
13241
|
+
// link
|
|
13242
|
+
if (token = this.tokenizer.link(src)) {
|
|
13243
|
+
src = src.substring(token.raw.length);
|
|
13244
|
+
tokens.push(token);
|
|
13245
|
+
continue;
|
|
13246
|
+
}
|
|
13247
|
+
// reflink, nolink
|
|
13248
|
+
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
13249
|
+
src = src.substring(token.raw.length);
|
|
13250
|
+
lastToken = tokens[tokens.length - 1];
|
|
13251
|
+
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
13252
|
+
lastToken.raw += token.raw;
|
|
13253
|
+
lastToken.text += token.text;
|
|
13254
|
+
} else {
|
|
13255
|
+
tokens.push(token);
|
|
13256
|
+
}
|
|
13257
|
+
continue;
|
|
13258
|
+
}
|
|
13259
|
+
// em & strong
|
|
13260
|
+
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
13261
|
+
src = src.substring(token.raw.length);
|
|
13262
|
+
tokens.push(token);
|
|
13263
|
+
continue;
|
|
13264
|
+
}
|
|
13265
|
+
// code
|
|
13266
|
+
if (token = this.tokenizer.codespan(src)) {
|
|
13267
|
+
src = src.substring(token.raw.length);
|
|
13268
|
+
tokens.push(token);
|
|
13269
|
+
continue;
|
|
13270
|
+
}
|
|
13271
|
+
// br
|
|
13272
|
+
if (token = this.tokenizer.br(src)) {
|
|
13273
|
+
src = src.substring(token.raw.length);
|
|
13274
|
+
tokens.push(token);
|
|
13275
|
+
continue;
|
|
13276
|
+
}
|
|
13277
|
+
// del (gfm)
|
|
13278
|
+
if (token = this.tokenizer.del(src)) {
|
|
13279
|
+
src = src.substring(token.raw.length);
|
|
13280
|
+
tokens.push(token);
|
|
13281
|
+
continue;
|
|
13282
|
+
}
|
|
13283
|
+
// autolink
|
|
13284
|
+
if (token = this.tokenizer.autolink(src)) {
|
|
13285
|
+
src = src.substring(token.raw.length);
|
|
13286
|
+
tokens.push(token);
|
|
13287
|
+
continue;
|
|
13288
|
+
}
|
|
13289
|
+
// url (gfm)
|
|
13290
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src))) {
|
|
13291
|
+
src = src.substring(token.raw.length);
|
|
13292
|
+
tokens.push(token);
|
|
13293
|
+
continue;
|
|
13294
|
+
}
|
|
13295
|
+
// text
|
|
13296
|
+
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
13297
|
+
cutSrc = src;
|
|
13298
|
+
if (this.options.extensions && this.options.extensions.startInline) {
|
|
13299
|
+
let startIndex = Infinity;
|
|
13300
|
+
const tempSrc = src.slice(1);
|
|
13301
|
+
let tempStart;
|
|
13302
|
+
this.options.extensions.startInline.forEach(getStartIndex => {
|
|
13303
|
+
tempStart = getStartIndex.call({
|
|
13304
|
+
lexer: this
|
|
13305
|
+
}, tempSrc);
|
|
13306
|
+
if (typeof tempStart === 'number' && tempStart >= 0) {
|
|
13307
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
13308
|
+
}
|
|
13309
|
+
});
|
|
13310
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
13311
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
13312
|
+
}
|
|
13313
|
+
}
|
|
13314
|
+
if (token = this.tokenizer.inlineText(cutSrc)) {
|
|
13315
|
+
src = src.substring(token.raw.length);
|
|
13316
|
+
if (token.raw.slice(-1) !== '_') {
|
|
13317
|
+
// Track prevChar before string of ____ started
|
|
13318
|
+
prevChar = token.raw.slice(-1);
|
|
13319
|
+
}
|
|
13320
|
+
keepPrevChar = true;
|
|
13321
|
+
lastToken = tokens[tokens.length - 1];
|
|
13322
|
+
if (lastToken && lastToken.type === 'text') {
|
|
13323
|
+
lastToken.raw += token.raw;
|
|
13324
|
+
lastToken.text += token.text;
|
|
13325
|
+
} else {
|
|
13326
|
+
tokens.push(token);
|
|
13327
|
+
}
|
|
13328
|
+
continue;
|
|
13329
|
+
}
|
|
13330
|
+
if (src) {
|
|
13331
|
+
const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
13332
|
+
if (this.options.silent) {
|
|
13333
|
+
console.error(errMsg);
|
|
13334
|
+
break;
|
|
13335
|
+
} else {
|
|
13336
|
+
throw new Error(errMsg);
|
|
13337
|
+
}
|
|
13338
|
+
}
|
|
13339
|
+
}
|
|
13340
|
+
return tokens;
|
|
13341
|
+
}
|
|
13342
|
+
}
|
|
13343
|
+
|
|
13344
|
+
/**
|
|
13345
|
+
* Renderer
|
|
13346
|
+
*/
|
|
13347
|
+
class _Renderer {
|
|
13348
|
+
// set by the parser
|
|
13349
|
+
constructor(options) {
|
|
13350
|
+
_defineProperty(this, "options", void 0);
|
|
13351
|
+
_defineProperty(this, "parser", void 0);
|
|
13352
|
+
this.options = options || _defaults;
|
|
13353
|
+
}
|
|
13354
|
+
space(token) {
|
|
13355
|
+
return '';
|
|
13356
|
+
}
|
|
13357
|
+
code(_ref) {
|
|
13358
|
+
var _match;
|
|
13359
|
+
let {
|
|
13360
|
+
text,
|
|
13361
|
+
lang,
|
|
13362
|
+
escaped
|
|
13363
|
+
} = _ref;
|
|
13364
|
+
const langString = (_match = (lang || '').match(/^\S*/)) === null || _match === void 0 ? void 0 : _match[0];
|
|
13365
|
+
const code = text.replace(/\n$/, '') + '\n';
|
|
13366
|
+
if (!langString) {
|
|
13367
|
+
return '<pre><code>' + (escaped ? code : escape$1(code, true)) + '</code></pre>\n';
|
|
13368
|
+
}
|
|
13369
|
+
return '<pre><code class="language-' + escape$1(langString) + '">' + (escaped ? code : escape$1(code, true)) + '</code></pre>\n';
|
|
13370
|
+
}
|
|
13371
|
+
blockquote(_ref2) {
|
|
13372
|
+
let {
|
|
13373
|
+
tokens
|
|
13374
|
+
} = _ref2;
|
|
13375
|
+
const body = this.parser.parse(tokens);
|
|
13376
|
+
return `<blockquote>\n${body}</blockquote>\n`;
|
|
13377
|
+
}
|
|
13378
|
+
html(_ref3) {
|
|
13379
|
+
let {
|
|
13380
|
+
text
|
|
13381
|
+
} = _ref3;
|
|
13382
|
+
return text;
|
|
13383
|
+
}
|
|
13384
|
+
heading(_ref4) {
|
|
13385
|
+
let {
|
|
13386
|
+
tokens,
|
|
13387
|
+
depth
|
|
13388
|
+
} = _ref4;
|
|
13389
|
+
return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>\n`;
|
|
13390
|
+
}
|
|
13391
|
+
hr(token) {
|
|
13392
|
+
return '<hr>\n';
|
|
13393
|
+
}
|
|
13394
|
+
list(token) {
|
|
13395
|
+
const ordered = token.ordered;
|
|
13396
|
+
const start = token.start;
|
|
13397
|
+
let body = '';
|
|
13398
|
+
for (let j = 0; j < token.items.length; j++) {
|
|
13399
|
+
const item = token.items[j];
|
|
13400
|
+
body += this.listitem(item);
|
|
13401
|
+
}
|
|
13402
|
+
const type = ordered ? 'ol' : 'ul';
|
|
13403
|
+
const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : '';
|
|
13404
|
+
return '<' + type + startAttr + '>\n' + body + '</' + type + '>\n';
|
|
13405
|
+
}
|
|
13406
|
+
listitem(item) {
|
|
13407
|
+
let itemBody = '';
|
|
13408
|
+
if (item.task) {
|
|
13409
|
+
const checkbox = this.checkbox({
|
|
13410
|
+
checked: !!item.checked
|
|
13411
|
+
});
|
|
13412
|
+
if (item.loose) {
|
|
13413
|
+
if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
|
|
13414
|
+
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
|
13415
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
|
13416
|
+
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
|
13417
|
+
}
|
|
13418
|
+
} else {
|
|
13419
|
+
item.tokens.unshift({
|
|
13420
|
+
type: 'text',
|
|
13421
|
+
raw: checkbox + ' ',
|
|
13422
|
+
text: checkbox + ' '
|
|
13423
|
+
});
|
|
13424
|
+
}
|
|
13425
|
+
} else {
|
|
13426
|
+
itemBody += checkbox + ' ';
|
|
13427
|
+
}
|
|
13428
|
+
}
|
|
13429
|
+
itemBody += this.parser.parse(item.tokens, !!item.loose);
|
|
13430
|
+
return `<li>${itemBody}</li>\n`;
|
|
13431
|
+
}
|
|
13432
|
+
checkbox(_ref5) {
|
|
13433
|
+
let {
|
|
13434
|
+
checked
|
|
13435
|
+
} = _ref5;
|
|
13436
|
+
return '<input ' + (checked ? 'checked="" ' : '') + 'disabled="" type="checkbox">';
|
|
13437
|
+
}
|
|
13438
|
+
paragraph(_ref6) {
|
|
13439
|
+
let {
|
|
13440
|
+
tokens
|
|
13441
|
+
} = _ref6;
|
|
13442
|
+
return `<p>${this.parser.parseInline(tokens)}</p>\n`;
|
|
13443
|
+
}
|
|
13444
|
+
table(token) {
|
|
13445
|
+
let header = '';
|
|
13446
|
+
// header
|
|
13447
|
+
let cell = '';
|
|
13448
|
+
for (let j = 0; j < token.header.length; j++) {
|
|
13449
|
+
cell += this.tablecell(token.header[j]);
|
|
13450
|
+
}
|
|
13451
|
+
header += this.tablerow({
|
|
13452
|
+
text: cell
|
|
13453
|
+
});
|
|
13454
|
+
let body = '';
|
|
13455
|
+
for (let j = 0; j < token.rows.length; j++) {
|
|
13456
|
+
const row = token.rows[j];
|
|
13457
|
+
cell = '';
|
|
13458
|
+
for (let k = 0; k < row.length; k++) {
|
|
13459
|
+
cell += this.tablecell(row[k]);
|
|
13460
|
+
}
|
|
13461
|
+
body += this.tablerow({
|
|
13462
|
+
text: cell
|
|
13463
|
+
});
|
|
13464
|
+
}
|
|
13465
|
+
if (body) body = `<tbody>${body}</tbody>`;
|
|
13466
|
+
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n';
|
|
13467
|
+
}
|
|
13468
|
+
tablerow(_ref7) {
|
|
13469
|
+
let {
|
|
13470
|
+
text
|
|
13471
|
+
} = _ref7;
|
|
13472
|
+
return `<tr>\n${text}</tr>\n`;
|
|
13473
|
+
}
|
|
13474
|
+
tablecell(token) {
|
|
13475
|
+
const content = this.parser.parseInline(token.tokens);
|
|
13476
|
+
const type = token.header ? 'th' : 'td';
|
|
13477
|
+
const tag = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
|
|
13478
|
+
return tag + content + `</${type}>\n`;
|
|
13479
|
+
}
|
|
13480
|
+
/**
|
|
13481
|
+
* span level renderer
|
|
13482
|
+
*/
|
|
13483
|
+
strong(_ref8) {
|
|
13484
|
+
let {
|
|
13485
|
+
tokens
|
|
13486
|
+
} = _ref8;
|
|
13487
|
+
return `<strong>${this.parser.parseInline(tokens)}</strong>`;
|
|
13488
|
+
}
|
|
13489
|
+
em(_ref9) {
|
|
13490
|
+
let {
|
|
13491
|
+
tokens
|
|
13492
|
+
} = _ref9;
|
|
13493
|
+
return `<em>${this.parser.parseInline(tokens)}</em>`;
|
|
13494
|
+
}
|
|
13495
|
+
codespan(_ref10) {
|
|
13496
|
+
let {
|
|
13497
|
+
text
|
|
13498
|
+
} = _ref10;
|
|
13499
|
+
return `<code>${text}</code>`;
|
|
13500
|
+
}
|
|
13501
|
+
br(token) {
|
|
13502
|
+
return '<br>';
|
|
13503
|
+
}
|
|
13504
|
+
del(_ref11) {
|
|
13505
|
+
let {
|
|
13506
|
+
tokens
|
|
13507
|
+
} = _ref11;
|
|
13508
|
+
return `<del>${this.parser.parseInline(tokens)}</del>`;
|
|
13509
|
+
}
|
|
13510
|
+
link(_ref12) {
|
|
13511
|
+
let {
|
|
13512
|
+
href,
|
|
13513
|
+
title,
|
|
13514
|
+
tokens
|
|
13515
|
+
} = _ref12;
|
|
13516
|
+
const text = this.parser.parseInline(tokens);
|
|
13517
|
+
const cleanHref = cleanUrl(href);
|
|
13518
|
+
if (cleanHref === null) {
|
|
13519
|
+
return text;
|
|
13520
|
+
}
|
|
13521
|
+
href = cleanHref;
|
|
13522
|
+
let out = '<a href="' + href + '"';
|
|
13523
|
+
if (title) {
|
|
13524
|
+
out += ' title="' + title + '"';
|
|
13525
|
+
}
|
|
13526
|
+
out += '>' + text + '</a>';
|
|
13527
|
+
return out;
|
|
13528
|
+
}
|
|
13529
|
+
image(_ref13) {
|
|
13530
|
+
let {
|
|
13531
|
+
href,
|
|
13532
|
+
title,
|
|
13533
|
+
text
|
|
13534
|
+
} = _ref13;
|
|
13535
|
+
const cleanHref = cleanUrl(href);
|
|
13536
|
+
if (cleanHref === null) {
|
|
13537
|
+
return text;
|
|
13538
|
+
}
|
|
13539
|
+
href = cleanHref;
|
|
13540
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
13541
|
+
if (title) {
|
|
13542
|
+
out += ` title="${title}"`;
|
|
13543
|
+
}
|
|
13544
|
+
out += '>';
|
|
13545
|
+
return out;
|
|
13546
|
+
}
|
|
13547
|
+
text(token) {
|
|
13548
|
+
return 'tokens' in token && token.tokens ? this.parser.parseInline(token.tokens) : token.text;
|
|
13549
|
+
}
|
|
13550
|
+
}
|
|
13551
|
+
|
|
13552
|
+
/**
|
|
13553
|
+
* TextRenderer
|
|
13554
|
+
* returns only the textual part of the token
|
|
13555
|
+
*/
|
|
13556
|
+
class _TextRenderer {
|
|
13557
|
+
// no need for block level renderers
|
|
13558
|
+
strong(_ref14) {
|
|
13559
|
+
let {
|
|
13560
|
+
text
|
|
13561
|
+
} = _ref14;
|
|
13562
|
+
return text;
|
|
13563
|
+
}
|
|
13564
|
+
em(_ref15) {
|
|
13565
|
+
let {
|
|
13566
|
+
text
|
|
13567
|
+
} = _ref15;
|
|
13568
|
+
return text;
|
|
13569
|
+
}
|
|
13570
|
+
codespan(_ref16) {
|
|
13571
|
+
let {
|
|
13572
|
+
text
|
|
13573
|
+
} = _ref16;
|
|
13574
|
+
return text;
|
|
13575
|
+
}
|
|
13576
|
+
del(_ref17) {
|
|
13577
|
+
let {
|
|
13578
|
+
text
|
|
13579
|
+
} = _ref17;
|
|
13580
|
+
return text;
|
|
13581
|
+
}
|
|
13582
|
+
html(_ref18) {
|
|
13583
|
+
let {
|
|
13584
|
+
text
|
|
13585
|
+
} = _ref18;
|
|
13586
|
+
return text;
|
|
13587
|
+
}
|
|
13588
|
+
text(_ref19) {
|
|
13589
|
+
let {
|
|
13590
|
+
text
|
|
13591
|
+
} = _ref19;
|
|
13592
|
+
return text;
|
|
13593
|
+
}
|
|
13594
|
+
link(_ref20) {
|
|
13595
|
+
let {
|
|
13596
|
+
text
|
|
13597
|
+
} = _ref20;
|
|
13598
|
+
return '' + text;
|
|
13599
|
+
}
|
|
13600
|
+
image(_ref21) {
|
|
13601
|
+
let {
|
|
13602
|
+
text
|
|
13603
|
+
} = _ref21;
|
|
13604
|
+
return '' + text;
|
|
13605
|
+
}
|
|
13606
|
+
br() {
|
|
13607
|
+
return '';
|
|
13608
|
+
}
|
|
13609
|
+
}
|
|
13610
|
+
|
|
13611
|
+
/**
|
|
13612
|
+
* Parsing & Compiling
|
|
13613
|
+
*/
|
|
13614
|
+
class _Parser {
|
|
13615
|
+
constructor(options) {
|
|
13616
|
+
_defineProperty(this, "options", void 0);
|
|
13617
|
+
_defineProperty(this, "renderer", void 0);
|
|
13618
|
+
_defineProperty(this, "textRenderer", void 0);
|
|
13619
|
+
this.options = options || _defaults;
|
|
13620
|
+
this.options.renderer = this.options.renderer || new _Renderer();
|
|
13621
|
+
this.renderer = this.options.renderer;
|
|
13622
|
+
this.renderer.options = this.options;
|
|
13623
|
+
this.renderer.parser = this;
|
|
13624
|
+
this.textRenderer = new _TextRenderer();
|
|
13625
|
+
}
|
|
13626
|
+
/**
|
|
13627
|
+
* Static Parse Method
|
|
13628
|
+
*/
|
|
13629
|
+
static parse(tokens, options) {
|
|
13630
|
+
const parser = new _Parser(options);
|
|
13631
|
+
return parser.parse(tokens);
|
|
13632
|
+
}
|
|
13633
|
+
/**
|
|
13634
|
+
* Static Parse Inline Method
|
|
13635
|
+
*/
|
|
13636
|
+
static parseInline(tokens, options) {
|
|
13637
|
+
const parser = new _Parser(options);
|
|
13638
|
+
return parser.parseInline(tokens);
|
|
13639
|
+
}
|
|
13640
|
+
/**
|
|
13641
|
+
* Parse Loop
|
|
13642
|
+
*/
|
|
13643
|
+
parse(tokens) {
|
|
13644
|
+
let top = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
13645
|
+
let out = '';
|
|
13646
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
13647
|
+
const anyToken = tokens[i];
|
|
13648
|
+
// Run any renderer extensions
|
|
13649
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
|
|
13650
|
+
const genericToken = anyToken;
|
|
13651
|
+
const ret = this.options.extensions.renderers[genericToken.type].call({
|
|
13652
|
+
parser: this
|
|
13653
|
+
}, genericToken);
|
|
13654
|
+
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(genericToken.type)) {
|
|
13655
|
+
out += ret || '';
|
|
13656
|
+
continue;
|
|
13657
|
+
}
|
|
13658
|
+
}
|
|
13659
|
+
const token = anyToken;
|
|
13660
|
+
switch (token.type) {
|
|
13661
|
+
case 'space':
|
|
13662
|
+
{
|
|
13663
|
+
out += this.renderer.space(token);
|
|
13664
|
+
continue;
|
|
13665
|
+
}
|
|
13666
|
+
case 'hr':
|
|
13667
|
+
{
|
|
13668
|
+
out += this.renderer.hr(token);
|
|
13669
|
+
continue;
|
|
13670
|
+
}
|
|
13671
|
+
case 'heading':
|
|
13672
|
+
{
|
|
13673
|
+
out += this.renderer.heading(token);
|
|
13674
|
+
continue;
|
|
13675
|
+
}
|
|
13676
|
+
case 'code':
|
|
13677
|
+
{
|
|
13678
|
+
out += this.renderer.code(token);
|
|
13679
|
+
continue;
|
|
13680
|
+
}
|
|
13681
|
+
case 'table':
|
|
13682
|
+
{
|
|
13683
|
+
out += this.renderer.table(token);
|
|
13684
|
+
continue;
|
|
13685
|
+
}
|
|
13686
|
+
case 'blockquote':
|
|
13687
|
+
{
|
|
13688
|
+
out += this.renderer.blockquote(token);
|
|
13689
|
+
continue;
|
|
13690
|
+
}
|
|
13691
|
+
case 'list':
|
|
13692
|
+
{
|
|
13693
|
+
out += this.renderer.list(token);
|
|
13694
|
+
continue;
|
|
13695
|
+
}
|
|
13696
|
+
case 'html':
|
|
13697
|
+
{
|
|
13698
|
+
out += this.renderer.html(token);
|
|
13699
|
+
continue;
|
|
13700
|
+
}
|
|
13701
|
+
case 'paragraph':
|
|
13702
|
+
{
|
|
13703
|
+
out += this.renderer.paragraph(token);
|
|
13704
|
+
continue;
|
|
13705
|
+
}
|
|
13706
|
+
case 'text':
|
|
13707
|
+
{
|
|
13708
|
+
let textToken = token;
|
|
13709
|
+
let body = this.renderer.text(textToken);
|
|
13710
|
+
while (i + 1 < tokens.length && tokens[i + 1].type === 'text') {
|
|
13711
|
+
textToken = tokens[++i];
|
|
13712
|
+
body += '\n' + this.renderer.text(textToken);
|
|
13713
|
+
}
|
|
13714
|
+
if (top) {
|
|
13715
|
+
out += this.renderer.paragraph({
|
|
13716
|
+
type: 'paragraph',
|
|
13717
|
+
raw: body,
|
|
13718
|
+
text: body,
|
|
13719
|
+
tokens: [{
|
|
13720
|
+
type: 'text',
|
|
13721
|
+
raw: body,
|
|
13722
|
+
text: body
|
|
13723
|
+
}]
|
|
13724
|
+
});
|
|
13725
|
+
} else {
|
|
13726
|
+
out += body;
|
|
13727
|
+
}
|
|
13728
|
+
continue;
|
|
13729
|
+
}
|
|
13730
|
+
default:
|
|
13731
|
+
{
|
|
13732
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
13733
|
+
if (this.options.silent) {
|
|
13734
|
+
console.error(errMsg);
|
|
13735
|
+
return '';
|
|
13736
|
+
} else {
|
|
13737
|
+
throw new Error(errMsg);
|
|
13738
|
+
}
|
|
13739
|
+
}
|
|
13740
|
+
}
|
|
13741
|
+
}
|
|
13742
|
+
return out;
|
|
13743
|
+
}
|
|
13744
|
+
/**
|
|
13745
|
+
* Parse Inline Tokens
|
|
13746
|
+
*/
|
|
13747
|
+
parseInline(tokens, renderer) {
|
|
13748
|
+
renderer = renderer || this.renderer;
|
|
13749
|
+
let out = '';
|
|
13750
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
13751
|
+
const anyToken = tokens[i];
|
|
13752
|
+
// Run any renderer extensions
|
|
13753
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
|
|
13754
|
+
const ret = this.options.extensions.renderers[anyToken.type].call({
|
|
13755
|
+
parser: this
|
|
13756
|
+
}, anyToken);
|
|
13757
|
+
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(anyToken.type)) {
|
|
13758
|
+
out += ret || '';
|
|
13759
|
+
continue;
|
|
13760
|
+
}
|
|
13761
|
+
}
|
|
13762
|
+
const token = anyToken;
|
|
13763
|
+
switch (token.type) {
|
|
13764
|
+
case 'escape':
|
|
13765
|
+
{
|
|
13766
|
+
out += renderer.text(token);
|
|
13767
|
+
break;
|
|
13768
|
+
}
|
|
13769
|
+
case 'html':
|
|
13770
|
+
{
|
|
13771
|
+
out += renderer.html(token);
|
|
13772
|
+
break;
|
|
13773
|
+
}
|
|
13774
|
+
case 'link':
|
|
13775
|
+
{
|
|
13776
|
+
out += renderer.link(token);
|
|
13777
|
+
break;
|
|
13778
|
+
}
|
|
13779
|
+
case 'image':
|
|
13780
|
+
{
|
|
13781
|
+
out += renderer.image(token);
|
|
13782
|
+
break;
|
|
13783
|
+
}
|
|
13784
|
+
case 'strong':
|
|
13785
|
+
{
|
|
13786
|
+
out += renderer.strong(token);
|
|
13787
|
+
break;
|
|
13788
|
+
}
|
|
13789
|
+
case 'em':
|
|
13790
|
+
{
|
|
13791
|
+
out += renderer.em(token);
|
|
13792
|
+
break;
|
|
13793
|
+
}
|
|
13794
|
+
case 'codespan':
|
|
13795
|
+
{
|
|
13796
|
+
out += renderer.codespan(token);
|
|
13797
|
+
break;
|
|
13798
|
+
}
|
|
13799
|
+
case 'br':
|
|
13800
|
+
{
|
|
13801
|
+
out += renderer.br(token);
|
|
13802
|
+
break;
|
|
13803
|
+
}
|
|
13804
|
+
case 'del':
|
|
13805
|
+
{
|
|
13806
|
+
out += renderer.del(token);
|
|
13807
|
+
break;
|
|
13808
|
+
}
|
|
13809
|
+
case 'text':
|
|
13810
|
+
{
|
|
13811
|
+
out += renderer.text(token);
|
|
13812
|
+
break;
|
|
13813
|
+
}
|
|
13814
|
+
default:
|
|
13815
|
+
{
|
|
13816
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
13817
|
+
if (this.options.silent) {
|
|
13818
|
+
console.error(errMsg);
|
|
13819
|
+
return '';
|
|
13820
|
+
} else {
|
|
13821
|
+
throw new Error(errMsg);
|
|
13822
|
+
}
|
|
13823
|
+
}
|
|
13824
|
+
}
|
|
13825
|
+
}
|
|
13826
|
+
return out;
|
|
13827
|
+
}
|
|
13828
|
+
}
|
|
13829
|
+
class _Hooks {
|
|
13830
|
+
constructor(options) {
|
|
13831
|
+
_defineProperty(this, "options", void 0);
|
|
13832
|
+
_defineProperty(this, "block", void 0);
|
|
13833
|
+
this.options = options || _defaults;
|
|
13834
|
+
}
|
|
13835
|
+
/**
|
|
13836
|
+
* Process markdown before marked
|
|
13837
|
+
*/
|
|
13838
|
+
preprocess(markdown) {
|
|
13839
|
+
return markdown;
|
|
13840
|
+
}
|
|
13841
|
+
/**
|
|
13842
|
+
* Process HTML after marked is finished
|
|
13843
|
+
*/
|
|
13844
|
+
postprocess(html) {
|
|
13845
|
+
return html;
|
|
13846
|
+
}
|
|
13847
|
+
/**
|
|
13848
|
+
* Process all tokens before walk tokens
|
|
13849
|
+
*/
|
|
13850
|
+
processAllTokens(tokens) {
|
|
13851
|
+
return tokens;
|
|
13852
|
+
}
|
|
13853
|
+
/**
|
|
13854
|
+
* Provide function to tokenize markdown
|
|
13855
|
+
*/
|
|
13856
|
+
provideLexer() {
|
|
13857
|
+
return this.block ? _Lexer.lex : _Lexer.lexInline;
|
|
13858
|
+
}
|
|
13859
|
+
/**
|
|
13860
|
+
* Provide function to parse tokens
|
|
13861
|
+
*/
|
|
13862
|
+
provideParser() {
|
|
13863
|
+
return this.block ? _Parser.parse : _Parser.parseInline;
|
|
13864
|
+
}
|
|
13865
|
+
}
|
|
13866
|
+
_defineProperty(_Hooks, "passThroughHooks", new Set(['preprocess', 'postprocess', 'processAllTokens']));
|
|
13867
|
+
class Marked {
|
|
13868
|
+
constructor() {
|
|
13869
|
+
_defineProperty(this, "defaults", _getDefaults());
|
|
13870
|
+
_defineProperty(this, "options", this.setOptions);
|
|
13871
|
+
_defineProperty(this, "parse", this.parseMarkdown(true));
|
|
13872
|
+
_defineProperty(this, "parseInline", this.parseMarkdown(false));
|
|
13873
|
+
_defineProperty(this, "Parser", _Parser);
|
|
13874
|
+
_defineProperty(this, "Renderer", _Renderer);
|
|
13875
|
+
_defineProperty(this, "TextRenderer", _TextRenderer);
|
|
13876
|
+
_defineProperty(this, "Lexer", _Lexer);
|
|
13877
|
+
_defineProperty(this, "Tokenizer", _Tokenizer);
|
|
13878
|
+
_defineProperty(this, "Hooks", _Hooks);
|
|
13879
|
+
this.use(...arguments);
|
|
13880
|
+
}
|
|
13881
|
+
/**
|
|
13882
|
+
* Run callback for every token
|
|
13883
|
+
*/
|
|
13884
|
+
walkTokens(tokens, callback) {
|
|
13885
|
+
let values = [];
|
|
13886
|
+
for (const token of tokens) {
|
|
13887
|
+
values = values.concat(callback.call(this, token));
|
|
13888
|
+
switch (token.type) {
|
|
13889
|
+
case 'table':
|
|
13890
|
+
{
|
|
13891
|
+
const tableToken = token;
|
|
13892
|
+
for (const cell of tableToken.header) {
|
|
13893
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
13894
|
+
}
|
|
13895
|
+
for (const row of tableToken.rows) {
|
|
13896
|
+
for (const cell of row) {
|
|
13897
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
13898
|
+
}
|
|
13899
|
+
}
|
|
13900
|
+
break;
|
|
13901
|
+
}
|
|
13902
|
+
case 'list':
|
|
13903
|
+
{
|
|
13904
|
+
const listToken = token;
|
|
13905
|
+
values = values.concat(this.walkTokens(listToken.items, callback));
|
|
13906
|
+
break;
|
|
13907
|
+
}
|
|
13908
|
+
default:
|
|
13909
|
+
{
|
|
13910
|
+
var _this$defaults$extens, _this$defaults$extens2;
|
|
13911
|
+
const genericToken = token;
|
|
13912
|
+
if ((_this$defaults$extens = this.defaults.extensions) !== null && _this$defaults$extens !== void 0 && (_this$defaults$extens2 = _this$defaults$extens.childTokens) !== null && _this$defaults$extens2 !== void 0 && _this$defaults$extens2[genericToken.type]) {
|
|
13913
|
+
this.defaults.extensions.childTokens[genericToken.type].forEach(childTokens => {
|
|
13914
|
+
const tokens = genericToken[childTokens].flat(Infinity);
|
|
13915
|
+
values = values.concat(this.walkTokens(tokens, callback));
|
|
13916
|
+
});
|
|
13917
|
+
} else if (genericToken.tokens) {
|
|
13918
|
+
values = values.concat(this.walkTokens(genericToken.tokens, callback));
|
|
13919
|
+
}
|
|
13920
|
+
}
|
|
13921
|
+
}
|
|
13922
|
+
}
|
|
13923
|
+
return values;
|
|
13924
|
+
}
|
|
13925
|
+
use() {
|
|
13926
|
+
const extensions = this.defaults.extensions || {
|
|
13927
|
+
renderers: {},
|
|
13928
|
+
childTokens: {}
|
|
13929
|
+
};
|
|
13930
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13931
|
+
args[_key] = arguments[_key];
|
|
13932
|
+
}
|
|
13933
|
+
args.forEach(pack => {
|
|
13934
|
+
// copy options to new object
|
|
13935
|
+
const opts = {
|
|
13936
|
+
...pack
|
|
13937
|
+
};
|
|
13938
|
+
// set async to true if it was set to true before
|
|
13939
|
+
opts.async = this.defaults.async || opts.async || false;
|
|
13940
|
+
// ==-- Parse "addon" extensions --== //
|
|
13941
|
+
if (pack.extensions) {
|
|
13942
|
+
pack.extensions.forEach(ext => {
|
|
13943
|
+
if (!ext.name) {
|
|
13944
|
+
throw new Error('extension name required');
|
|
13945
|
+
}
|
|
13946
|
+
if ('renderer' in ext) {
|
|
13947
|
+
// Renderer extensions
|
|
13948
|
+
const prevRenderer = extensions.renderers[ext.name];
|
|
13949
|
+
if (prevRenderer) {
|
|
13950
|
+
// Replace extension with func to run new extension but fall back if false
|
|
13951
|
+
extensions.renderers[ext.name] = function () {
|
|
13952
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
13953
|
+
args[_key2] = arguments[_key2];
|
|
13954
|
+
}
|
|
13955
|
+
let ret = ext.renderer.apply(this, args);
|
|
13956
|
+
if (ret === false) {
|
|
13957
|
+
ret = prevRenderer.apply(this, args);
|
|
13958
|
+
}
|
|
13959
|
+
return ret;
|
|
13960
|
+
};
|
|
13961
|
+
} else {
|
|
13962
|
+
extensions.renderers[ext.name] = ext.renderer;
|
|
13963
|
+
}
|
|
13964
|
+
}
|
|
13965
|
+
if ('tokenizer' in ext) {
|
|
13966
|
+
// Tokenizer Extensions
|
|
13967
|
+
if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') {
|
|
13968
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
13969
|
+
}
|
|
13970
|
+
const extLevel = extensions[ext.level];
|
|
13971
|
+
if (extLevel) {
|
|
13972
|
+
extLevel.unshift(ext.tokenizer);
|
|
13973
|
+
} else {
|
|
13974
|
+
extensions[ext.level] = [ext.tokenizer];
|
|
13975
|
+
}
|
|
13976
|
+
if (ext.start) {
|
|
13977
|
+
// Function to check for start of token
|
|
13978
|
+
if (ext.level === 'block') {
|
|
13979
|
+
if (extensions.startBlock) {
|
|
13980
|
+
extensions.startBlock.push(ext.start);
|
|
13981
|
+
} else {
|
|
13982
|
+
extensions.startBlock = [ext.start];
|
|
13983
|
+
}
|
|
13984
|
+
} else if (ext.level === 'inline') {
|
|
13985
|
+
if (extensions.startInline) {
|
|
13986
|
+
extensions.startInline.push(ext.start);
|
|
13987
|
+
} else {
|
|
13988
|
+
extensions.startInline = [ext.start];
|
|
13989
|
+
}
|
|
13990
|
+
}
|
|
13991
|
+
}
|
|
13992
|
+
}
|
|
13993
|
+
if ('childTokens' in ext && ext.childTokens) {
|
|
13994
|
+
// Child tokens to be visited by walkTokens
|
|
13995
|
+
extensions.childTokens[ext.name] = ext.childTokens;
|
|
13996
|
+
}
|
|
13997
|
+
});
|
|
13998
|
+
opts.extensions = extensions;
|
|
13999
|
+
}
|
|
14000
|
+
// ==-- Parse "overwrite" extensions --== //
|
|
14001
|
+
if (pack.renderer) {
|
|
14002
|
+
const renderer = this.defaults.renderer || new _Renderer(this.defaults);
|
|
14003
|
+
for (const prop in pack.renderer) {
|
|
14004
|
+
if (!(prop in renderer)) {
|
|
14005
|
+
throw new Error(`renderer '${prop}' does not exist`);
|
|
14006
|
+
}
|
|
14007
|
+
if (['options', 'parser'].includes(prop)) {
|
|
14008
|
+
// ignore options property
|
|
14009
|
+
continue;
|
|
14010
|
+
}
|
|
14011
|
+
const rendererProp = prop;
|
|
14012
|
+
const rendererFunc = pack.renderer[rendererProp];
|
|
14013
|
+
const prevRenderer = renderer[rendererProp];
|
|
14014
|
+
// Replace renderer with func to run extension, but fall back if false
|
|
14015
|
+
renderer[rendererProp] = function () {
|
|
14016
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
14017
|
+
args[_key3] = arguments[_key3];
|
|
14018
|
+
}
|
|
14019
|
+
let ret = rendererFunc.apply(renderer, args);
|
|
14020
|
+
if (ret === false) {
|
|
14021
|
+
ret = prevRenderer.apply(renderer, args);
|
|
14022
|
+
}
|
|
14023
|
+
return ret || '';
|
|
14024
|
+
};
|
|
14025
|
+
}
|
|
14026
|
+
opts.renderer = renderer;
|
|
14027
|
+
}
|
|
14028
|
+
if (pack.tokenizer) {
|
|
14029
|
+
const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
|
|
14030
|
+
for (const prop in pack.tokenizer) {
|
|
14031
|
+
if (!(prop in tokenizer)) {
|
|
14032
|
+
throw new Error(`tokenizer '${prop}' does not exist`);
|
|
14033
|
+
}
|
|
14034
|
+
if (['options', 'rules', 'lexer'].includes(prop)) {
|
|
14035
|
+
// ignore options, rules, and lexer properties
|
|
14036
|
+
continue;
|
|
14037
|
+
}
|
|
14038
|
+
const tokenizerProp = prop;
|
|
14039
|
+
const tokenizerFunc = pack.tokenizer[tokenizerProp];
|
|
14040
|
+
const prevTokenizer = tokenizer[tokenizerProp];
|
|
14041
|
+
// Replace tokenizer with func to run extension, but fall back if false
|
|
14042
|
+
// @ts-expect-error cannot type tokenizer function dynamically
|
|
14043
|
+
tokenizer[tokenizerProp] = function () {
|
|
14044
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
14045
|
+
args[_key4] = arguments[_key4];
|
|
14046
|
+
}
|
|
14047
|
+
let ret = tokenizerFunc.apply(tokenizer, args);
|
|
14048
|
+
if (ret === false) {
|
|
14049
|
+
ret = prevTokenizer.apply(tokenizer, args);
|
|
14050
|
+
}
|
|
14051
|
+
return ret;
|
|
14052
|
+
};
|
|
14053
|
+
}
|
|
14054
|
+
opts.tokenizer = tokenizer;
|
|
14055
|
+
}
|
|
14056
|
+
// ==-- Parse Hooks extensions --== //
|
|
14057
|
+
if (pack.hooks) {
|
|
14058
|
+
const hooks = this.defaults.hooks || new _Hooks();
|
|
14059
|
+
for (const prop in pack.hooks) {
|
|
14060
|
+
if (!(prop in hooks)) {
|
|
14061
|
+
throw new Error(`hook '${prop}' does not exist`);
|
|
14062
|
+
}
|
|
14063
|
+
if (['options', 'block'].includes(prop)) {
|
|
14064
|
+
// ignore options and block properties
|
|
14065
|
+
continue;
|
|
14066
|
+
}
|
|
14067
|
+
const hooksProp = prop;
|
|
14068
|
+
const hooksFunc = pack.hooks[hooksProp];
|
|
14069
|
+
const prevHook = hooks[hooksProp];
|
|
14070
|
+
if (_Hooks.passThroughHooks.has(prop)) {
|
|
14071
|
+
// @ts-expect-error cannot type hook function dynamically
|
|
14072
|
+
hooks[hooksProp] = arg => {
|
|
14073
|
+
if (this.defaults.async) {
|
|
14074
|
+
return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => {
|
|
14075
|
+
return prevHook.call(hooks, ret);
|
|
14076
|
+
});
|
|
14077
|
+
}
|
|
14078
|
+
const ret = hooksFunc.call(hooks, arg);
|
|
14079
|
+
return prevHook.call(hooks, ret);
|
|
14080
|
+
};
|
|
14081
|
+
} else {
|
|
14082
|
+
// @ts-expect-error cannot type hook function dynamically
|
|
14083
|
+
hooks[hooksProp] = function () {
|
|
14084
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
14085
|
+
args[_key5] = arguments[_key5];
|
|
14086
|
+
}
|
|
14087
|
+
let ret = hooksFunc.apply(hooks, args);
|
|
14088
|
+
if (ret === false) {
|
|
14089
|
+
ret = prevHook.apply(hooks, args);
|
|
14090
|
+
}
|
|
14091
|
+
return ret;
|
|
14092
|
+
};
|
|
14093
|
+
}
|
|
14094
|
+
}
|
|
14095
|
+
opts.hooks = hooks;
|
|
14096
|
+
}
|
|
14097
|
+
// ==-- Parse WalkTokens extensions --== //
|
|
14098
|
+
if (pack.walkTokens) {
|
|
14099
|
+
const walkTokens = this.defaults.walkTokens;
|
|
14100
|
+
const packWalktokens = pack.walkTokens;
|
|
14101
|
+
opts.walkTokens = function (token) {
|
|
14102
|
+
let values = [];
|
|
14103
|
+
values.push(packWalktokens.call(this, token));
|
|
14104
|
+
if (walkTokens) {
|
|
14105
|
+
values = values.concat(walkTokens.call(this, token));
|
|
14106
|
+
}
|
|
14107
|
+
return values;
|
|
14108
|
+
};
|
|
14109
|
+
}
|
|
14110
|
+
this.defaults = {
|
|
14111
|
+
...this.defaults,
|
|
14112
|
+
...opts
|
|
14113
|
+
};
|
|
14114
|
+
});
|
|
14115
|
+
return this;
|
|
14116
|
+
}
|
|
14117
|
+
setOptions(opt) {
|
|
14118
|
+
this.defaults = {
|
|
14119
|
+
...this.defaults,
|
|
14120
|
+
...opt
|
|
14121
|
+
};
|
|
14122
|
+
return this;
|
|
14123
|
+
}
|
|
14124
|
+
lexer(src, options) {
|
|
14125
|
+
return _Lexer.lex(src, options !== null && options !== void 0 ? options : this.defaults);
|
|
14126
|
+
}
|
|
14127
|
+
parser(tokens, options) {
|
|
14128
|
+
return _Parser.parse(tokens, options !== null && options !== void 0 ? options : this.defaults);
|
|
14129
|
+
}
|
|
14130
|
+
parseMarkdown(blockType) {
|
|
14131
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14132
|
+
const parse = (src, options) => {
|
|
14133
|
+
const origOpt = {
|
|
14134
|
+
...options
|
|
14135
|
+
};
|
|
14136
|
+
const opt = {
|
|
14137
|
+
...this.defaults,
|
|
14138
|
+
...origOpt
|
|
14139
|
+
};
|
|
14140
|
+
const throwError = this.onError(!!opt.silent, !!opt.async);
|
|
14141
|
+
// throw error if an extension set async to true but parse was called with async: false
|
|
14142
|
+
if (this.defaults.async === true && origOpt.async === false) {
|
|
14143
|
+
return throwError(new Error('marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.'));
|
|
14144
|
+
}
|
|
14145
|
+
// throw error in case of non string input
|
|
14146
|
+
if (typeof src === 'undefined' || src === null) {
|
|
14147
|
+
return throwError(new Error('marked(): input parameter is undefined or null'));
|
|
14148
|
+
}
|
|
14149
|
+
if (typeof src !== 'string') {
|
|
14150
|
+
return throwError(new Error('marked(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected'));
|
|
14151
|
+
}
|
|
14152
|
+
if (opt.hooks) {
|
|
14153
|
+
opt.hooks.options = opt;
|
|
14154
|
+
opt.hooks.block = blockType;
|
|
14155
|
+
}
|
|
14156
|
+
const lexer = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
|
|
14157
|
+
const parser = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
|
|
14158
|
+
if (opt.async) {
|
|
14159
|
+
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then(src => lexer(src, opt)).then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then(tokens => parser(tokens, opt)).then(html => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
|
|
14160
|
+
}
|
|
14161
|
+
try {
|
|
14162
|
+
if (opt.hooks) {
|
|
14163
|
+
src = opt.hooks.preprocess(src);
|
|
14164
|
+
}
|
|
14165
|
+
let tokens = lexer(src, opt);
|
|
14166
|
+
if (opt.hooks) {
|
|
14167
|
+
tokens = opt.hooks.processAllTokens(tokens);
|
|
14168
|
+
}
|
|
14169
|
+
if (opt.walkTokens) {
|
|
14170
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
14171
|
+
}
|
|
14172
|
+
let html = parser(tokens, opt);
|
|
14173
|
+
if (opt.hooks) {
|
|
14174
|
+
html = opt.hooks.postprocess(html);
|
|
14175
|
+
}
|
|
14176
|
+
return html;
|
|
14177
|
+
} catch (e) {
|
|
14178
|
+
return throwError(e);
|
|
14179
|
+
}
|
|
14180
|
+
};
|
|
14181
|
+
return parse;
|
|
14182
|
+
}
|
|
14183
|
+
onError(silent, async) {
|
|
14184
|
+
return e => {
|
|
14185
|
+
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
14186
|
+
if (silent) {
|
|
14187
|
+
const msg = '<p>An error occurred:</p><pre>' + escape$1(e.message + '', true) + '</pre>';
|
|
14188
|
+
if (async) {
|
|
14189
|
+
return Promise.resolve(msg);
|
|
14190
|
+
}
|
|
14191
|
+
return msg;
|
|
14192
|
+
}
|
|
14193
|
+
if (async) {
|
|
14194
|
+
return Promise.reject(e);
|
|
14195
|
+
}
|
|
14196
|
+
throw e;
|
|
14197
|
+
};
|
|
14198
|
+
}
|
|
14199
|
+
}
|
|
14200
|
+
const markedInstance = new Marked();
|
|
14201
|
+
function marked(src, opt) {
|
|
14202
|
+
return markedInstance.parse(src, opt);
|
|
14203
|
+
}
|
|
14204
|
+
/**
|
|
14205
|
+
* Sets the default options.
|
|
14206
|
+
*
|
|
14207
|
+
* @param options Hash of options
|
|
14208
|
+
*/
|
|
14209
|
+
marked.options = marked.setOptions = function (options) {
|
|
14210
|
+
markedInstance.setOptions(options);
|
|
14211
|
+
marked.defaults = markedInstance.defaults;
|
|
14212
|
+
changeDefaults(marked.defaults);
|
|
14213
|
+
return marked;
|
|
14214
|
+
};
|
|
14215
|
+
/**
|
|
14216
|
+
* Gets the original marked default options.
|
|
14217
|
+
*/
|
|
14218
|
+
marked.getDefaults = _getDefaults;
|
|
14219
|
+
marked.defaults = _defaults;
|
|
14220
|
+
/**
|
|
14221
|
+
* Use Extension
|
|
14222
|
+
*/
|
|
14223
|
+
marked.use = function () {
|
|
14224
|
+
markedInstance.use(...arguments);
|
|
14225
|
+
marked.defaults = markedInstance.defaults;
|
|
14226
|
+
changeDefaults(marked.defaults);
|
|
14227
|
+
return marked;
|
|
14228
|
+
};
|
|
14229
|
+
/**
|
|
14230
|
+
* Run callback for every token
|
|
14231
|
+
*/
|
|
14232
|
+
marked.walkTokens = function (tokens, callback) {
|
|
14233
|
+
return markedInstance.walkTokens(tokens, callback);
|
|
14234
|
+
};
|
|
14235
|
+
/**
|
|
14236
|
+
* Compiles markdown to HTML without enclosing `p` tag.
|
|
14237
|
+
*
|
|
14238
|
+
* @param src String of markdown source to be compiled
|
|
14239
|
+
* @param options Hash of options
|
|
14240
|
+
* @return String of compiled HTML
|
|
14241
|
+
*/
|
|
14242
|
+
marked.parseInline = markedInstance.parseInline;
|
|
14243
|
+
/**
|
|
14244
|
+
* Expose
|
|
14245
|
+
*/
|
|
14246
|
+
marked.Parser = _Parser;
|
|
14247
|
+
marked.parser = _Parser.parse;
|
|
14248
|
+
marked.Renderer = _Renderer;
|
|
14249
|
+
marked.TextRenderer = _TextRenderer;
|
|
14250
|
+
marked.Lexer = _Lexer;
|
|
14251
|
+
marked.lexer = _Lexer.lex;
|
|
14252
|
+
marked.Tokenizer = _Tokenizer;
|
|
14253
|
+
marked.Hooks = _Hooks;
|
|
14254
|
+
marked.parse = marked;
|
|
14255
|
+
const options = marked.options;
|
|
14256
|
+
const setOptions = marked.setOptions;
|
|
14257
|
+
const use = marked.use;
|
|
14258
|
+
const walkTokens = marked.walkTokens;
|
|
14259
|
+
const parseInline = marked.parseInline;
|
|
14260
|
+
const parse = (/* unused pure expression or super */ null && (marked));
|
|
14261
|
+
const parser = _Parser.parse;
|
|
14262
|
+
const lexer = _Lexer.lex;
|
|
14263
|
+
|
|
14264
|
+
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=script&lang=js
|
|
14265
|
+
|
|
14266
|
+
|
|
14267
|
+
|
|
14268
|
+
|
|
14269
|
+
|
|
14270
|
+
const controller = new AbortController();
|
|
14271
|
+
const signal = controller.signal;
|
|
14272
|
+
/* harmony default export */ var chatvue_type_script_lang_js = ({
|
|
14273
|
+
name: 'Chat',
|
|
14274
|
+
components: {
|
|
14275
|
+
ErrorChat: error_chat,
|
|
14276
|
+
ChatTools: chat_tools
|
|
14277
|
+
},
|
|
14278
|
+
props: {
|
|
14279
|
+
analyExercise: {},
|
|
14280
|
+
keyWord: {
|
|
14281
|
+
type: String,
|
|
14282
|
+
default: ''
|
|
14283
|
+
},
|
|
14284
|
+
resId: {
|
|
14285
|
+
type: String,
|
|
14286
|
+
default: ''
|
|
14287
|
+
},
|
|
14288
|
+
xtId: {
|
|
14289
|
+
type: String,
|
|
14290
|
+
default: ''
|
|
14291
|
+
}
|
|
14292
|
+
},
|
|
14293
|
+
data() {
|
|
14294
|
+
return {
|
|
14295
|
+
popover: false,
|
|
14296
|
+
input: '',
|
|
14297
|
+
errors: [],
|
|
14298
|
+
errorList: errorList,
|
|
14299
|
+
cacheKeyWord: '',
|
|
14300
|
+
// 由于外部需要快速清掉 keyword 但是存在重新发送请求的情况,因此需要一个混存记录
|
|
14301
|
+
messageData: [],
|
|
14302
|
+
chatId: '',
|
|
14303
|
+
// 对话id
|
|
14304
|
+
chatMajorId: '',
|
|
14305
|
+
finish: false
|
|
14306
|
+
};
|
|
14307
|
+
},
|
|
14308
|
+
computed: {
|
|
14309
|
+
canSubmit() {
|
|
14310
|
+
return this.errors.length === 0 && this.input === "";
|
|
14311
|
+
}
|
|
14312
|
+
},
|
|
14313
|
+
watch: {
|
|
14314
|
+
keyWord: {
|
|
14315
|
+
handler() {
|
|
14316
|
+
if (this.keyWord) {
|
|
14317
|
+
this.cacheKeyWord = this.keyWord;
|
|
14318
|
+
this.postMessage();
|
|
14319
|
+
}
|
|
14320
|
+
},
|
|
14321
|
+
immediate: true
|
|
14322
|
+
}
|
|
14323
|
+
},
|
|
14324
|
+
methods: {
|
|
14325
|
+
cancelPopover() {
|
|
14326
|
+
this.popover = false;
|
|
14327
|
+
},
|
|
14328
|
+
openPopover() {
|
|
14329
|
+
this.popover = true;
|
|
14330
|
+
},
|
|
14331
|
+
scrollToBottom() {
|
|
14332
|
+
this.$refs.chatContainer.scrollTop = this.$refs.chatContainer.scrollHeight;
|
|
14333
|
+
},
|
|
14334
|
+
async postMessage(list, commonKey, parentMsgId) {
|
|
14335
|
+
let reanswerParams = {};
|
|
14336
|
+
this.finish = false;
|
|
14337
|
+
if (list) {
|
|
14338
|
+
list.sending = true;
|
|
14339
|
+
reanswerParams = {
|
|
14340
|
+
reStatus: 1,
|
|
14341
|
+
parentMsgId: list.parentMsgId,
|
|
14342
|
+
msgId: list.msgId,
|
|
14343
|
+
content: this.messageData[list.index - 1].message
|
|
14344
|
+
};
|
|
14345
|
+
this.messageData[list.index].message = '';
|
|
14346
|
+
this.messageData[list.index].cacheMessage = '';
|
|
14347
|
+
this.makeAutoMessage();
|
|
14348
|
+
}
|
|
14349
|
+
const params = {
|
|
14350
|
+
messageList: [{
|
|
14351
|
+
content: this.keyWord || this.cacheKeyWord,
|
|
14352
|
+
resId: this.resId,
|
|
14353
|
+
chatId: this.chatId || undefined,
|
|
14354
|
+
commonKey: commonKey || false,
|
|
14355
|
+
parentMsgId: parentMsgId || undefined,
|
|
14356
|
+
xtId: this.analyExercise.busId,
|
|
14357
|
+
...reanswerParams
|
|
14358
|
+
}]
|
|
14359
|
+
};
|
|
14360
|
+
// list 存在说明是重新生成
|
|
14361
|
+
if (!list && !commonKey) {
|
|
14362
|
+
const userWord = this.keyWord || this.cacheKeyWord;
|
|
14363
|
+
this.messageData.push({
|
|
14364
|
+
type: 'user',
|
|
14365
|
+
message: userWord.replace(/\n/g, '<br>')
|
|
14366
|
+
});
|
|
14367
|
+
setTimeout(() => {
|
|
14368
|
+
this.messageData.push({
|
|
14369
|
+
type: 'robot',
|
|
14370
|
+
message: '',
|
|
14371
|
+
cacheMessage: '',
|
|
14372
|
+
zan: false,
|
|
14373
|
+
cai: false,
|
|
14374
|
+
stop: false,
|
|
14375
|
+
finish: false,
|
|
14376
|
+
sending: true,
|
|
14377
|
+
links: [],
|
|
14378
|
+
connectUrl: [],
|
|
14379
|
+
reAnswerCount: 0
|
|
14380
|
+
});
|
|
14381
|
+
this.makeAutoMessage();
|
|
14382
|
+
});
|
|
14383
|
+
}
|
|
14384
|
+
await sendMessageEventSource(params, signal, res => {
|
|
14385
|
+
this.makeMessageLine(res, list);
|
|
14386
|
+
});
|
|
14387
|
+
},
|
|
14388
|
+
makeAutoMessage() {
|
|
14389
|
+
const cacheMessage = [];
|
|
14390
|
+
for (let i = 0; i < this.messageData.length; i++) {
|
|
14391
|
+
const current = this.messageData[i];
|
|
14392
|
+
cacheMessage.push({
|
|
14393
|
+
role: current.type === 'robot' ? 'assistant' : 'user',
|
|
14394
|
+
content: current.message || '正在思考中。'
|
|
14395
|
+
});
|
|
14396
|
+
}
|
|
14397
|
+
this.makeAutoQuestioning(cacheMessage);
|
|
14398
|
+
},
|
|
14399
|
+
makeMessageLine(res, list) {
|
|
14400
|
+
const {
|
|
14401
|
+
content,
|
|
14402
|
+
status,
|
|
14403
|
+
chatId,
|
|
14404
|
+
msgId,
|
|
14405
|
+
parentMsgId,
|
|
11758
14406
|
reference,
|
|
11759
|
-
commonKey
|
|
14407
|
+
commonKey,
|
|
14408
|
+
connectUrl
|
|
11760
14409
|
} = JSON.parse(res.data);
|
|
11761
14410
|
let index = list ? list.index : this.messageData.length - 1;
|
|
11762
14411
|
const currentList = this.messageData[index];
|
|
14412
|
+
let allIdWithStart = true;
|
|
11763
14413
|
// 结束标识
|
|
11764
14414
|
if (status === 2 || status === 1) {
|
|
11765
14415
|
if (commonKey) {
|
|
@@ -11770,12 +14420,23 @@ const signal = controller.signal;
|
|
|
11770
14420
|
currentList.finish = true;
|
|
11771
14421
|
if (reference) {
|
|
11772
14422
|
currentList.links = JSON.parse(reference);
|
|
14423
|
+
currentList.links.map(item => {
|
|
14424
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
14425
|
+
allIdWithStart = false;
|
|
14426
|
+
}
|
|
14427
|
+
});
|
|
11773
14428
|
}
|
|
14429
|
+
if (connectUrl) {
|
|
14430
|
+
currentList.connectUrl = JSON.parse(connectUrl);
|
|
14431
|
+
}
|
|
14432
|
+
currentList.allIdWithStart = allIdWithStart;
|
|
11774
14433
|
this.cacheKeyWord = '';
|
|
14434
|
+
this.finish = true;
|
|
11775
14435
|
this.$emit('on-message-finish', chatId);
|
|
11776
14436
|
return;
|
|
11777
14437
|
}
|
|
11778
|
-
currentList.
|
|
14438
|
+
currentList.cacheMessage += content;
|
|
14439
|
+
currentList.message = marked.parse(currentList.cacheMessage);
|
|
11779
14440
|
currentList.msgId = msgId;
|
|
11780
14441
|
currentList.parentMsgId = parentMsgId;
|
|
11781
14442
|
currentList.chatId = chatId;
|
|
@@ -11785,9 +14446,26 @@ const signal = controller.signal;
|
|
|
11785
14446
|
// 防止出现调用基础模型前导致停止回答id错误
|
|
11786
14447
|
setTimeout(() => currentList.sending = false, 500);
|
|
11787
14448
|
},
|
|
14449
|
+
async makeAutoQuestioning(messages) {
|
|
14450
|
+
// 首次不触发
|
|
14451
|
+
if (messages.length <= 2) return;
|
|
14452
|
+
const autoRes = await getAutoQuestioning(this.chatMajorId, messages);
|
|
14453
|
+
const {
|
|
14454
|
+
message: {
|
|
14455
|
+
content: {
|
|
14456
|
+
followUps
|
|
14457
|
+
}
|
|
14458
|
+
}
|
|
14459
|
+
} = autoRes;
|
|
14460
|
+
this.messageData[this.messageData.length - 1].followUps = followUps.length > 3 ? followUps.splice(0, 3) : followUps;
|
|
14461
|
+
},
|
|
11788
14462
|
onStopChat(list) {
|
|
11789
14463
|
this.$emit('on-message-finish', list.chatId);
|
|
11790
14464
|
},
|
|
14465
|
+
selectModule(message) {
|
|
14466
|
+
this.cacheKeyWord = message;
|
|
14467
|
+
this.postMessage();
|
|
14468
|
+
},
|
|
11791
14469
|
async clearChat() {
|
|
11792
14470
|
if (this.messageData.length < 1) {
|
|
11793
14471
|
this.$message.warning('当前对话为最新对话');
|
|
@@ -11802,28 +14480,39 @@ const signal = controller.signal;
|
|
|
11802
14480
|
list.stop = false;
|
|
11803
14481
|
list.finish = false;
|
|
11804
14482
|
list.links = [];
|
|
14483
|
+
list.connectUrl = [];
|
|
11805
14484
|
this.postMessage(list);
|
|
11806
14485
|
this.$emit('on-reanser');
|
|
11807
14486
|
},
|
|
11808
14487
|
errorChatInit(list, chatId) {
|
|
11809
|
-
const {
|
|
11810
|
-
chatMajorId
|
|
11811
|
-
} = list[0];
|
|
11812
|
-
this.chatMajorId = chatMajorId.toString();
|
|
11813
14488
|
if (list && list[0].contents) {
|
|
14489
|
+
const {
|
|
14490
|
+
chatMajorId
|
|
14491
|
+
} = list[0];
|
|
14492
|
+
this.chatMajorId = chatMajorId && chatMajorId.toString();
|
|
11814
14493
|
const cacheArray = [];
|
|
11815
14494
|
list[0].contents.reverse().map(list => {
|
|
14495
|
+
let allIdWithStart = true;
|
|
14496
|
+
if (this.chatMajorId && list.references) {
|
|
14497
|
+
list.references.map(item => {
|
|
14498
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
14499
|
+
allIdWithStart = false;
|
|
14500
|
+
}
|
|
14501
|
+
});
|
|
14502
|
+
}
|
|
11816
14503
|
const obj = {
|
|
11817
14504
|
type: list.role === 'assistant' ? 'robot' : 'user',
|
|
11818
|
-
message: list.content.replace(/\n/g, '<br>'),
|
|
14505
|
+
message: list.role === 'assistant' ? marked.parse(list.content) : list.content.replace(/\n/g, '<br>'),
|
|
11819
14506
|
zan: list.type === 1,
|
|
11820
14507
|
cai: list.type === 2,
|
|
11821
14508
|
stop: list.status === 1,
|
|
11822
14509
|
finish: true,
|
|
11823
14510
|
links: list.references || [],
|
|
14511
|
+
connectUrl: list.connectUrls || [],
|
|
11824
14512
|
reAnswerCount: 0,
|
|
11825
14513
|
msgId: list.contentId,
|
|
11826
|
-
parentMsgId: list.parentMsgId
|
|
14514
|
+
parentMsgId: list.parentMsgId,
|
|
14515
|
+
allIdWithStart
|
|
11827
14516
|
};
|
|
11828
14517
|
cacheArray.push(obj);
|
|
11829
14518
|
});
|
|
@@ -11837,10 +14526,10 @@ const signal = controller.signal;
|
|
|
11837
14526
|
});
|
|
11838
14527
|
;// CONCATENATED MODULE: ./components/demo/src/chat.vue?vue&type=script&lang=js
|
|
11839
14528
|
/* harmony default export */ var src_chatvue_type_script_lang_js = (chatvue_type_script_lang_js);
|
|
11840
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=style&index=0&id=
|
|
14529
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat.vue?vue&type=style&index=0&id=d21026be&prod&lang=scss&scoped=true
|
|
11841
14530
|
// extracted by mini-css-extract-plugin
|
|
11842
14531
|
|
|
11843
|
-
;// CONCATENATED MODULE: ./components/demo/src/chat.vue?vue&type=style&index=0&id=
|
|
14532
|
+
;// CONCATENATED MODULE: ./components/demo/src/chat.vue?vue&type=style&index=0&id=d21026be&prod&lang=scss&scoped=true
|
|
11844
14533
|
|
|
11845
14534
|
;// CONCATENATED MODULE: ./components/demo/src/chat.vue
|
|
11846
14535
|
|
|
@@ -11853,11 +14542,11 @@ const signal = controller.signal;
|
|
|
11853
14542
|
|
|
11854
14543
|
var chat_component = normalizeComponent(
|
|
11855
14544
|
src_chatvue_type_script_lang_js,
|
|
11856
|
-
|
|
11857
|
-
|
|
14545
|
+
chatvue_type_template_id_d21026be_scoped_true_render,
|
|
14546
|
+
chatvue_type_template_id_d21026be_scoped_true_staticRenderFns,
|
|
11858
14547
|
false,
|
|
11859
14548
|
null,
|
|
11860
|
-
"
|
|
14549
|
+
"d21026be",
|
|
11861
14550
|
null
|
|
11862
14551
|
|
|
11863
14552
|
)
|
|
@@ -11866,14 +14555,14 @@ var chat_component = normalizeComponent(
|
|
|
11866
14555
|
;// CONCATENATED MODULE: ./node_modules/js-cookie/dist/js.cookie.mjs
|
|
11867
14556
|
/*! js-cookie v3.0.5 | MIT */
|
|
11868
14557
|
/* eslint-disable no-var */
|
|
11869
|
-
function js_cookie_assign(target) {
|
|
14558
|
+
function js_cookie_assign (target) {
|
|
11870
14559
|
for (var i = 1; i < arguments.length; i++) {
|
|
11871
14560
|
var source = arguments[i];
|
|
11872
14561
|
for (var key in source) {
|
|
11873
14562
|
target[key] = source[key];
|
|
11874
14563
|
}
|
|
11875
14564
|
}
|
|
11876
|
-
return target
|
|
14565
|
+
return target
|
|
11877
14566
|
}
|
|
11878
14567
|
/* eslint-enable no-var */
|
|
11879
14568
|
|
|
@@ -11883,37 +14572,48 @@ var defaultConverter = {
|
|
|
11883
14572
|
if (value[0] === '"') {
|
|
11884
14573
|
value = value.slice(1, -1);
|
|
11885
14574
|
}
|
|
11886
|
-
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
14575
|
+
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
11887
14576
|
},
|
|
11888
14577
|
write: function (value) {
|
|
11889
|
-
return encodeURIComponent(value).replace(
|
|
14578
|
+
return encodeURIComponent(value).replace(
|
|
14579
|
+
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
14580
|
+
decodeURIComponent
|
|
14581
|
+
)
|
|
11890
14582
|
}
|
|
11891
14583
|
};
|
|
11892
14584
|
/* eslint-enable no-var */
|
|
11893
14585
|
|
|
11894
14586
|
/* eslint-disable no-var */
|
|
11895
14587
|
|
|
11896
|
-
function init(converter, defaultAttributes) {
|
|
11897
|
-
function set(name, value, attributes) {
|
|
14588
|
+
function init (converter, defaultAttributes) {
|
|
14589
|
+
function set (name, value, attributes) {
|
|
11898
14590
|
if (typeof document === 'undefined') {
|
|
11899
|
-
return
|
|
14591
|
+
return
|
|
11900
14592
|
}
|
|
14593
|
+
|
|
11901
14594
|
attributes = js_cookie_assign({}, defaultAttributes, attributes);
|
|
14595
|
+
|
|
11902
14596
|
if (typeof attributes.expires === 'number') {
|
|
11903
14597
|
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
|
11904
14598
|
}
|
|
11905
14599
|
if (attributes.expires) {
|
|
11906
14600
|
attributes.expires = attributes.expires.toUTCString();
|
|
11907
14601
|
}
|
|
11908
|
-
|
|
14602
|
+
|
|
14603
|
+
name = encodeURIComponent(name)
|
|
14604
|
+
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
14605
|
+
.replace(/[()]/g, escape);
|
|
14606
|
+
|
|
11909
14607
|
var stringifiedAttributes = '';
|
|
11910
14608
|
for (var attributeName in attributes) {
|
|
11911
14609
|
if (!attributes[attributeName]) {
|
|
11912
|
-
continue
|
|
14610
|
+
continue
|
|
11913
14611
|
}
|
|
14612
|
+
|
|
11914
14613
|
stringifiedAttributes += '; ' + attributeName;
|
|
14614
|
+
|
|
11915
14615
|
if (attributes[attributeName] === true) {
|
|
11916
|
-
continue
|
|
14616
|
+
continue
|
|
11917
14617
|
}
|
|
11918
14618
|
|
|
11919
14619
|
// Considers RFC 6265 section 5.2:
|
|
@@ -11925,11 +14625,14 @@ function init(converter, defaultAttributes) {
|
|
|
11925
14625
|
// ...
|
|
11926
14626
|
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
11927
14627
|
}
|
|
11928
|
-
|
|
14628
|
+
|
|
14629
|
+
return (document.cookie =
|
|
14630
|
+
name + '=' + converter.write(value, name) + stringifiedAttributes)
|
|
11929
14631
|
}
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
14632
|
+
|
|
14633
|
+
function get (name) {
|
|
14634
|
+
if (typeof document === 'undefined' || (arguments.length && !name)) {
|
|
14635
|
+
return
|
|
11933
14636
|
}
|
|
11934
14637
|
|
|
11935
14638
|
// To prevent the for loop in the first place assign an empty array
|
|
@@ -11939,45 +14642,52 @@ function init(converter, defaultAttributes) {
|
|
|
11939
14642
|
for (var i = 0; i < cookies.length; i++) {
|
|
11940
14643
|
var parts = cookies[i].split('=');
|
|
11941
14644
|
var value = parts.slice(1).join('=');
|
|
14645
|
+
|
|
11942
14646
|
try {
|
|
11943
14647
|
var found = decodeURIComponent(parts[0]);
|
|
11944
14648
|
jar[found] = converter.read(value, found);
|
|
14649
|
+
|
|
11945
14650
|
if (name === found) {
|
|
11946
|
-
break
|
|
14651
|
+
break
|
|
11947
14652
|
}
|
|
11948
14653
|
} catch (e) {}
|
|
11949
14654
|
}
|
|
11950
|
-
|
|
14655
|
+
|
|
14656
|
+
return name ? jar[name] : jar
|
|
11951
14657
|
}
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
|
|
11955
|
-
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
|
|
11968
|
-
|
|
14658
|
+
|
|
14659
|
+
return Object.create(
|
|
14660
|
+
{
|
|
14661
|
+
set,
|
|
14662
|
+
get,
|
|
14663
|
+
remove: function (name, attributes) {
|
|
14664
|
+
set(
|
|
14665
|
+
name,
|
|
14666
|
+
'',
|
|
14667
|
+
js_cookie_assign({}, attributes, {
|
|
14668
|
+
expires: -1
|
|
14669
|
+
})
|
|
14670
|
+
);
|
|
14671
|
+
},
|
|
14672
|
+
withAttributes: function (attributes) {
|
|
14673
|
+
return init(this.converter, js_cookie_assign({}, this.attributes, attributes))
|
|
14674
|
+
},
|
|
14675
|
+
withConverter: function (converter) {
|
|
14676
|
+
return init(js_cookie_assign({}, this.converter, converter), this.attributes)
|
|
14677
|
+
}
|
|
11969
14678
|
},
|
|
11970
|
-
|
|
11971
|
-
value: Object.freeze(
|
|
14679
|
+
{
|
|
14680
|
+
attributes: { value: Object.freeze(defaultAttributes) },
|
|
14681
|
+
converter: { value: Object.freeze(converter) }
|
|
11972
14682
|
}
|
|
11973
|
-
|
|
14683
|
+
)
|
|
11974
14684
|
}
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
});
|
|
14685
|
+
|
|
14686
|
+
var api = init(defaultConverter, { path: '/' });
|
|
11978
14687
|
/* eslint-enable no-var */
|
|
11979
14688
|
|
|
11980
14689
|
|
|
14690
|
+
|
|
11981
14691
|
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=script&lang=js
|
|
11982
14692
|
|
|
11983
14693
|
|
|
@@ -12000,13 +14710,29 @@ var api = init(defaultConverter, {
|
|
|
12000
14710
|
return this.analyExercise.busId;
|
|
12001
14711
|
}
|
|
12002
14712
|
},
|
|
14713
|
+
watch: {
|
|
14714
|
+
visible() {
|
|
14715
|
+
if (this.visible) {
|
|
14716
|
+
checkCourseIdIsExist(this.resId).then(res => {
|
|
14717
|
+
if (res.flag === true) {
|
|
14718
|
+
this.courseFlag = true;
|
|
14719
|
+
} else {
|
|
14720
|
+
this.courseFlag = false;
|
|
14721
|
+
this.message = res.message;
|
|
14722
|
+
}
|
|
14723
|
+
});
|
|
14724
|
+
}
|
|
14725
|
+
}
|
|
14726
|
+
},
|
|
12003
14727
|
data() {
|
|
12004
14728
|
return {
|
|
12005
14729
|
aiMessage: '',
|
|
12006
14730
|
// 页面显示值
|
|
12007
14731
|
aiMessageKeyWord: '',
|
|
12008
14732
|
// 传入组件值
|
|
12009
|
-
stop: false
|
|
14733
|
+
stop: false,
|
|
14734
|
+
courseFlag: false,
|
|
14735
|
+
message: ''
|
|
12010
14736
|
};
|
|
12011
14737
|
},
|
|
12012
14738
|
mounted() {
|
|
@@ -12066,10 +14792,10 @@ var api = init(defaultConverter, {
|
|
|
12066
14792
|
});
|
|
12067
14793
|
;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=script&lang=js
|
|
12068
14794
|
/* harmony default export */ var src_mainvue_type_script_lang_js = (mainvue_type_script_lang_js);
|
|
12069
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=style&index=0&id=
|
|
14795
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-64.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-64.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-64.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-64.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/main.vue?vue&type=style&index=0&id=4661f078&prod&lang=scss&scoped=true
|
|
12070
14796
|
// extracted by mini-css-extract-plugin
|
|
12071
14797
|
|
|
12072
|
-
;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=style&index=0&id=
|
|
14798
|
+
;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=style&index=0&id=4661f078&prod&lang=scss&scoped=true
|
|
12073
14799
|
|
|
12074
14800
|
;// CONCATENATED MODULE: ./components/demo/src/main.vue
|
|
12075
14801
|
|
|
@@ -12086,7 +14812,7 @@ var main_component = normalizeComponent(
|
|
|
12086
14812
|
staticRenderFns,
|
|
12087
14813
|
false,
|
|
12088
14814
|
null,
|
|
12089
|
-
"
|
|
14815
|
+
"4661f078",
|
|
12090
14816
|
null
|
|
12091
14817
|
|
|
12092
14818
|
)
|