@ldelia/react-media 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/components/__tests__/timeline/timeline.test.js +5 -10
  2. package/dist/components/index.js +2 -17
  3. package/dist/components/timeline/RangeSelectorCanvas/RangeSelectorCanvas.js +16 -44
  4. package/dist/components/timeline/Timeline.js +26 -56
  5. package/dist/components/timeline/TimelineCanvas/TickTime.js +5 -10
  6. package/dist/components/timeline/TimelineCanvas/TickTimeCollectionDisplay.js +9 -14
  7. package/dist/components/timeline/TimelineCanvas/TimelineCanvas.js +16 -44
  8. package/dist/components/timeline/TimelineCanvas/drawTimeBlocksOnCanvas.js +4 -8
  9. package/dist/components/timeline/TimelineValue/TimelineValue.js +24 -54
  10. package/dist/components/timeline/ZoomContext/ZoomContext.js +2 -8
  11. package/dist/components/timeline/constants.js +1 -4
  12. package/dist/components/timeline/index.js +1 -17
  13. package/dist/components/timeline/utils/utils.js +6 -15
  14. package/dist/index.js +1 -17
  15. package/dist/setupTests.js +1 -3
  16. package/dist/stories/timeline.stories.js +18 -24
  17. package/package.json +45 -35
  18. package/.bitmap +0 -48
  19. package/.eslintcache +0 -1
  20. package/.prettierignore +0 -3
  21. package/.prettierrc +0 -7
  22. package/.storybook/main.js +0 -38
  23. package/.storybook/preview.js +0 -4
  24. package/config/env.js +0 -104
  25. package/config/getHttpsConfig.js +0 -66
  26. package/config/jest/babelTransform.js +0 -29
  27. package/config/jest/cssTransform.js +0 -14
  28. package/config/jest/fileTransform.js +0 -40
  29. package/config/modules.js +0 -134
  30. package/config/paths.js +0 -77
  31. package/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
  32. package/config/webpack.config.js +0 -755
  33. package/config/webpackDevServer.config.js +0 -127
  34. package/dist/components/__tests__/timeline/timeline.test.d.ts +0 -1
  35. package/dist/components/index.d.ts +0 -1
  36. package/dist/components/timeline/RangeSelectorCanvas/RangeSelectorCanvas.d.ts +0 -8
  37. package/dist/components/timeline/Timeline.d.ts +0 -12
  38. package/dist/components/timeline/TimelineCanvas/TickTime.d.ts +0 -7
  39. package/dist/components/timeline/TimelineCanvas/TickTimeCollectionDisplay.d.ts +0 -6
  40. package/dist/components/timeline/TimelineCanvas/TimelineCanvas.d.ts +0 -7
  41. package/dist/components/timeline/TimelineCanvas/drawTimeBlocksOnCanvas.d.ts +0 -2
  42. package/dist/components/timeline/TimelineValue/TimelineValue.d.ts +0 -7
  43. package/dist/components/timeline/ZoomContext/ZoomContext.d.ts +0 -7
  44. package/dist/components/timeline/constants.d.ts +0 -1
  45. package/dist/components/timeline/index.d.ts +0 -1
  46. package/dist/components/timeline/utils/utils.d.ts +0 -7
  47. package/dist/index.d.ts +0 -1
  48. package/dist/setupTests.d.ts +0 -1
  49. package/dist/stories/timeline.stories.d.ts +0 -9
  50. package/scripts/build.js +0 -217
  51. package/scripts/start.js +0 -154
  52. package/scripts/test.js +0 -52
  53. package/src/components/__tests__/timeline/timeline.test.js +0 -22
  54. package/src/components/__tests__/timeline/timeline.test.tsx +0 -26
  55. package/src/components/index.js +0 -2
  56. package/src/components/index.ts +0 -2
  57. package/src/components/reproduction-widget/README.md +0 -27
  58. package/src/components/reproduction-widget/ReproductionWidget.tsx +0 -68
  59. package/src/components/reproduction-widget/index.tsx +0 -1
  60. package/src/components/reproduction-widget/inner-players/PlayAlongInnerPlayer.tsx +0 -10
  61. package/src/components/reproduction-widget/inner-players/YouTubeInnerPlayer.tsx +0 -36
  62. package/src/components/reproduction-widget/models/Player/PlayAlongPlayer.ts +0 -129
  63. package/src/components/reproduction-widget/models/Player/PlayerEvents.ts +0 -4
  64. package/src/components/reproduction-widget/models/Player/YouTubePlayer.ts +0 -171
  65. package/src/components/reproduction-widget/models/Reproduction.ts +0 -272
  66. package/src/components/reproduction-widget/models/ReproductionBuilder.ts +0 -70
  67. package/src/components/timeline/README.md +0 -111
  68. package/src/components/timeline/RangeSelectorCanvas/RangeSelectorCanvas.js +0 -127
  69. package/src/components/timeline/RangeSelectorCanvas/RangeSelectorCanvas.tsx +0 -166
  70. package/src/components/timeline/Timeline.js +0 -77
  71. package/src/components/timeline/Timeline.tsx +0 -139
  72. package/src/components/timeline/TimelineCanvas/TickTime.js +0 -26
  73. package/src/components/timeline/TimelineCanvas/TickTime.tsx +0 -45
  74. package/src/components/timeline/TimelineCanvas/TickTimeCollectionDisplay.js +0 -19
  75. package/src/components/timeline/TimelineCanvas/TickTimeCollectionDisplay.tsx +0 -42
  76. package/src/components/timeline/TimelineCanvas/TimelineCanvas.js +0 -44
  77. package/src/components/timeline/TimelineCanvas/TimelineCanvas.tsx +0 -79
  78. package/src/components/timeline/TimelineCanvas/drawTimeBlocksOnCanvas.js +0 -28
  79. package/src/components/timeline/TimelineCanvas/drawTimeBlocksOnCanvas.ts +0 -43
  80. package/src/components/timeline/TimelineValue/TimelineValue.js +0 -50
  81. package/src/components/timeline/TimelineValue/TimelineValue.tsx +0 -87
  82. package/src/components/timeline/ZoomContext/ZoomContext.js +0 -2
  83. package/src/components/timeline/ZoomContext/ZoomContext.ts +0 -10
  84. package/src/components/timeline/constants.js +0 -13
  85. package/src/components/timeline/constants.ts +0 -13
  86. package/src/components/timeline/index.js +0 -1
  87. package/src/components/timeline/index.tsx +0 -1
  88. package/src/components/timeline/utils/utils.js +0 -28
  89. package/src/components/timeline/utils/utils.ts +0 -49
  90. package/src/index.js +0 -1
  91. package/src/index.ts +0 -1
  92. package/src/modules.d.ts +0 -1
  93. package/src/react-app-env.d.ts +0 -71
  94. package/src/react-docgen-types.d.ts +0 -37
  95. package/src/setupTests.js +0 -5
  96. package/src/setupTests.ts +0 -5
  97. package/src/stories/Configure.mdx +0 -364
  98. package/src/stories/reproduction-widget.stories.tsx +0 -23
  99. package/src/stories/timeline.stories.custom.css +0 -29
  100. package/src/stories/timeline.stories.js +0 -54
  101. package/src/stories/timeline.stories.tsx +0 -66
  102. package/storybook-static/favicon.svg +0 -1
  103. package/storybook-static/index.html +0 -173
  104. package/storybook-static/index.json +0 -1
  105. package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
  106. package/storybook-static/nunito-sans-bold.woff2 +0 -0
  107. package/storybook-static/nunito-sans-italic.woff2 +0 -0
  108. package/storybook-static/nunito-sans-regular.woff2 +0 -0
  109. package/storybook-static/project.json +0 -1
  110. package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +0 -3
  111. package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js.LEGAL.txt +0 -0
  112. package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +0 -12
  113. package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js.LEGAL.txt +0 -0
  114. package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +0 -412
  115. package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js.LEGAL.txt +0 -0
  116. package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +0 -3
  117. package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js.LEGAL.txt +0 -0
  118. package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +0 -3
  119. package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js.LEGAL.txt +0 -0
  120. package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +0 -3
  121. package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js.LEGAL.txt +0 -0
  122. package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +0 -3
  123. package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js.LEGAL.txt +0 -0
  124. package/storybook-static/sb-addons/links-1/manager-bundle.js +0 -3
  125. package/storybook-static/sb-addons/links-1/manager-bundle.js.LEGAL.txt +0 -0
  126. package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +0 -3
  127. package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
  128. package/storybook-static/sb-common-assets/favicon.svg +0 -1
  129. package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  130. package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  131. package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  132. package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  133. package/storybook-static/sb-manager/globals-module-info.js +0 -995
  134. package/storybook-static/sb-manager/globals-runtime.js +0 -53527
  135. package/storybook-static/sb-manager/globals.js +0 -48
  136. package/storybook-static/sb-manager/runtime.js +0 -11885
  137. package/storybook-static/sb-preview/globals.js +0 -33
  138. package/storybook-static/sb-preview/runtime.js +0 -9483
  139. package/tsconfig.json +0 -14
  140. /package/{src → dist}/components/reproduction-widget/ReproductionWidget.js +0 -0
  141. /package/{src → dist}/components/reproduction-widget/index.js +0 -0
  142. /package/{src → dist}/components/reproduction-widget/inner-players/PlayAlongInnerPlayer.js +0 -0
  143. /package/{src → dist}/components/reproduction-widget/inner-players/YouTubeInnerPlayer.js +0 -0
  144. /package/{src → dist}/components/reproduction-widget/models/Player/PlayAlongPlayer.js +0 -0
  145. /package/{src → dist}/components/reproduction-widget/models/Player/PlayerEvents.js +0 -0
  146. /package/{src → dist}/components/reproduction-widget/models/Player/YouTubePlayer.js +0 -0
  147. /package/{src → dist}/components/reproduction-widget/models/Reproduction.js +0 -0
  148. /package/{src → dist}/components/reproduction-widget/models/ReproductionBuilder.js +0 -0
  149. /package/{src → dist}/stories/reproduction-widget.stories.js +0 -0
@@ -1,127 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
5
- const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
6
- const ignoredFiles = require('react-dev-utils/ignoredFiles');
7
- const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
8
- const paths = require('./paths');
9
- const getHttpsConfig = require('./getHttpsConfig');
10
-
11
- const host = process.env.HOST || '0.0.0.0';
12
- const sockHost = process.env.WDS_SOCKET_HOST;
13
- const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
14
- const sockPort = process.env.WDS_SOCKET_PORT;
15
-
16
- module.exports = function (proxy, allowedHost) {
17
- const disableFirewall =
18
- !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
19
- return {
20
- // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
21
- // websites from potentially accessing local content through DNS rebinding:
22
- // https://github.com/webpack/webpack-dev-server/issues/887
23
- // https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
24
- // However, it made several existing use cases such as development in cloud
25
- // environment or subdomains in development significantly more complicated:
26
- // https://github.com/facebook/create-react-app/issues/2271
27
- // https://github.com/facebook/create-react-app/issues/2233
28
- // While we're investigating better solutions, for now we will take a
29
- // compromise. Since our WDS configuration only serves files in the `public`
30
- // folder we won't consider accessing them a vulnerability. However, if you
31
- // use the `proxy` feature, it gets more dangerous because it can expose
32
- // remote code execution vulnerabilities in backends like Django and Rails.
33
- // So we will disable the host check normally, but enable it if you have
34
- // specified the `proxy` setting. Finally, we let you override it if you
35
- // really know what you're doing with a special environment variable.
36
- // Note: ["localhost", ".localhost"] will support subdomains - but we might
37
- // want to allow setting the allowedHosts manually for more complex setups
38
- allowedHosts: disableFirewall ? 'all' : [allowedHost],
39
- headers: {
40
- 'Access-Control-Allow-Origin': '*',
41
- 'Access-Control-Allow-Methods': '*',
42
- 'Access-Control-Allow-Headers': '*',
43
- },
44
- // Enable gzip compression of generated files.
45
- compress: true,
46
- static: {
47
- // By default WebpackDevServer serves physical files from current directory
48
- // in addition to all the virtual build products that it serves from memory.
49
- // This is confusing because those files won’t automatically be available in
50
- // production build folder unless we copy them. However, copying the whole
51
- // project directory is dangerous because we may expose sensitive files.
52
- // Instead, we establish a convention that only files in `public` directory
53
- // get served. Our build script will copy `public` into the `build` folder.
54
- // In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
55
- // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
56
- // In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
57
- // Note that we only recommend to use `public` folder as an escape hatch
58
- // for files like `favicon.ico`, `manifest.json`, and libraries that are
59
- // for some reason broken when imported through webpack. If you just want to
60
- // use an image, put it in `src` and `import` it from JavaScript instead.
61
- directory: paths.appPublic,
62
- publicPath: [paths.publicUrlOrPath],
63
- // By default files from `contentBase` will not trigger a page reload.
64
- watch: {
65
- // Reportedly, this avoids CPU overload on some systems.
66
- // https://github.com/facebook/create-react-app/issues/293
67
- // src/node_modules is not ignored to support absolute imports
68
- // https://github.com/facebook/create-react-app/issues/1065
69
- ignored: ignoredFiles(paths.appSrc),
70
- },
71
- },
72
- client: {
73
- webSocketURL: {
74
- // Enable custom sockjs pathname for websocket connection to hot reloading server.
75
- // Enable custom sockjs hostname, pathname and port for websocket connection
76
- // to hot reloading server.
77
- hostname: sockHost,
78
- pathname: sockPath,
79
- port: sockPort,
80
- },
81
- overlay: {
82
- errors: true,
83
- warnings: false,
84
- },
85
- },
86
- devMiddleware: {
87
- // It is important to tell WebpackDevServer to use the same "publicPath" path as
88
- // we specified in the webpack config. When homepage is '.', default to serving
89
- // from the root.
90
- // remove last slash so user can land on `/test` instead of `/test/`
91
- publicPath: paths.publicUrlOrPath.slice(0, -1),
92
- },
93
-
94
- https: getHttpsConfig(),
95
- host,
96
- historyApiFallback: {
97
- // Paths with dots should still use the history fallback.
98
- // See https://github.com/facebook/create-react-app/issues/387.
99
- disableDotRule: true,
100
- index: paths.publicUrlOrPath,
101
- },
102
- // `proxy` is run between `before` and `after` `webpack-dev-server` hooks
103
- proxy,
104
- onBeforeSetupMiddleware(devServer) {
105
- // Keep `evalSourceMapMiddleware`
106
- // middlewares before `redirectServedPath` otherwise will not have any effect
107
- // This lets us fetch source contents from webpack for the error overlay
108
- devServer.app.use(evalSourceMapMiddleware(devServer));
109
-
110
- if (fs.existsSync(paths.proxySetup)) {
111
- // This registers user provided middleware for proxy reasons
112
- require(paths.proxySetup)(devServer.app);
113
- }
114
- },
115
- onAfterSetupMiddleware(devServer) {
116
- // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
117
- devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
118
-
119
- // This service worker file is effectively a 'no-op' that will reset any
120
- // previous service worker registered for the same host:port combination.
121
- // We do this in development to avoid hitting the production cache if
122
- // it used the same host and port.
123
- // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
124
- devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
125
- },
126
- };
127
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from './timeline';
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- export interface RangeSelectorCanvasProps {
3
- selectedRange: number[];
4
- onChange: (value: number) => void;
5
- onRangeChange: (value: number[]) => void;
6
- }
7
- declare const _default: React.NamedExoticComponent<RangeSelectorCanvasProps>;
8
- export default _default;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- export interface TimelineProps {
3
- duration: number;
4
- value: number;
5
- zoomLevel?: number;
6
- className?: string;
7
- selectedRange?: number[];
8
- withTimeBlocks?: boolean;
9
- onChange?: (value: number) => void;
10
- onRangeChange?: (value: number[]) => void;
11
- }
12
- export declare const Timeline: React.FC<TimelineProps>;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- export type Props = {
3
- start: number;
4
- leftPosition: string;
5
- };
6
- declare const TickTime: React.FC<Props>;
7
- export default TickTime;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- export interface TickTimeCollectionDisplayProps {
3
- tickTimes: number[];
4
- }
5
- declare const TickTimeCollectionDisplay: React.FC<TickTimeCollectionDisplayProps>;
6
- export default TickTimeCollectionDisplay;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- export interface VaLueLineCanvasProps {
3
- duration: number;
4
- withTimeBlocks: boolean;
5
- }
6
- declare const TimelineCanvas: React.ForwardRefExoticComponent<VaLueLineCanvasProps & React.RefAttributes<HTMLCanvasElement>>;
7
- export default TimelineCanvas;
@@ -1,2 +0,0 @@
1
- import { ZoomContextType } from '../ZoomContext/ZoomContext';
2
- export declare const drawTimeBlocksOnCanvas: (canvas: HTMLCanvasElement, blockStartingTimes: number[], zoomContextValue: ZoomContextType) => void;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface Props {
3
- canvasRef: React.RefObject<HTMLCanvasElement>;
4
- value: number;
5
- }
6
- export declare const TimelineValue: React.FC<Props>;
7
- export {};
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- export type ZoomContextType = {
3
- blockOffset: number;
4
- pixelsInSecond: number;
5
- timelineWrapperWidth: number;
6
- };
7
- export declare const ZoomContext: React.Context<ZoomContextType>;
@@ -1 +0,0 @@
1
- export declare const zoomLevelConfigurations: number[][];
@@ -1 +0,0 @@
1
- export * from './Timeline';
@@ -1,7 +0,0 @@
1
- import { ZoomContextType } from '../ZoomContext/ZoomContext';
2
- export declare const secondsToPixel: (zoomContextValue: ZoomContextType, seconds: number) => number;
3
- export declare const pixelToSeconds: (zoomContextValue: ZoomContextType, pixel: number) => number;
4
- export declare const getComputedElementWidth: (element: HTMLElement) => number;
5
- export declare const numberToPxString: (number: number) => string;
6
- export declare const getTimelineWrapperWidth: (timeLineContainerWidth: number, zoomLevel: number) => number;
7
- export declare function getBlockOffsetForZoomLevel(zoomLevel: number, duration: number, timelineWrapperWidth: number): number;
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './components';
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1,9 +0,0 @@
1
- import { TimelineProps } from '../components/timeline';
2
- import './timeline.stories.custom.css';
3
- declare const _default: import("@storybook/csf").ComponentAnnotations<import("@storybook/react/dist/types-a5624094").R, import("@storybook/csf").Args>;
4
- export default _default;
5
- export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react/dist/types-a5624094").R, TimelineProps>;
6
- export declare const WithSelectedRange: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react/dist/types-a5624094").R, TimelineProps>;
7
- export declare const WithCustomClassName: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react/dist/types-a5624094").R, TimelineProps>;
8
- export declare const WithoutTimeBlocks: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react/dist/types-a5624094").R, TimelineProps>;
9
- export declare const Minimalist: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react/dist/types-a5624094").R, TimelineProps>;
package/scripts/build.js DELETED
@@ -1,217 +0,0 @@
1
- 'use strict';
2
-
3
- // Do this as the first thing so that any code reading it knows the right env.
4
- process.env.BABEL_ENV = 'production';
5
- process.env.NODE_ENV = 'production';
6
-
7
- // Makes the script crash on unhandled rejections instead of silently
8
- // ignoring them. In the future, promise rejections that are not handled will
9
- // terminate the Node.js process with a non-zero exit code.
10
- process.on('unhandledRejection', err => {
11
- throw err;
12
- });
13
-
14
- // Ensure environment variables are read.
15
- require('../config/env');
16
-
17
- const path = require('path');
18
- const chalk = require('react-dev-utils/chalk');
19
- const fs = require('fs-extra');
20
- const bfj = require('bfj');
21
- const webpack = require('webpack');
22
- const configFactory = require('../config/webpack.config');
23
- const paths = require('../config/paths');
24
- const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
25
- const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
26
- const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
27
- const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
28
- const printBuildError = require('react-dev-utils/printBuildError');
29
-
30
- const measureFileSizesBeforeBuild =
31
- FileSizeReporter.measureFileSizesBeforeBuild;
32
- const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
33
- const useYarn = fs.existsSync(paths.yarnLockFile);
34
-
35
- // These sizes are pretty large. We'll warn for bundles exceeding them.
36
- const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
37
- const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
38
-
39
- const isInteractive = process.stdout.isTTY;
40
-
41
- // Warn and crash if required files are missing
42
- if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
43
- process.exit(1);
44
- }
45
-
46
- const argv = process.argv.slice(2);
47
- const writeStatsJson = argv.indexOf('--stats') !== -1;
48
-
49
- // Generate configuration
50
- const config = configFactory('production');
51
-
52
- // We require that you explicitly set browsers and do not fall back to
53
- // browserslist defaults.
54
- const { checkBrowsers } = require('react-dev-utils/browsersHelper');
55
- checkBrowsers(paths.appPath, isInteractive)
56
- .then(() => {
57
- // First, read the current file sizes in build directory.
58
- // This lets us display how much they changed later.
59
- return measureFileSizesBeforeBuild(paths.appBuild);
60
- })
61
- .then(previousFileSizes => {
62
- // Remove all content but keep the directory so that
63
- // if you're in it, you don't end up in Trash
64
- fs.emptyDirSync(paths.appBuild);
65
- // Merge with the public folder
66
- copyPublicFolder();
67
- // Start the webpack build
68
- return build(previousFileSizes);
69
- })
70
- .then(
71
- ({ stats, previousFileSizes, warnings }) => {
72
- if (warnings.length) {
73
- console.log(chalk.yellow('Compiled with warnings.\n'));
74
- console.log(warnings.join('\n\n'));
75
- console.log(
76
- '\nSearch for the ' +
77
- chalk.underline(chalk.yellow('keywords')) +
78
- ' to learn more about each warning.'
79
- );
80
- console.log(
81
- 'To ignore, add ' +
82
- chalk.cyan('// eslint-disable-next-line') +
83
- ' to the line before.\n'
84
- );
85
- } else {
86
- console.log(chalk.green('Compiled successfully.\n'));
87
- }
88
-
89
- console.log('File sizes after gzip:\n');
90
- printFileSizesAfterBuild(
91
- stats,
92
- previousFileSizes,
93
- paths.appBuild,
94
- WARN_AFTER_BUNDLE_GZIP_SIZE,
95
- WARN_AFTER_CHUNK_GZIP_SIZE
96
- );
97
- console.log();
98
-
99
- const appPackage = require(paths.appPackageJson);
100
- const publicUrl = paths.publicUrlOrPath;
101
- const publicPath = config.output.publicPath;
102
- const buildFolder = path.relative(process.cwd(), paths.appBuild);
103
- printHostingInstructions(
104
- appPackage,
105
- publicUrl,
106
- publicPath,
107
- buildFolder,
108
- useYarn
109
- );
110
- },
111
- err => {
112
- const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
113
- if (tscCompileOnError) {
114
- console.log(
115
- chalk.yellow(
116
- 'Compiled with the following type errors (you may want to check these before deploying your app):\n'
117
- )
118
- );
119
- printBuildError(err);
120
- } else {
121
- console.log(chalk.red('Failed to compile.\n'));
122
- printBuildError(err);
123
- process.exit(1);
124
- }
125
- }
126
- )
127
- .catch(err => {
128
- if (err && err.message) {
129
- console.log(err.message);
130
- }
131
- process.exit(1);
132
- });
133
-
134
- // Create the production build and print the deployment instructions.
135
- function build(previousFileSizes) {
136
- console.log('Creating an optimized production build...');
137
-
138
- const compiler = webpack(config);
139
- return new Promise((resolve, reject) => {
140
- compiler.run((err, stats) => {
141
- let messages;
142
- if (err) {
143
- if (!err.message) {
144
- return reject(err);
145
- }
146
-
147
- let errMessage = err.message;
148
-
149
- // Add additional information for postcss errors
150
- if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
151
- errMessage +=
152
- '\nCompileError: Begins at CSS selector ' +
153
- err['postcssNode'].selector;
154
- }
155
-
156
- messages = formatWebpackMessages({
157
- errors: [errMessage],
158
- warnings: [],
159
- });
160
- } else {
161
- messages = formatWebpackMessages(
162
- stats.toJson({ all: false, warnings: true, errors: true })
163
- );
164
- }
165
- if (messages.errors.length) {
166
- // Only keep the first error. Others are often indicative
167
- // of the same problem, but confuse the reader with noise.
168
- if (messages.errors.length > 1) {
169
- messages.errors.length = 1;
170
- }
171
- return reject(new Error(messages.errors.join('\n\n')));
172
- }
173
- if (
174
- process.env.CI &&
175
- (typeof process.env.CI !== 'string' ||
176
- process.env.CI.toLowerCase() !== 'false') &&
177
- messages.warnings.length
178
- ) {
179
- // Ignore sourcemap warnings in CI builds. See #8227 for more info.
180
- const filteredWarnings = messages.warnings.filter(
181
- w => !/Failed to parse source map/.test(w)
182
- );
183
- if (filteredWarnings.length) {
184
- console.log(
185
- chalk.yellow(
186
- '\nTreating warnings as errors because process.env.CI = true.\n' +
187
- 'Most CI servers set it automatically.\n'
188
- )
189
- );
190
- return reject(new Error(filteredWarnings.join('\n\n')));
191
- }
192
- }
193
-
194
- const resolveArgs = {
195
- stats,
196
- previousFileSizes,
197
- warnings: messages.warnings,
198
- };
199
-
200
- if (writeStatsJson) {
201
- return bfj
202
- .write(paths.appBuild + '/bundle-stats.json', stats.toJson())
203
- .then(() => resolve(resolveArgs))
204
- .catch(error => reject(new Error(error)));
205
- }
206
-
207
- return resolve(resolveArgs);
208
- });
209
- });
210
- }
211
-
212
- function copyPublicFolder() {
213
- fs.copySync(paths.appPublic, paths.appBuild, {
214
- dereference: true,
215
- filter: file => file !== paths.appHtml,
216
- });
217
- }
package/scripts/start.js DELETED
@@ -1,154 +0,0 @@
1
- 'use strict';
2
-
3
- // Do this as the first thing so that any code reading it knows the right env.
4
- process.env.BABEL_ENV = 'development';
5
- process.env.NODE_ENV = 'development';
6
-
7
- // Makes the script crash on unhandled rejections instead of silently
8
- // ignoring them. In the future, promise rejections that are not handled will
9
- // terminate the Node.js process with a non-zero exit code.
10
- process.on('unhandledRejection', err => {
11
- throw err;
12
- });
13
-
14
- // Ensure environment variables are read.
15
- require('../config/env');
16
-
17
- const fs = require('fs');
18
- const chalk = require('react-dev-utils/chalk');
19
- const webpack = require('webpack');
20
- const WebpackDevServer = require('webpack-dev-server');
21
- const clearConsole = require('react-dev-utils/clearConsole');
22
- const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
23
- const {
24
- choosePort,
25
- createCompiler,
26
- prepareProxy,
27
- prepareUrls,
28
- } = require('react-dev-utils/WebpackDevServerUtils');
29
- const openBrowser = require('react-dev-utils/openBrowser');
30
- const semver = require('semver');
31
- const paths = require('../config/paths');
32
- const configFactory = require('../config/webpack.config');
33
- const createDevServerConfig = require('../config/webpackDevServer.config');
34
- const getClientEnvironment = require('../config/env');
35
- const react = require(require.resolve('react', { paths: [paths.appPath] }));
36
-
37
- const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
38
- const useYarn = fs.existsSync(paths.yarnLockFile);
39
- const isInteractive = process.stdout.isTTY;
40
-
41
- // Warn and crash if required files are missing
42
- if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
43
- process.exit(1);
44
- }
45
-
46
- // Tools like Cloud9 rely on this.
47
- const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
48
- const HOST = process.env.HOST || '0.0.0.0';
49
-
50
- if (process.env.HOST) {
51
- console.log(
52
- chalk.cyan(
53
- `Attempting to bind to HOST environment variable: ${chalk.yellow(
54
- chalk.bold(process.env.HOST)
55
- )}`
56
- )
57
- );
58
- console.log(
59
- `If this was unintentional, check that you haven't mistakenly set it in your shell.`
60
- );
61
- console.log(
62
- `Learn more here: ${chalk.yellow('https://cra.link/advanced-config')}`
63
- );
64
- console.log();
65
- }
66
-
67
- // We require that you explicitly set browsers and do not fall back to
68
- // browserslist defaults.
69
- const { checkBrowsers } = require('react-dev-utils/browsersHelper');
70
- checkBrowsers(paths.appPath, isInteractive)
71
- .then(() => {
72
- // We attempt to use the default port but if it is busy, we offer the user to
73
- // run on a different port. `choosePort()` Promise resolves to the next free port.
74
- return choosePort(HOST, DEFAULT_PORT);
75
- })
76
- .then(port => {
77
- if (port == null) {
78
- // We have not found a port.
79
- return;
80
- }
81
-
82
- const config = configFactory('development');
83
- const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
84
- const appName = require(paths.appPackageJson).name;
85
-
86
- const useTypeScript = fs.existsSync(paths.appTsConfig);
87
- const urls = prepareUrls(
88
- protocol,
89
- HOST,
90
- port,
91
- paths.publicUrlOrPath.slice(0, -1)
92
- );
93
- // Create a webpack compiler that is configured with custom messages.
94
- const compiler = createCompiler({
95
- appName,
96
- config,
97
- urls,
98
- useYarn,
99
- useTypeScript,
100
- webpack,
101
- });
102
- // Load proxy config
103
- const proxySetting = require(paths.appPackageJson).proxy;
104
- const proxyConfig = prepareProxy(
105
- proxySetting,
106
- paths.appPublic,
107
- paths.publicUrlOrPath
108
- );
109
- // Serve webpack assets generated by the compiler over a web server.
110
- const serverConfig = {
111
- ...createDevServerConfig(proxyConfig, urls.lanUrlForConfig),
112
- host: HOST,
113
- port,
114
- };
115
- const devServer = new WebpackDevServer(serverConfig, compiler);
116
- // Launch WebpackDevServer.
117
- devServer.startCallback(() => {
118
- if (isInteractive) {
119
- clearConsole();
120
- }
121
-
122
- if (env.raw.FAST_REFRESH && semver.lt(react.version, '16.10.0')) {
123
- console.log(
124
- chalk.yellow(
125
- `Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.`
126
- )
127
- );
128
- }
129
-
130
- console.log(chalk.cyan('Starting the development server...\n'));
131
- openBrowser(urls.localUrlForBrowser);
132
- });
133
-
134
- ['SIGINT', 'SIGTERM'].forEach(function (sig) {
135
- process.on(sig, function () {
136
- devServer.close();
137
- process.exit();
138
- });
139
- });
140
-
141
- if (process.env.CI !== 'true') {
142
- // Gracefully exit when stdin ends
143
- process.stdin.on('end', function () {
144
- devServer.close();
145
- process.exit();
146
- });
147
- }
148
- })
149
- .catch(err => {
150
- if (err && err.message) {
151
- console.log(err.message);
152
- }
153
- process.exit(1);
154
- });
package/scripts/test.js DELETED
@@ -1,52 +0,0 @@
1
- 'use strict';
2
-
3
- // Do this as the first thing so that any code reading it knows the right env.
4
- process.env.BABEL_ENV = 'test';
5
- process.env.NODE_ENV = 'test';
6
- process.env.PUBLIC_URL = '';
7
-
8
- // Makes the script crash on unhandled rejections instead of silently
9
- // ignoring them. In the future, promise rejections that are not handled will
10
- // terminate the Node.js process with a non-zero exit code.
11
- process.on('unhandledRejection', err => {
12
- throw err;
13
- });
14
-
15
- // Ensure environment variables are read.
16
- require('../config/env');
17
-
18
- const jest = require('jest');
19
- const execSync = require('child_process').execSync;
20
- let argv = process.argv.slice(2);
21
-
22
- function isInGitRepository() {
23
- try {
24
- execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
25
- return true;
26
- } catch (e) {
27
- return false;
28
- }
29
- }
30
-
31
- function isInMercurialRepository() {
32
- try {
33
- execSync('hg --cwd . root', { stdio: 'ignore' });
34
- return true;
35
- } catch (e) {
36
- return false;
37
- }
38
- }
39
-
40
- // Watch unless on CI or explicitly running all tests
41
- if (
42
- !process.env.CI &&
43
- argv.indexOf('--watchAll') === -1 &&
44
- argv.indexOf('--watchAll=false') === -1
45
- ) {
46
- // https://github.com/facebook/create-react-app/issues/5210
47
- const hasSourceControl = isInGitRepository() || isInMercurialRepository();
48
- argv.push(hasSourceControl ? '--watch' : '--watchAll');
49
- }
50
-
51
-
52
- jest.run(argv);