@uniformdev/canvas-next-rsc-shared 19.173.1-alpha.17 → 19.173.2-alpha.210

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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { ContextInstance, ContextState, ContextOptions, PersonalizationEvent, TestEvent } from '@uniformdev/context';
2
- import * as _uniformdev_canvas from '@uniformdev/canvas';
1
+ import * as _uniformdev_context from '@uniformdev/context';
2
+ import { ContextInstance, ContextState, ContextOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent } from '@uniformdev/context';
3
3
  import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
4
4
  import { PropsWithChildren } from 'react';
5
5
 
@@ -144,22 +144,38 @@ type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiRespo
144
144
  };
145
145
  type AppDirectoryContext = Omit<ContextInstance, 'update'> & {
146
146
  update: (update: Partial<AppDirectoryContextState>) => Promise<void>;
147
- };
148
- type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
149
- type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'> & {
150
147
  /**
151
148
  * Internal use only. Please use `ContextUpdateTransfer` to handle any Context updates.
152
149
  *
153
150
  * @deprecated
154
151
  */
155
- __INTERNAL__: {
156
- update: AppDirectoryContext['update'];
157
- };
152
+ internal_update: AppDirectoryContext['update'];
158
153
  };
154
+ type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
155
+ type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'>;
159
156
 
160
157
  declare const createUniformContext: ({ serverCookieValue, ...rest }: Omit<ContextOptions, "transitionStore"> & {
161
158
  serverCookieValue: string | undefined;
162
- }) => AppDirectoryContext;
159
+ }) => AppDirectoryContextInstance;
160
+ declare class AppDirectoryContextInstance implements AppDirectoryContext {
161
+ #private;
162
+ readonly manifest: ContextInstance['manifest'];
163
+ readonly events: ContextInstance['events'];
164
+ constructor(context: Context);
165
+ get scores(): Readonly<_uniformdev_context.ScoreVector>;
166
+ get quirks(): Readonly<_uniformdev_context.Quirks>;
167
+ getTestVariantId(testName: string): string | null | undefined;
168
+ setTestVariantId(testName: string, variantId: string): void;
169
+ log(...message: LogMessage): void;
170
+ test<TVariant extends TestVariant>(options: TestOptions<TVariant>): _uniformdev_context.TestResult<TVariant>;
171
+ personalize<TVariant extends PersonalizedVariant>(options: PersonalizeOptions<TVariant>): _uniformdev_context.PersonalizedResult<TVariant>;
172
+ forget(fromAllDevices: boolean): Promise<void>;
173
+ getServerToClientTransitionState(): _uniformdev_context.ServerToClientTransitionState;
174
+ internal_processTestEvent(event: TestEvent): void;
175
+ internal_processPersonalizationEvent(event: PersonalizationEvent): void;
176
+ update(update: Partial<AppDirectoryContextState>): Promise<void>;
177
+ internal_update(update: Partial<AppDirectoryContextState>): Promise<void>;
178
+ }
163
179
 
164
180
  type PersonalizeProps = {
165
181
  trackingEventName: string;
@@ -170,9 +186,9 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
170
186
  };
171
187
 
172
188
  declare const runPersonalization: ({ component, trackingEventName, count, contextInstance, }: PersonalizeProps & {
173
- component: ComponentProps['component'];
189
+ component: ComponentProps["component"];
174
190
  } & {
175
- contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
191
+ contextInstance: Pick<ContextInstance, "personalize"> | undefined;
176
192
  }) => {
177
193
  indexes: number[];
178
194
  event: PersonalizationEvent;
@@ -182,14 +198,8 @@ type TestProps = {
182
198
  test: string;
183
199
  };
184
200
 
185
- declare const runTest: ({ test, component, contextInstance, }: TestProps & {
186
- component: _uniformdev_canvas.ComponentInstance;
187
- context: CompositionContext;
188
- slots: Record<string, SlotDefinition>;
189
- slotName: string | undefined;
190
- slotIndex: number | undefined;
191
- } & {
192
- contextInstance: Pick<ContextInstance, 'test' | 'manifest'> | undefined;
201
+ declare const runTest: ({ test, component, contextInstance, }: ComponentProps<TestProps> & {
202
+ contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
193
203
  }) => {
194
204
  index: number | null;
195
205
  event: TestEvent | null;
@@ -199,8 +209,8 @@ type ResolvePathResult = {
199
209
  type: 'path';
200
210
  value: string;
201
211
  };
202
- declare const resolvePath: ({ params }: Pick<PageParameters, 'params'>) => ResolvePathResult;
212
+ declare const resolvePath: ({ params }: Pick<PageParameters, "params">) => ResolvePathResult;
203
213
 
204
214
  declare function getBaseUrl(): string;
205
215
 
206
- export { type AppDirectoryContext, type AppDirectoryContextState, type AppDirectoryServerContext, type CacheMode, type ComponentProps, type CompositionContext, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
216
+ export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type CacheMode, type ComponentProps, type CompositionContext, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ContextInstance, ContextState, ContextOptions, PersonalizationEvent, TestEvent } from '@uniformdev/context';
2
- import * as _uniformdev_canvas from '@uniformdev/canvas';
1
+ import * as _uniformdev_context from '@uniformdev/context';
2
+ import { ContextInstance, ContextState, ContextOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent } from '@uniformdev/context';
3
3
  import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
4
4
  import { PropsWithChildren } from 'react';
5
5
 
@@ -144,22 +144,38 @@ type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiRespo
144
144
  };
145
145
  type AppDirectoryContext = Omit<ContextInstance, 'update'> & {
146
146
  update: (update: Partial<AppDirectoryContextState>) => Promise<void>;
147
- };
148
- type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
149
- type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'> & {
150
147
  /**
151
148
  * Internal use only. Please use `ContextUpdateTransfer` to handle any Context updates.
152
149
  *
153
150
  * @deprecated
154
151
  */
155
- __INTERNAL__: {
156
- update: AppDirectoryContext['update'];
157
- };
152
+ internal_update: AppDirectoryContext['update'];
158
153
  };
154
+ type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
155
+ type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'>;
159
156
 
160
157
  declare const createUniformContext: ({ serverCookieValue, ...rest }: Omit<ContextOptions, "transitionStore"> & {
161
158
  serverCookieValue: string | undefined;
162
- }) => AppDirectoryContext;
159
+ }) => AppDirectoryContextInstance;
160
+ declare class AppDirectoryContextInstance implements AppDirectoryContext {
161
+ #private;
162
+ readonly manifest: ContextInstance['manifest'];
163
+ readonly events: ContextInstance['events'];
164
+ constructor(context: Context);
165
+ get scores(): Readonly<_uniformdev_context.ScoreVector>;
166
+ get quirks(): Readonly<_uniformdev_context.Quirks>;
167
+ getTestVariantId(testName: string): string | null | undefined;
168
+ setTestVariantId(testName: string, variantId: string): void;
169
+ log(...message: LogMessage): void;
170
+ test<TVariant extends TestVariant>(options: TestOptions<TVariant>): _uniformdev_context.TestResult<TVariant>;
171
+ personalize<TVariant extends PersonalizedVariant>(options: PersonalizeOptions<TVariant>): _uniformdev_context.PersonalizedResult<TVariant>;
172
+ forget(fromAllDevices: boolean): Promise<void>;
173
+ getServerToClientTransitionState(): _uniformdev_context.ServerToClientTransitionState;
174
+ internal_processTestEvent(event: TestEvent): void;
175
+ internal_processPersonalizationEvent(event: PersonalizationEvent): void;
176
+ update(update: Partial<AppDirectoryContextState>): Promise<void>;
177
+ internal_update(update: Partial<AppDirectoryContextState>): Promise<void>;
178
+ }
163
179
 
164
180
  type PersonalizeProps = {
165
181
  trackingEventName: string;
@@ -170,9 +186,9 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
170
186
  };
171
187
 
172
188
  declare const runPersonalization: ({ component, trackingEventName, count, contextInstance, }: PersonalizeProps & {
173
- component: ComponentProps['component'];
189
+ component: ComponentProps["component"];
174
190
  } & {
175
- contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
191
+ contextInstance: Pick<ContextInstance, "personalize"> | undefined;
176
192
  }) => {
177
193
  indexes: number[];
178
194
  event: PersonalizationEvent;
@@ -182,14 +198,8 @@ type TestProps = {
182
198
  test: string;
183
199
  };
184
200
 
185
- declare const runTest: ({ test, component, contextInstance, }: TestProps & {
186
- component: _uniformdev_canvas.ComponentInstance;
187
- context: CompositionContext;
188
- slots: Record<string, SlotDefinition>;
189
- slotName: string | undefined;
190
- slotIndex: number | undefined;
191
- } & {
192
- contextInstance: Pick<ContextInstance, 'test' | 'manifest'> | undefined;
201
+ declare const runTest: ({ test, component, contextInstance, }: ComponentProps<TestProps> & {
202
+ contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
193
203
  }) => {
194
204
  index: number | null;
195
205
  event: TestEvent | null;
@@ -199,8 +209,8 @@ type ResolvePathResult = {
199
209
  type: 'path';
200
210
  value: string;
201
211
  };
202
- declare const resolvePath: ({ params }: Pick<PageParameters, 'params'>) => ResolvePathResult;
212
+ declare const resolvePath: ({ params }: Pick<PageParameters, "params">) => ResolvePathResult;
203
213
 
204
214
  declare function getBaseUrl(): string;
205
215
 
206
- export { type AppDirectoryContext, type AppDirectoryContextState, type AppDirectoryServerContext, type CacheMode, type ComponentProps, type CompositionContext, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
216
+ export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type CacheMode, type ComponentProps, type CompositionContext, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
package/dist/index.esm.js CHANGED
@@ -1,5 +1,16 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+
1
9
  // src/context/createUniformContext.ts
2
- import { Context, CookieTransitionDataStore } from "@uniformdev/context";
10
+ import {
11
+ Context,
12
+ CookieTransitionDataStore
13
+ } from "@uniformdev/context";
3
14
 
4
15
  // src/utils/path.ts
5
16
  var resolvePath = ({ params }) => {
@@ -63,51 +74,84 @@ var createUniformContext = ({
63
74
  serverCookieValue
64
75
  })
65
76
  });
66
- const appDirectoryContext = {
67
- forget: (...props) => context.forget(...props),
68
- getServerToClientTransitionState: () => context.getServerToClientTransitionState(),
69
- getTestVariantId: (...props) => context.getTestVariantId(...props),
70
- log: (...props) => context.log(...props),
71
- personalize: (...props) => context.personalize(...props),
72
- quirks: context.quirks,
73
- setTestVariantId: (...props) => context.setTestVariantId(...props),
74
- scores: context.scores,
75
- test: (...props) => context.test(...props),
76
- manifest: context.manifest,
77
- update: (update) => {
78
- const { params, searchParams } = update;
79
- const DEFAULT_URL = `${getBaseUrl()}/`;
80
- let url = void 0;
81
- if (params) {
82
- const path = resolvePath({
83
- params
84
- });
85
- if (!url) {
86
- url = new URL(DEFAULT_URL);
87
- }
88
- url.pathname = path.value;
77
+ const wrapped = new AppDirectoryContextInstance(context);
78
+ return wrapped;
79
+ };
80
+ var _context;
81
+ var AppDirectoryContextInstance = class {
82
+ constructor(context) {
83
+ __privateAdd(this, _context);
84
+ __privateSet(this, _context, context);
85
+ this.manifest = context.manifest;
86
+ this.events = context.events;
87
+ }
88
+ get scores() {
89
+ return __privateGet(this, _context).scores;
90
+ }
91
+ get quirks() {
92
+ return __privateGet(this, _context).quirks;
93
+ }
94
+ getTestVariantId(testName) {
95
+ return __privateGet(this, _context).getTestVariantId(testName);
96
+ }
97
+ setTestVariantId(testName, variantId) {
98
+ return __privateGet(this, _context).setTestVariantId(testName, variantId);
99
+ }
100
+ log(...message) {
101
+ return __privateGet(this, _context).log(...message);
102
+ }
103
+ test(options) {
104
+ return __privateGet(this, _context).test(options);
105
+ }
106
+ personalize(options) {
107
+ return __privateGet(this, _context).personalize(options);
108
+ }
109
+ forget(fromAllDevices) {
110
+ return __privateGet(this, _context).forget(fromAllDevices);
111
+ }
112
+ getServerToClientTransitionState() {
113
+ return __privateGet(this, _context).getServerToClientTransitionState();
114
+ }
115
+ internal_processTestEvent(event) {
116
+ return __privateGet(this, _context).internal_processTestEvent(event);
117
+ }
118
+ internal_processPersonalizationEvent(event) {
119
+ return __privateGet(this, _context).internal_processPersonalizationEvent(event);
120
+ }
121
+ update(update) {
122
+ const { params, searchParams } = update;
123
+ const DEFAULT_URL = `${getBaseUrl()}/`;
124
+ let url = void 0;
125
+ if (params) {
126
+ const path = resolvePath({
127
+ params
128
+ });
129
+ if (!url) {
130
+ url = new URL(DEFAULT_URL);
89
131
  }
90
- if (searchParams) {
91
- Object.keys(searchParams).forEach((key) => {
92
- const value = searchParams[key];
93
- if (typeof value === "string") {
94
- if (!url) {
95
- url = new URL(DEFAULT_URL);
96
- }
97
- url.searchParams.set(key, value);
132
+ url.pathname = path.value;
133
+ }
134
+ if (searchParams) {
135
+ Object.keys(searchParams).forEach((key) => {
136
+ const value = searchParams[key];
137
+ if (typeof value === "string") {
138
+ if (!url) {
139
+ url = new URL(DEFAULT_URL);
98
140
  }
99
- });
100
- }
101
- return context.update({
102
- ...update,
103
- url
141
+ url.searchParams.set(key, value);
142
+ }
104
143
  });
105
- },
106
- internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
107
- internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
108
- };
109
- return appDirectoryContext;
144
+ }
145
+ return __privateGet(this, _context).update({
146
+ ...update,
147
+ url
148
+ });
149
+ }
150
+ internal_update(update) {
151
+ return this.update(update);
152
+ }
110
153
  };
154
+ _context = new WeakMap();
111
155
 
112
156
  // src/runPersonalization.ts
113
157
  import { CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
@@ -242,6 +286,7 @@ var runTest = ({
242
286
  };
243
287
  };
244
288
  export {
289
+ AppDirectoryContextInstance,
245
290
  createUniformContext,
246
291
  getBaseUrl,
247
292
  resolvePath,
package/dist/index.js CHANGED
@@ -3,6 +3,9 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __typeError = (msg) => {
7
+ throw TypeError(msg);
8
+ };
6
9
  var __export = (target, all) => {
7
10
  for (var name in all)
8
11
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,10 +19,15 @@ var __copyProps = (to, from, except, desc) => {
16
19
  return to;
17
20
  };
18
21
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
19
26
 
20
27
  // src/index.ts
21
28
  var src_exports = {};
22
29
  __export(src_exports, {
30
+ AppDirectoryContextInstance: () => AppDirectoryContextInstance,
23
31
  createUniformContext: () => createUniformContext,
24
32
  getBaseUrl: () => getBaseUrl,
25
33
  resolvePath: () => resolvePath,
@@ -93,51 +101,84 @@ var createUniformContext = ({
93
101
  serverCookieValue
94
102
  })
95
103
  });
96
- const appDirectoryContext = {
97
- forget: (...props) => context.forget(...props),
98
- getServerToClientTransitionState: () => context.getServerToClientTransitionState(),
99
- getTestVariantId: (...props) => context.getTestVariantId(...props),
100
- log: (...props) => context.log(...props),
101
- personalize: (...props) => context.personalize(...props),
102
- quirks: context.quirks,
103
- setTestVariantId: (...props) => context.setTestVariantId(...props),
104
- scores: context.scores,
105
- test: (...props) => context.test(...props),
106
- manifest: context.manifest,
107
- update: (update) => {
108
- const { params, searchParams } = update;
109
- const DEFAULT_URL = `${getBaseUrl()}/`;
110
- let url = void 0;
111
- if (params) {
112
- const path = resolvePath({
113
- params
114
- });
115
- if (!url) {
116
- url = new URL(DEFAULT_URL);
117
- }
118
- url.pathname = path.value;
104
+ const wrapped = new AppDirectoryContextInstance(context);
105
+ return wrapped;
106
+ };
107
+ var _context;
108
+ var AppDirectoryContextInstance = class {
109
+ constructor(context) {
110
+ __privateAdd(this, _context);
111
+ __privateSet(this, _context, context);
112
+ this.manifest = context.manifest;
113
+ this.events = context.events;
114
+ }
115
+ get scores() {
116
+ return __privateGet(this, _context).scores;
117
+ }
118
+ get quirks() {
119
+ return __privateGet(this, _context).quirks;
120
+ }
121
+ getTestVariantId(testName) {
122
+ return __privateGet(this, _context).getTestVariantId(testName);
123
+ }
124
+ setTestVariantId(testName, variantId) {
125
+ return __privateGet(this, _context).setTestVariantId(testName, variantId);
126
+ }
127
+ log(...message) {
128
+ return __privateGet(this, _context).log(...message);
129
+ }
130
+ test(options) {
131
+ return __privateGet(this, _context).test(options);
132
+ }
133
+ personalize(options) {
134
+ return __privateGet(this, _context).personalize(options);
135
+ }
136
+ forget(fromAllDevices) {
137
+ return __privateGet(this, _context).forget(fromAllDevices);
138
+ }
139
+ getServerToClientTransitionState() {
140
+ return __privateGet(this, _context).getServerToClientTransitionState();
141
+ }
142
+ internal_processTestEvent(event) {
143
+ return __privateGet(this, _context).internal_processTestEvent(event);
144
+ }
145
+ internal_processPersonalizationEvent(event) {
146
+ return __privateGet(this, _context).internal_processPersonalizationEvent(event);
147
+ }
148
+ update(update) {
149
+ const { params, searchParams } = update;
150
+ const DEFAULT_URL = `${getBaseUrl()}/`;
151
+ let url = void 0;
152
+ if (params) {
153
+ const path = resolvePath({
154
+ params
155
+ });
156
+ if (!url) {
157
+ url = new URL(DEFAULT_URL);
119
158
  }
120
- if (searchParams) {
121
- Object.keys(searchParams).forEach((key) => {
122
- const value = searchParams[key];
123
- if (typeof value === "string") {
124
- if (!url) {
125
- url = new URL(DEFAULT_URL);
126
- }
127
- url.searchParams.set(key, value);
159
+ url.pathname = path.value;
160
+ }
161
+ if (searchParams) {
162
+ Object.keys(searchParams).forEach((key) => {
163
+ const value = searchParams[key];
164
+ if (typeof value === "string") {
165
+ if (!url) {
166
+ url = new URL(DEFAULT_URL);
128
167
  }
129
- });
130
- }
131
- return context.update({
132
- ...update,
133
- url
168
+ url.searchParams.set(key, value);
169
+ }
134
170
  });
135
- },
136
- internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
137
- internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
138
- };
139
- return appDirectoryContext;
171
+ }
172
+ return __privateGet(this, _context).update({
173
+ ...update,
174
+ url
175
+ });
176
+ }
177
+ internal_update(update) {
178
+ return this.update(update);
179
+ }
140
180
  };
181
+ _context = new WeakMap();
141
182
 
142
183
  // src/runPersonalization.ts
143
184
  var import_canvas = require("@uniformdev/canvas");
@@ -273,6 +314,7 @@ var runTest = ({
273
314
  };
274
315
  // Annotate the CommonJS export names for ESM import in node:
275
316
  0 && (module.exports = {
317
+ AppDirectoryContextInstance,
276
318
  createUniformContext,
277
319
  getBaseUrl,
278
320
  resolvePath,
package/dist/index.mjs CHANGED
@@ -1,5 +1,16 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+
1
9
  // src/context/createUniformContext.ts
2
- import { Context, CookieTransitionDataStore } from "@uniformdev/context";
10
+ import {
11
+ Context,
12
+ CookieTransitionDataStore
13
+ } from "@uniformdev/context";
3
14
 
4
15
  // src/utils/path.ts
5
16
  var resolvePath = ({ params }) => {
@@ -63,51 +74,84 @@ var createUniformContext = ({
63
74
  serverCookieValue
64
75
  })
65
76
  });
66
- const appDirectoryContext = {
67
- forget: (...props) => context.forget(...props),
68
- getServerToClientTransitionState: () => context.getServerToClientTransitionState(),
69
- getTestVariantId: (...props) => context.getTestVariantId(...props),
70
- log: (...props) => context.log(...props),
71
- personalize: (...props) => context.personalize(...props),
72
- quirks: context.quirks,
73
- setTestVariantId: (...props) => context.setTestVariantId(...props),
74
- scores: context.scores,
75
- test: (...props) => context.test(...props),
76
- manifest: context.manifest,
77
- update: (update) => {
78
- const { params, searchParams } = update;
79
- const DEFAULT_URL = `${getBaseUrl()}/`;
80
- let url = void 0;
81
- if (params) {
82
- const path = resolvePath({
83
- params
84
- });
85
- if (!url) {
86
- url = new URL(DEFAULT_URL);
87
- }
88
- url.pathname = path.value;
77
+ const wrapped = new AppDirectoryContextInstance(context);
78
+ return wrapped;
79
+ };
80
+ var _context;
81
+ var AppDirectoryContextInstance = class {
82
+ constructor(context) {
83
+ __privateAdd(this, _context);
84
+ __privateSet(this, _context, context);
85
+ this.manifest = context.manifest;
86
+ this.events = context.events;
87
+ }
88
+ get scores() {
89
+ return __privateGet(this, _context).scores;
90
+ }
91
+ get quirks() {
92
+ return __privateGet(this, _context).quirks;
93
+ }
94
+ getTestVariantId(testName) {
95
+ return __privateGet(this, _context).getTestVariantId(testName);
96
+ }
97
+ setTestVariantId(testName, variantId) {
98
+ return __privateGet(this, _context).setTestVariantId(testName, variantId);
99
+ }
100
+ log(...message) {
101
+ return __privateGet(this, _context).log(...message);
102
+ }
103
+ test(options) {
104
+ return __privateGet(this, _context).test(options);
105
+ }
106
+ personalize(options) {
107
+ return __privateGet(this, _context).personalize(options);
108
+ }
109
+ forget(fromAllDevices) {
110
+ return __privateGet(this, _context).forget(fromAllDevices);
111
+ }
112
+ getServerToClientTransitionState() {
113
+ return __privateGet(this, _context).getServerToClientTransitionState();
114
+ }
115
+ internal_processTestEvent(event) {
116
+ return __privateGet(this, _context).internal_processTestEvent(event);
117
+ }
118
+ internal_processPersonalizationEvent(event) {
119
+ return __privateGet(this, _context).internal_processPersonalizationEvent(event);
120
+ }
121
+ update(update) {
122
+ const { params, searchParams } = update;
123
+ const DEFAULT_URL = `${getBaseUrl()}/`;
124
+ let url = void 0;
125
+ if (params) {
126
+ const path = resolvePath({
127
+ params
128
+ });
129
+ if (!url) {
130
+ url = new URL(DEFAULT_URL);
89
131
  }
90
- if (searchParams) {
91
- Object.keys(searchParams).forEach((key) => {
92
- const value = searchParams[key];
93
- if (typeof value === "string") {
94
- if (!url) {
95
- url = new URL(DEFAULT_URL);
96
- }
97
- url.searchParams.set(key, value);
132
+ url.pathname = path.value;
133
+ }
134
+ if (searchParams) {
135
+ Object.keys(searchParams).forEach((key) => {
136
+ const value = searchParams[key];
137
+ if (typeof value === "string") {
138
+ if (!url) {
139
+ url = new URL(DEFAULT_URL);
98
140
  }
99
- });
100
- }
101
- return context.update({
102
- ...update,
103
- url
141
+ url.searchParams.set(key, value);
142
+ }
104
143
  });
105
- },
106
- internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
107
- internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
108
- };
109
- return appDirectoryContext;
144
+ }
145
+ return __privateGet(this, _context).update({
146
+ ...update,
147
+ url
148
+ });
149
+ }
150
+ internal_update(update) {
151
+ return this.update(update);
152
+ }
110
153
  };
154
+ _context = new WeakMap();
111
155
 
112
156
  // src/runPersonalization.ts
113
157
  import { CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
@@ -242,6 +286,7 @@ var runTest = ({
242
286
  };
243
287
  };
244
288
  export {
289
+ AppDirectoryContextInstance,
245
290
  createUniformContext,
246
291
  getBaseUrl,
247
292
  resolvePath,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc-shared",
3
- "version": "19.173.1-alpha.17+25c1176cea",
3
+ "version": "19.173.2-alpha.210+4f0f6ff104",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
7
7
  "dev": "tsup --watch",
8
- "lint": "eslint \"**/*.{ts,tsx}\" --fix",
8
+ "lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
9
9
  "test": "jest --maxWorkers=1 --passWithNoTests"
10
10
  },
11
11
  "sideEffects": false,
@@ -24,16 +24,16 @@
24
24
  "/dist"
25
25
  ],
26
26
  "devDependencies": {
27
- "@types/node": "^20.0.0",
28
- "@types/react": "18.2.40",
29
- "eslint": "8.57.0",
27
+ "@types/node": "20.10.6",
28
+ "@types/react": "18.3.3",
29
+ "eslint": "9.9.0",
30
30
  "next": "^14.0.0",
31
- "react": "18.2.0",
32
- "react-dom": "18.2.0"
31
+ "react": "18.3.1",
32
+ "react-dom": "18.3.1"
33
33
  },
34
34
  "dependencies": {
35
- "@uniformdev/canvas": "19.173.1-alpha.17+25c1176cea",
36
- "@uniformdev/context": "19.173.1-alpha.17+25c1176cea"
35
+ "@uniformdev/canvas": "19.173.2-alpha.210+4f0f6ff104",
36
+ "@uniformdev/context": "19.173.2-alpha.210+4f0f6ff104"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=16.14.0"
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "25c1176cea8d5114b92fc75cdd8bba4aa6463a50"
49
+ "gitHead": "4f0f6ff104f46349c338fde461f063f22f04ce0e"
50
50
  }