ripple 0.2.198 → 0.2.199

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 (52) hide show
  1. package/package.json +6 -2
  2. package/src/compiler/comment-utils.js +1 -1
  3. package/src/compiler/index.d.ts +2 -2
  4. package/src/compiler/phases/3-transform/client/index.js +101 -33
  5. package/src/compiler/phases/3-transform/segments.js +2 -2
  6. package/src/compiler/phases/3-transform/server/index.js +19 -4
  7. package/src/compiler/source-map-utils.js +2 -2
  8. package/src/compiler/types/index.d.ts +1 -1
  9. package/src/compiler/types/parse.d.ts +2 -2
  10. package/src/constants.js +15 -0
  11. package/src/jsx-runtime.d.ts +313 -204
  12. package/src/runtime/index-client.js +63 -1
  13. package/src/runtime/internal/client/for.js +26 -3
  14. package/src/runtime/internal/client/html.js +5 -5
  15. package/src/runtime/internal/client/hydration.js +36 -0
  16. package/src/runtime/internal/client/if.js +5 -0
  17. package/src/runtime/internal/client/index.js +3 -1
  18. package/src/runtime/internal/client/operations.js +99 -11
  19. package/src/runtime/internal/client/template.js +19 -5
  20. package/src/runtime/internal/server/index.js +2 -1
  21. package/src/utils/builders.js +5 -2
  22. package/tests/hydration/basic.test.js +61 -0
  23. package/tests/hydration/build-components.js +78 -0
  24. package/tests/hydration/compiled/client/basic.js +169 -0
  25. package/tests/hydration/compiled/client/events.js +280 -0
  26. package/tests/hydration/compiled/client/for.js +418 -0
  27. package/tests/hydration/compiled/client/if.js +291 -0
  28. package/tests/hydration/compiled/client/reactivity.js +167 -0
  29. package/tests/hydration/compiled/server/basic.js +139 -0
  30. package/tests/hydration/compiled/server/events.js +160 -0
  31. package/tests/hydration/compiled/server/for.js +254 -0
  32. package/tests/hydration/compiled/server/if.js +216 -0
  33. package/tests/hydration/compiled/server/reactivity.js +93 -0
  34. package/tests/hydration/components/basic.ripple +65 -0
  35. package/tests/hydration/components/events.ripple +107 -0
  36. package/tests/hydration/components/for.ripple +128 -0
  37. package/tests/hydration/components/if.ripple +123 -0
  38. package/tests/hydration/components/reactivity.ripple +41 -0
  39. package/tests/hydration/events.test.js +113 -0
  40. package/tests/hydration/for.test.js +117 -0
  41. package/tests/hydration/if.test.js +86 -0
  42. package/tests/hydration/reactivity.test.js +37 -0
  43. package/tests/server/basic.test.ripple +8 -8
  44. package/tests/server/context.test.ripple +1 -1
  45. package/tests/server/for.test.ripple +5 -5
  46. package/tests/server/if.test.ripple +5 -5
  47. package/tests/server/switch.test.ripple +4 -4
  48. package/tests/server.d.ts +14 -0
  49. package/tests/setup-hydration.js +69 -0
  50. package/tests/setup-server.js +27 -0
  51. package/tsconfig.json +1 -0
  52. package/types/index.d.ts +5 -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.198",
6
+ "version": "0.2.199",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index-client.js",
9
9
  "main": "src/runtime/index-client.js",
@@ -55,6 +55,10 @@
55
55
  "./internal/server": {
56
56
  "default": "./src/runtime/internal/server/index.js"
57
57
  },
58
+ "./ssr": {
59
+ "types": "./types/index.d.ts",
60
+ "default": "./src/runtime/index-server.js"
61
+ },
58
62
  "./jsx-runtime": {
59
63
  "types": "./src/jsx-runtime.d.ts",
60
64
  "import": "./src/jsx-runtime.js",
@@ -92,6 +96,6 @@
92
96
  "vscode-languageserver-types": "^3.17.5"
93
97
  },
94
98
  "peerDependencies": {
95
- "ripple": "0.2.198"
99
+ "ripple": "0.2.199"
96
100
  }
97
101
  }
@@ -11,7 +11,7 @@ export function is_ts_pragma(comment) {
11
11
  if (comment.type !== 'Line') return false;
12
12
 
13
13
  const pragmas = ['@ts-ignore', '@ts-expect-error', '@ts-nocheck', '@ts-check'];
14
- return pragmas.some((pragma) => comment.value.includes(pragma));
14
+ return pragmas.some((pragma) => comment.value.trimStart().startsWith(pragma));
15
15
  }
16
16
 
17
17
  /**
@@ -4,7 +4,7 @@ import type {
4
4
  Mapping as VolarMapping,
5
5
  } from '@volar/language-core';
6
6
  import type { DocumentHighlightKind } from 'vscode-languageserver-types';
7
- import type { SourceMapMappings } from '@jridgewell/sourcemap-codec';
7
+ import type { RawSourceMap } from 'source-map';
8
8
 
9
9
  // ============================================================================
10
10
  // Compiler API Exports
@@ -18,7 +18,7 @@ export interface CompileResult {
18
18
  /** The generated JavaScript code with source map */
19
19
  js: {
20
20
  code: string;
21
- map: SourceMapMappings;
21
+ map: RawSourceMap;
22
22
  };
23
23
  /** The generated CSS */
24
24
  css: string;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  @import * as AST from 'estree';
3
3
  @import * as ESTreeJSX from 'estree-jsx';
4
- @import { SourceMapMappings } from '@jridgewell/sourcemap-codec';
4
+ @import { RawSourceMap } from 'source-map';
5
5
  @import {
6
6
  AnalysisResult,
7
7
  TransformClientContext,
@@ -330,6 +330,33 @@ function set_hidden_import_from_ripple(name, context) {
330
330
  return name;
331
331
  }
332
332
 
333
+ /**
334
+ * @param {TransformClientContext} context
335
+ * @param {Partial<TransformClientState>} [more_state]
336
+ * @return TransformClientContext
337
+ */
338
+ function SetContextForOutsideComponent(context, more_state = {}) {
339
+ return /** @type {TransformClientContext} */ ({
340
+ ...context,
341
+ state: SetStateForOutsideComponent(context.state, more_state),
342
+ });
343
+ }
344
+
345
+ /**
346
+ * @param {TransformClientState} state
347
+ * @param {Partial<TransformClientState>} [more_state]
348
+ * @return TransformClientState
349
+ */
350
+ function SetStateForOutsideComponent(state, more_state = {}) {
351
+ return /** @type {TransformClientState} */ ({
352
+ ...state,
353
+ ...more_state,
354
+ init: null,
355
+ update: null,
356
+ final: null,
357
+ });
358
+ }
359
+
333
360
  /** @type {Visitors<AST.Node, TransformClientState>} */
334
361
  const visitors = {
335
362
  _(node, { next, state, path }) {
@@ -1404,6 +1431,27 @@ const visitors = {
1404
1431
  }),
1405
1432
  );
1406
1433
  state.template?.push(`</${node.id.name}>`);
1434
+
1435
+ // We need to check if any child nodes are dynamic to determine
1436
+ // if we need to pop the hydration stack to the parent node
1437
+ const needs_pop = node.children.some(
1438
+ (child) =>
1439
+ child.type === 'IfStatement' ||
1440
+ child.type === 'TryStatement' ||
1441
+ child.type === 'ForOfStatement' ||
1442
+ child.type === 'SwitchStatement' ||
1443
+ child.type === 'TsxCompat' ||
1444
+ child.type === 'Html' ||
1445
+ (child.type === 'Element' &&
1446
+ (child.id.type !== 'Identifier' || !is_element_dom_element(child))) ||
1447
+ (child.type === 'Text' && child.expression.type !== 'Literal'),
1448
+ );
1449
+
1450
+ if (needs_pop) {
1451
+ const id = state.flush_node?.();
1452
+
1453
+ init.push(b.stmt(b.call('_$_.pop', id)));
1454
+ }
1407
1455
  }
1408
1456
 
1409
1457
  update.push(...local_updates);
@@ -1882,7 +1930,7 @@ const visitors = {
1882
1930
  context.state.template?.push('<!>');
1883
1931
  }
1884
1932
 
1885
- const id = context.state.flush_node?.(is_controlled);
1933
+ const id = context.state.flush_node?.(false, is_controlled);
1886
1934
  const pattern = /** @type {AST.VariableDeclaration} */ (node.left).declarations[0].id;
1887
1935
  const body_scope = /** @type {ScopeInterface} */ (context.state.scopes.get(node.body));
1888
1936
 
@@ -1916,7 +1964,7 @@ const visitors = {
1916
1964
  SwitchStatement(node, context) {
1917
1965
  if (!is_inside_component(context)) {
1918
1966
  if (context.state.to_ts) {
1919
- return transform_ts_child(node, context);
1967
+ return transform_ts_child(node, SetContextForOutsideComponent(context));
1920
1968
  }
1921
1969
 
1922
1970
  return context.next();
@@ -1991,7 +2039,7 @@ const visitors = {
1991
2039
  IfStatement(node, context) {
1992
2040
  if (!is_inside_component(context)) {
1993
2041
  if (context.state.to_ts) {
1994
- return transform_ts_child(node, context);
2042
+ return transform_ts_child(node, SetContextForOutsideComponent(context));
1995
2043
  }
1996
2044
 
1997
2045
  return context.next();
@@ -2390,7 +2438,7 @@ function transform_ts_child(node, context) {
2390
2438
  attr.value === null
2391
2439
  ? b.literal(true)
2392
2440
  : // reset init, update, final to avoid adding attr value to the component body
2393
- visit(attr.value, { ...state, metadata, init: null, update: null, final: null });
2441
+ visit(attr.value, SetStateForOutsideComponent(state, { metadata }));
2394
2442
 
2395
2443
  // Handle both regular identifiers and tracked identifiers
2396
2444
  /** @type {string} */
@@ -2533,7 +2581,12 @@ function transform_ts_child(node, context) {
2533
2581
  );
2534
2582
  }
2535
2583
 
2536
- const result = b.if(/** @type {AST.Expression} */ (visit(node.test)), consequent, alternate);
2584
+ const result = b.if(
2585
+ /** @type {AST.Expression} */ (visit(node.test)),
2586
+ consequent,
2587
+ alternate,
2588
+ /** @type {AST.NodeWithLocation} */ (node),
2589
+ );
2537
2590
  if (!state.init) {
2538
2591
  return result;
2539
2592
  }
@@ -2799,30 +2852,33 @@ function transform_children(children, context) {
2799
2852
  const current_prev = prev;
2800
2853
  /** @type {AST.Identifier | null} */
2801
2854
  let cached;
2802
- /** @param {boolean} [is_controlled] */
2803
- const flush_node = (is_controlled) => {
2855
+ /**
2856
+ * @param {boolean} [is_text]
2857
+ * @param {boolean} [is_controlled]
2858
+ * */
2859
+ const flush_node = (is_text, is_controlled) => {
2804
2860
  if (cached && !is_controlled) {
2805
2861
  return cached;
2806
2862
  } else if (current_prev !== null) {
2807
2863
  const id = get_id(node);
2808
- state.init?.push(b.var(id, b.call('_$_.sibling', current_prev())));
2864
+ state.init?.push(b.var(id, b.call('_$_.sibling', current_prev(), is_text && b.true)));
2809
2865
  cached = id;
2810
2866
  return id;
2811
2867
  } else if (initial !== null) {
2812
2868
  if (is_fragment) {
2813
2869
  const id = get_id(node);
2814
- state.init?.push(b.var(id, b.call('_$_.child_frag', initial)));
2870
+ state.init?.push(b.var(id, b.call('_$_.first_child_frag', initial, is_text && b.true)));
2815
2871
  cached = id;
2816
2872
  return id;
2817
2873
  }
2818
2874
  return initial;
2819
2875
  } else if (state.flush_node !== null) {
2820
2876
  if (is_controlled) {
2821
- return state.flush_node?.();
2877
+ return state.flush_node?.(is_text);
2822
2878
  }
2823
2879
 
2824
2880
  const id = get_id(node);
2825
- state.init?.push(b.var(id, b.call('_$_.child', state.flush_node?.())));
2881
+ state.init?.push(b.var(id, b.call('_$_.child', state.flush_node?.(), is_text && b.true)));
2826
2882
  cached = id;
2827
2883
  return id;
2828
2884
  } else {
@@ -2849,7 +2905,7 @@ function transform_children(children, context) {
2849
2905
  } else if (node.type === 'Html') {
2850
2906
  context.state.template?.push('<!>');
2851
2907
 
2852
- const id = flush_node();
2908
+ const id = flush_node(false);
2853
2909
  state.update?.push({
2854
2910
  operation: () =>
2855
2911
  b.stmt(
@@ -2865,7 +2921,7 @@ function transform_children(children, context) {
2865
2921
  } else if (node.type === 'Text') {
2866
2922
  if (metadata?.tracking) {
2867
2923
  state.template?.push(' ');
2868
- const id = flush_node();
2924
+ const id = flush_node(true);
2869
2925
  state.update?.push({
2870
2926
  operation: (key) => b.stmt(b.call('_$_.set_text', id, key)),
2871
2927
  expression: /** @type {AST.Expression} */ (expression),
@@ -2884,14 +2940,14 @@ function transform_children(children, context) {
2884
2940
  ) {
2885
2941
  state.template?.push(escape_html(expr.value));
2886
2942
  } else {
2887
- const id = flush_node();
2943
+ const id = flush_node(true);
2888
2944
  state.init?.push(
2889
2945
  b.var(/** @type {AST.Identifier} */ (id), b.call('_$_.create_text', expr)),
2890
2946
  );
2891
2947
  state.final?.push(b.stmt(b.call('_$_.append', b.id('__anchor'), id)));
2892
2948
  }
2893
2949
  } else {
2894
- const id = flush_node();
2950
+ const id = flush_node(true);
2895
2951
  state.template?.push(' ');
2896
2952
  // avoid set_text overhead for single text nodes
2897
2953
  state.init?.push(
@@ -2906,16 +2962,22 @@ function transform_children(children, context) {
2906
2962
  }
2907
2963
  } else {
2908
2964
  // Handle Text nodes in fragments
2909
- state.template?.push(' ');
2910
- const id = flush_node();
2911
- state.update?.push({
2912
- operation: (key) => b.stmt(b.call('_$_.set_text', id, key)),
2913
- expression: /** @type {AST.Expression} */ (expression),
2914
- identity: node.expression,
2915
- initial: b.literal(' '),
2916
- });
2917
- if (metadata?.await) {
2918
- /** @type {NonNullable<TransformClientState['update']>} */ (state.update).async = true;
2965
+ const expr = /** @type {AST.Expression} */ (expression);
2966
+ if (expr.type === 'Literal') {
2967
+ state.template?.push(escape_html(expr.value));
2968
+ } else {
2969
+ state.template?.push(' ');
2970
+ const id = flush_node(true);
2971
+ state.update?.push({
2972
+ operation: (key) => b.stmt(b.call('_$_.set_text', id, key)),
2973
+ expression: /** @type {AST.Expression} */ (expression),
2974
+ identity: node.expression,
2975
+ initial: b.literal(' '),
2976
+ });
2977
+ if (metadata?.await) {
2978
+ /** @type {NonNullable<TransformClientState['update']>} */ (state.update).async =
2979
+ true;
2980
+ }
2919
2981
  }
2920
2982
  }
2921
2983
  } else if (node.type === 'ForOfStatement') {
@@ -3815,7 +3877,7 @@ function create_tsx_with_typescript_support(comments) {
3815
3877
  * @param {AnalysisResult} analysis - Analysis result
3816
3878
  * @param {boolean} to_ts - Whether to generate TypeScript output
3817
3879
  * @param {boolean} minify_css - Whether to minify CSS output
3818
- * @returns {{ ast: AST.Program, js: { code: string, map: SourceMapMappings, post_processing_changes?: PostProcessingChanges, line_offsets?: LineOffsets }, css: string, errors: RippleCompileError[]}}
3880
+ * @returns {{ ast: AST.Program, js: { code: string, map: RawSourceMap, post_processing_changes?: PostProcessingChanges, line_offsets?: LineOffsets }, css: string, errors: RippleCompileError[]}}
3819
3881
  */
3820
3882
  export function transform_client(filename, source, analysis, to_ts, minify_css) {
3821
3883
  /** @type {TransformClientState} */
@@ -3851,26 +3913,32 @@ export function transform_client(filename, source, analysis, to_ts, minify_css)
3851
3913
 
3852
3914
  const program = /** @type {AST.Program} */ (walk(analysis.ast, { ...state }, visitors));
3853
3915
 
3854
- for (const hoisted of state.hoisted) {
3855
- program.body.unshift(hoisted);
3856
- }
3916
+ const body = [];
3857
3917
 
3858
3918
  for (const import_node of state.imports) {
3859
3919
  if (typeof import_node === 'string') {
3860
- program.body.unshift(b.stmt(b.id(import_node)));
3920
+ body.push(b.stmt(b.id(import_node)));
3861
3921
  } else {
3862
- program.body.unshift(import_node);
3922
+ body.push(import_node);
3863
3923
  }
3864
3924
  }
3865
3925
 
3926
+ for (const hoisted of state.hoisted) {
3927
+ body.push(hoisted);
3928
+ }
3929
+
3930
+ body.push(...program.body);
3931
+
3866
3932
  if (state.events.size > 0) {
3867
- program.body.push(
3933
+ body.push(
3868
3934
  b.stmt(
3869
3935
  b.call('_$_.delegate', b.array(Array.from(state.events).map((name) => b.literal(name)))),
3870
3936
  ),
3871
3937
  );
3872
3938
  }
3873
3939
 
3940
+ program.body = body;
3941
+
3874
3942
  const language_handler = to_ts
3875
3943
  ? create_tsx_with_typescript_support(analysis.comments)
3876
3944
  : /** @type {Visitors<AST.Node, TransformClientState>} */ (tsx());
@@ -2,7 +2,7 @@
2
2
  @import * as AST from 'estree';
3
3
  @import * as ESTreeJSX from 'estree-jsx';
4
4
  @import { DocumentHighlightKind } from 'vscode-languageserver-types';
5
- @import { SourceMapMappings } from '@jridgewell/sourcemap-codec';
5
+ @import { RawSourceMap } from 'source-map';
6
6
  @import {
7
7
  CustomMappingData,
8
8
  PluginActionOverrides,
@@ -267,7 +267,7 @@ function extract_classes(node, src_to_gen_map, gen_line_offsets, src_line_offset
267
267
  * @param {AST.Node} ast_from_source - The original AST from source
268
268
  * @param {string} source - Original source code
269
269
  * @param {string} generated_code - Generated code (returned in output, not used for searching)
270
- * @param {SourceMapMappings} source_map - Esrap source map for accurate position lookup
270
+ * @param {RawSourceMap} source_map - Esrap source map for accurate position lookup
271
271
  * @param {PostProcessingChanges } post_processing_changes - Optional post-processing changes
272
272
  * @param {number[]} line_offsets - Pre-computed line offsets array for generated code
273
273
  * @returns {Omit<VolarMappingsResult, 'errors'>}
@@ -1,6 +1,5 @@
1
1
  /** @import * as AST from 'estree'; */
2
- /** @import { SourceMapMappings } from '@jridgewell/sourcemap-codec'; */
3
- /** @import { TSESTree } from '@typescript-eslint/types'; */
2
+ /** @import { RawSourceMap } from 'source-map'; */
4
3
  /**
5
4
  @import {
6
5
  TransformServerContext,
@@ -8,7 +7,6 @@
8
7
  Visitors,
9
8
  AnalysisResult,
10
9
  ScopeInterface,
11
- Visitor
12
10
  } from '#compiler' */
13
11
 
14
12
  import * as b from '../../../../utils/builders.js';
@@ -36,6 +34,7 @@ import {
36
34
  CSS_HASH_IDENTIFIER,
37
35
  obfuscate_identifier,
38
36
  } from '../../../identifier-utils.js';
37
+ import { BLOCK_CLOSE, BLOCK_OPEN } from '../../../../constants.js';
39
38
 
40
39
  /**
41
40
  * @param {AST.Node[]} children
@@ -771,6 +770,10 @@ const visitors = {
771
770
  }
772
771
  const body_scope = context.state.scopes.get(node.body);
773
772
 
773
+ context.state.init?.push(
774
+ b.stmt(b.call(b.member(b.id('__output'), b.id('push')), b.literal(BLOCK_OPEN))),
775
+ );
776
+
774
777
  const body = transform_body(/** @type {AST.BlockStatement} */ (node.body).body, {
775
778
  ...context,
776
779
  state: { ...context.state, scope: /** @type {ScopeInterface} */ (body_scope) },
@@ -789,6 +792,10 @@ const visitors = {
789
792
  b.block(body),
790
793
  ),
791
794
  );
795
+
796
+ context.state.init?.push(
797
+ b.stmt(b.call(b.member(b.id('__output'), b.id('push')), b.literal(BLOCK_CLOSE))),
798
+ );
792
799
  },
793
800
 
794
801
  IfStatement(node, context) {
@@ -812,6 +819,10 @@ const visitors = {
812
819
  }),
813
820
  );
814
821
 
822
+ context.state.init?.push(
823
+ b.stmt(b.call(b.member(b.id('__output'), b.id('push')), b.literal(BLOCK_OPEN))),
824
+ );
825
+
815
826
  /** @type {AST.BlockStatement | AST.IfStatement | null} */
816
827
  let alternate = null;
817
828
  if (node.alternate) {
@@ -832,6 +843,10 @@ const visitors = {
832
843
  context.state.init?.push(
833
844
  b.if(/** @type {AST.Expression} */ (context.visit(node.test)), consequent, alternate),
834
845
  );
846
+
847
+ context.state.init?.push(
848
+ b.stmt(b.call(b.member(b.id('__output'), b.id('push')), b.literal(BLOCK_CLOSE))),
849
+ );
835
850
  },
836
851
 
837
852
  AssignmentExpression(node, context) {
@@ -1225,7 +1240,7 @@ const visitors = {
1225
1240
  * @param {string} source
1226
1241
  * @param {AnalysisResult} analysis
1227
1242
  * @param {boolean} minify_css
1228
- * @returns {{ ast: AST.Program; js: { code: string; map: SourceMapMappings | null }; css: string; }}
1243
+ * @returns {{ ast: AST.Program; js: { code: string; map: RawSourceMap | null }; css: string; }}
1229
1244
  */
1230
1245
  export function transform_server(filename, source, analysis, minify_css) {
1231
1246
  // Use component metadata collected during the analyze phase
@@ -3,6 +3,7 @@
3
3
  @import * as AST from 'estree';
4
4
  @import { CodeMapping } from 'ripple/compiler';
5
5
  @import { CodeMapping as VolarCodeMapping } from '@volar/language-core';
6
+ @import { RawSourceMap } from 'source-map';
6
7
  */
7
8
 
8
9
  /**
@@ -72,7 +73,7 @@ export const offset_to_line_col = (offset, line_offsets) => {
72
73
  /**
73
74
  * Build a source-to-generated position lookup map from an esrap source map
74
75
  * Applies post-processing adjustments during map building for efficiency
75
- * @param {object} source_map - The source map object from esrap (v3 format)
76
+ * @param {RawSourceMap} source_map - The source map object from esrap (v3 format)
76
77
  * @param {PostProcessingChanges} post_processing_changes - Optional post-processing changes to apply
77
78
  * @param {LineOffsets} line_offsets - Pre-computed line offsets array
78
79
  * @param {string} generated_code - The final generated code (after post-processing)
@@ -90,7 +91,6 @@ export function build_src_to_gen_map(
90
91
  const reverse_map = new Map();
91
92
 
92
93
  // Decode the VLQ-encoded mappings string
93
- // @ts-ignore
94
94
  const decoded = decode(source_map.mappings);
95
95
 
96
96
  /**
@@ -1189,7 +1189,7 @@ export interface TransformClientState extends BaseState {
1189
1189
  events: Set<string>;
1190
1190
  filename: string;
1191
1191
  final: Array<AST.Statement> | null;
1192
- flush_node: ((is_controlled?: boolean) => AST.Identifier) | null;
1192
+ flush_node: ((is_text?: boolean, is_controlled?: boolean) => AST.Identifier) | null;
1193
1193
  hoisted: Array<AST.Statement>;
1194
1194
  imports: Set<string | AST.ImportDeclaration>;
1195
1195
  server_block_locals: AST.VariableDeclaration[];
@@ -14,8 +14,8 @@ import type * as acorn from 'acorn';
14
14
  import type * as AST from 'estree';
15
15
  import type * as ESTreeJSX from 'estree-jsx';
16
16
  import type * as ESRap from 'esrap';
17
- import type * as SourceMap from '@jridgewell/sourcemap-codec';
18
17
  import type * as RippleCompiler from '#compiler';
18
+ import type { RawSourceMap } from 'source-map';
19
19
  import type { RippleCompileError } from 'ripple/compiler';
20
20
 
21
21
  type ForInit = boolean | 'await';
@@ -42,7 +42,7 @@ declare module 'esrap' {
42
42
  ast: AST.Node,
43
43
  visitors: V,
44
44
  options?: ESRap.PrintOptions,
45
- ): { code: string; map: SourceMap.SourceMapMappings };
45
+ ): { code: string; map: RawSourceMap };
46
46
  }
47
47
 
48
48
  declare module 'esrap/languages/tsx' {
package/src/constants.js CHANGED
@@ -4,3 +4,18 @@ export const IS_CONTROLLED = 1 << 2;
4
4
  export const IS_INDEXED = 1 << 3;
5
5
  export const TEMPLATE_SVG_NAMESPACE = 1 << 5;
6
6
  export const TEMPLATE_MATHML_NAMESPACE = 1 << 6;
7
+
8
+ export const HYDRATION_START = '[';
9
+ export const HYDRATION_START_ELSE = '[!';
10
+ export const HYDRATION_END = ']';
11
+ export const HYDRATION_ERROR = {};
12
+
13
+ export const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
14
+ export const BLOCK_OPEN_ELSE = `<!--${HYDRATION_START_ELSE}-->`;
15
+ export const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
16
+ export const EMPTY_COMMENT = `<!---->`;
17
+
18
+ export const ELEMENT_NODE = 1;
19
+ export const TEXT_NODE = 3;
20
+ export const COMMENT_NODE = 8;
21
+ export const DOCUMENT_FRAGMENT_NODE = 11;