@uniformdev/next-app-router-client 20.50.1-alpha.4 → 20.50.1
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 +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.esm.js +62 -28
- package/dist/index.js +88 -55
- package/dist/index.mjs +62 -28
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ManifestV2, CompositionMetadata, TestEvent, ContextState, ContextOptions, CookieTransitionDataStoreOptions, Context, Quirks, ScoreVector } from '@uniformdev/context';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { JSX, PropsWithChildren } from 'react';
|
|
4
|
-
import { ComponentContext, ComponentParameter, PersonalizeProps } from '@uniformdev/next-app-router-shared';
|
|
4
|
+
import { SlotDefinition, ExtractTestResult, CompositionContext, ComponentContext, ComponentParameter, PersonalizeProps } from '@uniformdev/next-app-router-shared';
|
|
5
5
|
import { VisibilityParameterValue } from '@uniformdev/canvas';
|
|
6
6
|
import * as _uniformdev_context__ from '@uniformdev/context/*';
|
|
7
7
|
|
|
@@ -36,6 +36,20 @@ declare const ClientContextTestTransfer: ({ event }: {
|
|
|
36
36
|
event: TestEvent;
|
|
37
37
|
}) => null;
|
|
38
38
|
|
|
39
|
+
type ClientTestProps = {
|
|
40
|
+
slots: Record<string, SlotDefinition>;
|
|
41
|
+
test: ExtractTestResult;
|
|
42
|
+
context: CompositionContext;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Client-side A/B test component used when the server skipped test evaluation
|
|
46
|
+
* (e.g. during prefetch). Evaluates the test on the client using the visitor's
|
|
47
|
+
* stored variant or rolling a new one, ensuring consistent assignment across pages.
|
|
48
|
+
*/
|
|
49
|
+
declare const ClientTest: ({ slots, test, context: compositionContext }: ClientTestProps) => React.FunctionComponentElement<{
|
|
50
|
+
children?: React.ReactNode | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
39
53
|
type ClientUniformTextProps = {
|
|
40
54
|
/**
|
|
41
55
|
* The name of the HTML tag to render.
|
|
@@ -125,4 +139,4 @@ declare const useUniformContext: () => {
|
|
|
125
139
|
context: Context | undefined;
|
|
126
140
|
};
|
|
127
141
|
|
|
128
|
-
export { type ClientContextComponent, type ClientContextComponentProps, ClientContextTestTransfer, ClientUniformText, type ClientUniformTextProps, ContextUpdateTransfer, DefaultUniformClientContext, Personalize, UniformScript, VisibilityRulesWrapperClient, createClientUniformContext, useInitUniformContext, useQuirks, useScores, useUniformContext };
|
|
142
|
+
export { type ClientContextComponent, type ClientContextComponentProps, ClientContextTestTransfer, ClientTest, ClientUniformText, type ClientUniformTextProps, ContextUpdateTransfer, DefaultUniformClientContext, Personalize, UniformScript, VisibilityRulesWrapperClient, createClientUniformContext, useInitUniformContext, useQuirks, useScores, useUniformContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ManifestV2, CompositionMetadata, TestEvent, ContextState, ContextOptions, CookieTransitionDataStoreOptions, Context, Quirks, ScoreVector } from '@uniformdev/context';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { JSX, PropsWithChildren } from 'react';
|
|
4
|
-
import { ComponentContext, ComponentParameter, PersonalizeProps } from '@uniformdev/next-app-router-shared';
|
|
4
|
+
import { SlotDefinition, ExtractTestResult, CompositionContext, ComponentContext, ComponentParameter, PersonalizeProps } from '@uniformdev/next-app-router-shared';
|
|
5
5
|
import { VisibilityParameterValue } from '@uniformdev/canvas';
|
|
6
6
|
import * as _uniformdev_context__ from '@uniformdev/context/*';
|
|
7
7
|
|
|
@@ -36,6 +36,20 @@ declare const ClientContextTestTransfer: ({ event }: {
|
|
|
36
36
|
event: TestEvent;
|
|
37
37
|
}) => null;
|
|
38
38
|
|
|
39
|
+
type ClientTestProps = {
|
|
40
|
+
slots: Record<string, SlotDefinition>;
|
|
41
|
+
test: ExtractTestResult;
|
|
42
|
+
context: CompositionContext;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Client-side A/B test component used when the server skipped test evaluation
|
|
46
|
+
* (e.g. during prefetch). Evaluates the test on the client using the visitor's
|
|
47
|
+
* stored variant or rolling a new one, ensuring consistent assignment across pages.
|
|
48
|
+
*/
|
|
49
|
+
declare const ClientTest: ({ slots, test, context: compositionContext }: ClientTestProps) => React.FunctionComponentElement<{
|
|
50
|
+
children?: React.ReactNode | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
39
53
|
type ClientUniformTextProps = {
|
|
40
54
|
/**
|
|
41
55
|
* The name of the HTML tag to render.
|
|
@@ -125,4 +139,4 @@ declare const useUniformContext: () => {
|
|
|
125
139
|
context: Context | undefined;
|
|
126
140
|
};
|
|
127
141
|
|
|
128
|
-
export { type ClientContextComponent, type ClientContextComponentProps, ClientContextTestTransfer, ClientUniformText, type ClientUniformTextProps, ContextUpdateTransfer, DefaultUniformClientContext, Personalize, UniformScript, VisibilityRulesWrapperClient, createClientUniformContext, useInitUniformContext, useQuirks, useScores, useUniformContext };
|
|
142
|
+
export { type ClientContextComponent, type ClientContextComponentProps, ClientContextTestTransfer, ClientTest, ClientUniformText, type ClientUniformTextProps, ContextUpdateTransfer, DefaultUniformClientContext, Personalize, UniformScript, VisibilityRulesWrapperClient, createClientUniformContext, useInitUniformContext, useQuirks, useScores, useUniformContext };
|
package/dist/index.esm.js
CHANGED
|
@@ -70,6 +70,39 @@ var ClientContextTestTransfer = ({ event }) => {
|
|
|
70
70
|
return null;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
// src/components/ClientTest.tsx
|
|
74
|
+
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
75
|
+
import {
|
|
76
|
+
evaluateTest
|
|
77
|
+
} from "@uniformdev/next-app-router-shared";
|
|
78
|
+
import { createElement, Fragment, useEffect as useEffect4, useMemo, useState as useState3 } from "react";
|
|
79
|
+
var ClientTest = ({ slots, test, context: compositionContext }) => {
|
|
80
|
+
const testSlot = slots[CANVAS_TEST_SLOT];
|
|
81
|
+
const { context } = useUniformContext();
|
|
82
|
+
const [indexToShow, setIndexToShow] = useState3(void 0);
|
|
83
|
+
useEffect4(() => {
|
|
84
|
+
if (!context || !testSlot) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const { index } = evaluateTest({
|
|
88
|
+
context,
|
|
89
|
+
test,
|
|
90
|
+
compositionContext
|
|
91
|
+
});
|
|
92
|
+
if (index !== null) {
|
|
93
|
+
setIndexToShow(index);
|
|
94
|
+
}
|
|
95
|
+
}, [context, testSlot, test, compositionContext]);
|
|
96
|
+
const slotToShow = useMemo(() => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
if (typeof indexToShow !== "number" || !testSlot) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return (_b = (_a = testSlot.items[indexToShow]) == null ? void 0 : _a.component) != null ? _b : null;
|
|
102
|
+
}, [indexToShow, testSlot]);
|
|
103
|
+
return createElement(Fragment, void 0, slotToShow);
|
|
104
|
+
};
|
|
105
|
+
|
|
73
106
|
// src/components/ClientUniformText.tsx
|
|
74
107
|
import {
|
|
75
108
|
ATTRIBUTE_COMPONENT_ID,
|
|
@@ -81,15 +114,15 @@ import {
|
|
|
81
114
|
createQuirksVisibilityRule,
|
|
82
115
|
evaluatePropertyCriteria
|
|
83
116
|
} from "@uniformdev/canvas";
|
|
84
|
-
import React, { useMemo } from "react";
|
|
117
|
+
import React, { useMemo as useMemo2 } from "react";
|
|
85
118
|
|
|
86
119
|
// src/hooks/useQuirks.ts
|
|
87
|
-
import { useEffect as
|
|
120
|
+
import { useEffect as useEffect5, useState as useState4 } from "react";
|
|
88
121
|
function useQuirks() {
|
|
89
122
|
var _a;
|
|
90
123
|
const { context } = useUniformContext();
|
|
91
|
-
const [quirks, setQuirks] =
|
|
92
|
-
|
|
124
|
+
const [quirks, setQuirks] = useState4((_a = context == null ? void 0 : context.quirks) != null ? _a : {});
|
|
125
|
+
useEffect5(() => {
|
|
93
126
|
if (!context) {
|
|
94
127
|
return;
|
|
95
128
|
}
|
|
@@ -117,12 +150,12 @@ var ClientUniformText = ({
|
|
|
117
150
|
}) => {
|
|
118
151
|
const parameter = providedParameter;
|
|
119
152
|
const quirks = useQuirks();
|
|
120
|
-
const rules =
|
|
153
|
+
const rules = useMemo2(() => {
|
|
121
154
|
return {
|
|
122
155
|
...createQuirksVisibilityRule(quirks)
|
|
123
156
|
};
|
|
124
157
|
}, [quirks]);
|
|
125
|
-
const currentValue =
|
|
158
|
+
const currentValue = useMemo2(() => {
|
|
126
159
|
var _a;
|
|
127
160
|
if (!parameter) {
|
|
128
161
|
return void 0;
|
|
@@ -190,12 +223,12 @@ var getParameterAttributes = ({
|
|
|
190
223
|
};
|
|
191
224
|
|
|
192
225
|
// src/components/ContextUpdateTransfer.tsx
|
|
193
|
-
import { useEffect as
|
|
226
|
+
import { useEffect as useEffect6 } from "react";
|
|
194
227
|
var hasKeys = (obj) => Object.keys(obj).length > 0;
|
|
195
228
|
var ContextUpdateTransfer = ({ update }) => {
|
|
196
229
|
const { context } = useUniformContext();
|
|
197
230
|
const stableUpdate = useStableValue(update, hasKeys);
|
|
198
|
-
|
|
231
|
+
useEffect6(() => {
|
|
199
232
|
if (context && stableUpdate) {
|
|
200
233
|
context.update(stableUpdate);
|
|
201
234
|
}
|
|
@@ -243,7 +276,7 @@ var createClientUniformContext = (options) => {
|
|
|
243
276
|
import { UNIFORM_MIDDLEWARE_QUIRK_COOKIE_NAME } from "@uniformdev/next-app-router-shared";
|
|
244
277
|
import Cookies from "js-cookie";
|
|
245
278
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
246
|
-
import { useEffect as
|
|
279
|
+
import { useEffect as useEffect7, useRef as useRef3 } from "react";
|
|
247
280
|
var useInitUniformContext = (callback, compositionMetadata) => {
|
|
248
281
|
const path = usePathname();
|
|
249
282
|
const searchParams = useSearchParams();
|
|
@@ -251,7 +284,7 @@ var useInitUniformContext = (callback, compositionMetadata) => {
|
|
|
251
284
|
if (typeof window !== "undefined" && context.current === void 0) {
|
|
252
285
|
context.current = callback();
|
|
253
286
|
}
|
|
254
|
-
|
|
287
|
+
useEffect7(() => {
|
|
255
288
|
if (typeof window === "undefined" || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
256
289
|
return;
|
|
257
290
|
}
|
|
@@ -313,14 +346,14 @@ var DefaultUniformClientContext = ({
|
|
|
313
346
|
// src/components/Personalize.tsx
|
|
314
347
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
315
348
|
import { evaluatePersonalization } from "@uniformdev/next-app-router-shared";
|
|
316
|
-
import { createElement, Fragment, useEffect as
|
|
349
|
+
import { createElement as createElement2, Fragment as Fragment2, useEffect as useEffect9, useMemo as useMemo3, useState as useState6 } from "react";
|
|
317
350
|
|
|
318
351
|
// src/hooks/useScores.ts
|
|
319
|
-
import { useEffect as
|
|
352
|
+
import { useEffect as useEffect8, useState as useState5 } from "react";
|
|
320
353
|
function useScores() {
|
|
321
354
|
const { context } = useUniformContext();
|
|
322
|
-
const [scores, setScores] =
|
|
323
|
-
|
|
355
|
+
const [scores, setScores] = useState5(context == null ? void 0 : context.scores);
|
|
356
|
+
useEffect8(() => {
|
|
324
357
|
if (!context) {
|
|
325
358
|
return;
|
|
326
359
|
}
|
|
@@ -350,8 +383,8 @@ var Personalize = ({
|
|
|
350
383
|
const { context } = useUniformContext();
|
|
351
384
|
const scores = useScores();
|
|
352
385
|
const quirks = useQuirks();
|
|
353
|
-
const [indexesToShow, setIndexesToShow] =
|
|
354
|
-
|
|
386
|
+
const [indexesToShow, setIndexesToShow] = useState6(indexes);
|
|
387
|
+
useEffect9(() => {
|
|
355
388
|
if (typeof context === "undefined" || !personalizationSlot) {
|
|
356
389
|
return;
|
|
357
390
|
}
|
|
@@ -390,23 +423,23 @@ var Personalize = ({
|
|
|
390
423
|
quirks,
|
|
391
424
|
indexesToShow
|
|
392
425
|
]);
|
|
393
|
-
const slotsToShow =
|
|
426
|
+
const slotsToShow = useMemo3(() => {
|
|
394
427
|
return indexesToShow.map((key) => {
|
|
395
428
|
var _a2;
|
|
396
429
|
return (_a2 = personalizationSlot == null ? void 0 : personalizationSlot.items[key]) == null ? void 0 : _a2.component;
|
|
397
430
|
});
|
|
398
431
|
}, [indexesToShow, personalizationSlot]);
|
|
399
|
-
return
|
|
432
|
+
return createElement2(Fragment2, void 0, slotsToShow);
|
|
400
433
|
};
|
|
401
434
|
|
|
402
435
|
// src/components/UniformScript.tsx
|
|
403
436
|
import { createCanvasChannel, isAllowedReferrer } from "@uniformdev/canvas";
|
|
404
437
|
import { useRouter as useRouter2 } from "next/navigation";
|
|
405
|
-
import { useEffect as
|
|
438
|
+
import { useEffect as useEffect10, useMemo as useMemo4, useRef as useRef4 } from "react";
|
|
406
439
|
var UniformScript = () => {
|
|
407
440
|
const router = useRouter2();
|
|
408
441
|
const needsToRefreshRef = useRef4(false);
|
|
409
|
-
const channel =
|
|
442
|
+
const channel = useMemo4(() => {
|
|
410
443
|
var _a;
|
|
411
444
|
if (typeof window === "undefined") {
|
|
412
445
|
return;
|
|
@@ -417,7 +450,7 @@ var UniformScript = () => {
|
|
|
417
450
|
});
|
|
418
451
|
return instance;
|
|
419
452
|
}, []);
|
|
420
|
-
|
|
453
|
+
useEffect10(() => {
|
|
421
454
|
if (!channel) {
|
|
422
455
|
return;
|
|
423
456
|
}
|
|
@@ -434,7 +467,7 @@ var UniformScript = () => {
|
|
|
434
467
|
unsubscribeFromEditorUpdates();
|
|
435
468
|
};
|
|
436
469
|
}, [channel, router]);
|
|
437
|
-
|
|
470
|
+
useEffect10(() => {
|
|
438
471
|
if (typeof window === "undefined") {
|
|
439
472
|
return;
|
|
440
473
|
}
|
|
@@ -455,7 +488,7 @@ var UniformScript = () => {
|
|
|
455
488
|
document.head.appendChild(script);
|
|
456
489
|
}
|
|
457
490
|
}, []);
|
|
458
|
-
|
|
491
|
+
useEffect10(() => {
|
|
459
492
|
const handleBlurChange = () => {
|
|
460
493
|
if (needsToRefreshRef.current) {
|
|
461
494
|
router.refresh();
|
|
@@ -475,23 +508,23 @@ import {
|
|
|
475
508
|
createQuirksVisibilityRule as createQuirksVisibilityRule2,
|
|
476
509
|
evaluateNodeVisibilityParameter
|
|
477
510
|
} from "@uniformdev/canvas";
|
|
478
|
-
import React2, { useEffect as
|
|
511
|
+
import React2, { useEffect as useEffect11, useMemo as useMemo5, useState as useState7 } from "react";
|
|
479
512
|
var VisibilityRulesWrapperClient = ({
|
|
480
513
|
parameter,
|
|
481
514
|
initialIsVisible,
|
|
482
515
|
children
|
|
483
516
|
}) => {
|
|
484
|
-
const [isVisible, setIsVisible] =
|
|
485
|
-
const [visibleSource, setVisibleSource] =
|
|
517
|
+
const [isVisible, setIsVisible] = useState7(initialIsVisible);
|
|
518
|
+
const [visibleSource, setVisibleSource] = useState7(
|
|
486
519
|
initialIsVisible === null ? "unknown" : "server"
|
|
487
520
|
);
|
|
488
521
|
const quirks = useQuirks();
|
|
489
|
-
const rules =
|
|
522
|
+
const rules = useMemo5(() => {
|
|
490
523
|
return {
|
|
491
524
|
...createQuirksVisibilityRule2(quirks)
|
|
492
525
|
};
|
|
493
526
|
}, [quirks]);
|
|
494
|
-
|
|
527
|
+
useEffect11(() => {
|
|
495
528
|
const result = evaluateNodeVisibilityParameter({
|
|
496
529
|
rules,
|
|
497
530
|
parameter
|
|
@@ -506,6 +539,7 @@ var VisibilityRulesWrapperClient = ({
|
|
|
506
539
|
};
|
|
507
540
|
export {
|
|
508
541
|
ClientContextTestTransfer,
|
|
542
|
+
ClientTest,
|
|
509
543
|
ClientUniformText,
|
|
510
544
|
ContextUpdateTransfer,
|
|
511
545
|
DefaultUniformClientContext,
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
34
|
ClientContextTestTransfer: () => ClientContextTestTransfer,
|
|
35
|
+
ClientTest: () => ClientTest,
|
|
35
36
|
ClientUniformText: () => ClientUniformText,
|
|
36
37
|
ContextUpdateTransfer: () => ContextUpdateTransfer,
|
|
37
38
|
DefaultUniformClientContext: () => DefaultUniformClientContext,
|
|
@@ -116,17 +117,48 @@ var ClientContextTestTransfer = ({ event }) => {
|
|
|
116
117
|
return null;
|
|
117
118
|
};
|
|
118
119
|
|
|
119
|
-
// src/components/
|
|
120
|
+
// src/components/ClientTest.tsx
|
|
120
121
|
var import_canvas = require("@uniformdev/canvas");
|
|
121
|
-
var
|
|
122
|
+
var import_next_app_router_shared = require("@uniformdev/next-app-router-shared");
|
|
123
|
+
var import_react4 = require("react");
|
|
124
|
+
var ClientTest = ({ slots, test, context: compositionContext }) => {
|
|
125
|
+
const testSlot = slots[import_canvas.CANVAS_TEST_SLOT];
|
|
126
|
+
const { context } = useUniformContext();
|
|
127
|
+
const [indexToShow, setIndexToShow] = (0, import_react4.useState)(void 0);
|
|
128
|
+
(0, import_react4.useEffect)(() => {
|
|
129
|
+
if (!context || !testSlot) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const { index } = (0, import_next_app_router_shared.evaluateTest)({
|
|
133
|
+
context,
|
|
134
|
+
test,
|
|
135
|
+
compositionContext
|
|
136
|
+
});
|
|
137
|
+
if (index !== null) {
|
|
138
|
+
setIndexToShow(index);
|
|
139
|
+
}
|
|
140
|
+
}, [context, testSlot, test, compositionContext]);
|
|
141
|
+
const slotToShow = (0, import_react4.useMemo)(() => {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
if (typeof indexToShow !== "number" || !testSlot) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return (_b = (_a = testSlot.items[indexToShow]) == null ? void 0 : _a.component) != null ? _b : null;
|
|
147
|
+
}, [indexToShow, testSlot]);
|
|
148
|
+
return (0, import_react4.createElement)(import_react4.Fragment, void 0, slotToShow);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/components/ClientUniformText.tsx
|
|
152
|
+
var import_canvas2 = require("@uniformdev/canvas");
|
|
153
|
+
var import_react6 = __toESM(require("react"));
|
|
122
154
|
|
|
123
155
|
// src/hooks/useQuirks.ts
|
|
124
|
-
var
|
|
156
|
+
var import_react5 = require("react");
|
|
125
157
|
function useQuirks() {
|
|
126
158
|
var _a;
|
|
127
159
|
const { context } = useUniformContext();
|
|
128
|
-
const [quirks, setQuirks] = (0,
|
|
129
|
-
(0,
|
|
160
|
+
const [quirks, setQuirks] = (0, import_react5.useState)((_a = context == null ? void 0 : context.quirks) != null ? _a : {});
|
|
161
|
+
(0, import_react5.useEffect)(() => {
|
|
130
162
|
if (!context) {
|
|
131
163
|
return;
|
|
132
164
|
}
|
|
@@ -154,12 +186,12 @@ var ClientUniformText = ({
|
|
|
154
186
|
}) => {
|
|
155
187
|
const parameter = providedParameter;
|
|
156
188
|
const quirks = useQuirks();
|
|
157
|
-
const rules = (0,
|
|
189
|
+
const rules = (0, import_react6.useMemo)(() => {
|
|
158
190
|
return {
|
|
159
|
-
...(0,
|
|
191
|
+
...(0, import_canvas2.createQuirksVisibilityRule)(quirks)
|
|
160
192
|
};
|
|
161
193
|
}, [quirks]);
|
|
162
|
-
const currentValue = (0,
|
|
194
|
+
const currentValue = (0, import_react6.useMemo)(() => {
|
|
163
195
|
var _a;
|
|
164
196
|
if (!parameter) {
|
|
165
197
|
return void 0;
|
|
@@ -167,7 +199,7 @@ var ClientUniformText = ({
|
|
|
167
199
|
if (!rules.length || !((_a = parameter.conditions) == null ? void 0 : _a.length)) {
|
|
168
200
|
return parameter.value;
|
|
169
201
|
}
|
|
170
|
-
const match = (0,
|
|
202
|
+
const match = (0, import_canvas2.evaluatePropertyCriteria)({
|
|
171
203
|
baseValue: parameter.value,
|
|
172
204
|
conditionalValues: parameter.conditions,
|
|
173
205
|
rules
|
|
@@ -184,10 +216,10 @@ var ClientUniformText = ({
|
|
|
184
216
|
const parameterId = parameter.parameterId;
|
|
185
217
|
const isContextualEditing = Boolean(parameter._contextualEditing);
|
|
186
218
|
if (!isContextualEditing) {
|
|
187
|
-
return /* @__PURE__ */
|
|
219
|
+
return /* @__PURE__ */ import_react6.default.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(currentValue));
|
|
188
220
|
}
|
|
189
221
|
const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
|
|
190
|
-
return /* @__PURE__ */
|
|
222
|
+
return /* @__PURE__ */ import_react6.default.createElement(
|
|
191
223
|
Tag,
|
|
192
224
|
{
|
|
193
225
|
...props,
|
|
@@ -215,24 +247,24 @@ var getParameterAttributes = ({
|
|
|
215
247
|
const type = parameter == null ? void 0 : parameter.type;
|
|
216
248
|
const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
|
|
217
249
|
return {
|
|
218
|
-
[
|
|
219
|
-
[
|
|
220
|
-
[
|
|
221
|
-
[
|
|
222
|
-
[
|
|
223
|
-
[
|
|
250
|
+
[import_canvas2.ATTRIBUTE_COMPONENT_ID]: component._id,
|
|
251
|
+
[import_canvas2.ATTRIBUTE_PARAMETER_ID]: parameter.parameterId,
|
|
252
|
+
[import_canvas2.ATTRIBUTE_PARAMETER_VALUE]: String(value != null ? value : ""),
|
|
253
|
+
[import_canvas2.ATTRIBUTE_PARAMETER_TYPE]: type,
|
|
254
|
+
[import_canvas2.ATTRIBUTE_PLACEHOLDER]: placeholder,
|
|
255
|
+
[import_canvas2.ATTRIBUTE_MULTILINE]: isMultiline,
|
|
224
256
|
contentEditable: isEditable,
|
|
225
257
|
suppressContentEditableWarning: true
|
|
226
258
|
};
|
|
227
259
|
};
|
|
228
260
|
|
|
229
261
|
// src/components/ContextUpdateTransfer.tsx
|
|
230
|
-
var
|
|
262
|
+
var import_react7 = require("react");
|
|
231
263
|
var hasKeys = (obj) => Object.keys(obj).length > 0;
|
|
232
264
|
var ContextUpdateTransfer = ({ update }) => {
|
|
233
265
|
const { context } = useUniformContext();
|
|
234
266
|
const stableUpdate = useStableValue(update, hasKeys);
|
|
235
|
-
(0,
|
|
267
|
+
(0, import_react7.useEffect)(() => {
|
|
236
268
|
if (context && stableUpdate) {
|
|
237
269
|
context.update(stableUpdate);
|
|
238
270
|
}
|
|
@@ -274,18 +306,18 @@ var createClientUniformContext = (options) => {
|
|
|
274
306
|
};
|
|
275
307
|
|
|
276
308
|
// src/hooks/useInitUniformContext.ts
|
|
277
|
-
var
|
|
309
|
+
var import_next_app_router_shared2 = require("@uniformdev/next-app-router-shared");
|
|
278
310
|
var import_js_cookie = __toESM(require("js-cookie"));
|
|
279
311
|
var import_navigation = require("next/navigation");
|
|
280
|
-
var
|
|
312
|
+
var import_react8 = require("react");
|
|
281
313
|
var useInitUniformContext = (callback, compositionMetadata) => {
|
|
282
314
|
const path = (0, import_navigation.usePathname)();
|
|
283
315
|
const searchParams = (0, import_navigation.useSearchParams)();
|
|
284
|
-
const context = (0,
|
|
316
|
+
const context = (0, import_react8.useRef)(void 0);
|
|
285
317
|
if (typeof window !== "undefined" && context.current === void 0) {
|
|
286
318
|
context.current = callback();
|
|
287
319
|
}
|
|
288
|
-
(0,
|
|
320
|
+
(0, import_react8.useEffect)(() => {
|
|
289
321
|
if (typeof window === "undefined" || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
290
322
|
return;
|
|
291
323
|
}
|
|
@@ -293,7 +325,7 @@ var useInitUniformContext = (callback, compositionMetadata) => {
|
|
|
293
325
|
searchParams.forEach((value, key) => {
|
|
294
326
|
url.searchParams.set(key, value);
|
|
295
327
|
});
|
|
296
|
-
const quirkCookie = import_js_cookie.default.get(
|
|
328
|
+
const quirkCookie = import_js_cookie.default.get(import_next_app_router_shared2.UNIFORM_MIDDLEWARE_QUIRK_COOKIE_NAME);
|
|
297
329
|
let quirks = void 0;
|
|
298
330
|
if (quirkCookie) {
|
|
299
331
|
try {
|
|
@@ -302,7 +334,7 @@ var useInitUniformContext = (callback, compositionMetadata) => {
|
|
|
302
334
|
console.error("Error parsing quirk cookie", error);
|
|
303
335
|
}
|
|
304
336
|
}
|
|
305
|
-
import_js_cookie.default.remove(
|
|
337
|
+
import_js_cookie.default.remove(import_next_app_router_shared2.UNIFORM_MIDDLEWARE_QUIRK_COOKIE_NAME);
|
|
306
338
|
context.current.update({
|
|
307
339
|
url,
|
|
308
340
|
compositionMetadata,
|
|
@@ -345,16 +377,16 @@ var DefaultUniformClientContext = ({
|
|
|
345
377
|
};
|
|
346
378
|
|
|
347
379
|
// src/components/Personalize.tsx
|
|
348
|
-
var
|
|
349
|
-
var
|
|
350
|
-
var
|
|
380
|
+
var import_canvas3 = require("@uniformdev/canvas");
|
|
381
|
+
var import_next_app_router_shared3 = require("@uniformdev/next-app-router-shared");
|
|
382
|
+
var import_react10 = require("react");
|
|
351
383
|
|
|
352
384
|
// src/hooks/useScores.ts
|
|
353
|
-
var
|
|
385
|
+
var import_react9 = require("react");
|
|
354
386
|
function useScores() {
|
|
355
387
|
const { context } = useUniformContext();
|
|
356
|
-
const [scores, setScores] = (0,
|
|
357
|
-
(0,
|
|
388
|
+
const [scores, setScores] = (0, import_react9.useState)(context == null ? void 0 : context.scores);
|
|
389
|
+
(0, import_react9.useEffect)(() => {
|
|
358
390
|
if (!context) {
|
|
359
391
|
return;
|
|
360
392
|
}
|
|
@@ -380,16 +412,16 @@ var Personalize = ({
|
|
|
380
412
|
var _a, _b;
|
|
381
413
|
const trackingEventName = (_a = parameters.trackingEventName) == null ? void 0 : _a.value;
|
|
382
414
|
const algorithm = (_b = parameters.algorithm) == null ? void 0 : _b.value;
|
|
383
|
-
const personalizationSlot = slots[
|
|
415
|
+
const personalizationSlot = slots[import_canvas3.CANVAS_PERSONALIZE_SLOT];
|
|
384
416
|
const { context } = useUniformContext();
|
|
385
417
|
const scores = useScores();
|
|
386
418
|
const quirks = useQuirks();
|
|
387
|
-
const [indexesToShow, setIndexesToShow] = (0,
|
|
388
|
-
(0,
|
|
419
|
+
const [indexesToShow, setIndexesToShow] = (0, import_react10.useState)(indexes);
|
|
420
|
+
(0, import_react10.useEffect)(() => {
|
|
389
421
|
if (typeof context === "undefined" || !personalizationSlot) {
|
|
390
422
|
return;
|
|
391
423
|
}
|
|
392
|
-
const result = (0,
|
|
424
|
+
const result = (0, import_next_app_router_shared3.evaluatePersonalization)({
|
|
393
425
|
context,
|
|
394
426
|
compositionContext,
|
|
395
427
|
personalization: {
|
|
@@ -424,34 +456,34 @@ var Personalize = ({
|
|
|
424
456
|
quirks,
|
|
425
457
|
indexesToShow
|
|
426
458
|
]);
|
|
427
|
-
const slotsToShow = (0,
|
|
459
|
+
const slotsToShow = (0, import_react10.useMemo)(() => {
|
|
428
460
|
return indexesToShow.map((key) => {
|
|
429
461
|
var _a2;
|
|
430
462
|
return (_a2 = personalizationSlot == null ? void 0 : personalizationSlot.items[key]) == null ? void 0 : _a2.component;
|
|
431
463
|
});
|
|
432
464
|
}, [indexesToShow, personalizationSlot]);
|
|
433
|
-
return (0,
|
|
465
|
+
return (0, import_react10.createElement)(import_react10.Fragment, void 0, slotsToShow);
|
|
434
466
|
};
|
|
435
467
|
|
|
436
468
|
// src/components/UniformScript.tsx
|
|
437
|
-
var
|
|
469
|
+
var import_canvas4 = require("@uniformdev/canvas");
|
|
438
470
|
var import_navigation3 = require("next/navigation");
|
|
439
|
-
var
|
|
471
|
+
var import_react11 = require("react");
|
|
440
472
|
var UniformScript = () => {
|
|
441
473
|
const router = (0, import_navigation3.useRouter)();
|
|
442
|
-
const needsToRefreshRef = (0,
|
|
443
|
-
const channel = (0,
|
|
474
|
+
const needsToRefreshRef = (0, import_react11.useRef)(false);
|
|
475
|
+
const channel = (0, import_react11.useMemo)(() => {
|
|
444
476
|
var _a;
|
|
445
477
|
if (typeof window === "undefined") {
|
|
446
478
|
return;
|
|
447
479
|
}
|
|
448
|
-
const instance = (0,
|
|
480
|
+
const instance = (0, import_canvas4.createCanvasChannel)({
|
|
449
481
|
broadcastTo: [(_a = window.opener) != null ? _a : window.top],
|
|
450
482
|
listenTo: [window]
|
|
451
483
|
});
|
|
452
484
|
return instance;
|
|
453
485
|
}, []);
|
|
454
|
-
(0,
|
|
486
|
+
(0, import_react11.useEffect)(() => {
|
|
455
487
|
if (!channel) {
|
|
456
488
|
return;
|
|
457
489
|
}
|
|
@@ -468,13 +500,13 @@ var UniformScript = () => {
|
|
|
468
500
|
unsubscribeFromEditorUpdates();
|
|
469
501
|
};
|
|
470
502
|
}, [channel, router]);
|
|
471
|
-
(0,
|
|
503
|
+
(0, import_react11.useEffect)(() => {
|
|
472
504
|
if (typeof window === "undefined") {
|
|
473
505
|
return;
|
|
474
506
|
}
|
|
475
507
|
const existing = document.getElementById("uniform-script");
|
|
476
508
|
if (!existing) {
|
|
477
|
-
const textHost = (0,
|
|
509
|
+
const textHost = (0, import_canvas4.isAllowedReferrer)(window.document.referrer) ? window.document.referrer : "https://uniform.app/";
|
|
478
510
|
window.__UNIFORM_CONTEXTUAL_EDITING__ = {
|
|
479
511
|
framework: "React",
|
|
480
512
|
version: 2
|
|
@@ -489,7 +521,7 @@ var UniformScript = () => {
|
|
|
489
521
|
document.head.appendChild(script);
|
|
490
522
|
}
|
|
491
523
|
}, []);
|
|
492
|
-
(0,
|
|
524
|
+
(0, import_react11.useEffect)(() => {
|
|
493
525
|
const handleBlurChange = () => {
|
|
494
526
|
if (needsToRefreshRef.current) {
|
|
495
527
|
router.refresh();
|
|
@@ -505,25 +537,25 @@ var UniformScript = () => {
|
|
|
505
537
|
};
|
|
506
538
|
|
|
507
539
|
// src/components/VisibilityRulesWrapperClient.tsx
|
|
508
|
-
var
|
|
509
|
-
var
|
|
540
|
+
var import_canvas5 = require("@uniformdev/canvas");
|
|
541
|
+
var import_react12 = __toESM(require("react"));
|
|
510
542
|
var VisibilityRulesWrapperClient = ({
|
|
511
543
|
parameter,
|
|
512
544
|
initialIsVisible,
|
|
513
545
|
children
|
|
514
546
|
}) => {
|
|
515
|
-
const [isVisible, setIsVisible] = (0,
|
|
516
|
-
const [visibleSource, setVisibleSource] = (0,
|
|
547
|
+
const [isVisible, setIsVisible] = (0, import_react12.useState)(initialIsVisible);
|
|
548
|
+
const [visibleSource, setVisibleSource] = (0, import_react12.useState)(
|
|
517
549
|
initialIsVisible === null ? "unknown" : "server"
|
|
518
550
|
);
|
|
519
551
|
const quirks = useQuirks();
|
|
520
|
-
const rules = (0,
|
|
552
|
+
const rules = (0, import_react12.useMemo)(() => {
|
|
521
553
|
return {
|
|
522
|
-
...(0,
|
|
554
|
+
...(0, import_canvas5.createQuirksVisibilityRule)(quirks)
|
|
523
555
|
};
|
|
524
556
|
}, [quirks]);
|
|
525
|
-
(0,
|
|
526
|
-
const result = (0,
|
|
557
|
+
(0, import_react12.useEffect)(() => {
|
|
558
|
+
const result = (0, import_canvas5.evaluateNodeVisibilityParameter)({
|
|
527
559
|
rules,
|
|
528
560
|
parameter
|
|
529
561
|
});
|
|
@@ -533,11 +565,12 @@ var VisibilityRulesWrapperClient = ({
|
|
|
533
565
|
setIsVisible(result);
|
|
534
566
|
setVisibleSource("client");
|
|
535
567
|
}, [initialIsVisible, visibleSource, parameter, rules]);
|
|
536
|
-
return isVisible ? /* @__PURE__ */
|
|
568
|
+
return isVisible ? /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, children) : null;
|
|
537
569
|
};
|
|
538
570
|
// Annotate the CommonJS export names for ESM import in node:
|
|
539
571
|
0 && (module.exports = {
|
|
540
572
|
ClientContextTestTransfer,
|
|
573
|
+
ClientTest,
|
|
541
574
|
ClientUniformText,
|
|
542
575
|
ContextUpdateTransfer,
|
|
543
576
|
DefaultUniformClientContext,
|
package/dist/index.mjs
CHANGED
|
@@ -70,6 +70,39 @@ var ClientContextTestTransfer = ({ event }) => {
|
|
|
70
70
|
return null;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
// src/components/ClientTest.tsx
|
|
74
|
+
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
75
|
+
import {
|
|
76
|
+
evaluateTest
|
|
77
|
+
} from "@uniformdev/next-app-router-shared";
|
|
78
|
+
import { createElement, Fragment, useEffect as useEffect4, useMemo, useState as useState3 } from "react";
|
|
79
|
+
var ClientTest = ({ slots, test, context: compositionContext }) => {
|
|
80
|
+
const testSlot = slots[CANVAS_TEST_SLOT];
|
|
81
|
+
const { context } = useUniformContext();
|
|
82
|
+
const [indexToShow, setIndexToShow] = useState3(void 0);
|
|
83
|
+
useEffect4(() => {
|
|
84
|
+
if (!context || !testSlot) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const { index } = evaluateTest({
|
|
88
|
+
context,
|
|
89
|
+
test,
|
|
90
|
+
compositionContext
|
|
91
|
+
});
|
|
92
|
+
if (index !== null) {
|
|
93
|
+
setIndexToShow(index);
|
|
94
|
+
}
|
|
95
|
+
}, [context, testSlot, test, compositionContext]);
|
|
96
|
+
const slotToShow = useMemo(() => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
if (typeof indexToShow !== "number" || !testSlot) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return (_b = (_a = testSlot.items[indexToShow]) == null ? void 0 : _a.component) != null ? _b : null;
|
|
102
|
+
}, [indexToShow, testSlot]);
|
|
103
|
+
return createElement(Fragment, void 0, slotToShow);
|
|
104
|
+
};
|
|
105
|
+
|
|
73
106
|
// src/components/ClientUniformText.tsx
|
|
74
107
|
import {
|
|
75
108
|
ATTRIBUTE_COMPONENT_ID,
|
|
@@ -81,15 +114,15 @@ import {
|
|
|
81
114
|
createQuirksVisibilityRule,
|
|
82
115
|
evaluatePropertyCriteria
|
|
83
116
|
} from "@uniformdev/canvas";
|
|
84
|
-
import React, { useMemo } from "react";
|
|
117
|
+
import React, { useMemo as useMemo2 } from "react";
|
|
85
118
|
|
|
86
119
|
// src/hooks/useQuirks.ts
|
|
87
|
-
import { useEffect as
|
|
120
|
+
import { useEffect as useEffect5, useState as useState4 } from "react";
|
|
88
121
|
function useQuirks() {
|
|
89
122
|
var _a;
|
|
90
123
|
const { context } = useUniformContext();
|
|
91
|
-
const [quirks, setQuirks] =
|
|
92
|
-
|
|
124
|
+
const [quirks, setQuirks] = useState4((_a = context == null ? void 0 : context.quirks) != null ? _a : {});
|
|
125
|
+
useEffect5(() => {
|
|
93
126
|
if (!context) {
|
|
94
127
|
return;
|
|
95
128
|
}
|
|
@@ -117,12 +150,12 @@ var ClientUniformText = ({
|
|
|
117
150
|
}) => {
|
|
118
151
|
const parameter = providedParameter;
|
|
119
152
|
const quirks = useQuirks();
|
|
120
|
-
const rules =
|
|
153
|
+
const rules = useMemo2(() => {
|
|
121
154
|
return {
|
|
122
155
|
...createQuirksVisibilityRule(quirks)
|
|
123
156
|
};
|
|
124
157
|
}, [quirks]);
|
|
125
|
-
const currentValue =
|
|
158
|
+
const currentValue = useMemo2(() => {
|
|
126
159
|
var _a;
|
|
127
160
|
if (!parameter) {
|
|
128
161
|
return void 0;
|
|
@@ -190,12 +223,12 @@ var getParameterAttributes = ({
|
|
|
190
223
|
};
|
|
191
224
|
|
|
192
225
|
// src/components/ContextUpdateTransfer.tsx
|
|
193
|
-
import { useEffect as
|
|
226
|
+
import { useEffect as useEffect6 } from "react";
|
|
194
227
|
var hasKeys = (obj) => Object.keys(obj).length > 0;
|
|
195
228
|
var ContextUpdateTransfer = ({ update }) => {
|
|
196
229
|
const { context } = useUniformContext();
|
|
197
230
|
const stableUpdate = useStableValue(update, hasKeys);
|
|
198
|
-
|
|
231
|
+
useEffect6(() => {
|
|
199
232
|
if (context && stableUpdate) {
|
|
200
233
|
context.update(stableUpdate);
|
|
201
234
|
}
|
|
@@ -243,7 +276,7 @@ var createClientUniformContext = (options) => {
|
|
|
243
276
|
import { UNIFORM_MIDDLEWARE_QUIRK_COOKIE_NAME } from "@uniformdev/next-app-router-shared";
|
|
244
277
|
import Cookies from "js-cookie";
|
|
245
278
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
246
|
-
import { useEffect as
|
|
279
|
+
import { useEffect as useEffect7, useRef as useRef3 } from "react";
|
|
247
280
|
var useInitUniformContext = (callback, compositionMetadata) => {
|
|
248
281
|
const path = usePathname();
|
|
249
282
|
const searchParams = useSearchParams();
|
|
@@ -251,7 +284,7 @@ var useInitUniformContext = (callback, compositionMetadata) => {
|
|
|
251
284
|
if (typeof window !== "undefined" && context.current === void 0) {
|
|
252
285
|
context.current = callback();
|
|
253
286
|
}
|
|
254
|
-
|
|
287
|
+
useEffect7(() => {
|
|
255
288
|
if (typeof window === "undefined" || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
256
289
|
return;
|
|
257
290
|
}
|
|
@@ -313,14 +346,14 @@ var DefaultUniformClientContext = ({
|
|
|
313
346
|
// src/components/Personalize.tsx
|
|
314
347
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
315
348
|
import { evaluatePersonalization } from "@uniformdev/next-app-router-shared";
|
|
316
|
-
import { createElement, Fragment, useEffect as
|
|
349
|
+
import { createElement as createElement2, Fragment as Fragment2, useEffect as useEffect9, useMemo as useMemo3, useState as useState6 } from "react";
|
|
317
350
|
|
|
318
351
|
// src/hooks/useScores.ts
|
|
319
|
-
import { useEffect as
|
|
352
|
+
import { useEffect as useEffect8, useState as useState5 } from "react";
|
|
320
353
|
function useScores() {
|
|
321
354
|
const { context } = useUniformContext();
|
|
322
|
-
const [scores, setScores] =
|
|
323
|
-
|
|
355
|
+
const [scores, setScores] = useState5(context == null ? void 0 : context.scores);
|
|
356
|
+
useEffect8(() => {
|
|
324
357
|
if (!context) {
|
|
325
358
|
return;
|
|
326
359
|
}
|
|
@@ -350,8 +383,8 @@ var Personalize = ({
|
|
|
350
383
|
const { context } = useUniformContext();
|
|
351
384
|
const scores = useScores();
|
|
352
385
|
const quirks = useQuirks();
|
|
353
|
-
const [indexesToShow, setIndexesToShow] =
|
|
354
|
-
|
|
386
|
+
const [indexesToShow, setIndexesToShow] = useState6(indexes);
|
|
387
|
+
useEffect9(() => {
|
|
355
388
|
if (typeof context === "undefined" || !personalizationSlot) {
|
|
356
389
|
return;
|
|
357
390
|
}
|
|
@@ -390,23 +423,23 @@ var Personalize = ({
|
|
|
390
423
|
quirks,
|
|
391
424
|
indexesToShow
|
|
392
425
|
]);
|
|
393
|
-
const slotsToShow =
|
|
426
|
+
const slotsToShow = useMemo3(() => {
|
|
394
427
|
return indexesToShow.map((key) => {
|
|
395
428
|
var _a2;
|
|
396
429
|
return (_a2 = personalizationSlot == null ? void 0 : personalizationSlot.items[key]) == null ? void 0 : _a2.component;
|
|
397
430
|
});
|
|
398
431
|
}, [indexesToShow, personalizationSlot]);
|
|
399
|
-
return
|
|
432
|
+
return createElement2(Fragment2, void 0, slotsToShow);
|
|
400
433
|
};
|
|
401
434
|
|
|
402
435
|
// src/components/UniformScript.tsx
|
|
403
436
|
import { createCanvasChannel, isAllowedReferrer } from "@uniformdev/canvas";
|
|
404
437
|
import { useRouter as useRouter2 } from "next/navigation";
|
|
405
|
-
import { useEffect as
|
|
438
|
+
import { useEffect as useEffect10, useMemo as useMemo4, useRef as useRef4 } from "react";
|
|
406
439
|
var UniformScript = () => {
|
|
407
440
|
const router = useRouter2();
|
|
408
441
|
const needsToRefreshRef = useRef4(false);
|
|
409
|
-
const channel =
|
|
442
|
+
const channel = useMemo4(() => {
|
|
410
443
|
var _a;
|
|
411
444
|
if (typeof window === "undefined") {
|
|
412
445
|
return;
|
|
@@ -417,7 +450,7 @@ var UniformScript = () => {
|
|
|
417
450
|
});
|
|
418
451
|
return instance;
|
|
419
452
|
}, []);
|
|
420
|
-
|
|
453
|
+
useEffect10(() => {
|
|
421
454
|
if (!channel) {
|
|
422
455
|
return;
|
|
423
456
|
}
|
|
@@ -434,7 +467,7 @@ var UniformScript = () => {
|
|
|
434
467
|
unsubscribeFromEditorUpdates();
|
|
435
468
|
};
|
|
436
469
|
}, [channel, router]);
|
|
437
|
-
|
|
470
|
+
useEffect10(() => {
|
|
438
471
|
if (typeof window === "undefined") {
|
|
439
472
|
return;
|
|
440
473
|
}
|
|
@@ -455,7 +488,7 @@ var UniformScript = () => {
|
|
|
455
488
|
document.head.appendChild(script);
|
|
456
489
|
}
|
|
457
490
|
}, []);
|
|
458
|
-
|
|
491
|
+
useEffect10(() => {
|
|
459
492
|
const handleBlurChange = () => {
|
|
460
493
|
if (needsToRefreshRef.current) {
|
|
461
494
|
router.refresh();
|
|
@@ -475,23 +508,23 @@ import {
|
|
|
475
508
|
createQuirksVisibilityRule as createQuirksVisibilityRule2,
|
|
476
509
|
evaluateNodeVisibilityParameter
|
|
477
510
|
} from "@uniformdev/canvas";
|
|
478
|
-
import React2, { useEffect as
|
|
511
|
+
import React2, { useEffect as useEffect11, useMemo as useMemo5, useState as useState7 } from "react";
|
|
479
512
|
var VisibilityRulesWrapperClient = ({
|
|
480
513
|
parameter,
|
|
481
514
|
initialIsVisible,
|
|
482
515
|
children
|
|
483
516
|
}) => {
|
|
484
|
-
const [isVisible, setIsVisible] =
|
|
485
|
-
const [visibleSource, setVisibleSource] =
|
|
517
|
+
const [isVisible, setIsVisible] = useState7(initialIsVisible);
|
|
518
|
+
const [visibleSource, setVisibleSource] = useState7(
|
|
486
519
|
initialIsVisible === null ? "unknown" : "server"
|
|
487
520
|
);
|
|
488
521
|
const quirks = useQuirks();
|
|
489
|
-
const rules =
|
|
522
|
+
const rules = useMemo5(() => {
|
|
490
523
|
return {
|
|
491
524
|
...createQuirksVisibilityRule2(quirks)
|
|
492
525
|
};
|
|
493
526
|
}, [quirks]);
|
|
494
|
-
|
|
527
|
+
useEffect11(() => {
|
|
495
528
|
const result = evaluateNodeVisibilityParameter({
|
|
496
529
|
rules,
|
|
497
530
|
parameter
|
|
@@ -506,6 +539,7 @@ var VisibilityRulesWrapperClient = ({
|
|
|
506
539
|
};
|
|
507
540
|
export {
|
|
508
541
|
ClientContextTestTransfer,
|
|
542
|
+
ClientTest,
|
|
509
543
|
ClientUniformText,
|
|
510
544
|
ContextUpdateTransfer,
|
|
511
545
|
DefaultUniformClientContext,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/next-app-router-client",
|
|
3
|
-
"version": "20.50.1
|
|
3
|
+
"version": "20.50.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"vitest": "3.2.4"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@uniformdev/canvas": "20.50.1
|
|
40
|
-
"@uniformdev/canvas-react": "20.50.1
|
|
41
|
-
"@uniformdev/context": "20.50.1
|
|
42
|
-
"@uniformdev/next-app-router-shared": "20.50.1
|
|
39
|
+
"@uniformdev/canvas": "20.50.1",
|
|
40
|
+
"@uniformdev/canvas-react": "20.50.1",
|
|
41
|
+
"@uniformdev/context": "20.50.1",
|
|
42
|
+
"@uniformdev/next-app-router-shared": "20.50.1",
|
|
43
43
|
"js-cookie": "3.0.5"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "696a2df1399a5b68564f931286806b2597f6fa64"
|
|
57
57
|
}
|