mushroom-cli 1.2.8 → 2.0.0-alpha.1
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/README.md +63 -18
- package/dist/common.js +0 -143
- package/dist/config.js +0 -7
- package/dist/docs/docs.html +2 -2
- package/dist/docs/docs.v2.html +13 -13
- package/dist/docs/docs.v2.js +143 -73
- package/dist/gen/csharp/extEvents.js +195 -0
- package/dist/gen/gen-api-docs.js +51 -35
- package/dist/gen/gen-csharp.js +188 -421
- package/dist/gen/gen-list-api.js +4 -4
- package/dist/gen.js +4 -9
- package/dist/help.js +5 -5
- package/dist/init/init-netcore.js +26 -5
- package/dist/init/netcore/templateProcessor.js +182 -0
- package/package.json +8 -15
package/dist/docs/docs.v2.js
CHANGED
|
@@ -213,10 +213,14 @@ function formatModel(obj, strIndent, options) {
|
|
|
213
213
|
|
|
214
214
|
var result = '';
|
|
215
215
|
var nextIndent = strIndent + ' ';
|
|
216
|
-
|
|
216
|
+
var keys = Object.keys(obj);
|
|
217
|
+
var lastIndex = keys.length - 1;
|
|
218
|
+
for (var i = 0; i <= lastIndex; i++) {
|
|
219
|
+
var m = keys[i];
|
|
217
220
|
if (!obj.hasOwnProperty(m)) continue;
|
|
218
221
|
|
|
219
222
|
var child = obj[m];
|
|
223
|
+
var comma = i < lastIndex ? ',' : '';
|
|
220
224
|
|
|
221
225
|
var validation = !options.optionalToAll && child.validation && child.validation.required ? 'required' : 'optional';
|
|
222
226
|
if (child.type === 'IdRef' && child.reference) {
|
|
@@ -246,7 +250,7 @@ function formatModel(obj, strIndent, options) {
|
|
|
246
250
|
if (options.mode === 'model') {
|
|
247
251
|
if (child.type === 'object')
|
|
248
252
|
result +=
|
|
249
|
-
'\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) +
|
|
253
|
+
'\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) + comma;
|
|
250
254
|
else if (child.type === 'array') {
|
|
251
255
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
252
256
|
if (child.items.type === 'object')
|
|
@@ -269,33 +273,33 @@ function formatModel(obj, strIndent, options) {
|
|
|
269
273
|
' ' +
|
|
270
274
|
comment +
|
|
271
275
|
`\r\n${nextIndent}`;
|
|
272
|
-
result += ']
|
|
276
|
+
result += ']' + comma;
|
|
273
277
|
} else if (child.type === 'datetime')
|
|
274
278
|
result +=
|
|
275
|
-
`\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || 'ISODate_ISO_8601') + '
|
|
279
|
+
`\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || 'ISODate_ISO_8601') + comma + ' ' + comment;
|
|
276
280
|
else if (child.type === 'boolean')
|
|
277
|
-
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || 'false') + '
|
|
281
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || 'false') + comma + ' ' + comment;
|
|
278
282
|
else if (child.type === 'integer' || child.type === 'long' || child.type === 'double')
|
|
279
|
-
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || '0') + '
|
|
280
|
-
else result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + '
|
|
283
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || '0') + comma + ' ' + comment;
|
|
284
|
+
else result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + comma + ' ' + comment;
|
|
281
285
|
} else if (options.mode === 'model_null') {
|
|
282
286
|
if (child.type === 'object')
|
|
283
|
-
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) +
|
|
287
|
+
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) + comma;
|
|
284
288
|
else if (child.type === 'array') {
|
|
285
289
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
286
290
|
if (child.items.type === 'object')
|
|
287
|
-
result += ' ' + comment + formatModel(child.items.fields, nextIndent, options) + ']
|
|
288
|
-
else result += ']
|
|
289
|
-
} else result += `\r\n${nextIndent}"${m}": null
|
|
291
|
+
result += ' ' + comment + formatModel(child.items.fields, nextIndent, options) + ']' + comma;
|
|
292
|
+
else result += ']' + comma + ' ' + comment;
|
|
293
|
+
} else result += `\r\n${nextIndent}"${m}": null${comma} ${comment}`;
|
|
290
294
|
} else if (options.mode === 'model_undefined') {
|
|
291
295
|
if (child.type === 'object')
|
|
292
|
-
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) +
|
|
296
|
+
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) + comma;
|
|
293
297
|
else if (child.type === 'array') {
|
|
294
298
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
295
299
|
if (child.items.type === 'object')
|
|
296
|
-
result += ' ' + comment + formatModel(child.items.fields, nextIndent, options) + ']
|
|
297
|
-
else result += ']
|
|
298
|
-
} else result += `\r\n${nextIndent}"${m}": undefined
|
|
300
|
+
result += ' ' + comment + formatModel(child.items.fields, nextIndent, options) + ']' + comma + ' ';
|
|
301
|
+
else result += ']' + comma + ' ' + comment;
|
|
302
|
+
} else result += `\r\n${nextIndent}"${m}": undefined${comma} ${comment}`;
|
|
299
303
|
} else {
|
|
300
304
|
const fieldIdx = 'f_' + __field_idx.toString(36);
|
|
301
305
|
__field_idx++;
|
|
@@ -304,7 +308,7 @@ function formatModel(obj, strIndent, options) {
|
|
|
304
308
|
if (child.type === 'object') result += ' ' + comment + '<span id="' + fieldIdx + '">' + formatModel(child.fields, strIndent + ' ', options) + '</span>';
|
|
305
309
|
else if (child.type === 'array' && child.items.type === 'object')
|
|
306
310
|
result += ' ' + comment + '<span id="' + fieldIdx + '">' + formatModel(child.items.fields, strIndent + ' ', options) + '</span>';
|
|
307
|
-
else result += '
|
|
311
|
+
else result += ' ' + comment;
|
|
308
312
|
}
|
|
309
313
|
}
|
|
310
314
|
|
|
@@ -368,10 +372,14 @@ function formatHintModel(obj, strIndent, options) {
|
|
|
368
372
|
|
|
369
373
|
var result = '';
|
|
370
374
|
var nextIndent = strIndent + ' ';
|
|
371
|
-
|
|
375
|
+
var keys = Object.keys(obj);
|
|
376
|
+
var lastIndex = keys.length - 1;
|
|
377
|
+
for (var i = 0; i <= lastIndex; i++) {
|
|
378
|
+
var m = keys[i];
|
|
372
379
|
if (!obj.hasOwnProperty(m)) continue;
|
|
373
380
|
|
|
374
381
|
var child = obj[m];
|
|
382
|
+
var comma = i < lastIndex ? ',' : '';
|
|
375
383
|
|
|
376
384
|
var validation = !options.optionalToAll && child.required ? 'required' : 'optional';
|
|
377
385
|
if (child.type === 'IdRef' && child.reference) {
|
|
@@ -395,7 +403,7 @@ function formatHintModel(obj, strIndent, options) {
|
|
|
395
403
|
if (options.mode === 'model') {
|
|
396
404
|
if (child.type === 'object')
|
|
397
405
|
result +=
|
|
398
|
-
'\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) +
|
|
406
|
+
'\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) + comma;
|
|
399
407
|
else if (child.type === 'array') {
|
|
400
408
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
401
409
|
if (child.items.type === 'object')
|
|
@@ -418,40 +426,40 @@ function formatHintModel(obj, strIndent, options) {
|
|
|
418
426
|
' ' +
|
|
419
427
|
comment +
|
|
420
428
|
`\r\n${nextIndent}`;
|
|
421
|
-
result += ']
|
|
429
|
+
result += ']' + comma;
|
|
422
430
|
} else if (child.type === 'datetime')
|
|
423
431
|
result +=
|
|
424
|
-
`\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || 'ISODate_ISO_8601') + '
|
|
432
|
+
`\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || 'ISODate_ISO_8601') + comma + ' ' + comment;
|
|
425
433
|
else if (child.type === 'boolean')
|
|
426
|
-
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || 'false') + '
|
|
434
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || 'false') + comma + ' ' + comment;
|
|
427
435
|
else if (child.type === 'integer' || child.type === 'long' || child.type === 'double')
|
|
428
|
-
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || '0') + '
|
|
429
|
-
else result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + '
|
|
436
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || '0') + comma + ' ' + comment;
|
|
437
|
+
else result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + comma + ' ' + comment;
|
|
430
438
|
} else if (options.mode === 'model_null') {
|
|
431
439
|
if (child.type === 'object')
|
|
432
|
-
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) +
|
|
440
|
+
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) + comma;
|
|
433
441
|
else if (child.type === 'array') {
|
|
434
442
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
435
443
|
if (child.items.type === 'object')
|
|
436
|
-
result += ' ' + comment + formatHintModel(child.items.fields, nextIndent, options) + ']
|
|
437
|
-
else result += ']
|
|
438
|
-
} else result += `\r\n${nextIndent}"${m}": null
|
|
444
|
+
result += ' ' + comment + formatHintModel(child.items.fields, nextIndent, options) + ']' + comma;
|
|
445
|
+
else result += ']' + comma + ' ' + comment;
|
|
446
|
+
} else result += `\r\n${nextIndent}"${m}": null${comma} ${comment}`;
|
|
439
447
|
} else if (options.mode === 'model_undefined') {
|
|
440
448
|
if (child.type === 'object')
|
|
441
|
-
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) +
|
|
449
|
+
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) + comma;
|
|
442
450
|
else if (child.type === 'array') {
|
|
443
451
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
444
452
|
if (child.items.type === 'object')
|
|
445
|
-
result += ' ' + comment + formatHintModel(child.items.fields, nextIndent, options) + ']
|
|
446
|
-
else result += ']
|
|
447
|
-
} else result += `\r\n${nextIndent}"${m}": undefined
|
|
453
|
+
result += ' ' + comment + formatHintModel(child.items.fields, nextIndent, options) + ']' + comma + ' ';
|
|
454
|
+
else result += ']' + comma + ' ' + comment;
|
|
455
|
+
} else result += `\r\n${nextIndent}"${m}": undefined${comma} ${comment}`;
|
|
448
456
|
} else {
|
|
449
457
|
result += '\r\n' + strIndent + encodeHtml(m) + ': ' + encodeHtml(child.type);
|
|
450
458
|
if (child.type === 'array') result += child.items.type === 'object' ? ' of object' : ' of ' + child.items.type;
|
|
451
459
|
if (child.type === 'object') result += ' ' + comment + formatHintModel(child.fields, strIndent + ' ', options);
|
|
452
460
|
else if (child.type === 'array' && child.items.type === 'object')
|
|
453
461
|
result += ' ' + comment + formatHintModel(child.items.fields, strIndent + ' ', options);
|
|
454
|
-
else result += '
|
|
462
|
+
else result += ' ' + comment;
|
|
455
463
|
}
|
|
456
464
|
}
|
|
457
465
|
|
|
@@ -780,7 +788,6 @@ function renderEntityActionRolePage(entityName, actionName, grant) {
|
|
|
780
788
|
};
|
|
781
789
|
tabPage.innerHTML =
|
|
782
790
|
renderTemplate(template, data) + renderTemplate('template-project-entity-action-page-codeSnippets', data);
|
|
783
|
-
initDom(tabPage);
|
|
784
791
|
if (!action.deny) tabPage.querySelector('.deny-roles')?.remove();
|
|
785
792
|
|
|
786
793
|
if (!action.matches || !Array.isArray(action.matches) || !action.matches.length)
|
|
@@ -798,6 +805,7 @@ function renderEntityActionRolePage(entityName, actionName, grant) {
|
|
|
798
805
|
tabPage.querySelector('.description')?.remove();
|
|
799
806
|
}
|
|
800
807
|
callback(args);
|
|
808
|
+
initDom(tabPage);
|
|
801
809
|
}
|
|
802
810
|
|
|
803
811
|
function renderFindMany(args) {
|
|
@@ -1925,23 +1933,32 @@ function doCopy(e) {
|
|
|
1925
1933
|
const copyDom = this.parentNode.querySelector(this.dataset.copy);
|
|
1926
1934
|
|
|
1927
1935
|
if (window.ClipboardItem) {
|
|
1928
|
-
const content = copyDom
|
|
1936
|
+
const content = getVisibleText(copyDom);
|
|
1929
1937
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
1930
1938
|
const text = new ClipboardItem({ 'text/plain': blob });
|
|
1931
1939
|
navigator.clipboard.write([text]);
|
|
1932
1940
|
} else {
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1941
|
+
const clone = cloneVisible(copyDom);
|
|
1942
|
+
copyDom.parentNode.insertBefore(clone, copyDom);
|
|
1943
|
+
const savedDisplay = copyDom.style.display;
|
|
1944
|
+
copyDom.style.display = 'none';
|
|
1945
|
+
try {
|
|
1946
|
+
if (document.body.createTextRange) {
|
|
1947
|
+
const range = document.body.createTextRange();
|
|
1948
|
+
range.moveToElementText(clone);
|
|
1949
|
+
range.select();
|
|
1950
|
+
} else if (window.getSelection) {
|
|
1951
|
+
const selection = window.getSelection();
|
|
1952
|
+
const range = document.createRange();
|
|
1953
|
+
range.selectNodeContents(clone);
|
|
1954
|
+
selection.removeAllRanges();
|
|
1955
|
+
selection.addRange(range);
|
|
1956
|
+
}
|
|
1957
|
+
document.execCommand('copy');
|
|
1958
|
+
} finally {
|
|
1959
|
+
clone.remove();
|
|
1960
|
+
copyDom.style.display = savedDisplay;
|
|
1943
1961
|
}
|
|
1944
|
-
document.execCommand('copy');
|
|
1945
1962
|
}
|
|
1946
1963
|
|
|
1947
1964
|
copied();
|
|
@@ -1955,14 +1972,47 @@ function copied() {
|
|
|
1955
1972
|
setTimeout(() => dom.classList.remove('show'), 1000);
|
|
1956
1973
|
}
|
|
1957
1974
|
|
|
1975
|
+
function getVisibleText(element) {
|
|
1976
|
+
const clone = element.cloneNode(true);
|
|
1977
|
+
// Walk all elements in the clone; remove those that are hidden in the original DOM
|
|
1978
|
+
const originalAll = element.querySelectorAll('*');
|
|
1979
|
+
const cloneAll = clone.querySelectorAll('*');
|
|
1980
|
+
for (let i = cloneAll.length - 1; i >= 0; i--) {
|
|
1981
|
+
const style = window.getComputedStyle(originalAll[i]);
|
|
1982
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
1983
|
+
cloneAll[i].remove();
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
return clone.textContent || '';
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
function cloneVisible(element) {
|
|
1990
|
+
const clone = element.cloneNode(true);
|
|
1991
|
+
const originalAll = element.querySelectorAll('*');
|
|
1992
|
+
const cloneAll = clone.querySelectorAll('*');
|
|
1993
|
+
for (let i = cloneAll.length - 1; i >= 0; i--) {
|
|
1994
|
+
const style = window.getComputedStyle(originalAll[i]);
|
|
1995
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
1996
|
+
cloneAll[i].remove();
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
return clone;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
1958
2002
|
function initDom(dom) {
|
|
1959
2003
|
$('pre[data-language]', dom).each(function () {
|
|
1960
|
-
|
|
1961
|
-
holder
|
|
2004
|
+
let holder = this.querySelector(":scope > .command-bar");
|
|
2005
|
+
if (!holder) {
|
|
2006
|
+
holder = document.createElement('div');
|
|
2007
|
+
holder.className = 'command-bar';
|
|
2008
|
+
$(this).prepend(holder);
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
if (holder.querySelector(":scope > .command-item-copy")) return;
|
|
1962
2012
|
const copyButton = document.createElement('a');
|
|
2013
|
+
copyButton.className = 'command-item-copy';
|
|
1963
2014
|
copyButton.innerHTML = 'Copy';
|
|
1964
2015
|
holder.appendChild(copyButton);
|
|
1965
|
-
$(this).prepend(holder);
|
|
1966
2016
|
copyButton.onclick = function () {
|
|
1967
2017
|
if (location.protocol !== 'https:' && location.protocol !== 'file:') {
|
|
1968
2018
|
alert('Can not copy, please use https protocol!');
|
|
@@ -1972,23 +2022,32 @@ function initDom(dom) {
|
|
|
1972
2022
|
const commandBar = $(this).parent().detach();
|
|
1973
2023
|
try {
|
|
1974
2024
|
if (window.ClipboardItem) {
|
|
1975
|
-
const content = pre
|
|
2025
|
+
const content = getVisibleText(pre[0]);
|
|
1976
2026
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
1977
2027
|
const text = new ClipboardItem({ 'text/plain': blob });
|
|
1978
2028
|
navigator.clipboard.write([text]);
|
|
1979
2029
|
} else {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
2030
|
+
const clone = cloneVisible(pre[0]);
|
|
2031
|
+
pre[0].parentNode.insertBefore(clone, pre[0]);
|
|
2032
|
+
const savedDisplay = pre[0].style.display;
|
|
2033
|
+
pre[0].style.display = 'none';
|
|
2034
|
+
try {
|
|
2035
|
+
if (document.body.createTextRange) {
|
|
2036
|
+
const range = document.body.createTextRange();
|
|
2037
|
+
range.moveToElementText(clone);
|
|
2038
|
+
range.select();
|
|
2039
|
+
} else if (window.getSelection) {
|
|
2040
|
+
const selection = window.getSelection();
|
|
2041
|
+
const range = document.createRange();
|
|
2042
|
+
range.selectNodeContents(clone);
|
|
2043
|
+
selection.removeAllRanges();
|
|
2044
|
+
selection.addRange(range);
|
|
2045
|
+
}
|
|
2046
|
+
document.execCommand('copy');
|
|
2047
|
+
} finally {
|
|
2048
|
+
clone.remove();
|
|
2049
|
+
pre[0].style.display = savedDisplay;
|
|
1990
2050
|
}
|
|
1991
|
-
document.execCommand('copy');
|
|
1992
2051
|
}
|
|
1993
2052
|
} finally {
|
|
1994
2053
|
pre.prepend(commandBar);
|
|
@@ -1998,8 +2057,10 @@ function initDom(dom) {
|
|
|
1998
2057
|
};
|
|
1999
2058
|
});
|
|
2000
2059
|
|
|
2001
|
-
$('pre[data-language=json] .command-bar', dom).each(function () {
|
|
2060
|
+
$('pre[data-language=json] .command-bar, pre[data-language=object-spec] .command-bar', dom).each(function () {
|
|
2061
|
+
if (this.querySelector(":scope > .command-item-copy-without-comment")) return;
|
|
2002
2062
|
const copyButton = document.createElement('a');
|
|
2063
|
+
copyButton.className = 'command-item-copy-without-comment';
|
|
2003
2064
|
copyButton.innerHTML = 'Copy (without comment)';
|
|
2004
2065
|
$(this).prepend(copyButton);
|
|
2005
2066
|
copyButton.onclick = function () {
|
|
@@ -2015,23 +2076,32 @@ function initDom(dom) {
|
|
|
2015
2076
|
});
|
|
2016
2077
|
try {
|
|
2017
2078
|
if (window.ClipboardItem) {
|
|
2018
|
-
const content = pre
|
|
2079
|
+
const content = getVisibleText(pre[0]);
|
|
2019
2080
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
2020
2081
|
const text = new ClipboardItem({ 'text/plain': blob });
|
|
2021
2082
|
navigator.clipboard.write([text]);
|
|
2022
2083
|
} else {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2084
|
+
const clone = cloneVisible(pre[0]);
|
|
2085
|
+
pre[0].parentNode.insertBefore(clone, pre[0]);
|
|
2086
|
+
const savedDisplay = pre[0].style.display;
|
|
2087
|
+
pre[0].style.display = 'none';
|
|
2088
|
+
try {
|
|
2089
|
+
if (document.body.createTextRange) {
|
|
2090
|
+
const range = document.body.createTextRange();
|
|
2091
|
+
range.moveToElementText(clone);
|
|
2092
|
+
range.select();
|
|
2093
|
+
} else if (window.getSelection) {
|
|
2094
|
+
const selection = window.getSelection();
|
|
2095
|
+
const range = document.createRange();
|
|
2096
|
+
range.selectNodeContents(clone);
|
|
2097
|
+
selection.removeAllRanges();
|
|
2098
|
+
selection.addRange(range);
|
|
2099
|
+
}
|
|
2100
|
+
document.execCommand('copy');
|
|
2101
|
+
} finally {
|
|
2102
|
+
clone.remove();
|
|
2103
|
+
pre[0].style.display = savedDisplay;
|
|
2033
2104
|
}
|
|
2034
|
-
document.execCommand('copy');
|
|
2035
2105
|
}
|
|
2036
2106
|
} finally {
|
|
2037
2107
|
pre.prepend(commandBar);
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
const extEvents = {
|
|
2
|
+
auth: {
|
|
3
|
+
'Events.Login.Before': {
|
|
4
|
+
type: 'Before',
|
|
5
|
+
},
|
|
6
|
+
'Events.Login.Validate.Before': {
|
|
7
|
+
type: 'Before',
|
|
8
|
+
},
|
|
9
|
+
'Events.Login.Validate.After': {
|
|
10
|
+
type: 'After',
|
|
11
|
+
},
|
|
12
|
+
'Events.Login.CheckLocking.Before': {
|
|
13
|
+
type: 'Before',
|
|
14
|
+
},
|
|
15
|
+
'Events.Login.CheckLocking.After': {
|
|
16
|
+
type: 'After',
|
|
17
|
+
data: 'Mushroom.Extensions.DefaultAuth.UserLock',
|
|
18
|
+
},
|
|
19
|
+
CustomLoginAsyncFunc: {
|
|
20
|
+
type: 'Func',
|
|
21
|
+
registerFunc: 'RegisterCustomLoginAsyncHandler',
|
|
22
|
+
},
|
|
23
|
+
'Events.Login.LogAuth.Before': {
|
|
24
|
+
type: 'Before',
|
|
25
|
+
},
|
|
26
|
+
GetAuthLogInfoAsyncFunc: {
|
|
27
|
+
type: 'Func',
|
|
28
|
+
registerFunc: 'RegisterGetAuthLogInfoAsyncHandler',
|
|
29
|
+
},
|
|
30
|
+
'Events.Login.LogAuth.After': {
|
|
31
|
+
type: 'After',
|
|
32
|
+
data: 'Mushroom.Extensions.DefaultAuth.UserAuthLogResult',
|
|
33
|
+
},
|
|
34
|
+
'Events.Login.LoginFail': {
|
|
35
|
+
type: 'After',
|
|
36
|
+
},
|
|
37
|
+
'Events.Login.LoginSuccess': {
|
|
38
|
+
type: 'Event',
|
|
39
|
+
registerFunc: 'RegisterLoginSuccessHandler',
|
|
40
|
+
},
|
|
41
|
+
'Events.Login.After': {
|
|
42
|
+
type: 'After',
|
|
43
|
+
data: 'string',
|
|
44
|
+
},
|
|
45
|
+
'Events.Logout.Before': {
|
|
46
|
+
type: 'Before',
|
|
47
|
+
},
|
|
48
|
+
'Events.Logout.After': {
|
|
49
|
+
type: 'After',
|
|
50
|
+
data: 'bool',
|
|
51
|
+
},
|
|
52
|
+
'Events.Status.Before': {
|
|
53
|
+
type: 'Before',
|
|
54
|
+
},
|
|
55
|
+
'Events.Status.After': {
|
|
56
|
+
type: 'After',
|
|
57
|
+
data: 'bool',
|
|
58
|
+
},
|
|
59
|
+
'Events.Me.Before': {
|
|
60
|
+
type: 'Before',
|
|
61
|
+
},
|
|
62
|
+
'Events.Me.After': {
|
|
63
|
+
type: 'After',
|
|
64
|
+
data: 'Mushroom.Extensions.DefaultAuth.User',
|
|
65
|
+
},
|
|
66
|
+
'Events.Register.Before': {
|
|
67
|
+
type: 'Before',
|
|
68
|
+
},
|
|
69
|
+
SendCodeItemFunc: {
|
|
70
|
+
type: 'Func',
|
|
71
|
+
registerFunc: 'RegisterSendCodeItemHandler',
|
|
72
|
+
},
|
|
73
|
+
'Events.Register.After': {
|
|
74
|
+
type: 'After',
|
|
75
|
+
data: 'Mushroom.Extensions.DefaultAuth.User',
|
|
76
|
+
},
|
|
77
|
+
'Events.Activate.Before': {
|
|
78
|
+
type: 'Before',
|
|
79
|
+
},
|
|
80
|
+
'Events.Activate.After': {
|
|
81
|
+
type: 'After',
|
|
82
|
+
data: 'Mushroom.Extensions.DefaultAuth.User',
|
|
83
|
+
},
|
|
84
|
+
'Events.RecoverPassword.Before': {
|
|
85
|
+
type: 'Before',
|
|
86
|
+
},
|
|
87
|
+
'Events.RecoverPassword.After': {
|
|
88
|
+
type: 'After',
|
|
89
|
+
data: 'Mushroom.Extensions.DefaultAuth.User',
|
|
90
|
+
},
|
|
91
|
+
'Events.ResetPassword.Before': {
|
|
92
|
+
type: 'Before',
|
|
93
|
+
},
|
|
94
|
+
'Events.ResetPassword.After': {
|
|
95
|
+
type: 'After',
|
|
96
|
+
data: 'Mushroom.Extensions.DefaultAuth.User',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
file: {
|
|
100
|
+
'Events.Upload.Before': {
|
|
101
|
+
type: 'Before',
|
|
102
|
+
},
|
|
103
|
+
'Events.Upload.After': {
|
|
104
|
+
type: 'After',
|
|
105
|
+
},
|
|
106
|
+
'Events.Thumb.Before': {
|
|
107
|
+
type: 'Before',
|
|
108
|
+
},
|
|
109
|
+
'Events.Thumb.After': {
|
|
110
|
+
type: 'After',
|
|
111
|
+
},
|
|
112
|
+
'Events.Download.Before': {
|
|
113
|
+
type: 'Before',
|
|
114
|
+
},
|
|
115
|
+
'Events.Download.After': {
|
|
116
|
+
type: 'After',
|
|
117
|
+
},
|
|
118
|
+
'Events.Zip.Before': {
|
|
119
|
+
type: 'Before',
|
|
120
|
+
},
|
|
121
|
+
'Events.Zip.After': {
|
|
122
|
+
type: 'After',
|
|
123
|
+
},
|
|
124
|
+
LimitFileUploadSizeFunc: {
|
|
125
|
+
type: 'Func',
|
|
126
|
+
data: 'System.Threading.Tasks.Task<long?>',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
mail: {
|
|
130
|
+
AuthorizationFunc: {
|
|
131
|
+
type: 'Func',
|
|
132
|
+
data: 'System.Threading.Tasks.Task<bool>, Mushroom.Extensions.Mailing.MailingAuthorizationArgument',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
export const getExtensionEventsCode = (source, newLine) => {
|
|
137
|
+
const eventCodes = [];
|
|
138
|
+
const addEventCodes = (key, code, source) => {
|
|
139
|
+
const eventCode = eventCodes.find((ec) => ec.key === key);
|
|
140
|
+
if (eventCode) {
|
|
141
|
+
eventCode.source.push(source);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
eventCodes.push({
|
|
145
|
+
key,
|
|
146
|
+
code,
|
|
147
|
+
source: [source],
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
Object.keys(extEvents).forEach((ext) => {
|
|
151
|
+
const extension = source.extensions?.[ext];
|
|
152
|
+
if (!extension?.config)
|
|
153
|
+
return;
|
|
154
|
+
const config = extension.config;
|
|
155
|
+
Object.keys(extEvents[ext]).forEach((configName) => {
|
|
156
|
+
const def = extEvents[ext][configName];
|
|
157
|
+
const configValue = config[configName];
|
|
158
|
+
if (!configValue || typeof configValue !== 'string' || !configValue.startsWith('lib:'))
|
|
159
|
+
return;
|
|
160
|
+
if (def.type == 'Func') {
|
|
161
|
+
const defaultFunc = `RegisterCustomMethod<${def.data || 'System.Threading.Tasks.Task'}>`;
|
|
162
|
+
addEventCodes(ext + '.' + configName, `${def.registerFunc || defaultFunc}(${configValue.substring(4)});`, `extension: ${ext} - config: ${configName}`);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (def.type == 'Event') {
|
|
166
|
+
configValue.split(',').forEach((lib) => {
|
|
167
|
+
if (!lib || !lib.startsWith('lib:'))
|
|
168
|
+
return;
|
|
169
|
+
addEventCodes(ext + '.' + configName, `${def.registerFunc || 'RegisterEvent'}(${lib.substring(4)});`, `extension: ${ext} - config: ${configName}`);
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (def.type == 'Before') {
|
|
174
|
+
configValue.split(',').forEach((lib) => {
|
|
175
|
+
if (!lib || !lib.startsWith('lib:'))
|
|
176
|
+
return;
|
|
177
|
+
addEventCodes(ext + '.' + configName, `${def.registerFunc || 'RegisterBeforeEvent'}(${lib.substring(4)});`, `extension: ${ext} - config: ${configName}`);
|
|
178
|
+
});
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (def.type == 'After') {
|
|
182
|
+
configValue.split(',').forEach((lib) => {
|
|
183
|
+
if (!lib || !lib.startsWith('lib:'))
|
|
184
|
+
return;
|
|
185
|
+
addEventCodes(ext + '.' + configName, `${def.registerFunc || (def.data ? `RegisterAfterEvent<${def.data}>` : 'RegisterAfterEvent')}(${lib.substring(4)});`, `extension: ${ext} - config: ${configName}`);
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
return '';
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
return eventCodes
|
|
193
|
+
.map((ec) => `${ec.source.map((s) => ' // ' + s).join(newLine)}${newLine} ${ec.code}`)
|
|
194
|
+
.join(newLine);
|
|
195
|
+
};
|