@webstudio-is/react-sdk 0.0.0-73cd6ea → 0.0.0-7a19155

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/lib/index.js CHANGED
@@ -57,7 +57,8 @@ var generateRemixParams = (pathname) => {
57
57
  // src/props.ts
58
58
  import {
59
59
  getPagePath,
60
- findPageByIdOrPath
60
+ findPageByIdOrPath,
61
+ findTreeInstanceIdsExcludingSubtrees
61
62
  } from "@webstudio-is/sdk";
62
63
  var normalizeProps = ({
63
64
  props,
@@ -97,6 +98,14 @@ var normalizeProps = ({
97
98
  });
98
99
  continue;
99
100
  }
101
+ if (prop.name === "alt" && asset.type === "image") {
102
+ newProps.push({
103
+ ...propBase,
104
+ type: "string",
105
+ value: asset.description ?? ""
106
+ });
107
+ continue;
108
+ }
100
109
  newProps.push({
101
110
  ...propBase,
102
111
  type: "string",
@@ -153,8 +162,25 @@ var idAttribute = "data-ws-id";
153
162
  var selectorIdAttribute = "data-ws-selector";
154
163
  var componentAttribute = "data-ws-component";
155
164
  var showAttribute = "data-ws-show";
156
- var collapsedAttribute = "data-ws-collapsed";
165
+ var inflatedAttribute = "data-ws-collapsed";
157
166
  var textContentAttribute = "data-ws-text-content";
167
+ var findTreeInstanceIdsExcludingStaticHidden = ({
168
+ instances,
169
+ props,
170
+ rootInstanceId
171
+ }) => {
172
+ const hiddenInstanceIds = /* @__PURE__ */ new Set();
173
+ for (const prop of props.values()) {
174
+ if (prop.name === showAttribute && prop.type === "boolean" && prop.value === false) {
175
+ hiddenInstanceIds.add(prop.instanceId);
176
+ }
177
+ }
178
+ return findTreeInstanceIdsExcludingSubtrees(
179
+ instances,
180
+ rootInstanceId,
181
+ hiddenInstanceIds
182
+ );
183
+ };
158
184
  var attributeNameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
159
185
  var attributeNameChar = attributeNameStartChar + ":\\-0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
160
186
  var validAttributeNameRegex = new RegExp(
@@ -178,240 +204,55 @@ var isAttributeNameSafe = (attributeName) => {
178
204
  return false;
179
205
  };
180
206
 
207
+ // src/collection-utils.ts
208
+ var getCollectionEntries = (data) => {
209
+ if (data === null || data === void 0) {
210
+ return [];
211
+ }
212
+ if (typeof data !== "object") {
213
+ return [];
214
+ }
215
+ const entries = Object.entries(data);
216
+ if (Array.isArray(data)) {
217
+ return entries.map(([key, value]) => [Number(key), value]);
218
+ }
219
+ return entries;
220
+ };
221
+ var isStaticCollectionExpression = (expression) => {
222
+ const trimmedExpression = expression.trim();
223
+ return trimmedExpression.startsWith("[") && trimmedExpression.endsWith("]") || trimmedExpression.startsWith("{") && trimmedExpression.endsWith("}") || trimmedExpression.startsWith("({") && trimmedExpression.endsWith("})");
224
+ };
225
+ var generateCollectionIterationCode = ({
226
+ dataExpression,
227
+ keyVariable,
228
+ itemVariable
229
+ }) => {
230
+ const safeDataExpression = isStaticCollectionExpression(dataExpression) ? dataExpression : `${dataExpression} ?? {}`;
231
+ return `Object.entries(
232
+ // @ts-ignore
233
+ ${safeDataExpression}
234
+ ).map(([_key, ${itemVariable}]: any) => {
235
+ const ${keyVariable} = Array.isArray(${dataExpression}) ? Number(_key) : _key;
236
+ return`;
237
+ };
238
+
181
239
  // src/component-generator.ts
182
240
  import {
183
241
  parseComponentName,
184
242
  generateExpression,
185
243
  decodeDataSourceVariable,
186
- transpileExpression,
244
+ contentBlockDocumentProp,
187
245
  blockComponent,
246
+ blockBodyComponent,
188
247
  blockTemplateComponent,
189
248
  collectionComponent,
190
249
  descendantComponent,
191
250
  getIndexesWithinAncestors,
192
251
  elementComponent
193
252
  } from "@webstudio-is/sdk";
253
+ import { transpileExpression } from "@webstudio-is/expression";
194
254
  import { indexProperty, tagProperty } from "@webstudio-is/sdk/runtime";
195
-
196
- // src/__generated__/standard-attributes.ts
197
- var standardAttributesToReactProps = {
198
- "accept-charset": "acceptCharset",
199
- accesskey: "accessKey",
200
- allowfullscreen: "allowFullScreen",
201
- autocapitalize: "autoCapitalize",
202
- autocomplete: "autoComplete",
203
- autocorrect: "autoCorrect",
204
- autofocus: "autoFocus",
205
- autoplay: "autoPlay",
206
- charset: "charSet",
207
- class: "className",
208
- colspan: "colSpan",
209
- contenteditable: "contentEditable",
210
- crossorigin: "crossOrigin",
211
- datetime: "dateTime",
212
- enctype: "encType",
213
- enterkeyhint: "enterKeyHint",
214
- fetchpriority: "fetchPriority",
215
- for: "htmlFor",
216
- formmethod: "formMethod",
217
- formaction: "formAction",
218
- formenctype: "formEncType",
219
- formnovalidate: "formNoValidate",
220
- formtarget: "formTarget",
221
- hreflang: "hrefLang",
222
- "http-equiv": "httpEquiv",
223
- imagesizes: "imageSizes",
224
- imagesrcset: "imageSrcSet",
225
- inputmode: "inputMode",
226
- itemid: "itemID",
227
- itemprop: "itemProp",
228
- itemref: "itemRef",
229
- itemscope: "itemScope",
230
- itemtype: "itemType",
231
- maxlength: "maxLength",
232
- minlength: "minLength",
233
- nomodule: "noModule",
234
- novalidate: "noValidate",
235
- playsinline: "playsInline",
236
- readonly: "readOnly",
237
- referrerpolicy: "referrerPolicy",
238
- rowspan: "rowSpan",
239
- spellcheck: "spellCheck",
240
- srcdoc: "srcDoc",
241
- srclang: "srcLang",
242
- srcset: "srcSet",
243
- tabindex: "tabIndex",
244
- usemap: "useMap",
245
- "alignment-baseline": "alignmentBaseline",
246
- "baseline-shift": "baselineShift",
247
- "clip-path": "clipPath",
248
- "clip-rule": "clipRule",
249
- "color-interpolation": "colorInterpolation",
250
- "color-interpolation-filters": "colorInterpolationFilters",
251
- "color-profile": "colorProfile",
252
- "color-rendering": "colorRendering",
253
- "dominant-baseline": "dominantBaseline",
254
- "enable-background": "enableBackground",
255
- "fill-opacity": "fillOpacity",
256
- "fill-rule": "fillRule",
257
- "flood-opacity": "floodOpacity",
258
- "flood-color": "floodColor",
259
- "font-family": "fontFamily",
260
- "font-size": "fontSize",
261
- "font-size-adjust": "fontSizeAdjust",
262
- "font-stretch": "fontStretch",
263
- "font-style": "fontStyle",
264
- "font-variant": "fontVariant",
265
- "font-weight": "fontWeight",
266
- "glyph-orientation-horizontal": "glyphOrientationHorizontal",
267
- "glyph-orientation-vertical": "glyphOrientationVertical",
268
- "image-rendering": "imageRendering",
269
- "letter-spacing": "letterSpacing",
270
- "lighting-color": "lightingColor",
271
- "marker-end": "markerEnd",
272
- "marker-mid": "markerMid",
273
- "marker-start": "markerStart",
274
- "pointer-events": "pointerEvents",
275
- popovertarget: "popoverTarget",
276
- popovertargetaction: "popoverTargetAction",
277
- "shape-rendering": "shapeRendering",
278
- "stop-color": "stopColor",
279
- "stop-opacity": "stopOpacity",
280
- "stroke-dasharray": "strokeDasharray",
281
- "stroke-dashoffset": "strokeDashoffset",
282
- "stroke-linecap": "strokeLinecap",
283
- "stroke-linejoin": "strokeLinejoin",
284
- "stroke-miterlimit": "strokeMiterlimit",
285
- "stroke-width": "strokeWidth",
286
- "stroke-opacity": "strokeOpacity",
287
- "text-anchor": "textAnchor",
288
- "text-decoration": "textDecoration",
289
- "text-rendering": "textRendering",
290
- "unicode-bidi": "unicodeBidi",
291
- "word-spacing": "wordSpacing",
292
- "writing-mode": "writingMode",
293
- "xlink:actuate": "xlinkActuate",
294
- "xlink:arcrole": "xlinkArcrole",
295
- "xlink:href": "xlinkHref",
296
- "xlink:role": "xlinkRole",
297
- "xlink:show": "xlinkShow",
298
- "xlink:title": "xlinkTitle",
299
- "xlink:type": "xlinkType",
300
- "xml:base": "xmlBase",
301
- "xml:lang": "xmlLang",
302
- "xml:space": "xmlSpace",
303
- dirname: "dirName"
304
- };
305
- var reactPropsToStandardAttributes = {
306
- acceptCharset: "accept-charset",
307
- accessKey: "accesskey",
308
- allowFullScreen: "allowfullscreen",
309
- autoCapitalize: "autocapitalize",
310
- autoComplete: "autocomplete",
311
- autoCorrect: "autocorrect",
312
- autoFocus: "autofocus",
313
- autoPlay: "autoplay",
314
- charSet: "charset",
315
- className: "class",
316
- colSpan: "colspan",
317
- contentEditable: "contenteditable",
318
- crossOrigin: "crossorigin",
319
- dateTime: "datetime",
320
- encType: "enctype",
321
- enterKeyHint: "enterkeyhint",
322
- fetchPriority: "fetchpriority",
323
- htmlFor: "for",
324
- formMethod: "formmethod",
325
- formAction: "formaction",
326
- formEncType: "formenctype",
327
- formNoValidate: "formnovalidate",
328
- formTarget: "formtarget",
329
- hrefLang: "hreflang",
330
- httpEquiv: "http-equiv",
331
- imageSizes: "imagesizes",
332
- imageSrcSet: "imagesrcset",
333
- inputMode: "inputmode",
334
- itemID: "itemid",
335
- itemProp: "itemprop",
336
- itemRef: "itemref",
337
- itemScope: "itemscope",
338
- itemType: "itemtype",
339
- maxLength: "maxlength",
340
- minLength: "minlength",
341
- noModule: "nomodule",
342
- noValidate: "novalidate",
343
- playsInline: "playsinline",
344
- readOnly: "readonly",
345
- referrerPolicy: "referrerpolicy",
346
- rowSpan: "rowspan",
347
- spellCheck: "spellcheck",
348
- srcDoc: "srcdoc",
349
- srcLang: "srclang",
350
- srcSet: "srcset",
351
- tabIndex: "tabindex",
352
- useMap: "usemap",
353
- alignmentBaseline: "alignment-baseline",
354
- baselineShift: "baseline-shift",
355
- clipPath: "clip-path",
356
- clipRule: "clip-rule",
357
- colorInterpolation: "color-interpolation",
358
- colorInterpolationFilters: "color-interpolation-filters",
359
- colorProfile: "color-profile",
360
- colorRendering: "color-rendering",
361
- dominantBaseline: "dominant-baseline",
362
- enableBackground: "enable-background",
363
- fillOpacity: "fill-opacity",
364
- fillRule: "fill-rule",
365
- floodOpacity: "flood-opacity",
366
- floodColor: "flood-color",
367
- fontFamily: "font-family",
368
- fontSize: "font-size",
369
- fontSizeAdjust: "font-size-adjust",
370
- fontStretch: "font-stretch",
371
- fontStyle: "font-style",
372
- fontVariant: "font-variant",
373
- fontWeight: "font-weight",
374
- glyphOrientationHorizontal: "glyph-orientation-horizontal",
375
- glyphOrientationVertical: "glyph-orientation-vertical",
376
- imageRendering: "image-rendering",
377
- letterSpacing: "letter-spacing",
378
- lightingColor: "lighting-color",
379
- markerEnd: "marker-end",
380
- markerMid: "marker-mid",
381
- markerStart: "marker-start",
382
- pointerEvents: "pointer-events",
383
- popoverTarget: "popovertarget",
384
- popoverTargetAction: "popovertargetaction",
385
- shapeRendering: "shape-rendering",
386
- stopColor: "stop-color",
387
- stopOpacity: "stop-opacity",
388
- strokeDasharray: "stroke-dasharray",
389
- strokeDashoffset: "stroke-dashoffset",
390
- strokeLinecap: "stroke-linecap",
391
- strokeLinejoin: "stroke-linejoin",
392
- strokeMiterlimit: "stroke-miterlimit",
393
- strokeWidth: "stroke-width",
394
- strokeOpacity: "stroke-opacity",
395
- textAnchor: "text-anchor",
396
- textDecoration: "text-decoration",
397
- textRendering: "text-rendering",
398
- unicodeBidi: "unicode-bidi",
399
- wordSpacing: "word-spacing",
400
- writingMode: "writing-mode",
401
- xlinkActuate: "xlink:actuate",
402
- xlinkArcrole: "xlink:arcrole",
403
- xlinkHref: "xlink:href",
404
- xlinkRole: "xlink:role",
405
- xlinkShow: "xlink:show",
406
- xlinkTitle: "xlink:title",
407
- xlinkType: "xlink:type",
408
- xmlBase: "xml:base",
409
- xmlLang: "xml:lang",
410
- xmlSpace: "xml:space",
411
- dirName: "dirname"
412
- };
413
-
414
- // src/component-generator.ts
255
+ import { getJsxPropName } from "@webstudio-is/content-engine/jsx-attributes";
415
256
  var generateAction = ({
416
257
  scope,
417
258
  prop,
@@ -508,6 +349,7 @@ var generateJsxElement = ({
508
349
  tagsOverrides,
509
350
  instance,
510
351
  props,
352
+ resources,
511
353
  dataSources,
512
354
  usedDataSources,
513
355
  indexesWithinAncestors,
@@ -532,23 +374,54 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
532
374
  let conditionValue;
533
375
  let collectionDataValue;
534
376
  let collectionItemValue;
535
- let classNameValue;
377
+ let collectionItemKeyValue;
378
+ const classNameValues = [];
379
+ const projectedResourceProps = /* @__PURE__ */ new Map();
380
+ const componentPropNames = new Set(Object.keys(meta?.props ?? {}));
381
+ const acceptsHtmlAttributes = hasTags || instance.tag !== void 0 || instance.component === elementComponent;
382
+ const getGeneratedPropName = (instancePropName) => getJsxPropName({
383
+ instancePropName,
384
+ componentPropNames,
385
+ acceptsHtmlAttributes
386
+ });
387
+ const propsByGeneratedName = /* @__PURE__ */ new Map();
388
+ const classProps = /* @__PURE__ */ new Map();
536
389
  for (const prop of props.values()) {
537
- if (prop.instanceId !== instance.id) {
390
+ if (prop.instanceId !== instance.id || isAttributeNameSafe(prop.name) === false) {
391
+ continue;
392
+ }
393
+ const name = getGeneratedPropName(prop.name);
394
+ if (name === "className") {
395
+ classProps.set(prop.name, prop);
538
396
  continue;
539
397
  }
398
+ propsByGeneratedName.set(name, prop);
399
+ }
400
+ const generatedPropNames = /* @__PURE__ */ new Set([
401
+ ...propsByGeneratedName.keys(),
402
+ ...classProps.size > 0 ? ["className"] : []
403
+ ]);
404
+ for (const [name, prop] of [
405
+ ...propsByGeneratedName,
406
+ ...Array.from(classProps.values(), (prop2) => ["className", prop2])
407
+ ]) {
540
408
  const propValue = generatePropValue({
541
409
  scope,
542
410
  prop,
543
411
  dataSources,
544
412
  usedDataSources
545
413
  });
546
- if (isAttributeNameSafe(prop.name) === false) {
547
- continue;
548
- }
549
- let name = prop.name;
550
- if (hasTags && !meta?.props?.[prop.name]) {
551
- name = standardAttributesToReactProps[prop.name] ?? prop.name;
414
+ if (prop.type === "resource") {
415
+ const propMeta = meta?.props?.[prop.name];
416
+ const resource = resources?.get(prop.value);
417
+ if (propMeta?.type === "resource" && resource !== void 0) {
418
+ for (const propName of propMeta.generatedProps ?? []) {
419
+ const generatedPropName = getGeneratedPropName(propName);
420
+ if (generatedPropNames.has(generatedPropName) === false && isAttributeNameSafe(propName)) {
421
+ projectedResourceProps.set(generatedPropName, resource[propName]);
422
+ }
423
+ }
424
+ }
552
425
  }
553
426
  if (prop.name === showAttribute) {
554
427
  if (propValue === "true") {
@@ -567,10 +440,13 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
567
440
  if (prop.name === "item") {
568
441
  collectionItemValue = propValue;
569
442
  }
443
+ if (prop.name === "itemKey") {
444
+ collectionItemKeyValue = propValue;
445
+ }
570
446
  continue;
571
447
  }
572
448
  if (name === "className" && propValue !== void 0) {
573
- classNameValue = propValue;
449
+ classNameValues.push(propValue);
574
450
  continue;
575
451
  }
576
452
  if (propValue !== void 0) {
@@ -578,10 +454,14 @@ ${tagProperty}=${JSON.stringify(instance.tag)}`;
578
454
  ${name}={${propValue}}`;
579
455
  }
580
456
  }
457
+ for (const [name, value] of projectedResourceProps) {
458
+ generatedProps += `
459
+ ${name}={${JSON.stringify(value)}}`;
460
+ }
581
461
  const classMapArray = classesMap?.get(instance.id);
582
- if (classMapArray || classNameValue) {
462
+ if (classMapArray || classNameValues.length > 0) {
583
463
  let classNameTemplate = classMapArray ? classMapArray.join(" ") : "";
584
- if (classNameValue) {
464
+ for (const classNameValue of classNameValues) {
585
465
  if (classNameTemplate) {
586
466
  classNameTemplate += " ";
587
467
  }
@@ -598,21 +478,30 @@ ${name}={${propValue}}`;
598
478
  return "";
599
479
  }
600
480
  const indexVariable = scope.getName(`${instance.id}-index`, "index");
601
- generatedElement += `{${collectionDataValue}?.map?.((${collectionItemValue}: any, ${indexVariable}: number) =>
481
+ const keyVariable = collectionItemKeyValue ?? indexVariable;
482
+ generatedElement += `{${generateCollectionIterationCode({
483
+ dataExpression: collectionDataValue,
484
+ keyVariable,
485
+ itemVariable: collectionItemValue
486
+ })} (
602
487
  `;
603
- generatedElement += `<Fragment key={${indexVariable}}>
488
+ generatedElement += `<Fragment key={${keyVariable}}>
604
489
  `;
605
490
  generatedElement += children;
606
491
  generatedElement += `</Fragment>
607
492
  `;
608
- generatedElement += `)}
493
+ generatedElement += `)
494
+ `;
495
+ generatedElement += `})
609
496
  `;
610
- } else if (instance.component === blockComponent) {
497
+ generatedElement += `}
498
+ `;
499
+ } else if (instance.component === blockComponent || instance.component === blockBodyComponent) {
611
500
  generatedElement += children;
612
501
  } else {
613
502
  let componentVariable;
614
503
  if (instance.component === elementComponent) {
615
- componentVariable = instance.tag ?? "div";
504
+ componentVariable = instance.tag === "" ? "div" : instance.tag ?? "div";
616
505
  const componentDescriptor = tagsOverrides?.[componentVariable];
617
506
  if (componentDescriptor !== void 0) {
618
507
  const [_importSource, importSpecifier] = componentDescriptor.split(":");
@@ -663,11 +552,14 @@ var generateJsxChildren = ({
663
552
  children,
664
553
  instances,
665
554
  props,
555
+ resources,
666
556
  dataSources,
667
557
  usedDataSources,
668
558
  indexesWithinAncestors,
669
559
  classesMap,
670
- excludePlaceholders
560
+ excludePlaceholders,
561
+ publishedContentBlocks,
562
+ contentBodyOverride
671
563
  }) => {
672
564
  let generatedChildren = "";
673
565
  for (const child of children) {
@@ -687,7 +579,7 @@ var generateJsxChildren = ({
687
579
  usedDataSources,
688
580
  scope
689
581
  });
690
- generatedChildren = `{${expression}}
582
+ generatedChildren += `{renderText(${expression})}
691
583
  `;
692
584
  continue;
693
585
  }
@@ -697,6 +589,111 @@ var generateJsxChildren = ({
697
589
  if (instance === void 0) {
698
590
  continue;
699
591
  }
592
+ const publishedContent = publishedContentBlocks?.get(instance.id);
593
+ let generatedInstanceChildren;
594
+ if (contentBodyOverride?.instanceId === instance.id) {
595
+ generatedInstanceChildren = generateJsxChildren({
596
+ classesMap,
597
+ scope,
598
+ metas,
599
+ tagsOverrides,
600
+ children: contentBodyOverride.children,
601
+ instances,
602
+ props,
603
+ resources,
604
+ dataSources,
605
+ usedDataSources,
606
+ indexesWithinAncestors,
607
+ excludePlaceholders,
608
+ publishedContentBlocks
609
+ });
610
+ } else if (publishedContent === void 0) {
611
+ generatedInstanceChildren = generateJsxChildren({
612
+ classesMap,
613
+ scope,
614
+ metas,
615
+ tagsOverrides,
616
+ children: instance.children,
617
+ instances,
618
+ props,
619
+ resources,
620
+ dataSources,
621
+ usedDataSources,
622
+ indexesWithinAncestors,
623
+ excludePlaceholders,
624
+ publishedContentBlocks,
625
+ contentBodyOverride
626
+ });
627
+ } else {
628
+ const sourceExpression = publishedContent.sourceExpression === void 0 ? void 0 : generateExpression({
629
+ expression: publishedContent.sourceExpression,
630
+ dataSources,
631
+ usedDataSources,
632
+ scope
633
+ });
634
+ const documentParameter = Array.from(props.values()).find(
635
+ (prop) => prop.instanceId === instance.id && prop.name === contentBlockDocumentProp && prop.type === "parameter"
636
+ );
637
+ const documentDataSource = documentParameter === void 0 ? void 0 : dataSources.get(documentParameter.value);
638
+ if (documentDataSource !== void 0) {
639
+ usedDataSources.set(documentDataSource.id, documentDataSource);
640
+ }
641
+ const documentName = documentDataSource === void 0 ? void 0 : scope.getName(documentDataSource.id, documentDataSource.name);
642
+ const generatedCandidates = publishedContent.candidates.map(
643
+ ({
644
+ assetId,
645
+ dependencyRevision,
646
+ children: candidateChildren,
647
+ frontmatter
648
+ }) => {
649
+ const generated = generateJsxChildren({
650
+ classesMap,
651
+ scope,
652
+ metas,
653
+ tagsOverrides,
654
+ children: publishedContent.bodyInstanceId === void 0 ? candidateChildren : instance.children,
655
+ instances,
656
+ props,
657
+ resources,
658
+ dataSources,
659
+ usedDataSources,
660
+ indexesWithinAncestors,
661
+ excludePlaceholders,
662
+ publishedContentBlocks,
663
+ contentBodyOverride: publishedContent.bodyInstanceId === void 0 ? void 0 : {
664
+ instanceId: publishedContent.bodyInstanceId,
665
+ children: candidateChildren
666
+ }
667
+ });
668
+ const withDocument = documentName === void 0 ? generated : `{((${documentName}) => <Fragment>
669
+ ${generated}</Fragment>)(${JSON.stringify({ frontmatter })})}
670
+ `;
671
+ return {
672
+ assetId,
673
+ dependencyRevision,
674
+ generated: withDocument
675
+ };
676
+ }
677
+ );
678
+ if (sourceExpression === void 0) {
679
+ generatedInstanceChildren = generatedCandidates.map(
680
+ ({ dependencyRevision, generated }) => `<Fragment key=${JSON.stringify(dependencyRevision)}>
681
+ ${generated}</Fragment>
682
+ `
683
+ ).join("");
684
+ } else {
685
+ const sourceName = scope.getName(
686
+ `${instance.id}-published-source`,
687
+ "contentSource"
688
+ );
689
+ const branches = generatedCandidates.map(
690
+ ({ assetId, dependencyRevision, generated }) => `${sourceName} === ${JSON.stringify(assetId)} ? <Fragment key=${JSON.stringify(dependencyRevision)}>
691
+ ${generated}</Fragment>`
692
+ ).join(" : ");
693
+ generatedInstanceChildren = `{((${sourceName}) => ${branches.length === 0 ? "null" : `${branches} : null`})(${sourceExpression})}
694
+ `;
695
+ }
696
+ }
700
697
  generatedChildren += generateJsxElement({
701
698
  context: "jsx",
702
699
  scope,
@@ -704,23 +701,12 @@ var generateJsxChildren = ({
704
701
  tagsOverrides,
705
702
  instance,
706
703
  props,
704
+ resources,
707
705
  dataSources,
708
706
  usedDataSources,
709
707
  indexesWithinAncestors,
710
708
  classesMap,
711
- children: generateJsxChildren({
712
- classesMap,
713
- scope,
714
- metas,
715
- tagsOverrides,
716
- children: instance.children,
717
- instances,
718
- props,
719
- dataSources,
720
- usedDataSources,
721
- indexesWithinAncestors,
722
- excludePlaceholders
723
- })
709
+ children: generatedInstanceChildren
724
710
  });
725
711
  continue;
726
712
  }
@@ -735,10 +721,12 @@ var generateWebstudioComponent = ({
735
721
  parameters,
736
722
  instances,
737
723
  props,
724
+ resources,
738
725
  dataSources,
739
726
  metas,
740
727
  tagsOverrides,
741
- classesMap
728
+ classesMap,
729
+ publishedContentBlocks
742
730
  }) => {
743
731
  const instance = instances.get(rootInstanceId);
744
732
  const indexesWithinAncestors = getIndexesWithinAncestors(metas, instances, [
@@ -754,6 +742,7 @@ var generateWebstudioComponent = ({
754
742
  tagsOverrides,
755
743
  instance,
756
744
  props,
745
+ resources,
757
746
  dataSources,
758
747
  usedDataSources,
759
748
  indexesWithinAncestors,
@@ -765,10 +754,12 @@ var generateWebstudioComponent = ({
765
754
  children: instance.children,
766
755
  instances,
767
756
  props,
757
+ resources,
768
758
  dataSources,
769
759
  usedDataSources,
770
760
  indexesWithinAncestors,
771
- classesMap
761
+ classesMap,
762
+ publishedContentBlocks
772
763
  })
773
764
  });
774
765
  }
@@ -826,15 +817,28 @@ var generateWebstudioComponent = ({
826
817
  `;
827
818
  return generatedComponent;
828
819
  };
820
+
821
+ // src/standard-attributes.ts
822
+ import {
823
+ getInstancePropName,
824
+ getJsxPropName as getJsxPropName2,
825
+ reactPropsToStandardAttributes,
826
+ standardAttributesToReactProps
827
+ } from "@webstudio-is/content-engine/jsx-attributes";
829
828
  export {
830
- collapsedAttribute,
831
829
  componentAttribute,
830
+ findTreeInstanceIdsExcludingStaticHidden,
831
+ generateCollectionIterationCode,
832
832
  generateJsxChildren,
833
833
  generateJsxElement,
834
834
  generateRemixParams,
835
835
  generateRemixRoute,
836
836
  generateWebstudioComponent,
837
+ getCollectionEntries,
838
+ getInstancePropName,
839
+ getJsxPropName2 as getJsxPropName,
837
840
  idAttribute,
841
+ inflatedAttribute,
838
842
  isAttributeNameSafe,
839
843
  normalizeProps,
840
844
  reactPropsToStandardAttributes,