@swell/apps-sdk 1.0.177 → 1.0.179

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.cjs CHANGED
@@ -3390,13 +3390,20 @@ function getSectionSettingsFromProps(props, sectionSchema) {
3390
3390
  blocks: props.Blocks?.filter(
3391
3391
  (propBlock) => Boolean(propBlock.props.compiled?._component)
3392
3392
  ).map((propBlock) => {
3393
- const blockProps = propBlock.props.compiled.props;
3394
- const blockType = propBlock.props.compiled._component.split("__")[2];
3393
+ const {
3394
+ _id: id,
3395
+ _component: component,
3396
+ disabled: isDisabled,
3397
+ props: blockProps
3398
+ } = propBlock.props.compiled;
3399
+ const blockType = component.split("__")[2];
3395
3400
  const blockSchema = sectionSchema.blocks?.find(
3396
3401
  (block) => block.type === blockType
3397
3402
  );
3398
3403
  return {
3404
+ id,
3399
3405
  type: blockType,
3406
+ disabled: isDisabled,
3400
3407
  settings: blockSchema?.fields?.reduce(
3401
3408
  (acc, field) => {
3402
3409
  if (field?.id) {
@@ -13153,7 +13160,7 @@ function ShopifyCustomer(instance, account) {
13153
13160
  accepts_marketing: defer(() => account.email_optin),
13154
13161
  addresses: deferWith(
13155
13162
  account.addresses,
13156
- (addresses) => addresses.results.map(
13163
+ (addresses) => (addresses?.results || []).map(
13157
13164
  (address) => ShopifyAddress(instance, address)
13158
13165
  )
13159
13166
  ),
@@ -13189,7 +13196,9 @@ function ShopifyCustomer(instance, account) {
13189
13196
  name: defer(() => account.name),
13190
13197
  orders: deferWith(
13191
13198
  account.orders,
13192
- (orders) => orders.results.map((order) => ShopifyOrder(instance, order))
13199
+ (orders) => (orders?.results || []).map(
13200
+ (order) => ShopifyOrder(instance, order)
13201
+ )
13193
13202
  ),
13194
13203
  orders_count: defer(() => account.order_count),
13195
13204
  payment_methods: [],
@@ -14913,7 +14922,7 @@ function bind2(liquidSwell) {
14913
14922
  const value = yield (0, import_liquidjs16.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
14914
14923
  if (target === value) {
14915
14924
  const blockOutput = yield r.renderTemplates(branch.templates, ctx);
14916
- output += this.isBlock && liquidSwell.isEditor ? `<span class="swell-block">${blockOutput}</span>` : blockOutput;
14925
+ output += blockOutput;
14917
14926
  branchHit = true;
14918
14927
  break;
14919
14928
  }
@@ -18938,6 +18947,7 @@ function resolveSectionSettings(theme, sectionConfig, index) {
18938
18947
  );
18939
18948
  blocks = blocks?.map((block) => ({
18940
18949
  ...block,
18950
+ ...getBlockAttributes(theme, block),
18941
18951
  settings: resolveThemeSettings(
18942
18952
  theme,
18943
18953
  block.settings,
@@ -19079,6 +19089,17 @@ function findEditorSetting(editorSchemaSettings, key) {
19079
19089
  }
19080
19090
  return null;
19081
19091
  }
19092
+ function getBlockAttributes(theme, block) {
19093
+ if (!theme.swell.isEditor) {
19094
+ return;
19095
+ }
19096
+ const { id } = block;
19097
+ const attributes = `data-editor-block="${JSON.stringify({ id }).replaceAll('"', "&quot;")}"`;
19098
+ return {
19099
+ swell_attributes: attributes,
19100
+ shopify_attributes: attributes
19101
+ };
19102
+ }
19082
19103
  function parseJsonConfig(config) {
19083
19104
  try {
19084
19105
  return import_json56.default.parse(config?.file_data || "{}");