ripple 0.3.13 → 0.3.14
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 +21 -0
- package/package.json +5 -30
- package/src/runtime/array.js +38 -38
- package/src/runtime/create-subscriber.js +2 -2
- package/src/runtime/internal/client/bindings.js +4 -6
- package/src/runtime/internal/client/events.js +8 -3
- package/src/runtime/internal/client/hmr.js +5 -17
- package/src/runtime/internal/client/runtime.js +1 -0
- package/src/runtime/internal/server/blocks.js +7 -9
- package/src/runtime/internal/server/index.js +14 -22
- package/src/runtime/media-query.js +34 -33
- package/src/runtime/object.js +7 -10
- package/src/runtime/proxy.js +2 -3
- package/src/runtime/reactive-value.js +23 -21
- package/src/utils/ast.js +1 -1
- package/src/utils/attributes.js +43 -0
- package/src/utils/builders.js +2 -2
- package/tests/client/basic/basic.errors.test.rsrx +1 -1
- package/tests/client/basic/basic.styling.test.rsrx +1 -1
- package/tests/client/compiler/compiler.assignments.test.rsrx +1 -1
- package/tests/client/compiler/compiler.attributes.test.rsrx +1 -1
- package/tests/client/compiler/compiler.basic.test.rsrx +13 -13
- package/tests/client/compiler/compiler.tracked-access.test.rsrx +1 -1
- package/tests/client/compiler/compiler.try-in-function.test.rsrx +1 -1
- package/tests/client/compiler/compiler.typescript.test.rsrx +1 -1
- package/tests/client/css/global-additional-cases.test.rsrx +1 -1
- package/tests/client/css/global-advanced-selectors.test.rsrx +1 -1
- package/tests/client/css/global-at-rules.test.rsrx +1 -1
- package/tests/client/css/global-basic.test.rsrx +1 -1
- package/tests/client/css/global-classes-ids.test.rsrx +1 -1
- package/tests/client/css/global-combinators.test.rsrx +1 -1
- package/tests/client/css/global-complex-nesting.test.rsrx +1 -1
- package/tests/client/css/global-edge-cases.test.rsrx +1 -1
- package/tests/client/css/global-keyframes.test.rsrx +1 -1
- package/tests/client/css/global-nested.test.rsrx +1 -1
- package/tests/client/css/global-pseudo.test.rsrx +1 -1
- package/tests/client/css/global-scoping.test.rsrx +1 -1
- package/tests/client/css/style-identifier.test.rsrx +1 -1
- package/tests/client/return.test.rsrx +1 -1
- package/tests/hydration/build-components.js +1 -1
- package/tests/server/style-identifier.test.rsrx +1 -1
- package/tests/setup-server.js +1 -1
- package/tests/utils/compiler-compat-config.test.js +1 -1
- package/src/compiler/comment-utils.js +0 -91
- package/src/compiler/errors.js +0 -77
- package/src/compiler/identifier-utils.js +0 -80
- package/src/compiler/index.d.ts +0 -127
- package/src/compiler/index.js +0 -89
- package/src/compiler/phases/1-parse/index.js +0 -3007
- package/src/compiler/phases/1-parse/style.js +0 -704
- package/src/compiler/phases/2-analyze/css-analyze.js +0 -160
- package/src/compiler/phases/2-analyze/index.js +0 -2208
- package/src/compiler/phases/2-analyze/prune.js +0 -1131
- package/src/compiler/phases/2-analyze/validation.js +0 -168
- package/src/compiler/phases/3-transform/client/index.js +0 -5264
- package/src/compiler/phases/3-transform/segments.js +0 -2125
- package/src/compiler/phases/3-transform/server/index.js +0 -1749
- package/src/compiler/phases/3-transform/stylesheet.js +0 -545
- package/src/compiler/scope.js +0 -476
- package/src/compiler/source-map-utils.js +0 -358
- package/src/compiler/types/acorn.d.ts +0 -11
- package/src/compiler/types/estree-jsx.d.ts +0 -11
- package/src/compiler/types/estree.d.ts +0 -11
- package/src/compiler/types/index.d.ts +0 -1411
- package/src/compiler/types/parse.d.ts +0 -1723
- package/src/compiler/utils.js +0 -1258
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { parse, compile, compile_to_volar_mappings } from 'ripple
|
|
2
|
-
import {
|
|
1
|
+
import { parse, compile, compile_to_volar_mappings } from '@tsrx/ripple';
|
|
2
|
+
import { obfuscateIdentifier } from '@tsrx/core';
|
|
3
3
|
import type * as AST from 'estree';
|
|
4
4
|
|
|
5
5
|
function count_occurrences(string: string, subString: string): number {
|
|
@@ -59,7 +59,7 @@ describe('compiler > basics', () => {
|
|
|
59
59
|
const explicit_text = elements[1].children[0] as AST.TextNode;
|
|
60
60
|
|
|
61
61
|
expect(elements).toHaveLength(2);
|
|
62
|
-
expect(expression.type).toBe('
|
|
62
|
+
expect(expression.type).toBe('TSRXExpression');
|
|
63
63
|
expect((expression.expression as AST.Identifier).name).toBe('markup');
|
|
64
64
|
expect(explicit_text.type).toBe('Text');
|
|
65
65
|
expect((explicit_text.expression as AST.Identifier).name).toBe('markup');
|
|
@@ -321,15 +321,15 @@ describe('compiler > basics', () => {
|
|
|
321
321
|
// `;
|
|
322
322
|
// const result = compile_to_volar_mappings(source, 'test.ripple').code;
|
|
323
323
|
|
|
324
|
-
// expect(count_occurrences(result,
|
|
324
|
+
// expect(count_occurrences(result, obfuscateIdentifier('RippleArray'))).toBe(2);
|
|
325
325
|
// expect(count_occurrences(result, 'TA')).toBe(1);
|
|
326
|
-
// expect(count_occurrences(result,
|
|
326
|
+
// expect(count_occurrences(result, obfuscateIdentifier('RippleObject'))).toBe(2);
|
|
327
327
|
// expect(count_occurrences(result, 'TO')).toBe(1);
|
|
328
|
-
// expect(count_occurrences(result,
|
|
328
|
+
// expect(count_occurrences(result, obfuscateIdentifier('RippleSet'))).toBe(2);
|
|
329
329
|
// expect(count_occurrences(result, 'TS')).toBe(1);
|
|
330
|
-
// expect(count_occurrences(result,
|
|
330
|
+
// expect(count_occurrences(result, obfuscateIdentifier('RippleMap'))).toBe(2);
|
|
331
331
|
// expect(count_occurrences(result, 'TM')).toBe(1);
|
|
332
|
-
// expect(count_occurrences(result,
|
|
332
|
+
// expect(count_occurrences(result, obfuscateIdentifier('createRefKey'))).toBe(2);
|
|
333
333
|
// expect(count_occurrences(result, 'crk')).toBe(1);
|
|
334
334
|
// },
|
|
335
335
|
// );
|
|
@@ -347,11 +347,11 @@ describe('compiler > basics', () => {
|
|
|
347
347
|
// `;
|
|
348
348
|
// const result = compile_to_volar_mappings(source, 'test.ripple').code;
|
|
349
349
|
|
|
350
|
-
// expect(count_occurrences(result,
|
|
351
|
-
// expect(count_occurrences(result,
|
|
352
|
-
// expect(count_occurrences(result,
|
|
353
|
-
// expect(count_occurrences(result,
|
|
354
|
-
// expect(count_occurrences(result,
|
|
350
|
+
// expect(count_occurrences(result, obfuscateIdentifier('RippleArray'))).toBe(2);
|
|
351
|
+
// expect(count_occurrences(result, obfuscateIdentifier('RippleObject'))).toBe(2);
|
|
352
|
+
// expect(count_occurrences(result, obfuscateIdentifier('RippleSet'))).toBe(2);
|
|
353
|
+
// expect(count_occurrences(result, obfuscateIdentifier('RippleMap'))).toBe(2);
|
|
354
|
+
// expect(count_occurrences(result, obfuscateIdentifier('createRefKey'))).toBe(2);
|
|
355
355
|
// });
|
|
356
356
|
|
|
357
357
|
it('prints longhand tracked property values in to_ts output while preserving [\'#v\']', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { flushSync, track } from 'ripple';
|
|
3
|
-
import { compile } from 'ripple
|
|
3
|
+
import { compile } from '@tsrx/ripple';
|
|
4
4
|
|
|
5
5
|
describe('returns in prohibited scopes', () => {
|
|
6
6
|
it('throws error when return is used in module scope', () => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Or used as vitest globalSetup
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { compile } from 'ripple
|
|
7
|
+
import { compile } from '@tsrx/ripple';
|
|
8
8
|
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'fs';
|
|
9
9
|
import { join, basename } from 'path';
|
|
10
10
|
import { fileURLToPath } from 'url';
|
package/tests/setup-server.js
CHANGED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import * as AST from 'estree'
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Check if a comment is a TypeScript pragma (line comment)
|
|
7
|
-
* @param {AST.CommentWithLocation} comment
|
|
8
|
-
* @returns {boolean}
|
|
9
|
-
*/
|
|
10
|
-
export function is_ts_pragma(comment) {
|
|
11
|
-
if (comment.type !== 'Line') return false;
|
|
12
|
-
|
|
13
|
-
const pragmas = ['@ts-ignore', '@ts-expect-error', '@ts-nocheck', '@ts-check'];
|
|
14
|
-
return pragmas.some((pragma) => comment.value.trimStart().startsWith(pragma));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Check if a comment is a triple-slash directive
|
|
19
|
-
* /// <reference path="..." />
|
|
20
|
-
* @param {AST.CommentWithLocation} comment
|
|
21
|
-
* @returns {boolean}
|
|
22
|
-
*/
|
|
23
|
-
export function is_triple_slash_directive(comment) {
|
|
24
|
-
if (comment.type !== 'Line') return false;
|
|
25
|
-
|
|
26
|
-
// Triple slash directives start with / after the // is stripped
|
|
27
|
-
// So the value should start with / followed by <reference, <amd-module, or <amd-dependency
|
|
28
|
-
const value = comment.value.trim();
|
|
29
|
-
return /^\/\s*<(reference|amd-module|amd-dependency)/.test(value);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Check if a comment is a JSDoc comment with TypeScript annotations
|
|
34
|
-
* Examples: block comments containing `@type`, `@typedef`, `@param`, `@returns`, etc.
|
|
35
|
-
* @param {AST.CommentWithLocation} comment
|
|
36
|
-
* @returns {boolean}
|
|
37
|
-
*/
|
|
38
|
-
export function is_jsdoc_ts_annotation(comment) {
|
|
39
|
-
if (comment.type !== 'Block') return false;
|
|
40
|
-
|
|
41
|
-
// JSDoc comments start with /** which means the value starts with * after /* is stripped
|
|
42
|
-
if (!comment.value.startsWith('*')) return false;
|
|
43
|
-
|
|
44
|
-
// Check if it contains TypeScript-relevant tags
|
|
45
|
-
const tsAnnotations = [
|
|
46
|
-
'@type',
|
|
47
|
-
'@typedef',
|
|
48
|
-
'@param',
|
|
49
|
-
'@returns',
|
|
50
|
-
'@template',
|
|
51
|
-
'@extends',
|
|
52
|
-
'@implements',
|
|
53
|
-
'@satisfies',
|
|
54
|
-
'@overload',
|
|
55
|
-
'@import',
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
return tsAnnotations.some((annotation) => comment.value.includes(annotation));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Check if a comment should be preserved in to_ts mode
|
|
63
|
-
* @param {AST.CommentWithLocation} comment
|
|
64
|
-
* @returns {boolean}
|
|
65
|
-
*/
|
|
66
|
-
export function should_preserve_comment(comment) {
|
|
67
|
-
return (
|
|
68
|
-
is_ts_pragma(comment) || is_triple_slash_directive(comment) || is_jsdoc_ts_annotation(comment)
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Format a comment for output
|
|
74
|
-
* @param {AST.CommentWithLocation} comment
|
|
75
|
-
* @returns {string}
|
|
76
|
-
*/
|
|
77
|
-
export function format_comment(comment) {
|
|
78
|
-
if (comment.type === 'Line') {
|
|
79
|
-
// Check if it's a triple-slash directive (value starts with /)
|
|
80
|
-
if (comment.value.trimStart().startsWith('/')) {
|
|
81
|
-
return `/// ${comment.value.trimStart().slice(1)}`;
|
|
82
|
-
}
|
|
83
|
-
return `// ${comment.value.trim()}`;
|
|
84
|
-
} else {
|
|
85
|
-
// Block comment - check if it's a JSDoc (value starts with *)
|
|
86
|
-
if (comment.value.startsWith('*')) {
|
|
87
|
-
return `/** ${comment.value.trim().slice(1)} */`;
|
|
88
|
-
}
|
|
89
|
-
return `/* ${comment.value.trim()} */`;
|
|
90
|
-
}
|
|
91
|
-
}
|
package/src/compiler/errors.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@import * as AST from 'estree';
|
|
3
|
-
@import { RippleCompileError } from 'ripple/compiler';
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {string} message
|
|
9
|
-
* @param {string | null} filename
|
|
10
|
-
* @param {AST.Node | AST.NodeWithLocation} node
|
|
11
|
-
* @param {RippleCompileError[]} [errors]
|
|
12
|
-
* @param {AST.CommentWithLocation[]} [comments]
|
|
13
|
-
* @returns {void}
|
|
14
|
-
*/
|
|
15
|
-
export function error(message, filename, node, errors, comments) {
|
|
16
|
-
if (errors && comments && is_ripple_error_suppressed(node, comments)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const error = /** @type {RippleCompileError} */ (new Error(message));
|
|
21
|
-
|
|
22
|
-
// same as the acorn compiler error
|
|
23
|
-
error.pos = node.start ?? undefined;
|
|
24
|
-
error.raisedAt = node.end ?? undefined;
|
|
25
|
-
|
|
26
|
-
// custom properties
|
|
27
|
-
error.fileName = filename;
|
|
28
|
-
error.end = node.end ?? undefined;
|
|
29
|
-
error.loc = !node.loc
|
|
30
|
-
? undefined
|
|
31
|
-
: {
|
|
32
|
-
start: {
|
|
33
|
-
line: node.loc.start.line,
|
|
34
|
-
column: node.loc.start.column,
|
|
35
|
-
},
|
|
36
|
-
end: {
|
|
37
|
-
line: node.loc.end.line,
|
|
38
|
-
column: node.loc.end.column,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
if (errors) {
|
|
43
|
-
error.type = 'usage';
|
|
44
|
-
errors.push(error);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
error.type = 'fatal';
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @param {AST.CommentWithLocation} comment
|
|
54
|
-
* @return {boolean}
|
|
55
|
-
*/
|
|
56
|
-
function is_ripple_error_suppress_comment(comment) {
|
|
57
|
-
const text = comment.value.trim();
|
|
58
|
-
return text.startsWith('@ripple-ignore') || text.startsWith('@ripple-expect-error');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @param {AST.Node | AST.NodeWithLocation} node
|
|
63
|
-
* @param {AST.CommentWithLocation[]} comments
|
|
64
|
-
*/
|
|
65
|
-
function is_ripple_error_suppressed(node, comments) {
|
|
66
|
-
if (node.loc) {
|
|
67
|
-
const node_start_line = node.loc.start.line;
|
|
68
|
-
for (const comment of comments) {
|
|
69
|
-
if (comment.type === 'Line' && comment.loc.start.line === node_start_line - 1) {
|
|
70
|
-
if (is_ripple_error_suppress_comment(comment)) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export const IDENTIFIER_OBFUSCATION_PREFIX = '_$_';
|
|
2
|
-
export const STYLE_IDENTIFIER = IDENTIFIER_OBFUSCATION_PREFIX + encode_utf16_char('#') + 'style';
|
|
3
|
-
export const SERVER_IDENTIFIER = IDENTIFIER_OBFUSCATION_PREFIX + encode_utf16_char('#') + 'server';
|
|
4
|
-
export const CSS_HASH_IDENTIFIER = IDENTIFIER_OBFUSCATION_PREFIX + 'hash';
|
|
5
|
-
|
|
6
|
-
const DECODE_UTF16_REGEX = /_u([0-9a-fA-F]{4})_/g;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {string} char
|
|
10
|
-
* @returns {string}
|
|
11
|
-
*/
|
|
12
|
-
function encode_utf16_char(char) {
|
|
13
|
-
return `_u${('0000' + char.charCodeAt(0).toString(16)).slice(-4)}_`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Finds the next uppercase character or returns name.length
|
|
18
|
-
* @param {string} name
|
|
19
|
-
* @param {number} start
|
|
20
|
-
* @returns {number}
|
|
21
|
-
*/
|
|
22
|
-
function find_next_uppercase(name, start) {
|
|
23
|
-
for (let i = start; i < name.length; i++) {
|
|
24
|
-
if (name[i] === name[i].toUpperCase()) {
|
|
25
|
-
return i;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return name.length;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @param {string} encoded
|
|
33
|
-
* @returns {string}
|
|
34
|
-
*/
|
|
35
|
-
function decode_utf16_string(encoded) {
|
|
36
|
-
return encoded.replace(DECODE_UTF16_REGEX, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @param {string} name
|
|
41
|
-
* @returns {string}
|
|
42
|
-
*/
|
|
43
|
-
export function obfuscate_identifier(name) {
|
|
44
|
-
const first_char = name[0];
|
|
45
|
-
let start = 0;
|
|
46
|
-
if (first_char === '@' || first_char === '#') {
|
|
47
|
-
const encoded = encode_utf16_char(first_char);
|
|
48
|
-
name = encoded + name.slice(1);
|
|
49
|
-
start = encoded.length;
|
|
50
|
-
} else if (first_char === first_char.toUpperCase()) {
|
|
51
|
-
start = 1;
|
|
52
|
-
}
|
|
53
|
-
const index = find_next_uppercase(name, start);
|
|
54
|
-
|
|
55
|
-
const first_part = name.slice(0, index);
|
|
56
|
-
const second_part = name.slice(index);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
IDENTIFIER_OBFUSCATION_PREFIX +
|
|
60
|
-
(second_part ? second_part + '__' + first_part : first_part + '__')
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {string} name
|
|
66
|
-
* @returns {boolean}
|
|
67
|
-
*/
|
|
68
|
-
export function is_identifier_obfuscated(name) {
|
|
69
|
-
return name.startsWith(IDENTIFIER_OBFUSCATION_PREFIX);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @param {string} name
|
|
74
|
-
* @returns {string}
|
|
75
|
-
*/
|
|
76
|
-
export function deobfuscate_identifier(name) {
|
|
77
|
-
name = name.replaceAll(IDENTIFIER_OBFUSCATION_PREFIX, '');
|
|
78
|
-
const parts = name.split('__');
|
|
79
|
-
return decode_utf16_string((parts[1] ? parts[1] : '') + parts[0]);
|
|
80
|
-
}
|
package/src/compiler/index.d.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import type * as AST from 'estree';
|
|
2
|
-
import type {
|
|
3
|
-
CodeInformation as VolarCodeInformation,
|
|
4
|
-
Mapping as VolarMapping,
|
|
5
|
-
} from '@volar/language-core';
|
|
6
|
-
import type { DocumentHighlightKind } from 'vscode-languageserver-types';
|
|
7
|
-
import type { RawSourceMap } from 'source-map';
|
|
8
|
-
|
|
9
|
-
// ============================================================================
|
|
10
|
-
// Compiler API Exports
|
|
11
|
-
// ============================================================================
|
|
12
|
-
/**
|
|
13
|
-
* Result of compilation operation
|
|
14
|
-
*/
|
|
15
|
-
export interface CompileResult {
|
|
16
|
-
/** The transformed AST */
|
|
17
|
-
ast: AST.Program;
|
|
18
|
-
/** The generated JavaScript code with source map */
|
|
19
|
-
js: {
|
|
20
|
-
code: string;
|
|
21
|
-
map: RawSourceMap;
|
|
22
|
-
};
|
|
23
|
-
/** The generated CSS */
|
|
24
|
-
css: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface DefinitionLocation {
|
|
28
|
-
embeddedId: string; // e.g., 'style_0', 'style_1'
|
|
29
|
-
start: number; // start offset
|
|
30
|
-
end: number; // end offset
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface PluginActionOverrides {
|
|
34
|
-
/** Whether to enable word document highlighting for this mapping */
|
|
35
|
-
wordHighlight?: {
|
|
36
|
-
kind: DocumentHighlightKind;
|
|
37
|
-
};
|
|
38
|
-
/** TypeScript diagnostic codes to suppress for this mapping */
|
|
39
|
-
suppressedDiagnostics?: number[];
|
|
40
|
-
/** Custom hover documentation for this mapping, false to disable */
|
|
41
|
-
hover?: string | false | ((content: string) => string);
|
|
42
|
-
/** Custom definition info for this mapping, false to disable */
|
|
43
|
-
definition?:
|
|
44
|
-
| {
|
|
45
|
-
description?: string; // just for reference
|
|
46
|
-
// Generic location for embedded content (CSS, etc.)
|
|
47
|
-
location?: DefinitionLocation;
|
|
48
|
-
// Replace the type name in hover/definition with a different name
|
|
49
|
-
// And provide the path to import the type definitions from
|
|
50
|
-
// the `ripple` package directory, e.g. `types/index.d.ts`
|
|
51
|
-
// Currently only supported by the definition plugin
|
|
52
|
-
typeReplace?: {
|
|
53
|
-
name: string;
|
|
54
|
-
path: string;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
| false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface CustomMappingData extends PluginActionOverrides {
|
|
61
|
-
embeddedId?: string; // e.g. css regions: 'style_0', 'style_1', etc.
|
|
62
|
-
content?: string; // (e.g., css code)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface MappingData extends VolarCodeInformation {
|
|
66
|
-
customData: CustomMappingData;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface CodeMapping extends Omit<VolarMapping<MappingData>, 'generatedLengths'> {
|
|
70
|
-
generatedLengths: number[];
|
|
71
|
-
data: MappingData;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface VolarMappingsResult {
|
|
75
|
-
code: string;
|
|
76
|
-
mappings: CodeMapping[];
|
|
77
|
-
cssMappings: CodeMapping[];
|
|
78
|
-
errors: RippleCompileError[];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface RippleCompileError extends Error {
|
|
82
|
-
pos: number | undefined;
|
|
83
|
-
raisedAt: number | undefined;
|
|
84
|
-
end: number | undefined;
|
|
85
|
-
loc: AST.SourceLocation | undefined;
|
|
86
|
-
fileName: string | null;
|
|
87
|
-
type: 'fatal' | 'usage';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Compilation options
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
interface SharedCompileOptions {
|
|
95
|
-
minify_css?: boolean;
|
|
96
|
-
dev?: boolean;
|
|
97
|
-
}
|
|
98
|
-
export interface CompileOptions extends SharedCompileOptions {
|
|
99
|
-
mode?: 'client' | 'server';
|
|
100
|
-
hmr?: boolean;
|
|
101
|
-
compat_kinds?: string[];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface ParseOptions {
|
|
105
|
-
loose?: boolean;
|
|
106
|
-
errors?: RippleCompileError[];
|
|
107
|
-
comments?: AST.CommentWithLocation[];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface AnalyzeOptions
|
|
111
|
-
extends ParseOptions, Pick<CompileOptions, 'mode' | 'compat_kinds'> {
|
|
112
|
-
errors?: RippleCompileError[];
|
|
113
|
-
to_ts?: boolean;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface VolarCompileOptions
|
|
117
|
-
extends Omit<ParseOptions, 'errors' | 'comments'>, SharedCompileOptions {}
|
|
118
|
-
|
|
119
|
-
export function parse(source: string, options?: ParseOptions): AST.Program;
|
|
120
|
-
|
|
121
|
-
export function compile(source: string, filename: string, options?: CompileOptions): CompileResult;
|
|
122
|
-
|
|
123
|
-
export function compile_to_volar_mappings(
|
|
124
|
-
source: string,
|
|
125
|
-
filename: string,
|
|
126
|
-
options?: VolarCompileOptions,
|
|
127
|
-
): VolarMappingsResult;
|