@gem-sdk/core 2.1.13-staging.15 → 2.1.13-staging.18

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.
@@ -294,23 +294,27 @@ const RenderChildren = (props)=>{
294
294
  const WrapRenderChildren = ({ uid, customProps }, codes)=>{
295
295
  let liquid = '';
296
296
  if (codes?.length) {
297
+ let tempLiquid = '';
298
+ let fileIndex = 0;
297
299
  for(let i = 0; i < codes.length; i++){
298
300
  const code = codes[i];
299
301
  if (code) {
300
- const newLiquid = liquid + code;
301
- // Fix limit 256kb
302
302
  const textEncoder = new TextEncoder();
303
- const size = newLiquid ? textEncoder.encode(newLiquid).length : 0;
304
- // Limit each child item of an element (e.g., marquee, ...) to 50KB to ensure the total element size does not exceed 256KB.
305
- if (Math.ceil(size / 1024) >= 50) {
306
- const fileName = `gp-section-snippet-${uid + i}`;
307
- customProps.extraFiles[fileName] = code;
308
- liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant, form: form %}`;
303
+ const newTempLiquid = tempLiquid + code;
304
+ const newSize = textEncoder.encode(newTempLiquid).length;
305
+ if (Math.ceil(newSize / 1024) < 180) {
306
+ tempLiquid = newTempLiquid;
309
307
  } else {
310
- liquid += code;
308
+ const fileName = `gp-section-snippet-${uid}-${fileIndex++}`;
309
+ customProps.extraFiles[fileName] = tempLiquid;
310
+ liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant, form: form %}`;
311
+ tempLiquid = code;
311
312
  }
312
313
  }
313
314
  }
315
+ if (tempLiquid) {
316
+ liquid += tempLiquid;
317
+ }
314
318
  }
315
319
  return liquid;
316
320
  };
@@ -290,23 +290,27 @@ const RenderChildren = (props)=>{
290
290
  const WrapRenderChildren = ({ uid, customProps }, codes)=>{
291
291
  let liquid = '';
292
292
  if (codes?.length) {
293
+ let tempLiquid = '';
294
+ let fileIndex = 0;
293
295
  for(let i = 0; i < codes.length; i++){
294
296
  const code = codes[i];
295
297
  if (code) {
296
- const newLiquid = liquid + code;
297
- // Fix limit 256kb
298
298
  const textEncoder = new TextEncoder();
299
- const size = newLiquid ? textEncoder.encode(newLiquid).length : 0;
300
- // Limit each child item of an element (e.g., marquee, ...) to 50KB to ensure the total element size does not exceed 256KB.
301
- if (Math.ceil(size / 1024) >= 50) {
302
- const fileName = `gp-section-snippet-${uid + i}`;
303
- customProps.extraFiles[fileName] = code;
304
- liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant, form: form %}`;
299
+ const newTempLiquid = tempLiquid + code;
300
+ const newSize = textEncoder.encode(newTempLiquid).length;
301
+ if (Math.ceil(newSize / 1024) < 180) {
302
+ tempLiquid = newTempLiquid;
305
303
  } else {
306
- liquid += code;
304
+ const fileName = `gp-section-snippet-${uid}-${fileIndex++}`;
305
+ customProps.extraFiles[fileName] = tempLiquid;
306
+ liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant, form: form %}`;
307
+ tempLiquid = code;
307
308
  }
308
309
  }
309
310
  }
311
+ if (tempLiquid) {
312
+ liquid += tempLiquid;
313
+ }
310
314
  }
311
315
  return liquid;
312
316
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "2.1.13-staging.15",
3
+ "version": "2.1.13-staging.18",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",