rip-lang 3.13.78 → 3.13.79
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/package.json +5 -2
- package/src/components.js +28 -3
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.79-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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rip-lang",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.79",
|
|
4
4
|
"description": "A modern language that compiles to JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/compiler.js",
|
|
@@ -66,5 +66,8 @@
|
|
|
66
66
|
},
|
|
67
67
|
"homepage": "https://github.com/shreeve/rip-lang#readme",
|
|
68
68
|
"author": "Steve Shreeve <steve.shreeve@gmail.com>",
|
|
69
|
-
"license": "MIT"
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"typescript": "5.9.3"
|
|
72
|
+
}
|
|
70
73
|
}
|
package/src/components.js
CHANGED
|
@@ -107,6 +107,16 @@ function isPublicProp(target) {
|
|
|
107
107
|
return Array.isArray(target) && target[0] === '.' && target[1] === 'this';
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Extract type annotation from s-expression target node.
|
|
112
|
+
* Type annotations are stored as .type on String objects by the type rewriter.
|
|
113
|
+
*/
|
|
114
|
+
function getMemberType(target) {
|
|
115
|
+
if (target instanceof String && target.type) return target.type;
|
|
116
|
+
if (Array.isArray(target) && target[2] instanceof String && target[2].type) return target[2].type;
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
110
120
|
// ============================================================================
|
|
111
121
|
// Prototype Installation
|
|
112
122
|
// ============================================================================
|
|
@@ -703,7 +713,7 @@ export function installComponentSupport(CodeGenerator, Lexer) {
|
|
|
703
713
|
} else if (op === 'state') {
|
|
704
714
|
const varName = getMemberName(stmt[1]);
|
|
705
715
|
if (varName) {
|
|
706
|
-
stateVars.push({ name: varName, value: stmt[2], isPublic: isPublicProp(stmt[1]) });
|
|
716
|
+
stateVars.push({ name: varName, value: stmt[2], isPublic: isPublicProp(stmt[1]), type: getMemberType(stmt[1]) });
|
|
707
717
|
memberNames.add(varName);
|
|
708
718
|
reactiveMembers.add(varName);
|
|
709
719
|
}
|
|
@@ -717,7 +727,7 @@ export function installComponentSupport(CodeGenerator, Lexer) {
|
|
|
717
727
|
} else if (op === 'readonly') {
|
|
718
728
|
const varName = getMemberName(stmt[1]);
|
|
719
729
|
if (varName) {
|
|
720
|
-
readonlyVars.push({ name: varName, value: stmt[2], isPublic: isPublicProp(stmt[1]) });
|
|
730
|
+
readonlyVars.push({ name: varName, value: stmt[2], isPublic: isPublicProp(stmt[1]), type: getMemberType(stmt[1]) });
|
|
721
731
|
memberNames.add(varName);
|
|
722
732
|
}
|
|
723
733
|
} else if (op === '=') {
|
|
@@ -778,7 +788,22 @@ export function installComponentSupport(CodeGenerator, Lexer) {
|
|
|
778
788
|
lines.push('class extends __Component {');
|
|
779
789
|
|
|
780
790
|
// --- Init (called by __Component constructor) ---
|
|
781
|
-
|
|
791
|
+
if (this.options.lspMode) {
|
|
792
|
+
const typedProps = [];
|
|
793
|
+
for (const v of [...readonlyVars, ...stateVars]) {
|
|
794
|
+
if (v.isPublic) {
|
|
795
|
+
const t = v.type || 'any';
|
|
796
|
+
typedProps.push(`${v.name}?: ${t}`);
|
|
797
|
+
typedProps.push(`__bind_${v.name}__?: ${t}`);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
const propsType = typedProps.length > 0
|
|
801
|
+
? `{ ${typedProps.join(', ')}, [key: string]: any }`
|
|
802
|
+
: 'any';
|
|
803
|
+
lines.push(` _init(props: ${propsType}) {`);
|
|
804
|
+
} else {
|
|
805
|
+
lines.push(' _init(props) {');
|
|
806
|
+
}
|
|
782
807
|
|
|
783
808
|
// Constants (readonly)
|
|
784
809
|
for (const { name, value, isPublic } of readonlyVars) {
|