@tsrx/core 0.0.1 → 0.0.3
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/LICENSE +21 -0
- package/README.md +249 -0
- package/package.json +18 -17
- package/src/index.js +56 -58
- package/src/parse/index.js +1 -1
- package/src/parse/parse-module.js +18 -0
- package/src/plugin.js +2248 -0
- package/src/scope.js +1 -1
- package/src/source-map-utils.js +19 -19
- package/types/index.d.ts +20 -20
- package/types/parse.d.ts +3 -3
package/src/scope.js
CHANGED
package/src/source-map-utils.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
@import { PostProcessingChanges, LineOffsets } from '../types/index';
|
|
3
|
-
@import * as AST from 'estree';
|
|
4
|
-
@import { CodeMapping } from '../types/index';
|
|
5
|
-
@import { CodeMapping as VolarCodeMapping } from '@volar/language-core';
|
|
6
|
-
@import { RawSourceMap } from 'source-map';
|
|
2
|
+
* @import { PostProcessingChanges, LineOffsets } from '../types/index.js';
|
|
3
|
+
* @import * as AST from 'estree';
|
|
4
|
+
* @import { CodeMapping } from '../types/index.js';
|
|
5
|
+
* @import { CodeMapping as VolarCodeMapping } from '@volar/language-core';
|
|
6
|
+
* @import { RawSourceMap } from 'source-map';
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
@typedef {{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}} CodePosition
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@typedef {Map<string,
|
|
23
|
-
*/
|
|
10
|
+
* @typedef {{
|
|
11
|
+
* line: number,
|
|
12
|
+
* column: number,
|
|
13
|
+
* end_line: number,
|
|
14
|
+
* end_column: number,
|
|
15
|
+
* code: string,
|
|
16
|
+
* metadata: {
|
|
17
|
+
* css?: AST.Element['metadata']['css']
|
|
18
|
+
* },
|
|
19
|
+
* }} CodePosition
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** @typedef {Map<string, CodePosition[]>} CodeToGeneratedMap */
|
|
23
|
+
/** @typedef {Map<string, {line: number, column: number}[]>} GeneratedToSourceMap */
|
|
24
24
|
|
|
25
25
|
import { decode } from '@jridgewell/sourcemap-codec';
|
|
26
26
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type * as AST from 'estree';
|
|
2
2
|
import type * as ESTreeJSX from 'estree-jsx';
|
|
3
3
|
import type { TSESTree } from '@typescript-eslint/types';
|
|
4
|
-
import type { Parse } from './parse';
|
|
4
|
+
import type { Parse } from './parse.js';
|
|
5
5
|
import type * as ESRap from 'esrap';
|
|
6
6
|
import type { Position } from 'acorn';
|
|
7
|
-
import type { RequireAllOrNone } from '../src/helpers';
|
|
7
|
+
import type { RequireAllOrNone } from '../src/helpers.js';
|
|
8
8
|
|
|
9
9
|
export type { Parse };
|
|
10
10
|
|
|
@@ -163,7 +163,7 @@ declare module 'estree' {
|
|
|
163
163
|
Component: Component;
|
|
164
164
|
Tsx: Tsx;
|
|
165
165
|
TsxCompat: TsxCompat;
|
|
166
|
-
|
|
166
|
+
TSRXExpression: TSRXExpression;
|
|
167
167
|
Html: Html;
|
|
168
168
|
Element: Element;
|
|
169
169
|
Text: TextNode;
|
|
@@ -329,8 +329,8 @@ declare module 'estree' {
|
|
|
329
329
|
expression: AST.Expression;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
export interface
|
|
333
|
-
type: '
|
|
332
|
+
export interface TSRXExpression extends AST.BaseExpression {
|
|
333
|
+
type: 'TSRXExpression';
|
|
334
334
|
expression: AST.Expression;
|
|
335
335
|
loc?: AST.SourceLocation;
|
|
336
336
|
}
|
|
@@ -339,7 +339,7 @@ declare module 'estree' {
|
|
|
339
339
|
type: 'Element';
|
|
340
340
|
// MemberExpression for namespaced or dynamic elements
|
|
341
341
|
id: AST.Identifier | AST.MemberExpression;
|
|
342
|
-
attributes:
|
|
342
|
+
attributes: TSRXAttribute[];
|
|
343
343
|
children: AST.Node[];
|
|
344
344
|
selfClosing?: boolean;
|
|
345
345
|
unclosed?: boolean;
|
|
@@ -421,33 +421,33 @@ declare module 'estree' {
|
|
|
421
421
|
* Ripple's extended Declaration type that includes Component
|
|
422
422
|
* Use this instead of Declaration when you need Component support
|
|
423
423
|
*/
|
|
424
|
-
export type
|
|
424
|
+
export type TSRXDeclaration = AST.Declaration | Component | AST.TSDeclareFunction;
|
|
425
425
|
|
|
426
426
|
/**
|
|
427
427
|
* Ripple's extended ExportNamedDeclaration with Component support
|
|
428
428
|
*/
|
|
429
|
-
interface
|
|
430
|
-
declaration?:
|
|
429
|
+
interface TSRXExportNamedDeclaration extends Omit<AST.ExportNamedDeclaration, 'declaration'> {
|
|
430
|
+
declaration?: TSRXDeclaration | null | undefined;
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
/**
|
|
434
434
|
* Ripple's extended Program with Component support
|
|
435
435
|
*/
|
|
436
|
-
interface
|
|
436
|
+
interface TSRXProgram extends Omit<Program, 'body'> {
|
|
437
437
|
body: (Program['body'][number] | Component | FunctionExpression)[];
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
-
interface
|
|
440
|
+
interface TSRXMethodDefinition extends Omit<AST.MethodDefinition, 'value'> {
|
|
441
441
|
value: AST.MethodDefinition['value'] | Component;
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
interface
|
|
444
|
+
interface TSRXProperty extends Omit<AST.Property, 'value'> {
|
|
445
445
|
value: AST.Property['value'] | Component;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
export type
|
|
448
|
+
export type TSRXAttribute = AST.Attribute | AST.SpreadAttribute | AST.RefAttribute;
|
|
449
449
|
|
|
450
|
-
export type
|
|
450
|
+
export type TSRXStatement = AST.Statement | TSESTree.Statement;
|
|
451
451
|
|
|
452
452
|
export type NodeWithChildren = AST.Element | AST.Tsx | AST.TsxCompat;
|
|
453
453
|
|
|
@@ -658,11 +658,11 @@ declare module 'estree-jsx' {
|
|
|
658
658
|
computed?: boolean;
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
-
interface
|
|
661
|
+
interface TSRXJSXOpeningElement extends Omit<JSXOpeningElement, 'name'> {
|
|
662
662
|
name: AST.MemberExpression | JSXIdentifier | JSXNamespacedName;
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
-
interface
|
|
665
|
+
interface TSRXJSXClosingElement extends Omit<JSXClosingElement, 'name'> {
|
|
666
666
|
name: AST.MemberExpression | JSXIdentifier | JSXNamespacedName;
|
|
667
667
|
}
|
|
668
668
|
|
|
@@ -1144,7 +1144,7 @@ export interface AnalysisResult {
|
|
|
1144
1144
|
/**
|
|
1145
1145
|
* Configuration for Ripple parser plugin
|
|
1146
1146
|
*/
|
|
1147
|
-
export interface
|
|
1147
|
+
export interface TSRXPluginConfig {
|
|
1148
1148
|
allowSatisfies?: boolean;
|
|
1149
1149
|
}
|
|
1150
1150
|
|
|
@@ -1224,7 +1224,7 @@ export interface Binding {
|
|
|
1224
1224
|
/**
|
|
1225
1225
|
* Root scope manager
|
|
1226
1226
|
*/
|
|
1227
|
-
export interface
|
|
1227
|
+
export interface ScopeRootInterface {
|
|
1228
1228
|
/** Set of conflicting/reserved names */
|
|
1229
1229
|
conflicts: Set<string>;
|
|
1230
1230
|
/** Generate unique identifier name */
|
|
@@ -1232,7 +1232,7 @@ export interface ScopeRoot {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
1234
|
export interface ScopeConstructorInterface {
|
|
1235
|
-
root:
|
|
1235
|
+
root: ScopeRootInterface;
|
|
1236
1236
|
parent: ScopeInterface | null;
|
|
1237
1237
|
porous: boolean;
|
|
1238
1238
|
error_options: {
|
|
@@ -1255,7 +1255,7 @@ export type ScopeConstructorParameters = [
|
|
|
1255
1255
|
*/
|
|
1256
1256
|
export interface ScopeInterface {
|
|
1257
1257
|
/** Root scope manager */
|
|
1258
|
-
root:
|
|
1258
|
+
root: ScopeRootInterface;
|
|
1259
1259
|
/** Parent scope */
|
|
1260
1260
|
parent: ScopeInterface | null;
|
|
1261
1261
|
/** Map of declared bindings */
|
package/types/parse.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ 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 CoreCompiler from './index';
|
|
17
|
+
import type * as CoreCompiler from './index.js';
|
|
18
18
|
import type { RawSourceMap } from 'source-map';
|
|
19
19
|
|
|
20
20
|
type ForInit = boolean | 'await';
|
|
@@ -1196,7 +1196,7 @@ export namespace Parse {
|
|
|
1196
1196
|
topLevel?: boolean,
|
|
1197
1197
|
exports?: AST.ExportSpecifier,
|
|
1198
1198
|
):
|
|
1199
|
-
| AST.
|
|
1199
|
+
| AST.TSRXExpression
|
|
1200
1200
|
| AST.Html
|
|
1201
1201
|
| AST.TextNode
|
|
1202
1202
|
| ESTreeJSX.JSXEmptyExpression
|
|
@@ -1634,7 +1634,7 @@ export namespace Parse {
|
|
|
1634
1634
|
* Parse JSX attribute (name="value" or {spread})
|
|
1635
1635
|
* @returns JSXAttribute or JSXSpreadAttribute
|
|
1636
1636
|
*/
|
|
1637
|
-
jsx_parseAttribute(): AST.
|
|
1637
|
+
jsx_parseAttribute(): AST.TSRXAttribute | ESTreeJSX.JSXAttribute;
|
|
1638
1638
|
|
|
1639
1639
|
/**
|
|
1640
1640
|
* Parse JSX opening element at position
|