ripple 0.3.5 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # ripple
2
2
 
3
+ ## 0.3.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - ripple@0.3.6
9
+
3
10
  ## 0.3.5
4
11
 
5
12
  ### Patch Changes
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.3.5",
6
+ "version": "0.3.6",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index-client.js",
9
9
  "main": "src/runtime/index-client.js",
@@ -105,6 +105,6 @@
105
105
  "vscode-languageserver-types": "^3.17.5"
106
106
  },
107
107
  "peerDependencies": {
108
- "ripple": "0.3.5"
108
+ "ripple": "0.3.6"
109
109
  }
110
110
  }
@@ -1,5 +1,5 @@
1
1
  // Basic static components for hydration testing
2
- import type { Component } from 'ripple';
2
+ import type { Children } from 'ripple';
3
3
 
4
4
  export component StaticText() {
5
5
  <div>{'Hello World'}</div>
@@ -97,7 +97,7 @@ component Actions({ playgroundVisible = false }: { playgroundVisible: boolean })
97
97
  </div>
98
98
  }
99
99
 
100
- component Layout({ children }: { children: Component }) {
100
+ component Layout({ children }: { children: Children }) {
101
101
  <main>
102
102
  <div class="container">
103
103
  <children />
@@ -1,6 +1,6 @@
1
- import type { Component } from 'ripple';
1
+ import type { Children } from 'ripple';
2
2
 
3
- export component Layout(&{ children }: { children?: Component }) {
3
+ export component Layout(&{ children }: { children?: Children }) {
4
4
  <div class="layout">
5
5
  <children />
6
6
  </div>
@@ -0,0 +1,98 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { ripple } from '@ripple-ts/vite-plugin';
3
+
4
+ describe('vite-plugin-ripple hotUpdate', () => {
5
+ it('invalidates SSR modules for non-self-accepting .ripple files', async () => {
6
+ const [plugin] = ripple({ excludeRippleExternalModules: true });
7
+ await plugin.configResolved?.({ root: '/workspace', command: 'serve' });
8
+
9
+ const transform_request = vi.fn().mockResolvedValue(undefined);
10
+ const get_css_module = vi.fn().mockReturnValue(undefined);
11
+ const invalidate_css_module = vi.fn();
12
+ const send_hot_update = vi.fn();
13
+ const get_ssr_modules = vi.fn().mockReturnValue(new Set([{ id: 'ssr:a' }, { id: 'ssr:b' }]));
14
+ const invalidate_ssr_module = vi.fn();
15
+
16
+ const result = await plugin.hotUpdate.handler.call(
17
+ {
18
+ environment: {
19
+ name: 'client',
20
+ transformRequest: transform_request,
21
+ moduleGraph: {
22
+ getModuleById: get_css_module,
23
+ invalidateModule: invalidate_css_module,
24
+ },
25
+ hot: {
26
+ send: send_hot_update,
27
+ },
28
+ },
29
+ },
30
+ {
31
+ file: '/workspace/src/non-component.ripple',
32
+ modules: [{ id: 'client:non-component', isSelfAccepting: false }],
33
+ server: {
34
+ environments: {
35
+ ssr: {
36
+ moduleGraph: {
37
+ getModulesByFile: get_ssr_modules,
38
+ invalidateModule: invalidate_ssr_module,
39
+ },
40
+ },
41
+ },
42
+ },
43
+ },
44
+ );
45
+
46
+ expect(transform_request).toHaveBeenCalledWith('/src/non-component.ripple');
47
+ expect(get_ssr_modules).toHaveBeenCalledWith('/workspace/src/non-component.ripple');
48
+ expect(invalidate_ssr_module).toHaveBeenCalledTimes(2);
49
+ expect(send_hot_update).toHaveBeenCalledWith({ type: 'full-reload' });
50
+ expect(result).toEqual([]);
51
+ });
52
+
53
+ it('keeps self-accepting .ripple files on Vite HMR path', async () => {
54
+ const [plugin] = ripple({ excludeRippleExternalModules: true });
55
+ await plugin.configResolved?.({ root: '/workspace', command: 'serve' });
56
+
57
+ const transform_request = vi.fn().mockResolvedValue(undefined);
58
+ const get_ssr_modules = vi.fn();
59
+ const invalidate_ssr_module = vi.fn();
60
+ const send_hot_update = vi.fn();
61
+
62
+ const result = await plugin.hotUpdate.handler.call(
63
+ {
64
+ environment: {
65
+ name: 'client',
66
+ transformRequest: transform_request,
67
+ moduleGraph: {
68
+ getModuleById: vi.fn().mockReturnValue(undefined),
69
+ invalidateModule: vi.fn(),
70
+ },
71
+ hot: {
72
+ send: send_hot_update,
73
+ },
74
+ },
75
+ },
76
+ {
77
+ file: '/workspace/src/component.ripple',
78
+ modules: [{ id: 'client:component', isSelfAccepting: true }],
79
+ server: {
80
+ environments: {
81
+ ssr: {
82
+ moduleGraph: {
83
+ getModulesByFile: get_ssr_modules,
84
+ invalidateModule: invalidate_ssr_module,
85
+ },
86
+ },
87
+ },
88
+ },
89
+ },
90
+ );
91
+
92
+ expect(transform_request).toHaveBeenCalledWith('/src/component.ripple');
93
+ expect(get_ssr_modules).not.toHaveBeenCalled();
94
+ expect(invalidate_ssr_module).not.toHaveBeenCalled();
95
+ expect(send_hot_update).not.toHaveBeenCalled();
96
+ expect(result).toBeUndefined();
97
+ });
98
+ });
package/types/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  export type Component<T = Record<string, any>> = (props: T) => void;
2
2
 
3
+ /** Type for JSX children - accepts single child, multiple children, or no children */
4
+ export type Children = Component | readonly Component[];
5
+
3
6
  export type CompatApi = {
4
7
  createRoot: () => void;
5
8
  createComponent: (node: any, children_fn: () => any) => void;
@@ -159,10 +162,10 @@ export type InferComponent<T> = T extends () => infer R ? (R extends Component<a
159
162
  export type Props<K extends PropertyKey = any, V = unknown> = Record<K, V>;
160
163
  export type PropsWithExtras<T extends object> = Props & T & Record<string, unknown>;
161
164
  export type PropsWithChildren<T extends object = {}> = Expand<
162
- Omit<T, 'children'> & { children: Component }
165
+ Omit<T, 'children'> & { children: Children }
163
166
  >;
164
167
  export type PropsWithChildrenOptional<T extends object = {}> = Expand<
165
- Omit<T, 'children'> & { children?: Component }
168
+ Omit<T, 'children'> & { children?: Children }
166
169
  >;
167
170
  export type PropsNoChildren<T extends object = {}> = Expand<T>;
168
171
 
@@ -383,10 +386,10 @@ export const MediaQuery: MediaQueryConstructor;
383
386
 
384
387
  export function Portal<V = HTMLElement>({
385
388
  target,
386
- children: Component,
389
+ children,
387
390
  }: {
388
391
  target: V;
389
- children?: Component;
392
+ children?: Children;
390
393
  }): void;
391
394
 
392
395
  export type GetFunction<V> = () => V;