n8n-editor-ui 1.67.0 → 1.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-RSY0bJ42.js +57 -0
- package/dist/assets/{AuthView-DmC24d7S.js → AuthView-CrxWnr-e.js} +1 -1
- package/dist/assets/CanvasChat-D1ZEiEqI.js +4167 -0
- package/dist/assets/CanvasChat-DKeWqqZz.css +730 -0
- package/dist/assets/{CanvasControls-BPXQqeeO.js → CanvasControls-C-GYIweg.js} +6 -5
- package/dist/assets/{ChangePasswordView-SC3n2vJc.js → ChangePasswordView-BcJsOCsw.js} +2 -2
- package/dist/assets/CollectionParameter-BCa4NW-h.js +4 -0
- package/dist/assets/{CredentialsView-B3m9CpEC.js → CredentialsView-C0lKel2q.js} +12 -28
- package/dist/assets/{ErrorView-D6M8WlVP.js → ErrorView-4g2OU1Dw.js} +5 -4
- package/dist/assets/{ExecutionsFilter-DlZH8tDW.js → ExecutionsTime.vue_vue_type_script_setup_true_lang-Ce7AgzqR.js} +41 -41
- package/dist/assets/{ExecutionsView-DaHtYmF4.js → ExecutionsView-BjrC38YB.js} +28 -37
- package/dist/assets/{ExecutionsView-Dfy6JMwb.css → ExecutionsView-DlxsqdiC.css} +44 -38
- package/dist/assets/{FileSaver.min-DNytcjKT.js → FileSaver.min-Kzijnshy.js} +1 -1
- package/dist/assets/{FixedCollectionParameter-CypxYAFK.js → FixedCollectionParameter-BlCn1bdn.js} +1 -1
- package/dist/assets/{ForgotMyPasswordView-BJ6gd5CS.js → ForgotMyPasswordView-DM0y4hNn.js} +2 -2
- package/dist/assets/{MainHeader-D56WYRMG.css → MainHeader-CgL_r4xK.css} +78 -24
- package/dist/assets/{MainHeader-DniXcGMK.js → MainHeader-D1PkO9vp.js} +154 -45
- package/dist/assets/{MainSidebar-NwOfijmV.js → MainSidebar-CGlOacQQ.js} +63 -134
- package/dist/assets/{MainSidebar-BRYJRpOA.css → MainSidebar-DL53w2zU.css} +37 -21
- package/dist/assets/{NodeCreation-Ce1ct2i3.js → NodeCreation-yT3JgYis.js} +15 -11
- package/dist/assets/{NodeCreator-DMLTbzAt.js → NodeCreator-CeYHZgYz.js} +66 -64
- package/dist/assets/{NodeViewSwitcher-B9JUn3eY.js → NodeViewSwitcher-DJ9GWTwy.js} +2913 -2815
- package/dist/assets/{NodeViewSwitcher-CnP5aYyg.css → NodeViewSwitcher-s2TUlOvE.css} +136 -115
- package/dist/assets/{ProjectCardBadge-C3QU-WmO.js → ProjectCardBadge-dGORr1ye.js} +1 -1
- package/dist/assets/ProjectHeader-CFoxyI0_.js +216 -0
- package/dist/assets/ProjectHeader-CTK_rV3h.css +28 -0
- package/dist/assets/{ProjectSettings-BvcEg3hx.js → ProjectSettings-Bgl_JGoT.js} +27 -55
- package/dist/assets/{PushConnectionTracker.vue_vue_type_script_setup_true_lang-DlJOpf7N.js → PushConnectionTracker.vue_vue_type_script_setup_true_lang-BabWwsdK.js} +1 -1
- package/dist/assets/{ResourcesListLayout-Bc4__nvw.js → ResourcesListLayout-B1KB8fTB.js} +3 -46
- package/dist/assets/{ResourcesListLayout-Ci-K1bH3.css → ResourcesListLayout-BuxiQpsj.css} +8 -8
- package/dist/assets/{RunDataJson-ea5u1EeD.js → RunDataJson-BQRWHoEA.js} +12 -12
- package/dist/assets/{RunDataJsonActions-Dflnt8gK.js → RunDataJsonActions-BrABJ_1T.js} +3 -1
- package/dist/assets/{RunDataSearch-DKNVmEqa.js → RunDataSearch-kYhI-gst.js} +2 -2
- package/dist/assets/RunDataTable-BUXF-nH1.js +673 -0
- package/dist/assets/{RunDataTable-ZwoYenSI.css → RunDataTable-enskmmU4.css} +41 -35
- package/dist/assets/{SamlOnboarding-CPvGRYUg.js → SamlOnboarding-DI1aQpmq.js} +2 -2
- package/dist/assets/{SettingsApiView-BFj9fDL9.js → SettingsApiView-DfdFSKxW.js} +1 -1
- package/dist/assets/{SettingsCommunityNodesView-nJFDrtIR.js → SettingsCommunityNodesView-CFGZW601.js} +3 -3
- package/dist/assets/{SettingsExternalSecrets-0-mj45K-.js → SettingsExternalSecrets-CzMuyldc.js} +1 -1
- package/dist/assets/{SettingsLdapView-BhBxX72w.js → SettingsLdapView-B_aMpNa8.js} +1 -1
- package/dist/assets/{SettingsLogStreamingView-CmEJrEOv.js → SettingsLogStreamingView-ByHGVzc1.js} +1 -1
- package/dist/assets/{SettingsPersonalView-C__lC8Vv.js → SettingsPersonalView-BpmD5Kqd.js} +1 -1
- package/dist/assets/{SettingsSourceControl-CMoS5B5P.js → SettingsSourceControl-DeYPQUBX.js} +1 -1
- package/dist/assets/{SettingsSso-DJfrl1Rl.js → SettingsSso-1JSXMGCZ.js} +1 -1
- package/dist/assets/{SettingsUsageAndPlan-CWQ5uVrG.js → SettingsUsageAndPlan-CsUyzTgS.js} +1 -1
- package/dist/assets/{SettingsUsersView-Cvr6Digb.js → SettingsUsersView-iOvCX1d1.js} +1 -1
- package/dist/assets/{SettingsView-DtGga45F.js → SettingsView-WL2khukL.js} +1 -1
- package/dist/assets/{SetupView-DkJH96By.js → SetupView-CeWIEjRa.js} +2 -2
- package/dist/assets/{SetupWorkflowCredentialsButton-C1Jv_-V5.js → SetupWorkflowCredentialsButton-CqzxyhWQ.js} +1 -1
- package/dist/assets/{SetupWorkflowFromTemplateView-WSzVMgC4.js → SetupWorkflowFromTemplateView-HpPUcyfA.js} +3 -3
- package/dist/assets/{SigninView-xej8y-Vu.js → SigninView-DuDYUyp-.js} +2 -2
- package/dist/assets/{SignoutView-Dc8fBBIm.js → SignoutView-4gm8WRHv.js} +1 -1
- package/dist/assets/{SignupView-CKA28Xc8.js → SignupView-DjY8EclM.js} +2 -2
- package/dist/assets/{TemplateDetails-Pi49rFlS.js → TemplateDetails-CbfdJ3Zu.js} +2 -2
- package/dist/assets/{TemplateList-BncQL783.js → TemplateList-Cc_F6A58.js} +3 -2
- package/dist/assets/{TemplatesCollectionView-C9PKPo5y.js → TemplatesCollectionView-BcZLoIe4.js} +7 -7
- package/dist/assets/{TemplatesSearchView-65taIL-M.js → TemplatesSearchView-BMfAKWhL.js} +3 -3
- package/dist/assets/{TemplatesView-DkP9JWHk.js → TemplatesView-BP0ATqW_.js} +3 -2
- package/dist/assets/{TemplatesWorkflowView-B5uc0BtL.js → TemplatesWorkflowView-CPkYdvfj.js} +5 -5
- package/dist/assets/{VariablesView-DV1-KgmN.js → VariablesView-Bxnz2qAN.js} +12 -13
- package/dist/assets/{VariablesView-BPKo50HJ.css → VariablesView-meR15bnW.css} +18 -18
- package/dist/assets/{WorkerView-5P9lg6ew.js → WorkerView-DReO6N8w.js} +11 -10
- package/dist/assets/{WorkflowActivator-Dc_Un-Af.js → WorkflowActivator-B0RYBWDC.js} +2 -2
- package/dist/assets/{WorkflowExecutionsInfoAccordion-BLyC6lr5.js → WorkflowExecutionsInfoAccordion-DQl3QT6U.js} +7 -6
- package/dist/assets/{WorkflowExecutionsLandingPage-Dsa6Bgkn.js → WorkflowExecutionsLandingPage-B47g0omt.js} +2 -2
- package/dist/assets/{WorkflowExecutionsPreview-B_X-enUV.js → WorkflowExecutionsPreview-3ZPhGB00.js} +12 -11
- package/dist/assets/{WorkflowExecutionsView-Bkz3Sig-.js → WorkflowExecutionsView-C2F5tFjz.js} +18 -9
- package/dist/assets/{WorkflowExecutionsView-B8x2-iOd.css → WorkflowExecutionsView-CepgQyRt.css} +9 -1
- package/dist/assets/{WorkflowHistory-BiPMooAv.js → WorkflowHistory-tThywxbZ.js} +3 -3
- package/dist/assets/{WorkflowOnboardingView-XHuS6lCs.js → WorkflowOnboardingView-DJv_JU2k.js} +32 -1
- package/dist/assets/{WorkflowPreview-DxZKd23H.js → WorkflowPreview-DawY1Fi4.js} +1 -1
- package/dist/assets/{WorkflowsView-BBaLVqJs.js → WorkflowsView-DA1gqPuM.js} +16 -58
- package/dist/assets/buttons.esm-BOkmSohe.js +477 -0
- package/dist/assets/{index-7YFQEQmt.js → index-BcRlEQdt.js} +96643 -102180
- package/dist/assets/{index-BFH_KxyA.css → index-CSJeF569.css} +259 -726
- package/dist/assets/{pushConnection.store-DbprXL-x.js → pushConnection.store-C9cp1cmF.js} +1 -1
- package/dist/assets/{templateActions-QFQD8amJ.js → templateActions-BM1BlED1.js} +1 -1
- package/dist/assets/{useBugReporting-IgwBNdXI.js → useBugReporting-D4ibEI2f.js} +1 -1
- package/dist/assets/{useExecutionDebugging-CLORI_Ma.js → useExecutionDebugging-B9k8m7iG.js} +1 -1
- package/dist/assets/useExecutionHelpers-DYE5_K78.js +113 -0
- package/dist/assets/useGlobalEntityCreation-DtWHHZf8.js +168 -0
- package/dist/assets/{useNodeViewVersionSwitcher-CJLQ5lju.js → useNodeViewVersionSwitcher-CSLoLUvW.js} +1 -1
- package/dist/assets/{usePushConnection-DjPgTuLw.js → usePushConnection-BLi9GBVo.js} +63 -111
- package/dist/assets/{RunDataAi-x30tU8-0.css → useRunWorkflow-DH7ZzA8t.css} +97 -57
- package/dist/assets/useRunWorkflow-DOJBXbbW.js +3631 -0
- package/dist/assets/{useWorkflowActivate-D_gK841h.js → useWorkflowActivate-DmBELETa.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/AnnotationTagsDropdown.ee.vue_vue_type_script_setup_true_lang-DbabN_I2.js +0 -115
- package/dist/assets/CollectionParameter-Odk28FRT.js +0 -4
- package/dist/assets/ProjectTabs-DjoIePoM.css +0 -3
- package/dist/assets/ProjectTabs-Dve3xFj9.js +0 -88
- package/dist/assets/ResourceListHeader-B2sxe6HT.js +0 -66
- package/dist/assets/ResourceListHeader-DgE1VPUF.css +0 -19
- package/dist/assets/RunDataAi-BKu1beM6.js +0 -1539
- package/dist/assets/RunDataTable-DISLWxMc.js +0 -608
- package/dist/assets/dateFormatter-C53K7zEn.js +0 -21
- /package/dist/assets/{ExecutionsFilter-DVxRt-Pz.css → ExecutionsTime-DVxRt-Pz.css} +0 -0
|
@@ -0,0 +1,3631 @@
|
|
|
1
|
+
import { hN as baseSlice, hO as toString, ef as getDefaultExportFromCjs, d as defineComponent, a$ as useClipboard, a as useToast, hP as useAIAssistantHelpers, bh as useNodeTypesStore, at as useNDVStore, Z as useRootStore, hQ as useAssistantStore, K as useUIStore, q as computed, c as openBlock, h as createElementBlock, j as createBaseVNode, t as toDisplayString, ax as withDirectives, f as createCommentVNode, i as createVNode, l as unref, hR as InlineAskAssistantButton, w as withCtx, k as createTextVNode, F as Fragment, A as renderList, g as useI18n, eq as MAX_DISPLAY_DATA_SIZE, dv as isCommunityPackageName, hS as NEW_ASSISTANT_SESSION_MODAL, m as resolveComponent, cF as resolveDirective, hD as sanitizeHtml, ba as NodeConnectionType, hT as isObjectEmpty, r as ref, o as onMounted, n as normalizeClass, e as createBlock, aW as VueMarkdown, _ as _export_sfc, T as useWorkflowsStore, du as _sfc_main$4, I as withModifiers, H as watch, B as normalizeStyle, hU as ElTree, hq as isSubNodeType, hV as PIN_DATA_NODE_TYPES_DENYLIST, b9 as getNodeOutputs, hW as jsonStringify, hX as toMegaBytes, hY as stringSizeInBytes, ei as jsonParse, ak as useTelemetry, aM as useExternalHooks, hr as useDataSchema, hZ as MAX_PINNED_DATA_SIZE, h_ as MAX_WORKFLOW_SIZE, h$ as MAX_EXPECTED_REQUEST_SIZE, bi as useNodeHelpers, a4 as useWorkflowHelpers, au as useExecutionsStore, b0 as CHAT_TRIGGER_NODE_TYPE, bb as get, i0 as SINGLE_WEBHOOK_TRIGGERS, hL as useLocalStorage, i1 as displayForm, eG as isEmpty } from "./index-BcRlEQdt.js";
|
|
2
|
+
import { u as useExecutionHelpers } from "./useExecutionHelpers-DYE5_K78.js";
|
|
3
|
+
function castSlice(array, start, end) {
|
|
4
|
+
var length = array.length;
|
|
5
|
+
end = end === void 0 ? length : end;
|
|
6
|
+
return !start && end >= length ? array : baseSlice(array, start, end);
|
|
7
|
+
}
|
|
8
|
+
var rsAstralRange$1 = "\\ud800-\\udfff", rsComboMarksRange$1 = "\\u0300-\\u036f", reComboHalfMarksRange$1 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$1 = "\\u20d0-\\u20ff", rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1, rsVarRange$1 = "\\ufe0e\\ufe0f";
|
|
9
|
+
var rsZWJ$1 = "\\u200d";
|
|
10
|
+
var reHasUnicode = RegExp("[" + rsZWJ$1 + rsAstralRange$1 + rsComboRange$1 + rsVarRange$1 + "]");
|
|
11
|
+
function hasUnicode(string) {
|
|
12
|
+
return reHasUnicode.test(string);
|
|
13
|
+
}
|
|
14
|
+
function asciiToArray(string) {
|
|
15
|
+
return string.split("");
|
|
16
|
+
}
|
|
17
|
+
var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = "\\ufe0e\\ufe0f";
|
|
18
|
+
var rsAstral = "[" + rsAstralRange + "]", rsCombo = "[" + rsComboRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ = "\\u200d";
|
|
19
|
+
var reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
|
|
20
|
+
var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
|
|
21
|
+
function unicodeToArray(string) {
|
|
22
|
+
return string.match(reUnicode) || [];
|
|
23
|
+
}
|
|
24
|
+
function stringToArray(string) {
|
|
25
|
+
return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
|
|
26
|
+
}
|
|
27
|
+
function createCaseFirst(methodName) {
|
|
28
|
+
return function(string) {
|
|
29
|
+
string = toString(string);
|
|
30
|
+
var strSymbols = hasUnicode(string) ? stringToArray(string) : void 0;
|
|
31
|
+
var chr = strSymbols ? strSymbols[0] : string.charAt(0);
|
|
32
|
+
var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
|
|
33
|
+
return chr[methodName]() + trailing;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var upperFirst = createCaseFirst("toUpperCase");
|
|
37
|
+
function capitalize(string) {
|
|
38
|
+
return upperFirst(toString(string).toLowerCase());
|
|
39
|
+
}
|
|
40
|
+
function deepFreeze(obj) {
|
|
41
|
+
if (obj instanceof Map) {
|
|
42
|
+
obj.clear = obj.delete = obj.set = function() {
|
|
43
|
+
throw new Error("map is read-only");
|
|
44
|
+
};
|
|
45
|
+
} else if (obj instanceof Set) {
|
|
46
|
+
obj.add = obj.clear = obj.delete = function() {
|
|
47
|
+
throw new Error("set is read-only");
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
Object.freeze(obj);
|
|
51
|
+
Object.getOwnPropertyNames(obj).forEach((name) => {
|
|
52
|
+
const prop = obj[name];
|
|
53
|
+
const type = typeof prop;
|
|
54
|
+
if ((type === "object" || type === "function") && !Object.isFrozen(prop)) {
|
|
55
|
+
deepFreeze(prop);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return obj;
|
|
59
|
+
}
|
|
60
|
+
class Response {
|
|
61
|
+
/**
|
|
62
|
+
* @param {CompiledMode} mode
|
|
63
|
+
*/
|
|
64
|
+
constructor(mode) {
|
|
65
|
+
if (mode.data === void 0) mode.data = {};
|
|
66
|
+
this.data = mode.data;
|
|
67
|
+
this.isMatchIgnored = false;
|
|
68
|
+
}
|
|
69
|
+
ignoreMatch() {
|
|
70
|
+
this.isMatchIgnored = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function escapeHTML(value) {
|
|
74
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
75
|
+
}
|
|
76
|
+
function inherit$1(original, ...objects) {
|
|
77
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
78
|
+
for (const key in original) {
|
|
79
|
+
result[key] = original[key];
|
|
80
|
+
}
|
|
81
|
+
objects.forEach(function(obj) {
|
|
82
|
+
for (const key in obj) {
|
|
83
|
+
result[key] = obj[key];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return (
|
|
87
|
+
/** @type {T} */
|
|
88
|
+
result
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const SPAN_CLOSE = "</span>";
|
|
92
|
+
const emitsWrappingTags = (node) => {
|
|
93
|
+
return !!node.scope;
|
|
94
|
+
};
|
|
95
|
+
const scopeToCSSClass = (name, { prefix }) => {
|
|
96
|
+
if (name.startsWith("language:")) {
|
|
97
|
+
return name.replace("language:", "language-");
|
|
98
|
+
}
|
|
99
|
+
if (name.includes(".")) {
|
|
100
|
+
const pieces = name.split(".");
|
|
101
|
+
return [
|
|
102
|
+
`${prefix}${pieces.shift()}`,
|
|
103
|
+
...pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)
|
|
104
|
+
].join(" ");
|
|
105
|
+
}
|
|
106
|
+
return `${prefix}${name}`;
|
|
107
|
+
};
|
|
108
|
+
class HTMLRenderer {
|
|
109
|
+
/**
|
|
110
|
+
* Creates a new HTMLRenderer
|
|
111
|
+
*
|
|
112
|
+
* @param {Tree} parseTree - the parse tree (must support `walk` API)
|
|
113
|
+
* @param {{classPrefix: string}} options
|
|
114
|
+
*/
|
|
115
|
+
constructor(parseTree, options) {
|
|
116
|
+
this.buffer = "";
|
|
117
|
+
this.classPrefix = options.classPrefix;
|
|
118
|
+
parseTree.walk(this);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Adds texts to the output stream
|
|
122
|
+
*
|
|
123
|
+
* @param {string} text */
|
|
124
|
+
addText(text) {
|
|
125
|
+
this.buffer += escapeHTML(text);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Adds a node open to the output stream (if needed)
|
|
129
|
+
*
|
|
130
|
+
* @param {Node} node */
|
|
131
|
+
openNode(node) {
|
|
132
|
+
if (!emitsWrappingTags(node)) return;
|
|
133
|
+
const className = scopeToCSSClass(
|
|
134
|
+
node.scope,
|
|
135
|
+
{ prefix: this.classPrefix }
|
|
136
|
+
);
|
|
137
|
+
this.span(className);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Adds a node close to the output stream (if needed)
|
|
141
|
+
*
|
|
142
|
+
* @param {Node} node */
|
|
143
|
+
closeNode(node) {
|
|
144
|
+
if (!emitsWrappingTags(node)) return;
|
|
145
|
+
this.buffer += SPAN_CLOSE;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* returns the accumulated buffer
|
|
149
|
+
*/
|
|
150
|
+
value() {
|
|
151
|
+
return this.buffer;
|
|
152
|
+
}
|
|
153
|
+
// helpers
|
|
154
|
+
/**
|
|
155
|
+
* Builds a span element
|
|
156
|
+
*
|
|
157
|
+
* @param {string} className */
|
|
158
|
+
span(className) {
|
|
159
|
+
this.buffer += `<span class="${className}">`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const newNode = (opts = {}) => {
|
|
163
|
+
const result = { children: [] };
|
|
164
|
+
Object.assign(result, opts);
|
|
165
|
+
return result;
|
|
166
|
+
};
|
|
167
|
+
class TokenTree {
|
|
168
|
+
constructor() {
|
|
169
|
+
this.rootNode = newNode();
|
|
170
|
+
this.stack = [this.rootNode];
|
|
171
|
+
}
|
|
172
|
+
get top() {
|
|
173
|
+
return this.stack[this.stack.length - 1];
|
|
174
|
+
}
|
|
175
|
+
get root() {
|
|
176
|
+
return this.rootNode;
|
|
177
|
+
}
|
|
178
|
+
/** @param {Node} node */
|
|
179
|
+
add(node) {
|
|
180
|
+
this.top.children.push(node);
|
|
181
|
+
}
|
|
182
|
+
/** @param {string} scope */
|
|
183
|
+
openNode(scope) {
|
|
184
|
+
const node = newNode({ scope });
|
|
185
|
+
this.add(node);
|
|
186
|
+
this.stack.push(node);
|
|
187
|
+
}
|
|
188
|
+
closeNode() {
|
|
189
|
+
if (this.stack.length > 1) {
|
|
190
|
+
return this.stack.pop();
|
|
191
|
+
}
|
|
192
|
+
return void 0;
|
|
193
|
+
}
|
|
194
|
+
closeAllNodes() {
|
|
195
|
+
while (this.closeNode()) ;
|
|
196
|
+
}
|
|
197
|
+
toJSON() {
|
|
198
|
+
return JSON.stringify(this.rootNode, null, 4);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @typedef { import("./html_renderer").Renderer } Renderer
|
|
202
|
+
* @param {Renderer} builder
|
|
203
|
+
*/
|
|
204
|
+
walk(builder) {
|
|
205
|
+
return this.constructor._walk(builder, this.rootNode);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* @param {Renderer} builder
|
|
209
|
+
* @param {Node} node
|
|
210
|
+
*/
|
|
211
|
+
static _walk(builder, node) {
|
|
212
|
+
if (typeof node === "string") {
|
|
213
|
+
builder.addText(node);
|
|
214
|
+
} else if (node.children) {
|
|
215
|
+
builder.openNode(node);
|
|
216
|
+
node.children.forEach((child) => this._walk(builder, child));
|
|
217
|
+
builder.closeNode(node);
|
|
218
|
+
}
|
|
219
|
+
return builder;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @param {Node} node
|
|
223
|
+
*/
|
|
224
|
+
static _collapse(node) {
|
|
225
|
+
if (typeof node === "string") return;
|
|
226
|
+
if (!node.children) return;
|
|
227
|
+
if (node.children.every((el) => typeof el === "string")) {
|
|
228
|
+
node.children = [node.children.join("")];
|
|
229
|
+
} else {
|
|
230
|
+
node.children.forEach((child) => {
|
|
231
|
+
TokenTree._collapse(child);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
class TokenTreeEmitter extends TokenTree {
|
|
237
|
+
/**
|
|
238
|
+
* @param {*} options
|
|
239
|
+
*/
|
|
240
|
+
constructor(options) {
|
|
241
|
+
super();
|
|
242
|
+
this.options = options;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* @param {string} text
|
|
246
|
+
*/
|
|
247
|
+
addText(text) {
|
|
248
|
+
if (text === "") {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this.add(text);
|
|
252
|
+
}
|
|
253
|
+
/** @param {string} scope */
|
|
254
|
+
startScope(scope) {
|
|
255
|
+
this.openNode(scope);
|
|
256
|
+
}
|
|
257
|
+
endScope() {
|
|
258
|
+
this.closeNode();
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* @param {Emitter & {root: DataNode}} emitter
|
|
262
|
+
* @param {string} name
|
|
263
|
+
*/
|
|
264
|
+
__addSublanguage(emitter, name) {
|
|
265
|
+
const node = emitter.root;
|
|
266
|
+
if (name) node.scope = `language:${name}`;
|
|
267
|
+
this.add(node);
|
|
268
|
+
}
|
|
269
|
+
toHTML() {
|
|
270
|
+
const renderer = new HTMLRenderer(this, this.options);
|
|
271
|
+
return renderer.value();
|
|
272
|
+
}
|
|
273
|
+
finalize() {
|
|
274
|
+
this.closeAllNodes();
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function source(re) {
|
|
279
|
+
if (!re) return null;
|
|
280
|
+
if (typeof re === "string") return re;
|
|
281
|
+
return re.source;
|
|
282
|
+
}
|
|
283
|
+
function lookahead(re) {
|
|
284
|
+
return concat("(?=", re, ")");
|
|
285
|
+
}
|
|
286
|
+
function anyNumberOfTimes(re) {
|
|
287
|
+
return concat("(?:", re, ")*");
|
|
288
|
+
}
|
|
289
|
+
function optional(re) {
|
|
290
|
+
return concat("(?:", re, ")?");
|
|
291
|
+
}
|
|
292
|
+
function concat(...args) {
|
|
293
|
+
const joined = args.map((x) => source(x)).join("");
|
|
294
|
+
return joined;
|
|
295
|
+
}
|
|
296
|
+
function stripOptionsFromArgs(args) {
|
|
297
|
+
const opts = args[args.length - 1];
|
|
298
|
+
if (typeof opts === "object" && opts.constructor === Object) {
|
|
299
|
+
args.splice(args.length - 1, 1);
|
|
300
|
+
return opts;
|
|
301
|
+
} else {
|
|
302
|
+
return {};
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function either(...args) {
|
|
306
|
+
const opts = stripOptionsFromArgs(args);
|
|
307
|
+
const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")";
|
|
308
|
+
return joined;
|
|
309
|
+
}
|
|
310
|
+
function countMatchGroups(re) {
|
|
311
|
+
return new RegExp(re.toString() + "|").exec("").length - 1;
|
|
312
|
+
}
|
|
313
|
+
function startsWith(re, lexeme) {
|
|
314
|
+
const match = re && re.exec(lexeme);
|
|
315
|
+
return match && match.index === 0;
|
|
316
|
+
}
|
|
317
|
+
const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
|
|
318
|
+
function _rewriteBackreferences(regexps, { joinWith }) {
|
|
319
|
+
let numCaptures = 0;
|
|
320
|
+
return regexps.map((regex) => {
|
|
321
|
+
numCaptures += 1;
|
|
322
|
+
const offset = numCaptures;
|
|
323
|
+
let re = source(regex);
|
|
324
|
+
let out = "";
|
|
325
|
+
while (re.length > 0) {
|
|
326
|
+
const match = BACKREF_RE.exec(re);
|
|
327
|
+
if (!match) {
|
|
328
|
+
out += re;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
out += re.substring(0, match.index);
|
|
332
|
+
re = re.substring(match.index + match[0].length);
|
|
333
|
+
if (match[0][0] === "\\" && match[1]) {
|
|
334
|
+
out += "\\" + String(Number(match[1]) + offset);
|
|
335
|
+
} else {
|
|
336
|
+
out += match[0];
|
|
337
|
+
if (match[0] === "(") {
|
|
338
|
+
numCaptures++;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return out;
|
|
343
|
+
}).map((re) => `(${re})`).join(joinWith);
|
|
344
|
+
}
|
|
345
|
+
const MATCH_NOTHING_RE = /\b\B/;
|
|
346
|
+
const IDENT_RE = "[a-zA-Z]\\w*";
|
|
347
|
+
const UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
|
|
348
|
+
const NUMBER_RE = "\\b\\d+(\\.\\d+)?";
|
|
349
|
+
const C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
|
|
350
|
+
const BINARY_NUMBER_RE = "\\b(0b[01]+)";
|
|
351
|
+
const RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
|
|
352
|
+
const SHEBANG = (opts = {}) => {
|
|
353
|
+
const beginShebang = /^#![ ]*\//;
|
|
354
|
+
if (opts.binary) {
|
|
355
|
+
opts.begin = concat(
|
|
356
|
+
beginShebang,
|
|
357
|
+
/.*\b/,
|
|
358
|
+
opts.binary,
|
|
359
|
+
/\b.*/
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
return inherit$1({
|
|
363
|
+
scope: "meta",
|
|
364
|
+
begin: beginShebang,
|
|
365
|
+
end: /$/,
|
|
366
|
+
relevance: 0,
|
|
367
|
+
/** @type {ModeCallback} */
|
|
368
|
+
"on:begin": (m, resp) => {
|
|
369
|
+
if (m.index !== 0) resp.ignoreMatch();
|
|
370
|
+
}
|
|
371
|
+
}, opts);
|
|
372
|
+
};
|
|
373
|
+
const BACKSLASH_ESCAPE = {
|
|
374
|
+
begin: "\\\\[\\s\\S]",
|
|
375
|
+
relevance: 0
|
|
376
|
+
};
|
|
377
|
+
const APOS_STRING_MODE = {
|
|
378
|
+
scope: "string",
|
|
379
|
+
begin: "'",
|
|
380
|
+
end: "'",
|
|
381
|
+
illegal: "\\n",
|
|
382
|
+
contains: [BACKSLASH_ESCAPE]
|
|
383
|
+
};
|
|
384
|
+
const QUOTE_STRING_MODE = {
|
|
385
|
+
scope: "string",
|
|
386
|
+
begin: '"',
|
|
387
|
+
end: '"',
|
|
388
|
+
illegal: "\\n",
|
|
389
|
+
contains: [BACKSLASH_ESCAPE]
|
|
390
|
+
};
|
|
391
|
+
const PHRASAL_WORDS_MODE = {
|
|
392
|
+
begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
|
|
393
|
+
};
|
|
394
|
+
const COMMENT = function(begin, end, modeOptions = {}) {
|
|
395
|
+
const mode = inherit$1(
|
|
396
|
+
{
|
|
397
|
+
scope: "comment",
|
|
398
|
+
begin,
|
|
399
|
+
end,
|
|
400
|
+
contains: []
|
|
401
|
+
},
|
|
402
|
+
modeOptions
|
|
403
|
+
);
|
|
404
|
+
mode.contains.push({
|
|
405
|
+
scope: "doctag",
|
|
406
|
+
// hack to avoid the space from being included. the space is necessary to
|
|
407
|
+
// match here to prevent the plain text rule below from gobbling up doctags
|
|
408
|
+
begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
|
|
409
|
+
end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
|
|
410
|
+
excludeBegin: true,
|
|
411
|
+
relevance: 0
|
|
412
|
+
});
|
|
413
|
+
const ENGLISH_WORD = either(
|
|
414
|
+
// list of common 1 and 2 letter words in English
|
|
415
|
+
"I",
|
|
416
|
+
"a",
|
|
417
|
+
"is",
|
|
418
|
+
"so",
|
|
419
|
+
"us",
|
|
420
|
+
"to",
|
|
421
|
+
"at",
|
|
422
|
+
"if",
|
|
423
|
+
"in",
|
|
424
|
+
"it",
|
|
425
|
+
"on",
|
|
426
|
+
// note: this is not an exhaustive list of contractions, just popular ones
|
|
427
|
+
/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
|
|
428
|
+
// contractions - can't we'd they're let's, etc
|
|
429
|
+
/[A-Za-z]+[-][a-z]+/,
|
|
430
|
+
// `no-way`, etc.
|
|
431
|
+
/[A-Za-z][a-z]{2,}/
|
|
432
|
+
// allow capitalized words at beginning of sentences
|
|
433
|
+
);
|
|
434
|
+
mode.contains.push(
|
|
435
|
+
{
|
|
436
|
+
// TODO: how to include ", (, ) without breaking grammars that use these for
|
|
437
|
+
// comment delimiters?
|
|
438
|
+
// begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
|
|
439
|
+
// ---
|
|
440
|
+
// this tries to find sequences of 3 english words in a row (without any
|
|
441
|
+
// "programming" type syntax) this gives us a strong signal that we've
|
|
442
|
+
// TRULY found a comment - vs perhaps scanning with the wrong language.
|
|
443
|
+
// It's possible to find something that LOOKS like the start of the
|
|
444
|
+
// comment - but then if there is no readable text - good chance it is a
|
|
445
|
+
// false match and not a comment.
|
|
446
|
+
//
|
|
447
|
+
// for a visual example please see:
|
|
448
|
+
// https://github.com/highlightjs/highlight.js/issues/2827
|
|
449
|
+
begin: concat(
|
|
450
|
+
/[ ]+/,
|
|
451
|
+
// necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
|
|
452
|
+
"(",
|
|
453
|
+
ENGLISH_WORD,
|
|
454
|
+
/[.]?[:]?([.][ ]|[ ])/,
|
|
455
|
+
"){3}"
|
|
456
|
+
)
|
|
457
|
+
// look for 3 words in a row
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
return mode;
|
|
461
|
+
};
|
|
462
|
+
const C_LINE_COMMENT_MODE = COMMENT("//", "$");
|
|
463
|
+
const C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/");
|
|
464
|
+
const HASH_COMMENT_MODE = COMMENT("#", "$");
|
|
465
|
+
const NUMBER_MODE = {
|
|
466
|
+
scope: "number",
|
|
467
|
+
begin: NUMBER_RE,
|
|
468
|
+
relevance: 0
|
|
469
|
+
};
|
|
470
|
+
const C_NUMBER_MODE = {
|
|
471
|
+
scope: "number",
|
|
472
|
+
begin: C_NUMBER_RE,
|
|
473
|
+
relevance: 0
|
|
474
|
+
};
|
|
475
|
+
const BINARY_NUMBER_MODE = {
|
|
476
|
+
scope: "number",
|
|
477
|
+
begin: BINARY_NUMBER_RE,
|
|
478
|
+
relevance: 0
|
|
479
|
+
};
|
|
480
|
+
const REGEXP_MODE = {
|
|
481
|
+
scope: "regexp",
|
|
482
|
+
begin: /\/(?=[^/\n]*\/)/,
|
|
483
|
+
end: /\/[gimuy]*/,
|
|
484
|
+
contains: [
|
|
485
|
+
BACKSLASH_ESCAPE,
|
|
486
|
+
{
|
|
487
|
+
begin: /\[/,
|
|
488
|
+
end: /\]/,
|
|
489
|
+
relevance: 0,
|
|
490
|
+
contains: [BACKSLASH_ESCAPE]
|
|
491
|
+
}
|
|
492
|
+
]
|
|
493
|
+
};
|
|
494
|
+
const TITLE_MODE = {
|
|
495
|
+
scope: "title",
|
|
496
|
+
begin: IDENT_RE,
|
|
497
|
+
relevance: 0
|
|
498
|
+
};
|
|
499
|
+
const UNDERSCORE_TITLE_MODE = {
|
|
500
|
+
scope: "title",
|
|
501
|
+
begin: UNDERSCORE_IDENT_RE,
|
|
502
|
+
relevance: 0
|
|
503
|
+
};
|
|
504
|
+
const METHOD_GUARD = {
|
|
505
|
+
// excludes method names from keyword processing
|
|
506
|
+
begin: "\\.\\s*" + UNDERSCORE_IDENT_RE,
|
|
507
|
+
relevance: 0
|
|
508
|
+
};
|
|
509
|
+
const END_SAME_AS_BEGIN = function(mode) {
|
|
510
|
+
return Object.assign(
|
|
511
|
+
mode,
|
|
512
|
+
{
|
|
513
|
+
/** @type {ModeCallback} */
|
|
514
|
+
"on:begin": (m, resp) => {
|
|
515
|
+
resp.data._beginMatch = m[1];
|
|
516
|
+
},
|
|
517
|
+
/** @type {ModeCallback} */
|
|
518
|
+
"on:end": (m, resp) => {
|
|
519
|
+
if (resp.data._beginMatch !== m[1]) resp.ignoreMatch();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
);
|
|
523
|
+
};
|
|
524
|
+
var MODES = /* @__PURE__ */ Object.freeze({
|
|
525
|
+
__proto__: null,
|
|
526
|
+
APOS_STRING_MODE,
|
|
527
|
+
BACKSLASH_ESCAPE,
|
|
528
|
+
BINARY_NUMBER_MODE,
|
|
529
|
+
BINARY_NUMBER_RE,
|
|
530
|
+
COMMENT,
|
|
531
|
+
C_BLOCK_COMMENT_MODE,
|
|
532
|
+
C_LINE_COMMENT_MODE,
|
|
533
|
+
C_NUMBER_MODE,
|
|
534
|
+
C_NUMBER_RE,
|
|
535
|
+
END_SAME_AS_BEGIN,
|
|
536
|
+
HASH_COMMENT_MODE,
|
|
537
|
+
IDENT_RE,
|
|
538
|
+
MATCH_NOTHING_RE,
|
|
539
|
+
METHOD_GUARD,
|
|
540
|
+
NUMBER_MODE,
|
|
541
|
+
NUMBER_RE,
|
|
542
|
+
PHRASAL_WORDS_MODE,
|
|
543
|
+
QUOTE_STRING_MODE,
|
|
544
|
+
REGEXP_MODE,
|
|
545
|
+
RE_STARTERS_RE,
|
|
546
|
+
SHEBANG,
|
|
547
|
+
TITLE_MODE,
|
|
548
|
+
UNDERSCORE_IDENT_RE,
|
|
549
|
+
UNDERSCORE_TITLE_MODE
|
|
550
|
+
});
|
|
551
|
+
function skipIfHasPrecedingDot(match, response) {
|
|
552
|
+
const before = match.input[match.index - 1];
|
|
553
|
+
if (before === ".") {
|
|
554
|
+
response.ignoreMatch();
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function scopeClassName(mode, _parent) {
|
|
558
|
+
if (mode.className !== void 0) {
|
|
559
|
+
mode.scope = mode.className;
|
|
560
|
+
delete mode.className;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function beginKeywords(mode, parent) {
|
|
564
|
+
if (!parent) return;
|
|
565
|
+
if (!mode.beginKeywords) return;
|
|
566
|
+
mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)";
|
|
567
|
+
mode.__beforeBegin = skipIfHasPrecedingDot;
|
|
568
|
+
mode.keywords = mode.keywords || mode.beginKeywords;
|
|
569
|
+
delete mode.beginKeywords;
|
|
570
|
+
if (mode.relevance === void 0) mode.relevance = 0;
|
|
571
|
+
}
|
|
572
|
+
function compileIllegal(mode, _parent) {
|
|
573
|
+
if (!Array.isArray(mode.illegal)) return;
|
|
574
|
+
mode.illegal = either(...mode.illegal);
|
|
575
|
+
}
|
|
576
|
+
function compileMatch(mode, _parent) {
|
|
577
|
+
if (!mode.match) return;
|
|
578
|
+
if (mode.begin || mode.end) throw new Error("begin & end are not supported with match");
|
|
579
|
+
mode.begin = mode.match;
|
|
580
|
+
delete mode.match;
|
|
581
|
+
}
|
|
582
|
+
function compileRelevance(mode, _parent) {
|
|
583
|
+
if (mode.relevance === void 0) mode.relevance = 1;
|
|
584
|
+
}
|
|
585
|
+
const beforeMatchExt = (mode, parent) => {
|
|
586
|
+
if (!mode.beforeMatch) return;
|
|
587
|
+
if (mode.starts) throw new Error("beforeMatch cannot be used with starts");
|
|
588
|
+
const originalMode = Object.assign({}, mode);
|
|
589
|
+
Object.keys(mode).forEach((key) => {
|
|
590
|
+
delete mode[key];
|
|
591
|
+
});
|
|
592
|
+
mode.keywords = originalMode.keywords;
|
|
593
|
+
mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin));
|
|
594
|
+
mode.starts = {
|
|
595
|
+
relevance: 0,
|
|
596
|
+
contains: [
|
|
597
|
+
Object.assign(originalMode, { endsParent: true })
|
|
598
|
+
]
|
|
599
|
+
};
|
|
600
|
+
mode.relevance = 0;
|
|
601
|
+
delete originalMode.beforeMatch;
|
|
602
|
+
};
|
|
603
|
+
const COMMON_KEYWORDS = [
|
|
604
|
+
"of",
|
|
605
|
+
"and",
|
|
606
|
+
"for",
|
|
607
|
+
"in",
|
|
608
|
+
"not",
|
|
609
|
+
"or",
|
|
610
|
+
"if",
|
|
611
|
+
"then",
|
|
612
|
+
"parent",
|
|
613
|
+
// common variable name
|
|
614
|
+
"list",
|
|
615
|
+
// common variable name
|
|
616
|
+
"value"
|
|
617
|
+
// common variable name
|
|
618
|
+
];
|
|
619
|
+
const DEFAULT_KEYWORD_SCOPE = "keyword";
|
|
620
|
+
function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
|
|
621
|
+
const compiledKeywords = /* @__PURE__ */ Object.create(null);
|
|
622
|
+
if (typeof rawKeywords === "string") {
|
|
623
|
+
compileList(scopeName, rawKeywords.split(" "));
|
|
624
|
+
} else if (Array.isArray(rawKeywords)) {
|
|
625
|
+
compileList(scopeName, rawKeywords);
|
|
626
|
+
} else {
|
|
627
|
+
Object.keys(rawKeywords).forEach(function(scopeName2) {
|
|
628
|
+
Object.assign(
|
|
629
|
+
compiledKeywords,
|
|
630
|
+
compileKeywords(rawKeywords[scopeName2], caseInsensitive, scopeName2)
|
|
631
|
+
);
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
return compiledKeywords;
|
|
635
|
+
function compileList(scopeName2, keywordList) {
|
|
636
|
+
if (caseInsensitive) {
|
|
637
|
+
keywordList = keywordList.map((x) => x.toLowerCase());
|
|
638
|
+
}
|
|
639
|
+
keywordList.forEach(function(keyword) {
|
|
640
|
+
const pair = keyword.split("|");
|
|
641
|
+
compiledKeywords[pair[0]] = [scopeName2, scoreForKeyword(pair[0], pair[1])];
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function scoreForKeyword(keyword, providedScore) {
|
|
646
|
+
if (providedScore) {
|
|
647
|
+
return Number(providedScore);
|
|
648
|
+
}
|
|
649
|
+
return commonKeyword(keyword) ? 0 : 1;
|
|
650
|
+
}
|
|
651
|
+
function commonKeyword(keyword) {
|
|
652
|
+
return COMMON_KEYWORDS.includes(keyword.toLowerCase());
|
|
653
|
+
}
|
|
654
|
+
const seenDeprecations = {};
|
|
655
|
+
const error$1 = (message) => {
|
|
656
|
+
console.error(message);
|
|
657
|
+
};
|
|
658
|
+
const warn = (message, ...args) => {
|
|
659
|
+
console.log(`WARN: ${message}`, ...args);
|
|
660
|
+
};
|
|
661
|
+
const deprecated = (version2, message) => {
|
|
662
|
+
if (seenDeprecations[`${version2}/${message}`]) return;
|
|
663
|
+
console.log(`Deprecated as of ${version2}. ${message}`);
|
|
664
|
+
seenDeprecations[`${version2}/${message}`] = true;
|
|
665
|
+
};
|
|
666
|
+
const MultiClassError = new Error();
|
|
667
|
+
function remapScopeNames(mode, regexes, { key }) {
|
|
668
|
+
let offset = 0;
|
|
669
|
+
const scopeNames = mode[key];
|
|
670
|
+
const emit = {};
|
|
671
|
+
const positions = {};
|
|
672
|
+
for (let i = 1; i <= regexes.length; i++) {
|
|
673
|
+
positions[i + offset] = scopeNames[i];
|
|
674
|
+
emit[i + offset] = true;
|
|
675
|
+
offset += countMatchGroups(regexes[i - 1]);
|
|
676
|
+
}
|
|
677
|
+
mode[key] = positions;
|
|
678
|
+
mode[key]._emit = emit;
|
|
679
|
+
mode[key]._multi = true;
|
|
680
|
+
}
|
|
681
|
+
function beginMultiClass(mode) {
|
|
682
|
+
if (!Array.isArray(mode.begin)) return;
|
|
683
|
+
if (mode.skip || mode.excludeBegin || mode.returnBegin) {
|
|
684
|
+
error$1("skip, excludeBegin, returnBegin not compatible with beginScope: {}");
|
|
685
|
+
throw MultiClassError;
|
|
686
|
+
}
|
|
687
|
+
if (typeof mode.beginScope !== "object" || mode.beginScope === null) {
|
|
688
|
+
error$1("beginScope must be object");
|
|
689
|
+
throw MultiClassError;
|
|
690
|
+
}
|
|
691
|
+
remapScopeNames(mode, mode.begin, { key: "beginScope" });
|
|
692
|
+
mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" });
|
|
693
|
+
}
|
|
694
|
+
function endMultiClass(mode) {
|
|
695
|
+
if (!Array.isArray(mode.end)) return;
|
|
696
|
+
if (mode.skip || mode.excludeEnd || mode.returnEnd) {
|
|
697
|
+
error$1("skip, excludeEnd, returnEnd not compatible with endScope: {}");
|
|
698
|
+
throw MultiClassError;
|
|
699
|
+
}
|
|
700
|
+
if (typeof mode.endScope !== "object" || mode.endScope === null) {
|
|
701
|
+
error$1("endScope must be object");
|
|
702
|
+
throw MultiClassError;
|
|
703
|
+
}
|
|
704
|
+
remapScopeNames(mode, mode.end, { key: "endScope" });
|
|
705
|
+
mode.end = _rewriteBackreferences(mode.end, { joinWith: "" });
|
|
706
|
+
}
|
|
707
|
+
function scopeSugar(mode) {
|
|
708
|
+
if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) {
|
|
709
|
+
mode.beginScope = mode.scope;
|
|
710
|
+
delete mode.scope;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function MultiClass(mode) {
|
|
714
|
+
scopeSugar(mode);
|
|
715
|
+
if (typeof mode.beginScope === "string") {
|
|
716
|
+
mode.beginScope = { _wrap: mode.beginScope };
|
|
717
|
+
}
|
|
718
|
+
if (typeof mode.endScope === "string") {
|
|
719
|
+
mode.endScope = { _wrap: mode.endScope };
|
|
720
|
+
}
|
|
721
|
+
beginMultiClass(mode);
|
|
722
|
+
endMultiClass(mode);
|
|
723
|
+
}
|
|
724
|
+
function compileLanguage(language) {
|
|
725
|
+
function langRe(value, global) {
|
|
726
|
+
return new RegExp(
|
|
727
|
+
source(value),
|
|
728
|
+
"m" + (language.case_insensitive ? "i" : "") + (language.unicodeRegex ? "u" : "") + (global ? "g" : "")
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
class MultiRegex {
|
|
732
|
+
constructor() {
|
|
733
|
+
this.matchIndexes = {};
|
|
734
|
+
this.regexes = [];
|
|
735
|
+
this.matchAt = 1;
|
|
736
|
+
this.position = 0;
|
|
737
|
+
}
|
|
738
|
+
// @ts-ignore
|
|
739
|
+
addRule(re, opts) {
|
|
740
|
+
opts.position = this.position++;
|
|
741
|
+
this.matchIndexes[this.matchAt] = opts;
|
|
742
|
+
this.regexes.push([opts, re]);
|
|
743
|
+
this.matchAt += countMatchGroups(re) + 1;
|
|
744
|
+
}
|
|
745
|
+
compile() {
|
|
746
|
+
if (this.regexes.length === 0) {
|
|
747
|
+
this.exec = () => null;
|
|
748
|
+
}
|
|
749
|
+
const terminators = this.regexes.map((el) => el[1]);
|
|
750
|
+
this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: "|" }), true);
|
|
751
|
+
this.lastIndex = 0;
|
|
752
|
+
}
|
|
753
|
+
/** @param {string} s */
|
|
754
|
+
exec(s) {
|
|
755
|
+
this.matcherRe.lastIndex = this.lastIndex;
|
|
756
|
+
const match = this.matcherRe.exec(s);
|
|
757
|
+
if (!match) {
|
|
758
|
+
return null;
|
|
759
|
+
}
|
|
760
|
+
const i = match.findIndex((el, i2) => i2 > 0 && el !== void 0);
|
|
761
|
+
const matchData = this.matchIndexes[i];
|
|
762
|
+
match.splice(0, i);
|
|
763
|
+
return Object.assign(match, matchData);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
class ResumableMultiRegex {
|
|
767
|
+
constructor() {
|
|
768
|
+
this.rules = [];
|
|
769
|
+
this.multiRegexes = [];
|
|
770
|
+
this.count = 0;
|
|
771
|
+
this.lastIndex = 0;
|
|
772
|
+
this.regexIndex = 0;
|
|
773
|
+
}
|
|
774
|
+
// @ts-ignore
|
|
775
|
+
getMatcher(index) {
|
|
776
|
+
if (this.multiRegexes[index]) return this.multiRegexes[index];
|
|
777
|
+
const matcher = new MultiRegex();
|
|
778
|
+
this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
|
|
779
|
+
matcher.compile();
|
|
780
|
+
this.multiRegexes[index] = matcher;
|
|
781
|
+
return matcher;
|
|
782
|
+
}
|
|
783
|
+
resumingScanAtSamePosition() {
|
|
784
|
+
return this.regexIndex !== 0;
|
|
785
|
+
}
|
|
786
|
+
considerAll() {
|
|
787
|
+
this.regexIndex = 0;
|
|
788
|
+
}
|
|
789
|
+
// @ts-ignore
|
|
790
|
+
addRule(re, opts) {
|
|
791
|
+
this.rules.push([re, opts]);
|
|
792
|
+
if (opts.type === "begin") this.count++;
|
|
793
|
+
}
|
|
794
|
+
/** @param {string} s */
|
|
795
|
+
exec(s) {
|
|
796
|
+
const m = this.getMatcher(this.regexIndex);
|
|
797
|
+
m.lastIndex = this.lastIndex;
|
|
798
|
+
let result = m.exec(s);
|
|
799
|
+
if (this.resumingScanAtSamePosition()) {
|
|
800
|
+
if (result && result.index === this.lastIndex) ;
|
|
801
|
+
else {
|
|
802
|
+
const m2 = this.getMatcher(0);
|
|
803
|
+
m2.lastIndex = this.lastIndex + 1;
|
|
804
|
+
result = m2.exec(s);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (result) {
|
|
808
|
+
this.regexIndex += result.position + 1;
|
|
809
|
+
if (this.regexIndex === this.count) {
|
|
810
|
+
this.considerAll();
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return result;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
function buildModeRegex(mode) {
|
|
817
|
+
const mm = new ResumableMultiRegex();
|
|
818
|
+
mode.contains.forEach((term) => mm.addRule(term.begin, { rule: term, type: "begin" }));
|
|
819
|
+
if (mode.terminatorEnd) {
|
|
820
|
+
mm.addRule(mode.terminatorEnd, { type: "end" });
|
|
821
|
+
}
|
|
822
|
+
if (mode.illegal) {
|
|
823
|
+
mm.addRule(mode.illegal, { type: "illegal" });
|
|
824
|
+
}
|
|
825
|
+
return mm;
|
|
826
|
+
}
|
|
827
|
+
function compileMode(mode, parent) {
|
|
828
|
+
const cmode = (
|
|
829
|
+
/** @type CompiledMode */
|
|
830
|
+
mode
|
|
831
|
+
);
|
|
832
|
+
if (mode.isCompiled) return cmode;
|
|
833
|
+
[
|
|
834
|
+
scopeClassName,
|
|
835
|
+
// do this early so compiler extensions generally don't have to worry about
|
|
836
|
+
// the distinction between match/begin
|
|
837
|
+
compileMatch,
|
|
838
|
+
MultiClass,
|
|
839
|
+
beforeMatchExt
|
|
840
|
+
].forEach((ext) => ext(mode, parent));
|
|
841
|
+
language.compilerExtensions.forEach((ext) => ext(mode, parent));
|
|
842
|
+
mode.__beforeBegin = null;
|
|
843
|
+
[
|
|
844
|
+
beginKeywords,
|
|
845
|
+
// do this later so compiler extensions that come earlier have access to the
|
|
846
|
+
// raw array if they wanted to perhaps manipulate it, etc.
|
|
847
|
+
compileIllegal,
|
|
848
|
+
// default to 1 relevance if not specified
|
|
849
|
+
compileRelevance
|
|
850
|
+
].forEach((ext) => ext(mode, parent));
|
|
851
|
+
mode.isCompiled = true;
|
|
852
|
+
let keywordPattern = null;
|
|
853
|
+
if (typeof mode.keywords === "object" && mode.keywords.$pattern) {
|
|
854
|
+
mode.keywords = Object.assign({}, mode.keywords);
|
|
855
|
+
keywordPattern = mode.keywords.$pattern;
|
|
856
|
+
delete mode.keywords.$pattern;
|
|
857
|
+
}
|
|
858
|
+
keywordPattern = keywordPattern || /\w+/;
|
|
859
|
+
if (mode.keywords) {
|
|
860
|
+
mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
|
|
861
|
+
}
|
|
862
|
+
cmode.keywordPatternRe = langRe(keywordPattern, true);
|
|
863
|
+
if (parent) {
|
|
864
|
+
if (!mode.begin) mode.begin = /\B|\b/;
|
|
865
|
+
cmode.beginRe = langRe(cmode.begin);
|
|
866
|
+
if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
|
|
867
|
+
if (mode.end) cmode.endRe = langRe(cmode.end);
|
|
868
|
+
cmode.terminatorEnd = source(cmode.end) || "";
|
|
869
|
+
if (mode.endsWithParent && parent.terminatorEnd) {
|
|
870
|
+
cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
if (mode.illegal) cmode.illegalRe = langRe(
|
|
874
|
+
/** @type {RegExp | string} */
|
|
875
|
+
mode.illegal
|
|
876
|
+
);
|
|
877
|
+
if (!mode.contains) mode.contains = [];
|
|
878
|
+
mode.contains = [].concat(...mode.contains.map(function(c) {
|
|
879
|
+
return expandOrCloneMode(c === "self" ? mode : c);
|
|
880
|
+
}));
|
|
881
|
+
mode.contains.forEach(function(c) {
|
|
882
|
+
compileMode(
|
|
883
|
+
/** @type Mode */
|
|
884
|
+
c,
|
|
885
|
+
cmode
|
|
886
|
+
);
|
|
887
|
+
});
|
|
888
|
+
if (mode.starts) {
|
|
889
|
+
compileMode(mode.starts, parent);
|
|
890
|
+
}
|
|
891
|
+
cmode.matcher = buildModeRegex(cmode);
|
|
892
|
+
return cmode;
|
|
893
|
+
}
|
|
894
|
+
if (!language.compilerExtensions) language.compilerExtensions = [];
|
|
895
|
+
if (language.contains && language.contains.includes("self")) {
|
|
896
|
+
throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
|
|
897
|
+
}
|
|
898
|
+
language.classNameAliases = inherit$1(language.classNameAliases || {});
|
|
899
|
+
return compileMode(
|
|
900
|
+
/** @type Mode */
|
|
901
|
+
language
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
function dependencyOnParent(mode) {
|
|
905
|
+
if (!mode) return false;
|
|
906
|
+
return mode.endsWithParent || dependencyOnParent(mode.starts);
|
|
907
|
+
}
|
|
908
|
+
function expandOrCloneMode(mode) {
|
|
909
|
+
if (mode.variants && !mode.cachedVariants) {
|
|
910
|
+
mode.cachedVariants = mode.variants.map(function(variant) {
|
|
911
|
+
return inherit$1(mode, { variants: null }, variant);
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
if (mode.cachedVariants) {
|
|
915
|
+
return mode.cachedVariants;
|
|
916
|
+
}
|
|
917
|
+
if (dependencyOnParent(mode)) {
|
|
918
|
+
return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null });
|
|
919
|
+
}
|
|
920
|
+
if (Object.isFrozen(mode)) {
|
|
921
|
+
return inherit$1(mode);
|
|
922
|
+
}
|
|
923
|
+
return mode;
|
|
924
|
+
}
|
|
925
|
+
var version = "11.9.0";
|
|
926
|
+
class HTMLInjectionError extends Error {
|
|
927
|
+
constructor(reason, html) {
|
|
928
|
+
super(reason);
|
|
929
|
+
this.name = "HTMLInjectionError";
|
|
930
|
+
this.html = html;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
const escape = escapeHTML;
|
|
934
|
+
const inherit = inherit$1;
|
|
935
|
+
const NO_MATCH = Symbol("nomatch");
|
|
936
|
+
const MAX_KEYWORD_HITS = 7;
|
|
937
|
+
const HLJS = function(hljs) {
|
|
938
|
+
const languages = /* @__PURE__ */ Object.create(null);
|
|
939
|
+
const aliases = /* @__PURE__ */ Object.create(null);
|
|
940
|
+
const plugins = [];
|
|
941
|
+
let SAFE_MODE = true;
|
|
942
|
+
const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
|
|
943
|
+
const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: "Plain text", contains: [] };
|
|
944
|
+
let options = {
|
|
945
|
+
ignoreUnescapedHTML: false,
|
|
946
|
+
throwUnescapedHTML: false,
|
|
947
|
+
noHighlightRe: /^(no-?highlight)$/i,
|
|
948
|
+
languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
|
|
949
|
+
classPrefix: "hljs-",
|
|
950
|
+
cssSelector: "pre code",
|
|
951
|
+
languages: null,
|
|
952
|
+
// beta configuration options, subject to change, welcome to discuss
|
|
953
|
+
// https://github.com/highlightjs/highlight.js/issues/1086
|
|
954
|
+
__emitter: TokenTreeEmitter
|
|
955
|
+
};
|
|
956
|
+
function shouldNotHighlight(languageName) {
|
|
957
|
+
return options.noHighlightRe.test(languageName);
|
|
958
|
+
}
|
|
959
|
+
function blockLanguage(block2) {
|
|
960
|
+
let classes = block2.className + " ";
|
|
961
|
+
classes += block2.parentNode ? block2.parentNode.className : "";
|
|
962
|
+
const match = options.languageDetectRe.exec(classes);
|
|
963
|
+
if (match) {
|
|
964
|
+
const language = getLanguage(match[1]);
|
|
965
|
+
if (!language) {
|
|
966
|
+
warn(LANGUAGE_NOT_FOUND.replace("{}", match[1]));
|
|
967
|
+
warn("Falling back to no-highlight mode for this block.", block2);
|
|
968
|
+
}
|
|
969
|
+
return language ? match[1] : "no-highlight";
|
|
970
|
+
}
|
|
971
|
+
return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
|
|
972
|
+
}
|
|
973
|
+
function highlight2(codeOrLanguageName, optionsOrCode, ignoreIllegals) {
|
|
974
|
+
let code = "";
|
|
975
|
+
let languageName = "";
|
|
976
|
+
if (typeof optionsOrCode === "object") {
|
|
977
|
+
code = codeOrLanguageName;
|
|
978
|
+
ignoreIllegals = optionsOrCode.ignoreIllegals;
|
|
979
|
+
languageName = optionsOrCode.language;
|
|
980
|
+
} else {
|
|
981
|
+
deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
|
|
982
|
+
deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
|
|
983
|
+
languageName = codeOrLanguageName;
|
|
984
|
+
code = optionsOrCode;
|
|
985
|
+
}
|
|
986
|
+
if (ignoreIllegals === void 0) {
|
|
987
|
+
ignoreIllegals = true;
|
|
988
|
+
}
|
|
989
|
+
const context = {
|
|
990
|
+
code,
|
|
991
|
+
language: languageName
|
|
992
|
+
};
|
|
993
|
+
fire("before:highlight", context);
|
|
994
|
+
const result = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals);
|
|
995
|
+
result.code = context.code;
|
|
996
|
+
fire("after:highlight", result);
|
|
997
|
+
return result;
|
|
998
|
+
}
|
|
999
|
+
function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
|
|
1000
|
+
const keywordHits = /* @__PURE__ */ Object.create(null);
|
|
1001
|
+
function keywordData(mode, matchText) {
|
|
1002
|
+
return mode.keywords[matchText];
|
|
1003
|
+
}
|
|
1004
|
+
function processKeywords() {
|
|
1005
|
+
if (!top.keywords) {
|
|
1006
|
+
emitter.addText(modeBuffer);
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
let lastIndex = 0;
|
|
1010
|
+
top.keywordPatternRe.lastIndex = 0;
|
|
1011
|
+
let match = top.keywordPatternRe.exec(modeBuffer);
|
|
1012
|
+
let buf = "";
|
|
1013
|
+
while (match) {
|
|
1014
|
+
buf += modeBuffer.substring(lastIndex, match.index);
|
|
1015
|
+
const word = language.case_insensitive ? match[0].toLowerCase() : match[0];
|
|
1016
|
+
const data = keywordData(top, word);
|
|
1017
|
+
if (data) {
|
|
1018
|
+
const [kind, keywordRelevance] = data;
|
|
1019
|
+
emitter.addText(buf);
|
|
1020
|
+
buf = "";
|
|
1021
|
+
keywordHits[word] = (keywordHits[word] || 0) + 1;
|
|
1022
|
+
if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance;
|
|
1023
|
+
if (kind.startsWith("_")) {
|
|
1024
|
+
buf += match[0];
|
|
1025
|
+
} else {
|
|
1026
|
+
const cssClass = language.classNameAliases[kind] || kind;
|
|
1027
|
+
emitKeyword(match[0], cssClass);
|
|
1028
|
+
}
|
|
1029
|
+
} else {
|
|
1030
|
+
buf += match[0];
|
|
1031
|
+
}
|
|
1032
|
+
lastIndex = top.keywordPatternRe.lastIndex;
|
|
1033
|
+
match = top.keywordPatternRe.exec(modeBuffer);
|
|
1034
|
+
}
|
|
1035
|
+
buf += modeBuffer.substring(lastIndex);
|
|
1036
|
+
emitter.addText(buf);
|
|
1037
|
+
}
|
|
1038
|
+
function processSubLanguage() {
|
|
1039
|
+
if (modeBuffer === "") return;
|
|
1040
|
+
let result2 = null;
|
|
1041
|
+
if (typeof top.subLanguage === "string") {
|
|
1042
|
+
if (!languages[top.subLanguage]) {
|
|
1043
|
+
emitter.addText(modeBuffer);
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
result2 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
|
|
1047
|
+
continuations[top.subLanguage] = /** @type {CompiledMode} */
|
|
1048
|
+
result2._top;
|
|
1049
|
+
} else {
|
|
1050
|
+
result2 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
|
|
1051
|
+
}
|
|
1052
|
+
if (top.relevance > 0) {
|
|
1053
|
+
relevance += result2.relevance;
|
|
1054
|
+
}
|
|
1055
|
+
emitter.__addSublanguage(result2._emitter, result2.language);
|
|
1056
|
+
}
|
|
1057
|
+
function processBuffer() {
|
|
1058
|
+
if (top.subLanguage != null) {
|
|
1059
|
+
processSubLanguage();
|
|
1060
|
+
} else {
|
|
1061
|
+
processKeywords();
|
|
1062
|
+
}
|
|
1063
|
+
modeBuffer = "";
|
|
1064
|
+
}
|
|
1065
|
+
function emitKeyword(keyword, scope) {
|
|
1066
|
+
if (keyword === "") return;
|
|
1067
|
+
emitter.startScope(scope);
|
|
1068
|
+
emitter.addText(keyword);
|
|
1069
|
+
emitter.endScope();
|
|
1070
|
+
}
|
|
1071
|
+
function emitMultiClass(scope, match) {
|
|
1072
|
+
let i = 1;
|
|
1073
|
+
const max = match.length - 1;
|
|
1074
|
+
while (i <= max) {
|
|
1075
|
+
if (!scope._emit[i]) {
|
|
1076
|
+
i++;
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
const klass = language.classNameAliases[scope[i]] || scope[i];
|
|
1080
|
+
const text = match[i];
|
|
1081
|
+
if (klass) {
|
|
1082
|
+
emitKeyword(text, klass);
|
|
1083
|
+
} else {
|
|
1084
|
+
modeBuffer = text;
|
|
1085
|
+
processKeywords();
|
|
1086
|
+
modeBuffer = "";
|
|
1087
|
+
}
|
|
1088
|
+
i++;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
function startNewMode(mode, match) {
|
|
1092
|
+
if (mode.scope && typeof mode.scope === "string") {
|
|
1093
|
+
emitter.openNode(language.classNameAliases[mode.scope] || mode.scope);
|
|
1094
|
+
}
|
|
1095
|
+
if (mode.beginScope) {
|
|
1096
|
+
if (mode.beginScope._wrap) {
|
|
1097
|
+
emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap);
|
|
1098
|
+
modeBuffer = "";
|
|
1099
|
+
} else if (mode.beginScope._multi) {
|
|
1100
|
+
emitMultiClass(mode.beginScope, match);
|
|
1101
|
+
modeBuffer = "";
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
top = Object.create(mode, { parent: { value: top } });
|
|
1105
|
+
return top;
|
|
1106
|
+
}
|
|
1107
|
+
function endOfMode(mode, match, matchPlusRemainder) {
|
|
1108
|
+
let matched = startsWith(mode.endRe, matchPlusRemainder);
|
|
1109
|
+
if (matched) {
|
|
1110
|
+
if (mode["on:end"]) {
|
|
1111
|
+
const resp = new Response(mode);
|
|
1112
|
+
mode["on:end"](match, resp);
|
|
1113
|
+
if (resp.isMatchIgnored) matched = false;
|
|
1114
|
+
}
|
|
1115
|
+
if (matched) {
|
|
1116
|
+
while (mode.endsParent && mode.parent) {
|
|
1117
|
+
mode = mode.parent;
|
|
1118
|
+
}
|
|
1119
|
+
return mode;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
if (mode.endsWithParent) {
|
|
1123
|
+
return endOfMode(mode.parent, match, matchPlusRemainder);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
function doIgnore(lexeme) {
|
|
1127
|
+
if (top.matcher.regexIndex === 0) {
|
|
1128
|
+
modeBuffer += lexeme[0];
|
|
1129
|
+
return 1;
|
|
1130
|
+
} else {
|
|
1131
|
+
resumeScanAtSamePosition = true;
|
|
1132
|
+
return 0;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
function doBeginMatch(match) {
|
|
1136
|
+
const lexeme = match[0];
|
|
1137
|
+
const newMode = match.rule;
|
|
1138
|
+
const resp = new Response(newMode);
|
|
1139
|
+
const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
|
|
1140
|
+
for (const cb of beforeCallbacks) {
|
|
1141
|
+
if (!cb) continue;
|
|
1142
|
+
cb(match, resp);
|
|
1143
|
+
if (resp.isMatchIgnored) return doIgnore(lexeme);
|
|
1144
|
+
}
|
|
1145
|
+
if (newMode.skip) {
|
|
1146
|
+
modeBuffer += lexeme;
|
|
1147
|
+
} else {
|
|
1148
|
+
if (newMode.excludeBegin) {
|
|
1149
|
+
modeBuffer += lexeme;
|
|
1150
|
+
}
|
|
1151
|
+
processBuffer();
|
|
1152
|
+
if (!newMode.returnBegin && !newMode.excludeBegin) {
|
|
1153
|
+
modeBuffer = lexeme;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
startNewMode(newMode, match);
|
|
1157
|
+
return newMode.returnBegin ? 0 : lexeme.length;
|
|
1158
|
+
}
|
|
1159
|
+
function doEndMatch(match) {
|
|
1160
|
+
const lexeme = match[0];
|
|
1161
|
+
const matchPlusRemainder = codeToHighlight.substring(match.index);
|
|
1162
|
+
const endMode = endOfMode(top, match, matchPlusRemainder);
|
|
1163
|
+
if (!endMode) {
|
|
1164
|
+
return NO_MATCH;
|
|
1165
|
+
}
|
|
1166
|
+
const origin = top;
|
|
1167
|
+
if (top.endScope && top.endScope._wrap) {
|
|
1168
|
+
processBuffer();
|
|
1169
|
+
emitKeyword(lexeme, top.endScope._wrap);
|
|
1170
|
+
} else if (top.endScope && top.endScope._multi) {
|
|
1171
|
+
processBuffer();
|
|
1172
|
+
emitMultiClass(top.endScope, match);
|
|
1173
|
+
} else if (origin.skip) {
|
|
1174
|
+
modeBuffer += lexeme;
|
|
1175
|
+
} else {
|
|
1176
|
+
if (!(origin.returnEnd || origin.excludeEnd)) {
|
|
1177
|
+
modeBuffer += lexeme;
|
|
1178
|
+
}
|
|
1179
|
+
processBuffer();
|
|
1180
|
+
if (origin.excludeEnd) {
|
|
1181
|
+
modeBuffer = lexeme;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
do {
|
|
1185
|
+
if (top.scope) {
|
|
1186
|
+
emitter.closeNode();
|
|
1187
|
+
}
|
|
1188
|
+
if (!top.skip && !top.subLanguage) {
|
|
1189
|
+
relevance += top.relevance;
|
|
1190
|
+
}
|
|
1191
|
+
top = top.parent;
|
|
1192
|
+
} while (top !== endMode.parent);
|
|
1193
|
+
if (endMode.starts) {
|
|
1194
|
+
startNewMode(endMode.starts, match);
|
|
1195
|
+
}
|
|
1196
|
+
return origin.returnEnd ? 0 : lexeme.length;
|
|
1197
|
+
}
|
|
1198
|
+
function processContinuations() {
|
|
1199
|
+
const list = [];
|
|
1200
|
+
for (let current = top; current !== language; current = current.parent) {
|
|
1201
|
+
if (current.scope) {
|
|
1202
|
+
list.unshift(current.scope);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
list.forEach((item) => emitter.openNode(item));
|
|
1206
|
+
}
|
|
1207
|
+
let lastMatch = {};
|
|
1208
|
+
function processLexeme(textBeforeMatch, match) {
|
|
1209
|
+
const lexeme = match && match[0];
|
|
1210
|
+
modeBuffer += textBeforeMatch;
|
|
1211
|
+
if (lexeme == null) {
|
|
1212
|
+
processBuffer();
|
|
1213
|
+
return 0;
|
|
1214
|
+
}
|
|
1215
|
+
if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") {
|
|
1216
|
+
modeBuffer += codeToHighlight.slice(match.index, match.index + 1);
|
|
1217
|
+
if (!SAFE_MODE) {
|
|
1218
|
+
const err = new Error(`0 width match regex (${languageName})`);
|
|
1219
|
+
err.languageName = languageName;
|
|
1220
|
+
err.badRule = lastMatch.rule;
|
|
1221
|
+
throw err;
|
|
1222
|
+
}
|
|
1223
|
+
return 1;
|
|
1224
|
+
}
|
|
1225
|
+
lastMatch = match;
|
|
1226
|
+
if (match.type === "begin") {
|
|
1227
|
+
return doBeginMatch(match);
|
|
1228
|
+
} else if (match.type === "illegal" && !ignoreIllegals) {
|
|
1229
|
+
const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || "<unnamed>") + '"');
|
|
1230
|
+
err.mode = top;
|
|
1231
|
+
throw err;
|
|
1232
|
+
} else if (match.type === "end") {
|
|
1233
|
+
const processed = doEndMatch(match);
|
|
1234
|
+
if (processed !== NO_MATCH) {
|
|
1235
|
+
return processed;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
if (match.type === "illegal" && lexeme === "") {
|
|
1239
|
+
return 1;
|
|
1240
|
+
}
|
|
1241
|
+
if (iterations > 1e5 && iterations > match.index * 3) {
|
|
1242
|
+
const err = new Error("potential infinite loop, way more iterations than matches");
|
|
1243
|
+
throw err;
|
|
1244
|
+
}
|
|
1245
|
+
modeBuffer += lexeme;
|
|
1246
|
+
return lexeme.length;
|
|
1247
|
+
}
|
|
1248
|
+
const language = getLanguage(languageName);
|
|
1249
|
+
if (!language) {
|
|
1250
|
+
error$1(LANGUAGE_NOT_FOUND.replace("{}", languageName));
|
|
1251
|
+
throw new Error('Unknown language: "' + languageName + '"');
|
|
1252
|
+
}
|
|
1253
|
+
const md = compileLanguage(language);
|
|
1254
|
+
let result = "";
|
|
1255
|
+
let top = continuation || md;
|
|
1256
|
+
const continuations = {};
|
|
1257
|
+
const emitter = new options.__emitter(options);
|
|
1258
|
+
processContinuations();
|
|
1259
|
+
let modeBuffer = "";
|
|
1260
|
+
let relevance = 0;
|
|
1261
|
+
let index = 0;
|
|
1262
|
+
let iterations = 0;
|
|
1263
|
+
let resumeScanAtSamePosition = false;
|
|
1264
|
+
try {
|
|
1265
|
+
if (!language.__emitTokens) {
|
|
1266
|
+
top.matcher.considerAll();
|
|
1267
|
+
for (; ; ) {
|
|
1268
|
+
iterations++;
|
|
1269
|
+
if (resumeScanAtSamePosition) {
|
|
1270
|
+
resumeScanAtSamePosition = false;
|
|
1271
|
+
} else {
|
|
1272
|
+
top.matcher.considerAll();
|
|
1273
|
+
}
|
|
1274
|
+
top.matcher.lastIndex = index;
|
|
1275
|
+
const match = top.matcher.exec(codeToHighlight);
|
|
1276
|
+
if (!match) break;
|
|
1277
|
+
const beforeMatch = codeToHighlight.substring(index, match.index);
|
|
1278
|
+
const processedCount = processLexeme(beforeMatch, match);
|
|
1279
|
+
index = match.index + processedCount;
|
|
1280
|
+
}
|
|
1281
|
+
processLexeme(codeToHighlight.substring(index));
|
|
1282
|
+
} else {
|
|
1283
|
+
language.__emitTokens(codeToHighlight, emitter);
|
|
1284
|
+
}
|
|
1285
|
+
emitter.finalize();
|
|
1286
|
+
result = emitter.toHTML();
|
|
1287
|
+
return {
|
|
1288
|
+
language: languageName,
|
|
1289
|
+
value: result,
|
|
1290
|
+
relevance,
|
|
1291
|
+
illegal: false,
|
|
1292
|
+
_emitter: emitter,
|
|
1293
|
+
_top: top
|
|
1294
|
+
};
|
|
1295
|
+
} catch (err) {
|
|
1296
|
+
if (err.message && err.message.includes("Illegal")) {
|
|
1297
|
+
return {
|
|
1298
|
+
language: languageName,
|
|
1299
|
+
value: escape(codeToHighlight),
|
|
1300
|
+
illegal: true,
|
|
1301
|
+
relevance: 0,
|
|
1302
|
+
_illegalBy: {
|
|
1303
|
+
message: err.message,
|
|
1304
|
+
index,
|
|
1305
|
+
context: codeToHighlight.slice(index - 100, index + 100),
|
|
1306
|
+
mode: err.mode,
|
|
1307
|
+
resultSoFar: result
|
|
1308
|
+
},
|
|
1309
|
+
_emitter: emitter
|
|
1310
|
+
};
|
|
1311
|
+
} else if (SAFE_MODE) {
|
|
1312
|
+
return {
|
|
1313
|
+
language: languageName,
|
|
1314
|
+
value: escape(codeToHighlight),
|
|
1315
|
+
illegal: false,
|
|
1316
|
+
relevance: 0,
|
|
1317
|
+
errorRaised: err,
|
|
1318
|
+
_emitter: emitter,
|
|
1319
|
+
_top: top
|
|
1320
|
+
};
|
|
1321
|
+
} else {
|
|
1322
|
+
throw err;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
function justTextHighlightResult(code) {
|
|
1327
|
+
const result = {
|
|
1328
|
+
value: escape(code),
|
|
1329
|
+
illegal: false,
|
|
1330
|
+
relevance: 0,
|
|
1331
|
+
_top: PLAINTEXT_LANGUAGE,
|
|
1332
|
+
_emitter: new options.__emitter(options)
|
|
1333
|
+
};
|
|
1334
|
+
result._emitter.addText(code);
|
|
1335
|
+
return result;
|
|
1336
|
+
}
|
|
1337
|
+
function highlightAuto(code, languageSubset) {
|
|
1338
|
+
languageSubset = languageSubset || options.languages || Object.keys(languages);
|
|
1339
|
+
const plaintext = justTextHighlightResult(code);
|
|
1340
|
+
const results = languageSubset.filter(getLanguage).filter(autoDetection).map(
|
|
1341
|
+
(name) => _highlight(name, code, false)
|
|
1342
|
+
);
|
|
1343
|
+
results.unshift(plaintext);
|
|
1344
|
+
const sorted = results.sort((a, b) => {
|
|
1345
|
+
if (a.relevance !== b.relevance) return b.relevance - a.relevance;
|
|
1346
|
+
if (a.language && b.language) {
|
|
1347
|
+
if (getLanguage(a.language).supersetOf === b.language) {
|
|
1348
|
+
return 1;
|
|
1349
|
+
} else if (getLanguage(b.language).supersetOf === a.language) {
|
|
1350
|
+
return -1;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
return 0;
|
|
1354
|
+
});
|
|
1355
|
+
const [best, secondBest] = sorted;
|
|
1356
|
+
const result = best;
|
|
1357
|
+
result.secondBest = secondBest;
|
|
1358
|
+
return result;
|
|
1359
|
+
}
|
|
1360
|
+
function updateClassName(element, currentLang, resultLang) {
|
|
1361
|
+
const language = currentLang && aliases[currentLang] || resultLang;
|
|
1362
|
+
element.classList.add("hljs");
|
|
1363
|
+
element.classList.add(`language-${language}`);
|
|
1364
|
+
}
|
|
1365
|
+
function highlightElement(element) {
|
|
1366
|
+
let node = null;
|
|
1367
|
+
const language = blockLanguage(element);
|
|
1368
|
+
if (shouldNotHighlight(language)) return;
|
|
1369
|
+
fire(
|
|
1370
|
+
"before:highlightElement",
|
|
1371
|
+
{ el: element, language }
|
|
1372
|
+
);
|
|
1373
|
+
if (element.dataset.highlighted) {
|
|
1374
|
+
console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element);
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
if (element.children.length > 0) {
|
|
1378
|
+
if (!options.ignoreUnescapedHTML) {
|
|
1379
|
+
console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk.");
|
|
1380
|
+
console.warn("https://github.com/highlightjs/highlight.js/wiki/security");
|
|
1381
|
+
console.warn("The element with unescaped HTML:");
|
|
1382
|
+
console.warn(element);
|
|
1383
|
+
}
|
|
1384
|
+
if (options.throwUnescapedHTML) {
|
|
1385
|
+
const err = new HTMLInjectionError(
|
|
1386
|
+
"One of your code blocks includes unescaped HTML.",
|
|
1387
|
+
element.innerHTML
|
|
1388
|
+
);
|
|
1389
|
+
throw err;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
node = element;
|
|
1393
|
+
const text = node.textContent;
|
|
1394
|
+
const result = language ? highlight2(text, { language, ignoreIllegals: true }) : highlightAuto(text);
|
|
1395
|
+
element.innerHTML = result.value;
|
|
1396
|
+
element.dataset.highlighted = "yes";
|
|
1397
|
+
updateClassName(element, language, result.language);
|
|
1398
|
+
element.result = {
|
|
1399
|
+
language: result.language,
|
|
1400
|
+
// TODO: remove with version 11.0
|
|
1401
|
+
re: result.relevance,
|
|
1402
|
+
relevance: result.relevance
|
|
1403
|
+
};
|
|
1404
|
+
if (result.secondBest) {
|
|
1405
|
+
element.secondBest = {
|
|
1406
|
+
language: result.secondBest.language,
|
|
1407
|
+
relevance: result.secondBest.relevance
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
fire("after:highlightElement", { el: element, result, text });
|
|
1411
|
+
}
|
|
1412
|
+
function configure(userOptions) {
|
|
1413
|
+
options = inherit(options, userOptions);
|
|
1414
|
+
}
|
|
1415
|
+
const initHighlighting = () => {
|
|
1416
|
+
highlightAll();
|
|
1417
|
+
deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
|
|
1418
|
+
};
|
|
1419
|
+
function initHighlightingOnLoad() {
|
|
1420
|
+
highlightAll();
|
|
1421
|
+
deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
|
|
1422
|
+
}
|
|
1423
|
+
let wantsHighlight = false;
|
|
1424
|
+
function highlightAll() {
|
|
1425
|
+
if (document.readyState === "loading") {
|
|
1426
|
+
wantsHighlight = true;
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
const blocks = document.querySelectorAll(options.cssSelector);
|
|
1430
|
+
blocks.forEach(highlightElement);
|
|
1431
|
+
}
|
|
1432
|
+
function boot() {
|
|
1433
|
+
if (wantsHighlight) highlightAll();
|
|
1434
|
+
}
|
|
1435
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
1436
|
+
window.addEventListener("DOMContentLoaded", boot, false);
|
|
1437
|
+
}
|
|
1438
|
+
function registerLanguage(languageName, languageDefinition) {
|
|
1439
|
+
let lang = null;
|
|
1440
|
+
try {
|
|
1441
|
+
lang = languageDefinition(hljs);
|
|
1442
|
+
} catch (error$1$1) {
|
|
1443
|
+
error$1("Language definition for '{}' could not be registered.".replace("{}", languageName));
|
|
1444
|
+
if (!SAFE_MODE) {
|
|
1445
|
+
throw error$1$1;
|
|
1446
|
+
} else {
|
|
1447
|
+
error$1(error$1$1);
|
|
1448
|
+
}
|
|
1449
|
+
lang = PLAINTEXT_LANGUAGE;
|
|
1450
|
+
}
|
|
1451
|
+
if (!lang.name) lang.name = languageName;
|
|
1452
|
+
languages[languageName] = lang;
|
|
1453
|
+
lang.rawDefinition = languageDefinition.bind(null, hljs);
|
|
1454
|
+
if (lang.aliases) {
|
|
1455
|
+
registerAliases(lang.aliases, { languageName });
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
function unregisterLanguage(languageName) {
|
|
1459
|
+
delete languages[languageName];
|
|
1460
|
+
for (const alias of Object.keys(aliases)) {
|
|
1461
|
+
if (aliases[alias] === languageName) {
|
|
1462
|
+
delete aliases[alias];
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
function listLanguages() {
|
|
1467
|
+
return Object.keys(languages);
|
|
1468
|
+
}
|
|
1469
|
+
function getLanguage(name) {
|
|
1470
|
+
name = (name || "").toLowerCase();
|
|
1471
|
+
return languages[name] || languages[aliases[name]];
|
|
1472
|
+
}
|
|
1473
|
+
function registerAliases(aliasList, { languageName }) {
|
|
1474
|
+
if (typeof aliasList === "string") {
|
|
1475
|
+
aliasList = [aliasList];
|
|
1476
|
+
}
|
|
1477
|
+
aliasList.forEach((alias) => {
|
|
1478
|
+
aliases[alias.toLowerCase()] = languageName;
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
function autoDetection(name) {
|
|
1482
|
+
const lang = getLanguage(name);
|
|
1483
|
+
return lang && !lang.disableAutodetect;
|
|
1484
|
+
}
|
|
1485
|
+
function upgradePluginAPI(plugin) {
|
|
1486
|
+
if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
|
|
1487
|
+
plugin["before:highlightElement"] = (data) => {
|
|
1488
|
+
plugin["before:highlightBlock"](
|
|
1489
|
+
Object.assign({ block: data.el }, data)
|
|
1490
|
+
);
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
|
|
1494
|
+
plugin["after:highlightElement"] = (data) => {
|
|
1495
|
+
plugin["after:highlightBlock"](
|
|
1496
|
+
Object.assign({ block: data.el }, data)
|
|
1497
|
+
);
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
function addPlugin(plugin) {
|
|
1502
|
+
upgradePluginAPI(plugin);
|
|
1503
|
+
plugins.push(plugin);
|
|
1504
|
+
}
|
|
1505
|
+
function removePlugin(plugin) {
|
|
1506
|
+
const index = plugins.indexOf(plugin);
|
|
1507
|
+
if (index !== -1) {
|
|
1508
|
+
plugins.splice(index, 1);
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
function fire(event, args) {
|
|
1512
|
+
const cb = event;
|
|
1513
|
+
plugins.forEach(function(plugin) {
|
|
1514
|
+
if (plugin[cb]) {
|
|
1515
|
+
plugin[cb](args);
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
function deprecateHighlightBlock(el) {
|
|
1520
|
+
deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
|
|
1521
|
+
deprecated("10.7.0", "Please use highlightElement now.");
|
|
1522
|
+
return highlightElement(el);
|
|
1523
|
+
}
|
|
1524
|
+
Object.assign(hljs, {
|
|
1525
|
+
highlight: highlight2,
|
|
1526
|
+
highlightAuto,
|
|
1527
|
+
highlightAll,
|
|
1528
|
+
highlightElement,
|
|
1529
|
+
// TODO: Remove with v12 API
|
|
1530
|
+
highlightBlock: deprecateHighlightBlock,
|
|
1531
|
+
configure,
|
|
1532
|
+
initHighlighting,
|
|
1533
|
+
initHighlightingOnLoad,
|
|
1534
|
+
registerLanguage,
|
|
1535
|
+
unregisterLanguage,
|
|
1536
|
+
listLanguages,
|
|
1537
|
+
getLanguage,
|
|
1538
|
+
registerAliases,
|
|
1539
|
+
autoDetection,
|
|
1540
|
+
inherit,
|
|
1541
|
+
addPlugin,
|
|
1542
|
+
removePlugin
|
|
1543
|
+
});
|
|
1544
|
+
hljs.debugMode = function() {
|
|
1545
|
+
SAFE_MODE = false;
|
|
1546
|
+
};
|
|
1547
|
+
hljs.safeMode = function() {
|
|
1548
|
+
SAFE_MODE = true;
|
|
1549
|
+
};
|
|
1550
|
+
hljs.versionString = version;
|
|
1551
|
+
hljs.regex = {
|
|
1552
|
+
concat,
|
|
1553
|
+
lookahead,
|
|
1554
|
+
either,
|
|
1555
|
+
optional,
|
|
1556
|
+
anyNumberOfTimes
|
|
1557
|
+
};
|
|
1558
|
+
for (const key in MODES) {
|
|
1559
|
+
if (typeof MODES[key] === "object") {
|
|
1560
|
+
deepFreeze(MODES[key]);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
Object.assign(hljs, MODES);
|
|
1564
|
+
return hljs;
|
|
1565
|
+
};
|
|
1566
|
+
const highlight = HLJS({});
|
|
1567
|
+
highlight.newInstance = () => HLJS({});
|
|
1568
|
+
var core = highlight;
|
|
1569
|
+
highlight.HighlightJS = highlight;
|
|
1570
|
+
highlight.default = highlight;
|
|
1571
|
+
const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(core);
|
|
1572
|
+
const _hoisted_1$3 = { class: "node-error-view" };
|
|
1573
|
+
const _hoisted_2$3 = { class: "node-error-view__header" };
|
|
1574
|
+
const _hoisted_3$2 = {
|
|
1575
|
+
class: "node-error-view__header-message",
|
|
1576
|
+
"data-test-id": "node-error-message"
|
|
1577
|
+
};
|
|
1578
|
+
const _hoisted_4$1 = {
|
|
1579
|
+
key: 0,
|
|
1580
|
+
"data-test-id": "node-error-description",
|
|
1581
|
+
class: "node-error-view__header-description"
|
|
1582
|
+
};
|
|
1583
|
+
const _hoisted_5 = { key: 1 };
|
|
1584
|
+
const _hoisted_6 = {
|
|
1585
|
+
key: 2,
|
|
1586
|
+
class: "node-error-view__button",
|
|
1587
|
+
"data-test-id": "node-error-view-ask-assistant-button"
|
|
1588
|
+
};
|
|
1589
|
+
const _hoisted_7 = {
|
|
1590
|
+
key: 0,
|
|
1591
|
+
class: "node-error-view__info"
|
|
1592
|
+
};
|
|
1593
|
+
const _hoisted_8 = { class: "node-error-view__info-header" };
|
|
1594
|
+
const _hoisted_9 = { class: "node-error-view__info-title" };
|
|
1595
|
+
const _hoisted_10 = { class: "copy-button" };
|
|
1596
|
+
const _hoisted_11 = { class: "node-error-view__info-content" };
|
|
1597
|
+
const _hoisted_12 = {
|
|
1598
|
+
key: 0,
|
|
1599
|
+
class: "node-error-view__details"
|
|
1600
|
+
};
|
|
1601
|
+
const _hoisted_13 = { class: "node-error-view__details-summary" };
|
|
1602
|
+
const _hoisted_14 = { class: "node-error-view__details-content" };
|
|
1603
|
+
const _hoisted_15 = {
|
|
1604
|
+
key: 0,
|
|
1605
|
+
class: "node-error-view__details-row"
|
|
1606
|
+
};
|
|
1607
|
+
const _hoisted_16 = { class: "node-error-view__details-label" };
|
|
1608
|
+
const _hoisted_17 = { class: "node-error-view__details-value" };
|
|
1609
|
+
const _hoisted_18 = {
|
|
1610
|
+
key: 1,
|
|
1611
|
+
class: "node-error-view__details-row"
|
|
1612
|
+
};
|
|
1613
|
+
const _hoisted_19 = { class: "node-error-view__details-label" };
|
|
1614
|
+
const _hoisted_20 = { class: "node-error-view__details-value" };
|
|
1615
|
+
const _hoisted_21 = {
|
|
1616
|
+
key: 2,
|
|
1617
|
+
class: "node-error-view__details-row"
|
|
1618
|
+
};
|
|
1619
|
+
const _hoisted_22 = { class: "node-error-view__details-label" };
|
|
1620
|
+
const _hoisted_23 = { class: "node-error-view__details-value" };
|
|
1621
|
+
const _hoisted_24 = {
|
|
1622
|
+
key: 3,
|
|
1623
|
+
class: "node-error-view__details-row"
|
|
1624
|
+
};
|
|
1625
|
+
const _hoisted_25 = { class: "node-error-view__details-label" };
|
|
1626
|
+
const _hoisted_26 = { class: "node-error-view__details-value" };
|
|
1627
|
+
const _hoisted_27 = {
|
|
1628
|
+
key: 4,
|
|
1629
|
+
class: "node-error-view__details-row"
|
|
1630
|
+
};
|
|
1631
|
+
const _hoisted_28 = { class: "node-error-view__details-label" };
|
|
1632
|
+
const _hoisted_29 = { class: "node-error-view__details-value" };
|
|
1633
|
+
const _hoisted_30 = { class: "node-error-view__details" };
|
|
1634
|
+
const _hoisted_31 = { class: "node-error-view__details-summary" };
|
|
1635
|
+
const _hoisted_32 = { class: "node-error-view__details-content" };
|
|
1636
|
+
const _hoisted_33 = {
|
|
1637
|
+
key: 0,
|
|
1638
|
+
class: "node-error-view__details-row"
|
|
1639
|
+
};
|
|
1640
|
+
const _hoisted_34 = { class: "node-error-view__details-label" };
|
|
1641
|
+
const _hoisted_35 = { class: "node-error-view__details-value" };
|
|
1642
|
+
const _hoisted_36 = {
|
|
1643
|
+
key: 1,
|
|
1644
|
+
class: "node-error-view__details-row"
|
|
1645
|
+
};
|
|
1646
|
+
const _hoisted_37 = { class: "node-error-view__details-label" };
|
|
1647
|
+
const _hoisted_38 = { class: "node-error-view__details-value" };
|
|
1648
|
+
const _hoisted_39 = {
|
|
1649
|
+
key: 2,
|
|
1650
|
+
class: "node-error-view__details-row"
|
|
1651
|
+
};
|
|
1652
|
+
const _hoisted_40 = { class: "node-error-view__details-label" };
|
|
1653
|
+
const _hoisted_41 = { class: "node-error-view__details-value" };
|
|
1654
|
+
const _hoisted_42 = {
|
|
1655
|
+
key: 3,
|
|
1656
|
+
class: "node-error-view__details-row"
|
|
1657
|
+
};
|
|
1658
|
+
const _hoisted_43 = { class: "node-error-view__details-label" };
|
|
1659
|
+
const _hoisted_44 = { class: "node-error-view__details-value" };
|
|
1660
|
+
const _hoisted_45 = {
|
|
1661
|
+
key: 4,
|
|
1662
|
+
class: "node-error-view__details-row"
|
|
1663
|
+
};
|
|
1664
|
+
const _hoisted_46 = { class: "node-error-view__details-label" };
|
|
1665
|
+
const _hoisted_47 = { class: "node-error-view__details-value" };
|
|
1666
|
+
const _hoisted_48 = { class: "node-error-view__details-row" };
|
|
1667
|
+
const _hoisted_49 = { class: "node-error-view__details-label" };
|
|
1668
|
+
const _hoisted_50 = { class: "node-error-view__details-value" };
|
|
1669
|
+
const _hoisted_51 = {
|
|
1670
|
+
key: 5,
|
|
1671
|
+
class: "node-error-view__details-row"
|
|
1672
|
+
};
|
|
1673
|
+
const _hoisted_52 = { class: "node-error-view__details-label" };
|
|
1674
|
+
const _hoisted_53 = { class: "node-error-view__details-value" };
|
|
1675
|
+
const _hoisted_54 = {
|
|
1676
|
+
key: 6,
|
|
1677
|
+
class: "node-error-view__details-row"
|
|
1678
|
+
};
|
|
1679
|
+
const _hoisted_55 = { class: "node-error-view__details-label" };
|
|
1680
|
+
const _hoisted_56 = { class: "node-error-view__details-value" };
|
|
1681
|
+
const _hoisted_57 = {
|
|
1682
|
+
key: 7,
|
|
1683
|
+
class: "node-error-view__details-row"
|
|
1684
|
+
};
|
|
1685
|
+
const _hoisted_58 = { class: "node-error-view__details-label" };
|
|
1686
|
+
const _hoisted_59 = { class: "node-error-view__details-value" };
|
|
1687
|
+
const _hoisted_60 = {
|
|
1688
|
+
key: 8,
|
|
1689
|
+
class: "node-error-view__details-row"
|
|
1690
|
+
};
|
|
1691
|
+
const _hoisted_61 = { class: "node-error-view__details-label" };
|
|
1692
|
+
const _hoisted_62 = { class: "node-error-view__details-value" };
|
|
1693
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
1694
|
+
__name: "NodeErrorView",
|
|
1695
|
+
props: {
|
|
1696
|
+
error: {},
|
|
1697
|
+
compact: { type: Boolean }
|
|
1698
|
+
},
|
|
1699
|
+
setup(__props) {
|
|
1700
|
+
const props = __props;
|
|
1701
|
+
const clipboard = useClipboard();
|
|
1702
|
+
const toast = useToast();
|
|
1703
|
+
const i18n = useI18n();
|
|
1704
|
+
const assistantHelpers = useAIAssistantHelpers();
|
|
1705
|
+
const nodeTypesStore = useNodeTypesStore();
|
|
1706
|
+
const ndvStore = useNDVStore();
|
|
1707
|
+
const rootStore = useRootStore();
|
|
1708
|
+
const assistantStore = useAssistantStore();
|
|
1709
|
+
const uiStore = useUIStore();
|
|
1710
|
+
const displayCause = computed(() => {
|
|
1711
|
+
return JSON.stringify(props.error.cause ?? "").length < MAX_DISPLAY_DATA_SIZE;
|
|
1712
|
+
});
|
|
1713
|
+
const node = computed(() => {
|
|
1714
|
+
return props.error.node || ndvStore.activeNode;
|
|
1715
|
+
});
|
|
1716
|
+
const parameters = computed(() => {
|
|
1717
|
+
if (!node.value) {
|
|
1718
|
+
return [];
|
|
1719
|
+
}
|
|
1720
|
+
const nodeType = nodeTypesStore.getNodeType(node.value.type, node.value.typeVersion);
|
|
1721
|
+
if (nodeType === null) {
|
|
1722
|
+
return [];
|
|
1723
|
+
}
|
|
1724
|
+
return nodeType.properties;
|
|
1725
|
+
});
|
|
1726
|
+
const n8nVersion = computed(() => {
|
|
1727
|
+
const baseUrl = rootStore.urlBaseEditor;
|
|
1728
|
+
let instanceType = "Self Hosted";
|
|
1729
|
+
if (baseUrl.includes("n8n.cloud")) {
|
|
1730
|
+
instanceType = "Cloud";
|
|
1731
|
+
}
|
|
1732
|
+
return rootStore.versionCli + ` (${instanceType})`;
|
|
1733
|
+
});
|
|
1734
|
+
const hasManyInputItems = computed(() => {
|
|
1735
|
+
return ndvStore.ndvInputData.length > 1;
|
|
1736
|
+
});
|
|
1737
|
+
const nodeDefaultName = computed(() => {
|
|
1738
|
+
var _a;
|
|
1739
|
+
if (!node.value) {
|
|
1740
|
+
return "Node";
|
|
1741
|
+
}
|
|
1742
|
+
const nodeType = nodeTypesStore.getNodeType(node.value.type, node.value.typeVersion);
|
|
1743
|
+
return ((_a = nodeType == null ? void 0 : nodeType.defaults) == null ? void 0 : _a.name) || node.value.name;
|
|
1744
|
+
});
|
|
1745
|
+
const prepareRawMessages = computed(() => {
|
|
1746
|
+
var _a;
|
|
1747
|
+
const returnData = [];
|
|
1748
|
+
if (!((_a = props.error.messages) == null ? void 0 : _a.length)) {
|
|
1749
|
+
return [];
|
|
1750
|
+
}
|
|
1751
|
+
const errorMessage = getErrorMessage();
|
|
1752
|
+
Array.from(new Set(props.error.messages)).forEach((message) => {
|
|
1753
|
+
const isParsable = /^\d{3} - \{/.test(message);
|
|
1754
|
+
const parts = isParsable ? message.split(" - ").map((part) => part.trim()) : [];
|
|
1755
|
+
for (const part of parts) {
|
|
1756
|
+
try {
|
|
1757
|
+
const parsed = JSON.parse(part);
|
|
1758
|
+
if (typeof parsed === "object") {
|
|
1759
|
+
returnData.push(parsed);
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1762
|
+
} catch (error2) {
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
if (message === errorMessage) return;
|
|
1766
|
+
returnData.push(message);
|
|
1767
|
+
});
|
|
1768
|
+
return returnData;
|
|
1769
|
+
});
|
|
1770
|
+
const isAskAssistantAvailable = computed(() => {
|
|
1771
|
+
if (!node.value || isSubNodeError.value) {
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
const isCustomNode = node.value.type === void 0 || isCommunityPackageName(node.value.type);
|
|
1775
|
+
return assistantStore.canShowAssistantButtonsOnCanvas && !isCustomNode && !nodeIsHidden();
|
|
1776
|
+
});
|
|
1777
|
+
const assistantAlreadyAsked = computed(() => {
|
|
1778
|
+
return assistantStore.isNodeErrorActive({
|
|
1779
|
+
error: assistantHelpers.simplifyErrorForAssistant(props.error),
|
|
1780
|
+
node: props.error.node || ndvStore.activeNode
|
|
1781
|
+
});
|
|
1782
|
+
});
|
|
1783
|
+
const isSubNodeError = computed(() => {
|
|
1784
|
+
return props.error.name === "NodeOperationError" && props.error.functionality === "configuration-node";
|
|
1785
|
+
});
|
|
1786
|
+
function nodeVersionTag(nodeType) {
|
|
1787
|
+
if (!nodeType || "hidden" in nodeType && nodeType.hidden) {
|
|
1788
|
+
return i18n.baseText("nodeSettings.deprecated");
|
|
1789
|
+
}
|
|
1790
|
+
const latestNodeVersion = Math.max(...nodeTypesStore.getNodeVersions(nodeType.type));
|
|
1791
|
+
if (latestNodeVersion === nodeType.typeVersion) {
|
|
1792
|
+
return i18n.baseText("nodeSettings.latest");
|
|
1793
|
+
}
|
|
1794
|
+
return i18n.baseText("nodeSettings.latestVersion", {
|
|
1795
|
+
interpolate: { version: latestNodeVersion.toString() }
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
function prepareDescription(description) {
|
|
1799
|
+
return sanitizeHtml(description.replace(/`(.*?)`/g, "<code>$1</code>"));
|
|
1800
|
+
}
|
|
1801
|
+
function getErrorDescription() {
|
|
1802
|
+
var _a, _b;
|
|
1803
|
+
if ((_a = props.error.context) == null ? void 0 : _a.descriptionKey) {
|
|
1804
|
+
const interpolate = {
|
|
1805
|
+
nodeCause: props.error.context.nodeCause,
|
|
1806
|
+
runIndex: props.error.context.runIndex ?? "0",
|
|
1807
|
+
itemIndex: props.error.context.itemIndex ?? "0"
|
|
1808
|
+
};
|
|
1809
|
+
return prepareDescription(
|
|
1810
|
+
i18n.baseText(
|
|
1811
|
+
`nodeErrorView.description.${props.error.context.descriptionKey}`,
|
|
1812
|
+
{ interpolate }
|
|
1813
|
+
)
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
if (!((_b = props.error.context) == null ? void 0 : _b.descriptionTemplate)) {
|
|
1817
|
+
return prepareDescription(props.error.description ?? "");
|
|
1818
|
+
}
|
|
1819
|
+
const parameterName = parameterDisplayName(props.error.context.parameter);
|
|
1820
|
+
return prepareDescription(
|
|
1821
|
+
props.error.context.descriptionTemplate.replace(/%%PARAMETER%%/g, parameterName)
|
|
1822
|
+
);
|
|
1823
|
+
}
|
|
1824
|
+
function addItemIndexSuffix(message) {
|
|
1825
|
+
var _a, _b;
|
|
1826
|
+
let itemIndexSuffix = "";
|
|
1827
|
+
if (hasManyInputItems.value && ((_b = (_a = props.error) == null ? void 0 : _a.context) == null ? void 0 : _b.itemIndex) !== void 0) {
|
|
1828
|
+
itemIndexSuffix = `item ${props.error.context.itemIndex}`;
|
|
1829
|
+
}
|
|
1830
|
+
if (message.includes(itemIndexSuffix)) return message;
|
|
1831
|
+
return `${message} [${itemIndexSuffix}]`;
|
|
1832
|
+
}
|
|
1833
|
+
function getErrorMessage() {
|
|
1834
|
+
var _a, _b, _c;
|
|
1835
|
+
let message = "";
|
|
1836
|
+
const isNonEmptyString = (value) => !!value && typeof value === "string";
|
|
1837
|
+
if (isSubNodeError.value) {
|
|
1838
|
+
message = i18n.baseText("nodeErrorView.errorSubNode", {
|
|
1839
|
+
interpolate: { node: props.error.node.name }
|
|
1840
|
+
});
|
|
1841
|
+
} else if (isNonEmptyString(props.error.message) && (props.error.message === props.error.description || !((_a = props.error.context) == null ? void 0 : _a.messageTemplate))) {
|
|
1842
|
+
message = props.error.message;
|
|
1843
|
+
} else if (isNonEmptyString((_b = props.error.context) == null ? void 0 : _b.messageTemplate) && isNonEmptyString((_c = props.error.context) == null ? void 0 : _c.parameter)) {
|
|
1844
|
+
const parameterName = parameterDisplayName(props.error.context.parameter);
|
|
1845
|
+
message = props.error.context.messageTemplate.replace(/%%PARAMETER%%/g, parameterName);
|
|
1846
|
+
} else if (Array.isArray(props.error.messages) && props.error.messages.length > 0) {
|
|
1847
|
+
message = props.error.messages[0];
|
|
1848
|
+
}
|
|
1849
|
+
return addItemIndexSuffix(message);
|
|
1850
|
+
}
|
|
1851
|
+
function parameterDisplayName(path, fullPath = true) {
|
|
1852
|
+
try {
|
|
1853
|
+
const params = getParameterName(parameters.value, path.split("."));
|
|
1854
|
+
if (!params.length) {
|
|
1855
|
+
throw new Error();
|
|
1856
|
+
}
|
|
1857
|
+
if (!fullPath) {
|
|
1858
|
+
return params.pop().displayName;
|
|
1859
|
+
}
|
|
1860
|
+
return params.map((parameter) => parameter.displayName).join(" > ");
|
|
1861
|
+
} catch (error2) {
|
|
1862
|
+
return `Could not find parameter "${path}"`;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
function getParameterName(params, pathParts) {
|
|
1866
|
+
let currentParameterName = pathParts.shift();
|
|
1867
|
+
if (currentParameterName === void 0) {
|
|
1868
|
+
return [];
|
|
1869
|
+
}
|
|
1870
|
+
const arrayMatch = currentParameterName.match(/(.*)\[([\d])\]$/);
|
|
1871
|
+
if (arrayMatch !== null && arrayMatch.length > 0) {
|
|
1872
|
+
currentParameterName = arrayMatch[1];
|
|
1873
|
+
}
|
|
1874
|
+
const currentParameter = params.find(
|
|
1875
|
+
(parameter) => parameter.name === currentParameterName
|
|
1876
|
+
);
|
|
1877
|
+
if (currentParameter === void 0) {
|
|
1878
|
+
throw new Error(`Could not find parameter "${currentParameterName}"`);
|
|
1879
|
+
}
|
|
1880
|
+
if (pathParts.length === 0) {
|
|
1881
|
+
return [currentParameter];
|
|
1882
|
+
}
|
|
1883
|
+
if (currentParameter.hasOwnProperty("options")) {
|
|
1884
|
+
return [
|
|
1885
|
+
currentParameter,
|
|
1886
|
+
...getParameterName(currentParameter.options, pathParts)
|
|
1887
|
+
];
|
|
1888
|
+
}
|
|
1889
|
+
if (currentParameter.hasOwnProperty("values")) {
|
|
1890
|
+
return [
|
|
1891
|
+
currentParameter,
|
|
1892
|
+
...getParameterName(currentParameter.values, pathParts)
|
|
1893
|
+
];
|
|
1894
|
+
}
|
|
1895
|
+
return [currentParameter];
|
|
1896
|
+
}
|
|
1897
|
+
function copyErrorDetails() {
|
|
1898
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1899
|
+
const error2 = props.error;
|
|
1900
|
+
const errorInfo = {
|
|
1901
|
+
errorMessage: getErrorMessage()
|
|
1902
|
+
};
|
|
1903
|
+
if (error2.description) {
|
|
1904
|
+
errorInfo.errorDescription = error2.description;
|
|
1905
|
+
}
|
|
1906
|
+
const errorDetails = {};
|
|
1907
|
+
if ((_a = error2 == null ? void 0 : error2.messages) == null ? void 0 : _a.length) {
|
|
1908
|
+
errorDetails.rawErrorMessage = error2.messages;
|
|
1909
|
+
}
|
|
1910
|
+
if ("httpCode" in error2 && error2.httpCode) {
|
|
1911
|
+
errorDetails.httpCode = error2.httpCode;
|
|
1912
|
+
}
|
|
1913
|
+
if (error2.context && error2.context.data) {
|
|
1914
|
+
errorDetails.errorData = error2.context.data;
|
|
1915
|
+
}
|
|
1916
|
+
if (error2.extra) {
|
|
1917
|
+
errorDetails.errorExtra = error2.extra;
|
|
1918
|
+
}
|
|
1919
|
+
errorInfo.errorDetails = errorDetails;
|
|
1920
|
+
const n8nDetails = {};
|
|
1921
|
+
if (error2.node) {
|
|
1922
|
+
n8nDetails.nodeName = error2.node.name;
|
|
1923
|
+
n8nDetails.nodeType = error2.node.type;
|
|
1924
|
+
n8nDetails.nodeVersion = error2.node.typeVersion;
|
|
1925
|
+
if ((_c = (_b = error2.node) == null ? void 0 : _b.parameters) == null ? void 0 : _c.resource) {
|
|
1926
|
+
n8nDetails.resource = error2.node.parameters.resource;
|
|
1927
|
+
}
|
|
1928
|
+
if ((_e = (_d = error2 == null ? void 0 : error2.node) == null ? void 0 : _d.parameters) == null ? void 0 : _e.operation) {
|
|
1929
|
+
n8nDetails.operation = error2.node.parameters.operation;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
if (error2.context) {
|
|
1933
|
+
if (error2.context.itemIndex !== void 0) {
|
|
1934
|
+
n8nDetails.itemIndex = error2.context.itemIndex;
|
|
1935
|
+
}
|
|
1936
|
+
if (error2.context.runIndex !== void 0) {
|
|
1937
|
+
n8nDetails.runIndex = error2.context.runIndex;
|
|
1938
|
+
}
|
|
1939
|
+
if (error2.context.parameter !== void 0) {
|
|
1940
|
+
n8nDetails.parameter = error2.context.parameter;
|
|
1941
|
+
}
|
|
1942
|
+
if (error2.context.causeDetailed) {
|
|
1943
|
+
n8nDetails.causeDetailed = error2.context.causeDetailed;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
if (error2.timestamp) {
|
|
1947
|
+
n8nDetails.time = new Date(error2.timestamp).toLocaleString();
|
|
1948
|
+
}
|
|
1949
|
+
n8nDetails.n8nVersion = n8nVersion.value;
|
|
1950
|
+
n8nDetails.binaryDataMode = rootStore.binaryDataMode;
|
|
1951
|
+
if (error2.cause) {
|
|
1952
|
+
n8nDetails.cause = error2.cause;
|
|
1953
|
+
}
|
|
1954
|
+
n8nDetails.stackTrace = (_f = error2.stack) == null ? void 0 : _f.split("\n");
|
|
1955
|
+
errorInfo.n8nDetails = n8nDetails;
|
|
1956
|
+
void clipboard.copy(JSON.stringify(errorInfo, null, 2));
|
|
1957
|
+
copySuccess();
|
|
1958
|
+
}
|
|
1959
|
+
function copySuccess() {
|
|
1960
|
+
toast.showMessage({
|
|
1961
|
+
title: i18n.baseText("nodeErrorView.showMessage.title"),
|
|
1962
|
+
type: "info"
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
function nodeIsHidden() {
|
|
1966
|
+
const nodeType = nodeTypesStore.getNodeType(node == null ? void 0 : node.value.type);
|
|
1967
|
+
return (nodeType == null ? void 0 : nodeType.hidden) ?? false;
|
|
1968
|
+
}
|
|
1969
|
+
const onOpenErrorNodeDetailClick = () => {
|
|
1970
|
+
ndvStore.activeNodeName = props.error.node.name;
|
|
1971
|
+
};
|
|
1972
|
+
async function onAskAssistantClick() {
|
|
1973
|
+
const { message, lineNumber, description } = props.error;
|
|
1974
|
+
const sessionInProgress = !assistantStore.isSessionEnded;
|
|
1975
|
+
const errorHelp = {
|
|
1976
|
+
error: {
|
|
1977
|
+
name: props.error.name,
|
|
1978
|
+
message,
|
|
1979
|
+
lineNumber,
|
|
1980
|
+
description: description ?? getErrorDescription(),
|
|
1981
|
+
type: "type" in props.error ? props.error.type : void 0
|
|
1982
|
+
},
|
|
1983
|
+
node: node.value
|
|
1984
|
+
};
|
|
1985
|
+
if (sessionInProgress) {
|
|
1986
|
+
uiStore.openModalWithData({
|
|
1987
|
+
name: NEW_ASSISTANT_SESSION_MODAL,
|
|
1988
|
+
data: { context: { errorHelp } }
|
|
1989
|
+
});
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
await assistantStore.initErrorHelper(errorHelp);
|
|
1993
|
+
assistantStore.trackUserOpenedAssistant({
|
|
1994
|
+
source: "error",
|
|
1995
|
+
task: "error",
|
|
1996
|
+
has_existing_session: false
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
return (_ctx, _cache) => {
|
|
2000
|
+
var _a, _b, _c, _d, _e;
|
|
2001
|
+
const _component_n8n_button = resolveComponent("n8n-button");
|
|
2002
|
+
const _component_n8n_icon_button = resolveComponent("n8n-icon-button");
|
|
2003
|
+
const _component_n8n_tooltip = resolveComponent("n8n-tooltip");
|
|
2004
|
+
const _component_font_awesome_icon = resolveComponent("font-awesome-icon");
|
|
2005
|
+
const _directive_n8n_html = resolveDirective("n8n-html");
|
|
2006
|
+
return openBlock(), createElementBlock("div", _hoisted_1$3, [
|
|
2007
|
+
createBaseVNode("div", _hoisted_2$3, [
|
|
2008
|
+
createBaseVNode("div", _hoisted_3$2, [
|
|
2009
|
+
createBaseVNode("div", null, toDisplayString(getErrorMessage()), 1)
|
|
2010
|
+
]),
|
|
2011
|
+
(_ctx.error.description || ((_a = _ctx.error.context) == null ? void 0 : _a.descriptionKey)) && !isSubNodeError.value ? withDirectives((openBlock(), createElementBlock("div", _hoisted_4$1, null, 512)), [
|
|
2012
|
+
[_directive_n8n_html, getErrorDescription()]
|
|
2013
|
+
]) : createCommentVNode("", true),
|
|
2014
|
+
isSubNodeError.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
2015
|
+
createVNode(_component_n8n_button, {
|
|
2016
|
+
icon: "arrow-right",
|
|
2017
|
+
type: "secondary",
|
|
2018
|
+
label: unref(i18n).baseText("pushConnection.executionError.openNode"),
|
|
2019
|
+
class: "node-error-view__button",
|
|
2020
|
+
"data-test-id": "node-error-view-open-node-button",
|
|
2021
|
+
onClick: onOpenErrorNodeDetailClick
|
|
2022
|
+
}, null, 8, ["label"])
|
|
2023
|
+
])) : createCommentVNode("", true),
|
|
2024
|
+
isAskAssistantAvailable.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
2025
|
+
createVNode(InlineAskAssistantButton, {
|
|
2026
|
+
asked: assistantAlreadyAsked.value,
|
|
2027
|
+
onClick: onAskAssistantClick
|
|
2028
|
+
}, null, 8, ["asked"])
|
|
2029
|
+
])) : createCommentVNode("", true)
|
|
2030
|
+
]),
|
|
2031
|
+
!_ctx.compact ? (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
2032
|
+
createBaseVNode("div", _hoisted_8, [
|
|
2033
|
+
createBaseVNode("p", _hoisted_9, toDisplayString(unref(i18n).baseText("nodeErrorView.details.title")), 1),
|
|
2034
|
+
createVNode(_component_n8n_tooltip, {
|
|
2035
|
+
class: "item",
|
|
2036
|
+
content: unref(i18n).baseText("nodeErrorView.copyToClipboard.tooltip"),
|
|
2037
|
+
placement: "left"
|
|
2038
|
+
}, {
|
|
2039
|
+
default: withCtx(() => [
|
|
2040
|
+
createBaseVNode("div", _hoisted_10, [
|
|
2041
|
+
createVNode(_component_n8n_icon_button, {
|
|
2042
|
+
icon: "copy",
|
|
2043
|
+
type: "secondary",
|
|
2044
|
+
size: "mini",
|
|
2045
|
+
text: "true",
|
|
2046
|
+
"transparent-background": "transparent",
|
|
2047
|
+
onClick: copyErrorDetails
|
|
2048
|
+
})
|
|
2049
|
+
])
|
|
2050
|
+
]),
|
|
2051
|
+
_: 1
|
|
2052
|
+
}, 8, ["content"])
|
|
2053
|
+
]),
|
|
2054
|
+
createBaseVNode("div", _hoisted_11, [
|
|
2055
|
+
"httpCode" in _ctx.error && _ctx.error.httpCode || prepareRawMessages.value.length || ((_c = (_b = _ctx.error) == null ? void 0 : _b.context) == null ? void 0 : _c.data) || _ctx.error.extra ? (openBlock(), createElementBlock("details", _hoisted_12, [
|
|
2056
|
+
createBaseVNode("summary", _hoisted_13, [
|
|
2057
|
+
createVNode(_component_font_awesome_icon, {
|
|
2058
|
+
class: "node-error-view__details-icon",
|
|
2059
|
+
icon: "angle-right"
|
|
2060
|
+
}),
|
|
2061
|
+
createTextVNode(" " + toDisplayString(unref(i18n).baseText("nodeErrorView.details.from", {
|
|
2062
|
+
interpolate: { node: `${nodeDefaultName.value}` }
|
|
2063
|
+
})), 1)
|
|
2064
|
+
]),
|
|
2065
|
+
createBaseVNode("div", _hoisted_14, [
|
|
2066
|
+
"httpCode" in _ctx.error && _ctx.error.httpCode ? (openBlock(), createElementBlock("div", _hoisted_15, [
|
|
2067
|
+
createBaseVNode("p", _hoisted_16, toDisplayString(unref(i18n).baseText("nodeErrorView.errorCode")), 1),
|
|
2068
|
+
createBaseVNode("p", _hoisted_17, [
|
|
2069
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.httpCode), 1)
|
|
2070
|
+
])
|
|
2071
|
+
])) : createCommentVNode("", true),
|
|
2072
|
+
prepareRawMessages.value.length ? (openBlock(), createElementBlock("div", _hoisted_18, [
|
|
2073
|
+
createBaseVNode("p", _hoisted_19, toDisplayString(unref(i18n).baseText("nodeErrorView.details.rawMessages")), 1),
|
|
2074
|
+
createBaseVNode("div", _hoisted_20, [
|
|
2075
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(prepareRawMessages.value, (msg, index) => {
|
|
2076
|
+
return openBlock(), createElementBlock("div", { key: index }, [
|
|
2077
|
+
createBaseVNode("pre", null, [
|
|
2078
|
+
createBaseVNode("code", null, toDisplayString(msg), 1)
|
|
2079
|
+
])
|
|
2080
|
+
]);
|
|
2081
|
+
}), 128))
|
|
2082
|
+
])
|
|
2083
|
+
])) : createCommentVNode("", true),
|
|
2084
|
+
((_e = (_d = _ctx.error) == null ? void 0 : _d.context) == null ? void 0 : _e.data) ? (openBlock(), createElementBlock("div", _hoisted_21, [
|
|
2085
|
+
createBaseVNode("p", _hoisted_22, toDisplayString(unref(i18n).baseText("nodeErrorView.details.errorData")), 1),
|
|
2086
|
+
createBaseVNode("div", _hoisted_23, [
|
|
2087
|
+
createBaseVNode("pre", null, [
|
|
2088
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.context.data), 1)
|
|
2089
|
+
])
|
|
2090
|
+
])
|
|
2091
|
+
])) : createCommentVNode("", true),
|
|
2092
|
+
_ctx.error.extra ? (openBlock(), createElementBlock("div", _hoisted_24, [
|
|
2093
|
+
createBaseVNode("p", _hoisted_25, toDisplayString(unref(i18n).baseText("nodeErrorView.details.errorExtra")), 1),
|
|
2094
|
+
createBaseVNode("div", _hoisted_26, [
|
|
2095
|
+
createBaseVNode("pre", null, [
|
|
2096
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.extra), 1)
|
|
2097
|
+
])
|
|
2098
|
+
])
|
|
2099
|
+
])) : createCommentVNode("", true),
|
|
2100
|
+
_ctx.error.context && _ctx.error.context.request ? (openBlock(), createElementBlock("div", _hoisted_27, [
|
|
2101
|
+
createBaseVNode("p", _hoisted_28, toDisplayString(unref(i18n).baseText("nodeErrorView.details.request")), 1),
|
|
2102
|
+
createBaseVNode("div", _hoisted_29, [
|
|
2103
|
+
createBaseVNode("pre", null, [
|
|
2104
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.context.request), 1)
|
|
2105
|
+
])
|
|
2106
|
+
])
|
|
2107
|
+
])) : createCommentVNode("", true)
|
|
2108
|
+
])
|
|
2109
|
+
])) : createCommentVNode("", true),
|
|
2110
|
+
createBaseVNode("details", _hoisted_30, [
|
|
2111
|
+
createBaseVNode("summary", _hoisted_31, [
|
|
2112
|
+
createVNode(_component_font_awesome_icon, {
|
|
2113
|
+
class: "node-error-view__details-icon",
|
|
2114
|
+
icon: "angle-right"
|
|
2115
|
+
}),
|
|
2116
|
+
createTextVNode(" " + toDisplayString(unref(i18n).baseText("nodeErrorView.details.info")), 1)
|
|
2117
|
+
]),
|
|
2118
|
+
createBaseVNode("div", _hoisted_32, [
|
|
2119
|
+
_ctx.error.context && _ctx.error.context.itemIndex !== void 0 ? (openBlock(), createElementBlock("div", _hoisted_33, [
|
|
2120
|
+
createBaseVNode("p", _hoisted_34, toDisplayString(unref(i18n).baseText("nodeErrorView.itemIndex")), 1),
|
|
2121
|
+
createBaseVNode("p", _hoisted_35, [
|
|
2122
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.context.itemIndex), 1)
|
|
2123
|
+
])
|
|
2124
|
+
])) : createCommentVNode("", true),
|
|
2125
|
+
_ctx.error.context && _ctx.error.context.runIndex !== void 0 ? (openBlock(), createElementBlock("div", _hoisted_36, [
|
|
2126
|
+
createBaseVNode("p", _hoisted_37, toDisplayString(unref(i18n).baseText("nodeErrorView.runIndex")), 1),
|
|
2127
|
+
createBaseVNode("p", _hoisted_38, [
|
|
2128
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.context.runIndex), 1)
|
|
2129
|
+
])
|
|
2130
|
+
])) : createCommentVNode("", true),
|
|
2131
|
+
_ctx.error.context && _ctx.error.context.parameter !== void 0 ? (openBlock(), createElementBlock("div", _hoisted_39, [
|
|
2132
|
+
createBaseVNode("p", _hoisted_40, toDisplayString(unref(i18n).baseText("nodeErrorView.inParameter")), 1),
|
|
2133
|
+
createBaseVNode("p", _hoisted_41, [
|
|
2134
|
+
createBaseVNode("code", null, toDisplayString(parameterDisplayName(`${_ctx.error.context.parameter}`)), 1)
|
|
2135
|
+
])
|
|
2136
|
+
])) : createCommentVNode("", true),
|
|
2137
|
+
_ctx.error.node && _ctx.error.node.type ? (openBlock(), createElementBlock("div", _hoisted_42, [
|
|
2138
|
+
createBaseVNode("p", _hoisted_43, toDisplayString(unref(i18n).baseText("nodeErrorView.details.nodeType")), 1),
|
|
2139
|
+
createBaseVNode("p", _hoisted_44, [
|
|
2140
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.node.type), 1)
|
|
2141
|
+
])
|
|
2142
|
+
])) : createCommentVNode("", true),
|
|
2143
|
+
_ctx.error.node && _ctx.error.node.typeVersion ? (openBlock(), createElementBlock("div", _hoisted_45, [
|
|
2144
|
+
createBaseVNode("p", _hoisted_46, toDisplayString(unref(i18n).baseText("nodeErrorView.details.nodeVersion")), 1),
|
|
2145
|
+
createBaseVNode("p", _hoisted_47, [
|
|
2146
|
+
createBaseVNode("code", null, [
|
|
2147
|
+
createBaseVNode("span", null, toDisplayString(_ctx.error.node.typeVersion + " "), 1),
|
|
2148
|
+
createBaseVNode("span", null, "(" + toDisplayString(nodeVersionTag(_ctx.error.node)) + ")", 1)
|
|
2149
|
+
])
|
|
2150
|
+
])
|
|
2151
|
+
])) : createCommentVNode("", true),
|
|
2152
|
+
createBaseVNode("div", _hoisted_48, [
|
|
2153
|
+
createBaseVNode("p", _hoisted_49, toDisplayString(unref(i18n).baseText("nodeErrorView.details.n8nVersion")), 1),
|
|
2154
|
+
createBaseVNode("p", _hoisted_50, [
|
|
2155
|
+
createBaseVNode("code", null, toDisplayString(n8nVersion.value), 1)
|
|
2156
|
+
])
|
|
2157
|
+
]),
|
|
2158
|
+
_ctx.error.timestamp ? (openBlock(), createElementBlock("div", _hoisted_51, [
|
|
2159
|
+
createBaseVNode("p", _hoisted_52, toDisplayString(unref(i18n).baseText("nodeErrorView.time")), 1),
|
|
2160
|
+
createBaseVNode("p", _hoisted_53, [
|
|
2161
|
+
createBaseVNode("code", null, toDisplayString(new Date(_ctx.error.timestamp).toLocaleString()), 1)
|
|
2162
|
+
])
|
|
2163
|
+
])) : createCommentVNode("", true),
|
|
2164
|
+
_ctx.error.cause && displayCause.value ? (openBlock(), createElementBlock("div", _hoisted_54, [
|
|
2165
|
+
createBaseVNode("p", _hoisted_55, toDisplayString(unref(i18n).baseText("nodeErrorView.details.errorCause")), 1),
|
|
2166
|
+
createBaseVNode("pre", _hoisted_56, [
|
|
2167
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.cause), 1)
|
|
2168
|
+
])
|
|
2169
|
+
])) : createCommentVNode("", true),
|
|
2170
|
+
_ctx.error.context && _ctx.error.context.causeDetailed ? (openBlock(), createElementBlock("div", _hoisted_57, [
|
|
2171
|
+
createBaseVNode("p", _hoisted_58, toDisplayString(unref(i18n).baseText("nodeErrorView.details.causeDetailed")), 1),
|
|
2172
|
+
createBaseVNode("pre", _hoisted_59, [
|
|
2173
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.context.causeDetailed), 1)
|
|
2174
|
+
])
|
|
2175
|
+
])) : createCommentVNode("", true),
|
|
2176
|
+
_ctx.error.stack ? (openBlock(), createElementBlock("div", _hoisted_60, [
|
|
2177
|
+
createBaseVNode("p", _hoisted_61, toDisplayString(unref(i18n).baseText("nodeErrorView.details.stackTrace")), 1),
|
|
2178
|
+
createBaseVNode("pre", _hoisted_62, [
|
|
2179
|
+
createBaseVNode("code", null, toDisplayString(_ctx.error.stack), 1)
|
|
2180
|
+
])
|
|
2181
|
+
])) : createCommentVNode("", true)
|
|
2182
|
+
])
|
|
2183
|
+
])
|
|
2184
|
+
])
|
|
2185
|
+
])) : createCommentVNode("", true)
|
|
2186
|
+
]);
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
const fallbackParser = (execData) => ({
|
|
2191
|
+
type: "json",
|
|
2192
|
+
data: execData,
|
|
2193
|
+
parsed: false
|
|
2194
|
+
});
|
|
2195
|
+
const outputTypeParsers = {
|
|
2196
|
+
[NodeConnectionType.AiLanguageModel](execData) {
|
|
2197
|
+
const response = execData.response ?? execData;
|
|
2198
|
+
if (!response) throw new Error("No response from Language Model");
|
|
2199
|
+
if (Array.isArray(response == null ? void 0 : response.messages) && (response == null ? void 0 : response.messages.length) === 1 && typeof (response == null ? void 0 : response.messages[0]) === "string") {
|
|
2200
|
+
return {
|
|
2201
|
+
type: "text",
|
|
2202
|
+
data: response.messages[0],
|
|
2203
|
+
parsed: true
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
if (response.messages && Array.isArray(response.messages)) {
|
|
2207
|
+
return outputTypeParsers[NodeConnectionType.AiMemory](execData);
|
|
2208
|
+
}
|
|
2209
|
+
if (response.generations) {
|
|
2210
|
+
const generations = response.generations;
|
|
2211
|
+
const content = generations.map((generation) => {
|
|
2212
|
+
if (generation == null ? void 0 : generation.text) return generation.text;
|
|
2213
|
+
if (Array.isArray(generation)) {
|
|
2214
|
+
return generation.map((item) => item.text ?? item).join("\n\n").trim();
|
|
2215
|
+
}
|
|
2216
|
+
return generation;
|
|
2217
|
+
});
|
|
2218
|
+
return {
|
|
2219
|
+
type: "json",
|
|
2220
|
+
data: content,
|
|
2221
|
+
parsed: true
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
return {
|
|
2225
|
+
type: "json",
|
|
2226
|
+
data: response,
|
|
2227
|
+
parsed: true
|
|
2228
|
+
};
|
|
2229
|
+
},
|
|
2230
|
+
[NodeConnectionType.AiTool]: fallbackParser,
|
|
2231
|
+
[NodeConnectionType.AiAgent]: fallbackParser,
|
|
2232
|
+
[NodeConnectionType.AiMemory](execData) {
|
|
2233
|
+
var _a;
|
|
2234
|
+
const chatHistory = execData.chatHistory ?? execData.messages ?? ((_a = execData == null ? void 0 : execData.response) == null ? void 0 : _a.chat_history);
|
|
2235
|
+
if (Array.isArray(chatHistory)) {
|
|
2236
|
+
const responseText = chatHistory.map((content) => {
|
|
2237
|
+
var _a2;
|
|
2238
|
+
if (content.type === "constructor" && ((_a2 = content.id) == null ? void 0 : _a2.includes("messages")) && content.kwargs) {
|
|
2239
|
+
let message = content.kwargs.content;
|
|
2240
|
+
if (Array.isArray(message)) {
|
|
2241
|
+
message = message.map((item) => {
|
|
2242
|
+
const { type, image_url } = item;
|
|
2243
|
+
if (type === "image_url" && typeof image_url === "object" && typeof image_url.url === "string") {
|
|
2244
|
+
return ``;
|
|
2245
|
+
} else if (typeof image_url === "string") {
|
|
2246
|
+
return ``;
|
|
2247
|
+
}
|
|
2248
|
+
return item.text;
|
|
2249
|
+
}).join("\n");
|
|
2250
|
+
}
|
|
2251
|
+
if (Object.keys(content.kwargs.additional_kwargs).length) {
|
|
2252
|
+
message += ` (${JSON.stringify(content.kwargs.additional_kwargs)})`;
|
|
2253
|
+
}
|
|
2254
|
+
if (content.id.includes("HumanMessage")) {
|
|
2255
|
+
message = `**Human:** ${String(message).trim()}`;
|
|
2256
|
+
} else if (content.id.includes("AIMessage")) {
|
|
2257
|
+
message = `**AI:** ${message}`;
|
|
2258
|
+
} else if (content.id.includes("SystemMessage")) {
|
|
2259
|
+
message = `**System Message:** ${message}`;
|
|
2260
|
+
}
|
|
2261
|
+
return message;
|
|
2262
|
+
}
|
|
2263
|
+
return "";
|
|
2264
|
+
}).join("\n\n");
|
|
2265
|
+
if (responseText.length === 0) {
|
|
2266
|
+
return fallbackParser(execData);
|
|
2267
|
+
}
|
|
2268
|
+
return {
|
|
2269
|
+
type: "markdown",
|
|
2270
|
+
data: responseText,
|
|
2271
|
+
parsed: true
|
|
2272
|
+
};
|
|
2273
|
+
}
|
|
2274
|
+
return fallbackParser(execData);
|
|
2275
|
+
},
|
|
2276
|
+
[NodeConnectionType.AiOutputParser]: fallbackParser,
|
|
2277
|
+
[NodeConnectionType.AiRetriever]: fallbackParser,
|
|
2278
|
+
[NodeConnectionType.AiVectorStore](execData) {
|
|
2279
|
+
if (execData.documents) {
|
|
2280
|
+
return {
|
|
2281
|
+
type: "json",
|
|
2282
|
+
data: execData.documents,
|
|
2283
|
+
parsed: true
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
return fallbackParser(execData);
|
|
2287
|
+
},
|
|
2288
|
+
[NodeConnectionType.AiEmbedding](execData) {
|
|
2289
|
+
if (execData.documents) {
|
|
2290
|
+
return {
|
|
2291
|
+
type: "json",
|
|
2292
|
+
data: execData.documents,
|
|
2293
|
+
parsed: true
|
|
2294
|
+
};
|
|
2295
|
+
}
|
|
2296
|
+
return fallbackParser(execData);
|
|
2297
|
+
},
|
|
2298
|
+
[NodeConnectionType.AiDocument](execData) {
|
|
2299
|
+
if (execData.documents) {
|
|
2300
|
+
return {
|
|
2301
|
+
type: "json",
|
|
2302
|
+
data: execData.documents,
|
|
2303
|
+
parsed: true
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
return fallbackParser(execData);
|
|
2307
|
+
},
|
|
2308
|
+
[NodeConnectionType.AiTextSplitter](execData) {
|
|
2309
|
+
const arrayData = Array.isArray(execData.response) ? execData.response : [execData.textSplitter];
|
|
2310
|
+
return {
|
|
2311
|
+
type: "text",
|
|
2312
|
+
data: arrayData.join("\n\n"),
|
|
2313
|
+
parsed: true
|
|
2314
|
+
};
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
const useAiContentParsers = () => {
|
|
2318
|
+
const parseAiRunData = (executionData, endpointType) => {
|
|
2319
|
+
if ([NodeConnectionType.AiChain, NodeConnectionType.Main].includes(endpointType)) {
|
|
2320
|
+
return executionData.map((data) => ({ raw: data.json, parsedContent: null }));
|
|
2321
|
+
}
|
|
2322
|
+
const contentJson = executionData.map((node) => {
|
|
2323
|
+
const hasBinaryData = !isObjectEmpty(node.binary);
|
|
2324
|
+
return hasBinaryData ? node.binary : node.json;
|
|
2325
|
+
});
|
|
2326
|
+
const parser = outputTypeParsers[endpointType];
|
|
2327
|
+
if (!parser)
|
|
2328
|
+
return [
|
|
2329
|
+
{
|
|
2330
|
+
raw: contentJson.filter((item) => item !== void 0),
|
|
2331
|
+
parsedContent: null
|
|
2332
|
+
}
|
|
2333
|
+
];
|
|
2334
|
+
const parsedOutput = contentJson.filter((c) => c !== void 0).map((c) => ({ raw: c, parsedContent: parser(c) }));
|
|
2335
|
+
return parsedOutput;
|
|
2336
|
+
};
|
|
2337
|
+
return {
|
|
2338
|
+
parseAiRunData
|
|
2339
|
+
};
|
|
2340
|
+
};
|
|
2341
|
+
const _hoisted_1$2 = ["data-content-type"];
|
|
2342
|
+
const _hoisted_2$2 = ["textContent"];
|
|
2343
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
2344
|
+
__name: "AiRunContentBlock",
|
|
2345
|
+
props: {
|
|
2346
|
+
runData: {},
|
|
2347
|
+
error: {}
|
|
2348
|
+
},
|
|
2349
|
+
setup(__props) {
|
|
2350
|
+
const props = __props;
|
|
2351
|
+
const i18n = useI18n();
|
|
2352
|
+
const clipboard = useClipboard();
|
|
2353
|
+
const { showMessage } = useToast();
|
|
2354
|
+
const contentParsers = useAiContentParsers();
|
|
2355
|
+
const isExpanded = ref(getInitialExpandedState());
|
|
2356
|
+
const renderType = ref("rendered");
|
|
2357
|
+
const contentParsed = ref(false);
|
|
2358
|
+
const parsedRun = ref(void 0);
|
|
2359
|
+
function getInitialExpandedState() {
|
|
2360
|
+
const collapsedTypes = {
|
|
2361
|
+
input: [NodeConnectionType.AiDocument, NodeConnectionType.AiTextSplitter],
|
|
2362
|
+
output: [
|
|
2363
|
+
NodeConnectionType.AiDocument,
|
|
2364
|
+
NodeConnectionType.AiEmbedding,
|
|
2365
|
+
NodeConnectionType.AiTextSplitter,
|
|
2366
|
+
NodeConnectionType.AiVectorStore
|
|
2367
|
+
]
|
|
2368
|
+
};
|
|
2369
|
+
return !collapsedTypes[props.runData.inOut].includes(props.runData.type);
|
|
2370
|
+
}
|
|
2371
|
+
function isJsonString(text) {
|
|
2372
|
+
try {
|
|
2373
|
+
JSON.parse(text);
|
|
2374
|
+
return true;
|
|
2375
|
+
} catch (e) {
|
|
2376
|
+
return false;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
const markdownOptions = {
|
|
2380
|
+
highlight(str, lang) {
|
|
2381
|
+
if (lang && HighlightJS.getLanguage(lang)) {
|
|
2382
|
+
try {
|
|
2383
|
+
return HighlightJS.highlight(str, { language: lang }).value;
|
|
2384
|
+
} catch {
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
return "";
|
|
2388
|
+
}
|
|
2389
|
+
};
|
|
2390
|
+
function parseAiRunData(run) {
|
|
2391
|
+
if (!run.data) {
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2394
|
+
const parsedData = contentParsers.parseAiRunData(run.data, run.type);
|
|
2395
|
+
return parsedData;
|
|
2396
|
+
}
|
|
2397
|
+
function isMarkdown(content) {
|
|
2398
|
+
if (typeof content !== "string") return false;
|
|
2399
|
+
const markdownPatterns = [
|
|
2400
|
+
/^# .+/gm,
|
|
2401
|
+
// headers
|
|
2402
|
+
/\*{1,2}.+\*{1,2}/g,
|
|
2403
|
+
// emphasis and strong
|
|
2404
|
+
/\[.+\]\(.+\)/g,
|
|
2405
|
+
// links
|
|
2406
|
+
/```[\s\S]+```/g
|
|
2407
|
+
// code blocks
|
|
2408
|
+
];
|
|
2409
|
+
return markdownPatterns.some((pattern) => pattern.test(content));
|
|
2410
|
+
}
|
|
2411
|
+
function formatToJsonMarkdown(data) {
|
|
2412
|
+
return "```json\n" + data + "\n```";
|
|
2413
|
+
}
|
|
2414
|
+
function jsonToMarkdown(data) {
|
|
2415
|
+
if (isMarkdown(data)) return data;
|
|
2416
|
+
if (Array.isArray(data) && data.length && typeof data[0] !== "number") {
|
|
2417
|
+
const markdownArray = data.map((item) => jsonToMarkdown(item));
|
|
2418
|
+
return markdownArray.join("\n\n").trim();
|
|
2419
|
+
}
|
|
2420
|
+
if (typeof data === "string") {
|
|
2421
|
+
if (isJsonString(data)) {
|
|
2422
|
+
return formatToJsonMarkdown(data);
|
|
2423
|
+
}
|
|
2424
|
+
return data;
|
|
2425
|
+
}
|
|
2426
|
+
return formatToJsonMarkdown(JSON.stringify(data, null, 2));
|
|
2427
|
+
}
|
|
2428
|
+
function setContentParsed(content) {
|
|
2429
|
+
contentParsed.value = !!content.find((item) => {
|
|
2430
|
+
var _a;
|
|
2431
|
+
if (((_a = item.parsedContent) == null ? void 0 : _a.parsed) === true) {
|
|
2432
|
+
return true;
|
|
2433
|
+
}
|
|
2434
|
+
return false;
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
function onBlockHeaderClick() {
|
|
2438
|
+
isExpanded.value = !isExpanded.value;
|
|
2439
|
+
}
|
|
2440
|
+
function onCopyToClipboard(content) {
|
|
2441
|
+
try {
|
|
2442
|
+
void clipboard.copy(JSON.stringify(content, void 0, 2));
|
|
2443
|
+
showMessage({
|
|
2444
|
+
title: i18n.baseText("generic.copiedToClipboard"),
|
|
2445
|
+
type: "success"
|
|
2446
|
+
});
|
|
2447
|
+
} catch (err) {
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
function onRenderTypeChange(value) {
|
|
2451
|
+
renderType.value = value;
|
|
2452
|
+
}
|
|
2453
|
+
onMounted(() => {
|
|
2454
|
+
parsedRun.value = parseAiRunData(props.runData);
|
|
2455
|
+
if (parsedRun.value) {
|
|
2456
|
+
setContentParsed(parsedRun.value);
|
|
2457
|
+
}
|
|
2458
|
+
});
|
|
2459
|
+
return (_ctx, _cache) => {
|
|
2460
|
+
const _component_font_awesome_icon = resolveComponent("font-awesome-icon");
|
|
2461
|
+
const _component_n8n_radio_buttons = resolveComponent("n8n-radio-buttons");
|
|
2462
|
+
const _component_NodeErrorView = _sfc_main$3;
|
|
2463
|
+
const _component_n8n_icon_button = resolveComponent("n8n-icon-button");
|
|
2464
|
+
return openBlock(), createElementBlock("div", {
|
|
2465
|
+
class: normalizeClass(_ctx.$style.block)
|
|
2466
|
+
}, [
|
|
2467
|
+
createBaseVNode("header", {
|
|
2468
|
+
class: normalizeClass(_ctx.$style.blockHeader),
|
|
2469
|
+
onClick: onBlockHeaderClick
|
|
2470
|
+
}, [
|
|
2471
|
+
createBaseVNode("button", {
|
|
2472
|
+
class: normalizeClass(_ctx.$style.blockToggle)
|
|
2473
|
+
}, [
|
|
2474
|
+
createVNode(_component_font_awesome_icon, {
|
|
2475
|
+
icon: isExpanded.value ? "angle-down" : "angle-right",
|
|
2476
|
+
size: "lg"
|
|
2477
|
+
}, null, 8, ["icon"])
|
|
2478
|
+
], 2),
|
|
2479
|
+
createBaseVNode("p", {
|
|
2480
|
+
class: normalizeClass(_ctx.$style.blockTitle)
|
|
2481
|
+
}, toDisplayString(unref(capitalize)(_ctx.runData.inOut)), 3),
|
|
2482
|
+
contentParsed.value && !_ctx.error && isExpanded.value ? (openBlock(), createBlock(_component_n8n_radio_buttons, {
|
|
2483
|
+
key: 0,
|
|
2484
|
+
size: "small",
|
|
2485
|
+
"model-value": renderType.value,
|
|
2486
|
+
class: normalizeClass(_ctx.$style.rawSwitch),
|
|
2487
|
+
options: [
|
|
2488
|
+
{ label: "Rendered", value: "rendered" },
|
|
2489
|
+
{ label: "JSON", value: "json" }
|
|
2490
|
+
],
|
|
2491
|
+
"onUpdate:modelValue": onRenderTypeChange
|
|
2492
|
+
}, null, 8, ["model-value", "class"])) : createCommentVNode("", true)
|
|
2493
|
+
], 2),
|
|
2494
|
+
createBaseVNode("main", {
|
|
2495
|
+
class: normalizeClass({
|
|
2496
|
+
[_ctx.$style.blockContent]: true,
|
|
2497
|
+
[_ctx.$style.blockContentExpanded]: isExpanded.value
|
|
2498
|
+
})
|
|
2499
|
+
}, [
|
|
2500
|
+
_ctx.error ? (openBlock(), createBlock(_component_NodeErrorView, {
|
|
2501
|
+
key: 0,
|
|
2502
|
+
error: _ctx.error,
|
|
2503
|
+
class: normalizeClass(_ctx.$style.error)
|
|
2504
|
+
}, null, 8, ["error", "class"])) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(parsedRun.value, ({ parsedContent, raw }, index) => {
|
|
2505
|
+
return openBlock(), createElementBlock("div", {
|
|
2506
|
+
key: index,
|
|
2507
|
+
class: normalizeClass(_ctx.$style.contentText),
|
|
2508
|
+
"data-content-type": parsedContent == null ? void 0 : parsedContent.type
|
|
2509
|
+
}, [
|
|
2510
|
+
parsedContent && renderType.value === "rendered" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2511
|
+
parsedContent.type === "json" ? (openBlock(), createBlock(unref(VueMarkdown), {
|
|
2512
|
+
key: 0,
|
|
2513
|
+
source: jsonToMarkdown(parsedContent.data),
|
|
2514
|
+
class: normalizeClass(_ctx.$style.markdown),
|
|
2515
|
+
options: markdownOptions
|
|
2516
|
+
}, null, 8, ["source", "class"])) : createCommentVNode("", true),
|
|
2517
|
+
parsedContent.type === "markdown" ? (openBlock(), createBlock(unref(VueMarkdown), {
|
|
2518
|
+
key: 1,
|
|
2519
|
+
source: parsedContent.data,
|
|
2520
|
+
class: normalizeClass(_ctx.$style.markdown),
|
|
2521
|
+
options: markdownOptions
|
|
2522
|
+
}, null, 8, ["source", "class"])) : createCommentVNode("", true),
|
|
2523
|
+
parsedContent.type === "text" ? (openBlock(), createElementBlock("p", {
|
|
2524
|
+
key: 2,
|
|
2525
|
+
class: normalizeClass(_ctx.$style.runText),
|
|
2526
|
+
textContent: toDisplayString(parsedContent.data)
|
|
2527
|
+
}, null, 10, _hoisted_2$2)) : createCommentVNode("", true)
|
|
2528
|
+
], 64)) : (openBlock(), createElementBlock("div", {
|
|
2529
|
+
key: 1,
|
|
2530
|
+
class: normalizeClass(_ctx.$style.rawContent)
|
|
2531
|
+
}, [
|
|
2532
|
+
createVNode(_component_n8n_icon_button, {
|
|
2533
|
+
size: "small",
|
|
2534
|
+
class: normalizeClass(_ctx.$style.copyToClipboard),
|
|
2535
|
+
type: "secondary",
|
|
2536
|
+
title: unref(i18n).baseText("nodeErrorView.copyToClipboard"),
|
|
2537
|
+
icon: "copy",
|
|
2538
|
+
onClick: ($event) => onCopyToClipboard(raw)
|
|
2539
|
+
}, null, 8, ["class", "title", "onClick"]),
|
|
2540
|
+
createVNode(unref(VueMarkdown), {
|
|
2541
|
+
source: jsonToMarkdown(raw),
|
|
2542
|
+
class: normalizeClass(_ctx.$style.markdown)
|
|
2543
|
+
}, null, 8, ["source", "class"])
|
|
2544
|
+
], 2))
|
|
2545
|
+
], 10, _hoisted_1$2);
|
|
2546
|
+
}), 128))
|
|
2547
|
+
], 2)
|
|
2548
|
+
], 2);
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
});
|
|
2552
|
+
const copyToClipboard = "_copyToClipboard_1htnj_1";
|
|
2553
|
+
const rawContent = "_rawContent_1htnj_7";
|
|
2554
|
+
const markdown = "_markdown_1htnj_11";
|
|
2555
|
+
const contentText = "_contentText_1htnj_35";
|
|
2556
|
+
const block = "_block_1htnj_41";
|
|
2557
|
+
const blockContent = "_blockContent_1htnj_48";
|
|
2558
|
+
const blockContentExpanded = "_blockContentExpanded_1htnj_52";
|
|
2559
|
+
const runText = "_runText_1htnj_56";
|
|
2560
|
+
const rawSwitch = "_rawSwitch_1htnj_61";
|
|
2561
|
+
const blockHeader = "_blockHeader_1htnj_71";
|
|
2562
|
+
const blockTitle = "_blockTitle_1htnj_84";
|
|
2563
|
+
const blockToggle = "_blockToggle_1htnj_91";
|
|
2564
|
+
const error = "_error_1htnj_99";
|
|
2565
|
+
const style0$2 = {
|
|
2566
|
+
copyToClipboard,
|
|
2567
|
+
rawContent,
|
|
2568
|
+
markdown,
|
|
2569
|
+
contentText,
|
|
2570
|
+
block,
|
|
2571
|
+
blockContent,
|
|
2572
|
+
blockContentExpanded,
|
|
2573
|
+
runText,
|
|
2574
|
+
rawSwitch,
|
|
2575
|
+
blockHeader,
|
|
2576
|
+
blockTitle,
|
|
2577
|
+
blockToggle,
|
|
2578
|
+
error
|
|
2579
|
+
};
|
|
2580
|
+
const cssModules$2 = {
|
|
2581
|
+
"$style": style0$2
|
|
2582
|
+
};
|
|
2583
|
+
const AiRunContentBlock = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__cssModules", cssModules$2]]);
|
|
2584
|
+
const _hoisted_1$1 = { key: 0 };
|
|
2585
|
+
const _hoisted_2$1 = { key: 1 };
|
|
2586
|
+
const _hoisted_3$1 = { key: 2 };
|
|
2587
|
+
const _hoisted_4 = ["href"];
|
|
2588
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
2589
|
+
__name: "RunDataAiContent",
|
|
2590
|
+
props: {
|
|
2591
|
+
inputData: {},
|
|
2592
|
+
contentIndex: {}
|
|
2593
|
+
},
|
|
2594
|
+
setup(__props) {
|
|
2595
|
+
const props = __props;
|
|
2596
|
+
const nodeTypesStore = useNodeTypesStore();
|
|
2597
|
+
const workflowsStore = useWorkflowsStore();
|
|
2598
|
+
const { trackOpeningRelatedExecution, resolveRelatedExecutionUrl } = useExecutionHelpers();
|
|
2599
|
+
const i18n = useI18n();
|
|
2600
|
+
const consumedTokensSum = computed(() => {
|
|
2601
|
+
var _a, _b;
|
|
2602
|
+
const tokenUsage = (_b = (_a = outputRun.value) == null ? void 0 : _a.data) == null ? void 0 : _b.reduce(
|
|
2603
|
+
(acc, curr) => {
|
|
2604
|
+
var _a2, _b2;
|
|
2605
|
+
const tokenUsageData = ((_a2 = curr.json) == null ? void 0 : _a2.tokenUsage) ?? ((_b2 = curr.json) == null ? void 0 : _b2.tokenUsageEstimate);
|
|
2606
|
+
if (!tokenUsageData) return acc;
|
|
2607
|
+
return {
|
|
2608
|
+
completionTokens: acc.completionTokens + tokenUsageData.completionTokens,
|
|
2609
|
+
promptTokens: acc.promptTokens + tokenUsageData.promptTokens,
|
|
2610
|
+
totalTokens: acc.totalTokens + tokenUsageData.totalTokens
|
|
2611
|
+
};
|
|
2612
|
+
},
|
|
2613
|
+
{
|
|
2614
|
+
completionTokens: 0,
|
|
2615
|
+
promptTokens: 0,
|
|
2616
|
+
totalTokens: 0
|
|
2617
|
+
}
|
|
2618
|
+
);
|
|
2619
|
+
return tokenUsage;
|
|
2620
|
+
});
|
|
2621
|
+
const usingTokensEstimates = computed(() => {
|
|
2622
|
+
var _a, _b;
|
|
2623
|
+
return (_b = (_a = outputRun.value) == null ? void 0 : _a.data) == null ? void 0 : _b.some((d) => {
|
|
2624
|
+
var _a2;
|
|
2625
|
+
return (_a2 = d.json) == null ? void 0 : _a2.tokenUsageEstimate;
|
|
2626
|
+
});
|
|
2627
|
+
});
|
|
2628
|
+
function formatTokenUsageCount(count) {
|
|
2629
|
+
return usingTokensEstimates.value ? `~${count}` : count.toString();
|
|
2630
|
+
}
|
|
2631
|
+
function extractRunMeta(run) {
|
|
2632
|
+
var _a;
|
|
2633
|
+
const uiNode = workflowsStore.getNodeByName(props.inputData.node);
|
|
2634
|
+
const nodeType = nodeTypesStore.getNodeType((uiNode == null ? void 0 : uiNode.type) ?? "");
|
|
2635
|
+
const runMeta2 = {
|
|
2636
|
+
startTimeMs: run.metadata.startTime,
|
|
2637
|
+
executionTimeMs: run.metadata.executionTime,
|
|
2638
|
+
node: nodeType,
|
|
2639
|
+
type: run.inOut,
|
|
2640
|
+
connectionType: run.type,
|
|
2641
|
+
subExecution: (_a = run.metadata) == null ? void 0 : _a.subExecution
|
|
2642
|
+
};
|
|
2643
|
+
return runMeta2;
|
|
2644
|
+
}
|
|
2645
|
+
const outputRun = computed(() => {
|
|
2646
|
+
return props.inputData.data.find((r) => r.inOut === "output");
|
|
2647
|
+
});
|
|
2648
|
+
const runMeta = computed(() => {
|
|
2649
|
+
if (outputRun.value === void 0) {
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
return extractRunMeta(outputRun.value);
|
|
2653
|
+
});
|
|
2654
|
+
const executionRunData = computed(() => {
|
|
2655
|
+
var _a, _b, _c;
|
|
2656
|
+
return (_c = (_b = (_a = workflowsStore.getWorkflowExecution) == null ? void 0 : _a.data) == null ? void 0 : _b.resultData) == null ? void 0 : _c.runData;
|
|
2657
|
+
});
|
|
2658
|
+
const outputError = computed(() => {
|
|
2659
|
+
var _a, _b, _c;
|
|
2660
|
+
return (_c = (_b = (_a = executionRunData.value) == null ? void 0 : _a[props.inputData.node]) == null ? void 0 : _b[props.inputData.runIndex]) == null ? void 0 : _c.error;
|
|
2661
|
+
});
|
|
2662
|
+
return (_ctx, _cache) => {
|
|
2663
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2664
|
+
const _component_n8n_tooltip = resolveComponent("n8n-tooltip");
|
|
2665
|
+
const _component_N8nIcon = resolveComponent("N8nIcon");
|
|
2666
|
+
const _component_n8n_text = resolveComponent("n8n-text");
|
|
2667
|
+
const _component_n8n_info_tip = resolveComponent("n8n-info-tip");
|
|
2668
|
+
return openBlock(), createElementBlock("div", {
|
|
2669
|
+
class: normalizeClass(_ctx.$style.container)
|
|
2670
|
+
}, [
|
|
2671
|
+
createBaseVNode("header", {
|
|
2672
|
+
class: normalizeClass(_ctx.$style.header)
|
|
2673
|
+
}, [
|
|
2674
|
+
((_a = runMeta.value) == null ? void 0 : _a.node) ? (openBlock(), createBlock(_sfc_main$4, {
|
|
2675
|
+
key: 0,
|
|
2676
|
+
class: normalizeClass(_ctx.$style.nodeIcon),
|
|
2677
|
+
"node-type": runMeta.value.node,
|
|
2678
|
+
size: 20
|
|
2679
|
+
}, null, 8, ["class", "node-type"])) : createCommentVNode("", true),
|
|
2680
|
+
createBaseVNode("div", {
|
|
2681
|
+
class: normalizeClass(_ctx.$style.headerWrap)
|
|
2682
|
+
}, [
|
|
2683
|
+
createBaseVNode("p", {
|
|
2684
|
+
class: normalizeClass(_ctx.$style.title)
|
|
2685
|
+
}, toDisplayString(_ctx.inputData.node), 3),
|
|
2686
|
+
createBaseVNode("ul", {
|
|
2687
|
+
class: normalizeClass(_ctx.$style.meta)
|
|
2688
|
+
}, [
|
|
2689
|
+
((_b = runMeta.value) == null ? void 0 : _b.startTimeMs) ? (openBlock(), createElementBlock("li", _hoisted_1$1, toDisplayString((_c = runMeta.value) == null ? void 0 : _c.executionTimeMs) + "ms", 1)) : createCommentVNode("", true),
|
|
2690
|
+
((_d = runMeta.value) == null ? void 0 : _d.startTimeMs) ? (openBlock(), createElementBlock("li", _hoisted_2$1, [
|
|
2691
|
+
createVNode(_component_n8n_tooltip, null, {
|
|
2692
|
+
content: withCtx(() => {
|
|
2693
|
+
var _a2;
|
|
2694
|
+
return [
|
|
2695
|
+
createTextVNode(toDisplayString(new Date((_a2 = runMeta.value) == null ? void 0 : _a2.startTimeMs).toLocaleString()), 1)
|
|
2696
|
+
];
|
|
2697
|
+
}),
|
|
2698
|
+
default: withCtx(() => {
|
|
2699
|
+
var _a2;
|
|
2700
|
+
return [
|
|
2701
|
+
createTextVNode(" " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.startedAt", {
|
|
2702
|
+
interpolate: {
|
|
2703
|
+
startTime: new Date((_a2 = runMeta.value) == null ? void 0 : _a2.startTimeMs).toLocaleTimeString()
|
|
2704
|
+
}
|
|
2705
|
+
})), 1)
|
|
2706
|
+
];
|
|
2707
|
+
}),
|
|
2708
|
+
_: 1
|
|
2709
|
+
})
|
|
2710
|
+
])) : createCommentVNode("", true),
|
|
2711
|
+
((_e = runMeta.value) == null ? void 0 : _e.subExecution) ? (openBlock(), createElementBlock("li", _hoisted_3$1, [
|
|
2712
|
+
createBaseVNode("a", {
|
|
2713
|
+
href: unref(resolveRelatedExecutionUrl)(runMeta.value),
|
|
2714
|
+
target: "_blank",
|
|
2715
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => unref(trackOpeningRelatedExecution)(runMeta.value, "ai"), ["stop"]))
|
|
2716
|
+
}, [
|
|
2717
|
+
createVNode(_component_N8nIcon, {
|
|
2718
|
+
icon: "external-link-alt",
|
|
2719
|
+
size: "xsmall"
|
|
2720
|
+
}),
|
|
2721
|
+
createTextVNode(" " + toDisplayString(unref(i18n).baseText("runData.openSubExecution", {
|
|
2722
|
+
interpolate: {
|
|
2723
|
+
id: (_f = runMeta.value.subExecution) == null ? void 0 : _f.executionId
|
|
2724
|
+
}
|
|
2725
|
+
})), 1)
|
|
2726
|
+
], 8, _hoisted_4)
|
|
2727
|
+
])) : createCommentVNode("", true),
|
|
2728
|
+
(((_g = consumedTokensSum.value) == null ? void 0 : _g.totalTokens) ?? 0) > 0 ? (openBlock(), createElementBlock("li", {
|
|
2729
|
+
key: 3,
|
|
2730
|
+
class: normalizeClass(_ctx.$style.tokensUsage)
|
|
2731
|
+
}, [
|
|
2732
|
+
createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
|
|
2733
|
+
interpolate: {
|
|
2734
|
+
count: formatTokenUsageCount(((_h = consumedTokensSum.value) == null ? void 0 : _h.totalTokens) ?? 0)
|
|
2735
|
+
}
|
|
2736
|
+
})) + " ", 1),
|
|
2737
|
+
createVNode(_component_n8n_info_tip, {
|
|
2738
|
+
type: "tooltip",
|
|
2739
|
+
theme: "info-light",
|
|
2740
|
+
"tooltip-placement": "right"
|
|
2741
|
+
}, {
|
|
2742
|
+
default: withCtx(() => [
|
|
2743
|
+
createBaseVNode("div", null, [
|
|
2744
|
+
createVNode(_component_n8n_text, {
|
|
2745
|
+
bold: true,
|
|
2746
|
+
size: "small"
|
|
2747
|
+
}, {
|
|
2748
|
+
default: withCtx(() => {
|
|
2749
|
+
var _a2;
|
|
2750
|
+
return [
|
|
2751
|
+
createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens.prompt")) + " " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
|
|
2752
|
+
interpolate: {
|
|
2753
|
+
count: formatTokenUsageCount(((_a2 = consumedTokensSum.value) == null ? void 0 : _a2.promptTokens) ?? 0)
|
|
2754
|
+
}
|
|
2755
|
+
})), 1)
|
|
2756
|
+
];
|
|
2757
|
+
}),
|
|
2758
|
+
_: 1
|
|
2759
|
+
}),
|
|
2760
|
+
_cache[1] || (_cache[1] = createBaseVNode("br", null, null, -1)),
|
|
2761
|
+
createVNode(_component_n8n_text, {
|
|
2762
|
+
bold: true,
|
|
2763
|
+
size: "small"
|
|
2764
|
+
}, {
|
|
2765
|
+
default: withCtx(() => {
|
|
2766
|
+
var _a2;
|
|
2767
|
+
return [
|
|
2768
|
+
createTextVNode(toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens.completion")) + " " + toDisplayString(unref(i18n).baseText("runData.aiContentBlock.tokens", {
|
|
2769
|
+
interpolate: {
|
|
2770
|
+
count: formatTokenUsageCount(((_a2 = consumedTokensSum.value) == null ? void 0 : _a2.completionTokens) ?? 0)
|
|
2771
|
+
}
|
|
2772
|
+
})), 1)
|
|
2773
|
+
];
|
|
2774
|
+
}),
|
|
2775
|
+
_: 1
|
|
2776
|
+
})
|
|
2777
|
+
])
|
|
2778
|
+
]),
|
|
2779
|
+
_: 1
|
|
2780
|
+
})
|
|
2781
|
+
], 2)) : createCommentVNode("", true)
|
|
2782
|
+
], 2)
|
|
2783
|
+
], 2)
|
|
2784
|
+
], 2),
|
|
2785
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(props.inputData.data, (run, index) => {
|
|
2786
|
+
return openBlock(), createElementBlock("main", {
|
|
2787
|
+
key: index,
|
|
2788
|
+
class: normalizeClass(_ctx.$style.content)
|
|
2789
|
+
}, [
|
|
2790
|
+
createVNode(AiRunContentBlock, {
|
|
2791
|
+
"run-data": run,
|
|
2792
|
+
error: run.inOut === "output" ? outputError.value : void 0
|
|
2793
|
+
}, null, 8, ["run-data", "error"])
|
|
2794
|
+
], 2);
|
|
2795
|
+
}), 128))
|
|
2796
|
+
], 2);
|
|
2797
|
+
};
|
|
2798
|
+
}
|
|
2799
|
+
});
|
|
2800
|
+
const container$1 = "_container_dypaw_2";
|
|
2801
|
+
const nodeIcon$1 = "_nodeIcon_dypaw_5";
|
|
2802
|
+
const header = "_header_dypaw_8";
|
|
2803
|
+
const headerWrap = "_headerWrap_dypaw_14";
|
|
2804
|
+
const title$1 = "_title_dypaw_18";
|
|
2805
|
+
const meta = "_meta_dypaw_25";
|
|
2806
|
+
const tokensUsage = "_tokensUsage_dypaw_41";
|
|
2807
|
+
const style0$1 = {
|
|
2808
|
+
container: container$1,
|
|
2809
|
+
nodeIcon: nodeIcon$1,
|
|
2810
|
+
header,
|
|
2811
|
+
headerWrap,
|
|
2812
|
+
title: title$1,
|
|
2813
|
+
meta,
|
|
2814
|
+
tokensUsage
|
|
2815
|
+
};
|
|
2816
|
+
const cssModules$1 = {
|
|
2817
|
+
"$style": style0$1
|
|
2818
|
+
};
|
|
2819
|
+
const RunDataAiContent = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__cssModules", cssModules$1]]);
|
|
2820
|
+
const _hoisted_1 = ["data-tree-depth"];
|
|
2821
|
+
const _hoisted_2 = ["onClick"];
|
|
2822
|
+
const _hoisted_3 = ["textContent"];
|
|
2823
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
2824
|
+
__name: "RunDataAi",
|
|
2825
|
+
props: {
|
|
2826
|
+
node: {},
|
|
2827
|
+
runIndex: { default: 0 },
|
|
2828
|
+
slim: { type: Boolean },
|
|
2829
|
+
workflow: {}
|
|
2830
|
+
},
|
|
2831
|
+
setup(__props) {
|
|
2832
|
+
const props = __props;
|
|
2833
|
+
const workflowsStore = useWorkflowsStore();
|
|
2834
|
+
const nodeTypesStore = useNodeTypesStore();
|
|
2835
|
+
const selectedRun = ref([]);
|
|
2836
|
+
const i18n = useI18n();
|
|
2837
|
+
function isTreeNodeSelected(node) {
|
|
2838
|
+
return selectedRun.value.some((run) => run.node === node.node && run.runIndex === node.runIndex);
|
|
2839
|
+
}
|
|
2840
|
+
function getReferencedData(taskData, withInput, withOutput) {
|
|
2841
|
+
if (!taskData) {
|
|
2842
|
+
return [];
|
|
2843
|
+
}
|
|
2844
|
+
const returnData = [];
|
|
2845
|
+
function addFunction(data, inOut) {
|
|
2846
|
+
if (!data) {
|
|
2847
|
+
return;
|
|
2848
|
+
}
|
|
2849
|
+
Object.keys(data).map((type) => {
|
|
2850
|
+
var _a;
|
|
2851
|
+
returnData.push({
|
|
2852
|
+
data: data[type][0],
|
|
2853
|
+
inOut,
|
|
2854
|
+
type,
|
|
2855
|
+
metadata: {
|
|
2856
|
+
executionTime: taskData.executionTime,
|
|
2857
|
+
startTime: taskData.startTime,
|
|
2858
|
+
subExecution: (_a = taskData.metadata) == null ? void 0 : _a.subExecution
|
|
2859
|
+
}
|
|
2860
|
+
});
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
if (withInput) {
|
|
2864
|
+
addFunction(taskData.inputOverride, "input");
|
|
2865
|
+
}
|
|
2866
|
+
{
|
|
2867
|
+
addFunction(taskData.data, "output");
|
|
2868
|
+
}
|
|
2869
|
+
return returnData;
|
|
2870
|
+
}
|
|
2871
|
+
function toggleTreeItem(node) {
|
|
2872
|
+
node.expanded = !node.expanded;
|
|
2873
|
+
}
|
|
2874
|
+
function onItemClick(data) {
|
|
2875
|
+
var _a, _b;
|
|
2876
|
+
const matchingRun = (_a = aiData.value) == null ? void 0 : _a.find(
|
|
2877
|
+
(run) => run.node === data.node && run.runIndex === data.runIndex
|
|
2878
|
+
);
|
|
2879
|
+
if (!matchingRun) {
|
|
2880
|
+
selectedRun.value = [];
|
|
2881
|
+
return;
|
|
2882
|
+
}
|
|
2883
|
+
const selectedNodeRun = (_b = workflowsStore.getWorkflowResultDataByNodeName(data.node)) == null ? void 0 : _b[data.runIndex];
|
|
2884
|
+
if (!selectedNodeRun) {
|
|
2885
|
+
return;
|
|
2886
|
+
}
|
|
2887
|
+
selectedRun.value = [
|
|
2888
|
+
{
|
|
2889
|
+
node: data.node,
|
|
2890
|
+
runIndex: data.runIndex,
|
|
2891
|
+
data: getReferencedData(selectedNodeRun, true)
|
|
2892
|
+
}
|
|
2893
|
+
];
|
|
2894
|
+
}
|
|
2895
|
+
function getNodeType(nodeName) {
|
|
2896
|
+
const node = workflowsStore.getNodeByName(nodeName);
|
|
2897
|
+
if (!node) {
|
|
2898
|
+
return null;
|
|
2899
|
+
}
|
|
2900
|
+
const nodeType = nodeTypesStore.getNodeType(node == null ? void 0 : node.type);
|
|
2901
|
+
return nodeType;
|
|
2902
|
+
}
|
|
2903
|
+
function selectFirst() {
|
|
2904
|
+
if (executionTree.value.length && executionTree.value[0].children.length) {
|
|
2905
|
+
onItemClick(executionTree.value[0].children[0]);
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
const createNode = (nodeName, currentDepth, r, children = []) => {
|
|
2909
|
+
var _a, _b;
|
|
2910
|
+
return {
|
|
2911
|
+
node: nodeName,
|
|
2912
|
+
id: nodeName,
|
|
2913
|
+
depth: currentDepth,
|
|
2914
|
+
startTime: ((_b = (_a = r == null ? void 0 : r.data) == null ? void 0 : _a.metadata) == null ? void 0 : _b.startTime) ?? 0,
|
|
2915
|
+
runIndex: (r == null ? void 0 : r.runIndex) ?? 0,
|
|
2916
|
+
children
|
|
2917
|
+
};
|
|
2918
|
+
};
|
|
2919
|
+
function getTreeNodeData(nodeName, currentDepth) {
|
|
2920
|
+
var _a;
|
|
2921
|
+
const connections = props.workflow.connectionsByDestinationNode[nodeName];
|
|
2922
|
+
const resultData = ((_a = aiData.value) == null ? void 0 : _a.filter((data) => data.node === nodeName)) ?? [];
|
|
2923
|
+
if (!connections) {
|
|
2924
|
+
return resultData.map((d) => createNode(nodeName, currentDepth, d));
|
|
2925
|
+
}
|
|
2926
|
+
const connectedSubNodes = props.workflow.getParentNodes(nodeName, "ALL_NON_MAIN", 1);
|
|
2927
|
+
const children = connectedSubNodes.filter((name) => {
|
|
2928
|
+
var _a2;
|
|
2929
|
+
return (_a2 = aiData.value) == null ? void 0 : _a2.find((data) => data.node === name);
|
|
2930
|
+
}).flatMap((name) => getTreeNodeData(name, currentDepth + 1));
|
|
2931
|
+
children.sort((a, b) => a.startTime - b.startTime);
|
|
2932
|
+
if (resultData.length) {
|
|
2933
|
+
return resultData.map((r) => createNode(nodeName, currentDepth, r, children));
|
|
2934
|
+
}
|
|
2935
|
+
return [createNode(nodeName, currentDepth, void 0, children)];
|
|
2936
|
+
}
|
|
2937
|
+
const aiData = computed(() => {
|
|
2938
|
+
var _a, _b;
|
|
2939
|
+
const result = [];
|
|
2940
|
+
const connectedSubNodes = props.workflow.getParentNodes(props.node.name, "ALL_NON_MAIN");
|
|
2941
|
+
const rootNodeResult = workflowsStore.getWorkflowResultDataByNodeName(props.node.name);
|
|
2942
|
+
const rootNodeStartTime = ((_a = rootNodeResult == null ? void 0 : rootNodeResult[props.runIndex ?? 0]) == null ? void 0 : _a.startTime) ?? 0;
|
|
2943
|
+
const rootNodeEndTime = rootNodeStartTime + (((_b = rootNodeResult == null ? void 0 : rootNodeResult[props.runIndex ?? 0]) == null ? void 0 : _b.executionTime) ?? 0);
|
|
2944
|
+
connectedSubNodes.forEach((nodeName) => {
|
|
2945
|
+
const nodeRunData = workflowsStore.getWorkflowResultDataByNodeName(nodeName) ?? [];
|
|
2946
|
+
nodeRunData.forEach((run, runIndex) => {
|
|
2947
|
+
const referenceData = {
|
|
2948
|
+
data: getReferencedData(run, false)[0],
|
|
2949
|
+
node: nodeName,
|
|
2950
|
+
runIndex
|
|
2951
|
+
};
|
|
2952
|
+
result.push(referenceData);
|
|
2953
|
+
});
|
|
2954
|
+
});
|
|
2955
|
+
result.sort((a, b) => {
|
|
2956
|
+
var _a2, _b2, _c, _d;
|
|
2957
|
+
const aTime = ((_b2 = (_a2 = a.data) == null ? void 0 : _a2.metadata) == null ? void 0 : _b2.startTime) ?? 0;
|
|
2958
|
+
const bTime = ((_d = (_c = b.data) == null ? void 0 : _c.metadata) == null ? void 0 : _d.startTime) ?? 0;
|
|
2959
|
+
return aTime - bTime;
|
|
2960
|
+
});
|
|
2961
|
+
const currentNodeResult = result.filter((r) => {
|
|
2962
|
+
var _a2, _b2;
|
|
2963
|
+
const startTime = ((_b2 = (_a2 = r.data) == null ? void 0 : _a2.metadata) == null ? void 0 : _b2.startTime) ?? 0;
|
|
2964
|
+
return startTime >= rootNodeStartTime && startTime < rootNodeEndTime;
|
|
2965
|
+
});
|
|
2966
|
+
return currentNodeResult;
|
|
2967
|
+
});
|
|
2968
|
+
const executionTree = computed(() => {
|
|
2969
|
+
const rootNode = props.node;
|
|
2970
|
+
const tree2 = getTreeNodeData(rootNode.name, 0);
|
|
2971
|
+
return tree2 || [];
|
|
2972
|
+
});
|
|
2973
|
+
watch(() => props.runIndex, selectFirst, { immediate: true });
|
|
2974
|
+
return (_ctx, _cache) => {
|
|
2975
|
+
const _component_font_awesome_icon = resolveComponent("font-awesome-icon");
|
|
2976
|
+
const _component_n8n_tooltip = resolveComponent("n8n-tooltip");
|
|
2977
|
+
const _component_n8n_text = resolveComponent("n8n-text");
|
|
2978
|
+
return openBlock(), createElementBlock("div", {
|
|
2979
|
+
class: normalizeClass(_ctx.$style.container)
|
|
2980
|
+
}, [
|
|
2981
|
+
aiData.value.length > 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2982
|
+
createBaseVNode("div", {
|
|
2983
|
+
class: normalizeClass({ [_ctx.$style.tree]: true, [_ctx.$style.slim]: _ctx.slim })
|
|
2984
|
+
}, [
|
|
2985
|
+
createVNode(unref(ElTree), {
|
|
2986
|
+
data: executionTree.value,
|
|
2987
|
+
props: { label: "node" },
|
|
2988
|
+
"default-expand-all": "",
|
|
2989
|
+
indent: 12,
|
|
2990
|
+
"expand-on-click-node": false,
|
|
2991
|
+
"data-test-id": "lm-chat-logs-tree",
|
|
2992
|
+
onNodeClick: onItemClick
|
|
2993
|
+
}, {
|
|
2994
|
+
default: withCtx(({ node, data }) => [
|
|
2995
|
+
createBaseVNode("div", {
|
|
2996
|
+
class: normalizeClass({
|
|
2997
|
+
[_ctx.$style.treeNode]: true,
|
|
2998
|
+
[_ctx.$style.isSelected]: isTreeNodeSelected(data)
|
|
2999
|
+
}),
|
|
3000
|
+
"data-tree-depth": data.depth,
|
|
3001
|
+
style: normalizeStyle({ "--item-depth": data.depth })
|
|
3002
|
+
}, [
|
|
3003
|
+
data.children.length ? (openBlock(), createElementBlock("button", {
|
|
3004
|
+
key: 0,
|
|
3005
|
+
class: normalizeClass(_ctx.$style.treeToggle),
|
|
3006
|
+
onClick: ($event) => toggleTreeItem(node)
|
|
3007
|
+
}, [
|
|
3008
|
+
createVNode(_component_font_awesome_icon, {
|
|
3009
|
+
icon: node.expanded ? "angle-down" : "angle-right"
|
|
3010
|
+
}, null, 8, ["icon"])
|
|
3011
|
+
], 10, _hoisted_2)) : createCommentVNode("", true),
|
|
3012
|
+
createVNode(_component_n8n_tooltip, {
|
|
3013
|
+
disabled: !_ctx.slim,
|
|
3014
|
+
placement: "right"
|
|
3015
|
+
}, {
|
|
3016
|
+
content: withCtx(() => [
|
|
3017
|
+
createTextVNode(toDisplayString(node.label), 1)
|
|
3018
|
+
]),
|
|
3019
|
+
default: withCtx(() => [
|
|
3020
|
+
createBaseVNode("span", {
|
|
3021
|
+
class: normalizeClass(_ctx.$style.leafLabel)
|
|
3022
|
+
}, [
|
|
3023
|
+
createVNode(_sfc_main$4, {
|
|
3024
|
+
"node-type": getNodeType(data.node),
|
|
3025
|
+
size: 17,
|
|
3026
|
+
class: normalizeClass(_ctx.$style.nodeIcon)
|
|
3027
|
+
}, null, 8, ["node-type", "class"]),
|
|
3028
|
+
!_ctx.slim ? (openBlock(), createElementBlock("span", {
|
|
3029
|
+
key: 0,
|
|
3030
|
+
textContent: toDisplayString(node.label)
|
|
3031
|
+
}, null, 8, _hoisted_3)) : createCommentVNode("", true)
|
|
3032
|
+
], 2)
|
|
3033
|
+
]),
|
|
3034
|
+
_: 2
|
|
3035
|
+
}, 1032, ["disabled"])
|
|
3036
|
+
], 14, _hoisted_1)
|
|
3037
|
+
]),
|
|
3038
|
+
_: 1
|
|
3039
|
+
}, 8, ["data"])
|
|
3040
|
+
], 2),
|
|
3041
|
+
createBaseVNode("div", {
|
|
3042
|
+
class: normalizeClass(_ctx.$style.runData)
|
|
3043
|
+
}, [
|
|
3044
|
+
selectedRun.value.length === 0 ? (openBlock(), createElementBlock("div", {
|
|
3045
|
+
key: 0,
|
|
3046
|
+
class: normalizeClass(_ctx.$style.empty)
|
|
3047
|
+
}, [
|
|
3048
|
+
createVNode(_component_n8n_text, { size: "large" }, {
|
|
3049
|
+
default: withCtx(() => [
|
|
3050
|
+
createTextVNode(toDisplayString(unref(i18n).baseText("ndv.output.ai.empty", {
|
|
3051
|
+
interpolate: {
|
|
3052
|
+
node: props.node.name
|
|
3053
|
+
}
|
|
3054
|
+
})), 1)
|
|
3055
|
+
]),
|
|
3056
|
+
_: 1
|
|
3057
|
+
})
|
|
3058
|
+
], 2)) : createCommentVNode("", true),
|
|
3059
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(selectedRun.value, (data, index) => {
|
|
3060
|
+
return openBlock(), createElementBlock("div", {
|
|
3061
|
+
key: `${data.node}__${data.runIndex}__index`,
|
|
3062
|
+
"data-test-id": "lm-chat-logs-entry"
|
|
3063
|
+
}, [
|
|
3064
|
+
createVNode(RunDataAiContent, {
|
|
3065
|
+
"input-data": data,
|
|
3066
|
+
"content-index": index
|
|
3067
|
+
}, null, 8, ["input-data", "content-index"])
|
|
3068
|
+
]);
|
|
3069
|
+
}), 128))
|
|
3070
|
+
], 2)
|
|
3071
|
+
], 64)) : (openBlock(), createElementBlock("div", {
|
|
3072
|
+
key: 1,
|
|
3073
|
+
class: normalizeClass(_ctx.$style.noData)
|
|
3074
|
+
}, toDisplayString(unref(i18n).baseText("ndv.output.ai.waiting")), 3))
|
|
3075
|
+
], 2);
|
|
3076
|
+
};
|
|
3077
|
+
}
|
|
3078
|
+
});
|
|
3079
|
+
const treeToggle = "_treeToggle_bn98i_1";
|
|
3080
|
+
const leafLabel = "_leafLabel_bn98i_9";
|
|
3081
|
+
const noData = "_noData_bn98i_15";
|
|
3082
|
+
const empty = "_empty_bn98i_23";
|
|
3083
|
+
const title = "_title_bn98i_27";
|
|
3084
|
+
const tree = "_tree_bn98i_1";
|
|
3085
|
+
const slim = "_slim_bn98i_39";
|
|
3086
|
+
const runData = "_runData_bn98i_43";
|
|
3087
|
+
const container = "_container_bn98i_49";
|
|
3088
|
+
const nodeIcon = "_nodeIcon_bn98i_76";
|
|
3089
|
+
const isSelected = "_isSelected_bn98i_82";
|
|
3090
|
+
const treeNode = "_treeNode_bn98i_86";
|
|
3091
|
+
const style0 = {
|
|
3092
|
+
treeToggle,
|
|
3093
|
+
leafLabel,
|
|
3094
|
+
noData,
|
|
3095
|
+
empty,
|
|
3096
|
+
title,
|
|
3097
|
+
tree,
|
|
3098
|
+
slim,
|
|
3099
|
+
runData,
|
|
3100
|
+
container,
|
|
3101
|
+
nodeIcon,
|
|
3102
|
+
isSelected,
|
|
3103
|
+
treeNode
|
|
3104
|
+
};
|
|
3105
|
+
const cssModules = {
|
|
3106
|
+
"$style": style0
|
|
3107
|
+
};
|
|
3108
|
+
const RunDataAi = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
|
|
3109
|
+
function useNodeType(options = {}) {
|
|
3110
|
+
const nodeTypesStore = useNodeTypesStore();
|
|
3111
|
+
const nodeType = computed(() => {
|
|
3112
|
+
if (options.nodeType) {
|
|
3113
|
+
return unref(options.nodeType);
|
|
3114
|
+
}
|
|
3115
|
+
const activeNode = unref(options.node);
|
|
3116
|
+
if (activeNode) {
|
|
3117
|
+
return nodeTypesStore.getNodeType(activeNode.type, activeNode.typeVersion);
|
|
3118
|
+
}
|
|
3119
|
+
return null;
|
|
3120
|
+
});
|
|
3121
|
+
const isSubNodeType$1 = computed(() => isSubNodeType(nodeType.value));
|
|
3122
|
+
const isMultipleOutputsNodeType = computed(() => {
|
|
3123
|
+
var _a;
|
|
3124
|
+
const outputs = (_a = nodeType.value) == null ? void 0 : _a.outputs;
|
|
3125
|
+
if (typeof outputs === "string") return false;
|
|
3126
|
+
return (outputs ?? []).length > 1;
|
|
3127
|
+
});
|
|
3128
|
+
return {
|
|
3129
|
+
nodeType,
|
|
3130
|
+
isSubNodeType: isSubNodeType$1,
|
|
3131
|
+
isMultipleOutputsNodeType
|
|
3132
|
+
};
|
|
3133
|
+
}
|
|
3134
|
+
function usePinnedData(node, options = {}) {
|
|
3135
|
+
const rootStore = useRootStore();
|
|
3136
|
+
const workflowsStore = useWorkflowsStore();
|
|
3137
|
+
const toast = useToast();
|
|
3138
|
+
const i18n = useI18n();
|
|
3139
|
+
const telemetry = useTelemetry();
|
|
3140
|
+
const externalHooks = useExternalHooks();
|
|
3141
|
+
const { getInputDataWithPinned } = useDataSchema();
|
|
3142
|
+
const { isSubNodeType: isSubNodeType2, isMultipleOutputsNodeType } = useNodeType({
|
|
3143
|
+
node
|
|
3144
|
+
});
|
|
3145
|
+
const data = computed(() => {
|
|
3146
|
+
const targetNode = unref(node);
|
|
3147
|
+
return targetNode ? workflowsStore.pinDataByNodeName(targetNode.name) : void 0;
|
|
3148
|
+
});
|
|
3149
|
+
const hasData = computed(() => {
|
|
3150
|
+
const targetNode = unref(node);
|
|
3151
|
+
return !!targetNode && typeof data.value !== "undefined";
|
|
3152
|
+
});
|
|
3153
|
+
const isValidNodeType = computed(() => {
|
|
3154
|
+
const targetNode = unref(node);
|
|
3155
|
+
return !!targetNode && !isSubNodeType2.value && !isMultipleOutputsNodeType.value && !PIN_DATA_NODE_TYPES_DENYLIST.includes(targetNode.type);
|
|
3156
|
+
});
|
|
3157
|
+
function canPinNode(checkDataEmpty = false, outputIndex) {
|
|
3158
|
+
const targetNode = unref(node);
|
|
3159
|
+
if (targetNode === null || PIN_DATA_NODE_TYPES_DENYLIST.includes(targetNode.type)) return false;
|
|
3160
|
+
const nodeType = useNodeTypesStore().getNodeType(targetNode.type, targetNode.typeVersion);
|
|
3161
|
+
const dataToPin = getInputDataWithPinned(targetNode);
|
|
3162
|
+
if (!nodeType || checkDataEmpty && dataToPin.length === 0) return false;
|
|
3163
|
+
const workflow = workflowsStore.getCurrentWorkflow();
|
|
3164
|
+
const outputs = getNodeOutputs(workflow, targetNode, nodeType).map(
|
|
3165
|
+
(output) => typeof output === "string" ? { type: output } : output
|
|
3166
|
+
);
|
|
3167
|
+
const mainOutputs = outputs.filter(
|
|
3168
|
+
(output) => output.type === NodeConnectionType.Main && output.category !== "error"
|
|
3169
|
+
);
|
|
3170
|
+
let indexAcceptable = true;
|
|
3171
|
+
if (outputIndex !== void 0) {
|
|
3172
|
+
const output = outputs[outputIndex];
|
|
3173
|
+
if (outputs[outputIndex] === void 0) return false;
|
|
3174
|
+
indexAcceptable = output.type === NodeConnectionType.Main && output.category !== "error";
|
|
3175
|
+
}
|
|
3176
|
+
return mainOutputs.length === 1 && indexAcceptable;
|
|
3177
|
+
}
|
|
3178
|
+
function isValidJSON(data2) {
|
|
3179
|
+
try {
|
|
3180
|
+
JSON.parse(data2);
|
|
3181
|
+
return true;
|
|
3182
|
+
} catch (error2) {
|
|
3183
|
+
const title2 = i18n.baseText("runData.editOutputInvalid");
|
|
3184
|
+
const toRemove = new RegExp(/JSON\.parse:|of the JSON data/, "g");
|
|
3185
|
+
const message = error2.message.replace(toRemove, "").trim();
|
|
3186
|
+
const positionMatchRegEx = /at position (\d+)/;
|
|
3187
|
+
const positionMatch = error2.message.match(positionMatchRegEx);
|
|
3188
|
+
error2.message = message.charAt(0).toUpperCase() + message.slice(1);
|
|
3189
|
+
error2.message = error2.message.replace(
|
|
3190
|
+
"Unexpected token ' in JSON",
|
|
3191
|
+
i18n.baseText("runData.editOutputInvalid.singleQuote")
|
|
3192
|
+
);
|
|
3193
|
+
if (positionMatch) {
|
|
3194
|
+
const position = parseInt(positionMatch[1], 10);
|
|
3195
|
+
const lineBreaksUpToPosition = (data2.slice(0, position).match(/\n/g) || []).length;
|
|
3196
|
+
error2.message = error2.message.replace(
|
|
3197
|
+
positionMatchRegEx,
|
|
3198
|
+
i18n.baseText("runData.editOutputInvalid.atPosition", {
|
|
3199
|
+
interpolate: {
|
|
3200
|
+
position: `${position}`
|
|
3201
|
+
}
|
|
3202
|
+
})
|
|
3203
|
+
);
|
|
3204
|
+
error2.message = `${i18n.baseText("runData.editOutputInvalid.onLine", {
|
|
3205
|
+
interpolate: {
|
|
3206
|
+
line: `${lineBreaksUpToPosition + 1}`
|
|
3207
|
+
}
|
|
3208
|
+
})} ${error2.message}`;
|
|
3209
|
+
}
|
|
3210
|
+
toast.showError(error2, title2);
|
|
3211
|
+
return false;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
function getMaxPinnedDataSize() {
|
|
3215
|
+
return window.maxPinnedDataSize ?? MAX_PINNED_DATA_SIZE;
|
|
3216
|
+
}
|
|
3217
|
+
function isValidSize(data2) {
|
|
3218
|
+
const targetNode = unref(node);
|
|
3219
|
+
if (!targetNode) {
|
|
3220
|
+
return false;
|
|
3221
|
+
}
|
|
3222
|
+
if (typeof data2 === "object") data2 = JSON.stringify(data2);
|
|
3223
|
+
const { pinData: currentPinData, ...workflow } = workflowsStore.getCurrentWorkflow();
|
|
3224
|
+
const workflowJson = jsonStringify(workflow, { replaceCircularRefs: true });
|
|
3225
|
+
const newPinData = { ...currentPinData, [targetNode.name]: data2 };
|
|
3226
|
+
const newPinDataSize = workflowsStore.getPinDataSize(newPinData);
|
|
3227
|
+
if (newPinDataSize > getMaxPinnedDataSize()) {
|
|
3228
|
+
toast.showError(
|
|
3229
|
+
new Error(
|
|
3230
|
+
i18n.baseText("ndv.pinData.error.tooLarge.description", {
|
|
3231
|
+
interpolate: {
|
|
3232
|
+
size: toMegaBytes(newPinDataSize),
|
|
3233
|
+
limit: toMegaBytes(getMaxPinnedDataSize())
|
|
3234
|
+
}
|
|
3235
|
+
})
|
|
3236
|
+
),
|
|
3237
|
+
i18n.baseText("ndv.pinData.error.tooLarge.title")
|
|
3238
|
+
);
|
|
3239
|
+
return false;
|
|
3240
|
+
}
|
|
3241
|
+
const workflowSize = stringSizeInBytes(workflowJson) + newPinDataSize;
|
|
3242
|
+
const limit = MAX_WORKFLOW_SIZE - MAX_EXPECTED_REQUEST_SIZE;
|
|
3243
|
+
if (workflowSize > limit) {
|
|
3244
|
+
toast.showError(
|
|
3245
|
+
new Error(
|
|
3246
|
+
i18n.baseText("ndv.pinData.error.tooLargeWorkflow.description", {
|
|
3247
|
+
interpolate: { size: toMegaBytes(workflowSize), limit: toMegaBytes(limit) }
|
|
3248
|
+
})
|
|
3249
|
+
),
|
|
3250
|
+
i18n.baseText("ndv.pinData.error.tooLargeWorkflow.title")
|
|
3251
|
+
);
|
|
3252
|
+
return false;
|
|
3253
|
+
}
|
|
3254
|
+
return true;
|
|
3255
|
+
}
|
|
3256
|
+
function onSetDataSuccess({ source: source2 }) {
|
|
3257
|
+
const targetNode = unref(node);
|
|
3258
|
+
const displayMode = unref(options.displayMode);
|
|
3259
|
+
const runIndex = unref(options.runIndex);
|
|
3260
|
+
const telemetryPayload = {
|
|
3261
|
+
pinning_source: source2,
|
|
3262
|
+
node_type: targetNode == null ? void 0 : targetNode.type,
|
|
3263
|
+
push_ref: rootStore.pushRef,
|
|
3264
|
+
data_size: stringSizeInBytes(data.value),
|
|
3265
|
+
view: displayMode,
|
|
3266
|
+
run_index: runIndex
|
|
3267
|
+
};
|
|
3268
|
+
void externalHooks.run("runData.onDataPinningSuccess", telemetryPayload);
|
|
3269
|
+
telemetry.track("Ndv data pinning success", telemetryPayload);
|
|
3270
|
+
}
|
|
3271
|
+
function onSetDataError({
|
|
3272
|
+
errorType,
|
|
3273
|
+
source: source2
|
|
3274
|
+
}) {
|
|
3275
|
+
const targetNode = unref(node);
|
|
3276
|
+
const displayMode = unref(options.displayMode);
|
|
3277
|
+
const runIndex = unref(options.runIndex);
|
|
3278
|
+
telemetry.track("Ndv data pinning failure", {
|
|
3279
|
+
pinning_source: source2,
|
|
3280
|
+
node_type: targetNode == null ? void 0 : targetNode.type,
|
|
3281
|
+
push_ref: rootStore.pushRef,
|
|
3282
|
+
data_size: stringSizeInBytes(data.value),
|
|
3283
|
+
view: displayMode,
|
|
3284
|
+
run_index: runIndex,
|
|
3285
|
+
error_type: errorType
|
|
3286
|
+
});
|
|
3287
|
+
}
|
|
3288
|
+
function setData(data2, source2) {
|
|
3289
|
+
const targetNode = unref(node);
|
|
3290
|
+
if (!targetNode) {
|
|
3291
|
+
return;
|
|
3292
|
+
}
|
|
3293
|
+
if (typeof data2 === "string") {
|
|
3294
|
+
if (!isValidJSON(data2)) {
|
|
3295
|
+
onSetDataError({ errorType: "invalid-json", source: source2 });
|
|
3296
|
+
throw new Error("Invalid JSON");
|
|
3297
|
+
}
|
|
3298
|
+
data2 = jsonParse(data2);
|
|
3299
|
+
}
|
|
3300
|
+
if (!isValidSize(data2)) {
|
|
3301
|
+
onSetDataError({ errorType: "data-too-large", source: source2 });
|
|
3302
|
+
throw new Error("Data too large");
|
|
3303
|
+
}
|
|
3304
|
+
workflowsStore.pinData({ node: targetNode, data: data2 });
|
|
3305
|
+
onSetDataSuccess({ source: source2 });
|
|
3306
|
+
}
|
|
3307
|
+
function onUnsetData({ source: source2 }) {
|
|
3308
|
+
const targetNode = unref(node);
|
|
3309
|
+
const runIndex = unref(options.runIndex);
|
|
3310
|
+
telemetry.track("User unpinned ndv data", {
|
|
3311
|
+
node_type: targetNode == null ? void 0 : targetNode.type,
|
|
3312
|
+
push_ref: rootStore.pushRef,
|
|
3313
|
+
run_index: runIndex,
|
|
3314
|
+
source: source2,
|
|
3315
|
+
data_size: stringSizeInBytes(data.value)
|
|
3316
|
+
});
|
|
3317
|
+
}
|
|
3318
|
+
function unsetData(source2) {
|
|
3319
|
+
const targetNode = unref(node);
|
|
3320
|
+
if (!targetNode) {
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
onUnsetData({ source: source2 });
|
|
3324
|
+
workflowsStore.unpinData({ node: targetNode });
|
|
3325
|
+
}
|
|
3326
|
+
return {
|
|
3327
|
+
data,
|
|
3328
|
+
hasData,
|
|
3329
|
+
isValidNodeType,
|
|
3330
|
+
canPinNode,
|
|
3331
|
+
setData,
|
|
3332
|
+
onSetDataSuccess,
|
|
3333
|
+
onSetDataError,
|
|
3334
|
+
unsetData,
|
|
3335
|
+
onUnsetData,
|
|
3336
|
+
isValidJSON,
|
|
3337
|
+
isValidSize
|
|
3338
|
+
};
|
|
3339
|
+
}
|
|
3340
|
+
function useRunWorkflow(useRunWorkflowOpts) {
|
|
3341
|
+
const nodeHelpers = useNodeHelpers();
|
|
3342
|
+
const workflowHelpers = useWorkflowHelpers({ router: useRunWorkflowOpts.router });
|
|
3343
|
+
const i18n = useI18n();
|
|
3344
|
+
const toast = useToast();
|
|
3345
|
+
const rootStore = useRootStore();
|
|
3346
|
+
const uiStore = useUIStore();
|
|
3347
|
+
const workflowsStore = useWorkflowsStore();
|
|
3348
|
+
const executionsStore = useExecutionsStore();
|
|
3349
|
+
async function runWorkflowApi(runData2) {
|
|
3350
|
+
if (!rootStore.pushConnectionActive) {
|
|
3351
|
+
throw new Error(i18n.baseText("workflowRun.noActiveConnectionToTheServer"));
|
|
3352
|
+
}
|
|
3353
|
+
workflowsStore.subWorkflowExecutionError = null;
|
|
3354
|
+
uiStore.addActiveAction("workflowRunning");
|
|
3355
|
+
let response;
|
|
3356
|
+
try {
|
|
3357
|
+
response = await workflowsStore.runWorkflow(runData2);
|
|
3358
|
+
} catch (error2) {
|
|
3359
|
+
uiStore.removeActiveAction("workflowRunning");
|
|
3360
|
+
throw error2;
|
|
3361
|
+
}
|
|
3362
|
+
if (response.executionId !== void 0) {
|
|
3363
|
+
workflowsStore.activeExecutionId = response.executionId;
|
|
3364
|
+
}
|
|
3365
|
+
if (response.waitingForWebhook === true && useWorkflowsStore().nodesIssuesExist) {
|
|
3366
|
+
uiStore.removeActiveAction("workflowRunning");
|
|
3367
|
+
throw new Error(i18n.baseText("workflowRun.showError.resolveOutstandingIssues"));
|
|
3368
|
+
}
|
|
3369
|
+
if (response.waitingForWebhook === true) {
|
|
3370
|
+
workflowsStore.executionWaitingForWebhook = true;
|
|
3371
|
+
}
|
|
3372
|
+
return response;
|
|
3373
|
+
}
|
|
3374
|
+
async function runWorkflow(options) {
|
|
3375
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3376
|
+
const workflow = workflowHelpers.getCurrentWorkflow();
|
|
3377
|
+
if (uiStore.isActionActive["workflowRunning"]) {
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
toast.clearAllStickyNotifications();
|
|
3381
|
+
try {
|
|
3382
|
+
let directParentNodes = [];
|
|
3383
|
+
if (options.destinationNode !== void 0) {
|
|
3384
|
+
directParentNodes = workflow.getParentNodes(
|
|
3385
|
+
options.destinationNode,
|
|
3386
|
+
NodeConnectionType.Main,
|
|
3387
|
+
-1
|
|
3388
|
+
);
|
|
3389
|
+
}
|
|
3390
|
+
const runData2 = workflowsStore.getWorkflowRunData;
|
|
3391
|
+
if (workflowsStore.isNewWorkflow) {
|
|
3392
|
+
await workflowHelpers.saveCurrentWorkflow();
|
|
3393
|
+
}
|
|
3394
|
+
const workflowData = await workflowHelpers.getWorkflowDataToSave();
|
|
3395
|
+
const consolidatedData = consolidateRunDataAndStartNodes(
|
|
3396
|
+
directParentNodes,
|
|
3397
|
+
runData2,
|
|
3398
|
+
workflowData.pinData,
|
|
3399
|
+
workflow
|
|
3400
|
+
);
|
|
3401
|
+
const { startNodeNames } = consolidatedData;
|
|
3402
|
+
const destinationNodeType = options.destinationNode ? (_a = workflowsStore.getNodeByName(options.destinationNode)) == null ? void 0 : _a.type : "";
|
|
3403
|
+
let { runData: newRunData } = consolidatedData;
|
|
3404
|
+
let executedNode;
|
|
3405
|
+
if (startNodeNames.length === 0 && "destinationNode" in options && options.destinationNode !== void 0) {
|
|
3406
|
+
executedNode = options.destinationNode;
|
|
3407
|
+
startNodeNames.push(options.destinationNode);
|
|
3408
|
+
} else if ("triggerNode" in options && "nodeData" in options) {
|
|
3409
|
+
startNodeNames.push(
|
|
3410
|
+
...workflow.getChildNodes(options.triggerNode, NodeConnectionType.Main, 1)
|
|
3411
|
+
);
|
|
3412
|
+
newRunData = {
|
|
3413
|
+
[options.triggerNode]: [options.nodeData]
|
|
3414
|
+
};
|
|
3415
|
+
executedNode = options.triggerNode;
|
|
3416
|
+
}
|
|
3417
|
+
if (options.destinationNode && (workflowsStore.checkIfNodeHasChatParent(options.destinationNode) || destinationNodeType === CHAT_TRIGGER_NODE_TYPE)) {
|
|
3418
|
+
const startNode = workflow.getStartNode(options.destinationNode);
|
|
3419
|
+
if (startNode && startNode.type === CHAT_TRIGGER_NODE_TYPE) {
|
|
3420
|
+
const chatHasInputData = ((_b = nodeHelpers.getNodeInputData(startNode, 0, 0, "input")) == null ? void 0 : _b.length) > 0;
|
|
3421
|
+
const chatHasPinData = !!((_c = workflowData.pinData) == null ? void 0 : _c[startNode.name]);
|
|
3422
|
+
if (!chatHasInputData && !chatHasPinData) {
|
|
3423
|
+
workflowsStore.setPanelOpen("chat", true);
|
|
3424
|
+
return;
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
const triggers = workflowData.nodes.filter(
|
|
3429
|
+
(node) => node.type.toLowerCase().includes("trigger") && !node.disabled
|
|
3430
|
+
);
|
|
3431
|
+
if (!options.destinationNode && options.source !== "RunData.ManualChatMessage" && workflowData.nodes.some((node) => node.type === CHAT_TRIGGER_NODE_TYPE)) {
|
|
3432
|
+
const otherTriggers = triggers.filter((node) => node.type !== CHAT_TRIGGER_NODE_TYPE);
|
|
3433
|
+
if (otherTriggers.length) {
|
|
3434
|
+
const chatTriggerNode = workflowData.nodes.find(
|
|
3435
|
+
(node) => node.type === CHAT_TRIGGER_NODE_TYPE
|
|
3436
|
+
);
|
|
3437
|
+
if (chatTriggerNode) {
|
|
3438
|
+
chatTriggerNode.disabled = true;
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
const startNodes = startNodeNames.map((name) => {
|
|
3443
|
+
let sourceData = get(runData2, [name, 0, "source", 0], null);
|
|
3444
|
+
if (sourceData === null) {
|
|
3445
|
+
const parentNodes = workflow.getParentNodes(name, NodeConnectionType.Main, 1);
|
|
3446
|
+
const executeData = workflowHelpers.executeData(
|
|
3447
|
+
parentNodes,
|
|
3448
|
+
name,
|
|
3449
|
+
NodeConnectionType.Main,
|
|
3450
|
+
0
|
|
3451
|
+
);
|
|
3452
|
+
sourceData = get(executeData, ["source", NodeConnectionType.Main, 0], null);
|
|
3453
|
+
}
|
|
3454
|
+
return {
|
|
3455
|
+
name,
|
|
3456
|
+
sourceData
|
|
3457
|
+
};
|
|
3458
|
+
});
|
|
3459
|
+
const singleWebhookTrigger = triggers.find(
|
|
3460
|
+
(node) => SINGLE_WEBHOOK_TRIGGERS.includes(node.type)
|
|
3461
|
+
);
|
|
3462
|
+
if (singleWebhookTrigger && workflowsStore.isWorkflowActive) {
|
|
3463
|
+
toast.showMessage({
|
|
3464
|
+
title: i18n.baseText("workflowRun.showError.deactivate"),
|
|
3465
|
+
message: i18n.baseText("workflowRun.showError.productionActive", {
|
|
3466
|
+
interpolate: { nodeName: singleWebhookTrigger.name }
|
|
3467
|
+
}),
|
|
3468
|
+
type: "error"
|
|
3469
|
+
});
|
|
3470
|
+
return void 0;
|
|
3471
|
+
}
|
|
3472
|
+
const partialExecutionVersion = useLocalStorage("PartialExecution.version", -1);
|
|
3473
|
+
const startRunData = {
|
|
3474
|
+
workflowData,
|
|
3475
|
+
// With the new partial execution version the backend decides what run
|
|
3476
|
+
// data to use and what to ignore.
|
|
3477
|
+
runData: partialExecutionVersion.value === 1 ? runData2 ?? void 0 : newRunData,
|
|
3478
|
+
startNodes
|
|
3479
|
+
};
|
|
3480
|
+
if ("destinationNode" in options) {
|
|
3481
|
+
startRunData.destinationNode = options.destinationNode;
|
|
3482
|
+
}
|
|
3483
|
+
const executionData = {
|
|
3484
|
+
id: "__IN_PROGRESS__",
|
|
3485
|
+
finished: false,
|
|
3486
|
+
mode: "manual",
|
|
3487
|
+
status: "running",
|
|
3488
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
3489
|
+
startedAt: /* @__PURE__ */ new Date(),
|
|
3490
|
+
stoppedAt: void 0,
|
|
3491
|
+
workflowId: workflow.id,
|
|
3492
|
+
executedNode,
|
|
3493
|
+
data: {
|
|
3494
|
+
resultData: {
|
|
3495
|
+
runData: newRunData ?? {},
|
|
3496
|
+
pinData: workflowData.pinData,
|
|
3497
|
+
workflowData
|
|
3498
|
+
}
|
|
3499
|
+
},
|
|
3500
|
+
workflowData: {
|
|
3501
|
+
id: workflowsStore.workflowId,
|
|
3502
|
+
name: workflowData.name,
|
|
3503
|
+
active: workflowData.active,
|
|
3504
|
+
createdAt: 0,
|
|
3505
|
+
updatedAt: 0,
|
|
3506
|
+
...workflowData
|
|
3507
|
+
}
|
|
3508
|
+
};
|
|
3509
|
+
workflowsStore.setWorkflowExecutionData(executionData);
|
|
3510
|
+
nodeHelpers.updateNodesExecutionIssues();
|
|
3511
|
+
workflowHelpers.setDocumentTitle(workflow.name, "EXECUTING");
|
|
3512
|
+
const runWorkflowApiResponse = await runWorkflowApi(startRunData);
|
|
3513
|
+
const pinData = workflowData.pinData ?? {};
|
|
3514
|
+
const getTestUrl = /* @__PURE__ */ (() => {
|
|
3515
|
+
return (node) => {
|
|
3516
|
+
var _a2;
|
|
3517
|
+
const path = node.parameters.path || ((_a2 = node.parameters.options) == null ? void 0 : _a2.path) || node.webhookId;
|
|
3518
|
+
return `${rootStore.formTestUrl}/${path}`;
|
|
3519
|
+
};
|
|
3520
|
+
})();
|
|
3521
|
+
try {
|
|
3522
|
+
displayForm({
|
|
3523
|
+
nodes: workflowData.nodes,
|
|
3524
|
+
runData: (_f = (_e = (_d = workflowsStore.getWorkflowExecution) == null ? void 0 : _d.data) == null ? void 0 : _e.resultData) == null ? void 0 : _f.runData,
|
|
3525
|
+
destinationNode: options.destinationNode,
|
|
3526
|
+
pinData,
|
|
3527
|
+
directParentNodes,
|
|
3528
|
+
source: options.source,
|
|
3529
|
+
getTestUrl
|
|
3530
|
+
});
|
|
3531
|
+
} catch (error2) {
|
|
3532
|
+
}
|
|
3533
|
+
await useExternalHooks().run("workflowRun.runWorkflow", {
|
|
3534
|
+
nodeName: options.destinationNode,
|
|
3535
|
+
source: options.source
|
|
3536
|
+
});
|
|
3537
|
+
return runWorkflowApiResponse;
|
|
3538
|
+
} catch (error2) {
|
|
3539
|
+
workflowHelpers.setDocumentTitle(workflow.name, "ERROR");
|
|
3540
|
+
toast.showError(error2, i18n.baseText("workflowRun.showError.title"));
|
|
3541
|
+
return void 0;
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
function consolidateRunDataAndStartNodes(directParentNodes, runData2, pinData, workflow) {
|
|
3545
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3546
|
+
const startNodeNames = /* @__PURE__ */ new Set();
|
|
3547
|
+
let newRunData;
|
|
3548
|
+
if (runData2 !== null && Object.keys(runData2).length !== 0) {
|
|
3549
|
+
newRunData = {};
|
|
3550
|
+
for (const directParentNode of directParentNodes) {
|
|
3551
|
+
const parentNodes = workflow.getParentNodes(directParentNode, NodeConnectionType.Main);
|
|
3552
|
+
if (workflow.nodes[directParentNode].disabled) continue;
|
|
3553
|
+
parentNodes.push(directParentNode);
|
|
3554
|
+
for (const parentNode of parentNodes) {
|
|
3555
|
+
if (!((_a = runData2[parentNode]) == null ? void 0 : _a.length) && !((_b = pinData == null ? void 0 : pinData[parentNode]) == null ? void 0 : _b.length) || ((_d = (_c = runData2[parentNode]) == null ? void 0 : _c[0]) == null ? void 0 : _d.error) !== void 0) {
|
|
3556
|
+
startNodeNames.add(parentNode);
|
|
3557
|
+
break;
|
|
3558
|
+
}
|
|
3559
|
+
if (runData2[parentNode] && !((_f = (_e = runData2[parentNode]) == null ? void 0 : _e[0]) == null ? void 0 : _f.error)) {
|
|
3560
|
+
newRunData[parentNode] = (_g = runData2[parentNode]) == null ? void 0 : _g.slice(0, 1);
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
if (isEmpty(newRunData)) {
|
|
3565
|
+
newRunData = void 0;
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
return { runData: newRunData, startNodeNames: [...startNodeNames] };
|
|
3569
|
+
}
|
|
3570
|
+
async function stopCurrentExecution() {
|
|
3571
|
+
const executionId = workflowsStore.activeExecutionId;
|
|
3572
|
+
if (executionId === null) {
|
|
3573
|
+
return;
|
|
3574
|
+
}
|
|
3575
|
+
try {
|
|
3576
|
+
await executionsStore.stopCurrentExecution(executionId);
|
|
3577
|
+
} catch (error2) {
|
|
3578
|
+
const execution = await workflowsStore.getExecution(executionId);
|
|
3579
|
+
if (execution === void 0) {
|
|
3580
|
+
toast.showMessage({
|
|
3581
|
+
title: i18n.baseText("nodeView.showMessage.stopExecutionCatch.unsaved.title"),
|
|
3582
|
+
message: i18n.baseText("nodeView.showMessage.stopExecutionCatch.unsaved.message"),
|
|
3583
|
+
type: "success"
|
|
3584
|
+
});
|
|
3585
|
+
} else if (execution == null ? void 0 : execution.finished) {
|
|
3586
|
+
const executedData = {
|
|
3587
|
+
data: execution.data,
|
|
3588
|
+
finished: execution.finished,
|
|
3589
|
+
mode: execution.mode,
|
|
3590
|
+
startedAt: execution.startedAt,
|
|
3591
|
+
stoppedAt: execution.stoppedAt
|
|
3592
|
+
};
|
|
3593
|
+
workflowsStore.setWorkflowExecutionData(executedData);
|
|
3594
|
+
toast.showMessage({
|
|
3595
|
+
title: i18n.baseText("nodeView.showMessage.stopExecutionCatch.title"),
|
|
3596
|
+
message: i18n.baseText("nodeView.showMessage.stopExecutionCatch.message"),
|
|
3597
|
+
type: "success"
|
|
3598
|
+
});
|
|
3599
|
+
} else {
|
|
3600
|
+
toast.showError(error2, i18n.baseText("nodeView.showError.stopExecution.title"));
|
|
3601
|
+
}
|
|
3602
|
+
} finally {
|
|
3603
|
+
workflowsStore.markExecutionAsStopped();
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
async function stopWaitingForWebhook() {
|
|
3607
|
+
try {
|
|
3608
|
+
await workflowsStore.removeTestWebhook(workflowsStore.workflowId);
|
|
3609
|
+
} catch (error2) {
|
|
3610
|
+
toast.showError(error2, i18n.baseText("nodeView.showError.stopWaitingForWebhook.title"));
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
return {
|
|
3615
|
+
consolidateRunDataAndStartNodes,
|
|
3616
|
+
runWorkflow,
|
|
3617
|
+
runWorkflowApi,
|
|
3618
|
+
stopCurrentExecution,
|
|
3619
|
+
stopWaitingForWebhook
|
|
3620
|
+
};
|
|
3621
|
+
}
|
|
3622
|
+
export {
|
|
3623
|
+
HighlightJS as H,
|
|
3624
|
+
RunDataAi as R,
|
|
3625
|
+
_sfc_main$3 as _,
|
|
3626
|
+
useRunWorkflow as a,
|
|
3627
|
+
useNodeType as b,
|
|
3628
|
+
capitalize as c,
|
|
3629
|
+
upperFirst as d,
|
|
3630
|
+
usePinnedData as u
|
|
3631
|
+
};
|