ripple 0.2.121 → 0.2.125
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/package.json +1 -1
- package/src/compiler/index.js +1 -1
- package/src/compiler/phases/1-parse/index.js +1 -0
- package/src/compiler/phases/2-analyze/index.js +66 -32
- package/src/compiler/phases/3-transform/client/index.js +19 -0
- package/src/compiler/phases/3-transform/server/index.js +50 -37
- package/src/runtime/internal/client/composite.js +2 -4
- package/src/runtime/internal/client/script.js +1 -1
- package/src/runtime/internal/server/index.js +22 -13
- package/src/utils/builders.js +2 -2
- package/tests/client/__snapshots__/for.test.ripple.snap +0 -80
- package/tests/client/basic/__snapshots__/basic.rendering.test.ripple.snap +0 -48
- package/tests/client/basic/basic.errors.test.ripple +16 -0
- package/tests/client/basic/basic.get-set.test.ripple +291 -0
- package/tests/client/dynamic-elements.test.ripple +210 -8
- package/tests/server/await.test.ripple +61 -0
- package/tests/server/for.test.ripple +44 -0
- package/tests/server/if.test.ripple +21 -1
- package/tests/utils/escaping.test.js +102 -0
- package/tests/utils/events.test.js +147 -0
- package/tests/utils/normalize_css_property_name.test.js +43 -0
- package/tests/utils/patterns.test.js +382 -0
- package/tests/utils/sanitize_template_string.test.js +51 -0
- package/types/server.d.ts +25 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { sanitize_template_string } from '../../src/utils/sanitize_template_string.js';
|
|
3
|
+
|
|
4
|
+
describe('sanitize_template_string utility', () => {
|
|
5
|
+
it('should escape backticks', () => {
|
|
6
|
+
expect(sanitize_template_string('hello `world`')).toBe('hello \\`world\\`');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('should escape dollar brace sequences', () => {
|
|
10
|
+
expect(sanitize_template_string('hello ${world}')).toBe('hello \\${world}');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should escape backslashes', () => {
|
|
14
|
+
expect(sanitize_template_string('hello \\ world')).toBe('hello \\\\ world');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should escape all special characters together', () => {
|
|
18
|
+
expect(sanitize_template_string('`${test}\\`')).toBe('\\`\\${test}\\\\\\`');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should handle strings with no special characters', () => {
|
|
22
|
+
expect(sanitize_template_string('hello world')).toBe('hello world');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should handle empty strings', () => {
|
|
26
|
+
expect(sanitize_template_string('')).toBe('');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should escape multiple backticks', () => {
|
|
30
|
+
expect(sanitize_template_string('```')).toBe('\\`\\`\\`');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should escape multiple dollar braces', () => {
|
|
34
|
+
expect(sanitize_template_string('${a}${b}${c}')).toBe('\\${a}\\${b}\\${c}');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should escape multiple backslashes', () => {
|
|
38
|
+
expect(sanitize_template_string('\\\\\\')).toBe('\\\\\\\\\\\\');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should handle mixed content', () => {
|
|
42
|
+
expect(sanitize_template_string('Path: C:\\Users\\${name}`')).toBe('Path: C:\\\\Users\\\\\\${name}\\`');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should handle complex template literals', () => {
|
|
46
|
+
const input = 'const str = `Hello ${name}, path: \\${root}\\`';
|
|
47
|
+
const expected = 'const str = \\`Hello \\${name}, path: \\\\\\${root}\\\\\\`';
|
|
48
|
+
expect(sanitize_template_string(input)).toBe(expected);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
package/types/server.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
+
import type { Props } from '#public'
|
|
1
2
|
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export interface SSRRenderOutput {
|
|
4
|
+
head: string;
|
|
5
|
+
body: string;
|
|
6
|
+
css: Set<string>;
|
|
7
|
+
push(chunk: string): void;
|
|
8
|
+
register_css(hash: string): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SSRComponent {
|
|
12
|
+
(output: SSRRenderOutput, props?: Props): void | Promise<void>;
|
|
13
|
+
async?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SSRRenderResult {
|
|
17
|
+
head: string;
|
|
18
|
+
body: string;
|
|
19
|
+
css: Set<string>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type SSRRender = (component: SSRComponent) => Promise<SSRRenderResult>;
|
|
23
|
+
|
|
24
|
+
export declare function render(
|
|
25
|
+
component: SSRComponent,
|
|
26
|
+
): Promise<SSRRenderResult>;
|