@contentstack/studio-registry 1.10.0 → 2.0.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/cjs/index.cjs +199 -45
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/common/global-store.js +44 -8
- package/dist/esm/common/global-store.js.map +1 -1
- package/dist/esm/component-registry/registry-options-processor.js +42 -0
- package/dist/esm/component-registry/registry-options-processor.js.map +1 -1
- package/dist/esm/component-registry/registry.js +1 -1
- package/dist/esm/component-registry/registry.js.map +1 -1
- package/dist/esm/component-registry/singleton.js +40 -10
- package/dist/esm/component-registry/singleton.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.js +26 -13
- package/dist/esm/data-binder/retrieve-data.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.util.js +31 -1
- package/dist/esm/data-binder/retrieve-data.util.js.map +1 -1
- package/dist/esm/index.d.ts +94 -46
- package/dist/esm/index.js +3 -3
- package/dist/esm/state-store/function-registry.js +6 -6
- package/dist/esm/state-store/function-registry.js.map +1 -1
- package/dist/esm/state-store/public-api.js +1 -1
- package/dist/esm/state-store/public-api.js.map +1 -1
- package/dist/esm/state-store/state-store.js +8 -8
- package/dist/esm/state-store/state-store.js.map +1 -1
- package/package.json +12 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var constants = require('@contentstack/studio-messenger/constants');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Keys for registry error message lookup. Use these constants instead of string literals.
|
|
@@ -3949,6 +3949,7 @@ function processRegistryOptions(userConfig, options) {
|
|
|
3949
3949
|
defaultOptions.thumbnailUrl = userConfig.thumbnailUrl;
|
|
3950
3950
|
}
|
|
3951
3951
|
validateDesignProps(userConfig.type, defaultOptions.props, userConfig.styles);
|
|
3952
|
+
validateSlotDataFrom(userConfig.type, defaultOptions.props);
|
|
3952
3953
|
if (userConfig.styles) {
|
|
3953
3954
|
defaultOptions.styles = processRegistryOptionsStylesOptions(userConfig.styles);
|
|
3954
3955
|
}
|
|
@@ -4211,6 +4212,47 @@ function validateSlotCountPropLinkages(originalProps, processedProps) {
|
|
|
4211
4212
|
};
|
|
4212
4213
|
}
|
|
4213
4214
|
}
|
|
4215
|
+
/**
|
|
4216
|
+
* `dataFrom` on a slot names the prop whose bound data a `<Slot data>` key
|
|
4217
|
+
* forwards, so Studio can resolve that key's CMS schema. It is a schema hint
|
|
4218
|
+
* only — a bad entry must not break registration, so it is dropped with a
|
|
4219
|
+
* warning (registry convention: warn, don't throw). A target has to be a
|
|
4220
|
+
* registered, non-slot prop: a slot holds nodes, not data, and a missing name
|
|
4221
|
+
* would silently fall back to the plain-JSON schema Studio shows today.
|
|
4222
|
+
*/
|
|
4223
|
+
function validateSlotDataFrom(componentType, processedProps) {
|
|
4224
|
+
for (const [field, prop] of Object.entries(processedProps)) {
|
|
4225
|
+
if (prop.type !== "slot")
|
|
4226
|
+
continue;
|
|
4227
|
+
const slotProp = prop;
|
|
4228
|
+
const { dataFrom } = slotProp;
|
|
4229
|
+
if (dataFrom === undefined)
|
|
4230
|
+
continue;
|
|
4231
|
+
const warn = (reason) => console.warn(`[studio] Ignoring \`dataFrom\` ${reason} on slot "${field}" of component "${componentType}".`);
|
|
4232
|
+
if (!dataFrom || typeof dataFrom !== "object" || Array.isArray(dataFrom)) {
|
|
4233
|
+
warn("(expected an object mapping slot data keys to prop names)");
|
|
4234
|
+
delete slotProp.dataFrom;
|
|
4235
|
+
continue;
|
|
4236
|
+
}
|
|
4237
|
+
const valid = {};
|
|
4238
|
+
for (const [key, propName] of Object.entries(dataFrom)) {
|
|
4239
|
+
const target = typeof propName === "string" ? processedProps[propName] : undefined;
|
|
4240
|
+
if (!target) {
|
|
4241
|
+
warn(`entry "${key}": "${String(propName)}" is not a registered prop`);
|
|
4242
|
+
}
|
|
4243
|
+
else if (target.type === "slot") {
|
|
4244
|
+
warn(`entry "${key}": "${propName}" is a slot, not a data prop`);
|
|
4245
|
+
}
|
|
4246
|
+
else {
|
|
4247
|
+
valid[key] = propName;
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
if (Object.keys(valid).length)
|
|
4251
|
+
slotProp.dataFrom = valid;
|
|
4252
|
+
else
|
|
4253
|
+
delete slotProp.dataFrom;
|
|
4254
|
+
}
|
|
4255
|
+
}
|
|
4214
4256
|
function getBlockStyleSections() {
|
|
4215
4257
|
return STYLE_SECTION_CATEGORIES.block;
|
|
4216
4258
|
}
|
|
@@ -4710,8 +4752,34 @@ class ComponentRegistry {
|
|
|
4710
4752
|
*
|
|
4711
4753
|
* The key is versioned (`_v1`) so future shape changes can land under `_v2`
|
|
4712
4754
|
* without colliding with older SDK copies during a partial upgrade.
|
|
4755
|
+
*
|
|
4756
|
+
* ── Why there are TWO slots ─────────────────────────────────────────────────
|
|
4757
|
+
* Sharing works for everything whose value is identical in both graphs (design
|
|
4758
|
+
* tokens, breakpoints, state). It does NOT work for the component registry,
|
|
4759
|
+
* because the two renderers need DIFFERENT values for the same component type:
|
|
4760
|
+
*
|
|
4761
|
+
* - `StudioServerComponent` (`@contentstack/studio-react/rsc`) runs in the RSC
|
|
4762
|
+
* graph and needs the CLIENT REFERENCE for a `"use client"` component, so
|
|
4763
|
+
* React can serialize it as an island.
|
|
4764
|
+
* - `StudioComponent` (main entry) runs in the SSR/browser graph and needs the
|
|
4765
|
+
* REAL implementation, because a client reference cannot be called.
|
|
4766
|
+
*
|
|
4767
|
+
* With one shared slot and one entry per type, whichever graph registered
|
|
4768
|
+
* first decided what the other graph rendered. When the RSC renderer lost that
|
|
4769
|
+
* race it called a client component itself, outside any client React runtime,
|
|
4770
|
+
* and the first hook threw `Cannot read properties of null (reading
|
|
4771
|
+
* 'useState')`. Components without hooks rendered inline and silently lost
|
|
4772
|
+
* their island, so the breakage was invisible until an interactive component
|
|
4773
|
+
* hit it.
|
|
4774
|
+
*
|
|
4775
|
+
* So the component registry is keyed per graph: the RSC entry reads and writes
|
|
4776
|
+
* the `_rsc` slot, every other consumer keeps the original slot. Registration
|
|
4777
|
+
* order stops being load-bearing. The remaining registries stay shared — their
|
|
4778
|
+
* contents are plain data, correct in either graph.
|
|
4713
4779
|
*/
|
|
4714
4780
|
const GLOBAL_STORE_KEY = "__contentstack_studio_registry_v1";
|
|
4781
|
+
const GLOBAL_STORE_KEY_SERVER = "__contentstack_studio_registry_v1_rsc";
|
|
4782
|
+
const storeKeyFor = (graph) => graph === "server" ? GLOBAL_STORE_KEY_SERVER : GLOBAL_STORE_KEY;
|
|
4715
4783
|
/**
|
|
4716
4784
|
* Returns the SDK's versioned slot on globalThis, creating it on first call.
|
|
4717
4785
|
* Always returns the same object reference within a single JS runtime.
|
|
@@ -4720,11 +4788,15 @@ const GLOBAL_STORE_KEY = "__contentstack_studio_registry_v1";
|
|
|
4720
4788
|
* read/write so the public API of `studio-registry` stays free of cross-
|
|
4721
4789
|
* package import dependencies (e.g. `BreakpointManager` lives in
|
|
4722
4790
|
* `studio-client`).
|
|
4791
|
+
*
|
|
4792
|
+
* @param graph - which slot to read. Defaults to `"client"`; only the RSC
|
|
4793
|
+
* entry passes `"server"`.
|
|
4723
4794
|
*/
|
|
4724
|
-
function getGlobalStudioStore() {
|
|
4795
|
+
function getGlobalStudioStore(graph = "client") {
|
|
4725
4796
|
const g = globalThis;
|
|
4726
|
-
|
|
4727
|
-
|
|
4797
|
+
const key = storeKeyFor(graph);
|
|
4798
|
+
if (!g[key]) {
|
|
4799
|
+
g[key] = {
|
|
4728
4800
|
componentRegistry: null,
|
|
4729
4801
|
designRegistry: null,
|
|
4730
4802
|
breakpointManager: null,
|
|
@@ -4732,17 +4804,30 @@ function getGlobalStudioStore() {
|
|
|
4732
4804
|
functionRegistry: null,
|
|
4733
4805
|
};
|
|
4734
4806
|
}
|
|
4735
|
-
return g[
|
|
4807
|
+
return g[key];
|
|
4736
4808
|
}
|
|
4737
4809
|
/**
|
|
4738
|
-
* Clears the
|
|
4739
|
-
*
|
|
4810
|
+
* Clears the store. For tests only. Production code should never call this —
|
|
4811
|
+
* it would orphan every existing reference to the previous instances.
|
|
4812
|
+
*
|
|
4813
|
+
* @param graph - clears just that graph's slot. Omit to clear both.
|
|
4740
4814
|
*/
|
|
4741
|
-
function resetGlobalStudioStore() {
|
|
4815
|
+
function resetGlobalStudioStore(graph) {
|
|
4742
4816
|
const g = globalThis;
|
|
4743
|
-
|
|
4817
|
+
const keys = graph
|
|
4818
|
+
? [storeKeyFor(graph)]
|
|
4819
|
+
: [GLOBAL_STORE_KEY, GLOBAL_STORE_KEY_SERVER];
|
|
4820
|
+
for (const key of keys)
|
|
4821
|
+
delete g[key];
|
|
4744
4822
|
}
|
|
4745
4823
|
|
|
4824
|
+
const registryFor = (graph) => {
|
|
4825
|
+
const store = getGlobalStudioStore(graph);
|
|
4826
|
+
if (!store.componentRegistry) {
|
|
4827
|
+
store.componentRegistry = new ComponentRegistry();
|
|
4828
|
+
}
|
|
4829
|
+
return store.componentRegistry;
|
|
4830
|
+
};
|
|
4746
4831
|
/**
|
|
4747
4832
|
* Singleton ComponentRegistry, backed by a versioned slot on `globalThis`.
|
|
4748
4833
|
*
|
|
@@ -4756,13 +4841,33 @@ function resetGlobalStudioStore() {
|
|
|
4756
4841
|
* After this change, all callers of `getComponentRegistryInstance()` resolve
|
|
4757
4842
|
* to the same `ComponentRegistry` instance within a single JS runtime,
|
|
4758
4843
|
* regardless of which graph or worker they were evaluated in.
|
|
4844
|
+
*
|
|
4845
|
+
* One exception: the RSC renderer has its own instance — see
|
|
4846
|
+
* {@link getServerComponentRegistryInstance} and the "Why there are TWO slots"
|
|
4847
|
+
* note in `common/global-store.ts`.
|
|
4759
4848
|
*/
|
|
4760
4849
|
function getComponentRegistryInstance() {
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4850
|
+
return registryFor("client");
|
|
4851
|
+
}
|
|
4852
|
+
/**
|
|
4853
|
+
* Singleton ComponentRegistry for the RSC (server) module graph, used only by
|
|
4854
|
+
* `@contentstack/studio-react/rsc`.
|
|
4855
|
+
*
|
|
4856
|
+
* It is a SEPARATE instance from {@link getComponentRegistryInstance} on
|
|
4857
|
+
* purpose. The two renderers need different values for the same component
|
|
4858
|
+
* type — a client reference for the RSC renderer, the real implementation for
|
|
4859
|
+
* the client renderer — and both graphs run in one process, sharing
|
|
4860
|
+
* `globalThis`. One entry per type meant the first registration to arrive
|
|
4861
|
+
* decided what the other renderer got, making correctness depend on request
|
|
4862
|
+
* order (a Studio canvas request before the first visitor render was enough to
|
|
4863
|
+
* break every visitor render for the life of the process).
|
|
4864
|
+
*
|
|
4865
|
+
* Consequence for consumers: registering in the browser/SSR graph no longer
|
|
4866
|
+
* populates the RSC renderer. An app using `StudioServerComponent` must
|
|
4867
|
+
* register from a server module through `@contentstack/studio-react/rsc`.
|
|
4868
|
+
*/
|
|
4869
|
+
function getServerComponentRegistryInstance() {
|
|
4870
|
+
return registryFor("server");
|
|
4766
4871
|
}
|
|
4767
4872
|
/**
|
|
4768
4873
|
* Resets the singleton instance.
|
|
@@ -4777,16 +4882,19 @@ function getComponentRegistryInstance() {
|
|
|
4777
4882
|
* });
|
|
4778
4883
|
* ```
|
|
4779
4884
|
*/
|
|
4780
|
-
function resetComponentRegistryInstance() {
|
|
4781
|
-
|
|
4885
|
+
function resetComponentRegistryInstance(graph) {
|
|
4886
|
+
const graphs = graph ? [graph] : ["client", "server"];
|
|
4887
|
+
for (const g of graphs)
|
|
4888
|
+
getGlobalStudioStore(g).componentRegistry = null;
|
|
4782
4889
|
}
|
|
4783
4890
|
/**
|
|
4784
4891
|
* Checks if the singleton instance has been created.
|
|
4785
4892
|
*
|
|
4893
|
+
* @param graph - which graph's instance to check. Defaults to `"client"`.
|
|
4786
4894
|
* @returns true if the instance exists, false otherwise
|
|
4787
4895
|
*/
|
|
4788
|
-
function hasComponentRegistryInstance() {
|
|
4789
|
-
return getGlobalStudioStore().componentRegistry !== null;
|
|
4896
|
+
function hasComponentRegistryInstance(graph = "client") {
|
|
4897
|
+
return getGlobalStudioStore(graph).componentRegistry !== null;
|
|
4790
4898
|
}
|
|
4791
4899
|
|
|
4792
4900
|
const SIZE_TOKENS = {
|
|
@@ -6045,6 +6153,35 @@ function normalizeSingleSelectChoiceValue(resolvedData, prop) {
|
|
|
6045
6153
|
}
|
|
6046
6154
|
return resolvedData;
|
|
6047
6155
|
}
|
|
6156
|
+
/**
|
|
6157
|
+
* A design prop's bound value is written straight into a CSS declaration —
|
|
6158
|
+
* there is no token-to-CSS step left. So a CMS field holding `gradient-teal`
|
|
6159
|
+
* rather than `linear-gradient(...)` (or `var(--card-bg-gradient-teal)`)
|
|
6160
|
+
* produces an invalid declaration that the browser silently drops: no error,
|
|
6161
|
+
* no style, nothing to tell an author their field is the problem.
|
|
6162
|
+
*
|
|
6163
|
+
* Best-effort and browser-only: `CSS.supports` is absent server-side, where
|
|
6164
|
+
* this stays quiet rather than guessing.
|
|
6165
|
+
*/
|
|
6166
|
+
const STYLE_BINDING_PATH = /^styles\.[^.]+\.responsiveStyles\.[^.]+\.(.+)$/;
|
|
6167
|
+
const warnOnNonCssBoundValue = (key, value) => {
|
|
6168
|
+
const property = STYLE_BINDING_PATH.exec(key)?.[1];
|
|
6169
|
+
if (!property || typeof value !== "string" || !value.trim())
|
|
6170
|
+
return;
|
|
6171
|
+
if (typeof CSS === "undefined" || typeof CSS.supports !== "function")
|
|
6172
|
+
return;
|
|
6173
|
+
const kebab = property.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
6174
|
+
try {
|
|
6175
|
+
if (CSS.supports(kebab, value))
|
|
6176
|
+
return;
|
|
6177
|
+
}
|
|
6178
|
+
catch {
|
|
6179
|
+
return;
|
|
6180
|
+
}
|
|
6181
|
+
console.warn(`[studio] Bound design prop "${property}" resolved to "${value}", which is not a valid ` +
|
|
6182
|
+
`value for that CSS property — the declaration will be dropped and nothing will render. ` +
|
|
6183
|
+
`The field this is bound to has to hold a CSS value (e.g. a var(--token) or a literal).`);
|
|
6184
|
+
};
|
|
6048
6185
|
const resolveMetadataBindings = (node, data) => {
|
|
6049
6186
|
if (!node.metadata?.bindings)
|
|
6050
6187
|
return;
|
|
@@ -6053,6 +6190,7 @@ const resolveMetadataBindings = (node, data) => {
|
|
|
6053
6190
|
const binding = bindings[key];
|
|
6054
6191
|
const dataPath = binding && getBindingString(binding);
|
|
6055
6192
|
const getBinding = get(data, dataPath);
|
|
6193
|
+
warnOnNonCssBoundValue(key, getBinding);
|
|
6056
6194
|
set(node, key, getBinding);
|
|
6057
6195
|
}
|
|
6058
6196
|
};
|
|
@@ -6140,6 +6278,28 @@ const reportedBindingErrors = new Set();
|
|
|
6140
6278
|
* Keys are `${nodeUid}-${field}`; the trailing `-` (and fixed-length uids)
|
|
6141
6279
|
* makes the prefix match exact, so one node's uid can't match another's.
|
|
6142
6280
|
*/
|
|
6281
|
+
/**
|
|
6282
|
+
* Reports a binding error to the Visual Builder.
|
|
6283
|
+
*
|
|
6284
|
+
* The event manager is imported on demand rather than at module scope: it is
|
|
6285
|
+
* the postMessage bridge, and importing it statically pulls
|
|
6286
|
+
* @contentstack/advanced-post-message into every bundle that reaches this
|
|
6287
|
+
* module — including a published site, where `composableStudioEventManager` is
|
|
6288
|
+
* `undefined` and these calls do nothing. Both call sites are already
|
|
6289
|
+
* editor-only and best-effort, so sending a microtask later is not observable.
|
|
6290
|
+
*/
|
|
6291
|
+
function reportBindingError(propKey, errorMessage) {
|
|
6292
|
+
// The send is RETURNED from `then` so `catch` covers it as well as the
|
|
6293
|
+
// import. `send` rejects with NO_REQUEST_LISTENER_FOUND whenever nothing is
|
|
6294
|
+
// listening on the other side — which is every context except an open Studio
|
|
6295
|
+
// canvas — and an uncaught rejection there surfaces in the visitor's console
|
|
6296
|
+
// and fails the test run. Best-effort telemetry must never reject.
|
|
6297
|
+
void import('@contentstack/studio-messenger')
|
|
6298
|
+
.then(({ composableStudioEventManager }) => composableStudioEventManager?.send(constants.POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, { propKey, errorMessage }))
|
|
6299
|
+
.catch((error) => {
|
|
6300
|
+
console.warn("[studio] could not send", constants.POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, error);
|
|
6301
|
+
});
|
|
6302
|
+
}
|
|
6143
6303
|
function clearReportedBindingErrorsForNode(nodeUid) {
|
|
6144
6304
|
if (reportedBindingErrors.size === 0)
|
|
6145
6305
|
return;
|
|
@@ -6148,10 +6308,7 @@ function clearReportedBindingErrorsForNode(nodeUid) {
|
|
|
6148
6308
|
if (!propKey.startsWith(prefix))
|
|
6149
6309
|
continue;
|
|
6150
6310
|
reportedBindingErrors.delete(propKey);
|
|
6151
|
-
|
|
6152
|
-
propKey,
|
|
6153
|
-
errorMessage: "",
|
|
6154
|
-
});
|
|
6311
|
+
reportBindingError(propKey, "");
|
|
6155
6312
|
}
|
|
6156
6313
|
}
|
|
6157
6314
|
// Responsible for resolving props to values
|
|
@@ -6417,10 +6574,7 @@ function retrievePropValue(args) {
|
|
|
6417
6574
|
if (isCompositionBeingEdited) {
|
|
6418
6575
|
// In editor mode: Send to Visual Builder
|
|
6419
6576
|
reportedBindingErrors.add(`${node.uid}-${field}`);
|
|
6420
|
-
|
|
6421
|
-
propKey: `${node.uid}-${field}`,
|
|
6422
|
-
errorMessage: getRegistryErrorMessage(RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH_EDITOR, { expectedType: type, receivedType }),
|
|
6423
|
-
});
|
|
6577
|
+
reportBindingError(`${node.uid}-${field}`, getRegistryErrorMessage(RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH_EDITOR, { expectedType: type, receivedType }));
|
|
6424
6578
|
}
|
|
6425
6579
|
else {
|
|
6426
6580
|
// In production mode: Console warning
|
|
@@ -6444,10 +6598,7 @@ function retrievePropValue(args) {
|
|
|
6444
6598
|
const propKey = `${node.uid}-${field}`;
|
|
6445
6599
|
if (reportedBindingErrors.has(propKey)) {
|
|
6446
6600
|
reportedBindingErrors.delete(propKey);
|
|
6447
|
-
|
|
6448
|
-
propKey,
|
|
6449
|
-
errorMessage: "",
|
|
6450
|
-
});
|
|
6601
|
+
reportBindingError(propKey, "");
|
|
6451
6602
|
}
|
|
6452
6603
|
}
|
|
6453
6604
|
mappedData[field] = resolvedData;
|
|
@@ -6633,7 +6784,7 @@ class StudioStateStore {
|
|
|
6633
6784
|
this.externalUnsubs.clear();
|
|
6634
6785
|
if (storage === "custom") {
|
|
6635
6786
|
if (!hasCustomFns) {
|
|
6636
|
-
throw new Error('[
|
|
6787
|
+
throw new Error('[Contentstack Studio] state storage "custom" requires getState and setState functions');
|
|
6637
6788
|
}
|
|
6638
6789
|
this.userConfig = {
|
|
6639
6790
|
getState: config.getState,
|
|
@@ -6643,7 +6794,7 @@ class StudioStateStore {
|
|
|
6643
6794
|
}
|
|
6644
6795
|
else {
|
|
6645
6796
|
if (hasCustomFns && isDev$1()) {
|
|
6646
|
-
console.warn(`[
|
|
6797
|
+
console.warn(`[Contentstack Studio] state storage "${storage}" uses the built-in store — the provided getState/setState are ignored (use storage: "custom" to keep them)`);
|
|
6647
6798
|
}
|
|
6648
6799
|
this.userConfig = createWebStorageBackend(storage, config.storageKey ?? DEFAULT_STORAGE_KEY);
|
|
6649
6800
|
}
|
|
@@ -6695,7 +6846,7 @@ class StudioStateStore {
|
|
|
6695
6846
|
this.externalUnsubs.set(key, typeof unsub === "function" ? unsub : () => { });
|
|
6696
6847
|
}
|
|
6697
6848
|
catch (err) {
|
|
6698
|
-
console.error(`[
|
|
6849
|
+
console.error(`[Contentstack Studio] state subscribe("${key}") threw:`, err);
|
|
6699
6850
|
}
|
|
6700
6851
|
}
|
|
6701
6852
|
isConfigured() {
|
|
@@ -6727,7 +6878,7 @@ class StudioStateStore {
|
|
|
6727
6878
|
return;
|
|
6728
6879
|
}
|
|
6729
6880
|
if (existing.type !== def.type && isDev$1()) {
|
|
6730
|
-
console.warn(`[
|
|
6881
|
+
console.warn(`[Contentstack Studio] state variable "${key}" already declared as "${existing.type}"; ignoring re-declaration as "${def.type}"`);
|
|
6731
6882
|
}
|
|
6732
6883
|
return;
|
|
6733
6884
|
}
|
|
@@ -6760,7 +6911,7 @@ class StudioStateStore {
|
|
|
6760
6911
|
listener();
|
|
6761
6912
|
}
|
|
6762
6913
|
catch (err) {
|
|
6763
|
-
console.error("[
|
|
6914
|
+
console.error("[Contentstack Studio] state variables-changed listener threw:", err);
|
|
6764
6915
|
}
|
|
6765
6916
|
}
|
|
6766
6917
|
}
|
|
@@ -6783,7 +6934,7 @@ class StudioStateStore {
|
|
|
6783
6934
|
return this.userConfig.getState(key);
|
|
6784
6935
|
}
|
|
6785
6936
|
catch (err) {
|
|
6786
|
-
console.error(`[
|
|
6937
|
+
console.error(`[Contentstack Studio] getState("${key}") threw:`, err);
|
|
6787
6938
|
return undefined;
|
|
6788
6939
|
}
|
|
6789
6940
|
}
|
|
@@ -6800,7 +6951,7 @@ class StudioStateStore {
|
|
|
6800
6951
|
if (isServer()) {
|
|
6801
6952
|
if (!this.warnedServerSet && isDev$1()) {
|
|
6802
6953
|
this.warnedServerSet = true;
|
|
6803
|
-
console.warn("[
|
|
6954
|
+
console.warn("[Contentstack Studio] setState is a no-op during server rendering — state writes are client-only");
|
|
6804
6955
|
}
|
|
6805
6956
|
return;
|
|
6806
6957
|
}
|
|
@@ -6861,7 +7012,7 @@ class StudioStateStore {
|
|
|
6861
7012
|
listener();
|
|
6862
7013
|
}
|
|
6863
7014
|
catch (err) {
|
|
6864
|
-
console.error(`[
|
|
7015
|
+
console.error(`[Contentstack Studio] state listener for "${key}" threw:`, err);
|
|
6865
7016
|
}
|
|
6866
7017
|
}
|
|
6867
7018
|
}
|
|
@@ -6946,7 +7097,7 @@ function notifyFunctionsChanged() {
|
|
|
6946
7097
|
listener();
|
|
6947
7098
|
}
|
|
6948
7099
|
catch (err) {
|
|
6949
|
-
console.error("[
|
|
7100
|
+
console.error("[Contentstack Studio] studio-functions change listener threw:", err);
|
|
6950
7101
|
}
|
|
6951
7102
|
}
|
|
6952
7103
|
}
|
|
@@ -6985,11 +7136,11 @@ function registerStudioFunctions(functions) {
|
|
|
6985
7136
|
const registry = getRegistry();
|
|
6986
7137
|
for (const [name, fn] of Object.entries(functions ?? {})) {
|
|
6987
7138
|
if (typeof fn !== "function") {
|
|
6988
|
-
console.warn(`[
|
|
7139
|
+
console.warn(`[Contentstack Studio] registerStudioFunctions: "${name}" is not a function — skipped`);
|
|
6989
7140
|
continue;
|
|
6990
7141
|
}
|
|
6991
7142
|
if (registry.functions.has(name) && isDev()) {
|
|
6992
|
-
console.warn(`[
|
|
7143
|
+
console.warn(`[Contentstack Studio] studio function "${name}" re-registered (overwriting previous)`);
|
|
6993
7144
|
}
|
|
6994
7145
|
registry.functions.set(name, fn);
|
|
6995
7146
|
}
|
|
@@ -7013,7 +7164,7 @@ function getStudioFunctionNames() {
|
|
|
7013
7164
|
function callStudioFunction(name, ...args) {
|
|
7014
7165
|
const fn = getRegistry().functions.get(name);
|
|
7015
7166
|
if (!fn) {
|
|
7016
|
-
console.warn(`[
|
|
7167
|
+
console.warn(`[Contentstack Studio] studio function "${name}" is not registered. Did you call registerStudioFunctions()?`);
|
|
7017
7168
|
return undefined;
|
|
7018
7169
|
}
|
|
7019
7170
|
const store = getStateStoreInstance();
|
|
@@ -7031,14 +7182,14 @@ function callStudioFunction(name, ...args) {
|
|
|
7031
7182
|
typeof result.then === "function" &&
|
|
7032
7183
|
typeof result.catch === "function") {
|
|
7033
7184
|
return result.catch((err) => {
|
|
7034
|
-
console.error(`[
|
|
7185
|
+
console.error(`[Contentstack Studio] studio function "${name}" rejected:`, err);
|
|
7035
7186
|
return undefined;
|
|
7036
7187
|
});
|
|
7037
7188
|
}
|
|
7038
7189
|
return result;
|
|
7039
7190
|
}
|
|
7040
7191
|
catch (err) {
|
|
7041
|
-
console.error(`[
|
|
7192
|
+
console.error(`[Contentstack Studio] studio function "${name}" threw:`, err);
|
|
7042
7193
|
return undefined;
|
|
7043
7194
|
}
|
|
7044
7195
|
}
|
|
@@ -7290,7 +7441,7 @@ class BreakpointRegistry {
|
|
|
7290
7441
|
*/
|
|
7291
7442
|
function registerComponentStateVariable(key, options) {
|
|
7292
7443
|
if (!key || typeof key !== "string") {
|
|
7293
|
-
throw new Error("[
|
|
7444
|
+
throw new Error("[Contentstack Studio] registerComponentStateVariable requires a non-empty string key");
|
|
7294
7445
|
}
|
|
7295
7446
|
getStateStoreInstance().declareVariable(key, options, "component");
|
|
7296
7447
|
}
|
|
@@ -7444,6 +7595,7 @@ exports.getPlaceHolderComponent = getPlaceHolderComponent;
|
|
|
7444
7595
|
exports.getRepeaterBinding = getRepeaterBinding;
|
|
7445
7596
|
exports.getRepeaterContextPath = getRepeaterContextPath;
|
|
7446
7597
|
exports.getSectionUIDFromNode = getSectionUIDFromNode;
|
|
7598
|
+
exports.getServerComponentRegistryInstance = getServerComponentRegistryInstance;
|
|
7447
7599
|
exports.getSlotData = getSlotData;
|
|
7448
7600
|
exports.getStateDefaultsFor = getStateDefaultsFor;
|
|
7449
7601
|
exports.getStateStoreInstance = getStateStoreInstance;
|
|
@@ -7452,6 +7604,7 @@ exports.getStudioFunctionNames = getStudioFunctionNames;
|
|
|
7452
7604
|
exports.getStudioStateSnapshot = getStudioStateSnapshot;
|
|
7453
7605
|
exports.hasComponentRegistryInstance = hasComponentRegistryInstance;
|
|
7454
7606
|
exports.hasDesignRegistryInstance = hasDesignRegistryInstance;
|
|
7607
|
+
exports.isClientReferenceComponent = isClientReferenceComponent;
|
|
7455
7608
|
exports.isDataMatchingPropType = isDataMatchingPropType;
|
|
7456
7609
|
exports.isKnownType = isKnownType;
|
|
7457
7610
|
exports.normalizeSingleSelectChoiceValue = normalizeSingleSelectChoiceValue;
|
|
@@ -7468,5 +7621,6 @@ exports.retrievePropValue = retrievePropValue;
|
|
|
7468
7621
|
exports.studioState = studioState;
|
|
7469
7622
|
exports.subscribeStudioFunctionsChanged = subscribeStudioFunctionsChanged;
|
|
7470
7623
|
exports.subscribeStudioStateVariablesChanged = subscribeStudioStateVariablesChanged;
|
|
7624
|
+
exports.warnOnNonCssBoundValue = warnOnNonCssBoundValue;
|
|
7471
7625
|
exports.wrapActionProps = wrapActionProps;
|
|
7472
7626
|
//# sourceMappingURL=index.cjs.map
|