bruce-cesium 7.4.0 → 7.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7140,10 +7140,59 @@
7140
7140
  };
7141
7141
  }
7142
7142
  EntityLabelGroup.FromEntity = FromEntity;
7143
+ /**
7144
+ * Returns if we need to resolve Entity data to create the label data.
7145
+ */
7146
+ function NeedsEntityData(options) {
7147
+ var _a;
7148
+ if (!options) {
7149
+ return false;
7150
+ }
7151
+ if ((_a = options.attributes) === null || _a === void 0 ? void 0 : _a.length) {
7152
+ return true;
7153
+ }
7154
+ return [
7155
+ options.text, options.icon, options.iconUrl, options.iconClass,
7156
+ options.iconColor, options.iconStatus, options.iconPriority, options.iconScale
7157
+ ].some(Array.isArray);
7158
+ }
7159
+ EntityLabelGroup.NeedsEntityData = NeedsEntityData;
7160
+ // How many entities to read at once, so a long hand-picked list does not arrive as a burst.
7161
+ const HYDRATE_AT_ONCE = 8;
7162
+ /*
7163
+ * Reads the entities behind items that name one without carrying it.
7164
+ */
7165
+ async function Hydrate(items, api, signal) {
7166
+ if (!api) {
7167
+ return items;
7168
+ }
7169
+ const hydrated = items.slice();
7170
+ for (let start = 0; start < hydrated.length; start += HYDRATE_AT_ONCE) {
7171
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
7172
+ return hydrated;
7173
+ }
7174
+ await Promise.all(hydrated.slice(start, start + HYDRATE_AT_ONCE).map(async (item, at) => {
7175
+ if (!(item === null || item === void 0 ? void 0 : item.entityId) || item.entity) {
7176
+ return;
7177
+ }
7178
+ try {
7179
+ const { entity } = await BModels.Entity.Get({ api, entityId: item.entityId, migrated: true });
7180
+ if (entity) {
7181
+ hydrated[start + at] = { ...item, entity };
7182
+ }
7183
+ }
7184
+ catch {
7185
+ // Rip.
7186
+ }
7187
+ }));
7188
+ }
7189
+ return hydrated;
7190
+ }
7191
+ EntityLabelGroup.Hydrate = Hydrate;
7143
7192
  /*
7144
7193
  * Uses the existing DataLab grammar, discarding actions and projections that cannot return Entities.
7145
7194
  */
7146
- async function Loader(source, api, signal) {
7195
+ async function Loader(source, api, signal, hydrate) {
7147
7196
  var _a;
7148
7197
  var _b;
7149
7198
  if (source.type === "provider") {
@@ -7155,7 +7204,13 @@
7155
7204
  if (!Array.isArray(items)) {
7156
7205
  throw new Error("Label JSON must be an array of label items");
7157
7206
  }
7158
- return async (offset, limit) => ({ items: items.slice(offset, offset + limit), hasMore: offset + limit < items.length });
7207
+ return async (offset, limit, signal) => {
7208
+ const page = items.slice(offset, offset + limit);
7209
+ return {
7210
+ items: hydrate ? await Hydrate(page, api, signal) : page,
7211
+ hasMore: offset + limit < items.length
7212
+ };
7213
+ };
7159
7214
  }
7160
7215
  if (!api) {
7161
7216
  throw new Error("DataLab label sources require API getters on the visual register");
@@ -7284,7 +7339,7 @@
7284
7339
  const items = new Map();
7285
7340
  let truncated = false;
7286
7341
  try {
7287
- const load = await Loader(definition.source, (_g = this.register.ApiGetters) === null || _g === void 0 ? void 0 : _g.GetBruceApi(), controller.signal);
7342
+ const load = await Loader(definition.source, (_g = this.register.ApiGetters) === null || _g === void 0 ? void 0 : _g.GetBruceApi(), controller.signal, NeedsEntityData(definition.options));
7288
7343
  let offset = 0;
7289
7344
  for (let pageNumber = 0;; pageNumber++) {
7290
7345
  if (controller.signal.aborted || this.register.Disposed) {
@@ -7490,10 +7545,11 @@
7490
7545
  this.pending.delete(id);
7491
7546
  const group = this.active.get(id);
7492
7547
  if (!group) {
7548
+ // Nothing to unindex. Say so only if there was a definition to forget.
7493
7549
  if (known) {
7494
7550
  this.notify();
7495
- return;
7496
7551
  }
7552
+ return;
7497
7553
  }
7498
7554
  this.unindex(id);
7499
7555
  this.active.delete(id);
@@ -50068,7 +50124,7 @@ void main() {
50068
50124
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
50069
50125
  })(exports.StyleUtils || (exports.StyleUtils = {}));
50070
50126
 
50071
- const VERSION = "7.4.0";
50127
+ const VERSION = "7.4.1";
50072
50128
  /**
50073
50129
  * Updates the environment instance used by bruce-cesium to one specified.
50074
50130
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.