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