rip-lang 3.13.76 → 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 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.76-blue.svg" alt="Version"></a>
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
  }
@@ -4880,11 +4880,14 @@ ${blockFactoriesCode}return ${lines.join(`
4880
4880
  }
4881
4881
  } else if (arg && !childrenVar) {
4882
4882
  const textVar = this.newTextVar();
4883
- const val = typeof arg === "string" ? arg.valueOf() : null;
4884
- if (val && (val.startsWith('"') || val.startsWith("'") || val.startsWith("`"))) {
4885
- this._createLines.push(`${textVar} = document.createTextNode(${val});`);
4883
+ const exprCode = this.generateInComponent(arg, "value");
4884
+ if (this.hasReactiveDeps(arg)) {
4885
+ this._createLines.push(`${textVar} = document.createTextNode('');`);
4886
+ const body = `${textVar}.data = ${exprCode};`;
4887
+ const effect = this._factoryMode ? `disposers.push(__effect(() => { ${body} }));` : `__effect(() => { ${body} });`;
4888
+ childrenSetupLines.push(effect);
4886
4889
  } else {
4887
- this._createLines.push(`${textVar} = document.createTextNode(${this.generateInComponent(arg, "value")});`);
4890
+ this._createLines.push(`${textVar} = document.createTextNode(${exprCode});`);
4888
4891
  }
4889
4892
  childrenVar = textVar;
4890
4893
  props.push(`children: ${childrenVar}`);
@@ -5986,29 +5989,37 @@ if (typeof globalThis !== 'undefined') {
5986
5989
  needsBlank = true;
5987
5990
  }
5988
5991
  }
5989
- if (this.usesReactivity && !skip) {
5990
- if (skipRT) {
5991
- code += `var { __state, __computed, __effect, __batch, __readonly, __setErrorHandler, __handleError, __catchErrors } = globalThis.__rip;
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;
5992
6002
  `;
5993
- } else if (typeof globalThis !== "undefined" && globalThis.__rip) {
5994
- code += `const { __state, __computed, __effect, __batch, __readonly, __setErrorHandler, __handleError, __catchErrors } = globalThis.__rip;
6003
+ } else if (typeof globalThis !== "undefined" && globalThis.__rip) {
6004
+ code += `const { __state, __computed, __effect, __batch, __readonly, __setErrorHandler, __handleError, __catchErrors } = globalThis.__rip;
5995
6005
  `;
5996
- } else {
5997
- code += this.getReactiveRuntime();
6006
+ } else {
6007
+ code += this.getReactiveRuntime();
6008
+ }
6009
+ needsBlank = true;
5998
6010
  }
5999
- needsBlank = true;
6000
- }
6001
- if (this.usesTemplates && !skip) {
6002
- if (skipRT) {
6003
- 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;
6004
6014
  `;
6005
- } else if (typeof globalThis !== "undefined" && globalThis.__ripComponent) {
6006
- code += `const { __pushComponent, __popComponent, setContext, getContext, hasContext, __clsx, __lis, __reconcile, __transition, __handleComponentError, __Component } = globalThis.__ripComponent;
6015
+ } else if (typeof globalThis !== "undefined" && globalThis.__ripComponent) {
6016
+ code += `const { __pushComponent, __popComponent, setContext, getContext, hasContext, __clsx, __lis, __reconcile, __transition, __handleComponentError, __Component } = globalThis.__ripComponent;
6007
6017
  `;
6008
- } else {
6009
- code += this.getComponentRuntime();
6018
+ } else {
6019
+ code += this.getComponentRuntime();
6020
+ }
6021
+ needsBlank = true;
6010
6022
  }
6011
- needsBlank = true;
6012
6023
  }
6013
6024
  if (this.dataSection !== null && this.dataSection !== undefined && !skip) {
6014
6025
  code += `var DATA;
@@ -8690,12 +8701,14 @@ if (typeof globalThis !== 'undefined') {
8690
8701
  let sourceFile = this.options.filename || "input.rip";
8691
8702
  sourceMap = new SourceMapGenerator(file, sourceFile, source);
8692
8703
  }
8704
+ let lspMode = this.options.mode === "lsp";
8693
8705
  let generator = new CodeGenerator({
8694
8706
  dataSection,
8695
- skipPreamble: this.options.skipPreamble,
8707
+ skipPreamble: lspMode || this.options.skipPreamble,
8696
8708
  skipRuntimes: this.options.skipRuntimes,
8697
8709
  skipExports: this.options.skipExports,
8698
8710
  reactiveVars: this.options.reactiveVars,
8711
+ lspMode,
8699
8712
  sourceMap
8700
8713
  });
8701
8714
  let code = generator.compile(sexpr);
@@ -8712,6 +8725,11 @@ if (typeof globalThis !== 'undefined') {
8712
8725
  if (typeTokens) {
8713
8726
  dts = emitTypes(typeTokens, sexpr);
8714
8727
  }
8728
+ if (lspMode && dts) {
8729
+ code = dts.trimEnd() + `
8730
+
8731
+ ` + code;
8732
+ }
8715
8733
  return { tokens, sexpr, code, dts, map, reverseMap, data: dataSection, reactiveVars: generator.reactiveVars };
8716
8734
  }
8717
8735
  compileToJS(source) {
@@ -8751,9 +8769,33 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
8751
8769
  function getComponentRuntime() {
8752
8770
  return new CodeGenerator({}).getComponentRuntime();
8753
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
+ }
8754
8796
  // src/browser.js
8755
- var VERSION = "3.13.75";
8756
- var BUILD_DATE = "2026-03-03@00:02:43GMT";
8797
+ var VERSION = "3.13.77";
8798
+ var BUILD_DATE = "2026-03-03@07:30:00GMT";
8757
8799
  if (typeof globalThis !== "undefined") {
8758
8800
  if (!globalThis.__rip)
8759
8801
  new Function(getReactiveRuntime())();