@uniformdev/canvas-next-rsc-shared 19.181.2 → 19.182.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/dist/index.d.mts +26 -9
- package/dist/index.d.ts +26 -9
- package/dist/index.esm.js +87 -43
- package/dist/index.js +83 -42
- package/dist/index.mjs +87 -43
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _uniformdev_context from '@uniformdev/context';
|
|
2
|
+
import { ContextInstance, ContextState, ContextOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent } from '@uniformdev/context';
|
|
2
3
|
import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
|
|
3
4
|
import { PropsWithChildren } from 'react';
|
|
4
5
|
|
|
@@ -143,22 +144,38 @@ type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiRespo
|
|
|
143
144
|
};
|
|
144
145
|
type AppDirectoryContext = Omit<ContextInstance, 'update'> & {
|
|
145
146
|
update: (update: Partial<AppDirectoryContextState>) => Promise<void>;
|
|
146
|
-
};
|
|
147
|
-
type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
|
|
148
|
-
type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'> & {
|
|
149
147
|
/**
|
|
150
148
|
* Internal use only. Please use `ContextUpdateTransfer` to handle any Context updates.
|
|
151
149
|
*
|
|
152
150
|
* @deprecated
|
|
153
151
|
*/
|
|
154
|
-
|
|
155
|
-
update: AppDirectoryContext['update'];
|
|
156
|
-
};
|
|
152
|
+
internal_update: AppDirectoryContext['update'];
|
|
157
153
|
};
|
|
154
|
+
type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
|
|
155
|
+
type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'>;
|
|
158
156
|
|
|
159
157
|
declare const createUniformContext: ({ serverCookieValue, ...rest }: Omit<ContextOptions, "transitionStore"> & {
|
|
160
158
|
serverCookieValue: string | undefined;
|
|
161
|
-
}) =>
|
|
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
|
+
}
|
|
162
179
|
|
|
163
180
|
type PersonalizeProps = {
|
|
164
181
|
trackingEventName: string;
|
|
@@ -196,4 +213,4 @@ declare const resolvePath: ({ params }: Pick<PageParameters, "params">) => Resol
|
|
|
196
213
|
|
|
197
214
|
declare function getBaseUrl(): string;
|
|
198
215
|
|
|
199
|
-
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,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _uniformdev_context from '@uniformdev/context';
|
|
2
|
+
import { ContextInstance, ContextState, ContextOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent } from '@uniformdev/context';
|
|
2
3
|
import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
|
|
3
4
|
import { PropsWithChildren } from 'react';
|
|
4
5
|
|
|
@@ -143,22 +144,38 @@ type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiRespo
|
|
|
143
144
|
};
|
|
144
145
|
type AppDirectoryContext = Omit<ContextInstance, 'update'> & {
|
|
145
146
|
update: (update: Partial<AppDirectoryContextState>) => Promise<void>;
|
|
146
|
-
};
|
|
147
|
-
type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
|
|
148
|
-
type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'> & {
|
|
149
147
|
/**
|
|
150
148
|
* Internal use only. Please use `ContextUpdateTransfer` to handle any Context updates.
|
|
151
149
|
*
|
|
152
150
|
* @deprecated
|
|
153
151
|
*/
|
|
154
|
-
|
|
155
|
-
update: AppDirectoryContext['update'];
|
|
156
|
-
};
|
|
152
|
+
internal_update: AppDirectoryContext['update'];
|
|
157
153
|
};
|
|
154
|
+
type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
|
|
155
|
+
type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'>;
|
|
158
156
|
|
|
159
157
|
declare const createUniformContext: ({ serverCookieValue, ...rest }: Omit<ContextOptions, "transitionStore"> & {
|
|
160
158
|
serverCookieValue: string | undefined;
|
|
161
|
-
}) =>
|
|
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
|
+
}
|
|
162
179
|
|
|
163
180
|
type PersonalizeProps = {
|
|
164
181
|
trackingEventName: string;
|
|
@@ -196,4 +213,4 @@ declare const resolvePath: ({ params }: Pick<PageParameters, "params">) => Resol
|
|
|
196
213
|
|
|
197
214
|
declare function getBaseUrl(): string;
|
|
198
215
|
|
|
199
|
-
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 {
|
|
10
|
+
import {
|
|
11
|
+
Context,
|
|
12
|
+
CookieTransitionDataStore
|
|
13
|
+
} from "@uniformdev/context";
|
|
3
14
|
|
|
4
15
|
// src/utils/path.ts
|
|
5
16
|
var resolvePath = ({ params }) => {
|
|
@@ -63,52 +74,84 @@ var createUniformContext = ({
|
|
|
63
74
|
serverCookieValue
|
|
64
75
|
})
|
|
65
76
|
});
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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);
|
|
90
131
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
url
|
|
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);
|
|
99
140
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return context.update({
|
|
103
|
-
...update,
|
|
104
|
-
url
|
|
141
|
+
url.searchParams.set(key, value);
|
|
142
|
+
}
|
|
105
143
|
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
144
|
+
}
|
|
145
|
+
return __privateGet(this, _context).update({
|
|
146
|
+
...update,
|
|
147
|
+
url
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
internal_update(update) {
|
|
151
|
+
return this.update(update);
|
|
152
|
+
}
|
|
111
153
|
};
|
|
154
|
+
_context = new WeakMap();
|
|
112
155
|
|
|
113
156
|
// src/runPersonalization.ts
|
|
114
157
|
import { CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
@@ -243,6 +286,7 @@ var runTest = ({
|
|
|
243
286
|
};
|
|
244
287
|
};
|
|
245
288
|
export {
|
|
289
|
+
AppDirectoryContextInstance,
|
|
246
290
|
createUniformContext,
|
|
247
291
|
getBaseUrl,
|
|
248
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,52 +101,84 @@ var createUniformContext = ({
|
|
|
93
101
|
serverCookieValue
|
|
94
102
|
})
|
|
95
103
|
});
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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);
|
|
120
158
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
url
|
|
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);
|
|
129
167
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return context.update({
|
|
133
|
-
...update,
|
|
134
|
-
url
|
|
168
|
+
url.searchParams.set(key, value);
|
|
169
|
+
}
|
|
135
170
|
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
171
|
+
}
|
|
172
|
+
return __privateGet(this, _context).update({
|
|
173
|
+
...update,
|
|
174
|
+
url
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
internal_update(update) {
|
|
178
|
+
return this.update(update);
|
|
179
|
+
}
|
|
141
180
|
};
|
|
181
|
+
_context = new WeakMap();
|
|
142
182
|
|
|
143
183
|
// src/runPersonalization.ts
|
|
144
184
|
var import_canvas = require("@uniformdev/canvas");
|
|
@@ -274,6 +314,7 @@ var runTest = ({
|
|
|
274
314
|
};
|
|
275
315
|
// Annotate the CommonJS export names for ESM import in node:
|
|
276
316
|
0 && (module.exports = {
|
|
317
|
+
AppDirectoryContextInstance,
|
|
277
318
|
createUniformContext,
|
|
278
319
|
getBaseUrl,
|
|
279
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 {
|
|
10
|
+
import {
|
|
11
|
+
Context,
|
|
12
|
+
CookieTransitionDataStore
|
|
13
|
+
} from "@uniformdev/context";
|
|
3
14
|
|
|
4
15
|
// src/utils/path.ts
|
|
5
16
|
var resolvePath = ({ params }) => {
|
|
@@ -63,52 +74,84 @@ var createUniformContext = ({
|
|
|
63
74
|
serverCookieValue
|
|
64
75
|
})
|
|
65
76
|
});
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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);
|
|
90
131
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
url
|
|
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);
|
|
99
140
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return context.update({
|
|
103
|
-
...update,
|
|
104
|
-
url
|
|
141
|
+
url.searchParams.set(key, value);
|
|
142
|
+
}
|
|
105
143
|
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
144
|
+
}
|
|
145
|
+
return __privateGet(this, _context).update({
|
|
146
|
+
...update,
|
|
147
|
+
url
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
internal_update(update) {
|
|
151
|
+
return this.update(update);
|
|
152
|
+
}
|
|
111
153
|
};
|
|
154
|
+
_context = new WeakMap();
|
|
112
155
|
|
|
113
156
|
// src/runPersonalization.ts
|
|
114
157
|
import { CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
@@ -243,6 +286,7 @@ var runTest = ({
|
|
|
243
286
|
};
|
|
244
287
|
};
|
|
245
288
|
export {
|
|
289
|
+
AppDirectoryContextInstance,
|
|
246
290
|
createUniformContext,
|
|
247
291
|
getBaseUrl,
|
|
248
292
|
resolvePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc-shared",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.182.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"react-dom": "18.3.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@uniformdev/canvas": "19.
|
|
36
|
-
"@uniformdev/context": "19.
|
|
35
|
+
"@uniformdev/canvas": "19.182.0",
|
|
36
|
+
"@uniformdev/context": "19.182.0"
|
|
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": "
|
|
49
|
+
"gitHead": "138d94ac9eff7221b6357095578380edf30cdb27"
|
|
50
50
|
}
|