@jfdevelops/react-layout 1.6.1 → 2.1.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 (157) hide show
  1. package/dist/create-config/create-defined-resource-layout.cjs +26 -14
  2. package/dist/create-config/create-defined-resource-layout.cjs.map +1 -1
  3. package/dist/create-config/create-defined-resource-layout.d.cts +12 -6
  4. package/dist/create-config/create-defined-resource-layout.d.cts.map +1 -1
  5. package/dist/create-config/create-defined-resource-layout.d.mts +12 -6
  6. package/dist/create-config/create-defined-resource-layout.d.mts.map +1 -1
  7. package/dist/create-config/create-defined-resource-layout.mjs +27 -15
  8. package/dist/create-config/create-defined-resource-layout.mjs.map +1 -1
  9. package/dist/create-config/define-layout.cjs +129 -58
  10. package/dist/create-config/define-layout.cjs.map +1 -1
  11. package/dist/create-config/define-layout.d.cts +9 -13
  12. package/dist/create-config/define-layout.d.cts.map +1 -1
  13. package/dist/create-config/define-layout.d.mts +9 -13
  14. package/dist/create-config/define-layout.d.mts.map +1 -1
  15. package/dist/create-config/define-layout.mjs +130 -59
  16. package/dist/create-config/define-layout.mjs.map +1 -1
  17. package/dist/create-config/for-resources/create-component.d.cts +62 -38
  18. package/dist/create-config/for-resources/create-component.d.cts.map +1 -1
  19. package/dist/create-config/for-resources/create-component.d.mts +62 -38
  20. package/dist/create-config/for-resources/create-component.d.mts.map +1 -1
  21. package/dist/create-config/for-resources/create-for-resources.cjs +88 -12
  22. package/dist/create-config/for-resources/create-for-resources.cjs.map +1 -1
  23. package/dist/create-config/for-resources/create-for-resources.mjs +88 -12
  24. package/dist/create-config/for-resources/create-for-resources.mjs.map +1 -1
  25. package/dist/create-config/for-resources/scoped-layout.d.cts +2 -2
  26. package/dist/create-config/for-resources/scoped-layout.d.cts.map +1 -1
  27. package/dist/create-config/for-resources/scoped-layout.d.mts +2 -2
  28. package/dist/create-config/for-resources/scoped-layout.d.mts.map +1 -1
  29. package/dist/create-config/for-resources/scoped-render.cjs +39 -4
  30. package/dist/create-config/for-resources/scoped-render.cjs.map +1 -1
  31. package/dist/create-config/for-resources/scoped-render.d.cts +8 -1
  32. package/dist/create-config/for-resources/scoped-render.d.cts.map +1 -1
  33. package/dist/create-config/for-resources/scoped-render.d.mts +8 -1
  34. package/dist/create-config/for-resources/scoped-render.d.mts.map +1 -1
  35. package/dist/create-config/for-resources/scoped-render.mjs +39 -4
  36. package/dist/create-config/for-resources/scoped-render.mjs.map +1 -1
  37. package/dist/create-config/index.d.cts +3 -2
  38. package/dist/create-config/index.d.mts +3 -2
  39. package/dist/create-config/layout-name.cjs +1 -1
  40. package/dist/create-config/layout-name.mjs +1 -1
  41. package/dist/create-config/lazy-resource-layout.cjs +70 -86
  42. package/dist/create-config/lazy-resource-layout.cjs.map +1 -1
  43. package/dist/create-config/lazy-resource-layout.d.cts +9 -31
  44. package/dist/create-config/lazy-resource-layout.d.cts.map +1 -1
  45. package/dist/create-config/lazy-resource-layout.d.mts +9 -31
  46. package/dist/create-config/lazy-resource-layout.d.mts.map +1 -1
  47. package/dist/create-config/lazy-resource-layout.mjs +70 -86
  48. package/dist/create-config/lazy-resource-layout.mjs.map +1 -1
  49. package/dist/create-config/preview.cjs +1 -1
  50. package/dist/create-config/preview.d.cts +2 -0
  51. package/dist/create-config/preview.d.cts.map +1 -1
  52. package/dist/create-config/preview.d.mts +2 -0
  53. package/dist/create-config/preview.d.mts.map +1 -1
  54. package/dist/create-config/preview.mjs +1 -1
  55. package/dist/create-config/render-state-context.cjs +24 -0
  56. package/dist/create-config/render-state-context.cjs.map +1 -0
  57. package/dist/create-config/render-state-context.mjs +22 -0
  58. package/dist/create-config/render-state-context.mjs.map +1 -0
  59. package/dist/create-config/render-state.cjs +58 -18
  60. package/dist/create-config/render-state.cjs.map +1 -1
  61. package/dist/create-config/render-state.d.cts +44 -21
  62. package/dist/create-config/render-state.d.cts.map +1 -1
  63. package/dist/create-config/render-state.d.mts +44 -21
  64. package/dist/create-config/render-state.d.mts.map +1 -1
  65. package/dist/create-config/render-state.mjs +55 -18
  66. package/dist/create-config/render-state.mjs.map +1 -1
  67. package/dist/create-config/state-composable.cjs +4 -2
  68. package/dist/create-config/state-composable.cjs.map +1 -1
  69. package/dist/create-config/state-composable.d.cts.map +1 -1
  70. package/dist/create-config/state-composable.d.mts.map +1 -1
  71. package/dist/create-config/state-composable.mjs +4 -2
  72. package/dist/create-config/state-composable.mjs.map +1 -1
  73. package/dist/errors/lazy-resource-error.cjs +37 -0
  74. package/dist/errors/lazy-resource-error.cjs.map +1 -0
  75. package/dist/errors/lazy-resource-error.d.cts +26 -0
  76. package/dist/errors/lazy-resource-error.d.cts.map +1 -0
  77. package/dist/errors/lazy-resource-error.d.mts +26 -0
  78. package/dist/errors/lazy-resource-error.d.mts.map +1 -0
  79. package/dist/errors/lazy-resource-error.mjs +35 -0
  80. package/dist/errors/lazy-resource-error.mjs.map +1 -0
  81. package/dist/errors/react-layout-error.cjs +1 -1
  82. package/dist/errors/react-layout-error.mjs +1 -1
  83. package/dist/errors/resource-state-error.cjs +4 -1
  84. package/dist/errors/resource-state-error.cjs.map +1 -1
  85. package/dist/errors/resource-state-error.d.cts +1 -0
  86. package/dist/errors/resource-state-error.d.cts.map +1 -1
  87. package/dist/errors/resource-state-error.d.mts +1 -0
  88. package/dist/errors/resource-state-error.d.mts.map +1 -1
  89. package/dist/errors/resource-state-error.mjs +4 -1
  90. package/dist/errors/resource-state-error.mjs.map +1 -1
  91. package/dist/index.cjs +6 -2
  92. package/dist/index.d.cts +9 -5
  93. package/dist/index.d.mts +9 -5
  94. package/dist/index.mjs +4 -3
  95. package/dist/lazy/create-lazy-loader.cjs +78 -0
  96. package/dist/lazy/create-lazy-loader.cjs.map +1 -0
  97. package/dist/lazy/create-lazy-loader.d.cts +19 -0
  98. package/dist/lazy/create-lazy-loader.d.cts.map +1 -0
  99. package/dist/lazy/create-lazy-loader.d.mts +19 -0
  100. package/dist/lazy/create-lazy-loader.d.mts.map +1 -0
  101. package/dist/lazy/create-lazy-loader.mjs +78 -0
  102. package/dist/lazy/create-lazy-loader.mjs.map +1 -0
  103. package/dist/lazy/create-render-state.cjs +59 -0
  104. package/dist/lazy/create-render-state.cjs.map +1 -0
  105. package/dist/lazy/create-render-state.d.cts +33 -0
  106. package/dist/lazy/create-render-state.d.cts.map +1 -0
  107. package/dist/lazy/create-render-state.d.mts +33 -0
  108. package/dist/lazy/create-render-state.d.mts.map +1 -0
  109. package/dist/lazy/create-render-state.mjs +59 -0
  110. package/dist/lazy/create-render-state.mjs.map +1 -0
  111. package/dist/lazy/fallback-props.cjs +9 -0
  112. package/dist/lazy/fallback-props.cjs.map +1 -0
  113. package/dist/lazy/fallback-props.mjs +9 -0
  114. package/dist/lazy/fallback-props.mjs.map +1 -0
  115. package/dist/lazy/inspection.cjs +51 -0
  116. package/dist/lazy/inspection.cjs.map +1 -0
  117. package/dist/lazy/inspection.d.cts +28 -0
  118. package/dist/lazy/inspection.d.cts.map +1 -0
  119. package/dist/lazy/inspection.d.mts +28 -0
  120. package/dist/lazy/inspection.d.mts.map +1 -0
  121. package/dist/lazy/inspection.mjs +50 -0
  122. package/dist/lazy/inspection.mjs.map +1 -0
  123. package/dist/lazy/lazy-boundary.cjs +63 -0
  124. package/dist/lazy/lazy-boundary.cjs.map +1 -0
  125. package/dist/lazy/lazy-boundary.mjs +63 -0
  126. package/dist/lazy/lazy-boundary.mjs.map +1 -0
  127. package/dist/lazy/scoped-content.cjs +87 -0
  128. package/dist/lazy/scoped-content.cjs.map +1 -0
  129. package/dist/lazy/scoped-content.d.cts +19 -0
  130. package/dist/lazy/scoped-content.d.cts.map +1 -0
  131. package/dist/lazy/scoped-content.d.mts +19 -0
  132. package/dist/lazy/scoped-content.d.mts.map +1 -0
  133. package/dist/lazy/scoped-content.mjs +86 -0
  134. package/dist/lazy/scoped-content.mjs.map +1 -0
  135. package/dist/lazy/types.cjs +10 -0
  136. package/dist/lazy/types.cjs.map +1 -0
  137. package/dist/lazy/types.d.cts +40 -0
  138. package/dist/lazy/types.d.cts.map +1 -0
  139. package/dist/lazy/types.d.mts +40 -0
  140. package/dist/lazy/types.d.mts.map +1 -0
  141. package/dist/lazy/types.mjs +8 -0
  142. package/dist/lazy/types.mjs.map +1 -0
  143. package/dist/props.cjs +4 -2
  144. package/dist/props.cjs.map +1 -1
  145. package/dist/props.d.cts +6 -50
  146. package/dist/props.d.cts.map +1 -1
  147. package/dist/props.d.mts +6 -50
  148. package/dist/props.d.mts.map +1 -1
  149. package/dist/props.mjs +5 -2
  150. package/dist/props.mjs.map +1 -1
  151. package/dist/resource.cjs.map +1 -1
  152. package/dist/resource.d.cts +1 -1
  153. package/dist/resource.d.cts.map +1 -1
  154. package/dist/resource.d.mts +1 -1
  155. package/dist/resource.d.mts.map +1 -1
  156. package/dist/resource.mjs.map +1 -1
  157. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"create-for-resources.cjs","names":["capitalize","LayoutConfigurationError","reservedScopedComponentNames","isRenderableComponentType","resolveScopedRenderResult","withScopedCompoundStatics"],"sources":["../../../src/create-config/for-resources/create-for-resources.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n type ComponentType,\n type JSX,\n useContext,\n} from 'react';\nimport type { ComposableComponents } from '@jfdevelops/react-layout-composables';\nimport {\n type AnyBuiltPropDefinition,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport type { InPropsDefinition, InPropsObject } from '../../props';\nimport type { LayoutResourceKey, ResourceDefinition } from '../../resource';\nimport { capitalize } from '../../utils/capitalize';\nimport { LayoutConfigurationError } from '../../errors';\nimport type { LayoutIncludeProps } from '../define-layout';\nimport type {\n CapitalizedResource,\n ResourcesLayoutName,\n} from './resource-selection';\nimport type { CreateResourceLayoutForResourcesFn } from './scoped-layout';\nimport {\n isRenderableComponentType,\n reservedScopedComponentNames,\n resolveScopedRenderResult,\n type ScopedRenderResult,\n withScopedCompoundStatics,\n} from './scoped-render';\n\ntype CreateForResourcesOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n> = {\n createLayoutForResource: (\n defaultName: string | undefined,\n resource: LayoutResourceKey<Resources>,\n ) => unknown;\n createMakeComposableLayout?: () => (\n options: Record<string, unknown>,\n ) => unknown;\n createResourceLayout: (options: Record<string, unknown>) => unknown;\n getComponentPropDefinitions: (\n resource: LayoutResourceKey<Resources>,\n ) => Record<string, AnyBuiltPropDefinition>;\n};\n\nexport function createForResources<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends InPropsObject,\n>({\n createLayoutForResource,\n createMakeComposableLayout,\n createResourceLayout,\n getComponentPropDefinitions,\n}: CreateForResourcesOptions<Resources>) {\n return ((...resourcesOrOptions: Array<unknown>) => {\n const firstArgument = resourcesOrOptions[0];\n let resourceOptions: Array<{\n resource: LayoutResourceKey<Resources>;\n name?:\n | string\n | ((\n resource: CapitalizedResource<LayoutResourceKey<Resources>>,\n ) => string);\n }>;\n\n if (typeof firstArgument === 'string') {\n resourceOptions = resourcesOrOptions.map((resource) => ({\n resource: resource as LayoutResourceKey<Resources>,\n }));\n } else if (\n firstArgument !== null &&\n typeof firstArgument === 'object' &&\n 'resources' in firstArgument &&\n Array.isArray(firstArgument.resources)\n ) {\n const { name, resources } = firstArgument as {\n name?: ResourcesLayoutName<LayoutResourceKey<Resources>>;\n resources: Array<LayoutResourceKey<Resources>>;\n };\n resourceOptions = resources.map((resource) => ({\n name: typeof name === 'function' ? name : name?.[resource],\n resource,\n }));\n } else {\n resourceOptions = Object.entries(firstArgument ?? {}).map(\n ([resource, options]) => ({\n ...(options as {\n name?:\n | string\n | ((\n resource: CapitalizedResource<LayoutResourceKey<Resources>>,\n ) => string);\n }),\n resource: resource as LayoutResourceKey<Resources>,\n }),\n );\n }\n\n const defaultNames = new Map(\n resourceOptions.map(({ name, resource }) => [\n resource,\n typeof name === 'function'\n ? name(\n capitalize(resource) as CapitalizedResource<\n LayoutResourceKey<Resources>\n >,\n )\n : name,\n ]),\n );\n\n function scopedCreateResourceLayout(options: Record<string, unknown>) {\n const resource = options.resource as LayoutResourceKey<Resources>;\n\n return createResourceLayout({\n ...options,\n name: options.name ?? defaultNames.get(resource),\n });\n }\n\n function scopedForResource(options: {\n name?: string;\n resource: LayoutResourceKey<Resources>;\n }) {\n return createLayoutForResource(\n options.name ?? defaultNames.get(options.resource),\n options.resource,\n );\n }\n\n type ScopedComponentRenderFn = (\n props: Record<string, unknown>,\n components: Record<string, (props?: never) => JSX.Element>,\n ) => ScopedRenderResult;\n\n type ScopedResourceScopedComponentDefinition = {\n props?: Record<string, AnyBuiltPropDefinition>;\n render: ScopedComponentRenderFn;\n };\n\n type ScopedComponentEntry = {\n [option: string]: unknown;\n name?: string;\n props?: CreateComponentPropsBag;\n components?: Record<string, ScopedResourceScopedComponentDefinition>;\n render: ScopedComponentRenderFn;\n };\n\n type CreateComponentPropsBag = {\n include?: Record<string, true | 'optional'>;\n custom?: Record<string, AnyBuiltPropDefinition>;\n defined?: Record<string, unknown>;\n };\n\n function mergeCreateComponentProps(\n ...bags: Array<CreateComponentPropsBag | undefined>\n ): CreateComponentPropsBag {\n const include: Record<string, true | 'optional'> = {};\n const custom: Record<string, AnyBuiltPropDefinition> = {};\n\n for (const bag of bags) {\n Object.assign(include, bag?.include);\n Object.assign(custom, bag?.custom);\n\n for (const key of Object.keys(bag?.defined ?? {})) {\n include[key] = true;\n }\n }\n\n return { include, custom };\n }\n\n function createComponent(componentOptions: {\n props?: {\n include?: Record<string, true | 'optional'>;\n custom?: Record<string, AnyBuiltPropDefinition>;\n };\n resources?: Record<string, ScopedComponentEntry>;\n render: (\n props: Record<string, unknown>,\n context: Record<string, (props: never) => JSX.Element>,\n ) => ScopedRenderResult;\n }) {\n const mergedProps = mergeCreateComponentProps(\n componentOptions.props,\n ...Object.values(componentOptions.resources ?? {}).map(\n (entry) => entry.props,\n ),\n );\n const include = mergedProps.include ?? {};\n const custom = mergedProps.custom ?? {};\n const selectedResources = new Set(\n resourceOptions.map(({ resource }) => resource),\n );\n const componentPropsContext = createContext<\n Record<string, unknown> | undefined\n >(undefined);\n const definedEntries = new Map<\n LayoutResourceKey<Resources>,\n ScopedComponentEntry\n >();\n\n for (const [key, entry] of Object.entries(\n componentOptions.resources ?? {},\n )) {\n const resource = key as LayoutResourceKey<Resources>;\n\n if (!selectedResources.has(resource)) {\n throw new LayoutConfigurationError(\n `Resource \"${key}\" is not available in this scoped component`,\n );\n }\n\n definedEntries.set(resource, entry);\n }\n\n /** Resolved scoped components, per resource. */\n const resourceScopedComponents = new Map<\n LayoutResourceKey<Resources>,\n Record<string, (props?: never) => JSX.Element>\n >();\n const contextResources = new Map<string, LayoutResourceKey<Resources>>();\n const renderContext: Record<string, (props: never) => JSX.Element> =\n Object.fromEntries(\n [...definedEntries].map(([resource, entry]) => {\n const contextKey = capitalize(resource);\n\n if (contextKey === 'Root') {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" maps to the reserved render context key \"Root\"`,\n );\n }\n\n const existingResource = contextResources.get(contextKey);\n\n if (existingResource !== undefined) {\n throw new LayoutConfigurationError(\n `Resources \"${existingResource}\" and \"${resource}\" both map to render context key \"${contextKey}\"`,\n );\n }\n\n contextResources.set(contextKey, resource);\n\n /**\n * Built once per resource so every scoped component keeps a stable\n * identity, and shared by the resource render, the render context,\n * and any component bound through `asHOF()`.\n */\n const scopedComponents: Record<\n string,\n (props?: never) => JSX.Element\n > = {};\n\n for (const [name, definition] of Object.entries(\n entry.components ?? {},\n )) {\n if (reservedScopedComponentNames.has(name)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" for resource \"${resource}\" uses a reserved name`,\n );\n }\n\n const ownPropDefinitions = definition.props ?? {};\n // Last call-site own-props / returned component for this scoped\n // entry. Compound statics re-run `render` with these so\n // `<DataTable variant=\"b\" />` then `<DataTable.Loading />` sees \"b\".\n let cachedOwnProps: Record<string, unknown> = {};\n let cachedReturnedComponent:\n | ComponentType<Record<string, unknown>>\n | undefined;\n\n function ScopedComponent(ownProps?: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" must be rendered inside its scoped component`,\n );\n }\n\n const resolvedOwnProps = ownProps ?? {};\n cachedOwnProps = resolvedOwnProps;\n\n validateProps(ownPropDefinitions, resolvedOwnProps, {\n layoutName:\n entry.name ??\n defaultNames.get(resource) ??\n capitalize(resource),\n resource,\n });\n\n // Mount a returned component type with call-site props; pass\n // nodes (elements, portals, null) through unchanged.\n const result = definition.render(\n { ...componentProps, ...resolvedOwnProps, resource },\n scopedComponents,\n );\n\n if (isRenderableComponentType(result)) {\n cachedReturnedComponent = result as ComponentType<\n Record<string, unknown>\n >;\n }\n\n return resolveScopedRenderResult(result, resolvedOwnProps);\n }\n\n // Types expose compound statics from the returned component\n // (`DataTable.Loading`); attach matching runtime wrappers.\n scopedComponents[name] = withScopedCompoundStatics(\n ScopedComponent,\n (staticName) => {\n function CompoundStatic(ownProps?: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}.${staticName}\" must be rendered inside its scoped component`,\n );\n }\n\n // Prefer the component from the last parent call (same\n // closure as that call's own-props). Fall back to re-running\n // render with cached parent props when needed.\n let result: unknown = cachedReturnedComponent;\n\n if (!isRenderableComponentType(result)) {\n result = definition.render(\n {\n ...componentProps,\n ...cachedOwnProps,\n resource,\n },\n scopedComponents,\n );\n }\n\n if (!isRenderableComponentType(result)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" must return a component type to use static \"${staticName}\"`,\n );\n }\n\n const staticComponent = (\n result as ComponentType<Record<string, unknown>> &\n Record<string, unknown>\n )[staticName];\n\n if (!isRenderableComponentType(staticComponent)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" has no component static \"${staticName}\"`,\n );\n }\n\n // Loading's props — those mount the static itself.\n return createElement(staticComponent, ownProps ?? {});\n }\n\n CompoundStatic.displayName = `${name}.${staticName}`;\n return CompoundStatic;\n },\n ) as (props?: never) => JSX.Element;\n }\n\n resourceScopedComponents.set(resource, scopedComponents);\n\n function ResourceRender(ownProps?: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Render context component \"${contextKey}\" must be rendered inside its scoped component`,\n );\n }\n\n // Call-site props on `context.Users({ title, heading })` merge into\n // the resource render props and mount a returned component type.\n const callProps = { ...componentProps, ...ownProps, resource };\n return resolveScopedRenderResult(\n entry.render(callProps, scopedComponents),\n ownProps,\n );\n }\n\n return [\n contextKey,\n Object.assign(ResourceRender, scopedComponents),\n ];\n }),\n );\n\n /**\n * Layouts are created once per resource and cached. Creating one during\n * render would hand React a new component type on every pass, remounting\n * the whole subtree.\n */\n const roots = new Map<\n LayoutResourceKey<Resources>,\n (props: Record<string, unknown>) => JSX.Element\n >();\n\n function Root(rootProps: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n 'Render context component \"Root\" must be rendered inside its scoped component',\n );\n }\n\n const resource =\n componentProps.resource as LayoutResourceKey<Resources>;\n let root = roots.get(resource);\n\n if (root === undefined) {\n const entry = definedEntries.get(resource);\n\n if (entry === undefined) {\n throw new LayoutConfigurationError(\n `Render context component \"Root\" requires a \"resources.${resource}\" entry to build the layout for resource \"${resource}\"`,\n );\n }\n\n // Layout option values come from the outer component call site\n // (`<Directory title=\"…\" />`), not from the resource entry.\n const availableDefinitions =\n getComponentPropDefinitions(resource);\n const layoutOptions: Record<string, unknown> = {};\n const defined = entry.props?.defined ?? {};\n\n for (const key of Object.keys(availableDefinitions)) {\n if (key in defined) {\n layoutOptions[key] = defined[key];\n }\n\n const capitalized = capitalize(key);\n if (capitalized in defined) {\n layoutOptions[capitalized] = defined[capitalized];\n }\n\n if (key in componentProps) {\n layoutOptions[key] = componentProps[key];\n }\n\n if (capitalized in componentProps) {\n layoutOptions[capitalized] = componentProps[capitalized];\n }\n }\n\n root = scopedCreateResourceLayout({\n ...layoutOptions,\n namespace: false,\n name:\n entry.name ??\n defaultNames.get(resource) ??\n capitalize(resource),\n resource,\n }) as (props: Record<string, unknown>) => JSX.Element;\n roots.set(resource, root);\n }\n\n const entry = definedEntries.get(resource);\n const definedCustom: Record<string, unknown> = {};\n const forwardedRootProps: Record<string, unknown> = {};\n\n for (const key of Object.keys(getComponentPropDefinitions(resource))) {\n if (key in componentProps) {\n forwardedRootProps[key] = componentProps[key];\n }\n\n const capitalized = capitalize(key);\n if (capitalized in componentProps) {\n forwardedRootProps[capitalized] = componentProps[capitalized];\n }\n }\n\n for (const [key, value] of Object.entries(\n entry?.props?.defined ?? {},\n )) {\n if (key in custom) {\n definedCustom[key] = value;\n }\n }\n\n return createElement(root, {\n ...forwardedRootProps,\n ...definedCustom,\n ...rootProps,\n });\n }\n\n renderContext.Root = Root;\n\n function Component(componentProps: Record<string, unknown>) {\n const componentResource =\n componentProps.resource as LayoutResourceKey<Resources>;\n\n if (!selectedResources.has(componentResource)) {\n throw new LayoutConfigurationError(\n `Resource \"${componentResource}\" is not available in this scoped component`,\n );\n }\n\n const defined =\n definedEntries.get(componentResource)?.props?.defined ?? {};\n const resolvedComponentProps = { ...defined, ...componentProps };\n const availableDefinitions =\n getComponentPropDefinitions(componentResource);\n const definitionsToValidate: Record<string, AnyBuiltPropDefinition> =\n {};\n\n for (const [key, inclusion] of Object.entries(include)) {\n const definition = availableDefinitions[key];\n\n if (!definition) {\n continue;\n }\n\n // Keep declared keys as-is — do not capitalize JSX.Element props.\n if (inclusion === true || key in resolvedComponentProps) {\n definitionsToValidate[key] = definition;\n }\n }\n\n for (const [key, definition] of Object.entries(custom)) {\n if (key === 'children' || key === 'resource') {\n continue;\n }\n\n definitionsToValidate[key] = definition;\n }\n\n validateProps(definitionsToValidate, resolvedComponentProps, {\n layoutName:\n definedEntries.get(componentResource)?.name ??\n defaultNames.get(componentResource) ??\n capitalize(componentResource),\n resource: componentResource,\n });\n\n // Top-level render may return a component type; mount it with the full\n // component props (include/custom + inferred return-type props).\n return createElement(\n componentPropsContext.Provider,\n { value: resolvedComponentProps },\n resolveScopedRenderResult(\n componentOptions.render(resolvedComponentProps, renderContext),\n resolvedComponentProps,\n ),\n );\n }\n\n /**\n * Bound components are created once per resource and cached. Returning a\n * fresh component from the factory would hand React a new component type\n * whenever the caller rebinds, remounting the subtree.\n */\n const boundComponents = new Map<\n LayoutResourceKey<Resources>,\n (props: Record<string, unknown>) => JSX.Element\n >();\n\n function bindResource(resource: LayoutResourceKey<Resources>) {\n if (!selectedResources.has(resource)) {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" is not available in this scoped component`,\n );\n }\n\n let boundComponent = boundComponents.get(resource);\n\n if (boundComponent === undefined) {\n boundComponent = Object.assign(\n (boundProps: Record<string, unknown>) =>\n createElement(Component, { ...boundProps, resource }),\n {\n displayName: `ScopedResourceComponent(${resource})`,\n props: undefined,\n resource: undefined,\n },\n resourceScopedComponents.get(resource) ?? {},\n );\n boundComponents.set(resource, boundComponent);\n }\n\n return boundComponent;\n }\n\n function asHOF() {\n return bindResource;\n }\n\n return Object.assign(Component, {\n asHOF,\n displayName: 'ScopedResourceComponent',\n props: undefined,\n });\n }\n\n function createComponentSetProps(baseProps: CreateComponentPropsBag) {\n function createWithProps(componentOptions: {\n props?: CreateComponentPropsBag;\n resources?: Record<string, ScopedComponentEntry>;\n render: (\n props: Record<string, unknown>,\n context: Record<string, (props: never) => JSX.Element>,\n ) => ScopedRenderResult;\n }) {\n return createComponent({\n ...componentOptions,\n props: mergeCreateComponentProps(baseProps, componentOptions.props),\n });\n }\n\n createWithProps.createResourceComponents = createResourceComponents;\n\n return createWithProps;\n }\n\n function createResourceComponents(options: {\n resource: LayoutResourceKey<Resources>;\n props?: CreateComponentPropsBag;\n name?: string;\n components?: Record<string, ScopedResourceScopedComponentDefinition>;\n render: ScopedComponentRenderFn;\n }) {\n const { resource, props, ...entry } = options;\n\n if (\n !resourceOptions.some(\n (resourceOption) => resourceOption.resource === resource,\n )\n ) {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" is not available in this scoped component`,\n );\n }\n\n return { ...entry, props: props ?? {} };\n }\n\n Object.assign(createComponent, {\n setProps: createComponentSetProps,\n });\n\n const scopedExtras: {\n createComponent: typeof createComponent;\n createResourceComponents: typeof createResourceComponents;\n forResource: typeof scopedForResource;\n makeComposable?: (options: Record<string, unknown>) => unknown;\n resources: undefined;\n } = {\n createComponent,\n createResourceComponents,\n forResource: scopedForResource,\n resources: undefined,\n };\n\n if (createMakeComposableLayout) {\n const makeComposableLayout = createMakeComposableLayout();\n\n scopedExtras.makeComposable = (options) => {\n const resource = options.resource as LayoutResourceKey<Resources>;\n\n return makeComposableLayout({\n ...options,\n name: options.name ?? defaultNames.get(resource),\n });\n };\n }\n\n return Object.assign(scopedCreateResourceLayout, scopedExtras);\n }) as unknown as CreateResourceLayoutForResourcesFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps\n >;\n}\n"],"mappings":";;;;;;;AA8CA,SAAgB,mBAMd,EACA,yBACA,4BACA,sBACA,+BACuC;CACvC,SAAS,GAAG,uBAAuC;EACjD,MAAM,gBAAgB,mBAAmB;EACzC,IAAI;EASJ,IAAI,OAAO,kBAAkB,UAC3B,kBAAkB,mBAAmB,KAAK,cAAc,EAC5C,SACZ,EAAE;OACG,IACL,kBAAkB,QAClB,OAAO,kBAAkB,YACzB,eAAe,iBACf,MAAM,QAAQ,cAAc,SAAS,GACrC;GACA,MAAM,EAAE,MAAM,cAAc;GAI5B,kBAAkB,UAAU,KAAK,cAAc;IAC7C,MAAM,OAAO,SAAS,aAAa,OAAO,OAAO;IACjD;GACF,EAAE;EACJ,OACE,kBAAkB,OAAO,QAAQ,iBAAiB,CAAC,CAAC,EAAE,KACnD,CAAC,UAAU,cAAc;GACxB,GA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ACA,aAAa;IACb,OAAO;GACT,CAAC;EACH;EAEA,SAAS,wBAAwB,WAAoC;GACnE,SAAS,gBAAgB,kBAOtB;IACD,OAAO,gBAAgB;KACrB,GAAG;KACH,OAAO,0BAA0B,WAAW,iBAAiB,KAAK;IACpE,CAAC;GACH;GAEA,gBAAgB,2BAA2B;GAE3C,OAAO;EACT;EAEA,SAAS,yBAAyB,SAM/B;GACD,MAAM,EAAE,UAAU,OAAO,GAAG,UAAU;GAEtC,IACE,CAAC,gBAAgB,MACd,mBAAmB,eAAe,aAAa,QAClD,GAEA,MAAM,IAAIA,4DACR,aAAa,SAAS,4CACxB;GAGF,OAAO;IAAE,GAAG;IAAO,OAAO,SAAS,CAAC;GAAE;EACxC;EAEA,OAAO,OAAO,iBAAiB,EAC7B,UAAU,wBACZ,CAAC;EAED,MAAM,eAMF;GACF;GACA;GACA,aAAa;GACb,WAAW;EACb;EAEA,IAAI,4BAA4B;GAC9B,MAAM,uBAAuB,2BAA2B;GAExD,aAAa,kBAAkB,YAAY;IACzC,MAAM,WAAW,QAAQ;IAEzB,OAAO,qBAAqB;KAC1B,GAAG;KACH,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ;IACjD,CAAC;GACH;EACF;EAEA,OAAO,OAAO,OAAO,4BAA4B,YAAY;CAC/D;AAOF"}
1
+ {"version":3,"file":"create-for-resources.cjs","names":["capitalize","LayoutConfigurationError","scopedLazySymbol","createScopedLazyContent","withLazyHandle","reservedScopedComponentNames","RenderStateNameContext","isRenderableComponentType","resolveScopedRenderResult","withScopedCompoundStatics"],"sources":["../../../src/create-config/for-resources/create-for-resources.ts"],"sourcesContent":["import { RenderStateNameContext } from '../render-state-context';\nimport {\n createScopedLazyContent,\n scopedLazySymbol,\n type LazyEnvironment,\n type ScopedLazyContent,\n} from '../../lazy/scoped-content';\nimport { withLazyHandle } from '../../lazy/inspection';\nimport type { LazyHandle } from '../../lazy/types';\nimport {\n createContext,\n createElement,\n type ComponentType,\n type JSX,\n useContext,\n} from 'react';\nimport type { ComposableComponents } from '@jfdevelops/react-layout-composables';\nimport {\n type AnyBuiltPropDefinition,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport type { InPropsDefinition, InPropsObject } from '../../props';\nimport type { LayoutResourceKey, ResourceDefinition } from '../../resource';\nimport { capitalize } from '../../utils/capitalize';\nimport { LayoutConfigurationError } from '../../errors';\nimport type { LayoutIncludeProps } from '../define-layout';\nimport type {\n CapitalizedResource,\n ResourcesLayoutName,\n} from './resource-selection';\nimport type { CreateResourceLayoutForResourcesFn } from './scoped-layout';\nimport {\n isRenderableComponentType,\n reservedScopedComponentNames,\n resolveScopedRenderResult,\n type ScopedRenderResult,\n withScopedCompoundStatics,\n} from './scoped-render';\n\ntype CreateForResourcesOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n> = {\n lazyEnvironment?: LazyEnvironment;\n createLayoutForResource: (\n defaultName: string | undefined,\n resource: LayoutResourceKey<Resources>,\n ) => unknown;\n createMakeComposableLayout?: () => (\n options: Record<string, unknown>,\n ) => unknown;\n createResourceLayout: (options: Record<string, unknown>) => unknown;\n getComponentPropDefinitions: (\n resource: LayoutResourceKey<Resources>,\n ) => Record<string, AnyBuiltPropDefinition>;\n};\n\nexport function createForResources<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends InPropsObject,\n>({\n createLayoutForResource,\n createMakeComposableLayout,\n createResourceLayout,\n getComponentPropDefinitions,\n lazyEnvironment,\n}: CreateForResourcesOptions<Resources>) {\n return ((...resourcesOrOptions: Array<unknown>) => {\n const firstArgument = resourcesOrOptions[0];\n let resourceOptions: Array<{\n resource: LayoutResourceKey<Resources>;\n name?:\n | string\n | ((\n resource: CapitalizedResource<LayoutResourceKey<Resources>>,\n ) => string);\n }>;\n\n if (typeof firstArgument === 'string') {\n resourceOptions = resourcesOrOptions.map((resource) => ({\n resource: resource as LayoutResourceKey<Resources>,\n }));\n } else if (\n firstArgument !== null &&\n typeof firstArgument === 'object' &&\n 'resources' in firstArgument &&\n Array.isArray(firstArgument.resources)\n ) {\n const { name, resources } = firstArgument as {\n name?: ResourcesLayoutName<LayoutResourceKey<Resources>>;\n resources: Array<LayoutResourceKey<Resources>>;\n };\n resourceOptions = resources.map((resource) => ({\n name: typeof name === 'function' ? name : name?.[resource],\n resource,\n }));\n } else {\n resourceOptions = Object.entries(firstArgument ?? {}).map(\n ([resource, options]) => ({\n ...(options as {\n name?:\n | string\n | ((\n resource: CapitalizedResource<LayoutResourceKey<Resources>>,\n ) => string);\n }),\n resource: resource as LayoutResourceKey<Resources>,\n }),\n );\n }\n\n const defaultNames = new Map(\n resourceOptions.map(({ name, resource }) => [\n resource,\n typeof name === 'function'\n ? name(\n capitalize(resource) as CapitalizedResource<\n LayoutResourceKey<Resources>\n >,\n )\n : name,\n ]),\n );\n\n function scopedCreateResourceLayout(options: Record<string, unknown>) {\n const resource = options.resource as LayoutResourceKey<Resources>;\n\n return createResourceLayout({\n ...options,\n name: options.name ?? defaultNames.get(resource),\n });\n }\n\n function scopedForResource(options: {\n name?: string;\n resource: LayoutResourceKey<Resources>;\n }) {\n return createLayoutForResource(\n options.name ?? defaultNames.get(options.resource),\n options.resource,\n );\n }\n\n type ScopedComponentRenderFn = (\n props: Record<string, unknown>,\n components: Record<string, (props?: never) => JSX.Element>,\n ) => ScopedRenderResult;\n\n type ScopedResourceScopedComponentDefinition = {\n props?: Record<string, AnyBuiltPropDefinition>;\n [scopedLazySymbol]?: LazyHandle;\n } & ScopedLazyContent<ScopedComponentRenderFn>;\n\n type ScopedComponentEntry = {\n [option: string]: unknown;\n name?: string;\n props?: CreateComponentPropsBag;\n components?: Record<string, ScopedResourceScopedComponentDefinition>;\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n };\n\n type CreateComponentPropsBag = {\n include?: Record<string, true | 'optional'>;\n custom?: Record<string, AnyBuiltPropDefinition>;\n defined?: Record<string, unknown>;\n };\n\n function normalizeContent<\n T extends {\n render?: ScopedComponentRenderFn;\n lazy?: unknown;\n fallback?: React.ReactNode;\n [scopedLazySymbol]?: LazyHandle;\n },\n >(\n definition: T,\n resource: string,\n label: string,\n ): T & {\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n } {\n if (definition.lazy !== undefined && definition.render !== undefined)\n throw new LayoutConfigurationError(\n `Scoped content \"${label}\" must define render or lazy, never both`,\n );\n if (definition[scopedLazySymbol])\n return definition as T & {\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n };\n if (definition.lazy === undefined) {\n if (typeof definition.render !== 'function')\n throw new LayoutConfigurationError(\n `Scoped content \"${label}\" requires render or lazy`,\n );\n return definition as T & {\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n };\n }\n const Content = createScopedLazyContent(\n definition as Parameters<typeof createScopedLazyContent>[0],\n resource,\n label,\n lazyEnvironment,\n );\n const result = {\n ...definition,\n lazy: undefined,\n render: (\n callProps: Record<string, unknown>,\n context: Record<string, (props?: never) => JSX.Element>,\n ) => createElement(Content, { callProps, context }),\n [scopedLazySymbol]: Content,\n };\n return withLazyHandle(result, Content) as T & {\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n };\n }\n\n function aggregateHandle(handles: LazyHandle[]): LazyHandle {\n let imports: Promise<void>[] = [];\n let pending: Promise<void> | undefined;\n return {\n preload() {\n const next = handles.map((handle) => handle.preload());\n if (\n !pending ||\n next.some((promise, index) => promise !== imports[index])\n ) {\n imports = next;\n pending = Promise.all(next).then(() => undefined);\n }\n return pending;\n },\n get status() {\n if (handles.some((handle) => handle.status === 'error'))\n return 'error';\n if (handles.some((handle) => handle.status === 'loading'))\n return 'loading';\n if (handles.some((handle) => handle.status === 'unresolved'))\n return 'unresolved';\n return 'resolved';\n },\n };\n }\n\n function mergeCreateComponentProps(\n ...bags: Array<CreateComponentPropsBag | undefined>\n ): CreateComponentPropsBag {\n const include: Record<string, true | 'optional'> = {};\n const custom: Record<string, AnyBuiltPropDefinition> = {};\n\n for (const bag of bags) {\n Object.assign(include, bag?.include);\n Object.assign(custom, bag?.custom);\n\n for (const key of Object.keys(bag?.defined ?? {})) {\n include[key] = true;\n }\n }\n\n return { include, custom };\n }\n\n function createComponent(componentOptions: {\n props?: {\n include?: Record<string, true | 'optional'>;\n custom?: Record<string, AnyBuiltPropDefinition>;\n };\n resources?: Record<string, ScopedComponentEntry>;\n render?: ScopedComponentRenderFn;\n lazy?: Parameters<typeof createScopedLazyContent>[0]['lazy'];\n fallback?: React.ReactNode;\n }) {\n const mergedProps = mergeCreateComponentProps(\n componentOptions.props,\n ...Object.values(componentOptions.resources ?? {}).map(\n (entry) => entry.props,\n ),\n );\n const include = mergedProps.include ?? {};\n const custom = mergedProps.custom ?? {};\n const selectedResources = new Set(\n resourceOptions.map(({ resource }) => resource),\n );\n const topLevelContent = new Map(\n [...selectedResources].map((resource) => [\n resource,\n normalizeContent(componentOptions, resource, `${resource}:content`),\n ]),\n );\n const componentPropsContext = createContext<\n Record<string, unknown> | undefined\n >(undefined);\n const definedEntries = new Map<\n LayoutResourceKey<Resources>,\n ScopedComponentEntry\n >();\n\n for (const [key, entry] of Object.entries(\n componentOptions.resources ?? {},\n )) {\n const resource = key as LayoutResourceKey<Resources>;\n\n if (!selectedResources.has(resource)) {\n throw new LayoutConfigurationError(\n `Resource \"${key}\" is not available in this scoped component`,\n );\n }\n\n const normalized = normalizeContent(entry, resource, resource);\n normalized.components = Object.fromEntries(\n Object.entries(entry.components ?? {}).map(([name, definition]) => [\n name,\n normalizeContent(definition, resource, `${resource}.${name}`),\n ]),\n );\n definedEntries.set(resource, normalized);\n }\n\n /** Resolved scoped components, per resource. */\n const resourceScopedComponents = new Map<\n LayoutResourceKey<Resources>,\n Record<string, (props?: never) => JSX.Element>\n >();\n const contextResources = new Map<string, LayoutResourceKey<Resources>>();\n const renderContext: Record<string, (props: never) => JSX.Element> =\n Object.fromEntries(\n [...definedEntries].map(([resource, entry]) => {\n const contextKey = capitalize(resource);\n\n if (contextKey === 'Root') {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" maps to the reserved render context key \"Root\"`,\n );\n }\n\n const existingResource = contextResources.get(contextKey);\n\n if (existingResource !== undefined) {\n throw new LayoutConfigurationError(\n `Resources \"${existingResource}\" and \"${resource}\" both map to render context key \"${contextKey}\"`,\n );\n }\n\n contextResources.set(contextKey, resource);\n\n /**\n * Built once per resource so every scoped component keeps a stable\n * identity, and shared by the resource render, the render context,\n * and any component bound through `asHOF()`.\n */\n const scopedComponents: Record<\n string,\n (props?: never) => JSX.Element\n > = {};\n\n for (const [name, definition] of Object.entries(\n entry.components ?? {},\n )) {\n if (reservedScopedComponentNames.has(name)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" for resource \"${resource}\" uses a reserved name`,\n );\n }\n\n const ownPropDefinitions = definition.props ?? {};\n // Last call-site own-props / returned component for this scoped\n // entry. Compound statics re-run `render` with these so\n // `<DataTable variant=\"b\" />` then `<DataTable.Loading />` sees \"b\".\n let cachedOwnProps: Record<string, unknown> = {};\n let cachedState: string | undefined;\n let cachedReturnedComponent:\n | ComponentType<Record<string, unknown>>\n | undefined;\n\n function ScopedComponent(ownProps?: Record<string, unknown>) {\n const state = useContext(RenderStateNameContext);\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" must be rendered inside its scoped component`,\n );\n }\n\n const resolvedOwnProps = ownProps ?? {};\n cachedOwnProps = resolvedOwnProps;\n\n validateProps(ownPropDefinitions, resolvedOwnProps, {\n layoutName:\n entry.name ??\n defaultNames.get(resource) ??\n capitalize(resource),\n resource,\n });\n\n // Mount a returned component type with call-site props; pass\n // nodes (elements, portals, null) through unchanged.\n const result = definition.render!(\n { ...componentProps, ...resolvedOwnProps, resource },\n { ...scopedComponents, state } as unknown as typeof scopedComponents,\n );\n\n if (isRenderableComponentType(result)) {\n cachedState = state;\n cachedReturnedComponent = result as ComponentType<\n Record<string, unknown>\n >;\n }\n\n return resolveScopedRenderResult(result, resolvedOwnProps);\n }\n\n // Types expose compound statics from the returned component\n // (`DataTable.Loading`); attach matching runtime wrappers.\n if (definition[scopedLazySymbol])\n withLazyHandle(ScopedComponent, definition[scopedLazySymbol]);\n scopedComponents[name] = withScopedCompoundStatics(\n ScopedComponent,\n (staticName) => {\n function CompoundStatic(ownProps?: Record<string, unknown>) {\n const state = useContext(RenderStateNameContext);\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}.${staticName}\" must be rendered inside its scoped component`,\n );\n }\n\n // Prefer the component from the last parent call (same\n // closure as that call's own-props). Fall back to re-running\n // render with cached parent props when needed.\n let result: unknown = cachedState === state ? cachedReturnedComponent : undefined;\n\n if (!isRenderableComponentType(result)) {\n result = definition.render!(\n {\n ...componentProps,\n ...cachedOwnProps,\n resource,\n },\n { ...scopedComponents, state } as unknown as typeof scopedComponents,\n );\n }\n\n if (!isRenderableComponentType(result)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" must return a component type to use static \"${staticName}\"`,\n );\n }\n\n const staticComponent = (\n result as ComponentType<Record<string, unknown>> &\n Record<string, unknown>\n )[staticName];\n\n if (!isRenderableComponentType(staticComponent)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" has no component static \"${staticName}\"`,\n );\n }\n\n // Loading's props — those mount the static itself.\n return createElement(staticComponent, ownProps ?? {});\n }\n\n CompoundStatic.displayName = `${name}.${staticName}`;\n return CompoundStatic;\n },\n ) as (props?: never) => JSX.Element;\n }\n\n resourceScopedComponents.set(resource, scopedComponents);\n\n function ResourceRender(ownProps?: Record<string, unknown>) {\n const state = useContext(RenderStateNameContext);\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Render context component \"${contextKey}\" must be rendered inside its scoped component`,\n );\n }\n\n // Call-site props on `context.Users({ title, heading })` merge into\n // the resource render props and mount a returned component type.\n const callProps = { ...componentProps, ...ownProps, resource };\n return resolveScopedRenderResult(\n entry.render(callProps, { ...scopedComponents, state } as unknown as typeof scopedComponents),\n ownProps,\n );\n }\n\n return [\n contextKey,\n withLazyHandle(\n Object.assign(ResourceRender, scopedComponents),\n aggregateHandle([\n ...(entry[scopedLazySymbol] ? [entry[scopedLazySymbol]] : []),\n ...Object.values(entry.components ?? {}).flatMap(\n (definition) =>\n definition[scopedLazySymbol]\n ? [definition[scopedLazySymbol]]\n : [],\n ),\n ]),\n ),\n ];\n }),\n );\n\n /**\n * Layouts are created once per resource and cached. Creating one during\n * render would hand React a new component type on every pass, remounting\n * the whole subtree.\n */\n const roots = new Map<\n LayoutResourceKey<Resources>,\n (props: Record<string, unknown>) => JSX.Element\n >();\n\n function Root(rootProps: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n 'Render context component \"Root\" must be rendered inside its scoped component',\n );\n }\n\n const resource =\n componentProps.resource as LayoutResourceKey<Resources>;\n let root = roots.get(resource);\n\n if (root === undefined) {\n const entry = definedEntries.get(resource);\n\n if (entry === undefined) {\n throw new LayoutConfigurationError(\n `Render context component \"Root\" requires a \"resources.${resource}\" entry to build the layout for resource \"${resource}\"`,\n );\n }\n\n // Layout option values come from the outer component call site\n // (`<Directory title=\"…\" />`), not from the resource entry.\n const availableDefinitions = getComponentPropDefinitions(resource);\n const layoutOptions: Record<string, unknown> = {};\n const defined = entry.props?.defined ?? {};\n\n for (const key of Object.keys(availableDefinitions)) {\n if (key in defined) {\n layoutOptions[key] = defined[key];\n }\n\n const capitalized = capitalize(key);\n if (capitalized in defined) {\n layoutOptions[capitalized] = defined[capitalized];\n }\n\n if (key in componentProps) {\n layoutOptions[key] = componentProps[key];\n }\n\n if (capitalized in componentProps) {\n layoutOptions[capitalized] = componentProps[capitalized];\n }\n }\n\n root = scopedCreateResourceLayout({\n ...layoutOptions,\n namespace: false,\n name:\n entry.name ?? defaultNames.get(resource) ?? capitalize(resource),\n resource,\n }) as (props: Record<string, unknown>) => JSX.Element;\n roots.set(resource, root);\n }\n\n const entry = definedEntries.get(resource);\n const definedCustom: Record<string, unknown> = {};\n const forwardedRootProps: Record<string, unknown> = {};\n\n for (const key of Object.keys(getComponentPropDefinitions(resource))) {\n if (key in componentProps) {\n forwardedRootProps[key] = componentProps[key];\n }\n\n const capitalized = capitalize(key);\n if (capitalized in componentProps) {\n forwardedRootProps[capitalized] = componentProps[capitalized];\n }\n }\n\n for (const [key, value] of Object.entries(\n entry?.props?.defined ?? {},\n )) {\n if (key in custom) {\n definedCustom[key] = value;\n }\n }\n\n return createElement(root, {\n ...forwardedRootProps,\n ...definedCustom,\n ...rootProps,\n });\n }\n\n renderContext.Root = Root;\n\n function Component(componentProps: Record<string, unknown>) {\n const state = useContext(RenderStateNameContext);\n const componentResource =\n componentProps.resource as LayoutResourceKey<Resources>;\n\n if (!selectedResources.has(componentResource)) {\n throw new LayoutConfigurationError(\n `Resource \"${componentResource}\" is not available in this scoped component`,\n );\n }\n\n const defined =\n definedEntries.get(componentResource)?.props?.defined ?? {};\n const resolvedComponentProps = { ...defined, ...componentProps };\n const availableDefinitions =\n getComponentPropDefinitions(componentResource);\n const definitionsToValidate: Record<string, AnyBuiltPropDefinition> =\n {};\n\n for (const [key, inclusion] of Object.entries(include)) {\n const definition = availableDefinitions[key];\n\n if (!definition) {\n continue;\n }\n\n // Keep declared keys as-is — do not capitalize JSX.Element props.\n if (inclusion === true || key in resolvedComponentProps) {\n definitionsToValidate[key] = definition;\n }\n }\n\n for (const [key, definition] of Object.entries(custom)) {\n if (key === 'children' || key === 'resource') {\n continue;\n }\n\n definitionsToValidate[key] = definition;\n }\n\n validateProps(definitionsToValidate, resolvedComponentProps, {\n layoutName:\n definedEntries.get(componentResource)?.name ??\n defaultNames.get(componentResource) ??\n capitalize(componentResource),\n resource: componentResource,\n });\n\n // Top-level render may return a component type; mount it with the full\n // component props (include/custom + inferred return-type props).\n return createElement(\n componentPropsContext.Provider,\n { value: resolvedComponentProps },\n resolveScopedRenderResult(\n topLevelContent\n .get(componentResource)!\n .render(\n resolvedComponentProps,\n { ...renderContext, state } as unknown as Record<string, (props?: never) => JSX.Element>,\n ),\n resolvedComponentProps,\n ),\n );\n }\n\n /**\n * Bound components are created once per resource and cached. Returning a\n * fresh component from the factory would hand React a new component type\n * whenever the caller rebinds, remounting the subtree.\n */\n const boundComponents = new Map<\n LayoutResourceKey<Resources>,\n (props: Record<string, unknown>) => JSX.Element\n >();\n\n function bindResource(resource: LayoutResourceKey<Resources>) {\n if (!selectedResources.has(resource)) {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" is not available in this scoped component`,\n );\n }\n\n let boundComponent = boundComponents.get(resource);\n\n if (boundComponent === undefined) {\n boundComponent = Object.assign(\n (boundProps: Record<string, unknown>) =>\n createElement(Component, { ...boundProps, resource }),\n {\n displayName: `ScopedResourceComponent(${resource})`,\n props: undefined,\n resource: undefined,\n },\n resourceScopedComponents.get(resource) ?? {},\n );\n if (createMakeComposableLayout) {\n Object.assign(boundComponent, {\n makeComposable: (options: Record<string, unknown> = {}) =>\n scopedExtras.makeComposable?.({ ...options, resource }),\n });\n }\n const renderResource = renderContext[\n capitalize(resource)\n ] as unknown as LazyHandle;\n const ownContent = topLevelContent.get(resource)?.[scopedLazySymbol];\n withLazyHandle(\n boundComponent,\n aggregateHandle([\n ...(renderResource ? [renderResource] : []),\n ...(ownContent ? [ownContent] : []),\n ]),\n );\n boundComponents.set(resource, boundComponent);\n }\n\n return boundComponent;\n }\n\n function asHOF() {\n return bindResource;\n }\n\n withLazyHandle(\n Component,\n aggregateHandle([\n ...(Object.values(renderContext).filter(\n (value) => 'preload' in value,\n ) as unknown as LazyHandle[]),\n ...[...topLevelContent.values()].flatMap((entry) =>\n entry[scopedLazySymbol] ? [entry[scopedLazySymbol]] : [],\n ),\n ]),\n );\n return Object.assign(Component, {\n asHOF,\n displayName: 'ScopedResourceComponent',\n props: undefined,\n });\n }\n\n function createComponentSetProps(baseProps: CreateComponentPropsBag) {\n function createWithProps(componentOptions: {\n props?: CreateComponentPropsBag;\n resources?: Record<string, ScopedComponentEntry>;\n render: (\n props: Record<string, unknown>,\n context: Record<string, (props: never) => JSX.Element>,\n ) => ScopedRenderResult;\n }) {\n return createComponent({\n ...componentOptions,\n props: mergeCreateComponentProps(baseProps, componentOptions.props),\n });\n }\n\n createWithProps.createResourceComponents = createResourceComponents;\n\n return createWithProps;\n }\n\n function createResourceComponents(options: {\n resource: LayoutResourceKey<Resources>;\n props?: CreateComponentPropsBag;\n name?: string;\n components?: Record<string, ScopedResourceScopedComponentDefinition>;\n render?: ScopedComponentRenderFn;\n lazy?: Parameters<typeof createScopedLazyContent>[0]['lazy'];\n fallback?: React.ReactNode;\n }) {\n const { resource, props, ...entry } = options;\n\n if (\n !resourceOptions.some(\n (resourceOption) => resourceOption.resource === resource,\n )\n ) {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" is not available in this scoped component`,\n );\n }\n\n const normalized = normalizeContent(entry, resource, String(resource));\n const components = Object.fromEntries(\n Object.entries(normalized.components ?? {}).map(\n ([name, definition]) => [\n name,\n normalizeContent(definition, resource, `${resource}.${name}`),\n ],\n ),\n );\n const result = { ...normalized, components, props: props ?? {} };\n return withLazyHandle(\n result,\n aggregateHandle([\n ...(normalized[scopedLazySymbol]\n ? [normalized[scopedLazySymbol]]\n : []),\n ...Object.values(components).flatMap((definition) =>\n definition[scopedLazySymbol] ? [definition[scopedLazySymbol]] : [],\n ),\n ]),\n );\n }\n\n Object.assign(createComponent, {\n setProps: createComponentSetProps,\n });\n\n const scopedExtras: {\n createComponent: typeof createComponent;\n createResourceComponents: typeof createResourceComponents;\n forResource: typeof scopedForResource;\n makeComposable?: (options: Record<string, unknown>) => unknown;\n resources: undefined;\n } = {\n createComponent,\n createResourceComponents,\n forResource: scopedForResource,\n resources: undefined,\n };\n\n if (createMakeComposableLayout) {\n const makeComposableLayout = createMakeComposableLayout();\n\n scopedExtras.makeComposable = (options) => {\n const resource = options.resource as LayoutResourceKey<Resources>;\n\n return makeComposableLayout({\n ...options,\n name: options.name ?? defaultNames.get(resource),\n });\n };\n }\n\n return Object.assign(scopedCreateResourceLayout, scopedExtras);\n }) as unknown as CreateResourceLayoutForResourcesFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps\n >;\n}\n"],"mappings":";;;;;;;;;;AAwDA,SAAgB,mBAMd,EACA,yBACA,4BACA,sBACA,6BACA,mBACuC;CACvC,SAAS,GAAG,uBAAuC;EACjD,MAAM,gBAAgB,mBAAmB;EACzC,IAAI;EASJ,IAAI,OAAO,kBAAkB,UAC3B,kBAAkB,mBAAmB,KAAK,cAAc,EAC5C,SACZ,EAAE;OACG,IACL,kBAAkB,QAClB,OAAO,kBAAkB,YACzB,eAAe,iBACf,MAAM,QAAQ,cAAc,SAAS,GACrC;GACA,MAAM,EAAE,MAAM,cAAc;GAI5B,kBAAkB,UAAU,KAAK,cAAc;IAC7C,MAAM,OAAO,SAAS,aAAa,OAAO,OAAO;IACjD;GACF,EAAE;EACJ,OACE,kBAAkB,OAAO,QAAQ,iBAAiB,CAAC,CAAC,EAAE,KACnD,CAAC,UAAU,cAAc;GACxB,GAAI;GAOM;EACZ,EACF;EAGF,MAAM,eAAe,IAAI,IACvB,gBAAgB,KAAK,EAAE,MAAM,eAAe,CAC1C,UACA,OAAO,SAAS,aACZ,KACEA,8BAAW,QAAQ,CAGrB,IACA,IACN,CAAC,CACH;EAEA,SAAS,2BAA2B,SAAkC;GACpE,MAAM,WAAW,QAAQ;GAEzB,OAAO,qBAAqB;IAC1B,GAAG;IACH,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ;GACjD,CAAC;EACH;EAEA,SAAS,kBAAkB,SAGxB;GACD,OAAO,wBACL,QAAQ,QAAQ,aAAa,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IAAID,4DACR,aAAa,SAAS,4CACxB;GAGF,MAAM,aAAa,iBAAiB,OAAO,UAAU,OAAO,QAAQ,CAAC;GACrE,MAAM,aAAa,OAAO,YACxB,OAAO,QAAQ,WAAW,cAAc,CAAC,CAAC,EAAE,KACzC,CAAC,MAAM,gBAAgB,CACtB,MACA,iBAAiB,YAAY,UAAU,GAAG,SAAS,GAAG,MAAM,CAC9D,CACF,CACF;GAEA,OAAOG,kCACL;IAFe,GAAG;IAAY;IAAY,OAAO,SAAS,CAAC;GAEtD,GACL,gBAAgB,CACd,GAAI,WAAWF,2CACX,CAAC,WAAWA,wCAAiB,IAC7B,CAAC,GACL,GAAG,OAAO,OAAO,UAAU,EAAE,SAAS,eACpC,WAAWA,2CAAoB,CAAC,WAAWA,wCAAiB,IAAI,CAAC,CACnE,CACF,CAAC,CACH;EACF;EAEA,OAAO,OAAO,iBAAiB,EAC7B,UAAU,wBACZ,CAAC;EAED,MAAM,eAMF;GACF;GACA;GACA,aAAa;GACb,WAAW;EACb;EAEA,IAAI,4BAA4B;GAC9B,MAAM,uBAAuB,2BAA2B;GAExD,aAAa,kBAAkB,YAAY;IACzC,MAAM,WAAW,QAAQ;IAEzB,OAAO,qBAAqB;KAC1B,GAAG;KACH,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ;IACjD,CAAC;GACH;EACF;EAEA,OAAO,OAAO,OAAO,4BAA4B,YAAY;CAC/D;AAOF"}
@@ -1,11 +1,14 @@
1
+ import { RenderStateNameContext } from "../render-state-context.mjs";
1
2
  import { LayoutConfigurationError } from "../../errors/layout-configuration-error.mjs";
2
3
  import { capitalize } from "../../utils/capitalize.mjs";
4
+ import { withLazyHandle } from "../../lazy/inspection.mjs";
3
5
  import { isRenderableComponentType, reservedScopedComponentNames, resolveScopedRenderResult, withScopedCompoundStatics } from "./scoped-render.mjs";
6
+ import { createScopedLazyContent, scopedLazySymbol } from "../../lazy/scoped-content.mjs";
4
7
  import { createContext, createElement, useContext } from "react";
5
8
  import { validateProps } from "@jfdevelops/react-layout-validator";
6
9
 
7
10
  //#region src/create-config/for-resources/create-for-resources.ts
8
- function createForResources({ createLayoutForResource, createMakeComposableLayout, createResourceLayout, getComponentPropDefinitions }) {
11
+ function createForResources({ createLayoutForResource, createMakeComposableLayout, createResourceLayout, getComponentPropDefinitions, lazyEnvironment }) {
9
12
  return ((...resourcesOrOptions) => {
10
13
  const firstArgument = resourcesOrOptions[0];
11
14
  let resourceOptions;
@@ -31,6 +34,44 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
31
34
  function scopedForResource(options) {
32
35
  return createLayoutForResource(options.name ?? defaultNames.get(options.resource), options.resource);
33
36
  }
37
+ function normalizeContent(definition, resource, label) {
38
+ if (definition.lazy !== void 0 && definition.render !== void 0) throw new LayoutConfigurationError(`Scoped content "${label}" must define render or lazy, never both`);
39
+ if (definition[scopedLazySymbol]) return definition;
40
+ if (definition.lazy === void 0) {
41
+ if (typeof definition.render !== "function") throw new LayoutConfigurationError(`Scoped content "${label}" requires render or lazy`);
42
+ return definition;
43
+ }
44
+ const Content = createScopedLazyContent(definition, resource, label, lazyEnvironment);
45
+ return withLazyHandle({
46
+ ...definition,
47
+ lazy: void 0,
48
+ render: (callProps, context) => createElement(Content, {
49
+ callProps,
50
+ context
51
+ }),
52
+ [scopedLazySymbol]: Content
53
+ }, Content);
54
+ }
55
+ function aggregateHandle(handles) {
56
+ let imports = [];
57
+ let pending;
58
+ return {
59
+ preload() {
60
+ const next = handles.map((handle) => handle.preload());
61
+ if (!pending || next.some((promise, index) => promise !== imports[index])) {
62
+ imports = next;
63
+ pending = Promise.all(next).then(() => void 0);
64
+ }
65
+ return pending;
66
+ },
67
+ get status() {
68
+ if (handles.some((handle) => handle.status === "error")) return "error";
69
+ if (handles.some((handle) => handle.status === "loading")) return "loading";
70
+ if (handles.some((handle) => handle.status === "unresolved")) return "unresolved";
71
+ return "resolved";
72
+ }
73
+ };
74
+ }
34
75
  function mergeCreateComponentProps(...bags) {
35
76
  const include = {};
36
77
  const custom = {};
@@ -49,12 +90,15 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
49
90
  const include = mergedProps.include ?? {};
50
91
  const custom = mergedProps.custom ?? {};
51
92
  const selectedResources = new Set(resourceOptions.map(({ resource }) => resource));
93
+ const topLevelContent = new Map([...selectedResources].map((resource) => [resource, normalizeContent(componentOptions, resource, `${resource}:content`)]));
52
94
  const componentPropsContext = createContext(void 0);
53
95
  const definedEntries = /* @__PURE__ */ new Map();
54
96
  for (const [key, entry] of Object.entries(componentOptions.resources ?? {})) {
55
97
  const resource = key;
56
98
  if (!selectedResources.has(resource)) throw new LayoutConfigurationError(`Resource "${key}" is not available in this scoped component`);
57
- definedEntries.set(resource, entry);
99
+ const normalized = normalizeContent(entry, resource, resource);
100
+ normalized.components = Object.fromEntries(Object.entries(entry.components ?? {}).map(([name, definition]) => [name, normalizeContent(definition, resource, `${resource}.${name}`)]));
101
+ definedEntries.set(resource, normalized);
58
102
  }
59
103
  /** Resolved scoped components, per resource. */
60
104
  const resourceScopedComponents = /* @__PURE__ */ new Map();
@@ -75,8 +119,10 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
75
119
  if (reservedScopedComponentNames.has(name)) throw new LayoutConfigurationError(`Scoped component "${name}" for resource "${resource}" uses a reserved name`);
76
120
  const ownPropDefinitions = definition.props ?? {};
77
121
  let cachedOwnProps = {};
122
+ let cachedState;
78
123
  let cachedReturnedComponent;
79
124
  function ScopedComponent(ownProps) {
125
+ const state = useContext(RenderStateNameContext);
80
126
  const componentProps = useContext(componentPropsContext);
81
127
  if (componentProps === void 0) throw new LayoutConfigurationError(`Scoped component "${name}" must be rendered inside its scoped component`);
82
128
  const resolvedOwnProps = ownProps ?? {};
@@ -89,20 +135,31 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
89
135
  ...componentProps,
90
136
  ...resolvedOwnProps,
91
137
  resource
92
- }, scopedComponents);
93
- if (isRenderableComponentType(result)) cachedReturnedComponent = result;
138
+ }, {
139
+ ...scopedComponents,
140
+ state
141
+ });
142
+ if (isRenderableComponentType(result)) {
143
+ cachedState = state;
144
+ cachedReturnedComponent = result;
145
+ }
94
146
  return resolveScopedRenderResult(result, resolvedOwnProps);
95
147
  }
148
+ if (definition[scopedLazySymbol]) withLazyHandle(ScopedComponent, definition[scopedLazySymbol]);
96
149
  scopedComponents[name] = withScopedCompoundStatics(ScopedComponent, (staticName) => {
97
150
  function CompoundStatic(ownProps) {
151
+ const state = useContext(RenderStateNameContext);
98
152
  const componentProps = useContext(componentPropsContext);
99
153
  if (componentProps === void 0) throw new LayoutConfigurationError(`Scoped component "${name}.${staticName}" must be rendered inside its scoped component`);
100
- let result = cachedReturnedComponent;
154
+ let result = cachedState === state ? cachedReturnedComponent : void 0;
101
155
  if (!isRenderableComponentType(result)) result = definition.render({
102
156
  ...componentProps,
103
157
  ...cachedOwnProps,
104
158
  resource
105
- }, scopedComponents);
159
+ }, {
160
+ ...scopedComponents,
161
+ state
162
+ });
106
163
  if (!isRenderableComponentType(result)) throw new LayoutConfigurationError(`Scoped component "${name}" must return a component type to use static "${staticName}"`);
107
164
  const staticComponent = result[staticName];
108
165
  if (!isRenderableComponentType(staticComponent)) throw new LayoutConfigurationError(`Scoped component "${name}" has no component static "${staticName}"`);
@@ -114,6 +171,7 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
114
171
  }
115
172
  resourceScopedComponents.set(resource, scopedComponents);
116
173
  function ResourceRender(ownProps) {
174
+ const state = useContext(RenderStateNameContext);
117
175
  const componentProps = useContext(componentPropsContext);
118
176
  if (componentProps === void 0) throw new LayoutConfigurationError(`Render context component "${contextKey}" must be rendered inside its scoped component`);
119
177
  const callProps = {
@@ -121,9 +179,12 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
121
179
  ...ownProps,
122
180
  resource
123
181
  };
124
- return resolveScopedRenderResult(entry.render(callProps, scopedComponents), ownProps);
182
+ return resolveScopedRenderResult(entry.render(callProps, {
183
+ ...scopedComponents,
184
+ state
185
+ }), ownProps);
125
186
  }
126
- return [contextKey, Object.assign(ResourceRender, scopedComponents)];
187
+ return [contextKey, withLazyHandle(Object.assign(ResourceRender, scopedComponents), aggregateHandle([...entry[scopedLazySymbol] ? [entry[scopedLazySymbol]] : [], ...Object.values(entry.components ?? {}).flatMap((definition) => definition[scopedLazySymbol] ? [definition[scopedLazySymbol]] : [])]))];
127
188
  }));
128
189
  /**
129
190
  * Layouts are created once per resource and cached. Creating one during
@@ -174,6 +235,7 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
174
235
  }
175
236
  renderContext.Root = Root;
176
237
  function Component(componentProps) {
238
+ const state = useContext(RenderStateNameContext);
177
239
  const componentResource = componentProps.resource;
178
240
  if (!selectedResources.has(componentResource)) throw new LayoutConfigurationError(`Resource "${componentResource}" is not available in this scoped component`);
179
241
  const resolvedComponentProps = {
@@ -195,7 +257,10 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
195
257
  layoutName: definedEntries.get(componentResource)?.name ?? defaultNames.get(componentResource) ?? capitalize(componentResource),
196
258
  resource: componentResource
197
259
  });
198
- return createElement(componentPropsContext.Provider, { value: resolvedComponentProps }, resolveScopedRenderResult(componentOptions.render(resolvedComponentProps, renderContext), resolvedComponentProps));
260
+ return createElement(componentPropsContext.Provider, { value: resolvedComponentProps }, resolveScopedRenderResult(topLevelContent.get(componentResource).render(resolvedComponentProps, {
261
+ ...renderContext,
262
+ state
263
+ }), resolvedComponentProps));
199
264
  }
200
265
  /**
201
266
  * Bound components are created once per resource and cached. Returning a
@@ -215,6 +280,13 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
215
280
  props: void 0,
216
281
  resource: void 0
217
282
  }, resourceScopedComponents.get(resource) ?? {});
283
+ if (createMakeComposableLayout) Object.assign(boundComponent, { makeComposable: (options = {}) => scopedExtras.makeComposable?.({
284
+ ...options,
285
+ resource
286
+ }) });
287
+ const renderResource = renderContext[capitalize(resource)];
288
+ const ownContent = topLevelContent.get(resource)?.[scopedLazySymbol];
289
+ withLazyHandle(boundComponent, aggregateHandle([...renderResource ? [renderResource] : [], ...ownContent ? [ownContent] : []]));
218
290
  boundComponents.set(resource, boundComponent);
219
291
  }
220
292
  return boundComponent;
@@ -222,6 +294,7 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
222
294
  function asHOF() {
223
295
  return bindResource;
224
296
  }
297
+ withLazyHandle(Component, aggregateHandle([...Object.values(renderContext).filter((value) => "preload" in value), ...[...topLevelContent.values()].flatMap((entry) => entry[scopedLazySymbol] ? [entry[scopedLazySymbol]] : [])]));
225
298
  return Object.assign(Component, {
226
299
  asHOF,
227
300
  displayName: "ScopedResourceComponent",
@@ -241,10 +314,13 @@ function createForResources({ createLayoutForResource, createMakeComposableLayou
241
314
  function createResourceComponents(options) {
242
315
  const { resource, props, ...entry } = options;
243
316
  if (!resourceOptions.some((resourceOption) => resourceOption.resource === resource)) throw new LayoutConfigurationError(`Resource "${resource}" is not available in this scoped component`);
244
- return {
245
- ...entry,
317
+ const normalized = normalizeContent(entry, resource, String(resource));
318
+ const components = Object.fromEntries(Object.entries(normalized.components ?? {}).map(([name, definition]) => [name, normalizeContent(definition, resource, `${resource}.${name}`)]));
319
+ return withLazyHandle({
320
+ ...normalized,
321
+ components,
246
322
  props: props ?? {}
247
- };
323
+ }, aggregateHandle([...normalized[scopedLazySymbol] ? [normalized[scopedLazySymbol]] : [], ...Object.values(components).flatMap((definition) => definition[scopedLazySymbol] ? [definition[scopedLazySymbol]] : [])]));
248
324
  }
249
325
  Object.assign(createComponent, { setProps: createComponentSetProps });
250
326
  const scopedExtras = {
@@ -1 +1 @@
1
- {"version":3,"file":"create-for-resources.mjs","names":[],"sources":["../../../src/create-config/for-resources/create-for-resources.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n type ComponentType,\n type JSX,\n useContext,\n} from 'react';\nimport type { ComposableComponents } from '@jfdevelops/react-layout-composables';\nimport {\n type AnyBuiltPropDefinition,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport type { InPropsDefinition, InPropsObject } from '../../props';\nimport type { LayoutResourceKey, ResourceDefinition } from '../../resource';\nimport { capitalize } from '../../utils/capitalize';\nimport { LayoutConfigurationError } from '../../errors';\nimport type { LayoutIncludeProps } from '../define-layout';\nimport type {\n CapitalizedResource,\n ResourcesLayoutName,\n} from './resource-selection';\nimport type { CreateResourceLayoutForResourcesFn } from './scoped-layout';\nimport {\n isRenderableComponentType,\n reservedScopedComponentNames,\n resolveScopedRenderResult,\n type ScopedRenderResult,\n withScopedCompoundStatics,\n} from './scoped-render';\n\ntype CreateForResourcesOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n> = {\n createLayoutForResource: (\n defaultName: string | undefined,\n resource: LayoutResourceKey<Resources>,\n ) => unknown;\n createMakeComposableLayout?: () => (\n options: Record<string, unknown>,\n ) => unknown;\n createResourceLayout: (options: Record<string, unknown>) => unknown;\n getComponentPropDefinitions: (\n resource: LayoutResourceKey<Resources>,\n ) => Record<string, AnyBuiltPropDefinition>;\n};\n\nexport function createForResources<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends InPropsObject,\n>({\n createLayoutForResource,\n createMakeComposableLayout,\n createResourceLayout,\n getComponentPropDefinitions,\n}: CreateForResourcesOptions<Resources>) {\n return ((...resourcesOrOptions: Array<unknown>) => {\n const firstArgument = resourcesOrOptions[0];\n let resourceOptions: Array<{\n resource: LayoutResourceKey<Resources>;\n name?:\n | string\n | ((\n resource: CapitalizedResource<LayoutResourceKey<Resources>>,\n ) => string);\n }>;\n\n if (typeof firstArgument === 'string') {\n resourceOptions = resourcesOrOptions.map((resource) => ({\n resource: resource as LayoutResourceKey<Resources>,\n }));\n } else if (\n firstArgument !== null &&\n typeof firstArgument === 'object' &&\n 'resources' in firstArgument &&\n Array.isArray(firstArgument.resources)\n ) {\n const { name, resources } = firstArgument as {\n name?: ResourcesLayoutName<LayoutResourceKey<Resources>>;\n resources: Array<LayoutResourceKey<Resources>>;\n };\n resourceOptions = resources.map((resource) => ({\n name: typeof name === 'function' ? name : name?.[resource],\n resource,\n }));\n } else {\n resourceOptions = Object.entries(firstArgument ?? {}).map(\n ([resource, options]) => ({\n ...(options as {\n name?:\n | string\n | ((\n resource: CapitalizedResource<LayoutResourceKey<Resources>>,\n ) => string);\n }),\n resource: resource as LayoutResourceKey<Resources>,\n }),\n );\n }\n\n const defaultNames = new Map(\n resourceOptions.map(({ name, resource }) => [\n resource,\n typeof name === 'function'\n ? name(\n capitalize(resource) as CapitalizedResource<\n LayoutResourceKey<Resources>\n >,\n )\n : name,\n ]),\n );\n\n function scopedCreateResourceLayout(options: Record<string, unknown>) {\n const resource = options.resource as LayoutResourceKey<Resources>;\n\n return createResourceLayout({\n ...options,\n name: options.name ?? defaultNames.get(resource),\n });\n }\n\n function scopedForResource(options: {\n name?: string;\n resource: LayoutResourceKey<Resources>;\n }) {\n return createLayoutForResource(\n options.name ?? defaultNames.get(options.resource),\n options.resource,\n );\n }\n\n type ScopedComponentRenderFn = (\n props: Record<string, unknown>,\n components: Record<string, (props?: never) => JSX.Element>,\n ) => ScopedRenderResult;\n\n type ScopedResourceScopedComponentDefinition = {\n props?: Record<string, AnyBuiltPropDefinition>;\n render: ScopedComponentRenderFn;\n };\n\n type ScopedComponentEntry = {\n [option: string]: unknown;\n name?: string;\n props?: CreateComponentPropsBag;\n components?: Record<string, ScopedResourceScopedComponentDefinition>;\n render: ScopedComponentRenderFn;\n };\n\n type CreateComponentPropsBag = {\n include?: Record<string, true | 'optional'>;\n custom?: Record<string, AnyBuiltPropDefinition>;\n defined?: Record<string, unknown>;\n };\n\n function mergeCreateComponentProps(\n ...bags: Array<CreateComponentPropsBag | undefined>\n ): CreateComponentPropsBag {\n const include: Record<string, true | 'optional'> = {};\n const custom: Record<string, AnyBuiltPropDefinition> = {};\n\n for (const bag of bags) {\n Object.assign(include, bag?.include);\n Object.assign(custom, bag?.custom);\n\n for (const key of Object.keys(bag?.defined ?? {})) {\n include[key] = true;\n }\n }\n\n return { include, custom };\n }\n\n function createComponent(componentOptions: {\n props?: {\n include?: Record<string, true | 'optional'>;\n custom?: Record<string, AnyBuiltPropDefinition>;\n };\n resources?: Record<string, ScopedComponentEntry>;\n render: (\n props: Record<string, unknown>,\n context: Record<string, (props: never) => JSX.Element>,\n ) => ScopedRenderResult;\n }) {\n const mergedProps = mergeCreateComponentProps(\n componentOptions.props,\n ...Object.values(componentOptions.resources ?? {}).map(\n (entry) => entry.props,\n ),\n );\n const include = mergedProps.include ?? {};\n const custom = mergedProps.custom ?? {};\n const selectedResources = new Set(\n resourceOptions.map(({ resource }) => resource),\n );\n const componentPropsContext = createContext<\n Record<string, unknown> | undefined\n >(undefined);\n const definedEntries = new Map<\n LayoutResourceKey<Resources>,\n ScopedComponentEntry\n >();\n\n for (const [key, entry] of Object.entries(\n componentOptions.resources ?? {},\n )) {\n const resource = key as LayoutResourceKey<Resources>;\n\n if (!selectedResources.has(resource)) {\n throw new LayoutConfigurationError(\n `Resource \"${key}\" is not available in this scoped component`,\n );\n }\n\n definedEntries.set(resource, entry);\n }\n\n /** Resolved scoped components, per resource. */\n const resourceScopedComponents = new Map<\n LayoutResourceKey<Resources>,\n Record<string, (props?: never) => JSX.Element>\n >();\n const contextResources = new Map<string, LayoutResourceKey<Resources>>();\n const renderContext: Record<string, (props: never) => JSX.Element> =\n Object.fromEntries(\n [...definedEntries].map(([resource, entry]) => {\n const contextKey = capitalize(resource);\n\n if (contextKey === 'Root') {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" maps to the reserved render context key \"Root\"`,\n );\n }\n\n const existingResource = contextResources.get(contextKey);\n\n if (existingResource !== undefined) {\n throw new LayoutConfigurationError(\n `Resources \"${existingResource}\" and \"${resource}\" both map to render context key \"${contextKey}\"`,\n );\n }\n\n contextResources.set(contextKey, resource);\n\n /**\n * Built once per resource so every scoped component keeps a stable\n * identity, and shared by the resource render, the render context,\n * and any component bound through `asHOF()`.\n */\n const scopedComponents: Record<\n string,\n (props?: never) => JSX.Element\n > = {};\n\n for (const [name, definition] of Object.entries(\n entry.components ?? {},\n )) {\n if (reservedScopedComponentNames.has(name)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" for resource \"${resource}\" uses a reserved name`,\n );\n }\n\n const ownPropDefinitions = definition.props ?? {};\n // Last call-site own-props / returned component for this scoped\n // entry. Compound statics re-run `render` with these so\n // `<DataTable variant=\"b\" />` then `<DataTable.Loading />` sees \"b\".\n let cachedOwnProps: Record<string, unknown> = {};\n let cachedReturnedComponent:\n | ComponentType<Record<string, unknown>>\n | undefined;\n\n function ScopedComponent(ownProps?: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" must be rendered inside its scoped component`,\n );\n }\n\n const resolvedOwnProps = ownProps ?? {};\n cachedOwnProps = resolvedOwnProps;\n\n validateProps(ownPropDefinitions, resolvedOwnProps, {\n layoutName:\n entry.name ??\n defaultNames.get(resource) ??\n capitalize(resource),\n resource,\n });\n\n // Mount a returned component type with call-site props; pass\n // nodes (elements, portals, null) through unchanged.\n const result = definition.render(\n { ...componentProps, ...resolvedOwnProps, resource },\n scopedComponents,\n );\n\n if (isRenderableComponentType(result)) {\n cachedReturnedComponent = result as ComponentType<\n Record<string, unknown>\n >;\n }\n\n return resolveScopedRenderResult(result, resolvedOwnProps);\n }\n\n // Types expose compound statics from the returned component\n // (`DataTable.Loading`); attach matching runtime wrappers.\n scopedComponents[name] = withScopedCompoundStatics(\n ScopedComponent,\n (staticName) => {\n function CompoundStatic(ownProps?: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}.${staticName}\" must be rendered inside its scoped component`,\n );\n }\n\n // Prefer the component from the last parent call (same\n // closure as that call's own-props). Fall back to re-running\n // render with cached parent props when needed.\n let result: unknown = cachedReturnedComponent;\n\n if (!isRenderableComponentType(result)) {\n result = definition.render(\n {\n ...componentProps,\n ...cachedOwnProps,\n resource,\n },\n scopedComponents,\n );\n }\n\n if (!isRenderableComponentType(result)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" must return a component type to use static \"${staticName}\"`,\n );\n }\n\n const staticComponent = (\n result as ComponentType<Record<string, unknown>> &\n Record<string, unknown>\n )[staticName];\n\n if (!isRenderableComponentType(staticComponent)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" has no component static \"${staticName}\"`,\n );\n }\n\n // Loading's props — those mount the static itself.\n return createElement(staticComponent, ownProps ?? {});\n }\n\n CompoundStatic.displayName = `${name}.${staticName}`;\n return CompoundStatic;\n },\n ) as (props?: never) => JSX.Element;\n }\n\n resourceScopedComponents.set(resource, scopedComponents);\n\n function ResourceRender(ownProps?: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Render context component \"${contextKey}\" must be rendered inside its scoped component`,\n );\n }\n\n // Call-site props on `context.Users({ title, heading })` merge into\n // the resource render props and mount a returned component type.\n const callProps = { ...componentProps, ...ownProps, resource };\n return resolveScopedRenderResult(\n entry.render(callProps, scopedComponents),\n ownProps,\n );\n }\n\n return [\n contextKey,\n Object.assign(ResourceRender, scopedComponents),\n ];\n }),\n );\n\n /**\n * Layouts are created once per resource and cached. Creating one during\n * render would hand React a new component type on every pass, remounting\n * the whole subtree.\n */\n const roots = new Map<\n LayoutResourceKey<Resources>,\n (props: Record<string, unknown>) => JSX.Element\n >();\n\n function Root(rootProps: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n 'Render context component \"Root\" must be rendered inside its scoped component',\n );\n }\n\n const resource =\n componentProps.resource as LayoutResourceKey<Resources>;\n let root = roots.get(resource);\n\n if (root === undefined) {\n const entry = definedEntries.get(resource);\n\n if (entry === undefined) {\n throw new LayoutConfigurationError(\n `Render context component \"Root\" requires a \"resources.${resource}\" entry to build the layout for resource \"${resource}\"`,\n );\n }\n\n // Layout option values come from the outer component call site\n // (`<Directory title=\"…\" />`), not from the resource entry.\n const availableDefinitions =\n getComponentPropDefinitions(resource);\n const layoutOptions: Record<string, unknown> = {};\n const defined = entry.props?.defined ?? {};\n\n for (const key of Object.keys(availableDefinitions)) {\n if (key in defined) {\n layoutOptions[key] = defined[key];\n }\n\n const capitalized = capitalize(key);\n if (capitalized in defined) {\n layoutOptions[capitalized] = defined[capitalized];\n }\n\n if (key in componentProps) {\n layoutOptions[key] = componentProps[key];\n }\n\n if (capitalized in componentProps) {\n layoutOptions[capitalized] = componentProps[capitalized];\n }\n }\n\n root = scopedCreateResourceLayout({\n ...layoutOptions,\n namespace: false,\n name:\n entry.name ??\n defaultNames.get(resource) ??\n capitalize(resource),\n resource,\n }) as (props: Record<string, unknown>) => JSX.Element;\n roots.set(resource, root);\n }\n\n const entry = definedEntries.get(resource);\n const definedCustom: Record<string, unknown> = {};\n const forwardedRootProps: Record<string, unknown> = {};\n\n for (const key of Object.keys(getComponentPropDefinitions(resource))) {\n if (key in componentProps) {\n forwardedRootProps[key] = componentProps[key];\n }\n\n const capitalized = capitalize(key);\n if (capitalized in componentProps) {\n forwardedRootProps[capitalized] = componentProps[capitalized];\n }\n }\n\n for (const [key, value] of Object.entries(\n entry?.props?.defined ?? {},\n )) {\n if (key in custom) {\n definedCustom[key] = value;\n }\n }\n\n return createElement(root, {\n ...forwardedRootProps,\n ...definedCustom,\n ...rootProps,\n });\n }\n\n renderContext.Root = Root;\n\n function Component(componentProps: Record<string, unknown>) {\n const componentResource =\n componentProps.resource as LayoutResourceKey<Resources>;\n\n if (!selectedResources.has(componentResource)) {\n throw new LayoutConfigurationError(\n `Resource \"${componentResource}\" is not available in this scoped component`,\n );\n }\n\n const defined =\n definedEntries.get(componentResource)?.props?.defined ?? {};\n const resolvedComponentProps = { ...defined, ...componentProps };\n const availableDefinitions =\n getComponentPropDefinitions(componentResource);\n const definitionsToValidate: Record<string, AnyBuiltPropDefinition> =\n {};\n\n for (const [key, inclusion] of Object.entries(include)) {\n const definition = availableDefinitions[key];\n\n if (!definition) {\n continue;\n }\n\n // Keep declared keys as-is — do not capitalize JSX.Element props.\n if (inclusion === true || key in resolvedComponentProps) {\n definitionsToValidate[key] = definition;\n }\n }\n\n for (const [key, definition] of Object.entries(custom)) {\n if (key === 'children' || key === 'resource') {\n continue;\n }\n\n definitionsToValidate[key] = definition;\n }\n\n validateProps(definitionsToValidate, resolvedComponentProps, {\n layoutName:\n definedEntries.get(componentResource)?.name ??\n defaultNames.get(componentResource) ??\n capitalize(componentResource),\n resource: componentResource,\n });\n\n // Top-level render may return a component type; mount it with the full\n // component props (include/custom + inferred return-type props).\n return createElement(\n componentPropsContext.Provider,\n { value: resolvedComponentProps },\n resolveScopedRenderResult(\n componentOptions.render(resolvedComponentProps, renderContext),\n resolvedComponentProps,\n ),\n );\n }\n\n /**\n * Bound components are created once per resource and cached. Returning a\n * fresh component from the factory would hand React a new component type\n * whenever the caller rebinds, remounting the subtree.\n */\n const boundComponents = new Map<\n LayoutResourceKey<Resources>,\n (props: Record<string, unknown>) => JSX.Element\n >();\n\n function bindResource(resource: LayoutResourceKey<Resources>) {\n if (!selectedResources.has(resource)) {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" is not available in this scoped component`,\n );\n }\n\n let boundComponent = boundComponents.get(resource);\n\n if (boundComponent === undefined) {\n boundComponent = Object.assign(\n (boundProps: Record<string, unknown>) =>\n createElement(Component, { ...boundProps, resource }),\n {\n displayName: `ScopedResourceComponent(${resource})`,\n props: undefined,\n resource: undefined,\n },\n resourceScopedComponents.get(resource) ?? {},\n );\n boundComponents.set(resource, boundComponent);\n }\n\n return boundComponent;\n }\n\n function asHOF() {\n return bindResource;\n }\n\n return Object.assign(Component, {\n asHOF,\n displayName: 'ScopedResourceComponent',\n props: undefined,\n });\n }\n\n function createComponentSetProps(baseProps: CreateComponentPropsBag) {\n function createWithProps(componentOptions: {\n props?: CreateComponentPropsBag;\n resources?: Record<string, ScopedComponentEntry>;\n render: (\n props: Record<string, unknown>,\n context: Record<string, (props: never) => JSX.Element>,\n ) => ScopedRenderResult;\n }) {\n return createComponent({\n ...componentOptions,\n props: mergeCreateComponentProps(baseProps, componentOptions.props),\n });\n }\n\n createWithProps.createResourceComponents = createResourceComponents;\n\n return createWithProps;\n }\n\n function createResourceComponents(options: {\n resource: LayoutResourceKey<Resources>;\n props?: CreateComponentPropsBag;\n name?: string;\n components?: Record<string, ScopedResourceScopedComponentDefinition>;\n render: ScopedComponentRenderFn;\n }) {\n const { resource, props, ...entry } = options;\n\n if (\n !resourceOptions.some(\n (resourceOption) => resourceOption.resource === resource,\n )\n ) {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" is not available in this scoped component`,\n );\n }\n\n return { ...entry, props: props ?? {} };\n }\n\n Object.assign(createComponent, {\n setProps: createComponentSetProps,\n });\n\n const scopedExtras: {\n createComponent: typeof createComponent;\n createResourceComponents: typeof createResourceComponents;\n forResource: typeof scopedForResource;\n makeComposable?: (options: Record<string, unknown>) => unknown;\n resources: undefined;\n } = {\n createComponent,\n createResourceComponents,\n forResource: scopedForResource,\n resources: undefined,\n };\n\n if (createMakeComposableLayout) {\n const makeComposableLayout = createMakeComposableLayout();\n\n scopedExtras.makeComposable = (options) => {\n const resource = options.resource as LayoutResourceKey<Resources>;\n\n return makeComposableLayout({\n ...options,\n name: options.name ?? defaultNames.get(resource),\n });\n };\n }\n\n return Object.assign(scopedCreateResourceLayout, scopedExtras);\n }) as unknown as CreateResourceLayoutForResourcesFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps\n >;\n}\n"],"mappings":";;;;;;;AA8CA,SAAgB,mBAMd,EACA,yBACA,4BACA,sBACA,+BACuC;CACvC,SAAS,GAAG,uBAAuC;EACjD,MAAM,gBAAgB,mBAAmB;EACzC,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-resources.mjs","names":[],"sources":["../../../src/create-config/for-resources/create-for-resources.ts"],"sourcesContent":["import { RenderStateNameContext } from '../render-state-context';\nimport {\n createScopedLazyContent,\n scopedLazySymbol,\n type LazyEnvironment,\n type ScopedLazyContent,\n} from '../../lazy/scoped-content';\nimport { withLazyHandle } from '../../lazy/inspection';\nimport type { LazyHandle } from '../../lazy/types';\nimport {\n createContext,\n createElement,\n type ComponentType,\n type JSX,\n useContext,\n} from 'react';\nimport type { ComposableComponents } from '@jfdevelops/react-layout-composables';\nimport {\n type AnyBuiltPropDefinition,\n validateProps,\n} from '@jfdevelops/react-layout-validator';\nimport type { InPropsDefinition, InPropsObject } from '../../props';\nimport type { LayoutResourceKey, ResourceDefinition } from '../../resource';\nimport { capitalize } from '../../utils/capitalize';\nimport { LayoutConfigurationError } from '../../errors';\nimport type { LayoutIncludeProps } from '../define-layout';\nimport type {\n CapitalizedResource,\n ResourcesLayoutName,\n} from './resource-selection';\nimport type { CreateResourceLayoutForResourcesFn } from './scoped-layout';\nimport {\n isRenderableComponentType,\n reservedScopedComponentNames,\n resolveScopedRenderResult,\n type ScopedRenderResult,\n withScopedCompoundStatics,\n} from './scoped-render';\n\ntype CreateForResourcesOptions<\n Resources extends ReadonlyArray<ResourceDefinition>,\n> = {\n lazyEnvironment?: LazyEnvironment;\n createLayoutForResource: (\n defaultName: string | undefined,\n resource: LayoutResourceKey<Resources>,\n ) => unknown;\n createMakeComposableLayout?: () => (\n options: Record<string, unknown>,\n ) => unknown;\n createResourceLayout: (options: Record<string, unknown>) => unknown;\n getComponentPropDefinitions: (\n resource: LayoutResourceKey<Resources>,\n ) => Record<string, AnyBuiltPropDefinition>;\n};\n\nexport function createForResources<\n Resources extends ReadonlyArray<ResourceDefinition>,\n InProps extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, InProps, Composables>,\n CustomProps extends InPropsObject,\n>({\n createLayoutForResource,\n createMakeComposableLayout,\n createResourceLayout,\n getComponentPropDefinitions,\n lazyEnvironment,\n}: CreateForResourcesOptions<Resources>) {\n return ((...resourcesOrOptions: Array<unknown>) => {\n const firstArgument = resourcesOrOptions[0];\n let resourceOptions: Array<{\n resource: LayoutResourceKey<Resources>;\n name?:\n | string\n | ((\n resource: CapitalizedResource<LayoutResourceKey<Resources>>,\n ) => string);\n }>;\n\n if (typeof firstArgument === 'string') {\n resourceOptions = resourcesOrOptions.map((resource) => ({\n resource: resource as LayoutResourceKey<Resources>,\n }));\n } else if (\n firstArgument !== null &&\n typeof firstArgument === 'object' &&\n 'resources' in firstArgument &&\n Array.isArray(firstArgument.resources)\n ) {\n const { name, resources } = firstArgument as {\n name?: ResourcesLayoutName<LayoutResourceKey<Resources>>;\n resources: Array<LayoutResourceKey<Resources>>;\n };\n resourceOptions = resources.map((resource) => ({\n name: typeof name === 'function' ? name : name?.[resource],\n resource,\n }));\n } else {\n resourceOptions = Object.entries(firstArgument ?? {}).map(\n ([resource, options]) => ({\n ...(options as {\n name?:\n | string\n | ((\n resource: CapitalizedResource<LayoutResourceKey<Resources>>,\n ) => string);\n }),\n resource: resource as LayoutResourceKey<Resources>,\n }),\n );\n }\n\n const defaultNames = new Map(\n resourceOptions.map(({ name, resource }) => [\n resource,\n typeof name === 'function'\n ? name(\n capitalize(resource) as CapitalizedResource<\n LayoutResourceKey<Resources>\n >,\n )\n : name,\n ]),\n );\n\n function scopedCreateResourceLayout(options: Record<string, unknown>) {\n const resource = options.resource as LayoutResourceKey<Resources>;\n\n return createResourceLayout({\n ...options,\n name: options.name ?? defaultNames.get(resource),\n });\n }\n\n function scopedForResource(options: {\n name?: string;\n resource: LayoutResourceKey<Resources>;\n }) {\n return createLayoutForResource(\n options.name ?? defaultNames.get(options.resource),\n options.resource,\n );\n }\n\n type ScopedComponentRenderFn = (\n props: Record<string, unknown>,\n components: Record<string, (props?: never) => JSX.Element>,\n ) => ScopedRenderResult;\n\n type ScopedResourceScopedComponentDefinition = {\n props?: Record<string, AnyBuiltPropDefinition>;\n [scopedLazySymbol]?: LazyHandle;\n } & ScopedLazyContent<ScopedComponentRenderFn>;\n\n type ScopedComponentEntry = {\n [option: string]: unknown;\n name?: string;\n props?: CreateComponentPropsBag;\n components?: Record<string, ScopedResourceScopedComponentDefinition>;\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n };\n\n type CreateComponentPropsBag = {\n include?: Record<string, true | 'optional'>;\n custom?: Record<string, AnyBuiltPropDefinition>;\n defined?: Record<string, unknown>;\n };\n\n function normalizeContent<\n T extends {\n render?: ScopedComponentRenderFn;\n lazy?: unknown;\n fallback?: React.ReactNode;\n [scopedLazySymbol]?: LazyHandle;\n },\n >(\n definition: T,\n resource: string,\n label: string,\n ): T & {\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n } {\n if (definition.lazy !== undefined && definition.render !== undefined)\n throw new LayoutConfigurationError(\n `Scoped content \"${label}\" must define render or lazy, never both`,\n );\n if (definition[scopedLazySymbol])\n return definition as T & {\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n };\n if (definition.lazy === undefined) {\n if (typeof definition.render !== 'function')\n throw new LayoutConfigurationError(\n `Scoped content \"${label}\" requires render or lazy`,\n );\n return definition as T & {\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n };\n }\n const Content = createScopedLazyContent(\n definition as Parameters<typeof createScopedLazyContent>[0],\n resource,\n label,\n lazyEnvironment,\n );\n const result = {\n ...definition,\n lazy: undefined,\n render: (\n callProps: Record<string, unknown>,\n context: Record<string, (props?: never) => JSX.Element>,\n ) => createElement(Content, { callProps, context }),\n [scopedLazySymbol]: Content,\n };\n return withLazyHandle(result, Content) as T & {\n render: ScopedComponentRenderFn;\n [scopedLazySymbol]?: LazyHandle;\n };\n }\n\n function aggregateHandle(handles: LazyHandle[]): LazyHandle {\n let imports: Promise<void>[] = [];\n let pending: Promise<void> | undefined;\n return {\n preload() {\n const next = handles.map((handle) => handle.preload());\n if (\n !pending ||\n next.some((promise, index) => promise !== imports[index])\n ) {\n imports = next;\n pending = Promise.all(next).then(() => undefined);\n }\n return pending;\n },\n get status() {\n if (handles.some((handle) => handle.status === 'error'))\n return 'error';\n if (handles.some((handle) => handle.status === 'loading'))\n return 'loading';\n if (handles.some((handle) => handle.status === 'unresolved'))\n return 'unresolved';\n return 'resolved';\n },\n };\n }\n\n function mergeCreateComponentProps(\n ...bags: Array<CreateComponentPropsBag | undefined>\n ): CreateComponentPropsBag {\n const include: Record<string, true | 'optional'> = {};\n const custom: Record<string, AnyBuiltPropDefinition> = {};\n\n for (const bag of bags) {\n Object.assign(include, bag?.include);\n Object.assign(custom, bag?.custom);\n\n for (const key of Object.keys(bag?.defined ?? {})) {\n include[key] = true;\n }\n }\n\n return { include, custom };\n }\n\n function createComponent(componentOptions: {\n props?: {\n include?: Record<string, true | 'optional'>;\n custom?: Record<string, AnyBuiltPropDefinition>;\n };\n resources?: Record<string, ScopedComponentEntry>;\n render?: ScopedComponentRenderFn;\n lazy?: Parameters<typeof createScopedLazyContent>[0]['lazy'];\n fallback?: React.ReactNode;\n }) {\n const mergedProps = mergeCreateComponentProps(\n componentOptions.props,\n ...Object.values(componentOptions.resources ?? {}).map(\n (entry) => entry.props,\n ),\n );\n const include = mergedProps.include ?? {};\n const custom = mergedProps.custom ?? {};\n const selectedResources = new Set(\n resourceOptions.map(({ resource }) => resource),\n );\n const topLevelContent = new Map(\n [...selectedResources].map((resource) => [\n resource,\n normalizeContent(componentOptions, resource, `${resource}:content`),\n ]),\n );\n const componentPropsContext = createContext<\n Record<string, unknown> | undefined\n >(undefined);\n const definedEntries = new Map<\n LayoutResourceKey<Resources>,\n ScopedComponentEntry\n >();\n\n for (const [key, entry] of Object.entries(\n componentOptions.resources ?? {},\n )) {\n const resource = key as LayoutResourceKey<Resources>;\n\n if (!selectedResources.has(resource)) {\n throw new LayoutConfigurationError(\n `Resource \"${key}\" is not available in this scoped component`,\n );\n }\n\n const normalized = normalizeContent(entry, resource, resource);\n normalized.components = Object.fromEntries(\n Object.entries(entry.components ?? {}).map(([name, definition]) => [\n name,\n normalizeContent(definition, resource, `${resource}.${name}`),\n ]),\n );\n definedEntries.set(resource, normalized);\n }\n\n /** Resolved scoped components, per resource. */\n const resourceScopedComponents = new Map<\n LayoutResourceKey<Resources>,\n Record<string, (props?: never) => JSX.Element>\n >();\n const contextResources = new Map<string, LayoutResourceKey<Resources>>();\n const renderContext: Record<string, (props: never) => JSX.Element> =\n Object.fromEntries(\n [...definedEntries].map(([resource, entry]) => {\n const contextKey = capitalize(resource);\n\n if (contextKey === 'Root') {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" maps to the reserved render context key \"Root\"`,\n );\n }\n\n const existingResource = contextResources.get(contextKey);\n\n if (existingResource !== undefined) {\n throw new LayoutConfigurationError(\n `Resources \"${existingResource}\" and \"${resource}\" both map to render context key \"${contextKey}\"`,\n );\n }\n\n contextResources.set(contextKey, resource);\n\n /**\n * Built once per resource so every scoped component keeps a stable\n * identity, and shared by the resource render, the render context,\n * and any component bound through `asHOF()`.\n */\n const scopedComponents: Record<\n string,\n (props?: never) => JSX.Element\n > = {};\n\n for (const [name, definition] of Object.entries(\n entry.components ?? {},\n )) {\n if (reservedScopedComponentNames.has(name)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" for resource \"${resource}\" uses a reserved name`,\n );\n }\n\n const ownPropDefinitions = definition.props ?? {};\n // Last call-site own-props / returned component for this scoped\n // entry. Compound statics re-run `render` with these so\n // `<DataTable variant=\"b\" />` then `<DataTable.Loading />` sees \"b\".\n let cachedOwnProps: Record<string, unknown> = {};\n let cachedState: string | undefined;\n let cachedReturnedComponent:\n | ComponentType<Record<string, unknown>>\n | undefined;\n\n function ScopedComponent(ownProps?: Record<string, unknown>) {\n const state = useContext(RenderStateNameContext);\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" must be rendered inside its scoped component`,\n );\n }\n\n const resolvedOwnProps = ownProps ?? {};\n cachedOwnProps = resolvedOwnProps;\n\n validateProps(ownPropDefinitions, resolvedOwnProps, {\n layoutName:\n entry.name ??\n defaultNames.get(resource) ??\n capitalize(resource),\n resource,\n });\n\n // Mount a returned component type with call-site props; pass\n // nodes (elements, portals, null) through unchanged.\n const result = definition.render!(\n { ...componentProps, ...resolvedOwnProps, resource },\n { ...scopedComponents, state } as unknown as typeof scopedComponents,\n );\n\n if (isRenderableComponentType(result)) {\n cachedState = state;\n cachedReturnedComponent = result as ComponentType<\n Record<string, unknown>\n >;\n }\n\n return resolveScopedRenderResult(result, resolvedOwnProps);\n }\n\n // Types expose compound statics from the returned component\n // (`DataTable.Loading`); attach matching runtime wrappers.\n if (definition[scopedLazySymbol])\n withLazyHandle(ScopedComponent, definition[scopedLazySymbol]);\n scopedComponents[name] = withScopedCompoundStatics(\n ScopedComponent,\n (staticName) => {\n function CompoundStatic(ownProps?: Record<string, unknown>) {\n const state = useContext(RenderStateNameContext);\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}.${staticName}\" must be rendered inside its scoped component`,\n );\n }\n\n // Prefer the component from the last parent call (same\n // closure as that call's own-props). Fall back to re-running\n // render with cached parent props when needed.\n let result: unknown = cachedState === state ? cachedReturnedComponent : undefined;\n\n if (!isRenderableComponentType(result)) {\n result = definition.render!(\n {\n ...componentProps,\n ...cachedOwnProps,\n resource,\n },\n { ...scopedComponents, state } as unknown as typeof scopedComponents,\n );\n }\n\n if (!isRenderableComponentType(result)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" must return a component type to use static \"${staticName}\"`,\n );\n }\n\n const staticComponent = (\n result as ComponentType<Record<string, unknown>> &\n Record<string, unknown>\n )[staticName];\n\n if (!isRenderableComponentType(staticComponent)) {\n throw new LayoutConfigurationError(\n `Scoped component \"${name}\" has no component static \"${staticName}\"`,\n );\n }\n\n // Loading's props — those mount the static itself.\n return createElement(staticComponent, ownProps ?? {});\n }\n\n CompoundStatic.displayName = `${name}.${staticName}`;\n return CompoundStatic;\n },\n ) as (props?: never) => JSX.Element;\n }\n\n resourceScopedComponents.set(resource, scopedComponents);\n\n function ResourceRender(ownProps?: Record<string, unknown>) {\n const state = useContext(RenderStateNameContext);\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n `Render context component \"${contextKey}\" must be rendered inside its scoped component`,\n );\n }\n\n // Call-site props on `context.Users({ title, heading })` merge into\n // the resource render props and mount a returned component type.\n const callProps = { ...componentProps, ...ownProps, resource };\n return resolveScopedRenderResult(\n entry.render(callProps, { ...scopedComponents, state } as unknown as typeof scopedComponents),\n ownProps,\n );\n }\n\n return [\n contextKey,\n withLazyHandle(\n Object.assign(ResourceRender, scopedComponents),\n aggregateHandle([\n ...(entry[scopedLazySymbol] ? [entry[scopedLazySymbol]] : []),\n ...Object.values(entry.components ?? {}).flatMap(\n (definition) =>\n definition[scopedLazySymbol]\n ? [definition[scopedLazySymbol]]\n : [],\n ),\n ]),\n ),\n ];\n }),\n );\n\n /**\n * Layouts are created once per resource and cached. Creating one during\n * render would hand React a new component type on every pass, remounting\n * the whole subtree.\n */\n const roots = new Map<\n LayoutResourceKey<Resources>,\n (props: Record<string, unknown>) => JSX.Element\n >();\n\n function Root(rootProps: Record<string, unknown>) {\n const componentProps = useContext(componentPropsContext);\n\n if (componentProps === undefined) {\n throw new LayoutConfigurationError(\n 'Render context component \"Root\" must be rendered inside its scoped component',\n );\n }\n\n const resource =\n componentProps.resource as LayoutResourceKey<Resources>;\n let root = roots.get(resource);\n\n if (root === undefined) {\n const entry = definedEntries.get(resource);\n\n if (entry === undefined) {\n throw new LayoutConfigurationError(\n `Render context component \"Root\" requires a \"resources.${resource}\" entry to build the layout for resource \"${resource}\"`,\n );\n }\n\n // Layout option values come from the outer component call site\n // (`<Directory title=\"…\" />`), not from the resource entry.\n const availableDefinitions = getComponentPropDefinitions(resource);\n const layoutOptions: Record<string, unknown> = {};\n const defined = entry.props?.defined ?? {};\n\n for (const key of Object.keys(availableDefinitions)) {\n if (key in defined) {\n layoutOptions[key] = defined[key];\n }\n\n const capitalized = capitalize(key);\n if (capitalized in defined) {\n layoutOptions[capitalized] = defined[capitalized];\n }\n\n if (key in componentProps) {\n layoutOptions[key] = componentProps[key];\n }\n\n if (capitalized in componentProps) {\n layoutOptions[capitalized] = componentProps[capitalized];\n }\n }\n\n root = scopedCreateResourceLayout({\n ...layoutOptions,\n namespace: false,\n name:\n entry.name ?? defaultNames.get(resource) ?? capitalize(resource),\n resource,\n }) as (props: Record<string, unknown>) => JSX.Element;\n roots.set(resource, root);\n }\n\n const entry = definedEntries.get(resource);\n const definedCustom: Record<string, unknown> = {};\n const forwardedRootProps: Record<string, unknown> = {};\n\n for (const key of Object.keys(getComponentPropDefinitions(resource))) {\n if (key in componentProps) {\n forwardedRootProps[key] = componentProps[key];\n }\n\n const capitalized = capitalize(key);\n if (capitalized in componentProps) {\n forwardedRootProps[capitalized] = componentProps[capitalized];\n }\n }\n\n for (const [key, value] of Object.entries(\n entry?.props?.defined ?? {},\n )) {\n if (key in custom) {\n definedCustom[key] = value;\n }\n }\n\n return createElement(root, {\n ...forwardedRootProps,\n ...definedCustom,\n ...rootProps,\n });\n }\n\n renderContext.Root = Root;\n\n function Component(componentProps: Record<string, unknown>) {\n const state = useContext(RenderStateNameContext);\n const componentResource =\n componentProps.resource as LayoutResourceKey<Resources>;\n\n if (!selectedResources.has(componentResource)) {\n throw new LayoutConfigurationError(\n `Resource \"${componentResource}\" is not available in this scoped component`,\n );\n }\n\n const defined =\n definedEntries.get(componentResource)?.props?.defined ?? {};\n const resolvedComponentProps = { ...defined, ...componentProps };\n const availableDefinitions =\n getComponentPropDefinitions(componentResource);\n const definitionsToValidate: Record<string, AnyBuiltPropDefinition> =\n {};\n\n for (const [key, inclusion] of Object.entries(include)) {\n const definition = availableDefinitions[key];\n\n if (!definition) {\n continue;\n }\n\n // Keep declared keys as-is — do not capitalize JSX.Element props.\n if (inclusion === true || key in resolvedComponentProps) {\n definitionsToValidate[key] = definition;\n }\n }\n\n for (const [key, definition] of Object.entries(custom)) {\n if (key === 'children' || key === 'resource') {\n continue;\n }\n\n definitionsToValidate[key] = definition;\n }\n\n validateProps(definitionsToValidate, resolvedComponentProps, {\n layoutName:\n definedEntries.get(componentResource)?.name ??\n defaultNames.get(componentResource) ??\n capitalize(componentResource),\n resource: componentResource,\n });\n\n // Top-level render may return a component type; mount it with the full\n // component props (include/custom + inferred return-type props).\n return createElement(\n componentPropsContext.Provider,\n { value: resolvedComponentProps },\n resolveScopedRenderResult(\n topLevelContent\n .get(componentResource)!\n .render(\n resolvedComponentProps,\n { ...renderContext, state } as unknown as Record<string, (props?: never) => JSX.Element>,\n ),\n resolvedComponentProps,\n ),\n );\n }\n\n /**\n * Bound components are created once per resource and cached. Returning a\n * fresh component from the factory would hand React a new component type\n * whenever the caller rebinds, remounting the subtree.\n */\n const boundComponents = new Map<\n LayoutResourceKey<Resources>,\n (props: Record<string, unknown>) => JSX.Element\n >();\n\n function bindResource(resource: LayoutResourceKey<Resources>) {\n if (!selectedResources.has(resource)) {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" is not available in this scoped component`,\n );\n }\n\n let boundComponent = boundComponents.get(resource);\n\n if (boundComponent === undefined) {\n boundComponent = Object.assign(\n (boundProps: Record<string, unknown>) =>\n createElement(Component, { ...boundProps, resource }),\n {\n displayName: `ScopedResourceComponent(${resource})`,\n props: undefined,\n resource: undefined,\n },\n resourceScopedComponents.get(resource) ?? {},\n );\n if (createMakeComposableLayout) {\n Object.assign(boundComponent, {\n makeComposable: (options: Record<string, unknown> = {}) =>\n scopedExtras.makeComposable?.({ ...options, resource }),\n });\n }\n const renderResource = renderContext[\n capitalize(resource)\n ] as unknown as LazyHandle;\n const ownContent = topLevelContent.get(resource)?.[scopedLazySymbol];\n withLazyHandle(\n boundComponent,\n aggregateHandle([\n ...(renderResource ? [renderResource] : []),\n ...(ownContent ? [ownContent] : []),\n ]),\n );\n boundComponents.set(resource, boundComponent);\n }\n\n return boundComponent;\n }\n\n function asHOF() {\n return bindResource;\n }\n\n withLazyHandle(\n Component,\n aggregateHandle([\n ...(Object.values(renderContext).filter(\n (value) => 'preload' in value,\n ) as unknown as LazyHandle[]),\n ...[...topLevelContent.values()].flatMap((entry) =>\n entry[scopedLazySymbol] ? [entry[scopedLazySymbol]] : [],\n ),\n ]),\n );\n return Object.assign(Component, {\n asHOF,\n displayName: 'ScopedResourceComponent',\n props: undefined,\n });\n }\n\n function createComponentSetProps(baseProps: CreateComponentPropsBag) {\n function createWithProps(componentOptions: {\n props?: CreateComponentPropsBag;\n resources?: Record<string, ScopedComponentEntry>;\n render: (\n props: Record<string, unknown>,\n context: Record<string, (props: never) => JSX.Element>,\n ) => ScopedRenderResult;\n }) {\n return createComponent({\n ...componentOptions,\n props: mergeCreateComponentProps(baseProps, componentOptions.props),\n });\n }\n\n createWithProps.createResourceComponents = createResourceComponents;\n\n return createWithProps;\n }\n\n function createResourceComponents(options: {\n resource: LayoutResourceKey<Resources>;\n props?: CreateComponentPropsBag;\n name?: string;\n components?: Record<string, ScopedResourceScopedComponentDefinition>;\n render?: ScopedComponentRenderFn;\n lazy?: Parameters<typeof createScopedLazyContent>[0]['lazy'];\n fallback?: React.ReactNode;\n }) {\n const { resource, props, ...entry } = options;\n\n if (\n !resourceOptions.some(\n (resourceOption) => resourceOption.resource === resource,\n )\n ) {\n throw new LayoutConfigurationError(\n `Resource \"${resource}\" is not available in this scoped component`,\n );\n }\n\n const normalized = normalizeContent(entry, resource, String(resource));\n const components = Object.fromEntries(\n Object.entries(normalized.components ?? {}).map(\n ([name, definition]) => [\n name,\n normalizeContent(definition, resource, `${resource}.${name}`),\n ],\n ),\n );\n const result = { ...normalized, components, props: props ?? {} };\n return withLazyHandle(\n result,\n aggregateHandle([\n ...(normalized[scopedLazySymbol]\n ? [normalized[scopedLazySymbol]]\n : []),\n ...Object.values(components).flatMap((definition) =>\n definition[scopedLazySymbol] ? [definition[scopedLazySymbol]] : [],\n ),\n ]),\n );\n }\n\n Object.assign(createComponent, {\n setProps: createComponentSetProps,\n });\n\n const scopedExtras: {\n createComponent: typeof createComponent;\n createResourceComponents: typeof createResourceComponents;\n forResource: typeof scopedForResource;\n makeComposable?: (options: Record<string, unknown>) => unknown;\n resources: undefined;\n } = {\n createComponent,\n createResourceComponents,\n forResource: scopedForResource,\n resources: undefined,\n };\n\n if (createMakeComposableLayout) {\n const makeComposableLayout = createMakeComposableLayout();\n\n scopedExtras.makeComposable = (options) => {\n const resource = options.resource as LayoutResourceKey<Resources>;\n\n return makeComposableLayout({\n ...options,\n name: options.name ?? defaultNames.get(resource),\n });\n };\n }\n\n return Object.assign(scopedCreateResourceLayout, scopedExtras);\n }) as unknown as CreateResourceLayoutForResourcesFn<\n Resources,\n InProps,\n Composables,\n IncludeProps,\n CustomProps\n >;\n}\n"],"mappings":";;;;;;;;;;AAwDA,SAAgB,mBAMd,EACA,yBACA,4BACA,sBACA,6BACA,mBACuC;CACvC,SAAS,GAAG,uBAAuC;EACjD,MAAM,gBAAgB,mBAAmB;EACzC,IAAI;EASJ,IAAI,OAAO,kBAAkB,UAC3B,kBAAkB,mBAAmB,KAAK,cAAc,EAC5C,SACZ,EAAE;OACG,IACL,kBAAkB,QAClB,OAAO,kBAAkB,YACzB,eAAe,iBACf,MAAM,QAAQ,cAAc,SAAS,GACrC;GACA,MAAM,EAAE,MAAM,cAAc;GAI5B,kBAAkB,UAAU,KAAK,cAAc;IAC7C,MAAM,OAAO,SAAS,aAAa,OAAO,OAAO;IACjD;GACF,EAAE;EACJ,OACE,kBAAkB,OAAO,QAAQ,iBAAiB,CAAC,CAAC,EAAE,KACnD,CAAC,UAAU,cAAc;GACxB,GAAI;GAOM;EACZ,EACF;EAGF,MAAM,eAAe,IAAI,IACvB,gBAAgB,KAAK,EAAE,MAAM,eAAe,CAC1C,UACA,OAAO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component render function.
75
75
  * @returns A component scoped to the selected resources.
76
76
  */
77
- createComponent: ScopedCreateComponent<Resources, InProps, Composables, Arguments, CustomProps>; /** Builds one reusable entry for the selected resources. */
78
- createResourceComponents: ScopedCreateResourceComponents<Resources, InProps, Composables, Arguments, CustomProps, {}, {}>;
77
+ createComponent: ScopedCreateComponent<Resources, InProps, Composables, Arguments, CustomProps, 'default' | Extract<keyof States, string>>; /** Builds one reusable entry for the selected resources. */
78
+ createResourceComponents: ScopedCreateResourceComponents<Resources, InProps, Composables, Arguments, CustomProps, {}, {}, 'default' | Extract<keyof States, string>>;
79
79
  forResource: ScopedCreateLayoutForResource<Resources, InProps, Composables, IncludeProps, Arguments, CustomProps, DefaultNamespace, States, DefaultNaming>;
80
80
  /**
81
81
  * Type-only property containing the target resource union. This property is
@@ -1 +1 @@
1
- {"version":3,"file":"scoped-layout.d.cts","names":[],"sources":["../../../src/create-config/for-resources/scoped-layout.ts"],"mappings":";;;;;;;;;;KA0CY,iCAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,uBACC,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,qBAC1C,aAAA,iDAED,uBAAA,CAAwB,SAAA,EAAW,SAAA,iBACtC,aAAA,IACZ,sBAAA,CAAuB,SAAA,EAAW,OAAA,EAAS,WAAA,EAAa,YAAA;EAC1D,QAAA,EAAU,QAAA;EACV,KAAA,GAAQ,KAAA;EACR,IAAA,GAAO,IAAA;AAAA;AAAA,KAGG,gCAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,uBACC,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,qBAC1C,aAAA,+BACE,aAAA,+EAGE,eAAA,wDAEL,uBAAA,CAAwB,SAAA,EAAW,SAAA,yBAC9B,0BAAA,CACpB,SAAA,EAAW,QAAA,EAAU,aAAA,iBAET,aAAA,mCACc,gBAA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AAA,IAChB,4BAAA,CACD,SAAA,EACA,OAAA,EACA,WAAA,EACA,YAAA,EACA,6BAAA,CAA8B,SAAA,EAAW,YAAA,EAAc,IAAA,GACvD,WAAA,EACA,gBAAA,EACA,MAAA,EACA,aAAA;EAjWA;;;;;;;;;;;;;EAAA,4DAmXwB,uBAAA,CAAwB,SAAA,EAAW,YAAA,GAE3D,OAAA,EAAS,SAAA,GACP,iCAAA,CAAkC,SAAA,EAAW,YAAA,IAC7C,OAAA,CACE,MAAA,CAAO,OAAA,cAAqB,iBAAA,CAAkB,SAAA,cAEhD,MAAA,CAAO,OAAA,OAAc,SAAA,EAAW,iBAAA,CAAkB,SAAA,aACnD,4BAAA,CACD,SAAA,EACA,OAAA,EACA,WAAA,EACA,YAAA,EACA,+BAAA,CAAgC,SAAA,GAChC,WAAA,EACA,gBAAA,EACA,MAAA,EACA,aAAA;AAAA"}
1
+ {"version":3,"file":"scoped-layout.d.cts","names":[],"sources":["../../../src/create-config/for-resources/scoped-layout.ts"],"mappings":";;;;;;;;;;KA0CY,iCAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,uBACC,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,qBAC1C,aAAA,iDAED,uBAAA,CAAwB,SAAA,EAAW,SAAA,iBACtC,aAAA,IACZ,sBAAA,CAAuB,SAAA,EAAW,OAAA,EAAS,WAAA,EAAa,YAAA;EAC1D,QAAA,EAAU,QAAA;EACV,KAAA,GAAQ,KAAA;EACR,IAAA,GAAO,IAAA;AAAA;AAAA,KAGG,gCAAA,mBACQ,aAAA,CAAc,kBAAA,mBAChB,iBAAA,CAAkB,SAAA,uBACd,oBAAA,uBACC,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,qBAC1C,aAAA,+BACE,aAAA,+EAGE,eAAA,wDAEL,uBAAA,CAAwB,SAAA,EAAW,SAAA,yBAC9B,0BAAA,CACpB,SAAA,EAAW,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IAAA,GAAO,QAAA,EAAU,mBAAA,CAAoB,YAAA,cAA0B,IAAA;EAAA;IAC3D,SAAA,EAAW,YAAA;EAAA,IAChB,4BAAA,CACD,SAAA,EACA,OAAA,EACA,WAAA,EACA,YAAA,EACA,6BAAA,CAA8B,SAAA,EAAW,YAAA,EAAc,IAAA,GACvD,WAAA,EACA,gBAAA,EACA,MAAA,EACA,aAAA;EAnWA;;;;;;;;;;;;;EAAA,4DAqXwB,uBAAA,CAAwB,SAAA,EAAW,YAAA,GAE3D,OAAA,EAAS,SAAA,GACP,iCAAA,CAAkC,SAAA,EAAW,YAAA,IAC7C,OAAA,CACE,MAAA,CAAO,OAAA,cAAqB,iBAAA,CAAkB,SAAA,cAEhD,MAAA,CAAO,OAAA,OAAc,SAAA,EAAW,iBAAA,CAAkB,SAAA,aACnD,4BAAA,CACD,SAAA,EACA,OAAA,EACA,WAAA,EACA,YAAA,EACA,+BAAA,CAAgC,SAAA,GAChC,WAAA,EACA,gBAAA,EACA,MAAA,EACA,aAAA;AAAA"}
@@ -74,8 +74,8 @@ type ScopedCreateResourceLayoutFn<Resources extends ReadonlyArray<ResourceDefini
74
74
  * shared component render function.
75
75
  * @returns A component scoped to the selected resources.
76
76
  */
77
- createComponent: ScopedCreateComponent<Resources, InProps, Composables, Arguments, CustomProps>; /** Builds one reusable entry for the selected resources. */
78
- createResourceComponents: ScopedCreateResourceComponents<Resources, InProps, Composables, Arguments, CustomProps, {}, {}>;
77
+ createComponent: ScopedCreateComponent<Resources, InProps, Composables, Arguments, CustomProps, 'default' | Extract<keyof States, string>>; /** Builds one reusable entry for the selected resources. */
78
+ createResourceComponents: ScopedCreateResourceComponents<Resources, InProps, Composables, Arguments, CustomProps, {}, {}, 'default' | Extract<keyof States, string>>;
79
79
  forResource: ScopedCreateLayoutForResource<Resources, InProps, Composables, IncludeProps, Arguments, CustomProps, DefaultNamespace, States, DefaultNaming>;
80
80
  /**
81
81
  * Type-only property containing the target resource union. This property is