@constela/core 0.9.0 → 0.9.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/README.md CHANGED
@@ -79,6 +79,9 @@ All fields except `version`, `state`, `actions`, and `view` are optional.
79
79
  // Loop node
80
80
  { "kind": "each", "items": { "expr": "state", "name": "todos" }, "as": "item", "body": { ... } }
81
81
 
82
+ // Loop node with key (efficient diffing)
83
+ { "kind": "each", "items": { ... }, "as": "item", "key": { "expr": "var", "name": "item", "path": "id" }, "body": { ... } }
84
+
82
85
  // Component node
83
86
  { "kind": "component", "name": "Button", "props": { "label": { ... } } }
84
87
 
@@ -95,7 +98,7 @@ All fields except `version`, `state`, `actions`, and `view` are optional.
95
98
 
96
99
  ## Action Step Types
97
100
 
98
- 11 step types for declarative actions:
101
+ 14 step types for declarative actions:
99
102
 
100
103
  ```json
101
104
  // Set state value
@@ -105,6 +108,10 @@ All fields except `version`, `state`, `actions`, and `view` are optional.
105
108
  { "do": "update", "target": "count", "operation": "increment" }
106
109
  { "do": "update", "target": "todos", "operation": "push", "value": { ... } }
107
110
 
111
+ // Set nested path (fine-grained update)
112
+ { "do": "setPath", "target": "posts", "path": [5, "liked"], "value": { "expr": "lit", "value": true } }
113
+ { "do": "setPath", "target": "posts", "path": { "expr": "var", "name": "payload", "path": "index" }, "field": "liked", "value": { ... } }
114
+
108
115
  // HTTP request
109
116
  { "do": "fetch", "url": { ... }, "method": "GET", "onSuccess": [ ... ], "onError": [ ... ] }
110
117
 
@@ -131,6 +138,30 @@ All fields except `version`, `state`, `actions`, and `view` are optional.
131
138
 
132
139
  // DOM manipulation
133
140
  { "do": "dom", "operation": "addClass", "ref": "myElement", "value": { ... } }
141
+
142
+ // WebSocket send
143
+ { "do": "send", "connection": "chat", "data": { "expr": "state", "name": "inputText" } }
144
+
145
+ // WebSocket close
146
+ { "do": "close", "connection": "chat" }
147
+ ```
148
+
149
+ ## Connections
150
+
151
+ WebSocket connections for real-time data:
152
+
153
+ ```json
154
+ {
155
+ "connections": {
156
+ "chat": {
157
+ "type": "websocket",
158
+ "url": "wss://api.example.com/ws",
159
+ "onMessage": { "action": "handleMessage" },
160
+ "onOpen": { "action": "connectionOpened" },
161
+ "onClose": { "action": "connectionClosed" }
162
+ }
163
+ }
164
+ }
134
165
  ```
135
166
 
136
167
  **Update Operations:**
package/dist/index.d.ts CHANGED
@@ -135,7 +135,14 @@ interface StyleExpr {
135
135
  name: string;
136
136
  variants?: Record<string, Expression>;
137
137
  }
138
- type Expression = LitExpr | StateExpr | VarExpr | BinExpr | NotExpr | ParamExpr | CondExpr | GetExpr | RouteExpr | ImportExpr | DataExpr | RefExpr | IndexExpr | StyleExpr;
138
+ /**
139
+ * Concat expression - concatenates multiple expressions into a string
140
+ */
141
+ interface ConcatExpr {
142
+ expr: 'concat';
143
+ items: Expression[];
144
+ }
145
+ type Expression = LitExpr | StateExpr | VarExpr | BinExpr | NotExpr | ParamExpr | CondExpr | GetExpr | RouteExpr | ImportExpr | DataExpr | RefExpr | IndexExpr | StyleExpr | ConcatExpr;
139
146
  /**
140
147
  * Number state field
141
148
  */
@@ -611,6 +618,10 @@ declare function isRefExpr(value: unknown): value is RefExpr;
611
618
  * Checks if value is a style expression
612
619
  */
613
620
  declare function isStyleExpr(value: unknown): value is StyleExpr;
621
+ /**
622
+ * Checks if value is a concat expression
623
+ */
624
+ declare function isConcatExpr(value: unknown): value is ConcatExpr;
614
625
  /**
615
626
  * Checks if value is a data source
616
627
  */
@@ -1709,4 +1720,4 @@ declare const astSchema: {
1709
1720
  };
1710
1721
  };
1711
1722
 
1712
- export { type ActionDefinition, type ActionStep, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type BooleanField, CLIPBOARD_OPERATIONS, type CallStep, type ClipboardOperation, type ClipboardStep, type CloseStep, type CodeNode, type ComponentDef, type ComponentNode, type ComponentsRef, type CompoundVariant, type CondExpr, type ConstelaAst, ConstelaError, type ConstelaProgram, DATA_SOURCE_TYPES, DATA_TRANSFORMS, type DataExpr, type DataSource, type DataSourceType, type DataTransform, type DisposeStep, type DomStep, type EachNode, type ElementNode, type ErrorCode, type ErrorOptions, type EventHandler, type Expression, type FetchStep, type GetExpr, HTTP_METHODS, type HttpMethod, type IfNode, type ImportExpr, type ImportStep, type LayoutProgram, type LifecycleHooks, type ListField, type LitExpr, type MarkdownNode, NAVIGATE_TARGETS, type NavigateStep, type NavigateTarget, type NotExpr, type NumberField, type ObjectField, PARAM_TYPES, type ParamDef, type ParamExpr, type ParamType, type Program, type RefExpr, type RouteDefinition, type RouteExpr, 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 StringField, type StyleExpr, type StylePreset, type SubscribeStep, type TextNode, UPDATE_OPERATIONS, type UpdateOperation, type UpdateStep, type ValidationFailure, type ValidationResult, type ValidationSuccess, type VarExpr, type ViewNode, astSchema, createClipboardWriteMissingValueError, createComponentCycleError, createComponentNotFoundError, createComponentPropMissingError, createComponentPropTypeError, createCondElseRequiredError, createDataNotDefinedError, createDuplicateActionError, createDuplicateDefaultSlotError, createDuplicateSlotNameError, createImportsNotDefinedError, createInvalidClipboardOperationError, createInvalidDataSourceError, createInvalidNavigateTargetError, createInvalidSlotNameError, createInvalidStorageOperationError, createInvalidStorageTypeError, createLayoutMissingSlotError, createLayoutNotFoundError, createOperationInvalidForTypeError, createOperationMissingFieldError, createOperationUnknownError, createRouteNotDefinedError, createSchemaError, createSlotInLoopError, createStorageSetMissingValueError, createUndefinedActionError, createUndefinedDataError, createUndefinedDataSourceError, createUndefinedImportError, createUndefinedParamError, createUndefinedRefError, createUndefinedRouteParamError, createUndefinedStateError, createUndefinedStyleError, createUndefinedVarError, createUndefinedVariantError, createUnsupportedVersionError, findSimilarNames, isActionStep, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isComponentNode, isCondExpr, isConstelaError, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isEventHandler, isExpression, isFetchStep, isGetExpr, isIfNode, isImportExpr, isImportStep, isLayoutProgram, isLifecycleHooks, isListField, isLitExpr, isMarkdownNode, isNamedSlotNode, isNavigateStep, isNotExpr, isNumberField, isObjectField, isParamExpr, isRefExpr, isRouteDefinition, isRouteExpr, isSetStep, isSlotNode, isStateExpr, isStateField, isStaticPathsDefinition, isStorageStep, isStringField, isStyleExpr, isSubscribeStep, isTextNode, isUpdateStep, isVarExpr, isViewNode, validateAst };
1723
+ export { type ActionDefinition, type ActionStep, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type BooleanField, CLIPBOARD_OPERATIONS, type CallStep, type ClipboardOperation, type ClipboardStep, type CloseStep, type CodeNode, type ComponentDef, type ComponentNode, type ComponentsRef, type CompoundVariant, type ConcatExpr, type CondExpr, type ConstelaAst, ConstelaError, type ConstelaProgram, DATA_SOURCE_TYPES, DATA_TRANSFORMS, type DataExpr, type DataSource, type DataSourceType, type DataTransform, type DisposeStep, type DomStep, type EachNode, type ElementNode, type ErrorCode, type ErrorOptions, type EventHandler, type Expression, type FetchStep, type GetExpr, HTTP_METHODS, type HttpMethod, type IfNode, type ImportExpr, type ImportStep, type LayoutProgram, type LifecycleHooks, type ListField, type LitExpr, type MarkdownNode, NAVIGATE_TARGETS, type NavigateStep, type NavigateTarget, type NotExpr, type NumberField, type ObjectField, PARAM_TYPES, type ParamDef, type ParamExpr, type ParamType, type Program, type RefExpr, type RouteDefinition, type RouteExpr, 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 StringField, type StyleExpr, type StylePreset, type SubscribeStep, type TextNode, UPDATE_OPERATIONS, type UpdateOperation, type UpdateStep, type ValidationFailure, type ValidationResult, type ValidationSuccess, type VarExpr, type ViewNode, astSchema, createClipboardWriteMissingValueError, createComponentCycleError, createComponentNotFoundError, createComponentPropMissingError, createComponentPropTypeError, createCondElseRequiredError, createDataNotDefinedError, createDuplicateActionError, createDuplicateDefaultSlotError, createDuplicateSlotNameError, createImportsNotDefinedError, createInvalidClipboardOperationError, createInvalidDataSourceError, createInvalidNavigateTargetError, createInvalidSlotNameError, createInvalidStorageOperationError, createInvalidStorageTypeError, createLayoutMissingSlotError, createLayoutNotFoundError, createOperationInvalidForTypeError, createOperationMissingFieldError, createOperationUnknownError, createRouteNotDefinedError, createSchemaError, createSlotInLoopError, createStorageSetMissingValueError, createUndefinedActionError, createUndefinedDataError, createUndefinedDataSourceError, createUndefinedImportError, createUndefinedParamError, createUndefinedRefError, createUndefinedRouteParamError, createUndefinedStateError, createUndefinedStyleError, createUndefinedVarError, createUndefinedVariantError, createUnsupportedVersionError, findSimilarNames, isActionStep, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isComponentNode, isConcatExpr, isCondExpr, isConstelaError, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isEventHandler, isExpression, isFetchStep, isGetExpr, isIfNode, isImportExpr, isImportStep, isLayoutProgram, isLifecycleHooks, isListField, isLitExpr, isMarkdownNode, isNamedSlotNode, isNavigateStep, isNotExpr, isNumberField, isObjectField, isParamExpr, isRefExpr, isRouteDefinition, isRouteExpr, isSetStep, isSlotNode, isStateExpr, isStateField, isStaticPathsDefinition, isStorageStep, isStringField, isStyleExpr, isSubscribeStep, isTextNode, isUpdateStep, isVarExpr, isViewNode, validateAst };
package/dist/index.js CHANGED
@@ -139,6 +139,9 @@ function isStyleExpr(value) {
139
139
  }
140
140
  return true;
141
141
  }
142
+ function isConcatExpr(value) {
143
+ return typeof value === "object" && value !== null && value.expr === "concat" && Array.isArray(value.items);
144
+ }
142
145
  function isDataSource(value) {
143
146
  if (!isObject(value)) return false;
144
147
  const type = value["type"];
@@ -175,7 +178,7 @@ function isRouteDefinition(value) {
175
178
  return true;
176
179
  }
177
180
  function isExpression(value) {
178
- return isLitExpr(value) || isStateExpr(value) || isVarExpr(value) || isBinExpr(value) || isNotExpr(value) || isParamExpr(value) || isCondExpr(value) || isGetExpr(value) || isRouteExpr(value) || isImportExpr(value) || isDataExpr(value) || isRefExpr(value) || isIndexExpr(value) || isStyleExpr(value);
181
+ return isLitExpr(value) || isStateExpr(value) || isVarExpr(value) || isBinExpr(value) || isNotExpr(value) || isParamExpr(value) || isCondExpr(value) || isGetExpr(value) || isRouteExpr(value) || isImportExpr(value) || isDataExpr(value) || isRefExpr(value) || isIndexExpr(value) || isStyleExpr(value) || isConcatExpr(value);
179
182
  }
180
183
  function isElementNode(value) {
181
184
  if (!isObject(value)) return false;
@@ -1904,6 +1907,7 @@ export {
1904
1907
  isClipboardStep,
1905
1908
  isCodeNode,
1906
1909
  isComponentNode,
1910
+ isConcatExpr,
1907
1911
  isCondExpr,
1908
1912
  isConstelaError,
1909
1913
  isDataExpr,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/core",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Core types, schema, and validator for Constela UI framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",