@simpleapps-com/augur-web 0.2.14 → 0.2.15

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.
@@ -0,0 +1,44 @@
1
+ /** Supported session replay providers. */
2
+ type SessionReplayProvider = "mouseflow" | "hotjar";
3
+ interface SessionReplayScriptProps {
4
+ /** Session replay provider. */
5
+ provider: SessionReplayProvider;
6
+ /** Project/site ID from the provider. */
7
+ siteId: string;
8
+ /** Sampling rate (0-1). 1 = all sessions, 0.5 = 50%. Default: 1. */
9
+ sampleRate?: number;
10
+ /** Disable in development. Default: false. */
11
+ disabled?: boolean;
12
+ }
13
+ declare global {
14
+ interface Window {
15
+ _mfq?: unknown[];
16
+ hj?: (...args: unknown[]) => void;
17
+ _hjSettings?: {
18
+ hjid: string;
19
+ hjsv: number;
20
+ };
21
+ }
22
+ }
23
+ /**
24
+ * Loads a session replay script with `lazyOnload` behavior.
25
+ * Renders nothing — this is a side-effect-only leaf component.
26
+ *
27
+ * Session replay tools require main thread DOM access (MutationObserver)
28
+ * and cannot run in web workers.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * // In layout.tsx
33
+ * <SessionReplayScript provider="mouseflow" siteId="88d79cd5-..." />
34
+ *
35
+ * // With 50% sampling
36
+ * <SessionReplayScript provider="mouseflow" siteId="..." sampleRate={0.5} />
37
+ *
38
+ * // Disabled in dev
39
+ * <SessionReplayScript provider="hotjar" siteId="..." disabled={isDev} />
40
+ * ```
41
+ */
42
+ declare function SessionReplayScript({ provider, siteId, sampleRate, disabled, }: SessionReplayScriptProps): null;
43
+
44
+ export { type SessionReplayProvider, SessionReplayScript, type SessionReplayScriptProps };
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/session-replay.tsx
5
+ import { useEffect, useRef } from "react";
6
+ function injectMouseflow(siteId) {
7
+ if (typeof document === "undefined") return;
8
+ if (document.getElementById("mouseflow-script")) return;
9
+ window._mfq = window._mfq || [];
10
+ const script = document.createElement("script");
11
+ script.id = "mouseflow-script";
12
+ script.src = `https://cdn.mouseflow.com/projects/${encodeURIComponent(siteId)}.js`;
13
+ script.async = true;
14
+ script.defer = true;
15
+ document.head.appendChild(script);
16
+ }
17
+ function injectHotjar(siteId) {
18
+ if (typeof document === "undefined") return;
19
+ if (document.getElementById("hotjar-script")) return;
20
+ window._hjSettings = { hjid: siteId, hjsv: 6 };
21
+ window.hj = window.hj || function hjQueue(...args) {
22
+ window.hj.q = window.hj.q || [];
23
+ window.hj.q.push(args);
24
+ };
25
+ const script = document.createElement("script");
26
+ script.id = "hotjar-script";
27
+ script.src = `https://static.hotjar.com/c/hotjar-${encodeURIComponent(siteId)}.js?sv=6`;
28
+ script.async = true;
29
+ script.defer = true;
30
+ document.head.appendChild(script);
31
+ }
32
+ var injectors = {
33
+ mouseflow: injectMouseflow,
34
+ hotjar: injectHotjar
35
+ };
36
+ function SessionReplayScript({
37
+ provider,
38
+ siteId,
39
+ sampleRate = 1,
40
+ disabled = false
41
+ }) {
42
+ const injectedRef = useRef(false);
43
+ useEffect(() => {
44
+ if (disabled || injectedRef.current) return;
45
+ if (sampleRate < 1 && Math.random() > sampleRate) return;
46
+ injectedRef.current = true;
47
+ const inject = injectors[provider];
48
+ if (typeof requestIdleCallback === "function") {
49
+ requestIdleCallback(() => inject(siteId));
50
+ } else {
51
+ setTimeout(() => inject(siteId), 0);
52
+ }
53
+ }, [provider, siteId, sampleRate, disabled]);
54
+ return null;
55
+ }
56
+ export {
57
+ SessionReplayScript
58
+ };
59
+ //# sourceMappingURL=session-replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/session-replay.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Supported session replay providers. */\nexport type SessionReplayProvider = \"mouseflow\" | \"hotjar\";\n\nexport interface SessionReplayScriptProps {\n /** Session replay provider. */\n provider: SessionReplayProvider;\n /** Project/site ID from the provider. */\n siteId: string;\n /** Sampling rate (0-1). 1 = all sessions, 0.5 = 50%. Default: 1. */\n sampleRate?: number;\n /** Disable in development. Default: false. */\n disabled?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Globals\n// ---------------------------------------------------------------------------\n\ndeclare global {\n interface Window {\n _mfq?: unknown[];\n hj?: (...args: unknown[]) => void;\n _hjSettings?: { hjid: string; hjsv: number };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Script injectors\n// ---------------------------------------------------------------------------\n\nfunction injectMouseflow(siteId: string): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(\"mouseflow-script\")) return;\n\n window._mfq = window._mfq || [];\n\n const script = document.createElement(\"script\");\n script.id = \"mouseflow-script\";\n script.src = `https://cdn.mouseflow.com/projects/${encodeURIComponent(siteId)}.js`;\n script.async = true;\n script.defer = true;\n document.head.appendChild(script);\n}\n\nfunction injectHotjar(siteId: string): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(\"hotjar-script\")) return;\n\n window._hjSettings = { hjid: siteId, hjsv: 6 };\n window.hj =\n window.hj ||\n function hjQueue(...args: unknown[]) {\n (window.hj as unknown as { q: unknown[] }).q =\n (window.hj as unknown as { q: unknown[] }).q || [];\n (window.hj as unknown as { q: unknown[] }).q.push(args);\n };\n\n const script = document.createElement(\"script\");\n script.id = \"hotjar-script\";\n script.src = `https://static.hotjar.com/c/hotjar-${encodeURIComponent(siteId)}.js?sv=6`;\n script.async = true;\n script.defer = true;\n document.head.appendChild(script);\n}\n\nconst injectors: Record<SessionReplayProvider, (siteId: string) => void> = {\n mouseflow: injectMouseflow,\n hotjar: injectHotjar,\n};\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\n/**\n * Loads a session replay script with `lazyOnload` behavior.\n * Renders nothing — this is a side-effect-only leaf component.\n *\n * Session replay tools require main thread DOM access (MutationObserver)\n * and cannot run in web workers.\n *\n * @example\n * ```tsx\n * // In layout.tsx\n * <SessionReplayScript provider=\"mouseflow\" siteId=\"88d79cd5-...\" />\n *\n * // With 50% sampling\n * <SessionReplayScript provider=\"mouseflow\" siteId=\"...\" sampleRate={0.5} />\n *\n * // Disabled in dev\n * <SessionReplayScript provider=\"hotjar\" siteId=\"...\" disabled={isDev} />\n * ```\n */\nexport function SessionReplayScript({\n provider,\n siteId,\n sampleRate = 1,\n disabled = false,\n}: SessionReplayScriptProps) {\n const injectedRef = useRef(false);\n\n useEffect(() => {\n if (disabled || injectedRef.current) return;\n if (sampleRate < 1 && Math.random() > sampleRate) return;\n\n injectedRef.current = true;\n\n const inject = injectors[provider];\n\n // Load during idle time (lazyOnload behavior)\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => inject(siteId));\n } else {\n setTimeout(() => inject(siteId), 0);\n }\n }, [provider, siteId, sampleRate, disabled]);\n\n return null;\n}\n"],"mappings":";;;;AAEA,SAAS,WAAW,cAAc;AAoClC,SAAS,gBAAgB,QAAsB;AAC7C,MAAI,OAAO,aAAa,YAAa;AACrC,MAAI,SAAS,eAAe,kBAAkB,EAAG;AAEjD,SAAO,OAAO,OAAO,QAAQ,CAAC;AAE9B,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,KAAK;AACZ,SAAO,MAAM,sCAAsC,mBAAmB,MAAM,CAAC;AAC7E,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,WAAS,KAAK,YAAY,MAAM;AAClC;AAEA,SAAS,aAAa,QAAsB;AAC1C,MAAI,OAAO,aAAa,YAAa;AACrC,MAAI,SAAS,eAAe,eAAe,EAAG;AAE9C,SAAO,cAAc,EAAE,MAAM,QAAQ,MAAM,EAAE;AAC7C,SAAO,KACL,OAAO,MACP,SAAS,WAAW,MAAiB;AACnC,IAAC,OAAO,GAAmC,IACxC,OAAO,GAAmC,KAAK,CAAC;AACnD,IAAC,OAAO,GAAmC,EAAE,KAAK,IAAI;AAAA,EACxD;AAEF,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,KAAK;AACZ,SAAO,MAAM,sCAAsC,mBAAmB,MAAM,CAAC;AAC7E,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,WAAS,KAAK,YAAY,MAAM;AAClC;AAEA,IAAM,YAAqE;AAAA,EACzE,WAAW;AAAA,EACX,QAAQ;AACV;AAyBO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,WAAW;AACb,GAA6B;AAC3B,QAAM,cAAc,OAAO,KAAK;AAEhC,YAAU,MAAM;AACd,QAAI,YAAY,YAAY,QAAS;AACrC,QAAI,aAAa,KAAK,KAAK,OAAO,IAAI,WAAY;AAElD,gBAAY,UAAU;AAEtB,UAAM,SAAS,UAAU,QAAQ;AAGjC,QAAI,OAAO,wBAAwB,YAAY;AAC7C,0BAAoB,MAAM,OAAO,MAAM,CAAC;AAAA,IAC1C,OAAO;AACL,iBAAW,MAAM,OAAO,MAAM,GAAG,CAAC;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,UAAU,QAAQ,YAAY,QAAQ,CAAC;AAE3C,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleapps-com/augur-web",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "Shared React UI components for Augur ecommerce sites (Radix + Tailwind)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -60,6 +60,11 @@
60
60
  "import": "./dist/pagination.js",
61
61
  "require": "./dist/pagination.cjs"
62
62
  },
63
+ "./price": {
64
+ "types": "./dist/price.d.ts",
65
+ "import": "./dist/price.js",
66
+ "require": "./dist/price.cjs"
67
+ },
63
68
  "./radio-group": {
64
69
  "types": "./dist/radio-group.d.ts",
65
70
  "import": "./dist/radio-group.js",
@@ -145,6 +150,11 @@
145
150
  "import": "./dist/form-textarea.js",
146
151
  "require": "./dist/form-textarea.cjs"
147
152
  },
153
+ "./financing-widget": {
154
+ "types": "./dist/financing-widget.d.ts",
155
+ "import": "./dist/financing-widget.js",
156
+ "require": "./dist/financing-widget.cjs"
157
+ },
148
158
  "./gtm": {
149
159
  "types": "./dist/gtm.d.ts",
150
160
  "import": "./dist/gtm.js",
@@ -154,6 +164,11 @@
154
164
  "types": "./dist/mdx-components.d.ts",
155
165
  "import": "./dist/mdx-components.js",
156
166
  "require": "./dist/mdx-components.cjs"
167
+ },
168
+ "./session-replay": {
169
+ "types": "./dist/session-replay.d.ts",
170
+ "import": "./dist/session-replay.js",
171
+ "require": "./dist/session-replay.cjs"
157
172
  }
158
173
  },
159
174
  "sideEffects": false,