@jfdevelops/react-layout 2.4.0 → 2.5.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.
- package/dist/create-config/create-reusable.cjs +19 -6
- package/dist/create-config/create-reusable.cjs.map +1 -1
- package/dist/create-config/create-reusable.d.cts +1 -0
- package/dist/create-config/create-reusable.d.mts +1 -0
- package/dist/create-config/create-reusable.mjs +19 -6
- package/dist/create-config/create-reusable.mjs.map +1 -1
- package/dist/create-config/index.d.cts +1 -0
- package/dist/create-config/index.d.mts +1 -0
- package/dist/create-config/reusable-resource-input.cjs +22 -0
- package/dist/create-config/reusable-resource-input.cjs.map +1 -0
- package/dist/create-config/reusable-resource-input.d.cts +16 -0
- package/dist/create-config/reusable-resource-input.d.cts.map +1 -0
- package/dist/create-config/reusable-resource-input.d.mts +16 -0
- package/dist/create-config/reusable-resource-input.d.mts.map +1 -0
- package/dist/create-config/reusable-resource-input.mjs +19 -0
- package/dist/create-config/reusable-resource-input.mjs.map +1 -0
- package/dist/create-config/reusable-types.d.cts +14 -6
- package/dist/create-config/reusable-types.d.cts.map +1 -1
- package/dist/create-config/reusable-types.d.mts +14 -6
- package/dist/create-config/reusable-types.d.mts.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_layout_configuration_error = require('../errors/layout-configuration-error.cjs');
|
|
2
2
|
const require_define_layout = require('./define-layout.cjs');
|
|
3
|
+
const require_reusable_resource_input = require('./reusable-resource-input.cjs');
|
|
3
4
|
let _jfdevelops_react_layout_validator = require("@jfdevelops/react-layout-validator");
|
|
4
5
|
|
|
5
6
|
//#region src/create-config/create-reusable.ts
|
|
@@ -130,22 +131,27 @@ function readLocation(location, props, options, resources) {
|
|
|
130
131
|
for (const key of location.path) value = value?.[key];
|
|
131
132
|
return value;
|
|
132
133
|
}
|
|
133
|
-
function resolvePlan(plan, props, options, resources) {
|
|
134
|
+
function resolvePlan(plan, props, options, resources, resourceSelections) {
|
|
134
135
|
const result = {};
|
|
135
136
|
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
|
+
if (node.guards.some((group) => group.every((location) => readLocation(location, props, options, resources) !== void 0))) result[key] = resolvePlan(node, props, options, resources, resourceSelections);
|
|
137
138
|
} else {
|
|
138
139
|
if (node.guards?.some((location) => readLocation(location, props, options, resources) === void 0)) continue;
|
|
139
140
|
const value = readLocation(node, props, options, resources);
|
|
140
|
-
if (node.selector)
|
|
141
|
-
|
|
141
|
+
if (node.selector) {
|
|
142
|
+
const selected = node.source === "resource" ? resourceSelections.get(node.selector) : node.selector(value);
|
|
143
|
+
result[key] = node.source === "resource" && require_reusable_resource_input.isSingleResourceInput(selected) ? props.resources : selected;
|
|
144
|
+
} else if (value !== void 0 || node.definition?.visibility !== "optional") result[key] = value;
|
|
142
145
|
}
|
|
143
146
|
return result;
|
|
144
147
|
}
|
|
145
148
|
function createReusableBuilder(resources, options) {
|
|
146
149
|
const keys = resources.map((entry) => typeof entry === "string" ? entry : entry.value);
|
|
147
150
|
const resource = _jfdevelops_react_layout_validator.createProp.string.enum(keys);
|
|
148
|
-
const
|
|
151
|
+
const singleResource = _jfdevelops_react_layout_validator.createProp.string.enum(require_reusable_resource_input.getResourcePaths(resources));
|
|
152
|
+
const resourcesAccessor = Object.assign(require_define_layout.createLayoutResourcesAccessor(resources), { single() {
|
|
153
|
+
return { [require_reusable_resource_input.singleResourceInput]: resources };
|
|
154
|
+
} });
|
|
149
155
|
function createReusable(definition) {
|
|
150
156
|
const include = definition.props?.include ?? {};
|
|
151
157
|
const select = definition.select ?? {};
|
|
@@ -195,6 +201,7 @@ function createReusableBuilder(resources, options) {
|
|
|
195
201
|
const effectiveCallerDefinitions = planDefinitions(plan, "props");
|
|
196
202
|
const sources = mergeSelections(sourceSelection(include.options, true), sourceSelection(select.options, false));
|
|
197
203
|
const sourceDefinitions = sources === true ? optionDefinitions : planDefinitions(optionPlan(optionDefinitions, sources, "options"), "options");
|
|
204
|
+
const resourceSelectors = new Set([include.resources, select.resources].filter((selector) => typeof selector === "function"));
|
|
198
205
|
const needsOptions = Object.keys(sourceDefinitions).length > 0;
|
|
199
206
|
if (needsOptions && Object.hasOwn(callerDefinitions, "options")) throw new require_layout_configuration_error.LayoutConfigurationError("Reusable prop \"options\" is reserved for source values.");
|
|
200
207
|
return function reusable(props = {}) {
|
|
@@ -202,7 +209,13 @@ function createReusableBuilder(resources, options) {
|
|
|
202
209
|
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
210
|
const values = props.options ?? {};
|
|
204
211
|
(0, _jfdevelops_react_layout_validator.validateProps)(sourceDefinitions, values);
|
|
205
|
-
|
|
212
|
+
const resourceSelections = /* @__PURE__ */ new Map();
|
|
213
|
+
for (const selector of resourceSelectors) {
|
|
214
|
+
const selected = selector(resourcesAccessor);
|
|
215
|
+
if (require_reusable_resource_input.isSingleResourceInput(selected)) (0, _jfdevelops_react_layout_validator.validateProps)({ resources: singleResource }, props);
|
|
216
|
+
resourceSelections.set(selector, selected);
|
|
217
|
+
}
|
|
218
|
+
return definition.fn(resolvePlan(plan, props, values, resourcesAccessor, resourceSelections));
|
|
206
219
|
};
|
|
207
220
|
}
|
|
208
221
|
return createReusable;
|
|
@@ -1 +1 @@
|
|
|
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,4BAA4B,IAAI,GAAG;EACxE,MAAM,aAAa,YAAY;EAC/B,MAAM,WAAyB;GAAE;GAAM,MAAM,CAAC,GAAG,MAAM,GAAG;EAAE;EAC5D,IAAI,OAAO,UAAU,YACnB,SAAS,OAAO;GACd,GAAG;GACH,MAAM;GACN,QAAQ,cAAc,KAAK,UAAU;IAAE,MAAM;IAAW;GAAK,EAAE;GAC/D,MAAM;GACN,QAAQ;GACR,UAAU;GACV;EACF;OACK,IACL,gBAAgB,cAChB,UAAU,cACV,WAAW,SAAS,aACnB,UAAU,QAAS,SAAS,OAAO,UAAU,WAW9C,SAAS,OAAO;GACd,GAVa,WACb,WAAW,YACX,OACA,MACA,SAAS,MACT,WAAW,eAAe,aACtB,CAAC,GAAG,eAAe,SAAS,IAAI,IAChC,aAGI;GACR,UAAU,WAAW,eAAe;EACtC;OACK,IAAI,UAAU,MACnB,SAAS,OAAO;GACd,GAAG;GACH,QAAQ,cAAc,KAAK,UAAU;IAAE;IAAM;GAAK,EAAE;GACpD,MAAM;GACN,QA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ACvC,MAAM,SAAS,WACb,OAAO,YACL,OAAO,QAAQ,WAAW,OAAO,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,WAAW,CACnE,KACA;GACE,MAAM;GACN,QAAQ;GACR,MAAM;GACN,MAAM,CAAC,GAAG;GACV,YAAY;EACd,CACF,CAAC,CACH,CACF;EACA,WAAW,WAAW,UAAU,MAAM;EACtC,MAAM,WAAW,QAAQ,QAAQ,SAAS;EAC1C,MAAM,OAAO,WAAW,UAAU,UAAU,WAAW,OAAO;EAC9D,MAAM,oBAAoB,gBACxB,0BAA0B,UAAU,QAAQ,GAC5C,OACF;EAEA,MAAM,6BAA6B,gBAAgB,MAAM,OAAO;EAChE,MAAM,UAAU,gBACd,gBAAgB,QAAQ,SAAS,IAAI,GACrC,gBAAgB,OAAO,SAAS,KAAK,CACvC;EACA,MAAM,oBACJ,YAAY,OACR,oBACA,gBACE,WAAW,mBAAmB,SAAS,SAAS,GAChD,SACF;EACN,MAAM,eAAe,OAAO,KAAK,iBAAiB,EAAE,SAAS;EAC7D,IAAI,gBAAgB,OAAO,OAAO,mBAAmB,SAAS,GAC5D,MAAM,IAAIA,4DACR,0DACF;EAGF,OAAO,SAAS,SAAS,QAAiC,CAAC,GAAG;GAK5D,sDAHoB,WAAW,UAC3B,oBACA,4BACuB,KAAK;GAChC,IACE,gBACA,MAAM,YAAY,WACjB,MAAM,YAAY,QACjB,OAAO,MAAM,YAAY,YACzB,MAAM,QAAQ,MAAM,OAAO,IAE7B,MAAM,IAAIA,4DACR,4CACF;GAEF,MAAM,SAAU,MAAM,WAAW,CAAC;GAClC,sDAAc,mBAAmB,MAAM;GACvC,OAAO,WAAW,GAAG,YAAY,MAAM,OAAO,QAAQ,iBAAiB,CAAC;EAC1E;CACF;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"create-reusable.cjs","names":["LayoutConfigurationError","createProp","isSingleResourceInput","getResourcePaths","createLayoutResourcesAccessor","singleResourceInput"],"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';\nimport {\n singleResourceInput,\n isSingleResourceInput,\n getResourcePaths,\n} from './reusable-resource-input';\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 ResourceSelector = NonNullable<ValuePlan['selector']>;\ntype ResourceSelections = Map<ResourceSelector, unknown>;\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 resourceSelections: ResourceSelections,\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(\n node,\n props,\n options,\n resources,\n resourceSelections,\n );\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) {\n const selected =\n node.source === 'resource'\n ? resourceSelections.get(node.selector)\n : node.selector(value);\n result[key] =\n node.source === 'resource' && isSingleResourceInput(selected)\n ? props.resources\n : selected;\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 singleResource = createProp.string.enum(\n getResourcePaths(resources) as [string, ...string[]],\n );\n const resourcesAccessor = Object.assign(\n createLayoutResourcesAccessor(resources),\n {\n single() {\n return { [singleResourceInput]: resources };\n },\n },\n );\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 resourceSelectors = new Set(\n [include.resources, select.resources].filter(\n (selector): selector is ResourceSelector =>\n typeof selector === 'function',\n ),\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 // Resource callbacks also declare caller inputs, independently of overlap precedence.\n const resourceSelections: ResourceSelections = new Map();\n for (const selector of resourceSelectors) {\n const selected = selector(resourcesAccessor);\n if (isSingleResourceInput(selected))\n validateProps({ resources: singleResource }, props);\n resourceSelections.set(selector, selected);\n }\n return definition.fn(\n resolvePlan(plan, props, values, resourcesAccessor, resourceSelections),\n );\n };\n }\n return createReusable as unknown;\n}\n"],"mappings":";;;;;;AAsCA,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,W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BAAkB,CACxE;EACF;CACF;CACA,OAAO;AACT"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
import { ReusableResourcesAccessor, SingleResourceInput } from "./reusable-resource-input.cjs";
|
|
1
2
|
import { CreateReusable, ReusableArguments, ReusableDefinition, ReusableFunction, ReusableInclude, ReusableInput, ReusableOptionSelection, ReusableOverlap, ReusableProps, ReusableResolved, ReusableSelected } from "./reusable-types.cjs";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
import { ReusableResourcesAccessor, SingleResourceInput } from "./reusable-resource-input.mjs";
|
|
1
2
|
import { CreateReusable, ReusableArguments, ReusableDefinition, ReusableFunction, ReusableInclude, ReusableInput, ReusableOptionSelection, ReusableOverlap, ReusableProps, ReusableResolved, ReusableSelected } from "./reusable-types.mjs";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LayoutConfigurationError } from "../errors/layout-configuration-error.mjs";
|
|
2
2
|
import { createLayoutResourcesAccessor } from "./define-layout.mjs";
|
|
3
|
+
import { getResourcePaths, isSingleResourceInput, singleResourceInput } from "./reusable-resource-input.mjs";
|
|
3
4
|
import { createProp, validateProps } from "@jfdevelops/react-layout-validator";
|
|
4
5
|
|
|
5
6
|
//#region src/create-config/create-reusable.ts
|
|
@@ -130,22 +131,27 @@ function readLocation(location, props, options, resources) {
|
|
|
130
131
|
for (const key of location.path) value = value?.[key];
|
|
131
132
|
return value;
|
|
132
133
|
}
|
|
133
|
-
function resolvePlan(plan, props, options, resources) {
|
|
134
|
+
function resolvePlan(plan, props, options, resources, resourceSelections) {
|
|
134
135
|
const result = {};
|
|
135
136
|
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
|
+
if (node.guards.some((group) => group.every((location) => readLocation(location, props, options, resources) !== void 0))) result[key] = resolvePlan(node, props, options, resources, resourceSelections);
|
|
137
138
|
} else {
|
|
138
139
|
if (node.guards?.some((location) => readLocation(location, props, options, resources) === void 0)) continue;
|
|
139
140
|
const value = readLocation(node, props, options, resources);
|
|
140
|
-
if (node.selector)
|
|
141
|
-
|
|
141
|
+
if (node.selector) {
|
|
142
|
+
const selected = node.source === "resource" ? resourceSelections.get(node.selector) : node.selector(value);
|
|
143
|
+
result[key] = node.source === "resource" && isSingleResourceInput(selected) ? props.resources : selected;
|
|
144
|
+
} else if (value !== void 0 || node.definition?.visibility !== "optional") result[key] = value;
|
|
142
145
|
}
|
|
143
146
|
return result;
|
|
144
147
|
}
|
|
145
148
|
function createReusableBuilder(resources, options) {
|
|
146
149
|
const keys = resources.map((entry) => typeof entry === "string" ? entry : entry.value);
|
|
147
150
|
const resource = createProp.string.enum(keys);
|
|
148
|
-
const
|
|
151
|
+
const singleResource = createProp.string.enum(getResourcePaths(resources));
|
|
152
|
+
const resourcesAccessor = Object.assign(createLayoutResourcesAccessor(resources), { single() {
|
|
153
|
+
return { [singleResourceInput]: resources };
|
|
154
|
+
} });
|
|
149
155
|
function createReusable(definition) {
|
|
150
156
|
const include = definition.props?.include ?? {};
|
|
151
157
|
const select = definition.select ?? {};
|
|
@@ -195,6 +201,7 @@ function createReusableBuilder(resources, options) {
|
|
|
195
201
|
const effectiveCallerDefinitions = planDefinitions(plan, "props");
|
|
196
202
|
const sources = mergeSelections(sourceSelection(include.options, true), sourceSelection(select.options, false));
|
|
197
203
|
const sourceDefinitions = sources === true ? optionDefinitions : planDefinitions(optionPlan(optionDefinitions, sources, "options"), "options");
|
|
204
|
+
const resourceSelectors = new Set([include.resources, select.resources].filter((selector) => typeof selector === "function"));
|
|
198
205
|
const needsOptions = Object.keys(sourceDefinitions).length > 0;
|
|
199
206
|
if (needsOptions && Object.hasOwn(callerDefinitions, "options")) throw new LayoutConfigurationError("Reusable prop \"options\" is reserved for source values.");
|
|
200
207
|
return function reusable(props = {}) {
|
|
@@ -202,7 +209,13 @@ function createReusableBuilder(resources, options) {
|
|
|
202
209
|
if (needsOptions && props.options !== void 0 && (props.options === null || typeof props.options !== "object" || Array.isArray(props.options))) throw new LayoutConfigurationError("Reusable source options must be an object.");
|
|
203
210
|
const values = props.options ?? {};
|
|
204
211
|
validateProps(sourceDefinitions, values);
|
|
205
|
-
|
|
212
|
+
const resourceSelections = /* @__PURE__ */ new Map();
|
|
213
|
+
for (const selector of resourceSelectors) {
|
|
214
|
+
const selected = selector(resourcesAccessor);
|
|
215
|
+
if (isSingleResourceInput(selected)) validateProps({ resources: singleResource }, props);
|
|
216
|
+
resourceSelections.set(selector, selected);
|
|
217
|
+
}
|
|
218
|
+
return definition.fn(resolvePlan(plan, props, values, resourcesAccessor, resourceSelections));
|
|
206
219
|
};
|
|
207
220
|
}
|
|
208
221
|
return createReusable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-reusable.mjs","names":[],"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;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,YAAY,OACR,oBACA,gBACE,WAAW,mBAAmB,SAAS,SAAS,GAChD,SACF;EACN,MAAM,eAAe,OAAO,KAAK,iBAAiB,EAAE,SAAS;EAC7D,IAAI,gBAAgB,OAAO,OAAO,mBAAmB,SAAS,GAC5D,MAAM,IAAI,yBACR,0DACF;EAGF,OAAO,SAAS,SAAS,QAAiC,CAAC,GAAG;GAK5D,cAHoB,WAAW,UAC3B,oBACA,4BACuB,KAAK;GAChC,IACE,gBACA,MAAM,YAAY,WACjB,MAAM,YAAY,QACjB,OAAO,MAAM,YAAY,YACzB,MAAM,QAAQ,MAAM,OAAO,IAE7B,MAAM,IAAI,yBACR,4CACF;GAEF,MAAM,SAAU,MAAM,WAAW,CAAC;GAClC,cAAc,mBAAmB,MAAM;GACvC,OAAO,WAAW,GAAG,YAAY,MAAM,OAAO,QAAQ,iBAAiB,CAAC;EAC1E;CACF;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"create-reusable.mjs","names":[],"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';\nimport {\n singleResourceInput,\n isSingleResourceInput,\n getResourcePaths,\n} from './reusable-resource-input';\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 ResourceSelector = NonNullable<ValuePlan['selector']>;\ntype ResourceSelections = Map<ResourceSelector, unknown>;\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 resourceSelections: ResourceSelections,\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(\n node,\n props,\n options,\n resources,\n resourceSelections,\n );\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) {\n const selected =\n node.source === 'resource'\n ? resourceSelections.get(node.selector)\n : node.selector(value);\n result[key] =\n node.source === 'resource' && isSingleResourceInput(selected)\n ? props.resources\n : selected;\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 singleResource = createProp.string.enum(\n getResourcePaths(resources) as [string, ...string[]],\n );\n const resourcesAccessor = Object.assign(\n createLayoutResourcesAccessor(resources),\n {\n single() {\n return { [singleResourceInput]: resources };\n },\n },\n );\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 resourceSelectors = new Set(\n [include.resources, select.resources].filter(\n (selector): selector is ResourceSelector =>\n typeof selector === 'function',\n ),\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 // Resource callbacks also declare caller inputs, independently of overlap precedence.\n const resourceSelections: ResourceSelections = new Map();\n for (const selector of resourceSelectors) {\n const selected = selector(resourcesAccessor);\n if (isSingleResourceInput(selected))\n validateProps({ resources: singleResource }, props);\n resourceSelections.set(selector, selected);\n }\n return definition.fn(\n resolvePlan(plan, props, values, resourcesAccessor, resourceSelections),\n );\n };\n }\n return createReusable as unknown;\n}\n"],"mappings":";;;;;;AAsCA,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,IAAI,yBAAyB,4BAA4B,IAAI,GAAG;EACxE,MAAM,aAAa,YAAY;EAC/B,MAAM,WAAyB;GAAE;GAAM,MAAM,CAAC,GAAG,MAAM,GAAG;EAAE;EAC5D,IAAI,OAAO,UAAU,YACnB,SAAS,OAAO;GACd,GAAG;GACH,MAAM;GACN,QAAQ,cAAc,KAAK,UAAU;IAAE,MAAM;IAAW;GAAK,EAAE;GAC/D,MAAM;GACN,QAAQ;GACR,UAAU;GACV;EACF;OACK,IACL,gBAAgB,cAChB,UAAU,cACV,WAAW,SAAS,aACnB,UAAU,QAAS,SAAS,OAAO,UAAU,WAW9C,SAAS,OAAO;GACd,GAVa,WACb,WAAW,YACX,OACA,MACA,SAAS,MACT,WAAW,eAAe,aACtB,CA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mB,SAAS,GAC5D,MAAM,IAAI,yBACR,0DACF;EAGF,OAAO,SAAS,SAAS,QAAiC,CAAC,GAAG;GAK5D,cAHoB,WAAW,UAC3B,oBACA,4BACuB,KAAK;GAChC,IACE,gBACA,MAAM,YAAY,WACjB,MAAM,YAAY,QACjB,OAAO,MAAM,YAAY,YACzB,MAAM,QAAQ,MAAM,OAAO,IAE7B,MAAM,IAAI,yBACR,4CACF;GAEF,MAAM,SAAU,MAAM,WAAW,CAAC;GAClC,cAAc,mBAAmB,MAAM;GAEvC,MAAM,qCAAyC,IAAI,IAAI;GACvD,KAAK,MAAM,YAAY,mBAAmB;IACxC,MAAM,WAAW,SAAS,iBAAiB;IAC3C,IAAI,sBAAsB,QAAQ,GAChC,cAAc,EAAE,WAAW,eAAe,GAAG,KAAK;IACpD,mBAAmB,IAAI,UAAU,QAAQ;GAC3C;GACA,OAAO,WAAW,GAChB,YAAY,MAAM,OAAO,QAAQ,mBAAmB,kBAAkB,CACxE;EACF;CACF;CACA,OAAO;AACT"}
|
|
@@ -10,6 +10,7 @@ import { IsSubResourceKey, IsSubResourceKeyOptions, IsSubResourceKeyResult } fro
|
|
|
10
10
|
import { ComponentTypes, CreateResourceConfigFn, CreateResourceConfigForResource, CreatedResourceConfig, GetComponent, GetComponentAtBound, GetComponentForResource, GetComponentForResourceOptions, GetComponentOptions, GetComponentOptionsForResource, ResourceConfigFragment, ResourceConfigPath, ResourceFromGetComponentBound, SubResourceFromGetComponentBound, ValidateForResourceBound } from "./get-component.cjs";
|
|
11
11
|
import { CreateResourceLinkConfig, CreateResourceLinkGroupInput, CreateResourceLinkGroupOptions, CreateResourceLinkOptions, CreateResourceLinksFn, CreateResourceLinksWithGroups, CreateResourceLinksWithGroupsFn, CreateResourceLinksWithGroupsResult, CreateResourceMap, CreateResourceMapFn, CreatedResourceHref, CreatedResourceLink, CreatedResourceLinkBase, CreatedResourceMap, DefineResourceIconFn, DefineResourceIconInputHelpers, DefineResourceIconInputResult, FindResolvedResourceGroupResult, FindResourceGroupResult, InferHashFromResourceLinkHref, ResolveResourceIconInput, ResolvedResourceLinksWithGroups, ResolvedResourceLinksWithGroupsResult, ResourceAnchorLinkFn, ResourceIcon, ResourceIconFn, ResourceLinkHref, ValidateResource } from "./create-resource-links.cjs";
|
|
12
12
|
import { ContextualInlineRenderState, ContextualInlineRenderStates, CreateResourceLayoutFn, CreateResourceLayoutMakeComposableOptions, CreateResourceLayoutWithLayoutOptions, CreateViewMapBuiltInRenderStatesOptions, CreateViewMapFunctionRenderOptions, CreateViewMapInlineRenderStatesOptions, CreateViewMapOptions, CreateViewMapRenderStatesOptions, DefineResourceLayout, DefineResourceLayoutFn, DefineResourceLayoutForResources, DefineResourceLayoutForResourcesFactory, DefineResourceLayoutWithLayoutFn, DefineResourcesFn, DefinedResourceLayout, DefinedResourceLayoutWithShell, LayoutDefinition, LayoutIncludeProps, LayoutRenderResourcesAccessor, LayoutResourcesAccessor, ResourceLayoutProvider, ResourceLayoutProviderProps, ResourceLayoutShellComponent, ResourceLayoutShellProps, ResourceSelection, ShellLayoutDefinition, ShellRenderContext, TypedBuiltInRenderStates, TypedInlineRenderState, defineResourceLayout } from "./define-layout.cjs";
|
|
13
|
+
import { ReusableResourcesAccessor, SingleResourceInput } from "./reusable-resource-input.cjs";
|
|
13
14
|
import { CreateReusable, ReusableArguments, ReusableDefinition, ReusableFunction, ReusableInclude, ReusableInput, ReusableOptionSelection, ReusableOverlap, ReusableProps, ReusableResolved, ReusableSelected } from "./reusable-types.cjs";
|
|
14
15
|
import { LazyResourceLayoutComponent, LazyResourceLayoutOptions } from "./lazy-resource-layout.cjs";
|
|
15
16
|
import { BoundDefineResourceLayout, CreateDefinedResourceLayoutOptions, CreateDefinedResourceLayoutResult, DefineLazyDefaults, DefinedResourceLayoutInput, NonEmptyResources, createDefinedResourceLayout } from "./create-defined-resource-layout.cjs";
|
|
@@ -10,6 +10,7 @@ import { IsSubResourceKey, IsSubResourceKeyOptions, IsSubResourceKeyResult } fro
|
|
|
10
10
|
import { ComponentTypes, CreateResourceConfigFn, CreateResourceConfigForResource, CreatedResourceConfig, GetComponent, GetComponentAtBound, GetComponentForResource, GetComponentForResourceOptions, GetComponentOptions, GetComponentOptionsForResource, ResourceConfigFragment, ResourceConfigPath, ResourceFromGetComponentBound, SubResourceFromGetComponentBound, ValidateForResourceBound } from "./get-component.mjs";
|
|
11
11
|
import { CreateResourceLinkConfig, CreateResourceLinkGroupInput, CreateResourceLinkGroupOptions, CreateResourceLinkOptions, CreateResourceLinksFn, CreateResourceLinksWithGroups, CreateResourceLinksWithGroupsFn, CreateResourceLinksWithGroupsResult, CreateResourceMap, CreateResourceMapFn, CreatedResourceHref, CreatedResourceLink, CreatedResourceLinkBase, CreatedResourceMap, DefineResourceIconFn, DefineResourceIconInputHelpers, DefineResourceIconInputResult, FindResolvedResourceGroupResult, FindResourceGroupResult, InferHashFromResourceLinkHref, ResolveResourceIconInput, ResolvedResourceLinksWithGroups, ResolvedResourceLinksWithGroupsResult, ResourceAnchorLinkFn, ResourceIcon, ResourceIconFn, ResourceLinkHref, ValidateResource } from "./create-resource-links.mjs";
|
|
12
12
|
import { ContextualInlineRenderState, ContextualInlineRenderStates, CreateResourceLayoutFn, CreateResourceLayoutMakeComposableOptions, CreateResourceLayoutWithLayoutOptions, CreateViewMapBuiltInRenderStatesOptions, CreateViewMapFunctionRenderOptions, CreateViewMapInlineRenderStatesOptions, CreateViewMapOptions, CreateViewMapRenderStatesOptions, DefineResourceLayout, DefineResourceLayoutFn, DefineResourceLayoutForResources, DefineResourceLayoutForResourcesFactory, DefineResourceLayoutWithLayoutFn, DefineResourcesFn, DefinedResourceLayout, DefinedResourceLayoutWithShell, LayoutDefinition, LayoutIncludeProps, LayoutRenderResourcesAccessor, LayoutResourcesAccessor, ResourceLayoutProvider, ResourceLayoutProviderProps, ResourceLayoutShellComponent, ResourceLayoutShellProps, ResourceSelection, ShellLayoutDefinition, ShellRenderContext, TypedBuiltInRenderStates, TypedInlineRenderState, defineResourceLayout } from "./define-layout.mjs";
|
|
13
|
+
import { ReusableResourcesAccessor, SingleResourceInput } from "./reusable-resource-input.mjs";
|
|
13
14
|
import { CreateReusable, ReusableArguments, ReusableDefinition, ReusableFunction, ReusableInclude, ReusableInput, ReusableOptionSelection, ReusableOverlap, ReusableProps, ReusableResolved, ReusableSelected } from "./reusable-types.mjs";
|
|
14
15
|
import { LazyResourceLayoutComponent, LazyResourceLayoutOptions } from "./lazy-resource-layout.mjs";
|
|
15
16
|
import { BoundDefineResourceLayout, CreateDefinedResourceLayoutOptions, CreateDefinedResourceLayoutResult, DefineLazyDefaults, DefinedResourceLayoutInput, NonEmptyResources, createDefinedResourceLayout } from "./create-defined-resource-layout.mjs";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/create-config/reusable-resource-input.ts
|
|
3
|
+
const singleResourceInput = Symbol("react-layout.single-resource-input");
|
|
4
|
+
function isSingleResourceInput(value) {
|
|
5
|
+
return value !== null && typeof value === "object" && singleResourceInput in value;
|
|
6
|
+
}
|
|
7
|
+
function getResourcePaths(resources, prefix = "") {
|
|
8
|
+
const paths = [];
|
|
9
|
+
for (const resource of resources) {
|
|
10
|
+
const key = typeof resource === "string" ? resource : resource.value;
|
|
11
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
12
|
+
paths.push(path);
|
|
13
|
+
if (typeof resource !== "string") paths.push(...getResourcePaths(resource.subResources, path));
|
|
14
|
+
}
|
|
15
|
+
return paths;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.getResourcePaths = getResourcePaths;
|
|
20
|
+
exports.isSingleResourceInput = isSingleResourceInput;
|
|
21
|
+
exports.singleResourceInput = singleResourceInput;
|
|
22
|
+
//# sourceMappingURL=reusable-resource-input.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reusable-resource-input.cjs","names":[],"sources":["../../src/create-config/reusable-resource-input.ts"],"sourcesContent":["import type { LayoutResourcesAccessor } from './define-layout';\nimport type { ResourceDefinition } from '../resource';\n\nexport const singleResourceInput = Symbol('react-layout.single-resource-input');\n\n/** Describes one configured resource path supplied by the reusable's caller. */\nexport type SingleResourceInput<\n Resources extends readonly ResourceDefinition[],\n> = {\n readonly [singleResourceInput]: Resources;\n};\n\n/** Resource selector capabilities available to reusable definitions. */\nexport type ReusableResourcesAccessor<\n Resources extends readonly ResourceDefinition[],\n> = LayoutResourcesAccessor<Resources> & {\n single(): SingleResourceInput<Resources>;\n};\n\nexport function isSingleResourceInput(\n value: unknown,\n): value is SingleResourceInput<readonly ResourceDefinition[]> {\n return (\n value !== null && typeof value === 'object' && singleResourceInput in value\n );\n}\n\nexport function getResourcePaths(\n resources: readonly ResourceDefinition[],\n prefix = '',\n) {\n const paths: string[] = [];\n for (const resource of resources) {\n const key = typeof resource === 'string' ? resource : resource.value;\n const path = prefix ? `${prefix}.${key}` : key;\n paths.push(path);\n if (typeof resource !== 'string')\n paths.push(...getResourcePaths(resource.subResources, path));\n }\n return paths;\n}\n"],"mappings":";;AAGA,MAAa,sBAAsB,OAAO,oCAAoC;AAgB9E,SAAgB,sBACd,OAC6D;CAC7D,OACE,UAAU,QAAQ,OAAO,UAAU,YAAY,uBAAuB;AAE1E;AAEA,SAAgB,iBACd,WACA,SAAS,IACT;CACA,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,MAAM,OAAO,aAAa,WAAW,WAAW,SAAS;EAC/D,MAAM,OAAO,SAAS,GAAG,OAAO,GAAG,QAAQ;EAC3C,MAAM,KAAK,IAAI;EACf,IAAI,OAAO,aAAa,UACtB,MAAM,KAAK,GAAG,iBAAiB,SAAS,cAAc,IAAI,CAAC;CAC/D;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ResourceDefinition } from "../resource.cjs";
|
|
2
|
+
import { LayoutResourcesAccessor } from "./define-layout.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/create-config/reusable-resource-input.d.ts
|
|
5
|
+
declare const singleResourceInput: unique symbol;
|
|
6
|
+
/** Describes one configured resource path supplied by the reusable's caller. */
|
|
7
|
+
type SingleResourceInput<Resources extends readonly ResourceDefinition[]> = {
|
|
8
|
+
readonly [singleResourceInput]: Resources;
|
|
9
|
+
};
|
|
10
|
+
/** Resource selector capabilities available to reusable definitions. */
|
|
11
|
+
type ReusableResourcesAccessor<Resources extends readonly ResourceDefinition[]> = LayoutResourcesAccessor<Resources> & {
|
|
12
|
+
single(): SingleResourceInput<Resources>;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ReusableResourcesAccessor, SingleResourceInput };
|
|
16
|
+
//# sourceMappingURL=reusable-resource-input.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reusable-resource-input.d.cts","names":[],"sources":["../../src/create-config/reusable-resource-input.ts"],"mappings":";;;;cAGa,mBAAA;;KAGD,mBAAA,4BACiB,kBAAA;EAAA,UAEjB,mBAAA,GAAsB,SAAA;AAAA;;KAItB,yBAAA,4BACiB,kBAAA,MACzB,uBAAA,CAAwB,SAAA;EAC1B,MAAA,IAAU,mBAAA,CAAoB,SAAA;AAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ResourceDefinition } from "../resource.mjs";
|
|
2
|
+
import { LayoutResourcesAccessor } from "./define-layout.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/create-config/reusable-resource-input.d.ts
|
|
5
|
+
declare const singleResourceInput: unique symbol;
|
|
6
|
+
/** Describes one configured resource path supplied by the reusable's caller. */
|
|
7
|
+
type SingleResourceInput<Resources extends readonly ResourceDefinition[]> = {
|
|
8
|
+
readonly [singleResourceInput]: Resources;
|
|
9
|
+
};
|
|
10
|
+
/** Resource selector capabilities available to reusable definitions. */
|
|
11
|
+
type ReusableResourcesAccessor<Resources extends readonly ResourceDefinition[]> = LayoutResourcesAccessor<Resources> & {
|
|
12
|
+
single(): SingleResourceInput<Resources>;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ReusableResourcesAccessor, SingleResourceInput };
|
|
16
|
+
//# sourceMappingURL=reusable-resource-input.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reusable-resource-input.d.mts","names":[],"sources":["../../src/create-config/reusable-resource-input.ts"],"mappings":";;;;cAGa,mBAAA;;KAGD,mBAAA,4BACiB,kBAAA;EAAA,UAEjB,mBAAA,GAAsB,SAAA;AAAA;;KAItB,yBAAA,4BACiB,kBAAA,MACzB,uBAAA,CAAwB,SAAA;EAC1B,MAAA,IAAU,mBAAA,CAAoB,SAAA;AAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/create-config/reusable-resource-input.ts
|
|
2
|
+
const singleResourceInput = Symbol("react-layout.single-resource-input");
|
|
3
|
+
function isSingleResourceInput(value) {
|
|
4
|
+
return value !== null && typeof value === "object" && singleResourceInput in value;
|
|
5
|
+
}
|
|
6
|
+
function getResourcePaths(resources, prefix = "") {
|
|
7
|
+
const paths = [];
|
|
8
|
+
for (const resource of resources) {
|
|
9
|
+
const key = typeof resource === "string" ? resource : resource.value;
|
|
10
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
11
|
+
paths.push(path);
|
|
12
|
+
if (typeof resource !== "string") paths.push(...getResourcePaths(resource.subResources, path));
|
|
13
|
+
}
|
|
14
|
+
return paths;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getResourcePaths, isSingleResourceInput, singleResourceInput };
|
|
19
|
+
//# sourceMappingURL=reusable-resource-input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reusable-resource-input.mjs","names":[],"sources":["../../src/create-config/reusable-resource-input.ts"],"sourcesContent":["import type { LayoutResourcesAccessor } from './define-layout';\nimport type { ResourceDefinition } from '../resource';\n\nexport const singleResourceInput = Symbol('react-layout.single-resource-input');\n\n/** Describes one configured resource path supplied by the reusable's caller. */\nexport type SingleResourceInput<\n Resources extends readonly ResourceDefinition[],\n> = {\n readonly [singleResourceInput]: Resources;\n};\n\n/** Resource selector capabilities available to reusable definitions. */\nexport type ReusableResourcesAccessor<\n Resources extends readonly ResourceDefinition[],\n> = LayoutResourcesAccessor<Resources> & {\n single(): SingleResourceInput<Resources>;\n};\n\nexport function isSingleResourceInput(\n value: unknown,\n): value is SingleResourceInput<readonly ResourceDefinition[]> {\n return (\n value !== null && typeof value === 'object' && singleResourceInput in value\n );\n}\n\nexport function getResourcePaths(\n resources: readonly ResourceDefinition[],\n prefix = '',\n) {\n const paths: string[] = [];\n for (const resource of resources) {\n const key = typeof resource === 'string' ? resource : resource.value;\n const path = prefix ? `${prefix}.${key}` : key;\n paths.push(path);\n if (typeof resource !== 'string')\n paths.push(...getResourcePaths(resource.subResources, path));\n }\n return paths;\n}\n"],"mappings":";AAGA,MAAa,sBAAsB,OAAO,oCAAoC;AAgB9E,SAAgB,sBACd,OAC6D;CAC7D,OACE,UAAU,QAAQ,OAAO,UAAU,YAAY,uBAAuB;AAE1E;AAEA,SAAgB,iBACd,WACA,SAAS,IACT;CACA,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,MAAM,OAAO,aAAa,WAAW,WAAW,SAAS;EAC/D,MAAM,OAAO,SAAS,GAAG,OAAO,GAAG,QAAQ;EAC3C,MAAM,KAAK,IAAI;EACf,IAAI,OAAO,aAAa,UACtB,MAAM,KAAK,GAAG,iBAAiB,SAAS,cAAc,IAAI,CAAC;CAC/D;CACA,OAAO;AACT"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Show } from "../utils.cjs";
|
|
2
|
+
import { ResourceDefinition, ResourceEnum, ResourcePath } from "../resource.cjs";
|
|
2
3
|
import { InPropsDefinition, InPropsObject, InferredInProps, PropsContract } from "../props.cjs";
|
|
3
4
|
import { LayoutResourcesAccessor } from "./define-layout.cjs";
|
|
5
|
+
import { ReusableResourcesAccessor, SingleResourceInput } from "./reusable-resource-input.cjs";
|
|
4
6
|
import { AnyBuiltPropDefinition, ExtractDefinitionValue, ResolvedBuiltPropShape } from "@jfdevelops/react-layout-validator";
|
|
5
7
|
|
|
6
8
|
//#region src/create-config/reusable-types.d.ts
|
|
@@ -11,10 +13,16 @@ type ReusableOptionSelection<Props extends InPropsObject> = { [Key in keyof Prop
|
|
|
11
13
|
type: 'object';
|
|
12
14
|
properties: infer Shape extends InPropsObject;
|
|
13
15
|
} ? true | Selector<OptionValue<Props[Key]>> | ReusableOptionSelection<Shape> : true | Selector<OptionValue<Props[Key]>> };
|
|
16
|
+
type ResolvedResourceSelection<Resources extends readonly ResourceDefinition[], Result> = Result extends SingleResourceInput<readonly ResourceDefinition[]> ? ResourcePath<Resources> : Result;
|
|
17
|
+
type ResourceCallerInput<Resources extends readonly ResourceDefinition[], Contract> = Contract extends {
|
|
18
|
+
resources: (...args: any[]) => infer Result;
|
|
19
|
+
} ? Extract<Result, SingleResourceInput<readonly ResourceDefinition[]>> extends never ? {} : {
|
|
20
|
+
resources: ResourcePath<Resources>;
|
|
21
|
+
} : {};
|
|
14
22
|
type OptionDefinitions<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>> = InferredInProps<Resources, Options> extends infer Props extends InPropsObject ? Props : never;
|
|
15
23
|
/** Only data sources declared by the factory are available for selection. */
|
|
16
24
|
type ReusableInclude<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>> = {
|
|
17
|
-
resources?: true | Selector<
|
|
25
|
+
resources?: true | Selector<ReusableResourcesAccessor<Resources>>;
|
|
18
26
|
} & (keyof OptionDefinitions<Resources, Options> extends never ? {} : {
|
|
19
27
|
options?: true | Selector<ResolvedBuiltPropShape<OptionDefinitions<Resources, Options>>> | ReusableOptionSelection<OptionDefinitions<Resources, Options>>;
|
|
20
28
|
});
|
|
@@ -30,7 +38,7 @@ type ReusableProps<Resources extends readonly ResourceDefinition[], Options exte
|
|
|
30
38
|
} : Include extends {
|
|
31
39
|
resources: (...args: any[]) => infer Result;
|
|
32
40
|
} ? {
|
|
33
|
-
resources: Result
|
|
41
|
+
resources: ResolvedResourceSelection<Resources, Result>;
|
|
34
42
|
} : {}) & (Include extends {
|
|
35
43
|
options: infer Selection;
|
|
36
44
|
} ? Selection extends ((...args: any[]) => infer Result) ? {
|
|
@@ -40,7 +48,7 @@ type ReusableProps<Resources extends readonly ResourceDefinition[], Options exte
|
|
|
40
48
|
type ReusableSelected<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Selection> = (Selection extends {
|
|
41
49
|
resources: infer Value;
|
|
42
50
|
} ? {
|
|
43
|
-
resources: Value extends ((...args: any[]) => infer Result) ? Result : LayoutResourcesAccessor<Resources>;
|
|
51
|
+
resources: Value extends ((...args: any[]) => infer Result) ? ResolvedResourceSelection<Resources, Result> : LayoutResourcesAccessor<Resources>;
|
|
44
52
|
} : {}) & (Selection extends {
|
|
45
53
|
options: infer Value;
|
|
46
54
|
} ? Value extends ((...args: any[]) => infer Result) ? {
|
|
@@ -94,7 +102,7 @@ type SourceInput<Values> = keyof Values extends never ? {} : {} extends Values ?
|
|
|
94
102
|
} : {
|
|
95
103
|
options: Values;
|
|
96
104
|
};
|
|
97
|
-
type ReusableInput<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Include, Custom extends InPropsObject, Select> = Expanded<ReusableProps<Resources, Options, CallerContract<Resources, Options, Include, Select>, Custom> & SourceInput<OptionSource<OptionDefinitions<Resources, Options>, Include, true> & OptionSource<OptionDefinitions<Resources, Options>, Select, false>>>;
|
|
105
|
+
type ReusableInput<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Include, Custom extends InPropsObject, Select> = Expanded<ReusableProps<Resources, Options, CallerContract<Resources, Options, Include, Select>, Custom> & ResourceCallerInput<Resources, Include> & ResourceCallerInput<Resources, Select> & SourceInput<OptionSource<OptionDefinitions<Resources, Options>, Include, true> & OptionSource<OptionDefinitions<Resources, Options>, Select, false>>>;
|
|
98
106
|
type SelectionAt<Selection, Key extends PropertyKey> = Selection extends true ? true : Key extends keyof Selection ? Selection[Key] : undefined;
|
|
99
107
|
type CallerOptions<Props extends InPropsObject, Include, Select> = { [Key in keyof Props as SelectionAt<Include, Key> extends infer Value ? Value extends Selector<any> | undefined ? never : Value extends true ? SelectionAt<Select, Key> extends true ? never : Props[Key] extends {
|
|
100
108
|
properties: infer Shape extends InPropsObject;
|
|
@@ -125,7 +133,7 @@ type ReusableDefinition<Resources extends readonly ResourceDefinition[], Options
|
|
|
125
133
|
type ReusableArguments<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Include, Custom extends InPropsObject, Select> = {} extends ReusableInput<Resources, Options, Include, Custom, Select> ? [props?: ReusableInput<Resources, Options, Include, Custom, Select>] : [props: ReusableInput<Resources, Options, Include, Custom, Select>];
|
|
126
134
|
type ReusableFunction<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Include, Custom extends InPropsObject, Select, Result> = (...args: ReusableArguments<Resources, Options, Include, Custom, Select>) => Expanded<Result>;
|
|
127
135
|
/** Creates a validated function with one merged callback argument. */
|
|
128
|
-
type CreateReusable<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>> = <const Include extends ReusableInclude<Resources, Options> = {}, const Custom extends InPropsObject = {}, const Select extends ReusableInclude<Resources, Options> = {}, Result = unknown, const Overlap extends ReusableOverlap | undefined = undefined>(definition: ReusableDefinition<Resources, Options, Include, Custom, Select, Result, Overlap>) => ReusableFunction<Resources, Options, Include, Custom, Select, Result
|
|
136
|
+
type CreateReusable<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>> = <const Include extends ReusableInclude<Resources, Options> = {}, const Custom extends InPropsObject = {}, const Select extends ReusableInclude<Resources, Options> = {}, Result = unknown, const Overlap extends ReusableOverlap | undefined = undefined>(definition: ReusableDefinition<Resources, Options, Include, Custom, Select, Result, Overlap>) => Show<ReusableFunction<Resources, Options, Include, Custom, Select, Result>>;
|
|
129
137
|
//#endregion
|
|
130
138
|
export { CreateReusable, ReusableArguments, ReusableDefinition, ReusableFunction, ReusableInclude, ReusableInput, ReusableOptionSelection, ReusableOverlap, ReusableProps, ReusableResolved, ReusableSelected };
|
|
131
139
|
//# sourceMappingURL=reusable-types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusable-types.d.cts","names":[],"sources":["../../src/create-config/reusable-types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"reusable-types.d.cts","names":[],"sources":["../../src/create-config/reusable-types.ts"],"mappings":";;;;;;;;KA2BK,QAAA,YAAoB,MAAA,EAAQ,MAAM;AAAA,KAClC,WAAA,oBAA+B,sBAAA,IAChC,sBAAA,CAAuB,UAAA,KACtB,UAAA;;KAGO,uBAAA,eAAsC,aAAA,oBAClC,KAAA,IAAS,KAAA,CAAM,GAAA;EAC3B,IAAA;EACA,UAAA,sBAAgC,aAAA;AAAA,WAEvB,QAAA,CAAS,WAAA,CAAY,KAAA,CAAM,GAAA,MAAS,uBAAA,CAAwB,KAAA,WAC5D,QAAA,CAAS,WAAA,CAAY,KAAA,CAAM,GAAA;AAAA,KAGnC,yBAAA,4BACwB,kBAAA,cAEzB,MAAA,SAAe,mBAAA,UAA6B,kBAAA,MAC5C,YAAA,CAAa,SAAA,IACb,MAAA;AAAA,KAEC,mBAAA,4BACwB,kBAAA,gBAEzB,QAAA;EAAmB,SAAA,MAAe,IAAA;AAAA,IAClC,OAAA,CACE,MAAA,EACA,mBAAA,UAA6B,kBAAA;EAG3B,SAAA,EAAW,YAAA,CAAa,SAAA;AAAA;AAAA,KAG3B,iBAAA,4BACwB,kBAAA,oBACX,iBAAA,CAAkB,SAAA,KAChC,eAAA,CACF,SAAA,EACA,OAAA,8BAC4B,aAAA,GAC1B,KAAA;;KAIQ,eA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AA;AAAA,KAEnD,gBAAA,4BACiB,kBAAA,oBACX,iBAAA,CAAkB,SAAA,2BAEnB,aAAA,wBAIZ,IAAA,EAAM,iBAAA,CAAkB,SAAA,EAAW,OAAA,EAAS,OAAA,EAAS,MAAA,EAAQ,MAAA,MAC7D,QAAA,CAAS,MAAA;;KAGF,cAAA,4BACiB,kBAAA,oBACX,iBAAA,CAAkB,SAAA,4BAEZ,eAAA,CAAgB,SAAA,EAAW,OAAA,6BAC5B,aAAA,4BACA,eAAA,CAAgB,SAAA,EAAW,OAAA,gDAE1B,eAAA,0BAEtB,UAAA,EAAY,kBAAA,CACV,SAAA,EACA,OAAA,EACA,OAAA,EACA,MAAA,EACA,MAAA,EACA,MAAA,EACA,OAAA,MAEC,IAAA,CACH,gBAAA,CAAiB,SAAA,EAAW,OAAA,EAAS,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,MAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Show } from "../utils.mjs";
|
|
2
|
+
import { ResourceDefinition, ResourceEnum, ResourcePath } from "../resource.mjs";
|
|
2
3
|
import { InPropsDefinition, InPropsObject, InferredInProps, PropsContract } from "../props.mjs";
|
|
3
4
|
import { LayoutResourcesAccessor } from "./define-layout.mjs";
|
|
5
|
+
import { ReusableResourcesAccessor, SingleResourceInput } from "./reusable-resource-input.mjs";
|
|
4
6
|
import { AnyBuiltPropDefinition, ExtractDefinitionValue, ResolvedBuiltPropShape } from "@jfdevelops/react-layout-validator";
|
|
5
7
|
|
|
6
8
|
//#region src/create-config/reusable-types.d.ts
|
|
@@ -11,10 +13,16 @@ type ReusableOptionSelection<Props extends InPropsObject> = { [Key in keyof Prop
|
|
|
11
13
|
type: 'object';
|
|
12
14
|
properties: infer Shape extends InPropsObject;
|
|
13
15
|
} ? true | Selector<OptionValue<Props[Key]>> | ReusableOptionSelection<Shape> : true | Selector<OptionValue<Props[Key]>> };
|
|
16
|
+
type ResolvedResourceSelection<Resources extends readonly ResourceDefinition[], Result> = Result extends SingleResourceInput<readonly ResourceDefinition[]> ? ResourcePath<Resources> : Result;
|
|
17
|
+
type ResourceCallerInput<Resources extends readonly ResourceDefinition[], Contract> = Contract extends {
|
|
18
|
+
resources: (...args: any[]) => infer Result;
|
|
19
|
+
} ? Extract<Result, SingleResourceInput<readonly ResourceDefinition[]>> extends never ? {} : {
|
|
20
|
+
resources: ResourcePath<Resources>;
|
|
21
|
+
} : {};
|
|
14
22
|
type OptionDefinitions<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>> = InferredInProps<Resources, Options> extends infer Props extends InPropsObject ? Props : never;
|
|
15
23
|
/** Only data sources declared by the factory are available for selection. */
|
|
16
24
|
type ReusableInclude<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>> = {
|
|
17
|
-
resources?: true | Selector<
|
|
25
|
+
resources?: true | Selector<ReusableResourcesAccessor<Resources>>;
|
|
18
26
|
} & (keyof OptionDefinitions<Resources, Options> extends never ? {} : {
|
|
19
27
|
options?: true | Selector<ResolvedBuiltPropShape<OptionDefinitions<Resources, Options>>> | ReusableOptionSelection<OptionDefinitions<Resources, Options>>;
|
|
20
28
|
});
|
|
@@ -30,7 +38,7 @@ type ReusableProps<Resources extends readonly ResourceDefinition[], Options exte
|
|
|
30
38
|
} : Include extends {
|
|
31
39
|
resources: (...args: any[]) => infer Result;
|
|
32
40
|
} ? {
|
|
33
|
-
resources: Result
|
|
41
|
+
resources: ResolvedResourceSelection<Resources, Result>;
|
|
34
42
|
} : {}) & (Include extends {
|
|
35
43
|
options: infer Selection;
|
|
36
44
|
} ? Selection extends ((...args: any[]) => infer Result) ? {
|
|
@@ -40,7 +48,7 @@ type ReusableProps<Resources extends readonly ResourceDefinition[], Options exte
|
|
|
40
48
|
type ReusableSelected<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Selection> = (Selection extends {
|
|
41
49
|
resources: infer Value;
|
|
42
50
|
} ? {
|
|
43
|
-
resources: Value extends ((...args: any[]) => infer Result) ? Result : LayoutResourcesAccessor<Resources>;
|
|
51
|
+
resources: Value extends ((...args: any[]) => infer Result) ? ResolvedResourceSelection<Resources, Result> : LayoutResourcesAccessor<Resources>;
|
|
44
52
|
} : {}) & (Selection extends {
|
|
45
53
|
options: infer Value;
|
|
46
54
|
} ? Value extends ((...args: any[]) => infer Result) ? {
|
|
@@ -94,7 +102,7 @@ type SourceInput<Values> = keyof Values extends never ? {} : {} extends Values ?
|
|
|
94
102
|
} : {
|
|
95
103
|
options: Values;
|
|
96
104
|
};
|
|
97
|
-
type ReusableInput<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Include, Custom extends InPropsObject, Select> = Expanded<ReusableProps<Resources, Options, CallerContract<Resources, Options, Include, Select>, Custom> & SourceInput<OptionSource<OptionDefinitions<Resources, Options>, Include, true> & OptionSource<OptionDefinitions<Resources, Options>, Select, false>>>;
|
|
105
|
+
type ReusableInput<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Include, Custom extends InPropsObject, Select> = Expanded<ReusableProps<Resources, Options, CallerContract<Resources, Options, Include, Select>, Custom> & ResourceCallerInput<Resources, Include> & ResourceCallerInput<Resources, Select> & SourceInput<OptionSource<OptionDefinitions<Resources, Options>, Include, true> & OptionSource<OptionDefinitions<Resources, Options>, Select, false>>>;
|
|
98
106
|
type SelectionAt<Selection, Key extends PropertyKey> = Selection extends true ? true : Key extends keyof Selection ? Selection[Key] : undefined;
|
|
99
107
|
type CallerOptions<Props extends InPropsObject, Include, Select> = { [Key in keyof Props as SelectionAt<Include, Key> extends infer Value ? Value extends Selector<any> | undefined ? never : Value extends true ? SelectionAt<Select, Key> extends true ? never : Props[Key] extends {
|
|
100
108
|
properties: infer Shape extends InPropsObject;
|
|
@@ -125,7 +133,7 @@ type ReusableDefinition<Resources extends readonly ResourceDefinition[], Options
|
|
|
125
133
|
type ReusableArguments<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Include, Custom extends InPropsObject, Select> = {} extends ReusableInput<Resources, Options, Include, Custom, Select> ? [props?: ReusableInput<Resources, Options, Include, Custom, Select>] : [props: ReusableInput<Resources, Options, Include, Custom, Select>];
|
|
126
134
|
type ReusableFunction<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>, Include, Custom extends InPropsObject, Select, Result> = (...args: ReusableArguments<Resources, Options, Include, Custom, Select>) => Expanded<Result>;
|
|
127
135
|
/** Creates a validated function with one merged callback argument. */
|
|
128
|
-
type CreateReusable<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>> = <const Include extends ReusableInclude<Resources, Options> = {}, const Custom extends InPropsObject = {}, const Select extends ReusableInclude<Resources, Options> = {}, Result = unknown, const Overlap extends ReusableOverlap | undefined = undefined>(definition: ReusableDefinition<Resources, Options, Include, Custom, Select, Result, Overlap>) => ReusableFunction<Resources, Options, Include, Custom, Select, Result
|
|
136
|
+
type CreateReusable<Resources extends readonly ResourceDefinition[], Options extends InPropsDefinition<Resources>> = <const Include extends ReusableInclude<Resources, Options> = {}, const Custom extends InPropsObject = {}, const Select extends ReusableInclude<Resources, Options> = {}, Result = unknown, const Overlap extends ReusableOverlap | undefined = undefined>(definition: ReusableDefinition<Resources, Options, Include, Custom, Select, Result, Overlap>) => Show<ReusableFunction<Resources, Options, Include, Custom, Select, Result>>;
|
|
129
137
|
//#endregion
|
|
130
138
|
export { CreateReusable, ReusableArguments, ReusableDefinition, ReusableFunction, ReusableInclude, ReusableInput, ReusableOptionSelection, ReusableOverlap, ReusableProps, ReusableResolved, ReusableSelected };
|
|
131
139
|
//# sourceMappingURL=reusable-types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusable-types.d.mts","names":[],"sources":["../../src/create-config/reusable-types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"reusable-types.d.mts","names":[],"sources":["../../src/create-config/reusable-types.ts"],"mappings":";;;;;;;;KA2BK,QAAA,Y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CAAiB,SAAA,EAAW,OAAA,EAAS,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,MAAA"}
|
package/dist/index.d.cts
CHANGED
|
@@ -17,6 +17,7 @@ import { ComponentTypes, CreateResourceConfigFn, CreateResourceConfigForResource
|
|
|
17
17
|
import { CreateResourceMap, CreateResourceMapFn } from "./create-config/create-resource-links.cjs";
|
|
18
18
|
import { ScopedComponentRenderFn } from "./lazy/scoped-content.cjs";
|
|
19
19
|
import { ContextualInlineRenderState, ContextualInlineRenderStates, CreateResourceLayoutWithLayoutOptions, CreateViewMapBuiltInRenderStatesOptions, CreateViewMapFunctionRenderOptions, CreateViewMapInlineRenderStatesOptions, CreateViewMapRenderStatesOptions, DefineResourceLayoutWithLayoutFn, DefineResourcesFn, DefinedResourceLayoutWithShell, LayoutRenderResourcesAccessor, LayoutResourcesAccessor, ResourceLayoutProvider, ResourceLayoutProviderProps, ResourceLayoutShellComponent, ResourceLayoutShellProps, ResourceSelection, ShellLayoutDefinition, ShellRenderContext, TypedBuiltInRenderStates, TypedInlineRenderState, defineResourceLayout } from "./create-config/define-layout.cjs";
|
|
20
|
+
import { ReusableResourcesAccessor, SingleResourceInput } from "./create-config/reusable-resource-input.cjs";
|
|
20
21
|
import { CreateReusable, ReusableArguments, ReusableDefinition, ReusableFunction, ReusableInclude, ReusableInput, ReusableOptionSelection, ReusableOverlap, ReusableProps, ReusableResolved, ReusableSelected } from "./create-config/reusable-types.cjs";
|
|
21
22
|
import { CreateLazyRenderState, LazyDefaultState } from "./lazy/create-render-state.cjs";
|
|
22
23
|
import { LazyResourceLayoutComponent, LazyResourceLayoutOptions } from "./create-config/lazy-resource-layout.cjs";
|
|
@@ -35,4 +36,4 @@ import { MissingPathVariableContext, MissingPathVariableError } from "./errors/m
|
|
|
35
36
|
import { MissingResourceProviderError } from "./errors/missing-resource-provider.cjs";
|
|
36
37
|
import { AnyComposableComponent, ComposableComponent, ComposableComponentCallable, ComposableComponents, ComposableNameContext, ComposablePresetComponent, ComposablePresetComponentCallProps, ComposablePresetMeta, ComposablePresetProps, ComposableResourceLayout, CreateLayoutComposable, DefinedComposableComponentRecord, LayoutComposablePresetProvider, LayoutComposablesFactory, MakeComposable, MakeComposableOptions, MergePresetProps, PresetPropsFromComposable, RequiredPresetLayoutProps, RequiredPresetRenderProps, ResolveLayoutComposables, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "@jfdevelops/react-layout-composables";
|
|
37
38
|
import { AnyBuiltPropDefinition, ExtractDefinitionValue, PropError, PropErrorOptions, ResolveLayoutProps, ResolveLayoutPropsAsDefined, ResolveProps, ResolvedBuiltPropShape, createPrimitivePropBuilder, createProp, isPropDefinitionShape, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
38
|
-
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type AnyRenderStateDefinition, type AsStateComposable, type BaseComponent, type BoundDefineResourceLayout, type BuiltinRenderStateName, type ChildrenRequirement, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type ContextualInlineRenderState, type ContextualInlineRenderStates, type CreateDefinedResourceLayoutOptions, type CreateDefinedResourceLayoutResult, type CreateGetComponentForPath, type CreateLayoutBuildingBlocks, type CreateLayoutBuildingBlocksArguments, type CreateLayoutBuildingBlocksResult, type CreateLayoutComposable, type CreateLazyErrorComponent, type CreateLazyRenderState, type CreateRenderState, type CreateRenderStateBuilderArguments, type CreateRenderStateBuilderResult, type CreateRenderStateFromState, type CreateResourceConfigFn, type CreateResourceConfigForResource, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreateReusable, type CreateViewMapBuiltInRenderStatesOptions, type CreateViewMapFunctionRenderOptions, type CreateViewMapInlineRenderStatesOptions, type CreateViewMapRenderStatesOptions, type CreatedResourceConfig, type CustomPropsObject, type DeferredRenderState, type DefineLayoutComposables, type DefineLazyDefaults, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutInput, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedComponentPropDefinitions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPartContext, InvalidPartError, type InvalidPartTypeContext, InvalidPartTypeError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesDefinition, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutNameCallback, type LayoutNameContext, type LayoutNameFactory, type LayoutNameInput, type LayoutNameOptions, type LayoutNamePartDefinitions, type LayoutNamePartType, type LayoutNamePartValues, type LayoutNameParts, type LayoutNameResolver, type LayoutPreviewProps, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type LazyDefaultState, type LazyErrorHandlers, type LazyHandle, type LazyOptions, type LazyRenderState, type LazyResourceError, type LazyResourceErrorComponent, type LazyResourceErrorMap, type LazyResourceErrorProps, type LazyResourceLayoutComponent, type LazyResourceLayoutOptions, type LazyResourceLoadingComponent, LazyResourceModuleShapeError, LazyResourceStateNotFoundError, type LazyResourceStates, type LoadStatus, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NonEmptyResources, type NormalizeResource, type NormalizeResources, type NormalizedResourceDefinition, type NormalizedResourceDefinitions, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsContract, type PropsRenderDefinition, ReactLayoutError, type RenderStateCallProps, type RenderStateCallback, type RenderStateComposablesDefinition, type RenderStateContext, type RenderStateFragment, type RenderStateName, type RenderStateOverloads, type RenderStateProps, type RenderStateReferences, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedLayoutName, type ResolvedPathValue, type ResourceConfigFragment, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, ResourceModuleLoadError, type ResourcePath, ResourceRenderError, type ResourceSelection, type ResourceStateError, type ResourceTree, type ReusableArguments, type ReusableDefinition, type ReusableFunction, type ReusableInclude, type ReusableInput, type ReusableOptionSelection, type ReusableOverlap, type ReusableProps, type ReusableResolved, type ReusableSelected, type ScopedComponentRenderFn, type ShellLayoutDefinition, type ShellRenderContext, type Show, type StateComposable, type StateComposableOptions, type TargetPathBuilder, type TypedBuiltInRenderStates, type TypedInlineRenderState, type TypedRenderStateCallback, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineLayoutName, defineLayoutPreview, defineResourceLayout, isLazyResourceError, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
|
39
|
+
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type AnyRenderStateDefinition, type AsStateComposable, type BaseComponent, type BoundDefineResourceLayout, type BuiltinRenderStateName, type ChildrenRequirement, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type ContextualInlineRenderState, type ContextualInlineRenderStates, type CreateDefinedResourceLayoutOptions, type CreateDefinedResourceLayoutResult, type CreateGetComponentForPath, type CreateLayoutBuildingBlocks, type CreateLayoutBuildingBlocksArguments, type CreateLayoutBuildingBlocksResult, type CreateLayoutComposable, type CreateLazyErrorComponent, type CreateLazyRenderState, type CreateRenderState, type CreateRenderStateBuilderArguments, type CreateRenderStateBuilderResult, type CreateRenderStateFromState, type CreateResourceConfigFn, type CreateResourceConfigForResource, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreateReusable, type CreateViewMapBuiltInRenderStatesOptions, type CreateViewMapFunctionRenderOptions, type CreateViewMapInlineRenderStatesOptions, type CreateViewMapRenderStatesOptions, type CreatedResourceConfig, type CustomPropsObject, type DeferredRenderState, type DefineLayoutComposables, type DefineLazyDefaults, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutInput, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedComponentPropDefinitions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPartContext, InvalidPartError, type InvalidPartTypeContext, InvalidPartTypeError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesDefinition, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutNameCallback, type LayoutNameContext, type LayoutNameFactory, type LayoutNameInput, type LayoutNameOptions, type LayoutNamePartDefinitions, type LayoutNamePartType, type LayoutNamePartValues, type LayoutNameParts, type LayoutNameResolver, type LayoutPreviewProps, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type LazyDefaultState, type LazyErrorHandlers, type LazyHandle, type LazyOptions, type LazyRenderState, type LazyResourceError, type LazyResourceErrorComponent, type LazyResourceErrorMap, type LazyResourceErrorProps, type LazyResourceLayoutComponent, type LazyResourceLayoutOptions, type LazyResourceLoadingComponent, LazyResourceModuleShapeError, LazyResourceStateNotFoundError, type LazyResourceStates, type LoadStatus, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NonEmptyResources, type NormalizeResource, type NormalizeResources, type NormalizedResourceDefinition, type NormalizedResourceDefinitions, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsContract, type PropsRenderDefinition, ReactLayoutError, type RenderStateCallProps, type RenderStateCallback, type RenderStateComposablesDefinition, type RenderStateContext, type RenderStateFragment, type RenderStateName, type RenderStateOverloads, type RenderStateProps, type RenderStateReferences, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedLayoutName, type ResolvedPathValue, type ResourceConfigFragment, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, ResourceModuleLoadError, type ResourcePath, ResourceRenderError, type ResourceSelection, type ResourceStateError, type ResourceTree, type ReusableArguments, type ReusableDefinition, type ReusableFunction, type ReusableInclude, type ReusableInput, type ReusableOptionSelection, type ReusableOverlap, type ReusableProps, type ReusableResolved, type ReusableResourcesAccessor, type ReusableSelected, type ScopedComponentRenderFn, type ShellLayoutDefinition, type ShellRenderContext, type Show, type SingleResourceInput, type StateComposable, type StateComposableOptions, type TargetPathBuilder, type TypedBuiltInRenderStates, type TypedInlineRenderState, type TypedRenderStateCallback, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineLayoutName, defineLayoutPreview, defineResourceLayout, isLazyResourceError, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
package/dist/index.d.mts
CHANGED
|
@@ -17,6 +17,7 @@ import { ComponentTypes, CreateResourceConfigFn, CreateResourceConfigForResource
|
|
|
17
17
|
import { CreateResourceMap, CreateResourceMapFn } from "./create-config/create-resource-links.mjs";
|
|
18
18
|
import { ScopedComponentRenderFn } from "./lazy/scoped-content.mjs";
|
|
19
19
|
import { ContextualInlineRenderState, ContextualInlineRenderStates, CreateResourceLayoutWithLayoutOptions, CreateViewMapBuiltInRenderStatesOptions, CreateViewMapFunctionRenderOptions, CreateViewMapInlineRenderStatesOptions, CreateViewMapRenderStatesOptions, DefineResourceLayoutWithLayoutFn, DefineResourcesFn, DefinedResourceLayoutWithShell, LayoutRenderResourcesAccessor, LayoutResourcesAccessor, ResourceLayoutProvider, ResourceLayoutProviderProps, ResourceLayoutShellComponent, ResourceLayoutShellProps, ResourceSelection, ShellLayoutDefinition, ShellRenderContext, TypedBuiltInRenderStates, TypedInlineRenderState, defineResourceLayout } from "./create-config/define-layout.mjs";
|
|
20
|
+
import { ReusableResourcesAccessor, SingleResourceInput } from "./create-config/reusable-resource-input.mjs";
|
|
20
21
|
import { CreateReusable, ReusableArguments, ReusableDefinition, ReusableFunction, ReusableInclude, ReusableInput, ReusableOptionSelection, ReusableOverlap, ReusableProps, ReusableResolved, ReusableSelected } from "./create-config/reusable-types.mjs";
|
|
21
22
|
import { CreateLazyRenderState, LazyDefaultState } from "./lazy/create-render-state.mjs";
|
|
22
23
|
import { LazyResourceLayoutComponent, LazyResourceLayoutOptions } from "./create-config/lazy-resource-layout.mjs";
|
|
@@ -35,4 +36,4 @@ import { MissingPathVariableContext, MissingPathVariableError } from "./errors/m
|
|
|
35
36
|
import { MissingResourceProviderError } from "./errors/missing-resource-provider.mjs";
|
|
36
37
|
import { AnyComposableComponent, ComposableComponent, ComposableComponentCallable, ComposableComponents, ComposableNameContext, ComposablePresetComponent, ComposablePresetComponentCallProps, ComposablePresetMeta, ComposablePresetProps, ComposableResourceLayout, CreateLayoutComposable, DefinedComposableComponentRecord, LayoutComposablePresetProvider, LayoutComposablesFactory, MakeComposable, MakeComposableOptions, MergePresetProps, PresetPropsFromComposable, RequiredPresetLayoutProps, RequiredPresetRenderProps, ResolveLayoutComposables, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "@jfdevelops/react-layout-composables";
|
|
37
38
|
import { AnyBuiltPropDefinition, ExtractDefinitionValue, PropError, PropErrorOptions, ResolveLayoutProps, ResolveLayoutPropsAsDefined, ResolveProps, ResolvedBuiltPropShape, createPrimitivePropBuilder, createProp, isPropDefinitionShape, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
|
|
38
|
-
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type AnyRenderStateDefinition, type AsStateComposable, type BaseComponent, type BoundDefineResourceLayout, type BuiltinRenderStateName, type ChildrenRequirement, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type ContextualInlineRenderState, type ContextualInlineRenderStates, type CreateDefinedResourceLayoutOptions, type CreateDefinedResourceLayoutResult, type CreateGetComponentForPath, type CreateLayoutBuildingBlocks, type CreateLayoutBuildingBlocksArguments, type CreateLayoutBuildingBlocksResult, type CreateLayoutComposable, type CreateLazyErrorComponent, type CreateLazyRenderState, type CreateRenderState, type CreateRenderStateBuilderArguments, type CreateRenderStateBuilderResult, type CreateRenderStateFromState, type CreateResourceConfigFn, type CreateResourceConfigForResource, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreateReusable, type CreateViewMapBuiltInRenderStatesOptions, type CreateViewMapFunctionRenderOptions, type CreateViewMapInlineRenderStatesOptions, type CreateViewMapRenderStatesOptions, type CreatedResourceConfig, type CustomPropsObject, type DeferredRenderState, type DefineLayoutComposables, type DefineLazyDefaults, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutInput, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedComponentPropDefinitions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPartContext, InvalidPartError, type InvalidPartTypeContext, InvalidPartTypeError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesDefinition, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutNameCallback, type LayoutNameContext, type LayoutNameFactory, type LayoutNameInput, type LayoutNameOptions, type LayoutNamePartDefinitions, type LayoutNamePartType, type LayoutNamePartValues, type LayoutNameParts, type LayoutNameResolver, type LayoutPreviewProps, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type LazyDefaultState, type LazyErrorHandlers, type LazyHandle, type LazyOptions, type LazyRenderState, type LazyResourceError, type LazyResourceErrorComponent, type LazyResourceErrorMap, type LazyResourceErrorProps, type LazyResourceLayoutComponent, type LazyResourceLayoutOptions, type LazyResourceLoadingComponent, LazyResourceModuleShapeError, LazyResourceStateNotFoundError, type LazyResourceStates, type LoadStatus, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NonEmptyResources, type NormalizeResource, type NormalizeResources, type NormalizedResourceDefinition, type NormalizedResourceDefinitions, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsContract, type PropsRenderDefinition, ReactLayoutError, type RenderStateCallProps, type RenderStateCallback, type RenderStateComposablesDefinition, type RenderStateContext, type RenderStateFragment, type RenderStateName, type RenderStateOverloads, type RenderStateProps, type RenderStateReferences, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedLayoutName, type ResolvedPathValue, type ResourceConfigFragment, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, ResourceModuleLoadError, type ResourcePath, ResourceRenderError, type ResourceSelection, type ResourceStateError, type ResourceTree, type ReusableArguments, type ReusableDefinition, type ReusableFunction, type ReusableInclude, type ReusableInput, type ReusableOptionSelection, type ReusableOverlap, type ReusableProps, type ReusableResolved, type ReusableSelected, type ScopedComponentRenderFn, type ShellLayoutDefinition, type ShellRenderContext, type Show, type StateComposable, type StateComposableOptions, type TargetPathBuilder, type TypedBuiltInRenderStates, type TypedInlineRenderState, type TypedRenderStateCallback, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineLayoutName, defineLayoutPreview, defineResourceLayout, isLazyResourceError, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|
|
39
|
+
export { type AnyBuiltPropDefinition, type AnyComposableComponent, type AnyRenderStateDefinition, type AsStateComposable, type BaseComponent, type BoundDefineResourceLayout, type BuiltinRenderStateName, type ChildrenRequirement, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type ContextualInlineRenderState, type ContextualInlineRenderStates, type CreateDefinedResourceLayoutOptions, type CreateDefinedResourceLayoutResult, type CreateGetComponentForPath, type CreateLayoutBuildingBlocks, type CreateLayoutBuildingBlocksArguments, type CreateLayoutBuildingBlocksResult, type CreateLayoutComposable, type CreateLazyErrorComponent, type CreateLazyRenderState, type CreateRenderState, type CreateRenderStateBuilderArguments, type CreateRenderStateBuilderResult, type CreateRenderStateFromState, type CreateResourceConfigFn, type CreateResourceConfigForResource, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreateReusable, type CreateViewMapBuiltInRenderStatesOptions, type CreateViewMapFunctionRenderOptions, type CreateViewMapInlineRenderStatesOptions, type CreateViewMapRenderStatesOptions, type CreatedResourceConfig, type CustomPropsObject, type DeferredRenderState, type DefineLayoutComposables, type DefineLazyDefaults, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutInput, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedComponentPropDefinitions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPartContext, InvalidPartError, type InvalidPartTypeContext, InvalidPartTypeError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesDefinition, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutNameCallback, type LayoutNameContext, type LayoutNameFactory, type LayoutNameInput, type LayoutNameOptions, type LayoutNamePartDefinitions, type LayoutNamePartType, type LayoutNamePartValues, type LayoutNameParts, type LayoutNameResolver, type LayoutPreviewProps, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type LazyDefaultState, type LazyErrorHandlers, type LazyHandle, type LazyOptions, type LazyRenderState, type LazyResourceError, type LazyResourceErrorComponent, type LazyResourceErrorMap, type LazyResourceErrorProps, type LazyResourceLayoutComponent, type LazyResourceLayoutOptions, type LazyResourceLoadingComponent, LazyResourceModuleShapeError, LazyResourceStateNotFoundError, type LazyResourceStates, type LoadStatus, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NonEmptyResources, type NormalizeResource, type NormalizeResources, type NormalizedResourceDefinition, type NormalizedResourceDefinitions, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsContract, type PropsRenderDefinition, ReactLayoutError, type RenderStateCallProps, type RenderStateCallback, type RenderStateComposablesDefinition, type RenderStateContext, type RenderStateFragment, type RenderStateName, type RenderStateOverloads, type RenderStateProps, type RenderStateReferences, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedLayoutName, type ResolvedPathValue, type ResourceConfigFragment, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, ResourceModuleLoadError, type ResourcePath, ResourceRenderError, type ResourceSelection, type ResourceStateError, type ResourceTree, type ReusableArguments, type ReusableDefinition, type ReusableFunction, type ReusableInclude, type ReusableInput, type ReusableOptionSelection, type ReusableOverlap, type ReusableProps, type ReusableResolved, type ReusableResourcesAccessor, type ReusableSelected, type ScopedComponentRenderFn, type ShellLayoutDefinition, type ShellRenderContext, type Show, type SingleResourceInput, type StateComposable, type StateComposableOptions, type TargetPathBuilder, type TypedBuiltInRenderStates, type TypedInlineRenderState, type TypedRenderStateCallback, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createDefinedResourceLayout, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineLayoutName, defineLayoutPreview, defineResourceLayout, isLazyResourceError, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResourceDefinitions, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
|