@omnidotdev/rdk 0.6.0 → 0.8.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.
@@ -1 +1 @@
1
- {"version":3,"file":"FiducialAnchor.d.ts","sourceRoot":"","sources":["../../src/fiducial/FiducialAnchor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,mBAAmB;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,QAAA,MAAM,cAAc,GAAI,8EAOrB,mBAAmB,4CAqHrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"FiducialAnchor.d.ts","sourceRoot":"","sources":["../../src/fiducial/FiducialAnchor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,mBAAmB;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,QAAA,MAAM,cAAc,GAAI,8EAOrB,mBAAmB,4CA4HrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -7,6 +7,15 @@ export interface FiducialInternal {
7
7
  arSource: ArToolkitSource | null;
8
8
  arContext: ArToolkitContext | null;
9
9
  }
10
+ /**
11
+ * State returned by fiducial backend hook.
12
+ */
13
+ export interface FiducialBackendState extends FiducialInternal {
14
+ /** Whether the backend is still initializing (not yet ready). */
15
+ isPending: boolean;
16
+ /** Whether the backend is initialized and ready to use. */
17
+ isSuccess: boolean;
18
+ }
10
19
  export interface FiducialSessionOptions {
11
20
  /** Input source type. */
12
21
  sourceType?: "webcam" | "image" | "video";
@@ -1 +1 @@
1
- {"version":3,"file":"fiducialBackend.d.ts","sourceRoot":"","sources":["../../src/fiducial/fiducialBackend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EAChB,MAAM,2CAA2C,CAAC;AAInD,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AAGjE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,sBAAsB;IACrC,yBAAyB;IACzB,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IAC1C,6BAA6B;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB;IACtB,aAAa,CAAC,EAAE,OAAO,GAAG,kBAAkB,GAAG,MAAM,GAAG,iBAAiB,CAAC;IAC1E,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,cAAc,CAAC,EACX,KAAK,GACL,eAAe,GACf,cAAc,GACd,KAAK,GACL,gBAAgB,GAChB,gBAAgB,CAAC;CACtB;AAED;;GAEG;AACH,QAAA,MAAM,qBAAqB,GACzB,UAAU,sBAAsB,KAC/B,OAAO,CAAC,gBAAgB,CA+I1B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"fiducialBackend.d.ts","sourceRoot":"","sources":["../../src/fiducial/fiducialBackend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EAChB,MAAM,2CAA2C,CAAC;AAInD,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AAGjE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,iEAAiE;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,yBAAyB;IACzB,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;IAC1C,6BAA6B;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB;IACtB,aAAa,CAAC,EAAE,OAAO,GAAG,kBAAkB,GAAG,MAAM,GAAG,iBAAiB,CAAC;IAC1E,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,cAAc,CAAC,EACX,KAAK,GACL,eAAe,GACf,cAAc,GACd,KAAK,GACL,gBAAgB,GAChB,gBAAgB,CAAC;CACtB;AAED;;GAEG;AACH,QAAA,MAAM,qBAAqB,GACzB,UAAU,sBAAsB,KAC/B,OAAO,CAAC,gBAAgB,CA+I1B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -4,5 +4,5 @@ export { default as createFiducialBackend } from './fiducialBackend';
4
4
  export { default as useFiducialBackend } from './useFiducialBackend';
5
5
  export type { FiducialAnchorProps } from './FiducialAnchor';
6
6
  export type { FiducialSessionProps } from './FiducialSession';
7
- export type { FiducialInternal, FiducialSessionOptions, } from './fiducialBackend';
7
+ export type { FiducialBackendState, FiducialInternal, FiducialSessionOptions, } from './fiducialBackend';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fiducial/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAErE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EACV,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fiducial/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAErE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
@@ -1,14 +1,17 @@
1
- import { FiducialInternal } from './fiducialBackend';
1
+ import { FiducialBackendState } from './fiducialBackend';
2
2
  /**
3
3
  * Access the fiducial backend internals.
4
- * @returns fiducial backend or null if no fiducial session is active.
4
+ * @returns fiducial backend state. `isSuccess` can be checked to verify readiness.
5
5
  *
6
6
  * @example
7
7
  * ```tsx
8
- * const fiducial = useFiducialBackend();
9
- * const arContext = fiducial?.arContext;
8
+ * const { arContext, isSuccess } = useFiducialBackend();
9
+ *
10
+ * if (isSuccess && arContext) {
11
+ * // use `arContext`
12
+ * }
10
13
  * ```
11
14
  */
12
- declare const useFiducialBackend: () => FiducialInternal | null;
15
+ declare const useFiducialBackend: () => FiducialBackendState;
13
16
  export default useFiducialBackend;
14
17
  //# sourceMappingURL=useFiducialBackend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFiducialBackend.d.ts","sourceRoot":"","sources":["../../src/fiducial/useFiducialBackend.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;;;;GASG;AACH,QAAA,MAAM,kBAAkB,QAAO,gBAAgB,GAAG,IAMjD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"useFiducialBackend.d.ts","sourceRoot":"","sources":["../../src/fiducial/useFiducialBackend.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,mBAAmB,CAAC;AAYhF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,kBAAkB,QAAO,oBAc9B,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,36 @@
1
+ export interface GeoLineProps {
2
+ /** Array of coordinates forming the line. GeoJSON-style: [lon, lat, elevation?] */
3
+ coordinates: Array<[number, number, number?]>;
4
+ /**
5
+ * Line color.
6
+ * @default "#ff0000"
7
+ */
8
+ color?: string;
9
+ /**
10
+ * Whether line is dashed.
11
+ * @default false
12
+ */
13
+ isDashed?: boolean;
14
+ /**
15
+ * Dash size (requires isDashed=true).
16
+ * @default 3
17
+ */
18
+ dashSize?: number;
19
+ /**
20
+ * Line width (in world units).
21
+ * @default 1
22
+ */
23
+ lineWidth?: number;
24
+ /**
25
+ * Gap size (requires isDashed=true).
26
+ * @default 1
27
+ */
28
+ gapSize?: number;
29
+ }
30
+ /**
31
+ * Geolocation line component for rendering lines in AR space. Useful for e.g. roads, paths, and routes.
32
+ * Accepts an array of lon/lat coordinates in GeoJSON-style format.
33
+ */
34
+ declare const GeoLine: ({ coordinates, color, isDashed, dashSize, gapSize, lineWidth, }: GeoLineProps) => import("react").JSX.Element;
35
+ export default GeoLine;
36
+ //# sourceMappingURL=GeoLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeoLine.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeoLine.tsx"],"names":[],"mappings":"AAWA,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,QAAA,MAAM,OAAO,GAAI,iEAOd,YAAY,gCAyEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,35 @@
1
+ export interface GeoPolygonProps {
2
+ /** Outer ring coordinates. GeoJSON-style: [lon, lat, elevation?] */
3
+ coordinates: Array<[number, number, number?]>;
4
+ /**
5
+ * Optional inner rings (holes).
6
+ */
7
+ holes?: Array<Array<[number, number, number?]>>;
8
+ /**
9
+ * Fill color.
10
+ * @default "#ff0000"
11
+ */
12
+ color?: string;
13
+ /**
14
+ * Fill opacity (0-1).
15
+ * @default 1
16
+ */
17
+ opacity?: number;
18
+ /**
19
+ * Whether to render as wireframe.
20
+ * @default false
21
+ */
22
+ isWireframe?: boolean;
23
+ /**
24
+ * Side to render: front, back, or double.
25
+ * @default "double"
26
+ */
27
+ side?: "front" | "back" | "double";
28
+ }
29
+ /**
30
+ * Geolocation polygon component for rendering filled areas in AR space.
31
+ * Accepts an array of lon/lat coordinates in GeoJSON-style format.
32
+ */
33
+ declare const GeoPolygon: ({ coordinates, holes, color, opacity, isWireframe, side, }: GeoPolygonProps) => import("react").JSX.Element;
34
+ export default GeoPolygon;
35
+ //# sourceMappingURL=GeoPolygon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeoPolygon.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeoPolygon.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9C;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;CACpC;AAQD;;;GAGG;AACH,QAAA,MAAM,UAAU,GAAI,4DAOjB,eAAe,gCA6HjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GeolocationAnchor.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeolocationAnchor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,yBAAyB,EAAE,aAAa,CAAC,EACpD,iBAAiB;IACnB,wFAAwF;IACxF,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,QAAA,MAAM,iBAAiB,GAAI,2GAQxB,sBAAsB,gCA0DxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"GeolocationAnchor.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeolocationAnchor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,yBAAyB,EAAE,aAAa,CAAC,EACpD,iBAAiB;IACnB,wFAAwF;IACxF,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,QAAA,MAAM,iBAAiB,GAAI,2GAQxB,sBAAsB,gCA4DxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -17,7 +17,8 @@ export interface AnchorEntry {
17
17
  latitude: number;
18
18
  longitude: number;
19
19
  altitude: number;
20
- onAttach?: () => void;
20
+ /** Called once attached to LocAR scene. Receives locar instance for coordinate conversion. */
21
+ onAttach?: (locar: LocAR) => void;
21
22
  onGpsUpdate?: (position: GeolocationPosition, distMoved: number) => void;
22
23
  }
23
24
  /**
@@ -38,6 +39,15 @@ export interface GeolocationInternal {
38
39
  /** Get an anchor entry by ID. */
39
40
  getAnchor: (id: string) => AnchorEntry | undefined;
40
41
  }
42
+ /**
43
+ * State returned by geolocation backend hook.
44
+ */
45
+ export interface GeolocationBackendState extends GeolocationInternal {
46
+ /** Whether the backend is still initializing (not yet ready). */
47
+ isPending: boolean;
48
+ /** Whether the backend is initialized and ready to use. */
49
+ isSuccess: boolean;
50
+ }
41
51
  /**
42
52
  * Options for the geolocation backend.
43
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"geolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/geolocationBackend.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,aAAa,IAAI,KAAK,EACtB,MAAM,EACP,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,OAAO,CAAC;AAEjE;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,iBAAiB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,2CAA2C;IAC3C,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzD,6CAA6C;IAC7C,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iCAAiC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9E;AAED;;GAEG;AACH,QAAA,MAAM,wBAAwB,GAC5B,UAAU,yBAAyB,KAClC,OAAO,CAAC,mBAAmB,CA+N7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
1
+ {"version":3,"file":"geolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/geolocationBackend.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,aAAa,IAAI,KAAK,EACtB,MAAM,EACP,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,OAAO,CAAC;AAEjE;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,iBAAiB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,2CAA2C;IAC3C,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzD,6CAA6C;IAC7C,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iCAAiC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,iEAAiE;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9E;AAED;;GAEG;AACH,QAAA,MAAM,wBAAwB,GAC5B,UAAU,yBAAyB,KAClC,OAAO,CAAC,mBAAmB,CA+N7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -1,8 +1,12 @@
1
+ export { default as GeoLine } from './GeoLine';
1
2
  export { default as GeolocationAnchor } from './GeolocationAnchor';
2
3
  export { default as GeolocationSession } from './GeolocationSession';
4
+ export { default as GeoPolygon } from './GeoPolygon';
3
5
  export { default as createGeolocationBackend } from './geolocationBackend';
4
6
  export { default as useGeolocationBackend } from './useGeolocationBackend';
7
+ export type { GeoLineProps } from './GeoLine';
5
8
  export type { GeolocationAnchorProps } from './GeolocationAnchor';
6
9
  export type { GeolocationSessionProps } from './GeolocationSession';
7
- export type { AnchorEntry, GeolocationInternal, GeolocationSessionOptions, GpsUpdateEvent, } from './geolocationBackend';
10
+ export type { GeoPolygonProps } from './GeoPolygon';
11
+ export type { AnchorEntry, GeolocationBackendState, GeolocationInternal, GeolocationSessionOptions, GpsUpdateEvent, } from './geolocationBackend';
8
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geolocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAE3E,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,GACf,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geolocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAE3E,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EACV,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,GACf,MAAM,sBAAsB,CAAC"}
@@ -1,14 +1,17 @@
1
- import { GeolocationInternal } from './geolocationBackend';
1
+ import { GeolocationBackendState } from './geolocationBackend';
2
2
  /**
3
3
  * Access the geolocation backend internals.
4
- * @returns geolocation backend or null if no geolocation session is active.
4
+ * @returns geolocation backend state. `isSuccess` can be checked to verify readiness.
5
5
  *
6
6
  * @example
7
7
  * ```tsx
8
- * const geo = useGeolocationBackend();
9
- * const worldCoords = geo?.locar?.lonLatToWorldCoords(lon, lat);
8
+ * const { locar, isSuccess } = useGeolocationBackend();
9
+ *
10
+ * if (isSuccess && locar) {
11
+ * const worldCoords = locar.lonLatToWorldCoords(lon, lat);
12
+ * }
10
13
  * ```
11
14
  */
12
- declare const useGeolocationBackend: () => GeolocationInternal | null;
15
+ declare const useGeolocationBackend: () => GeolocationBackendState;
13
16
  export default useGeolocationBackend;
14
17
  //# sourceMappingURL=useGeolocationBackend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGeolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/useGeolocationBackend.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;;;;;;;GASG;AACH,QAAA,MAAM,qBAAqB,QAAO,mBAAmB,GAAG,IAMvD,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"useGeolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/useGeolocationBackend.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,uBAAuB,EAExB,MAAM,sBAAsB,CAAC;AAmB9B;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,qBAAqB,QAAO,uBAcjC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
package/build/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),h=require("@react-three/fiber"),C=require("react/jsx-runtime"),I=require("@ar-js-org/ar.js/three.js/build/ar-threex"),q=require("three"),E=require("locar"),x=require("@react-three/xr");var v=typeof document<"u"?document.currentScript:null;const p={FIDUCIAL:"fiducial",GEOLOCATION:"geolocation",IMMERSIVE:"immersive"},O=n=>{let e;const t=new Set,r=(i,f)=>{const l=typeof i=="function"?i(e):i;if(!Object.is(l,e)){const o=e;e=f??(typeof l!="object"||l===null)?l:Object.assign({},e,l),t.forEach(d=>d(e,o))}},c=()=>e,a={setState:r,getState:c,getInitialState:()=>u,subscribe:i=>(t.add(i),()=>t.delete(i))},u=e=n(r,c,a);return a},D=(n=>n?O(n):O),N=n=>n;function U(n,e=N){const t=m.useSyncExternalStore(n.subscribe,m.useCallback(()=>e(n.getState()),[n,e]),m.useCallback(()=>e(n.getInitialState()),[n,e]));return m.useDebugValue(t),t}const X=n=>{const e=D(n),t=r=>U(e,r);return Object.assign(t,e),t},H=(n=>X),W=n=>(e,t,r)=>{const c=r.subscribe;return r.subscribe=((A,a,u)=>{let i=A;if(a){const f=u?.equalityFn||Object.is;let l=A(r.getState());i=o=>{const d=A(o);if(!f(l,d)){const S=l;a(l=d,S)}},u?.fireImmediately&&a(l,l)}return c(i)}),n(e,t,r)},K=W,T=n=>Symbol.iterator in n,j=n=>"entries"in n,F=(n,e)=>{const t=n instanceof Map?n:new Map(n.entries()),r=e instanceof Map?e:new Map(e.entries());if(t.size!==r.size)return!1;for(const[c,s]of t)if(!r.has(c)||!Object.is(s,r.get(c)))return!1;return!0},V=(n,e)=>{const t=n[Symbol.iterator](),r=e[Symbol.iterator]();let c=t.next(),s=r.next();for(;!c.done&&!s.done;){if(!Object.is(c.value,s.value))return!1;c=t.next(),s=r.next()}return!!c.done&&!!s.done};function Y(n,e){return Object.is(n,e)?!0:typeof n!="object"||n===null||typeof e!="object"||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e)?!1:T(n)&&T(e)?j(n)&&j(e)?F(n,e):V(n,e):F({entries:()=>Object.entries(n)},{entries:()=>Object.entries(e)})}function Q(n){const e=m.useRef(void 0);return t=>{const r=n(t);return Y(e.current,r)?e.current:e.current=r}}const M=H()(K((n,e)=>({video:null,backends:new Map,immersiveStore:null,registerBackend:async(t,r)=>{try{const c=e(),s=new Set(c.backends.keys()),A=s.has(p.FIDUCIAL)||t.type===p.FIDUCIAL,a=s.has(p.GEOLOCATION)||t.type===p.GEOLOCATION;if(A&&a){const u="❌ [RDK] INCOMPATIBLE SESSIONS: fiducial and geolocation backends cannot be used together due to camera/video conflicts between AR.js and LocAR.js libraries. Use only one session type per app.";throw console.error(u),new Error(u)}await t.init({scene:r.scene,camera:r.camera,renderer:r.renderer}),n(u=>{const i=new Map(u.backends);return i.set(t.type,t),{backends:i}})}catch(c){throw console.error("[XRStore] Failed to register backend:",c),c}},unregisterBackend:t=>{n(r=>{const c=new Map(r.backends);c.delete(t.type);try{t.dispose?.()}catch(s){console.error("[XRStore] Error disposing backend:",s)}return{backends:c}})},setVideo:t=>{n({video:t})},updateBackends:t=>{const{backends:r}=e();for(const c of r.values())try{c.update?.(t)}catch(s){console.error("[XRStore] Backend update error:",s)}},setImmersiveStore:t=>{n({immersiveStore:t})}}))),L=()=>M.getState(),_=M.subscribe,y=n=>M(Q(t=>{const r={...t,isImmersive:t.backends.has(p.IMMERSIVE),immersive:t.immersiveStore||null};return n?n(r):r})),J=({children:n})=>{const{updateBackends:e}=y();return h.useFrame((t,r)=>{e(r)}),n},B=()=>y(t=>t.backends).get(p.FIDUCIAL)?.getInternal()??null,$=({patternUrl:n,barcodeValue:e,params:t,onMarkerFound:r,onMarkerLost:c,children:s})=>{const A=m.useRef(null),a=B(),u=m.useRef(!1),i=m.useRef(!1),f=m.useRef(null);return m.useEffect(()=>{if(!a)return;let l=!1;return(()=>{try{const{arContext:d}=a,S=A.current;if(!d||!S||l)return;if(S.visible=!1,i.current=!1,!d.arController){requestAnimationFrame(()=>{if(!A.current||l||!a.arContext?.arController)return;const g=new I.ArMarkerControls(a.arContext,A.current,{type:n?"pattern":e?"barcode":"unknown",patternUrl:n,barcodeValue:e,...t});f.current=g,i.current=!0});return}const w=new I.ArMarkerControls(d,S,{type:n?"pattern":e?"barcode":"unknown",patternUrl:n,barcodeValue:e,...t});f.current=w,i.current=!0}catch(d){console.error("Failed to initialize fiducial anchor:",d)}})(),()=>{l=!0;const d=f.current;typeof d?.dispose=="function"&&d.dispose(),i.current=!1}},[a,n,e,t]),h.useFrame(()=>{const l=A.current;if(!l||!i.current){l&&(l.visible=!1);return}const o=l.visible;o&&!u.current?(u.current=!0,r?.()):!o&&u.current&&(u.current=!1,c?.())}),C.jsx("group",{ref:A,visible:!1,children:s})},Z=({options:n={},children:e})=>{const{scene:t,camera:r,gl:c}=h.useThree(),{registerBackend:s,unregisterBackend:A}=y(),a=m.useRef(null),u=m.useRef(n);return u.current=n,m.useEffect(()=>{if(a.current)return;let i=!1;return(async()=>{try{const l=z(u.current);if(i)return;await s(l,{scene:t,camera:r,renderer:c}),a.current=l}catch(l){console.error("[FiducialSession] Failed to initialize:",l)}})(),()=>{i=!0,a.current&&(A(a.current),a.current=null)}},[t,r,c,s,A]),e},z=n=>{let e=null,t=null,r=null,c;return{type:p.FIDUCIAL,async init({camera:s,renderer:A}){e=new I.ArToolkitSource({sourceType:n?.sourceType??"webcam"}),await new Promise((i,f)=>{const l=setTimeout(()=>{f(new Error("AR source initialization timeout"))},1e4);e?.init(()=>{clearTimeout(l);const o=e?.domElement;o&&(o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.width="100vw",o.style.height="100vh",o.style.objectFit="cover",o.style.zIndex="-1",o.style.pointerEvents="none"),i()})});const a={cameraParametersUrl:n?.cameraParametersUrl??new URL("data:application/octet-stream;base64,AAACgAAAAeBAgwrsW6bUSwAAAAAAAAAAQHQ3KqAAAAAAAAAAAAAAAAAAAAAAAAAAQIL0K3dHyf9AbbNowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAAAAAAAAAAA/uWNa4AAAAL+3lTLAAAAAv17YFWAAAAA/VYLXIAAAAECCe0YgAAAAQIJlMOAAAABAdDcqoAAAAEBts2jAAAAAP+8OmzqkDy4=",typeof document>"u"?require("url").pathToFileURL(__filename).href:v&&v.tagName.toUpperCase()==="SCRIPT"&&v.src||new URL("index.cjs",document.baseURI).href).toString(),detectionMode:n?.detectionMode??"mono",patternRatio:n?.patternRatio??.5,matrixCodeType:n?.matrixCodeType??"3x3"};t=new I.ArToolkitContext(a),r=s;const u=()=>{e?.onResizeElement();const i=window.innerWidth,f=window.innerHeight;A.setSize(i,f,!1),e?.copyElementSizeTo(A.domElement),t?.arController&&e?.copyElementSizeTo(t.arController.canvas)};await new Promise((i,f)=>{const l=setTimeout(()=>{f(new Error("AR context initialization timeout"))},1e4);t?.init(()=>{clearTimeout(l);try{const o=t?.getProjectionMatrix();o&&s.projectionMatrix.copy(o),u(),i()}catch(o){f(o)}})}),window.addEventListener("resize",u),c=u},update(){if(!(!e||!t)&&!(!e.ready||!e.domElement))try{t.update(e.domElement);const s=t.getProjectionMatrix?.();r&&s&&r.projectionMatrix.copy(s)}catch(s){console.warn("AR.js update error:",s)}},dispose(){if(c&&(window.removeEventListener("resize",c),c=void 0),t&&typeof t.dispose=="function"&&t.dispose(),e?.domElement){const s=e.domElement.parentNode;s&&s.removeChild(e.domElement)}e=null,t=null,r=null},getInternal:()=>({arSource:e,arContext:t})}},G=()=>y(t=>t.backends).get(p.GEOLOCATION)?.getInternal()??null,ee=({latitude:n,longitude:e,altitude:t=0,isBillboard:r=!0,onAttach:c,onGpsUpdate:s,children:A})=>{const a=G(),{camera:u}=h.useThree(),[i]=m.useState(()=>new q.Group),f=m.useMemo(()=>Math.random().toString(36).slice(2,11),[]),l=m.useCallback(()=>{c?.()},[c]),o=m.useCallback((d,S)=>{s?.(d,S)},[s]);return m.useEffect(()=>{if(a)return a.registerAnchor(f,{anchor:i,isAttached:!1,latitude:n,longitude:e,altitude:t,onAttach:l,onGpsUpdate:o}),()=>{a.unregisterAnchor(f)}},[a,i,f,n,e,t,l,o]),h.useFrame(()=>{!r||!u||!a||!a.getAnchor(f)?.isAttached||i.lookAt(u.position)}),h.createPortal(C.jsx("group",{children:A}),i)},te=({options:n={},children:e})=>{const{scene:t,camera:r,gl:c}=h.useThree(),{registerBackend:s,unregisterBackend:A}=y(),a=m.useRef(null),u=m.useRef(n);return u.current=n,m.useEffect(()=>{if(a.current)return;let i=!1;return(async()=>{try{const l=P(u.current);if(i)return;await s(l,{scene:t,camera:r,renderer:c}),a.current=l}catch(l){console.error("[GeolocationSession] Failed to initialize:",l)}})(),()=>{i=!0,a.current&&(A(a.current),a.current=null)}},[t,r,c,s,A]),e},P=n=>{let e=null,t=null,r=null,c,s=null,A=null,a=null,u=null;const i=new Map;let f=null;const l=o=>{if(!(!e||o.isAttached))try{e.add(o.anchor,o.longitude,o.latitude,o.altitude),o.isAttached=!0,o.onAttach?.()}catch(d){console.error("❌ Failed to attach anchor:",d)}};return{type:p.GEOLOCATION,async init(o){const{camera:d,renderer:S,scene:w}=o;if(!w)throw new Error("[geolocationBackend] A THREE.Scene is required for location-based AR");A=d,a=S,u=w,e=new E.LocationBased(w,d),t=new E.Webcam(n?.webcamConstraints??{video:{facingMode:"environment"}}),s=b=>{f=b.position;for(const k of i.values())k.isAttached||l(k),k.onGpsUpdate?.(b.position,b.distMoved);n?.onGpsUpdate?.(b.position,b.distMoved)},e.on("gpsupdate",s),t.on("webcamstarted",b=>{w.background=b.texture}),t.on("webcamerror",b=>{console.error("[geolocationBackend] webcam error:",b)}),r=new E.DeviceOrientationControls(d),r.on("deviceorientationgranted",b=>{b.target?.connect?.()}),r.on("deviceorientationerror",b=>{console.error("[geolocationBackend] Device orientation error:",b)}),r.init?.(),e.on("gpserror",b=>{console.error("[geolocationBackend] gps error:",b)}),e.startGps(),typeof n?.fakeLat=="number"&&typeof n?.fakeLon=="number"&&e.fakeGps(n.fakeLon,n.fakeLat);const g=e.getLastKnownLocation();g!==null&&(f={coords:{longitude:g.longitude,latitude:g.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>g},timestamp:Date.now(),toJSON:()=>g});const R=()=>{if(!a||!A)return;const b=window.innerWidth,k=window.innerHeight;a.setSize(b,k,!1),A.aspect=b/k,A.updateProjectionMatrix?.()};R(),window.addEventListener("resize",R),c=R},update(){r?.update?.()},dispose(){e&&s&&e.off("gpsupdate",s),e?.stopGps?.(),t?.stop?.(),r?.dispose?.(),c&&(window.removeEventListener("resize",c),c=void 0);for(const o of i.values())if(o.isAttached)try{o.anchor.removeFromParent()}catch(d){console.error("⚠️ Error removing anchor:",d)}i.clear(),e=null,t=null,r=null,A=null,a=null,u=null,s=null,f=null},getInternal:()=>({locar:e,webcam:t,deviceOrientation:r,scene:u,camera:A,lastPosition:f,registerAnchor:(o,d)=>{i.set(o,d),f!==null&&!d.isAttached&&(l(d),d.onGpsUpdate?.(f,0))},unregisterAnchor:o=>{const d=i.get(o);if(d?.isAttached)try{d.anchor.removeFromParent()}catch(S){console.error(`⚠️ Error removing anchor ${o}:`,S)}i.delete(o)},getAnchor:o=>i.get(o)})}},ne=()=>({type:p.IMMERSIVE,init:()=>{},getInternal:()=>null}),re=({children:n})=>{const e=m.useMemo(()=>x.createXRStore(),[]);return m.useEffect(()=>{const t=L(),r=ne();return t.backends.set(p.IMMERSIVE,r),t.setImmersiveStore(e),()=>{t.backends.delete(p.IMMERSIVE),t.setImmersiveStore(null)}},[e]),C.jsx(x.XR,{store:e,children:n})};exports.BACKEND_TYPES=p;exports.FiducialAnchor=$;exports.FiducialSession=Z;exports.GeolocationAnchor=ee;exports.GeolocationSession=te;exports.ImmersiveSession=re;exports.XR=J;exports.createFiducialBackend=z;exports.createGeolocationBackend=P;exports.getXRStore=L;exports.subscribeToXRStore=_;exports.useFiducialBackend=B;exports.useGeolocationBackend=G;exports.useXRStore=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),R=require("@react-three/fiber"),v=require("react/jsx-runtime"),P=require("@ar-js-org/ar.js/three.js/build/ar-threex"),I=require("three"),re=require("three/addons/lines/Line2.js"),oe=require("three/addons/lines/LineGeometry.js"),se=require("three/addons/lines/LineMaterial.js"),N=require("locar"),U=require("@react-three/xr");var X=typeof document<"u"?document.currentScript:null;const b={FIDUCIAL:"fiducial",GEOLOCATION:"geolocation",IMMERSIVE:"immersive"},W=t=>{let e;const n=new Set,r=(s,f)=>{const u=typeof s=="function"?s(e):s;if(!Object.is(u,e)){const c=e;e=f??(typeof u!="object"||u===null)?u:Object.assign({},e,u),n.forEach(A=>A(e,c))}},i=()=>e,o={setState:r,getState:i,getInitialState:()=>d,subscribe:s=>(n.add(s),()=>n.delete(s))},d=e=t(r,i,o);return o},ce=(t=>t?W(t):W),ie=t=>t;function ae(t,e=ie){const n=m.useSyncExternalStore(t.subscribe,m.useCallback(()=>e(t.getState()),[t,e]),m.useCallback(()=>e(t.getInitialState()),[t,e]));return m.useDebugValue(n),n}const le=t=>{const e=ce(t),n=r=>ae(e,r);return Object.assign(n,e),n},ue=(t=>le),de=t=>(e,n,r)=>{const i=r.subscribe;return r.subscribe=((l,o,d)=>{let s=l;if(o){const f=d?.equalityFn||Object.is;let u=l(r.getState());s=c=>{const A=l(c);if(!f(u,A)){const h=u;o(u=A,h)}},d?.fireImmediately&&o(u,u)}return i(s)}),t(e,n,r)},Ae=de,_=t=>Symbol.iterator in t,H=t=>"entries"in t,K=(t,e)=>{const n=t instanceof Map?t:new Map(t.entries()),r=e instanceof Map?e:new Map(e.entries());if(n.size!==r.size)return!1;for(const[i,a]of n)if(!r.has(i)||!Object.is(a,r.get(i)))return!1;return!0},fe=(t,e)=>{const n=t[Symbol.iterator](),r=e[Symbol.iterator]();let i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function me(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:_(t)&&_(e)?H(t)&&H(e)?K(t,e):fe(t,e):K({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function ge(t){const e=m.useRef(void 0);return n=>{const r=t(n);return me(e.current,r)?e.current:e.current=r}}const q=ue()(Ae((t,e)=>({video:null,backends:new Map,immersiveStore:null,registerBackend:async(n,r)=>{try{const i=e(),a=new Set(i.backends.keys()),l=a.has(b.FIDUCIAL)||n.type===b.FIDUCIAL,o=a.has(b.GEOLOCATION)||n.type===b.GEOLOCATION;if(l&&o){const d="❌ [RDK] INCOMPATIBLE SESSIONS: fiducial and geolocation backends cannot be used together due to camera/video conflicts between AR.js and LocAR.js libraries. Use only one session type per app.";throw console.error(d),new Error(d)}await n.init({scene:r.scene,camera:r.camera,renderer:r.renderer}),t(d=>{const s=new Map(d.backends);return s.set(n.type,n),{backends:s}})}catch(i){throw console.error("[XRStore] Failed to register backend:",i),i}},unregisterBackend:n=>{t(r=>{const i=new Map(r.backends);i.delete(n.type);try{n.dispose?.()}catch(a){console.error("[XRStore] Error disposing backend:",a)}return{backends:i}})},setVideo:n=>{t({video:n})},updateBackends:n=>{const{backends:r}=e();for(const i of r.values())try{i.update?.(n)}catch(a){console.error("[XRStore] Backend update error:",a)}},setImmersiveStore:n=>{t({immersiveStore:n})}}))),V=()=>q.getState(),he=q.subscribe,C=t=>q(ge(n=>{const r={...n,isImmersive:n.backends.has(b.IMMERSIVE),immersive:n.immersiveStore||null};return t?t(r):r})),Se=({children:t})=>{const{updateBackends:e}=C();return R.useFrame((n,r)=>{e(r)}),t},pe={isPending:!0,isSuccess:!1,arSource:null,arContext:null},Y=()=>{const e=C(n=>n.backends).get(b.FIDUCIAL);return e?{...e.getInternal(),isPending:!1,isSuccess:!0}:pe},be=({patternUrl:t,barcodeValue:e,params:n,onMarkerFound:r,onMarkerLost:i,children:a})=>{const l=m.useRef(null),o=Y(),d=m.useRef(!1),s=m.useRef(!1),f=m.useRef(null);return m.useEffect(()=>{if(!o.isSuccess)return;let u=!1;return(()=>{try{const{arContext:A}=o,h=l.current;if(!A||!h||u)return;if(h.visible=!1,s.current=!1,!A.arController){requestAnimationFrame(()=>{if(!l.current||u||!o.arContext?.arController)return;const y=new P.ArMarkerControls(o.arContext,l.current,{type:t?"pattern":e?"barcode":"unknown",patternUrl:t,barcodeValue:e,...n});f.current=y,s.current=!0});return}const p=new P.ArMarkerControls(A,h,{type:t?"pattern":e?"barcode":"unknown",patternUrl:t,barcodeValue:e,...n});f.current=p,s.current=!0}catch(A){console.error("Failed to initialize fiducial anchor:",A)}})(),()=>{u=!0;const A=f.current;typeof A?.dispose=="function"&&A.dispose(),s.current=!1}},[o.isSuccess,o.arContext,t,e,n,o]),R.useFrame(()=>{const u=l.current;if(!u||!s.current){u&&(u.visible=!1);return}const c=u.visible;c&&!d.current?(d.current=!0,r?.()):!c&&d.current&&(d.current=!1,i?.())}),v.jsx("group",{ref:l,visible:!1,children:a})},we=({options:t={},children:e})=>{const{scene:n,camera:r,gl:i}=R.useThree(),{registerBackend:a,unregisterBackend:l}=C(),o=m.useRef(null),d=m.useRef(t);return d.current=t,m.useEffect(()=>{if(o.current)return;let s=!1;return(async()=>{try{const u=Q(d.current);if(s)return;await a(u,{scene:n,camera:r,renderer:i}),o.current=u}catch(u){console.error("[FiducialSession] Failed to initialize:",u)}})(),()=>{s=!0,o.current&&(l(o.current),o.current=null)}},[n,r,i,a,l]),e},Q=t=>{let e=null,n=null,r=null,i;return{type:b.FIDUCIAL,async init({camera:a,renderer:l}){e=new P.ArToolkitSource({sourceType:t?.sourceType??"webcam"}),await new Promise((s,f)=>{const u=setTimeout(()=>{f(new Error("AR source initialization timeout"))},1e4);e?.init(()=>{clearTimeout(u);const c=e?.domElement;c&&(c.style.position="fixed",c.style.top="0",c.style.left="0",c.style.width="100vw",c.style.height="100vh",c.style.objectFit="cover",c.style.zIndex="-1",c.style.pointerEvents="none"),s()})});const o={cameraParametersUrl:t?.cameraParametersUrl??new URL("data:application/octet-stream;base64,AAACgAAAAeBAgwrsW6bUSwAAAAAAAAAAQHQ3KqAAAAAAAAAAAAAAAAAAAAAAAAAAQIL0K3dHyf9AbbNowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAAAAAAAAAAA/uWNa4AAAAL+3lTLAAAAAv17YFWAAAAA/VYLXIAAAAECCe0YgAAAAQIJlMOAAAABAdDcqoAAAAEBts2jAAAAAP+8OmzqkDy4=",typeof document>"u"?require("url").pathToFileURL(__filename).href:X&&X.tagName.toUpperCase()==="SCRIPT"&&X.src||new URL("index.cjs",document.baseURI).href).toString(),detectionMode:t?.detectionMode??"mono",patternRatio:t?.patternRatio??.5,matrixCodeType:t?.matrixCodeType??"3x3"};n=new P.ArToolkitContext(o),r=a;const d=()=>{e?.onResizeElement();const s=window.innerWidth,f=window.innerHeight;l.setSize(s,f,!1),e?.copyElementSizeTo(l.domElement),n?.arController&&e?.copyElementSizeTo(n.arController.canvas)};await new Promise((s,f)=>{const u=setTimeout(()=>{f(new Error("AR context initialization timeout"))},1e4);n?.init(()=>{clearTimeout(u);try{const c=n?.getProjectionMatrix();c&&a.projectionMatrix.copy(c),d(),s()}catch(c){f(c)}})}),window.addEventListener("resize",d),i=d},update(){if(!(!e||!n)&&!(!e.ready||!e.domElement))try{n.update(e.domElement);const a=n.getProjectionMatrix?.();r&&a&&r.projectionMatrix.copy(a)}catch(a){console.warn("AR.js update error:",a)}},dispose(){if(i&&(window.removeEventListener("resize",i),i=void 0),n&&typeof n.dispose=="function"&&n.dispose(),e?.domElement){const a=e.domElement.parentNode;a&&a.removeChild(e.domElement)}e=null,n=null,r=null},getInternal:()=>({arSource:e,arContext:n})}},ye={isPending:!0,isSuccess:!1,locar:null,webcam:null,deviceOrientation:null,scene:null,camera:null,lastPosition:null,registerAnchor:()=>{},unregisterAnchor:()=>{},getAnchor:()=>{}},G=()=>{const e=C(n=>n.backends).get(b.GEOLOCATION);return e?{...e.getInternal(),isPending:!1,isSuccess:!0}:ye},ke=({coordinates:t,color:e="#ff0000",isDashed:n=!1,dashSize:r=3,gapSize:i=1,lineWidth:a=1})=>{const l=G(),[o]=m.useState(()=>new I.Group),d=m.useMemo(()=>Math.random().toString(36).slice(2,11),[]),[s,f]=m.useState(null);return m.useEffect(()=>{if(!l.isSuccess||t.length<2)return;const[u,c,A=0]=t[0],h=p=>{const[y,L,g=0]=t[0],[w,M]=p.lonLatToWorldCoords(y,L),k=t.map(([z,S,E=0])=>{const[T,j]=p.lonLatToWorldCoords(z,S);return new I.Vector3(T-w,E-g,j-M)}),x=new oe.LineGeometry().setFromPoints(k),O=new se.LineMaterial({color:e,dashSize:r,gapSize:i,dashed:n,worldUnits:!0,linewidth:a}),F=new re.Line2(x,O);n&&F.computeLineDistances(),f(F)};return l.registerAnchor(d,{anchor:o,isAttached:!1,latitude:c,longitude:u,altitude:A,onAttach:h}),()=>{l.unregisterAnchor(d)}},[l.isSuccess,l.registerAnchor,l.unregisterAnchor,d,o,t,e,n,r,i,a]),R.createPortal(v.jsx("group",{children:s&&v.jsx("primitive",{object:s})}),o)},Ee=({latitude:t,longitude:e,altitude:n=0,isBillboard:r=!0,onAttach:i,onGpsUpdate:a,children:l})=>{const o=G(),{camera:d}=R.useThree(),[s]=m.useState(()=>new I.Group),f=m.useMemo(()=>Math.random().toString(36).slice(2,11),[]),u=m.useCallback(()=>{i?.()},[i]),c=m.useCallback((A,h)=>{a?.(A,h)},[a]);return m.useEffect(()=>{if(o.isSuccess)return o.registerAnchor(f,{anchor:s,isAttached:!1,latitude:t,longitude:e,altitude:n,onAttach:u,onGpsUpdate:c}),()=>{o.unregisterAnchor(f)}},[o.isSuccess,o.registerAnchor,o.unregisterAnchor,s,f,t,e,n,u,c]),R.useFrame(()=>{!r||!d||!o.isSuccess||!o.getAnchor(f)?.isAttached||s.lookAt(d.position)}),R.createPortal(v.jsx("group",{children:l}),s)},Ie=({options:t={},children:e})=>{const{scene:n,camera:r,gl:i}=R.useThree(),{registerBackend:a,unregisterBackend:l}=C(),o=m.useRef(null),d=m.useRef(t);return d.current=t,m.useEffect(()=>{if(o.current)return;let s=!1;return(async()=>{try{const u=J(d.current);if(s)return;await a(u,{scene:n,camera:r,renderer:i}),o.current=u}catch(u){console.error("[GeolocationSession] Failed to initialize:",u)}})(),()=>{s=!0,o.current&&(l(o.current),o.current=null)}},[n,r,i,a,l]),e},ve={front:I.FrontSide,back:I.BackSide,double:I.DoubleSide},Re=({coordinates:t,holes:e,color:n="#ff0000",opacity:r=1,isWireframe:i=!1,side:a="double"})=>{const l=G(),[o]=m.useState(()=>new I.Group),d=m.useMemo(()=>Math.random().toString(36).slice(2,11),[]),[s,f]=m.useState(null);return m.useEffect(()=>{if(!l.isSuccess||t.length<3)return;const[u,c,A=0]=t[0],h=p=>{const[y,L,g=0]=t[0],[w,M]=p.lonLatToWorldCoords(y,L),k=[];for(const[S,E,T=0]of t){const[j,B]=p.lonLatToWorldCoords(S,E);k.push({x:j-w,z:B-M,elev:T-g})}const x=new I.Shape;x.moveTo(k[0].x,k[0].z);for(let S=1;S<k.length;S++)x.lineTo(k[S].x,k[S].z);if(x.closePath(),e&&e.length>0)for(const S of e){if(S.length<3)continue;const E=new I.Path,[T,j]=S[0],[B,Z]=p.lonLatToWorldCoords(T,j);E.moveTo(B-w,Z-M);for(let D=1;D<S.length;D++){const[$,ee]=S[D],[te,ne]=p.lonLatToWorldCoords($,ee);E.lineTo(te-w,ne-M)}E.closePath(),x.holes.push(E)}const O=new I.ShapeGeometry(x),z=k.reduce((S,E)=>S+E.elev,0)/k.length;O.rotateX(-Math.PI/2),f({geometry:O,avgElevation:z})};return l.registerAnchor(d,{anchor:o,isAttached:!1,latitude:c,longitude:u,altitude:A,onAttach:h}),()=>{l.unregisterAnchor(d)}},[l.isSuccess,l.registerAnchor,l.unregisterAnchor,d,o,t,e]),R.createPortal(v.jsx("group",{children:s&&v.jsx("group",{position:[0,s.avgElevation,0],children:v.jsx("mesh",{geometry:s.geometry,children:v.jsx("meshBasicMaterial",{color:n,opacity:r,transparent:r<1,wireframe:i,side:ve[a]})})})}),o)},J=t=>{let e=null,n=null,r=null,i,a=null,l=null,o=null,d=null;const s=new Map;let f=null;const u=c=>{if(!(!e||c.isAttached))try{e.add(c.anchor,c.longitude,c.latitude,c.altitude),c.isAttached=!0,c.onAttach?.(e)}catch(A){console.error("❌ Failed to attach anchor:",A)}};return{type:b.GEOLOCATION,async init(c){const{camera:A,renderer:h,scene:p}=c;if(!p)throw new Error("[geolocationBackend] A THREE.Scene is required for location-based AR");l=A,o=h,d=p,e=new N.LocationBased(p,A),n=new N.Webcam(t?.webcamConstraints??{video:{facingMode:"environment"}}),a=g=>{f=g.position;for(const w of s.values())w.isAttached||u(w),w.onGpsUpdate?.(g.position,g.distMoved);t?.onGpsUpdate?.(g.position,g.distMoved)},e.on("gpsupdate",a),n.on("webcamstarted",g=>{p.background=g.texture}),n.on("webcamerror",g=>{console.error("[geolocationBackend] webcam error:",g)}),r=new N.DeviceOrientationControls(A),r.on("deviceorientationgranted",g=>{g.target?.connect?.()}),r.on("deviceorientationerror",g=>{console.error("[geolocationBackend] Device orientation error:",g)}),r.init?.(),e.on("gpserror",g=>{console.error("[geolocationBackend] gps error:",g)}),e.startGps(),typeof t?.fakeLat=="number"&&typeof t?.fakeLon=="number"&&e.fakeGps(t.fakeLon,t.fakeLat);const y=e.getLastKnownLocation();y!==null&&(f={coords:{longitude:y.longitude,latitude:y.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>y},timestamp:Date.now(),toJSON:()=>y});const L=()=>{if(!o||!l)return;const g=window.innerWidth,w=window.innerHeight;o.setSize(g,w,!1),l.aspect=g/w,l.updateProjectionMatrix?.()};L(),window.addEventListener("resize",L),i=L},update(){r?.update?.()},dispose(){e&&a&&e.off("gpsupdate",a),e?.stopGps?.(),n?.stop?.(),r?.dispose?.(),i&&(window.removeEventListener("resize",i),i=void 0);for(const c of s.values())if(c.isAttached)try{c.anchor.removeFromParent()}catch(A){console.error("⚠️ Error removing anchor:",A)}s.clear(),e=null,n=null,r=null,l=null,o=null,d=null,a=null,f=null},getInternal:()=>({locar:e,webcam:n,deviceOrientation:r,scene:d,camera:l,lastPosition:f,registerAnchor:(c,A)=>{s.set(c,A),f!==null&&!A.isAttached&&(u(A),A.onGpsUpdate?.(f,0))},unregisterAnchor:c=>{const A=s.get(c);if(A?.isAttached)try{A.anchor.removeFromParent()}catch(h){console.error(`⚠️ Error removing anchor ${c}:`,h)}s.delete(c)},getAnchor:c=>s.get(c)})}},Le=()=>({type:b.IMMERSIVE,init:()=>{},getInternal:()=>null}),xe=({children:t})=>{const e=m.useMemo(()=>U.createXRStore(),[]);return m.useEffect(()=>{const n=V(),r=Le();return n.backends.set(b.IMMERSIVE,r),n.setImmersiveStore(e),()=>{n.backends.delete(b.IMMERSIVE),n.setImmersiveStore(null)}},[e]),v.jsx(U.XR,{store:e,children:t})};exports.BACKEND_TYPES=b;exports.FiducialAnchor=be;exports.FiducialSession=we;exports.GeoLine=ke;exports.GeoPolygon=Re;exports.GeolocationAnchor=Ee;exports.GeolocationSession=Ie;exports.ImmersiveSession=xe;exports.XR=Se;exports.createFiducialBackend=Q;exports.createGeolocationBackend=J;exports.getXRStore=V;exports.subscribeToXRStore=he;exports.useFiducialBackend=Y;exports.useGeolocationBackend=G;exports.useXRStore=C;