@contentstack/studio-registry 1.6.0 → 1.6.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/cjs/index.cjs +51 -8
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/component-registry/registry-options-processor.js +15 -0
- package/dist/esm/component-registry/registry-options-processor.js.map +1 -1
- package/dist/esm/component-registry/registry.js +27 -2
- package/dist/esm/component-registry/registry.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.js +3 -0
- package/dist/esm/data-binder/retrieve-data.js.map +1 -1
- package/dist/esm/index.d.ts +22 -7
- package/package.json +6 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -212,7 +212,7 @@ var freeSelf = typeof self == 'object' && self && self.Object === Object && self
|
|
|
212
212
|
var root = freeGlobal || freeSelf || Function('return this')();
|
|
213
213
|
|
|
214
214
|
/** Built-in value references. */
|
|
215
|
-
var Symbol = root.Symbol;
|
|
215
|
+
var Symbol$1 = root.Symbol;
|
|
216
216
|
|
|
217
217
|
/** Used for built-in method references. */
|
|
218
218
|
var objectProto$e = Object.prototype;
|
|
@@ -228,7 +228,7 @@ var hasOwnProperty$b = objectProto$e.hasOwnProperty;
|
|
|
228
228
|
var nativeObjectToString$1 = objectProto$e.toString;
|
|
229
229
|
|
|
230
230
|
/** Built-in value references. */
|
|
231
|
-
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
|
|
231
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
234
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
@@ -283,7 +283,7 @@ var nullTag = '[object Null]',
|
|
|
283
283
|
undefinedTag = '[object Undefined]';
|
|
284
284
|
|
|
285
285
|
/** Built-in value references. */
|
|
286
|
-
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
286
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
289
|
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
@@ -400,7 +400,7 @@ function arrayMap(array, iteratee) {
|
|
|
400
400
|
var isArray = Array.isArray;
|
|
401
401
|
|
|
402
402
|
/** Used to convert symbols to primitives and strings. */
|
|
403
|
-
var symbolProto$1 = Symbol ? Symbol.prototype : undefined,
|
|
403
|
+
var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : undefined,
|
|
404
404
|
symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
|
|
405
405
|
|
|
406
406
|
/**
|
|
@@ -2214,7 +2214,7 @@ function arrayPush(array, values) {
|
|
|
2214
2214
|
}
|
|
2215
2215
|
|
|
2216
2216
|
/** Built-in value references. */
|
|
2217
|
-
var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
|
|
2217
|
+
var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : undefined;
|
|
2218
2218
|
|
|
2219
2219
|
/**
|
|
2220
2220
|
* Checks if `value` is a flattenable `arguments` object or array.
|
|
@@ -3051,7 +3051,7 @@ function cloneRegExp(regexp) {
|
|
|
3051
3051
|
}
|
|
3052
3052
|
|
|
3053
3053
|
/** Used to convert symbols to primitives and strings. */
|
|
3054
|
-
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
3054
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
|
|
3055
3055
|
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
|
3056
3056
|
|
|
3057
3057
|
/**
|
|
@@ -4087,11 +4087,26 @@ function processRegistryOptionsProps(props) {
|
|
|
4087
4087
|
}
|
|
4088
4088
|
processedProps[field] = clone(prop);
|
|
4089
4089
|
delete processedProps[field].validate;
|
|
4090
|
+
normalizeChoiceDefaultValue(processedProps[field]);
|
|
4090
4091
|
}
|
|
4091
4092
|
}
|
|
4092
4093
|
validateSlotCountPropLinkages(props, processedProps);
|
|
4093
4094
|
return { props: processedProps, validators: propValidators };
|
|
4094
4095
|
}
|
|
4096
|
+
/**
|
|
4097
|
+
* The editor stores a single-select choice value as a `string[]` (and the SDK unwraps
|
|
4098
|
+
* it to a scalar on render). Authors may write a single-select `defaultValue` as a
|
|
4099
|
+
* scalar for ergonomics, so canonicalize it to a one-element array here — that keeps
|
|
4100
|
+
* one storage shape across every consumer. Without it, a scalar default reaches the
|
|
4101
|
+
* editor's array-only reader and the choice control renders with nothing selected.
|
|
4102
|
+
*/
|
|
4103
|
+
function normalizeChoiceDefaultValue(prop) {
|
|
4104
|
+
if (prop.type === "choice" &&
|
|
4105
|
+
!prop.multiSelect &&
|
|
4106
|
+
typeof prop.defaultValue === "string") {
|
|
4107
|
+
prop.defaultValue = [prop.defaultValue];
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4095
4110
|
function getExpandedPropTypes(prop) {
|
|
4096
4111
|
const propTypeMapping = {
|
|
4097
4112
|
array: { type: "array", items: { type: "any" } },
|
|
@@ -4148,6 +4163,15 @@ function getDefaultComponentRegistryOptions() {
|
|
|
4148
4163
|
};
|
|
4149
4164
|
}
|
|
4150
4165
|
|
|
4166
|
+
/**
|
|
4167
|
+
* True when the value is an RSC client-reference proxy — what a `"use client"`
|
|
4168
|
+
* module's exports look like from the server module graph (Next.js App
|
|
4169
|
+
* Router, Turbopack). Invoking one during SSR throws "Attempted to call X()
|
|
4170
|
+
* from the server", so real implementations always take precedence over
|
|
4171
|
+
* proxies in the registry.
|
|
4172
|
+
*/
|
|
4173
|
+
const isClientReferenceComponent = (component) => component?.$$typeof ===
|
|
4174
|
+
Symbol.for("react.client.reference");
|
|
4151
4175
|
class ComponentRegistry {
|
|
4152
4176
|
componentRegistry = new Map();
|
|
4153
4177
|
propValidatorRegistry = new Map();
|
|
@@ -4263,8 +4287,24 @@ class ComponentRegistry {
|
|
|
4263
4287
|
console.warn("Default components are not allowed.");
|
|
4264
4288
|
}
|
|
4265
4289
|
}
|
|
4266
|
-
|
|
4267
|
-
|
|
4290
|
+
const existing = this.componentRegistry.get(type);
|
|
4291
|
+
const existingIsClientReference = isClientReferenceComponent(existing?.component);
|
|
4292
|
+
const incomingIsClientReference = isClientReferenceComponent(componentConfig.component);
|
|
4293
|
+
// Never downgrade: a client-reference proxy (RSC server module graph)
|
|
4294
|
+
// must not replace an already-registered real implementation. The
|
|
4295
|
+
// registry is a globalThis singleton shared between the server graph
|
|
4296
|
+
// and the SSR pass — if the proxy wins, SSR emits empty placeholders
|
|
4297
|
+
// instead of content.
|
|
4298
|
+
if (existing && incomingIsClientReference && !existingIsClientReference) {
|
|
4299
|
+
return;
|
|
4300
|
+
}
|
|
4301
|
+
// If already have and override not allowed continue with registered
|
|
4302
|
+
// version — unless the stored entry is a client-reference proxy and a
|
|
4303
|
+
// real implementation just arrived (SSR/client graph registering after
|
|
4304
|
+
// the server graph): upgrade so server renders emit real content.
|
|
4305
|
+
if (existing &&
|
|
4306
|
+
!options.overrideComponents &&
|
|
4307
|
+
!(existingIsClientReference && !incomingIsClientReference)) {
|
|
4268
4308
|
return;
|
|
4269
4309
|
}
|
|
4270
4310
|
const { processedOptions, propValidators } = processRegistryOptions(componentConfig, {
|
|
@@ -6372,6 +6412,9 @@ function retrievePropValue(args) {
|
|
|
6372
6412
|
// Section-slot needs its own node uid at render time so it can look up
|
|
6373
6413
|
// the page-side fill in SectionInstanceSlotsCtx.slotsMap[node.uid].
|
|
6374
6414
|
mappedData["_uid"] = node.uid;
|
|
6415
|
+
// The authored Slot default (COMS-1659): rendered when a placement leaves
|
|
6416
|
+
// the slot empty (editor preview only; design keeps the dropzone).
|
|
6417
|
+
mappedData["defaultSection"] = node?.metadata?.defaultSection?.uid;
|
|
6375
6418
|
}
|
|
6376
6419
|
if (node.type === "condition-block") {
|
|
6377
6420
|
mappedData["condition"] = node?.metadata?.condition;
|