@xmachines/json-render-core 0.21.0-xm.1 → 0.21.0-xm.2
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/index.d.mts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -934,6 +934,49 @@ interface UserPromptOptions {
|
|
|
934
934
|
*/
|
|
935
935
|
declare function buildUserPrompt(options: UserPromptOptions): string;
|
|
936
936
|
|
|
937
|
+
/**
|
|
938
|
+
* Slot metadata for named-slot validation.
|
|
939
|
+
*
|
|
940
|
+
* A renderer package records the slot names that each catalog component
|
|
941
|
+
* declares when it builds a registry from a catalog. When it renders an
|
|
942
|
+
* element with `slots`, it calls {@link warnElementSlots}, which warns about
|
|
943
|
+
* `slots.default` (spelled `children`) and about a slot name that the
|
|
944
|
+
* component does not declare.
|
|
945
|
+
*
|
|
946
|
+
* The metadata is keyed on the registry OBJECT, so a registry that a renderer
|
|
947
|
+
* clones must carry it over with {@link copySlotMetadata}. A hand-built
|
|
948
|
+
* registry carries no metadata, and its slot names are not validated.
|
|
949
|
+
*
|
|
950
|
+
* @packageDocumentation
|
|
951
|
+
*/
|
|
952
|
+
/** Slot names declared by one catalog component. */
|
|
953
|
+
interface ComponentSlotMetadata {
|
|
954
|
+
slots?: string[];
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Attach the slot declarations of a catalog to the registry that renders it.
|
|
958
|
+
* A catalog without component data attaches nothing.
|
|
959
|
+
*/
|
|
960
|
+
declare function setCatalogSlotMetadata(registry: object, catalog: unknown): void;
|
|
961
|
+
/**
|
|
962
|
+
* Carry the slot metadata of one registry over to a clone of it. A bare
|
|
963
|
+
* spread loses the metadata and silences named-slot validation.
|
|
964
|
+
*/
|
|
965
|
+
declare function copySlotMetadata(from: object, to: object): void;
|
|
966
|
+
/**
|
|
967
|
+
* Slot declarations for one component type, or `undefined` when the registry
|
|
968
|
+
* carries no catalog metadata or the type is not in the catalog.
|
|
969
|
+
*/
|
|
970
|
+
declare function getComponentSlotMetadata(registry: object, type: string): ComponentSlotMetadata | undefined;
|
|
971
|
+
/**
|
|
972
|
+
* Warn about the named slots of an element of component `type`: about
|
|
973
|
+
* `slots.default`, which is spelled `children`, and about each slot name that
|
|
974
|
+
* the catalog does not declare for the component. The renderer still renders
|
|
975
|
+
* an undeclared slot. Nothing is validated for a registry without catalog
|
|
976
|
+
* metadata, or for a component that declares no slots.
|
|
977
|
+
*/
|
|
978
|
+
declare function warnElementSlots(registry: object, type: string, slots: Record<string, string[]> | undefined): void;
|
|
979
|
+
|
|
937
980
|
/**
|
|
938
981
|
* Deep-merge `patch` into `base`, returning a new object.
|
|
939
982
|
*
|
|
@@ -1087,4 +1130,4 @@ interface Experimental_EvaluatorOptions {
|
|
|
1087
1130
|
*/
|
|
1088
1131
|
declare function experimental_createEvaluator(options: Experimental_EvaluatorOptions): Experimental_CompositionEvaluator;
|
|
1089
1132
|
|
|
1090
|
-
export { type ActionDispatchInfo, type ActionObserver, type ActionSettleInfo, AndCondition, type BuildEditUserPromptOptions, type BuiltInAction, type Catalog, type ComputedFunction, type DirectiveDefinition, type DirectiveRegistry, DynamicValue, type EditConfig, type EditMode, type Experimental_ChoiceQuestion, type Experimental_ComposeSpecOptions, type Experimental_CompositionCandidate, type Experimental_CompositionCatalog, type Experimental_CompositionEvaluation, type Experimental_CompositionEvaluator, type Experimental_CompositionEvent, type Experimental_CompositionStep, type Experimental_EvaluatorOptions, type InferActionParams, type InferCatalogActions, type InferCatalogComponents, type InferCatalogInput, type InferComponentProps, type InferSpec, JsonPatch, type JsonSchemaOptions, OrCondition, type PromptContext, type PromptOptions, type PromptTemplate, type PropExpression, type PropResolutionContext, type RenderErrorHandler, type Schema, type SchemaBuilder, type SchemaDefinition, type SchemaOptions, type SchemaType, Spec, type SpecIssue, type SpecIssueSeverity, type SpecValidationIssues, type SpecValidationResult, StateCondition, StateModel, UIElement, type UserPromptOptions, type ValidateSpecOptions, type ValidationCheck, type ValidationCheckResult, ValidationCheckSchema, type ValidationConfig, ValidationConfigSchema, type ValidationContext, type ValidationFunction, type ValidationFunctionDefinition, type ValidationResult, VisibilityCondition, VisibilityConditionSchema, VisibilityConditionStrictSchema, type VisibilityContext, autoFixSpec, buildEditInstructions, buildEditUserPrompt, buildUserPrompt, builtInValidationFunctions, check, conditionUsesItemScope, createDirectiveRegistry, deepMergeSpec, defineCatalog, defineDirective, defineSchema, diffToPatches, evaluateVisibility, experimental_composeSpec, experimental_createEvaluator, findDirective, formatSpecIssues, isDevtoolsActive, isNonEmptySpec, markDevtoolsActive, nextActionDispatchId, notifyActionDispatch, notifyActionSettle, registerActionObserver, resolveActionParam, resolveBindings, resolveElementProps, resolvePropValue, runValidation, runValidationCheck, splitRepeatVisibility, subscribeDevtoolsActive, validateSpec, visibility };
|
|
1133
|
+
export { type ActionDispatchInfo, type ActionObserver, type ActionSettleInfo, AndCondition, type BuildEditUserPromptOptions, type BuiltInAction, type Catalog, type ComponentSlotMetadata, type ComputedFunction, type DirectiveDefinition, type DirectiveRegistry, DynamicValue, type EditConfig, type EditMode, type Experimental_ChoiceQuestion, type Experimental_ComposeSpecOptions, type Experimental_CompositionCandidate, type Experimental_CompositionCatalog, type Experimental_CompositionEvaluation, type Experimental_CompositionEvaluator, type Experimental_CompositionEvent, type Experimental_CompositionStep, type Experimental_EvaluatorOptions, type InferActionParams, type InferCatalogActions, type InferCatalogComponents, type InferCatalogInput, type InferComponentProps, type InferSpec, JsonPatch, type JsonSchemaOptions, OrCondition, type PromptContext, type PromptOptions, type PromptTemplate, type PropExpression, type PropResolutionContext, type RenderErrorHandler, type Schema, type SchemaBuilder, type SchemaDefinition, type SchemaOptions, type SchemaType, Spec, type SpecIssue, type SpecIssueSeverity, type SpecValidationIssues, type SpecValidationResult, StateCondition, StateModel, UIElement, type UserPromptOptions, type ValidateSpecOptions, type ValidationCheck, type ValidationCheckResult, ValidationCheckSchema, type ValidationConfig, ValidationConfigSchema, type ValidationContext, type ValidationFunction, type ValidationFunctionDefinition, type ValidationResult, VisibilityCondition, VisibilityConditionSchema, VisibilityConditionStrictSchema, type VisibilityContext, autoFixSpec, buildEditInstructions, buildEditUserPrompt, buildUserPrompt, builtInValidationFunctions, check, conditionUsesItemScope, copySlotMetadata, createDirectiveRegistry, deepMergeSpec, defineCatalog, defineDirective, defineSchema, diffToPatches, evaluateVisibility, experimental_composeSpec, experimental_createEvaluator, findDirective, formatSpecIssues, getComponentSlotMetadata, isDevtoolsActive, isNonEmptySpec, markDevtoolsActive, nextActionDispatchId, notifyActionDispatch, notifyActionSettle, registerActionObserver, resolveActionParam, resolveBindings, resolveElementProps, resolvePropValue, runValidation, runValidationCheck, setCatalogSlotMetadata, splitRepeatVisibility, subscribeDevtoolsActive, validateSpec, visibility, warnElementSlots };
|
package/dist/index.d.ts
CHANGED
|
@@ -934,6 +934,49 @@ interface UserPromptOptions {
|
|
|
934
934
|
*/
|
|
935
935
|
declare function buildUserPrompt(options: UserPromptOptions): string;
|
|
936
936
|
|
|
937
|
+
/**
|
|
938
|
+
* Slot metadata for named-slot validation.
|
|
939
|
+
*
|
|
940
|
+
* A renderer package records the slot names that each catalog component
|
|
941
|
+
* declares when it builds a registry from a catalog. When it renders an
|
|
942
|
+
* element with `slots`, it calls {@link warnElementSlots}, which warns about
|
|
943
|
+
* `slots.default` (spelled `children`) and about a slot name that the
|
|
944
|
+
* component does not declare.
|
|
945
|
+
*
|
|
946
|
+
* The metadata is keyed on the registry OBJECT, so a registry that a renderer
|
|
947
|
+
* clones must carry it over with {@link copySlotMetadata}. A hand-built
|
|
948
|
+
* registry carries no metadata, and its slot names are not validated.
|
|
949
|
+
*
|
|
950
|
+
* @packageDocumentation
|
|
951
|
+
*/
|
|
952
|
+
/** Slot names declared by one catalog component. */
|
|
953
|
+
interface ComponentSlotMetadata {
|
|
954
|
+
slots?: string[];
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Attach the slot declarations of a catalog to the registry that renders it.
|
|
958
|
+
* A catalog without component data attaches nothing.
|
|
959
|
+
*/
|
|
960
|
+
declare function setCatalogSlotMetadata(registry: object, catalog: unknown): void;
|
|
961
|
+
/**
|
|
962
|
+
* Carry the slot metadata of one registry over to a clone of it. A bare
|
|
963
|
+
* spread loses the metadata and silences named-slot validation.
|
|
964
|
+
*/
|
|
965
|
+
declare function copySlotMetadata(from: object, to: object): void;
|
|
966
|
+
/**
|
|
967
|
+
* Slot declarations for one component type, or `undefined` when the registry
|
|
968
|
+
* carries no catalog metadata or the type is not in the catalog.
|
|
969
|
+
*/
|
|
970
|
+
declare function getComponentSlotMetadata(registry: object, type: string): ComponentSlotMetadata | undefined;
|
|
971
|
+
/**
|
|
972
|
+
* Warn about the named slots of an element of component `type`: about
|
|
973
|
+
* `slots.default`, which is spelled `children`, and about each slot name that
|
|
974
|
+
* the catalog does not declare for the component. The renderer still renders
|
|
975
|
+
* an undeclared slot. Nothing is validated for a registry without catalog
|
|
976
|
+
* metadata, or for a component that declares no slots.
|
|
977
|
+
*/
|
|
978
|
+
declare function warnElementSlots(registry: object, type: string, slots: Record<string, string[]> | undefined): void;
|
|
979
|
+
|
|
937
980
|
/**
|
|
938
981
|
* Deep-merge `patch` into `base`, returning a new object.
|
|
939
982
|
*
|
|
@@ -1087,4 +1130,4 @@ interface Experimental_EvaluatorOptions {
|
|
|
1087
1130
|
*/
|
|
1088
1131
|
declare function experimental_createEvaluator(options: Experimental_EvaluatorOptions): Experimental_CompositionEvaluator;
|
|
1089
1132
|
|
|
1090
|
-
export { type ActionDispatchInfo, type ActionObserver, type ActionSettleInfo, AndCondition, type BuildEditUserPromptOptions, type BuiltInAction, type Catalog, type ComputedFunction, type DirectiveDefinition, type DirectiveRegistry, DynamicValue, type EditConfig, type EditMode, type Experimental_ChoiceQuestion, type Experimental_ComposeSpecOptions, type Experimental_CompositionCandidate, type Experimental_CompositionCatalog, type Experimental_CompositionEvaluation, type Experimental_CompositionEvaluator, type Experimental_CompositionEvent, type Experimental_CompositionStep, type Experimental_EvaluatorOptions, type InferActionParams, type InferCatalogActions, type InferCatalogComponents, type InferCatalogInput, type InferComponentProps, type InferSpec, JsonPatch, type JsonSchemaOptions, OrCondition, type PromptContext, type PromptOptions, type PromptTemplate, type PropExpression, type PropResolutionContext, type RenderErrorHandler, type Schema, type SchemaBuilder, type SchemaDefinition, type SchemaOptions, type SchemaType, Spec, type SpecIssue, type SpecIssueSeverity, type SpecValidationIssues, type SpecValidationResult, StateCondition, StateModel, UIElement, type UserPromptOptions, type ValidateSpecOptions, type ValidationCheck, type ValidationCheckResult, ValidationCheckSchema, type ValidationConfig, ValidationConfigSchema, type ValidationContext, type ValidationFunction, type ValidationFunctionDefinition, type ValidationResult, VisibilityCondition, VisibilityConditionSchema, VisibilityConditionStrictSchema, type VisibilityContext, autoFixSpec, buildEditInstructions, buildEditUserPrompt, buildUserPrompt, builtInValidationFunctions, check, conditionUsesItemScope, createDirectiveRegistry, deepMergeSpec, defineCatalog, defineDirective, defineSchema, diffToPatches, evaluateVisibility, experimental_composeSpec, experimental_createEvaluator, findDirective, formatSpecIssues, isDevtoolsActive, isNonEmptySpec, markDevtoolsActive, nextActionDispatchId, notifyActionDispatch, notifyActionSettle, registerActionObserver, resolveActionParam, resolveBindings, resolveElementProps, resolvePropValue, runValidation, runValidationCheck, splitRepeatVisibility, subscribeDevtoolsActive, validateSpec, visibility };
|
|
1133
|
+
export { type ActionDispatchInfo, type ActionObserver, type ActionSettleInfo, AndCondition, type BuildEditUserPromptOptions, type BuiltInAction, type Catalog, type ComponentSlotMetadata, type ComputedFunction, type DirectiveDefinition, type DirectiveRegistry, DynamicValue, type EditConfig, type EditMode, type Experimental_ChoiceQuestion, type Experimental_ComposeSpecOptions, type Experimental_CompositionCandidate, type Experimental_CompositionCatalog, type Experimental_CompositionEvaluation, type Experimental_CompositionEvaluator, type Experimental_CompositionEvent, type Experimental_CompositionStep, type Experimental_EvaluatorOptions, type InferActionParams, type InferCatalogActions, type InferCatalogComponents, type InferCatalogInput, type InferComponentProps, type InferSpec, JsonPatch, type JsonSchemaOptions, OrCondition, type PromptContext, type PromptOptions, type PromptTemplate, type PropExpression, type PropResolutionContext, type RenderErrorHandler, type Schema, type SchemaBuilder, type SchemaDefinition, type SchemaOptions, type SchemaType, Spec, type SpecIssue, type SpecIssueSeverity, type SpecValidationIssues, type SpecValidationResult, StateCondition, StateModel, UIElement, type UserPromptOptions, type ValidateSpecOptions, type ValidationCheck, type ValidationCheckResult, ValidationCheckSchema, type ValidationConfig, ValidationConfigSchema, type ValidationContext, type ValidationFunction, type ValidationFunctionDefinition, type ValidationResult, VisibilityCondition, VisibilityConditionSchema, VisibilityConditionStrictSchema, type VisibilityContext, autoFixSpec, buildEditInstructions, buildEditUserPrompt, buildUserPrompt, builtInValidationFunctions, check, conditionUsesItemScope, copySlotMetadata, createDirectiveRegistry, deepMergeSpec, defineCatalog, defineDirective, defineSchema, diffToPatches, evaluateVisibility, experimental_composeSpec, experimental_createEvaluator, findDirective, formatSpecIssues, getComponentSlotMetadata, isDevtoolsActive, isNonEmptySpec, markDevtoolsActive, nextActionDispatchId, notifyActionDispatch, notifyActionSettle, registerActionObserver, resolveActionParam, resolveBindings, resolveElementProps, resolvePropValue, runValidation, runValidationCheck, setCatalogSlotMetadata, splitRepeatVisibility, subscribeDevtoolsActive, validateSpec, visibility, warnElementSlots };
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
check: () => check,
|
|
49
49
|
compileSpecStream: () => compileSpecStream,
|
|
50
50
|
conditionUsesItemScope: () => conditionUsesItemScope,
|
|
51
|
+
copySlotMetadata: () => copySlotMetadata,
|
|
51
52
|
createDirectiveRegistry: () => createDirectiveRegistry,
|
|
52
53
|
createJsonRenderTransform: () => createJsonRenderTransform,
|
|
53
54
|
createMixedStreamParser: () => createMixedStreamParser,
|
|
@@ -66,6 +67,7 @@ __export(index_exports, {
|
|
|
66
67
|
findFormValue: () => findFormValue,
|
|
67
68
|
formatSpecIssues: () => formatSpecIssues,
|
|
68
69
|
getByPath: () => getByPath,
|
|
70
|
+
getComponentSlotMetadata: () => getComponentSlotMetadata,
|
|
69
71
|
interpolateString: () => interpolateString,
|
|
70
72
|
isDevtoolsActive: () => isDevtoolsActive,
|
|
71
73
|
isNonEmptySpec: () => isNonEmptySpec,
|
|
@@ -89,10 +91,12 @@ __export(index_exports, {
|
|
|
89
91
|
runValidation: () => runValidation,
|
|
90
92
|
runValidationCheck: () => runValidationCheck,
|
|
91
93
|
setByPath: () => setByPath,
|
|
94
|
+
setCatalogSlotMetadata: () => setCatalogSlotMetadata,
|
|
92
95
|
splitRepeatVisibility: () => splitRepeatVisibility,
|
|
93
96
|
subscribeDevtoolsActive: () => subscribeDevtoolsActive,
|
|
94
97
|
validateSpec: () => validateSpec,
|
|
95
|
-
visibility: () => visibility
|
|
98
|
+
visibility: () => visibility,
|
|
99
|
+
warnElementSlots: () => warnElementSlots
|
|
96
100
|
});
|
|
97
101
|
module.exports = __toCommonJS(index_exports);
|
|
98
102
|
|
|
@@ -3195,6 +3199,37 @@ Remember: Output /root first, then interleave /elements and /state patches so th
|
|
|
3195
3199
|
return parts.join("\n");
|
|
3196
3200
|
}
|
|
3197
3201
|
|
|
3202
|
+
// src/slot-metadata.ts
|
|
3203
|
+
var registryMetadata = /* @__PURE__ */ new WeakMap();
|
|
3204
|
+
function setCatalogSlotMetadata(registry, catalog) {
|
|
3205
|
+
const components = catalog?.data?.components;
|
|
3206
|
+
if (components) registryMetadata.set(registry, components);
|
|
3207
|
+
}
|
|
3208
|
+
function copySlotMetadata(from, to) {
|
|
3209
|
+
const components = registryMetadata.get(from);
|
|
3210
|
+
if (components) registryMetadata.set(to, components);
|
|
3211
|
+
}
|
|
3212
|
+
function getComponentSlotMetadata(registry, type) {
|
|
3213
|
+
return registryMetadata.get(registry)?.[type];
|
|
3214
|
+
}
|
|
3215
|
+
function warnElementSlots(registry, type, slots) {
|
|
3216
|
+
if (!slots) return;
|
|
3217
|
+
const declared = getComponentSlotMetadata(registry, type)?.slots;
|
|
3218
|
+
if (!declared) return;
|
|
3219
|
+
const available = new Set(declared);
|
|
3220
|
+
for (const slotName of Object.keys(slots)) {
|
|
3221
|
+
if (slotName === "default") {
|
|
3222
|
+
console.warn(
|
|
3223
|
+
`[json-render] Component "${type}" uses slots.default. Use "children" for default slot content.`
|
|
3224
|
+
);
|
|
3225
|
+
} else if (!available.has(slotName)) {
|
|
3226
|
+
console.warn(
|
|
3227
|
+
`[json-render] Unknown slot "${slotName}" on component "${type}". Available slots: ${declared.filter((slot) => slot !== "default").join(", ")}`
|
|
3228
|
+
);
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3198
3233
|
// src/merge.ts
|
|
3199
3234
|
function isPlainObject(value) {
|
|
3200
3235
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -4149,6 +4184,7 @@ function experimental_createEvaluator(options) {
|
|
|
4149
4184
|
check,
|
|
4150
4185
|
compileSpecStream,
|
|
4151
4186
|
conditionUsesItemScope,
|
|
4187
|
+
copySlotMetadata,
|
|
4152
4188
|
createDirectiveRegistry,
|
|
4153
4189
|
createJsonRenderTransform,
|
|
4154
4190
|
createMixedStreamParser,
|
|
@@ -4167,6 +4203,7 @@ function experimental_createEvaluator(options) {
|
|
|
4167
4203
|
findFormValue,
|
|
4168
4204
|
formatSpecIssues,
|
|
4169
4205
|
getByPath,
|
|
4206
|
+
getComponentSlotMetadata,
|
|
4170
4207
|
interpolateString,
|
|
4171
4208
|
isDevtoolsActive,
|
|
4172
4209
|
isNonEmptySpec,
|
|
@@ -4190,9 +4227,11 @@ function experimental_createEvaluator(options) {
|
|
|
4190
4227
|
runValidation,
|
|
4191
4228
|
runValidationCheck,
|
|
4192
4229
|
setByPath,
|
|
4230
|
+
setCatalogSlotMetadata,
|
|
4193
4231
|
splitRepeatVisibility,
|
|
4194
4232
|
subscribeDevtoolsActive,
|
|
4195
4233
|
validateSpec,
|
|
4196
|
-
visibility
|
|
4234
|
+
visibility,
|
|
4235
|
+
warnElementSlots
|
|
4197
4236
|
});
|
|
4198
4237
|
//# sourceMappingURL=index.js.map
|