@next-core/runtime 1.52.1 → 1.54.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.
Files changed (35) hide show
  1. package/dist/cjs/internal/CustomTemplates/constants.js +1 -2
  2. package/dist/cjs/internal/CustomTemplates/constants.js.map +1 -1
  3. package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js +1 -2
  4. package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
  5. package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js +10 -18
  6. package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
  7. package/dist/cjs/internal/FormRenderer/expandFormRenderer.js +2 -1
  8. package/dist/cjs/internal/FormRenderer/expandFormRenderer.js.map +1 -1
  9. package/dist/cjs/internal/FormRenderer/registerFormRenderer.js +47 -0
  10. package/dist/cjs/internal/FormRenderer/registerFormRenderer.js.map +1 -0
  11. package/dist/cjs/internal/Renderer.js +2 -9
  12. package/dist/cjs/internal/Renderer.js.map +1 -1
  13. package/dist/cjs/internal/Runtime.js +8 -7
  14. package/dist/cjs/internal/Runtime.js.map +1 -1
  15. package/dist/cjs/internal/interfaces.js.map +1 -1
  16. package/dist/esm/internal/CustomTemplates/constants.js +0 -1
  17. package/dist/esm/internal/CustomTemplates/constants.js.map +1 -1
  18. package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js +1 -2
  19. package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
  20. package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js +11 -19
  21. package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
  22. package/dist/esm/internal/FormRenderer/expandFormRenderer.js +1 -1
  23. package/dist/esm/internal/FormRenderer/expandFormRenderer.js.map +1 -1
  24. package/dist/esm/internal/FormRenderer/registerFormRenderer.js +47 -0
  25. package/dist/esm/internal/FormRenderer/registerFormRenderer.js.map +1 -0
  26. package/dist/esm/internal/Renderer.js +3 -10
  27. package/dist/esm/internal/Renderer.js.map +1 -1
  28. package/dist/esm/internal/Runtime.js +8 -7
  29. package/dist/esm/internal/Runtime.js.map +1 -1
  30. package/dist/esm/internal/interfaces.js.map +1 -1
  31. package/dist/types/internal/CustomTemplates/constants.d.ts +0 -2
  32. package/dist/types/internal/FormRenderer/expandFormRenderer.d.ts +1 -0
  33. package/dist/types/internal/FormRenderer/registerFormRenderer.d.ts +1 -0
  34. package/dist/types/internal/interfaces.d.ts +0 -1
  35. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  import { hasOwnProperty } from "@next-core/utils/general";
2
2
  import { clamp } from "lodash";
3
- import { symbolForAsyncComputedPropsFromHost, symbolForTPlExternalForEachIndex, symbolForTPlExternalForEachItem, symbolForTPlExternalForEachSize, symbolForTPlExternalNoForEach, symbolForTplStateStoreId } from "./constants.js";
3
+ import { symbolForAsyncComputedPropsFromHost, symbolForTPlExternalForEachIndex, symbolForTPlExternalForEachItem, symbolForTPlExternalForEachSize, symbolForTplStateStoreId } from "./constants.js";
4
4
  import { computePropertyValue } from "../compute/computeRealProperties.js";
5
5
  import { childrenToSlots } from "../Renderer.js";
6
6
  export function setupTemplateProxy(hostContext, ref, slots) {
@@ -59,7 +59,7 @@ export function setupTemplateProxy(hostContext, ref, slots) {
59
59
  // External bricks of a template, should not access the template internal forEach `ITEM`.
60
60
  // For some existing templates who is *USING* this bug, we keep the old behavior.
61
61
  const hostHasForEach = hasOwnProperty(hostBrick.runtimeContext, "forEachItem");
62
- expandableSlot[clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((hostContext.__temporary_tpl_tag_name === "base-layout-v3.tpl-scroll-load-list" || hostContext.__temporary_tpl_tag_name === "shrcb-homepage.tpl-custom-scroll-load-list") && !hostHasForEach ? insertBricks : setupTemplateExternalBricks(insertBricks, hostHasForEach, hostBrick.runtimeContext.forEachItem, hostBrick.runtimeContext.forEachIndex, hostBrick.runtimeContext.forEachSize)));
62
+ expandableSlot[clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...(!hostHasForEach ? insertBricks : setupTemplateExternalBricksWithForEach(insertBricks, hostBrick.runtimeContext.forEachItem, hostBrick.runtimeContext.forEachIndex, hostBrick.runtimeContext.forEachSize)));
63
63
  }
64
64
  for (const [slotName, quasis] of quasisMap.entries()) {
65
65
  if (!hasOwnProperty(slots, slotName)) {
@@ -83,47 +83,39 @@ export function setupTemplateProxy(hostContext, ref, slots) {
83
83
  }
84
84
 
85
85
  // External bricks of a template, have the same forEachItem context as their host.
86
- function setupTemplateExternalBricks(bricks, hasForEach, forEachItem, forEachIndex, forEachSize) {
86
+ function setupTemplateExternalBricksWithForEach(bricks, forEachItem, forEachIndex, forEachSize) {
87
87
  return bricks.map(_ref2 => {
88
88
  let {
89
89
  children,
90
90
  slots,
91
- [symbolForTPlExternalForEachItem]: a,
92
- [symbolForTPlExternalForEachIndex]: b,
93
- [symbolForTPlExternalForEachSize]: c,
94
- [symbolForTPlExternalNoForEach]: d,
95
91
  ...brick
96
92
  } = _ref2;
97
93
  return {
98
94
  ...brick,
99
- ...(hasForEach ? {
100
- [symbolForTPlExternalForEachItem]: forEachItem,
101
- [symbolForTPlExternalForEachIndex]: forEachIndex,
102
- [symbolForTPlExternalForEachSize]: forEachSize
103
- } : {
104
- [symbolForTPlExternalNoForEach]: true
105
- }),
95
+ [symbolForTPlExternalForEachItem]: forEachItem,
96
+ [symbolForTPlExternalForEachIndex]: forEachIndex,
97
+ [symbolForTPlExternalForEachSize]: forEachSize,
106
98
  // Keep `:forEach` bricks as original, since they have their own forEachItem context.
107
99
  slots: brick.brick === ":forEach" ? childrenToSlots(children, slots) : Object.fromEntries(Object.entries(childrenToSlots(children, slots) ?? {}).map(_ref3 => {
108
100
  let [slotName, slotConf] = _ref3;
109
101
  return [slotName, slotConf.type === "routes" ? {
110
102
  type: "routes",
111
- routes: setupTemplateExternalRoutes(slotConf.routes, hasForEach, forEachItem, forEachIndex, forEachSize)
103
+ routes: setupTemplateExternalRoutesWithForEach(slotConf.routes, forEachItem, forEachIndex, forEachSize)
112
104
  } : {
113
105
  type: "bricks",
114
- bricks: setupTemplateExternalBricks(slotConf.bricks, hasForEach, forEachItem, forEachIndex, forEachSize)
106
+ bricks: setupTemplateExternalBricksWithForEach(slotConf.bricks, forEachItem, forEachIndex, forEachSize)
115
107
  }];
116
108
  }))
117
109
  };
118
110
  });
119
111
  }
120
- function setupTemplateExternalRoutes(routes, hasForEach, forEachItem, forEachIndex, forEachSize) {
112
+ function setupTemplateExternalRoutesWithForEach(routes, forEachItem, forEachIndex, forEachSize) {
121
113
  return routes.map(route => route.type === "routes" ? {
122
114
  ...route,
123
- routes: setupTemplateExternalRoutes(route.routes, hasForEach, forEachItem, forEachIndex, forEachSize)
115
+ routes: setupTemplateExternalRoutesWithForEach(route.routes, forEachItem, forEachIndex, forEachSize)
124
116
  } : route.type === "redirect" ? route : {
125
117
  ...route,
126
- bricks: setupTemplateExternalBricks(route.bricks, hasForEach, forEachItem, forEachIndex, forEachSize)
118
+ bricks: setupTemplateExternalBricksWithForEach(route.bricks, forEachItem, forEachIndex, forEachSize)
127
119
  });
128
120
  }
129
121
  //# sourceMappingURL=setupTemplateProxy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setupTemplateProxy.js","names":["hasOwnProperty","clamp","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachSize","symbolForTPlExternalNoForEach","symbolForTplStateStoreId","computePropertyValue","childrenToSlots","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostPropertyEntries","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","asyncHostProps","map","_ref","from","to","filtered","filter","entry","length","refProperty","Boolean","slotProxies","quasisMap","Map","_externalSlots$from","insertBricks","bricks","refToSlot","refSlot","expandableSlot","size","i","push","set","refPosition","hostHasForEach","runtimeContext","__temporary_tpl_tag_name","setupTemplateExternalBricks","forEachItem","forEachIndex","forEachSize","slotName","quasis","entries","type","slotConf","flatMap","index","concat","hasForEach","_ref2","children","a","b","c","d","brick","Object","fromEntries","_ref3","routes","setupTemplateExternalRoutes","route"],"sources":["../../../../src/internal/CustomTemplates/setupTemplateProxy.ts"],"sourcesContent":["import type { BrickConf, RouteConf, SlotsConfOfBricks } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { clamp } from \"lodash\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachIndex,\n symbolForTPlExternalForEachItem,\n symbolForTPlExternalForEachSize,\n symbolForTPlExternalNoForEach,\n symbolForTplStateStoreId,\n type RuntimeBrickConfWithTplSymbols,\n} from \"./constants.js\";\nimport type { AsyncPropertyEntry, TemplateHostContext } from \"../interfaces.js\";\nimport { computePropertyValue } from \"../compute/computeRealProperties.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function setupTemplateProxy(\n hostContext: TemplateHostContext,\n ref: string | undefined,\n slots: SlotsConfOfBricks\n) {\n const {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots,\n tplStateStoreId,\n hostBrick,\n } = hostContext;\n\n let asyncComputedProps: AsyncPropertyEntry[] | undefined;\n\n if (ref && reversedProxies) {\n const propertyProxies = reversedProxies.properties.get(ref);\n if (propertyProxies) {\n const getComputedProps = (\n asyncHostProps: AsyncPropertyEntry[]\n ): AsyncPropertyEntry[] => {\n return propertyProxies!\n .map(({ from, to }) => {\n const filtered = asyncHostProps.filter(\n (entry) => entry[0] === from\n );\n if (filtered.length > 0 && to.refProperty) {\n return [\n to.refProperty,\n computePropertyValue(filtered, from),\n true,\n ];\n }\n })\n .filter(Boolean) as [string, Promise<unknown>][];\n };\n\n asyncComputedProps = getComputedProps(asyncHostPropertyEntries);\n }\n\n const slotProxies = reversedProxies.slots.get(ref);\n if (slotProxies && externalSlots) {\n // Use an approach like template-literal's quasis:\n // `quasi0${0}quais1${1}quasi2...`\n // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.\n const quasisMap = new Map<string, BrickConf[][]>();\n\n for (const { from, to } of slotProxies) {\n const insertBricks = externalSlots[from]?.bricks ?? [];\n if (!insertBricks.length) {\n continue;\n }\n const refToSlot = to.refSlot ?? from;\n let expandableSlot = quasisMap.get(refToSlot);\n if (!expandableSlot) {\n expandableSlot = [];\n // The size of quasis should be the existed slotted bricks' size plus one.\n const size = hasOwnProperty(slots, refToSlot)\n ? slots[refToSlot].bricks.length + 1\n : 1;\n for (let i = 0; i < size; i += 1) {\n expandableSlot.push([]);\n }\n quasisMap.set(refToSlot, expandableSlot);\n }\n const refPosition = to.refPosition ?? -1;\n // External bricks of a template, should not access the template internal forEach `ITEM`.\n // For some existing templates who is *USING* this bug, we keep the old behavior.\n const hostHasForEach = hasOwnProperty(\n hostBrick.runtimeContext,\n \"forEachItem\"\n );\n expandableSlot[\n clamp(\n refPosition < 0 ? expandableSlot.length + refPosition : refPosition,\n 0,\n expandableSlot.length - 1\n )\n ].push(\n ...((hostContext.__temporary_tpl_tag_name ===\n \"base-layout-v3.tpl-scroll-load-list\" ||\n hostContext.__temporary_tpl_tag_name ===\n \"shrcb-homepage.tpl-custom-scroll-load-list\") &&\n !hostHasForEach\n ? insertBricks\n : setupTemplateExternalBricks(\n insertBricks,\n hostHasForEach,\n hostBrick.runtimeContext.forEachItem,\n hostBrick.runtimeContext.forEachIndex!,\n hostBrick.runtimeContext.forEachSize!\n ))\n );\n }\n\n for (const [slotName, quasis] of quasisMap.entries()) {\n if (!hasOwnProperty(slots, slotName)) {\n slots[slotName] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n const slotConf = slots[slotName];\n slotConf.bricks = quasis.flatMap((bricks, index) =>\n index < slotConf.bricks.length\n ? bricks.concat(slotConf.bricks[index])\n : bricks\n );\n\n if (slotConf.bricks.length === 0) {\n delete slots[slotName];\n }\n }\n }\n }\n\n return {\n [symbolForAsyncComputedPropsFromHost]: asyncComputedProps,\n [symbolForTplStateStoreId]: tplStateStoreId,\n };\n}\n\n// External bricks of a template, have the same forEachItem context as their host.\nfunction setupTemplateExternalBricks(\n bricks: BrickConf[],\n hasForEach: boolean,\n forEachItem: unknown,\n forEachIndex: number,\n forEachSize: number\n): BrickConf[] {\n return (bricks as RuntimeBrickConfWithTplSymbols[]).map(\n ({\n children,\n slots,\n [symbolForTPlExternalForEachItem]: a,\n [symbolForTPlExternalForEachIndex]: b,\n [symbolForTPlExternalForEachSize]: c,\n [symbolForTPlExternalNoForEach]: d,\n ...brick\n }) => ({\n ...brick,\n ...(hasForEach\n ? {\n [symbolForTPlExternalForEachItem]: forEachItem,\n [symbolForTPlExternalForEachIndex]: forEachIndex,\n [symbolForTPlExternalForEachSize]: forEachSize,\n }\n : {\n [symbolForTPlExternalNoForEach]: true,\n }),\n // Keep `:forEach` bricks as original, since they have their own forEachItem context.\n slots:\n brick.brick === \":forEach\"\n ? childrenToSlots(children, slots)\n : Object.fromEntries(\n Object.entries(childrenToSlots(children, slots) ?? {}).map(\n ([slotName, slotConf]) => [\n slotName,\n slotConf.type === \"routes\"\n ? {\n type: \"routes\",\n routes: setupTemplateExternalRoutes(\n slotConf.routes,\n hasForEach,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n : {\n type: \"bricks\",\n bricks: setupTemplateExternalBricks(\n slotConf.bricks,\n hasForEach,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n },\n ]\n )\n ),\n })\n );\n}\n\nfunction setupTemplateExternalRoutes(\n routes: RouteConf[],\n hasForEach: boolean,\n forEachItem: unknown,\n forEachIndex: number,\n forEachSize: number\n): RouteConf[] {\n return routes.map((route) =>\n route.type === \"routes\"\n ? {\n ...route,\n routes: setupTemplateExternalRoutes(\n route.routes,\n hasForEach,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n : route.type === \"redirect\"\n ? route\n : {\n ...route,\n bricks: setupTemplateExternal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A,CACH,CACF;IACR,CAAC;EAAA,CACH,CAAC;AACH;AAEA,SAASqB,2BAA2BA,CAClCD,MAAmB,EACnBX,UAAmB,EACnBX,WAAoB,EACpBC,YAAoB,EACpBC,WAAmB,EACN;EACb,OAAOoB,MAAM,CAAClD,GAAG,CAAEoD,KAAK,IACtBA,KAAK,CAAClB,IAAI,KAAK,QAAQ,GACnB;IACE,GAAGkB,KAAK;IACRF,MAAM,EAAEC,2BAA2B,CACjCC,KAAK,CAACF,MAAM,EACZX,UAAU,EACVX,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CAAC,GACDsB,KAAK,CAAClB,IAAI,KAAK,UAAU,GACvBkB,KAAK,GACL;IACE,GAAGA,KAAK;IACRrC,MAAM,EAAEY,2BAA2B,CACjCyB,KAAK,CAACrC,MAAM,EACZwB,UAAU,EACVX,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CACR,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"setupTemplateProxy.js","names":["hasOwnProperty","clamp","symbolForAsyncComputedPropsFromHost","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachSize","symbolForTplStateStoreId","computePropertyValue","childrenToSlots","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostPropertyEntries","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","asyncHostProps","map","_ref","from","to","filtered","filter","entry","length","refProperty","Boolean","slotProxies","quasisMap","Map","_externalSlots$from","insertBricks","bricks","refToSlot","refSlot","expandableSlot","size","i","push","set","refPosition","hostHasForEach","runtimeContext","setupTemplateExternalBricksWithForEach","forEachItem","forEachIndex","forEachSize","slotName","quasis","entries","type","slotConf","flatMap","index","concat","_ref2","children","brick","Object","fromEntries","_ref3","routes","setupTemplateExternalRoutesWithForEach","route"],"sources":["../../../../src/internal/CustomTemplates/setupTemplateProxy.ts"],"sourcesContent":["import type { BrickConf, RouteConf, SlotsConfOfBricks } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { clamp } from \"lodash\";\nimport {\n symbolForAsyncComputedPropsFromHost,\n symbolForTPlExternalForEachIndex,\n symbolForTPlExternalForEachItem,\n symbolForTPlExternalForEachSize,\n symbolForTplStateStoreId,\n type RuntimeBrickConfWithTplSymbols,\n} from \"./constants.js\";\nimport type { AsyncPropertyEntry, TemplateHostContext } from \"../interfaces.js\";\nimport { computePropertyValue } from \"../compute/computeRealProperties.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function setupTemplateProxy(\n hostContext: TemplateHostContext,\n ref: string | undefined,\n slots: SlotsConfOfBricks\n) {\n const {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots,\n tplStateStoreId,\n hostBrick,\n } = hostContext;\n\n let asyncComputedProps: AsyncPropertyEntry[] | undefined;\n\n if (ref && reversedProxies) {\n const propertyProxies = reversedProxies.properties.get(ref);\n if (propertyProxies) {\n const getComputedProps = (\n asyncHostProps: AsyncPropertyEntry[]\n ): AsyncPropertyEntry[] => {\n return propertyProxies!\n .map(({ from, to }) => {\n const filtered = asyncHostProps.filter(\n (entry) => entry[0] === from\n );\n if (filtered.length > 0 && to.refProperty) {\n return [\n to.refProperty,\n computePropertyValue(filtered, from),\n true,\n ];\n }\n })\n .filter(Boolean) as [string, Promise<unknown>][];\n };\n\n asyncComputedProps = getComputedProps(asyncHostPropertyEntries);\n }\n\n const slotProxies = reversedProxies.slots.get(ref);\n if (slotProxies && externalSlots) {\n // Use an approach like template-literal's quasis:\n // `quasi0${0}quais1${1}quasi2...`\n // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.\n const quasisMap = new Map<string, BrickConf[][]>();\n\n for (const { from, to } of slotProxies) {\n const insertBricks = externalSlots[from]?.bricks ?? [];\n if (!insertBricks.length) {\n continue;\n }\n const refToSlot = to.refSlot ?? from;\n let expandableSlot = quasisMap.get(refToSlot);\n if (!expandableSlot) {\n expandableSlot = [];\n // The size of quasis should be the existed slotted bricks' size plus one.\n const size = hasOwnProperty(slots, refToSlot)\n ? slots[refToSlot].bricks.length + 1\n : 1;\n for (let i = 0; i < size; i += 1) {\n expandableSlot.push([]);\n }\n quasisMap.set(refToSlot, expandableSlot);\n }\n const refPosition = to.refPosition ?? -1;\n // External bricks of a template, should not access the template internal forEach `ITEM`.\n // For some existing templates who is *USING* this bug, we keep the old behavior.\n const hostHasForEach = hasOwnProperty(\n hostBrick.runtimeContext,\n \"forEachItem\"\n );\n expandableSlot[\n clamp(\n refPosition < 0 ? expandableSlot.length + refPosition : refPosition,\n 0,\n expandableSlot.length - 1\n )\n ].push(\n ...(!hostHasForEach\n ? insertBricks\n : setupTemplateExternalBricksWithForEach(\n insertBricks,\n hostBrick.runtimeContext.forEachItem,\n hostBrick.runtimeContext.forEachIndex!,\n hostBrick.runtimeContext.forEachSize!\n ))\n );\n }\n\n for (const [slotName, quasis] of quasisMap.entries()) {\n if (!hasOwnProperty(slots, slotName)) {\n slots[slotName] = {\n type: \"bricks\",\n bricks: [],\n };\n }\n const slotConf = slots[slotName];\n slotConf.bricks = quasis.flatMap((bricks, index) =>\n index < slotConf.bricks.length\n ? bricks.concat(slotConf.bricks[index])\n : bricks\n );\n\n if (slotConf.bricks.length === 0) {\n delete slots[slotName];\n }\n }\n }\n }\n\n return {\n [symbolForAsyncComputedPropsFromHost]: asyncComputedProps,\n [symbolForTplStateStoreId]: tplStateStoreId,\n };\n}\n\n// External bricks of a template, have the same forEachItem context as their host.\nfunction setupTemplateExternalBricksWithForEach(\n bricks: BrickConf[],\n forEachItem: unknown,\n forEachIndex: number,\n forEachSize: number\n): BrickConf[] {\n return (bricks as RuntimeBrickConfWithTplSymbols[]).map(\n ({ children, slots, ...brick }) => ({\n ...brick,\n [symbolForTPlExternalForEachItem]: forEachItem,\n [symbolForTPlExternalForEachIndex]: forEachIndex,\n [symbolForTPlExternalForEachSize]: forEachSize,\n // Keep `:forEach` bricks as original, since they have their own forEachItem context.\n slots:\n brick.brick === \":forEach\"\n ? childrenToSlots(children, slots)\n : Object.fromEntries(\n Object.entries(childrenToSlots(children, slots) ?? {}).map(\n ([slotName, slotConf]) => [\n slotName,\n slotConf.type === \"routes\"\n ? {\n type: \"routes\",\n routes: setupTemplateExternalRoutesWithForEach(\n slotConf.routes,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n : {\n type: \"bricks\",\n bricks: setupTemplateExternalBricksWithForEach(\n slotConf.bricks,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n },\n ]\n )\n ),\n })\n );\n}\n\nfunction setupTemplateExternalRoutesWithForEach(\n routes: RouteConf[],\n forEachItem: unknown,\n forEachIndex: number,\n forEachSize: number\n): RouteConf[] {\n return routes.map((route) =>\n route.type === \"routes\"\n ? {\n ...route,\n routes: setupTemplateExternalRoutesWithForEach(\n route.routes,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n : route.type === \"redirect\"\n ? route\n : {\n ...route,\n bricks: setupTemplateExternalBricksWithForEach(\n route.bricks,\n forEachItem,\n forEachIndex,\n forEachSize\n ),\n }\n );\n}\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,QAAQ,QAAQ;AAC9B,SACEC,mCAAmC,EACnCC,gCAAgC,EAChCC,+BAA+B,EAC/BC,+BAA+B,EAC/BC,wBAAwB,QAEnB,gBAAgB;AAEvB,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,SAASC,eAAe,QAAQ,gBAAgB;AAEhD,OAAO,SAASC,kBAAkBA,CAChCC,WAAgC,EAChCC,GAAuB,EACvBC,KAAwB,EACxB;EACA,MAAM;IACJC,eAAe;IACfC,wBAAwB;IACxBC,aAAa;IACbC,eAAe;IACfC;EACF,CAAC,GAAGP,WAAW;EAEf,IAAIQ,kBAAoD;EAExD,IAAIP,GAAG,IAAIE,eAAe,EAAE;IAC1B,MAAMM,eAAe,GAAGN,eAAe,CAACO,UAAU,CAACC,GAAG,CAACV,GAAG,CAAC;IAC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AAsC,CAC5CX,QAAQ,CAACU,MAAM,EACfjB,WAAW,EACXC,YAAY,EACZC,WACF;QACF,CAAC,GACD;UACEI,IAAI,EAAE,QAAQ;UACdlB,MAAM,EAAEW,sCAAsC,CAC5CQ,QAAQ,CAACnB,MAAM,EACfY,WAAW,EACXC,YAAY,EACZC,WACF;QACF,CAAC,CACN;MAAA,CACH,CACF;IACR,CAAC;EAAA,CACH,CAAC;AACH;AAEA,SAASgB,sCAAsCA,CAC7CD,MAAmB,EACnBjB,WAAoB,EACpBC,YAAoB,EACpBC,WAAmB,EACN;EACb,OAAOe,MAAM,CAAC5C,GAAG,CAAE8C,KAAK,IACtBA,KAAK,CAACb,IAAI,KAAK,QAAQ,GACnB;IACE,GAAGa,KAAK;IACRF,MAAM,EAAEC,sCAAsC,CAC5CC,KAAK,CAACF,MAAM,EACZjB,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CAAC,GACDiB,KAAK,CAACb,IAAI,KAAK,UAAU,GACvBa,KAAK,GACL;IACE,GAAGA,KAAK;IACR/B,MAAM,EAAEW,sCAAsC,CAC5CoB,KAAK,CAAC/B,MAAM,EACZY,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CACR,CAAC;AACH","ignoreList":[]}
@@ -3,7 +3,7 @@ import { uniqueId } from "lodash";
3
3
  import { DataStore } from "../data/DataStore.js";
4
4
  import { getDefaultProperties } from "./getDefaultProperties.js";
5
5
  import { symbolForFormStateStoreId } from "./constants.js";
6
- const formContainers = ["forms.general-form", "form.general-form", "eo-form"];
6
+ export const formContainers = ["forms.general-form", "form.general-form", "eo-form"];
7
7
  export function expandFormRenderer(formData, hostBrickConf, hostBrick, asyncHostPropertyEntries, rendererContext) {
8
8
  var _hostBrickConf$proper;
9
9
  const normalizedFormData = typeof formData === "string" ? JSON.parse(formData) : formData;
@@ -1 +1 @@
1
- {"version":3,"file":"expandFormRenderer.js","names":["hasOwnProperty","uniqueId","DataStore","getDefaultProperties","symbolForFormStateStoreId","formContainers","expandFormRenderer","formData","hostBrickConf","hostBrick","asyncHostPropertyEntries","rendererContext","_hostBrickConf$proper","normalizedFormData","JSON","parse","formStateStoreId","runtimeContext","forEachItem","forEachIndex","forEachSize","tplStateStoreId","formStateStore","undefined","formStateStoreMap","set","formStateStoreScope","push","context","some","ctx","name","define","formConf","formSchemaToBrick","formSchema","fields","includes","brick","events","mergeEvents","renderRoot","properties","slots","children","style","padding","schema","id","bricks","mountPoint","instanceId","iid","field","find","item","fieldId","defaults","brickConf","slot","formSchemasToBricks","if","schemas","Array","isArray","map","targetEvents","sourceEvents","eventType","handlers","Object","entries","flat"],"sources":["../../../../src/internal/FormRenderer/expandFormRenderer.ts"],"sourcesContent":["import type { BrickConf, BrickEventsMap } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { uniqueId } from \"lodash\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport type { AsyncPropertyEntry, RuntimeBrick } from \"../interfaces.js\";\nimport type {\n FieldProperties,\n FormDataProperties,\n FormSchemaProperties,\n} from \"./interfaces.js\";\nimport { getDefaultProperties } from \"./getDefaultProperties.js\";\nimport { symbolForFormStateStoreId } from \"./constants.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\n\nconst formContainers = [\"forms.general-form\", \"form.general-form\", \"eo-form\"];\n\nexport function expandFormRenderer(\n formData: unknown,\n hostBrickConf: BrickConf,\n hostBrick: RuntimeBrick,\n asyncHostPropertyEntries: AsyncPropertyEntry[],\n rendererContext: RendererContext\n): BrickConf {\n const normalizedFormData = (\n typeof formData === \"string\" ? JSON.parse(formData) : formData\n ) as FormDataProperties;\n\n const formStateStoreId = uniqueId(\"form-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n formStateStoreId,\n };\n\n // There is a boundary for `forEach*` and `STATE` between form internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n delete runtimeContext.tplStateStoreId;\n\n const formStateStore = new DataStore(\n \"FORM_STATE\",\n undefined,\n rendererContext,\n formStateStoreId\n );\n runtimeContext.formStateStoreMap.set(formStateStoreId, formStateStore);\n if (runtimeContext.formStateStoreScope) {\n runtimeContext.formStateStoreScope.push(formStateStore);\n }\n\n // Always add a state of `params`.\n const context = normalizedFormData.context ?? [];\n if (!context.some((ctx) => ctx.name === \"params\")) {\n context.push({ name: \"params\" });\n }\n\n formStateStore.define(context, runtimeContext, asyncHostPropertyEntries);\n\n const formConf = formSchemaToBrick(\n normalizedFormData.formSchema,\n normalizedFormData.fields,\n formStateStoreId\n );\n\n if (formContainers.includes(formConf.brick) && hostBrickConf.events) {\n formConf.events = mergeEvents(formConf.events, hostBrickConf.events);\n }\n\n const renderRoot =\n typeof hostBrickConf.properties?.renderRoot !== \"boolean\" ||\n hostBrickConf.properties.renderRoot;\n\n if (renderRoot) {\n return {\n ...hostBrickConf,\n slots: undefined,\n children: [\n {\n brick: \"eo-micro-view\",\n properties: { style: { padding: \"12px\" } },\n children: [formConf],\n },\n ],\n };\n }\n\n return {\n ...hostBrickConf,\n slots: undefined,\n children: [formConf],\n };\n}\n\nfunction formSchemaToBrick(\n schema: FormSchemaProperties,\n fields: FieldProperties[],\n formStateStoreId: string\n): BrickConf {\n const { id, bricks, events, context, mountPoint, instanceId: iid } = schema;\n let { brick, properties } = schema;\n\n // 根据字段类型获取默认配置\n const field = fields.find((item: FieldProperties) => item.fieldId === id);\n if (field) {\n const defaults = getDefaultProperties(field);\n if (!brick) {\n brick = defaults.brick;\n }\n properties = {\n ...defaults.properties,\n ...properties,\n };\n }\n\n const brickConf = {\n brick,\n properties,\n iid,\n slot: mountPoint,\n events,\n context,\n children: formSchemasToBricks(bricks, fields, formStateStoreId),\n [symbolForFormStateStoreId]: formStateStoreId,\n } as BrickConf;\n\n if (hasOwnProperty(schema, \"if\")) {\n brickConf.if = schema.if;\n }\n\n return brickConf;\n}\n\nfunction formSchemasToBricks(\n schemas: FormSchemaProperties[] | undefined,\n fields: FieldProperties[],\n formStateStoreId: string\n): BrickConf[] | undefined {\n if (Array.isArray(schemas)) {\n return schemas.map((schema) =>\n formSchemaToBrick(schema, fields, formStateStoreId)\n );\n }\n}\n\nfunction mergeEvents(\n targetEvents: BrickEventsMap | undefined,\n sourceEvents: BrickEventsMap\n): BrickEventsMap {\n const events = targetEvents ?? {};\n\n for (const [eventType, handlers] of Object.entries(sourceEvents)) {\n events[eventType] = hasOwnProperty(events, eventType)\n ? [events[eventType], handlers].flat()\n : handlers;\n }\n\n return events;\n}\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,SAAS,QAAQ,sBAAsB;AAOhD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,yBAAyB,QAAQ,gBAAgB;AAG1D,MAAMC,cAAc,GAAG,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,SAAS,CAAC;AAE7E,OAAO,SAASC,kBAAkBA,CAChCC,QAAiB,EACjBC,aAAwB,EACxBC,SAAuB,EACvBC,wBAA8C,EAC9CC,eAAgC,EACrB;EAAA,IAAAC,qBAAA;EACX,MAAMC,kBAAkB,GACtB,OAAON,QAAQ,KAAK,QAAQ,GAAGO,IAAI,CAACC,KAAK,CAACR,QAAQ,CAAC,GAAGA,QACjC;EAEvB,MAAMS,gBAAgB,GAAGf,QAAQ,CAAC,aAAa,CAAC;EAChD,MAAMgB,cAAc,GAAG;IACrB,GAAGR,SAAS,CAACQ,cAAc;IAC3BD;EACF,CAAC;;EAED;EACA,OAAOC,cAAc,CAACC,WAAW;EACjC,OAAOD,cAAc,CAACE,YAAY;EAClC,OAAOF,cAAc,CAACG,WAAW;EACjC,OAAOH,cAAc,CAACI,eAAe;EAErC,MAAMC,cAAc,GAAG,IAAIpB,SAAS,CAClC,YAAY,EACZqB,SAAS,EACTZ,eAAe,EACfK,gBACF,CAAC;EACDC,cAAc,CAACO,iBAAiB,CAACC,GAAG,CAACT,gBAAgB,EAAEM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AAM,IACxBb,iBAAiB,CAACa,MAAM,EAAEX,MAAM,EAAEpB,gBAAgB,CACpD,CAAC;EACH;AACF;AAEA,SAASwB,WAAWA,CAClB0B,YAAwC,EACxCC,YAA4B,EACZ;EAChB,MAAM5B,MAAM,GAAG2B,YAAY,IAAI,CAAC,CAAC;EAEjC,KAAK,MAAM,CAACE,SAAS,EAAEC,QAAQ,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACJ,YAAY,CAAC,EAAE;IAChE5B,MAAM,CAAC6B,SAAS,CAAC,GAAGpE,cAAc,CAACuC,MAAM,EAAE6B,SAAS,CAAC,GACjD,CAAC7B,MAAM,CAAC6B,SAAS,CAAC,EAAEC,QAAQ,CAAC,CAACG,IAAI,CAAC,CAAC,GACpCH,QAAQ;EACd;EAEA,OAAO9B,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"expandFormRenderer.js","names":["hasOwnProperty","uniqueId","DataStore","getDefaultProperties","symbolForFormStateStoreId","formContainers","expandFormRenderer","formData","hostBrickConf","hostBrick","asyncHostPropertyEntries","rendererContext","_hostBrickConf$proper","normalizedFormData","JSON","parse","formStateStoreId","runtimeContext","forEachItem","forEachIndex","forEachSize","tplStateStoreId","formStateStore","undefined","formStateStoreMap","set","formStateStoreScope","push","context","some","ctx","name","define","formConf","formSchemaToBrick","formSchema","fields","includes","brick","events","mergeEvents","renderRoot","properties","slots","children","style","padding","schema","id","bricks","mountPoint","instanceId","iid","field","find","item","fieldId","defaults","brickConf","slot","formSchemasToBricks","if","schemas","Array","isArray","map","targetEvents","sourceEvents","eventType","handlers","Object","entries","flat"],"sources":["../../../../src/internal/FormRenderer/expandFormRenderer.ts"],"sourcesContent":["import type { BrickConf, BrickEventsMap } from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { uniqueId } from \"lodash\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport type { AsyncPropertyEntry, RuntimeBrick } from \"../interfaces.js\";\nimport type {\n FieldProperties,\n FormDataProperties,\n FormSchemaProperties,\n} from \"./interfaces.js\";\nimport { getDefaultProperties } from \"./getDefaultProperties.js\";\nimport { symbolForFormStateStoreId } from \"./constants.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\n\nexport const formContainers = [\n \"forms.general-form\",\n \"form.general-form\",\n \"eo-form\",\n];\n\nexport function expandFormRenderer(\n formData: unknown,\n hostBrickConf: BrickConf,\n hostBrick: RuntimeBrick,\n asyncHostPropertyEntries: AsyncPropertyEntry[],\n rendererContext: RendererContext\n): BrickConf {\n const normalizedFormData = (\n typeof formData === \"string\" ? JSON.parse(formData) : formData\n ) as FormDataProperties;\n\n const formStateStoreId = uniqueId(\"form-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n formStateStoreId,\n };\n\n // There is a boundary for `forEach*` and `STATE` between form internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n delete runtimeContext.tplStateStoreId;\n\n const formStateStore = new DataStore(\n \"FORM_STATE\",\n undefined,\n rendererContext,\n formStateStoreId\n );\n runtimeContext.formStateStoreMap.set(formStateStoreId, formStateStore);\n if (runtimeContext.formStateStoreScope) {\n runtimeContext.formStateStoreScope.push(formStateStore);\n }\n\n // Always add a state of `params`.\n const context = normalizedFormData.context ?? [];\n if (!context.some((ctx) => ctx.name === \"params\")) {\n context.push({ name: \"params\" });\n }\n\n formStateStore.define(context, runtimeContext, asyncHostPropertyEntries);\n\n const formConf = formSchemaToBrick(\n normalizedFormData.formSchema,\n normalizedFormData.fields,\n formStateStoreId\n );\n\n if (formContainers.includes(formConf.brick) && hostBrickConf.events) {\n formConf.events = mergeEvents(formConf.events, hostBrickConf.events);\n }\n\n const renderRoot =\n typeof hostBrickConf.properties?.renderRoot !== \"boolean\" ||\n hostBrickConf.properties.renderRoot;\n\n if (renderRoot) {\n return {\n ...hostBrickConf,\n slots: undefined,\n children: [\n {\n brick: \"eo-micro-view\",\n properties: { style: { padding: \"12px\" } },\n children: [formConf],\n },\n ],\n };\n }\n\n return {\n ...hostBrickConf,\n slots: undefined,\n children: [formConf],\n };\n}\n\nfunction formSchemaToBrick(\n schema: FormSchemaProperties,\n fields: FieldProperties[],\n formStateStoreId: string\n): BrickConf {\n const { id, bricks, events, context, mountPoint, instanceId: iid } = schema;\n let { brick, properties } = schema;\n\n // 根据字段类型获取默认配置\n const field = fields.find((item: FieldProperties) => item.fieldId === id);\n if (field) {\n const defaults = getDefaultProperties(field);\n if (!brick) {\n brick = defaults.brick;\n }\n properties = {\n ...defaults.properties,\n ...properties,\n };\n }\n\n const brickConf = {\n brick,\n properties,\n iid,\n slot: mountPoint,\n events,\n context,\n children: formSchemasToBricks(bricks, fields, formStateStoreId),\n [symbolForFormStateStoreId]: formStateStoreId,\n } as BrickConf;\n\n if (hasOwnProperty(schema, \"if\")) {\n brickConf.if = schema.if;\n }\n\n return brickConf;\n}\n\nfunction formSchemasToBricks(\n schemas: FormSchemaProperties[] | undefined,\n fields: FieldProperties[],\n formStateStoreId: string\n): BrickConf[] | undefined {\n if (Array.isArray(schemas)) {\n return schemas.map((schema) =>\n formSchemaToBrick(schema, fields, formStateStoreId)\n );\n }\n}\n\nfunction mergeEvents(\n targetEvents: BrickEventsMap | undefined,\n sourceEvents: BrickEventsMap\n): BrickEventsMap {\n const events = targetEvents ?? {};\n\n for (const [eventType, handlers] of Object.entries(sourceEvents)) {\n events[eventType] = hasOwnProperty(events, eventType)\n ? [events[eventType], handlers].flat()\n : handlers;\n }\n\n return events;\n}\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,SAAS,QAAQ,sBAAsB;AAOhD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,yBAAyB,QAAQ,gBAAgB;AAG1D,OAAO,MAAMC,cAAc,GAAG,CAC5B,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,CACV;AAED,OAAO,SAASC,kBAAkBA,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 import _assertClassBrand from "@babel/runtime/helpers/assertClassBrand";
3
+ import { FORM_RENDERER } from "./constants.js";
4
+ import { formContainers } from "./expandFormRenderer.js";
5
+ var _FormElement_brand = /*#__PURE__*/new WeakSet();
6
+ class FormElement extends HTMLElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ _classPrivateMethodInitSpec(this, _FormElement_brand);
10
+ }
11
+ get $$typeof() {
12
+ return "formRenderer";
13
+ }
14
+ validate() {
15
+ _assertClassBrand(_FormElement_brand, this, _proxyFormMethod).call(this, "validate");
16
+ }
17
+ setInitValue() {
18
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ args[_key] = arguments[_key];
20
+ }
21
+ _assertClassBrand(_FormElement_brand, this, _proxyFormMethod).call(this, "setInitValue", args);
22
+ }
23
+ resetFields() {
24
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
25
+ args[_key2] = arguments[_key2];
26
+ }
27
+ _assertClassBrand(_FormElement_brand, this, _proxyFormMethod).call(this, "resetFields", args);
28
+ }
29
+ }
30
+ function _proxyFormMethod(method) {
31
+ var _containerElement$tag;
32
+ let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
33
+ const containerElement = this.firstElementChild;
34
+ const tagName = containerElement === null || containerElement === void 0 || (_containerElement$tag = containerElement.tagName) === null || _containerElement$tag === void 0 ? void 0 : _containerElement$tag.toLowerCase();
35
+ if (formContainers.includes(tagName)) {
36
+ containerElement[method](...args);
37
+ } else {
38
+ // eslint-disable-next-line no-console
39
+ console.error(`no ${method} method in the container element`, {
40
+ container: tagName
41
+ });
42
+ }
43
+ }
44
+ export function registerFormRenderer() {
45
+ customElements.get(FORM_RENDERER) || customElements.define(FORM_RENDERER, FormElement);
46
+ }
47
+ //# sourceMappingURL=registerFormRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerFormRenderer.js","names":["FORM_RENDERER","formContainers","_FormElement_brand","WeakSet","FormElement","HTMLElement","constructor","arguments","_classPrivateMethodInitSpec","$$typeof","validate","_assertClassBrand","_proxyFormMethod","call","setInitValue","_len","length","args","Array","_key","resetFields","_len2","_key2","method","_containerElement$tag","undefined","containerElement","firstElementChild","tagName","toLowerCase","includes","console","error","container","registerFormRenderer","customElements","get","define"],"sources":["../../../../src/internal/FormRenderer/registerFormRenderer.ts"],"sourcesContent":["import { FORM_RENDERER } from \"./constants.js\";\nimport { formContainers } from \"./expandFormRenderer.js\";\n\nclass FormElement extends HTMLElement {\n get $$typeof(): string {\n return \"formRenderer\";\n }\n\n #proxyFormMethod(method: string, args: unknown[] = []): void {\n const containerElement = this.firstElementChild;\n\n const tagName = containerElement?.tagName?.toLowerCase();\n\n if (formContainers.includes(tagName as string)) {\n (containerElement as any)[method](...args);\n } else {\n // eslint-disable-next-line no-console\n console.error(`no ${method} method in the container element`, {\n container: tagName,\n });\n }\n }\n\n validate(): void {\n this.#proxyFormMethod(\"validate\");\n }\n\n setInitValue(...args: unknown[]): void {\n this.#proxyFormMethod(\"setInitValue\", args);\n }\n\n resetFields(...args: unknown[]): void {\n this.#proxyFormMethod(\"resetFields\", args);\n }\n}\n\nexport function registerFormRenderer(): void {\n customElements.get(FORM_RENDERER) ||\n customElements.define(FORM_RENDERER, FormElement);\n}\n"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,cAAc,QAAQ,yBAAyB;AAAC,IAAAC,kBAAA,oBAAAC,OAAA;AAEzD,MAAMC,WAAW,SAASC,WAAW,CAAC;EAAAC,YAAA;IAAA,SAAAC,SAAA;IAAAC,2BAAA,OAAAN,kBAAA;EAAA;EACpC,IAAIO,QAAQA,CAAA,EAAW;IACrB,OAAO,cAAc;EACvB;EAiBAC,QAAQA,CAAA,EAAS;IACfC,iBAAA,CAAAT,kBAAA,MAAI,EAACU,gBAAe,CAAC,CAAAC,IAAA,CAArB,IAAI,EAAkB,UAAU;EAClC;EAEAC,YAAYA,CAAA,EAA2B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5DU,SAAS,EAAEL;IACb,CAAC,CAAC;EACJ;AACF;AAeF,OAAO,SAASM,oBAAoBA,CAAA,EAAS;EAC3CC,cAAc,CAACC,GAAG,CAACpC,aAAa,CAAC,IAC/BmC,cAAc,CAACE,MAAM,CAACrC,aAAa,EAAEI,WAAW,CAAC;AACrD","ignoreList":[]}
@@ -9,7 +9,7 @@ import { resolveData } from "./data/resolveData.js";
9
9
  import { asyncComputeRealValue } from "./compute/computeRealValue.js";
10
10
  import { listenOnTrackingContext } from "./compute/listenOnTrackingContext.js";
11
11
  import { matchRoute, matchRoutes } from "./matchRoutes.js";
12
- import { symbolForAsyncComputedPropsFromHost, symbolForTPlExternalForEachIndex, symbolForTPlExternalForEachItem, symbolForTPlExternalForEachSize, symbolForTPlExternalNoForEach, symbolForTplStateStoreId } from "./CustomTemplates/constants.js";
12
+ import { symbolForAsyncComputedPropsFromHost, symbolForTPlExternalForEachIndex, symbolForTPlExternalForEachItem, symbolForTPlExternalForEachSize, symbolForTplStateStoreId } from "./CustomTemplates/constants.js";
13
13
  import { expandCustomTemplate } from "./CustomTemplates/expandCustomTemplate.js";
14
14
  import { getTagNameOfCustomTemplate, getTplStateStore } from "./CustomTemplates/utils.js";
15
15
  import { customTemplates } from "../CustomTemplates.js";
@@ -19,6 +19,7 @@ import { getTracks } from "./compute/getTracks.js";
19
19
  import { isStrictMode, warnAboutStrictMode } from "../isStrictMode.js";
20
20
  import { FORM_RENDERER, symbolForFormStateStoreId } from "./FormRenderer/constants.js";
21
21
  import { expandFormRenderer } from "./FormRenderer/expandFormRenderer.js";
22
+ import { registerFormRenderer } from "./FormRenderer/registerFormRenderer.js";
22
23
  import { isPreEvaluated } from "./compute/evaluate.js";
23
24
  import { getPreEvaluatedRaw } from "./compute/evaluate.js";
24
25
  import { matchHomepage } from "./matchStoryboard.js";
@@ -204,10 +205,6 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
204
205
  runtimeContext.forEachItem = brickConf[symbolForTPlExternalForEachItem];
205
206
  runtimeContext.forEachIndex = brickConf[symbolForTPlExternalForEachIndex];
206
207
  runtimeContext.forEachSize = brickConf[symbolForTPlExternalForEachSize];
207
- } else if (brickConf[symbolForTPlExternalNoForEach]) {
208
- delete runtimeContext.forEachItem;
209
- delete runtimeContext.forEachIndex;
210
- delete runtimeContext.forEachSize;
211
208
  }
212
209
  const {
213
210
  context
@@ -357,11 +354,7 @@ async function legacyRenderBrick(returnNode, brickConf, _runtimeContext, rendere
357
354
  tplStack.set(tplTagName, tplCount + 1);
358
355
  } else if (brickName.includes("-") && !customElements.get(brickName)) {
359
356
  if (brickName === FORM_RENDERER) {
360
- customElements.define(FORM_RENDERER, class FormRendererElement extends HTMLElement {
361
- get $$typeof() {
362
- return "form-renderer";
363
- }
364
- });
357
+ registerFormRenderer();
365
358
  } else {
366
359
  output.blockingList.push(catchLoad(enqueueStableLoadBricks([brickName], getBrickPackages()), "brick", brickName, rendererContext.unknownBricks));
367
360
  }