@hifilabs/pixel 0.7.0 → 0.7.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.
- package/dist/index.esm.d.ts +5 -0
- package/dist/index.js +17 -0
- package/dist/index.mjs +17 -0
- package/package.json +1 -1
package/dist/index.esm.d.ts
CHANGED
|
@@ -53,7 +53,12 @@ export interface BalanceContextValue {
|
|
|
53
53
|
setConsent: (preferences: ConsentPreferences) => void;
|
|
54
54
|
getConsent: () => ConsentPreferences | null;
|
|
55
55
|
hasConsent: (type: 'analytics' | 'marketing' | 'personalization') => boolean;
|
|
56
|
+
/** True when the pixel script has loaded successfully */
|
|
56
57
|
isReady: boolean;
|
|
58
|
+
/** True if the pixel script failed to load */
|
|
59
|
+
isError: boolean;
|
|
60
|
+
/** Error object if script loading failed */
|
|
61
|
+
error: Error | null;
|
|
57
62
|
artistId: string;
|
|
58
63
|
projectId?: string;
|
|
59
64
|
endpoint?: string;
|
package/dist/index.js
CHANGED
|
@@ -100,6 +100,8 @@ var defaultContextValue = {
|
|
|
100
100
|
hasConsent: () => false,
|
|
101
101
|
// State - SSR-safe defaults
|
|
102
102
|
isReady: false,
|
|
103
|
+
isError: false,
|
|
104
|
+
error: null,
|
|
103
105
|
artistId: "",
|
|
104
106
|
projectId: void 0,
|
|
105
107
|
endpoint: void 0,
|
|
@@ -284,6 +286,8 @@ function BalanceProvider({
|
|
|
284
286
|
children
|
|
285
287
|
}) {
|
|
286
288
|
const [isReady, setIsReady] = (0, import_react4.useState)(false);
|
|
289
|
+
const [isError, setIsError] = (0, import_react4.useState)(false);
|
|
290
|
+
const [error, setError] = (0, import_react4.useState)(null);
|
|
287
291
|
const [shouldLoadScript, setShouldLoadScript] = (0, import_react4.useState)(false);
|
|
288
292
|
(0, import_react4.useEffect)(() => {
|
|
289
293
|
ensureGlobalStub();
|
|
@@ -390,6 +394,8 @@ function BalanceProvider({
|
|
|
390
394
|
hasConsent: hasConsent2,
|
|
391
395
|
// State
|
|
392
396
|
isReady,
|
|
397
|
+
isError,
|
|
398
|
+
error,
|
|
393
399
|
artistId,
|
|
394
400
|
projectId,
|
|
395
401
|
endpoint,
|
|
@@ -406,6 +412,8 @@ function BalanceProvider({
|
|
|
406
412
|
getConsent2,
|
|
407
413
|
hasConsent2,
|
|
408
414
|
isReady,
|
|
415
|
+
isError,
|
|
416
|
+
error,
|
|
409
417
|
artistId,
|
|
410
418
|
projectId,
|
|
411
419
|
endpoint,
|
|
@@ -419,8 +427,17 @@ function BalanceProvider({
|
|
|
419
427
|
}, [debug]);
|
|
420
428
|
const handleScriptError = (0, import_react4.useCallback)((e) => {
|
|
421
429
|
console.error("[BalanceProvider] Failed to load pixel script:", e);
|
|
430
|
+
setIsError(true);
|
|
431
|
+
setError(e);
|
|
422
432
|
}, []);
|
|
423
433
|
const resolvedScriptUrl = scriptUrl ?? DEFAULT_SCRIPT_URL;
|
|
434
|
+
(0, import_react4.useEffect)(() => {
|
|
435
|
+
if (debug && !scriptUrl) {
|
|
436
|
+
console.warn(
|
|
437
|
+
'[BalanceProvider] Using default CDN URL. For production, consider hosting the pixel script locally:\n1. Copy index.js from artist-os-distro/apps/web/public/scripts/\n2. Place it in your public/scripts/index.js\n3. Set scriptUrl="/scripts/index.js"\n\nThis avoids external dependencies and CSP issues.'
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
}, [debug, scriptUrl]);
|
|
424
441
|
const content = /* @__PURE__ */ import_react4.default.createElement(BalanceContext.Provider, { value: contextValue }, shouldLoadScript && /* @__PURE__ */ import_react4.default.createElement(
|
|
425
442
|
import_script2.default,
|
|
426
443
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -31,6 +31,8 @@ var defaultContextValue = {
|
|
|
31
31
|
hasConsent: () => false,
|
|
32
32
|
// State - SSR-safe defaults
|
|
33
33
|
isReady: false,
|
|
34
|
+
isError: false,
|
|
35
|
+
error: null,
|
|
34
36
|
artistId: "",
|
|
35
37
|
projectId: void 0,
|
|
36
38
|
endpoint: void 0,
|
|
@@ -215,6 +217,8 @@ function BalanceProvider({
|
|
|
215
217
|
children
|
|
216
218
|
}) {
|
|
217
219
|
const [isReady, setIsReady] = useState(false);
|
|
220
|
+
const [isError, setIsError] = useState(false);
|
|
221
|
+
const [error, setError] = useState(null);
|
|
218
222
|
const [shouldLoadScript, setShouldLoadScript] = useState(false);
|
|
219
223
|
useEffect2(() => {
|
|
220
224
|
ensureGlobalStub();
|
|
@@ -321,6 +325,8 @@ function BalanceProvider({
|
|
|
321
325
|
hasConsent: hasConsent2,
|
|
322
326
|
// State
|
|
323
327
|
isReady,
|
|
328
|
+
isError,
|
|
329
|
+
error,
|
|
324
330
|
artistId,
|
|
325
331
|
projectId,
|
|
326
332
|
endpoint,
|
|
@@ -337,6 +343,8 @@ function BalanceProvider({
|
|
|
337
343
|
getConsent2,
|
|
338
344
|
hasConsent2,
|
|
339
345
|
isReady,
|
|
346
|
+
isError,
|
|
347
|
+
error,
|
|
340
348
|
artistId,
|
|
341
349
|
projectId,
|
|
342
350
|
endpoint,
|
|
@@ -350,8 +358,17 @@ function BalanceProvider({
|
|
|
350
358
|
}, [debug]);
|
|
351
359
|
const handleScriptError = useCallback2((e) => {
|
|
352
360
|
console.error("[BalanceProvider] Failed to load pixel script:", e);
|
|
361
|
+
setIsError(true);
|
|
362
|
+
setError(e);
|
|
353
363
|
}, []);
|
|
354
364
|
const resolvedScriptUrl = scriptUrl ?? DEFAULT_SCRIPT_URL;
|
|
365
|
+
useEffect2(() => {
|
|
366
|
+
if (debug && !scriptUrl) {
|
|
367
|
+
console.warn(
|
|
368
|
+
'[BalanceProvider] Using default CDN URL. For production, consider hosting the pixel script locally:\n1. Copy index.js from artist-os-distro/apps/web/public/scripts/\n2. Place it in your public/scripts/index.js\n3. Set scriptUrl="/scripts/index.js"\n\nThis avoids external dependencies and CSP issues.'
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
}, [debug, scriptUrl]);
|
|
355
372
|
const content = /* @__PURE__ */ React3.createElement(BalanceContext.Provider, { value: contextValue }, shouldLoadScript && /* @__PURE__ */ React3.createElement(
|
|
356
373
|
Script2,
|
|
357
374
|
{
|