bpmn-js-bpmnlint
Advanced tools
Comparing version 0.20.1 to 0.21.0
@@ -22,4 +22,2 @@ (function (global, factory) { | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function getAugmentedNamespace(n) { | ||
@@ -97,5 +95,7 @@ if (n.__esModule) return n; | ||
* | ||
* @param {Array<?>} arr | ||
* @template T | ||
* | ||
* @return {Array<?>} | ||
* @param {T[][]} arr | ||
* | ||
* @return {T[]} | ||
*/ | ||
@@ -106,29 +106,51 @@ function flatten(arr) { | ||
var nativeToString$1 = Object.prototype.toString; | ||
var nativeHasOwnProperty$1 = Object.prototype.hasOwnProperty; | ||
function isUndefined$1(obj) { | ||
const nativeToString = Object.prototype.toString; | ||
const nativeHasOwnProperty = Object.prototype.hasOwnProperty; | ||
function isUndefined(obj) { | ||
return obj === undefined; | ||
} | ||
function isDefined(obj) { | ||
return obj !== undefined; | ||
} | ||
function isNil(obj) { | ||
return obj == null; | ||
} | ||
function isArray$2(obj) { | ||
return nativeToString$1.call(obj) === '[object Array]'; | ||
function isArray$1(obj) { | ||
return nativeToString.call(obj) === '[object Array]'; | ||
} | ||
function isObject$1(obj) { | ||
return nativeToString$1.call(obj) === '[object Object]'; | ||
return nativeToString.call(obj) === '[object Object]'; | ||
} | ||
function isNumber(obj) { | ||
return nativeToString$1.call(obj) === '[object Number]'; | ||
return nativeToString.call(obj) === '[object Number]'; | ||
} | ||
function isFunction$1(obj) { | ||
var tag = nativeToString$1.call(obj); | ||
return tag === '[object Function]' || tag === '[object AsyncFunction]' || tag === '[object GeneratorFunction]' || tag === '[object AsyncGeneratorFunction]' || tag === '[object Proxy]'; | ||
/** | ||
* @param {any} obj | ||
* | ||
* @return {boolean} | ||
*/ | ||
function isFunction(obj) { | ||
const tag = nativeToString.call(obj); | ||
return ( | ||
tag === '[object Function]' || | ||
tag === '[object AsyncFunction]' || | ||
tag === '[object GeneratorFunction]' || | ||
tag === '[object AsyncGeneratorFunction]' || | ||
tag === '[object Proxy]' | ||
); | ||
} | ||
function isString(obj) { | ||
return nativeToString$1.call(obj) === '[object String]'; | ||
return nativeToString.call(obj) === '[object String]'; | ||
} | ||
/** | ||
@@ -139,5 +161,5 @@ * Ensure collection is an array. | ||
*/ | ||
function ensureArray(obj) { | ||
function ensureArray(obj) { | ||
if (isArray$2(obj)) { | ||
if (isArray$1(obj)) { | ||
return; | ||
@@ -148,2 +170,3 @@ } | ||
} | ||
/** | ||
@@ -157,65 +180,137 @@ * Return true, if target owns a property with the given key. | ||
*/ | ||
function has$1(target, key) { | ||
return nativeHasOwnProperty$1.call(target, key); | ||
function has(target, key) { | ||
return nativeHasOwnProperty.call(target, key); | ||
} | ||
/** | ||
* @template T | ||
* @typedef { ( | ||
* ((e: T) => boolean) | | ||
* ((e: T, idx: number) => boolean) | | ||
* ((e: T, key: string) => boolean) | | ||
* string | | ||
* number | ||
* ) } Matcher | ||
*/ | ||
/** | ||
* @template T | ||
* @template U | ||
* | ||
* @typedef { ( | ||
* ((e: T) => U) | string | number | ||
* ) } Extractor | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef { (val: T, key: any) => boolean } MatchFn | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef { T[] } ArrayCollection | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef { { [key: string]: T } } StringKeyValueCollection | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef { { [key: number]: T } } NumberKeyValueCollection | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef { StringKeyValueCollection<T> | NumberKeyValueCollection<T> } KeyValueCollection | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef { KeyValueCollection<T> | ArrayCollection<T> } Collection | ||
*/ | ||
/** | ||
* Find element in collection. | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function|Object} matcher | ||
* @template T | ||
* @param {Collection<T>} collection | ||
* @param {Matcher<T>} matcher | ||
* | ||
* @return {Object} | ||
*/ | ||
function find(collection, matcher) { | ||
function find(collection, matcher) { | ||
matcher = toMatcher(matcher); | ||
var match; | ||
forEach$1(collection, function (val, key) { | ||
if (matcher(val, key)) { | ||
const matchFn = toMatcher(matcher); | ||
let match; | ||
forEach(collection, function(val, key) { | ||
if (matchFn(val, key)) { | ||
match = val; | ||
return false; | ||
} | ||
}); | ||
return match; | ||
} | ||
/** | ||
* Find element index in collection. | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} matcher | ||
* @template T | ||
* @param {Collection<T>} collection | ||
* @param {Matcher<T>} matcher | ||
* | ||
* @return {Object} | ||
* @return {number} | ||
*/ | ||
function findIndex(collection, matcher) { | ||
function findIndex(collection, matcher) { | ||
matcher = toMatcher(matcher); | ||
var idx = isArray$2(collection) ? -1 : undefined; | ||
forEach$1(collection, function (val, key) { | ||
if (matcher(val, key)) { | ||
const matchFn = toMatcher(matcher); | ||
let idx = isArray$1(collection) ? -1 : undefined; | ||
forEach(collection, function(val, key) { | ||
if (matchFn(val, key)) { | ||
idx = key; | ||
return false; | ||
} | ||
}); | ||
return idx; | ||
} | ||
/** | ||
* Find element in collection. | ||
* Filter elements in collection. | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} matcher | ||
* @template T | ||
* @param {Collection<T>} collection | ||
* @param {Matcher<T>} matcher | ||
* | ||
* @return {Array} result | ||
* @return {T[]} result | ||
*/ | ||
function filter(collection, matcher) { | ||
function filter(collection, matcher) { | ||
var result = []; | ||
forEach$1(collection, function (val, key) { | ||
if (matcher(val, key)) { | ||
const matchFn = toMatcher(matcher); | ||
let result = []; | ||
forEach(collection, function(val, key) { | ||
if (matchFn(val, key)) { | ||
result.push(val); | ||
} | ||
}); | ||
return result; | ||
} | ||
/** | ||
@@ -225,20 +320,24 @@ * Iterate over collection; returning something | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} iterator | ||
* @template T | ||
* @param {Collection<T>} collection | ||
* @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator | ||
* | ||
* @return {Object} return result that stopped the iteration | ||
* @return {T} return result that stopped the iteration | ||
*/ | ||
function forEach(collection, iterator) { | ||
function forEach$1(collection, iterator) { | ||
var val, result; | ||
let val, | ||
result; | ||
if (isUndefined$1(collection)) { | ||
if (isUndefined(collection)) { | ||
return; | ||
} | ||
var convertKey = isArray$2(collection) ? toNum$1 : identity$1; | ||
const convertKey = isArray$1(collection) ? toNum : identity; | ||
for (var key in collection) { | ||
if (has$1(collection, key)) { | ||
for (let key in collection) { | ||
if (has(collection, key)) { | ||
val = collection[key]; | ||
result = iterator(val, convertKey(key)); | ||
@@ -252,13 +351,15 @@ | ||
} | ||
/** | ||
* Return collection without element. | ||
* | ||
* @param {Array} arr | ||
* @param {Function} matcher | ||
* @template T | ||
* @param {ArrayCollection<T>} arr | ||
* @param {Matcher<T>} matcher | ||
* | ||
* @return {Array} | ||
* @return {T[]} | ||
*/ | ||
function without(arr, matcher) { | ||
function without(arr, matcher) { | ||
if (isUndefined$1(arr)) { | ||
if (isUndefined(arr)) { | ||
return []; | ||
@@ -268,23 +369,34 @@ } | ||
ensureArray(arr); | ||
matcher = toMatcher(matcher); | ||
return arr.filter(function (el, idx) { | ||
return !matcher(el, idx); | ||
const matchFn = toMatcher(matcher); | ||
return arr.filter(function(el, idx) { | ||
return !matchFn(el, idx); | ||
}); | ||
} | ||
/** | ||
* Reduce collection, returning a single result. | ||
* | ||
* @param {Object|Array} collection | ||
* @param {Function} iterator | ||
* @param {Any} result | ||
* @template T | ||
* @template V | ||
* | ||
* @return {Any} result returned from last iterator | ||
* @param {Collection<T>} collection | ||
* @param {(result: V, entry: T, index: any) => V} iterator | ||
* @param {V} result | ||
* | ||
* @return {V} result returned from last iterator | ||
*/ | ||
function reduce(collection, iterator, result) { | ||
function reduce$1(collection, iterator, result) { | ||
forEach$1(collection, function (value, idx) { | ||
forEach(collection, function(value, idx) { | ||
result = iterator(result, value, idx); | ||
}); | ||
return result; | ||
} | ||
/** | ||
@@ -299,8 +411,10 @@ * Return true if every element in the collection | ||
*/ | ||
function every(collection, matcher) { | ||
function every(collection, matcher) { | ||
return !!reduce$1(collection, function (matches, val, key) { | ||
return !!reduce(collection, function(matches, val, key) { | ||
return matches && matcher(val, key); | ||
}, true); | ||
} | ||
/** | ||
@@ -315,6 +429,8 @@ * Return true if some elements in the collection | ||
*/ | ||
function some(collection, matcher) { | ||
function some(collection, matcher) { | ||
return !!find(collection, matcher); | ||
} | ||
/** | ||
@@ -329,10 +445,14 @@ * Transform a collection into another collection | ||
*/ | ||
function map$1(collection, fn) { | ||
function map$2(collection, fn) { | ||
var result = []; | ||
forEach$1(collection, function (val, key) { | ||
let result = []; | ||
forEach(collection, function(val, key) { | ||
result.push(fn(val, key)); | ||
}); | ||
return result; | ||
} | ||
/** | ||
@@ -345,6 +465,7 @@ * Get the collections keys. | ||
*/ | ||
function keys(collection) { | ||
return collection && Object.keys(collection) || []; | ||
} | ||
/** | ||
@@ -357,6 +478,7 @@ * Shorthand for `keys(o).length`. | ||
*/ | ||
function size(collection) { | ||
return keys(collection).length; | ||
} | ||
/** | ||
@@ -369,24 +491,24 @@ * Get the values in the collection. | ||
*/ | ||
function values(collection) { | ||
return map$2(collection, function (val) { | ||
return val; | ||
}); | ||
return map$1(collection, (val) => val); | ||
} | ||
/** | ||
* Group collection members by attribute. | ||
* | ||
* @param {Object|Array} collection | ||
* @param {Function} extractor | ||
* @param {Object|Array} collection | ||
* @param {Extractor} extractor | ||
* | ||
* @return {Object} map with { attrValue => [ a, b, c ] } | ||
*/ | ||
function groupBy(collection, extractor, grouped = {}) { | ||
function groupBy$1(collection, extractor) { | ||
var grouped = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
extractor = toExtractor$1(extractor); | ||
forEach$1(collection, function (val) { | ||
var discriminator = extractor(val) || '_'; | ||
var group = grouped[discriminator]; | ||
extractor = toExtractor(extractor); | ||
forEach(collection, function(val) { | ||
let discriminator = extractor(val) || '_'; | ||
let group = grouped[discriminator]; | ||
if (!group) { | ||
@@ -398,36 +520,47 @@ group = grouped[discriminator] = []; | ||
}); | ||
return grouped; | ||
} | ||
function uniqueBy(extractor) { | ||
extractor = toExtractor$1(extractor); | ||
var grouped = {}; | ||
for (var _len = arguments.length, collections = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
collections[_key - 1] = arguments[_key]; | ||
} | ||
forEach$1(collections, function (c) { | ||
return groupBy$1(c, extractor, grouped); | ||
}); | ||
var result = map$2(grouped, function (val, key) { | ||
function uniqueBy(extractor, ...collections) { | ||
extractor = toExtractor(extractor); | ||
let grouped = {}; | ||
forEach(collections, (c) => groupBy(c, extractor, grouped)); | ||
let result = map$1(grouped, function(val, key) { | ||
return val[0]; | ||
}); | ||
return result; | ||
} | ||
var unionBy = uniqueBy; | ||
const unionBy = uniqueBy; | ||
/** | ||
* Sort collection by criteria. | ||
* | ||
* @param {Object|Array} collection | ||
* @param {String|Function} extractor | ||
* @template T | ||
* | ||
* @param {Collection<T>} collection | ||
* @param {Extractor<T, number | string>} extractor | ||
* | ||
* @return {Array} | ||
*/ | ||
function sortBy(collection, extractor) { | ||
function sortBy(collection, extractor) { | ||
extractor = toExtractor$1(extractor); | ||
var sorted = []; | ||
forEach$1(collection, function (value, key) { | ||
var disc = extractor(value, key); | ||
var entry = { | ||
extractor = toExtractor(extractor); | ||
let sorted = []; | ||
forEach(collection, function(value, key) { | ||
let disc = extractor(value, key); | ||
let entry = { | ||
d: disc, | ||
@@ -438,3 +571,3 @@ v: value | ||
for (var idx = 0; idx < sorted.length; idx++) { | ||
var d = sorted[idx].d; | ||
let { d } = sorted[idx]; | ||
@@ -445,11 +578,12 @@ if (disc < d) { | ||
} | ||
} // not inserted, append (!) | ||
} | ||
// not inserted, append (!) | ||
sorted.push(entry); | ||
}); | ||
return map$2(sorted, function (e) { | ||
return e.v; | ||
}); | ||
return map$1(sorted, (e) => e.v); | ||
} | ||
/** | ||
@@ -460,21 +594,39 @@ * Create an object pattern matcher. | ||
* | ||
* ```javascript | ||
* const matcher = matchPattern({ id: 1 }); | ||
* | ||
* let element = find(elements, matcher); | ||
* ``` | ||
* | ||
* @param {Object} pattern | ||
* @template T | ||
* | ||
* @return {Function} matcherFn | ||
* @param {T} pattern | ||
* | ||
* @return { (el: any) => boolean } matcherFn | ||
*/ | ||
function matchPattern(pattern) { | ||
function matchPattern(pattern) { | ||
return function (el) { | ||
return every(pattern, function (val, key) { | ||
return function(el) { | ||
return every(pattern, function(val, key) { | ||
return el[key] === val; | ||
}); | ||
}; | ||
} | ||
function toExtractor$1(extractor) { | ||
return isFunction$1(extractor) ? extractor : function (e) { | ||
/** | ||
* @param {string | ((e: any) => any) } extractor | ||
* | ||
* @return { (e: any) => any } | ||
*/ | ||
function toExtractor(extractor) { | ||
/** | ||
* @satisfies { (e: any) => any } | ||
*/ | ||
return isFunction(extractor) ? extractor : (e) => { | ||
// @ts-ignore: just works | ||
return e[extractor]; | ||
@@ -484,4 +636,11 @@ }; | ||
/** | ||
* @template T | ||
* @param {Matcher<T>} matcher | ||
* | ||
* @return {MatchFn<T>} | ||
*/ | ||
function toMatcher(matcher) { | ||
return isFunction$1(matcher) ? matcher : function (e) { | ||
return isFunction(matcher) ? matcher : (e) => { | ||
return e === matcher; | ||
@@ -491,11 +650,22 @@ }; | ||
function identity$1(arg) { | ||
function identity(arg) { | ||
return arg; | ||
} | ||
function toNum$1(arg) { | ||
function toNum(arg) { | ||
return Number(arg); | ||
} | ||
/* global setTimeout clearTimeout */ | ||
/** | ||
* @typedef { { | ||
* (...args: any[]): any; | ||
* flush: () => void; | ||
* cancel: () => void; | ||
* } } DebouncedFunction | ||
*/ | ||
/** | ||
* Debounce fn, calling it only once if the given time | ||
@@ -510,14 +680,19 @@ * elapsed between calls. | ||
* | ||
* @return {Function} debounced function | ||
* @return {DebouncedFunction} debounced function | ||
*/ | ||
function debounce(fn, timeout) { | ||
var timer; | ||
var lastArgs; | ||
var lastThis; | ||
var lastNow; | ||
let timer; | ||
let lastArgs; | ||
let lastThis; | ||
let lastNow; | ||
function fire(force) { | ||
var now = Date.now(); | ||
var scheduledDiff = force ? 0 : lastNow + timeout - now; | ||
let now = Date.now(); | ||
let scheduledDiff = force ? 0 : (lastNow + timeout) - now; | ||
if (scheduledDiff > 0) { | ||
@@ -528,2 +703,3 @@ return schedule(scheduledDiff); | ||
fn.apply(lastThis, lastArgs); | ||
clear(); | ||
@@ -552,12 +728,12 @@ } | ||
function callback() { | ||
/** | ||
* @type { DebouncedFunction } | ||
*/ | ||
function callback(...args) { | ||
lastNow = Date.now(); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
lastArgs = args; | ||
lastThis = this; // ensure an execution is scheduled | ||
lastThis = this; | ||
// ensure an execution is scheduled | ||
if (!timer) { | ||
@@ -570,4 +746,6 @@ schedule(timeout); | ||
callback.cancel = clear; | ||
return callback; | ||
} | ||
/** | ||
@@ -582,6 +760,7 @@ * Throttle fn, calling at most once | ||
*/ | ||
function throttle(fn, interval) { | ||
let throttling = false; | ||
function throttle(fn, interval) { | ||
var throttling = false; | ||
return function () { | ||
return function(...args) { | ||
if (throttling) { | ||
@@ -591,5 +770,6 @@ return; | ||
fn.apply(void 0, arguments); | ||
fn(...args); | ||
throttling = true; | ||
setTimeout(function () { | ||
setTimeout(() => { | ||
throttling = false; | ||
@@ -599,2 +779,3 @@ }, interval); | ||
} | ||
/** | ||
@@ -608,3 +789,2 @@ * Bind function against target <this>. | ||
*/ | ||
function bind(fn, target) { | ||
@@ -614,36 +794,2 @@ return fn.bind(target); | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
/** | ||
@@ -657,10 +803,6 @@ * Convenience wrapper for `Object.assign`. | ||
*/ | ||
function assign(target, ...others) { | ||
return Object.assign(target, ...others); | ||
} | ||
function assign$1(target) { | ||
for (var _len = arguments.length, others = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
others[_key - 1] = arguments[_key]; | ||
} | ||
return _extends.apply(void 0, [target].concat(others)); | ||
} | ||
/** | ||
@@ -671,12 +813,18 @@ * Sets a nested property of a given object to the specified value. | ||
* | ||
* @param {Object} target The target of the set operation. | ||
* @template T | ||
* | ||
* @param {T} target The target of the set operation. | ||
* @param {(string|number)[]} path The path to the nested value. | ||
* @param {any} value The value to set. | ||
* | ||
* @return {T} | ||
*/ | ||
function set(target, path, value) { | ||
function set(target, path, value) { | ||
var currentTarget = target; | ||
forEach$1(path, function (key, idx) { | ||
let currentTarget = target; | ||
forEach(path, function(key, idx) { | ||
if (typeof key !== 'number' && typeof key !== 'string') { | ||
throw new Error('illegal key type: ' + _typeof(key) + '. Key should be of type number or string.'); | ||
throw new Error('illegal key type: ' + typeof key + '. Key should be of type number or string.'); | ||
} | ||
@@ -692,4 +840,4 @@ | ||
var nextKey = path[idx + 1]; | ||
var nextTarget = currentTarget[key]; | ||
let nextKey = path[idx + 1]; | ||
let nextTarget = currentTarget[key]; | ||
@@ -700,4 +848,4 @@ if (isDefined(nextKey) && isNil(nextTarget)) { | ||
if (isUndefined$1(nextKey)) { | ||
if (isUndefined$1(value)) { | ||
if (isUndefined(nextKey)) { | ||
if (isUndefined(value)) { | ||
delete currentTarget[key]; | ||
@@ -711,4 +859,7 @@ } else { | ||
}); | ||
return target; | ||
} | ||
/** | ||
@@ -720,10 +871,15 @@ * Gets a nested property of a given object. | ||
* @param {any} [defaultValue] The value to return if no value exists. | ||
* | ||
* @return {any} | ||
*/ | ||
function get(target, path, defaultValue) { | ||
function get(target, path, defaultValue) { | ||
var currentTarget = target; | ||
forEach$1(path, function (key) { | ||
let currentTarget = target; | ||
forEach(path, function(key) { | ||
// accessing nil property yields <undefined> | ||
if (isNil(currentTarget)) { | ||
currentTarget = undefined; | ||
return false; | ||
@@ -734,17 +890,25 @@ } | ||
}); | ||
return isUndefined$1(currentTarget) ? defaultValue : currentTarget; | ||
return isUndefined(currentTarget) ? defaultValue : currentTarget; | ||
} | ||
/** | ||
* Pick given properties from the target object. | ||
* Pick properties from the given target. | ||
* | ||
* @param {Object} target | ||
* @param {Array} properties | ||
* @template T | ||
* @template {any[]} V | ||
* | ||
* @return {Object} target | ||
* @param {T} target | ||
* @param {V} properties | ||
* | ||
* @return Pick<T, V> | ||
*/ | ||
function pick(target, properties) { | ||
function pick(target, properties) { | ||
var result = {}; | ||
var obj = Object(target); | ||
forEach$1(properties, function (prop) { | ||
let result = {}; | ||
let obj = Object(target); | ||
forEach(properties, function(prop) { | ||
if (prop in obj) { | ||
@@ -754,17 +918,25 @@ result[prop] = target[prop]; | ||
}); | ||
return result; | ||
} | ||
/** | ||
* Pick all target properties, excluding the given ones. | ||
* | ||
* @param {Object} target | ||
* @param {Array} properties | ||
* @template T | ||
* @template {any[]} V | ||
* | ||
* @return {Object} target | ||
* @param {T} target | ||
* @param {V} properties | ||
* | ||
* @return {Omit<T, V>} target | ||
*/ | ||
function omit(target, properties) { | ||
function omit(target, properties) { | ||
var result = {}; | ||
var obj = Object(target); | ||
forEach$1(obj, function (prop, key) { | ||
let result = {}; | ||
let obj = Object(target); | ||
forEach(obj, function(prop, key) { | ||
if (properties.indexOf(key) === -1) { | ||
@@ -774,4 +946,6 @@ result[key] = prop; | ||
}); | ||
return result; | ||
} | ||
/** | ||
@@ -787,8 +961,4 @@ * Recursively merge `...sources` into given target. | ||
*/ | ||
function merge(target, ...sources) { | ||
function merge(target) { | ||
for (var _len2 = arguments.length, sources = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
sources[_key2 - 1] = arguments[_key2]; | ||
} | ||
if (!sources.length) { | ||
@@ -798,3 +968,4 @@ return target; | ||
forEach$1(sources, function (source) { | ||
forEach(sources, function(source) { | ||
// skip non-obj sources, i.e. null | ||
@@ -805,3 +976,4 @@ if (!source || !isObject$1(source)) { | ||
forEach$1(source, function (sourceVal, key) { | ||
forEach(source, function(sourceVal, key) { | ||
if (key === '__proto__') { | ||
@@ -811,6 +983,8 @@ return; | ||
var targetVal = target[key]; | ||
let targetVal = target[key]; | ||
if (isObject$1(sourceVal)) { | ||
if (!isObject$1(targetVal)) { | ||
// override target[key] with object | ||
@@ -824,4 +998,6 @@ targetVal = {}; | ||
} | ||
}); | ||
}); | ||
return target; | ||
@@ -832,3 +1008,3 @@ } | ||
__proto__: null, | ||
assign: assign$1, | ||
assign: assign, | ||
bind: bind, | ||
@@ -842,9 +1018,9 @@ debounce: debounce, | ||
flatten: flatten, | ||
forEach: forEach$1, | ||
forEach: forEach, | ||
get: get, | ||
groupBy: groupBy$1, | ||
has: has$1, | ||
isArray: isArray$2, | ||
groupBy: groupBy, | ||
has: has, | ||
isArray: isArray$1, | ||
isDefined: isDefined, | ||
isFunction: isFunction$1, | ||
isFunction: isFunction, | ||
isNil: isNil, | ||
@@ -854,5 +1030,5 @@ isNumber: isNumber, | ||
isString: isString, | ||
isUndefined: isUndefined$1, | ||
isUndefined: isUndefined, | ||
keys: keys, | ||
map: map$2, | ||
map: map$1, | ||
matchPattern: matchPattern, | ||
@@ -862,3 +1038,3 @@ merge: merge, | ||
pick: pick, | ||
reduce: reduce$1, | ||
reduce: reduce, | ||
set: set, | ||
@@ -880,3 +1056,3 @@ size: size, | ||
const { | ||
isArray: isArray$1, | ||
isArray, | ||
isObject | ||
@@ -916,3 +1092,3 @@ } = require$$1; | ||
if (path && isArray$1(path)) { | ||
if (path && isArray(path)) { | ||
report = { | ||
@@ -960,3 +1136,4 @@ ...report, | ||
1: 'warn', | ||
2: 'error' | ||
2: 'error', | ||
3: 'info' | ||
}; | ||
@@ -1415,176 +1592,2 @@ | ||
/** | ||
* Flatten array, one level deep. | ||
* | ||
* @param {Array<?>} arr | ||
* | ||
* @return {Array<?>} | ||
*/ | ||
const nativeToString = Object.prototype.toString; | ||
const nativeHasOwnProperty = Object.prototype.hasOwnProperty; | ||
function isUndefined(obj) { | ||
return obj === undefined; | ||
} | ||
function isArray(obj) { | ||
return nativeToString.call(obj) === '[object Array]'; | ||
} | ||
function isFunction(obj) { | ||
const tag = nativeToString.call(obj); | ||
return ( | ||
tag === '[object Function]' || | ||
tag === '[object AsyncFunction]' || | ||
tag === '[object GeneratorFunction]' || | ||
tag === '[object AsyncGeneratorFunction]' || | ||
tag === '[object Proxy]' | ||
); | ||
} | ||
/** | ||
* Return true, if target owns a property with the given key. | ||
* | ||
* @param {Object} target | ||
* @param {String} key | ||
* | ||
* @return {Boolean} | ||
*/ | ||
function has(target, key) { | ||
return nativeHasOwnProperty.call(target, key); | ||
} | ||
/** | ||
* Iterate over collection; returning something | ||
* (non-undefined) will stop iteration. | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} iterator | ||
* | ||
* @return {Object} return result that stopped the iteration | ||
*/ | ||
function forEach(collection, iterator) { | ||
let val, | ||
result; | ||
if (isUndefined(collection)) { | ||
return; | ||
} | ||
const convertKey = isArray(collection) ? toNum : identity; | ||
for (let key in collection) { | ||
if (has(collection, key)) { | ||
val = collection[key]; | ||
result = iterator(val, convertKey(key)); | ||
if (result === false) { | ||
return val; | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Reduce collection, returning a single result. | ||
* | ||
* @param {Object|Array} collection | ||
* @param {Function} iterator | ||
* @param {Any} result | ||
* | ||
* @return {Any} result returned from last iterator | ||
*/ | ||
function reduce(collection, iterator, result) { | ||
forEach(collection, function(value, idx) { | ||
result = iterator(result, value, idx); | ||
}); | ||
return result; | ||
} | ||
/** | ||
* Transform a collection into another collection | ||
* by piping each member through the given fn. | ||
* | ||
* @param {Object|Array} collection | ||
* @param {Function} fn | ||
* | ||
* @return {Array} transformed collection | ||
*/ | ||
function map$1(collection, fn) { | ||
let result = []; | ||
forEach(collection, function(val, key) { | ||
result.push(fn(val, key)); | ||
}); | ||
return result; | ||
} | ||
/** | ||
* Group collection members by attribute. | ||
* | ||
* @param {Object|Array} collection | ||
* @param {Function} extractor | ||
* | ||
* @return {Object} map with { attrValue => [ a, b, c ] } | ||
*/ | ||
function groupBy(collection, extractor, grouped = {}) { | ||
extractor = toExtractor(extractor); | ||
forEach(collection, function(val) { | ||
let discriminator = extractor(val) || '_'; | ||
let group = grouped[discriminator]; | ||
if (!group) { | ||
group = grouped[discriminator] = []; | ||
} | ||
group.push(val); | ||
}); | ||
return grouped; | ||
} | ||
function toExtractor(extractor) { | ||
return isFunction(extractor) ? extractor : (e) => { | ||
return e[extractor]; | ||
}; | ||
} | ||
function identity(arg) { | ||
return arg; | ||
} | ||
function toNum(arg) { | ||
return Number(arg); | ||
} | ||
/** | ||
* Convenience wrapper for `Object.assign`. | ||
* | ||
* @param {Object} target | ||
* @param {...Object} others | ||
* | ||
* @return {Object} the target | ||
*/ | ||
function assign(target, ...others) { | ||
return Object.assign(target, ...others); | ||
} | ||
var componentEvent = {}; | ||
@@ -1748,112 +1751,8 @@ | ||
var css_escapeExports = {}; | ||
var css_escape = { | ||
get exports(){ return css_escapeExports; }, | ||
set exports(v){ css_escapeExports = v; }, | ||
}; | ||
/** | ||
* @param {string} str | ||
* | ||
* @return {string} | ||
*/ | ||
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */ | ||
(function (module, exports) { | ||
(function(root, factory) { | ||
// https://github.com/umdjs/umd/blob/master/returnExports.js | ||
{ | ||
// For Node.js. | ||
module.exports = factory(root); | ||
} | ||
}(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) { | ||
if (root.CSS && root.CSS.escape) { | ||
return root.CSS.escape; | ||
} | ||
// https://drafts.csswg.org/cssom/#serialize-an-identifier | ||
var cssEscape = function(value) { | ||
if (arguments.length == 0) { | ||
throw new TypeError('`CSS.escape` requires an argument.'); | ||
} | ||
var string = String(value); | ||
var length = string.length; | ||
var index = -1; | ||
var codeUnit; | ||
var result = ''; | ||
var firstCodeUnit = string.charCodeAt(0); | ||
while (++index < length) { | ||
codeUnit = string.charCodeAt(index); | ||
// Note: there’s no need to special-case astral symbols, surrogate | ||
// pairs, or lone surrogates. | ||
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER | ||
// (U+FFFD). | ||
if (codeUnit == 0x0000) { | ||
result += '\uFFFD'; | ||
continue; | ||
} | ||
if ( | ||
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is | ||
// U+007F, […] | ||
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F || | ||
// If the character is the first character and is in the range [0-9] | ||
// (U+0030 to U+0039), […] | ||
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) || | ||
// If the character is the second character and is in the range [0-9] | ||
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […] | ||
( | ||
index == 1 && | ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 && | ||
firstCodeUnit == 0x002D | ||
) | ||
) { | ||
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point | ||
result += '\\' + codeUnit.toString(16) + ' '; | ||
continue; | ||
} | ||
if ( | ||
// If the character is the first character and is a `-` (U+002D), and | ||
// there is no second character, […] | ||
index == 0 && | ||
length == 1 && | ||
codeUnit == 0x002D | ||
) { | ||
result += '\\' + string.charAt(index); | ||
continue; | ||
} | ||
// If the character is not handled by one of the above rules and is | ||
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or | ||
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to | ||
// U+005A), or [a-z] (U+0061 to U+007A), […] | ||
if ( | ||
codeUnit >= 0x0080 || | ||
codeUnit == 0x002D || | ||
codeUnit == 0x005F || | ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 || | ||
codeUnit >= 0x0041 && codeUnit <= 0x005A || | ||
codeUnit >= 0x0061 && codeUnit <= 0x007A | ||
) { | ||
// the character itself | ||
result += string.charAt(index); | ||
continue; | ||
} | ||
// Otherwise, the escaped character. | ||
// https://drafts.csswg.org/cssom/#escape-a-character | ||
result += '\\' + string.charAt(index); | ||
} | ||
return result; | ||
}; | ||
if (!root.CSS) { | ||
root.CSS = {}; | ||
} | ||
root.CSS.escape = cssEscape; | ||
return cssEscape; | ||
})); | ||
} (css_escape)); | ||
var HTML_ESCAPE_MAP = { | ||
@@ -1867,2 +1766,7 @@ '&': '&', | ||
/** | ||
* @param {string} str | ||
* | ||
* @return {string} | ||
*/ | ||
function escapeHTML(str) { | ||
@@ -1877,5 +1781,10 @@ str = '' + str; | ||
/** | ||
* @typedef { import('../model/Types').Element } Element | ||
* @typedef { import('../model/Types').ModdleElement } ModdleElement | ||
*/ | ||
/** | ||
* Is an element of the given BPMN type? | ||
* | ||
* @param {djs.model.Base|ModdleElement} element | ||
* @param {Element|ModdleElement} element | ||
* @param {string} type | ||
@@ -1894,3 +1803,3 @@ * | ||
* | ||
* @param {djs.model.Base|ModdleElement} element | ||
* @param {Element|ModdleElement} element | ||
* | ||
@@ -1897,0 +1806,0 @@ * @return {ModdleElement} |
@@ -1,3 +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()}})}t.$inject=["injector","linting"];var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(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}var r=Object.prototype.toString,i=Object.prototype.hasOwnProperty;function o(t){return void 0===t}function s(t){return void 0!==t}function u(t){return null==t}function c(t){return"[object Array]"===r.call(t)}function l(t){return"[object Object]"===r.call(t)}function a(t){var e=r.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e||"[object Proxy]"===e}function f(t){if(!c(t))throw new Error("must supply array")}function p(t,e){return i.call(t,e)}function d(t,e){var n;return e=j(e),h(t,(function(t,r){if(e(t,r))return n=t,!1})),n}function h(t,e){var n;if(!o(t)){var r=c(t)?S:E;for(var i in t)if(p(t,i)&&!1===e(n=t[i],r(i)))return n}}function g(t,e,n){return h(t,(function(t,r){n=e(n,t,r)})),n}function v(t,e){return!!g(t,(function(t,n,r){return t&&e(n,r)}),!0)}function y(t,e){var n=[];return h(t,(function(t,r){n.push(e(t,r))})),n}function m(t){return t&&Object.keys(t)||[]}function b(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e=C(e),h(t,(function(t){var r=e(t)||"_",i=n[r];i||(i=n[r]=[]),i.push(t)})),n}function _(t){t=C(t);for(var e={},n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return h(r,(function(n){return b(n,t,e)})),y(e,(function(t,e){return t[0]}))}var w=_;function C(t){return a(t)?t:function(e){return e[t]}}function j(t){return a(t)?t:function(e){return e===t}}function E(t){return t}function S(t){return Number(t)}function R(t){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(t)}function O(){return O=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},O.apply(this,arguments)}var A=Object.freeze({__proto__:null,assign:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return O.apply(void 0,[t].concat(n))},bind:function(t,e){return t.bind(e)},debounce:function(t,e){var n,r,i,o;function s(n){var s=Date.now(),l=n?0:o+e-s;if(l>0)return u(l);t.apply(i,r),c()}function u(t){n=setTimeout(s,t)}function c(){n&&clearTimeout(n),n=o=r=i=void 0}function l(){o=Date.now();for(var t=arguments.length,s=new Array(t),c=0;c<t;c++)s[c]=arguments[c];r=s,i=this,n||u(e)}return l.flush=function(){n&&s(!0),c()},l.cancel=c,l},ensureArray:f,every:v,filter:function(t,e){var n=[];return h(t,(function(t,r){e(t,r)&&n.push(t)})),n},find:d,findIndex:function(t,e){e=j(e);var n=c(t)?-1:void 0;return h(t,(function(t,r){if(e(t,r))return n=r,!1})),n},flatten:function(t){return Array.prototype.concat.apply([],t)},forEach:h,get:function(t,e,n){var r=t;return h(e,(function(t){if(u(r))return r=void 0,!1;r=r[t]})),o(r)?n:r},groupBy:b,has:p,isArray:c,isDefined:s,isFunction:a,isNil:u,isNumber:function(t){return"[object Number]"===r.call(t)},isObject:l,isString:function(t){return"[object String]"===r.call(t)},isUndefined:o,keys:m,map:y,matchPattern:function(t){return function(e){return v(t,(function(t,n){return e[n]===t}))}},merge:function t(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.length?(h(r,(function(n){n&&l(n)&&h(n,(function(n,r){if("__proto__"!==r){var i=e[r];l(n)?(l(i)||(i={}),e[r]=t(i,n)):e[r]=n}}))})),e):e},omit:function(t,e){var n={};return h(Object(t),(function(t,r){-1===e.indexOf(r)&&(n[r]=t)})),n},pick:function(t,e){var n={},r=Object(t);return h(e,(function(e){e in r&&(n[e]=t[e])})),n},reduce:g,set:function(t,e,n){var r=t;return h(e,(function(t,i){if("number"!=typeof t&&"string"!=typeof t)throw new Error("illegal key type: "+R(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__");var c=e[i+1],l=r[t];s(c)&&u(l)&&(l=r[t]=isNaN(+c)?{}:[]),o(c)?o(n)?delete r[t]:r[t]=n:r=l})),t},size:function(t){return m(t).length},some:function(t,e){return!!d(t,e)},sortBy:function(t,e){e=C(e);var n=[];return h(t,(function(t,r){for(var i=e(t,r),o={d:i,v:t},s=0;s<n.length;s++){if(i<n[s].d)return void n.splice(s,0,o)}n.push(o)})),y(n,(function(t){return t.v}))},throttle:function(t,e){var n=!1;return function(){n||(t.apply(void 0,arguments),n=!0,setTimeout((function(){n=!1}),e))}},unionBy:w,uniqueBy:_,values:function(t){return y(t,(function(t){return t}))},without:function(t,e){return o(t)?[]:(f(t),e=j(e),t.filter((function(t,n){return!e(t,n)})))}}),k=n(A);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:x,isObject:L}=k;class B{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&&x(n)&&(r={...r,path:n}),n&&L(n)&&(r={...r,...n}),this.messages.push(r)}}const N=function({moddleRoot:t,rule:e}){const n=new B({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},P={0:"off",1:"warn",2:"error"};function I(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 T=I;function F(t){return"bpmnlint"===t?"bpmnlint":t.startsWith("bpmnlint-plugin-")?t:`bpmnlint-plugin-${t}`}I.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"}]}},I.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)}))},I.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)}))},I.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)}))},I.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})),{})))},I.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}))},I.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=P[e]||e,{config:n,category:e}},I.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+"/":""}${F(o)}`,ruleName:s}},I.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+"/":""}${F(i)}`,configName:o}},I.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)}`},I.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 M={Linter:T};const z=Object.prototype.toString,D=Object.prototype.hasOwnProperty;function W(t,e){return D.call(t,e)}function G(t,e){let n,r;if(void 0===t)return;const i=function(t){return"[object Array]"===z.call(t)}(t)?V:q;for(let o in t)if(W(t,o)&&(n=t[o],r=e(n,i(o)),!1===r))return n}function H(t,e,n={}){return e=function(t){return function(t){const e=z.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e||"[object Proxy]"===e}(t)?t:e=>e[t]}(e),G(t,(function(t){let r=e(t)||"_",i=n[r];i||(i=n[r]=[]),i.push(t)})),n}function q(t){return t}function V(t){return Number(t)}function J(t,...e){return Object.assign(t,...e)}var K,U,X,Q={};function Y(){K=window.addEventListener?"addEventListener":"attachEvent",U=window.removeEventListener?"removeEventListener":"detachEvent",X="addEventListener"!==K?"on":""}Q.bind=function(t,e,n,r){return K||Y(),t[K](X+e,n,r||!1),n},Q.unbind=function(t,e,n,r){return U||Y(),t[U](X+e,n,r||!1),n};var Z,tt=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(nt,r)?nt[r]:nt._default,s=o[0],u=o[1],c=o[2];(i=e.createElement("div")).innerHTML=u+t+c;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},et=!1;"undefined"!=typeof document&&((Z=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',et=!Z.getElementsByTagName("link").length,Z=void 0);var nt={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:et?[1,"X<div>","</div>"]:[0,"",""]};nt.td=nt.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],nt.option=nt.optgroup=[1,'<select multiple="multiple">',"</select>"],nt.thead=nt.tbody=nt.colgroup=nt.caption=nt.tfoot=[1,"<table>","</table>"],nt.polyline=nt.ellipse=nt.polygon=nt.circle=nt.text=nt.line=nt.path=nt.rect=nt.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var rt=tt,it={}; | ||
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */ | ||
!function(t,n){var r;r=e,t.exports=function(t){if(t.CSS&&t.CSS.escape)return t.CSS.escape;var e=function(t){if(0==arguments.length)throw new TypeError("`CSS.escape` requires an argument.");for(var e,n=String(t),r=n.length,i=-1,o="",s=n.charCodeAt(0);++i<r;)0!=(e=n.charCodeAt(i))?o+=e>=1&&e<=31||127==e||0==i&&e>=48&&e<=57||1==i&&e>=48&&e<=57&&45==s?"\\"+e.toString(16)+" ":0==i&&1==r&&45==e||!(e>=128||45==e||95==e||e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)?"\\"+n.charAt(i):n.charAt(i):o+="�";return o};return t.CSS||(t.CSS={}),t.CSS.escape=e,e}(r)}({get exports(){return it},set exports(t){it=t}});var ot={"&":"&","<":"<",">":">",'"':""","'":"'"};function st(t){return(t=""+t)&&t.replace(/[&<>"']/g,(function(t){return ot[t]}))}function ut(t,e){var n=function(t){return t&&t.businessObject||t}(t);return n&&"function"==typeof n.$instanceOf&&n.$instanceOf(e)}var ct='<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',lt='<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',at='<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>',ft=500,pt={resolver:{resolveRule:function(){return null}},config:{}},dt={error:ct,warning:lt,success:at,inactive:at};function ht(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=pt,this._overlayIds={};var u=this;i.on(["import.done","elements.changed","linting.configChanged","linting.toggle"],ft,(function(t){u.isActive()&&u.update()})),i.on("linting.toggle",(function(t){t.active||(u._clearIssues(),u._updateButton())})),i.on("diagram.clear",(function(){u._clearIssues()}));var c=n&&n.bpmnlint;c&&i.once("diagram.init",(function(){if(u.getLinterConfig()===pt)try{u.setLinterConfig(c)}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 ht.prototype.setLinterConfig=function(t){if(!t.config||!t.resolver)throw new Error("Expected linterConfig = { config, resolver }");this._linterConfig=t,this._eventBus.fire("linting.configChanged")},ht.prototype.getLinterConfig=function(){return this._linterConfig},ht.prototype._init=function(){this._createButton(),this._updateButton()},ht.prototype.isActive=function(){return this._active},ht.prototype._formatIssues=function(t){let e=this,n=(r=function(t,e,n){return t.concat(e.map((function(t){return t.rule=n,t})))},i=[],G(t,(function(t,e){i=r(i,t,e)})),i);var r,i;const o=e._elementRegistry.filter((t=>ut(t,"bpmn:Participant"))).map((t=>t.businessObject));return n=function(t,e){let n=[];return G(t,(function(t,r){n.push(e(t,r))})),n}(n,(function(t){if(!e._elementRegistry.get(t.id)){t.isChildIssue=!0,t.actualElementId=t.id;const n=o.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=H(n,(function(t){return t.id})),n},ht.prototype.toggle=function(t){return t=void 0===t?!this.isActive():t,this._setActive(t),t},ht.prototype._setActive=function(t){this._active!==t&&(this._active=t,this._eventBus.fire("linting.toggle",{active:t}))},ht.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 u in n)t._issues[u]?n[u]!==t._issues[u]&&(i[u]=n[u]):o[u]=n[u];r=J(r,i),o=J(o,i),t._clearOverlays(),t._createIssues(o),t._issues=n,t._updateButton(),t._fireComplete(n)}}))}},ht.prototype._fireComplete=function(t){this._eventBus.fire("linting.completed",{issues:t})},ht.prototype._createIssues=function(t){for(var e in t)this._createElementIssues(e,t[e])},ht.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&&ut(n,"bpmn:Process")?(r="bottom-right",i={top:20,left:150}):s&&ut(n,"bpmn:SubProcess")?(r="bottom-right",i={top:50,left:150}):(r="top-right",i={top:-7,left:-7});var u=H(e,(function(t){return(t.isChildIssue?"child":"")+t.category})),c=u.error,l=u.warn,a=u.childerror,f=u.childwarn;if(c||l||a||f){var p=rt('<div class="bjsl-overlay bjsl-issues-'+r+'"></div>'),d=rt(c||a?'<div class="bjsl-icon bjsl-icon-error">'+ct+"</div>":'<div class="bjsl-icon bjsl-icon-warning">'+lt+"</div>"),h=rt('<div class="bjsl-dropdown"></div>'),g=rt('<div class="bjsl-dropdown-content"></div>'),v=rt('<div class="bjsl-issues"></div>'),y=rt('<div class="bjsl-current-element-issues"></div>'),m=rt("<ul></ul>");if(p.appendChild(d),p.appendChild(h),h.appendChild(g),g.appendChild(v),v.appendChild(y),y.appendChild(m),c&&this._addErrors(m,c),l&&this._addWarnings(m,l),a||f){var b=rt('<div class="bjsl-child-issues"></div>'),_=rt("<ul></ul>"),w=rt('<a class="bjsl-issue-heading">Issues for child elements:</a>');if(a&&this._addErrors(_,a),f&&this._addWarnings(_,f),c||l){var C=rt("<hr/>");b.appendChild(C)}b.appendChild(w),b.appendChild(_),v.appendChild(b)}this._overlayIds[t]=this._overlays.add(n,"linting",{position:i,html:p,scale:{min:.9}})}}},ht.prototype._addErrors=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"error",e)}))},ht.prototype._addWarnings=function(t,e){var n=this;e.forEach((function(e){n._addEntry(t,"warning",e)}))},ht.prototype._addEntry=function(t,e,n){var r=n.rule,i=this._translate(n.message),o=n.actualElementId,s=rt('<li class="'+e+'"><span class="icon"> '+dt[e]+'</span><a title="'+st(r)+": "+st(i)+'" data-rule="'+st(r)+'" data-message="'+st(i)+'">'+st(i)+"</a>"+(o?'<a class="bjsl-id-hint"><code>'+o+"</code></a>":"")+"</li>");t.appendChild(s)},ht.prototype._clearOverlays=function(){this._overlays.remove({type:"linting"}),this._overlayIds={}},ht.prototype._clearIssues=function(){this._issues={},this._clearOverlays()},ht.prototype._setButtonState=function(t,e,n){var r=this._button,i=dt[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},ht.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)},ht.prototype._createButton=function(){var t=this;this._button=rt('<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)},ht.prototype.lint=function(){var t=this._bpmnjs.getDefinitions();return new M.Linter(this._linterConfig).lint(t)},ht.$inject=["bpmnjs","canvas","config.linting","elementRegistry","eventBus","overlays","translate"],{__init__:["linting","lintingEditorActions"],linting:["type",ht],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(){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]}})); |
{ | ||
"name": "bpmn-js-bpmnlint", | ||
"version": "0.20.1", | ||
"version": "0.21.0", | ||
"description": "bpmn-js integration for bpmnlint", | ||
@@ -38,4 +38,4 @@ "main": "dist/index.js", | ||
"@rollup/plugin-terser": "^0.4.0", | ||
"bpmn-js": "^11.3.1", | ||
"bpmnlint": "^8.1.1", | ||
"bpmn-js": "^13.2.0", | ||
"bpmnlint": "^8.3.1", | ||
"bpmnlint-loader": "^0.1.6", | ||
@@ -45,3 +45,3 @@ "chai": "^4.3.7", | ||
"cross-env": "^7.0.3", | ||
"diagram-js": "^11.9.0", | ||
"diagram-js": "^12.2.0", | ||
"eslint": "^8.34.0", | ||
@@ -67,3 +67,3 @@ "eslint-plugin-bpmn-io": "^1.0.0", | ||
"dependencies": { | ||
"min-dash": "^4.0.0", | ||
"min-dash": "^4.1.1", | ||
"min-dom": "^4.1.0" | ||
@@ -70,0 +70,0 @@ }, |
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
168518
2879
Updatedmin-dash@^4.1.1