@ericchen1990/pano-view 3.10.0 → 4.0.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.
package/dist/data.d.mts CHANGED
@@ -542,7 +542,23 @@ type PanoDragMotion = {
542
542
  bounce?: boolean;
543
543
  };
544
544
 
545
- type PanoMapCorner = "top-left" | "top-right" | "bottom-left" | "bottom-right";
545
+ declare const PANO_OVERLAY_ALIGNS: readonly ["top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
546
+ type PanoOverlayAlign = (typeof PANO_OVERLAY_ALIGNS)[number];
547
+ type PanoOverlayAxis = "horizontal" | "vertical";
548
+ type PanoOverlayInset = number | string | {
549
+ top?: number | string;
550
+ right?: number | string;
551
+ bottom?: number | string;
552
+ left?: number | string;
553
+ };
554
+ /** Shared screen-edge anchor for planar overlay chrome. */
555
+ type PanoOverlayAnchor = {
556
+ align?: PanoOverlayAlign;
557
+ /** Used for corner anchors. Edges infer the axis and ignore this value. */
558
+ axis?: PanoOverlayAxis;
559
+ inset?: PanoOverlayInset;
560
+ };
561
+
546
562
  type PanoMapGradientStop = {
547
563
  offset: number;
548
564
  color: string;
@@ -594,28 +610,24 @@ type PanoMapSpotDefinition = {
594
610
  icon?: string;
595
611
  };
596
612
  type PanoMapControlsDefinition = {
597
- /** Show expand/collapse on a docked panel. */
613
+ /** Show the edge tab that slides a panel off-screen. */
598
614
  collapse?: boolean;
599
615
  /** Show zoom-in and zoom-out buttons. */
600
616
  zoom?: boolean;
601
617
  };
602
- type PanoMapDockedPresentation = {
603
- mode: "docked";
604
- corner?: PanoMapCorner;
618
+ type PanoMapPanelPresentation = {
619
+ mode: "panel";
620
+ anchor?: PanoOverlayAnchor;
605
621
  width?: number;
606
622
  height?: number;
607
- offsetX?: number;
608
- offsetY?: number;
609
623
  };
610
624
  type PanoMapDialogPresentation = {
611
625
  mode: "dialog";
612
- corner?: PanoMapCorner;
613
- offsetX?: number;
614
- offsetY?: number;
626
+ anchor?: PanoOverlayAnchor;
615
627
  width?: number;
616
628
  height?: number;
617
629
  };
618
- type PanoMapPresentation = PanoMapDockedPresentation | PanoMapDialogPresentation;
630
+ type PanoMapPresentation = PanoMapPanelPresentation | PanoMapDialogPresentation;
619
631
  type PanoMapDefinition = {
620
632
  image: string;
621
633
  /**
@@ -696,4 +708,4 @@ declare function parsePanoProject(value: unknown, options?: {
696
708
  }): PanoProjectDefinition;
697
709
  declare function loadPanoProject(source: string | PanoProjectDefinition, options?: LoadPanoProjectOptions): Promise<LoadedPanoProject>;
698
710
 
699
- export { type AssetUrlContext, type AssetUrlResolver, type CubemapViewerConfig, type JsonObject, type JsonRequestOptions, type JsonValue, type LoadPanoProjectOptions, type LoadSceneFromJsonOptions, type LoadedPanoProject, type LoadedProjectScene, PanoDataError, type PanoDataErrorCode, type PanoDragMotion, type PanoMapControlsDefinition, type PanoMapCorner, type PanoMapDefinition, type PanoMapDialogPresentation, type PanoMapDockedPresentation, type PanoMapGradientStop, type PanoMapPresentation, type PanoMapSectorDefinition, type PanoMapSectorGradient, type PanoMapSpotDefinition, type PanoProjectDefinition, type PanoProjectSceneDefinition, type PanoViewLimits, type PopupAssetUrlContext, type PopupAssetUrlResolver, type ProjectCustomHotspotAction, type ProjectHotspotAction, type ProjectHotspotDefinition, type ProjectHotspotTrigger, type ProjectPopupBlock, type ProjectPopupDefinition, type SceneFromViewerConfigOptions, type SphereViewerConfig, type ViewerConfig, type ViewerDocument, hotspotAction, loadPanoProject, loadSceneFromJson, parsePanoMap, parsePanoProject, projectHotspotTriggers, resolvePanoMapAssets, resolveHotspotAssets as resolveProjectHotspotAssets, resolveProjectPopupAssets, sceneFromViewerConfig, setHotspotAction };
711
+ export { type AssetUrlContext, type AssetUrlResolver, type CubemapViewerConfig, type JsonObject, type JsonRequestOptions, type JsonValue, type LoadPanoProjectOptions, type LoadSceneFromJsonOptions, type LoadedPanoProject, type LoadedProjectScene, PanoDataError, type PanoDataErrorCode, type PanoDragMotion, type PanoMapControlsDefinition, type PanoMapDefinition, type PanoMapDialogPresentation, type PanoMapGradientStop, type PanoMapPanelPresentation, type PanoMapPresentation, type PanoMapSectorDefinition, type PanoMapSectorGradient, type PanoMapSpotDefinition, type PanoProjectDefinition, type PanoProjectSceneDefinition, type PanoViewLimits, type PopupAssetUrlContext, type PopupAssetUrlResolver, type ProjectCustomHotspotAction, type ProjectHotspotAction, type ProjectHotspotDefinition, type ProjectHotspotTrigger, type ProjectPopupBlock, type ProjectPopupDefinition, type SceneFromViewerConfigOptions, type SphereViewerConfig, type ViewerConfig, type ViewerDocument, hotspotAction, loadPanoProject, loadSceneFromJson, parsePanoMap, parsePanoProject, projectHotspotTriggers, resolvePanoMapAssets, resolveHotspotAssets as resolveProjectHotspotAssets, resolveProjectPopupAssets, sceneFromViewerConfig, setHotspotAction };
package/dist/data.d.ts CHANGED
@@ -542,7 +542,23 @@ type PanoDragMotion = {
542
542
  bounce?: boolean;
543
543
  };
544
544
 
545
- type PanoMapCorner = "top-left" | "top-right" | "bottom-left" | "bottom-right";
545
+ declare const PANO_OVERLAY_ALIGNS: readonly ["top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
546
+ type PanoOverlayAlign = (typeof PANO_OVERLAY_ALIGNS)[number];
547
+ type PanoOverlayAxis = "horizontal" | "vertical";
548
+ type PanoOverlayInset = number | string | {
549
+ top?: number | string;
550
+ right?: number | string;
551
+ bottom?: number | string;
552
+ left?: number | string;
553
+ };
554
+ /** Shared screen-edge anchor for planar overlay chrome. */
555
+ type PanoOverlayAnchor = {
556
+ align?: PanoOverlayAlign;
557
+ /** Used for corner anchors. Edges infer the axis and ignore this value. */
558
+ axis?: PanoOverlayAxis;
559
+ inset?: PanoOverlayInset;
560
+ };
561
+
546
562
  type PanoMapGradientStop = {
547
563
  offset: number;
548
564
  color: string;
@@ -594,28 +610,24 @@ type PanoMapSpotDefinition = {
594
610
  icon?: string;
595
611
  };
596
612
  type PanoMapControlsDefinition = {
597
- /** Show expand/collapse on a docked panel. */
613
+ /** Show the edge tab that slides a panel off-screen. */
598
614
  collapse?: boolean;
599
615
  /** Show zoom-in and zoom-out buttons. */
600
616
  zoom?: boolean;
601
617
  };
602
- type PanoMapDockedPresentation = {
603
- mode: "docked";
604
- corner?: PanoMapCorner;
618
+ type PanoMapPanelPresentation = {
619
+ mode: "panel";
620
+ anchor?: PanoOverlayAnchor;
605
621
  width?: number;
606
622
  height?: number;
607
- offsetX?: number;
608
- offsetY?: number;
609
623
  };
610
624
  type PanoMapDialogPresentation = {
611
625
  mode: "dialog";
612
- corner?: PanoMapCorner;
613
- offsetX?: number;
614
- offsetY?: number;
626
+ anchor?: PanoOverlayAnchor;
615
627
  width?: number;
616
628
  height?: number;
617
629
  };
618
- type PanoMapPresentation = PanoMapDockedPresentation | PanoMapDialogPresentation;
630
+ type PanoMapPresentation = PanoMapPanelPresentation | PanoMapDialogPresentation;
619
631
  type PanoMapDefinition = {
620
632
  image: string;
621
633
  /**
@@ -696,4 +708,4 @@ declare function parsePanoProject(value: unknown, options?: {
696
708
  }): PanoProjectDefinition;
697
709
  declare function loadPanoProject(source: string | PanoProjectDefinition, options?: LoadPanoProjectOptions): Promise<LoadedPanoProject>;
698
710
 
699
- export { type AssetUrlContext, type AssetUrlResolver, type CubemapViewerConfig, type JsonObject, type JsonRequestOptions, type JsonValue, type LoadPanoProjectOptions, type LoadSceneFromJsonOptions, type LoadedPanoProject, type LoadedProjectScene, PanoDataError, type PanoDataErrorCode, type PanoDragMotion, type PanoMapControlsDefinition, type PanoMapCorner, type PanoMapDefinition, type PanoMapDialogPresentation, type PanoMapDockedPresentation, type PanoMapGradientStop, type PanoMapPresentation, type PanoMapSectorDefinition, type PanoMapSectorGradient, type PanoMapSpotDefinition, type PanoProjectDefinition, type PanoProjectSceneDefinition, type PanoViewLimits, type PopupAssetUrlContext, type PopupAssetUrlResolver, type ProjectCustomHotspotAction, type ProjectHotspotAction, type ProjectHotspotDefinition, type ProjectHotspotTrigger, type ProjectPopupBlock, type ProjectPopupDefinition, type SceneFromViewerConfigOptions, type SphereViewerConfig, type ViewerConfig, type ViewerDocument, hotspotAction, loadPanoProject, loadSceneFromJson, parsePanoMap, parsePanoProject, projectHotspotTriggers, resolvePanoMapAssets, resolveHotspotAssets as resolveProjectHotspotAssets, resolveProjectPopupAssets, sceneFromViewerConfig, setHotspotAction };
711
+ export { type AssetUrlContext, type AssetUrlResolver, type CubemapViewerConfig, type JsonObject, type JsonRequestOptions, type JsonValue, type LoadPanoProjectOptions, type LoadSceneFromJsonOptions, type LoadedPanoProject, type LoadedProjectScene, PanoDataError, type PanoDataErrorCode, type PanoDragMotion, type PanoMapControlsDefinition, type PanoMapDefinition, type PanoMapDialogPresentation, type PanoMapGradientStop, type PanoMapPanelPresentation, type PanoMapPresentation, type PanoMapSectorDefinition, type PanoMapSectorGradient, type PanoMapSpotDefinition, type PanoProjectDefinition, type PanoProjectSceneDefinition, type PanoViewLimits, type PopupAssetUrlContext, type PopupAssetUrlResolver, type ProjectCustomHotspotAction, type ProjectHotspotAction, type ProjectHotspotDefinition, type ProjectHotspotTrigger, type ProjectPopupBlock, type ProjectPopupDefinition, type SceneFromViewerConfigOptions, type SphereViewerConfig, type ViewerConfig, type ViewerDocument, hotspotAction, loadPanoProject, loadSceneFromJson, parsePanoMap, parsePanoProject, projectHotspotTriggers, resolvePanoMapAssets, resolveHotspotAssets as resolveProjectHotspotAssets, resolveProjectPopupAssets, sceneFromViewerConfig, setHotspotAction };
package/dist/data.mjs CHANGED
@@ -809,13 +809,56 @@ function resolveHotspotAssets(hotspot, baseUrl, sceneId, resolver) {
809
809
  return result;
810
810
  }
811
811
 
812
- // src/data/map.ts
813
- var CORNERS = /* @__PURE__ */ new Set([
812
+ // src/overlay/align.ts
813
+ var PANO_OVERLAY_ALIGNS = [
814
+ "top",
815
+ "bottom",
816
+ "left",
817
+ "right",
814
818
  "top-left",
815
819
  "top-right",
816
820
  "bottom-left",
817
821
  "bottom-right"
818
- ]);
822
+ ];
823
+ var ALIGN_LIST = PANO_OVERLAY_ALIGNS.join(", ");
824
+ function isRecord2(value) {
825
+ return typeof value === "object" && value !== null && !Array.isArray(value);
826
+ }
827
+ function parseInsetLength(value, field) {
828
+ if (typeof value === "number" && Number.isFinite(value)) return value;
829
+ if (typeof value === "string" && value.trim()) return value;
830
+ throw new Error(`${field}: expected a finite number or a nonempty string`);
831
+ }
832
+ function parseInset(value, field) {
833
+ if (typeof value === "number" || typeof value === "string") {
834
+ return parseInsetLength(value, field);
835
+ }
836
+ if (!isRecord2(value)) throw new Error(`${field}: expected a number, string, or object`);
837
+ const sides = ["top", "right", "bottom", "left"];
838
+ const inset = {};
839
+ for (const side of sides) {
840
+ if (value[side] === void 0) continue;
841
+ inset[side] = parseInsetLength(value[side], `${field}.${side}`);
842
+ }
843
+ return inset;
844
+ }
845
+ function parseOverlayAnchor(value, field) {
846
+ if (!isRecord2(value)) throw new Error(`${field}: expected an object`);
847
+ const align = value.align === void 0 ? void 0 : typeof value.align === "string" && PANO_OVERLAY_ALIGNS.includes(value.align) ? value.align : (() => {
848
+ throw new Error(`${field}.align: expected ${ALIGN_LIST}`);
849
+ })();
850
+ const axis = value.axis === void 0 ? void 0 : value.axis === "horizontal" || value.axis === "vertical" ? value.axis : (() => {
851
+ throw new Error(`${field}.axis: expected "horizontal" or "vertical"`);
852
+ })();
853
+ const inset = value.inset === void 0 ? void 0 : parseInset(value.inset, `${field}.inset`);
854
+ return {
855
+ ...align === void 0 ? {} : { align },
856
+ ...axis === void 0 ? {} : { axis },
857
+ ...inset === void 0 ? {} : { inset }
858
+ };
859
+ }
860
+
861
+ // src/data/map.ts
819
862
  function optionalNumber(record, key, options = {}) {
820
863
  const value = record[key];
821
864
  if (value === void 0) return void 0;
@@ -893,25 +936,29 @@ function parseSector(value, field) {
893
936
  function parsePresentation(value, field) {
894
937
  if (!isRecord(value)) throw new Error(`${field}: expected an object`);
895
938
  const mode = value.mode;
896
- if (mode !== "docked" && mode !== "dialog")
897
- throw new Error(`${field}.mode: expected "docked" or "dialog"`);
898
- const cornerValue = value.corner;
899
- const corner = cornerValue === void 0 ? void 0 : typeof cornerValue === "string" && CORNERS.has(cornerValue) ? cornerValue : (() => {
900
- throw new Error(
901
- `${field}.corner: expected top-left, top-right, bottom-left, or bottom-right`
902
- );
903
- })();
939
+ if (mode === "docked") {
940
+ throw new Error(`${field}.mode: "docked" was removed; expected "panel" or "dialog"`);
941
+ }
942
+ if (mode !== "panel" && mode !== "dialog") {
943
+ throw new Error(`${field}.mode: expected "panel" or "dialog"`);
944
+ }
945
+ if ("corner" in value) {
946
+ throw new Error(`${field}.corner: use anchor.align`);
947
+ }
948
+ if ("offsetX" in value) {
949
+ throw new Error(`${field}.offsetX: use anchor.inset`);
950
+ }
951
+ if ("offsetY" in value) {
952
+ throw new Error(`${field}.offsetY: use anchor.inset`);
953
+ }
954
+ const anchor = value.anchor === void 0 ? void 0 : parseOverlayAnchor(value.anchor, `${field}.anchor`);
904
955
  const width = optionalNumber(value, "width", { exclusiveMin: 0 });
905
956
  const height = optionalNumber(value, "height", { exclusiveMin: 0 });
906
- const offsetX = optionalNumber(value, "offsetX", { min: 0 });
907
- const offsetY = optionalNumber(value, "offsetY", { min: 0 });
908
957
  return {
909
958
  mode,
910
- ...corner === void 0 ? {} : { corner },
959
+ ...anchor === void 0 ? {} : { anchor },
911
960
  ...width === void 0 ? {} : { width },
912
- ...height === void 0 ? {} : { height },
913
- ...offsetX === void 0 ? {} : { offsetX },
914
- ...offsetY === void 0 ? {} : { offsetY }
961
+ ...height === void 0 ? {} : { height }
915
962
  };
916
963
  }
917
964
  function parseOptionalBoolean(value, field) {