@jfdevelops/react-layout 2.3.0 → 2.4.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 (31) hide show
  1. package/dist/create-config/create-defined-resource-layout.cjs.map +1 -1
  2. package/dist/create-config/create-defined-resource-layout.d.cts +1 -1
  3. package/dist/create-config/create-defined-resource-layout.d.cts.map +1 -1
  4. package/dist/create-config/create-defined-resource-layout.d.mts +1 -1
  5. package/dist/create-config/create-defined-resource-layout.d.mts.map +1 -1
  6. package/dist/create-config/create-defined-resource-layout.mjs.map +1 -1
  7. package/dist/create-config/create-reusable.cjs +185 -21
  8. package/dist/create-config/create-reusable.cjs.map +1 -1
  9. package/dist/create-config/create-reusable.d.cts +1 -41
  10. package/dist/create-config/create-reusable.d.mts +1 -41
  11. package/dist/create-config/create-reusable.mjs +185 -21
  12. package/dist/create-config/create-reusable.mjs.map +1 -1
  13. package/dist/create-config/index.d.cts +1 -1
  14. package/dist/create-config/index.d.mts +1 -1
  15. package/dist/create-config/merge-layout-props.cjs.map +1 -1
  16. package/dist/create-config/merge-layout-props.mjs.map +1 -1
  17. package/dist/create-config/reusable-types.d.cts +131 -0
  18. package/dist/create-config/reusable-types.d.cts.map +1 -0
  19. package/dist/create-config/reusable-types.d.mts +131 -0
  20. package/dist/create-config/reusable-types.d.mts.map +1 -0
  21. package/dist/index.d.cts +3 -3
  22. package/dist/index.d.mts +3 -3
  23. package/dist/props.cjs.map +1 -1
  24. package/dist/props.d.cts +6 -1
  25. package/dist/props.d.cts.map +1 -1
  26. package/dist/props.d.mts +6 -1
  27. package/dist/props.d.mts.map +1 -1
  28. package/dist/props.mjs.map +1 -1
  29. package/package.json +2 -2
  30. package/dist/create-config/create-reusable.d.cts.map +0 -1
  31. package/dist/create-config/create-reusable.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"create-defined-resource-layout.cjs","names":["defineResourceLayout","LayoutConfigurationError","createLazyRenderStateBuilder","lazyDefaultsSymbol","layoutDebug","mergeLayoutProps","inspectLazy","createLazyResourceLayout","layoutInspection","createReusableBuilder","createRenderStateBuilder","createLayoutResourcesAccessor"],"sources":["../../src/create-config/create-defined-resource-layout.ts"],"sourcesContent":["import type {\n CustomPropsInput,\n CustomPropsObject,\n} from '../custom-props';\nimport { createReusableBuilder, type CreateReusable } from './create-reusable';\nimport { inspectLazy } from '../lazy/inspection';\nimport type { ResourcePath } from '../resource';\nimport { createLazyRenderStateBuilder, type CreateLazyRenderState, type CreateBoundLazyErrorComponent } from '../lazy/create-render-state';\nimport { lazyDefaultsSymbol } from '../lazy/types';\nimport type { LazyResourceError } from '../errors/lazy-resource-error';\nimport {\n getLayoutDebug,\n layoutDebug,\n createInspectionStore,\n layoutInspection,\n getInspectionSource,\n} from '@jfdevelops/react-layout-devtools-core';\nimport { mergeLayoutProps } from './merge-layout-props';\nimport type { LayoutNameInput } from './layout-name';\nimport type { MergeContract } from './define-layout';\nimport type {\n ComposableComponents,\n CreateLayoutComposable,\n} from '@jfdevelops/react-layout-composables';\nimport { LayoutConfigurationError } from '../errors';\nimport type { InPropsDefinition } from '../props';\nimport type { LayoutResourceKey, ResourceDefinition } from '../resource';\nimport {\n type CreateViewMapFunctionRenderOptions,\n type DefinedResourceLayout,\n defineResourceLayout,\n type LayoutIncludeProps,\n type LayoutResourcesAccessor,\n type CreateViewMapRenderStatesOptions,\n type DefinedResourceLayoutFromStates,\n createLayoutResourcesAccessor,\n} from './define-layout';\nimport {\n createLazyResourceLayout,\n type LazyResourceLayoutOptions,\n type LazyResourceStates,\n} from './lazy-resource-layout';\nimport {\n createRenderStateBuilder,\n type CreateRenderState,\n type RenderStateContext,\n type RenderStateReferences,\n type LayoutComposablesDefinition,\n} from './render-state';\n\n/** A resource tuple with at least one entry, preserving literal and nested paths. */\nexport type NonEmptyResources = readonly [\n ResourceDefinition,\n ...ResourceDefinition[]\n];\n\n/** Configuration shared by every layout created from one defined-layout factory. */\nexport type CreateDefinedResourceLayoutOptions<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n namespace?: DefaultNamespace;\n /** Default naming convention; explicit definition and component names override it. */\n name?: DefaultNaming;\n /** Shared prop contracts, merged by key with layout and state contracts. */\n props?: {\n include?: LayoutIncludeProps<Resources, Options, Composables> & SharedInclude;\n custom?: SharedCustom & CustomPropsInput<SharedCustom>;\n };\n /** Resources supported by every layout created from this factory. */\n resources: Resources;\n /** Props that render states can opt into through `props.include`. */\n options?: Options;\n /** Layout-wide composables available to every render state. */\n composables?: LayoutComposablesDefinition<Resources, Composables>;\n};\n\n/** The flat layout definition accepted after shared configuration is bound. */\nexport type DefinedResourceLayoutInput<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, Options, Composables>,\n CustomProps extends CustomPropsObject,\n Render,\n Namespace extends boolean = false\n> = Omit<\n CreateViewMapFunctionRenderOptions<\n Resources,\n Options,\n Composables,\n IncludeProps,\n CustomProps\n >['layout'],\n 'composables' | 'render'\n> & { render: Render; namespace?: Namespace };\n\ntype BoundLayoutComposables<\n Shared extends ComposableComponents,\n Local extends ComposableComponents\n> = Omit<Shared, keyof Local> & Local;\n\n/** Flattens a definition's layout while preserving its namespace setting. */\ntype BoundLayoutInput<\n Definition extends { layout: unknown; namespace?: boolean }\n> = Definition['layout'] &\n Pick<Definition, 'namespace'> &\n (Definition extends { name?: infer Name } ? { name?: Name } : {});\n\n/** A `defineResourceLayout` function with its shared configuration pre-bound. */\nexport type BoundDefineResourceLayout<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n /**\n * Defines a layout whose `render` map contains the required `default` state\n * and any built-in or custom compound component states.\n * Keep this overload first so incomplete render objects suggest state keys.\n * Use `createRenderState` for state-local `composables(create)` callbacks;\n * the helper infers their render context independently of the enclosing map.\n */\n <\n const Render extends { default: unknown } & Record<string, unknown>,\n LocalComposables extends ComposableComponents = {},\n Namespace extends boolean = DefaultNamespace,\n const IncludeProps extends LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > = {},\n CustomProps extends CustomPropsObject = {},\n const Naming extends\n | LayoutNameInput<\n LayoutResourceKey<Resources>,\n ('default' | keyof Render) & string\n >\n | undefined = DefaultNaming\n >(\n layout: Omit<\n BoundLayoutInput<\n CreateViewMapRenderStatesOptions<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Render,\n Namespace\n >\n >,\n 'composables' | 'name' | 'props'\n > & {\n name?: Naming;\n props?: {\n include?: LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > & IncludeProps;\n custom?: CustomProps & CustomPropsInput<CustomProps>;\n };\n composables?: (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: RenderStateReferences<Resources, Options, Composables, Render>\n ) => LocalComposables;\n }\n ): DefinedResourceLayoutFromStates<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n Render,\n Namespace,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Naming\n >;\n /** Defines a layout whose `render` value is a single default-state callback. */\n <\n const IncludeProps extends LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > = {},\n CustomProps extends CustomPropsObject = {},\n LocalComposables extends ComposableComponents = {},\n Namespace extends boolean = DefaultNamespace,\n const Naming extends\n | LayoutNameInput<LayoutResourceKey<Resources>, 'default'>\n | undefined = DefaultNaming\n >(\n layout: Omit<\n BoundLayoutInput<\n CreateViewMapFunctionRenderOptions<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Namespace\n >\n >,\n 'composables' | 'name' | 'props'\n > & {\n name?: Naming;\n props?: {\n include?: LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > & IncludeProps;\n custom?: CustomProps & CustomPropsInput<CustomProps>;\n };\n composables?: (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: {}\n ) => LocalComposables;\n }\n ): DefinedResourceLayout<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n {},\n Namespace,\n Naming\n >;\n /**\n * Creates a lazy proxy for the single library-defined component exported by\n * a resource module.\n *\n * @param options - Resource path and named-module import callback.\n */\n lazy<Module extends Record<string, unknown>>(\n options: LazyResourceLayoutOptions<Resources, Module>\n ): ReturnType<typeof createLazyResourceLayout<Resources, Module>>;\n};\n\n/** Registers loading and module-error components used by lazy layouts. */\nexport type DefineLazyDefaults<\n Resource = string,\n Resources extends ReadonlyArray<ResourceDefinition> = ReadonlyArray<ResourceDefinition>,\n Options extends InPropsDefinition<Resources> = {},\n Composables extends ComposableComponents = {},\n> = {\n /**\n * Sets defaults before the first lazy layout. Development reloads may replace them.\n *\n * @param defaults - Shared components for pending module loads and failures.\n */\n (defaults: LazyResourceStates<Resource>): void;\n readonly errors: LazyResourceError;\n createRenderState: CreateLazyRenderState<Resources, Options, Composables>;\n /** @deprecated Use createRenderState({ state: 'Error', render }) instead. */\n createErrorComponent: CreateBoundLazyErrorComponent<Resource, RenderStateContext<Composables, Resources, 'Error'>>;\n};\n\n/** Reusable helpers produced by {@link createDefinedResourceLayout}. */\nexport type CreateDefinedResourceLayoutResult<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n /** Creates a custom logic function with selected options and custom props. */\n createReusable: CreateReusable<Resources, Options>;\n /** Creates eager, deferred, or separately imported render-state fragments. */\n createRenderState: CreateRenderState<\n Resources,\n Options,\n Composables,\n SharedInclude,\n SharedCustom\n >;\n /** Sets the shared loading and module-error UI used by lazy layouts. */\n defineLazyDefaults: DefineLazyDefaults<ResourcePath<Resources>, Resources, Options, Composables>;\n /** Defines a layout using the resources, options, and composables already bound. */\n defineResourceLayout: BoundDefineResourceLayout<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefaultNaming\n >;\n /** Reads, selects, or validates the resources bound to this factory. */\n resources: LayoutResourcesAccessor<Resources>;\n};\n\n/**\n * A configuration that may omit its name cannot guarantee a naming default.\n */\ntype DefinedFactoryNaming<Naming> = undefined extends Naming ? undefined : Naming;\n\n/**\n * Creates type-linked layout helpers from one shared configuration. The returned\n * `defineResourceLayout` accepts the layout directly, while `createRenderState`\n * carries the same resource and option types across file boundaries.\n *\n * @param configuration - Resources and optional shared props/composables to\n * bind to every returned helper.\n * @returns Helpers that share the configuration's inferred literal types.\n *\n * @example\n * ```tsx\n * const { createRenderState, defineResourceLayout } =\n * createDefinedResourceLayout({\n * resources: ['users'],\n * options: { title: createProp.string() },\n * });\n *\n * const Loading = createRenderState({\n * state: 'Loading',\n * props: { include: { title: true } },\n * render: ({ title }) => <p>Loading {title}</p>,\n * });\n *\n * export const usersLayout = defineResourceLayout({\n * render: { default: () => <Users />, ...Loading },\n * });\n * ```\n */\nexport function createDefinedResourceLayout<\n const Resources extends NonEmptyResources,\n const Options extends InPropsDefinition<Resources> = {},\n Composables extends ComposableComponents = {},\n DefaultNamespace extends boolean = false,\n const SharedInclude extends object = {},\n const SharedCustom extends CustomPropsObject = {},\n const DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = LayoutNameInput<LayoutResourceKey<Resources>> | undefined\n>(\n configuration: CreateDefinedResourceLayoutOptions<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefaultNaming\n >\n): CreateDefinedResourceLayoutResult<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefinedFactoryNaming<DefaultNaming>\n> {\n const { resources, options = {} as Options, composables } = configuration;\n const defineBoundLayout = defineResourceLayout.forResources(...resources);\n const inspection = createInspectionStore();\n let lazyDefaults: LazyResourceStates<ResourcePath<Resources>> = {};\n let lazyDefaultsDefined = false;\n let lazyLayoutCreated = false;\n\n function defineLazyDefaults(\n defaults: LazyResourceStates<ResourcePath<Resources>>\n ): void {\n const replacingInDevelopment = lazyDefaultsDefined && process.env.NODE_ENV !== 'production';\n if (lazyDefaultsDefined && !replacingInDevelopment) {\n throw new LayoutConfigurationError(\n 'Lazy resource defaults can only be defined once.'\n );\n }\n\n if (lazyLayoutCreated && !replacingInDevelopment) {\n throw new LayoutConfigurationError(\n 'Lazy resource defaults must be defined before creating a lazy resource layout.'\n );\n }\n\n lazyDefaults = defaults;\n\n lazyDefaultsDefined = true;\n }\n\n Object.defineProperty(defineLazyDefaults, 'errors', {\n value: undefined,\n enumerable: false,\n });\n defineLazyDefaults.createRenderState = createLazyRenderStateBuilder({ resources, options, composables });\n defineLazyDefaults.createErrorComponent = ((render: any) =>\n defineLazyDefaults.createRenderState({ state: 'Error', render })\n ) as CreateBoundLazyErrorComponent<ResourcePath<Resources>, RenderStateContext<Composables, Resources, 'Error'>>;\n\n const boundDefineResourceLayout = ((layout: Record<string, unknown>) => {\n const localComposables = layout.composables as\n | LayoutComposablesDefinition<Resources, ComposableComponents>\n | undefined;\n const definition = defineBoundLayout({\n [lazyDefaultsSymbol]: () => lazyDefaults,\n [layoutDebug]: getLayoutDebug(layout) ?? getLayoutDebug(configuration),\n options,\n name: layout.name ?? configuration.name,\n namespace: layout.namespace ?? configuration.namespace,\n layout: {\n ...layout,\n props: mergeLayoutProps(\n configuration.props,\n layout.props as { include?: object; custom?: object }\n ),\n composables:\n composables || localComposables\n ? (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: {}\n ) => ({\n ...composables?.(create, states),\n ...localComposables?.(create, states),\n })\n : undefined,\n },\n } as never);\n\n inspection.connect(definition);\n\n return definition;\n }) as unknown as BoundDefineResourceLayout<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefinedFactoryNaming<DefaultNaming>\n >;\n\n boundDefineResourceLayout.lazy = <Module extends Record<string, unknown>>(\n lazyOptions: LazyResourceLayoutOptions<Resources, Module>\n ): ReturnType<typeof createLazyResourceLayout<Resources, Module>> => {\n lazyLayoutCreated = true;\n\n const label = (lazyOptions as unknown as { resource: string }).resource;\n const lazyInspection = inspectLazy(label, inspection);\n const id = lazyInspection.id;\n\n return createLazyResourceLayout(\n {\n ...lazyOptions,\n load: async () => {\n const module: Record<string, unknown> = await lazyOptions.load();\n\n for (const entry of Object.values(module)) {\n const component =\n entry && typeof entry === 'object' && 'Root' in entry\n ? entry.Root\n : entry;\n\n if (\n ((typeof component === 'object' && component !== null) ||\n typeof component === 'function') &&\n layoutInspection in component\n ) {\n inspection.connect(component);\n\n const target = getInspectionSource(component)\n .getSnapshot()\n .nodes.find(\n (n) =>\n n.kind === 'layout' &&\n n.label ===\n (component as { displayName?: string }).displayName\n );\n\n if (target) inspection.edge(id, target.id, 'references');\n }\n }\n\n return module as Module;\n },\n },\n () => lazyDefaults,\n lazyInspection.hooks\n );\n };\n\n return inspection.attach({\n createReusable: createReusableBuilder(resources, options),\n createRenderState: createRenderStateBuilder<Resources, Options, Composables, SharedInclude, SharedCustom>(\n {\n props: configuration.props,\n composables,\n options,\n resources,\n },\n {\n store: inspection,\n defaults: () => lazyDefaults as LazyResourceStates,\n onLazy: () => {\n lazyLayoutCreated = true;\n },\n }\n ),\n defineLazyDefaults: defineLazyDefaults as DefineLazyDefaults<\n ResourcePath<Resources>, Resources, Options, Composables\n >,\n defineResourceLayout: boundDefineResourceLayout,\n resources: createLayoutResourcesAccessor(resources),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkWA,SAAgB,4BAWd,eAiBA;CACA,MAAM,EAAE,WAAW,UAAU,CAAC,GAAc,gBAAgB;CAC5D,MAAM,oBAAoBA,2CAAqB,aAAa,GAAG,SAAS;CACxE,MAAM,+EAAmC;CACzC,IAAI,eAA4D,CAAC;CACjE,IAAI,sBAAsB;CAC1B,IAAI,oBAAoB;CAExB,SAAS,mBACP,UACM;EACN,MAAM,yBAAyB,uBAAuB,QAAQ,IAAI,aAAa;EAC/E,IAAI,uBAAuB,CAAC,wBAC1B,MAAM,IAAIC,4DACR,kDACF;EAGF,IAAI,qBAAqB,CAAC,wBACxB,MAAM,IAAIA,4DACR,gFACF;EAGF,eAAe;EAEf,sBAAsB;CACxB;CAEA,OAAO,eAAe,oBAAoB,UAAU;EAClD,OAAO;EACP,YAAY;CACd,CAAC;CACD,mBAAmB,oBAAoBC,yDAA6B;EAAE;EAAW;EAAS;CAAY,CAAC;CACvG,mBAAmB,yBAAyB,WAC1C,mBAAmB,kBAAkB;EAAE,OAAO;EAAS;CAAO,CAAC;CAGjE,MAAM,8BAA8B,WAAoC;EACtE,MAAM,mBAAmB,OAAO;EAGhC,MAAM,aAAa,kBAAkB;IAClCC,yCAA2B;IAC3BC,gHAA6B,MAAM,gEAAoB,aAAa;GACrE;GACA,MAAM,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":["defineResourceLayout","LayoutConfigurationError","createLazyRenderStateBuilder","lazyDefaultsSymbol","layoutDebug","mergeLayoutProps","inspectLazy","createLazyResourceLayout","layoutInspection","createReusableBuilder","createRenderStateBuilder","createLayoutResourcesAccessor"],"sources":["../../src/create-config/create-defined-resource-layout.ts"],"sourcesContent":["import type {\n CustomPropsInput,\n CustomPropsObject,\n} from '../custom-props';\nimport { createReusableBuilder, type CreateReusable } from './create-reusable';\nimport { inspectLazy } from '../lazy/inspection';\nimport type { ResourcePath } from '../resource';\nimport { createLazyRenderStateBuilder, type CreateLazyRenderState, type CreateBoundLazyErrorComponent } from '../lazy/create-render-state';\nimport { lazyDefaultsSymbol } from '../lazy/types';\nimport type { LazyResourceError } from '../errors/lazy-resource-error';\nimport {\n getLayoutDebug,\n layoutDebug,\n createInspectionStore,\n layoutInspection,\n getInspectionSource,\n} from '@jfdevelops/react-layout-devtools-core';\nimport { mergeLayoutProps } from './merge-layout-props';\nimport type { LayoutNameInput } from './layout-name';\nimport type { MergeContract } from './define-layout';\nimport type {\n ComposableComponents,\n CreateLayoutComposable,\n} from '@jfdevelops/react-layout-composables';\nimport { LayoutConfigurationError } from '../errors';\nimport type { InPropsDefinition } from '../props';\nimport type { LayoutResourceKey, ResourceDefinition } from '../resource';\nimport {\n type CreateViewMapFunctionRenderOptions,\n type DefinedResourceLayout,\n defineResourceLayout,\n type LayoutIncludeProps,\n type LayoutResourcesAccessor,\n type CreateViewMapRenderStatesOptions,\n type DefinedResourceLayoutFromStates,\n createLayoutResourcesAccessor,\n} from './define-layout';\nimport {\n createLazyResourceLayout,\n type LazyResourceLayoutOptions,\n type LazyResourceStates,\n} from './lazy-resource-layout';\nimport {\n createRenderStateBuilder,\n type CreateRenderState,\n type RenderStateContext,\n type RenderStateReferences,\n type LayoutComposablesDefinition,\n} from './render-state';\n\n/** A resource tuple with at least one entry, preserving literal and nested paths. */\nexport type NonEmptyResources = readonly [\n ResourceDefinition,\n ...ResourceDefinition[]\n];\n\n/** Configuration shared by every layout created from one defined-layout factory. */\nexport type CreateDefinedResourceLayoutOptions<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n namespace?: DefaultNamespace;\n /** Default naming convention; explicit definition and component names override it. */\n name?: DefaultNaming;\n /** Shared prop contracts, merged by key with layout and state contracts. */\n props?: {\n include?: LayoutIncludeProps<Resources, Options, Composables> & SharedInclude;\n custom?: SharedCustom & CustomPropsInput<SharedCustom>;\n };\n /** Resources supported by every layout created from this factory. */\n resources: Resources;\n /** Props that render states can opt into through `props.include`. */\n options?: Options;\n /** Layout-wide composables available to every render state. */\n composables?: LayoutComposablesDefinition<Resources, Composables>;\n};\n\n/** The flat layout definition accepted after shared configuration is bound. */\nexport type DefinedResourceLayoutInput<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, Options, Composables>,\n CustomProps extends CustomPropsObject,\n Render,\n Namespace extends boolean = false\n> = Omit<\n CreateViewMapFunctionRenderOptions<\n Resources,\n Options,\n Composables,\n IncludeProps,\n CustomProps\n >['layout'],\n 'composables' | 'render'\n> & { render: Render; namespace?: Namespace };\n\ntype BoundLayoutComposables<\n Shared extends ComposableComponents,\n Local extends ComposableComponents\n> = Omit<Shared, keyof Local> & Local;\n\n/** Flattens a definition's layout while preserving its namespace setting. */\ntype BoundLayoutInput<\n Definition extends { layout: unknown; namespace?: boolean }\n> = Definition['layout'] &\n Pick<Definition, 'namespace'> &\n (Definition extends { name?: infer Name } ? { name?: Name } : {});\n\n/** A `defineResourceLayout` function with its shared configuration pre-bound. */\nexport type BoundDefineResourceLayout<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n /**\n * Defines a layout whose `render` map contains the required `default` state\n * and any built-in or custom compound component states.\n * Keep this overload first so incomplete render objects suggest state keys.\n * Use `createRenderState` for state-local `composables(create)` callbacks;\n * the helper infers their render context independently of the enclosing map.\n */\n <\n const Render extends { default: unknown } & Record<string, unknown>,\n LocalComposables extends ComposableComponents = {},\n Namespace extends boolean = DefaultNamespace,\n const IncludeProps extends LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > = {},\n CustomProps extends CustomPropsObject = {},\n const Naming extends\n | LayoutNameInput<\n LayoutResourceKey<Resources>,\n ('default' | keyof Render) & string\n >\n | undefined = DefaultNaming\n >(\n layout: Omit<\n BoundLayoutInput<\n CreateViewMapRenderStatesOptions<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Render,\n Namespace\n >\n >,\n 'composables' | 'name' | 'props'\n > & {\n name?: Naming;\n props?: {\n include?: LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > & IncludeProps;\n custom?: CustomProps & CustomPropsInput<CustomProps>;\n };\n composables?: (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: RenderStateReferences<Resources, Options, Composables, Render>\n ) => LocalComposables;\n }\n ): DefinedResourceLayoutFromStates<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n Render,\n Namespace,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Naming\n >;\n /** Defines a layout whose `render` value is a single default-state callback. */\n <\n const IncludeProps extends LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > = {},\n CustomProps extends CustomPropsObject = {},\n LocalComposables extends ComposableComponents = {},\n Namespace extends boolean = DefaultNamespace,\n const Naming extends\n | LayoutNameInput<LayoutResourceKey<Resources>, 'default'>\n | undefined = DefaultNaming\n >(\n layout: Omit<\n BoundLayoutInput<\n CreateViewMapFunctionRenderOptions<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Namespace\n >\n >,\n 'composables' | 'name' | 'props'\n > & {\n name?: Naming;\n props?: {\n include?: LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > & IncludeProps;\n custom?: CustomProps & CustomPropsInput<CustomProps>;\n };\n composables?: (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: {}\n ) => LocalComposables;\n }\n ): DefinedResourceLayout<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n {},\n Namespace,\n Naming\n >;\n /**\n * Creates a lazy proxy for the single library-defined component exported by\n * a resource module.\n *\n * @param options - Resource path and named-module import callback.\n */\n lazy<Module extends Record<string, unknown>>(\n options: LazyResourceLayoutOptions<Resources, Module>\n ): ReturnType<typeof createLazyResourceLayout<Resources, Module>>;\n};\n\n/** Registers loading and module-error components used by lazy layouts. */\nexport type DefineLazyDefaults<\n Resource = string,\n Resources extends ReadonlyArray<ResourceDefinition> = ReadonlyArray<ResourceDefinition>,\n Options extends InPropsDefinition<Resources> = {},\n Composables extends ComposableComponents = {},\n> = {\n /**\n * Sets defaults before the first lazy layout. Development reloads may replace them.\n *\n * @param defaults - Shared components for pending module loads and failures.\n */\n (defaults: LazyResourceStates<Resource>): void;\n readonly errors: LazyResourceError;\n createRenderState: CreateLazyRenderState<Resources, Options, Composables>;\n /** @deprecated Use createRenderState({ state: 'Error', render }) instead. */\n createErrorComponent: CreateBoundLazyErrorComponent<Resource, RenderStateContext<Composables, Resources, 'Error'>>;\n};\n\n/** Reusable helpers produced by {@link createDefinedResourceLayout}. */\nexport type CreateDefinedResourceLayoutResult<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n /** Creates a custom logic function with selected options and custom props. */\n createReusable: CreateReusable<Resources, Options>;\n /** Creates eager, deferred, or separately imported render-state fragments. */\n createRenderState: CreateRenderState<\n Resources,\n Options,\n Composables,\n SharedInclude,\n SharedCustom\n >;\n /** Sets the shared loading and module-error UI used by lazy layouts. */\n defineLazyDefaults: DefineLazyDefaults<ResourcePath<Resources>, Resources, Options, Composables>;\n /** Defines a layout using the resources, options, and composables already bound. */\n defineResourceLayout: BoundDefineResourceLayout<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefaultNaming\n >;\n /** Reads, selects, or validates the resources bound to this factory. */\n resources: LayoutResourcesAccessor<Resources>;\n};\n\n/**\n * A configuration that may omit its name cannot guarantee a naming default.\n */\ntype DefinedFactoryNaming<Naming> = undefined extends Naming ? undefined : Naming;\n\n/**\n * Creates type-linked layout helpers from one shared configuration. The returned\n * `defineResourceLayout` accepts the layout directly, while `createRenderState`\n * carries the same resource and option types across file boundaries.\n *\n * @param configuration - Resources and optional shared props/composables to\n * bind to every returned helper.\n * @returns Helpers that share the configuration's inferred literal types.\n *\n * @example\n * ```tsx\n * const { createRenderState, defineResourceLayout } =\n * createDefinedResourceLayout({\n * resources: ['users'],\n * options: { title: createProp.string() },\n * });\n *\n * const Loading = createRenderState({\n * state: 'Loading',\n * props: { include: { title: true } },\n * render: ({ title }) => <p>Loading {title}</p>,\n * });\n *\n * export const usersLayout = defineResourceLayout({\n * render: { default: () => <Users />, ...Loading },\n * });\n * ```\n */\nexport function createDefinedResourceLayout<\n const Resources extends NonEmptyResources,\n const Options extends InPropsDefinition<Resources> = {},\n Composables extends ComposableComponents = {},\n DefaultNamespace extends boolean = false,\n const SharedInclude extends object = {},\n const SharedCustom extends CustomPropsObject = {},\n const DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = LayoutNameInput<LayoutResourceKey<Resources>> | undefined\n>(\n configuration: CreateDefinedResourceLayoutOptions<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefaultNaming\n >\n): CreateDefinedResourceLayoutResult<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefinedFactoryNaming<DefaultNaming>\n> {\n const { resources, options = {} as Options, composables } = configuration;\n const defineBoundLayout = defineResourceLayout.forResources(...resources);\n const inspection = createInspectionStore();\n let lazyDefaults: LazyResourceStates<ResourcePath<Resources>> = {};\n let lazyDefaultsDefined = false;\n let lazyLayoutCreated = false;\n\n function defineLazyDefaults(\n defaults: LazyResourceStates<ResourcePath<Resources>>\n ): void {\n const replacingInDevelopment = lazyDefaultsDefined && process.env.NODE_ENV !== 'production';\n if (lazyDefaultsDefined && !replacingInDevelopment) {\n throw new LayoutConfigurationError(\n 'Lazy resource defaults can only be defined once.'\n );\n }\n\n if (lazyLayoutCreated && !replacingInDevelopment) {\n throw new LayoutConfigurationError(\n 'Lazy resource defaults must be defined before creating a lazy resource layout.'\n );\n }\n\n lazyDefaults = defaults;\n\n lazyDefaultsDefined = true;\n }\n\n Object.defineProperty(defineLazyDefaults, 'errors', {\n value: undefined,\n enumerable: false,\n });\n defineLazyDefaults.createRenderState = createLazyRenderStateBuilder({ resources, options, composables });\n defineLazyDefaults.createErrorComponent = ((render: any) =>\n defineLazyDefaults.createRenderState({ state: 'Error', render })\n ) as CreateBoundLazyErrorComponent<ResourcePath<Resources>, RenderStateContext<Composables, Resources, 'Error'>>;\n\n const boundDefineResourceLayout = ((layout: Record<string, unknown>) => {\n const localComposables = layout.composables as\n | LayoutComposablesDefinition<Resources, ComposableComponents>\n | undefined;\n const definition = defineBoundLayout({\n [lazyDefaultsSymbol]: () => lazyDefaults,\n [layoutDebug]: getLayoutDebug(layout) ?? getLayoutDebug(configuration),\n options,\n name: layout.name ?? configuration.name,\n namespace: layout.namespace ?? configuration.namespace,\n layout: {\n ...layout,\n props: mergeLayoutProps(\n configuration.props,\n layout.props as { include?: object; custom?: object }\n ),\n composables:\n composables || localComposables\n ? (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: {}\n ) => ({\n ...composables?.(create, states),\n ...localComposables?.(create, states),\n })\n : undefined,\n },\n } as never);\n\n inspection.connect(definition);\n\n return definition;\n }) as unknown as BoundDefineResourceLayout<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefinedFactoryNaming<DefaultNaming>\n >;\n\n boundDefineResourceLayout.lazy = <Module extends Record<string, unknown>>(\n lazyOptions: LazyResourceLayoutOptions<Resources, Module>\n ): ReturnType<typeof createLazyResourceLayout<Resources, Module>> => {\n lazyLayoutCreated = true;\n\n const label = (lazyOptions as unknown as { resource: string }).resource;\n const lazyInspection = inspectLazy(label, inspection);\n const id = lazyInspection.id;\n\n return createLazyResourceLayout(\n {\n ...lazyOptions,\n load: async () => {\n const module: Record<string, unknown> = await lazyOptions.load();\n\n for (const entry of Object.values(module)) {\n const component =\n entry && typeof entry === 'object' && 'Root' in entry\n ? entry.Root\n : entry;\n\n if (\n ((typeof component === 'object' && component !== null) ||\n typeof component === 'function') &&\n layoutInspection in component\n ) {\n inspection.connect(component);\n\n const target = getInspectionSource(component)\n .getSnapshot()\n .nodes.find(\n (n) =>\n n.kind === 'layout' &&\n n.label ===\n (component as { displayName?: string }).displayName\n );\n\n if (target) inspection.edge(id, target.id, 'references');\n }\n }\n\n return module as Module;\n },\n },\n () => lazyDefaults,\n lazyInspection.hooks\n );\n };\n\n return inspection.attach({\n createReusable: createReusableBuilder<Resources, Options>(resources, options),\n createRenderState: createRenderStateBuilder<Resources, Options, Composables, SharedInclude, SharedCustom>(\n {\n props: configuration.props,\n composables,\n options,\n resources,\n },\n {\n store: inspection,\n defaults: () => lazyDefaults as LazyResourceStates,\n onLazy: () => {\n lazyLayoutCreated = true;\n },\n }\n ),\n defineLazyDefaults: defineLazyDefaults as DefineLazyDefaults<\n ResourcePath<Resources>, Resources, Options, Composables\n >,\n defineResourceLayout: boundDefineResourceLayout,\n resources: createLayoutResourcesAccessor(resources),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkWA,SAAgB,4BAWd,eAiBA;CACA,MAAM,EAAE,WAAW,UAAU,CAAC,GAAc,gBAAgB;CAC5D,MAAM,oBAAoBA,2CAAqB,aAAa,GAAG,SAAS;CACxE,MAAM,+EAAmC;CACzC,IAAI,eAA4D,CAAC;CACjE,IAAI,sBAAsB;CAC1B,IAAI,oBAAoB;CAExB,SAAS,mBACP,UACM;EACN,MAAM,yBAAyB,uBAAuB,QAAQ,IAAI,aAAa;EAC/E,IAAI,uBAAuB,CAAC,wBAC1B,MAAM,IAAIC,4DACR,kDACF;EAGF,IAAI,qBAAqB,CAAC,wBACxB,MAAM,IAAIA,4DACR,gFACF;EAGF,eAAe;EAEf,sBAAsB;CACxB;CAEA,OAAO,eAAe,oBAAoB,UAAU;EAClD,OAAO;EACP,YAAY;CACd,CAAC;CACD,mBAAmB,oBAAoBC,yDAA6B;EAAE;EAAW;EAAS;CAAY,CAAC;CACvG,mBAAmB,yBAAyB,WAC1C,mBAAmB,kBAAkB;EAAE,OAAO;EAAS;CAAO,CAAC;CAGjE,MAAM,8BAA8B,WAAoC;EACtE,MAAM,mBAAmB,OAAO;EAGhC,MAAM,aAAa,kBAAkB;IAClCC,yCAA2B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;CACpD,CAAC;AACH"}
@@ -6,7 +6,7 @@ import { InPropsDefinition } from "../props.cjs";
6
6
  import { CreateRenderState, LayoutComposablesDefinition, RenderStateContext, RenderStateReferences } from "./render-state.cjs";
7
7
  import { LayoutNameInput } from "./layout-name.cjs";
8
8
  import { CreateViewMapFunctionRenderOptions, CreateViewMapRenderStatesOptions, DefinedResourceLayout, DefinedResourceLayoutFromStates, LayoutIncludeProps, LayoutResourcesAccessor, MergeContract } from "./define-layout.cjs";
9
- import { CreateReusable } from "./create-reusable.cjs";
9
+ import { CreateReusable } from "./reusable-types.cjs";
10
10
  import { CreateBoundLazyErrorComponent, CreateLazyRenderState } from "../lazy/create-render-state.cjs";
11
11
  import { LazyResourceLayoutOptions, createLazyResourceLayout } from "./lazy-resource-layout.cjs";
12
12
  import { ComposableComponents, CreateLayoutComposable } from "@jfdevelops/react-layout-composables";
@@ -1 +1 @@
1
- {"version":3,"file":"create-defined-resource-layout.d.cts","names":[],"sources":["../../src/create-config/create-defined-resource-layout.ts"],"mappings":";;;;;;;;;;;;;;;KAmDY,iBAAA,aACV,kBAAA,KACG,kBAAkB;AAAA;AAAA,KAIX,kCAAA,mBACQ,iBAAA,kBACF,iBAAA,CAAkB,SAAA,uBACd,oBAAA,kEAEE,kBAAA,CACpB,SAAA,EACA,OAAA,EACA,WAAA,6BAEmB,iBAAA,6BAEjB,eAAA,CAAgB,iBAAA,CAAkB,SAAA;EAGtC,SAAA,GAAY,gBAAA,EAfgC;EAiB5C,IAAA,GAAO,aAAA,EAf2B;EAiBlC,KAAA;IACE,OAAA,GAAU,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,IAAe,aAAA;IAChE,MAAA,GAAS,YAAA,GAAe,gBAAA,CAAiB,YAAA;EAAA,GAbzC;EAgBF,SAAA,EAAW,SAAA,EAdU;EAgBrB,OAAA,GAAU,OAAA,EAdU;EAgBpB,WAAA,GAAc,2BAAA,CAA4B,SAAA,EAAW,WAAA;AAAA;;KAI3C,0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,2BAAA,yBACU,iBAAA,wBACF,iBAAA,CAAkB,SAAA,4BACpB,oBAAA,qHAGO,iBAAA,mCAEvB,eAAA,CAAgB,iBAAA,CAAkB,SAAA,iBACtB,eAAA,CAAgB,iBAAA,CAAkB,SAAA,gBAElD,aAAA,EAAe,kCAAA,CACb,SAAA,EACA,OAAA,EACA,WAAA,EACA,gBAAA,EACA,aAAA,EACA,YAAA,EACA,aAAA,IAED,iCAAA,CACD,SAAA,EACA,OAAA,EACA,WAAA,EACA,gBAAA,EACA,aAAA,EACA,YAAA,EACA,oBAAA,CAAqB,aAAA"}
1
+ {"version":3,"file":"create-defined-resource-layout.d.cts","names":[],"sources":["../../src/create-config/create-defined-resource-layout.ts"],"mappings":";;;;;;;;;;;;;;;KAmDY,iBAAA,aACV,kBAAA,KACG,kBAAkB;;KAIX,kCAAA,mBACQ,iBAAA,kBACF,iBAAA,CAAkB,SAAA,uBACd,oBAAA,kEAEE,kBAAA,CACpB,SAAA,EACA,OAAA,EACA,WAAA,6BAEmB,iBAAA,6BAEjB,eAAA,CAAgB,iBAAA,CAAkB,SAAA;EAGtC,SAAA,GAAY,gBAAA,EAfgC;EAiB5C,IAAA,GAAO,aAAA,EAhBW;EAkBlB,KAAA;IACE,OAAA,GAAU,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,IAAe,aAAA;IAChE,MAAA,GAAS,YAAA,GAAe,gBAAA,CAAiB,YAAA;EAAA,GAdzC;EAiBF,SAAA,EAAW,SAAA,EAnBW;EAqBtB,OAAA,GAAU,OAAA,EAd4B;EAgBtC,WAAA,GAAc,2BAAA,CAA4B,SAAA,EAAW,WAAA;AAAA;;KAI3C,0BAAA,mBACQ,iBAAA,kBACF,iBAAA,CAAkB,SAAA,uBACd,oBAAA,uBACC,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,uBACxC,iBAAA,+CAGlB,IAAA,CACF,kCAAA,CACE,SAAA,EACA,OAAA,EACA,WAAA,EACA,YAAA,E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A,EACA,OAAA,EACA,WAAA,EACA,gBAAA,EACA,aAAA,EACA,YAAA,EACA,aAAA,IAED,iCAAA,CACD,SAAA,EACA,OAAA,EACA,WAAA,EACA,gBAAA,EACA,aAAA,EACA,YAAA,EACA,oBAAA,CAAqB,aAAA"}
@@ -6,7 +6,7 @@ import { InPropsDefinition } from "../props.mjs";
6
6
  import { CreateRenderState, LayoutComposablesDefinition, RenderStateContext, RenderStateReferences } from "./render-state.mjs";
7
7
  import { LayoutNameInput } from "./layout-name.mjs";
8
8
  import { CreateViewMapFunctionRenderOptions, CreateViewMapRenderStatesOptions, DefinedResourceLayout, DefinedResourceLayoutFromStates, LayoutIncludeProps, LayoutResourcesAccessor, MergeContract } from "./define-layout.mjs";
9
- import { CreateReusable } from "./create-reusable.mjs";
9
+ import { CreateReusable } from "./reusable-types.mjs";
10
10
  import { CreateBoundLazyErrorComponent, CreateLazyRenderState } from "../lazy/create-render-state.mjs";
11
11
  import { LazyResourceLayoutOptions, createLazyResourceLayout } from "./lazy-resource-layout.mjs";
12
12
  import { ComposableComponents, CreateLayoutComposable } from "@jfdevelops/react-layout-composables";
@@ -1 +1 @@
1
- {"version":3,"file":"create-defined-resource-layout.d.mts","names":[],"sources":["../../src/create-config/create-defined-resource-layout.ts"],"mappings":";;;;;;;;;;;;;;;KAmDY,iBAAA,aACV,kBAAA,KACG,kBAAkB;AAAA;AAAA,KAIX,kCAAA,mBACQ,iBAAA,kBACF,iBAAA,CAAkB,SAAA,uBACd,oBAAA,kEAEE,kBAAA,CACpB,SAAA,EACA,OAAA,EACA,WAAA,6BAEmB,iBAAA,6BAEjB,eAAA,CAAgB,iBAAA,CAAkB,SAAA;EAGtC,SAAA,GAAY,gBAAA,EAfgC;EAiB5C,IAAA,GAAO,aAAA,EAf2B;EAiBlC,KAAA;IACE,OAAA,GAAU,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,IAAe,aAAA;IAChE,MAAA,GAAS,YAAA,GAAe,gBAAA,CAAi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A,EACA,aAAA,GAtNA;EAyNF,SAAA,EAAW,uBAAA,CAAwB,SAAA;AAAA;;;;KAMhC,oBAAA,6BAAiD,MAAA,eAAqB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BjE,2BAAA,yBACU,iBAAA,wBACF,iBAAA,CAAkB,SAAA,4BACpB,oBAAA,qHAGO,iBAAA,mCAEvB,eAAA,CAAgB,iBAAA,CAAkB,SAAA,iBACtB,eAAA,CAAgB,iBAAA,CAAkB,SAAA,gBAElD,aAAA,EAAe,kCAAA,CACb,SAAA,EACA,OAAA,EACA,WAAA,EACA,gBAAA,EACA,aAAA,EACA,YAAA,EACA,aAAA,IAED,iCAAA,CACD,SAAA,EACA,OAAA,EACA,WAAA,EACA,gBAAA,EACA,aAAA,EACA,YAAA,EACA,oBAAA,CAAqB,aAAA"}
1
+ {"version":3,"file":"create-defined-resource-layout.d.mts","names":[],"sources":["../../src/create-config/create-defined-resource-layout.ts"],"mappings":";;;;;;;;;;;;;;;KAmDY,iBAAA,aACV,kBAAA,KACG,kBAAkB;;KAIX,kCAAA,mBACQ,iBAAA,kBACF,iBAAA,CAAkB,SAAA,uBACd,oBAAA,kEAEE,kBAAA,CACpB,SAAA,EACA,OAAA,EACA,WAAA,6BAEmB,iBAAA,6BAEjB,eAAA,CAAgB,iBAAA,CAAkB,SAAA;EAGtC,SAAA,GAAY,gBAAA,EAfgC;EAiB5C,IAAA,GAAO,aAAA,EAhBW;EAkBlB,KAAA;IACE,OAAA,GAAU,kBAAA,CAAmB,SAAA,EAAW,OAAA,EAAS,WAAA,IAAe,aAAA;IAChE,MAAA,GAAS,YAAA,GAAe,gBAAA,CAAiB,YAAA;EAAA,GAdzC;EAiBF,SAAA,EAAW,SAAA,EAnBW;EAqBtB,OAAA,GAAU,OAAA,EAd4B;EAgBtC,WAAA,GAAc,2BAAA,CAA4B,SAAA,EAAW,WAAA;AAAA;;KAI3C,0BAAA,mBACQ,iBAAA,kBACF,iBAAA,CAAkB,S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,SAAA,4BACpB,oBAAA,qHAGO,iBAAA,mCAEvB,eAAA,CAAgB,iBAAA,CAAkB,SAAA,iBACtB,eAAA,CAAgB,iBAAA,CAAkB,SAAA,gBAElD,aAAA,EAAe,kCAAA,CACb,SAAA,EACA,OAAA,EACA,WAAA,EACA,gBAAA,EACA,aAAA,EACA,YAAA,EACA,aAAA,IAED,iCAAA,CACD,SAAA,EACA,OAAA,EACA,WAAA,EACA,gBAAA,EACA,aAAA,EACA,YAAA,EACA,oBAAA,CAAqB,aAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-defined-resource-layout.mjs","names":[],"sources":["../../src/create-config/create-defined-resource-layout.ts"],"sourcesContent":["import type {\n CustomPropsInput,\n CustomPropsObject,\n} from '../custom-props';\nimport { createReusableBuilder, type CreateReusable } from './create-reusable';\nimport { inspectLazy } from '../lazy/inspection';\nimport type { ResourcePath } from '../resource';\nimport { createLazyRenderStateBuilder, type CreateLazyRenderState, type CreateBoundLazyErrorComponent } from '../lazy/create-render-state';\nimport { lazyDefaultsSymbol } from '../lazy/types';\nimport type { LazyResourceError } from '../errors/lazy-resource-error';\nimport {\n getLayoutDebug,\n layoutDebug,\n createInspectionStore,\n layoutInspection,\n getInspectionSource,\n} from '@jfdevelops/react-layout-devtools-core';\nimport { mergeLayoutProps } from './merge-layout-props';\nimport type { LayoutNameInput } from './layout-name';\nimport type { MergeContract } from './define-layout';\nimport type {\n ComposableComponents,\n CreateLayoutComposable,\n} from '@jfdevelops/react-layout-composables';\nimport { LayoutConfigurationError } from '../errors';\nimport type { InPropsDefinition } from '../props';\nimport type { LayoutResourceKey, ResourceDefinition } from '../resource';\nimport {\n type CreateViewMapFunctionRenderOptions,\n type DefinedResourceLayout,\n defineResourceLayout,\n type LayoutIncludeProps,\n type LayoutResourcesAccessor,\n type CreateViewMapRenderStatesOptions,\n type DefinedResourceLayoutFromStates,\n createLayoutResourcesAccessor,\n} from './define-layout';\nimport {\n createLazyResourceLayout,\n type LazyResourceLayoutOptions,\n type LazyResourceStates,\n} from './lazy-resource-layout';\nimport {\n createRenderStateBuilder,\n type CreateRenderState,\n type RenderStateContext,\n type RenderStateReferences,\n type LayoutComposablesDefinition,\n} from './render-state';\n\n/** A resource tuple with at least one entry, preserving literal and nested paths. */\nexport type NonEmptyResources = readonly [\n ResourceDefinition,\n ...ResourceDefinition[]\n];\n\n/** Configuration shared by every layout created from one defined-layout factory. */\nexport type CreateDefinedResourceLayoutOptions<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n namespace?: DefaultNamespace;\n /** Default naming convention; explicit definition and component names override it. */\n name?: DefaultNaming;\n /** Shared prop contracts, merged by key with layout and state contracts. */\n props?: {\n include?: LayoutIncludeProps<Resources, Options, Composables> & SharedInclude;\n custom?: SharedCustom & CustomPropsInput<SharedCustom>;\n };\n /** Resources supported by every layout created from this factory. */\n resources: Resources;\n /** Props that render states can opt into through `props.include`. */\n options?: Options;\n /** Layout-wide composables available to every render state. */\n composables?: LayoutComposablesDefinition<Resources, Composables>;\n};\n\n/** The flat layout definition accepted after shared configuration is bound. */\nexport type DefinedResourceLayoutInput<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, Options, Composables>,\n CustomProps extends CustomPropsObject,\n Render,\n Namespace extends boolean = false\n> = Omit<\n CreateViewMapFunctionRenderOptions<\n Resources,\n Options,\n Composables,\n IncludeProps,\n CustomProps\n >['layout'],\n 'composables' | 'render'\n> & { render: Render; namespace?: Namespace };\n\ntype BoundLayoutComposables<\n Shared extends ComposableComponents,\n Local extends ComposableComponents\n> = Omit<Shared, keyof Local> & Local;\n\n/** Flattens a definition's layout while preserving its namespace setting. */\ntype BoundLayoutInput<\n Definition extends { layout: unknown; namespace?: boolean }\n> = Definition['layout'] &\n Pick<Definition, 'namespace'> &\n (Definition extends { name?: infer Name } ? { name?: Name } : {});\n\n/** A `defineResourceLayout` function with its shared configuration pre-bound. */\nexport type BoundDefineResourceLayout<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n /**\n * Defines a layout whose `render` map contains the required `default` state\n * and any built-in or custom compound component states.\n * Keep this overload first so incomplete render objects suggest state keys.\n * Use `createRenderState` for state-local `composables(create)` callbacks;\n * the helper infers their render context independently of the enclosing map.\n */\n <\n const Render extends { default: unknown } & Record<string, unknown>,\n LocalComposables extends ComposableComponents = {},\n Namespace extends boolean = DefaultNamespace,\n const IncludeProps extends LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > = {},\n CustomProps extends CustomPropsObject = {},\n const Naming extends\n | LayoutNameInput<\n LayoutResourceKey<Resources>,\n ('default' | keyof Render) & string\n >\n | undefined = DefaultNaming\n >(\n layout: Omit<\n BoundLayoutInput<\n CreateViewMapRenderStatesOptions<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Render,\n Namespace\n >\n >,\n 'composables' | 'name' | 'props'\n > & {\n name?: Naming;\n props?: {\n include?: LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > & IncludeProps;\n custom?: CustomProps & CustomPropsInput<CustomProps>;\n };\n composables?: (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: RenderStateReferences<Resources, Options, Composables, Render>\n ) => LocalComposables;\n }\n ): DefinedResourceLayoutFromStates<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n Render,\n Namespace,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Naming\n >;\n /** Defines a layout whose `render` value is a single default-state callback. */\n <\n const IncludeProps extends LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > = {},\n CustomProps extends CustomPropsObject = {},\n LocalComposables extends ComposableComponents = {},\n Namespace extends boolean = DefaultNamespace,\n const Naming extends\n | LayoutNameInput<LayoutResourceKey<Resources>, 'default'>\n | undefined = DefaultNaming\n >(\n layout: Omit<\n BoundLayoutInput<\n CreateViewMapFunctionRenderOptions<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Namespace\n >\n >,\n 'composables' | 'name' | 'props'\n > & {\n name?: Naming;\n props?: {\n include?: LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > & IncludeProps;\n custom?: CustomProps & CustomPropsInput<CustomProps>;\n };\n composables?: (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: {}\n ) => LocalComposables;\n }\n ): DefinedResourceLayout<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n {},\n Namespace,\n Naming\n >;\n /**\n * Creates a lazy proxy for the single library-defined component exported by\n * a resource module.\n *\n * @param options - Resource path and named-module import callback.\n */\n lazy<Module extends Record<string, unknown>>(\n options: LazyResourceLayoutOptions<Resources, Module>\n ): ReturnType<typeof createLazyResourceLayout<Resources, Module>>;\n};\n\n/** Registers loading and module-error components used by lazy layouts. */\nexport type DefineLazyDefaults<\n Resource = string,\n Resources extends ReadonlyArray<ResourceDefinition> = ReadonlyArray<ResourceDefinition>,\n Options extends InPropsDefinition<Resources> = {},\n Composables extends ComposableComponents = {},\n> = {\n /**\n * Sets defaults before the first lazy layout. Development reloads may replace them.\n *\n * @param defaults - Shared components for pending module loads and failures.\n */\n (defaults: LazyResourceStates<Resource>): void;\n readonly errors: LazyResourceError;\n createRenderState: CreateLazyRenderState<Resources, Options, Composables>;\n /** @deprecated Use createRenderState({ state: 'Error', render }) instead. */\n createErrorComponent: CreateBoundLazyErrorComponent<Resource, RenderStateContext<Composables, Resources, 'Error'>>;\n};\n\n/** Reusable helpers produced by {@link createDefinedResourceLayout}. */\nexport type CreateDefinedResourceLayoutResult<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n /** Creates a custom logic function with selected options and custom props. */\n createReusable: CreateReusable<Resources, Options>;\n /** Creates eager, deferred, or separately imported render-state fragments. */\n createRenderState: CreateRenderState<\n Resources,\n Options,\n Composables,\n SharedInclude,\n SharedCustom\n >;\n /** Sets the shared loading and module-error UI used by lazy layouts. */\n defineLazyDefaults: DefineLazyDefaults<ResourcePath<Resources>, Resources, Options, Composables>;\n /** Defines a layout using the resources, options, and composables already bound. */\n defineResourceLayout: BoundDefineResourceLayout<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefaultNaming\n >;\n /** Reads, selects, or validates the resources bound to this factory. */\n resources: LayoutResourcesAccessor<Resources>;\n};\n\n/**\n * A configuration that may omit its name cannot guarantee a naming default.\n */\ntype DefinedFactoryNaming<Naming> = undefined extends Naming ? undefined : Naming;\n\n/**\n * Creates type-linked layout helpers from one shared configuration. The returned\n * `defineResourceLayout` accepts the layout directly, while `createRenderState`\n * carries the same resource and option types across file boundaries.\n *\n * @param configuration - Resources and optional shared props/composables to\n * bind to every returned helper.\n * @returns Helpers that share the configuration's inferred literal types.\n *\n * @example\n * ```tsx\n * const { createRenderState, defineResourceLayout } =\n * createDefinedResourceLayout({\n * resources: ['users'],\n * options: { title: createProp.string() },\n * });\n *\n * const Loading = createRenderState({\n * state: 'Loading',\n * props: { include: { title: true } },\n * render: ({ title }) => <p>Loading {title}</p>,\n * });\n *\n * export const usersLayout = defineResourceLayout({\n * render: { default: () => <Users />, ...Loading },\n * });\n * ```\n */\nexport function createDefinedResourceLayout<\n const Resources extends NonEmptyResources,\n const Options extends InPropsDefinition<Resources> = {},\n Composables extends ComposableComponents = {},\n DefaultNamespace extends boolean = false,\n const SharedInclude extends object = {},\n const SharedCustom extends CustomPropsObject = {},\n const DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = LayoutNameInput<LayoutResourceKey<Resources>> | undefined\n>(\n configuration: CreateDefinedResourceLayoutOptions<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefaultNaming\n >\n): CreateDefinedResourceLayoutResult<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefinedFactoryNaming<DefaultNaming>\n> {\n const { resources, options = {} as Options, composables } = configuration;\n const defineBoundLayout = defineResourceLayout.forResources(...resources);\n const inspection = createInspectionStore();\n let lazyDefaults: LazyResourceStates<ResourcePath<Resources>> = {};\n let lazyDefaultsDefined = false;\n let lazyLayoutCreated = false;\n\n function defineLazyDefaults(\n defaults: LazyResourceStates<ResourcePath<Resources>>\n ): void {\n const replacingInDevelopment = lazyDefaultsDefined && process.env.NODE_ENV !== 'production';\n if (lazyDefaultsDefined && !replacingInDevelopment) {\n throw new LayoutConfigurationError(\n 'Lazy resource defaults can only be defined once.'\n );\n }\n\n if (lazyLayoutCreated && !replacingInDevelopment) {\n throw new LayoutConfigurationError(\n 'Lazy resource defaults must be defined before creating a lazy resource layout.'\n );\n }\n\n lazyDefaults = defaults;\n\n lazyDefaultsDefined = true;\n }\n\n Object.defineProperty(defineLazyDefaults, 'errors', {\n value: undefined,\n enumerable: false,\n });\n defineLazyDefaults.createRenderState = createLazyRenderStateBuilder({ resources, options, composables });\n defineLazyDefaults.createErrorComponent = ((render: any) =>\n defineLazyDefaults.createRenderState({ state: 'Error', render })\n ) as CreateBoundLazyErrorComponent<ResourcePath<Resources>, RenderStateContext<Composables, Resources, 'Error'>>;\n\n const boundDefineResourceLayout = ((layout: Record<string, unknown>) => {\n const localComposables = layout.composables as\n | LayoutComposablesDefinition<Resources, ComposableComponents>\n | undefined;\n const definition = defineBoundLayout({\n [lazyDefaultsSymbol]: () => lazyDefaults,\n [layoutDebug]: getLayoutDebug(layout) ?? getLayoutDebug(configuration),\n options,\n name: layout.name ?? configuration.name,\n namespace: layout.namespace ?? configuration.namespace,\n layout: {\n ...layout,\n props: mergeLayoutProps(\n configuration.props,\n layout.props as { include?: object; custom?: object }\n ),\n composables:\n composables || localComposables\n ? (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: {}\n ) => ({\n ...composables?.(create, states),\n ...localComposables?.(create, states),\n })\n : undefined,\n },\n } as never);\n\n inspection.connect(definition);\n\n return definition;\n }) as unknown as BoundDefineResourceLayout<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefinedFactoryNaming<DefaultNaming>\n >;\n\n boundDefineResourceLayout.lazy = <Module extends Record<string, unknown>>(\n lazyOptions: LazyResourceLayoutOptions<Resources, Module>\n ): ReturnType<typeof createLazyResourceLayout<Resources, Module>> => {\n lazyLayoutCreated = true;\n\n const label = (lazyOptions as unknown as { resource: string }).resource;\n const lazyInspection = inspectLazy(label, inspection);\n const id = lazyInspection.id;\n\n return createLazyResourceLayout(\n {\n ...lazyOptions,\n load: async () => {\n const module: Record<string, unknown> = await lazyOptions.load();\n\n for (const entry of Object.values(module)) {\n const component =\n entry && typeof entry === 'object' && 'Root' in entry\n ? entry.Root\n : entry;\n\n if (\n ((typeof component === 'object' && component !== null) ||\n typeof component === 'function') &&\n layoutInspection in component\n ) {\n inspection.connect(component);\n\n const target = getInspectionSource(component)\n .getSnapshot()\n .nodes.find(\n (n) =>\n n.kind === 'layout' &&\n n.label ===\n (component as { displayName?: string }).displayName\n );\n\n if (target) inspection.edge(id, target.id, 'references');\n }\n }\n\n return module as Module;\n },\n },\n () => lazyDefaults,\n lazyInspection.hooks\n );\n };\n\n return inspection.attach({\n createReusable: createReusableBuilder(resources, options),\n createRenderState: createRenderStateBuilder<Resources, Options, Composables, SharedInclude, SharedCustom>(\n {\n props: configuration.props,\n composables,\n options,\n resources,\n },\n {\n store: inspection,\n defaults: () => lazyDefaults as LazyResourceStates,\n onLazy: () => {\n lazyLayoutCreated = true;\n },\n }\n ),\n defineLazyDefaults: defineLazyDefaults as DefineLazyDefaults<\n ResourcePath<Resources>, Resources, Options, Composables\n >,\n defineResourceLayout: boundDefineResourceLayout,\n resources: createLayoutResourcesAccessor(resources),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkWA,SAAgB,4BAWd,eAiBA;CACA,MAAM,EAAE,WAAW,UAAU,CAAC,GAAc,gBAAgB;CAC5D,MAAM,oBAAoB,qBAAqB,aAAa,GAAG,SAAS;CACxE,MAAM,aAAa,sBAAsB;CACzC,IAAI,eAA4D,CAAC;CACjE,IAAI,sBAAsB;CAC1B,IAAI,oBAAoB;CAExB,SAAS,mBACP,UACM;EACN,MAAM,yBAAyB,uBAAuB,QAAQ,IAAI,aAAa;EAC/E,IAAI,uBAAuB,CAAC,wBAC1B,MAAM,IAAI,yBACR,kDACF;EAGF,IAAI,qBAAqB,CAAC,wBACxB,MAAM,IAAI,yBACR,gFACF;EAGF,eAAe;EAEf,sBAAsB;CACxB;CAEA,OAAO,eAAe,oBAAoB,UAAU;EAClD,OAAO;EACP,YAAY;CACd,CAAC;CACD,mBAAmB,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AW,OAAO;EACvB,gBAAgB,sBAAsB,WAAW,OAAO;EACxD,mBAAmB,yBACjB;GACE,OAAO,cAAc;GACrB;GACA;GACA;EACF,GACA;GACE,OAAO;GACP,gBAAgB;GAChB,cAAc;IACZ,oBAAoB;GACtB;EACF,CACF;EACoB;EAGpB,sBAAsB;EACtB,WAAW,8BAA8B,SAAS;CACpD,CAAC;AACH"}
1
+ {"version":3,"file":"create-defined-resource-layout.mjs","names":[],"sources":["../../src/create-config/create-defined-resource-layout.ts"],"sourcesContent":["import type {\n CustomPropsInput,\n CustomPropsObject,\n} from '../custom-props';\nimport { createReusableBuilder, type CreateReusable } from './create-reusable';\nimport { inspectLazy } from '../lazy/inspection';\nimport type { ResourcePath } from '../resource';\nimport { createLazyRenderStateBuilder, type CreateLazyRenderState, type CreateBoundLazyErrorComponent } from '../lazy/create-render-state';\nimport { lazyDefaultsSymbol } from '../lazy/types';\nimport type { LazyResourceError } from '../errors/lazy-resource-error';\nimport {\n getLayoutDebug,\n layoutDebug,\n createInspectionStore,\n layoutInspection,\n getInspectionSource,\n} from '@jfdevelops/react-layout-devtools-core';\nimport { mergeLayoutProps } from './merge-layout-props';\nimport type { LayoutNameInput } from './layout-name';\nimport type { MergeContract } from './define-layout';\nimport type {\n ComposableComponents,\n CreateLayoutComposable,\n} from '@jfdevelops/react-layout-composables';\nimport { LayoutConfigurationError } from '../errors';\nimport type { InPropsDefinition } from '../props';\nimport type { LayoutResourceKey, ResourceDefinition } from '../resource';\nimport {\n type CreateViewMapFunctionRenderOptions,\n type DefinedResourceLayout,\n defineResourceLayout,\n type LayoutIncludeProps,\n type LayoutResourcesAccessor,\n type CreateViewMapRenderStatesOptions,\n type DefinedResourceLayoutFromStates,\n createLayoutResourcesAccessor,\n} from './define-layout';\nimport {\n createLazyResourceLayout,\n type LazyResourceLayoutOptions,\n type LazyResourceStates,\n} from './lazy-resource-layout';\nimport {\n createRenderStateBuilder,\n type CreateRenderState,\n type RenderStateContext,\n type RenderStateReferences,\n type LayoutComposablesDefinition,\n} from './render-state';\n\n/** A resource tuple with at least one entry, preserving literal and nested paths. */\nexport type NonEmptyResources = readonly [\n ResourceDefinition,\n ...ResourceDefinition[]\n];\n\n/** Configuration shared by every layout created from one defined-layout factory. */\nexport type CreateDefinedResourceLayoutOptions<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n namespace?: DefaultNamespace;\n /** Default naming convention; explicit definition and component names override it. */\n name?: DefaultNaming;\n /** Shared prop contracts, merged by key with layout and state contracts. */\n props?: {\n include?: LayoutIncludeProps<Resources, Options, Composables> & SharedInclude;\n custom?: SharedCustom & CustomPropsInput<SharedCustom>;\n };\n /** Resources supported by every layout created from this factory. */\n resources: Resources;\n /** Props that render states can opt into through `props.include`. */\n options?: Options;\n /** Layout-wide composables available to every render state. */\n composables?: LayoutComposablesDefinition<Resources, Composables>;\n};\n\n/** The flat layout definition accepted after shared configuration is bound. */\nexport type DefinedResourceLayoutInput<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n IncludeProps extends LayoutIncludeProps<Resources, Options, Composables>,\n CustomProps extends CustomPropsObject,\n Render,\n Namespace extends boolean = false\n> = Omit<\n CreateViewMapFunctionRenderOptions<\n Resources,\n Options,\n Composables,\n IncludeProps,\n CustomProps\n >['layout'],\n 'composables' | 'render'\n> & { render: Render; namespace?: Namespace };\n\ntype BoundLayoutComposables<\n Shared extends ComposableComponents,\n Local extends ComposableComponents\n> = Omit<Shared, keyof Local> & Local;\n\n/** Flattens a definition's layout while preserving its namespace setting. */\ntype BoundLayoutInput<\n Definition extends { layout: unknown; namespace?: boolean }\n> = Definition['layout'] &\n Pick<Definition, 'namespace'> &\n (Definition extends { name?: infer Name } ? { name?: Name } : {});\n\n/** A `defineResourceLayout` function with its shared configuration pre-bound. */\nexport type BoundDefineResourceLayout<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n /**\n * Defines a layout whose `render` map contains the required `default` state\n * and any built-in or custom compound component states.\n * Keep this overload first so incomplete render objects suggest state keys.\n * Use `createRenderState` for state-local `composables(create)` callbacks;\n * the helper infers their render context independently of the enclosing map.\n */\n <\n const Render extends { default: unknown } & Record<string, unknown>,\n LocalComposables extends ComposableComponents = {},\n Namespace extends boolean = DefaultNamespace,\n const IncludeProps extends LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > = {},\n CustomProps extends CustomPropsObject = {},\n const Naming extends\n | LayoutNameInput<\n LayoutResourceKey<Resources>,\n ('default' | keyof Render) & string\n >\n | undefined = DefaultNaming\n >(\n layout: Omit<\n BoundLayoutInput<\n CreateViewMapRenderStatesOptions<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Render,\n Namespace\n >\n >,\n 'composables' | 'name' | 'props'\n > & {\n name?: Naming;\n props?: {\n include?: LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > & IncludeProps;\n custom?: CustomProps & CustomPropsInput<CustomProps>;\n };\n composables?: (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: RenderStateReferences<Resources, Options, Composables, Render>\n ) => LocalComposables;\n }\n ): DefinedResourceLayoutFromStates<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n Render,\n Namespace,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Naming\n >;\n /** Defines a layout whose `render` value is a single default-state callback. */\n <\n const IncludeProps extends LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > = {},\n CustomProps extends CustomPropsObject = {},\n LocalComposables extends ComposableComponents = {},\n Namespace extends boolean = DefaultNamespace,\n const Naming extends\n | LayoutNameInput<LayoutResourceKey<Resources>, 'default'>\n | undefined = DefaultNaming\n >(\n layout: Omit<\n BoundLayoutInput<\n CreateViewMapFunctionRenderOptions<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n Namespace\n >\n >,\n 'composables' | 'name' | 'props'\n > & {\n name?: Naming;\n props?: {\n include?: LayoutIncludeProps<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>\n > & IncludeProps;\n custom?: CustomProps & CustomPropsInput<CustomProps>;\n };\n composables?: (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: {}\n ) => LocalComposables;\n }\n ): DefinedResourceLayout<\n Resources,\n Options,\n BoundLayoutComposables<Composables, LocalComposables>,\n MergeContract<SharedInclude, IncludeProps>,\n MergeContract<SharedCustom, CustomProps>,\n {},\n Namespace,\n Naming\n >;\n /**\n * Creates a lazy proxy for the single library-defined component exported by\n * a resource module.\n *\n * @param options - Resource path and named-module import callback.\n */\n lazy<Module extends Record<string, unknown>>(\n options: LazyResourceLayoutOptions<Resources, Module>\n ): ReturnType<typeof createLazyResourceLayout<Resources, Module>>;\n};\n\n/** Registers loading and module-error components used by lazy layouts. */\nexport type DefineLazyDefaults<\n Resource = string,\n Resources extends ReadonlyArray<ResourceDefinition> = ReadonlyArray<ResourceDefinition>,\n Options extends InPropsDefinition<Resources> = {},\n Composables extends ComposableComponents = {},\n> = {\n /**\n * Sets defaults before the first lazy layout. Development reloads may replace them.\n *\n * @param defaults - Shared components for pending module loads and failures.\n */\n (defaults: LazyResourceStates<Resource>): void;\n readonly errors: LazyResourceError;\n createRenderState: CreateLazyRenderState<Resources, Options, Composables>;\n /** @deprecated Use createRenderState({ state: 'Error', render }) instead. */\n createErrorComponent: CreateBoundLazyErrorComponent<Resource, RenderStateContext<Composables, Resources, 'Error'>>;\n};\n\n/** Reusable helpers produced by {@link createDefinedResourceLayout}. */\nexport type CreateDefinedResourceLayoutResult<\n Resources extends NonEmptyResources,\n Options extends InPropsDefinition<Resources>,\n Composables extends ComposableComponents,\n DefaultNamespace extends boolean = false,\n SharedInclude extends LayoutIncludeProps<\n Resources,\n Options,\n Composables\n > = {},\n SharedCustom extends CustomPropsObject = {},\n DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = undefined\n> = {\n /** Creates a custom logic function with selected options and custom props. */\n createReusable: CreateReusable<Resources, Options>;\n /** Creates eager, deferred, or separately imported render-state fragments. */\n createRenderState: CreateRenderState<\n Resources,\n Options,\n Composables,\n SharedInclude,\n SharedCustom\n >;\n /** Sets the shared loading and module-error UI used by lazy layouts. */\n defineLazyDefaults: DefineLazyDefaults<ResourcePath<Resources>, Resources, Options, Composables>;\n /** Defines a layout using the resources, options, and composables already bound. */\n defineResourceLayout: BoundDefineResourceLayout<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefaultNaming\n >;\n /** Reads, selects, or validates the resources bound to this factory. */\n resources: LayoutResourcesAccessor<Resources>;\n};\n\n/**\n * A configuration that may omit its name cannot guarantee a naming default.\n */\ntype DefinedFactoryNaming<Naming> = undefined extends Naming ? undefined : Naming;\n\n/**\n * Creates type-linked layout helpers from one shared configuration. The returned\n * `defineResourceLayout` accepts the layout directly, while `createRenderState`\n * carries the same resource and option types across file boundaries.\n *\n * @param configuration - Resources and optional shared props/composables to\n * bind to every returned helper.\n * @returns Helpers that share the configuration's inferred literal types.\n *\n * @example\n * ```tsx\n * const { createRenderState, defineResourceLayout } =\n * createDefinedResourceLayout({\n * resources: ['users'],\n * options: { title: createProp.string() },\n * });\n *\n * const Loading = createRenderState({\n * state: 'Loading',\n * props: { include: { title: true } },\n * render: ({ title }) => <p>Loading {title}</p>,\n * });\n *\n * export const usersLayout = defineResourceLayout({\n * render: { default: () => <Users />, ...Loading },\n * });\n * ```\n */\nexport function createDefinedResourceLayout<\n const Resources extends NonEmptyResources,\n const Options extends InPropsDefinition<Resources> = {},\n Composables extends ComposableComponents = {},\n DefaultNamespace extends boolean = false,\n const SharedInclude extends object = {},\n const SharedCustom extends CustomPropsObject = {},\n const DefaultNaming extends\n | LayoutNameInput<LayoutResourceKey<Resources>>\n | undefined = LayoutNameInput<LayoutResourceKey<Resources>> | undefined\n>(\n configuration: CreateDefinedResourceLayoutOptions<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefaultNaming\n >\n): CreateDefinedResourceLayoutResult<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefinedFactoryNaming<DefaultNaming>\n> {\n const { resources, options = {} as Options, composables } = configuration;\n const defineBoundLayout = defineResourceLayout.forResources(...resources);\n const inspection = createInspectionStore();\n let lazyDefaults: LazyResourceStates<ResourcePath<Resources>> = {};\n let lazyDefaultsDefined = false;\n let lazyLayoutCreated = false;\n\n function defineLazyDefaults(\n defaults: LazyResourceStates<ResourcePath<Resources>>\n ): void {\n const replacingInDevelopment = lazyDefaultsDefined && process.env.NODE_ENV !== 'production';\n if (lazyDefaultsDefined && !replacingInDevelopment) {\n throw new LayoutConfigurationError(\n 'Lazy resource defaults can only be defined once.'\n );\n }\n\n if (lazyLayoutCreated && !replacingInDevelopment) {\n throw new LayoutConfigurationError(\n 'Lazy resource defaults must be defined before creating a lazy resource layout.'\n );\n }\n\n lazyDefaults = defaults;\n\n lazyDefaultsDefined = true;\n }\n\n Object.defineProperty(defineLazyDefaults, 'errors', {\n value: undefined,\n enumerable: false,\n });\n defineLazyDefaults.createRenderState = createLazyRenderStateBuilder({ resources, options, composables });\n defineLazyDefaults.createErrorComponent = ((render: any) =>\n defineLazyDefaults.createRenderState({ state: 'Error', render })\n ) as CreateBoundLazyErrorComponent<ResourcePath<Resources>, RenderStateContext<Composables, Resources, 'Error'>>;\n\n const boundDefineResourceLayout = ((layout: Record<string, unknown>) => {\n const localComposables = layout.composables as\n | LayoutComposablesDefinition<Resources, ComposableComponents>\n | undefined;\n const definition = defineBoundLayout({\n [lazyDefaultsSymbol]: () => lazyDefaults,\n [layoutDebug]: getLayoutDebug(layout) ?? getLayoutDebug(configuration),\n options,\n name: layout.name ?? configuration.name,\n namespace: layout.namespace ?? configuration.namespace,\n layout: {\n ...layout,\n props: mergeLayoutProps(\n configuration.props,\n layout.props as { include?: object; custom?: object }\n ),\n composables:\n composables || localComposables\n ? (\n create: CreateLayoutComposable<LayoutResourceKey<Resources>>,\n states: {}\n ) => ({\n ...composables?.(create, states),\n ...localComposables?.(create, states),\n })\n : undefined,\n },\n } as never);\n\n inspection.connect(definition);\n\n return definition;\n }) as unknown as BoundDefineResourceLayout<\n Resources,\n Options,\n Composables,\n DefaultNamespace,\n SharedInclude,\n SharedCustom,\n DefinedFactoryNaming<DefaultNaming>\n >;\n\n boundDefineResourceLayout.lazy = <Module extends Record<string, unknown>>(\n lazyOptions: LazyResourceLayoutOptions<Resources, Module>\n ): ReturnType<typeof createLazyResourceLayout<Resources, Module>> => {\n lazyLayoutCreated = true;\n\n const label = (lazyOptions as unknown as { resource: string }).resource;\n const lazyInspection = inspectLazy(label, inspection);\n const id = lazyInspection.id;\n\n return createLazyResourceLayout(\n {\n ...lazyOptions,\n load: async () => {\n const module: Record<string, unknown> = await lazyOptions.load();\n\n for (const entry of Object.values(module)) {\n const component =\n entry && typeof entry === 'object' && 'Root' in entry\n ? entry.Root\n : entry;\n\n if (\n ((typeof component === 'object' && component !== null) ||\n typeof component === 'function') &&\n layoutInspection in component\n ) {\n inspection.connect(component);\n\n const target = getInspectionSource(component)\n .getSnapshot()\n .nodes.find(\n (n) =>\n n.kind === 'layout' &&\n n.label ===\n (component as { displayName?: string }).displayName\n );\n\n if (target) inspection.edge(id, target.id, 'references');\n }\n }\n\n return module as Module;\n },\n },\n () => lazyDefaults,\n lazyInspection.hooks\n );\n };\n\n return inspection.attach({\n createReusable: createReusableBuilder<Resources, Options>(resources, options),\n createRenderState: createRenderStateBuilder<Resources, Options, Composables, SharedInclude, SharedCustom>(\n {\n props: configuration.props,\n composables,\n options,\n resources,\n },\n {\n store: inspection,\n defaults: () => lazyDefaults as LazyResourceStates,\n onLazy: () => {\n lazyLayoutCreated = true;\n },\n }\n ),\n defineLazyDefaults: defineLazyDefaults as DefineLazyDefaults<\n ResourcePath<Resources>, Resources, Options, Composables\n >,\n defineResourceLayout: boundDefineResourceLayout,\n resources: createLayoutResourcesAccessor(resources),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkWA,SAAgB,4BAWd,eAiBA;CACA,MAAM,EAAE,WAAW,UAAU,CAAC,GAAc,gBAAgB;CAC5D,MAAM,oBAAoB,qBAAqB,aAAa,GAAG,SAAS;CACxE,MAAM,aAAa,sBAAsB;CACzC,IAAI,eAA4D,CAAC;CACjE,IAAI,sBAAsB;CAC1B,IAAI,oBAAoB;CAExB,SAAS,mBACP,UACM;EACN,MAAM,yBAAyB,uBAAuB,QAAQ,IAAI,aAAa;EAC/E,IAAI,uBAAuB,CAAC,wBAC1B,MAAM,IAAI,yBACR,kDACF;EAGF,IAAI,qBAAqB,CAAC,wBACxB,MAAM,IAAI,yBACR,gFACF;EAGF,eAAe;EAEf,sBAAsB;CACxB;CAEA,OAAO,eAAe,oBAAoB,UAAU;EAClD,OAAO;EACP,YAAY;CACd,CAAC;CACD,mBAAmB,oBAAoB,6BAA6B;EAAE;EAAW;EAAS;CAAY,CAAC;CACvG,mBAAmB,yBAAyB,WAC1C,mBAAmB,kBAA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GACA;GACA;EACF,GACA;GACE,OAAO;GACP,gBAAgB;GAChB,cAAc;IACZ,oBAAoB;GACtB;EACF,CACF;EACoB;EAGpB,sBAAsB;EACtB,WAAW,8BAA8B,SAAS;CACpD,CAAC;AACH"}
@@ -1,44 +1,208 @@
1
1
  const require_layout_configuration_error = require('../errors/layout-configuration-error.cjs');
2
+ const require_define_layout = require('./define-layout.cjs');
2
3
  let _jfdevelops_react_layout_validator = require("@jfdevelops/react-layout-validator");
3
4
 
4
5
  //#region src/create-config/create-reusable.ts
5
- function selectOptions(definitions, selection) {
6
- const selected = {};
7
- for (const [key, include] of Object.entries(selection)) {
8
- const definition = definitions[key];
6
+ function objectPlan(children, optional = false, guards = [[]]) {
7
+ return {
8
+ kind: "object",
9
+ children,
10
+ optional,
11
+ guards
12
+ };
13
+ }
14
+ function optionPlan(definitions, selection, from, path = [], optionalPaths = []) {
15
+ const entries = selection === true ? Object.fromEntries(Object.keys(definitions).map((key) => [key, true])) : selection;
16
+ const children = {};
17
+ for (const [key, value] of Object.entries(entries ?? {})) {
9
18
  if (!Object.hasOwn(definitions, key)) throw new require_layout_configuration_error.LayoutConfigurationError(`Unknown reusable option "${key}".`);
10
- if (include === true) {
11
- selected[key] = definition;
19
+ const definition = definitions[key];
20
+ const location = {
21
+ from,
22
+ path: [...path, key]
23
+ };
24
+ if (typeof value === "function") children[key] = {
25
+ ...location,
26
+ from: "options",
27
+ guards: optionalPaths.map((path) => ({
28
+ from: "options",
29
+ path
30
+ })),
31
+ kind: "value",
32
+ source: "option",
33
+ selector: value,
34
+ definition
35
+ };
36
+ else if ("properties" in definition && "type" in definition && definition.type === "object" && (value === true || value && typeof value === "object")) children[key] = {
37
+ ...optionPlan(definition.properties, value, from, location.path, definition.visibility === "optional" ? [...optionalPaths, location.path] : optionalPaths),
38
+ optional: definition.visibility === "optional"
39
+ };
40
+ else if (value === true) children[key] = {
41
+ ...location,
42
+ guards: optionalPaths.map((path) => ({
43
+ from,
44
+ path
45
+ })),
46
+ kind: "value",
47
+ source: "option",
48
+ definition
49
+ };
50
+ else throw new require_layout_configuration_error.LayoutConfigurationError(`Invalid reusable selection for "${key}".`);
51
+ }
52
+ const origins = /* @__PURE__ */ new Set();
53
+ function collectOrigins(node) {
54
+ if (node.kind === "value") origins.add(node.from);
55
+ else Object.values(node.children).forEach(collectOrigins);
56
+ }
57
+ Object.values(children).forEach(collectOrigins);
58
+ if (!origins.size) origins.add(from);
59
+ return objectPlan(children, false, [...origins].map((origin) => optionalPaths.map((path) => ({
60
+ from: origin,
61
+ path
62
+ }))));
63
+ }
64
+ function sameSelection(left, right) {
65
+ return left.source === right.source && left.selector === right.selector && left.path.join(".") === right.path.join(".") && (left.source === "option" || left.from === right.from);
66
+ }
67
+ function mergePlans(left, right, overlap, path = []) {
68
+ const children = { ...left.children };
69
+ for (const [key, other] of Object.entries(right.children)) {
70
+ const current = children[key];
71
+ if (!current) {
72
+ children[key] = other;
12
73
  continue;
13
74
  }
14
- if (!include || typeof include !== "object" || !("properties" in definition) || !("type" in definition) || definition.type !== "object") throw new require_layout_configuration_error.LayoutConfigurationError(`Invalid reusable selection for "${key}".`);
15
- const nested = _jfdevelops_react_layout_validator.createProp.object(selectOptions(definition.properties, include));
16
- selected[key] = definition.visibility === "optional" ? nested.optional() : nested;
75
+ if (current.kind === "object" && other.kind === "object") children[key] = mergePlans(current, other, overlap, [...path, key]);
76
+ else if (current.kind === "value" && other.kind === "value" && sameSelection(current, other)) children[key] = other.from === "options" ? other : current;
77
+ else if (overlap) children[key] = overlap === "preferProps" ? current : other;
78
+ else throw new require_layout_configuration_error.LayoutConfigurationError(`Ambiguous reusable property "${[...path, key].join(".")}". Rename one result or set overlap to "preferProps" or "preferSelect".`);
17
79
  }
18
- return selected;
80
+ return {
81
+ kind: "object",
82
+ children,
83
+ optional: left.optional && right.optional,
84
+ guards: [...left.guards, ...right.guards]
85
+ };
86
+ }
87
+ function withoutSharedCallerValues(left, right) {
88
+ const children = { ...left.children };
89
+ for (const [key, other] of Object.entries(right.children)) {
90
+ const current = children[key];
91
+ if (current?.kind === "object" && other.kind === "object") children[key] = withoutSharedCallerValues(current, other);
92
+ else if (current?.kind === "value" && other.kind === "value" && sameSelection(current, other) && other.from === "options") delete children[key];
93
+ }
94
+ return {
95
+ ...left,
96
+ children
97
+ };
98
+ }
99
+ function planDefinitions(plan, from) {
100
+ const definitions = {};
101
+ for (const [key, value] of Object.entries(plan.children)) if (value.kind === "value") {
102
+ if (value.from === from && value.definition) definitions[key] = value.definition;
103
+ } else {
104
+ const nested = planDefinitions(value, from);
105
+ if (Object.keys(nested).length) {
106
+ const definition = _jfdevelops_react_layout_validator.createProp.object(nested);
107
+ definitions[key] = value.optional ? definition.optional() : definition;
108
+ }
109
+ }
110
+ return definitions;
111
+ }
112
+ function sourceSelection(selection, callbacksOnly) {
113
+ if (typeof selection === "function") return true;
114
+ if (selection === true) return callbacksOnly ? {} : true;
115
+ const source = {};
116
+ for (const [key, value] of Object.entries(selection ?? {})) {
117
+ const nested = sourceSelection(value, callbacksOnly);
118
+ if (nested === true || Object.keys(nested).length) source[key] = nested;
119
+ }
120
+ return source;
121
+ }
122
+ function mergeSelections(left, right) {
123
+ if (left === true || right === true) return true;
124
+ const merged = { ...left };
125
+ for (const [key, value] of Object.entries(right)) merged[key] = Object.hasOwn(left, key) ? mergeSelections(left[key], value) : value;
126
+ return merged;
127
+ }
128
+ function readLocation(location, props, options, resources) {
129
+ let value = location.from === "props" ? props : location.from === "options" ? options : resources;
130
+ for (const key of location.path) value = value?.[key];
131
+ return value;
132
+ }
133
+ function resolvePlan(plan, props, options, resources) {
134
+ const result = {};
135
+ for (const [key, node] of Object.entries(plan.children)) if (node.kind === "object") {
136
+ if (node.guards.some((group) => group.every((location) => readLocation(location, props, options, resources) !== void 0))) result[key] = resolvePlan(node, props, options, resources);
137
+ } else {
138
+ if (node.guards?.some((location) => readLocation(location, props, options, resources) === void 0)) continue;
139
+ const value = readLocation(node, props, options, resources);
140
+ if (node.selector) result[key] = node.selector(value);
141
+ else if (value !== void 0 || node.definition?.visibility !== "optional") result[key] = value;
142
+ }
143
+ return result;
19
144
  }
20
145
  function createReusableBuilder(resources, options) {
21
146
  const keys = resources.map((entry) => typeof entry === "string" ? entry : entry.value);
22
147
  const resource = _jfdevelops_react_layout_validator.createProp.string.enum(keys);
148
+ const resourcesAccessor = require_define_layout.createLayoutResourcesAccessor(resources);
23
149
  function createReusable(definition) {
24
150
  const include = definition.props?.include ?? {};
25
- for (const key of Object.keys(include)) if (key !== "resources" && key !== "options") throw new require_layout_configuration_error.LayoutConfigurationError(`Unknown reusable source "${key}".`);
151
+ const select = definition.select ?? {};
152
+ if (definition.overlap !== void 0 && definition.overlap !== "preferProps" && definition.overlap !== "preferSelect") throw new require_layout_configuration_error.LayoutConfigurationError("Unknown reusable overlap policy.");
26
153
  const optionDefinitions = typeof options === "function" ? options({
27
154
  name: _jfdevelops_react_layout_validator.createProp.string.literal("Reusable"),
28
155
  resource
29
156
  }) : options;
30
- const definitions = { ...include.options === true ? optionDefinitions : include.options ? selectOptions(optionDefinitions, include.options) : {} };
31
- if (include.resources) {
32
- if (Object.hasOwn(definitions, "resources")) throw new require_layout_configuration_error.LayoutConfigurationError("Reusable prop \"resources\" is selected more than once.");
33
- definitions.resources = _jfdevelops_react_layout_validator.createProp.array(resource);
34
- }
35
- for (const [key, custom] of Object.entries(definition.props?.custom ?? {})) {
36
- if (Object.hasOwn(definitions, key)) throw new require_layout_configuration_error.LayoutConfigurationError(`Reusable prop "${key}" is selected more than once.`);
37
- definitions[key] = custom;
157
+ function compile(selection, from) {
158
+ let plan = objectPlan({});
159
+ for (const [key, value] of Object.entries(selection)) {
160
+ let next;
161
+ if (key === "options") {
162
+ if (value !== true && typeof value !== "function" && (!value || typeof value !== "object" || Array.isArray(value))) throw new require_layout_configuration_error.LayoutConfigurationError("Invalid reusable options selection.");
163
+ next = typeof value === "function" ? objectPlan({ options: {
164
+ kind: "value",
165
+ source: "option",
166
+ from: "options",
167
+ path: [],
168
+ selector: value
169
+ } }) : optionPlan(optionDefinitions, value, from);
170
+ } else if (key === "resources" && (value === true || typeof value === "function")) next = objectPlan({ resources: {
171
+ kind: "value",
172
+ source: "resource",
173
+ from: value === true && from === "props" ? "props" : "resources",
174
+ path: value === true && from === "props" ? ["resources"] : [],
175
+ selector: typeof value === "function" ? value : void 0,
176
+ definition: value === true && from === "props" ? _jfdevelops_react_layout_validator.createProp.array(resource) : void 0
177
+ } });
178
+ else throw new require_layout_configuration_error.LayoutConfigurationError(`Invalid reusable source "${key}".`);
179
+ plan = mergePlans(plan, next);
180
+ }
181
+ return plan;
38
182
  }
183
+ let included = compile(include, "props");
184
+ const custom = objectPlan(Object.fromEntries(Object.entries(definition.props?.custom ?? {}).map(([key, value]) => [key, {
185
+ kind: "value",
186
+ source: "custom",
187
+ from: "props",
188
+ path: [key],
189
+ definition: value
190
+ }])));
191
+ included = mergePlans(included, custom);
192
+ const selected = compile(select, "options");
193
+ const plan = mergePlans(included, selected, definition.overlap);
194
+ const callerDefinitions = planDefinitions(withoutSharedCallerValues(included, selected), "props");
195
+ const effectiveCallerDefinitions = planDefinitions(plan, "props");
196
+ const sources = mergeSelections(sourceSelection(include.options, true), sourceSelection(select.options, false));
197
+ const sourceDefinitions = sources === true ? optionDefinitions : planDefinitions(optionPlan(optionDefinitions, sources, "options"), "options");
198
+ const needsOptions = Object.keys(sourceDefinitions).length > 0;
199
+ if (needsOptions && Object.hasOwn(callerDefinitions, "options")) throw new require_layout_configuration_error.LayoutConfigurationError("Reusable prop \"options\" is reserved for source values.");
39
200
  return function reusable(props = {}) {
40
- (0, _jfdevelops_react_layout_validator.validateProps)(definitions, props);
41
- return definition.fn(props);
201
+ (0, _jfdevelops_react_layout_validator.validateProps)(definition.overlap ? callerDefinitions : effectiveCallerDefinitions, props);
202
+ if (needsOptions && props.options !== void 0 && (props.options === null || typeof props.options !== "object" || Array.isArray(props.options))) throw new require_layout_configuration_error.LayoutConfigurationError("Reusable source options must be an object.");
203
+ const values = props.options ?? {};
204
+ (0, _jfdevelops_react_layout_validator.validateProps)(sourceDefinitions, values);
205
+ return definition.fn(resolvePlan(plan, props, values, resourcesAccessor));
42
206
  };
43
207
  }
44
208
  return createReusable;
@@ -1 +1 @@
1
- {"version":3,"file":"create-reusable.cjs","names":["LayoutConfigurationError","createProp"],"sources":["../../src/create-config/create-reusable.ts"],"sourcesContent":["import {\n createProp,\n validateProps,\n type AnyBuiltPropDefinition,\n type ExtractDefinitionValue,\n type ResolvedBuiltPropShape,\n} from '@jfdevelops/react-layout-validator';\nimport type {\n InferredInProps,\n InPropsDefinition,\n InPropsObject,\n} from '../props';\nimport type { ResourceDefinition, ResourceEnum } from '../resource';\nimport { LayoutConfigurationError } from '../errors';\n\n/** Object definitions can be selected recursively; other definitions are leaves. */\nexport type ReusableOptionSelection<Props extends InPropsObject> = {\n [Key in keyof Props]?: Props[Key] extends {\n type: 'object';\n properties: infer Shape extends InPropsObject;\n }\n ? true | ReusableOptionSelection<Shape>\n : true;\n};\n\ntype OptionDefinitions<\n Resources extends readonly ResourceDefinition[],\n Options extends InPropsDefinition<Resources>,\n> = InferredInProps<\n Resources,\n Options\n> extends infer Props extends InPropsObject\n ? Props\n : never;\n\n/** Only data sources declared by the factory are available for selection. */\nexport type ReusableInclude<\n Resources extends readonly ResourceDefinition[],\n Options extends InPropsDefinition<Resources>,\n> = { resources?: true } & (keyof OptionDefinitions<\n Resources,\n Options\n> extends never\n ? {}\n : {\n options?:\n | true\n | ReusableOptionSelection<OptionDefinitions<Resources, Options>>;\n });\n\ntype SelectedOptionValue<\n Definition extends AnyBuiltPropDefinition,\n Selection,\n> = Selection extends true\n ? ExtractDefinitionValue<Definition>\n : Definition extends { properties: infer Shape extends InPropsObject }\n ? SelectedOptionProps<Shape, Selection>\n : never;\n\ntype SelectedOptionProps<Props extends InPropsObject, Selection> = {\n [Key in keyof Props &\n keyof Selection as Props[Key]['visibility'] extends 'required'\n ? Key\n : never]: SelectedOptionValue<Props[Key], Selection[Key]>;\n} & {\n [Key in keyof Props &\n keyof Selection as Props[Key]['visibility'] extends 'optional'\n ? Key\n : never]?: SelectedOptionValue<Props[Key], Selection[Key]>;\n};\n\n/** Options are flattened one level, so `options: { meta: true }` supplies `meta`. */\nexport type ReusableProps<\n Resources extends readonly ResourceDefinition[],\n Options extends InPropsDefinition<Resources>,\n Include,\n Custom extends InPropsObject,\n> = (Include extends { resources: true }\n ? { resources: ResourceEnum<Resources>[number][] }\n : {}) &\n (Include extends { options: infer Selection }\n ? Selection extends true\n ? ResolvedBuiltPropShape<OptionDefinitions<Resources, Options>>\n : SelectedOptionProps<OptionDefinitions<Resources, Options>, Selection>\n : {}) &\n ResolvedBuiltPropShape<Custom>;\n\n// Generic constraints alone accept extra keys on structurally compatible objects.\ntype ExactSelection<Selection, Allowed> = {\n [Key in keyof Selection]: Key extends keyof Allowed\n ? Selection[Key] extends object\n ? ExactSelection<Selection[Key], Exclude<Allowed[Key], true | undefined>>\n : Allowed[Key]\n : never;\n};\n\n/** Creates a validated ordinary function with the shared configuration's types. */\nexport type CreateReusable<\n Resources extends readonly ResourceDefinition[],\n Options extends InPropsDefinition<Resources>,\n> = <\n const Include extends ReusableInclude<Resources, Options> = {},\n const Custom extends InPropsObject = {},\n Result = unknown,\n>(definition: {\n props?: {\n include?: ReusableInclude<Resources, Options> &\n Include &\n ExactSelection<Include, ReusableInclude<Resources, Options>>;\n custom?: Custom;\n };\n fn: (props: ReusableProps<Resources, Options, Include, Custom>) => Result;\n}) => (\n ...args: {} extends ReusableProps<Resources, Options, Include, Custom>\n ? [props?: ReusableProps<Resources, Options, Include, Custom>]\n : [props: ReusableProps<Resources, Options, Include, Custom>]\n) => Result;\n\nfunction selectOptions(\n definitions: InPropsObject,\n selection: Record<string, unknown>,\n) {\n const selected: InPropsObject = {};\n for (const [key, include] of Object.entries(selection)) {\n const definition = definitions[key];\n if (!Object.hasOwn(definitions, key)) {\n throw new LayoutConfigurationError(`Unknown reusable option \"${key}\".`);\n }\n if (include === true) {\n selected[key] = definition;\n continue;\n }\n if (\n !include ||\n typeof include !== 'object' ||\n !('properties' in definition) ||\n !('type' in definition) ||\n definition.type !== 'object'\n ) {\n throw new LayoutConfigurationError(\n `Invalid reusable selection for \"${key}\".`,\n );\n }\n const nested = createProp.object(\n selectOptions(\n definition.properties as InPropsObject,\n include as Record<string, unknown>,\n ),\n );\n selected[key] =\n definition.visibility === 'optional' ? nested.optional() : nested;\n }\n return selected;\n}\n\nexport function createReusableBuilder<\n const Resources extends readonly ResourceDefinition[],\n Options extends InPropsDefinition<Resources>,\n>(resources: Resources, options: Options): CreateReusable<Resources, Options>;\nexport function createReusableBuilder(\n resources: readonly ResourceDefinition[],\n options: InPropsObject | ((...args: any[]) => InPropsObject),\n) {\n const keys = resources.map((entry) =>\n typeof entry === 'string' ? entry : entry.value,\n );\n const resource = createProp.string.enum(keys as [string, ...string[]]);\n\n function createReusable(definition: {\n props?: { include?: Record<string, unknown>; custom?: InPropsObject };\n fn: (props: Record<string, unknown>) => unknown;\n }) {\n const include = definition.props?.include ?? {};\n for (const key of Object.keys(include)) {\n if (key !== 'resources' && key !== 'options') {\n throw new LayoutConfigurationError(`Unknown reusable source \"${key}\".`);\n }\n }\n const optionDefinitions =\n typeof options === 'function'\n ? options({ name: createProp.string.literal('Reusable'), resource })\n : options;\n const selected =\n include.options === true\n ? optionDefinitions\n : include.options\n ? selectOptions(\n optionDefinitions,\n include.options as Record<string, unknown>,\n )\n : {};\n const definitions: InPropsObject = { ...selected };\n if (include.resources) {\n if (Object.hasOwn(definitions, 'resources')) {\n throw new LayoutConfigurationError(\n 'Reusable prop \"resources\" is selected more than once.',\n );\n }\n definitions.resources = createProp.array(resource);\n }\n for (const [key, custom] of Object.entries(\n definition.props?.custom ?? {},\n )) {\n if (Object.hasOwn(definitions, key)) {\n throw new LayoutConfigurationError(\n `Reusable prop \"${key}\" is selected more than once.`,\n );\n }\n definitions[key] = custom;\n }\n\n return function reusable(props: Record<string, unknown> = {}) {\n validateProps(definitions, props);\n return definition.fn(props);\n };\n }\n\n return createReusable as unknown;\n}\n"],"mappings":";;;;AAsHA,SAAS,cACP,aACA,WACA;CACA,MAAM,WAA0B,CAAC;CACjC,KAAK,MAAM,CAAC,KAAK,YAAY,OAAO,QAAQ,SAAS,GAAG;EACtD,MAAM,aAAa,YAAY;EAC/B,IAAI,CAAC,OAAO,OAAO,aAAa,GAAG,GACjC,MAAM,IAAIA,4DAAyB,4BAA4B,IAAI,GAAG;EAExE,IAAI,YAAY,MAAM;GACpB,SAAS,OAAO;GAChB;EACF;EACA,IACE,CAAC,WACD,OAAO,YAAY,YACnB,EAAE,gBAAgB,eAClB,EAAE,UAAU,eACZ,WAAW,SAAS,UAEpB,MAAM,IAAIA,4DACR,mCAAmC,IAAI,GACzC;EAEF,MAAM,SAASC,8CAAW,OACxB,cACE,WAAW,YACX,OACF,CACF;EACA,SAAS,OACP,WAAW,eAAe,aAAa,OAAO,SAAS,IAAI;CAC/D;CACA,OAAO;AACT;AAMA,SAAgB,sBACd,WACA,SACA;CACA,MAAM,OAAO,UAAU,KAAK,UAC1B,OAAO,UAAU,WAAW,QAAQ,MAAM,KAC5C;CACA,MAAM,WAAWA,8CAAW,OAAO,KAAK,IAA6B;CAErE,SAAS,eAAe,YAGrB;EACD,MAAM,UAAU,WAAW,OAAO,WAAW,CAAC;EAC9C,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,GACnC,IAAI,QAAQ,eAAe,QAAQ,WACjC,MAAM,IAAID,4DAAyB,4BAA4B,IAAI,GAAG;EAG1E,MAAM,oBACJ,OAAO,YAAY,aACf,QAAQ;GAAE,MAAMC,8CAAW,OAAO,QAAQ,UAAU;GAAG;EAAS,CAAC,IACjE;EAUN,MAAM,cAA6B,EAAE,GARnC,QAAQ,YAAY,OAChB,oBACA,QAAQ,UACR,cACE,mBACA,QAAQ,OACV,IACA,CAAC,EAC0C;EACjD,IAAI,QAAQ,WAAW;GACrB,IAAI,OAAO,OAAO,aAAa,WAAW,GACxC,MAAM,IAAID,4DACR,yDACF;GAEF,YAAY,YAAYC,8CAAW,MAAM,QAAQ;EACnD;EACA,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QACjC,WAAW,OAAO,UAAU,CAAC,CAC/B,GAAG;GACD,IAAI,OAAO,OAAO,aAAa,GAAG,GAChC,MAAM,IAAID,4DACR,kBAAkB,IAAI,8BACxB;GAEF,YAAY,OAAO;EACrB;EAEA,OAAO,SAAS,SAAS,QAAiC,CAAC,GAAG;GAC5D,sDAAc,aAAa,KAAK;GAChC,OAAO,WAAW,GAAG,KAAK;EAC5B;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"create-reusable.cjs","names":["LayoutConfigurationError","createProp","createLayoutResourcesAccessor"],"sources":["../../src/create-config/create-reusable.ts"],"sourcesContent":["import {\n createProp,\n validateProps,\n type AnyBuiltPropDefinition,\n} from '@jfdevelops/react-layout-validator';\nimport type { InPropsDefinition, InPropsObject, PropsContract } from '../props';\nimport type { ResourceDefinition } from '../resource';\nimport { LayoutConfigurationError } from '../errors';\nimport { createLayoutResourcesAccessor } from './define-layout';\nimport type { CreateReusable, ReusableOverlap } from './reusable-types';\nexport type * from './reusable-types';\n\ntype RuntimeSelection = Record<string, unknown>;\ntype PlanLocation = { from: 'props' | 'options' | 'resources'; path: string[] };\ntype ValuePlan = PlanLocation & {\n kind: 'value';\n // Optional ancestors remain tied to the value's original source after merging.\n guards?: PlanLocation[];\n source: 'option' | 'resource' | 'custom';\n selector?: (value: any) => unknown;\n definition?: AnyBuiltPropDefinition;\n};\ntype ObjectPlan = {\n kind: 'object';\n children: Record<string, Plan>;\n optional: boolean;\n guards: PlanLocation[][];\n};\ntype Plan = ValuePlan | ObjectPlan;\n\nfunction objectPlan(\n children: Record<string, Plan>,\n optional = false,\n guards: PlanLocation[][] = [[]],\n): ObjectPlan {\n return { kind: 'object', children, optional, guards };\n}\n\nfunction optionPlan(\n definitions: InPropsObject,\n selection: unknown,\n from: 'props' | 'options',\n path: string[] = [],\n optionalPaths: string[][] = [],\n): ObjectPlan {\n const entries =\n selection === true\n ? Object.fromEntries(Object.keys(definitions).map((key) => [key, true]))\n : (selection as RuntimeSelection);\n const children: Record<string, Plan> = {};\n for (const [key, value] of Object.entries(entries ?? {})) {\n if (!Object.hasOwn(definitions, key))\n throw new LayoutConfigurationError(`Unknown reusable option \"${key}\".`);\n const definition = definitions[key];\n const location: PlanLocation = { from, path: [...path, key] };\n if (typeof value === 'function') {\n children[key] = {\n ...location,\n from: 'options',\n guards: optionalPaths.map((path) => ({ from: 'options', path })),\n kind: 'value',\n source: 'option',\n selector: value as ValuePlan['selector'],\n definition,\n };\n } else if (\n 'properties' in definition &&\n 'type' in definition &&\n definition.type === 'object' &&\n (value === true || (value && typeof value === 'object'))\n ) {\n const nested = optionPlan(\n definition.properties as InPropsObject,\n value,\n from,\n location.path,\n definition.visibility === 'optional'\n ? [...optionalPaths, location.path]\n : optionalPaths,\n );\n children[key] = {\n ...nested,\n optional: definition.visibility === 'optional',\n };\n } else if (value === true) {\n children[key] = {\n ...location,\n guards: optionalPaths.map((path) => ({ from, path })),\n kind: 'value',\n source: 'option',\n definition,\n };\n } else\n throw new LayoutConfigurationError(\n `Invalid reusable selection for \"${key}\".`,\n );\n }\n const origins = new Set<PlanLocation['from']>();\n function collectOrigins(node: Plan) {\n if (node.kind === 'value') origins.add(node.from);\n else Object.values(node.children).forEach(collectOrigins);\n }\n Object.values(children).forEach(collectOrigins);\n if (!origins.size) origins.add(from);\n return objectPlan(\n children,\n false,\n [...origins].map((origin) =>\n optionalPaths.map((path) => ({ from: origin, path })),\n ),\n );\n}\n\nfunction sameSelection(left: ValuePlan, right: ValuePlan) {\n return (\n left.source === right.source &&\n left.selector === right.selector &&\n left.path.join('.') === right.path.join('.') &&\n (left.source === 'option' || left.from === right.from)\n );\n}\n\nfunction mergePlans(\n left: ObjectPlan,\n right: ObjectPlan,\n overlap?: ReusableOverlap,\n path: string[] = [],\n): ObjectPlan {\n const children = { ...left.children };\n for (const [key, other] of Object.entries(right.children)) {\n const current = children[key];\n if (!current) {\n children[key] = other;\n continue;\n }\n if (current.kind === 'object' && other.kind === 'object') {\n children[key] = mergePlans(current, other, overlap, [...path, key]);\n } else if (\n current.kind === 'value' &&\n other.kind === 'value' &&\n sameSelection(current, other)\n ) {\n // A shared option selection uses one source value and executes only once.\n children[key] = other.from === 'options' ? other : current;\n } else if (overlap)\n children[key] = overlap === 'preferProps' ? current : other;\n else\n throw new LayoutConfigurationError(\n `Ambiguous reusable property \"${[...path, key].join(\n '.',\n )}\". Rename one result or set overlap to \"preferProps\" or \"preferSelect\".`,\n );\n }\n return {\n kind: 'object',\n children,\n optional: left.optional && right.optional,\n guards: [...left.guards, ...right.guards],\n };\n}\n\nfunction withoutSharedCallerValues(\n left: ObjectPlan,\n right: ObjectPlan,\n): ObjectPlan {\n const children = { ...left.children };\n for (const [key, other] of Object.entries(right.children)) {\n const current = children[key];\n if (current?.kind === 'object' && other.kind === 'object')\n children[key] = withoutSharedCallerValues(current, other);\n else if (\n current?.kind === 'value' &&\n other.kind === 'value' &&\n sameSelection(current, other) &&\n other.from === 'options'\n )\n delete children[key];\n }\n return { ...left, children };\n}\n\nfunction planDefinitions(\n plan: ObjectPlan,\n from: 'props' | 'options',\n): InPropsObject {\n const definitions: InPropsObject = {};\n for (const [key, value] of Object.entries(plan.children)) {\n if (value.kind === 'value') {\n if (value.from === from && value.definition)\n definitions[key] = value.definition;\n } else {\n const nested = planDefinitions(value, from);\n if (Object.keys(nested).length) {\n const definition = createProp.object(nested);\n definitions[key] = value.optional ? definition.optional() : definition;\n }\n }\n }\n return definitions;\n}\n\nfunction sourceSelection(\n selection: unknown,\n callbacksOnly: boolean,\n): true | RuntimeSelection {\n if (typeof selection === 'function') return true;\n if (selection === true) return callbacksOnly ? {} : true;\n const source: RuntimeSelection = {};\n for (const [key, value] of Object.entries(\n (selection ?? {}) as RuntimeSelection,\n )) {\n const nested = sourceSelection(value, callbacksOnly);\n if (nested === true || Object.keys(nested).length) source[key] = nested;\n }\n return source;\n}\n\nfunction mergeSelections(\n left: true | RuntimeSelection,\n right: true | RuntimeSelection,\n): true | RuntimeSelection {\n if (left === true || right === true) return true;\n const merged = { ...left };\n for (const [key, value] of Object.entries(right))\n merged[key] = Object.hasOwn(left, key)\n ? mergeSelections(\n left[key] as true | RuntimeSelection,\n value as true | RuntimeSelection,\n )\n : value;\n return merged;\n}\n\nfunction readLocation(\n location: PlanLocation,\n props: Record<string, unknown>,\n options: Record<string, unknown>,\n resources: unknown,\n) {\n let value: any =\n location.from === 'props'\n ? props\n : location.from === 'options'\n ? options\n : resources;\n for (const key of location.path) value = value?.[key];\n return value;\n}\n\nfunction resolvePlan(\n plan: ObjectPlan,\n props: Record<string, unknown>,\n options: Record<string, unknown>,\n resources: unknown,\n) {\n const result: Record<string, unknown> = {};\n for (const [key, node] of Object.entries(plan.children)) {\n if (node.kind === 'object') {\n if (\n node.guards.some((group) =>\n group.every(\n (location) =>\n readLocation(location, props, options, resources) !== undefined,\n ),\n )\n ) {\n result[key] = resolvePlan(node, props, options, resources);\n }\n } else {\n if (\n node.guards?.some(\n (location) =>\n readLocation(location, props, options, resources) === undefined,\n )\n )\n continue;\n const value = readLocation(node, props, options, resources);\n if (node.selector) result[key] = node.selector(value);\n else if (\n value !== undefined ||\n node.definition?.visibility !== 'optional'\n )\n result[key] = value;\n }\n }\n return result;\n}\n\nexport function createReusableBuilder<\n const Resources extends readonly ResourceDefinition[],\n Options extends InPropsDefinition<Resources>,\n>(resources: Resources, options: Options): CreateReusable<Resources, Options>;\nexport function createReusableBuilder(\n resources: readonly ResourceDefinition[],\n options: InPropsObject | ((...args: any[]) => InPropsObject),\n) {\n const keys = resources.map((entry) =>\n typeof entry === 'string' ? entry : entry.value,\n );\n const resource = createProp.string.enum(keys as [string, ...string[]]);\n const resourcesAccessor = createLayoutResourcesAccessor(resources);\n\n function createReusable(definition: {\n props?: PropsContract<RuntimeSelection, InPropsObject>;\n select?: RuntimeSelection;\n overlap?: ReusableOverlap;\n fn: (props: Record<string, unknown>) => unknown;\n }) {\n const include = definition.props?.include ?? {};\n const select = definition.select ?? {};\n if (\n definition.overlap !== undefined &&\n definition.overlap !== 'preferProps' &&\n definition.overlap !== 'preferSelect'\n ) {\n throw new LayoutConfigurationError('Unknown reusable overlap policy.');\n }\n const optionDefinitions =\n typeof options === 'function'\n ? options({ name: createProp.string.literal('Reusable'), resource })\n : options;\n\n function compile(selection: RuntimeSelection, from: 'props' | 'options') {\n let plan = objectPlan({});\n for (const [key, value] of Object.entries(selection)) {\n let next: ObjectPlan;\n if (key === 'options') {\n if (\n value !== true &&\n typeof value !== 'function' &&\n (!value || typeof value !== 'object' || Array.isArray(value))\n ) {\n throw new LayoutConfigurationError(\n 'Invalid reusable options selection.',\n );\n }\n next =\n typeof value === 'function'\n ? objectPlan({\n options: {\n kind: 'value',\n source: 'option',\n from: 'options',\n path: [],\n selector: value as ValuePlan['selector'],\n },\n })\n : optionPlan(optionDefinitions, value, from);\n } else if (\n key === 'resources' &&\n (value === true || typeof value === 'function')\n ) {\n next = objectPlan({\n resources: {\n kind: 'value',\n source: 'resource',\n from: value === true && from === 'props' ? 'props' : 'resources',\n path: value === true && from === 'props' ? ['resources'] : [],\n selector:\n typeof value === 'function'\n ? (value as ValuePlan['selector'])\n : undefined,\n definition:\n value === true && from === 'props'\n ? createProp.array(resource)\n : undefined,\n },\n });\n } else\n throw new LayoutConfigurationError(\n `Invalid reusable source \"${key}\".`,\n );\n plan = mergePlans(plan, next);\n }\n return plan;\n }\n\n let included = compile(include, 'props');\n const custom = objectPlan(\n Object.fromEntries(\n Object.entries(definition.props?.custom ?? {}).map(([key, value]) => [\n key,\n {\n kind: 'value',\n source: 'custom',\n from: 'props',\n path: [key],\n definition: value,\n } as ValuePlan,\n ]),\n ),\n );\n included = mergePlans(included, custom);\n const selected = compile(select, 'options');\n const plan = mergePlans(included, selected, definition.overlap);\n const callerDefinitions = planDefinitions(\n withoutSharedCallerValues(included, selected),\n 'props',\n );\n // Identical true selections supplied by select are removed from the caller props contract.\n const effectiveCallerDefinitions = planDefinitions(plan, 'props');\n const sources = mergeSelections(\n sourceSelection(include.options, true),\n sourceSelection(select.options, false),\n );\n const sourceDefinitions =\n sources === true\n ? optionDefinitions\n : planDefinitions(\n optionPlan(optionDefinitions, sources, 'options'),\n 'options',\n );\n const needsOptions = Object.keys(sourceDefinitions).length > 0;\n if (needsOptions && Object.hasOwn(callerDefinitions, 'options')) {\n throw new LayoutConfigurationError(\n 'Reusable prop \"options\" is reserved for source values.',\n );\n }\n\n return function reusable(props: Record<string, unknown> = {}) {\n // Validate configured caller props too when an explicit overlap policy discards their output.\n const definitions = definition.overlap\n ? callerDefinitions\n : effectiveCallerDefinitions;\n validateProps(definitions, props);\n if (\n needsOptions &&\n props.options !== undefined &&\n (props.options === null ||\n typeof props.options !== 'object' ||\n Array.isArray(props.options))\n ) {\n throw new LayoutConfigurationError(\n 'Reusable source options must be an object.',\n );\n }\n const values = (props.options ?? {}) as Record<string, unknown>;\n validateProps(sourceDefinitions, values);\n return definition.fn(resolvePlan(plan, props, values, resourcesAccessor));\n };\n }\n return createReusable as unknown;\n}\n"],"mappings":";;;;;AA8BA,SAAS,WACP,UACA,WAAW,OACX,SAA2B,CAAC,CAAC,CAAC,GAClB;CACZ,OAAO;EAAE,MAAM;EAAU;EAAU;EAAU;CAAO;AACtD;AAEA,SAAS,WACP,aACA,WACA,MACA,OAAiB,CAAC,GAClB,gBAA4B,CAAC,GACjB;CACZ,MAAM,UACJ,cAAc,OACV,OAAO,YAAY,OAAO,KAAK,WAAW,EAAE,KAAK,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC,IACpE;CACP,MAAM,WAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,WAAW,CAAC,CAAC,GAAG;EACxD,IAAI,CAAC,OAAO,OAAO,aAAa,GAAG,GACjC,MAAM,IAAIA,4DAAyB,4BAA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