bruce-cesium 6.6.9 → 6.7.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
- import { Cartes, Entity as Entity$1, Geometry, ProjectViewTile, ENVIRONMENT, EntityRelationType, EntityType, Calculator, Style, DelayQueue, LRUCache, BruceEvent, ObjectUtils, AccountConcept, EntityHistoricData, EntityLod, RecordChangeFeed, ZoomControl, EntityTag, Tileset, EntityCoords, Api, DataLab, EntitySource, ClientFile, MenuItem, EntityRelation, BruceApi, ProgramKey, Bounds, Carto, ProjectView, ProjectViewBookmark, ProjectViewLegacyTile, Camera, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session } from 'bruce-models';
1
+ import { Cartes, Entity as Entity$1, Geometry, ProjectViewTile, ENVIRONMENT, EntityRelationType, EntityType, Calculator, Style, DelayQueue, LRUCache, BruceEvent, ObjectUtils, AccountConcept, EntityHistoricData, EntityLod, RecordChangeFeed, ZoomControl, EntityTag, Tileset, EntityCoords, Api, DataLab, EntitySource, ClientFile, MenuItem, EntityRelation, BruceApi, ProgramKey, Bounds, Carto, ProjectView, ProjectViewBookmark, ProjectViewLegacyTile, Camera, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, DistanceDisplayCondition, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, BoundingSphere, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
3
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, HeightReference, HorizontalOrigin, VerticalOrigin, ClassificationType, ConstantPositionProperty, PolygonHierarchy, ShadowMode, PolylineGraphics, ArcType, CornerType, ColorBlendMode, Model, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, HeadingPitchRange, Cesium3DTileStyle, Cesium3DTileColorBlendMode, Ion, Cesium3DTileset, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, BoundingSphere, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -16113,7 +16113,16 @@ var TilesetOsmRenderManager;
16113
16113
  // Already exists, no need to re-initialize.
16114
16114
  return;
16115
16115
  }
16116
- const validToken = await ViewerUtils.AssertIonToken(Ion.defaultAccessToken);
16116
+ let validToken;
16117
+ if (Ion.defaultServer) {
16118
+ // Proxy server was set after verifying Ion availability upstream
16119
+ // (including template account fallback) — trust that check.
16120
+ validToken = true;
16121
+ }
16122
+ else {
16123
+ // No proxy; validate the legacy access token directly.
16124
+ validToken = await ViewerUtils.AssertIonToken(Ion.defaultAccessToken);
16125
+ }
16117
16126
  if (!validToken) {
16118
16127
  console.warn("'tileset-osm-render-manager.ts' could not locate a valid Cesium Ion token.");
16119
16128
  return;
@@ -23080,7 +23089,14 @@ var TileRenderEngine;
23080
23089
  // If we need a cesium token, and we don't have one, then we can't render this.
23081
23090
  let shouldCreate = true;
23082
23091
  if (NEEDS_CESIUM_TOKEN.includes(defaultImg.id)) {
23083
- shouldCreate = await ViewerUtils.AssertIonToken(Ion.defaultAccessToken);
23092
+ // Proxy server was set after verifying Ion availability upstream.
23093
+ if (Ion.defaultServer) {
23094
+ shouldCreate = true;
23095
+ }
23096
+ // Legacy route, to be killed off.
23097
+ else {
23098
+ shouldCreate = await ViewerUtils.AssertIonToken(Ion.defaultAccessToken);
23099
+ }
23084
23100
  }
23085
23101
  if (shouldCreate) {
23086
23102
  try {
@@ -23523,7 +23539,14 @@ var TileRenderEngine;
23523
23539
  // Cesium token is required for Cesium World Terrain.
23524
23540
  let shouldCreate = true;
23525
23541
  if (defaultTerr.id == ProjectViewTile.EDefaultTerrain.CesiumWorldTerrain) {
23526
- shouldCreate = await ViewerUtils.AssertIonToken(Ion.defaultAccessToken);
23542
+ // Proxy server was set after verifying Ion availability upstream
23543
+ if (Ion.defaultServer) {
23544
+ shouldCreate = true;
23545
+ }
23546
+ // Legacy route, to be killed off.
23547
+ else {
23548
+ shouldCreate = await ViewerUtils.AssertIonToken(Ion.defaultAccessToken);
23549
+ }
23527
23550
  }
23528
23551
  if (shouldCreate) {
23529
23552
  provider = await renderDefaultTerrTile(defaultTerr.id);
@@ -23855,31 +23878,27 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
23855
23878
  try {
23856
23879
  const bruceApi = getters.GetBruceApi();
23857
23880
  await bruceApi.Loading;
23858
- // Proxy path: token injected server-side.
23881
+ // Get token record to check availability.
23882
+ const { programKeys } = await ProgramKey.GetList({ api: bruceApi });
23883
+ const ionKey = programKeys.find(k => k.ProgramId === ProgramKey.EProgramId.CesiumIon);
23859
23884
  if (bruceApi.IsVersionAtLeast(BruceApi.VERSION_WITH_PROXIES)) {
23860
- Ion.defaultServer = bruceApi.GetBaseUrl() + "proxy/cesium-ion/";
23861
- Ion.defaultAccessToken = "proxy";
23862
- cTokenSet = true;
23885
+ // Marked as available.
23886
+ if (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Available) {
23887
+ Ion.defaultServer = bruceApi.GetBaseUrl() + "proxy/cesium-ion/";
23888
+ Ion.defaultAccessToken = "proxy";
23889
+ cTokenSet = true;
23890
+ }
23863
23891
  }
23864
- // Legacy path: fetch real Ion token from DB.
23865
- // Kill off once API instances are migrated.
23866
23892
  else {
23867
- try {
23868
- const { programKey } = await ProgramKey.Get({
23869
- programId: ProgramKey.EProgramId.CesiumIon,
23870
- api: bruceApi
23871
- });
23872
- if (programKey === null || programKey === void 0 ? void 0 : programKey.Key) {
23873
- const valid = await ViewerUtils.AssertIonToken(programKey.Key);
23874
- if (valid) {
23875
- Ion.defaultAccessToken = programKey.Key;
23876
- cTokenSet = true;
23877
- }
23893
+ // Legacy path: fetch real Ion token from DB.
23894
+ // Kill off once API instances are migrated.
23895
+ if (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Key) {
23896
+ const valid = await ViewerUtils.AssertIonToken(ionKey.Key);
23897
+ if (valid) {
23898
+ Ion.defaultAccessToken = ionKey.Key;
23899
+ cTokenSet = true;
23878
23900
  }
23879
23901
  }
23880
- catch (e) {
23881
- console.error(e);
23882
- }
23883
23902
  }
23884
23903
  }
23885
23904
  catch (e) {
@@ -29700,16 +29719,12 @@ var ViewerUtils;
29700
29719
  ViewerUtils$$1.CreateWidgets = CreateWidgets;
29701
29720
  /**
29702
29721
  * Returns if the given token is valid or not.
29703
- * This will perform a test request to Cesium API.
29722
+ * Returns true if the supplied Cesium Ion access token is valid by probing the Ion endpoint.
29723
+ * @warning don't use when going through the proxy API route.
29704
29724
  * @param token
29705
29725
  * @returns
29706
29726
  */
29707
29727
  async function AssertIonToken(token) {
29708
- // If routed through a proxy then we don't need auth on client side for it.
29709
- const defaultServer = Ion.defaultServer;
29710
- if (defaultServer && typeof defaultServer === "string" && !defaultServer.includes("cesium.com")) {
29711
- return true;
29712
- }
29713
29728
  if (!token) {
29714
29729
  return false;
29715
29730
  }
@@ -36314,7 +36329,7 @@ class WidgetViewBar extends Widget.AWidget {
36314
36329
  }
36315
36330
  }
36316
36331
 
36317
- const VERSION = "6.6.9";
36332
+ const VERSION = "6.7.1";
36318
36333
  /**
36319
36334
  * Updates the environment instance used by bruce-cesium to one specified.
36320
36335
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.