rip-lang 3.13.125 → 3.13.127
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 +55 -44
- package/docs/dist/rip.min.js +61 -60
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/compiler.js +18 -13
- package/src/components.js +37 -20
- package/src/grammar/grammar.rip +5 -5
- package/src/grammar/lunar.rip +6 -6
- package/src/parser.js +5 -7
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.127-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
|
@@ -3159,10 +3159,12 @@
|
|
|
3159
3159
|
case 68:
|
|
3160
3160
|
return ["regex-index", $[$0], null];
|
|
3161
3161
|
case 69:
|
|
3162
|
+
case 120:
|
|
3162
3163
|
return ["=", $[$0 - 2], $[$0]];
|
|
3163
3164
|
case 70:
|
|
3164
3165
|
return ["=", $[$0 - 3], $[$0]];
|
|
3165
3166
|
case 71:
|
|
3167
|
+
case 121:
|
|
3166
3168
|
return ["=", $[$0 - 4], $[$0 - 1]];
|
|
3167
3169
|
case 72:
|
|
3168
3170
|
return ["=", $[$0], $[$0 - 2]];
|
|
@@ -3244,15 +3246,11 @@
|
|
|
3244
3246
|
case 367:
|
|
3245
3247
|
return [...$[$0 - 5], ...$[$0 - 2]];
|
|
3246
3248
|
case 116:
|
|
3247
|
-
return [$[$0], $[$0]
|
|
3249
|
+
return [null, $[$0], $[$0]];
|
|
3248
3250
|
case 118:
|
|
3249
|
-
return [$[$0 - 2], $[$0]
|
|
3251
|
+
return [":", $[$0 - 2], $[$0]];
|
|
3250
3252
|
case 119:
|
|
3251
|
-
return [$[$0 - 4], $[$0 - 1]
|
|
3252
|
-
case 120:
|
|
3253
|
-
return [$[$0 - 2], $[$0], "="];
|
|
3254
|
-
case 121:
|
|
3255
|
-
return [$[$0 - 4], $[$0 - 1], "="];
|
|
3253
|
+
return [":", $[$0 - 4], $[$0 - 1]];
|
|
3256
3254
|
case 126:
|
|
3257
3255
|
return ["dynamicKey", $[$0 - 1]];
|
|
3258
3256
|
case 127:
|
|
@@ -4098,8 +4096,8 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4098
4096
|
for (const pair of pairs) {
|
|
4099
4097
|
if (!Array.isArray(pair))
|
|
4100
4098
|
continue;
|
|
4101
|
-
const key = pair[
|
|
4102
|
-
const val = pair[
|
|
4099
|
+
const key = pair[1] instanceof String ? pair[1].valueOf() : pair[1];
|
|
4100
|
+
const val = pair[2] instanceof String ? pair[2].valueOf() : pair[2];
|
|
4103
4101
|
if (key === "type" && typeof val === "string") {
|
|
4104
4102
|
return val.replace(/^["']|["']$/g, "");
|
|
4105
4103
|
}
|
|
@@ -4248,16 +4246,11 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4248
4246
|
if (tag === "=" && i > 0) {
|
|
4249
4247
|
let prev = tokens[i - 1][0];
|
|
4250
4248
|
if (prev === "TERMINATOR" || prev === "INDENT" || prev === "RENDER") {
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
tokens[i][1] = val;
|
|
4257
|
-
}
|
|
4258
|
-
val.text = true;
|
|
4259
|
-
}
|
|
4260
|
-
return 0;
|
|
4249
|
+
const textToken = gen2("IDENTIFIER", "__text__", token);
|
|
4250
|
+
const callStart = gen2("CALL_START", "(", token);
|
|
4251
|
+
tokens.splice(i, 1, textToken, callStart);
|
|
4252
|
+
this.detectEnd(i + 2, (t) => t[0] === "TERMINATOR" || t[0] === "OUTDENT", (t, j) => tokens.splice(j, 0, gen2("CALL_END", ")", t)), { returnOnNegativeLevel: true });
|
|
4253
|
+
return 2;
|
|
4261
4254
|
}
|
|
4262
4255
|
}
|
|
4263
4256
|
if (tag === "UNARY_MATH" && token[1] === "~" && nextToken && nextToken[0] === "IDENTIFIER") {
|
|
@@ -4392,7 +4385,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4392
4385
|
}
|
|
4393
4386
|
let isTemplateElement = false;
|
|
4394
4387
|
let prevTag = i > 0 ? tokens[i - 1][0] : null;
|
|
4395
|
-
let isAfterControlFlow = prevTag === "IF" || prevTag === "UNLESS" || prevTag === "WHILE" || prevTag === "UNTIL" || prevTag === "WHEN";
|
|
4388
|
+
let isAfterControlFlow = prevTag === "IF" || prevTag === "UNLESS" || prevTag === "WHILE" || prevTag === "UNTIL" || prevTag === "WHEN" || prevTag === "FORIN" || prevTag === "FOROF" || prevTag === "FORAS" || prevTag === "FORASAWAIT" || prevTag === "BY";
|
|
4396
4389
|
let isClsxCallEnd = false;
|
|
4397
4390
|
if (tag === "CALL_END") {
|
|
4398
4391
|
let depth = 1;
|
|
@@ -4533,10 +4526,10 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4533
4526
|
if (sexpr[0] === "object") {
|
|
4534
4527
|
return ["object", ...sexpr.slice(1).map((pair) => {
|
|
4535
4528
|
if (Array.isArray(pair) && pair.length >= 2) {
|
|
4536
|
-
let key = pair[
|
|
4529
|
+
let key = pair[1];
|
|
4537
4530
|
let newKey = Array.isArray(key) ? this.transformComponentMembers(key, localScope) : key;
|
|
4538
|
-
let newValue = this.transformComponentMembers(pair[
|
|
4539
|
-
return [newKey, newValue
|
|
4531
|
+
let newValue = this.transformComponentMembers(pair[2], localScope);
|
|
4532
|
+
return [pair[0], newKey, newValue];
|
|
4540
4533
|
}
|
|
4541
4534
|
return this.transformComponentMembers(pair, localScope);
|
|
4542
4535
|
})];
|
|
@@ -4647,7 +4640,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4647
4640
|
const pair = stmt[i];
|
|
4648
4641
|
if (!Array.isArray(pair))
|
|
4649
4642
|
continue;
|
|
4650
|
-
const [methodName, funcDef] = pair;
|
|
4643
|
+
const [, methodName, funcDef] = pair;
|
|
4651
4644
|
if (typeof methodName === "string" && LIFECYCLE_HOOKS.has(methodName)) {
|
|
4652
4645
|
lifecycleHooks.push({ name: methodName, value: funcDef });
|
|
4653
4646
|
} else if (typeof methodName === "string") {
|
|
@@ -4796,7 +4789,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4796
4789
|
const pair = obj[j];
|
|
4797
4790
|
if (!Array.isArray(pair) || pair.length < 2)
|
|
4798
4791
|
continue;
|
|
4799
|
-
const [key, value] = pair;
|
|
4792
|
+
const [, key, value] = pair;
|
|
4800
4793
|
if (Array.isArray(key) && key[0] === "." && key[1] === "this" && Array.isArray(value) && value[0] === "." && value[1] === "this") {
|
|
4801
4794
|
const eventName = typeof key[2] === "string" ? key[2] : key[2]?.valueOf?.();
|
|
4802
4795
|
const methodName = typeof value[2] === "string" ? value[2] : value[2]?.valueOf?.();
|
|
@@ -4863,7 +4856,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4863
4856
|
if (obj) {
|
|
4864
4857
|
for (let j = 1;j < obj.length; j++) {
|
|
4865
4858
|
const pair = obj[j];
|
|
4866
|
-
const [key, value] = pair;
|
|
4859
|
+
const [, key, value] = pair;
|
|
4867
4860
|
if (typeof key === "string" && !key.startsWith("@")) {
|
|
4868
4861
|
const srcLine = pair.loc?.r ?? obj.loc?.r;
|
|
4869
4862
|
if (key.startsWith("__bind_") && key.endsWith("__")) {
|
|
@@ -4898,7 +4891,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4898
4891
|
const pair = obj[j];
|
|
4899
4892
|
if (!Array.isArray(pair) || pair.length < 2)
|
|
4900
4893
|
continue;
|
|
4901
|
-
const [key, value] = pair;
|
|
4894
|
+
const [, key, value] = pair;
|
|
4902
4895
|
const srcLine = pair.loc?.r ?? obj.loc?.r;
|
|
4903
4896
|
if (Array.isArray(key) && key[0] === "." && key[1] === "this") {
|
|
4904
4897
|
let memberName = typeof key[2] === "string" ? key[2] : key[2]?.valueOf?.();
|
|
@@ -5398,6 +5391,18 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
5398
5391
|
if (headStr === "for" || headStr === "for-in" || headStr === "for-of" || headStr === "for-as") {
|
|
5399
5392
|
return this.generateTemplateLoop(sexpr);
|
|
5400
5393
|
}
|
|
5394
|
+
if (headStr === "__text__") {
|
|
5395
|
+
const expr = rest[0] ?? "undefined";
|
|
5396
|
+
const textVar2 = this.newTextVar();
|
|
5397
|
+
const exprCode2 = this.generateInComponent(expr, "value");
|
|
5398
|
+
if (this.hasReactiveDeps(expr)) {
|
|
5399
|
+
this._createLines.push(`${textVar2} = document.createTextNode('');`);
|
|
5400
|
+
this._pushEffect(`${textVar2}.data = String(${exprCode2});`);
|
|
5401
|
+
} else {
|
|
5402
|
+
this._createLines.push(`${textVar2} = document.createTextNode(String(${exprCode2}));`);
|
|
5403
|
+
}
|
|
5404
|
+
return textVar2;
|
|
5405
|
+
}
|
|
5401
5406
|
const textVar = this.newTextVar();
|
|
5402
5407
|
const exprCode = this.generateInComponent(sexpr, "value");
|
|
5403
5408
|
if (this.hasReactiveDeps(sexpr)) {
|
|
@@ -5567,7 +5572,7 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
5567
5572
|
proto.generateAttributes = function(elVar, objExpr) {
|
|
5568
5573
|
const inputType = extractInputType(objExpr.slice(1));
|
|
5569
5574
|
for (let i = 1;i < objExpr.length; i++) {
|
|
5570
|
-
let [key, value] = objExpr[i];
|
|
5575
|
+
let [, key, value] = objExpr[i];
|
|
5571
5576
|
if (this.is(key, ".") && key[1] === "this") {
|
|
5572
5577
|
const eventName = key[2];
|
|
5573
5578
|
if (this._autoWireExplicit && this._autoWireEl === elVar) {
|
|
@@ -5944,7 +5949,7 @@ ${blockFactoriesCode}return ${lines.join(`
|
|
|
5944
5949
|
};
|
|
5945
5950
|
const addObjectProps = (objExpr) => {
|
|
5946
5951
|
for (let i = 1;i < objExpr.length; i++) {
|
|
5947
|
-
const [key, value] = objExpr[i];
|
|
5952
|
+
const [, key, value] = objExpr[i];
|
|
5948
5953
|
if (typeof key === "string") {
|
|
5949
5954
|
addProp(key, value);
|
|
5950
5955
|
} else if (Array.isArray(key) && key[0] === "." && key[1] === "this" && typeof key[2] === "string") {
|
|
@@ -7101,7 +7106,7 @@ if (typeof globalThis !== 'undefined') {
|
|
|
7101
7106
|
let stmtEntries = body.map((stmt, index) => {
|
|
7102
7107
|
let isSingle = body.length === 1 && imports.length === 0;
|
|
7103
7108
|
let isObj = this.is(stmt, "object");
|
|
7104
|
-
let isObjComp = isObj && stmt.length === 2 && Array.isArray(stmt[1]) && Array.isArray(stmt[1][
|
|
7109
|
+
let isObjComp = isObj && stmt.length === 2 && Array.isArray(stmt[1]) && Array.isArray(stmt[1][2]) && stmt[1][2][0] === "comprehension";
|
|
7105
7110
|
let isAlreadyExpr = this.is(stmt, "comprehension") || this.is(stmt, "object-comprehension") || this.is(stmt, "do-iife");
|
|
7106
7111
|
let hasNoVars = this.programVars.size === 0;
|
|
7107
7112
|
let needsParens = isSingle && isObj && hasNoVars && !isAlreadyExpr && !isObjComp;
|
|
@@ -8022,15 +8027,15 @@ ${this.indent()}}`;
|
|
|
8022
8027
|
return hasTrailingElision ? `[${codes},]` : `[${codes}]`;
|
|
8023
8028
|
}
|
|
8024
8029
|
generateObject(head, pairs, context) {
|
|
8025
|
-
if (pairs.length === 1 && Array.isArray(pairs[0]) && Array.isArray(pairs[0][
|
|
8026
|
-
let [keyVar, compNode] = pairs[0];
|
|
8030
|
+
if (pairs.length === 1 && Array.isArray(pairs[0]) && Array.isArray(pairs[0][2]) && pairs[0][2][0] === "comprehension") {
|
|
8031
|
+
let [, keyVar, compNode] = pairs[0];
|
|
8027
8032
|
let [, valueExpr, iterators, guards] = compNode;
|
|
8028
8033
|
return this.generate(["object-comprehension", keyVar, valueExpr, iterators, guards], context);
|
|
8029
8034
|
}
|
|
8030
8035
|
let codes = pairs.map((pair) => {
|
|
8031
8036
|
if (this.is(pair, "..."))
|
|
8032
8037
|
return `...${this.generate(pair[1], "value")}`;
|
|
8033
|
-
let [key, value
|
|
8038
|
+
let [operator, key, value] = pair;
|
|
8034
8039
|
let keyCode;
|
|
8035
8040
|
if (this.is(key, "dynamicKey"))
|
|
8036
8041
|
keyCode = `[${this.generate(key[1], "value")}]`;
|
|
@@ -8401,14 +8406,14 @@ ${this.indent()}}`;
|
|
|
8401
8406
|
let members = bodyStmts[0].slice(1);
|
|
8402
8407
|
this.indentLevel++;
|
|
8403
8408
|
let boundMethods = [];
|
|
8404
|
-
for (let [mk, mv] of members) {
|
|
8409
|
+
for (let [, mk, mv] of members) {
|
|
8405
8410
|
let isStatic = this.is(mk, ".") && mk[1] === "this";
|
|
8406
8411
|
let isComputed = this.is(mk, "computed");
|
|
8407
8412
|
let mName = this.extractMemberName(mk);
|
|
8408
8413
|
if (this.is(mv, "=>") && !isStatic && !isComputed && mName !== "constructor")
|
|
8409
8414
|
boundMethods.push(mName);
|
|
8410
8415
|
}
|
|
8411
|
-
for (let [mk, mv] of members) {
|
|
8416
|
+
for (let [, mk, mv] of members) {
|
|
8412
8417
|
let isStatic = this.is(mk, ".") && mk[1] === "this";
|
|
8413
8418
|
let isComputed = this.is(mk, "computed");
|
|
8414
8419
|
let mName = this.extractMemberName(mk);
|
|
@@ -8466,7 +8471,7 @@ ${this.indent()}}`;
|
|
|
8466
8471
|
let members = bodyStmts[0].slice(1);
|
|
8467
8472
|
let additionalStmts = bodyStmts.slice(1);
|
|
8468
8473
|
this.indentLevel++;
|
|
8469
|
-
for (let [mk, mv] of members) {
|
|
8474
|
+
for (let [, mk, mv] of members) {
|
|
8470
8475
|
let isStatic = this.is(mk, ".") && mk[1] === "this", mName = this.extractMemberName(mk);
|
|
8471
8476
|
if (this.is(mv, "->") || this.is(mv, "=>")) {
|
|
8472
8477
|
let [, params, body] = mv;
|
|
@@ -8734,7 +8739,7 @@ export default ${expr[1]}`;
|
|
|
8734
8739
|
return `...${pair[1]}`;
|
|
8735
8740
|
if (this.is(pair, "default"))
|
|
8736
8741
|
return `${pair[1]} = ${this.generate(pair[2], "value")}`;
|
|
8737
|
-
let [key, value
|
|
8742
|
+
let [operator, key, value] = pair;
|
|
8738
8743
|
if (operator === "=")
|
|
8739
8744
|
return `${key} = ${this.generate(value, "value")}`;
|
|
8740
8745
|
if (key === value)
|
|
@@ -9152,13 +9157,13 @@ ${this.indent()}}`;
|
|
|
9152
9157
|
generateSwitchCaseBody(body, context) {
|
|
9153
9158
|
let code = "";
|
|
9154
9159
|
let hasFlow = this.hasExplicitControlFlow(body);
|
|
9160
|
+
let stmts = this.unwrapBlock(body);
|
|
9155
9161
|
if (hasFlow) {
|
|
9156
|
-
for (let s of
|
|
9162
|
+
for (let s of stmts)
|
|
9157
9163
|
code += this.indent() + this.generate(s, "statement") + `;
|
|
9158
9164
|
`;
|
|
9159
9165
|
} else if (context === "value") {
|
|
9160
9166
|
if (this.is(body, "block") && body.length > 2) {
|
|
9161
|
-
let stmts = body.slice(1);
|
|
9162
9167
|
for (let i = 0;i < stmts.length; i++) {
|
|
9163
9168
|
if (i === stmts.length - 1)
|
|
9164
9169
|
code += this.indent() + `return ${this.generate(stmts[i], "value")};
|
|
@@ -9172,8 +9177,14 @@ ${this.indent()}}`;
|
|
|
9172
9177
|
`;
|
|
9173
9178
|
}
|
|
9174
9179
|
} else {
|
|
9175
|
-
if (this.is(
|
|
9176
|
-
|
|
9180
|
+
if (stmts.length === 1 && this.is(stmts[0], "if") && !this.hasStatementInBranch(stmts[0]) && !this.hasNestedMultiStatement(stmts[0])) {
|
|
9181
|
+
let [_, condition, thenBranch, ...elseBranches] = stmts[0];
|
|
9182
|
+
let thenExpr = this.extractExpression(this.unwrapIfBranch(thenBranch));
|
|
9183
|
+
let elseExpr = this.buildTernaryChain(elseBranches);
|
|
9184
|
+
code += this.indent() + `(${this.unwrap(this.generate(condition, "value"))} ? ${thenExpr} : ${elseExpr});
|
|
9185
|
+
`;
|
|
9186
|
+
} else if (this.is(body, "block") && body.length > 1) {
|
|
9187
|
+
for (let s of stmts)
|
|
9177
9188
|
code += this.indent() + this.generate(s, "statement") + `;
|
|
9178
9189
|
`;
|
|
9179
9190
|
} else {
|
|
@@ -9453,7 +9464,7 @@ ${this.indent()}}`;
|
|
|
9453
9464
|
return;
|
|
9454
9465
|
}
|
|
9455
9466
|
if (pair.length >= 2) {
|
|
9456
|
-
let [key, value
|
|
9467
|
+
let [operator, key, value] = pair;
|
|
9457
9468
|
if (operator === "=") {
|
|
9458
9469
|
if (typeof key === "string")
|
|
9459
9470
|
varSet.add(key);
|
|
@@ -9988,8 +9999,8 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
|
9988
9999
|
return new CodeGenerator({}).getComponentRuntime();
|
|
9989
10000
|
}
|
|
9990
10001
|
// src/browser.js
|
|
9991
|
-
var VERSION = "3.13.
|
|
9992
|
-
var BUILD_DATE = "2026-03-
|
|
10002
|
+
var VERSION = "3.13.127";
|
|
10003
|
+
var BUILD_DATE = "2026-03-21@07:18:26GMT";
|
|
9993
10004
|
if (typeof globalThis !== "undefined") {
|
|
9994
10005
|
if (!globalThis.__rip)
|
|
9995
10006
|
new Function(getReactiveRuntime())();
|