@syntrologie/runtime-sdk 2.5.1 → 2.6.0-canary.2

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.
@@ -19285,7 +19285,7 @@ var SyntrologieSDK = (() => {
19285
19285
  }
19286
19286
 
19287
19287
  // src/version.ts
19288
- var SDK_VERSION = "2.5.1";
19288
+ var SDK_VERSION = "2.6.0-canary.2";
19289
19289
 
19290
19290
  // src/types.ts
19291
19291
  var SDK_SCHEMA_VERSION = "2.0";
@@ -36651,7 +36651,7 @@ ${cssRules}
36651
36651
  return regex.test(normalizedPath);
36652
36652
  }
36653
36653
  var ContextManager = class {
36654
- constructor(options = {}) {
36654
+ constructor(options) {
36655
36655
  __publicField(this, "context");
36656
36656
  __publicField(this, "previousContext");
36657
36657
  __publicField(this, "listeners", /* @__PURE__ */ new Set());
@@ -36743,30 +36743,8 @@ ${cssRules}
36743
36743
  };
36744
36744
  window.addEventListener("resize", handleResize);
36745
36745
  this.cleanupFns.push(() => window.removeEventListener("resize", handleResize));
36746
- if (this.navigation) {
36747
- const unsub = this.navigation.subscribe(() => this.updatePage());
36748
- this.cleanupFns.push(unsub);
36749
- } else {
36750
- const handlePopState = () => {
36751
- this.updatePage();
36752
- };
36753
- window.addEventListener("popstate", handlePopState);
36754
- this.cleanupFns.push(() => window.removeEventListener("popstate", handlePopState));
36755
- const originalPushState = history.pushState.bind(history);
36756
- const originalReplaceState = history.replaceState.bind(history);
36757
- history.pushState = (...args) => {
36758
- originalPushState(...args);
36759
- queueMicrotask(() => this.updatePage());
36760
- };
36761
- history.replaceState = (...args) => {
36762
- originalReplaceState(...args);
36763
- queueMicrotask(() => this.updatePage());
36764
- };
36765
- this.cleanupFns.push(() => {
36766
- history.pushState = originalPushState;
36767
- history.replaceState = originalReplaceState;
36768
- });
36769
- }
36746
+ const unsub = this.navigation.subscribe(() => this.updatePage());
36747
+ this.cleanupFns.push(unsub);
36770
36748
  }
36771
36749
  updateViewport() {
36772
36750
  const newViewport = {
@@ -36822,7 +36800,7 @@ ${cssRules}
36822
36800
  }
36823
36801
  }
36824
36802
  };
36825
- function createContextManager(options = {}) {
36803
+ function createContextManager(options) {
36826
36804
  return new ContextManager(options);
36827
36805
  }
36828
36806
 
@@ -36907,8 +36885,9 @@ ${cssRules}
36907
36885
  return events.hasRecentEvent(condition.eventName, withinMs);
36908
36886
  }
36909
36887
  case "state_equals": {
36910
- if (!state) return false;
36911
- return false;
36888
+ if (!state?.getValue) return false;
36889
+ const actual = state.getValue(condition.key);
36890
+ return actual === condition.value;
36912
36891
  }
36913
36892
  case "viewport": {
36914
36893
  const { width, height } = context.viewport;
@@ -37045,7 +37024,8 @@ ${cssRules}
37045
37024
  isDismissed: (key) => state.dismissals.isDismissed(key),
37046
37025
  isCooldownActive: (key) => state.cooldowns.isActive(key),
37047
37026
  getFrequencyCount: (key) => state.frequency.count(key),
37048
- getSessionMetric: (key) => sessionMetrics?.get(key) ?? 0
37027
+ getSessionMetric: (key) => sessionMetrics?.get(key) ?? 0,
37028
+ getValue: (key) => state.session.get(key) ?? state.user.get(key)
37049
37029
  } : void 0,
37050
37030
  events: events ? {
37051
37031
  hasRecentEvent: (eventName, withinMs) => events.hasRecentEvent(eventName, withinMs)
@@ -38625,6 +38605,22 @@ ${cssRules}
38625
38605
  accumulator
38626
38606
  }
38627
38607
  });
38608
+ let unsubPageViews;
38609
+ if (sessionMetrics) {
38610
+ sessionMetrics.increment("page_views");
38611
+ let lastCountedPath = typeof window !== "undefined" ? window.location.pathname : "/";
38612
+ unsubPageViews = navigation2.subscribe((url, method) => {
38613
+ if (method === "replaceState") return;
38614
+ try {
38615
+ const newPath = new URL(url).pathname;
38616
+ if (newPath !== lastCountedPath) {
38617
+ lastCountedPath = newPath;
38618
+ sessionMetrics.increment("page_views");
38619
+ }
38620
+ } catch {
38621
+ }
38622
+ });
38623
+ }
38628
38624
  const runtime7 = {
38629
38625
  telemetry,
38630
38626
  context,
@@ -38683,6 +38679,7 @@ ${cssRules}
38683
38679
  apps.unbind().catch((err) => {
38684
38680
  console.error("[Runtime] Error unbinding apps registry:", err);
38685
38681
  });
38682
+ unsubPageViews?.();
38686
38683
  anchorResolverService.destroy();
38687
38684
  accumulator.destroy();
38688
38685
  navigation2.destroy();
@@ -39174,15 +39171,13 @@ ${cssRules}
39174
39171
  } : void 0
39175
39172
  });
39176
39173
  }
39177
- if (options.enableSessionMetrics) {
39178
- sessionMetrics = createSessionMetricTracker({
39179
- experiments,
39180
- onMetricChange: (key, value) => {
39181
- debug("Syntro Bootstrap", `Session metric changed: ${key} = ${value}`);
39182
- }
39183
- });
39184
- debug("Syntro Bootstrap", "SessionMetricTracker created");
39185
- }
39174
+ sessionMetrics = createSessionMetricTracker({
39175
+ experiments,
39176
+ onMetricChange: (key, value) => {
39177
+ debug("Syntro Bootstrap", `Session metric changed: ${key} = ${value}`);
39178
+ }
39179
+ });
39180
+ debug("Syntro Bootstrap", "SessionMetricTracker created");
39186
39181
  let runtimeMode = "production";
39187
39182
  if (editorMode) runtimeMode = "editor";
39188
39183
  else if (auditMode) runtimeMode = "audit";
@@ -39349,7 +39344,7 @@ ${cssRules}
39349
39344
  }
39350
39345
 
39351
39346
  // src/index.ts
39352
- var RUNTIME_SDK_BUILD = true ? `${"2026-03-04T23:42:52.228Z"} (${"90cd96b60c"})` : "dev";
39347
+ var RUNTIME_SDK_BUILD = true ? `${"2026-03-05T16:08:37.839Z"} (${"0c8e316295"})` : "dev";
39353
39348
  if (typeof window !== "undefined") {
39354
39349
  console.log(`[Syntro Runtime] Build: ${RUNTIME_SDK_BUILD}`);
39355
39350
  const existing = window.SynOS;