@snap/react-camera-kit 0.0.1

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.
Files changed (132) hide show
  1. package/LICENSE.md +37 -0
  2. package/README.md +130 -0
  3. package/dist/cjs/CameraKitProvider.d.ts +203 -0
  4. package/dist/cjs/CameraKitProvider.d.ts.map +1 -0
  5. package/dist/cjs/CameraKitProvider.js +542 -0
  6. package/dist/cjs/CameraKitProvider.js.map +1 -0
  7. package/dist/cjs/Canvas.d.ts +7 -0
  8. package/dist/cjs/Canvas.d.ts.map +1 -0
  9. package/dist/cjs/Canvas.js +50 -0
  10. package/dist/cjs/Canvas.js.map +1 -0
  11. package/dist/cjs/LensPlayer.d.ts +101 -0
  12. package/dist/cjs/LensPlayer.d.ts.map +1 -0
  13. package/dist/cjs/LensPlayer.js +67 -0
  14. package/dist/cjs/LensPlayer.js.map +1 -0
  15. package/dist/cjs/index.d.ts +17 -0
  16. package/dist/cjs/index.d.ts.map +1 -0
  17. package/dist/cjs/index.js +34 -0
  18. package/dist/cjs/index.js.map +1 -0
  19. package/dist/cjs/internal/bootstrapUtils.d.ts +13 -0
  20. package/dist/cjs/internal/bootstrapUtils.d.ts.map +1 -0
  21. package/dist/cjs/internal/bootstrapUtils.js +29 -0
  22. package/dist/cjs/internal/bootstrapUtils.js.map +1 -0
  23. package/dist/cjs/internal/error.d.ts +2 -0
  24. package/dist/cjs/internal/error.d.ts.map +1 -0
  25. package/dist/cjs/internal/error.js +30 -0
  26. package/dist/cjs/internal/error.js.map +1 -0
  27. package/dist/cjs/internal/isMobile.d.ts +5 -0
  28. package/dist/cjs/internal/isMobile.d.ts.map +1 -0
  29. package/dist/cjs/internal/isMobile.js +15 -0
  30. package/dist/cjs/internal/isMobile.js.map +1 -0
  31. package/dist/cjs/internal/logging.d.ts +40 -0
  32. package/dist/cjs/internal/logging.d.ts.map +1 -0
  33. package/dist/cjs/internal/logging.js +63 -0
  34. package/dist/cjs/internal/logging.js.map +1 -0
  35. package/dist/cjs/internal/metrics.d.ts +29 -0
  36. package/dist/cjs/internal/metrics.d.ts.map +1 -0
  37. package/dist/cjs/internal/metrics.js +128 -0
  38. package/dist/cjs/internal/metrics.js.map +1 -0
  39. package/dist/cjs/internal/sessionUtils.d.ts +3 -0
  40. package/dist/cjs/internal/sessionUtils.d.ts.map +1 -0
  41. package/dist/cjs/internal/sessionUtils.js +17 -0
  42. package/dist/cjs/internal/sessionUtils.js.map +1 -0
  43. package/dist/cjs/internal/sourceUtils.d.ts +22 -0
  44. package/dist/cjs/internal/sourceUtils.d.ts.map +1 -0
  45. package/dist/cjs/internal/sourceUtils.js +143 -0
  46. package/dist/cjs/internal/sourceUtils.js.map +1 -0
  47. package/dist/cjs/package.json +1 -0
  48. package/dist/cjs/types.d.ts +96 -0
  49. package/dist/cjs/types.d.ts.map +1 -0
  50. package/dist/cjs/types.js +26 -0
  51. package/dist/cjs/types.js.map +1 -0
  52. package/dist/cjs/useApplyLens.d.ts +25 -0
  53. package/dist/cjs/useApplyLens.d.ts.map +1 -0
  54. package/dist/cjs/useApplyLens.js +87 -0
  55. package/dist/cjs/useApplyLens.js.map +1 -0
  56. package/dist/cjs/useApplySource.d.ts +11 -0
  57. package/dist/cjs/useApplySource.d.ts.map +1 -0
  58. package/dist/cjs/useApplySource.js +66 -0
  59. package/dist/cjs/useApplySource.js.map +1 -0
  60. package/dist/cjs/usePlaybackOptions.d.ts +38 -0
  61. package/dist/cjs/usePlaybackOptions.d.ts.map +1 -0
  62. package/dist/cjs/usePlaybackOptions.js +51 -0
  63. package/dist/cjs/usePlaybackOptions.js.map +1 -0
  64. package/dist/cjs/version.d.ts +3 -0
  65. package/dist/cjs/version.d.ts.map +1 -0
  66. package/dist/cjs/version.js +6 -0
  67. package/dist/cjs/version.js.map +1 -0
  68. package/dist/esm/CameraKitProvider.d.ts +203 -0
  69. package/dist/esm/CameraKitProvider.d.ts.map +1 -0
  70. package/dist/esm/CameraKitProvider.js +533 -0
  71. package/dist/esm/CameraKitProvider.js.map +1 -0
  72. package/dist/esm/Canvas.d.ts +7 -0
  73. package/dist/esm/Canvas.d.ts.map +1 -0
  74. package/dist/esm/Canvas.js +45 -0
  75. package/dist/esm/Canvas.js.map +1 -0
  76. package/dist/esm/LensPlayer.d.ts +101 -0
  77. package/dist/esm/LensPlayer.d.ts.map +1 -0
  78. package/dist/esm/LensPlayer.js +63 -0
  79. package/dist/esm/LensPlayer.js.map +1 -0
  80. package/dist/esm/index.d.ts +17 -0
  81. package/dist/esm/index.d.ts.map +1 -0
  82. package/dist/esm/index.js +13 -0
  83. package/dist/esm/index.js.map +1 -0
  84. package/dist/esm/internal/bootstrapUtils.d.ts +13 -0
  85. package/dist/esm/internal/bootstrapUtils.d.ts.map +1 -0
  86. package/dist/esm/internal/bootstrapUtils.js +26 -0
  87. package/dist/esm/internal/bootstrapUtils.js.map +1 -0
  88. package/dist/esm/internal/error.d.ts +2 -0
  89. package/dist/esm/internal/error.d.ts.map +1 -0
  90. package/dist/esm/internal/error.js +27 -0
  91. package/dist/esm/internal/error.js.map +1 -0
  92. package/dist/esm/internal/isMobile.d.ts +5 -0
  93. package/dist/esm/internal/isMobile.d.ts.map +1 -0
  94. package/dist/esm/internal/isMobile.js +12 -0
  95. package/dist/esm/internal/isMobile.js.map +1 -0
  96. package/dist/esm/internal/logging.d.ts +40 -0
  97. package/dist/esm/internal/logging.d.ts.map +1 -0
  98. package/dist/esm/internal/logging.js +58 -0
  99. package/dist/esm/internal/logging.js.map +1 -0
  100. package/dist/esm/internal/metrics.d.ts +29 -0
  101. package/dist/esm/internal/metrics.d.ts.map +1 -0
  102. package/dist/esm/internal/metrics.js +91 -0
  103. package/dist/esm/internal/metrics.js.map +1 -0
  104. package/dist/esm/internal/sessionUtils.d.ts +3 -0
  105. package/dist/esm/internal/sessionUtils.d.ts.map +1 -0
  106. package/dist/esm/internal/sessionUtils.js +14 -0
  107. package/dist/esm/internal/sessionUtils.js.map +1 -0
  108. package/dist/esm/internal/sourceUtils.d.ts +22 -0
  109. package/dist/esm/internal/sourceUtils.d.ts.map +1 -0
  110. package/dist/esm/internal/sourceUtils.js +139 -0
  111. package/dist/esm/internal/sourceUtils.js.map +1 -0
  112. package/dist/esm/types.d.ts +96 -0
  113. package/dist/esm/types.d.ts.map +1 -0
  114. package/dist/esm/types.js +20 -0
  115. package/dist/esm/types.js.map +1 -0
  116. package/dist/esm/useApplyLens.d.ts +25 -0
  117. package/dist/esm/useApplyLens.d.ts.map +1 -0
  118. package/dist/esm/useApplyLens.js +81 -0
  119. package/dist/esm/useApplyLens.js.map +1 -0
  120. package/dist/esm/useApplySource.d.ts +11 -0
  121. package/dist/esm/useApplySource.d.ts.map +1 -0
  122. package/dist/esm/useApplySource.js +60 -0
  123. package/dist/esm/useApplySource.js.map +1 -0
  124. package/dist/esm/usePlaybackOptions.d.ts +38 -0
  125. package/dist/esm/usePlaybackOptions.d.ts.map +1 -0
  126. package/dist/esm/usePlaybackOptions.js +48 -0
  127. package/dist/esm/usePlaybackOptions.js.map +1 -0
  128. package/dist/esm/version.d.ts +3 -0
  129. package/dist/esm/version.d.ts.map +1 -0
  130. package/dist/esm/version.js +3 -0
  131. package/dist/esm/version.js.map +1 -0
  132. package/package.json +94 -0
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
+ import { useInternalCameraKit } from "./CameraKitProvider";
4
+ // --- Internal helper hookup -------------------------------------------------
5
+ function attachCanvas(container, canvas) {
6
+ if (!container.contains(canvas))
7
+ container.appendChild(canvas);
8
+ }
9
+ function detachCanvas(container, canvas) {
10
+ if (container?.contains(canvas))
11
+ container.removeChild(canvas);
12
+ }
13
+ // --- Live child -------------------------------------------------------------
14
+ export const LiveCanvas = ({ className, style }) => {
15
+ const { currentSession } = useInternalCameraKit();
16
+ const containerRef = useRef(null);
17
+ useEffect(() => {
18
+ if (!currentSession || !containerRef.current)
19
+ return;
20
+ attachCanvas(containerRef.current, currentSession.output.live);
21
+ currentSession.play("live");
22
+ return () => {
23
+ detachCanvas(containerRef.current, currentSession.output.live);
24
+ currentSession.pause("live");
25
+ };
26
+ }, [currentSession]);
27
+ return _jsx("div", { ref: containerRef, className: className, style: style });
28
+ };
29
+ // --- Capture child ----------------------------------------------------------
30
+ export const CaptureCanvas = ({ className, style }) => {
31
+ const { currentSession } = useInternalCameraKit();
32
+ const containerRef = useRef(null);
33
+ useEffect(() => {
34
+ if (!currentSession || !containerRef.current)
35
+ return;
36
+ attachCanvas(containerRef.current, currentSession.output.capture);
37
+ currentSession.play("capture");
38
+ return () => {
39
+ detachCanvas(containerRef.current, currentSession.output.capture);
40
+ currentSession.pause("capture");
41
+ };
42
+ }, [currentSession]);
43
+ return _jsx("div", { ref: containerRef, className: className, style: style });
44
+ };
45
+ //# sourceMappingURL=Canvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../../src/Canvas.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAO3D,+EAA+E;AAC/E,SAAS,YAAY,CAAC,SAAsB,EAAE,MAAyB;IACrE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,YAAY,CAAC,SAA6B,EAAE,MAAyB;IAC5E,IAAI,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC;QAAE,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AACjE,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAA+B,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;IAC7E,MAAM,EAAE,cAAc,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAClD,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,cAAc,IAAI,CAAC,YAAY,CAAC,OAAO;YAAE,OAAO;QAErD,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/D,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE5B,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC/D,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,OAAO,cAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;AACxE,CAAC,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,aAAa,GAA+B,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;IAChF,MAAM,EAAE,cAAc,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAClD,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,cAAc,IAAI,CAAC,YAAY,CAAC,OAAO;YAAE,OAAO;QAErD,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClE,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE/B,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,YAAY,CAAC,OAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACnE,cAAc,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,OAAO,cAAK,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;AACxE,CAAC,CAAC","sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useInternalCameraKit } from \"./CameraKitProvider\";\n\nexport interface CanvasChildProps {\n className?: string;\n style?: React.CSSProperties;\n}\n\n// --- Internal helper hookup -------------------------------------------------\nfunction attachCanvas(container: HTMLElement, canvas: HTMLCanvasElement) {\n if (!container.contains(canvas)) container.appendChild(canvas);\n}\n\nfunction detachCanvas(container: HTMLElement | null, canvas: HTMLCanvasElement) {\n if (container?.contains(canvas)) container.removeChild(canvas);\n}\n\n// --- Live child -------------------------------------------------------------\nexport const LiveCanvas: React.FC<CanvasChildProps> = ({ className, style }) => {\n const { currentSession } = useInternalCameraKit();\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!currentSession || !containerRef.current) return;\n\n attachCanvas(containerRef.current, currentSession.output.live);\n currentSession.play(\"live\");\n\n return () => {\n detachCanvas(containerRef.current, currentSession.output.live);\n currentSession.pause(\"live\");\n };\n }, [currentSession]);\n\n return <div ref={containerRef} className={className} style={style} />;\n};\n\n// --- Capture child ----------------------------------------------------------\nexport const CaptureCanvas: React.FC<CanvasChildProps> = ({ className, style }) => {\n const { currentSession } = useInternalCameraKit();\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!currentSession || !containerRef.current) return;\n\n attachCanvas(containerRef.current, currentSession.output.capture);\n currentSession.play(\"capture\");\n\n return () => {\n detachCanvas(containerRef.current!, currentSession.output.capture);\n currentSession.pause(\"capture\");\n };\n }, [currentSession]);\n\n return <div ref={containerRef} className={className} style={style} />;\n};\n"]}
@@ -0,0 +1,101 @@
1
+ import { ReactNode } from "react";
2
+ import { CameraKitSessionEvents, Lens, LensLaunchData, ScreenRegions } from "@snap/camera-kit";
3
+ import { CanvasType, OutputSize, SourceInput } from "./types";
4
+ /**
5
+ * Props for the LensPlayer component.
6
+ */
7
+ export interface LensPlayerProps {
8
+ /** The media source to apply (camera, video, or image). Defaults to camera if not specified. */
9
+ source?: SourceInput;
10
+ /** Optional output size configuration for the rendering canvas. */
11
+ outputSize?: OutputSize;
12
+ /** The unique identifier of the Lens to apply. */
13
+ lensId?: string;
14
+ /** The group ID containing the Lens. Required when lensId is provided. */
15
+ lensGroupId?: string;
16
+ /** Optional launch parameters to pass to the Lens.. */
17
+ lensLaunchData?: LensLaunchData;
18
+ /** Optional async guard that must resolve before the Lens is considered ready.
19
+ * The guard is called when the lens is in loading state,
20
+ * and when the promise returned by the function resolves, it will transition to the ready state.
21
+ * If the promise doesn't resolve within 2 seconds, the ready state is forced. */
22
+ lensReadyGuard?: () => Promise<void>;
23
+ /**
24
+ * Trigger to refresh the current Lens. When this value changes,
25
+ * the Lens will be removed and reapplied. Useful for restarting
26
+ * the Lens experience without moving LensPlayer to another component.
27
+ */
28
+ refreshTrigger?: unknown;
29
+ /** Which canvas to render: "live" for real-time preview or "capture" for snapshot. Defaults to "live". */
30
+ canvasType?: CanvasType;
31
+ /**
32
+ * A maximum FPS, rendering will not exceed this limit.
33
+ *
34
+ * This may be useful to reduce CPU/GPU resource usage by CameraKit if, for example,
35
+ * the input media source has a low FPS – CameraKit would then not try to render more
36
+ * frequently than the source produces new frames.
37
+ *
38
+ * This may also be useful to gracefully degrade performance in situations where
39
+ * lowering FPS is preferable over alternatives.
40
+ */
41
+ fpsLimit?: number;
42
+ /**
43
+ * Whether to mute all sounds. Unmuted by default.
44
+ */
45
+ muted?: boolean;
46
+ /**
47
+ * Configuration object containing the current set of screen regions.
48
+ *
49
+ * Screen regions define areas of the screen that have special meaning for Lens rendering,
50
+ * such as safe rendering areas, UI button locations, keyboard areas, etc. This allows lenses
51
+ * to adapt their content placement based on the host application's UI layout.
52
+ */
53
+ screenRegions?: ScreenRegions;
54
+ /**
55
+ * A callback to handle Lens playback errors.
56
+ */
57
+ onError?: (error: CameraKitSessionEvents["detail"]["error"], lens: Lens) => void;
58
+ /** CSS class name to apply to the wrapper or canvas element. */
59
+ className?: string;
60
+ /** Inline styles to apply to the wrapper or canvas element. */
61
+ style?: React.CSSProperties;
62
+ /** Custom children to render instead of the default canvas. When provided, children are wrapped in a styled div. */
63
+ children?: ReactNode;
64
+ }
65
+ /**
66
+ * A declarative, all-in-one component for rendering Camera Kit Lenses.
67
+ *
68
+ * LensPlayer combines source management, lens application, and playback controls into a single
69
+ * component. It handles the complexity of coordinating multiple hooks and provides a simple
70
+ * prop-based API for common use cases.
71
+ *
72
+ * @example
73
+ * ```tsx
74
+ * // Basic lens player with camera source
75
+ * <LensPlayer lensId="lens-123" lensGroupId="my-group" />
76
+ *
77
+ * // With custom source and output size
78
+ * <LensPlayer
79
+ * source={{ kind: "video", element: videoElement }}
80
+ * outputSize={{ mode: "fixed", width: 1280, height: 720 }}
81
+ * lensId="lens-123"
82
+ * lensGroupId="my-group"
83
+ * />
84
+ *
85
+ * // With playback controls and error handling
86
+ * <LensPlayer
87
+ * lensId="lens-123"
88
+ * lensGroupId="my-group"
89
+ * fpsLimit={30}
90
+ * muted={true}
91
+ * onError={(error) => console.error("Playback error:", error)}
92
+ * />
93
+ *
94
+ * // With custom children instead of default canvas
95
+ * <LensPlayer lensId="lens-123" lensGroupId="my-group">
96
+ * <div>Custom UI overlaying the Lens <LiveCanvas /></div>
97
+ * </LensPlayer>
98
+ * ```
99
+ */
100
+ export declare const LensPlayer: React.FC<LensPlayerProps>;
101
+ //# sourceMappingURL=LensPlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LensPlayer.d.ts","sourceRoot":"","sources":["../../src/LensPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAO9D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gGAAgG;IAChG,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,mEAAmE;IACnE,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,uDAAuD;IACvD,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;qFAGiF;IACjF,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,0GAA0G;IAC1G,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEjF,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B,oHAAoH;IACpH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA8ChD,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
+ import { useApplySource } from "./useApplySource";
4
+ import { useApplyLens } from "./useApplyLens";
5
+ import { usePlaybackOptions } from "./usePlaybackOptions";
6
+ import { CaptureCanvas, LiveCanvas } from "./Canvas";
7
+ import { useCameraKit } from "./CameraKitProvider";
8
+ /**
9
+ * A declarative, all-in-one component for rendering Camera Kit Lenses.
10
+ *
11
+ * LensPlayer combines source management, lens application, and playback controls into a single
12
+ * component. It handles the complexity of coordinating multiple hooks and provides a simple
13
+ * prop-based API for common use cases.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * // Basic lens player with camera source
18
+ * <LensPlayer lensId="lens-123" lensGroupId="my-group" />
19
+ *
20
+ * // With custom source and output size
21
+ * <LensPlayer
22
+ * source={{ kind: "video", element: videoElement }}
23
+ * outputSize={{ mode: "fixed", width: 1280, height: 720 }}
24
+ * lensId="lens-123"
25
+ * lensGroupId="my-group"
26
+ * />
27
+ *
28
+ * // With playback controls and error handling
29
+ * <LensPlayer
30
+ * lensId="lens-123"
31
+ * lensGroupId="my-group"
32
+ * fpsLimit={30}
33
+ * muted={true}
34
+ * onError={(error) => console.error("Playback error:", error)}
35
+ * />
36
+ *
37
+ * // With custom children instead of default canvas
38
+ * <LensPlayer lensId="lens-123" lensGroupId="my-group">
39
+ * <div>Custom UI overlaying the Lens <LiveCanvas /></div>
40
+ * </LensPlayer>
41
+ * ```
42
+ */
43
+ export const LensPlayer = ({ source, outputSize, lensId, lensGroupId, lensLaunchData, lensReadyGuard, refreshTrigger, canvasType, fpsLimit, muted, screenRegions, onError, className, style, children, }) => {
44
+ usePlaybackOptions({ fpsLimit, muted, screenRegions, onError });
45
+ useApplySource(source, outputSize);
46
+ useApplyLens(lensId, lensGroupId, lensLaunchData, lensReadyGuard);
47
+ // Handle refresh trigger - only refresh when the value actually changes (not on mount)
48
+ const { refreshLens } = useCameraKit();
49
+ const prevRefreshTrigger = useRef(refreshTrigger);
50
+ useEffect(() => {
51
+ if (prevRefreshTrigger.current !== refreshTrigger) {
52
+ prevRefreshTrigger.current = refreshTrigger;
53
+ refreshLens();
54
+ }
55
+ }, [refreshTrigger, refreshLens]);
56
+ if (children) {
57
+ // If custom children were provided, we wrap them to allow styling at the outer div.
58
+ return (_jsx("div", { className: className, style: style, children: children }));
59
+ }
60
+ // Otherwise, we render the asked (or by default live) canvas.
61
+ return canvasType === "capture" ? (_jsx(CaptureCanvas, { className: className, style: style })) : (_jsx(LiveCanvas, { className: className, style: style }));
62
+ };
63
+ //# sourceMappingURL=LensPlayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LensPlayer.js","sourceRoot":"","sources":["../../src/LensPlayer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA8EnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EACpD,MAAM,EACN,UAAU,EACV,MAAM,EACN,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,QAAQ,EACR,KAAK,EACL,aAAa,EACb,OAAO,EACP,SAAS,EACT,KAAK,EACL,QAAQ,GACT,EAAE,EAAE;IACH,kBAAkB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IAChE,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnC,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAElE,uFAAuF;IACvF,MAAM,EAAE,WAAW,EAAE,GAAG,YAAY,EAAE,CAAC;IACvC,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;IAClD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,kBAAkB,CAAC,OAAO,KAAK,cAAc,EAAE,CAAC;YAClD,kBAAkB,CAAC,OAAO,GAAG,cAAc,CAAC;YAC5C,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,EAAE,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CAAC;IAElC,IAAI,QAAQ,EAAE,CAAC;QACb,oFAAoF;QACpF,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,YACpC,QAAQ,GACL,CACP,CAAC;IACJ,CAAC;IAED,8DAA8D;IAC9D,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAChC,KAAC,aAAa,IAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAI,CACtD,CAAC,CAAC,CAAC,CACF,KAAC,UAAU,IAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAI,CACnD,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { ReactNode, useEffect, useRef } from \"react\";\nimport { CameraKitSessionEvents, Lens, LensLaunchData, ScreenRegions } from \"@snap/camera-kit\";\nimport { CanvasType, OutputSize, SourceInput } from \"./types\";\nimport { useApplySource } from \"./useApplySource\";\nimport { useApplyLens } from \"./useApplyLens\";\nimport { usePlaybackOptions } from \"./usePlaybackOptions\";\nimport { CaptureCanvas, LiveCanvas } from \"./Canvas\";\nimport { useCameraKit } from \"./CameraKitProvider\";\n\n/**\n * Props for the LensPlayer component.\n */\nexport interface LensPlayerProps {\n /** The media source to apply (camera, video, or image). Defaults to camera if not specified. */\n source?: SourceInput;\n\n /** Optional output size configuration for the rendering canvas. */\n outputSize?: OutputSize;\n\n /** The unique identifier of the Lens to apply. */\n lensId?: string;\n\n /** The group ID containing the Lens. Required when lensId is provided. */\n lensGroupId?: string;\n\n /** Optional launch parameters to pass to the Lens.. */\n lensLaunchData?: LensLaunchData;\n\n /** Optional async guard that must resolve before the Lens is considered ready.\n * The guard is called when the lens is in loading state,\n * and when the promise returned by the function resolves, it will transition to the ready state.\n * If the promise doesn't resolve within 2 seconds, the ready state is forced. */\n lensReadyGuard?: () => Promise<void>;\n\n /**\n * Trigger to refresh the current Lens. When this value changes,\n * the Lens will be removed and reapplied. Useful for restarting\n * the Lens experience without moving LensPlayer to another component.\n */\n refreshTrigger?: unknown;\n\n /** Which canvas to render: \"live\" for real-time preview or \"capture\" for snapshot. Defaults to \"live\". */\n canvasType?: CanvasType;\n\n /**\n * A maximum FPS, rendering will not exceed this limit.\n *\n * This may be useful to reduce CPU/GPU resource usage by CameraKit if, for example,\n * the input media source has a low FPS – CameraKit would then not try to render more\n * frequently than the source produces new frames.\n *\n * This may also be useful to gracefully degrade performance in situations where\n * lowering FPS is preferable over alternatives.\n */\n fpsLimit?: number;\n\n /**\n * Whether to mute all sounds. Unmuted by default.\n */\n muted?: boolean;\n\n /**\n * Configuration object containing the current set of screen regions.\n *\n * Screen regions define areas of the screen that have special meaning for Lens rendering,\n * such as safe rendering areas, UI button locations, keyboard areas, etc. This allows lenses\n * to adapt their content placement based on the host application's UI layout.\n */\n screenRegions?: ScreenRegions;\n\n /**\n * A callback to handle Lens playback errors.\n */\n onError?: (error: CameraKitSessionEvents[\"detail\"][\"error\"], lens: Lens) => void;\n\n /** CSS class name to apply to the wrapper or canvas element. */\n className?: string;\n\n /** Inline styles to apply to the wrapper or canvas element. */\n style?: React.CSSProperties;\n\n /** Custom children to render instead of the default canvas. When provided, children are wrapped in a styled div. */\n children?: ReactNode;\n}\n\n/**\n * A declarative, all-in-one component for rendering Camera Kit Lenses.\n *\n * LensPlayer combines source management, lens application, and playback controls into a single\n * component. It handles the complexity of coordinating multiple hooks and provides a simple\n * prop-based API for common use cases.\n *\n * @example\n * ```tsx\n * // Basic lens player with camera source\n * <LensPlayer lensId=\"lens-123\" lensGroupId=\"my-group\" />\n *\n * // With custom source and output size\n * <LensPlayer\n * source={{ kind: \"video\", element: videoElement }}\n * outputSize={{ mode: \"fixed\", width: 1280, height: 720 }}\n * lensId=\"lens-123\"\n * lensGroupId=\"my-group\"\n * />\n *\n * // With playback controls and error handling\n * <LensPlayer\n * lensId=\"lens-123\"\n * lensGroupId=\"my-group\"\n * fpsLimit={30}\n * muted={true}\n * onError={(error) => console.error(\"Playback error:\", error)}\n * />\n *\n * // With custom children instead of default canvas\n * <LensPlayer lensId=\"lens-123\" lensGroupId=\"my-group\">\n * <div>Custom UI overlaying the Lens <LiveCanvas /></div>\n * </LensPlayer>\n * ```\n */\nexport const LensPlayer: React.FC<LensPlayerProps> = ({\n source,\n outputSize,\n lensId,\n lensGroupId,\n lensLaunchData,\n lensReadyGuard,\n refreshTrigger,\n canvasType,\n fpsLimit,\n muted,\n screenRegions,\n onError,\n className,\n style,\n children,\n}) => {\n usePlaybackOptions({ fpsLimit, muted, screenRegions, onError });\n useApplySource(source, outputSize);\n useApplyLens(lensId, lensGroupId, lensLaunchData, lensReadyGuard);\n\n // Handle refresh trigger - only refresh when the value actually changes (not on mount)\n const { refreshLens } = useCameraKit();\n const prevRefreshTrigger = useRef(refreshTrigger);\n useEffect(() => {\n if (prevRefreshTrigger.current !== refreshTrigger) {\n prevRefreshTrigger.current = refreshTrigger;\n refreshLens();\n }\n }, [refreshTrigger, refreshLens]);\n\n if (children) {\n // If custom children were provided, we wrap them to allow styling at the outer div.\n return (\n <div className={className} style={style}>\n {children}\n </div>\n );\n }\n\n // Otherwise, we render the asked (or by default live) canvas.\n return canvasType === \"capture\" ? (\n <CaptureCanvas className={className} style={style} />\n ) : (\n <LiveCanvas className={className} style={style} />\n );\n};\n"]}
@@ -0,0 +1,17 @@
1
+ export { CameraKitProvider, useCameraKit } from "./CameraKitProvider";
2
+ export type { MetricEventHandlerFactory } from "./CameraKitProvider";
3
+ export type { CameraKitLogger, LogLevel } from "./internal/logging";
4
+ export { createConsoleLogger, createNoopLogger } from "./internal/logging";
5
+ export { LensPlayer } from "./LensPlayer";
6
+ export type { LensPlayerProps } from "./LensPlayer";
7
+ export { LiveCanvas, CaptureCanvas } from "./Canvas";
8
+ export type { CanvasChildProps } from "./Canvas";
9
+ export { useApplyLens } from "./useApplyLens";
10
+ export { useApplySource } from "./useApplySource";
11
+ export { usePlaybackOptions } from "./usePlaybackOptions";
12
+ export type { PlaybackOptions } from "./usePlaybackOptions";
13
+ export type { SourceStatus, LensStatus, CurrentSource, CurrentLens, CameraSourceInput, VideoSourceInput, ImageSourceInput, SourceInput, CameraSourceOutput, VideoSourceOutput, ImageSourceOutput, SourceOutput, FixedOutputSize, MatchInputSize, OutputSize, SourceOptions, CameraFacing, CameraConstraints, CameraRotation, CanvasType, CameraInfo, } from "./types";
14
+ export { NO_CURRENT_LENS, isCameraSource, isVideoSource, isImageSource, CameraRotationOptions } from "./types";
15
+ export { createCameraKitSource, DEFAULT_CAMERA_DEVICE_ID, defaultStreamResolution } from "./internal/sourceUtils";
16
+ export type { SourceApplication, TupleOf } from "./internal/sourceUtils";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACtE,YAAY,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGrE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,YAAY,EACV,YAAY,EACZ,UAAU,EACV,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG/G,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAClH,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,13 @@
1
+ // Main components
2
+ export { CameraKitProvider, useCameraKit } from "./CameraKitProvider";
3
+ export { createConsoleLogger, createNoopLogger } from "./internal/logging";
4
+ export { LensPlayer } from "./LensPlayer";
5
+ export { LiveCanvas, CaptureCanvas } from "./Canvas";
6
+ // Hooks
7
+ export { useApplyLens } from "./useApplyLens";
8
+ export { useApplySource } from "./useApplySource";
9
+ export { usePlaybackOptions } from "./usePlaybackOptions";
10
+ export { NO_CURRENT_LENS, isCameraSource, isVideoSource, isImageSource, CameraRotationOptions } from "./types";
11
+ // Source utilities
12
+ export { createCameraKitSource, DEFAULT_CAMERA_DEVICE_ID, defaultStreamResolution } from "./internal/sourceUtils";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKtE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGrD,QAAQ;AACR,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA4B1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE/G,mBAAmB;AACnB,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["// Main components\nexport { CameraKitProvider, useCameraKit } from \"./CameraKitProvider\";\nexport type { MetricEventHandlerFactory } from \"./CameraKitProvider\";\n\n// Logging\nexport type { CameraKitLogger, LogLevel } from \"./internal/logging\";\nexport { createConsoleLogger, createNoopLogger } from \"./internal/logging\";\n\nexport { LensPlayer } from \"./LensPlayer\";\nexport type { LensPlayerProps } from \"./LensPlayer\";\n\nexport { LiveCanvas, CaptureCanvas } from \"./Canvas\";\nexport type { CanvasChildProps } from \"./Canvas\";\n\n// Hooks\nexport { useApplyLens } from \"./useApplyLens\";\nexport { useApplySource } from \"./useApplySource\";\nexport { usePlaybackOptions } from \"./usePlaybackOptions\";\nexport type { PlaybackOptions } from \"./usePlaybackOptions\";\n\n// Types\nexport type {\n SourceStatus,\n LensStatus,\n CurrentSource,\n CurrentLens,\n CameraSourceInput,\n VideoSourceInput,\n ImageSourceInput,\n SourceInput,\n CameraSourceOutput,\n VideoSourceOutput,\n ImageSourceOutput,\n SourceOutput,\n FixedOutputSize,\n MatchInputSize,\n OutputSize,\n SourceOptions,\n CameraFacing,\n CameraConstraints,\n CameraRotation,\n CanvasType,\n CameraInfo,\n} from \"./types\";\n\nexport { NO_CURRENT_LENS, isCameraSource, isVideoSource, isImageSource, CameraRotationOptions } from \"./types\";\n\n// Source utilities\nexport { createCameraKitSource, DEFAULT_CAMERA_DEVICE_ID, defaultStreamResolution } from \"./internal/sourceUtils\";\nexport type { SourceApplication, TupleOf } from \"./internal/sourceUtils\";\n"]}
@@ -0,0 +1,13 @@
1
+ import { CameraKit, CameraKitBootstrapConfiguration, CameraKitSession, CreateSessionOptions, PublicContainer } from "@snap/camera-kit";
2
+ import { CameraKitLogger } from "./logging";
3
+ export interface BootstrapResult {
4
+ kit: CameraKit;
5
+ session: CameraKitSession;
6
+ destroy: () => Promise<void>;
7
+ }
8
+ /**
9
+ * Bootstraps CameraKit and creates a session with proper cancellation support.
10
+ * Cleans up resources if the operation is aborted via the AbortSignal.
11
+ */
12
+ export declare function bootstrapCameraKitWithSession(config: CameraKitBootstrapConfiguration, extendContainer: ((container: PublicContainer) => PublicContainer) | undefined, sessionOptions: CreateSessionOptions, signal: AbortSignal, log: CameraKitLogger): Promise<BootstrapResult>;
13
+ //# sourceMappingURL=bootstrapUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrapUtils.d.ts","sourceRoot":"","sources":["../../../src/internal/bootstrapUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,+BAA+B,EAC/B,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,gBAAgB,CAAC;IAC1B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,+BAA+B,EACvC,eAAe,EAAE,CAAC,CAAC,SAAS,EAAE,eAAe,KAAK,eAAe,CAAC,GAAG,SAAS,EAC9E,cAAc,EAAE,oBAAoB,EACpC,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,eAAe,CAAC,CAwB1B"}
@@ -0,0 +1,26 @@
1
+ import { bootstrapCameraKit, } from "@snap/camera-kit";
2
+ /**
3
+ * Bootstraps CameraKit and creates a session with proper cancellation support.
4
+ * Cleans up resources if the operation is aborted via the AbortSignal.
5
+ */
6
+ export async function bootstrapCameraKitWithSession(config, extendContainer, sessionOptions, signal, log) {
7
+ // Bootstrap the CameraKit SDK
8
+ const kit = await bootstrapCameraKit(config, extendContainer);
9
+ function destroy() {
10
+ return kit.destroy().catch((error) => log.error("kit_destroy_failed", error));
11
+ }
12
+ // Check if aborted after bootstrap
13
+ if (signal.aborted) {
14
+ destroy();
15
+ signal.throwIfAborted();
16
+ }
17
+ // Create session
18
+ const session = await kit.createSession(sessionOptions);
19
+ // Check if aborted after session creation
20
+ if (signal.aborted) {
21
+ destroy();
22
+ signal.throwIfAborted();
23
+ }
24
+ return { kit, session, destroy };
25
+ }
26
+ //# sourceMappingURL=bootstrapUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrapUtils.js","sourceRoot":"","sources":["../../../src/internal/bootstrapUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAMnB,MAAM,kBAAkB,CAAC;AAS1B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,MAAuC,EACvC,eAA8E,EAC9E,cAAoC,EACpC,MAAmB,EACnB,GAAoB;IAEpB,8BAA8B;IAC9B,MAAM,GAAG,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAE9D,SAAS,OAAO;QACd,OAAO,GAAG,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,mCAAmC;IACnC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;QACV,MAAM,CAAC,cAAc,EAAE,CAAC;IAC1B,CAAC;IAED,iBAAiB;IACjB,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAExD,0CAA0C;IAC1C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;QACV,MAAM,CAAC,cAAc,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import {\n bootstrapCameraKit,\n CameraKit,\n CameraKitBootstrapConfiguration,\n CameraKitSession,\n CreateSessionOptions,\n PublicContainer,\n} from \"@snap/camera-kit\";\nimport { CameraKitLogger } from \"./logging\";\n\nexport interface BootstrapResult {\n kit: CameraKit;\n session: CameraKitSession;\n destroy: () => Promise<void>;\n}\n\n/**\n * Bootstraps CameraKit and creates a session with proper cancellation support.\n * Cleans up resources if the operation is aborted via the AbortSignal.\n */\nexport async function bootstrapCameraKitWithSession(\n config: CameraKitBootstrapConfiguration,\n extendContainer: ((container: PublicContainer) => PublicContainer) | undefined,\n sessionOptions: CreateSessionOptions,\n signal: AbortSignal,\n log: CameraKitLogger,\n): Promise<BootstrapResult> {\n // Bootstrap the CameraKit SDK\n const kit = await bootstrapCameraKit(config, extendContainer);\n\n function destroy() {\n return kit.destroy().catch((error) => log.error(\"kit_destroy_failed\", error));\n }\n\n // Check if aborted after bootstrap\n if (signal.aborted) {\n destroy();\n signal.throwIfAborted();\n }\n\n // Create session\n const session = await kit.createSession(sessionOptions);\n\n // Check if aborted after session creation\n if (signal.aborted) {\n destroy();\n signal.throwIfAborted();\n }\n\n return { kit, session, destroy };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function ensureError(error: unknown, context?: string): Error;
2
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/internal/error.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CA8BnE"}
@@ -0,0 +1,27 @@
1
+ export function ensureError(error, context) {
2
+ if (error instanceof Error)
3
+ return error;
4
+ const contextPrefix = context ? `[${context}] ` : "";
5
+ try {
6
+ // Handle primitive types more explicitly
7
+ if (typeof error === "string") {
8
+ return new Error(`${contextPrefix}${error}`);
9
+ }
10
+ if (error === null || error === undefined) {
11
+ return new Error(`${contextPrefix}An unknown error occurred (${error})`);
12
+ }
13
+ // Try to extract useful info from error-like objects
14
+ const errorObj = error;
15
+ const message = errorObj.message || errorObj.error || "Unknown error";
16
+ const details = JSON.stringify(error, null, 2);
17
+ return new Error(`${contextPrefix}Non-Error exception: ${message}\nDetails: ${details}`);
18
+ }
19
+ catch (serializationError) {
20
+ // Provide more info about what failed
21
+ return new Error(`${contextPrefix}Non-Error exception thrown. ` +
22
+ `Type: ${typeof error}, ` +
23
+ `Constructor: ${error?.constructor?.name ?? "unknown"}, ` +
24
+ `Serialization failed: ${serializationError instanceof Error ? serializationError.message : "unknown reason"}`);
25
+ }
26
+ }
27
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/internal/error.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,KAAc,EAAE,OAAgB;IAC1D,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzC,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAErD,IAAI,CAAC;QACH,yCAAyC;QACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,KAAK,CAAC,GAAG,aAAa,GAAG,KAAK,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,IAAI,KAAK,CAAC,GAAG,aAAa,8BAA8B,KAAK,GAAG,CAAC,CAAC;QAC3E,CAAC;QAED,qDAAqD;QACrD,MAAM,QAAQ,GAAG,KAAgC,CAAC;QAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,KAAK,IAAI,eAAe,CAAC;QACtE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAE/C,OAAO,IAAI,KAAK,CAAC,GAAG,aAAa,wBAAwB,OAAO,cAAc,OAAO,EAAE,CAAC,CAAC;IAC3F,CAAC;IAAC,OAAO,kBAAkB,EAAE,CAAC;QAC5B,sCAAsC;QACtC,OAAO,IAAI,KAAK,CACd,GAAG,aAAa,8BAA8B;YAC5C,SAAS,OAAO,KAAK,IAAI;YACzB,gBAAgB,KAAK,EAAE,WAAW,EAAE,IAAI,IAAI,SAAS,IAAI;YACzD,yBAAyB,kBAAkB,YAAY,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,EAAE,CACjH,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["export function ensureError(error: unknown, context?: string): Error {\n if (error instanceof Error) return error;\n\n const contextPrefix = context ? `[${context}] ` : \"\";\n\n try {\n // Handle primitive types more explicitly\n if (typeof error === \"string\") {\n return new Error(`${contextPrefix}${error}`);\n }\n\n if (error === null || error === undefined) {\n return new Error(`${contextPrefix}An unknown error occurred (${error})`);\n }\n\n // Try to extract useful info from error-like objects\n const errorObj = error as Record<string, unknown>;\n const message = errorObj.message || errorObj.error || \"Unknown error\";\n const details = JSON.stringify(error, null, 2);\n\n return new Error(`${contextPrefix}Non-Error exception: ${message}\\nDetails: ${details}`);\n } catch (serializationError) {\n // Provide more info about what failed\n return new Error(\n `${contextPrefix}Non-Error exception thrown. ` +\n `Type: ${typeof error}, ` +\n `Constructor: ${error?.constructor?.name ?? \"unknown\"}, ` +\n `Serialization failed: ${serializationError instanceof Error ? serializationError.message : \"unknown reason\"}`,\n );\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Detects if the current device is a mobile device
3
+ */
4
+ export declare function isMobile(): boolean;
5
+ //# sourceMappingURL=isMobile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMobile.d.ts","sourceRoot":"","sources":["../../../src/internal/isMobile.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,QAAQ,IAAI,OAAO,CASlC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Detects if the current device is a mobile device
3
+ */
4
+ export function isMobile() {
5
+ if (typeof navigator === "undefined" || typeof window === "undefined") {
6
+ return false;
7
+ }
8
+ // Check user agent for mobile indicators
9
+ const userAgent = navigator.userAgent || navigator.vendor || window.opera;
10
+ return /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent);
11
+ }
12
+ //# sourceMappingURL=isMobile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMobile.js","sourceRoot":"","sources":["../../../src/internal/isMobile.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,QAAQ;IACtB,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yCAAyC;IACzC,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,IAAK,MAAc,CAAC,KAAK,CAAC;IAEnF,OAAO,gEAAgE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["/**\n * Detects if the current device is a mobile device\n */\n\nexport function isMobile(): boolean {\n if (typeof navigator === \"undefined\" || typeof window === \"undefined\") {\n return false;\n }\n\n // Check user agent for mobile indicators\n const userAgent = navigator.userAgent || navigator.vendor || (window as any).opera;\n\n return /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent);\n}\n"]}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Pluggable logging interface for react-camera-kit.
3
+ * Vendor-neutral design allows integrating with any logging system.
4
+ */
5
+ export type LogLevel = "debug" | "info" | "warn" | "error";
6
+ /**
7
+ * Logger interface that matches console.log signature.
8
+ * Can be implemented by any logging library.
9
+ * Users only need to implement the basic log methods - child logger creation is handled internally.
10
+ */
11
+ export interface CameraKitLogger {
12
+ debug(message?: any, ...optionalParams: any[]): void;
13
+ info(message?: any, ...optionalParams: any[]): void;
14
+ warn(message?: any, ...optionalParams: any[]): void;
15
+ error(message?: any, ...optionalParams: any[]): void;
16
+ }
17
+ /**
18
+ * Logger interface that matches console.log signature.
19
+ * Can be implemented by any logging library.
20
+ * Users only need to implement the basic log methods - child logger creation is handled internally.
21
+ */
22
+ export interface InternalLogger extends CameraKitLogger {
23
+ logLevel: LogLevel;
24
+ }
25
+ /**
26
+ * Creates a child logger with a namespace prefix.
27
+ * This is used internally to create namespaced loggers for different parts of the library.
28
+ */
29
+ export declare function wrapLogger(inner: InternalLogger, namespace: string): InternalLogger;
30
+ /**
31
+ * Console-based logger implementation with timestamps.
32
+ * Log level can be controlled via the setLevel() method or CameraKitProvider's logLevel prop.
33
+ */
34
+ export declare function createConsoleLogger(): CameraKitLogger;
35
+ /**
36
+ * No-op logger that discards all log messages.
37
+ * Useful for production environments where logging is handled externally.
38
+ */
39
+ export declare function createNoopLogger(): CameraKitLogger;
40
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../../src/internal/logging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACpD,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACpD,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CACtD;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAID;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,CA0BnF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,eAAe,CAOrD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,CAOlD"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Pluggable logging interface for react-camera-kit.
3
+ * Vendor-neutral design allows integrating with any logging system.
4
+ */
5
+ const noop = () => { };
6
+ /**
7
+ * Creates a child logger with a namespace prefix.
8
+ * This is used internally to create namespaced loggers for different parts of the library.
9
+ */
10
+ export function wrapLogger(inner, namespace) {
11
+ const levelOrder = ["debug", "info", "warn", "error"];
12
+ const minLevelIndex = levelOrder.indexOf(inner.logLevel);
13
+ function shouldLog(msgLevel) {
14
+ return levelOrder.indexOf(msgLevel) >= minLevelIndex;
15
+ }
16
+ // Create a wrapper that prefixes messages with namespace
17
+ const outer = {
18
+ logLevel: inner.logLevel,
19
+ debug: shouldLog("debug")
20
+ ? (message, ...optionalParams) => inner.debug(`[${namespace}] ${message}`, ...optionalParams)
21
+ : noop,
22
+ info: shouldLog("info")
23
+ ? (message, ...optionalParams) => inner.info(`[${namespace}] ${message}`, ...optionalParams)
24
+ : noop,
25
+ warn: shouldLog("warn")
26
+ ? (message, ...optionalParams) => inner.warn(`[${namespace}] ${message}`, ...optionalParams)
27
+ : noop,
28
+ error: shouldLog("error")
29
+ ? (message, ...optionalParams) => inner.error(`[${namespace}] ${message}`, ...optionalParams)
30
+ : noop,
31
+ };
32
+ return outer;
33
+ }
34
+ /**
35
+ * Console-based logger implementation with timestamps.
36
+ * Log level can be controlled via the setLevel() method or CameraKitProvider's logLevel prop.
37
+ */
38
+ export function createConsoleLogger() {
39
+ return {
40
+ debug: (message, ...optionalParams) => console.debug(message, ...optionalParams),
41
+ info: (message, ...optionalParams) => console.info(message, ...optionalParams),
42
+ warn: (message, ...optionalParams) => console.warn(message, ...optionalParams),
43
+ error: (message, ...optionalParams) => console.error(message, ...optionalParams),
44
+ };
45
+ }
46
+ /**
47
+ * No-op logger that discards all log messages.
48
+ * Useful for production environments where logging is handled externally.
49
+ */
50
+ export function createNoopLogger() {
51
+ return {
52
+ debug: noop,
53
+ info: noop,
54
+ warn: noop,
55
+ error: noop,
56
+ };
57
+ }
58
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../src/internal/logging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyBH,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEtB;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAqB,EAAE,SAAiB;IACjE,MAAM,UAAU,GAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAClE,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEzD,SAAS,SAAS,CAAC,QAAkB;QACnC,OAAO,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC;IACvD,CAAC;IAED,yDAAyD;IACzD,MAAM,KAAK,GAAmB;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC;YACvB,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,EAAE,GAAG,cAAc,CAAC;YAC7F,CAAC,CAAC,IAAI;QACR,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC;YACrB,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,EAAE,GAAG,cAAc,CAAC;YAC5F,CAAC,CAAC,IAAI;QACR,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC;YACrB,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,EAAE,GAAG,cAAc,CAAC;YAC5F,CAAC,CAAC,IAAI;QACR,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC;YACvB,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,SAAS,KAAK,OAAO,EAAE,EAAE,GAAG,cAAc,CAAC;YAC7F,CAAC,CAAC,IAAI;KACT,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC;QAChF,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC;QAC9E,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC;QAC9E,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC;KACjF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Pluggable logging interface for react-camera-kit.\n * Vendor-neutral design allows integrating with any logging system.\n */\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\n/**\n * Logger interface that matches console.log signature.\n * Can be implemented by any logging library.\n * Users only need to implement the basic log methods - child logger creation is handled internally.\n */\nexport interface CameraKitLogger {\n debug(message?: any, ...optionalParams: any[]): void;\n info(message?: any, ...optionalParams: any[]): void;\n warn(message?: any, ...optionalParams: any[]): void;\n error(message?: any, ...optionalParams: any[]): void;\n}\n\n/**\n * Logger interface that matches console.log signature.\n * Can be implemented by any logging library.\n * Users only need to implement the basic log methods - child logger creation is handled internally.\n */\nexport interface InternalLogger extends CameraKitLogger {\n logLevel: LogLevel;\n}\n\nconst noop = () => {};\n\n/**\n * Creates a child logger with a namespace prefix.\n * This is used internally to create namespaced loggers for different parts of the library.\n */\nexport function wrapLogger(inner: InternalLogger, namespace: string): InternalLogger {\n const levelOrder: LogLevel[] = [\"debug\", \"info\", \"warn\", \"error\"];\n const minLevelIndex = levelOrder.indexOf(inner.logLevel);\n\n function shouldLog(msgLevel: LogLevel): boolean {\n return levelOrder.indexOf(msgLevel) >= minLevelIndex;\n }\n\n // Create a wrapper that prefixes messages with namespace\n const outer: InternalLogger = {\n logLevel: inner.logLevel,\n debug: shouldLog(\"debug\")\n ? (message, ...optionalParams) => inner.debug(`[${namespace}] ${message}`, ...optionalParams)\n : noop,\n info: shouldLog(\"info\")\n ? (message, ...optionalParams) => inner.info(`[${namespace}] ${message}`, ...optionalParams)\n : noop,\n warn: shouldLog(\"warn\")\n ? (message, ...optionalParams) => inner.warn(`[${namespace}] ${message}`, ...optionalParams)\n : noop,\n error: shouldLog(\"error\")\n ? (message, ...optionalParams) => inner.error(`[${namespace}] ${message}`, ...optionalParams)\n : noop,\n };\n\n return outer;\n}\n\n/**\n * Console-based logger implementation with timestamps.\n * Log level can be controlled via the setLevel() method or CameraKitProvider's logLevel prop.\n */\nexport function createConsoleLogger(): CameraKitLogger {\n return {\n debug: (message, ...optionalParams) => console.debug(message, ...optionalParams),\n info: (message, ...optionalParams) => console.info(message, ...optionalParams),\n warn: (message, ...optionalParams) => console.warn(message, ...optionalParams),\n error: (message, ...optionalParams) => console.error(message, ...optionalParams),\n };\n}\n\n/**\n * No-op logger that discards all log messages.\n * Useful for production environments where logging is handled externally.\n */\nexport function createNoopLogger(): CameraKitLogger {\n return {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n };\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { Metric, PublicContainer } from "@snap/camera-kit";
2
+ import { Subject } from "rxjs";
3
+ export type MetricsReporter = ReturnType<typeof createMetricsReporter>;
4
+ /**
5
+ * Creates a metrics reporter that pushes Count metrics into a Subject.
6
+ * The subject is wired into Camera Kit's DI container so metrics flow
7
+ * through the SDK's built-in pipeline to the backend.
8
+ */
9
+ declare function createMetricsReporter(subject: Subject<Metric>): {
10
+ reportCount(name: string): void;
11
+ };
12
+ /** Global metrics reporter — safe to call at any point; events are buffered until the DI wiring is established. */
13
+ export declare const metricsReporter: {
14
+ reportCount(name: string): void;
15
+ };
16
+ /**
17
+ * Wraps a user-supplied `extendContainer` (if any) so that our metrics Subject
18
+ * is always provided into Camera Kit's DI container.
19
+ *
20
+ * Newer Camera Kit versions (with `externalMetricsFactory`)
21
+ * use a simpler declarative approach. Older versions fall back to
22
+ * `externalMetricsSubjectFactory` with manual subscribe-and-forward.
23
+ *
24
+ * On re-bootstrap the previous forwarding subscription is torn down automatically
25
+ * (legacy path only; the new path doesn't need that).
26
+ */
27
+ export declare function extendContainerWithMetrics(userExtendContainer?: (container: PublicContainer) => PublicContainer): (container: PublicContainer) => PublicContainer;
28
+ export {};
29
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,eAAe,EAAgC,MAAM,kBAAkB,CAAC;AAEhG,OAAO,EAAc,OAAO,EAAgB,MAAM,MAAM,CAAC;AAuCzD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEvE;;;;GAIG;AACH,iBAAS,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC;sBAEjC,MAAM;EAQ3B;AAED,mHAAmH;AACnH,eAAO,MAAM,eAAe;sBAXN,MAAM;CAWwC,CAAC;AAErE;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,eAAe,KAAK,eAAe,GACpE,CAAC,SAAS,EAAE,eAAe,KAAK,eAAe,CAqBjD"}