@remotion/cli 3.1.7 → 3.1.11

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 (61) hide show
  1. package/dist/bundle-on-cli.d.ts +2 -0
  2. package/dist/bundle-on-cli.js +41 -0
  3. package/dist/bundle.d.ts +1 -0
  4. package/dist/bundle.js +31 -0
  5. package/dist/chalk/symbols.d.ts +111 -0
  6. package/dist/chalk/symbols.js +75 -0
  7. package/dist/chalk/utilities.d.ts +2 -0
  8. package/dist/chalk/utilities.js +37 -0
  9. package/dist/code-frame.js +2 -1
  10. package/dist/compositions.js +4 -1
  11. package/dist/editor/components/Canvas.js +2 -0
  12. package/dist/editor/components/CompositionManager.d.ts +4 -0
  13. package/dist/editor/components/CompositionManager.js +60 -0
  14. package/dist/editor/components/CompositionSelector.js +2 -0
  15. package/dist/editor/components/CompositionSelectorItem.js +1 -0
  16. package/dist/editor/components/CurrentComposition.js +5 -0
  17. package/dist/editor/components/LoadingIndicator.d.ts +2 -0
  18. package/dist/editor/components/LoadingIndicator.js +35 -0
  19. package/dist/editor/components/Menu/MenuItem.js +1 -1
  20. package/dist/editor/components/Menu/MenuSubItem.js +1 -1
  21. package/dist/editor/components/Menu/styles.d.ts +3 -2
  22. package/dist/editor/components/Menu/styles.js +10 -3
  23. package/dist/editor/components/MenuToolbar.js +2 -0
  24. package/dist/editor/components/NewComposition/ComboBox.js +12 -2
  25. package/dist/editor/components/Notifications/Notification.js +1 -1
  26. package/dist/editor/components/Notifications/NotificationCenter.js +1 -0
  27. package/dist/editor/components/PreviewToolbar.js +2 -0
  28. package/dist/editor/components/Timeline/TimelineList.js +2 -0
  29. package/dist/editor/components/Timeline/TimelineScrollable.d.ts +4 -0
  30. package/dist/editor/components/Timeline/TimelineScrollable.js +23 -0
  31. package/dist/editor/components/Timeline/TimelineZoomControls.d.ts +2 -0
  32. package/dist/editor/components/Timeline/TimelineZoomControls.js +29 -0
  33. package/dist/editor/components/Timeline/timeline-scroll-logic.d.ts +4 -0
  34. package/dist/editor/components/Timeline/timeline-scroll-logic.js +13 -0
  35. package/dist/editor/state/timeline-zoom.d.ts +10 -0
  36. package/dist/editor/state/timeline-zoom.js +24 -0
  37. package/dist/prepare-entry-point.d.ts +11 -0
  38. package/dist/prepare-entry-point.js +36 -0
  39. package/dist/preview-server/error-overlay/remotion-overlay/Button.d.ts +1 -0
  40. package/dist/preview-server/error-overlay/remotion-overlay/Button.js +9 -2
  41. package/dist/preview-server/error-overlay/remotion-overlay/HelpLink.js +5 -1
  42. package/dist/preview-server/error-overlay/remotion-overlay/get-help-link.js +24 -0
  43. package/dist/preview-server/fast-refresh/helpers.d.ts +39 -0
  44. package/dist/preview-server/fast-refresh/helpers.js +145 -0
  45. package/dist/preview-server/fast-refresh/index.d.ts +30 -0
  46. package/dist/preview-server/fast-refresh/index.js +86 -0
  47. package/dist/preview-server/fast-refresh/loader.d.ts +35 -0
  48. package/dist/preview-server/fast-refresh/loader.js +81 -0
  49. package/dist/preview-server/fast-refresh/runtime.d.ts +35 -0
  50. package/dist/preview-server/fast-refresh/runtime.js +32 -0
  51. package/dist/preview-server/static-preview.d.ts +1 -0
  52. package/dist/preview-server/static-preview.js +40 -0
  53. package/dist/preview-server/webpack-cache.d.ts +12 -0
  54. package/dist/preview-server/webpack-cache.js +66 -0
  55. package/dist/render.js +9 -5
  56. package/dist/setup-cache.d.ts +8 -0
  57. package/dist/setup-cache.js +16 -1
  58. package/dist/still.js +6 -5
  59. package/dist/webpack-cache.d.ts +2 -2
  60. package/dist/webpack-cache.js +10 -10
  61. package/package.json +10 -10
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimelineList = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const colors_1 = require("../../helpers/colors");
5
6
  const is_collapsed_1 = require("./is-collapsed");
6
7
  const TimelineListItem_1 = require("./TimelineListItem");
7
8
  const container = {
8
9
  flex: 1,
9
10
  display: 'flex',
10
11
  flexDirection: 'column',
12
+ background: colors_1.BACKGROUND,
11
13
  };
12
14
  const TimelineList = ({ timeline, viewState, dispatchStateChange }) => {
13
15
  return ((0, jsx_runtime_1.jsx)("div", { style: container, children: timeline.map((track, i) => {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const TimelineScrollable: React.FC<{
3
+ children: React.ReactNode;
4
+ }>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineScrollable = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const timeline_refs_1 = require("./timeline-refs");
7
+ const outer = {
8
+ width: '100%',
9
+ height: '100%',
10
+ overflowX: 'auto',
11
+ position: 'relative',
12
+ backgroundColor: '#111',
13
+ };
14
+ const TimelineScrollable = ({ children }) => {
15
+ const containerStyle = (0, react_1.useMemo)(() => {
16
+ return {
17
+ width: '100%',
18
+ height: '100%',
19
+ };
20
+ }, []);
21
+ return ((0, jsx_runtime_1.jsx)("div", { ref: timeline_refs_1.scrollableRef, style: outer, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, children: children }) }));
22
+ };
23
+ exports.TimelineScrollable = TimelineScrollable;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const TimelineZoomControls: React.FC;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineZoomControls = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const timeline_zoom_1 = require("../../state/timeline-zoom");
7
+ const ControlButton_1 = require("../ControlButton");
8
+ const container = {
9
+ color: 'black',
10
+ flexDirection: 'row',
11
+ display: 'flex',
12
+ };
13
+ const buttonStyle = {
14
+ fontSize: 24,
15
+ };
16
+ const TimelineZoomControls = () => {
17
+ const { setZoom, zoom } = (0, react_1.useContext)(timeline_zoom_1.TimelineZoomCtx);
18
+ const onMinusClicked = (0, react_1.useCallback)(() => {
19
+ setZoom((z) => Math.max(timeline_zoom_1.TIMELINE_MIN_ZOOM, z - 0.2));
20
+ }, [setZoom]);
21
+ const onPlusClicked = (0, react_1.useCallback)(() => {
22
+ setZoom((z) => Math.min(timeline_zoom_1.TIMELINE_MAX_ZOOM, z + 0.2));
23
+ }, [setZoom]);
24
+ const onChange = (0, react_1.useCallback)((e) => {
25
+ setZoom(Number(e.target.value));
26
+ }, [setZoom]);
27
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsx)(ControlButton_1.ControlButton, { onClick: onMinusClicked, style: buttonStyle, title: "Zoom out timeline", role: 'ControlButton', type: "button", children: "-" }), (0, jsx_runtime_1.jsx)("input", { type: 'range', min: timeline_zoom_1.TIMELINE_MIN_ZOOM, step: 0.1, value: zoom, max: timeline_zoom_1.TIMELINE_MAX_ZOOM, onChange: onChange }), (0, jsx_runtime_1.jsx)(ControlButton_1.ControlButton, { onClick: onPlusClicked, style: buttonStyle, title: "Zoom in timeline", role: 'button', type: "button", children: "+" })] }));
28
+ };
29
+ exports.TimelineZoomControls = TimelineZoomControls;
@@ -0,0 +1,4 @@
1
+ export declare const canScrollTimelineIntoDirection: () => {
2
+ canScrollRight: boolean;
3
+ canScrollLeft: boolean;
4
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canScrollTimelineIntoDirection = void 0;
4
+ const timeline_layout_1 = require("../../helpers/timeline-layout");
5
+ const timeline_refs_1 = require("./timeline-refs");
6
+ const canScrollTimelineIntoDirection = () => {
7
+ const current = timeline_refs_1.scrollableRef.current;
8
+ const { scrollWidth, scrollLeft, clientWidth } = current;
9
+ const canScrollRight = scrollWidth - scrollLeft - clientWidth > timeline_layout_1.TIMELINE_PADDING;
10
+ const canScrollLeft = scrollLeft > timeline_layout_1.TIMELINE_PADDING;
11
+ return { canScrollRight, canScrollLeft };
12
+ };
13
+ exports.canScrollTimelineIntoDirection = canScrollTimelineIntoDirection;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export declare const TIMELINE_MIN_ZOOM = 1;
3
+ export declare const TIMELINE_MAX_ZOOM = 5;
4
+ export declare const TimelineZoomCtx: React.Context<{
5
+ zoom: number;
6
+ setZoom: React.Dispatch<React.SetStateAction<number>>;
7
+ }>;
8
+ export declare const TimelineZoomContext: React.FC<{
9
+ children: React.ReactNode;
10
+ }>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimelineZoomContext = exports.TimelineZoomCtx = exports.TIMELINE_MAX_ZOOM = exports.TIMELINE_MIN_ZOOM = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ exports.TIMELINE_MIN_ZOOM = 1;
7
+ exports.TIMELINE_MAX_ZOOM = 5;
8
+ exports.TimelineZoomCtx = (0, react_1.createContext)({
9
+ zoom: -1,
10
+ setZoom: () => {
11
+ throw new Error('has no context');
12
+ },
13
+ });
14
+ const TimelineZoomContext = ({ children }) => {
15
+ const [zoom, setZoom] = (0, react_1.useState)(exports.TIMELINE_MIN_ZOOM);
16
+ const value = (0, react_1.useMemo)(() => {
17
+ return {
18
+ zoom,
19
+ setZoom,
20
+ };
21
+ }, [zoom]);
22
+ return ((0, jsx_runtime_1.jsx)(exports.TimelineZoomCtx.Provider, { value: value, children: children }));
23
+ };
24
+ exports.TimelineZoomContext = TimelineZoomContext;
@@ -0,0 +1,11 @@
1
+ import { RenderStep } from './step';
2
+ export declare const prepareEntryPoint: ({ file, otherSteps, publicPath, outDir, }: {
3
+ file: string;
4
+ otherSteps: RenderStep[];
5
+ outDir: string | null;
6
+ publicPath: string | null;
7
+ }) => Promise<{
8
+ urlOrBundle: string;
9
+ steps: RenderStep[];
10
+ shouldDelete: boolean;
11
+ }>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.prepareEntryPoint = void 0;
7
+ const renderer_1 = require("@remotion/renderer");
8
+ const promises_1 = require("fs/promises");
9
+ const path_1 = __importDefault(require("path"));
10
+ const process_1 = require("process");
11
+ const log_1 = require("./log");
12
+ const setup_cache_1 = require("./setup-cache");
13
+ const prepareEntryPoint = async ({ file, otherSteps, publicPath, outDir, }) => {
14
+ if (renderer_1.RenderInternals.isServeUrl(file)) {
15
+ return { urlOrBundle: file, steps: otherSteps, shouldDelete: false };
16
+ }
17
+ const joined = path_1.default.resolve(process.cwd(), file);
18
+ try {
19
+ const stats = await (0, promises_1.stat)(joined);
20
+ if (stats.isDirectory()) {
21
+ return { urlOrBundle: joined, steps: otherSteps, shouldDelete: false };
22
+ }
23
+ }
24
+ catch (err) {
25
+ log_1.Log.error(`No file or directory exists at ${joined}.`);
26
+ (0, process_1.exit)(1);
27
+ }
28
+ const urlOrBundle = await (0, setup_cache_1.bundleOnCli)({
29
+ fullPath: joined,
30
+ steps: ['bundling', ...otherSteps],
31
+ outDir,
32
+ publicPath,
33
+ });
34
+ return { urlOrBundle, steps: ['bundling', ...otherSteps], shouldDelete: true };
35
+ };
36
+ exports.prepareEntryPoint = prepareEntryPoint;
@@ -3,4 +3,5 @@ export declare const Button: React.FC<{
3
3
  onClick: () => void;
4
4
  disabled?: boolean;
5
5
  children: React.ReactNode;
6
+ style?: React.CSSProperties;
6
7
  }>;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Button = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
5
6
  const colors_1 = require("../../../editor/helpers/colors");
6
7
  const button = {
7
8
  border: `1px solid ${colors_1.INPUT_BORDER_COLOR_UNHOVERED}`,
@@ -18,7 +19,13 @@ const buttonContainer = {
18
19
  cursor: 'pointer',
19
20
  fontSize: 14,
20
21
  };
21
- const Button = ({ children, onClick, disabled }) => {
22
- return ((0, jsx_runtime_1.jsx)("button", { style: button, type: "button", disabled: disabled, onClick: onClick, children: (0, jsx_runtime_1.jsx)("div", { style: buttonContainer, children: children }) }));
22
+ const Button = ({ children, onClick, disabled, style }) => {
23
+ const combined = (0, react_1.useMemo)(() => {
24
+ return {
25
+ ...button,
26
+ ...(style !== null && style !== void 0 ? style : {}),
27
+ };
28
+ }, [style]);
29
+ return ((0, jsx_runtime_1.jsx)("button", { style: combined, type: "button", disabled: disabled, onClick: onClick, children: (0, jsx_runtime_1.jsx)("div", { style: buttonContainer, children: children }) }));
23
30
  };
24
31
  exports.Button = Button;
@@ -6,6 +6,10 @@ const react_1 = require("react");
6
6
  const use_keybinding_1 = require("../../../editor/helpers/use-keybinding");
7
7
  const Button_1 = require("./Button");
8
8
  const ShortcutHint_1 = require("./ShortcutHint");
9
+ const buttonStyle = {
10
+ backgroundColor: 'var(--blue)',
11
+ color: 'white',
12
+ };
9
13
  const HelpLink = ({ canHaveKeyboardShortcuts, link }) => {
10
14
  const openLink = (0, react_1.useCallback)(() => {
11
15
  window.open(link.url, '_blank');
@@ -26,6 +30,6 @@ const HelpLink = ({ canHaveKeyboardShortcuts, link }) => {
26
30
  });
27
31
  return () => unregister();
28
32
  }, [canHaveKeyboardShortcuts, openLink, registerKeybinding]);
29
- return ((0, jsx_runtime_1.jsxs)(Button_1.Button, { onClick: openLink, children: ["Help: ", '"', link.title, '"', canHaveKeyboardShortcuts ? ((0, jsx_runtime_1.jsx)(ShortcutHint_1.ShortcutHint, { keyToPress: "h", cmdOrCtrl: true })) : null] }));
33
+ return ((0, jsx_runtime_1.jsxs)(Button_1.Button, { style: buttonStyle, onClick: openLink, children: ["Help: ", '"', link.title, '"', canHaveKeyboardShortcuts ? ((0, jsx_runtime_1.jsx)(ShortcutHint_1.ShortcutHint, { keyToPress: "h", cmdOrCtrl: true })) : null] }));
30
34
  };
31
35
  exports.HelpLink = HelpLink;
@@ -14,6 +14,30 @@ const getHelpLink = (message) => {
14
14
  url: 'https://remotion.dev/docs/wrong-composition-mount',
15
15
  };
16
16
  }
17
+ if (message.includes('https://remotion.dev/docs/staticfile-relative-paths')) {
18
+ return {
19
+ title: 'staticFile() relative paths',
20
+ url: 'https://remotion.dev/docs/staticfile-relative-paths',
21
+ };
22
+ }
23
+ if (message.includes('https://remotion.dev/docs/staticfile-remote-urls')) {
24
+ return {
25
+ title: 'staticFile() remote URLs',
26
+ url: 'https://remotion.dev/docs/staticfile-remote-urls',
27
+ };
28
+ }
29
+ if (message.includes('https://remotion.dev/docs/non-seekable-media')) {
30
+ return {
31
+ title: 'Non-seekable media',
32
+ url: 'https://remotion.dev/docs/non-seekable-media',
33
+ };
34
+ }
35
+ if (message.includes('https://remotion.dev/docs/media-playback-error')) {
36
+ return {
37
+ title: 'Media playback error',
38
+ url: 'https://remotion.dev/docs/media-playback-error',
39
+ };
40
+ }
17
41
  return null;
18
42
  };
19
43
  exports.getHelpLink = getHelpLink;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Source code is adapted from https://github.com/WebHotelier/webpack-fast-refresh#readme and rewritten in Typescript. This file is MIT licensed.
3
+ */
4
+ /**
5
+ * MIT License
6
+ *
7
+ * Copyright (c) Facebook, Inc. and its affiliates.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+ declare function registerExportsForReactRefresh(moduleExports: unknown, moduleID: unknown): void;
28
+ declare function isReactRefreshBoundary(moduleExports: unknown): boolean;
29
+ declare function shouldInvalidateReactRefreshBoundary(prevExports: unknown, nextExports: unknown): boolean;
30
+ declare function getRefreshBoundarySignature(moduleExports: unknown): any[];
31
+ declare function scheduleUpdate(): void;
32
+ declare const _default: {
33
+ registerExportsForReactRefresh: typeof registerExportsForReactRefresh;
34
+ isReactRefreshBoundary: typeof isReactRefreshBoundary;
35
+ shouldInvalidateReactRefreshBoundary: typeof shouldInvalidateReactRefreshBoundary;
36
+ getRefreshBoundarySignature: typeof getRefreshBoundarySignature;
37
+ scheduleUpdate: typeof scheduleUpdate;
38
+ };
39
+ export default _default;
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ /**
3
+ * Source code is adapted from https://github.com/WebHotelier/webpack-fast-refresh#readme and rewritten in Typescript. This file is MIT licensed.
4
+ */
5
+ /**
6
+ * MIT License
7
+ *
8
+ * Copyright (c) Facebook, Inc. and its affiliates.
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ * of this software and associated documentation files (the "Software"), to deal
12
+ * in the Software without restriction, including without limitation the rights
13
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ * copies of the Software, and to permit persons to whom the Software is
15
+ * furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all
18
+ * copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ * SOFTWARE.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ // This file is copied from the Metro JavaScript bundler, with minor tweaks for
30
+ // webpack compatibility.
31
+ //
32
+ // https://github.com/facebook/metro/blob/d6b9685c730d0d63577db40f41369157f28dfa3a/packages/metro/src/lib/polyfills/require.js
33
+ const RefreshRuntime = require('react-refresh/runtime');
34
+ function isSafeExport(key) {
35
+ return (key === '__esModule' ||
36
+ key === '__N_SSG' ||
37
+ key === '__N_SSP' ||
38
+ key === 'config');
39
+ }
40
+ function registerExportsForReactRefresh(moduleExports, moduleID) {
41
+ RefreshRuntime.register(moduleExports, moduleID + ' %exports%');
42
+ if (moduleExports === null ||
43
+ moduleExports === undefined ||
44
+ typeof moduleExports !== 'object') {
45
+ // Exit if we can't iterate over exports.
46
+ // (This is important for legacy environments.)
47
+ return;
48
+ }
49
+ for (const key in moduleExports) {
50
+ if (isSafeExport(key)) {
51
+ continue;
52
+ }
53
+ // @ts-expect-error
54
+ const exportValue = moduleExports[key];
55
+ const typeID = moduleID + ' %exports% ' + key;
56
+ RefreshRuntime.register(exportValue, typeID);
57
+ }
58
+ }
59
+ function isReactRefreshBoundary(moduleExports) {
60
+ if (RefreshRuntime.isLikelyComponentType(moduleExports)) {
61
+ return true;
62
+ }
63
+ if (moduleExports === null ||
64
+ moduleExports === undefined ||
65
+ typeof moduleExports !== 'object') {
66
+ // Exit if we can't iterate over exports.
67
+ return false;
68
+ }
69
+ let hasExports = false;
70
+ let areAllExportsComponents = true;
71
+ for (const key in moduleExports) {
72
+ hasExports = true;
73
+ if (isSafeExport(key)) {
74
+ continue;
75
+ }
76
+ // @ts-expect-error
77
+ const exportValue = moduleExports[key];
78
+ if (!RefreshRuntime.isLikelyComponentType(exportValue)) {
79
+ areAllExportsComponents = false;
80
+ }
81
+ }
82
+ return hasExports && areAllExportsComponents;
83
+ }
84
+ function shouldInvalidateReactRefreshBoundary(prevExports, nextExports) {
85
+ const prevSignature = getRefreshBoundarySignature(prevExports);
86
+ const nextSignature = getRefreshBoundarySignature(nextExports);
87
+ if (prevSignature.length !== nextSignature.length) {
88
+ return true;
89
+ }
90
+ for (let i = 0; i < nextSignature.length; i++) {
91
+ if (prevSignature[i] !== nextSignature[i]) {
92
+ return true;
93
+ }
94
+ }
95
+ return false;
96
+ }
97
+ function getRefreshBoundarySignature(moduleExports) {
98
+ const signature = [];
99
+ signature.push(RefreshRuntime.getFamilyByType(moduleExports));
100
+ if (moduleExports === null ||
101
+ moduleExports === undefined ||
102
+ typeof moduleExports !== 'object') {
103
+ // Exit if we can't iterate over exports.
104
+ // (This is important for legacy environments.)
105
+ return signature;
106
+ }
107
+ for (const key in moduleExports) {
108
+ if (isSafeExport(key)) {
109
+ continue;
110
+ }
111
+ // @ts-expect-error
112
+ const exportValue = moduleExports[key];
113
+ signature.push(key);
114
+ signature.push(RefreshRuntime.getFamilyByType(exportValue));
115
+ }
116
+ return signature;
117
+ }
118
+ function scheduleUpdate() {
119
+ var _a, _b;
120
+ const execute = () => {
121
+ try {
122
+ RefreshRuntime.performReactRefresh();
123
+ }
124
+ catch (err) {
125
+ console.warn('Warning: Failed to re-render. We will retry on the next Fast Refresh event.\n' +
126
+ err);
127
+ }
128
+ };
129
+ // Only trigger refresh if the webpack HMR state is idle
130
+ if (((_a = module.hot) === null || _a === void 0 ? void 0 : _a.status()) === 'idle') {
131
+ return;
132
+ }
133
+ (_b = module.hot) === null || _b === void 0 ? void 0 : _b.addStatusHandler((status) => {
134
+ if (status === 'idle') {
135
+ execute();
136
+ }
137
+ });
138
+ }
139
+ exports.default = {
140
+ registerExportsForReactRefresh,
141
+ isReactRefreshBoundary,
142
+ shouldInvalidateReactRefreshBoundary,
143
+ getRefreshBoundarySignature,
144
+ scheduleUpdate,
145
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Source code is adapted from https://github.com/WebHotelier/webpack-fast-refresh#readme and rewritten in Typescript. This file is MIT licensed.
3
+ */
4
+ /**
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright (c) 2020 Vercel, Inc.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+ import webpack from 'webpack';
28
+ export declare class ReactFreshWebpackPlugin {
29
+ apply(compiler: webpack.Compiler): void;
30
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * Source code is adapted from https://github.com/WebHotelier/webpack-fast-refresh#readme and rewritten in Typescript. This file is MIT licensed.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ReactFreshWebpackPlugin = void 0;
7
+ /**
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2020 Vercel, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+ // This file is copied from the @vercel/next.js, with removed TS annotations
31
+ // minor tweaks, and removed all webpack v4-related functionality
32
+ //
33
+ // https://github.com/vercel/next.js/blob/canary/packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts
34
+ const webpack_1 = require("webpack");
35
+ class ReactRefreshRuntimeModule extends webpack_1.RuntimeModule {
36
+ constructor() {
37
+ super('react refresh', 5);
38
+ }
39
+ generate() {
40
+ const { runtimeTemplate } = this.compilation;
41
+ return webpack_1.Template.asString([
42
+ `${webpack_1.RuntimeGlobals.interceptModuleExecution}.push(${runtimeTemplate.basicFunction('options', [
43
+ `const originalFactory = options.factory;`,
44
+ `options.factory = ${runtimeTemplate.basicFunction('moduleObject, moduleExports, webpackRequire', [
45
+ // Legacy CSS implementations will `eval` browser code in a Node.js
46
+ // context to extract CSS. For backwards compatibility, we need to check
47
+ // we're in a browser context before continuing.
48
+ `const hasRefresh = typeof self !== "undefined" && !!self.$RefreshInterceptModuleExecution$;`,
49
+ `const cleanup = hasRefresh ? self.$RefreshInterceptModuleExecution$(moduleObject.id) : () => {};`,
50
+ 'try {',
51
+ webpack_1.Template.indent('originalFactory.call(this, moduleObject, moduleExports, webpackRequire);'),
52
+ '} finally {',
53
+ webpack_1.Template.indent(`cleanup();`),
54
+ '}',
55
+ ])}`,
56
+ ])})`,
57
+ ]);
58
+ }
59
+ }
60
+ class ReactFreshWebpackPlugin {
61
+ apply(compiler) {
62
+ const webpackMajorVersion = parseInt(webpack_1.version !== null && webpack_1.version !== void 0 ? webpack_1.version : '', 10);
63
+ if (webpackMajorVersion < 5) {
64
+ throw new Error(`ReactFreshWebpackPlugin does not support webpack v${webpackMajorVersion}.`);
65
+ }
66
+ compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
67
+ compilation.mainTemplate.hooks.localVars.tap(this.constructor.name, (source) => webpack_1.Template.asString([
68
+ source,
69
+ '',
70
+ '// noop fns to prevent runtime errors during initialization',
71
+ 'if (typeof self !== "undefined") {',
72
+ webpack_1.Template.indent('self.$RefreshReg$ = function () {};'),
73
+ webpack_1.Template.indent('self.$RefreshSig$ = function () {'),
74
+ webpack_1.Template.indent(webpack_1.Template.indent('return function (type) {')),
75
+ webpack_1.Template.indent(webpack_1.Template.indent(webpack_1.Template.indent('return type;'))),
76
+ webpack_1.Template.indent(webpack_1.Template.indent('};')),
77
+ webpack_1.Template.indent('};'),
78
+ '}',
79
+ ]));
80
+ compilation.hooks.additionalTreeRuntimeRequirements.tap(this.constructor.name, (chunk) => {
81
+ compilation.addRuntimeModule(chunk, new ReactRefreshRuntimeModule());
82
+ });
83
+ });
84
+ }
85
+ }
86
+ exports.ReactFreshWebpackPlugin = ReactFreshWebpackPlugin;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * ⚠️ Be careful when refactoring this file!
3
+ * This gets injected into every file of the browser.
4
+ * You cannot have returns, optional chains, inverse the if statement etc.
5
+ * Check the Typescript output in dist/ to see that no extra `var` statements were produced
6
+ */
7
+ /**
8
+ * Source code is adapted from https://github.com/WebHotelier/webpack-fast-refresh#readme and rewritten in Typescript. This file is MIT licensed.
9
+ */
10
+ /**
11
+ * The MIT License (MIT)
12
+ *
13
+ * Copyright (c) 2020 Vercel, Inc.
14
+ *
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ * of this software and associated documentation files (the "Software"), to deal
17
+ * in the Software without restriction, including without limitation the rights
18
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ * copies of the Software, and to permit persons to whom the Software is
20
+ * furnished to do so, subject to the following conditions:
21
+ *
22
+ * The above copyright notice and this permission notice shall be included in all
23
+ * copies or substantial portions of the Software.
24
+ *
25
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ * SOFTWARE.
32
+ */
33
+ import { LoaderDefinition } from 'webpack';
34
+ declare const ReactRefreshLoader: LoaderDefinition;
35
+ export default ReactRefreshLoader;