web-mojo 2.1.1106 → 2.1.1108
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/admin.cjs.js +1 -1
- package/dist/admin.es.js +12 -12
- package/dist/auth.cjs.js +1 -1
- package/dist/auth.es.js +1 -1
- package/dist/charts.cjs.js +1 -1
- package/dist/charts.es.js +4 -4
- package/dist/chunks/{ChatView-UCV0jQ1g.js → ChatView-BL4kPmQd.js} +2 -2
- package/dist/chunks/{ChatView-UCV0jQ1g.js.map → ChatView-BL4kPmQd.js.map} +1 -1
- package/dist/chunks/{ChatView-Bzh-NQL2.js → ChatView-CTe1wlQP.js} +7 -7
- package/dist/chunks/{ChatView-Bzh-NQL2.js.map → ChatView-CTe1wlQP.js.map} +1 -1
- package/dist/chunks/{Collection-B64LJ92k.js → Collection-Ds4EOzap.js} +2 -2
- package/dist/chunks/{Collection-B64LJ92k.js.map → Collection-Ds4EOzap.js.map} +1 -1
- package/dist/chunks/{Collection-DpdzB_n7.js → Collection-bgdNt0wV.js} +2 -2
- package/dist/chunks/{Collection-DpdzB_n7.js.map → Collection-bgdNt0wV.js.map} +1 -1
- package/dist/chunks/{ContextMenu-DWau8gXS.js → ContextMenu-DwvxeWLt.js} +2 -2
- package/dist/chunks/{ContextMenu-DWau8gXS.js.map → ContextMenu-DwvxeWLt.js.map} +1 -1
- package/dist/chunks/{ContextMenu-CLRRrCUp.js → ContextMenu-KHTc-Ubo.js} +3 -3
- package/dist/chunks/{ContextMenu-CLRRrCUp.js.map → ContextMenu-KHTc-Ubo.js.map} +1 -1
- package/dist/chunks/{DataView-DESqBxT-.js → DataView-DAGqpR7b.js} +2 -2
- package/dist/chunks/{DataView-DESqBxT-.js.map → DataView-DAGqpR7b.js.map} +1 -1
- package/dist/chunks/{DataView-QXyfcg2M.js → DataView-DbexZltc.js} +2 -2
- package/dist/chunks/{DataView-QXyfcg2M.js.map → DataView-DbexZltc.js.map} +1 -1
- package/dist/chunks/{Dialog-Cn2eJvUP.js → Dialog-CXOsYNLf.js} +5 -5
- package/dist/chunks/{Dialog-Cn2eJvUP.js.map → Dialog-CXOsYNLf.js.map} +1 -1
- package/dist/chunks/{Dialog-bCQhKfum.js → Dialog-DE-21f_8.js} +2 -2
- package/dist/chunks/{Dialog-bCQhKfum.js.map → Dialog-DE-21f_8.js.map} +1 -1
- package/dist/chunks/{FormView-oUu9Kaw9.js → FormView-DbPZwhZ6.js} +54 -5
- package/dist/chunks/FormView-DbPZwhZ6.js.map +1 -0
- package/dist/chunks/{FormView-BSWvqTCy.js → FormView-Dya3nBrn.js} +3 -3
- package/dist/chunks/FormView-Dya3nBrn.js.map +1 -0
- package/dist/chunks/{ListView-BpGEatee.js → ListView-BQgv3OvQ.js} +2 -2
- package/dist/chunks/{ListView-BpGEatee.js.map → ListView-BQgv3OvQ.js.map} +1 -1
- package/dist/chunks/{ListView-B2gyVSMW.js → ListView-DFP4ie99.js} +3 -3
- package/dist/chunks/{ListView-B2gyVSMW.js.map → ListView-DFP4ie99.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-BgrlHdCZ.js → MetricsMiniChartWidget-DOcsPk5u.js} +2 -2
- package/dist/chunks/{MetricsMiniChartWidget-BgrlHdCZ.js.map → MetricsMiniChartWidget-DOcsPk5u.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-BaN18P32.js → MetricsMiniChartWidget-Dan8l57G.js} +4 -4
- package/dist/chunks/{MetricsMiniChartWidget-BaN18P32.js.map → MetricsMiniChartWidget-Dan8l57G.js.map} +1 -1
- package/dist/chunks/{PDFViewer-C1EDn3ZS.js → PDFViewer-B1g6Q6ae.js} +3 -3
- package/dist/chunks/{PDFViewer-C1EDn3ZS.js.map → PDFViewer-B1g6Q6ae.js.map} +1 -1
- package/dist/chunks/{PDFViewer-oSjl3wqi.js → PDFViewer-DDb7xLGo.js} +2 -2
- package/dist/chunks/{PDFViewer-oSjl3wqi.js.map → PDFViewer-DDb7xLGo.js.map} +1 -1
- package/dist/chunks/Rest-BIyXKaFn.js +2 -0
- package/dist/chunks/Rest-BIyXKaFn.js.map +1 -0
- package/dist/chunks/{Rest-DpbPbmra.js → Rest-C3KvOEeY.js} +597 -598
- package/dist/chunks/Rest-C3KvOEeY.js.map +1 -0
- package/dist/chunks/{TokenManager-D06vfK4l.js → TokenManager-B0Z_dd7k.js} +2 -2
- package/dist/chunks/{TokenManager-D06vfK4l.js.map → TokenManager-B0Z_dd7k.js.map} +1 -1
- package/dist/chunks/{TokenManager-B4Bsjnlr.js → TokenManager-DUmZuAKG.js} +5 -5
- package/dist/chunks/{TokenManager-B4Bsjnlr.js.map → TokenManager-DUmZuAKG.js.map} +1 -1
- package/dist/chunks/{WebSocketClient-DghNkEyO.js → WebSocketClient-CGQLSIgP.js} +2 -2
- package/dist/chunks/{WebSocketClient-DghNkEyO.js.map → WebSocketClient-CGQLSIgP.js.map} +1 -1
- package/dist/chunks/{WebSocketClient-E08hfP5f.js → WebSocketClient-sEN2DmCF.js} +2 -2
- package/dist/chunks/{WebSocketClient-E08hfP5f.js.map → WebSocketClient-sEN2DmCF.js.map} +1 -1
- package/dist/chunks/{version-CEIJQUnP.js → version-CrckCqr_.js} +4 -4
- package/dist/chunks/{version-CEIJQUnP.js.map → version-CrckCqr_.js.map} +1 -1
- package/dist/chunks/{version-DdJLBH34.js → version-DIk6UpNb.js} +2 -2
- package/dist/chunks/{version-DdJLBH34.js.map → version-DIk6UpNb.js.map} +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +6 -6
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +15 -15
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.es.js +5 -5
- package/dist/map.cjs.js +1 -1
- package/dist/map.es.js +2 -2
- package/dist/timeline.cjs.js +1 -1
- package/dist/timeline.es.js +4 -4
- package/package.json +1 -1
- package/dist/chunks/FormView-BSWvqTCy.js.map +0 -1
- package/dist/chunks/FormView-oUu9Kaw9.js.map +0 -1
- package/dist/chunks/Rest-BpDyhFfG.js +0 -2
- package/dist/chunks/Rest-BpDyhFfG.js.map +0 -1
- package/dist/chunks/Rest-DpbPbmra.js.map +0 -1
|
@@ -1,460 +1,3 @@
|
|
|
1
|
-
const objectToString = Object.prototype.toString;
|
|
2
|
-
const isArray = Array.isArray || function(obj) {
|
|
3
|
-
return objectToString.call(obj) === "[object Array]";
|
|
4
|
-
};
|
|
5
|
-
const isFunction = function(obj) {
|
|
6
|
-
return typeof obj === "function";
|
|
7
|
-
};
|
|
8
|
-
const isObject = function(obj) {
|
|
9
|
-
return obj != null && typeof obj === "object";
|
|
10
|
-
};
|
|
11
|
-
const escapeHtml = function(string) {
|
|
12
|
-
const entityMap = {
|
|
13
|
-
"&": "&",
|
|
14
|
-
"<": "<",
|
|
15
|
-
">": ">",
|
|
16
|
-
'"': """,
|
|
17
|
-
"'": "'",
|
|
18
|
-
"/": "/",
|
|
19
|
-
"`": "`",
|
|
20
|
-
"=": "="
|
|
21
|
-
};
|
|
22
|
-
return String(string).replace(/[&<>"'`=\/]/g, function(s) {
|
|
23
|
-
return entityMap[s];
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
class Scanner {
|
|
27
|
-
constructor(string) {
|
|
28
|
-
this.string = string;
|
|
29
|
-
this.tail = string;
|
|
30
|
-
this.pos = 0;
|
|
31
|
-
}
|
|
32
|
-
eos() {
|
|
33
|
-
return this.tail === "";
|
|
34
|
-
}
|
|
35
|
-
scan(re) {
|
|
36
|
-
const match = this.tail.match(re);
|
|
37
|
-
if (!match || match.index !== 0) {
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
const string = match[0];
|
|
41
|
-
this.tail = this.tail.substring(string.length);
|
|
42
|
-
this.pos += string.length;
|
|
43
|
-
return string;
|
|
44
|
-
}
|
|
45
|
-
scanUntil(re) {
|
|
46
|
-
const index = this.tail.search(re);
|
|
47
|
-
let match;
|
|
48
|
-
switch (index) {
|
|
49
|
-
case -1:
|
|
50
|
-
match = this.tail;
|
|
51
|
-
this.tail = "";
|
|
52
|
-
break;
|
|
53
|
-
case 0:
|
|
54
|
-
match = "";
|
|
55
|
-
break;
|
|
56
|
-
default:
|
|
57
|
-
match = this.tail.substring(0, index);
|
|
58
|
-
this.tail = this.tail.substring(index);
|
|
59
|
-
}
|
|
60
|
-
this.pos += match.length;
|
|
61
|
-
return match;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
class Context {
|
|
65
|
-
constructor(view, parentContext) {
|
|
66
|
-
this.view = view;
|
|
67
|
-
this.cache = { ".": this.view };
|
|
68
|
-
this.parent = parentContext;
|
|
69
|
-
if (!this.view?._cacheId) {
|
|
70
|
-
if (this.view && typeof this.view === "object") {
|
|
71
|
-
this.view._cacheId = Math.random().toString(36).substring(2);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
push(view) {
|
|
76
|
-
return new Context(view, this);
|
|
77
|
-
}
|
|
78
|
-
lookup(name) {
|
|
79
|
-
if (this.renderCache && this.view?._cacheId) {
|
|
80
|
-
const cacheKey = `${this.view._cacheId}:${name}`;
|
|
81
|
-
if (this.renderCache.has(cacheKey)) {
|
|
82
|
-
return this.renderCache.get(cacheKey);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (name === ".") {
|
|
86
|
-
return this.view;
|
|
87
|
-
}
|
|
88
|
-
if (name && name.startsWith(".")) {
|
|
89
|
-
let actualName = name.substring(1);
|
|
90
|
-
let shouldIterate = false;
|
|
91
|
-
if (actualName.endsWith("|iter")) {
|
|
92
|
-
actualName = actualName.substring(0, actualName.length - 5);
|
|
93
|
-
shouldIterate = true;
|
|
94
|
-
}
|
|
95
|
-
if (this.view && typeof this.view === "object") {
|
|
96
|
-
let value2;
|
|
97
|
-
if (typeof this.view.getContextValue === "function") {
|
|
98
|
-
try {
|
|
99
|
-
value2 = this.view.getContextValue(actualName);
|
|
100
|
-
if (value2 !== void 0) {
|
|
101
|
-
if (isFunction(value2)) {
|
|
102
|
-
value2 = value2.call(this.view);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
} catch (e) {
|
|
106
|
-
value2 = void 0;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (value2 === void 0 && actualName in this.view) {
|
|
110
|
-
value2 = this.view[actualName];
|
|
111
|
-
if (isFunction(value2)) {
|
|
112
|
-
value2 = value2.call(this.view);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (isArray(value2)) {
|
|
116
|
-
if (shouldIterate) {
|
|
117
|
-
return value2;
|
|
118
|
-
} else {
|
|
119
|
-
return value2.length > 0;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (isObject(value2)) {
|
|
123
|
-
if (shouldIterate) {
|
|
124
|
-
return Object.entries(value2).map(([key, val]) => ({
|
|
125
|
-
key,
|
|
126
|
-
value: val
|
|
127
|
-
}));
|
|
128
|
-
} else {
|
|
129
|
-
return Object.keys(value2).length > 0;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return value2;
|
|
133
|
-
}
|
|
134
|
-
return void 0;
|
|
135
|
-
}
|
|
136
|
-
const cache = this.cache;
|
|
137
|
-
let value;
|
|
138
|
-
if (cache.hasOwnProperty(name)) {
|
|
139
|
-
value = cache[name];
|
|
140
|
-
} else {
|
|
141
|
-
let context = this;
|
|
142
|
-
let intermediateValue;
|
|
143
|
-
let names;
|
|
144
|
-
let index;
|
|
145
|
-
let lookupHit = false;
|
|
146
|
-
while (context) {
|
|
147
|
-
if (context.view && typeof context.view.getContextValue === "function") {
|
|
148
|
-
try {
|
|
149
|
-
intermediateValue = context.view.getContextValue(name);
|
|
150
|
-
if (intermediateValue !== void 0) {
|
|
151
|
-
lookupHit = true;
|
|
152
|
-
}
|
|
153
|
-
} catch (e) {
|
|
154
|
-
lookupHit = false;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (!lookupHit) {
|
|
158
|
-
if (name.indexOf(".") > 0) {
|
|
159
|
-
intermediateValue = context.view;
|
|
160
|
-
names = name.split(".");
|
|
161
|
-
index = 0;
|
|
162
|
-
while (intermediateValue != null && index < names.length) {
|
|
163
|
-
if (intermediateValue && typeof intermediateValue.getContextValue === "function" && index < names.length) {
|
|
164
|
-
try {
|
|
165
|
-
const remainingPath = names.slice(index).join(".");
|
|
166
|
-
intermediateValue = intermediateValue.getContextValue(remainingPath);
|
|
167
|
-
index = names.length;
|
|
168
|
-
if (intermediateValue !== void 0) {
|
|
169
|
-
lookupHit = true;
|
|
170
|
-
}
|
|
171
|
-
} catch (e) {
|
|
172
|
-
if (index === names.length - 1) {
|
|
173
|
-
lookupHit = hasProperty(intermediateValue, names[index]) || primitiveHasOwnProperty(intermediateValue, names[index]);
|
|
174
|
-
}
|
|
175
|
-
intermediateValue = intermediateValue[names[index++]];
|
|
176
|
-
}
|
|
177
|
-
} else {
|
|
178
|
-
if (index === names.length - 1) {
|
|
179
|
-
lookupHit = hasProperty(intermediateValue, names[index]) || primitiveHasOwnProperty(intermediateValue, names[index]);
|
|
180
|
-
}
|
|
181
|
-
intermediateValue = intermediateValue[names[index++]];
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
intermediateValue = context.view[name];
|
|
186
|
-
lookupHit = hasProperty(context.view, name);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (lookupHit) {
|
|
190
|
-
value = intermediateValue;
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
context = context.parent;
|
|
194
|
-
}
|
|
195
|
-
cache[name] = value;
|
|
196
|
-
}
|
|
197
|
-
if (isFunction(value)) value = value.call(this.view);
|
|
198
|
-
if (this.renderCache && this.view?._cacheId) {
|
|
199
|
-
const cacheKey = `${this.view._cacheId}:${name}`;
|
|
200
|
-
this.renderCache.set(cacheKey, value);
|
|
201
|
-
}
|
|
202
|
-
return value;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function hasProperty(obj, propName) {
|
|
206
|
-
return obj != null && typeof obj === "object" && propName in obj;
|
|
207
|
-
}
|
|
208
|
-
function primitiveHasOwnProperty(primitive, propName) {
|
|
209
|
-
return primitive != null && typeof primitive !== "object" && primitive.hasOwnProperty && primitive.hasOwnProperty(propName);
|
|
210
|
-
}
|
|
211
|
-
class Writer {
|
|
212
|
-
constructor() {
|
|
213
|
-
this.templateCache = /* @__PURE__ */ new Map();
|
|
214
|
-
}
|
|
215
|
-
clearCache() {
|
|
216
|
-
this.templateCache.clear();
|
|
217
|
-
}
|
|
218
|
-
parse(template, tags) {
|
|
219
|
-
tags = tags || ["{{", "}}"];
|
|
220
|
-
const cacheKey = template + ":" + tags.join(":");
|
|
221
|
-
let tokens = this.templateCache.get(cacheKey);
|
|
222
|
-
if (tokens == null) {
|
|
223
|
-
tokens = this.parseTemplate(template, tags);
|
|
224
|
-
this.templateCache.set(cacheKey, tokens);
|
|
225
|
-
}
|
|
226
|
-
return tokens;
|
|
227
|
-
}
|
|
228
|
-
parseTemplate(template, tags) {
|
|
229
|
-
if (!template) return [];
|
|
230
|
-
const openingTag = tags[0];
|
|
231
|
-
const closingTag = tags[1];
|
|
232
|
-
const scanner = new Scanner(template);
|
|
233
|
-
const tokens = [];
|
|
234
|
-
let start, type, value, chr, token;
|
|
235
|
-
const openingTagRe = new RegExp(escapeRegExp(openingTag) + "\\s*");
|
|
236
|
-
const closingTagRe = new RegExp("\\s*" + escapeRegExp(closingTag));
|
|
237
|
-
const closingCurlyRe = new RegExp("\\s*" + escapeRegExp("}" + closingTag));
|
|
238
|
-
while (!scanner.eos()) {
|
|
239
|
-
start = scanner.pos;
|
|
240
|
-
value = scanner.scanUntil(openingTagRe);
|
|
241
|
-
if (value) {
|
|
242
|
-
for (let i = 0; i < value.length; ++i) {
|
|
243
|
-
chr = value.charAt(i);
|
|
244
|
-
if (chr === "\n") {
|
|
245
|
-
tokens.push(["text", chr]);
|
|
246
|
-
} else {
|
|
247
|
-
tokens.push(["text", chr]);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
if (!scanner.scan(openingTagRe)) break;
|
|
252
|
-
type = scanner.scan(/[#^\/>{&=!]/);
|
|
253
|
-
if (!type) type = "name";
|
|
254
|
-
scanner.scan(/\s*/);
|
|
255
|
-
if (type === "=") {
|
|
256
|
-
value = scanner.scanUntil(/\s*=/);
|
|
257
|
-
scanner.scan(/\s*=/);
|
|
258
|
-
scanner.scanUntil(closingTagRe);
|
|
259
|
-
} else if (type === "{") {
|
|
260
|
-
value = scanner.scanUntil(closingCurlyRe);
|
|
261
|
-
scanner.scan(closingCurlyRe);
|
|
262
|
-
type = "&";
|
|
263
|
-
} else {
|
|
264
|
-
value = scanner.scanUntil(closingTagRe);
|
|
265
|
-
}
|
|
266
|
-
scanner.scan(closingTagRe);
|
|
267
|
-
if (type === "#" || type === "^") {
|
|
268
|
-
token = [type, value, start, scanner.pos];
|
|
269
|
-
tokens.push(token);
|
|
270
|
-
} else if (type === "/") {
|
|
271
|
-
let openSection;
|
|
272
|
-
for (let i = tokens.length - 1; i >= 0; --i) {
|
|
273
|
-
if (tokens[i][0] === "#" || tokens[i][0] === "^") {
|
|
274
|
-
if (tokens[i][1] === value) {
|
|
275
|
-
openSection = tokens[i];
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if (openSection) {
|
|
281
|
-
if (openSection.length === 4) {
|
|
282
|
-
openSection.push(scanner.pos);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
tokens.push([type, value, start, scanner.pos]);
|
|
286
|
-
} else {
|
|
287
|
-
tokens.push([type, value, start, scanner.pos]);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return this.nestSections(this.squashTokens(tokens));
|
|
291
|
-
}
|
|
292
|
-
squashTokens(tokens) {
|
|
293
|
-
const squashedTokens = [];
|
|
294
|
-
let token, lastToken;
|
|
295
|
-
for (let i = 0; i < tokens.length; ++i) {
|
|
296
|
-
token = tokens[i];
|
|
297
|
-
if (token) {
|
|
298
|
-
if (token[0] === "text" && lastToken && lastToken[0] === "text") {
|
|
299
|
-
lastToken[1] += token[1];
|
|
300
|
-
lastToken[3] = token[3];
|
|
301
|
-
} else {
|
|
302
|
-
squashedTokens.push(token);
|
|
303
|
-
lastToken = token;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return squashedTokens;
|
|
308
|
-
}
|
|
309
|
-
nestSections(tokens) {
|
|
310
|
-
const nestedTokens = [];
|
|
311
|
-
let collector = nestedTokens;
|
|
312
|
-
const sections = [];
|
|
313
|
-
for (let i = 0; i < tokens.length; ++i) {
|
|
314
|
-
const token = tokens[i];
|
|
315
|
-
switch (token[0]) {
|
|
316
|
-
case "#":
|
|
317
|
-
case "^":
|
|
318
|
-
const sectionToken = [
|
|
319
|
-
token[0],
|
|
320
|
-
// type ('#' or '^')
|
|
321
|
-
token[1],
|
|
322
|
-
// section name
|
|
323
|
-
token[2],
|
|
324
|
-
// start position
|
|
325
|
-
token[3],
|
|
326
|
-
// end position after opening tag
|
|
327
|
-
[],
|
|
328
|
-
// children array
|
|
329
|
-
token[4] || null
|
|
330
|
-
// closing position (if set during parsing)
|
|
331
|
-
];
|
|
332
|
-
collector.push(sectionToken);
|
|
333
|
-
sections.push(sectionToken);
|
|
334
|
-
collector = sectionToken[4];
|
|
335
|
-
break;
|
|
336
|
-
case "/":
|
|
337
|
-
const section = sections.pop();
|
|
338
|
-
if (section) {
|
|
339
|
-
section[5] = token[2];
|
|
340
|
-
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
|
|
341
|
-
}
|
|
342
|
-
break;
|
|
343
|
-
default:
|
|
344
|
-
collector.push(token);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return nestedTokens;
|
|
348
|
-
}
|
|
349
|
-
render(template, view, partials, config) {
|
|
350
|
-
const tags = this.getConfigTags(config) || ["{{", "}}"];
|
|
351
|
-
const tokens = this.parse(template, tags);
|
|
352
|
-
const renderCache = /* @__PURE__ */ new Map();
|
|
353
|
-
return this.renderTokens(tokens, new Context(view), partials, template, config, renderCache);
|
|
354
|
-
}
|
|
355
|
-
renderTokens(tokens, context, partials, originalTemplate, config, renderCache) {
|
|
356
|
-
if (renderCache && !context.renderCache) {
|
|
357
|
-
context.renderCache = renderCache;
|
|
358
|
-
}
|
|
359
|
-
let buffer = "";
|
|
360
|
-
for (let i = 0; i < tokens.length; ++i) {
|
|
361
|
-
const token = tokens[i];
|
|
362
|
-
let value;
|
|
363
|
-
switch (token[0]) {
|
|
364
|
-
case "#":
|
|
365
|
-
value = context.lookup(token[1]);
|
|
366
|
-
if (!value) continue;
|
|
367
|
-
const childTokens = token[4];
|
|
368
|
-
if (!childTokens || !isArray(childTokens)) {
|
|
369
|
-
console.warn(`MUSTACHE WARNING - Section ${token[1]} has no child tokens:`, token);
|
|
370
|
-
continue;
|
|
371
|
-
}
|
|
372
|
-
if (isArray(value)) {
|
|
373
|
-
for (let j = 0; j < value.length; ++j) {
|
|
374
|
-
const itemContext = context.push(value[j]);
|
|
375
|
-
if (context.renderCache) {
|
|
376
|
-
itemContext.renderCache = context.renderCache;
|
|
377
|
-
}
|
|
378
|
-
const itemResult = this.renderTokens(childTokens, itemContext, partials, originalTemplate, config, renderCache);
|
|
379
|
-
buffer += itemResult;
|
|
380
|
-
}
|
|
381
|
-
} else if (typeof value === "object" || typeof value === "string" || typeof value === "number") {
|
|
382
|
-
const pushedContext = context.push(value);
|
|
383
|
-
if (context.renderCache) {
|
|
384
|
-
pushedContext.renderCache = context.renderCache;
|
|
385
|
-
}
|
|
386
|
-
buffer += this.renderTokens(childTokens, pushedContext, partials, originalTemplate, config, renderCache);
|
|
387
|
-
} else if (isFunction(value)) {
|
|
388
|
-
const text = originalTemplate == null ? null : originalTemplate.slice(token[3], token[5]);
|
|
389
|
-
value = value.call(context.view, text, (template) => this.render(template, context.view, partials, config));
|
|
390
|
-
if (value != null) buffer += value;
|
|
391
|
-
} else if (value) {
|
|
392
|
-
buffer += this.renderTokens(childTokens, context, partials, originalTemplate, config, renderCache);
|
|
393
|
-
}
|
|
394
|
-
break;
|
|
395
|
-
case "^":
|
|
396
|
-
value = context.lookup(token[1]);
|
|
397
|
-
if (!value || isArray(value) && value.length === 0) {
|
|
398
|
-
const childTokens2 = token[4];
|
|
399
|
-
if (childTokens2 && isArray(childTokens2)) {
|
|
400
|
-
buffer += this.renderTokens(childTokens2, context, partials, originalTemplate, config, renderCache);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
break;
|
|
404
|
-
case ">":
|
|
405
|
-
if (!partials) continue;
|
|
406
|
-
value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
|
407
|
-
if (value != null) {
|
|
408
|
-
buffer += this.render(value, context.view, partials, config);
|
|
409
|
-
}
|
|
410
|
-
break;
|
|
411
|
-
case "&":
|
|
412
|
-
value = context.lookup(token[1]);
|
|
413
|
-
if (value != null) buffer += value;
|
|
414
|
-
break;
|
|
415
|
-
case "name":
|
|
416
|
-
value = context.lookup(token[1]);
|
|
417
|
-
if (value != null) buffer += escapeHtml(value);
|
|
418
|
-
break;
|
|
419
|
-
case "text":
|
|
420
|
-
buffer += token[1];
|
|
421
|
-
break;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
return buffer;
|
|
425
|
-
}
|
|
426
|
-
getConfigTags(config) {
|
|
427
|
-
if (isObject(config) && isArray(config.tags)) {
|
|
428
|
-
return config.tags;
|
|
429
|
-
}
|
|
430
|
-
return null;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
function escapeRegExp(string) {
|
|
434
|
-
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
435
|
-
}
|
|
436
|
-
const defaultWriter = new Writer();
|
|
437
|
-
const Mustache = {
|
|
438
|
-
name: "MOJO Mustache",
|
|
439
|
-
version: "1.0.0",
|
|
440
|
-
tags: ["{{", "}}"],
|
|
441
|
-
Scanner,
|
|
442
|
-
Context,
|
|
443
|
-
Writer,
|
|
444
|
-
escape: escapeHtml,
|
|
445
|
-
clearCache() {
|
|
446
|
-
return defaultWriter.clearCache();
|
|
447
|
-
},
|
|
448
|
-
parse(template, tags) {
|
|
449
|
-
return defaultWriter.parse(template, tags);
|
|
450
|
-
},
|
|
451
|
-
render(template, view, partials, config) {
|
|
452
|
-
if (typeof template !== "string") {
|
|
453
|
-
throw new TypeError('Invalid template! Template should be a "string"');
|
|
454
|
-
}
|
|
455
|
-
return defaultWriter.render(template, view, partials, config);
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
1
|
const GENERIC_AVATAR_SVG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2NlZDRkYSI+PHBhdGggZD0iTTEyIDEyYzIuMjEgMCA0LTEuNzkgNC00cy0xLjc5LTQtNC00LTQgMS43OS00IDQgMS43OSA0IDQgNHptMCAyYy0yLjY3IDAtOCAxLjM0LTggNHYyaDE2di0yYzAtMi42Ni01LjMzLTQtOC00eiIvPjwvc3ZnPg==";
|
|
459
2
|
class DataFormatter {
|
|
460
3
|
constructor() {
|
|
@@ -2253,173 +1796,629 @@ class MOJOUtils {
|
|
|
2253
1796
|
numbers = numbers.replace(/[01]/g, "");
|
|
2254
1797
|
specialChars = specialChars.replace(/[|]/g, "");
|
|
2255
1798
|
}
|
|
2256
|
-
let charPool = "";
|
|
2257
|
-
const requiredChars = [];
|
|
2258
|
-
if (config.customChars) {
|
|
2259
|
-
charPool = config.customChars;
|
|
2260
|
-
} else {
|
|
2261
|
-
if (config.includeLowercase) {
|
|
2262
|
-
charPool += lowercase;
|
|
2263
|
-
requiredChars.push(lowercase[Math.floor(Math.random() * lowercase.length)]);
|
|
1799
|
+
let charPool = "";
|
|
1800
|
+
const requiredChars = [];
|
|
1801
|
+
if (config.customChars) {
|
|
1802
|
+
charPool = config.customChars;
|
|
1803
|
+
} else {
|
|
1804
|
+
if (config.includeLowercase) {
|
|
1805
|
+
charPool += lowercase;
|
|
1806
|
+
requiredChars.push(lowercase[Math.floor(Math.random() * lowercase.length)]);
|
|
1807
|
+
}
|
|
1808
|
+
if (config.includeUppercase) {
|
|
1809
|
+
charPool += uppercase;
|
|
1810
|
+
requiredChars.push(uppercase[Math.floor(Math.random() * uppercase.length)]);
|
|
1811
|
+
}
|
|
1812
|
+
if (config.includeNumbers) {
|
|
1813
|
+
charPool += numbers;
|
|
1814
|
+
requiredChars.push(numbers[Math.floor(Math.random() * numbers.length)]);
|
|
1815
|
+
}
|
|
1816
|
+
if (config.includeSpecialChars) {
|
|
1817
|
+
charPool += specialChars;
|
|
1818
|
+
requiredChars.push(specialChars[Math.floor(Math.random() * specialChars.length)]);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
if (!charPool) {
|
|
1822
|
+
throw new Error("No character types selected for password generation");
|
|
1823
|
+
}
|
|
1824
|
+
let password = "";
|
|
1825
|
+
for (const char of requiredChars) {
|
|
1826
|
+
password += char;
|
|
1827
|
+
}
|
|
1828
|
+
for (let i = password.length; i < config.length; i++) {
|
|
1829
|
+
password += charPool[Math.floor(Math.random() * charPool.length)];
|
|
1830
|
+
}
|
|
1831
|
+
return password.split("").sort(() => Math.random() - 0.5).join("");
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Parse query string into object
|
|
1835
|
+
* @param {string} queryString - Query string to parse
|
|
1836
|
+
* @returns {object} Parsed query parameters
|
|
1837
|
+
*/
|
|
1838
|
+
static parseQueryString(queryString) {
|
|
1839
|
+
const params = {};
|
|
1840
|
+
const searchParams = new URLSearchParams(queryString);
|
|
1841
|
+
for (const [key, value] of searchParams.entries()) {
|
|
1842
|
+
params[key] = value;
|
|
1843
|
+
}
|
|
1844
|
+
return params;
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Convert object to query string
|
|
1848
|
+
* @param {object} params - Parameters object
|
|
1849
|
+
* @returns {string} Query string
|
|
1850
|
+
*/
|
|
1851
|
+
static toQueryString(params) {
|
|
1852
|
+
return new URLSearchParams(params).toString();
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Wrap data objects to provide get() method support
|
|
1856
|
+
* This ensures pipe formatting works in all contexts
|
|
1857
|
+
* @param {*} data - Data to wrap
|
|
1858
|
+
* @param {object} rootContext - Optional root context for nested access
|
|
1859
|
+
* @returns {*} Wrapped data if object/array, otherwise original
|
|
1860
|
+
*/
|
|
1861
|
+
static wrapData(data, rootContext = null, depth = 3) {
|
|
1862
|
+
if (!data || typeof data !== "object") {
|
|
1863
|
+
return data;
|
|
1864
|
+
}
|
|
1865
|
+
if (data instanceof Date || data instanceof RegExp || data instanceof Error) {
|
|
1866
|
+
return data;
|
|
1867
|
+
}
|
|
1868
|
+
if (depth <= 0) {
|
|
1869
|
+
return data;
|
|
1870
|
+
}
|
|
1871
|
+
if (typeof data.getContextValue === "function") {
|
|
1872
|
+
return data;
|
|
1873
|
+
}
|
|
1874
|
+
if (Array.isArray(data)) {
|
|
1875
|
+
return data.map((item) => {
|
|
1876
|
+
if (item && typeof item === "object" && !item.getContextValue) {
|
|
1877
|
+
return new DataWrapper(item, rootContext);
|
|
1878
|
+
}
|
|
1879
|
+
return item;
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
return new DataWrapper(data, rootContext);
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
class DataWrapper {
|
|
1886
|
+
constructor(data, rootContext = null) {
|
|
1887
|
+
Object.defineProperty(this, "_data", {
|
|
1888
|
+
value: data,
|
|
1889
|
+
writable: false,
|
|
1890
|
+
enumerable: false,
|
|
1891
|
+
configurable: false
|
|
1892
|
+
});
|
|
1893
|
+
Object.defineProperty(this, "_rootContext", {
|
|
1894
|
+
value: rootContext,
|
|
1895
|
+
writable: false,
|
|
1896
|
+
enumerable: false,
|
|
1897
|
+
configurable: false
|
|
1898
|
+
});
|
|
1899
|
+
if (data && typeof data === "object") {
|
|
1900
|
+
for (const key in data) {
|
|
1901
|
+
if (data.hasOwnProperty(key)) {
|
|
1902
|
+
const value = data[key];
|
|
1903
|
+
this[key] = MOJOUtils.wrapData(value, rootContext);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Get value with pipe support
|
|
1910
|
+
* @param {string} key - Key with optional pipes
|
|
1911
|
+
* @returns {*} Value, possibly formatted
|
|
1912
|
+
*/
|
|
1913
|
+
getContextValue(key) {
|
|
1914
|
+
let field = key;
|
|
1915
|
+
let pipes = "";
|
|
1916
|
+
let parenDepth = 0;
|
|
1917
|
+
let pipeIndex = -1;
|
|
1918
|
+
for (let i = 0; i < key.length; i++) {
|
|
1919
|
+
const char = key[i];
|
|
1920
|
+
if (char === "(") parenDepth++;
|
|
1921
|
+
else if (char === ")") parenDepth--;
|
|
1922
|
+
else if (char === "|" && parenDepth === 0) {
|
|
1923
|
+
pipeIndex = i;
|
|
1924
|
+
break;
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
if (pipeIndex > -1) {
|
|
1928
|
+
field = key.substring(0, pipeIndex).trim();
|
|
1929
|
+
pipes = key.substring(pipeIndex + 1).trim();
|
|
1930
|
+
}
|
|
1931
|
+
let value;
|
|
1932
|
+
if (field in this && field !== "_data" && field !== "_rootContext") {
|
|
1933
|
+
value = this[field];
|
|
1934
|
+
} else {
|
|
1935
|
+
value = MOJOUtils.getNestedValue(this._data, field);
|
|
1936
|
+
}
|
|
1937
|
+
if (pipes && value !== void 0) {
|
|
1938
|
+
return dataFormatter.pipe(value, pipes, this._rootContext || this._data);
|
|
1939
|
+
}
|
|
1940
|
+
return value;
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Check if wrapper has a property
|
|
1944
|
+
* @param {string} key - Property key
|
|
1945
|
+
* @returns {boolean} True if property exists
|
|
1946
|
+
*/
|
|
1947
|
+
has(key) {
|
|
1948
|
+
return this._data && this._data.hasOwnProperty(key);
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Get the raw wrapped data
|
|
1952
|
+
* @returns {object} The original data object
|
|
1953
|
+
*/
|
|
1954
|
+
toJSON() {
|
|
1955
|
+
return this._data;
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
MOJOUtils.DataWrapper = DataWrapper;
|
|
1959
|
+
if (typeof window !== "undefined") {
|
|
1960
|
+
window.utils = MOJOUtils;
|
|
1961
|
+
}
|
|
1962
|
+
const objectToString = Object.prototype.toString;
|
|
1963
|
+
const isArray = Array.isArray || function(obj) {
|
|
1964
|
+
return objectToString.call(obj) === "[object Array]";
|
|
1965
|
+
};
|
|
1966
|
+
const isFunction = function(obj) {
|
|
1967
|
+
return typeof obj === "function";
|
|
1968
|
+
};
|
|
1969
|
+
const isObject = function(obj) {
|
|
1970
|
+
return obj != null && typeof obj === "object";
|
|
1971
|
+
};
|
|
1972
|
+
const escapeHtml = function(string) {
|
|
1973
|
+
const entityMap = {
|
|
1974
|
+
"&": "&",
|
|
1975
|
+
"<": "<",
|
|
1976
|
+
">": ">",
|
|
1977
|
+
'"': """,
|
|
1978
|
+
"'": "'",
|
|
1979
|
+
"/": "/",
|
|
1980
|
+
"`": "`",
|
|
1981
|
+
"=": "="
|
|
1982
|
+
};
|
|
1983
|
+
return String(string).replace(/[&<>"'`=\/]/g, function(s) {
|
|
1984
|
+
return entityMap[s];
|
|
1985
|
+
});
|
|
1986
|
+
};
|
|
1987
|
+
class Scanner {
|
|
1988
|
+
constructor(string) {
|
|
1989
|
+
this.string = string;
|
|
1990
|
+
this.tail = string;
|
|
1991
|
+
this.pos = 0;
|
|
1992
|
+
}
|
|
1993
|
+
eos() {
|
|
1994
|
+
return this.tail === "";
|
|
1995
|
+
}
|
|
1996
|
+
scan(re) {
|
|
1997
|
+
const match = this.tail.match(re);
|
|
1998
|
+
if (!match || match.index !== 0) {
|
|
1999
|
+
return "";
|
|
2000
|
+
}
|
|
2001
|
+
const string = match[0];
|
|
2002
|
+
this.tail = this.tail.substring(string.length);
|
|
2003
|
+
this.pos += string.length;
|
|
2004
|
+
return string;
|
|
2005
|
+
}
|
|
2006
|
+
scanUntil(re) {
|
|
2007
|
+
const index = this.tail.search(re);
|
|
2008
|
+
let match;
|
|
2009
|
+
switch (index) {
|
|
2010
|
+
case -1:
|
|
2011
|
+
match = this.tail;
|
|
2012
|
+
this.tail = "";
|
|
2013
|
+
break;
|
|
2014
|
+
case 0:
|
|
2015
|
+
match = "";
|
|
2016
|
+
break;
|
|
2017
|
+
default:
|
|
2018
|
+
match = this.tail.substring(0, index);
|
|
2019
|
+
this.tail = this.tail.substring(index);
|
|
2020
|
+
}
|
|
2021
|
+
this.pos += match.length;
|
|
2022
|
+
return match;
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
class Context {
|
|
2026
|
+
constructor(view, parentContext) {
|
|
2027
|
+
this.view = view;
|
|
2028
|
+
this.cache = { ".": this.view };
|
|
2029
|
+
this.parent = parentContext;
|
|
2030
|
+
if (!this.view?._cacheId) {
|
|
2031
|
+
if (this.view && typeof this.view === "object") {
|
|
2032
|
+
this.view._cacheId = Math.random().toString(36).substring(2);
|
|
2264
2033
|
}
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
push(view) {
|
|
2037
|
+
return new Context(view, this);
|
|
2038
|
+
}
|
|
2039
|
+
lookup(name) {
|
|
2040
|
+
if (this.renderCache && this.view?._cacheId) {
|
|
2041
|
+
const cacheKey = `${this.view._cacheId}:${name}`;
|
|
2042
|
+
if (this.renderCache.has(cacheKey)) {
|
|
2043
|
+
return this.renderCache.get(cacheKey);
|
|
2268
2044
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2045
|
+
}
|
|
2046
|
+
if (name === ".") {
|
|
2047
|
+
return this.view;
|
|
2048
|
+
}
|
|
2049
|
+
if (name && name.startsWith(".")) {
|
|
2050
|
+
let actualName = name.substring(1);
|
|
2051
|
+
let shouldIterate = false;
|
|
2052
|
+
if (actualName.endsWith("|iter")) {
|
|
2053
|
+
actualName = actualName.substring(0, actualName.length - 5);
|
|
2054
|
+
shouldIterate = true;
|
|
2272
2055
|
}
|
|
2273
|
-
if (
|
|
2274
|
-
|
|
2275
|
-
|
|
2056
|
+
if (this.view && typeof this.view === "object") {
|
|
2057
|
+
let value2;
|
|
2058
|
+
if (typeof this.view.getContextValue === "function") {
|
|
2059
|
+
try {
|
|
2060
|
+
value2 = this.view.getContextValue(actualName);
|
|
2061
|
+
if (value2 !== void 0) {
|
|
2062
|
+
if (isFunction(value2)) {
|
|
2063
|
+
value2 = value2.call(this.view);
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
} catch (e) {
|
|
2067
|
+
value2 = void 0;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
if (value2 === void 0 && actualName in this.view) {
|
|
2071
|
+
value2 = this.view[actualName];
|
|
2072
|
+
if (isFunction(value2)) {
|
|
2073
|
+
value2 = value2.call(this.view);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
if (isArray(value2)) {
|
|
2077
|
+
if (shouldIterate) {
|
|
2078
|
+
return value2;
|
|
2079
|
+
} else {
|
|
2080
|
+
return value2.length > 0;
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
if (isObject(value2)) {
|
|
2084
|
+
if (shouldIterate) {
|
|
2085
|
+
return Object.entries(value2).map(([key, val]) => ({
|
|
2086
|
+
key,
|
|
2087
|
+
value: val
|
|
2088
|
+
}));
|
|
2089
|
+
} else {
|
|
2090
|
+
return Object.keys(value2).length > 0;
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
return value2;
|
|
2276
2094
|
}
|
|
2095
|
+
return void 0;
|
|
2277
2096
|
}
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2097
|
+
const cache = this.cache;
|
|
2098
|
+
let value;
|
|
2099
|
+
if (cache.hasOwnProperty(name)) {
|
|
2100
|
+
value = cache[name];
|
|
2101
|
+
} else {
|
|
2102
|
+
let context = this;
|
|
2103
|
+
let intermediateValue;
|
|
2104
|
+
let names;
|
|
2105
|
+
let index;
|
|
2106
|
+
let lookupHit = false;
|
|
2107
|
+
while (context) {
|
|
2108
|
+
if (context.view && typeof context.view.getContextValue === "function") {
|
|
2109
|
+
try {
|
|
2110
|
+
intermediateValue = context.view.getContextValue(name);
|
|
2111
|
+
if (intermediateValue !== void 0) {
|
|
2112
|
+
lookupHit = true;
|
|
2113
|
+
}
|
|
2114
|
+
} catch (e) {
|
|
2115
|
+
lookupHit = false;
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
if (!lookupHit) {
|
|
2119
|
+
if (name.indexOf(".") > 0) {
|
|
2120
|
+
intermediateValue = context.view;
|
|
2121
|
+
names = name.split(".");
|
|
2122
|
+
index = 0;
|
|
2123
|
+
while (intermediateValue != null && index < names.length) {
|
|
2124
|
+
if (intermediateValue && typeof intermediateValue.getContextValue === "function" && index < names.length) {
|
|
2125
|
+
try {
|
|
2126
|
+
const remainingPath = names.slice(index).join(".");
|
|
2127
|
+
intermediateValue = intermediateValue.getContextValue(remainingPath);
|
|
2128
|
+
index = names.length;
|
|
2129
|
+
if (intermediateValue !== void 0) {
|
|
2130
|
+
lookupHit = true;
|
|
2131
|
+
}
|
|
2132
|
+
} catch (e) {
|
|
2133
|
+
if (index === names.length - 1) {
|
|
2134
|
+
lookupHit = hasProperty(intermediateValue, names[index]) || primitiveHasOwnProperty(intermediateValue, names[index]);
|
|
2135
|
+
}
|
|
2136
|
+
intermediateValue = intermediateValue[names[index++]];
|
|
2137
|
+
}
|
|
2138
|
+
} else {
|
|
2139
|
+
if (index === names.length - 1) {
|
|
2140
|
+
lookupHit = hasProperty(intermediateValue, names[index]) || primitiveHasOwnProperty(intermediateValue, names[index]);
|
|
2141
|
+
}
|
|
2142
|
+
intermediateValue = intermediateValue[names[index++]];
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
} else {
|
|
2146
|
+
intermediateValue = context.view[name];
|
|
2147
|
+
lookupHit = hasProperty(context.view, name);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
if (lookupHit) {
|
|
2151
|
+
value = intermediateValue;
|
|
2152
|
+
break;
|
|
2153
|
+
}
|
|
2154
|
+
context = context.parent;
|
|
2155
|
+
}
|
|
2156
|
+
cache[name] = value;
|
|
2284
2157
|
}
|
|
2285
|
-
|
|
2286
|
-
|
|
2158
|
+
if (isFunction(value)) value = value.call(this.view);
|
|
2159
|
+
if (this.renderCache && this.view?._cacheId) {
|
|
2160
|
+
const cacheKey = `${this.view._cacheId}:${name}`;
|
|
2161
|
+
this.renderCache.set(cacheKey, value);
|
|
2287
2162
|
}
|
|
2288
|
-
return
|
|
2163
|
+
return value;
|
|
2289
2164
|
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
}
|
|
2301
|
-
return params;
|
|
2165
|
+
}
|
|
2166
|
+
function hasProperty(obj, propName) {
|
|
2167
|
+
return obj != null && typeof obj === "object" && propName in obj;
|
|
2168
|
+
}
|
|
2169
|
+
function primitiveHasOwnProperty(primitive, propName) {
|
|
2170
|
+
return primitive != null && typeof primitive !== "object" && primitive.hasOwnProperty && primitive.hasOwnProperty(propName);
|
|
2171
|
+
}
|
|
2172
|
+
class Writer {
|
|
2173
|
+
constructor() {
|
|
2174
|
+
this.templateCache = /* @__PURE__ */ new Map();
|
|
2302
2175
|
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
* @param {object} params - Parameters object
|
|
2306
|
-
* @returns {string} Query string
|
|
2307
|
-
*/
|
|
2308
|
-
static toQueryString(params) {
|
|
2309
|
-
return new URLSearchParams(params).toString();
|
|
2176
|
+
clearCache() {
|
|
2177
|
+
this.templateCache.clear();
|
|
2310
2178
|
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
static wrapData(data, rootContext = null, depth = 3) {
|
|
2319
|
-
if (!data || typeof data !== "object") {
|
|
2320
|
-
return data;
|
|
2321
|
-
}
|
|
2322
|
-
if (data instanceof Date || data instanceof RegExp || data instanceof Error) {
|
|
2323
|
-
return data;
|
|
2324
|
-
}
|
|
2325
|
-
if (depth <= 0) {
|
|
2326
|
-
return data;
|
|
2327
|
-
}
|
|
2328
|
-
if (typeof data.getContextValue === "function") {
|
|
2329
|
-
return data;
|
|
2179
|
+
parse(template, tags) {
|
|
2180
|
+
tags = tags || ["{{", "}}"];
|
|
2181
|
+
const cacheKey = template + ":" + tags.join(":");
|
|
2182
|
+
let tokens = this.templateCache.get(cacheKey);
|
|
2183
|
+
if (tokens == null) {
|
|
2184
|
+
tokens = this.parseTemplate(template, tags);
|
|
2185
|
+
this.templateCache.set(cacheKey, tokens);
|
|
2330
2186
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2187
|
+
return tokens;
|
|
2188
|
+
}
|
|
2189
|
+
parseTemplate(template, tags) {
|
|
2190
|
+
if (!template) return [];
|
|
2191
|
+
const openingTag = tags[0];
|
|
2192
|
+
const closingTag = tags[1];
|
|
2193
|
+
const scanner = new Scanner(template);
|
|
2194
|
+
const tokens = [];
|
|
2195
|
+
let start, type, value, chr, token;
|
|
2196
|
+
const openingTagRe = new RegExp(escapeRegExp(openingTag) + "\\s*");
|
|
2197
|
+
const closingTagRe = new RegExp("\\s*" + escapeRegExp(closingTag));
|
|
2198
|
+
const closingCurlyRe = new RegExp("\\s*" + escapeRegExp("}" + closingTag));
|
|
2199
|
+
while (!scanner.eos()) {
|
|
2200
|
+
start = scanner.pos;
|
|
2201
|
+
value = scanner.scanUntil(openingTagRe);
|
|
2202
|
+
if (value) {
|
|
2203
|
+
for (let i = 0; i < value.length; ++i) {
|
|
2204
|
+
chr = value.charAt(i);
|
|
2205
|
+
if (chr === "\n") {
|
|
2206
|
+
tokens.push(["text", chr]);
|
|
2207
|
+
} else {
|
|
2208
|
+
tokens.push(["text", chr]);
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
if (!scanner.scan(openingTagRe)) break;
|
|
2213
|
+
type = scanner.scan(/[#^\/>{&=!]/);
|
|
2214
|
+
if (!type) type = "name";
|
|
2215
|
+
scanner.scan(/\s*/);
|
|
2216
|
+
if (type === "=") {
|
|
2217
|
+
value = scanner.scanUntil(/\s*=/);
|
|
2218
|
+
scanner.scan(/\s*=/);
|
|
2219
|
+
scanner.scanUntil(closingTagRe);
|
|
2220
|
+
} else if (type === "{") {
|
|
2221
|
+
value = scanner.scanUntil(closingCurlyRe);
|
|
2222
|
+
scanner.scan(closingCurlyRe);
|
|
2223
|
+
type = "&";
|
|
2224
|
+
} else {
|
|
2225
|
+
value = scanner.scanUntil(closingTagRe);
|
|
2226
|
+
}
|
|
2227
|
+
scanner.scan(closingTagRe);
|
|
2228
|
+
if (type === "#" || type === "^") {
|
|
2229
|
+
token = [type, value, start, scanner.pos];
|
|
2230
|
+
tokens.push(token);
|
|
2231
|
+
} else if (type === "/") {
|
|
2232
|
+
let openSection;
|
|
2233
|
+
for (let i = tokens.length - 1; i >= 0; --i) {
|
|
2234
|
+
if (tokens[i][0] === "#" || tokens[i][0] === "^") {
|
|
2235
|
+
if (tokens[i][1] === value) {
|
|
2236
|
+
openSection = tokens[i];
|
|
2237
|
+
break;
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2335
2240
|
}
|
|
2336
|
-
|
|
2337
|
-
|
|
2241
|
+
if (openSection) {
|
|
2242
|
+
if (openSection.length === 4) {
|
|
2243
|
+
openSection.push(scanner.pos);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
tokens.push([type, value, start, scanner.pos]);
|
|
2247
|
+
} else {
|
|
2248
|
+
tokens.push([type, value, start, scanner.pos]);
|
|
2249
|
+
}
|
|
2338
2250
|
}
|
|
2339
|
-
return
|
|
2251
|
+
return this.nestSections(this.squashTokens(tokens));
|
|
2340
2252
|
}
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
enumerable: false,
|
|
2354
|
-
configurable: false
|
|
2355
|
-
});
|
|
2356
|
-
if (data && typeof data === "object") {
|
|
2357
|
-
for (const key in data) {
|
|
2358
|
-
if (data.hasOwnProperty(key)) {
|
|
2359
|
-
const value = data[key];
|
|
2360
|
-
this[key] = MOJOUtils.wrapData(value, rootContext);
|
|
2253
|
+
squashTokens(tokens) {
|
|
2254
|
+
const squashedTokens = [];
|
|
2255
|
+
let token, lastToken;
|
|
2256
|
+
for (let i = 0; i < tokens.length; ++i) {
|
|
2257
|
+
token = tokens[i];
|
|
2258
|
+
if (token) {
|
|
2259
|
+
if (token[0] === "text" && lastToken && lastToken[0] === "text") {
|
|
2260
|
+
lastToken[1] += token[1];
|
|
2261
|
+
lastToken[3] = token[3];
|
|
2262
|
+
} else {
|
|
2263
|
+
squashedTokens.push(token);
|
|
2264
|
+
lastToken = token;
|
|
2361
2265
|
}
|
|
2362
2266
|
}
|
|
2363
2267
|
}
|
|
2268
|
+
return squashedTokens;
|
|
2364
2269
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2270
|
+
nestSections(tokens) {
|
|
2271
|
+
const nestedTokens = [];
|
|
2272
|
+
let collector = nestedTokens;
|
|
2273
|
+
const sections = [];
|
|
2274
|
+
for (let i = 0; i < tokens.length; ++i) {
|
|
2275
|
+
const token = tokens[i];
|
|
2276
|
+
switch (token[0]) {
|
|
2277
|
+
case "#":
|
|
2278
|
+
case "^":
|
|
2279
|
+
const sectionToken = [
|
|
2280
|
+
token[0],
|
|
2281
|
+
// type ('#' or '^')
|
|
2282
|
+
token[1],
|
|
2283
|
+
// section name
|
|
2284
|
+
token[2],
|
|
2285
|
+
// start position
|
|
2286
|
+
token[3],
|
|
2287
|
+
// end position after opening tag
|
|
2288
|
+
[],
|
|
2289
|
+
// children array
|
|
2290
|
+
token[4] || null
|
|
2291
|
+
// closing position (if set during parsing)
|
|
2292
|
+
];
|
|
2293
|
+
collector.push(sectionToken);
|
|
2294
|
+
sections.push(sectionToken);
|
|
2295
|
+
collector = sectionToken[4];
|
|
2296
|
+
break;
|
|
2297
|
+
case "/":
|
|
2298
|
+
const section = sections.pop();
|
|
2299
|
+
if (section) {
|
|
2300
|
+
section[5] = token[2];
|
|
2301
|
+
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
|
|
2302
|
+
}
|
|
2303
|
+
break;
|
|
2304
|
+
default:
|
|
2305
|
+
collector.push(token);
|
|
2382
2306
|
}
|
|
2383
2307
|
}
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2308
|
+
return nestedTokens;
|
|
2309
|
+
}
|
|
2310
|
+
render(template, view, partials, config) {
|
|
2311
|
+
const tags = this.getConfigTags(config) || ["{{", "}}"];
|
|
2312
|
+
const tokens = this.parse(template, tags);
|
|
2313
|
+
const renderCache = /* @__PURE__ */ new Map();
|
|
2314
|
+
return this.renderTokens(tokens, new Context(view), partials, template, config, renderCache);
|
|
2315
|
+
}
|
|
2316
|
+
renderTokens(tokens, context, partials, originalTemplate, config, renderCache) {
|
|
2317
|
+
if (renderCache && !context.renderCache) {
|
|
2318
|
+
context.renderCache = renderCache;
|
|
2387
2319
|
}
|
|
2388
|
-
let
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2320
|
+
let buffer = "";
|
|
2321
|
+
for (let i = 0; i < tokens.length; ++i) {
|
|
2322
|
+
const token = tokens[i];
|
|
2323
|
+
let value;
|
|
2324
|
+
switch (token[0]) {
|
|
2325
|
+
case "#":
|
|
2326
|
+
value = context.lookup(token[1]);
|
|
2327
|
+
if (!value) continue;
|
|
2328
|
+
const childTokens = token[4];
|
|
2329
|
+
if (!childTokens || !isArray(childTokens)) {
|
|
2330
|
+
console.warn(`MUSTACHE WARNING - Section ${token[1]} has no child tokens:`, token);
|
|
2331
|
+
continue;
|
|
2332
|
+
}
|
|
2333
|
+
if (isArray(value)) {
|
|
2334
|
+
for (let j = 0; j < value.length; ++j) {
|
|
2335
|
+
const itemContext = context.push(value[j]);
|
|
2336
|
+
if (context.renderCache) {
|
|
2337
|
+
itemContext.renderCache = context.renderCache;
|
|
2338
|
+
}
|
|
2339
|
+
const itemResult = this.renderTokens(childTokens, itemContext, partials, originalTemplate, config, renderCache);
|
|
2340
|
+
buffer += itemResult;
|
|
2341
|
+
}
|
|
2342
|
+
} else if (typeof value === "object" || typeof value === "string" || typeof value === "number") {
|
|
2343
|
+
const pushedContext = context.push(value);
|
|
2344
|
+
if (context.renderCache) {
|
|
2345
|
+
pushedContext.renderCache = context.renderCache;
|
|
2346
|
+
}
|
|
2347
|
+
buffer += this.renderTokens(childTokens, pushedContext, partials, originalTemplate, config, renderCache);
|
|
2348
|
+
} else if (isFunction(value)) {
|
|
2349
|
+
const text = originalTemplate == null ? null : originalTemplate.slice(token[3], token[5]);
|
|
2350
|
+
value = value.call(context.view, text, (template) => this.render(template, context.view, partials, config));
|
|
2351
|
+
if (value != null) buffer += value;
|
|
2352
|
+
} else if (value) {
|
|
2353
|
+
buffer += this.renderTokens(childTokens, context, partials, originalTemplate, config, renderCache);
|
|
2354
|
+
}
|
|
2355
|
+
break;
|
|
2356
|
+
case "^":
|
|
2357
|
+
value = context.lookup(token[1]);
|
|
2358
|
+
if (!value || isArray(value) && value.length === 0) {
|
|
2359
|
+
const childTokens2 = token[4];
|
|
2360
|
+
if (childTokens2 && isArray(childTokens2)) {
|
|
2361
|
+
buffer += this.renderTokens(childTokens2, context, partials, originalTemplate, config, renderCache);
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
break;
|
|
2365
|
+
case ">":
|
|
2366
|
+
if (!partials) continue;
|
|
2367
|
+
value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
|
2368
|
+
if (value != null) {
|
|
2369
|
+
buffer += this.render(value, context.view, partials, config);
|
|
2370
|
+
}
|
|
2371
|
+
break;
|
|
2372
|
+
case "&":
|
|
2373
|
+
value = context.lookup(token[1]);
|
|
2374
|
+
if (value != null) buffer += value;
|
|
2375
|
+
break;
|
|
2376
|
+
case "name":
|
|
2377
|
+
value = context.lookup(token[1]);
|
|
2378
|
+
if (value != null) buffer += escapeHtml(value);
|
|
2379
|
+
break;
|
|
2380
|
+
case "text":
|
|
2381
|
+
buffer += token[1];
|
|
2382
|
+
break;
|
|
2394
2383
|
}
|
|
2395
|
-
} else {
|
|
2396
|
-
value = void 0;
|
|
2397
2384
|
}
|
|
2398
|
-
|
|
2399
|
-
return dataFormatter.pipe(value, pipes, this._rootContext || this._data);
|
|
2400
|
-
}
|
|
2401
|
-
return value;
|
|
2402
|
-
}
|
|
2403
|
-
/**
|
|
2404
|
-
* Check if wrapper has a property
|
|
2405
|
-
* @param {string} key - Property key
|
|
2406
|
-
* @returns {boolean} True if property exists
|
|
2407
|
-
*/
|
|
2408
|
-
has(key) {
|
|
2409
|
-
return this._data && this._data.hasOwnProperty(key);
|
|
2385
|
+
return buffer;
|
|
2410
2386
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
return this._data;
|
|
2387
|
+
getConfigTags(config) {
|
|
2388
|
+
if (isObject(config) && isArray(config.tags)) {
|
|
2389
|
+
return config.tags;
|
|
2390
|
+
}
|
|
2391
|
+
return null;
|
|
2417
2392
|
}
|
|
2418
2393
|
}
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
window.utils = MOJOUtils;
|
|
2394
|
+
function escapeRegExp(string) {
|
|
2395
|
+
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
2422
2396
|
}
|
|
2397
|
+
const defaultWriter = new Writer();
|
|
2398
|
+
const Mustache = {
|
|
2399
|
+
name: "MOJO Mustache",
|
|
2400
|
+
version: "1.0.0",
|
|
2401
|
+
tags: ["{{", "}}"],
|
|
2402
|
+
Scanner,
|
|
2403
|
+
Context,
|
|
2404
|
+
Writer,
|
|
2405
|
+
escape: escapeHtml,
|
|
2406
|
+
clearCache() {
|
|
2407
|
+
return defaultWriter.clearCache();
|
|
2408
|
+
},
|
|
2409
|
+
parse(template, tags) {
|
|
2410
|
+
return defaultWriter.parse(template, tags);
|
|
2411
|
+
},
|
|
2412
|
+
render(template, view, partials, config) {
|
|
2413
|
+
if (typeof template !== "string") {
|
|
2414
|
+
throw new TypeError('Invalid template! Template should be a "string"');
|
|
2415
|
+
}
|
|
2416
|
+
if (view && typeof view === "object" && !view.getContextValue && typeof view.toJSON !== "function") {
|
|
2417
|
+
view = MOJOUtils.wrapData(view);
|
|
2418
|
+
}
|
|
2419
|
+
return defaultWriter.render(template, view, partials, config);
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2423
2422
|
class EventDelegate {
|
|
2424
2423
|
constructor(view) {
|
|
2425
2424
|
this.view = view;
|
|
@@ -4133,4 +4132,4 @@ export {
|
|
|
4133
4132
|
dataFormatter as d,
|
|
4134
4133
|
rest as r
|
|
4135
4134
|
};
|
|
4136
|
-
//# sourceMappingURL=Rest-
|
|
4135
|
+
//# sourceMappingURL=Rest-C3KvOEeY.js.map
|