code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
unsortedForEach(aCallback, aThisArg) {
this._array.forEach(aCallback, aThisArg);
} | Iterate through internal items. This method takes the same arguments that
`Array.prototype.forEach` takes.
NOTE: The order of the mappings is NOT guaranteed. | unsortedForEach | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
add(aMapping) {
if (generatedPositionAfter(this._last, aMapping)) {
this._last = aMapping;
this._array.push(aMapping);
} else {
this._sorted = false;
this._array.push(aMapping);
}
} | Add the given source mapping.
@param Object aMapping | add | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
toArray() {
if (!this._sorted) {
this._array.sort(util.compareByGeneratedPositionsInflated);
this._sorted = true;
}
return this._array;
} | Returns the flat, sorted array of mappings. The mappings are sorted by
generated position.
WARNING: This method returns internal data without copying, for
performance. The return value must NOT be mutated, and should be treated as
an immutable borrow. If you want to take ownership, you must make your own
copy. | toArray | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
static async with(rawSourceMap, sourceMapUrl, f) {
const consumer = await new SourceMapConsumer(rawSourceMap, sourceMapUrl);
try {
return await f(consumer);
} finally {
consumer.destroy();
}
} | Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
(see the `SourceMapConsumer` constructor for details. Then, invoke the `async
function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
for `f` to complete, call `destroy` on the consumer, and return `f`'s return
value.
You ... | with | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
eachMapping(aCallback, aContext, aOrder) {
throw new Error("Subclasses must implement eachMapping");
} | Iterate over each mapping between an original source/line/column and a
generated line/column in this source map.
@param Function aCallback
The function that is called with each mapping.
@param Object aContext
Optional. If specified, this object will be the value of `this` every
time that `aCallbac... | eachMapping | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
allGeneratedPositionsFor(aArgs) {
throw new Error("Subclasses must implement allGeneratedPositionsFor");
} | Returns all generated line and column information for the original source,
line, and column provided. If no column is provided, returns all mappings
corresponding to a either the line we are searching for or the next
closest line that has any mappings. Otherwise, returns all mappings
corresponding to the given line and... | allGeneratedPositionsFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
destroy() {
throw new Error("Subclasses must implement destroy");
} | Returns all generated line and column information for the original source,
line, and column provided. If no column is provided, returns all mappings
corresponding to a either the line we are searching for or the next
closest line that has any mappings. Otherwise, returns all mappings
corresponding to the given line and... | destroy | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
constructor(aSourceMap, aSourceMapURL) {
return super(INTERNAL).then(that => {
let sourceMap = aSourceMap;
if (typeof aSourceMap === "string") {
sourceMap = util.parseSourceMapInput(aSourceMap);
}
const version = util.getArg(sourceMap, "version");
const sources = util.getArg(s... | A BasicSourceMapConsumer instance represents a parsed source map which we can
query for information about the original file positions by giving it a file
position in the generated source.
The first parameter is the raw source map (either as a JSON string, or
already parsed to an object). According to the spec, source ... | constructor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
_findSourceIndex(aSource) {
// In the most common usecases, we'll be constantly looking up the index for the same source
// files, so we cache the index lookup to avoid constantly recomputing the full URLs.
const cachedIndex = this._sourceLookupCache.get(aSource);
if (typeof cachedIndex === "number") {
... | Utility function to find the index of a source. Returns -1 if not
found. | _findSourceIndex | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
static fromSourceMap(aSourceMap, aSourceMapURL) {
return new BasicSourceMapConsumer(aSourceMap.toString());
} | Create a BasicSourceMapConsumer from a SourceMapGenerator.
@param SourceMapGenerator aSourceMap
The source map that will be consumed.
@param String aSourceMapURL
The URL at which the source map can be found (optional)
@returns BasicSourceMapConsumer | fromSourceMap | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
get sources() {
return this._absoluteSources.toArray();
} | Create a BasicSourceMapConsumer from a SourceMapGenerator.
@param SourceMapGenerator aSourceMap
The source map that will be consumed.
@param String aSourceMapURL
The URL at which the source map can be found (optional)
@returns BasicSourceMapConsumer | sources | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
_getMappingsPtr() {
if (this._mappingsPtr === 0) {
this._parseMappings();
}
return this._mappingsPtr;
} | Create a BasicSourceMapConsumer from a SourceMapGenerator.
@param SourceMapGenerator aSourceMap
The source map that will be consumed.
@param String aSourceMapURL
The URL at which the source map can be found (optional)
@returns BasicSourceMapConsumer | _getMappingsPtr | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
_parseMappings() {
const aStr = this._mappings;
const size = aStr.length;
const mappingsBufPtr = this._wasm.exports.allocate_mappings(size);
const mappingsBuf = new Uint8Array(this._wasm.exports.memory.buffer, mappingsBufPtr, size);
for (let i = 0; i < size; i++) {
mappingsBuf[i] = aStr.charC... | Parse the mappings in a string in to a data structure which we can easily
query (the ordered arrays in the `this.__generatedMappings` and
`this.__originalMappings` properties). | _parseMappings | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
eachMapping(aCallback, aContext, aOrder) {
const context = aContext || null;
const order = aOrder || SourceMapConsumer.GENERATED_ORDER;
this._wasm.withMappingCallback(
mapping => {
if (mapping.source !== null) {
mapping.source = this._absoluteSources.at(mapping.source);
i... | Parse the mappings in a string in to a data structure which we can easily
query (the ordered arrays in the `this.__generatedMappings` and
`this.__originalMappings` properties). | eachMapping | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
allGeneratedPositionsFor(aArgs) {
let source = util.getArg(aArgs, "source");
const originalLine = util.getArg(aArgs, "line");
const originalColumn = aArgs.column || 0;
source = this._findSourceIndex(source);
if (source < 0) {
return [];
}
if (originalLine < 1) {
throw new Error... | Parse the mappings in a string in to a data structure which we can easily
query (the ordered arrays in the `this.__generatedMappings` and
`this.__originalMappings` properties). | allGeneratedPositionsFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
destroy() {
if (this._mappingsPtr !== 0) {
this._wasm.exports.free_mappings(this._mappingsPtr);
this._mappingsPtr = 0;
}
} | Parse the mappings in a string in to a data structure which we can easily
query (the ordered arrays in the `this.__generatedMappings` and
`this.__originalMappings` properties). | destroy | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
computeColumnSpans() {
if (this._computedColumnSpans) {
return;
}
this._wasm.exports.compute_column_spans(this._getMappingsPtr());
this._computedColumnSpans = true;
} | Compute the last column for each generated mapping. The last column is
inclusive. | computeColumnSpans | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
originalPositionFor(aArgs) {
const needle = {
generatedLine: util.getArg(aArgs, "line"),
generatedColumn: util.getArg(aArgs, "column")
};
if (needle.generatedLine < 1) {
throw new Error("Line numbers must be >= 1");
}
if (needle.generatedColumn < 0) {
throw new Error("Colum... | Returns the original source, line, and column information for the generated
source's line and column positions provided. The only argument is an object
with the following properties:
- line: The line number in the generated source. The line number
is 1-based.
- column: The column number in the generated sourc... | originalPositionFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
hasContentsOfAllSources() {
if (!this.sourcesContent) {
return false;
}
return this.sourcesContent.length >= this._sources.size() &&
!this.sourcesContent.some(function(sc) { return sc == null; });
} | Return true if we have the source content for every source in the source
map, false otherwise. | hasContentsOfAllSources | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
sourceContentFor(aSource, nullOnMissing) {
if (!this.sourcesContent) {
return null;
}
const index = this._findSourceIndex(aSource);
if (index >= 0) {
return this.sourcesContent[index];
}
// This function is used recursively from
// IndexedSourceMapConsumer.prototype.sourceConte... | Returns the original source content. The only argument is the url of the
original source file. Returns null if no original source content is
available. | sourceContentFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
generatedPositionFor(aArgs) {
let source = util.getArg(aArgs, "source");
source = this._findSourceIndex(source);
if (source < 0) {
return {
line: null,
column: null,
lastColumn: null
};
}
const needle = {
source,
originalLine: util.getArg(aArgs, "line... | Returns the generated line and column information for the original source,
line, and column positions provided. The only argument is an object with
the following properties:
- source: The filename of the original source.
- line: The line number in the original source. The line number
is 1-based.
- column: T... | generatedPositionFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
originalPositionFor(aArgs) {
const needle = {
generatedLine: util.getArg(aArgs, "line"),
generatedColumn: util.getArg(aArgs, "column")
};
// Find the section containing the generated position we're trying to map
// to an original position.
const sectionIndex = binarySearch.search(needle... | Returns the original source, line, and column information for the generated
source's line and column positions provided. The only argument is an object
with the following properties:
- line: The line number in the generated source. The line number
is 1-based.
- column: The column number in the generated sourc... | originalPositionFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
hasContentsOfAllSources() {
return this._sections.every(function(s) {
return s.consumer.hasContentsOfAllSources();
});
} | Return true if we have the source content for every source in the source
map, false otherwise. | hasContentsOfAllSources | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
sourceContentFor(aSource, nullOnMissing) {
for (let i = 0; i < this._sections.length; i++) {
const section = this._sections[i];
const content = section.consumer.sourceContentFor(aSource, true);
if (content) {
return content;
}
}
if (nullOnMissing) {
return null;
}
... | Returns the original source content. The only argument is the url of the
original source file. Returns null if no original source content is
available. | sourceContentFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
_findSectionIndex(source) {
for (let i = 0; i < this._sections.length; i++) {
const { consumer } = this._sections[i];
if (consumer._findSourceIndex(source) !== -1) {
return i;
}
}
return -1;
} | Returns the original source content. The only argument is the url of the
original source file. Returns null if no original source content is
available. | _findSectionIndex | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
generatedPositionFor(aArgs) {
const index = this._findSectionIndex(util.getArg(aArgs, "source"));
const section = index >= 0 ? this._sections[index] : null;
const nextSection =
index >= 0 && index + 1 < this._sections.length
? this._sections[index + 1]
: null;
const generatedPosit... | Returns the generated line and column information for the original source,
line, and column positions provided. The only argument is an object with
the following properties:
- source: The filename of the original source.
- line: The line number in the original source. The line number
is 1-based.
- column: T... | generatedPositionFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
allGeneratedPositionsFor(aArgs) {
const index = this._findSectionIndex(util.getArg(aArgs, "source"));
const section = index >= 0 ? this._sections[index] : null;
const nextSection =
index >= 0 && index + 1 < this._sections.length
? this._sections[index + 1]
: null;
if (!section) re... | Returns the generated line and column information for the original source,
line, and column positions provided. The only argument is an object with
the following properties:
- source: The filename of the original source.
- line: The line number in the original source. The line number
is 1-based.
- column: T... | allGeneratedPositionsFor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
eachMapping(aCallback, aContext, aOrder) {
this._sections.forEach((section, index) => {
const nextSection =
index + 1 < this._sections.length
? this._sections[index + 1]
: null;
const { generatedOffset } = section;
const lineShift = generatedOffset.generatedLine - 1;
... | Returns the generated line and column information for the original source,
line, and column positions provided. The only argument is an object with
the following properties:
- source: The filename of the original source.
- line: The line number in the original source. The line number
is 1-based.
- column: T... | eachMapping | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
computeColumnSpans() {
for (let i = 0; i < this._sections.length; i++) {
this._sections[i].consumer.computeColumnSpans();
}
} | Returns the generated line and column information for the original source,
line, and column positions provided. The only argument is an object with
the following properties:
- source: The filename of the original source.
- line: The line number in the original source. The line number
is 1-based.
- column: T... | computeColumnSpans | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
destroy() {
for (let i = 0; i < this._sections.length; i++) {
this._sections[i].consumer.destroy();
}
} | Returns the generated line and column information for the original source,
line, and column positions provided. The only argument is an object with
the following properties:
- source: The filename of the original source.
- line: The line number in the original source. The line number
is 1-based.
- column: T... | destroy | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function _factory(aSourceMap, aSourceMapURL) {
let sourceMap = aSourceMap;
if (typeof aSourceMap === "string") {
sourceMap = util.parseSourceMapInput(aSourceMap);
}
const consumer = sourceMap.sections != null
? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL)
: new BasicSourceMapConsumer(... | Returns the generated line and column information for the original source,
line, and column positions provided. The only argument is an object with
the following properties:
- source: The filename of the original source.
- line: The line number in the original source. The line number
is 1-based.
- column: T... | _factory | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function _factoryBSM(aSourceMap, aSourceMapURL) {
return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
} | Returns the generated line and column information for the original source,
line, and column positions provided. The only argument is an object with
the following properties:
- source: The filename of the original source.
- line: The line number in the original source. The line number
is 1-based.
- column: T... | _factoryBSM | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
constructor(aArgs) {
if (!aArgs) {
aArgs = {};
}
this._file = util.getArg(aArgs, "file", null);
this._sourceRoot = util.getArg(aArgs, "sourceRoot", null);
this._skipValidation = util.getArg(aArgs, "skipValidation", false);
this._sources = new ArraySet();
this._names = new ArraySet();
... | An instance of the SourceMapGenerator represents a source map which is
being built incrementally. You may pass an object with the following
properties:
- file: The filename of the generated source.
- sourceRoot: A root for all relative URLs in this source map. | constructor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
static fromSourceMap(aSourceMapConsumer) {
const sourceRoot = aSourceMapConsumer.sourceRoot;
const generator = new SourceMapGenerator({
file: aSourceMapConsumer.file,
sourceRoot
});
aSourceMapConsumer.eachMapping(function(mapping) {
const newMapping = {
generated: {
l... | Creates a new SourceMapGenerator based on a SourceMapConsumer
@param aSourceMapConsumer The SourceMap. | fromSourceMap | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
addMapping(aArgs) {
const generated = util.getArg(aArgs, "generated");
const original = util.getArg(aArgs, "original", null);
let source = util.getArg(aArgs, "source", null);
let name = util.getArg(aArgs, "name", null);
if (!this._skipValidation) {
this._validateMapping(generated, original, s... | Add a single mapping from original source line and column to the generated
source's line and column for this source map being created. The mapping
object should have the following properties:
- generated: An object with the generated line and column positions.
- original: An object with the original line and colum... | addMapping | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
setSourceContent(aSourceFile, aSourceContent) {
let source = aSourceFile;
if (this._sourceRoot != null) {
source = util.relative(this._sourceRoot, source);
}
if (aSourceContent != null) {
// Add the source content to the _sourcesContents map.
// Create a new _sourcesContents map if th... | Set the source content for a source file. | setSourceContent | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
_validateMapping(aGenerated, aOriginal, aSource, aName) {
// When aOriginal is truthy but has empty values for .line and .column,
// it is most likely a programmer error. In this case we throw a very
// specific error message to try to guide them the right way.
// For example: https://github.com/Polymer... | A mapping can have one of the three levels of data:
1. Just the generated position.
2. The Generated position, original position, and original source.
3. Generated and original position, original source, as well as a name
token.
To maintain consistency, we validate that any new mapping being added falls
in... | _validateMapping | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
_serializeMappings() {
let previousGeneratedColumn = 0;
let previousGeneratedLine = 1;
let previousOriginalColumn = 0;
let previousOriginalLine = 0;
let previousName = 0;
let previousSource = 0;
let result = "";
let next;
let mapping;
let nameIdx;
let sourceIdx;
const ma... | Serialize the accumulated mappings in to the stream of base 64 VLQs
specified by the source map format. | _serializeMappings | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
_generateSourcesContent(aSources, aSourceRoot) {
return aSources.map(function(source) {
if (!this._sourcesContents) {
return null;
}
if (aSourceRoot != null) {
source = util.relative(aSourceRoot, source);
}
const key = util.toSetString(source);
return Object.proto... | Serialize the accumulated mappings in to the stream of base 64 VLQs
specified by the source map format. | _generateSourcesContent | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
toString() {
return JSON.stringify(this.toJSON());
} | Render the source map being generated to a string. | toString | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
constructor(aLine, aColumn, aSource, aChunks, aName) {
this.children = [];
this.sourceContents = {};
this.line = aLine == null ? null : aLine;
this.column = aColumn == null ? null : aColumn;
this.source = aSource == null ? null : aSource;
this.name = aName == null ? null : aName;
this[isSour... | SourceNodes provide a way to abstract over interpolating/concatenating
snippets of generated JavaScript source code while maintaining the line and
column information associated with the original source code.
@param aLine The original line number.
@param aColumn The original column number.
@param aSource The original s... | constructor | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
static fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
// The SourceNode we want to fill with the generated code
// and the SourceMap
const node = new SourceNode();
// All even indices of this array are one line of the generated code,
// while all odd indices are the ne... | Creates a SourceNode from generated code and a SourceMapConsumer.
@param aGeneratedCode The generated code
@param aSourceMapConsumer The SourceMap for the generated code
@param aRelativePath Optional. The path that relative sources in the
SourceMapConsumer should be relative to. | fromStringWithSourceMap | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
shiftNextLine = function() {
const lineContents = getNextLine();
// The last line of a file might not have a newline.
const newLine = getNextLine() || "";
return lineContents + newLine;
function getNextLine() {
return remainingLinesIndex < remainingLines.length ?
remai... | Creates a SourceNode from generated code and a SourceMapConsumer.
@param aGeneratedCode The generated code
@param aSourceMapConsumer The SourceMap for the generated code
@param aRelativePath Optional. The path that relative sources in the
SourceMapConsumer should be relative to. | shiftNextLine | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
shiftNextLine = function() {
const lineContents = getNextLine();
// The last line of a file might not have a newline.
const newLine = getNextLine() || "";
return lineContents + newLine;
function getNextLine() {
return remainingLinesIndex < remainingLines.length ?
remai... | Creates a SourceNode from generated code and a SourceMapConsumer.
@param aGeneratedCode The generated code
@param aSourceMapConsumer The SourceMap for the generated code
@param aRelativePath Optional. The path that relative sources in the
SourceMapConsumer should be relative to. | shiftNextLine | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function getNextLine() {
return remainingLinesIndex < remainingLines.length ?
remainingLines[remainingLinesIndex++] : undefined;
} | Creates a SourceNode from generated code and a SourceMapConsumer.
@param aGeneratedCode The generated code
@param aSourceMapConsumer The SourceMap for the generated code
@param aRelativePath Optional. The path that relative sources in the
SourceMapConsumer should be relative to. | getNextLine | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function addMappingWithCode(mapping, code) {
if (mapping === null || mapping.source === undefined) {
node.add(code);
} else {
const source = aRelativePath
? util.join(aRelativePath, mapping.source)
: mapping.source;
node.add(new SourceNode(mapping.originalLine,
... | Creates a SourceNode from generated code and a SourceMapConsumer.
@param aGeneratedCode The generated code
@param aSourceMapConsumer The SourceMap for the generated code
@param aRelativePath Optional. The path that relative sources in the
SourceMapConsumer should be relative to. | addMappingWithCode | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
add(aChunk) {
if (Array.isArray(aChunk)) {
aChunk.forEach(function(chunk) {
this.add(chunk);
}, this);
} else if (aChunk[isSourceNode] || typeof aChunk === "string") {
if (aChunk) {
this.children.push(aChunk);
}
} else {
throw new TypeError(
"Expected a ... | Add a chunk of generated JS to this source node.
@param aChunk A string snippet of generated JS code, another instance of
SourceNode, or an array where each member is one of those things. | add | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
prepend(aChunk) {
if (Array.isArray(aChunk)) {
for (let i = aChunk.length - 1; i >= 0; i--) {
this.prepend(aChunk[i]);
}
} else if (aChunk[isSourceNode] || typeof aChunk === "string") {
this.children.unshift(aChunk);
} else {
throw new TypeError(
"Expected a SourceNod... | Add a chunk of generated JS to the beginning of this source node.
@param aChunk A string snippet of generated JS code, another instance of
SourceNode, or an array where each member is one of those things. | prepend | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
walk(aFn) {
let chunk;
for (let i = 0, len = this.children.length; i < len; i++) {
chunk = this.children[i];
if (chunk[isSourceNode]) {
chunk.walk(aFn);
} else if (chunk !== "") {
aFn(chunk, { source: this.source,
line: this.line,
col... | Walk over the tree of JS snippets in this node and its children. The
walking function is called once for each snippet of JS and is passed that
snippet and the its original associated source's line/column location.
@param aFn The traversal function. | walk | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
join(aSep) {
let newChildren;
let i;
const len = this.children.length;
if (len > 0) {
newChildren = [];
for (i = 0; i < len - 1; i++) {
newChildren.push(this.children[i]);
newChildren.push(aSep);
}
newChildren.push(this.children[i]);
this.children = newChild... | Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
each of `this.children`.
@param aSep The separator. | join | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
replaceRight(aPattern, aReplacement) {
const lastChild = this.children[this.children.length - 1];
if (lastChild[isSourceNode]) {
lastChild.replaceRight(aPattern, aReplacement);
} else if (typeof lastChild === "string") {
this.children[this.children.length - 1] = lastChild.replace(aPattern, aRepl... | Call String.prototype.replace on the very right-most source snippet. Useful
for trimming whitespace from the end of a source node, etc.
@param aPattern The pattern to replace.
@param aReplacement The thing to replace the pattern with. | replaceRight | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
setSourceContent(aSourceFile, aSourceContent) {
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
} | Set the source content for a source file. This will be added to the SourceMapGenerator
in the sourcesContent field.
@param aSourceFile The filename of the source file
@param aSourceContent The content of the source file | setSourceContent | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
walkSourceContents(aFn) {
for (let i = 0, len = this.children.length; i < len; i++) {
if (this.children[i][isSourceNode]) {
this.children[i].walkSourceContents(aFn);
}
}
const sources = Object.keys(this.sourceContents);
for (let i = 0, len = sources.length; i < len; i++) {
aFn... | Walk over the tree of SourceNodes. The walking function is called for each
source file content and is passed the filename and source content.
@param aFn The traversal function. | walkSourceContents | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
toString() {
let str = "";
this.walk(function(chunk) {
str += chunk;
});
return str;
} | Return the string representation of this source node. Walks over the tree
and concatenates all the various snippets together to one string. | toString | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
toStringWithSourceMap(aArgs) {
const generated = {
code: "",
line: 1,
column: 0
};
const map = new SourceMapGenerator(aArgs);
let sourceMappingActive = false;
let lastOriginalSource = null;
let lastOriginalLine = null;
let lastOriginalColumn = null;
let lastOriginalName... | Returns the string representation of this source node along with a source
map. | toStringWithSourceMap | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function getArg(aArgs, aName, aDefaultValue) {
if (aName in aArgs) {
return aArgs[aName];
} else if (arguments.length === 3) {
return aDefaultValue;
}
throw new Error('"' + aName + '" is a required argument.');
} | This is a helper function for getting values from parameter/options
objects.
@param args The object we are extracting values from
@param name The name of the property we are getting.
@param defaultValue An optional value to return if the property is missing
from the object. If this is not specified and the property is... | getArg | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function identity(s) {
return s;
} | This is a helper function for getting values from parameter/options
objects.
@param args The object we are extracting values from
@param name The name of the property we are getting.
@param defaultValue An optional value to return if the property is missing
from the object. If this is not specified and the property is... | identity | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function compareByGeneratedPositionsInflated(mappingA, mappingB) {
let cmp = mappingA.generatedLine - mappingB.generatedLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
if (cmp !== 0) {
return cmp;
}
cmp = strcmp(mappingA.source, mappingB.source);
... | Comparator between two mappings with inflated source and name strings where
the generated positions are compared. | compareByGeneratedPositionsInflated | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function parseSourceMapInput(str) {
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
} | Strip any JSON XSSI avoidance prefix from the string (as documented
in the source maps specification), and then parse the string as
JSON. | parseSourceMapInput | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function createSafeHandler(cb) {
return input => {
const type = getURLType(input);
const base = buildSafeBase(input);
const url = new URL(input, base);
cb(url);
const result = url.toString();
if (type === "absolute") {
return result;
} else if (type === "scheme-relative") {
... | Make it easy to create small utilities that tweak a URL's path. | createSafeHandler | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function withBase(url, base) {
return new URL(url, base).toString();
} | Make it easy to create small utilities that tweak a URL's path. | withBase | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function buildUniqueSegment(prefix, str) {
let id = 0;
do {
const ident = prefix + (id++);
if (str.indexOf(ident) === -1) return ident;
} while (true);
} | Make it easy to create small utilities that tweak a URL's path. | buildUniqueSegment | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function buildSafeBase(str) {
const maxDotParts = str.split("..").length - 1;
// If we used a segment that also existed in `str`, then we would be unable
// to compute relative paths. For example, if `segment` were just "a":
//
// const url = "../../a/"
// const base = buildSafeBase(url); // http://hos... | Make it easy to create small utilities that tweak a URL's path. | buildSafeBase | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function getURLType(url) {
if (url[0] === "/") {
if (url[1] === "/") return "scheme-relative";
return "path-absolute";
}
return ABSOLUTE_SCHEME.test(url) ? "absolute" : "path-relative";
} | Make it easy to create small utilities that tweak a URL's path. | getURLType | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function computeRelativeURL(rootURL, targetURL) {
if (typeof rootURL === "string") rootURL = new URL(rootURL);
if (typeof targetURL === "string") targetURL = new URL(targetURL);
const targetParts = targetURL.pathname.split("/");
const rootParts = rootURL.pathname.split("/");
// If we've got a URL path endin... | Given two URLs that are assumed to be on the same
protocol/host/user/password build a relative URL from the
path, params, and hash values.
@param rootURL The root URL that the target will be relative to.
@param targetURL The target that the relative URL points to.
@return A rootURL-relative, normalized URL value. | computeRelativeURL | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function join(aRoot, aPath) {
const pathType = getURLType(aPath);
const rootType = getURLType(aRoot);
aRoot = ensureDirectory(aRoot);
if (pathType === "absolute") {
return withBase(aPath, undefined);
}
if (rootType === "absolute") {
return withBase(aPath, aRoot);
}
if (pathType === "scheme-re... | Joins two paths/URLs.
All returned URLs will be normalized.
@param aRoot The root path or URL. Assumed to reference a directory.
@param aPath The path or URL to be joined with the root.
@return A joined and normalized URL value. | join | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function relative(rootURL, targetURL) {
const result = relativeIfPossible(rootURL, targetURL);
return typeof result === "string" ? result : normalize(targetURL);
} | Make a path relative to a URL or another path. If returning a
relative URL is not possible, the original target will be returned.
All returned URLs will be normalized.
@param aRoot The root path or URL.
@param aPath The path or URL to be made relative to aRoot.
@return A rootURL-relative (if possible), normalized URL ... | relative | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function relativeIfPossible(rootURL, targetURL) {
const urlType = getURLType(rootURL);
if (urlType !== getURLType(targetURL)) {
return null;
}
const base = buildSafeBase(rootURL + targetURL);
const root = new URL(rootURL, base);
const target = new URL(targetURL, base);
try {
new URL("", target.t... | Make a path relative to a URL or another path. If returning a
relative URL is not possible, the original target will be returned.
All returned URLs will be normalized.
@param aRoot The root path or URL.
@param aPath The path or URL to be made relative to aRoot.
@return A rootURL-relative (if possible), normalized URL ... | relativeIfPossible | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
// The source map spec states that "sourceRoot" and "sources" entries are to be appended. While
// that is a little vague, implementations have generally interpreted that as joining the
// URLs with a `/` between then, assuming the "sourceRoot" does... | Compute the URL of a source given the the source root, the source's
URL, and the source map's URL. | computeSourceURL | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
function Mapping() {
this.generatedLine = 0;
this.generatedColumn = 0;
this.lastGeneratedColumn = null;
this.source = null;
this.originalLine = null;
this.originalColumn = null;
this.name = null;
} | Provide the JIT with a nice shape / hidden class. | Mapping | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
mapping_callback(
generatedLine,
generatedColumn,
hasLastGeneratedColumn,
lastGeneratedColumn,
hasOriginal,
source,
originalLine,
originalColumn,
hasName,
name
) {
const mappi... | Provide the JIT with a nice shape / hidden class. | mapping_callback | javascript | vercel/next.js | packages/next/src/compiled/source-map08/source-map.js | https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/source-map08/source-map.js | MIT |
constructor(options = {}) {
this.options = {
shouldIgnorePath: options.shouldIgnorePath ?? defaultShouldIgnorePath,
isSourceMapAsset: options.isSourceMapAsset ?? defaultIsSourceMapAsset,
}
} | This plugin adds a field to source maps that identifies which sources are
vendored or runtime-injected (aka third-party) sources. These are consumed by
Chrome DevTools to automatically ignore-list sources. | constructor | javascript | vercel/next.js | packages/next/webpack-plugins/devtools-ignore-list-plugin.js | https://github.com/vercel/next.js/blob/master/packages/next/webpack-plugins/devtools-ignore-list-plugin.js | MIT |
apply(compiler) {
const { RawSource } = compiler.webpack.sources
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.processAssets.tap(
{
name: PLUGIN_NAME,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING,
additionalAssets: tru... | This plugin adds a field to source maps that identifies which sources are
vendored or runtime-injected (aka third-party) sources. These are consumed by
Chrome DevTools to automatically ignore-list sources. | apply | javascript | vercel/next.js | packages/next/webpack-plugins/devtools-ignore-list-plugin.js | https://github.com/vercel/next.js/blob/master/packages/next/webpack-plugins/devtools-ignore-list-plugin.js | MIT |
function loader(value, bindings, callback) {
const defaults = this.sourceMap ? { SourceMapGenerator } : {}
const options = this.getOptions()
const config = { ...defaults, ...options }
const hash = getOptionsHash(options)
const compiler = this._compiler || marker
let map = cache.get(compiler)
if (!map) {... | A webpack loader for mdx-rs. This is largely based on existing @mdx-js/loader,
replaces internal compilation logic to use mdx-rs instead. | loader | javascript | vercel/next.js | packages/next-mdx/mdx-rs-loader.js | https://github.com/vercel/next.js/blob/master/packages/next-mdx/mdx-rs-loader.js | MIT |
function getOptionsHash(options) {
const hash = createHash('sha256')
let key
for (key in options) {
if (own.call(options, key)) {
const value = options[key]
if (value !== undefined) {
const valueString = JSON.stringify(value)
hash.update(key + valueString)
}
}
}
re... | A webpack loader for mdx-rs. This is largely based on existing @mdx-js/loader,
replaces internal compilation logic to use mdx-rs instead. | getOptionsHash | javascript | vercel/next.js | packages/next-mdx/mdx-rs-loader.js | https://github.com/vercel/next.js/blob/master/packages/next-mdx/mdx-rs-loader.js | MIT |
function createFormatAwareProcessors(bindings, compileOptions = {}) {
const mdExtensions = compileOptions.mdExtensions || md
const mdxExtensions = compileOptions.mdxExtensions || mdx
let cachedMarkdown
let cachedMdx
return {
extnames:
compileOptions.format === 'md'
? mdExtensions
:... | A webpack loader for mdx-rs. This is largely based on existing @mdx-js/loader,
replaces internal compilation logic to use mdx-rs instead. | createFormatAwareProcessors | javascript | vercel/next.js | packages/next-mdx/mdx-rs-loader.js | https://github.com/vercel/next.js/blob/master/packages/next-mdx/mdx-rs-loader.js | MIT |
function compile({ value, path: p }) {
const format =
compileOptions.format === 'md' || compileOptions.format === 'mdx'
? compileOptions.format
: path.extname(p) &&
(compileOptions.mdExtensions || md).includes(path.extname(p))
? 'md'
: 'mdx'
const options =... | A webpack loader for mdx-rs. This is largely based on existing @mdx-js/loader,
replaces internal compilation logic to use mdx-rs instead. | compile | javascript | vercel/next.js | packages/next-mdx/mdx-rs-loader.js | https://github.com/vercel/next.js/blob/master/packages/next-mdx/mdx-rs-loader.js | MIT |
async function getSchedulerVersion(reactVersion) {
const url = `https://registry.npmjs.org/react-dom/${reactVersion}`
const response = await fetch(url, {
headers: {
Accept: 'application/json',
},
})
if (!response.ok) {
throw new Error(
`${url}: ${response.status} ${response.statusText}\n... | Set to `null` to automatically sync the React version of Pages Router with App Router React version.
Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
"Active" just refers to our current development practice. While we do support
React 18 in pages router, we don't focus our developmen... | getSchedulerVersion | javascript | vercel/next.js | scripts/sync-react.js | https://github.com/vercel/next.js/blob/master/scripts/sync-react.js | MIT |
async function sync({ channel, newVersionStr, noInstall }) {
const useExperimental = channel === 'experimental'
const cwd = process.cwd()
const pkgJson = JSON.parse(
await fsp.readFile(path.join(cwd, 'package.json'), 'utf-8')
)
const devDependencies = pkgJson.devDependencies
const pnpmOverrides = pkgJso... | Set to `null` to automatically sync the React version of Pages Router with App Router React version.
Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
"Active" just refers to our current development practice. While we do support
React 18 in pages router, we don't focus our developmen... | sync | javascript | vercel/next.js | scripts/sync-react.js | https://github.com/vercel/next.js/blob/master/scripts/sync-react.js | MIT |
function extractInfoFromReactVersion(reactVersion) {
const match = reactVersion.match(
/(?<semverVersion>.*)-(?<releaseLabel>.*)-(?<sha>.*)-(?<dateString>.*)$/
)
return match ? match.groups : null
} | Set to `null` to automatically sync the React version of Pages Router with App Router React version.
Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
"Active" just refers to our current development practice. While we do support
React 18 in pages router, we don't focus our developmen... | extractInfoFromReactVersion | javascript | vercel/next.js | scripts/sync-react.js | https://github.com/vercel/next.js/blob/master/scripts/sync-react.js | MIT |
async function getChangelogFromGitHub(baseSha, newSha) {
const pageSize = 50
let changelog = []
for (let currentPage = 1; ; currentPage++) {
const url = `https://api.github.com/repos/facebook/react/compare/${baseSha}...${newSha}?per_page=${pageSize}&page=${currentPage}`
const headers = {}
// GITHUB_TO... | Set to `null` to automatically sync the React version of Pages Router with App Router React version.
Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
"Active" just refers to our current development practice. While we do support
React 18 in pages router, we don't focus our developmen... | getChangelogFromGitHub | javascript | vercel/next.js | scripts/sync-react.js | https://github.com/vercel/next.js/blob/master/scripts/sync-react.js | MIT |
async function findHighestNPMReactVersion(versionLike) {
const { stdout, stderr } = await execa(
'npm',
['--silent', 'view', '--json', `react@${versionLike}`, 'version'],
{
// Avoid "Usage Error: This project is configured to use pnpm".
cwd: '/tmp',
}
)
if (stderr) {
console.error(... | Set to `null` to automatically sync the React version of Pages Router with App Router React version.
Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
"Active" just refers to our current development practice. While we do support
React 18 in pages router, we don't focus our developmen... | findHighestNPMReactVersion | javascript | vercel/next.js | scripts/sync-react.js | https://github.com/vercel/next.js/blob/master/scripts/sync-react.js | MIT |
async function main() {
const cwd = process.cwd()
const errors = []
const argv = await yargs(process.argv.slice(2))
.version(false)
.options('actor', {
type: 'string',
description:
'Required with `--create-pull`. The actor (GitHub username) that runs this script. Will be used for notif... | Set to `null` to automatically sync the React version of Pages Router with App Router React version.
Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
"Active" just refers to our current development practice. While we do support
React 18 in pages router, we don't focus our developmen... | main | javascript | vercel/next.js | scripts/sync-react.js | https://github.com/vercel/next.js/blob/master/scripts/sync-react.js | MIT |
async function commitEverything(message) {
await execa('git', ['add', '-A'])
await execa('git', [
'commit',
'--message',
message,
'--no-verify',
// Some steps can be empty, e.g. when we don't sync Pages router
'--allow-empty',
])
} | Set to `null` to automatically sync the React version of Pages Router with App Router React version.
Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
"Active" just refers to our current development practice. While we do support
React 18 in pages router, we don't focus our developmen... | commitEverything | javascript | vercel/next.js | scripts/sync-react.js | https://github.com/vercel/next.js/blob/master/scripts/sync-react.js | MIT |
formatUnion = (values) =>
values.map((value) => `"${value}"`).join('|') | This is an autogenerated file by scripts/update-google-fonts.js | formatUnion | javascript | vercel/next.js | scripts/update-google-fonts.js | https://github.com/vercel/next.js/blob/master/scripts/update-google-fonts.js | MIT |
formatUnion = (values) =>
values.map((value) => `"${value}"`).join('|') | This is an autogenerated file by scripts/update-google-fonts.js | formatUnion | javascript | vercel/next.js | scripts/update-google-fonts.js | https://github.com/vercel/next.js/blob/master/scripts/update-google-fonts.js | MIT |
function exec(title, file, args) {
logCommand(title, `${file} ${args.join(' ')}`)
return execa(file, args, {
stderr: 'inherit',
})
} | @param title {string}
@param file {string}
@param args {readonly string[]}
@returns {execa.ExecaChildProcess} | exec | javascript | vercel/next.js | test/update-bundler-manifest.js | https://github.com/vercel/next.js/blob/master/test/update-bundler-manifest.js | MIT |
function logCommand(title, command) {
let message = `\n${bold().underline(title)}\n`
if (command) {
message += `> ${bold(command)}\n`
}
console.log(message)
} | @param {string} title
@param {string} [command] | logCommand | javascript | vercel/next.js | test/update-bundler-manifest.js | https://github.com/vercel/next.js/blob/master/test/update-bundler-manifest.js | MIT |
function accountForOverhead(megaBytes) {
// We are sending {megaBytes} - 5% to account for encoding overhead
return Math.floor(1024 * 1024 * megaBytes * 0.95)
} | This function accounts for the overhead of encoding the data to be sent
over the network via a multipart request.
@param {number} megaBytes
@returns {number} | accountForOverhead | javascript | vercel/next.js | test/e2e/app-dir/actions/account-for-overhead.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/actions/account-for-overhead.js | MIT |
async function middleware(request) {
if (request.nextUrl.pathname === '/searchparams-normalization-bug') {
const headers = new Headers(request.headers)
headers.set('test', request.nextUrl.searchParams.get('val') || '')
const response = NextResponse.next({
request: {
headers,
},
})
... | @param {import('next/server').NextRequest} request
@returns {Promise<NextResponse | undefined>} | middleware | javascript | vercel/next.js | test/e2e/app-dir/app/middleware.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/app/middleware.js | MIT |
async function middleware(request) {
const headersFromRequest = new Headers(request.headers)
// It should be able to import and use `headers` inside middleware
const headersFromNext = await nextHeaders()
headersFromRequest.set('x-from-middleware', 'hello-from-middleware')
// make sure headers() from `next/he... | @param {import('next/server').NextRequest} request | middleware | javascript | vercel/next.js | test/e2e/app-dir/app-middleware/middleware.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/app-middleware/middleware.js | MIT |
function middleware(request) {
if (
request.nextUrl.pathname ===
'/hooks/use-selected-layout-segment/rewritten-middleware'
) {
return NextResponse.rewrite(
new URL(
'/hooks/use-selected-layout-segment/first/slug3/second/catch/all',
request.url
)
)
}
} | @param {import('next/server').NextRequest} request
@returns {NextResponse | undefined} | middleware | javascript | vercel/next.js | test/e2e/app-dir/hooks/middleware.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/hooks/middleware.js | MIT |
function middleware(request) {
const rscQuery = request.nextUrl.searchParams.get(NEXT_RSC_UNION_QUERY)
// Test that the RSC query is not present in the middleware
if (rscQuery) {
throw new Error('RSC query should not be present in the middleware')
}
if (request.nextUrl.pathname === '/redirect-middleware... | @param {import('next/server').NextRequest} request
@returns {NextResponse | undefined} | middleware | javascript | vercel/next.js | test/e2e/app-dir/navigation/middleware.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/navigation/middleware.js | MIT |
get() {
return {
waitUntil(/** @type {Promise<any>} */ promise) {
cliLog('waitUntil from "@next/request-context" was called')
promise.catch((err) => {
console.error(err)
})
},
}
} | @type {import('next/dist/server/after/builtin-request-context').BuiltinRequestContext} | get | javascript | vercel/next.js | test/e2e/app-dir/next-after-app/utils/provided-request-context.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/next-after-app/utils/provided-request-context.js | MIT |
waitUntil(/** @type {Promise<any>} */ promise) {
cliLog('waitUntil from "@next/request-context" was called')
promise.catch((err) => {
console.error(err)
})
} | @type {import('next/dist/server/after/builtin-request-context').BuiltinRequestContext} | waitUntil | javascript | vercel/next.js | test/e2e/app-dir/next-after-app/utils/provided-request-context.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/next-after-app/utils/provided-request-context.js | MIT |
async get(cacheKey, softTags) {
console.log('ModernCustomCacheHandler::get', cacheKey, softTags)
return defaultCacheHandler.get(cacheKey, softTags)
} | @type {import('next/dist/server/lib/cache-handlers/types').CacheHandlerV2} | get | javascript | vercel/next.js | test/e2e/app-dir/use-cache-custom-handler/handler.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/use-cache-custom-handler/handler.js | MIT |
async set(cacheKey, pendingEntry) {
console.log('ModernCustomCacheHandler::set', cacheKey)
return defaultCacheHandler.set(cacheKey, pendingEntry)
} | @type {import('next/dist/server/lib/cache-handlers/types').CacheHandlerV2} | set | javascript | vercel/next.js | test/e2e/app-dir/use-cache-custom-handler/handler.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/use-cache-custom-handler/handler.js | MIT |
async refreshTags() {
console.log('ModernCustomCacheHandler::refreshTags')
return defaultCacheHandler.refreshTags()
} | @type {import('next/dist/server/lib/cache-handlers/types').CacheHandlerV2} | refreshTags | javascript | vercel/next.js | test/e2e/app-dir/use-cache-custom-handler/handler.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/use-cache-custom-handler/handler.js | MIT |
async getExpiration(...tags) {
console.log('ModernCustomCacheHandler::getExpiration', JSON.stringify(tags))
// Expecting soft tags in `get` to be used by the cache handler for checking
// the expiration of a cache entry, instead of letting Next.js handle it.
return Infinity
} | @type {import('next/dist/server/lib/cache-handlers/types').CacheHandlerV2} | getExpiration | javascript | vercel/next.js | test/e2e/app-dir/use-cache-custom-handler/handler.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/use-cache-custom-handler/handler.js | MIT |
async expireTags(...tags) {
console.log('ModernCustomCacheHandler::expireTags', JSON.stringify(tags))
return defaultCacheHandler.expireTags(...tags)
} | @type {import('next/dist/server/lib/cache-handlers/types').CacheHandlerV2} | expireTags | javascript | vercel/next.js | test/e2e/app-dir/use-cache-custom-handler/handler.js | https://github.com/vercel/next.js/blob/master/test/e2e/app-dir/use-cache-custom-handler/handler.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.