Add .gitignore to exclude all node packages and lock files
This commit is contained in:
Generated
Vendored
+123
@@ -0,0 +1,123 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.makeOrReuseServer = exports.prepareServer = void 0;
|
||||
const node_fs_1 = require("node:fs");
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const no_react_1 = require("remotion/no-react");
|
||||
const download_and_map_assets_to_file_1 = require("./assets/download-and-map-assets-to-file");
|
||||
const download_map_1 = require("./assets/download-map");
|
||||
const get_bundle_url_from_serve_url_1 = require("./get-bundle-url-from-serve-url");
|
||||
const is_serve_url_1 = require("./is-serve-url");
|
||||
const logger_1 = require("./logger");
|
||||
const normalize_serve_url_1 = require("./normalize-serve-url");
|
||||
const serve_static_1 = require("./serve-static");
|
||||
const symbolicate_stacktrace_1 = require("./symbolicate-stacktrace");
|
||||
const wait_for_symbolication_error_to_be_done_1 = require("./wait-for-symbolication-error-to-be-done");
|
||||
const prepareServer = async ({ webpackConfigOrServeUrl, port, remotionRoot, offthreadVideoThreads, logLevel, indent, offthreadVideoCacheSizeInBytes, binariesDirectory, forceIPv4, }) => {
|
||||
const downloadMap = (0, download_map_1.makeDownloadMap)();
|
||||
logger_1.Log.verbose({ indent, logLevel }, 'Created directory for temporary files', downloadMap.assetDir);
|
||||
if ((0, is_serve_url_1.isServeUrl)(webpackConfigOrServeUrl)) {
|
||||
const { port: offthreadPort, close: closeProxy, compositor: comp, } = await (0, serve_static_1.serveStatic)(null, {
|
||||
port,
|
||||
downloadMap,
|
||||
remotionRoot,
|
||||
offthreadVideoThreads,
|
||||
logLevel,
|
||||
indent,
|
||||
offthreadVideoCacheSizeInBytes,
|
||||
binariesDirectory,
|
||||
forceIPv4,
|
||||
});
|
||||
const normalized = (0, normalize_serve_url_1.normalizeServeUrl)(webpackConfigOrServeUrl);
|
||||
let remoteSourceMap = null;
|
||||
(0, symbolicate_stacktrace_1.getSourceMapFromRemoteUrl)((0, get_bundle_url_from_serve_url_1.getBundleMapUrlFromServeUrl)(normalized))
|
||||
.then((s) => {
|
||||
remoteSourceMap = s;
|
||||
})
|
||||
.catch((err) => {
|
||||
logger_1.Log.verbose({ indent, logLevel }, 'Could not fetch sourcemap for ', normalized, err);
|
||||
});
|
||||
return Promise.resolve({
|
||||
serveUrl: normalized,
|
||||
closeServer: () => {
|
||||
(0, download_map_1.cleanDownloadMap)(downloadMap);
|
||||
remoteSourceMap === null || remoteSourceMap === void 0 ? void 0 : remoteSourceMap.destroy();
|
||||
remoteSourceMap = null;
|
||||
return closeProxy();
|
||||
},
|
||||
offthreadPort,
|
||||
compositor: comp,
|
||||
sourceMap: () => remoteSourceMap,
|
||||
downloadMap,
|
||||
});
|
||||
}
|
||||
// Check if the path has a `index.html` file
|
||||
const indexFile = node_path_1.default.join(webpackConfigOrServeUrl, 'index.html');
|
||||
const exists = (0, node_fs_1.existsSync)(indexFile);
|
||||
if (!exists) {
|
||||
throw new Error(`Tried to serve the Webpack bundle on a HTTP server, but the file ${indexFile} does not exist. Is this a valid path to a Webpack bundle?`);
|
||||
}
|
||||
let localSourceMap = null;
|
||||
(0, symbolicate_stacktrace_1.getSourceMapFromLocalFile)(node_path_1.default.join(webpackConfigOrServeUrl, no_react_1.NoReactInternals.bundleName))
|
||||
.then((s) => {
|
||||
localSourceMap = s;
|
||||
})
|
||||
.catch((err) => {
|
||||
logger_1.Log.verbose({ indent, logLevel }, 'Could not fetch sourcemap for ', webpackConfigOrServeUrl, err);
|
||||
});
|
||||
const { port: serverPort, close, compositor, } = await (0, serve_static_1.serveStatic)(webpackConfigOrServeUrl, {
|
||||
port,
|
||||
downloadMap,
|
||||
remotionRoot,
|
||||
offthreadVideoThreads,
|
||||
logLevel,
|
||||
indent,
|
||||
offthreadVideoCacheSizeInBytes,
|
||||
binariesDirectory,
|
||||
forceIPv4,
|
||||
});
|
||||
return Promise.resolve({
|
||||
closeServer: async (force) => {
|
||||
localSourceMap === null || localSourceMap === void 0 ? void 0 : localSourceMap.destroy();
|
||||
localSourceMap = null;
|
||||
(0, download_map_1.cleanDownloadMap)(downloadMap);
|
||||
if (!force) {
|
||||
await (0, wait_for_symbolication_error_to_be_done_1.waitForSymbolicationToBeDone)();
|
||||
}
|
||||
return close();
|
||||
},
|
||||
// This should be kept localhost, even if the server is bound to ::1,
|
||||
// to prevent "Failed to load resource: net::ERR_FAILED Access to image at 'http://localhost:3000/proxy?src=http%3A%2F%2F%5B%3A%3A%5D%3A3000%2Fpublic%2Fframer.webm&time=0&transparent=false' from origin 'http://[::]:3000' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`".
|
||||
serveUrl: `http://localhost:${serverPort}`,
|
||||
offthreadPort: serverPort,
|
||||
compositor,
|
||||
sourceMap: () => localSourceMap,
|
||||
downloadMap,
|
||||
});
|
||||
};
|
||||
exports.prepareServer = prepareServer;
|
||||
const makeOrReuseServer = async (server, config, { onDownload, }) => {
|
||||
if (server) {
|
||||
const cleanupOnDownload = (0, download_and_map_assets_to_file_1.attachDownloadListenerToEmitter)(server.downloadMap, onDownload);
|
||||
return {
|
||||
server,
|
||||
cleanupServer: () => {
|
||||
cleanupOnDownload();
|
||||
return Promise.resolve();
|
||||
},
|
||||
};
|
||||
}
|
||||
const newServer = await (0, exports.prepareServer)(config);
|
||||
const cleanupOnDownloadNew = (0, download_and_map_assets_to_file_1.attachDownloadListenerToEmitter)(newServer.downloadMap, onDownload);
|
||||
return {
|
||||
server: newServer,
|
||||
cleanupServer: (force) => {
|
||||
cleanupOnDownloadNew();
|
||||
return Promise.all([newServer.closeServer(force)]);
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.makeOrReuseServer = makeOrReuseServer;
|
||||
Reference in New Issue
Block a user