cypress 10.4.0 → 10.7.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.
- package/angular/CHANGELOG.md +86 -0
- package/angular/README.md +85 -0
- package/angular/dist/index.d.ts +1 -0
- package/angular/dist/index.js +265 -0
- package/angular/dist/mount.d.ts +112 -0
- package/angular/package.json +68 -0
- package/lib/tasks/download.js +4 -3
- package/mount-utils/CHANGELOG.md +7 -0
- package/mount-utils/package.json +5 -1
- package/package.json +16 -4
- package/react/CHANGELOG.md +20 -0
- package/react/dist/createMount.d.ts +7 -6
- package/react/dist/cypress-react.cjs.js +653 -140
- package/react/dist/cypress-react.esm-bundler.js +640 -127
- package/react/dist/mount.d.ts +2 -1
- package/react/dist/mountHook.d.ts +1 -0
- package/react/dist/types.d.ts +2 -7
- package/react/package.json +4 -6
- package/react18/CHANGELOG.md +13 -0
- package/react18/dist/cypress-react.cjs.js +300 -118
- package/react18/dist/cypress-react.esm-bundler.js +286 -104
- package/react18/dist/index.d.ts +2 -1
- package/react18/package.json +2 -2
- package/svelte/CHANGELOG.md +0 -0
- package/svelte/README.md +83 -0
- package/svelte/dist/cypress-svelte.cjs.js +213 -0
- package/svelte/dist/cypress-svelte.esm-bundler.js +209 -0
- package/svelte/dist/index.d.ts +1 -0
- package/svelte/dist/mount.d.ts +30 -0
- package/svelte/package.json +43 -0
- package/types/cypress-type-helpers.d.ts +3 -1
- package/types/cypress.d.ts +61 -5
- package/vue/CHANGELOG.md +14 -0
- package/vue/dist/cypress-vue.cjs.js +30 -38
- package/vue/dist/cypress-vue.esm-bundler.js +30 -38
- package/vue/dist/index.d.ts +1 -0
- package/vue/package.json +2 -8
- package/vue2/CHANGELOG.md +7 -0
- package/vue2/dist/cypress-vue2.cjs.js +53 -84
- package/vue2/dist/cypress-vue2.esm-bundler.js +53 -84
- package/vue2/dist/index.d.ts +1 -0
- package/vue2/package.json +2 -5
- package/vue2/dist/cypress-vue2.browser.js +0 -20197
package/react/dist/mount.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
/// <reference types="cypress" />
|
2
|
+
/// <reference types="cypress" />
|
2
3
|
import React from 'react';
|
3
4
|
import type { MountOptions } from './types';
|
4
5
|
export declare function mount(jsx: React.ReactNode, options?: MountOptions, rerenderKey?: string): Cypress.Chainable<import("./types").MountReturn>;
|
5
6
|
export declare function unmount(options?: {
|
6
7
|
log: boolean;
|
7
|
-
}): Cypress.Chainable<
|
8
|
+
}): Cypress.Chainable<undefined>;
|
package/react/dist/types.d.ts
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
/// <reference types="cypress" />
|
2
|
+
/// <reference types="cypress" />
|
2
3
|
import type React from 'react';
|
3
4
|
import type { StyleOptions } from '@cypress/mount-utils';
|
4
5
|
export interface UnmountArgs {
|
5
6
|
log: boolean;
|
6
7
|
boundComponentMessage?: string;
|
7
8
|
}
|
8
|
-
export interface InternalUnmountOptionsReact {
|
9
|
-
unmount: (el: HTMLElement) => boolean;
|
10
|
-
}
|
11
|
-
export interface InternalUnmountOptionsReact18 {
|
12
|
-
unmount: () => boolean;
|
13
|
-
}
|
14
|
-
export declare type InternalUnmountOptions = InternalUnmountOptionsReact | InternalUnmountOptionsReact18;
|
15
9
|
export declare type MountOptions = Partial<StyleOptions & MountReactComponentOptions>;
|
16
10
|
export interface MountReactComponentOptions {
|
17
11
|
alias: string;
|
@@ -31,6 +25,7 @@ export interface InternalMountOptions {
|
|
31
25
|
reactDom: typeof import('react-dom');
|
32
26
|
render: (reactComponent: ReturnType<typeof React.createElement>, el: HTMLElement, reactDomToUse: typeof import('react-dom')) => void;
|
33
27
|
unmount: (options: UnmountArgs) => void;
|
28
|
+
cleanup: () => boolean;
|
34
29
|
}
|
35
30
|
export interface MountReturn {
|
36
31
|
/**
|
package/react/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"description": "Test React components using Cypress",
|
5
5
|
"main": "dist/cypress-react.cjs.js",
|
6
6
|
"scripts": {
|
7
|
-
"build": "rimraf dist && rollup -c rollup.config.
|
7
|
+
"build": "rimraf dist && rollup -c rollup.config.mjs",
|
8
8
|
"postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
|
9
9
|
"build-prod": "yarn build",
|
10
10
|
"cy:open": "node ../../scripts/cypress.js open --component",
|
@@ -16,8 +16,7 @@
|
|
16
16
|
},
|
17
17
|
"devDependencies": {
|
18
18
|
"@cypress/mount-utils": "0.0.0-development",
|
19
|
-
"@
|
20
|
-
"@rollup/plugin-node-resolve": "^11.1.1",
|
19
|
+
"@types/semver": "7.3.9",
|
21
20
|
"@vitejs/plugin-react": "1.3.1",
|
22
21
|
"axios": "0.21.2",
|
23
22
|
"cypress": "0.0.0-development",
|
@@ -26,9 +25,8 @@
|
|
26
25
|
"react-dom": "16.8.6",
|
27
26
|
"react-router": "6.0.0-alpha.1",
|
28
27
|
"react-router-dom": "6.0.0-alpha.1",
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"typescript": "^4.2.3",
|
28
|
+
"semver": "^7.3.2",
|
29
|
+
"typescript": "^4.7.4",
|
32
30
|
"vite": "3.0.3",
|
33
31
|
"vite-plugin-require-transform": "1.0.3"
|
34
32
|
},
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# [@cypress/react18-v1.0.1](https://github.com/cypress-io/cypress/compare/@cypress/react18-v1.0.0...@cypress/react18-v1.0.1) (2022-08-15)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **react18:** unmount component with react18 API ([#23204](https://github.com/cypress-io/cypress/issues/23204)) ([eab950b](https://github.com/cypress-io/cypress/commit/eab950bec013f9caf5836e3fa58670fde25e2684))
|
7
|
+
|
8
|
+
# @cypress/react18-v1.0.0 (2022-08-11)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* React 18 support ([#22876](https://github.com/cypress-io/cypress/issues/22876)) ([f0d3a48](https://github.com/cypress-io/cypress/commit/f0d3a4867907bf6e60468510daa883ccc8dcfb63))
|
@@ -16,66 +16,39 @@ require('react-dom');
|
|
16
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
17
17
|
|
18
18
|
function _interopNamespace(e) {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
});
|
29
|
-
}
|
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]; }
|
30
28
|
});
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
}
|
30
|
+
});
|
31
|
+
}
|
32
|
+
n["default"] = e;
|
33
|
+
return Object.freeze(n);
|
34
34
|
}
|
35
35
|
|
36
36
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
37
37
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
38
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();
|
39
|
+
const cachedDisplayNames = new WeakMap();
|
66
40
|
/**
|
67
41
|
* Gets the display name of the component when possible.
|
68
42
|
* @param type {JSX} The type object returned from creating the react element.
|
69
43
|
* @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
|
70
44
|
* @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
|
71
45
|
*/
|
72
|
-
function getDisplayName(type, fallbackName) {
|
73
|
-
|
74
|
-
var nameFromCache = cachedDisplayNames.get(type);
|
46
|
+
function getDisplayName(type, fallbackName = 'Unknown') {
|
47
|
+
const nameFromCache = cachedDisplayNames.get(type);
|
75
48
|
if (nameFromCache != null) {
|
76
49
|
return nameFromCache;
|
77
50
|
}
|
78
|
-
|
51
|
+
let displayName = null;
|
79
52
|
// The displayName property is not guaranteed to be a string.
|
80
53
|
// It's only safe to use for our purposes if it's a string.
|
81
54
|
// github.com/facebook/react-devtools/issues/803
|
@@ -87,13 +60,13 @@ function getDisplayName(type, fallbackName) {
|
|
87
60
|
}
|
88
61
|
// Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
|
89
62
|
// We need displayName with module name for error reports but it clutters the DevTools.
|
90
|
-
|
63
|
+
const match = displayName.match(/^(.*) \[from (.*)\]$/);
|
91
64
|
if (match) {
|
92
|
-
|
93
|
-
|
65
|
+
const componentName = match[1];
|
66
|
+
const moduleName = match[2];
|
94
67
|
if (componentName && moduleName) {
|
95
68
|
if (moduleName === componentName ||
|
96
|
-
moduleName.startsWith(componentName
|
69
|
+
moduleName.startsWith(`${componentName}.`)) {
|
97
70
|
displayName = componentName;
|
98
71
|
}
|
99
72
|
}
|
@@ -252,13 +225,13 @@ function setupHooks(optionalCallback) {
|
|
252
225
|
/**
|
253
226
|
* Inject custom style text or CSS file or 3rd party style resources
|
254
227
|
*/
|
255
|
-
|
256
|
-
return
|
257
|
-
|
228
|
+
const injectStyles = (options) => {
|
229
|
+
return () => {
|
230
|
+
const el = getContainerEl();
|
258
231
|
return injectStylesBeforeElement(options, document, el);
|
259
232
|
};
|
260
233
|
};
|
261
|
-
|
234
|
+
let mountCleanup;
|
262
235
|
/**
|
263
236
|
* Create an `mount` function. Performs all the non-React-version specific
|
264
237
|
* behavior related to mounting. The React-version-specific code
|
@@ -268,41 +241,40 @@ var lastMountedReactDom;
|
|
268
241
|
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
269
242
|
* or people writing adapters for third-party, custom adapters.
|
270
243
|
*/
|
271
|
-
|
272
|
-
if (options === void 0) { options = {}; }
|
244
|
+
const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions) => {
|
273
245
|
if (!internalMountOptions) {
|
274
246
|
throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
|
275
247
|
}
|
248
|
+
mountCleanup = internalMountOptions.cleanup;
|
276
249
|
// Get the display name property via the component constructor
|
277
250
|
// @ts-ignore FIXME
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
? jsxComponentName
|
251
|
+
const componentName = getDisplayName(jsx.type, options.alias);
|
252
|
+
const displayName = options.alias || componentName;
|
253
|
+
const jsxComponentName = `<${componentName} ... />`;
|
254
|
+
const message = options.alias
|
255
|
+
? `${jsxComponentName} as "${options.alias}"`
|
283
256
|
: jsxComponentName;
|
284
257
|
return cy
|
285
258
|
.then(injectStyles(options))
|
286
|
-
.then(
|
259
|
+
.then(() => {
|
287
260
|
var _a, _b, _c;
|
288
|
-
|
289
|
-
|
290
|
-
var el = getContainerEl();
|
261
|
+
const reactDomToUse = internalMountOptions.reactDom;
|
262
|
+
const el = getContainerEl();
|
291
263
|
if (!el) {
|
292
264
|
throw new Error([
|
293
|
-
|
265
|
+
`[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
|
294
266
|
].join(' '));
|
295
267
|
}
|
296
|
-
|
268
|
+
const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
|
297
269
|
// @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
|
298
270
|
(((_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
|
-
|
300
|
-
key
|
271
|
+
const props = {
|
272
|
+
key,
|
301
273
|
};
|
302
|
-
|
274
|
+
const reactComponent = React__namespace.createElement(options.strict ? React__namespace.StrictMode : React__namespace.Fragment, props, jsx);
|
303
275
|
// since we always surround the component with a fragment
|
304
276
|
// let's get back the original component
|
305
|
-
|
277
|
+
const userComponent = reactComponent.props.children;
|
306
278
|
internalMountOptions.render(reactComponent, el, reactDomToUse);
|
307
279
|
if (options.log !== false) {
|
308
280
|
Cypress.log({
|
@@ -311,7 +283,7 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
311
283
|
message: [message],
|
312
284
|
// @ts-ignore
|
313
285
|
$el: el.children.item(0),
|
314
|
-
consoleProps:
|
286
|
+
consoleProps: () => {
|
315
287
|
return {
|
316
288
|
// @ts-ignore protect the use of jsx functional components use ReactNode
|
317
289
|
props: jsx.props,
|
@@ -325,10 +297,10 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
325
297
|
// Separate alias and returned value. Alias returns the component only, and the thenable returns the additional functions
|
326
298
|
cy.wrap(userComponent, { log: false })
|
327
299
|
.as(displayName)
|
328
|
-
.then(
|
300
|
+
.then(() => {
|
329
301
|
return cy.wrap({
|
330
302
|
component: userComponent,
|
331
|
-
rerender:
|
303
|
+
rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
|
332
304
|
unmount: internalMountOptions.unmount,
|
333
305
|
}, { log: false });
|
334
306
|
})
|
@@ -346,39 +318,31 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
346
318
|
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
347
319
|
* or people writing adapters for third-party, custom adapters.
|
348
320
|
*/
|
349
|
-
|
350
|
-
return cy.then(
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
},
|
368
|
-
});
|
369
|
-
}
|
370
|
-
}
|
371
|
-
});
|
321
|
+
const makeUnmountFn = (options) => {
|
322
|
+
return cy.then(() => {
|
323
|
+
var _a;
|
324
|
+
const wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
325
|
+
if (wasUnmounted && options.log) {
|
326
|
+
Cypress.log({
|
327
|
+
name: 'unmount',
|
328
|
+
type: 'parent',
|
329
|
+
message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
|
330
|
+
consoleProps: () => {
|
331
|
+
return {
|
332
|
+
description: 'Unmounts React component',
|
333
|
+
parent: getContainerEl().parentNode,
|
334
|
+
home: 'https://github.com/cypress-io/cypress',
|
335
|
+
};
|
336
|
+
},
|
337
|
+
});
|
338
|
+
}
|
372
339
|
});
|
373
340
|
};
|
374
341
|
// Cleanup before each run
|
375
342
|
// NOTE: we cannot use unmount here because
|
376
343
|
// we are not in the context of a test
|
377
|
-
|
378
|
-
|
379
|
-
if (el && lastMountedReactDom) {
|
380
|
-
lastMountedReactDom.unmountComponentAtNode(el);
|
381
|
-
}
|
344
|
+
const preMountCleanup = () => {
|
345
|
+
mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
382
346
|
};
|
383
347
|
// Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
|
384
348
|
// by creating an explicit function/import that the user can register in their 'component.js' support file,
|
@@ -393,29 +357,247 @@ var preMountCleanup = function () {
|
|
393
357
|
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
|
394
358
|
setupHooks(preMountCleanup);
|
395
359
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
360
|
+
const debug = (
|
361
|
+
typeof process === 'object' &&
|
362
|
+
process.env &&
|
363
|
+
process.env.NODE_DEBUG &&
|
364
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)
|
365
|
+
) ? (...args) => console.error('SEMVER', ...args)
|
366
|
+
: () => {};
|
367
|
+
|
368
|
+
var debug_1 = debug;
|
369
|
+
|
370
|
+
// Note: this is the semver.org version of the spec that it implements
|
371
|
+
// Not necessarily the package version of this code.
|
372
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
373
|
+
|
374
|
+
const MAX_LENGTH$1 = 256;
|
375
|
+
const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
|
376
|
+
/* istanbul ignore next */ 9007199254740991;
|
377
|
+
|
378
|
+
// Max safe segment length for coercion.
|
379
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
380
|
+
|
381
|
+
var constants = {
|
382
|
+
SEMVER_SPEC_VERSION,
|
383
|
+
MAX_LENGTH: MAX_LENGTH$1,
|
384
|
+
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
|
385
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
386
|
+
};
|
387
|
+
|
388
|
+
function createCommonjsModule(fn) {
|
389
|
+
var module = { exports: {} };
|
390
|
+
return fn(module, module.exports), module.exports;
|
391
|
+
}
|
392
|
+
|
393
|
+
createCommonjsModule(function (module, exports) {
|
394
|
+
const { MAX_SAFE_COMPONENT_LENGTH } = constants;
|
395
|
+
|
396
|
+
exports = module.exports = {};
|
397
|
+
|
398
|
+
// The actual regexps go on exports.re
|
399
|
+
const re = exports.re = [];
|
400
|
+
const src = exports.src = [];
|
401
|
+
const t = exports.t = {};
|
402
|
+
let R = 0;
|
403
|
+
|
404
|
+
const createToken = (name, value, isGlobal) => {
|
405
|
+
const index = R++;
|
406
|
+
debug_1(name, index, value);
|
407
|
+
t[name] = index;
|
408
|
+
src[index] = value;
|
409
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
410
|
+
};
|
411
|
+
|
412
|
+
// The following Regular Expressions can be used for tokenizing,
|
413
|
+
// validating, and parsing SemVer version strings.
|
414
|
+
|
415
|
+
// ## Numeric Identifier
|
416
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
417
|
+
|
418
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
419
|
+
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
|
420
|
+
|
421
|
+
// ## Non-numeric Identifier
|
422
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
423
|
+
// more letters, digits, or hyphens.
|
424
|
+
|
425
|
+
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
|
426
|
+
|
427
|
+
// ## Main Version
|
428
|
+
// Three dot-separated numeric identifiers.
|
429
|
+
|
430
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
431
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
432
|
+
`(${src[t.NUMERICIDENTIFIER]})`);
|
433
|
+
|
434
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
435
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
436
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
437
|
+
|
438
|
+
// ## Pre-release Version Identifier
|
439
|
+
// A numeric identifier, or a non-numeric identifier.
|
440
|
+
|
441
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
442
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
443
|
+
|
444
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
445
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
446
|
+
|
447
|
+
// ## Pre-release Version
|
448
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
449
|
+
// identifiers.
|
450
|
+
|
451
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
452
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
453
|
+
|
454
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
455
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
456
|
+
|
457
|
+
// ## Build Metadata Identifier
|
458
|
+
// Any combination of digits, letters, or hyphens.
|
459
|
+
|
460
|
+
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
|
461
|
+
|
462
|
+
// ## Build Metadata
|
463
|
+
// Plus sign, followed by one or more period-separated build metadata
|
464
|
+
// identifiers.
|
465
|
+
|
466
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
467
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
468
|
+
|
469
|
+
// ## Full Version String
|
470
|
+
// A main version, followed optionally by a pre-release version and
|
471
|
+
// build metadata.
|
472
|
+
|
473
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
474
|
+
// the version string are capturing groups. The build metadata is not a
|
475
|
+
// capturing group, because it should not ever be used in version
|
476
|
+
// comparison.
|
477
|
+
|
478
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
479
|
+
}${src[t.PRERELEASE]}?${
|
480
|
+
src[t.BUILD]}?`);
|
481
|
+
|
482
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
483
|
+
|
484
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
485
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
486
|
+
// common in the npm registry.
|
487
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
488
|
+
}${src[t.PRERELEASELOOSE]}?${
|
489
|
+
src[t.BUILD]}?`);
|
490
|
+
|
491
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
492
|
+
|
493
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
494
|
+
|
495
|
+
// Something like "2.*" or "1.2.x".
|
496
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
497
|
+
// Only the first item is strictly required.
|
498
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
499
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
500
|
+
|
501
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
502
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
503
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
504
|
+
`(?:${src[t.PRERELEASE]})?${
|
505
|
+
src[t.BUILD]}?` +
|
506
|
+
`)?)?`);
|
507
|
+
|
508
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
509
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
510
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
511
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
512
|
+
src[t.BUILD]}?` +
|
513
|
+
`)?)?`);
|
514
|
+
|
515
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
516
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
517
|
+
|
518
|
+
// Coercion.
|
519
|
+
// Extract anything that could conceivably be a part of a valid semver
|
520
|
+
createToken('COERCE', `${'(^|[^\\d])' +
|
521
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
522
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
523
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
524
|
+
`(?:$|[^\\d])`);
|
525
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
526
|
+
|
527
|
+
// Tilde ranges.
|
528
|
+
// Meaning is "reasonably at or greater than"
|
529
|
+
createToken('LONETILDE', '(?:~>?)');
|
530
|
+
|
531
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
532
|
+
exports.tildeTrimReplace = '$1~';
|
533
|
+
|
534
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
535
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
536
|
+
|
537
|
+
// Caret ranges.
|
538
|
+
// Meaning is "at least and backwards compatible with"
|
539
|
+
createToken('LONECARET', '(?:\\^)');
|
540
|
+
|
541
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
542
|
+
exports.caretTrimReplace = '$1^';
|
543
|
+
|
544
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
545
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
546
|
+
|
547
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
548
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
549
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
550
|
+
|
551
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
552
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
553
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
554
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
555
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
556
|
+
|
557
|
+
// Something like `1.2.3 - 1.2.4`
|
558
|
+
// Note that these all use the loose form, because they'll be
|
559
|
+
// checked against either the strict or loose comparator form
|
560
|
+
// later.
|
561
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
562
|
+
`\\s+-\\s+` +
|
563
|
+
`(${src[t.XRANGEPLAIN]})` +
|
564
|
+
`\\s*$`);
|
565
|
+
|
566
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
567
|
+
`\\s+-\\s+` +
|
568
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
569
|
+
`\\s*$`);
|
570
|
+
|
571
|
+
// Star ranges basically just allow anything at all.
|
572
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
573
|
+
// >=0.0.0 is like a star
|
574
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
575
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
576
|
+
});
|
577
|
+
|
578
|
+
// @ts-expect-error
|
579
|
+
let root;
|
580
|
+
const cleanup = () => {
|
581
|
+
if (root) {
|
582
|
+
root.unmount();
|
583
|
+
return true;
|
584
|
+
}
|
585
|
+
return false;
|
586
|
+
};
|
587
|
+
function mount(jsx, options = {}, rerenderKey) {
|
588
|
+
const internalOptions = {
|
400
589
|
reactDom: ReactDOM__default["default"],
|
401
|
-
render:
|
590
|
+
render: (reactComponent, el) => {
|
402
591
|
root = ReactDOM__default["default"].createRoot(el);
|
403
592
|
return root.render(reactComponent);
|
404
593
|
},
|
405
|
-
unmount
|
594
|
+
unmount,
|
595
|
+
cleanup,
|
406
596
|
};
|
407
|
-
return makeMountFn('mount', jsx,
|
597
|
+
return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM__default["default"] }, options), rerenderKey, internalOptions);
|
408
598
|
}
|
409
|
-
function unmount(options) {
|
410
|
-
|
411
|
-
var internalOptions = {
|
412
|
-
// type is ReturnType<typeof ReactDOM.createRoot>
|
413
|
-
unmount: function () {
|
414
|
-
root.unmount();
|
415
|
-
return true;
|
416
|
-
},
|
417
|
-
};
|
418
|
-
return makeUnmountFn(options, internalOptions);
|
599
|
+
function unmount(options = { log: true }) {
|
600
|
+
return makeUnmountFn(options);
|
419
601
|
}
|
420
602
|
|
421
603
|
exports.mount = mount;
|