@uniformdev/canvas-next-rsc-client 19.135.0 → 19.135.1-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -25,9 +25,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
 
28
- // ../../node_modules/.pnpm/rfdc@1.3.1/node_modules/rfdc/index.js
28
+ // ../../node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js
29
29
  var require_rfdc = __commonJS({
30
- "../../node_modules/.pnpm/rfdc@1.3.1/node_modules/rfdc/index.js"(exports, module) {
30
+ "../../node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js"(exports, module) {
31
31
  "use strict";
32
32
  module.exports = rfdc4;
33
33
  function copyBuffer(cur) {
@@ -38,19 +38,28 @@ var require_rfdc = __commonJS({
38
38
  }
39
39
  function rfdc4(opts) {
40
40
  opts = opts || {};
41
- if (opts.circles)
42
- return rfdcCircles(opts);
41
+ if (opts.circles) return rfdcCircles(opts);
42
+ const constructorHandlers = /* @__PURE__ */ new Map();
43
+ constructorHandlers.set(Date, (o) => new Date(o));
44
+ constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
45
+ constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
46
+ if (opts.constructorHandlers) {
47
+ for (const handler2 of opts.constructorHandlers) {
48
+ constructorHandlers.set(handler2[0], handler2[1]);
49
+ }
50
+ }
51
+ let handler = null;
43
52
  return opts.proto ? cloneProto : clone2;
44
53
  function cloneArray(a, fn) {
45
- var keys = Object.keys(a);
46
- var a2 = new Array(keys.length);
47
- for (var i = 0; i < keys.length; i++) {
48
- var k = keys[i];
49
- var cur = a[k];
54
+ const keys = Object.keys(a);
55
+ const a2 = new Array(keys.length);
56
+ for (let i = 0; i < keys.length; i++) {
57
+ const k = keys[i];
58
+ const cur = a[k];
50
59
  if (typeof cur !== "object" || cur === null) {
51
60
  a2[k] = cur;
52
- } else if (cur instanceof Date) {
53
- a2[k] = new Date(cur);
61
+ } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
62
+ a2[k] = handler(cur, fn);
54
63
  } else if (ArrayBuffer.isView(cur)) {
55
64
  a2[k] = copyBuffer(cur);
56
65
  } else {
@@ -60,29 +69,19 @@ var require_rfdc = __commonJS({
60
69
  return a2;
61
70
  }
62
71
  function clone2(o) {
63
- if (typeof o !== "object" || o === null)
64
- return o;
65
- if (o instanceof Date)
66
- return new Date(o);
67
- if (Array.isArray(o))
68
- return cloneArray(o, clone2);
69
- if (o instanceof Map)
70
- return new Map(cloneArray(Array.from(o), clone2));
71
- if (o instanceof Set)
72
- return new Set(cloneArray(Array.from(o), clone2));
73
- var o2 = {};
74
- for (var k in o) {
75
- if (Object.hasOwnProperty.call(o, k) === false)
76
- continue;
77
- var cur = o[k];
72
+ if (typeof o !== "object" || o === null) return o;
73
+ if (Array.isArray(o)) return cloneArray(o, clone2);
74
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
75
+ return handler(o, clone2);
76
+ }
77
+ const o2 = {};
78
+ for (const k in o) {
79
+ if (Object.hasOwnProperty.call(o, k) === false) continue;
80
+ const cur = o[k];
78
81
  if (typeof cur !== "object" || cur === null) {
79
82
  o2[k] = cur;
80
- } else if (cur instanceof Date) {
81
- o2[k] = new Date(cur);
82
- } else if (cur instanceof Map) {
83
- o2[k] = new Map(cloneArray(Array.from(cur), clone2));
84
- } else if (cur instanceof Set) {
85
- o2[k] = new Set(cloneArray(Array.from(cur), clone2));
83
+ } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
84
+ o2[k] = handler(cur, clone2);
86
85
  } else if (ArrayBuffer.isView(cur)) {
87
86
  o2[k] = copyBuffer(cur);
88
87
  } else {
@@ -92,27 +91,18 @@ var require_rfdc = __commonJS({
92
91
  return o2;
93
92
  }
94
93
  function cloneProto(o) {
95
- if (typeof o !== "object" || o === null)
96
- return o;
97
- if (o instanceof Date)
98
- return new Date(o);
99
- if (Array.isArray(o))
100
- return cloneArray(o, cloneProto);
101
- if (o instanceof Map)
102
- return new Map(cloneArray(Array.from(o), cloneProto));
103
- if (o instanceof Set)
104
- return new Set(cloneArray(Array.from(o), cloneProto));
105
- var o2 = {};
106
- for (var k in o) {
107
- var cur = o[k];
94
+ if (typeof o !== "object" || o === null) return o;
95
+ if (Array.isArray(o)) return cloneArray(o, cloneProto);
96
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
97
+ return handler(o, cloneProto);
98
+ }
99
+ const o2 = {};
100
+ for (const k in o) {
101
+ const cur = o[k];
108
102
  if (typeof cur !== "object" || cur === null) {
109
103
  o2[k] = cur;
110
- } else if (cur instanceof Date) {
111
- o2[k] = new Date(cur);
112
- } else if (cur instanceof Map) {
113
- o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
114
- } else if (cur instanceof Set) {
115
- o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
104
+ } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
105
+ o2[k] = handler(cur, cloneProto);
116
106
  } else if (ArrayBuffer.isView(cur)) {
117
107
  o2[k] = copyBuffer(cur);
118
108
  } else {
@@ -123,23 +113,33 @@ var require_rfdc = __commonJS({
123
113
  }
124
114
  }
125
115
  function rfdcCircles(opts) {
126
- var refs = [];
127
- var refsNew = [];
116
+ const refs = [];
117
+ const refsNew = [];
118
+ const constructorHandlers = /* @__PURE__ */ new Map();
119
+ constructorHandlers.set(Date, (o) => new Date(o));
120
+ constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
121
+ constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
122
+ if (opts.constructorHandlers) {
123
+ for (const handler2 of opts.constructorHandlers) {
124
+ constructorHandlers.set(handler2[0], handler2[1]);
125
+ }
126
+ }
127
+ let handler = null;
128
128
  return opts.proto ? cloneProto : clone2;
129
129
  function cloneArray(a, fn) {
130
- var keys = Object.keys(a);
131
- var a2 = new Array(keys.length);
132
- for (var i = 0; i < keys.length; i++) {
133
- var k = keys[i];
134
- var cur = a[k];
130
+ const keys = Object.keys(a);
131
+ const a2 = new Array(keys.length);
132
+ for (let i = 0; i < keys.length; i++) {
133
+ const k = keys[i];
134
+ const cur = a[k];
135
135
  if (typeof cur !== "object" || cur === null) {
136
136
  a2[k] = cur;
137
- } else if (cur instanceof Date) {
138
- a2[k] = new Date(cur);
137
+ } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
138
+ a2[k] = handler(cur, fn);
139
139
  } else if (ArrayBuffer.isView(cur)) {
140
140
  a2[k] = copyBuffer(cur);
141
141
  } else {
142
- var index = refs.indexOf(cur);
142
+ const index = refs.indexOf(cur);
143
143
  if (index !== -1) {
144
144
  a2[k] = refsNew[index];
145
145
  } else {
@@ -150,35 +150,25 @@ var require_rfdc = __commonJS({
150
150
  return a2;
151
151
  }
152
152
  function clone2(o) {
153
- if (typeof o !== "object" || o === null)
154
- return o;
155
- if (o instanceof Date)
156
- return new Date(o);
157
- if (Array.isArray(o))
158
- return cloneArray(o, clone2);
159
- if (o instanceof Map)
160
- return new Map(cloneArray(Array.from(o), clone2));
161
- if (o instanceof Set)
162
- return new Set(cloneArray(Array.from(o), clone2));
163
- var o2 = {};
153
+ if (typeof o !== "object" || o === null) return o;
154
+ if (Array.isArray(o)) return cloneArray(o, clone2);
155
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
156
+ return handler(o, clone2);
157
+ }
158
+ const o2 = {};
164
159
  refs.push(o);
165
160
  refsNew.push(o2);
166
- for (var k in o) {
167
- if (Object.hasOwnProperty.call(o, k) === false)
168
- continue;
169
- var cur = o[k];
161
+ for (const k in o) {
162
+ if (Object.hasOwnProperty.call(o, k) === false) continue;
163
+ const cur = o[k];
170
164
  if (typeof cur !== "object" || cur === null) {
171
165
  o2[k] = cur;
172
- } else if (cur instanceof Date) {
173
- o2[k] = new Date(cur);
174
- } else if (cur instanceof Map) {
175
- o2[k] = new Map(cloneArray(Array.from(cur), clone2));
176
- } else if (cur instanceof Set) {
177
- o2[k] = new Set(cloneArray(Array.from(cur), clone2));
166
+ } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
167
+ o2[k] = handler(cur, clone2);
178
168
  } else if (ArrayBuffer.isView(cur)) {
179
169
  o2[k] = copyBuffer(cur);
180
170
  } else {
181
- var i = refs.indexOf(cur);
171
+ const i = refs.indexOf(cur);
182
172
  if (i !== -1) {
183
173
  o2[k] = refsNew[i];
184
174
  } else {
@@ -191,33 +181,24 @@ var require_rfdc = __commonJS({
191
181
  return o2;
192
182
  }
193
183
  function cloneProto(o) {
194
- if (typeof o !== "object" || o === null)
195
- return o;
196
- if (o instanceof Date)
197
- return new Date(o);
198
- if (Array.isArray(o))
199
- return cloneArray(o, cloneProto);
200
- if (o instanceof Map)
201
- return new Map(cloneArray(Array.from(o), cloneProto));
202
- if (o instanceof Set)
203
- return new Set(cloneArray(Array.from(o), cloneProto));
204
- var o2 = {};
184
+ if (typeof o !== "object" || o === null) return o;
185
+ if (Array.isArray(o)) return cloneArray(o, cloneProto);
186
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
187
+ return handler(o, cloneProto);
188
+ }
189
+ const o2 = {};
205
190
  refs.push(o);
206
191
  refsNew.push(o2);
207
- for (var k in o) {
208
- var cur = o[k];
192
+ for (const k in o) {
193
+ const cur = o[k];
209
194
  if (typeof cur !== "object" || cur === null) {
210
195
  o2[k] = cur;
211
- } else if (cur instanceof Date) {
212
- o2[k] = new Date(cur);
213
- } else if (cur instanceof Map) {
214
- o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
215
- } else if (cur instanceof Set) {
216
- o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
196
+ } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {
197
+ o2[k] = handler(cur, cloneProto);
217
198
  } else if (ArrayBuffer.isView(cur)) {
218
199
  o2[k] = copyBuffer(cur);
219
200
  } else {
220
- var i = refs.indexOf(cur);
201
+ const i = refs.indexOf(cur);
221
202
  if (i !== -1) {
222
203
  o2[k] = refsNew[i];
223
204
  } else {
@@ -361,27 +342,21 @@ var ContextUpdateTransferClient = ({
361
342
  var has = Object.prototype.hasOwnProperty;
362
343
  function dequal(foo, bar) {
363
344
  var ctor, len;
364
- if (foo === bar)
365
- return true;
345
+ if (foo === bar) return true;
366
346
  if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
367
- if (ctor === Date)
368
- return foo.getTime() === bar.getTime();
369
- if (ctor === RegExp)
370
- return foo.toString() === bar.toString();
347
+ if (ctor === Date) return foo.getTime() === bar.getTime();
348
+ if (ctor === RegExp) return foo.toString() === bar.toString();
371
349
  if (ctor === Array) {
372
350
  if ((len = foo.length) === bar.length) {
373
- while (len-- && dequal(foo[len], bar[len]))
374
- ;
351
+ while (len-- && dequal(foo[len], bar[len])) ;
375
352
  }
376
353
  return len === -1;
377
354
  }
378
355
  if (!ctor || typeof foo === "object") {
379
356
  len = 0;
380
357
  for (ctor in foo) {
381
- if (has.call(foo, ctor) && ++len && !has.call(bar, ctor))
382
- return false;
383
- if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor]))
384
- return false;
358
+ if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
359
+ if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
385
360
  }
386
361
  return Object.keys(bar).length === len;
387
362
  }
@@ -491,33 +466,27 @@ var api = init(defaultConverter, { path: "/" });
491
466
  var import_rfdc = __toESM(require_rfdc(), 1);
492
467
  var import_rfdc2 = __toESM(require_rfdc(), 1);
493
468
  var import_rfdc3 = __toESM(require_rfdc(), 1);
494
- var __accessCheck = (obj, member, msg) => {
495
- if (!member.has(obj))
496
- throw TypeError("Cannot " + msg);
497
- };
498
- var __privateGet = (obj, member, getter) => {
499
- __accessCheck(obj, member, "read from private field");
500
- return getter ? getter.call(obj) : member.get(obj);
501
- };
502
- var __privateSet = (obj, member, value, setter) => {
503
- __accessCheck(obj, member, "write to private field");
504
- setter ? setter.call(obj, value) : member.set(obj, value);
505
- return value;
506
- };
507
- var __privateMethod = (obj, member, method) => {
508
- __accessCheck(obj, member, "access private method");
509
- return method;
469
+ var __typeError = (msg) => {
470
+ throw TypeError(msg);
510
471
  };
472
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
473
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
474
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
475
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
511
476
  var ENR_SEPARATOR = "_";
477
+ var _id;
478
+ _id = /* @__PURE__ */ new WeakMap();
512
479
  var _evaluator;
513
480
  var _onLogMessage;
514
481
  _evaluator = /* @__PURE__ */ new WeakMap();
515
482
  _onLogMessage = /* @__PURE__ */ new WeakMap();
516
483
  var _mf;
517
484
  var _signalInstances;
485
+ var _goalEvaluators;
518
486
  var _onLogMessage2;
519
487
  _mf = /* @__PURE__ */ new WeakMap();
520
488
  _signalInstances = /* @__PURE__ */ new WeakMap();
489
+ _goalEvaluators = /* @__PURE__ */ new WeakMap();
521
490
  _onLogMessage2 = /* @__PURE__ */ new WeakMap();
522
491
  function getEnrichmentVectorKey(category, value) {
523
492
  return `${category}${ENR_SEPARATOR}${value}`;
@@ -604,9 +573,9 @@ var _cookieName;
604
573
  var _cookieAttributes;
605
574
  _cookieName = /* @__PURE__ */ new WeakMap();
606
575
  _cookieAttributes = /* @__PURE__ */ new WeakMap();
607
- var _fetchData;
576
+ var _EdgeTransitionDataStore_instances;
608
577
  var fetchData_fn;
609
- _fetchData = /* @__PURE__ */ new WeakSet();
578
+ _EdgeTransitionDataStore_instances = /* @__PURE__ */ new WeakSet();
610
579
  fetchData_fn = async function() {
611
580
  const serviceData = await new Promise((resolve) => {
612
581
  setTimeout(() => {
@@ -622,64 +591,61 @@ var emptyVisitorData = () => ({
622
591
  scores: {},
623
592
  sessionScores: {},
624
593
  tests: {},
594
+ goals: {},
625
595
  consent: false,
626
596
  controlGroup: false,
627
597
  personalizeVariants: {}
628
598
  });
629
599
  var clone = (0, import_rfdc.default)();
600
+ var _LocalStorage_instances;
601
+ var key_fn;
602
+ _LocalStorage_instances = /* @__PURE__ */ new WeakSet();
603
+ key_fn = function(key) {
604
+ return this.partitionKey ? `${this.partitionKey}.${key}` : key;
605
+ };
630
606
  var STORAGE_KEY = "ufvisitor";
631
607
  var _mitt2;
632
608
  var _persist;
633
609
  var _visitTimeout;
634
610
  var _options;
635
- var _currentData;
611
+ var _VisitorDataStore_instances;
636
612
  var currentData_get;
637
- var _replaceData;
638
613
  var replaceData_fn;
639
- var _setVisitTimeout;
640
614
  var setVisitTimeout_fn;
641
- var _isExpired;
642
615
  var isExpired_fn;
643
- var _handleCaps;
644
616
  var handleCaps_fn;
645
- var _defaultData;
646
617
  var defaultData_fn;
647
618
  _mitt2 = /* @__PURE__ */ new WeakMap();
648
619
  _persist = /* @__PURE__ */ new WeakMap();
649
620
  _visitTimeout = /* @__PURE__ */ new WeakMap();
650
621
  _options = /* @__PURE__ */ new WeakMap();
651
- _currentData = /* @__PURE__ */ new WeakSet();
622
+ _VisitorDataStore_instances = /* @__PURE__ */ new WeakSet();
652
623
  currentData_get = function() {
653
624
  return __privateGet(this, _persist).get(STORAGE_KEY);
654
625
  };
655
- _replaceData = /* @__PURE__ */ new WeakSet();
656
626
  replaceData_fn = function(data, quiet = false) {
657
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
658
- const oldData = __privateGet(this, _currentData, currentData_get);
627
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
628
+ const oldData = __privateGet(this, _VisitorDataStore_instances, currentData_get);
659
629
  const now = Date.now();
660
- if (data.controlGroup) {
661
- data.scores = {};
662
- data.sessionScores = {};
663
- } else {
664
- __privateMethod(this, _handleCaps, handleCaps_fn).call(this, data.scores);
665
- __privateMethod(this, _handleCaps, handleCaps_fn).call(this, data.sessionScores);
666
- (_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
667
- now,
668
- lastUpd: oldData == null ? void 0 : oldData.updated,
669
- scores: data.scores,
670
- sessionScores: data.sessionScores,
671
- onLogMessage: __privateGet(this, _options).onLogMessage
672
- });
673
- }
630
+ __privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.scores);
631
+ __privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.sessionScores);
632
+ (_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
633
+ now,
634
+ lastUpd: oldData == null ? void 0 : oldData.updated,
635
+ scores: data.scores,
636
+ sessionScores: data.sessionScores,
637
+ onLogMessage: __privateGet(this, _options).onLogMessage
638
+ });
674
639
  const haveScoresChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
675
640
  const haveSessionScoresChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
676
641
  const haveQuirksChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
677
642
  const haveTestsChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.tests, data.tests);
643
+ const haveGoalsChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.goals, data.goals);
678
644
  const updatedData = {
679
645
  updated: now,
680
646
  visitorData: data
681
647
  };
682
- __privateMethod(this, _setVisitTimeout, setVisitTimeout_fn).call(this);
648
+ __privateMethod(this, _VisitorDataStore_instances, setVisitTimeout_fn).call(this);
683
649
  __privateGet(this, _persist).set(STORAGE_KEY, updatedData, !!data.consent);
684
650
  (_d = (_c = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _d.call(_c, ["debug", 102, data]);
685
651
  if (!quiet) {
@@ -699,9 +665,17 @@ replaceData_fn = function(data, quiet = false) {
699
665
  __privateGet(this, _mitt2).emit("controlGroupUpdated", data);
700
666
  (_i = (_h = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _i.call(_h, ["debug", 104, (_g = data.controlGroup) != null ? _g : false]);
701
667
  }
668
+ if (haveGoalsChanged) {
669
+ const newGoalKeys = Object.keys((_j = data.goals) != null ? _j : {});
670
+ for (let i = 0; i < newGoalKeys.length; i++) {
671
+ const key = newGoalKeys[i];
672
+ if (!((_k = oldData == null ? void 0 : oldData.visitorData.goals) == null ? void 0 : _k[key])) {
673
+ __privateGet(this, _mitt2).emit("goalConverted", { goalId: key });
674
+ }
675
+ }
676
+ }
702
677
  }
703
678
  };
704
- _setVisitTimeout = /* @__PURE__ */ new WeakSet();
705
679
  setVisitTimeout_fn = function() {
706
680
  if (typeof document === "undefined" || !__privateGet(this, _options).visitLifespan) {
707
681
  return;
@@ -713,12 +687,10 @@ setVisitTimeout_fn = function() {
713
687
  this.data;
714
688
  }, __privateGet(this, _options).visitLifespan + 50));
715
689
  };
716
- _isExpired = /* @__PURE__ */ new WeakSet();
717
690
  isExpired_fn = function(data) {
718
691
  const expires = __privateGet(this, _options).visitLifespan;
719
692
  return expires ? data.updated + expires < Date.now() : false;
720
693
  };
721
- _handleCaps = /* @__PURE__ */ new WeakSet();
722
694
  handleCaps_fn = function(scores) {
723
695
  var _a, _b;
724
696
  if (!__privateGet(this, _options).manifest) {
@@ -736,7 +708,6 @@ handleCaps_fn = function(scores) {
736
708
  }
737
709
  }
738
710
  };
739
- _defaultData = /* @__PURE__ */ new WeakSet();
740
711
  defaultData_fn = function() {
741
712
  var _a, _b, _c;
742
713
  return {
@@ -749,33 +720,44 @@ var _serverTransitionState;
749
720
  var _scores;
750
721
  var _state;
751
722
  var _pzCache;
723
+ var _plugins;
724
+ var _commands;
752
725
  var _mitt3;
753
- var _emitTest;
726
+ var _Context_instances;
754
727
  var emitTest_fn;
755
- var _updateComputedScores;
728
+ var updateGoals_fn;
756
729
  var updateComputedScores_fn;
757
- var _calculateScores;
758
730
  var calculateScores_fn;
759
731
  _serverTransitionState = /* @__PURE__ */ new WeakMap();
760
732
  _scores = /* @__PURE__ */ new WeakMap();
761
733
  _state = /* @__PURE__ */ new WeakMap();
762
734
  _pzCache = /* @__PURE__ */ new WeakMap();
735
+ _plugins = /* @__PURE__ */ new WeakMap();
736
+ _commands = /* @__PURE__ */ new WeakMap();
763
737
  _mitt3 = /* @__PURE__ */ new WeakMap();
764
- _emitTest = /* @__PURE__ */ new WeakSet();
738
+ _Context_instances = /* @__PURE__ */ new WeakSet();
765
739
  emitTest_fn = function(event) {
766
740
  __privateGet(this, _mitt3).emit("testResult", event);
767
741
  };
768
- _updateComputedScores = /* @__PURE__ */ new WeakSet();
742
+ updateGoals_fn = async function(data) {
743
+ const goalCommands = this.manifest.computeGoals(data);
744
+ if (goalCommands.length !== 0) {
745
+ await this.storage.updateData(goalCommands);
746
+ }
747
+ };
769
748
  updateComputedScores_fn = function(newData) {
770
- const newScores = __privateMethod(this, _calculateScores, calculateScores_fn).call(this, newData);
749
+ const newScores = __privateMethod(this, _Context_instances, calculateScores_fn).call(this, newData);
771
750
  const newScoresHaveChanged = !dequal(newScores, __privateGet(this, _scores));
772
751
  if (newScoresHaveChanged) {
773
752
  __privateSet(this, _scores, newScores);
753
+ __privateMethod(this, _Context_instances, updateGoals_fn).call(this, {
754
+ scores: __privateGet(this, _scores),
755
+ quirks: void 0
756
+ });
774
757
  __privateGet(this, _mitt3).emit("scoresUpdated", newScores);
775
758
  __privateGet(this, _mitt3).emit("log", ["info", 3, newScores]);
776
759
  }
777
760
  };
778
- _calculateScores = /* @__PURE__ */ new WeakSet();
779
761
  calculateScores_fn = function(newData) {
780
762
  var _a;
781
763
  let newScores = { ...newData.scores };
@@ -822,13 +804,11 @@ function enableContextDevTools(options) {
822
804
  );
823
805
  };
824
806
  const onPersonalizationResult = (e) => {
825
- if (!e.changed)
826
- return;
807
+ if (!e.changed) return;
827
808
  personalizations.push(e);
828
809
  };
829
810
  const onTestResult = (e) => {
830
- if (!e.variantAssigned)
831
- return;
811
+ if (!e.variantAssigned) return;
832
812
  tests.push(e);
833
813
  };
834
814
  if (isBrowser) {
@@ -975,18 +955,17 @@ var PersonalizeClient = (props) => {
975
955
  // src/components/TestClient.ts
976
956
  import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
977
957
  import { runTest } from "@uniformdev/canvas-next-rsc-shared";
978
- import { createElement as createElement2, Fragment as Fragment4, useEffect as useEffect8, useState as useState7 } from "react";
958
+ import { createElement as createElement2, Fragment as Fragment4, useMemo } from "react";
979
959
  var TestClient = (props) => {
980
960
  var _a;
981
961
  const { slots } = props;
982
962
  const { context } = useUniformContext();
983
- const [index, setIndex] = useState7(0);
984
- useEffect8(() => {
963
+ const index = useMemo(() => {
985
964
  const result = runTest({
986
965
  ...props,
987
966
  contextInstance: context
988
967
  });
989
- setIndex(result.index);
968
+ return result.index;
990
969
  }, [props, context]);
991
970
  if (typeof index !== "number") {
992
971
  return null;
@@ -1001,14 +980,14 @@ import {
1001
980
  isAllowedReferrer
1002
981
  } from "@uniformdev/canvas";
1003
982
  import { useRouter as useRouter2, useSearchParams as useSearchParams3 } from "next/navigation";
1004
- import { useEffect as useEffect9, useMemo, useRef } from "react";
983
+ import { useEffect as useEffect8, useMemo as useMemo2, useRef } from "react";
1005
984
  import { Fragment as Fragment5, jsx as jsx3 } from "react/jsx-runtime";
1006
985
  var UniformScript = () => {
1007
986
  const router = useRouter2();
1008
987
  const params = useSearchParams3();
1009
988
  const needsToRefreshRef = useRef(false);
1010
989
  const enabled = params.get(IN_CONTEXT_EDITOR_QUERY_STRING_PARAM2) === "true";
1011
- const channel = useMemo(() => {
990
+ const channel = useMemo2(() => {
1012
991
  var _a;
1013
992
  if (typeof window === "undefined") {
1014
993
  return;
@@ -1019,7 +998,7 @@ var UniformScript = () => {
1019
998
  });
1020
999
  return instance;
1021
1000
  }, []);
1022
- useEffect9(() => {
1001
+ useEffect8(() => {
1023
1002
  if (!channel) {
1024
1003
  return;
1025
1004
  }
@@ -1036,7 +1015,7 @@ var UniformScript = () => {
1036
1015
  unsubscribeFromEditorUpdates();
1037
1016
  };
1038
1017
  }, [channel, router]);
1039
- useEffect9(() => {
1018
+ useEffect8(() => {
1040
1019
  if (typeof window === "undefined") {
1041
1020
  return;
1042
1021
  }
@@ -1044,6 +1023,10 @@ var UniformScript = () => {
1044
1023
  if (enabled) {
1045
1024
  if (!existing) {
1046
1025
  const textHost = isAllowedReferrer(window.document.referrer) ? window.document.referrer : "https://uniform.app/";
1026
+ window.__UNIFORM_CONTEXTUAL_EDITING__ = {
1027
+ framework: "React",
1028
+ version: 2
1029
+ };
1047
1030
  const bundleHost = new URL(textHost);
1048
1031
  bundleHost.pathname = "/files/canvas-in-context-embed/index.js";
1049
1032
  const script = document.createElement("script");
@@ -1057,7 +1040,7 @@ var UniformScript = () => {
1057
1040
  existing.remove();
1058
1041
  }
1059
1042
  }, [enabled]);
1060
- useEffect9(() => {
1043
+ useEffect8(() => {
1061
1044
  const handleBlurChange = () => {
1062
1045
  if (needsToRefreshRef.current) {
1063
1046
  router.refresh();
@@ -1071,6 +1054,87 @@ var UniformScript = () => {
1071
1054
  }, [router]);
1072
1055
  return /* @__PURE__ */ jsx3(Fragment5, {});
1073
1056
  };
1057
+
1058
+ // src/components/VisibilityRulesWrapperClient.tsx
1059
+ import {
1060
+ createQuirksVisibilityRule,
1061
+ evaluateNodeVisibilityParameter
1062
+ } from "@uniformdev/canvas";
1063
+ import { useEffect as useEffect10, useMemo as useMemo3, useState as useState8 } from "react";
1064
+
1065
+ // src/hooks/useQuirks.ts
1066
+ import { useEffect as useEffect9, useState as useState7 } from "react";
1067
+ function useQuirks() {
1068
+ var _a;
1069
+ const { context } = useUniformContext();
1070
+ const [quirks, setQuirks] = useState7((_a = context == null ? void 0 : context.quirks) != null ? _a : {});
1071
+ useEffect9(() => {
1072
+ if (!context) {
1073
+ return;
1074
+ }
1075
+ const quirkChangeListener = (updatedQuirks) => {
1076
+ setQuirks(updatedQuirks);
1077
+ };
1078
+ setQuirks(context.quirks);
1079
+ context == null ? void 0 : context.events.on("quirksUpdated", quirkChangeListener);
1080
+ return () => {
1081
+ context == null ? void 0 : context.events.off("quirksUpdated", quirkChangeListener);
1082
+ };
1083
+ }, [context]);
1084
+ return quirks;
1085
+ }
1086
+
1087
+ // src/components/VisibilityRulesWrapperClient.tsx
1088
+ import { Fragment as Fragment6, jsx as jsx4 } from "react/jsx-runtime";
1089
+ var VisibilityRulesWrapperClient = ({
1090
+ parameter,
1091
+ initialIsVisible,
1092
+ children
1093
+ }) => {
1094
+ const [isVisible, setIsVisible] = useState8(initialIsVisible);
1095
+ const [visibleSource, setVisibleSource] = useState8(
1096
+ initialIsVisible === null ? "unknown" : "server"
1097
+ );
1098
+ const quirks = useQuirks();
1099
+ const rules = useMemo3(() => {
1100
+ return {
1101
+ ...createQuirksVisibilityRule(quirks)
1102
+ };
1103
+ }, [quirks]);
1104
+ useEffect10(() => {
1105
+ const result = evaluateNodeVisibilityParameter({
1106
+ rules,
1107
+ parameter
1108
+ });
1109
+ if (visibleSource === "server" && initialIsVisible && !result) {
1110
+ return;
1111
+ }
1112
+ setIsVisible(result);
1113
+ setVisibleSource("client");
1114
+ }, [initialIsVisible, visibleSource, parameter, rules]);
1115
+ return isVisible ? /* @__PURE__ */ jsx4(Fragment6, { children }) : null;
1116
+ };
1117
+
1118
+ // src/hooks/useScores.ts
1119
+ import { useEffect as useEffect11, useState as useState9 } from "react";
1120
+ function useScores() {
1121
+ const { context } = useUniformContext();
1122
+ const [scores, setScores] = useState9(context == null ? void 0 : context.scores);
1123
+ useEffect11(() => {
1124
+ if (!context) {
1125
+ return;
1126
+ }
1127
+ const scoringChangeListener = (updatedScores) => {
1128
+ setScores(updatedScores);
1129
+ };
1130
+ setScores(context.scores);
1131
+ context.events.on("scoresUpdated", scoringChangeListener);
1132
+ return () => {
1133
+ context.events.off("scoresUpdated", scoringChangeListener);
1134
+ };
1135
+ }, [context]);
1136
+ return scores;
1137
+ }
1074
1138
  export {
1075
1139
  ClientContextPersonalizationTransfer,
1076
1140
  ClientContextTestTransfer,
@@ -1081,8 +1145,11 @@ export {
1081
1145
  PersonalizeClient,
1082
1146
  TestClient,
1083
1147
  UniformScript,
1148
+ VisibilityRulesWrapperClient,
1084
1149
  createClientUniformContext,
1085
1150
  useInitUniformContext,
1151
+ useQuirks,
1152
+ useScores,
1086
1153
  useUniformContext
1087
1154
  };
1088
1155
  /*! Bundled license information: