bpmn-js 17.0.2 → 17.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-viewer v17.0.2
2
+ * bpmn-js - bpmn-viewer v17.2.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2024-02-16
11
+ * Date: 2024-03-22
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -5149,8 +5149,8 @@
5149
5149
  * @typedef { number | Partial<Padding> } PaddingConfig
5150
5150
  *
5151
5151
  * @typedef { {
5152
- * horizontal: 'center' | 'left';
5153
- * vertical: 'top' | 'center';
5152
+ * horizontal: 'center' | 'left' | 'right';
5153
+ * vertical: 'top' | 'middle';
5154
5154
  * } } Alignment
5155
5155
  *
5156
5156
  * @typedef { 'center-middle' | 'center-top' } AlignmentConfig
@@ -5414,7 +5414,7 @@
5414
5414
  /**
5415
5415
  * Creates a new label utility
5416
5416
  *
5417
- * @param {TextConfig} config
5417
+ * @param {TextConfig} [config]
5418
5418
  */
5419
5419
  function Text(config) {
5420
5420
 
@@ -7399,6 +7399,7 @@
7399
7399
  /**
7400
7400
  * @typedef {import('../../model/Types').Element} Element
7401
7401
  *
7402
+ * @typedef {import('./OutlineProvider').default} OutlineProvider
7402
7403
  * @typedef {import('../../core/EventBus').default} EventBus
7403
7404
  * @typedef {import('../../draw/Styles').default} Styles
7404
7405
  */
@@ -7557,7 +7558,7 @@
7557
7558
  * Returns the outline for an element.
7558
7559
  *
7559
7560
  * @param {Element} element
7560
- **/
7561
+ */
7561
7562
  Outline.prototype.getOutline = function(element) {
7562
7563
  var outline;
7563
7564
  var providers = this._getProviders();
@@ -8138,7 +8139,7 @@
8138
8139
  }, config && config.defaults);
8139
8140
 
8140
8141
  /**
8141
- * @type {Map<string, Overlay>}
8142
+ * @type {Record<string, Overlay>}
8142
8143
  */
8143
8144
  this._overlays = {};
8144
8145
 
@@ -8207,8 +8208,7 @@
8207
8208
  } else {
8208
8209
  return [];
8209
8210
  }
8210
- } else
8211
- if (search.type) {
8211
+ } else if (search.type) {
8212
8212
  return filter(this._overlays, matchPattern({ type: search.type }));
8213
8213
  } else {
8214
8214
 
@@ -9964,16 +9964,19 @@
9964
9964
  * @typedef { import('./index.js').ModuleDeclaration } ModuleDeclaration
9965
9965
  * @typedef { import('./index.js').ModuleDefinition } ModuleDefinition
9966
9966
  * @typedef { import('./index.js').InjectorContext } InjectorContext
9967
+ *
9968
+ * @typedef { import('./index.js').TypedDeclaration<any, any> } TypedDeclaration
9967
9969
  */
9968
9970
 
9969
9971
  /**
9970
9972
  * Create a new injector with the given modules.
9971
9973
  *
9972
9974
  * @param {ModuleDefinition[]} modules
9973
- * @param {InjectorContext} [parent]
9975
+ * @param {InjectorContext} [_parent]
9974
9976
  */
9975
- function Injector(modules, parent) {
9976
- parent = parent || {
9977
+ function Injector(modules, _parent) {
9978
+
9979
+ const parent = _parent || /** @type InjectorContext */ ({
9977
9980
  get: function(name, strict) {
9978
9981
  currentlyResolving.push(name);
9979
9982
 
@@ -9983,7 +9986,7 @@
9983
9986
  throw error(`No provider for "${ name }"!`);
9984
9987
  }
9985
9988
  }
9986
- };
9989
+ });
9987
9990
 
9988
9991
  const currentlyResolving = [];
9989
9992
  const providers = this._providers = Object.create(parent._providers || null);
@@ -10006,12 +10009,13 @@
10006
10009
  * @return {any}
10007
10010
  */
10008
10011
  function get(name, strict) {
10009
- if (!providers[name] && name.indexOf('.') !== -1) {
10012
+ if (!providers[name] && name.includes('.')) {
10013
+
10010
10014
  const parts = name.split('.');
10011
- let pivot = get(parts.shift());
10015
+ let pivot = get(/** @type { string } */ (parts.shift()));
10012
10016
 
10013
10017
  while (parts.length) {
10014
- pivot = pivot[parts.shift()];
10018
+ pivot = pivot[/** @type { string } */ (parts.shift())];
10015
10019
  }
10016
10020
 
10017
10021
  return pivot;
@@ -10051,6 +10055,9 @@
10051
10055
  }
10052
10056
  }
10053
10057
 
10058
+ /**
10059
+ * @type {string[]}
10060
+ */
10054
10061
  const inject = fn.$inject || parseAnnotations(fn);
10055
10062
  const dependencies = inject.map(dep => {
10056
10063
  if (hasOwnProp(locals, dep)) {
@@ -10062,7 +10069,7 @@
10062
10069
 
10063
10070
  return {
10064
10071
  fn: fn,
10065
- dependencies: dependencies
10072
+ dependencies
10066
10073
  };
10067
10074
  }
10068
10075
 
@@ -10082,7 +10089,7 @@
10082
10089
  } = fnDef(type);
10083
10090
 
10084
10091
  // instantiate var args constructor
10085
- const Constructor = Function.prototype.bind.apply(fn, [ null ].concat(dependencies));
10092
+ const Constructor = Function.prototype.bind.call(fn, null, ...dependencies);
10086
10093
 
10087
10094
  return new Constructor();
10088
10095
  }
@@ -10262,13 +10269,17 @@
10262
10269
  return;
10263
10270
  }
10264
10271
 
10265
- if (moduleDefinition[key][2] === 'private') {
10266
- providers[key] = moduleDefinition[key];
10272
+ const typeDeclaration = /** @type { TypedDeclaration } */ (
10273
+ moduleDefinition[key]
10274
+ );
10275
+
10276
+ if (typeDeclaration[2] === 'private') {
10277
+ providers[key] = typeDeclaration;
10267
10278
  return;
10268
10279
  }
10269
10280
 
10270
- const type = moduleDefinition[key][0];
10271
- const value = moduleDefinition[key][1];
10281
+ const type = typeDeclaration[0];
10282
+ const value = typeDeclaration[1];
10272
10283
 
10273
10284
  providers[key] = [ factoryMap[type], arrayUnwrap(type, value), type ];
10274
10285
  });
@@ -10656,6 +10667,7 @@
10656
10667
  * @typedef {import('../util/Types').Point} Point
10657
10668
  * @typedef {import('../util/Types').Rect} Rect
10658
10669
  * @typedef {import('../util/Types').RectTRBL} RectTRBL
10670
+ * @typedef {import('../util/Types').ScrollDelta} ScrollDelta
10659
10671
  */
10660
10672
 
10661
10673
  function round(number, resolution) {
@@ -11356,7 +11368,7 @@
11356
11368
  Canvas.prototype.setRootElement = function(rootElement) {
11357
11369
 
11358
11370
  if (rootElement === this._rootElement) {
11359
- return;
11371
+ return rootElement;
11360
11372
  }
11361
11373
 
11362
11374
  let plane;
@@ -11791,7 +11803,7 @@
11791
11803
  /**
11792
11804
  * Gets or sets the scroll of the canvas.
11793
11805
  *
11794
- * @param {Point} [delta] The scroll to be set.
11806
+ * @param {ScrollDelta} [delta] The scroll to be set.
11795
11807
  *
11796
11808
  * @return {Point}
11797
11809
  */
@@ -13162,6 +13174,8 @@
13162
13174
  * var sum = eventBus.fire('sum', 1, 2);
13163
13175
  * console.log(sum); // 3
13164
13176
  * ```
13177
+ *
13178
+ * @template [EventMap=null]
13165
13179
  */
13166
13180
  function EventBus() {
13167
13181
 
@@ -13175,8 +13189,9 @@
13175
13189
  this.on('diagram.destroy', 1, this._destroy, this);
13176
13190
  }
13177
13191
 
13178
-
13179
13192
  /**
13193
+ * @overlord
13194
+ *
13180
13195
  * Register an event listener for events with the given name.
13181
13196
  *
13182
13197
  * The callback will be invoked with `event, ...additionalArguments`
@@ -13195,6 +13210,25 @@
13195
13210
  * @param {EventBusEventCallback<T>} callback
13196
13211
  * @param {any} [that] callback context
13197
13212
  */
13213
+ /**
13214
+ * Register an event listener for events with the given name.
13215
+ *
13216
+ * The callback will be invoked with `event, ...additionalArguments`
13217
+ * that have been passed to {@link EventBus#fire}.
13218
+ *
13219
+ * Returning false from a listener will prevent the events default action
13220
+ * (if any is specified). To stop an event from being processed further in
13221
+ * other listeners execute {@link Event#stopPropagation}.
13222
+ *
13223
+ * Returning anything but `undefined` from a listener will stop the listener propagation.
13224
+ *
13225
+ * @template {keyof EventMap} EventName
13226
+ *
13227
+ * @param {EventName} events to subscribe to
13228
+ * @param {number} [priority=1000] listen priority
13229
+ * @param {EventBusEventCallback<EventMap[EventName]>} callback
13230
+ * @param {any} [that] callback context
13231
+ */
13198
13232
  EventBus.prototype.on = function(events, priority, callback, that) {
13199
13233
 
13200
13234
  events = isArray$2(events) ? events : [ events ];
@@ -13232,6 +13266,8 @@
13232
13266
  };
13233
13267
 
13234
13268
  /**
13269
+ * @overlord
13270
+ *
13235
13271
  * Register an event listener that is called only once.
13236
13272
  *
13237
13273
  * @template T
@@ -13241,6 +13277,16 @@
13241
13277
  * @param {EventBusEventCallback<T>} callback
13242
13278
  * @param {any} [that] callback context
13243
13279
  */
13280
+ /**
13281
+ * Register an event listener that is called only once.
13282
+ *
13283
+ * @template {keyof EventMap} EventName
13284
+ *
13285
+ * @param {EventName} events to subscribe to
13286
+ * @param {number} [priority=1000] listen priority
13287
+ * @param {EventBusEventCallback<EventMap[EventName]>} callback
13288
+ * @param {any} [that] callback context
13289
+ */
13244
13290
  EventBus.prototype.once = function(events, priority, callback, that) {
13245
13291
  var self = this;
13246
13292
 
@@ -13903,8 +13949,7 @@
13903
13949
 
13904
13950
  // update positioning
13905
13951
  translate$1(gfx, element.x, element.y);
13906
- } else
13907
- if (type === 'connection') {
13952
+ } else if (type === 'connection') {
13908
13953
  this.drawConnection(visual, element);
13909
13954
  } else {
13910
13955
  throw new Error('unknown type: ' + type);
@@ -13967,6 +14012,16 @@
13967
14012
  * } & Record<string, any> } DiagramOptions
13968
14013
  */
13969
14014
 
14015
+ /**
14016
+ * @template T
14017
+ * @typedef {import('didi').FactoryFunction<T>} FactoryFunction
14018
+ */
14019
+
14020
+ /**
14021
+ * @template T
14022
+ * @typedef {import('didi').ArrayFunc<T>} ArrayFunc
14023
+ */
14024
+
13970
14025
  /**
13971
14026
  * Bootstrap an injector from a list of modules, instantiating a number of default components
13972
14027
  *
@@ -13985,9 +14040,10 @@
13985
14040
  /**
13986
14041
  * Creates an injector from passed options.
13987
14042
  *
14043
+ * @template ServiceMap
13988
14044
  * @param {DiagramOptions} [options]
13989
14045
  *
13990
- * @return {Injector}
14046
+ * @return {Injector<ServiceMap>}
13991
14047
  */
13992
14048
  function createInjector(options) {
13993
14049
 
@@ -14014,6 +14070,7 @@
14014
14070
  *
14015
14071
  * @class
14016
14072
  * @constructor
14073
+ * @template [ServiceMap=null]
14017
14074
  *
14018
14075
  * @example Creating a plug-in that logs whenever a shape is added to the canvas.
14019
14076
  *
@@ -14052,44 +14109,17 @@
14052
14109
  * ```
14053
14110
  *
14054
14111
  * @param {DiagramOptions} [options]
14055
- * @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
14112
+ * @param {Injector<ServiceMap>} [injector] An (optional) injector to bootstrap the diagram with.
14056
14113
  */
14057
14114
  function Diagram(options, injector) {
14058
14115
 
14059
- this._injector = injector = injector || createInjector(options);
14060
-
14061
- // API
14062
-
14063
- /**
14064
- * Resolves a diagram service.
14065
- *
14066
- * @template T
14067
- *
14068
- * @param {string} name The name of the service to get.
14069
- * @param {boolean} [strict=true] If false, resolve missing services to null.
14070
- *
14071
- * @return {T|null}
14072
- */
14073
- this.get = injector.get;
14074
-
14075
14116
  /**
14076
- * Executes a function with its dependencies injected.
14077
- *
14078
- * @template T
14079
- *
14080
- * @param {Function} func function to be invoked
14081
- * @param {InjectionContext} [context] context of the invocation
14082
- * @param {LocalsMap} [locals] locals provided
14083
- *
14084
- * @return {T|null}
14117
+ * @type {Injector<ServiceMap>}
14085
14118
  */
14086
- this.invoke = injector.invoke;
14119
+ this._injector = injector || createInjector(options);
14087
14120
 
14088
14121
  // init
14089
14122
 
14090
- // indicate via event
14091
-
14092
-
14093
14123
  /**
14094
14124
  * An event indicating that all plug-ins are loaded.
14095
14125
  *
@@ -14112,6 +14142,82 @@
14112
14142
  this.get('eventBus').fire('diagram.init');
14113
14143
  }
14114
14144
 
14145
+ /**
14146
+ * @overlord
14147
+ *
14148
+ * Resolves a diagram service.
14149
+ *
14150
+ * @template T
14151
+ *
14152
+ * @param {string} name The name of the service to get.
14153
+ *
14154
+ * @return {T}
14155
+ */
14156
+ /**
14157
+ * @overlord
14158
+ *
14159
+ * Resolves a diagram service.
14160
+ *
14161
+ * @template T
14162
+ *
14163
+ * @param {string} name The name of the service to get.
14164
+ * @param {true} strict If false, resolve missing services to null.
14165
+ *
14166
+ * @return {T}
14167
+ */
14168
+ /**
14169
+ * @overlord
14170
+ *
14171
+ * Resolves a diagram service.
14172
+ *
14173
+ * @template T
14174
+ *
14175
+ * @param {string} name The name of the service to get.
14176
+ * @param {boolean} strict If false, resolve missing services to null.
14177
+ *
14178
+ * @return {T|null}
14179
+ */
14180
+ /**
14181
+ * Resolves a diagram service.
14182
+ *
14183
+ * @template {keyof ServiceMap} Name
14184
+ *
14185
+ * @param {Name} name The name of the service to get.
14186
+ *
14187
+ * @return {ServiceMap[Name]}
14188
+ */
14189
+ Diagram.prototype.get = function(name, strict) {
14190
+ return this._injector.get(name, strict);
14191
+ };
14192
+
14193
+ /**
14194
+ * @overlord
14195
+ *
14196
+ * Invoke the given function, injecting dependencies. Return the result.
14197
+ *
14198
+ * @template T
14199
+ *
14200
+ * @param {FactoryFunction<T>} func
14201
+ * @param {InjectionContext} [context]
14202
+ * @param {LocalsMap} [locals]
14203
+ *
14204
+ * @return {T}
14205
+ */
14206
+ /**
14207
+ * Invoke the given function, injecting dependencies provided in
14208
+ * array notation. Return the result.
14209
+ *
14210
+ * @template T
14211
+ *
14212
+ * @param {ArrayFunc<T>} func function to be invoked
14213
+ * @param {InjectionContext} [context] context of the invocation
14214
+ * @param {LocalsMap} [locals] locals provided
14215
+ *
14216
+ * @return {T}
14217
+ */
14218
+ Diagram.prototype.invoke = function(func, context, locals) {
14219
+ return this._injector.invoke(func, context, locals);
14220
+ };
14115
14221
 
14116
14222
  /**
14117
14223
  * Destroys the diagram