@srsergio/taptapp-ar 1.0.55 → 1.0.58

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/README.md CHANGED
@@ -147,7 +147,7 @@ Drop the component into your app. It handles camera permissions, scanning animat
147
147
  import { TaptappAR, mapDataToPropsConfig } from '@srsergio/taptapp-ar';
148
148
 
149
149
  const MyARComponent = ({ data }) => {
150
- // mapDataToPropsConfig helps you format your data for the component
150
+ // Use mapDataToPropsConfig to convert your raw data into ARConfig
151
151
  const config = mapDataToPropsConfig(data);
152
152
 
153
153
  return (
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./react/types.js";
1
+ export { ARConfig, ARDataItem, mapDataToPropsConfig } from "./react/types.js";
2
2
  export * from "./react/use-ar.js";
3
3
  export * from "./react/TaptappAR.js";
4
4
  export * from "./compiler/offline-compiler.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./react/types.js";
1
+ export { mapDataToPropsConfig } from "./react/types.js";
2
2
  export * from "./react/use-ar.js";
3
3
  export * from "./react/TaptappAR.js";
4
4
  export * from "./compiler/offline-compiler.js";
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
- import type { PropsConfig } from "./types.js";
2
+ import type { ARConfig } from "./types.js";
3
3
  export interface TaptappARProps {
4
- config: PropsConfig;
4
+ config: ARConfig;
5
5
  className?: string;
6
6
  showScanningOverlay?: boolean;
7
7
  showErrorOverlay?: boolean;
@@ -1,22 +1,25 @@
1
- export interface PropsConfig {
1
+ export interface ARConfig {
2
2
  cardId: string;
3
3
  targetImageSrc: string;
4
4
  targetTaarSrc: string;
5
5
  videoSrc: string;
6
+ overlaySrc: string;
6
7
  videoWidth: number;
7
8
  videoHeight: number;
8
9
  scale: number;
10
+ overlayType: "video" | "image";
9
11
  }
10
- export interface DataItem {
12
+ export interface ARDataItem {
11
13
  id: string;
12
- type: "photos" | "videoNative" | "ar";
14
+ type: "photos" | "videoNative" | "ar" | "imageOverlay";
13
15
  images?: {
14
16
  image: string;
15
17
  fileId: string;
16
18
  }[];
17
19
  url?: string;
20
+ fileId?: string;
18
21
  scale?: number;
19
22
  width?: number;
20
23
  height?: number;
21
24
  }
22
- export declare function mapDataToPropsConfig(data: any[]): PropsConfig;
25
+ export declare function mapDataToPropsConfig(data: ARDataItem[]): ARConfig;
@@ -1,14 +1,16 @@
1
1
  export function mapDataToPropsConfig(data) {
2
2
  const photos = data.find((item) => item.type === "photos");
3
- const video = data.find((item) => item.type === "videoNative");
3
+ const overlay = data.find((item) => item.type === "videoNative" || item.type === "imageOverlay");
4
4
  const ar = data.find((item) => item.type === "ar");
5
5
  return {
6
6
  cardId: photos?.id || "",
7
7
  targetImageSrc: photos?.images?.[0]?.image || "",
8
8
  targetTaarSrc: ar?.url || "",
9
- videoSrc: video?.url || "",
10
- videoWidth: video?.width || 0,
11
- videoHeight: video?.height || 0,
12
- scale: video?.scale || 1,
9
+ videoSrc: overlay?.url || "",
10
+ overlaySrc: overlay?.url || "",
11
+ videoWidth: overlay?.width || 0,
12
+ videoHeight: overlay?.height || 0,
13
+ scale: overlay?.scale || 1,
14
+ overlayType: overlay?.type === "videoNative" ? "video" : "image",
13
15
  };
14
16
  }
@@ -1,4 +1,4 @@
1
- import type { PropsConfig } from "./types.js";
1
+ import type { ARConfig } from "./types.js";
2
2
  export type ARStatus = "scanning" | "tracking" | "error";
3
3
  export interface UseARReturn {
4
4
  containerRef: React.RefObject<HTMLDivElement>;
@@ -7,4 +7,4 @@ export interface UseARReturn {
7
7
  isPlaying: boolean;
8
8
  toggleVideo: () => Promise<void>;
9
9
  }
10
- export declare const useAR: (config: PropsConfig) => UseARReturn;
10
+ export declare const useAR: (config: ARConfig) => UseARReturn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srsergio/taptapp-ar",
3
- "version": "1.0.55",
3
+ "version": "1.0.58",
4
4
  "author": "Sergio Lazaro <srsergiolazaro@gmail.com>",
5
5
  "license": "GPL-3.0",
6
6
  "description": "Ultra-fast, lightweight Augmented Reality Image Tracking SDK for the web. Features an optimized offline compiler, React components, and compatibility with Three.js/A-Frame. No heavy ML frameworks required.",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./react/types.js";
1
+ export { ARConfig, ARDataItem, mapDataToPropsConfig } from "./react/types.js";
2
2
  export * from "./react/use-ar.js";
3
3
  export * from "./react/TaptappAR.js";
4
4
  export * from "./compiler/offline-compiler.js";
@@ -1,9 +1,9 @@
1
1
  import React, { useMemo } from "react";
2
2
  import { useAR } from "./use-ar.js";
3
- import type { PropsConfig } from "./types.js";
3
+ import type { ARConfig } from "./types.js";
4
4
 
5
5
  export interface TaptappARProps {
6
- config: PropsConfig;
6
+ config: ARConfig;
7
7
  className?: string;
8
8
  showScanningOverlay?: boolean;
9
9
  showErrorOverlay?: boolean;
@@ -1,35 +1,40 @@
1
- export interface PropsConfig {
1
+ export interface ARConfig {
2
2
  cardId: string;
3
3
  targetImageSrc: string;
4
4
  targetTaarSrc: string;
5
5
  videoSrc: string;
6
+ overlaySrc: string; // Alias for preloading/compatibility
6
7
  videoWidth: number;
7
8
  videoHeight: number;
8
9
  scale: number;
10
+ overlayType: "video" | "image";
9
11
  }
10
12
 
11
- export interface DataItem {
13
+ export interface ARDataItem {
12
14
  id: string;
13
- type: "photos" | "videoNative" | "ar";
15
+ type: "photos" | "videoNative" | "ar" | "imageOverlay";
14
16
  images?: { image: string; fileId: string }[];
15
17
  url?: string;
18
+ fileId?: string;
16
19
  scale?: number;
17
20
  width?: number;
18
21
  height?: number;
19
22
  }
20
23
 
21
- export function mapDataToPropsConfig(data: any[]): PropsConfig {
24
+ export function mapDataToPropsConfig(data: ARDataItem[]): ARConfig {
22
25
  const photos = data.find((item) => item.type === "photos");
23
- const video = data.find((item) => item.type === "videoNative");
26
+ const overlay = data.find((item) => item.type === "videoNative" || item.type === "imageOverlay");
24
27
  const ar = data.find((item) => item.type === "ar");
25
28
 
26
29
  return {
27
30
  cardId: photos?.id || "",
28
31
  targetImageSrc: photos?.images?.[0]?.image || "",
29
32
  targetTaarSrc: ar?.url || "",
30
- videoSrc: video?.url || "",
31
- videoWidth: video?.width || 0,
32
- videoHeight: video?.height || 0,
33
- scale: video?.scale || 1,
33
+ videoSrc: overlay?.url || "",
34
+ overlaySrc: overlay?.url || "",
35
+ videoWidth: overlay?.width || 0,
36
+ videoHeight: overlay?.height || 0,
37
+ scale: overlay?.scale || 1,
38
+ overlayType: overlay?.type === "videoNative" ? "video" : "image",
34
39
  };
35
40
  }
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useRef, useState, useCallback } from "react";
2
- import type { PropsConfig } from "./types.js";
2
+ import type { ARConfig } from "./types.js";
3
3
  import type { SimpleAR as SimpleARType } from "../compiler/simple-ar.js";
4
4
 
5
5
  export type ARStatus = "scanning" | "tracking" | "error";
@@ -12,7 +12,7 @@ export interface UseARReturn {
12
12
  toggleVideo: () => Promise<void>;
13
13
  }
14
14
 
15
- export const useAR = (config: PropsConfig): UseARReturn => {
15
+ export const useAR = (config: ARConfig): UseARReturn => {
16
16
  const containerRef = useRef<HTMLDivElement>(null);
17
17
  const overlayRef = useRef<HTMLVideoElement | HTMLImageElement>(null);
18
18
  const [status, setStatus] = useState<ARStatus>("scanning");