diff --git a/packages/next/compiled/webpack/bundle5.js b/packages/next/compiled/webpack/bundle5.js index 1ed5d251ff7af7f..8b99e94c26a0bce 100644 --- a/packages/next/compiled/webpack/bundle5.js +++ b/packages/next/compiled/webpack/bundle5.js @@ -129584,56 +129584,44 @@ class OperationMergerBackend { * @param {any} providerContext call context for the provider methods */ constructor(provider, syncProvider, providerContext) { - const activeAsyncOperations = new Map(); + this._provider = provider; + this._syncProvider = syncProvider; + this._providerContext = providerContext; + this._activeAsyncOperations = new Map(); - this.provide = provider + this.provide = this._provider ? (path, options, callback) => { if (typeof options === "function") { callback = options; options = undefined; } if (options) { - return provider.call(providerContext, path, options, callback); + return this._provider.call( + this._providerContext, + path, + options, + callback + ); } if (typeof path !== "string") { callback(new TypeError("path must be a string")); return; } - let callbacks = activeAsyncOperations.get(path); + let callbacks = this._activeAsyncOperations.get(path); if (callbacks) { callbacks.push(callback); return; } - activeAsyncOperations.set(path, (callbacks = [callback])); - provider.call(providerContext, path, (err, result) => { - activeAsyncOperations.delete(path); + this._activeAsyncOperations.set(path, (callbacks = [callback])); + provider(path, (err, result) => { + this._activeAsyncOperations.delete(path); runCallbacks(callbacks, err, result); }); } : null; - this.provideSync = syncProvider + this.provideSync = this._syncProvider ? (path, options) => { - return syncProvider.call(providerContext, path, options); - } - : null; - - this.provideCustom = provider - ? (provider, providerContext, path, callback) => { - let callbacks = activeAsyncOperations.get(path); - if (callbacks) { - callbacks.push(callback); - return; - } - activeAsyncOperations.set(path, (callbacks = [callback])); - provider.call(providerContext, path, (err, result) => { - activeAsyncOperations.delete(path); - runCallbacks(callbacks, err, result); - }); - } - : null; - this.provideCustomSync = syncProvider - ? (syncProvider, providerContext, path) => { - return syncProvider.call(providerContext, path); + return this._syncProvider.call(this._providerContext, path, options); } : null; } @@ -129698,11 +129686,6 @@ class CacheBackend { this.provide = provider ? this.provide.bind(this) : null; this.provideSync = syncProvider ? this.provideSync.bind(this) : null; - - this.provideCustom = provider ? this.provideCustom.bind(this) : null; - this.provideCustomSync = syncProvider - ? this.provideCustomSync.bind(this) - : null; } provide(path, options, callback) { @@ -129797,74 +129780,6 @@ class CacheBackend { return result; } - provideCustom(provider, providerContext, path, callback) { - // When in sync mode we can move to async mode - if (this._mode === STORAGE_MODE_SYNC) { - this._enterAsyncMode(); - } - - // Check in cache - let cacheEntry = this._data.get(path); - if (cacheEntry !== undefined) { - if (cacheEntry.err) return nextTick(callback, cacheEntry.err); - return nextTick(callback, null, cacheEntry.result); - } - - // Check if there is already the same operation running - let callbacks = this._activeAsyncOperations.get(path); - if (callbacks !== undefined) { - callbacks.push(callback); - return; - } - this._activeAsyncOperations.set(path, (callbacks = [callback])); - - // Run the operation - provider.call(providerContext, path, (err, result) => { - this._activeAsyncOperations.delete(path); - this._storeResult(path, err, result); - - // Enter async mode if not yet done - this._enterAsyncMode(); - - runCallbacks(callbacks, err, result); - }); - } - - provideCustomSync(provider, providerContext, path) { - // In sync mode we may have to decay some cache items - if (this._mode === STORAGE_MODE_SYNC) { - this._runDecays(); - } - - // Check in cache - let cacheEntry = this._data.get(path); - if (cacheEntry !== undefined) { - if (cacheEntry.err) throw cacheEntry.err; - return cacheEntry.result; - } - - // Get all active async operations - // This sync operation will also complete them - const callbacks = this._activeAsyncOperations.get(path); - this._activeAsyncOperations.delete(path); - - // Run the operation - // When in idle mode, we will enter sync mode - let result; - try { - result = provider.call(providerContext, path); - } catch (err) { - this._storeResult(path, err, undefined); - this._enterSyncModeWhenIdle(); - if (callbacks) runCallbacks(callbacks, err, undefined); - throw err; - } - this._storeResult(path, undefined, result); - this._enterSyncModeWhenIdle(); - if (callbacks) runCallbacks(callbacks, undefined, result); - return result; - } - purge(what) { if (!what) { if (this._mode !== STORAGE_MODE_IDLE) { @@ -130017,10 +129932,8 @@ module.exports = class CachedInputFileSystem { this.fileSystem ); const stat = this._statBackend.provide; - const customStat = this._statBackend.provideCustom; this.stat = /** @type {FileSystem["stat"]} */ (stat); const statSync = this._statBackend.provideSync; - const customStatSync = this._statBackend.provideCustomSync; this.statSync = /** @type {SyncFileSystem["statSync"]} */ (statSync); this._readdirBackend = createBackend( @@ -130036,161 +129949,8 @@ module.exports = class CachedInputFileSystem { this._readFileBackend = createBackend( duration, - this.fileSystem.readFile && - this.fileSystem.fstat && - this.fileSystem.read && - this.fileSystem.open && - this.fileSystem.close && - customStat - ? /** - * @this {{ fstat: NonNullable, readFile: NonNullable, open: NonNullable, read: NonNullable, close: NonNullable }} - */ - function (path, options, callback) { - if (typeof options === "function") { - callback = options; - options = undefined; - } - if (typeof options === "object") - return this.readFile(path, options, callback); - this.open(path, "r", (err, fd) => { - if (err) return callback(err); - if (typeof fd !== "number") - return callback(new Error("fd must be a number")); - customStat( - (path, callback) => this.fstat(fd, callback), - null, - path, - (err, stats) => { - if (err) return callback(err); - if (stats.size > 0 && stats.size < 128 * 1024) { - let remaining = stats.size + 1; - const buffer = Buffer.allocUnsafe(remaining); - const afterRead = (err, bytesRead) => { - if (err) { - return this.close(fd, () => { - callback(err); - }); - } - remaining -= bytesRead; - if (bytesRead === 0 || remaining === 1) { - this.close(fd, err => { - if (err) return callback(err); - return callback( - null, - buffer.slice(0, buffer.length - remaining) - ); - }); - } else if (remaining === 0) { - // The file size has changed from the cached info - // We keep reading until the end is found - let buf = Buffer.allocUnsafe(16 * 1024); - let bufPos = 0; - const buffers = [buffer]; - const afterUnknownRead = (err, bytesRead) => { - if (err) { - return this.close(fd, () => { - callback(err); - }); - } - bufPos += bytesRead; - if (bytesRead === 0) { - if (bufPos > 0) buffers.push(buf.slice(0, bufPos)); - this.close(fd, err => { - if (err) return callback(err); - return callback(null, Buffer.concat(buffers)); - }); - } else { - if (bufPos === buf.length) { - buffers.push(buf); - buf = Buffer.allocUnsafe(16 * 1024); - bufPos = 0; - } - this.read( - fd, - buf, - bufPos, - buf.length - bufPos, - -1, - afterUnknownRead - ); - } - }; - this.read( - fd, - buf, - bufPos, - buf.length - bufPos, - -1, - afterUnknownRead - ); - } else { - this.read( - fd, - buffer, - stats.size - remaining, - remaining + 1, - -1, - afterRead - ); - } - }; - this.read(fd, buffer, 0, remaining, -1, afterRead); - } else { - this.readFile(fd, options, (err, buffer) => { - this.close(fd, closeErr => { - if (err) return callback(err); - if (closeErr) return callback(closeErr); - callback(null, buffer); - }); - }); - } - } - ); - }); - } - : this.fileSystem.readFile, - this.fileSystem.readFileSync && - this.fileSystem.fstatSync && - this.fileSystem.readSync && - this.fileSystem.openSync && - this.fileSystem.closeSync && - customStatSync - ? /** - * @this {{ fstatSync: NonNullable, readFileSync: NonNullable, openSync: NonNullable, readSync: NonNullable, closeSync: NonNullable }} - */ - function (path, options) { - if (typeof options === "object") - return this.readFileSync(path, options); - const fd = this.openSync(path, "r"); - if (typeof fd !== "number") throw new Error("fd must be a number"); - const stats = customStatSync(() => this.fstatSync(fd), null, path); - if (stats.size > 0 && stats.size < 128 * 1024) { - let remaining = stats.size; - const buffer = Buffer.allocUnsafe(remaining); - try { - let bytesRead = this.readSync(fd, buffer, 0, remaining, -1); - remaining -= bytesRead; - while (bytesRead !== 0 && remaining !== 0) { - bytesRead = this.readSync( - fd, - buffer, - stats.size - remaining, - remaining, - -1 - ); - remaining -= bytesRead; - } - return buffer; - } finally { - this.closeSync(fd); - } - } else { - const buffer = this.readFileSync(fd); - this.closeSync(fd); - return buffer; - } - } - : this.fileSystem.readFileSync, + this.fileSystem.readFile, + this.fileSystem.readFileSync, this.fileSystem ); const readFile = this._readFileBackend.provide; @@ -131829,11 +131589,7 @@ const { /** * @typedef {Object} FileSystem - * @property {(function(string | number, FileSystemCallback): void) & function(string | number, object, FileSystemCallback): void} readFile - * @property {(function(string, string | number, FileSystemCallback): void) & function(string, string | number, string | number, FileSystemCallback): void=} open - * @property {(function(number, FileSystemCallback): void) & function(number, object, FileSystemCallback): void=} fstat - * @property {function(number, Buffer | Uint8Array, number, number, number, function(PossibleFileSystemError & Error | null | undefined, number=): void): void=} read - * @property {function(number, function(PossibleFileSystemError & Error | null | undefined): void): void=} close + * @property {(function(string, FileSystemCallback): void) & function(string, object, FileSystemCallback): void} readFile * @property {(function(string, FileSystemCallback<(Buffer | string)[] | FileSystemDirent[]>): void) & function(string, object, FileSystemCallback<(Buffer | string)[] | FileSystemDirent[]>): void} readdir * @property {((function(string, FileSystemCallback): void) & function(string, object, FileSystemCallback): void)=} readJson * @property {(function(string, FileSystemCallback): void) & function(string, object, FileSystemCallback): void} readlink @@ -131843,11 +131599,7 @@ const { /** * @typedef {Object} SyncFileSystem - * @property {function(string | number, object=): Buffer | string} readFileSync - * @property {function(string, string | number, string | number=): number=} openSync - * @property {function(number, object=): FileSystemStats=} fstatSync - * @property {function(number, Buffer | Uint8Array, number, number, number): number=} readSync - * @property {function(number): void=} closeSync + * @property {function(string, object=): Buffer | string} readFileSync * @property {function(string, object=): (Buffer | string)[] | FileSystemDirent[]} readdirSync * @property {(function(string, object=): object)=} readJsonSync * @property {function(string, object=): Buffer | string} readlinkSync diff --git a/test/integration/font-optimization/fixtures/with-google/manifest-snapshot.json b/test/integration/font-optimization/fixtures/with-google/manifest-snapshot.json index c0ffadb9fa779ec..0ccaf464125cb8c 100644 --- a/test/integration/font-optimization/fixtures/with-google/manifest-snapshot.json +++ b/test/integration/font-optimization/fixtures/with-google/manifest-snapshot.json @@ -1,11 +1,11 @@ [ { "url": "https://fonts.googleapis.com/css?family=Voces", - "content": "@font-face{font-family:'Voces';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/voces/v15/-F6_fjJyLyU8d7PGDmk.woff) format('woff')}@font-face{font-family:'Voces';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/voces/v15/-F6_fjJyLyU8d7PIDm_6pClI_ik.woff2) format('woff2');unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:'Voces';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/voces/v15/-F6_fjJyLyU8d7PGDm_6pClI.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}" + "content": "@font-face{font-family:'Voces';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/voces/v18/-F6_fjJyLyU8d7PGDmk.woff) format('woff')}@font-face{font-family:'Voces';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/voces/v18/-F6_fjJyLyU8d7PIDm_6pClI_ik.woff2) format('woff2');unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:'Voces';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/voces/v18/-F6_fjJyLyU8d7PGDm_6pClI.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}" }, { "url": "https://fonts.googleapis.com/css2?family=Modak", - "content": "@font-face{font-family:'Modak';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/modak/v8/EJRYQgs1XtIEsnME.woff) format('woff')}@font-face{font-family:'Modak';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/modak/v8/EJRYQgs1XtIEskMB-hR77LKVTy8.woff2) format('woff2');unicode-range:U+0900-097F,U+1CD0-1CF6,U+1CF8-1CF9,U+200C-200D,U+20A8,U+20B9,U+25CC,U+A830-A839,U+A8E0-A8FB}@font-face{font-family:'Modak';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/modak/v8/EJRYQgs1XtIEskMO-hR77LKVTy8.woff2) format('woff2');unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:'Modak';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/modak/v8/EJRYQgs1XtIEskMA-hR77LKV.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}" + "content": "@font-face{font-family:'Modak';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/modak/v16/EJRYQgs1XtIEsnME.woff) format('woff')}@font-face{font-family:'Modak';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/modak/v16/EJRYQgs1XtIEskMB-hR77LKVTy8.woff2) format('woff2');unicode-range:U+0900-097F,U+1CD0-1CF6,U+1CF8-1CF9,U+200C-200D,U+20A8,U+20B9,U+25CC,U+A830-A839,U+A8E0-A8FB}@font-face{font-family:'Modak';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/modak/v16/EJRYQgs1XtIEskMO-hR77LKVTy8.woff2) format('woff2');unicode-range:U+0100-024F,U+0259,U+1E00-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:'Modak';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/modak/v16/EJRYQgs1XtIEskMA-hR77LKV.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}" }, { "url": "https://fonts.googleapis.com/css2?family=Roboto:wght@700", diff --git a/yarn.lock b/yarn.lock index e11c7c225f34bdb..2667122b971e85e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8809,7 +8809,8 @@ enhanced-resolve@^4.3.0: enhanced-resolve@^5.8.3: version "5.8.3" - resolved "https://codeload.github.com/webpack/enhanced-resolve/tar.gz/a7c161eeb141bfc7fda375df36c13df006a8cf76" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.3.tgz#6d552d465cce0423f5b3d718511ea53826a7b2f0" + integrity sha512-EGAbGvH7j7Xt2nc0E7D99La1OiEs8LnyimkRgwExpUMScN6O+3x9tIWs7PLQZVNx4YD+00skHXPXi1yQHpAmZA== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0"