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