rip-lang 3.13.107 → 3.13.108
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 +47 -12
- package/docs/dist/rip.min.js +108 -108
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/components.js +41 -6
- package/src/lexer.js +1 -1
- package/src/sourcemap-utils.js +33 -3
- package/src/typecheck.js +89 -23
- package/src/types.js +11 -4
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.108-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
|
@@ -314,12 +314,13 @@
|
|
|
314
314
|
j++;
|
|
315
315
|
continue;
|
|
316
316
|
}
|
|
317
|
-
|
|
317
|
+
let isProperty = t[0] === "PROPERTY" || t[0] === "IDENTIFIER" || depth === 1 && /^[a-zA-Z_$]/.test(t[1]) && tokens[j + 1]?.[0] === "TYPE_ANNOTATION";
|
|
318
|
+
if (depth === 1 && isProperty) {
|
|
318
319
|
let propName = t[1];
|
|
319
320
|
let optional = false;
|
|
320
321
|
let readonly = false;
|
|
321
322
|
j++;
|
|
322
|
-
if (propName === "readonly" && (tokens[j]
|
|
323
|
+
if (propName === "readonly" && tokens[j] && (tokens[j][0] === "PROPERTY" || tokens[j][0] === "IDENTIFIER" || /^[a-zA-Z_$]/.test(tokens[j][1]) && tokens[j + 1]?.[0] === "TYPE_ANNOTATION")) {
|
|
323
324
|
readonly = true;
|
|
324
325
|
propName = tokens[j][1];
|
|
325
326
|
if (tokens[j].data?.predicate)
|
|
@@ -1020,7 +1021,7 @@
|
|
|
1020
1021
|
let preamble = [];
|
|
1021
1022
|
if (usesSignal) {
|
|
1022
1023
|
preamble.push("interface Signal<T> { value: T; read(): T; lock(): Signal<T>; free(): Signal<T>; kill(): T; }");
|
|
1023
|
-
preamble.push("declare function __state<T>(value: T): Signal<T>;");
|
|
1024
|
+
preamble.push("declare function __state<T>(value: T | Signal<T>): Signal<T>;");
|
|
1024
1025
|
}
|
|
1025
1026
|
if (usesComputed) {
|
|
1026
1027
|
preamble.push("interface Computed<T> { readonly value: T; read(): T; lock(): Computed<T>; free(): Computed<T>; kill(): T; }");
|
|
@@ -1145,6 +1146,9 @@
|
|
|
1145
1146
|
if (!hasDefault)
|
|
1146
1147
|
hasRequired = true;
|
|
1147
1148
|
publicProps.push(` ${propName}${opt}: ${typeStr};`);
|
|
1149
|
+
if (mHead === "state") {
|
|
1150
|
+
publicProps.push(` __bind_${propName}__?: Signal<${typeStr}>;`);
|
|
1151
|
+
}
|
|
1148
1152
|
}
|
|
1149
1153
|
lines.push(`${exp}declare class ${name} {`);
|
|
1150
1154
|
if (publicProps.length > 0) {
|
|
@@ -2241,9 +2245,10 @@
|
|
|
2241
2245
|
this.emit("PROPERTY", "prototype");
|
|
2242
2246
|
this.emit(".", ".");
|
|
2243
2247
|
return 2;
|
|
2244
|
-
} else if (val === "::")
|
|
2248
|
+
} else if (val === "::") {
|
|
2245
2249
|
tag = "TYPE_ANNOTATION";
|
|
2246
|
-
|
|
2250
|
+
this.inTypeAnnotation = true;
|
|
2251
|
+
} else if (val === "~=")
|
|
2247
2252
|
tag = "COMPUTED_ASSIGN";
|
|
2248
2253
|
else if (val === ":=")
|
|
2249
2254
|
tag = "REACTIVE_ASSIGN";
|
|
@@ -4357,6 +4362,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4357
4362
|
const ts = expandType(type);
|
|
4358
4363
|
const opt = required ? "" : "?";
|
|
4359
4364
|
propEntries.push(`${name}${opt}: ${ts || "any"}`);
|
|
4365
|
+
propEntries.push(`__bind_${name}__?: Signal<${ts || "any"}>`);
|
|
4360
4366
|
}
|
|
4361
4367
|
for (const { name, type, isPublic } of readonlyVars) {
|
|
4362
4368
|
if (!isPublic)
|
|
@@ -4451,6 +4457,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4451
4457
|
}
|
|
4452
4458
|
if (renderBlock) {
|
|
4453
4459
|
const constructions = [];
|
|
4460
|
+
let constructionIdx = 0;
|
|
4454
4461
|
const extractProps = (args) => {
|
|
4455
4462
|
const props = [];
|
|
4456
4463
|
for (const arg of args) {
|
|
@@ -4467,10 +4474,17 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4467
4474
|
}
|
|
4468
4475
|
if (obj) {
|
|
4469
4476
|
for (let j = 1;j < obj.length; j++) {
|
|
4470
|
-
const
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4477
|
+
const pair = obj[j];
|
|
4478
|
+
const [key, value] = pair;
|
|
4479
|
+
if (typeof key === "string" && !key.startsWith("@")) {
|
|
4480
|
+
const srcLine = pair.loc?.r ?? obj.loc?.r;
|
|
4481
|
+
if (key.startsWith("__bind_") && key.endsWith("__")) {
|
|
4482
|
+
const member = typeof value === "string" && this.reactiveMembers?.has(value) ? `this.${value}` : this.generateInComponent(value, "value");
|
|
4483
|
+
props.push({ code: `${key}: ${member}`, srcLine });
|
|
4484
|
+
} else {
|
|
4485
|
+
const val = this.generateInComponent(value, "value");
|
|
4486
|
+
props.push({ code: `${key}: ${val}`, srcLine });
|
|
4487
|
+
}
|
|
4474
4488
|
}
|
|
4475
4489
|
}
|
|
4476
4490
|
}
|
|
@@ -4483,7 +4497,28 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
4483
4497
|
const head2 = node[0]?.valueOf?.() ?? node[0];
|
|
4484
4498
|
if (typeof head2 === "string" && /^[A-Z]/.test(head2)) {
|
|
4485
4499
|
const props = extractProps(node.slice(1));
|
|
4486
|
-
|
|
4500
|
+
const varName = `_${constructionIdx++}`;
|
|
4501
|
+
const propsType = `ConstructorParameters<typeof ${head2}>[0] & {}`;
|
|
4502
|
+
if (props.length === 0) {
|
|
4503
|
+
const tagLine = node.loc?.r;
|
|
4504
|
+
constructions.push(` const ${varName}: ${propsType} = {};` + (tagLine != null ? ` // @rip-src:${tagLine}` : ""));
|
|
4505
|
+
} else if (props.length === 1) {
|
|
4506
|
+
const srcLine = props[0].srcLine ?? node.loc?.r;
|
|
4507
|
+
constructions.push(` const ${varName}: ${propsType} = {${props[0].code}};` + (srcLine != null ? ` // @rip-src:${srcLine}` : ""));
|
|
4508
|
+
} else {
|
|
4509
|
+
const tagLine = node.loc?.r;
|
|
4510
|
+
const distinctLines = new Set(props.map((p) => p.srcLine).filter((l) => l != null));
|
|
4511
|
+
if (distinctLines.size <= 1) {
|
|
4512
|
+
const srcLine = props[0].srcLine ?? tagLine;
|
|
4513
|
+
constructions.push(` const ${varName}: ${propsType} = {${props.map((p) => p.code).join(", ")}};` + (srcLine != null ? ` // @rip-src:${srcLine}` : ""));
|
|
4514
|
+
} else {
|
|
4515
|
+
constructions.push(` const ${varName}: ${propsType} = {` + (tagLine != null ? ` // @rip-src:${tagLine}` : ""));
|
|
4516
|
+
for (const p of props) {
|
|
4517
|
+
constructions.push(` ${p.code},` + (p.srcLine != null ? ` // @rip-src:${p.srcLine}` : ""));
|
|
4518
|
+
}
|
|
4519
|
+
constructions.push(` };`);
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4487
4522
|
}
|
|
4488
4523
|
for (let i = 1;i < node.length; i++)
|
|
4489
4524
|
walkRender(node[i]);
|
|
@@ -9353,8 +9388,8 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
|
9353
9388
|
return new CodeGenerator({}).getComponentRuntime();
|
|
9354
9389
|
}
|
|
9355
9390
|
// src/browser.js
|
|
9356
|
-
var VERSION = "3.13.
|
|
9357
|
-
var BUILD_DATE = "2026-03-
|
|
9391
|
+
var VERSION = "3.13.108";
|
|
9392
|
+
var BUILD_DATE = "2026-03-13@23:35:48GMT";
|
|
9358
9393
|
if (typeof globalThis !== "undefined") {
|
|
9359
9394
|
if (!globalThis.__rip)
|
|
9360
9395
|
new Function(getReactiveRuntime())();
|