@mongoosejs/studio 0.0.73 → 0.0.75
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/backend/actions/ChatMessage/executeScript.js +74 -0
- package/backend/actions/ChatMessage/index.js +3 -0
- package/backend/actions/ChatThread/createChatMessage.js +253 -0
- package/backend/actions/ChatThread/createChatThread.js +19 -0
- package/backend/actions/ChatThread/getChatThread.js +36 -0
- package/backend/actions/ChatThread/index.js +6 -0
- package/backend/actions/ChatThread/listChatThreads.js +24 -0
- package/backend/actions/index.js +2 -0
- package/backend/db/chatMessageSchema.js +30 -0
- package/backend/db/chatThreadSchema.js +15 -0
- package/backend/index.js +6 -2
- package/express.js +1 -0
- package/frontend/public/app.js +2905 -196
- package/frontend/public/tw.css +146 -0
- package/frontend/src/api.js +38 -3
- package/frontend/src/async-button/async-button.html +12 -2
- package/frontend/src/chat/chat-message/chat-message.html +16 -0
- package/frontend/src/chat/chat-message/chat-message.js +66 -0
- package/frontend/src/chat/chat-message-script/chat-message-script.html +52 -0
- package/frontend/src/chat/chat-message-script/chat-message-script.js +35 -0
- package/frontend/src/chat/chat.html +69 -0
- package/frontend/src/chat/chat.js +89 -0
- package/frontend/src/index.js +22 -37
- package/frontend/src/modal/modal.html +2 -2
- package/frontend/src/modal/modal.js +3 -2
- package/frontend/src/navbar/navbar.html +4 -0
- package/frontend/src/navbar/navbar.js +3 -0
- package/frontend/src/routes.js +19 -3
- package/package.json +2 -1
package/frontend/public/app.js
CHANGED
|
@@ -56,6 +56,25 @@ if (window.MONGOOSE_STUDIO_CONFIG.isLambda) {
|
|
|
56
56
|
return client.post('', { action: 'Dashboard.updateDashboard', ...params}).then(res => res.data);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
exports.ChatThread = {
|
|
60
|
+
createChatMessage(params) {
|
|
61
|
+
return client.post('', { action: 'ChatThread.createChatMessage', ...params }).then(res => res.data);
|
|
62
|
+
},
|
|
63
|
+
createChatThread(params) {
|
|
64
|
+
return client.post('', { action: 'ChatThread.createChatThread', ...params }).then(res => res.data);
|
|
65
|
+
},
|
|
66
|
+
getChatThread(params) {
|
|
67
|
+
return client.post('', { action: 'ChatThread.getChatThread', ...params }).then(res => res.data);
|
|
68
|
+
},
|
|
69
|
+
listChatThreads(params) {
|
|
70
|
+
return client.post('', { action: 'ChatThread.listChatThreads', ...params }).then(res => res.data);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ChatMessage = {
|
|
74
|
+
executeScript(params) {
|
|
75
|
+
return client.post('', { action: 'ChatMessage.executeScript', ...params }).then(res => res.data);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
59
78
|
exports.Model = {
|
|
60
79
|
createChart(params) {
|
|
61
80
|
return client.post('', { action: 'Model.createChart', ...params}).then(res => res.data);
|
|
@@ -127,6 +146,25 @@ if (window.MONGOOSE_STUDIO_CONFIG.isLambda) {
|
|
|
127
146
|
return client.post('/Dashboard/updateDashboard', params).then(res => res.data);
|
|
128
147
|
}
|
|
129
148
|
}
|
|
149
|
+
exports.ChatThread = {
|
|
150
|
+
createChatMessage: function createChatMessage(params) {
|
|
151
|
+
return client.post('/ChatThread/createChatMessage', params).then(res => res.data);
|
|
152
|
+
},
|
|
153
|
+
createChatThread: function createChatThread(params) {
|
|
154
|
+
return client.post('/ChatThread/createChatThread', params).then(res => res.data);
|
|
155
|
+
},
|
|
156
|
+
getChatThread: function getChatThread(params) {
|
|
157
|
+
return client.post('/ChatThread/getChatThread', params).then(res => res.data);
|
|
158
|
+
},
|
|
159
|
+
listChatThreads: function listChatThreads(params) {
|
|
160
|
+
return client.post('/ChatThread/listChatThreads', params).then(res => res.data);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
exports.ChatMessage = {
|
|
164
|
+
executeScript: function executeScript(params) {
|
|
165
|
+
return client.post('/ChatMessage/executeScript', params).then(res => res.data);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
130
168
|
exports.Model = {
|
|
131
169
|
createChart: function (params) {
|
|
132
170
|
return client.post('/Model/createChart', params).then(res => res.data);
|
|
@@ -180,9 +218,6 @@ if (window.MONGOOSE_STUDIO_CONFIG.isLambda) {
|
|
|
180
218
|
return client.post('/Model/updateDocument', params).then(res => res.data);
|
|
181
219
|
}
|
|
182
220
|
};
|
|
183
|
-
exports.Script = {
|
|
184
|
-
|
|
185
|
-
};
|
|
186
221
|
}
|
|
187
222
|
|
|
188
223
|
|
|
@@ -256,6 +291,229 @@ module.exports = app => app.component('async-button', {
|
|
|
256
291
|
template: template
|
|
257
292
|
});
|
|
258
293
|
|
|
294
|
+
/***/ }),
|
|
295
|
+
|
|
296
|
+
/***/ "./frontend/src/chat/chat-message-script/chat-message-script.js":
|
|
297
|
+
/*!**********************************************************************!*\
|
|
298
|
+
!*** ./frontend/src/chat/chat-message-script/chat-message-script.js ***!
|
|
299
|
+
\**********************************************************************/
|
|
300
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
301
|
+
|
|
302
|
+
"use strict";
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
const api = __webpack_require__(/*! ../../api */ "./frontend/src/api.js");
|
|
306
|
+
const marked = (__webpack_require__(/*! marked */ "./node_modules/marked/lib/marked.cjs").marked);
|
|
307
|
+
const template = __webpack_require__(/*! ./chat-message-script.html */ "./frontend/src/chat/chat-message-script/chat-message-script.html");
|
|
308
|
+
|
|
309
|
+
module.exports = app => app.component('chat-message-script', {
|
|
310
|
+
template: template,
|
|
311
|
+
props: ['message', 'script', 'language'],
|
|
312
|
+
data: () => ({ activeTab: 'code', showDetailModal: false }),
|
|
313
|
+
computed: {
|
|
314
|
+
styleForMessage() {
|
|
315
|
+
return this.message.role === 'user' ? 'bg-gray-100' : '';
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
methods: {
|
|
319
|
+
async executeScript(message, script) {
|
|
320
|
+
const { chatMessage } = await api.ChatMessage.executeScript({
|
|
321
|
+
chatMessageId: message._id,
|
|
322
|
+
script
|
|
323
|
+
});
|
|
324
|
+
message.executionResult = chatMessage.executionResult;
|
|
325
|
+
this.activeTab = 'output';
|
|
326
|
+
},
|
|
327
|
+
openDetailModal() {
|
|
328
|
+
this.showDetailModal = true;
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
mounted() {
|
|
332
|
+
Prism.highlightElement(this.$refs.code);
|
|
333
|
+
if (this.message.executionResult?.output) {
|
|
334
|
+
this.activeTab = 'output';
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
/***/ }),
|
|
341
|
+
|
|
342
|
+
/***/ "./frontend/src/chat/chat-message/chat-message.js":
|
|
343
|
+
/*!********************************************************!*\
|
|
344
|
+
!*** ./frontend/src/chat/chat-message/chat-message.js ***!
|
|
345
|
+
\********************************************************/
|
|
346
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
347
|
+
|
|
348
|
+
"use strict";
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
const api = __webpack_require__(/*! ../../api */ "./frontend/src/api.js");
|
|
352
|
+
const marked = (__webpack_require__(/*! marked */ "./node_modules/marked/lib/marked.cjs").marked);
|
|
353
|
+
const template = __webpack_require__(/*! ./chat-message.html */ "./frontend/src/chat/chat-message/chat-message.html");
|
|
354
|
+
|
|
355
|
+
module.exports = app => app.component('chat-message', {
|
|
356
|
+
template: template,
|
|
357
|
+
props: ['message'],
|
|
358
|
+
computed: {
|
|
359
|
+
styleForMessage() {
|
|
360
|
+
return this.message.role === 'user' ? 'bg-gray-100' : '';
|
|
361
|
+
},
|
|
362
|
+
contentSplitByScripts() {
|
|
363
|
+
const content = this.message.content;
|
|
364
|
+
const parts = [];
|
|
365
|
+
let currentIndex = 0;
|
|
366
|
+
let codeBlockMatch;
|
|
367
|
+
|
|
368
|
+
// Regular expression to match markdown code blocks
|
|
369
|
+
const codeBlockRegex = /```(\w*)\n([\s\S]*?)\n```/g;
|
|
370
|
+
|
|
371
|
+
while ((codeBlockMatch = codeBlockRegex.exec(content)) !== null) {
|
|
372
|
+
// Add text before the code block
|
|
373
|
+
if (codeBlockMatch.index > currentIndex) {
|
|
374
|
+
parts.push({
|
|
375
|
+
type: 'text',
|
|
376
|
+
content: content.substring(currentIndex, codeBlockMatch.index)
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Add the code block
|
|
381
|
+
parts.push({
|
|
382
|
+
type: 'code',
|
|
383
|
+
language: codeBlockMatch[1] || '',
|
|
384
|
+
content: codeBlockMatch[2]
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
currentIndex = codeBlockMatch.index + codeBlockMatch[0].length;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Add any remaining text after the last code block
|
|
391
|
+
if (currentIndex < content.length) {
|
|
392
|
+
parts.push({
|
|
393
|
+
type: 'text',
|
|
394
|
+
content: content.substring(currentIndex)
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return parts;
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
methods: {
|
|
402
|
+
marked(text) {
|
|
403
|
+
return marked(text);
|
|
404
|
+
},
|
|
405
|
+
async executeScript(message, script) {
|
|
406
|
+
const { chatMessage } = await api.ChatMessage.executeScript({
|
|
407
|
+
chatMessageId: message._id,
|
|
408
|
+
script
|
|
409
|
+
});
|
|
410
|
+
message.executionResult = chatMessage.executionResult;
|
|
411
|
+
console.log(message);
|
|
412
|
+
},
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
/***/ }),
|
|
418
|
+
|
|
419
|
+
/***/ "./frontend/src/chat/chat.js":
|
|
420
|
+
/*!***********************************!*\
|
|
421
|
+
!*** ./frontend/src/chat/chat.js ***!
|
|
422
|
+
\***********************************/
|
|
423
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
424
|
+
|
|
425
|
+
"use strict";
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
const api = __webpack_require__(/*! ../api */ "./frontend/src/api.js");
|
|
429
|
+
const template = __webpack_require__(/*! ./chat.html */ "./frontend/src/chat/chat.html");
|
|
430
|
+
|
|
431
|
+
module.exports = app => app.component('chat', {
|
|
432
|
+
template: template,
|
|
433
|
+
props: ['threadId'],
|
|
434
|
+
data: () => ({
|
|
435
|
+
status: 'loading',
|
|
436
|
+
sendingMessage: false,
|
|
437
|
+
newMessage: '',
|
|
438
|
+
chatThreadId: null,
|
|
439
|
+
chatThreads: [],
|
|
440
|
+
chatMessages: []
|
|
441
|
+
}),
|
|
442
|
+
methods: {
|
|
443
|
+
async sendMessage() {
|
|
444
|
+
this.sendingMessage = true;
|
|
445
|
+
try {
|
|
446
|
+
if (!this.chatThreadId) {
|
|
447
|
+
const { chatThread } = await api.ChatThread.createChatThread();
|
|
448
|
+
this.chatThreads.unshift(chatThread);
|
|
449
|
+
this.chatThreadId = chatThread._id;
|
|
450
|
+
this.chatMessages = [];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
this.chatMessages.push({
|
|
454
|
+
content: this.newMessage,
|
|
455
|
+
role: 'user'
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
this.$nextTick(() => {
|
|
459
|
+
if (this.$refs.messagesContainer) {
|
|
460
|
+
this.$refs.messagesContainer.scrollTop = this.$refs.messagesContainer.scrollHeight;
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
const { chatMessages } = await api.ChatThread.createChatMessage({
|
|
465
|
+
chatThreadId: this.chatThreadId,
|
|
466
|
+
content: this.newMessage
|
|
467
|
+
});
|
|
468
|
+
this.chatMessages.push(chatMessages[1]);
|
|
469
|
+
|
|
470
|
+
this.newMessage = '';
|
|
471
|
+
|
|
472
|
+
this.$nextTick(() => {
|
|
473
|
+
if (this.$refs.messagesContainer) {
|
|
474
|
+
this.$refs.messagesContainer.scrollTop = this.$refs.messagesContainer.scrollHeight;
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
} finally {
|
|
478
|
+
this.sendingMessage = false;
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
selectThread(threadId) {
|
|
482
|
+
this.$router.push('/chat/' + threadId);
|
|
483
|
+
},
|
|
484
|
+
styleForMessage(message) {
|
|
485
|
+
return message.role === 'user' ? 'bg-gray-100' : '';
|
|
486
|
+
},
|
|
487
|
+
async createNewThread() {
|
|
488
|
+
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
async mounted() {
|
|
492
|
+
this.chatThreadId = this.threadId;
|
|
493
|
+
const { chatThreads } = await api.ChatThread.listChatThreads();
|
|
494
|
+
this.chatThreads = chatThreads;
|
|
495
|
+
if (this.chatThreadId) {
|
|
496
|
+
const { chatMessages } = await api.ChatThread.getChatThread({ chatThreadId: this.chatThreadId });
|
|
497
|
+
this.chatMessages = chatMessages;
|
|
498
|
+
}
|
|
499
|
+
this.status = 'loaded';
|
|
500
|
+
|
|
501
|
+
if (this.chatThreadId) {
|
|
502
|
+
// Scroll to bottom of messages container after messages are loaded
|
|
503
|
+
this.$nextTick(() => {
|
|
504
|
+
if (this.$refs.messagesContainer) {
|
|
505
|
+
this.$refs.messagesContainer.scrollTop = this.$refs.messagesContainer.scrollHeight;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
this.$refs.messagesContainer.querySelectorAll('code').forEach(el => {
|
|
509
|
+
Prism.highlightElement(el);
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
|
|
259
517
|
/***/ }),
|
|
260
518
|
|
|
261
519
|
/***/ "./frontend/src/clone-document/clone-document.js":
|
|
@@ -1058,7 +1316,7 @@ appendCSS(__webpack_require__(/*! ./document.css */ "./frontend/src/document/doc
|
|
|
1058
1316
|
|
|
1059
1317
|
module.exports = app => app.component('document', {
|
|
1060
1318
|
template: template,
|
|
1061
|
-
props: ['model', 'documentId', 'user', 'roles'],
|
|
1319
|
+
props: ['model', 'documentId', 'user', 'roles', 'hasAPIKey'],
|
|
1062
1320
|
data: () => ({
|
|
1063
1321
|
schemaPaths: [],
|
|
1064
1322
|
status: 'init',
|
|
@@ -1089,6 +1347,9 @@ module.exports = app => app.component('document', {
|
|
|
1089
1347
|
},
|
|
1090
1348
|
computed: {
|
|
1091
1349
|
canManipulate() {
|
|
1350
|
+
if (!this.hasAPIKey) {
|
|
1351
|
+
return true;
|
|
1352
|
+
}
|
|
1092
1353
|
if (!this.roles) {
|
|
1093
1354
|
return false;
|
|
1094
1355
|
}
|
|
@@ -1440,6 +1701,151 @@ module.exports = app => app.component('export-query-results', {
|
|
|
1440
1701
|
}
|
|
1441
1702
|
});
|
|
1442
1703
|
|
|
1704
|
+
/***/ }),
|
|
1705
|
+
|
|
1706
|
+
/***/ "./frontend/src/index.js":
|
|
1707
|
+
/*!*******************************!*\
|
|
1708
|
+
!*** ./frontend/src/index.js ***!
|
|
1709
|
+
\*******************************/
|
|
1710
|
+
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
|
1711
|
+
|
|
1712
|
+
"use strict";
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
if (typeof process === 'undefined') {
|
|
1716
|
+
__webpack_require__.g.process = { env: {} }; // To make `util` package work
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
const api = __webpack_require__(/*! ./api */ "./frontend/src/api.js");
|
|
1720
|
+
const mothership = __webpack_require__(/*! ./mothership */ "./frontend/src/mothership.js");
|
|
1721
|
+
const vanillatoasts = __webpack_require__(/*! vanillatoasts */ "./node_modules/vanillatoasts/vanillatoasts.js");
|
|
1722
|
+
|
|
1723
|
+
const app = Vue.createApp({
|
|
1724
|
+
template: '<app-component />'
|
|
1725
|
+
});
|
|
1726
|
+
|
|
1727
|
+
// Import all components
|
|
1728
|
+
const requireComponents = __webpack_require__("./frontend/src sync recursive ^\\.\\/.*$");
|
|
1729
|
+
// Object to store the imported modules
|
|
1730
|
+
const components = {};
|
|
1731
|
+
// Iterate over the matched keys (file paths)
|
|
1732
|
+
requireComponents.keys().forEach((filePath) => {
|
|
1733
|
+
// Extract directory name and file name from the path
|
|
1734
|
+
const pieces = filePath.split('/');
|
|
1735
|
+
const directoryName = pieces[pieces.length - 2];
|
|
1736
|
+
const fileName = pieces[pieces.length - 1].replace('.js', '');
|
|
1737
|
+
|
|
1738
|
+
// Check if the file name matches the directory name
|
|
1739
|
+
if (directoryName === fileName) {
|
|
1740
|
+
components[directoryName] = requireComponents(filePath);
|
|
1741
|
+
components[directoryName](app);
|
|
1742
|
+
}
|
|
1743
|
+
});
|
|
1744
|
+
|
|
1745
|
+
console.log('Loaded components', Object.keys(components).sort());
|
|
1746
|
+
|
|
1747
|
+
app.component('app-component', {
|
|
1748
|
+
template: `
|
|
1749
|
+
<div>
|
|
1750
|
+
<div v-if="hasAPIKey && (user == null || status === 'init')">
|
|
1751
|
+
<splash :loading="status === 'init'" />
|
|
1752
|
+
</div>
|
|
1753
|
+
<div v-else-if="!hasAPIKey || user">
|
|
1754
|
+
<navbar :user="user" :roles="roles" />
|
|
1755
|
+
<div class="view">
|
|
1756
|
+
<router-view :key="$route.fullPath" :user="user" :roles="roles" :hasAPIKey="hasAPIKey" />
|
|
1757
|
+
</div>
|
|
1758
|
+
</div>
|
|
1759
|
+
</div>
|
|
1760
|
+
`,
|
|
1761
|
+
errorCaptured(err) {
|
|
1762
|
+
vanillatoasts.create({
|
|
1763
|
+
title: `Error: ${err?.response?.data?.message || err.message}`,
|
|
1764
|
+
icon: 'images/failure.jpg',
|
|
1765
|
+
timeout: 10000,
|
|
1766
|
+
positionClass: 'bottomRight'
|
|
1767
|
+
});
|
|
1768
|
+
},
|
|
1769
|
+
computed: {
|
|
1770
|
+
hasAPIKey() {
|
|
1771
|
+
return mothership.hasAPIKey;
|
|
1772
|
+
}
|
|
1773
|
+
},
|
|
1774
|
+
async mounted() {
|
|
1775
|
+
window.$router = this.$router;
|
|
1776
|
+
window.state = this;
|
|
1777
|
+
|
|
1778
|
+
if (mothership.hasAPIKey) {
|
|
1779
|
+
const href = window.location.href;
|
|
1780
|
+
if (href.match(/\?code=([a-zA-Z0-9]+)$/)) {
|
|
1781
|
+
const code = href.match(/\?code=([a-zA-Z0-9]+)$/)[1];
|
|
1782
|
+
try {
|
|
1783
|
+
const { accessToken, user, roles } = await mothership.github(code);
|
|
1784
|
+
if (roles == null) {
|
|
1785
|
+
this.authError = 'You are not authorized to access this workspace';
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
this.user = user;
|
|
1789
|
+
this.roles = roles;
|
|
1790
|
+
window.localStorage.setItem('_mongooseStudioAccessToken', accessToken._id);
|
|
1791
|
+
} catch (err) {
|
|
1792
|
+
this.authError = 'An error occurred while logging in. Please try again.';
|
|
1793
|
+
this.status = 'loaded';
|
|
1794
|
+
return;
|
|
1795
|
+
} finally {
|
|
1796
|
+
setTimeout(() => {
|
|
1797
|
+
this.$router.replace(this.$router.currentRoute.value.path);
|
|
1798
|
+
}, 0);
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
const { nodeEnv } = await api.status();
|
|
1802
|
+
this.nodeEnv = nodeEnv;
|
|
1803
|
+
} else {
|
|
1804
|
+
const token = window.localStorage.getItem('_mongooseStudioAccessToken');
|
|
1805
|
+
if (token) {
|
|
1806
|
+
const { user, roles } = await mothership.me();
|
|
1807
|
+
this.user = user;
|
|
1808
|
+
this.roles = roles;
|
|
1809
|
+
|
|
1810
|
+
const { nodeEnv } = await api.status();
|
|
1811
|
+
this.nodeEnv = nodeEnv;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
} else {
|
|
1815
|
+
const { nodeEnv } = await api.status();
|
|
1816
|
+
this.nodeEnv = nodeEnv;
|
|
1817
|
+
}
|
|
1818
|
+
this.status = 'loaded';
|
|
1819
|
+
},
|
|
1820
|
+
setup() {
|
|
1821
|
+
const user = Vue.ref(null);
|
|
1822
|
+
const roles = Vue.ref(null);
|
|
1823
|
+
const status = Vue.ref('init');
|
|
1824
|
+
const nodeEnv = Vue.ref(null);
|
|
1825
|
+
const authError = Vue.ref(null);
|
|
1826
|
+
|
|
1827
|
+
const state = Vue.reactive({ user, roles, status, nodeEnv, authError });
|
|
1828
|
+
Vue.provide('state', state);
|
|
1829
|
+
|
|
1830
|
+
return state;
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
|
|
1834
|
+
const { routes } = __webpack_require__(/*! ./routes */ "./frontend/src/routes.js");
|
|
1835
|
+
const router = VueRouter.createRouter({
|
|
1836
|
+
history: VueRouter.createWebHashHistory(),
|
|
1837
|
+
routes: routes.map(route => ({
|
|
1838
|
+
...route,
|
|
1839
|
+
component: app.component(route.component),
|
|
1840
|
+
props: (route) => route.params
|
|
1841
|
+
}))
|
|
1842
|
+
});
|
|
1843
|
+
|
|
1844
|
+
app.use(router);
|
|
1845
|
+
|
|
1846
|
+
app.mount('#content');
|
|
1847
|
+
|
|
1848
|
+
|
|
1443
1849
|
/***/ }),
|
|
1444
1850
|
|
|
1445
1851
|
/***/ "./frontend/src/list-array/list-array.js":
|
|
@@ -1752,9 +2158,11 @@ const template = __webpack_require__(/*! ./modal.html */ "./frontend/src/modal/m
|
|
|
1752
2158
|
appendCSS(__webpack_require__(/*! ./modal.css */ "./frontend/src/modal/modal.css"));
|
|
1753
2159
|
|
|
1754
2160
|
module.exports = app => app.component('modal', {
|
|
1755
|
-
template
|
|
2161
|
+
template,
|
|
2162
|
+
props: ['containerClass']
|
|
1756
2163
|
});
|
|
1757
2164
|
|
|
2165
|
+
|
|
1758
2166
|
/***/ }),
|
|
1759
2167
|
|
|
1760
2168
|
/***/ "./frontend/src/models/models.js":
|
|
@@ -2191,6 +2599,9 @@ module.exports = app => app.component('navbar', {
|
|
|
2191
2599
|
documentView() {
|
|
2192
2600
|
return ['root', 'model', 'document'].includes(this.$route.name);
|
|
2193
2601
|
},
|
|
2602
|
+
chatView() {
|
|
2603
|
+
return ['chat index', 'chat'].includes(this.$route.name);
|
|
2604
|
+
},
|
|
2194
2605
|
routeName() {
|
|
2195
2606
|
return this.$route.name;
|
|
2196
2607
|
},
|
|
@@ -2261,9 +2672,9 @@ module.exports = app => app.component('navbar', {
|
|
|
2261
2672
|
|
|
2262
2673
|
// Role-based access control configuration
|
|
2263
2674
|
const roleAccess = {
|
|
2264
|
-
owner: ['root', 'model', 'document', 'dashboards', 'dashboard', 'team'],
|
|
2265
|
-
admin: ['root', 'model', 'document', 'dashboards', 'dashboard', 'team'],
|
|
2266
|
-
member: ['root', 'model', 'document', 'dashboards', 'dashboard'],
|
|
2675
|
+
owner: ['root', 'model', 'document', 'dashboards', 'dashboard', 'team', 'chat'],
|
|
2676
|
+
admin: ['root', 'model', 'document', 'dashboards', 'dashboard', 'team', 'chat'],
|
|
2677
|
+
member: ['root', 'model', 'document', 'dashboards', 'dashboard', 'chat'],
|
|
2267
2678
|
readonly: ['root', 'model', 'document'],
|
|
2268
2679
|
dashboards: ['dashboards', 'dashboard']
|
|
2269
2680
|
};
|
|
@@ -2324,9 +2735,25 @@ module.exports = {
|
|
|
2324
2735
|
meta: {
|
|
2325
2736
|
authorized: true
|
|
2326
2737
|
}
|
|
2327
|
-
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2738
|
+
},
|
|
2739
|
+
{
|
|
2740
|
+
path: '/chat',
|
|
2741
|
+
name: 'chat index',
|
|
2742
|
+
component: 'chat',
|
|
2743
|
+
meta: {
|
|
2744
|
+
authorized: true
|
|
2745
|
+
}
|
|
2746
|
+
},
|
|
2747
|
+
{
|
|
2748
|
+
path: '/chat/:threadId',
|
|
2749
|
+
name: 'chat',
|
|
2750
|
+
component: 'chat',
|
|
2751
|
+
meta: {
|
|
2752
|
+
authorized: true
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
],
|
|
2756
|
+
roleAccess,
|
|
2330
2757
|
hasAccess
|
|
2331
2758
|
};
|
|
2332
2759
|
|
|
@@ -2453,6 +2880,184 @@ module.exports = app => app.component('team', {
|
|
|
2453
2880
|
});
|
|
2454
2881
|
|
|
2455
2882
|
|
|
2883
|
+
/***/ }),
|
|
2884
|
+
|
|
2885
|
+
/***/ "./frontend/src sync recursive ^\\.\\/.*$":
|
|
2886
|
+
/*!*************************************!*\
|
|
2887
|
+
!*** ./frontend/src/ sync ^\.\/.*$ ***!
|
|
2888
|
+
\*************************************/
|
|
2889
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
2890
|
+
|
|
2891
|
+
var map = {
|
|
2892
|
+
"./": "./frontend/src/index.js",
|
|
2893
|
+
"./api": "./frontend/src/api.js",
|
|
2894
|
+
"./api.js": "./frontend/src/api.js",
|
|
2895
|
+
"./appendCSS": "./frontend/src/appendCSS.js",
|
|
2896
|
+
"./appendCSS.js": "./frontend/src/appendCSS.js",
|
|
2897
|
+
"./async-button/async-button": "./frontend/src/async-button/async-button.js",
|
|
2898
|
+
"./async-button/async-button.html": "./frontend/src/async-button/async-button.html",
|
|
2899
|
+
"./async-button/async-button.js": "./frontend/src/async-button/async-button.js",
|
|
2900
|
+
"./chat/chat": "./frontend/src/chat/chat.js",
|
|
2901
|
+
"./chat/chat-message-script/chat-message-script": "./frontend/src/chat/chat-message-script/chat-message-script.js",
|
|
2902
|
+
"./chat/chat-message-script/chat-message-script.html": "./frontend/src/chat/chat-message-script/chat-message-script.html",
|
|
2903
|
+
"./chat/chat-message-script/chat-message-script.js": "./frontend/src/chat/chat-message-script/chat-message-script.js",
|
|
2904
|
+
"./chat/chat-message/chat-message": "./frontend/src/chat/chat-message/chat-message.js",
|
|
2905
|
+
"./chat/chat-message/chat-message.html": "./frontend/src/chat/chat-message/chat-message.html",
|
|
2906
|
+
"./chat/chat-message/chat-message.js": "./frontend/src/chat/chat-message/chat-message.js",
|
|
2907
|
+
"./chat/chat.html": "./frontend/src/chat/chat.html",
|
|
2908
|
+
"./chat/chat.js": "./frontend/src/chat/chat.js",
|
|
2909
|
+
"./clone-document/clone-document": "./frontend/src/clone-document/clone-document.js",
|
|
2910
|
+
"./clone-document/clone-document.css": "./frontend/src/clone-document/clone-document.css",
|
|
2911
|
+
"./clone-document/clone-document.html": "./frontend/src/clone-document/clone-document.html",
|
|
2912
|
+
"./clone-document/clone-document.js": "./frontend/src/clone-document/clone-document.js",
|
|
2913
|
+
"./create-dashboard/create-dashboard": "./frontend/src/create-dashboard/create-dashboard.js",
|
|
2914
|
+
"./create-dashboard/create-dashboard.html": "./frontend/src/create-dashboard/create-dashboard.html",
|
|
2915
|
+
"./create-dashboard/create-dashboard.js": "./frontend/src/create-dashboard/create-dashboard.js",
|
|
2916
|
+
"./create-document/create-document": "./frontend/src/create-document/create-document.js",
|
|
2917
|
+
"./create-document/create-document.css": "./frontend/src/create-document/create-document.css",
|
|
2918
|
+
"./create-document/create-document.html": "./frontend/src/create-document/create-document.html",
|
|
2919
|
+
"./create-document/create-document.js": "./frontend/src/create-document/create-document.js",
|
|
2920
|
+
"./dashboard-result/dashboard-chart/dashboard-chart": "./frontend/src/dashboard-result/dashboard-chart/dashboard-chart.js",
|
|
2921
|
+
"./dashboard-result/dashboard-chart/dashboard-chart.html": "./frontend/src/dashboard-result/dashboard-chart/dashboard-chart.html",
|
|
2922
|
+
"./dashboard-result/dashboard-chart/dashboard-chart.js": "./frontend/src/dashboard-result/dashboard-chart/dashboard-chart.js",
|
|
2923
|
+
"./dashboard-result/dashboard-document/dashboard-document": "./frontend/src/dashboard-result/dashboard-document/dashboard-document.js",
|
|
2924
|
+
"./dashboard-result/dashboard-document/dashboard-document.html": "./frontend/src/dashboard-result/dashboard-document/dashboard-document.html",
|
|
2925
|
+
"./dashboard-result/dashboard-document/dashboard-document.js": "./frontend/src/dashboard-result/dashboard-document/dashboard-document.js",
|
|
2926
|
+
"./dashboard-result/dashboard-primitive/dashboard-primitive": "./frontend/src/dashboard-result/dashboard-primitive/dashboard-primitive.js",
|
|
2927
|
+
"./dashboard-result/dashboard-primitive/dashboard-primitive.html": "./frontend/src/dashboard-result/dashboard-primitive/dashboard-primitive.html",
|
|
2928
|
+
"./dashboard-result/dashboard-primitive/dashboard-primitive.js": "./frontend/src/dashboard-result/dashboard-primitive/dashboard-primitive.js",
|
|
2929
|
+
"./dashboard-result/dashboard-result": "./frontend/src/dashboard-result/dashboard-result.js",
|
|
2930
|
+
"./dashboard-result/dashboard-result.html": "./frontend/src/dashboard-result/dashboard-result.html",
|
|
2931
|
+
"./dashboard-result/dashboard-result.js": "./frontend/src/dashboard-result/dashboard-result.js",
|
|
2932
|
+
"./dashboard-result/dashboard-text/dashboard-text": "./frontend/src/dashboard-result/dashboard-text/dashboard-text.js",
|
|
2933
|
+
"./dashboard-result/dashboard-text/dashboard-text.html": "./frontend/src/dashboard-result/dashboard-text/dashboard-text.html",
|
|
2934
|
+
"./dashboard-result/dashboard-text/dashboard-text.js": "./frontend/src/dashboard-result/dashboard-text/dashboard-text.js",
|
|
2935
|
+
"./dashboard/dashboard": "./frontend/src/dashboard/dashboard.js",
|
|
2936
|
+
"./dashboard/dashboard.html": "./frontend/src/dashboard/dashboard.html",
|
|
2937
|
+
"./dashboard/dashboard.js": "./frontend/src/dashboard/dashboard.js",
|
|
2938
|
+
"./dashboard/edit-dashboard/edit-dashboard": "./frontend/src/dashboard/edit-dashboard/edit-dashboard.js",
|
|
2939
|
+
"./dashboard/edit-dashboard/edit-dashboard.html": "./frontend/src/dashboard/edit-dashboard/edit-dashboard.html",
|
|
2940
|
+
"./dashboard/edit-dashboard/edit-dashboard.js": "./frontend/src/dashboard/edit-dashboard/edit-dashboard.js",
|
|
2941
|
+
"./dashboards/dashboards": "./frontend/src/dashboards/dashboards.js",
|
|
2942
|
+
"./dashboards/dashboards.html": "./frontend/src/dashboards/dashboards.html",
|
|
2943
|
+
"./dashboards/dashboards.js": "./frontend/src/dashboards/dashboards.js",
|
|
2944
|
+
"./detail-array/detail-array": "./frontend/src/detail-array/detail-array.js",
|
|
2945
|
+
"./detail-array/detail-array.html": "./frontend/src/detail-array/detail-array.html",
|
|
2946
|
+
"./detail-array/detail-array.js": "./frontend/src/detail-array/detail-array.js",
|
|
2947
|
+
"./detail-default/detail-default": "./frontend/src/detail-default/detail-default.js",
|
|
2948
|
+
"./detail-default/detail-default.html": "./frontend/src/detail-default/detail-default.html",
|
|
2949
|
+
"./detail-default/detail-default.js": "./frontend/src/detail-default/detail-default.js",
|
|
2950
|
+
"./document-details/document-details": "./frontend/src/document-details/document-details.js",
|
|
2951
|
+
"./document-details/document-details.css": "./frontend/src/document-details/document-details.css",
|
|
2952
|
+
"./document-details/document-details.html": "./frontend/src/document-details/document-details.html",
|
|
2953
|
+
"./document-details/document-details.js": "./frontend/src/document-details/document-details.js",
|
|
2954
|
+
"./document-details/document-property/document-property": "./frontend/src/document-details/document-property/document-property.js",
|
|
2955
|
+
"./document-details/document-property/document-property.css": "./frontend/src/document-details/document-property/document-property.css",
|
|
2956
|
+
"./document-details/document-property/document-property.html": "./frontend/src/document-details/document-property/document-property.html",
|
|
2957
|
+
"./document-details/document-property/document-property.js": "./frontend/src/document-details/document-property/document-property.js",
|
|
2958
|
+
"./document/confirm-changes/confirm-changes": "./frontend/src/document/confirm-changes/confirm-changes.js",
|
|
2959
|
+
"./document/confirm-changes/confirm-changes.html": "./frontend/src/document/confirm-changes/confirm-changes.html",
|
|
2960
|
+
"./document/confirm-changes/confirm-changes.js": "./frontend/src/document/confirm-changes/confirm-changes.js",
|
|
2961
|
+
"./document/confirm-delete/confirm-delete": "./frontend/src/document/confirm-delete/confirm-delete.js",
|
|
2962
|
+
"./document/confirm-delete/confirm-delete.html": "./frontend/src/document/confirm-delete/confirm-delete.html",
|
|
2963
|
+
"./document/confirm-delete/confirm-delete.js": "./frontend/src/document/confirm-delete/confirm-delete.js",
|
|
2964
|
+
"./document/document": "./frontend/src/document/document.js",
|
|
2965
|
+
"./document/document.css": "./frontend/src/document/document.css",
|
|
2966
|
+
"./document/document.html": "./frontend/src/document/document.html",
|
|
2967
|
+
"./document/document.js": "./frontend/src/document/document.js",
|
|
2968
|
+
"./edit-array/edit-array": "./frontend/src/edit-array/edit-array.js",
|
|
2969
|
+
"./edit-array/edit-array.css": "./frontend/src/edit-array/edit-array.css",
|
|
2970
|
+
"./edit-array/edit-array.html": "./frontend/src/edit-array/edit-array.html",
|
|
2971
|
+
"./edit-array/edit-array.js": "./frontend/src/edit-array/edit-array.js",
|
|
2972
|
+
"./edit-date/edit-date": "./frontend/src/edit-date/edit-date.js",
|
|
2973
|
+
"./edit-date/edit-date.html": "./frontend/src/edit-date/edit-date.html",
|
|
2974
|
+
"./edit-date/edit-date.js": "./frontend/src/edit-date/edit-date.js",
|
|
2975
|
+
"./edit-default/edit-default": "./frontend/src/edit-default/edit-default.js",
|
|
2976
|
+
"./edit-default/edit-default.html": "./frontend/src/edit-default/edit-default.html",
|
|
2977
|
+
"./edit-default/edit-default.js": "./frontend/src/edit-default/edit-default.js",
|
|
2978
|
+
"./edit-number/edit-number": "./frontend/src/edit-number/edit-number.js",
|
|
2979
|
+
"./edit-number/edit-number.html": "./frontend/src/edit-number/edit-number.html",
|
|
2980
|
+
"./edit-number/edit-number.js": "./frontend/src/edit-number/edit-number.js",
|
|
2981
|
+
"./edit-subdocument/edit-subdocument": "./frontend/src/edit-subdocument/edit-subdocument.js",
|
|
2982
|
+
"./edit-subdocument/edit-subdocument.html": "./frontend/src/edit-subdocument/edit-subdocument.html",
|
|
2983
|
+
"./edit-subdocument/edit-subdocument.js": "./frontend/src/edit-subdocument/edit-subdocument.js",
|
|
2984
|
+
"./export-query-results/export-query-results": "./frontend/src/export-query-results/export-query-results.js",
|
|
2985
|
+
"./export-query-results/export-query-results.css": "./frontend/src/export-query-results/export-query-results.css",
|
|
2986
|
+
"./export-query-results/export-query-results.html": "./frontend/src/export-query-results/export-query-results.html",
|
|
2987
|
+
"./export-query-results/export-query-results.js": "./frontend/src/export-query-results/export-query-results.js",
|
|
2988
|
+
"./index": "./frontend/src/index.js",
|
|
2989
|
+
"./index.js": "./frontend/src/index.js",
|
|
2990
|
+
"./list-array/list-array": "./frontend/src/list-array/list-array.js",
|
|
2991
|
+
"./list-array/list-array.css": "./frontend/src/list-array/list-array.css",
|
|
2992
|
+
"./list-array/list-array.html": "./frontend/src/list-array/list-array.html",
|
|
2993
|
+
"./list-array/list-array.js": "./frontend/src/list-array/list-array.js",
|
|
2994
|
+
"./list-default/list-default": "./frontend/src/list-default/list-default.js",
|
|
2995
|
+
"./list-default/list-default.css": "./frontend/src/list-default/list-default.css",
|
|
2996
|
+
"./list-default/list-default.html": "./frontend/src/list-default/list-default.html",
|
|
2997
|
+
"./list-default/list-default.js": "./frontend/src/list-default/list-default.js",
|
|
2998
|
+
"./list-json/list-json": "./frontend/src/list-json/list-json.js",
|
|
2999
|
+
"./list-json/list-json.css": "./frontend/src/list-json/list-json.css",
|
|
3000
|
+
"./list-json/list-json.html": "./frontend/src/list-json/list-json.html",
|
|
3001
|
+
"./list-json/list-json.js": "./frontend/src/list-json/list-json.js",
|
|
3002
|
+
"./list-mixed/list-mixed": "./frontend/src/list-mixed/list-mixed.js",
|
|
3003
|
+
"./list-mixed/list-mixed.css": "./frontend/src/list-mixed/list-mixed.css",
|
|
3004
|
+
"./list-mixed/list-mixed.html": "./frontend/src/list-mixed/list-mixed.html",
|
|
3005
|
+
"./list-mixed/list-mixed.js": "./frontend/src/list-mixed/list-mixed.js",
|
|
3006
|
+
"./list-string/list-string": "./frontend/src/list-string/list-string.js",
|
|
3007
|
+
"./list-string/list-string.css": "./frontend/src/list-string/list-string.css",
|
|
3008
|
+
"./list-string/list-string.html": "./frontend/src/list-string/list-string.html",
|
|
3009
|
+
"./list-string/list-string.js": "./frontend/src/list-string/list-string.js",
|
|
3010
|
+
"./list-subdocument/list-subdocument": "./frontend/src/list-subdocument/list-subdocument.js",
|
|
3011
|
+
"./list-subdocument/list-subdocument.css": "./frontend/src/list-subdocument/list-subdocument.css",
|
|
3012
|
+
"./list-subdocument/list-subdocument.html": "./frontend/src/list-subdocument/list-subdocument.html",
|
|
3013
|
+
"./list-subdocument/list-subdocument.js": "./frontend/src/list-subdocument/list-subdocument.js",
|
|
3014
|
+
"./modal/modal": "./frontend/src/modal/modal.js",
|
|
3015
|
+
"./modal/modal.css": "./frontend/src/modal/modal.css",
|
|
3016
|
+
"./modal/modal.html": "./frontend/src/modal/modal.html",
|
|
3017
|
+
"./modal/modal.js": "./frontend/src/modal/modal.js",
|
|
3018
|
+
"./models/models": "./frontend/src/models/models.js",
|
|
3019
|
+
"./models/models.css": "./frontend/src/models/models.css",
|
|
3020
|
+
"./models/models.html": "./frontend/src/models/models.html",
|
|
3021
|
+
"./models/models.js": "./frontend/src/models/models.js",
|
|
3022
|
+
"./mothership": "./frontend/src/mothership.js",
|
|
3023
|
+
"./mothership.js": "./frontend/src/mothership.js",
|
|
3024
|
+
"./navbar/navbar": "./frontend/src/navbar/navbar.js",
|
|
3025
|
+
"./navbar/navbar.css": "./frontend/src/navbar/navbar.css",
|
|
3026
|
+
"./navbar/navbar.html": "./frontend/src/navbar/navbar.html",
|
|
3027
|
+
"./navbar/navbar.js": "./frontend/src/navbar/navbar.js",
|
|
3028
|
+
"./routes": "./frontend/src/routes.js",
|
|
3029
|
+
"./routes.js": "./frontend/src/routes.js",
|
|
3030
|
+
"./splash/splash": "./frontend/src/splash/splash.js",
|
|
3031
|
+
"./splash/splash.html": "./frontend/src/splash/splash.html",
|
|
3032
|
+
"./splash/splash.js": "./frontend/src/splash/splash.js",
|
|
3033
|
+
"./team/new-invitation/new-invitation": "./frontend/src/team/new-invitation/new-invitation.js",
|
|
3034
|
+
"./team/new-invitation/new-invitation.html": "./frontend/src/team/new-invitation/new-invitation.html",
|
|
3035
|
+
"./team/new-invitation/new-invitation.js": "./frontend/src/team/new-invitation/new-invitation.js",
|
|
3036
|
+
"./team/team": "./frontend/src/team/team.js",
|
|
3037
|
+
"./team/team.html": "./frontend/src/team/team.html",
|
|
3038
|
+
"./team/team.js": "./frontend/src/team/team.js"
|
|
3039
|
+
};
|
|
3040
|
+
|
|
3041
|
+
|
|
3042
|
+
function webpackContext(req) {
|
|
3043
|
+
var id = webpackContextResolve(req);
|
|
3044
|
+
return __webpack_require__(id);
|
|
3045
|
+
}
|
|
3046
|
+
function webpackContextResolve(req) {
|
|
3047
|
+
if(!__webpack_require__.o(map, req)) {
|
|
3048
|
+
var e = new Error("Cannot find module '" + req + "'");
|
|
3049
|
+
e.code = 'MODULE_NOT_FOUND';
|
|
3050
|
+
throw e;
|
|
3051
|
+
}
|
|
3052
|
+
return map[req];
|
|
3053
|
+
}
|
|
3054
|
+
webpackContext.keys = function webpackContextKeys() {
|
|
3055
|
+
return Object.keys(map);
|
|
3056
|
+
};
|
|
3057
|
+
webpackContext.resolve = webpackContextResolve;
|
|
3058
|
+
module.exports = webpackContext;
|
|
3059
|
+
webpackContext.id = "./frontend/src sync recursive ^\\.\\/.*$";
|
|
3060
|
+
|
|
2456
3061
|
/***/ }),
|
|
2457
3062
|
|
|
2458
3063
|
/***/ "./node_modules/mpath/index.js":
|
|
@@ -3062,7 +3667,40 @@ module.exports = function stringToParts(str) {
|
|
|
3062
3667
|
/***/ ((module) => {
|
|
3063
3668
|
|
|
3064
3669
|
"use strict";
|
|
3065
|
-
module.exports = "<button v-bind=\"attrsToBind\" :disabled=\"isDisabled\" @click=\"handleClick\">\n <slot></slot>\n</button
|
|
3670
|
+
module.exports = "<button v-bind=\"attrsToBind\" :disabled=\"isDisabled\" @click=\"handleClick\">\n <div v-if=\"status === 'in_progress'\" style=\"text-align: center\">\n <svg style=\"height: 1em\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <g>\n <circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" opacity=\"0.3\" />\n <path d=\"M12 2a10 10 0 0 1 10 10\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\">\n <animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 12 12\" to=\"360 12 12\" dur=\"1s\" repeatCount=\"indefinite\" />\n </path>\n </g>\n </svg>\n </div>\n <slot v-if=\"status == 'success' || status == 'init'\"></slot>\n</button>\n";
|
|
3671
|
+
|
|
3672
|
+
/***/ }),
|
|
3673
|
+
|
|
3674
|
+
/***/ "./frontend/src/chat/chat-message-script/chat-message-script.html":
|
|
3675
|
+
/*!************************************************************************!*\
|
|
3676
|
+
!*** ./frontend/src/chat/chat-message-script/chat-message-script.html ***!
|
|
3677
|
+
\************************************************************************/
|
|
3678
|
+
/***/ ((module) => {
|
|
3679
|
+
|
|
3680
|
+
"use strict";
|
|
3681
|
+
module.exports = "<div class=\"relative border rounded bg-gray-100 text-black text-sm overflow-hidden\">\n <div class=\"flex border-b pt-[1px] text-xs font-medium bg-gray-200\">\n <button\n class=\"px-3 py-1 border-r border-gray-300 hover:bg-green-300\"\n :class=\"{'bg-gray-300': activeTab === 'code', 'bg-green-300': activeTab === 'code'}\"\n @click=\"activeTab = 'code'\">\n Code\n </button>\n <button\n class=\"px-3 py-1 hover:bg-green-300\"\n :class=\"{'bg-green-300': activeTab === 'output'}\"\n @click=\"activeTab = 'output'\">\n Output\n </button>\n <div class=\"ml-auto mr-1 flex\">\n <button\n v-if=\"activeTab === 'output'\"\n class=\"px-2 py-1 mr-1 text-xs bg-blue-500 text-white border-none rounded cursor-pointer hover:bg-blue-600 transition-colors flex items-center\"\n @click=\"openDetailModal\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" class=\"h-3 w-3\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 1v4m0 0h-4m4 0l-5-5\" />\n </svg>\n </button>\n <async-button\n class=\"px-2 py-1 text-xs bg-green-500 text-white border-none rounded cursor-pointer hover:bg-green-600 transition-colors disabled:bg-gray-400\"\n @click=\"executeScript(message, script)\">\n Execute\n </async-button>\n </div>\n </div>\n\n <pre class=\"p-3 whitespace-pre-wrap max-h-[30vh] overflow-y-auto\" v-show=\"activeTab === 'code'\"><code v-text=\"script\" ref=\"code\" :class=\"'language-' + language\"></code></pre>\n\n <pre class=\"p-3 whitespace-pre-wrap max-h-[30vh] overflow-y-auto bg-white border-t\" v-show=\"activeTab === 'output'\">\n <dashboard-chart v-if=\"message.executionResult?.output?.$chart\" :value=\"message.executionResult?.output\" />\n <div v-else>\n {{ message.executionResult?.output ? JSON.stringify(message.executionResult.output, null, 2) : 'No output' }}\n </div>\n </pre>\n\n <modal ref=\"outputModal\" v-if=\"showDetailModal\" containerClass=\"!h-[90vh] !w-[90vw]\">\n <template #body>\n <div class=\"absolute font-mono right-1 top-1 cursor-pointer text-xl\" @click=\"showDetailModal = false;\">×</div>\n <div class=\"h-full overflow-auto\">\n <dashboard-chart v-if=\"message.executionResult?.output?.$chart\" :value=\"message.executionResult?.output\" />\n <pre v-else class=\"whitespace-pre-wrap\">\n {{ message.executionResult?.output ? JSON.stringify(message.executionResult.output, null, 2) : 'No output' }}\n </pre>\n </div>\n </template>\n </modal>\n</div>\n";
|
|
3682
|
+
|
|
3683
|
+
/***/ }),
|
|
3684
|
+
|
|
3685
|
+
/***/ "./frontend/src/chat/chat-message/chat-message.html":
|
|
3686
|
+
/*!**********************************************************!*\
|
|
3687
|
+
!*** ./frontend/src/chat/chat-message/chat-message.html ***!
|
|
3688
|
+
\**********************************************************/
|
|
3689
|
+
/***/ ((module) => {
|
|
3690
|
+
|
|
3691
|
+
"use strict";
|
|
3692
|
+
module.exports = "<div class=\"relative flex items-start space-x-3\" :class=\"{'justify-end': message.role === 'user'}\">\n <div\n class=\"min-w-0 max-w-[calc(100%-6.5rem)]\"\n :class=\"{'text-right': message.role === 'user'}\">\n\n <div class=\"text-sm text-gray-900 p-3 rounded-md inline-block\" :class=\"styleForMessage\">\n <div v-for=\"part in contentSplitByScripts\">\n <div v-if=\"part.type === 'text'\" v-html=\"marked(part.content)\">\n </div>\n <div v-else-if=\"part.type === 'code'\">\n <chat-message-script :message=\"message\" :script=\"part.content\" :language=\"part.language\"></chat-message-script>\n </div>\n </div>\n </div>\n </div>\n</div>\n";
|
|
3693
|
+
|
|
3694
|
+
/***/ }),
|
|
3695
|
+
|
|
3696
|
+
/***/ "./frontend/src/chat/chat.html":
|
|
3697
|
+
/*!*************************************!*\
|
|
3698
|
+
!*** ./frontend/src/chat/chat.html ***!
|
|
3699
|
+
\*************************************/
|
|
3700
|
+
/***/ ((module) => {
|
|
3701
|
+
|
|
3702
|
+
"use strict";
|
|
3703
|
+
module.exports = "<div class=\"flex\" style=\"height: calc(100vh - 55px)\">\n <!-- Sidebar: Chat Threads -->\n <aside class=\"w-64 bg-gray-100 border-r overflow-y-auto h-full\">\n <div class=\"p-4 font-bold text-lg border-b\">Chat Threads</div>\n <div class=\"p-4\">\n <button\n @click=\"createNewThread\"\n class=\"w-full bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700\"\n >\n Create New Thread\n </button>\n </div>\n <div v-if=\"status === 'loaded' && chatThreads.length === 0\" class=\"p-4 text-sm text-gray-700\">\n No threads yet\n </div>\n <ul vif=\"status === 'loaded'\">\n <li\n v-for=\"thread in chatThreads\"\n :key=\"thread._id\"\n @click=\"selectThread(thread._id)\"\n class=\"p-4 hover:bg-gray-200 cursor-pointer\"\n :class=\"{ 'bg-gray-300': thread._id === chatThreadId }\"\n >\n {{ thread.title || 'Untitled Thread' }}\n </li>\n </ul>\n </aside>\n\n <!-- Main Chat Area -->\n <main class=\"flex-1 flex flex-col\">\n <div class=\"flex-1 overflow-y-auto p-6 space-y-4\" ref=\"messagesContainer\">\n <ul role=\"list\" class=\"space-y-4\">\n <div v-if=\"true\">\n <div class=\"flex items-center justify-center py-3 mb-4\">\n <div class=\"bg-gray-300 h-px flex-grow max-w-xs\"></div>\n <p class=\"mx-4 text-sm font-medium text-gray-500\">This is the beginning of the message thread</p>\n <div class=\"bg-gray-300 h-px flex-grow max-w-xs\"></div>\n </div>\n </div>\n <li v-for=\"message in chatMessages\" :key=\"message._id\">\n <chat-message :message=\"message\"></chat-message>\n </li>\n </ul>\n </div>\n\n\n <!-- Input Area -->\n <div class=\"border-t p-4\">\n <form @submit.prevent=\"sendMessage\" :disabled=\"sendingMessage\" class=\"flex gap-2\">\n <input\n v-model=\"newMessage\"\n placeholder=\"Ask something...\"\n class=\"flex-1 border rounded px-4 py-2\"\n />\n <button class=\"bg-blue-600 text-white px-4 py-2 rounded disabled:bg-gray-600\" :disabled=\"sendingMessage\">\n <svg v-if=\"sendingMessage\" style=\"height: 1em\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <g>\n <circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" opacity=\"0.3\" />\n <path d=\"M12 2a10 10 0 0 1 10 10\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\">\n <animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 12 12\" to=\"360 12 12\" dur=\"1s\" repeatCount=\"indefinite\" />\n </path>\n </g>\n </svg>\n <span v-else>Send</span>\n </button>\n </form>\n </div>\n </main>\n</div>\n";
|
|
3066
3704
|
|
|
3067
3705
|
/***/ }),
|
|
3068
3706
|
|
|
@@ -3557,7 +4195,7 @@ module.exports = "/** Vue modal */\n\n.modal-mask {\n position: fixed;\n z-ind
|
|
|
3557
4195
|
/***/ ((module) => {
|
|
3558
4196
|
|
|
3559
4197
|
"use strict";
|
|
3560
|
-
module.exports = "<transition name=\"modal\">\n <div class=\"modal-mask\">\n <div class=\"modal-wrapper\">\n <div class=\"modal-container\">\n <div class=\"modal-body\">\n <slot name=\"body\">\n </slot>\n </div>\n </div>\n </div>\n </div>\n</transition
|
|
4198
|
+
module.exports = "<transition name=\"modal\">\n <div class=\"modal-mask\">\n <div class=\"modal-wrapper\">\n <div class=\"modal-container\" :class=\"containerClass\">\n <div class=\"modal-body\">\n <slot name=\"body\">\n </slot>\n </div>\n </div>\n </div>\n </div>\n</transition>\n";
|
|
3561
4199
|
|
|
3562
4200
|
/***/ }),
|
|
3563
4201
|
|
|
@@ -3601,7 +4239,7 @@ module.exports = ".navbar {\n width: 100%;\n background-color: #eee;\n}\n\n.ac
|
|
|
3601
4239
|
/***/ ((module) => {
|
|
3602
4240
|
|
|
3603
4241
|
"use strict";
|
|
3604
|
-
module.exports = "<div class=\"navbar\">\n <div class=\"nav-left flex items-center gap-4 h-full\">\n <router-link :to=\"{ name: defaultRoute }\">\n <img src=\"images/logo.svg\" alt=\"Mongoose Studio Logo\" />\n </router-link>\n <div v-if=\"!!state.nodeEnv\" class=\"inline-flex items-center rounded-md px-2 py-1 text-sm font-medium text-gray-900\" :class=\"warnEnv ? 'bg-red-300' : 'bg-yellow-300'\">\n {{state.nodeEnv}}\n </div>\n </div>\n <div class=\"nav-right h-full\">\n <div class=\"sm:ml-6 sm:flex sm:space-x-8 h-full\">\n <a v-if=\"hasAccess(roles, 'root')\"\n href=\"#/\"\n class=\"inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium\"\n :class=\"documentView ? 'text-gray-900 border-ultramarine-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Documents</a>\n <a v-if=\"hasAccess(roles, 'dashboards')\"\n href=\"#/dashboards\"\n class=\"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium\"\n :class=\"dashboardView ? 'text-gray-900 border-ultramarine-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Dashboards</a>\n\n <div class=\"h-full flex items-center\" v-if=\"!user && hasAPIKey\">\n <button\n type=\"button\"\n @click=\"loginWithGithub\"\n class=\"rounded bg-ultramarine-600 px-2 py-2 text-sm font-semibold text-white shadow-sm hover:bg-ultramarine-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ultramarine-600\">\n Login\n </button>\n </div>\n <div v-if=\"user && hasAPIKey\" class=\"h-full flex items-center relative\" v-clickOutside=\"hideFlyout\">\n <div>\n <button type=\"button\" @click=\"showFlyout = !showFlyout\" class=\"relative flex rounded-full bg-gray-800 text-sm focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800\" id=\"user-menu-button\" aria-expanded=\"false\" aria-haspopup=\"true\">\n <span class=\"absolute -inset-1.5\"></span>\n <span class=\"sr-only\">Open user menu</span>\n <img class=\"size-8 rounded-full\" :src=\"user.picture\" alt=\"\">\n </button>\n </div>\n\n <div v-if=\"showFlyout\" class=\"absolute right-0 z-10 top-[90%] w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black/5 focus:outline-none\" role=\"menu\" aria-orientation=\"vertical\" aria-labelledby=\"user-menu-button\" tabindex=\"-1\">\n <router-link to=\"/team\" v-if=\"hasAccess(roles, 'team')\" @click=\"showFlyout = false\" class=\"cursor-pointer block px-4 py-2 text-sm text-gray-700 hover:bg-ultramarine-200\" role=\"menuitem\" tabindex=\"-1\" id=\"user-menu-item-2\">Team</router-link>\n <span @click=\"logout\" class=\"cursor-pointer block px-4 py-2 text-sm text-gray-700 hover:bg-ultramarine-200\" role=\"menuitem\" tabindex=\"-1\" id=\"user-menu-item-2\">Sign out</span>\n </div>\n </div>\n\n </div>\n </div>\n <div style=\"clear: both\"></div>\n</div>\n";
|
|
4242
|
+
module.exports = "<div class=\"navbar\">\n <div class=\"nav-left flex items-center gap-4 h-full\">\n <router-link :to=\"{ name: defaultRoute }\">\n <img src=\"images/logo.svg\" alt=\"Mongoose Studio Logo\" />\n </router-link>\n <div v-if=\"!!state.nodeEnv\" class=\"inline-flex items-center rounded-md px-2 py-1 text-sm font-medium text-gray-900\" :class=\"warnEnv ? 'bg-red-300' : 'bg-yellow-300'\">\n {{state.nodeEnv}}\n </div>\n </div>\n <div class=\"nav-right h-full\">\n <div class=\"sm:ml-6 sm:flex sm:space-x-8 h-full\">\n <a v-if=\"hasAccess(roles, 'root')\"\n href=\"#/\"\n class=\"inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium\"\n :class=\"documentView ? 'text-gray-900 border-ultramarine-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Documents</a>\n <a v-if=\"hasAccess(roles, 'dashboards')\"\n href=\"#/dashboards\"\n class=\"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium\"\n :class=\"dashboardView ? 'text-gray-900 border-ultramarine-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Dashboards</a>\n <a v-if=\"hasAccess(roles, 'chat')\"\n href=\"#/chat\"\n class=\"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium\"\n :class=\"chatView ? 'text-gray-900 border-ultramarine-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Chat</a>\n\n <div class=\"h-full flex items-center\" v-if=\"!user && hasAPIKey\">\n <button\n type=\"button\"\n @click=\"loginWithGithub\"\n class=\"rounded bg-ultramarine-600 px-2 py-2 text-sm font-semibold text-white shadow-sm hover:bg-ultramarine-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ultramarine-600\">\n Login\n </button>\n </div>\n <div v-if=\"user && hasAPIKey\" class=\"h-full flex items-center relative\" v-clickOutside=\"hideFlyout\">\n <div>\n <button type=\"button\" @click=\"showFlyout = !showFlyout\" class=\"relative flex rounded-full bg-gray-800 text-sm focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800\" id=\"user-menu-button\" aria-expanded=\"false\" aria-haspopup=\"true\">\n <span class=\"absolute -inset-1.5\"></span>\n <span class=\"sr-only\">Open user menu</span>\n <img class=\"size-8 rounded-full\" :src=\"user.picture\" alt=\"\">\n </button>\n </div>\n\n <div v-if=\"showFlyout\" class=\"absolute right-0 z-10 top-[90%] w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black/5 focus:outline-none\" role=\"menu\" aria-orientation=\"vertical\" aria-labelledby=\"user-menu-button\" tabindex=\"-1\">\n <router-link to=\"/team\" v-if=\"hasAccess(roles, 'team')\" @click=\"showFlyout = false\" class=\"cursor-pointer block px-4 py-2 text-sm text-gray-700 hover:bg-ultramarine-200\" role=\"menuitem\" tabindex=\"-1\" id=\"user-menu-item-2\">Team</router-link>\n <span @click=\"logout\" class=\"cursor-pointer block px-4 py-2 text-sm text-gray-700 hover:bg-ultramarine-200\" role=\"menuitem\" tabindex=\"-1\" id=\"user-menu-item-2\">Sign out</span>\n </div>\n </div>\n\n </div>\n </div>\n <div style=\"clear: both\"></div>\n</div>\n";
|
|
3605
4243
|
|
|
3606
4244
|
/***/ }),
|
|
3607
4245
|
|
|
@@ -11400,209 +12038,2280 @@ exports.setInternalBufferSize = setInternalBufferSize;
|
|
|
11400
12038
|
//# sourceMappingURL=bson.cjs.map
|
|
11401
12039
|
|
|
11402
12040
|
|
|
11403
|
-
/***/ })
|
|
12041
|
+
/***/ }),
|
|
11404
12042
|
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
/******/ // The require function
|
|
11411
|
-
/******/ function __webpack_require__(moduleId) {
|
|
11412
|
-
/******/ // Check if module is in cache
|
|
11413
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
11414
|
-
/******/ if (cachedModule !== undefined) {
|
|
11415
|
-
/******/ return cachedModule.exports;
|
|
11416
|
-
/******/ }
|
|
11417
|
-
/******/ // Create a new module (and put it into the cache)
|
|
11418
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
11419
|
-
/******/ // no module.id needed
|
|
11420
|
-
/******/ // no module.loaded needed
|
|
11421
|
-
/******/ exports: {}
|
|
11422
|
-
/******/ };
|
|
11423
|
-
/******/
|
|
11424
|
-
/******/ // Execute the module function
|
|
11425
|
-
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
11426
|
-
/******/
|
|
11427
|
-
/******/ // Return the exports of the module
|
|
11428
|
-
/******/ return module.exports;
|
|
11429
|
-
/******/ }
|
|
11430
|
-
/******/
|
|
11431
|
-
/************************************************************************/
|
|
11432
|
-
/******/ /* webpack/runtime/global */
|
|
11433
|
-
/******/ (() => {
|
|
11434
|
-
/******/ __webpack_require__.g = (function() {
|
|
11435
|
-
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
11436
|
-
/******/ try {
|
|
11437
|
-
/******/ return this || new Function('return this')();
|
|
11438
|
-
/******/ } catch (e) {
|
|
11439
|
-
/******/ if (typeof window === 'object') return window;
|
|
11440
|
-
/******/ }
|
|
11441
|
-
/******/ })();
|
|
11442
|
-
/******/ })();
|
|
11443
|
-
/******/
|
|
11444
|
-
/************************************************************************/
|
|
11445
|
-
var __webpack_exports__ = {};
|
|
11446
|
-
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
|
|
11447
|
-
(() => {
|
|
11448
|
-
"use strict";
|
|
11449
|
-
/*!*******************************!*\
|
|
11450
|
-
!*** ./frontend/src/index.js ***!
|
|
11451
|
-
\*******************************/
|
|
12043
|
+
/***/ "./node_modules/marked/lib/marked.cjs":
|
|
12044
|
+
/*!********************************************!*\
|
|
12045
|
+
!*** ./node_modules/marked/lib/marked.cjs ***!
|
|
12046
|
+
\********************************************/
|
|
12047
|
+
/***/ ((module) => {
|
|
11452
12048
|
|
|
12049
|
+
"use strict";
|
|
12050
|
+
/**
|
|
12051
|
+
* marked v15.0.12 - a markdown parser
|
|
12052
|
+
* Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
|
|
12053
|
+
* https://github.com/markedjs/marked
|
|
12054
|
+
*/
|
|
11453
12055
|
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
12056
|
+
/**
|
|
12057
|
+
* DO NOT EDIT THIS FILE
|
|
12058
|
+
* The code in this file is generated from files in ./src/
|
|
12059
|
+
*/
|
|
11457
12060
|
|
|
11458
|
-
const api = __webpack_require__(/*! ./api */ "./frontend/src/api.js");
|
|
11459
|
-
const mothership = __webpack_require__(/*! ./mothership */ "./frontend/src/mothership.js");
|
|
11460
|
-
const vanillatoasts = __webpack_require__(/*! vanillatoasts */ "./node_modules/vanillatoasts/vanillatoasts.js");
|
|
11461
12061
|
|
|
11462
|
-
|
|
11463
|
-
|
|
12062
|
+
var __defProp = Object.defineProperty;
|
|
12063
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12064
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12065
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12066
|
+
var __export = (target, all) => {
|
|
12067
|
+
for (var name in all)
|
|
12068
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12069
|
+
};
|
|
12070
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12071
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12072
|
+
for (let key of __getOwnPropNames(from))
|
|
12073
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12074
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12075
|
+
}
|
|
12076
|
+
return to;
|
|
12077
|
+
};
|
|
12078
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
12079
|
+
|
|
12080
|
+
// src/marked.ts
|
|
12081
|
+
var marked_exports = {};
|
|
12082
|
+
__export(marked_exports, {
|
|
12083
|
+
Hooks: () => _Hooks,
|
|
12084
|
+
Lexer: () => _Lexer,
|
|
12085
|
+
Marked: () => Marked,
|
|
12086
|
+
Parser: () => _Parser,
|
|
12087
|
+
Renderer: () => _Renderer,
|
|
12088
|
+
TextRenderer: () => _TextRenderer,
|
|
12089
|
+
Tokenizer: () => _Tokenizer,
|
|
12090
|
+
defaults: () => _defaults,
|
|
12091
|
+
getDefaults: () => _getDefaults,
|
|
12092
|
+
lexer: () => lexer,
|
|
12093
|
+
marked: () => marked,
|
|
12094
|
+
options: () => options,
|
|
12095
|
+
parse: () => parse,
|
|
12096
|
+
parseInline: () => parseInline,
|
|
12097
|
+
parser: () => parser,
|
|
12098
|
+
setOptions: () => setOptions,
|
|
12099
|
+
use: () => use,
|
|
12100
|
+
walkTokens: () => walkTokens
|
|
11464
12101
|
});
|
|
12102
|
+
module.exports = __toCommonJS(marked_exports);
|
|
12103
|
+
|
|
12104
|
+
// src/defaults.ts
|
|
12105
|
+
function _getDefaults() {
|
|
12106
|
+
return {
|
|
12107
|
+
async: false,
|
|
12108
|
+
breaks: false,
|
|
12109
|
+
extensions: null,
|
|
12110
|
+
gfm: true,
|
|
12111
|
+
hooks: null,
|
|
12112
|
+
pedantic: false,
|
|
12113
|
+
renderer: null,
|
|
12114
|
+
silent: false,
|
|
12115
|
+
tokenizer: null,
|
|
12116
|
+
walkTokens: null
|
|
12117
|
+
};
|
|
12118
|
+
}
|
|
12119
|
+
var _defaults = _getDefaults();
|
|
12120
|
+
function changeDefaults(newDefaults) {
|
|
12121
|
+
_defaults = newDefaults;
|
|
12122
|
+
}
|
|
12123
|
+
|
|
12124
|
+
// src/rules.ts
|
|
12125
|
+
var noopTest = { exec: () => null };
|
|
12126
|
+
function edit(regex, opt = "") {
|
|
12127
|
+
let source = typeof regex === "string" ? regex : regex.source;
|
|
12128
|
+
const obj = {
|
|
12129
|
+
replace: (name, val) => {
|
|
12130
|
+
let valSource = typeof val === "string" ? val : val.source;
|
|
12131
|
+
valSource = valSource.replace(other.caret, "$1");
|
|
12132
|
+
source = source.replace(name, valSource);
|
|
12133
|
+
return obj;
|
|
12134
|
+
},
|
|
12135
|
+
getRegex: () => {
|
|
12136
|
+
return new RegExp(source, opt);
|
|
12137
|
+
}
|
|
12138
|
+
};
|
|
12139
|
+
return obj;
|
|
12140
|
+
}
|
|
12141
|
+
var other = {
|
|
12142
|
+
codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
|
|
12143
|
+
outputLinkReplace: /\\([\[\]])/g,
|
|
12144
|
+
indentCodeCompensation: /^(\s+)(?:```)/,
|
|
12145
|
+
beginningSpace: /^\s+/,
|
|
12146
|
+
endingHash: /#$/,
|
|
12147
|
+
startingSpaceChar: /^ /,
|
|
12148
|
+
endingSpaceChar: / $/,
|
|
12149
|
+
nonSpaceChar: /[^ ]/,
|
|
12150
|
+
newLineCharGlobal: /\n/g,
|
|
12151
|
+
tabCharGlobal: /\t/g,
|
|
12152
|
+
multipleSpaceGlobal: /\s+/g,
|
|
12153
|
+
blankLine: /^[ \t]*$/,
|
|
12154
|
+
doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
|
|
12155
|
+
blockquoteStart: /^ {0,3}>/,
|
|
12156
|
+
blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
|
|
12157
|
+
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
|
|
12158
|
+
listReplaceTabs: /^\t+/,
|
|
12159
|
+
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
|
|
12160
|
+
listIsTask: /^\[[ xX]\] /,
|
|
12161
|
+
listReplaceTask: /^\[[ xX]\] +/,
|
|
12162
|
+
anyLine: /\n.*\n/,
|
|
12163
|
+
hrefBrackets: /^<(.*)>$/,
|
|
12164
|
+
tableDelimiter: /[:|]/,
|
|
12165
|
+
tableAlignChars: /^\||\| *$/g,
|
|
12166
|
+
tableRowBlankLine: /\n[ \t]*$/,
|
|
12167
|
+
tableAlignRight: /^ *-+: *$/,
|
|
12168
|
+
tableAlignCenter: /^ *:-+: *$/,
|
|
12169
|
+
tableAlignLeft: /^ *:-+ *$/,
|
|
12170
|
+
startATag: /^<a /i,
|
|
12171
|
+
endATag: /^<\/a>/i,
|
|
12172
|
+
startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
|
|
12173
|
+
endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
|
|
12174
|
+
startAngleBracket: /^</,
|
|
12175
|
+
endAngleBracket: />$/,
|
|
12176
|
+
pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
|
|
12177
|
+
unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
|
|
12178
|
+
escapeTest: /[&<>"']/,
|
|
12179
|
+
escapeReplace: /[&<>"']/g,
|
|
12180
|
+
escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
|
|
12181
|
+
escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
|
|
12182
|
+
unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
|
|
12183
|
+
caret: /(^|[^\[])\^/g,
|
|
12184
|
+
percentDecode: /%25/g,
|
|
12185
|
+
findPipe: /\|/g,
|
|
12186
|
+
splitPipe: / \|/,
|
|
12187
|
+
slashPipe: /\\\|/g,
|
|
12188
|
+
carriageReturn: /\r\n|\r/g,
|
|
12189
|
+
spaceLine: /^ +$/gm,
|
|
12190
|
+
notSpaceStart: /^\S*/,
|
|
12191
|
+
endingNewline: /\n$/,
|
|
12192
|
+
listItemRegex: (bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
12193
|
+
nextBulletRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
12194
|
+
hrRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
|
|
12195
|
+
fencesBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`),
|
|
12196
|
+
headingBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`),
|
|
12197
|
+
htmlBeginRegex: (indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i")
|
|
12198
|
+
};
|
|
12199
|
+
var newline = /^(?:[ \t]*(?:\n|$))+/;
|
|
12200
|
+
var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
12201
|
+
var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
12202
|
+
var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
12203
|
+
var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
12204
|
+
var bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
12205
|
+
var lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
12206
|
+
var lheading = edit(lheadingCore).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
12207
|
+
var lheadingGfm = edit(lheadingCore).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
12208
|
+
var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
|
|
12209
|
+
var blockText = /^[^\n]+/;
|
|
12210
|
+
var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
12211
|
+
var def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
12212
|
+
var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
|
|
12213
|
+
var _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
12214
|
+
var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
12215
|
+
var html = edit(
|
|
12216
|
+
"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))",
|
|
12217
|
+
"i"
|
|
12218
|
+
).replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
12219
|
+
var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
|
|
12220
|
+
var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
|
|
12221
|
+
var blockNormal = {
|
|
12222
|
+
blockquote,
|
|
12223
|
+
code: blockCode,
|
|
12224
|
+
def,
|
|
12225
|
+
fences,
|
|
12226
|
+
heading,
|
|
12227
|
+
hr,
|
|
12228
|
+
html,
|
|
12229
|
+
lheading,
|
|
12230
|
+
list,
|
|
12231
|
+
newline,
|
|
12232
|
+
paragraph,
|
|
12233
|
+
table: noopTest,
|
|
12234
|
+
text: blockText
|
|
12235
|
+
};
|
|
12236
|
+
var gfmTable = edit(
|
|
12237
|
+
"^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
|
|
12238
|
+
).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
|
|
12239
|
+
var blockGfm = {
|
|
12240
|
+
...blockNormal,
|
|
12241
|
+
lheading: lheadingGfm,
|
|
12242
|
+
table: gfmTable,
|
|
12243
|
+
paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
|
|
12244
|
+
};
|
|
12245
|
+
var blockPedantic = {
|
|
12246
|
+
...blockNormal,
|
|
12247
|
+
html: edit(
|
|
12248
|
+
`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
|
|
12249
|
+
).replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
|
|
12250
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
12251
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
12252
|
+
fences: noopTest,
|
|
12253
|
+
// fences not supported
|
|
12254
|
+
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
12255
|
+
paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
12256
|
+
};
|
|
12257
|
+
var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
12258
|
+
var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
12259
|
+
var br = /^( {2,}|\\)\n(?!\s*$)/;
|
|
12260
|
+
var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
12261
|
+
var _punctuation = /[\p{P}\p{S}]/u;
|
|
12262
|
+
var _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
|
|
12263
|
+
var _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
|
|
12264
|
+
var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
|
|
12265
|
+
var _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
|
|
12266
|
+
var _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
|
|
12267
|
+
var _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
12268
|
+
var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
|
|
12269
|
+
var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
|
|
12270
|
+
var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
|
|
12271
|
+
var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
|
|
12272
|
+
var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
12273
|
+
var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
|
|
12274
|
+
var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
|
|
12275
|
+
var emStrongRDelimUnd = edit(
|
|
12276
|
+
"^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
|
|
12277
|
+
"gu"
|
|
12278
|
+
).replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
|
|
12279
|
+
var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
|
|
12280
|
+
var autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
12281
|
+
var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
|
|
12282
|
+
var tag = edit(
|
|
12283
|
+
"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
|
|
12284
|
+
).replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
12285
|
+
var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
12286
|
+
var link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
12287
|
+
var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
|
|
12288
|
+
var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
|
|
12289
|
+
var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
|
|
12290
|
+
var inlineNormal = {
|
|
12291
|
+
_backpedal: noopTest,
|
|
12292
|
+
// only used for GFM url
|
|
12293
|
+
anyPunctuation,
|
|
12294
|
+
autolink,
|
|
12295
|
+
blockSkip,
|
|
12296
|
+
br,
|
|
12297
|
+
code: inlineCode,
|
|
12298
|
+
del: noopTest,
|
|
12299
|
+
emStrongLDelim,
|
|
12300
|
+
emStrongRDelimAst,
|
|
12301
|
+
emStrongRDelimUnd,
|
|
12302
|
+
escape,
|
|
12303
|
+
link,
|
|
12304
|
+
nolink,
|
|
12305
|
+
punctuation,
|
|
12306
|
+
reflink,
|
|
12307
|
+
reflinkSearch,
|
|
12308
|
+
tag,
|
|
12309
|
+
text: inlineText,
|
|
12310
|
+
url: noopTest
|
|
12311
|
+
};
|
|
12312
|
+
var inlinePedantic = {
|
|
12313
|
+
...inlineNormal,
|
|
12314
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
|
|
12315
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
|
|
12316
|
+
};
|
|
12317
|
+
var inlineGfm = {
|
|
12318
|
+
...inlineNormal,
|
|
12319
|
+
emStrongRDelimAst: emStrongRDelimAstGfm,
|
|
12320
|
+
emStrongLDelim: emStrongLDelimGfm,
|
|
12321
|
+
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
|
|
12322
|
+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
12323
|
+
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
|
|
12324
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
12325
|
+
};
|
|
12326
|
+
var inlineBreaks = {
|
|
12327
|
+
...inlineGfm,
|
|
12328
|
+
br: edit(br).replace("{2,}", "*").getRegex(),
|
|
12329
|
+
text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
12330
|
+
};
|
|
12331
|
+
var block = {
|
|
12332
|
+
normal: blockNormal,
|
|
12333
|
+
gfm: blockGfm,
|
|
12334
|
+
pedantic: blockPedantic
|
|
12335
|
+
};
|
|
12336
|
+
var inline = {
|
|
12337
|
+
normal: inlineNormal,
|
|
12338
|
+
gfm: inlineGfm,
|
|
12339
|
+
breaks: inlineBreaks,
|
|
12340
|
+
pedantic: inlinePedantic
|
|
12341
|
+
};
|
|
11465
12342
|
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
__webpack_require__(/*! ./detail-default/detail-default */ "./frontend/src/detail-default/detail-default.js")(app);
|
|
11480
|
-
__webpack_require__(/*! ./document/document */ "./frontend/src/document/document.js")(app);
|
|
11481
|
-
__webpack_require__(/*! ./document/confirm-changes/confirm-changes */ "./frontend/src/document/confirm-changes/confirm-changes.js")(app);
|
|
11482
|
-
__webpack_require__(/*! ./document/confirm-delete/confirm-delete */ "./frontend/src/document/confirm-delete/confirm-delete.js")(app);
|
|
11483
|
-
__webpack_require__(/*! ./document-details/document-details */ "./frontend/src/document-details/document-details.js")(app);
|
|
11484
|
-
__webpack_require__(/*! ./document-details/document-property/document-property */ "./frontend/src/document-details/document-property/document-property.js")(app);
|
|
11485
|
-
__webpack_require__(/*! ./edit-array/edit-array */ "./frontend/src/edit-array/edit-array.js")(app);
|
|
11486
|
-
__webpack_require__(/*! ./edit-default/edit-default */ "./frontend/src/edit-default/edit-default.js")(app);
|
|
11487
|
-
__webpack_require__(/*! ./edit-number/edit-number */ "./frontend/src/edit-number/edit-number.js")(app);
|
|
11488
|
-
__webpack_require__(/*! ./edit-date/edit-date */ "./frontend/src/edit-date/edit-date.js")(app);
|
|
11489
|
-
__webpack_require__(/*! ./edit-subdocument/edit-subdocument */ "./frontend/src/edit-subdocument/edit-subdocument.js")(app);
|
|
11490
|
-
__webpack_require__(/*! ./export-query-results/export-query-results */ "./frontend/src/export-query-results/export-query-results.js")(app);
|
|
11491
|
-
__webpack_require__(/*! ./list-array/list-array */ "./frontend/src/list-array/list-array.js")(app);
|
|
11492
|
-
__webpack_require__(/*! ./list-default/list-default */ "./frontend/src/list-default/list-default.js")(app);
|
|
11493
|
-
__webpack_require__(/*! ./list-json/list-json */ "./frontend/src/list-json/list-json.js")(app)
|
|
11494
|
-
__webpack_require__(/*! ./list-mixed/list-mixed */ "./frontend/src/list-mixed/list-mixed.js")(app);
|
|
11495
|
-
__webpack_require__(/*! ./list-string/list-string */ "./frontend/src/list-string/list-string.js")(app);
|
|
11496
|
-
__webpack_require__(/*! ./list-subdocument/list-subdocument */ "./frontend/src/list-subdocument/list-subdocument.js")(app);
|
|
11497
|
-
__webpack_require__(/*! ./modal/modal */ "./frontend/src/modal/modal.js")(app);
|
|
11498
|
-
__webpack_require__(/*! ./models/models */ "./frontend/src/models/models.js")(app);
|
|
11499
|
-
__webpack_require__(/*! ./navbar/navbar */ "./frontend/src/navbar/navbar.js")(app);
|
|
11500
|
-
__webpack_require__(/*! ./splash/splash */ "./frontend/src/splash/splash.js")(app);
|
|
11501
|
-
__webpack_require__(/*! ./team/team */ "./frontend/src/team/team.js")(app);
|
|
11502
|
-
__webpack_require__(/*! ./team/new-invitation/new-invitation */ "./frontend/src/team/new-invitation/new-invitation.js")(app);
|
|
11503
|
-
|
|
11504
|
-
app.component('app-component', {
|
|
11505
|
-
template: `
|
|
11506
|
-
<div>
|
|
11507
|
-
<div v-if="hasAPIKey && (user == null || status === 'init')">
|
|
11508
|
-
<splash :loading="status === 'init'" />
|
|
11509
|
-
</div>
|
|
11510
|
-
<div v-else-if="!hasAPIKey || user">
|
|
11511
|
-
<navbar :user="user" :roles="roles" />
|
|
11512
|
-
<div class="view">
|
|
11513
|
-
<router-view :key="$route.fullPath" :user="user" :roles="roles" />
|
|
11514
|
-
</div>
|
|
11515
|
-
</div>
|
|
11516
|
-
</div>
|
|
11517
|
-
`,
|
|
11518
|
-
errorCaptured(err) {
|
|
11519
|
-
vanillatoasts.create({
|
|
11520
|
-
title: `Error: ${err?.response?.data?.message || err.message}`,
|
|
11521
|
-
icon: 'images/failure.jpg',
|
|
11522
|
-
timeout: 10000,
|
|
11523
|
-
positionClass: 'bottomRight'
|
|
11524
|
-
});
|
|
11525
|
-
},
|
|
11526
|
-
computed: {
|
|
11527
|
-
hasAPIKey() {
|
|
11528
|
-
return mothership.hasAPIKey;
|
|
12343
|
+
// src/helpers.ts
|
|
12344
|
+
var escapeReplacements = {
|
|
12345
|
+
"&": "&",
|
|
12346
|
+
"<": "<",
|
|
12347
|
+
">": ">",
|
|
12348
|
+
'"': """,
|
|
12349
|
+
"'": "'"
|
|
12350
|
+
};
|
|
12351
|
+
var getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
12352
|
+
function escape2(html2, encode) {
|
|
12353
|
+
if (encode) {
|
|
12354
|
+
if (other.escapeTest.test(html2)) {
|
|
12355
|
+
return html2.replace(other.escapeReplace, getEscapeReplacement);
|
|
11529
12356
|
}
|
|
11530
|
-
}
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
12357
|
+
} else {
|
|
12358
|
+
if (other.escapeTestNoEncode.test(html2)) {
|
|
12359
|
+
return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
|
|
12360
|
+
}
|
|
12361
|
+
}
|
|
12362
|
+
return html2;
|
|
12363
|
+
}
|
|
12364
|
+
function cleanUrl(href) {
|
|
12365
|
+
try {
|
|
12366
|
+
href = encodeURI(href).replace(other.percentDecode, "%");
|
|
12367
|
+
} catch {
|
|
12368
|
+
return null;
|
|
12369
|
+
}
|
|
12370
|
+
return href;
|
|
12371
|
+
}
|
|
12372
|
+
function splitCells(tableRow, count) {
|
|
12373
|
+
const row = tableRow.replace(other.findPipe, (match, offset, str) => {
|
|
12374
|
+
let escaped = false;
|
|
12375
|
+
let curr = offset;
|
|
12376
|
+
while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
|
|
12377
|
+
if (escaped) {
|
|
12378
|
+
return "|";
|
|
12379
|
+
} else {
|
|
12380
|
+
return " |";
|
|
12381
|
+
}
|
|
12382
|
+
}), cells = row.split(other.splitPipe);
|
|
12383
|
+
let i = 0;
|
|
12384
|
+
if (!cells[0].trim()) {
|
|
12385
|
+
cells.shift();
|
|
12386
|
+
}
|
|
12387
|
+
if (cells.length > 0 && !cells.at(-1)?.trim()) {
|
|
12388
|
+
cells.pop();
|
|
12389
|
+
}
|
|
12390
|
+
if (count) {
|
|
12391
|
+
if (cells.length > count) {
|
|
12392
|
+
cells.splice(count);
|
|
12393
|
+
} else {
|
|
12394
|
+
while (cells.length < count) cells.push("");
|
|
12395
|
+
}
|
|
12396
|
+
}
|
|
12397
|
+
for (; i < cells.length; i++) {
|
|
12398
|
+
cells[i] = cells[i].trim().replace(other.slashPipe, "|");
|
|
12399
|
+
}
|
|
12400
|
+
return cells;
|
|
12401
|
+
}
|
|
12402
|
+
function rtrim(str, c, invert) {
|
|
12403
|
+
const l = str.length;
|
|
12404
|
+
if (l === 0) {
|
|
12405
|
+
return "";
|
|
12406
|
+
}
|
|
12407
|
+
let suffLen = 0;
|
|
12408
|
+
while (suffLen < l) {
|
|
12409
|
+
const currChar = str.charAt(l - suffLen - 1);
|
|
12410
|
+
if (currChar === c && !invert) {
|
|
12411
|
+
suffLen++;
|
|
12412
|
+
} else if (currChar !== c && invert) {
|
|
12413
|
+
suffLen++;
|
|
12414
|
+
} else {
|
|
12415
|
+
break;
|
|
12416
|
+
}
|
|
12417
|
+
}
|
|
12418
|
+
return str.slice(0, l - suffLen);
|
|
12419
|
+
}
|
|
12420
|
+
function findClosingBracket(str, b) {
|
|
12421
|
+
if (str.indexOf(b[1]) === -1) {
|
|
12422
|
+
return -1;
|
|
12423
|
+
}
|
|
12424
|
+
let level = 0;
|
|
12425
|
+
for (let i = 0; i < str.length; i++) {
|
|
12426
|
+
if (str[i] === "\\") {
|
|
12427
|
+
i++;
|
|
12428
|
+
} else if (str[i] === b[0]) {
|
|
12429
|
+
level++;
|
|
12430
|
+
} else if (str[i] === b[1]) {
|
|
12431
|
+
level--;
|
|
12432
|
+
if (level < 0) {
|
|
12433
|
+
return i;
|
|
12434
|
+
}
|
|
12435
|
+
}
|
|
12436
|
+
}
|
|
12437
|
+
if (level > 0) {
|
|
12438
|
+
return -2;
|
|
12439
|
+
}
|
|
12440
|
+
return -1;
|
|
12441
|
+
}
|
|
11534
12442
|
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
12443
|
+
// src/Tokenizer.ts
|
|
12444
|
+
function outputLink(cap, link2, raw, lexer2, rules) {
|
|
12445
|
+
const href = link2.href;
|
|
12446
|
+
const title = link2.title || null;
|
|
12447
|
+
const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
|
|
12448
|
+
lexer2.state.inLink = true;
|
|
12449
|
+
const token = {
|
|
12450
|
+
type: cap[0].charAt(0) === "!" ? "image" : "link",
|
|
12451
|
+
raw,
|
|
12452
|
+
href,
|
|
12453
|
+
title,
|
|
12454
|
+
text,
|
|
12455
|
+
tokens: lexer2.inlineTokens(text)
|
|
12456
|
+
};
|
|
12457
|
+
lexer2.state.inLink = false;
|
|
12458
|
+
return token;
|
|
12459
|
+
}
|
|
12460
|
+
function indentCodeCompensation(raw, text, rules) {
|
|
12461
|
+
const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
|
|
12462
|
+
if (matchIndentToCode === null) {
|
|
12463
|
+
return text;
|
|
12464
|
+
}
|
|
12465
|
+
const indentToCode = matchIndentToCode[1];
|
|
12466
|
+
return text.split("\n").map((node) => {
|
|
12467
|
+
const matchIndentInNode = node.match(rules.other.beginningSpace);
|
|
12468
|
+
if (matchIndentInNode === null) {
|
|
12469
|
+
return node;
|
|
12470
|
+
}
|
|
12471
|
+
const [indentInNode] = matchIndentInNode;
|
|
12472
|
+
if (indentInNode.length >= indentToCode.length) {
|
|
12473
|
+
return node.slice(indentToCode.length);
|
|
12474
|
+
}
|
|
12475
|
+
return node;
|
|
12476
|
+
}).join("\n");
|
|
12477
|
+
}
|
|
12478
|
+
var _Tokenizer = class {
|
|
12479
|
+
options;
|
|
12480
|
+
rules;
|
|
12481
|
+
// set by the lexer
|
|
12482
|
+
lexer;
|
|
12483
|
+
// set by the lexer
|
|
12484
|
+
constructor(options2) {
|
|
12485
|
+
this.options = options2 || _defaults;
|
|
12486
|
+
}
|
|
12487
|
+
space(src) {
|
|
12488
|
+
const cap = this.rules.block.newline.exec(src);
|
|
12489
|
+
if (cap && cap[0].length > 0) {
|
|
12490
|
+
return {
|
|
12491
|
+
type: "space",
|
|
12492
|
+
raw: cap[0]
|
|
12493
|
+
};
|
|
12494
|
+
}
|
|
12495
|
+
}
|
|
12496
|
+
code(src) {
|
|
12497
|
+
const cap = this.rules.block.code.exec(src);
|
|
12498
|
+
if (cap) {
|
|
12499
|
+
const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
|
|
12500
|
+
return {
|
|
12501
|
+
type: "code",
|
|
12502
|
+
raw: cap[0],
|
|
12503
|
+
codeBlockStyle: "indented",
|
|
12504
|
+
text: !this.options.pedantic ? rtrim(text, "\n") : text
|
|
12505
|
+
};
|
|
12506
|
+
}
|
|
12507
|
+
}
|
|
12508
|
+
fences(src) {
|
|
12509
|
+
const cap = this.rules.block.fences.exec(src);
|
|
12510
|
+
if (cap) {
|
|
12511
|
+
const raw = cap[0];
|
|
12512
|
+
const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
|
|
12513
|
+
return {
|
|
12514
|
+
type: "code",
|
|
12515
|
+
raw,
|
|
12516
|
+
lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
|
|
12517
|
+
text
|
|
12518
|
+
};
|
|
12519
|
+
}
|
|
12520
|
+
}
|
|
12521
|
+
heading(src) {
|
|
12522
|
+
const cap = this.rules.block.heading.exec(src);
|
|
12523
|
+
if (cap) {
|
|
12524
|
+
let text = cap[2].trim();
|
|
12525
|
+
if (this.rules.other.endingHash.test(text)) {
|
|
12526
|
+
const trimmed = rtrim(text, "#");
|
|
12527
|
+
if (this.options.pedantic) {
|
|
12528
|
+
text = trimmed.trim();
|
|
12529
|
+
} else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
|
|
12530
|
+
text = trimmed.trim();
|
|
12531
|
+
}
|
|
12532
|
+
}
|
|
12533
|
+
return {
|
|
12534
|
+
type: "heading",
|
|
12535
|
+
raw: cap[0],
|
|
12536
|
+
depth: cap[1].length,
|
|
12537
|
+
text,
|
|
12538
|
+
tokens: this.lexer.inline(text)
|
|
12539
|
+
};
|
|
12540
|
+
}
|
|
12541
|
+
}
|
|
12542
|
+
hr(src) {
|
|
12543
|
+
const cap = this.rules.block.hr.exec(src);
|
|
12544
|
+
if (cap) {
|
|
12545
|
+
return {
|
|
12546
|
+
type: "hr",
|
|
12547
|
+
raw: rtrim(cap[0], "\n")
|
|
12548
|
+
};
|
|
12549
|
+
}
|
|
12550
|
+
}
|
|
12551
|
+
blockquote(src) {
|
|
12552
|
+
const cap = this.rules.block.blockquote.exec(src);
|
|
12553
|
+
if (cap) {
|
|
12554
|
+
let lines = rtrim(cap[0], "\n").split("\n");
|
|
12555
|
+
let raw = "";
|
|
12556
|
+
let text = "";
|
|
12557
|
+
const tokens = [];
|
|
12558
|
+
while (lines.length > 0) {
|
|
12559
|
+
let inBlockquote = false;
|
|
12560
|
+
const currentLines = [];
|
|
12561
|
+
let i;
|
|
12562
|
+
for (i = 0; i < lines.length; i++) {
|
|
12563
|
+
if (this.rules.other.blockquoteStart.test(lines[i])) {
|
|
12564
|
+
currentLines.push(lines[i]);
|
|
12565
|
+
inBlockquote = true;
|
|
12566
|
+
} else if (!inBlockquote) {
|
|
12567
|
+
currentLines.push(lines[i]);
|
|
12568
|
+
} else {
|
|
12569
|
+
break;
|
|
11544
12570
|
}
|
|
11545
|
-
this.user = user;
|
|
11546
|
-
this.roles = roles;
|
|
11547
|
-
window.localStorage.setItem('_mongooseStudioAccessToken', accessToken._id);
|
|
11548
|
-
} catch (err) {
|
|
11549
|
-
this.authError = 'An error occurred while logging in. Please try again.';
|
|
11550
|
-
this.status = 'loaded';
|
|
11551
|
-
return;
|
|
11552
|
-
} finally {
|
|
11553
|
-
setTimeout(() => {
|
|
11554
|
-
this.$router.replace(this.$router.currentRoute.value.path);
|
|
11555
|
-
}, 0);
|
|
11556
12571
|
}
|
|
11557
|
-
|
|
11558
|
-
const
|
|
11559
|
-
this.
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
12572
|
+
lines = lines.slice(i);
|
|
12573
|
+
const currentRaw = currentLines.join("\n");
|
|
12574
|
+
const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
12575
|
+
raw = raw ? `${raw}
|
|
12576
|
+
${currentRaw}` : currentRaw;
|
|
12577
|
+
text = text ? `${text}
|
|
12578
|
+
${currentText}` : currentText;
|
|
12579
|
+
const top = this.lexer.state.top;
|
|
12580
|
+
this.lexer.state.top = true;
|
|
12581
|
+
this.lexer.blockTokens(currentText, tokens, true);
|
|
12582
|
+
this.lexer.state.top = top;
|
|
12583
|
+
if (lines.length === 0) {
|
|
12584
|
+
break;
|
|
12585
|
+
}
|
|
12586
|
+
const lastToken = tokens.at(-1);
|
|
12587
|
+
if (lastToken?.type === "code") {
|
|
12588
|
+
break;
|
|
12589
|
+
} else if (lastToken?.type === "blockquote") {
|
|
12590
|
+
const oldToken = lastToken;
|
|
12591
|
+
const newText = oldToken.raw + "\n" + lines.join("\n");
|
|
12592
|
+
const newToken = this.blockquote(newText);
|
|
12593
|
+
tokens[tokens.length - 1] = newToken;
|
|
12594
|
+
raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
|
|
12595
|
+
text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
|
|
12596
|
+
break;
|
|
12597
|
+
} else if (lastToken?.type === "list") {
|
|
12598
|
+
const oldToken = lastToken;
|
|
12599
|
+
const newText = oldToken.raw + "\n" + lines.join("\n");
|
|
12600
|
+
const newToken = this.list(newText);
|
|
12601
|
+
tokens[tokens.length - 1] = newToken;
|
|
12602
|
+
raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
|
|
12603
|
+
text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
|
|
12604
|
+
lines = newText.substring(tokens.at(-1).raw.length).split("\n");
|
|
12605
|
+
continue;
|
|
11569
12606
|
}
|
|
11570
12607
|
}
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
12608
|
+
return {
|
|
12609
|
+
type: "blockquote",
|
|
12610
|
+
raw,
|
|
12611
|
+
tokens,
|
|
12612
|
+
text
|
|
12613
|
+
};
|
|
11574
12614
|
}
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
12615
|
+
}
|
|
12616
|
+
list(src) {
|
|
12617
|
+
let cap = this.rules.block.list.exec(src);
|
|
12618
|
+
if (cap) {
|
|
12619
|
+
let bull = cap[1].trim();
|
|
12620
|
+
const isordered = bull.length > 1;
|
|
12621
|
+
const list2 = {
|
|
12622
|
+
type: "list",
|
|
12623
|
+
raw: "",
|
|
12624
|
+
ordered: isordered,
|
|
12625
|
+
start: isordered ? +bull.slice(0, -1) : "",
|
|
12626
|
+
loose: false,
|
|
12627
|
+
items: []
|
|
12628
|
+
};
|
|
12629
|
+
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
12630
|
+
if (this.options.pedantic) {
|
|
12631
|
+
bull = isordered ? bull : "[*+-]";
|
|
12632
|
+
}
|
|
12633
|
+
const itemRegex = this.rules.other.listItemRegex(bull);
|
|
12634
|
+
let endsWithBlankLine = false;
|
|
12635
|
+
while (src) {
|
|
12636
|
+
let endEarly = false;
|
|
12637
|
+
let raw = "";
|
|
12638
|
+
let itemContents = "";
|
|
12639
|
+
if (!(cap = itemRegex.exec(src))) {
|
|
12640
|
+
break;
|
|
12641
|
+
}
|
|
12642
|
+
if (this.rules.block.hr.test(src)) {
|
|
12643
|
+
break;
|
|
12644
|
+
}
|
|
12645
|
+
raw = cap[0];
|
|
12646
|
+
src = src.substring(raw.length);
|
|
12647
|
+
let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => " ".repeat(3 * t.length));
|
|
12648
|
+
let nextLine = src.split("\n", 1)[0];
|
|
12649
|
+
let blankLine = !line.trim();
|
|
12650
|
+
let indent = 0;
|
|
12651
|
+
if (this.options.pedantic) {
|
|
12652
|
+
indent = 2;
|
|
12653
|
+
itemContents = line.trimStart();
|
|
12654
|
+
} else if (blankLine) {
|
|
12655
|
+
indent = cap[1].length + 1;
|
|
12656
|
+
} else {
|
|
12657
|
+
indent = cap[2].search(this.rules.other.nonSpaceChar);
|
|
12658
|
+
indent = indent > 4 ? 1 : indent;
|
|
12659
|
+
itemContents = line.slice(indent);
|
|
12660
|
+
indent += cap[1].length;
|
|
12661
|
+
}
|
|
12662
|
+
if (blankLine && this.rules.other.blankLine.test(nextLine)) {
|
|
12663
|
+
raw += nextLine + "\n";
|
|
12664
|
+
src = src.substring(nextLine.length + 1);
|
|
12665
|
+
endEarly = true;
|
|
12666
|
+
}
|
|
12667
|
+
if (!endEarly) {
|
|
12668
|
+
const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
|
|
12669
|
+
const hrRegex = this.rules.other.hrRegex(indent);
|
|
12670
|
+
const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
|
|
12671
|
+
const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
|
|
12672
|
+
const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
|
|
12673
|
+
while (src) {
|
|
12674
|
+
const rawLine = src.split("\n", 1)[0];
|
|
12675
|
+
let nextLineWithoutTabs;
|
|
12676
|
+
nextLine = rawLine;
|
|
12677
|
+
if (this.options.pedantic) {
|
|
12678
|
+
nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
|
|
12679
|
+
nextLineWithoutTabs = nextLine;
|
|
12680
|
+
} else {
|
|
12681
|
+
nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
|
|
12682
|
+
}
|
|
12683
|
+
if (fencesBeginRegex.test(nextLine)) {
|
|
12684
|
+
break;
|
|
12685
|
+
}
|
|
12686
|
+
if (headingBeginRegex.test(nextLine)) {
|
|
12687
|
+
break;
|
|
12688
|
+
}
|
|
12689
|
+
if (htmlBeginRegex.test(nextLine)) {
|
|
12690
|
+
break;
|
|
12691
|
+
}
|
|
12692
|
+
if (nextBulletRegex.test(nextLine)) {
|
|
12693
|
+
break;
|
|
12694
|
+
}
|
|
12695
|
+
if (hrRegex.test(nextLine)) {
|
|
12696
|
+
break;
|
|
12697
|
+
}
|
|
12698
|
+
if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
|
|
12699
|
+
itemContents += "\n" + nextLineWithoutTabs.slice(indent);
|
|
12700
|
+
} else {
|
|
12701
|
+
if (blankLine) {
|
|
12702
|
+
break;
|
|
12703
|
+
}
|
|
12704
|
+
if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) {
|
|
12705
|
+
break;
|
|
12706
|
+
}
|
|
12707
|
+
if (fencesBeginRegex.test(line)) {
|
|
12708
|
+
break;
|
|
12709
|
+
}
|
|
12710
|
+
if (headingBeginRegex.test(line)) {
|
|
12711
|
+
break;
|
|
12712
|
+
}
|
|
12713
|
+
if (hrRegex.test(line)) {
|
|
12714
|
+
break;
|
|
12715
|
+
}
|
|
12716
|
+
itemContents += "\n" + nextLine;
|
|
12717
|
+
}
|
|
12718
|
+
if (!blankLine && !nextLine.trim()) {
|
|
12719
|
+
blankLine = true;
|
|
12720
|
+
}
|
|
12721
|
+
raw += rawLine + "\n";
|
|
12722
|
+
src = src.substring(rawLine.length + 1);
|
|
12723
|
+
line = nextLineWithoutTabs.slice(indent);
|
|
12724
|
+
}
|
|
12725
|
+
}
|
|
12726
|
+
if (!list2.loose) {
|
|
12727
|
+
if (endsWithBlankLine) {
|
|
12728
|
+
list2.loose = true;
|
|
12729
|
+
} else if (this.rules.other.doubleBlankLine.test(raw)) {
|
|
12730
|
+
endsWithBlankLine = true;
|
|
12731
|
+
}
|
|
12732
|
+
}
|
|
12733
|
+
let istask = null;
|
|
12734
|
+
let ischecked;
|
|
12735
|
+
if (this.options.gfm) {
|
|
12736
|
+
istask = this.rules.other.listIsTask.exec(itemContents);
|
|
12737
|
+
if (istask) {
|
|
12738
|
+
ischecked = istask[0] !== "[ ] ";
|
|
12739
|
+
itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
|
|
12740
|
+
}
|
|
12741
|
+
}
|
|
12742
|
+
list2.items.push({
|
|
12743
|
+
type: "list_item",
|
|
12744
|
+
raw,
|
|
12745
|
+
task: !!istask,
|
|
12746
|
+
checked: ischecked,
|
|
12747
|
+
loose: false,
|
|
12748
|
+
text: itemContents,
|
|
12749
|
+
tokens: []
|
|
12750
|
+
});
|
|
12751
|
+
list2.raw += raw;
|
|
12752
|
+
}
|
|
12753
|
+
const lastItem = list2.items.at(-1);
|
|
12754
|
+
if (lastItem) {
|
|
12755
|
+
lastItem.raw = lastItem.raw.trimEnd();
|
|
12756
|
+
lastItem.text = lastItem.text.trimEnd();
|
|
12757
|
+
} else {
|
|
12758
|
+
return;
|
|
12759
|
+
}
|
|
12760
|
+
list2.raw = list2.raw.trimEnd();
|
|
12761
|
+
for (let i = 0; i < list2.items.length; i++) {
|
|
12762
|
+
this.lexer.state.top = false;
|
|
12763
|
+
list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
|
|
12764
|
+
if (!list2.loose) {
|
|
12765
|
+
const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
|
|
12766
|
+
const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));
|
|
12767
|
+
list2.loose = hasMultipleLineBreaks;
|
|
12768
|
+
}
|
|
12769
|
+
}
|
|
12770
|
+
if (list2.loose) {
|
|
12771
|
+
for (let i = 0; i < list2.items.length; i++) {
|
|
12772
|
+
list2.items[i].loose = true;
|
|
12773
|
+
}
|
|
12774
|
+
}
|
|
12775
|
+
return list2;
|
|
12776
|
+
}
|
|
12777
|
+
}
|
|
12778
|
+
html(src) {
|
|
12779
|
+
const cap = this.rules.block.html.exec(src);
|
|
12780
|
+
if (cap) {
|
|
12781
|
+
const token = {
|
|
12782
|
+
type: "html",
|
|
12783
|
+
block: true,
|
|
12784
|
+
raw: cap[0],
|
|
12785
|
+
pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
|
|
12786
|
+
text: cap[0]
|
|
12787
|
+
};
|
|
12788
|
+
return token;
|
|
12789
|
+
}
|
|
12790
|
+
}
|
|
12791
|
+
def(src) {
|
|
12792
|
+
const cap = this.rules.block.def.exec(src);
|
|
12793
|
+
if (cap) {
|
|
12794
|
+
const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
|
|
12795
|
+
const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
|
|
12796
|
+
const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
|
|
12797
|
+
return {
|
|
12798
|
+
type: "def",
|
|
12799
|
+
tag: tag2,
|
|
12800
|
+
raw: cap[0],
|
|
12801
|
+
href,
|
|
12802
|
+
title
|
|
12803
|
+
};
|
|
12804
|
+
}
|
|
12805
|
+
}
|
|
12806
|
+
table(src) {
|
|
12807
|
+
const cap = this.rules.block.table.exec(src);
|
|
12808
|
+
if (!cap) {
|
|
12809
|
+
return;
|
|
12810
|
+
}
|
|
12811
|
+
if (!this.rules.other.tableDelimiter.test(cap[2])) {
|
|
12812
|
+
return;
|
|
12813
|
+
}
|
|
12814
|
+
const headers = splitCells(cap[1]);
|
|
12815
|
+
const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
|
|
12816
|
+
const rows = cap[3]?.trim() ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
|
|
12817
|
+
const item = {
|
|
12818
|
+
type: "table",
|
|
12819
|
+
raw: cap[0],
|
|
12820
|
+
header: [],
|
|
12821
|
+
align: [],
|
|
12822
|
+
rows: []
|
|
12823
|
+
};
|
|
12824
|
+
if (headers.length !== aligns.length) {
|
|
12825
|
+
return;
|
|
12826
|
+
}
|
|
12827
|
+
for (const align of aligns) {
|
|
12828
|
+
if (this.rules.other.tableAlignRight.test(align)) {
|
|
12829
|
+
item.align.push("right");
|
|
12830
|
+
} else if (this.rules.other.tableAlignCenter.test(align)) {
|
|
12831
|
+
item.align.push("center");
|
|
12832
|
+
} else if (this.rules.other.tableAlignLeft.test(align)) {
|
|
12833
|
+
item.align.push("left");
|
|
12834
|
+
} else {
|
|
12835
|
+
item.align.push(null);
|
|
12836
|
+
}
|
|
12837
|
+
}
|
|
12838
|
+
for (let i = 0; i < headers.length; i++) {
|
|
12839
|
+
item.header.push({
|
|
12840
|
+
text: headers[i],
|
|
12841
|
+
tokens: this.lexer.inline(headers[i]),
|
|
12842
|
+
header: true,
|
|
12843
|
+
align: item.align[i]
|
|
12844
|
+
});
|
|
12845
|
+
}
|
|
12846
|
+
for (const row of rows) {
|
|
12847
|
+
item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
|
|
12848
|
+
return {
|
|
12849
|
+
text: cell,
|
|
12850
|
+
tokens: this.lexer.inline(cell),
|
|
12851
|
+
header: false,
|
|
12852
|
+
align: item.align[i]
|
|
12853
|
+
};
|
|
12854
|
+
}));
|
|
12855
|
+
}
|
|
12856
|
+
return item;
|
|
12857
|
+
}
|
|
12858
|
+
lheading(src) {
|
|
12859
|
+
const cap = this.rules.block.lheading.exec(src);
|
|
12860
|
+
if (cap) {
|
|
12861
|
+
return {
|
|
12862
|
+
type: "heading",
|
|
12863
|
+
raw: cap[0],
|
|
12864
|
+
depth: cap[2].charAt(0) === "=" ? 1 : 2,
|
|
12865
|
+
text: cap[1],
|
|
12866
|
+
tokens: this.lexer.inline(cap[1])
|
|
12867
|
+
};
|
|
12868
|
+
}
|
|
12869
|
+
}
|
|
12870
|
+
paragraph(src) {
|
|
12871
|
+
const cap = this.rules.block.paragraph.exec(src);
|
|
12872
|
+
if (cap) {
|
|
12873
|
+
const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
|
|
12874
|
+
return {
|
|
12875
|
+
type: "paragraph",
|
|
12876
|
+
raw: cap[0],
|
|
12877
|
+
text,
|
|
12878
|
+
tokens: this.lexer.inline(text)
|
|
12879
|
+
};
|
|
12880
|
+
}
|
|
12881
|
+
}
|
|
12882
|
+
text(src) {
|
|
12883
|
+
const cap = this.rules.block.text.exec(src);
|
|
12884
|
+
if (cap) {
|
|
12885
|
+
return {
|
|
12886
|
+
type: "text",
|
|
12887
|
+
raw: cap[0],
|
|
12888
|
+
text: cap[0],
|
|
12889
|
+
tokens: this.lexer.inline(cap[0])
|
|
12890
|
+
};
|
|
12891
|
+
}
|
|
12892
|
+
}
|
|
12893
|
+
escape(src) {
|
|
12894
|
+
const cap = this.rules.inline.escape.exec(src);
|
|
12895
|
+
if (cap) {
|
|
12896
|
+
return {
|
|
12897
|
+
type: "escape",
|
|
12898
|
+
raw: cap[0],
|
|
12899
|
+
text: cap[1]
|
|
12900
|
+
};
|
|
12901
|
+
}
|
|
12902
|
+
}
|
|
12903
|
+
tag(src) {
|
|
12904
|
+
const cap = this.rules.inline.tag.exec(src);
|
|
12905
|
+
if (cap) {
|
|
12906
|
+
if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
|
|
12907
|
+
this.lexer.state.inLink = true;
|
|
12908
|
+
} else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
|
|
12909
|
+
this.lexer.state.inLink = false;
|
|
12910
|
+
}
|
|
12911
|
+
if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
|
|
12912
|
+
this.lexer.state.inRawBlock = true;
|
|
12913
|
+
} else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
|
|
12914
|
+
this.lexer.state.inRawBlock = false;
|
|
12915
|
+
}
|
|
12916
|
+
return {
|
|
12917
|
+
type: "html",
|
|
12918
|
+
raw: cap[0],
|
|
12919
|
+
inLink: this.lexer.state.inLink,
|
|
12920
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
12921
|
+
block: false,
|
|
12922
|
+
text: cap[0]
|
|
12923
|
+
};
|
|
12924
|
+
}
|
|
12925
|
+
}
|
|
12926
|
+
link(src) {
|
|
12927
|
+
const cap = this.rules.inline.link.exec(src);
|
|
12928
|
+
if (cap) {
|
|
12929
|
+
const trimmedUrl = cap[2].trim();
|
|
12930
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
|
|
12931
|
+
if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
|
|
12932
|
+
return;
|
|
12933
|
+
}
|
|
12934
|
+
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
|
|
12935
|
+
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
12936
|
+
return;
|
|
12937
|
+
}
|
|
12938
|
+
} else {
|
|
12939
|
+
const lastParenIndex = findClosingBracket(cap[2], "()");
|
|
12940
|
+
if (lastParenIndex === -2) {
|
|
12941
|
+
return;
|
|
12942
|
+
}
|
|
12943
|
+
if (lastParenIndex > -1) {
|
|
12944
|
+
const start = cap[0].indexOf("!") === 0 ? 5 : 4;
|
|
12945
|
+
const linkLen = start + cap[1].length + lastParenIndex;
|
|
12946
|
+
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
12947
|
+
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
12948
|
+
cap[3] = "";
|
|
12949
|
+
}
|
|
12950
|
+
}
|
|
12951
|
+
let href = cap[2];
|
|
12952
|
+
let title = "";
|
|
12953
|
+
if (this.options.pedantic) {
|
|
12954
|
+
const link2 = this.rules.other.pedanticHrefTitle.exec(href);
|
|
12955
|
+
if (link2) {
|
|
12956
|
+
href = link2[1];
|
|
12957
|
+
title = link2[3];
|
|
12958
|
+
}
|
|
12959
|
+
} else {
|
|
12960
|
+
title = cap[3] ? cap[3].slice(1, -1) : "";
|
|
12961
|
+
}
|
|
12962
|
+
href = href.trim();
|
|
12963
|
+
if (this.rules.other.startAngleBracket.test(href)) {
|
|
12964
|
+
if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
|
|
12965
|
+
href = href.slice(1);
|
|
12966
|
+
} else {
|
|
12967
|
+
href = href.slice(1, -1);
|
|
12968
|
+
}
|
|
12969
|
+
}
|
|
12970
|
+
return outputLink(cap, {
|
|
12971
|
+
href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
|
|
12972
|
+
title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
|
|
12973
|
+
}, cap[0], this.lexer, this.rules);
|
|
12974
|
+
}
|
|
12975
|
+
}
|
|
12976
|
+
reflink(src, links) {
|
|
12977
|
+
let cap;
|
|
12978
|
+
if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
|
|
12979
|
+
const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
|
|
12980
|
+
const link2 = links[linkString.toLowerCase()];
|
|
12981
|
+
if (!link2) {
|
|
12982
|
+
const text = cap[0].charAt(0);
|
|
12983
|
+
return {
|
|
12984
|
+
type: "text",
|
|
12985
|
+
raw: text,
|
|
12986
|
+
text
|
|
12987
|
+
};
|
|
12988
|
+
}
|
|
12989
|
+
return outputLink(cap, link2, cap[0], this.lexer, this.rules);
|
|
12990
|
+
}
|
|
12991
|
+
}
|
|
12992
|
+
emStrong(src, maskedSrc, prevChar = "") {
|
|
12993
|
+
let match = this.rules.inline.emStrongLDelim.exec(src);
|
|
12994
|
+
if (!match) return;
|
|
12995
|
+
if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
12996
|
+
const nextChar = match[1] || match[2] || "";
|
|
12997
|
+
if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
|
|
12998
|
+
const lLength = [...match[0]].length - 1;
|
|
12999
|
+
let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
|
|
13000
|
+
const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
13001
|
+
endReg.lastIndex = 0;
|
|
13002
|
+
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
13003
|
+
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
13004
|
+
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
13005
|
+
if (!rDelim) continue;
|
|
13006
|
+
rLength = [...rDelim].length;
|
|
13007
|
+
if (match[3] || match[4]) {
|
|
13008
|
+
delimTotal += rLength;
|
|
13009
|
+
continue;
|
|
13010
|
+
} else if (match[5] || match[6]) {
|
|
13011
|
+
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
13012
|
+
midDelimTotal += rLength;
|
|
13013
|
+
continue;
|
|
13014
|
+
}
|
|
13015
|
+
}
|
|
13016
|
+
delimTotal -= rLength;
|
|
13017
|
+
if (delimTotal > 0) continue;
|
|
13018
|
+
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
13019
|
+
const lastCharLength = [...match[0]][0].length;
|
|
13020
|
+
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
|
|
13021
|
+
if (Math.min(lLength, rLength) % 2) {
|
|
13022
|
+
const text2 = raw.slice(1, -1);
|
|
13023
|
+
return {
|
|
13024
|
+
type: "em",
|
|
13025
|
+
raw,
|
|
13026
|
+
text: text2,
|
|
13027
|
+
tokens: this.lexer.inlineTokens(text2)
|
|
13028
|
+
};
|
|
13029
|
+
}
|
|
13030
|
+
const text = raw.slice(2, -2);
|
|
13031
|
+
return {
|
|
13032
|
+
type: "strong",
|
|
13033
|
+
raw,
|
|
13034
|
+
text,
|
|
13035
|
+
tokens: this.lexer.inlineTokens(text)
|
|
13036
|
+
};
|
|
13037
|
+
}
|
|
13038
|
+
}
|
|
13039
|
+
}
|
|
13040
|
+
codespan(src) {
|
|
13041
|
+
const cap = this.rules.inline.code.exec(src);
|
|
13042
|
+
if (cap) {
|
|
13043
|
+
let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
|
|
13044
|
+
const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
|
|
13045
|
+
const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
|
|
13046
|
+
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
13047
|
+
text = text.substring(1, text.length - 1);
|
|
13048
|
+
}
|
|
13049
|
+
return {
|
|
13050
|
+
type: "codespan",
|
|
13051
|
+
raw: cap[0],
|
|
13052
|
+
text
|
|
13053
|
+
};
|
|
13054
|
+
}
|
|
13055
|
+
}
|
|
13056
|
+
br(src) {
|
|
13057
|
+
const cap = this.rules.inline.br.exec(src);
|
|
13058
|
+
if (cap) {
|
|
13059
|
+
return {
|
|
13060
|
+
type: "br",
|
|
13061
|
+
raw: cap[0]
|
|
13062
|
+
};
|
|
13063
|
+
}
|
|
13064
|
+
}
|
|
13065
|
+
del(src) {
|
|
13066
|
+
const cap = this.rules.inline.del.exec(src);
|
|
13067
|
+
if (cap) {
|
|
13068
|
+
return {
|
|
13069
|
+
type: "del",
|
|
13070
|
+
raw: cap[0],
|
|
13071
|
+
text: cap[2],
|
|
13072
|
+
tokens: this.lexer.inlineTokens(cap[2])
|
|
13073
|
+
};
|
|
13074
|
+
}
|
|
13075
|
+
}
|
|
13076
|
+
autolink(src) {
|
|
13077
|
+
const cap = this.rules.inline.autolink.exec(src);
|
|
13078
|
+
if (cap) {
|
|
13079
|
+
let text, href;
|
|
13080
|
+
if (cap[2] === "@") {
|
|
13081
|
+
text = cap[1];
|
|
13082
|
+
href = "mailto:" + text;
|
|
13083
|
+
} else {
|
|
13084
|
+
text = cap[1];
|
|
13085
|
+
href = text;
|
|
13086
|
+
}
|
|
13087
|
+
return {
|
|
13088
|
+
type: "link",
|
|
13089
|
+
raw: cap[0],
|
|
13090
|
+
text,
|
|
13091
|
+
href,
|
|
13092
|
+
tokens: [
|
|
13093
|
+
{
|
|
13094
|
+
type: "text",
|
|
13095
|
+
raw: text,
|
|
13096
|
+
text
|
|
13097
|
+
}
|
|
13098
|
+
]
|
|
13099
|
+
};
|
|
13100
|
+
}
|
|
13101
|
+
}
|
|
13102
|
+
url(src) {
|
|
13103
|
+
let cap;
|
|
13104
|
+
if (cap = this.rules.inline.url.exec(src)) {
|
|
13105
|
+
let text, href;
|
|
13106
|
+
if (cap[2] === "@") {
|
|
13107
|
+
text = cap[0];
|
|
13108
|
+
href = "mailto:" + text;
|
|
13109
|
+
} else {
|
|
13110
|
+
let prevCapZero;
|
|
13111
|
+
do {
|
|
13112
|
+
prevCapZero = cap[0];
|
|
13113
|
+
cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
|
|
13114
|
+
} while (prevCapZero !== cap[0]);
|
|
13115
|
+
text = cap[0];
|
|
13116
|
+
if (cap[1] === "www.") {
|
|
13117
|
+
href = "http://" + cap[0];
|
|
13118
|
+
} else {
|
|
13119
|
+
href = cap[0];
|
|
13120
|
+
}
|
|
13121
|
+
}
|
|
13122
|
+
return {
|
|
13123
|
+
type: "link",
|
|
13124
|
+
raw: cap[0],
|
|
13125
|
+
text,
|
|
13126
|
+
href,
|
|
13127
|
+
tokens: [
|
|
13128
|
+
{
|
|
13129
|
+
type: "text",
|
|
13130
|
+
raw: text,
|
|
13131
|
+
text
|
|
13132
|
+
}
|
|
13133
|
+
]
|
|
13134
|
+
};
|
|
13135
|
+
}
|
|
13136
|
+
}
|
|
13137
|
+
inlineText(src) {
|
|
13138
|
+
const cap = this.rules.inline.text.exec(src);
|
|
13139
|
+
if (cap) {
|
|
13140
|
+
const escaped = this.lexer.state.inRawBlock;
|
|
13141
|
+
return {
|
|
13142
|
+
type: "text",
|
|
13143
|
+
raw: cap[0],
|
|
13144
|
+
text: cap[0],
|
|
13145
|
+
escaped
|
|
13146
|
+
};
|
|
13147
|
+
}
|
|
13148
|
+
}
|
|
13149
|
+
};
|
|
11583
13150
|
|
|
11584
|
-
|
|
11585
|
-
|
|
13151
|
+
// src/Lexer.ts
|
|
13152
|
+
var _Lexer = class __Lexer {
|
|
13153
|
+
tokens;
|
|
13154
|
+
options;
|
|
13155
|
+
state;
|
|
13156
|
+
tokenizer;
|
|
13157
|
+
inlineQueue;
|
|
13158
|
+
constructor(options2) {
|
|
13159
|
+
this.tokens = [];
|
|
13160
|
+
this.tokens.links = /* @__PURE__ */ Object.create(null);
|
|
13161
|
+
this.options = options2 || _defaults;
|
|
13162
|
+
this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
|
|
13163
|
+
this.tokenizer = this.options.tokenizer;
|
|
13164
|
+
this.tokenizer.options = this.options;
|
|
13165
|
+
this.tokenizer.lexer = this;
|
|
13166
|
+
this.inlineQueue = [];
|
|
13167
|
+
this.state = {
|
|
13168
|
+
inLink: false,
|
|
13169
|
+
inRawBlock: false,
|
|
13170
|
+
top: true
|
|
13171
|
+
};
|
|
13172
|
+
const rules = {
|
|
13173
|
+
other,
|
|
13174
|
+
block: block.normal,
|
|
13175
|
+
inline: inline.normal
|
|
13176
|
+
};
|
|
13177
|
+
if (this.options.pedantic) {
|
|
13178
|
+
rules.block = block.pedantic;
|
|
13179
|
+
rules.inline = inline.pedantic;
|
|
13180
|
+
} else if (this.options.gfm) {
|
|
13181
|
+
rules.block = block.gfm;
|
|
13182
|
+
if (this.options.breaks) {
|
|
13183
|
+
rules.inline = inline.breaks;
|
|
13184
|
+
} else {
|
|
13185
|
+
rules.inline = inline.gfm;
|
|
13186
|
+
}
|
|
13187
|
+
}
|
|
13188
|
+
this.tokenizer.rules = rules;
|
|
13189
|
+
}
|
|
13190
|
+
/**
|
|
13191
|
+
* Expose Rules
|
|
13192
|
+
*/
|
|
13193
|
+
static get rules() {
|
|
13194
|
+
return {
|
|
13195
|
+
block,
|
|
13196
|
+
inline
|
|
13197
|
+
};
|
|
13198
|
+
}
|
|
13199
|
+
/**
|
|
13200
|
+
* Static Lex Method
|
|
13201
|
+
*/
|
|
13202
|
+
static lex(src, options2) {
|
|
13203
|
+
const lexer2 = new __Lexer(options2);
|
|
13204
|
+
return lexer2.lex(src);
|
|
13205
|
+
}
|
|
13206
|
+
/**
|
|
13207
|
+
* Static Lex Inline Method
|
|
13208
|
+
*/
|
|
13209
|
+
static lexInline(src, options2) {
|
|
13210
|
+
const lexer2 = new __Lexer(options2);
|
|
13211
|
+
return lexer2.inlineTokens(src);
|
|
13212
|
+
}
|
|
13213
|
+
/**
|
|
13214
|
+
* Preprocessing
|
|
13215
|
+
*/
|
|
13216
|
+
lex(src) {
|
|
13217
|
+
src = src.replace(other.carriageReturn, "\n");
|
|
13218
|
+
this.blockTokens(src, this.tokens);
|
|
13219
|
+
for (let i = 0; i < this.inlineQueue.length; i++) {
|
|
13220
|
+
const next = this.inlineQueue[i];
|
|
13221
|
+
this.inlineTokens(next.src, next.tokens);
|
|
13222
|
+
}
|
|
13223
|
+
this.inlineQueue = [];
|
|
13224
|
+
return this.tokens;
|
|
13225
|
+
}
|
|
13226
|
+
blockTokens(src, tokens = [], lastParagraphClipped = false) {
|
|
13227
|
+
if (this.options.pedantic) {
|
|
13228
|
+
src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
|
|
13229
|
+
}
|
|
13230
|
+
while (src) {
|
|
13231
|
+
let token;
|
|
13232
|
+
if (this.options.extensions?.block?.some((extTokenizer) => {
|
|
13233
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
13234
|
+
src = src.substring(token.raw.length);
|
|
13235
|
+
tokens.push(token);
|
|
13236
|
+
return true;
|
|
13237
|
+
}
|
|
13238
|
+
return false;
|
|
13239
|
+
})) {
|
|
13240
|
+
continue;
|
|
13241
|
+
}
|
|
13242
|
+
if (token = this.tokenizer.space(src)) {
|
|
13243
|
+
src = src.substring(token.raw.length);
|
|
13244
|
+
const lastToken = tokens.at(-1);
|
|
13245
|
+
if (token.raw.length === 1 && lastToken !== void 0) {
|
|
13246
|
+
lastToken.raw += "\n";
|
|
13247
|
+
} else {
|
|
13248
|
+
tokens.push(token);
|
|
13249
|
+
}
|
|
13250
|
+
continue;
|
|
13251
|
+
}
|
|
13252
|
+
if (token = this.tokenizer.code(src)) {
|
|
13253
|
+
src = src.substring(token.raw.length);
|
|
13254
|
+
const lastToken = tokens.at(-1);
|
|
13255
|
+
if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
|
|
13256
|
+
lastToken.raw += "\n" + token.raw;
|
|
13257
|
+
lastToken.text += "\n" + token.text;
|
|
13258
|
+
this.inlineQueue.at(-1).src = lastToken.text;
|
|
13259
|
+
} else {
|
|
13260
|
+
tokens.push(token);
|
|
13261
|
+
}
|
|
13262
|
+
continue;
|
|
13263
|
+
}
|
|
13264
|
+
if (token = this.tokenizer.fences(src)) {
|
|
13265
|
+
src = src.substring(token.raw.length);
|
|
13266
|
+
tokens.push(token);
|
|
13267
|
+
continue;
|
|
13268
|
+
}
|
|
13269
|
+
if (token = this.tokenizer.heading(src)) {
|
|
13270
|
+
src = src.substring(token.raw.length);
|
|
13271
|
+
tokens.push(token);
|
|
13272
|
+
continue;
|
|
13273
|
+
}
|
|
13274
|
+
if (token = this.tokenizer.hr(src)) {
|
|
13275
|
+
src = src.substring(token.raw.length);
|
|
13276
|
+
tokens.push(token);
|
|
13277
|
+
continue;
|
|
13278
|
+
}
|
|
13279
|
+
if (token = this.tokenizer.blockquote(src)) {
|
|
13280
|
+
src = src.substring(token.raw.length);
|
|
13281
|
+
tokens.push(token);
|
|
13282
|
+
continue;
|
|
13283
|
+
}
|
|
13284
|
+
if (token = this.tokenizer.list(src)) {
|
|
13285
|
+
src = src.substring(token.raw.length);
|
|
13286
|
+
tokens.push(token);
|
|
13287
|
+
continue;
|
|
13288
|
+
}
|
|
13289
|
+
if (token = this.tokenizer.html(src)) {
|
|
13290
|
+
src = src.substring(token.raw.length);
|
|
13291
|
+
tokens.push(token);
|
|
13292
|
+
continue;
|
|
13293
|
+
}
|
|
13294
|
+
if (token = this.tokenizer.def(src)) {
|
|
13295
|
+
src = src.substring(token.raw.length);
|
|
13296
|
+
const lastToken = tokens.at(-1);
|
|
13297
|
+
if (lastToken?.type === "paragraph" || lastToken?.type === "text") {
|
|
13298
|
+
lastToken.raw += "\n" + token.raw;
|
|
13299
|
+
lastToken.text += "\n" + token.raw;
|
|
13300
|
+
this.inlineQueue.at(-1).src = lastToken.text;
|
|
13301
|
+
} else if (!this.tokens.links[token.tag]) {
|
|
13302
|
+
this.tokens.links[token.tag] = {
|
|
13303
|
+
href: token.href,
|
|
13304
|
+
title: token.title
|
|
13305
|
+
};
|
|
13306
|
+
}
|
|
13307
|
+
continue;
|
|
13308
|
+
}
|
|
13309
|
+
if (token = this.tokenizer.table(src)) {
|
|
13310
|
+
src = src.substring(token.raw.length);
|
|
13311
|
+
tokens.push(token);
|
|
13312
|
+
continue;
|
|
13313
|
+
}
|
|
13314
|
+
if (token = this.tokenizer.lheading(src)) {
|
|
13315
|
+
src = src.substring(token.raw.length);
|
|
13316
|
+
tokens.push(token);
|
|
13317
|
+
continue;
|
|
13318
|
+
}
|
|
13319
|
+
let cutSrc = src;
|
|
13320
|
+
if (this.options.extensions?.startBlock) {
|
|
13321
|
+
let startIndex = Infinity;
|
|
13322
|
+
const tempSrc = src.slice(1);
|
|
13323
|
+
let tempStart;
|
|
13324
|
+
this.options.extensions.startBlock.forEach((getStartIndex) => {
|
|
13325
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
13326
|
+
if (typeof tempStart === "number" && tempStart >= 0) {
|
|
13327
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
13328
|
+
}
|
|
13329
|
+
});
|
|
13330
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
13331
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
13332
|
+
}
|
|
13333
|
+
}
|
|
13334
|
+
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
13335
|
+
const lastToken = tokens.at(-1);
|
|
13336
|
+
if (lastParagraphClipped && lastToken?.type === "paragraph") {
|
|
13337
|
+
lastToken.raw += "\n" + token.raw;
|
|
13338
|
+
lastToken.text += "\n" + token.text;
|
|
13339
|
+
this.inlineQueue.pop();
|
|
13340
|
+
this.inlineQueue.at(-1).src = lastToken.text;
|
|
13341
|
+
} else {
|
|
13342
|
+
tokens.push(token);
|
|
13343
|
+
}
|
|
13344
|
+
lastParagraphClipped = cutSrc.length !== src.length;
|
|
13345
|
+
src = src.substring(token.raw.length);
|
|
13346
|
+
continue;
|
|
13347
|
+
}
|
|
13348
|
+
if (token = this.tokenizer.text(src)) {
|
|
13349
|
+
src = src.substring(token.raw.length);
|
|
13350
|
+
const lastToken = tokens.at(-1);
|
|
13351
|
+
if (lastToken?.type === "text") {
|
|
13352
|
+
lastToken.raw += "\n" + token.raw;
|
|
13353
|
+
lastToken.text += "\n" + token.text;
|
|
13354
|
+
this.inlineQueue.pop();
|
|
13355
|
+
this.inlineQueue.at(-1).src = lastToken.text;
|
|
13356
|
+
} else {
|
|
13357
|
+
tokens.push(token);
|
|
13358
|
+
}
|
|
13359
|
+
continue;
|
|
13360
|
+
}
|
|
13361
|
+
if (src) {
|
|
13362
|
+
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
13363
|
+
if (this.options.silent) {
|
|
13364
|
+
console.error(errMsg);
|
|
13365
|
+
break;
|
|
13366
|
+
} else {
|
|
13367
|
+
throw new Error(errMsg);
|
|
13368
|
+
}
|
|
13369
|
+
}
|
|
13370
|
+
}
|
|
13371
|
+
this.state.top = true;
|
|
13372
|
+
return tokens;
|
|
13373
|
+
}
|
|
13374
|
+
inline(src, tokens = []) {
|
|
13375
|
+
this.inlineQueue.push({ src, tokens });
|
|
13376
|
+
return tokens;
|
|
13377
|
+
}
|
|
13378
|
+
/**
|
|
13379
|
+
* Lexing/Compiling
|
|
13380
|
+
*/
|
|
13381
|
+
inlineTokens(src, tokens = []) {
|
|
13382
|
+
let maskedSrc = src;
|
|
13383
|
+
let match = null;
|
|
13384
|
+
if (this.tokens.links) {
|
|
13385
|
+
const links = Object.keys(this.tokens.links);
|
|
13386
|
+
if (links.length > 0) {
|
|
13387
|
+
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
13388
|
+
if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
|
|
13389
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
13390
|
+
}
|
|
13391
|
+
}
|
|
13392
|
+
}
|
|
13393
|
+
}
|
|
13394
|
+
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
|
|
13395
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
13396
|
+
}
|
|
13397
|
+
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
13398
|
+
maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
13399
|
+
}
|
|
13400
|
+
let keepPrevChar = false;
|
|
13401
|
+
let prevChar = "";
|
|
13402
|
+
while (src) {
|
|
13403
|
+
if (!keepPrevChar) {
|
|
13404
|
+
prevChar = "";
|
|
13405
|
+
}
|
|
13406
|
+
keepPrevChar = false;
|
|
13407
|
+
let token;
|
|
13408
|
+
if (this.options.extensions?.inline?.some((extTokenizer) => {
|
|
13409
|
+
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
13410
|
+
src = src.substring(token.raw.length);
|
|
13411
|
+
tokens.push(token);
|
|
13412
|
+
return true;
|
|
13413
|
+
}
|
|
13414
|
+
return false;
|
|
13415
|
+
})) {
|
|
13416
|
+
continue;
|
|
13417
|
+
}
|
|
13418
|
+
if (token = this.tokenizer.escape(src)) {
|
|
13419
|
+
src = src.substring(token.raw.length);
|
|
13420
|
+
tokens.push(token);
|
|
13421
|
+
continue;
|
|
13422
|
+
}
|
|
13423
|
+
if (token = this.tokenizer.tag(src)) {
|
|
13424
|
+
src = src.substring(token.raw.length);
|
|
13425
|
+
tokens.push(token);
|
|
13426
|
+
continue;
|
|
13427
|
+
}
|
|
13428
|
+
if (token = this.tokenizer.link(src)) {
|
|
13429
|
+
src = src.substring(token.raw.length);
|
|
13430
|
+
tokens.push(token);
|
|
13431
|
+
continue;
|
|
13432
|
+
}
|
|
13433
|
+
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
13434
|
+
src = src.substring(token.raw.length);
|
|
13435
|
+
const lastToken = tokens.at(-1);
|
|
13436
|
+
if (token.type === "text" && lastToken?.type === "text") {
|
|
13437
|
+
lastToken.raw += token.raw;
|
|
13438
|
+
lastToken.text += token.text;
|
|
13439
|
+
} else {
|
|
13440
|
+
tokens.push(token);
|
|
13441
|
+
}
|
|
13442
|
+
continue;
|
|
13443
|
+
}
|
|
13444
|
+
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
13445
|
+
src = src.substring(token.raw.length);
|
|
13446
|
+
tokens.push(token);
|
|
13447
|
+
continue;
|
|
13448
|
+
}
|
|
13449
|
+
if (token = this.tokenizer.codespan(src)) {
|
|
13450
|
+
src = src.substring(token.raw.length);
|
|
13451
|
+
tokens.push(token);
|
|
13452
|
+
continue;
|
|
13453
|
+
}
|
|
13454
|
+
if (token = this.tokenizer.br(src)) {
|
|
13455
|
+
src = src.substring(token.raw.length);
|
|
13456
|
+
tokens.push(token);
|
|
13457
|
+
continue;
|
|
13458
|
+
}
|
|
13459
|
+
if (token = this.tokenizer.del(src)) {
|
|
13460
|
+
src = src.substring(token.raw.length);
|
|
13461
|
+
tokens.push(token);
|
|
13462
|
+
continue;
|
|
13463
|
+
}
|
|
13464
|
+
if (token = this.tokenizer.autolink(src)) {
|
|
13465
|
+
src = src.substring(token.raw.length);
|
|
13466
|
+
tokens.push(token);
|
|
13467
|
+
continue;
|
|
13468
|
+
}
|
|
13469
|
+
if (!this.state.inLink && (token = this.tokenizer.url(src))) {
|
|
13470
|
+
src = src.substring(token.raw.length);
|
|
13471
|
+
tokens.push(token);
|
|
13472
|
+
continue;
|
|
13473
|
+
}
|
|
13474
|
+
let cutSrc = src;
|
|
13475
|
+
if (this.options.extensions?.startInline) {
|
|
13476
|
+
let startIndex = Infinity;
|
|
13477
|
+
const tempSrc = src.slice(1);
|
|
13478
|
+
let tempStart;
|
|
13479
|
+
this.options.extensions.startInline.forEach((getStartIndex) => {
|
|
13480
|
+
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
13481
|
+
if (typeof tempStart === "number" && tempStart >= 0) {
|
|
13482
|
+
startIndex = Math.min(startIndex, tempStart);
|
|
13483
|
+
}
|
|
13484
|
+
});
|
|
13485
|
+
if (startIndex < Infinity && startIndex >= 0) {
|
|
13486
|
+
cutSrc = src.substring(0, startIndex + 1);
|
|
13487
|
+
}
|
|
13488
|
+
}
|
|
13489
|
+
if (token = this.tokenizer.inlineText(cutSrc)) {
|
|
13490
|
+
src = src.substring(token.raw.length);
|
|
13491
|
+
if (token.raw.slice(-1) !== "_") {
|
|
13492
|
+
prevChar = token.raw.slice(-1);
|
|
13493
|
+
}
|
|
13494
|
+
keepPrevChar = true;
|
|
13495
|
+
const lastToken = tokens.at(-1);
|
|
13496
|
+
if (lastToken?.type === "text") {
|
|
13497
|
+
lastToken.raw += token.raw;
|
|
13498
|
+
lastToken.text += token.text;
|
|
13499
|
+
} else {
|
|
13500
|
+
tokens.push(token);
|
|
13501
|
+
}
|
|
13502
|
+
continue;
|
|
13503
|
+
}
|
|
13504
|
+
if (src) {
|
|
13505
|
+
const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
|
|
13506
|
+
if (this.options.silent) {
|
|
13507
|
+
console.error(errMsg);
|
|
13508
|
+
break;
|
|
13509
|
+
} else {
|
|
13510
|
+
throw new Error(errMsg);
|
|
13511
|
+
}
|
|
13512
|
+
}
|
|
13513
|
+
}
|
|
13514
|
+
return tokens;
|
|
13515
|
+
}
|
|
13516
|
+
};
|
|
11586
13517
|
|
|
11587
|
-
|
|
13518
|
+
// src/Renderer.ts
|
|
13519
|
+
var _Renderer = class {
|
|
13520
|
+
options;
|
|
13521
|
+
parser;
|
|
13522
|
+
// set by the parser
|
|
13523
|
+
constructor(options2) {
|
|
13524
|
+
this.options = options2 || _defaults;
|
|
13525
|
+
}
|
|
13526
|
+
space(token) {
|
|
13527
|
+
return "";
|
|
13528
|
+
}
|
|
13529
|
+
code({ text, lang, escaped }) {
|
|
13530
|
+
const langString = (lang || "").match(other.notSpaceStart)?.[0];
|
|
13531
|
+
const code = text.replace(other.endingNewline, "") + "\n";
|
|
13532
|
+
if (!langString) {
|
|
13533
|
+
return "<pre><code>" + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
|
|
13534
|
+
}
|
|
13535
|
+
return '<pre><code class="language-' + escape2(langString) + '">' + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
|
|
13536
|
+
}
|
|
13537
|
+
blockquote({ tokens }) {
|
|
13538
|
+
const body = this.parser.parse(tokens);
|
|
13539
|
+
return `<blockquote>
|
|
13540
|
+
${body}</blockquote>
|
|
13541
|
+
`;
|
|
13542
|
+
}
|
|
13543
|
+
html({ text }) {
|
|
13544
|
+
return text;
|
|
13545
|
+
}
|
|
13546
|
+
heading({ tokens, depth }) {
|
|
13547
|
+
return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
|
|
13548
|
+
`;
|
|
13549
|
+
}
|
|
13550
|
+
hr(token) {
|
|
13551
|
+
return "<hr>\n";
|
|
13552
|
+
}
|
|
13553
|
+
list(token) {
|
|
13554
|
+
const ordered = token.ordered;
|
|
13555
|
+
const start = token.start;
|
|
13556
|
+
let body = "";
|
|
13557
|
+
for (let j = 0; j < token.items.length; j++) {
|
|
13558
|
+
const item = token.items[j];
|
|
13559
|
+
body += this.listitem(item);
|
|
13560
|
+
}
|
|
13561
|
+
const type = ordered ? "ol" : "ul";
|
|
13562
|
+
const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
|
|
13563
|
+
return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
|
|
13564
|
+
}
|
|
13565
|
+
listitem(item) {
|
|
13566
|
+
let itemBody = "";
|
|
13567
|
+
if (item.task) {
|
|
13568
|
+
const checkbox = this.checkbox({ checked: !!item.checked });
|
|
13569
|
+
if (item.loose) {
|
|
13570
|
+
if (item.tokens[0]?.type === "paragraph") {
|
|
13571
|
+
item.tokens[0].text = checkbox + " " + item.tokens[0].text;
|
|
13572
|
+
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
|
|
13573
|
+
item.tokens[0].tokens[0].text = checkbox + " " + escape2(item.tokens[0].tokens[0].text);
|
|
13574
|
+
item.tokens[0].tokens[0].escaped = true;
|
|
13575
|
+
}
|
|
13576
|
+
} else {
|
|
13577
|
+
item.tokens.unshift({
|
|
13578
|
+
type: "text",
|
|
13579
|
+
raw: checkbox + " ",
|
|
13580
|
+
text: checkbox + " ",
|
|
13581
|
+
escaped: true
|
|
13582
|
+
});
|
|
13583
|
+
}
|
|
13584
|
+
} else {
|
|
13585
|
+
itemBody += checkbox + " ";
|
|
13586
|
+
}
|
|
13587
|
+
}
|
|
13588
|
+
itemBody += this.parser.parse(item.tokens, !!item.loose);
|
|
13589
|
+
return `<li>${itemBody}</li>
|
|
13590
|
+
`;
|
|
11588
13591
|
}
|
|
11589
|
-
})
|
|
13592
|
+
checkbox({ checked }) {
|
|
13593
|
+
return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
13594
|
+
}
|
|
13595
|
+
paragraph({ tokens }) {
|
|
13596
|
+
return `<p>${this.parser.parseInline(tokens)}</p>
|
|
13597
|
+
`;
|
|
13598
|
+
}
|
|
13599
|
+
table(token) {
|
|
13600
|
+
let header = "";
|
|
13601
|
+
let cell = "";
|
|
13602
|
+
for (let j = 0; j < token.header.length; j++) {
|
|
13603
|
+
cell += this.tablecell(token.header[j]);
|
|
13604
|
+
}
|
|
13605
|
+
header += this.tablerow({ text: cell });
|
|
13606
|
+
let body = "";
|
|
13607
|
+
for (let j = 0; j < token.rows.length; j++) {
|
|
13608
|
+
const row = token.rows[j];
|
|
13609
|
+
cell = "";
|
|
13610
|
+
for (let k = 0; k < row.length; k++) {
|
|
13611
|
+
cell += this.tablecell(row[k]);
|
|
13612
|
+
}
|
|
13613
|
+
body += this.tablerow({ text: cell });
|
|
13614
|
+
}
|
|
13615
|
+
if (body) body = `<tbody>${body}</tbody>`;
|
|
13616
|
+
return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
|
|
13617
|
+
}
|
|
13618
|
+
tablerow({ text }) {
|
|
13619
|
+
return `<tr>
|
|
13620
|
+
${text}</tr>
|
|
13621
|
+
`;
|
|
13622
|
+
}
|
|
13623
|
+
tablecell(token) {
|
|
13624
|
+
const content = this.parser.parseInline(token.tokens);
|
|
13625
|
+
const type = token.header ? "th" : "td";
|
|
13626
|
+
const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
|
|
13627
|
+
return tag2 + content + `</${type}>
|
|
13628
|
+
`;
|
|
13629
|
+
}
|
|
13630
|
+
/**
|
|
13631
|
+
* span level renderer
|
|
13632
|
+
*/
|
|
13633
|
+
strong({ tokens }) {
|
|
13634
|
+
return `<strong>${this.parser.parseInline(tokens)}</strong>`;
|
|
13635
|
+
}
|
|
13636
|
+
em({ tokens }) {
|
|
13637
|
+
return `<em>${this.parser.parseInline(tokens)}</em>`;
|
|
13638
|
+
}
|
|
13639
|
+
codespan({ text }) {
|
|
13640
|
+
return `<code>${escape2(text, true)}</code>`;
|
|
13641
|
+
}
|
|
13642
|
+
br(token) {
|
|
13643
|
+
return "<br>";
|
|
13644
|
+
}
|
|
13645
|
+
del({ tokens }) {
|
|
13646
|
+
return `<del>${this.parser.parseInline(tokens)}</del>`;
|
|
13647
|
+
}
|
|
13648
|
+
link({ href, title, tokens }) {
|
|
13649
|
+
const text = this.parser.parseInline(tokens);
|
|
13650
|
+
const cleanHref = cleanUrl(href);
|
|
13651
|
+
if (cleanHref === null) {
|
|
13652
|
+
return text;
|
|
13653
|
+
}
|
|
13654
|
+
href = cleanHref;
|
|
13655
|
+
let out = '<a href="' + href + '"';
|
|
13656
|
+
if (title) {
|
|
13657
|
+
out += ' title="' + escape2(title) + '"';
|
|
13658
|
+
}
|
|
13659
|
+
out += ">" + text + "</a>";
|
|
13660
|
+
return out;
|
|
13661
|
+
}
|
|
13662
|
+
image({ href, title, text, tokens }) {
|
|
13663
|
+
if (tokens) {
|
|
13664
|
+
text = this.parser.parseInline(tokens, this.parser.textRenderer);
|
|
13665
|
+
}
|
|
13666
|
+
const cleanHref = cleanUrl(href);
|
|
13667
|
+
if (cleanHref === null) {
|
|
13668
|
+
return escape2(text);
|
|
13669
|
+
}
|
|
13670
|
+
href = cleanHref;
|
|
13671
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
13672
|
+
if (title) {
|
|
13673
|
+
out += ` title="${escape2(title)}"`;
|
|
13674
|
+
}
|
|
13675
|
+
out += ">";
|
|
13676
|
+
return out;
|
|
13677
|
+
}
|
|
13678
|
+
text(token) {
|
|
13679
|
+
return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape2(token.text);
|
|
13680
|
+
}
|
|
13681
|
+
};
|
|
11590
13682
|
|
|
11591
|
-
|
|
11592
|
-
|
|
11593
|
-
|
|
11594
|
-
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
}
|
|
13683
|
+
// src/TextRenderer.ts
|
|
13684
|
+
var _TextRenderer = class {
|
|
13685
|
+
// no need for block level renderers
|
|
13686
|
+
strong({ text }) {
|
|
13687
|
+
return text;
|
|
13688
|
+
}
|
|
13689
|
+
em({ text }) {
|
|
13690
|
+
return text;
|
|
13691
|
+
}
|
|
13692
|
+
codespan({ text }) {
|
|
13693
|
+
return text;
|
|
13694
|
+
}
|
|
13695
|
+
del({ text }) {
|
|
13696
|
+
return text;
|
|
13697
|
+
}
|
|
13698
|
+
html({ text }) {
|
|
13699
|
+
return text;
|
|
13700
|
+
}
|
|
13701
|
+
text({ text }) {
|
|
13702
|
+
return text;
|
|
13703
|
+
}
|
|
13704
|
+
link({ text }) {
|
|
13705
|
+
return "" + text;
|
|
13706
|
+
}
|
|
13707
|
+
image({ text }) {
|
|
13708
|
+
return "" + text;
|
|
13709
|
+
}
|
|
13710
|
+
br() {
|
|
13711
|
+
return "";
|
|
13712
|
+
}
|
|
13713
|
+
};
|
|
11600
13714
|
|
|
11601
|
-
|
|
13715
|
+
// src/Parser.ts
|
|
13716
|
+
var _Parser = class __Parser {
|
|
13717
|
+
options;
|
|
13718
|
+
renderer;
|
|
13719
|
+
textRenderer;
|
|
13720
|
+
constructor(options2) {
|
|
13721
|
+
this.options = options2 || _defaults;
|
|
13722
|
+
this.options.renderer = this.options.renderer || new _Renderer();
|
|
13723
|
+
this.renderer = this.options.renderer;
|
|
13724
|
+
this.renderer.options = this.options;
|
|
13725
|
+
this.renderer.parser = this;
|
|
13726
|
+
this.textRenderer = new _TextRenderer();
|
|
13727
|
+
}
|
|
13728
|
+
/**
|
|
13729
|
+
* Static Parse Method
|
|
13730
|
+
*/
|
|
13731
|
+
static parse(tokens, options2) {
|
|
13732
|
+
const parser2 = new __Parser(options2);
|
|
13733
|
+
return parser2.parse(tokens);
|
|
13734
|
+
}
|
|
13735
|
+
/**
|
|
13736
|
+
* Static Parse Inline Method
|
|
13737
|
+
*/
|
|
13738
|
+
static parseInline(tokens, options2) {
|
|
13739
|
+
const parser2 = new __Parser(options2);
|
|
13740
|
+
return parser2.parseInline(tokens);
|
|
13741
|
+
}
|
|
13742
|
+
/**
|
|
13743
|
+
* Parse Loop
|
|
13744
|
+
*/
|
|
13745
|
+
parse(tokens, top = true) {
|
|
13746
|
+
let out = "";
|
|
13747
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
13748
|
+
const anyToken = tokens[i];
|
|
13749
|
+
if (this.options.extensions?.renderers?.[anyToken.type]) {
|
|
13750
|
+
const genericToken = anyToken;
|
|
13751
|
+
const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
|
|
13752
|
+
if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
|
|
13753
|
+
out += ret || "";
|
|
13754
|
+
continue;
|
|
13755
|
+
}
|
|
13756
|
+
}
|
|
13757
|
+
const token = anyToken;
|
|
13758
|
+
switch (token.type) {
|
|
13759
|
+
case "space": {
|
|
13760
|
+
out += this.renderer.space(token);
|
|
13761
|
+
continue;
|
|
13762
|
+
}
|
|
13763
|
+
case "hr": {
|
|
13764
|
+
out += this.renderer.hr(token);
|
|
13765
|
+
continue;
|
|
13766
|
+
}
|
|
13767
|
+
case "heading": {
|
|
13768
|
+
out += this.renderer.heading(token);
|
|
13769
|
+
continue;
|
|
13770
|
+
}
|
|
13771
|
+
case "code": {
|
|
13772
|
+
out += this.renderer.code(token);
|
|
13773
|
+
continue;
|
|
13774
|
+
}
|
|
13775
|
+
case "table": {
|
|
13776
|
+
out += this.renderer.table(token);
|
|
13777
|
+
continue;
|
|
13778
|
+
}
|
|
13779
|
+
case "blockquote": {
|
|
13780
|
+
out += this.renderer.blockquote(token);
|
|
13781
|
+
continue;
|
|
13782
|
+
}
|
|
13783
|
+
case "list": {
|
|
13784
|
+
out += this.renderer.list(token);
|
|
13785
|
+
continue;
|
|
13786
|
+
}
|
|
13787
|
+
case "html": {
|
|
13788
|
+
out += this.renderer.html(token);
|
|
13789
|
+
continue;
|
|
13790
|
+
}
|
|
13791
|
+
case "paragraph": {
|
|
13792
|
+
out += this.renderer.paragraph(token);
|
|
13793
|
+
continue;
|
|
13794
|
+
}
|
|
13795
|
+
case "text": {
|
|
13796
|
+
let textToken = token;
|
|
13797
|
+
let body = this.renderer.text(textToken);
|
|
13798
|
+
while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
|
|
13799
|
+
textToken = tokens[++i];
|
|
13800
|
+
body += "\n" + this.renderer.text(textToken);
|
|
13801
|
+
}
|
|
13802
|
+
if (top) {
|
|
13803
|
+
out += this.renderer.paragraph({
|
|
13804
|
+
type: "paragraph",
|
|
13805
|
+
raw: body,
|
|
13806
|
+
text: body,
|
|
13807
|
+
tokens: [{ type: "text", raw: body, text: body, escaped: true }]
|
|
13808
|
+
});
|
|
13809
|
+
} else {
|
|
13810
|
+
out += body;
|
|
13811
|
+
}
|
|
13812
|
+
continue;
|
|
13813
|
+
}
|
|
13814
|
+
default: {
|
|
13815
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
13816
|
+
if (this.options.silent) {
|
|
13817
|
+
console.error(errMsg);
|
|
13818
|
+
return "";
|
|
13819
|
+
} else {
|
|
13820
|
+
throw new Error(errMsg);
|
|
13821
|
+
}
|
|
13822
|
+
}
|
|
13823
|
+
}
|
|
13824
|
+
}
|
|
13825
|
+
return out;
|
|
13826
|
+
}
|
|
13827
|
+
/**
|
|
13828
|
+
* Parse Inline Tokens
|
|
13829
|
+
*/
|
|
13830
|
+
parseInline(tokens, renderer = this.renderer) {
|
|
13831
|
+
let out = "";
|
|
13832
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
13833
|
+
const anyToken = tokens[i];
|
|
13834
|
+
if (this.options.extensions?.renderers?.[anyToken.type]) {
|
|
13835
|
+
const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
|
|
13836
|
+
if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
|
|
13837
|
+
out += ret || "";
|
|
13838
|
+
continue;
|
|
13839
|
+
}
|
|
13840
|
+
}
|
|
13841
|
+
const token = anyToken;
|
|
13842
|
+
switch (token.type) {
|
|
13843
|
+
case "escape": {
|
|
13844
|
+
out += renderer.text(token);
|
|
13845
|
+
break;
|
|
13846
|
+
}
|
|
13847
|
+
case "html": {
|
|
13848
|
+
out += renderer.html(token);
|
|
13849
|
+
break;
|
|
13850
|
+
}
|
|
13851
|
+
case "link": {
|
|
13852
|
+
out += renderer.link(token);
|
|
13853
|
+
break;
|
|
13854
|
+
}
|
|
13855
|
+
case "image": {
|
|
13856
|
+
out += renderer.image(token);
|
|
13857
|
+
break;
|
|
13858
|
+
}
|
|
13859
|
+
case "strong": {
|
|
13860
|
+
out += renderer.strong(token);
|
|
13861
|
+
break;
|
|
13862
|
+
}
|
|
13863
|
+
case "em": {
|
|
13864
|
+
out += renderer.em(token);
|
|
13865
|
+
break;
|
|
13866
|
+
}
|
|
13867
|
+
case "codespan": {
|
|
13868
|
+
out += renderer.codespan(token);
|
|
13869
|
+
break;
|
|
13870
|
+
}
|
|
13871
|
+
case "br": {
|
|
13872
|
+
out += renderer.br(token);
|
|
13873
|
+
break;
|
|
13874
|
+
}
|
|
13875
|
+
case "del": {
|
|
13876
|
+
out += renderer.del(token);
|
|
13877
|
+
break;
|
|
13878
|
+
}
|
|
13879
|
+
case "text": {
|
|
13880
|
+
out += renderer.text(token);
|
|
13881
|
+
break;
|
|
13882
|
+
}
|
|
13883
|
+
default: {
|
|
13884
|
+
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
13885
|
+
if (this.options.silent) {
|
|
13886
|
+
console.error(errMsg);
|
|
13887
|
+
return "";
|
|
13888
|
+
} else {
|
|
13889
|
+
throw new Error(errMsg);
|
|
13890
|
+
}
|
|
13891
|
+
}
|
|
13892
|
+
}
|
|
13893
|
+
}
|
|
13894
|
+
return out;
|
|
13895
|
+
}
|
|
13896
|
+
};
|
|
11602
13897
|
|
|
11603
|
-
|
|
13898
|
+
// src/Hooks.ts
|
|
13899
|
+
var _Hooks = class {
|
|
13900
|
+
options;
|
|
13901
|
+
block;
|
|
13902
|
+
constructor(options2) {
|
|
13903
|
+
this.options = options2 || _defaults;
|
|
13904
|
+
}
|
|
13905
|
+
static passThroughHooks = /* @__PURE__ */ new Set([
|
|
13906
|
+
"preprocess",
|
|
13907
|
+
"postprocess",
|
|
13908
|
+
"processAllTokens"
|
|
13909
|
+
]);
|
|
13910
|
+
/**
|
|
13911
|
+
* Process markdown before marked
|
|
13912
|
+
*/
|
|
13913
|
+
preprocess(markdown) {
|
|
13914
|
+
return markdown;
|
|
13915
|
+
}
|
|
13916
|
+
/**
|
|
13917
|
+
* Process HTML after marked is finished
|
|
13918
|
+
*/
|
|
13919
|
+
postprocess(html2) {
|
|
13920
|
+
return html2;
|
|
13921
|
+
}
|
|
13922
|
+
/**
|
|
13923
|
+
* Process all tokens before walk tokens
|
|
13924
|
+
*/
|
|
13925
|
+
processAllTokens(tokens) {
|
|
13926
|
+
return tokens;
|
|
13927
|
+
}
|
|
13928
|
+
/**
|
|
13929
|
+
* Provide function to tokenize markdown
|
|
13930
|
+
*/
|
|
13931
|
+
provideLexer() {
|
|
13932
|
+
return this.block ? _Lexer.lex : _Lexer.lexInline;
|
|
13933
|
+
}
|
|
13934
|
+
/**
|
|
13935
|
+
* Provide function to parse tokens
|
|
13936
|
+
*/
|
|
13937
|
+
provideParser() {
|
|
13938
|
+
return this.block ? _Parser.parse : _Parser.parseInline;
|
|
13939
|
+
}
|
|
13940
|
+
};
|
|
13941
|
+
|
|
13942
|
+
// src/Instance.ts
|
|
13943
|
+
var Marked = class {
|
|
13944
|
+
defaults = _getDefaults();
|
|
13945
|
+
options = this.setOptions;
|
|
13946
|
+
parse = this.parseMarkdown(true);
|
|
13947
|
+
parseInline = this.parseMarkdown(false);
|
|
13948
|
+
Parser = _Parser;
|
|
13949
|
+
Renderer = _Renderer;
|
|
13950
|
+
TextRenderer = _TextRenderer;
|
|
13951
|
+
Lexer = _Lexer;
|
|
13952
|
+
Tokenizer = _Tokenizer;
|
|
13953
|
+
Hooks = _Hooks;
|
|
13954
|
+
constructor(...args) {
|
|
13955
|
+
this.use(...args);
|
|
13956
|
+
}
|
|
13957
|
+
/**
|
|
13958
|
+
* Run callback for every token
|
|
13959
|
+
*/
|
|
13960
|
+
walkTokens(tokens, callback) {
|
|
13961
|
+
let values = [];
|
|
13962
|
+
for (const token of tokens) {
|
|
13963
|
+
values = values.concat(callback.call(this, token));
|
|
13964
|
+
switch (token.type) {
|
|
13965
|
+
case "table": {
|
|
13966
|
+
const tableToken = token;
|
|
13967
|
+
for (const cell of tableToken.header) {
|
|
13968
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
13969
|
+
}
|
|
13970
|
+
for (const row of tableToken.rows) {
|
|
13971
|
+
for (const cell of row) {
|
|
13972
|
+
values = values.concat(this.walkTokens(cell.tokens, callback));
|
|
13973
|
+
}
|
|
13974
|
+
}
|
|
13975
|
+
break;
|
|
13976
|
+
}
|
|
13977
|
+
case "list": {
|
|
13978
|
+
const listToken = token;
|
|
13979
|
+
values = values.concat(this.walkTokens(listToken.items, callback));
|
|
13980
|
+
break;
|
|
13981
|
+
}
|
|
13982
|
+
default: {
|
|
13983
|
+
const genericToken = token;
|
|
13984
|
+
if (this.defaults.extensions?.childTokens?.[genericToken.type]) {
|
|
13985
|
+
this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
|
|
13986
|
+
const tokens2 = genericToken[childTokens].flat(Infinity);
|
|
13987
|
+
values = values.concat(this.walkTokens(tokens2, callback));
|
|
13988
|
+
});
|
|
13989
|
+
} else if (genericToken.tokens) {
|
|
13990
|
+
values = values.concat(this.walkTokens(genericToken.tokens, callback));
|
|
13991
|
+
}
|
|
13992
|
+
}
|
|
13993
|
+
}
|
|
13994
|
+
}
|
|
13995
|
+
return values;
|
|
13996
|
+
}
|
|
13997
|
+
use(...args) {
|
|
13998
|
+
const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
13999
|
+
args.forEach((pack) => {
|
|
14000
|
+
const opts = { ...pack };
|
|
14001
|
+
opts.async = this.defaults.async || opts.async || false;
|
|
14002
|
+
if (pack.extensions) {
|
|
14003
|
+
pack.extensions.forEach((ext) => {
|
|
14004
|
+
if (!ext.name) {
|
|
14005
|
+
throw new Error("extension name required");
|
|
14006
|
+
}
|
|
14007
|
+
if ("renderer" in ext) {
|
|
14008
|
+
const prevRenderer = extensions.renderers[ext.name];
|
|
14009
|
+
if (prevRenderer) {
|
|
14010
|
+
extensions.renderers[ext.name] = function(...args2) {
|
|
14011
|
+
let ret = ext.renderer.apply(this, args2);
|
|
14012
|
+
if (ret === false) {
|
|
14013
|
+
ret = prevRenderer.apply(this, args2);
|
|
14014
|
+
}
|
|
14015
|
+
return ret;
|
|
14016
|
+
};
|
|
14017
|
+
} else {
|
|
14018
|
+
extensions.renderers[ext.name] = ext.renderer;
|
|
14019
|
+
}
|
|
14020
|
+
}
|
|
14021
|
+
if ("tokenizer" in ext) {
|
|
14022
|
+
if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
|
|
14023
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
14024
|
+
}
|
|
14025
|
+
const extLevel = extensions[ext.level];
|
|
14026
|
+
if (extLevel) {
|
|
14027
|
+
extLevel.unshift(ext.tokenizer);
|
|
14028
|
+
} else {
|
|
14029
|
+
extensions[ext.level] = [ext.tokenizer];
|
|
14030
|
+
}
|
|
14031
|
+
if (ext.start) {
|
|
14032
|
+
if (ext.level === "block") {
|
|
14033
|
+
if (extensions.startBlock) {
|
|
14034
|
+
extensions.startBlock.push(ext.start);
|
|
14035
|
+
} else {
|
|
14036
|
+
extensions.startBlock = [ext.start];
|
|
14037
|
+
}
|
|
14038
|
+
} else if (ext.level === "inline") {
|
|
14039
|
+
if (extensions.startInline) {
|
|
14040
|
+
extensions.startInline.push(ext.start);
|
|
14041
|
+
} else {
|
|
14042
|
+
extensions.startInline = [ext.start];
|
|
14043
|
+
}
|
|
14044
|
+
}
|
|
14045
|
+
}
|
|
14046
|
+
}
|
|
14047
|
+
if ("childTokens" in ext && ext.childTokens) {
|
|
14048
|
+
extensions.childTokens[ext.name] = ext.childTokens;
|
|
14049
|
+
}
|
|
14050
|
+
});
|
|
14051
|
+
opts.extensions = extensions;
|
|
14052
|
+
}
|
|
14053
|
+
if (pack.renderer) {
|
|
14054
|
+
const renderer = this.defaults.renderer || new _Renderer(this.defaults);
|
|
14055
|
+
for (const prop in pack.renderer) {
|
|
14056
|
+
if (!(prop in renderer)) {
|
|
14057
|
+
throw new Error(`renderer '${prop}' does not exist`);
|
|
14058
|
+
}
|
|
14059
|
+
if (["options", "parser"].includes(prop)) {
|
|
14060
|
+
continue;
|
|
14061
|
+
}
|
|
14062
|
+
const rendererProp = prop;
|
|
14063
|
+
const rendererFunc = pack.renderer[rendererProp];
|
|
14064
|
+
const prevRenderer = renderer[rendererProp];
|
|
14065
|
+
renderer[rendererProp] = (...args2) => {
|
|
14066
|
+
let ret = rendererFunc.apply(renderer, args2);
|
|
14067
|
+
if (ret === false) {
|
|
14068
|
+
ret = prevRenderer.apply(renderer, args2);
|
|
14069
|
+
}
|
|
14070
|
+
return ret || "";
|
|
14071
|
+
};
|
|
14072
|
+
}
|
|
14073
|
+
opts.renderer = renderer;
|
|
14074
|
+
}
|
|
14075
|
+
if (pack.tokenizer) {
|
|
14076
|
+
const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
|
|
14077
|
+
for (const prop in pack.tokenizer) {
|
|
14078
|
+
if (!(prop in tokenizer)) {
|
|
14079
|
+
throw new Error(`tokenizer '${prop}' does not exist`);
|
|
14080
|
+
}
|
|
14081
|
+
if (["options", "rules", "lexer"].includes(prop)) {
|
|
14082
|
+
continue;
|
|
14083
|
+
}
|
|
14084
|
+
const tokenizerProp = prop;
|
|
14085
|
+
const tokenizerFunc = pack.tokenizer[tokenizerProp];
|
|
14086
|
+
const prevTokenizer = tokenizer[tokenizerProp];
|
|
14087
|
+
tokenizer[tokenizerProp] = (...args2) => {
|
|
14088
|
+
let ret = tokenizerFunc.apply(tokenizer, args2);
|
|
14089
|
+
if (ret === false) {
|
|
14090
|
+
ret = prevTokenizer.apply(tokenizer, args2);
|
|
14091
|
+
}
|
|
14092
|
+
return ret;
|
|
14093
|
+
};
|
|
14094
|
+
}
|
|
14095
|
+
opts.tokenizer = tokenizer;
|
|
14096
|
+
}
|
|
14097
|
+
if (pack.hooks) {
|
|
14098
|
+
const hooks = this.defaults.hooks || new _Hooks();
|
|
14099
|
+
for (const prop in pack.hooks) {
|
|
14100
|
+
if (!(prop in hooks)) {
|
|
14101
|
+
throw new Error(`hook '${prop}' does not exist`);
|
|
14102
|
+
}
|
|
14103
|
+
if (["options", "block"].includes(prop)) {
|
|
14104
|
+
continue;
|
|
14105
|
+
}
|
|
14106
|
+
const hooksProp = prop;
|
|
14107
|
+
const hooksFunc = pack.hooks[hooksProp];
|
|
14108
|
+
const prevHook = hooks[hooksProp];
|
|
14109
|
+
if (_Hooks.passThroughHooks.has(prop)) {
|
|
14110
|
+
hooks[hooksProp] = (arg) => {
|
|
14111
|
+
if (this.defaults.async) {
|
|
14112
|
+
return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
|
|
14113
|
+
return prevHook.call(hooks, ret2);
|
|
14114
|
+
});
|
|
14115
|
+
}
|
|
14116
|
+
const ret = hooksFunc.call(hooks, arg);
|
|
14117
|
+
return prevHook.call(hooks, ret);
|
|
14118
|
+
};
|
|
14119
|
+
} else {
|
|
14120
|
+
hooks[hooksProp] = (...args2) => {
|
|
14121
|
+
let ret = hooksFunc.apply(hooks, args2);
|
|
14122
|
+
if (ret === false) {
|
|
14123
|
+
ret = prevHook.apply(hooks, args2);
|
|
14124
|
+
}
|
|
14125
|
+
return ret;
|
|
14126
|
+
};
|
|
14127
|
+
}
|
|
14128
|
+
}
|
|
14129
|
+
opts.hooks = hooks;
|
|
14130
|
+
}
|
|
14131
|
+
if (pack.walkTokens) {
|
|
14132
|
+
const walkTokens2 = this.defaults.walkTokens;
|
|
14133
|
+
const packWalktokens = pack.walkTokens;
|
|
14134
|
+
opts.walkTokens = function(token) {
|
|
14135
|
+
let values = [];
|
|
14136
|
+
values.push(packWalktokens.call(this, token));
|
|
14137
|
+
if (walkTokens2) {
|
|
14138
|
+
values = values.concat(walkTokens2.call(this, token));
|
|
14139
|
+
}
|
|
14140
|
+
return values;
|
|
14141
|
+
};
|
|
14142
|
+
}
|
|
14143
|
+
this.defaults = { ...this.defaults, ...opts };
|
|
14144
|
+
});
|
|
14145
|
+
return this;
|
|
14146
|
+
}
|
|
14147
|
+
setOptions(opt) {
|
|
14148
|
+
this.defaults = { ...this.defaults, ...opt };
|
|
14149
|
+
return this;
|
|
14150
|
+
}
|
|
14151
|
+
lexer(src, options2) {
|
|
14152
|
+
return _Lexer.lex(src, options2 ?? this.defaults);
|
|
14153
|
+
}
|
|
14154
|
+
parser(tokens, options2) {
|
|
14155
|
+
return _Parser.parse(tokens, options2 ?? this.defaults);
|
|
14156
|
+
}
|
|
14157
|
+
parseMarkdown(blockType) {
|
|
14158
|
+
const parse2 = (src, options2) => {
|
|
14159
|
+
const origOpt = { ...options2 };
|
|
14160
|
+
const opt = { ...this.defaults, ...origOpt };
|
|
14161
|
+
const throwError = this.onError(!!opt.silent, !!opt.async);
|
|
14162
|
+
if (this.defaults.async === true && origOpt.async === false) {
|
|
14163
|
+
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."));
|
|
14164
|
+
}
|
|
14165
|
+
if (typeof src === "undefined" || src === null) {
|
|
14166
|
+
return throwError(new Error("marked(): input parameter is undefined or null"));
|
|
14167
|
+
}
|
|
14168
|
+
if (typeof src !== "string") {
|
|
14169
|
+
return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
|
|
14170
|
+
}
|
|
14171
|
+
if (opt.hooks) {
|
|
14172
|
+
opt.hooks.options = opt;
|
|
14173
|
+
opt.hooks.block = blockType;
|
|
14174
|
+
}
|
|
14175
|
+
const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
|
|
14176
|
+
const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
|
|
14177
|
+
if (opt.async) {
|
|
14178
|
+
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
|
|
14179
|
+
}
|
|
14180
|
+
try {
|
|
14181
|
+
if (opt.hooks) {
|
|
14182
|
+
src = opt.hooks.preprocess(src);
|
|
14183
|
+
}
|
|
14184
|
+
let tokens = lexer2(src, opt);
|
|
14185
|
+
if (opt.hooks) {
|
|
14186
|
+
tokens = opt.hooks.processAllTokens(tokens);
|
|
14187
|
+
}
|
|
14188
|
+
if (opt.walkTokens) {
|
|
14189
|
+
this.walkTokens(tokens, opt.walkTokens);
|
|
14190
|
+
}
|
|
14191
|
+
let html2 = parser2(tokens, opt);
|
|
14192
|
+
if (opt.hooks) {
|
|
14193
|
+
html2 = opt.hooks.postprocess(html2);
|
|
14194
|
+
}
|
|
14195
|
+
return html2;
|
|
14196
|
+
} catch (e) {
|
|
14197
|
+
return throwError(e);
|
|
14198
|
+
}
|
|
14199
|
+
};
|
|
14200
|
+
return parse2;
|
|
14201
|
+
}
|
|
14202
|
+
onError(silent, async) {
|
|
14203
|
+
return (e) => {
|
|
14204
|
+
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
|
|
14205
|
+
if (silent) {
|
|
14206
|
+
const msg = "<p>An error occurred:</p><pre>" + escape2(e.message + "", true) + "</pre>";
|
|
14207
|
+
if (async) {
|
|
14208
|
+
return Promise.resolve(msg);
|
|
14209
|
+
}
|
|
14210
|
+
return msg;
|
|
14211
|
+
}
|
|
14212
|
+
if (async) {
|
|
14213
|
+
return Promise.reject(e);
|
|
14214
|
+
}
|
|
14215
|
+
throw e;
|
|
14216
|
+
};
|
|
14217
|
+
}
|
|
14218
|
+
};
|
|
14219
|
+
|
|
14220
|
+
// src/marked.ts
|
|
14221
|
+
var markedInstance = new Marked();
|
|
14222
|
+
function marked(src, opt) {
|
|
14223
|
+
return markedInstance.parse(src, opt);
|
|
14224
|
+
}
|
|
14225
|
+
marked.options = marked.setOptions = function(options2) {
|
|
14226
|
+
markedInstance.setOptions(options2);
|
|
14227
|
+
marked.defaults = markedInstance.defaults;
|
|
14228
|
+
changeDefaults(marked.defaults);
|
|
14229
|
+
return marked;
|
|
14230
|
+
};
|
|
14231
|
+
marked.getDefaults = _getDefaults;
|
|
14232
|
+
marked.defaults = _defaults;
|
|
14233
|
+
marked.use = function(...args) {
|
|
14234
|
+
markedInstance.use(...args);
|
|
14235
|
+
marked.defaults = markedInstance.defaults;
|
|
14236
|
+
changeDefaults(marked.defaults);
|
|
14237
|
+
return marked;
|
|
14238
|
+
};
|
|
14239
|
+
marked.walkTokens = function(tokens, callback) {
|
|
14240
|
+
return markedInstance.walkTokens(tokens, callback);
|
|
14241
|
+
};
|
|
14242
|
+
marked.parseInline = markedInstance.parseInline;
|
|
14243
|
+
marked.Parser = _Parser;
|
|
14244
|
+
marked.parser = _Parser.parse;
|
|
14245
|
+
marked.Renderer = _Renderer;
|
|
14246
|
+
marked.TextRenderer = _TextRenderer;
|
|
14247
|
+
marked.Lexer = _Lexer;
|
|
14248
|
+
marked.lexer = _Lexer.lex;
|
|
14249
|
+
marked.Tokenizer = _Tokenizer;
|
|
14250
|
+
marked.Hooks = _Hooks;
|
|
14251
|
+
marked.parse = marked;
|
|
14252
|
+
var options = marked.options;
|
|
14253
|
+
var setOptions = marked.setOptions;
|
|
14254
|
+
var use = marked.use;
|
|
14255
|
+
var walkTokens = marked.walkTokens;
|
|
14256
|
+
var parseInline = marked.parseInline;
|
|
14257
|
+
var parse = marked;
|
|
14258
|
+
var parser = _Parser.parse;
|
|
14259
|
+
var lexer = _Lexer.lex;
|
|
14260
|
+
//# sourceMappingURL=marked.cjs.map
|
|
11604
14261
|
|
|
11605
|
-
})();
|
|
11606
14262
|
|
|
14263
|
+
/***/ })
|
|
14264
|
+
|
|
14265
|
+
/******/ });
|
|
14266
|
+
/************************************************************************/
|
|
14267
|
+
/******/ // The module cache
|
|
14268
|
+
/******/ var __webpack_module_cache__ = {};
|
|
14269
|
+
/******/
|
|
14270
|
+
/******/ // The require function
|
|
14271
|
+
/******/ function __webpack_require__(moduleId) {
|
|
14272
|
+
/******/ // Check if module is in cache
|
|
14273
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
14274
|
+
/******/ if (cachedModule !== undefined) {
|
|
14275
|
+
/******/ return cachedModule.exports;
|
|
14276
|
+
/******/ }
|
|
14277
|
+
/******/ // Create a new module (and put it into the cache)
|
|
14278
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
14279
|
+
/******/ // no module.id needed
|
|
14280
|
+
/******/ // no module.loaded needed
|
|
14281
|
+
/******/ exports: {}
|
|
14282
|
+
/******/ };
|
|
14283
|
+
/******/
|
|
14284
|
+
/******/ // Execute the module function
|
|
14285
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
14286
|
+
/******/
|
|
14287
|
+
/******/ // Return the exports of the module
|
|
14288
|
+
/******/ return module.exports;
|
|
14289
|
+
/******/ }
|
|
14290
|
+
/******/
|
|
14291
|
+
/************************************************************************/
|
|
14292
|
+
/******/ /* webpack/runtime/global */
|
|
14293
|
+
/******/ (() => {
|
|
14294
|
+
/******/ __webpack_require__.g = (function() {
|
|
14295
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
14296
|
+
/******/ try {
|
|
14297
|
+
/******/ return this || new Function('return this')();
|
|
14298
|
+
/******/ } catch (e) {
|
|
14299
|
+
/******/ if (typeof window === 'object') return window;
|
|
14300
|
+
/******/ }
|
|
14301
|
+
/******/ })();
|
|
14302
|
+
/******/ })();
|
|
14303
|
+
/******/
|
|
14304
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
14305
|
+
/******/ (() => {
|
|
14306
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
14307
|
+
/******/ })();
|
|
14308
|
+
/******/
|
|
14309
|
+
/************************************************************************/
|
|
14310
|
+
/******/
|
|
14311
|
+
/******/ // startup
|
|
14312
|
+
/******/ // Load entry module and return exports
|
|
14313
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
14314
|
+
/******/ var __webpack_exports__ = __webpack_require__("./frontend/src/index.js");
|
|
14315
|
+
/******/
|
|
11607
14316
|
/******/ })()
|
|
11608
14317
|
;
|