@constela/core 0.17.4 → 0.18.1
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.ts +11 -4
- package/dist/index.js +19 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ declare function isThemeConfig(value: unknown): value is ThemeConfig;
|
|
|
50
50
|
* for representing Constela UI applications.
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
|
-
declare const BINARY_OPERATORS: readonly ["+", "-", "*", "/", "==", "!=", "<", "<=", ">", ">=", "&&", "||"];
|
|
53
|
+
declare const BINARY_OPERATORS: readonly ["+", "-", "*", "/", "%", "==", "!=", "<", "<=", ">", ">=", "&&", "||"];
|
|
54
54
|
type BinaryOperator = (typeof BINARY_OPERATORS)[number];
|
|
55
55
|
declare const UPDATE_OPERATIONS: readonly ["increment", "decrement", "push", "pop", "remove", "toggle", "merge", "replaceAt", "insertAt", "splice"];
|
|
56
56
|
type UpdateOperation = (typeof UPDATE_OPERATIONS)[number];
|
|
@@ -100,6 +100,13 @@ interface StateExpr {
|
|
|
100
100
|
name: string;
|
|
101
101
|
path?: string;
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Local state expression - references a component's local state
|
|
105
|
+
*/
|
|
106
|
+
interface LocalExpr {
|
|
107
|
+
expr: 'local';
|
|
108
|
+
name: string;
|
|
109
|
+
}
|
|
103
110
|
/**
|
|
104
111
|
* Variable expression - references a loop variable or event data
|
|
105
112
|
*/
|
|
@@ -216,7 +223,7 @@ interface ValidityExpr {
|
|
|
216
223
|
*/
|
|
217
224
|
interface CallExpr {
|
|
218
225
|
expr: 'call';
|
|
219
|
-
target: Expression;
|
|
226
|
+
target: Expression | null;
|
|
220
227
|
method: string;
|
|
221
228
|
args?: Expression[];
|
|
222
229
|
}
|
|
@@ -236,7 +243,7 @@ interface ArrayExpr {
|
|
|
236
243
|
expr: 'array';
|
|
237
244
|
elements: Expression[];
|
|
238
245
|
}
|
|
239
|
-
type Expression = LitExpr | StateExpr | VarExpr | BinExpr | NotExpr | ParamExpr | CondExpr | GetExpr | RouteExpr | ImportExpr | DataExpr | RefExpr | IndexExpr | StyleExpr | ConcatExpr | ValidityExpr | CallExpr | LambdaExpr | ArrayExpr;
|
|
246
|
+
type Expression = LitExpr | StateExpr | LocalExpr | VarExpr | BinExpr | NotExpr | ParamExpr | CondExpr | GetExpr | RouteExpr | ImportExpr | DataExpr | RefExpr | IndexExpr | StyleExpr | ConcatExpr | ValidityExpr | CallExpr | LambdaExpr | ArrayExpr;
|
|
240
247
|
/**
|
|
241
248
|
* Cookie expression for state initial value
|
|
242
249
|
*/
|
|
@@ -2424,4 +2431,4 @@ declare function isSuspenseBoundary(value: unknown): value is SuspenseBoundary;
|
|
|
2424
2431
|
*/
|
|
2425
2432
|
declare function isStreamChunk(value: unknown): value is StreamChunk;
|
|
2426
2433
|
|
|
2427
|
-
export { AI_OUTPUT_TYPES, AI_PROVIDER_TYPES, type ActionDefinition, type ActionStep, type AiDataSource, type AiOutputType, type AiProviderType, type ArrayExpr, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type BindStep, type BooleanField, CLIPBOARD_OPERATIONS, COLOR_SCHEMES, type CallExpr, type CallStep, type ClearTimerStep, type ClipboardOperation, type ClipboardStep, type CloseStep, type CodeNode, type ColorScheme, type ComponentDef, type ComponentNode, type ComponentsRef, type CompoundVariant, type ConcatExpr, type CondExpr, type ConfirmStep, type ConstelaAst, ConstelaError, type ConstelaProgram, type CookieInitialExpr, DATA_SOURCE_TYPES, DATA_TRANSFORMS, type DataExpr, type DataSource, type DataSourceType, type DataTransform, type DelayStep, type DisposeStep, type DomStep, type EachNode, type ElementNode, type ErrorBoundaryNode, type ErrorCode, type ErrorOptions, type EventHandler, type EventHandlerOptions, type Expression, FOCUS_OPERATIONS, type FetchStep, type FlushStrategy, type FocusOperation, type FocusStep, type GenerateStep, type GetExpr, HTTP_METHODS, type HttpMethod, ISLAND_STRATEGIES, type IfNode, type IfStep, type ImportExpr, type ImportStep, type IndexExpr, type IntervalStep, type IslandNode, type IslandStrategy, type IslandStrategyOptions, type LambdaExpr, type LayoutProgram, type LifecycleHooks, type ListField, type LitExpr, type LocalActionDefinition, type LocalActionStep, type MarkdownNode, NAVIGATE_TARGETS, type NavigateStep, type NavigateTarget, type NotExpr, type NumberField, type ObjectField, type OptimisticStep, PARAM_TYPES, type ParamDef, type ParamExpr, type ParamType, type PortalNode, type Program, type ReconnectConfig, type RefExpr, type RejectStep, type RouteDefinition, type RouteExpr, type SSECloseStep, type SSEConnectStep, STORAGE_OPERATIONS, STORAGE_TYPES, type SendStep, type SetPathStep, type SetStep, type SlotNode, type StateExpr, type StateField, type StaticPathsDefinition, type StorageOperation, type StorageStep, type StorageType, type StreamChunk, type StreamChunkType, type StreamingRenderOptions, type StringField, type StyleExpr, type StylePreset, type SubscribeStep, type SuspenseBoundary, type SuspenseNode, type TextNode, type ThemeColors, type ThemeConfig, type ThemeFonts, UPDATE_OPERATIONS, type UnbindStep, type UpdateOperation, type UpdateStep, VALIDITY_PROPERTIES, type ValidationFailure, type ValidationResult, type ValidationSuccess, type ValidityExpr, type ValidityProperty, type VarExpr, type ViewNode, astSchema, createClipboardWriteMissingValueError, createComponentCycleError, createComponentNotFoundError, createComponentPropMissingError, createComponentPropTypeError, createCondElseRequiredError, createDataNotDefinedError, createDuplicateActionError, createDuplicateDefaultSlotError, createDuplicateIslandIdError, createDuplicateSlotNameError, createImportsNotDefinedError, createInvalidClipboardOperationError, createInvalidDataSourceError, createInvalidNavigateTargetError, createInvalidSlotNameError, createInvalidStorageOperationError, createInvalidStorageTypeError, createLayoutMissingSlotError, createLayoutNotFoundError, createLocalActionInvalidStepError, createOperationInvalidForTypeError, createOperationMissingFieldError, createOperationUnknownError, createRouteNotDefinedError, createSchemaError, createSlotInLoopError, createStorageSetMissingValueError, createUndefinedActionError, createUndefinedDataError, createUndefinedDataSourceError, createUndefinedImportError, createUndefinedLocalStateError, createUndefinedParamError, createUndefinedRefError, createUndefinedRouteParamError, createUndefinedStateError, createUndefinedStyleError, createUndefinedVarError, createUndefinedVariantError, createUnsupportedVersionError, findSimilarNames, isActionStep, isAiDataSource, isArrayExpr, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isColorScheme, isComponentNode, isConcatExpr, isCondExpr, isConstelaError, isCookieInitialExpr, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isErrorBoundaryNode, isEventHandler, isExpression, isFetchStep, isFocusStep, isGenerateStep, isGetExpr, isIfNode, isImportExpr, isImportStep, isIslandNode, isIslandStrategy, isIslandStrategyOptions, isLayoutProgram, isLifecycleHooks, isListField, isLitExpr, isLocalActionDefinition, isLocalActionStep, isMarkdownNode, isNamedSlotNode, isNavigateStep, isNotExpr, isNumberField, isObjectField, isParamExpr, isPortalNode, isRefExpr, isRouteDefinition, isRouteExpr, isSetPathStep, isSetStep, isSlotNode, isStateExpr, isStateField, isStaticPathsDefinition, isStorageStep, isStreamChunk, isStreamingRenderOptions, isStringField, isStyleExpr, isSubscribeStep, isSuspenseBoundary, isSuspenseNode, isTextNode, isThemeColors, isThemeConfig, isThemeFonts, isUpdateStep, isValidityExpr, isVarExpr, isViewNode, validateAst };
|
|
2434
|
+
export { AI_OUTPUT_TYPES, AI_PROVIDER_TYPES, type ActionDefinition, type ActionStep, type AiDataSource, type AiOutputType, type AiProviderType, type ArrayExpr, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type BindStep, type BooleanField, CLIPBOARD_OPERATIONS, COLOR_SCHEMES, type CallExpr, type CallStep, type ClearTimerStep, type ClipboardOperation, type ClipboardStep, type CloseStep, type CodeNode, type ColorScheme, type ComponentDef, type ComponentNode, type ComponentsRef, type CompoundVariant, type ConcatExpr, type CondExpr, type ConfirmStep, type ConstelaAst, ConstelaError, type ConstelaProgram, type CookieInitialExpr, DATA_SOURCE_TYPES, DATA_TRANSFORMS, type DataExpr, type DataSource, type DataSourceType, type DataTransform, type DelayStep, type DisposeStep, type DomStep, type EachNode, type ElementNode, type ErrorBoundaryNode, type ErrorCode, type ErrorOptions, type EventHandler, type EventHandlerOptions, type Expression, FOCUS_OPERATIONS, type FetchStep, type FlushStrategy, type FocusOperation, type FocusStep, type GenerateStep, type GetExpr, HTTP_METHODS, type HttpMethod, ISLAND_STRATEGIES, type IfNode, type IfStep, type ImportExpr, type ImportStep, type IndexExpr, type IntervalStep, type IslandNode, type IslandStrategy, type IslandStrategyOptions, type LambdaExpr, type LayoutProgram, type LifecycleHooks, type ListField, type LitExpr, type LocalActionDefinition, type LocalActionStep, type LocalExpr, type MarkdownNode, NAVIGATE_TARGETS, type NavigateStep, type NavigateTarget, type NotExpr, type NumberField, type ObjectField, type OptimisticStep, PARAM_TYPES, type ParamDef, type ParamExpr, type ParamType, type PortalNode, type Program, type ReconnectConfig, type RefExpr, type RejectStep, type RouteDefinition, type RouteExpr, type SSECloseStep, type SSEConnectStep, STORAGE_OPERATIONS, STORAGE_TYPES, type SendStep, type SetPathStep, type SetStep, type SlotNode, type StateExpr, type StateField, type StaticPathsDefinition, type StorageOperation, type StorageStep, type StorageType, type StreamChunk, type StreamChunkType, type StreamingRenderOptions, type StringField, type StyleExpr, type StylePreset, type SubscribeStep, type SuspenseBoundary, type SuspenseNode, type TextNode, type ThemeColors, type ThemeConfig, type ThemeFonts, UPDATE_OPERATIONS, type UnbindStep, type UpdateOperation, type UpdateStep, VALIDITY_PROPERTIES, type ValidationFailure, type ValidationResult, type ValidationSuccess, type ValidityExpr, type ValidityProperty, type VarExpr, type ViewNode, astSchema, createClipboardWriteMissingValueError, createComponentCycleError, createComponentNotFoundError, createComponentPropMissingError, createComponentPropTypeError, createCondElseRequiredError, createDataNotDefinedError, createDuplicateActionError, createDuplicateDefaultSlotError, createDuplicateIslandIdError, createDuplicateSlotNameError, createImportsNotDefinedError, createInvalidClipboardOperationError, createInvalidDataSourceError, createInvalidNavigateTargetError, createInvalidSlotNameError, createInvalidStorageOperationError, createInvalidStorageTypeError, createLayoutMissingSlotError, createLayoutNotFoundError, createLocalActionInvalidStepError, createOperationInvalidForTypeError, createOperationMissingFieldError, createOperationUnknownError, createRouteNotDefinedError, createSchemaError, createSlotInLoopError, createStorageSetMissingValueError, createUndefinedActionError, createUndefinedDataError, createUndefinedDataSourceError, createUndefinedImportError, createUndefinedLocalStateError, createUndefinedParamError, createUndefinedRefError, createUndefinedRouteParamError, createUndefinedStateError, createUndefinedStyleError, createUndefinedVarError, createUndefinedVariantError, createUnsupportedVersionError, findSimilarNames, isActionStep, isAiDataSource, isArrayExpr, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isColorScheme, isComponentNode, isConcatExpr, isCondExpr, isConstelaError, isCookieInitialExpr, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isErrorBoundaryNode, isEventHandler, isExpression, isFetchStep, isFocusStep, isGenerateStep, isGetExpr, isIfNode, isImportExpr, isImportStep, isIslandNode, isIslandStrategy, isIslandStrategyOptions, isLayoutProgram, isLifecycleHooks, isListField, isLitExpr, isLocalActionDefinition, isLocalActionStep, isMarkdownNode, isNamedSlotNode, isNavigateStep, isNotExpr, isNumberField, isObjectField, isParamExpr, isPortalNode, isRefExpr, isRouteDefinition, isRouteExpr, isSetPathStep, isSetStep, isSlotNode, isStateExpr, isStateField, isStaticPathsDefinition, isStorageStep, isStreamChunk, isStreamingRenderOptions, isStringField, isStyleExpr, isSubscribeStep, isSuspenseBoundary, isSuspenseNode, isTextNode, isThemeColors, isThemeConfig, isThemeFonts, isUpdateStep, isValidityExpr, isVarExpr, isViewNode, validateAst };
|
package/dist/index.js
CHANGED
|
@@ -50,6 +50,7 @@ var BINARY_OPERATORS = [
|
|
|
50
50
|
"-",
|
|
51
51
|
"*",
|
|
52
52
|
"/",
|
|
53
|
+
"%",
|
|
53
54
|
"==",
|
|
54
55
|
"!=",
|
|
55
56
|
"<",
|
|
@@ -988,7 +989,7 @@ function isObject3(value) {
|
|
|
988
989
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
989
990
|
}
|
|
990
991
|
var VALID_VIEW_KINDS = ["element", "text", "if", "each", "component", "slot", "markdown", "code", "portal", "island"];
|
|
991
|
-
var VALID_EXPR_TYPES = ["lit", "state", "var", "bin", "not", "param", "cond", "get", "style", "validity", "index", "call", "lambda", "array", "concat"];
|
|
992
|
+
var VALID_EXPR_TYPES = ["lit", "state", "local", "var", "bin", "not", "param", "cond", "get", "style", "validity", "index", "call", "lambda", "array", "concat", "obj"];
|
|
992
993
|
var VALID_PARAM_TYPES = ["string", "number", "boolean", "json"];
|
|
993
994
|
var VALID_ACTION_TYPES = ["set", "update", "setPath", "fetch", "delay", "interval", "clearTimer", "focus", "if", "storage", "dom", "sseConnect", "sseClose", "optimistic", "confirm", "reject"];
|
|
994
995
|
var VALID_STATE_TYPES = ["number", "string", "list", "boolean", "object"];
|
|
@@ -1217,6 +1218,7 @@ function validateExpression(expr, path) {
|
|
|
1217
1218
|
}
|
|
1218
1219
|
break;
|
|
1219
1220
|
case "state":
|
|
1221
|
+
case "local":
|
|
1220
1222
|
case "var":
|
|
1221
1223
|
if (typeof expr["name"] !== "string") {
|
|
1222
1224
|
return { path: path + "/name", message: "name is required" };
|
|
@@ -1323,8 +1325,10 @@ function validateExpression(expr, path) {
|
|
|
1323
1325
|
return { path: path + "/method", message: "method is required" };
|
|
1324
1326
|
}
|
|
1325
1327
|
{
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
+
if (expr["target"] !== null) {
|
|
1329
|
+
const targetError = validateExpression(expr["target"], path + "/target");
|
|
1330
|
+
if (targetError) return targetError;
|
|
1331
|
+
}
|
|
1328
1332
|
if ("args" in expr && expr["args"] !== void 0) {
|
|
1329
1333
|
if (!Array.isArray(expr["args"])) {
|
|
1330
1334
|
return { path: path + "/args", message: "args must be an array" };
|
|
@@ -1375,6 +1379,18 @@ function validateExpression(expr, path) {
|
|
|
1375
1379
|
if (itemError) return itemError;
|
|
1376
1380
|
}
|
|
1377
1381
|
break;
|
|
1382
|
+
case "obj":
|
|
1383
|
+
if (!("props" in expr)) {
|
|
1384
|
+
return { path: path + "/props", message: "props is required" };
|
|
1385
|
+
}
|
|
1386
|
+
if (!isObject3(expr["props"])) {
|
|
1387
|
+
return { path: path + "/props", message: "props must be an object" };
|
|
1388
|
+
}
|
|
1389
|
+
for (const [propKey, propValue] of Object.entries(expr["props"])) {
|
|
1390
|
+
const propError = validateExpression(propValue, path + "/props/" + propKey);
|
|
1391
|
+
if (propError) return propError;
|
|
1392
|
+
}
|
|
1393
|
+
break;
|
|
1378
1394
|
}
|
|
1379
1395
|
return null;
|
|
1380
1396
|
}
|