rip-lang 3.13.77 → 3.13.78
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/bin/rip +9 -3
- package/docs/dist/rip.js +62 -23
- package/docs/dist/rip.min.js +74 -50
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/compiler.js +48 -18
- package/src/components.js +5 -4
- package/src/typecheck.js +11 -95
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.78-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/bin/rip
CHANGED
|
@@ -32,6 +32,7 @@ Usage:
|
|
|
32
32
|
Options:
|
|
33
33
|
-c, --compile Show compiled JavaScript output
|
|
34
34
|
-d, --dts Show type declarations
|
|
35
|
+
-l, --lsp Show LSP TypeScript output (DTS + typed code for IntelliSense)
|
|
35
36
|
-m, --map Embed inline source map in compiled output
|
|
36
37
|
-h, --help Show this help message
|
|
37
38
|
-o, --output <file> Write JavaScript to file
|
|
@@ -161,6 +162,7 @@ async function main() {
|
|
|
161
162
|
const showSExpr = ripOptions.includes('-s') || ripOptions.includes('--sexpr');
|
|
162
163
|
const showCompiled = ripOptions.includes('-c') || ripOptions.includes('--compile');
|
|
163
164
|
const generateDts = ripOptions.includes('-d') || ripOptions.includes('--dts');
|
|
165
|
+
const showLsp = ripOptions.includes('-l') || ripOptions.includes('--lsp');
|
|
164
166
|
const generateMap = ripOptions.includes('-m') || ripOptions.includes('--map');
|
|
165
167
|
const quiet = ripOptions.includes('-q') || ripOptions.includes('--quiet');
|
|
166
168
|
|
|
@@ -174,7 +176,7 @@ async function main() {
|
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
// Stdin handling — read into memory; only write temp file for the execute path
|
|
177
|
-
const hasCompileFlag = showCompiled || showTokens || showSExpr || generateDts || generateMap || outputFile;
|
|
179
|
+
const hasCompileFlag = showCompiled || showTokens || showSExpr || generateDts || showLsp || generateMap || outputFile;
|
|
178
180
|
let source;
|
|
179
181
|
|
|
180
182
|
if (!inputFile) {
|
|
@@ -255,20 +257,24 @@ async function main() {
|
|
|
255
257
|
|
|
256
258
|
try {
|
|
257
259
|
const compiler = new Compiler({ showTokens, showSExpr, quiet,
|
|
258
|
-
types: generateDts ? 'emit' : undefined,
|
|
260
|
+
types: (generateDts || showLsp) ? 'emit' : undefined,
|
|
259
261
|
sourceMap: generateMap ? 'inline' : undefined,
|
|
262
|
+
mode: showLsp ? 'lsp' : undefined,
|
|
260
263
|
});
|
|
261
264
|
const result = compiler.compile(source);
|
|
262
265
|
|
|
263
266
|
if (outputFile) {
|
|
264
267
|
writeFileSync(outputFile, result.code, 'utf-8');
|
|
265
268
|
if (!quiet) console.log(`Compiled to ${outputFile}`);
|
|
269
|
+
} else if (showLsp) {
|
|
270
|
+
if (!quiet) console.log(`// == LSP TypeScript output by Rip ${VERSION} == //\n`);
|
|
271
|
+
console.log(result.code);
|
|
266
272
|
} else if (showCompiled) {
|
|
267
273
|
if (!quiet) console.log(`// == JavaScript output by Rip ${VERSION} == //\n`);
|
|
268
274
|
console.log(result.code);
|
|
269
275
|
}
|
|
270
276
|
|
|
271
|
-
if (generateDts && result.dts) {
|
|
277
|
+
if (generateDts && !showLsp && result.dts) {
|
|
272
278
|
if (!quiet) console.log(`// == Type declarations == //\n`);
|
|
273
279
|
console.log(result.dts);
|
|
274
280
|
}
|
package/docs/dist/rip.js
CHANGED
|
@@ -3500,10 +3500,10 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
3500
3500
|
return null;
|
|
3501
3501
|
}
|
|
3502
3502
|
function getMemberName(target) {
|
|
3503
|
-
if (typeof target === "string")
|
|
3504
|
-
return target;
|
|
3505
|
-
if (Array.isArray(target) && target[0] === "." && target[1] === "this" && typeof target[2] === "string") {
|
|
3506
|
-
return target[2];
|
|
3503
|
+
if (typeof target === "string" || target instanceof String)
|
|
3504
|
+
return target.valueOf();
|
|
3505
|
+
if (Array.isArray(target) && target[0] === "." && target[1] === "this" && (typeof target[2] === "string" || target[2] instanceof String)) {
|
|
3506
|
+
return target[2].valueOf();
|
|
3507
3507
|
}
|
|
3508
3508
|
return null;
|
|
3509
3509
|
}
|
|
@@ -5989,29 +5989,37 @@ if (typeof globalThis !== 'undefined') {
|
|
|
5989
5989
|
needsBlank = true;
|
|
5990
5990
|
}
|
|
5991
5991
|
}
|
|
5992
|
-
if (this.
|
|
5993
|
-
if (
|
|
5994
|
-
code += `
|
|
5992
|
+
if (this.options.lspMode && (this.usesReactivity || this.usesTemplates)) {
|
|
5993
|
+
if (needsBlank)
|
|
5994
|
+
code += `
|
|
5995
|
+
`;
|
|
5996
|
+
code += getLspRuntimeDeclarations();
|
|
5997
|
+
needsBlank = true;
|
|
5998
|
+
} else {
|
|
5999
|
+
if (this.usesReactivity && !skip) {
|
|
6000
|
+
if (skipRT) {
|
|
6001
|
+
code += `var { __state, __computed, __effect, __batch, __readonly, __setErrorHandler, __handleError, __catchErrors } = globalThis.__rip;
|
|
5995
6002
|
`;
|
|
5996
|
-
|
|
5997
|
-
|
|
6003
|
+
} else if (typeof globalThis !== "undefined" && globalThis.__rip) {
|
|
6004
|
+
code += `const { __state, __computed, __effect, __batch, __readonly, __setErrorHandler, __handleError, __catchErrors } = globalThis.__rip;
|
|
5998
6005
|
`;
|
|
5999
|
-
|
|
6000
|
-
|
|
6006
|
+
} else {
|
|
6007
|
+
code += this.getReactiveRuntime();
|
|
6008
|
+
}
|
|
6009
|
+
needsBlank = true;
|
|
6001
6010
|
}
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
if (skipRT) {
|
|
6006
|
-
code += `var { __pushComponent, __popComponent, setContext, getContext, hasContext, __clsx, __lis, __reconcile, __transition, __handleComponentError, __Component } = globalThis.__ripComponent;
|
|
6011
|
+
if (this.usesTemplates && !skip) {
|
|
6012
|
+
if (skipRT) {
|
|
6013
|
+
code += `var { __pushComponent, __popComponent, setContext, getContext, hasContext, __clsx, __lis, __reconcile, __transition, __handleComponentError, __Component } = globalThis.__ripComponent;
|
|
6007
6014
|
`;
|
|
6008
|
-
|
|
6009
|
-
|
|
6015
|
+
} else if (typeof globalThis !== "undefined" && globalThis.__ripComponent) {
|
|
6016
|
+
code += `const { __pushComponent, __popComponent, setContext, getContext, hasContext, __clsx, __lis, __reconcile, __transition, __handleComponentError, __Component } = globalThis.__ripComponent;
|
|
6010
6017
|
`;
|
|
6011
|
-
|
|
6012
|
-
|
|
6018
|
+
} else {
|
|
6019
|
+
code += this.getComponentRuntime();
|
|
6020
|
+
}
|
|
6021
|
+
needsBlank = true;
|
|
6013
6022
|
}
|
|
6014
|
-
needsBlank = true;
|
|
6015
6023
|
}
|
|
6016
6024
|
if (this.dataSection !== null && this.dataSection !== undefined && !skip) {
|
|
6017
6025
|
code += `var DATA;
|
|
@@ -8693,12 +8701,14 @@ if (typeof globalThis !== 'undefined') {
|
|
|
8693
8701
|
let sourceFile = this.options.filename || "input.rip";
|
|
8694
8702
|
sourceMap = new SourceMapGenerator(file, sourceFile, source);
|
|
8695
8703
|
}
|
|
8704
|
+
let lspMode = this.options.mode === "lsp";
|
|
8696
8705
|
let generator = new CodeGenerator({
|
|
8697
8706
|
dataSection,
|
|
8698
|
-
skipPreamble: this.options.skipPreamble,
|
|
8707
|
+
skipPreamble: lspMode || this.options.skipPreamble,
|
|
8699
8708
|
skipRuntimes: this.options.skipRuntimes,
|
|
8700
8709
|
skipExports: this.options.skipExports,
|
|
8701
8710
|
reactiveVars: this.options.reactiveVars,
|
|
8711
|
+
lspMode,
|
|
8702
8712
|
sourceMap
|
|
8703
8713
|
});
|
|
8704
8714
|
let code = generator.compile(sexpr);
|
|
@@ -8715,6 +8725,11 @@ if (typeof globalThis !== 'undefined') {
|
|
|
8715
8725
|
if (typeTokens) {
|
|
8716
8726
|
dts = emitTypes(typeTokens, sexpr);
|
|
8717
8727
|
}
|
|
8728
|
+
if (lspMode && dts) {
|
|
8729
|
+
code = dts.trimEnd() + `
|
|
8730
|
+
|
|
8731
|
+
` + code;
|
|
8732
|
+
}
|
|
8718
8733
|
return { tokens, sexpr, code, dts, map, reverseMap, data: dataSection, reactiveVars: generator.reactiveVars };
|
|
8719
8734
|
}
|
|
8720
8735
|
compileToJS(source) {
|
|
@@ -8754,9 +8769,33 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
|
8754
8769
|
function getComponentRuntime() {
|
|
8755
8770
|
return new CodeGenerator({}).getComponentRuntime();
|
|
8756
8771
|
}
|
|
8772
|
+
function getLspRuntimeDeclarations() {
|
|
8773
|
+
return `interface Signal<T> { value: T; read(): T; lock(): Signal<T>; free(): Signal<T>; kill(): T; }
|
|
8774
|
+
interface Computed<T> { readonly value: T; read(): T; lock(): Computed<T>; free(): Computed<T>; kill(): T; }
|
|
8775
|
+
declare function __state<T>(v: T): Signal<T>;
|
|
8776
|
+
declare function __computed<T>(fn: () => T): Computed<T>;
|
|
8777
|
+
declare function __effect(fn: () => void | (() => void)): () => void;
|
|
8778
|
+
declare function __batch<T>(fn: () => T): T;
|
|
8779
|
+
declare function __readonly<T>(v: T): Readonly<{ value: T }>;
|
|
8780
|
+
declare function __setErrorHandler(handler: ((err: any) => void) | null): ((err: any) => void) | null;
|
|
8781
|
+
declare function __handleError(error: any): void;
|
|
8782
|
+
declare function __catchErrors<T extends (...args: any[]) => any>(fn: T): T;
|
|
8783
|
+
declare function __pushComponent(component: any): any;
|
|
8784
|
+
declare function __popComponent(prev: any): void;
|
|
8785
|
+
declare function setContext(key: string, value: any): void;
|
|
8786
|
+
declare function getContext(key: string): any;
|
|
8787
|
+
declare function hasContext(key: string): boolean;
|
|
8788
|
+
declare function __clsx(...args: any[]): string;
|
|
8789
|
+
declare function __lis(arr: number[]): number[];
|
|
8790
|
+
declare function __reconcile(anchor: any, state: any, items: any[], ctx: any, factory: any, keyFn: any, ...outer: any[]): void;
|
|
8791
|
+
declare function __transition(el: any, name: string, dir: string, done?: () => void): void;
|
|
8792
|
+
declare function __handleComponentError(error: any, component: any): void;
|
|
8793
|
+
declare class __Component { constructor(props?: any); mount(target?: any): any; unmount(): void; emit(name: string, detail?: any): void; static mount(target?: any): any; [key: string]: any; }
|
|
8794
|
+
`;
|
|
8795
|
+
}
|
|
8757
8796
|
// src/browser.js
|
|
8758
8797
|
var VERSION = "3.13.77";
|
|
8759
|
-
var BUILD_DATE = "2026-03-03@
|
|
8798
|
+
var BUILD_DATE = "2026-03-03@07:30:00GMT";
|
|
8760
8799
|
if (typeof globalThis !== "undefined") {
|
|
8761
8800
|
if (!globalThis.__rip)
|
|
8762
8801
|
new Function(getReactiveRuntime())();
|