@remotion/bundler 3.1.4 → 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +10 -4
- package/dist/bundle.js +36 -11
- package/dist/esbuild-loader/index.js +1 -1
- package/dist/index-html.d.ts +7 -1
- package/dist/index-html.js +3 -3
- package/dist/index.d.ts +21 -12
- package/dist/setup-environment.js +0 -1
- package/dist/webpack-cache.d.ts +2 -2
- package/dist/webpack-cache.js +13 -14
- package/dist/webpack-config.d.ts +2 -1
- package/dist/webpack-config.js +2 -1
- package/package.json +3 -3
- package/dist/bundler.d.ts +0 -7
- package/dist/bundler.js +0 -76
- package/dist/dev-middleware/compatible-api.d.ts +0 -10
- package/dist/dev-middleware/compatible-api.js +0 -44
- package/dist/dev-middleware/get-filename-from-url.d.ts +0 -2
- package/dist/dev-middleware/get-filename-from-url.js +0 -92
- package/dist/dev-middleware/get-paths.d.ts +0 -7
- package/dist/dev-middleware/get-paths.js +0 -19
- package/dist/dev-middleware/index.d.ts +0 -3
- package/dist/dev-middleware/index.js +0 -57
- package/dist/dev-middleware/is-color-supported.d.ts +0 -1
- package/dist/dev-middleware/is-color-supported.js +0 -37
- package/dist/dev-middleware/middleware.d.ts +0 -4
- package/dist/dev-middleware/middleware.js +0 -141
- package/dist/dev-middleware/range-parser.d.ts +0 -15
- package/dist/dev-middleware/range-parser.js +0 -96
- package/dist/dev-middleware/ready.d.ts +0 -5
- package/dist/dev-middleware/ready.js +0 -13
- package/dist/dev-middleware/setup-hooks.d.ts +0 -2
- package/dist/dev-middleware/setup-hooks.js +0 -44
- package/dist/dev-middleware/setup-output-filesystem.d.ts +0 -2
- package/dist/dev-middleware/setup-output-filesystem.js +0 -13
- package/dist/dev-middleware/types.d.ts +0 -11
- package/dist/dev-middleware/types.js +0 -2
- package/dist/error-overlay/entry-basic.d.ts +0 -1
- package/dist/error-overlay/entry-basic.js +0 -21
- package/dist/error-overlay/react-overlay/effects/format-warning.d.ts +0 -11
- package/dist/error-overlay/react-overlay/effects/format-warning.js +0 -41
- package/dist/error-overlay/react-overlay/effects/map-error-to-react-stack.d.ts +0 -7
- package/dist/error-overlay/react-overlay/effects/map-error-to-react-stack.js +0 -46
- package/dist/error-overlay/react-overlay/effects/proxy-console.d.ts +0 -24
- package/dist/error-overlay/react-overlay/effects/proxy-console.js +0 -63
- package/dist/error-overlay/react-overlay/effects/resolve-file-source.d.ts +0 -3
- package/dist/error-overlay/react-overlay/effects/resolve-file-source.js +0 -31
- package/dist/error-overlay/react-overlay/effects/stack-trace-limit.d.ts +0 -3
- package/dist/error-overlay/react-overlay/effects/stack-trace-limit.js +0 -43
- package/dist/error-overlay/react-overlay/effects/unhandled-error.d.ts +0 -4
- package/dist/error-overlay/react-overlay/effects/unhandled-error.js +0 -45
- package/dist/error-overlay/react-overlay/effects/unhandled-rejection.d.ts +0 -4
- package/dist/error-overlay/react-overlay/effects/unhandled-rejection.js +0 -41
- package/dist/error-overlay/react-overlay/index.d.ts +0 -2
- package/dist/error-overlay/react-overlay/index.js +0 -21
- package/dist/error-overlay/react-overlay/listen-to-runtime-errors.d.ts +0 -8
- package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +0 -78
- package/dist/error-overlay/react-overlay/utils/get-file-source.d.ts +0 -1
- package/dist/error-overlay/react-overlay/utils/get-file-source.js +0 -21
- package/dist/error-overlay/react-overlay/utils/get-lines-around.d.ts +0 -14
- package/dist/error-overlay/react-overlay/utils/get-lines-around.js +0 -24
- package/dist/error-overlay/react-overlay/utils/get-source-map.d.ts +0 -13
- package/dist/error-overlay/react-overlay/utils/get-source-map.js +0 -58
- package/dist/error-overlay/react-overlay/utils/get-stack-frames.d.ts +0 -2
- package/dist/error-overlay/react-overlay/utils/get-stack-frames.js +0 -27
- package/dist/error-overlay/react-overlay/utils/open-in-editor.d.ts +0 -12
- package/dist/error-overlay/react-overlay/utils/open-in-editor.js +0 -459
- package/dist/error-overlay/react-overlay/utils/parser.d.ts +0 -2
- package/dist/error-overlay/react-overlay/utils/parser.js +0 -117
- package/dist/error-overlay/react-overlay/utils/stack-frame.d.ts +0 -40
- package/dist/error-overlay/react-overlay/utils/stack-frame.js +0 -31
- package/dist/error-overlay/react-overlay/utils/unmapper.d.ts +0 -2
- package/dist/error-overlay/react-overlay/utils/unmapper.js +0 -64
- package/dist/error-overlay/remotion-overlay/AskOnDiscord.d.ts +0 -2
- package/dist/error-overlay/remotion-overlay/AskOnDiscord.js +0 -14
- package/dist/error-overlay/remotion-overlay/Button.d.ts +0 -6
- package/dist/error-overlay/remotion-overlay/Button.js +0 -24
- package/dist/error-overlay/remotion-overlay/CodeFrame.d.ts +0 -6
- package/dist/error-overlay/remotion-overlay/CodeFrame.js +0 -28
- package/dist/error-overlay/remotion-overlay/DismissButton.d.ts +0 -2
- package/dist/error-overlay/remotion-overlay/DismissButton.js +0 -23
- package/dist/error-overlay/remotion-overlay/ErrorDisplay.d.ts +0 -5
- package/dist/error-overlay/remotion-overlay/ErrorDisplay.js +0 -45
- package/dist/error-overlay/remotion-overlay/ErrorLoader.d.ts +0 -4
- package/dist/error-overlay/remotion-overlay/ErrorLoader.js +0 -61
- package/dist/error-overlay/remotion-overlay/ErrorTitle.d.ts +0 -6
- package/dist/error-overlay/remotion-overlay/ErrorTitle.js +0 -41
- package/dist/error-overlay/remotion-overlay/OpenInEditor.d.ts +0 -5
- package/dist/error-overlay/remotion-overlay/OpenInEditor.js +0 -90
- package/dist/error-overlay/remotion-overlay/Overlay.d.ts +0 -14
- package/dist/error-overlay/remotion-overlay/Overlay.js +0 -49
- package/dist/error-overlay/remotion-overlay/SearchGitHubIssues.d.ts +0 -4
- package/dist/error-overlay/remotion-overlay/SearchGitHubIssues.js +0 -13
- package/dist/error-overlay/remotion-overlay/StackFrame.d.ts +0 -8
- package/dist/error-overlay/remotion-overlay/StackFrame.js +0 -48
- package/dist/error-overlay/remotion-overlay/Symbolicating.d.ts +0 -2
- package/dist/error-overlay/remotion-overlay/Symbolicating.js +0 -8
- package/dist/error-overlay/remotion-overlay/carets.d.ts +0 -3
- package/dist/error-overlay/remotion-overlay/carets.js +0 -12
- package/dist/error-overlay/remotion-overlay/format-location.d.ts +0 -1
- package/dist/error-overlay/remotion-overlay/format-location.js +0 -10
- package/dist/error-overlay/remotion-overlay/index.d.ts +0 -1
- package/dist/error-overlay/remotion-overlay/index.js +0 -18
- package/dist/get-latest-remotion-version.d.ts +0 -1
- package/dist/get-latest-remotion-version.js +0 -31
- package/dist/get-package-manager.d.ts +0 -8
- package/dist/get-package-manager.js +0 -38
- package/dist/get-port.d.ts +0 -1
- package/dist/get-port.js +0 -80
- package/dist/hot-middleware/client.d.ts +0 -19
- package/dist/hot-middleware/client.js +0 -206
- package/dist/hot-middleware/index.d.ts +0 -13
- package/dist/hot-middleware/index.js +0 -180
- package/dist/hot-middleware/process-update.d.ts +0 -12
- package/dist/hot-middleware/process-update.js +0 -147
- package/dist/hot-middleware/strip-ansi.d.ts +0 -1
- package/dist/hot-middleware/strip-ansi.js +0 -21
- package/dist/hot-middleware/types.d.ts +0 -37
- package/dist/hot-middleware/types.js +0 -17
- package/dist/is-path-inside.d.ts +0 -1
- package/dist/is-path-inside.js +0 -27
- package/dist/p-limit.d.ts +0 -1
- package/dist/p-limit.js +0 -57
- package/dist/project-info.d.ts +0 -5
- package/dist/project-info.js +0 -22
- package/dist/routes.d.ts +0 -2
- package/dist/routes.js +0 -121
- package/dist/serve-static.d.ts +0 -9
- package/dist/serve-static.js +0 -81
- package/dist/start-server-pure.d.ts +0 -8
- package/dist/start-server-pure.js +0 -68
- package/dist/start-server.d.ts +0 -8
- package/dist/start-server.js +0 -132
- package/dist/static-preview.d.ts +0 -1
- package/dist/static-preview.js +0 -40
- package/dist/test/expect-to-throw.d.ts +0 -1
- package/dist/test/expect-to-throw.js +0 -14
- package/dist/test/latest-remotion-version.test.d.ts +0 -1
- package/dist/test/latest-remotion-version.test.js +0 -6
- package/dist/test/parse-error-stack.test.d.ts +0 -1
- package/dist/test/parse-error-stack.test.js +0 -17
- package/dist/test/parse-module-not-found.test.d.ts +0 -1
- package/dist/test/parse-module-not-found.test.js +0 -17
- package/dist/test/secure-source-read.test.d.ts +0 -1
- package/dist/test/secure-source-read.test.js +0 -8
- package/dist/ts-alias-plugin.d.ts +0 -4
- package/dist/ts-alias-plugin.js +0 -21
- package/dist/update-available.d.ts +0 -10
- package/dist/update-available.js +0 -36
|
@@ -1,18 +0,0 @@
|
|
|
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.mountRemotionOverlay = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const client_1 = __importDefault(require("react-dom/client"));
|
|
9
|
-
const Overlay_1 = require("./Overlay");
|
|
10
|
-
const mountRemotionOverlay = () => {
|
|
11
|
-
if (client_1.default.createRoot) {
|
|
12
|
-
client_1.default.createRoot(document.getElementById('remotion-error-overlay')).render((0, jsx_runtime_1.jsx)(Overlay_1.Overlay, {}));
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
client_1.default.render((0, jsx_runtime_1.jsx)(Overlay_1.Overlay, {}), document.getElementById('remotion-error-overlay'));
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.mountRemotionOverlay = mountRemotionOverlay;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getLatestRemotionVersion: () => Promise<any>;
|
|
@@ -1,31 +0,0 @@
|
|
|
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.getLatestRemotionVersion = void 0;
|
|
7
|
-
const https_1 = __importDefault(require("https"));
|
|
8
|
-
const getPackageJsonForRemotion = () => {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
const req = https_1.default.get('https://registry.npmjs.org/remotion', {
|
|
11
|
-
headers: {
|
|
12
|
-
accept: 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*',
|
|
13
|
-
},
|
|
14
|
-
}, (res) => {
|
|
15
|
-
let data = '';
|
|
16
|
-
res.on('data', (d) => {
|
|
17
|
-
data += d;
|
|
18
|
-
});
|
|
19
|
-
res.on('end', () => resolve(data));
|
|
20
|
-
});
|
|
21
|
-
req.on('error', (error) => {
|
|
22
|
-
reject(error);
|
|
23
|
-
});
|
|
24
|
-
req.end();
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
const getLatestRemotionVersion = async () => {
|
|
28
|
-
const pkgJson = await getPackageJsonForRemotion();
|
|
29
|
-
return JSON.parse(pkgJson)['dist-tags'].latest;
|
|
30
|
-
};
|
|
31
|
-
exports.getLatestRemotionVersion = getLatestRemotionVersion;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare type PackageManager = 'npm' | 'yarn' | 'pnpm';
|
|
2
|
-
declare type LockfilePath = {
|
|
3
|
-
manager: PackageManager;
|
|
4
|
-
path: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const lockFilePaths: LockfilePath[];
|
|
7
|
-
export declare const getPackageManager: () => PackageManager | 'unknown';
|
|
8
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
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.getPackageManager = exports.lockFilePaths = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
exports.lockFilePaths = [
|
|
10
|
-
{ path: 'package-lock.json', manager: 'npm' },
|
|
11
|
-
{
|
|
12
|
-
path: 'yarn.lock',
|
|
13
|
-
manager: 'yarn',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
path: 'pnpm-lock.yaml',
|
|
17
|
-
manager: 'pnpm',
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
const getPackageManager = () => {
|
|
21
|
-
const existingPkgManagers = exports.lockFilePaths.filter((p) => fs_1.default.existsSync(path_1.default.join(process.cwd(), p.path)));
|
|
22
|
-
if (existingPkgManagers.length === 0) {
|
|
23
|
-
return 'unknown';
|
|
24
|
-
}
|
|
25
|
-
if (existingPkgManagers.length > 1) {
|
|
26
|
-
const error = [
|
|
27
|
-
`Found multiple lockfiles:`,
|
|
28
|
-
...existingPkgManagers.map((m) => {
|
|
29
|
-
return `- ${m.path}`;
|
|
30
|
-
}),
|
|
31
|
-
'',
|
|
32
|
-
'This can lead to bugs, delete all but one of these files and run this command again.',
|
|
33
|
-
].join('\n');
|
|
34
|
-
throw new Error(error);
|
|
35
|
-
}
|
|
36
|
-
return existingPkgManagers[0].manager;
|
|
37
|
-
};
|
|
38
|
-
exports.getPackageManager = getPackageManager;
|
package/dist/get-port.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getDesiredPort: (desiredPort: number | undefined, from: number, to: number) => Promise<number>;
|
package/dist/get-port.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
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.getDesiredPort = void 0;
|
|
7
|
-
const net_1 = __importDefault(require("net"));
|
|
8
|
-
const p_limit_1 = require("./p-limit");
|
|
9
|
-
const getAvailablePort = (portToTry) => new Promise((resolve) => {
|
|
10
|
-
let status = 'unavailable';
|
|
11
|
-
const host = '127.0.0.1';
|
|
12
|
-
const socket = new net_1.default.Socket();
|
|
13
|
-
socket.on('connect', () => {
|
|
14
|
-
status = 'unavailable';
|
|
15
|
-
socket.destroy();
|
|
16
|
-
});
|
|
17
|
-
socket.setTimeout(1000);
|
|
18
|
-
socket.on('timeout', () => {
|
|
19
|
-
status = 'unavailable';
|
|
20
|
-
socket.destroy();
|
|
21
|
-
resolve(status);
|
|
22
|
-
});
|
|
23
|
-
socket.on('error', () => {
|
|
24
|
-
status = 'available';
|
|
25
|
-
});
|
|
26
|
-
socket.on('close', () => resolve(status));
|
|
27
|
-
socket.connect(portToTry, host);
|
|
28
|
-
});
|
|
29
|
-
const portCheckSequence = function* (ports) {
|
|
30
|
-
if (ports) {
|
|
31
|
-
yield* ports;
|
|
32
|
-
}
|
|
33
|
-
yield 0; // Fall back to 0 if anything else failed
|
|
34
|
-
};
|
|
35
|
-
const getPort = async (from, to) => {
|
|
36
|
-
const ports = makeRange(from, to);
|
|
37
|
-
for (const port of portCheckSequence(ports)) {
|
|
38
|
-
if ((await getAvailablePort(port)) === 'available') {
|
|
39
|
-
return port;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
throw new Error('No available ports found');
|
|
43
|
-
};
|
|
44
|
-
const getDesiredPortUnlimited = async (desiredPort, from, to) => {
|
|
45
|
-
if (typeof desiredPort !== 'undefined' &&
|
|
46
|
-
(await getAvailablePort(desiredPort)) === 'available') {
|
|
47
|
-
return desiredPort;
|
|
48
|
-
}
|
|
49
|
-
const actualPort = await getPort(from, to);
|
|
50
|
-
// If did specify a port but did not get that one, fail hard.
|
|
51
|
-
if (desiredPort && desiredPort !== actualPort) {
|
|
52
|
-
throw new Error(`You specified port ${desiredPort} to be used for the HTTP server, but it is not available. Choose a different port or remove the setting to let Remotion automatically select a free port.`);
|
|
53
|
-
}
|
|
54
|
-
return actualPort;
|
|
55
|
-
};
|
|
56
|
-
const limit = (0, p_limit_1.pLimit)(1);
|
|
57
|
-
const getDesiredPort = (desiredPort, from, to) => {
|
|
58
|
-
return limit(getDesiredPortUnlimited, desiredPort, from, to);
|
|
59
|
-
};
|
|
60
|
-
exports.getDesiredPort = getDesiredPort;
|
|
61
|
-
const makeRange = (from, to) => {
|
|
62
|
-
if (!Number.isInteger(from) || !Number.isInteger(to)) {
|
|
63
|
-
throw new TypeError('`from` and `to` must be integer numbers');
|
|
64
|
-
}
|
|
65
|
-
if (from < 1024 || from > 65535) {
|
|
66
|
-
throw new RangeError('`from` must be between 1024 and 65535');
|
|
67
|
-
}
|
|
68
|
-
if (to < 1024 || to > 65536) {
|
|
69
|
-
throw new RangeError('`to` must be between 1024 and 65536');
|
|
70
|
-
}
|
|
71
|
-
if (to < from) {
|
|
72
|
-
throw new RangeError('`to` must be greater than or equal to `from`');
|
|
73
|
-
}
|
|
74
|
-
const generator = function* (f, t) {
|
|
75
|
-
for (let port = f; port <= t; port++) {
|
|
76
|
-
yield port;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
return generator(from, to);
|
|
80
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { HotMiddlewareMessage } from './types';
|
|
2
|
-
declare function eventSourceWrapper(): {
|
|
3
|
-
addMessageListener(fn: (msg: MessageEvent) => void): void;
|
|
4
|
-
};
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
__whmEventSourceWrapper: {
|
|
8
|
-
[key: string]: ReturnType<typeof eventSourceWrapper>;
|
|
9
|
-
};
|
|
10
|
-
__webpack_hot_middleware_reporter__: Reporter;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
declare type Reporter = ReturnType<typeof createReporter>;
|
|
14
|
-
declare function createReporter(): {
|
|
15
|
-
cleanProblemsCache(): void;
|
|
16
|
-
problems(type: 'errors' | 'warnings', obj: HotMiddlewareMessage): boolean;
|
|
17
|
-
success: () => undefined;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Source code is adapted from
|
|
5
|
-
* https://github.com/webpack-contrib/webpack-hot-middleware#readme
|
|
6
|
-
* and rewritten in TypeScript. This file is MIT licensed
|
|
7
|
-
*/
|
|
8
|
-
const process_update_1 = require("./process-update");
|
|
9
|
-
const strip_ansi_1 = require("./strip-ansi");
|
|
10
|
-
const types_1 = require("./types");
|
|
11
|
-
if (typeof window === 'undefined') {
|
|
12
|
-
// do nothing
|
|
13
|
-
}
|
|
14
|
-
else if (typeof window.EventSource === 'undefined') {
|
|
15
|
-
console.warn('Unsupported browser: You need a browser that supports EventSource ');
|
|
16
|
-
}
|
|
17
|
-
else if (types_1.hotMiddlewareOptions.autoConnect) {
|
|
18
|
-
connect();
|
|
19
|
-
}
|
|
20
|
-
function setOptionsAndConnect() {
|
|
21
|
-
connect();
|
|
22
|
-
}
|
|
23
|
-
function eventSourceWrapper() {
|
|
24
|
-
let source;
|
|
25
|
-
let lastActivity = Date.now();
|
|
26
|
-
const listeners = [];
|
|
27
|
-
init();
|
|
28
|
-
const timer = setInterval(() => {
|
|
29
|
-
if (Date.now() - lastActivity > types_1.hotMiddlewareOptions.timeout) {
|
|
30
|
-
handleDisconnect();
|
|
31
|
-
}
|
|
32
|
-
}, types_1.hotMiddlewareOptions.timeout / 2);
|
|
33
|
-
function init() {
|
|
34
|
-
source = new window.EventSource(types_1.hotMiddlewareOptions.path);
|
|
35
|
-
source.onopen = handleOnline;
|
|
36
|
-
source.onerror = handleDisconnect;
|
|
37
|
-
source.onmessage = handleMessage;
|
|
38
|
-
}
|
|
39
|
-
function handleOnline() {
|
|
40
|
-
lastActivity = Date.now();
|
|
41
|
-
}
|
|
42
|
-
function handleMessage(event) {
|
|
43
|
-
lastActivity = Date.now();
|
|
44
|
-
for (let i = 0; i < listeners.length; i++) {
|
|
45
|
-
listeners[i](event);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function handleDisconnect() {
|
|
49
|
-
clearInterval(timer);
|
|
50
|
-
source.close();
|
|
51
|
-
setTimeout(init, types_1.hotMiddlewareOptions.timeout);
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
addMessageListener(fn) {
|
|
55
|
-
listeners.push(fn);
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function getEventSourceWrapper() {
|
|
60
|
-
if (!window.__whmEventSourceWrapper) {
|
|
61
|
-
window.__whmEventSourceWrapper = {};
|
|
62
|
-
}
|
|
63
|
-
if (!window.__whmEventSourceWrapper[types_1.hotMiddlewareOptions.path]) {
|
|
64
|
-
// cache the wrapper for other entries loaded on
|
|
65
|
-
// the same page with the same hotMiddlewareOptions.path
|
|
66
|
-
window.__whmEventSourceWrapper[types_1.hotMiddlewareOptions.path] =
|
|
67
|
-
eventSourceWrapper();
|
|
68
|
-
}
|
|
69
|
-
return window.__whmEventSourceWrapper[types_1.hotMiddlewareOptions.path];
|
|
70
|
-
}
|
|
71
|
-
function connect() {
|
|
72
|
-
getEventSourceWrapper().addMessageListener(handleMessage);
|
|
73
|
-
function handleMessage(event) {
|
|
74
|
-
if (event.data === '\uD83D\uDC93') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
try {
|
|
78
|
-
processMessage(JSON.parse(event.data));
|
|
79
|
-
}
|
|
80
|
-
catch (ex) {
|
|
81
|
-
if (types_1.hotMiddlewareOptions.warn) {
|
|
82
|
-
console.warn('Invalid HMR message: ' + event.data + '\n' + ex);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// the reporter needs to be a singleton on the page
|
|
88
|
-
// in case the client is being used by multiple bundles
|
|
89
|
-
// we only want to report once.
|
|
90
|
-
// all the errors will go to all clients
|
|
91
|
-
const singletonKey = '__webpack_hot_middleware_reporter__';
|
|
92
|
-
let reporter;
|
|
93
|
-
if (typeof window !== 'undefined') {
|
|
94
|
-
if (!window[singletonKey]) {
|
|
95
|
-
window[singletonKey] = createReporter();
|
|
96
|
-
}
|
|
97
|
-
reporter = window[singletonKey];
|
|
98
|
-
}
|
|
99
|
-
function createReporter() {
|
|
100
|
-
const styles = {
|
|
101
|
-
errors: 'color: #ff0000;',
|
|
102
|
-
warnings: 'color: #999933;',
|
|
103
|
-
};
|
|
104
|
-
let previousProblems = null;
|
|
105
|
-
function log(type, obj) {
|
|
106
|
-
if (obj.action === 'building') {
|
|
107
|
-
console.log('[Fast Refresh] Building');
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const newProblems = obj[type]
|
|
111
|
-
.map((msg) => {
|
|
112
|
-
return (0, strip_ansi_1.stripAnsi)(msg);
|
|
113
|
-
})
|
|
114
|
-
.join('\n');
|
|
115
|
-
if (previousProblems === newProblems) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
previousProblems = newProblems;
|
|
119
|
-
const style = styles[type];
|
|
120
|
-
const name = obj.name ? "'" + obj.name + "' " : '';
|
|
121
|
-
const title = '[Fast Refresh] bundle ' + name + 'has ' + obj[type].length + ' ' + type;
|
|
122
|
-
// NOTE: console.warn or console.error will print the stack trace
|
|
123
|
-
// which isn't helpful here, so using console.log to escape it.
|
|
124
|
-
if (console.group && console.groupEnd) {
|
|
125
|
-
console.group('%c' + title, style);
|
|
126
|
-
console.log('%c' + newProblems, style);
|
|
127
|
-
console.groupEnd();
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
console.log('%c' + title + '\n\t%c' + newProblems.replace(/\n/g, '\n\t'), style + 'font-weight: bold;', style + 'font-weight: normal;');
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
cleanProblemsCache() {
|
|
135
|
-
previousProblems = null;
|
|
136
|
-
},
|
|
137
|
-
problems(type, obj) {
|
|
138
|
-
if (types_1.hotMiddlewareOptions.warn) {
|
|
139
|
-
log(type, obj);
|
|
140
|
-
}
|
|
141
|
-
return true;
|
|
142
|
-
},
|
|
143
|
-
success: () => undefined,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
let customHandler;
|
|
147
|
-
let subscribeAllHandler;
|
|
148
|
-
function processMessage(obj) {
|
|
149
|
-
switch (obj.action) {
|
|
150
|
-
case 'building':
|
|
151
|
-
console.log('[Fast refresh] bundle ' +
|
|
152
|
-
(obj.name ? "'" + obj.name + "' " : '') +
|
|
153
|
-
'rebuilding');
|
|
154
|
-
break;
|
|
155
|
-
case 'built':
|
|
156
|
-
console.log('[Fast refresh] bundle ' +
|
|
157
|
-
(obj.name ? "'" + obj.name + "' " : '') +
|
|
158
|
-
'rebuilt in ' +
|
|
159
|
-
obj.time +
|
|
160
|
-
'ms');
|
|
161
|
-
// fall through
|
|
162
|
-
case 'sync': {
|
|
163
|
-
if (obj.name &&
|
|
164
|
-
types_1.hotMiddlewareOptions.name &&
|
|
165
|
-
obj.name !== types_1.hotMiddlewareOptions.name) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
let applyUpdate = true;
|
|
169
|
-
if (obj.errors.length > 0) {
|
|
170
|
-
if (reporter)
|
|
171
|
-
reporter.problems('errors', obj);
|
|
172
|
-
applyUpdate = false;
|
|
173
|
-
}
|
|
174
|
-
else if (obj.warnings.length > 0) {
|
|
175
|
-
if (reporter) {
|
|
176
|
-
const overlayShown = reporter.problems('warnings', obj);
|
|
177
|
-
applyUpdate = overlayShown;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else if (reporter) {
|
|
181
|
-
reporter.cleanProblemsCache();
|
|
182
|
-
reporter.success();
|
|
183
|
-
}
|
|
184
|
-
if (applyUpdate) {
|
|
185
|
-
(0, process_update_1.processUpdate)(obj.hash, obj.modules, types_1.hotMiddlewareOptions);
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
default:
|
|
190
|
-
if (customHandler) {
|
|
191
|
-
customHandler(obj);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (subscribeAllHandler) {
|
|
195
|
-
subscribeAllHandler(obj);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
module.exports = {
|
|
199
|
-
subscribeAll(handler) {
|
|
200
|
-
subscribeAllHandler = handler;
|
|
201
|
-
},
|
|
202
|
-
subscribe(handler) {
|
|
203
|
-
customHandler = handler;
|
|
204
|
-
},
|
|
205
|
-
setOptionsAndConnect,
|
|
206
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Source code is adapted from
|
|
3
|
-
* https://github.com/webpack-contrib/webpack-hot-middleware#readme
|
|
4
|
-
* and rewritten in TypeScript. This file is MIT licensed
|
|
5
|
-
*/
|
|
6
|
-
import { Request, Response } from 'express';
|
|
7
|
-
import webpack from 'webpack';
|
|
8
|
-
import { HotMiddlewareMessage } from './types';
|
|
9
|
-
export declare const webpackHotMiddleware: (compiler: webpack.Compiler) => {
|
|
10
|
-
(req: Request, res: Response, next: () => void): void;
|
|
11
|
-
publish(payload: HotMiddlewareMessage): void;
|
|
12
|
-
close(): void;
|
|
13
|
-
};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Source code is adapted from
|
|
4
|
-
* https://github.com/webpack-contrib/webpack-hot-middleware#readme
|
|
5
|
-
* and rewritten in TypeScript. This file is MIT licensed
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.webpackHotMiddleware = void 0;
|
|
9
|
-
const url_1 = require("url");
|
|
10
|
-
const types_1 = require("./types");
|
|
11
|
-
const pathMatch = function (url, path) {
|
|
12
|
-
try {
|
|
13
|
-
return (0, url_1.parse)(url).pathname === path;
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const webpackHotMiddleware = (compiler) => {
|
|
20
|
-
let eventStream = createEventStream(types_1.hotMiddlewareOptions.heartbeat);
|
|
21
|
-
let latestStats = null;
|
|
22
|
-
let closed = false;
|
|
23
|
-
compiler.hooks.invalid.tap('webpack-hot-middleware', onInvalid);
|
|
24
|
-
compiler.hooks.done.tap('webpack-hot-middleware', onDone);
|
|
25
|
-
function onInvalid() {
|
|
26
|
-
if (closed)
|
|
27
|
-
return;
|
|
28
|
-
latestStats = null;
|
|
29
|
-
types_1.hotMiddlewareOptions.log('webpack building...');
|
|
30
|
-
eventStream === null || eventStream === void 0 ? void 0 : eventStream.publish({
|
|
31
|
-
action: 'building',
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function onDone(statsResult) {
|
|
35
|
-
if (closed)
|
|
36
|
-
return;
|
|
37
|
-
// Keep hold of latest stats so they can be propagated to new clients
|
|
38
|
-
latestStats = statsResult;
|
|
39
|
-
publishStats('built', latestStats, eventStream, types_1.hotMiddlewareOptions.log);
|
|
40
|
-
}
|
|
41
|
-
const middleware = function (req, res, next) {
|
|
42
|
-
if (closed)
|
|
43
|
-
return next();
|
|
44
|
-
if (!pathMatch(req.url, types_1.hotMiddlewareOptions.path))
|
|
45
|
-
return next();
|
|
46
|
-
eventStream === null || eventStream === void 0 ? void 0 : eventStream.handler(req, res);
|
|
47
|
-
if (latestStats) {
|
|
48
|
-
publishStats('sync', latestStats, eventStream, types_1.hotMiddlewareOptions.log);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
middleware.publish = function (payload) {
|
|
52
|
-
if (closed)
|
|
53
|
-
return;
|
|
54
|
-
eventStream === null || eventStream === void 0 ? void 0 : eventStream.publish(payload);
|
|
55
|
-
};
|
|
56
|
-
middleware.close = function () {
|
|
57
|
-
if (closed)
|
|
58
|
-
return;
|
|
59
|
-
// Can't remove compiler plugins, so we just set a flag and noop if closed
|
|
60
|
-
// https://github.com/webpack/tapable/issues/32#issuecomment-350644466
|
|
61
|
-
closed = true;
|
|
62
|
-
eventStream === null || eventStream === void 0 ? void 0 : eventStream.close();
|
|
63
|
-
eventStream = null;
|
|
64
|
-
};
|
|
65
|
-
return middleware;
|
|
66
|
-
};
|
|
67
|
-
exports.webpackHotMiddleware = webpackHotMiddleware;
|
|
68
|
-
function createEventStream(heartbeat) {
|
|
69
|
-
let clientId = 0;
|
|
70
|
-
let clients = {};
|
|
71
|
-
function everyClient(fn) {
|
|
72
|
-
Object.keys(clients).forEach((id) => {
|
|
73
|
-
fn(clients[id]);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
const interval = setInterval(() => {
|
|
77
|
-
everyClient((client) => {
|
|
78
|
-
client.write('data: \uD83D\uDC93\n\n');
|
|
79
|
-
});
|
|
80
|
-
}, heartbeat).unref();
|
|
81
|
-
return {
|
|
82
|
-
close() {
|
|
83
|
-
clearInterval(interval);
|
|
84
|
-
everyClient((client) => {
|
|
85
|
-
if (!client.finished)
|
|
86
|
-
client.end();
|
|
87
|
-
});
|
|
88
|
-
clients = {};
|
|
89
|
-
},
|
|
90
|
-
handler(req, res) {
|
|
91
|
-
const headers = {
|
|
92
|
-
'Access-Control-Allow-Origin': '*',
|
|
93
|
-
'Content-Type': 'text/event-stream;charset=utf-8',
|
|
94
|
-
'Cache-Control': 'no-cache, no-transform',
|
|
95
|
-
// While behind nginx, event stream should not be buffered:
|
|
96
|
-
// http://nginx.org/docs/http/ngx_http_proxy_module.html#proxy_buffering
|
|
97
|
-
'X-Accel-Buffering': 'no',
|
|
98
|
-
};
|
|
99
|
-
const isHttp1 = !(parseInt(req.httpVersion, 10) >= 2);
|
|
100
|
-
if (isHttp1) {
|
|
101
|
-
req.socket.setKeepAlive(true);
|
|
102
|
-
Object.assign(headers, {
|
|
103
|
-
Connection: 'keep-alive',
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
res.writeHead(200, headers);
|
|
107
|
-
res.write('\n');
|
|
108
|
-
const id = clientId++;
|
|
109
|
-
clients[id] = res;
|
|
110
|
-
req.on('close', () => {
|
|
111
|
-
if (!res.finished)
|
|
112
|
-
res.end();
|
|
113
|
-
delete clients[id];
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
publish(payload) {
|
|
117
|
-
everyClient((client) => {
|
|
118
|
-
client.write('data: ' + JSON.stringify(payload) + '\n\n');
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function publishStats(action, statsResult, eventStream, log) {
|
|
124
|
-
const stats = statsResult.toJson({
|
|
125
|
-
all: false,
|
|
126
|
-
cached: true,
|
|
127
|
-
children: true,
|
|
128
|
-
modules: true,
|
|
129
|
-
timings: true,
|
|
130
|
-
hash: true,
|
|
131
|
-
});
|
|
132
|
-
// For multi-compiler, stats will be an object with a 'children' array of stats
|
|
133
|
-
const bundles = extractBundles(stats);
|
|
134
|
-
bundles.forEach((_stats) => {
|
|
135
|
-
let name = _stats.name || '';
|
|
136
|
-
// Fallback to compilation name in case of 1 bundle (if it exists)
|
|
137
|
-
if (bundles.length === 1 && !name && statsResult.compilation) {
|
|
138
|
-
name = statsResult.compilation.name || '';
|
|
139
|
-
}
|
|
140
|
-
if (log) {
|
|
141
|
-
log('webpack built ' +
|
|
142
|
-
(name ? name + ' ' : '') +
|
|
143
|
-
_stats.hash +
|
|
144
|
-
' in ' +
|
|
145
|
-
_stats.time +
|
|
146
|
-
'ms');
|
|
147
|
-
}
|
|
148
|
-
eventStream === null || eventStream === void 0 ? void 0 : eventStream.publish({
|
|
149
|
-
name,
|
|
150
|
-
action,
|
|
151
|
-
time: _stats.time,
|
|
152
|
-
hash: _stats.hash,
|
|
153
|
-
warnings: _stats.warnings || [],
|
|
154
|
-
errors: _stats.errors || [],
|
|
155
|
-
modules: buildModuleMap(_stats.modules),
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
function extractBundles(stats) {
|
|
160
|
-
var _a;
|
|
161
|
-
// Stats has modules, single bundle
|
|
162
|
-
if (stats.modules)
|
|
163
|
-
return [stats];
|
|
164
|
-
// Stats has children, multiple bundles
|
|
165
|
-
if ((_a = stats.children) === null || _a === void 0 ? void 0 : _a.length)
|
|
166
|
-
return stats.children;
|
|
167
|
-
// Not sure, assume single
|
|
168
|
-
return [stats];
|
|
169
|
-
}
|
|
170
|
-
function buildModuleMap(modules) {
|
|
171
|
-
const map = {};
|
|
172
|
-
if (!modules) {
|
|
173
|
-
return map;
|
|
174
|
-
}
|
|
175
|
-
modules.forEach((module) => {
|
|
176
|
-
const id = module.id;
|
|
177
|
-
map[id] = module.name;
|
|
178
|
-
});
|
|
179
|
-
return map;
|
|
180
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Source code is adapted from
|
|
3
|
-
* https://github.com/webpack-contrib/webpack-hot-middleware#readme
|
|
4
|
-
* and rewritten in TypeScript. This file is MIT licensed
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Based heavily on https://github.com/webpack/webpack/blob/
|
|
8
|
-
* c0afdf9c6abc1dd70707c594e473802a566f7b6e/hot/only-dev-server.js
|
|
9
|
-
* Original copyright Tobias Koppers @sokra (MIT license)
|
|
10
|
-
*/
|
|
11
|
-
import { HotMiddlewareOptions, ModuleMap } from './types';
|
|
12
|
-
export declare const processUpdate: (hash: string | undefined, moduleMap: ModuleMap, options: HotMiddlewareOptions) => void;
|