@aoelite/refpact-ts 0.0.0-stage → 0.1.2

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/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/dist/baseline.d.ts +26 -0
  4. package/dist/baseline.js +65 -0
  5. package/dist/core/index.d.ts +79 -0
  6. package/dist/core/index.js +90 -0
  7. package/dist/core/model.d.ts +340 -0
  8. package/dist/core/model.js +1 -0
  9. package/dist/core/results.d.ts +237 -0
  10. package/dist/core/results.js +1 -0
  11. package/dist/core/wasm.d.ts +7 -0
  12. package/dist/core/wasm.js +67 -0
  13. package/dist/custom.d.ts +129 -0
  14. package/dist/custom.js +217 -0
  15. package/dist/filters.d.ts +73 -0
  16. package/dist/filters.js +39 -0
  17. package/dist/frontend/checks.d.ts +15 -0
  18. package/dist/frontend/checks.js +12 -0
  19. package/dist/frontend/classic.d.ts +3 -0
  20. package/dist/frontend/classic.js +105 -0
  21. package/dist/frontend/compiler.d.ts +93 -0
  22. package/dist/frontend/compiler.js +116 -0
  23. package/dist/frontend/components.d.ts +29 -0
  24. package/dist/frontend/components.js +111 -0
  25. package/dist/frontend/declarations.d.ts +45 -0
  26. package/dist/frontend/declarations.js +158 -0
  27. package/dist/frontend/dependencies.d.ts +53 -0
  28. package/dist/frontend/dependencies.js +337 -0
  29. package/dist/frontend/imports.d.ts +149 -0
  30. package/dist/frontend/imports.js +765 -0
  31. package/dist/frontend/native.d.ts +3 -0
  32. package/dist/frontend/native.js +165 -0
  33. package/dist/frontend/paths.d.ts +10 -0
  34. package/dist/frontend/paths.js +18 -0
  35. package/dist/frontend/project.d.ts +118 -0
  36. package/dist/frontend/project.js +775 -0
  37. package/dist/group.d.ts +74 -0
  38. package/dist/group.js +106 -0
  39. package/dist/index.d.ts +35 -0
  40. package/dist/index.js +27 -0
  41. package/dist/items.d.ts +133 -0
  42. package/dist/items.js +179 -0
  43. package/dist/layers.d.ts +112 -0
  44. package/dist/layers.js +215 -0
  45. package/dist/onion.d.ts +78 -0
  46. package/dist/onion.js +96 -0
  47. package/dist/patterns.d.ts +14 -0
  48. package/dist/patterns.js +15 -0
  49. package/dist/rules.d.ts +408 -0
  50. package/dist/rules.js +655 -0
  51. package/package.json +52 -4
  52. package/wasm/refpact_core.wasm +0 -0
@@ -0,0 +1,149 @@
1
+ import type { Node, SourceFile } from "./compiler.ts";
2
+ import type { DependencyKind } from "./dependencies.ts";
3
+ /** The reference kinds of the TypeScript front end. */
4
+ export declare const KINDS: readonly ["import", "import-type", "dynamic-import", "require", "export-from", "export-type-from", "resolve", "global"];
5
+ /**
6
+ * The kind of a place that asks where a module is and does not load it: `require.resolve("m")`,
7
+ * `import.meta.resolve("m")` and `new URL("./m", import.meta.url)`.
8
+ */
9
+ export declare const RESOLVE_KIND: Kind;
10
+ /**
11
+ * The kind of a use of a global of the host, such as `process.env` or `fetch(..)`: a name
12
+ * that no file of the project declares and that the ECMAScript library does not declare.
13
+ */
14
+ export declare const GLOBAL_KIND: Kind;
15
+ /**
16
+ * The kind of a use of a member of a class, an interface or an enum: `order.total`. Only a
17
+ * project that is loaded with `resolveMembers` has this kind.
18
+ */
19
+ export declare const MEMBER_KIND: Kind;
20
+ /** One of the reference kinds of the TypeScript front end. */
21
+ export type Kind = (typeof KINDS)[number] | "member" | DependencyKind;
22
+ /** One name taken from a module: `a` in `import { a as b } from "m"`. */
23
+ export interface NameUse {
24
+ /** The name as the module exports it. `default` for a default import. */
25
+ readonly exported: string;
26
+ readonly kind: Kind;
27
+ /** The node that carries the position and the symbol. */
28
+ readonly node: Node;
29
+ /**
30
+ * True for a name in the braces of an `import` or an `export ... from`. The symbol of such
31
+ * a name is an alias of the export that the module has under `exported`.
32
+ */
33
+ readonly specifier?: true;
34
+ }
35
+ /** A local name that stands for a whole module: `ns` in `import * as ns from "m"`. */
36
+ export interface NamespaceBinding {
37
+ readonly local: string;
38
+ readonly node: Node;
39
+ readonly kind: Kind;
40
+ }
41
+ /** One statement or expression that names a module. */
42
+ export interface ModuleUse {
43
+ readonly specifier: string;
44
+ readonly specifierNode: Node;
45
+ /** The node whose position is reported for a use of the module as a whole. */
46
+ readonly at: Node;
47
+ readonly kind: Kind;
48
+ /** True when the construct uses the module as a whole and not only some names of it. */
49
+ readonly whole: boolean;
50
+ readonly names: readonly NameUse[];
51
+ readonly namespace?: NamespaceBinding;
52
+ /** The `require` identifier of a `require("m")` call. It may be a local name, not Node's. */
53
+ readonly requireNode?: Node;
54
+ /**
55
+ * How the code gives the specifier, when it is not one string in the place.
56
+ * - `constant`: the code computes it from strings that are known, and `specifier` is the result.
57
+ * - `pattern`: a part is not known. `specifier` has a `*` for each such part.
58
+ * - `glob`: the argument of `import.meta.glob`, which is a glob pattern.
59
+ * - `unknown`: nothing of it is known. `specifier` is empty.
60
+ */
61
+ readonly computed?: "constant" | "pattern" | "glob" | "unknown";
62
+ /**
63
+ * The names of constants that the specifier is computed from, each with the name of the
64
+ * declaration that was read. The value holds only when the compiler says that both are
65
+ * one variable.
66
+ */
67
+ readonly constants?: readonly {
68
+ readonly use: Node;
69
+ readonly declaration: Node;
70
+ }[];
71
+ /** True for `new URL(..)`, which may name a file that is no module, such as an image. */
72
+ readonly asset?: true;
73
+ }
74
+ /** `object.member` or `object.member` in a type, where `object` may be a namespace binding. */
75
+ export interface MemberUse {
76
+ readonly object: Node;
77
+ readonly member: Node;
78
+ readonly objectName: string;
79
+ readonly memberName: string;
80
+ /**
81
+ * For a member of a `const` that stands for a namespace binding, `const f = ns; f.name`: the
82
+ * name of the declaration of the `const`, and the name of the binding in its value.
83
+ * `object` is then the `const` where it is used, and `objectName` is the name of the binding.
84
+ */
85
+ readonly alias?: {
86
+ readonly declaration: Node;
87
+ readonly of: Node;
88
+ };
89
+ }
90
+ /**
91
+ * Finds every construct of the file that names a module.
92
+ *
93
+ * `prune` lets the visit leave out nodes, see {@link Mentions}. It must be `false` for a
94
+ * JavaScript file: the compiler makes nodes from the types in JSDoc comments, and such a node
95
+ * is in the text before the node that it belongs to, not in it.
96
+ */
97
+ export declare function collectModuleUses(sourceFile: SourceFile, prune: boolean): ModuleUse[];
98
+ /** Finds `object.member` where `object` is one of the given local names. */
99
+ export declare function collectMemberUses(sourceFile: SourceFile, locals: ReadonlySet<string>, prune: boolean): MemberUse[];
100
+ /**
101
+ * The names after the dot of each `object.name` of a file, in the order of the text. What a
102
+ * name is a member of depends on the type of the object, which only the compiler knows.
103
+ * Every node of the file is visited.
104
+ */
105
+ export declare function collectAccesses(sourceFile: SourceFile): Node[];
106
+ /**
107
+ * A name in a file that may be a global: `fetch` in `fetch(..)`, or `process` and its member
108
+ * `env` in `process.env`. Through `globalThis`, `window`, `self` and `global`, the global is
109
+ * the name after the dot: `window.localStorage` is `localStorage`. Only the compiler can tell
110
+ * whether the names are globals: `node` and `through` are the nodes to ask.
111
+ */
112
+ export interface GlobalUse {
113
+ /** The node that carries the position. */
114
+ readonly at: Node;
115
+ /** The node of the name of the global. */
116
+ readonly node: Node;
117
+ /** The name of the global. */
118
+ readonly name: string;
119
+ /** The member of the global that is used, if any: `env` in `process.env`. */
120
+ readonly member?: string;
121
+ /** `globalThis`, `window`, `self` or `global`, when the global is written as its member. */
122
+ readonly through?: Node;
123
+ /** The shorthand property that the name is, `{ fetch }`: the compiler is asked for its value apart. */
124
+ readonly shorthand?: Node;
125
+ }
126
+ /**
127
+ * The names in value positions that may be globals, in the order of the text. Types,
128
+ * the names after a dot, JSX tags and the callee of `require(..)` are left out.
129
+ */
130
+ export declare function collectGlobalUses(sourceFile: SourceFile): GlobalUse[];
131
+ /**
132
+ * The markers that a file can contain: a use of the global `console`, a `debugger`
133
+ * statement, and `unresolved-import`, an import of a relative path, a `paths` alias or a
134
+ * `#name` of `imports` that leads to no file.
135
+ */
136
+ export declare const MARKERS: readonly ["console", "debugger", "unresolved-import", "computed-import"];
137
+ /** One of {@link MARKERS}. */
138
+ export type MarkerName = (typeof MARKERS)[number];
139
+ /**
140
+ * A place that may be a marker. A `debugger` statement is one. `console.name` is one when
141
+ * `console` is the global, which only the compiler can tell: `object` is the node to ask.
142
+ */
143
+ export interface MarkerUse {
144
+ readonly marker: MarkerName;
145
+ readonly at: Node;
146
+ readonly object?: Node;
147
+ }
148
+ /** The `debugger` statements of a file, and its `console.name`, in the order of the text. */
149
+ export declare function collectMarkers(sourceFile: SourceFile, prune: boolean): MarkerUse[];