latest update in wings
This commit is contained in:
58
build/node_modules/next/dist/trace/index.js
generated
vendored
Normal file
58
build/node_modules/next/dist/trace/index.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
Span: null,
|
||||
SpanStatus: null,
|
||||
exportTraceState: null,
|
||||
flushAllTraces: null,
|
||||
getTraceEvents: null,
|
||||
hrtimeToEpochNanoseconds: null,
|
||||
initializeTraceState: null,
|
||||
recordTraceEvents: null,
|
||||
setGlobal: null,
|
||||
trace: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
Span: function() {
|
||||
return _trace.Span;
|
||||
},
|
||||
SpanStatus: function() {
|
||||
return _trace.SpanStatus;
|
||||
},
|
||||
exportTraceState: function() {
|
||||
return _trace.exportTraceState;
|
||||
},
|
||||
flushAllTraces: function() {
|
||||
return _trace.flushAllTraces;
|
||||
},
|
||||
getTraceEvents: function() {
|
||||
return _trace.getTraceEvents;
|
||||
},
|
||||
hrtimeToEpochNanoseconds: function() {
|
||||
return _trace.hrtimeToEpochNanoseconds;
|
||||
},
|
||||
initializeTraceState: function() {
|
||||
return _trace.initializeTraceState;
|
||||
},
|
||||
recordTraceEvents: function() {
|
||||
return _trace.recordTraceEvents;
|
||||
},
|
||||
setGlobal: function() {
|
||||
return _shared.setGlobal;
|
||||
},
|
||||
trace: function() {
|
||||
return _trace.trace;
|
||||
}
|
||||
});
|
||||
const _trace = require("./trace");
|
||||
const _shared = require("./shared");
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
37
build/node_modules/next/dist/trace/report/index.js
generated
vendored
Normal file
37
build/node_modules/next/dist/trace/report/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "reporter", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return reporter;
|
||||
}
|
||||
});
|
||||
const _totelemetry = /*#__PURE__*/ _interop_require_default(require("./to-telemetry"));
|
||||
const _tojson = /*#__PURE__*/ _interop_require_default(require("./to-json"));
|
||||
const _tojsonbuild = /*#__PURE__*/ _interop_require_default(require("./to-json-build"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
class MultiReporter {
|
||||
constructor(reporters){
|
||||
this.reporters = [];
|
||||
this.reporters = reporters;
|
||||
}
|
||||
async flushAll(opts) {
|
||||
await Promise.all(this.reporters.map((reporter)=>reporter.flushAll(opts)));
|
||||
}
|
||||
report(event) {
|
||||
this.reporters.forEach((reporter)=>reporter.report(event));
|
||||
}
|
||||
}
|
||||
const reporter = new MultiReporter([
|
||||
_tojson.default,
|
||||
_tojsonbuild.default,
|
||||
_totelemetry.default
|
||||
]);
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
40
build/node_modules/next/dist/trace/report/to-json-build.js
generated
vendored
Normal file
40
build/node_modules/next/dist/trace/report/to-json-build.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _default;
|
||||
}
|
||||
});
|
||||
const _shared = require("../shared");
|
||||
const _constants = require("../../shared/lib/constants");
|
||||
const _tojson = require("./to-json");
|
||||
const allowlistedEvents = new Set([
|
||||
'next-build',
|
||||
'run-turbopack',
|
||||
'run-webpack',
|
||||
'run-typescript',
|
||||
'run-eslint',
|
||||
'static-check',
|
||||
'collect-build-traces',
|
||||
'static-generation',
|
||||
'output-export-full-static-export',
|
||||
'adapter-handle-build-complete',
|
||||
'output-standalone',
|
||||
'telemetry-flush',
|
||||
'turbopack-build-events',
|
||||
'turbopack-persistence',
|
||||
'turbopack-compaction'
|
||||
]);
|
||||
const _default = (0, _tojson.createJsonReporter)({
|
||||
filename: 'trace-build',
|
||||
sizeLimit: Infinity,
|
||||
filter: (event)=>{
|
||||
const phase = _shared.traceGlobals.get('phase');
|
||||
return phase === _constants.PHASE_PRODUCTION_BUILD && allowlistedEvents.has(event.name);
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=to-json-build.js.map
|
||||
165
build/node_modules/next/dist/trace/report/to-json.js
generated
vendored
Normal file
165
build/node_modules/next/dist/trace/report/to-json.js
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
batcher: null,
|
||||
createJsonReporter: null,
|
||||
default: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
batcher: function() {
|
||||
return batcher;
|
||||
},
|
||||
createJsonReporter: function() {
|
||||
return createJsonReporter;
|
||||
},
|
||||
default: function() {
|
||||
return _default;
|
||||
}
|
||||
});
|
||||
const _shared = require("../shared");
|
||||
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _constants = require("../../shared/lib/constants");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function batcher(reportEvents) {
|
||||
const events = [];
|
||||
// Promise queue to ensure events are always sent on flushAll
|
||||
const queue = new Set();
|
||||
return {
|
||||
flushAll: async ()=>{
|
||||
await Promise.all(queue);
|
||||
if (events.length > 0) {
|
||||
await reportEvents(events);
|
||||
events.length = 0;
|
||||
}
|
||||
},
|
||||
report: (event)=>{
|
||||
events.push(event);
|
||||
if (events.length > 100) {
|
||||
const evts = events.slice();
|
||||
events.length = 0;
|
||||
const report = reportEvents(evts);
|
||||
queue.add(report);
|
||||
report.then(()=>queue.delete(report));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
const writeStreamOptions = {
|
||||
flags: 'a',
|
||||
encoding: 'utf8'
|
||||
};
|
||||
class RotatingWriteStream {
|
||||
constructor(file, sizeLimit){
|
||||
this.file = file;
|
||||
this.size = 0;
|
||||
this.sizeLimit = sizeLimit;
|
||||
this.createWriteStream();
|
||||
}
|
||||
createWriteStream() {
|
||||
this.writeStream = _fs.default.createWriteStream(this.file, writeStreamOptions);
|
||||
}
|
||||
// Recreate the file
|
||||
async rotate() {
|
||||
await this.end();
|
||||
try {
|
||||
_fs.default.unlinkSync(this.file);
|
||||
} catch (err) {
|
||||
// It's fine if the file does not exist yet
|
||||
if (err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
this.size = 0;
|
||||
this.createWriteStream();
|
||||
this.rotatePromise = undefined;
|
||||
}
|
||||
async write(data) {
|
||||
if (this.rotatePromise) await this.rotatePromise;
|
||||
this.size += data.length;
|
||||
if (this.size > this.sizeLimit) {
|
||||
await (this.rotatePromise = this.rotate());
|
||||
}
|
||||
if (!this.writeStream.write(data, 'utf8')) {
|
||||
if (this.drainPromise === undefined) {
|
||||
this.drainPromise = new Promise((resolve, _reject)=>{
|
||||
this.writeStream.once('drain', ()=>{
|
||||
this.drainPromise = undefined;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
await this.drainPromise;
|
||||
}
|
||||
}
|
||||
end() {
|
||||
return new Promise((resolve)=>{
|
||||
this.writeStream.end(resolve);
|
||||
});
|
||||
}
|
||||
}
|
||||
function createJsonReporter(options) {
|
||||
let writeStream;
|
||||
let batch;
|
||||
function report(event) {
|
||||
if (options.filter && !options.filter(event)) {
|
||||
return;
|
||||
}
|
||||
const distDir = _shared.traceGlobals.get('distDir');
|
||||
const phase = _shared.traceGlobals.get('phase');
|
||||
if (!distDir || !phase) {
|
||||
return;
|
||||
}
|
||||
if (!batch) {
|
||||
batch = batcher(async (events)=>{
|
||||
if (!writeStream) {
|
||||
await _fs.default.promises.mkdir(distDir, {
|
||||
recursive: true
|
||||
});
|
||||
const file = _path.default.join(distDir, options.filename);
|
||||
const limit = typeof options.sizeLimit === 'function' ? options.sizeLimit(phase) : options.sizeLimit;
|
||||
writeStream = new RotatingWriteStream(file, limit);
|
||||
}
|
||||
const eventsJson = JSON.stringify(events);
|
||||
try {
|
||||
await writeStream.write(eventsJson + '\n');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
batch.report({
|
||||
...event,
|
||||
traceId: _shared.traceId
|
||||
});
|
||||
}
|
||||
return {
|
||||
flushAll: (opts)=>batch ? batch.flushAll().then(()=>{
|
||||
const phase = _shared.traceGlobals.get('phase');
|
||||
// Only end writeStream when manually flushing in production
|
||||
if ((opts == null ? void 0 : opts.end) || phase !== _constants.PHASE_DEVELOPMENT_SERVER) {
|
||||
return writeStream.end();
|
||||
}
|
||||
}) : undefined,
|
||||
report
|
||||
};
|
||||
}
|
||||
const _default = createJsonReporter({
|
||||
filename: 'trace',
|
||||
sizeLimit: (phase)=>// Development is limited to 50MB, production is unlimited
|
||||
phase === _constants.PHASE_DEVELOPMENT_SERVER ? 52428800 : Infinity
|
||||
});
|
||||
|
||||
//# sourceMappingURL=to-json.js.map
|
||||
36
build/node_modules/next/dist/trace/report/to-telemetry.js
generated
vendored
Normal file
36
build/node_modules/next/dist/trace/report/to-telemetry.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _default;
|
||||
}
|
||||
});
|
||||
const _shared = require("../shared");
|
||||
const TRACE_EVENT_ACCESSLIST = new Map(Object.entries({
|
||||
'webpack-invalidated': 'WEBPACK_INVALIDATED'
|
||||
}));
|
||||
const reportToTelemetry = ({ name, duration })=>{
|
||||
const eventName = TRACE_EVENT_ACCESSLIST.get(name);
|
||||
if (!eventName) {
|
||||
return;
|
||||
}
|
||||
const telemetry = _shared.traceGlobals.get('telemetry');
|
||||
if (!telemetry) {
|
||||
return;
|
||||
}
|
||||
telemetry.record({
|
||||
eventName,
|
||||
payload: {
|
||||
durationInMicroseconds: duration
|
||||
}
|
||||
});
|
||||
};
|
||||
const _default = {
|
||||
flushAll: ()=>{},
|
||||
report: reportToTelemetry
|
||||
};
|
||||
|
||||
//# sourceMappingURL=to-telemetry.js.map
|
||||
39
build/node_modules/next/dist/trace/shared.js
generated
vendored
Normal file
39
build/node_modules/next/dist/trace/shared.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
setGlobal: null,
|
||||
traceGlobals: null,
|
||||
traceId: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
setGlobal: function() {
|
||||
return setGlobal;
|
||||
},
|
||||
traceGlobals: function() {
|
||||
return traceGlobals;
|
||||
},
|
||||
traceId: function() {
|
||||
return traceId;
|
||||
}
|
||||
});
|
||||
const _nodecrypto = require("node:crypto");
|
||||
let _traceGlobals = global._traceGlobals;
|
||||
if (!_traceGlobals) {
|
||||
_traceGlobals = new Map();
|
||||
}
|
||||
global._traceGlobals = _traceGlobals;
|
||||
const traceGlobals = _traceGlobals;
|
||||
const setGlobal = (key, val)=>{
|
||||
traceGlobals.set(key, val);
|
||||
};
|
||||
const traceId = process.env.TRACE_ID || process.env.NEXT_PRIVATE_TRACE_ID || (0, _nodecrypto.randomBytes)(8).toString('hex');
|
||||
|
||||
//# sourceMappingURL=shared.js.map
|
||||
211
build/node_modules/next/dist/trace/trace.js
generated
vendored
Normal file
211
build/node_modules/next/dist/trace/trace.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
Span: null,
|
||||
SpanStatus: null,
|
||||
clearTraceEvents: null,
|
||||
exportTraceState: null,
|
||||
flushAllTraces: null,
|
||||
getTraceEvents: null,
|
||||
hrtimeToEpochNanoseconds: null,
|
||||
initializeTraceState: null,
|
||||
recordTraceEvents: null,
|
||||
trace: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
Span: function() {
|
||||
return Span;
|
||||
},
|
||||
SpanStatus: function() {
|
||||
return SpanStatus;
|
||||
},
|
||||
clearTraceEvents: function() {
|
||||
return clearTraceEvents;
|
||||
},
|
||||
exportTraceState: function() {
|
||||
return exportTraceState;
|
||||
},
|
||||
flushAllTraces: function() {
|
||||
return flushAllTraces;
|
||||
},
|
||||
getTraceEvents: function() {
|
||||
return getTraceEvents;
|
||||
},
|
||||
hrtimeToEpochNanoseconds: function() {
|
||||
return hrtimeToEpochNanoseconds;
|
||||
},
|
||||
initializeTraceState: function() {
|
||||
return initializeTraceState;
|
||||
},
|
||||
recordTraceEvents: function() {
|
||||
return recordTraceEvents;
|
||||
},
|
||||
trace: function() {
|
||||
return trace;
|
||||
}
|
||||
});
|
||||
const _report = require("./report");
|
||||
const NUM_OF_MICROSEC_IN_NANOSEC = BigInt('1000');
|
||||
const NUM_OF_MILLISEC_IN_NANOSEC = BigInt('1000000');
|
||||
let count = 0;
|
||||
const getId = ()=>{
|
||||
count++;
|
||||
return count;
|
||||
};
|
||||
let defaultParentSpanId;
|
||||
let shouldSaveTraceEvents;
|
||||
let savedTraceEvents = [];
|
||||
const RECORD_SPAN_THRESHOLD_MS = parseInt(process.env.NEXT_TRACE_SPAN_THRESHOLD_MS ?? '-1');
|
||||
var SpanStatus = /*#__PURE__*/ function(SpanStatus) {
|
||||
SpanStatus["Started"] = "started";
|
||||
SpanStatus["Stopped"] = "stopped";
|
||||
return SpanStatus;
|
||||
}({});
|
||||
class Span {
|
||||
constructor({ name, parentId, attrs, startTime }){
|
||||
this.name = name;
|
||||
this.parentId = parentId ?? defaultParentSpanId;
|
||||
this.attrs = attrs ? {
|
||||
...attrs
|
||||
} : {};
|
||||
this.status = "started";
|
||||
this.id = getId();
|
||||
this._start = startTime || process.hrtime.bigint();
|
||||
// hrtime cannot be used to reconstruct tracing span's actual start time
|
||||
// since it does not have relation to clock time:
|
||||
// `These times are relative to an arbitrary time in the past, and not related to the time of day and therefore not subject to clock drift`
|
||||
// https://nodejs.org/api/process.html#processhrtimetime
|
||||
// Capturing current datetime as additional metadata for external reconstruction.
|
||||
this.now = Date.now();
|
||||
}
|
||||
// Durations are reported as microseconds. This gives 1000x the precision
|
||||
// of something like Date.now(), which reports in milliseconds.
|
||||
// Additionally, ~285 years can be safely represented as microseconds as
|
||||
// a float64 in both JSON and JavaScript.
|
||||
stop(stopTime) {
|
||||
if (this.status === "stopped") {
|
||||
// Don't report the same span twice.
|
||||
// TODO: In the future this should throw as `.stop()` shouldn't be called multiple times.
|
||||
return;
|
||||
}
|
||||
const end = stopTime || process.hrtime.bigint();
|
||||
const duration = (end - this._start) / NUM_OF_MICROSEC_IN_NANOSEC;
|
||||
this.status = "stopped";
|
||||
if (duration > Number.MAX_SAFE_INTEGER) {
|
||||
throw Object.defineProperty(new Error(`Duration is too long to express as float64: ${duration}`), "__NEXT_ERROR_CODE", {
|
||||
value: "E1030",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const timestamp = this._start / NUM_OF_MICROSEC_IN_NANOSEC;
|
||||
const traceEvent = {
|
||||
name: this.name,
|
||||
duration: Number(duration),
|
||||
timestamp: Number(timestamp),
|
||||
id: this.id,
|
||||
parentId: this.parentId,
|
||||
tags: this.attrs,
|
||||
startTime: this.now
|
||||
};
|
||||
if (duration > RECORD_SPAN_THRESHOLD_MS * 1000) {
|
||||
_report.reporter.report(traceEvent);
|
||||
if (shouldSaveTraceEvents) {
|
||||
savedTraceEvents.push(traceEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
traceChild(name, attrs) {
|
||||
return new Span({
|
||||
name,
|
||||
parentId: this.id,
|
||||
attrs
|
||||
});
|
||||
}
|
||||
manualTraceChild(name, // Start time in nanoseconds since epoch.
|
||||
startTime, // Stop time in nanoseconds since epoch.
|
||||
stopTime, attrs) {
|
||||
// We need to convert the time info to the same base as hrtime since that is used usually.
|
||||
const correction = process.hrtime.bigint() - BigInt(Date.now()) * NUM_OF_MILLISEC_IN_NANOSEC;
|
||||
const span = new Span({
|
||||
name,
|
||||
parentId: this.id,
|
||||
attrs,
|
||||
startTime: startTime ? startTime + correction : process.hrtime.bigint()
|
||||
});
|
||||
span.stop(stopTime ? stopTime + correction : process.hrtime.bigint());
|
||||
}
|
||||
getId() {
|
||||
return this.id;
|
||||
}
|
||||
setAttribute(key, value) {
|
||||
this.attrs[key] = value;
|
||||
}
|
||||
traceFn(fn) {
|
||||
try {
|
||||
return fn(this);
|
||||
} catch (e) {
|
||||
this.attrs['failed'] = true;
|
||||
throw e;
|
||||
} finally{
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
async traceAsyncFn(fn) {
|
||||
try {
|
||||
return await fn(this);
|
||||
} catch (e) {
|
||||
this.attrs['failed'] = true;
|
||||
throw e;
|
||||
} finally{
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
const trace = (name, parentId, attrs)=>{
|
||||
return new Span({
|
||||
name,
|
||||
parentId,
|
||||
attrs
|
||||
});
|
||||
};
|
||||
const flushAllTraces = (opts)=>_report.reporter.flushAll(opts);
|
||||
const exportTraceState = ()=>({
|
||||
defaultParentSpanId,
|
||||
lastId: count,
|
||||
shouldSaveTraceEvents
|
||||
});
|
||||
const initializeTraceState = (state)=>{
|
||||
count = state.lastId;
|
||||
defaultParentSpanId = state.defaultParentSpanId;
|
||||
shouldSaveTraceEvents = state.shouldSaveTraceEvents;
|
||||
};
|
||||
function getTraceEvents() {
|
||||
return savedTraceEvents;
|
||||
}
|
||||
function recordTraceEvents(events) {
|
||||
for (const traceEvent of events){
|
||||
_report.reporter.report(traceEvent);
|
||||
if (traceEvent.id > count) {
|
||||
count = traceEvent.id + 1;
|
||||
}
|
||||
}
|
||||
if (shouldSaveTraceEvents) {
|
||||
savedTraceEvents.push(...events);
|
||||
}
|
||||
}
|
||||
const clearTraceEvents = ()=>savedTraceEvents = [];
|
||||
function hrtimeToEpochNanoseconds(hrtimeValue) {
|
||||
const offset = BigInt(Date.now()) * NUM_OF_MILLISEC_IN_NANOSEC - process.hrtime.bigint();
|
||||
return hrtimeValue + offset;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=trace.js.map
|
||||
Reference in New Issue
Block a user