@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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/react/TaptappAR.d.ts +2 -2
- package/dist/react/types.d.ts +7 -4
- package/dist/react/types.js +7 -5
- package/dist/react/use-ar.d.ts +2 -2
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/react/TaptappAR.tsx +2 -2
- package/src/react/types.ts +14 -9
- package/src/react/use-ar.ts +2 -2
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
|
|
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
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ARConfig } from "./types.js";
|
|
3
3
|
export interface TaptappARProps {
|
|
4
|
-
config:
|
|
4
|
+
config: ARConfig;
|
|
5
5
|
className?: string;
|
|
6
6
|
showScanningOverlay?: boolean;
|
|
7
7
|
showErrorOverlay?: boolean;
|
package/dist/react/types.d.ts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
export interface
|
|
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
|
|
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:
|
|
25
|
+
export declare function mapDataToPropsConfig(data: ARDataItem[]): ARConfig;
|
package/dist/react/types.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export function mapDataToPropsConfig(data) {
|
|
2
2
|
const photos = data.find((item) => item.type === "photos");
|
|
3
|
-
const
|
|
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:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
}
|
package/dist/react/use-ar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
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:
|
|
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.
|
|
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
package/src/react/TaptappAR.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import { useAR } from "./use-ar.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ARConfig } from "./types.js";
|
|
4
4
|
|
|
5
5
|
export interface TaptappARProps {
|
|
6
|
-
config:
|
|
6
|
+
config: ARConfig;
|
|
7
7
|
className?: string;
|
|
8
8
|
showScanningOverlay?: boolean;
|
|
9
9
|
showErrorOverlay?: boolean;
|
package/src/react/types.ts
CHANGED
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
export interface
|
|
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
|
|
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:
|
|
24
|
+
export function mapDataToPropsConfig(data: ARDataItem[]): ARConfig {
|
|
22
25
|
const photos = data.find((item) => item.type === "photos");
|
|
23
|
-
const
|
|
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:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
}
|
package/src/react/use-ar.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState, useCallback } from "react";
|
|
2
|
-
import type {
|
|
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:
|
|
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");
|