@contentful/experiences-visual-editor-react 1.39.0-alpha-20250528T1342-e28bc3d.0 → 1.39.0-alpha-20250603T1404-5a5eb4e.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.js +377 -222
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +687 -233
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -35291,6 +35291,40 @@ function baseToString(value) {
|
|
|
35291
35291
|
return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
|
|
35292
35292
|
}
|
|
35293
35293
|
|
|
35294
|
+
/** Used to match a single whitespace character. */
|
|
35295
|
+
var reWhitespace = /\s/;
|
|
35296
|
+
|
|
35297
|
+
/**
|
|
35298
|
+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
35299
|
+
* character of `string`.
|
|
35300
|
+
*
|
|
35301
|
+
* @private
|
|
35302
|
+
* @param {string} string The string to inspect.
|
|
35303
|
+
* @returns {number} Returns the index of the last non-whitespace character.
|
|
35304
|
+
*/
|
|
35305
|
+
function trimmedEndIndex(string) {
|
|
35306
|
+
var index = string.length;
|
|
35307
|
+
|
|
35308
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
35309
|
+
return index;
|
|
35310
|
+
}
|
|
35311
|
+
|
|
35312
|
+
/** Used to match leading whitespace. */
|
|
35313
|
+
var reTrimStart = /^\s+/;
|
|
35314
|
+
|
|
35315
|
+
/**
|
|
35316
|
+
* The base implementation of `_.trim`.
|
|
35317
|
+
*
|
|
35318
|
+
* @private
|
|
35319
|
+
* @param {string} string The string to trim.
|
|
35320
|
+
* @returns {string} Returns the trimmed string.
|
|
35321
|
+
*/
|
|
35322
|
+
function baseTrim(string) {
|
|
35323
|
+
return string
|
|
35324
|
+
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
35325
|
+
: string;
|
|
35326
|
+
}
|
|
35327
|
+
|
|
35294
35328
|
/**
|
|
35295
35329
|
* Checks if `value` is the
|
|
35296
35330
|
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
@@ -35321,6 +35355,65 @@ function isObject(value) {
|
|
|
35321
35355
|
return value != null && (type == 'object' || type == 'function');
|
|
35322
35356
|
}
|
|
35323
35357
|
|
|
35358
|
+
/** Used as references for various `Number` constants. */
|
|
35359
|
+
var NAN = 0 / 0;
|
|
35360
|
+
|
|
35361
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
35362
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
35363
|
+
|
|
35364
|
+
/** Used to detect binary string values. */
|
|
35365
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
35366
|
+
|
|
35367
|
+
/** Used to detect octal string values. */
|
|
35368
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
35369
|
+
|
|
35370
|
+
/** Built-in method references without a dependency on `root`. */
|
|
35371
|
+
var freeParseInt = parseInt;
|
|
35372
|
+
|
|
35373
|
+
/**
|
|
35374
|
+
* Converts `value` to a number.
|
|
35375
|
+
*
|
|
35376
|
+
* @static
|
|
35377
|
+
* @memberOf _
|
|
35378
|
+
* @since 4.0.0
|
|
35379
|
+
* @category Lang
|
|
35380
|
+
* @param {*} value The value to process.
|
|
35381
|
+
* @returns {number} Returns the number.
|
|
35382
|
+
* @example
|
|
35383
|
+
*
|
|
35384
|
+
* _.toNumber(3.2);
|
|
35385
|
+
* // => 3.2
|
|
35386
|
+
*
|
|
35387
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
35388
|
+
* // => 5e-324
|
|
35389
|
+
*
|
|
35390
|
+
* _.toNumber(Infinity);
|
|
35391
|
+
* // => Infinity
|
|
35392
|
+
*
|
|
35393
|
+
* _.toNumber('3.2');
|
|
35394
|
+
* // => 3.2
|
|
35395
|
+
*/
|
|
35396
|
+
function toNumber(value) {
|
|
35397
|
+
if (typeof value == 'number') {
|
|
35398
|
+
return value;
|
|
35399
|
+
}
|
|
35400
|
+
if (isSymbol(value)) {
|
|
35401
|
+
return NAN;
|
|
35402
|
+
}
|
|
35403
|
+
if (isObject(value)) {
|
|
35404
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
35405
|
+
value = isObject(other) ? (other + '') : other;
|
|
35406
|
+
}
|
|
35407
|
+
if (typeof value != 'string') {
|
|
35408
|
+
return value === 0 ? value : +value;
|
|
35409
|
+
}
|
|
35410
|
+
value = baseTrim(value);
|
|
35411
|
+
var isBinary = reIsBinary.test(value);
|
|
35412
|
+
return (isBinary || reIsOctal.test(value))
|
|
35413
|
+
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
35414
|
+
: (reIsBadHex.test(value) ? NAN : +value);
|
|
35415
|
+
}
|
|
35416
|
+
|
|
35324
35417
|
/**
|
|
35325
35418
|
* This method returns the first argument it receives.
|
|
35326
35419
|
*
|
|
@@ -35812,7 +35905,7 @@ function copyObject(source, props, object, customizer) {
|
|
|
35812
35905
|
}
|
|
35813
35906
|
|
|
35814
35907
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
35815
|
-
var nativeMax = Math.max;
|
|
35908
|
+
var nativeMax$1 = Math.max;
|
|
35816
35909
|
|
|
35817
35910
|
/**
|
|
35818
35911
|
* A specialized version of `baseRest` which transforms the rest array.
|
|
@@ -35824,11 +35917,11 @@ var nativeMax = Math.max;
|
|
|
35824
35917
|
* @returns {Function} Returns the new function.
|
|
35825
35918
|
*/
|
|
35826
35919
|
function overRest(func, start, transform) {
|
|
35827
|
-
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
|
35920
|
+
start = nativeMax$1(start === undefined ? (func.length - 1) : start, 0);
|
|
35828
35921
|
return function() {
|
|
35829
35922
|
var args = arguments,
|
|
35830
35923
|
index = -1,
|
|
35831
|
-
length = nativeMax(args.length - start, 0),
|
|
35924
|
+
length = nativeMax$1(args.length - start, 0),
|
|
35832
35925
|
array = Array(length);
|
|
35833
35926
|
|
|
35834
35927
|
while (++index < length) {
|
|
@@ -36768,7 +36861,7 @@ MapCache.prototype.has = mapCacheHas;
|
|
|
36768
36861
|
MapCache.prototype.set = mapCacheSet;
|
|
36769
36862
|
|
|
36770
36863
|
/** Error message constants. */
|
|
36771
|
-
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
36864
|
+
var FUNC_ERROR_TEXT$1 = 'Expected a function';
|
|
36772
36865
|
|
|
36773
36866
|
/**
|
|
36774
36867
|
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
@@ -36816,7 +36909,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
|
|
36816
36909
|
*/
|
|
36817
36910
|
function memoize(func, resolver) {
|
|
36818
36911
|
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
|
36819
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
36912
|
+
throw new TypeError(FUNC_ERROR_TEXT$1);
|
|
36820
36913
|
}
|
|
36821
36914
|
var memoized = function() {
|
|
36822
36915
|
var args = arguments,
|
|
@@ -38433,6 +38526,212 @@ function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
|
38433
38526
|
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
|
38434
38527
|
}
|
|
38435
38528
|
|
|
38529
|
+
/**
|
|
38530
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
38531
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
38532
|
+
*
|
|
38533
|
+
* @static
|
|
38534
|
+
* @memberOf _
|
|
38535
|
+
* @since 2.4.0
|
|
38536
|
+
* @category Date
|
|
38537
|
+
* @returns {number} Returns the timestamp.
|
|
38538
|
+
* @example
|
|
38539
|
+
*
|
|
38540
|
+
* _.defer(function(stamp) {
|
|
38541
|
+
* console.log(_.now() - stamp);
|
|
38542
|
+
* }, _.now());
|
|
38543
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
38544
|
+
*/
|
|
38545
|
+
var now = function() {
|
|
38546
|
+
return root.Date.now();
|
|
38547
|
+
};
|
|
38548
|
+
|
|
38549
|
+
/** Error message constants. */
|
|
38550
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
38551
|
+
|
|
38552
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
38553
|
+
var nativeMax = Math.max,
|
|
38554
|
+
nativeMin = Math.min;
|
|
38555
|
+
|
|
38556
|
+
/**
|
|
38557
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
38558
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
38559
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
38560
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
38561
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
38562
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
38563
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
38564
|
+
* calls to the debounced function return the result of the last `func`
|
|
38565
|
+
* invocation.
|
|
38566
|
+
*
|
|
38567
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
38568
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
38569
|
+
* is invoked more than once during the `wait` timeout.
|
|
38570
|
+
*
|
|
38571
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
38572
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
38573
|
+
*
|
|
38574
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
38575
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
38576
|
+
*
|
|
38577
|
+
* @static
|
|
38578
|
+
* @memberOf _
|
|
38579
|
+
* @since 0.1.0
|
|
38580
|
+
* @category Function
|
|
38581
|
+
* @param {Function} func The function to debounce.
|
|
38582
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
38583
|
+
* @param {Object} [options={}] The options object.
|
|
38584
|
+
* @param {boolean} [options.leading=false]
|
|
38585
|
+
* Specify invoking on the leading edge of the timeout.
|
|
38586
|
+
* @param {number} [options.maxWait]
|
|
38587
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
38588
|
+
* @param {boolean} [options.trailing=true]
|
|
38589
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
38590
|
+
* @returns {Function} Returns the new debounced function.
|
|
38591
|
+
* @example
|
|
38592
|
+
*
|
|
38593
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
38594
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
38595
|
+
*
|
|
38596
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
38597
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
38598
|
+
* 'leading': true,
|
|
38599
|
+
* 'trailing': false
|
|
38600
|
+
* }));
|
|
38601
|
+
*
|
|
38602
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
38603
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
38604
|
+
* var source = new EventSource('/stream');
|
|
38605
|
+
* jQuery(source).on('message', debounced);
|
|
38606
|
+
*
|
|
38607
|
+
* // Cancel the trailing debounced invocation.
|
|
38608
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
38609
|
+
*/
|
|
38610
|
+
function debounce(func, wait, options) {
|
|
38611
|
+
var lastArgs,
|
|
38612
|
+
lastThis,
|
|
38613
|
+
maxWait,
|
|
38614
|
+
result,
|
|
38615
|
+
timerId,
|
|
38616
|
+
lastCallTime,
|
|
38617
|
+
lastInvokeTime = 0,
|
|
38618
|
+
leading = false,
|
|
38619
|
+
maxing = false,
|
|
38620
|
+
trailing = true;
|
|
38621
|
+
|
|
38622
|
+
if (typeof func != 'function') {
|
|
38623
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
38624
|
+
}
|
|
38625
|
+
wait = toNumber(wait) || 0;
|
|
38626
|
+
if (isObject(options)) {
|
|
38627
|
+
leading = !!options.leading;
|
|
38628
|
+
maxing = 'maxWait' in options;
|
|
38629
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
38630
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
38631
|
+
}
|
|
38632
|
+
|
|
38633
|
+
function invokeFunc(time) {
|
|
38634
|
+
var args = lastArgs,
|
|
38635
|
+
thisArg = lastThis;
|
|
38636
|
+
|
|
38637
|
+
lastArgs = lastThis = undefined;
|
|
38638
|
+
lastInvokeTime = time;
|
|
38639
|
+
result = func.apply(thisArg, args);
|
|
38640
|
+
return result;
|
|
38641
|
+
}
|
|
38642
|
+
|
|
38643
|
+
function leadingEdge(time) {
|
|
38644
|
+
// Reset any `maxWait` timer.
|
|
38645
|
+
lastInvokeTime = time;
|
|
38646
|
+
// Start the timer for the trailing edge.
|
|
38647
|
+
timerId = setTimeout(timerExpired, wait);
|
|
38648
|
+
// Invoke the leading edge.
|
|
38649
|
+
return leading ? invokeFunc(time) : result;
|
|
38650
|
+
}
|
|
38651
|
+
|
|
38652
|
+
function remainingWait(time) {
|
|
38653
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
38654
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
|
38655
|
+
timeWaiting = wait - timeSinceLastCall;
|
|
38656
|
+
|
|
38657
|
+
return maxing
|
|
38658
|
+
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
38659
|
+
: timeWaiting;
|
|
38660
|
+
}
|
|
38661
|
+
|
|
38662
|
+
function shouldInvoke(time) {
|
|
38663
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
38664
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
|
38665
|
+
|
|
38666
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
38667
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
38668
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
38669
|
+
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
38670
|
+
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
38671
|
+
}
|
|
38672
|
+
|
|
38673
|
+
function timerExpired() {
|
|
38674
|
+
var time = now();
|
|
38675
|
+
if (shouldInvoke(time)) {
|
|
38676
|
+
return trailingEdge(time);
|
|
38677
|
+
}
|
|
38678
|
+
// Restart the timer.
|
|
38679
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
38680
|
+
}
|
|
38681
|
+
|
|
38682
|
+
function trailingEdge(time) {
|
|
38683
|
+
timerId = undefined;
|
|
38684
|
+
|
|
38685
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
38686
|
+
// debounced at least once.
|
|
38687
|
+
if (trailing && lastArgs) {
|
|
38688
|
+
return invokeFunc(time);
|
|
38689
|
+
}
|
|
38690
|
+
lastArgs = lastThis = undefined;
|
|
38691
|
+
return result;
|
|
38692
|
+
}
|
|
38693
|
+
|
|
38694
|
+
function cancel() {
|
|
38695
|
+
if (timerId !== undefined) {
|
|
38696
|
+
clearTimeout(timerId);
|
|
38697
|
+
}
|
|
38698
|
+
lastInvokeTime = 0;
|
|
38699
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
38700
|
+
}
|
|
38701
|
+
|
|
38702
|
+
function flush() {
|
|
38703
|
+
return timerId === undefined ? result : trailingEdge(now());
|
|
38704
|
+
}
|
|
38705
|
+
|
|
38706
|
+
function debounced() {
|
|
38707
|
+
var time = now(),
|
|
38708
|
+
isInvoking = shouldInvoke(time);
|
|
38709
|
+
|
|
38710
|
+
lastArgs = arguments;
|
|
38711
|
+
lastThis = this;
|
|
38712
|
+
lastCallTime = time;
|
|
38713
|
+
|
|
38714
|
+
if (isInvoking) {
|
|
38715
|
+
if (timerId === undefined) {
|
|
38716
|
+
return leadingEdge(lastCallTime);
|
|
38717
|
+
}
|
|
38718
|
+
if (maxing) {
|
|
38719
|
+
// Handle invocations in a tight loop.
|
|
38720
|
+
clearTimeout(timerId);
|
|
38721
|
+
timerId = setTimeout(timerExpired, wait);
|
|
38722
|
+
return invokeFunc(lastCallTime);
|
|
38723
|
+
}
|
|
38724
|
+
}
|
|
38725
|
+
if (timerId === undefined) {
|
|
38726
|
+
timerId = setTimeout(timerExpired, wait);
|
|
38727
|
+
}
|
|
38728
|
+
return result;
|
|
38729
|
+
}
|
|
38730
|
+
debounced.cancel = cancel;
|
|
38731
|
+
debounced.flush = flush;
|
|
38732
|
+
return debounced;
|
|
38733
|
+
}
|
|
38734
|
+
|
|
38436
38735
|
/**
|
|
38437
38736
|
* Gets the last element of `array`.
|
|
38438
38737
|
*
|
|
@@ -38710,6 +39009,7 @@ const OUTGOING_EVENTS = {
|
|
|
38710
39009
|
OutsideCanvasClick: 'outsideCanvasClick',
|
|
38711
39010
|
SDKFeatures: 'sdkFeatures',
|
|
38712
39011
|
RequestEntities: 'REQUEST_ENTITIES',
|
|
39012
|
+
CanvasGeometryUpdated: 'canvasGeometryUpdated',
|
|
38713
39013
|
};
|
|
38714
39014
|
const INCOMING_EVENTS$1 = {
|
|
38715
39015
|
RequestEditorMode: 'requestEditorMode',
|
|
@@ -44712,17 +45012,16 @@ const PrimitiveValueSchema$1 = z.union([
|
|
|
44712
45012
|
z.record(z.any(), z.any()),
|
|
44713
45013
|
z.undefined(),
|
|
44714
45014
|
]);
|
|
45015
|
+
const UsedComponentsSchema$1 = z.array(z.object({
|
|
45016
|
+
sys: z.object({
|
|
45017
|
+
type: z.literal('Link'),
|
|
45018
|
+
id: z.string(),
|
|
45019
|
+
linkType: z.literal('Entry'),
|
|
45020
|
+
}),
|
|
45021
|
+
}));
|
|
44715
45022
|
const uuidKeySchema$1 = z
|
|
44716
45023
|
.string()
|
|
44717
45024
|
.regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });
|
|
44718
|
-
/**
|
|
44719
|
-
* Property keys for imported components have a limit of 32 characters (to be implemented) while
|
|
44720
|
-
* property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).
|
|
44721
|
-
* Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
|
|
44722
|
-
*/
|
|
44723
|
-
const propertyKeySchema$1 = z
|
|
44724
|
-
.string()
|
|
44725
|
-
.regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
|
|
44726
45025
|
const DataSourceSchema$1 = z.record(uuidKeySchema$1, z.object({
|
|
44727
45026
|
sys: z.object({
|
|
44728
45027
|
type: z.literal('Link'),
|
|
@@ -44730,7 +45029,62 @@ const DataSourceSchema$1 = z.record(uuidKeySchema$1, z.object({
|
|
|
44730
45029
|
linkType: z.enum(['Entry', 'Asset']),
|
|
44731
45030
|
}),
|
|
44732
45031
|
}));
|
|
45032
|
+
const UnboundValuesSchema$1 = z.record(uuidKeySchema$1, z.object({
|
|
45033
|
+
value: PrimitiveValueSchema$1,
|
|
45034
|
+
}));
|
|
45035
|
+
/**
|
|
45036
|
+
* Property keys for imported components have a limit of 32 characters (to be implemented) while
|
|
45037
|
+
* property keys for patterns have a limit of 54 characters (<32-char-variable-name>_<21-char-nanoid-id>).
|
|
45038
|
+
* Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
|
|
45039
|
+
*/
|
|
45040
|
+
const propertyKeySchema$1 = z
|
|
45041
|
+
.string()
|
|
45042
|
+
.regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
|
|
45043
|
+
const ComponentTreeNodeIdSchema$1 = z
|
|
45044
|
+
.string()
|
|
45045
|
+
.regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
|
|
45046
|
+
const breakpointsRefinement$1 = (value, ctx) => {
|
|
45047
|
+
if (!value.length || value[0].query !== '*') {
|
|
45048
|
+
ctx.addIssue({
|
|
45049
|
+
code: z.ZodIssueCode.custom,
|
|
45050
|
+
message: `The first breakpoint should include the following attributes: { "query": "*" }`,
|
|
45051
|
+
});
|
|
45052
|
+
}
|
|
45053
|
+
const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
|
|
45054
|
+
// check if the current breakpoint id is found in the rest of the array
|
|
45055
|
+
const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
|
|
45056
|
+
return breakpointIndex !== currentBreakpointIndex;
|
|
45057
|
+
});
|
|
45058
|
+
if (hasDuplicateIds) {
|
|
45059
|
+
ctx.addIssue({
|
|
45060
|
+
code: z.ZodIssueCode.custom,
|
|
45061
|
+
message: `Breakpoint IDs must be unique`,
|
|
45062
|
+
});
|
|
45063
|
+
}
|
|
45064
|
+
// Extract the queries boundary by removing the special characters around it
|
|
45065
|
+
const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
|
|
45066
|
+
// sort updates queries array in place so we need to create a copy
|
|
45067
|
+
const originalQueries = [...queries];
|
|
45068
|
+
queries.sort((q1, q2) => {
|
|
45069
|
+
if (q1 === '*') {
|
|
45070
|
+
return -1;
|
|
45071
|
+
}
|
|
45072
|
+
if (q2 === '*') {
|
|
45073
|
+
return 1;
|
|
45074
|
+
}
|
|
45075
|
+
return q1 > q2 ? -1 : 1;
|
|
45076
|
+
});
|
|
45077
|
+
if (originalQueries.join('') !== queries.join('')) {
|
|
45078
|
+
ctx.addIssue({
|
|
45079
|
+
code: z.ZodIssueCode.custom,
|
|
45080
|
+
message: `Breakpoints should be ordered from largest to smallest pixel value`,
|
|
45081
|
+
});
|
|
45082
|
+
}
|
|
45083
|
+
};
|
|
44733
45084
|
const ValuesByBreakpointSchema$1 = z.record(z.lazy(() => PrimitiveValueSchema$1));
|
|
45085
|
+
const BindingSourceTypeEnumSchema$1 = z
|
|
45086
|
+
.array(z.enum(['entry', 'asset', 'manual', 'experience']))
|
|
45087
|
+
.nonempty();
|
|
44734
45088
|
const DesignValueSchema$1 = z
|
|
44735
45089
|
.object({
|
|
44736
45090
|
type: z.literal('DesignValue'),
|
|
@@ -44763,8 +45117,6 @@ const ComponentValueSchema$1 = z
|
|
|
44763
45117
|
key: z.string(),
|
|
44764
45118
|
})
|
|
44765
45119
|
.strict();
|
|
44766
|
-
// TODO: finalize schema structure before release
|
|
44767
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
44768
45120
|
const NoValueSchema$1 = z.object({ type: z.literal('NoValue') }).strict();
|
|
44769
45121
|
const ComponentPropertyValueSchema$1 = z.discriminatedUnion('type', [
|
|
44770
45122
|
DesignValueSchema$1,
|
|
@@ -44776,41 +45128,12 @@ const ComponentPropertyValueSchema$1 = z.discriminatedUnion('type', [
|
|
|
44776
45128
|
]);
|
|
44777
45129
|
// TODO: finalize schema structure before release
|
|
44778
45130
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
44779
|
-
const VariableMappingSchema$1 = z.object({
|
|
44780
|
-
patternPropertyDefinitionId: propertyKeySchema$1,
|
|
44781
|
-
type: z.literal('ContentTypeMapping'),
|
|
44782
|
-
pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
|
|
44783
|
-
});
|
|
44784
|
-
const VariableMappingsSchema$1 = z.record(propertyKeySchema$1, VariableMappingSchema$1);
|
|
44785
|
-
// TODO: finalize schema structure before release
|
|
44786
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
44787
|
-
const PatternPropertyDefinitionSchema$1 = z.object({
|
|
44788
|
-
defaultValue: z
|
|
44789
|
-
.record(z.string(), z.object({
|
|
44790
|
-
sys: z.object({
|
|
44791
|
-
type: z.literal('Link'),
|
|
44792
|
-
id: z.string(),
|
|
44793
|
-
linkType: z.enum(['Entry']),
|
|
44794
|
-
}),
|
|
44795
|
-
}))
|
|
44796
|
-
.optional(),
|
|
44797
|
-
contentTypes: z.record(z.string(), z.object({
|
|
44798
|
-
sys: z.object({
|
|
44799
|
-
type: z.literal('Link'),
|
|
44800
|
-
id: z.string(),
|
|
44801
|
-
linkType: z.enum(['ContentType']),
|
|
44802
|
-
}),
|
|
44803
|
-
})),
|
|
44804
|
-
});
|
|
44805
|
-
const PatternPropertyDefinitionsSchema$1 = z.record(propertyKeySchema$1, PatternPropertyDefinitionSchema$1);
|
|
44806
|
-
// TODO: finalize schema structure before release
|
|
44807
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
44808
45131
|
const PatternPropertySchema$1 = z.object({
|
|
44809
45132
|
type: z.literal('BoundValue'),
|
|
44810
45133
|
path: z.string(),
|
|
44811
45134
|
contentType: z.string(),
|
|
44812
45135
|
});
|
|
44813
|
-
const
|
|
45136
|
+
const PatternPropertiesSchema$1 = z.record(propertyKeySchema$1, PatternPropertySchema$1);
|
|
44814
45137
|
const BreakpointSchema$1 = z
|
|
44815
45138
|
.object({
|
|
44816
45139
|
id: propertyKeySchema$1,
|
|
@@ -44820,12 +45143,6 @@ const BreakpointSchema$1 = z
|
|
|
44820
45143
|
displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),
|
|
44821
45144
|
})
|
|
44822
45145
|
.strict();
|
|
44823
|
-
const UnboundValuesSchema$1 = z.record(uuidKeySchema$1, z.object({
|
|
44824
|
-
value: PrimitiveValueSchema$1,
|
|
44825
|
-
}));
|
|
44826
|
-
const ComponentTreeNodeIdSchema$1 = z
|
|
44827
|
-
.string()
|
|
44828
|
-
.regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
|
|
44829
45146
|
// Use helper schema to define a recursive schema with its type correctly below
|
|
44830
45147
|
const BaseComponentTreeNodeSchema$1 = z.object({
|
|
44831
45148
|
id: ComponentTreeNodeIdSchema$1.optional(),
|
|
@@ -44833,14 +45150,8 @@ const BaseComponentTreeNodeSchema$1 = z.object({
|
|
|
44833
45150
|
displayName: z.string().optional(),
|
|
44834
45151
|
slotId: z.string().optional(),
|
|
44835
45152
|
variables: z.record(propertyKeySchema$1, ComponentPropertyValueSchema$1),
|
|
44836
|
-
patternProperties:
|
|
44837
|
-
});
|
|
44838
|
-
const ComponentTreeNodeSchema$1 = BaseComponentTreeNodeSchema$1.extend({
|
|
44839
|
-
children: z.lazy(() => ComponentTreeNodeSchema$1.array()),
|
|
45153
|
+
patternProperties: PatternPropertiesSchema$1.optional(),
|
|
44840
45154
|
});
|
|
44841
|
-
const BindingSourceTypeEnumSchema$1 = z
|
|
44842
|
-
.array(z.enum(['entry', 'asset', 'manual', 'experience']))
|
|
44843
|
-
.nonempty();
|
|
44844
45155
|
const ComponentVariableSchema$1 = z.object({
|
|
44845
45156
|
displayName: z.string().optional(),
|
|
44846
45157
|
type: DefinitionPropertyTypeSchema$1,
|
|
@@ -44861,8 +45172,25 @@ const ComponentVariableSchema$1 = z.object({
|
|
|
44861
45172
|
})
|
|
44862
45173
|
.optional(),
|
|
44863
45174
|
});
|
|
44864
|
-
const
|
|
44865
|
-
|
|
45175
|
+
const ComponentTreeNodeSchema$1 = BaseComponentTreeNodeSchema$1.extend({
|
|
45176
|
+
children: z.lazy(() => ComponentTreeNodeSchema$1.array()),
|
|
45177
|
+
});
|
|
45178
|
+
const ComponentTreeSchema$1 = z
|
|
45179
|
+
.object({
|
|
45180
|
+
breakpoints: z.array(BreakpointSchema$1).superRefine(breakpointsRefinement$1),
|
|
45181
|
+
children: z.array(ComponentTreeNodeSchema$1),
|
|
45182
|
+
schemaVersion: SchemaVersions$1,
|
|
45183
|
+
})
|
|
45184
|
+
.strict();
|
|
45185
|
+
const localeWrapper$1 = (fieldSchema) => z.record(z.string(), fieldSchema);
|
|
45186
|
+
|
|
45187
|
+
z.object({
|
|
45188
|
+
componentTree: localeWrapper$1(ComponentTreeSchema$1),
|
|
45189
|
+
dataSource: localeWrapper$1(DataSourceSchema$1),
|
|
45190
|
+
unboundValues: localeWrapper$1(UnboundValuesSchema$1),
|
|
45191
|
+
usedComponents: localeWrapper$1(UsedComponentsSchema$1).optional(),
|
|
45192
|
+
});
|
|
45193
|
+
|
|
44866
45194
|
const THUMBNAIL_IDS$1 = [
|
|
44867
45195
|
'columns',
|
|
44868
45196
|
'columnsPlusRight',
|
|
@@ -44888,72 +45216,50 @@ const THUMBNAIL_IDS$1 = [
|
|
|
44888
45216
|
'textColumns',
|
|
44889
45217
|
'duplex',
|
|
44890
45218
|
];
|
|
44891
|
-
|
|
44892
|
-
|
|
44893
|
-
|
|
44894
|
-
|
|
44895
|
-
|
|
44896
|
-
|
|
44897
|
-
});
|
|
44898
|
-
|
|
44899
|
-
|
|
44900
|
-
|
|
44901
|
-
|
|
44902
|
-
|
|
44903
|
-
|
|
44904
|
-
|
|
44905
|
-
|
|
44906
|
-
|
|
44907
|
-
|
|
44908
|
-
|
|
44909
|
-
|
|
44910
|
-
|
|
44911
|
-
|
|
44912
|
-
|
|
44913
|
-
|
|
44914
|
-
|
|
44915
|
-
|
|
44916
|
-
})
|
|
44917
|
-
|
|
44918
|
-
|
|
44919
|
-
|
|
44920
|
-
|
|
44921
|
-
|
|
44922
|
-
|
|
44923
|
-
|
|
44924
|
-
|
|
44925
|
-
|
|
44926
|
-
|
|
44927
|
-
|
|
44928
|
-
|
|
44929
|
-
return -1;
|
|
44930
|
-
}
|
|
44931
|
-
if (q2 === '*') {
|
|
44932
|
-
return 1;
|
|
44933
|
-
}
|
|
44934
|
-
return q1 > q2 ? -1 : 1;
|
|
44935
|
-
});
|
|
44936
|
-
if (originalQueries.join('') !== queries.join('')) {
|
|
44937
|
-
ctx.addIssue({
|
|
44938
|
-
code: z.ZodIssueCode.custom,
|
|
44939
|
-
message: `Breakpoints should be ordered from largest to smallest pixel value`,
|
|
44940
|
-
});
|
|
44941
|
-
}
|
|
44942
|
-
};
|
|
44943
|
-
const ComponentTreeSchema$1 = z
|
|
44944
|
-
.object({
|
|
44945
|
-
breakpoints: z.array(BreakpointSchema$1).superRefine(breakpointsRefinement$1),
|
|
44946
|
-
children: z.array(ComponentTreeNodeSchema$1),
|
|
44947
|
-
schemaVersion: SchemaVersions$1,
|
|
44948
|
-
})
|
|
44949
|
-
.strict();
|
|
44950
|
-
const localeWrapper$1 = (fieldSchema) => z.record(z.string(), fieldSchema);
|
|
45219
|
+
// TODO: finalize schema structure before release
|
|
45220
|
+
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
45221
|
+
const VariableMappingSchema$1 = z.object({
|
|
45222
|
+
patternPropertyDefinitionId: propertyKeySchema$1,
|
|
45223
|
+
type: z.literal('ContentTypeMapping'),
|
|
45224
|
+
pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
|
|
45225
|
+
});
|
|
45226
|
+
// TODO: finalize schema structure before release
|
|
45227
|
+
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
45228
|
+
const PatternPropertyDefinitionSchema$1 = z.object({
|
|
45229
|
+
defaultValue: z
|
|
45230
|
+
.record(z.string(), z.object({
|
|
45231
|
+
sys: z.object({
|
|
45232
|
+
type: z.literal('Link'),
|
|
45233
|
+
id: z.string(),
|
|
45234
|
+
linkType: z.enum(['Entry']),
|
|
45235
|
+
}),
|
|
45236
|
+
}))
|
|
45237
|
+
.optional(),
|
|
45238
|
+
contentTypes: z.record(z.string(), z.object({
|
|
45239
|
+
sys: z.object({
|
|
45240
|
+
type: z.literal('Link'),
|
|
45241
|
+
id: z.string(),
|
|
45242
|
+
linkType: z.enum(['ContentType']),
|
|
45243
|
+
}),
|
|
45244
|
+
})),
|
|
45245
|
+
});
|
|
45246
|
+
const PatternPropertyDefinitionsSchema$1 = z.record(propertyKeySchema$1, PatternPropertyDefinitionSchema$1);
|
|
45247
|
+
const VariableMappingsSchema$1 = z.record(propertyKeySchema$1, VariableMappingSchema$1);
|
|
45248
|
+
const ComponentVariablesSchema$1 = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
|
|
45249
|
+
ComponentVariableSchema$1);
|
|
45250
|
+
const ComponentSettingsSchema$1 = z.object({
|
|
45251
|
+
variableDefinitions: ComponentVariablesSchema$1,
|
|
45252
|
+
thumbnailId: z.enum(THUMBNAIL_IDS$1).optional(),
|
|
45253
|
+
category: z.string().max(50, 'Category must contain at most 50 characters').optional(),
|
|
45254
|
+
variableMappings: VariableMappingsSchema$1.optional(),
|
|
45255
|
+
patternPropertyDefinitions: PatternPropertyDefinitionsSchema$1.optional(),
|
|
45256
|
+
});
|
|
44951
45257
|
z.object({
|
|
44952
45258
|
componentTree: localeWrapper$1(ComponentTreeSchema$1),
|
|
44953
45259
|
dataSource: localeWrapper$1(DataSourceSchema$1),
|
|
44954
45260
|
unboundValues: localeWrapper$1(UnboundValuesSchema$1),
|
|
44955
45261
|
usedComponents: localeWrapper$1(UsedComponentsSchema$1).optional(),
|
|
44956
|
-
componentSettings: localeWrapper$1(ComponentSettingsSchema$1)
|
|
45262
|
+
componentSettings: localeWrapper$1(ComponentSettingsSchema$1),
|
|
44957
45263
|
});
|
|
44958
45264
|
|
|
44959
45265
|
z.object({
|
|
@@ -45237,6 +45543,51 @@ let DebugLogger$1 = class DebugLogger {
|
|
|
45237
45543
|
DebugLogger$1.instance = null;
|
|
45238
45544
|
DebugLogger$1.getInstance();
|
|
45239
45545
|
|
|
45546
|
+
const findOutermostCoordinates = (first, second) => {
|
|
45547
|
+
return {
|
|
45548
|
+
top: Math.min(first.top, second.top),
|
|
45549
|
+
right: Math.max(first.right, second.right),
|
|
45550
|
+
bottom: Math.max(first.bottom, second.bottom),
|
|
45551
|
+
left: Math.min(first.left, second.left),
|
|
45552
|
+
};
|
|
45553
|
+
};
|
|
45554
|
+
const getElementCoordinates = (element) => {
|
|
45555
|
+
const rect = element.getBoundingClientRect();
|
|
45556
|
+
/**
|
|
45557
|
+
* If element does not have children, or element has it's own width or height,
|
|
45558
|
+
* return the element's coordinates.
|
|
45559
|
+
*/
|
|
45560
|
+
if (element.children.length === 0 || rect.width !== 0 || rect.height !== 0) {
|
|
45561
|
+
return rect;
|
|
45562
|
+
}
|
|
45563
|
+
const rects = [];
|
|
45564
|
+
/**
|
|
45565
|
+
* If element has children, or element does not have it's own width and height,
|
|
45566
|
+
* we find the cordinates of the children, and assume the outermost coordinates of the children
|
|
45567
|
+
* as the coordinate of the element.
|
|
45568
|
+
*
|
|
45569
|
+
* E.g child1 => {top: 2, bottom: 3, left: 4, right: 6} & child2 => {top: 1, bottom: 8, left: 12, right: 24}
|
|
45570
|
+
* The final assumed coordinates of the element would be => { top: 1, right: 24, bottom: 8, left: 4 }
|
|
45571
|
+
*/
|
|
45572
|
+
for (const child of element.children) {
|
|
45573
|
+
const childRect = getElementCoordinates(child);
|
|
45574
|
+
if (childRect.width !== 0 || childRect.height !== 0) {
|
|
45575
|
+
const { top, right, bottom, left } = childRect;
|
|
45576
|
+
rects.push({ top, right, bottom, left });
|
|
45577
|
+
}
|
|
45578
|
+
}
|
|
45579
|
+
if (rects.length === 0) {
|
|
45580
|
+
return rect;
|
|
45581
|
+
}
|
|
45582
|
+
const { top, right, bottom, left } = rects.reduce(findOutermostCoordinates);
|
|
45583
|
+
return DOMRect.fromRect({
|
|
45584
|
+
x: left,
|
|
45585
|
+
y: top,
|
|
45586
|
+
height: bottom - top,
|
|
45587
|
+
width: right - left,
|
|
45588
|
+
});
|
|
45589
|
+
};
|
|
45590
|
+
|
|
45240
45591
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45241
45592
|
const isLinkToAsset = (variable) => {
|
|
45242
45593
|
if (!variable)
|
|
@@ -48097,17 +48448,16 @@ const PrimitiveValueSchema = z.union([
|
|
|
48097
48448
|
z.record(z.any(), z.any()),
|
|
48098
48449
|
z.undefined(),
|
|
48099
48450
|
]);
|
|
48451
|
+
const UsedComponentsSchema = z.array(z.object({
|
|
48452
|
+
sys: z.object({
|
|
48453
|
+
type: z.literal('Link'),
|
|
48454
|
+
id: z.string(),
|
|
48455
|
+
linkType: z.literal('Entry'),
|
|
48456
|
+
}),
|
|
48457
|
+
}));
|
|
48100
48458
|
const uuidKeySchema = z
|
|
48101
48459
|
.string()
|
|
48102
48460
|
.regex(/^[a-zA-Z0-9-_]{1,21}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,21}$/' });
|
|
48103
|
-
/**
|
|
48104
|
-
* Property keys for imported components have a limit of 32 characters (to be implemented) while
|
|
48105
|
-
* property keys for patterns have a limit of 54 characters (<32-char-variabl-name>_<21-char-nanoid-id>).
|
|
48106
|
-
* Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
|
|
48107
|
-
*/
|
|
48108
|
-
const propertyKeySchema = z
|
|
48109
|
-
.string()
|
|
48110
|
-
.regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
|
|
48111
48461
|
const DataSourceSchema = z.record(uuidKeySchema, z.object({
|
|
48112
48462
|
sys: z.object({
|
|
48113
48463
|
type: z.literal('Link'),
|
|
@@ -48115,7 +48465,62 @@ const DataSourceSchema = z.record(uuidKeySchema, z.object({
|
|
|
48115
48465
|
linkType: z.enum(['Entry', 'Asset']),
|
|
48116
48466
|
}),
|
|
48117
48467
|
}));
|
|
48468
|
+
const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
|
|
48469
|
+
value: PrimitiveValueSchema,
|
|
48470
|
+
}));
|
|
48471
|
+
/**
|
|
48472
|
+
* Property keys for imported components have a limit of 32 characters (to be implemented) while
|
|
48473
|
+
* property keys for patterns have a limit of 54 characters (<32-char-variable-name>_<21-char-nanoid-id>).
|
|
48474
|
+
* Because we cannot distinguish between the two in the componentTree, we will use the larger limit for both.
|
|
48475
|
+
*/
|
|
48476
|
+
const propertyKeySchema = z
|
|
48477
|
+
.string()
|
|
48478
|
+
.regex(/^[a-zA-Z0-9-_]{1,54}$/, { message: 'Does not match /^[a-zA-Z0-9-_]{1,54}$/' });
|
|
48479
|
+
const ComponentTreeNodeIdSchema = z
|
|
48480
|
+
.string()
|
|
48481
|
+
.regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
|
|
48482
|
+
const breakpointsRefinement = (value, ctx) => {
|
|
48483
|
+
if (!value.length || value[0].query !== '*') {
|
|
48484
|
+
ctx.addIssue({
|
|
48485
|
+
code: z.ZodIssueCode.custom,
|
|
48486
|
+
message: `The first breakpoint should include the following attributes: { "query": "*" }`,
|
|
48487
|
+
});
|
|
48488
|
+
}
|
|
48489
|
+
const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
|
|
48490
|
+
// check if the current breakpoint id is found in the rest of the array
|
|
48491
|
+
const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
|
|
48492
|
+
return breakpointIndex !== currentBreakpointIndex;
|
|
48493
|
+
});
|
|
48494
|
+
if (hasDuplicateIds) {
|
|
48495
|
+
ctx.addIssue({
|
|
48496
|
+
code: z.ZodIssueCode.custom,
|
|
48497
|
+
message: `Breakpoint IDs must be unique`,
|
|
48498
|
+
});
|
|
48499
|
+
}
|
|
48500
|
+
// Extract the queries boundary by removing the special characters around it
|
|
48501
|
+
const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
|
|
48502
|
+
// sort updates queries array in place so we need to create a copy
|
|
48503
|
+
const originalQueries = [...queries];
|
|
48504
|
+
queries.sort((q1, q2) => {
|
|
48505
|
+
if (q1 === '*') {
|
|
48506
|
+
return -1;
|
|
48507
|
+
}
|
|
48508
|
+
if (q2 === '*') {
|
|
48509
|
+
return 1;
|
|
48510
|
+
}
|
|
48511
|
+
return q1 > q2 ? -1 : 1;
|
|
48512
|
+
});
|
|
48513
|
+
if (originalQueries.join('') !== queries.join('')) {
|
|
48514
|
+
ctx.addIssue({
|
|
48515
|
+
code: z.ZodIssueCode.custom,
|
|
48516
|
+
message: `Breakpoints should be ordered from largest to smallest pixel value`,
|
|
48517
|
+
});
|
|
48518
|
+
}
|
|
48519
|
+
};
|
|
48118
48520
|
const ValuesByBreakpointSchema = z.record(z.lazy(() => PrimitiveValueSchema));
|
|
48521
|
+
const BindingSourceTypeEnumSchema = z
|
|
48522
|
+
.array(z.enum(['entry', 'asset', 'manual', 'experience']))
|
|
48523
|
+
.nonempty();
|
|
48119
48524
|
const DesignValueSchema = z
|
|
48120
48525
|
.object({
|
|
48121
48526
|
type: z.literal('DesignValue'),
|
|
@@ -48148,8 +48553,6 @@ const ComponentValueSchema = z
|
|
|
48148
48553
|
key: z.string(),
|
|
48149
48554
|
})
|
|
48150
48555
|
.strict();
|
|
48151
|
-
// TODO: finalize schema structure before release
|
|
48152
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
48153
48556
|
const NoValueSchema = z.object({ type: z.literal('NoValue') }).strict();
|
|
48154
48557
|
const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
48155
48558
|
DesignValueSchema,
|
|
@@ -48161,41 +48564,12 @@ const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
|
48161
48564
|
]);
|
|
48162
48565
|
// TODO: finalize schema structure before release
|
|
48163
48566
|
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
48164
|
-
const VariableMappingSchema = z.object({
|
|
48165
|
-
patternPropertyDefinitionId: propertyKeySchema,
|
|
48166
|
-
type: z.literal('ContentTypeMapping'),
|
|
48167
|
-
pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
|
|
48168
|
-
});
|
|
48169
|
-
const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
|
|
48170
|
-
// TODO: finalize schema structure before release
|
|
48171
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
48172
|
-
const PatternPropertyDefinitionSchema = z.object({
|
|
48173
|
-
defaultValue: z
|
|
48174
|
-
.record(z.string(), z.object({
|
|
48175
|
-
sys: z.object({
|
|
48176
|
-
type: z.literal('Link'),
|
|
48177
|
-
id: z.string(),
|
|
48178
|
-
linkType: z.enum(['Entry']),
|
|
48179
|
-
}),
|
|
48180
|
-
}))
|
|
48181
|
-
.optional(),
|
|
48182
|
-
contentTypes: z.record(z.string(), z.object({
|
|
48183
|
-
sys: z.object({
|
|
48184
|
-
type: z.literal('Link'),
|
|
48185
|
-
id: z.string(),
|
|
48186
|
-
linkType: z.enum(['ContentType']),
|
|
48187
|
-
}),
|
|
48188
|
-
})),
|
|
48189
|
-
});
|
|
48190
|
-
const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
|
|
48191
|
-
// TODO: finalize schema structure before release
|
|
48192
|
-
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
48193
48567
|
const PatternPropertySchema = z.object({
|
|
48194
48568
|
type: z.literal('BoundValue'),
|
|
48195
48569
|
path: z.string(),
|
|
48196
48570
|
contentType: z.string(),
|
|
48197
48571
|
});
|
|
48198
|
-
const
|
|
48572
|
+
const PatternPropertiesSchema = z.record(propertyKeySchema, PatternPropertySchema);
|
|
48199
48573
|
const BreakpointSchema = z
|
|
48200
48574
|
.object({
|
|
48201
48575
|
id: propertyKeySchema,
|
|
@@ -48205,12 +48579,6 @@ const BreakpointSchema = z
|
|
|
48205
48579
|
displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),
|
|
48206
48580
|
})
|
|
48207
48581
|
.strict();
|
|
48208
|
-
const UnboundValuesSchema = z.record(uuidKeySchema, z.object({
|
|
48209
|
-
value: PrimitiveValueSchema,
|
|
48210
|
-
}));
|
|
48211
|
-
const ComponentTreeNodeIdSchema = z
|
|
48212
|
-
.string()
|
|
48213
|
-
.regex(/^[a-zA-Z0-9]{1,8}$/, { message: 'Does not match /^[a-zA-Z0-9]{1,8}$/' });
|
|
48214
48582
|
// Use helper schema to define a recursive schema with its type correctly below
|
|
48215
48583
|
const BaseComponentTreeNodeSchema = z.object({
|
|
48216
48584
|
id: ComponentTreeNodeIdSchema.optional(),
|
|
@@ -48218,14 +48586,8 @@ const BaseComponentTreeNodeSchema = z.object({
|
|
|
48218
48586
|
displayName: z.string().optional(),
|
|
48219
48587
|
slotId: z.string().optional(),
|
|
48220
48588
|
variables: z.record(propertyKeySchema, ComponentPropertyValueSchema),
|
|
48221
|
-
patternProperties:
|
|
48222
|
-
});
|
|
48223
|
-
const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
|
|
48224
|
-
children: z.lazy(() => ComponentTreeNodeSchema.array()),
|
|
48589
|
+
patternProperties: PatternPropertiesSchema.optional(),
|
|
48225
48590
|
});
|
|
48226
|
-
const BindingSourceTypeEnumSchema = z
|
|
48227
|
-
.array(z.enum(['entry', 'asset', 'manual', 'experience']))
|
|
48228
|
-
.nonempty();
|
|
48229
48591
|
const ComponentVariableSchema = z.object({
|
|
48230
48592
|
displayName: z.string().optional(),
|
|
48231
48593
|
type: DefinitionPropertyTypeSchema,
|
|
@@ -48246,8 +48608,25 @@ const ComponentVariableSchema = z.object({
|
|
|
48246
48608
|
})
|
|
48247
48609
|
.optional(),
|
|
48248
48610
|
});
|
|
48249
|
-
const
|
|
48250
|
-
|
|
48611
|
+
const ComponentTreeNodeSchema = BaseComponentTreeNodeSchema.extend({
|
|
48612
|
+
children: z.lazy(() => ComponentTreeNodeSchema.array()),
|
|
48613
|
+
});
|
|
48614
|
+
const ComponentTreeSchema = z
|
|
48615
|
+
.object({
|
|
48616
|
+
breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
|
|
48617
|
+
children: z.array(ComponentTreeNodeSchema),
|
|
48618
|
+
schemaVersion: SchemaVersions,
|
|
48619
|
+
})
|
|
48620
|
+
.strict();
|
|
48621
|
+
const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
|
|
48622
|
+
|
|
48623
|
+
z.object({
|
|
48624
|
+
componentTree: localeWrapper(ComponentTreeSchema),
|
|
48625
|
+
dataSource: localeWrapper(DataSourceSchema),
|
|
48626
|
+
unboundValues: localeWrapper(UnboundValuesSchema),
|
|
48627
|
+
usedComponents: localeWrapper(UsedComponentsSchema).optional(),
|
|
48628
|
+
});
|
|
48629
|
+
|
|
48251
48630
|
const THUMBNAIL_IDS = [
|
|
48252
48631
|
'columns',
|
|
48253
48632
|
'columnsPlusRight',
|
|
@@ -48273,6 +48652,37 @@ const THUMBNAIL_IDS = [
|
|
|
48273
48652
|
'textColumns',
|
|
48274
48653
|
'duplex',
|
|
48275
48654
|
];
|
|
48655
|
+
// TODO: finalize schema structure before release
|
|
48656
|
+
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
48657
|
+
const VariableMappingSchema = z.object({
|
|
48658
|
+
patternPropertyDefinitionId: propertyKeySchema,
|
|
48659
|
+
type: z.literal('ContentTypeMapping'),
|
|
48660
|
+
pathsByContentType: z.record(z.string(), z.object({ path: z.string() })),
|
|
48661
|
+
});
|
|
48662
|
+
// TODO: finalize schema structure before release
|
|
48663
|
+
// https://contentful.atlassian.net/browse/LUMOS-523
|
|
48664
|
+
const PatternPropertyDefinitionSchema = z.object({
|
|
48665
|
+
defaultValue: z
|
|
48666
|
+
.record(z.string(), z.object({
|
|
48667
|
+
sys: z.object({
|
|
48668
|
+
type: z.literal('Link'),
|
|
48669
|
+
id: z.string(),
|
|
48670
|
+
linkType: z.enum(['Entry']),
|
|
48671
|
+
}),
|
|
48672
|
+
}))
|
|
48673
|
+
.optional(),
|
|
48674
|
+
contentTypes: z.record(z.string(), z.object({
|
|
48675
|
+
sys: z.object({
|
|
48676
|
+
type: z.literal('Link'),
|
|
48677
|
+
id: z.string(),
|
|
48678
|
+
linkType: z.enum(['ContentType']),
|
|
48679
|
+
}),
|
|
48680
|
+
})),
|
|
48681
|
+
});
|
|
48682
|
+
const PatternPropertyDefinitionsSchema = z.record(propertyKeySchema, PatternPropertyDefinitionSchema);
|
|
48683
|
+
const VariableMappingsSchema = z.record(propertyKeySchema, VariableMappingSchema);
|
|
48684
|
+
const ComponentVariablesSchema = z.record(z.string().regex(/^[a-zA-Z0-9-_]{1,54}$/), // Here the key is <variableName>_<nanoidId> so we need to allow for a longer length
|
|
48685
|
+
ComponentVariableSchema);
|
|
48276
48686
|
const ComponentSettingsSchema = z.object({
|
|
48277
48687
|
variableDefinitions: ComponentVariablesSchema,
|
|
48278
48688
|
thumbnailId: z.enum(THUMBNAIL_IDS).optional(),
|
|
@@ -48280,65 +48690,12 @@ const ComponentSettingsSchema = z.object({
|
|
|
48280
48690
|
variableMappings: VariableMappingsSchema.optional(),
|
|
48281
48691
|
patternPropertyDefinitions: PatternPropertyDefinitionsSchema.optional(),
|
|
48282
48692
|
});
|
|
48283
|
-
const UsedComponentsSchema = z.array(z.object({
|
|
48284
|
-
sys: z.object({
|
|
48285
|
-
type: z.literal('Link'),
|
|
48286
|
-
id: z.string(),
|
|
48287
|
-
linkType: z.literal('Entry'),
|
|
48288
|
-
}),
|
|
48289
|
-
}));
|
|
48290
|
-
const breakpointsRefinement = (value, ctx) => {
|
|
48291
|
-
if (!value.length || value[0].query !== '*') {
|
|
48292
|
-
ctx.addIssue({
|
|
48293
|
-
code: z.ZodIssueCode.custom,
|
|
48294
|
-
message: `The first breakpoint should include the following attributes: { "query": "*" }`,
|
|
48295
|
-
});
|
|
48296
|
-
}
|
|
48297
|
-
const hasDuplicateIds = value.some((currentBreakpoint, currentBreakpointIndex) => {
|
|
48298
|
-
// check if the current breakpoint id is found in the rest of the array
|
|
48299
|
-
const breakpointIndex = value.findIndex((breakpoint) => breakpoint.id === currentBreakpoint.id);
|
|
48300
|
-
return breakpointIndex !== currentBreakpointIndex;
|
|
48301
|
-
});
|
|
48302
|
-
if (hasDuplicateIds) {
|
|
48303
|
-
ctx.addIssue({
|
|
48304
|
-
code: z.ZodIssueCode.custom,
|
|
48305
|
-
message: `Breakpoint IDs must be unique`,
|
|
48306
|
-
});
|
|
48307
|
-
}
|
|
48308
|
-
// Extract the queries boundary by removing the special characters around it
|
|
48309
|
-
const queries = value.map((bp) => bp.query === '*' ? bp.query : parseInt(bp.query.replace(/px|<|>/, '')));
|
|
48310
|
-
// sort updates queries array in place so we need to create a copy
|
|
48311
|
-
const originalQueries = [...queries];
|
|
48312
|
-
queries.sort((q1, q2) => {
|
|
48313
|
-
if (q1 === '*') {
|
|
48314
|
-
return -1;
|
|
48315
|
-
}
|
|
48316
|
-
if (q2 === '*') {
|
|
48317
|
-
return 1;
|
|
48318
|
-
}
|
|
48319
|
-
return q1 > q2 ? -1 : 1;
|
|
48320
|
-
});
|
|
48321
|
-
if (originalQueries.join('') !== queries.join('')) {
|
|
48322
|
-
ctx.addIssue({
|
|
48323
|
-
code: z.ZodIssueCode.custom,
|
|
48324
|
-
message: `Breakpoints should be ordered from largest to smallest pixel value`,
|
|
48325
|
-
});
|
|
48326
|
-
}
|
|
48327
|
-
};
|
|
48328
|
-
const ComponentTreeSchema = z
|
|
48329
|
-
.object({
|
|
48330
|
-
breakpoints: z.array(BreakpointSchema).superRefine(breakpointsRefinement),
|
|
48331
|
-
children: z.array(ComponentTreeNodeSchema),
|
|
48332
|
-
schemaVersion: SchemaVersions,
|
|
48333
|
-
})
|
|
48334
|
-
.strict();
|
|
48335
|
-
const localeWrapper = (fieldSchema) => z.record(z.string(), fieldSchema);
|
|
48336
48693
|
z.object({
|
|
48337
48694
|
componentTree: localeWrapper(ComponentTreeSchema),
|
|
48338
48695
|
dataSource: localeWrapper(DataSourceSchema),
|
|
48339
48696
|
unboundValues: localeWrapper(UnboundValuesSchema),
|
|
48340
48697
|
usedComponents: localeWrapper(UsedComponentsSchema).optional(),
|
|
48341
|
-
componentSettings: localeWrapper(ComponentSettingsSchema)
|
|
48698
|
+
componentSettings: localeWrapper(ComponentSettingsSchema),
|
|
48342
48699
|
});
|
|
48343
48700
|
|
|
48344
48701
|
z.object({
|
|
@@ -49132,18 +49489,115 @@ const EmptyCanvasMessage = () => {
|
|
|
49132
49489
|
React$1.createElement("span", { className: styles['empty-canvas-label'] }, "Add components to begin")));
|
|
49133
49490
|
};
|
|
49134
49491
|
|
|
49492
|
+
/**
|
|
49493
|
+
* This function gets the element co-ordinates of a specified component in the DOM and its parent
|
|
49494
|
+
* and sends the DOM Rect to the client app.
|
|
49495
|
+
*/
|
|
49496
|
+
const sendCanvasGeometryUpdatedMessage = async (tree, sourceEvent) => {
|
|
49497
|
+
const nodeToCoordinatesMap = {};
|
|
49498
|
+
await waitForAllImagesToBeLoaded();
|
|
49499
|
+
collectNodeCoordinates(tree.root, nodeToCoordinatesMap);
|
|
49500
|
+
sendMessage(OUTGOING_EVENTS.CanvasGeometryUpdated, {
|
|
49501
|
+
size: {
|
|
49502
|
+
width: document.documentElement.scrollWidth,
|
|
49503
|
+
height: document.documentElement.scrollHeight,
|
|
49504
|
+
},
|
|
49505
|
+
nodes: nodeToCoordinatesMap,
|
|
49506
|
+
sourceEvent,
|
|
49507
|
+
});
|
|
49508
|
+
};
|
|
49509
|
+
const collectNodeCoordinates = (node, nodeToCoordinatesMap) => {
|
|
49510
|
+
const selectedElement = document.querySelector(`[data-cf-node-id="${node.data.id}"]`);
|
|
49511
|
+
if (selectedElement) {
|
|
49512
|
+
const rect = getElementCoordinates(selectedElement);
|
|
49513
|
+
nodeToCoordinatesMap[node.data.id] = {
|
|
49514
|
+
coordinates: {
|
|
49515
|
+
x: rect.x + window.scrollX,
|
|
49516
|
+
y: rect.y + window.scrollY,
|
|
49517
|
+
width: rect.width,
|
|
49518
|
+
height: rect.height,
|
|
49519
|
+
},
|
|
49520
|
+
};
|
|
49521
|
+
}
|
|
49522
|
+
node.children.forEach((child) => collectNodeCoordinates(child, nodeToCoordinatesMap));
|
|
49523
|
+
};
|
|
49524
|
+
const waitForAllImagesToBeLoaded = () => {
|
|
49525
|
+
// If the document contains an image, wait for this image to be loaded before collecting & sending all geometry data.
|
|
49526
|
+
const allImageNodes = document.querySelectorAll('img');
|
|
49527
|
+
return Promise.all(Array.from(allImageNodes).map((imageNode) => {
|
|
49528
|
+
if (imageNode.complete) {
|
|
49529
|
+
return Promise.resolve();
|
|
49530
|
+
}
|
|
49531
|
+
return new Promise((resolve, reject) => {
|
|
49532
|
+
const handleImageLoad = (event) => {
|
|
49533
|
+
imageNode.removeEventListener('load', handleImageLoad);
|
|
49534
|
+
imageNode.removeEventListener('error', handleImageLoad);
|
|
49535
|
+
if (event.type === 'error') {
|
|
49536
|
+
console.warn('Image failed to load:', imageNode);
|
|
49537
|
+
reject();
|
|
49538
|
+
}
|
|
49539
|
+
else {
|
|
49540
|
+
resolve();
|
|
49541
|
+
}
|
|
49542
|
+
};
|
|
49543
|
+
imageNode.addEventListener('load', handleImageLoad);
|
|
49544
|
+
imageNode.addEventListener('error', handleImageLoad);
|
|
49545
|
+
});
|
|
49546
|
+
}));
|
|
49547
|
+
};
|
|
49548
|
+
|
|
49549
|
+
const useCanvasGeometryUpdates = ({ tree, rootContainerRef, }) => {
|
|
49550
|
+
const debouncedUpdateGeometry = reactExports.useMemo(() => debounce((tree, sourceEvent) => {
|
|
49551
|
+
// When the DOM changed, we still need to wait for the next frame to ensure that
|
|
49552
|
+
// rendering is complete (e.g. this is required when deleting a node).
|
|
49553
|
+
window.requestAnimationFrame(() => {
|
|
49554
|
+
sendCanvasGeometryUpdatedMessage(tree, sourceEvent);
|
|
49555
|
+
});
|
|
49556
|
+
}, 100, {
|
|
49557
|
+
leading: true,
|
|
49558
|
+
// To be sure, we recalculate it at the end of the frame again. Though, we couldn't
|
|
49559
|
+
// yet show the need for this. So we might be able to drop this later to boost performance.
|
|
49560
|
+
trailing: true,
|
|
49561
|
+
}), []);
|
|
49562
|
+
// Store tree in a ref to avoid the need to deactivate & reactivate the mutation observer
|
|
49563
|
+
// when the tree changes. This is important to avoid missing out on some mutation events.
|
|
49564
|
+
const treeRef = reactExports.useRef(tree);
|
|
49565
|
+
reactExports.useEffect(() => {
|
|
49566
|
+
treeRef.current = tree;
|
|
49567
|
+
}, [tree]);
|
|
49568
|
+
// Handling window resize events
|
|
49569
|
+
reactExports.useEffect(() => {
|
|
49570
|
+
const resizeEventListener = () => debouncedUpdateGeometry(treeRef.current, 'resize');
|
|
49571
|
+
window.addEventListener('resize', resizeEventListener);
|
|
49572
|
+
return () => window.removeEventListener('resize', resizeEventListener);
|
|
49573
|
+
}, [debouncedUpdateGeometry]);
|
|
49574
|
+
// Handling DOM mutations
|
|
49575
|
+
reactExports.useEffect(() => {
|
|
49576
|
+
if (!rootContainerRef.current)
|
|
49577
|
+
return;
|
|
49578
|
+
const observer = new MutationObserver(() => debouncedUpdateGeometry(treeRef.current, 'mutation'));
|
|
49579
|
+
observer.observe(rootContainerRef.current, {
|
|
49580
|
+
childList: true,
|
|
49581
|
+
subtree: true,
|
|
49582
|
+
attributes: true,
|
|
49583
|
+
});
|
|
49584
|
+
return () => observer.disconnect();
|
|
49585
|
+
}, [debouncedUpdateGeometry, rootContainerRef]);
|
|
49586
|
+
};
|
|
49587
|
+
|
|
49135
49588
|
const RootRenderer = () => {
|
|
49589
|
+
const rootContainerRef = reactExports.useRef(null);
|
|
49590
|
+
const tree = useTreeStore((state) => state.tree);
|
|
49591
|
+
useCanvasGeometryUpdates({ tree, rootContainerRef });
|
|
49136
49592
|
useEditorSubscriber();
|
|
49137
49593
|
const breakpoints = useTreeStore((state) => state.breakpoints);
|
|
49138
|
-
const containerRef = reactExports.useRef(null);
|
|
49139
49594
|
const { resolveDesignValue } = useBreakpoints(breakpoints);
|
|
49140
|
-
const tree = useTreeStore((state) => state.tree);
|
|
49141
49595
|
// If the root blockId is defined but not the default string, it is the entry ID
|
|
49142
49596
|
// of the experience/ pattern to properly detect circular dependencies.
|
|
49143
49597
|
const rootBlockId = tree.root.data.blockId ?? ROOT_ID;
|
|
49144
49598
|
const wrappingPatternIds = rootBlockId !== ROOT_ID ? new Set([rootBlockId]) : new Set();
|
|
49145
49599
|
return (React$1.createElement(React$1.Fragment, null,
|
|
49146
|
-
React$1.createElement("div", { "data-ctfl-root": true, className: styles$2.rootContainer, ref:
|
|
49600
|
+
React$1.createElement("div", { "data-ctfl-root": true, className: styles$2.rootContainer, ref: rootContainerRef }, !tree.root.children.length ? (React$1.createElement(EmptyCanvasMessage, null)) : (tree.root.children.map((topLevelChildNode) => (React$1.createElement(EditorBlock, { key: topLevelChildNode.data.id, node: topLevelChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds })))))));
|
|
49147
49601
|
};
|
|
49148
49602
|
|
|
49149
49603
|
const useInitializeEditor = () => {
|