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.
@@ -1,6 +1,6 @@
1
1
  import * as Cesium from 'cesium';
2
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, HeightReference, Matrix4, ShaderSource, Ellipsoid, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, DistanceDisplayCondition, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ArcType, CornerType, ImageMaterialProperty, SceneTransforms, PolygonHierarchy, PolylineGraphics, Rectangle, FeatureDetection, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, CustomDataSource, GeometryInstance, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
- import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, Entity as Entity$1, EntityLod, EntityTag, EntityType, ObjectUtils, Style, Api, Carto, Geometry as Geometry$1, ClientFileValueMap, Color as Color$1, Bounds, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, AccountConcept, BruceApi, RecordChangeFeed, EntityRelation, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, UrlUtils, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, ProjectViewBookmarkGroup, EntityRelationType, EntityHistoricData } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, HeightReference, DistanceDisplayCondition, ShaderSource, Cartesian3, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, JulianDate, Quaternion, HeadingPitchRoll, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ArcType, CornerType, ImageMaterialProperty, SceneTransforms, PolygonHierarchy, PolylineGraphics, Rectangle, FeatureDetection, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, SceneMode, HeadingPitchRange, Cesium3DTileStyle, Ion, IonResource, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, OrthographicFrustum, EasingFunction, Cesium3DTileColorBlendMode, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CustomDataSource, GeometryInstance, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, Entity as Entity$1, EntityLod, EntityTag, EntityType, ObjectUtils, Style, Api, Carto, Geometry as Geometry$1, ClientFileValueMap, Color as Color$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, Bounds, BruceEvent, EntityCoords, DataLab, DelayQueue, AccountConcept, BruceApi, EntityRelation, RecordChangeFeed, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, ProjectViewBookmarkGroup, Session, Account, AccountLimits, UrlUtils, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType, EntityHistoricData } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -7157,10 +7157,59 @@ var EntityLabelGroup;
7157
7157
  };
7158
7158
  }
7159
7159
  EntityLabelGroup.FromEntity = FromEntity;
7160
+ /**
7161
+ * Returns if we need to resolve Entity data to create the label data.
7162
+ */
7163
+ function NeedsEntityData(options) {
7164
+ var _a;
7165
+ if (!options) {
7166
+ return false;
7167
+ }
7168
+ if ((_a = options.attributes) === null || _a === void 0 ? void 0 : _a.length) {
7169
+ return true;
7170
+ }
7171
+ return [
7172
+ options.text, options.icon, options.iconUrl, options.iconClass,
7173
+ options.iconColor, options.iconStatus, options.iconPriority, options.iconScale
7174
+ ].some(Array.isArray);
7175
+ }
7176
+ EntityLabelGroup.NeedsEntityData = NeedsEntityData;
7177
+ // How many entities to read at once, so a long hand-picked list does not arrive as a burst.
7178
+ const HYDRATE_AT_ONCE = 8;
7179
+ /*
7180
+ * Reads the entities behind items that name one without carrying it.
7181
+ */
7182
+ async function Hydrate(items, api, signal) {
7183
+ if (!api) {
7184
+ return items;
7185
+ }
7186
+ const hydrated = items.slice();
7187
+ for (let start = 0; start < hydrated.length; start += HYDRATE_AT_ONCE) {
7188
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
7189
+ return hydrated;
7190
+ }
7191
+ await Promise.all(hydrated.slice(start, start + HYDRATE_AT_ONCE).map(async (item, at) => {
7192
+ if (!(item === null || item === void 0 ? void 0 : item.entityId) || item.entity) {
7193
+ return;
7194
+ }
7195
+ try {
7196
+ const { entity } = await Entity$1.Get({ api, entityId: item.entityId, migrated: true });
7197
+ if (entity) {
7198
+ hydrated[start + at] = { ...item, entity };
7199
+ }
7200
+ }
7201
+ catch {
7202
+ // Rip.
7203
+ }
7204
+ }));
7205
+ }
7206
+ return hydrated;
7207
+ }
7208
+ EntityLabelGroup.Hydrate = Hydrate;
7160
7209
  /*
7161
7210
  * Uses the existing DataLab grammar, discarding actions and projections that cannot return Entities.
7162
7211
  */
7163
- async function Loader(source, api, signal) {
7212
+ async function Loader(source, api, signal, hydrate) {
7164
7213
  var _a;
7165
7214
  var _b;
7166
7215
  if (source.type === "provider") {
@@ -7172,7 +7221,13 @@ var EntityLabelGroup;
7172
7221
  if (!Array.isArray(items)) {
7173
7222
  throw new Error("Label JSON must be an array of label items");
7174
7223
  }
7175
- return async (offset, limit) => ({ items: items.slice(offset, offset + limit), hasMore: offset + limit < items.length });
7224
+ return async (offset, limit, signal) => {
7225
+ const page = items.slice(offset, offset + limit);
7226
+ return {
7227
+ items: hydrate ? await Hydrate(page, api, signal) : page,
7228
+ hasMore: offset + limit < items.length
7229
+ };
7230
+ };
7176
7231
  }
7177
7232
  if (!api) {
7178
7233
  throw new Error("DataLab label sources require API getters on the visual register");
@@ -7301,7 +7356,7 @@ var EntityLabelGroup;
7301
7356
  const items = new Map();
7302
7357
  let truncated = false;
7303
7358
  try {
7304
- const load = await Loader(definition.source, (_g = this.register.ApiGetters) === null || _g === void 0 ? void 0 : _g.GetBruceApi(), controller.signal);
7359
+ const load = await Loader(definition.source, (_g = this.register.ApiGetters) === null || _g === void 0 ? void 0 : _g.GetBruceApi(), controller.signal, NeedsEntityData(definition.options));
7305
7360
  let offset = 0;
7306
7361
  for (let pageNumber = 0;; pageNumber++) {
7307
7362
  if (controller.signal.aborted || this.register.Disposed) {
@@ -7507,10 +7562,11 @@ var EntityLabelGroup;
7507
7562
  this.pending.delete(id);
7508
7563
  const group = this.active.get(id);
7509
7564
  if (!group) {
7565
+ // Nothing to unindex. Say so only if there was a definition to forget.
7510
7566
  if (known) {
7511
7567
  this.notify();
7512
- return;
7513
7568
  }
7569
+ return;
7514
7570
  }
7515
7571
  this.unindex(id);
7516
7572
  this.active.delete(id);
@@ -50208,7 +50264,7 @@ var StyleUtils;
50208
50264
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
50209
50265
  })(StyleUtils || (StyleUtils = {}));
50210
50266
 
50211
- const VERSION = "7.4.0";
50267
+ const VERSION = "7.4.1";
50212
50268
  /**
50213
50269
  * Updates the environment instance used by bruce-cesium to one specified.
50214
50270
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.