@next-core/runtime 1.56.2 → 1.57.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 (30) hide show
  1. package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js +15 -5
  2. package/dist/cjs/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
  3. package/dist/cjs/internal/CustomTemplates/replaceSlotWithSlottedBricks.js +42 -0
  4. package/dist/cjs/internal/CustomTemplates/replaceSlotWithSlottedBricks.js.map +1 -0
  5. package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js +5 -1
  6. package/dist/cjs/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
  7. package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js +13 -4
  8. package/dist/cjs/internal/CustomTemplates/setupUseBrickInTemplate.js.map +1 -1
  9. package/dist/cjs/internal/Renderer.js +5 -2
  10. package/dist/cjs/internal/Renderer.js.map +1 -1
  11. package/dist/cjs/internal/data/DataStore.js +0 -1
  12. package/dist/cjs/internal/data/DataStore.js.map +1 -1
  13. package/dist/cjs/internal/interfaces.js.map +1 -1
  14. package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js +15 -5
  15. package/dist/esm/internal/CustomTemplates/expandCustomTemplate.js.map +1 -1
  16. package/dist/esm/internal/CustomTemplates/replaceSlotWithSlottedBricks.js +36 -0
  17. package/dist/esm/internal/CustomTemplates/replaceSlotWithSlottedBricks.js.map +1 -0
  18. package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js +5 -2
  19. package/dist/esm/internal/CustomTemplates/setupTemplateProxy.js.map +1 -1
  20. package/dist/esm/internal/CustomTemplates/setupUseBrickInTemplate.js +13 -4
  21. package/dist/esm/internal/CustomTemplates/setupUseBrickInTemplate.js.map +1 -1
  22. package/dist/esm/internal/Renderer.js +5 -2
  23. package/dist/esm/internal/Renderer.js.map +1 -1
  24. package/dist/esm/internal/data/DataStore.js +0 -1
  25. package/dist/esm/internal/data/DataStore.js.map +1 -1
  26. package/dist/esm/internal/interfaces.js.map +1 -1
  27. package/dist/types/internal/CustomTemplates/replaceSlotWithSlottedBricks.d.ts +3 -0
  28. package/dist/types/internal/CustomTemplates/setupTemplateProxy.d.ts +3 -2
  29. package/dist/types/internal/interfaces.d.ts +1 -0
  30. package/package.json +2 -2
@@ -11,6 +11,7 @@ var _setupTemplateProxy = require("./setupTemplateProxy.js");
11
11
  var _setupUseBrickInTemplate = require("./setupUseBrickInTemplate.js");
12
12
  var _Renderer = require("../Renderer.js");
13
13
  var _Runtime = require("../Runtime.js");
14
+ var _replaceSlotWithSlottedBricks = require("./replaceSlotWithSlottedBricks.js");
14
15
  function expandCustomTemplate(tplTagName, brickConf, hostBrick, asyncHostPropertyEntries, rendererContext) {
15
16
  var _hooks$flowApi;
16
17
  const tplStateStoreId = (0, _lodash.uniqueId)("tpl-state-");
@@ -89,21 +90,26 @@ function expandCustomTemplate(tplTagName, brickConf, hostBrick, asyncHostPropert
89
90
  asyncHostPropertyEntries,
90
91
  externalSlots: (0, _Renderer.childrenToSlots)(externalChildren, originalExternalSlots),
91
92
  tplStateStoreId,
92
- hostBrick: hostBrick
93
+ hostBrick: hostBrick,
94
+ usedSlots: new Set()
93
95
  };
94
96
  newBrickConf.slots = {
95
97
  "": {
96
98
  type: "bricks",
97
- bricks: bricks.map(item => expandBrickInTemplate(item, hostContext))
99
+ bricks: bricks.flatMap(item => expandBrickInTemplate(item, hostContext))
98
100
  }
99
101
  };
100
102
  return newBrickConf;
101
103
  }
102
- function expandBrickInTemplate(brickConfInTemplate, hostContext) {
104
+ function expandBrickInTemplate(brickConfInTemplate, hostContext, markSlotted) {
103
105
  // Ignore `if: null` to make `looseCheckIf` working.
104
106
  if (brickConfInTemplate.if === null) {
105
107
  delete brickConfInTemplate.if;
106
108
  }
109
+ if (brickConfInTemplate.brick === "slot") {
110
+ markSlotted === null || markSlotted === void 0 || markSlotted();
111
+ return (0, _replaceSlotWithSlottedBricks.replaceSlotWithSlottedBricks)(brickConfInTemplate, hostContext, expandBrickInTemplate);
112
+ }
107
113
  const {
108
114
  properties,
109
115
  slots: slotsInTemplate,
@@ -111,15 +117,19 @@ function expandBrickInTemplate(brickConfInTemplate, hostContext) {
111
117
  ...restBrickConfInTemplate
112
118
  } = brickConfInTemplate;
113
119
  const transpiledSlots = (0, _Renderer.childrenToSlots)(childrenInTemplate, slotsInTemplate);
120
+ let slotted = false;
121
+ const markChild = () => {
122
+ slotted = true;
123
+ };
114
124
  const slots = Object.fromEntries(Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [slotName, {
115
125
  type: "bricks",
116
- bricks: (slotConf.bricks ?? []).map(item => expandBrickInTemplate(item, hostContext))
126
+ bricks: (slotConf.bricks ?? []).flatMap(item => expandBrickInTemplate(item, hostContext, markChild))
117
127
  }]));
118
128
  return {
119
129
  ...restBrickConfInTemplate,
120
130
  properties: (0, _setupUseBrickInTemplate.setupUseBrickInTemplate)(properties, hostContext),
121
131
  slots,
122
- ...(0, _setupTemplateProxy.setupTemplateProxy)(hostContext, restBrickConfInTemplate.ref, slots)
132
+ ...(0, _setupTemplateProxy.setupTemplateProxy)(hostContext, restBrickConfInTemplate.ref, slots, slotted)
123
133
  };
124
134
  }
125
135
  //# sourceMappingURL=expandCustomTemplate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expandCustomTemplate.js","names":["_lodash","require","_CustomTemplates","_DataStore","_setupTemplateProxy","_setupUseBrickInTemplate","_Renderer","_Runtime","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostPropertyEntries","rendererContext","_hooks$flowApi","tplStateStoreId","uniqueId","runtimeContext","forEachItem","forEachIndex","forEachSize","formStateStoreId","tplStateStore","DataStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","customTemplates","get","hooks","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","childrenToSlots","type","map","item","expandBrickInTemplate","brickConfInTemplate","if","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","transpiledSlots","fromEntries","slotName","slotConf","setupUseBrickInTemplate","setupTemplateProxy"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { RuntimeBrickConfWithTplSymbols } from \"./constants.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncPropertyEntry,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostPropertyEntries: AsyncPropertyEntry[],\n rendererContext: RendererContext\n): T {\n const tplStateStoreId = uniqueId(\"tpl-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n tplStateStoreId,\n };\n\n // There is a boundary for `forEach*` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\n \"STATE\",\n hostBrick,\n rendererContext,\n tplStateStoreId\n );\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostPropertyEntries);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.map((item) => expandBrickInTemplate(item, hostContext)),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConfInTemplate,\n hostContext: TemplateHostContext\n): RuntimeBrickConfWithTplSymbols {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n const slots: SlotsConfOfBricks = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(hostContext, restBrickConfInTemplate.ref, slots),\n };\n}\n"],"mappings":";;;;;;AAOA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,mBAAA,GAAAH,OAAA;AAOA,IAAAI,wBAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAGO,SAASO,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,wBAA8C,EAC9CC,eAAgC,EAC7B;EAAA,IAAAC,cAAA;EACH,MAAMC,eAAe,GAAG,IAAAC,gBAAQ,EAAC,YAAY,CAAC;EAC9C,MAAMC,cAAc,GAAG;IACrB,GAAGN,SAAS,CAACM,cAAc;IAC3BF;EACF,CAAC;;EAED;EACA,OAAOE,cAAc,CAACC,WAAW;EACjC,OAAOD,cAAc,CAACE,YAAY;EAClC,OAAOF,cAAc,CAACG,WAAW;EACjC,OAAOH,cAAc,CAACI,gBAAgB;EAEtC,MAAMC,aAAa,GAAG,IAAIC,oBAAS,CACjC,OAAO,EACPZ,SAAS,EACTE,eAAe,EACfE,eACF,CAAC;EACDE,cAAc,CAACO,gBAAgB,CAACC,GAAG,CAACV,eAAe,EAAEO,aAAa,CAAC;EACnE,IAAIL,cAAc,CAACS,kBAAkB,EAAE;IACrCT,cAAc,C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AAe,GAAG,IAAAV,yBAAe,EACrCQ,kBAAkB,EAClBD,eACF,CAAoC;EAEpC,MAAM3B,KAAwB,GAAGc,MAAM,CAACiB,WAAW,CACjDjB,MAAM,CAACC,OAAO,CAACe,eAAe,IAAI,CAAC,CAAC,CAAC,CAACR,GAAG,CAAC,CAAC,CAACU,QAAQ,EAAEC,QAAQ,CAAC,KAAK,CAClED,QAAQ,EACR;IACEX,IAAI,EAAE,QAAQ;IACd/B,MAAM,EAAE,CAAC2C,QAAQ,CAAC3C,MAAM,IAAI,EAAE,EAAEgC,GAAG,CAAEC,IAAI,IACvCC,qBAAqB,CAACD,IAAI,EAAEL,WAAW,CACzC;EACF,CAAC,CACF,CACH,CAAC;EAED,OAAO;IACL,GAAGW,uBAAuB;IAC1BlB,UAAU,EAAE,IAAAuB,gDAAuB,EAACvB,UAAU,EAAEO,WAAW,CAAC;IAC5DlB,KAAK;IACL,GAAG,IAAAmC,sCAAkB,EAACjB,WAAW,EAAEW,uBAAuB,CAACZ,GAAG,EAAEjB,KAAK;EACvE,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"expandCustomTemplate.js","names":["_lodash","require","_CustomTemplates","_DataStore","_setupTemplateProxy","_setupUseBrickInTemplate","_Renderer","_Runtime","_replaceSlotWithSlottedBricks","expandCustomTemplate","tplTagName","brickConf","hostBrick","asyncHostPropertyEntries","rendererContext","_hooks$flowApi","tplStateStoreId","uniqueId","runtimeContext","forEachItem","forEachIndex","forEachSize","formStateStoreId","tplStateStore","DataStore","tplStateStoreMap","set","tplStateStoreScope","push","bricks","proxy","state","contracts","customTemplates","get","hooks","flowApi","collectWidgetContract","define","slots","originalExternalSlots","children","externalChildren","restBrickConf","newBrickConf","brick","tplHostMetadata","internalBricksByRef","Map","reversedProxies","properties","from","to","Object","entries","proxies","ref","hostContext","externalSlots","childrenToSlots","usedSlots","Set","type","flatMap","item","expandBrickInTemplate","brickConfInTemplate","markSlotted","if","replaceSlotWithSlottedBricks","slotsInTemplate","childrenInTemplate","restBrickConfInTemplate","transpiledSlots","slotted","markChild","fromEntries","map","slotName","slotConf","setupUseBrickInTemplate","setupTemplateProxy"],"sources":["../../../../src/internal/CustomTemplates/expandCustomTemplate.ts"],"sourcesContent":["import type {\n BrickConf,\n BrickConfInTemplate,\n SlotConfOfBricks,\n SlotsConfInTemplate,\n SlotsConfOfBricks,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { uniqueId } from \"lodash\";\nimport { customTemplates } from \"../../CustomTemplates.js\";\nimport { DataStore } from \"../data/DataStore.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport type {\n AsyncPropertyEntry,\n RuntimeBrick,\n TemplateHostBrick,\n TemplateHostContext,\n} from \"../interfaces.js\";\nimport { setupUseBrickInTemplate } from \"./setupUseBrickInTemplate.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { hooks } from \"../Runtime.js\";\nimport type { RendererContext } from \"../RendererContext.js\";\nimport { replaceSlotWithSlottedBricks } from \"./replaceSlotWithSlottedBricks.js\";\n\nexport function expandCustomTemplate<T extends BrickConf | UseSingleBrickConf>(\n tplTagName: string,\n brickConf: T,\n hostBrick: RuntimeBrick,\n asyncHostPropertyEntries: AsyncPropertyEntry[],\n rendererContext: RendererContext\n): T {\n const tplStateStoreId = uniqueId(\"tpl-state-\");\n const runtimeContext = {\n ...hostBrick.runtimeContext,\n tplStateStoreId,\n };\n\n // There is a boundary for `forEach*` and `FORM_STATE` between template internals and externals.\n delete runtimeContext.forEachItem;\n delete runtimeContext.forEachIndex;\n delete runtimeContext.forEachSize;\n delete runtimeContext.formStateStoreId;\n\n const tplStateStore = new DataStore(\n \"STATE\",\n hostBrick,\n rendererContext,\n tplStateStoreId\n );\n runtimeContext.tplStateStoreMap.set(tplStateStoreId, tplStateStore);\n if (runtimeContext.tplStateStoreScope) {\n runtimeContext.tplStateStoreScope.push(tplStateStore);\n }\n\n const { bricks, proxy, state, contracts } = customTemplates.get(tplTagName)!;\n hooks?.flowApi?.collectWidgetContract(contracts);\n tplStateStore.define(state, runtimeContext, asyncHostPropertyEntries);\n\n const {\n slots: originalExternalSlots,\n children: externalChildren,\n ...restBrickConf\n } = brickConf;\n\n const newBrickConf = {\n ...restBrickConf,\n brick: tplTagName,\n } as T;\n\n hostBrick.tplHostMetadata = {\n internalBricksByRef: new Map(),\n tplStateStoreId,\n proxy,\n };\n\n // Reversed proxies are used for expand storyboard before rendering page.\n const reversedProxies: TemplateHostContext[\"reversedProxies\"] = {\n properties: new Map(),\n slots: new Map(),\n // mergeBases: new Map(),\n };\n\n if (proxy?.properties) {\n for (const [from, to] of Object.entries(proxy.properties)) {\n let proxies = reversedProxies.properties.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.properties.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n if (proxy?.slots) {\n for (const [from, to] of Object.entries(proxy.slots)) {\n let proxies = reversedProxies.slots.get(to.ref);\n if (!proxies) {\n proxies = [];\n reversedProxies.slots.set(to.ref, proxies);\n }\n proxies.push({\n from,\n to,\n });\n }\n }\n\n const hostContext: TemplateHostContext = {\n reversedProxies,\n asyncHostPropertyEntries,\n externalSlots: childrenToSlots(externalChildren, originalExternalSlots) as\n | SlotsConfOfBricks\n | undefined,\n tplStateStoreId,\n hostBrick: hostBrick as TemplateHostBrick,\n usedSlots: new Set(),\n };\n\n newBrickConf.slots = {\n \"\": {\n type: \"bricks\",\n bricks: bricks.flatMap((item) =>\n expandBrickInTemplate(item, hostContext)\n ),\n },\n };\n\n return newBrickConf;\n}\n\nfunction expandBrickInTemplate(\n brickConfInTemplate: BrickConf,\n hostContext: TemplateHostContext,\n markSlotted?: () => void\n): BrickConf | BrickConf[] {\n // Ignore `if: null` to make `looseCheckIf` working.\n if (brickConfInTemplate.if === null) {\n delete brickConfInTemplate.if;\n }\n\n if (brickConfInTemplate.brick === \"slot\") {\n markSlotted?.();\n return replaceSlotWithSlottedBricks(\n brickConfInTemplate,\n hostContext,\n expandBrickInTemplate\n );\n }\n\n const {\n properties,\n slots: slotsInTemplate,\n children: childrenInTemplate,\n ...restBrickConfInTemplate\n } = brickConfInTemplate as BrickConfInTemplate;\n\n const transpiledSlots = childrenToSlots(\n childrenInTemplate,\n slotsInTemplate\n ) as SlotsConfInTemplate | undefined;\n\n let slotted = false;\n const markChild = () => {\n slotted = true;\n };\n const slots = Object.fromEntries<SlotConfOfBricks>(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).flatMap((item) =>\n expandBrickInTemplate(item, hostContext, markChild)\n ),\n },\n ])\n );\n\n return {\n ...restBrickConfInTemplate,\n properties: setupUseBrickInTemplate(properties, hostContext),\n slots,\n ...setupTemplateProxy(\n hostContext,\n restBrickConfInTemplate.ref,\n slots,\n slotted\n ),\n };\n}\n"],"mappings":";;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAOA,IAAAI,wBAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAEA,IAAAO,6BAAA,GAAAP,OAAA;AAEO,SAASQ,oBAAoBA,CAClCC,UAAkB,EAClBC,SAAY,EACZC,SAAuB,EACvBC,wBAA8C,EAC9CC,eAAgC,EAC7B;EAAA,IAAAC,cAAA;EACH,MAAMC,eAAe,GAAG,IAAAC,gBAAQ,EAAC,YAAY,CAAC;EAC9C,MAAMC,cAAc,GAAG;IACrB,GAAGN,SAAS,CAACM,cAAc;IAC3BF;EACF,CAAC;;EAED;EACA,OAAOE,cAAc,CAACC,WAAW;EACjC,OAAOD,cAAc,CAACE,YAAY;EAClC,OAAOF,cAAc,CAACG,WAAW;EACjC,OAAOH,cAAc,CAACI,gBAAgB;EAEtC,MAAMC,aAA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CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.replaceSlotWithSlottedBricks = replaceSlotWithSlottedBricks;
7
+ var _general = require("@next-core/utils/general");
8
+ var _cook = require("@next-core/cook");
9
+ var _setupTemplateProxy = require("./setupTemplateProxy.js");
10
+ var _Renderer = require("../Renderer.js");
11
+ function replaceSlotWithSlottedBricks(brickConf, hostContext, expand) {
12
+ var _brickConf$properties, _defaultSlots$;
13
+ // Currently, no support for `if` in a slot.
14
+ if (brickConf.if != null && !brickConf.if || typeof brickConf.if === "string") {
15
+ throw new Error(`Can not use "if" in a slot currently, check your template "${hostContext.hostBrick.type}"`);
16
+ }
17
+ const slot = String(((_brickConf$properties = brickConf.properties) === null || _brickConf$properties === void 0 ? void 0 : _brickConf$properties.name) ?? "");
18
+
19
+ // Currently, no support for expression as slot name.
20
+ if ((0, _cook.isEvaluable)(slot)) {
21
+ throw new Error(`Can not use an expression as slot name "${slot}" currently, check your template "${hostContext.hostBrick.type}"`);
22
+ }
23
+
24
+ // Do not repeat the same slot name in a template.
25
+ if (hostContext.usedSlots.has(slot)) {
26
+ throw new Error(`Can not have multiple slots with the same name "${slot}", check your template "${hostContext.hostBrick.type}"`);
27
+ }
28
+ hostContext.usedSlots.add(slot);
29
+ if (hostContext.externalSlots && (0, _general.hasOwnProperty)(hostContext.externalSlots, slot)) {
30
+ const insertBricks = hostContext.externalSlots[slot].bricks ?? [];
31
+ if (insertBricks.length > 0) {
32
+ const hostCtx = hostContext.hostBrick.runtimeContext;
33
+ // External bricks of a template, should not access the template internal forEach `ITEM`.
34
+ // For some existing templates who is *USING* this bug, we keep the old behavior.
35
+ const hostHasForEach = (0, _general.hasOwnProperty)(hostCtx, "forEachItem");
36
+ return hostHasForEach ? (0, _setupTemplateProxy.setupTemplateExternalBricksWithForEach)(insertBricks, hostCtx.forEachItem, hostCtx.forEachIndex, hostCtx.forEachSize) : insertBricks;
37
+ }
38
+ }
39
+ const defaultSlots = (0, _Renderer.childrenToSlots)(brickConf.children, brickConf.slots);
40
+ return ((defaultSlots === null || defaultSlots === void 0 || (_defaultSlots$ = defaultSlots[""]) === null || _defaultSlots$ === void 0 ? void 0 : _defaultSlots$.bricks) ?? []).flatMap(item => expand(item, hostContext));
41
+ }
42
+ //# sourceMappingURL=replaceSlotWithSlottedBricks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replaceSlotWithSlottedBricks.js","names":["_general","require","_cook","_setupTemplateProxy","_Renderer","replaceSlotWithSlottedBricks","brickConf","hostContext","expand","_brickConf$properties","_defaultSlots$","if","Error","hostBrick","type","slot","String","properties","name","isEvaluable","usedSlots","has","add","externalSlots","hasOwnProperty","insertBricks","bricks","length","hostCtx","runtimeContext","hostHasForEach","setupTemplateExternalBricksWithForEach","forEachItem","forEachIndex","forEachSize","defaultSlots","childrenToSlots","children","slots","flatMap","item"],"sources":["../../../../src/internal/CustomTemplates/replaceSlotWithSlottedBricks.ts"],"sourcesContent":["import type {\n BrickConf,\n SlotsConfInTemplate,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { isEvaluable } from \"@next-core/cook\";\nimport type { TemplateHostContext } from \"../interfaces.js\";\nimport { setupTemplateExternalBricksWithForEach } from \"./setupTemplateProxy.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function replaceSlotWithSlottedBricks<\n T extends BrickConf | UseSingleBrickConf,\n>(\n brickConf: T,\n hostContext: TemplateHostContext,\n expand: (item: T, hostContext: TemplateHostContext) => T | T[]\n): T[] {\n // Currently, no support for `if` in a slot.\n if (\n (brickConf.if != null && !brickConf.if) ||\n typeof brickConf.if === \"string\"\n ) {\n throw new Error(\n `Can not use \"if\" in a slot currently, check your template \"${hostContext.hostBrick.type}\"`\n );\n }\n\n const slot = String(brickConf.properties?.name ?? \"\");\n\n // Currently, no support for expression as slot name.\n if (isEvaluable(slot)) {\n throw new Error(\n `Can not use an expression as slot name \"${slot}\" currently, check your template \"${hostContext.hostBrick.type}\"`\n );\n }\n\n // Do not repeat the same slot name in a template.\n if (hostContext.usedSlots.has(slot)) {\n throw new Error(\n `Can not have multiple slots with the same name \"${slot}\", check your template \"${hostContext.hostBrick.type}\"`\n );\n }\n hostContext.usedSlots.add(slot);\n\n if (\n hostContext.externalSlots &&\n hasOwnProperty(hostContext.externalSlots, slot)\n ) {\n const insertBricks = hostContext.externalSlots[slot].bricks ?? [];\n if (insertBricks.length > 0) {\n const hostCtx = hostContext.hostBrick.runtimeContext;\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(hostCtx, \"forEachItem\");\n return (\n hostHasForEach\n ? setupTemplateExternalBricksWithForEach(\n insertBricks,\n hostCtx.forEachItem,\n hostCtx.forEachIndex!,\n hostCtx.forEachSize!\n )\n : insertBricks\n ) as T[];\n }\n }\n\n const defaultSlots = childrenToSlots(brickConf.children, brickConf.slots) as\n | SlotsConfInTemplate\n | undefined;\n return (defaultSlots?.[\"\"]?.bricks ?? []).flatMap((item) =>\n expand(item as T, hostContext)\n );\n}\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEO,SAASI,4BAA4BA,CAG1CC,SAAY,EACZC,WAAgC,EAChCC,MAA8D,EACzD;EAAA,IAAAC,qBAAA,EAAAC,cAAA;EACL;EACA,IACGJ,SAAS,CAACK,EAAE,IAAI,IAAI,IAAI,CAACL,SAAS,CAACK,EAAE,IACtC,OAAOL,SAAS,CAACK,EAAE,KAAK,QAAQ,EAChC;IACA,MAAM,IAAIC,KAAK,CACb,8DAA8DL,WAAW,CAACM,SAAS,CAACC,IAAI,GAC1F,CAAC;EACH;EAE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ZyB,YAAY,CAAG,EAAE,CAAC,cAAAzB,cAAA,uBAAlBA,cAAA,CAAoBgB,MAAM,KAAI,EAAE,EAAEa,OAAO,CAAEC,IAAI,IACrDhC,MAAM,CAACgC,IAAI,EAAOjC,WAAW,CAC/B,CAAC;AACH","ignoreList":[]}
@@ -3,13 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.setupTemplateExternalBricksWithForEach = setupTemplateExternalBricksWithForEach;
6
7
  exports.setupTemplateProxy = setupTemplateProxy;
7
8
  var _general = require("@next-core/utils/general");
8
9
  var _lodash = require("lodash");
9
10
  var _constants = require("./constants.js");
10
11
  var _computeRealProperties = require("../compute/computeRealProperties.js");
11
12
  var _Renderer = require("../Renderer.js");
12
- function setupTemplateProxy(hostContext, ref, slots) {
13
+ function setupTemplateProxy(hostContext, ref, slots, slotted) {
13
14
  const {
14
15
  reversedProxies,
15
16
  asyncHostPropertyEntries,
@@ -35,6 +36,9 @@ function setupTemplateProxy(hostContext, ref, slots) {
35
36
  asyncComputedProps = getComputedProps(asyncHostPropertyEntries);
36
37
  }
37
38
  const slotProxies = reversedProxies.slots.get(ref);
39
+ if (slotProxies && slotted) {
40
+ throw new Error(`Can not have proxied slot ref when the parent has a slot element child, check your template "${hostBrick.type}" and ref "${ref}"`);
41
+ }
38
42
  if (slotProxies && externalSlots) {
39
43
  // Use an approach like template-literal's quasis:
40
44
  // `quasi0${0}quais1${1}quasi2...`
@@ -1 +1 @@
1
- {"version":3,"file":"setupTemplateProxy.js","names":["_general","require","_lodash","_constants","_computeRealProperties","_Renderer","setupTemplateProxy","hostContext","ref","slots","reversedProxies","asyncHostPropertyEntries","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","asyncHostProps","map","from","to","filtered","filter","entry","length","refProperty","computePropertyValue","Boolean","slotProxies","quasisMap","Map","_externalSlots$from","insertBricks","bricks","refToSlot","refSlot","expandableSlot","size","hasOwnProperty","i","push","set","refPosition","hostHasForEach","runtimeContext","clamp","setupTemplateExternalBricksWithForEach","forEachItem","forEachIndex","forEachSize","slotName","quasis","entries","type","slotConf","flatMap","index","concat","symbolForAsyncComputedPropsFromHost","symbolForTplStateStoreId","children","brick","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachSize","childrenToSlots","Object","fromEntries","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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AASA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEO,SAASK,kBAAkBA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yBAAe,EAACL,QAAQ,EAAEtD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAACY,GAAG,CACxD,CAAC,CAACgC,QAAQ,EAAEI,QAAQ,CAAC,KAAK,CACxBJ,QAAQ,EACRI,QAAQ,CAACD,IAAI,KAAK,QAAQ,GACtB;MACEA,IAAI,EAAE,QAAQ;MACde,MAAM,EAAEC,sCAAsC,CAC5Cf,QAAQ,CAACc,MAAM,EACfrB,WAAW,EACXC,YAAY,EACZC,WACF;IACF,CAAC,GACD;MACEI,IAAI,EAAE,QAAQ;MACdpB,MAAM,EAAEa,sCAAsC,CAC5CQ,QAAQ,CAACrB,MAAM,EACfc,WAAW,EACXC,YAAY,EACZC,WACF;IACF,CAAC,CAET,CACF;EACR,CAAC,CACH,CAAC;AACH;AAEA,SAASoB,sCAAsCA,CAC7CD,MAAmB,EACnBrB,WAAoB,EACpBC,YAAoB,EACpBC,WAAmB,EACN;EACb,OAAOmB,MAAM,CAAClD,GAAG,CAAEoD,KAAK,IACtBA,KAAK,CAACjB,IAAI,KAAK,QAAQ,GACnB;IACE,GAAGiB,KAAK;IACRF,MAAM,EAAEC,sCAAsC,CAC5CC,KAAK,CAACF,MAAM,EACZrB,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CAAC,GACDqB,KAAK,CAACjB,IAAI,KAAK,UAAU,GACvBiB,KAAK,GACL;IACE,GAAGA,KAAK;IACRrC,MAAM,EAAEa,sCAAsC,CAC5CwB,KAAK,CAACrC,MAAM,EACZc,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CACR,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"setupTemplateProxy.js","names":["_general","require","_lodash","_constants","_computeRealProperties","_Renderer","setupTemplateProxy","hostContext","ref","slots","slotted","reversedProxies","asyncHostPropertyEntries","externalSlots","tplStateStoreId","hostBrick","asyncComputedProps","propertyProxies","properties","get","getComputedProps","asyncHostProps","map","from","to","filtered","filter","entry","length","refProperty","computePropertyValue","Boolean","slotProxies","Error","type","quasisMap","Map","_externalSlots$from","insertBricks","bricks","refToSlot","refSlot","expandableSlot","size","hasOwnProperty","i","push","set","refPosition","hostHasForEach","runtimeContext","clamp","setupTemplateExternalBricksWithForEach","forEachItem","forEachIndex","forEachSize","slotName","quasis","entries","slotConf","flatMap","index","concat","symbolForAsyncComputedPropsFromHost","symbolForTplStateStoreId","children","brick","symbolForTPlExternalForEachItem","symbolForTPlExternalForEachIndex","symbolForTPlExternalForEachSize","childrenToSlots","Object","fromEntries","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 slotted: boolean\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\n if (slotProxies && slotted) {\n throw new Error(\n `Can not have proxied slot ref when the parent has a slot element child, check your template \"${hostBrick.type}\" and ref \"${ref}\"`\n );\n }\n\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.\nexport function 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":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CAACpC,MAAM,EACZc,WAAW,EACXC,YAAY,EACZC,WACF;EACF,CACR,CAAC;AACH","ignoreList":[]}
@@ -7,6 +7,7 @@ exports.setupUseBrickInTemplate = setupUseBrickInTemplate;
7
7
  var _general = require("@next-core/utils/general");
8
8
  var _setupTemplateProxy = require("./setupTemplateProxy.js");
9
9
  var _Renderer = require("../Renderer.js");
10
+ var _replaceSlotWithSlottedBricks = require("./replaceSlotWithSlottedBricks.js");
10
11
  function setupUseBrickInTemplate(props, hostContext) {
11
12
  function walk(props) {
12
13
  if (!(0, _general.isObject)(props) || typeof props === "function") {
@@ -15,9 +16,13 @@ function setupUseBrickInTemplate(props, hostContext) {
15
16
  if (Array.isArray(props)) {
16
17
  return props.map(walk);
17
18
  }
18
- return Object.fromEntries(Object.entries(props).map(([key, value]) => (0, _general.isObject)(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)]).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
19
+ return Object.fromEntries(Object.entries(props).map(([key, value]) => (0, _general.isObject)(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.flatMap(v => setup(v))] : [key, setup(value)] : [key, walk(value)]).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
19
20
  }
20
- function setup(item) {
21
+ function setup(item, markSlotted) {
22
+ if (item.brick === "slot") {
23
+ markSlotted === null || markSlotted === void 0 || markSlotted();
24
+ return (0, _replaceSlotWithSlottedBricks.replaceSlotWithSlottedBricks)(item, hostContext, it => setup(it));
25
+ }
21
26
  const {
22
27
  properties,
23
28
  slots: originalSlots,
@@ -25,15 +30,19 @@ function setupUseBrickInTemplate(props, hostContext) {
25
30
  ...restConf
26
31
  } = item;
27
32
  const transpiledSlots = (0, _Renderer.childrenToSlots)(children, originalSlots);
33
+ let slotted = false;
34
+ const markChild = () => {
35
+ slotted = true;
36
+ };
28
37
  const slots = Object.fromEntries(Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [slotName, {
29
38
  type: "bricks",
30
- bricks: (slotConf.bricks ?? []).map(setup)
39
+ bricks: (slotConf.bricks ?? []).flatMap(it => setup(it, markChild))
31
40
  }]));
32
41
  return {
33
42
  ...restConf,
34
43
  properties: walk(properties),
35
44
  slots,
36
- ...(0, _setupTemplateProxy.setupTemplateProxy)(hostContext, restConf.ref, slots)
45
+ ...(0, _setupTemplateProxy.setupTemplateProxy)(hostContext, restConf.ref, slots, slotted)
37
46
  };
38
47
  }
39
48
  return walk(props);
@@ -1 +1 @@
1
- {"version":3,"file":"setupUseBrickInTemplate.js","names":["_general","require","_setupTemplateProxy","_Renderer","setupUseBrickInTemplate","props","hostContext","walk","isObject","Array","isArray","map","Object","fromEntries","entries","key","value","setup","concat","getOwnPropertySymbols","k","item","properties","slots","originalSlots","children","restConf","transpiledSlots","childrenToSlots","slotName","slotConf","type","bricks","setupTemplateProxy","ref"],"sources":["../../../../src/internal/CustomTemplates/setupUseBrickInTemplate.ts"],"sourcesContent":["import type { UseBrickSlotsConf, UseSingleBrickConf } from \"@next-core/types\";\nimport { isObject } from \"@next-core/utils/general\";\nimport type { TemplateHostContext } from \"../interfaces.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\n\nexport function setupUseBrickInTemplate<T>(\n props: T,\n hostContext: TemplateHostContext\n): T {\n function walk<P>(props: P): P {\n if (!isObject(props) || typeof props === \"function\") {\n return props;\n }\n\n if (Array.isArray(props)) {\n return props.map(walk) as P;\n }\n\n return Object.fromEntries(\n Object.entries(props)\n .map(([key, value]) =>\n isObject(value) && key === \"useBrick\"\n ? Array.isArray(value)\n ? [key, value.map(setup)]\n : [key, setup(value as UseSingleBrickConf)]\n : [key, walk(value)]\n )\n .concat(\n Object.getOwnPropertySymbols(props).map((k) => [\n k,\n (props as Record<string | symbol, unknown>)[k],\n ])\n )\n ) as P;\n }\n\n function setup(item: UseSingleBrickConf): UseSingleBrickConf {\n const { properties, slots: originalSlots, children, ...restConf } = item;\n\n const transpiledSlots = childrenToSlots(children, originalSlots) as\n | UseBrickSlotsConf\n | undefined;\n\n const slots = Object.fromEntries(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).map(setup),\n },\n ])\n ) as UseBrickSlotsConf;\n\n return {\n ...restConf,\n properties: walk(properties),\n slots,\n ...setupTemplateProxy(hostContext, restConf.ref, slots),\n };\n }\n\n return walk(props);\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,SAASG,uBAAuBA,CACrCC,KAAQ,EACRC,WAAgC,EAC7B;EACH,SAASC,IAAIA,CAAIF,KAAQ,EAAK;IAC5B,IAAI,CAAC,IAAAG,iBAAQ,EAACH,KAAK,CAAC,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MACnD,OAAOA,KAAK;IACd;IAEA,IAAII,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,EAAE;MACxB,OAAOA,KAAK,CAACM,GAAG,CAACJ,IAAI,CAAC;IACxB;IAEA,OAAOK,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACT,KAAK,CAAC,CAClBM,GAAG,CAAC,CAAC,CAACI,GAAG,EAAEC,KAAK,CAAC,KAChB,IAAAR,iBAAQ,EAACQ,KAAK,CAAC,IAAID,GAAG,KAAK,UAAU,GACjCN,KAAK,CAACC,OAAO,CAACM,KAAK,CAAC,GAClB,CAACD,GAAG,EAAEC,KAAK,CAACL,GAAG,CAACM,KAAK,CAAC,CAAC,GACvB,CAACF,GAAG,EAAEE,KAAK,CAACD,KAA2B,CAAC,CAAC,GAC3C,CAACD,GAAG,EAAER,IAAI,CAACS,KAAK,CAAC,CACvB,CAAC,CACAE,MAAM,CACLN,MAAM,CAACO,qBAAqB,CAACd,KAAK,CAAC,CAACM,GAAG,CAAES,CAAC,IAAK,CAC7CA,CAAC,EACAf,KAAK,CAAsCe,CAAC,CAAC,CAC/C,CACH,CACJ,CAAC;EACH;EAEA,SAASH,KAAKA,CAACI,IAAwB,EAAsB;IAC3D,MAAM;MAAEC,UAAU;MAAEC,KAAK,EAAEC,aAAa;MAAEC,QAAQ;MAAE,GAAGC;IAAS,CAAC,GAAGL,IAAI;IAExE,MAAMM,eAAe,GAAG,IAAAC,yBAAe,EAACH,QAAQ,EAAED,aAAa,CAElD;IAEb,MAAMD,KAAK,GAAGX,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACE,OAAO,CAACa,eAAe,IAAI,CAAC,CAAC,CAAC,CAAChB,GAAG,CAAC,CAAC,CAACkB,QAAQ,EAAEC,QAAQ,CAAC,KAAK,CAClED,QAAQ,EACR;MACEE,IAAI,EAAE,QAAQ;MACdC,MAAM,EAAE,CAACF,QAAQ,CAACE,MAAM,IAAI,EAAE,EAAErB,GAAG,CAACM,KAAK;IAC3C,CAAC,CACF,CACH,CAAsB;IAEtB,OAAO;MACL,GAAGS,QAAQ;MACXJ,UAAU,EAAEf,IAAI,CAACe,UAAU,CAAC;MAC5BC,KAAK;MACL,GAAG,IAAAU,sCAAkB,EAAC3B,WAAW,EAAEoB,QAAQ,CAACQ,GAAG,EAAEX,KAAK;IACxD,CAAC;EACH;EAEA,OAAOhB,IAAI,CAACF,KAAK,CAAC;AACpB","ignoreList":[]}
1
+ {"version":3,"file":"setupUseBrickInTemplate.js","names":["_general","require","_setupTemplateProxy","_Renderer","_replaceSlotWithSlottedBricks","setupUseBrickInTemplate","props","hostContext","walk","isObject","Array","isArray","map","Object","fromEntries","entries","key","value","flatMap","v","setup","concat","getOwnPropertySymbols","k","item","markSlotted","brick","replaceSlotWithSlottedBricks","it","properties","slots","originalSlots","children","restConf","transpiledSlots","childrenToSlots","slotted","markChild","slotName","slotConf","type","bricks","setupTemplateProxy","ref"],"sources":["../../../../src/internal/CustomTemplates/setupUseBrickInTemplate.ts"],"sourcesContent":["import type {\n UseBrickSlotConf,\n UseBrickSlotsConf,\n UseSingleBrickConf,\n} from \"@next-core/types\";\nimport { isObject } from \"@next-core/utils/general\";\nimport type { TemplateHostContext } from \"../interfaces.js\";\nimport { setupTemplateProxy } from \"./setupTemplateProxy.js\";\nimport { childrenToSlots } from \"../Renderer.js\";\nimport { replaceSlotWithSlottedBricks } from \"./replaceSlotWithSlottedBricks.js\";\n\nexport function setupUseBrickInTemplate<T>(\n props: T,\n hostContext: TemplateHostContext\n): T {\n function walk<P>(props: P): P {\n if (!isObject(props) || typeof props === \"function\") {\n return props;\n }\n\n if (Array.isArray(props)) {\n return props.map(walk) as P;\n }\n\n return Object.fromEntries(\n Object.entries(props)\n .map(([key, value]) =>\n isObject(value) && key === \"useBrick\"\n ? Array.isArray(value)\n ? [key, value.flatMap((v) => setup(v))]\n : [key, setup(value as UseSingleBrickConf)]\n : [key, walk(value)]\n )\n .concat(\n Object.getOwnPropertySymbols(props).map((k) => [\n k,\n (props as Record<string | symbol, unknown>)[k],\n ])\n )\n ) as P;\n }\n\n function setup(\n item: UseSingleBrickConf,\n markSlotted?: () => void\n ): UseSingleBrickConf | UseSingleBrickConf[] {\n if (item.brick === \"slot\") {\n markSlotted?.();\n return replaceSlotWithSlottedBricks(item, hostContext, (it) => setup(it));\n }\n\n const { properties, slots: originalSlots, children, ...restConf } = item;\n\n const transpiledSlots = childrenToSlots(children, originalSlots) as\n | UseBrickSlotsConf\n | undefined;\n\n let slotted = false;\n const markChild = () => {\n slotted = true;\n };\n const slots = Object.fromEntries<UseBrickSlotConf>(\n Object.entries(transpiledSlots ?? {}).map(([slotName, slotConf]) => [\n slotName,\n {\n type: \"bricks\",\n bricks: (slotConf.bricks ?? []).flatMap((it) => setup(it, markChild)),\n },\n ])\n );\n\n return {\n ...restConf,\n properties: walk(properties),\n slots,\n ...setupTemplateProxy(hostContext, restConf.ref, slots, slotted),\n };\n }\n\n return walk(props);\n}\n"],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AG,CAAC;MACf,OAAO,IAAAE,0DAA4B,EAACH,IAAI,EAAEjB,WAAW,EAAGqB,EAAE,IAAKR,KAAK,CAACQ,EAAE,CAAC,CAAC;IAC3E;IAEA,MAAM;MAAEC,UAAU;MAAEC,KAAK,EAAEC,aAAa;MAAEC,QAAQ;MAAE,GAAGC;IAAS,CAAC,GAAGT,IAAI;IAExE,MAAMU,eAAe,GAAG,IAAAC,yBAAe,EAACH,QAAQ,EAAED,aAAa,CAElD;IAEb,IAAIK,OAAO,GAAG,KAAK;IACnB,MAAMC,SAAS,GAAGA,CAAA,KAAM;MACtBD,OAAO,GAAG,IAAI;IAChB,CAAC;IACD,MAAMN,KAAK,GAAGjB,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACE,OAAO,CAACmB,eAAe,IAAI,CAAC,CAAC,CAAC,CAACtB,GAAG,CAAC,CAAC,CAAC0B,QAAQ,EAAEC,QAAQ,CAAC,KAAK,CAClED,QAAQ,EACR;MACEE,IAAI,EAAE,QAAQ;MACdC,MAAM,EAAE,CAACF,QAAQ,CAACE,MAAM,IAAI,EAAE,EAAEvB,OAAO,CAAEU,EAAE,IAAKR,KAAK,CAACQ,EAAE,EAAES,SAAS,CAAC;IACtE,CAAC,CACF,CACH,CAAC;IAED,OAAO;MACL,GAAGJ,QAAQ;MACXJ,UAAU,EAAErB,IAAI,CAACqB,UAAU,CAAC;MAC5BC,KAAK;MACL,GAAG,IAAAY,sCAAkB,EAACnC,WAAW,EAAE0B,QAAQ,CAACU,GAAG,EAAEb,KAAK,EAAEM,OAAO;IACjE,CAAC;EACH;EAEA,OAAO5B,IAAI,CAACF,KAAK,CAAC;AACpB","ignoreList":[]}
@@ -726,8 +726,11 @@ function childrenToSlots(children, originalSlots) {
726
726
  }
727
727
  if (Array.isArray(children) && !newSlots) {
728
728
  newSlots = {};
729
- for (const child of children) {
730
- const slot = child.slot ?? "";
729
+ for (const {
730
+ slot: sl,
731
+ ...child
732
+ } of children) {
733
+ const slot = sl ?? "";
731
734
  if (!(0, _general.hasOwnProperty)(newSlots, slot)) {
732
735
  newSlots[slot] = {
733
736
  type: "bricks",