@remotion/bundler 4.0.0-webhook.27 → 4.1.0-alpha2

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 (47) hide show
  1. package/LICENSE.md +8 -8
  2. package/dist/bundle-mode.d.ts +0 -0
  3. package/dist/bundle-mode.js +0 -0
  4. package/dist/bundle.d.ts +12 -4
  5. package/dist/bundle.js +111 -25
  6. package/dist/copy-dir.d.ts +9 -1
  7. package/dist/copy-dir.js +25 -9
  8. package/dist/esbuild-loader/index.d.ts +0 -0
  9. package/dist/esbuild-loader/index.js +2 -2
  10. package/dist/esbuild-loader/interfaces.d.ts +3 -3
  11. package/dist/esbuild-loader/interfaces.js +0 -0
  12. package/dist/fast-refresh/helpers.d.ts +0 -0
  13. package/dist/fast-refresh/helpers.js +2 -2
  14. package/dist/fast-refresh/index.d.ts +0 -0
  15. package/dist/fast-refresh/index.js +0 -0
  16. package/dist/fast-refresh/loader.d.ts +94 -0
  17. package/dist/fast-refresh/loader.js +8 -15
  18. package/dist/fast-refresh/runtime.d.ts +0 -0
  19. package/dist/fast-refresh/runtime.js +0 -1
  20. package/dist/homepage/homepage.d.ts +0 -0
  21. package/dist/homepage/homepage.js +53 -9
  22. package/dist/index-html.d.ts +39 -2
  23. package/dist/index-html.js +17 -7
  24. package/dist/index.d.ts +21 -8
  25. package/dist/index.js +2 -0
  26. package/dist/optional-dependencies.d.ts +5 -0
  27. package/dist/optional-dependencies.js +27 -0
  28. package/dist/read-recursively.d.ts +8 -0
  29. package/dist/read-recursively.js +78 -0
  30. package/dist/renderEntry.d.ts +0 -0
  31. package/dist/renderEntry.js +42 -16
  32. package/dist/setup-environment.d.ts +0 -0
  33. package/dist/setup-environment.js +81 -0
  34. package/dist/stringify-with-circular-references.d.ts +1 -0
  35. package/dist/stringify-with-circular-references.js +18 -0
  36. package/dist/test/validate-bundle.test.d.ts +0 -0
  37. package/dist/test/validate-bundle.test.js +0 -0
  38. package/dist/test/validate-public-dir.test.d.ts +0 -0
  39. package/dist/test/validate-public-dir.test.js +2 -2
  40. package/dist/validate-public-dir.d.ts +0 -0
  41. package/dist/validate-public-dir.js +6 -6
  42. package/dist/webpack-cache.d.ts +4 -3
  43. package/dist/webpack-cache.js +24 -23
  44. package/dist/webpack-config.d.ts +6 -4
  45. package/dist/webpack-config.js +16 -14
  46. package/package.json +64 -67
  47. package/react-shim.js +5 -1
package/LICENSE.md CHANGED
@@ -1,34 +1,34 @@
1
1
  # Remotion License
2
2
 
3
- Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion create videos for free (even commercial), while a company license is required for for-profit organisations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
3
+ Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
4
4
 
5
5
  - [Free license](#free-license)
6
6
  - [Company license](#company-license)
7
7
 
8
8
  ## Free license
9
9
 
10
- Copyright © 2022 [Jonny Burger](https://jonny.io)
10
+ Copyright © 2023 [Remotion](https://www.remotion.dev/)
11
11
 
12
12
  ### Eligibility
13
13
 
14
14
  You are eligible to use Remotion for free if you are:
15
15
 
16
16
  - an individual
17
- - a for-profit organisation with up to 3 employees
18
- - a non-profit or not-for-profit organisation
17
+ - a for-profit organization with up to 3 employees
18
+ - a non-profit or not-for-profit organization
19
19
  - evaluating whether Remotion is a good fit, and are not yet using it in a commercial way
20
20
 
21
21
  ### Allowed use cases
22
22
 
23
- Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify and the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
23
+ Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
24
24
 
25
25
  ### Disallowed use cases
26
26
 
27
- It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, sublicensing your own derivate of Remotion.
27
+ It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, or sublicensing your own derivate of Remotion.
28
28
 
29
29
  ### Warranty notice
30
30
 
31
- 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 author 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.
31
+ 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 non-infringement. In no event shall the author 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.
32
32
 
33
33
  ### Support
34
34
 
@@ -36,6 +36,6 @@ Support is provided on a best-we-can-do basis via GitHub Issues and Discord.
36
36
 
37
37
  ## Company license
38
38
 
39
- You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support.
39
+ You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support (read the [Support Policy](/docs/support)).
40
40
 
41
41
  Visit [companies.remotion.dev](https://companies.remotion.dev) for pricing and to buy a license.
File without changes
File without changes
package/dist/bundle.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- import type { WebpackOverrideFn } from 'remotion';
2
1
  import webpack from 'webpack';
3
- export declare type LegacyBundleOptions = {
2
+ import type { WebpackOverrideFn } from './webpack-config';
3
+ export type LegacyBundleOptions = {
4
4
  webpackOverride?: WebpackOverrideFn;
5
5
  outDir?: string;
6
6
  enableCaching?: boolean;
7
7
  publicPath?: string;
8
8
  rootDir?: string;
9
9
  publicDir?: string | null;
10
+ onPublicDirCopyProgress?: (bytes: number) => void;
11
+ onSymlinkDetected?: (path: string) => void;
10
12
  };
11
13
  export declare const getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, options, }: {
12
14
  outDir: string;
@@ -15,14 +17,20 @@ export declare const getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onP
15
17
  onProgress?: ((progress: number) => void) | undefined;
16
18
  options?: LegacyBundleOptions | undefined;
17
19
  }) => [string, webpack.Configuration];
18
- export declare type BundleOptions = {
20
+ export type BundleOptions = {
19
21
  entryPoint: string;
20
22
  onProgress?: (progress: number) => void;
23
+ ignoreRegisterRootWarning?: boolean;
24
+ onDirectoryCreated?: (dir: string) => void;
21
25
  } & LegacyBundleOptions;
22
- declare type Arguments = [options: BundleOptions] | [
26
+ type Arguments = [options: BundleOptions] | [
23
27
  entryPoint: string,
24
28
  onProgress?: (progress: number) => void,
25
29
  options?: LegacyBundleOptions
26
30
  ];
31
+ /**
32
+ * @description The method bundles a Remotion project using Webpack and prepares it for rendering using renderMedia()
33
+ * @see [Documentation](https://www.remotion.dev/docs/bundle)
34
+ */
27
35
  export declare function bundle(...args: Arguments): Promise<string>;
28
36
  export {};
package/dist/bundle.js CHANGED
@@ -1,25 +1,49 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.bundle = exports.getConfig = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const os_1 = __importDefault(require("os"));
9
- const path_1 = __importDefault(require("path"));
10
- const util_1 = require("util");
30
+ const node_fs_1 = __importStar(require("node:fs"));
31
+ const node_os_1 = __importDefault(require("node:os"));
32
+ const node_path_1 = __importDefault(require("node:path"));
33
+ const node_util_1 = require("node:util");
34
+ const node_worker_threads_1 = require("node:worker_threads");
11
35
  const webpack_1 = __importDefault(require("webpack"));
12
- const worker_threads_1 = require("worker_threads");
13
36
  const copy_dir_1 = require("./copy-dir");
14
37
  const index_html_1 = require("./index-html");
38
+ const read_recursively_1 = require("./read-recursively");
15
39
  const webpack_config_1 = require("./webpack-config");
16
- const promisified = (0, util_1.promisify)(webpack_1.default);
40
+ const promisified = (0, node_util_1.promisify)(webpack_1.default);
17
41
  const prepareOutDir = async (specified) => {
18
42
  if (specified) {
19
- await fs_1.default.promises.mkdir(specified, { recursive: true });
43
+ await node_fs_1.default.promises.mkdir(specified, { recursive: true });
20
44
  return specified;
21
45
  }
22
- return fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'react-motion-graphics'));
46
+ return node_fs_1.default.promises.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), 'remotion-webpack-bundle-'));
23
47
  };
24
48
  const trimLeadingSlash = (p) => {
25
49
  if (p.startsWith('/')) {
@@ -44,12 +68,11 @@ const getConfig = ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, optio
44
68
  webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : ((f) => f),
45
69
  onProgress,
46
70
  enableCaching: (_b = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _b !== void 0 ? _b : true,
47
- maxTimelineTracks: 15,
48
- // For production, the variables are set dynamically
49
- envVariables: {},
71
+ maxTimelineTracks: 90,
50
72
  entryPoints: [],
51
73
  remotionRoot: resolvedRemotionRoot,
52
74
  keyboardShortcutsEnabled: false,
75
+ poll: null,
53
76
  });
54
77
  };
55
78
  exports.getConfig = getConfig;
@@ -71,19 +94,52 @@ const convertArgumentsIntoOptions = (args) => {
71
94
  }
72
95
  return firstArg;
73
96
  };
97
+ const recursionLimit = 5;
98
+ const findClosestPackageJsonFolder = (currentDir) => {
99
+ let possiblePackageJson = '';
100
+ for (let i = 0; i < recursionLimit; i++) {
101
+ possiblePackageJson = node_path_1.default.join(currentDir, 'package.json');
102
+ const exists = node_fs_1.default.existsSync(possiblePackageJson);
103
+ if (exists) {
104
+ return node_path_1.default.dirname(possiblePackageJson);
105
+ }
106
+ currentDir = node_path_1.default.dirname(currentDir);
107
+ }
108
+ return null;
109
+ };
110
+ const validateEntryPoint = async (entryPoint) => {
111
+ const contents = await node_fs_1.promises.readFile(entryPoint, 'utf8');
112
+ if (!contents.includes('registerRoot')) {
113
+ throw new Error([
114
+ `You passed ${entryPoint} as your entry point, but this file does not contain "registerRoot".`,
115
+ 'You should use the file that calls registerRoot() as the entry point.',
116
+ 'To ignore this error, pass "ignoreRegisterRootWarning" to bundle().',
117
+ 'This error cannot be ignored on the CLI.',
118
+ ].join(' '));
119
+ }
120
+ };
121
+ /**
122
+ * @description The method bundles a Remotion project using Webpack and prepares it for rendering using renderMedia()
123
+ * @see [Documentation](https://www.remotion.dev/docs/bundle)
124
+ */
74
125
  async function bundle(...args) {
75
- var _a, _b, _c;
126
+ var _a, _b, _c, _d, _e;
76
127
  const actualArgs = convertArgumentsIntoOptions(args);
77
- const resolvedRemotionRoot = (_a = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.rootDir) !== null && _a !== void 0 ? _a : process.cwd();
78
- const outDir = await prepareOutDir((_b = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.outDir) !== null && _b !== void 0 ? _b : null);
128
+ const entryPoint = node_path_1.default.resolve(process.cwd(), actualArgs.entryPoint);
129
+ const resolvedRemotionRoot = (_b = (_a = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.rootDir) !== null && _a !== void 0 ? _a : findClosestPackageJsonFolder(entryPoint)) !== null && _b !== void 0 ? _b : process.cwd();
130
+ if (!actualArgs.ignoreRegisterRootWarning) {
131
+ await validateEntryPoint(entryPoint);
132
+ }
133
+ const outDir = await prepareOutDir((_c = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.outDir) !== null && _c !== void 0 ? _c : null);
134
+ (_d = actualArgs.onDirectoryCreated) === null || _d === void 0 ? void 0 : _d.call(actualArgs, outDir);
79
135
  // The config might use an override which might use
80
136
  // `process.cwd()`. The context should always be the Remotion root.
81
137
  // This is not supported in worker threads (used for tests)
82
138
  const currentCwd = process.cwd();
83
- if (worker_threads_1.isMainThread) {
139
+ if (node_worker_threads_1.isMainThread) {
84
140
  process.chdir(resolvedRemotionRoot);
85
141
  }
86
- const { entryPoint, onProgress, ...options } = actualArgs;
142
+ const { onProgress, ...options } = actualArgs;
87
143
  const [, config] = (0, exports.getConfig)({
88
144
  outDir,
89
145
  entryPoint,
@@ -92,7 +148,7 @@ async function bundle(...args) {
92
148
  options,
93
149
  });
94
150
  const output = await promisified([config]);
95
- if (worker_threads_1.isMainThread) {
151
+ if (node_worker_threads_1.isMainThread) {
96
152
  process.chdir(currentCwd);
97
153
  }
98
154
  if (!output) {
@@ -102,17 +158,36 @@ async function bundle(...args) {
102
158
  if (errors !== undefined && errors.length > 0) {
103
159
  throw new Error(errors[0].message + '\n' + errors[0].details);
104
160
  }
105
- const baseDir = (_c = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.publicPath) !== null && _c !== void 0 ? _c : '/';
161
+ const baseDir = (_e = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.publicPath) !== null && _e !== void 0 ? _e : '/';
106
162
  const staticHash = '/' +
107
163
  [trimTrailingSlash(trimLeadingSlash(baseDir)), 'public']
108
164
  .filter(Boolean)
109
165
  .join('/');
110
166
  const from = (options === null || options === void 0 ? void 0 : options.publicDir)
111
- ? path_1.default.resolve(resolvedRemotionRoot, options.publicDir)
112
- : path_1.default.join(resolvedRemotionRoot, 'public');
113
- const to = path_1.default.join(outDir, 'public');
114
- if (fs_1.default.existsSync(from)) {
115
- await (0, copy_dir_1.copyDir)(from, to);
167
+ ? node_path_1.default.resolve(resolvedRemotionRoot, options.publicDir)
168
+ : node_path_1.default.join(resolvedRemotionRoot, 'public');
169
+ const to = node_path_1.default.join(outDir, 'public');
170
+ let symlinkWarningShown = false;
171
+ const showSymlinkWarning = (ent, src) => {
172
+ if (symlinkWarningShown) {
173
+ return;
174
+ }
175
+ const absolutePath = node_path_1.default.join(src, ent.name);
176
+ if (options.onSymlinkDetected) {
177
+ options.onSymlinkDetected(absolutePath);
178
+ return;
179
+ }
180
+ symlinkWarningShown = true;
181
+ console.warn(`\nFound a symbolic link in the public folder (${absolutePath}). The symlink will be forwarded into the bundle.`);
182
+ };
183
+ if (node_fs_1.default.existsSync(from)) {
184
+ await (0, copy_dir_1.copyDir)({
185
+ src: from,
186
+ dest: to,
187
+ onSymlinkDetected: showSymlinkWarning,
188
+ onProgress: (prog) => { var _a; return (_a = options.onPublicDirCopyProgress) === null || _a === void 0 ? void 0 : _a.call(options, prog); },
189
+ copied: 0,
190
+ });
116
191
  }
117
192
  const html = (0, index_html_1.indexHtml)({
118
193
  staticHash,
@@ -120,9 +195,20 @@ async function bundle(...args) {
120
195
  editorName: null,
121
196
  inputProps: null,
122
197
  remotionRoot: resolvedRemotionRoot,
123
- previewServerCommand: null,
198
+ studioServerCommand: null,
199
+ renderQueue: null,
200
+ numberOfAudioTags: 0,
201
+ publicFiles: (0, read_recursively_1.readRecursively)({
202
+ folder: '.',
203
+ startPath: from,
204
+ staticHash,
205
+ limit: 1000,
206
+ }),
207
+ includeFavicon: false,
208
+ title: 'Remotion Bundle',
209
+ renderDefaults: undefined,
124
210
  });
125
- fs_1.default.writeFileSync(path_1.default.join(outDir, 'index.html'), html);
211
+ node_fs_1.default.writeFileSync(node_path_1.default.join(outDir, 'index.html'), html);
126
212
  return outDir;
127
213
  }
128
214
  exports.bundle = bundle;
@@ -1 +1,9 @@
1
- export declare function copyDir(src: string, dest: string): Promise<void>;
1
+ /// <reference types="node" />
2
+ import fs from 'node:fs';
3
+ export declare function copyDir({ src, dest, onSymlinkDetected, onProgress, copied, }: {
4
+ src: string;
5
+ dest: string;
6
+ onSymlinkDetected: (entry: fs.Dirent, dir: string) => void;
7
+ onProgress: (bytes: number) => void;
8
+ copied: number;
9
+ }): Promise<void>;
package/dist/copy-dir.js CHANGED
@@ -4,19 +4,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.copyDir = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- async function copyDir(src, dest) {
10
- await fs_1.default.promises.mkdir(dest, { recursive: true });
11
- const entries = await fs_1.default.promises.readdir(src, { withFileTypes: true });
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ async function copyDir({ src, dest, onSymlinkDetected, onProgress, copied = 0, }) {
10
+ await node_fs_1.default.promises.mkdir(dest, { recursive: true });
11
+ const entries = await node_fs_1.default.promises.readdir(src, { withFileTypes: true });
12
12
  for (const entry of entries) {
13
- const srcPath = path_1.default.join(src, entry.name);
14
- const destPath = path_1.default.join(dest, entry.name);
13
+ const srcPath = node_path_1.default.join(src, entry.name);
14
+ const destPath = node_path_1.default.join(dest, entry.name);
15
15
  if (entry.isDirectory()) {
16
- await copyDir(srcPath, destPath);
16
+ await copyDir({
17
+ src: srcPath,
18
+ dest: destPath,
19
+ onSymlinkDetected,
20
+ onProgress,
21
+ copied,
22
+ });
23
+ }
24
+ else if (entry.isSymbolicLink()) {
25
+ const realpath = await node_fs_1.default.promises.realpath(srcPath);
26
+ onSymlinkDetected(entry, src);
27
+ await node_fs_1.default.promises.symlink(realpath, destPath);
17
28
  }
18
29
  else {
19
- await fs_1.default.promises.copyFile(srcPath, destPath);
30
+ const [, { size }] = await Promise.all([
31
+ node_fs_1.default.promises.copyFile(srcPath, destPath),
32
+ node_fs_1.default.promises.stat(srcPath),
33
+ ]);
34
+ copied += size;
35
+ onProgress(copied);
20
36
  }
21
37
  }
22
38
  }
File without changes
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const esbuild_1 = require("esbuild");
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const isTsExtensionPtrn = /\.ts$/i;
9
9
  const isTypescriptInstalled = () => {
10
10
  try {
@@ -21,7 +21,7 @@ async function ESBuildLoader(source) {
21
21
  this.getOptions();
22
22
  const options = this.getOptions();
23
23
  const { implementation, ...esbuildTransformOptions } = options;
24
- const tsConfigPath = path_1.default.join(this.context, 'tsconfig.json');
24
+ const tsConfigPath = node_path_1.default.join(this.context, 'tsconfig.json');
25
25
  if (implementation && typeof implementation.transform !== 'function') {
26
26
  done(new TypeError(`esbuild-loader: options.implementation.transform must be an ESBuild transform function. Received ${typeof implementation.transform}`));
27
27
  return;
@@ -1,11 +1,11 @@
1
1
  import type { transform, TransformOptions } from 'esbuild';
2
- declare type Implementation = {
2
+ type Implementation = {
3
3
  transform: typeof transform;
4
4
  };
5
- declare type Except<ObjectType, Properties> = {
5
+ type Except<ObjectType, Properties> = {
6
6
  [Key in keyof ObjectType as Key extends Properties ? never : Key]: ObjectType[Key];
7
7
  };
8
- export declare type LoaderOptions = Except<TransformOptions, 'sourcemap' | 'sourcefile'> & {
8
+ export type LoaderOptions = Except<TransformOptions, 'sourcemap' | 'sourcefile'> & {
9
9
  implementation: Implementation;
10
10
  };
11
11
  export {};
File without changes
File without changes
@@ -127,10 +127,10 @@ function scheduleUpdate() {
127
127
  }
128
128
  };
129
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') {
130
+ if (((_a = __webpack_module__.hot) === null || _a === void 0 ? void 0 : _a.status()) === 'idle') {
131
131
  return;
132
132
  }
133
- (_b = module.hot) === null || _b === void 0 ? void 0 : _b.addStatusHandler((status) => {
133
+ (_b = __webpack_module__.hot) === null || _b === void 0 ? void 0 : _b.addStatusHandler((status) => {
134
134
  if (status === 'idle') {
135
135
  execute();
136
136
  }
File without changes
File without changes
@@ -31,5 +31,99 @@
31
31
  * SOFTWARE.
32
32
  */
33
33
  import type { LoaderDefinition } from 'webpack';
34
+ declare global {
35
+ const __webpack_hash__: unknown;
36
+ interface HotNotifierInfo {
37
+ type: 'self-declined' | 'declined' | 'unaccepted' | 'accepted' | 'disposed' | 'accept-errored' | 'self-accept-errored' | 'self-accept-error-handler-errored';
38
+ /**
39
+ * The module in question.
40
+ */
41
+ moduleId: number;
42
+ /**
43
+ * For errors: the module id owning the accept handler.
44
+ */
45
+ dependencyId?: number | undefined;
46
+ /**
47
+ * For declined/accepted/unaccepted: the chain from where the update was propagated.
48
+ */
49
+ chain?: number[] | undefined;
50
+ /**
51
+ * For declined: the module id of the declining parent
52
+ */
53
+ parentId?: number | undefined;
54
+ /**
55
+ * For accepted: the modules that are outdated and will be disposed
56
+ */
57
+ outdatedModules?: number[] | undefined;
58
+ /**
59
+ * For accepted: The location of accept handlers that will handle the update
60
+ */
61
+ outdatedDependencies?: {
62
+ [dependencyId: number]: number[];
63
+ } | undefined;
64
+ /**
65
+ * For errors: the thrown error
66
+ */
67
+ error?: Error | undefined;
68
+ /**
69
+ * For self-accept-error-handler-errored: the error thrown by the module
70
+ * before the error handler tried to handle it.
71
+ */
72
+ originalError?: Error | undefined;
73
+ }
74
+ interface AcceptOptions {
75
+ /**
76
+ * If true the update process continues even if some modules are not accepted (and would bubble to the entry point).
77
+ */
78
+ ignoreUnaccepted?: boolean | undefined;
79
+ /**
80
+ * Ignore changes made to declined modules.
81
+ */
82
+ ignoreDeclined?: boolean | undefined;
83
+ /**
84
+ * Ignore errors throw in accept handlers, error handlers and while reevaluating module.
85
+ */
86
+ ignoreErrored?: boolean | undefined;
87
+ /**
88
+ * Notifier for declined modules.
89
+ */
90
+ onDeclined?: ((info: HotNotifierInfo) => void) | undefined;
91
+ /**
92
+ * Notifier for unaccepted modules.
93
+ */
94
+ onUnaccepted?: ((info: HotNotifierInfo) => void) | undefined;
95
+ /**
96
+ * Notifier for accepted modules.
97
+ */
98
+ onAccepted?: ((info: HotNotifierInfo) => void) | undefined;
99
+ /**
100
+ * Notifier for disposed modules.
101
+ */
102
+ onDisposed?: ((info: HotNotifierInfo) => void) | undefined;
103
+ /**
104
+ * Notifier for errors.
105
+ */
106
+ onErrored?: ((info: HotNotifierInfo) => void) | undefined;
107
+ /**
108
+ * Indicates that apply() is automatically called by check function
109
+ */
110
+ autoApply?: boolean | undefined;
111
+ }
112
+ const __webpack_module__: {
113
+ id: string;
114
+ exports: unknown;
115
+ hot: {
116
+ accept: () => void;
117
+ dispose: (onDispose: (data: Record<string, unknown>) => void) => void;
118
+ invalidate: () => void;
119
+ data?: Record<string, unknown>;
120
+ addStatusHandler(callback: (status: string) => void): void;
121
+ status(): string;
122
+ apply(options?: AcceptOptions): Promise<ModuleId[]>;
123
+ check(autoApply?: boolean): Promise<null | ModuleId[]>;
124
+ };
125
+ };
126
+ type ModuleId = string | number;
127
+ }
34
128
  declare const ReactRefreshLoader: LoaderDefinition;
35
129
  export default ReactRefreshLoader;
@@ -12,34 +12,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  // This function gets unwrapped into global scope, which is why we don't invert
13
13
  // if-blocks. Also, you cannot use `return`.
14
14
  function RefreshModuleRuntime() {
15
+ var _a, _b;
15
16
  // Legacy CSS implementations will `eval` browser code in a Node.js context
16
17
  // to extract CSS. For backwards compatibility, we need to check we're in a
17
18
  // browser context before continuing.
18
19
  if (typeof self !== 'undefined' &&
19
20
  // AMP / No-JS mode does not inject these helpers:
20
21
  '$RefreshHelpers$' in self) {
21
- // @ts-expect-error
22
- // eslint-disable-next-line no-proto
23
- const currentExports = module.__proto__.exports;
24
- let prevExports = null;
25
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
26
- if (module.hot && module.hot.data && module.hot.data.prevExports) {
27
- prevExports = module.hot.data.prevExports;
28
- }
22
+ const currentExports = __webpack_module__.exports;
23
+ const prevExports = (_b = (_a = __webpack_module__.hot.data) === null || _a === void 0 ? void 0 : _a.prevExports) !== null && _b !== void 0 ? _b : null;
29
24
  // This cannot happen in MainTemplate because the exports mismatch between
30
25
  // templating and execution.
31
- self.$RefreshHelpers$.registerExportsForReactRefresh(currentExports, module.id);
26
+ self.$RefreshHelpers$.registerExportsForReactRefresh(currentExports, __webpack_module__.id);
32
27
  // A module can be accepted automatically based on its exports, e.g. when
33
28
  // it is a Refresh Boundary.
34
29
  if (self.$RefreshHelpers$.isReactRefreshBoundary(currentExports)) {
35
30
  // Save the previous exports on update so we can compare the boundary
36
31
  // signatures.
37
- module.hot.dispose((data) => {
32
+ __webpack_module__.hot.dispose((data) => {
38
33
  data.prevExports = currentExports;
39
34
  });
40
35
  // Unconditionally accept an update to this module, we'll check if it's
41
36
  // still a Refresh Boundary later.
42
- module.hot.accept();
37
+ __webpack_module__.hot.accept();
43
38
  // This field is set when the previous version of this module was a
44
39
  // Refresh Boundary, letting us know we need to check for invalidation or
45
40
  // enqueue an update.
@@ -52,8 +47,7 @@ function RefreshModuleRuntime() {
52
47
  // re-render. Similarly, if you convert a class component to a
53
48
  // function, we want to invalidate the boundary.
54
49
  if (self.$RefreshHelpers$.shouldInvalidateReactRefreshBoundary(prevExports, currentExports)) {
55
- // @ts-expect-error
56
- module.hot.invalidate();
50
+ __webpack_module__.hot.invalidate();
57
51
  }
58
52
  else {
59
53
  self.$RefreshHelpers$.scheduleUpdate();
@@ -67,8 +61,7 @@ function RefreshModuleRuntime() {
67
61
  // because we already accepted this update (accidental side effect).
68
62
  const isNoLongerABoundary = prevExports !== null;
69
63
  if (isNoLongerABoundary) {
70
- // @ts-expect-error
71
- module.hot.invalidate();
64
+ __webpack_module__.hot.invalidate();
72
65
  }
73
66
  }
74
67
  }
File without changes
@@ -24,7 +24,6 @@ self.$RefreshInterceptModuleExecution$ = function (webpackModuleId) {
24
24
  };
25
25
  self.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
26
26
  // Modeled after `useEffect` cleanup pattern:
27
- // https://reactjs.org/docs/hooks-effect.html#effects-with-cleanup
28
27
  return () => {
29
28
  self.$RefreshReg$ = prevRefreshReg;
30
29
  self.$RefreshSig$ = prevRefreshSig;
File without changes