cypress 10.3.0 → 10.5.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 (72) hide show
  1. package/angular/CHANGELOG.md +55 -0
  2. package/angular/README.md +154 -0
  3. package/angular/dist/index.d.ts +1 -0
  4. package/angular/dist/index.js +263 -0
  5. package/angular/dist/mount.d.ts +111 -0
  6. package/angular/package.json +70 -0
  7. package/lib/exec/open.js +7 -2
  8. package/lib/exec/spawn.js +7 -2
  9. package/mount-utils/CHANGELOG.md +7 -1
  10. package/mount-utils/README.md +7 -0
  11. package/mount-utils/dist/index.js +8 -1
  12. package/mount-utils/package.json +1 -0
  13. package/package.json +26 -10
  14. package/react/CHANGELOG.md +13 -19
  15. package/react/README.md +28 -323
  16. package/react/dist/createMount.d.ts +28 -0
  17. package/react/dist/cypress-react.cjs.js +643 -99
  18. package/react/dist/cypress-react.esm-bundler.js +640 -100
  19. package/react/dist/getDisplayName.d.ts +1 -1
  20. package/react/dist/index.d.ts +2 -0
  21. package/react/dist/mount.d.ts +5 -141
  22. package/react/dist/types.d.ts +44 -0
  23. package/react/package.json +3 -5
  24. package/react18/CHANGELOG.md +6 -0
  25. package/react18/dist/cypress-react.cjs.js +633 -0
  26. package/react18/dist/cypress-react.esm-bundler.js +605 -0
  27. package/react18/dist/index.d.ts +5 -0
  28. package/react18/package.json +59 -0
  29. package/types/cypress.d.ts +24 -3
  30. package/types/index.d.ts +1 -1
  31. package/types/{net-stubbing.ts → net-stubbing.d.ts} +0 -0
  32. package/vue/CHANGELOG.md +16 -17
  33. package/vue/README.md +17 -607
  34. package/vue/dist/@vue/test-utils/baseWrapper.d.ts +63 -0
  35. package/vue/dist/@vue/test-utils/components/RouterLinkStub.d.ts +21 -0
  36. package/vue/dist/@vue/test-utils/config.d.ts +30 -0
  37. package/vue/dist/@vue/test-utils/constants/dom-events.d.ts +900 -0
  38. package/vue/dist/@vue/test-utils/createDomEvent.d.ts +9 -0
  39. package/vue/dist/@vue/test-utils/domWrapper.d.ts +18 -0
  40. package/vue/dist/@vue/test-utils/emit.d.ts +5 -0
  41. package/vue/dist/@vue/test-utils/errorWrapper.d.ts +1 -0
  42. package/vue/dist/@vue/test-utils/index.d.ts +11 -0
  43. package/vue/dist/@vue/test-utils/interfaces/wrapperLike.d.ts +56 -0
  44. package/vue/dist/@vue/test-utils/mount.d.ts +35 -0
  45. package/vue/dist/@vue/test-utils/stubs.d.ts +22 -0
  46. package/vue/dist/@vue/test-utils/types.d.ts +125 -0
  47. package/vue/dist/@vue/test-utils/utils/autoUnmount.d.ts +5 -0
  48. package/vue/dist/@vue/test-utils/utils/compileSlots.d.ts +2 -0
  49. package/vue/dist/@vue/test-utils/utils/componentName.d.ts +4 -0
  50. package/vue/dist/@vue/test-utils/utils/find.d.ts +10 -0
  51. package/vue/dist/@vue/test-utils/utils/flushPromises.d.ts +1 -0
  52. package/vue/dist/@vue/test-utils/utils/getRootNodes.d.ts +2 -0
  53. package/vue/dist/@vue/test-utils/utils/isElement.d.ts +1 -0
  54. package/vue/dist/@vue/test-utils/utils/isElementVisible.d.ts +6 -0
  55. package/vue/dist/@vue/test-utils/utils/matchName.d.ts +1 -0
  56. package/vue/dist/@vue/test-utils/utils/stringifyNode.d.ts +1 -0
  57. package/vue/dist/@vue/test-utils/utils/vueCompatSupport.d.ts +8 -0
  58. package/vue/dist/@vue/test-utils/utils/vueShared.d.ts +3 -0
  59. package/vue/dist/@vue/test-utils/utils.d.ts +13 -0
  60. package/vue/dist/@vue/test-utils/vueWrapper.d.ts +35 -0
  61. package/vue/dist/@vue/test-utils/wrapperFactory.d.ts +14 -0
  62. package/vue/dist/cypress-vue.cjs.js +5585 -5211
  63. package/vue/dist/cypress-vue.esm-bundler.js +5586 -5213
  64. package/vue/dist/index.d.ts +35 -3
  65. package/vue/package.json +11 -8
  66. package/vue2/CHANGELOG.md +7 -0
  67. package/vue2/README.md +11 -627
  68. package/vue2/dist/cypress-vue2.browser.js +267 -261
  69. package/vue2/dist/cypress-vue2.cjs.js +266 -260
  70. package/vue2/dist/cypress-vue2.esm-bundler.js +264 -258
  71. package/vue2/package.json +1 -1
  72. package/react/dist/cypress-react.browser.js +0 -497
@@ -0,0 +1,633 @@
1
+
2
+ /**
3
+ * @cypress/react18 v0.0.0-development
4
+ * (c) 2022 Cypress.io
5
+ * Released under the MIT License
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var ReactDOM = require('react-dom/client');
13
+ var React = require('react');
14
+ require('react-dom');
15
+
16
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
+
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n["default"] = e;
33
+ return Object.freeze(n);
34
+ }
35
+
36
+ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
37
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
38
+
39
+ /******************************************************************************
40
+ Copyright (c) Microsoft Corporation.
41
+
42
+ Permission to use, copy, modify, and/or distribute this software for any
43
+ purpose with or without fee is hereby granted.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
46
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
47
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
48
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
49
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
50
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
51
+ PERFORMANCE OF THIS SOFTWARE.
52
+ ***************************************************************************** */
53
+
54
+ var __assign = function() {
55
+ __assign = Object.assign || function __assign(t) {
56
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
57
+ s = arguments[i];
58
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
59
+ }
60
+ return t;
61
+ };
62
+ return __assign.apply(this, arguments);
63
+ };
64
+
65
+ var cachedDisplayNames = new WeakMap();
66
+ /**
67
+ * Gets the display name of the component when possible.
68
+ * @param type {JSX} The type object returned from creating the react element.
69
+ * @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
70
+ * @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
71
+ */
72
+ function getDisplayName(type, fallbackName) {
73
+ if (fallbackName === void 0) { fallbackName = 'Unknown'; }
74
+ var nameFromCache = cachedDisplayNames.get(type);
75
+ if (nameFromCache != null) {
76
+ return nameFromCache;
77
+ }
78
+ var displayName = null;
79
+ // The displayName property is not guaranteed to be a string.
80
+ // It's only safe to use for our purposes if it's a string.
81
+ // github.com/facebook/react-devtools/issues/803
82
+ if (typeof type.displayName === 'string') {
83
+ displayName = type.displayName;
84
+ }
85
+ if (!displayName) {
86
+ displayName = type.name || fallbackName;
87
+ }
88
+ // Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
89
+ // We need displayName with module name for error reports but it clutters the DevTools.
90
+ var match = displayName.match(/^(.*) \[from (.*)\]$/);
91
+ if (match) {
92
+ var componentName = match[1];
93
+ var moduleName = match[2];
94
+ if (componentName && moduleName) {
95
+ if (moduleName === componentName ||
96
+ moduleName.startsWith(componentName + ".")) {
97
+ displayName = componentName;
98
+ }
99
+ }
100
+ }
101
+ try {
102
+ cachedDisplayNames.set(type, displayName);
103
+ }
104
+ catch (e) {
105
+ // do nothing
106
+ }
107
+ return displayName;
108
+ }
109
+
110
+ const ROOT_SELECTOR = '[data-cy-root]';
111
+ const getContainerEl = () => {
112
+ const el = document.querySelector(ROOT_SELECTOR);
113
+ if (el) {
114
+ return el;
115
+ }
116
+ throw Error(`No element found that matches selector ${ROOT_SELECTOR}. Please add a root element with data-cy-root attribute to your "component-index.html" file so that Cypress can attach your component to the DOM.`);
117
+ };
118
+ /**
119
+ * Remove any style or extra link elements from the iframe placeholder
120
+ * left from any previous test
121
+ *
122
+ */
123
+ function cleanupStyles() {
124
+ const styles = document.body.querySelectorAll('[data-cy=injected-style-tag]');
125
+ styles.forEach((styleElement) => {
126
+ if (styleElement.parentElement) {
127
+ styleElement.parentElement.removeChild(styleElement);
128
+ }
129
+ });
130
+ const links = document.body.querySelectorAll('[data-cy=injected-stylesheet]');
131
+ links.forEach((link) => {
132
+ if (link.parentElement) {
133
+ link.parentElement.removeChild(link);
134
+ }
135
+ });
136
+ }
137
+ /**
138
+ * Insert links to external style resources.
139
+ */
140
+ function insertStylesheets(stylesheets, document, el) {
141
+ stylesheets.forEach((href) => {
142
+ const link = document.createElement('link');
143
+ link.type = 'text/css';
144
+ link.rel = 'stylesheet';
145
+ link.href = href;
146
+ link.dataset.cy = 'injected-stylesheet';
147
+ document.body.insertBefore(link, el);
148
+ });
149
+ }
150
+ /**
151
+ * Inserts a single stylesheet element
152
+ */
153
+ function insertStyles(styles, document, el) {
154
+ styles.forEach((style) => {
155
+ const styleElement = document.createElement('style');
156
+ styleElement.dataset.cy = 'injected-style-tag';
157
+ styleElement.appendChild(document.createTextNode(style));
158
+ document.body.insertBefore(styleElement, el);
159
+ });
160
+ }
161
+ function insertSingleCssFile(cssFilename, document, el, log) {
162
+ return cy.readFile(cssFilename, { log }).then((css) => {
163
+ const style = document.createElement('style');
164
+ style.appendChild(document.createTextNode(css));
165
+ document.body.insertBefore(style, el);
166
+ });
167
+ }
168
+ /**
169
+ * Reads the given CSS file from local file system
170
+ * and adds the loaded style text as an element.
171
+ */
172
+ function insertLocalCssFiles(cssFilenames, document, el, log) {
173
+ return Cypress.Promise.mapSeries(cssFilenames, (cssFilename) => {
174
+ return insertSingleCssFile(cssFilename, document, el, log);
175
+ });
176
+ }
177
+ /**
178
+ * Injects custom style text or CSS file or 3rd party style resources
179
+ * into the given document.
180
+ */
181
+ const injectStylesBeforeElement = (options, document, el) => {
182
+ if (!el)
183
+ return;
184
+ // first insert all stylesheets as Link elements
185
+ let stylesheets = [];
186
+ if (typeof options.stylesheet === 'string') {
187
+ stylesheets.push(options.stylesheet);
188
+ }
189
+ else if (Array.isArray(options.stylesheet)) {
190
+ stylesheets = stylesheets.concat(options.stylesheet);
191
+ }
192
+ if (typeof options.stylesheets === 'string') {
193
+ options.stylesheets = [options.stylesheets];
194
+ }
195
+ if (options.stylesheets) {
196
+ stylesheets = stylesheets.concat(options.stylesheets);
197
+ }
198
+ insertStylesheets(stylesheets, document, el);
199
+ // insert any styles as <style>...</style> elements
200
+ let styles = [];
201
+ if (typeof options.style === 'string') {
202
+ styles.push(options.style);
203
+ }
204
+ else if (Array.isArray(options.style)) {
205
+ styles = styles.concat(options.style);
206
+ }
207
+ if (typeof options.styles === 'string') {
208
+ styles.push(options.styles);
209
+ }
210
+ else if (Array.isArray(options.styles)) {
211
+ styles = styles.concat(options.styles);
212
+ }
213
+ insertStyles(styles, document, el);
214
+ // now load any css files by path and add their content
215
+ // as <style>...</style> elements
216
+ let cssFiles = [];
217
+ if (typeof options.cssFile === 'string') {
218
+ cssFiles.push(options.cssFile);
219
+ }
220
+ else if (Array.isArray(options.cssFile)) {
221
+ cssFiles = cssFiles.concat(options.cssFile);
222
+ }
223
+ if (typeof options.cssFiles === 'string') {
224
+ cssFiles.push(options.cssFiles);
225
+ }
226
+ else if (Array.isArray(options.cssFiles)) {
227
+ cssFiles = cssFiles.concat(options.cssFiles);
228
+ }
229
+ return insertLocalCssFiles(cssFiles, document, el, options.log);
230
+ };
231
+ function setupHooks(optionalCallback) {
232
+ // Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
233
+ // file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
234
+ // testing so we early return.
235
+ // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
236
+ if (Cypress.testingType !== 'component') {
237
+ return;
238
+ }
239
+ // When running component specs, we cannot allow "cy.visit"
240
+ // because it will wipe out our preparation work, and does not make much sense
241
+ // thus we overwrite "cy.visit" to throw an error
242
+ Cypress.Commands.overwrite('visit', () => {
243
+ throw new Error('cy.visit from a component spec is not allowed');
244
+ });
245
+ // @ts-ignore
246
+ Cypress.on('test:before:run', () => {
247
+ optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
248
+ cleanupStyles();
249
+ });
250
+ }
251
+
252
+ /**
253
+ * Inject custom style text or CSS file or 3rd party style resources
254
+ */
255
+ var injectStyles = function (options) {
256
+ return function () {
257
+ var el = getContainerEl();
258
+ return injectStylesBeforeElement(options, document, el);
259
+ };
260
+ };
261
+ var mountCleanup;
262
+ /**
263
+ * Create an `mount` function. Performs all the non-React-version specific
264
+ * behavior related to mounting. The React-version-specific code
265
+ * is injected. This helps us to maintain a consistent public API
266
+ * and handle breaking changes in React's rendering API.
267
+ *
268
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
269
+ * or people writing adapters for third-party, custom adapters.
270
+ */
271
+ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
272
+ if (options === void 0) { options = {}; }
273
+ if (!internalMountOptions) {
274
+ throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
275
+ }
276
+ mountCleanup = internalMountOptions.cleanup;
277
+ // Get the display name property via the component constructor
278
+ // @ts-ignore FIXME
279
+ var componentName = getDisplayName(jsx.type, options.alias);
280
+ var displayName = options.alias || componentName;
281
+ var jsxComponentName = "<" + componentName + " ... />";
282
+ var message = options.alias
283
+ ? jsxComponentName + " as \"" + options.alias + "\""
284
+ : jsxComponentName;
285
+ return cy
286
+ .then(injectStyles(options))
287
+ .then(function () {
288
+ var _a, _b, _c;
289
+ var reactDomToUse = internalMountOptions.reactDom;
290
+ var el = getContainerEl();
291
+ if (!el) {
292
+ throw new Error([
293
+ "[@cypress/react] \uD83D\uDD25 Hmm, cannot find root element to mount the component. Searched for " + ROOT_SELECTOR,
294
+ ].join(' '));
295
+ }
296
+ var key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
297
+ // @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
298
+ (((_c = (_b = (_a = Cypress === null || Cypress === void 0 ? void 0 : Cypress.mocha) === null || _a === void 0 ? void 0 : _a.getRunner()) === null || _b === void 0 ? void 0 : _b.test) === null || _c === void 0 ? void 0 : _c.title) || '') + Math.random();
299
+ var props = {
300
+ key: key,
301
+ };
302
+ var reactComponent = React__namespace.createElement(options.strict ? React__namespace.StrictMode : React__namespace.Fragment, props, jsx);
303
+ // since we always surround the component with a fragment
304
+ // let's get back the original component
305
+ var userComponent = reactComponent.props.children;
306
+ internalMountOptions.render(reactComponent, el, reactDomToUse);
307
+ if (options.log !== false) {
308
+ Cypress.log({
309
+ name: type,
310
+ type: 'parent',
311
+ message: [message],
312
+ // @ts-ignore
313
+ $el: el.children.item(0),
314
+ consoleProps: function () {
315
+ return {
316
+ // @ts-ignore protect the use of jsx functional components use ReactNode
317
+ props: jsx.props,
318
+ description: type === 'mount' ? 'Mounts React component' : 'Rerenders mounted React component',
319
+ home: 'https://github.com/cypress-io/cypress',
320
+ };
321
+ },
322
+ }).snapshot('mounted').end();
323
+ }
324
+ return (
325
+ // Separate alias and returned value. Alias returns the component only, and the thenable returns the additional functions
326
+ cy.wrap(userComponent, { log: false })
327
+ .as(displayName)
328
+ .then(function () {
329
+ return cy.wrap({
330
+ component: userComponent,
331
+ rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
332
+ unmount: internalMountOptions.unmount,
333
+ }, { log: false });
334
+ })
335
+ // by waiting, we delaying test execution for the next tick of event loop
336
+ // and letting hooks and component lifecycle methods to execute mount
337
+ // https://github.com/bahmutov/cypress-react-unit-test/issues/200
338
+ .wait(0, { log: false }));
339
+ // Bluebird types are terrible. I don't think the return type can be carried without this cast
340
+ });
341
+ };
342
+ /**
343
+ * Create an `unmount` function. Performs all the non-React-version specific
344
+ * behavior related to unmounting.
345
+ *
346
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
347
+ * or people writing adapters for third-party, custom adapters.
348
+ */
349
+ var makeUnmountFn = function (options) {
350
+ return cy.then(function () {
351
+ var _a;
352
+ var wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
353
+ if (wasUnmounted && options.log) {
354
+ Cypress.log({
355
+ name: 'unmount',
356
+ type: 'parent',
357
+ message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
358
+ consoleProps: function () {
359
+ return {
360
+ description: 'Unmounts React component',
361
+ parent: getContainerEl().parentNode,
362
+ home: 'https://github.com/cypress-io/cypress',
363
+ };
364
+ },
365
+ });
366
+ }
367
+ });
368
+ };
369
+ // Cleanup before each run
370
+ // NOTE: we cannot use unmount here because
371
+ // we are not in the context of a test
372
+ var preMountCleanup = function () {
373
+ mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
374
+ };
375
+ // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
376
+ // by creating an explicit function/import that the user can register in their 'component.js' support file,
377
+ // such as:
378
+ // import 'cypress/<my-framework>/support'
379
+ // or
380
+ // import { registerCT } from 'cypress/<my-framework>'
381
+ // registerCT()
382
+ // Note: This would be a breaking change
383
+ // it is required to unmount component in beforeEach hook in order to provide a clean state inside test
384
+ // because `mount` can be called after some preparation that can side effect unmount
385
+ // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
386
+ setupHooks(preMountCleanup);
387
+
388
+ const debug = (
389
+ typeof process === 'object' &&
390
+ process.env &&
391
+ process.env.NODE_DEBUG &&
392
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
393
+ ) ? (...args) => console.error('SEMVER', ...args)
394
+ : () => {};
395
+
396
+ var debug_1 = debug;
397
+
398
+ // Note: this is the semver.org version of the spec that it implements
399
+ // Not necessarily the package version of this code.
400
+ const SEMVER_SPEC_VERSION = '2.0.0';
401
+
402
+ const MAX_LENGTH$1 = 256;
403
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
404
+ /* istanbul ignore next */ 9007199254740991;
405
+
406
+ // Max safe segment length for coercion.
407
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
408
+
409
+ var constants = {
410
+ SEMVER_SPEC_VERSION,
411
+ MAX_LENGTH: MAX_LENGTH$1,
412
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
413
+ MAX_SAFE_COMPONENT_LENGTH,
414
+ };
415
+
416
+ function createCommonjsModule(fn) {
417
+ var module = { exports: {} };
418
+ return fn(module, module.exports), module.exports;
419
+ }
420
+
421
+ createCommonjsModule(function (module, exports) {
422
+ const { MAX_SAFE_COMPONENT_LENGTH } = constants;
423
+
424
+ exports = module.exports = {};
425
+
426
+ // The actual regexps go on exports.re
427
+ const re = exports.re = [];
428
+ const src = exports.src = [];
429
+ const t = exports.t = {};
430
+ let R = 0;
431
+
432
+ const createToken = (name, value, isGlobal) => {
433
+ const index = R++;
434
+ debug_1(name, index, value);
435
+ t[name] = index;
436
+ src[index] = value;
437
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
438
+ };
439
+
440
+ // The following Regular Expressions can be used for tokenizing,
441
+ // validating, and parsing SemVer version strings.
442
+
443
+ // ## Numeric Identifier
444
+ // A single `0`, or a non-zero digit followed by zero or more digits.
445
+
446
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
447
+ createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
448
+
449
+ // ## Non-numeric Identifier
450
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
451
+ // more letters, digits, or hyphens.
452
+
453
+ createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
454
+
455
+ // ## Main Version
456
+ // Three dot-separated numeric identifiers.
457
+
458
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
459
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
460
+ `(${src[t.NUMERICIDENTIFIER]})`);
461
+
462
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
463
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
464
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
465
+
466
+ // ## Pre-release Version Identifier
467
+ // A numeric identifier, or a non-numeric identifier.
468
+
469
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
470
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
471
+
472
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
473
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
474
+
475
+ // ## Pre-release Version
476
+ // Hyphen, followed by one or more dot-separated pre-release version
477
+ // identifiers.
478
+
479
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
480
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
481
+
482
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
483
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
484
+
485
+ // ## Build Metadata Identifier
486
+ // Any combination of digits, letters, or hyphens.
487
+
488
+ createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
489
+
490
+ // ## Build Metadata
491
+ // Plus sign, followed by one or more period-separated build metadata
492
+ // identifiers.
493
+
494
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
495
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
496
+
497
+ // ## Full Version String
498
+ // A main version, followed optionally by a pre-release version and
499
+ // build metadata.
500
+
501
+ // Note that the only major, minor, patch, and pre-release sections of
502
+ // the version string are capturing groups. The build metadata is not a
503
+ // capturing group, because it should not ever be used in version
504
+ // comparison.
505
+
506
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
507
+ }${src[t.PRERELEASE]}?${
508
+ src[t.BUILD]}?`);
509
+
510
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
511
+
512
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
513
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
514
+ // common in the npm registry.
515
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
516
+ }${src[t.PRERELEASELOOSE]}?${
517
+ src[t.BUILD]}?`);
518
+
519
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
520
+
521
+ createToken('GTLT', '((?:<|>)?=?)');
522
+
523
+ // Something like "2.*" or "1.2.x".
524
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
525
+ // Only the first item is strictly required.
526
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
527
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
528
+
529
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
530
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
531
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
532
+ `(?:${src[t.PRERELEASE]})?${
533
+ src[t.BUILD]}?` +
534
+ `)?)?`);
535
+
536
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
537
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
538
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
539
+ `(?:${src[t.PRERELEASELOOSE]})?${
540
+ src[t.BUILD]}?` +
541
+ `)?)?`);
542
+
543
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
544
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
545
+
546
+ // Coercion.
547
+ // Extract anything that could conceivably be a part of a valid semver
548
+ createToken('COERCE', `${'(^|[^\\d])' +
549
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
550
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
551
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
552
+ `(?:$|[^\\d])`);
553
+ createToken('COERCERTL', src[t.COERCE], true);
554
+
555
+ // Tilde ranges.
556
+ // Meaning is "reasonably at or greater than"
557
+ createToken('LONETILDE', '(?:~>?)');
558
+
559
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
560
+ exports.tildeTrimReplace = '$1~';
561
+
562
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
563
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
564
+
565
+ // Caret ranges.
566
+ // Meaning is "at least and backwards compatible with"
567
+ createToken('LONECARET', '(?:\\^)');
568
+
569
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
570
+ exports.caretTrimReplace = '$1^';
571
+
572
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
573
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
574
+
575
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
576
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
577
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
578
+
579
+ // An expression to strip any whitespace between the gtlt and the thing
580
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
581
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
582
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
583
+ exports.comparatorTrimReplace = '$1$2$3';
584
+
585
+ // Something like `1.2.3 - 1.2.4`
586
+ // Note that these all use the loose form, because they'll be
587
+ // checked against either the strict or loose comparator form
588
+ // later.
589
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
590
+ `\\s+-\\s+` +
591
+ `(${src[t.XRANGEPLAIN]})` +
592
+ `\\s*$`);
593
+
594
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
595
+ `\\s+-\\s+` +
596
+ `(${src[t.XRANGEPLAINLOOSE]})` +
597
+ `\\s*$`);
598
+
599
+ // Star ranges basically just allow anything at all.
600
+ createToken('STAR', '(<|>)?=?\\s*\\*');
601
+ // >=0.0.0 is like a star
602
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
603
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
604
+ });
605
+
606
+ var root;
607
+ var cleanup = function () {
608
+ if (root) {
609
+ root.unmount();
610
+ return true;
611
+ }
612
+ return false;
613
+ };
614
+ function mount(jsx, options, rerenderKey) {
615
+ if (options === void 0) { options = {}; }
616
+ var internalOptions = {
617
+ reactDom: ReactDOM__default["default"],
618
+ render: function (reactComponent, el) {
619
+ root = ReactDOM__default["default"].createRoot(el);
620
+ return root.render(reactComponent);
621
+ },
622
+ unmount: unmount,
623
+ cleanup: cleanup,
624
+ };
625
+ return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM__default["default"] }, options), rerenderKey, internalOptions);
626
+ }
627
+ function unmount(options) {
628
+ if (options === void 0) { options = { log: true }; }
629
+ return makeUnmountFn(options);
630
+ }
631
+
632
+ exports.mount = mount;
633
+ exports.unmount = unmount;