bpmn-js-bpmnlint
Advanced tools
Comparing version 0.21.0 to 0.22.0
@@ -28,6 +28,3 @@ (function (global, factory) { | ||
if (this instanceof a) { | ||
var args = [null]; | ||
args.push.apply(args, arguments); | ||
var Ctor = Function.bind.apply(f, args); | ||
return new Ctor(); | ||
return Reflect.construct(f, arguments, this.constructor); | ||
} | ||
@@ -1091,3 +1088,5 @@ return f.apply(this, arguments); | ||
const ruleErrorCategory = 'rule-error'; | ||
function Linter$1(options = {}) { | ||
@@ -1154,4 +1153,4 @@ | ||
{ | ||
message: 'Rule error: ' + e.message, | ||
category: 'error' | ||
message: e.message, | ||
category: ruleErrorCategory | ||
} | ||
@@ -1544,47 +1543,3 @@ ]; | ||
var componentEvent = {}; | ||
var bind$1, unbind$1, prefix; | ||
function detect () { | ||
bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent'; | ||
unbind$1 = window.removeEventListener ? 'removeEventListener' : 'detachEvent'; | ||
prefix = bind$1 !== 'addEventListener' ? 'on' : ''; | ||
} | ||
/** | ||
* Bind `el` event `type` to `fn`. | ||
* | ||
* @param {Element} el | ||
* @param {String} type | ||
* @param {Function} fn | ||
* @param {Boolean} capture | ||
* @return {Function} | ||
* @api public | ||
*/ | ||
componentEvent.bind = function(el, type, fn, capture){ | ||
if (!bind$1) detect(); | ||
el[bind$1](prefix + type, fn, capture || false); | ||
return fn; | ||
}; | ||
/** | ||
* Unbind `el` event `type`'s callback `fn`. | ||
* | ||
* @param {Element} el | ||
* @param {String} type | ||
* @param {Function} fn | ||
* @param {Boolean} capture | ||
* @return {Function} | ||
* @api public | ||
*/ | ||
componentEvent.unbind = function(el, type, fn, capture){ | ||
if (!unbind$1) detect(); | ||
el[unbind$1](prefix + type, fn, capture || false); | ||
return fn; | ||
}; | ||
/** | ||
* Expose `parse`. | ||
@@ -1760,8 +1715,10 @@ */ | ||
var ErrorSvg = "<svg width=\"12\" height=\"12\" version=\"1.1\" viewBox=\"0 0 352 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var ErrorSvg = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n version=\"1.1\"\n viewBox=\"0 0 512 512\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M 339.07183,256.00001 463.66713,131.4047 c 15.28961,-15.2896 15.28961,-40.079175 0,-55.381227 l -27.6906,-27.690611 c -15.28961,-15.289602 -40.07917,-15.289602 -55.38123,0 L 256,172.92818 131.4047,48.332862 c -15.2896,-15.289602 -40.079177,-15.289602 -55.381228,0 L 48.332861,76.023473 c -15.2896,15.2896 -15.2896,40.079177 0,55.381227 L 172.92815,256.00001 48.332861,380.59531 c -15.2896,15.2896 -15.2896,40.07917 0,55.38123 l 27.690611,27.69061 c 15.289601,15.28959 40.091628,15.28959 55.381228,0 L 256,339.07184 380.5953,463.66715 c 15.2896,15.28959 40.09162,15.28959 55.38123,0 l 27.6906,-27.69061 c 15.28961,-15.2896 15.28961,-40.07918 0,-55.38123 z\"\n fill=\"currentColor\" />\n</svg>\n"; | ||
var WarningSvg = "<svg width=\"12\" height=\"12\" version=\"1.1\" viewBox=\"0 0 512 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m256 323.95c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zm-80.561-271.8 11.61 204.35c.544 9.334 8.78 16.64 18.755 16.64h100.39c9.975 0 18.211-7.306 18.754-16.64l11.611-204.35c.587-10.082-7.98-18.56-18.754-18.56h-123.62c-10.775 0-19.34 8.478-18.753 18.56z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var WarningSvg = "<svg version=\"1.1\" viewBox=\"0 0 512 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m256 323.95c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zm-80.561-271.8 11.61 204.35c.544 9.334 8.78 16.64 18.755 16.64h100.39c9.975 0 18.211-7.306 18.754-16.64l11.611-204.35c.587-10.082-7.98-18.56-18.754-18.56h-123.62c-10.775 0-19.34 8.478-18.753 18.56z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var SuccessSvg = "<svg width=\"12\" height=\"12\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path fill=\"currentColor\" d=\"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z\"></path></svg>"; | ||
var SuccessSvg = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n viewBox=\"0 0 512 512\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\"\n d=\"m 173.898,439.40356 -166.4,-166.4 c -9.997,-9.997 -9.997,-26.206 0,-36.204 l 36.203,-36.204 c 9.997,-9.998 26.207,-9.998 36.204,0 L 192,312.68956 432.095,72.595562 c 9.997,-9.997 26.207,-9.997 36.204,0 l 36.203,36.203998 c 9.997,9.997 9.997,26.206 0,36.204 l -294.4,294.401 c -9.998,9.997 -26.207,9.997 -36.204,-10e-4 z\" />\n</svg>\n"; | ||
var InfoSvg = "<svg\n viewBox=\"3.5 3.5 9 9\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\" d=\"M6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z\"></path>\n</svg>"; | ||
var OFFSET_TOP = -7, | ||
@@ -1785,2 +1742,3 @@ OFFSET_RIGHT = -7; | ||
success: SuccessSvg, | ||
info: InfoSvg, | ||
inactive: SuccessSvg | ||
@@ -1820,5 +1778,3 @@ }; | ||
], LOW_PRIORITY, function(e) { | ||
if (self.isActive()) { | ||
self.update(); | ||
} | ||
self.update(); | ||
}); | ||
@@ -2015,4 +1971,7 @@ | ||
self._clearOverlays(); | ||
self._createIssues(add); | ||
if (self.isActive()) { | ||
self._createIssues(add); | ||
} | ||
self._issues = newIssues; | ||
@@ -2088,6 +2047,15 @@ | ||
warnings = issuesByType.warn, | ||
infos = issuesByType.info, | ||
childErrors = issuesByType.childerror, | ||
childWarnings = issuesByType.childwarn; | ||
childWarnings = issuesByType.childwarn, | ||
childInfos = issuesByType.childinfo; | ||
if (!errors && !warnings && !childErrors && !childWarnings) { | ||
if ( | ||
!infos && | ||
!errors && | ||
!warnings && | ||
!childErrors && | ||
!childWarnings && | ||
!childInfos | ||
) { | ||
return; | ||
@@ -2102,3 +2070,5 @@ } | ||
? domify$1('<div class="bjsl-icon bjsl-icon-error">' + ErrorSvg + '</div>') | ||
: domify$1('<div class="bjsl-icon bjsl-icon-warning">' + WarningSvg + '</div>'); | ||
: (warnings || childWarnings) | ||
? domify$1('<div class="bjsl-icon bjsl-icon-warning">' + WarningSvg + '</div>') | ||
: domify$1('<div class="bjsl-icon bjsl-icon-info">' + InfoSvg + '</div>'); | ||
@@ -2132,5 +2102,9 @@ var $dropdown = domify$1('<div class="bjsl-dropdown"></div>'); | ||
if (infos) { | ||
this._addInfos($issueList, infos); | ||
} | ||
// If errors or warnings for child elements of the current element are to be displayed, | ||
// then add an additional list | ||
if (childErrors || childWarnings) { | ||
if (childErrors || childWarnings || childInfos) { | ||
var $childIssues = domify$1('<div class="bjsl-child-issues"></div>'); | ||
@@ -2148,2 +2122,6 @@ var $childIssueList = domify$1('<ul></ul>'); | ||
if (childInfos) { | ||
this._addInfos($childIssueList, childInfos); | ||
} | ||
if (errors || warnings) { | ||
@@ -2163,3 +2141,3 @@ var $childIssuesSeperator = domify$1('<hr/>'); | ||
scale: { | ||
min: .9 | ||
min: .7 | ||
} | ||
@@ -2187,2 +2165,11 @@ }); | ||
Linting.prototype._addInfos = function($ul, infos) { | ||
var self = this; | ||
infos.forEach(function(error) { | ||
self._addEntry($ul, 'info', error); | ||
}); | ||
}; | ||
Linting.prototype._addEntry = function($ul, state, entry) { | ||
@@ -2226,9 +2213,31 @@ | ||
Linting.prototype._setButtonState = function(state, errors, warnings) { | ||
Linting.prototype._setButtonState = function(issues) { | ||
var { | ||
errors, | ||
warnings, | ||
infos | ||
} = issues; | ||
var button = this._button; | ||
var state = (errors && 'error') || (warnings && 'warning') || 'success'; | ||
var icon = stateToIcon[state]; | ||
var label = this._translate( | ||
(errors || warnings) | ||
? '{errors} Errors, {warnings} Warnings' | ||
: 'No Issues', | ||
{ | ||
errors: String(errors), | ||
warnings: String(warnings), | ||
infos: String(infos), | ||
} | ||
); | ||
var html = icon + '<span>' + this._translate('{errors} Errors, {warnings} Warnings', { errors: errors.toString(), warnings: warnings.toString() }) + '</span>'; | ||
var html = ` | ||
<span class="icon">${icon}</span> | ||
<span>${ label }</span>`; | ||
state = this.isActive() ? state : 'inactive'; | ||
[ | ||
@@ -2252,10 +2261,5 @@ 'error', | ||
if (!this.isActive()) { | ||
this._setButtonState('inactive', 0, 0); | ||
return; | ||
} | ||
var errors = 0, | ||
warnings = 0; | ||
warnings = 0, | ||
infos = 0; | ||
@@ -2268,2 +2272,4 @@ for (var id in this._issues) { | ||
warnings++; | ||
} else if (issue.category === 'info') { | ||
infos++; | ||
} | ||
@@ -2273,5 +2279,7 @@ }); | ||
var state = (errors && 'error') || (warnings && 'warning') || 'success'; | ||
this._setButtonState(state, errors, warnings); | ||
this._setButtonState({ | ||
errors, | ||
warnings, | ||
infos | ||
}); | ||
}; | ||
@@ -2284,3 +2292,3 @@ | ||
this._button = domify$1( | ||
'<button class="bjsl-button bjsl-button-inactive" title="' + this._translate('Toggle linting') + '"></button>' | ||
'<button class="bjsl-button bjsl-button-inactive" title="' + this._translate('Toggle linting overlays') + '"></button>' | ||
); | ||
@@ -2287,0 +2295,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BpmnJSBpmnlint=e()}(this,(function(){"use strict";function t(t,e){var n=t.get("editorActions",!1);n&&n.register({toggleLinting:function(){e.toggle()}})}function e(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){if(this instanceof t){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(e,n))}return e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}t.$inject=["injector","linting"];const n=Object.prototype.toString,r=Object.prototype.hasOwnProperty;function i(t){return void 0===t}function o(t){return void 0!==t}function s(t){return null==t}function c(t){return"[object Array]"===n.call(t)}function u(t){return"[object Object]"===n.call(t)}function l(t){const e=n.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e||"[object Proxy]"===e}function a(t){if(!c(t))throw new Error("must supply array")}function f(t,e){return r.call(t,e)}function p(t,e){const n=C(e);let r;return d(t,(function(t,e){if(n(t,e))return r=t,!1})),r}function d(t,e){let n,r;if(i(t))return;const o=c(t)?E:j;for(let i in t)if(f(t,i)&&(n=t[i],r=e(n,o(i)),!1===r))return n}function h(t,e,n){return d(t,(function(t,r){n=e(n,t,r)})),n}function g(t,e){return!!h(t,(function(t,n,r){return t&&e(n,r)}),!0)}function v(t,e){let n=[];return d(t,(function(t,r){n.push(e(t,r))})),n}function m(t){return t&&Object.keys(t)||[]}function y(t,e,n={}){return e=w(e),d(t,(function(t){let r=e(t)||"_",i=n[r];i||(i=n[r]=[]),i.push(t)})),n}function b(t,...e){t=w(t);let n={};return d(e,(e=>y(e,t,n))),v(n,(function(t,e){return t[0]}))}const _=b;function w(t){return l(t)?t:e=>e[t]}function C(t){return l(t)?t:e=>e===t}function j(t){return t}function E(t){return Number(t)}function R(t,...e){return Object.assign(t,...e)}var O=Object.freeze({__proto__:null,assign:R,bind:function(t,e){return t.bind(e)},debounce:function(t,e){let n,r,i,o;function s(n){let s=Date.now(),l=n?0:o+e-s;if(l>0)return c(l);t.apply(i,r),u()}function c(t){n=setTimeout(s,t)}function u(){n&&clearTimeout(n),n=o=r=i=void 0}function l(...t){o=Date.now(),r=t,i=this,n||c(e)}return l.flush=function(){n&&s(!0),u()},l.cancel=u,l},ensureArray:a,every:g,filter:function(t,e){const n=C(e);let r=[];return d(t,(function(t,e){n(t,e)&&r.push(t)})),r},find:p,findIndex:function(t,e){const n=C(e);let r=c(t)?-1:void 0;return d(t,(function(t,e){if(n(t,e))return r=e,!1})),r},flatten:function(t){return Array.prototype.concat.apply([],t)},forEach:d,get:function(t,e,n){let r=t;return d(e,(function(t){if(s(r))return r=void 0,!1;r=r[t]})),i(r)?n:r},groupBy:y,has:f,isArray:c,isDefined:o,isFunction:l,isNil:s,isNumber:function(t){return"[object Number]"===n.call(t)},isObject:u,isString:function(t){return"[object String]"===n.call(t)},isUndefined:i,keys:m,map:v,matchPattern:function(t){return function(e){return g(t,(function(t,n){return e[n]===t}))}},merge:function t(e,...n){return n.length?(d(n,(function(n){n&&u(n)&&d(n,(function(n,r){if("__proto__"===r)return;let i=e[r];u(n)?(u(i)||(i={}),e[r]=t(i,n)):e[r]=n}))})),e):e},omit:function(t,e){let n={};return d(Object(t),(function(t,r){-1===e.indexOf(r)&&(n[r]=t)})),n},pick:function(t,e){let n={},r=Object(t);return d(e,(function(e){e in r&&(n[e]=t[e])})),n},reduce:h,set:function(t,e,n){let r=t;return d(e,(function(t,c){if("number"!=typeof t&&"string"!=typeof t)throw new Error("illegal key type: "+typeof t+". Key should be of type number or string.");if("constructor"===t)throw new Error("illegal key: constructor");if("__proto__"===t)throw new Error("illegal key: __proto__");let u=e[c+1],l=r[t];o(u)&&s(l)&&(l=r[t]=isNaN(+u)?{}:[]),i(u)?i(n)?delete r[t]:r[t]=n:r=l})),t},size:function(t){return m(t).length},some:function(t,e){return!!p(t,e)},sortBy:function(t,e){e=w(e);let n=[];return d(t,(function(t,r){let i=e(t,r),o={d:i,v:t};for(var s=0;s<n.length;s++){let{d:t}=n[s];if(i<t)return void n.splice(s,0,o)}n.push(o)})),v(n,(t=>t.v))},throttle:function(t,e){let n=!1;return function(...r){n||(t(...r),n=!0,setTimeout((()=>{n=!1}),e))}},unionBy:_,uniqueBy:b,values:function(t){return v(t,(t=>t))},without:function(t,e){if(i(t))return[];a(t);const n=C(e);return t.filter((function(t,e){return!n(t,e)}))}}),k=e(O);const $=function t(e,n){const r=n.enter||null,i=n.leave||null,o=r&&r(e),s=e.$descriptor;if(!1!==o&&!s.isGeneric){s.properties.filter((t=>!t.isAttr&&!t.isReference&&"String"!==t.type)).forEach((r=>{if(r.name in e){const i=e[r.name];r.isMany?i.forEach((e=>{t(e,n)})):t(i,n)}}))}i&&i(e)},{isArray:L,isObject:B}=k;class x{constructor({moddleRoot:t,rule:e}){this.rule=e,this.moddleRoot=t,this.messages=[],this.report=this.report.bind(this)}report(t,e,n){let r={id:t,message:e};n&&L(n)&&(r={...r,path:n}),n&&B(n)&&(r={...r,...n}),this.messages.push(r)}}const N=function({moddleRoot:t,rule:e}){const n=new x({rule:e,moddleRoot:t}),r=e.check,i=r&&r.enter||r,o=r&&r.leave;if(!i&&!o)throw new Error("no check implemented");return $(t,{enter:i?t=>i(t,n):null,leave:o?t=>o(t,n):null}),n.messages},I={0:"off",1:"warn",2:"error",3:"info"};function A(t={}){const{config:e,resolver:n}=t;if(void 0===n)throw new Error("must provide <options.resolver>");this.config=e,this.resolver=n,this.cachedRules={},this.cachedConfigs={}}var P=A;function S(t){return"bpmnlint"===t?"bpmnlint":t.startsWith("bpmnlint-plugin-")?t:`bpmnlint-plugin-${t}`}A.prototype.applyRule=function(t,e){const{config:n,rule:r,category:i,name:o}=e;try{return N({moddleRoot:t,rule:r,config:n}).map((function(t){return{...t,category:i}}))}catch(t){return console.error("rule <"+o+"> failed with error: ",t),[{message:"Rule error: "+t.message,category:"error"}]}},A.prototype.resolveRule=function(t,e){const{pkg:n,ruleName:r}=this.parseRuleName(t),i=`${n}-${r}`,o=this.cachedRules[i];return o?Promise.resolve(o):Promise.resolve(this.resolver.resolveRule(n,r)).then((n=>{if(!n)throw new Error(`unknown rule <${t}>`);return this.cachedRules[i]=n(e)}))},A.prototype.resolveConfig=function(t){const{pkg:e,configName:n}=this.parseConfigName(t),r=`${e}-${n}`,i=this.cachedConfigs[r];return i?Promise.resolve(i):Promise.resolve(this.resolver.resolveConfig(e,n)).then((n=>{if(!n)throw new Error(`unknown config <${t}>`);return this.cachedConfigs[r]=this.normalizeConfig(n,e)}))},A.prototype.resolveRules=function(t){return this.resolveConfiguredRules(t).then((t=>{const e=Object.entries(t).map((([t,e])=>{const{category:n,config:r}=this.parseRuleValue(e);return{name:t,category:n,config:r}})),n=e.filter((t=>"off"!==t.category)).map((t=>{const{name:e,config:n}=t;return this.resolveRule(e,n).then((function(e){return{...t,rule:e}}))}));return Promise.all(n)}))},A.prototype.resolveConfiguredRules=function(t){let e=t.extends;return"string"==typeof e&&(e=[e]),void 0===e&&(e=[]),Promise.all(e.map((t=>this.resolveConfig(t).then((t=>this.resolveConfiguredRules(t)))))).then((e=>[...e,this.normalizeConfig(t,"bpmnlint").rules].reduce(((t,e)=>({...t,...e})),{})))},A.prototype.lint=function(t,e){return e=e||this.config,this.resolveRules(e).then((e=>{const n={};return e.forEach((e=>{const{name:r}=e,i=this.applyRule(t,e);i.length&&(n[r]=i)})),n}))},A.prototype.parseRuleValue=function(t){let e,n;return Array.isArray(t)?(e=t[0],n=t[1]):(e=t,n={}),"string"==typeof e&&(e=e.toLowerCase()),e=I[e]||e,{config:n,category:e}},A.prototype.parseRuleName=function(t,e="bpmnlint"){const n=/^(?:(?:(@[^/]+)\/)?([^@]{1}[^/]*)\/)?([^/]+)$/.exec(t);if(!n)throw new Error(`unparseable rule name <${t}>`);const[r,i,o,s]=n;if(!o)return{pkg:e,ruleName:s};return{pkg:`${i?i+"/":""}${S(o)}`,ruleName:s}},A.prototype.parseConfigName=function(t){const e=/^(?:(?:plugin:(?:(@[^/]+)\/)?([^@]{1}[^/]*)\/)|bpmnlint:)([^/]+)$/.exec(t);if(!e)throw new Error(`unparseable config name <${t}>`);const[n,r,i,o]=e;if(!i)return{pkg:"bpmnlint",configName:o};return{pkg:`${r?r+"/":""}${S(i)}`,configName:o}},A.prototype.getSimplePackageName=function(t){const e=/^(?:(@[^/]+)\/)?([^/]+)$/.exec(t);if(!e)throw new Error(`unparseable package name <${t}>`);const[n,r,i]=e;return`${r?r+"/":""}${function(t){if(t.startsWith("bpmnlint-plugin-"))return t.substring("bpmnlint-plugin-".length);return t}(i)}`},A.prototype.normalizeConfig=function(t,e){const n=t.rules||{},r=Object.keys(n).reduce(((t,r)=>{const i=n[r],{pkg:o,ruleName:s}=this.parseRuleName(r,e);return t["bpmnlint"===o?s:`${this.getSimplePackageName(o)}/${s}`]=i,t}),{});return{...t,rules:r}};var T,M,z,D={Linter:P},F={};function W(){T=window.addEventListener?"addEventListener":"attachEvent",M=window.removeEventListener?"removeEventListener":"detachEvent",z="addEventListener"!==T?"on":""}F.bind=function(t,e,n,r){return T||W(),t[T](z+e,n,r||!1),n},F.unbind=function(t,e,n,r){return M||W(),t[M](z+e,n,r||!1),n};var H,G=function(t,e){if("string"!=typeof t)throw new TypeError("String expected");e||(e=document);var n=/<([\w:]+)/.exec(t);if(!n)return e.createTextNode(t);t=t.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){return(i=e.createElement("html")).innerHTML=t,i.removeChild(i.lastChild)}var i,o=Object.prototype.hasOwnProperty.call(V,r)?V[r]:V._default,s=o[0],c=o[1],u=o[2];(i=e.createElement("div")).innerHTML=c+t+u;for(;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);var l=e.createDocumentFragment();for(;i.firstChild;)l.appendChild(i.removeChild(i.firstChild));return l},q=!1;"undefined"!=typeof document&&((H=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',q=!H.getElementsByTagName("link").length,H=void 0);var V={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:q?[1,"X<div>","</div>"]:[0,"",""]};V.td=V.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],V.option=V.optgroup=[1,'<select multiple="multiple">',"</select>"],V.thead=V.tbody=V.colgroup=V.caption=V.tfoot=[1,"<table>","</table>"],V.polyline=V.ellipse=V.polygon=V.circle=V.text=V.line=V.path=V.rect=V.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var J=G,K={"&":"&","<":"<",">":">",'"':""","'":"'"};function U(t){return(t=""+t)&&t.replace(/[&<>"']/g,(function(t){return K[t]}))}function X(t,e){var n=function(t){return t&&t.businessObject||t}(t);return n&&"function"==typeof n.$instanceOf&&n.$instanceOf(e)}var Q='<svg width="12" height="12" version="1.1" viewBox="0 0 352 512" xmlns="http://www.w3.org/2000/svg">\n <path d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z" fill="currentColor"/>\n</svg>\n',Y='<svg width="12" height="12" version="1.1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">\n <path d="m256 323.95c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zm-80.561-271.8 11.61 204.35c.544 9.334 8.78 16.64 18.755 16.64h100.39c9.975 0 18.211-7.306 18.754-16.64l11.611-204.35c.587-10.082-7.98-18.56-18.754-18.56h-123.62c-10.775 0-19.34 8.478-18.753 18.56z" fill="currentColor"/>\n</svg>\n',Z='<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"></path></svg>',tt=500,et={resolver:{resolveRule:function(){return null}},config:{}},nt={error:Q,warning:Y,success:Z,inactive:Z};function rt(t,e,n,r,i,o,s){this._bpmnjs=t,this._canvas=e,this._elementRegistry=r,this._eventBus=i,this._overlays=o,this._translate=s,this._issues={},this._active=n&&n.active||!1,this._linterConfig=et,this._overlayIds={};var c=this;i.on(["import.done","elements.changed","linting.configChanged","linting.toggle"],tt,(function(t){c.isActive()&&c.update()})),i.on("linting.toggle",(function(t){t.active||(c._clearIssues(),c._updateButton())})),i.on("diagram.clear",(function(){c._clearIssues()}));var u=n&&n.bpmnlint;u&&i.once("diagram.init",(function(){if(c.getLinterConfig()===et)try{c.setLinterConfig(u)}catch(t){console.error("[bpmn-js-bpmnlint] Invalid lint rules configured. Please doublecheck your linting.bpmnlint configuration, cf. https://github.com/bpmn-io/bpmn-js-bpmnlint#configure-lint-rules")}})),this._init()}return rt.prototype.setLinterConfig=function(t){if(!t.config||!t.resolver)throw new Error("Expected linterConfig = { config, resolver }");this._linterConfig=t,this._eventBus.fire("linting.configChanged")},rt.prototype.getLinterConfig=function(){return this._linterConfig},rt.prototype._init=function(){this._createButton(),this._updateButton()},rt.prototype.isActive=function(){return this._active},rt.prototype._formatIssues=function(t){let e=this,n=h(t,(function(t,e,n){return t.concat(e.map((function(t){return t.rule=n,t})))}),[]);const r=e._elementRegistry.filter((t=>X(t,"bpmn:Participant"))).map((t=>t.businessObject));return n=v(n,(function(t){if(!e._elementRegistry.get(t.id)){t.isChildIssue=!0,t.actualElementId=t.id;const n=r.filter((e=>e.processRef&&e.processRef.id&&e.processRef.id===t.id));n.length?t.id=n[0].id:t.id=e._canvas.getRootElement().id}return t})),n=y(n,(function(t){return t.id})),n},rt.prototype.toggle=function(t){return t=void 0===t?!this.isActive():t,this._setActive(t),t},rt.prototype._setActive=function(t){this._active!==t&&(this._active=t,this._eventBus.fire("linting.toggle",{active:t}))},rt.prototype.update=function(){var t=this;if(this._bpmnjs.getDefinitions()){var e=this._lintStart=Math.random();this.lint().then((function(n){if(t._lintStart===e){n=t._formatIssues(n);var r={},i={},o={};for(var s in t._issues)n[s]||(r[s]=t._issues[s]);for(var c in n)t._issues[c]?n[c]!==t._issues[c]&&(i[c]=n[c]):o[c]=n[c];r=R(r,i),o=R(o,i),t._clearOverlays(),t._createIssues(o),t._issues=n,t._updateButton(),t._fireComplete(n)}}))}},rt.prototype._fireComplete=function(t){this._eventBus.fire("linting.completed",{issues:t})},rt.prototype._createIssues=function(t){for(var e in t)this._createElementIssues(e,t[e])},rt.prototype._createElementIssues=function(t,e){var n=this._elementRegistry.get(t);if(n){var r,i,o=this._elementRegistry.get(t+"_plane");o&&this._createElementIssues(o.id,e);var s=!n.parent;s&&X(n,"bpmn:Process")?(r="bottom-right",i={top:20,left:150}):s&&X(n,"bpmn:SubProcess")?(r="bottom-right",i={top:50,left:150}):(r="top-right",i={top:-7,left:-7});var c=y(e,(function(t){return(t.isChildIssue?"child":"")+t.category})),u=c.error,l=c.warn,a=c.childerror,f=c.childwarn;if(u||l||a||f){var p=J('<div class="bjsl-overlay bjsl-issues-'+r+'"></div>'),d=J(u||a?'<div class="bjsl-icon bjsl-icon-error">'+Q+"</div>":'<div class="bjsl-icon bjsl-icon-warning">'+Y+"</div>"),h=J('<div class="bjsl-dropdown"></div>'),g=J('<div class="bjsl-dropdown-content"></div>'),v=J('<div class="bjsl-issues"></div>'),m=J('<div class="bjsl-current-element-issues"></div>'),b=J("<ul></ul>");if(p.appendChild(d),p.appendChild(h),h.appendChild(g),g.appendChild(v),v.appendChild(m),m.appendChild(b),u&&this._addErrors(b,u),l&&this._addWarnings(b,l),a||f){var _=J('<div class="bjsl-child-issues"></div>'),w=J("<ul></ul>"),C=J('<a class="bjsl-issue-heading">Issues for child elements:</a>');if(a&&this._addErrors(w,a),f&&this._addWarnings(w,f),u||l){var j=J("<hr/>");_.appendChild(j)}_.appendChild(C),_.appendChild(w),v.appendChild(_)}this._overlayIds[t]=this._overlays.add(n,"linting",{position:i,html:p,scale:{min:.9}})}}},rt.prototype._addErrors=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"error",e)}))},rt.prototype._addWarnings=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"warning",e)}))},rt.prototype._addEntry=function(t,e,n){var r=n.rule,i=this._translate(n.message),o=n.actualElementId,s=J('<li class="'+e+'"><span class="icon"> '+nt[e]+'</span><a title="'+U(r)+": "+U(i)+'" data-rule="'+U(r)+'" data-message="'+U(i)+'">'+U(i)+"</a>"+(o?'<a class="bjsl-id-hint"><code>'+o+"</code></a>":"")+"</li>");t.appendChild(s)},rt.prototype._clearOverlays=function(){this._overlays.remove({type:"linting"}),this._overlayIds={}},rt.prototype._clearIssues=function(){this._issues={},this._clearOverlays()},rt.prototype._setButtonState=function(t,e,n){var r=this._button,i=nt[t]+"<span>"+this._translate("{errors} Errors, {warnings} Warnings",{errors:e.toString(),warnings:n.toString()})+"</span>";["error","inactive","success","warning"].forEach((function(e){t===e?r.classList.add("bjsl-button-"+e):r.classList.remove("bjsl-button-"+e)})),r.innerHTML=i},rt.prototype._updateButton=function(){if(this.isActive()){var t=0,e=0;for(var n in this._issues)this._issues[n].forEach((function(n){"error"===n.category?t++:"warn"===n.category&&e++}));var r=(t?"error":e&&"warning")||"success";this._setButtonState(r,t,e)}else this._setButtonState("inactive",0,0)},rt.prototype._createButton=function(){var t=this;this._button=J('<button class="bjsl-button bjsl-button-inactive" title="'+this._translate("Toggle linting")+'"></button>'),this._button.addEventListener("click",(function(){t.toggle()})),this._canvas.getContainer().appendChild(this._button)},rt.prototype.lint=function(){var t=this._bpmnjs.getDefinitions();return new D.Linter(this._linterConfig).lint(t)},rt.$inject=["bpmnjs","canvas","config.linting","elementRegistry","eventBus","overlays","translate"],{__init__:["linting","lintingEditorActions"],linting:["type",rt],lintingEditorActions:["type",t]}})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BpmnJSBpmnlint=e()}(this,(function(){"use strict";function t(t,e){var n=t.get("editorActions",!1);n&&n.register({toggleLinting:function(){e.toggle()}})}function e(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}t.$inject=["injector","linting"];const n=Object.prototype.toString,r=Object.prototype.hasOwnProperty;function i(t){return void 0===t}function o(t){return void 0!==t}function s(t){return null==t}function c(t){return"[object Array]"===n.call(t)}function l(t){return"[object Object]"===n.call(t)}function u(t){const e=n.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e||"[object Proxy]"===e}function a(t){if(!c(t))throw new Error("must supply array")}function f(t,e){return r.call(t,e)}function p(t,e){const n=C(e);let r;return d(t,(function(t,e){if(n(t,e))return r=t,!1})),r}function d(t,e){let n,r;if(i(t))return;const o=c(t)?E:j;for(let i in t)if(f(t,i)&&(n=t[i],r=e(n,o(i)),!1===r))return n}function h(t,e,n){return d(t,(function(t,r){n=e(n,t,r)})),n}function g(t,e){return!!h(t,(function(t,n,r){return t&&e(n,r)}),!0)}function v(t,e){let n=[];return d(t,(function(t,r){n.push(e(t,r))})),n}function m(t){return t&&Object.keys(t)||[]}function y(t,e,n={}){return e=w(e),d(t,(function(t){let r=e(t)||"_",i=n[r];i||(i=n[r]=[]),i.push(t)})),n}function b(t,...e){t=w(t);let n={};return d(e,(e=>y(e,t,n))),v(n,(function(t,e){return t[0]}))}const _=b;function w(t){return u(t)?t:e=>e[t]}function C(t){return u(t)?t:e=>e===t}function j(t){return t}function E(t){return Number(t)}function R(t,...e){return Object.assign(t,...e)}var $=Object.freeze({__proto__:null,assign:R,bind:function(t,e){return t.bind(e)},debounce:function(t,e){let n,r,i,o;function s(n){let s=Date.now(),u=n?0:o+e-s;if(u>0)return c(u);t.apply(i,r),l()}function c(t){n=setTimeout(s,t)}function l(){n&&clearTimeout(n),n=o=r=i=void 0}function u(...t){o=Date.now(),r=t,i=this,n||c(e)}return u.flush=function(){n&&s(!0),l()},u.cancel=l,u},ensureArray:a,every:g,filter:function(t,e){const n=C(e);let r=[];return d(t,(function(t,e){n(t,e)&&r.push(t)})),r},find:p,findIndex:function(t,e){const n=C(e);let r=c(t)?-1:void 0;return d(t,(function(t,e){if(n(t,e))return r=e,!1})),r},flatten:function(t){return Array.prototype.concat.apply([],t)},forEach:d,get:function(t,e,n){let r=t;return d(e,(function(t){if(s(r))return r=void 0,!1;r=r[t]})),i(r)?n:r},groupBy:y,has:f,isArray:c,isDefined:o,isFunction:u,isNil:s,isNumber:function(t){return"[object Number]"===n.call(t)},isObject:l,isString:function(t){return"[object String]"===n.call(t)},isUndefined:i,keys:m,map:v,matchPattern:function(t){return function(e){return g(t,(function(t,n){return e[n]===t}))}},merge:function t(e,...n){return n.length?(d(n,(function(n){n&&l(n)&&d(n,(function(n,r){if("__proto__"===r)return;let i=e[r];l(n)?(l(i)||(i={}),e[r]=t(i,n)):e[r]=n}))})),e):e},omit:function(t,e){let n={};return d(Object(t),(function(t,r){-1===e.indexOf(r)&&(n[r]=t)})),n},pick:function(t,e){let n={},r=Object(t);return d(e,(function(e){e in r&&(n[e]=t[e])})),n},reduce:h,set:function(t,e,n){let r=t;return d(e,(function(t,c){if("number"!=typeof t&&"string"!=typeof t)throw new Error("illegal key type: "+typeof t+". Key should be of type number or string.");if("constructor"===t)throw new Error("illegal key: constructor");if("__proto__"===t)throw new Error("illegal key: __proto__");let l=e[c+1],u=r[t];o(l)&&s(u)&&(u=r[t]=isNaN(+l)?{}:[]),i(l)?i(n)?delete r[t]:r[t]=n:r=u})),t},size:function(t){return m(t).length},some:function(t,e){return!!p(t,e)},sortBy:function(t,e){e=w(e);let n=[];return d(t,(function(t,r){let i=e(t,r),o={d:i,v:t};for(var s=0;s<n.length;s++){let{d:t}=n[s];if(i<t)return void n.splice(s,0,o)}n.push(o)})),v(n,(t=>t.v))},throttle:function(t,e){let n=!1;return function(...r){n||(t(...r),n=!0,setTimeout((()=>{n=!1}),e))}},unionBy:_,uniqueBy:b,values:function(t){return v(t,(t=>t))},without:function(t,e){if(i(t))return[];a(t);const n=C(e);return t.filter((function(t,e){return!n(t,e)}))}}),x=e($);const O=function t(e,n){const r=n.enter||null,i=n.leave||null,o=r&&r(e),s=e.$descriptor;if(!1!==o&&!s.isGeneric){s.properties.filter((t=>!t.isAttr&&!t.isReference&&"String"!==t.type)).forEach((r=>{if(r.name in e){const i=e[r.name];r.isMany?i.forEach((e=>{t(e,n)})):t(i,n)}}))}i&&i(e)},{isArray:k,isObject:B}=x;class I{constructor({moddleRoot:t,rule:e}){this.rule=e,this.moddleRoot=t,this.messages=[],this.report=this.report.bind(this)}report(t,e,n){let r={id:t,message:e};n&&k(n)&&(r={...r,path:n}),n&&B(n)&&(r={...r,...n}),this.messages.push(r)}}const N=function({moddleRoot:t,rule:e}){const n=new I({rule:e,moddleRoot:t}),r=e.check,i=r&&r.enter||r,o=r&&r.leave;if(!i&&!o)throw new Error("no check implemented");return O(t,{enter:i?t=>i(t,n):null,leave:o?t=>o(t,n):null}),n.messages},A={0:"off",1:"warn",2:"error",3:"info"};function L(t={}){const{config:e,resolver:n}=t;if(void 0===n)throw new Error("must provide <options.resolver>");this.config=e,this.resolver=n,this.cachedRules={},this.cachedConfigs={}}var P=L;function S(t){return"bpmnlint"===t?"bpmnlint":t.startsWith("bpmnlint-plugin-")?t:`bpmnlint-plugin-${t}`}L.prototype.applyRule=function(t,e){const{config:n,rule:r,category:i,name:o}=e;try{return N({moddleRoot:t,rule:r,config:n}).map((function(t){return{...t,category:i}}))}catch(t){return console.error("rule <"+o+"> failed with error: ",t),[{message:t.message,category:"rule-error"}]}},L.prototype.resolveRule=function(t,e){const{pkg:n,ruleName:r}=this.parseRuleName(t),i=`${n}-${r}`,o=this.cachedRules[i];return o?Promise.resolve(o):Promise.resolve(this.resolver.resolveRule(n,r)).then((n=>{if(!n)throw new Error(`unknown rule <${t}>`);return this.cachedRules[i]=n(e)}))},L.prototype.resolveConfig=function(t){const{pkg:e,configName:n}=this.parseConfigName(t),r=`${e}-${n}`,i=this.cachedConfigs[r];return i?Promise.resolve(i):Promise.resolve(this.resolver.resolveConfig(e,n)).then((n=>{if(!n)throw new Error(`unknown config <${t}>`);return this.cachedConfigs[r]=this.normalizeConfig(n,e)}))},L.prototype.resolveRules=function(t){return this.resolveConfiguredRules(t).then((t=>{const e=Object.entries(t).map((([t,e])=>{const{category:n,config:r}=this.parseRuleValue(e);return{name:t,category:n,config:r}})),n=e.filter((t=>"off"!==t.category)).map((t=>{const{name:e,config:n}=t;return this.resolveRule(e,n).then((function(e){return{...t,rule:e}}))}));return Promise.all(n)}))},L.prototype.resolveConfiguredRules=function(t){let e=t.extends;return"string"==typeof e&&(e=[e]),void 0===e&&(e=[]),Promise.all(e.map((t=>this.resolveConfig(t).then((t=>this.resolveConfiguredRules(t)))))).then((e=>[...e,this.normalizeConfig(t,"bpmnlint").rules].reduce(((t,e)=>({...t,...e})),{})))},L.prototype.lint=function(t,e){return e=e||this.config,this.resolveRules(e).then((e=>{const n={};return e.forEach((e=>{const{name:r}=e,i=this.applyRule(t,e);i.length&&(n[r]=i)})),n}))},L.prototype.parseRuleValue=function(t){let e,n;return Array.isArray(t)?(e=t[0],n=t[1]):(e=t,n={}),"string"==typeof e&&(e=e.toLowerCase()),e=A[e]||e,{config:n,category:e}},L.prototype.parseRuleName=function(t,e="bpmnlint"){const n=/^(?:(?:(@[^/]+)\/)?([^@]{1}[^/]*)\/)?([^/]+)$/.exec(t);if(!n)throw new Error(`unparseable rule name <${t}>`);const[r,i,o,s]=n;if(!o)return{pkg:e,ruleName:s};return{pkg:`${i?i+"/":""}${S(o)}`,ruleName:s}},L.prototype.parseConfigName=function(t){const e=/^(?:(?:plugin:(?:(@[^/]+)\/)?([^@]{1}[^/]*)\/)|bpmnlint:)([^/]+)$/.exec(t);if(!e)throw new Error(`unparseable config name <${t}>`);const[n,r,i,o]=e;if(!i)return{pkg:"bpmnlint",configName:o};return{pkg:`${r?r+"/":""}${S(i)}`,configName:o}},L.prototype.getSimplePackageName=function(t){const e=/^(?:(@[^/]+)\/)?([^/]+)$/.exec(t);if(!e)throw new Error(`unparseable package name <${t}>`);const[n,r,i]=e;return`${r?r+"/":""}${function(t){if(t.startsWith("bpmnlint-plugin-"))return t.substring(16);return t}(i)}`},L.prototype.normalizeConfig=function(t,e){const n=t.rules||{},r=Object.keys(n).reduce(((t,r)=>{const i=n[r],{pkg:o,ruleName:s}=this.parseRuleName(r,e);return t["bpmnlint"===o?s:`${this.getSimplePackageName(o)}/${s}`]=i,t}),{});return{...t,rules:r}};var T,M={Linter:P},z=function(t,e){if("string"!=typeof t)throw new TypeError("String expected");e||(e=document);var n=/<([\w:]+)/.exec(t);if(!n)return e.createTextNode(t);t=t.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){return(i=e.createElement("html")).innerHTML=t,i.removeChild(i.lastChild)}var i,o=Object.prototype.hasOwnProperty.call(D,r)?D[r]:D._default,s=o[0],c=o[1],l=o[2];(i=e.createElement("div")).innerHTML=c+t+l;for(;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);var u=e.createDocumentFragment();for(;i.firstChild;)u.appendChild(i.removeChild(i.firstChild));return u},F=!1;"undefined"!=typeof document&&((T=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',F=!T.getElementsByTagName("link").length,T=void 0);var D={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:F?[1,"X<div>","</div>"]:[0,"",""]};D.td=D.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],D.option=D.optgroup=[1,'<select multiple="multiple">',"</select>"],D.thead=D.tbody=D.colgroup=D.caption=D.tfoot=[1,"<table>","</table>"],D.polyline=D.ellipse=D.polygon=D.circle=D.text=D.line=D.path=D.rect=D.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var W=z,H={"&":"&","<":"<",">":">",'"':""","'":"'"};function G(t){return(t=""+t)&&t.replace(/[&<>"']/g,(function(t){return H[t]}))}function U(t,e){var n=function(t){return t&&t.businessObject||t}(t);return n&&"function"==typeof n.$instanceOf&&n.$instanceOf(e)}var q='<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<svg\n version="1.1"\n viewBox="0 0 512 512"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg">\n <path\n d="M 339.07183,256.00001 463.66713,131.4047 c 15.28961,-15.2896 15.28961,-40.079175 0,-55.381227 l -27.6906,-27.690611 c -15.28961,-15.289602 -40.07917,-15.289602 -55.38123,0 L 256,172.92818 131.4047,48.332862 c -15.2896,-15.289602 -40.079177,-15.289602 -55.381228,0 L 48.332861,76.023473 c -15.2896,15.2896 -15.2896,40.079177 0,55.381227 L 172.92815,256.00001 48.332861,380.59531 c -15.2896,15.2896 -15.2896,40.07917 0,55.38123 l 27.690611,27.69061 c 15.289601,15.28959 40.091628,15.28959 55.381228,0 L 256,339.07184 380.5953,463.66715 c 15.2896,15.28959 40.09162,15.28959 55.38123,0 l 27.6906,-27.69061 c 15.28961,-15.2896 15.28961,-40.07918 0,-55.38123 z"\n fill="currentColor" />\n</svg>\n',V='<svg version="1.1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">\n <path d="m256 323.95c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zm-80.561-271.8 11.61 204.35c.544 9.334 8.78 16.64 18.755 16.64h100.39c9.975 0 18.211-7.306 18.754-16.64l11.611-204.35c.587-10.082-7.98-18.56-18.754-18.56h-123.62c-10.775 0-19.34 8.478-18.753 18.56z" fill="currentColor"/>\n</svg>\n',Z='<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<svg\n viewBox="0 0 512 512"\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg">\n <path\n fill="currentColor"\n d="m 173.898,439.40356 -166.4,-166.4 c -9.997,-9.997 -9.997,-26.206 0,-36.204 l 36.203,-36.204 c 9.997,-9.998 26.207,-9.998 36.204,0 L 192,312.68956 432.095,72.595562 c 9.997,-9.997 26.207,-9.997 36.204,0 l 36.203,36.203998 c 9.997,9.997 9.997,26.206 0,36.204 l -294.4,294.401 c -9.998,9.997 -26.207,9.997 -36.204,-10e-4 z" />\n</svg>\n',J='<svg\n viewBox="3.5 3.5 9 9"\n version="1.1"\n xmlns="http://www.w3.org/2000/svg">\n <path\n fill="currentColor" d="M6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path>\n</svg>',K={resolver:{resolveRule:function(){return null}},config:{}},X={error:q,warning:V,success:Z,info:J,inactive:Z};function Q(t,e,n,r,i,o,s){this._bpmnjs=t,this._canvas=e,this._elementRegistry=r,this._eventBus=i,this._overlays=o,this._translate=s,this._issues={},this._active=n&&n.active||!1,this._linterConfig=K,this._overlayIds={};var c=this;i.on(["import.done","elements.changed","linting.configChanged","linting.toggle"],500,(function(t){c.update()})),i.on("linting.toggle",(function(t){t.active||(c._clearIssues(),c._updateButton())})),i.on("diagram.clear",(function(){c._clearIssues()}));var l=n&&n.bpmnlint;l&&i.once("diagram.init",(function(){if(c.getLinterConfig()===K)try{c.setLinterConfig(l)}catch(t){console.error("[bpmn-js-bpmnlint] Invalid lint rules configured. Please doublecheck your linting.bpmnlint configuration, cf. https://github.com/bpmn-io/bpmn-js-bpmnlint#configure-lint-rules")}})),this._init()}return Q.prototype.setLinterConfig=function(t){if(!t.config||!t.resolver)throw new Error("Expected linterConfig = { config, resolver }");this._linterConfig=t,this._eventBus.fire("linting.configChanged")},Q.prototype.getLinterConfig=function(){return this._linterConfig},Q.prototype._init=function(){this._createButton(),this._updateButton()},Q.prototype.isActive=function(){return this._active},Q.prototype._formatIssues=function(t){let e=this,n=h(t,(function(t,e,n){return t.concat(e.map((function(t){return t.rule=n,t})))}),[]);const r=e._elementRegistry.filter((t=>U(t,"bpmn:Participant"))).map((t=>t.businessObject));return n=v(n,(function(t){if(!e._elementRegistry.get(t.id)){t.isChildIssue=!0,t.actualElementId=t.id;const n=r.filter((e=>e.processRef&&e.processRef.id&&e.processRef.id===t.id));n.length?t.id=n[0].id:t.id=e._canvas.getRootElement().id}return t})),n=y(n,(function(t){return t.id})),n},Q.prototype.toggle=function(t){return t=void 0===t?!this.isActive():t,this._setActive(t),t},Q.prototype._setActive=function(t){this._active!==t&&(this._active=t,this._eventBus.fire("linting.toggle",{active:t}))},Q.prototype.update=function(){var t=this;if(this._bpmnjs.getDefinitions()){var e=this._lintStart=Math.random();this.lint().then((function(n){if(t._lintStart===e){n=t._formatIssues(n);var r={},i={},o={};for(var s in t._issues)n[s]||(r[s]=t._issues[s]);for(var c in n)t._issues[c]?n[c]!==t._issues[c]&&(i[c]=n[c]):o[c]=n[c];r=R(r,i),o=R(o,i),t._clearOverlays(),t.isActive()&&t._createIssues(o),t._issues=n,t._updateButton(),t._fireComplete(n)}}))}},Q.prototype._fireComplete=function(t){this._eventBus.fire("linting.completed",{issues:t})},Q.prototype._createIssues=function(t){for(var e in t)this._createElementIssues(e,t[e])},Q.prototype._createElementIssues=function(t,e){var n=this._elementRegistry.get(t);if(n){var r,i,o=this._elementRegistry.get(t+"_plane");o&&this._createElementIssues(o.id,e);var s=!n.parent;s&&U(n,"bpmn:Process")?(r="bottom-right",i={top:20,left:150}):s&&U(n,"bpmn:SubProcess")?(r="bottom-right",i={top:50,left:150}):(r="top-right",i={top:-7,left:-7});var c=y(e,(function(t){return(t.isChildIssue?"child":"")+t.category})),l=c.error,u=c.warn,a=c.info,f=c.childerror,p=c.childwarn,d=c.childinfo;if(a||l||u||f||p||d){var h=W('<div class="bjsl-overlay bjsl-issues-'+r+'"></div>'),g=W(l||f?'<div class="bjsl-icon bjsl-icon-error">'+q+"</div>":u||p?'<div class="bjsl-icon bjsl-icon-warning">'+V+"</div>":'<div class="bjsl-icon bjsl-icon-info">'+J+"</div>"),v=W('<div class="bjsl-dropdown"></div>'),m=W('<div class="bjsl-dropdown-content"></div>'),b=W('<div class="bjsl-issues"></div>'),_=W('<div class="bjsl-current-element-issues"></div>'),w=W("<ul></ul>");if(h.appendChild(g),h.appendChild(v),v.appendChild(m),m.appendChild(b),b.appendChild(_),_.appendChild(w),l&&this._addErrors(w,l),u&&this._addWarnings(w,u),a&&this._addInfos(w,a),f||p||d){var C=W('<div class="bjsl-child-issues"></div>'),j=W("<ul></ul>"),E=W('<a class="bjsl-issue-heading">Issues for child elements:</a>');if(f&&this._addErrors(j,f),p&&this._addWarnings(j,p),d&&this._addInfos(j,d),l||u){var R=W("<hr/>");C.appendChild(R)}C.appendChild(E),C.appendChild(j),b.appendChild(C)}this._overlayIds[t]=this._overlays.add(n,"linting",{position:i,html:h,scale:{min:.7}})}}},Q.prototype._addErrors=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"error",e)}))},Q.prototype._addWarnings=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"warning",e)}))},Q.prototype._addInfos=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"info",e)}))},Q.prototype._addEntry=function(t,e,n){var r=n.rule,i=this._translate(n.message),o=n.actualElementId,s=W('<li class="'+e+'"><span class="icon"> '+X[e]+'</span><a title="'+G(r)+": "+G(i)+'" data-rule="'+G(r)+'" data-message="'+G(i)+'">'+G(i)+"</a>"+(o?'<a class="bjsl-id-hint"><code>'+o+"</code></a>":"")+"</li>");t.appendChild(s)},Q.prototype._clearOverlays=function(){this._overlays.remove({type:"linting"}),this._overlayIds={}},Q.prototype._clearIssues=function(){this._issues={},this._clearOverlays()},Q.prototype._setButtonState=function(t){var{errors:e,warnings:n,infos:r}=t,i=this._button,o=(e?"error":n&&"warning")||"success",s=`\n <span class="icon">${X[o]}</span>\n <span>${this._translate(e||n?"{errors} Errors, {warnings} Warnings":"No Issues",{errors:String(e),warnings:String(n),infos:String(r)})}</span>`;o=this.isActive()?o:"inactive",["error","inactive","success","warning"].forEach((function(t){o===t?i.classList.add("bjsl-button-"+t):i.classList.remove("bjsl-button-"+t)})),i.innerHTML=s},Q.prototype._updateButton=function(){var t=0,e=0,n=0;for(var r in this._issues)this._issues[r].forEach((function(r){"error"===r.category?t++:"warn"===r.category?e++:"info"===r.category&&n++}));this._setButtonState({errors:t,warnings:e,infos:n})},Q.prototype._createButton=function(){var t=this;this._button=W('<button class="bjsl-button bjsl-button-inactive" title="'+this._translate("Toggle linting overlays")+'"></button>'),this._button.addEventListener("click",(function(){t.toggle()})),this._canvas.getContainer().appendChild(this._button)},Q.prototype.lint=function(){var t=this._bpmnjs.getDefinitions();return new M.Linter(this._linterConfig).lint(t)},Q.$inject=["bpmnjs","canvas","config.linting","elementRegistry","eventBus","overlays","translate"],{__init__:["linting","lintingEditorActions"],linting:["type",Q],lintingEditorActions:["type",t]}})); |
@@ -22,8 +22,10 @@ import { Linter } from 'bpmnlint'; | ||
var ErrorSvg = "<svg width=\"12\" height=\"12\" version=\"1.1\" viewBox=\"0 0 352 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var ErrorSvg = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n version=\"1.1\"\n viewBox=\"0 0 512 512\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M 339.07183,256.00001 463.66713,131.4047 c 15.28961,-15.2896 15.28961,-40.079175 0,-55.381227 l -27.6906,-27.690611 c -15.28961,-15.289602 -40.07917,-15.289602 -55.38123,0 L 256,172.92818 131.4047,48.332862 c -15.2896,-15.289602 -40.079177,-15.289602 -55.381228,0 L 48.332861,76.023473 c -15.2896,15.2896 -15.2896,40.079177 0,55.381227 L 172.92815,256.00001 48.332861,380.59531 c -15.2896,15.2896 -15.2896,40.07917 0,55.38123 l 27.690611,27.69061 c 15.289601,15.28959 40.091628,15.28959 55.381228,0 L 256,339.07184 380.5953,463.66715 c 15.2896,15.28959 40.09162,15.28959 55.38123,0 l 27.6906,-27.69061 c 15.28961,-15.2896 15.28961,-40.07918 0,-55.38123 z\"\n fill=\"currentColor\" />\n</svg>\n"; | ||
var WarningSvg = "<svg width=\"12\" height=\"12\" version=\"1.1\" viewBox=\"0 0 512 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m256 323.95c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zm-80.561-271.8 11.61 204.35c.544 9.334 8.78 16.64 18.755 16.64h100.39c9.975 0 18.211-7.306 18.754-16.64l11.611-204.35c.587-10.082-7.98-18.56-18.754-18.56h-123.62c-10.775 0-19.34 8.478-18.753 18.56z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var WarningSvg = "<svg version=\"1.1\" viewBox=\"0 0 512 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m256 323.95c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zm-80.561-271.8 11.61 204.35c.544 9.334 8.78 16.64 18.755 16.64h100.39c9.975 0 18.211-7.306 18.754-16.64l11.611-204.35c.587-10.082-7.98-18.56-18.754-18.56h-123.62c-10.775 0-19.34 8.478-18.753 18.56z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var SuccessSvg = "<svg width=\"12\" height=\"12\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path fill=\"currentColor\" d=\"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z\"></path></svg>"; | ||
var SuccessSvg = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n viewBox=\"0 0 512 512\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\"\n d=\"m 173.898,439.40356 -166.4,-166.4 c -9.997,-9.997 -9.997,-26.206 0,-36.204 l 36.203,-36.204 c 9.997,-9.998 26.207,-9.998 36.204,0 L 192,312.68956 432.095,72.595562 c 9.997,-9.997 26.207,-9.997 36.204,0 l 36.203,36.203998 c 9.997,9.997 9.997,26.206 0,36.204 l -294.4,294.401 c -9.998,9.997 -26.207,9.997 -36.204,-10e-4 z\" />\n</svg>\n"; | ||
var InfoSvg = "<svg\n viewBox=\"3.5 3.5 9 9\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\" d=\"M6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z\"></path>\n</svg>"; | ||
var OFFSET_TOP = -7, | ||
@@ -47,2 +49,3 @@ OFFSET_RIGHT = -7; | ||
success: SuccessSvg, | ||
info: InfoSvg, | ||
inactive: SuccessSvg | ||
@@ -82,5 +85,3 @@ }; | ||
], LOW_PRIORITY, function(e) { | ||
if (self.isActive()) { | ||
self.update(); | ||
} | ||
self.update(); | ||
}); | ||
@@ -277,4 +278,7 @@ | ||
self._clearOverlays(); | ||
self._createIssues(add); | ||
if (self.isActive()) { | ||
self._createIssues(add); | ||
} | ||
self._issues = newIssues; | ||
@@ -350,6 +354,15 @@ | ||
warnings = issuesByType.warn, | ||
infos = issuesByType.info, | ||
childErrors = issuesByType.childerror, | ||
childWarnings = issuesByType.childwarn; | ||
childWarnings = issuesByType.childwarn, | ||
childInfos = issuesByType.childinfo; | ||
if (!errors && !warnings && !childErrors && !childWarnings) { | ||
if ( | ||
!infos && | ||
!errors && | ||
!warnings && | ||
!childErrors && | ||
!childWarnings && | ||
!childInfos | ||
) { | ||
return; | ||
@@ -364,3 +377,5 @@ } | ||
? domify('<div class="bjsl-icon bjsl-icon-error">' + ErrorSvg + '</div>') | ||
: domify('<div class="bjsl-icon bjsl-icon-warning">' + WarningSvg + '</div>'); | ||
: (warnings || childWarnings) | ||
? domify('<div class="bjsl-icon bjsl-icon-warning">' + WarningSvg + '</div>') | ||
: domify('<div class="bjsl-icon bjsl-icon-info">' + InfoSvg + '</div>'); | ||
@@ -394,5 +409,9 @@ var $dropdown = domify('<div class="bjsl-dropdown"></div>'); | ||
if (infos) { | ||
this._addInfos($issueList, infos); | ||
} | ||
// If errors or warnings for child elements of the current element are to be displayed, | ||
// then add an additional list | ||
if (childErrors || childWarnings) { | ||
if (childErrors || childWarnings || childInfos) { | ||
var $childIssues = domify('<div class="bjsl-child-issues"></div>'); | ||
@@ -410,2 +429,6 @@ var $childIssueList = domify('<ul></ul>'); | ||
if (childInfos) { | ||
this._addInfos($childIssueList, childInfos); | ||
} | ||
if (errors || warnings) { | ||
@@ -425,3 +448,3 @@ var $childIssuesSeperator = domify('<hr/>'); | ||
scale: { | ||
min: .9 | ||
min: .7 | ||
} | ||
@@ -449,2 +472,11 @@ }); | ||
Linting.prototype._addInfos = function($ul, infos) { | ||
var self = this; | ||
infos.forEach(function(error) { | ||
self._addEntry($ul, 'info', error); | ||
}); | ||
}; | ||
Linting.prototype._addEntry = function($ul, state, entry) { | ||
@@ -488,9 +520,31 @@ | ||
Linting.prototype._setButtonState = function(state, errors, warnings) { | ||
Linting.prototype._setButtonState = function(issues) { | ||
var { | ||
errors, | ||
warnings, | ||
infos | ||
} = issues; | ||
var button = this._button; | ||
var state = (errors && 'error') || (warnings && 'warning') || 'success'; | ||
var icon = stateToIcon[state]; | ||
var label = this._translate( | ||
(errors || warnings) | ||
? '{errors} Errors, {warnings} Warnings' | ||
: 'No Issues', | ||
{ | ||
errors: String(errors), | ||
warnings: String(warnings), | ||
infos: String(infos), | ||
} | ||
); | ||
var html = icon + '<span>' + this._translate('{errors} Errors, {warnings} Warnings', { errors: errors.toString(), warnings: warnings.toString() }) + '</span>'; | ||
var html = ` | ||
<span class="icon">${icon}</span> | ||
<span>${ label }</span>`; | ||
state = this.isActive() ? state : 'inactive'; | ||
[ | ||
@@ -514,10 +568,5 @@ 'error', | ||
if (!this.isActive()) { | ||
this._setButtonState('inactive', 0, 0); | ||
return; | ||
} | ||
var errors = 0, | ||
warnings = 0; | ||
warnings = 0, | ||
infos = 0; | ||
@@ -530,2 +579,4 @@ for (var id in this._issues) { | ||
warnings++; | ||
} else if (issue.category === 'info') { | ||
infos++; | ||
} | ||
@@ -535,5 +586,7 @@ }); | ||
var state = (errors && 'error') || (warnings && 'warning') || 'success'; | ||
this._setButtonState(state, errors, warnings); | ||
this._setButtonState({ | ||
errors, | ||
warnings, | ||
infos | ||
}); | ||
}; | ||
@@ -546,3 +599,3 @@ | ||
this._button = domify( | ||
'<button class="bjsl-button bjsl-button-inactive" title="' + this._translate('Toggle linting') + '"></button>' | ||
'<button class="bjsl-button bjsl-button-inactive" title="' + this._translate('Toggle linting overlays') + '"></button>' | ||
); | ||
@@ -549,0 +602,0 @@ |
@@ -24,8 +24,10 @@ 'use strict'; | ||
var ErrorSvg = "<svg width=\"12\" height=\"12\" version=\"1.1\" viewBox=\"0 0 352 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var ErrorSvg = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n version=\"1.1\"\n viewBox=\"0 0 512 512\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M 339.07183,256.00001 463.66713,131.4047 c 15.28961,-15.2896 15.28961,-40.079175 0,-55.381227 l -27.6906,-27.690611 c -15.28961,-15.289602 -40.07917,-15.289602 -55.38123,0 L 256,172.92818 131.4047,48.332862 c -15.2896,-15.289602 -40.079177,-15.289602 -55.381228,0 L 48.332861,76.023473 c -15.2896,15.2896 -15.2896,40.079177 0,55.381227 L 172.92815,256.00001 48.332861,380.59531 c -15.2896,15.2896 -15.2896,40.07917 0,55.38123 l 27.690611,27.69061 c 15.289601,15.28959 40.091628,15.28959 55.381228,0 L 256,339.07184 380.5953,463.66715 c 15.2896,15.28959 40.09162,15.28959 55.38123,0 l 27.6906,-27.69061 c 15.28961,-15.2896 15.28961,-40.07918 0,-55.38123 z\"\n fill=\"currentColor\" />\n</svg>\n"; | ||
var WarningSvg = "<svg width=\"12\" height=\"12\" version=\"1.1\" viewBox=\"0 0 512 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m256 323.95c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zm-80.561-271.8 11.61 204.35c.544 9.334 8.78 16.64 18.755 16.64h100.39c9.975 0 18.211-7.306 18.754-16.64l11.611-204.35c.587-10.082-7.98-18.56-18.754-18.56h-123.62c-10.775 0-19.34 8.478-18.753 18.56z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var WarningSvg = "<svg version=\"1.1\" viewBox=\"0 0 512 512\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m256 323.95c-45.518 0-82.419 34.576-82.419 77.229 0 42.652 36.9 77.229 82.419 77.229 45.518 0 82.419-34.577 82.419-77.23 0-42.652-36.9-77.229-82.419-77.229zm-80.561-271.8 11.61 204.35c.544 9.334 8.78 16.64 18.755 16.64h100.39c9.975 0 18.211-7.306 18.754-16.64l11.611-204.35c.587-10.082-7.98-18.56-18.754-18.56h-123.62c-10.775 0-19.34 8.478-18.753 18.56z\" fill=\"currentColor\"/>\n</svg>\n"; | ||
var SuccessSvg = "<svg width=\"12\" height=\"12\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path fill=\"currentColor\" d=\"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z\"></path></svg>"; | ||
var SuccessSvg = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n viewBox=\"0 0 512 512\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\"\n d=\"m 173.898,439.40356 -166.4,-166.4 c -9.997,-9.997 -9.997,-26.206 0,-36.204 l 36.203,-36.204 c 9.997,-9.998 26.207,-9.998 36.204,0 L 192,312.68956 432.095,72.595562 c 9.997,-9.997 26.207,-9.997 36.204,0 l 36.203,36.203998 c 9.997,9.997 9.997,26.206 0,36.204 l -294.4,294.401 c -9.998,9.997 -26.207,9.997 -36.204,-10e-4 z\" />\n</svg>\n"; | ||
var InfoSvg = "<svg\n viewBox=\"3.5 3.5 9 9\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\" d=\"M6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z\"></path>\n</svg>"; | ||
var OFFSET_TOP = -7, | ||
@@ -49,2 +51,3 @@ OFFSET_RIGHT = -7; | ||
success: SuccessSvg, | ||
info: InfoSvg, | ||
inactive: SuccessSvg | ||
@@ -84,5 +87,3 @@ }; | ||
], LOW_PRIORITY, function(e) { | ||
if (self.isActive()) { | ||
self.update(); | ||
} | ||
self.update(); | ||
}); | ||
@@ -279,4 +280,7 @@ | ||
self._clearOverlays(); | ||
self._createIssues(add); | ||
if (self.isActive()) { | ||
self._createIssues(add); | ||
} | ||
self._issues = newIssues; | ||
@@ -352,6 +356,15 @@ | ||
warnings = issuesByType.warn, | ||
infos = issuesByType.info, | ||
childErrors = issuesByType.childerror, | ||
childWarnings = issuesByType.childwarn; | ||
childWarnings = issuesByType.childwarn, | ||
childInfos = issuesByType.childinfo; | ||
if (!errors && !warnings && !childErrors && !childWarnings) { | ||
if ( | ||
!infos && | ||
!errors && | ||
!warnings && | ||
!childErrors && | ||
!childWarnings && | ||
!childInfos | ||
) { | ||
return; | ||
@@ -366,3 +379,5 @@ } | ||
? minDom.domify('<div class="bjsl-icon bjsl-icon-error">' + ErrorSvg + '</div>') | ||
: minDom.domify('<div class="bjsl-icon bjsl-icon-warning">' + WarningSvg + '</div>'); | ||
: (warnings || childWarnings) | ||
? minDom.domify('<div class="bjsl-icon bjsl-icon-warning">' + WarningSvg + '</div>') | ||
: minDom.domify('<div class="bjsl-icon bjsl-icon-info">' + InfoSvg + '</div>'); | ||
@@ -396,5 +411,9 @@ var $dropdown = minDom.domify('<div class="bjsl-dropdown"></div>'); | ||
if (infos) { | ||
this._addInfos($issueList, infos); | ||
} | ||
// If errors or warnings for child elements of the current element are to be displayed, | ||
// then add an additional list | ||
if (childErrors || childWarnings) { | ||
if (childErrors || childWarnings || childInfos) { | ||
var $childIssues = minDom.domify('<div class="bjsl-child-issues"></div>'); | ||
@@ -412,2 +431,6 @@ var $childIssueList = minDom.domify('<ul></ul>'); | ||
if (childInfos) { | ||
this._addInfos($childIssueList, childInfos); | ||
} | ||
if (errors || warnings) { | ||
@@ -427,3 +450,3 @@ var $childIssuesSeperator = minDom.domify('<hr/>'); | ||
scale: { | ||
min: .9 | ||
min: .7 | ||
} | ||
@@ -451,2 +474,11 @@ }); | ||
Linting.prototype._addInfos = function($ul, infos) { | ||
var self = this; | ||
infos.forEach(function(error) { | ||
self._addEntry($ul, 'info', error); | ||
}); | ||
}; | ||
Linting.prototype._addEntry = function($ul, state, entry) { | ||
@@ -490,9 +522,31 @@ | ||
Linting.prototype._setButtonState = function(state, errors, warnings) { | ||
Linting.prototype._setButtonState = function(issues) { | ||
var { | ||
errors, | ||
warnings, | ||
infos | ||
} = issues; | ||
var button = this._button; | ||
var state = (errors && 'error') || (warnings && 'warning') || 'success'; | ||
var icon = stateToIcon[state]; | ||
var label = this._translate( | ||
(errors || warnings) | ||
? '{errors} Errors, {warnings} Warnings' | ||
: 'No Issues', | ||
{ | ||
errors: String(errors), | ||
warnings: String(warnings), | ||
infos: String(infos), | ||
} | ||
); | ||
var html = icon + '<span>' + this._translate('{errors} Errors, {warnings} Warnings', { errors: errors.toString(), warnings: warnings.toString() }) + '</span>'; | ||
var html = ` | ||
<span class="icon">${icon}</span> | ||
<span>${ label }</span>`; | ||
state = this.isActive() ? state : 'inactive'; | ||
[ | ||
@@ -516,10 +570,5 @@ 'error', | ||
if (!this.isActive()) { | ||
this._setButtonState('inactive', 0, 0); | ||
return; | ||
} | ||
var errors = 0, | ||
warnings = 0; | ||
warnings = 0, | ||
infos = 0; | ||
@@ -532,2 +581,4 @@ for (var id in this._issues) { | ||
warnings++; | ||
} else if (issue.category === 'info') { | ||
infos++; | ||
} | ||
@@ -537,5 +588,7 @@ }); | ||
var state = (errors && 'error') || (warnings && 'warning') || 'success'; | ||
this._setButtonState(state, errors, warnings); | ||
this._setButtonState({ | ||
errors, | ||
warnings, | ||
infos | ||
}); | ||
}; | ||
@@ -548,3 +601,3 @@ | ||
this._button = minDom.domify( | ||
'<button class="bjsl-button bjsl-button-inactive" title="' + this._translate('Toggle linting') + '"></button>' | ||
'<button class="bjsl-button bjsl-button-inactive" title="' + this._translate('Toggle linting overlays') + '"></button>' | ||
); | ||
@@ -551,0 +604,0 @@ |
{ | ||
"name": "bpmn-js-bpmnlint", | ||
"version": "0.21.0", | ||
"version": "0.22.0", | ||
"description": "bpmn-js integration for bpmnlint", | ||
@@ -16,4 +16,4 @@ "main": "dist/index.js", | ||
"distro": "run-s build test:build copy-assets", | ||
"build": "NODE_ENV=production rollup -c", | ||
"build:watch": "NODE_ENV=production rollup -c -w", | ||
"build": "NODE_ENV=production rollup -c --bundleConfigAsCjs", | ||
"build:watch": "npm run build -- -w", | ||
"test:build": "karma start test/distro/karma.conf.js", | ||
@@ -36,16 +36,16 @@ "copy-assets": "cpx assets/css/* dist/assets/css/ -v", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^24.0.1", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"@rollup/plugin-terser": "^0.4.0", | ||
"bpmn-js": "^13.2.0", | ||
"bpmnlint": "^8.3.1", | ||
"@rollup/plugin-commonjs": "^25.0.7", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"bpmn-js": "^16.3.2", | ||
"bpmnlint": "^10.0.0", | ||
"bpmnlint-loader": "^0.1.6", | ||
"chai": "^4.3.7", | ||
"chai": "^4.4.0", | ||
"cpx": "^1.5.0", | ||
"cross-env": "^7.0.3", | ||
"diagram-js": "^12.2.0", | ||
"eslint": "^8.34.0", | ||
"diagram-js": "^13.4.0", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-bpmn-io": "^1.0.0", | ||
"karma": "^6.4.1", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma": "^6.4.2", | ||
"karma-chrome-launcher": "^3.2.0", | ||
"karma-debug-launcher": "^0.0.5", | ||
@@ -56,11 +56,11 @@ "karma-env-preprocessor": "^0.1.1", | ||
"karma-webpack": "^5.0.0", | ||
"mocha": "^8.4.0", | ||
"mocha": "^10.0.0", | ||
"mocha-test-container-support": "^0.2.0", | ||
"npm-run-all": "^4.1.5", | ||
"puppeteer": "^19.7.1", | ||
"rollup": "^2.79.1", | ||
"puppeteer": "^21.7.0", | ||
"rollup": "^4.9.4", | ||
"rollup-plugin-string": "^3.0.0", | ||
"sinon": "^9.2.4", | ||
"sinon": "^17.0.1", | ||
"sinon-chai": "^3.7.0", | ||
"webpack": "^5.75.0" | ||
"webpack": "^5.89.0" | ||
}, | ||
@@ -67,0 +67,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178442
3010