@remotion/bundler 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 (138) hide show
  1. package/dist/bundler.d.ts +7 -0
  2. package/dist/bundler.js +76 -0
  3. package/dist/dev-middleware/compatible-api.d.ts +10 -0
  4. package/dist/dev-middleware/compatible-api.js +44 -0
  5. package/dist/dev-middleware/get-filename-from-url.d.ts +2 -0
  6. package/dist/dev-middleware/get-filename-from-url.js +92 -0
  7. package/dist/dev-middleware/get-paths.d.ts +7 -0
  8. package/dist/dev-middleware/get-paths.js +19 -0
  9. package/dist/dev-middleware/index.d.ts +3 -0
  10. package/dist/dev-middleware/index.js +57 -0
  11. package/dist/dev-middleware/is-color-supported.d.ts +1 -0
  12. package/dist/dev-middleware/is-color-supported.js +37 -0
  13. package/dist/dev-middleware/middleware.d.ts +4 -0
  14. package/dist/dev-middleware/middleware.js +141 -0
  15. package/dist/dev-middleware/range-parser.d.ts +15 -0
  16. package/dist/dev-middleware/range-parser.js +96 -0
  17. package/dist/dev-middleware/ready.d.ts +5 -0
  18. package/dist/dev-middleware/ready.js +13 -0
  19. package/dist/dev-middleware/setup-hooks.d.ts +2 -0
  20. package/dist/dev-middleware/setup-hooks.js +44 -0
  21. package/dist/dev-middleware/setup-output-filesystem.d.ts +2 -0
  22. package/dist/dev-middleware/setup-output-filesystem.js +13 -0
  23. package/dist/dev-middleware/types.d.ts +11 -0
  24. package/dist/dev-middleware/types.js +2 -0
  25. package/dist/error-overlay/entry-basic.d.ts +1 -0
  26. package/dist/error-overlay/entry-basic.js +21 -0
  27. package/dist/error-overlay/react-overlay/effects/format-warning.d.ts +11 -0
  28. package/dist/error-overlay/react-overlay/effects/format-warning.js +41 -0
  29. package/dist/error-overlay/react-overlay/effects/map-error-to-react-stack.d.ts +7 -0
  30. package/dist/error-overlay/react-overlay/effects/map-error-to-react-stack.js +46 -0
  31. package/dist/error-overlay/react-overlay/effects/proxy-console.d.ts +24 -0
  32. package/dist/error-overlay/react-overlay/effects/proxy-console.js +63 -0
  33. package/dist/error-overlay/react-overlay/effects/resolve-file-source.d.ts +3 -0
  34. package/dist/error-overlay/react-overlay/effects/resolve-file-source.js +31 -0
  35. package/dist/error-overlay/react-overlay/effects/stack-trace-limit.d.ts +3 -0
  36. package/dist/error-overlay/react-overlay/effects/stack-trace-limit.js +43 -0
  37. package/dist/error-overlay/react-overlay/effects/unhandled-error.d.ts +4 -0
  38. package/dist/error-overlay/react-overlay/effects/unhandled-error.js +45 -0
  39. package/dist/error-overlay/react-overlay/effects/unhandled-rejection.d.ts +4 -0
  40. package/dist/error-overlay/react-overlay/effects/unhandled-rejection.js +41 -0
  41. package/dist/error-overlay/react-overlay/index.d.ts +2 -0
  42. package/dist/error-overlay/react-overlay/index.js +21 -0
  43. package/dist/error-overlay/react-overlay/listen-to-runtime-errors.d.ts +8 -0
  44. package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +78 -0
  45. package/dist/error-overlay/react-overlay/utils/get-file-source.d.ts +1 -0
  46. package/dist/error-overlay/react-overlay/utils/get-file-source.js +21 -0
  47. package/dist/error-overlay/react-overlay/utils/get-lines-around.d.ts +14 -0
  48. package/dist/error-overlay/react-overlay/utils/get-lines-around.js +24 -0
  49. package/dist/error-overlay/react-overlay/utils/get-source-map.d.ts +13 -0
  50. package/dist/error-overlay/react-overlay/utils/get-source-map.js +58 -0
  51. package/dist/error-overlay/react-overlay/utils/get-stack-frames.d.ts +2 -0
  52. package/dist/error-overlay/react-overlay/utils/get-stack-frames.js +27 -0
  53. package/dist/error-overlay/react-overlay/utils/open-in-editor.d.ts +12 -0
  54. package/dist/error-overlay/react-overlay/utils/open-in-editor.js +459 -0
  55. package/dist/error-overlay/react-overlay/utils/parser.d.ts +2 -0
  56. package/dist/error-overlay/react-overlay/utils/parser.js +117 -0
  57. package/dist/error-overlay/react-overlay/utils/stack-frame.d.ts +40 -0
  58. package/dist/error-overlay/react-overlay/utils/stack-frame.js +31 -0
  59. package/dist/error-overlay/react-overlay/utils/unmapper.d.ts +2 -0
  60. package/dist/error-overlay/react-overlay/utils/unmapper.js +64 -0
  61. package/dist/error-overlay/remotion-overlay/AskOnDiscord.d.ts +2 -0
  62. package/dist/error-overlay/remotion-overlay/AskOnDiscord.js +14 -0
  63. package/dist/error-overlay/remotion-overlay/Button.d.ts +6 -0
  64. package/dist/error-overlay/remotion-overlay/Button.js +24 -0
  65. package/dist/error-overlay/remotion-overlay/CodeFrame.d.ts +6 -0
  66. package/dist/error-overlay/remotion-overlay/CodeFrame.js +28 -0
  67. package/dist/error-overlay/remotion-overlay/DismissButton.d.ts +2 -0
  68. package/dist/error-overlay/remotion-overlay/DismissButton.js +23 -0
  69. package/dist/error-overlay/remotion-overlay/ErrorDisplay.d.ts +5 -0
  70. package/dist/error-overlay/remotion-overlay/ErrorDisplay.js +45 -0
  71. package/dist/error-overlay/remotion-overlay/ErrorLoader.d.ts +4 -0
  72. package/dist/error-overlay/remotion-overlay/ErrorLoader.js +61 -0
  73. package/dist/error-overlay/remotion-overlay/ErrorTitle.d.ts +6 -0
  74. package/dist/error-overlay/remotion-overlay/ErrorTitle.js +41 -0
  75. package/dist/error-overlay/remotion-overlay/OpenInEditor.d.ts +5 -0
  76. package/dist/error-overlay/remotion-overlay/OpenInEditor.js +90 -0
  77. package/dist/error-overlay/remotion-overlay/Overlay.d.ts +14 -0
  78. package/dist/error-overlay/remotion-overlay/Overlay.js +49 -0
  79. package/dist/error-overlay/remotion-overlay/SearchGitHubIssues.d.ts +4 -0
  80. package/dist/error-overlay/remotion-overlay/SearchGitHubIssues.js +13 -0
  81. package/dist/error-overlay/remotion-overlay/StackFrame.d.ts +8 -0
  82. package/dist/error-overlay/remotion-overlay/StackFrame.js +48 -0
  83. package/dist/error-overlay/remotion-overlay/Symbolicating.d.ts +2 -0
  84. package/dist/error-overlay/remotion-overlay/Symbolicating.js +8 -0
  85. package/dist/error-overlay/remotion-overlay/carets.d.ts +3 -0
  86. package/dist/error-overlay/remotion-overlay/carets.js +12 -0
  87. package/dist/error-overlay/remotion-overlay/format-location.d.ts +1 -0
  88. package/dist/error-overlay/remotion-overlay/format-location.js +10 -0
  89. package/dist/error-overlay/remotion-overlay/index.d.ts +1 -0
  90. package/dist/error-overlay/remotion-overlay/index.js +18 -0
  91. package/dist/get-latest-remotion-version.d.ts +1 -0
  92. package/dist/get-latest-remotion-version.js +31 -0
  93. package/dist/get-package-manager.d.ts +8 -0
  94. package/dist/get-package-manager.js +38 -0
  95. package/dist/get-port.d.ts +1 -0
  96. package/dist/get-port.js +80 -0
  97. package/dist/hot-middleware/client.d.ts +19 -0
  98. package/dist/hot-middleware/client.js +206 -0
  99. package/dist/hot-middleware/index.d.ts +13 -0
  100. package/dist/hot-middleware/index.js +180 -0
  101. package/dist/hot-middleware/process-update.d.ts +12 -0
  102. package/dist/hot-middleware/process-update.js +147 -0
  103. package/dist/hot-middleware/strip-ansi.d.ts +1 -0
  104. package/dist/hot-middleware/strip-ansi.js +21 -0
  105. package/dist/hot-middleware/types.d.ts +37 -0
  106. package/dist/hot-middleware/types.js +17 -0
  107. package/dist/is-path-inside.d.ts +1 -0
  108. package/dist/is-path-inside.js +27 -0
  109. package/dist/p-limit.d.ts +1 -0
  110. package/dist/p-limit.js +57 -0
  111. package/dist/project-info.d.ts +5 -0
  112. package/dist/project-info.js +22 -0
  113. package/dist/routes.d.ts +2 -0
  114. package/dist/routes.js +121 -0
  115. package/dist/serve-static.d.ts +9 -0
  116. package/dist/serve-static.js +81 -0
  117. package/dist/setup-environment.js +3 -1
  118. package/dist/start-server-pure.d.ts +8 -0
  119. package/dist/start-server-pure.js +68 -0
  120. package/dist/start-server.d.ts +8 -0
  121. package/dist/start-server.js +132 -0
  122. package/dist/static-preview.d.ts +1 -0
  123. package/dist/static-preview.js +40 -0
  124. package/dist/test/expect-to-throw.d.ts +1 -0
  125. package/dist/test/expect-to-throw.js +14 -0
  126. package/dist/test/latest-remotion-version.test.d.ts +1 -0
  127. package/dist/test/latest-remotion-version.test.js +6 -0
  128. package/dist/test/parse-error-stack.test.d.ts +1 -0
  129. package/dist/test/parse-error-stack.test.js +17 -0
  130. package/dist/test/parse-module-not-found.test.d.ts +1 -0
  131. package/dist/test/parse-module-not-found.test.js +17 -0
  132. package/dist/test/secure-source-read.test.d.ts +1 -0
  133. package/dist/test/secure-source-read.test.js +8 -0
  134. package/dist/ts-alias-plugin.d.ts +4 -0
  135. package/dist/ts-alias-plugin.js +21 -0
  136. package/dist/update-available.d.ts +10 -0
  137. package/dist/update-available.js +36 -0
  138. package/package.json +3 -3
@@ -0,0 +1,180 @@
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
+ }
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,147 @@
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.processUpdate = void 0;
9
+ /* global __webpack_hash__ */
10
+ if (!module.hot) {
11
+ throw new Error('[Fast refresh] Hot Module Replacement is disabled.');
12
+ }
13
+ const hmrDocsUrl = 'https://webpack.js.org/concepts/hot-module-replacement/'; // eslint-disable-line max-len
14
+ let lastHash;
15
+ const failureStatuses = { abort: 1, fail: 1 };
16
+ const applyOptions = {
17
+ ignoreUnaccepted: true,
18
+ ignoreDeclined: true,
19
+ ignoreErrored: true,
20
+ onUnaccepted(data) {
21
+ var _a;
22
+ console.warn('Ignored an update to unaccepted module ' +
23
+ ((_a = data.chain) !== null && _a !== void 0 ? _a : []).join(' -> '));
24
+ },
25
+ onDeclined(data) {
26
+ var _a;
27
+ console.warn('Ignored an update to declined module ' + ((_a = data.chain) !== null && _a !== void 0 ? _a : []).join(' -> '));
28
+ },
29
+ onErrored(data) {
30
+ console.error(data.error);
31
+ console.warn('Ignored an error while updating module ' +
32
+ data.moduleId +
33
+ ' (' +
34
+ data.type +
35
+ ')');
36
+ },
37
+ };
38
+ function upToDate(hash) {
39
+ if (hash)
40
+ lastHash = hash;
41
+ return lastHash === __webpack_hash__;
42
+ }
43
+ const processUpdate = function (hash, moduleMap, options) {
44
+ var _a;
45
+ const { reload } = options;
46
+ if (!upToDate(hash) && ((_a = module.hot) === null || _a === void 0 ? void 0 : _a.status()) === 'idle') {
47
+ console.log('[Fast refresh] Checking for updates on the server...');
48
+ check();
49
+ }
50
+ async function check() {
51
+ var _a;
52
+ const cb = function (err, updatedModules) {
53
+ var _a;
54
+ if (err)
55
+ return handleError(err);
56
+ if (!updatedModules) {
57
+ if (options.warn) {
58
+ console.warn('[Fast refresh] Cannot find update (Full reload needed)');
59
+ console.warn('[Fast refresh] (Probably because of restarting the server)');
60
+ }
61
+ performReload();
62
+ return null;
63
+ }
64
+ const applyCallback = function (applyErr, renewedModules) {
65
+ if (applyErr)
66
+ return handleError(applyErr);
67
+ if (!upToDate())
68
+ check();
69
+ logUpdates(updatedModules, renewedModules);
70
+ };
71
+ const applyResult = (_a = module.hot) === null || _a === void 0 ? void 0 : _a.apply(applyOptions, applyCallback);
72
+ if (applyResult === null || applyResult === void 0 ? void 0 : applyResult.then) {
73
+ // HotModuleReplacement.runtime.js refers to the result as `outdatedModules`
74
+ applyResult
75
+ .then((outdatedModules) => {
76
+ applyCallback(null, outdatedModules);
77
+ })
78
+ .catch((_err) => applyCallback(_err, []));
79
+ }
80
+ };
81
+ try {
82
+ const result = await ((_a = module.hot) === null || _a === void 0 ? void 0 : _a.check(false, cb));
83
+ cb(null, result);
84
+ }
85
+ catch (err) {
86
+ cb(err, []);
87
+ }
88
+ }
89
+ function logUpdates(updatedModules, renewedModules) {
90
+ var _a;
91
+ const unacceptedModules = (_a = updatedModules === null || updatedModules === void 0 ? void 0 : updatedModules.filter((moduleId) => {
92
+ return renewedModules && renewedModules.indexOf(moduleId) < 0;
93
+ })) !== null && _a !== void 0 ? _a : [];
94
+ if (unacceptedModules.length > 0) {
95
+ if (options.warn) {
96
+ console.warn("[Fast refresh] The following modules couldn't be hot updated: " +
97
+ '(Full reload needed)\n' +
98
+ 'This is usually because the modules which have changed ' +
99
+ '(and their parents) do not know how to hot reload themselves. ' +
100
+ 'See ' +
101
+ hmrDocsUrl +
102
+ ' for more details.');
103
+ unacceptedModules.forEach((moduleId) => {
104
+ console.warn('[Fast refresh] - ' + (moduleMap[moduleId] || moduleId));
105
+ });
106
+ }
107
+ performReload();
108
+ return;
109
+ }
110
+ if (!renewedModules || renewedModules.length === 0) {
111
+ console.log('[Fast refresh] Nothing hot updated.');
112
+ }
113
+ else {
114
+ console.log('[Fast refresh] Updated modules:');
115
+ renewedModules.forEach((moduleId) => {
116
+ console.log('[Fast refresh] - ' + (moduleMap[moduleId] || moduleId));
117
+ });
118
+ }
119
+ if (upToDate()) {
120
+ console.log('[Fast refresh] App is up to date.');
121
+ }
122
+ }
123
+ function handleError(err) {
124
+ var _a, _b;
125
+ if (((_b = (_a = module.hot) === null || _a === void 0 ? void 0 : _a.status()) !== null && _b !== void 0 ? _b : 'nope') in failureStatuses) {
126
+ if (options.warn) {
127
+ console.warn('[Fast refresh] Cannot check for update (Full reload needed)');
128
+ console.warn('[Fast refresh] ' + (err.stack || err.message));
129
+ }
130
+ performReload();
131
+ return;
132
+ }
133
+ if (options.warn) {
134
+ console.warn('[Fast refresh] Update check failed: ' + (err.stack || err.message));
135
+ window.location.reload();
136
+ }
137
+ }
138
+ function performReload() {
139
+ if (!reload) {
140
+ return;
141
+ }
142
+ if (options.warn)
143
+ console.warn('[Fast refresh] Reloading page');
144
+ window.location.reload();
145
+ }
146
+ };
147
+ exports.processUpdate = processUpdate;
@@ -0,0 +1 @@
1
+ export declare const stripAnsi: (str: string) => string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripAnsi = void 0;
4
+ /**
5
+ * Code inlined from https://github.com/chalk/strip-ansi#readme
6
+ * This file is MIT licensed.
7
+ */
8
+ const ansiRegex = () => {
9
+ const pattern = [
10
+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
11
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
12
+ ].join('|');
13
+ return new RegExp(pattern, 'g');
14
+ };
15
+ const stripAnsi = (str) => {
16
+ if (typeof str !== 'string') {
17
+ throw new TypeError(`Expected a \`string\`, got \`${typeof str}\``);
18
+ }
19
+ return str.replace(ansiRegex(), '');
20
+ };
21
+ exports.stripAnsi = stripAnsi;
@@ -0,0 +1,37 @@
1
+ import webpack from 'webpack';
2
+ export declare type HotMiddlewareMessage = {
3
+ action: 'building';
4
+ name?: string;
5
+ } | {
6
+ action: 'built' | 'sync';
7
+ name: string;
8
+ time: number | undefined;
9
+ errors: unknown[];
10
+ warnings: unknown[];
11
+ hash: string | undefined;
12
+ modules: {
13
+ [key: string]: string;
14
+ };
15
+ };
16
+ export declare const hotMiddlewareOptions: {
17
+ path: string;
18
+ timeout: number;
19
+ overlay: boolean;
20
+ reload: boolean;
21
+ log: {
22
+ (...data: any[]): void;
23
+ (message?: any, ...optionalParams: any[]): void;
24
+ };
25
+ warn: boolean;
26
+ name: string;
27
+ autoConnect: boolean;
28
+ overlayStyles: {};
29
+ overlayWarnings: boolean;
30
+ ansiColors: {};
31
+ heartbeat: number;
32
+ };
33
+ export declare type HotMiddlewareOptions = typeof hotMiddlewareOptions;
34
+ export declare type WebpackStats = ReturnType<webpack.Stats['toJson']>;
35
+ export declare type ModuleMap = {
36
+ [key: string]: string;
37
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hotMiddlewareOptions = void 0;
4
+ exports.hotMiddlewareOptions = {
5
+ path: '/__webpack_hmr',
6
+ timeout: 20 * 1000,
7
+ overlay: true,
8
+ reload: false,
9
+ log: console.log.bind(console),
10
+ warn: true,
11
+ name: '',
12
+ autoConnect: true,
13
+ overlayStyles: {},
14
+ overlayWarnings: false,
15
+ ansiColors: {},
16
+ heartbeat: 10 * 1000,
17
+ };
@@ -0,0 +1 @@
1
+ export declare const isPathInside: (thePath: string, potentialParent: string) => boolean;
@@ -0,0 +1,27 @@
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.isPathInside = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const isPathInside = function (thePath, potentialParent) {
9
+ // For inside-directory checking, we want to allow trailing slashes, so normalize.
10
+ thePath = stripTrailingSep(thePath);
11
+ potentialParent = stripTrailingSep(potentialParent);
12
+ // Node treats only Windows as case-insensitive in its path module; we follow those conventions.
13
+ if (process.platform === 'win32') {
14
+ thePath = thePath.toLowerCase();
15
+ potentialParent = potentialParent.toLowerCase();
16
+ }
17
+ return (thePath.lastIndexOf(potentialParent, 0) === 0 &&
18
+ (thePath[potentialParent.length] === path_1.default.sep ||
19
+ thePath[potentialParent.length] === undefined));
20
+ };
21
+ exports.isPathInside = isPathInside;
22
+ function stripTrailingSep(thePath) {
23
+ if (thePath[thePath.length - 1] === path_1.default.sep) {
24
+ return thePath.slice(0, -1);
25
+ }
26
+ return thePath;
27
+ }
@@ -0,0 +1 @@
1
+ export declare const pLimit: (concurrency: number) => <Arguments extends unknown[], ReturnType_1>(fn: (..._arguments: Arguments) => ReturnType_1 | PromiseLike<ReturnType_1>, ...args: Arguments) => Promise<ReturnType_1>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pLimit = void 0;
4
+ const pLimit = (concurrency) => {
5
+ const queue = [];
6
+ let activeCount = 0;
7
+ const next = () => {
8
+ var _a;
9
+ activeCount--;
10
+ if (queue.length > 0) {
11
+ (_a = queue.shift()) === null || _a === void 0 ? void 0 : _a();
12
+ }
13
+ };
14
+ const run = async (fn, resolve, ...args) => {
15
+ activeCount++;
16
+ // eslint-disable-next-line require-await
17
+ const result = (async () => fn(...args))();
18
+ resolve(result);
19
+ try {
20
+ await result;
21
+ }
22
+ catch (_a) { }
23
+ next();
24
+ };
25
+ const enqueue = (fn, resolve, ...args) => {
26
+ queue.push(() => run(fn, resolve, ...args));
27
+ (async () => {
28
+ var _a;
29
+ // This function needs to wait until the next microtask before comparing
30
+ // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
31
+ // when the run function is dequeued and called. The comparison in the if-statement
32
+ // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
33
+ await Promise.resolve();
34
+ if (activeCount < concurrency && queue.length > 0) {
35
+ (_a = queue.shift()) === null || _a === void 0 ? void 0 : _a();
36
+ }
37
+ })();
38
+ };
39
+ const generator = (fn, ...args) => new Promise((resolve) => {
40
+ enqueue(fn, resolve, ...args);
41
+ });
42
+ Object.defineProperties(generator, {
43
+ activeCount: {
44
+ get: () => activeCount,
45
+ },
46
+ pendingCount: {
47
+ get: () => queue.length,
48
+ },
49
+ clearQueue: {
50
+ value: () => {
51
+ queue.length = 0;
52
+ },
53
+ },
54
+ });
55
+ return generator;
56
+ };
57
+ exports.pLimit = pLimit;
@@ -0,0 +1,5 @@
1
+ export declare type ProjectInfo = {
2
+ videoFile: string | null;
3
+ relativeVideoFile: string | null;
4
+ };
5
+ export declare const getProjectInfo: () => Promise<ProjectInfo>;
@@ -0,0 +1,22 @@
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.getProjectInfo = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ const getProjectInfo = () => {
10
+ var _a;
11
+ const pathsToLookFor = ['src/Video.tsx', 'src/Video.jsx'].map((p) => {
12
+ return path_1.default.join(process.cwd(), p);
13
+ });
14
+ const videoFile = (_a = pathsToLookFor.find((p) => (0, fs_1.existsSync)(p))) !== null && _a !== void 0 ? _a : null;
15
+ return Promise.resolve({
16
+ videoFile,
17
+ relativeVideoFile: videoFile
18
+ ? path_1.default.relative(process.cwd(), videoFile)
19
+ : null,
20
+ });
21
+ };
22
+ exports.getProjectInfo = getProjectInfo;
@@ -0,0 +1,2 @@
1
+ import { IncomingMessage, ServerResponse } from 'http';
2
+ export declare const handleRoutes: (hash: string, request: IncomingMessage, response: ServerResponse) => void | Promise<void>;
package/dist/routes.js ADDED
@@ -0,0 +1,121 @@
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.handleRoutes = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ const url_1 = require("url");
10
+ const get_file_source_1 = require("./error-overlay/react-overlay/utils/get-file-source");
11
+ const open_in_editor_1 = require("./error-overlay/react-overlay/utils/open-in-editor");
12
+ const project_info_1 = require("./project-info");
13
+ const serve_static_1 = require("./serve-static");
14
+ const static_preview_1 = require("./static-preview");
15
+ const update_available_1 = require("./update-available");
16
+ const handleUpdate = async (_, response) => {
17
+ const data = await (0, update_available_1.isUpdateAvailableWithTimeout)();
18
+ response.setHeader('content-type', 'application/json');
19
+ response.writeHead(200);
20
+ response.end(JSON.stringify(data));
21
+ };
22
+ const editorGuess = (0, open_in_editor_1.guessEditor)();
23
+ const handleFallback = async (hash, _, response) => {
24
+ const edit = await editorGuess;
25
+ const displayName = (0, open_in_editor_1.getDisplayNameForEditor)(edit[0]);
26
+ response.setHeader('content-type', 'text/html');
27
+ response.writeHead(200);
28
+ response.end((0, static_preview_1.indexHtml)(hash, '/', displayName));
29
+ };
30
+ const handleProjectInfo = async (_, response) => {
31
+ const data = await (0, project_info_1.getProjectInfo)();
32
+ response.setHeader('content-type', 'application/json');
33
+ response.writeHead(200);
34
+ response.end(JSON.stringify(data));
35
+ };
36
+ const handleFileSource = async (search, _, response) => {
37
+ if (!search.startsWith('?')) {
38
+ throw new Error('query must start with ?');
39
+ }
40
+ const query = new url_1.URLSearchParams(search);
41
+ const f = query.get('f');
42
+ if (typeof f !== 'string') {
43
+ throw new Error('must pass `f` parameter');
44
+ }
45
+ const data = await (0, get_file_source_1.getFileSource)(decodeURIComponent(f));
46
+ response.writeHead(200);
47
+ response.write(data);
48
+ return response.end();
49
+ };
50
+ const handleOpenInEditor = async (req, res) => {
51
+ try {
52
+ const b = await new Promise((_resolve) => {
53
+ let data = '';
54
+ req.on('data', (chunk) => {
55
+ data += chunk;
56
+ });
57
+ req.on('end', () => {
58
+ _resolve(data.toString());
59
+ });
60
+ });
61
+ const body = JSON.parse(b);
62
+ if (!('stack' in body)) {
63
+ throw new TypeError('Need to pass stack');
64
+ }
65
+ const stack = body.stack;
66
+ const guess = await editorGuess;
67
+ const didOpen = await (0, open_in_editor_1.launchEditor)({
68
+ colNumber: stack.originalColumnNumber,
69
+ editor: guess[0],
70
+ fileName: path_1.default.resolve(process.cwd(), stack.originalFileName),
71
+ lineNumber: stack.originalLineNumber,
72
+ vsCodeNewWindow: false,
73
+ });
74
+ res.setHeader('content-type', 'application/json');
75
+ res.writeHead(200);
76
+ res.end(JSON.stringify({
77
+ success: didOpen,
78
+ }));
79
+ }
80
+ catch (err) {
81
+ res.setHeader('content-type', 'application/json');
82
+ res.writeHead(200);
83
+ res.end(JSON.stringify({
84
+ success: false,
85
+ }));
86
+ }
87
+ };
88
+ const handleFavicon = (_, response) => {
89
+ const filePath = path_1.default.join(__dirname, '..', 'web', 'favicon.png');
90
+ const stat = (0, fs_1.statSync)(filePath);
91
+ response.writeHead(200, {
92
+ 'Content-Type': 'image/png',
93
+ 'Content-Length': stat.size,
94
+ });
95
+ const readStream = (0, fs_1.createReadStream)(filePath);
96
+ readStream.pipe(response);
97
+ };
98
+ const handleRoutes = (hash, request, response) => {
99
+ const url = new URL(request.url, 'http://localhost');
100
+ if (url.pathname === '/api/update') {
101
+ return handleUpdate(request, response);
102
+ }
103
+ if (url.pathname === '/api/project-info') {
104
+ return handleProjectInfo(request, response);
105
+ }
106
+ if (url.pathname === '/api/file-source') {
107
+ return handleFileSource(url.search, request, response);
108
+ }
109
+ if (url.pathname === '/api/open-in-editor') {
110
+ return handleOpenInEditor(request, response);
111
+ }
112
+ if (url.pathname === '/remotion.png') {
113
+ return handleFavicon(request, response);
114
+ }
115
+ if (url.pathname.startsWith(hash)) {
116
+ const root = path_1.default.join(process.cwd(), 'public');
117
+ return (0, serve_static_1.serveStatic)(root, hash, request, response);
118
+ }
119
+ return handleFallback(hash, request, response);
120
+ };
121
+ exports.handleRoutes = handleRoutes;
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * serve-static
3
+ * Copyright(c) 2010 Sencha Inc.
4
+ * Copyright(c) 2011 TJ Holowaychuk
5
+ * Copyright(c) 2014-2016 Douglas Christopher Wilson
6
+ * MIT Licensed
7
+ */
8
+ import { IncomingMessage, ServerResponse } from 'http';
9
+ export declare const serveStatic: (root: string, hash: string, req: IncomingMessage, res: ServerResponse) => Promise<void>;