ripple 0.2.75 → 0.2.77

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.
Files changed (29) hide show
  1. package/package.json +8 -1
  2. package/src/compiler/index.js +29 -12
  3. package/src/compiler/phases/1-parse/index.js +0 -5
  4. package/src/compiler/phases/3-transform/client/index.js +1667 -0
  5. package/src/compiler/phases/3-transform/server/index.js +240 -0
  6. package/src/compiler/utils.js +60 -0
  7. package/src/runtime/index.js +6 -0
  8. package/src/runtime/internal/client/for.js +3 -4
  9. package/src/runtime/internal/client/runtime.js +4 -0
  10. package/src/runtime/internal/server/index.js +70 -0
  11. package/src/server/index.js +1 -0
  12. package/src/utils/escaping.js +26 -0
  13. package/tests/{__snapshots__ → client/__snapshots__}/basic.test.ripple.snap +9 -0
  14. package/tests/{array.test.ripple → client/array.test.ripple} +1 -1
  15. package/tests/{basic.test.ripple → client/basic.test.ripple} +13 -0
  16. package/types/server.d.ts +0 -0
  17. package/src/compiler/phases/3-transform/index.js +0 -1721
  18. /package/tests/{__snapshots__ → client/__snapshots__}/composite.test.ripple.snap +0 -0
  19. /package/tests/{__snapshots__ → client/__snapshots__}/for.test.ripple.snap +0 -0
  20. /package/tests/{accessors-props.test.ripple → client/accessors-props.test.ripple} +0 -0
  21. /package/tests/{boundaries.test.ripple → client/boundaries.test.ripple} +0 -0
  22. /package/tests/{compiler.test.ripple → client/compiler.test.ripple} +0 -0
  23. /package/tests/{composite.test.ripple → client/composite.test.ripple} +0 -0
  24. /package/tests/{context.test.ripple → client/context.test.ripple} +0 -0
  25. /package/tests/{for.test.ripple → client/for.test.ripple} +0 -0
  26. /package/tests/{map.test.ripple → client/map.test.ripple} +0 -0
  27. /package/tests/{ref.test.ripple → client/ref.test.ripple} +0 -0
  28. /package/tests/{set.test.ripple → client/set.test.ripple} +0 -0
  29. /package/tests/{svg.test.ripple → client/svg.test.ripple} +0 -0
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ripple is an elegant TypeScript UI framework",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.75",
6
+ "version": "0.2.77",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index.js",
9
9
  "main": "src/runtime/index.js",
@@ -29,6 +29,10 @@
29
29
  "default": "./src/runtime/index.js"
30
30
  },
31
31
  "./package.json": "./package.json",
32
+ "./server": {
33
+ "types": "./types/server.d.ts",
34
+ "default": "./src/server/index.js"
35
+ },
32
36
  "./compiler": {
33
37
  "types": "./types/index.d.ts",
34
38
  "require": "./compiler/index.js",
@@ -42,6 +46,9 @@
42
46
  "./internal/client": {
43
47
  "default": "./src/runtime/internal/client/index.js"
44
48
  },
49
+ "./internal/server": {
50
+ "default": "./src/runtime/internal/server/index.js"
51
+ },
45
52
  "./jsx-runtime": {
46
53
  "types": "./src/jsx-runtime.d.ts",
47
54
  "import": "./src/jsx-runtime.js",
@@ -1,25 +1,42 @@
1
+ /** @import { RawSourceMap } from 'source-map' */
2
+ /** @import { Program } from 'estree' */
3
+ /** @import { ParseError } from './phases/1-parse/index.js' */
4
+
1
5
  import { parse as parse_module } from './phases/1-parse/index.js';
2
6
  import { analyze } from './phases/2-analyze/index.js';
3
- import { transform } from './phases/3-transform/index.js';
7
+ import { transform_client } from './phases/3-transform/client/index.js';
8
+ import { transform_server } from './phases/3-transform/server/index.js';
4
9
  import { convert_source_map_to_mappings } from './phases/3-transform/segments.js';
5
10
 
11
+ /**
12
+ * @param {string} source
13
+ * @returns {{ ast: Program, errors: ParseError[] }}
14
+ */
6
15
  export function parse(source) {
7
- return parse_module(source);
16
+ return parse_module(source);
8
17
  }
9
18
 
10
- export function compile(source, filename) {
11
- const ast = parse_module(source);
12
- const analysis = analyze(ast, filename);
13
- const result = transform(filename, source, analysis, false);
19
+ /**
20
+ * @param {string} source
21
+ * @param {string} filename
22
+ * @param {{ mode?: 'client' | 'server' }} options
23
+ * @returns {{ js: { code: string, map: RawSourceMap }, css: { code: string, map: RawSourceMap } | null }}
24
+ */
25
+ export function compile(source, filename, options = {}) {
26
+ const ast = parse_module(source);
27
+ const analysis = analyze(ast, filename);
28
+ const result = options.mode === 'server'
29
+ ? transform_server(filename, source, analysis)
30
+ : transform_client(filename, source, analysis, false);
14
31
 
15
- return result;
32
+ return result;
16
33
  }
17
34
 
18
35
  export function compile_to_volar_mappings(source, filename) {
19
- // Parse and transform to get the esrap sourcemap
20
- const ast = parse_module(source);
21
- const analysis = analyze(ast, filename);
22
- const transformed = transform(filename, source, analysis, true);
36
+ // Parse and transform to get the esrap sourcemap
37
+ const ast = parse_module(source);
38
+ const analysis = analyze(ast, filename);
39
+ const transformed = transform_client(filename, source, analysis, true);
23
40
 
24
- return convert_source_map_to_mappings(transformed.js.map, source, transformed.js.code);
41
+ return convert_source_map_to_mappings(transformed.js.map, source, transformed.js.code);
25
42
  }
@@ -828,11 +828,6 @@ function RipplePlugin(config) {
828
828
  }
829
829
  }
830
830
 
831
- if (this.type.label === '</>/<=/>=') {
832
- debugger;
833
- console.log('HERE', this.value, this.type);
834
- }
835
-
836
831
  if (this.type.label === '{') {
837
832
  const node = this.jsx_parseExpressionContainer();
838
833
  node.type = 'Text';