@runeditrun/rer 0.2.83 → 0.2.85

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 (269) hide show
  1. package/README.md +21 -24
  2. package/cli/README.md +17 -1
  3. package/cli/authoring.mjs +1 -0
  4. package/cli/bounded.mjs +1 -1
  5. package/cli/business/carry.mjs +149 -0
  6. package/cli/business/command.mjs +6 -1
  7. package/cli/business/connect.mjs +1 -1
  8. package/cli/business/local-commands.mjs +2 -0
  9. package/cli/business/opt-ins.mjs +8 -4
  10. package/cli/business/questions.mjs +4 -1
  11. package/cli/business/state.mjs +1 -1
  12. package/cli/business/supervisor.mjs +7 -1
  13. package/cli/container-transfer.mjs +2 -2
  14. package/cli/contract.mjs +7 -7
  15. package/cli/demo-host.mjs +5 -1
  16. package/cli/demo-native.mjs +2 -1
  17. package/cli/demo.mjs +6 -1
  18. package/cli/deploy-command.mjs +6 -4
  19. package/cli/deploy.mjs +9 -7
  20. package/cli/errors.mjs +1 -1
  21. package/cli/export.mjs +1 -1
  22. package/cli/human-error.mjs +20 -0
  23. package/cli/lifecycle.mjs +23 -5
  24. package/cli/main.mjs +1 -1
  25. package/cli/managed-data-schema.mjs +114 -0
  26. package/cli/managed-data-zip.mjs +116 -0
  27. package/cli/managed-data.mjs +110 -0
  28. package/cli/managed-server.mjs +25 -14
  29. package/cli/native-owner-entry.mjs +86 -0
  30. package/cli/output.mjs +3 -2
  31. package/cli/parse.mjs +3 -3
  32. package/cli/portability-empty.mjs +59 -0
  33. package/cli/portability-migrations.mjs +7 -5
  34. package/cli/portability-policy.mjs +5 -2
  35. package/cli/portability-worker.mjs +15 -6
  36. package/cli/portability.mjs +30 -8
  37. package/cli/ready-summary.mjs +9 -0
  38. package/cli/run-transfers.mjs +37 -0
  39. package/cli/runtime-front-door.mjs +4 -4
  40. package/cli/server-proxy.mjs +4 -3
  41. package/cli/server-registry.mjs +13 -8
  42. package/cli/site.mjs +6 -1
  43. package/cli/transfers.mjs +17 -4
  44. package/edition-authoring/base-copies.mjs +125 -30
  45. package/edition-authoring/copy-checkout.mjs +7 -120
  46. package/edition-authoring/edition-migrations.mjs +41 -0
  47. package/edition-authoring/files.mjs +67 -0
  48. package/edition-authoring/lock.mjs +2 -2
  49. package/edition-authoring/module-closure.mjs +232 -0
  50. package/edition-authoring/module-edges.mjs +100 -0
  51. package/edition-authoring/module-resolution.mjs +66 -0
  52. package/edition-authoring/module-syntax.mjs +57 -0
  53. package/edition-authoring/package-target.mjs +92 -0
  54. package/edition-authoring/runtime-dependencies.mjs +74 -97
  55. package/edition-authoring/vendor/babel-parser/LICENSE +22 -0
  56. package/edition-authoring/vendor/babel-parser/README.md +21 -0
  57. package/edition-authoring/vendor/babel-parser/babel-helper-string-parser/index.mjs +292 -0
  58. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/identifier.mjs +66 -0
  59. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/index.mjs +13 -0
  60. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/keyword.mjs +31 -0
  61. package/edition-authoring/vendor/babel-parser/babel-parser/index.mjs +99 -0
  62. package/edition-authoring/vendor/babel-parser/babel-parser/options.mjs +81 -0
  63. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/bind-operator-errors.mjs +8 -0
  64. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/module-errors.mjs +15 -0
  65. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/parse-expression-errors.mjs +10 -0
  66. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/pipeline-operator-errors.mjs +29 -0
  67. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/standard-errors.mjs +224 -0
  68. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/strict-mode-errors.mjs +17 -0
  69. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/to-node-description.mjs +31 -0
  70. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error.mjs +114 -0
  71. package/edition-authoring/vendor/babel-parser/babel-parser/parser/base.mjs +34 -0
  72. package/edition-authoring/vendor/babel-parser/babel-parser/parser/comments.mjs +199 -0
  73. package/edition-authoring/vendor/babel-parser/babel-parser/parser/expression.mjs +1794 -0
  74. package/edition-authoring/vendor/babel-parser/babel-parser/parser/index.mjs +76 -0
  75. package/edition-authoring/vendor/babel-parser/babel-parser/parser/lval.mjs +439 -0
  76. package/edition-authoring/vendor/babel-parser/babel-parser/parser/node.mjs +111 -0
  77. package/edition-authoring/vendor/babel-parser/babel-parser/parser/statement.mjs +1962 -0
  78. package/edition-authoring/vendor/babel-parser/babel-parser/parser/util.mjs +244 -0
  79. package/edition-authoring/vendor/babel-parser/babel-parser/plugin-utils.mjs +116 -0
  80. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/estree.mjs +417 -0
  81. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/index.mjs +2412 -0
  82. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/scope.mjs +37 -0
  83. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/index.mjs +420 -0
  84. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/xhtml.mjs +261 -0
  85. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/placeholders.mjs +205 -0
  86. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/index.mjs +2889 -0
  87. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/scope.mjs +115 -0
  88. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/v8intrinsic.mjs +26 -0
  89. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/context.mjs +22 -0
  90. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/index.mjs +1037 -0
  91. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/state.mjs +178 -0
  92. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/types.mjs +583 -0
  93. package/edition-authoring/vendor/babel-parser/babel-parser/types.mjs +1 -0
  94. package/edition-authoring/vendor/babel-parser/babel-parser/util/class-scope.mjs +82 -0
  95. package/edition-authoring/vendor/babel-parser/babel-parser/util/expression-scope.mjs +121 -0
  96. package/edition-authoring/vendor/babel-parser/babel-parser/util/identifier.mjs +23 -0
  97. package/edition-authoring/vendor/babel-parser/babel-parser/util/location.mjs +34 -0
  98. package/edition-authoring/vendor/babel-parser/babel-parser/util/production-parameter.mjs +40 -0
  99. package/edition-authoring/vendor/babel-parser/babel-parser/util/scope.mjs +173 -0
  100. package/edition-authoring/vendor/babel-parser/babel-parser/util/scopeflags.mjs +66 -0
  101. package/edition-authoring/vendor/babel-parser/babel-parser/util/whitespace.mjs +61 -0
  102. package/edition-authoring/vendor/yaml/LICENSE +13 -0
  103. package/edition-authoring/vendor/yaml/README.md +11 -0
  104. package/edition-authoring/vendor/yaml/compose/compose-collection.mjs +88 -0
  105. package/edition-authoring/vendor/yaml/compose/compose-doc.mjs +43 -0
  106. package/edition-authoring/vendor/yaml/compose/compose-node.mjs +110 -0
  107. package/edition-authoring/vendor/yaml/compose/compose-scalar.mjs +86 -0
  108. package/edition-authoring/vendor/yaml/compose/composer.mjs +218 -0
  109. package/edition-authoring/vendor/yaml/compose/resolve-block-map.mjs +115 -0
  110. package/edition-authoring/vendor/yaml/compose/resolve-block-scalar.mjs +198 -0
  111. package/edition-authoring/vendor/yaml/compose/resolve-block-seq.mjs +49 -0
  112. package/edition-authoring/vendor/yaml/compose/resolve-end.mjs +37 -0
  113. package/edition-authoring/vendor/yaml/compose/resolve-flow-collection.mjs +207 -0
  114. package/edition-authoring/vendor/yaml/compose/resolve-flow-scalar.mjs +228 -0
  115. package/edition-authoring/vendor/yaml/compose/resolve-props.mjs +148 -0
  116. package/edition-authoring/vendor/yaml/compose/util-contains-newline.mjs +34 -0
  117. package/edition-authoring/vendor/yaml/compose/util-empty-scalar-position.mjs +27 -0
  118. package/edition-authoring/vendor/yaml/compose/util-flow-indent-check.mjs +15 -0
  119. package/edition-authoring/vendor/yaml/compose/util-map-includes.mjs +13 -0
  120. package/edition-authoring/vendor/yaml/doc/Document.mjs +333 -0
  121. package/edition-authoring/vendor/yaml/doc/anchors.mjs +74 -0
  122. package/edition-authoring/vendor/yaml/doc/applyReviver.mjs +54 -0
  123. package/edition-authoring/vendor/yaml/doc/createNode.mjs +88 -0
  124. package/edition-authoring/vendor/yaml/doc/directives.mjs +176 -0
  125. package/edition-authoring/vendor/yaml/errors.mjs +57 -0
  126. package/edition-authoring/vendor/yaml/index.mjs +17 -0
  127. package/edition-authoring/vendor/yaml/log.mjs +11 -0
  128. package/edition-authoring/vendor/yaml/nodes/Alias.mjs +119 -0
  129. package/edition-authoring/vendor/yaml/nodes/Collection.mjs +147 -0
  130. package/edition-authoring/vendor/yaml/nodes/Node.mjs +38 -0
  131. package/edition-authoring/vendor/yaml/nodes/Pair.mjs +36 -0
  132. package/edition-authoring/vendor/yaml/nodes/Scalar.mjs +24 -0
  133. package/edition-authoring/vendor/yaml/nodes/YAMLMap.mjs +144 -0
  134. package/edition-authoring/vendor/yaml/nodes/YAMLSeq.mjs +113 -0
  135. package/edition-authoring/vendor/yaml/nodes/addPairToJSMap.mjs +62 -0
  136. package/edition-authoring/vendor/yaml/nodes/identity.mjs +36 -0
  137. package/edition-authoring/vendor/yaml/nodes/toJS.mjs +35 -0
  138. package/edition-authoring/vendor/yaml/parse/cst-scalar.mjs +214 -0
  139. package/edition-authoring/vendor/yaml/parse/cst-stringify.mjs +61 -0
  140. package/edition-authoring/vendor/yaml/parse/cst-visit.mjs +97 -0
  141. package/edition-authoring/vendor/yaml/parse/cst.mjs +98 -0
  142. package/edition-authoring/vendor/yaml/parse/lexer.mjs +722 -0
  143. package/edition-authoring/vendor/yaml/parse/line-counter.mjs +39 -0
  144. package/edition-authoring/vendor/yaml/parse/parser.mjs +975 -0
  145. package/edition-authoring/vendor/yaml/public-api.mjs +102 -0
  146. package/edition-authoring/vendor/yaml/schema/Schema.mjs +37 -0
  147. package/edition-authoring/vendor/yaml/schema/common/map.mjs +17 -0
  148. package/edition-authoring/vendor/yaml/schema/common/null.mjs +15 -0
  149. package/edition-authoring/vendor/yaml/schema/common/seq.mjs +17 -0
  150. package/edition-authoring/vendor/yaml/schema/common/string.mjs +14 -0
  151. package/edition-authoring/vendor/yaml/schema/core/bool.mjs +19 -0
  152. package/edition-authoring/vendor/yaml/schema/core/float.mjs +43 -0
  153. package/edition-authoring/vendor/yaml/schema/core/int.mjs +38 -0
  154. package/edition-authoring/vendor/yaml/schema/core/schema.mjs +23 -0
  155. package/edition-authoring/vendor/yaml/schema/json/schema.mjs +62 -0
  156. package/edition-authoring/vendor/yaml/schema/tags.mjs +96 -0
  157. package/edition-authoring/vendor/yaml/schema/yaml-1.1/binary.mjs +59 -0
  158. package/edition-authoring/vendor/yaml/schema/yaml-1.1/bool.mjs +26 -0
  159. package/edition-authoring/vendor/yaml/schema/yaml-1.1/float.mjs +46 -0
  160. package/edition-authoring/vendor/yaml/schema/yaml-1.1/int.mjs +71 -0
  161. package/edition-authoring/vendor/yaml/schema/yaml-1.1/merge.mjs +67 -0
  162. package/edition-authoring/vendor/yaml/schema/yaml-1.1/omap.mjs +74 -0
  163. package/edition-authoring/vendor/yaml/schema/yaml-1.1/pairs.mjs +78 -0
  164. package/edition-authoring/vendor/yaml/schema/yaml-1.1/schema.mjs +39 -0
  165. package/edition-authoring/vendor/yaml/schema/yaml-1.1/set.mjs +93 -0
  166. package/edition-authoring/vendor/yaml/schema/yaml-1.1/timestamp.mjs +101 -0
  167. package/edition-authoring/vendor/yaml/stringify/foldFlowLines.mjs +146 -0
  168. package/edition-authoring/vendor/yaml/stringify/stringify.mjs +130 -0
  169. package/edition-authoring/vendor/yaml/stringify/stringifyCollection.mjs +155 -0
  170. package/edition-authoring/vendor/yaml/stringify/stringifyComment.mjs +20 -0
  171. package/edition-authoring/vendor/yaml/stringify/stringifyDocument.mjs +85 -0
  172. package/edition-authoring/vendor/yaml/stringify/stringifyNumber.mjs +25 -0
  173. package/edition-authoring/vendor/yaml/stringify/stringifyPair.mjs +150 -0
  174. package/edition-authoring/vendor/yaml/stringify/stringifyString.mjs +338 -0
  175. package/edition-authoring/vendor/yaml/util.mjs +11 -0
  176. package/edition-authoring/vendor/yaml/visit.mjs +233 -0
  177. package/edition-authoring/workflow-copies.mjs +125 -0
  178. package/edition-authoring/workflow-scripts.mjs +112 -0
  179. package/foundation/runtime/contract-docs.mjs +754 -0
  180. package/foundation/runtime/run-data.d.mts +1 -0
  181. package/foundation/runtime/run-data.mjs +2 -0
  182. package/global/CHANGELOG.md +55 -3
  183. package/global/README.md +21 -24
  184. package/global/cli/command.mjs +8 -2
  185. package/global/cli/install.mjs +4 -5
  186. package/global/cli/path-link.mjs +3 -2
  187. package/global/cli/repo-command.mjs +3 -7
  188. package/global/launch/dev.mjs +12 -2
  189. package/global/launch/facts.mjs +2 -2
  190. package/global/launch/render.mjs +16 -9
  191. package/global/launch/state.mjs +4 -4
  192. package/global/main.mjs +12 -7
  193. package/install.sh +17 -6
  194. package/modules/container/README.md +6 -1
  195. package/modules/container/adapters/d1-limits.mjs +286 -0
  196. package/modules/container/adapters/d1-sqlite.mjs +95 -0
  197. package/modules/container/adapters/d1-workerd-preload.mjs +19 -0
  198. package/modules/container/adapters/d1-workerd-setup.mjs +26 -0
  199. package/modules/container/adapters/d1-workerd.mjs +5 -0
  200. package/modules/container/adapters/sqlite-worker.mjs +5 -3
  201. package/modules/container/build.mjs +1 -0
  202. package/modules/container/image-variables.mjs +8 -3
  203. package/modules/container/transfer.mjs +14 -4
  204. package/modules/container/worker-engine.mjs +3 -3
  205. package/modules/demo/declaration.mjs +1 -4
  206. package/modules/demo/vite.mjs +1 -1
  207. package/modules/demo-host/build.mjs +1 -0
  208. package/modules/demo-host/native/prepare.mjs +2 -1
  209. package/modules/demo-host/native/sql.mjs +7 -2
  210. package/modules/deploy-kit/README.md +23 -3
  211. package/modules/deploy-kit/d1-import-diagnostics.mjs +56 -0
  212. package/modules/deploy-kit/d1-import.mjs +17 -5
  213. package/modules/deploy-kit/diagnostics.mjs +29 -3
  214. package/modules/deploy-kit/owner-cli.mjs +20 -7
  215. package/modules/deploy-kit/provider-transport.mjs +19 -4
  216. package/modules/deploy-kit/provider.mjs +57 -22
  217. package/modules/deploy-kit/readiness-window.mjs +1 -1
  218. package/modules/deploy-kit/site.mjs +8 -3
  219. package/modules/deploy-kit/templates.mjs +3 -3
  220. package/modules/deploy-kit/worker.mjs +4 -4
  221. package/modules/import-kit/src/d1/README.md +23 -4
  222. package/modules/import-kit/src/d1/atomic-prefix.ts +2 -2
  223. package/modules/import-kit/src/d1/budget.ts +15 -7
  224. package/modules/import-kit/src/d1/column-layout.ts +5 -0
  225. package/modules/import-kit/src/d1/creation.ts +15 -8
  226. package/modules/import-kit/src/d1/database.ts +3 -3
  227. package/modules/import-kit/src/d1/erasure-pages.ts +2 -1
  228. package/modules/import-kit/src/d1/erasure.ts +2 -2
  229. package/modules/import-kit/src/d1/jobs.ts +10 -6
  230. package/modules/import-kit/src/d1/plans.ts +14 -8
  231. package/modules/import-kit/src/d1/retirement.ts +2 -2
  232. package/modules/import-kit/src/d1/sets.ts +1 -3
  233. package/modules/import-kit/src/d1/staged-creation.ts +3 -3
  234. package/modules/import-kit/src/door/limits.ts +1 -1
  235. package/modules/import-kit/src/door/refusals.ts +1 -1
  236. package/modules/portability/README.md +112 -4
  237. package/modules/portability/backfills.mjs +9 -8
  238. package/modules/portability/bridge.mjs +12 -5
  239. package/modules/portability/catalogue.mjs +12 -5
  240. package/modules/portability/files.mjs +4 -3
  241. package/modules/portability/http.mjs +3 -3
  242. package/modules/portability/import.mjs +18 -9
  243. package/modules/portability/index.d.mts +4 -3
  244. package/modules/portability/index.mjs +1 -1
  245. package/modules/portability/ledgers.mjs +3 -2
  246. package/modules/portability/legacy-safety.mjs +11 -2
  247. package/modules/portability/migration-history.mjs +2 -2
  248. package/modules/portability/progress.mjs +1 -0
  249. package/modules/portability/restore-empty.mjs +12 -0
  250. package/modules/release/github-verify.mjs +11 -2
  251. package/onboarding/adapter.mjs +35 -6
  252. package/onboarding/app-fetch.mjs +6 -4
  253. package/onboarding/development-runtime.mjs +19 -0
  254. package/onboarding/local/operation.mjs +45 -27
  255. package/onboarding/loopback-fetch.mjs +16 -0
  256. package/onboarding/operator-installer.mjs +4 -6
  257. package/onboarding/process-diagnostics.mjs +6 -2
  258. package/onboarding/production-runtime.mjs +4 -2
  259. package/onboarding/readiness.mjs +1 -0
  260. package/package.json +1 -1
  261. package/scripts/publish-check/README.md +6 -0
  262. package/scripts/publish-check/history_scan.py +5 -3
  263. package/scripts/publish-check/hygiene_config.py +2 -1
  264. package/scripts/publish-check/public_hygiene.py +1 -1
  265. package/scripts/publish-check/report.py +9 -3
  266. package/scripts/publish-check/third-party-notices.json +13 -0
  267. package/scripts/publish-check/third_party_notices.py +38 -0
  268. package/scripts/publish-check/tree_scan.py +6 -0
  269. package/scripts/publish-check.mjs +1 -1
@@ -0,0 +1,1037 @@
1
+ // Generated from Babel v7.29.8 (MIT); see README.md.
2
+ import { OptionFlags } from "../options.mjs";
3
+ import { Position, SourceLocation, createPositionWithColumnOffset } from "../util/location.mjs";
4
+ import CommentsParser from "../parser/comments.mjs";
5
+ import { isIdentifierStart, isIdentifierChar } from "../util/identifier.mjs";
6
+ import { tokenIsKeyword, tokenLabelName, tt, keywords as keywordTypes } from "./types.mjs";
7
+ import { Errors } from "../parse-error.mjs";
8
+ import { lineBreakG, isNewLine, isWhitespace, skipWhiteSpace, skipWhiteSpaceInLine } from "../util/whitespace.mjs";
9
+ import State from "./state.mjs";
10
+ import { readInt, readCodePoint, readStringContents } from "../../babel-helper-string-parser/index.mjs";
11
+ function buildPosition(pos, lineStart, curLine) {
12
+ return new Position(curLine, pos - lineStart, pos);
13
+ }
14
+ const VALID_REGEX_FLAGS = /* @__PURE__ */ new Set([103, 109, 115, 105, 121, 117, 100, 118]);
15
+ class Token {
16
+ constructor(state) {
17
+ const startIndex = state.startIndex || 0;
18
+ this.type = state.type;
19
+ this.value = state.value;
20
+ this.start = startIndex + state.start;
21
+ this.end = startIndex + state.end;
22
+ this.loc = new SourceLocation(state.startLoc, state.endLoc);
23
+ }
24
+ }
25
+ class Tokenizer extends CommentsParser {
26
+ isLookahead;
27
+ tokens = [];
28
+ constructor(options, input) {
29
+ super();
30
+ this.state = new State();
31
+ this.state.init(options);
32
+ this.input = input;
33
+ this.length = input.length;
34
+ this.comments = [];
35
+ this.isLookahead = false;
36
+ }
37
+ pushToken(token) {
38
+ this.tokens.length = this.state.tokensLength;
39
+ this.tokens.push(token);
40
+ ++this.state.tokensLength;
41
+ }
42
+ next() {
43
+ this.checkKeywordEscapes();
44
+ if (this.optionFlags & OptionFlags.Tokens) {
45
+ this.pushToken(new Token(this.state));
46
+ }
47
+ this.state.lastTokEndLoc = this.state.endLoc;
48
+ this.state.lastTokStartLoc = this.state.startLoc;
49
+ this.nextToken();
50
+ }
51
+ eat(type) {
52
+ if (this.match(type)) {
53
+ this.next();
54
+ return true;
55
+ } else {
56
+ return false;
57
+ }
58
+ }
59
+ match(type) {
60
+ return this.state.type === type;
61
+ }
62
+ createLookaheadState(state) {
63
+ return {
64
+ pos: state.pos,
65
+ value: null,
66
+ type: state.type,
67
+ start: state.start,
68
+ end: state.end,
69
+ context: [this.curContext()],
70
+ inType: state.inType,
71
+ startLoc: state.startLoc,
72
+ lastTokEndLoc: state.lastTokEndLoc,
73
+ curLine: state.curLine,
74
+ lineStart: state.lineStart,
75
+ curPosition: state.curPosition
76
+ };
77
+ }
78
+ lookahead() {
79
+ const old = this.state;
80
+ this.state = this.createLookaheadState(old);
81
+ this.isLookahead = true;
82
+ this.nextToken();
83
+ this.isLookahead = false;
84
+ const curr = this.state;
85
+ this.state = old;
86
+ return curr;
87
+ }
88
+ nextTokenStart() {
89
+ return this.nextTokenStartSince(this.state.pos);
90
+ }
91
+ nextTokenStartSince(pos) {
92
+ skipWhiteSpace.lastIndex = pos;
93
+ return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos;
94
+ }
95
+ lookaheadCharCode() {
96
+ return this.lookaheadCharCodeSince(this.state.pos);
97
+ }
98
+ lookaheadCharCodeSince(pos) {
99
+ return this.input.charCodeAt(this.nextTokenStartSince(pos));
100
+ }
101
+ nextTokenInLineStart() {
102
+ return this.nextTokenInLineStartSince(this.state.pos);
103
+ }
104
+ nextTokenInLineStartSince(pos) {
105
+ skipWhiteSpaceInLine.lastIndex = pos;
106
+ return skipWhiteSpaceInLine.test(this.input) ? skipWhiteSpaceInLine.lastIndex : pos;
107
+ }
108
+ lookaheadInLineCharCode() {
109
+ return this.input.charCodeAt(this.nextTokenInLineStart());
110
+ }
111
+ codePointAtPos(pos) {
112
+ let cp = this.input.charCodeAt(pos);
113
+ if ((cp & 64512) === 55296 && ++pos < this.input.length) {
114
+ const trail = this.input.charCodeAt(pos);
115
+ if ((trail & 64512) === 56320) {
116
+ cp = 65536 + ((cp & 1023) << 10) + (trail & 1023);
117
+ }
118
+ }
119
+ return cp;
120
+ }
121
+ setStrict(strict) {
122
+ this.state.strict = strict;
123
+ if (strict) {
124
+ this.state.strictErrors.forEach(([toParseError, at]) => this.raise(toParseError, at));
125
+ this.state.strictErrors.clear();
126
+ }
127
+ }
128
+ curContext() {
129
+ return this.state.context[this.state.context.length - 1];
130
+ }
131
+ nextToken() {
132
+ this.skipSpace();
133
+ this.state.start = this.state.pos;
134
+ if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
135
+ if (this.state.pos >= this.length) {
136
+ this.finishToken(tt.eof);
137
+ return;
138
+ }
139
+ this.getTokenFromCode(this.codePointAtPos(this.state.pos));
140
+ }
141
+ skipBlockComment(commentEnd) {
142
+ let startLoc;
143
+ if (!this.isLookahead) startLoc = this.state.curPosition();
144
+ const start = this.state.pos;
145
+ const end = this.input.indexOf(commentEnd, start + 2);
146
+ if (end === -1) {
147
+ throw this.raise(Errors.UnterminatedComment, this.state.curPosition());
148
+ }
149
+ this.state.pos = end + commentEnd.length;
150
+ lineBreakG.lastIndex = start + 2;
151
+ while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) {
152
+ ++this.state.curLine;
153
+ this.state.lineStart = lineBreakG.lastIndex;
154
+ }
155
+ if (this.isLookahead) return;
156
+ const comment = {
157
+ type: "CommentBlock",
158
+ value: this.input.slice(start + 2, end),
159
+ start: this.sourceToOffsetPos(start),
160
+ end: this.sourceToOffsetPos(end + commentEnd.length),
161
+ loc: new SourceLocation(startLoc, this.state.curPosition())
162
+ };
163
+ if (this.optionFlags & OptionFlags.Tokens) this.pushToken(comment);
164
+ return comment;
165
+ }
166
+ skipLineComment(startSkip) {
167
+ const start = this.state.pos;
168
+ let startLoc;
169
+ if (!this.isLookahead) startLoc = this.state.curPosition();
170
+ let ch = this.input.charCodeAt(this.state.pos += startSkip);
171
+ if (this.state.pos < this.length) {
172
+ while (!isNewLine(ch) && ++this.state.pos < this.length) {
173
+ ch = this.input.charCodeAt(this.state.pos);
174
+ }
175
+ }
176
+ if (this.isLookahead) return;
177
+ const end = this.state.pos;
178
+ const value = this.input.slice(start + startSkip, end);
179
+ const comment = {
180
+ type: "CommentLine",
181
+ value,
182
+ start: this.sourceToOffsetPos(start),
183
+ end: this.sourceToOffsetPos(end),
184
+ loc: new SourceLocation(startLoc, this.state.curPosition())
185
+ };
186
+ if (this.optionFlags & OptionFlags.Tokens) this.pushToken(comment);
187
+ return comment;
188
+ }
189
+ skipSpace() {
190
+ const spaceStart = this.state.pos;
191
+ const comments = this.optionFlags & OptionFlags.AttachComment ? [] : null;
192
+ loop: while (this.state.pos < this.length) {
193
+ const ch = this.input.charCodeAt(this.state.pos);
194
+ switch (ch) {
195
+ case 32:
196
+ case 160:
197
+ case 9:
198
+ ++this.state.pos;
199
+ break;
200
+ case 13:
201
+ if (this.input.charCodeAt(this.state.pos + 1) === 10) {
202
+ ++this.state.pos;
203
+ }
204
+ // falls through (upstream parser grammar)
205
+ case 10:
206
+ case 8232:
207
+ case 8233:
208
+ ++this.state.pos;
209
+ ++this.state.curLine;
210
+ this.state.lineStart = this.state.pos;
211
+ break;
212
+ case 47:
213
+ switch (this.input.charCodeAt(this.state.pos + 1)) {
214
+ case 42: {
215
+ const comment = this.skipBlockComment("*/");
216
+ if (comment !== void 0) {
217
+ this.addComment(comment);
218
+ comments?.push(comment);
219
+ }
220
+ break;
221
+ }
222
+ case 47: {
223
+ const comment = this.skipLineComment(2);
224
+ if (comment !== void 0) {
225
+ this.addComment(comment);
226
+ comments?.push(comment);
227
+ }
228
+ break;
229
+ }
230
+ default:
231
+ break loop;
232
+ }
233
+ break;
234
+ default:
235
+ if (isWhitespace(ch)) {
236
+ ++this.state.pos;
237
+ } else if (ch === 45 && !this.inModule && this.optionFlags & OptionFlags.AnnexB) {
238
+ const pos = this.state.pos;
239
+ if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
240
+ const comment = this.skipLineComment(3);
241
+ if (comment !== void 0) {
242
+ this.addComment(comment);
243
+ comments?.push(comment);
244
+ }
245
+ } else {
246
+ break loop;
247
+ }
248
+ } else if (ch === 60 && !this.inModule && this.optionFlags & OptionFlags.AnnexB) {
249
+ const pos = this.state.pos;
250
+ if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
251
+ const comment = this.skipLineComment(4);
252
+ if (comment !== void 0) {
253
+ this.addComment(comment);
254
+ comments?.push(comment);
255
+ }
256
+ } else {
257
+ break loop;
258
+ }
259
+ } else {
260
+ break loop;
261
+ }
262
+ }
263
+ }
264
+ if (comments?.length > 0) {
265
+ const end = this.state.pos;
266
+ const commentWhitespace = {
267
+ start: this.sourceToOffsetPos(spaceStart),
268
+ end: this.sourceToOffsetPos(end),
269
+ comments,
270
+ leadingNode: null,
271
+ trailingNode: null,
272
+ containingNode: null
273
+ };
274
+ this.state.commentStack.push(commentWhitespace);
275
+ }
276
+ }
277
+ finishToken(type, val) {
278
+ this.state.end = this.state.pos;
279
+ this.state.endLoc = this.state.curPosition();
280
+ const prevType = this.state.type;
281
+ this.state.type = type;
282
+ this.state.value = val;
283
+ if (!this.isLookahead) {
284
+ this.updateContext(prevType);
285
+ }
286
+ }
287
+ replaceToken(type) {
288
+ this.state.type = type;
289
+ this.updateContext();
290
+ }
291
+ readToken_numberSign() {
292
+ if (this.state.pos === 0 && this.readToken_interpreter()) {
293
+ return;
294
+ }
295
+ const nextPos = this.state.pos + 1;
296
+ const next = this.codePointAtPos(nextPos);
297
+ if (next >= 48 && next <= 57) {
298
+ throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition());
299
+ }
300
+ if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
301
+ this.expectPlugin("recordAndTuple");
302
+ if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") {
303
+ throw this.raise(next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, this.state.curPosition());
304
+ }
305
+ this.state.pos += 2;
306
+ if (next === 123) {
307
+ this.finishToken(tt.braceHashL);
308
+ } else {
309
+ this.finishToken(tt.bracketHashL);
310
+ }
311
+ } else if (isIdentifierStart(next)) {
312
+ ++this.state.pos;
313
+ this.finishToken(tt.privateName, this.readWord1(next));
314
+ } else if (next === 92) {
315
+ ++this.state.pos;
316
+ this.finishToken(tt.privateName, this.readWord1());
317
+ } else {
318
+ this.finishOp(tt.hash, 1);
319
+ }
320
+ }
321
+ readToken_dot() {
322
+ const next = this.input.charCodeAt(this.state.pos + 1);
323
+ if (next >= 48 && next <= 57) {
324
+ this.readNumber(true);
325
+ return;
326
+ }
327
+ if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
328
+ this.state.pos += 3;
329
+ this.finishToken(tt.ellipsis);
330
+ } else {
331
+ ++this.state.pos;
332
+ this.finishToken(tt.dot);
333
+ }
334
+ }
335
+ readToken_slash() {
336
+ const next = this.input.charCodeAt(this.state.pos + 1);
337
+ if (next === 61) {
338
+ this.finishOp(tt.slashAssign, 2);
339
+ } else {
340
+ this.finishOp(tt.slash, 1);
341
+ }
342
+ }
343
+ readToken_interpreter() {
344
+ if (this.state.pos !== 0 || this.length < 2) return false;
345
+ let ch = this.input.charCodeAt(this.state.pos + 1);
346
+ if (ch !== 33) return false;
347
+ const start = this.state.pos;
348
+ this.state.pos += 1;
349
+ while (!isNewLine(ch) && ++this.state.pos < this.length) {
350
+ ch = this.input.charCodeAt(this.state.pos);
351
+ }
352
+ const value = this.input.slice(start + 2, this.state.pos);
353
+ this.finishToken(tt.interpreterDirective, value);
354
+ return true;
355
+ }
356
+ readToken_mult_modulo(code) {
357
+ let type = code === 42 ? tt.star : tt.modulo;
358
+ let width = 1;
359
+ let next = this.input.charCodeAt(this.state.pos + 1);
360
+ if (code === 42 && next === 42) {
361
+ width++;
362
+ next = this.input.charCodeAt(this.state.pos + 2);
363
+ type = tt.exponent;
364
+ }
365
+ if (next === 61 && !this.state.inType) {
366
+ width++;
367
+ type = code === 37 ? tt.moduloAssign : tt.assign;
368
+ }
369
+ this.finishOp(type, width);
370
+ }
371
+ readToken_pipe_amp(code) {
372
+ const next = this.input.charCodeAt(this.state.pos + 1);
373
+ if (next === code) {
374
+ if (this.input.charCodeAt(this.state.pos + 2) === 61) {
375
+ this.finishOp(tt.assign, 3);
376
+ } else {
377
+ this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2);
378
+ }
379
+ return;
380
+ }
381
+ if (code === 124) {
382
+ if (next === 62) {
383
+ this.finishOp(tt.pipeline, 2);
384
+ return;
385
+ }
386
+ if (this.hasPlugin("recordAndTuple") && next === 125) {
387
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
388
+ throw this.raise(Errors.RecordExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
389
+ }
390
+ this.state.pos += 2;
391
+ this.finishToken(tt.braceBarR);
392
+ return;
393
+ }
394
+ if (this.hasPlugin("recordAndTuple") && next === 93) {
395
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
396
+ throw this.raise(Errors.TupleExpressionBarIncorrectEndSyntaxType, this.state.curPosition());
397
+ }
398
+ this.state.pos += 2;
399
+ this.finishToken(tt.bracketBarR);
400
+ return;
401
+ }
402
+ }
403
+ if (next === 61) {
404
+ this.finishOp(tt.assign, 2);
405
+ return;
406
+ }
407
+ this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1);
408
+ }
409
+ readToken_caret() {
410
+ const next = this.input.charCodeAt(this.state.pos + 1);
411
+ if (next === 61 && !this.state.inType) {
412
+ this.finishOp(tt.xorAssign, 2);
413
+ } else if (next === 94 && this.hasPlugin(["pipelineOperator", {
414
+ proposal: "hack",
415
+ topicToken: "^^"
416
+ }])) {
417
+ this.finishOp(tt.doubleCaret, 2);
418
+ const lookaheadCh = this.input.codePointAt(this.state.pos);
419
+ if (lookaheadCh === 94) {
420
+ this.unexpected();
421
+ }
422
+ } else {
423
+ this.finishOp(tt.bitwiseXOR, 1);
424
+ }
425
+ }
426
+ readToken_atSign() {
427
+ const next = this.input.charCodeAt(this.state.pos + 1);
428
+ if (next === 64 && this.hasPlugin(["pipelineOperator", {
429
+ proposal: "hack",
430
+ topicToken: "@@"
431
+ }])) {
432
+ this.finishOp(tt.doubleAt, 2);
433
+ } else {
434
+ this.finishOp(tt.at, 1);
435
+ }
436
+ }
437
+ readToken_plus_min(code) {
438
+ const next = this.input.charCodeAt(this.state.pos + 1);
439
+ if (next === code) {
440
+ this.finishOp(tt.incDec, 2);
441
+ return;
442
+ }
443
+ if (next === 61) {
444
+ this.finishOp(tt.assign, 2);
445
+ } else {
446
+ this.finishOp(tt.plusMin, 1);
447
+ }
448
+ }
449
+ readToken_lt() {
450
+ const {
451
+ pos
452
+ } = this.state;
453
+ const next = this.input.charCodeAt(pos + 1);
454
+ if (next === 60) {
455
+ if (this.input.charCodeAt(pos + 2) === 61) {
456
+ this.finishOp(tt.assign, 3);
457
+ return;
458
+ }
459
+ this.finishOp(tt.bitShiftL, 2);
460
+ return;
461
+ }
462
+ if (next === 61) {
463
+ this.finishOp(tt.relational, 2);
464
+ return;
465
+ }
466
+ this.finishOp(tt.lt, 1);
467
+ }
468
+ readToken_gt() {
469
+ const {
470
+ pos
471
+ } = this.state;
472
+ const next = this.input.charCodeAt(pos + 1);
473
+ if (next === 62) {
474
+ const size = this.input.charCodeAt(pos + 2) === 62 ? 3 : 2;
475
+ if (this.input.charCodeAt(pos + size) === 61) {
476
+ this.finishOp(tt.assign, size + 1);
477
+ return;
478
+ }
479
+ this.finishOp(tt.bitShiftR, size);
480
+ return;
481
+ }
482
+ if (next === 61) {
483
+ this.finishOp(tt.relational, 2);
484
+ return;
485
+ }
486
+ this.finishOp(tt.gt, 1);
487
+ }
488
+ readToken_eq_excl(code) {
489
+ const next = this.input.charCodeAt(this.state.pos + 1);
490
+ if (next === 61) {
491
+ this.finishOp(tt.equality, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
492
+ return;
493
+ }
494
+ if (code === 61 && next === 62) {
495
+ this.state.pos += 2;
496
+ this.finishToken(tt.arrow);
497
+ return;
498
+ }
499
+ this.finishOp(code === 61 ? tt.eq : tt.bang, 1);
500
+ }
501
+ readToken_question() {
502
+ const next = this.input.charCodeAt(this.state.pos + 1);
503
+ const next2 = this.input.charCodeAt(this.state.pos + 2);
504
+ if (next === 63) {
505
+ if (next2 === 61) {
506
+ this.finishOp(tt.assign, 3);
507
+ } else {
508
+ this.finishOp(tt.nullishCoalescing, 2);
509
+ }
510
+ } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
511
+ this.state.pos += 2;
512
+ this.finishToken(tt.questionDot);
513
+ } else {
514
+ ++this.state.pos;
515
+ this.finishToken(tt.question);
516
+ }
517
+ }
518
+ getTokenFromCode(code) {
519
+ switch (code) {
520
+ case 46:
521
+ this.readToken_dot();
522
+ return;
523
+ case 40:
524
+ ++this.state.pos;
525
+ this.finishToken(tt.parenL);
526
+ return;
527
+ case 41:
528
+ ++this.state.pos;
529
+ this.finishToken(tt.parenR);
530
+ return;
531
+ case 59:
532
+ ++this.state.pos;
533
+ this.finishToken(tt.semi);
534
+ return;
535
+ case 44:
536
+ ++this.state.pos;
537
+ this.finishToken(tt.comma);
538
+ return;
539
+ case 91:
540
+ if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
541
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
542
+ throw this.raise(Errors.TupleExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
543
+ }
544
+ this.state.pos += 2;
545
+ this.finishToken(tt.bracketBarL);
546
+ } else {
547
+ ++this.state.pos;
548
+ this.finishToken(tt.bracketL);
549
+ }
550
+ return;
551
+ case 93:
552
+ ++this.state.pos;
553
+ this.finishToken(tt.bracketR);
554
+ return;
555
+ case 123:
556
+ if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
557
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
558
+ throw this.raise(Errors.RecordExpressionBarIncorrectStartSyntaxType, this.state.curPosition());
559
+ }
560
+ this.state.pos += 2;
561
+ this.finishToken(tt.braceBarL);
562
+ } else {
563
+ ++this.state.pos;
564
+ this.finishToken(tt.braceL);
565
+ }
566
+ return;
567
+ case 125:
568
+ ++this.state.pos;
569
+ this.finishToken(tt.braceR);
570
+ return;
571
+ case 58:
572
+ if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
573
+ this.finishOp(tt.doubleColon, 2);
574
+ } else {
575
+ ++this.state.pos;
576
+ this.finishToken(tt.colon);
577
+ }
578
+ return;
579
+ case 63:
580
+ this.readToken_question();
581
+ return;
582
+ case 96:
583
+ this.readTemplateToken();
584
+ return;
585
+ case 48: {
586
+ const next = this.input.charCodeAt(this.state.pos + 1);
587
+ if (next === 120 || next === 88) {
588
+ this.readRadixNumber(16);
589
+ return;
590
+ }
591
+ if (next === 111 || next === 79) {
592
+ this.readRadixNumber(8);
593
+ return;
594
+ }
595
+ if (next === 98 || next === 66) {
596
+ this.readRadixNumber(2);
597
+ return;
598
+ }
599
+ }
600
+ // falls through (upstream parser grammar)
601
+ case 49:
602
+ case 50:
603
+ case 51:
604
+ case 52:
605
+ case 53:
606
+ case 54:
607
+ case 55:
608
+ case 56:
609
+ case 57:
610
+ this.readNumber(false);
611
+ return;
612
+ case 34:
613
+ case 39:
614
+ this.readString(code);
615
+ return;
616
+ case 47:
617
+ this.readToken_slash();
618
+ return;
619
+ case 37:
620
+ case 42:
621
+ this.readToken_mult_modulo(code);
622
+ return;
623
+ case 124:
624
+ case 38:
625
+ this.readToken_pipe_amp(code);
626
+ return;
627
+ case 94:
628
+ this.readToken_caret();
629
+ return;
630
+ case 43:
631
+ case 45:
632
+ this.readToken_plus_min(code);
633
+ return;
634
+ case 60:
635
+ this.readToken_lt();
636
+ return;
637
+ case 62:
638
+ this.readToken_gt();
639
+ return;
640
+ case 61:
641
+ case 33:
642
+ this.readToken_eq_excl(code);
643
+ return;
644
+ case 126:
645
+ this.finishOp(tt.tilde, 1);
646
+ return;
647
+ case 64:
648
+ this.readToken_atSign();
649
+ return;
650
+ case 35:
651
+ this.readToken_numberSign();
652
+ return;
653
+ case 92:
654
+ this.readWord();
655
+ return;
656
+ default:
657
+ if (isIdentifierStart(code)) {
658
+ this.readWord(code);
659
+ return;
660
+ }
661
+ }
662
+ throw this.raise(Errors.InvalidOrUnexpectedToken, this.state.curPosition(), {
663
+ unexpected: String.fromCodePoint(code)
664
+ });
665
+ }
666
+ finishOp(type, size) {
667
+ const str = this.input.slice(this.state.pos, this.state.pos + size);
668
+ this.state.pos += size;
669
+ this.finishToken(type, str);
670
+ }
671
+ readRegexp() {
672
+ const startLoc = this.state.startLoc;
673
+ const start = this.state.start + 1;
674
+ let escaped, inClass;
675
+ let {
676
+ pos
677
+ } = this.state;
678
+ for (; ; ++pos) {
679
+ if (pos >= this.length) {
680
+ throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
681
+ }
682
+ const ch = this.input.charCodeAt(pos);
683
+ if (isNewLine(ch)) {
684
+ throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1));
685
+ }
686
+ if (escaped) {
687
+ escaped = false;
688
+ } else {
689
+ if (ch === 91) {
690
+ inClass = true;
691
+ } else if (ch === 93 && inClass) {
692
+ inClass = false;
693
+ } else if (ch === 47 && !inClass) {
694
+ break;
695
+ }
696
+ escaped = ch === 92;
697
+ }
698
+ }
699
+ const content = this.input.slice(start, pos);
700
+ ++pos;
701
+ let mods = "";
702
+ const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start);
703
+ while (pos < this.length) {
704
+ const cp = this.codePointAtPos(pos);
705
+ const char = String.fromCharCode(cp);
706
+ if (VALID_REGEX_FLAGS.has(cp)) {
707
+ if (cp === 118) {
708
+ if (mods.includes("u")) {
709
+ this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
710
+ }
711
+ } else if (cp === 117) {
712
+ if (mods.includes("v")) {
713
+ this.raise(Errors.IncompatibleRegExpUVFlags, nextPos());
714
+ }
715
+ }
716
+ if (mods.includes(char)) {
717
+ this.raise(Errors.DuplicateRegExpFlags, nextPos());
718
+ }
719
+ } else if (isIdentifierChar(cp) || cp === 92) {
720
+ this.raise(Errors.MalformedRegExpFlags, nextPos());
721
+ } else {
722
+ break;
723
+ }
724
+ ++pos;
725
+ mods += char;
726
+ }
727
+ this.state.pos = pos;
728
+ this.finishToken(tt.regexp, {
729
+ pattern: content,
730
+ flags: mods
731
+ });
732
+ }
733
+ readInt(radix, len, forceLen = false, allowNumSeparator = true) {
734
+ const {
735
+ n,
736
+ pos
737
+ } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, radix, len, forceLen, allowNumSeparator, this.errorHandlers_readInt, false);
738
+ this.state.pos = pos;
739
+ return n;
740
+ }
741
+ readRadixNumber(radix) {
742
+ const start = this.state.pos;
743
+ const startLoc = this.state.curPosition();
744
+ let isBigInt = false;
745
+ this.state.pos += 2;
746
+ const val = this.readInt(radix);
747
+ if (val == null) {
748
+ this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), {
749
+ radix
750
+ });
751
+ }
752
+ const next = this.input.charCodeAt(this.state.pos);
753
+ if (next === 110) {
754
+ ++this.state.pos;
755
+ isBigInt = true;
756
+ } else if (next === 109) {
757
+ throw this.raise(Errors.InvalidDecimal, startLoc);
758
+ }
759
+ if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
760
+ throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
761
+ }
762
+ if (isBigInt) {
763
+ const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
764
+ this.finishToken(tt.bigint, str);
765
+ return;
766
+ }
767
+ this.finishToken(tt.num, val);
768
+ }
769
+ readNumber(startsWithDot) {
770
+ const start = this.state.pos;
771
+ const startLoc = this.state.curPosition();
772
+ let isFloat = false;
773
+ let isBigInt = false;
774
+ let hasExponent = false;
775
+ let isOctal = false;
776
+ if (!startsWithDot && this.readInt(10) === null) {
777
+ this.raise(Errors.InvalidNumber, this.state.curPosition());
778
+ }
779
+ const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
780
+ if (hasLeadingZero) {
781
+ const integer = this.input.slice(start, this.state.pos);
782
+ this.recordStrictModeErrors(Errors.StrictOctalLiteral, startLoc);
783
+ if (!this.state.strict) {
784
+ const underscorePos = integer.indexOf("_");
785
+ if (underscorePos > 0) {
786
+ this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos));
787
+ }
788
+ }
789
+ isOctal = hasLeadingZero && !/[89]/.test(integer);
790
+ }
791
+ let next = this.input.charCodeAt(this.state.pos);
792
+ if (next === 46 && !isOctal) {
793
+ ++this.state.pos;
794
+ this.readInt(10);
795
+ isFloat = true;
796
+ next = this.input.charCodeAt(this.state.pos);
797
+ }
798
+ if ((next === 69 || next === 101) && !isOctal) {
799
+ next = this.input.charCodeAt(++this.state.pos);
800
+ if (next === 43 || next === 45) {
801
+ ++this.state.pos;
802
+ }
803
+ if (this.readInt(10) === null) {
804
+ this.raise(Errors.InvalidOrMissingExponent, startLoc);
805
+ }
806
+ isFloat = true;
807
+ hasExponent = true;
808
+ next = this.input.charCodeAt(this.state.pos);
809
+ }
810
+ if (next === 110) {
811
+ if (isFloat || hasLeadingZero) {
812
+ this.raise(Errors.InvalidBigIntLiteral, startLoc);
813
+ }
814
+ ++this.state.pos;
815
+ isBigInt = true;
816
+ }
817
+ if (next === 109) {
818
+ this.expectPlugin("decimal", this.state.curPosition());
819
+ if (hasExponent || hasLeadingZero) {
820
+ this.raise(Errors.InvalidDecimal, startLoc);
821
+ }
822
+ ++this.state.pos;
823
+ var isDecimal = true;
824
+ }
825
+ if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
826
+ throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
827
+ }
828
+ const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
829
+ if (isBigInt) {
830
+ this.finishToken(tt.bigint, str);
831
+ return;
832
+ }
833
+ if (isDecimal) {
834
+ this.finishToken(tt.decimal, str);
835
+ return;
836
+ }
837
+ const val = isOctal ? parseInt(str, 8) : parseFloat(str);
838
+ this.finishToken(tt.num, val);
839
+ }
840
+ readCodePoint(throwOnInvalid) {
841
+ const {
842
+ code,
843
+ pos
844
+ } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint);
845
+ this.state.pos = pos;
846
+ return code;
847
+ }
848
+ readString(quote) {
849
+ const {
850
+ str,
851
+ pos,
852
+ curLine,
853
+ lineStart
854
+ } = readStringContents(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string);
855
+ this.state.pos = pos + 1;
856
+ this.state.lineStart = lineStart;
857
+ this.state.curLine = curLine;
858
+ this.finishToken(tt.string, str);
859
+ }
860
+ readTemplateContinuation() {
861
+ if (!this.match(tt.braceR)) {
862
+ this.unexpected(null, tt.braceR);
863
+ }
864
+ this.state.pos--;
865
+ this.readTemplateToken();
866
+ }
867
+ readTemplateToken() {
868
+ const opening = this.input[this.state.pos];
869
+ const {
870
+ str,
871
+ firstInvalidLoc,
872
+ pos,
873
+ curLine,
874
+ lineStart
875
+ } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template);
876
+ this.state.pos = pos + 1;
877
+ this.state.lineStart = lineStart;
878
+ this.state.curLine = curLine;
879
+ if (firstInvalidLoc) {
880
+ this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, this.sourceToOffsetPos(firstInvalidLoc.pos));
881
+ }
882
+ if (this.input.codePointAt(pos) === 96) {
883
+ this.finishToken(tt.templateTail, firstInvalidLoc ? null : opening + str + "`");
884
+ } else {
885
+ this.state.pos++;
886
+ this.finishToken(tt.templateNonTail, firstInvalidLoc ? null : opening + str + "${");
887
+ }
888
+ }
889
+ recordStrictModeErrors(toParseError, at) {
890
+ const index = at.index;
891
+ if (this.state.strict && !this.state.strictErrors.has(index)) {
892
+ this.raise(toParseError, at);
893
+ } else {
894
+ this.state.strictErrors.set(index, [toParseError, at]);
895
+ }
896
+ }
897
+ readWord1(firstCode) {
898
+ this.state.containsEsc = false;
899
+ let word = "";
900
+ const start = this.state.pos;
901
+ let chunkStart = this.state.pos;
902
+ if (firstCode !== void 0) {
903
+ this.state.pos += firstCode <= 65535 ? 1 : 2;
904
+ }
905
+ while (this.state.pos < this.length) {
906
+ const ch = this.codePointAtPos(this.state.pos);
907
+ if (isIdentifierChar(ch)) {
908
+ this.state.pos += ch <= 65535 ? 1 : 2;
909
+ } else if (ch === 92) {
910
+ this.state.containsEsc = true;
911
+ word += this.input.slice(chunkStart, this.state.pos);
912
+ const escStart = this.state.curPosition();
913
+ const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
914
+ if (this.input.charCodeAt(++this.state.pos) !== 117) {
915
+ this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
916
+ chunkStart = this.state.pos - 1;
917
+ continue;
918
+ }
919
+ ++this.state.pos;
920
+ const esc = this.readCodePoint(true);
921
+ if (esc !== null) {
922
+ if (!identifierCheck(esc)) {
923
+ this.raise(Errors.EscapedCharNotAnIdentifier, escStart);
924
+ }
925
+ word += String.fromCodePoint(esc);
926
+ }
927
+ chunkStart = this.state.pos;
928
+ } else {
929
+ break;
930
+ }
931
+ }
932
+ return word + this.input.slice(chunkStart, this.state.pos);
933
+ }
934
+ readWord(firstCode) {
935
+ const word = this.readWord1(firstCode);
936
+ const type = keywordTypes.get(word);
937
+ if (type !== void 0) {
938
+ this.finishToken(type, tokenLabelName(type));
939
+ } else {
940
+ this.finishToken(tt.name, word);
941
+ }
942
+ }
943
+ checkKeywordEscapes() {
944
+ const {
945
+ type
946
+ } = this.state;
947
+ if (tokenIsKeyword(type) && this.state.containsEsc) {
948
+ this.raise(Errors.InvalidEscapedReservedWord, this.state.startLoc, {
949
+ reservedWord: tokenLabelName(type)
950
+ });
951
+ }
952
+ }
953
+ raise(toParseError, at, details = {}) {
954
+ const loc = at instanceof Position ? at : at.loc.start;
955
+ const error = toParseError(loc, details);
956
+ if (!(this.optionFlags & OptionFlags.ErrorRecovery)) throw error;
957
+ if (!this.isLookahead) this.state.errors.push(error);
958
+ return error;
959
+ }
960
+ raiseOverwrite(toParseError, at, details = {}) {
961
+ const loc = at instanceof Position ? at : at.loc.start;
962
+ const pos = loc.index;
963
+ const errors = this.state.errors;
964
+ for (let i = errors.length - 1; i >= 0; i--) {
965
+ const error = errors[i];
966
+ if (error.loc.index === pos) {
967
+ return errors[i] = toParseError(loc, details);
968
+ }
969
+ if (error.loc.index < pos) break;
970
+ }
971
+ return this.raise(toParseError, at, details);
972
+ }
973
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Retain the upstream parser interface and bindings.
974
+ updateContext(prevType) {
975
+ }
976
+ unexpected(loc, type) {
977
+ throw this.raise(Errors.UnexpectedToken, loc != null ? loc : this.state.startLoc, {
978
+ expected: type ? tokenLabelName(type) : null
979
+ });
980
+ }
981
+ expectPlugin(pluginName, loc) {
982
+ if (this.hasPlugin(pluginName)) {
983
+ return true;
984
+ }
985
+ throw this.raise(Errors.MissingPlugin, loc != null ? loc : this.state.startLoc, {
986
+ missingPlugin: [pluginName]
987
+ });
988
+ }
989
+ expectOnePlugin(pluginNames) {
990
+ if (!pluginNames.some((name) => this.hasPlugin(name))) {
991
+ throw this.raise(Errors.MissingOneOfPlugins, this.state.startLoc, {
992
+ missingPlugin: pluginNames
993
+ });
994
+ }
995
+ }
996
+ errorBuilder(error) {
997
+ return (pos, lineStart, curLine) => {
998
+ this.raise(error, buildPosition(pos, lineStart, curLine));
999
+ };
1000
+ }
1001
+ errorHandlers_readInt = {
1002
+ invalidDigit: (pos, lineStart, curLine, radix) => {
1003
+ if (!(this.optionFlags & OptionFlags.ErrorRecovery)) return false;
1004
+ this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), {
1005
+ radix
1006
+ });
1007
+ return true;
1008
+ },
1009
+ numericSeparatorInEscapeSequence: this.errorBuilder(Errors.NumericSeparatorInEscapeSequence),
1010
+ unexpectedNumericSeparator: this.errorBuilder(Errors.UnexpectedNumericSeparator)
1011
+ };
1012
+ errorHandlers_readCodePoint = {
1013
+ ...this.errorHandlers_readInt,
1014
+ invalidEscapeSequence: this.errorBuilder(Errors.InvalidEscapeSequence),
1015
+ invalidCodePoint: this.errorBuilder(Errors.InvalidCodePoint)
1016
+ };
1017
+ errorHandlers_readStringContents_string = {
1018
+ ...this.errorHandlers_readCodePoint,
1019
+ strictNumericEscape: (pos, lineStart, curLine) => {
1020
+ this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine));
1021
+ },
1022
+ unterminated: (pos, lineStart, curLine) => {
1023
+ throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine));
1024
+ }
1025
+ };
1026
+ errorHandlers_readStringContents_template = {
1027
+ ...this.errorHandlers_readCodePoint,
1028
+ strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape),
1029
+ unterminated: (pos, lineStart, curLine) => {
1030
+ throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine));
1031
+ }
1032
+ };
1033
+ }
1034
+ export {
1035
+ Token,
1036
+ Tokenizer as default
1037
+ };