rip-lang 3.13.124 → 3.13.126
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 +1 -1
- package/docs/dist/rip.js +69 -18
- package/docs/dist/rip.min.js +125 -124
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/compiler.js +9 -4
- package/src/components.js +26 -9
- package/src/lexer.js +31 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.
|
|
12
|
+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.126-blue.svg" alt="Version"></a>
|
|
13
13
|
<a href="#zero-dependencies"><img src="https://img.shields.io/badge/dependencies-ZERO-brightgreen.svg" alt="Dependencies"></a>
|
|
14
14
|
<a href="#"><img src="https://img.shields.io/badge/tests-1%2C436%2F1%2C436-brightgreen.svg" alt="Tests"></a>
|
|
15
15
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
|
package/docs/dist/rip.js
CHANGED
|
@@ -2565,7 +2565,10 @@
|
|
|
2565
2565
|
if (tag === "THEN")
|
|
2566
2566
|
indent.fromThen = true;
|
|
2567
2567
|
tokens.splice(i + 1, 0, indent);
|
|
2568
|
-
this.
|
|
2568
|
+
if (tag === "THEN" && this.singleLineOwner(i) === "LEADING_WHEN")
|
|
2569
|
+
this.detectWhenThenEnd(i + 2, condition, action);
|
|
2570
|
+
else
|
|
2571
|
+
this.detectEnd(i + 2, condition, action);
|
|
2569
2572
|
if (tag === "THEN")
|
|
2570
2573
|
tokens.splice(i, 1);
|
|
2571
2574
|
return 1;
|
|
@@ -2573,6 +2576,41 @@
|
|
|
2573
2576
|
return 1;
|
|
2574
2577
|
});
|
|
2575
2578
|
}
|
|
2579
|
+
singleLineOwner(i) {
|
|
2580
|
+
let starters = new Set(["LEADING_WHEN", "IF", "POST_IF", "UNLESS", "POST_UNLESS", "ELSE", "CATCH", "TRY", "FINALLY", "->", "=>"]);
|
|
2581
|
+
for (let j = i - 1;j >= 0; j--) {
|
|
2582
|
+
let token = this.tokens[j];
|
|
2583
|
+
let tag = token?.[0];
|
|
2584
|
+
if (starters.has(tag))
|
|
2585
|
+
return tag;
|
|
2586
|
+
if (LINE_BREAK.has(tag) || token?.newLine)
|
|
2587
|
+
return null;
|
|
2588
|
+
}
|
|
2589
|
+
return null;
|
|
2590
|
+
}
|
|
2591
|
+
detectWhenThenEnd(i, condition, action) {
|
|
2592
|
+
let levels = 0;
|
|
2593
|
+
let nestedInlineBranches = 0;
|
|
2594
|
+
while (i < this.tokens.length) {
|
|
2595
|
+
let token = this.tokens[i];
|
|
2596
|
+
let tag = token[0];
|
|
2597
|
+
if (levels === 0) {
|
|
2598
|
+
if (tag === "THEN" && this.singleLineOwner(i) !== "LEADING_WHEN")
|
|
2599
|
+
nestedInlineBranches++;
|
|
2600
|
+
else if (tag === "ELSE" && nestedInlineBranches > 0)
|
|
2601
|
+
nestedInlineBranches--;
|
|
2602
|
+
else if (condition.call(this, token, i))
|
|
2603
|
+
return action.call(this, token, i);
|
|
2604
|
+
}
|
|
2605
|
+
if (EXPRESSION_START.has(tag))
|
|
2606
|
+
levels++;
|
|
2607
|
+
if (EXPRESSION_END.has(tag))
|
|
2608
|
+
levels--;
|
|
2609
|
+
if (levels < 0)
|
|
2610
|
+
return action.call(this, token, i);
|
|
2611
|
+
i++;
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2576
2614
|
tagPostfixConditionals() {
|
|
2577
2615
|
let original = null;
|
|
2578
2616
|
let condition = (token, i) => {
|
|
@@ -4210,16 +4248,11 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4210
4248
|
if (tag === "=" && i > 0) {
|
|
4211
4249
|
let prev = tokens[i - 1][0];
|
|
4212
4250
|
if (prev === "TERMINATOR" || prev === "INDENT" || prev === "RENDER") {
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
tokens[i][1] = val;
|
|
4219
|
-
}
|
|
4220
|
-
val.text = true;
|
|
4221
|
-
}
|
|
4222
|
-
return 0;
|
|
4251
|
+
const textToken = gen2("IDENTIFIER", "__text__", token);
|
|
4252
|
+
const callStart = gen2("CALL_START", "(", token);
|
|
4253
|
+
tokens.splice(i, 1, textToken, callStart);
|
|
4254
|
+
this.detectEnd(i + 2, (t) => t[0] === "TERMINATOR" || t[0] === "OUTDENT", (t, j) => tokens.splice(j, 0, gen2("CALL_END", ")", t)), { returnOnNegativeLevel: true });
|
|
4255
|
+
return 2;
|
|
4223
4256
|
}
|
|
4224
4257
|
}
|
|
4225
4258
|
if (tag === "UNARY_MATH" && token[1] === "~" && nextToken && nextToken[0] === "IDENTIFIER") {
|
|
@@ -4354,7 +4387,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4354
4387
|
}
|
|
4355
4388
|
let isTemplateElement = false;
|
|
4356
4389
|
let prevTag = i > 0 ? tokens[i - 1][0] : null;
|
|
4357
|
-
let isAfterControlFlow = prevTag === "IF" || prevTag === "UNLESS" || prevTag === "WHILE" || prevTag === "UNTIL" || prevTag === "WHEN";
|
|
4390
|
+
let isAfterControlFlow = prevTag === "IF" || prevTag === "UNLESS" || prevTag === "WHILE" || prevTag === "UNTIL" || prevTag === "WHEN" || prevTag === "FORIN" || prevTag === "FOROF" || prevTag === "FORAS" || prevTag === "FORASAWAIT" || prevTag === "BY";
|
|
4358
4391
|
let isClsxCallEnd = false;
|
|
4359
4392
|
if (tag === "CALL_END") {
|
|
4360
4393
|
let depth = 1;
|
|
@@ -5360,6 +5393,18 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
5360
5393
|
if (headStr === "for" || headStr === "for-in" || headStr === "for-of" || headStr === "for-as") {
|
|
5361
5394
|
return this.generateTemplateLoop(sexpr);
|
|
5362
5395
|
}
|
|
5396
|
+
if (headStr === "__text__") {
|
|
5397
|
+
const expr = rest[0] ?? "undefined";
|
|
5398
|
+
const textVar2 = this.newTextVar();
|
|
5399
|
+
const exprCode2 = this.generateInComponent(expr, "value");
|
|
5400
|
+
if (this.hasReactiveDeps(expr)) {
|
|
5401
|
+
this._createLines.push(`${textVar2} = document.createTextNode('');`);
|
|
5402
|
+
this._pushEffect(`${textVar2}.data = String(${exprCode2});`);
|
|
5403
|
+
} else {
|
|
5404
|
+
this._createLines.push(`${textVar2} = document.createTextNode(String(${exprCode2}));`);
|
|
5405
|
+
}
|
|
5406
|
+
return textVar2;
|
|
5407
|
+
}
|
|
5363
5408
|
const textVar = this.newTextVar();
|
|
5364
5409
|
const exprCode = this.generateInComponent(sexpr, "value");
|
|
5365
5410
|
if (this.hasReactiveDeps(sexpr)) {
|
|
@@ -9114,13 +9159,13 @@ ${this.indent()}}`;
|
|
|
9114
9159
|
generateSwitchCaseBody(body, context) {
|
|
9115
9160
|
let code = "";
|
|
9116
9161
|
let hasFlow = this.hasExplicitControlFlow(body);
|
|
9162
|
+
let stmts = this.unwrapBlock(body);
|
|
9117
9163
|
if (hasFlow) {
|
|
9118
|
-
for (let s of
|
|
9164
|
+
for (let s of stmts)
|
|
9119
9165
|
code += this.indent() + this.generate(s, "statement") + `;
|
|
9120
9166
|
`;
|
|
9121
9167
|
} else if (context === "value") {
|
|
9122
9168
|
if (this.is(body, "block") && body.length > 2) {
|
|
9123
|
-
let stmts = body.slice(1);
|
|
9124
9169
|
for (let i = 0;i < stmts.length; i++) {
|
|
9125
9170
|
if (i === stmts.length - 1)
|
|
9126
9171
|
code += this.indent() + `return ${this.generate(stmts[i], "value")};
|
|
@@ -9134,8 +9179,14 @@ ${this.indent()}}`;
|
|
|
9134
9179
|
`;
|
|
9135
9180
|
}
|
|
9136
9181
|
} else {
|
|
9137
|
-
if (this.is(
|
|
9138
|
-
|
|
9182
|
+
if (stmts.length === 1 && this.is(stmts[0], "if") && !this.hasStatementInBranch(stmts[0]) && !this.hasNestedMultiStatement(stmts[0])) {
|
|
9183
|
+
let [_, condition, thenBranch, ...elseBranches] = stmts[0];
|
|
9184
|
+
let thenExpr = this.extractExpression(this.unwrapIfBranch(thenBranch));
|
|
9185
|
+
let elseExpr = this.buildTernaryChain(elseBranches);
|
|
9186
|
+
code += this.indent() + `(${this.unwrap(this.generate(condition, "value"))} ? ${thenExpr} : ${elseExpr});
|
|
9187
|
+
`;
|
|
9188
|
+
} else if (this.is(body, "block") && body.length > 1) {
|
|
9189
|
+
for (let s of stmts)
|
|
9139
9190
|
code += this.indent() + this.generate(s, "statement") + `;
|
|
9140
9191
|
`;
|
|
9141
9192
|
} else {
|
|
@@ -9950,8 +10001,8 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
|
9950
10001
|
return new CodeGenerator({}).getComponentRuntime();
|
|
9951
10002
|
}
|
|
9952
10003
|
// src/browser.js
|
|
9953
|
-
var VERSION = "3.13.
|
|
9954
|
-
var BUILD_DATE = "2026-03-
|
|
10004
|
+
var VERSION = "3.13.126";
|
|
10005
|
+
var BUILD_DATE = "2026-03-21@06:00:44GMT";
|
|
9955
10006
|
if (typeof globalThis !== "undefined") {
|
|
9956
10007
|
if (!globalThis.__rip)
|
|
9957
10008
|
new Function(getReactiveRuntime())();
|