@constela/compiler 0.10.0 → 0.11.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/index.d.ts +60 -4
- package/dist/index.js +94 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ interface CompiledAction {
|
|
|
89
89
|
name: string;
|
|
90
90
|
steps: CompiledActionStep[];
|
|
91
91
|
}
|
|
92
|
-
type CompiledActionStep = CompiledSetStep | CompiledUpdateStep | CompiledSetPathStep | CompiledFetchStep | CompiledStorageStep | CompiledClipboardStep | CompiledNavigateStep | CompiledImportStep | CompiledCallStep | CompiledSubscribeStep | CompiledDisposeStep | CompiledDomStep | CompiledIfStep | CompiledSendStep | CompiledCloseStep;
|
|
92
|
+
type CompiledActionStep = CompiledSetStep | CompiledUpdateStep | CompiledSetPathStep | CompiledFetchStep | CompiledStorageStep | CompiledClipboardStep | CompiledNavigateStep | CompiledImportStep | CompiledCallStep | CompiledSubscribeStep | CompiledDisposeStep | CompiledDomStep | CompiledIfStep | CompiledSendStep | CompiledCloseStep | CompiledDelayStep | CompiledIntervalStep | CompiledClearTimerStep | CompiledFocusStep;
|
|
93
93
|
interface CompiledSetStep {
|
|
94
94
|
do: 'set';
|
|
95
95
|
target: string;
|
|
@@ -217,6 +217,41 @@ interface CompiledCloseStep {
|
|
|
217
217
|
do: 'close';
|
|
218
218
|
connection: string;
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Compiled delay step - executes steps after a delay (setTimeout equivalent)
|
|
222
|
+
*/
|
|
223
|
+
interface CompiledDelayStep {
|
|
224
|
+
do: 'delay';
|
|
225
|
+
ms: CompiledExpression;
|
|
226
|
+
then: CompiledActionStep[];
|
|
227
|
+
result?: string;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Compiled interval step - executes an action repeatedly (setInterval equivalent)
|
|
231
|
+
*/
|
|
232
|
+
interface CompiledIntervalStep {
|
|
233
|
+
do: 'interval';
|
|
234
|
+
ms: CompiledExpression;
|
|
235
|
+
action: string;
|
|
236
|
+
result?: string;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Compiled clearTimer step - clears a timer (clearTimeout/clearInterval equivalent)
|
|
240
|
+
*/
|
|
241
|
+
interface CompiledClearTimerStep {
|
|
242
|
+
do: 'clearTimer';
|
|
243
|
+
target: CompiledExpression;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Compiled focus step - manages form element focus
|
|
247
|
+
*/
|
|
248
|
+
interface CompiledFocusStep {
|
|
249
|
+
do: 'focus';
|
|
250
|
+
target: CompiledExpression;
|
|
251
|
+
operation: 'focus' | 'blur' | 'select';
|
|
252
|
+
onSuccess?: CompiledActionStep[];
|
|
253
|
+
onError?: CompiledActionStep[];
|
|
254
|
+
}
|
|
220
255
|
/**
|
|
221
256
|
* Compiled local action
|
|
222
257
|
*/
|
|
@@ -236,7 +271,7 @@ interface CompiledLocalStateNode {
|
|
|
236
271
|
actions: Record<string, CompiledLocalAction>;
|
|
237
272
|
child: CompiledNode;
|
|
238
273
|
}
|
|
239
|
-
type CompiledNode = CompiledElementNode | CompiledTextNode | CompiledIfNode | CompiledEachNode | CompiledMarkdownNode | CompiledCodeNode | CompiledSlotNode | CompiledLocalStateNode;
|
|
274
|
+
type CompiledNode = CompiledElementNode | CompiledTextNode | CompiledIfNode | CompiledEachNode | CompiledMarkdownNode | CompiledCodeNode | CompiledSlotNode | CompiledPortalNode | CompiledLocalStateNode;
|
|
240
275
|
interface CompiledElementNode {
|
|
241
276
|
kind: 'element';
|
|
242
277
|
tag: string;
|
|
@@ -275,7 +310,12 @@ interface CompiledSlotNode {
|
|
|
275
310
|
kind: 'slot';
|
|
276
311
|
name?: string;
|
|
277
312
|
}
|
|
278
|
-
|
|
313
|
+
interface CompiledPortalNode {
|
|
314
|
+
kind: 'portal';
|
|
315
|
+
target: 'body' | 'head' | string;
|
|
316
|
+
children: CompiledNode[];
|
|
317
|
+
}
|
|
318
|
+
type CompiledExpression = CompiledLitExpr | CompiledStateExpr | CompiledVarExpr | CompiledBinExpr | CompiledNotExpr | CompiledCondExpr | CompiledGetExpr | CompiledRouteExpr | CompiledImportExpr | CompiledDataExpr | CompiledRefExpr | CompiledIndexExpr | CompiledParamExpr | CompiledStyleExpr | CompiledConcatExpr | CompiledValidityExpr;
|
|
279
319
|
interface CompiledLitExpr {
|
|
280
320
|
expr: 'lit';
|
|
281
321
|
value: string | number | boolean | null | unknown[];
|
|
@@ -345,10 +385,26 @@ interface CompiledConcatExpr {
|
|
|
345
385
|
expr: 'concat';
|
|
346
386
|
items: CompiledExpression[];
|
|
347
387
|
}
|
|
388
|
+
interface CompiledValidityExpr {
|
|
389
|
+
expr: 'validity';
|
|
390
|
+
ref: string;
|
|
391
|
+
property?: string;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Compiled event handler options for special events like intersect
|
|
395
|
+
*/
|
|
396
|
+
interface CompiledEventHandlerOptions {
|
|
397
|
+
threshold?: number;
|
|
398
|
+
rootMargin?: string;
|
|
399
|
+
once?: boolean;
|
|
400
|
+
}
|
|
348
401
|
interface CompiledEventHandler {
|
|
349
402
|
event: string;
|
|
350
403
|
action: string;
|
|
351
404
|
payload?: CompiledExpression | Record<string, CompiledExpression>;
|
|
405
|
+
debounce?: number;
|
|
406
|
+
throttle?: number;
|
|
407
|
+
options?: CompiledEventHandlerOptions;
|
|
352
408
|
}
|
|
353
409
|
/**
|
|
354
410
|
* Transforms the validated and analyzed AST into a CompiledProgram
|
|
@@ -478,4 +534,4 @@ declare function transformLayoutPass(layout: LayoutProgram, _context: LayoutAnal
|
|
|
478
534
|
*/
|
|
479
535
|
declare function composeLayoutWithPage(layout: CompiledProgram, page: CompiledProgram, layoutParams?: Record<string, Expression>, slots?: Record<string, ViewNode>): CompiledProgram;
|
|
480
536
|
|
|
481
|
-
export { type AnalysisContext, type AnalyzePassFailure, type AnalyzePassResult, type AnalyzePassSuccess, type CompileFailure, type CompileResult, type CompileSuccess, type CompiledAction, type CompiledActionStep, type CompiledBinExpr, type CompiledCallStep, type CompiledClipboardStep, type CompiledCloseStep, type CompiledCodeNode, type CompiledConcatExpr, type CompiledCondExpr, type CompiledDataExpr, type CompiledDisposeStep, type CompiledDomStep, type CompiledEachNode, type CompiledElementNode, type CompiledEventHandler, type CompiledExpression, type CompiledFetchStep, type CompiledGetExpr, type CompiledIfNode, type CompiledIfStep, type CompiledImportExpr, type CompiledImportStep, type CompiledIndexExpr, type CompiledLayoutProgram, type CompiledLifecycleHooks, type CompiledLitExpr, type CompiledLocalAction, type CompiledLocalStateNode, type CompiledMarkdownNode, type CompiledNavigateStep, type CompiledNode, type CompiledNotExpr, type CompiledParamExpr, type CompiledProgram, type CompiledRefExpr, type CompiledRouteDefinition, type CompiledRouteExpr, type CompiledSendStep, type CompiledSetPathStep, type CompiledSetStep, type CompiledSlotNode, type CompiledStateExpr, type CompiledStorageStep, type CompiledStyleExpr, type CompiledSubscribeStep, type CompiledTextNode, type CompiledUpdateStep, type CompiledVarExpr, type LayoutAnalysisContext, type LayoutAnalysisFailure, type LayoutAnalysisResult, type LayoutAnalysisSuccess, type ValidatePassFailure, type ValidatePassResult, type ValidatePassSuccess, analyzeLayoutPass, analyzePass, compile, composeLayoutWithPage, transformLayoutPass, transformPass, validatePass };
|
|
537
|
+
export { type AnalysisContext, type AnalyzePassFailure, type AnalyzePassResult, type AnalyzePassSuccess, type CompileFailure, type CompileResult, type CompileSuccess, type CompiledAction, type CompiledActionStep, type CompiledBinExpr, type CompiledCallStep, type CompiledClearTimerStep, type CompiledClipboardStep, type CompiledCloseStep, type CompiledCodeNode, type CompiledConcatExpr, type CompiledCondExpr, type CompiledDataExpr, type CompiledDelayStep, type CompiledDisposeStep, type CompiledDomStep, type CompiledEachNode, type CompiledElementNode, type CompiledEventHandler, type CompiledEventHandlerOptions, type CompiledExpression, type CompiledFetchStep, type CompiledFocusStep, type CompiledGetExpr, type CompiledIfNode, type CompiledIfStep, type CompiledImportExpr, type CompiledImportStep, type CompiledIndexExpr, type CompiledIntervalStep, type CompiledLayoutProgram, type CompiledLifecycleHooks, type CompiledLitExpr, type CompiledLocalAction, type CompiledLocalStateNode, type CompiledMarkdownNode, type CompiledNavigateStep, type CompiledNode, type CompiledNotExpr, type CompiledParamExpr, type CompiledPortalNode, type CompiledProgram, type CompiledRefExpr, type CompiledRouteDefinition, type CompiledRouteExpr, type CompiledSendStep, type CompiledSetPathStep, type CompiledSetStep, type CompiledSlotNode, type CompiledStateExpr, type CompiledStorageStep, type CompiledStyleExpr, type CompiledSubscribeStep, type CompiledTextNode, type CompiledUpdateStep, type CompiledValidityExpr, type CompiledVarExpr, type LayoutAnalysisContext, type LayoutAnalysisFailure, type LayoutAnalysisResult, type LayoutAnalysisSuccess, type ValidatePassFailure, type ValidatePassResult, type ValidatePassSuccess, analyzeLayoutPass, analyzePass, compile, composeLayoutWithPage, transformLayoutPass, transformPass, validatePass };
|
package/dist/index.js
CHANGED
|
@@ -1235,6 +1235,16 @@ function transformExpression(expr, ctx) {
|
|
|
1235
1235
|
expr: "concat",
|
|
1236
1236
|
items: expr.items.map((item) => transformExpression(item, ctx))
|
|
1237
1237
|
};
|
|
1238
|
+
case "validity": {
|
|
1239
|
+
const validityExpr = {
|
|
1240
|
+
expr: "validity",
|
|
1241
|
+
ref: expr.ref
|
|
1242
|
+
};
|
|
1243
|
+
if (expr.property) {
|
|
1244
|
+
validityExpr.property = expr.property;
|
|
1245
|
+
}
|
|
1246
|
+
return validityExpr;
|
|
1247
|
+
}
|
|
1238
1248
|
}
|
|
1239
1249
|
}
|
|
1240
1250
|
function transformEventHandler(handler, ctx) {
|
|
@@ -1245,6 +1255,24 @@ function transformEventHandler(handler, ctx) {
|
|
|
1245
1255
|
if (handler.payload) {
|
|
1246
1256
|
result.payload = transformExpression(handler.payload, ctx);
|
|
1247
1257
|
}
|
|
1258
|
+
if (handler.debounce !== void 0) {
|
|
1259
|
+
result.debounce = handler.debounce;
|
|
1260
|
+
}
|
|
1261
|
+
if (handler.throttle !== void 0) {
|
|
1262
|
+
result.throttle = handler.throttle;
|
|
1263
|
+
}
|
|
1264
|
+
if (handler.options) {
|
|
1265
|
+
result.options = {};
|
|
1266
|
+
if (handler.options.threshold !== void 0) {
|
|
1267
|
+
result.options.threshold = handler.options.threshold;
|
|
1268
|
+
}
|
|
1269
|
+
if (handler.options.rootMargin !== void 0) {
|
|
1270
|
+
result.options.rootMargin = handler.options.rootMargin;
|
|
1271
|
+
}
|
|
1272
|
+
if (handler.options.once !== void 0) {
|
|
1273
|
+
result.options.once = handler.options.once;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1248
1276
|
return result;
|
|
1249
1277
|
}
|
|
1250
1278
|
var emptyContext = { components: {} };
|
|
@@ -1436,6 +1464,52 @@ function transformActionStep(step) {
|
|
|
1436
1464
|
connection: closeStep.connection
|
|
1437
1465
|
};
|
|
1438
1466
|
}
|
|
1467
|
+
case "delay": {
|
|
1468
|
+
const delayStep = step;
|
|
1469
|
+
const compiledDelayStep = {
|
|
1470
|
+
do: "delay",
|
|
1471
|
+
ms: transformExpression(delayStep.ms, emptyContext),
|
|
1472
|
+
then: delayStep.then.map(transformActionStep)
|
|
1473
|
+
};
|
|
1474
|
+
if (delayStep.result) {
|
|
1475
|
+
compiledDelayStep.result = delayStep.result;
|
|
1476
|
+
}
|
|
1477
|
+
return compiledDelayStep;
|
|
1478
|
+
}
|
|
1479
|
+
case "interval": {
|
|
1480
|
+
const intervalStep = step;
|
|
1481
|
+
const compiledIntervalStep = {
|
|
1482
|
+
do: "interval",
|
|
1483
|
+
ms: transformExpression(intervalStep.ms, emptyContext),
|
|
1484
|
+
action: intervalStep.action
|
|
1485
|
+
};
|
|
1486
|
+
if (intervalStep.result) {
|
|
1487
|
+
compiledIntervalStep.result = intervalStep.result;
|
|
1488
|
+
}
|
|
1489
|
+
return compiledIntervalStep;
|
|
1490
|
+
}
|
|
1491
|
+
case "clearTimer": {
|
|
1492
|
+
const clearTimerStep = step;
|
|
1493
|
+
return {
|
|
1494
|
+
do: "clearTimer",
|
|
1495
|
+
target: transformExpression(clearTimerStep.target, emptyContext)
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
case "focus": {
|
|
1499
|
+
const focusStep = step;
|
|
1500
|
+
const compiledFocusStep = {
|
|
1501
|
+
do: "focus",
|
|
1502
|
+
target: transformExpression(focusStep.target, emptyContext),
|
|
1503
|
+
operation: focusStep.operation
|
|
1504
|
+
};
|
|
1505
|
+
if (focusStep.onSuccess) {
|
|
1506
|
+
compiledFocusStep.onSuccess = focusStep.onSuccess.map(transformActionStep);
|
|
1507
|
+
}
|
|
1508
|
+
if (focusStep.onError) {
|
|
1509
|
+
compiledFocusStep.onError = focusStep.onError.map(transformActionStep);
|
|
1510
|
+
}
|
|
1511
|
+
return compiledFocusStep;
|
|
1512
|
+
}
|
|
1439
1513
|
}
|
|
1440
1514
|
}
|
|
1441
1515
|
function flattenSlotChildren(children, ctx) {
|
|
@@ -1568,6 +1642,18 @@ function transformViewNode(node, ctx) {
|
|
|
1568
1642
|
}
|
|
1569
1643
|
return { kind: "text", value: { expr: "lit", value: "" } };
|
|
1570
1644
|
}
|
|
1645
|
+
case "portal": {
|
|
1646
|
+
const portalNode = node;
|
|
1647
|
+
const compiledChildren = [];
|
|
1648
|
+
for (const child of portalNode.children) {
|
|
1649
|
+
compiledChildren.push(transformViewNode(child, ctx));
|
|
1650
|
+
}
|
|
1651
|
+
return {
|
|
1652
|
+
kind: "portal",
|
|
1653
|
+
target: portalNode.target,
|
|
1654
|
+
children: compiledChildren
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1571
1657
|
}
|
|
1572
1658
|
}
|
|
1573
1659
|
function transformState(state) {
|
|
@@ -2254,6 +2340,14 @@ function transformViewNode2(node, ctx) {
|
|
|
2254
2340
|
language: node.language,
|
|
2255
2341
|
content: node.content
|
|
2256
2342
|
};
|
|
2343
|
+
case "portal":
|
|
2344
|
+
return {
|
|
2345
|
+
kind: "portal",
|
|
2346
|
+
target: node.target,
|
|
2347
|
+
children: (node.children ?? []).map(
|
|
2348
|
+
(child) => transformViewNode2(child, ctx)
|
|
2349
|
+
)
|
|
2350
|
+
};
|
|
2257
2351
|
}
|
|
2258
2352
|
}
|
|
2259
2353
|
function transformLayoutPass(layout, _context) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Compiler for Constela UI framework - AST to Program transformation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@constela/core": "0.
|
|
18
|
+
"@constela/core": "0.11.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.10.0",
|