@checkly/playwright-core 1.51.17-beta.2 → 1.54.2-beta.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 (376) hide show
  1. package/ThirdPartyNotices.txt +65 -123
  2. package/browsers.json +16 -14
  3. package/index.js +1 -1
  4. package/lib/androidServerImpl.js +47 -50
  5. package/lib/browserServerImpl.js +89 -69
  6. package/lib/checkly/escapeRegExp.js +23 -27
  7. package/lib/checkly/fetch.js +64 -46
  8. package/lib/checkly/secretsFilter.js +49 -35
  9. package/lib/cli/driver.js +71 -69
  10. package/lib/cli/program.js +400 -359
  11. package/lib/cli/programWithTestStub.js +51 -45
  12. package/lib/client/accessibility.js +31 -32
  13. package/lib/client/android.js +151 -242
  14. package/lib/client/api.js +135 -283
  15. package/lib/client/artifact.js +39 -36
  16. package/lib/client/browser.js +96 -71
  17. package/lib/client/browserContext.js +314 -345
  18. package/lib/client/browserType.js +103 -127
  19. package/lib/client/cdpSession.js +29 -31
  20. package/lib/client/channelOwner.js +90 -113
  21. package/lib/client/clientHelper.js +48 -39
  22. package/lib/client/clientInstrumentation.js +40 -37
  23. package/lib/client/clientStackTrace.js +41 -37
  24. package/lib/client/clock.js +36 -36
  25. package/lib/client/connection.js +188 -214
  26. package/lib/client/consoleMessage.js +31 -28
  27. package/lib/client/coverage.js +25 -22
  28. package/lib/client/dialog.js +30 -31
  29. package/lib/client/download.js +25 -25
  30. package/lib/client/electron.js +80 -77
  31. package/lib/client/elementHandle.js +120 -159
  32. package/lib/client/errors.js +53 -53
  33. package/lib/client/eventEmitter.js +124 -121
  34. package/lib/client/events.js +72 -68
  35. package/lib/client/fetch.js +166 -190
  36. package/lib/client/fileChooser.js +25 -24
  37. package/lib/client/fileUtils.js +31 -28
  38. package/lib/client/frame.js +207 -306
  39. package/lib/client/harRouter.js +42 -52
  40. package/lib/client/input.js +42 -69
  41. package/lib/client/jsHandle.js +54 -69
  42. package/lib/client/jsonPipe.js +27 -23
  43. package/lib/client/localUtils.js +29 -29
  44. package/lib/client/locator.js +145 -237
  45. package/lib/client/network.js +282 -307
  46. package/lib/client/page.js +269 -318
  47. package/lib/client/platform.js +46 -43
  48. package/lib/client/playwright.js +51 -76
  49. package/lib/client/selectors.js +45 -63
  50. package/lib/client/stream.js +29 -25
  51. package/lib/client/timeoutSettings.js +55 -41
  52. package/lib/client/tracing.js +49 -96
  53. package/lib/client/types.js +26 -22
  54. package/lib/client/video.js +35 -27
  55. package/lib/client/waiter.js +69 -88
  56. package/lib/client/webError.js +25 -23
  57. package/lib/client/webSocket.js +43 -56
  58. package/lib/client/worker.js +48 -56
  59. package/lib/client/writableStream.js +27 -23
  60. package/lib/generated/bindingsControllerSource.js +28 -0
  61. package/lib/generated/clockSource.js +26 -6
  62. package/lib/generated/consoleApiSource.js +26 -6
  63. package/lib/generated/injectedScriptSource.js +26 -6
  64. package/lib/generated/pollingRecorderSource.js +26 -6
  65. package/lib/generated/storageScriptSource.js +28 -0
  66. package/lib/generated/utilityScriptSource.js +26 -6
  67. package/lib/generated/webSocketMockSource.js +333 -5
  68. package/lib/inProcessFactory.js +51 -53
  69. package/lib/inprocess.js +2 -19
  70. package/lib/outofprocess.js +51 -46
  71. package/lib/protocol/serializers.js +153 -134
  72. package/lib/protocol/validator.js +2807 -2739
  73. package/lib/protocol/validatorPrimitives.js +114 -73
  74. package/lib/remote/playwrightConnection.js +88 -242
  75. package/lib/remote/playwrightServer.js +305 -92
  76. package/lib/server/accessibility.js +44 -37
  77. package/lib/server/android/android.js +251 -241
  78. package/lib/server/android/backendAdb.js +87 -82
  79. package/lib/server/artifact.js +78 -55
  80. package/lib/server/bidi/bidiBrowser.js +297 -158
  81. package/lib/server/bidi/bidiChromium.js +119 -89
  82. package/lib/server/bidi/bidiConnection.js +66 -83
  83. package/lib/server/bidi/bidiExecutionContext.js +129 -113
  84. package/lib/server/bidi/bidiFirefox.js +86 -76
  85. package/lib/server/bidi/bidiInput.js +106 -117
  86. package/lib/server/bidi/bidiNetworkManager.js +142 -159
  87. package/lib/server/bidi/bidiOverCdp.js +57 -58
  88. package/lib/server/bidi/bidiPage.js +260 -260
  89. package/lib/server/bidi/bidiPdf.js +52 -86
  90. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
  91. package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
  92. package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
  93. package/lib/server/bidi/third_party/bidiProtocol.js +22 -137
  94. package/lib/server/bidi/third_party/bidiProtocolCore.js +152 -0
  95. package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
  96. package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
  97. package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
  98. package/lib/server/browser.js +93 -95
  99. package/lib/server/browserContext.js +419 -429
  100. package/lib/server/browserType.js +186 -216
  101. package/lib/server/callLog.js +47 -44
  102. package/lib/server/chromium/chromium.js +235 -203
  103. package/lib/server/chromium/chromiumSwitches.js +100 -67
  104. package/lib/server/chromium/crAccessibility.js +157 -131
  105. package/lib/server/chromium/crBrowser.js +310 -292
  106. package/lib/server/chromium/crConnection.js +95 -121
  107. package/lib/server/chromium/crCoverage.js +121 -131
  108. package/lib/server/chromium/crDevTools.js +60 -51
  109. package/lib/server/chromium/crDragDrop.js +68 -84
  110. package/lib/server/chromium/crExecutionContext.js +89 -83
  111. package/lib/server/chromium/crInput.js +118 -113
  112. package/lib/server/chromium/crNetworkManager.js +274 -375
  113. package/lib/server/chromium/crPage.js +536 -593
  114. package/lib/server/chromium/crPdf.js +54 -86
  115. package/lib/server/chromium/crProtocolHelper.js +92 -80
  116. package/lib/server/chromium/crServiceWorker.js +84 -73
  117. package/lib/server/chromium/defaultFontFamilies.js +152 -135
  118. package/lib/server/chromium/protocol.d.js +16 -0
  119. package/lib/server/chromium/videoRecorder.js +66 -99
  120. package/lib/server/clock.js +107 -83
  121. package/lib/server/codegen/csharp.js +192 -162
  122. package/lib/server/codegen/java.js +156 -129
  123. package/lib/server/codegen/javascript.js +163 -148
  124. package/lib/server/codegen/jsonl.js +32 -28
  125. package/lib/server/codegen/language.js +75 -52
  126. package/lib/server/codegen/languages.js +65 -27
  127. package/lib/server/codegen/python.js +141 -126
  128. package/lib/server/codegen/types.js +15 -4
  129. package/lib/server/console.js +28 -32
  130. package/lib/server/cookieStore.js +108 -86
  131. package/lib/server/debugController.js +147 -151
  132. package/lib/server/debugger.js +86 -78
  133. package/lib/server/deviceDescriptors.js +37 -24
  134. package/lib/server/deviceDescriptorsSource.json +238 -128
  135. package/lib/server/dialog.js +84 -39
  136. package/lib/server/dispatchers/androidDispatcher.js +257 -148
  137. package/lib/server/dispatchers/artifactDispatcher.js +79 -79
  138. package/lib/server/dispatchers/browserContextDispatcher.js +289 -259
  139. package/lib/server/dispatchers/browserDispatcher.js +96 -148
  140. package/lib/server/dispatchers/browserTypeDispatcher.js +50 -41
  141. package/lib/server/dispatchers/cdpSessionDispatcher.js +35 -39
  142. package/lib/server/dispatchers/debugControllerDispatcher.js +65 -83
  143. package/lib/server/dispatchers/dialogDispatcher.js +34 -31
  144. package/lib/server/dispatchers/dispatcher.js +208 -248
  145. package/lib/server/dispatchers/electronDispatcher.js +66 -70
  146. package/lib/server/dispatchers/elementHandlerDispatcher.js +164 -216
  147. package/lib/server/dispatchers/frameDispatcher.js +211 -272
  148. package/lib/server/dispatchers/jsHandleDispatcher.js +63 -75
  149. package/lib/server/dispatchers/jsonPipeDispatcher.js +37 -38
  150. package/lib/server/dispatchers/localUtilsDispatcher.js +121 -119
  151. package/lib/server/dispatchers/networkDispatchers.js +117 -128
  152. package/lib/server/dispatchers/pageDispatcher.js +256 -248
  153. package/lib/server/dispatchers/playwrightDispatcher.js +92 -87
  154. package/lib/server/dispatchers/streamDispatcher.js +52 -48
  155. package/lib/server/dispatchers/tracingDispatcher.js +47 -52
  156. package/lib/server/dispatchers/webSocketRouteDispatcher.js +126 -150
  157. package/lib/server/dispatchers/writableStreamDispatcher.js +65 -43
  158. package/lib/server/dom.js +485 -582
  159. package/lib/server/download.js +47 -37
  160. package/lib/server/electron/electron.js +216 -243
  161. package/lib/server/electron/loader.js +9 -37
  162. package/lib/server/errors.js +47 -46
  163. package/lib/server/fetch.js +317 -360
  164. package/lib/server/fileChooser.js +25 -24
  165. package/lib/server/fileUploadUtils.js +66 -60
  166. package/lib/server/firefox/ffAccessibility.js +153 -131
  167. package/lib/server/firefox/ffBrowser.js +268 -305
  168. package/lib/server/firefox/ffConnection.js +63 -84
  169. package/lib/server/firefox/ffExecutionContext.js +92 -73
  170. package/lib/server/firefox/ffInput.js +82 -84
  171. package/lib/server/firefox/ffNetworkManager.js +137 -114
  172. package/lib/server/firefox/ffPage.js +261 -293
  173. package/lib/server/firefox/firefox.js +80 -72
  174. package/lib/server/firefox/protocol.d.js +16 -0
  175. package/lib/server/formData.js +107 -35
  176. package/lib/server/frameSelectors.js +98 -114
  177. package/lib/server/frames.js +845 -1055
  178. package/lib/server/har/harRecorder.js +85 -77
  179. package/lib/server/har/harTracer.js +290 -223
  180. package/lib/server/harBackend.js +80 -80
  181. package/lib/server/helper.js +55 -59
  182. package/lib/server/index.js +59 -99
  183. package/lib/server/input.js +151 -189
  184. package/lib/server/instrumentation.js +57 -44
  185. package/lib/server/javascript.js +133 -134
  186. package/lib/server/launchApp.js +113 -75
  187. package/lib/server/localUtils.js +150 -142
  188. package/lib/server/macEditingCommands.js +141 -137
  189. package/lib/server/network.js +299 -303
  190. package/lib/server/page.js +513 -544
  191. package/lib/server/pipeTransport.js +49 -45
  192. package/lib/server/playwright.js +58 -67
  193. package/lib/server/progress.js +137 -68
  194. package/lib/server/protocolError.js +34 -31
  195. package/lib/server/recorder/chat.js +70 -86
  196. package/lib/server/recorder/recorderApp.js +341 -176
  197. package/lib/server/recorder/recorderInTraceViewer.js +65 -94
  198. package/lib/server/recorder/recorderRunner.js +93 -116
  199. package/lib/server/recorder/recorderSignalProcessor.js +83 -0
  200. package/lib/server/recorder/recorderUtils.js +104 -47
  201. package/lib/server/recorder/throttledFile.js +42 -30
  202. package/lib/server/recorder.js +395 -275
  203. package/lib/server/registry/browserFetcher.js +106 -101
  204. package/lib/server/registry/dependencies.js +245 -196
  205. package/lib/server/registry/index.js +930 -803
  206. package/lib/server/registry/nativeDeps.js +1073 -464
  207. package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
  208. package/lib/server/screenshotter.js +160 -191
  209. package/lib/server/selectors.js +90 -51
  210. package/lib/server/socksClientCertificatesInterceptor.js +171 -186
  211. package/lib/server/socksInterceptor.js +62 -70
  212. package/lib/server/trace/recorder/snapshotter.js +76 -102
  213. package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
  214. package/lib/server/trace/recorder/tracing.js +354 -362
  215. package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
  216. package/lib/server/trace/viewer/traceViewer.js +160 -147
  217. package/lib/server/transport.js +119 -134
  218. package/lib/server/types.js +26 -22
  219. package/lib/server/usKeyboardLayout.js +135 -545
  220. package/lib/server/utils/ascii.js +39 -26
  221. package/lib/server/utils/comparators.js +105 -103
  222. package/lib/server/utils/crypto.js +157 -112
  223. package/lib/server/utils/debug.js +36 -32
  224. package/lib/server/utils/debugLogger.js +77 -48
  225. package/lib/server/utils/env.js +52 -37
  226. package/lib/server/utils/eventsHelper.js +29 -28
  227. package/lib/server/utils/expectUtils.js +31 -26
  228. package/lib/server/utils/fileUtils.js +123 -136
  229. package/lib/server/utils/happyEyeballs.js +141 -126
  230. package/lib/server/utils/hostPlatform.js +84 -120
  231. package/lib/server/utils/httpServer.js +106 -121
  232. package/lib/server/utils/image_tools/colorUtils.js +42 -51
  233. package/lib/server/utils/image_tools/compare.js +44 -43
  234. package/lib/server/utils/image_tools/imageChannel.js +38 -30
  235. package/lib/server/utils/image_tools/stats.js +40 -40
  236. package/lib/server/utils/linuxUtils.js +50 -37
  237. package/lib/server/utils/network.js +152 -96
  238. package/lib/server/utils/nodePlatform.js +87 -79
  239. package/lib/server/utils/pipeTransport.js +44 -42
  240. package/lib/server/utils/processLauncher.js +111 -121
  241. package/lib/server/utils/profiler.js +52 -39
  242. package/lib/server/utils/socksProxy.js +280 -339
  243. package/lib/server/utils/spawnAsync.js +37 -41
  244. package/lib/server/utils/task.js +31 -38
  245. package/lib/server/utils/userAgent.js +73 -66
  246. package/lib/server/utils/wsServer.js +68 -75
  247. package/lib/server/utils/zipFile.js +36 -37
  248. package/lib/server/utils/zones.js +37 -34
  249. package/lib/server/webkit/protocol.d.js +16 -0
  250. package/lib/server/webkit/webkit.js +77 -61
  251. package/lib/server/webkit/wkAccessibility.js +161 -118
  252. package/lib/server/webkit/wkBrowser.js +193 -184
  253. package/lib/server/webkit/wkConnection.js +59 -83
  254. package/lib/server/webkit/wkExecutionContext.js +85 -70
  255. package/lib/server/webkit/wkInput.js +97 -95
  256. package/lib/server/webkit/wkInterceptableRequest.js +102 -95
  257. package/lib/server/webkit/wkPage.js +568 -667
  258. package/lib/server/webkit/wkProvisionalPage.js +45 -56
  259. package/lib/server/webkit/wkWorkers.js +79 -79
  260. package/lib/utils/expectUtils.js +31 -26
  261. package/lib/utils/isomorphic/ariaSnapshot.js +149 -152
  262. package/lib/utils/isomorphic/assert.js +28 -22
  263. package/lib/utils/isomorphic/colors.js +66 -59
  264. package/lib/utils/isomorphic/cssParser.js +120 -125
  265. package/lib/utils/isomorphic/cssTokenizer.js +436 -364
  266. package/lib/utils/isomorphic/headers.js +38 -37
  267. package/lib/utils/isomorphic/locatorGenerators.js +358 -357
  268. package/lib/utils/isomorphic/locatorParser.js +96 -105
  269. package/lib/utils/isomorphic/locatorUtils.js +63 -44
  270. package/lib/utils/isomorphic/manualPromise.js +46 -39
  271. package/lib/utils/isomorphic/mimeType.js +447 -25
  272. package/lib/utils/isomorphic/multimap.js +34 -27
  273. package/lib/utils/isomorphic/protocolFormatter.js +68 -0
  274. package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
  275. package/lib/utils/isomorphic/recorderUtils.js +140 -181
  276. package/lib/utils/isomorphic/rtti.js +35 -33
  277. package/lib/utils/isomorphic/selectorParser.js +182 -193
  278. package/lib/utils/isomorphic/semaphore.js +27 -24
  279. package/lib/utils/isomorphic/stackTrace.js +87 -98
  280. package/lib/utils/isomorphic/stringUtils.js +98 -112
  281. package/lib/utils/isomorphic/time.js +46 -22
  282. package/lib/utils/isomorphic/timeoutRunner.js +53 -53
  283. package/lib/utils/isomorphic/traceUtils.js +37 -41
  284. package/lib/utils/isomorphic/types.js +15 -4
  285. package/lib/utils/isomorphic/urlMatch.js +113 -67
  286. package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
  287. package/lib/utils.js +101 -443
  288. package/lib/utilsBundle.js +101 -52
  289. package/lib/utilsBundleImpl/index.js +160 -150
  290. package/lib/zipBundle.js +32 -23
  291. package/lib/zipBundleImpl.js +4 -4
  292. package/package.json +1 -1
  293. package/types/protocol.d.ts +1267 -1057
  294. package/types/types.d.ts +131 -29
  295. package/lib/common/socksProxy.js +0 -569
  296. package/lib/common/timeoutSettings.js +0 -73
  297. package/lib/common/types.js +0 -5
  298. package/lib/image_tools/colorUtils.js +0 -98
  299. package/lib/image_tools/compare.js +0 -108
  300. package/lib/image_tools/imageChannel.js +0 -70
  301. package/lib/image_tools/stats.js +0 -102
  302. package/lib/protocol/debug.js +0 -27
  303. package/lib/protocol/transport.js +0 -82
  304. package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
  305. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
  306. package/lib/server/recorder/contextRecorder.js +0 -290
  307. package/lib/server/recorder/recorderCollection.js +0 -104
  308. package/lib/server/recorder/recorderFrontend.js +0 -5
  309. package/lib/server/storageScript.js +0 -160
  310. package/lib/server/timeoutSettings.js +0 -74
  311. package/lib/third_party/diff_match_patch.js +0 -2222
  312. package/lib/utils/ascii.js +0 -31
  313. package/lib/utils/comparators.js +0 -171
  314. package/lib/utils/crypto.js +0 -174
  315. package/lib/utils/debug.js +0 -46
  316. package/lib/utils/debugLogger.js +0 -91
  317. package/lib/utils/env.js +0 -49
  318. package/lib/utils/eventsHelper.js +0 -38
  319. package/lib/utils/fileUtils.js +0 -205
  320. package/lib/utils/happy-eyeballs.js +0 -210
  321. package/lib/utils/headers.js +0 -52
  322. package/lib/utils/hostPlatform.js +0 -133
  323. package/lib/utils/httpServer.js +0 -237
  324. package/lib/utils/index.js +0 -368
  325. package/lib/utils/linuxUtils.js +0 -78
  326. package/lib/utils/manualPromise.js +0 -109
  327. package/lib/utils/multimap.js +0 -75
  328. package/lib/utils/network.js +0 -160
  329. package/lib/utils/processLauncher.js +0 -248
  330. package/lib/utils/profiler.js +0 -53
  331. package/lib/utils/rtti.js +0 -44
  332. package/lib/utils/semaphore.js +0 -51
  333. package/lib/utils/spawnAsync.js +0 -45
  334. package/lib/utils/stackTrace.js +0 -121
  335. package/lib/utils/task.js +0 -58
  336. package/lib/utils/time.js +0 -37
  337. package/lib/utils/timeoutRunner.js +0 -66
  338. package/lib/utils/traceUtils.js +0 -44
  339. package/lib/utils/userAgent.js +0 -105
  340. package/lib/utils/wsServer.js +0 -127
  341. package/lib/utils/zipFile.js +0 -75
  342. package/lib/utils/zones.js +0 -62
  343. package/lib/vite/htmlReport/index.html +0 -69
  344. package/lib/vite/recorder/assets/codeMirrorModule-B9YMkrwa.js +0 -24
  345. package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
  346. package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  347. package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
  348. package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
  349. package/lib/vite/recorder/index.html +0 -29
  350. package/lib/vite/recorder/playwright-logo.svg +0 -9
  351. package/lib/vite/traceViewer/assets/codeMirrorModule-gU1OOCQO.js +0 -24
  352. package/lib/vite/traceViewer/assets/defaultSettingsView-B5n_FjMx.js +0 -1
  353. package/lib/vite/traceViewer/assets/inspectorTab-6Tru8Mn_.js +0 -235
  354. package/lib/vite/traceViewer/assets/workbench-B_Nj4NA2.js +0 -25
  355. package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
  356. package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
  357. package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  358. package/lib/vite/traceViewer/defaultSettingsView.CO3FR0CX.css +0 -1
  359. package/lib/vite/traceViewer/embedded.DpNPH6mk.js +0 -2
  360. package/lib/vite/traceViewer/embedded.html +0 -18
  361. package/lib/vite/traceViewer/embedded.mLhjB5IF.css +0 -1
  362. package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
  363. package/lib/vite/traceViewer/index.CuE3SYGw.js +0 -2
  364. package/lib/vite/traceViewer/index.html +0 -47
  365. package/lib/vite/traceViewer/inspectorTab.CXDulcFG.css +0 -1
  366. package/lib/vite/traceViewer/playwright-logo.svg +0 -9
  367. package/lib/vite/traceViewer/recorder.BD-uZJs7.js +0 -2
  368. package/lib/vite/traceViewer/recorder.html +0 -17
  369. package/lib/vite/traceViewer/recorder.tn0RQdqM.css +0 -0
  370. package/lib/vite/traceViewer/snapshot.html +0 -21
  371. package/lib/vite/traceViewer/sw.bundle.js +0 -3
  372. package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
  373. package/lib/vite/traceViewer/uiMode.DHrNgddz.js +0 -5
  374. package/lib/vite/traceViewer/uiMode.html +0 -21
  375. package/lib/vite/traceViewer/workbench.B9vIAzH9.css +0 -1
  376. package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
@@ -1,84 +1,119 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var cssTokenizer_exports = {};
20
+ __export(cssTokenizer_exports, {
21
+ AtKeywordToken: () => AtKeywordToken,
22
+ BadStringToken: () => BadStringToken,
23
+ BadURLToken: () => BadURLToken,
24
+ CDCToken: () => CDCToken,
25
+ CDOToken: () => CDOToken,
26
+ CSSParserToken: () => CSSParserToken,
27
+ CloseCurlyToken: () => CloseCurlyToken,
28
+ CloseParenToken: () => CloseParenToken,
29
+ CloseSquareToken: () => CloseSquareToken,
30
+ ColonToken: () => ColonToken,
31
+ ColumnToken: () => ColumnToken,
32
+ CommaToken: () => CommaToken,
33
+ DashMatchToken: () => DashMatchToken,
34
+ DelimToken: () => DelimToken,
35
+ DimensionToken: () => DimensionToken,
36
+ EOFToken: () => EOFToken,
37
+ FunctionToken: () => FunctionToken,
38
+ GroupingToken: () => GroupingToken,
39
+ HashToken: () => HashToken,
40
+ IdentToken: () => IdentToken,
41
+ IncludeMatchToken: () => IncludeMatchToken,
42
+ InvalidCharacterError: () => InvalidCharacterError,
43
+ NumberToken: () => NumberToken,
44
+ OpenCurlyToken: () => OpenCurlyToken,
45
+ OpenParenToken: () => OpenParenToken,
46
+ OpenSquareToken: () => OpenSquareToken,
47
+ PercentageToken: () => PercentageToken,
48
+ PrefixMatchToken: () => PrefixMatchToken,
49
+ SemicolonToken: () => SemicolonToken,
50
+ StringToken: () => StringToken,
51
+ StringValuedToken: () => StringValuedToken,
52
+ SubstringMatchToken: () => SubstringMatchToken,
53
+ SuffixMatchToken: () => SuffixMatchToken,
54
+ URLToken: () => URLToken,
55
+ WhitespaceToken: () => WhitespaceToken,
56
+ tokenize: () => tokenize
5
57
  });
6
- exports.WhitespaceToken = exports.URLToken = exports.SuffixMatchToken = exports.SubstringMatchToken = exports.StringValuedToken = exports.StringToken = exports.SemicolonToken = exports.PrefixMatchToken = exports.PercentageToken = exports.OpenSquareToken = exports.OpenParenToken = exports.OpenCurlyToken = exports.NumberToken = exports.InvalidCharacterError = exports.IncludeMatchToken = exports.IdentToken = exports.HashToken = exports.GroupingToken = exports.FunctionToken = exports.EOFToken = exports.DimensionToken = exports.DelimToken = exports.DashMatchToken = exports.CommaToken = exports.ColumnToken = exports.ColonToken = exports.CloseSquareToken = exports.CloseParenToken = exports.CloseCurlyToken = exports.CSSParserToken = exports.CDOToken = exports.CDCToken = exports.BadURLToken = exports.BadStringToken = exports.AtKeywordToken = void 0;
7
- exports.tokenize = tokenize;
8
- /* eslint-disable notice/notice */
9
-
10
- /*
11
- * The code in this file is licensed under the CC0 license.
12
- * http://creativecommons.org/publicdomain/zero/1.0/
13
- * It is free to use for any purpose. No attribution, permission, or reproduction of this license is required.
14
- */
15
-
16
- // Original at https://github.com/tabatkins/parse-css
17
- // Changes:
18
- // - JS is replaced with TS.
19
- // - Universal Module Definition wrapper is removed.
20
- // - Everything not related to tokenizing - below the first exports block - is removed.
21
-
22
- const between = function (num, first, last) {
58
+ module.exports = __toCommonJS(cssTokenizer_exports);
59
+ const between = function(num, first, last) {
23
60
  return num >= first && num <= last;
24
61
  };
25
62
  function digit(code) {
26
- return between(code, 0x30, 0x39);
63
+ return between(code, 48, 57);
27
64
  }
28
65
  function hexdigit(code) {
29
- return digit(code) || between(code, 0x41, 0x46) || between(code, 0x61, 0x66);
66
+ return digit(code) || between(code, 65, 70) || between(code, 97, 102);
30
67
  }
31
68
  function uppercaseletter(code) {
32
- return between(code, 0x41, 0x5a);
69
+ return between(code, 65, 90);
33
70
  }
34
71
  function lowercaseletter(code) {
35
- return between(code, 0x61, 0x7a);
72
+ return between(code, 97, 122);
36
73
  }
37
74
  function letter(code) {
38
75
  return uppercaseletter(code) || lowercaseletter(code);
39
76
  }
40
77
  function nonascii(code) {
41
- return code >= 0x80;
78
+ return code >= 128;
42
79
  }
43
80
  function namestartchar(code) {
44
- return letter(code) || nonascii(code) || code === 0x5f;
81
+ return letter(code) || nonascii(code) || code === 95;
45
82
  }
46
83
  function namechar(code) {
47
- return namestartchar(code) || digit(code) || code === 0x2d;
84
+ return namestartchar(code) || digit(code) || code === 45;
48
85
  }
49
86
  function nonprintable(code) {
50
- return between(code, 0, 8) || code === 0xb || between(code, 0xe, 0x1f) || code === 0x7f;
87
+ return between(code, 0, 8) || code === 11 || between(code, 14, 31) || code === 127;
51
88
  }
52
89
  function newline(code) {
53
- return code === 0xa;
90
+ return code === 10;
54
91
  }
55
92
  function whitespace(code) {
56
- return newline(code) || code === 9 || code === 0x20;
93
+ return newline(code) || code === 9 || code === 32;
57
94
  }
58
- const maximumallowedcodepoint = 0x10ffff;
95
+ const maximumallowedcodepoint = 1114111;
59
96
  class InvalidCharacterError extends Error {
60
97
  constructor(message) {
61
98
  super(message);
62
- this.name = 'InvalidCharacterError';
99
+ this.name = "InvalidCharacterError";
63
100
  }
64
101
  }
65
- exports.InvalidCharacterError = InvalidCharacterError;
66
102
  function preprocess(str) {
67
- // Turn a string into an array of code points,
68
- // following the preprocessing cleanup rules.
69
103
  const codepoints = [];
70
104
  for (let i = 0; i < str.length; i++) {
71
105
  let code = str.charCodeAt(i);
72
- if (code === 0xd && str.charCodeAt(i + 1) === 0xa) {
73
- code = 0xa;
106
+ if (code === 13 && str.charCodeAt(i + 1) === 10) {
107
+ code = 10;
74
108
  i++;
75
109
  }
76
- if (code === 0xd || code === 0xc) code = 0xa;
77
- if (code === 0x0) code = 0xfffd;
78
- if (between(code, 0xd800, 0xdbff) && between(str.charCodeAt(i + 1), 0xdc00, 0xdfff)) {
79
- // Decode a surrogate pair into an astral codepoint.
80
- const lead = code - 0xd800;
81
- const trail = str.charCodeAt(i + 1) - 0xdc00;
110
+ if (code === 13 || code === 12)
111
+ code = 10;
112
+ if (code === 0)
113
+ code = 65533;
114
+ if (between(code, 55296, 56319) && between(str.charCodeAt(i + 1), 56320, 57343)) {
115
+ const lead = code - 55296;
116
+ const trail = str.charCodeAt(i + 1) - 56320;
82
117
  code = Math.pow(2, 16) + lead * Math.pow(2, 10) + trail;
83
118
  i++;
84
119
  }
@@ -87,11 +122,11 @@ function preprocess(str) {
87
122
  return codepoints;
88
123
  }
89
124
  function stringFromCode(code) {
90
- if (code <= 0xffff) return String.fromCharCode(code);
91
- // Otherwise, encode astral char as surrogate pair.
125
+ if (code <= 65535)
126
+ return String.fromCharCode(code);
92
127
  code -= Math.pow(2, 16);
93
- const lead = Math.floor(code / Math.pow(2, 10)) + 0xd800;
94
- const trail = code % Math.pow(2, 10) + 0xdc00;
128
+ const lead = Math.floor(code / Math.pow(2, 10)) + 55296;
129
+ const trail = code % Math.pow(2, 10) + 56320;
95
130
  return String.fromCharCode(lead) + String.fromCharCode(trail);
96
131
  }
97
132
  function tokenize(str1) {
@@ -99,39 +134,39 @@ function tokenize(str1) {
99
134
  let i = -1;
100
135
  const tokens = [];
101
136
  let code;
102
-
103
- // Line number information.
104
137
  let line = 0;
105
138
  let column = 0;
106
- // The only use of lastLineLength is in reconsume().
107
139
  let lastLineLength = 0;
108
- const incrLineno = function () {
140
+ const incrLineno = function() {
109
141
  line += 1;
110
142
  lastLineLength = column;
111
143
  column = 0;
112
144
  };
113
- const locStart = {
114
- line: line,
115
- column: column
145
+ const locStart = { line, column };
146
+ const codepoint = function(i2) {
147
+ if (i2 >= str.length)
148
+ return -1;
149
+ return str[i2];
116
150
  };
117
- const codepoint = function (i) {
118
- if (i >= str.length) return -1;
119
- return str[i];
120
- };
121
- const next = function (num) {
122
- if (num === undefined) num = 1;
123
- if (num > 3) throw 'Spec Error: no more than three codepoints of lookahead.';
151
+ const next = function(num) {
152
+ if (num === void 0)
153
+ num = 1;
154
+ if (num > 3)
155
+ throw "Spec Error: no more than three codepoints of lookahead.";
124
156
  return codepoint(i + num);
125
157
  };
126
- const consume = function (num) {
127
- if (num === undefined) num = 1;
158
+ const consume = function(num) {
159
+ if (num === void 0)
160
+ num = 1;
128
161
  i += num;
129
162
  code = codepoint(i);
130
- if (newline(code)) incrLineno();else column += num;
131
- // console.log('Consume '+i+' '+String.fromCharCode(code) + ' 0x' + code.toString(16));
163
+ if (newline(code))
164
+ incrLineno();
165
+ else
166
+ column += num;
132
167
  return true;
133
168
  };
134
- const reconsume = function () {
169
+ const reconsume = function() {
135
170
  i -= 1;
136
171
  if (newline(code)) {
137
172
  line -= 1;
@@ -143,66 +178,68 @@ function tokenize(str1) {
143
178
  locStart.column = column;
144
179
  return true;
145
180
  };
146
- const eof = function (codepoint) {
147
- if (codepoint === undefined) codepoint = code;
148
- return codepoint === -1;
181
+ const eof = function(codepoint2) {
182
+ if (codepoint2 === void 0)
183
+ codepoint2 = code;
184
+ return codepoint2 === -1;
185
+ };
186
+ const donothing = function() {
149
187
  };
150
- const donothing = function () {};
151
- const parseerror = function () {
152
- // Language bindings don't like writing to stdout!
153
- // console.log('Parse error at index ' + i + ', processing codepoint 0x' + code.toString(16) + '.'); return true;
188
+ const parseerror = function() {
154
189
  };
155
- const consumeAToken = function () {
190
+ const consumeAToken = function() {
156
191
  consumeComments();
157
192
  consume();
158
193
  if (whitespace(code)) {
159
- while (whitespace(next())) consume();
194
+ while (whitespace(next()))
195
+ consume();
160
196
  return new WhitespaceToken();
161
- } else if (code === 0x22) {
197
+ } else if (code === 34) {
162
198
  return consumeAStringToken();
163
- } else if (code === 0x23) {
199
+ } else if (code === 35) {
164
200
  if (namechar(next()) || areAValidEscape(next(1), next(2))) {
165
- const token = new HashToken('');
166
- if (wouldStartAnIdentifier(next(1), next(2), next(3))) token.type = 'id';
201
+ const token = new HashToken("");
202
+ if (wouldStartAnIdentifier(next(1), next(2), next(3)))
203
+ token.type = "id";
167
204
  token.value = consumeAName();
168
205
  return token;
169
206
  } else {
170
207
  return new DelimToken(code);
171
208
  }
172
- } else if (code === 0x24) {
173
- if (next() === 0x3d) {
209
+ } else if (code === 36) {
210
+ if (next() === 61) {
174
211
  consume();
175
212
  return new SuffixMatchToken();
176
213
  } else {
177
214
  return new DelimToken(code);
178
215
  }
179
- } else if (code === 0x27) {
216
+ } else if (code === 39) {
180
217
  return consumeAStringToken();
181
- } else if (code === 0x28) {
218
+ } else if (code === 40) {
182
219
  return new OpenParenToken();
183
- } else if (code === 0x29) {
220
+ } else if (code === 41) {
184
221
  return new CloseParenToken();
185
- } else if (code === 0x2a) {
186
- if (next() === 0x3d) {
222
+ } else if (code === 42) {
223
+ if (next() === 61) {
187
224
  consume();
188
225
  return new SubstringMatchToken();
189
226
  } else {
190
227
  return new DelimToken(code);
191
228
  }
192
- } else if (code === 0x2b) {
229
+ } else if (code === 43) {
193
230
  if (startsWithANumber()) {
194
231
  reconsume();
195
232
  return consumeANumericToken();
196
233
  } else {
197
234
  return new DelimToken(code);
198
235
  }
199
- } else if (code === 0x2c) {
236
+ } else if (code === 44) {
200
237
  return new CommaToken();
201
- } else if (code === 0x2d) {
238
+ } else if (code === 45) {
202
239
  if (startsWithANumber()) {
203
240
  reconsume();
204
241
  return consumeANumericToken();
205
- } else if (next(1) === 0x2d && next(2) === 0x3e) {
242
+ } else if (next(1) === 45 && next(2) === 62) {
206
243
  consume(2);
207
244
  return new CDCToken();
208
245
  } else if (startsWithAnIdentifier()) {
@@ -211,29 +248,32 @@ function tokenize(str1) {
211
248
  } else {
212
249
  return new DelimToken(code);
213
250
  }
214
- } else if (code === 0x2e) {
251
+ } else if (code === 46) {
215
252
  if (startsWithANumber()) {
216
253
  reconsume();
217
254
  return consumeANumericToken();
218
255
  } else {
219
256
  return new DelimToken(code);
220
257
  }
221
- } else if (code === 0x3a) {
258
+ } else if (code === 58) {
222
259
  return new ColonToken();
223
- } else if (code === 0x3b) {
260
+ } else if (code === 59) {
224
261
  return new SemicolonToken();
225
- } else if (code === 0x3c) {
226
- if (next(1) === 0x21 && next(2) === 0x2d && next(3) === 0x2d) {
262
+ } else if (code === 60) {
263
+ if (next(1) === 33 && next(2) === 45 && next(3) === 45) {
227
264
  consume(3);
228
265
  return new CDOToken();
229
266
  } else {
230
267
  return new DelimToken(code);
231
268
  }
232
- } else if (code === 0x40) {
233
- if (wouldStartAnIdentifier(next(1), next(2), next(3))) return new AtKeywordToken(consumeAName());else return new DelimToken(code);
234
- } else if (code === 0x5b) {
269
+ } else if (code === 64) {
270
+ if (wouldStartAnIdentifier(next(1), next(2), next(3)))
271
+ return new AtKeywordToken(consumeAName());
272
+ else
273
+ return new DelimToken(code);
274
+ } else if (code === 91) {
235
275
  return new OpenSquareToken();
236
- } else if (code === 0x5c) {
276
+ } else if (code === 92) {
237
277
  if (startsWithAValidEscape()) {
238
278
  reconsume();
239
279
  return consumeAnIdentlikeToken();
@@ -241,31 +281,31 @@ function tokenize(str1) {
241
281
  parseerror();
242
282
  return new DelimToken(code);
243
283
  }
244
- } else if (code === 0x5d) {
284
+ } else if (code === 93) {
245
285
  return new CloseSquareToken();
246
- } else if (code === 0x5e) {
247
- if (next() === 0x3d) {
286
+ } else if (code === 94) {
287
+ if (next() === 61) {
248
288
  consume();
249
289
  return new PrefixMatchToken();
250
290
  } else {
251
291
  return new DelimToken(code);
252
292
  }
253
- } else if (code === 0x7b) {
293
+ } else if (code === 123) {
254
294
  return new OpenCurlyToken();
255
- } else if (code === 0x7c) {
256
- if (next() === 0x3d) {
295
+ } else if (code === 124) {
296
+ if (next() === 61) {
257
297
  consume();
258
298
  return new DashMatchToken();
259
- } else if (next() === 0x7c) {
299
+ } else if (next() === 124) {
260
300
  consume();
261
301
  return new ColumnToken();
262
302
  } else {
263
303
  return new DelimToken(code);
264
304
  }
265
- } else if (code === 0x7d) {
305
+ } else if (code === 125) {
266
306
  return new CloseCurlyToken();
267
- } else if (code === 0x7e) {
268
- if (next() === 0x3d) {
307
+ } else if (code === 126) {
308
+ if (next() === 61) {
269
309
  consume();
270
310
  return new IncludeMatchToken();
271
311
  } else {
@@ -283,12 +323,12 @@ function tokenize(str1) {
283
323
  return new DelimToken(code);
284
324
  }
285
325
  };
286
- const consumeComments = function () {
287
- while (next(1) === 0x2f && next(2) === 0x2a) {
326
+ const consumeComments = function() {
327
+ while (next(1) === 47 && next(2) === 42) {
288
328
  consume(2);
289
329
  while (true) {
290
330
  consume();
291
- if (code === 0x2a && next() === 0x2f) {
331
+ if (code === 42 && next() === 47) {
292
332
  consume();
293
333
  break;
294
334
  } else if (eof()) {
@@ -298,7 +338,7 @@ function tokenize(str1) {
298
338
  }
299
339
  }
300
340
  };
301
- const consumeANumericToken = function () {
341
+ const consumeANumericToken = function() {
302
342
  const num = consumeANumber();
303
343
  if (wouldStartAnIdentifier(next(1), next(2), next(3))) {
304
344
  const token = new DimensionToken();
@@ -307,7 +347,7 @@ function tokenize(str1) {
307
347
  token.type = num.type;
308
348
  token.unit = consumeAName();
309
349
  return token;
310
- } else if (next() === 0x25) {
350
+ } else if (next() === 37) {
311
351
  consume();
312
352
  const token = new PercentageToken();
313
353
  token.value = num.value;
@@ -321,22 +361,29 @@ function tokenize(str1) {
321
361
  return token;
322
362
  }
323
363
  };
324
- const consumeAnIdentlikeToken = function () {
325
- const str = consumeAName();
326
- if (str.toLowerCase() === 'url' && next() === 0x28) {
364
+ const consumeAnIdentlikeToken = function() {
365
+ const str2 = consumeAName();
366
+ if (str2.toLowerCase() === "url" && next() === 40) {
327
367
  consume();
328
- while (whitespace(next(1)) && whitespace(next(2))) consume();
329
- if (next() === 0x22 || next() === 0x27) return new FunctionToken(str);else if (whitespace(next()) && (next(2) === 0x22 || next(2) === 0x27)) return new FunctionToken(str);else return consumeAURLToken();
330
- } else if (next() === 0x28) {
368
+ while (whitespace(next(1)) && whitespace(next(2)))
369
+ consume();
370
+ if (next() === 34 || next() === 39)
371
+ return new FunctionToken(str2);
372
+ else if (whitespace(next()) && (next(2) === 34 || next(2) === 39))
373
+ return new FunctionToken(str2);
374
+ else
375
+ return consumeAURLToken();
376
+ } else if (next() === 40) {
331
377
  consume();
332
- return new FunctionToken(str);
378
+ return new FunctionToken(str2);
333
379
  } else {
334
- return new IdentToken(str);
380
+ return new IdentToken(str2);
335
381
  }
336
382
  };
337
- const consumeAStringToken = function (endingCodePoint) {
338
- if (endingCodePoint === undefined) endingCodePoint = code;
339
- let string = '';
383
+ const consumeAStringToken = function(endingCodePoint) {
384
+ if (endingCodePoint === void 0)
385
+ endingCodePoint = code;
386
+ let string = "";
340
387
  while (consume()) {
341
388
  if (code === endingCodePoint || eof()) {
342
389
  return new StringToken(string);
@@ -344,35 +391,43 @@ function tokenize(str1) {
344
391
  parseerror();
345
392
  reconsume();
346
393
  return new BadStringToken();
347
- } else if (code === 0x5c) {
348
- if (eof(next())) donothing();else if (newline(next())) consume();else string += stringFromCode(consumeEscape());
394
+ } else if (code === 92) {
395
+ if (eof(next()))
396
+ donothing();
397
+ else if (newline(next()))
398
+ consume();
399
+ else
400
+ string += stringFromCode(consumeEscape());
349
401
  } else {
350
402
  string += stringFromCode(code);
351
403
  }
352
404
  }
353
- throw new Error('Internal error');
405
+ throw new Error("Internal error");
354
406
  };
355
- const consumeAURLToken = function () {
356
- const token = new URLToken('');
357
- while (whitespace(next())) consume();
358
- if (eof(next())) return token;
407
+ const consumeAURLToken = function() {
408
+ const token = new URLToken("");
409
+ while (whitespace(next()))
410
+ consume();
411
+ if (eof(next()))
412
+ return token;
359
413
  while (consume()) {
360
- if (code === 0x29 || eof()) {
414
+ if (code === 41 || eof()) {
361
415
  return token;
362
416
  } else if (whitespace(code)) {
363
- while (whitespace(next())) consume();
364
- if (next() === 0x29 || eof(next())) {
417
+ while (whitespace(next()))
418
+ consume();
419
+ if (next() === 41 || eof(next())) {
365
420
  consume();
366
421
  return token;
367
422
  } else {
368
423
  consumeTheRemnantsOfABadURL();
369
424
  return new BadURLToken();
370
425
  }
371
- } else if (code === 0x22 || code === 0x27 || code === 0x28 || nonprintable(code)) {
426
+ } else if (code === 34 || code === 39 || code === 40 || nonprintable(code)) {
372
427
  parseerror();
373
428
  consumeTheRemnantsOfABadURL();
374
429
  return new BadURLToken();
375
- } else if (code === 0x5c) {
430
+ } else if (code === 92) {
376
431
  if (startsWithAValidEscape()) {
377
432
  token.value += stringFromCode(consumeEscape());
378
433
  } else {
@@ -384,14 +439,11 @@ function tokenize(str1) {
384
439
  token.value += stringFromCode(code);
385
440
  }
386
441
  }
387
- throw new Error('Internal error');
442
+ throw new Error("Internal error");
388
443
  };
389
- const consumeEscape = function () {
390
- // Assume the current character is the \
391
- // and the next code point is not a newline.
444
+ const consumeEscape = function() {
392
445
  consume();
393
446
  if (hexdigit(code)) {
394
- // Consume 1-6 hex digits
395
447
  const digits = [code];
396
448
  for (let total = 0; total < 5; total++) {
397
449
  if (hexdigit(next())) {
@@ -401,39 +453,53 @@ function tokenize(str1) {
401
453
  break;
402
454
  }
403
455
  }
404
- if (whitespace(next())) consume();
405
- let value = parseInt(digits.map(function (x) {
456
+ if (whitespace(next()))
457
+ consume();
458
+ let value = parseInt(digits.map(function(x) {
406
459
  return String.fromCharCode(x);
407
- }).join(''), 16);
408
- if (value > maximumallowedcodepoint) value = 0xfffd;
460
+ }).join(""), 16);
461
+ if (value > maximumallowedcodepoint)
462
+ value = 65533;
409
463
  return value;
410
464
  } else if (eof()) {
411
- return 0xfffd;
465
+ return 65533;
412
466
  } else {
413
467
  return code;
414
468
  }
415
469
  };
416
- const areAValidEscape = function (c1, c2) {
417
- if (c1 !== 0x5c) return false;
418
- if (newline(c2)) return false;
470
+ const areAValidEscape = function(c1, c2) {
471
+ if (c1 !== 92)
472
+ return false;
473
+ if (newline(c2))
474
+ return false;
419
475
  return true;
420
476
  };
421
- const startsWithAValidEscape = function () {
477
+ const startsWithAValidEscape = function() {
422
478
  return areAValidEscape(code, next());
423
479
  };
424
- const wouldStartAnIdentifier = function (c1, c2, c3) {
425
- if (c1 === 0x2d) return namestartchar(c2) || c2 === 0x2d || areAValidEscape(c2, c3);else if (namestartchar(c1)) return true;else if (c1 === 0x5c) return areAValidEscape(c1, c2);else return false;
480
+ const wouldStartAnIdentifier = function(c1, c2, c3) {
481
+ if (c1 === 45)
482
+ return namestartchar(c2) || c2 === 45 || areAValidEscape(c2, c3);
483
+ else if (namestartchar(c1))
484
+ return true;
485
+ else if (c1 === 92)
486
+ return areAValidEscape(c1, c2);
487
+ else
488
+ return false;
426
489
  };
427
- const startsWithAnIdentifier = function () {
490
+ const startsWithAnIdentifier = function() {
428
491
  return wouldStartAnIdentifier(code, next(1), next(2));
429
492
  };
430
- const wouldStartANumber = function (c1, c2, c3) {
431
- if (c1 === 0x2b || c1 === 0x2d) {
432
- if (digit(c2)) return true;
433
- if (c2 === 0x2e && digit(c3)) return true;
493
+ const wouldStartANumber = function(c1, c2, c3) {
494
+ if (c1 === 43 || c1 === 45) {
495
+ if (digit(c2))
496
+ return true;
497
+ if (c2 === 46 && digit(c3))
498
+ return true;
434
499
  return false;
435
- } else if (c1 === 0x2e) {
436
- if (digit(c2)) return true;
500
+ } else if (c1 === 46) {
501
+ if (digit(c2))
502
+ return true;
437
503
  return false;
438
504
  } else if (digit(c1)) {
439
505
  return true;
@@ -441,11 +507,11 @@ function tokenize(str1) {
441
507
  return false;
442
508
  }
443
509
  };
444
- const startsWithANumber = function () {
510
+ const startsWithANumber = function() {
445
511
  return wouldStartANumber(code, next(1), next(2));
446
512
  };
447
- const consumeAName = function () {
448
- let result = '';
513
+ const consumeAName = function() {
514
+ let result = "";
449
515
  while (consume()) {
450
516
  if (namechar(code)) {
451
517
  result += stringFromCode(code);
@@ -456,12 +522,12 @@ function tokenize(str1) {
456
522
  return result;
457
523
  }
458
524
  }
459
- throw new Error('Internal parse error');
525
+ throw new Error("Internal parse error");
460
526
  };
461
- const consumeANumber = function () {
462
- let repr = '';
463
- let type = 'integer';
464
- if (next() === 0x2b || next() === 0x2d) {
527
+ const consumeANumber = function() {
528
+ let repr = "";
529
+ let type = "integer";
530
+ if (next() === 43 || next() === 45) {
465
531
  consume();
466
532
  repr += stringFromCode(code);
467
533
  }
@@ -469,57 +535,50 @@ function tokenize(str1) {
469
535
  consume();
470
536
  repr += stringFromCode(code);
471
537
  }
472
- if (next(1) === 0x2e && digit(next(2))) {
538
+ if (next(1) === 46 && digit(next(2))) {
473
539
  consume();
474
540
  repr += stringFromCode(code);
475
541
  consume();
476
542
  repr += stringFromCode(code);
477
- type = 'number';
543
+ type = "number";
478
544
  while (digit(next())) {
479
545
  consume();
480
546
  repr += stringFromCode(code);
481
547
  }
482
548
  }
483
- const c1 = next(1),
484
- c2 = next(2),
485
- c3 = next(3);
486
- if ((c1 === 0x45 || c1 === 0x65) && digit(c2)) {
549
+ const c1 = next(1), c2 = next(2), c3 = next(3);
550
+ if ((c1 === 69 || c1 === 101) && digit(c2)) {
487
551
  consume();
488
552
  repr += stringFromCode(code);
489
553
  consume();
490
554
  repr += stringFromCode(code);
491
- type = 'number';
555
+ type = "number";
492
556
  while (digit(next())) {
493
557
  consume();
494
558
  repr += stringFromCode(code);
495
559
  }
496
- } else if ((c1 === 0x45 || c1 === 0x65) && (c2 === 0x2b || c2 === 0x2d) && digit(c3)) {
560
+ } else if ((c1 === 69 || c1 === 101) && (c2 === 43 || c2 === 45) && digit(c3)) {
497
561
  consume();
498
562
  repr += stringFromCode(code);
499
563
  consume();
500
564
  repr += stringFromCode(code);
501
565
  consume();
502
566
  repr += stringFromCode(code);
503
- type = 'number';
567
+ type = "number";
504
568
  while (digit(next())) {
505
569
  consume();
506
570
  repr += stringFromCode(code);
507
571
  }
508
572
  }
509
573
  const value = convertAStringToANumber(repr);
510
- return {
511
- type: type,
512
- value: value,
513
- repr: repr
514
- };
574
+ return { type, value, repr };
515
575
  };
516
- const convertAStringToANumber = function (string) {
517
- // CSS's number rules are identical to JS, afaik.
576
+ const convertAStringToANumber = function(string) {
518
577
  return +string;
519
578
  };
520
- const consumeTheRemnantsOfABadURL = function () {
579
+ const consumeTheRemnantsOfABadURL = function() {
521
580
  while (consume()) {
522
- if (code === 0x29 || eof()) {
581
+ if (code === 41 || eof()) {
523
582
  return;
524
583
  } else if (startsWithAValidEscape()) {
525
584
  consumeEscape();
@@ -533,219 +592,194 @@ function tokenize(str1) {
533
592
  while (!eof(next())) {
534
593
  tokens.push(consumeAToken());
535
594
  iterationCount++;
536
- if (iterationCount > str.length * 2) throw new Error("I'm infinite-looping!");
595
+ if (iterationCount > str.length * 2)
596
+ throw new Error("I'm infinite-looping!");
537
597
  }
538
598
  return tokens;
539
599
  }
540
600
  class CSSParserToken {
541
601
  constructor() {
542
- this.tokenType = '';
543
- this.value = void 0;
602
+ this.tokenType = "";
544
603
  }
545
604
  toJSON() {
546
- return {
547
- token: this.tokenType
548
- };
605
+ return { token: this.tokenType };
549
606
  }
550
607
  toString() {
551
608
  return this.tokenType;
552
609
  }
553
610
  toSource() {
554
- return '' + this;
611
+ return "" + this;
555
612
  }
556
613
  }
557
- exports.CSSParserToken = CSSParserToken;
558
614
  class BadStringToken extends CSSParserToken {
559
- constructor(...args) {
560
- super(...args);
561
- this.tokenType = 'BADSTRING';
615
+ constructor() {
616
+ super(...arguments);
617
+ this.tokenType = "BADSTRING";
562
618
  }
563
619
  }
564
- exports.BadStringToken = BadStringToken;
565
620
  class BadURLToken extends CSSParserToken {
566
- constructor(...args) {
567
- super(...args);
568
- this.tokenType = 'BADURL';
621
+ constructor() {
622
+ super(...arguments);
623
+ this.tokenType = "BADURL";
569
624
  }
570
625
  }
571
- exports.BadURLToken = BadURLToken;
572
626
  class WhitespaceToken extends CSSParserToken {
573
- constructor(...args) {
574
- super(...args);
575
- this.tokenType = 'WHITESPACE';
627
+ constructor() {
628
+ super(...arguments);
629
+ this.tokenType = "WHITESPACE";
576
630
  }
577
631
  toString() {
578
- return 'WS';
632
+ return "WS";
579
633
  }
580
634
  toSource() {
581
- return ' ';
635
+ return " ";
582
636
  }
583
637
  }
584
- exports.WhitespaceToken = WhitespaceToken;
585
638
  class CDOToken extends CSSParserToken {
586
- constructor(...args) {
587
- super(...args);
588
- this.tokenType = 'CDO';
639
+ constructor() {
640
+ super(...arguments);
641
+ this.tokenType = "CDO";
589
642
  }
590
643
  toSource() {
591
- return '<!--';
644
+ return "<!--";
592
645
  }
593
646
  }
594
- exports.CDOToken = CDOToken;
595
647
  class CDCToken extends CSSParserToken {
596
- constructor(...args) {
597
- super(...args);
598
- this.tokenType = 'CDC';
648
+ constructor() {
649
+ super(...arguments);
650
+ this.tokenType = "CDC";
599
651
  }
600
652
  toSource() {
601
- return '-->';
653
+ return "-->";
602
654
  }
603
655
  }
604
- exports.CDCToken = CDCToken;
605
656
  class ColonToken extends CSSParserToken {
606
- constructor(...args) {
607
- super(...args);
608
- this.tokenType = ':';
657
+ constructor() {
658
+ super(...arguments);
659
+ this.tokenType = ":";
609
660
  }
610
661
  }
611
- exports.ColonToken = ColonToken;
612
662
  class SemicolonToken extends CSSParserToken {
613
- constructor(...args) {
614
- super(...args);
615
- this.tokenType = ';';
663
+ constructor() {
664
+ super(...arguments);
665
+ this.tokenType = ";";
616
666
  }
617
667
  }
618
- exports.SemicolonToken = SemicolonToken;
619
668
  class CommaToken extends CSSParserToken {
620
- constructor(...args) {
621
- super(...args);
622
- this.tokenType = ',';
669
+ constructor() {
670
+ super(...arguments);
671
+ this.tokenType = ",";
623
672
  }
624
673
  }
625
- exports.CommaToken = CommaToken;
626
674
  class GroupingToken extends CSSParserToken {
627
- constructor(...args) {
628
- super(...args);
629
- this.value = '';
630
- this.mirror = '';
675
+ constructor() {
676
+ super(...arguments);
677
+ this.value = "";
678
+ this.mirror = "";
631
679
  }
632
680
  }
633
- exports.GroupingToken = GroupingToken;
634
681
  class OpenCurlyToken extends GroupingToken {
635
682
  constructor() {
636
683
  super();
637
- this.tokenType = '{';
638
- this.value = '{';
639
- this.mirror = '}';
684
+ this.tokenType = "{";
685
+ this.value = "{";
686
+ this.mirror = "}";
640
687
  }
641
688
  }
642
- exports.OpenCurlyToken = OpenCurlyToken;
643
689
  class CloseCurlyToken extends GroupingToken {
644
690
  constructor() {
645
691
  super();
646
- this.tokenType = '}';
647
- this.value = '}';
648
- this.mirror = '{';
692
+ this.tokenType = "}";
693
+ this.value = "}";
694
+ this.mirror = "{";
649
695
  }
650
696
  }
651
- exports.CloseCurlyToken = CloseCurlyToken;
652
697
  class OpenSquareToken extends GroupingToken {
653
698
  constructor() {
654
699
  super();
655
- this.tokenType = '[';
656
- this.value = '[';
657
- this.mirror = ']';
700
+ this.tokenType = "[";
701
+ this.value = "[";
702
+ this.mirror = "]";
658
703
  }
659
704
  }
660
- exports.OpenSquareToken = OpenSquareToken;
661
705
  class CloseSquareToken extends GroupingToken {
662
706
  constructor() {
663
707
  super();
664
- this.tokenType = ']';
665
- this.value = ']';
666
- this.mirror = '[';
708
+ this.tokenType = "]";
709
+ this.value = "]";
710
+ this.mirror = "[";
667
711
  }
668
712
  }
669
- exports.CloseSquareToken = CloseSquareToken;
670
713
  class OpenParenToken extends GroupingToken {
671
714
  constructor() {
672
715
  super();
673
- this.tokenType = '(';
674
- this.value = '(';
675
- this.mirror = ')';
716
+ this.tokenType = "(";
717
+ this.value = "(";
718
+ this.mirror = ")";
676
719
  }
677
720
  }
678
- exports.OpenParenToken = OpenParenToken;
679
721
  class CloseParenToken extends GroupingToken {
680
722
  constructor() {
681
723
  super();
682
- this.tokenType = ')';
683
- this.value = ')';
684
- this.mirror = '(';
724
+ this.tokenType = ")";
725
+ this.value = ")";
726
+ this.mirror = "(";
685
727
  }
686
728
  }
687
- exports.CloseParenToken = CloseParenToken;
688
729
  class IncludeMatchToken extends CSSParserToken {
689
- constructor(...args) {
690
- super(...args);
691
- this.tokenType = '~=';
730
+ constructor() {
731
+ super(...arguments);
732
+ this.tokenType = "~=";
692
733
  }
693
734
  }
694
- exports.IncludeMatchToken = IncludeMatchToken;
695
735
  class DashMatchToken extends CSSParserToken {
696
- constructor(...args) {
697
- super(...args);
698
- this.tokenType = '|=';
736
+ constructor() {
737
+ super(...arguments);
738
+ this.tokenType = "|=";
699
739
  }
700
740
  }
701
- exports.DashMatchToken = DashMatchToken;
702
741
  class PrefixMatchToken extends CSSParserToken {
703
- constructor(...args) {
704
- super(...args);
705
- this.tokenType = '^=';
742
+ constructor() {
743
+ super(...arguments);
744
+ this.tokenType = "^=";
706
745
  }
707
746
  }
708
- exports.PrefixMatchToken = PrefixMatchToken;
709
747
  class SuffixMatchToken extends CSSParserToken {
710
- constructor(...args) {
711
- super(...args);
712
- this.tokenType = '$=';
748
+ constructor() {
749
+ super(...arguments);
750
+ this.tokenType = "$=";
713
751
  }
714
752
  }
715
- exports.SuffixMatchToken = SuffixMatchToken;
716
753
  class SubstringMatchToken extends CSSParserToken {
717
- constructor(...args) {
718
- super(...args);
719
- this.tokenType = '*=';
754
+ constructor() {
755
+ super(...arguments);
756
+ this.tokenType = "*=";
720
757
  }
721
758
  }
722
- exports.SubstringMatchToken = SubstringMatchToken;
723
759
  class ColumnToken extends CSSParserToken {
724
- constructor(...args) {
725
- super(...args);
726
- this.tokenType = '||';
760
+ constructor() {
761
+ super(...arguments);
762
+ this.tokenType = "||";
727
763
  }
728
764
  }
729
- exports.ColumnToken = ColumnToken;
730
765
  class EOFToken extends CSSParserToken {
731
- constructor(...args) {
732
- super(...args);
733
- this.tokenType = 'EOF';
766
+ constructor() {
767
+ super(...arguments);
768
+ this.tokenType = "EOF";
734
769
  }
735
770
  toSource() {
736
- return '';
771
+ return "";
737
772
  }
738
773
  }
739
- exports.EOFToken = EOFToken;
740
774
  class DelimToken extends CSSParserToken {
741
775
  constructor(code) {
742
776
  super();
743
- this.tokenType = 'DELIM';
744
- this.value = '';
777
+ this.tokenType = "DELIM";
778
+ this.value = "";
745
779
  this.value = stringFromCode(code);
746
780
  }
747
781
  toString() {
748
- return 'DELIM(' + this.value + ')';
782
+ return "DELIM(" + this.value + ")";
749
783
  }
750
784
  toJSON() {
751
785
  const json = this.constructor.prototype.constructor.prototype.toJSON.call(this);
@@ -753,14 +787,16 @@ class DelimToken extends CSSParserToken {
753
787
  return json;
754
788
  }
755
789
  toSource() {
756
- if (this.value === '\\') return '\\\n';else return this.value;
790
+ if (this.value === "\\")
791
+ return "\\\n";
792
+ else
793
+ return this.value;
757
794
  }
758
795
  }
759
- exports.DelimToken = DelimToken;
760
796
  class StringValuedToken extends CSSParserToken {
761
- constructor(...args) {
762
- super(...args);
763
- this.value = '';
797
+ constructor() {
798
+ super(...arguments);
799
+ this.value = "";
764
800
  }
765
801
  ASCIIMatch(str) {
766
802
  return this.value.toLowerCase() === str.toLowerCase();
@@ -771,61 +807,55 @@ class StringValuedToken extends CSSParserToken {
771
807
  return json;
772
808
  }
773
809
  }
774
- exports.StringValuedToken = StringValuedToken;
775
810
  class IdentToken extends StringValuedToken {
776
811
  constructor(val) {
777
812
  super();
778
- this.tokenType = 'IDENT';
813
+ this.tokenType = "IDENT";
779
814
  this.value = val;
780
815
  }
781
816
  toString() {
782
- return 'IDENT(' + this.value + ')';
817
+ return "IDENT(" + this.value + ")";
783
818
  }
784
819
  toSource() {
785
820
  return escapeIdent(this.value);
786
821
  }
787
822
  }
788
- exports.IdentToken = IdentToken;
789
823
  class FunctionToken extends StringValuedToken {
790
824
  constructor(val) {
791
825
  super();
792
- this.tokenType = 'FUNCTION';
793
- this.mirror = void 0;
826
+ this.tokenType = "FUNCTION";
794
827
  this.value = val;
795
- this.mirror = ')';
828
+ this.mirror = ")";
796
829
  }
797
830
  toString() {
798
- return 'FUNCTION(' + this.value + ')';
831
+ return "FUNCTION(" + this.value + ")";
799
832
  }
800
833
  toSource() {
801
- return escapeIdent(this.value) + '(';
834
+ return escapeIdent(this.value) + "(";
802
835
  }
803
836
  }
804
- exports.FunctionToken = FunctionToken;
805
837
  class AtKeywordToken extends StringValuedToken {
806
838
  constructor(val) {
807
839
  super();
808
- this.tokenType = 'AT-KEYWORD';
840
+ this.tokenType = "AT-KEYWORD";
809
841
  this.value = val;
810
842
  }
811
843
  toString() {
812
- return 'AT(' + this.value + ')';
844
+ return "AT(" + this.value + ")";
813
845
  }
814
846
  toSource() {
815
- return '@' + escapeIdent(this.value);
847
+ return "@" + escapeIdent(this.value);
816
848
  }
817
849
  }
818
- exports.AtKeywordToken = AtKeywordToken;
819
850
  class HashToken extends StringValuedToken {
820
851
  constructor(val) {
821
852
  super();
822
- this.tokenType = 'HASH';
823
- this.type = void 0;
853
+ this.tokenType = "HASH";
824
854
  this.value = val;
825
- this.type = 'unrestricted';
855
+ this.type = "unrestricted";
826
856
  }
827
857
  toString() {
828
- return 'HASH(' + this.value + ')';
858
+ return "HASH(" + this.value + ")";
829
859
  }
830
860
  toJSON() {
831
861
  const json = this.constructor.prototype.constructor.prototype.toJSON.call(this);
@@ -834,47 +864,46 @@ class HashToken extends StringValuedToken {
834
864
  return json;
835
865
  }
836
866
  toSource() {
837
- if (this.type === 'id') return '#' + escapeIdent(this.value);else return '#' + escapeHash(this.value);
867
+ if (this.type === "id")
868
+ return "#" + escapeIdent(this.value);
869
+ else
870
+ return "#" + escapeHash(this.value);
838
871
  }
839
872
  }
840
- exports.HashToken = HashToken;
841
873
  class StringToken extends StringValuedToken {
842
874
  constructor(val) {
843
875
  super();
844
- this.tokenType = 'STRING';
876
+ this.tokenType = "STRING";
845
877
  this.value = val;
846
878
  }
847
879
  toString() {
848
880
  return '"' + escapeString(this.value) + '"';
849
881
  }
850
882
  }
851
- exports.StringToken = StringToken;
852
883
  class URLToken extends StringValuedToken {
853
884
  constructor(val) {
854
885
  super();
855
- this.tokenType = 'URL';
886
+ this.tokenType = "URL";
856
887
  this.value = val;
857
888
  }
858
889
  toString() {
859
- return 'URL(' + this.value + ')';
890
+ return "URL(" + this.value + ")";
860
891
  }
861
892
  toSource() {
862
893
  return 'url("' + escapeString(this.value) + '")';
863
894
  }
864
895
  }
865
- exports.URLToken = URLToken;
866
896
  class NumberToken extends CSSParserToken {
867
897
  constructor() {
868
898
  super();
869
- this.tokenType = 'NUMBER';
870
- this.type = void 0;
871
- this.repr = void 0;
872
- this.type = 'integer';
873
- this.repr = '';
899
+ this.tokenType = "NUMBER";
900
+ this.type = "integer";
901
+ this.repr = "";
874
902
  }
875
903
  toString() {
876
- if (this.type === 'integer') return 'INT(' + this.value + ')';
877
- return 'NUMBER(' + this.value + ')';
904
+ if (this.type === "integer")
905
+ return "INT(" + this.value + ")";
906
+ return "NUMBER(" + this.value + ")";
878
907
  }
879
908
  toJSON() {
880
909
  const json = super.toJSON();
@@ -887,16 +916,14 @@ class NumberToken extends CSSParserToken {
887
916
  return this.repr;
888
917
  }
889
918
  }
890
- exports.NumberToken = NumberToken;
891
919
  class PercentageToken extends CSSParserToken {
892
920
  constructor() {
893
921
  super();
894
- this.tokenType = 'PERCENTAGE';
895
- this.repr = void 0;
896
- this.repr = '';
922
+ this.tokenType = "PERCENTAGE";
923
+ this.repr = "";
897
924
  }
898
925
  toString() {
899
- return 'PERCENTAGE(' + this.value + ')';
926
+ return "PERCENTAGE(" + this.value + ")";
900
927
  }
901
928
  toJSON() {
902
929
  const json = this.constructor.prototype.constructor.prototype.toJSON.call(this);
@@ -905,23 +932,19 @@ class PercentageToken extends CSSParserToken {
905
932
  return json;
906
933
  }
907
934
  toSource() {
908
- return this.repr + '%';
935
+ return this.repr + "%";
909
936
  }
910
937
  }
911
- exports.PercentageToken = PercentageToken;
912
938
  class DimensionToken extends CSSParserToken {
913
939
  constructor() {
914
940
  super();
915
- this.tokenType = 'DIMENSION';
916
- this.type = void 0;
917
- this.repr = void 0;
918
- this.unit = void 0;
919
- this.type = 'integer';
920
- this.repr = '';
921
- this.unit = '';
941
+ this.tokenType = "DIMENSION";
942
+ this.type = "integer";
943
+ this.repr = "";
944
+ this.unit = "";
922
945
  }
923
946
  toString() {
924
- return 'DIM(' + this.value + ',' + this.unit + ')';
947
+ return "DIM(" + this.value + "," + this.unit + ")";
925
948
  }
926
949
  toJSON() {
927
950
  const json = this.constructor.prototype.constructor.prototype.toJSON.call(this);
@@ -934,46 +957,95 @@ class DimensionToken extends CSSParserToken {
934
957
  toSource() {
935
958
  const source = this.repr;
936
959
  let unit = escapeIdent(this.unit);
937
- if (unit[0].toLowerCase() === 'e' && (unit[1] === '-' || between(unit.charCodeAt(1), 0x30, 0x39))) {
938
- // Unit is ambiguous with scinot
939
- // Remove the leading "e", replace with escape.
940
- unit = '\\65 ' + unit.slice(1, unit.length);
960
+ if (unit[0].toLowerCase() === "e" && (unit[1] === "-" || between(unit.charCodeAt(1), 48, 57))) {
961
+ unit = "\\65 " + unit.slice(1, unit.length);
941
962
  }
942
963
  return source + unit;
943
964
  }
944
965
  }
945
- exports.DimensionToken = DimensionToken;
946
966
  function escapeIdent(string) {
947
- string = '' + string;
948
- let result = '';
967
+ string = "" + string;
968
+ let result = "";
949
969
  const firstcode = string.charCodeAt(0);
950
970
  for (let i = 0; i < string.length; i++) {
951
971
  const code = string.charCodeAt(i);
952
- if (code === 0x0) throw new InvalidCharacterError('Invalid character: the input contains U+0000.');
953
- if (between(code, 0x1, 0x1f) || code === 0x7f || i === 0 && between(code, 0x30, 0x39) || i === 1 && between(code, 0x30, 0x39) && firstcode === 0x2d) result += '\\' + code.toString(16) + ' ';else if (code >= 0x80 || code === 0x2d || code === 0x5f || between(code, 0x30, 0x39) || between(code, 0x41, 0x5a) || between(code, 0x61, 0x7a)) result += string[i];else result += '\\' + string[i];
972
+ if (code === 0)
973
+ throw new InvalidCharacterError("Invalid character: the input contains U+0000.");
974
+ if (between(code, 1, 31) || code === 127 || i === 0 && between(code, 48, 57) || i === 1 && between(code, 48, 57) && firstcode === 45)
975
+ result += "\\" + code.toString(16) + " ";
976
+ else if (code >= 128 || code === 45 || code === 95 || between(code, 48, 57) || between(code, 65, 90) || between(code, 97, 122))
977
+ result += string[i];
978
+ else
979
+ result += "\\" + string[i];
954
980
  }
955
981
  return result;
956
982
  }
957
983
  function escapeHash(string) {
958
- // Escapes the contents of "unrestricted"-type hash tokens.
959
- // Won't preserve the ID-ness of "id"-type hash tokens;
960
- // use escapeIdent() for that.
961
- string = '' + string;
962
- let result = '';
984
+ string = "" + string;
985
+ let result = "";
963
986
  for (let i = 0; i < string.length; i++) {
964
987
  const code = string.charCodeAt(i);
965
- if (code === 0x0) throw new InvalidCharacterError('Invalid character: the input contains U+0000.');
966
- if (code >= 0x80 || code === 0x2d || code === 0x5f || between(code, 0x30, 0x39) || between(code, 0x41, 0x5a) || between(code, 0x61, 0x7a)) result += string[i];else result += '\\' + code.toString(16) + ' ';
988
+ if (code === 0)
989
+ throw new InvalidCharacterError("Invalid character: the input contains U+0000.");
990
+ if (code >= 128 || code === 45 || code === 95 || between(code, 48, 57) || between(code, 65, 90) || between(code, 97, 122))
991
+ result += string[i];
992
+ else
993
+ result += "\\" + code.toString(16) + " ";
967
994
  }
968
995
  return result;
969
996
  }
970
997
  function escapeString(string) {
971
- string = '' + string;
972
- let result = '';
998
+ string = "" + string;
999
+ let result = "";
973
1000
  for (let i = 0; i < string.length; i++) {
974
1001
  const code = string.charCodeAt(i);
975
- if (code === 0x0) throw new InvalidCharacterError('Invalid character: the input contains U+0000.');
976
- if (between(code, 0x1, 0x1f) || code === 0x7f) result += '\\' + code.toString(16) + ' ';else if (code === 0x22 || code === 0x5c) result += '\\' + string[i];else result += string[i];
1002
+ if (code === 0)
1003
+ throw new InvalidCharacterError("Invalid character: the input contains U+0000.");
1004
+ if (between(code, 1, 31) || code === 127)
1005
+ result += "\\" + code.toString(16) + " ";
1006
+ else if (code === 34 || code === 92)
1007
+ result += "\\" + string[i];
1008
+ else
1009
+ result += string[i];
977
1010
  }
978
1011
  return result;
979
- }
1012
+ }
1013
+ // Annotate the CommonJS export names for ESM import in node:
1014
+ 0 && (module.exports = {
1015
+ AtKeywordToken,
1016
+ BadStringToken,
1017
+ BadURLToken,
1018
+ CDCToken,
1019
+ CDOToken,
1020
+ CSSParserToken,
1021
+ CloseCurlyToken,
1022
+ CloseParenToken,
1023
+ CloseSquareToken,
1024
+ ColonToken,
1025
+ ColumnToken,
1026
+ CommaToken,
1027
+ DashMatchToken,
1028
+ DelimToken,
1029
+ DimensionToken,
1030
+ EOFToken,
1031
+ FunctionToken,
1032
+ GroupingToken,
1033
+ HashToken,
1034
+ IdentToken,
1035
+ IncludeMatchToken,
1036
+ InvalidCharacterError,
1037
+ NumberToken,
1038
+ OpenCurlyToken,
1039
+ OpenParenToken,
1040
+ OpenSquareToken,
1041
+ PercentageToken,
1042
+ PrefixMatchToken,
1043
+ SemicolonToken,
1044
+ StringToken,
1045
+ StringValuedToken,
1046
+ SubstringMatchToken,
1047
+ SuffixMatchToken,
1048
+ URLToken,
1049
+ WhitespaceToken,
1050
+ tokenize
1051
+ });