@remix-run/node
Advanced tools
Comparing version 0.0.0-nightly-2483ce5-20221019 to 0.0.0-nightly-24d1b2186-20240830
/** | ||
* @remix-run/node v0.0.0-nightly-2483ce5-20221019 | ||
* @remix-run/node v0.0.0-nightly-24d1b2186-20240830 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -1,2 +0,1 @@ | ||
import { atob, btoa } from "./base64"; | ||
declare global { | ||
@@ -8,5 +7,2 @@ namespace NodeJS { | ||
interface Global { | ||
atob: typeof atob; | ||
btoa: typeof btoa; | ||
Blob: typeof Blob; | ||
File: typeof File; | ||
@@ -22,3 +18,8 @@ Headers: typeof Headers; | ||
} | ||
interface RequestInit { | ||
duplex?: "half"; | ||
} | ||
} | ||
export declare function installGlobals(): void; | ||
export declare function installGlobals({ nativeFetch, }?: { | ||
nativeFetch?: boolean; | ||
}): void; |
/** | ||
* @remix-run/node v0.0.0-nightly-2483ce5-20221019 | ||
* @remix-run/node v0.0.0-nightly-24d1b2186-20240830 | ||
* | ||
@@ -15,22 +15,38 @@ * Copyright (c) Remix Software Inc. | ||
var webStream = require('@remix-run/web-stream'); | ||
var base64 = require('./base64.js'); | ||
var fetch = require('./fetch.js'); | ||
var webFile = require('@remix-run/web-file'); | ||
var webFetch = require('@remix-run/web-fetch'); | ||
function installGlobals() { | ||
global.atob = base64.atob; | ||
global.btoa = base64.btoa; | ||
global.Blob = webFile.Blob; | ||
global.File = webFile.File; | ||
global.Headers = webFetch.Headers; | ||
global.Request = fetch.Request; | ||
global.Response = fetch.Response; | ||
global.fetch = fetch.fetch; | ||
global.FormData = webFetch.FormData; | ||
global.ReadableStream = webStream.ReadableStream; | ||
global.WritableStream = webStream.WritableStream; | ||
function installGlobals({ | ||
nativeFetch | ||
} = {}) { | ||
if (nativeFetch) { | ||
let { | ||
File: UndiciFile, | ||
fetch: undiciFetch, | ||
FormData: UndiciFormData, | ||
Headers: UndiciHeaders, | ||
Request: UndiciRequest, | ||
Response: UndiciResponse | ||
} = require("undici"); | ||
global.File = UndiciFile; | ||
global.Headers = UndiciHeaders; | ||
global.Request = UndiciRequest; | ||
global.Response = UndiciResponse; | ||
global.fetch = undiciFetch; | ||
global.FormData = UndiciFormData; | ||
} else { | ||
let { | ||
File: RemixFile, | ||
fetch: RemixFetch, | ||
FormData: RemixFormData, | ||
Headers: RemixHeaders, | ||
Request: RemixRequest, | ||
Response: RemixResponse | ||
} = require("@remix-run/web-fetch"); | ||
global.File = RemixFile; | ||
global.Headers = RemixHeaders; | ||
global.Request = RemixRequest; | ||
global.Response = RemixResponse; | ||
global.fetch = RemixFetch; | ||
global.FormData = RemixFormData; | ||
} | ||
} | ||
exports.installGlobals = installGlobals; |
/** | ||
* @remix-run/node v0.0.0-nightly-2483ce5-20221019 | ||
* @remix-run/node v0.0.0-nightly-24d1b2186-20240830 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -1,4 +0,1 @@ | ||
export { AbortController } from "abort-controller"; | ||
export type { HeadersInit, RequestInfo, RequestInit, ResponseInit, } from "./fetch"; | ||
export { fetch, FormData, Headers, Request, Response } from "./fetch"; | ||
export { installGlobals } from "./globals"; | ||
@@ -9,3 +6,3 @@ export { createFileSessionStorage } from "./sessions/fileStorage"; | ||
export { createReadableStreamFromReadable, readableStreamToString, writeAsyncIterableToWritable, writeReadableStreamToWritable, } from "./stream"; | ||
export { createRequestHandler, createSession, isCookie, isSession, json, JsonFunction, MaxPartSizeExceededError, redirect, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData, } from "@remix-run/server-runtime"; | ||
export type { ActionArgs, ActionFunction, AppData, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, DataFunctionArgs, EntryContext, ErrorBoundaryComponent, HandleDataRequestFunction, HandleDocumentRequestFunction, HeadersFunction, HtmlLinkDescriptor, HtmlMetaDescriptor, LinkDescriptor, LinksFunction, LoaderArgs, LoaderFunction, MemoryUploadHandlerFilterArgs, MemoryUploadHandlerOptions, MetaDescriptor, MetaFunction, PageLinkDescriptor, RequestHandler, RouteComponent, RouteHandle, SerializeFrom, ServerBuild, ServerEntryModule, Session, SessionData, SessionIdStorageStrategy, SessionStorage, SignFunction, TypedResponse, UnsignFunction, UploadHandlerPart, UploadHandler, } from "@remix-run/server-runtime"; | ||
export { createRequestHandler, createSession, unstable_data, defer, broadcastDevReady, logDevReady, isCookie, isSession, json, MaxPartSizeExceededError, redirect, redirectDocument, replace, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData, } from "@remix-run/server-runtime"; | ||
export type { ActionFunction, ActionFunctionArgs, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, DataFunctionArgs, EntryContext, ErrorResponse, HandleDataRequestFunction, HandleDocumentRequestFunction, HeadersArgs, HeadersFunction, HtmlLinkDescriptor, JsonFunction, LinkDescriptor, LinksFunction, LoaderFunction, LoaderFunctionArgs, MemoryUploadHandlerFilterArgs, MemoryUploadHandlerOptions, HandleErrorFunction, PageLinkDescriptor, RequestHandler, SerializeFrom, ServerBuild, ServerEntryModule, ServerRuntimeMetaArgs as MetaArgs, ServerRuntimeMetaDescriptor as MetaDescriptor, ServerRuntimeMetaFunction as MetaFunction, Session, SessionData, SessionIdStorageStrategy, SessionStorage, SignFunction, TypedDeferredData, TypedResponse, UnsignFunction, UploadHandler, UploadHandlerPart, } from "@remix-run/server-runtime"; |
/** | ||
* @remix-run/node v0.0.0-nightly-2483ce5-20221019 | ||
* @remix-run/node v0.0.0-nightly-24d1b2186-20240830 | ||
* | ||
@@ -15,5 +15,2 @@ * Copyright (c) Remix Software Inc. | ||
var sourceMapSupport = require('source-map-support'); | ||
var abortController = require('abort-controller'); | ||
var fetch = require('./fetch.js'); | ||
var globals = require('./globals.js'); | ||
@@ -25,17 +22,5 @@ var fileStorage = require('./sessions/fileStorage.js'); | ||
var serverRuntime = require('@remix-run/server-runtime'); | ||
var webFetch = require('@remix-run/web-fetch'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var sourceMapSupport__default = /*#__PURE__*/_interopDefaultLegacy(sourceMapSupport); | ||
sourceMapSupport__default["default"].install(); | ||
Object.defineProperty(exports, 'AbortController', { | ||
enumerable: true, | ||
get: function () { return abortController.AbortController; } | ||
}); | ||
exports.Request = fetch.Request; | ||
exports.Response = fetch.Response; | ||
exports.fetch = fetch.fetch; | ||
exports.installGlobals = globals.installGlobals; | ||
@@ -53,6 +38,2 @@ exports.createFileSessionStorage = fileStorage.createFileSessionStorage; | ||
exports.writeReadableStreamToWritable = stream.writeReadableStreamToWritable; | ||
Object.defineProperty(exports, 'JsonFunction', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.JsonFunction; } | ||
}); | ||
Object.defineProperty(exports, 'MaxPartSizeExceededError', { | ||
@@ -62,2 +43,6 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, 'broadcastDevReady', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.broadcastDevReady; } | ||
}); | ||
Object.defineProperty(exports, 'createRequestHandler', { | ||
@@ -71,2 +56,6 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, 'defer', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.defer; } | ||
}); | ||
Object.defineProperty(exports, 'isCookie', { | ||
@@ -84,2 +73,6 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, 'logDevReady', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.logDevReady; } | ||
}); | ||
Object.defineProperty(exports, 'redirect', { | ||
@@ -89,2 +82,10 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, 'redirectDocument', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.redirectDocument; } | ||
}); | ||
Object.defineProperty(exports, 'replace', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.replace; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_composeUploadHandlers', { | ||
@@ -98,2 +99,6 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, 'unstable_data', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.unstable_data; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_parseMultipartFormData', { | ||
@@ -103,9 +108,1 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, 'FormData', { | ||
enumerable: true, | ||
get: function () { return webFetch.FormData; } | ||
}); | ||
Object.defineProperty(exports, 'Headers', { | ||
enumerable: true, | ||
get: function () { return webFetch.Headers; } | ||
}); |
@@ -1,2 +0,2 @@ | ||
import type { SessionStorage, SessionIdStorageStrategy } from "@remix-run/server-runtime"; | ||
import type { SessionStorage, SessionIdStorageStrategy, SessionData } from "@remix-run/server-runtime"; | ||
interface FileSessionStorageOptions { | ||
@@ -19,5 +19,6 @@ /** | ||
* | ||
* @see https://remix.run/api/remix#createfilesessionstorage-node | ||
* @see https://remix.run/utils/sessions#createfilesessionstorage-node | ||
*/ | ||
export declare function createFileSessionStorage({ cookie, dir, }: FileSessionStorageOptions): SessionStorage; | ||
export declare function createFileSessionStorage<Data = SessionData, FlashData = Data>({ cookie, dir, }: FileSessionStorageOptions): SessionStorage<Data, FlashData>; | ||
export declare function getFile(dir: string, id: string): string; | ||
export {}; |
/** | ||
* @remix-run/node v0.0.0-nightly-2483ce5-20221019 | ||
* @remix-run/node v0.0.0-nightly-24d1b2186-20240830 | ||
* | ||
@@ -15,5 +15,5 @@ * Copyright (c) Remix Software Inc. | ||
var crypto = require('crypto'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var crypto = require('node:crypto'); | ||
var node_fs = require('node:fs'); | ||
var path = require('node:path'); | ||
var implementations = require('../implementations.js'); | ||
@@ -48,3 +48,3 @@ | ||
* | ||
* @see https://remix.run/api/remix#createfilesessionstorage-node | ||
* @see https://remix.run/utils/sessions#createfilesessionstorage-node | ||
*/ | ||
@@ -57,3 +57,2 @@ function createFileSessionStorage({ | ||
cookie, | ||
async createData(data, expires) { | ||
@@ -64,19 +63,17 @@ let content = JSON.stringify({ | ||
}); | ||
while (true) { | ||
// TODO: Once node v16 is available on AWS we should use the webcrypto | ||
// API's crypto.getRandomValues() function here instead. | ||
let randomBytes = crypto__namespace.randomBytes(8); // This storage manages an id space of 2^64 ids, which is far greater | ||
// TODO: Once Node v19 is supported we should use the globally provided | ||
// Web Crypto API's crypto.getRandomValues() function here instead. | ||
let randomBytes = crypto__namespace.webcrypto.getRandomValues(new Uint8Array(8)); | ||
// This storage manages an id space of 2^64 ids, which is far greater | ||
// than the maximum number of files allowed on an NTFS or ext4 volume | ||
// (2^32). However, the larger id space should help to avoid collisions | ||
// with existing ids when creating new sessions, which speeds things up. | ||
let id = Buffer.from(randomBytes).toString("hex"); | ||
try { | ||
let file = getFile(dir, id); | ||
await fs.promises.mkdir(path__namespace.dirname(file), { | ||
await node_fs.promises.mkdir(path__namespace.dirname(file), { | ||
recursive: true | ||
}); | ||
await fs.promises.writeFile(file, content, { | ||
await node_fs.promises.writeFile(file, content, { | ||
encoding: "utf-8", | ||
@@ -91,16 +88,14 @@ flag: "wx" | ||
}, | ||
async readData(id) { | ||
try { | ||
let file = getFile(dir, id); | ||
let content = JSON.parse(await fs.promises.readFile(file, "utf-8")); | ||
let content = JSON.parse(await node_fs.promises.readFile(file, "utf-8")); | ||
let data = content.data; | ||
let expires = typeof content.expires === "string" ? new Date(content.expires) : null; | ||
if (!expires || expires > new Date()) { | ||
return data; | ||
} // Remove expired session data. | ||
} | ||
if (expires) await fs.promises.unlink(file); | ||
// Remove expired session data. | ||
if (expires) await node_fs.promises.unlink(file); | ||
return null; | ||
@@ -112,3 +107,2 @@ } catch (error) { | ||
}, | ||
async updateData(id, data, expires) { | ||
@@ -120,8 +114,7 @@ let content = JSON.stringify({ | ||
let file = getFile(dir, id); | ||
await fs.promises.mkdir(path__namespace.dirname(file), { | ||
await node_fs.promises.mkdir(path__namespace.dirname(file), { | ||
recursive: true | ||
}); | ||
await fs.promises.writeFile(file, content, "utf-8"); | ||
await node_fs.promises.writeFile(file, content, "utf-8"); | ||
}, | ||
async deleteData(id) { | ||
@@ -133,5 +126,4 @@ // Return early if the id is empty, otherwise we'll end up trying to | ||
} | ||
try { | ||
await fs.promises.unlink(getFile(dir, id)); | ||
await node_fs.promises.unlink(getFile(dir, id)); | ||
} catch (error) { | ||
@@ -141,6 +133,4 @@ if (error.code !== "ENOENT") throw error; | ||
} | ||
}); | ||
} | ||
function getFile(dir, id) { | ||
@@ -155,1 +145,2 @@ // Divide the session id up into a directory (first 2 bytes) and filename | ||
exports.createFileSessionStorage = createFileSessionStorage; | ||
exports.getFile = getFile; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { Readable, Writable } from "stream"; | ||
import type { Readable, Writable } from "node:stream"; | ||
export declare function writeReadableStreamToWritable(stream: ReadableStream, writable: Writable): Promise<void>; | ||
@@ -5,0 +5,0 @@ export declare function writeAsyncIterableToWritable(iterable: AsyncIterable<Uint8Array>, writable: Writable): Promise<void>; |
/** | ||
* @remix-run/node v0.0.0-nightly-2483ce5-20221019 | ||
* @remix-run/node v0.0.0-nightly-24d1b2186-20240830 | ||
* | ||
@@ -15,31 +15,22 @@ * Copyright (c) Remix Software Inc. | ||
var stream = require('stream'); | ||
var node_stream = require('node:stream'); | ||
async function writeReadableStreamToWritable(stream, writable) { | ||
let reader = stream.getReader(); | ||
async function read() { | ||
let { | ||
done, | ||
value | ||
} = await reader.read(); | ||
if (done) { | ||
writable.end(); | ||
return; | ||
let flushable = writable; | ||
try { | ||
while (true) { | ||
let { | ||
done, | ||
value | ||
} = await reader.read(); | ||
if (done) { | ||
writable.end(); | ||
break; | ||
} | ||
writable.write(value); | ||
if (typeof flushable.flush === "function") { | ||
flushable.flush(); | ||
} | ||
} | ||
writable.write(value); // If the stream is flushable, flush it to allow streaming to continue. | ||
let flushable = writable; | ||
if (typeof flushable.flush === "function") { | ||
flushable.flush(); | ||
} | ||
await read(); | ||
} | ||
try { | ||
await read(); | ||
} catch (error) { | ||
@@ -55,3 +46,2 @@ writable.destroy(error); | ||
} | ||
writable.end(); | ||
@@ -66,4 +56,3 @@ } catch (error) { | ||
let chunks = []; | ||
async function read() { | ||
while (true) { | ||
let { | ||
@@ -73,13 +62,9 @@ done, | ||
} = await reader.read(); | ||
if (done) { | ||
return; | ||
} else if (value) { | ||
break; | ||
} | ||
if (value) { | ||
chunks.push(value); | ||
} | ||
await read(); | ||
} | ||
await read(); | ||
return Buffer.concat(chunks).toString(encoding); | ||
@@ -92,8 +77,7 @@ } | ||
}; | ||
class StreamPump { | ||
constructor(stream$1) { | ||
this.highWaterMark = stream$1.readableHighWaterMark || new stream.Stream.Readable().readableHighWaterMark; | ||
constructor(stream) { | ||
this.highWaterMark = stream.readableHighWaterMark || new node_stream.Stream.Readable().readableHighWaterMark; | ||
this.accumalatedSize = 0; | ||
this.stream = stream$1; | ||
this.stream = stream; | ||
this.enqueue = this.enqueue.bind(this); | ||
@@ -103,7 +87,5 @@ this.error = this.error.bind(this); | ||
} | ||
size(chunk) { | ||
return (chunk === null || chunk === void 0 ? void 0 : chunk.byteLength) || 0; | ||
} | ||
start(controller) { | ||
@@ -116,7 +98,5 @@ this.controller = controller; | ||
} | ||
pull() { | ||
this.resume(); | ||
} | ||
cancel(reason) { | ||
@@ -126,3 +106,2 @@ if (this.stream.destroy) { | ||
} | ||
this.stream.off("data", this.enqueue); | ||
@@ -133,3 +112,2 @@ this.stream.off("error", this.error); | ||
} | ||
enqueue(chunk) { | ||
@@ -141,3 +119,2 @@ if (this.controller) { | ||
this.controller.enqueue(bytes); | ||
if (available <= 0) { | ||
@@ -152,3 +129,2 @@ this.pause(); | ||
} | ||
pause() { | ||
@@ -159,3 +135,2 @@ if (this.stream.pause) { | ||
} | ||
resume() { | ||
@@ -166,3 +141,2 @@ if (this.stream.readable && this.stream.resume) { | ||
} | ||
close() { | ||
@@ -174,3 +148,2 @@ if (this.controller) { | ||
} | ||
error(error) { | ||
@@ -182,3 +155,2 @@ if (this.controller) { | ||
} | ||
} | ||
@@ -185,0 +157,0 @@ |
/// <reference types="node" /> | ||
import type { UploadHandler } from "@remix-run/server-runtime"; | ||
export declare type FileUploadHandlerFilterArgs = { | ||
export type FileUploadHandlerFilterArgs = { | ||
filename: string; | ||
@@ -8,3 +8,3 @@ contentType: string; | ||
}; | ||
export declare type FileUploadHandlerPathResolverArgs = { | ||
export type FileUploadHandlerPathResolverArgs = { | ||
filename: string; | ||
@@ -18,4 +18,4 @@ contentType: string; | ||
*/ | ||
export declare type FileUploadHandlerPathResolver = (args: FileUploadHandlerPathResolverArgs) => string | undefined; | ||
export declare type FileUploadHandlerOptions = { | ||
export type FileUploadHandlerPathResolver = (args: FileUploadHandlerPathResolverArgs) => string | undefined; | ||
export type FileUploadHandlerOptions = { | ||
/** | ||
@@ -43,4 +43,4 @@ * Avoid file conflicts by appending a count on the end of the filename | ||
* @param filename | ||
* @param mimetype | ||
* @param encoding | ||
* @param contentType | ||
* @param name | ||
*/ | ||
@@ -50,3 +50,3 @@ filter?(args: FileUploadHandlerFilterArgs): boolean | Promise<boolean>; | ||
export declare function createFileUploadHandler({ directory, avoidFileConflicts, file, filter, maxPartSize, }?: FileUploadHandlerOptions): UploadHandler; | ||
export declare class NodeOnDiskFile implements File { | ||
export declare class NodeOnDiskFile implements Omit<File, "constructor"> { | ||
private filepath; | ||
@@ -58,2 +58,3 @@ type: string; | ||
webkitRelativePath: string; | ||
prototype: File; | ||
constructor(filepath: string, type: string, slicer?: { | ||
@@ -70,2 +71,4 @@ start: number; | ||
get [Symbol.toStringTag](): string; | ||
remove(): Promise<void>; | ||
getFilePath(): string; | ||
} |
/** | ||
* @remix-run/node v0.0.0-nightly-2483ce5-20221019 | ||
* @remix-run/node v0.0.0-nightly-24d1b2186-20240830 | ||
* | ||
@@ -15,12 +15,12 @@ * Copyright (c) Remix Software Inc. | ||
var crypto = require('crypto'); | ||
var fs = require('fs'); | ||
var promises = require('fs/promises'); | ||
var os = require('os'); | ||
var path = require('path'); | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
var crypto = require('node:crypto'); | ||
var node_fs = require('node:fs'); | ||
var promises = require('node:fs/promises'); | ||
var node_os = require('node:os'); | ||
var path = require('node:path'); | ||
var node_stream = require('node:stream'); | ||
var node_util = require('node:util'); | ||
var serverRuntime = require('@remix-run/server-runtime'); | ||
var streamSlice = require('stream-slice'); | ||
var stream$1 = require('../stream.js'); | ||
var stream = require('../stream.js'); | ||
@@ -47,2 +47,7 @@ function _interopNamespace(e) { | ||
/** | ||
* Chooses the path of the file to be uploaded. If a string is not | ||
* returned the file will not be written. | ||
*/ | ||
let defaultFilePathResolver = ({ | ||
@@ -54,16 +59,12 @@ filename | ||
}; | ||
async function uniqueFile(filepath) { | ||
let ext = path.extname(filepath); | ||
let uniqueFilepath = filepath; | ||
for (let i = 1; await promises.stat(uniqueFilepath).then(() => true).catch(() => false); i++) { | ||
uniqueFilepath = (ext ? filepath.slice(0, -ext.length) : filepath) + `-${new Date().getTime()}${ext}`; | ||
} | ||
return uniqueFilepath; | ||
} | ||
function createFileUploadHandler({ | ||
directory = os.tmpdir(), | ||
directory = node_os.tmpdir(), | ||
avoidFileConflicts = true, | ||
@@ -87,3 +88,2 @@ file = defaultFilePathResolver, | ||
} | ||
let dir = typeof directory === "string" ? directory : directory({ | ||
@@ -94,7 +94,5 @@ name, | ||
}); | ||
if (!dir) { | ||
return undefined; | ||
} | ||
let filedir = path.resolve(dir); | ||
@@ -106,24 +104,18 @@ let path$1 = typeof file === "string" ? file : file({ | ||
}); | ||
if (!path$1) { | ||
return undefined; | ||
} | ||
let filepath = path.resolve(filedir, path$1); | ||
if (avoidFileConflicts) { | ||
filepath = await uniqueFile(filepath); | ||
} | ||
await promises.mkdir(path.dirname(filepath), { | ||
recursive: true | ||
}).catch(() => {}); | ||
let writeFileStream = fs.createWriteStream(filepath); | ||
let writeFileStream = node_fs.createWriteStream(filepath); | ||
let size = 0; | ||
let deleteFile = false; | ||
try { | ||
for await (let chunk of data) { | ||
size += chunk.byteLength; | ||
if (size > maxPartSize) { | ||
@@ -133,3 +125,2 @@ deleteFile = true; | ||
} | ||
writeFileStream.write(chunk); | ||
@@ -139,4 +130,3 @@ } | ||
writeFileStream.end(); | ||
await util.promisify(stream.finished)(writeFileStream); | ||
await node_util.promisify(node_stream.finished)(writeFileStream); | ||
if (deleteFile) { | ||
@@ -147,5 +137,10 @@ await promises.rm(filepath).catch(() => {}); | ||
// TODO: remove this typecast once TS fixed File class regression | ||
// https://github.com/microsoft/TypeScript/issues/52166 | ||
return new NodeOnDiskFile(filepath, contentType); | ||
}; | ||
} | ||
// TODO: remove this `Omit` usage once TS fixed File class regression | ||
// https://github.com/microsoft/TypeScript/issues/52166 | ||
class NodeOnDiskFile { | ||
@@ -155,2 +150,5 @@ lastModified = 0; | ||
// TODO: remove this property once TS fixed File class regression | ||
// https://github.com/microsoft/TypeScript/issues/52166 | ||
prototype = File.prototype; | ||
constructor(filepath, type, slicer) { | ||
@@ -162,6 +160,4 @@ this.filepath = filepath; | ||
} | ||
get size() { | ||
let stats = fs.statSync(this.filepath); | ||
let stats = node_fs.statSync(this.filepath); | ||
if (this.slicer) { | ||
@@ -171,9 +167,6 @@ let slice = this.slicer.end - this.slicer.start; | ||
} | ||
return stats.size; | ||
} | ||
slice(start, end, type) { | ||
var _this$slicer; | ||
if (typeof start === "number" && start < 0) start = this.size + start; | ||
@@ -187,12 +180,12 @@ if (typeof end === "number" && end < 0) end = this.size + end; | ||
end | ||
}); | ||
} | ||
// TODO: remove this typecast once TS fixed File class regression | ||
// https://github.com/microsoft/TypeScript/issues/52166 | ||
); | ||
} | ||
async arrayBuffer() { | ||
let stream = fs.createReadStream(this.filepath); | ||
let stream = node_fs.createReadStream(this.filepath); | ||
if (this.slicer) { | ||
stream = stream.pipe(streamSlice__namespace.slice(this.slicer.start, this.slicer.end)); | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -205,21 +198,21 @@ let buf = []; | ||
} | ||
stream() { | ||
let stream = fs.createReadStream(this.filepath); | ||
let stream$1 = node_fs.createReadStream(this.filepath); | ||
if (this.slicer) { | ||
stream = stream.pipe(streamSlice__namespace.slice(this.slicer.start, this.slicer.end)); | ||
stream$1 = stream$1.pipe(streamSlice__namespace.slice(this.slicer.start, this.slicer.end)); | ||
} | ||
return stream$1.createReadableStreamFromReadable(stream); | ||
return stream.createReadableStreamFromReadable(stream$1); | ||
} | ||
async text() { | ||
return stream$1.readableStreamToString(this.stream()); | ||
return stream.readableStreamToString(this.stream()); | ||
} | ||
get [Symbol.toStringTag]() { | ||
return "File"; | ||
} | ||
remove() { | ||
return promises.unlink(this.filepath); | ||
} | ||
getFilePath() { | ||
return this.filepath; | ||
} | ||
} | ||
@@ -226,0 +219,0 @@ |
@@ -1,7 +0,22 @@ | ||
Copyright 2021 Remix Software Inc. | ||
MIT License | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
Copyright (c) Remix Software Inc. 2020-2021 | ||
Copyright (c) Shopify Inc. 2022-2024 | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
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 AUTHORS 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. | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
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 | ||
AUTHORS 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. |
{ | ||
"name": "@remix-run/node", | ||
"version": "0.0.0-nightly-2483ce5-20221019", | ||
"version": "0.0.0-nightly-24d1b2186-20240830", | ||
"description": "Node.js platform abstractions for Remix", | ||
@@ -16,20 +16,29 @@ "bugs": { | ||
"typings": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"sideEffects": [ | ||
"./install.js" | ||
], | ||
"dependencies": { | ||
"@remix-run/server-runtime": "0.0.0-nightly-2483ce5-20221019", | ||
"@remix-run/web-fetch": "^4.3.1", | ||
"@remix-run/web-file": "^3.0.2", | ||
"@remix-run/web-stream": "^1.0.3", | ||
"@remix-run/server-runtime": "0.0.0-nightly-24d1b2186-20240830", | ||
"@remix-run/web-fetch": "^4.4.2", | ||
"@web3-storage/multipart-parser": "^1.0.0", | ||
"abort-controller": "^3.0.0", | ||
"cookie-signature": "^1.1.0", | ||
"source-map-support": "^0.5.21", | ||
"stream-slice": "^0.1.2" | ||
"stream-slice": "^0.1.2", | ||
"undici": "^6.11.1" | ||
}, | ||
"devDependencies": { | ||
"@types/cookie-signature": "^1.0.3", | ||
"@types/source-map-support": "^0.5.4" | ||
"@types/source-map-support": "^0.5.4", | ||
"typescript": "^5.1.6" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.1.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"typescript": { | ||
"optional": true | ||
} | ||
}, | ||
"engines": { | ||
"node": ">=14" | ||
"node": ">=18.0.0" | ||
}, | ||
@@ -39,6 +48,11 @@ "files": [ | ||
"globals.d.ts", | ||
"install.d.ts", | ||
"install.js", | ||
"CHANGELOG.md", | ||
"LICENSE.md", | ||
"README.md" | ||
] | ||
} | ||
], | ||
"scripts": { | ||
"tsc": "tsc" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
8
0
0
30929
3
20
805
+ Addedundici@^6.11.1
+ Added@remix-run/router@0.0.0-experimental-7d87ffb8c(transitive)
+ Added@remix-run/server-runtime@0.0.0-nightly-24d1b2186-20240830(transitive)
+ Added@types/cookie@0.6.0(transitive)
+ Addedcookie@0.6.0(transitive)
+ Addedturbo-stream@2.4.0(transitive)
+ Addedtypescript@5.7.2(transitive)
+ Addedundici@6.21.0(transitive)
- Removed@remix-run/web-file@^3.0.2
- Removed@remix-run/web-stream@^1.0.3
- Removedabort-controller@^3.0.0
- Removed@babel/runtime@7.26.0(transitive)
- Removed@remix-run/server-runtime@0.0.0-nightly-2483ce5-20221019(transitive)
- Removed@types/cookie@0.4.1(transitive)
- Removedcookie@0.4.2(transitive)
- Removedhistory@5.3.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedreact@18.3.1(transitive)
- Removedreact-dom@18.3.1(transitive)
- Removedreact-router@6.3.0(transitive)
- Removedreact-router-dom@6.3.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedscheduler@0.23.2(transitive)
Updated@remix-run/server-runtime@0.0.0-nightly-24d1b2186-20240830
Updated@remix-run/web-fetch@^4.4.2