Add .gitignore to exclude all node packages and lock files
This commit is contained in:
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Source code is adapted from
|
||||
* https://github.com/webpack-contrib/webpack-hot-middleware#readme
|
||||
* and rewritten in TypeScript. This file is MIT licensed
|
||||
*/
|
||||
import type { HotMiddlewareMessage } from '@remotion/studio-shared';
|
||||
declare function eventSourceWrapper(): {
|
||||
addMessageListener(fn: (msg: MessageEvent) => void): void;
|
||||
};
|
||||
declare global {
|
||||
interface Window {
|
||||
__whmEventSourceWrapper: {
|
||||
[key: string]: ReturnType<typeof eventSourceWrapper>;
|
||||
};
|
||||
__webpack_hot_middleware_reporter__: Reporter;
|
||||
}
|
||||
}
|
||||
type Reporter = ReturnType<typeof createReporter>;
|
||||
declare function createReporter(): {
|
||||
cleanProblemsCache(): void;
|
||||
problems(type: "errors" | "warnings", obj: HotMiddlewareMessage): boolean;
|
||||
success: () => undefined;
|
||||
};
|
||||
export declare const enableHotMiddleware: () => void;
|
||||
export {};
|
||||
Generated
Vendored
+172
@@ -0,0 +1,172 @@
|
||||
"use strict";
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.enableHotMiddleware = void 0;
|
||||
const studio_shared_1 = require("@remotion/studio-shared");
|
||||
const process_update_1 = require("./process-update");
|
||||
function eventSourceWrapper() {
|
||||
let source;
|
||||
let lastActivity = Date.now();
|
||||
const listeners = [];
|
||||
init();
|
||||
const timer = setInterval(() => {
|
||||
if (Date.now() - lastActivity > studio_shared_1.hotMiddlewareOptions.timeout) {
|
||||
handleDisconnect();
|
||||
}
|
||||
}, studio_shared_1.hotMiddlewareOptions.timeout / 2);
|
||||
function init() {
|
||||
source = new window.EventSource(studio_shared_1.hotMiddlewareOptions.path);
|
||||
source.onopen = handleOnline;
|
||||
source.onerror = handleDisconnect;
|
||||
source.onmessage = handleMessage;
|
||||
}
|
||||
function handleOnline() {
|
||||
lastActivity = Date.now();
|
||||
}
|
||||
function handleMessage(event) {
|
||||
lastActivity = Date.now();
|
||||
for (let i = 0; i < listeners.length; i++) {
|
||||
listeners[i](event);
|
||||
}
|
||||
}
|
||||
function handleDisconnect() {
|
||||
clearInterval(timer);
|
||||
source.close();
|
||||
setTimeout(init, 1000);
|
||||
}
|
||||
return {
|
||||
addMessageListener(fn) {
|
||||
listeners.push(fn);
|
||||
},
|
||||
};
|
||||
}
|
||||
function getEventSourceWrapper() {
|
||||
if (!window.__whmEventSourceWrapper) {
|
||||
window.__whmEventSourceWrapper = {};
|
||||
}
|
||||
if (!window.__whmEventSourceWrapper[studio_shared_1.hotMiddlewareOptions.path]) {
|
||||
// cache the wrapper for other entries loaded on
|
||||
// the same page with the same hotMiddlewareOptions.path
|
||||
window.__whmEventSourceWrapper[studio_shared_1.hotMiddlewareOptions.path] =
|
||||
eventSourceWrapper();
|
||||
}
|
||||
return window.__whmEventSourceWrapper[studio_shared_1.hotMiddlewareOptions.path];
|
||||
}
|
||||
function connect() {
|
||||
getEventSourceWrapper().addMessageListener(handleMessage);
|
||||
function handleMessage(event) {
|
||||
if (event.data === '\uD83D\uDC93') {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
processMessage(JSON.parse(event.data));
|
||||
}
|
||||
catch (ex) {
|
||||
if (studio_shared_1.hotMiddlewareOptions.warn) {
|
||||
console.warn('Invalid HMR message: ' + event.data + '\n' + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function createReporter() {
|
||||
const styles = {
|
||||
errors: 'color: #ff0000;',
|
||||
warnings: 'color: #999933;',
|
||||
};
|
||||
let previousProblems = null;
|
||||
function log(type, obj) {
|
||||
if (obj.action === 'building') {
|
||||
console.log('[Fast Refresh] Building');
|
||||
return;
|
||||
}
|
||||
const newProblems = obj[type]
|
||||
.map((msg) => {
|
||||
return (0, studio_shared_1.stripAnsi)(msg);
|
||||
})
|
||||
.join('\n');
|
||||
if (previousProblems === newProblems) {
|
||||
return;
|
||||
}
|
||||
previousProblems = newProblems;
|
||||
const style = styles[type];
|
||||
const name = obj.name ? "'" + obj.name + "' " : '';
|
||||
const title = '[Fast Refresh] bundle ' + name + 'has ' + obj[type].length + ' ' + type;
|
||||
// NOTE: console.warn or console.error will print the stack trace
|
||||
// which isn't helpful here, so using console.log to escape it.
|
||||
if (console.group && console.groupEnd) {
|
||||
console.group('%c' + title, style);
|
||||
console.log('%c' + newProblems, style);
|
||||
console.groupEnd();
|
||||
}
|
||||
else {
|
||||
console.log('%c' + title + '\n\t%c' + newProblems.replace(/\n/g, '\n\t'), style + 'font-weight: bold;', style + 'font-weight: normal;');
|
||||
}
|
||||
}
|
||||
return {
|
||||
cleanProblemsCache() {
|
||||
previousProblems = null;
|
||||
},
|
||||
problems(type, obj) {
|
||||
if (studio_shared_1.hotMiddlewareOptions.warn) {
|
||||
log(type, obj);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
success: () => undefined,
|
||||
};
|
||||
}
|
||||
function processMessage(obj) {
|
||||
var _a, _b;
|
||||
switch (obj.action) {
|
||||
case 'building':
|
||||
(_a = window.remotion_isBuilding) === null || _a === void 0 ? void 0 : _a.call(window);
|
||||
break;
|
||||
case 'sync':
|
||||
case 'built': {
|
||||
let applyUpdate = true;
|
||||
if (obj.errors.length > 0) {
|
||||
if (reporter)
|
||||
reporter.problems('errors', obj);
|
||||
applyUpdate = false;
|
||||
}
|
||||
else if (obj.warnings.length > 0) {
|
||||
if (reporter) {
|
||||
const overlayShown = reporter.problems('warnings', obj);
|
||||
applyUpdate = overlayShown;
|
||||
}
|
||||
}
|
||||
else if (reporter) {
|
||||
reporter.cleanProblemsCache();
|
||||
reporter.success();
|
||||
}
|
||||
if (applyUpdate) {
|
||||
(_b = window.remotion_finishedBuilding) === null || _b === void 0 ? void 0 : _b.call(window);
|
||||
(0, process_update_1.processUpdate)(obj.hash, obj.modules, studio_shared_1.hotMiddlewareOptions);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
let reporter;
|
||||
const singletonKey = '__webpack_hot_middleware_reporter__';
|
||||
const enableHotMiddleware = () => {
|
||||
if (typeof window === 'undefined') {
|
||||
// do nothing
|
||||
}
|
||||
else if (typeof window.EventSource === 'undefined') {
|
||||
console.warn('Unsupported browser: You need a browser that supports EventSource ');
|
||||
}
|
||||
else {
|
||||
connect();
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
if (!window[singletonKey]) {
|
||||
window[singletonKey] = createReporter();
|
||||
}
|
||||
reporter = window[singletonKey];
|
||||
}
|
||||
};
|
||||
exports.enableHotMiddleware = enableHotMiddleware;
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Source code is adapted from
|
||||
* https://github.com/webpack-contrib/webpack-hot-middleware#readme
|
||||
* and rewritten in TypeScript. This file is MIT licensed
|
||||
*/
|
||||
/**
|
||||
* Based heavily on https://github.com/webpack/webpack/blob/
|
||||
* c0afdf9c6abc1dd70707c594e473802a566f7b6e/hot/only-dev-server.js
|
||||
* Original copyright Tobias Koppers @sokra (MIT license)
|
||||
*/
|
||||
import type { HotMiddlewareOptions, ModuleMap } from '@remotion/studio-shared';
|
||||
export declare const processUpdate: (hash: string | undefined, moduleMap: ModuleMap, options: HotMiddlewareOptions) => void;
|
||||
Generated
Vendored
+158
@@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
/* eslint-disable no-console */
|
||||
/**
|
||||
* Source code is adapted from
|
||||
* https://github.com/webpack-contrib/webpack-hot-middleware#readme
|
||||
* and rewritten in TypeScript. This file is MIT licensed
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.processUpdate = void 0;
|
||||
const NotificationCenter_1 = require("../components/Notifications/NotificationCenter");
|
||||
const url_state_1 = require("../helpers/url-state");
|
||||
if (!__webpack_module__.hot) {
|
||||
throw new Error('[Fast refresh] Hot Module Replacement is disabled.');
|
||||
}
|
||||
const hmrDocsUrl = 'https://webpack.js.org/concepts/hot-module-replacement/';
|
||||
let lastHash;
|
||||
const failureStatuses = { abort: 1, fail: 1 };
|
||||
const applyOptions = {
|
||||
ignoreUnaccepted: true,
|
||||
ignoreDeclined: true,
|
||||
ignoreErrored: true,
|
||||
onUnaccepted(data) {
|
||||
var _a;
|
||||
console.warn('Ignored an update to unaccepted module ' +
|
||||
((_a = data.chain) !== null && _a !== void 0 ? _a : []).join(' -> '));
|
||||
// Case:
|
||||
// 1. Import a CSS file with a bad filename in Root.tsx
|
||||
// 2. Fix the import and save it
|
||||
if (!window.remotion_isStudio) {
|
||||
(0, url_state_1.reloadUrl)();
|
||||
}
|
||||
},
|
||||
onDeclined(data) {
|
||||
var _a;
|
||||
console.warn('Ignored an update to declined module ' + ((_a = data.chain) !== null && _a !== void 0 ? _a : []).join(' -> '));
|
||||
},
|
||||
onErrored(data) {
|
||||
console.error(data.error);
|
||||
console.warn('Ignored an error while updating module ' +
|
||||
data.moduleId +
|
||||
' (' +
|
||||
data.type +
|
||||
')');
|
||||
},
|
||||
};
|
||||
function upToDate(hash) {
|
||||
if (hash)
|
||||
lastHash = hash;
|
||||
return lastHash === __webpack_hash__;
|
||||
}
|
||||
const processUpdate = function (hash, moduleMap, options) {
|
||||
var _a;
|
||||
const { reload } = options;
|
||||
if (!upToDate(hash) && ((_a = __webpack_module__.hot) === null || _a === void 0 ? void 0 : _a.status()) === 'idle') {
|
||||
check();
|
||||
}
|
||||
async function check() {
|
||||
var _a;
|
||||
const cb = function (err, updatedModules) {
|
||||
var _a;
|
||||
if (err)
|
||||
return handleError(err);
|
||||
if (!updatedModules) {
|
||||
if (options.warn) {
|
||||
console.warn('[Fast refresh] Cannot find update (Full reload needed)');
|
||||
console.warn('[Fast refresh] (Probably because of restarting the server)');
|
||||
}
|
||||
performReload();
|
||||
return null;
|
||||
}
|
||||
const applyCallback = function (applyErr, renewedModules) {
|
||||
if (applyErr)
|
||||
return handleError(applyErr);
|
||||
if (!upToDate()) {
|
||||
check();
|
||||
}
|
||||
logUpdates(updatedModules, renewedModules);
|
||||
};
|
||||
const applyResult = (_a = __webpack_module__.hot) === null || _a === void 0 ? void 0 : _a.apply(applyOptions);
|
||||
if (applyResult === null || applyResult === void 0 ? void 0 : applyResult.then) {
|
||||
// HotModuleReplacement.runtime.js refers to the result as `outdatedModules`
|
||||
applyResult
|
||||
.then((outdatedModules) => {
|
||||
applyCallback(null, outdatedModules);
|
||||
})
|
||||
.catch((_err) => applyCallback(_err, []));
|
||||
}
|
||||
};
|
||||
try {
|
||||
const result = await ((_a = __webpack_module__.hot) === null || _a === void 0 ? void 0 : _a.check(false));
|
||||
cb(null, result);
|
||||
}
|
||||
catch (err) {
|
||||
cb(err, []);
|
||||
}
|
||||
}
|
||||
function logUpdates(updatedModules, renewedModules) {
|
||||
var _a;
|
||||
const unacceptedModules = (_a = updatedModules === null || updatedModules === void 0 ? void 0 : updatedModules.filter((moduleId) => {
|
||||
return renewedModules && renewedModules.indexOf(moduleId) < 0;
|
||||
})) !== null && _a !== void 0 ? _a : [];
|
||||
if (unacceptedModules.length > 0) {
|
||||
if (options.warn) {
|
||||
console.warn("[Fast refresh] The following modules couldn't be hot updated: " +
|
||||
'(Full reload needed)\n' +
|
||||
'This is usually because the modules which have changed ' +
|
||||
'(and their parents) do not know how to hot reload themselves. ' +
|
||||
'See ' +
|
||||
hmrDocsUrl +
|
||||
' for more details.');
|
||||
unacceptedModules.forEach((moduleId) => {
|
||||
console.warn('[Fast refresh] - ' + (moduleMap[moduleId] || moduleId));
|
||||
});
|
||||
}
|
||||
performReload();
|
||||
return;
|
||||
}
|
||||
if (!renewedModules || renewedModules.length === 0) {
|
||||
console.log('[Fast refresh] Nothing hot updated.');
|
||||
}
|
||||
else {
|
||||
renewedModules.forEach((moduleId) => {
|
||||
console.log(`[Fast refresh] ${moduleMap[moduleId] || moduleId} fast refreshed.`);
|
||||
});
|
||||
}
|
||||
}
|
||||
function handleError(err) {
|
||||
var _a, _b;
|
||||
if (((_b = (_a = __webpack_module__.hot) === null || _a === void 0 ? void 0 : _a.status()) !== null && _b !== void 0 ? _b : 'nope') in failureStatuses) {
|
||||
if (options.warn) {
|
||||
console.warn('[Fast refresh] Cannot check for update (Full reload needed)');
|
||||
console.warn('[Fast refresh] ' + (err.stack || err.message));
|
||||
}
|
||||
performReload();
|
||||
return;
|
||||
}
|
||||
if (options.warn) {
|
||||
console.warn('[Fast refresh] Update check failed: ' + (err.stack || err.message));
|
||||
if (!window.remotion_unsavedProps) {
|
||||
(0, url_state_1.reloadUrl)();
|
||||
}
|
||||
}
|
||||
}
|
||||
function performReload() {
|
||||
if (!reload) {
|
||||
return;
|
||||
}
|
||||
if (options.warn)
|
||||
console.warn('[Fast refresh] Reloading page');
|
||||
if (window.remotion_unsavedProps) {
|
||||
(0, NotificationCenter_1.showNotification)('Fast refresh needs to reload the page, but you have unsaved props. Save then reload the page to apply changes.', 1000);
|
||||
}
|
||||
else {
|
||||
(0, url_state_1.reloadUrl)();
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.processUpdate = processUpdate;
|
||||
Reference in New Issue
Block a user