@syntrologie/runtime-sdk 0.2.20 → 1.0.1-canary.0
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/CAPABILITIES.md +211 -0
- package/dist/SmartCanvasElement.js +11 -1
- package/dist/SmartCanvasElement.js.map +1 -1
- package/dist/api.js +26 -12
- package/dist/api.js.map +1 -1
- package/dist/bootstrap.d.ts +16 -2
- package/dist/bootstrap.js +84 -30
- package/dist/bootstrap.js.map +1 -1
- package/dist/configFetcher.js +2 -1
- package/dist/configFetcher.js.map +1 -1
- package/dist/context/ContextManager.d.ts +66 -0
- package/dist/context/ContextManager.js +268 -0
- package/dist/context/ContextManager.js.map +1 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/index.js +7 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/schema.d.ts +360 -0
- package/dist/context/schema.js +50 -0
- package/dist/context/schema.js.map +1 -0
- package/dist/context/types.d.ts +101 -0
- package/dist/context/types.js +8 -0
- package/dist/context/types.js.map +1 -0
- package/dist/decisions/engine.d.ts +43 -0
- package/dist/decisions/engine.js +112 -0
- package/dist/decisions/engine.js.map +1 -0
- package/dist/decisions/index.d.ts +9 -0
- package/dist/decisions/index.js +10 -0
- package/dist/decisions/index.js.map +1 -0
- package/dist/decisions/schema.d.ts +2166 -0
- package/dist/decisions/schema.js +143 -0
- package/dist/decisions/schema.js.map +1 -0
- package/dist/decisions/strategies/rules.d.ts +24 -0
- package/dist/decisions/strategies/rules.js +152 -0
- package/dist/decisions/strategies/rules.js.map +1 -0
- package/dist/decisions/strategies/score.d.ts +10 -0
- package/dist/decisions/strategies/score.js +29 -0
- package/dist/decisions/strategies/score.js.map +1 -0
- package/dist/decisions/types.d.ts +242 -0
- package/dist/decisions/types.js +2 -0
- package/dist/decisions/types.js.map +1 -0
- package/dist/editorLoader.d.ts +10 -0
- package/dist/editorLoader.js +68 -29
- package/dist/editorLoader.js.map +1 -1
- package/dist/events/EventBus.d.ts +59 -0
- package/dist/events/EventBus.js +154 -0
- package/dist/events/EventBus.js.map +1 -0
- package/dist/events/index.d.ts +9 -0
- package/dist/events/index.js +10 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/normalizers/canvas.d.ts +67 -0
- package/dist/events/normalizers/canvas.js +116 -0
- package/dist/events/normalizers/canvas.js.map +1 -0
- package/dist/events/normalizers/posthog.d.ts +29 -0
- package/dist/events/normalizers/posthog.js +155 -0
- package/dist/events/normalizers/posthog.js.map +1 -0
- package/dist/events/schema.d.ts +70 -0
- package/dist/events/schema.js +30 -0
- package/dist/events/schema.js.map +1 -0
- package/dist/events/types.d.ts +73 -0
- package/dist/events/types.js +41 -0
- package/dist/events/types.js.map +1 -0
- package/dist/hooks/useShadowCanvasConfig.d.ts +5 -1
- package/dist/hooks/useShadowCanvasConfig.js +17 -3
- package/dist/hooks/useShadowCanvasConfig.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +29 -0
- package/dist/logger.js +81 -0
- package/dist/logger.js.map +1 -0
- package/dist/overlays/schema.d.ts +55 -55
- package/dist/runtime.d.ts +86 -0
- package/dist/runtime.js +132 -0
- package/dist/runtime.js.map +1 -0
- package/dist/smart-canvas.esm.js +11 -11
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +1801 -249
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +12 -11
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/state/StateStore.d.ts +41 -0
- package/dist/state/StateStore.js +170 -0
- package/dist/state/StateStore.js.map +1 -0
- package/dist/state/helpers/cooldowns.d.ts +7 -0
- package/dist/state/helpers/cooldowns.js +31 -0
- package/dist/state/helpers/cooldowns.js.map +1 -0
- package/dist/state/helpers/dismissals.d.ts +7 -0
- package/dist/state/helpers/dismissals.js +34 -0
- package/dist/state/helpers/dismissals.js.map +1 -0
- package/dist/state/helpers/frequency.d.ts +8 -0
- package/dist/state/helpers/frequency.js +43 -0
- package/dist/state/helpers/frequency.js.map +1 -0
- package/dist/state/index.d.ts +7 -0
- package/dist/state/index.js +7 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/schema.d.ts +49 -0
- package/dist/state/schema.js +25 -0
- package/dist/state/schema.js.map +1 -0
- package/dist/state/types.d.ts +137 -0
- package/dist/state/types.js +9 -0
- package/dist/state/types.js.map +1 -0
- package/dist/telemetry/adapters/posthog.d.ts +1 -1
- package/dist/telemetry/adapters/posthog.js +1 -1
- package/dist/telemetry/adapters/posthog.js.map +1 -1
- package/dist/token.d.ts +2 -0
- package/dist/token.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/package.json +7 -4
- package/schema/canvas-config.schema.json +205 -0
- package/schema/runtime-context.schema.json +131 -0
package/dist/smart-canvas.js
CHANGED
|
@@ -282,8 +282,8 @@ var SyntrologieSDK = (() => {
|
|
|
282
282
|
function(fulfilledValue) {
|
|
283
283
|
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
|
284
284
|
},
|
|
285
|
-
function(
|
|
286
|
-
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason =
|
|
285
|
+
function(error2) {
|
|
286
|
+
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error2);
|
|
287
287
|
}
|
|
288
288
|
)), thenable.status) {
|
|
289
289
|
case "fulfilled":
|
|
@@ -399,13 +399,13 @@ var SyntrologieSDK = (() => {
|
|
|
399
399
|
void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
|
|
400
400
|
}
|
|
401
401
|
},
|
|
402
|
-
function(
|
|
402
|
+
function(error2) {
|
|
403
403
|
if (0 === payload._status || -1 === payload._status) {
|
|
404
404
|
payload._status = 2;
|
|
405
|
-
payload._result =
|
|
405
|
+
payload._result = error2;
|
|
406
406
|
var _ioInfo2 = payload._ioInfo;
|
|
407
407
|
null != _ioInfo2 && (_ioInfo2.end = performance.now());
|
|
408
|
-
void 0 === thenable.status && (thenable.status = "rejected", thenable.reason =
|
|
408
|
+
void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error2);
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
);
|
|
@@ -476,8 +476,8 @@ var SyntrologieSDK = (() => {
|
|
|
476
476
|
return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
477
477
|
});
|
|
478
478
|
return;
|
|
479
|
-
} catch (
|
|
480
|
-
ReactSharedInternals.thrownErrors.push(
|
|
479
|
+
} catch (error2) {
|
|
480
|
+
ReactSharedInternals.thrownErrors.push(error2);
|
|
481
481
|
}
|
|
482
482
|
else ReactSharedInternals.actQueue = null;
|
|
483
483
|
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
|
|
@@ -503,8 +503,8 @@ var SyntrologieSDK = (() => {
|
|
|
503
503
|
} while (1);
|
|
504
504
|
}
|
|
505
505
|
queue.length = 0;
|
|
506
|
-
} catch (
|
|
507
|
-
queue.splice(0, i2 + 1), ReactSharedInternals.thrownErrors.push(
|
|
506
|
+
} catch (error2) {
|
|
507
|
+
queue.splice(0, i2 + 1), ReactSharedInternals.thrownErrors.push(error2);
|
|
508
508
|
} finally {
|
|
509
509
|
isFlushing = false;
|
|
510
510
|
}
|
|
@@ -582,20 +582,20 @@ var SyntrologieSDK = (() => {
|
|
|
582
582
|
UnknownOwner
|
|
583
583
|
)();
|
|
584
584
|
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
585
|
-
var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(
|
|
585
|
+
var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error2) {
|
|
586
586
|
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
587
587
|
var event = new window.ErrorEvent("error", {
|
|
588
588
|
bubbles: true,
|
|
589
589
|
cancelable: true,
|
|
590
|
-
message: "object" === typeof
|
|
591
|
-
error
|
|
590
|
+
message: "object" === typeof error2 && null !== error2 && "string" === typeof error2.message ? String(error2.message) : String(error2),
|
|
591
|
+
error: error2
|
|
592
592
|
});
|
|
593
593
|
if (!window.dispatchEvent(event)) return;
|
|
594
594
|
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
595
|
-
process.emit("uncaughtException",
|
|
595
|
+
process.emit("uncaughtException", error2);
|
|
596
596
|
return;
|
|
597
597
|
}
|
|
598
|
-
console.error(
|
|
598
|
+
console.error(error2);
|
|
599
599
|
}, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
|
|
600
600
|
queueMicrotask(function() {
|
|
601
601
|
return queueMicrotask(callback);
|
|
@@ -654,8 +654,8 @@ var SyntrologieSDK = (() => {
|
|
|
654
654
|
var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
|
|
655
655
|
try {
|
|
656
656
|
var result = callback();
|
|
657
|
-
} catch (
|
|
658
|
-
ReactSharedInternals.thrownErrors.push(
|
|
657
|
+
} catch (error2) {
|
|
658
|
+
ReactSharedInternals.thrownErrors.push(error2);
|
|
659
659
|
}
|
|
660
660
|
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
661
661
|
throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
@@ -693,11 +693,11 @@ var SyntrologieSDK = (() => {
|
|
|
693
693
|
}
|
|
694
694
|
} else resolve(returnValue);
|
|
695
695
|
},
|
|
696
|
-
function(
|
|
696
|
+
function(error2) {
|
|
697
697
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
698
|
-
0 < ReactSharedInternals.thrownErrors.length ? (
|
|
698
|
+
0 < ReactSharedInternals.thrownErrors.length ? (error2 = aggregateErrors(
|
|
699
699
|
ReactSharedInternals.thrownErrors
|
|
700
|
-
), ReactSharedInternals.thrownErrors.length = 0, reject(
|
|
700
|
+
), ReactSharedInternals.thrownErrors.length = 0, reject(error2)) : reject(error2);
|
|
701
701
|
}
|
|
702
702
|
);
|
|
703
703
|
}
|
|
@@ -917,8 +917,8 @@ var SyntrologieSDK = (() => {
|
|
|
917
917
|
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
|
918
918
|
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
919
919
|
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
|
|
920
|
-
} catch (
|
|
921
|
-
reportGlobalError(
|
|
920
|
+
} catch (error2) {
|
|
921
|
+
reportGlobalError(error2);
|
|
922
922
|
} finally {
|
|
923
923
|
null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
|
|
924
924
|
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
|
@@ -5093,23 +5093,23 @@ var SyntrologieSDK = (() => {
|
|
|
5093
5093
|
"disabledDepth fell below zero. This is a bug in React. Please file an issue."
|
|
5094
5094
|
);
|
|
5095
5095
|
}
|
|
5096
|
-
function formatOwnerStack(
|
|
5096
|
+
function formatOwnerStack(error2) {
|
|
5097
5097
|
var prevPrepareStackTrace = Error.prepareStackTrace;
|
|
5098
5098
|
Error.prepareStackTrace = void 0;
|
|
5099
|
-
|
|
5099
|
+
error2 = error2.stack;
|
|
5100
5100
|
Error.prepareStackTrace = prevPrepareStackTrace;
|
|
5101
|
-
|
|
5102
|
-
prevPrepareStackTrace =
|
|
5103
|
-
-1 !== prevPrepareStackTrace && (
|
|
5104
|
-
prevPrepareStackTrace =
|
|
5105
|
-
-1 !== prevPrepareStackTrace && (prevPrepareStackTrace =
|
|
5101
|
+
error2.startsWith("Error: react-stack-top-frame\n") && (error2 = error2.slice(29));
|
|
5102
|
+
prevPrepareStackTrace = error2.indexOf("\n");
|
|
5103
|
+
-1 !== prevPrepareStackTrace && (error2 = error2.slice(prevPrepareStackTrace + 1));
|
|
5104
|
+
prevPrepareStackTrace = error2.indexOf("react_stack_bottom_frame");
|
|
5105
|
+
-1 !== prevPrepareStackTrace && (prevPrepareStackTrace = error2.lastIndexOf(
|
|
5106
5106
|
"\n",
|
|
5107
5107
|
prevPrepareStackTrace
|
|
5108
5108
|
));
|
|
5109
5109
|
if (-1 !== prevPrepareStackTrace)
|
|
5110
|
-
|
|
5110
|
+
error2 = error2.slice(0, prevPrepareStackTrace);
|
|
5111
5111
|
else return "";
|
|
5112
|
-
return
|
|
5112
|
+
return error2;
|
|
5113
5113
|
}
|
|
5114
5114
|
function describeBuiltInComponentFrame(name) {
|
|
5115
5115
|
if (void 0 === prefix)
|
|
@@ -7606,10 +7606,10 @@ var SyntrologieSDK = (() => {
|
|
|
7606
7606
|
if (null !== name) {
|
|
7607
7607
|
selfTime = [];
|
|
7608
7608
|
for (var i2 = 0; i2 < errors.length; i2++) {
|
|
7609
|
-
var
|
|
7609
|
+
var error2 = errors[i2].value;
|
|
7610
7610
|
selfTime.push([
|
|
7611
7611
|
"Error",
|
|
7612
|
-
"object" === typeof
|
|
7612
|
+
"object" === typeof error2 && null !== error2 && "string" === typeof error2.message ? String(error2.message) : String(error2)
|
|
7613
7613
|
]);
|
|
7614
7614
|
}
|
|
7615
7615
|
null !== fiber.key && addValueToProperties("key", fiber.key, selfTime, 0, "");
|
|
@@ -7723,10 +7723,10 @@ var SyntrologieSDK = (() => {
|
|
|
7723
7723
|
if (supportsUserTiming && !(endTime <= startTime)) {
|
|
7724
7724
|
lanes = [];
|
|
7725
7725
|
for (var i2 = 0; i2 < recoverableErrors.length; i2++) {
|
|
7726
|
-
var
|
|
7726
|
+
var error2 = recoverableErrors[i2].value;
|
|
7727
7727
|
lanes.push([
|
|
7728
7728
|
"Recoverable Error",
|
|
7729
|
-
"object" === typeof
|
|
7729
|
+
"object" === typeof error2 && null !== error2 && "string" === typeof error2.message ? String(error2.message) : String(error2)
|
|
7730
7730
|
]);
|
|
7731
7731
|
}
|
|
7732
7732
|
startTime = {
|
|
@@ -7790,10 +7790,10 @@ var SyntrologieSDK = (() => {
|
|
|
7790
7790
|
function logCommitErrored(startTime, endTime, errors, passive, debugTask) {
|
|
7791
7791
|
if (supportsUserTiming && !(endTime <= startTime)) {
|
|
7792
7792
|
for (var properties = [], i2 = 0; i2 < errors.length; i2++) {
|
|
7793
|
-
var
|
|
7793
|
+
var error2 = errors[i2].value;
|
|
7794
7794
|
properties.push([
|
|
7795
7795
|
"Error",
|
|
7796
|
-
"object" === typeof
|
|
7796
|
+
"object" === typeof error2 && null !== error2 && "string" === typeof error2.message ? String(error2.message) : String(error2)
|
|
7797
7797
|
]);
|
|
7798
7798
|
}
|
|
7799
7799
|
startTime = {
|
|
@@ -8417,8 +8417,8 @@ var SyntrologieSDK = (() => {
|
|
|
8417
8417
|
), hydrationErrors = null);
|
|
8418
8418
|
return queuedErrors;
|
|
8419
8419
|
}
|
|
8420
|
-
function queueHydrationError(
|
|
8421
|
-
null === hydrationErrors ? hydrationErrors = [
|
|
8420
|
+
function queueHydrationError(error2) {
|
|
8421
|
+
null === hydrationErrors ? hydrationErrors = [error2] : hydrationErrors.push(error2);
|
|
8422
8422
|
}
|
|
8423
8423
|
function emitPendingHydrationWarnings() {
|
|
8424
8424
|
var diffRoot = hydrationDiffRootDEV;
|
|
@@ -8784,11 +8784,11 @@ var SyntrologieSDK = (() => {
|
|
|
8784
8784
|
thenableWithOverride.value = result;
|
|
8785
8785
|
for (var i2 = 0; i2 < listeners.length; i2++) (0, listeners[i2])(result);
|
|
8786
8786
|
},
|
|
8787
|
-
function(
|
|
8787
|
+
function(error2) {
|
|
8788
8788
|
thenableWithOverride.status = "rejected";
|
|
8789
|
-
thenableWithOverride.reason =
|
|
8790
|
-
for (
|
|
8791
|
-
(0, listeners[
|
|
8789
|
+
thenableWithOverride.reason = error2;
|
|
8790
|
+
for (error2 = 0; error2 < listeners.length; error2++)
|
|
8791
|
+
(0, listeners[error2])(void 0);
|
|
8792
8792
|
}
|
|
8793
8793
|
);
|
|
8794
8794
|
return thenableWithOverride;
|
|
@@ -8856,11 +8856,11 @@ var SyntrologieSDK = (() => {
|
|
|
8856
8856
|
fulfilledThenable.value = fulfilledValue;
|
|
8857
8857
|
}
|
|
8858
8858
|
},
|
|
8859
|
-
function(
|
|
8859
|
+
function(error2) {
|
|
8860
8860
|
if ("pending" === thenable.status) {
|
|
8861
8861
|
var rejectedThenable = thenable;
|
|
8862
8862
|
rejectedThenable.status = "rejected";
|
|
8863
|
-
rejectedThenable.reason =
|
|
8863
|
+
rejectedThenable.reason = error2;
|
|
8864
8864
|
}
|
|
8865
8865
|
}
|
|
8866
8866
|
);
|
|
@@ -10453,7 +10453,7 @@ var SyntrologieSDK = (() => {
|
|
|
10453
10453
|
try {
|
|
10454
10454
|
var nextValue = latestGetSnapshot();
|
|
10455
10455
|
return !objectIs(inst, nextValue);
|
|
10456
|
-
} catch (
|
|
10456
|
+
} catch (error2) {
|
|
10457
10457
|
return true;
|
|
10458
10458
|
}
|
|
10459
10459
|
}
|
|
@@ -10564,8 +10564,8 @@ var SyntrologieSDK = (() => {
|
|
|
10564
10564
|
var returnValue = action(prevState, payload), onStartTransitionFinish = ReactSharedInternals.S;
|
|
10565
10565
|
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
10566
10566
|
handleActionReturnValue(actionQueue, node, returnValue);
|
|
10567
|
-
} catch (
|
|
10568
|
-
onActionError(actionQueue, node,
|
|
10567
|
+
} catch (error2) {
|
|
10568
|
+
onActionError(actionQueue, node, error2);
|
|
10569
10569
|
} finally {
|
|
10570
10570
|
null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
|
|
10571
10571
|
"We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
|
|
@@ -10585,8 +10585,8 @@ var SyntrologieSDK = (() => {
|
|
|
10585
10585
|
function(nextState) {
|
|
10586
10586
|
onActionSuccess(actionQueue, node, nextState);
|
|
10587
10587
|
},
|
|
10588
|
-
function(
|
|
10589
|
-
return onActionError(actionQueue, node,
|
|
10588
|
+
function(error2) {
|
|
10589
|
+
return onActionError(actionQueue, node, error2);
|
|
10590
10590
|
}
|
|
10591
10591
|
), node.isTransition || console.error(
|
|
10592
10592
|
"An async function with useActionState was called outside of a transition. This is likely not what you intended (for example, isPending will not update correctly). Either call the returned function inside startTransition, or pass it to an `action` or `formAction` prop."
|
|
@@ -10600,13 +10600,13 @@ var SyntrologieSDK = (() => {
|
|
|
10600
10600
|
actionNode = actionQueue.pending;
|
|
10601
10601
|
null !== actionNode && (nextState = actionNode.next, nextState === actionNode ? actionQueue.pending = null : (nextState = nextState.next, actionNode.next = nextState, runActionStateAction(actionQueue, nextState)));
|
|
10602
10602
|
}
|
|
10603
|
-
function onActionError(actionQueue, actionNode,
|
|
10603
|
+
function onActionError(actionQueue, actionNode, error2) {
|
|
10604
10604
|
var last = actionQueue.pending;
|
|
10605
10605
|
actionQueue.pending = null;
|
|
10606
10606
|
if (null !== last) {
|
|
10607
10607
|
last = last.next;
|
|
10608
10608
|
do
|
|
10609
|
-
actionNode.status = "rejected", actionNode.reason =
|
|
10609
|
+
actionNode.status = "rejected", actionNode.reason = error2, notifyActionListeners(actionNode), actionNode = actionNode.next;
|
|
10610
10610
|
while (actionNode !== last);
|
|
10611
10611
|
}
|
|
10612
10612
|
actionQueue.action = null;
|
|
@@ -10986,12 +10986,12 @@ var SyntrologieSDK = (() => {
|
|
|
10986
10986
|
finishedState,
|
|
10987
10987
|
requestUpdateLane(fiber)
|
|
10988
10988
|
);
|
|
10989
|
-
} catch (
|
|
10989
|
+
} catch (error2) {
|
|
10990
10990
|
dispatchSetStateInternal(
|
|
10991
10991
|
fiber,
|
|
10992
10992
|
queue,
|
|
10993
10993
|
{ then: function() {
|
|
10994
|
-
}, status: "rejected", reason:
|
|
10994
|
+
}, status: "rejected", reason: error2 },
|
|
10995
10995
|
requestUpdateLane(fiber)
|
|
10996
10996
|
);
|
|
10997
10997
|
} finally {
|
|
@@ -11181,7 +11181,7 @@ var SyntrologieSDK = (() => {
|
|
|
11181
11181
|
update.eagerState = eagerState;
|
|
11182
11182
|
if (objectIs(eagerState, currentState))
|
|
11183
11183
|
return enqueueUpdate$1(fiber, queue, update, 0), null === workInProgressRoot && finishQueueingConcurrentUpdates(), false;
|
|
11184
|
-
} catch (
|
|
11184
|
+
} catch (error2) {
|
|
11185
11185
|
} finally {
|
|
11186
11186
|
ReactSharedInternals.H = prevDispatcher;
|
|
11187
11187
|
}
|
|
@@ -11318,32 +11318,32 @@ var SyntrologieSDK = (() => {
|
|
|
11318
11318
|
}
|
|
11319
11319
|
return newProps;
|
|
11320
11320
|
}
|
|
11321
|
-
function defaultOnUncaughtError(
|
|
11322
|
-
reportGlobalError(
|
|
11321
|
+
function defaultOnUncaughtError(error2) {
|
|
11322
|
+
reportGlobalError(error2);
|
|
11323
11323
|
console.warn(
|
|
11324
11324
|
"%s\n\n%s\n",
|
|
11325
11325
|
componentName ? "An error occurred in the <" + componentName + "> component." : "An error occurred in one of your React components.",
|
|
11326
11326
|
"Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://react.dev/link/error-boundaries to learn more about error boundaries."
|
|
11327
11327
|
);
|
|
11328
11328
|
}
|
|
11329
|
-
function defaultOnCaughtError(
|
|
11329
|
+
function defaultOnCaughtError(error2) {
|
|
11330
11330
|
var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component." : "The above error occurred in one of your React components.", recreateMessage = "React will try to recreate this component tree from scratch using the error boundary you provided, " + ((errorBoundaryName || "Anonymous") + ".");
|
|
11331
|
-
if ("object" === typeof
|
|
11332
|
-
var JSCompiler_inline_result =
|
|
11333
|
-
|
|
11331
|
+
if ("object" === typeof error2 && null !== error2 && "string" === typeof error2.environmentName) {
|
|
11332
|
+
var JSCompiler_inline_result = error2.environmentName;
|
|
11333
|
+
error2 = [
|
|
11334
11334
|
"%o\n\n%s\n\n%s\n",
|
|
11335
|
-
|
|
11335
|
+
error2,
|
|
11336
11336
|
componentNameMessage,
|
|
11337
11337
|
recreateMessage
|
|
11338
11338
|
].slice(0);
|
|
11339
|
-
"string" === typeof
|
|
11339
|
+
"string" === typeof error2[0] ? error2.splice(
|
|
11340
11340
|
0,
|
|
11341
11341
|
1,
|
|
11342
|
-
badgeFormat + " " +
|
|
11342
|
+
badgeFormat + " " + error2[0],
|
|
11343
11343
|
badgeStyle,
|
|
11344
11344
|
pad + JSCompiler_inline_result + pad,
|
|
11345
11345
|
resetStyle
|
|
11346
|
-
) :
|
|
11346
|
+
) : error2.splice(
|
|
11347
11347
|
0,
|
|
11348
11348
|
0,
|
|
11349
11349
|
badgeFormat,
|
|
@@ -11351,30 +11351,30 @@ var SyntrologieSDK = (() => {
|
|
|
11351
11351
|
pad + JSCompiler_inline_result + pad,
|
|
11352
11352
|
resetStyle
|
|
11353
11353
|
);
|
|
11354
|
-
|
|
11355
|
-
JSCompiler_inline_result = bind.apply(console.error,
|
|
11354
|
+
error2.unshift(console);
|
|
11355
|
+
JSCompiler_inline_result = bind.apply(console.error, error2);
|
|
11356
11356
|
JSCompiler_inline_result();
|
|
11357
11357
|
} else
|
|
11358
11358
|
console.error(
|
|
11359
11359
|
"%o\n\n%s\n\n%s\n",
|
|
11360
|
-
|
|
11360
|
+
error2,
|
|
11361
11361
|
componentNameMessage,
|
|
11362
11362
|
recreateMessage
|
|
11363
11363
|
);
|
|
11364
11364
|
}
|
|
11365
|
-
function defaultOnRecoverableError(
|
|
11366
|
-
reportGlobalError(
|
|
11365
|
+
function defaultOnRecoverableError(error2) {
|
|
11366
|
+
reportGlobalError(error2);
|
|
11367
11367
|
}
|
|
11368
11368
|
function logUncaughtError(root2, errorInfo) {
|
|
11369
11369
|
try {
|
|
11370
11370
|
componentName = errorInfo.source ? getComponentNameFromFiber(errorInfo.source) : null;
|
|
11371
11371
|
errorBoundaryName = null;
|
|
11372
|
-
var
|
|
11372
|
+
var error2 = errorInfo.value;
|
|
11373
11373
|
if (null !== ReactSharedInternals.actQueue)
|
|
11374
|
-
ReactSharedInternals.thrownErrors.push(
|
|
11374
|
+
ReactSharedInternals.thrownErrors.push(error2);
|
|
11375
11375
|
else {
|
|
11376
11376
|
var onUncaughtError = root2.onUncaughtError;
|
|
11377
|
-
onUncaughtError(
|
|
11377
|
+
onUncaughtError(error2, { componentStack: errorInfo.stack });
|
|
11378
11378
|
}
|
|
11379
11379
|
} catch (e$5) {
|
|
11380
11380
|
setTimeout(function() {
|
|
@@ -11414,9 +11414,9 @@ var SyntrologieSDK = (() => {
|
|
|
11414
11414
|
function initializeClassErrorUpdate(update, root2, fiber, errorInfo) {
|
|
11415
11415
|
var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
|
|
11416
11416
|
if ("function" === typeof getDerivedStateFromError) {
|
|
11417
|
-
var
|
|
11417
|
+
var error2 = errorInfo.value;
|
|
11418
11418
|
update.payload = function() {
|
|
11419
|
-
return getDerivedStateFromError(
|
|
11419
|
+
return getDerivedStateFromError(error2);
|
|
11420
11420
|
};
|
|
11421
11421
|
update.callback = function() {
|
|
11422
11422
|
markFailedErrorBoundaryForHotReloading(fiber);
|
|
@@ -11502,14 +11502,14 @@ var SyntrologieSDK = (() => {
|
|
|
11502
11502
|
value,
|
|
11503
11503
|
rootRenderLanes
|
|
11504
11504
|
), enqueueCapturedUpdate(root2, rootRenderLanes), workInProgressRootExitStatus !== RootSuspendedWithDelay && (workInProgressRootExitStatus = RootErrored)), false;
|
|
11505
|
-
var
|
|
11505
|
+
var error2 = createCapturedValueAtFiber(
|
|
11506
11506
|
Error(
|
|
11507
11507
|
"There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root.",
|
|
11508
11508
|
{ cause: value }
|
|
11509
11509
|
),
|
|
11510
11510
|
sourceFiber
|
|
11511
11511
|
);
|
|
11512
|
-
null === workInProgressRootConcurrentErrors ? workInProgressRootConcurrentErrors = [
|
|
11512
|
+
null === workInProgressRootConcurrentErrors ? workInProgressRootConcurrentErrors = [error2] : workInProgressRootConcurrentErrors.push(error2);
|
|
11513
11513
|
workInProgressRootExitStatus !== RootSuspendedWithDelay && (workInProgressRootExitStatus = RootErrored);
|
|
11514
11514
|
if (null === returnFiber) return true;
|
|
11515
11515
|
value = createCapturedValueAtFiber(value, sourceFiber);
|
|
@@ -11523,7 +11523,7 @@ var SyntrologieSDK = (() => {
|
|
|
11523
11523
|
root2
|
|
11524
11524
|
), enqueueCapturedUpdate(sourceFiber, root2), false;
|
|
11525
11525
|
case 1:
|
|
11526
|
-
if (returnFiber = sourceFiber.type,
|
|
11526
|
+
if (returnFiber = sourceFiber.type, error2 = sourceFiber.stateNode, 0 === (sourceFiber.flags & 128) && ("function" === typeof returnFiber.getDerivedStateFromError || null !== error2 && "function" === typeof error2.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(error2))))
|
|
11527
11527
|
return sourceFiber.flags |= 65536, rootRenderLanes &= -rootRenderLanes, sourceFiber.lanes |= rootRenderLanes, rootRenderLanes = createClassErrorUpdate(rootRenderLanes), initializeClassErrorUpdate(
|
|
11528
11528
|
rootRenderLanes,
|
|
11529
11529
|
root2,
|
|
@@ -13790,8 +13790,8 @@ var SyntrologieSDK = (() => {
|
|
|
13790
13790
|
updateQueue = updateQueue.next;
|
|
13791
13791
|
} while (updateQueue !== firstEffect);
|
|
13792
13792
|
}
|
|
13793
|
-
} catch (
|
|
13794
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
13793
|
+
} catch (error2) {
|
|
13794
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
13795
13795
|
}
|
|
13796
13796
|
}
|
|
13797
13797
|
function commitHookEffectListUnmount(flags, finishedWork, nearestMountedAncestor) {
|
|
@@ -13814,8 +13814,8 @@ var SyntrologieSDK = (() => {
|
|
|
13814
13814
|
updateQueue = updateQueue.next;
|
|
13815
13815
|
} while (updateQueue !== firstEffect);
|
|
13816
13816
|
}
|
|
13817
|
-
} catch (
|
|
13818
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
13817
|
+
} catch (error2) {
|
|
13818
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
13819
13819
|
}
|
|
13820
13820
|
}
|
|
13821
13821
|
function commitHookPassiveMountEffects(finishedWork, hookFlags) {
|
|
@@ -13850,8 +13850,8 @@ var SyntrologieSDK = (() => {
|
|
|
13850
13850
|
updateQueue,
|
|
13851
13851
|
instance
|
|
13852
13852
|
);
|
|
13853
|
-
} catch (
|
|
13854
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
13853
|
+
} catch (error2) {
|
|
13854
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
13855
13855
|
}
|
|
13856
13856
|
}
|
|
13857
13857
|
}
|
|
@@ -13888,8 +13888,8 @@ var SyntrologieSDK = (() => {
|
|
|
13888
13888
|
);
|
|
13889
13889
|
}));
|
|
13890
13890
|
current2.__reactInternalSnapshotBeforeUpdate = snapshot;
|
|
13891
|
-
} catch (
|
|
13892
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
13891
|
+
} catch (error2) {
|
|
13892
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
13893
13893
|
}
|
|
13894
13894
|
}
|
|
13895
13895
|
function safelyCallComponentWillUnmount(current2, nearestMountedAncestor, instance) {
|
|
@@ -13945,8 +13945,8 @@ var SyntrologieSDK = (() => {
|
|
|
13945
13945
|
function safelyAttachRef(current2, nearestMountedAncestor) {
|
|
13946
13946
|
try {
|
|
13947
13947
|
runWithFiberInDEV(current2, commitAttachRef, current2);
|
|
13948
|
-
} catch (
|
|
13949
|
-
captureCommitPhaseError(current2, nearestMountedAncestor,
|
|
13948
|
+
} catch (error2) {
|
|
13949
|
+
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
|
13950
13950
|
}
|
|
13951
13951
|
}
|
|
13952
13952
|
function safelyDetachRef(current2, nearestMountedAncestor) {
|
|
@@ -13961,8 +13961,8 @@ var SyntrologieSDK = (() => {
|
|
|
13961
13961
|
recordEffectDuration(current2);
|
|
13962
13962
|
}
|
|
13963
13963
|
else runWithFiberInDEV(current2, refCleanup);
|
|
13964
|
-
} catch (
|
|
13965
|
-
captureCommitPhaseError(current2, nearestMountedAncestor,
|
|
13964
|
+
} catch (error2) {
|
|
13965
|
+
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
|
13966
13966
|
} finally {
|
|
13967
13967
|
current2.refCleanup = null, current2 = current2.alternate, null != current2 && (current2.refCleanup = null);
|
|
13968
13968
|
}
|
|
@@ -14019,8 +14019,8 @@ var SyntrologieSDK = (() => {
|
|
|
14019
14019
|
props,
|
|
14020
14020
|
finishedWork
|
|
14021
14021
|
);
|
|
14022
|
-
} catch (
|
|
14023
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14022
|
+
} catch (error2) {
|
|
14023
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14024
14024
|
}
|
|
14025
14025
|
}
|
|
14026
14026
|
function commitHostUpdate(finishedWork, newProps, oldProps) {
|
|
@@ -14034,8 +14034,8 @@ var SyntrologieSDK = (() => {
|
|
|
14034
14034
|
newProps,
|
|
14035
14035
|
finishedWork
|
|
14036
14036
|
);
|
|
14037
|
-
} catch (
|
|
14038
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14037
|
+
} catch (error2) {
|
|
14038
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14039
14039
|
}
|
|
14040
14040
|
}
|
|
14041
14041
|
function isHostParent(fiber) {
|
|
@@ -14132,8 +14132,8 @@ var SyntrologieSDK = (() => {
|
|
|
14132
14132
|
singleton,
|
|
14133
14133
|
finishedWork
|
|
14134
14134
|
);
|
|
14135
|
-
} catch (
|
|
14136
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14135
|
+
} catch (error2) {
|
|
14136
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14137
14137
|
}
|
|
14138
14138
|
}
|
|
14139
14139
|
function isHydratingParent(current2, finishedWork) {
|
|
@@ -14336,8 +14336,8 @@ var SyntrologieSDK = (() => {
|
|
|
14336
14336
|
flags,
|
|
14337
14337
|
prevProps
|
|
14338
14338
|
);
|
|
14339
|
-
} catch (
|
|
14340
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14339
|
+
} catch (error2) {
|
|
14340
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14341
14341
|
}
|
|
14342
14342
|
}
|
|
14343
14343
|
finishedRoot.effectDuration += popNestedEffectDurations(current2);
|
|
@@ -14362,11 +14362,11 @@ var SyntrologieSDK = (() => {
|
|
|
14362
14362
|
current2,
|
|
14363
14363
|
finishedWork
|
|
14364
14364
|
);
|
|
14365
|
-
} catch (
|
|
14365
|
+
} catch (error2) {
|
|
14366
14366
|
captureCommitPhaseError(
|
|
14367
14367
|
finishedWork,
|
|
14368
14368
|
finishedWork.return,
|
|
14369
|
-
|
|
14369
|
+
error2
|
|
14370
14370
|
);
|
|
14371
14371
|
}
|
|
14372
14372
|
}
|
|
@@ -14388,8 +14388,8 @@ var SyntrologieSDK = (() => {
|
|
|
14388
14388
|
commitStartTime,
|
|
14389
14389
|
finishedRoot.effectDuration
|
|
14390
14390
|
);
|
|
14391
|
-
} catch (
|
|
14392
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14391
|
+
} catch (error2) {
|
|
14392
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14393
14393
|
}
|
|
14394
14394
|
} else recursivelyTraverseLayoutEffects(finishedRoot, finishedWork);
|
|
14395
14395
|
break;
|
|
@@ -14535,11 +14535,11 @@ var SyntrologieSDK = (() => {
|
|
|
14535
14535
|
hostParent,
|
|
14536
14536
|
deletedFiber.stateNode
|
|
14537
14537
|
);
|
|
14538
|
-
} catch (
|
|
14538
|
+
} catch (error2) {
|
|
14539
14539
|
captureCommitPhaseError(
|
|
14540
14540
|
deletedFiber,
|
|
14541
14541
|
nearestMountedAncestor,
|
|
14542
|
-
|
|
14542
|
+
error2
|
|
14543
14543
|
);
|
|
14544
14544
|
}
|
|
14545
14545
|
else
|
|
@@ -14550,11 +14550,11 @@ var SyntrologieSDK = (() => {
|
|
|
14550
14550
|
hostParent,
|
|
14551
14551
|
deletedFiber.stateNode
|
|
14552
14552
|
);
|
|
14553
|
-
} catch (
|
|
14553
|
+
} catch (error2) {
|
|
14554
14554
|
captureCommitPhaseError(
|
|
14555
14555
|
deletedFiber,
|
|
14556
14556
|
nearestMountedAncestor,
|
|
14557
|
-
|
|
14557
|
+
error2
|
|
14558
14558
|
);
|
|
14559
14559
|
}
|
|
14560
14560
|
break;
|
|
@@ -14653,8 +14653,8 @@ var SyntrologieSDK = (() => {
|
|
|
14653
14653
|
commitHydratedActivityInstance,
|
|
14654
14654
|
finishedRoot
|
|
14655
14655
|
);
|
|
14656
|
-
} catch (
|
|
14657
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14656
|
+
} catch (error2) {
|
|
14657
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14658
14658
|
}
|
|
14659
14659
|
}
|
|
14660
14660
|
}
|
|
@@ -14666,8 +14666,8 @@ var SyntrologieSDK = (() => {
|
|
|
14666
14666
|
commitHydratedSuspenseInstance,
|
|
14667
14667
|
finishedRoot
|
|
14668
14668
|
);
|
|
14669
|
-
} catch (
|
|
14670
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14669
|
+
} catch (error2) {
|
|
14670
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14671
14671
|
}
|
|
14672
14672
|
}
|
|
14673
14673
|
function getRetryCache(finishedWork) {
|
|
@@ -14912,8 +14912,8 @@ var SyntrologieSDK = (() => {
|
|
|
14912
14912
|
resetTextContent,
|
|
14913
14913
|
existingHiddenCallbacks
|
|
14914
14914
|
);
|
|
14915
|
-
} catch (
|
|
14916
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14915
|
+
} catch (error2) {
|
|
14916
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14917
14917
|
}
|
|
14918
14918
|
}
|
|
14919
14919
|
flags & 4 && null != finishedWork.stateNode && (existingHiddenCallbacks = finishedWork.memoizedProps, commitHostUpdate(
|
|
@@ -14944,8 +14944,8 @@ var SyntrologieSDK = (() => {
|
|
|
14944
14944
|
current2,
|
|
14945
14945
|
flags
|
|
14946
14946
|
);
|
|
14947
|
-
} catch (
|
|
14948
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14947
|
+
} catch (error2) {
|
|
14948
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14949
14949
|
}
|
|
14950
14950
|
}
|
|
14951
14951
|
break;
|
|
@@ -14964,8 +14964,8 @@ var SyntrologieSDK = (() => {
|
|
|
14964
14964
|
commitHydratedContainer,
|
|
14965
14965
|
root2.containerInfo
|
|
14966
14966
|
);
|
|
14967
|
-
} catch (
|
|
14968
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
14967
|
+
} catch (error2) {
|
|
14968
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
14969
14969
|
}
|
|
14970
14970
|
needsFormReset && (needsFormReset = false, recursivelyResetForms(finishedWork));
|
|
14971
14971
|
root2.effectDuration += popNestedEffectDurations(
|
|
@@ -15033,8 +15033,8 @@ var SyntrologieSDK = (() => {
|
|
|
15033
15033
|
wasHidden.stateNode,
|
|
15034
15034
|
wasHidden.memoizedProps
|
|
15035
15035
|
);
|
|
15036
|
-
} catch (
|
|
15037
|
-
captureCommitPhaseError(wasHidden, wasHidden.return,
|
|
15036
|
+
} catch (error2) {
|
|
15037
|
+
captureCommitPhaseError(wasHidden, wasHidden.return, error2);
|
|
15038
15038
|
}
|
|
15039
15039
|
}
|
|
15040
15040
|
} else if (6 === root2.tag) {
|
|
@@ -15051,8 +15051,8 @@ var SyntrologieSDK = (() => {
|
|
|
15051
15051
|
maybeNodes,
|
|
15052
15052
|
wasHidden.memoizedProps
|
|
15053
15053
|
);
|
|
15054
|
-
} catch (
|
|
15055
|
-
captureCommitPhaseError(wasHidden, wasHidden.return,
|
|
15054
|
+
} catch (error2) {
|
|
15055
|
+
captureCommitPhaseError(wasHidden, wasHidden.return, error2);
|
|
15056
15056
|
}
|
|
15057
15057
|
}
|
|
15058
15058
|
} else if (18 === root2.tag) {
|
|
@@ -15068,8 +15068,8 @@ var SyntrologieSDK = (() => {
|
|
|
15068
15068
|
unhideDehydratedBoundary,
|
|
15069
15069
|
wasHidden.stateNode
|
|
15070
15070
|
);
|
|
15071
|
-
} catch (
|
|
15072
|
-
captureCommitPhaseError(wasHidden, wasHidden.return,
|
|
15071
|
+
} catch (error2) {
|
|
15072
|
+
captureCommitPhaseError(wasHidden, wasHidden.return, error2);
|
|
15073
15073
|
}
|
|
15074
15074
|
}
|
|
15075
15075
|
} else if ((22 !== root2.tag && 23 !== root2.tag || null === root2.memoizedState || root2 === finishedWork) && null !== root2.child) {
|
|
@@ -15127,8 +15127,8 @@ var SyntrologieSDK = (() => {
|
|
|
15127
15127
|
if (flags & 2) {
|
|
15128
15128
|
try {
|
|
15129
15129
|
runWithFiberInDEV(finishedWork, commitPlacement, finishedWork);
|
|
15130
|
-
} catch (
|
|
15131
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
15130
|
+
} catch (error2) {
|
|
15131
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
15132
15132
|
}
|
|
15133
15133
|
finishedWork.flags &= -3;
|
|
15134
15134
|
}
|
|
@@ -15244,8 +15244,8 @@ var SyntrologieSDK = (() => {
|
|
|
15244
15244
|
current2,
|
|
15245
15245
|
finishedRoot
|
|
15246
15246
|
);
|
|
15247
|
-
} catch (
|
|
15248
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
15247
|
+
} catch (error2) {
|
|
15248
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
15249
15249
|
}
|
|
15250
15250
|
}
|
|
15251
15251
|
includeWorkInProgressEffects && flags & 64 && commitClassCallbacks(finishedWork);
|
|
@@ -15282,8 +15282,8 @@ var SyntrologieSDK = (() => {
|
|
|
15282
15282
|
commitStartTime,
|
|
15283
15283
|
includeWorkInProgressEffects.effectDuration
|
|
15284
15284
|
);
|
|
15285
|
-
} catch (
|
|
15286
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
15285
|
+
} catch (error2) {
|
|
15286
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
15287
15287
|
}
|
|
15288
15288
|
} else
|
|
15289
15289
|
recursivelyTraverseReappearLayoutEffects(
|
|
@@ -15454,8 +15454,8 @@ var SyntrologieSDK = (() => {
|
|
|
15454
15454
|
commitStartTime,
|
|
15455
15455
|
finishedRoot.passiveEffectDuration
|
|
15456
15456
|
);
|
|
15457
|
-
} catch (
|
|
15458
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
15457
|
+
} catch (error2) {
|
|
15458
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
15459
15459
|
}
|
|
15460
15460
|
} else
|
|
15461
15461
|
recursivelyTraversePassiveMountEffects(
|
|
@@ -16396,7 +16396,7 @@ var SyntrologieSDK = (() => {
|
|
|
16396
16396
|
check = check.value;
|
|
16397
16397
|
try {
|
|
16398
16398
|
if (!objectIs(getSnapshot(), check)) return false;
|
|
16399
|
-
} catch (
|
|
16399
|
+
} catch (error2) {
|
|
16400
16400
|
return false;
|
|
16401
16401
|
}
|
|
16402
16402
|
}
|
|
@@ -16991,8 +16991,8 @@ var SyntrologieSDK = (() => {
|
|
|
16991
16991
|
workInProgress = null;
|
|
16992
16992
|
return;
|
|
16993
16993
|
}
|
|
16994
|
-
} catch (
|
|
16995
|
-
if (null !== returnFiber) throw workInProgress = returnFiber,
|
|
16994
|
+
} catch (error2) {
|
|
16995
|
+
if (null !== returnFiber) throw workInProgress = returnFiber, error2;
|
|
16996
16996
|
workInProgressRootExitStatus = RootFatalErrored;
|
|
16997
16997
|
logUncaughtError(
|
|
16998
16998
|
root2,
|
|
@@ -17561,36 +17561,36 @@ var SyntrologieSDK = (() => {
|
|
|
17561
17561
|
ReactDOMSharedInternals.p = previousPriority, ReactSharedInternals.T = renderPriority, releaseRootPooledCache(root2, remainingLanes);
|
|
17562
17562
|
}
|
|
17563
17563
|
}
|
|
17564
|
-
function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber,
|
|
17565
|
-
sourceFiber = createCapturedValueAtFiber(
|
|
17564
|
+
function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error2) {
|
|
17565
|
+
sourceFiber = createCapturedValueAtFiber(error2, sourceFiber);
|
|
17566
17566
|
recordEffectError(sourceFiber);
|
|
17567
17567
|
sourceFiber = createRootErrorUpdate(rootFiber.stateNode, sourceFiber, 2);
|
|
17568
17568
|
rootFiber = enqueueUpdate(rootFiber, sourceFiber, 2);
|
|
17569
17569
|
null !== rootFiber && (markRootUpdated$1(rootFiber, 2), ensureRootIsScheduled(rootFiber));
|
|
17570
17570
|
}
|
|
17571
|
-
function captureCommitPhaseError(sourceFiber, nearestMountedAncestor,
|
|
17571
|
+
function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error2) {
|
|
17572
17572
|
isRunningInsertionEffect = false;
|
|
17573
17573
|
if (3 === sourceFiber.tag)
|
|
17574
|
-
captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber,
|
|
17574
|
+
captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error2);
|
|
17575
17575
|
else {
|
|
17576
17576
|
for (; null !== nearestMountedAncestor; ) {
|
|
17577
17577
|
if (3 === nearestMountedAncestor.tag) {
|
|
17578
17578
|
captureCommitPhaseErrorOnRoot(
|
|
17579
17579
|
nearestMountedAncestor,
|
|
17580
17580
|
sourceFiber,
|
|
17581
|
-
|
|
17581
|
+
error2
|
|
17582
17582
|
);
|
|
17583
17583
|
return;
|
|
17584
17584
|
}
|
|
17585
17585
|
if (1 === nearestMountedAncestor.tag) {
|
|
17586
17586
|
var instance = nearestMountedAncestor.stateNode;
|
|
17587
17587
|
if ("function" === typeof nearestMountedAncestor.type.getDerivedStateFromError || "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) {
|
|
17588
|
-
sourceFiber = createCapturedValueAtFiber(
|
|
17588
|
+
sourceFiber = createCapturedValueAtFiber(error2, sourceFiber);
|
|
17589
17589
|
recordEffectError(sourceFiber);
|
|
17590
|
-
|
|
17591
|
-
instance = enqueueUpdate(nearestMountedAncestor,
|
|
17590
|
+
error2 = createClassErrorUpdate(2);
|
|
17591
|
+
instance = enqueueUpdate(nearestMountedAncestor, error2, 2);
|
|
17592
17592
|
null !== instance && (initializeClassErrorUpdate(
|
|
17593
|
-
|
|
17593
|
+
error2,
|
|
17594
17594
|
instance,
|
|
17595
17595
|
nearestMountedAncestor,
|
|
17596
17596
|
sourceFiber
|
|
@@ -17602,7 +17602,7 @@ var SyntrologieSDK = (() => {
|
|
|
17602
17602
|
}
|
|
17603
17603
|
console.error(
|
|
17604
17604
|
"Internal React error: Attempted to capture a commit phase error inside a detached tree. This indicates a bug in React. Potential causes include deleting the same fiber more than once, committing an already-finished tree, or an inconsistent return pointer.\n\nError message:\n\n%s",
|
|
17605
|
-
|
|
17605
|
+
error2
|
|
17606
17606
|
);
|
|
17607
17607
|
}
|
|
17608
17608
|
}
|
|
@@ -17977,8 +17977,8 @@ var SyntrologieSDK = (() => {
|
|
|
17977
17977
|
event.currentTarget = currentTarget;
|
|
17978
17978
|
try {
|
|
17979
17979
|
listener(event);
|
|
17980
|
-
} catch (
|
|
17981
|
-
reportGlobalError(
|
|
17980
|
+
} catch (error2) {
|
|
17981
|
+
reportGlobalError(error2);
|
|
17982
17982
|
}
|
|
17983
17983
|
event.currentTarget = null;
|
|
17984
17984
|
}
|
|
@@ -20222,9 +20222,9 @@ var SyntrologieSDK = (() => {
|
|
|
20222
20222
|
var event = window.event;
|
|
20223
20223
|
return event && event !== schedulerEvent ? event.timeStamp : -1.1;
|
|
20224
20224
|
}
|
|
20225
|
-
function handleErrorInNextTick(
|
|
20225
|
+
function handleErrorInNextTick(error2) {
|
|
20226
20226
|
setTimeout(function() {
|
|
20227
|
-
throw
|
|
20227
|
+
throw error2;
|
|
20228
20228
|
});
|
|
20229
20229
|
}
|
|
20230
20230
|
function commitMount(domElement, type, newProps) {
|
|
@@ -22647,20 +22647,20 @@ var SyntrologieSDK = (() => {
|
|
|
22647
22647
|
return localDate.now();
|
|
22648
22648
|
};
|
|
22649
22649
|
}
|
|
22650
|
-
var reportGlobalError = "function" === typeof reportError ? reportError : function(
|
|
22650
|
+
var reportGlobalError = "function" === typeof reportError ? reportError : function(error2) {
|
|
22651
22651
|
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
22652
22652
|
var event = new window.ErrorEvent("error", {
|
|
22653
22653
|
bubbles: true,
|
|
22654
22654
|
cancelable: true,
|
|
22655
|
-
message: "object" === typeof
|
|
22656
|
-
error
|
|
22655
|
+
message: "object" === typeof error2 && null !== error2 && "string" === typeof error2.message ? String(error2.message) : String(error2),
|
|
22656
|
+
error: error2
|
|
22657
22657
|
});
|
|
22658
22658
|
if (!window.dispatchEvent(event)) return;
|
|
22659
22659
|
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
22660
|
-
process.emit("uncaughtException",
|
|
22660
|
+
process.emit("uncaughtException", error2);
|
|
22661
22661
|
return;
|
|
22662
22662
|
}
|
|
22663
|
-
console.error(
|
|
22663
|
+
console.error(error2);
|
|
22664
22664
|
}, OMITTED_PROP_ERROR = "This object has been omitted by React in the console log to avoid sending too much data from the server. Try logging smaller or more specific objects.", EMPTY_ARRAY = 0, COMPLEX_ARRAY = 1, PRIMITIVE_ARRAY = 2, ENTRIES_ARRAY = 3, REMOVED = "\u2013\xA0", ADDED = "+\xA0", UNCHANGED = "\u2007\xA0", supportsUserTiming = "undefined" !== typeof console && "function" === typeof console.timeStamp && "undefined" !== typeof performance && "function" === typeof performance.measure, COMPONENTS_TRACK = "Components \u269B", LANES_TRACK_GROUP = "Scheduler \u269B", currentTrack = "Blocking", alreadyWarnedForDeepEquality = false, reusableComponentDevToolDetails = {
|
|
22665
22665
|
color: "primary",
|
|
22666
22666
|
properties: null,
|
|
@@ -22882,8 +22882,8 @@ var SyntrologieSDK = (() => {
|
|
|
22882
22882
|
react_stack_bottom_frame: function(finishedWork, instance) {
|
|
22883
22883
|
try {
|
|
22884
22884
|
instance.componentDidMount();
|
|
22885
|
-
} catch (
|
|
22886
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
22885
|
+
} catch (error2) {
|
|
22886
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
22887
22887
|
}
|
|
22888
22888
|
}
|
|
22889
22889
|
}, callComponentDidMountInDEV = callComponentDidMount.react_stack_bottom_frame.bind(
|
|
@@ -22892,8 +22892,8 @@ var SyntrologieSDK = (() => {
|
|
|
22892
22892
|
react_stack_bottom_frame: function(finishedWork, instance, prevProps, prevState, snapshot) {
|
|
22893
22893
|
try {
|
|
22894
22894
|
instance.componentDidUpdate(prevProps, prevState, snapshot);
|
|
22895
|
-
} catch (
|
|
22896
|
-
captureCommitPhaseError(finishedWork, finishedWork.return,
|
|
22895
|
+
} catch (error2) {
|
|
22896
|
+
captureCommitPhaseError(finishedWork, finishedWork.return, error2);
|
|
22897
22897
|
}
|
|
22898
22898
|
}
|
|
22899
22899
|
}, callComponentDidUpdateInDEV = callComponentDidUpdate.react_stack_bottom_frame.bind(
|
|
@@ -22911,8 +22911,8 @@ var SyntrologieSDK = (() => {
|
|
|
22911
22911
|
react_stack_bottom_frame: function(current2, nearestMountedAncestor, instance) {
|
|
22912
22912
|
try {
|
|
22913
22913
|
instance.componentWillUnmount();
|
|
22914
|
-
} catch (
|
|
22915
|
-
captureCommitPhaseError(current2, nearestMountedAncestor,
|
|
22914
|
+
} catch (error2) {
|
|
22915
|
+
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
|
22916
22916
|
}
|
|
22917
22917
|
}
|
|
22918
22918
|
}, callComponentWillUnmountInDEV = callComponentWillUnmount.react_stack_bottom_frame.bind(
|
|
@@ -22928,8 +22928,8 @@ var SyntrologieSDK = (() => {
|
|
|
22928
22928
|
react_stack_bottom_frame: function(current2, nearestMountedAncestor, destroy) {
|
|
22929
22929
|
try {
|
|
22930
22930
|
destroy();
|
|
22931
|
-
} catch (
|
|
22932
|
-
captureCommitPhaseError(current2, nearestMountedAncestor,
|
|
22931
|
+
} catch (error2) {
|
|
22932
|
+
captureCommitPhaseError(current2, nearestMountedAncestor, error2);
|
|
22933
22933
|
}
|
|
22934
22934
|
}
|
|
22935
22935
|
}, callDestroyInDEV = callDestroy.react_stack_bottom_frame.bind(callDestroy), callLazyInit = {
|
|
@@ -24551,33 +24551,94 @@ var SyntrologieSDK = (() => {
|
|
|
24551
24551
|
// src/index.ts
|
|
24552
24552
|
var index_exports = {};
|
|
24553
24553
|
__export(index_exports, {
|
|
24554
|
+
ActivationConfigZ: () => ActivationConfigZ,
|
|
24555
|
+
AnchorStateZ: () => AnchorStateZ,
|
|
24556
|
+
AnchorVisibleConditionZ: () => AnchorVisibleConditionZ,
|
|
24557
|
+
AugmentationZ: () => AugmentationZ,
|
|
24558
|
+
BoundingBoxZ: () => BoundingBoxZ,
|
|
24559
|
+
CanvasEvents: () => CanvasEvents,
|
|
24554
24560
|
CanvasRecipeZ: () => CanvasRecipeZ,
|
|
24561
|
+
ConditionZ: () => ConditionZ,
|
|
24562
|
+
ContextManager: () => ContextManager,
|
|
24563
|
+
CooldownActiveConditionZ: () => CooldownActiveConditionZ,
|
|
24564
|
+
DecisionStrategyZ: () => DecisionStrategyZ,
|
|
24565
|
+
DismissedConditionZ: () => DismissedConditionZ,
|
|
24566
|
+
EVENT_SCHEMA_VERSION: () => EVENT_SCHEMA_VERSION,
|
|
24567
|
+
EventBus: () => EventBus,
|
|
24568
|
+
EventFilterZ: () => EventFilterZ,
|
|
24569
|
+
EventOccurredConditionZ: () => EventOccurredConditionZ,
|
|
24570
|
+
EventSourceZ: () => EventSourceZ,
|
|
24571
|
+
ExternalStrategyZ: () => ExternalStrategyZ,
|
|
24572
|
+
FrequencyEntryZ: () => FrequencyEntryZ,
|
|
24573
|
+
FrequencyLimitConditionZ: () => FrequencyLimitConditionZ,
|
|
24555
24574
|
HighlightStepZ: () => HighlightStepZ,
|
|
24575
|
+
ModelStrategyZ: () => ModelStrategyZ,
|
|
24576
|
+
NormalizedEventZ: () => NormalizedEventZ,
|
|
24577
|
+
PageContextZ: () => PageContextZ,
|
|
24578
|
+
PageHistoryEntryZ: () => PageHistoryEntryZ,
|
|
24579
|
+
PageUrlConditionZ: () => PageUrlConditionZ,
|
|
24580
|
+
RUNTIME_VERSION: () => RUNTIME_VERSION,
|
|
24581
|
+
RouteConditionZ: () => RouteConditionZ,
|
|
24582
|
+
RouteFilterZ: () => RouteFilterZ,
|
|
24583
|
+
RuleStrategyZ: () => RuleStrategyZ,
|
|
24584
|
+
RuleZ: () => RuleZ,
|
|
24585
|
+
RuntimeContextZ: () => RuntimeContextZ,
|
|
24586
|
+
ScoreStrategyZ: () => ScoreStrategyZ,
|
|
24556
24587
|
SelectorZ: () => SelectorZ,
|
|
24588
|
+
SessionContextZ: () => SessionContextZ,
|
|
24589
|
+
SessionMetricConditionZ: () => SessionMetricConditionZ,
|
|
24557
24590
|
SessionMetricTracker: () => SessionMetricTracker,
|
|
24558
24591
|
ShadowCanvasOverlay: () => ShadowCanvasOverlay,
|
|
24559
24592
|
SmartCanvasApp: () => SmartCanvasApp,
|
|
24560
24593
|
SmartCanvasController: () => SmartCanvasController,
|
|
24561
24594
|
SmartCanvasElement: () => SmartCanvasElement,
|
|
24562
24595
|
SmartCanvasPortal: () => SmartCanvasPortal,
|
|
24596
|
+
StandardEvents: () => StandardEvents,
|
|
24597
|
+
StateEqualsConditionZ: () => StateEqualsConditionZ,
|
|
24598
|
+
StateStore: () => StateStore,
|
|
24599
|
+
StoredValueZ: () => StoredValueZ,
|
|
24563
24600
|
Syntro: () => Syntro,
|
|
24564
24601
|
TileCard: () => TileCard,
|
|
24565
24602
|
TileWheel: () => TileWheel,
|
|
24566
24603
|
TooltipStepZ: () => TooltipStepZ,
|
|
24604
|
+
ViewportConditionZ: () => ViewportConditionZ,
|
|
24605
|
+
ViewportContextZ: () => ViewportContextZ,
|
|
24567
24606
|
createCanvasConfigFetcher: () => createCanvasConfigFetcher,
|
|
24607
|
+
createContextManager: () => createContextManager,
|
|
24608
|
+
createDecisionEngine: () => createDecisionEngine,
|
|
24609
|
+
createEventBus: () => createEventBus,
|
|
24568
24610
|
createGrowthBookClient: () => createGrowthBookClient,
|
|
24569
24611
|
createOverlayRecipeFetcher: () => createOverlayRecipeFetcher,
|
|
24570
24612
|
createPostHogClient: () => createPostHogClient,
|
|
24613
|
+
createPostHogNormalizer: () => createPostHogNormalizer,
|
|
24571
24614
|
createSessionMetricTracker: () => createSessionMetricTracker,
|
|
24572
24615
|
createSmartCanvas: () => createSmartCanvas,
|
|
24573
24616
|
createSmartCanvasController: () => createSmartCanvasController,
|
|
24617
|
+
createSmartCanvasRuntime: () => createSmartCanvasRuntime,
|
|
24618
|
+
createStateStore: () => createStateStore,
|
|
24574
24619
|
decodeToken: () => decodeToken,
|
|
24575
24620
|
encodeToken: () => encodeToken,
|
|
24621
|
+
evaluate: () => evaluate2,
|
|
24622
|
+
evaluateCondition: () => evaluateCondition,
|
|
24623
|
+
evaluateRule: () => evaluateRule,
|
|
24624
|
+
evaluateRuleStrategy: () => evaluateRuleStrategy,
|
|
24625
|
+
evaluateScoreStrategy: () => evaluateScoreStrategy,
|
|
24626
|
+
evaluateSync: () => evaluateSync,
|
|
24576
24627
|
getAntiFlickerSnippet: () => getAntiFlickerSnippet,
|
|
24628
|
+
normalizePostHogEvent: () => normalizePostHogEvent,
|
|
24577
24629
|
registerSmartCanvasElement: () => registerSmartCanvasElement,
|
|
24578
24630
|
resolveConfigUri: () => resolveConfigUri,
|
|
24631
|
+
shouldNormalizeEvent: () => shouldNormalizeEvent,
|
|
24579
24632
|
useShadowCanvasConfig: () => useShadowCanvasConfig,
|
|
24580
|
-
|
|
24633
|
+
validateActivationConfig: () => validateActivationConfig,
|
|
24634
|
+
validateCondition: () => validateCondition,
|
|
24635
|
+
validateEventFilter: () => validateEventFilter,
|
|
24636
|
+
validateFrequencyEntry: () => validateFrequencyEntry,
|
|
24637
|
+
validateNormalizedEvent: () => validateNormalizedEvent,
|
|
24638
|
+
validateRecipe: () => validateRecipe,
|
|
24639
|
+
validateRuntimeContext: () => validateRuntimeContext,
|
|
24640
|
+
validateStoredValue: () => validateStoredValue,
|
|
24641
|
+
validateStrategy: () => validateStrategy
|
|
24581
24642
|
});
|
|
24582
24643
|
|
|
24583
24644
|
// node_modules/posthog-js/dist/module.js
|
|
@@ -29118,7 +29179,7 @@ var SyntrologieSDK = (() => {
|
|
|
29118
29179
|
this.client = Uo;
|
|
29119
29180
|
const enableFeatureFlags = options.enableFeatureFlags ?? true;
|
|
29120
29181
|
this.client.init(options.apiKey, {
|
|
29121
|
-
api_host: options.apiHost ?? "https://
|
|
29182
|
+
api_host: options.apiHost ?? "https://telemetry.syntrologie.com",
|
|
29122
29183
|
// Feature flags for segment membership (in_segment_* flags)
|
|
29123
29184
|
// When enabled, /decide is called to get segment flags
|
|
29124
29185
|
advanced_disable_feature_flags: !enableFeatureFlags,
|
|
@@ -32186,7 +32247,8 @@ var SyntrologieSDK = (() => {
|
|
|
32186
32247
|
function useShadowCanvasConfig({
|
|
32187
32248
|
fetcher,
|
|
32188
32249
|
pollIntervalMs = 3e4,
|
|
32189
|
-
experiments
|
|
32250
|
+
experiments,
|
|
32251
|
+
runtime
|
|
32190
32252
|
}) {
|
|
32191
32253
|
const [state, setState] = (0, import_react.useState)({
|
|
32192
32254
|
tiles: [],
|
|
@@ -32197,7 +32259,15 @@ var SyntrologieSDK = (() => {
|
|
|
32197
32259
|
setState((prev) => ({ ...prev, isLoading: true, error: void 0 }));
|
|
32198
32260
|
const response = await fetcher();
|
|
32199
32261
|
let tiles = response.tiles || [];
|
|
32200
|
-
if (
|
|
32262
|
+
if (runtime && response.routes) {
|
|
32263
|
+
runtime.setRoutes(response.routes);
|
|
32264
|
+
}
|
|
32265
|
+
if (runtime) {
|
|
32266
|
+
tiles = await runtime.filterTiles(tiles);
|
|
32267
|
+
if (experiments) {
|
|
32268
|
+
tiles = tiles.filter((tile) => experiments.shouldRenderRectangle(tile));
|
|
32269
|
+
}
|
|
32270
|
+
} else if (experiments) {
|
|
32201
32271
|
tiles = tiles.filter((tile) => experiments.shouldRenderRectangle(tile));
|
|
32202
32272
|
}
|
|
32203
32273
|
setState({
|
|
@@ -32220,7 +32290,7 @@ var SyntrologieSDK = (() => {
|
|
|
32220
32290
|
error: err instanceof Error ? err.message : "Unknown error"
|
|
32221
32291
|
}));
|
|
32222
32292
|
}
|
|
32223
|
-
}, [experiments, fetcher]);
|
|
32293
|
+
}, [experiments, fetcher, runtime]);
|
|
32224
32294
|
(0, import_react.useEffect)(() => {
|
|
32225
32295
|
load();
|
|
32226
32296
|
if (!pollIntervalMs) return;
|
|
@@ -33663,7 +33733,7 @@ var SyntrologieSDK = (() => {
|
|
|
33663
33733
|
footerSlot,
|
|
33664
33734
|
tiles,
|
|
33665
33735
|
isLoading,
|
|
33666
|
-
error,
|
|
33736
|
+
error: error2,
|
|
33667
33737
|
canvasTitle,
|
|
33668
33738
|
displayMode = "standard",
|
|
33669
33739
|
theme: themeOverride,
|
|
@@ -33748,9 +33818,9 @@ var SyntrologieSDK = (() => {
|
|
|
33748
33818
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: wrapperStyle, children: [
|
|
33749
33819
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: containerStyle, children: [
|
|
33750
33820
|
!isFocused && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("header", { style: { color: "white", padding: "1.5rem 1.5rem 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: { margin: 0, fontSize: "0.7rem", textTransform: "uppercase", letterSpacing: "0.5em", color: "rgba(255, 255, 255, 0.6)" }, children: canvasTitle ?? "Smart Canvas" }) }),
|
|
33751
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { flex: 1, overflowY: "auto", padding: isFocused ? "0" : "1.5rem" }, children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { color: "rgba(255, 255, 255, 0.85)", padding: isFocused ? "1rem" : "0" }, children: "Loading..." }) :
|
|
33821
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { flex: 1, overflowY: "auto", padding: isFocused ? "0" : "1.5rem" }, children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { color: "rgba(255, 255, 255, 0.85)", padding: isFocused ? "1rem" : "0" }, children: "Loading..." }) : error2 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { color: "#fecdd3", padding: isFocused ? "1rem" : "0" }, children: [
|
|
33752
33822
|
"Failed to load: ",
|
|
33753
|
-
|
|
33823
|
+
error2
|
|
33754
33824
|
] }) : isFocused ? (
|
|
33755
33825
|
/* Focused Mode: Render first tile full size */
|
|
33756
33826
|
tiles.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -34083,7 +34153,7 @@ var SyntrologieSDK = (() => {
|
|
|
34083
34153
|
}
|
|
34084
34154
|
const uri = resolveConfigUri({ configUri, experiments, featureKey });
|
|
34085
34155
|
if (!uri) {
|
|
34086
|
-
|
|
34156
|
+
return { tiles: [], overlays: [] };
|
|
34087
34157
|
}
|
|
34088
34158
|
if (!validateConfigUri(uri)) {
|
|
34089
34159
|
throw new Error(`SmartCanvas: config URI not allowed: ${uri}`);
|
|
@@ -34396,8 +34466,8 @@ var SyntrologieSDK = (() => {
|
|
|
34396
34466
|
return issue.message;
|
|
34397
34467
|
};
|
|
34398
34468
|
const fieldErrors = { _errors: [] };
|
|
34399
|
-
const processError = (
|
|
34400
|
-
for (const issue of
|
|
34469
|
+
const processError = (error2) => {
|
|
34470
|
+
for (const issue of error2.issues) {
|
|
34401
34471
|
if (issue.code === "invalid_union") {
|
|
34402
34472
|
issue.unionErrors.map(processError);
|
|
34403
34473
|
} else if (issue.code === "invalid_return_type") {
|
|
@@ -34460,8 +34530,8 @@ var SyntrologieSDK = (() => {
|
|
|
34460
34530
|
}
|
|
34461
34531
|
};
|
|
34462
34532
|
ZodError.create = (issues) => {
|
|
34463
|
-
const
|
|
34464
|
-
return
|
|
34533
|
+
const error2 = new ZodError(issues);
|
|
34534
|
+
return error2;
|
|
34465
34535
|
};
|
|
34466
34536
|
|
|
34467
34537
|
// node_modules/zod/v3/locales/en.js
|
|
@@ -34725,8 +34795,8 @@ var SyntrologieSDK = (() => {
|
|
|
34725
34795
|
get error() {
|
|
34726
34796
|
if (this._error)
|
|
34727
34797
|
return this._error;
|
|
34728
|
-
const
|
|
34729
|
-
this._error =
|
|
34798
|
+
const error2 = new ZodError(ctx.common.issues);
|
|
34799
|
+
this._error = error2;
|
|
34730
34800
|
return this._error;
|
|
34731
34801
|
}
|
|
34732
34802
|
};
|
|
@@ -37381,25 +37451,25 @@ var SyntrologieSDK = (() => {
|
|
|
37381
37451
|
});
|
|
37382
37452
|
return INVALID;
|
|
37383
37453
|
}
|
|
37384
|
-
function makeArgsIssue(args,
|
|
37454
|
+
function makeArgsIssue(args, error2) {
|
|
37385
37455
|
return makeIssue({
|
|
37386
37456
|
data: args,
|
|
37387
37457
|
path: ctx.path,
|
|
37388
37458
|
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x2) => !!x2),
|
|
37389
37459
|
issueData: {
|
|
37390
37460
|
code: ZodIssueCode.invalid_arguments,
|
|
37391
|
-
argumentsError:
|
|
37461
|
+
argumentsError: error2
|
|
37392
37462
|
}
|
|
37393
37463
|
});
|
|
37394
37464
|
}
|
|
37395
|
-
function makeReturnsIssue(returns,
|
|
37465
|
+
function makeReturnsIssue(returns, error2) {
|
|
37396
37466
|
return makeIssue({
|
|
37397
37467
|
data: returns,
|
|
37398
37468
|
path: ctx.path,
|
|
37399
37469
|
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x2) => !!x2),
|
|
37400
37470
|
issueData: {
|
|
37401
37471
|
code: ZodIssueCode.invalid_return_type,
|
|
37402
|
-
returnTypeError:
|
|
37472
|
+
returnTypeError: error2
|
|
37403
37473
|
}
|
|
37404
37474
|
});
|
|
37405
37475
|
}
|
|
@@ -37408,15 +37478,15 @@ var SyntrologieSDK = (() => {
|
|
|
37408
37478
|
if (this._def.returns instanceof ZodPromise) {
|
|
37409
37479
|
const me2 = this;
|
|
37410
37480
|
return OK(async function(...args) {
|
|
37411
|
-
const
|
|
37481
|
+
const error2 = new ZodError([]);
|
|
37412
37482
|
const parsedArgs = await me2._def.args.parseAsync(args, params).catch((e2) => {
|
|
37413
|
-
|
|
37414
|
-
throw
|
|
37483
|
+
error2.addIssue(makeArgsIssue(args, e2));
|
|
37484
|
+
throw error2;
|
|
37415
37485
|
});
|
|
37416
37486
|
const result = await Reflect.apply(fn2, this, parsedArgs);
|
|
37417
37487
|
const parsedReturns = await me2._def.returns._def.type.parseAsync(result, params).catch((e2) => {
|
|
37418
|
-
|
|
37419
|
-
throw
|
|
37488
|
+
error2.addIssue(makeReturnsIssue(result, e2));
|
|
37489
|
+
throw error2;
|
|
37420
37490
|
});
|
|
37421
37491
|
return parsedReturns;
|
|
37422
37492
|
});
|
|
@@ -38740,7 +38810,15 @@ var SyntrologieSDK = (() => {
|
|
|
38740
38810
|
root = document.createElement("div");
|
|
38741
38811
|
root.id = id;
|
|
38742
38812
|
root.setAttribute("data-smart-canvas-overlay", "true");
|
|
38743
|
-
document.body
|
|
38813
|
+
if (document.body) {
|
|
38814
|
+
document.body.appendChild(root);
|
|
38815
|
+
} else {
|
|
38816
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
38817
|
+
if (!root.parentNode) {
|
|
38818
|
+
document.body.appendChild(root);
|
|
38819
|
+
}
|
|
38820
|
+
}, { once: true });
|
|
38821
|
+
}
|
|
38744
38822
|
}
|
|
38745
38823
|
return root;
|
|
38746
38824
|
};
|
|
@@ -38927,8 +39005,8 @@ var SyntrologieSDK = (() => {
|
|
|
38927
39005
|
} else {
|
|
38928
39006
|
console.warn(`[SmartCanvas] Early patch failed: ${patch.id}`, result.reason);
|
|
38929
39007
|
}
|
|
38930
|
-
} catch (
|
|
38931
|
-
console.error(`[SmartCanvas] Error applying early patch: ${patch.id}`,
|
|
39008
|
+
} catch (error2) {
|
|
39009
|
+
console.error(`[SmartCanvas] Error applying early patch: ${patch.id}`, error2);
|
|
38932
39010
|
}
|
|
38933
39011
|
});
|
|
38934
39012
|
console.log(`[SmartCanvas] Applied ${appliedCount}/${patches.length} patches early`);
|
|
@@ -38946,6 +39024,51 @@ var SyntrologieSDK = (() => {
|
|
|
38946
39024
|
}));
|
|
38947
39025
|
}
|
|
38948
39026
|
|
|
39027
|
+
// src/logger.ts
|
|
39028
|
+
var debugEnabled = false;
|
|
39029
|
+
function checkUrlParam() {
|
|
39030
|
+
if (typeof window === "undefined") return false;
|
|
39031
|
+
try {
|
|
39032
|
+
const params = new URLSearchParams(window.location.search);
|
|
39033
|
+
return params.get("syntro_debug") === "true";
|
|
39034
|
+
} catch {
|
|
39035
|
+
return false;
|
|
39036
|
+
}
|
|
39037
|
+
}
|
|
39038
|
+
function initLogger(tokenDebug) {
|
|
39039
|
+
if (checkUrlParam()) {
|
|
39040
|
+
debugEnabled = true;
|
|
39041
|
+
return;
|
|
39042
|
+
}
|
|
39043
|
+
debugEnabled = tokenDebug ?? false;
|
|
39044
|
+
}
|
|
39045
|
+
function isDebugEnabled() {
|
|
39046
|
+
if (checkUrlParam()) return true;
|
|
39047
|
+
return debugEnabled;
|
|
39048
|
+
}
|
|
39049
|
+
function debug(prefix, message, data) {
|
|
39050
|
+
if (!isDebugEnabled()) return;
|
|
39051
|
+
if (data !== void 0) {
|
|
39052
|
+
console.log(`[${prefix}]`, message, data);
|
|
39053
|
+
} else {
|
|
39054
|
+
console.log(`[${prefix}]`, message);
|
|
39055
|
+
}
|
|
39056
|
+
}
|
|
39057
|
+
function warn(prefix, message, data) {
|
|
39058
|
+
if (data !== void 0) {
|
|
39059
|
+
console.warn(`[${prefix}]`, message, data);
|
|
39060
|
+
} else {
|
|
39061
|
+
console.warn(`[${prefix}]`, message);
|
|
39062
|
+
}
|
|
39063
|
+
}
|
|
39064
|
+
function error(prefix, message, data) {
|
|
39065
|
+
if (data !== void 0) {
|
|
39066
|
+
console.error(`[${prefix}]`, message, data);
|
|
39067
|
+
} else {
|
|
39068
|
+
console.error(`[${prefix}]`, message);
|
|
39069
|
+
}
|
|
39070
|
+
}
|
|
39071
|
+
|
|
38949
39072
|
// src/editorLoader.ts
|
|
38950
39073
|
var DEFAULT_EDITOR_URL = "https://cdn.syntrologie.com/editor-sdk/latest/editor-sdk.js";
|
|
38951
39074
|
var ALLOWED_EDITOR_HOSTS = [
|
|
@@ -38958,17 +39081,17 @@ var SyntrologieSDK = (() => {
|
|
|
38958
39081
|
".syntrologie.com"
|
|
38959
39082
|
];
|
|
38960
39083
|
function validateEditorUrl(url) {
|
|
38961
|
-
|
|
39084
|
+
debug("Syntro Runtime", "Validating editor URL:", url);
|
|
38962
39085
|
try {
|
|
38963
39086
|
const parsed = new URL(url);
|
|
38964
39087
|
const isLocalhost = /^(localhost|127\.0\.0\.1)$/.test(parsed.hostname);
|
|
38965
|
-
|
|
39088
|
+
debug("Syntro Runtime", "Parsed URL:", {
|
|
38966
39089
|
hostname: parsed.hostname,
|
|
38967
39090
|
protocol: parsed.protocol,
|
|
38968
39091
|
isLocalhost
|
|
38969
39092
|
});
|
|
38970
39093
|
if (parsed.protocol !== "https:" && !isLocalhost) {
|
|
38971
|
-
|
|
39094
|
+
warn("Syntro Runtime", "\u274C Editor URL must use HTTPS:", url);
|
|
38972
39095
|
return false;
|
|
38973
39096
|
}
|
|
38974
39097
|
const isAllowed = ALLOWED_EDITOR_HOSTS.some((host) => {
|
|
@@ -38977,34 +39100,34 @@ var SyntrologieSDK = (() => {
|
|
|
38977
39100
|
}
|
|
38978
39101
|
return parsed.hostname === host;
|
|
38979
39102
|
});
|
|
38980
|
-
|
|
39103
|
+
debug("Syntro Runtime", "Host allowlist check:", {
|
|
38981
39104
|
hostname: parsed.hostname,
|
|
38982
39105
|
allowedHosts: ALLOWED_EDITOR_HOSTS,
|
|
38983
39106
|
isAllowed
|
|
38984
39107
|
});
|
|
38985
39108
|
if (!isAllowed) {
|
|
38986
|
-
|
|
39109
|
+
warn("Syntro Runtime", "\u274C Editor URL host not in allowlist:", parsed.hostname);
|
|
38987
39110
|
return false;
|
|
38988
39111
|
}
|
|
38989
|
-
|
|
39112
|
+
debug("Syntro Runtime", "\u2713 Editor URL validated");
|
|
38990
39113
|
return true;
|
|
38991
39114
|
} catch (e2) {
|
|
38992
|
-
|
|
39115
|
+
warn("Syntro Runtime", "\u274C Invalid editor URL: " + url, e2);
|
|
38993
39116
|
return false;
|
|
38994
39117
|
}
|
|
38995
39118
|
}
|
|
38996
39119
|
var shouldLoadEditor = () => {
|
|
38997
|
-
|
|
39120
|
+
debug("Syntro Runtime", "====== EDITOR LOAD CHECK ======");
|
|
38998
39121
|
if (typeof window === "undefined") {
|
|
38999
|
-
|
|
39122
|
+
debug("Syntro Runtime", "Not in browser - skipping editor");
|
|
39000
39123
|
return false;
|
|
39001
39124
|
}
|
|
39002
39125
|
const params = new URLSearchParams(window.location.search);
|
|
39003
|
-
|
|
39004
|
-
|
|
39126
|
+
debug("Syntro Runtime", "URL:", window.location.href);
|
|
39127
|
+
debug("Syntro Runtime", "Search params:", window.location.search);
|
|
39005
39128
|
const hasEditorFlag = params.has("syntro_editor") || params.has("syntro-editor");
|
|
39006
39129
|
const hasEditorToken = params.has("editor_token");
|
|
39007
|
-
|
|
39130
|
+
debug("Syntro Runtime", "Editor flags:", {
|
|
39008
39131
|
hasEditorFlag,
|
|
39009
39132
|
hasEditorToken,
|
|
39010
39133
|
syntro_editor: params.get("syntro_editor"),
|
|
@@ -39012,38 +39135,65 @@ var SyntrologieSDK = (() => {
|
|
|
39012
39135
|
editor_token: hasEditorToken ? `${params.get("editor_token")?.slice(0, 10)}...` : "none"
|
|
39013
39136
|
});
|
|
39014
39137
|
if (hasEditorFlag && !hasEditorToken) {
|
|
39015
|
-
|
|
39016
|
-
|
|
39138
|
+
warn("Syntro Runtime", "\u274C Editor activation requires editor_token parameter");
|
|
39139
|
+
debug("Syntro Runtime", "================================");
|
|
39017
39140
|
return false;
|
|
39018
39141
|
}
|
|
39019
39142
|
const shouldLoad = hasEditorFlag && hasEditorToken;
|
|
39020
|
-
|
|
39021
|
-
|
|
39143
|
+
debug("Syntro Runtime", "Should load editor:", shouldLoad);
|
|
39144
|
+
debug("Syntro Runtime", "================================");
|
|
39022
39145
|
return shouldLoad;
|
|
39023
39146
|
};
|
|
39147
|
+
var isAuditMode = () => {
|
|
39148
|
+
debug("Syntro Runtime", "====== AUDIT MODE CHECK ======");
|
|
39149
|
+
if (typeof window === "undefined") {
|
|
39150
|
+
debug("Syntro Runtime", "Not in browser - skipping audit");
|
|
39151
|
+
return false;
|
|
39152
|
+
}
|
|
39153
|
+
const params = new URLSearchParams(window.location.search);
|
|
39154
|
+
const hasAuditFlag = params.has("syntro_audit");
|
|
39155
|
+
const auditSessionId = params.get("audit_session_id");
|
|
39156
|
+
debug("Syntro Runtime", "Audit flags:", {
|
|
39157
|
+
hasAuditFlag,
|
|
39158
|
+
auditSessionId: auditSessionId ? `${auditSessionId.slice(0, 8)}...` : "none"
|
|
39159
|
+
});
|
|
39160
|
+
if (!hasAuditFlag) {
|
|
39161
|
+
debug("Syntro Runtime", "No syntro_audit param - not in audit mode");
|
|
39162
|
+
debug("Syntro Runtime", "================================");
|
|
39163
|
+
return false;
|
|
39164
|
+
}
|
|
39165
|
+
debug("Syntro Runtime", "\u2713 Audit mode active");
|
|
39166
|
+
debug("Syntro Runtime", "================================");
|
|
39167
|
+
return true;
|
|
39168
|
+
};
|
|
39169
|
+
var getActiveSdkMode = () => {
|
|
39170
|
+
if (shouldLoadEditor()) return "editor";
|
|
39171
|
+
if (isAuditMode()) return "audit";
|
|
39172
|
+
return null;
|
|
39173
|
+
};
|
|
39024
39174
|
var loadEditorSdk = async (editorUrlOrOptions) => {
|
|
39025
|
-
|
|
39175
|
+
debug("Syntro Runtime", "====== LOAD EDITOR SDK ======");
|
|
39026
39176
|
if (typeof window === "undefined") {
|
|
39027
|
-
|
|
39177
|
+
debug("Syntro Runtime", "Not in browser - skipping editor SDK load");
|
|
39028
39178
|
return;
|
|
39029
39179
|
}
|
|
39030
39180
|
if (window.SyntroEditor) {
|
|
39031
|
-
|
|
39181
|
+
debug("Syntro Runtime", "Editor SDK already loaded (window.SyntroEditor exists)");
|
|
39032
39182
|
return;
|
|
39033
39183
|
}
|
|
39034
39184
|
const options = typeof editorUrlOrOptions === "string" ? { editorUrl: editorUrlOrOptions } : editorUrlOrOptions ?? {};
|
|
39035
39185
|
const editorUrl = options.editorUrl ?? DEFAULT_EDITOR_URL;
|
|
39036
|
-
|
|
39037
|
-
|
|
39186
|
+
debug("Syntro Runtime", "Editor URL:", editorUrl);
|
|
39187
|
+
debug("Syntro Runtime", "Options:", {
|
|
39038
39188
|
hasIntegrity: !!options.integrity,
|
|
39039
39189
|
isDefault: editorUrl === DEFAULT_EDITOR_URL
|
|
39040
39190
|
});
|
|
39041
39191
|
if (!validateEditorUrl(editorUrl)) {
|
|
39042
39192
|
console.error("[Syntro Runtime] \u274C BLOCKED: Editor from untrusted URL:", editorUrl);
|
|
39043
|
-
|
|
39193
|
+
debug("Syntro Runtime", "================================");
|
|
39044
39194
|
return;
|
|
39045
39195
|
}
|
|
39046
|
-
|
|
39196
|
+
debug("Syntro Runtime", "\u2713 URL validated, injecting script tag...");
|
|
39047
39197
|
return new Promise((resolve, reject) => {
|
|
39048
39198
|
const script = document.createElement("script");
|
|
39049
39199
|
script.src = editorUrl;
|
|
@@ -39051,23 +39201,23 @@ var SyntrologieSDK = (() => {
|
|
|
39051
39201
|
if (options.integrity) {
|
|
39052
39202
|
script.integrity = options.integrity;
|
|
39053
39203
|
script.crossOrigin = "anonymous";
|
|
39054
|
-
|
|
39204
|
+
debug("Syntro Runtime", "SRI integrity check enabled");
|
|
39055
39205
|
}
|
|
39056
39206
|
script.onload = () => {
|
|
39057
|
-
|
|
39058
|
-
|
|
39059
|
-
|
|
39207
|
+
debug("Syntro Runtime", "\u2713 Editor SDK script loaded successfully");
|
|
39208
|
+
debug("Syntro Runtime", "window.SyntroEditor:", !!window.SyntroEditor);
|
|
39209
|
+
debug("Syntro Runtime", "================================");
|
|
39060
39210
|
resolve();
|
|
39061
39211
|
};
|
|
39062
39212
|
script.onerror = (err) => {
|
|
39063
39213
|
console.error("[Syntro Runtime] \u274C Failed to load Editor SDK:", err);
|
|
39064
39214
|
console.error("[Syntro Runtime] URL attempted:", editorUrl);
|
|
39065
39215
|
console.error("[Syntro Runtime] Check: Is the URL accessible? CORS? Network?");
|
|
39066
|
-
|
|
39216
|
+
debug("Syntro Runtime", "================================");
|
|
39067
39217
|
reject(err);
|
|
39068
39218
|
};
|
|
39069
39219
|
document.head.appendChild(script);
|
|
39070
|
-
|
|
39220
|
+
debug("Syntro Runtime", "Script tag appended to <head>");
|
|
39071
39221
|
});
|
|
39072
39222
|
};
|
|
39073
39223
|
|
|
@@ -39100,14 +39250,16 @@ var SyntrologieSDK = (() => {
|
|
|
39100
39250
|
}
|
|
39101
39251
|
});
|
|
39102
39252
|
}
|
|
39103
|
-
} catch (
|
|
39104
|
-
console.error("[SmartCanvas] Error applying early patches:",
|
|
39253
|
+
} catch (error2) {
|
|
39254
|
+
console.error("[SmartCanvas] Error applying early patches:", error2);
|
|
39105
39255
|
}
|
|
39106
39256
|
}
|
|
39107
39257
|
if (removeAntiFlicker) {
|
|
39108
39258
|
removeAntiFlicker();
|
|
39109
39259
|
}
|
|
39110
|
-
|
|
39260
|
+
const sdkMode = getActiveSdkMode();
|
|
39261
|
+
if (sdkMode) {
|
|
39262
|
+
console.log(`[SmartCanvas] Loading editor SDK for ${sdkMode} mode`);
|
|
39111
39263
|
loadEditorSdk(config.editorUrl).catch(console.error);
|
|
39112
39264
|
}
|
|
39113
39265
|
registerSmartCanvasElement();
|
|
@@ -39117,8 +39269,17 @@ var SyntrologieSDK = (() => {
|
|
|
39117
39269
|
host.style.setProperty(key, value);
|
|
39118
39270
|
}
|
|
39119
39271
|
}
|
|
39120
|
-
const
|
|
39121
|
-
|
|
39272
|
+
const appendToTarget = () => {
|
|
39273
|
+
const target = config.target ?? document.body;
|
|
39274
|
+
if (target) {
|
|
39275
|
+
target.appendChild(host);
|
|
39276
|
+
}
|
|
39277
|
+
};
|
|
39278
|
+
if (document.body) {
|
|
39279
|
+
appendToTarget();
|
|
39280
|
+
} else {
|
|
39281
|
+
document.addEventListener("DOMContentLoaded", appendToTarget, { once: true });
|
|
39282
|
+
}
|
|
39122
39283
|
const experiments = config.integrations?.experiments;
|
|
39123
39284
|
const telemetry = config.integrations?.telemetry;
|
|
39124
39285
|
const fetcher = config.fetcher ?? createCanvasConfigFetcher({
|
|
@@ -39164,8 +39325,8 @@ var SyntrologieSDK = (() => {
|
|
|
39164
39325
|
const freshConfig = await currentFetcher();
|
|
39165
39326
|
currentConfig = freshConfig;
|
|
39166
39327
|
return freshConfig;
|
|
39167
|
-
} catch (
|
|
39168
|
-
console.error("[SmartCanvas] Error fetching config:",
|
|
39328
|
+
} catch (error2) {
|
|
39329
|
+
console.error("[SmartCanvas] Error fetching config:", error2);
|
|
39169
39330
|
}
|
|
39170
39331
|
}
|
|
39171
39332
|
return currentConfig;
|
|
@@ -39205,9 +39366,8 @@ var SyntrologieSDK = (() => {
|
|
|
39205
39366
|
}
|
|
39206
39367
|
};
|
|
39207
39368
|
if (typeof window !== "undefined") {
|
|
39208
|
-
const isEditorMode2 = new URLSearchParams(window.location.search).has("editor_token");
|
|
39209
39369
|
const isDev = true;
|
|
39210
|
-
if (
|
|
39370
|
+
if (sdkMode || isDev) {
|
|
39211
39371
|
window.__smartCanvasHandle = handle;
|
|
39212
39372
|
}
|
|
39213
39373
|
}
|
|
@@ -39366,6 +39526,1363 @@ var SyntrologieSDK = (() => {
|
|
|
39366
39526
|
return new SessionMetricTracker(options);
|
|
39367
39527
|
}
|
|
39368
39528
|
|
|
39529
|
+
// src/context/schema.ts
|
|
39530
|
+
var PageContextZ = external_exports.object({
|
|
39531
|
+
url: external_exports.string(),
|
|
39532
|
+
routeId: external_exports.string().optional(),
|
|
39533
|
+
title: external_exports.string().optional(),
|
|
39534
|
+
locale: external_exports.string().optional()
|
|
39535
|
+
});
|
|
39536
|
+
var PageHistoryEntryZ = external_exports.object({
|
|
39537
|
+
url: external_exports.string(),
|
|
39538
|
+
ts: external_exports.number()
|
|
39539
|
+
});
|
|
39540
|
+
var SessionContextZ = external_exports.object({
|
|
39541
|
+
sessionId: external_exports.string(),
|
|
39542
|
+
startTs: external_exports.number(),
|
|
39543
|
+
pageHistory: external_exports.array(PageHistoryEntryZ).optional()
|
|
39544
|
+
});
|
|
39545
|
+
var ViewportContextZ = external_exports.object({
|
|
39546
|
+
width: external_exports.number(),
|
|
39547
|
+
height: external_exports.number()
|
|
39548
|
+
});
|
|
39549
|
+
var BoundingBoxZ = external_exports.object({
|
|
39550
|
+
x: external_exports.number(),
|
|
39551
|
+
y: external_exports.number(),
|
|
39552
|
+
w: external_exports.number(),
|
|
39553
|
+
h: external_exports.number()
|
|
39554
|
+
});
|
|
39555
|
+
var AnchorStateZ = external_exports.object({
|
|
39556
|
+
anchorId: external_exports.string(),
|
|
39557
|
+
present: external_exports.boolean(),
|
|
39558
|
+
visible: external_exports.boolean().optional(),
|
|
39559
|
+
boundingBox: BoundingBoxZ.optional()
|
|
39560
|
+
});
|
|
39561
|
+
var AugmentationZ = external_exports.record(
|
|
39562
|
+
external_exports.union([external_exports.number(), external_exports.string(), external_exports.boolean(), external_exports.undefined()])
|
|
39563
|
+
);
|
|
39564
|
+
var RuntimeContextZ = external_exports.object({
|
|
39565
|
+
page: PageContextZ,
|
|
39566
|
+
session: SessionContextZ,
|
|
39567
|
+
viewport: ViewportContextZ,
|
|
39568
|
+
anchors: external_exports.array(AnchorStateZ).optional(),
|
|
39569
|
+
augmented: AugmentationZ.optional()
|
|
39570
|
+
});
|
|
39571
|
+
function validateRuntimeContext(data) {
|
|
39572
|
+
return RuntimeContextZ.safeParse(data);
|
|
39573
|
+
}
|
|
39574
|
+
|
|
39575
|
+
// src/context/ContextManager.ts
|
|
39576
|
+
function createDefaultContext() {
|
|
39577
|
+
const now = Date.now();
|
|
39578
|
+
return {
|
|
39579
|
+
page: {
|
|
39580
|
+
url: typeof window !== "undefined" ? window.location.href : "",
|
|
39581
|
+
title: typeof document !== "undefined" ? document.title : void 0
|
|
39582
|
+
},
|
|
39583
|
+
session: {
|
|
39584
|
+
sessionId: "",
|
|
39585
|
+
startTs: now,
|
|
39586
|
+
pageHistory: []
|
|
39587
|
+
},
|
|
39588
|
+
viewport: {
|
|
39589
|
+
width: typeof window !== "undefined" ? window.innerWidth : 0,
|
|
39590
|
+
height: typeof window !== "undefined" ? window.innerHeight : 0
|
|
39591
|
+
}
|
|
39592
|
+
};
|
|
39593
|
+
}
|
|
39594
|
+
function matchRoute2(url, routes) {
|
|
39595
|
+
if (!routes) return void 0;
|
|
39596
|
+
let pathname;
|
|
39597
|
+
try {
|
|
39598
|
+
pathname = new URL(url).pathname;
|
|
39599
|
+
} catch {
|
|
39600
|
+
pathname = url;
|
|
39601
|
+
}
|
|
39602
|
+
if (routes.exclude) {
|
|
39603
|
+
for (const pattern of routes.exclude) {
|
|
39604
|
+
if (matchPattern(pathname, pattern)) {
|
|
39605
|
+
return void 0;
|
|
39606
|
+
}
|
|
39607
|
+
}
|
|
39608
|
+
}
|
|
39609
|
+
if (routes.include) {
|
|
39610
|
+
for (const pattern of routes.include) {
|
|
39611
|
+
if (matchPattern(pathname, pattern)) {
|
|
39612
|
+
return pattern;
|
|
39613
|
+
}
|
|
39614
|
+
}
|
|
39615
|
+
return void 0;
|
|
39616
|
+
}
|
|
39617
|
+
return pathname;
|
|
39618
|
+
}
|
|
39619
|
+
function matchPattern(pathname, pattern) {
|
|
39620
|
+
const normalizedPath = pathname.replace(/\/$/, "") || "/";
|
|
39621
|
+
const normalizedPattern = pattern.replace(/\/$/, "") || "/";
|
|
39622
|
+
if (normalizedPath === normalizedPattern) return true;
|
|
39623
|
+
const regexPattern = normalizedPattern.replace(/:[^/]+/g, "[^/]+").replace(/\*/g, ".*");
|
|
39624
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
39625
|
+
return regex.test(normalizedPath);
|
|
39626
|
+
}
|
|
39627
|
+
var ContextManager = class {
|
|
39628
|
+
constructor(options = {}) {
|
|
39629
|
+
__publicField(this, "context");
|
|
39630
|
+
__publicField(this, "previousContext");
|
|
39631
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
39632
|
+
__publicField(this, "telemetry");
|
|
39633
|
+
__publicField(this, "routes");
|
|
39634
|
+
// Event listener cleanup functions
|
|
39635
|
+
__publicField(this, "cleanupFns", []);
|
|
39636
|
+
this.telemetry = options.telemetry;
|
|
39637
|
+
this.routes = options.routes;
|
|
39638
|
+
this.context = createDefaultContext();
|
|
39639
|
+
this.previousContext = { ...this.context };
|
|
39640
|
+
if (options.telemetry?.getSessionId) {
|
|
39641
|
+
const sessionId = options.telemetry.getSessionId();
|
|
39642
|
+
if (sessionId) {
|
|
39643
|
+
this.context.session.sessionId = sessionId;
|
|
39644
|
+
}
|
|
39645
|
+
}
|
|
39646
|
+
if (options.initialPageHistory) {
|
|
39647
|
+
this.context.session.pageHistory = options.initialPageHistory;
|
|
39648
|
+
}
|
|
39649
|
+
this.context.page.routeId = matchRoute2(this.context.page.url, this.routes);
|
|
39650
|
+
this.addPageToHistory(this.context.page.url);
|
|
39651
|
+
if (typeof window !== "undefined") {
|
|
39652
|
+
this.setupBrowserListeners();
|
|
39653
|
+
}
|
|
39654
|
+
}
|
|
39655
|
+
/**
|
|
39656
|
+
* Get the current runtime context.
|
|
39657
|
+
*/
|
|
39658
|
+
get() {
|
|
39659
|
+
return { ...this.context };
|
|
39660
|
+
}
|
|
39661
|
+
/**
|
|
39662
|
+
* Subscribe to context changes.
|
|
39663
|
+
* Returns an unsubscribe function.
|
|
39664
|
+
*/
|
|
39665
|
+
subscribe(callback) {
|
|
39666
|
+
this.listeners.add(callback);
|
|
39667
|
+
return () => {
|
|
39668
|
+
this.listeners.delete(callback);
|
|
39669
|
+
};
|
|
39670
|
+
}
|
|
39671
|
+
/**
|
|
39672
|
+
* Update the routes config (e.g., when config is fetched).
|
|
39673
|
+
*/
|
|
39674
|
+
setRoutes(routes) {
|
|
39675
|
+
this.routes = routes;
|
|
39676
|
+
const newRouteId = matchRoute2(this.context.page.url, this.routes);
|
|
39677
|
+
if (newRouteId !== this.context.page.routeId) {
|
|
39678
|
+
this.updateContext({ page: { ...this.context.page, routeId: newRouteId } });
|
|
39679
|
+
}
|
|
39680
|
+
}
|
|
39681
|
+
/**
|
|
39682
|
+
* Update anchor states.
|
|
39683
|
+
*/
|
|
39684
|
+
setAnchors(anchors) {
|
|
39685
|
+
this.updateContext({ anchors });
|
|
39686
|
+
}
|
|
39687
|
+
/**
|
|
39688
|
+
* Manually update the session ID (e.g., when telemetry initializes).
|
|
39689
|
+
*/
|
|
39690
|
+
setSessionId(sessionId) {
|
|
39691
|
+
if (sessionId !== this.context.session.sessionId) {
|
|
39692
|
+
this.updateContext({
|
|
39693
|
+
session: { ...this.context.session, sessionId }
|
|
39694
|
+
});
|
|
39695
|
+
}
|
|
39696
|
+
}
|
|
39697
|
+
/**
|
|
39698
|
+
* Clean up event listeners and subscriptions.
|
|
39699
|
+
*/
|
|
39700
|
+
destroy() {
|
|
39701
|
+
for (const cleanup of this.cleanupFns) {
|
|
39702
|
+
cleanup();
|
|
39703
|
+
}
|
|
39704
|
+
this.cleanupFns = [];
|
|
39705
|
+
this.listeners.clear();
|
|
39706
|
+
}
|
|
39707
|
+
// ==================== Private Methods ====================
|
|
39708
|
+
setupBrowserListeners() {
|
|
39709
|
+
let resizeTimeout;
|
|
39710
|
+
const handleResize = () => {
|
|
39711
|
+
clearTimeout(resizeTimeout);
|
|
39712
|
+
resizeTimeout = setTimeout(() => {
|
|
39713
|
+
this.updateViewport();
|
|
39714
|
+
}, 100);
|
|
39715
|
+
};
|
|
39716
|
+
window.addEventListener("resize", handleResize);
|
|
39717
|
+
this.cleanupFns.push(() => window.removeEventListener("resize", handleResize));
|
|
39718
|
+
const handlePopState = () => {
|
|
39719
|
+
this.updatePage();
|
|
39720
|
+
};
|
|
39721
|
+
window.addEventListener("popstate", handlePopState);
|
|
39722
|
+
this.cleanupFns.push(() => window.removeEventListener("popstate", handlePopState));
|
|
39723
|
+
const originalPushState = history.pushState.bind(history);
|
|
39724
|
+
const originalReplaceState = history.replaceState.bind(history);
|
|
39725
|
+
history.pushState = (...args) => {
|
|
39726
|
+
originalPushState(...args);
|
|
39727
|
+
this.updatePage();
|
|
39728
|
+
};
|
|
39729
|
+
history.replaceState = (...args) => {
|
|
39730
|
+
originalReplaceState(...args);
|
|
39731
|
+
this.updatePage();
|
|
39732
|
+
};
|
|
39733
|
+
this.cleanupFns.push(() => {
|
|
39734
|
+
history.pushState = originalPushState;
|
|
39735
|
+
history.replaceState = originalReplaceState;
|
|
39736
|
+
});
|
|
39737
|
+
}
|
|
39738
|
+
updateViewport() {
|
|
39739
|
+
const newViewport = {
|
|
39740
|
+
width: window.innerWidth,
|
|
39741
|
+
height: window.innerHeight
|
|
39742
|
+
};
|
|
39743
|
+
if (newViewport.width !== this.context.viewport.width || newViewport.height !== this.context.viewport.height) {
|
|
39744
|
+
this.updateContext({ viewport: newViewport });
|
|
39745
|
+
}
|
|
39746
|
+
}
|
|
39747
|
+
updatePage() {
|
|
39748
|
+
const url = window.location.href;
|
|
39749
|
+
const title = document.title;
|
|
39750
|
+
const routeId = matchRoute2(url, this.routes);
|
|
39751
|
+
const newPage = {
|
|
39752
|
+
url,
|
|
39753
|
+
title,
|
|
39754
|
+
routeId
|
|
39755
|
+
};
|
|
39756
|
+
if (newPage.url !== this.context.page.url || newPage.title !== this.context.page.title || newPage.routeId !== this.context.page.routeId) {
|
|
39757
|
+
if (newPage.url !== this.context.page.url) {
|
|
39758
|
+
this.addPageToHistory(newPage.url);
|
|
39759
|
+
}
|
|
39760
|
+
this.updateContext({ page: newPage });
|
|
39761
|
+
}
|
|
39762
|
+
}
|
|
39763
|
+
addPageToHistory(url) {
|
|
39764
|
+
const entry = {
|
|
39765
|
+
url,
|
|
39766
|
+
ts: Date.now()
|
|
39767
|
+
};
|
|
39768
|
+
const pageHistory = [...this.context.session.pageHistory || [], entry];
|
|
39769
|
+
if (pageHistory.length > 50) {
|
|
39770
|
+
pageHistory.shift();
|
|
39771
|
+
}
|
|
39772
|
+
this.context.session.pageHistory = pageHistory;
|
|
39773
|
+
}
|
|
39774
|
+
updateContext(partial) {
|
|
39775
|
+
this.previousContext = { ...this.context };
|
|
39776
|
+
this.context = {
|
|
39777
|
+
...this.context,
|
|
39778
|
+
...partial
|
|
39779
|
+
};
|
|
39780
|
+
this.notifyListeners();
|
|
39781
|
+
}
|
|
39782
|
+
notifyListeners() {
|
|
39783
|
+
for (const callback of this.listeners) {
|
|
39784
|
+
try {
|
|
39785
|
+
callback(this.context, this.previousContext);
|
|
39786
|
+
} catch (err) {
|
|
39787
|
+
console.error("[ContextManager] Listener error:", err);
|
|
39788
|
+
}
|
|
39789
|
+
}
|
|
39790
|
+
}
|
|
39791
|
+
};
|
|
39792
|
+
function createContextManager(options = {}) {
|
|
39793
|
+
return new ContextManager(options);
|
|
39794
|
+
}
|
|
39795
|
+
|
|
39796
|
+
// src/events/types.ts
|
|
39797
|
+
var StandardEvents = {
|
|
39798
|
+
// UI events (from PostHog autocapture)
|
|
39799
|
+
UI_CLICK: "ui.click",
|
|
39800
|
+
UI_SCROLL: "ui.scroll",
|
|
39801
|
+
UI_INPUT: "ui.input",
|
|
39802
|
+
UI_CHANGE: "ui.change",
|
|
39803
|
+
UI_SUBMIT: "ui.submit",
|
|
39804
|
+
// Navigation events
|
|
39805
|
+
NAV_PAGE_VIEW: "nav.page_view",
|
|
39806
|
+
NAV_PAGE_LEAVE: "nav.page_leave",
|
|
39807
|
+
// Canvas events
|
|
39808
|
+
CANVAS_OPENED: "canvas.opened",
|
|
39809
|
+
CANVAS_CLOSED: "canvas.closed",
|
|
39810
|
+
TILE_VIEWED: "tile.viewed",
|
|
39811
|
+
TILE_EXPANDED: "tile.expanded",
|
|
39812
|
+
TILE_COLLAPSED: "tile.collapsed",
|
|
39813
|
+
TILE_ACTION: "tile.action",
|
|
39814
|
+
// Overlay/tour events
|
|
39815
|
+
OVERLAY_STARTED: "overlay.started",
|
|
39816
|
+
OVERLAY_COMPLETED: "overlay.completed",
|
|
39817
|
+
OVERLAY_DISMISSED: "overlay.dismissed",
|
|
39818
|
+
OVERLAY_STEP_VIEWED: "overlay.step_viewed",
|
|
39819
|
+
// Derived behavioral signals (Phase 3)
|
|
39820
|
+
BEHAVIOR_RAGE_CLICK: "behavior.rage_click",
|
|
39821
|
+
BEHAVIOR_HESITATION: "behavior.hesitation",
|
|
39822
|
+
BEHAVIOR_CONFUSION: "behavior.confusion"
|
|
39823
|
+
};
|
|
39824
|
+
var EVENT_SCHEMA_VERSION = "1.0.0";
|
|
39825
|
+
|
|
39826
|
+
// src/events/schema.ts
|
|
39827
|
+
var EventSourceZ = external_exports.enum(["posthog", "canvas", "derived"]);
|
|
39828
|
+
var NormalizedEventZ = external_exports.object({
|
|
39829
|
+
ts: external_exports.number(),
|
|
39830
|
+
name: external_exports.string(),
|
|
39831
|
+
source: EventSourceZ,
|
|
39832
|
+
props: external_exports.record(external_exports.unknown()).optional(),
|
|
39833
|
+
schemaVersion: external_exports.string()
|
|
39834
|
+
});
|
|
39835
|
+
var EventFilterZ = external_exports.object({
|
|
39836
|
+
names: external_exports.array(external_exports.string()).optional(),
|
|
39837
|
+
patterns: external_exports.array(external_exports.string()).optional(),
|
|
39838
|
+
sources: external_exports.array(EventSourceZ).optional()
|
|
39839
|
+
});
|
|
39840
|
+
function validateNormalizedEvent(data) {
|
|
39841
|
+
return NormalizedEventZ.safeParse(data);
|
|
39842
|
+
}
|
|
39843
|
+
function validateEventFilter(data) {
|
|
39844
|
+
return EventFilterZ.safeParse(data);
|
|
39845
|
+
}
|
|
39846
|
+
|
|
39847
|
+
// src/events/EventBus.ts
|
|
39848
|
+
function matchesFilter(event, filter) {
|
|
39849
|
+
if (!filter) return true;
|
|
39850
|
+
if (filter.names && filter.names.length > 0) {
|
|
39851
|
+
if (!filter.names.includes(event.name)) {
|
|
39852
|
+
return false;
|
|
39853
|
+
}
|
|
39854
|
+
}
|
|
39855
|
+
if (filter.patterns && filter.patterns.length > 0) {
|
|
39856
|
+
const matched = filter.patterns.some((pattern) => {
|
|
39857
|
+
try {
|
|
39858
|
+
const regex = new RegExp(pattern);
|
|
39859
|
+
return regex.test(event.name);
|
|
39860
|
+
} catch {
|
|
39861
|
+
return false;
|
|
39862
|
+
}
|
|
39863
|
+
});
|
|
39864
|
+
if (!matched) return false;
|
|
39865
|
+
}
|
|
39866
|
+
if (filter.sources && filter.sources.length > 0) {
|
|
39867
|
+
if (!filter.sources.includes(event.source)) {
|
|
39868
|
+
return false;
|
|
39869
|
+
}
|
|
39870
|
+
}
|
|
39871
|
+
return true;
|
|
39872
|
+
}
|
|
39873
|
+
var EventBus = class {
|
|
39874
|
+
constructor(options = {}) {
|
|
39875
|
+
__publicField(this, "subscriptions", /* @__PURE__ */ new Set());
|
|
39876
|
+
__publicField(this, "history", []);
|
|
39877
|
+
__publicField(this, "maxHistorySize");
|
|
39878
|
+
this.maxHistorySize = options.maxHistorySize ?? 100;
|
|
39879
|
+
}
|
|
39880
|
+
/**
|
|
39881
|
+
* Subscribe to events matching an optional filter.
|
|
39882
|
+
* Returns an unsubscribe function.
|
|
39883
|
+
*/
|
|
39884
|
+
subscribe(filterOrCallback, maybeCallback) {
|
|
39885
|
+
let filter;
|
|
39886
|
+
let callback;
|
|
39887
|
+
if (typeof filterOrCallback === "function") {
|
|
39888
|
+
filter = void 0;
|
|
39889
|
+
callback = filterOrCallback;
|
|
39890
|
+
} else {
|
|
39891
|
+
filter = filterOrCallback;
|
|
39892
|
+
callback = maybeCallback;
|
|
39893
|
+
}
|
|
39894
|
+
const subscription = { filter, callback };
|
|
39895
|
+
this.subscriptions.add(subscription);
|
|
39896
|
+
return () => {
|
|
39897
|
+
this.subscriptions.delete(subscription);
|
|
39898
|
+
};
|
|
39899
|
+
}
|
|
39900
|
+
/**
|
|
39901
|
+
* Publish an event to all matching subscribers.
|
|
39902
|
+
*/
|
|
39903
|
+
publish(name, props, source = "canvas") {
|
|
39904
|
+
const event = {
|
|
39905
|
+
ts: Date.now(),
|
|
39906
|
+
name,
|
|
39907
|
+
source,
|
|
39908
|
+
props,
|
|
39909
|
+
schemaVersion: EVENT_SCHEMA_VERSION
|
|
39910
|
+
};
|
|
39911
|
+
this.publishEvent(event);
|
|
39912
|
+
}
|
|
39913
|
+
/**
|
|
39914
|
+
* Publish a pre-constructed NormalizedEvent.
|
|
39915
|
+
*/
|
|
39916
|
+
publishEvent(event) {
|
|
39917
|
+
this.history.push(event);
|
|
39918
|
+
if (this.history.length > this.maxHistorySize) {
|
|
39919
|
+
this.history.shift();
|
|
39920
|
+
}
|
|
39921
|
+
for (const subscription of this.subscriptions) {
|
|
39922
|
+
if (matchesFilter(event, subscription.filter)) {
|
|
39923
|
+
try {
|
|
39924
|
+
subscription.callback(event);
|
|
39925
|
+
} catch (err) {
|
|
39926
|
+
console.error("[EventBus] Subscriber error:", err);
|
|
39927
|
+
}
|
|
39928
|
+
}
|
|
39929
|
+
}
|
|
39930
|
+
}
|
|
39931
|
+
/**
|
|
39932
|
+
* Get recent events matching an optional filter.
|
|
39933
|
+
*/
|
|
39934
|
+
getRecent(filter, limit) {
|
|
39935
|
+
let events = this.history;
|
|
39936
|
+
if (filter) {
|
|
39937
|
+
events = events.filter((e2) => matchesFilter(e2, filter));
|
|
39938
|
+
}
|
|
39939
|
+
if (limit && limit > 0) {
|
|
39940
|
+
events = events.slice(-limit);
|
|
39941
|
+
}
|
|
39942
|
+
return events;
|
|
39943
|
+
}
|
|
39944
|
+
/**
|
|
39945
|
+
* Check if an event with a specific name occurred within a time window.
|
|
39946
|
+
*/
|
|
39947
|
+
hasRecentEvent(eventName, withinMs, source) {
|
|
39948
|
+
const cutoff = Date.now() - withinMs;
|
|
39949
|
+
return this.history.some(
|
|
39950
|
+
(e2) => e2.name === eventName && e2.ts >= cutoff && (source === void 0 || e2.source === source)
|
|
39951
|
+
);
|
|
39952
|
+
}
|
|
39953
|
+
/**
|
|
39954
|
+
* Count events matching a filter within a time window.
|
|
39955
|
+
*/
|
|
39956
|
+
countRecentEvents(filter, withinMs) {
|
|
39957
|
+
let events = this.history.filter((e2) => matchesFilter(e2, filter));
|
|
39958
|
+
if (withinMs !== void 0) {
|
|
39959
|
+
const cutoff = Date.now() - withinMs;
|
|
39960
|
+
events = events.filter((e2) => e2.ts >= cutoff);
|
|
39961
|
+
}
|
|
39962
|
+
return events.length;
|
|
39963
|
+
}
|
|
39964
|
+
/**
|
|
39965
|
+
* Clear all event history.
|
|
39966
|
+
*/
|
|
39967
|
+
clearHistory() {
|
|
39968
|
+
this.history = [];
|
|
39969
|
+
}
|
|
39970
|
+
/**
|
|
39971
|
+
* Get the number of current subscribers.
|
|
39972
|
+
*/
|
|
39973
|
+
getSubscriberCount() {
|
|
39974
|
+
return this.subscriptions.size;
|
|
39975
|
+
}
|
|
39976
|
+
};
|
|
39977
|
+
function createEventBus(options = {}) {
|
|
39978
|
+
return new EventBus(options);
|
|
39979
|
+
}
|
|
39980
|
+
|
|
39981
|
+
// src/events/normalizers/posthog.ts
|
|
39982
|
+
var POSTHOG_EVENT_MAP = {
|
|
39983
|
+
// Autocapture events
|
|
39984
|
+
$autocapture: "ui.click",
|
|
39985
|
+
// Default autocapture is usually clicks
|
|
39986
|
+
$click: StandardEvents.UI_CLICK,
|
|
39987
|
+
$scroll: StandardEvents.UI_SCROLL,
|
|
39988
|
+
$input: StandardEvents.UI_INPUT,
|
|
39989
|
+
$change: StandardEvents.UI_CHANGE,
|
|
39990
|
+
$submit: StandardEvents.UI_SUBMIT,
|
|
39991
|
+
// Navigation events
|
|
39992
|
+
$pageview: StandardEvents.NAV_PAGE_VIEW,
|
|
39993
|
+
$pageleave: StandardEvents.NAV_PAGE_LEAVE,
|
|
39994
|
+
// Session events
|
|
39995
|
+
$session_start: "session.start",
|
|
39996
|
+
// Identify events
|
|
39997
|
+
$identify: "user.identify"
|
|
39998
|
+
};
|
|
39999
|
+
function getEventName(phEvent) {
|
|
40000
|
+
const eventName = phEvent.event;
|
|
40001
|
+
if (POSTHOG_EVENT_MAP[eventName]) {
|
|
40002
|
+
return POSTHOG_EVENT_MAP[eventName];
|
|
40003
|
+
}
|
|
40004
|
+
if (eventName === "$autocapture") {
|
|
40005
|
+
const tagName = phEvent.properties?.$tag_name;
|
|
40006
|
+
const eventType = phEvent.properties?.$event_type;
|
|
40007
|
+
if (eventType === "submit") return StandardEvents.UI_SUBMIT;
|
|
40008
|
+
if (eventType === "change") return StandardEvents.UI_CHANGE;
|
|
40009
|
+
if (tagName === "input" || tagName === "textarea") return StandardEvents.UI_INPUT;
|
|
40010
|
+
return StandardEvents.UI_CLICK;
|
|
40011
|
+
}
|
|
40012
|
+
if (!eventName.startsWith("$")) {
|
|
40013
|
+
return `posthog.${eventName}`;
|
|
40014
|
+
}
|
|
40015
|
+
return eventName.replace("$", "posthog.");
|
|
40016
|
+
}
|
|
40017
|
+
function extractProps(phEvent) {
|
|
40018
|
+
const props = {};
|
|
40019
|
+
const phProps = phEvent.properties || {};
|
|
40020
|
+
if (phProps.$tag_name) props.tagName = phProps.$tag_name;
|
|
40021
|
+
if (phProps.$el_text) props.elementText = phProps.$el_text;
|
|
40022
|
+
if (phProps.$elements) props.elements = phProps.$elements;
|
|
40023
|
+
if (phProps.$current_url) props.url = phProps.$current_url;
|
|
40024
|
+
if (phProps.$pathname) props.pathname = phProps.$pathname;
|
|
40025
|
+
if (phProps.$host) props.host = phProps.$host;
|
|
40026
|
+
if (phProps.$viewport_width) props.viewportWidth = phProps.$viewport_width;
|
|
40027
|
+
if (phProps.$viewport_height) props.viewportHeight = phProps.$viewport_height;
|
|
40028
|
+
if (phProps.$session_id) props.sessionId = phProps.$session_id;
|
|
40029
|
+
if (phProps.$scroll_depth) props.scrollDepth = phProps.$scroll_depth;
|
|
40030
|
+
if (phProps.$scroll_percentage) props.scrollPercentage = phProps.$scroll_percentage;
|
|
40031
|
+
props.originalEvent = phEvent.event;
|
|
40032
|
+
return props;
|
|
40033
|
+
}
|
|
40034
|
+
function normalizePostHogEvent(phEvent) {
|
|
40035
|
+
let ts2;
|
|
40036
|
+
if (typeof phEvent.timestamp === "number") {
|
|
40037
|
+
ts2 = phEvent.timestamp;
|
|
40038
|
+
} else if (typeof phEvent.timestamp === "string") {
|
|
40039
|
+
ts2 = new Date(phEvent.timestamp).getTime();
|
|
40040
|
+
} else {
|
|
40041
|
+
ts2 = Date.now();
|
|
40042
|
+
}
|
|
40043
|
+
return {
|
|
40044
|
+
ts: ts2,
|
|
40045
|
+
name: getEventName(phEvent),
|
|
40046
|
+
source: "posthog",
|
|
40047
|
+
props: extractProps(phEvent),
|
|
40048
|
+
schemaVersion: EVENT_SCHEMA_VERSION
|
|
40049
|
+
};
|
|
40050
|
+
}
|
|
40051
|
+
function shouldNormalizeEvent(phEvent) {
|
|
40052
|
+
const eventName = phEvent.event;
|
|
40053
|
+
const skipEvents = [
|
|
40054
|
+
"$feature_flag_called",
|
|
40055
|
+
"$feature_flags",
|
|
40056
|
+
"$groups",
|
|
40057
|
+
"$groupidentify",
|
|
40058
|
+
"$set",
|
|
40059
|
+
"$set_once",
|
|
40060
|
+
"$unset",
|
|
40061
|
+
"$create_alias",
|
|
40062
|
+
"$capture_metrics",
|
|
40063
|
+
"$performance_event",
|
|
40064
|
+
"$web_vitals",
|
|
40065
|
+
"$exception",
|
|
40066
|
+
"$dead_click",
|
|
40067
|
+
"$heatmap"
|
|
40068
|
+
];
|
|
40069
|
+
if (skipEvents.includes(eventName)) {
|
|
40070
|
+
return false;
|
|
40071
|
+
}
|
|
40072
|
+
return true;
|
|
40073
|
+
}
|
|
40074
|
+
function createPostHogNormalizer(publishFn) {
|
|
40075
|
+
return (eventName, properties) => {
|
|
40076
|
+
const phEvent = {
|
|
40077
|
+
event: eventName,
|
|
40078
|
+
properties,
|
|
40079
|
+
timestamp: Date.now()
|
|
40080
|
+
};
|
|
40081
|
+
if (shouldNormalizeEvent(phEvent)) {
|
|
40082
|
+
const normalizedEvent = normalizePostHogEvent(phEvent);
|
|
40083
|
+
publishFn(normalizedEvent);
|
|
40084
|
+
}
|
|
40085
|
+
};
|
|
40086
|
+
}
|
|
40087
|
+
|
|
40088
|
+
// src/events/normalizers/canvas.ts
|
|
40089
|
+
function createCanvasEvent(name, props) {
|
|
40090
|
+
return {
|
|
40091
|
+
ts: Date.now(),
|
|
40092
|
+
name,
|
|
40093
|
+
source: "canvas",
|
|
40094
|
+
props,
|
|
40095
|
+
schemaVersion: EVENT_SCHEMA_VERSION
|
|
40096
|
+
};
|
|
40097
|
+
}
|
|
40098
|
+
function canvasOpened(surface) {
|
|
40099
|
+
return createCanvasEvent(StandardEvents.CANVAS_OPENED, { surface });
|
|
40100
|
+
}
|
|
40101
|
+
function canvasClosed(surface) {
|
|
40102
|
+
return createCanvasEvent(StandardEvents.CANVAS_CLOSED, { surface });
|
|
40103
|
+
}
|
|
40104
|
+
function tileViewed(tileId, surface) {
|
|
40105
|
+
return createCanvasEvent(StandardEvents.TILE_VIEWED, { tileId, surface });
|
|
40106
|
+
}
|
|
40107
|
+
function tileExpanded(tileId, surface) {
|
|
40108
|
+
return createCanvasEvent(StandardEvents.TILE_EXPANDED, { tileId, surface });
|
|
40109
|
+
}
|
|
40110
|
+
function tileCollapsed(tileId, surface) {
|
|
40111
|
+
return createCanvasEvent(StandardEvents.TILE_COLLAPSED, { tileId, surface });
|
|
40112
|
+
}
|
|
40113
|
+
function tileAction(tileId, actionId, surface) {
|
|
40114
|
+
return createCanvasEvent(StandardEvents.TILE_ACTION, {
|
|
40115
|
+
tileId,
|
|
40116
|
+
actionId,
|
|
40117
|
+
surface
|
|
40118
|
+
});
|
|
40119
|
+
}
|
|
40120
|
+
function overlayStarted(recipeId, recipeName) {
|
|
40121
|
+
return createCanvasEvent(StandardEvents.OVERLAY_STARTED, {
|
|
40122
|
+
recipeId,
|
|
40123
|
+
recipeName
|
|
40124
|
+
});
|
|
40125
|
+
}
|
|
40126
|
+
function overlayCompleted(recipeId, recipeName) {
|
|
40127
|
+
return createCanvasEvent(StandardEvents.OVERLAY_COMPLETED, {
|
|
40128
|
+
recipeId,
|
|
40129
|
+
recipeName
|
|
40130
|
+
});
|
|
40131
|
+
}
|
|
40132
|
+
function overlayDismissed(recipeId, recipeName, stepIndex) {
|
|
40133
|
+
return createCanvasEvent(StandardEvents.OVERLAY_DISMISSED, {
|
|
40134
|
+
recipeId,
|
|
40135
|
+
recipeName,
|
|
40136
|
+
stepIndex
|
|
40137
|
+
});
|
|
40138
|
+
}
|
|
40139
|
+
function overlayStepViewed(recipeId, stepIndex, stepTitle) {
|
|
40140
|
+
return createCanvasEvent(StandardEvents.OVERLAY_STEP_VIEWED, {
|
|
40141
|
+
recipeId,
|
|
40142
|
+
stepIndex,
|
|
40143
|
+
stepTitle
|
|
40144
|
+
});
|
|
40145
|
+
}
|
|
40146
|
+
function customCanvasEvent(name, props) {
|
|
40147
|
+
const eventName = name.startsWith("canvas.") ? name : `canvas.${name}`;
|
|
40148
|
+
return createCanvasEvent(eventName, props);
|
|
40149
|
+
}
|
|
40150
|
+
var CanvasEvents = {
|
|
40151
|
+
canvasOpened,
|
|
40152
|
+
canvasClosed,
|
|
40153
|
+
tileViewed,
|
|
40154
|
+
tileExpanded,
|
|
40155
|
+
tileCollapsed,
|
|
40156
|
+
tileAction,
|
|
40157
|
+
overlayStarted,
|
|
40158
|
+
overlayCompleted,
|
|
40159
|
+
overlayDismissed,
|
|
40160
|
+
overlayStepViewed,
|
|
40161
|
+
custom: customCanvasEvent
|
|
40162
|
+
};
|
|
40163
|
+
|
|
40164
|
+
// src/state/schema.ts
|
|
40165
|
+
var StoredValueZ = external_exports.object({
|
|
40166
|
+
value: external_exports.unknown(),
|
|
40167
|
+
expiresAt: external_exports.number().optional()
|
|
40168
|
+
});
|
|
40169
|
+
var FrequencyEntryZ = external_exports.object({
|
|
40170
|
+
count: external_exports.number(),
|
|
40171
|
+
resetAt: external_exports.number().optional()
|
|
40172
|
+
});
|
|
40173
|
+
function validateStoredValue(data) {
|
|
40174
|
+
return StoredValueZ.safeParse(data);
|
|
40175
|
+
}
|
|
40176
|
+
function validateFrequencyEntry(data) {
|
|
40177
|
+
return FrequencyEntryZ.safeParse(data);
|
|
40178
|
+
}
|
|
40179
|
+
|
|
40180
|
+
// src/state/helpers/dismissals.ts
|
|
40181
|
+
var DISMISSAL_PREFIX = "dismissed:";
|
|
40182
|
+
function createDismissalStore(sessionStorage2, userStorage) {
|
|
40183
|
+
return {
|
|
40184
|
+
mark(key, permanent = false) {
|
|
40185
|
+
const storageKey = DISMISSAL_PREFIX + key;
|
|
40186
|
+
const storage = permanent ? userStorage : sessionStorage2;
|
|
40187
|
+
storage.set(storageKey, true);
|
|
40188
|
+
},
|
|
40189
|
+
isDismissed(key) {
|
|
40190
|
+
const storageKey = DISMISSAL_PREFIX + key;
|
|
40191
|
+
return sessionStorage2.has(storageKey) || userStorage.has(storageKey);
|
|
40192
|
+
},
|
|
40193
|
+
clear(key) {
|
|
40194
|
+
const storageKey = DISMISSAL_PREFIX + key;
|
|
40195
|
+
sessionStorage2.remove(storageKey);
|
|
40196
|
+
userStorage.remove(storageKey);
|
|
40197
|
+
},
|
|
40198
|
+
clearAll() {
|
|
40199
|
+
for (const key of sessionStorage2.keys()) {
|
|
40200
|
+
if (key.startsWith(DISMISSAL_PREFIX)) {
|
|
40201
|
+
sessionStorage2.remove(key);
|
|
40202
|
+
}
|
|
40203
|
+
}
|
|
40204
|
+
for (const key of userStorage.keys()) {
|
|
40205
|
+
if (key.startsWith(DISMISSAL_PREFIX)) {
|
|
40206
|
+
userStorage.remove(key);
|
|
40207
|
+
}
|
|
40208
|
+
}
|
|
40209
|
+
}
|
|
40210
|
+
};
|
|
40211
|
+
}
|
|
40212
|
+
|
|
40213
|
+
// src/state/helpers/cooldowns.ts
|
|
40214
|
+
var COOLDOWN_PREFIX = "cooldown:";
|
|
40215
|
+
function createCooldownStore(storage) {
|
|
40216
|
+
return {
|
|
40217
|
+
set(key, durationMs) {
|
|
40218
|
+
const storageKey = COOLDOWN_PREFIX + key;
|
|
40219
|
+
const expiresAt = Date.now() + durationMs;
|
|
40220
|
+
storage.set(storageKey, expiresAt);
|
|
40221
|
+
},
|
|
40222
|
+
isActive(key) {
|
|
40223
|
+
return this.remaining(key) > 0;
|
|
40224
|
+
},
|
|
40225
|
+
remaining(key) {
|
|
40226
|
+
const storageKey = COOLDOWN_PREFIX + key;
|
|
40227
|
+
const expiresAt = storage.get(storageKey);
|
|
40228
|
+
if (expiresAt === void 0) return 0;
|
|
40229
|
+
const remaining = expiresAt - Date.now();
|
|
40230
|
+
if (remaining <= 0) {
|
|
40231
|
+
storage.remove(storageKey);
|
|
40232
|
+
return 0;
|
|
40233
|
+
}
|
|
40234
|
+
return remaining;
|
|
40235
|
+
},
|
|
40236
|
+
clear(key) {
|
|
40237
|
+
const storageKey = COOLDOWN_PREFIX + key;
|
|
40238
|
+
storage.remove(storageKey);
|
|
40239
|
+
}
|
|
40240
|
+
};
|
|
40241
|
+
}
|
|
40242
|
+
|
|
40243
|
+
// src/state/helpers/frequency.ts
|
|
40244
|
+
var FREQUENCY_PREFIX = "freq:";
|
|
40245
|
+
function createFrequencyStore(storage) {
|
|
40246
|
+
function getEntry(key) {
|
|
40247
|
+
const storageKey = FREQUENCY_PREFIX + key;
|
|
40248
|
+
const entry = storage.get(storageKey);
|
|
40249
|
+
if (!entry) return void 0;
|
|
40250
|
+
if (entry.resetAt && Date.now() >= entry.resetAt) {
|
|
40251
|
+
storage.remove(storageKey);
|
|
40252
|
+
return void 0;
|
|
40253
|
+
}
|
|
40254
|
+
return entry;
|
|
40255
|
+
}
|
|
40256
|
+
return {
|
|
40257
|
+
increment(key, resetAfterMs) {
|
|
40258
|
+
const storageKey = FREQUENCY_PREFIX + key;
|
|
40259
|
+
const existing = getEntry(key);
|
|
40260
|
+
const newCount = (existing?.count ?? 0) + 1;
|
|
40261
|
+
const entry = {
|
|
40262
|
+
count: newCount,
|
|
40263
|
+
// Keep existing resetAt or set new one
|
|
40264
|
+
resetAt: existing?.resetAt ?? (resetAfterMs ? Date.now() + resetAfterMs : void 0)
|
|
40265
|
+
};
|
|
40266
|
+
storage.set(storageKey, entry);
|
|
40267
|
+
return newCount;
|
|
40268
|
+
},
|
|
40269
|
+
count(key) {
|
|
40270
|
+
const entry = getEntry(key);
|
|
40271
|
+
return entry?.count ?? 0;
|
|
40272
|
+
},
|
|
40273
|
+
reset(key) {
|
|
40274
|
+
const storageKey = FREQUENCY_PREFIX + key;
|
|
40275
|
+
storage.remove(storageKey);
|
|
40276
|
+
},
|
|
40277
|
+
hasReachedLimit(key, limit) {
|
|
40278
|
+
return this.count(key) >= limit;
|
|
40279
|
+
}
|
|
40280
|
+
};
|
|
40281
|
+
}
|
|
40282
|
+
|
|
40283
|
+
// src/state/StateStore.ts
|
|
40284
|
+
var DEFAULT_NAMESPACE = "syntro";
|
|
40285
|
+
function createBrowserStorage(storage, namespace) {
|
|
40286
|
+
const prefix = `${namespace}:`;
|
|
40287
|
+
return {
|
|
40288
|
+
get(key) {
|
|
40289
|
+
if (!storage) return void 0;
|
|
40290
|
+
try {
|
|
40291
|
+
const raw = storage.getItem(prefix + key);
|
|
40292
|
+
if (!raw) return void 0;
|
|
40293
|
+
const stored = JSON.parse(raw);
|
|
40294
|
+
if (stored.expiresAt && Date.now() >= stored.expiresAt) {
|
|
40295
|
+
storage.removeItem(prefix + key);
|
|
40296
|
+
return void 0;
|
|
40297
|
+
}
|
|
40298
|
+
return stored.value;
|
|
40299
|
+
} catch {
|
|
40300
|
+
return void 0;
|
|
40301
|
+
}
|
|
40302
|
+
},
|
|
40303
|
+
set(key, value, ttlMs) {
|
|
40304
|
+
if (!storage) return;
|
|
40305
|
+
try {
|
|
40306
|
+
const stored = {
|
|
40307
|
+
value,
|
|
40308
|
+
expiresAt: ttlMs ? Date.now() + ttlMs : void 0
|
|
40309
|
+
};
|
|
40310
|
+
storage.setItem(prefix + key, JSON.stringify(stored));
|
|
40311
|
+
} catch (err) {
|
|
40312
|
+
console.warn("[StateStore] Failed to save:", err);
|
|
40313
|
+
}
|
|
40314
|
+
},
|
|
40315
|
+
remove(key) {
|
|
40316
|
+
if (!storage) return;
|
|
40317
|
+
storage.removeItem(prefix + key);
|
|
40318
|
+
},
|
|
40319
|
+
has(key) {
|
|
40320
|
+
if (!storage) return false;
|
|
40321
|
+
return this.get(key) !== void 0;
|
|
40322
|
+
},
|
|
40323
|
+
keys() {
|
|
40324
|
+
if (!storage) return [];
|
|
40325
|
+
const keys = [];
|
|
40326
|
+
for (let i2 = 0; i2 < storage.length; i2++) {
|
|
40327
|
+
const key = storage.key(i2);
|
|
40328
|
+
if (key?.startsWith(prefix)) {
|
|
40329
|
+
keys.push(key.slice(prefix.length));
|
|
40330
|
+
}
|
|
40331
|
+
}
|
|
40332
|
+
return keys;
|
|
40333
|
+
},
|
|
40334
|
+
clear() {
|
|
40335
|
+
if (!storage) return;
|
|
40336
|
+
const keysToRemove = this.keys();
|
|
40337
|
+
for (const key of keysToRemove) {
|
|
40338
|
+
storage.removeItem(prefix + key);
|
|
40339
|
+
}
|
|
40340
|
+
}
|
|
40341
|
+
};
|
|
40342
|
+
}
|
|
40343
|
+
function createMemoryStorage(namespace) {
|
|
40344
|
+
const store = /* @__PURE__ */ new Map();
|
|
40345
|
+
const prefix = `${namespace}:`;
|
|
40346
|
+
return {
|
|
40347
|
+
get(key) {
|
|
40348
|
+
const stored = store.get(prefix + key);
|
|
40349
|
+
if (!stored) return void 0;
|
|
40350
|
+
if (stored.expiresAt && Date.now() >= stored.expiresAt) {
|
|
40351
|
+
store.delete(prefix + key);
|
|
40352
|
+
return void 0;
|
|
40353
|
+
}
|
|
40354
|
+
return stored.value;
|
|
40355
|
+
},
|
|
40356
|
+
set(key, value, ttlMs) {
|
|
40357
|
+
store.set(prefix + key, {
|
|
40358
|
+
value,
|
|
40359
|
+
expiresAt: ttlMs ? Date.now() + ttlMs : void 0
|
|
40360
|
+
});
|
|
40361
|
+
},
|
|
40362
|
+
remove(key) {
|
|
40363
|
+
store.delete(prefix + key);
|
|
40364
|
+
},
|
|
40365
|
+
has(key) {
|
|
40366
|
+
return this.get(key) !== void 0;
|
|
40367
|
+
},
|
|
40368
|
+
keys() {
|
|
40369
|
+
const keys = [];
|
|
40370
|
+
for (const key of store.keys()) {
|
|
40371
|
+
if (key.startsWith(prefix)) {
|
|
40372
|
+
keys.push(key.slice(prefix.length));
|
|
40373
|
+
}
|
|
40374
|
+
}
|
|
40375
|
+
return keys;
|
|
40376
|
+
},
|
|
40377
|
+
clear() {
|
|
40378
|
+
for (const key of store.keys()) {
|
|
40379
|
+
if (key.startsWith(prefix)) {
|
|
40380
|
+
store.delete(key);
|
|
40381
|
+
}
|
|
40382
|
+
}
|
|
40383
|
+
}
|
|
40384
|
+
};
|
|
40385
|
+
}
|
|
40386
|
+
var StateStore = class {
|
|
40387
|
+
constructor(options = {}) {
|
|
40388
|
+
/** Session-scoped storage (cleared on browser close) */
|
|
40389
|
+
__publicField(this, "session");
|
|
40390
|
+
/** User-scoped storage (persists across sessions) */
|
|
40391
|
+
__publicField(this, "user");
|
|
40392
|
+
/** Dismissal tracking */
|
|
40393
|
+
__publicField(this, "dismissals");
|
|
40394
|
+
/** Cooldown tracking */
|
|
40395
|
+
__publicField(this, "cooldowns");
|
|
40396
|
+
/** Frequency tracking */
|
|
40397
|
+
__publicField(this, "frequency");
|
|
40398
|
+
__publicField(this, "namespace");
|
|
40399
|
+
__publicField(this, "namespacedStorages", /* @__PURE__ */ new Map());
|
|
40400
|
+
this.namespace = options.namespace ?? DEFAULT_NAMESPACE;
|
|
40401
|
+
if (typeof window !== "undefined") {
|
|
40402
|
+
this.session = createBrowserStorage(
|
|
40403
|
+
typeof sessionStorage !== "undefined" ? sessionStorage : void 0,
|
|
40404
|
+
this.namespace
|
|
40405
|
+
);
|
|
40406
|
+
this.user = createBrowserStorage(
|
|
40407
|
+
typeof localStorage !== "undefined" ? localStorage : void 0,
|
|
40408
|
+
this.namespace
|
|
40409
|
+
);
|
|
40410
|
+
} else {
|
|
40411
|
+
this.session = createMemoryStorage(this.namespace);
|
|
40412
|
+
this.user = createMemoryStorage(this.namespace);
|
|
40413
|
+
}
|
|
40414
|
+
this.dismissals = createDismissalStore(this.session, this.user);
|
|
40415
|
+
this.cooldowns = createCooldownStore(this.user);
|
|
40416
|
+
this.frequency = createFrequencyStore(this.session);
|
|
40417
|
+
}
|
|
40418
|
+
/**
|
|
40419
|
+
* Create a namespaced storage scope.
|
|
40420
|
+
* Useful for isolating state by adaptive/tile.
|
|
40421
|
+
*
|
|
40422
|
+
* @param namespace - Additional namespace segment
|
|
40423
|
+
* @returns A ScopedStorage with the nested namespace
|
|
40424
|
+
*/
|
|
40425
|
+
ns(namespace) {
|
|
40426
|
+
const fullNamespace = `${this.namespace}:${namespace}`;
|
|
40427
|
+
if (!this.namespacedStorages.has(fullNamespace)) {
|
|
40428
|
+
const storage = typeof window !== "undefined" && typeof sessionStorage !== "undefined" ? createBrowserStorage(sessionStorage, fullNamespace) : createMemoryStorage(fullNamespace);
|
|
40429
|
+
this.namespacedStorages.set(fullNamespace, storage);
|
|
40430
|
+
}
|
|
40431
|
+
return this.namespacedStorages.get(fullNamespace);
|
|
40432
|
+
}
|
|
40433
|
+
};
|
|
40434
|
+
function createStateStore(options = {}) {
|
|
40435
|
+
return new StateStore(options);
|
|
40436
|
+
}
|
|
40437
|
+
|
|
40438
|
+
// src/decisions/schema.ts
|
|
40439
|
+
var PageUrlConditionZ = external_exports.object({
|
|
40440
|
+
type: external_exports.literal("page_url"),
|
|
40441
|
+
url: external_exports.string()
|
|
40442
|
+
});
|
|
40443
|
+
var RouteConditionZ = external_exports.object({
|
|
40444
|
+
type: external_exports.literal("route"),
|
|
40445
|
+
routeId: external_exports.string()
|
|
40446
|
+
});
|
|
40447
|
+
var AnchorVisibleConditionZ = external_exports.object({
|
|
40448
|
+
type: external_exports.literal("anchor_visible"),
|
|
40449
|
+
anchorId: external_exports.string(),
|
|
40450
|
+
state: external_exports.enum(["visible", "present", "absent"])
|
|
40451
|
+
});
|
|
40452
|
+
var EventOccurredConditionZ = external_exports.object({
|
|
40453
|
+
type: external_exports.literal("event_occurred"),
|
|
40454
|
+
eventName: external_exports.string(),
|
|
40455
|
+
withinMs: external_exports.number().optional()
|
|
40456
|
+
});
|
|
40457
|
+
var StateEqualsConditionZ = external_exports.object({
|
|
40458
|
+
type: external_exports.literal("state_equals"),
|
|
40459
|
+
key: external_exports.string(),
|
|
40460
|
+
value: external_exports.unknown()
|
|
40461
|
+
});
|
|
40462
|
+
var ViewportConditionZ = external_exports.object({
|
|
40463
|
+
type: external_exports.literal("viewport"),
|
|
40464
|
+
minWidth: external_exports.number().optional(),
|
|
40465
|
+
maxWidth: external_exports.number().optional(),
|
|
40466
|
+
minHeight: external_exports.number().optional(),
|
|
40467
|
+
maxHeight: external_exports.number().optional()
|
|
40468
|
+
});
|
|
40469
|
+
var SessionMetricConditionZ = external_exports.object({
|
|
40470
|
+
type: external_exports.literal("session_metric"),
|
|
40471
|
+
key: external_exports.string(),
|
|
40472
|
+
operator: external_exports.enum(["gte", "lte", "eq", "gt", "lt"]),
|
|
40473
|
+
threshold: external_exports.number()
|
|
40474
|
+
});
|
|
40475
|
+
var DismissedConditionZ = external_exports.object({
|
|
40476
|
+
type: external_exports.literal("dismissed"),
|
|
40477
|
+
key: external_exports.string(),
|
|
40478
|
+
inverted: external_exports.boolean().optional()
|
|
40479
|
+
});
|
|
40480
|
+
var CooldownActiveConditionZ = external_exports.object({
|
|
40481
|
+
type: external_exports.literal("cooldown_active"),
|
|
40482
|
+
key: external_exports.string(),
|
|
40483
|
+
inverted: external_exports.boolean().optional()
|
|
40484
|
+
});
|
|
40485
|
+
var FrequencyLimitConditionZ = external_exports.object({
|
|
40486
|
+
type: external_exports.literal("frequency_limit"),
|
|
40487
|
+
key: external_exports.string(),
|
|
40488
|
+
limit: external_exports.number(),
|
|
40489
|
+
inverted: external_exports.boolean().optional()
|
|
40490
|
+
});
|
|
40491
|
+
var ConditionZ = external_exports.discriminatedUnion("type", [
|
|
40492
|
+
PageUrlConditionZ,
|
|
40493
|
+
RouteConditionZ,
|
|
40494
|
+
AnchorVisibleConditionZ,
|
|
40495
|
+
EventOccurredConditionZ,
|
|
40496
|
+
StateEqualsConditionZ,
|
|
40497
|
+
ViewportConditionZ,
|
|
40498
|
+
SessionMetricConditionZ,
|
|
40499
|
+
DismissedConditionZ,
|
|
40500
|
+
CooldownActiveConditionZ,
|
|
40501
|
+
FrequencyLimitConditionZ
|
|
40502
|
+
]);
|
|
40503
|
+
var RuleZ = external_exports.object({
|
|
40504
|
+
conditions: external_exports.array(ConditionZ),
|
|
40505
|
+
value: external_exports.unknown()
|
|
40506
|
+
});
|
|
40507
|
+
var RuleStrategyZ = external_exports.object({
|
|
40508
|
+
type: external_exports.literal("rules"),
|
|
40509
|
+
rules: external_exports.array(RuleZ),
|
|
40510
|
+
default: external_exports.unknown()
|
|
40511
|
+
});
|
|
40512
|
+
var ScoreStrategyZ = external_exports.object({
|
|
40513
|
+
type: external_exports.literal("score"),
|
|
40514
|
+
field: external_exports.string(),
|
|
40515
|
+
threshold: external_exports.number(),
|
|
40516
|
+
above: external_exports.unknown(),
|
|
40517
|
+
below: external_exports.unknown()
|
|
40518
|
+
});
|
|
40519
|
+
var ModelStrategyZ = external_exports.object({
|
|
40520
|
+
type: external_exports.literal("model"),
|
|
40521
|
+
modelId: external_exports.string(),
|
|
40522
|
+
inputs: external_exports.array(external_exports.string()),
|
|
40523
|
+
outputMapping: external_exports.record(external_exports.unknown()),
|
|
40524
|
+
default: external_exports.unknown()
|
|
40525
|
+
});
|
|
40526
|
+
var ExternalStrategyZ = external_exports.object({
|
|
40527
|
+
type: external_exports.literal("external"),
|
|
40528
|
+
endpoint: external_exports.string(),
|
|
40529
|
+
method: external_exports.enum(["GET", "POST"]).optional(),
|
|
40530
|
+
default: external_exports.unknown(),
|
|
40531
|
+
timeoutMs: external_exports.number().optional()
|
|
40532
|
+
});
|
|
40533
|
+
var DecisionStrategyZ = external_exports.discriminatedUnion("type", [
|
|
40534
|
+
RuleStrategyZ,
|
|
40535
|
+
ScoreStrategyZ,
|
|
40536
|
+
ModelStrategyZ,
|
|
40537
|
+
ExternalStrategyZ
|
|
40538
|
+
]);
|
|
40539
|
+
var RouteFilterZ = external_exports.object({
|
|
40540
|
+
include: external_exports.array(external_exports.string()).optional(),
|
|
40541
|
+
exclude: external_exports.array(external_exports.string()).optional()
|
|
40542
|
+
});
|
|
40543
|
+
var ActivationConfigZ = external_exports.object({
|
|
40544
|
+
routes: RouteFilterZ.optional(),
|
|
40545
|
+
strategy: DecisionStrategyZ.optional()
|
|
40546
|
+
});
|
|
40547
|
+
function validateCondition(data) {
|
|
40548
|
+
return ConditionZ.safeParse(data);
|
|
40549
|
+
}
|
|
40550
|
+
function validateStrategy(data) {
|
|
40551
|
+
return DecisionStrategyZ.safeParse(data);
|
|
40552
|
+
}
|
|
40553
|
+
function validateActivationConfig(data) {
|
|
40554
|
+
return ActivationConfigZ.safeParse(data);
|
|
40555
|
+
}
|
|
40556
|
+
|
|
40557
|
+
// src/decisions/strategies/rules.ts
|
|
40558
|
+
function evaluateCondition(condition, evalContext) {
|
|
40559
|
+
const { context, state, events } = evalContext;
|
|
40560
|
+
switch (condition.type) {
|
|
40561
|
+
case "page_url": {
|
|
40562
|
+
const { url } = condition;
|
|
40563
|
+
const currentUrl = context.page.url;
|
|
40564
|
+
const pattern = url.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*");
|
|
40565
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
40566
|
+
return regex.test(currentUrl);
|
|
40567
|
+
}
|
|
40568
|
+
case "route": {
|
|
40569
|
+
return context.page.routeId === condition.routeId;
|
|
40570
|
+
}
|
|
40571
|
+
case "anchor_visible": {
|
|
40572
|
+
const anchor = context.anchors?.find(
|
|
40573
|
+
(a2) => a2.anchorId === condition.anchorId
|
|
40574
|
+
);
|
|
40575
|
+
switch (condition.state) {
|
|
40576
|
+
case "visible":
|
|
40577
|
+
return anchor?.visible === true;
|
|
40578
|
+
case "present":
|
|
40579
|
+
return anchor?.present === true;
|
|
40580
|
+
case "absent":
|
|
40581
|
+
return !anchor?.present;
|
|
40582
|
+
default:
|
|
40583
|
+
return false;
|
|
40584
|
+
}
|
|
40585
|
+
}
|
|
40586
|
+
case "event_occurred": {
|
|
40587
|
+
if (!events) return false;
|
|
40588
|
+
const withinMs = condition.withinMs ?? 6e4;
|
|
40589
|
+
return events.hasRecentEvent(condition.eventName, withinMs);
|
|
40590
|
+
}
|
|
40591
|
+
case "state_equals": {
|
|
40592
|
+
if (!state) return false;
|
|
40593
|
+
return false;
|
|
40594
|
+
}
|
|
40595
|
+
case "viewport": {
|
|
40596
|
+
const { width, height } = context.viewport;
|
|
40597
|
+
if (condition.minWidth !== void 0 && width < condition.minWidth)
|
|
40598
|
+
return false;
|
|
40599
|
+
if (condition.maxWidth !== void 0 && width > condition.maxWidth)
|
|
40600
|
+
return false;
|
|
40601
|
+
if (condition.minHeight !== void 0 && height < condition.minHeight)
|
|
40602
|
+
return false;
|
|
40603
|
+
if (condition.maxHeight !== void 0 && height > condition.maxHeight)
|
|
40604
|
+
return false;
|
|
40605
|
+
return true;
|
|
40606
|
+
}
|
|
40607
|
+
case "session_metric": {
|
|
40608
|
+
if (!state) return false;
|
|
40609
|
+
const metricValue = state.getSessionMetric(condition.key);
|
|
40610
|
+
const { operator, threshold } = condition;
|
|
40611
|
+
switch (operator) {
|
|
40612
|
+
case "gte":
|
|
40613
|
+
return metricValue >= threshold;
|
|
40614
|
+
case "lte":
|
|
40615
|
+
return metricValue <= threshold;
|
|
40616
|
+
case "eq":
|
|
40617
|
+
return metricValue === threshold;
|
|
40618
|
+
case "gt":
|
|
40619
|
+
return metricValue > threshold;
|
|
40620
|
+
case "lt":
|
|
40621
|
+
return metricValue < threshold;
|
|
40622
|
+
default:
|
|
40623
|
+
return false;
|
|
40624
|
+
}
|
|
40625
|
+
}
|
|
40626
|
+
case "dismissed": {
|
|
40627
|
+
if (!state) return condition.inverted ?? false;
|
|
40628
|
+
const isDismissed = state.isDismissed(condition.key);
|
|
40629
|
+
return condition.inverted ? !isDismissed : isDismissed;
|
|
40630
|
+
}
|
|
40631
|
+
case "cooldown_active": {
|
|
40632
|
+
if (!state) return condition.inverted ?? false;
|
|
40633
|
+
const isActive = state.isCooldownActive(condition.key);
|
|
40634
|
+
return condition.inverted ? !isActive : isActive;
|
|
40635
|
+
}
|
|
40636
|
+
case "frequency_limit": {
|
|
40637
|
+
if (!state) return condition.inverted ?? false;
|
|
40638
|
+
const count = state.getFrequencyCount(condition.key);
|
|
40639
|
+
const limitReached = count >= condition.limit;
|
|
40640
|
+
return condition.inverted ? !limitReached : limitReached;
|
|
40641
|
+
}
|
|
40642
|
+
default:
|
|
40643
|
+
console.warn("[RuleStrategy] Unknown condition type:", condition.type);
|
|
40644
|
+
return false;
|
|
40645
|
+
}
|
|
40646
|
+
}
|
|
40647
|
+
function evaluateRule(rule, evalContext) {
|
|
40648
|
+
const conditionResults = [];
|
|
40649
|
+
for (const condition of rule.conditions) {
|
|
40650
|
+
const result = evaluateCondition(condition, evalContext);
|
|
40651
|
+
conditionResults.push({ condition, result });
|
|
40652
|
+
if (!result) {
|
|
40653
|
+
return { matched: false, conditionResults };
|
|
40654
|
+
}
|
|
40655
|
+
}
|
|
40656
|
+
return { matched: true, conditionResults };
|
|
40657
|
+
}
|
|
40658
|
+
function evaluateRuleStrategy(strategy, evalContext) {
|
|
40659
|
+
for (let i2 = 0; i2 < strategy.rules.length; i2++) {
|
|
40660
|
+
const rule = strategy.rules[i2];
|
|
40661
|
+
const { matched, conditionResults } = evaluateRule(rule, evalContext);
|
|
40662
|
+
if (matched) {
|
|
40663
|
+
return {
|
|
40664
|
+
value: rule.value,
|
|
40665
|
+
isFallback: false,
|
|
40666
|
+
matchInfo: {
|
|
40667
|
+
strategyType: "rules",
|
|
40668
|
+
matchedRuleIndex: i2,
|
|
40669
|
+
evaluatedConditions: conditionResults
|
|
40670
|
+
}
|
|
40671
|
+
};
|
|
40672
|
+
}
|
|
40673
|
+
}
|
|
40674
|
+
return {
|
|
40675
|
+
value: strategy.default,
|
|
40676
|
+
isFallback: true,
|
|
40677
|
+
matchInfo: {
|
|
40678
|
+
strategyType: "rules"
|
|
40679
|
+
}
|
|
40680
|
+
};
|
|
40681
|
+
}
|
|
40682
|
+
|
|
40683
|
+
// src/decisions/strategies/score.ts
|
|
40684
|
+
function evaluateScoreStrategy(strategy, evalContext) {
|
|
40685
|
+
const { context } = evalContext;
|
|
40686
|
+
const score = context.augmented?.[strategy.field];
|
|
40687
|
+
if (score === void 0 || typeof score !== "number") {
|
|
40688
|
+
return {
|
|
40689
|
+
value: strategy.below,
|
|
40690
|
+
isFallback: true,
|
|
40691
|
+
matchInfo: {
|
|
40692
|
+
strategyType: "score"
|
|
40693
|
+
}
|
|
40694
|
+
};
|
|
40695
|
+
}
|
|
40696
|
+
const isAbove = score >= strategy.threshold;
|
|
40697
|
+
return {
|
|
40698
|
+
value: isAbove ? strategy.above : strategy.below,
|
|
40699
|
+
isFallback: false,
|
|
40700
|
+
matchInfo: {
|
|
40701
|
+
strategyType: "score"
|
|
40702
|
+
}
|
|
40703
|
+
};
|
|
40704
|
+
}
|
|
40705
|
+
|
|
40706
|
+
// src/decisions/engine.ts
|
|
40707
|
+
function createEvaluationContext(context, options) {
|
|
40708
|
+
const { state, events, sessionMetrics } = options;
|
|
40709
|
+
return {
|
|
40710
|
+
context,
|
|
40711
|
+
state: state ? {
|
|
40712
|
+
isDismissed: (key) => state.dismissals.isDismissed(key),
|
|
40713
|
+
isCooldownActive: (key) => state.cooldowns.isActive(key),
|
|
40714
|
+
getFrequencyCount: (key) => state.frequency.count(key),
|
|
40715
|
+
getSessionMetric: (key) => sessionMetrics?.get(key) ?? 0
|
|
40716
|
+
} : void 0,
|
|
40717
|
+
events: events ? {
|
|
40718
|
+
hasRecentEvent: (eventName, withinMs) => events.hasRecentEvent(eventName, withinMs)
|
|
40719
|
+
} : void 0
|
|
40720
|
+
};
|
|
40721
|
+
}
|
|
40722
|
+
async function evaluate2(strategy, context, options = {}) {
|
|
40723
|
+
const evalContext = createEvaluationContext(context, options);
|
|
40724
|
+
switch (strategy.type) {
|
|
40725
|
+
case "rules":
|
|
40726
|
+
return evaluateRuleStrategy(strategy, evalContext);
|
|
40727
|
+
case "score":
|
|
40728
|
+
return evaluateScoreStrategy(strategy, evalContext);
|
|
40729
|
+
case "model":
|
|
40730
|
+
return {
|
|
40731
|
+
value: strategy.default,
|
|
40732
|
+
isFallback: true,
|
|
40733
|
+
matchInfo: {
|
|
40734
|
+
strategyType: "model"
|
|
40735
|
+
}
|
|
40736
|
+
};
|
|
40737
|
+
case "external":
|
|
40738
|
+
return {
|
|
40739
|
+
value: strategy.default,
|
|
40740
|
+
isFallback: true,
|
|
40741
|
+
matchInfo: {
|
|
40742
|
+
strategyType: "external"
|
|
40743
|
+
}
|
|
40744
|
+
};
|
|
40745
|
+
default:
|
|
40746
|
+
console.warn("[DecisionEngine] Unknown strategy type:", strategy.type);
|
|
40747
|
+
return {
|
|
40748
|
+
value: void 0,
|
|
40749
|
+
isFallback: true,
|
|
40750
|
+
matchInfo: {
|
|
40751
|
+
strategyType: strategy.type
|
|
40752
|
+
}
|
|
40753
|
+
};
|
|
40754
|
+
}
|
|
40755
|
+
}
|
|
40756
|
+
function evaluateSync(strategy, context, options = {}) {
|
|
40757
|
+
const evalContext = createEvaluationContext(context, options);
|
|
40758
|
+
switch (strategy.type) {
|
|
40759
|
+
case "rules":
|
|
40760
|
+
return evaluateRuleStrategy(strategy, evalContext);
|
|
40761
|
+
case "score":
|
|
40762
|
+
return evaluateScoreStrategy(strategy, evalContext);
|
|
40763
|
+
case "model":
|
|
40764
|
+
case "external":
|
|
40765
|
+
return {
|
|
40766
|
+
value: strategy.default,
|
|
40767
|
+
isFallback: true,
|
|
40768
|
+
matchInfo: {
|
|
40769
|
+
strategyType: strategy.type
|
|
40770
|
+
}
|
|
40771
|
+
};
|
|
40772
|
+
default:
|
|
40773
|
+
return {
|
|
40774
|
+
value: void 0,
|
|
40775
|
+
isFallback: true,
|
|
40776
|
+
matchInfo: {
|
|
40777
|
+
strategyType: strategy.type
|
|
40778
|
+
}
|
|
40779
|
+
};
|
|
40780
|
+
}
|
|
40781
|
+
}
|
|
40782
|
+
function createDecisionEngine(options) {
|
|
40783
|
+
return {
|
|
40784
|
+
evaluate: (strategy, context) => evaluate2(strategy, context, options),
|
|
40785
|
+
evaluateSync: (strategy, context) => evaluateSync(strategy, context, options)
|
|
40786
|
+
};
|
|
40787
|
+
}
|
|
40788
|
+
|
|
40789
|
+
// src/runtime.ts
|
|
40790
|
+
var RUNTIME_VERSION = "2.0.0";
|
|
40791
|
+
function matchesRouteFilter(url, filter) {
|
|
40792
|
+
if (!filter) return true;
|
|
40793
|
+
let pathname;
|
|
40794
|
+
try {
|
|
40795
|
+
pathname = new URL(url).pathname;
|
|
40796
|
+
} catch {
|
|
40797
|
+
pathname = url;
|
|
40798
|
+
}
|
|
40799
|
+
const normalizedPath = pathname.replace(/\/$/, "") || "/";
|
|
40800
|
+
if (filter.exclude) {
|
|
40801
|
+
for (const pattern of filter.exclude) {
|
|
40802
|
+
if (matchRoutePattern(normalizedPath, pattern)) {
|
|
40803
|
+
return false;
|
|
40804
|
+
}
|
|
40805
|
+
}
|
|
40806
|
+
}
|
|
40807
|
+
if (filter.include && filter.include.length > 0) {
|
|
40808
|
+
for (const pattern of filter.include) {
|
|
40809
|
+
if (matchRoutePattern(normalizedPath, pattern)) {
|
|
40810
|
+
return true;
|
|
40811
|
+
}
|
|
40812
|
+
}
|
|
40813
|
+
return false;
|
|
40814
|
+
}
|
|
40815
|
+
return true;
|
|
40816
|
+
}
|
|
40817
|
+
function matchRoutePattern(pathname, pattern) {
|
|
40818
|
+
const normalizedPattern = pattern.replace(/\/$/, "") || "/";
|
|
40819
|
+
if (pathname === normalizedPattern) return true;
|
|
40820
|
+
const regexPattern = normalizedPattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/:[^/]+/g, "[^/]+");
|
|
40821
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
40822
|
+
return regex.test(pathname);
|
|
40823
|
+
}
|
|
40824
|
+
function createSmartCanvasRuntime(options = {}) {
|
|
40825
|
+
const { telemetry, sessionMetrics, routes, mode = "production", namespace } = options;
|
|
40826
|
+
const context = createContextManager({
|
|
40827
|
+
telemetry,
|
|
40828
|
+
routes
|
|
40829
|
+
});
|
|
40830
|
+
const events = createEventBus();
|
|
40831
|
+
const state = createStateStore({
|
|
40832
|
+
namespace
|
|
40833
|
+
});
|
|
40834
|
+
const decisionEngine = createDecisionEngine({
|
|
40835
|
+
state,
|
|
40836
|
+
events,
|
|
40837
|
+
sessionMetrics
|
|
40838
|
+
});
|
|
40839
|
+
const runtime = {
|
|
40840
|
+
telemetry,
|
|
40841
|
+
context,
|
|
40842
|
+
events,
|
|
40843
|
+
state,
|
|
40844
|
+
sessionMetrics,
|
|
40845
|
+
version: RUNTIME_VERSION,
|
|
40846
|
+
mode,
|
|
40847
|
+
async evaluate(strategy) {
|
|
40848
|
+
return decisionEngine.evaluate(strategy, context.get());
|
|
40849
|
+
},
|
|
40850
|
+
evaluateSync(strategy) {
|
|
40851
|
+
return decisionEngine.evaluateSync(strategy, context.get());
|
|
40852
|
+
},
|
|
40853
|
+
async filterTiles(tiles) {
|
|
40854
|
+
const currentUrl = context.get().page.url;
|
|
40855
|
+
const results = [];
|
|
40856
|
+
for (const tile of tiles) {
|
|
40857
|
+
const activation = tile.activation;
|
|
40858
|
+
if (!activation) {
|
|
40859
|
+
results.push(tile);
|
|
40860
|
+
continue;
|
|
40861
|
+
}
|
|
40862
|
+
if (!matchesRouteFilter(currentUrl, activation.routes)) {
|
|
40863
|
+
continue;
|
|
40864
|
+
}
|
|
40865
|
+
if (!activation.strategy) {
|
|
40866
|
+
results.push(tile);
|
|
40867
|
+
continue;
|
|
40868
|
+
}
|
|
40869
|
+
const result = await this.evaluate(activation.strategy);
|
|
40870
|
+
if (result.value) {
|
|
40871
|
+
results.push(tile);
|
|
40872
|
+
}
|
|
40873
|
+
}
|
|
40874
|
+
return results;
|
|
40875
|
+
},
|
|
40876
|
+
setRoutes(routes2) {
|
|
40877
|
+
context.setRoutes(routes2);
|
|
40878
|
+
},
|
|
40879
|
+
destroy() {
|
|
40880
|
+
context.destroy();
|
|
40881
|
+
}
|
|
40882
|
+
};
|
|
40883
|
+
return runtime;
|
|
40884
|
+
}
|
|
40885
|
+
|
|
39369
40886
|
// src/token.ts
|
|
39370
40887
|
var TOKEN_PREFIX = "syn_";
|
|
39371
40888
|
function decodeToken(token) {
|
|
@@ -39604,12 +41121,12 @@ var SyntrologieSDK = (() => {
|
|
|
39604
41121
|
}
|
|
39605
41122
|
function isEditorMode() {
|
|
39606
41123
|
if (typeof window === "undefined") {
|
|
39607
|
-
|
|
41124
|
+
debug("Syntro Bootstrap", "isEditorMode: not in browser");
|
|
39608
41125
|
return false;
|
|
39609
41126
|
}
|
|
39610
41127
|
const params = new URLSearchParams(window.location.search);
|
|
39611
41128
|
const hasToken = params.has("editor_token");
|
|
39612
|
-
|
|
41129
|
+
debug("Syntro Bootstrap", "isEditorMode check:", {
|
|
39613
41130
|
url: window.location.href,
|
|
39614
41131
|
search: window.location.search,
|
|
39615
41132
|
hasEditorToken: hasToken,
|
|
@@ -39617,6 +41134,20 @@ var SyntrologieSDK = (() => {
|
|
|
39617
41134
|
});
|
|
39618
41135
|
return hasToken;
|
|
39619
41136
|
}
|
|
41137
|
+
function isAuditMode3() {
|
|
41138
|
+
if (typeof window === "undefined") {
|
|
41139
|
+
debug("Syntro Bootstrap", "isAuditMode: not in browser");
|
|
41140
|
+
return false;
|
|
41141
|
+
}
|
|
41142
|
+
const params = new URLSearchParams(window.location.search);
|
|
41143
|
+
const hasAuditFlag = params.has("syntro_audit");
|
|
41144
|
+
debug("Syntro Bootstrap", "isAuditMode check:", {
|
|
41145
|
+
url: window.location.href,
|
|
41146
|
+
hasAuditFlag,
|
|
41147
|
+
auditSessionId: params.get("audit_session_id") ?? "none"
|
|
41148
|
+
});
|
|
41149
|
+
return hasAuditFlag;
|
|
41150
|
+
}
|
|
39620
41151
|
var SEGMENT_CACHE_KEY = "syntro_segment_attributes";
|
|
39621
41152
|
function loadCachedSegmentAttributes() {
|
|
39622
41153
|
if (typeof window === "undefined") return {};
|
|
@@ -39624,11 +41155,11 @@ var SyntrologieSDK = (() => {
|
|
|
39624
41155
|
const cached = localStorage.getItem(SEGMENT_CACHE_KEY);
|
|
39625
41156
|
if (cached) {
|
|
39626
41157
|
const attrs = JSON.parse(cached);
|
|
39627
|
-
|
|
41158
|
+
debug("Syntro Bootstrap", "Loaded cached segment attributes:", attrs);
|
|
39628
41159
|
return attrs;
|
|
39629
41160
|
}
|
|
39630
41161
|
} catch (err) {
|
|
39631
|
-
|
|
41162
|
+
warn("Syntro Bootstrap", "Failed to load cached segment attributes:", err);
|
|
39632
41163
|
}
|
|
39633
41164
|
return {};
|
|
39634
41165
|
}
|
|
@@ -39636,9 +41167,9 @@ var SyntrologieSDK = (() => {
|
|
|
39636
41167
|
if (typeof window === "undefined") return;
|
|
39637
41168
|
try {
|
|
39638
41169
|
localStorage.setItem(SEGMENT_CACHE_KEY, JSON.stringify(attrs));
|
|
39639
|
-
|
|
41170
|
+
debug("Syntro Bootstrap", "Cached segment attributes:", attrs);
|
|
39640
41171
|
} catch (err) {
|
|
39641
|
-
|
|
41172
|
+
warn("Syntro Bootstrap", "Failed to cache segment attributes:", err);
|
|
39642
41173
|
}
|
|
39643
41174
|
}
|
|
39644
41175
|
function extractSegmentFlags(allFlags) {
|
|
@@ -39652,47 +41183,51 @@ var SyntrologieSDK = (() => {
|
|
|
39652
41183
|
return segmentFlags;
|
|
39653
41184
|
}
|
|
39654
41185
|
async function init(options) {
|
|
39655
|
-
|
|
39656
|
-
|
|
41186
|
+
initLogger();
|
|
41187
|
+
debug("Syntro Bootstrap", "====== INIT ======");
|
|
41188
|
+
debug("Syntro Bootstrap", "Options:", {
|
|
39657
41189
|
hasToken: !!options.token,
|
|
39658
41190
|
tokenPrefix: options.token?.slice(0, 15) + "...",
|
|
39659
41191
|
hasCanvasOptions: !!options.canvas
|
|
39660
41192
|
});
|
|
39661
41193
|
const editorMode = isEditorMode();
|
|
39662
|
-
|
|
41194
|
+
const auditMode = isAuditMode3();
|
|
41195
|
+
const sdkMode = editorMode ? "editor" : auditMode ? "audit" : null;
|
|
41196
|
+
debug("Syntro Bootstrap", "SDK mode:", sdkMode ?? "normal");
|
|
39663
41197
|
let payload;
|
|
39664
41198
|
if (options.token) {
|
|
39665
41199
|
if (options.token.startsWith("syn_")) {
|
|
39666
|
-
|
|
41200
|
+
debug("Syntro Bootstrap", "Token starts with syn_, decoding...");
|
|
39667
41201
|
payload = decodeToken(options.token);
|
|
39668
|
-
|
|
39669
|
-
|
|
39670
|
-
|
|
41202
|
+
initLogger(payload.d);
|
|
41203
|
+
} else if (!sdkMode) {
|
|
41204
|
+
error("Syntro Bootstrap", "\u274C Token does not start with syn_ and NOT in editor/audit mode!");
|
|
41205
|
+
error("Syntro Bootstrap", "Token received:", options.token);
|
|
39671
41206
|
throw new Error("Invalid Syntro token: must start with 'syn_'");
|
|
39672
41207
|
} else {
|
|
39673
|
-
|
|
41208
|
+
debug("Syntro Bootstrap", `\u2713 Non-syn_ token allowed (${sdkMode} mode)`);
|
|
39674
41209
|
}
|
|
39675
|
-
} else if (!
|
|
39676
|
-
|
|
39677
|
-
throw new Error("Syntro token is required (unless in editor mode)");
|
|
41210
|
+
} else if (!sdkMode) {
|
|
41211
|
+
error("Syntro Bootstrap", "\u274C No token provided and NOT in editor/audit mode!");
|
|
41212
|
+
throw new Error("Syntro token is required (unless in editor or audit mode)");
|
|
39678
41213
|
} else {
|
|
39679
|
-
|
|
41214
|
+
debug("Syntro Bootstrap", `\u2713 No token, but ${sdkMode} mode - proceeding`);
|
|
39680
41215
|
}
|
|
39681
41216
|
const experimentHost = getEnvVar("NEXT_PUBLIC_SYNTRO_EXPERIMENT_HOST") || getEnvVar("VITE_SYNTRO_EXPERIMENT_HOST") || payload?.eh;
|
|
39682
41217
|
const telemetryHost = getEnvVar("NEXT_PUBLIC_SYNTRO_TELEMETRY_HOST") || getEnvVar("VITE_SYNTRO_TELEMETRY_HOST") || payload?.th;
|
|
39683
41218
|
const editorUrl = getEnvVar("NEXT_PUBLIC_SYNTRO_EDITOR_URL") || getEnvVar("VITE_SYNTRO_EDITOR_URL") || options.canvas?.editorUrl;
|
|
39684
41219
|
const cachedSegmentAttrs = loadCachedSegmentAttributes();
|
|
39685
|
-
|
|
41220
|
+
debug("Syntro Bootstrap", "Phase 1: Using cached segment attributes:", cachedSegmentAttrs);
|
|
39686
41221
|
let experiments;
|
|
39687
41222
|
const onFeatureFlagsLoaded = (allFlags) => {
|
|
39688
|
-
|
|
41223
|
+
debug("Syntro Bootstrap", "Phase 2: PostHog feature flags loaded");
|
|
39689
41224
|
const segmentFlags = extractSegmentFlags(allFlags);
|
|
39690
|
-
|
|
41225
|
+
debug("Syntro Bootstrap", "Segment flags from PostHog:", segmentFlags);
|
|
39691
41226
|
cacheSegmentAttributes(segmentFlags);
|
|
39692
41227
|
if (experiments) {
|
|
39693
41228
|
const sessionAttrs = sessionMetrics?.getAll?.() ?? {};
|
|
39694
41229
|
const updatedAttrs = { ...sessionAttrs, ...segmentFlags };
|
|
39695
|
-
|
|
41230
|
+
debug("Syntro Bootstrap", "Updating GrowthBook with attributes:", updatedAttrs);
|
|
39696
41231
|
experiments.setAttributes?.(updatedAttrs);
|
|
39697
41232
|
}
|
|
39698
41233
|
};
|
|
@@ -39741,10 +41276,10 @@ var SyntrologieSDK = (() => {
|
|
|
39741
41276
|
sessionMetrics = createSessionMetricTracker({
|
|
39742
41277
|
experiments,
|
|
39743
41278
|
onMetricChange: (key, value) => {
|
|
39744
|
-
|
|
41279
|
+
debug("Syntro Bootstrap", `Session metric changed: ${key} = ${value}`);
|
|
39745
41280
|
}
|
|
39746
41281
|
});
|
|
39747
|
-
|
|
41282
|
+
debug("Syntro Bootstrap", "SessionMetricTracker created");
|
|
39748
41283
|
}
|
|
39749
41284
|
const canvas = await createSmartCanvas({
|
|
39750
41285
|
...options.canvas,
|
|
@@ -39752,7 +41287,23 @@ var SyntrologieSDK = (() => {
|
|
|
39752
41287
|
integrations: { experiments, telemetry },
|
|
39753
41288
|
editorUrl
|
|
39754
41289
|
});
|
|
39755
|
-
|
|
41290
|
+
let runtimeMode = "production";
|
|
41291
|
+
if (editorMode) runtimeMode = "editor";
|
|
41292
|
+
else if (auditMode) runtimeMode = "audit";
|
|
41293
|
+
else if (getEnvVar("NODE_ENV") === "development") runtimeMode = "development";
|
|
41294
|
+
const runtime = createSmartCanvasRuntime({
|
|
41295
|
+
telemetry,
|
|
41296
|
+
sessionMetrics,
|
|
41297
|
+
mode: runtimeMode
|
|
41298
|
+
});
|
|
41299
|
+
debug("Syntro Bootstrap", "Runtime created:", {
|
|
41300
|
+
version: runtime.version,
|
|
41301
|
+
mode: runtime.mode,
|
|
41302
|
+
hasContext: !!runtime.context,
|
|
41303
|
+
hasEvents: !!runtime.events,
|
|
41304
|
+
hasState: !!runtime.state
|
|
41305
|
+
});
|
|
41306
|
+
return { canvas, runtime, experiments, telemetry, sessionMetrics };
|
|
39756
41307
|
}
|
|
39757
41308
|
var Syntro = {
|
|
39758
41309
|
init,
|
|
@@ -39821,4 +41372,5 @@ react-dom/cjs/react-dom-client.development.js:
|
|
|
39821
41372
|
* LICENSE file in the root directory of this source tree.
|
|
39822
41373
|
*)
|
|
39823
41374
|
*/
|
|
41375
|
+
window.Syntro=SyntrologieSDK.Syntro;
|
|
39824
41376
|
//# sourceMappingURL=smart-canvas.js.map
|