@uniformdev/canvas-next-rsc-client 19.55.2-alpha.54 → 19.55.2-alpha.57
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 +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.esm.js +46 -25
- package/dist/index.js +56 -33
- package/dist/index.mjs +46 -25
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { ManifestV2, ContextOptions } from '@uniformdev/context';
|
|
1
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
import { PureContextualEditingComponentWrapperProps } from '@uniformdev/canvas-react/core';
|
|
3
4
|
import * as react from 'react';
|
|
4
5
|
import { PropsWithChildren } from 'react';
|
|
6
|
+
import * as _uniformdev_canvas_next_rsc_shared from '@uniformdev/canvas-next-rsc-shared';
|
|
5
7
|
import { AppDirectoryContextState, PersonalizeProps, ComponentProps, TestProps, AppDirectoryContext } from '@uniformdev/canvas-next-rsc-shared';
|
|
6
8
|
|
|
9
|
+
type ClientContextComponent = (props: {
|
|
10
|
+
manifest: ManifestV2;
|
|
11
|
+
}) => JSX.Element | null;
|
|
12
|
+
|
|
7
13
|
declare const ClientContextualEditingComponentWrapper: (props: PropsWithChildren<PureContextualEditingComponentWrapperProps>) => react_jsx_runtime.JSX.Element;
|
|
8
14
|
|
|
9
15
|
declare const ClientContextUpdate: () => react_jsx_runtime.JSX.Element;
|
|
@@ -13,6 +19,8 @@ declare const ContextUpdateTransferClient: ({ update, ts, }: {
|
|
|
13
19
|
ts: number;
|
|
14
20
|
}) => null;
|
|
15
21
|
|
|
22
|
+
declare const DefaultUniformClientContext: ClientContextComponent;
|
|
23
|
+
|
|
16
24
|
type PersonalizeClientProps = PersonalizeProps & {
|
|
17
25
|
indexes: number[];
|
|
18
26
|
};
|
|
@@ -26,6 +34,9 @@ declare const TestClient: (props: ComponentProps<TestProps>) => react.FunctionCo
|
|
|
26
34
|
|
|
27
35
|
declare const UniformScript: () => react_jsx_runtime.JSX.Element;
|
|
28
36
|
|
|
37
|
+
type CreateClientUniformContextOptions = Omit<ContextOptions, 'transitionStore'>;
|
|
38
|
+
declare const createClientUniformContext: (options: CreateClientUniformContextOptions) => _uniformdev_canvas_next_rsc_shared.AppDirectoryContext;
|
|
39
|
+
|
|
29
40
|
declare const useInitUniformContext: (callback: () => AppDirectoryContext) => void;
|
|
30
41
|
|
|
31
42
|
declare global {
|
|
@@ -37,4 +48,4 @@ declare const useUniformContext: () => {
|
|
|
37
48
|
context: AppDirectoryContext | undefined;
|
|
38
49
|
};
|
|
39
50
|
|
|
40
|
-
export { ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, PersonalizeClient, PersonalizeClientProps, TestClient, UniformScript, useInitUniformContext, useUniformContext };
|
|
51
|
+
export { ClientContextComponent, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, PersonalizeClientProps, TestClient, UniformScript, createClientUniformContext, useInitUniformContext, useUniformContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { ManifestV2, ContextOptions } from '@uniformdev/context';
|
|
1
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
import { PureContextualEditingComponentWrapperProps } from '@uniformdev/canvas-react/core';
|
|
3
4
|
import * as react from 'react';
|
|
4
5
|
import { PropsWithChildren } from 'react';
|
|
6
|
+
import * as _uniformdev_canvas_next_rsc_shared from '@uniformdev/canvas-next-rsc-shared';
|
|
5
7
|
import { AppDirectoryContextState, PersonalizeProps, ComponentProps, TestProps, AppDirectoryContext } from '@uniformdev/canvas-next-rsc-shared';
|
|
6
8
|
|
|
9
|
+
type ClientContextComponent = (props: {
|
|
10
|
+
manifest: ManifestV2;
|
|
11
|
+
}) => JSX.Element | null;
|
|
12
|
+
|
|
7
13
|
declare const ClientContextualEditingComponentWrapper: (props: PropsWithChildren<PureContextualEditingComponentWrapperProps>) => react_jsx_runtime.JSX.Element;
|
|
8
14
|
|
|
9
15
|
declare const ClientContextUpdate: () => react_jsx_runtime.JSX.Element;
|
|
@@ -13,6 +19,8 @@ declare const ContextUpdateTransferClient: ({ update, ts, }: {
|
|
|
13
19
|
ts: number;
|
|
14
20
|
}) => null;
|
|
15
21
|
|
|
22
|
+
declare const DefaultUniformClientContext: ClientContextComponent;
|
|
23
|
+
|
|
16
24
|
type PersonalizeClientProps = PersonalizeProps & {
|
|
17
25
|
indexes: number[];
|
|
18
26
|
};
|
|
@@ -26,6 +34,9 @@ declare const TestClient: (props: ComponentProps<TestProps>) => react.FunctionCo
|
|
|
26
34
|
|
|
27
35
|
declare const UniformScript: () => react_jsx_runtime.JSX.Element;
|
|
28
36
|
|
|
37
|
+
type CreateClientUniformContextOptions = Omit<ContextOptions, 'transitionStore'>;
|
|
38
|
+
declare const createClientUniformContext: (options: CreateClientUniformContextOptions) => _uniformdev_canvas_next_rsc_shared.AppDirectoryContext;
|
|
39
|
+
|
|
29
40
|
declare const useInitUniformContext: (callback: () => AppDirectoryContext) => void;
|
|
30
41
|
|
|
31
42
|
declare global {
|
|
@@ -37,4 +48,4 @@ declare const useUniformContext: () => {
|
|
|
37
48
|
context: AppDirectoryContext | undefined;
|
|
38
49
|
};
|
|
39
50
|
|
|
40
|
-
export { ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, PersonalizeClient, PersonalizeClientProps, TestClient, UniformScript, useInitUniformContext, useUniformContext };
|
|
51
|
+
export { ClientContextComponent, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, PersonalizeClientProps, TestClient, UniformScript, createClientUniformContext, useInitUniformContext, useUniformContext };
|
package/dist/index.esm.js
CHANGED
|
@@ -88,15 +88,49 @@ var ContextUpdateTransferClient = ({
|
|
|
88
88
|
return null;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
+
// src/context/createClientUniformContext.ts
|
|
92
|
+
import { createUniformContext } from "@uniformdev/canvas-next-rsc-shared";
|
|
93
|
+
var createClientUniformContext = (options) => {
|
|
94
|
+
return createUniformContext({
|
|
95
|
+
...options,
|
|
96
|
+
serverCookieValue: void 0
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/hooks/useInitUniformContext.ts
|
|
101
|
+
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
102
|
+
var useInitUniformContext = (callback) => {
|
|
103
|
+
const [called, setCalled] = useState3(false);
|
|
104
|
+
useEffect4(() => {
|
|
105
|
+
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
window.__UNIFORM_CONTEXT__ = callback();
|
|
109
|
+
setCalled(true);
|
|
110
|
+
const event = new Event("uniform.context.loaded");
|
|
111
|
+
window.dispatchEvent(event);
|
|
112
|
+
}, [called, callback]);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/components/DefaultUniformClientContext.tsx
|
|
116
|
+
var DefaultUniformClientContext = ({ manifest }) => {
|
|
117
|
+
useInitUniformContext(() => {
|
|
118
|
+
return createClientUniformContext({
|
|
119
|
+
manifest
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
|
|
91
125
|
// src/components/PersonalizeClient.ts
|
|
92
126
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
93
127
|
import { runPersonalization } from "@uniformdev/canvas-next-rsc-shared";
|
|
94
|
-
import { createElement, Fragment as Fragment3, useEffect as
|
|
128
|
+
import { createElement, Fragment as Fragment3, useEffect as useEffect5, useState as useState4 } from "react";
|
|
95
129
|
var PersonalizeClient = (props) => {
|
|
96
130
|
const { slots } = props;
|
|
97
131
|
const { context } = useUniformContext();
|
|
98
|
-
const [indexesToShow, setIndexesToShow] =
|
|
99
|
-
|
|
132
|
+
const [indexesToShow, setIndexesToShow] = useState4(props.indexes);
|
|
133
|
+
useEffect5(() => {
|
|
100
134
|
const result = runPersonalization({
|
|
101
135
|
...props,
|
|
102
136
|
contextInstance: context
|
|
@@ -113,13 +147,13 @@ var PersonalizeClient = (props) => {
|
|
|
113
147
|
// src/components/TestClient.ts
|
|
114
148
|
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
115
149
|
import { runTest } from "@uniformdev/canvas-next-rsc-shared";
|
|
116
|
-
import { createElement as createElement2, Fragment as Fragment4, useEffect as
|
|
150
|
+
import { createElement as createElement2, Fragment as Fragment4, useEffect as useEffect6, useState as useState5 } from "react";
|
|
117
151
|
var TestClient = (props) => {
|
|
118
152
|
var _a;
|
|
119
153
|
const { slots } = props;
|
|
120
154
|
const { context } = useUniformContext();
|
|
121
|
-
const [index, setIndex] =
|
|
122
|
-
|
|
155
|
+
const [index, setIndex] = useState5(0);
|
|
156
|
+
useEffect6(() => {
|
|
123
157
|
const result = runTest({
|
|
124
158
|
...props,
|
|
125
159
|
contextInstance: context
|
|
@@ -139,7 +173,7 @@ import {
|
|
|
139
173
|
isAllowedReferrer
|
|
140
174
|
} from "@uniformdev/canvas";
|
|
141
175
|
import { useRouter, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
142
|
-
import { useEffect as
|
|
176
|
+
import { useEffect as useEffect7, useMemo, useRef } from "react";
|
|
143
177
|
import { Fragment as Fragment5, jsx as jsx3 } from "react/jsx-runtime";
|
|
144
178
|
var UniformScript = () => {
|
|
145
179
|
const router = useRouter();
|
|
@@ -157,7 +191,7 @@ var UniformScript = () => {
|
|
|
157
191
|
});
|
|
158
192
|
return instance;
|
|
159
193
|
}, []);
|
|
160
|
-
|
|
194
|
+
useEffect7(() => {
|
|
161
195
|
if (!channel) {
|
|
162
196
|
return;
|
|
163
197
|
}
|
|
@@ -174,7 +208,7 @@ var UniformScript = () => {
|
|
|
174
208
|
unsubscribeFromEditorUpdates();
|
|
175
209
|
};
|
|
176
210
|
}, [channel, router]);
|
|
177
|
-
|
|
211
|
+
useEffect7(() => {
|
|
178
212
|
if (typeof window === "undefined") {
|
|
179
213
|
return;
|
|
180
214
|
}
|
|
@@ -195,7 +229,7 @@ var UniformScript = () => {
|
|
|
195
229
|
existing.remove();
|
|
196
230
|
}
|
|
197
231
|
}, [enabled]);
|
|
198
|
-
|
|
232
|
+
useEffect7(() => {
|
|
199
233
|
const handleBlurChange = () => {
|
|
200
234
|
if (needsToRefreshRef.current) {
|
|
201
235
|
router.refresh();
|
|
@@ -209,28 +243,15 @@ var UniformScript = () => {
|
|
|
209
243
|
}, [router]);
|
|
210
244
|
return /* @__PURE__ */ jsx3(Fragment5, {});
|
|
211
245
|
};
|
|
212
|
-
|
|
213
|
-
// src/hooks/useInitUniformContext.ts
|
|
214
|
-
import { useEffect as useEffect7, useState as useState5 } from "react";
|
|
215
|
-
var useInitUniformContext = (callback) => {
|
|
216
|
-
const [called, setCalled] = useState5(false);
|
|
217
|
-
useEffect7(() => {
|
|
218
|
-
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
window.__UNIFORM_CONTEXT__ = callback();
|
|
222
|
-
setCalled(true);
|
|
223
|
-
const event = new Event("uniform.context.loaded");
|
|
224
|
-
window.dispatchEvent(event);
|
|
225
|
-
}, [called, callback]);
|
|
226
|
-
};
|
|
227
246
|
export {
|
|
228
247
|
ClientContextUpdate,
|
|
229
248
|
ClientContextualEditingComponentWrapper,
|
|
230
249
|
ContextUpdateTransferClient,
|
|
250
|
+
DefaultUniformClientContext,
|
|
231
251
|
PersonalizeClient,
|
|
232
252
|
TestClient,
|
|
233
253
|
UniformScript,
|
|
254
|
+
createClientUniformContext,
|
|
234
255
|
useInitUniformContext,
|
|
235
256
|
useUniformContext
|
|
236
257
|
};
|
package/dist/index.js
CHANGED
|
@@ -24,9 +24,11 @@ __export(src_exports, {
|
|
|
24
24
|
ClientContextUpdate: () => ClientContextUpdate,
|
|
25
25
|
ClientContextualEditingComponentWrapper: () => ClientContextualEditingComponentWrapper,
|
|
26
26
|
ContextUpdateTransferClient: () => ContextUpdateTransferClient,
|
|
27
|
+
DefaultUniformClientContext: () => DefaultUniformClientContext,
|
|
27
28
|
PersonalizeClient: () => PersonalizeClient,
|
|
28
29
|
TestClient: () => TestClient,
|
|
29
30
|
UniformScript: () => UniformScript,
|
|
31
|
+
createClientUniformContext: () => createClientUniformContext,
|
|
30
32
|
useInitUniformContext: () => useInitUniformContext,
|
|
31
33
|
useUniformContext: () => useUniformContext
|
|
32
34
|
});
|
|
@@ -118,16 +120,50 @@ var ContextUpdateTransferClient = ({
|
|
|
118
120
|
return null;
|
|
119
121
|
};
|
|
120
122
|
|
|
121
|
-
// src/
|
|
122
|
-
var import_canvas2 = require("@uniformdev/canvas");
|
|
123
|
+
// src/context/createClientUniformContext.ts
|
|
123
124
|
var import_canvas_next_rsc_shared = require("@uniformdev/canvas-next-rsc-shared");
|
|
125
|
+
var createClientUniformContext = (options) => {
|
|
126
|
+
return (0, import_canvas_next_rsc_shared.createUniformContext)({
|
|
127
|
+
...options,
|
|
128
|
+
serverCookieValue: void 0
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// src/hooks/useInitUniformContext.ts
|
|
124
133
|
var import_react5 = require("react");
|
|
134
|
+
var useInitUniformContext = (callback) => {
|
|
135
|
+
const [called, setCalled] = (0, import_react5.useState)(false);
|
|
136
|
+
(0, import_react5.useEffect)(() => {
|
|
137
|
+
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
window.__UNIFORM_CONTEXT__ = callback();
|
|
141
|
+
setCalled(true);
|
|
142
|
+
const event = new Event("uniform.context.loaded");
|
|
143
|
+
window.dispatchEvent(event);
|
|
144
|
+
}, [called, callback]);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/components/DefaultUniformClientContext.tsx
|
|
148
|
+
var DefaultUniformClientContext = ({ manifest }) => {
|
|
149
|
+
useInitUniformContext(() => {
|
|
150
|
+
return createClientUniformContext({
|
|
151
|
+
manifest
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
return null;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/components/PersonalizeClient.ts
|
|
158
|
+
var import_canvas2 = require("@uniformdev/canvas");
|
|
159
|
+
var import_canvas_next_rsc_shared2 = require("@uniformdev/canvas-next-rsc-shared");
|
|
160
|
+
var import_react6 = require("react");
|
|
125
161
|
var PersonalizeClient = (props) => {
|
|
126
162
|
const { slots } = props;
|
|
127
163
|
const { context } = useUniformContext();
|
|
128
|
-
const [indexesToShow, setIndexesToShow] = (0,
|
|
129
|
-
(0,
|
|
130
|
-
const result = (0,
|
|
164
|
+
const [indexesToShow, setIndexesToShow] = (0, import_react6.useState)(props.indexes);
|
|
165
|
+
(0, import_react6.useEffect)(() => {
|
|
166
|
+
const result = (0, import_canvas_next_rsc_shared2.runPersonalization)({
|
|
131
167
|
...props,
|
|
132
168
|
contextInstance: context
|
|
133
169
|
});
|
|
@@ -137,20 +173,20 @@ var PersonalizeClient = (props) => {
|
|
|
137
173
|
var _a;
|
|
138
174
|
return (_a = slots[import_canvas2.CANVAS_PERSONALIZE_SLOT]) == null ? void 0 : _a.items[key];
|
|
139
175
|
});
|
|
140
|
-
return (0,
|
|
176
|
+
return (0, import_react6.createElement)(import_react6.Fragment, void 0, slotsToShow);
|
|
141
177
|
};
|
|
142
178
|
|
|
143
179
|
// src/components/TestClient.ts
|
|
144
180
|
var import_canvas3 = require("@uniformdev/canvas");
|
|
145
|
-
var
|
|
146
|
-
var
|
|
181
|
+
var import_canvas_next_rsc_shared3 = require("@uniformdev/canvas-next-rsc-shared");
|
|
182
|
+
var import_react7 = require("react");
|
|
147
183
|
var TestClient = (props) => {
|
|
148
184
|
var _a;
|
|
149
185
|
const { slots } = props;
|
|
150
186
|
const { context } = useUniformContext();
|
|
151
|
-
const [index, setIndex] = (0,
|
|
152
|
-
(0,
|
|
153
|
-
const result = (0,
|
|
187
|
+
const [index, setIndex] = (0, import_react7.useState)(0);
|
|
188
|
+
(0, import_react7.useEffect)(() => {
|
|
189
|
+
const result = (0, import_canvas_next_rsc_shared3.runTest)({
|
|
154
190
|
...props,
|
|
155
191
|
contextInstance: context
|
|
156
192
|
});
|
|
@@ -159,20 +195,20 @@ var TestClient = (props) => {
|
|
|
159
195
|
if (typeof index !== "number") {
|
|
160
196
|
return null;
|
|
161
197
|
}
|
|
162
|
-
return (0,
|
|
198
|
+
return (0, import_react7.createElement)(import_react7.Fragment, void 0, (_a = slots == null ? void 0 : slots[import_canvas3.CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]);
|
|
163
199
|
};
|
|
164
200
|
|
|
165
201
|
// src/components/UniformScriptClient.tsx
|
|
166
202
|
var import_canvas4 = require("@uniformdev/canvas");
|
|
167
203
|
var import_navigation3 = require("next/navigation");
|
|
168
|
-
var
|
|
204
|
+
var import_react8 = require("react");
|
|
169
205
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
170
206
|
var UniformScript = () => {
|
|
171
207
|
const router = (0, import_navigation3.useRouter)();
|
|
172
208
|
const params = (0, import_navigation3.useSearchParams)();
|
|
173
|
-
const needsToRefreshRef = (0,
|
|
209
|
+
const needsToRefreshRef = (0, import_react8.useRef)(false);
|
|
174
210
|
const enabled = params.get(import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM) === "true";
|
|
175
|
-
const channel = (0,
|
|
211
|
+
const channel = (0, import_react8.useMemo)(() => {
|
|
176
212
|
var _a;
|
|
177
213
|
if (typeof window === "undefined") {
|
|
178
214
|
return;
|
|
@@ -183,7 +219,7 @@ var UniformScript = () => {
|
|
|
183
219
|
});
|
|
184
220
|
return instance;
|
|
185
221
|
}, []);
|
|
186
|
-
(0,
|
|
222
|
+
(0, import_react8.useEffect)(() => {
|
|
187
223
|
if (!channel) {
|
|
188
224
|
return;
|
|
189
225
|
}
|
|
@@ -200,7 +236,7 @@ var UniformScript = () => {
|
|
|
200
236
|
unsubscribeFromEditorUpdates();
|
|
201
237
|
};
|
|
202
238
|
}, [channel, router]);
|
|
203
|
-
(0,
|
|
239
|
+
(0, import_react8.useEffect)(() => {
|
|
204
240
|
if (typeof window === "undefined") {
|
|
205
241
|
return;
|
|
206
242
|
}
|
|
@@ -221,7 +257,7 @@ var UniformScript = () => {
|
|
|
221
257
|
existing.remove();
|
|
222
258
|
}
|
|
223
259
|
}, [enabled]);
|
|
224
|
-
(0,
|
|
260
|
+
(0, import_react8.useEffect)(() => {
|
|
225
261
|
const handleBlurChange = () => {
|
|
226
262
|
if (needsToRefreshRef.current) {
|
|
227
263
|
router.refresh();
|
|
@@ -235,29 +271,16 @@ var UniformScript = () => {
|
|
|
235
271
|
}, [router]);
|
|
236
272
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {});
|
|
237
273
|
};
|
|
238
|
-
|
|
239
|
-
// src/hooks/useInitUniformContext.ts
|
|
240
|
-
var import_react8 = require("react");
|
|
241
|
-
var useInitUniformContext = (callback) => {
|
|
242
|
-
const [called, setCalled] = (0, import_react8.useState)(false);
|
|
243
|
-
(0, import_react8.useEffect)(() => {
|
|
244
|
-
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
window.__UNIFORM_CONTEXT__ = callback();
|
|
248
|
-
setCalled(true);
|
|
249
|
-
const event = new Event("uniform.context.loaded");
|
|
250
|
-
window.dispatchEvent(event);
|
|
251
|
-
}, [called, callback]);
|
|
252
|
-
};
|
|
253
274
|
// Annotate the CommonJS export names for ESM import in node:
|
|
254
275
|
0 && (module.exports = {
|
|
255
276
|
ClientContextUpdate,
|
|
256
277
|
ClientContextualEditingComponentWrapper,
|
|
257
278
|
ContextUpdateTransferClient,
|
|
279
|
+
DefaultUniformClientContext,
|
|
258
280
|
PersonalizeClient,
|
|
259
281
|
TestClient,
|
|
260
282
|
UniformScript,
|
|
283
|
+
createClientUniformContext,
|
|
261
284
|
useInitUniformContext,
|
|
262
285
|
useUniformContext
|
|
263
286
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -88,15 +88,49 @@ var ContextUpdateTransferClient = ({
|
|
|
88
88
|
return null;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
+
// src/context/createClientUniformContext.ts
|
|
92
|
+
import { createUniformContext } from "@uniformdev/canvas-next-rsc-shared";
|
|
93
|
+
var createClientUniformContext = (options) => {
|
|
94
|
+
return createUniformContext({
|
|
95
|
+
...options,
|
|
96
|
+
serverCookieValue: void 0
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/hooks/useInitUniformContext.ts
|
|
101
|
+
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
102
|
+
var useInitUniformContext = (callback) => {
|
|
103
|
+
const [called, setCalled] = useState3(false);
|
|
104
|
+
useEffect4(() => {
|
|
105
|
+
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
window.__UNIFORM_CONTEXT__ = callback();
|
|
109
|
+
setCalled(true);
|
|
110
|
+
const event = new Event("uniform.context.loaded");
|
|
111
|
+
window.dispatchEvent(event);
|
|
112
|
+
}, [called, callback]);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/components/DefaultUniformClientContext.tsx
|
|
116
|
+
var DefaultUniformClientContext = ({ manifest }) => {
|
|
117
|
+
useInitUniformContext(() => {
|
|
118
|
+
return createClientUniformContext({
|
|
119
|
+
manifest
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
|
|
91
125
|
// src/components/PersonalizeClient.ts
|
|
92
126
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
93
127
|
import { runPersonalization } from "@uniformdev/canvas-next-rsc-shared";
|
|
94
|
-
import { createElement, Fragment as Fragment3, useEffect as
|
|
128
|
+
import { createElement, Fragment as Fragment3, useEffect as useEffect5, useState as useState4 } from "react";
|
|
95
129
|
var PersonalizeClient = (props) => {
|
|
96
130
|
const { slots } = props;
|
|
97
131
|
const { context } = useUniformContext();
|
|
98
|
-
const [indexesToShow, setIndexesToShow] =
|
|
99
|
-
|
|
132
|
+
const [indexesToShow, setIndexesToShow] = useState4(props.indexes);
|
|
133
|
+
useEffect5(() => {
|
|
100
134
|
const result = runPersonalization({
|
|
101
135
|
...props,
|
|
102
136
|
contextInstance: context
|
|
@@ -113,13 +147,13 @@ var PersonalizeClient = (props) => {
|
|
|
113
147
|
// src/components/TestClient.ts
|
|
114
148
|
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
115
149
|
import { runTest } from "@uniformdev/canvas-next-rsc-shared";
|
|
116
|
-
import { createElement as createElement2, Fragment as Fragment4, useEffect as
|
|
150
|
+
import { createElement as createElement2, Fragment as Fragment4, useEffect as useEffect6, useState as useState5 } from "react";
|
|
117
151
|
var TestClient = (props) => {
|
|
118
152
|
var _a;
|
|
119
153
|
const { slots } = props;
|
|
120
154
|
const { context } = useUniformContext();
|
|
121
|
-
const [index, setIndex] =
|
|
122
|
-
|
|
155
|
+
const [index, setIndex] = useState5(0);
|
|
156
|
+
useEffect6(() => {
|
|
123
157
|
const result = runTest({
|
|
124
158
|
...props,
|
|
125
159
|
contextInstance: context
|
|
@@ -139,7 +173,7 @@ import {
|
|
|
139
173
|
isAllowedReferrer
|
|
140
174
|
} from "@uniformdev/canvas";
|
|
141
175
|
import { useRouter, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
142
|
-
import { useEffect as
|
|
176
|
+
import { useEffect as useEffect7, useMemo, useRef } from "react";
|
|
143
177
|
import { Fragment as Fragment5, jsx as jsx3 } from "react/jsx-runtime";
|
|
144
178
|
var UniformScript = () => {
|
|
145
179
|
const router = useRouter();
|
|
@@ -157,7 +191,7 @@ var UniformScript = () => {
|
|
|
157
191
|
});
|
|
158
192
|
return instance;
|
|
159
193
|
}, []);
|
|
160
|
-
|
|
194
|
+
useEffect7(() => {
|
|
161
195
|
if (!channel) {
|
|
162
196
|
return;
|
|
163
197
|
}
|
|
@@ -174,7 +208,7 @@ var UniformScript = () => {
|
|
|
174
208
|
unsubscribeFromEditorUpdates();
|
|
175
209
|
};
|
|
176
210
|
}, [channel, router]);
|
|
177
|
-
|
|
211
|
+
useEffect7(() => {
|
|
178
212
|
if (typeof window === "undefined") {
|
|
179
213
|
return;
|
|
180
214
|
}
|
|
@@ -195,7 +229,7 @@ var UniformScript = () => {
|
|
|
195
229
|
existing.remove();
|
|
196
230
|
}
|
|
197
231
|
}, [enabled]);
|
|
198
|
-
|
|
232
|
+
useEffect7(() => {
|
|
199
233
|
const handleBlurChange = () => {
|
|
200
234
|
if (needsToRefreshRef.current) {
|
|
201
235
|
router.refresh();
|
|
@@ -209,28 +243,15 @@ var UniformScript = () => {
|
|
|
209
243
|
}, [router]);
|
|
210
244
|
return /* @__PURE__ */ jsx3(Fragment5, {});
|
|
211
245
|
};
|
|
212
|
-
|
|
213
|
-
// src/hooks/useInitUniformContext.ts
|
|
214
|
-
import { useEffect as useEffect7, useState as useState5 } from "react";
|
|
215
|
-
var useInitUniformContext = (callback) => {
|
|
216
|
-
const [called, setCalled] = useState5(false);
|
|
217
|
-
useEffect7(() => {
|
|
218
|
-
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
window.__UNIFORM_CONTEXT__ = callback();
|
|
222
|
-
setCalled(true);
|
|
223
|
-
const event = new Event("uniform.context.loaded");
|
|
224
|
-
window.dispatchEvent(event);
|
|
225
|
-
}, [called, callback]);
|
|
226
|
-
};
|
|
227
246
|
export {
|
|
228
247
|
ClientContextUpdate,
|
|
229
248
|
ClientContextualEditingComponentWrapper,
|
|
230
249
|
ContextUpdateTransferClient,
|
|
250
|
+
DefaultUniformClientContext,
|
|
231
251
|
PersonalizeClient,
|
|
232
252
|
TestClient,
|
|
233
253
|
UniformScript,
|
|
254
|
+
createClientUniformContext,
|
|
234
255
|
useInitUniformContext,
|
|
235
256
|
useUniformContext
|
|
236
257
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc-client",
|
|
3
|
-
"version": "19.55.2-alpha.
|
|
3
|
+
"version": "19.55.2-alpha.57+ce05e047a",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"react-dom": "18.2.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@uniformdev/canvas": "19.55.2-alpha.
|
|
36
|
-
"@uniformdev/canvas-next-rsc-shared": "^19.55.2-alpha.
|
|
37
|
-
"@uniformdev/canvas-react": "^19.55.2-alpha.
|
|
35
|
+
"@uniformdev/canvas": "19.55.2-alpha.57+ce05e047a",
|
|
36
|
+
"@uniformdev/canvas-next-rsc-shared": "^19.55.2-alpha.57+ce05e047a",
|
|
37
|
+
"@uniformdev/canvas-react": "^19.55.2-alpha.57+ce05e047a"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=16.14.0"
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "ce05e047a1116e4b1edeb495b1d0a3943bbe9833"
|
|
51
51
|
}
|