monkeypatchlist 0.0.0-stage → 0.1.0

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 (221) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +61 -0
  3. package/README.md +183 -2
  4. package/catalog/catalog.json +552211 -0
  5. package/catalog/catalog.schema.json +787 -0
  6. package/catalog/changelog.json +3 -0
  7. package/dist/bin/monkeypatchlist.d.ts +2 -0
  8. package/dist/bin/monkeypatchlist.js +3 -0
  9. package/dist/catalog.d.ts +561 -0
  10. package/dist/catalog.js +58 -0
  11. package/dist/cli.d.ts +84 -0
  12. package/dist/cli.js +470 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.js +1 -0
  15. package/dist/lockfile-input.d.ts +9 -0
  16. package/dist/lockfile-input.js +91 -0
  17. package/dist/packages/analysis/binding.d.ts +2 -0
  18. package/dist/packages/analysis/binding.js +5 -0
  19. package/dist/packages/analysis/index.d.ts +10 -0
  20. package/dist/packages/analysis/index.js +13 -0
  21. package/dist/packages/analysis/job.d.ts +33 -0
  22. package/dist/packages/analysis/job.js +85 -0
  23. package/dist/packages/analysis/lib/absence-tags.d.ts +34 -0
  24. package/dist/packages/analysis/lib/absence-tags.js +340 -0
  25. package/dist/packages/analysis/lib/ast.d.ts +28 -0
  26. package/dist/packages/analysis/lib/ast.js +64 -0
  27. package/dist/packages/analysis/lib/binding.d.ts +36 -0
  28. package/dist/packages/analysis/lib/binding.js +66 -0
  29. package/dist/packages/analysis/lib/budget.d.ts +80 -0
  30. package/dist/packages/analysis/lib/budget.js +31 -0
  31. package/dist/packages/analysis/lib/catch-arms.d.ts +19 -0
  32. package/dist/packages/analysis/lib/catch-arms.js +351 -0
  33. package/dist/packages/analysis/lib/chunk-loads.d.ts +160 -0
  34. package/dist/packages/analysis/lib/chunk-loads.js +882 -0
  35. package/dist/packages/analysis/lib/chunk-registry.d.ts +45 -0
  36. package/dist/packages/analysis/lib/chunk-registry.js +334 -0
  37. package/dist/packages/analysis/lib/code-routes.d.ts +52 -0
  38. package/dist/packages/analysis/lib/code-routes.js +921 -0
  39. package/dist/packages/analysis/lib/collisions.d.ts +22 -0
  40. package/dist/packages/analysis/lib/collisions.js +103 -0
  41. package/dist/packages/analysis/lib/definitions.d.ts +76 -0
  42. package/dist/packages/analysis/lib/definitions.js +782 -0
  43. package/dist/packages/analysis/lib/early-exits.d.ts +39 -0
  44. package/dist/packages/analysis/lib/early-exits.js +161 -0
  45. package/dist/packages/analysis/lib/effect.d.ts +138 -0
  46. package/dist/packages/analysis/lib/effect.js +800 -0
  47. package/dist/packages/analysis/lib/global-object.d.ts +581 -0
  48. package/dist/packages/analysis/lib/global-object.js +8240 -0
  49. package/dist/packages/analysis/lib/keys.d.ts +33 -0
  50. package/dist/packages/analysis/lib/keys.js +82 -0
  51. package/dist/packages/analysis/lib/line-starts.d.ts +41 -0
  52. package/dist/packages/analysis/lib/line-starts.js +79 -0
  53. package/dist/packages/analysis/lib/link-group.d.ts +51 -0
  54. package/dist/packages/analysis/lib/link-group.js +487 -0
  55. package/dist/packages/analysis/lib/module-links.d.ts +117 -0
  56. package/dist/packages/analysis/lib/module-links.js +1060 -0
  57. package/dist/packages/analysis/lib/nested-code.d.ts +38 -0
  58. package/dist/packages/analysis/lib/nested-code.js +200 -0
  59. package/dist/packages/analysis/lib/numeric.d.ts +16 -0
  60. package/dist/packages/analysis/lib/numeric.js +216 -0
  61. package/dist/packages/analysis/lib/once-flags.d.ts +12 -0
  62. package/dist/packages/analysis/lib/once-flags.js +190 -0
  63. package/dist/packages/analysis/lib/parameter-arguments.d.ts +12 -0
  64. package/dist/packages/analysis/lib/parameter-arguments.js +34 -0
  65. package/dist/packages/analysis/lib/parse.d.ts +10 -0
  66. package/dist/packages/analysis/lib/parse.js +39 -0
  67. package/dist/packages/analysis/lib/partial.d.ts +60 -0
  68. package/dist/packages/analysis/lib/partial.js +518 -0
  69. package/dist/packages/analysis/lib/print.d.ts +3 -0
  70. package/dist/packages/analysis/lib/print.js +150 -0
  71. package/dist/packages/analysis/lib/reachability.d.ts +137 -0
  72. package/dist/packages/analysis/lib/reachability.js +1295 -0
  73. package/dist/packages/analysis/lib/resolver.d.ts +13 -0
  74. package/dist/packages/analysis/lib/resolver.js +2886 -0
  75. package/dist/packages/analysis/lib/restores.d.ts +42 -0
  76. package/dist/packages/analysis/lib/restores.js +482 -0
  77. package/dist/packages/analysis/lib/rewritten-deletes.d.ts +6 -0
  78. package/dist/packages/analysis/lib/rewritten-deletes.js +142 -0
  79. package/dist/packages/analysis/lib/scope.d.ts +110 -0
  80. package/dist/packages/analysis/lib/scope.js +443 -0
  81. package/dist/packages/analysis/lib/script-loads.d.ts +56 -0
  82. package/dist/packages/analysis/lib/script-loads.js +359 -0
  83. package/dist/packages/analysis/lib/summaries.d.ts +177 -0
  84. package/dist/packages/analysis/lib/summaries.js +498 -0
  85. package/dist/packages/analysis/lib/types.d.ts +632 -0
  86. package/dist/packages/analysis/lib/types.js +128 -0
  87. package/dist/packages/analysis/lib/wrap.d.ts +34 -0
  88. package/dist/packages/analysis/lib/wrap.js +407 -0
  89. package/dist/packages/analysis/lib/writes.d.ts +358 -0
  90. package/dist/packages/analysis/lib/writes.js +1612 -0
  91. package/dist/packages/analysis/visit-order.d.ts +3 -0
  92. package/dist/packages/analysis/visit-order.js +23 -0
  93. package/dist/packages/attribution/index.d.ts +233 -0
  94. package/dist/packages/attribution/index.js +444 -0
  95. package/dist/packages/attribution/lib/containing-package.d.ts +76 -0
  96. package/dist/packages/attribution/lib/containing-package.js +304 -0
  97. package/dist/packages/attribution/lib/first-party.d.ts +37 -0
  98. package/dist/packages/attribution/lib/first-party.js +153 -0
  99. package/dist/packages/attribution/lib/lockfile-graph.d.ts +99 -0
  100. package/dist/packages/attribution/lib/lockfile-graph.js +158 -0
  101. package/dist/packages/attribution/lib/lockfile.d.ts +33 -0
  102. package/dist/packages/attribution/lib/lockfile.js +330 -0
  103. package/dist/packages/attribution/lib/path-rules.d.ts +29 -0
  104. package/dist/packages/attribution/lib/path-rules.js +84 -0
  105. package/dist/packages/attribution/lib/pnpm.d.ts +4 -0
  106. package/dist/packages/attribution/lib/pnpm.js +133 -0
  107. package/dist/packages/attribution/lib/remote-url.d.ts +7 -0
  108. package/dist/packages/attribution/lib/remote-url.js +24 -0
  109. package/dist/packages/attribution/lib/source-map.d.ts +51 -0
  110. package/dist/packages/attribution/lib/source-map.js +125 -0
  111. package/dist/packages/attribution/lib/yaml.d.ts +9 -0
  112. package/dist/packages/attribution/lib/yaml.js +277 -0
  113. package/dist/packages/attribution/lib/yarn.d.ts +7 -0
  114. package/dist/packages/attribution/lib/yarn.js +227 -0
  115. package/dist/packages/baseline/index.d.ts +45 -0
  116. package/dist/packages/baseline/index.js +41 -0
  117. package/dist/packages/baseline/lib/error.d.ts +15 -0
  118. package/dist/packages/baseline/lib/error.js +25 -0
  119. package/dist/packages/baseline/lib/format.d.ts +49 -0
  120. package/dist/packages/baseline/lib/format.js +22 -0
  121. package/dist/packages/baseline/lib/migrations.d.ts +19 -0
  122. package/dist/packages/baseline/lib/migrations.js +7 -0
  123. package/dist/packages/baseline/lib/previous.d.ts +23 -0
  124. package/dist/packages/baseline/lib/previous.js +64 -0
  125. package/dist/packages/baseline/lib/read.d.ts +39 -0
  126. package/dist/packages/baseline/lib/read.js +219 -0
  127. package/dist/packages/baseline/lib/report.d.ts +25 -0
  128. package/dist/packages/baseline/lib/report.js +104 -0
  129. package/dist/packages/baseline/lib/skew.d.ts +51 -0
  130. package/dist/packages/baseline/lib/skew.js +75 -0
  131. package/dist/packages/compare/index.d.ts +120 -0
  132. package/dist/packages/compare/index.js +274 -0
  133. package/dist/packages/compare/lib/catalog-notes.d.ts +73 -0
  134. package/dist/packages/compare/lib/catalog-notes.js +224 -0
  135. package/dist/packages/completeness/index.d.ts +246 -0
  136. package/dist/packages/completeness/index.js +249 -0
  137. package/dist/packages/confidence/index.d.ts +54 -0
  138. package/dist/packages/confidence/index.js +71 -0
  139. package/dist/packages/config/index.d.ts +107 -0
  140. package/dist/packages/config/index.js +95 -0
  141. package/dist/packages/config/lib/command-line.d.ts +23 -0
  142. package/dist/packages/config/lib/command-line.js +239 -0
  143. package/dist/packages/config/lib/config-file.d.ts +11 -0
  144. package/dist/packages/config/lib/config-file.js +119 -0
  145. package/dist/packages/config/lib/scan-config-id.d.ts +28 -0
  146. package/dist/packages/config/lib/scan-config-id.js +54 -0
  147. package/dist/packages/config/lib/schema.d.ts +2 -0
  148. package/dist/packages/config/lib/schema.js +31 -0
  149. package/dist/packages/config/lib/types.d.ts +64 -0
  150. package/dist/packages/config/lib/types.js +6 -0
  151. package/dist/packages/config/lib/urls.d.ts +6 -0
  152. package/dist/packages/config/lib/urls.js +9 -0
  153. package/dist/packages/discovery/index.d.ts +277 -0
  154. package/dist/packages/discovery/index.js +1950 -0
  155. package/dist/packages/discovery/lib/import-map.d.ts +68 -0
  156. package/dist/packages/discovery/lib/import-map.js +180 -0
  157. package/dist/packages/discovery/lib/requests.d.ts +58 -0
  158. package/dist/packages/discovery/lib/requests.js +591 -0
  159. package/dist/packages/discovery/lib/scopes.d.ts +6 -0
  160. package/dist/packages/discovery/lib/scopes.js +286 -0
  161. package/dist/packages/discovery/lib/source-maps.d.ts +56 -0
  162. package/dist/packages/discovery/lib/source-maps.js +209 -0
  163. package/dist/packages/discovery/lib/swept-code.d.ts +27 -0
  164. package/dist/packages/discovery/lib/swept-code.js +107 -0
  165. package/dist/packages/discovery/lib/syntax.d.ts +17 -0
  166. package/dist/packages/discovery/lib/syntax.js +39 -0
  167. package/dist/packages/findings/index.d.ts +106 -0
  168. package/dist/packages/findings/index.js +254 -0
  169. package/dist/packages/findings/lib/scope.d.ts +38 -0
  170. package/dist/packages/findings/lib/scope.js +110 -0
  171. package/dist/packages/parallel/index.d.ts +2 -0
  172. package/dist/packages/parallel/index.js +5 -0
  173. package/dist/packages/parallel/lib/protocol.d.ts +15 -0
  174. package/dist/packages/parallel/lib/protocol.js +2 -0
  175. package/dist/packages/parallel/lib/runner.d.ts +36 -0
  176. package/dist/packages/parallel/lib/runner.js +96 -0
  177. package/dist/packages/parallel/lib/schedule.d.ts +16 -0
  178. package/dist/packages/parallel/lib/schedule.js +52 -0
  179. package/dist/packages/parallel/lib/worker.d.ts +1 -0
  180. package/dist/packages/parallel/lib/worker.js +18 -0
  181. package/dist/packages/policy/index.d.ts +36 -0
  182. package/dist/packages/policy/index.js +22 -0
  183. package/dist/packages/report/explain.d.ts +26 -0
  184. package/dist/packages/report/explain.js +99 -0
  185. package/dist/packages/report/index.d.ts +210 -0
  186. package/dist/packages/report/index.js +388 -0
  187. package/dist/packages/report/terminal.d.ts +11 -0
  188. package/dist/packages/report/terminal.js +331 -0
  189. package/dist/packages/source-store/fixture.d.ts +22 -0
  190. package/dist/packages/source-store/fixture.js +58 -0
  191. package/dist/packages/source-store/index.d.ts +278 -0
  192. package/dist/packages/source-store/index.js +322 -0
  193. package/dist/packages/source-store/lib/addresses.d.ts +6 -0
  194. package/dist/packages/source-store/lib/addresses.js +91 -0
  195. package/dist/packages/source-store/lib/connection.d.ts +15 -0
  196. package/dist/packages/source-store/lib/connection.js +135 -0
  197. package/dist/packages/source-store/lib/content-types.d.ts +16 -0
  198. package/dist/packages/source-store/lib/content-types.js +75 -0
  199. package/dist/packages/source-store/lib/data-urls.d.ts +10 -0
  200. package/dist/packages/source-store/lib/data-urls.js +85 -0
  201. package/dist/packages/source-store/lib/deadline.d.ts +18 -0
  202. package/dist/packages/source-store/lib/deadline.js +44 -0
  203. package/dist/packages/source-store/lib/exchange.d.ts +29 -0
  204. package/dist/packages/source-store/lib/exchange.js +112 -0
  205. package/dist/packages/source-store/lib/integrity.d.ts +19 -0
  206. package/dist/packages/source-store/lib/integrity.js +86 -0
  207. package/dist/packages/source-store/lib/outcomes.d.ts +12 -0
  208. package/dist/packages/source-store/lib/outcomes.js +22 -0
  209. package/dist/packages/source-store/lib/proxy.d.ts +11 -0
  210. package/dist/packages/source-store/lib/proxy.js +53 -0
  211. package/dist/packages/source-store/lib/session.d.ts +12 -0
  212. package/dist/packages/source-store/lib/session.js +139 -0
  213. package/dist/packages/source-store/lib/urls.d.ts +6 -0
  214. package/dist/packages/source-store/lib/urls.js +15 -0
  215. package/dist/packages/source-store/resolve.d.ts +59 -0
  216. package/dist/packages/source-store/resolve.js +45 -0
  217. package/dist/scan.d.ts +65 -0
  218. package/dist/scan.js +592 -0
  219. package/package.json +95 -4
  220. package/schema/config.schema.json +133 -0
  221. package/schema/report.schema.json +1905 -0
@@ -0,0 +1,358 @@
1
+ import { type AstNode } from './ast.ts';
2
+ import type { Fold, GlobalResolution, Leaf, Position, Value } from './global-object.ts';
3
+ import { type Key as MemberKey } from './keys.ts';
4
+ import { type Declared, type ScopeRules } from './scope.ts';
5
+ import type { Caps } from './budget.ts';
6
+ import type { Mechanism, RealmInstance } from './types.ts';
7
+ /** A native member written, and how: the syntax's reading of the change, before the catalog decides its effect. */
8
+ export interface Write {
9
+ /** The write site: the assignment, the `delete`, the call, or for a bulk mechanism the property of its object. */
10
+ site: AstNode;
11
+ /** The native holder written, e.g. `Window` or `Array.prototype`. */
12
+ holder: string;
13
+ /** The leaves the holder, and the native function a call mechanism uses, were reached from, in document order. */
14
+ leaves: Leaf[];
15
+ /** The window the holder written belongs to (§4 Other windows), from the leaves it was reached from. */
16
+ realmInstance: RealmInstance;
17
+ mechanism: Mechanism;
18
+ /**
19
+ * The native function that makes the write, by catalog name (`Object.defineProperty`, `Reflect.set`), or its legacy
20
+ * method name (`__defineGetter__`); absent for syntax (`=`, `delete`). It decides whether a write that can't change
21
+ * its target throws (§3 Ineffective writes).
22
+ */
23
+ writer?: string;
24
+ change: Change;
25
+ /**
26
+ * The folds (§14) the native writer function, the holder, the member and the descriptor's fields come from, in that
27
+ * order, each after the folds it folds.
28
+ */
29
+ folds: Fold[];
30
+ /**
31
+ * The folds the holder written and the member come from, apart: a write inside a helper is looked up at the outermost
32
+ * call whose arguments carry both (§10).
33
+ */
34
+ parts: Parts;
35
+ /** Where attribution looks the write up, and its token (§10 lookup point). */
36
+ lookup: WriteLookup;
37
+ /** For mechanism `declare`, the declaration that makes the write (§3 Declarations in classic scripts). */
38
+ declaration?: Declaration;
39
+ /** For one candidate of a site's candidate set (§5 Candidate sets), the set and the branches it comes from. */
40
+ alternatives?: Alternatives;
41
+ }
42
+ /**
43
+ * A write site's candidate set (§5 Candidate sets, ADR 0019): the holders or members a branch that neither folding nor
44
+ * the catalog settles gives, and the targets they make, each of which is its own finding.
45
+ */
46
+ export interface Alternatives {
47
+ /** When the candidates are several holders, the expression whose branches give them, and the holders. */
48
+ holders?: {
49
+ node: AstNode;
50
+ names: string[];
51
+ };
52
+ /**
53
+ * When the candidates are several members, or come from a key whose other alternatives the analyzer can't resolve,
54
+ * the key whose branches give them, the members, the prefixes of its pattern wildcards (§5 Pattern wildcards), and
55
+ * whether it had such other alternatives (`unresolved`) or a heap-read or once-flag boolean, `null` or `undefined` an
56
+ * undecided test gave back, which is never a key (`tested`).
57
+ */
58
+ members?: {
59
+ node: AstNode;
60
+ keys: MemberKey[];
61
+ prefixes?: string[];
62
+ unresolved?: true;
63
+ tested?: true;
64
+ };
65
+ /** The site's candidate targets, by name: `<holder>.<member>`, or `<holder>.*` for wildcards, in source order. */
66
+ targets: string[];
67
+ }
68
+ /** The most candidates a site's candidate set gives findings for (§5 Candidate sets, ADR 0019). */
69
+ export declare const maxCandidates = 4;
70
+ /**
71
+ * A write site whose candidate set has more than `maxCandidates` targets, holders only (§5 Candidate sets): with one
72
+ * member that folds, the candidate `writes` and the `open` write site the patch-shape test reads; with a member that
73
+ * doesn't, the candidate wildcard writes, one per holder. Either gives an `unresolved-holder` limitation at most.
74
+ */
75
+ export type WideSite = {
76
+ site: AstNode;
77
+ open: OpenWrite;
78
+ writes: Write[];
79
+ } | {
80
+ site: AstNode;
81
+ wild: WildWrite[];
82
+ };
83
+ /**
84
+ * A declaration that writes a global object's member (§3): how it binds the name (`Declared`), and for a `var`,
85
+ * whether it only binds it, with no initializer and no loop to assign it (`var x;`).
86
+ */
87
+ export type Declaration = Declared & {
88
+ bare?: true;
89
+ };
90
+ /**
91
+ * A write site whose member folds to a constant but whose holder may be an object the analyzer can't resolve: one
92
+ * alternative of it, at least, is unknown (§5 Partially resolved writes). Whether it is an `unresolved-holder`
93
+ * limitation is for the site's patch shape and the catalog to decide (`partial.ts`).
94
+ */
95
+ export interface OpenWrite {
96
+ /** The write site, as a `Write` of it would give it. */
97
+ site: AstNode;
98
+ /** The expression that gives the holder written. */
99
+ holder: AstNode;
100
+ mechanism: Mechanism;
101
+ change: Exclude<Change, {
102
+ kind: 'prototype';
103
+ }>;
104
+ /** For an assign, the value written. */
105
+ value?: AstNode;
106
+ /** For an assign, the member expression written, which is no read of the original. */
107
+ target?: AstNode;
108
+ /** Whether the write is a logical assignment that keeps the member when present (`o.m ||= p`, `o.m ??= p`). */
109
+ keepsPresent?: boolean;
110
+ }
111
+ /**
112
+ * The member of a wildcard write (§5 Partially resolved writes): a key the analyzer can't fold. It names no member, so
113
+ * each member the wildcard matches takes its place when the outcome is judged (`effect.ts`).
114
+ */
115
+ export declare const unknownMember: unique symbol;
116
+ /**
117
+ * A write site whose holder resolves to one native holder but whose key folds to nothing the analyzer knows (§5
118
+ * Partially resolved writes): a wildcard target `<holder>.*` when the same key is reused (`partial.ts`). Its change
119
+ * has `unknownMember` for its member.
120
+ */
121
+ export interface WildWrite extends Write {
122
+ /** The expression that gives the key. */
123
+ key: AstNode;
124
+ /** The expression that gives the holder written. */
125
+ object: AstNode;
126
+ /** For an assign or a delete, the member expression written, which is no read of the original. */
127
+ target?: AstNode;
128
+ /** For an assign, the value written. */
129
+ value?: AstNode;
130
+ /** Whether the write is a logical assignment that keeps the member when present (`o[k] ||= p`, `o[k] ??= p`). */
131
+ keepsPresent?: boolean;
132
+ /**
133
+ * When the key is a candidate set of more than `maxCandidates` members, the members the wildcard's matched set is
134
+ * narrowed to (§5).
135
+ */
136
+ members?: MemberKey[];
137
+ /**
138
+ * When the key folds to a constant prefix that no catalog member of the holder or its catalog prototype chain starts
139
+ * with, the prefix: the write is a pattern wildcard `<holder>.<prefix>*`, a non-native `add` (§5 Pattern wildcards).
140
+ */
141
+ pattern?: string;
142
+ /**
143
+ * When the key folds to constant prefixes some catalog member of the holder or its chain starts with, the prefixes:
144
+ * the write is `<holder>.*` under the reuse rule, its matched set narrowed to the members that start with one of
145
+ * them, together with `members` when both are set. Several prefixes at one site give one `<holder>.*`, whose
146
+ * matched set is the members that start with any of them (Principle 3).
147
+ */
148
+ prefixes?: string[];
149
+ /**
150
+ * Whether the prefix is configurable: the key's other alternatives are values the analyzer can't resolve, which give
151
+ * nothing.
152
+ */
153
+ configurable?: true;
154
+ }
155
+ /** The folds the holder written and the member come from. */
156
+ export interface Parts {
157
+ holder: readonly Fold[];
158
+ member: readonly Fold[];
159
+ }
160
+ /**
161
+ * Where attribution looks a write up (§10): the member token written at the site, or else the holder argument, with the
162
+ * token the token check looks for, or null when there is none.
163
+ */
164
+ export interface WriteLookup {
165
+ node: AstNode;
166
+ token: string | null;
167
+ }
168
+ /**
169
+ * The change a write makes:
170
+ * - `set`: a [[Set]] of a value (`assign`, `bulk-assign`). `same` says the value is a read of the same slot, which
171
+ * writes back what is there. `through` is the object the member is looked up on when it isn't the one written, as
172
+ * `Reflect.set(t, k, v, r)` looks k up on t and writes its receiver r (§3).
173
+ * - `define`: a [[DefineOwnProperty]] with a descriptor, as far as the syntax shows it. `via` names the method of the
174
+ * holder that makes it (`__defineGetter__`), which must be the one `Object.prototype` gives.
175
+ * - `delete`
176
+ * - `prototype`: a new [[Prototype]], with the values it can be. `setter` says it is set through `__proto__`, whose
177
+ * setter must be the one the prototype chain reaches: `through`'s, when the holder is a `Reflect.set` receiver.
178
+ * `sameWindow` says the new prototype is one native holder, reached through the same window expression as the holder
179
+ * written, with nothing between the reads that could change which window that is (§3 Undecidable outcomes): the two
180
+ * belong to one window.
181
+ */
182
+ export type Change = {
183
+ kind: 'set';
184
+ member: MemberKey;
185
+ same: boolean;
186
+ /**
187
+ * Set when `same` holds only because a heap field carries the read of the slot (`s.orig = window.fetch;
188
+ * window.fetch = s.orig`): the value may be the native saved before an install, so the write is judged as a restore
189
+ * too (§3 Restores).
190
+ */
191
+ throughHeap?: true;
192
+ through?: Through | undefined;
193
+ value?: WrittenValue;
194
+ /** The expression the new value comes from, where it is evaluated, for wrap evidence (§5 capability 10). */
195
+ sources?: Source[];
196
+ } | {
197
+ kind: 'define';
198
+ member: MemberKey;
199
+ descriptor: DescriptorLiteral;
200
+ /**
201
+ * When the descriptor can be several objects the heap holds, or has fields that may be absent (§3, §5 Resolver
202
+ * capabilities 5), every descriptor it can be, the first of which is `descriptor`: `refused` for one that
203
+ * ToPropertyDescriptor refuses, so that nothing is written.
204
+ */
205
+ alternatives?: (DescriptorLiteral | 'refused')[];
206
+ via?: AccessorDefiner;
207
+ /** The expression that gives the descriptor, where it is evaluated, for descriptor restores (§3 Restores). */
208
+ source?: Source;
209
+ } | {
210
+ kind: 'delete';
211
+ member: MemberKey;
212
+ } | {
213
+ kind: 'prototype';
214
+ proto: Value[];
215
+ setter: boolean;
216
+ sameWindow: boolean;
217
+ through?: string | undefined;
218
+ };
219
+ /** An expression that gives a written value, and where it is evaluated. */
220
+ export interface Source {
221
+ node: AstNode;
222
+ at: Position;
223
+ }
224
+ /**
225
+ * What the syntax shows of the value a [[Set]] writes, where its outcome follows the value: `opener`, whose setter
226
+ * redefines it as an own data property for any value but `null` (§3). `isNull` says whether the value is `null`, or
227
+ * `unknown` when the analyzer can't decide it, as for a write-back of what the getter returns, which may be `null`.
228
+ * `site` is the value, or the getter or missing argument that gives it.
229
+ */
230
+ export interface WrittenValue {
231
+ isNull: Attribute;
232
+ site: AstNode;
233
+ }
234
+ /**
235
+ * The object a `Reflect.set` looks its member up on when it isn't the receiver written (§3): a native holder, or
236
+ * `unresolved`, the argument that denotes no native holder and may be any object.
237
+ */
238
+ export type Through = {
239
+ holder: string;
240
+ } | {
241
+ unresolved: AstNode;
242
+ };
243
+ /** An attribute's value in a descriptor: a boolean, or `unknown` when it can't be decided. */
244
+ export type Attribute = boolean | 'unknown';
245
+ /**
246
+ * A descriptor as the syntax shows it: the fields an object literal gives it (ECMA-262 ToPropertyDescriptor), and the
247
+ * parts the analyzer can't see (§3 Undecidable outcomes). `value.same` says the value is a read of the slot being
248
+ * defined, and `value.fresh` that it is a new object. `get` and `set` say the literal has the field, whatever value a later part gives it. It never shows both
249
+ * accessor and data fields, which ToPropertyDescriptor refuses.
250
+ */
251
+ export interface DescriptorLiteral {
252
+ /**
253
+ * `fresh` says every value it can be is an object or function the code creates, which differs from any value the
254
+ * member holds already.
255
+ */
256
+ value?: {
257
+ same: boolean;
258
+ fresh: boolean;
259
+ sources?: Source[];
260
+ throughHeap?: true;
261
+ };
262
+ get: boolean;
263
+ set: boolean;
264
+ writable?: Attribute;
265
+ enumerable?: Attribute;
266
+ configurable?: Attribute;
267
+ /**
268
+ * The parts that may give the descriptor any field it doesn't have itself, in source order: the descriptor, when it is
269
+ * no object the heap holds; an object's unseen base fields (a `new`, or a native's result such as
270
+ * `getOwnPropertyDescriptor`'s); a spread or a key that doesn't fold, which may also replace the values of the fields before it,
271
+ * so those values are not kept; and a `__proto__: p` field, whose object ToPropertyDescriptor reads for the fields
272
+ * the literal lacks. Empty when every field is seen.
273
+ */
274
+ unseen: AstNode[];
275
+ /** The fields whose attribute can't be decided (`{ enumerable: flag }`, `{ get configurable(){…} }`), in source order. */
276
+ undecided: AstNode[];
277
+ /**
278
+ * For one of several descriptors a define can have, what makes it one: the objects the descriptor can be, when it can
279
+ * be several, and the writes of the fields that may be absent (§3).
280
+ */
281
+ evidence?: AstNode[];
282
+ }
283
+ /** The legacy methods that define an accessor on their `this` (§3), with the accessor field each gives. */
284
+ declare const accessorDefiners: {
285
+ readonly __defineGetter__: "get";
286
+ readonly __defineSetter__: "set";
287
+ };
288
+ export type AccessorDefiner = keyof typeof accessorDefiners;
289
+ export interface WriteContext {
290
+ scope: ScopeRules;
291
+ resolution: GlobalResolution;
292
+ /** The realm's global holder, e.g. `Window`. */
293
+ global: string;
294
+ /** The window whose global object the code's free names are properties of (§4 Other windows). */
295
+ instance: RealmInstance;
296
+ /**
297
+ * Raises `analysis-budget` for folds that passed the `fold-length` cap in the key, holder or descriptor of a write
298
+ * that reaches the global object or a native holder, any alternative counting (Principle 5, §13).
299
+ */
300
+ budget(folds: readonly AstNode[]): void;
301
+ /**
302
+ * Counts the descriptor-alternatives cap for defines whose descriptor objects have more combinations of maybe-absent
303
+ * fields than it allows, so those fields were read as parts the analyzer can't see, and raises `analysis-budget` when
304
+ * the write reaches the global object or a native holder (Principle 5, §18).
305
+ */
306
+ descriptorsCut(sites: readonly AstNode[], native: boolean): void;
307
+ /**
308
+ * Counts the `candidateRuns` cap for a node whose candidate sites it cut, so they give nothing, and raises
309
+ * `analysis-budget` when a holder they write can be the global object or a native holder, any alternative counting
310
+ * (Principle 5, §18).
311
+ */
312
+ candidatesCut(node: AstNode, native: boolean): void;
313
+ /**
314
+ * The descriptor fields a native holder supplies as a descriptor's prototype, read through its chain in the unmutated
315
+ * catalog (§3 Undecidable outcomes); undefined when the analyzer can't read them.
316
+ */
317
+ descriptorFields(holder: string): DescriptorFields | undefined;
318
+ /** The caps (§18): `heapDepth`, `descriptorAlternatives` and `candidateRuns` here. */
319
+ caps: Pick<Caps, 'heapDepth' | 'descriptorAlternatives' | 'candidateRuns'>;
320
+ /** Counts a hit of the `heapDepth` cap at the heap field read it keeps a write-back from being followed through. */
321
+ capHit(name: 'heapDepth', node: AstNode): void;
322
+ /**
323
+ * Whether a write of `holder` whose key starts with `prefix` is a pattern wildcard: no catalog member of the holder or
324
+ * its catalog prototype chain starts with it, so it can name or shadow none (§5 Pattern wildcards).
325
+ */
326
+ patternPrefix(holder: string, prefix: string): boolean;
327
+ }
328
+ /**
329
+ * The native members `node` writes directly, in source order. When a fold in the key, holder or descriptor of the write
330
+ * passed the `fold-length` cap, and its holder can be the global object or a native holder, it goes to `budget`, whether
331
+ * or not the write resolves (Principle 5, §13): the value written, and a call's native function, are no part of it.
332
+ */
333
+ export declare function writesAt(node: AstNode, at: Position, context: WriteContext): Write[];
334
+ /**
335
+ * The native members `node` writes directly, as `writesAt` gives them, and the write sites in it whose member folds
336
+ * but whose holder may be an object the analyzer can't resolve (§5 Partially resolved writes).
337
+ */
338
+ export declare function sitesAt(node: AstNode, where: Position, context: WriteContext): Sites;
339
+ /** The write sites at a node (`sitesAt`). */
340
+ export interface Sites {
341
+ writes: Write[];
342
+ open: OpenWrite[];
343
+ wild: WildWrite[];
344
+ wide: WideSite[];
345
+ }
346
+ /** The name of the target a write names, before the catalog decides its outcome. */
347
+ export declare function candidateName(write: Write): string;
348
+ /** The fields ECMA-262 ToPropertyDescriptor reads. */
349
+ export declare const descriptorFields: ReadonlySet<string>;
350
+ /**
351
+ * The descriptor fields a native holder supplies as a descriptor's prototype (§3 Undecidable outcomes): `functions`, whose
352
+ * value is a function, and `throwing`, whose getter throws when ToPropertyDescriptor reads it.
353
+ */
354
+ export interface DescriptorFields {
355
+ readonly functions: ReadonlySet<string>;
356
+ readonly throwing: ReadonlySet<string>;
357
+ }
358
+ export {};