@simpleapps-com/augur-web 0.2.14 → 0.2.16
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/dist/chunk-PTAWV5SA.js +29 -0
- package/dist/chunk-PTAWV5SA.js.map +1 -0
- package/dist/chunk-VT4JLAIE.cjs +29 -0
- package/dist/chunk-VT4JLAIE.cjs.map +1 -0
- package/dist/financing-widget.cjs +47 -0
- package/dist/financing-widget.cjs.map +1 -0
- package/dist/financing-widget.d.cts +45 -0
- package/dist/financing-widget.d.ts +45 -0
- package/dist/financing-widget.js +47 -0
- package/dist/financing-widget.js.map +1 -0
- package/dist/form-select.cjs +2 -2
- package/dist/form-select.cjs.map +1 -1
- package/dist/form-select.js +3 -3
- package/dist/gtm.cjs +22 -19
- package/dist/gtm.cjs.map +1 -1
- package/dist/gtm.d.cts +37 -17
- package/dist/gtm.d.ts +37 -17
- package/dist/gtm.js +21 -18
- package/dist/gtm.js.map +1 -1
- package/dist/price-format.cjs +8 -0
- package/dist/price-format.cjs.map +1 -0
- package/dist/price-format.d.cts +17 -0
- package/dist/price-format.d.ts +17 -0
- package/dist/price-format.js +8 -0
- package/dist/price-format.js.map +1 -0
- package/dist/price.cjs +90 -0
- package/dist/price.cjs.map +1 -0
- package/dist/price.d.cts +61 -0
- package/dist/price.d.ts +61 -0
- package/dist/price.js +90 -0
- package/dist/price.js.map +1 -0
- package/dist/session-replay.cjs +59 -0
- package/dist/session-replay.cjs.map +1 -0
- package/dist/session-replay.d.cts +44 -0
- package/dist/session-replay.d.ts +44 -0
- package/dist/session-replay.js +59 -0
- package/dist/session-replay.js.map +1 -0
- package/package.json +21 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/price.tsx"],"sourcesContent":["\"use client\";\n\nimport { cn } from \"@simpleapps-com/augur-utils/web\";\nimport { createFormatPrice } from \"./price-format\";\nimport type { FormatPriceOptions } from \"./price-format\";\n\n// Re-export server-safe types so client consumers get everything from one path\nexport type { PriceFormatConfig, FormatPriceOptions } from \"./price-format\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface PriceClassNames {\n /** The formatted amount text. */\n amount?: string;\n /** The UOM label (e.g. \"EACH\"). */\n uom?: string;\n /** The separator between price and UOM (e.g. \"/\"). */\n separator?: string;\n /** The zero-price label (e.g. \"Call for Price\"). */\n zero?: string;\n /** The loading skeleton. */\n skeleton?: string;\n /** The strikethrough original price. */\n original?: string;\n}\n\nexport interface PriceConfig {\n /** ISO 4217 currency code. Default: `\"USD\"`. */\n currency?: string;\n /** BCP 47 locale. Default: `\"en-US\"`. */\n locale?: string;\n /** Decimal places. Default: `2`. */\n precision?: number;\n /** Label shown when value is 0. Default: `\"Call for Price\"`. */\n zeroLabel?: string;\n /** Separator between price and UOM. Default: `\"/\"`. */\n uomSeparator?: string;\n /** Default class names for sub-elements. */\n classNames?: PriceClassNames;\n}\n\ntype PricePropsBase = {\n /** Unit price. */\n value?: number;\n /** Quantity — multiplied by value for extended price. */\n quantity?: number;\n /** Unit of measure label (e.g. \"EACH\", \"FT\"). */\n uom?: string;\n /** Override precision for this instance. */\n precision?: number;\n /** Original price shown as strikethrough for sale display. */\n originalValue?: number;\n /** Additional class names for the root element. */\n className?: string;\n /** Class names for sub-elements, merged with factory defaults. */\n classNames?: PriceClassNames;\n};\n\nexport type PriceProps =\n | (PricePropsBase & { loading?: false })\n | { loading: true; className?: string; classNames?: PriceClassNames };\n\nexport interface CreatePriceResult {\n Price: React.FC<PriceProps>;\n formatPrice: (value: number, options?: FormatPriceOptions) => string;\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nconst defaults = {\n currency: \"USD\",\n locale: \"en-US\",\n precision: 2,\n zeroLabel: \"Call for Price\",\n uomSeparator: \"/\",\n} as const;\n\nexport function createPrice(config: PriceConfig = {}): CreatePriceResult {\n const {\n currency,\n locale,\n precision,\n zeroLabel,\n uomSeparator,\n classNames: factoryClassNames,\n } = { ...defaults, ...config };\n\n const formatPrice = createFormatPrice({ currency, locale, precision });\n\n const slotKeys: (keyof PriceClassNames)[] = [\n \"amount\", \"uom\", \"separator\", \"zero\", \"skeleton\", \"original\",\n ];\n\n function mergeClassNames(\n instance?: PriceClassNames,\n ): PriceClassNames {\n if (!factoryClassNames && !instance) return {};\n const result: PriceClassNames = {};\n for (const key of slotKeys) {\n const merged = cn(factoryClassNames?.[key], instance?.[key]);\n if (merged) result[key] = merged;\n }\n return result;\n }\n\n function Price(props: PriceProps) {\n if (\"loading\" in props && props.loading) {\n const slots = mergeClassNames(props.classNames);\n return (\n <span\n className={cn(\n \"inline-block h-4 w-16 animate-pulse rounded bg-muted\",\n slots.skeleton,\n props.className,\n )}\n />\n );\n }\n\n const {\n value = 0,\n quantity,\n uom,\n precision: instancePrecision,\n originalValue,\n className,\n classNames: instanceClassNames,\n } = props as PricePropsBase;\n\n const slots = mergeClassNames(instanceClassNames);\n\n if (value === 0 && originalValue === undefined) {\n return (\n <span className={cn(\"text-muted-foreground\", slots.zero, className)}>\n {zeroLabel}\n </span>\n );\n }\n\n const formatted = formatPrice(value, {\n precision: instancePrecision,\n quantity,\n });\n\n return (\n <span className={className}>\n {originalValue !== undefined && (\n <s className={cn(\"mr-1 text-muted-foreground\", slots.original)}>\n {formatPrice(originalValue, { precision: instancePrecision })}\n </s>\n )}\n <span className={slots.amount}>{formatted}</span>\n {uom && (\n <>\n <span className={cn(\"ml-1\", slots.separator)}>\n {uomSeparator}\n </span>\n <span className={cn(\"ml-1 text-muted-foreground\", slots.uom)}>\n {uom}\n </span>\n </>\n )}\n </span>\n );\n }\n\n Price.displayName = \"Price\";\n\n return { Price, formatPrice };\n}\n"],"mappings":";;;;;;;AAEA,SAAS,UAAU;AA+GX,SA4CE,UA5CF,KA4CE,YA5CF;AAxCR,IAAM,WAAW;AAAA,EACf,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;A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qBAAC,UAAK,WACH;AAAA,wBAAkB,UACjB,oBAAC,OAAE,WAAW,GAAG,8BAA8B,MAAM,QAAQ,GAC1D,sBAAY,eAAe,EAAE,WAAW,kBAAkB,CAAC,GAC9D;AAAA,MAEF,oBAAC,UAAK,WAAW,MAAM,QAAS,qBAAU;AAAA,MACzC,OACC,iCACE;AAAA,4BAAC,UAAK,WAAW,GAAG,QAAQ,MAAM,SAAS,GACxC,wBACH;AAAA,QACA,oBAAC,UAAK,WAAW,GAAG,8BAA8B,MAAM,GAAG,GACxD,eACH;AAAA,SACF;AAAA,OAEJ;AAAA,EAEJ;AAEA,QAAM,cAAc;AAEpB,SAAO,EAAE,OAAO,YAAY;AAC9B;","names":["slots"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/session-replay.tsx
|
|
5
|
+
var _react = require('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 = _react.useRef.call(void 0, false);
|
|
43
|
+
_react.useEffect.call(void 0, () => {
|
|
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
|
+
|
|
57
|
+
|
|
58
|
+
exports.SessionReplayScript = SessionReplayScript;
|
|
59
|
+
//# sourceMappingURL=session-replay.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/session-replay.cjs","../src/session-replay.tsx"],"names":[],"mappings":"AAAA,qFAAY;AACZ,YAAY;AACZ;AACA;ACDA,8BAAkC;AAoClC,SAAS,eAAA,CAAgB,MAAA,EAAsB;AAC7C,EAAA,GAAA,CAAI,OAAO,SAAA,IAAa,WAAA,EAAa,MAAA;AACrC,EAAA,GAAA,CAAI,QAAA,CAAS,cAAA,CAAe,kBAAkB,CAAA,EAAG,MAA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AA,EAAQ,IAAA;AACf,EAAA,MAAA,CAAO,MAAA,EAAQ,IAAA;AACf,EAAA,QAAA,CAAS,IAAA,CAAK,WAAA,CAAY,MAAM,CAAA;AAClC;AAEA,IAAM,UAAA,EAAqE;AAAA,EACzE,SAAA,EAAW,eAAA;AAAA,EACX,MAAA,EAAQ;AACV,CAAA;AAyBO,SAAS,mBAAA,CAAoB;AAAA,EAClC,QAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA,EAAa,CAAA;AAAA,EACb,SAAA,EAAW;AACb,CAAA,EAA6B;AAC3B,EAAA,MAAM,YAAA,EAAc,2BAAA,KAAY,CAAA;AAEhC,EAAA,8BAAA,CAAU,EAAA,GAAM;AACd,IAAA,GAAA,CAAI,SAAA,GAAY,WAAA,CAAY,OAAA,EAAS,MAAA;AACrC,IAAA,GAAA,CAAI,WAAA,EAAa,EAAA,GAAK,IAAA,CAAK,MAAA,CAAO,EAAA,EAAI,UAAA,EAAY,MAAA;AAElD,IAAA,WAAA,CAAY,QAAA,EAAU,IAAA;AAEtB,IAAA,MAAM,OAAA,EAAS,SAAA,CAAU,QAAQ,CAAA;AAGjC,IAAA,GAAA,CAAI,OAAO,oBAAA,IAAwB,UAAA,EAAY;AAC7C,MAAA,mBAAA,CAAoB,CAAA,EAAA,GAAM,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,IAC1C,EAAA,KAAO;AACL,MAAA,UAAA,CAAW,CAAA,EAAA,GAAM,MAAA,CAAO,MAAM,CAAA,EAAG,CAAC,CAAA;AAAA,IACpC;AAAA,EACF,CAAA,EAAG,CAAC,QAAA,EAAU,MAAA,EAAQ,UAAA,EAAY,QAAQ,CAAC,CAAA;AAE3C,EAAA,OAAO,IAAA;AACT;ADvEA;AACE;AACF,kDAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/session-replay.cjs","sourcesContent":[null,"\"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"]}
|
|
@@ -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,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.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Shared React UI components for Augur ecommerce sites (Radix + Tailwind)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -60,6 +60,16 @@
|
|
|
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
|
+
},
|
|
68
|
+
"./price-format": {
|
|
69
|
+
"types": "./dist/price-format.d.ts",
|
|
70
|
+
"import": "./dist/price-format.js",
|
|
71
|
+
"require": "./dist/price-format.cjs"
|
|
72
|
+
},
|
|
63
73
|
"./radio-group": {
|
|
64
74
|
"types": "./dist/radio-group.d.ts",
|
|
65
75
|
"import": "./dist/radio-group.js",
|
|
@@ -145,6 +155,11 @@
|
|
|
145
155
|
"import": "./dist/form-textarea.js",
|
|
146
156
|
"require": "./dist/form-textarea.cjs"
|
|
147
157
|
},
|
|
158
|
+
"./financing-widget": {
|
|
159
|
+
"types": "./dist/financing-widget.d.ts",
|
|
160
|
+
"import": "./dist/financing-widget.js",
|
|
161
|
+
"require": "./dist/financing-widget.cjs"
|
|
162
|
+
},
|
|
148
163
|
"./gtm": {
|
|
149
164
|
"types": "./dist/gtm.d.ts",
|
|
150
165
|
"import": "./dist/gtm.js",
|
|
@@ -154,6 +169,11 @@
|
|
|
154
169
|
"types": "./dist/mdx-components.d.ts",
|
|
155
170
|
"import": "./dist/mdx-components.js",
|
|
156
171
|
"require": "./dist/mdx-components.cjs"
|
|
172
|
+
},
|
|
173
|
+
"./session-replay": {
|
|
174
|
+
"types": "./dist/session-replay.d.ts",
|
|
175
|
+
"import": "./dist/session-replay.js",
|
|
176
|
+
"require": "./dist/session-replay.cjs"
|
|
157
177
|
}
|
|
158
178
|
},
|
|
159
179
|
"sideEffects": false,
|