MinsoftK

4

Showing 1000 changed files with 0 additions and 4769 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 -Copyright 2017 Smooth Code
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 -
5 -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 -
7 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 -# @svgr/babel-preset
2 -
3 -## Install
4 -
5 -```
6 -npm install --save-dev @svgr/babel-preset
7 -```
8 -
9 -## Usage
10 -
11 -**.babelrc**
12 -
13 -```json
14 -{
15 - "presets": [["@svgr/babel-preset", { "svgProps": { "width": 200 } }]]
16 -}
17 -```
18 -
19 -## License
20 -
21 -MIT
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = void 0;
5 -
6 -var _babelPluginAddJsxAttribute = _interopRequireDefault(require("@svgr/babel-plugin-add-jsx-attribute"));
7 -
8 -var _babelPluginRemoveJsxAttribute = _interopRequireDefault(require("@svgr/babel-plugin-remove-jsx-attribute"));
9 -
10 -var _babelPluginRemoveJsxEmptyExpression = _interopRequireDefault(require("@svgr/babel-plugin-remove-jsx-empty-expression"));
11 -
12 -var _babelPluginReplaceJsxAttributeValue = _interopRequireDefault(require("@svgr/babel-plugin-replace-jsx-attribute-value"));
13 -
14 -var _babelPluginSvgDynamicTitle = _interopRequireDefault(require("@svgr/babel-plugin-svg-dynamic-title"));
15 -
16 -var _babelPluginSvgEmDimensions = _interopRequireDefault(require("@svgr/babel-plugin-svg-em-dimensions"));
17 -
18 -var _babelPluginTransformReactNativeSvg = _interopRequireDefault(require("@svgr/babel-plugin-transform-react-native-svg"));
19 -
20 -var _babelPluginTransformSvgComponent = _interopRequireDefault(require("@svgr/babel-plugin-transform-svg-component"));
21 -
22 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 -
24 -function getAttributeValue(value) {
25 - const literal = typeof value === 'string' && value.startsWith('{') && value.endsWith('}');
26 - return {
27 - value: literal ? value.slice(1, -1) : value,
28 - literal
29 - };
30 -}
31 -
32 -function propsToAttributes(props) {
33 - return Object.keys(props).map(name => {
34 - const {
35 - literal,
36 - value
37 - } = getAttributeValue(props[name]);
38 - return {
39 - name,
40 - literal,
41 - value
42 - };
43 - });
44 -}
45 -
46 -function replaceMapToValues(replaceMap) {
47 - return Object.keys(replaceMap).map(value => {
48 - const {
49 - literal,
50 - value: newValue
51 - } = getAttributeValue(replaceMap[value]);
52 - return {
53 - value,
54 - newValue,
55 - literal
56 - };
57 - });
58 -}
59 -
60 -const plugin = (api, opts) => {
61 - let toRemoveAttributes = ['version'];
62 - let toAddAttributes = [];
63 -
64 - if (opts.svgProps) {
65 - toAddAttributes = [...toAddAttributes, ...propsToAttributes(opts.svgProps)];
66 - }
67 -
68 - if (opts.ref) {
69 - toAddAttributes = [...toAddAttributes, {
70 - name: 'ref',
71 - value: 'svgRef',
72 - literal: true
73 - }];
74 - }
75 -
76 - if (opts.titleProp) {
77 - toAddAttributes = [...toAddAttributes, {
78 - name: 'aria-labelledby',
79 - value: 'titleId',
80 - literal: true
81 - }];
82 - }
83 -
84 - if (opts.expandProps) {
85 - toAddAttributes = [...toAddAttributes, {
86 - name: 'props',
87 - spread: true,
88 - position: opts.expandProps
89 - }];
90 - }
91 -
92 - if (!opts.dimensions) {
93 - toRemoveAttributes = [...toRemoveAttributes, 'width', 'height'];
94 - }
95 -
96 - const plugins = [[_babelPluginTransformSvgComponent.default, opts], ...(opts.icon && opts.dimensions ? [_babelPluginSvgEmDimensions.default] : []), [_babelPluginRemoveJsxAttribute.default, {
97 - elements: ['svg', 'Svg'],
98 - attributes: toRemoveAttributes
99 - }], [_babelPluginAddJsxAttribute.default, {
100 - elements: ['svg', 'Svg'],
101 - attributes: toAddAttributes
102 - }], _babelPluginRemoveJsxEmptyExpression.default];
103 -
104 - if (opts.replaceAttrValues) {
105 - plugins.push([_babelPluginReplaceJsxAttributeValue.default, {
106 - values: replaceMapToValues(opts.replaceAttrValues)
107 - }]);
108 - }
109 -
110 - if (opts.titleProp) {
111 - plugins.push(_babelPluginSvgDynamicTitle.default);
112 - }
113 -
114 - if (opts.native) {
115 - if (opts.native.expo) {
116 - plugins.push([_babelPluginTransformReactNativeSvg.default, opts.native]);
117 - } else {
118 - plugins.push(_babelPluginTransformReactNativeSvg.default);
119 - }
120 - }
121 -
122 - return {
123 - plugins
124 - };
125 -};
126 -
127 -var _default = plugin;
128 -exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "_from": "@svgr/babel-preset@^5.5.0",
3 - "_id": "@svgr/babel-preset@5.5.0",
4 - "_inBundle": false,
5 - "_integrity": "sha512-4FiXBjvQ+z2j7yASeGPEi8VD/5rrGQk4Xrq3EdJmoZgz/tpqChpo5hgXDvmEauwtvOc52q8ghhZK4Oy7qph4ig==",
6 - "_location": "/@svgr/babel-preset",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@svgr/babel-preset@^5.5.0",
12 - "name": "@svgr/babel-preset",
13 - "escapedName": "@svgr%2fbabel-preset",
14 - "scope": "@svgr",
15 - "rawSpec": "^5.5.0",
16 - "saveSpec": null,
17 - "fetchSpec": "^5.5.0"
18 - },
19 - "_requiredBy": [
20 - "/@svgr/plugin-jsx"
21 - ],
22 - "_resolved": "https://registry.npmjs.org/@svgr/babel-preset/-/babel-preset-5.5.0.tgz",
23 - "_shasum": "8af54f3e0a8add7b1e2b0fcd5a882c55393df327",
24 - "_spec": "@svgr/babel-preset@^5.5.0",
25 - "_where": "C:\\Users\\kkwan_000\\Desktop\\git\\2017110269\\minsung\\node_modules\\@svgr\\plugin-jsx",
26 - "author": {
27 - "name": "Greg Bergé",
28 - "email": "berge.greg@gmail.com"
29 - },
30 - "bundleDependencies": false,
31 - "dependencies": {
32 - "@svgr/babel-plugin-add-jsx-attribute": "^5.4.0",
33 - "@svgr/babel-plugin-remove-jsx-attribute": "^5.4.0",
34 - "@svgr/babel-plugin-remove-jsx-empty-expression": "^5.0.1",
35 - "@svgr/babel-plugin-replace-jsx-attribute-value": "^5.0.1",
36 - "@svgr/babel-plugin-svg-dynamic-title": "^5.4.0",
37 - "@svgr/babel-plugin-svg-em-dimensions": "^5.4.0",
38 - "@svgr/babel-plugin-transform-react-native-svg": "^5.4.0",
39 - "@svgr/babel-plugin-transform-svg-component": "^5.5.0"
40 - },
41 - "deprecated": false,
42 - "description": "SVGR preset that apply transformations from config",
43 - "engines": {
44 - "node": ">=10"
45 - },
46 - "funding": {
47 - "type": "github",
48 - "url": "https://github.com/sponsors/gregberge"
49 - },
50 - "gitHead": "b5920550bd966f876cb65c5e23af180461e5aa23",
51 - "homepage": "https://react-svgr.com",
52 - "keywords": [
53 - "babel-plugin",
54 - "babel-preset"
55 - ],
56 - "license": "MIT",
57 - "main": "lib/index.js",
58 - "name": "@svgr/babel-preset",
59 - "publishConfig": {
60 - "access": "public"
61 - },
62 - "repository": {
63 - "type": "git",
64 - "url": "https://github.com/gregberge/svgr/tree/master/packages/babel-preset"
65 - },
66 - "scripts": {
67 - "build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
68 - "prebuild": "rm -rf lib/",
69 - "prepublishOnly": "yarn run build"
70 - },
71 - "version": "5.5.0"
72 -}
This diff is collapsed. Click to expand it.
1 -Copyright 2017 Smooth Code
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 -
5 -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 -
7 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 -# @svgr/core
2 -
3 -[![Build Status][build-badge]][build]
4 -[![version][version-badge]][package]
5 -[![MIT License][license-badge]][license]
6 -
7 -Node API of SVGR.
8 -
9 -```
10 -npm install @svgr/core
11 -```
12 -
13 -## Usage
14 -
15 -```js
16 -import svgr from '@svgr/core'
17 -
18 -const svgCode = `
19 -<svg xmlns="http://www.w3.org/2000/svg"
20 - xmlns:xlink="http://www.w3.org/1999/xlink">
21 - <rect x="10" y="10" height="100" width="100"
22 - style="stroke:#ff0000; fill: #0000ff"/>
23 -</svg>
24 -`
25 -
26 -svgr(svgCode, { icon: true }, { componentName: 'MyComponent' }).then(
27 - (jsCode) => {
28 - console.log(jsCode)
29 - },
30 -)
31 -```
32 -
33 -Use `svgr.sync(code, config, state)` if you would like to use sync version.
34 -
35 -### Plugins
36 -
37 -By default `@svgr/core` doesn't include `svgo` and `prettier` plugins, if you want them, you have to install them and include them in config.
38 -
39 -```js
40 -svgr(svgCode, {
41 - plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx', '@svgr/plugin-prettier'],
42 -}).then((jsCode) => {
43 - console.log(jsCode)
44 -})
45 -```
46 -
47 -## License
48 -
49 -MIT
50 -
51 -[build-badge]: https://img.shields.io/travis/smooth-code/svgr.svg?style=flat-square
52 -[build]: https://travis-ci.org/smooth-code/svgr
53 -[version-badge]: https://img.shields.io/npm/v/@svgr/core.svg?style=flat-square
54 -[package]: https://www.npmjs.com/package/@svgr/core
55 -[license-badge]: https://img.shields.io/npm/l/@svgr/core.svg?style=flat-square
56 -[license]: https://github.com/smooth-code/svgr/blob/master/LICENSE
57 -
58 -```
59 -
60 -```
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.resolveConfig = resolveConfig;
5 -exports.resolveConfigFile = resolveConfigFile;
6 -exports.loadConfig = loadConfig;
7 -exports.DEFAULT_CONFIG = void 0;
8 -
9 -var _cosmiconfig = require("cosmiconfig");
10 -
11 -const DEFAULT_CONFIG = {
12 - dimensions: true,
13 - expandProps: 'end',
14 - icon: false,
15 - native: false,
16 - typescript: false,
17 - prettier: true,
18 - prettierConfig: null,
19 - memo: false,
20 - ref: false,
21 - replaceAttrValues: null,
22 - svgProps: null,
23 - svgo: true,
24 - svgoConfig: null,
25 - template: null,
26 - titleProp: false,
27 - runtimeConfig: true,
28 - plugins: null,
29 - namedExport: 'ReactComponent'
30 -};
31 -exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
32 -const explorer = (0, _cosmiconfig.cosmiconfig)('svgr', {
33 - sync: true,
34 - cache: true,
35 - rcExtensions: true
36 -});
37 -const explorerSync = (0, _cosmiconfig.cosmiconfigSync)('svgr', {
38 - sync: true,
39 - cache: true,
40 - rcExtensions: true
41 -});
42 -
43 -async function resolveConfig(searchFrom, configFile) {
44 - if (configFile == null) {
45 - const result = await explorer.search(searchFrom);
46 - return result ? result.config : null;
47 - }
48 -
49 - const result = await explorer.load(configFile);
50 - return result ? result.config : null;
51 -}
52 -
53 -resolveConfig.sync = (searchFrom, configFile) => {
54 - if (configFile == null) {
55 - const result = explorerSync.search(searchFrom);
56 - return result ? result.config : null;
57 - }
58 -
59 - const result = explorerSync.load(configFile);
60 - return result ? result.config : null;
61 -};
62 -
63 -async function resolveConfigFile(filePath) {
64 - const result = await explorer.search(filePath);
65 - return result ? result.filepath : null;
66 -}
67 -
68 -resolveConfigFile.sync = filePath => {
69 - const result = explorerSync.search(filePath);
70 - return result ? result.filepath : null;
71 -};
72 -
73 -async function loadConfig({
74 - configFile,
75 - ...baseConfig
76 -}, state = {}) {
77 - const rcConfig = state.filePath && baseConfig.runtimeConfig !== false ? await resolveConfig(state.filePath, configFile) : {};
78 - return { ...DEFAULT_CONFIG,
79 - ...rcConfig,
80 - ...baseConfig
81 - };
82 -}
83 -
84 -loadConfig.sync = ({
85 - configFile,
86 - ...baseConfig
87 -}, state = {}) => {
88 - const rcConfig = state.filePath && baseConfig.runtimeConfig !== false ? resolveConfig.sync(state.filePath, configFile) : {};
89 - return { ...DEFAULT_CONFIG,
90 - ...rcConfig,
91 - ...baseConfig
92 - };
93 -};
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = void 0;
5 -
6 -var _state = require("./state");
7 -
8 -var _config = require("./config");
9 -
10 -var _plugins = require("./plugins");
11 -
12 -function run(code, config, state) {
13 - const expandedState = (0, _state.expandState)(state);
14 - const plugins = (0, _plugins.getPlugins)(config, state).map(_plugins.resolvePlugin);
15 - let nextCode = String(code).replace('\0', ''); // eslint-disable-next-line no-restricted-syntax
16 -
17 - for (const plugin of plugins) {
18 - nextCode = plugin(nextCode, config, expandedState);
19 - }
20 -
21 - return nextCode;
22 -}
23 -
24 -async function convert(code, config = {}, state = {}) {
25 - config = await (0, _config.loadConfig)(config, state);
26 - return run(code, config, state);
27 -}
28 -
29 -convert.sync = (code, config = {}, state = {}) => {
30 - config = _config.loadConfig.sync(config, state);
31 - return run(code, config, state);
32 -};
33 -
34 -var _default = convert;
35 -exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -var _exportNames = {};
5 -exports.default = void 0;
6 -
7 -var _convert = _interopRequireDefault(require("./convert"));
8 -
9 -exports.default = _convert.default;
10 -
11 -var _config = require("./config");
12 -
13 -Object.keys(_config).forEach(function (key) {
14 - if (key === "default" || key === "__esModule") return;
15 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
16 - if (key in exports && exports[key] === _config[key]) return;
17 - exports[key] = _config[key];
18 -});
19 -
20 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.getPlugins = getPlugins;
5 -exports.resolvePlugin = resolvePlugin;
6 -exports.loadPlugin = loadPlugin;
7 -
8 -var _pluginJsx = _interopRequireDefault(require("@svgr/plugin-jsx"));
9 -
10 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11 -
12 -const DEFAULT_PLUGINS = [_pluginJsx.default];
13 -
14 -function getPlugins(config, state) {
15 - if (config.plugins) {
16 - return config.plugins;
17 - }
18 -
19 - if (state.caller && state.caller.defaultPlugins) {
20 - return state.caller.defaultPlugins;
21 - }
22 -
23 - return DEFAULT_PLUGINS;
24 -}
25 -
26 -function resolvePlugin(plugin) {
27 - if (typeof plugin === 'function') {
28 - return plugin;
29 - }
30 -
31 - if (typeof plugin === 'string') {
32 - return loadPlugin(plugin);
33 - }
34 -
35 - throw new Error(`Invalid plugin "${plugin}"`);
36 -}
37 -
38 -const pluginCache = {};
39 -
40 -function loadPlugin(moduleName) {
41 - if (pluginCache[moduleName]) {
42 - return pluginCache[moduleName];
43 - }
44 -
45 - try {
46 - // eslint-disable-next-line
47 - const plugin = require(moduleName);
48 -
49 - if (!plugin.default || !plugin) {
50 - throw new Error(`Invalid plugin "${moduleName}"`);
51 - }
52 -
53 - pluginCache[moduleName] = plugin.default || plugin;
54 - return pluginCache[moduleName];
55 - } catch (error) {
56 - throw new Error(`Module "${moduleName}" missing. Maybe \`npm install ${moduleName}\` could help!`);
57 - }
58 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.expandState = expandState;
5 -
6 -var _path = _interopRequireDefault(require("path"));
7 -
8 -var _camelcase = _interopRequireDefault(require("camelcase"));
9 -
10 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11 -
12 -const validCharacters = /[^a-zA-Z0-9_-]/g;
13 -
14 -function getComponentName(state) {
15 - if (!state.filePath) return 'SvgComponent';
16 - const pascalCaseFileName = (0, _camelcase.default)(_path.default.parse(state.filePath).name.replace(validCharacters, ''), {
17 - pascalCase: true
18 - });
19 - return `Svg${pascalCaseFileName}`;
20 -}
21 -
22 -function expandState(state) {
23 - return {
24 - componentName: state.componentName || getComponentName(state),
25 - ...state
26 - };
27 -}
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "_from": "@svgr/core@^5.4.0",
3 - "_id": "@svgr/core@5.5.0",
4 - "_inBundle": false,
5 - "_integrity": "sha512-q52VOcsJPvV3jO1wkPtzTuKlvX7Y3xIcWRpCMtBF3MrteZJtBfQw/+u0B1BHy5ColpQc1/YVTrPEtSYIMNZlrQ==",
6 - "_location": "/@svgr/core",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@svgr/core@^5.4.0",
12 - "name": "@svgr/core",
13 - "escapedName": "@svgr%2fcore",
14 - "scope": "@svgr",
15 - "rawSpec": "^5.4.0",
16 - "saveSpec": null,
17 - "fetchSpec": "^5.4.0"
18 - },
19 - "_requiredBy": [
20 - "/@svgr/webpack"
21 - ],
22 - "_resolved": "https://registry.npmjs.org/@svgr/core/-/core-5.5.0.tgz",
23 - "_shasum": "82e826b8715d71083120fe8f2492ec7d7874a579",
24 - "_spec": "@svgr/core@^5.4.0",
25 - "_where": "C:\\Users\\kkwan_000\\Desktop\\git\\2017110269\\minsung\\node_modules\\@svgr\\webpack",
26 - "author": {
27 - "name": "Greg Bergé",
28 - "email": "berge.greg@gmail.com"
29 - },
30 - "bundleDependencies": false,
31 - "dependencies": {
32 - "@svgr/plugin-jsx": "^5.5.0",
33 - "camelcase": "^6.2.0",
34 - "cosmiconfig": "^7.0.0"
35 - },
36 - "deprecated": false,
37 - "description": "Transform SVG into React Components.",
38 - "engines": {
39 - "node": ">=10"
40 - },
41 - "funding": {
42 - "type": "github",
43 - "url": "https://github.com/sponsors/gregberge"
44 - },
45 - "gitHead": "b5920550bd966f876cb65c5e23af180461e5aa23",
46 - "homepage": "https://react-svgr.com",
47 - "keywords": [
48 - "svgr",
49 - "svg",
50 - "react",
51 - "core",
52 - "api"
53 - ],
54 - "license": "MIT",
55 - "main": "lib/index.js",
56 - "name": "@svgr/core",
57 - "publishConfig": {
58 - "access": "public"
59 - },
60 - "repository": {
61 - "type": "git",
62 - "url": "https://github.com/gregberge/svgr/tree/master/packages/core"
63 - },
64 - "scripts": {
65 - "build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
66 - "prebuild": "rm -rf lib/",
67 - "prepublishOnly": "yarn run build"
68 - },
69 - "version": "5.5.0"
70 -}
1 -# Change Log
2 -
3 -All notable changes to this project will be documented in this file.
4 -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 -
6 -# [5.5.0](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/compare/v5.4.0...v5.5.0) (2020-11-15)
7 -
8 -**Note:** Version bump only for package @svgr/hast-util-to-babel-ast
9 -
10 -
11 -
12 -
13 -
14 -# [5.4.0](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/compare/v5.3.1...v5.4.0) (2020-04-27)
15 -
16 -**Note:** Version bump only for package @svgr/hast-util-to-babel-ast
17 -
18 -
19 -
20 -
21 -
22 -## [5.0.1](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/compare/v5.0.0...v5.0.1) (2019-12-29)
23 -
24 -
25 -### Bug Fixes
26 -
27 -* fix engines in package.json ([a45d6fc](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/commit/a45d6fc8b43402bec60ed4e9273f90fdc65a23a7))
28 -
29 -
30 -
31 -
32 -
33 -## [4.3.2](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/compare/v4.3.1...v4.3.2) (2019-07-15)
34 -
35 -
36 -### Performance Improvements
37 -
38 -* replace rehype with svg-parser ([#321](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/issues/321)) ([7eb5ef6](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/commit/7eb5ef6))
39 -
40 -
41 -
42 -
43 -
44 -## [4.3.1](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/compare/v4.3.0...v4.3.1) (2019-07-01)
45 -
46 -**Note:** Version bump only for package @svgr/hast-util-to-babel-ast
47 -
48 -
49 -
50 -
51 -
52 -# [4.2.0](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/compare/v4.1.0...v4.2.0) (2019-04-11)
53 -
54 -
55 -### Bug Fixes
56 -
57 -* **hast-util-to-babel-ast:** correctly handle aria attributes ([23d12aa](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/commit/23d12aa)), closes [#279](https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast/issues/279)
58 -
59 -
60 -
61 -
62 -
63 -# [4.1.0](https://github.com/gregberge/svgr/compare/v4.0.4...v4.1.0) (2018-11-24)
64 -
65 -**Note:** Version bump only for package @svgr/hast-util-to-babel-ast
66 -
67 -
68 -
69 -
70 -
71 -## [4.0.3](https://github.com/gregberge/svgr/compare/v4.0.2...v4.0.3) (2018-11-13)
72 -
73 -
74 -### Bug Fixes
75 -
76 -* upgrade dependencies ([7e2195f](https://github.com/gregberge/svgr/commit/7e2195f))
77 -
78 -
79 -
80 -
81 -
82 -## [4.0.2](https://github.com/gregberge/svgr/compare/v4.0.1...v4.0.2) (2018-11-08)
83 -
84 -
85 -### Bug Fixes
86 -
87 -* **hast-util-to-babel-ast:** replace tabs by spaces in attributes ([b0f3d19](https://github.com/gregberge/svgr/commit/b0f3d19)), closes [#219](https://github.com/gregberge/svgr/issues/219)
88 -
89 -
90 -
91 -
92 -
93 -## [4.0.1](https://github.com/gregberge/svgr/compare/v4.0.0...v4.0.1) (2018-11-08)
94 -
95 -
96 -### Bug Fixes
97 -
98 -* **hast-util-to-babel-ast:** correctly transforms data & aria attributes ([99711c4](https://github.com/gregberge/svgr/commit/99711c4)), closes [#221](https://github.com/gregberge/svgr/issues/221)
99 -* **hast-util-to-babel-ast:** replace line-breaks in attributes ([00a2625](https://github.com/gregberge/svgr/commit/00a2625)), closes [#219](https://github.com/gregberge/svgr/issues/219)
100 -
101 -
102 -
103 -
104 -
105 -# [4.0.0](https://github.com/gregberge/svgr/compare/v3.1.0...v4.0.0) (2018-11-04)
106 -
107 -
108 -### Features
109 -
110 -* **v4:** new architecture ([ac8b8ca](https://github.com/gregberge/svgr/commit/ac8b8ca))
111 -
112 -
113 -### BREAKING CHANGES
114 -
115 -* **v4:** - `template` option must now returns a Babel AST
116 -- `@svgr/core` does not include svgo & prettier by default
1 -Copyright 2017 Smooth Code
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 -
5 -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 -
7 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 -# @svgr/hast-util-to-babel-ast
2 -
3 -[![Build Status](https://img.shields.io/travis/smooth-code/svgr.svg)](https://travis-ci.org/smooth-code/svgr)
4 -[![Version](https://img.shields.io/npm/v/@svgr/hast-util-to-babel-ast.svg)](https://www.npmjs.com/package/@svgr/hast-util-to-babel-ast)
5 -[![MIT License](https://img.shields.io/npm/l/@svgr/hast-util-to-babel-ast.svg)](https://github.com/smooth-code/svgr/blob/master/LICENSE)
6 -
7 -Transforms HAST into Babel AST.
8 -
9 -## Install
10 -
11 -```
12 -npm install --save-dev @svgr/hast-util-to-babel-ast
13 -```
14 -
15 -## Usage
16 -
17 -```js
18 -import { parse } from 'svg-parser'
19 -import toBabelAST from '@svgr/hast-util-to-babel-ast'
20 -
21 -const hastTree = parse(`<svg></svg>`)
22 -
23 -const babelTree = hastToBabelAst(hastTree)
24 -```
25 -
26 -## License
27 -
28 -MIT
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = void 0;
5 -
6 -var _one = _interopRequireDefault(require("./one"));
7 -
8 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9 -
10 -/* Transform the children of `parent`. */
11 -function all(h, parent) {
12 - const nodes = parent.children || [];
13 - const {
14 - length
15 - } = nodes;
16 - const values = [];
17 - let index = -1;
18 -
19 - while (++index < length) {
20 - const result = (0, _one.default)(h, nodes[index], parent);
21 - values.push(result);
22 - }
23 -
24 - return values.filter(node => node);
25 -}
26 -
27 -var _default = all;
28 -exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = void 0;
5 -
6 -var t = _interopRequireWildcard(require("@babel/types"));
7 -
8 -var _util = require("./util");
9 -
10 -var _stringToObjectStyle = _interopRequireDefault(require("./stringToObjectStyle"));
11 -
12 -var _mappings = require("./mappings");
13 -
14 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15 -
16 -function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
17 -
18 -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19 -
20 -function convertAriaAttribute(kebabKey) {
21 - const [aria, ...parts] = kebabKey.split('-');
22 - return `${aria}-${parts.join('').toLowerCase()}`;
23 -}
24 -
25 -function getKey(key, value, node) {
26 - const lowerCaseKey = key.toLowerCase();
27 - const mappedElementAttribute = _mappings.ELEMENT_ATTRIBUTE_MAPPING[node.name] && _mappings.ELEMENT_ATTRIBUTE_MAPPING[node.name][lowerCaseKey];
28 - const mappedAttribute = _mappings.ATTRIBUTE_MAPPING[lowerCaseKey];
29 -
30 - if (mappedElementAttribute || mappedAttribute) {
31 - return t.jsxIdentifier(mappedElementAttribute || mappedAttribute);
32 - }
33 -
34 - const kebabKey = (0, _util.kebabCase)(key);
35 -
36 - if (kebabKey.startsWith('aria-')) {
37 - return t.jsxIdentifier(convertAriaAttribute(kebabKey));
38 - }
39 -
40 - if (kebabKey.startsWith('data-')) {
41 - return t.jsxIdentifier(kebabKey);
42 - }
43 -
44 - return t.jsxIdentifier(key);
45 -}
46 -
47 -function getValue(key, value) {
48 - // Handle className
49 - if (Array.isArray(value)) {
50 - return t.stringLiteral((0, _util.replaceSpaces)(value.join(' ')));
51 - }
52 -
53 - if (key === 'style') {
54 - return t.jsxExpressionContainer((0, _stringToObjectStyle.default)(value));
55 - }
56 -
57 - if ((0, _util.isNumeric)(value)) {
58 - return t.jsxExpressionContainer(t.numericLiteral(Number(value)));
59 - }
60 -
61 - return t.stringLiteral((0, _util.replaceSpaces)(value));
62 -}
63 -
64 -const getAttributes = node => {
65 - const keys = Object.keys(node.properties);
66 - const attributes = [];
67 - let index = -1;
68 -
69 - while (++index < keys.length) {
70 - const key = keys[index];
71 - const value = node.properties[key];
72 - const attribute = t.jsxAttribute(getKey(key, value, node), getValue(key, value, node));
73 - attributes.push(attribute);
74 - }
75 -
76 - return attributes;
77 -};
78 -
79 -var _default = getAttributes;
80 -exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.element = exports.text = exports.comment = exports.root = void 0;
5 -
6 -var t = _interopRequireWildcard(require("@babel/types"));
7 -
8 -var _all = _interopRequireDefault(require("./all"));
9 -
10 -var _getAttributes = _interopRequireDefault(require("./getAttributes"));
11 -
12 -var _mappings = require("./mappings");
13 -
14 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15 -
16 -function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
17 -
18 -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19 -
20 -const root = (h, node) => t.program((0, _all.default)(h, node));
21 -
22 -exports.root = root;
23 -
24 -const comment = (h, node, parent) => {
25 - if (parent.type === 'root') {
26 - return null;
27 - }
28 -
29 - const expression = t.jsxEmptyExpression();
30 - t.addComment(expression, 'inner', node.value);
31 - return t.jsxExpressionContainer(expression);
32 -};
33 -
34 -exports.comment = comment;
35 -
36 -const text = (h, node, parent) => {
37 - if (parent.type === 'root') {
38 - return null;
39 - }
40 -
41 - if (node.value.match(/^\s+$/)) {
42 - return null;
43 - }
44 -
45 - return t.jsxExpressionContainer(t.stringLiteral(node.value));
46 -};
47 -
48 -exports.text = text;
49 -
50 -const element = (h, node, parent) => {
51 - const children = (0, _all.default)(h, node);
52 - const selfClosing = children.length === 0;
53 - const name = _mappings.ELEMENT_TAG_NAME_MAPPING[node.tagName] || node.tagName;
54 - const openingElement = t.jsxOpeningElement(t.jsxIdentifier(name), (0, _getAttributes.default)(node), selfClosing);
55 - const closingElement = !selfClosing ? t.jsxClosingElement(t.jsxIdentifier(name)) : null;
56 - const jsxElement = t.jsxElement(openingElement, closingElement, children);
57 -
58 - if (parent.type === 'root') {
59 - return t.expressionStatement(jsxElement);
60 - }
61 -
62 - return jsxElement;
63 -};
64 -
65 -exports.element = element;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = void 0;
5 -
6 -var handlers = _interopRequireWildcard(require("./handlers"));
7 -
8 -var _one = _interopRequireDefault(require("./one"));
9 -
10 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11 -
12 -function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13 -
14 -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15 -
16 -const h = {
17 - handlers
18 -};
19 -
20 -function toBabelAST(tree) {
21 - return (0, _one.default)(h, tree);
22 -}
23 -
24 -var _default = toBabelAST;
25 -exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = void 0;
5 -
6 -function one(h, node, parent) {
7 - const type = node && node.type;
8 - const fn = h.handlers[type];
9 - /* Fail on non-nodes. */
10 -
11 - if (!type) {
12 - throw new Error(`Expected node, got \`${node}\``);
13 - }
14 -
15 - if (!fn) {
16 - throw new Error(`Node of type ${type} is unknown`);
17 - }
18 -
19 - return fn(h, node, parent);
20 -}
21 -
22 -var _default = one;
23 -exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = void 0;
5 -
6 -var t = _interopRequireWildcard(require("@babel/types"));
7 -
8 -var _util = require("./util");
9 -
10 -function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 -
12 -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 -
14 -// Inspired by https://github.com/reactjs/react-magic/blob/master/src/htmltojsx.js
15 -
16 -/**
17 - * Determines if the CSS value can be converted from a
18 - * 'px' suffixed string to a numeric value.
19 - *
20 - * @param {string} value CSS property value
21 - * @return {boolean}
22 - */
23 -function isConvertiblePixelValue(value) {
24 - return /^\d+px$/.test(value);
25 -}
26 -/**
27 - * Format style key into JSX style object key.
28 - *
29 - * @param {string} key
30 - * @return {string}
31 - */
32 -
33 -
34 -function formatKey(key) {
35 - key = key.toLowerCase(); // Don't capitalize -ms- prefix
36 -
37 - if (/^-ms-/.test(key)) key = key.substr(1);
38 - return t.identifier((0, _util.hyphenToCamelCase)(key));
39 -}
40 -/**
41 - * Format style value into JSX style object value.
42 - *
43 - * @param {string} key
44 - * @return {string}
45 - */
46 -
47 -
48 -function formatValue(value) {
49 - if ((0, _util.isNumeric)(value)) return t.numericLiteral(Number(value));
50 - if (isConvertiblePixelValue(value)) return t.numericLiteral(Number((0, _util.trimEnd)(value, 'px')));
51 - return t.stringLiteral(value);
52 -}
53 -/**
54 - * Handle parsing of inline styles.
55 - *
56 - * @param {string} rawStyle
57 - * @returns {object}
58 - */
59 -
60 -
61 -function stringToObjectStyle(rawStyle) {
62 - const entries = rawStyle.split(';');
63 - const properties = [];
64 - let index = -1;
65 -
66 - while (++index < entries.length) {
67 - const entry = entries[index];
68 - const style = entry.trim();
69 - const firstColon = style.indexOf(':');
70 - const value = style.substr(firstColon + 1).trim();
71 - const key = style.substr(0, firstColon);
72 -
73 - if (key !== '') {
74 - const property = t.objectProperty(formatKey(key), formatValue(value));
75 - properties.push(property);
76 - }
77 - }
78 -
79 - return t.objectExpression(properties);
80 -}
81 -
82 -var _default = stringToObjectStyle;
83 -exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.isNumeric = isNumeric;
5 -exports.hyphenToCamelCase = hyphenToCamelCase;
6 -exports.trimEnd = trimEnd;
7 -exports.kebabCase = kebabCase;
8 -exports.replaceSpaces = replaceSpaces;
9 -
10 -/**
11 - * Determines if the specified string consists entirely of numeric characters.
12 - *
13 - * @param {*} [value]
14 - * @returns {boolean}
15 - */
16 -function isNumeric(value) {
17 - return !Number.isNaN(value - parseFloat(value));
18 -}
19 -/**
20 - * Convert a hyphenated string to camelCase.
21 - *
22 - * @param {string} string
23 - * @returns {string}
24 - */
25 -
26 -
27 -function hyphenToCamelCase(string) {
28 - return string.replace(/-(.)/g, (match, chr) => chr.toUpperCase());
29 -}
30 -/**
31 - * Trim the specified substring off the string. If the string does not end
32 - * with the specified substring, this is a no-op.
33 - *
34 - * @param {string} haystack String to search in
35 - * @param {string} needle String to search for
36 - * @return {string}
37 - */
38 -
39 -
40 -function trimEnd(haystack, needle) {
41 - return haystack.endsWith(needle) ? haystack.slice(0, -needle.length) : haystack;
42 -}
43 -
44 -const KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
45 -
46 -function kebabCase(str) {
47 - return str.replace(KEBAB_REGEX, match => `-${match.toLowerCase()}`);
48 -}
49 -
50 -const SPACES_REGEXP = /[\t\r\n\u0085\u2028\u2029]+/g;
51 -
52 -function replaceSpaces(str) {
53 - return str.replace(SPACES_REGEXP, ' ');
54 -}
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "_from": "@svgr/hast-util-to-babel-ast@^5.5.0",
3 - "_id": "@svgr/hast-util-to-babel-ast@5.5.0",
4 - "_inBundle": false,
5 - "_integrity": "sha512-cAaR/CAiZRB8GP32N+1jocovUtvlj0+e65TB50/6Lcime+EA49m/8l+P2ko+XPJ4dw3xaPS3jOL4F2X4KWxoeQ==",
6 - "_location": "/@svgr/hast-util-to-babel-ast",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@svgr/hast-util-to-babel-ast@^5.5.0",
12 - "name": "@svgr/hast-util-to-babel-ast",
13 - "escapedName": "@svgr%2fhast-util-to-babel-ast",
14 - "scope": "@svgr",
15 - "rawSpec": "^5.5.0",
16 - "saveSpec": null,
17 - "fetchSpec": "^5.5.0"
18 - },
19 - "_requiredBy": [
20 - "/@svgr/plugin-jsx"
21 - ],
22 - "_resolved": "https://registry.npmjs.org/@svgr/hast-util-to-babel-ast/-/hast-util-to-babel-ast-5.5.0.tgz",
23 - "_shasum": "5ee52a9c2533f73e63f8f22b779f93cd432a5461",
24 - "_spec": "@svgr/hast-util-to-babel-ast@^5.5.0",
25 - "_where": "C:\\Users\\kkwan_000\\Desktop\\git\\2017110269\\minsung\\node_modules\\@svgr\\plugin-jsx",
26 - "author": {
27 - "name": "Greg Bergé",
28 - "email": "berge.greg@gmail.com"
29 - },
30 - "bundleDependencies": false,
31 - "dependencies": {
32 - "@babel/types": "^7.12.6"
33 - },
34 - "deprecated": false,
35 - "description": "Transform HAST to Babel AST (JSX)",
36 - "engines": {
37 - "node": ">=10"
38 - },
39 - "funding": {
40 - "type": "github",
41 - "url": "https://github.com/sponsors/gregberge"
42 - },
43 - "gitHead": "b5920550bd966f876cb65c5e23af180461e5aa23",
44 - "homepage": "https://react-svgr.com",
45 - "keywords": [
46 - "html",
47 - "hast",
48 - "babel",
49 - "hast-util",
50 - "unist-util",
51 - "unist"
52 - ],
53 - "license": "MIT",
54 - "main": "lib/index.js",
55 - "name": "@svgr/hast-util-to-babel-ast",
56 - "publishConfig": {
57 - "access": "public"
58 - },
59 - "repository": {
60 - "type": "git",
61 - "url": "https://github.com/gregberge/svgr/tree/master/packages/hast-util-to-babel-ast"
62 - },
63 - "scripts": {
64 - "build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
65 - "prebuild": "rm -rf lib/",
66 - "prepublishOnly": "yarn run build"
67 - },
68 - "version": "5.5.0"
69 -}
1 -# Change Log
2 -
3 -All notable changes to this project will be documented in this file.
4 -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 -
6 -# [5.5.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v5.4.0...v5.5.0) (2020-11-15)
7 -
8 -
9 -### Bug Fixes
10 -
11 -* prevent removing the namespace by svgr ([[#475](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/issues/475)](https://github.com/gregberge/svgr/issues/475) ([#498](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/issues/498)) ([00e84ea](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/commit/00e84ead96d89bcbd072b9585b4db1365e392d33))
12 -
13 -
14 -
15 -
16 -
17 -# [5.4.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v5.3.1...v5.4.0) (2020-04-27)
18 -
19 -**Note:** Version bump only for package @svgr/plugin-jsx
20 -
21 -
22 -
23 -
24 -
25 -## [5.3.1](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v5.3.0...v5.3.1) (2020-04-05)
26 -
27 -**Note:** Version bump only for package @svgr/plugin-jsx
28 -
29 -
30 -
31 -
32 -
33 -# [5.3.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v5.2.0...v5.3.0) (2020-03-22)
34 -
35 -**Note:** Version bump only for package @svgr/plugin-jsx
36 -
37 -
38 -
39 -
40 -
41 -# [5.2.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v5.1.0...v5.2.0) (2020-02-23)
42 -
43 -**Note:** Version bump only for package @svgr/plugin-jsx
44 -
45 -
46 -
47 -
48 -
49 -## [5.0.1](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v5.0.0...v5.0.1) (2019-12-29)
50 -
51 -
52 -### Bug Fixes
53 -
54 -* fix engines in package.json ([a45d6fc](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/commit/a45d6fc8b43402bec60ed4e9273f90fdc65a23a7))
55 -
56 -
57 -
58 -
59 -
60 -## [4.3.3](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v4.3.2...v4.3.3) (2019-09-24)
61 -
62 -**Note:** Version bump only for package @svgr/plugin-jsx
63 -
64 -
65 -
66 -
67 -
68 -## [4.3.2](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v4.3.1...v4.3.2) (2019-07-15)
69 -
70 -
71 -### Performance Improvements
72 -
73 -* replace rehype with svg-parser ([#321](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/issues/321)) ([7eb5ef6](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/commit/7eb5ef6))
74 -
75 -
76 -
77 -
78 -
79 -## [4.3.1](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v4.3.0...v4.3.1) (2019-07-01)
80 -
81 -**Note:** Version bump only for package @svgr/plugin-jsx
82 -
83 -
84 -
85 -
86 -
87 -# [4.3.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v4.2.0...v4.3.0) (2019-05-28)
88 -
89 -**Note:** Version bump only for package @svgr/plugin-jsx
90 -
91 -
92 -
93 -
94 -
95 -# [4.2.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx/compare/v4.1.0...v4.2.0) (2019-04-11)
96 -
97 -**Note:** Version bump only for package @svgr/plugin-jsx
98 -
99 -
100 -
101 -
102 -
103 -# [4.1.0](https://github.com/gregberge/svgr/compare/v4.0.4...v4.1.0) (2018-11-24)
104 -
105 -**Note:** Version bump only for package @svgr/plugin-jsx
106 -
107 -
108 -
109 -
110 -
111 -## [4.0.3](https://github.com/gregberge/svgr/compare/v4.0.2...v4.0.3) (2018-11-13)
112 -
113 -
114 -### Bug Fixes
115 -
116 -* upgrade dependencies ([7e2195f](https://github.com/gregberge/svgr/commit/7e2195f))
117 -
118 -
119 -
120 -
121 -
122 -## [4.0.2](https://github.com/gregberge/svgr/compare/v4.0.1...v4.0.2) (2018-11-08)
123 -
124 -**Note:** Version bump only for package @svgr/plugin-jsx
125 -
126 -
127 -
128 -
129 -
130 -## [4.0.1](https://github.com/gregberge/svgr/compare/v4.0.0...v4.0.1) (2018-11-08)
131 -
132 -**Note:** Version bump only for package @svgr/plugin-jsx
133 -
134 -
135 -
136 -
137 -
138 -# [4.0.0](https://github.com/gregberge/svgr/compare/v3.1.0...v4.0.0) (2018-11-04)
139 -
140 -
141 -### Features
142 -
143 -* **svgo:** prefix ids by default ([06c338d](https://github.com/gregberge/svgr/commit/06c338d)), closes [#210](https://github.com/gregberge/svgr/issues/210)
144 -* **v4:** new architecture ([ac8b8ca](https://github.com/gregberge/svgr/commit/ac8b8ca))
145 -
146 -
147 -### BREAKING CHANGES
148 -
149 -* **v4:** - `template` option must now returns a Babel AST
150 -- `@svgr/core` does not include svgo & prettier by default
1 -Copyright 2017 Smooth Code
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 -
5 -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 -
7 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 -# @svgr/plugin-jsx
2 -
3 -[![Build Status](https://img.shields.io/travis/smooth-code/svgr.svg)](https://travis-ci.org/smooth-code/svgr)
4 -[![Version](https://img.shields.io/npm/v/@svgr/plugin-jsx.svg)](https://www.npmjs.com/package/@svgr/plugin-jsx)
5 -[![MIT License](https://img.shields.io/npm/l/@svgr/plugin-jsx.svg)](https://github.com/smooth-code/svgr/blob/master/LICENSE)
6 -
7 -Transforms SVG into JSX.
8 -
9 -## Install
10 -
11 -```
12 -npm install --save-dev @svgr/plugin-jsx
13 -```
14 -
15 -## Usage
16 -
17 -**.svgrrc**
18 -
19 -```json
20 -{
21 - "plugins": ["@svgr/plugin-jsx"]
22 -}
23 -```
24 -
25 -## How does it work?
26 -
27 -`@svgr/plugin-jsx` consists in three phases:
28 -
29 -- Parsing the SVG code using [svg-parser](https://github.com/Rich-Harris/svg-parser)
30 -- Converting the [HAST](https://github.com/syntax-tree/hast) into a [Babel AST](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md)
31 -- Applying [`@svgr/babel-preset`](../babel-preset/README.md) transformations
32 -
33 -## Applying custom transformations
34 -
35 -You can extend the Babel config applied in this plugin using `jsx.babelConfig` config path:
36 -
37 -```js
38 -// .svgrrc.js
39 -
40 -module.exports = {
41 - jsx: {
42 - babelConfig: {
43 - plugins: [
44 - // For an example, this plugin will remove "id" attribute from "svg" tag
45 - [
46 - '@svgr/babel-plugin-remove-jsx-attribute',
47 - {
48 - elements: ['svg'],
49 - attributes: ['id'],
50 - },
51 - ],
52 - ],
53 - },
54 - },
55 -}
56 -```
57 -
58 -Several Babel plugins are available:
59 -
60 -- [`@svgr/babel-plugin-add-jsx-attribute`](../babel-plugin-add-jsx-attribute/README.md)
61 -- [`@svgr/babel-plugin-remove-jsx-attribute`](../babel-plugin-remove-jsx-attribute/README.md)
62 -- [`@svgr/babel-plugin-remove-jsx-empty-expression`](../babel-plugin-remove-jsx-empty-expression/README.md)
63 -- [`@svgr/babel-plugin-replace-jsx-attribute-value`](../babel-plugin-replace-jsx-attribute-value/README.md)
64 -- [`@svgr/babel-plugin-svg-dynamic-title`](../babel-plugin-svg-dynamic-title/README.md)
65 -- [`@svgr/babel-plugin-svg-em-dimensions`](../babel-plugin-svg-em-dimensions/README.md)
66 -- [`@svgr/babel-plugin-transform-react-native-svg`](../babel-plugin-transform-react-native-svg/README.md)
67 -- [`@svgr/babel-plugin-transform-svg-component`](../babel-plugin-transform-svg-component/README.md)
68 -
69 -If you want to create your own, reading [Babel Handbook](https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md) is a good start!
70 -
71 -## License
72 -
73 -MIT
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = jsxPlugin;
5 -
6 -var _svgParser = require("svg-parser");
7 -
8 -var _hastUtilToBabelAst = _interopRequireDefault(require("@svgr/hast-util-to-babel-ast"));
9 -
10 -var _core = require("@babel/core");
11 -
12 -var _babelPreset = _interopRequireDefault(require("@svgr/babel-preset"));
13 -
14 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15 -
16 -function jsxPlugin(code, config, state) {
17 - const filePath = state.filePath || 'unknown';
18 - const hastTree = (0, _svgParser.parse)(code);
19 - const babelTree = (0, _hastUtilToBabelAst.default)(hastTree);
20 - const {
21 - code: generatedCode
22 - } = (0, _core.transformFromAstSync)(babelTree, code, {
23 - caller: {
24 - name: 'svgr'
25 - },
26 - presets: [(0, _core.createConfigItem)([_babelPreset.default, { ...config,
27 - state
28 - }], {
29 - type: 'preset'
30 - })],
31 - filename: filePath,
32 - babelrc: false,
33 - configFile: false,
34 - code: true,
35 - ast: false,
36 - inputSourceMap: false,
37 - ...(config.jsx && config.jsx.babelConfig)
38 - });
39 - return generatedCode;
40 -}
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "_from": "@svgr/plugin-jsx@^5.4.0",
3 - "_id": "@svgr/plugin-jsx@5.5.0",
4 - "_inBundle": false,
5 - "_integrity": "sha512-V/wVh33j12hGh05IDg8GpIUXbjAPnTdPTKuP4VNLggnwaHMPNQNae2pRnyTAILWCQdz5GyMqtO488g7CKM8CBA==",
6 - "_location": "/@svgr/plugin-jsx",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@svgr/plugin-jsx@^5.4.0",
12 - "name": "@svgr/plugin-jsx",
13 - "escapedName": "@svgr%2fplugin-jsx",
14 - "scope": "@svgr",
15 - "rawSpec": "^5.4.0",
16 - "saveSpec": null,
17 - "fetchSpec": "^5.4.0"
18 - },
19 - "_requiredBy": [
20 - "/@svgr/core",
21 - "/@svgr/webpack"
22 - ],
23 - "_resolved": "https://registry.npmjs.org/@svgr/plugin-jsx/-/plugin-jsx-5.5.0.tgz",
24 - "_shasum": "1aa8cd798a1db7173ac043466d7b52236b369000",
25 - "_spec": "@svgr/plugin-jsx@^5.4.0",
26 - "_where": "C:\\Users\\kkwan_000\\Desktop\\git\\2017110269\\minsung\\node_modules\\@svgr\\webpack",
27 - "author": {
28 - "name": "Greg Bergé",
29 - "email": "berge.greg@gmail.com"
30 - },
31 - "bundleDependencies": false,
32 - "dependencies": {
33 - "@babel/core": "^7.12.3",
34 - "@svgr/babel-preset": "^5.5.0",
35 - "@svgr/hast-util-to-babel-ast": "^5.5.0",
36 - "svg-parser": "^2.0.2"
37 - },
38 - "deprecated": false,
39 - "description": "Transform SVG into JSX",
40 - "engines": {
41 - "node": ">=10"
42 - },
43 - "funding": {
44 - "type": "github",
45 - "url": "https://github.com/sponsors/gregberge"
46 - },
47 - "gitHead": "b5920550bd966f876cb65c5e23af180461e5aa23",
48 - "homepage": "https://react-svgr.com",
49 - "keywords": [
50 - "svgr-plugin"
51 - ],
52 - "license": "MIT",
53 - "main": "lib/index.js",
54 - "name": "@svgr/plugin-jsx",
55 - "publishConfig": {
56 - "access": "public"
57 - },
58 - "repository": {
59 - "type": "git",
60 - "url": "https://github.com/gregberge/svgr/tree/master/packages/plugin-jsx"
61 - },
62 - "scripts": {
63 - "build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
64 - "prebuild": "rm -rf lib/",
65 - "prepublishOnly": "yarn run build"
66 - },
67 - "version": "5.5.0"
68 -}
1 -# Change Log
2 -
3 -All notable changes to this project will be documented in this file.
4 -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 -
6 -# [5.5.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/compare/v5.4.0...v5.5.0) (2020-11-15)
7 -
8 -
9 -### Features
10 -
11 -* **svgo:** add .svgorc.js config file support ([#451](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/issues/451)) ([8049b1a](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/commit/8049b1a63603672096892b6ab3d303580c2f303f)), closes [#412](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/issues/412)
12 -
13 -
14 -### Performance Improvements
15 -
16 -* replace merge-deep with smaller deepmerge ([#463](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/issues/463)) ([1f015eb](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/commit/1f015eb16fca093a08b012236dc83623f7bcce55))
17 -
18 -
19 -
20 -
21 -
22 -# [5.4.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/compare/v5.3.1...v5.4.0) (2020-04-27)
23 -
24 -**Note:** Version bump only for package @svgr/plugin-svgo
25 -
26 -
27 -
28 -
29 -
30 -# [5.3.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/compare/v5.2.0...v5.3.0) (2020-03-22)
31 -
32 -
33 -### Bug Fixes
34 -
35 -* **svgo:** support any SVGO config format ([#412](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/issues/412)) ([f2b2367](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/commit/f2b2367389fda20baba6e0a5e884e7f7fe29a3ed)), closes [#400](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/issues/400)
36 -
37 -
38 -
39 -
40 -
41 -# [5.2.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/compare/v5.1.0...v5.2.0) (2020-02-23)
42 -
43 -
44 -### Bug Fixes
45 -
46 -* verify that `svgoConfig.plugins` is an array ([#397](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/issues/397)) ([88110b6](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/commit/88110b6eb4d93ded68ca2de05cc82654dfac977d))
47 -
48 -
49 -
50 -
51 -
52 -# [5.1.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/compare/v5.0.1...v5.1.0) (2020-01-20)
53 -
54 -
55 -### Bug Fixes
56 -
57 -* fix merging svgo plugins in config ([#384](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/issues/384)) ([c9d2dfc](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/commit/c9d2dfcb8d4da55eb21a13507c87d9e549a86e7e))
58 -
59 -
60 -
61 -
62 -
63 -## [5.0.1](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/compare/v5.0.0...v5.0.1) (2019-12-29)
64 -
65 -
66 -### Bug Fixes
67 -
68 -* fix engines in package.json ([a45d6fc](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/commit/a45d6fc8b43402bec60ed4e9273f90fdc65a23a7))
69 -
70 -
71 -
72 -
73 -
74 -## [4.3.1](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/compare/v4.3.0...v4.3.1) (2019-07-01)
75 -
76 -**Note:** Version bump only for package @svgr/plugin-svgo
77 -
78 -
79 -
80 -
81 -
82 -# [4.2.0](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/compare/v4.1.0...v4.2.0) (2019-04-11)
83 -
84 -
85 -### Bug Fixes
86 -
87 -* keep viewBox when dimensions are removed ([#281](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/issues/281)) ([f476c8e](https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo/commit/f476c8e))
88 -
89 -
90 -
91 -
92 -
93 -## [4.0.3](https://github.com/gregberge/svgr/compare/v4.0.2...v4.0.3) (2018-11-13)
94 -
95 -
96 -### Bug Fixes
97 -
98 -* upgrade dependencies ([7e2195f](https://github.com/gregberge/svgr/commit/7e2195f))
99 -
100 -
101 -
102 -
103 -
104 -# [4.0.0](https://github.com/gregberge/svgr/compare/v3.1.0...v4.0.0) (2018-11-04)
105 -
106 -
107 -### Features
108 -
109 -* **svgo:** prefix ids by default ([06c338d](https://github.com/gregberge/svgr/commit/06c338d)), closes [#210](https://github.com/gregberge/svgr/issues/210)
110 -* **v4:** new architecture ([ac8b8ca](https://github.com/gregberge/svgr/commit/ac8b8ca))
111 -
112 -
113 -### BREAKING CHANGES
114 -
115 -* **v4:** - `template` option must now returns a Babel AST
116 -- `@svgr/core` does not include svgo & prettier by default
1 -Copyright 2017 Smooth Code
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 -
5 -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 -
7 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 -# @svgr/plugin-svgo
2 -
3 -[![Build Status](https://img.shields.io/travis/smooth-code/svgr.svg)](https://travis-ci.org/smooth-code/svgr)
4 -[![Version](https://img.shields.io/npm/v/@svgr/plugin-svgo.svg)](https://www.npmjs.com/package/@svgr/plugin-svgo)
5 -[![MIT License](https://img.shields.io/npm/l/@svgr/plugin-svgo.svg)](https://github.com/smooth-code/svgr/blob/master/LICENSE)
6 -
7 -Optimize SVG using SVGO.
8 -
9 -## Install
10 -
11 -```
12 -npm install --save-dev @svgr/plugin-svgo
13 -```
14 -
15 -## Usage
16 -
17 -**.svgrrc**
18 -
19 -```json
20 -{
21 - "plugins": ["@svgr/plugin-svgo"]
22 -}
23 -```
24 -
25 -## License
26 -
27 -MIT
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.getFilePath = getFilePath;
5 -exports.getBaseSvgoConfig = getBaseSvgoConfig;
6 -exports.getPlugins = getPlugins;
7 -exports.mergeSvgoConfig = mergeSvgoConfig;
8 -
9 -var _deepmerge = _interopRequireDefault(require("deepmerge"));
10 -
11 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12 -
13 -function getFilePath(state) {
14 - return state.filePath || process.cwd();
15 -}
16 -
17 -function getBaseSvgoConfig(config) {
18 - const baseSvgoConfig = {
19 - plugins: [{
20 - prefixIds: true
21 - }]
22 - };
23 -
24 - if (config.icon || config.dimensions === false) {
25 - baseSvgoConfig.plugins.push({
26 - removeViewBox: false
27 - });
28 - }
29 -
30 - return baseSvgoConfig;
31 -}
32 -
33 -function getPlugins(config) {
34 - if (!config || !config.plugins) {
35 - return [];
36 - }
37 -
38 - if (!Array.isArray(config.plugins)) {
39 - throw Error('`svgoConfig.plugins` must be an array');
40 - }
41 -
42 - return config.plugins;
43 -}
44 -
45 -function extractPlugins(config) {
46 - if (!config) return [];
47 - if (!config.plugins) return [];
48 - if (!Array.isArray(config.plugins)) return [config.plugins];
49 - return config.plugins;
50 -}
51 -
52 -function mergePlugins(configs) {
53 - const plugins = configs.reduce((merged, config) => _deepmerge.default.all([merged, ...extractPlugins(config)]), {});
54 - return Object.keys(plugins).reduce((array, key) => {
55 - array.push({
56 - [key]: plugins[key]
57 - });
58 - return array;
59 - }, []);
60 -}
61 -
62 -function mergeSvgoConfig(...configs) {
63 - const plugins = mergePlugins(configs);
64 - return { ..._deepmerge.default.all(configs.filter(Boolean)),
65 - plugins
66 - };
67 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = svgoPlugin;
5 -
6 -var _svgo = _interopRequireDefault(require("svgo"));
7 -
8 -var _cosmiconfig = require("cosmiconfig");
9 -
10 -var _config = require("./config");
11 -
12 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 -
14 -/* eslint-disable no-underscore-dangle */
15 -const explorer = (0, _cosmiconfig.cosmiconfigSync)('svgo', {
16 - searchPlaces: ['package.json', '.svgorc', '.svgorc.js', '.svgorc.json', '.svgorc.yaml', '.svgorc.yml', 'svgo.config.js', '.svgo.yml'],
17 - transform: result => result && result.config,
18 - cache: true
19 -});
20 -
21 -function encodeSVGDatauri(str, type) {
22 - let prefix = 'data:image/svg+xml'; // base64
23 -
24 - if (!type || type === 'base64') {
25 - prefix += ';base64,';
26 -
27 - if (Buffer.from) {
28 - str = prefix + Buffer.from(str).toString('base64');
29 - } else {
30 - // eslint-disable-next-line
31 - str = prefix + new Buffer(str).toString('base64');
32 - } // URI encoded
33 -
34 - } else if (type === 'enc') {
35 - str = `${prefix},${encodeURIComponent(str)}`; // unencoded
36 - } else if (type === 'unenc') {
37 - str = `${prefix},${str}`;
38 - }
39 -
40 - return str;
41 -} // See https://github.com/svg/svgo/blob/master/lib/svgo.js#L24
42 -// _optimizeOnce is synchronous internally
43 -
44 -
45 -function optimizeSync(svgstr, info) {
46 - const {
47 - config
48 - } = this;
49 -
50 - if (config.error) {
51 - throw config.error;
52 - }
53 -
54 - const maxPassCount = config.multipass ? 10 : 1;
55 - let counter = 0;
56 - let prevResultSize = Number.POSITIVE_INFINITY;
57 - let result;
58 -
59 - const optimizeOnceCallback = svgjs => {
60 - if (svgjs.error) {
61 - throw svgjs.error;
62 - } // eslint-disable-next-line no-plusplus
63 -
64 -
65 - if (++counter < maxPassCount && svgjs.data.length < prevResultSize) {
66 - prevResultSize = svgjs.data.length;
67 -
68 - this._optimizeOnce(svgjs.data, info, optimizeOnceCallback);
69 - } else {
70 - if (config.datauri) {
71 - svgjs.data = encodeSVGDatauri(svgjs.data, config.datauri);
72 - }
73 -
74 - if (info.path) {
75 - svgjs.path = info.path;
76 - }
77 -
78 - result = svgjs;
79 - }
80 - };
81 -
82 - this._optimizeOnce(svgstr, info, optimizeOnceCallback);
83 -
84 - return result;
85 -}
86 -
87 -function createSvgo(config, rcConfig) {
88 - const baseSvgoConfig = (0, _config.getBaseSvgoConfig)(config);
89 - const mergedConfig = (0, _config.mergeSvgoConfig)(baseSvgoConfig, rcConfig, config.svgoConfig);
90 - return new _svgo.default(mergedConfig);
91 -}
92 -
93 -function getInfo(state) {
94 - return state.filePath ? {
95 - input: 'file',
96 - path: state.filePath
97 - } : {
98 - input: 'string'
99 - };
100 -}
101 -
102 -function svgoPlugin(code, config, state) {
103 - if (!config.svgo) return code;
104 - const filePath = (0, _config.getFilePath)(state);
105 - const svgoRcConfig = config.runtimeConfig ? explorer.search(filePath) : {};
106 - const svgo = createSvgo(config, svgoRcConfig);
107 - const {
108 - data
109 - } = optimizeSync.call(svgo, code, getInfo(state));
110 - return data;
111 -}
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "_from": "@svgr/plugin-svgo@^5.4.0",
3 - "_id": "@svgr/plugin-svgo@5.5.0",
4 - "_inBundle": false,
5 - "_integrity": "sha512-r5swKk46GuQl4RrVejVwpeeJaydoxkdwkM1mBKOgJLBUJPGaLci6ylg/IjhrRsREKDkr4kbMWdgOtbXEh0fyLQ==",
6 - "_location": "/@svgr/plugin-svgo",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "range",
10 - "registry": true,
11 - "raw": "@svgr/plugin-svgo@^5.4.0",
12 - "name": "@svgr/plugin-svgo",
13 - "escapedName": "@svgr%2fplugin-svgo",
14 - "scope": "@svgr",
15 - "rawSpec": "^5.4.0",
16 - "saveSpec": null,
17 - "fetchSpec": "^5.4.0"
18 - },
19 - "_requiredBy": [
20 - "/@svgr/webpack"
21 - ],
22 - "_resolved": "https://registry.npmjs.org/@svgr/plugin-svgo/-/plugin-svgo-5.5.0.tgz",
23 - "_shasum": "02da55d85320549324e201c7b2e53bf431fcc246",
24 - "_spec": "@svgr/plugin-svgo@^5.4.0",
25 - "_where": "C:\\Users\\kkwan_000\\Desktop\\git\\2017110269\\minsung\\node_modules\\@svgr\\webpack",
26 - "author": {
27 - "name": "Greg Bergé",
28 - "email": "berge.greg@gmail.com"
29 - },
30 - "bundleDependencies": false,
31 - "dependencies": {
32 - "cosmiconfig": "^7.0.0",
33 - "deepmerge": "^4.2.2",
34 - "svgo": "^1.2.2"
35 - },
36 - "deprecated": false,
37 - "description": "Optimize SVG",
38 - "engines": {
39 - "node": ">=10"
40 - },
41 - "funding": {
42 - "type": "github",
43 - "url": "https://github.com/sponsors/gregberge"
44 - },
45 - "gitHead": "b5920550bd966f876cb65c5e23af180461e5aa23",
46 - "homepage": "https://react-svgr.com",
47 - "keywords": [
48 - "svgr-plugin"
49 - ],
50 - "license": "MIT",
51 - "main": "lib/index.js",
52 - "name": "@svgr/plugin-svgo",
53 - "publishConfig": {
54 - "access": "public"
55 - },
56 - "repository": {
57 - "type": "git",
58 - "url": "https://github.com/gregberge/svgr/tree/master/packages/plugin-svgo"
59 - },
60 - "scripts": {
61 - "build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
62 - "prebuild": "rm -rf lib/",
63 - "prepublishOnly": "yarn run build"
64 - },
65 - "version": "5.5.0"
66 -}
1 -# Change Log
2 -
3 -All notable changes to this project will be documented in this file.
4 -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 -
6 -# [5.4.0](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v5.3.1...v5.4.0) (2020-04-27)
7 -
8 -**Note:** Version bump only for package @svgr/webpack
9 -
10 -
11 -
12 -
13 -
14 -## [5.3.1](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v5.3.0...v5.3.1) (2020-04-05)
15 -
16 -**Note:** Version bump only for package @svgr/webpack
17 -
18 -
19 -
20 -
21 -
22 -# [5.3.0](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v5.2.0...v5.3.0) (2020-03-22)
23 -
24 -**Note:** Version bump only for package @svgr/webpack
25 -
26 -
27 -
28 -
29 -
30 -# [5.2.0](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v5.1.0...v5.2.0) (2020-02-23)
31 -
32 -**Note:** Version bump only for package @svgr/webpack
33 -
34 -
35 -
36 -
37 -
38 -# [5.1.0](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v5.0.1...v5.1.0) (2020-01-20)
39 -
40 -**Note:** Version bump only for package @svgr/webpack
41 -
42 -
43 -
44 -
45 -
46 -## [5.0.1](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v5.0.0...v5.0.1) (2019-12-29)
47 -
48 -
49 -### Bug Fixes
50 -
51 -* fix engines in package.json ([a45d6fc](https://github.com/gregberge/svgr/tree/master/packages/webpack/commit/a45d6fc8b43402bec60ed4e9273f90fdc65a23a7))
52 -
53 -
54 -
55 -
56 -
57 -## [4.3.3](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v4.3.2...v4.3.3) (2019-09-24)
58 -
59 -**Note:** Version bump only for package @svgr/webpack
60 -
61 -
62 -
63 -
64 -
65 -## [4.3.2](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v4.3.1...v4.3.2) (2019-07-15)
66 -
67 -**Note:** Version bump only for package @svgr/webpack
68 -
69 -
70 -
71 -
72 -
73 -## [4.3.1](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v4.3.0...v4.3.1) (2019-07-01)
74 -
75 -**Note:** Version bump only for package @svgr/webpack
76 -
77 -
78 -
79 -
80 -
81 -# [4.3.0](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v4.2.0...v4.3.0) (2019-05-28)
82 -
83 -**Note:** Version bump only for package @svgr/webpack
84 -
85 -
86 -
87 -
88 -
89 -# [4.2.0](https://github.com/gregberge/svgr/tree/master/packages/webpack/compare/v4.1.0...v4.2.0) (2019-04-11)
90 -
91 -**Note:** Version bump only for package @svgr/webpack
92 -
93 -
94 -
95 -
96 -
97 -# [4.1.0](https://github.com/gregberge/svgr/compare/v4.0.4...v4.1.0) (2018-11-24)
98 -
99 -
100 -### Features
101 -
102 -* add parcel plugin ([#235](https://github.com/gregberge/svgr/issues/235)) ([144dbe3](https://github.com/gregberge/svgr/commit/144dbe3)), closes [#215](https://github.com/gregberge/svgr/issues/215)
103 -
104 -
105 -
106 -
107 -
108 -## [4.0.4](https://github.com/gregberge/svgr/compare/v4.0.3...v4.0.4) (2018-11-24)
109 -
110 -
111 -### Bug Fixes
112 -
113 -* **webpack:** use static babel config ([#240](https://github.com/gregberge/svgr/issues/240)) ([d67af31](https://github.com/gregberge/svgr/commit/d67af31)), closes [#232](https://github.com/gregberge/svgr/issues/232)
114 -
115 -
116 -
117 -
118 -
119 -## [4.0.3](https://github.com/gregberge/svgr/compare/v4.0.2...v4.0.3) (2018-11-13)
120 -
121 -
122 -### Bug Fixes
123 -
124 -* upgrade dependencies ([7e2195f](https://github.com/gregberge/svgr/commit/7e2195f))
125 -
126 -
127 -
128 -
129 -
130 -## [4.0.2](https://github.com/gregberge/svgr/compare/v4.0.1...v4.0.2) (2018-11-08)
131 -
132 -**Note:** Version bump only for package @svgr/webpack
133 -
134 -
135 -
136 -
137 -
138 -## [4.0.1](https://github.com/gregberge/svgr/compare/v4.0.0...v4.0.1) (2018-11-08)
139 -
140 -**Note:** Version bump only for package @svgr/webpack
141 -
142 -
143 -
144 -
145 -
146 -# [4.0.0](https://github.com/gregberge/svgr/compare/v3.1.0...v4.0.0) (2018-11-04)
147 -
148 -
149 -### Bug Fixes
150 -
151 -* prevent babel read babel.config.js ([#206](https://github.com/gregberge/svgr/issues/206)) ([514d43d](https://github.com/gregberge/svgr/commit/514d43d))
152 -
153 -
154 -### Features
155 -
156 -* **svgo:** prefix ids by default ([06c338d](https://github.com/gregberge/svgr/commit/06c338d)), closes [#210](https://github.com/gregberge/svgr/issues/210)
157 -* **v4:** new architecture ([ac8b8ca](https://github.com/gregberge/svgr/commit/ac8b8ca))
158 -
159 -
160 -### BREAKING CHANGES
161 -
162 -* **v4:** - `template` option must now returns a Babel AST
163 -- `@svgr/core` does not include svgo & prettier by default
164 -
165 -
166 -
167 -
168 -
169 -# [3.1.0](https://github.com/gregberge/svgr/compare/v3.0.0...v3.1.0) (2018-10-05)
170 -
171 -**Note:** Version bump only for package @svgr/webpack
172 -
173 -
174 -
175 -
176 -
177 -<a name="3.0.0"></a>
178 -# [3.0.0](https://github.com/gregberge/svgr/compare/v2.4.1...v3.0.0) (2018-10-01)
179 -
180 -
181 -### Bug Fixes
182 -
183 -* **webpack:** forward filePath in webpack loader ([b7a108e](https://github.com/gregberge/svgr/commit/b7a108e)), closes [#177](https://github.com/gregberge/svgr/issues/177) [#188](https://github.com/gregberge/svgr/issues/188)
184 -
185 -
186 -### Features
187 -
188 -* always prefix component name with "Svg" ([f71aa7a](https://github.com/gregberge/svgr/commit/f71aa7a)), closes [#190](https://github.com/gregberge/svgr/issues/190)
189 -
190 -
191 -### BREAKING CHANGES
192 -
193 -* **webpack:** runtime configuration is now loaded using webpack
194 -loader.
195 -
196 -
197 -
198 -
199 -
200 -<a name="2.4.1"></a>
201 -## [2.4.1](https://github.com/gregberge/svgr/compare/v2.4.0...v2.4.1) (2018-09-16)
202 -
203 -**Note:** Version bump only for package @svgr/webpack
204 -
205 -
206 -
207 -
208 -
209 -<a name="2.4.0"></a>
210 -# [2.4.0](https://github.com/gregberge/svgr/compare/v2.3.0...v2.4.0) (2018-09-16)
211 -
212 -
213 -### Features
214 -
215 -* **upgrade:** h2x@1.1.0 (jsdom@12.0.0) & others ([2d9b7bd](https://github.com/gregberge/svgr/commit/2d9b7bd))
216 -
217 -
218 -
219 -
220 -
221 -<a name="2.3.0"></a>
222 -# [2.3.0](https://github.com/gregberge/svgr/compare/v2.2.1...v2.3.0) (2018-09-03)
223 -
224 -
225 -### Features
226 -
227 -* upgrade to Babel v7 ([7bc908d](https://github.com/gregberge/svgr/commit/7bc908d))
228 -
229 -
230 -
231 -
232 -
233 -<a name="2.2.1"></a>
234 -## [2.2.1](https://github.com/gregberge/svgr/compare/v2.2.0...v2.2.1) (2018-08-16)
235 -
236 -**Note:** Version bump only for package @svgr/webpack
237 -
238 -
239 -
240 -
241 -
242 -<a name="2.2.0"></a>
243 -# [2.2.0](https://github.com/gregberge/svgr/compare/v2.1.1...v2.2.0) (2018-08-13)
244 -
245 -
246 -### Bug Fixes
247 -
248 -* **webpack:** use source when possible ([#139](https://github.com/gregberge/svgr/issues/139)) ([ae9965d](https://github.com/gregberge/svgr/commit/ae9965d))
249 -
250 -
251 -
252 -
253 -
254 -<a name="2.1.1"></a>
255 -## [2.1.1](https://github.com/gregberge/svgr/compare/v2.1.0...v2.1.1) (2018-07-11)
256 -
257 -
258 -
259 -
260 -**Note:** Version bump only for package @svgr/webpack
261 -
262 -<a name="2.1.0"></a>
263 -# [2.1.0](https://github.com/gregberge/svgr/compare/v2.0.0...v2.1.0) (2018-07-08)
264 -
265 -
266 -
267 -
268 -**Note:** Version bump only for package @svgr/webpack
1 -Copyright 2017 Smooth Code
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 -
5 -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 -
7 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 -# @svgr/webpack
2 -
3 -[![Build Status](https://img.shields.io/travis/gregberge/svgr.svg)](https://travis-ci.org/gregberge/svgr)
4 -[![Version](https://img.shields.io/npm/v/@svgr/webpack.svg)](https://www.npmjs.com/package/@svgr/webpack)
5 -[![MIT License](https://img.shields.io/npm/l/@svgr/webpack.svg)](https://github.com/gregberge/svgr/blob/master/LICENSE)
6 -
7 -Webpack loader for SVGR.
8 -
9 -```
10 -npm install @svgr/webpack --save-dev
11 -```
12 -
13 -## Usage
14 -
15 -In your `webpack.config.js`:
16 -
17 -```js
18 -{
19 - test: /\.svg$/,
20 - use: ['@svgr/webpack'],
21 -}
22 -```
23 -
24 -In your code:
25 -
26 -```js
27 -import Star from './star.svg'
28 -
29 -const App = () => (
30 - <div>
31 - <Star />
32 - </div>
33 -)
34 -```
35 -
36 -### Passing options
37 -
38 -```js
39 -{
40 - test: /\.svg$/,
41 - use: [
42 - {
43 - loader: '@svgr/webpack',
44 - options: {
45 - native: true,
46 - },
47 - },
48 - ],
49 -}
50 -```
51 -
52 -### Using with `url-loader` or `file-loader`
53 -
54 -It is possible to use it with [`url-loader`](https://github.com/webpack-contrib/url-loader) or [`file-loader`](https://github.com/webpack-contrib/file-loader).
55 -
56 -In your `webpack.config.js`:
57 -
58 -```js
59 -{
60 - test: /\.svg$/,
61 - use: ['@svgr/webpack', 'url-loader'],
62 -}
63 -```
64 -
65 -In your code:
66 -
67 -```js
68 -import starUrl, { ReactComponent as Star } from './star.svg'
69 -
70 -const App = () => (
71 - <div>
72 - <img src={starUrl} alt="star" />
73 - <Star />
74 - </div>
75 -)
76 -```
77 -
78 -### Use your own Babel configuration
79 -
80 -By default, `@svgr/webpack` includes a `babel-loader` with [an optimized configuration](https://github.com/gregberge/svgr/blob/master/packages/webpack/src/index.js). In some case you may want to apply a custom one (if you are using Preact for an example). You can turn off Babel transformation by specifying `babel: false` in options.
81 -
82 -```js
83 -// Example using preact
84 -{
85 - test: /\.svg$/,
86 - use: [
87 - {
88 - loader: 'babel-loader',
89 - options: {
90 - presets: ['preact', 'env'],
91 - },
92 - },
93 - {
94 - loader: '@svgr/webpack',
95 - options: { babel: false },
96 - }
97 - ],
98 -}
99 -```
100 -
101 -### Handle SVG in CSS, Sass or Less
102 -
103 -It is possible to detect the module that requires your SVG using [`Rule.issuer`](https://webpack.js.org/configuration/module/#rule-issuer) in Webpack. Using it you can specify two different configurations for JavaScript and the rest of your files.
104 -
105 -```js
106 -{
107 - {
108 - test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
109 - issuer: {
110 - test: /\.jsx?$/
111 - },
112 - use: ['babel-loader', '@svgr/webpack', 'url-loader']
113 - },
114 - {
115 - test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
116 - loader: 'url-loader'
117 - },
118 -}
119 -```
120 -
121 -## License
122 -
123 -MIT
1 -"use strict";
2 -
3 -exports.__esModule = true;
4 -exports.default = void 0;
5 -
6 -var _loaderUtils = require("loader-utils");
7 -
8 -var _core = require("@babel/core");
9 -
10 -var _core2 = _interopRequireDefault(require("@svgr/core"));
11 -
12 -var _pluginSvgo = _interopRequireDefault(require("@svgr/plugin-svgo"));
13 -
14 -var _pluginJsx = _interopRequireDefault(require("@svgr/plugin-jsx"));
15 -
16 -var _presetReact = _interopRequireDefault(require("@babel/preset-react"));
17 -
18 -var _presetEnv = _interopRequireDefault(require("@babel/preset-env"));
19 -
20 -var _pluginTransformReactConstantElements = _interopRequireDefault(require("@babel/plugin-transform-react-constant-elements"));
21 -
22 -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 -
24 -function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
25 -
26 -const babelOptions = {
27 - babelrc: false,
28 - configFile: false,
29 - presets: [(0, _core.createConfigItem)(_presetReact.default, {
30 - type: 'preset'
31 - }), (0, _core.createConfigItem)([_presetEnv.default, {
32 - modules: false
33 - }], {
34 - type: 'preset'
35 - })],
36 - plugins: [(0, _core.createConfigItem)(_pluginTransformReactConstantElements.default)]
37 -};
38 -
39 -function svgrLoader(source) {
40 - const callback = this.async();
41 -
42 - const _ref = (0, _loaderUtils.getOptions)(this) || {},
43 - {
44 - babel = true
45 - } = _ref,
46 - options = _objectWithoutPropertiesLoose(_ref, ["babel"]);
47 -
48 - const readSvg = () => new Promise((resolve, reject) => {
49 - this.fs.readFile(this.resourcePath, (err, result) => {
50 - if (err) reject(err);
51 - resolve(result);
52 - });
53 - });
54 -
55 - const previousExport = (() => {
56 - if (source.toString('utf-8').startsWith('export ')) {
57 - return source;
58 - }
59 -
60 - const exportMatches = source.toString('utf-8').match(/^module.exports\s*=\s*(.*)/);
61 - return exportMatches ? `export default ${exportMatches[1]}` : null;
62 - })();
63 -
64 - const tranformSvg = svg => (0, _core2.default)(svg, options, {
65 - caller: {
66 - name: '@svgr/webpack',
67 - previousExport,
68 - defaultPlugins: [_pluginSvgo.default, _pluginJsx.default]
69 - },
70 - filePath: this.resourcePath
71 - }).then(jsCode => {
72 - if (!babel) return jsCode;
73 - return (0, _core.transformAsync)(jsCode, babelOptions).then(({
74 - code
75 - }) => code);
76 - }).then(result => callback(null, result)).catch(err => callback(err));
77 -
78 - if (previousExport) {
79 - readSvg().then(tranformSvg);
80 - } else {
81 - tranformSvg(source);
82 - }
83 -}
84 -
85 -var _default = svgrLoader;
86 -exports.default = _default;
...\ No newline at end of file ...\ No newline at end of file
1 -{
2 - "_from": "@svgr/webpack@5.4.0",
3 - "_id": "@svgr/webpack@5.4.0",
4 - "_inBundle": false,
5 - "_integrity": "sha512-LjepnS/BSAvelnOnnzr6Gg0GcpLmnZ9ThGFK5WJtm1xOqdBE/1IACZU7MMdVzjyUkfFqGz87eRE4hFaSLiUwYg==",
6 - "_location": "/@svgr/webpack",
7 - "_phantomChildren": {},
8 - "_requested": {
9 - "type": "version",
10 - "registry": true,
11 - "raw": "@svgr/webpack@5.4.0",
12 - "name": "@svgr/webpack",
13 - "escapedName": "@svgr%2fwebpack",
14 - "scope": "@svgr",
15 - "rawSpec": "5.4.0",
16 - "saveSpec": null,
17 - "fetchSpec": "5.4.0"
18 - },
19 - "_requiredBy": [
20 - "/react-scripts"
21 - ],
22 - "_resolved": "https://registry.npmjs.org/@svgr/webpack/-/webpack-5.4.0.tgz",
23 - "_shasum": "b68bc86e29cf007292b96ced65f80971175632e0",
24 - "_spec": "@svgr/webpack@5.4.0",
25 - "_where": "C:\\Users\\kkwan_000\\Desktop\\git\\2017110269\\minsung\\node_modules\\react-scripts",
26 - "author": {
27 - "name": "Greg Bergé",
28 - "email": "berge.greg@gmail.com"
29 - },
30 - "bundleDependencies": false,
31 - "dependencies": {
32 - "@babel/core": "^7.9.0",
33 - "@babel/plugin-transform-react-constant-elements": "^7.9.0",
34 - "@babel/preset-env": "^7.9.5",
35 - "@babel/preset-react": "^7.9.4",
36 - "@svgr/core": "^5.4.0",
37 - "@svgr/plugin-jsx": "^5.4.0",
38 - "@svgr/plugin-svgo": "^5.4.0",
39 - "loader-utils": "^2.0.0"
40 - },
41 - "deprecated": false,
42 - "description": "SVGR webpack loader.",
43 - "devDependencies": {
44 - "babel-loader": "^8.0.6",
45 - "memory-fs": "^0.5.0",
46 - "url-loader": "^4.1.0",
47 - "webpack": "^4.43.0"
48 - },
49 - "engines": {
50 - "node": ">=10"
51 - },
52 - "funding": {
53 - "type": "github",
54 - "url": "https://github.com/sponsors/gregberge"
55 - },
56 - "gitHead": "e9c9d2fbfbce7a6879c90cd8522101caf2406d42",
57 - "homepage": "https://react-svgr.com",
58 - "keywords": [
59 - "svgr",
60 - "svg",
61 - "react",
62 - "webpack",
63 - "webpack-loader"
64 - ],
65 - "license": "MIT",
66 - "main": "lib/index.js",
67 - "name": "@svgr/webpack",
68 - "publishConfig": {
69 - "access": "public"
70 - },
71 - "repository": {
72 - "type": "git",
73 - "url": "https://github.com/gregberge/svgr/tree/master/packages/webpack"
74 - },
75 - "scripts": {
76 - "build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
77 - "prebuild": "rm -rf lib/",
78 - "prepublishOnly": "yarn run build"
79 - },
80 - "version": "5.4.0"
81 -}
1 -# CHANGELOG
2 -
3 -The changelog is automatically updated using
4 -[semantic-release](https://github.com/semantic-release/semantic-release). You
5 -can see it on the [releases page](../../releases).
1 -The MIT License (MIT)
2 -Copyright (c) 2017 Kent C. Dodds
3 -
4 -Permission is hereby granted, free of charge, to any person obtaining a copy
5 -of this software and associated documentation files (the "Software"), to deal
6 -in the Software without restriction, including without limitation the rights
7 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 -copies of the Software, and to permit persons to whom the Software is
9 -furnished to do so, subject to the following conditions:
10 -
11 -The above copyright notice and this permission notice shall be included in all
12 -copies or substantial portions of the Software.
13 -
14 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 -SOFTWARE.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.runWithExpensiveErrorDiagnosticsDisabled = runWithExpensiveErrorDiagnosticsDisabled;
7 -exports.configure = configure;
8 -exports.getConfig = getConfig;
9 -exports.DEFAULT_IGNORE_TAGS = void 0;
10 -
11 -var _prettyDom = require("./pretty-dom");
12 -
13 -// It would be cleaner for this to live inside './queries', but
14 -// other parts of the code assume that all exports from
15 -// './queries' are query functions.
16 -let config = {
17 - testIdAttribute: 'data-testid',
18 - asyncUtilTimeout: 1000,
19 - // this is to support React's async `act` function.
20 - // forcing react-testing-library to wrap all async functions would've been
21 - // a total nightmare (consider wrapping every findBy* query and then also
22 - // updating `within` so those would be wrapped too. Total nightmare).
23 - // so we have this config option that's really only intended for
24 - // react-testing-library to use. For that reason, this feature will remain
25 - // undocumented.
26 - asyncWrapper: cb => cb(),
27 - eventWrapper: cb => cb(),
28 - // default value for the `hidden` option in `ByRole` queries
29 - defaultHidden: false,
30 - // showOriginalStackTrace flag to show the full error stack traces for async errors
31 - showOriginalStackTrace: false,
32 - // throw errors w/ suggestions for better queries. Opt in so off by default.
33 - throwSuggestions: false,
34 -
35 - // called when getBy* queries fail. (message, container) => Error
36 - getElementError(message, container) {
37 - const error = new Error([message, (0, _prettyDom.prettyDOM)(container)].filter(Boolean).join('\n\n'));
38 - error.name = 'TestingLibraryElementError';
39 - return error;
40 - },
41 -
42 - _disableExpensiveErrorDiagnostics: false,
43 - computedStyleSupportsPseudoElements: false
44 -};
45 -const DEFAULT_IGNORE_TAGS = 'script, style';
46 -exports.DEFAULT_IGNORE_TAGS = DEFAULT_IGNORE_TAGS;
47 -
48 -function runWithExpensiveErrorDiagnosticsDisabled(callback) {
49 - try {
50 - config._disableExpensiveErrorDiagnostics = true;
51 - return callback();
52 - } finally {
53 - config._disableExpensiveErrorDiagnostics = false;
54 - }
55 -}
56 -
57 -function configure(newConfig) {
58 - if (typeof newConfig === 'function') {
59 - // Pass the existing config out to the provided function
60 - // and accept a delta in return
61 - newConfig = newConfig(config);
62 - } // Merge the incoming config delta
63 -
64 -
65 - config = { ...config,
66 - ...newConfig
67 - };
68 -}
69 -
70 -function getConfig() {
71 - return config;
72 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.fireEvent = fireEvent;
7 -exports.createEvent = createEvent;
8 -
9 -var _config = require("./config");
10 -
11 -var _helpers = require("./helpers");
12 -
13 -var _eventMap = require("./event-map");
14 -
15 -function fireEvent(element, event) {
16 - return (0, _config.getConfig)().eventWrapper(() => {
17 - if (!event) {
18 - throw new Error(`Unable to fire an event - please provide an event object.`);
19 - }
20 -
21 - if (!element) {
22 - throw new Error(`Unable to fire a "${event.type}" event - please provide a DOM element.`);
23 - }
24 -
25 - return element.dispatchEvent(event);
26 - });
27 -}
28 -
29 -function createEvent(eventName, node, init, {
30 - EventType = 'Event',
31 - defaultInit = {}
32 -} = {}) {
33 - if (!node) {
34 - throw new Error(`Unable to fire a "${eventName}" event - please provide a DOM element.`);
35 - }
36 -
37 - const eventInit = { ...defaultInit,
38 - ...init
39 - };
40 - const {
41 - target: {
42 - value,
43 - files,
44 - ...targetProperties
45 - } = {}
46 - } = eventInit;
47 -
48 - if (value !== undefined) {
49 - setNativeValue(node, value);
50 - }
51 -
52 - if (files !== undefined) {
53 - // input.files is a read-only property so this is not allowed:
54 - // input.files = [file]
55 - // so we have to use this workaround to set the property
56 - Object.defineProperty(node, 'files', {
57 - configurable: true,
58 - enumerable: true,
59 - writable: true,
60 - value: files
61 - });
62 - }
63 -
64 - Object.assign(node, targetProperties);
65 - const window = (0, _helpers.getWindowFromNode)(node);
66 - const EventConstructor = window[EventType] || window.Event;
67 - let event;
68 - /* istanbul ignore else */
69 -
70 - if (typeof EventConstructor === 'function') {
71 - event = new EventConstructor(eventName, eventInit);
72 - } else {
73 - // IE11 polyfill from https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
74 - event = window.document.createEvent(EventType);
75 - const {
76 - bubbles,
77 - cancelable,
78 - detail,
79 - ...otherInit
80 - } = eventInit;
81 - event.initEvent(eventName, bubbles, cancelable, detail);
82 - Object.keys(otherInit).forEach(eventKey => {
83 - event[eventKey] = otherInit[eventKey];
84 - });
85 - } // DataTransfer is not supported in jsdom: https://github.com/jsdom/jsdom/issues/1568
86 -
87 -
88 - ['dataTransfer', 'clipboardData'].forEach(dataTransferKey => {
89 - const dataTransferValue = eventInit[dataTransferKey];
90 -
91 - if (typeof dataTransferValue === 'object') {
92 - /* istanbul ignore if */
93 - if (typeof window.DataTransfer === 'function') {
94 - Object.defineProperty(event, dataTransferKey, {
95 - value: Object.getOwnPropertyNames(dataTransferValue).reduce((acc, propName) => {
96 - Object.defineProperty(acc, propName, {
97 - value: dataTransferValue[propName]
98 - });
99 - return acc;
100 - }, new window.DataTransfer())
101 - });
102 - } else {
103 - Object.defineProperty(event, dataTransferKey, {
104 - value: dataTransferValue
105 - });
106 - }
107 - }
108 - });
109 - return event;
110 -}
111 -
112 -Object.keys(_eventMap.eventMap).forEach(key => {
113 - const {
114 - EventType,
115 - defaultInit
116 - } = _eventMap.eventMap[key];
117 - const eventName = key.toLowerCase();
118 -
119 - createEvent[key] = (node, init) => createEvent(eventName, node, init, {
120 - EventType,
121 - defaultInit
122 - });
123 -
124 - fireEvent[key] = (node, init) => fireEvent(node, createEvent[key](node, init));
125 -}); // function written after some investigation here:
126 -// https://github.com/facebook/react/issues/10135#issuecomment-401496776
127 -
128 -function setNativeValue(element, value) {
129 - const {
130 - set: valueSetter
131 - } = Object.getOwnPropertyDescriptor(element, 'value') || {};
132 - const prototype = Object.getPrototypeOf(element);
133 - const {
134 - set: prototypeValueSetter
135 - } = Object.getOwnPropertyDescriptor(prototype, 'value') || {};
136 -
137 - if (prototypeValueSetter && valueSetter !== prototypeValueSetter) {
138 - prototypeValueSetter.call(element, value);
139 - }
140 - /* istanbul ignore next (I don't want to bother) */
141 - else if (valueSetter) {
142 - valueSetter.call(element, value);
143 - } else {
144 - throw new Error('The given element does not have a value setter');
145 - }
146 -}
147 -
148 -Object.keys(_eventMap.eventAliasMap).forEach(aliasKey => {
149 - const key = _eventMap.eventAliasMap[aliasKey];
150 -
151 - fireEvent[aliasKey] = (...args) => fireEvent[key](...args);
152 -});
153 -/* eslint complexity:["error", 9] */
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.getNodeText = getNodeText;
7 -
8 -var _helpers = require("./helpers");
9 -
10 -function getNodeText(node) {
11 - if (node.matches('input[type=submit], input[type=button]')) {
12 - return node.value;
13 - }
14 -
15 - return Array.from(node.childNodes).filter(child => child.nodeType === _helpers.TEXT_NODE && Boolean(child.textContent)).map(c => c.textContent).join('');
16 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4 -
5 -Object.defineProperty(exports, "__esModule", {
6 - value: true
7 -});
8 -exports.getQueriesForElement = getQueriesForElement;
9 -
10 -var defaultQueries = _interopRequireWildcard(require("./queries"));
11 -
12 -/**
13 - * @typedef {{[key: string]: Function}} FuncMap
14 - */
15 -
16 -/**
17 - * @param {HTMLElement} element container
18 - * @param {FuncMap} queries object of functions
19 - * @param {Object} initialValue for reducer
20 - * @returns {FuncMap} returns object of functions bound to container
21 - */
22 -function getQueriesForElement(element, queries = defaultQueries, initialValue = {}) {
23 - return Object.keys(queries).reduce((helpers, key) => {
24 - const fn = queries[key];
25 - helpers[key] = fn.bind(null, element);
26 - return helpers;
27 - }, initialValue);
28 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.getUserCodeFrame = getUserCodeFrame;
7 -// We try to load node dependencies
8 -let chalk = null;
9 -let readFileSync = null;
10 -let codeFrameColumns = null;
11 -
12 -try {
13 - const nodeRequire = module && module.require;
14 - readFileSync = nodeRequire.call(module, 'fs').readFileSync;
15 - codeFrameColumns = nodeRequire.call(module, '@babel/code-frame').codeFrameColumns;
16 - chalk = nodeRequire.call(module, 'chalk');
17 -} catch {// We're in a browser environment
18 -} // frame has the form "at myMethod (location/to/my/file.js:10:2)"
19 -
20 -
21 -function getCodeFrame(frame) {
22 - const locationStart = frame.indexOf('(') + 1;
23 - const locationEnd = frame.indexOf(')');
24 - const frameLocation = frame.slice(locationStart, locationEnd);
25 - const frameLocationElements = frameLocation.split(':');
26 - const [filename, line, column] = [frameLocationElements[0], parseInt(frameLocationElements[1], 10), parseInt(frameLocationElements[2], 10)];
27 - let rawFileContents = '';
28 -
29 - try {
30 - rawFileContents = readFileSync(filename, 'utf-8');
31 - } catch {
32 - return '';
33 - }
34 -
35 - const codeFrame = codeFrameColumns(rawFileContents, {
36 - start: {
37 - line,
38 - column
39 - }
40 - }, {
41 - highlightCode: true,
42 - linesBelow: 0
43 - });
44 - return `${chalk.dim(frameLocation)}\n${codeFrame}\n`;
45 -}
46 -
47 -function getUserCodeFrame() {
48 - // If we couldn't load dependencies, we can't generate the user trace
49 -
50 - /* istanbul ignore next */
51 - if (!readFileSync || !codeFrameColumns) {
52 - return '';
53 - }
54 -
55 - const err = new Error();
56 - const firstClientCodeFrame = err.stack.split('\n').slice(1) // Remove first line which has the form "Error: TypeError"
57 - .find(frame => !frame.includes('node_modules/')); // Ignore frames from 3rd party libraries
58 -
59 - return getCodeFrame(firstClientCodeFrame);
60 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.getWindowFromNode = getWindowFromNode;
7 -exports.getDocument = getDocument;
8 -exports.runWithRealTimers = runWithRealTimers;
9 -exports.checkContainerType = checkContainerType;
10 -exports.TEXT_NODE = exports.jestFakeTimersAreEnabled = exports.setTimeout = exports.setImmediate = exports.clearTimeout = void 0;
11 -const globalObj = typeof window === 'undefined' ? global : window; // Constant node.nodeType for text nodes, see:
12 -// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants
13 -
14 -const TEXT_NODE = 3; // Currently this fn only supports jest timers, but it could support other test runners in the future.
15 -
16 -exports.TEXT_NODE = TEXT_NODE;
17 -
18 -function runWithRealTimers(callback) {
19 - const fakeTimersType = getJestFakeTimersType();
20 -
21 - if (fakeTimersType) {
22 - jest.useRealTimers();
23 - }
24 -
25 - const callbackReturnValue = callback();
26 -
27 - if (fakeTimersType) {
28 - jest.useFakeTimers(fakeTimersType);
29 - }
30 -
31 - return callbackReturnValue;
32 -}
33 -
34 -function getJestFakeTimersType() {
35 - // istanbul ignore if
36 - if (typeof jest === 'undefined' || typeof globalObj.setTimeout === 'undefined') {
37 - return null;
38 - }
39 -
40 - if (typeof globalObj.setTimeout._isMockFunction !== 'undefined' && globalObj.setTimeout._isMockFunction) {
41 - return 'legacy';
42 - }
43 -
44 - if (typeof globalObj.setTimeout.clock !== 'undefined' && typeof jest.getRealSystemTime !== 'undefined') {
45 - try {
46 - // jest.getRealSystemTime is only supported for Jest's `modern` fake timers and otherwise throws
47 - jest.getRealSystemTime();
48 - return 'modern';
49 - } catch {// not using Jest's modern fake timers
50 - }
51 - }
52 -
53 - return null;
54 -}
55 -
56 -const jestFakeTimersAreEnabled = () => Boolean(getJestFakeTimersType()); // we only run our tests in node, and setImmediate is supported in node.
57 -// istanbul ignore next
58 -
59 -
60 -exports.jestFakeTimersAreEnabled = jestFakeTimersAreEnabled;
61 -
62 -function setImmediatePolyfill(fn) {
63 - return globalObj.setTimeout(fn, 0);
64 -}
65 -
66 -function getTimeFunctions() {
67 - // istanbul ignore next
68 - return {
69 - clearTimeoutFn: globalObj.clearTimeout,
70 - setImmediateFn: globalObj.setImmediate || setImmediatePolyfill,
71 - setTimeoutFn: globalObj.setTimeout
72 - };
73 -}
74 -
75 -const {
76 - clearTimeoutFn,
77 - setImmediateFn,
78 - setTimeoutFn
79 -} = runWithRealTimers(getTimeFunctions);
80 -exports.setTimeout = setTimeoutFn;
81 -exports.setImmediate = setImmediateFn;
82 -exports.clearTimeout = clearTimeoutFn;
83 -
84 -function getDocument() {
85 - /* istanbul ignore if */
86 - if (typeof window === 'undefined') {
87 - throw new Error('Could not find default container');
88 - }
89 -
90 - return window.document;
91 -}
92 -
93 -function getWindowFromNode(node) {
94 - if (node.defaultView) {
95 - // node is document
96 - return node.defaultView;
97 - } else if (node.ownerDocument && node.ownerDocument.defaultView) {
98 - // node is a DOM node
99 - return node.ownerDocument.defaultView;
100 - } else if (node.window) {
101 - // node is window
102 - return node.window;
103 - } else if (node.then instanceof Function) {
104 - throw new Error(`It looks like you passed a Promise object instead of a DOM node. Did you do something like \`fireEvent.click(screen.findBy...\` when you meant to use a \`getBy\` query \`fireEvent.click(screen.getBy...\`, or await the findBy query \`fireEvent.click(await screen.findBy...\`?`);
105 - } else {
106 - // The user passed something unusual to a calling function
107 - throw new Error(`Unable to find the "window" object for the given node. Please file an issue with the code that's causing you to see this error: https://github.com/testing-library/dom-testing-library/issues/new`);
108 - }
109 -}
110 -
111 -function checkContainerType(container) {
112 - if (!container || !(typeof container.querySelector === 'function') || !(typeof container.querySelectorAll === 'function')) {
113 - throw new TypeError(`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(container)}.`);
114 - }
115 -
116 - function getTypeName(object) {
117 - if (typeof object === 'object') {
118 - return object === null ? 'null' : object.constructor.name;
119 - }
120 -
121 - return typeof object;
122 - }
123 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4 -
5 -Object.defineProperty(exports, "__esModule", {
6 - value: true
7 -});
8 -var _exportNames = {
9 - within: true,
10 - queries: true,
11 - queryHelpers: true,
12 - getDefaultNormalizer: true,
13 - getRoles: true,
14 - logRoles: true,
15 - isInaccessible: true,
16 - configure: true,
17 - getConfig: true
18 -};
19 -Object.defineProperty(exports, "within", {
20 - enumerable: true,
21 - get: function () {
22 - return _getQueriesForElement.getQueriesForElement;
23 - }
24 -});
25 -Object.defineProperty(exports, "getDefaultNormalizer", {
26 - enumerable: true,
27 - get: function () {
28 - return _matches.getDefaultNormalizer;
29 - }
30 -});
31 -Object.defineProperty(exports, "getRoles", {
32 - enumerable: true,
33 - get: function () {
34 - return _roleHelpers.getRoles;
35 - }
36 -});
37 -Object.defineProperty(exports, "logRoles", {
38 - enumerable: true,
39 - get: function () {
40 - return _roleHelpers.logRoles;
41 - }
42 -});
43 -Object.defineProperty(exports, "isInaccessible", {
44 - enumerable: true,
45 - get: function () {
46 - return _roleHelpers.isInaccessible;
47 - }
48 -});
49 -Object.defineProperty(exports, "configure", {
50 - enumerable: true,
51 - get: function () {
52 - return _config.configure;
53 - }
54 -});
55 -Object.defineProperty(exports, "getConfig", {
56 - enumerable: true,
57 - get: function () {
58 - return _config.getConfig;
59 - }
60 -});
61 -exports.queryHelpers = exports.queries = void 0;
62 -
63 -var _getQueriesForElement = require("./get-queries-for-element");
64 -
65 -Object.keys(_getQueriesForElement).forEach(function (key) {
66 - if (key === "default" || key === "__esModule") return;
67 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
68 - if (key in exports && exports[key] === _getQueriesForElement[key]) return;
69 - Object.defineProperty(exports, key, {
70 - enumerable: true,
71 - get: function () {
72 - return _getQueriesForElement[key];
73 - }
74 - });
75 -});
76 -
77 -var queries = _interopRequireWildcard(require("./queries"));
78 -
79 -exports.queries = queries;
80 -Object.keys(queries).forEach(function (key) {
81 - if (key === "default" || key === "__esModule") return;
82 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
83 - if (key in exports && exports[key] === queries[key]) return;
84 - Object.defineProperty(exports, key, {
85 - enumerable: true,
86 - get: function () {
87 - return queries[key];
88 - }
89 - });
90 -});
91 -
92 -var queryHelpers = _interopRequireWildcard(require("./query-helpers"));
93 -
94 -exports.queryHelpers = queryHelpers;
95 -Object.keys(queryHelpers).forEach(function (key) {
96 - if (key === "default" || key === "__esModule") return;
97 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
98 - if (key in exports && exports[key] === queryHelpers[key]) return;
99 - Object.defineProperty(exports, key, {
100 - enumerable: true,
101 - get: function () {
102 - return queryHelpers[key];
103 - }
104 - });
105 -});
106 -
107 -var _waitFor = require("./wait-for");
108 -
109 -Object.keys(_waitFor).forEach(function (key) {
110 - if (key === "default" || key === "__esModule") return;
111 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
112 - if (key in exports && exports[key] === _waitFor[key]) return;
113 - Object.defineProperty(exports, key, {
114 - enumerable: true,
115 - get: function () {
116 - return _waitFor[key];
117 - }
118 - });
119 -});
120 -
121 -var _waitForElement = require("./wait-for-element");
122 -
123 -Object.keys(_waitForElement).forEach(function (key) {
124 - if (key === "default" || key === "__esModule") return;
125 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
126 - if (key in exports && exports[key] === _waitForElement[key]) return;
127 - Object.defineProperty(exports, key, {
128 - enumerable: true,
129 - get: function () {
130 - return _waitForElement[key];
131 - }
132 - });
133 -});
134 -
135 -var _waitForElementToBeRemoved = require("./wait-for-element-to-be-removed");
136 -
137 -Object.keys(_waitForElementToBeRemoved).forEach(function (key) {
138 - if (key === "default" || key === "__esModule") return;
139 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
140 - if (key in exports && exports[key] === _waitForElementToBeRemoved[key]) return;
141 - Object.defineProperty(exports, key, {
142 - enumerable: true,
143 - get: function () {
144 - return _waitForElementToBeRemoved[key];
145 - }
146 - });
147 -});
148 -
149 -var _waitForDomChange = require("./wait-for-dom-change");
150 -
151 -Object.keys(_waitForDomChange).forEach(function (key) {
152 - if (key === "default" || key === "__esModule") return;
153 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
154 - if (key in exports && exports[key] === _waitForDomChange[key]) return;
155 - Object.defineProperty(exports, key, {
156 - enumerable: true,
157 - get: function () {
158 - return _waitForDomChange[key];
159 - }
160 - });
161 -});
162 -
163 -var _matches = require("./matches");
164 -
165 -var _getNodeText = require("./get-node-text");
166 -
167 -Object.keys(_getNodeText).forEach(function (key) {
168 - if (key === "default" || key === "__esModule") return;
169 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
170 - if (key in exports && exports[key] === _getNodeText[key]) return;
171 - Object.defineProperty(exports, key, {
172 - enumerable: true,
173 - get: function () {
174 - return _getNodeText[key];
175 - }
176 - });
177 -});
178 -
179 -var _events = require("./events");
180 -
181 -Object.keys(_events).forEach(function (key) {
182 - if (key === "default" || key === "__esModule") return;
183 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
184 - if (key in exports && exports[key] === _events[key]) return;
185 - Object.defineProperty(exports, key, {
186 - enumerable: true,
187 - get: function () {
188 - return _events[key];
189 - }
190 - });
191 -});
192 -
193 -var _screen = require("./screen");
194 -
195 -Object.keys(_screen).forEach(function (key) {
196 - if (key === "default" || key === "__esModule") return;
197 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
198 - if (key in exports && exports[key] === _screen[key]) return;
199 - Object.defineProperty(exports, key, {
200 - enumerable: true,
201 - get: function () {
202 - return _screen[key];
203 - }
204 - });
205 -});
206 -
207 -var _roleHelpers = require("./role-helpers");
208 -
209 -var _prettyDom = require("./pretty-dom");
210 -
211 -Object.keys(_prettyDom).forEach(function (key) {
212 - if (key === "default" || key === "__esModule") return;
213 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
214 - if (key in exports && exports[key] === _prettyDom[key]) return;
215 - Object.defineProperty(exports, key, {
216 - enumerable: true,
217 - get: function () {
218 - return _prettyDom[key];
219 - }
220 - });
221 -});
222 -
223 -var _config = require("./config");
224 -
225 -var _suggestions = require("./suggestions");
226 -
227 -Object.keys(_suggestions).forEach(function (key) {
228 - if (key === "default" || key === "__esModule") return;
229 - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
230 - if (key in exports && exports[key] === _suggestions[key]) return;
231 - Object.defineProperty(exports, key, {
232 - enumerable: true,
233 - get: function () {
234 - return _suggestions[key];
235 - }
236 - });
237 -});
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.getLabels = getLabels;
7 -exports.getRealLabels = getRealLabels;
8 -exports.getLabelContent = getLabelContent;
9 -
10 -var _helpers = require("./helpers");
11 -
12 -const labelledNodeNames = ['button', 'meter', 'output', 'progress', 'select', 'textarea', 'input'];
13 -
14 -function getTextContent(node) {
15 - if (labelledNodeNames.includes(node.nodeName.toLowerCase())) {
16 - return '';
17 - }
18 -
19 - if (node.nodeType === _helpers.TEXT_NODE) return node.textContent;
20 - return Array.from(node.childNodes).map(childNode => getTextContent(childNode)).join('');
21 -}
22 -
23 -function getLabelContent(element) {
24 - let textContent;
25 -
26 - if (element.tagName.toLowerCase() === 'label') {
27 - textContent = getTextContent(element);
28 - } else {
29 - textContent = element.value || element.textContent;
30 - }
31 -
32 - return textContent;
33 -} // Based on https://github.com/eps1lon/dom-accessibility-api/pull/352
34 -
35 -
36 -function getRealLabels(element) {
37 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- types are not aware of older browsers that don't implement `labels`
38 - if (element.labels !== undefined) {
39 - var _labels;
40 -
41 - return (_labels = element.labels) != null ? _labels : [];
42 - }
43 -
44 - if (!isLabelable(element)) return [];
45 - const labels = element.ownerDocument.querySelectorAll('label');
46 - return Array.from(labels).filter(label => label.control === element);
47 -}
48 -
49 -function isLabelable(element) {
50 - return /BUTTON|METER|OUTPUT|PROGRESS|SELECT|TEXTAREA/.test(element.tagName) || element.tagName === 'INPUT' && element.getAttribute('type') !== 'hidden';
51 -}
52 -
53 -function getLabels(container, element, {
54 - selector = '*'
55 -} = {}) {
56 - const ariaLabelledBy = element.getAttribute('aria-labelledby');
57 - const labelsId = ariaLabelledBy ? ariaLabelledBy.split(' ') : [];
58 - return labelsId.length ? labelsId.map(labelId => {
59 - const labellingElement = container.querySelector(`[id="${labelId}"]`);
60 - return labellingElement ? {
61 - content: getLabelContent(labellingElement),
62 - formControl: null
63 - } : {
64 - content: '',
65 - formControl: null
66 - };
67 - }) : Array.from(getRealLabels(element)).map(label => {
68 - const textToMatch = getLabelContent(label);
69 - const labelledFormControl = Array.from(label.querySelectorAll('button, input, meter, output, progress, select, textarea')).filter(formControlElement => formControlElement.matches(selector))[0];
70 - return {
71 - content: textToMatch,
72 - formControl: labelledFormControl
73 - };
74 - });
75 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.fuzzyMatches = fuzzyMatches;
7 -exports.matches = matches;
8 -exports.getDefaultNormalizer = getDefaultNormalizer;
9 -exports.makeNormalizer = makeNormalizer;
10 -
11 -function assertNotNullOrUndefined(matcher) {
12 - if (matcher === null || matcher === undefined) {
13 - throw new Error( // eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- implicitly converting `T` to `string`
14 - `It looks like ${matcher} was passed instead of a matcher. Did you do something like getByText(${matcher})?`);
15 - }
16 -}
17 -
18 -function fuzzyMatches(textToMatch, node, matcher, normalizer) {
19 - if (typeof textToMatch !== 'string') {
20 - return false;
21 - }
22 -
23 - assertNotNullOrUndefined(matcher);
24 - const normalizedText = normalizer(textToMatch);
25 -
26 - if (typeof matcher === 'string') {
27 - return normalizedText.toLowerCase().includes(matcher.toLowerCase());
28 - } else if (typeof matcher === 'function') {
29 - return matcher(normalizedText, node);
30 - } else {
31 - return matcher.test(normalizedText);
32 - }
33 -}
34 -
35 -function matches(textToMatch, node, matcher, normalizer) {
36 - if (typeof textToMatch !== 'string') {
37 - return false;
38 - }
39 -
40 - assertNotNullOrUndefined(matcher);
41 - const normalizedText = normalizer(textToMatch);
42 -
43 - if (matcher instanceof Function) {
44 - return matcher(normalizedText, node);
45 - } else if (matcher instanceof RegExp) {
46 - return matcher.test(normalizedText);
47 - } else {
48 - return normalizedText === String(matcher);
49 - }
50 -}
51 -
52 -function getDefaultNormalizer({
53 - trim = true,
54 - collapseWhitespace = true
55 -} = {}) {
56 - return text => {
57 - let normalizedText = text;
58 - normalizedText = trim ? normalizedText.trim() : normalizedText;
59 - normalizedText = collapseWhitespace ? normalizedText.replace(/\s+/g, ' ') : normalizedText;
60 - return normalizedText;
61 - };
62 -}
63 -/**
64 - * Constructs a normalizer to pass to functions in matches.js
65 - * @param {boolean|undefined} trim The user-specified value for `trim`, without
66 - * any defaulting having been applied
67 - * @param {boolean|undefined} collapseWhitespace The user-specified value for
68 - * `collapseWhitespace`, without any defaulting having been applied
69 - * @param {Function|undefined} normalizer The user-specified normalizer
70 - * @returns {Function} A normalizer
71 - */
72 -
73 -
74 -function makeNormalizer({
75 - trim,
76 - collapseWhitespace,
77 - normalizer
78 -}) {
79 - if (normalizer) {
80 - // User has specified a custom normalizer
81 - if (typeof trim !== 'undefined' || typeof collapseWhitespace !== 'undefined') {
82 - // They've also specified a value for trim or collapseWhitespace
83 - throw new Error('trim and collapseWhitespace are not supported with a normalizer. ' + 'If you want to use the default trim and collapseWhitespace logic in your normalizer, ' + 'use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer');
84 - }
85 -
86 - return normalizer;
87 - } else {
88 - // No custom normalizer specified. Just use default.
89 - return getDefaultNormalizer({
90 - trim,
91 - collapseWhitespace
92 - });
93 - }
94 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4 -
5 -Object.defineProperty(exports, "__esModule", {
6 - value: true
7 -});
8 -exports.prettyDOM = prettyDOM;
9 -Object.defineProperty(exports, "prettyFormat", {
10 - enumerable: true,
11 - get: function () {
12 - return _prettyFormat.default;
13 - }
14 -});
15 -exports.logDOM = void 0;
16 -
17 -var _prettyFormat = _interopRequireDefault(require("pretty-format"));
18 -
19 -var _getUserCodeFrame = require("./get-user-code-frame");
20 -
21 -var _helpers = require("./helpers");
22 -
23 -function inCypress(dom) {
24 - const window = dom.ownerDocument && dom.ownerDocument.defaultView || undefined;
25 - return typeof global !== 'undefined' && global.Cypress || typeof window !== 'undefined' && window.Cypress;
26 -}
27 -
28 -const inNode = () => typeof process !== 'undefined' && process.versions !== undefined && process.versions.node !== undefined;
29 -
30 -const getMaxLength = dom => inCypress(dom) ? 0 : typeof process !== 'undefined' && process.env.DEBUG_PRINT_LIMIT || 7000;
31 -
32 -const {
33 - DOMElement,
34 - DOMCollection
35 -} = _prettyFormat.default.plugins;
36 -
37 -function prettyDOM(dom, maxLength, options) {
38 - if (!dom) {
39 - dom = (0, _helpers.getDocument)().body;
40 - }
41 -
42 - if (typeof maxLength !== 'number') {
43 - maxLength = getMaxLength(dom);
44 - }
45 -
46 - if (maxLength === 0) {
47 - return '';
48 - }
49 -
50 - if (dom.documentElement) {
51 - dom = dom.documentElement;
52 - }
53 -
54 - let domTypeName = typeof dom;
55 -
56 - if (domTypeName === 'object') {
57 - domTypeName = dom.constructor.name;
58 - } else {
59 - // To don't fall with `in` operator
60 - dom = {};
61 - }
62 -
63 - if (!('outerHTML' in dom)) {
64 - throw new TypeError(`Expected an element or document but got ${domTypeName}`);
65 - }
66 -
67 - const debugContent = (0, _prettyFormat.default)(dom, {
68 - plugins: [DOMElement, DOMCollection],
69 - printFunctionName: false,
70 - highlight: inNode(),
71 - ...options
72 - });
73 - return maxLength !== undefined && dom.outerHTML.length > maxLength ? `${debugContent.slice(0, maxLength)}...` : debugContent;
74 -}
75 -
76 -const logDOM = (...args) => {
77 - const userCodeFrame = (0, _getUserCodeFrame.getUserCodeFrame)();
78 -
79 - if (userCodeFrame) {
80 - console.log(`${prettyDOM(...args)}\n\n${userCodeFrame}`);
81 - } else {
82 - console.log(prettyDOM(...args));
83 - }
84 -};
85 -
86 -exports.logDOM = logDOM;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -
7 -var _matches = require("../matches");
8 -
9 -Object.keys(_matches).forEach(function (key) {
10 - if (key === "default" || key === "__esModule") return;
11 - if (key in exports && exports[key] === _matches[key]) return;
12 - Object.defineProperty(exports, key, {
13 - enumerable: true,
14 - get: function () {
15 - return _matches[key];
16 - }
17 - });
18 -});
19 -
20 -var _getNodeText = require("../get-node-text");
21 -
22 -Object.keys(_getNodeText).forEach(function (key) {
23 - if (key === "default" || key === "__esModule") return;
24 - if (key in exports && exports[key] === _getNodeText[key]) return;
25 - Object.defineProperty(exports, key, {
26 - enumerable: true,
27 - get: function () {
28 - return _getNodeText[key];
29 - }
30 - });
31 -});
32 -
33 -var _queryHelpers = require("../query-helpers");
34 -
35 -Object.keys(_queryHelpers).forEach(function (key) {
36 - if (key === "default" || key === "__esModule") return;
37 - if (key in exports && exports[key] === _queryHelpers[key]) return;
38 - Object.defineProperty(exports, key, {
39 - enumerable: true,
40 - get: function () {
41 - return _queryHelpers[key];
42 - }
43 - });
44 -});
45 -
46 -var _config = require("../config");
47 -
48 -Object.keys(_config).forEach(function (key) {
49 - if (key === "default" || key === "__esModule") return;
50 - if (key in exports && exports[key] === _config[key]) return;
51 - Object.defineProperty(exports, key, {
52 - enumerable: true,
53 - get: function () {
54 - return _config[key];
55 - }
56 - });
57 -});
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.findByAltText = exports.findAllByAltText = exports.getAllByAltText = exports.getByAltText = exports.queryAllByAltText = exports.queryByAltText = void 0;
7 -
8 -var _queryHelpers = require("../query-helpers");
9 -
10 -var _helpers = require("../helpers");
11 -
12 -var _allUtils = require("./all-utils");
13 -
14 -function queryAllByAltText(container, alt, {
15 - exact = true,
16 - collapseWhitespace,
17 - trim,
18 - normalizer
19 -} = {}) {
20 - (0, _helpers.checkContainerType)(container);
21 - const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
22 - const matchNormalizer = (0, _allUtils.makeNormalizer)({
23 - collapseWhitespace,
24 - trim,
25 - normalizer
26 - });
27 - return Array.from(container.querySelectorAll('img,input,area')).filter(node => matcher(node.getAttribute('alt'), node, alt, matchNormalizer));
28 -}
29 -
30 -const getMultipleError = (c, alt) => `Found multiple elements with the alt text: ${alt}`;
31 -
32 -const getMissingError = (c, alt) => `Unable to find an element with the alt text: ${alt}`;
33 -
34 -const queryAllByAltTextWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByAltText, queryAllByAltText.name, 'queryAll');
35 -exports.queryAllByAltText = queryAllByAltTextWithSuggestions;
36 -const [queryByAltText, getAllByAltText, getByAltText, findAllByAltText, findByAltText] = (0, _allUtils.buildQueries)(queryAllByAltText, getMultipleError, getMissingError);
37 -exports.findByAltText = findByAltText;
38 -exports.findAllByAltText = findAllByAltText;
39 -exports.getByAltText = getByAltText;
40 -exports.getAllByAltText = getAllByAltText;
41 -exports.queryByAltText = queryByAltText;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.findByDisplayValue = exports.findAllByDisplayValue = exports.getAllByDisplayValue = exports.getByDisplayValue = exports.queryAllByDisplayValue = exports.queryByDisplayValue = void 0;
7 -
8 -var _queryHelpers = require("../query-helpers");
9 -
10 -var _helpers = require("../helpers");
11 -
12 -var _allUtils = require("./all-utils");
13 -
14 -function queryAllByDisplayValue(container, value, {
15 - exact = true,
16 - collapseWhitespace,
17 - trim,
18 - normalizer
19 -} = {}) {
20 - (0, _helpers.checkContainerType)(container);
21 - const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
22 - const matchNormalizer = (0, _allUtils.makeNormalizer)({
23 - collapseWhitespace,
24 - trim,
25 - normalizer
26 - });
27 - return Array.from(container.querySelectorAll(`input,textarea,select`)).filter(node => {
28 - if (node.tagName === 'SELECT') {
29 - const selectedOptions = Array.from(node.options).filter(option => option.selected);
30 - return selectedOptions.some(optionNode => matcher((0, _allUtils.getNodeText)(optionNode), optionNode, value, matchNormalizer));
31 - } else {
32 - return matcher(node.value, node, value, matchNormalizer);
33 - }
34 - });
35 -}
36 -
37 -const getMultipleError = (c, value) => `Found multiple elements with the display value: ${value}.`;
38 -
39 -const getMissingError = (c, value) => `Unable to find an element with the display value: ${value}.`;
40 -
41 -const queryAllByDisplayValueWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByDisplayValue, queryAllByDisplayValue.name, 'queryAll');
42 -exports.queryAllByDisplayValue = queryAllByDisplayValueWithSuggestions;
43 -const [queryByDisplayValue, getAllByDisplayValue, getByDisplayValue, findAllByDisplayValue, findByDisplayValue] = (0, _allUtils.buildQueries)(queryAllByDisplayValue, getMultipleError, getMissingError);
44 -exports.findByDisplayValue = findByDisplayValue;
45 -exports.findAllByDisplayValue = findAllByDisplayValue;
46 -exports.getByDisplayValue = getByDisplayValue;
47 -exports.getAllByDisplayValue = getAllByDisplayValue;
48 -exports.queryByDisplayValue = queryByDisplayValue;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -
7 -var _labelText = require("./label-text");
8 -
9 -Object.keys(_labelText).forEach(function (key) {
10 - if (key === "default" || key === "__esModule") return;
11 - if (key in exports && exports[key] === _labelText[key]) return;
12 - Object.defineProperty(exports, key, {
13 - enumerable: true,
14 - get: function () {
15 - return _labelText[key];
16 - }
17 - });
18 -});
19 -
20 -var _placeholderText = require("./placeholder-text");
21 -
22 -Object.keys(_placeholderText).forEach(function (key) {
23 - if (key === "default" || key === "__esModule") return;
24 - if (key in exports && exports[key] === _placeholderText[key]) return;
25 - Object.defineProperty(exports, key, {
26 - enumerable: true,
27 - get: function () {
28 - return _placeholderText[key];
29 - }
30 - });
31 -});
32 -
33 -var _text = require("./text");
34 -
35 -Object.keys(_text).forEach(function (key) {
36 - if (key === "default" || key === "__esModule") return;
37 - if (key in exports && exports[key] === _text[key]) return;
38 - Object.defineProperty(exports, key, {
39 - enumerable: true,
40 - get: function () {
41 - return _text[key];
42 - }
43 - });
44 -});
45 -
46 -var _displayValue = require("./display-value");
47 -
48 -Object.keys(_displayValue).forEach(function (key) {
49 - if (key === "default" || key === "__esModule") return;
50 - if (key in exports && exports[key] === _displayValue[key]) return;
51 - Object.defineProperty(exports, key, {
52 - enumerable: true,
53 - get: function () {
54 - return _displayValue[key];
55 - }
56 - });
57 -});
58 -
59 -var _altText = require("./alt-text");
60 -
61 -Object.keys(_altText).forEach(function (key) {
62 - if (key === "default" || key === "__esModule") return;
63 - if (key in exports && exports[key] === _altText[key]) return;
64 - Object.defineProperty(exports, key, {
65 - enumerable: true,
66 - get: function () {
67 - return _altText[key];
68 - }
69 - });
70 -});
71 -
72 -var _title = require("./title");
73 -
74 -Object.keys(_title).forEach(function (key) {
75 - if (key === "default" || key === "__esModule") return;
76 - if (key in exports && exports[key] === _title[key]) return;
77 - Object.defineProperty(exports, key, {
78 - enumerable: true,
79 - get: function () {
80 - return _title[key];
81 - }
82 - });
83 -});
84 -
85 -var _role = require("./role");
86 -
87 -Object.keys(_role).forEach(function (key) {
88 - if (key === "default" || key === "__esModule") return;
89 - if (key in exports && exports[key] === _role[key]) return;
90 - Object.defineProperty(exports, key, {
91 - enumerable: true,
92 - get: function () {
93 - return _role[key];
94 - }
95 - });
96 -});
97 -
98 -var _testId = require("./test-id");
99 -
100 -Object.keys(_testId).forEach(function (key) {
101 - if (key === "default" || key === "__esModule") return;
102 - if (key in exports && exports[key] === _testId[key]) return;
103 - Object.defineProperty(exports, key, {
104 - enumerable: true,
105 - get: function () {
106 - return _testId[key];
107 - }
108 - });
109 -});
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.findByLabelText = exports.findAllByLabelText = exports.getByLabelText = exports.getAllByLabelText = exports.queryByLabelText = exports.queryAllByLabelText = void 0;
7 -
8 -var _config = require("../config");
9 -
10 -var _helpers = require("../helpers");
11 -
12 -var _labelHelpers = require("../label-helpers");
13 -
14 -var _allUtils = require("./all-utils");
15 -
16 -function queryAllLabels(container) {
17 - return Array.from(container.querySelectorAll('label,input')).map(node => {
18 - return {
19 - node,
20 - textToMatch: (0, _labelHelpers.getLabelContent)(node)
21 - };
22 - }).filter(({
23 - textToMatch
24 - }) => textToMatch !== null);
25 -}
26 -
27 -function queryAllLabelsByText(container, text, {
28 - exact = true,
29 - trim,
30 - collapseWhitespace,
31 - normalizer
32 -} = {}) {
33 - const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
34 - const matchNormalizer = (0, _allUtils.makeNormalizer)({
35 - collapseWhitespace,
36 - trim,
37 - normalizer
38 - });
39 - const textToMatchByLabels = queryAllLabels(container);
40 - return textToMatchByLabels.filter(({
41 - node,
42 - textToMatch
43 - }) => matcher(textToMatch, node, text, matchNormalizer)).map(({
44 - node
45 - }) => node);
46 -}
47 -
48 -function queryAllByLabelText(container, text, {
49 - selector = '*',
50 - exact = true,
51 - collapseWhitespace,
52 - trim,
53 - normalizer
54 -} = {}) {
55 - (0, _helpers.checkContainerType)(container);
56 - const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
57 - const matchNormalizer = (0, _allUtils.makeNormalizer)({
58 - collapseWhitespace,
59 - trim,
60 - normalizer
61 - });
62 - const matchingLabelledElements = Array.from(container.querySelectorAll('*')).filter(element => {
63 - return (0, _labelHelpers.getRealLabels)(element).length || element.hasAttribute('aria-labelledby');
64 - }).reduce((labelledElements, labelledElement) => {
65 - const labelList = (0, _labelHelpers.getLabels)(container, labelledElement, {
66 - selector
67 - });
68 - labelList.filter(label => Boolean(label.formControl)).forEach(label => {
69 - if (matcher(label.content, label.formControl, text, matchNormalizer)) labelledElements.push(label.formControl);
70 - });
71 - const labelsValue = labelList.filter(label => Boolean(label.content)).map(label => label.content);
72 - if (matcher(labelsValue.join(' '), labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
73 -
74 - if (labelsValue.length > 1) {
75 - labelsValue.forEach((labelValue, index) => {
76 - if (matcher(labelValue, labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
77 - const labelsFiltered = [...labelsValue];
78 - labelsFiltered.splice(index, 1);
79 -
80 - if (labelsFiltered.length > 1) {
81 - if (matcher(labelsFiltered.join(' '), labelledElement, text, matchNormalizer)) labelledElements.push(labelledElement);
82 - }
83 - });
84 - }
85 -
86 - return labelledElements;
87 - }, []).concat((0, _allUtils.queryAllByAttribute)('aria-label', container, text, {
88 - exact
89 - }));
90 - return Array.from(new Set(matchingLabelledElements)).filter(element => element.matches(selector));
91 -} // the getAll* query would normally look like this:
92 -// const getAllByLabelText = makeGetAllQuery(
93 -// queryAllByLabelText,
94 -// (c, text) => `Unable to find a label with the text of: ${text}`,
95 -// )
96 -// however, we can give a more helpful error message than the generic one,
97 -// so we're writing this one out by hand.
98 -
99 -
100 -const getAllByLabelText = (container, text, ...rest) => {
101 - const els = queryAllByLabelText(container, text, ...rest);
102 -
103 - if (!els.length) {
104 - const labels = queryAllLabelsByText(container, text, ...rest);
105 -
106 - if (labels.length) {
107 - const tagNames = labels.map(label => getTagNameOfElementAssociatedWithLabelViaFor(container, label)).filter(tagName => !!tagName);
108 -
109 - if (tagNames.length) {
110 - throw (0, _config.getConfig)().getElementError(tagNames.map(tagName => `Found a label with the text of: ${text}, however the element associated with this label (<${tagName} />) is non-labellable [https://html.spec.whatwg.org/multipage/forms.html#category-label]. If you really need to label a <${tagName} />, you can use aria-label or aria-labelledby instead.`).join('\n\n'), container);
111 - } else {
112 - throw (0, _config.getConfig)().getElementError(`Found a label with the text of: ${text}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`, container);
113 - }
114 - } else {
115 - throw (0, _config.getConfig)().getElementError(`Unable to find a label with the text of: ${text}`, container);
116 - }
117 - }
118 -
119 - return els;
120 -};
121 -
122 -function getTagNameOfElementAssociatedWithLabelViaFor(container, label) {
123 - const htmlFor = label.getAttribute('for');
124 -
125 - if (!htmlFor) {
126 - return null;
127 - }
128 -
129 - const element = container.querySelector(`[id="${htmlFor}"]`);
130 - return element ? element.tagName.toLowerCase() : null;
131 -} // the reason mentioned above is the same reason we're not using buildQueries
132 -
133 -
134 -const getMultipleError = (c, text) => `Found multiple elements with the text of: ${text}`;
135 -
136 -const queryByLabelText = (0, _allUtils.wrapSingleQueryWithSuggestion)((0, _allUtils.makeSingleQuery)(queryAllByLabelText, getMultipleError), queryAllByLabelText.name, 'query');
137 -exports.queryByLabelText = queryByLabelText;
138 -const getByLabelText = (0, _allUtils.makeSingleQuery)(getAllByLabelText, getMultipleError);
139 -const findAllByLabelText = (0, _allUtils.makeFindQuery)((0, _allUtils.wrapAllByQueryWithSuggestion)(getAllByLabelText, getAllByLabelText.name, 'findAll'));
140 -exports.findAllByLabelText = findAllByLabelText;
141 -const findByLabelText = (0, _allUtils.makeFindQuery)((0, _allUtils.wrapSingleQueryWithSuggestion)(getByLabelText, getAllByLabelText.name, 'find'));
142 -exports.findByLabelText = findByLabelText;
143 -const getAllByLabelTextWithSuggestions = (0, _allUtils.wrapAllByQueryWithSuggestion)(getAllByLabelText, getAllByLabelText.name, 'getAll');
144 -exports.getAllByLabelText = getAllByLabelTextWithSuggestions;
145 -const getByLabelTextWithSuggestions = (0, _allUtils.wrapSingleQueryWithSuggestion)(getByLabelText, getAllByLabelText.name, 'get');
146 -exports.getByLabelText = getByLabelTextWithSuggestions;
147 -const queryAllByLabelTextWithSuggestions = (0, _allUtils.wrapAllByQueryWithSuggestion)(queryAllByLabelText, queryAllByLabelText.name, 'queryAll');
148 -exports.queryAllByLabelText = queryAllByLabelTextWithSuggestions;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.findByPlaceholderText = exports.findAllByPlaceholderText = exports.getAllByPlaceholderText = exports.getByPlaceholderText = exports.queryAllByPlaceholderText = exports.queryByPlaceholderText = void 0;
7 -
8 -var _queryHelpers = require("../query-helpers");
9 -
10 -var _helpers = require("../helpers");
11 -
12 -var _allUtils = require("./all-utils");
13 -
14 -function queryAllByPlaceholderText(...args) {
15 - (0, _helpers.checkContainerType)(...args);
16 - return (0, _allUtils.queryAllByAttribute)('placeholder', ...args);
17 -}
18 -
19 -const getMultipleError = (c, text) => `Found multiple elements with the placeholder text of: ${text}`;
20 -
21 -const getMissingError = (c, text) => `Unable to find an element with the placeholder text of: ${text}`;
22 -
23 -const queryAllByPlaceholderTextWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByPlaceholderText, queryAllByPlaceholderText.name, 'queryAll');
24 -exports.queryAllByPlaceholderText = queryAllByPlaceholderTextWithSuggestions;
25 -const [queryByPlaceholderText, getAllByPlaceholderText, getByPlaceholderText, findAllByPlaceholderText, findByPlaceholderText] = (0, _allUtils.buildQueries)(queryAllByPlaceholderText, getMultipleError, getMissingError);
26 -exports.findByPlaceholderText = findByPlaceholderText;
27 -exports.findAllByPlaceholderText = findAllByPlaceholderText;
28 -exports.getByPlaceholderText = getByPlaceholderText;
29 -exports.getAllByPlaceholderText = getAllByPlaceholderText;
30 -exports.queryByPlaceholderText = queryByPlaceholderText;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.findByRole = exports.findAllByRole = exports.getByRole = exports.getAllByRole = exports.queryAllByRole = exports.queryByRole = void 0;
7 -
8 -var _domAccessibilityApi = require("dom-accessibility-api");
9 -
10 -var _ariaQuery = require("aria-query");
11 -
12 -var _roleHelpers = require("../role-helpers");
13 -
14 -var _queryHelpers = require("../query-helpers");
15 -
16 -var _helpers = require("../helpers");
17 -
18 -var _allUtils = require("./all-utils");
19 -
20 -function queryAllByRole(container, role, {
21 - exact = true,
22 - collapseWhitespace,
23 - hidden = (0, _allUtils.getConfig)().defaultHidden,
24 - name,
25 - trim,
26 - normalizer,
27 - queryFallbacks = false,
28 - selected,
29 - checked,
30 - pressed,
31 - level,
32 - expanded
33 -} = {}) {
34 - (0, _helpers.checkContainerType)(container);
35 - const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
36 - const matchNormalizer = (0, _allUtils.makeNormalizer)({
37 - collapseWhitespace,
38 - trim,
39 - normalizer
40 - });
41 -
42 - if (selected !== undefined) {
43 - var _allRoles$get;
44 -
45 - // guard against unknown roles
46 - if (((_allRoles$get = _ariaQuery.roles.get(role)) == null ? void 0 : _allRoles$get.props['aria-selected']) === undefined) {
47 - throw new Error(`"aria-selected" is not supported on role "${role}".`);
48 - }
49 - }
50 -
51 - if (checked !== undefined) {
52 - var _allRoles$get2;
53 -
54 - // guard against unknown roles
55 - if (((_allRoles$get2 = _ariaQuery.roles.get(role)) == null ? void 0 : _allRoles$get2.props['aria-checked']) === undefined) {
56 - throw new Error(`"aria-checked" is not supported on role "${role}".`);
57 - }
58 - }
59 -
60 - if (pressed !== undefined) {
61 - var _allRoles$get3;
62 -
63 - // guard against unknown roles
64 - if (((_allRoles$get3 = _ariaQuery.roles.get(role)) == null ? void 0 : _allRoles$get3.props['aria-pressed']) === undefined) {
65 - throw new Error(`"aria-pressed" is not supported on role "${role}".`);
66 - }
67 - }
68 -
69 - if (level !== undefined) {
70 - // guard against using `level` option with any role other than `heading`
71 - if (role !== 'heading') {
72 - throw new Error(`Role "${role}" cannot have "level" property.`);
73 - }
74 - }
75 -
76 - if (expanded !== undefined) {
77 - var _allRoles$get4;
78 -
79 - // guard against unknown roles
80 - if (((_allRoles$get4 = _ariaQuery.roles.get(role)) == null ? void 0 : _allRoles$get4.props['aria-expanded']) === undefined) {
81 - throw new Error(`"aria-expanded" is not supported on role "${role}".`);
82 - }
83 - }
84 -
85 - const subtreeIsInaccessibleCache = new WeakMap();
86 -
87 - function cachedIsSubtreeInaccessible(element) {
88 - if (!subtreeIsInaccessibleCache.has(element)) {
89 - subtreeIsInaccessibleCache.set(element, (0, _roleHelpers.isSubtreeInaccessible)(element));
90 - }
91 -
92 - return subtreeIsInaccessibleCache.get(element);
93 - }
94 -
95 - return Array.from(container.querySelectorAll('*')).filter(node => {
96 - const isRoleSpecifiedExplicitly = node.hasAttribute('role');
97 -
98 - if (isRoleSpecifiedExplicitly) {
99 - const roleValue = node.getAttribute('role');
100 -
101 - if (queryFallbacks) {
102 - return roleValue.split(' ').filter(Boolean).some(text => matcher(text, node, role, matchNormalizer));
103 - } // if a custom normalizer is passed then let normalizer handle the role value
104 -
105 -
106 - if (normalizer) {
107 - return matcher(roleValue, node, role, matchNormalizer);
108 - } // other wise only send the first word to match
109 -
110 -
111 - const [firstWord] = roleValue.split(' ');
112 - return matcher(firstWord, node, role, matchNormalizer);
113 - }
114 -
115 - const implicitRoles = (0, _roleHelpers.getImplicitAriaRoles)(node);
116 - return implicitRoles.some(implicitRole => matcher(implicitRole, node, role, matchNormalizer));
117 - }).filter(element => {
118 - if (selected !== undefined) {
119 - return selected === (0, _roleHelpers.computeAriaSelected)(element);
120 - }
121 -
122 - if (checked !== undefined) {
123 - return checked === (0, _roleHelpers.computeAriaChecked)(element);
124 - }
125 -
126 - if (pressed !== undefined) {
127 - return pressed === (0, _roleHelpers.computeAriaPressed)(element);
128 - }
129 -
130 - if (expanded !== undefined) {
131 - return expanded === (0, _roleHelpers.computeAriaExpanded)(element);
132 - }
133 -
134 - if (level !== undefined) {
135 - return level === (0, _roleHelpers.computeHeadingLevel)(element);
136 - } // don't care if aria attributes are unspecified
137 -
138 -
139 - return true;
140 - }).filter(element => {
141 - return hidden === false ? (0, _roleHelpers.isInaccessible)(element, {
142 - isSubtreeInaccessible: cachedIsSubtreeInaccessible
143 - }) === false : true;
144 - }).filter(element => {
145 - if (name === undefined) {
146 - // Don't care
147 - return true;
148 - }
149 -
150 - return (0, _allUtils.matches)((0, _domAccessibilityApi.computeAccessibleName)(element, {
151 - computedStyleSupportsPseudoElements: (0, _allUtils.getConfig)().computedStyleSupportsPseudoElements
152 - }), element, name, text => text);
153 - });
154 -}
155 -
156 -const getMultipleError = (c, role, {
157 - name
158 -} = {}) => {
159 - let nameHint = '';
160 -
161 - if (name === undefined) {
162 - nameHint = '';
163 - } else if (typeof name === 'string') {
164 - nameHint = ` and name "${name}"`;
165 - } else {
166 - nameHint = ` and name \`${name}\``;
167 - }
168 -
169 - return `Found multiple elements with the role "${role}"${nameHint}`;
170 -};
171 -
172 -const getMissingError = (container, role, {
173 - hidden = (0, _allUtils.getConfig)().defaultHidden,
174 - name
175 -} = {}) => {
176 - if ((0, _allUtils.getConfig)()._disableExpensiveErrorDiagnostics) {
177 - return `Unable to find role="${role}"`;
178 - }
179 -
180 - let roles = '';
181 - Array.from(container.children).forEach(childElement => {
182 - roles += (0, _roleHelpers.prettyRoles)(childElement, {
183 - hidden,
184 - includeName: name !== undefined
185 - });
186 - });
187 - let roleMessage;
188 -
189 - if (roles.length === 0) {
190 - if (hidden === false) {
191 - roleMessage = 'There are no accessible roles. But there might be some inaccessible roles. ' + 'If you wish to access them, then set the `hidden` option to `true`. ' + 'Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole';
192 - } else {
193 - roleMessage = 'There are no available roles.';
194 - }
195 - } else {
196 - roleMessage = `
197 -Here are the ${hidden === false ? 'accessible' : 'available'} roles:
198 -
199 - ${roles.replace(/\n/g, '\n ').replace(/\n\s\s\n/g, '\n\n')}
200 -`.trim();
201 - }
202 -
203 - let nameHint = '';
204 -
205 - if (name === undefined) {
206 - nameHint = '';
207 - } else if (typeof name === 'string') {
208 - nameHint = ` and name "${name}"`;
209 - } else {
210 - nameHint = ` and name \`${name}\``;
211 - }
212 -
213 - return `
214 -Unable to find an ${hidden === false ? 'accessible ' : ''}element with the role "${role}"${nameHint}
215 -
216 -${roleMessage}`.trim();
217 -};
218 -
219 -const queryAllByRoleWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByRole, queryAllByRole.name, 'queryAll');
220 -exports.queryAllByRole = queryAllByRoleWithSuggestions;
221 -const [queryByRole, getAllByRole, getByRole, findAllByRole, findByRole] = (0, _allUtils.buildQueries)(queryAllByRole, getMultipleError, getMissingError);
222 -exports.findByRole = findByRole;
223 -exports.findAllByRole = findAllByRole;
224 -exports.getByRole = getByRole;
225 -exports.getAllByRole = getAllByRole;
226 -exports.queryByRole = queryByRole;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.findByTestId = exports.findAllByTestId = exports.getAllByTestId = exports.getByTestId = exports.queryAllByTestId = exports.queryByTestId = void 0;
7 -
8 -var _helpers = require("../helpers");
9 -
10 -var _queryHelpers = require("../query-helpers");
11 -
12 -var _allUtils = require("./all-utils");
13 -
14 -const getTestIdAttribute = () => (0, _allUtils.getConfig)().testIdAttribute;
15 -
16 -function queryAllByTestId(...args) {
17 - (0, _helpers.checkContainerType)(...args);
18 - return (0, _allUtils.queryAllByAttribute)(getTestIdAttribute(), ...args);
19 -}
20 -
21 -const getMultipleError = (c, id) => `Found multiple elements by: [${getTestIdAttribute()}="${id}"]`;
22 -
23 -const getMissingError = (c, id) => `Unable to find an element by: [${getTestIdAttribute()}="${id}"]`;
24 -
25 -const queryAllByTestIdWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByTestId, queryAllByTestId.name, 'queryAll');
26 -exports.queryAllByTestId = queryAllByTestIdWithSuggestions;
27 -const [queryByTestId, getAllByTestId, getByTestId, findAllByTestId, findByTestId] = (0, _allUtils.buildQueries)(queryAllByTestId, getMultipleError, getMissingError);
28 -exports.findByTestId = findByTestId;
29 -exports.findAllByTestId = findAllByTestId;
30 -exports.getByTestId = getByTestId;
31 -exports.getAllByTestId = getAllByTestId;
32 -exports.queryByTestId = queryByTestId;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.findByText = exports.findAllByText = exports.getAllByText = exports.getByText = exports.queryAllByText = exports.queryByText = void 0;
7 -
8 -var _queryHelpers = require("../query-helpers");
9 -
10 -var _helpers = require("../helpers");
11 -
12 -var _config = require("../config");
13 -
14 -var _allUtils = require("./all-utils");
15 -
16 -function queryAllByText(container, text, {
17 - selector = '*',
18 - exact = true,
19 - collapseWhitespace,
20 - trim,
21 - ignore = _config.DEFAULT_IGNORE_TAGS,
22 - normalizer
23 -} = {}) {
24 - (0, _helpers.checkContainerType)(container);
25 - const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
26 - const matchNormalizer = (0, _allUtils.makeNormalizer)({
27 - collapseWhitespace,
28 - trim,
29 - normalizer
30 - });
31 - let baseArray = [];
32 -
33 - if (typeof container.matches === 'function' && container.matches(selector)) {
34 - baseArray = [container];
35 - }
36 -
37 - return [...baseArray, ...Array.from(container.querySelectorAll(selector))].filter(node => !ignore || !node.matches(ignore)).filter(node => matcher((0, _allUtils.getNodeText)(node), node, text, matchNormalizer));
38 -}
39 -
40 -const getMultipleError = (c, text) => `Found multiple elements with the text: ${text}`;
41 -
42 -const getMissingError = (c, text) => `Unable to find an element with the text: ${text}. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.`;
43 -
44 -const queryAllByTextWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByText, queryAllByText.name, 'queryAll');
45 -exports.queryAllByText = queryAllByTextWithSuggestions;
46 -const [queryByText, getAllByText, getByText, findAllByText, findByText] = (0, _allUtils.buildQueries)(queryAllByText, getMultipleError, getMissingError);
47 -exports.findByText = findByText;
48 -exports.findAllByText = findAllByText;
49 -exports.getByText = getByText;
50 -exports.getAllByText = getAllByText;
51 -exports.queryByText = queryByText;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.findByTitle = exports.findAllByTitle = exports.getAllByTitle = exports.getByTitle = exports.queryAllByTitle = exports.queryByTitle = void 0;
7 -
8 -var _queryHelpers = require("../query-helpers");
9 -
10 -var _helpers = require("../helpers");
11 -
12 -var _allUtils = require("./all-utils");
13 -
14 -const isSvgTitle = node => {
15 - var _node$parentElement;
16 -
17 - return node.tagName.toLowerCase() === 'title' && ((_node$parentElement = node.parentElement) == null ? void 0 : _node$parentElement.tagName.toLowerCase()) === 'svg';
18 -};
19 -
20 -function queryAllByTitle(container, text, {
21 - exact = true,
22 - collapseWhitespace,
23 - trim,
24 - normalizer
25 -} = {}) {
26 - (0, _helpers.checkContainerType)(container);
27 - const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
28 - const matchNormalizer = (0, _allUtils.makeNormalizer)({
29 - collapseWhitespace,
30 - trim,
31 - normalizer
32 - });
33 - return Array.from(container.querySelectorAll('[title], svg > title')).filter(node => matcher(node.getAttribute('title'), node, text, matchNormalizer) || isSvgTitle(node) && matcher((0, _allUtils.getNodeText)(node), node, text, matchNormalizer));
34 -}
35 -
36 -const getMultipleError = (c, title) => `Found multiple elements with the title: ${title}.`;
37 -
38 -const getMissingError = (c, title) => `Unable to find an element with the title: ${title}.`;
39 -
40 -const queryAllByTitleWithSuggestions = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByTitle, queryAllByTitle.name, 'queryAll');
41 -exports.queryAllByTitle = queryAllByTitleWithSuggestions;
42 -const [queryByTitle, getAllByTitle, getByTitle, findAllByTitle, findByTitle] = (0, _allUtils.buildQueries)(queryAllByTitle, getMultipleError, getMissingError);
43 -exports.findByTitle = findByTitle;
44 -exports.findAllByTitle = findAllByTitle;
45 -exports.getByTitle = getByTitle;
46 -exports.getAllByTitle = getAllByTitle;
47 -exports.queryByTitle = queryByTitle;
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.getElementError = getElementError;
7 -exports.getMultipleElementsFoundError = getMultipleElementsFoundError;
8 -exports.queryAllByAttribute = queryAllByAttribute;
9 -exports.queryByAttribute = queryByAttribute;
10 -exports.makeSingleQuery = makeSingleQuery;
11 -exports.makeGetAllQuery = makeGetAllQuery;
12 -exports.makeFindQuery = makeFindQuery;
13 -exports.buildQueries = buildQueries;
14 -exports.wrapSingleQueryWithSuggestion = exports.wrapAllByQueryWithSuggestion = void 0;
15 -
16 -var _suggestions = require("./suggestions");
17 -
18 -var _matches = require("./matches");
19 -
20 -var _waitFor = require("./wait-for");
21 -
22 -var _config = require("./config");
23 -
24 -function getElementError(message, container) {
25 - return (0, _config.getConfig)().getElementError(message, container);
26 -}
27 -
28 -function getMultipleElementsFoundError(message, container) {
29 - return getElementError(`${message}\n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).`, container);
30 -}
31 -
32 -function queryAllByAttribute(attribute, container, text, {
33 - exact = true,
34 - collapseWhitespace,
35 - trim,
36 - normalizer
37 -} = {}) {
38 - const matcher = exact ? _matches.matches : _matches.fuzzyMatches;
39 - const matchNormalizer = (0, _matches.makeNormalizer)({
40 - collapseWhitespace,
41 - trim,
42 - normalizer
43 - });
44 - return Array.from(container.querySelectorAll(`[${attribute}]`)).filter(node => matcher(node.getAttribute(attribute), node, text, matchNormalizer));
45 -}
46 -
47 -function queryByAttribute(attribute, container, text, ...args) {
48 - const els = queryAllByAttribute(attribute, container, text, ...args);
49 -
50 - if (els.length > 1) {
51 - throw getMultipleElementsFoundError(`Found multiple elements by [${attribute}=${text}]`, container);
52 - }
53 -
54 - return els[0] || null;
55 -} // this accepts a query function and returns a function which throws an error
56 -// if more than one elements is returned, otherwise it returns the first
57 -// element or null
58 -
59 -
60 -function makeSingleQuery(allQuery, getMultipleError) {
61 - return (container, ...args) => {
62 - const els = allQuery(container, ...args);
63 -
64 - if (els.length > 1) {
65 - const elementStrings = els.map(element => getElementError(null, element).message).join('\n\n');
66 - throw getMultipleElementsFoundError(`${getMultipleError(container, ...args)}
67 -
68 -Here are the matching elements:
69 -
70 -${elementStrings}`, container);
71 - }
72 -
73 - return els[0] || null;
74 - };
75 -}
76 -
77 -function getSuggestionError(suggestion, container) {
78 - return (0, _config.getConfig)().getElementError(`A better query is available, try this:
79 -${suggestion.toString()}
80 -`, container);
81 -} // this accepts a query function and returns a function which throws an error
82 -// if an empty list of elements is returned
83 -
84 -
85 -function makeGetAllQuery(allQuery, getMissingError) {
86 - return (container, ...args) => {
87 - const els = allQuery(container, ...args);
88 -
89 - if (!els.length) {
90 - throw (0, _config.getConfig)().getElementError(getMissingError(container, ...args), container);
91 - }
92 -
93 - return els;
94 - };
95 -} // this accepts a getter query function and returns a function which calls
96 -// waitFor and passing a function which invokes the getter.
97 -
98 -
99 -function makeFindQuery(getter) {
100 - return (container, text, options, waitForOptions) => (0, _waitFor.waitFor)(() => {
101 - return getter(container, text, options);
102 - }, waitForOptions);
103 -}
104 -
105 -const wrapSingleQueryWithSuggestion = (query, queryAllByName, variant) => (container, ...args) => {
106 - const element = query(container, ...args);
107 - const [{
108 - suggest = (0, _config.getConfig)().throwSuggestions
109 - } = {}] = args.slice(-1);
110 -
111 - if (element && suggest) {
112 - const suggestion = (0, _suggestions.getSuggestedQuery)(element, variant);
113 -
114 - if (suggestion && !queryAllByName.endsWith(suggestion.queryName)) {
115 - throw getSuggestionError(suggestion.toString(), container);
116 - }
117 - }
118 -
119 - return element;
120 -};
121 -
122 -exports.wrapSingleQueryWithSuggestion = wrapSingleQueryWithSuggestion;
123 -
124 -const wrapAllByQueryWithSuggestion = (query, queryAllByName, variant) => (container, ...args) => {
125 - const els = query(container, ...args);
126 - const [{
127 - suggest = (0, _config.getConfig)().throwSuggestions
128 - } = {}] = args.slice(-1);
129 -
130 - if (els.length && suggest) {
131 - // get a unique list of all suggestion messages. We are only going to make a suggestion if
132 - // all the suggestions are the same
133 - const uniqueSuggestionMessages = [...new Set(els.map(element => {
134 - var _getSuggestedQuery;
135 -
136 - return (_getSuggestedQuery = (0, _suggestions.getSuggestedQuery)(element, variant)) == null ? void 0 : _getSuggestedQuery.toString();
137 - }))];
138 -
139 - if ( // only want to suggest if all the els have the same suggestion.
140 - uniqueSuggestionMessages.length === 1 && !queryAllByName.endsWith((0, _suggestions.getSuggestedQuery)(els[0], variant).queryName)) {
141 - throw getSuggestionError(uniqueSuggestionMessages[0], container);
142 - }
143 - }
144 -
145 - return els;
146 -};
147 -
148 -exports.wrapAllByQueryWithSuggestion = wrapAllByQueryWithSuggestion;
149 -
150 -function buildQueries(queryAllBy, getMultipleError, getMissingError) {
151 - const queryBy = wrapSingleQueryWithSuggestion(makeSingleQuery(queryAllBy, getMultipleError), queryAllBy.name, 'query');
152 - const getAllBy = makeGetAllQuery(queryAllBy, getMissingError);
153 - const getBy = makeSingleQuery(getAllBy, getMultipleError);
154 - const getByWithSuggestions = wrapSingleQueryWithSuggestion(getBy, queryAllBy.name, 'get');
155 - const getAllWithSuggestions = wrapAllByQueryWithSuggestion(getAllBy, queryAllBy.name.replace('query', 'get'), 'getAll');
156 - const findAllBy = makeFindQuery(wrapAllByQueryWithSuggestion(getAllBy, queryAllBy.name, 'findAll'));
157 - const findBy = makeFindQuery(wrapSingleQueryWithSuggestion(getBy, queryAllBy.name, 'find'));
158 - return [queryBy, getAllWithSuggestions, getByWithSuggestions, findAllBy, findBy];
159 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -Object.defineProperty(exports, "__esModule", {
4 - value: true
5 -});
6 -exports.getRoles = getRoles;
7 -exports.getImplicitAriaRoles = getImplicitAriaRoles;
8 -exports.isSubtreeInaccessible = isSubtreeInaccessible;
9 -exports.prettyRoles = prettyRoles;
10 -exports.isInaccessible = isInaccessible;
11 -exports.computeAriaSelected = computeAriaSelected;
12 -exports.computeAriaChecked = computeAriaChecked;
13 -exports.computeAriaPressed = computeAriaPressed;
14 -exports.computeAriaExpanded = computeAriaExpanded;
15 -exports.computeHeadingLevel = computeHeadingLevel;
16 -exports.logRoles = void 0;
17 -
18 -var _ariaQuery = require("aria-query");
19 -
20 -var _domAccessibilityApi = require("dom-accessibility-api");
21 -
22 -var _prettyDom = require("./pretty-dom");
23 -
24 -var _config = require("./config");
25 -
26 -const elementRoleList = buildElementRoleList(_ariaQuery.elementRoles);
27 -/**
28 - * @param {Element} element -
29 - * @returns {boolean} - `true` if `element` and its subtree are inaccessible
30 - */
31 -
32 -function isSubtreeInaccessible(element) {
33 - if (element.hidden === true) {
34 - return true;
35 - }
36 -
37 - if (element.getAttribute('aria-hidden') === 'true') {
38 - return true;
39 - }
40 -
41 - const window = element.ownerDocument.defaultView;
42 -
43 - if (window.getComputedStyle(element).display === 'none') {
44 - return true;
45 - }
46 -
47 - return false;
48 -}
49 -/**
50 - * Partial implementation https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
51 - * which should only be used for elements with a non-presentational role i.e.
52 - * `role="none"` and `role="presentation"` will not be excluded.
53 - *
54 - * Implements aria-hidden semantics (i.e. parent overrides child)
55 - * Ignores "Child Presentational: True" characteristics
56 - *
57 - * @param {Element} element -
58 - * @param {object} [options] -
59 - * @param {function (element: Element): boolean} options.isSubtreeInaccessible -
60 - * can be used to return cached results from previous isSubtreeInaccessible calls
61 - * @returns {boolean} true if excluded, otherwise false
62 - */
63 -
64 -
65 -function isInaccessible(element, options = {}) {
66 - const {
67 - isSubtreeInaccessible: isSubtreeInaccessibleImpl = isSubtreeInaccessible
68 - } = options;
69 - const window = element.ownerDocument.defaultView; // since visibility is inherited we can exit early
70 -
71 - if (window.getComputedStyle(element).visibility === 'hidden') {
72 - return true;
73 - }
74 -
75 - let currentElement = element;
76 -
77 - while (currentElement) {
78 - if (isSubtreeInaccessibleImpl(currentElement)) {
79 - return true;
80 - }
81 -
82 - currentElement = currentElement.parentElement;
83 - }
84 -
85 - return false;
86 -}
87 -
88 -function getImplicitAriaRoles(currentNode) {
89 - // eslint bug here:
90 - // eslint-disable-next-line no-unused-vars
91 - for (const {
92 - match,
93 - roles
94 - } of elementRoleList) {
95 - if (match(currentNode)) {
96 - return [...roles];
97 - }
98 - }
99 -
100 - return [];
101 -}
102 -
103 -function buildElementRoleList(elementRolesMap) {
104 - function makeElementSelector({
105 - name,
106 - attributes
107 - }) {
108 - return `${name}${attributes.map(({
109 - name: attributeName,
110 - value,
111 - constraints = []
112 - }) => {
113 - const shouldNotExist = constraints.indexOf('undefined') !== -1;
114 -
115 - if (shouldNotExist) {
116 - return `:not([${attributeName}])`;
117 - } else if (value) {
118 - return `[${attributeName}="${value}"]`;
119 - } else {
120 - return `[${attributeName}]`;
121 - }
122 - }).join('')}`;
123 - }
124 -
125 - function getSelectorSpecificity({
126 - attributes = []
127 - }) {
128 - return attributes.length;
129 - }
130 -
131 - function match(element) {
132 - return node => {
133 - let {
134 - attributes = []
135 - } = element; // https://github.com/testing-library/dom-testing-library/issues/814
136 -
137 - const typeTextIndex = attributes.findIndex(attribute => attribute.value && attribute.name === 'type' && attribute.value === 'text');
138 -
139 - if (typeTextIndex >= 0) {
140 - // not using splice to not mutate the attributes array
141 - attributes = [...attributes.slice(0, typeTextIndex), ...attributes.slice(typeTextIndex + 1)];
142 -
143 - if (node.type !== 'text') {
144 - return false;
145 - }
146 - }
147 -
148 - return node.matches(makeElementSelector({ ...element,
149 - attributes
150 - }));
151 - };
152 - }
153 -
154 - let result = []; // eslint bug here:
155 - // eslint-disable-next-line no-unused-vars
156 -
157 - for (const [element, roles] of elementRolesMap.entries()) {
158 - result = [...result, {
159 - match: match(element),
160 - roles: Array.from(roles),
161 - specificity: getSelectorSpecificity(element)
162 - }];
163 - }
164 -
165 - return result.sort(function ({
166 - specificity: leftSpecificity
167 - }, {
168 - specificity: rightSpecificity
169 - }) {
170 - return rightSpecificity - leftSpecificity;
171 - });
172 -}
173 -
174 -function getRoles(container, {
175 - hidden = false
176 -} = {}) {
177 - function flattenDOM(node) {
178 - return [node, ...Array.from(node.children).reduce((acc, child) => [...acc, ...flattenDOM(child)], [])];
179 - }
180 -
181 - return flattenDOM(container).filter(element => {
182 - return hidden === false ? isInaccessible(element) === false : true;
183 - }).reduce((acc, node) => {
184 - let roles = []; // TODO: This violates html-aria which does not allow any role on every element
185 -
186 - if (node.hasAttribute('role')) {
187 - roles = node.getAttribute('role').split(' ').slice(0, 1);
188 - } else {
189 - roles = getImplicitAriaRoles(node);
190 - }
191 -
192 - return roles.reduce((rolesAcc, role) => Array.isArray(rolesAcc[role]) ? { ...rolesAcc,
193 - [role]: [...rolesAcc[role], node]
194 - } : { ...rolesAcc,
195 - [role]: [node]
196 - }, acc);
197 - }, {});
198 -}
199 -
200 -function prettyRoles(dom, {
201 - hidden
202 -}) {
203 - const roles = getRoles(dom, {
204 - hidden
205 - }); // We prefer to skip generic role, we don't recommend it
206 -
207 - return Object.entries(roles).filter(([role]) => role !== 'generic').map(([role, elements]) => {
208 - const delimiterBar = '-'.repeat(50);
209 - const elementsString = elements.map(el => {
210 - const nameString = `Name "${(0, _domAccessibilityApi.computeAccessibleName)(el, {
211 - computedStyleSupportsPseudoElements: (0, _config.getConfig)().computedStyleSupportsPseudoElements
212 - })}":\n`;
213 - const domString = (0, _prettyDom.prettyDOM)(el.cloneNode(false));
214 - return `${nameString}${domString}`;
215 - }).join('\n\n');
216 - return `${role}:\n\n${elementsString}\n\n${delimiterBar}`;
217 - }).join('\n');
218 -}
219 -
220 -const logRoles = (dom, {
221 - hidden = false
222 -} = {}) => console.log(prettyRoles(dom, {
223 - hidden
224 -}));
225 -/**
226 - * @param {Element} element -
227 - * @returns {boolean | undefined} - false/true if (not)selected, undefined if not selectable
228 - */
229 -
230 -
231 -exports.logRoles = logRoles;
232 -
233 -function computeAriaSelected(element) {
234 - // implicit value from html-aam mappings: https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings
235 - // https://www.w3.org/TR/html-aam-1.0/#details-id-97
236 - if (element.tagName === 'OPTION') {
237 - return element.selected;
238 - } // explicit value
239 -
240 -
241 - return checkBooleanAttribute(element, 'aria-selected');
242 -}
243 -/**
244 - * @param {Element} element -
245 - * @returns {boolean | undefined} - false/true if (not)checked, undefined if not checked-able
246 - */
247 -
248 -
249 -function computeAriaChecked(element) {
250 - // implicit value from html-aam mappings: https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings
251 - // https://www.w3.org/TR/html-aam-1.0/#details-id-56
252 - // https://www.w3.org/TR/html-aam-1.0/#details-id-67
253 - if ('indeterminate' in element && element.indeterminate) {
254 - return undefined;
255 - }
256 -
257 - if ('checked' in element) {
258 - return element.checked;
259 - } // explicit value
260 -
261 -
262 - return checkBooleanAttribute(element, 'aria-checked');
263 -}
264 -/**
265 - * @param {Element} element -
266 - * @returns {boolean | undefined} - false/true if (not)pressed, undefined if not press-able
267 - */
268 -
269 -
270 -function computeAriaPressed(element) {
271 - // https://www.w3.org/TR/wai-aria-1.1/#aria-pressed
272 - return checkBooleanAttribute(element, 'aria-pressed');
273 -}
274 -/**
275 - * @param {Element} element -
276 - * @returns {boolean | undefined} - false/true if (not)expanded, undefined if not expand-able
277 - */
278 -
279 -
280 -function computeAriaExpanded(element) {
281 - // https://www.w3.org/TR/wai-aria-1.1/#aria-expanded
282 - return checkBooleanAttribute(element, 'aria-expanded');
283 -}
284 -
285 -function checkBooleanAttribute(element, attribute) {
286 - const attributeValue = element.getAttribute(attribute);
287 -
288 - if (attributeValue === 'true') {
289 - return true;
290 - }
291 -
292 - if (attributeValue === 'false') {
293 - return false;
294 - }
295 -
296 - return undefined;
297 -}
298 -/**
299 - * @param {Element} element -
300 - * @returns {number | undefined} - number if implicit heading or aria-level present, otherwise undefined
301 - */
302 -
303 -
304 -function computeHeadingLevel(element) {
305 - // https://w3c.github.io/html-aam/#el-h1-h6
306 - // https://w3c.github.io/html-aam/#el-h1-h6
307 - // explicit aria-level value
308 - // https://www.w3.org/TR/wai-aria-1.2/#aria-level
309 - const ariaLevelAttribute = element.getAttribute('aria-level') && Number(element.getAttribute('aria-level'));
310 - return ariaLevelAttribute || {
311 - H1: 1,
312 - H2: 2,
313 - H3: 3,
314 - H4: 4,
315 - H5: 5,
316 - H6: 6
317 - }[element.tagName];
318 -}
...\ No newline at end of file ...\ No newline at end of file
1 -"use strict";
2 -
3 -var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4 -
5 -Object.defineProperty(exports, "__esModule", {
6 - value: true
7 -});
8 -exports.screen = void 0;
9 -
10 -var _lzString = require("lz-string");
11 -
12 -var queries = _interopRequireWildcard(require("./queries"));
13 -
14 -var _getQueriesForElement = require("./get-queries-for-element");
15 -
16 -var _prettyDom = require("./pretty-dom");
17 -
18 -var _helpers = require("./helpers");
19 -
20 -function unindent(string) {
21 - // remove white spaces first, to save a few bytes.
22 - // testing-playground will reformat on load any ways.
23 - return string.replace(/[ \t]*[\n][ \t]*/g, '\n');
24 -}
25 -
26 -function encode(value) {
27 - return (0, _lzString.compressToEncodedURIComponent)(unindent(value));
28 -}
29 -
30 -function getPlaygroundUrl(markup) {
31 - return `https://testing-playground.com/#markup=${encode(markup)}`;
32 -}
33 -
34 -const debug = (element, maxLength, options) => Array.isArray(element) ? element.forEach(el => (0, _prettyDom.logDOM)(el, maxLength, options)) : (0, _prettyDom.logDOM)(element, maxLength, options);
35 -
36 -const logTestingPlaygroundURL = (element = (0, _helpers.getDocument)().body) => {
37 - if (!element || !('innerHTML' in element)) {
38 - console.log(`The element you're providing isn't a valid DOM element.`);
39 - return;
40 - }
41 -
42 - if (!element.innerHTML) {
43 - console.log(`The provided element doesn't have any children.`);
44 - return;
45 - }
46 -
47 - console.log(`Open this URL in your browser\n\n${getPlaygroundUrl(element.innerHTML)}`);
48 -};
49 -
50 -const initialValue = {
51 - debug,
52 - logTestingPlaygroundURL
53 -};
54 -const screen = typeof document !== 'undefined' && document.body ? (0, _getQueriesForElement.getQueriesForElement)(document.body, queries, initialValue) : Object.keys(queries).reduce((helpers, key) => {
55 - helpers[key] = () => {
56 - throw new TypeError('For queries bound to document.body a global document has to be available... Learn more: https://testing-library.com/s/screen-global-error');
57 - };
58 -
59 - return helpers;
60 -}, initialValue);
61 -exports.screen = screen;
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.