@reearth/core 0.0.7-alpha.61 → 0.0.7-alpha.63

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.
package/dist/index.d.ts CHANGED
@@ -6,11 +6,11 @@ import { CSSProperties } from 'react';
6
6
  import { Feature as Feature_2 } from 'geojson';
7
7
  import { ForwardRefExoticComponent } from 'react';
8
8
  import { LineString } from 'geojson';
9
+ import { MemoExoticComponent } from 'react';
9
10
  import { MultiLineString } from 'geojson';
10
11
  import { MultiPoint } from 'geojson';
11
12
  import { MultiPolygon } from 'geojson';
12
13
  import { MutableRefObject } from 'react';
13
- import { NamedExoticComponent } from 'react';
14
14
  import { Point } from 'geojson';
15
15
  import { Polygon as Polygon_2 } from 'geojson';
16
16
  import { PropsWithoutRef } from 'react';
@@ -160,7 +160,6 @@ export declare type CameraProperty = {
160
160
 
161
161
  export declare type Cesium3DTilesAppearance = {
162
162
  show?: boolean;
163
- height?: number;
164
163
  color?: string;
165
164
  styleUrl?: string;
166
165
  shadows?: "disabled" | "enabled" | "cast_only" | "receive_only";
@@ -280,7 +279,7 @@ declare type CommonProps = {
280
279
  sketchEditingFeature?: SketchEditingFeature;
281
280
  };
282
281
 
283
- export declare function computeAtom(cache?: typeof globalDataFeaturesCache): WritableAtom<ComputedLayer | undefined, [Command], void>;
282
+ export declare function computeAtom(cache?: typeof globalDataFeaturesCache): WritableAtom<ComputedLayer | undefined, Command, void>;
284
283
 
285
284
  export declare type ComputedFeature = CommonFeature<"computedFeature"> & Partial<AppearanceTypes>;
286
285
 
@@ -335,9 +334,9 @@ declare type CoreContext = {
335
334
 
336
335
  export declare const coreContext: Context<CoreContext>;
337
336
 
338
- export declare const CoreVisualizer: NamedExoticComponent<CoreVisualizerProps & {
339
- children?: ReactNode | undefined;
340
- } & RefAttributes<MapRef>>;
337
+ export declare const CoreVisualizer: MemoExoticComponent<ForwardRefExoticComponent<CoreVisualizerProps & {
338
+ children?: ReactNode;
339
+ } & RefAttributes<MapRef>>>;
341
340
 
342
341
  export declare type CoreVisualizerProps = {
343
342
  engine?: EngineType;
@@ -368,22 +367,16 @@ export declare type CoreVisualizerProps = {
368
367
  onSketchFeatureDelete?: (layerId: string, featureId: string) => void;
369
368
  onInteractionModeChange?: (mode: InteractionModeType) => void;
370
369
  onAPIReady?: () => void;
371
- onCreditsUpdate?: (credits?: Credits) => void;
370
+ onCreditsUpdate?: (credits: Credit[]) => void;
372
371
  };
373
372
 
374
- export declare type CreditItem = {
373
+ export declare type Credit = {
375
374
  html?: string;
376
375
  };
377
376
 
378
- export declare type Credits = {
379
- engine: {
380
- cesium?: CreditItem;
381
- };
382
- lightbox: CreditItem[];
383
- screen: CreditItem[];
384
- };
377
+ export declare type CursorType = "auto" | "grab" | "crosshair";
385
378
 
386
- declare type CursorType = "default" | "auto" | "help" | "pointer" | "grab" | "crosshair" | "wait";
379
+ declare type CursorType_2 = "default" | "auto" | "help" | "pointer" | "grab" | "crosshair";
387
380
 
388
381
  export declare type Data = {
389
382
  type: DataType;
@@ -512,7 +505,7 @@ export declare type EngineProps = {
512
505
  shouldRender?: boolean;
513
506
  meta?: Record<string, unknown>;
514
507
  displayCredits?: boolean;
515
- layersRef?: RefObject<LayersRef | null>;
508
+ layersRef?: RefObject<LayersRef>;
516
509
  requestingRenderMode?: MutableRefObject<RequestingRenderMode>;
517
510
  timelineManagerRef?: TimelineManagerRef;
518
511
  onLayerSelect?: (layerId: string | undefined, featureId?: string, options?: LayerSelectionReason, info?: SelectedFeatureInfo) => void;
@@ -526,7 +519,7 @@ export declare type EngineProps = {
526
519
  onLayerSelectWithRectStart?: (e: LayerSelectWithRectStart) => void;
527
520
  onLayerSelectWithRectMove?: (e: LayerSelectWithRectMove) => void;
528
521
  onLayerSelectWithRectEnd?: (e: LayerSelectWithRectEnd) => void;
529
- onCreditsUpdate?: (credits?: Credits) => void;
522
+ onCreditsUpdate?: (credits: Credit[]) => void;
530
523
  };
531
524
 
532
525
  export declare type EngineRef = {
@@ -564,7 +557,7 @@ export declare type EngineRef = {
564
557
  type: SketchType;
565
558
  controlPoints: Position3d[];
566
559
  }) => LineString | Polygon_2 | MultiPolygon | Point | undefined;
567
- setCursor: (cursor: CursorType) => void;
560
+ setCursor: (cursor: CursorType_2) => void;
568
561
  flyTo: FlyTo;
569
562
  flyToBBox: (bbox: [number, number, number, number], options?: CameraOptions & {
570
563
  heading?: number;
@@ -603,7 +596,7 @@ export declare type EngineRef = {
603
596
  tick: () => Date | void;
604
597
  inViewport: (location?: LatLng) => boolean;
605
598
  onTick: TickEvent;
606
- tickEventCallback?: RefObject<TickEventCallback[] | null>;
599
+ tickEventCallback?: RefObject<TickEventCallback[]>;
607
600
  removeTickEventListener: TickEvent;
608
601
  findFeatureById: (layerId: string, featureId: string) => Feature | undefined;
609
602
  bringToFront: (layerId: string) => void;
@@ -615,7 +608,7 @@ export declare type EngineRef = {
615
608
  unselectFeatures: (layerId: string, featureId: string[]) => void;
616
609
  pickManyFromViewport: (windowPosition: [x: number, y: number], windowWidth: number, windowHeight: number, condition?: (f: PickedFeature) => boolean) => PickedFeature[] | undefined;
617
610
  calcRectangleControlPoint: (p1: Position3d, p2: Position3d, p3: Position3d) => [p1: Position3d, p2: Position3d, p3: Position3d];
618
- getCredits: () => Credits | undefined;
611
+ getCredits: () => Credit[] | undefined;
619
612
  } & MouseEventHandles;
620
613
 
621
614
  export declare const engines: {
@@ -772,17 +765,6 @@ export declare type FrustumAppearance = {
772
765
  length?: number;
773
766
  };
774
767
 
775
- export declare type GeoidProperty = {
776
- server: {
777
- url: string;
778
- geoidProperty: string;
779
- };
780
- };
781
-
782
- declare type GeoidRef = {
783
- getGeoidHeight: (lat?: number, lng?: number) => Promise<number | undefined>;
784
- };
785
-
786
768
  export declare type Geometry = Point | LineString | Polygon_2 | MultiPoint | MultiLineString | MultiPolygon;
787
769
 
788
770
  export declare type GeometryOptionsXYZ = {
@@ -794,11 +776,11 @@ export declare function getCompat(l: Layer | undefined): LayerCompat | undefined
794
776
 
795
777
  declare const globalDataFeaturesCache: {
796
778
  get: Atom_2<(key: string, key2: string) => Feature[] | undefined>;
797
- set: WritableAtom<null, [value: {
779
+ set: WritableAtom<null, {
798
780
  key: string;
799
781
  key2: string;
800
782
  value?: Feature[] | undefined;
801
- }], void> & {
783
+ }, void> & {
802
784
  init: null;
803
785
  };
804
786
  getAll: Atom_2<(key: string) => Feature[][] | undefined>;
@@ -1108,10 +1090,12 @@ export declare type LookAtDestination = {
1108
1090
  export declare type LUT = readonly ColorTuple[];
1109
1091
 
1110
1092
  declare const Map_2: ForwardRefExoticComponent< {
1111
- engines?: Record<string, Engine>;
1112
- engine?: string;
1113
- onAPIReady?: () => void;
1114
- } & Omit<Props_2, "Feature" | "viewerProperty" | "selectionReason" | "delegatedDataTypes" | "clusterComponent" | "selectedLayerId"> & Omit<EngineProps, "onLayerSelect" | "selectedLayerId" | "layerSelectionReason"> & Omit<SketchProps, "engineRef" | "SketchComponent" | "layersRef"> & RefAttributes<MapRef>>;
1093
+ engines?: Record<string, Engine> | undefined;
1094
+ engine?: string | undefined;
1095
+ onAPIReady?: (() => void) | undefined;
1096
+ } & Omit<Props_2, "Feature" | "viewerProperty" | "selectionReason" | "delegatedDataTypes" | "clusterComponent" | "selectedLayerId"> & Omit<EngineProps, "onLayerSelect" | "selectedLayerId" | "layerSelectionReason"> & Omit<SketchProps, "engineRef" | "SketchComponent" | "layersRef"> & {
1097
+ cursor?: CursorType | undefined;
1098
+ } & RefAttributes<MapRef>>;
1115
1099
  export { Map_2 as Map }
1116
1100
 
1117
1101
  export declare type MapRef = {
@@ -1119,7 +1103,6 @@ export declare type MapRef = {
1119
1103
  layers: WrappedRef<LayersRef>;
1120
1104
  sketch: WrappedRef<SketchRef>;
1121
1105
  spatialId?: WrappedRef<SpatialIdRef>;
1122
- geoid: WrappedRef<GeoidRef>;
1123
1106
  timeline?: TimelineManagerRef;
1124
1107
  };
1125
1108
 
@@ -1172,7 +1155,6 @@ export declare type ModelAppearance = {
1172
1155
  model?: string;
1173
1156
  url?: string;
1174
1157
  heightReference?: "none" | "clamp" | "relative";
1175
- height?: number;
1176
1158
  heading?: number;
1177
1159
  pitch?: number;
1178
1160
  roll?: number;
@@ -1356,7 +1338,9 @@ export declare type Props = {
1356
1338
  engines?: Record<string, Engine>;
1357
1339
  engine?: string;
1358
1340
  onAPIReady?: () => void;
1359
- } & Omit<Props_2, "Feature" | "clusterComponent" | "selectionReason" | "delegatedDataTypes" | "selectedLayerId" | "viewerProperty"> & Omit<EngineProps, "onLayerSelect" | "layerSelectionReason" | "selectedLayerId"> & Omit<SketchProps, "layersRef" | "engineRef" | "SketchComponent">;
1341
+ } & Omit<Props_2, "Feature" | "clusterComponent" | "selectionReason" | "delegatedDataTypes" | "selectedLayerId" | "viewerProperty"> & Omit<EngineProps, "onLayerSelect" | "layerSelectionReason" | "selectedLayerId"> & Omit<SketchProps, "layersRef" | "engineRef" | "SketchComponent"> & {
1342
+ cursor?: CursorType;
1343
+ };
1360
1344
 
1361
1345
  declare type Props_2 = Omit<Props_3, "atomMap" | "isHidden" | "selectedLayerId"> & {
1362
1346
  selectedLayer?: {
@@ -1367,7 +1351,7 @@ declare type Props_2 = Omit<Props_3, "atomMap" | "isHidden" | "selectedLayerId">
1367
1351
  hiddenLayers?: string[];
1368
1352
  viewerProperty?: ViewerProperty;
1369
1353
  requestingRenderMode?: MutableRefObject<RequestingRenderMode>;
1370
- engineRef?: RefObject<EngineRef | null>;
1354
+ engineRef?: RefObject<EngineRef>;
1371
1355
  onLayerSelect?: (layerId: string | undefined, featureId: string | undefined, layer: (() => Promise<ComputedLayer | undefined>) | undefined, reason: LayerSelectionReason | undefined, info: SelectedFeatureInfo | undefined) => void;
1372
1356
  onMount?: () => void;
1373
1357
  };
@@ -1551,8 +1535,8 @@ export declare type SketchOptions = {
1551
1535
  };
1552
1536
 
1553
1537
  export declare type SketchProps = {
1554
- layersRef: RefObject<LayersRef | null>;
1555
- engineRef: RefObject<EngineRef | null>;
1538
+ layersRef: RefObject<LayersRef>;
1539
+ engineRef: RefObject<EngineRef>;
1556
1540
  SketchComponent?: SketchComponentType;
1557
1541
  selectedFeature?: Feature;
1558
1542
  interactionMode?: InteractionModeType;
@@ -1616,16 +1600,9 @@ export declare type Spacing = {
1616
1600
  declare type SpatialIdPickSpaceOptions = {
1617
1601
  zoom?: number;
1618
1602
  maxHeight?: number;
1619
- minHeight?: number;
1603
+ color?: string;
1620
1604
  dataOnly?: boolean;
1621
1605
  rightClickToExit?: boolean;
1622
- color?: string;
1623
- outlineColor?: string;
1624
- groundIndicatorColor?: string;
1625
- selectorColor?: string;
1626
- selectorOutlineColor?: string;
1627
- verticalSpaceIndicatorColor?: string;
1628
- verticalSpaceIndicatorOutlineColor?: string;
1629
1606
  };
1630
1607
 
1631
1608
  declare type SpatialIdRef = {
@@ -1727,7 +1704,7 @@ declare type TimelineCommit = (PlayCommand | PauseCommand | SetTimeCommand | Set
1727
1704
  };
1728
1705
 
1729
1706
  export declare type TimelineCommitter = {
1730
- source: string;
1707
+ source: "widgetContext" | "pluginAPI" | "featureResource" | "storyTimelineBlock" | "storyPage" | "initialize";
1731
1708
  id?: string;
1732
1709
  };
1733
1710
 
@@ -1791,7 +1768,7 @@ export declare type Undefinable<T extends object> = {
1791
1768
 
1792
1769
  export declare function useGet<T>(value: T): () => T;
1793
1770
 
1794
- export declare const useVisualizer: () => RefObject<MapRef | null>;
1771
+ export declare const useVisualizer: () => RefObject<MapRef>;
1795
1772
 
1796
1773
  export declare type ValueType = keyof ValueTypes;
1797
1774
 
@@ -1816,7 +1793,6 @@ export declare type ValueTypes = {
1816
1793
 
1817
1794
  export declare type ViewerProperty = {
1818
1795
  globe?: GlobeProperty;
1819
- geoid?: GeoidProperty;
1820
1796
  terrain?: TerrainProperty;
1821
1797
  scene?: SceneProperty;
1822
1798
  tiles?: TileProperty[];
@@ -1836,7 +1812,7 @@ export declare type Viewport = {
1836
1812
  query: Record<string, string>;
1837
1813
  };
1838
1814
 
1839
- export declare type VisualizerContext = RefObject<MapRef | null>;
1815
+ export declare type VisualizerContext = RefObject<MapRef>;
1840
1816
 
1841
1817
  export declare type WrappedRef<T> = {
1842
1818
  [P in keyof T as T[P] extends (...args: any[]) => any ? P : never]: T[P] extends (...args: infer A) => infer R ? (...args: A) => R | undefined : never;
@@ -1845,8 +1821,38 @@ export declare type WrappedRef<T> = {
1845
1821
  export { }
1846
1822
 
1847
1823
 
1824
+ declare global {
1825
+ interface Window {
1826
+ REEARTH_E2E_ACCESS_TOKEN?: string;
1827
+ REEARTH_E2E_CESIUM_VIEWER?: any;
1828
+ }
1829
+ }
1830
+
1831
+
1848
1832
  declare module "@cesium/engine" {
1849
1833
  namespace SceneTransforms {
1850
1834
  function transformWindowToDrawingBuffer(scene: Scene, windowPosition: Cartesian2, result?: Cartesian2): Cartesian2;
1851
1835
  }
1852
1836
  }
1837
+
1838
+
1839
+ namespace SceneTransforms {
1840
+ function transformWindowToDrawingBuffer(scene: Scene, windowPosition: Cartesian2, result?: Cartesian2): Cartesian2;
1841
+ }
1842
+
1843
+
1844
+ declare global {
1845
+ namespace Vi {
1846
+ interface JestAssertion<T = any> extends jest.Matchers<void, T>, EmotionMatchers {
1847
+ toHaveStyleRule: EmotionMatchers["toHaveStyleRule"];
1848
+ }
1849
+ }
1850
+ }
1851
+
1852
+
1853
+ namespace Vi {
1854
+ interface JestAssertion<T = any> extends jest.Matchers<void, T>, EmotionMatchers {
1855
+ toHaveStyleRule: EmotionMatchers["toHaveStyleRule"];
1856
+ }
1857
+ }
1858
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reearth/core",
3
- "version": "0.0.7-alpha.61",
3
+ "version": "0.0.7-alpha.63",
4
4
  "author": "Re:Earth contributors <community@reearth.io>",
5
5
  "license": "Apache-2.0",
6
6
  "description": "A library that abstracts a map engine as one common API.",
@@ -204,6 +204,12 @@ export default function useHooks({
204
204
  ),
205
205
  );
206
206
 
207
+ // Store getComputedLayer in a ref to avoid recreating prototypes on every change
208
+ const getComputedLayerRef = useRef(getComputedLayer);
209
+ useEffect(() => {
210
+ getComputedLayerRef.current = getComputedLayer;
211
+ }, [getComputedLayer]);
212
+
207
213
  const lazyComputedLayerPrototype = useMemo<object>(() => {
208
214
  return objectFromGetter(
209
215
  // id and layer should not be accessible
@@ -212,12 +218,12 @@ export default function useHooks({
212
218
  const id: string | undefined = (this as any).id;
213
219
  if (!id || typeof id !== "string") throw new Error("layer ID is not specified");
214
220
 
215
- const layer = getComputedLayer(id);
221
+ const layer = getComputedLayerRef.current(id);
216
222
  if (!layer) return undefined;
217
223
  return (layer as any)[key];
218
224
  },
219
225
  );
220
- }, [getComputedLayer]);
226
+ }, []);
221
227
 
222
228
  const lazyLayerPrototype = useMemo<object>(() => {
223
229
  return objectFromGetter(layerKeys, function (key) {
@@ -237,7 +243,7 @@ export default function useHooks({
237
243
  else if (key === "isVisible") return layer.visible;
238
244
  // computed
239
245
  else if (key === "computed") {
240
- const computedLayer = getComputedLayer(layer.id);
246
+ const computedLayer = getComputedLayerRef.current(layer.id);
241
247
  if (!computedLayer) return undefined;
242
248
  const computed = Object.create(lazyComputedLayerPrototype);
243
249
  computed.id = id;
@@ -246,7 +252,7 @@ export default function useHooks({
246
252
 
247
253
  return (layer as any)[key];
248
254
  });
249
- }, [getComputedLayer, layerMap, lazyComputedLayerPrototype]);
255
+ }, [layerMap, lazyComputedLayerPrototype]);
250
256
 
251
257
  const findById = useCallback(
252
258
  (layerId: string): LazyLayer | undefined => {