ai-assistant-pro 0.0.7 → 0.0.9
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 -3
- package/components/demo/src/chat-tools.vue +17 -2
- package/components/demo/src/chat.vue +129 -28
- package/components/demo/src/hot-search.vue +41 -18
- package/components/demo/src/main.vue +22 -4
- package/components/demo/utils/config.js +16 -11
- package/components/demo/utils/request.js +10 -8
- package/dist/ai-assistant-pro.common.js +3345 -613
- package/dist/ai-assistant-pro.common.js.map +1 -1
- package/dist/ai-assistant-pro.css +1 -1
- package/dist/ai-assistant-pro.umd.js +3344 -612
- package/dist/ai-assistant-pro.umd.js.map +1 -1
- package/dist/ai-assistant-pro.umd.min.js +4 -4
- package/dist/ai-assistant-pro.umd.min.js.map +1 -1
- package/package.json +2 -1
|
@@ -7411,7 +7411,7 @@ __webpack_require__.d(common_utils_namespaceObject, {
|
|
|
7411
7411
|
origin: function() { return origin; }
|
|
7412
7412
|
});
|
|
7413
7413
|
|
|
7414
|
-
;//
|
|
7414
|
+
;// ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
|
|
7415
7415
|
/* eslint-disable no-var */
|
|
7416
7416
|
// This file is imported into lib/wc client bundles.
|
|
7417
7417
|
|
|
@@ -7428,7 +7428,7 @@ if (typeof window !== 'undefined') {
|
|
|
7428
7428
|
// Indicate to webpack that this file can be concatenated
|
|
7429
7429
|
/* harmony default export */ var setPublicPath = (null);
|
|
7430
7430
|
|
|
7431
|
-
;//
|
|
7431
|
+
;// ./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=4903e526&scoped=true
|
|
7432
7432
|
var render = function render() {
|
|
7433
7433
|
var _vm = this,
|
|
7434
7434
|
_c = _vm._self._c;
|
|
@@ -7464,6 +7464,9 @@ var render = function render() {
|
|
|
7464
7464
|
})])]), _vm.courseFlag ? [_c('div', {
|
|
7465
7465
|
staticClass: "ai-main-content"
|
|
7466
7466
|
}, [!_vm.chatShow ? _c('hot-search', {
|
|
7467
|
+
attrs: {
|
|
7468
|
+
"resId": _vm.resId
|
|
7469
|
+
},
|
|
7467
7470
|
on: {
|
|
7468
7471
|
"select-module": _vm.selectModule
|
|
7469
7472
|
}
|
|
@@ -7471,6 +7474,7 @@ var render = function render() {
|
|
|
7471
7474
|
ref: "chatRef",
|
|
7472
7475
|
attrs: {
|
|
7473
7476
|
"resId": _vm.resId,
|
|
7477
|
+
"open-course-id": _vm.openCourseId,
|
|
7474
7478
|
"chatId": _vm.chatId,
|
|
7475
7479
|
"key-word": _vm.aiMessageKeyWord,
|
|
7476
7480
|
"message-data": _vm.messageList,
|
|
@@ -7535,239 +7539,43 @@ var render = function render() {
|
|
|
7535
7539
|
};
|
|
7536
7540
|
var staticRenderFns = [];
|
|
7537
7541
|
|
|
7538
|
-
;//
|
|
7542
|
+
;// ./components/demo/src/main.vue?vue&type=template&id=4903e526&scoped=true
|
|
7539
7543
|
|
|
7540
|
-
;//
|
|
7541
|
-
var
|
|
7544
|
+
;// ./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/hot-search.vue?vue&type=template&id=abf2ffc4&scoped=true
|
|
7545
|
+
var hot_searchvue_type_template_id_abf2ffc4_scoped_true_render = function render() {
|
|
7542
7546
|
var _vm = this,
|
|
7543
7547
|
_c = _vm._self._c;
|
|
7544
|
-
return
|
|
7548
|
+
return _c('div', {
|
|
7549
|
+
staticClass: "hot-search-contain"
|
|
7550
|
+
}, [_vm._m(0), _c('div', {
|
|
7551
|
+
staticClass: "robot-message"
|
|
7552
|
+
}, [_vm.prologue ? [_vm._v(" " + _vm._s(_vm.prologue) + " ")] : [_c('p', [_vm._v("Hi,我是学习助手。")]), _c('p', [_vm._v("在这里你可以获得专业、准确的课程讲解,包括对公式的深入理解和细腻的解答。")])], _vm._l(_vm.aiMessage, function (list, index) {
|
|
7553
|
+
return _c('div', {
|
|
7554
|
+
key: index,
|
|
7555
|
+
staticClass: "hot-list",
|
|
7556
|
+
on: {
|
|
7557
|
+
"click": function ($event) {
|
|
7558
|
+
return _vm.selectModule(list);
|
|
7559
|
+
}
|
|
7560
|
+
}
|
|
7561
|
+
}, [_vm._v(" " + _vm._s(list) + " "), _c('i', {
|
|
7562
|
+
staticClass: "el-icon-arrow-right go-icon"
|
|
7563
|
+
})]);
|
|
7564
|
+
})], 2)]);
|
|
7545
7565
|
};
|
|
7546
|
-
var
|
|
7566
|
+
var hot_searchvue_type_template_id_abf2ffc4_scoped_true_staticRenderFns = [function () {
|
|
7547
7567
|
var _vm = this,
|
|
7548
7568
|
_c = _vm._self._c;
|
|
7549
7569
|
return _c('div', {
|
|
7550
|
-
staticClass: "hot-search-contain"
|
|
7551
|
-
}, [_c('div', {
|
|
7552
7570
|
staticClass: "robot"
|
|
7553
7571
|
}, [_c('div', {
|
|
7554
7572
|
staticClass: "robot-image-div"
|
|
7555
|
-
})])
|
|
7556
|
-
staticClass: "robot-message"
|
|
7557
|
-
}, [_c('p', [_vm._v("Hi,我是学习助手。")]), _c('p', [_vm._v("在这里你可以获得专业、准确的课程讲解,包括对公式的深入理解和细腻的解答。")])])]);
|
|
7573
|
+
})]);
|
|
7558
7574
|
}];
|
|
7559
7575
|
|
|
7560
|
-
;//
|
|
7561
|
-
|
|
7562
|
-
;// 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/hot-search.vue?vue&type=script&lang=js
|
|
7563
|
-
/* harmony default export */ var hot_searchvue_type_script_lang_js = ({
|
|
7564
|
-
name: 'HotSearch',
|
|
7565
|
-
data() {
|
|
7566
|
-
return {
|
|
7567
|
-
aiMessage: [{
|
|
7568
|
-
value: '请解释一下牛顿第二定律的公式和物理意义。',
|
|
7569
|
-
id: 1
|
|
7570
|
-
}, {
|
|
7571
|
-
value: '电磁感应定律是如何描述的?请给出相关公式并解释。',
|
|
7572
|
-
id: 2
|
|
7573
|
-
}, {
|
|
7574
|
-
value: '在光学中,光的干涉现象是如何产生的?能否用公式来表示?',
|
|
7575
|
-
id: 3
|
|
7576
|
-
}]
|
|
7577
|
-
};
|
|
7578
|
-
},
|
|
7579
|
-
methods: {
|
|
7580
|
-
selectModule(list) {
|
|
7581
|
-
this.$emit('select-module', list);
|
|
7582
|
-
}
|
|
7583
|
-
}
|
|
7584
|
-
});
|
|
7585
|
-
;// CONCATENATED MODULE: ./components/demo/src/hot-search.vue?vue&type=script&lang=js
|
|
7586
|
-
/* harmony default export */ var src_hot_searchvue_type_script_lang_js = (hot_searchvue_type_script_lang_js);
|
|
7587
|
-
;// 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/hot-search.vue?vue&type=style&index=0&id=73bfe44c&prod&lang=scss&scoped=true
|
|
7588
|
-
// extracted by mini-css-extract-plugin
|
|
7589
|
-
|
|
7590
|
-
;// CONCATENATED MODULE: ./components/demo/src/hot-search.vue?vue&type=style&index=0&id=73bfe44c&prod&lang=scss&scoped=true
|
|
7591
|
-
|
|
7592
|
-
;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
|
|
7593
|
-
/* globals __VUE_SSR_CONTEXT__ */
|
|
7594
|
-
|
|
7595
|
-
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
|
|
7596
|
-
// This module is a runtime utility for cleaner component module output and will
|
|
7597
|
-
// be included in the final webpack user bundle.
|
|
7598
|
-
|
|
7599
|
-
function normalizeComponent(
|
|
7600
|
-
scriptExports,
|
|
7601
|
-
render,
|
|
7602
|
-
staticRenderFns,
|
|
7603
|
-
functionalTemplate,
|
|
7604
|
-
injectStyles,
|
|
7605
|
-
scopeId,
|
|
7606
|
-
moduleIdentifier /* server only */,
|
|
7607
|
-
shadowMode /* vue-cli only */
|
|
7608
|
-
) {
|
|
7609
|
-
// Vue.extend constructor export interop
|
|
7610
|
-
var options =
|
|
7611
|
-
typeof scriptExports === 'function' ? scriptExports.options : scriptExports
|
|
7612
|
-
|
|
7613
|
-
// render functions
|
|
7614
|
-
if (render) {
|
|
7615
|
-
options.render = render
|
|
7616
|
-
options.staticRenderFns = staticRenderFns
|
|
7617
|
-
options._compiled = true
|
|
7618
|
-
}
|
|
7619
|
-
|
|
7620
|
-
// functional template
|
|
7621
|
-
if (functionalTemplate) {
|
|
7622
|
-
options.functional = true
|
|
7623
|
-
}
|
|
7624
|
-
|
|
7625
|
-
// scopedId
|
|
7626
|
-
if (scopeId) {
|
|
7627
|
-
options._scopeId = 'data-v-' + scopeId
|
|
7628
|
-
}
|
|
7629
|
-
|
|
7630
|
-
var hook
|
|
7631
|
-
if (moduleIdentifier) {
|
|
7632
|
-
// server build
|
|
7633
|
-
hook = function (context) {
|
|
7634
|
-
// 2.3 injection
|
|
7635
|
-
context =
|
|
7636
|
-
context || // cached call
|
|
7637
|
-
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
7638
|
-
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
|
|
7639
|
-
// 2.2 with runInNewContext: true
|
|
7640
|
-
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
7641
|
-
context = __VUE_SSR_CONTEXT__
|
|
7642
|
-
}
|
|
7643
|
-
// inject component styles
|
|
7644
|
-
if (injectStyles) {
|
|
7645
|
-
injectStyles.call(this, context)
|
|
7646
|
-
}
|
|
7647
|
-
// register component module identifier for async chunk inferrence
|
|
7648
|
-
if (context && context._registeredComponents) {
|
|
7649
|
-
context._registeredComponents.add(moduleIdentifier)
|
|
7650
|
-
}
|
|
7651
|
-
}
|
|
7652
|
-
// used by ssr in case component is cached and beforeCreate
|
|
7653
|
-
// never gets called
|
|
7654
|
-
options._ssrRegister = hook
|
|
7655
|
-
} else if (injectStyles) {
|
|
7656
|
-
hook = shadowMode
|
|
7657
|
-
? function () {
|
|
7658
|
-
injectStyles.call(
|
|
7659
|
-
this,
|
|
7660
|
-
(options.functional ? this.parent : this).$root.$options.shadowRoot
|
|
7661
|
-
)
|
|
7662
|
-
}
|
|
7663
|
-
: injectStyles
|
|
7664
|
-
}
|
|
7665
|
-
|
|
7666
|
-
if (hook) {
|
|
7667
|
-
if (options.functional) {
|
|
7668
|
-
// for template-only hot-reload because in that case the render fn doesn't
|
|
7669
|
-
// go through the normalizer
|
|
7670
|
-
options._injectStyles = hook
|
|
7671
|
-
// register for functional component in vue file
|
|
7672
|
-
var originalRender = options.render
|
|
7673
|
-
options.render = function renderWithStyleInjection(h, context) {
|
|
7674
|
-
hook.call(context)
|
|
7675
|
-
return originalRender(h, context)
|
|
7676
|
-
}
|
|
7677
|
-
} else {
|
|
7678
|
-
// inject component registration as beforeCreate hook
|
|
7679
|
-
var existing = options.beforeCreate
|
|
7680
|
-
options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
|
|
7681
|
-
}
|
|
7682
|
-
}
|
|
7683
|
-
|
|
7684
|
-
return {
|
|
7685
|
-
exports: scriptExports,
|
|
7686
|
-
options: options
|
|
7687
|
-
}
|
|
7688
|
-
}
|
|
7689
|
-
|
|
7690
|
-
;// CONCATENATED MODULE: ./components/demo/src/hot-search.vue
|
|
7691
|
-
|
|
7576
|
+
;// ./components/demo/src/hot-search.vue?vue&type=template&id=abf2ffc4&scoped=true
|
|
7692
7577
|
|
|
7693
|
-
|
|
7694
|
-
;
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
/* normalize component */
|
|
7698
|
-
|
|
7699
|
-
var component = normalizeComponent(
|
|
7700
|
-
src_hot_searchvue_type_script_lang_js,
|
|
7701
|
-
hot_searchvue_type_template_id_73bfe44c_scoped_true_render,
|
|
7702
|
-
hot_searchvue_type_template_id_73bfe44c_scoped_true_staticRenderFns,
|
|
7703
|
-
false,
|
|
7704
|
-
null,
|
|
7705
|
-
"73bfe44c",
|
|
7706
|
-
null
|
|
7707
|
-
|
|
7708
|
-
)
|
|
7709
|
-
|
|
7710
|
-
/* harmony default export */ var hot_search = (component.exports);
|
|
7711
|
-
;// 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=1abfa6ce&scoped=true
|
|
7712
|
-
var chatvue_type_template_id_1abfa6ce_scoped_true_render = function render() {
|
|
7713
|
-
var _vm = this,
|
|
7714
|
-
_c = _vm._self._c;
|
|
7715
|
-
return _c('div', {
|
|
7716
|
-
ref: "chatContainer",
|
|
7717
|
-
staticClass: "chat-contain"
|
|
7718
|
-
}, _vm._l(_vm.messageData, function (list, index) {
|
|
7719
|
-
return _c('div', {
|
|
7720
|
-
key: index,
|
|
7721
|
-
staticClass: "message",
|
|
7722
|
-
class: {
|
|
7723
|
-
'user-list': list.type === 'user'
|
|
7724
|
-
}
|
|
7725
|
-
}, [list.type === 'robot' ? _c('div', {
|
|
7726
|
-
staticClass: "robot"
|
|
7727
|
-
}, [_c('div', {
|
|
7728
|
-
staticClass: "robot-image-div"
|
|
7729
|
-
})]) : _c('div', {
|
|
7730
|
-
staticClass: "robot user"
|
|
7731
|
-
}, [_vm._v("user")]), _c('div', {
|
|
7732
|
-
staticClass: "robot-message",
|
|
7733
|
-
class: {
|
|
7734
|
-
'user-info': list.type === 'user'
|
|
7735
|
-
}
|
|
7736
|
-
}, [_c('div', {
|
|
7737
|
-
domProps: {
|
|
7738
|
-
"innerHTML": _vm._s(list.message)
|
|
7739
|
-
}
|
|
7740
|
-
}), list.type === 'robot' && list.links.length > 0 ? _c('div', {
|
|
7741
|
-
staticClass: "link"
|
|
7742
|
-
}, [_c('div', {
|
|
7743
|
-
staticClass: "link-title"
|
|
7744
|
-
}, [_vm._v("相关链接")]), _c('div', {
|
|
7745
|
-
staticClass: "link-content"
|
|
7746
|
-
}, [_vm._l(list.links, function (item) {
|
|
7747
|
-
return [!item.title.startsWith(_vm.chatMajorId) ? _c('div', {
|
|
7748
|
-
staticClass: "links"
|
|
7749
|
-
}, [_c('a', {
|
|
7750
|
-
attrs: {
|
|
7751
|
-
"href": 'https://ai-yuliao.hep.com.cn' + item.documentUrl,
|
|
7752
|
-
"target": "_blank"
|
|
7753
|
-
}
|
|
7754
|
-
}, [_c('span', [_vm._v(_vm._s(item.title))])])]) : _vm._e()];
|
|
7755
|
-
})], 2)]) : _vm._e(), list.type === 'robot' ? _c('chat-tools', {
|
|
7756
|
-
attrs: {
|
|
7757
|
-
"chatId": _vm.chatId,
|
|
7758
|
-
"detail-data": list,
|
|
7759
|
-
"sending": list.sending
|
|
7760
|
-
},
|
|
7761
|
-
on: {
|
|
7762
|
-
"on-reanswer": list => _vm.reanswer(list, index),
|
|
7763
|
-
"on-stop-chat": _vm.onStopChat
|
|
7764
|
-
}
|
|
7765
|
-
}) : _vm._e()], 1)]);
|
|
7766
|
-
}), 0);
|
|
7767
|
-
};
|
|
7768
|
-
var chatvue_type_template_id_1abfa6ce_scoped_true_staticRenderFns = [];
|
|
7769
|
-
|
|
7770
|
-
;// CONCATENATED MODULE: ./node_modules/axios/lib/helpers/bind.js
|
|
7578
|
+
;// ./node_modules/axios/lib/helpers/bind.js
|
|
7771
7579
|
|
|
7772
7580
|
|
|
7773
7581
|
function bind(fn, thisArg) {
|
|
@@ -7776,7 +7584,7 @@ function bind(fn, thisArg) {
|
|
|
7776
7584
|
};
|
|
7777
7585
|
}
|
|
7778
7586
|
|
|
7779
|
-
;//
|
|
7587
|
+
;// ./node_modules/axios/lib/utils.js
|
|
7780
7588
|
|
|
7781
7589
|
|
|
7782
7590
|
|
|
@@ -8538,7 +8346,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
8538
8346
|
asap
|
|
8539
8347
|
});
|
|
8540
8348
|
|
|
8541
|
-
;//
|
|
8349
|
+
;// ./node_modules/axios/lib/core/AxiosError.js
|
|
8542
8350
|
|
|
8543
8351
|
|
|
8544
8352
|
|
|
@@ -8643,11 +8451,11 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
|
8643
8451
|
|
|
8644
8452
|
/* harmony default export */ var core_AxiosError = (AxiosError);
|
|
8645
8453
|
|
|
8646
|
-
;//
|
|
8454
|
+
;// ./node_modules/axios/lib/helpers/null.js
|
|
8647
8455
|
// eslint-disable-next-line strict
|
|
8648
8456
|
/* harmony default export */ var helpers_null = (null);
|
|
8649
8457
|
|
|
8650
|
-
;//
|
|
8458
|
+
;// ./node_modules/axios/lib/helpers/toFormData.js
|
|
8651
8459
|
|
|
8652
8460
|
|
|
8653
8461
|
|
|
@@ -8868,7 +8676,7 @@ function toFormData(obj, formData, options) {
|
|
|
8868
8676
|
|
|
8869
8677
|
/* harmony default export */ var helpers_toFormData = (toFormData);
|
|
8870
8678
|
|
|
8871
|
-
;//
|
|
8679
|
+
;// ./node_modules/axios/lib/helpers/AxiosURLSearchParams.js
|
|
8872
8680
|
|
|
8873
8681
|
|
|
8874
8682
|
|
|
@@ -8928,7 +8736,7 @@ AxiosURLSearchParams_prototype.toString = function toString(encoder) {
|
|
|
8928
8736
|
|
|
8929
8737
|
/* harmony default export */ var helpers_AxiosURLSearchParams = (AxiosURLSearchParams);
|
|
8930
8738
|
|
|
8931
|
-
;//
|
|
8739
|
+
;// ./node_modules/axios/lib/helpers/buildURL.js
|
|
8932
8740
|
|
|
8933
8741
|
|
|
8934
8742
|
|
|
@@ -8993,7 +8801,7 @@ function buildURL(url, params, options) {
|
|
|
8993
8801
|
return url;
|
|
8994
8802
|
}
|
|
8995
8803
|
|
|
8996
|
-
;//
|
|
8804
|
+
;// ./node_modules/axios/lib/core/InterceptorManager.js
|
|
8997
8805
|
|
|
8998
8806
|
|
|
8999
8807
|
|
|
@@ -9066,7 +8874,7 @@ class InterceptorManager {
|
|
|
9066
8874
|
|
|
9067
8875
|
/* harmony default export */ var core_InterceptorManager = (InterceptorManager);
|
|
9068
8876
|
|
|
9069
|
-
;//
|
|
8877
|
+
;// ./node_modules/axios/lib/defaults/transitional.js
|
|
9070
8878
|
|
|
9071
8879
|
|
|
9072
8880
|
/* harmony default export */ var defaults_transitional = ({
|
|
@@ -9075,23 +8883,23 @@ class InterceptorManager {
|
|
|
9075
8883
|
clarifyTimeoutError: false
|
|
9076
8884
|
});
|
|
9077
8885
|
|
|
9078
|
-
;//
|
|
8886
|
+
;// ./node_modules/axios/lib/platform/browser/classes/URLSearchParams.js
|
|
9079
8887
|
|
|
9080
8888
|
|
|
9081
8889
|
|
|
9082
8890
|
/* harmony default export */ var classes_URLSearchParams = (typeof URLSearchParams !== 'undefined' ? URLSearchParams : helpers_AxiosURLSearchParams);
|
|
9083
8891
|
|
|
9084
|
-
;//
|
|
8892
|
+
;// ./node_modules/axios/lib/platform/browser/classes/FormData.js
|
|
9085
8893
|
|
|
9086
8894
|
|
|
9087
8895
|
/* harmony default export */ var classes_FormData = (typeof FormData !== 'undefined' ? FormData : null);
|
|
9088
8896
|
|
|
9089
|
-
;//
|
|
8897
|
+
;// ./node_modules/axios/lib/platform/browser/classes/Blob.js
|
|
9090
8898
|
|
|
9091
8899
|
|
|
9092
8900
|
/* harmony default export */ var classes_Blob = (typeof Blob !== 'undefined' ? Blob : null);
|
|
9093
8901
|
|
|
9094
|
-
;//
|
|
8902
|
+
;// ./node_modules/axios/lib/platform/browser/index.js
|
|
9095
8903
|
|
|
9096
8904
|
|
|
9097
8905
|
|
|
@@ -9106,7 +8914,7 @@ class InterceptorManager {
|
|
|
9106
8914
|
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
9107
8915
|
});
|
|
9108
8916
|
|
|
9109
|
-
;//
|
|
8917
|
+
;// ./node_modules/axios/lib/platform/common/utils.js
|
|
9110
8918
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
9111
8919
|
|
|
9112
8920
|
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
@@ -9153,7 +8961,7 @@ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
|
9153
8961
|
|
|
9154
8962
|
|
|
9155
8963
|
|
|
9156
|
-
;//
|
|
8964
|
+
;// ./node_modules/axios/lib/platform/index.js
|
|
9157
8965
|
|
|
9158
8966
|
|
|
9159
8967
|
|
|
@@ -9162,7 +8970,7 @@ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
|
9162
8970
|
...browser
|
|
9163
8971
|
});
|
|
9164
8972
|
|
|
9165
|
-
;//
|
|
8973
|
+
;// ./node_modules/axios/lib/helpers/toURLEncodedForm.js
|
|
9166
8974
|
|
|
9167
8975
|
|
|
9168
8976
|
|
|
@@ -9182,7 +8990,7 @@ function toURLEncodedForm(data, options) {
|
|
|
9182
8990
|
}, options));
|
|
9183
8991
|
}
|
|
9184
8992
|
|
|
9185
|
-
;//
|
|
8993
|
+
;// ./node_modules/axios/lib/helpers/formDataToJSON.js
|
|
9186
8994
|
|
|
9187
8995
|
|
|
9188
8996
|
|
|
@@ -9279,7 +9087,7 @@ function formDataToJSON(formData) {
|
|
|
9279
9087
|
|
|
9280
9088
|
/* harmony default export */ var helpers_formDataToJSON = (formDataToJSON);
|
|
9281
9089
|
|
|
9282
|
-
;//
|
|
9090
|
+
;// ./node_modules/axios/lib/defaults/index.js
|
|
9283
9091
|
|
|
9284
9092
|
|
|
9285
9093
|
|
|
@@ -9442,7 +9250,7 @@ utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
|
9442
9250
|
|
|
9443
9251
|
/* harmony default export */ var lib_defaults = (defaults);
|
|
9444
9252
|
|
|
9445
|
-
;//
|
|
9253
|
+
;// ./node_modules/axios/lib/helpers/parseHeaders.js
|
|
9446
9254
|
|
|
9447
9255
|
|
|
9448
9256
|
|
|
@@ -9499,7 +9307,7 @@ const ignoreDuplicateOf = utils.toObjectSet([
|
|
|
9499
9307
|
return parsed;
|
|
9500
9308
|
});
|
|
9501
9309
|
|
|
9502
|
-
;//
|
|
9310
|
+
;// ./node_modules/axios/lib/core/AxiosHeaders.js
|
|
9503
9311
|
|
|
9504
9312
|
|
|
9505
9313
|
|
|
@@ -9803,7 +9611,7 @@ utils.freezeMethods(AxiosHeaders);
|
|
|
9803
9611
|
|
|
9804
9612
|
/* harmony default export */ var core_AxiosHeaders = (AxiosHeaders);
|
|
9805
9613
|
|
|
9806
|
-
;//
|
|
9614
|
+
;// ./node_modules/axios/lib/core/transformData.js
|
|
9807
9615
|
|
|
9808
9616
|
|
|
9809
9617
|
|
|
@@ -9833,14 +9641,14 @@ function transformData(fns, response) {
|
|
|
9833
9641
|
return data;
|
|
9834
9642
|
}
|
|
9835
9643
|
|
|
9836
|
-
;//
|
|
9644
|
+
;// ./node_modules/axios/lib/cancel/isCancel.js
|
|
9837
9645
|
|
|
9838
9646
|
|
|
9839
9647
|
function isCancel(value) {
|
|
9840
9648
|
return !!(value && value.__CANCEL__);
|
|
9841
9649
|
}
|
|
9842
9650
|
|
|
9843
|
-
;//
|
|
9651
|
+
;// ./node_modules/axios/lib/cancel/CanceledError.js
|
|
9844
9652
|
|
|
9845
9653
|
|
|
9846
9654
|
|
|
@@ -9867,7 +9675,7 @@ utils.inherits(CanceledError, core_AxiosError, {
|
|
|
9867
9675
|
|
|
9868
9676
|
/* harmony default export */ var cancel_CanceledError = (CanceledError);
|
|
9869
9677
|
|
|
9870
|
-
;//
|
|
9678
|
+
;// ./node_modules/axios/lib/core/settle.js
|
|
9871
9679
|
|
|
9872
9680
|
|
|
9873
9681
|
|
|
@@ -9896,7 +9704,7 @@ function settle(resolve, reject, response) {
|
|
|
9896
9704
|
}
|
|
9897
9705
|
}
|
|
9898
9706
|
|
|
9899
|
-
;//
|
|
9707
|
+
;// ./node_modules/axios/lib/helpers/parseProtocol.js
|
|
9900
9708
|
|
|
9901
9709
|
|
|
9902
9710
|
function parseProtocol(url) {
|
|
@@ -9904,7 +9712,7 @@ function parseProtocol(url) {
|
|
|
9904
9712
|
return match && match[1] || '';
|
|
9905
9713
|
}
|
|
9906
9714
|
|
|
9907
|
-
;//
|
|
9715
|
+
;// ./node_modules/axios/lib/helpers/speedometer.js
|
|
9908
9716
|
|
|
9909
9717
|
|
|
9910
9718
|
/**
|
|
@@ -9961,7 +9769,7 @@ function speedometer(samplesCount, min) {
|
|
|
9961
9769
|
|
|
9962
9770
|
/* harmony default export */ var helpers_speedometer = (speedometer);
|
|
9963
9771
|
|
|
9964
|
-
;//
|
|
9772
|
+
;// ./node_modules/axios/lib/helpers/throttle.js
|
|
9965
9773
|
/**
|
|
9966
9774
|
* Throttle decorator
|
|
9967
9775
|
* @param {Function} fn
|
|
@@ -10007,7 +9815,7 @@ function throttle(fn, freq) {
|
|
|
10007
9815
|
|
|
10008
9816
|
/* harmony default export */ var helpers_throttle = (throttle);
|
|
10009
9817
|
|
|
10010
|
-
;//
|
|
9818
|
+
;// ./node_modules/axios/lib/helpers/progressEventReducer.js
|
|
10011
9819
|
|
|
10012
9820
|
|
|
10013
9821
|
|
|
@@ -10053,7 +9861,7 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
10053
9861
|
|
|
10054
9862
|
const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args));
|
|
10055
9863
|
|
|
10056
|
-
;//
|
|
9864
|
+
;// ./node_modules/axios/lib/helpers/isURLSameOrigin.js
|
|
10057
9865
|
|
|
10058
9866
|
|
|
10059
9867
|
|
|
@@ -10122,7 +9930,7 @@ const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args));
|
|
|
10122
9930
|
};
|
|
10123
9931
|
})());
|
|
10124
9932
|
|
|
10125
|
-
;//
|
|
9933
|
+
;// ./node_modules/axios/lib/helpers/cookies.js
|
|
10126
9934
|
|
|
10127
9935
|
|
|
10128
9936
|
|
|
@@ -10166,7 +9974,7 @@ const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args));
|
|
|
10166
9974
|
});
|
|
10167
9975
|
|
|
10168
9976
|
|
|
10169
|
-
;//
|
|
9977
|
+
;// ./node_modules/axios/lib/helpers/isAbsoluteURL.js
|
|
10170
9978
|
|
|
10171
9979
|
|
|
10172
9980
|
/**
|
|
@@ -10183,7 +9991,7 @@ function isAbsoluteURL(url) {
|
|
|
10183
9991
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
10184
9992
|
}
|
|
10185
9993
|
|
|
10186
|
-
;//
|
|
9994
|
+
;// ./node_modules/axios/lib/helpers/combineURLs.js
|
|
10187
9995
|
|
|
10188
9996
|
|
|
10189
9997
|
/**
|
|
@@ -10200,7 +10008,7 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
10200
10008
|
: baseURL;
|
|
10201
10009
|
}
|
|
10202
10010
|
|
|
10203
|
-
;//
|
|
10011
|
+
;// ./node_modules/axios/lib/core/buildFullPath.js
|
|
10204
10012
|
|
|
10205
10013
|
|
|
10206
10014
|
|
|
@@ -10223,7 +10031,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
|
10223
10031
|
return requestedURL;
|
|
10224
10032
|
}
|
|
10225
10033
|
|
|
10226
|
-
;//
|
|
10034
|
+
;// ./node_modules/axios/lib/core/mergeConfig.js
|
|
10227
10035
|
|
|
10228
10036
|
|
|
10229
10037
|
|
|
@@ -10331,7 +10139,7 @@ function mergeConfig(config1, config2) {
|
|
|
10331
10139
|
return config;
|
|
10332
10140
|
}
|
|
10333
10141
|
|
|
10334
|
-
;//
|
|
10142
|
+
;// ./node_modules/axios/lib/helpers/resolveConfig.js
|
|
10335
10143
|
|
|
10336
10144
|
|
|
10337
10145
|
|
|
@@ -10390,7 +10198,7 @@ function mergeConfig(config1, config2) {
|
|
|
10390
10198
|
});
|
|
10391
10199
|
|
|
10392
10200
|
|
|
10393
|
-
;//
|
|
10201
|
+
;// ./node_modules/axios/lib/adapters/xhr.js
|
|
10394
10202
|
|
|
10395
10203
|
|
|
10396
10204
|
|
|
@@ -10589,55 +10397,57 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
|
10589
10397
|
});
|
|
10590
10398
|
});
|
|
10591
10399
|
|
|
10592
|
-
;//
|
|
10400
|
+
;// ./node_modules/axios/lib/helpers/composeSignals.js
|
|
10401
|
+
|
|
10593
10402
|
|
|
10594
10403
|
|
|
10595
10404
|
|
|
10596
10405
|
const composeSignals = (signals, timeout) => {
|
|
10597
|
-
|
|
10406
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
10598
10407
|
|
|
10599
|
-
|
|
10408
|
+
if (timeout || length) {
|
|
10409
|
+
let controller = new AbortController();
|
|
10600
10410
|
|
|
10601
|
-
|
|
10602
|
-
if (!aborted) {
|
|
10603
|
-
aborted = true;
|
|
10604
|
-
unsubscribe();
|
|
10605
|
-
const err = cancel instanceof Error ? cancel : this.reason;
|
|
10606
|
-
controller.abort(err instanceof core_AxiosError ? err : new cancel_CanceledError(err instanceof Error ? err.message : err));
|
|
10607
|
-
}
|
|
10608
|
-
}
|
|
10411
|
+
let aborted;
|
|
10609
10412
|
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10413
|
+
const onabort = function (reason) {
|
|
10414
|
+
if (!aborted) {
|
|
10415
|
+
aborted = true;
|
|
10416
|
+
unsubscribe();
|
|
10417
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
10418
|
+
controller.abort(err instanceof core_AxiosError ? err : new cancel_CanceledError(err instanceof Error ? err.message : err));
|
|
10419
|
+
}
|
|
10420
|
+
}
|
|
10613
10421
|
|
|
10614
|
-
|
|
10615
|
-
if (signals) {
|
|
10616
|
-
timer && clearTimeout(timer);
|
|
10422
|
+
let timer = timeout && setTimeout(() => {
|
|
10617
10423
|
timer = null;
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
signals
|
|
10424
|
+
onabort(new core_AxiosError(`timeout ${timeout} of ms exceeded`, core_AxiosError.ETIMEDOUT))
|
|
10425
|
+
}, timeout)
|
|
10426
|
+
|
|
10427
|
+
const unsubscribe = () => {
|
|
10428
|
+
if (signals) {
|
|
10429
|
+
timer && clearTimeout(timer);
|
|
10430
|
+
timer = null;
|
|
10431
|
+
signals.forEach(signal => {
|
|
10432
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
|
10433
|
+
});
|
|
10434
|
+
signals = null;
|
|
10435
|
+
}
|
|
10623
10436
|
}
|
|
10624
|
-
}
|
|
10625
10437
|
|
|
10626
|
-
|
|
10438
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
10627
10439
|
|
|
10628
|
-
|
|
10440
|
+
const {signal} = controller;
|
|
10629
10441
|
|
|
10630
|
-
|
|
10442
|
+
signal.unsubscribe = () => utils.asap(unsubscribe);
|
|
10631
10443
|
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
timer = null;
|
|
10635
|
-
}];
|
|
10444
|
+
return signal;
|
|
10445
|
+
}
|
|
10636
10446
|
}
|
|
10637
10447
|
|
|
10638
10448
|
/* harmony default export */ var helpers_composeSignals = (composeSignals);
|
|
10639
10449
|
|
|
10640
|
-
;//
|
|
10450
|
+
;// ./node_modules/axios/lib/helpers/trackStream.js
|
|
10641
10451
|
|
|
10642
10452
|
const streamChunk = function* (chunk, chunkSize) {
|
|
10643
10453
|
let len = chunk.byteLength;
|
|
@@ -10657,14 +10467,34 @@ const streamChunk = function* (chunk, chunkSize) {
|
|
|
10657
10467
|
}
|
|
10658
10468
|
}
|
|
10659
10469
|
|
|
10660
|
-
const readBytes = async function* (iterable, chunkSize
|
|
10661
|
-
for await (const chunk of iterable) {
|
|
10662
|
-
yield* streamChunk(
|
|
10470
|
+
const readBytes = async function* (iterable, chunkSize) {
|
|
10471
|
+
for await (const chunk of readStream(iterable)) {
|
|
10472
|
+
yield* streamChunk(chunk, chunkSize);
|
|
10473
|
+
}
|
|
10474
|
+
}
|
|
10475
|
+
|
|
10476
|
+
const readStream = async function* (stream) {
|
|
10477
|
+
if (stream[Symbol.asyncIterator]) {
|
|
10478
|
+
yield* stream;
|
|
10479
|
+
return;
|
|
10480
|
+
}
|
|
10481
|
+
|
|
10482
|
+
const reader = stream.getReader();
|
|
10483
|
+
try {
|
|
10484
|
+
for (;;) {
|
|
10485
|
+
const {done, value} = await reader.read();
|
|
10486
|
+
if (done) {
|
|
10487
|
+
break;
|
|
10488
|
+
}
|
|
10489
|
+
yield value;
|
|
10490
|
+
}
|
|
10491
|
+
} finally {
|
|
10492
|
+
await reader.cancel();
|
|
10663
10493
|
}
|
|
10664
10494
|
}
|
|
10665
10495
|
|
|
10666
|
-
const trackStream = (stream, chunkSize, onProgress, onFinish
|
|
10667
|
-
const iterator = readBytes(stream, chunkSize
|
|
10496
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
10497
|
+
const iterator = readBytes(stream, chunkSize);
|
|
10668
10498
|
|
|
10669
10499
|
let bytes = 0;
|
|
10670
10500
|
let done;
|
|
@@ -10706,7 +10536,7 @@ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
|
|
10706
10536
|
})
|
|
10707
10537
|
}
|
|
10708
10538
|
|
|
10709
|
-
;//
|
|
10539
|
+
;// ./node_modules/axios/lib/adapters/fetch.js
|
|
10710
10540
|
|
|
10711
10541
|
|
|
10712
10542
|
|
|
@@ -10778,7 +10608,11 @@ const getBodyLength = async (body) => {
|
|
|
10778
10608
|
}
|
|
10779
10609
|
|
|
10780
10610
|
if(utils.isSpecCompliantForm(body)) {
|
|
10781
|
-
|
|
10611
|
+
const _request = new Request(platform.origin, {
|
|
10612
|
+
method: 'POST',
|
|
10613
|
+
body,
|
|
10614
|
+
});
|
|
10615
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
10782
10616
|
}
|
|
10783
10617
|
|
|
10784
10618
|
if(utils.isArrayBufferView(body) || utils.isArrayBuffer(body)) {
|
|
@@ -10818,18 +10652,13 @@ const resolveBodyLength = async (headers, body) => {
|
|
|
10818
10652
|
|
|
10819
10653
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
10820
10654
|
|
|
10821
|
-
let
|
|
10822
|
-
helpers_composeSignals([signal, cancelToken], timeout) : [];
|
|
10655
|
+
let composedSignal = helpers_composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
10823
10656
|
|
|
10824
|
-
let
|
|
10825
|
-
|
|
10826
|
-
const onFinish = () => {
|
|
10827
|
-
!finished && setTimeout(() => {
|
|
10828
|
-
composedSignal && composedSignal.unsubscribe();
|
|
10829
|
-
});
|
|
10657
|
+
let request;
|
|
10830
10658
|
|
|
10831
|
-
|
|
10832
|
-
|
|
10659
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
10660
|
+
composedSignal.unsubscribe();
|
|
10661
|
+
});
|
|
10833
10662
|
|
|
10834
10663
|
let requestContentLength;
|
|
10835
10664
|
|
|
@@ -10856,7 +10685,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
|
10856
10685
|
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
10857
10686
|
);
|
|
10858
10687
|
|
|
10859
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush
|
|
10688
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
10860
10689
|
}
|
|
10861
10690
|
}
|
|
10862
10691
|
|
|
@@ -10866,7 +10695,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
|
10866
10695
|
|
|
10867
10696
|
// Cloudflare Workers throws when credentials are defined
|
|
10868
10697
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
10869
|
-
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
10698
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
10870
10699
|
request = new Request(url, {
|
|
10871
10700
|
...fetchOptions,
|
|
10872
10701
|
signal: composedSignal,
|
|
@@ -10881,7 +10710,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
|
10881
10710
|
|
|
10882
10711
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
10883
10712
|
|
|
10884
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
10713
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
10885
10714
|
const options = {};
|
|
10886
10715
|
|
|
10887
10716
|
['status', 'statusText', 'headers'].forEach(prop => {
|
|
@@ -10898,8 +10727,8 @@ const resolveBodyLength = async (headers, body) => {
|
|
|
10898
10727
|
response = new Response(
|
|
10899
10728
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
10900
10729
|
flush && flush();
|
|
10901
|
-
|
|
10902
|
-
}
|
|
10730
|
+
unsubscribe && unsubscribe();
|
|
10731
|
+
}),
|
|
10903
10732
|
options
|
|
10904
10733
|
);
|
|
10905
10734
|
}
|
|
@@ -10908,9 +10737,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
|
10908
10737
|
|
|
10909
10738
|
let responseData = await resolvers[utils.findKey(resolvers, responseType) || 'text'](response, config);
|
|
10910
10739
|
|
|
10911
|
-
!isStreamResponse &&
|
|
10912
|
-
|
|
10913
|
-
stopTimeout && stopTimeout();
|
|
10740
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
10914
10741
|
|
|
10915
10742
|
return await new Promise((resolve, reject) => {
|
|
10916
10743
|
settle(resolve, reject, {
|
|
@@ -10923,7 +10750,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
|
10923
10750
|
})
|
|
10924
10751
|
})
|
|
10925
10752
|
} catch (err) {
|
|
10926
|
-
|
|
10753
|
+
unsubscribe && unsubscribe();
|
|
10927
10754
|
|
|
10928
10755
|
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
10929
10756
|
throw Object.assign(
|
|
@@ -10940,7 +10767,7 @@ const resolveBodyLength = async (headers, body) => {
|
|
|
10940
10767
|
|
|
10941
10768
|
|
|
10942
10769
|
|
|
10943
|
-
;//
|
|
10770
|
+
;// ./node_modules/axios/lib/adapters/adapters.js
|
|
10944
10771
|
|
|
10945
10772
|
|
|
10946
10773
|
|
|
@@ -11021,7 +10848,7 @@ const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === n
|
|
|
11021
10848
|
adapters: knownAdapters
|
|
11022
10849
|
});
|
|
11023
10850
|
|
|
11024
|
-
;//
|
|
10851
|
+
;// ./node_modules/axios/lib/core/dispatchRequest.js
|
|
11025
10852
|
|
|
11026
10853
|
|
|
11027
10854
|
|
|
@@ -11104,9 +10931,9 @@ function dispatchRequest(config) {
|
|
|
11104
10931
|
});
|
|
11105
10932
|
}
|
|
11106
10933
|
|
|
11107
|
-
;//
|
|
11108
|
-
const VERSION = "1.7.
|
|
11109
|
-
;//
|
|
10934
|
+
;// ./node_modules/axios/lib/env/data.js
|
|
10935
|
+
const VERSION = "1.7.7";
|
|
10936
|
+
;// ./node_modules/axios/lib/helpers/validator.js
|
|
11110
10937
|
|
|
11111
10938
|
|
|
11112
10939
|
|
|
@@ -11199,7 +11026,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
11199
11026
|
validators
|
|
11200
11027
|
});
|
|
11201
11028
|
|
|
11202
|
-
;//
|
|
11029
|
+
;// ./node_modules/axios/lib/core/Axios.js
|
|
11203
11030
|
|
|
11204
11031
|
|
|
11205
11032
|
|
|
@@ -11429,7 +11256,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
|
11429
11256
|
|
|
11430
11257
|
/* harmony default export */ var core_Axios = (Axios);
|
|
11431
11258
|
|
|
11432
|
-
;//
|
|
11259
|
+
;// ./node_modules/axios/lib/cancel/CancelToken.js
|
|
11433
11260
|
|
|
11434
11261
|
|
|
11435
11262
|
|
|
@@ -11534,6 +11361,20 @@ class CancelToken {
|
|
|
11534
11361
|
}
|
|
11535
11362
|
}
|
|
11536
11363
|
|
|
11364
|
+
toAbortSignal() {
|
|
11365
|
+
const controller = new AbortController();
|
|
11366
|
+
|
|
11367
|
+
const abort = (err) => {
|
|
11368
|
+
controller.abort(err);
|
|
11369
|
+
};
|
|
11370
|
+
|
|
11371
|
+
this.subscribe(abort);
|
|
11372
|
+
|
|
11373
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
11374
|
+
|
|
11375
|
+
return controller.signal;
|
|
11376
|
+
}
|
|
11377
|
+
|
|
11537
11378
|
/**
|
|
11538
11379
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
11539
11380
|
* cancels the `CancelToken`.
|
|
@@ -11552,7 +11393,7 @@ class CancelToken {
|
|
|
11552
11393
|
|
|
11553
11394
|
/* harmony default export */ var cancel_CancelToken = (CancelToken);
|
|
11554
11395
|
|
|
11555
|
-
;//
|
|
11396
|
+
;// ./node_modules/axios/lib/helpers/spread.js
|
|
11556
11397
|
|
|
11557
11398
|
|
|
11558
11399
|
/**
|
|
@@ -11582,7 +11423,7 @@ function spread(callback) {
|
|
|
11582
11423
|
};
|
|
11583
11424
|
}
|
|
11584
11425
|
|
|
11585
|
-
;//
|
|
11426
|
+
;// ./node_modules/axios/lib/helpers/isAxiosError.js
|
|
11586
11427
|
|
|
11587
11428
|
|
|
11588
11429
|
|
|
@@ -11598,7 +11439,7 @@ function isAxiosError(payload) {
|
|
|
11598
11439
|
return utils.isObject(payload) && (payload.isAxiosError === true);
|
|
11599
11440
|
}
|
|
11600
11441
|
|
|
11601
|
-
;//
|
|
11442
|
+
;// ./node_modules/axios/lib/helpers/HttpStatusCode.js
|
|
11602
11443
|
const HttpStatusCode = {
|
|
11603
11444
|
Continue: 100,
|
|
11604
11445
|
SwitchingProtocols: 101,
|
|
@@ -11671,7 +11512,7 @@ Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
|
11671
11512
|
|
|
11672
11513
|
/* harmony default export */ var helpers_HttpStatusCode = (HttpStatusCode);
|
|
11673
11514
|
|
|
11674
|
-
;//
|
|
11515
|
+
;// ./node_modules/axios/lib/axios.js
|
|
11675
11516
|
|
|
11676
11517
|
|
|
11677
11518
|
|
|
@@ -11762,7 +11603,7 @@ axios.default = axios;
|
|
|
11762
11603
|
// this module should only have a default export
|
|
11763
11604
|
/* harmony default export */ var lib_axios = (axios);
|
|
11764
11605
|
|
|
11765
|
-
;//
|
|
11606
|
+
;// ./components/demo/plugins/cache.js
|
|
11766
11607
|
const sessionCache = {
|
|
11767
11608
|
set(key, value) {
|
|
11768
11609
|
if (!sessionStorage) {
|
|
@@ -11839,12 +11680,12 @@ const localCache = {
|
|
|
11839
11680
|
*/
|
|
11840
11681
|
local: localCache
|
|
11841
11682
|
});
|
|
11842
|
-
;//
|
|
11683
|
+
;// external "element-ui"
|
|
11843
11684
|
var external_element_ui_namespaceObject = require("element-ui");
|
|
11844
11685
|
// EXTERNAL MODULE: ./node_modules/crypto-js/index.js
|
|
11845
11686
|
var crypto_js = __webpack_require__(396);
|
|
11846
11687
|
var crypto_js_default = /*#__PURE__*/__webpack_require__.n(crypto_js);
|
|
11847
|
-
;//
|
|
11688
|
+
;// ./node_modules/js-base64/base64.mjs
|
|
11848
11689
|
/**
|
|
11849
11690
|
* base64.ts
|
|
11850
11691
|
*
|
|
@@ -12140,7 +11981,7 @@ const gBase64 = {
|
|
|
12140
11981
|
// and finally,
|
|
12141
11982
|
|
|
12142
11983
|
|
|
12143
|
-
;//
|
|
11984
|
+
;// ./components/demo/utils/aes-utils.js
|
|
12144
11985
|
|
|
12145
11986
|
|
|
12146
11987
|
const a = 'RU5D';
|
|
@@ -12160,20 +12001,20 @@ const iv = crypto_js_default().enc.Utf8.parse(n);
|
|
|
12160
12001
|
// 解密方法
|
|
12161
12002
|
function decrypt(word) {
|
|
12162
12003
|
const stringToEncode = 'Hello, World!'; // 要进行 Base64 编码的字符串
|
|
12163
|
-
const encodedString =
|
|
12164
|
-
const decodedString =
|
|
12004
|
+
const encodedString = Base64.encode(stringToEncode); // 进行 Base64 编码
|
|
12005
|
+
const decodedString = Base64.decode(encodedString); // 进行 Base64 解码
|
|
12165
12006
|
|
|
12166
|
-
let base64 =
|
|
12167
|
-
let src =
|
|
12168
|
-
let decrypt =
|
|
12007
|
+
let base64 = CryptoJS.enc.Base64.parse(word);
|
|
12008
|
+
let src = CryptoJS.enc.Base64.stringify(base64);
|
|
12009
|
+
let decrypt = CryptoJS.AES.decrypt(src, key, {
|
|
12169
12010
|
iv: iv,
|
|
12170
|
-
mode:
|
|
12171
|
-
padding:
|
|
12011
|
+
mode: CryptoJS.mode.CBC,
|
|
12012
|
+
padding: CryptoJS.pad.Pkcs7
|
|
12172
12013
|
});
|
|
12173
|
-
let decryptedStr = decrypt.toString(
|
|
12014
|
+
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
|
|
12174
12015
|
return decryptedStr.toString();
|
|
12175
12016
|
}
|
|
12176
|
-
;//
|
|
12017
|
+
;// ./components/demo/utils/constants.js
|
|
12177
12018
|
let appId = '601a39a2a4a7cd88d5ddcef5';
|
|
12178
12019
|
const whiteList = ['/home', '/overview'];
|
|
12179
12020
|
if (({"NODE_ENV":"production","BASE_URL":""}).VITE_APP_BUILD_TYPE === 'aliyun') {
|
|
@@ -12188,7 +12029,7 @@ if (({"NODE_ENV":"production","BASE_URL":""}).VITE_APP_BUILD_TYPE === 'aliyun')
|
|
|
12188
12029
|
publicPath: 'https://agent.icve.com.cn/heatp-portal/do/',
|
|
12189
12030
|
publicPrefix: '/heatp'
|
|
12190
12031
|
});
|
|
12191
|
-
;//
|
|
12032
|
+
;// ./components/demo/utils/request.js
|
|
12192
12033
|
|
|
12193
12034
|
|
|
12194
12035
|
|
|
@@ -12204,7 +12045,9 @@ const service = lib_axios.create({
|
|
|
12204
12045
|
});
|
|
12205
12046
|
service.interceptors.request.use(config => {
|
|
12206
12047
|
if (cache.session.getJSON('SRKJ_TOKEN_CACHE')) {
|
|
12207
|
-
config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
12048
|
+
// config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
12049
|
+
if (!config.params) config.params = {};
|
|
12050
|
+
config.params.token = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
12208
12051
|
}
|
|
12209
12052
|
// 是否需要防止数据重复提交
|
|
12210
12053
|
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
|
|
@@ -12237,12 +12080,12 @@ service.interceptors.response.use(res => {
|
|
|
12237
12080
|
return res.data;
|
|
12238
12081
|
}
|
|
12239
12082
|
let srkjData = res.data;
|
|
12240
|
-
if (srkjData) {
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
|
-
}
|
|
12083
|
+
// if (srkjData) {
|
|
12084
|
+
// const respData = decrypt(srkjData);
|
|
12085
|
+
// try {
|
|
12086
|
+
// srkjData = JSON.parse(respData);
|
|
12087
|
+
// } catch (e) {}
|
|
12088
|
+
// }
|
|
12246
12089
|
if (res.status === 401) {
|
|
12247
12090
|
external_element_ui_namespaceObject.Message.warning(srkjData.message.description);
|
|
12248
12091
|
return;
|
|
@@ -12252,8 +12095,8 @@ service.interceptors.response.use(res => {
|
|
|
12252
12095
|
}
|
|
12253
12096
|
return srkjData.queryData || srkjData.data || srkjData.token;
|
|
12254
12097
|
});
|
|
12255
|
-
/* harmony default export */ var
|
|
12256
|
-
;//
|
|
12098
|
+
/* harmony default export */ var utils_request = (service);
|
|
12099
|
+
;// ./node_modules/@microsoft/fetch-event-source/lib/esm/parse.js
|
|
12257
12100
|
async function getBytes(stream, onChunk) {
|
|
12258
12101
|
const reader = stream.getReader();
|
|
12259
12102
|
let result;
|
|
@@ -12364,7 +12207,7 @@ function newMessage() {
|
|
|
12364
12207
|
};
|
|
12365
12208
|
}
|
|
12366
12209
|
//# sourceMappingURL=parse.js.map
|
|
12367
|
-
;//
|
|
12210
|
+
;// ./node_modules/@microsoft/fetch-event-source/lib/esm/fetch.js
|
|
12368
12211
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
12369
12212
|
var t = {};
|
|
12370
12213
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -12454,15 +12297,17 @@ function defaultOnOpen(response) {
|
|
|
12454
12297
|
}
|
|
12455
12298
|
}
|
|
12456
12299
|
//# sourceMappingURL=fetch.js.map
|
|
12457
|
-
;//
|
|
12300
|
+
;// ./components/demo/api/index.js
|
|
12458
12301
|
|
|
12459
12302
|
|
|
12460
12303
|
|
|
12461
12304
|
const baseURL = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_BASE_URL') || constants.publicPath;
|
|
12462
|
-
|
|
12305
|
+
let prefix = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_PRE_FIX') || constants.publicPrefix;
|
|
12306
|
+
// 0.0.8 版本接口升级
|
|
12307
|
+
prefix += '/plugin/v2';
|
|
12463
12308
|
|
|
12464
12309
|
const ssoAuth = token => {
|
|
12465
|
-
return
|
|
12310
|
+
return utils_request({
|
|
12466
12311
|
url: prefix + '/sso/assistant',
|
|
12467
12312
|
method: 'get',
|
|
12468
12313
|
params: {
|
|
@@ -12478,7 +12323,7 @@ const authUser = headers => {
|
|
|
12478
12323
|
});
|
|
12479
12324
|
};
|
|
12480
12325
|
const newChat = resId => {
|
|
12481
|
-
return
|
|
12326
|
+
return utils_request({
|
|
12482
12327
|
url: prefix + '/assistant/addChat',
|
|
12483
12328
|
method: 'post',
|
|
12484
12329
|
params: {
|
|
@@ -12487,46 +12332,46 @@ const newChat = resId => {
|
|
|
12487
12332
|
});
|
|
12488
12333
|
};
|
|
12489
12334
|
const chartClear = chatId => {
|
|
12490
|
-
return
|
|
12335
|
+
return utils_request({
|
|
12491
12336
|
url: prefix + `/assistant/chartClear/${chatId}`,
|
|
12492
12337
|
method: 'post'
|
|
12493
12338
|
});
|
|
12494
12339
|
};
|
|
12495
12340
|
const stopChat = chatId => {
|
|
12496
|
-
return
|
|
12341
|
+
return utils_request({
|
|
12497
12342
|
url: prefix + `/assistant/stop/${chatId}`,
|
|
12498
12343
|
method: 'post'
|
|
12499
12344
|
});
|
|
12500
12345
|
};
|
|
12501
12346
|
const chatEvaluateAdd = params => {
|
|
12502
|
-
return
|
|
12347
|
+
return utils_request({
|
|
12503
12348
|
url: prefix + `/assistant/chatEvaluateAdd`,
|
|
12504
12349
|
method: 'post',
|
|
12505
12350
|
data: params
|
|
12506
12351
|
});
|
|
12507
12352
|
};
|
|
12508
12353
|
const chatEvaluateCancel = params => {
|
|
12509
|
-
return
|
|
12354
|
+
return utils_request({
|
|
12510
12355
|
url: prefix + `/assistant/chatEvaluateCancel`,
|
|
12511
12356
|
method: 'post',
|
|
12512
12357
|
data: params
|
|
12513
12358
|
});
|
|
12514
12359
|
};
|
|
12515
12360
|
const pustReanswerToTeacher = params => {
|
|
12516
|
-
return
|
|
12361
|
+
return utils_request({
|
|
12517
12362
|
url: prefix + `/assistant/push`,
|
|
12518
12363
|
method: 'post',
|
|
12519
12364
|
data: params
|
|
12520
12365
|
});
|
|
12521
12366
|
};
|
|
12522
12367
|
const getDetailList = resId => {
|
|
12523
|
-
return
|
|
12368
|
+
return utils_request({
|
|
12524
12369
|
url: prefix + `/assistant/detail/v2/${resId}`,
|
|
12525
12370
|
method: 'get'
|
|
12526
12371
|
});
|
|
12527
12372
|
};
|
|
12528
12373
|
const countAccess = resId => {
|
|
12529
|
-
return
|
|
12374
|
+
return utils_request({
|
|
12530
12375
|
url: prefix + `/assistant/access`,
|
|
12531
12376
|
method: 'post',
|
|
12532
12377
|
params: {
|
|
@@ -12535,33 +12380,321 @@ const countAccess = resId => {
|
|
|
12535
12380
|
});
|
|
12536
12381
|
};
|
|
12537
12382
|
const checkCourseIdIsExist = resId => {
|
|
12538
|
-
return
|
|
12383
|
+
return utils_request({
|
|
12539
12384
|
url: prefix + `/ia/hasPermission?courseId=${resId}`,
|
|
12540
12385
|
method: 'get'
|
|
12541
12386
|
});
|
|
12542
12387
|
};
|
|
12388
|
+
/**
|
|
12389
|
+
* 开场白及提示词查询
|
|
12390
|
+
* */
|
|
12391
|
+
const queryCallWord = resId => {
|
|
12392
|
+
return utils_request({
|
|
12393
|
+
url: prefix + `/ia/byCourseId?courseId=${resId}`,
|
|
12394
|
+
method: 'get'
|
|
12395
|
+
});
|
|
12396
|
+
};
|
|
12397
|
+
|
|
12398
|
+
/**
|
|
12399
|
+
* 自动追问
|
|
12400
|
+
* @param iaId 请求参数id
|
|
12401
|
+
* @param message 对话对
|
|
12402
|
+
* @returns 返回节点详情数据
|
|
12403
|
+
*/
|
|
12404
|
+
async function getAutoQuestioning(iaId, message) {
|
|
12405
|
+
return utils_request.post(`${prefix}/ia/autoFollowUp`, {
|
|
12406
|
+
iaId,
|
|
12407
|
+
messages: message
|
|
12408
|
+
});
|
|
12409
|
+
}
|
|
12543
12410
|
async function sendMessageEventSource(params, signal, onmessage) {
|
|
12544
|
-
return fetchEventSource(`${baseURL}${prefix}/assistant/conversation`, {
|
|
12411
|
+
return fetchEventSource(`${baseURL}${prefix}/assistant/conversation?token=${cache.session.getJSON('SRKJ_TOKEN_CACHE')}`, {
|
|
12545
12412
|
method: 'POST',
|
|
12546
12413
|
signal: signal,
|
|
12547
12414
|
openWhenHidden: true,
|
|
12548
12415
|
headers: {
|
|
12549
|
-
'Content-Type': 'application/json'
|
|
12550
|
-
'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE')
|
|
12416
|
+
'Content-Type': 'application/json'
|
|
12417
|
+
// 'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE'),
|
|
12551
12418
|
},
|
|
12552
12419
|
body: JSON.stringify(params),
|
|
12553
12420
|
onmessage
|
|
12554
12421
|
});
|
|
12555
12422
|
}
|
|
12556
|
-
;//
|
|
12557
|
-
|
|
12423
|
+
;// ./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/hot-search.vue?vue&type=script&lang=js
|
|
12558
12424
|
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
|
|
12563
|
-
|
|
12564
|
-
|
|
12425
|
+
/* harmony default export */ var hot_searchvue_type_script_lang_js = ({
|
|
12426
|
+
name: 'HotSearch',
|
|
12427
|
+
props: {
|
|
12428
|
+
resId: {
|
|
12429
|
+
type: String,
|
|
12430
|
+
default: ''
|
|
12431
|
+
}
|
|
12432
|
+
},
|
|
12433
|
+
data() {
|
|
12434
|
+
return {
|
|
12435
|
+
aiMessage: [
|
|
12436
|
+
// {
|
|
12437
|
+
// value: '请解释一下牛顿第二定律的公式和物理意义。',
|
|
12438
|
+
// id: 1,
|
|
12439
|
+
// },
|
|
12440
|
+
// {
|
|
12441
|
+
// value: '电磁感应定律是如何描述的?请给出相关公式并解释。',
|
|
12442
|
+
// id: 2,
|
|
12443
|
+
// },
|
|
12444
|
+
// {
|
|
12445
|
+
// value: '在光学中,光的干涉现象是如何产生的?能否用公式来表示?',
|
|
12446
|
+
// id: 3,
|
|
12447
|
+
// }
|
|
12448
|
+
],
|
|
12449
|
+
prologue: ' '
|
|
12450
|
+
};
|
|
12451
|
+
},
|
|
12452
|
+
methods: {
|
|
12453
|
+
selectModule(list) {
|
|
12454
|
+
this.$emit('select-module', list);
|
|
12455
|
+
}
|
|
12456
|
+
},
|
|
12457
|
+
async mounted() {
|
|
12458
|
+
const wordRes = await queryCallWord(this.resId);
|
|
12459
|
+
if (!wordRes) return;
|
|
12460
|
+
const {
|
|
12461
|
+
guideExample,
|
|
12462
|
+
prologue
|
|
12463
|
+
} = wordRes;
|
|
12464
|
+
if (guideExample && guideExample.length > 0) {
|
|
12465
|
+
this.aiMessage = JSON.parse(guideExample);
|
|
12466
|
+
}
|
|
12467
|
+
this.prologue = prologue;
|
|
12468
|
+
}
|
|
12469
|
+
});
|
|
12470
|
+
;// ./components/demo/src/hot-search.vue?vue&type=script&lang=js
|
|
12471
|
+
/* harmony default export */ var src_hot_searchvue_type_script_lang_js = (hot_searchvue_type_script_lang_js);
|
|
12472
|
+
;// ./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/hot-search.vue?vue&type=style&index=0&id=abf2ffc4&prod&lang=scss&scoped=true
|
|
12473
|
+
// extracted by mini-css-extract-plugin
|
|
12474
|
+
|
|
12475
|
+
;// ./components/demo/src/hot-search.vue?vue&type=style&index=0&id=abf2ffc4&prod&lang=scss&scoped=true
|
|
12476
|
+
|
|
12477
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
|
|
12478
|
+
/* globals __VUE_SSR_CONTEXT__ */
|
|
12479
|
+
|
|
12480
|
+
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
|
|
12481
|
+
// This module is a runtime utility for cleaner component module output and will
|
|
12482
|
+
// be included in the final webpack user bundle.
|
|
12483
|
+
|
|
12484
|
+
function normalizeComponent(
|
|
12485
|
+
scriptExports,
|
|
12486
|
+
render,
|
|
12487
|
+
staticRenderFns,
|
|
12488
|
+
functionalTemplate,
|
|
12489
|
+
injectStyles,
|
|
12490
|
+
scopeId,
|
|
12491
|
+
moduleIdentifier /* server only */,
|
|
12492
|
+
shadowMode /* vue-cli only */
|
|
12493
|
+
) {
|
|
12494
|
+
// Vue.extend constructor export interop
|
|
12495
|
+
var options =
|
|
12496
|
+
typeof scriptExports === 'function' ? scriptExports.options : scriptExports
|
|
12497
|
+
|
|
12498
|
+
// render functions
|
|
12499
|
+
if (render) {
|
|
12500
|
+
options.render = render
|
|
12501
|
+
options.staticRenderFns = staticRenderFns
|
|
12502
|
+
options._compiled = true
|
|
12503
|
+
}
|
|
12504
|
+
|
|
12505
|
+
// functional template
|
|
12506
|
+
if (functionalTemplate) {
|
|
12507
|
+
options.functional = true
|
|
12508
|
+
}
|
|
12509
|
+
|
|
12510
|
+
// scopedId
|
|
12511
|
+
if (scopeId) {
|
|
12512
|
+
options._scopeId = 'data-v-' + scopeId
|
|
12513
|
+
}
|
|
12514
|
+
|
|
12515
|
+
var hook
|
|
12516
|
+
if (moduleIdentifier) {
|
|
12517
|
+
// server build
|
|
12518
|
+
hook = function (context) {
|
|
12519
|
+
// 2.3 injection
|
|
12520
|
+
context =
|
|
12521
|
+
context || // cached call
|
|
12522
|
+
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
12523
|
+
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
|
|
12524
|
+
// 2.2 with runInNewContext: true
|
|
12525
|
+
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
12526
|
+
context = __VUE_SSR_CONTEXT__
|
|
12527
|
+
}
|
|
12528
|
+
// inject component styles
|
|
12529
|
+
if (injectStyles) {
|
|
12530
|
+
injectStyles.call(this, context)
|
|
12531
|
+
}
|
|
12532
|
+
// register component module identifier for async chunk inferrence
|
|
12533
|
+
if (context && context._registeredComponents) {
|
|
12534
|
+
context._registeredComponents.add(moduleIdentifier)
|
|
12535
|
+
}
|
|
12536
|
+
}
|
|
12537
|
+
// used by ssr in case component is cached and beforeCreate
|
|
12538
|
+
// never gets called
|
|
12539
|
+
options._ssrRegister = hook
|
|
12540
|
+
} else if (injectStyles) {
|
|
12541
|
+
hook = shadowMode
|
|
12542
|
+
? function () {
|
|
12543
|
+
injectStyles.call(
|
|
12544
|
+
this,
|
|
12545
|
+
(options.functional ? this.parent : this).$root.$options.shadowRoot
|
|
12546
|
+
)
|
|
12547
|
+
}
|
|
12548
|
+
: injectStyles
|
|
12549
|
+
}
|
|
12550
|
+
|
|
12551
|
+
if (hook) {
|
|
12552
|
+
if (options.functional) {
|
|
12553
|
+
// for template-only hot-reload because in that case the render fn doesn't
|
|
12554
|
+
// go through the normalizer
|
|
12555
|
+
options._injectStyles = hook
|
|
12556
|
+
// register for functional component in vue file
|
|
12557
|
+
var originalRender = options.render
|
|
12558
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
12559
|
+
hook.call(context)
|
|
12560
|
+
return originalRender(h, context)
|
|
12561
|
+
}
|
|
12562
|
+
} else {
|
|
12563
|
+
// inject component registration as beforeCreate hook
|
|
12564
|
+
var existing = options.beforeCreate
|
|
12565
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
|
|
12566
|
+
}
|
|
12567
|
+
}
|
|
12568
|
+
|
|
12569
|
+
return {
|
|
12570
|
+
exports: scriptExports,
|
|
12571
|
+
options: options
|
|
12572
|
+
}
|
|
12573
|
+
}
|
|
12574
|
+
|
|
12575
|
+
;// ./components/demo/src/hot-search.vue
|
|
12576
|
+
|
|
12577
|
+
|
|
12578
|
+
|
|
12579
|
+
;
|
|
12580
|
+
|
|
12581
|
+
|
|
12582
|
+
/* normalize component */
|
|
12583
|
+
|
|
12584
|
+
var component = normalizeComponent(
|
|
12585
|
+
src_hot_searchvue_type_script_lang_js,
|
|
12586
|
+
hot_searchvue_type_template_id_abf2ffc4_scoped_true_render,
|
|
12587
|
+
hot_searchvue_type_template_id_abf2ffc4_scoped_true_staticRenderFns,
|
|
12588
|
+
false,
|
|
12589
|
+
null,
|
|
12590
|
+
"abf2ffc4",
|
|
12591
|
+
null
|
|
12592
|
+
|
|
12593
|
+
)
|
|
12594
|
+
|
|
12595
|
+
/* harmony default export */ var hot_search = (component.exports);
|
|
12596
|
+
;// ./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=322788ca&scoped=true
|
|
12597
|
+
var chatvue_type_template_id_322788ca_scoped_true_render = function render() {
|
|
12598
|
+
var _vm = this,
|
|
12599
|
+
_c = _vm._self._c;
|
|
12600
|
+
return _c('div', {
|
|
12601
|
+
ref: "chatContainer",
|
|
12602
|
+
staticClass: "chat-contain"
|
|
12603
|
+
}, _vm._l(_vm.messageData, function (list, index) {
|
|
12604
|
+
return _c('div', {
|
|
12605
|
+
key: index,
|
|
12606
|
+
staticClass: "message",
|
|
12607
|
+
class: {
|
|
12608
|
+
'user-list': list.type === 'user'
|
|
12609
|
+
}
|
|
12610
|
+
}, [list.type === 'robot' ? _c('div', {
|
|
12611
|
+
staticClass: "robot"
|
|
12612
|
+
}, [_c('div', {
|
|
12613
|
+
staticClass: "robot-image-div"
|
|
12614
|
+
})]) : _c('div', {
|
|
12615
|
+
staticClass: "robot user"
|
|
12616
|
+
}, [_vm._v("user")]), _c('div', {
|
|
12617
|
+
staticClass: "robot-message",
|
|
12618
|
+
class: {
|
|
12619
|
+
'user-info': list.type === 'user'
|
|
12620
|
+
}
|
|
12621
|
+
}, [_c('div', {
|
|
12622
|
+
domProps: {
|
|
12623
|
+
"innerHTML": _vm._s(list.message)
|
|
12624
|
+
}
|
|
12625
|
+
}), list.type === 'robot' && list.links.length > 0 ? _c('div', {
|
|
12626
|
+
staticClass: "link"
|
|
12627
|
+
}, [!list.allIdWithStart ? _c('div', [_c('div', {
|
|
12628
|
+
staticClass: "link-title"
|
|
12629
|
+
}, [_vm._v("参考文件")]), _c('div', {
|
|
12630
|
+
staticClass: "link-content"
|
|
12631
|
+
}, [_vm._l(list.links, function (item) {
|
|
12632
|
+
return [!item.title.startsWith(_vm.chatMajorId) ? _c('div', {
|
|
12633
|
+
staticClass: "links"
|
|
12634
|
+
}, [_c('a', {
|
|
12635
|
+
attrs: {
|
|
12636
|
+
"href": 'https://ai-yuliao.hep.com.cn' + item.documentUrl,
|
|
12637
|
+
"target": "_blank"
|
|
12638
|
+
}
|
|
12639
|
+
}, [_c('span', [_vm._v(_vm._s(item.title))])])]) : _vm._e()];
|
|
12640
|
+
})], 2)]) : _vm._e()]) : _vm._e(), list.type === 'robot' && list.connectUrl.length > 0 ? _c('div', {
|
|
12641
|
+
staticClass: "link"
|
|
12642
|
+
}, [_c('div', {
|
|
12643
|
+
staticClass: "link-title"
|
|
12644
|
+
}, [_vm._v("相关链接")]), _c('div', {
|
|
12645
|
+
staticClass: "link-content"
|
|
12646
|
+
}, [_vm._l(list.connectUrl, function (item) {
|
|
12647
|
+
return [_c('div', {
|
|
12648
|
+
staticClass: "links"
|
|
12649
|
+
}, [_c('a', {
|
|
12650
|
+
attrs: {
|
|
12651
|
+
"href": item.iaUrl,
|
|
12652
|
+
"target": "_blank"
|
|
12653
|
+
}
|
|
12654
|
+
}, [_c('span', [_vm._v(_vm._s(item.iaUrlName))])])])];
|
|
12655
|
+
})], 2)]) : _vm._e(), list.type === 'robot' && _vm.finish && list.followUps && list.followUps.length > 0 ? _c('div', [_c('div', {
|
|
12656
|
+
staticClass: "link-title"
|
|
12657
|
+
}, [_vm._v("智能追问")]), _c('div', {
|
|
12658
|
+
staticClass: "link-content"
|
|
12659
|
+
}, _vm._l(list.followUps, function (list, index) {
|
|
12660
|
+
return _c('div', {
|
|
12661
|
+
key: index,
|
|
12662
|
+
staticClass: "hot-list",
|
|
12663
|
+
on: {
|
|
12664
|
+
"click": function ($event) {
|
|
12665
|
+
return _vm.selectModule(list);
|
|
12666
|
+
}
|
|
12667
|
+
}
|
|
12668
|
+
}, [_vm._v(" " + _vm._s(list) + " "), _c('i', {
|
|
12669
|
+
staticClass: "el-icon-arrow-right go-icon"
|
|
12670
|
+
})]);
|
|
12671
|
+
}), 0)]) : _vm._e(), list.type === 'robot' ? _c('chat-tools', {
|
|
12672
|
+
attrs: {
|
|
12673
|
+
"chatId": _vm.chatId,
|
|
12674
|
+
"detail-data": list,
|
|
12675
|
+
"sending": list.sending,
|
|
12676
|
+
"resId": _vm.resId,
|
|
12677
|
+
"open-course-id": _vm.openCourseId,
|
|
12678
|
+
"is-last": index === _vm.messageData.length - 1
|
|
12679
|
+
},
|
|
12680
|
+
on: {
|
|
12681
|
+
"on-reanswer": list => _vm.reanswer(list, index),
|
|
12682
|
+
"on-stop-chat": _vm.onStopChat
|
|
12683
|
+
}
|
|
12684
|
+
}) : _vm._e()], 1)]);
|
|
12685
|
+
}), 0);
|
|
12686
|
+
};
|
|
12687
|
+
var chatvue_type_template_id_322788ca_scoped_true_staticRenderFns = [];
|
|
12688
|
+
|
|
12689
|
+
;// ./components/demo/utils/config.js
|
|
12690
|
+
|
|
12691
|
+
// import constants from '../utils/constants';
|
|
12692
|
+
|
|
12693
|
+
const errorList = [{
|
|
12694
|
+
name: "格式问题",
|
|
12695
|
+
code: "1"
|
|
12696
|
+
}, {
|
|
12697
|
+
name: "逻辑问题",
|
|
12565
12698
|
code: "2"
|
|
12566
12699
|
}, {
|
|
12567
12700
|
name: "有害信息",
|
|
@@ -12583,25 +12716,31 @@ const cacheMessageList = [{
|
|
|
12583
12716
|
type: 'robot',
|
|
12584
12717
|
message: '电磁感应定律是描述磁场与电场之间关系的物理定律。具体来说,当导体回路中的磁通量发生变化时,会在回路中产生感应电动势。这个感应电动势的大小与磁通量变化的速率成正比,这就是法拉第电磁感应定律。\n' + ' 相关的公式是:ε = -dΦ/dt\n' + ' 其中,ε 表示感应电动势,Φ 表示磁通量,t 表示时间,dΦ/dt 则表示磁通量对时间的变化率。注意这里的负号,它表示感应电动势的方向与磁通量变化的方向相反,这是楞次定律的体现。\n' + ' 解释这个公式时,我们可以理解为:当穿过一个闭合导体回路的磁通量发生变化时,会在回路中产生感应电动势,其大小正比于磁通量变化的速率。这种感应电动势是由于磁场的变化而引发的,它是磁场变化对电场的直接影响,体现了磁场与电场之间的紧密联系。'
|
|
12585
12718
|
}];
|
|
12719
|
+
|
|
12720
|
+
// export const getUserInfo = async (token) => {
|
|
12721
|
+
// const ssoRes = await ssoAuth(token);
|
|
12722
|
+
// const userRes = await authUser({
|
|
12723
|
+
// 'X-Auth-User': encodeURIComponent(ssoRes.name),
|
|
12724
|
+
// 'X-Auth-Token': ssoRes.password,
|
|
12725
|
+
// 'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
|
|
12726
|
+
// 'X-App-Id': `${constants['X-App-Id']}`,
|
|
12727
|
+
// 'X-App-Secret': `${constants['X-App-Secret']}`,
|
|
12728
|
+
// 'X-Auth-User-Type': '1',
|
|
12729
|
+
// });
|
|
12730
|
+
// cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
|
|
12731
|
+
// }
|
|
12732
|
+
|
|
12586
12733
|
const getUserInfo = async token => {
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
'X-Auth-User': encodeURIComponent(ssoRes.name),
|
|
12590
|
-
'X-Auth-Token': ssoRes.password,
|
|
12591
|
-
'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
|
|
12592
|
-
'X-App-Id': `${constants['X-App-Id']}`,
|
|
12593
|
-
'X-App-Secret': `${constants['X-App-Secret']}`,
|
|
12594
|
-
'X-Auth-User-Type': '1'
|
|
12595
|
-
});
|
|
12596
|
-
cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
|
|
12734
|
+
await ssoAuth(token);
|
|
12735
|
+
cache.session.setJSON('SRKJ_TOKEN_CACHE', token);
|
|
12597
12736
|
};
|
|
12598
|
-
;//
|
|
12599
|
-
var
|
|
12737
|
+
;// ./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=78eed5c6&scoped=true
|
|
12738
|
+
var chat_toolsvue_type_template_id_78eed5c6_scoped_true_render = function render() {
|
|
12600
12739
|
var _vm = this,
|
|
12601
12740
|
_c = _vm._self._c;
|
|
12602
12741
|
return _c('div', {
|
|
12603
12742
|
staticClass: "robot-tools"
|
|
12604
|
-
}, [_vm.listData.stop || _vm.listData.finish && !_vm.sending ? _c('div', {
|
|
12743
|
+
}, [(_vm.listData.stop || _vm.listData.finish && !_vm.sending) && _vm.isLast ? _c('div', {
|
|
12605
12744
|
staticClass: "robot-reanswer",
|
|
12606
12745
|
staticStyle: {
|
|
12607
12746
|
"margin-bottom": "8px"
|
|
@@ -12684,216 +12823,2736 @@ var chat_toolsvue_type_template_id_4de6d38a_scoped_true_render = function render
|
|
|
12684
12823
|
"alt": "",
|
|
12685
12824
|
"src": __webpack_require__(554)
|
|
12686
12825
|
}
|
|
12687
|
-
})]) : _c('div', {
|
|
12688
|
-
staticClass: "tools-icon",
|
|
12689
|
-
on: {
|
|
12690
|
-
"click": function ($event) {
|
|
12691
|
-
return _vm.doCai(_vm.listData);
|
|
12692
|
-
}
|
|
12826
|
+
})]) : _c('div', {
|
|
12827
|
+
staticClass: "tools-icon",
|
|
12828
|
+
on: {
|
|
12829
|
+
"click": function ($event) {
|
|
12830
|
+
return _vm.doCai(_vm.listData);
|
|
12831
|
+
}
|
|
12832
|
+
}
|
|
12833
|
+
}, [_c('img', {
|
|
12834
|
+
attrs: {
|
|
12835
|
+
"alt": "",
|
|
12836
|
+
"src": __webpack_require__(271)
|
|
12837
|
+
}
|
|
12838
|
+
})])])], 1), _c('div', {
|
|
12839
|
+
staticClass: "popover-box"
|
|
12840
|
+
}, [_c('div', {
|
|
12841
|
+
staticClass: "pop-title"
|
|
12842
|
+
}, [_vm._v(" 你的反馈将 "), _c('br'), _vm._v(" 帮助职教一问优化进步 ")]), _c('i', {
|
|
12843
|
+
staticClass: "el-icon-close",
|
|
12844
|
+
staticStyle: {
|
|
12845
|
+
"font-size": "2rem"
|
|
12846
|
+
},
|
|
12847
|
+
on: {
|
|
12848
|
+
"click": function ($event) {
|
|
12849
|
+
return _vm.cancelPopover();
|
|
12850
|
+
}
|
|
12851
|
+
}
|
|
12852
|
+
}), _c('div', {
|
|
12853
|
+
staticClass: "error-list"
|
|
12854
|
+
}, [_c('el-checkbox-group', {
|
|
12855
|
+
model: {
|
|
12856
|
+
value: _vm.errors,
|
|
12857
|
+
callback: function ($$v) {
|
|
12858
|
+
_vm.errors = $$v;
|
|
12859
|
+
},
|
|
12860
|
+
expression: "errors"
|
|
12861
|
+
}
|
|
12862
|
+
}, _vm._l(_vm.errorList, function (item) {
|
|
12863
|
+
return _c('el-checkbox', {
|
|
12864
|
+
key: item.code,
|
|
12865
|
+
staticClass: "check",
|
|
12866
|
+
attrs: {
|
|
12867
|
+
"label": item.code,
|
|
12868
|
+
"border": ""
|
|
12869
|
+
}
|
|
12870
|
+
}, [_vm._v(" " + _vm._s(item.name) + " ")]);
|
|
12871
|
+
}), 1), _c('el-input', {
|
|
12872
|
+
attrs: {
|
|
12873
|
+
"rows": 4,
|
|
12874
|
+
"maxlength": "30",
|
|
12875
|
+
"placeholder": "其他",
|
|
12876
|
+
"resize": "none",
|
|
12877
|
+
"type": "textarea"
|
|
12878
|
+
},
|
|
12879
|
+
model: {
|
|
12880
|
+
value: _vm.input,
|
|
12881
|
+
callback: function ($$v) {
|
|
12882
|
+
_vm.input = $$v;
|
|
12883
|
+
},
|
|
12884
|
+
expression: "input"
|
|
12885
|
+
}
|
|
12886
|
+
}), _c('div', {
|
|
12887
|
+
staticClass: "sumit-button"
|
|
12888
|
+
}, [_c('el-button', {
|
|
12889
|
+
attrs: {
|
|
12890
|
+
"disabled": _vm.canSubmit
|
|
12891
|
+
},
|
|
12892
|
+
on: {
|
|
12893
|
+
"click": function ($event) {
|
|
12894
|
+
return _vm.doCai(_vm.listData);
|
|
12895
|
+
}
|
|
12896
|
+
}
|
|
12897
|
+
}, [_vm._v("提交")])], 1)], 1)])])], 1)]);
|
|
12898
|
+
};
|
|
12899
|
+
var chat_toolsvue_type_template_id_78eed5c6_scoped_true_staticRenderFns = [];
|
|
12900
|
+
|
|
12901
|
+
;// ./components/demo/src/chat-tools.vue?vue&type=template&id=78eed5c6&scoped=true
|
|
12902
|
+
|
|
12903
|
+
;// ./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
|
|
12904
|
+
|
|
12905
|
+
|
|
12906
|
+
/* harmony default export */ var chat_toolsvue_type_script_lang_js = ({
|
|
12907
|
+
name: 'ChatTools',
|
|
12908
|
+
props: {
|
|
12909
|
+
detailData: {
|
|
12910
|
+
type: Object,
|
|
12911
|
+
default: () => {}
|
|
12912
|
+
},
|
|
12913
|
+
chatId: {
|
|
12914
|
+
type: String,
|
|
12915
|
+
default: ''
|
|
12916
|
+
},
|
|
12917
|
+
sending: {
|
|
12918
|
+
type: Boolean,
|
|
12919
|
+
default: false
|
|
12920
|
+
},
|
|
12921
|
+
resId: {
|
|
12922
|
+
type: String,
|
|
12923
|
+
default: ''
|
|
12924
|
+
},
|
|
12925
|
+
openCourseId: {
|
|
12926
|
+
type: String,
|
|
12927
|
+
default: ''
|
|
12928
|
+
},
|
|
12929
|
+
isLast: {
|
|
12930
|
+
type: Boolean,
|
|
12931
|
+
default: false
|
|
12932
|
+
}
|
|
12933
|
+
},
|
|
12934
|
+
data() {
|
|
12935
|
+
return {
|
|
12936
|
+
input: "",
|
|
12937
|
+
popover: false,
|
|
12938
|
+
errors: [],
|
|
12939
|
+
errorList: errorList
|
|
12940
|
+
};
|
|
12941
|
+
},
|
|
12942
|
+
computed: {
|
|
12943
|
+
canSubmit() {
|
|
12944
|
+
return this.errors.length === 0 && this.input === "";
|
|
12945
|
+
},
|
|
12946
|
+
listData() {
|
|
12947
|
+
return this.detailData;
|
|
12948
|
+
}
|
|
12949
|
+
},
|
|
12950
|
+
methods: {
|
|
12951
|
+
cancelPopover() {
|
|
12952
|
+
this.popover = false;
|
|
12953
|
+
},
|
|
12954
|
+
openPopover() {
|
|
12955
|
+
this.popover = true;
|
|
12956
|
+
},
|
|
12957
|
+
async stopChat(list) {
|
|
12958
|
+
const {
|
|
12959
|
+
msgId
|
|
12960
|
+
} = list;
|
|
12961
|
+
await stopChat(msgId);
|
|
12962
|
+
list.stop = true;
|
|
12963
|
+
this.$emit('on-stop-chat', list);
|
|
12964
|
+
},
|
|
12965
|
+
async reAnswer(list) {
|
|
12966
|
+
list.reAnswerCount += 1;
|
|
12967
|
+
if (list.reAnswerCount >= 3) {
|
|
12968
|
+
this.$confirm('对于回答是否依旧不满意,是否需要给教师负责人发送请求信息,由老师进行回答?', '提示', {
|
|
12969
|
+
confirmButtonText: '确定',
|
|
12970
|
+
cancelButtonText: '取消',
|
|
12971
|
+
type: 'warning'
|
|
12972
|
+
}).then(async () => {
|
|
12973
|
+
await pustReanswerToTeacher({
|
|
12974
|
+
chatId: this.chatId,
|
|
12975
|
+
msgId: list.msgId,
|
|
12976
|
+
parentMsgId: list.parentMsgId,
|
|
12977
|
+
courseId: this.resId,
|
|
12978
|
+
openCourseId: this.openCourseId
|
|
12979
|
+
});
|
|
12980
|
+
this.$message.success('已发送给老师');
|
|
12981
|
+
}).catch(() => {});
|
|
12982
|
+
}
|
|
12983
|
+
this.$emit('on-reanswer', list);
|
|
12984
|
+
},
|
|
12985
|
+
async doZan(list) {
|
|
12986
|
+
const param = {
|
|
12987
|
+
chatId: this.chatId,
|
|
12988
|
+
msgId: list.msgId,
|
|
12989
|
+
type: 1
|
|
12990
|
+
};
|
|
12991
|
+
list.zan ? await chatEvaluateCancel(param) : await chatEvaluateAdd(param);
|
|
12992
|
+
list.zan = !list.zan;
|
|
12993
|
+
list.cai = false;
|
|
12994
|
+
},
|
|
12995
|
+
async doCai(list) {
|
|
12996
|
+
let caiOption = {};
|
|
12997
|
+
if (!list.cai) {
|
|
12998
|
+
caiOption = {
|
|
12999
|
+
desc: this.input,
|
|
13000
|
+
tags: this.errors
|
|
13001
|
+
};
|
|
13002
|
+
}
|
|
13003
|
+
const param = {
|
|
13004
|
+
chatId: this.chatId,
|
|
13005
|
+
msgId: list.msgId,
|
|
13006
|
+
type: 2,
|
|
13007
|
+
...caiOption
|
|
13008
|
+
};
|
|
13009
|
+
list.cai ? await chatEvaluateCancel(param) : await chatEvaluateAdd(param);
|
|
13010
|
+
list.cai = !list.cai;
|
|
13011
|
+
list.zan = false;
|
|
13012
|
+
if (list.cai) {
|
|
13013
|
+
this.$message.success('感谢您的反馈');
|
|
13014
|
+
}
|
|
13015
|
+
this.popover = false;
|
|
13016
|
+
this.input = '';
|
|
13017
|
+
this.errors = [];
|
|
13018
|
+
}
|
|
13019
|
+
}
|
|
13020
|
+
});
|
|
13021
|
+
;// ./components/demo/src/chat-tools.vue?vue&type=script&lang=js
|
|
13022
|
+
/* harmony default export */ var src_chat_toolsvue_type_script_lang_js = (chat_toolsvue_type_script_lang_js);
|
|
13023
|
+
;// ./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=78eed5c6&prod&lang=scss&scoped=true
|
|
13024
|
+
// extracted by mini-css-extract-plugin
|
|
13025
|
+
|
|
13026
|
+
;// ./components/demo/src/chat-tools.vue?vue&type=style&index=0&id=78eed5c6&prod&lang=scss&scoped=true
|
|
13027
|
+
|
|
13028
|
+
;// ./components/demo/src/chat-tools.vue
|
|
13029
|
+
|
|
13030
|
+
|
|
13031
|
+
|
|
13032
|
+
;
|
|
13033
|
+
|
|
13034
|
+
|
|
13035
|
+
/* normalize component */
|
|
13036
|
+
|
|
13037
|
+
var chat_tools_component = normalizeComponent(
|
|
13038
|
+
src_chat_toolsvue_type_script_lang_js,
|
|
13039
|
+
chat_toolsvue_type_template_id_78eed5c6_scoped_true_render,
|
|
13040
|
+
chat_toolsvue_type_template_id_78eed5c6_scoped_true_staticRenderFns,
|
|
13041
|
+
false,
|
|
13042
|
+
null,
|
|
13043
|
+
"78eed5c6",
|
|
13044
|
+
null
|
|
13045
|
+
|
|
13046
|
+
)
|
|
13047
|
+
|
|
13048
|
+
/* harmony default export */ var chat_tools = (chat_tools_component.exports);
|
|
13049
|
+
;// ./node_modules/marked/lib/marked.esm.js
|
|
13050
|
+
/**
|
|
13051
|
+
* marked v14.1.2 - a markdown parser
|
|
13052
|
+
* Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
|
|
13053
|
+
* https://github.com/markedjs/marked
|
|
13054
|
+
*/
|
|
13055
|
+
|
|
13056
|
+
/**
|
|
13057
|
+
* DO NOT EDIT THIS FILE
|
|
13058
|
+
* The code in this file is generated from files in ./src/
|
|
13059
|
+
*/
|
|
13060
|
+
|
|
13061
|
+
/**
|
|
13062
|
+
* Gets the original marked default options.
|
|
13063
|
+
*/
|
|
13064
|
+
function _getDefaults() {
|
|
13065
|
+
return {
|
|
13066
|
+
async: false,
|
|
13067
|
+
breaks: false,
|
|
13068
|
+
extensions: null,
|
|
13069
|
+
gfm: true,
|
|
13070
|
+
hooks: null,
|
|
13071
|
+
pedantic: false,
|
|
13072
|
+
renderer: null,
|
|
13073
|
+
silent: false,
|
|
13074
|
+
tokenizer: null,
|
|
13075
|
+
walkTokens: null,
|
|
13076
|
+
};
|
|
13077
|
+
}
|
|
13078
|
+
let _defaults = _getDefaults();
|
|
13079
|
+
function changeDefaults(newDefaults) {
|
|
13080
|
+
_defaults = newDefaults;
|
|
13081
|
+
}
|
|
13082
|
+
|
|
13083
|
+
/**
|
|
13084
|
+
* Helpers
|
|
13085
|
+
*/
|
|
13086
|
+
const escapeTest = /[&<>"']/;
|
|
13087
|
+
const escapeReplace = new RegExp(escapeTest.source, 'g');
|
|
13088
|
+
const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
|
|
13089
|
+
const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
|
|
13090
|
+
const escapeReplacements = {
|
|
13091
|
+
'&': '&',
|
|
13092
|
+
'<': '<',
|
|
13093
|
+
'>': '>',
|
|
13094
|
+
'"': '"',
|
|
13095
|
+
"'": ''',
|
|
13096
|
+
};
|
|
13097
|
+
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
13098
|
+
function escape$1(html, encode) {
|
|
13099
|
+
if (encode) {
|
|
13100
|
+
if (escapeTest.test(html)) {
|
|
13101
|
+
return html.replace(escapeReplace, getEscapeReplacement);
|
|
13102
|
+
}
|
|
13103
|
+
}
|
|
13104
|
+
else {
|
|
13105
|
+
if (escapeTestNoEncode.test(html)) {
|
|
13106
|
+
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
13107
|
+
}
|
|
13108
|
+
}
|
|
13109
|
+
return html;
|
|
13110
|
+
}
|
|
13111
|
+
const caret = /(^|[^\[])\^/g;
|
|
13112
|
+
function edit(regex, opt) {
|
|
13113
|
+
let source = typeof regex === 'string' ? regex : regex.source;
|
|
13114
|
+
opt = opt || '';
|
|
13115
|
+
const obj = {
|
|
13116
|
+
replace: (name, val) => {
|
|
13117
|
+
let valSource = typeof val === 'string' ? val : val.source;
|
|
13118
|
+
valSource = valSource.replace(caret, '$1');
|
|
13119
|
+
source = source.replace(name, valSource);
|
|
13120
|
+
return obj;
|
|
13121
|
+
},
|
|
13122
|
+
getRegex: () => {
|
|
13123
|
+
return new RegExp(source, opt);
|
|
13124
|
+
},
|
|
13125
|
+
};
|
|
13126
|
+
return obj;
|
|
13127
|
+
}
|
|
13128
|
+
function cleanUrl(href) {
|
|
13129
|
+
try {
|
|
13130
|
+
href = encodeURI(href).replace(/%25/g, '%');
|
|
13131
|
+
}
|
|
13132
|
+
catch {
|
|
13133
|
+
return null;
|
|
13134
|
+
}
|
|
13135
|
+
return href;
|
|
13136
|
+
}
|
|
13137
|
+
const noopTest = { exec: () => null };
|
|
13138
|
+
function splitCells(tableRow, count) {
|
|
13139
|
+
// ensure that every cell-delimiting pipe has a space
|
|
13140
|
+
// before it to distinguish it from an escaped pipe
|
|
13141
|
+
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
13142
|
+
let escaped = false;
|
|
13143
|
+
let curr = offset;
|
|
13144
|
+
while (--curr >= 0 && str[curr] === '\\')
|
|
13145
|
+
escaped = !escaped;
|
|
13146
|
+
if (escaped) {
|
|
13147
|
+
// odd number of slashes means | is escaped
|
|
13148
|
+
// so we leave it alone
|
|
13149
|
+
return '|';
|
|
13150
|
+
}
|
|
13151
|
+
else {
|
|
13152
|
+
// add space before unescaped |
|
|
13153
|
+
return ' |';
|
|
13154
|
+
}
|
|
13155
|
+
}), cells = row.split(/ \|/);
|
|
13156
|
+
let i = 0;
|
|
13157
|
+
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
13158
|
+
if (!cells[0].trim()) {
|
|
13159
|
+
cells.shift();
|
|
13160
|
+
}
|
|
13161
|
+
if (cells.length > 0 && !cells[cells.length - 1].trim()) {
|
|
13162
|
+
cells.pop();
|
|
13163
|
+
}
|
|
13164
|
+
if (count) {
|
|
13165
|
+
if (cells.length > count) {
|
|
13166
|
+
cells.splice(count);
|
|
13167
|
+
}
|
|
13168
|
+
else {
|
|
13169
|
+
while (cells.length < count)
|
|
13170
|
+
cells.push('');
|
|
13171
|
+
}
|
|
13172
|
+
}
|
|
13173
|
+
for (; i < cells.length; i++) {
|
|
13174
|
+
// leading or trailing whitespace is ignored per the gfm spec
|
|
13175
|
+
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
13176
|
+
}
|
|
13177
|
+
return cells;
|
|
13178
|
+
}
|
|
13179
|
+
/**
|
|
13180
|
+
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
13181
|
+
* /c*$/ is vulnerable to REDOS.
|
|
13182
|
+
*
|
|
13183
|
+
* @param str
|
|
13184
|
+
* @param c
|
|
13185
|
+
* @param invert Remove suffix of non-c chars instead. Default falsey.
|
|
13186
|
+
*/
|
|
13187
|
+
function rtrim(str, c, invert) {
|
|
13188
|
+
const l = str.length;
|
|
13189
|
+
if (l === 0) {
|
|
13190
|
+
return '';
|
|
13191
|
+
}
|
|
13192
|
+
// Length of suffix matching the invert condition.
|
|
13193
|
+
let suffLen = 0;
|
|
13194
|
+
// Step left until we fail to match the invert condition.
|
|
13195
|
+
while (suffLen < l) {
|
|
13196
|
+
const currChar = str.charAt(l - suffLen - 1);
|
|
13197
|
+
if (currChar === c && !invert) {
|
|
13198
|
+
suffLen++;
|
|
13199
|
+
}
|
|
13200
|
+
else if (currChar !== c && invert) {
|
|
13201
|
+
suffLen++;
|
|
13202
|
+
}
|
|
13203
|
+
else {
|
|
13204
|
+
break;
|
|
13205
|
+
}
|
|
13206
|
+
}
|
|
13207
|
+
return str.slice(0, l - suffLen);
|
|
13208
|
+
}
|
|
13209
|
+
function findClosingBracket(str, b) {
|
|
13210
|
+
if (str.indexOf(b[1]) === -1) {
|
|
13211
|
+
return -1;
|
|
13212
|
+
}
|
|
13213
|
+
let level = 0;
|
|
13214
|
+
for (let i = 0; i < str.length; i++) {
|
|
13215
|
+
if (str[i] === '\\') {
|
|
13216
|
+
i++;
|
|
13217
|
+
}
|
|
13218
|
+
else if (str[i] === b[0]) {
|
|
13219
|
+
level++;
|
|
13220
|
+
}
|
|
13221
|
+
else if (str[i] === b[1]) {
|
|
13222
|
+
level--;
|
|
13223
|
+
if (level < 0) {
|
|
13224
|
+
return i;
|
|
13225
|
+
}
|
|
13226
|
+
}
|
|
13227
|
+
}
|
|
13228
|
+
return -1;
|
|
13229
|
+
}
|
|
13230
|
+
|
|
13231
|
+
function outputLink(cap, link, raw, lexer) {
|
|
13232
|
+
const href = link.href;
|
|
13233
|
+
const title = link.title ? escape$1(link.title) : null;
|
|
13234
|
+
const text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
13235
|
+
if (cap[0].charAt(0) !== '!') {
|
|
13236
|
+
lexer.state.inLink = true;
|
|
13237
|
+
const token = {
|
|
13238
|
+
type: 'link',
|
|
13239
|
+
raw,
|
|
13240
|
+
href,
|
|
13241
|
+
title,
|
|
13242
|
+
text,
|
|
13243
|
+
tokens: lexer.inlineTokens(text),
|
|
13244
|
+
};
|
|
13245
|
+
lexer.state.inLink = false;
|
|
13246
|
+
return token;
|
|
13247
|
+
}
|
|
13248
|
+
return {
|
|
13249
|
+
type: 'image',
|
|
13250
|
+
raw,
|
|
13251
|
+
href,
|
|
13252
|
+
title,
|
|
13253
|
+
text: escape$1(text),
|
|
13254
|
+
};
|
|
13255
|
+
}
|
|
13256
|
+
function indentCodeCompensation(raw, text) {
|
|
13257
|
+
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
13258
|
+
if (matchIndentToCode === null) {
|
|
13259
|
+
return text;
|
|
13260
|
+
}
|
|
13261
|
+
const indentToCode = matchIndentToCode[1];
|
|
13262
|
+
return text
|
|
13263
|
+
.split('\n')
|
|
13264
|
+
.map(node => {
|
|
13265
|
+
const matchIndentInNode = node.match(/^\s+/);
|
|
13266
|
+
if (matchIndentInNode === null) {
|
|
13267
|
+
return node;
|
|
13268
|
+
}
|
|
13269
|
+
const [indentInNode] = matchIndentInNode;
|
|
13270
|
+
if (indentInNode.length >= indentToCode.length) {
|
|
13271
|
+
return node.slice(indentToCode.length);
|
|
13272
|
+
}
|
|
13273
|
+
return node;
|
|
13274
|
+
})
|
|
13275
|
+
.join('\n');
|
|
13276
|
+
}
|
|
13277
|
+
/**
|
|
13278
|
+
* Tokenizer
|
|
13279
|
+
*/
|
|
13280
|
+
class _Tokenizer {
|
|
13281
|
+
options;
|
|
13282
|
+
rules; // set by the lexer
|
|
13283
|
+
lexer; // set by the lexer
|
|
13284
|
+
constructor(options) {
|
|
13285
|
+
this.options = options || _defaults;
|
|
13286
|
+
}
|
|
13287
|
+
space(src) {
|
|
13288
|
+
const cap = this.rules.block.newline.exec(src);
|
|
13289
|
+
if (cap && cap[0].length > 0) {
|
|
13290
|
+
return {
|
|
13291
|
+
type: 'space',
|
|
13292
|
+
raw: cap[0],
|
|
13293
|
+
};
|
|
13294
|
+
}
|
|
13295
|
+
}
|
|
13296
|
+
code(src) {
|
|
13297
|
+
const cap = this.rules.block.code.exec(src);
|
|
13298
|
+
if (cap) {
|
|
13299
|
+
const text = cap[0].replace(/^(?: {1,4}| {0,3}\t)/gm, '');
|
|
13300
|
+
return {
|
|
13301
|
+
type: 'code',
|
|
13302
|
+
raw: cap[0],
|
|
13303
|
+
codeBlockStyle: 'indented',
|
|
13304
|
+
text: !this.options.pedantic
|
|
13305
|
+
? rtrim(text, '\n')
|
|
13306
|
+
: text,
|
|
13307
|
+
};
|
|
13308
|
+
}
|
|
13309
|
+
}
|
|
13310
|
+
fences(src) {
|
|
13311
|
+
const cap = this.rules.block.fences.exec(src);
|
|
13312
|
+
if (cap) {
|
|
13313
|
+
const raw = cap[0];
|
|
13314
|
+
const text = indentCodeCompensation(raw, cap[3] || '');
|
|
13315
|
+
return {
|
|
13316
|
+
type: 'code',
|
|
13317
|
+
raw,
|
|
13318
|
+
lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2],
|
|
13319
|
+
text,
|
|
13320
|
+
};
|
|
13321
|
+
}
|
|
13322
|
+
}
|
|
13323
|
+
heading(src) {
|
|
13324
|
+
const cap = this.rules.block.heading.exec(src);
|
|
13325
|
+
if (cap) {
|
|
13326
|
+
let text = cap[2].trim();
|
|
13327
|
+
// remove trailing #s
|
|
13328
|
+
if (/#$/.test(text)) {
|
|
13329
|
+
const trimmed = rtrim(text, '#');
|
|
13330
|
+
if (this.options.pedantic) {
|
|
13331
|
+
text = trimmed.trim();
|
|
13332
|
+
}
|
|
13333
|
+
else if (!trimmed || / $/.test(trimmed)) {
|
|
13334
|
+
// CommonMark requires space before trailing #s
|
|
13335
|
+
text = trimmed.trim();
|
|
13336
|
+
}
|
|
13337
|
+
}
|
|
13338
|
+
return {
|
|
13339
|
+
type: 'heading',
|
|
13340
|
+
raw: cap[0],
|
|
13341
|
+
depth: cap[1].length,
|
|
13342
|
+
text,
|
|
13343
|
+
tokens: this.lexer.inline(text),
|
|
13344
|
+
};
|
|
13345
|
+
}
|
|
13346
|
+
}
|
|
13347
|
+
hr(src) {
|
|
13348
|
+
const cap = this.rules.block.hr.exec(src);
|
|
13349
|
+
if (cap) {
|
|
13350
|
+
return {
|
|
13351
|
+
type: 'hr',
|
|
13352
|
+
raw: rtrim(cap[0], '\n'),
|
|
13353
|
+
};
|
|
13354
|
+
}
|
|
13355
|
+
}
|
|
13356
|
+
blockquote(src) {
|
|
13357
|
+
const cap = this.rules.block.blockquote.exec(src);
|
|
13358
|
+
if (cap) {
|
|
13359
|
+
let lines = rtrim(cap[0], '\n').split('\n');
|
|
13360
|
+
let raw = '';
|
|
13361
|
+
let text = '';
|
|
13362
|
+
const tokens = [];
|
|
13363
|
+
while (lines.length > 0) {
|
|
13364
|
+
let inBlockquote = false;
|
|
13365
|
+
const currentLines = [];
|
|
13366
|
+
let i;
|
|
13367
|
+
for (i = 0; i < lines.length; i++) {
|
|
13368
|
+
// get lines up to a continuation
|
|
13369
|
+
if (/^ {0,3}>/.test(lines[i])) {
|
|
13370
|
+
currentLines.push(lines[i]);
|
|
13371
|
+
inBlockquote = true;
|
|
13372
|
+
}
|
|
13373
|
+
else if (!inBlockquote) {
|
|
13374
|
+
currentLines.push(lines[i]);
|
|
13375
|
+
}
|
|
13376
|
+
else {
|
|
13377
|
+
break;
|
|
13378
|
+
}
|
|
13379
|
+
}
|
|
13380
|
+
lines = lines.slice(i);
|
|
13381
|
+
const currentRaw = currentLines.join('\n');
|
|
13382
|
+
const currentText = currentRaw
|
|
13383
|
+
// precede setext continuation with 4 spaces so it isn't a setext
|
|
13384
|
+
.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, '\n $1')
|
|
13385
|
+
.replace(/^ {0,3}>[ \t]?/gm, '');
|
|
13386
|
+
raw = raw ? `${raw}\n${currentRaw}` : currentRaw;
|
|
13387
|
+
text = text ? `${text}\n${currentText}` : currentText;
|
|
13388
|
+
// parse blockquote lines as top level tokens
|
|
13389
|
+
// merge paragraphs if this is a continuation
|
|
13390
|
+
const top = this.lexer.state.top;
|
|
13391
|
+
this.lexer.state.top = true;
|
|
13392
|
+
this.lexer.blockTokens(currentText, tokens, true);
|
|
13393
|
+
this.lexer.state.top = top;
|
|
13394
|
+
// if there is no continuation then we are done
|
|
13395
|
+
if (lines.length === 0) {
|
|
13396
|
+
break;
|
|
13397
|
+
}
|
|
13398
|
+
const lastToken = tokens[tokens.length - 1];
|
|
13399
|
+
if (lastToken?.type === 'code') {
|
|
13400
|
+
// blockquote continuation cannot be preceded by a code block
|
|
13401
|
+
break;
|
|
13402
|
+
}
|
|
13403
|
+
else if (lastToken?.type === 'blockquote') {
|
|
13404
|
+
// include continuation in nested blockquote
|
|
13405
|
+
const oldToken = lastToken;
|
|
13406
|
+
const newText = oldToken.raw + '\n' + lines.join('\n');
|
|
13407
|
+
const newToken = this.blockquote(newText);
|
|
13408
|
+
tokens[tokens.length - 1] = newToken;
|
|
13409
|
+
raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
|
|
13410
|
+
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
|
|
13411
|
+
break;
|
|
13412
|
+
}
|
|
13413
|
+
else if (lastToken?.type === 'list') {
|
|
13414
|
+
// include continuation in nested list
|
|
13415
|
+
const oldToken = lastToken;
|
|
13416
|
+
const newText = oldToken.raw + '\n' + lines.join('\n');
|
|
13417
|
+
const newToken = this.list(newText);
|
|
13418
|
+
tokens[tokens.length - 1] = newToken;
|
|
13419
|
+
raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
|
|
13420
|
+
text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
|
|
13421
|
+
lines = newText.substring(tokens[tokens.length - 1].raw.length).split('\n');
|
|
13422
|
+
continue;
|
|
13423
|
+
}
|
|
13424
|
+
}
|
|
13425
|
+
return {
|
|
13426
|
+
type: 'blockquote',
|
|
13427
|
+
raw,
|
|
13428
|
+
tokens,
|
|
13429
|
+
text,
|
|
13430
|
+
};
|
|
13431
|
+
}
|
|
13432
|
+
}
|
|
13433
|
+
list(src) {
|
|
13434
|
+
let cap = this.rules.block.list.exec(src);
|
|
13435
|
+
if (cap) {
|
|
13436
|
+
let bull = cap[1].trim();
|
|
13437
|
+
const isordered = bull.length > 1;
|
|
13438
|
+
const list = {
|
|
13439
|
+
type: 'list',
|
|
13440
|
+
raw: '',
|
|
13441
|
+
ordered: isordered,
|
|
13442
|
+
start: isordered ? +bull.slice(0, -1) : '',
|
|
13443
|
+
loose: false,
|
|
13444
|
+
items: [],
|
|
13445
|
+
};
|
|
13446
|
+
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
13447
|
+
if (this.options.pedantic) {
|
|
13448
|
+
bull = isordered ? bull : '[*+-]';
|
|
13449
|
+
}
|
|
13450
|
+
// Get next list item
|
|
13451
|
+
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
|
|
13452
|
+
let endsWithBlankLine = false;
|
|
13453
|
+
// Check if current bullet point can start a new List Item
|
|
13454
|
+
while (src) {
|
|
13455
|
+
let endEarly = false;
|
|
13456
|
+
let raw = '';
|
|
13457
|
+
let itemContents = '';
|
|
13458
|
+
if (!(cap = itemRegex.exec(src))) {
|
|
13459
|
+
break;
|
|
13460
|
+
}
|
|
13461
|
+
if (this.rules.block.hr.test(src)) { // End list if bullet was actually HR (possibly move into itemRegex?)
|
|
13462
|
+
break;
|
|
13463
|
+
}
|
|
13464
|
+
raw = cap[0];
|
|
13465
|
+
src = src.substring(raw.length);
|
|
13466
|
+
let line = cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length));
|
|
13467
|
+
let nextLine = src.split('\n', 1)[0];
|
|
13468
|
+
let blankLine = !line.trim();
|
|
13469
|
+
let indent = 0;
|
|
13470
|
+
if (this.options.pedantic) {
|
|
13471
|
+
indent = 2;
|
|
13472
|
+
itemContents = line.trimStart();
|
|
13473
|
+
}
|
|
13474
|
+
else if (blankLine) {
|
|
13475
|
+
indent = cap[1].length + 1;
|
|
13476
|
+
}
|
|
13477
|
+
else {
|
|
13478
|
+
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
13479
|
+
indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
|
|
13480
|
+
itemContents = line.slice(indent);
|
|
13481
|
+
indent += cap[1].length;
|
|
13482
|
+
}
|
|
13483
|
+
if (blankLine && /^[ \t]*$/.test(nextLine)) { // Items begin with at most one blank line
|
|
13484
|
+
raw += nextLine + '\n';
|
|
13485
|
+
src = src.substring(nextLine.length + 1);
|
|
13486
|
+
endEarly = true;
|
|
13487
|
+
}
|
|
13488
|
+
if (!endEarly) {
|
|
13489
|
+
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`);
|
|
13490
|
+
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
13491
|
+
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
|
|
13492
|
+
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
|
|
13493
|
+
const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, 'i');
|
|
13494
|
+
// Check if following lines should be included in List Item
|
|
13495
|
+
while (src) {
|
|
13496
|
+
const rawLine = src.split('\n', 1)[0];
|
|
13497
|
+
let nextLineWithoutTabs;
|
|
13498
|
+
nextLine = rawLine;
|
|
13499
|
+
// Re-align to follow commonmark nesting rules
|
|
13500
|
+
if (this.options.pedantic) {
|
|
13501
|
+
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
|
|
13502
|
+
nextLineWithoutTabs = nextLine;
|
|
13503
|
+
}
|
|
13504
|
+
else {
|
|
13505
|
+
nextLineWithoutTabs = nextLine.replace(/\t/g, ' ');
|
|
13506
|
+
}
|
|
13507
|
+
// End list item if found code fences
|
|
13508
|
+
if (fencesBeginRegex.test(nextLine)) {
|
|
13509
|
+
break;
|
|
13510
|
+
}
|
|
13511
|
+
// End list item if found start of new heading
|
|
13512
|
+
if (headingBeginRegex.test(nextLine)) {
|
|
13513
|
+
break;
|
|
13514
|
+
}
|
|
13515
|
+
// End list item if found start of html block
|
|
13516
|
+
if (htmlBeginRegex.test(nextLine)) {
|
|
13517
|
+
break;
|
|
13518
|
+
}
|
|
13519
|
+
// End list item if found start of new bullet
|
|
13520
|
+
if (nextBulletRegex.test(nextLine)) {
|
|
13521
|
+
break;
|
|
13522
|
+
}
|
|
13523
|
+
// Horizontal rule found
|
|
13524
|
+
if (hrRegex.test(nextLine)) {
|
|
13525
|
+
break;
|
|
13526
|
+
}
|
|
13527
|
+
if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible
|
|
13528
|
+
itemContents += '\n' + nextLineWithoutTabs.slice(indent);
|
|
13529
|
+
}
|
|
13530
|
+
else {
|
|
13531
|
+
// not enough indentation
|
|
13532
|
+
if (blankLine) {
|
|
13533
|
+
break;
|
|
13534
|
+
}
|
|
13535
|
+
// paragraph continuation unless last line was a different block level element
|
|
13536
|
+
if (line.replace(/\t/g, ' ').search(/[^ ]/) >= 4) { // indented code block
|
|
13537
|
+
break;
|
|
13538
|
+
}
|
|
13539
|
+
if (fencesBeginRegex.test(line)) {
|
|
13540
|
+
break;
|
|
13541
|
+
}
|
|
13542
|
+
if (headingBeginRegex.test(line)) {
|
|
13543
|
+
break;
|
|
13544
|
+
}
|
|
13545
|
+
if (hrRegex.test(line)) {
|
|
13546
|
+
break;
|
|
13547
|
+
}
|
|
13548
|
+
itemContents += '\n' + nextLine;
|
|
13549
|
+
}
|
|
13550
|
+
if (!blankLine && !nextLine.trim()) { // Check if current line is blank
|
|
13551
|
+
blankLine = true;
|
|
13552
|
+
}
|
|
13553
|
+
raw += rawLine + '\n';
|
|
13554
|
+
src = src.substring(rawLine.length + 1);
|
|
13555
|
+
line = nextLineWithoutTabs.slice(indent);
|
|
13556
|
+
}
|
|
13557
|
+
}
|
|
13558
|
+
if (!list.loose) {
|
|
13559
|
+
// If the previous item ended with a blank line, the list is loose
|
|
13560
|
+
if (endsWithBlankLine) {
|
|
13561
|
+
list.loose = true;
|
|
13562
|
+
}
|
|
13563
|
+
else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
|
|
13564
|
+
endsWithBlankLine = true;
|
|
13565
|
+
}
|
|
13566
|
+
}
|
|
13567
|
+
let istask = null;
|
|
13568
|
+
let ischecked;
|
|
13569
|
+
// Check for task list items
|
|
13570
|
+
if (this.options.gfm) {
|
|
13571
|
+
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
13572
|
+
if (istask) {
|
|
13573
|
+
ischecked = istask[0] !== '[ ] ';
|
|
13574
|
+
itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
|
|
13575
|
+
}
|
|
13576
|
+
}
|
|
13577
|
+
list.items.push({
|
|
13578
|
+
type: 'list_item',
|
|
13579
|
+
raw,
|
|
13580
|
+
task: !!istask,
|
|
13581
|
+
checked: ischecked,
|
|
13582
|
+
loose: false,
|
|
13583
|
+
text: itemContents,
|
|
13584
|
+
tokens: [],
|
|
13585
|
+
});
|
|
13586
|
+
list.raw += raw;
|
|
13587
|
+
}
|
|
13588
|
+
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
13589
|
+
list.items[list.items.length - 1].raw = list.items[list.items.length - 1].raw.trimEnd();
|
|
13590
|
+
list.items[list.items.length - 1].text = list.items[list.items.length - 1].text.trimEnd();
|
|
13591
|
+
list.raw = list.raw.trimEnd();
|
|
13592
|
+
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
13593
|
+
for (let i = 0; i < list.items.length; i++) {
|
|
13594
|
+
this.lexer.state.top = false;
|
|
13595
|
+
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
13596
|
+
if (!list.loose) {
|
|
13597
|
+
// Check if list should be loose
|
|
13598
|
+
const spacers = list.items[i].tokens.filter(t => t.type === 'space');
|
|
13599
|
+
const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => /\n.*\n/.test(t.raw));
|
|
13600
|
+
list.loose = hasMultipleLineBreaks;
|
|
13601
|
+
}
|
|
13602
|
+
}
|
|
13603
|
+
// Set all items to loose if list is loose
|
|
13604
|
+
if (list.loose) {
|
|
13605
|
+
for (let i = 0; i < list.items.length; i++) {
|
|
13606
|
+
list.items[i].loose = true;
|
|
13607
|
+
}
|
|
13608
|
+
}
|
|
13609
|
+
return list;
|
|
13610
|
+
}
|
|
13611
|
+
}
|
|
13612
|
+
html(src) {
|
|
13613
|
+
const cap = this.rules.block.html.exec(src);
|
|
13614
|
+
if (cap) {
|
|
13615
|
+
const token = {
|
|
13616
|
+
type: 'html',
|
|
13617
|
+
block: true,
|
|
13618
|
+
raw: cap[0],
|
|
13619
|
+
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
|
|
13620
|
+
text: cap[0],
|
|
13621
|
+
};
|
|
13622
|
+
return token;
|
|
13623
|
+
}
|
|
13624
|
+
}
|
|
13625
|
+
def(src) {
|
|
13626
|
+
const cap = this.rules.block.def.exec(src);
|
|
13627
|
+
if (cap) {
|
|
13628
|
+
const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
13629
|
+
const href = cap[2] ? cap[2].replace(/^<(.*)>$/, '$1').replace(this.rules.inline.anyPunctuation, '$1') : '';
|
|
13630
|
+
const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, '$1') : cap[3];
|
|
13631
|
+
return {
|
|
13632
|
+
type: 'def',
|
|
13633
|
+
tag,
|
|
13634
|
+
raw: cap[0],
|
|
13635
|
+
href,
|
|
13636
|
+
title,
|
|
13637
|
+
};
|
|
13638
|
+
}
|
|
13639
|
+
}
|
|
13640
|
+
table(src) {
|
|
13641
|
+
const cap = this.rules.block.table.exec(src);
|
|
13642
|
+
if (!cap) {
|
|
13643
|
+
return;
|
|
13644
|
+
}
|
|
13645
|
+
if (!/[:|]/.test(cap[2])) {
|
|
13646
|
+
// delimiter row must have a pipe (|) or colon (:) otherwise it is a setext heading
|
|
13647
|
+
return;
|
|
13648
|
+
}
|
|
13649
|
+
const headers = splitCells(cap[1]);
|
|
13650
|
+
const aligns = cap[2].replace(/^\||\| *$/g, '').split('|');
|
|
13651
|
+
const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : [];
|
|
13652
|
+
const item = {
|
|
13653
|
+
type: 'table',
|
|
13654
|
+
raw: cap[0],
|
|
13655
|
+
header: [],
|
|
13656
|
+
align: [],
|
|
13657
|
+
rows: [],
|
|
13658
|
+
};
|
|
13659
|
+
if (headers.length !== aligns.length) {
|
|
13660
|
+
// header and align columns must be equal, rows can be different.
|
|
13661
|
+
return;
|
|
13662
|
+
}
|
|
13663
|
+
for (const align of aligns) {
|
|
13664
|
+
if (/^ *-+: *$/.test(align)) {
|
|
13665
|
+
item.align.push('right');
|
|
13666
|
+
}
|
|
13667
|
+
else if (/^ *:-+: *$/.test(align)) {
|
|
13668
|
+
item.align.push('center');
|
|
13669
|
+
}
|
|
13670
|
+
else if (/^ *:-+ *$/.test(align)) {
|
|
13671
|
+
item.align.push('left');
|
|
13672
|
+
}
|
|
13673
|
+
else {
|
|
13674
|
+
item.align.push(null);
|
|
13675
|
+
}
|
|
13676
|
+
}
|
|
13677
|
+
for (let i = 0; i < headers.length; i++) {
|
|
13678
|
+
item.header.push({
|
|
13679
|
+
text: headers[i],
|
|
13680
|
+
tokens: this.lexer.inline(headers[i]),
|
|
13681
|
+
header: true,
|
|
13682
|
+
align: item.align[i],
|
|
13683
|
+
});
|
|
13684
|
+
}
|
|
13685
|
+
for (const row of rows) {
|
|
13686
|
+
item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
|
|
13687
|
+
return {
|
|
13688
|
+
text: cell,
|
|
13689
|
+
tokens: this.lexer.inline(cell),
|
|
13690
|
+
header: false,
|
|
13691
|
+
align: item.align[i],
|
|
13692
|
+
};
|
|
13693
|
+
}));
|
|
13694
|
+
}
|
|
13695
|
+
return item;
|
|
13696
|
+
}
|
|
13697
|
+
lheading(src) {
|
|
13698
|
+
const cap = this.rules.block.lheading.exec(src);
|
|
13699
|
+
if (cap) {
|
|
13700
|
+
return {
|
|
13701
|
+
type: 'heading',
|
|
13702
|
+
raw: cap[0],
|
|
13703
|
+
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
13704
|
+
text: cap[1],
|
|
13705
|
+
tokens: this.lexer.inline(cap[1]),
|
|
13706
|
+
};
|
|
13707
|
+
}
|
|
13708
|
+
}
|
|
13709
|
+
paragraph(src) {
|
|
13710
|
+
const cap = this.rules.block.paragraph.exec(src);
|
|
13711
|
+
if (cap) {
|
|
13712
|
+
const text = cap[1].charAt(cap[1].length - 1) === '\n'
|
|
13713
|
+
? cap[1].slice(0, -1)
|
|
13714
|
+
: cap[1];
|
|
13715
|
+
return {
|
|
13716
|
+
type: 'paragraph',
|
|
13717
|
+
raw: cap[0],
|
|
13718
|
+
text,
|
|
13719
|
+
tokens: this.lexer.inline(text),
|
|
13720
|
+
};
|
|
13721
|
+
}
|
|
13722
|
+
}
|
|
13723
|
+
text(src) {
|
|
13724
|
+
const cap = this.rules.block.text.exec(src);
|
|
13725
|
+
if (cap) {
|
|
13726
|
+
return {
|
|
13727
|
+
type: 'text',
|
|
13728
|
+
raw: cap[0],
|
|
13729
|
+
text: cap[0],
|
|
13730
|
+
tokens: this.lexer.inline(cap[0]),
|
|
13731
|
+
};
|
|
13732
|
+
}
|
|
13733
|
+
}
|
|
13734
|
+
escape(src) {
|
|
13735
|
+
const cap = this.rules.inline.escape.exec(src);
|
|
13736
|
+
if (cap) {
|
|
13737
|
+
return {
|
|
13738
|
+
type: 'escape',
|
|
13739
|
+
raw: cap[0],
|
|
13740
|
+
text: escape$1(cap[1]),
|
|
13741
|
+
};
|
|
13742
|
+
}
|
|
13743
|
+
}
|
|
13744
|
+
tag(src) {
|
|
13745
|
+
const cap = this.rules.inline.tag.exec(src);
|
|
13746
|
+
if (cap) {
|
|
13747
|
+
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
13748
|
+
this.lexer.state.inLink = true;
|
|
13749
|
+
}
|
|
13750
|
+
else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
|
|
13751
|
+
this.lexer.state.inLink = false;
|
|
13752
|
+
}
|
|
13753
|
+
if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
13754
|
+
this.lexer.state.inRawBlock = true;
|
|
13755
|
+
}
|
|
13756
|
+
else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
13757
|
+
this.lexer.state.inRawBlock = false;
|
|
13758
|
+
}
|
|
13759
|
+
return {
|
|
13760
|
+
type: 'html',
|
|
13761
|
+
raw: cap[0],
|
|
13762
|
+
inLink: this.lexer.state.inLink,
|
|
13763
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
13764
|
+
block: false,
|
|
13765
|
+
text: cap[0],
|
|
13766
|
+
};
|
|
13767
|
+
}
|
|
13768
|
+
}
|
|
13769
|
+
link(src) {
|
|
13770
|
+
const cap = this.rules.inline.link.exec(src);
|
|
13771
|
+
if (cap) {
|
|
13772
|
+
const trimmedUrl = cap[2].trim();
|
|
13773
|
+
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
13774
|
+
// commonmark requires matching angle brackets
|
|
13775
|
+
if (!(/>$/.test(trimmedUrl))) {
|
|
13776
|
+
return;
|
|
13777
|
+
}
|
|
13778
|
+
// ending angle bracket cannot be escaped
|
|
13779
|
+
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
13780
|
+
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
13781
|
+
return;
|
|
13782
|
+
}
|
|
13783
|
+
}
|
|
13784
|
+
else {
|
|
13785
|
+
// find closing parenthesis
|
|
13786
|
+
const lastParenIndex = findClosingBracket(cap[2], '()');
|
|
13787
|
+
if (lastParenIndex > -1) {
|
|
13788
|
+
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
13789
|
+
const linkLen = start + cap[1].length + lastParenIndex;
|
|
13790
|
+
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
13791
|
+
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
13792
|
+
cap[3] = '';
|
|
13793
|
+
}
|
|
13794
|
+
}
|
|
13795
|
+
let href = cap[2];
|
|
13796
|
+
let title = '';
|
|
13797
|
+
if (this.options.pedantic) {
|
|
13798
|
+
// split pedantic href and title
|
|
13799
|
+
const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
13800
|
+
if (link) {
|
|
13801
|
+
href = link[1];
|
|
13802
|
+
title = link[3];
|
|
13803
|
+
}
|
|
13804
|
+
}
|
|
13805
|
+
else {
|
|
13806
|
+
title = cap[3] ? cap[3].slice(1, -1) : '';
|
|
13807
|
+
}
|
|
13808
|
+
href = href.trim();
|
|
13809
|
+
if (/^</.test(href)) {
|
|
13810
|
+
if (this.options.pedantic && !(/>$/.test(trimmedUrl))) {
|
|
13811
|
+
// pedantic allows starting angle bracket without ending angle bracket
|
|
13812
|
+
href = href.slice(1);
|
|
13813
|
+
}
|
|
13814
|
+
else {
|
|
13815
|
+
href = href.slice(1, -1);
|
|
13816
|
+
}
|
|
13817
|
+
}
|
|
13818
|
+
return outputLink(cap, {
|
|
13819
|
+
href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href,
|
|
13820
|
+
title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title,
|
|
13821
|
+
}, cap[0], this.lexer);
|
|
13822
|
+
}
|
|
13823
|
+
}
|
|
13824
|
+
reflink(src, links) {
|
|
13825
|
+
let cap;
|
|
13826
|
+
if ((cap = this.rules.inline.reflink.exec(src))
|
|
13827
|
+
|| (cap = this.rules.inline.nolink.exec(src))) {
|
|
13828
|
+
const linkString = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
|
13829
|
+
const link = links[linkString.toLowerCase()];
|
|
13830
|
+
if (!link) {
|
|
13831
|
+
const text = cap[0].charAt(0);
|
|
13832
|
+
return {
|
|
13833
|
+
type: 'text',
|
|
13834
|
+
raw: text,
|
|
13835
|
+
text,
|
|
13836
|
+
};
|
|
13837
|
+
}
|
|
13838
|
+
return outputLink(cap, link, cap[0], this.lexer);
|
|
13839
|
+
}
|
|
13840
|
+
}
|
|
13841
|
+
emStrong(src, maskedSrc, prevChar = '') {
|
|
13842
|
+
let match = this.rules.inline.emStrongLDelim.exec(src);
|
|
13843
|
+
if (!match)
|
|
13844
|
+
return;
|
|
13845
|
+
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
13846
|
+
if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
|
|
13847
|
+
return;
|
|
13848
|
+
const nextChar = match[1] || match[2] || '';
|
|
13849
|
+
if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
|
|
13850
|
+
// unicode Regex counts emoji as 1 char; spread into array for proper count (used multiple times below)
|
|
13851
|
+
const lLength = [...match[0]].length - 1;
|
|
13852
|
+
let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
|
|
13853
|
+
const endReg = match[0][0] === '*' ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
13854
|
+
endReg.lastIndex = 0;
|
|
13855
|
+
// Clip maskedSrc to same section of string as src (move to lexer?)
|
|
13856
|
+
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
13857
|
+
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
13858
|
+
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
13859
|
+
if (!rDelim)
|
|
13860
|
+
continue; // skip single * in __abc*abc__
|
|
13861
|
+
rLength = [...rDelim].length;
|
|
13862
|
+
if (match[3] || match[4]) { // found another Left Delim
|
|
13863
|
+
delimTotal += rLength;
|
|
13864
|
+
continue;
|
|
13865
|
+
}
|
|
13866
|
+
else if (match[5] || match[6]) { // either Left or Right Delim
|
|
13867
|
+
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
13868
|
+
midDelimTotal += rLength;
|
|
13869
|
+
continue; // CommonMark Emphasis Rules 9-10
|
|
13870
|
+
}
|
|
13871
|
+
}
|
|
13872
|
+
delimTotal -= rLength;
|
|
13873
|
+
if (delimTotal > 0)
|
|
13874
|
+
continue; // Haven't found enough closing delimiters
|
|
13875
|
+
// Remove extra characters. *a*** -> *a*
|
|
13876
|
+
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
13877
|
+
// char length can be >1 for unicode characters;
|
|
13878
|
+
const lastCharLength = [...match[0]][0].length;
|
|
13879
|
+
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
|
|
13880
|
+
// Create `em` if smallest delimiter has odd char count. *a***
|
|
13881
|
+
if (Math.min(lLength, rLength) % 2) {
|
|
13882
|
+
const text = raw.slice(1, -1);
|
|
13883
|
+
return {
|
|
13884
|
+
type: 'em',
|
|
13885
|
+
raw,
|
|
13886
|
+
text,
|
|
13887
|
+
tokens: this.lexer.inlineTokens(text),
|
|
13888
|
+
};
|
|
13889
|
+
}
|
|
13890
|
+
// Create 'strong' if smallest delimiter has even char count. **a***
|
|
13891
|
+
const text = raw.slice(2, -2);
|
|
13892
|
+
return {
|
|
13893
|
+
type: 'strong',
|
|
13894
|
+
raw,
|
|
13895
|
+
text,
|
|
13896
|
+
tokens: this.lexer.inlineTokens(text),
|
|
13897
|
+
};
|
|
13898
|
+
}
|
|
13899
|
+
}
|
|
13900
|
+
}
|
|
13901
|
+
codespan(src) {
|
|
13902
|
+
const cap = this.rules.inline.code.exec(src);
|
|
13903
|
+
if (cap) {
|
|
13904
|
+
let text = cap[2].replace(/\n/g, ' ');
|
|
13905
|
+
const hasNonSpaceChars = /[^ ]/.test(text);
|
|
13906
|
+
const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
13907
|
+
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
13908
|
+
text = text.substring(1, text.length - 1);
|
|
13909
|
+
}
|
|
13910
|
+
text = escape$1(text, true);
|
|
13911
|
+
return {
|
|
13912
|
+
type: 'codespan',
|
|
13913
|
+
raw: cap[0],
|
|
13914
|
+
text,
|
|
13915
|
+
};
|
|
13916
|
+
}
|
|
13917
|
+
}
|
|
13918
|
+
br(src) {
|
|
13919
|
+
const cap = this.rules.inline.br.exec(src);
|
|
13920
|
+
if (cap) {
|
|
13921
|
+
return {
|
|
13922
|
+
type: 'br',
|
|
13923
|
+
raw: cap[0],
|
|
13924
|
+
};
|
|
13925
|
+
}
|
|
13926
|
+
}
|
|
13927
|
+
del(src) {
|
|
13928
|
+
const cap = this.rules.inline.del.exec(src);
|
|
13929
|
+
if (cap) {
|
|
13930
|
+
return {
|
|
13931
|
+
type: 'del',
|
|
13932
|
+
raw: cap[0],
|
|
13933
|
+
text: cap[2],
|
|
13934
|
+
tokens: this.lexer.inlineTokens(cap[2]),
|
|
13935
|
+
};
|
|
13936
|
+
}
|
|
13937
|
+
}
|
|
13938
|
+
autolink(src) {
|
|
13939
|
+
const cap = this.rules.inline.autolink.exec(src);
|
|
13940
|
+
if (cap) {
|
|
13941
|
+
let text, href;
|
|
13942
|
+
if (cap[2] === '@') {
|
|
13943
|
+
text = escape$1(cap[1]);
|
|
13944
|
+
href = 'mailto:' + text;
|
|
13945
|
+
}
|
|
13946
|
+
else {
|
|
13947
|
+
text = escape$1(cap[1]);
|
|
13948
|
+
href = text;
|
|
13949
|
+
}
|
|
13950
|
+
return {
|
|
13951
|
+
type: 'link',
|
|
13952
|
+
raw: cap[0],
|
|
13953
|
+
text,
|
|
13954
|
+
href,
|
|
13955
|
+
tokens: [
|
|
13956
|
+
{
|
|
13957
|
+
type: 'text',
|
|
13958
|
+
raw: text,
|
|
13959
|
+
text,
|
|
13960
|
+
},
|
|
13961
|
+
],
|
|
13962
|
+
};
|
|
13963
|
+
}
|
|
13964
|
+
}
|
|
13965
|
+
url(src) {
|
|
13966
|
+
let cap;
|
|
13967
|
+
if (cap = this.rules.inline.url.exec(src)) {
|
|
13968
|
+
let text, href;
|
|
13969
|
+
if (cap[2] === '@') {
|
|
13970
|
+
text = escape$1(cap[0]);
|
|
13971
|
+
href = 'mailto:' + text;
|
|
13972
|
+
}
|
|
13973
|
+
else {
|
|
13974
|
+
// do extended autolink path validation
|
|
13975
|
+
let prevCapZero;
|
|
13976
|
+
do {
|
|
13977
|
+
prevCapZero = cap[0];
|
|
13978
|
+
cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? '';
|
|
13979
|
+
} while (prevCapZero !== cap[0]);
|
|
13980
|
+
text = escape$1(cap[0]);
|
|
13981
|
+
if (cap[1] === 'www.') {
|
|
13982
|
+
href = 'http://' + cap[0];
|
|
13983
|
+
}
|
|
13984
|
+
else {
|
|
13985
|
+
href = cap[0];
|
|
13986
|
+
}
|
|
13987
|
+
}
|
|
13988
|
+
return {
|
|
13989
|
+
type: 'link',
|
|
13990
|
+
raw: cap[0],
|
|
13991
|
+
text,
|
|
13992
|
+
href,
|
|
13993
|
+
tokens: [
|
|
13994
|
+
{
|
|
13995
|
+
type: 'text',
|
|
13996
|
+
raw: text,
|
|
13997
|
+
text,
|
|
13998
|
+
},
|
|
13999
|
+
],
|
|
14000
|
+
};
|
|
14001
|
+
}
|
|
14002
|
+
}
|
|
14003
|
+
inlineText(src) {
|
|
14004
|
+
const cap = this.rules.inline.text.exec(src);
|
|
14005
|
+
if (cap) {
|
|
14006
|
+
let text;
|
|
14007
|
+
if (this.lexer.state.inRawBlock) {
|
|
14008
|
+
text = cap[0];
|
|
14009
|
+
}
|
|
14010
|
+
else {
|
|
14011
|
+
text = escape$1(cap[0]);
|
|
14012
|
+
}
|
|
14013
|
+
return {
|
|
14014
|
+
type: 'text',
|
|
14015
|
+
raw: cap[0],
|
|
14016
|
+
text,
|
|
14017
|
+
};
|
|
14018
|
+
}
|
|
14019
|
+
}
|
|
14020
|
+
}
|
|
14021
|
+
|
|
14022
|
+
/**
|
|
14023
|
+
* Block-Level Grammar
|
|
14024
|
+
*/
|
|
14025
|
+
const newline = /^(?:[ \t]*(?:\n|$))+/;
|
|
14026
|
+
const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
14027
|
+
const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
14028
|
+
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
14029
|
+
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
14030
|
+
const bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
14031
|
+
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
|
|
14032
|
+
.replace(/bull/g, bullet) // lists can interrupt
|
|
14033
|
+
.replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
|
|
14034
|
+
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
|
|
14035
|
+
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
|
|
14036
|
+
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
|
|
14037
|
+
.replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt
|
|
14038
|
+
.getRegex();
|
|
14039
|
+
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
14040
|
+
const blockText = /^[^\n]+/;
|
|
14041
|
+
const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
14042
|
+
const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/)
|
|
14043
|
+
.replace('label', _blockLabel)
|
|
14044
|
+
.replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/)
|
|
14045
|
+
.getRegex();
|
|
14046
|
+
const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/)
|
|
14047
|
+
.replace(/bull/g, bullet)
|
|
14048
|
+
.getRegex();
|
|
14049
|
+
const _tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
|
14050
|
+
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
|
14051
|
+
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
|
14052
|
+
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
|
14053
|
+
+ '|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title'
|
|
14054
|
+
+ '|tr|track|ul';
|
|
14055
|
+
const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
14056
|
+
const html = edit('^ {0,3}(?:' // optional indentation
|
|
14057
|
+
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
14058
|
+
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
14059
|
+
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
14060
|
+
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
14061
|
+
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
14062
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
|
|
14063
|
+
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
|
|
14064
|
+
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
|
|
14065
|
+
+ ')', 'i')
|
|
14066
|
+
.replace('comment', _comment)
|
|
14067
|
+
.replace('tag', _tag)
|
|
14068
|
+
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
|
14069
|
+
.getRegex();
|
|
14070
|
+
const paragraph = edit(_paragraph)
|
|
14071
|
+
.replace('hr', hr)
|
|
14072
|
+
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
|
14073
|
+
.replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
|
|
14074
|
+
.replace('|table', '')
|
|
14075
|
+
.replace('blockquote', ' {0,3}>')
|
|
14076
|
+
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
14077
|
+
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
14078
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
14079
|
+
.replace('tag', _tag) // pars can be interrupted by type (6) html blocks
|
|
14080
|
+
.getRegex();
|
|
14081
|
+
const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/)
|
|
14082
|
+
.replace('paragraph', paragraph)
|
|
14083
|
+
.getRegex();
|
|
14084
|
+
/**
|
|
14085
|
+
* Normal Block Grammar
|
|
14086
|
+
*/
|
|
14087
|
+
const blockNormal = {
|
|
14088
|
+
blockquote,
|
|
14089
|
+
code: blockCode,
|
|
14090
|
+
def,
|
|
14091
|
+
fences,
|
|
14092
|
+
heading,
|
|
14093
|
+
hr,
|
|
14094
|
+
html,
|
|
14095
|
+
lheading,
|
|
14096
|
+
list,
|
|
14097
|
+
newline,
|
|
14098
|
+
paragraph,
|
|
14099
|
+
table: noopTest,
|
|
14100
|
+
text: blockText,
|
|
14101
|
+
};
|
|
14102
|
+
/**
|
|
14103
|
+
* GFM Block Grammar
|
|
14104
|
+
*/
|
|
14105
|
+
const gfmTable = edit('^ *([^\\n ].*)\\n' // Header
|
|
14106
|
+
+ ' {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)' // Align
|
|
14107
|
+
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)') // Cells
|
|
14108
|
+
.replace('hr', hr)
|
|
14109
|
+
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
|
14110
|
+
.replace('blockquote', ' {0,3}>')
|
|
14111
|
+
.replace('code', '(?: {4}| {0,3}\t)[^\\n]')
|
|
14112
|
+
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
14113
|
+
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
14114
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
14115
|
+
.replace('tag', _tag) // tables can be interrupted by type (6) html blocks
|
|
14116
|
+
.getRegex();
|
|
14117
|
+
const blockGfm = {
|
|
14118
|
+
...blockNormal,
|
|
14119
|
+
table: gfmTable,
|
|
14120
|
+
paragraph: edit(_paragraph)
|
|
14121
|
+
.replace('hr', hr)
|
|
14122
|
+
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
|
|
14123
|
+
.replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs
|
|
14124
|
+
.replace('table', gfmTable) // interrupt paragraphs with table
|
|
14125
|
+
.replace('blockquote', ' {0,3}>')
|
|
14126
|
+
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
14127
|
+
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
14128
|
+
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
14129
|
+
.replace('tag', _tag) // pars can be interrupted by type (6) html blocks
|
|
14130
|
+
.getRegex(),
|
|
14131
|
+
};
|
|
14132
|
+
/**
|
|
14133
|
+
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
14134
|
+
*/
|
|
14135
|
+
const blockPedantic = {
|
|
14136
|
+
...blockNormal,
|
|
14137
|
+
html: edit('^ *(?:comment *(?:\\n|\\s*$)'
|
|
14138
|
+
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
14139
|
+
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
|
14140
|
+
.replace('comment', _comment)
|
|
14141
|
+
.replace(/tag/g, '(?!(?:'
|
|
14142
|
+
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
|
14143
|
+
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
|
14144
|
+
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
|
14145
|
+
.getRegex(),
|
|
14146
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
14147
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
14148
|
+
fences: noopTest, // fences not supported
|
|
14149
|
+
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
14150
|
+
paragraph: edit(_paragraph)
|
|
14151
|
+
.replace('hr', hr)
|
|
14152
|
+
.replace('heading', ' *#{1,6} *[^\n]')
|
|
14153
|
+
.replace('lheading', lheading)
|
|
14154
|
+
.replace('|table', '')
|
|
14155
|
+
.replace('blockquote', ' {0,3}>')
|
|
14156
|
+
.replace('|fences', '')
|
|
14157
|
+
.replace('|list', '')
|
|
14158
|
+
.replace('|html', '')
|
|
14159
|
+
.replace('|tag', '')
|
|
14160
|
+
.getRegex(),
|
|
14161
|
+
};
|
|
14162
|
+
/**
|
|
14163
|
+
* Inline-Level Grammar
|
|
14164
|
+
*/
|
|
14165
|
+
const marked_esm_escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
14166
|
+
const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
14167
|
+
const br = /^( {2,}|\\)\n(?!\s*$)/;
|
|
14168
|
+
const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
14169
|
+
// list of unicode punctuation marks, plus any missing characters from CommonMark spec
|
|
14170
|
+
const _punctuation = '\\p{P}\\p{S}';
|
|
14171
|
+
const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u')
|
|
14172
|
+
.replace(/punctuation/g, _punctuation).getRegex();
|
|
14173
|
+
// sequences em should skip over [title](link), `code`, <html>
|
|
14174
|
+
const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
|
|
14175
|
+
const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u')
|
|
14176
|
+
.replace(/punct/g, _punctuation)
|
|
14177
|
+
.getRegex();
|
|
14178
|
+
const emStrongRDelimAst = edit('^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong
|
|
14179
|
+
+ '|[^*]+(?=[^*])' // Consume to delim
|
|
14180
|
+
+ '|(?!\\*)[punct](\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter
|
|
14181
|
+
+ '|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)' // (2) a***#, a*** can only be a Right Delimiter
|
|
14182
|
+
+ '|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])' // (3) #***a, ***a can only be Left Delimiter
|
|
14183
|
+
+ '|[\\s](\\*+)(?!\\*)(?=[punct])' // (4) ***# can only be Left Delimiter
|
|
14184
|
+
+ '|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])' // (5) #***# can be either Left or Right Delimiter
|
|
14185
|
+
+ '|[^punct\\s](\\*+)(?=[^punct\\s])', 'gu') // (6) a***a can be either Left or Right Delimiter
|
|
14186
|
+
.replace(/punct/g, _punctuation)
|
|
14187
|
+
.getRegex();
|
|
14188
|
+
// (6) Not allowed for _
|
|
14189
|
+
const emStrongRDelimUnd = edit('^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong
|
|
14190
|
+
+ '|[^_]+(?=[^_])' // Consume to delim
|
|
14191
|
+
+ '|(?!_)[punct](_+)(?=[\\s]|$)' // (1) #___ can only be a Right Delimiter
|
|
14192
|
+
+ '|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)' // (2) a___#, a___ can only be a Right Delimiter
|
|
14193
|
+
+ '|(?!_)[punct\\s](_+)(?=[^punct\\s])' // (3) #___a, ___a can only be Left Delimiter
|
|
14194
|
+
+ '|[\\s](_+)(?!_)(?=[punct])' // (4) ___# can only be Left Delimiter
|
|
14195
|
+
+ '|(?!_)[punct](_+)(?!_)(?=[punct])', 'gu') // (5) #___# can be either Left or Right Delimiter
|
|
14196
|
+
.replace(/punct/g, _punctuation)
|
|
14197
|
+
.getRegex();
|
|
14198
|
+
const anyPunctuation = edit(/\\([punct])/, 'gu')
|
|
14199
|
+
.replace(/punct/g, _punctuation)
|
|
14200
|
+
.getRegex();
|
|
14201
|
+
const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/)
|
|
14202
|
+
.replace('scheme', /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/)
|
|
14203
|
+
.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])?)+(?![-_])/)
|
|
14204
|
+
.getRegex();
|
|
14205
|
+
const _inlineComment = edit(_comment).replace('(?:-->|$)', '-->').getRegex();
|
|
14206
|
+
const tag = edit('^comment'
|
|
14207
|
+
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
14208
|
+
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
14209
|
+
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
14210
|
+
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
14211
|
+
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>') // CDATA section
|
|
14212
|
+
.replace('comment', _inlineComment)
|
|
14213
|
+
.replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/)
|
|
14214
|
+
.getRegex();
|
|
14215
|
+
const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
14216
|
+
const marked_esm_link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/)
|
|
14217
|
+
.replace('label', _inlineLabel)
|
|
14218
|
+
.replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/)
|
|
14219
|
+
.replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/)
|
|
14220
|
+
.getRegex();
|
|
14221
|
+
const reflink = edit(/^!?\[(label)\]\[(ref)\]/)
|
|
14222
|
+
.replace('label', _inlineLabel)
|
|
14223
|
+
.replace('ref', _blockLabel)
|
|
14224
|
+
.getRegex();
|
|
14225
|
+
const nolink = edit(/^!?\[(ref)\](?:\[\])?/)
|
|
14226
|
+
.replace('ref', _blockLabel)
|
|
14227
|
+
.getRegex();
|
|
14228
|
+
const reflinkSearch = edit('reflink|nolink(?!\\()', 'g')
|
|
14229
|
+
.replace('reflink', reflink)
|
|
14230
|
+
.replace('nolink', nolink)
|
|
14231
|
+
.getRegex();
|
|
14232
|
+
/**
|
|
14233
|
+
* Normal Inline Grammar
|
|
14234
|
+
*/
|
|
14235
|
+
const inlineNormal = {
|
|
14236
|
+
_backpedal: noopTest, // only used for GFM url
|
|
14237
|
+
anyPunctuation,
|
|
14238
|
+
autolink,
|
|
14239
|
+
blockSkip,
|
|
14240
|
+
br,
|
|
14241
|
+
code: inlineCode,
|
|
14242
|
+
del: noopTest,
|
|
14243
|
+
emStrongLDelim,
|
|
14244
|
+
emStrongRDelimAst,
|
|
14245
|
+
emStrongRDelimUnd,
|
|
14246
|
+
escape: marked_esm_escape,
|
|
14247
|
+
link: marked_esm_link,
|
|
14248
|
+
nolink,
|
|
14249
|
+
punctuation,
|
|
14250
|
+
reflink,
|
|
14251
|
+
reflinkSearch,
|
|
14252
|
+
tag,
|
|
14253
|
+
text: inlineText,
|
|
14254
|
+
url: noopTest,
|
|
14255
|
+
};
|
|
14256
|
+
/**
|
|
14257
|
+
* Pedantic Inline Grammar
|
|
14258
|
+
*/
|
|
14259
|
+
const inlinePedantic = {
|
|
14260
|
+
...inlineNormal,
|
|
14261
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
|
14262
|
+
.replace('label', _inlineLabel)
|
|
14263
|
+
.getRegex(),
|
|
14264
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
14265
|
+
.replace('label', _inlineLabel)
|
|
14266
|
+
.getRegex(),
|
|
14267
|
+
};
|
|
14268
|
+
/**
|
|
14269
|
+
* GFM Inline Grammar
|
|
14270
|
+
*/
|
|
14271
|
+
const inlineGfm = {
|
|
14272
|
+
...inlineNormal,
|
|
14273
|
+
escape: edit(marked_esm_escape).replace('])', '~|])').getRegex(),
|
|
14274
|
+
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i')
|
|
14275
|
+
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
|
|
14276
|
+
.getRegex(),
|
|
14277
|
+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
14278
|
+
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
14279
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/,
|
|
14280
|
+
};
|
|
14281
|
+
/**
|
|
14282
|
+
* GFM + Line Breaks Inline Grammar
|
|
14283
|
+
*/
|
|
14284
|
+
const inlineBreaks = {
|
|
14285
|
+
...inlineGfm,
|
|
14286
|
+
br: edit(br).replace('{2,}', '*').getRegex(),
|
|
14287
|
+
text: edit(inlineGfm.text)
|
|
14288
|
+
.replace('\\b_', '\\b_| {2,}\\n')
|
|
14289
|
+
.replace(/\{2,\}/g, '*')
|
|
14290
|
+
.getRegex(),
|
|
14291
|
+
};
|
|
14292
|
+
/**
|
|
14293
|
+
* exports
|
|
14294
|
+
*/
|
|
14295
|
+
const block = {
|
|
14296
|
+
normal: blockNormal,
|
|
14297
|
+
gfm: blockGfm,
|
|
14298
|
+
pedantic: blockPedantic,
|
|
14299
|
+
};
|
|
14300
|
+
const inline = {
|
|
14301
|
+
normal: inlineNormal,
|
|
14302
|
+
gfm: inlineGfm,
|
|
14303
|
+
breaks: inlineBreaks,
|
|
14304
|
+
pedantic: inlinePedantic,
|
|
14305
|
+
};
|
|
14306
|
+
|
|
14307
|
+
/**
|
|
14308
|
+
* Block Lexer
|
|
14309
|
+
*/
|
|
14310
|
+
class _Lexer {
|
|
14311
|
+
tokens;
|
|
14312
|
+
options;
|
|
14313
|
+
state;
|
|
14314
|
+
tokenizer;
|
|
14315
|
+
inlineQueue;
|
|
14316
|
+
constructor(options) {
|
|
14317
|
+
// TokenList cannot be created in one go
|
|
14318
|
+
this.tokens = [];
|
|
14319
|
+
this.tokens.links = Object.create(null);
|
|
14320
|
+
this.options = options || _defaults;
|
|
14321
|
+
this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
|
|
14322
|
+
this.tokenizer = this.options.tokenizer;
|
|
14323
|
+
this.tokenizer.options = this.options;
|
|
14324
|
+
this.tokenizer.lexer = this;
|
|
14325
|
+
this.inlineQueue = [];
|
|
14326
|
+
this.state = {
|
|
14327
|
+
inLink: false,
|
|
14328
|
+
inRawBlock: false,
|
|
14329
|
+
top: true,
|
|
14330
|
+
};
|
|
14331
|
+
const rules = {
|
|
14332
|
+
block: block.normal,
|
|
14333
|
+
inline: inline.normal,
|
|
14334
|
+
};
|
|
14335
|
+
if (this.options.pedantic) {
|
|
14336
|
+
rules.block = block.pedantic;
|
|
14337
|
+
rules.inline = inline.pedantic;
|
|
14338
|
+
}
|
|
14339
|
+
else if (this.options.gfm) {
|
|
14340
|
+
rules.block = block.gfm;
|
|
14341
|
+
if (this.options.breaks) {
|
|
14342
|
+
rules.inline = inline.breaks;
|
|
14343
|
+
}
|
|
14344
|
+
else {
|
|
14345
|
+
rules.inline = inline.gfm;
|
|
14346
|
+
}
|
|
14347
|
+
}
|
|
14348
|
+
this.tokenizer.rules = rules;
|
|
14349
|
+
}
|
|
14350
|
+
/**
|
|
14351
|
+
* Expose Rules
|
|
14352
|
+
*/
|
|
14353
|
+
static get rules() {
|
|
14354
|
+
return {
|
|
14355
|
+
block,
|
|
14356
|
+
inline,
|
|
14357
|
+
};
|
|
14358
|
+
}
|
|
14359
|
+
/**
|
|
14360
|
+
* Static Lex Method
|
|
14361
|
+
*/
|
|
14362
|
+
static lex(src, options) {
|
|
14363
|
+
const lexer = new _Lexer(options);
|
|
14364
|
+
return lexer.lex(src);
|
|
14365
|
+
}
|
|
14366
|
+
/**
|
|
14367
|
+
* Static Lex Inline Method
|
|
14368
|
+
*/
|
|
14369
|
+
static lexInline(src, options) {
|
|
14370
|
+
const lexer = new _Lexer(options);
|
|
14371
|
+
return lexer.inlineTokens(src);
|
|
14372
|
+
}
|
|
14373
|
+
/**
|
|
14374
|
+
* Preprocessing
|
|
14375
|
+
*/
|
|
14376
|
+
lex(src) {
|
|
14377
|
+
src = src
|
|
14378
|
+
.replace(/\r\n|\r/g, '\n');
|
|
14379
|
+
this.blockTokens(src, this.tokens);
|
|
14380
|
+
for (let i = 0; i < this.inlineQueue.length; i++) {
|
|
14381
|
+
const next = this.inlineQueue[i];
|
|
14382
|
+
this.inlineTokens(next.src, next.tokens);
|
|
14383
|
+
}
|
|
14384
|
+
this.inlineQueue = [];
|
|
14385
|
+
return this.tokens;
|
|
14386
|
+
}
|
|
14387
|
+
blockTokens(src, tokens = [], lastParagraphClipped = false) {
|
|
14388
|
+
if (this.options.pedantic) {
|
|
14389
|
+
src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
|
|
14390
|
+
}
|
|
14391
|
+
let token;
|
|
14392
|
+
let lastToken;
|
|
14393
|
+
let cutSrc;
|
|
14394
|
+
while (src) {
|
|
14395
|
+
if (this.options.extensions
|
|
14396
|
+
&& this.options.extensions.block
|
|
14397
|
+
&& this.options.extensions.block.some((extTokenizer) => {
|
|
14398
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
14399
|
+
src = src.substring(token.raw.length);
|
|
14400
|
+
tokens.push(token);
|
|
14401
|
+
return true;
|
|
14402
|
+
}
|
|
14403
|
+
return false;
|
|
14404
|
+
})) {
|
|
14405
|
+
continue;
|
|
14406
|
+
}
|
|
14407
|
+
// newline
|
|
14408
|
+
if (token = this.tokenizer.space(src)) {
|
|
14409
|
+
src = src.substring(token.raw.length);
|
|
14410
|
+
if (token.raw.length === 1 && tokens.length > 0) {
|
|
14411
|
+
// if there's a single \n as a spacer, it's terminating the last line,
|
|
14412
|
+
// so move it there so that we don't get unnecessary paragraph tags
|
|
14413
|
+
tokens[tokens.length - 1].raw += '\n';
|
|
14414
|
+
}
|
|
14415
|
+
else {
|
|
14416
|
+
tokens.push(token);
|
|
14417
|
+
}
|
|
14418
|
+
continue;
|
|
14419
|
+
}
|
|
14420
|
+
// code
|
|
14421
|
+
if (token = this.tokenizer.code(src)) {
|
|
14422
|
+
src = src.substring(token.raw.length);
|
|
14423
|
+
lastToken = tokens[tokens.length - 1];
|
|
14424
|
+
// An indented code block cannot interrupt a paragraph.
|
|
14425
|
+
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
14426
|
+
lastToken.raw += '\n' + token.raw;
|
|
14427
|
+
lastToken.text += '\n' + token.text;
|
|
14428
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
14429
|
+
}
|
|
14430
|
+
else {
|
|
14431
|
+
tokens.push(token);
|
|
14432
|
+
}
|
|
14433
|
+
continue;
|
|
14434
|
+
}
|
|
14435
|
+
// fences
|
|
14436
|
+
if (token = this.tokenizer.fences(src)) {
|
|
14437
|
+
src = src.substring(token.raw.length);
|
|
14438
|
+
tokens.push(token);
|
|
14439
|
+
continue;
|
|
14440
|
+
}
|
|
14441
|
+
// heading
|
|
14442
|
+
if (token = this.tokenizer.heading(src)) {
|
|
14443
|
+
src = src.substring(token.raw.length);
|
|
14444
|
+
tokens.push(token);
|
|
14445
|
+
continue;
|
|
14446
|
+
}
|
|
14447
|
+
// hr
|
|
14448
|
+
if (token = this.tokenizer.hr(src)) {
|
|
14449
|
+
src = src.substring(token.raw.length);
|
|
14450
|
+
tokens.push(token);
|
|
14451
|
+
continue;
|
|
14452
|
+
}
|
|
14453
|
+
// blockquote
|
|
14454
|
+
if (token = this.tokenizer.blockquote(src)) {
|
|
14455
|
+
src = src.substring(token.raw.length);
|
|
14456
|
+
tokens.push(token);
|
|
14457
|
+
continue;
|
|
14458
|
+
}
|
|
14459
|
+
// list
|
|
14460
|
+
if (token = this.tokenizer.list(src)) {
|
|
14461
|
+
src = src.substring(token.raw.length);
|
|
14462
|
+
tokens.push(token);
|
|
14463
|
+
continue;
|
|
14464
|
+
}
|
|
14465
|
+
// html
|
|
14466
|
+
if (token = this.tokenizer.html(src)) {
|
|
14467
|
+
src = src.substring(token.raw.length);
|
|
14468
|
+
tokens.push(token);
|
|
14469
|
+
continue;
|
|
14470
|
+
}
|
|
14471
|
+
// def
|
|
14472
|
+
if (token = this.tokenizer.def(src)) {
|
|
14473
|
+
src = src.substring(token.raw.length);
|
|
14474
|
+
lastToken = tokens[tokens.length - 1];
|
|
14475
|
+
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
14476
|
+
lastToken.raw += '\n' + token.raw;
|
|
14477
|
+
lastToken.text += '\n' + token.raw;
|
|
14478
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
14479
|
+
}
|
|
14480
|
+
else if (!this.tokens.links[token.tag]) {
|
|
14481
|
+
this.tokens.links[token.tag] = {
|
|
14482
|
+
href: token.href,
|
|
14483
|
+
title: token.title,
|
|
14484
|
+
};
|
|
14485
|
+
}
|
|
14486
|
+
continue;
|
|
14487
|
+
}
|
|
14488
|
+
// table (gfm)
|
|
14489
|
+
if (token = this.tokenizer.table(src)) {
|
|
14490
|
+
src = src.substring(token.raw.length);
|
|
14491
|
+
tokens.push(token);
|
|
14492
|
+
continue;
|
|
14493
|
+
}
|
|
14494
|
+
// lheading
|
|
14495
|
+
if (token = this.tokenizer.lheading(src)) {
|
|
14496
|
+
src = src.substring(token.raw.length);
|
|
14497
|
+
tokens.push(token);
|
|
14498
|
+
continue;
|
|
14499
|
+
}
|
|
14500
|
+
// top-level paragraph
|
|
14501
|
+
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
14502
|
+
cutSrc = src;
|
|
14503
|
+
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
14504
|
+
let startIndex = Infinity;
|
|
14505
|
+
const tempSrc = src.slice(1);
|
|
14506
|
+
let tempStart;
|
|
14507
|
+
this.options.extensions.startBlock.forEach((getStartIndex) => {
|
|
14508
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
14509
|
+
if (typeof tempStart === 'number' && tempStart >= 0) {
|
|
14510
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
14511
|
+
}
|
|
14512
|
+
});
|
|
14513
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
14514
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
14515
|
+
}
|
|
14516
|
+
}
|
|
14517
|
+
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
14518
|
+
lastToken = tokens[tokens.length - 1];
|
|
14519
|
+
if (lastParagraphClipped && lastToken?.type === 'paragraph') {
|
|
14520
|
+
lastToken.raw += '\n' + token.raw;
|
|
14521
|
+
lastToken.text += '\n' + token.text;
|
|
14522
|
+
this.inlineQueue.pop();
|
|
14523
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
14524
|
+
}
|
|
14525
|
+
else {
|
|
14526
|
+
tokens.push(token);
|
|
14527
|
+
}
|
|
14528
|
+
lastParagraphClipped = (cutSrc.length !== src.length);
|
|
14529
|
+
src = src.substring(token.raw.length);
|
|
14530
|
+
continue;
|
|
14531
|
+
}
|
|
14532
|
+
// text
|
|
14533
|
+
if (token = this.tokenizer.text(src)) {
|
|
14534
|
+
src = src.substring(token.raw.length);
|
|
14535
|
+
lastToken = tokens[tokens.length - 1];
|
|
14536
|
+
if (lastToken && lastToken.type === 'text') {
|
|
14537
|
+
lastToken.raw += '\n' + token.raw;
|
|
14538
|
+
lastToken.text += '\n' + token.text;
|
|
14539
|
+
this.inlineQueue.pop();
|
|
14540
|
+
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
14541
|
+
}
|
|
14542
|
+
else {
|
|
14543
|
+
tokens.push(token);
|
|
14544
|
+
}
|
|
14545
|
+
continue;
|
|
14546
|
+
}
|
|
14547
|
+
if (src) {
|
|
14548
|
+
const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
14549
|
+
if (this.options.silent) {
|
|
14550
|
+
console.error(errMsg);
|
|
14551
|
+
break;
|
|
14552
|
+
}
|
|
14553
|
+
else {
|
|
14554
|
+
throw new Error(errMsg);
|
|
14555
|
+
}
|
|
14556
|
+
}
|
|
14557
|
+
}
|
|
14558
|
+
this.state.top = true;
|
|
14559
|
+
return tokens;
|
|
14560
|
+
}
|
|
14561
|
+
inline(src, tokens = []) {
|
|
14562
|
+
this.inlineQueue.push({ src, tokens });
|
|
14563
|
+
return tokens;
|
|
14564
|
+
}
|
|
14565
|
+
/**
|
|
14566
|
+
* Lexing/Compiling
|
|
14567
|
+
*/
|
|
14568
|
+
inlineTokens(src, tokens = []) {
|
|
14569
|
+
let token, lastToken, cutSrc;
|
|
14570
|
+
// String with links masked to avoid interference with em and strong
|
|
14571
|
+
let maskedSrc = src;
|
|
14572
|
+
let match;
|
|
14573
|
+
let keepPrevChar, prevChar;
|
|
14574
|
+
// Mask out reflinks
|
|
14575
|
+
if (this.tokens.links) {
|
|
14576
|
+
const links = Object.keys(this.tokens.links);
|
|
14577
|
+
if (links.length > 0) {
|
|
14578
|
+
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
14579
|
+
if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
|
14580
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
14581
|
+
}
|
|
14582
|
+
}
|
|
14583
|
+
}
|
|
14584
|
+
}
|
|
14585
|
+
// Mask out other blocks
|
|
14586
|
+
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
14587
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
14588
|
+
}
|
|
14589
|
+
// Mask out escaped characters
|
|
14590
|
+
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
|
|
14591
|
+
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
14592
|
+
}
|
|
14593
|
+
while (src) {
|
|
14594
|
+
if (!keepPrevChar) {
|
|
14595
|
+
prevChar = '';
|
|
14596
|
+
}
|
|
14597
|
+
keepPrevChar = false;
|
|
14598
|
+
// extensions
|
|
14599
|
+
if (this.options.extensions
|
|
14600
|
+
&& this.options.extensions.inline
|
|
14601
|
+
&& this.options.extensions.inline.some((extTokenizer) => {
|
|
14602
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
14603
|
+
src = src.substring(token.raw.length);
|
|
14604
|
+
tokens.push(token);
|
|
14605
|
+
return true;
|
|
14606
|
+
}
|
|
14607
|
+
return false;
|
|
14608
|
+
})) {
|
|
14609
|
+
continue;
|
|
14610
|
+
}
|
|
14611
|
+
// escape
|
|
14612
|
+
if (token = this.tokenizer.escape(src)) {
|
|
14613
|
+
src = src.substring(token.raw.length);
|
|
14614
|
+
tokens.push(token);
|
|
14615
|
+
continue;
|
|
14616
|
+
}
|
|
14617
|
+
// tag
|
|
14618
|
+
if (token = this.tokenizer.tag(src)) {
|
|
14619
|
+
src = src.substring(token.raw.length);
|
|
14620
|
+
lastToken = tokens[tokens.length - 1];
|
|
14621
|
+
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
14622
|
+
lastToken.raw += token.raw;
|
|
14623
|
+
lastToken.text += token.text;
|
|
14624
|
+
}
|
|
14625
|
+
else {
|
|
14626
|
+
tokens.push(token);
|
|
14627
|
+
}
|
|
14628
|
+
continue;
|
|
14629
|
+
}
|
|
14630
|
+
// link
|
|
14631
|
+
if (token = this.tokenizer.link(src)) {
|
|
14632
|
+
src = src.substring(token.raw.length);
|
|
14633
|
+
tokens.push(token);
|
|
14634
|
+
continue;
|
|
14635
|
+
}
|
|
14636
|
+
// reflink, nolink
|
|
14637
|
+
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
14638
|
+
src = src.substring(token.raw.length);
|
|
14639
|
+
lastToken = tokens[tokens.length - 1];
|
|
14640
|
+
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
14641
|
+
lastToken.raw += token.raw;
|
|
14642
|
+
lastToken.text += token.text;
|
|
14643
|
+
}
|
|
14644
|
+
else {
|
|
14645
|
+
tokens.push(token);
|
|
14646
|
+
}
|
|
14647
|
+
continue;
|
|
14648
|
+
}
|
|
14649
|
+
// em & strong
|
|
14650
|
+
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
14651
|
+
src = src.substring(token.raw.length);
|
|
14652
|
+
tokens.push(token);
|
|
14653
|
+
continue;
|
|
14654
|
+
}
|
|
14655
|
+
// code
|
|
14656
|
+
if (token = this.tokenizer.codespan(src)) {
|
|
14657
|
+
src = src.substring(token.raw.length);
|
|
14658
|
+
tokens.push(token);
|
|
14659
|
+
continue;
|
|
14660
|
+
}
|
|
14661
|
+
// br
|
|
14662
|
+
if (token = this.tokenizer.br(src)) {
|
|
14663
|
+
src = src.substring(token.raw.length);
|
|
14664
|
+
tokens.push(token);
|
|
14665
|
+
continue;
|
|
14666
|
+
}
|
|
14667
|
+
// del (gfm)
|
|
14668
|
+
if (token = this.tokenizer.del(src)) {
|
|
14669
|
+
src = src.substring(token.raw.length);
|
|
14670
|
+
tokens.push(token);
|
|
14671
|
+
continue;
|
|
14672
|
+
}
|
|
14673
|
+
// autolink
|
|
14674
|
+
if (token = this.tokenizer.autolink(src)) {
|
|
14675
|
+
src = src.substring(token.raw.length);
|
|
14676
|
+
tokens.push(token);
|
|
14677
|
+
continue;
|
|
14678
|
+
}
|
|
14679
|
+
// url (gfm)
|
|
14680
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src))) {
|
|
14681
|
+
src = src.substring(token.raw.length);
|
|
14682
|
+
tokens.push(token);
|
|
14683
|
+
continue;
|
|
14684
|
+
}
|
|
14685
|
+
// text
|
|
14686
|
+
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
14687
|
+
cutSrc = src;
|
|
14688
|
+
if (this.options.extensions && this.options.extensions.startInline) {
|
|
14689
|
+
let startIndex = Infinity;
|
|
14690
|
+
const tempSrc = src.slice(1);
|
|
14691
|
+
let tempStart;
|
|
14692
|
+
this.options.extensions.startInline.forEach((getStartIndex) => {
|
|
14693
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
14694
|
+
if (typeof tempStart === 'number' && tempStart >= 0) {
|
|
14695
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
14696
|
+
}
|
|
14697
|
+
});
|
|
14698
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
14699
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
14700
|
+
}
|
|
14701
|
+
}
|
|
14702
|
+
if (token = this.tokenizer.inlineText(cutSrc)) {
|
|
14703
|
+
src = src.substring(token.raw.length);
|
|
14704
|
+
if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started
|
|
14705
|
+
prevChar = token.raw.slice(-1);
|
|
14706
|
+
}
|
|
14707
|
+
keepPrevChar = true;
|
|
14708
|
+
lastToken = tokens[tokens.length - 1];
|
|
14709
|
+
if (lastToken && lastToken.type === 'text') {
|
|
14710
|
+
lastToken.raw += token.raw;
|
|
14711
|
+
lastToken.text += token.text;
|
|
14712
|
+
}
|
|
14713
|
+
else {
|
|
14714
|
+
tokens.push(token);
|
|
14715
|
+
}
|
|
14716
|
+
continue;
|
|
14717
|
+
}
|
|
14718
|
+
if (src) {
|
|
14719
|
+
const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
14720
|
+
if (this.options.silent) {
|
|
14721
|
+
console.error(errMsg);
|
|
14722
|
+
break;
|
|
14723
|
+
}
|
|
14724
|
+
else {
|
|
14725
|
+
throw new Error(errMsg);
|
|
14726
|
+
}
|
|
14727
|
+
}
|
|
14728
|
+
}
|
|
14729
|
+
return tokens;
|
|
14730
|
+
}
|
|
14731
|
+
}
|
|
14732
|
+
|
|
14733
|
+
/**
|
|
14734
|
+
* Renderer
|
|
14735
|
+
*/
|
|
14736
|
+
class _Renderer {
|
|
14737
|
+
options;
|
|
14738
|
+
parser; // set by the parser
|
|
14739
|
+
constructor(options) {
|
|
14740
|
+
this.options = options || _defaults;
|
|
14741
|
+
}
|
|
14742
|
+
space(token) {
|
|
14743
|
+
return '';
|
|
14744
|
+
}
|
|
14745
|
+
code({ text, lang, escaped }) {
|
|
14746
|
+
const langString = (lang || '').match(/^\S*/)?.[0];
|
|
14747
|
+
const code = text.replace(/\n$/, '') + '\n';
|
|
14748
|
+
if (!langString) {
|
|
14749
|
+
return '<pre><code>'
|
|
14750
|
+
+ (escaped ? code : escape$1(code, true))
|
|
14751
|
+
+ '</code></pre>\n';
|
|
14752
|
+
}
|
|
14753
|
+
return '<pre><code class="language-'
|
|
14754
|
+
+ escape$1(langString)
|
|
14755
|
+
+ '">'
|
|
14756
|
+
+ (escaped ? code : escape$1(code, true))
|
|
14757
|
+
+ '</code></pre>\n';
|
|
14758
|
+
}
|
|
14759
|
+
blockquote({ tokens }) {
|
|
14760
|
+
const body = this.parser.parse(tokens);
|
|
14761
|
+
return `<blockquote>\n${body}</blockquote>\n`;
|
|
14762
|
+
}
|
|
14763
|
+
html({ text }) {
|
|
14764
|
+
return text;
|
|
14765
|
+
}
|
|
14766
|
+
heading({ tokens, depth }) {
|
|
14767
|
+
return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>\n`;
|
|
14768
|
+
}
|
|
14769
|
+
hr(token) {
|
|
14770
|
+
return '<hr>\n';
|
|
14771
|
+
}
|
|
14772
|
+
list(token) {
|
|
14773
|
+
const ordered = token.ordered;
|
|
14774
|
+
const start = token.start;
|
|
14775
|
+
let body = '';
|
|
14776
|
+
for (let j = 0; j < token.items.length; j++) {
|
|
14777
|
+
const item = token.items[j];
|
|
14778
|
+
body += this.listitem(item);
|
|
14779
|
+
}
|
|
14780
|
+
const type = ordered ? 'ol' : 'ul';
|
|
14781
|
+
const startAttr = (ordered && start !== 1) ? (' start="' + start + '"') : '';
|
|
14782
|
+
return '<' + type + startAttr + '>\n' + body + '</' + type + '>\n';
|
|
14783
|
+
}
|
|
14784
|
+
listitem(item) {
|
|
14785
|
+
let itemBody = '';
|
|
14786
|
+
if (item.task) {
|
|
14787
|
+
const checkbox = this.checkbox({ checked: !!item.checked });
|
|
14788
|
+
if (item.loose) {
|
|
14789
|
+
if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
|
|
14790
|
+
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
|
14791
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
|
14792
|
+
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
|
14793
|
+
}
|
|
14794
|
+
}
|
|
14795
|
+
else {
|
|
14796
|
+
item.tokens.unshift({
|
|
14797
|
+
type: 'text',
|
|
14798
|
+
raw: checkbox + ' ',
|
|
14799
|
+
text: checkbox + ' ',
|
|
14800
|
+
});
|
|
14801
|
+
}
|
|
14802
|
+
}
|
|
14803
|
+
else {
|
|
14804
|
+
itemBody += checkbox + ' ';
|
|
14805
|
+
}
|
|
14806
|
+
}
|
|
14807
|
+
itemBody += this.parser.parse(item.tokens, !!item.loose);
|
|
14808
|
+
return `<li>${itemBody}</li>\n`;
|
|
14809
|
+
}
|
|
14810
|
+
checkbox({ checked }) {
|
|
14811
|
+
return '<input '
|
|
14812
|
+
+ (checked ? 'checked="" ' : '')
|
|
14813
|
+
+ 'disabled="" type="checkbox">';
|
|
14814
|
+
}
|
|
14815
|
+
paragraph({ tokens }) {
|
|
14816
|
+
return `<p>${this.parser.parseInline(tokens)}</p>\n`;
|
|
14817
|
+
}
|
|
14818
|
+
table(token) {
|
|
14819
|
+
let header = '';
|
|
14820
|
+
// header
|
|
14821
|
+
let cell = '';
|
|
14822
|
+
for (let j = 0; j < token.header.length; j++) {
|
|
14823
|
+
cell += this.tablecell(token.header[j]);
|
|
14824
|
+
}
|
|
14825
|
+
header += this.tablerow({ text: cell });
|
|
14826
|
+
let body = '';
|
|
14827
|
+
for (let j = 0; j < token.rows.length; j++) {
|
|
14828
|
+
const row = token.rows[j];
|
|
14829
|
+
cell = '';
|
|
14830
|
+
for (let k = 0; k < row.length; k++) {
|
|
14831
|
+
cell += this.tablecell(row[k]);
|
|
14832
|
+
}
|
|
14833
|
+
body += this.tablerow({ text: cell });
|
|
14834
|
+
}
|
|
14835
|
+
if (body)
|
|
14836
|
+
body = `<tbody>${body}</tbody>`;
|
|
14837
|
+
return '<table>\n'
|
|
14838
|
+
+ '<thead>\n'
|
|
14839
|
+
+ header
|
|
14840
|
+
+ '</thead>\n'
|
|
14841
|
+
+ body
|
|
14842
|
+
+ '</table>\n';
|
|
14843
|
+
}
|
|
14844
|
+
tablerow({ text }) {
|
|
14845
|
+
return `<tr>\n${text}</tr>\n`;
|
|
14846
|
+
}
|
|
14847
|
+
tablecell(token) {
|
|
14848
|
+
const content = this.parser.parseInline(token.tokens);
|
|
14849
|
+
const type = token.header ? 'th' : 'td';
|
|
14850
|
+
const tag = token.align
|
|
14851
|
+
? `<${type} align="${token.align}">`
|
|
14852
|
+
: `<${type}>`;
|
|
14853
|
+
return tag + content + `</${type}>\n`;
|
|
14854
|
+
}
|
|
14855
|
+
/**
|
|
14856
|
+
* span level renderer
|
|
14857
|
+
*/
|
|
14858
|
+
strong({ tokens }) {
|
|
14859
|
+
return `<strong>${this.parser.parseInline(tokens)}</strong>`;
|
|
14860
|
+
}
|
|
14861
|
+
em({ tokens }) {
|
|
14862
|
+
return `<em>${this.parser.parseInline(tokens)}</em>`;
|
|
14863
|
+
}
|
|
14864
|
+
codespan({ text }) {
|
|
14865
|
+
return `<code>${text}</code>`;
|
|
14866
|
+
}
|
|
14867
|
+
br(token) {
|
|
14868
|
+
return '<br>';
|
|
14869
|
+
}
|
|
14870
|
+
del({ tokens }) {
|
|
14871
|
+
return `<del>${this.parser.parseInline(tokens)}</del>`;
|
|
14872
|
+
}
|
|
14873
|
+
link({ href, title, tokens }) {
|
|
14874
|
+
const text = this.parser.parseInline(tokens);
|
|
14875
|
+
const cleanHref = cleanUrl(href);
|
|
14876
|
+
if (cleanHref === null) {
|
|
14877
|
+
return text;
|
|
14878
|
+
}
|
|
14879
|
+
href = cleanHref;
|
|
14880
|
+
let out = '<a href="' + href + '"';
|
|
14881
|
+
if (title) {
|
|
14882
|
+
out += ' title="' + title + '"';
|
|
14883
|
+
}
|
|
14884
|
+
out += '>' + text + '</a>';
|
|
14885
|
+
return out;
|
|
14886
|
+
}
|
|
14887
|
+
image({ href, title, text }) {
|
|
14888
|
+
const cleanHref = cleanUrl(href);
|
|
14889
|
+
if (cleanHref === null) {
|
|
14890
|
+
return text;
|
|
14891
|
+
}
|
|
14892
|
+
href = cleanHref;
|
|
14893
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
14894
|
+
if (title) {
|
|
14895
|
+
out += ` title="${title}"`;
|
|
14896
|
+
}
|
|
14897
|
+
out += '>';
|
|
14898
|
+
return out;
|
|
14899
|
+
}
|
|
14900
|
+
text(token) {
|
|
14901
|
+
return 'tokens' in token && token.tokens ? this.parser.parseInline(token.tokens) : token.text;
|
|
14902
|
+
}
|
|
14903
|
+
}
|
|
14904
|
+
|
|
14905
|
+
/**
|
|
14906
|
+
* TextRenderer
|
|
14907
|
+
* returns only the textual part of the token
|
|
14908
|
+
*/
|
|
14909
|
+
class _TextRenderer {
|
|
14910
|
+
// no need for block level renderers
|
|
14911
|
+
strong({ text }) {
|
|
14912
|
+
return text;
|
|
14913
|
+
}
|
|
14914
|
+
em({ text }) {
|
|
14915
|
+
return text;
|
|
12693
14916
|
}
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
"alt": "",
|
|
12697
|
-
"src": __webpack_require__(271)
|
|
14917
|
+
codespan({ text }) {
|
|
14918
|
+
return text;
|
|
12698
14919
|
}
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
}, [_c('div', {
|
|
12702
|
-
staticClass: "pop-title"
|
|
12703
|
-
}, [_vm._v(" 你的反馈将 "), _c('br'), _vm._v(" 帮助职教一问优化进步 ")]), _c('i', {
|
|
12704
|
-
staticClass: "el-icon-close",
|
|
12705
|
-
staticStyle: {
|
|
12706
|
-
"font-size": "2rem"
|
|
12707
|
-
},
|
|
12708
|
-
on: {
|
|
12709
|
-
"click": function ($event) {
|
|
12710
|
-
return _vm.cancelPopover();
|
|
12711
|
-
}
|
|
14920
|
+
del({ text }) {
|
|
14921
|
+
return text;
|
|
12712
14922
|
}
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
}, [_c('el-checkbox-group', {
|
|
12716
|
-
model: {
|
|
12717
|
-
value: _vm.errors,
|
|
12718
|
-
callback: function ($$v) {
|
|
12719
|
-
_vm.errors = $$v;
|
|
12720
|
-
},
|
|
12721
|
-
expression: "errors"
|
|
14923
|
+
html({ text }) {
|
|
14924
|
+
return text;
|
|
12722
14925
|
}
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
key: item.code,
|
|
12726
|
-
staticClass: "check",
|
|
12727
|
-
attrs: {
|
|
12728
|
-
"label": item.code,
|
|
12729
|
-
"border": ""
|
|
12730
|
-
}
|
|
12731
|
-
}, [_vm._v(" " + _vm._s(item.name) + " ")]);
|
|
12732
|
-
}), 1), _c('el-input', {
|
|
12733
|
-
attrs: {
|
|
12734
|
-
"rows": 4,
|
|
12735
|
-
"maxlength": "30",
|
|
12736
|
-
"placeholder": "其他",
|
|
12737
|
-
"resize": "none",
|
|
12738
|
-
"type": "textarea"
|
|
12739
|
-
},
|
|
12740
|
-
model: {
|
|
12741
|
-
value: _vm.input,
|
|
12742
|
-
callback: function ($$v) {
|
|
12743
|
-
_vm.input = $$v;
|
|
12744
|
-
},
|
|
12745
|
-
expression: "input"
|
|
14926
|
+
text({ text }) {
|
|
14927
|
+
return text;
|
|
12746
14928
|
}
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
}, [_c('el-button', {
|
|
12750
|
-
attrs: {
|
|
12751
|
-
"disabled": _vm.canSubmit
|
|
12752
|
-
},
|
|
12753
|
-
on: {
|
|
12754
|
-
"click": function ($event) {
|
|
12755
|
-
return _vm.doCai(_vm.listData);
|
|
12756
|
-
}
|
|
14929
|
+
link({ text }) {
|
|
14930
|
+
return '' + text;
|
|
12757
14931
|
}
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
14932
|
+
image({ text }) {
|
|
14933
|
+
return '' + text;
|
|
14934
|
+
}
|
|
14935
|
+
br() {
|
|
14936
|
+
return '';
|
|
14937
|
+
}
|
|
14938
|
+
}
|
|
12766
14939
|
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
14940
|
+
/**
|
|
14941
|
+
* Parsing & Compiling
|
|
14942
|
+
*/
|
|
14943
|
+
class _Parser {
|
|
14944
|
+
options;
|
|
14945
|
+
renderer;
|
|
14946
|
+
textRenderer;
|
|
14947
|
+
constructor(options) {
|
|
14948
|
+
this.options = options || _defaults;
|
|
14949
|
+
this.options.renderer = this.options.renderer || new _Renderer();
|
|
14950
|
+
this.renderer = this.options.renderer;
|
|
14951
|
+
this.renderer.options = this.options;
|
|
14952
|
+
this.renderer.parser = this;
|
|
14953
|
+
this.textRenderer = new _TextRenderer();
|
|
12781
14954
|
}
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
errorList: errorList
|
|
12789
|
-
};
|
|
12790
|
-
},
|
|
12791
|
-
computed: {
|
|
12792
|
-
canSubmit() {
|
|
12793
|
-
return this.errors.length === 0 && this.input === "";
|
|
12794
|
-
},
|
|
12795
|
-
listData() {
|
|
12796
|
-
return this.detailData;
|
|
14955
|
+
/**
|
|
14956
|
+
* Static Parse Method
|
|
14957
|
+
*/
|
|
14958
|
+
static parse(tokens, options) {
|
|
14959
|
+
const parser = new _Parser(options);
|
|
14960
|
+
return parser.parse(tokens);
|
|
12797
14961
|
}
|
|
12798
|
-
|
|
12799
|
-
|
|
12800
|
-
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
this.popover = true;
|
|
12805
|
-
},
|
|
12806
|
-
async stopChat(list) {
|
|
12807
|
-
const {
|
|
12808
|
-
msgId
|
|
12809
|
-
} = list;
|
|
12810
|
-
await stopChat(msgId);
|
|
12811
|
-
list.stop = true;
|
|
12812
|
-
this.$emit('on-stop-chat', list);
|
|
12813
|
-
},
|
|
12814
|
-
async reAnswer(list) {
|
|
12815
|
-
list.reAnswerCount += 1;
|
|
12816
|
-
if (list.reAnswerCount >= 3) {
|
|
12817
|
-
this.$confirm('对于回答是否依旧不满意,是否需要给教师负责人发送请求信息,由老师进行回答?', '提示', {
|
|
12818
|
-
confirmButtonText: '确定',
|
|
12819
|
-
cancelButtonText: '取消',
|
|
12820
|
-
type: 'warning'
|
|
12821
|
-
}).then(async () => {
|
|
12822
|
-
await pustReanswerToTeacher({
|
|
12823
|
-
chatId: this.chatId,
|
|
12824
|
-
msgId: list.msgId,
|
|
12825
|
-
parentMsgId: list.parentMsgId
|
|
12826
|
-
});
|
|
12827
|
-
this.$message.success('已发送给老师');
|
|
12828
|
-
}).catch(() => {});
|
|
12829
|
-
}
|
|
12830
|
-
this.$emit('on-reanswer', list);
|
|
12831
|
-
},
|
|
12832
|
-
async doZan(list) {
|
|
12833
|
-
const param = {
|
|
12834
|
-
chatId: this.chatId,
|
|
12835
|
-
msgId: list.msgId,
|
|
12836
|
-
type: 1
|
|
12837
|
-
};
|
|
12838
|
-
list.zan ? await chatEvaluateCancel(param) : await chatEvaluateAdd(param);
|
|
12839
|
-
list.zan = !list.zan;
|
|
12840
|
-
list.cai = false;
|
|
12841
|
-
},
|
|
12842
|
-
async doCai(list) {
|
|
12843
|
-
let caiOption = {};
|
|
12844
|
-
if (!list.cai) {
|
|
12845
|
-
caiOption = {
|
|
12846
|
-
desc: this.input,
|
|
12847
|
-
tags: this.errors
|
|
12848
|
-
};
|
|
12849
|
-
}
|
|
12850
|
-
const param = {
|
|
12851
|
-
chatId: this.chatId,
|
|
12852
|
-
msgId: list.msgId,
|
|
12853
|
-
type: 2,
|
|
12854
|
-
...caiOption
|
|
12855
|
-
};
|
|
12856
|
-
list.cai ? await chatEvaluateCancel(param) : await chatEvaluateAdd(param);
|
|
12857
|
-
list.cai = !list.cai;
|
|
12858
|
-
list.zan = false;
|
|
12859
|
-
if (list.cai) {
|
|
12860
|
-
this.$message.success('感谢您的反馈');
|
|
12861
|
-
}
|
|
12862
|
-
this.popover = false;
|
|
12863
|
-
this.input = '';
|
|
12864
|
-
this.errors = [];
|
|
14962
|
+
/**
|
|
14963
|
+
* Static Parse Inline Method
|
|
14964
|
+
*/
|
|
14965
|
+
static parseInline(tokens, options) {
|
|
14966
|
+
const parser = new _Parser(options);
|
|
14967
|
+
return parser.parseInline(tokens);
|
|
12865
14968
|
}
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
14969
|
+
/**
|
|
14970
|
+
* Parse Loop
|
|
14971
|
+
*/
|
|
14972
|
+
parse(tokens, top = true) {
|
|
14973
|
+
let out = '';
|
|
14974
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
14975
|
+
const anyToken = tokens[i];
|
|
14976
|
+
// Run any renderer extensions
|
|
14977
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
|
|
14978
|
+
const genericToken = anyToken;
|
|
14979
|
+
const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
|
|
14980
|
+
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(genericToken.type)) {
|
|
14981
|
+
out += ret || '';
|
|
14982
|
+
continue;
|
|
14983
|
+
}
|
|
14984
|
+
}
|
|
14985
|
+
const token = anyToken;
|
|
14986
|
+
switch (token.type) {
|
|
14987
|
+
case 'space': {
|
|
14988
|
+
out += this.renderer.space(token);
|
|
14989
|
+
continue;
|
|
14990
|
+
}
|
|
14991
|
+
case 'hr': {
|
|
14992
|
+
out += this.renderer.hr(token);
|
|
14993
|
+
continue;
|
|
14994
|
+
}
|
|
14995
|
+
case 'heading': {
|
|
14996
|
+
out += this.renderer.heading(token);
|
|
14997
|
+
continue;
|
|
14998
|
+
}
|
|
14999
|
+
case 'code': {
|
|
15000
|
+
out += this.renderer.code(token);
|
|
15001
|
+
continue;
|
|
15002
|
+
}
|
|
15003
|
+
case 'table': {
|
|
15004
|
+
out += this.renderer.table(token);
|
|
15005
|
+
continue;
|
|
15006
|
+
}
|
|
15007
|
+
case 'blockquote': {
|
|
15008
|
+
out += this.renderer.blockquote(token);
|
|
15009
|
+
continue;
|
|
15010
|
+
}
|
|
15011
|
+
case 'list': {
|
|
15012
|
+
out += this.renderer.list(token);
|
|
15013
|
+
continue;
|
|
15014
|
+
}
|
|
15015
|
+
case 'html': {
|
|
15016
|
+
out += this.renderer.html(token);
|
|
15017
|
+
continue;
|
|
15018
|
+
}
|
|
15019
|
+
case 'paragraph': {
|
|
15020
|
+
out += this.renderer.paragraph(token);
|
|
15021
|
+
continue;
|
|
15022
|
+
}
|
|
15023
|
+
case 'text': {
|
|
15024
|
+
let textToken = token;
|
|
15025
|
+
let body = this.renderer.text(textToken);
|
|
15026
|
+
while (i + 1 < tokens.length && tokens[i + 1].type === 'text') {
|
|
15027
|
+
textToken = tokens[++i];
|
|
15028
|
+
body += '\n' + this.renderer.text(textToken);
|
|
15029
|
+
}
|
|
15030
|
+
if (top) {
|
|
15031
|
+
out += this.renderer.paragraph({
|
|
15032
|
+
type: 'paragraph',
|
|
15033
|
+
raw: body,
|
|
15034
|
+
text: body,
|
|
15035
|
+
tokens: [{ type: 'text', raw: body, text: body }],
|
|
15036
|
+
});
|
|
15037
|
+
}
|
|
15038
|
+
else {
|
|
15039
|
+
out += body;
|
|
15040
|
+
}
|
|
15041
|
+
continue;
|
|
15042
|
+
}
|
|
15043
|
+
default: {
|
|
15044
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
15045
|
+
if (this.options.silent) {
|
|
15046
|
+
console.error(errMsg);
|
|
15047
|
+
return '';
|
|
15048
|
+
}
|
|
15049
|
+
else {
|
|
15050
|
+
throw new Error(errMsg);
|
|
15051
|
+
}
|
|
15052
|
+
}
|
|
15053
|
+
}
|
|
15054
|
+
}
|
|
15055
|
+
return out;
|
|
15056
|
+
}
|
|
15057
|
+
/**
|
|
15058
|
+
* Parse Inline Tokens
|
|
15059
|
+
*/
|
|
15060
|
+
parseInline(tokens, renderer) {
|
|
15061
|
+
renderer = renderer || this.renderer;
|
|
15062
|
+
let out = '';
|
|
15063
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
15064
|
+
const anyToken = tokens[i];
|
|
15065
|
+
// Run any renderer extensions
|
|
15066
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
|
|
15067
|
+
const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
|
|
15068
|
+
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(anyToken.type)) {
|
|
15069
|
+
out += ret || '';
|
|
15070
|
+
continue;
|
|
15071
|
+
}
|
|
15072
|
+
}
|
|
15073
|
+
const token = anyToken;
|
|
15074
|
+
switch (token.type) {
|
|
15075
|
+
case 'escape': {
|
|
15076
|
+
out += renderer.text(token);
|
|
15077
|
+
break;
|
|
15078
|
+
}
|
|
15079
|
+
case 'html': {
|
|
15080
|
+
out += renderer.html(token);
|
|
15081
|
+
break;
|
|
15082
|
+
}
|
|
15083
|
+
case 'link': {
|
|
15084
|
+
out += renderer.link(token);
|
|
15085
|
+
break;
|
|
15086
|
+
}
|
|
15087
|
+
case 'image': {
|
|
15088
|
+
out += renderer.image(token);
|
|
15089
|
+
break;
|
|
15090
|
+
}
|
|
15091
|
+
case 'strong': {
|
|
15092
|
+
out += renderer.strong(token);
|
|
15093
|
+
break;
|
|
15094
|
+
}
|
|
15095
|
+
case 'em': {
|
|
15096
|
+
out += renderer.em(token);
|
|
15097
|
+
break;
|
|
15098
|
+
}
|
|
15099
|
+
case 'codespan': {
|
|
15100
|
+
out += renderer.codespan(token);
|
|
15101
|
+
break;
|
|
15102
|
+
}
|
|
15103
|
+
case 'br': {
|
|
15104
|
+
out += renderer.br(token);
|
|
15105
|
+
break;
|
|
15106
|
+
}
|
|
15107
|
+
case 'del': {
|
|
15108
|
+
out += renderer.del(token);
|
|
15109
|
+
break;
|
|
15110
|
+
}
|
|
15111
|
+
case 'text': {
|
|
15112
|
+
out += renderer.text(token);
|
|
15113
|
+
break;
|
|
15114
|
+
}
|
|
15115
|
+
default: {
|
|
15116
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
15117
|
+
if (this.options.silent) {
|
|
15118
|
+
console.error(errMsg);
|
|
15119
|
+
return '';
|
|
15120
|
+
}
|
|
15121
|
+
else {
|
|
15122
|
+
throw new Error(errMsg);
|
|
15123
|
+
}
|
|
15124
|
+
}
|
|
15125
|
+
}
|
|
15126
|
+
}
|
|
15127
|
+
return out;
|
|
15128
|
+
}
|
|
15129
|
+
}
|
|
12876
15130
|
|
|
15131
|
+
class _Hooks {
|
|
15132
|
+
options;
|
|
15133
|
+
block;
|
|
15134
|
+
constructor(options) {
|
|
15135
|
+
this.options = options || _defaults;
|
|
15136
|
+
}
|
|
15137
|
+
static passThroughHooks = new Set([
|
|
15138
|
+
'preprocess',
|
|
15139
|
+
'postprocess',
|
|
15140
|
+
'processAllTokens',
|
|
15141
|
+
]);
|
|
15142
|
+
/**
|
|
15143
|
+
* Process markdown before marked
|
|
15144
|
+
*/
|
|
15145
|
+
preprocess(markdown) {
|
|
15146
|
+
return markdown;
|
|
15147
|
+
}
|
|
15148
|
+
/**
|
|
15149
|
+
* Process HTML after marked is finished
|
|
15150
|
+
*/
|
|
15151
|
+
postprocess(html) {
|
|
15152
|
+
return html;
|
|
15153
|
+
}
|
|
15154
|
+
/**
|
|
15155
|
+
* Process all tokens before walk tokens
|
|
15156
|
+
*/
|
|
15157
|
+
processAllTokens(tokens) {
|
|
15158
|
+
return tokens;
|
|
15159
|
+
}
|
|
15160
|
+
/**
|
|
15161
|
+
* Provide function to tokenize markdown
|
|
15162
|
+
*/
|
|
15163
|
+
provideLexer() {
|
|
15164
|
+
return this.block ? _Lexer.lex : _Lexer.lexInline;
|
|
15165
|
+
}
|
|
15166
|
+
/**
|
|
15167
|
+
* Provide function to parse tokens
|
|
15168
|
+
*/
|
|
15169
|
+
provideParser() {
|
|
15170
|
+
return this.block ? _Parser.parse : _Parser.parseInline;
|
|
15171
|
+
}
|
|
15172
|
+
}
|
|
12877
15173
|
|
|
15174
|
+
class Marked {
|
|
15175
|
+
defaults = _getDefaults();
|
|
15176
|
+
options = this.setOptions;
|
|
15177
|
+
parse = this.parseMarkdown(true);
|
|
15178
|
+
parseInline = this.parseMarkdown(false);
|
|
15179
|
+
Parser = _Parser;
|
|
15180
|
+
Renderer = _Renderer;
|
|
15181
|
+
TextRenderer = _TextRenderer;
|
|
15182
|
+
Lexer = _Lexer;
|
|
15183
|
+
Tokenizer = _Tokenizer;
|
|
15184
|
+
Hooks = _Hooks;
|
|
15185
|
+
constructor(...args) {
|
|
15186
|
+
this.use(...args);
|
|
15187
|
+
}
|
|
15188
|
+
/**
|
|
15189
|
+
* Run callback for every token
|
|
15190
|
+
*/
|
|
15191
|
+
walkTokens(tokens, callback) {
|
|
15192
|
+
let values = [];
|
|
15193
|
+
for (const token of tokens) {
|
|
15194
|
+
values = values.concat(callback.call(this, token));
|
|
15195
|
+
switch (token.type) {
|
|
15196
|
+
case 'table': {
|
|
15197
|
+
const tableToken = token;
|
|
15198
|
+
for (const cell of tableToken.header) {
|
|
15199
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
15200
|
+
}
|
|
15201
|
+
for (const row of tableToken.rows) {
|
|
15202
|
+
for (const cell of row) {
|
|
15203
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
15204
|
+
}
|
|
15205
|
+
}
|
|
15206
|
+
break;
|
|
15207
|
+
}
|
|
15208
|
+
case 'list': {
|
|
15209
|
+
const listToken = token;
|
|
15210
|
+
values = values.concat(this.walkTokens(listToken.items, callback));
|
|
15211
|
+
break;
|
|
15212
|
+
}
|
|
15213
|
+
default: {
|
|
15214
|
+
const genericToken = token;
|
|
15215
|
+
if (this.defaults.extensions?.childTokens?.[genericToken.type]) {
|
|
15216
|
+
this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
|
|
15217
|
+
const tokens = genericToken[childTokens].flat(Infinity);
|
|
15218
|
+
values = values.concat(this.walkTokens(tokens, callback));
|
|
15219
|
+
});
|
|
15220
|
+
}
|
|
15221
|
+
else if (genericToken.tokens) {
|
|
15222
|
+
values = values.concat(this.walkTokens(genericToken.tokens, callback));
|
|
15223
|
+
}
|
|
15224
|
+
}
|
|
15225
|
+
}
|
|
15226
|
+
}
|
|
15227
|
+
return values;
|
|
15228
|
+
}
|
|
15229
|
+
use(...args) {
|
|
15230
|
+
const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
15231
|
+
args.forEach((pack) => {
|
|
15232
|
+
// copy options to new object
|
|
15233
|
+
const opts = { ...pack };
|
|
15234
|
+
// set async to true if it was set to true before
|
|
15235
|
+
opts.async = this.defaults.async || opts.async || false;
|
|
15236
|
+
// ==-- Parse "addon" extensions --== //
|
|
15237
|
+
if (pack.extensions) {
|
|
15238
|
+
pack.extensions.forEach((ext) => {
|
|
15239
|
+
if (!ext.name) {
|
|
15240
|
+
throw new Error('extension name required');
|
|
15241
|
+
}
|
|
15242
|
+
if ('renderer' in ext) { // Renderer extensions
|
|
15243
|
+
const prevRenderer = extensions.renderers[ext.name];
|
|
15244
|
+
if (prevRenderer) {
|
|
15245
|
+
// Replace extension with func to run new extension but fall back if false
|
|
15246
|
+
extensions.renderers[ext.name] = function (...args) {
|
|
15247
|
+
let ret = ext.renderer.apply(this, args);
|
|
15248
|
+
if (ret === false) {
|
|
15249
|
+
ret = prevRenderer.apply(this, args);
|
|
15250
|
+
}
|
|
15251
|
+
return ret;
|
|
15252
|
+
};
|
|
15253
|
+
}
|
|
15254
|
+
else {
|
|
15255
|
+
extensions.renderers[ext.name] = ext.renderer;
|
|
15256
|
+
}
|
|
15257
|
+
}
|
|
15258
|
+
if ('tokenizer' in ext) { // Tokenizer Extensions
|
|
15259
|
+
if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) {
|
|
15260
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
15261
|
+
}
|
|
15262
|
+
const extLevel = extensions[ext.level];
|
|
15263
|
+
if (extLevel) {
|
|
15264
|
+
extLevel.unshift(ext.tokenizer);
|
|
15265
|
+
}
|
|
15266
|
+
else {
|
|
15267
|
+
extensions[ext.level] = [ext.tokenizer];
|
|
15268
|
+
}
|
|
15269
|
+
if (ext.start) { // Function to check for start of token
|
|
15270
|
+
if (ext.level === 'block') {
|
|
15271
|
+
if (extensions.startBlock) {
|
|
15272
|
+
extensions.startBlock.push(ext.start);
|
|
15273
|
+
}
|
|
15274
|
+
else {
|
|
15275
|
+
extensions.startBlock = [ext.start];
|
|
15276
|
+
}
|
|
15277
|
+
}
|
|
15278
|
+
else if (ext.level === 'inline') {
|
|
15279
|
+
if (extensions.startInline) {
|
|
15280
|
+
extensions.startInline.push(ext.start);
|
|
15281
|
+
}
|
|
15282
|
+
else {
|
|
15283
|
+
extensions.startInline = [ext.start];
|
|
15284
|
+
}
|
|
15285
|
+
}
|
|
15286
|
+
}
|
|
15287
|
+
}
|
|
15288
|
+
if ('childTokens' in ext && ext.childTokens) { // Child tokens to be visited by walkTokens
|
|
15289
|
+
extensions.childTokens[ext.name] = ext.childTokens;
|
|
15290
|
+
}
|
|
15291
|
+
});
|
|
15292
|
+
opts.extensions = extensions;
|
|
15293
|
+
}
|
|
15294
|
+
// ==-- Parse "overwrite" extensions --== //
|
|
15295
|
+
if (pack.renderer) {
|
|
15296
|
+
const renderer = this.defaults.renderer || new _Renderer(this.defaults);
|
|
15297
|
+
for (const prop in pack.renderer) {
|
|
15298
|
+
if (!(prop in renderer)) {
|
|
15299
|
+
throw new Error(`renderer '${prop}' does not exist`);
|
|
15300
|
+
}
|
|
15301
|
+
if (['options', 'parser'].includes(prop)) {
|
|
15302
|
+
// ignore options property
|
|
15303
|
+
continue;
|
|
15304
|
+
}
|
|
15305
|
+
const rendererProp = prop;
|
|
15306
|
+
const rendererFunc = pack.renderer[rendererProp];
|
|
15307
|
+
const prevRenderer = renderer[rendererProp];
|
|
15308
|
+
// Replace renderer with func to run extension, but fall back if false
|
|
15309
|
+
renderer[rendererProp] = (...args) => {
|
|
15310
|
+
let ret = rendererFunc.apply(renderer, args);
|
|
15311
|
+
if (ret === false) {
|
|
15312
|
+
ret = prevRenderer.apply(renderer, args);
|
|
15313
|
+
}
|
|
15314
|
+
return ret || '';
|
|
15315
|
+
};
|
|
15316
|
+
}
|
|
15317
|
+
opts.renderer = renderer;
|
|
15318
|
+
}
|
|
15319
|
+
if (pack.tokenizer) {
|
|
15320
|
+
const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
|
|
15321
|
+
for (const prop in pack.tokenizer) {
|
|
15322
|
+
if (!(prop in tokenizer)) {
|
|
15323
|
+
throw new Error(`tokenizer '${prop}' does not exist`);
|
|
15324
|
+
}
|
|
15325
|
+
if (['options', 'rules', 'lexer'].includes(prop)) {
|
|
15326
|
+
// ignore options, rules, and lexer properties
|
|
15327
|
+
continue;
|
|
15328
|
+
}
|
|
15329
|
+
const tokenizerProp = prop;
|
|
15330
|
+
const tokenizerFunc = pack.tokenizer[tokenizerProp];
|
|
15331
|
+
const prevTokenizer = tokenizer[tokenizerProp];
|
|
15332
|
+
// Replace tokenizer with func to run extension, but fall back if false
|
|
15333
|
+
// @ts-expect-error cannot type tokenizer function dynamically
|
|
15334
|
+
tokenizer[tokenizerProp] = (...args) => {
|
|
15335
|
+
let ret = tokenizerFunc.apply(tokenizer, args);
|
|
15336
|
+
if (ret === false) {
|
|
15337
|
+
ret = prevTokenizer.apply(tokenizer, args);
|
|
15338
|
+
}
|
|
15339
|
+
return ret;
|
|
15340
|
+
};
|
|
15341
|
+
}
|
|
15342
|
+
opts.tokenizer = tokenizer;
|
|
15343
|
+
}
|
|
15344
|
+
// ==-- Parse Hooks extensions --== //
|
|
15345
|
+
if (pack.hooks) {
|
|
15346
|
+
const hooks = this.defaults.hooks || new _Hooks();
|
|
15347
|
+
for (const prop in pack.hooks) {
|
|
15348
|
+
if (!(prop in hooks)) {
|
|
15349
|
+
throw new Error(`hook '${prop}' does not exist`);
|
|
15350
|
+
}
|
|
15351
|
+
if (['options', 'block'].includes(prop)) {
|
|
15352
|
+
// ignore options and block properties
|
|
15353
|
+
continue;
|
|
15354
|
+
}
|
|
15355
|
+
const hooksProp = prop;
|
|
15356
|
+
const hooksFunc = pack.hooks[hooksProp];
|
|
15357
|
+
const prevHook = hooks[hooksProp];
|
|
15358
|
+
if (_Hooks.passThroughHooks.has(prop)) {
|
|
15359
|
+
// @ts-expect-error cannot type hook function dynamically
|
|
15360
|
+
hooks[hooksProp] = (arg) => {
|
|
15361
|
+
if (this.defaults.async) {
|
|
15362
|
+
return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => {
|
|
15363
|
+
return prevHook.call(hooks, ret);
|
|
15364
|
+
});
|
|
15365
|
+
}
|
|
15366
|
+
const ret = hooksFunc.call(hooks, arg);
|
|
15367
|
+
return prevHook.call(hooks, ret);
|
|
15368
|
+
};
|
|
15369
|
+
}
|
|
15370
|
+
else {
|
|
15371
|
+
// @ts-expect-error cannot type hook function dynamically
|
|
15372
|
+
hooks[hooksProp] = (...args) => {
|
|
15373
|
+
let ret = hooksFunc.apply(hooks, args);
|
|
15374
|
+
if (ret === false) {
|
|
15375
|
+
ret = prevHook.apply(hooks, args);
|
|
15376
|
+
}
|
|
15377
|
+
return ret;
|
|
15378
|
+
};
|
|
15379
|
+
}
|
|
15380
|
+
}
|
|
15381
|
+
opts.hooks = hooks;
|
|
15382
|
+
}
|
|
15383
|
+
// ==-- Parse WalkTokens extensions --== //
|
|
15384
|
+
if (pack.walkTokens) {
|
|
15385
|
+
const walkTokens = this.defaults.walkTokens;
|
|
15386
|
+
const packWalktokens = pack.walkTokens;
|
|
15387
|
+
opts.walkTokens = function (token) {
|
|
15388
|
+
let values = [];
|
|
15389
|
+
values.push(packWalktokens.call(this, token));
|
|
15390
|
+
if (walkTokens) {
|
|
15391
|
+
values = values.concat(walkTokens.call(this, token));
|
|
15392
|
+
}
|
|
15393
|
+
return values;
|
|
15394
|
+
};
|
|
15395
|
+
}
|
|
15396
|
+
this.defaults = { ...this.defaults, ...opts };
|
|
15397
|
+
});
|
|
15398
|
+
return this;
|
|
15399
|
+
}
|
|
15400
|
+
setOptions(opt) {
|
|
15401
|
+
this.defaults = { ...this.defaults, ...opt };
|
|
15402
|
+
return this;
|
|
15403
|
+
}
|
|
15404
|
+
lexer(src, options) {
|
|
15405
|
+
return _Lexer.lex(src, options ?? this.defaults);
|
|
15406
|
+
}
|
|
15407
|
+
parser(tokens, options) {
|
|
15408
|
+
return _Parser.parse(tokens, options ?? this.defaults);
|
|
15409
|
+
}
|
|
15410
|
+
parseMarkdown(blockType) {
|
|
15411
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15412
|
+
const parse = (src, options) => {
|
|
15413
|
+
const origOpt = { ...options };
|
|
15414
|
+
const opt = { ...this.defaults, ...origOpt };
|
|
15415
|
+
const throwError = this.onError(!!opt.silent, !!opt.async);
|
|
15416
|
+
// throw error if an extension set async to true but parse was called with async: false
|
|
15417
|
+
if (this.defaults.async === true && origOpt.async === false) {
|
|
15418
|
+
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.'));
|
|
15419
|
+
}
|
|
15420
|
+
// throw error in case of non string input
|
|
15421
|
+
if (typeof src === 'undefined' || src === null) {
|
|
15422
|
+
return throwError(new Error('marked(): input parameter is undefined or null'));
|
|
15423
|
+
}
|
|
15424
|
+
if (typeof src !== 'string') {
|
|
15425
|
+
return throwError(new Error('marked(): input parameter is of type '
|
|
15426
|
+
+ Object.prototype.toString.call(src) + ', string expected'));
|
|
15427
|
+
}
|
|
15428
|
+
if (opt.hooks) {
|
|
15429
|
+
opt.hooks.options = opt;
|
|
15430
|
+
opt.hooks.block = blockType;
|
|
15431
|
+
}
|
|
15432
|
+
const lexer = opt.hooks ? opt.hooks.provideLexer() : (blockType ? _Lexer.lex : _Lexer.lexInline);
|
|
15433
|
+
const parser = opt.hooks ? opt.hooks.provideParser() : (blockType ? _Parser.parse : _Parser.parseInline);
|
|
15434
|
+
if (opt.async) {
|
|
15435
|
+
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
|
|
15436
|
+
.then(src => lexer(src, opt))
|
|
15437
|
+
.then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens)
|
|
15438
|
+
.then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens)
|
|
15439
|
+
.then(tokens => parser(tokens, opt))
|
|
15440
|
+
.then(html => opt.hooks ? opt.hooks.postprocess(html) : html)
|
|
15441
|
+
.catch(throwError);
|
|
15442
|
+
}
|
|
15443
|
+
try {
|
|
15444
|
+
if (opt.hooks) {
|
|
15445
|
+
src = opt.hooks.preprocess(src);
|
|
15446
|
+
}
|
|
15447
|
+
let tokens = lexer(src, opt);
|
|
15448
|
+
if (opt.hooks) {
|
|
15449
|
+
tokens = opt.hooks.processAllTokens(tokens);
|
|
15450
|
+
}
|
|
15451
|
+
if (opt.walkTokens) {
|
|
15452
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
15453
|
+
}
|
|
15454
|
+
let html = parser(tokens, opt);
|
|
15455
|
+
if (opt.hooks) {
|
|
15456
|
+
html = opt.hooks.postprocess(html);
|
|
15457
|
+
}
|
|
15458
|
+
return html;
|
|
15459
|
+
}
|
|
15460
|
+
catch (e) {
|
|
15461
|
+
return throwError(e);
|
|
15462
|
+
}
|
|
15463
|
+
};
|
|
15464
|
+
return parse;
|
|
15465
|
+
}
|
|
15466
|
+
onError(silent, async) {
|
|
15467
|
+
return (e) => {
|
|
15468
|
+
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
15469
|
+
if (silent) {
|
|
15470
|
+
const msg = '<p>An error occurred:</p><pre>'
|
|
15471
|
+
+ escape$1(e.message + '', true)
|
|
15472
|
+
+ '</pre>';
|
|
15473
|
+
if (async) {
|
|
15474
|
+
return Promise.resolve(msg);
|
|
15475
|
+
}
|
|
15476
|
+
return msg;
|
|
15477
|
+
}
|
|
15478
|
+
if (async) {
|
|
15479
|
+
return Promise.reject(e);
|
|
15480
|
+
}
|
|
15481
|
+
throw e;
|
|
15482
|
+
};
|
|
15483
|
+
}
|
|
15484
|
+
}
|
|
12878
15485
|
|
|
12879
|
-
;
|
|
15486
|
+
const markedInstance = new Marked();
|
|
15487
|
+
function marked(src, opt) {
|
|
15488
|
+
return markedInstance.parse(src, opt);
|
|
15489
|
+
}
|
|
15490
|
+
/**
|
|
15491
|
+
* Sets the default options.
|
|
15492
|
+
*
|
|
15493
|
+
* @param options Hash of options
|
|
15494
|
+
*/
|
|
15495
|
+
marked.options =
|
|
15496
|
+
marked.setOptions = function (options) {
|
|
15497
|
+
markedInstance.setOptions(options);
|
|
15498
|
+
marked.defaults = markedInstance.defaults;
|
|
15499
|
+
changeDefaults(marked.defaults);
|
|
15500
|
+
return marked;
|
|
15501
|
+
};
|
|
15502
|
+
/**
|
|
15503
|
+
* Gets the original marked default options.
|
|
15504
|
+
*/
|
|
15505
|
+
marked.getDefaults = _getDefaults;
|
|
15506
|
+
marked.defaults = _defaults;
|
|
15507
|
+
/**
|
|
15508
|
+
* Use Extension
|
|
15509
|
+
*/
|
|
15510
|
+
marked.use = function (...args) {
|
|
15511
|
+
markedInstance.use(...args);
|
|
15512
|
+
marked.defaults = markedInstance.defaults;
|
|
15513
|
+
changeDefaults(marked.defaults);
|
|
15514
|
+
return marked;
|
|
15515
|
+
};
|
|
15516
|
+
/**
|
|
15517
|
+
* Run callback for every token
|
|
15518
|
+
*/
|
|
15519
|
+
marked.walkTokens = function (tokens, callback) {
|
|
15520
|
+
return markedInstance.walkTokens(tokens, callback);
|
|
15521
|
+
};
|
|
15522
|
+
/**
|
|
15523
|
+
* Compiles markdown to HTML without enclosing `p` tag.
|
|
15524
|
+
*
|
|
15525
|
+
* @param src String of markdown source to be compiled
|
|
15526
|
+
* @param options Hash of options
|
|
15527
|
+
* @return String of compiled HTML
|
|
15528
|
+
*/
|
|
15529
|
+
marked.parseInline = markedInstance.parseInline;
|
|
15530
|
+
/**
|
|
15531
|
+
* Expose
|
|
15532
|
+
*/
|
|
15533
|
+
marked.Parser = _Parser;
|
|
15534
|
+
marked.parser = _Parser.parse;
|
|
15535
|
+
marked.Renderer = _Renderer;
|
|
15536
|
+
marked.TextRenderer = _TextRenderer;
|
|
15537
|
+
marked.Lexer = _Lexer;
|
|
15538
|
+
marked.lexer = _Lexer.lex;
|
|
15539
|
+
marked.Tokenizer = _Tokenizer;
|
|
15540
|
+
marked.Hooks = _Hooks;
|
|
15541
|
+
marked.parse = marked;
|
|
15542
|
+
const options = marked.options;
|
|
15543
|
+
const setOptions = marked.setOptions;
|
|
15544
|
+
const use = marked.use;
|
|
15545
|
+
const walkTokens = marked.walkTokens;
|
|
15546
|
+
const parseInline = marked.parseInline;
|
|
15547
|
+
const parse = (/* unused pure expression or super */ null && (marked));
|
|
15548
|
+
const parser = _Parser.parse;
|
|
15549
|
+
const lexer = _Lexer.lex;
|
|
12880
15550
|
|
|
12881
15551
|
|
|
12882
|
-
|
|
15552
|
+
//# sourceMappingURL=marked.esm.js.map
|
|
12883
15553
|
|
|
12884
|
-
|
|
12885
|
-
src_chat_toolsvue_type_script_lang_js,
|
|
12886
|
-
chat_toolsvue_type_template_id_4de6d38a_scoped_true_render,
|
|
12887
|
-
chat_toolsvue_type_template_id_4de6d38a_scoped_true_staticRenderFns,
|
|
12888
|
-
false,
|
|
12889
|
-
null,
|
|
12890
|
-
"4de6d38a",
|
|
12891
|
-
null
|
|
12892
|
-
|
|
12893
|
-
)
|
|
15554
|
+
;// ./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
|
|
12894
15555
|
|
|
12895
|
-
/* harmony default export */ var chat_tools = (chat_tools_component.exports);
|
|
12896
|
-
;// 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
|
|
12897
15556
|
|
|
12898
15557
|
|
|
12899
15558
|
|
|
@@ -12913,6 +15572,10 @@ const signal = controller.signal;
|
|
|
12913
15572
|
type: String,
|
|
12914
15573
|
default: ''
|
|
12915
15574
|
},
|
|
15575
|
+
openCourseId: {
|
|
15576
|
+
type: String,
|
|
15577
|
+
default: ''
|
|
15578
|
+
},
|
|
12916
15579
|
chatId: {
|
|
12917
15580
|
type: String,
|
|
12918
15581
|
default: ''
|
|
@@ -12932,6 +15595,7 @@ const signal = controller.signal;
|
|
|
12932
15595
|
input: "",
|
|
12933
15596
|
errors: [],
|
|
12934
15597
|
errorList: errorList,
|
|
15598
|
+
finish: false,
|
|
12935
15599
|
cacheKeyWord: '' // 由于外部需要快速清掉 keyword 但是存在重新发送请求的情况,因此需要一个混存记录
|
|
12936
15600
|
};
|
|
12937
15601
|
},
|
|
@@ -12963,6 +15627,7 @@ const signal = controller.signal;
|
|
|
12963
15627
|
},
|
|
12964
15628
|
async postMessage(list, commonKey, parentMsgId) {
|
|
12965
15629
|
let reanswerParams = {};
|
|
15630
|
+
this.finish = false;
|
|
12966
15631
|
if (list) {
|
|
12967
15632
|
list.sending = true;
|
|
12968
15633
|
reanswerParams = {
|
|
@@ -12972,6 +15637,8 @@ const signal = controller.signal;
|
|
|
12972
15637
|
content: this.messageData[list.index - 1].message
|
|
12973
15638
|
};
|
|
12974
15639
|
this.messageData[list.index].message = '';
|
|
15640
|
+
this.messageData[list.index].cacheMessage = '';
|
|
15641
|
+
this.makeAutoMessage();
|
|
12975
15642
|
}
|
|
12976
15643
|
const params = {
|
|
12977
15644
|
messageList: [{
|
|
@@ -12985,26 +15652,43 @@ const signal = controller.signal;
|
|
|
12985
15652
|
};
|
|
12986
15653
|
// list 存在说明是重新生成
|
|
12987
15654
|
if (!list && !commonKey) {
|
|
15655
|
+
const userWord = this.keyWord || this.cacheKeyWord;
|
|
12988
15656
|
this.messageData.push({
|
|
12989
15657
|
type: 'user',
|
|
12990
|
-
message:
|
|
15658
|
+
message: userWord.replace(/\n/g, '<br>')
|
|
15659
|
+
});
|
|
15660
|
+
setTimeout(() => {
|
|
15661
|
+
this.messageData.push({
|
|
15662
|
+
type: 'robot',
|
|
15663
|
+
message: '',
|
|
15664
|
+
cacheMessage: '',
|
|
15665
|
+
zan: false,
|
|
15666
|
+
cai: false,
|
|
15667
|
+
stop: false,
|
|
15668
|
+
finish: false,
|
|
15669
|
+
sending: true,
|
|
15670
|
+
links: [],
|
|
15671
|
+
connectUrl: [],
|
|
15672
|
+
reAnswerCount: 0
|
|
15673
|
+
});
|
|
15674
|
+
this.makeAutoMessage();
|
|
12991
15675
|
});
|
|
12992
|
-
setTimeout(() => this.messageData.push({
|
|
12993
|
-
type: 'robot',
|
|
12994
|
-
message: '',
|
|
12995
|
-
zan: false,
|
|
12996
|
-
cai: false,
|
|
12997
|
-
stop: false,
|
|
12998
|
-
finish: false,
|
|
12999
|
-
sending: true,
|
|
13000
|
-
links: [],
|
|
13001
|
-
reAnswerCount: 0
|
|
13002
|
-
}));
|
|
13003
15676
|
}
|
|
13004
15677
|
await sendMessageEventSource(params, signal, res => {
|
|
13005
15678
|
this.makeMessageLine(res, list);
|
|
13006
15679
|
});
|
|
13007
15680
|
},
|
|
15681
|
+
makeAutoMessage() {
|
|
15682
|
+
const cacheMessage = [];
|
|
15683
|
+
for (let i = 0; i < this.messageData.length; i++) {
|
|
15684
|
+
const current = this.messageData[i];
|
|
15685
|
+
cacheMessage.push({
|
|
15686
|
+
role: current.type === 'robot' ? 'assistant' : 'user',
|
|
15687
|
+
content: current.message || '正在思考中。'
|
|
15688
|
+
});
|
|
15689
|
+
}
|
|
15690
|
+
this.makeAutoQuestioning(cacheMessage);
|
|
15691
|
+
},
|
|
13008
15692
|
makeMessageLine(res, list) {
|
|
13009
15693
|
const {
|
|
13010
15694
|
content,
|
|
@@ -13013,10 +15697,12 @@ const signal = controller.signal;
|
|
|
13013
15697
|
msgId,
|
|
13014
15698
|
parentMsgId,
|
|
13015
15699
|
reference,
|
|
13016
|
-
commonKey
|
|
15700
|
+
commonKey,
|
|
15701
|
+
connectUrl
|
|
13017
15702
|
} = JSON.parse(res.data);
|
|
13018
15703
|
let index = list ? list.index : this.messageData.length - 1;
|
|
13019
15704
|
const currentList = this.messageData[index];
|
|
15705
|
+
let allIdWithStart = true;
|
|
13020
15706
|
// 结束标识
|
|
13021
15707
|
if (status === 2 || status === 1) {
|
|
13022
15708
|
if (commonKey) {
|
|
@@ -13027,12 +15713,23 @@ const signal = controller.signal;
|
|
|
13027
15713
|
currentList.finish = true;
|
|
13028
15714
|
if (reference) {
|
|
13029
15715
|
currentList.links = JSON.parse(reference);
|
|
15716
|
+
currentList.links.map(item => {
|
|
15717
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
15718
|
+
allIdWithStart = false;
|
|
15719
|
+
}
|
|
15720
|
+
});
|
|
15721
|
+
}
|
|
15722
|
+
if (connectUrl) {
|
|
15723
|
+
currentList.connectUrl = JSON.parse(connectUrl);
|
|
13030
15724
|
}
|
|
15725
|
+
currentList.allIdWithStart = allIdWithStart;
|
|
13031
15726
|
this.cacheKeyWord = '';
|
|
15727
|
+
this.finish = true;
|
|
13032
15728
|
this.$emit('on-message-finish', chatId);
|
|
13033
15729
|
return;
|
|
13034
15730
|
}
|
|
13035
|
-
currentList.
|
|
15731
|
+
currentList.cacheMessage += content;
|
|
15732
|
+
currentList.message = marked.parse(currentList.cacheMessage);
|
|
13036
15733
|
currentList.msgId = msgId;
|
|
13037
15734
|
currentList.parentMsgId = parentMsgId;
|
|
13038
15735
|
currentList.chatId = chatId;
|
|
@@ -13042,27 +15739,45 @@ const signal = controller.signal;
|
|
|
13042
15739
|
// 防止出现调用基础模型前导致停止回答id错误
|
|
13043
15740
|
setTimeout(() => currentList.sending = false, 500);
|
|
13044
15741
|
},
|
|
15742
|
+
async makeAutoQuestioning(messages) {
|
|
15743
|
+
// 首次不触发
|
|
15744
|
+
if (messages.length <= 2) return;
|
|
15745
|
+
const autoRes = await getAutoQuestioning(this.chatMajorId, messages);
|
|
15746
|
+
const {
|
|
15747
|
+
message: {
|
|
15748
|
+
content: {
|
|
15749
|
+
followUps
|
|
15750
|
+
}
|
|
15751
|
+
}
|
|
15752
|
+
} = autoRes;
|
|
15753
|
+
this.messageData[this.messageData.length - 1].followUps = followUps.length > 3 ? followUps.splice(0, 3) : followUps;
|
|
15754
|
+
},
|
|
13045
15755
|
onStopChat(list) {
|
|
13046
15756
|
this.$emit('on-message-finish', list.chatId);
|
|
13047
15757
|
},
|
|
15758
|
+
selectModule(message) {
|
|
15759
|
+
this.cacheKeyWord = message;
|
|
15760
|
+
this.postMessage();
|
|
15761
|
+
},
|
|
13048
15762
|
reanswer(list, index) {
|
|
13049
15763
|
list.index = index;
|
|
13050
15764
|
list.stop = false;
|
|
13051
15765
|
list.finish = false;
|
|
13052
15766
|
list.links = [];
|
|
15767
|
+
list.connectUrl = [];
|
|
13053
15768
|
this.postMessage(list);
|
|
13054
15769
|
this.$emit('on-reanser');
|
|
13055
15770
|
}
|
|
13056
15771
|
}
|
|
13057
15772
|
});
|
|
13058
|
-
;//
|
|
15773
|
+
;// ./components/demo/src/chat.vue?vue&type=script&lang=js
|
|
13059
15774
|
/* harmony default export */ var src_chatvue_type_script_lang_js = (chatvue_type_script_lang_js);
|
|
13060
|
-
;//
|
|
15775
|
+
;// ./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=322788ca&prod&lang=scss&scoped=true
|
|
13061
15776
|
// extracted by mini-css-extract-plugin
|
|
13062
15777
|
|
|
13063
|
-
;//
|
|
15778
|
+
;// ./components/demo/src/chat.vue?vue&type=style&index=0&id=322788ca&prod&lang=scss&scoped=true
|
|
13064
15779
|
|
|
13065
|
-
;//
|
|
15780
|
+
;// ./components/demo/src/chat.vue
|
|
13066
15781
|
|
|
13067
15782
|
|
|
13068
15783
|
|
|
@@ -13073,17 +15788,17 @@ const signal = controller.signal;
|
|
|
13073
15788
|
|
|
13074
15789
|
var chat_component = normalizeComponent(
|
|
13075
15790
|
src_chatvue_type_script_lang_js,
|
|
13076
|
-
|
|
13077
|
-
|
|
15791
|
+
chatvue_type_template_id_322788ca_scoped_true_render,
|
|
15792
|
+
chatvue_type_template_id_322788ca_scoped_true_staticRenderFns,
|
|
13078
15793
|
false,
|
|
13079
15794
|
null,
|
|
13080
|
-
"
|
|
15795
|
+
"322788ca",
|
|
13081
15796
|
null
|
|
13082
15797
|
|
|
13083
15798
|
)
|
|
13084
15799
|
|
|
13085
15800
|
/* harmony default export */ var chat = (chat_component.exports);
|
|
13086
|
-
;//
|
|
15801
|
+
;// ./node_modules/js-cookie/dist/js.cookie.mjs
|
|
13087
15802
|
/*! js-cookie v3.0.5 | MIT */
|
|
13088
15803
|
/* eslint-disable no-var */
|
|
13089
15804
|
function js_cookie_assign (target) {
|
|
@@ -13219,7 +15934,8 @@ var api = init(defaultConverter, { path: '/' });
|
|
|
13219
15934
|
|
|
13220
15935
|
|
|
13221
15936
|
|
|
13222
|
-
;//
|
|
15937
|
+
;// ./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
|
|
15938
|
+
|
|
13223
15939
|
|
|
13224
15940
|
|
|
13225
15941
|
|
|
@@ -13236,6 +15952,10 @@ var api = init(defaultConverter, { path: '/' });
|
|
|
13236
15952
|
resId: {
|
|
13237
15953
|
type: String,
|
|
13238
15954
|
default: ''
|
|
15955
|
+
},
|
|
15956
|
+
openCourseId: {
|
|
15957
|
+
type: String,
|
|
15958
|
+
default: ''
|
|
13239
15959
|
}
|
|
13240
15960
|
},
|
|
13241
15961
|
watch: {
|
|
@@ -13283,8 +16003,10 @@ var api = init(defaultConverter, { path: '/' });
|
|
|
13283
16003
|
}
|
|
13284
16004
|
this.$emit('close');
|
|
13285
16005
|
},
|
|
13286
|
-
selectModule() {
|
|
16006
|
+
selectModule(hotKey) {
|
|
13287
16007
|
this.chatShow = true;
|
|
16008
|
+
this.aiMessage = hotKey;
|
|
16009
|
+
this.goChat({});
|
|
13288
16010
|
},
|
|
13289
16011
|
showHot() {
|
|
13290
16012
|
this.chatShow = false;
|
|
@@ -13297,20 +16019,30 @@ var api = init(defaultConverter, { path: '/' });
|
|
|
13297
16019
|
const {
|
|
13298
16020
|
chatMajorId
|
|
13299
16021
|
} = listRes[0];
|
|
13300
|
-
this.chatMajorId = chatMajorId.toString();
|
|
16022
|
+
this.chatMajorId = chatMajorId && chatMajorId.toString();
|
|
13301
16023
|
const cacheArray = [];
|
|
13302
16024
|
currentList.map(list => {
|
|
16025
|
+
let allIdWithStart = true;
|
|
16026
|
+
if (this.chatMajorId && list.references) {
|
|
16027
|
+
list.references.map(item => {
|
|
16028
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
16029
|
+
allIdWithStart = false;
|
|
16030
|
+
}
|
|
16031
|
+
});
|
|
16032
|
+
}
|
|
13303
16033
|
const obj = {
|
|
13304
16034
|
type: list.role === 'assistant' ? 'robot' : 'user',
|
|
13305
|
-
message: list.content.replace(/\n/g, '<br>'),
|
|
16035
|
+
message: list.role === 'assistant' ? marked.parse(list.content) : list.content.replace(/\n/g, '<br>'),
|
|
13306
16036
|
zan: list.type === 1,
|
|
13307
16037
|
cai: list.type === 2,
|
|
13308
16038
|
stop: list.status === 1,
|
|
13309
16039
|
finish: true,
|
|
13310
16040
|
links: list.references || [],
|
|
16041
|
+
connectUrl: list.connectUrls || [],
|
|
13311
16042
|
reAnswerCount: 0,
|
|
13312
16043
|
msgId: list.contentId,
|
|
13313
|
-
parentMsgId: list.parentMsgId
|
|
16044
|
+
parentMsgId: list.parentMsgId,
|
|
16045
|
+
allIdWithStart
|
|
13314
16046
|
};
|
|
13315
16047
|
cacheArray.push(obj);
|
|
13316
16048
|
});
|
|
@@ -13387,14 +16119,14 @@ var api = init(defaultConverter, { path: '/' });
|
|
|
13387
16119
|
}
|
|
13388
16120
|
}
|
|
13389
16121
|
});
|
|
13390
|
-
;//
|
|
16122
|
+
;// ./components/demo/src/main.vue?vue&type=script&lang=js
|
|
13391
16123
|
/* harmony default export */ var src_mainvue_type_script_lang_js = (mainvue_type_script_lang_js);
|
|
13392
|
-
;//
|
|
16124
|
+
;// ./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=4903e526&prod&lang=scss&scoped=true
|
|
13393
16125
|
// extracted by mini-css-extract-plugin
|
|
13394
16126
|
|
|
13395
|
-
;//
|
|
16127
|
+
;// ./components/demo/src/main.vue?vue&type=style&index=0&id=4903e526&prod&lang=scss&scoped=true
|
|
13396
16128
|
|
|
13397
|
-
;//
|
|
16129
|
+
;// ./components/demo/src/main.vue
|
|
13398
16130
|
|
|
13399
16131
|
|
|
13400
16132
|
|
|
@@ -13409,19 +16141,19 @@ var main_component = normalizeComponent(
|
|
|
13409
16141
|
staticRenderFns,
|
|
13410
16142
|
false,
|
|
13411
16143
|
null,
|
|
13412
|
-
"
|
|
16144
|
+
"4903e526",
|
|
13413
16145
|
null
|
|
13414
16146
|
|
|
13415
16147
|
)
|
|
13416
16148
|
|
|
13417
16149
|
/* harmony default export */ var main = (main_component.exports);
|
|
13418
|
-
;//
|
|
16150
|
+
;// ./components/demo/index.js
|
|
13419
16151
|
|
|
13420
16152
|
main.install = function (Vue) {
|
|
13421
16153
|
Vue.component(main.name, main);
|
|
13422
16154
|
};
|
|
13423
16155
|
/* harmony default export */ var demo = (main);
|
|
13424
|
-
;//
|
|
16156
|
+
;// ./components/index.js
|
|
13425
16157
|
|
|
13426
16158
|
const components = {
|
|
13427
16159
|
AiAssistant: demo
|
|
@@ -13435,7 +16167,7 @@ const install = function (Vue) {
|
|
|
13435
16167
|
/* harmony default export */ var components_0 = ({
|
|
13436
16168
|
install
|
|
13437
16169
|
});
|
|
13438
|
-
;//
|
|
16170
|
+
;// ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
|
|
13439
16171
|
|
|
13440
16172
|
|
|
13441
16173
|
/* harmony default export */ var entry_lib = (components_0);
|