@lokascript/compilation-service 2.2.0 → 2.3.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/{chunk-PVQF6QYP.js → chunk-BHZMWRBA.js} +2 -2
- package/dist/{chunk-ZQ3GX55O.js → chunk-BW34XOBT.js} +2 -2
- package/dist/{core-parser-adapter-VCJB52SO-7T2PARW4.js → core-parser-adapter-VCJB52SO-I5AIPWJQ.js} +2 -2
- package/dist/{dist-CYO3JGTJ.js → dist-5S22WYM3.js} +138 -75
- package/dist/{dist-CYO3JGTJ.js.map → dist-5S22WYM3.js.map} +1 -1
- package/dist/{dist-A6VWPCPB.js → dist-CXRMMXI7.js} +3 -3
- package/dist/http.cjs +137 -74
- package/dist/http.cjs.map +1 -1
- package/dist/http.js +1 -1
- package/dist/index.cjs +137 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-PVQF6QYP.js.map → chunk-BHZMWRBA.js.map} +0 -0
- /package/dist/{chunk-ZQ3GX55O.js.map → chunk-BW34XOBT.js.map} +0 -0
- /package/dist/{core-parser-adapter-VCJB52SO-7T2PARW4.js.map → core-parser-adapter-VCJB52SO-I5AIPWJQ.js.map} +0 -0
- /package/dist/{dist-A6VWPCPB.js.map → dist-CXRMMXI7.js.map} +0 -0
package/dist/http.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -170,7 +170,8 @@ function tokenize$1(input) {
|
|
|
170
170
|
const isCommandContext = prevToken && prevToken.kind === TokenKind.IDENTIFIER && COMMANDS.has(prevToken.value.toLowerCase());
|
|
171
171
|
const isKeywordContext = prevToken && prevToken.kind === TokenKind.IDENTIFIER && SELECTOR_CONTEXT_KEYWORDS.has(prevToken.value.toLowerCase());
|
|
172
172
|
const isCSSSelectorContext = !prevToken || prevToken.kind === TokenKind.OPERATOR && prevToken.value !== ")" && prevToken.value !== "]" || isCommandContext || isKeywordContext || prevToken.value === "(" || prevToken.value === "[" || prevToken.value === "{" || prevToken.value === "," || prevToken.value === ";";
|
|
173
|
-
|
|
173
|
+
const isAdjacentToPrev = prevToken && prevToken.end === tokenizer.position;
|
|
174
|
+
if (isCSSSelectorContext && !isAdjacentToPrev && (isAlpha(peek(tokenizer)) || peek(tokenizer) === "{")) {
|
|
174
175
|
tokenizeCSSSelector(tokenizer);
|
|
175
176
|
continue;
|
|
176
177
|
}
|
|
@@ -386,6 +387,17 @@ function tokenizeCSSSelector(tokenizer) {
|
|
|
386
387
|
const start = tokenizer.position;
|
|
387
388
|
const prefix2 = advance(tokenizer);
|
|
388
389
|
let value = prefix2;
|
|
390
|
+
if (tokenizer.position < tokenizer.input.length && tokenizer.input[tokenizer.position] === "{") {
|
|
391
|
+
value += advance(tokenizer);
|
|
392
|
+
while (tokenizer.position < tokenizer.input.length) {
|
|
393
|
+
const ch = tokenizer.input[tokenizer.position];
|
|
394
|
+
value += advance(tokenizer);
|
|
395
|
+
if (ch === "}")
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
addToken(tokenizer, TokenKind.SELECTOR, value, start);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
389
401
|
while (tokenizer.position < tokenizer.input.length) {
|
|
390
402
|
const char = tokenizer.input[tokenizer.position];
|
|
391
403
|
if (isAlphaNumeric(char) || char === "-" || char === "_" || char === ":") {
|
|
@@ -1262,31 +1274,14 @@ function parseTriggerCommand(ctx, identifierNode) {
|
|
|
1262
1274
|
});
|
|
1263
1275
|
}
|
|
1264
1276
|
}
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
const arg = allArgs[i];
|
|
1272
|
-
const argRecord = arg;
|
|
1273
|
-
const argValue = argRecord.name || argRecord.value;
|
|
1274
|
-
if ((arg.type === "identifier" || arg.type === "literal" || arg.type === "keyword") && (argValue === "on" || argValue === "to")) {
|
|
1275
|
-
operationIndex = i;
|
|
1276
|
-
operationKeyword = argValue;
|
|
1277
|
-
break;
|
|
1277
|
+
const finalArgs = [...allArgs];
|
|
1278
|
+
if (ctx.check("on") || ctx.check("to")) {
|
|
1279
|
+
const keyword = ctx.advance().value;
|
|
1280
|
+
finalArgs.push(ctx.createIdentifier(keyword));
|
|
1281
|
+
while (!isCommandBoundary(ctx)) {
|
|
1282
|
+
finalArgs.push(ctx.parsePrimary());
|
|
1278
1283
|
}
|
|
1279
1284
|
}
|
|
1280
|
-
const finalArgs = [];
|
|
1281
|
-
if (operationIndex === -1) {
|
|
1282
|
-
finalArgs.push(...allArgs);
|
|
1283
|
-
} else {
|
|
1284
|
-
const eventArgs = allArgs.slice(0, operationIndex);
|
|
1285
|
-
const targetArgs = allArgs.slice(operationIndex + 1);
|
|
1286
|
-
finalArgs.push(...eventArgs);
|
|
1287
|
-
finalArgs.push(ctx.createIdentifier(operationKeyword));
|
|
1288
|
-
finalArgs.push(...targetArgs);
|
|
1289
|
-
}
|
|
1290
1285
|
return CommandNodeBuilder.fromIdentifier(identifierNode).withArgs(...finalArgs).endingAt(ctx.getPosition()).build();
|
|
1291
1286
|
}
|
|
1292
1287
|
function parseHaltCommand(ctx, identifierNode) {
|
|
@@ -1914,8 +1909,9 @@ function parseSwapCommand(ctx, identifierNode) {
|
|
|
1914
1909
|
}
|
|
1915
1910
|
function parseWaitCommand(ctx, commandToken) {
|
|
1916
1911
|
const args = [];
|
|
1917
|
-
|
|
1918
|
-
|
|
1912
|
+
const isExpressionStart = ctx.checkTimeExpression() || ctx.checkLiteral() || ctx.checkContextVar() || ctx.check("(") || ctx.checkIdentifierLike() && !ctx.check("for") && !isCommandBoundary(ctx);
|
|
1913
|
+
if (isExpressionStart) {
|
|
1914
|
+
const timeExpr = ctx.parseExpression();
|
|
1919
1915
|
args.push(timeExpr);
|
|
1920
1916
|
return CommandNodeBuilder.from(commandToken).withArgs(...args).blocking().endingAt(ctx.getPosition()).build();
|
|
1921
1917
|
}
|
|
@@ -2083,43 +2079,24 @@ function parsePropertyOfTarget(ctx, startPosition) {
|
|
|
2083
2079
|
return null;
|
|
2084
2080
|
const thePosition = ctx.savePosition();
|
|
2085
2081
|
ctx.advance();
|
|
2086
|
-
const
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
const propertyToken = ctx.advance();
|
|
2090
|
-
if (ctx.check(KEYWORDS$1.OF)) {
|
|
2091
|
-
ctx.advance();
|
|
2092
|
-
const targetToken = ctx.advance();
|
|
2093
|
-
const isIdSelector2 = targetToken.value.startsWith("#");
|
|
2094
|
-
return {
|
|
2095
|
-
type: "propertyOfExpression",
|
|
2096
|
-
property: {
|
|
2097
|
-
type: "identifier",
|
|
2098
|
-
name: propertyToken.value,
|
|
2099
|
-
start: propertyToken.start,
|
|
2100
|
-
end: propertyToken.end
|
|
2101
|
-
},
|
|
2102
|
-
target: {
|
|
2103
|
-
type: isIdSelector2 ? "idSelector" : "cssSelector",
|
|
2104
|
-
value: targetToken.value,
|
|
2105
|
-
start: targetToken.start,
|
|
2106
|
-
end: targetToken.end
|
|
2107
|
-
},
|
|
2108
|
-
start: startPosition,
|
|
2109
|
-
end: ctx.savePosition()
|
|
2110
|
-
};
|
|
2111
|
-
}
|
|
2112
|
-
ctx.restorePosition(startPosition);
|
|
2082
|
+
const propertyExpr = ctx.parseExpression();
|
|
2083
|
+
if (!propertyExpr) {
|
|
2084
|
+
ctx.restorePosition(thePosition);
|
|
2113
2085
|
return null;
|
|
2114
2086
|
}
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
start:
|
|
2121
|
-
end:
|
|
2122
|
-
|
|
2087
|
+
const exprAny = propertyExpr;
|
|
2088
|
+
if (exprAny.type === "binaryExpression" && exprAny.operator === KEYWORDS$1.OF) {
|
|
2089
|
+
const property = exprAny.left;
|
|
2090
|
+
const target = exprAny.right;
|
|
2091
|
+
return createPropertyOfExpression(property, target, {
|
|
2092
|
+
start: property.start ?? 0,
|
|
2093
|
+
end: target.end ?? 0,
|
|
2094
|
+
line: property.line ?? 1,
|
|
2095
|
+
column: property.column ?? 1
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
if (ctx.check(KEYWORDS$1.TO)) {
|
|
2099
|
+
return propertyExpr;
|
|
2123
2100
|
}
|
|
2124
2101
|
ctx.restorePosition(thePosition);
|
|
2125
2102
|
return null;
|
|
@@ -2443,6 +2420,68 @@ function parseFetchNakedNamedArgs(ctx) {
|
|
|
2443
2420
|
column: startPos.column
|
|
2444
2421
|
};
|
|
2445
2422
|
}
|
|
2423
|
+
function findJsEndBoundary(ctx, startPos) {
|
|
2424
|
+
const input = ctx.getInputSlice(startPos);
|
|
2425
|
+
if (!input) {
|
|
2426
|
+
return startPos;
|
|
2427
|
+
}
|
|
2428
|
+
let i = 0;
|
|
2429
|
+
while (i < input.length) {
|
|
2430
|
+
const ch = input[i];
|
|
2431
|
+
if (ch === "'" || ch === "\u2019" || ch === "\u2018") {
|
|
2432
|
+
i++;
|
|
2433
|
+
while (i < input.length && input[i] !== ch) {
|
|
2434
|
+
if (input[i] === "\\")
|
|
2435
|
+
i++;
|
|
2436
|
+
i++;
|
|
2437
|
+
}
|
|
2438
|
+
i++;
|
|
2439
|
+
continue;
|
|
2440
|
+
}
|
|
2441
|
+
if (ch === '"') {
|
|
2442
|
+
i++;
|
|
2443
|
+
while (i < input.length && input[i] !== '"') {
|
|
2444
|
+
if (input[i] === "\\")
|
|
2445
|
+
i++;
|
|
2446
|
+
i++;
|
|
2447
|
+
}
|
|
2448
|
+
i++;
|
|
2449
|
+
continue;
|
|
2450
|
+
}
|
|
2451
|
+
if (ch === "`") {
|
|
2452
|
+
i++;
|
|
2453
|
+
while (i < input.length && input[i] !== "`") {
|
|
2454
|
+
if (input[i] === "\\")
|
|
2455
|
+
i++;
|
|
2456
|
+
i++;
|
|
2457
|
+
}
|
|
2458
|
+
i++;
|
|
2459
|
+
continue;
|
|
2460
|
+
}
|
|
2461
|
+
if (ch === "/" && i + 1 < input.length && input[i + 1] === "/") {
|
|
2462
|
+
i += 2;
|
|
2463
|
+
while (i < input.length && input[i] !== "\n")
|
|
2464
|
+
i++;
|
|
2465
|
+
continue;
|
|
2466
|
+
}
|
|
2467
|
+
if (ch === "/" && i + 1 < input.length && input[i + 1] === "*") {
|
|
2468
|
+
i += 2;
|
|
2469
|
+
while (i < input.length && !(input[i] === "*" && i + 1 < input.length && input[i + 1] === "/"))
|
|
2470
|
+
i++;
|
|
2471
|
+
i += 2;
|
|
2472
|
+
continue;
|
|
2473
|
+
}
|
|
2474
|
+
if ((ch === "e" || ch === "E") && i + 3 <= input.length && input.slice(i, i + 3).toLowerCase() === "end") {
|
|
2475
|
+
const before = i === 0 || !/[a-zA-Z0-9_]/.test(input[i - 1]);
|
|
2476
|
+
const after = i + 3 >= input.length || !/[a-zA-Z0-9_]/.test(input[i + 3]);
|
|
2477
|
+
if (before && after) {
|
|
2478
|
+
return startPos + i;
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
i++;
|
|
2482
|
+
}
|
|
2483
|
+
return startPos + input.length;
|
|
2484
|
+
}
|
|
2446
2485
|
function parseJsCommand(ctx, identifierNode) {
|
|
2447
2486
|
const parameters = [];
|
|
2448
2487
|
if (ctx.match("(")) {
|
|
@@ -2455,11 +2494,12 @@ function parseJsCommand(ctx, identifierNode) {
|
|
|
2455
2494
|
ctx.consume(")", "Expected ) after js parameters");
|
|
2456
2495
|
}
|
|
2457
2496
|
const jsCodeStart = ctx.peek().start;
|
|
2458
|
-
|
|
2497
|
+
const jsCodeEnd = findJsEndBoundary(ctx, jsCodeStart);
|
|
2498
|
+
while (!ctx.isAtEnd() && !ctx.check(KEYWORDS$1.END)) {
|
|
2499
|
+
if (ctx.peek().start >= jsCodeEnd)
|
|
2500
|
+
break;
|
|
2459
2501
|
ctx.advance();
|
|
2460
2502
|
}
|
|
2461
|
-
const endToken = ctx.peek();
|
|
2462
|
-
const jsCodeEnd = endToken.start;
|
|
2463
2503
|
ctx.consume(KEYWORDS$1.END, "Expected end after js code body");
|
|
2464
2504
|
const rawSlice = ctx.getInputSlice(jsCodeStart, jsCodeEnd);
|
|
2465
2505
|
const code = rawSlice.trim();
|
|
@@ -25442,7 +25482,7 @@ var init_dist = __esm({
|
|
|
25442
25482
|
}
|
|
25443
25483
|
} else {
|
|
25444
25484
|
const commandName = expr.name.toLowerCase();
|
|
25445
|
-
if (commandName === "wait" && this.checkTimeExpression()) {
|
|
25485
|
+
if (commandName === "wait" && (this.checkTimeExpression() || this.checkNumber() || this.checkIdentifier() || this.checkContextVar() || this.check("("))) {
|
|
25446
25486
|
const command2 = this.createCommandFromIdentifier(expr);
|
|
25447
25487
|
if (command2) {
|
|
25448
25488
|
expr = command2;
|
|
@@ -26552,9 +26592,7 @@ var init_dist = __esm({
|
|
|
26552
26592
|
while (!this.isAtEnd() && !this.check("end")) {
|
|
26553
26593
|
if (this.match("on")) {
|
|
26554
26594
|
const handlerPos = this.getPosition();
|
|
26555
|
-
const
|
|
26556
|
-
const eventName = eventToken.value;
|
|
26557
|
-
this.advance();
|
|
26595
|
+
const eventName = this.parseEventNameWithNamespace("Expected event name after 'on'");
|
|
26558
26596
|
const eventArgs = [];
|
|
26559
26597
|
if (this.check("(")) {
|
|
26560
26598
|
this.advance();
|
|
@@ -28397,6 +28435,8 @@ var init_dist = __esm({
|
|
|
28397
28435
|
return this.evaluateIdSelector(node, context);
|
|
28398
28436
|
case "attributeAccess":
|
|
28399
28437
|
return this.evaluateAttributeAccess(node, context);
|
|
28438
|
+
case "asExpression":
|
|
28439
|
+
return this.evaluateAsExpression(node, context);
|
|
28400
28440
|
default:
|
|
28401
28441
|
throw new Error(`Unsupported AST node type for evaluation: ${node.type}`);
|
|
28402
28442
|
}
|
|
@@ -28672,6 +28712,14 @@ var init_dist = __esm({
|
|
|
28672
28712
|
}
|
|
28673
28713
|
return `@${node.attributeName}`;
|
|
28674
28714
|
}
|
|
28715
|
+
async evaluateAsExpression(node, context) {
|
|
28716
|
+
const value = await this.evaluate(node.expression, context);
|
|
28717
|
+
const asExpr = this.expressionRegistry.get("as");
|
|
28718
|
+
if (asExpr) {
|
|
28719
|
+
return asExpr.evaluate(context, value, node.targetType);
|
|
28720
|
+
}
|
|
28721
|
+
throw new Error(`Conversion type 'as' not registered`);
|
|
28722
|
+
}
|
|
28675
28723
|
getAvailableExpressions() {
|
|
28676
28724
|
return Array.from(this.expressionRegistry.keys());
|
|
28677
28725
|
}
|
|
@@ -33171,6 +33219,8 @@ var init_dist = __esm({
|
|
|
33171
33219
|
this.behaviorAPI = {
|
|
33172
33220
|
has: (name) => this.behaviorRegistry.has(name),
|
|
33173
33221
|
get: (name) => this.behaviorRegistry.get(name),
|
|
33222
|
+
set: (name, definition) => this.behaviorRegistry.set(name, definition),
|
|
33223
|
+
resolve: null,
|
|
33174
33224
|
install: async (behaviorName, element, parameters) => {
|
|
33175
33225
|
return await this.installBehaviorOnElement(behaviorName, element, parameters);
|
|
33176
33226
|
}
|
|
@@ -33634,9 +33684,14 @@ var init_dist = __esm({
|
|
|
33634
33684
|
}
|
|
33635
33685
|
async installBehaviorOnElement(behaviorName, element, parameters) {
|
|
33636
33686
|
debug.runtime(`BEHAVIOR: installBehaviorOnElement called: ${behaviorName}`);
|
|
33637
|
-
|
|
33638
|
-
if (!behavior)
|
|
33639
|
-
|
|
33687
|
+
let behavior = this.behaviorRegistry.get(behaviorName);
|
|
33688
|
+
if (!behavior) {
|
|
33689
|
+
if (this.behaviorAPI.resolve && this.behaviorAPI.resolve(behaviorName)) {
|
|
33690
|
+
behavior = this.behaviorRegistry.get(behaviorName);
|
|
33691
|
+
}
|
|
33692
|
+
if (!behavior)
|
|
33693
|
+
throw new Error(`Behavior "${behaviorName}" not found`);
|
|
33694
|
+
}
|
|
33640
33695
|
if (behavior.type === "imperative" && typeof behavior.install === "function") {
|
|
33641
33696
|
debug.runtime(`BEHAVIOR: Installing imperative behavior '${behaviorName}'`);
|
|
33642
33697
|
behavior.install(element, parameters);
|
|
@@ -36484,7 +36539,9 @@ var init_dist = __esm({
|
|
|
36484
36539
|
return { type: "property", element: firstValue[0], property: "textContent", value: value2 };
|
|
36485
36540
|
}
|
|
36486
36541
|
if (typeof firstValue !== "string") {
|
|
36487
|
-
|
|
36542
|
+
const isMember = firstArg?.type === "memberExpression" || firstArg?.type === "propertyAccess";
|
|
36543
|
+
const hint = isMember ? ` (a property chain evaluated to ${firstValue === null ? "null" : typeof firstValue} \u2014 check that all intermediate objects exist)` : "";
|
|
36544
|
+
throw new Error(`set command target must be a string or object literal${hint}`);
|
|
36488
36545
|
}
|
|
36489
36546
|
const value = await this.extractValue(raw, evaluator, context);
|
|
36490
36547
|
return { type: "variable", name: firstValue, value };
|
|
@@ -39249,12 +39306,18 @@ var init_dist = __esm({
|
|
|
39249
39306
|
const behaviorRegistry = context.locals.get("_behaviors");
|
|
39250
39307
|
if (behaviorRegistry && typeof behaviorRegistry === "object") {
|
|
39251
39308
|
const registry = behaviorRegistry;
|
|
39252
|
-
|
|
39309
|
+
if (registry.has(behaviorName))
|
|
39310
|
+
return true;
|
|
39311
|
+
if (registry.resolve && registry.resolve(behaviorName))
|
|
39312
|
+
return true;
|
|
39253
39313
|
}
|
|
39254
39314
|
if (typeof globalThis !== "undefined") {
|
|
39255
39315
|
const hyperscriptGlobal = globalThis._hyperscript;
|
|
39256
39316
|
if (hyperscriptGlobal?.behaviors) {
|
|
39257
|
-
|
|
39317
|
+
if (hyperscriptGlobal.behaviors.has(behaviorName))
|
|
39318
|
+
return true;
|
|
39319
|
+
if (hyperscriptGlobal.behaviors.resolve && hyperscriptGlobal.behaviors.resolve(behaviorName))
|
|
39320
|
+
return true;
|
|
39258
39321
|
}
|
|
39259
39322
|
}
|
|
39260
39323
|
return false;
|