Initial boiler plate project

This commit is contained in:
2024-09-24 03:52:46 +00:00
parent 6120b2d6c3
commit 154b93e267
10034 changed files with 2079352 additions and 2 deletions

10
node_modules/next/dist/trace/report/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
import type { TraceEvent } from '../types';
import type { Reporter } from './types';
declare class MultiReporter implements Reporter {
private reporters;
constructor(reporters: Reporter[]);
flushAll(): Promise<void>;
report(event: TraceEvent): void;
}
export declare const reporter: MultiReporter;
export {};

35
node_modules/next/dist/trace/report/index.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
"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"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
class MultiReporter {
constructor(reporters){
this.reporters = [];
this.reporters = reporters;
}
async flushAll() {
await Promise.all(this.reporters.map((reporter)=>reporter.flushAll()));
}
report(event) {
this.reporters.forEach((reporter)=>reporter.report(event));
}
}
const reporter = new MultiReporter([
_tojson.default,
_totelemetry.default
]);
//# sourceMappingURL=index.js.map

1
node_modules/next/dist/trace/report/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/trace/report/index.ts"],"names":["reporter","MultiReporter","constructor","reporters","flushAll","Promise","all","map","report","event","forEach","reportToJson","reportToTelemetry"],"mappings":";;;;+BAsBaA;;;eAAAA;;;oEArBiB;+DACL;;;;;;AAGzB,MAAMC;IAGJC,YAAYC,SAAqB,CAAE;aAF3BA,YAAwB,EAAE;QAGhC,IAAI,CAACA,SAAS,GAAGA;IACnB;IAEA,MAAMC,WAAW;QACf,MAAMC,QAAQC,GAAG,CAAC,IAAI,CAACH,SAAS,CAACI,GAAG,CAAC,CAACP,WAAaA,SAASI,QAAQ;IACtE;IAEAI,OAAOC,KAAiB,EAAE;QACxB,IAAI,CAACN,SAAS,CAACO,OAAO,CAAC,CAACV,WAAaA,SAASQ,MAAM,CAACC;IACvD;AACF;AAGO,MAAMT,WAAW,IAAIC,cAAc;IAACU,eAAY;IAAEC,oBAAiB;CAAC"}

1
node_modules/next/dist/trace/report/index.test.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export {};

63
node_modules/next/dist/trace/report/index.test.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _promises = require("fs/promises");
const _ = require(".");
const _shared = require("../shared");
const _path = require("path");
const _os = require("os");
const TRACE_EVENT = {
name: "test-span",
duration: 321,
timestamp: Date.now(),
id: 127,
startTime: Date.now()
};
const WEBPACK_INVALIDATED_EVENT = {
name: "webpack-invalidated",
duration: 100,
timestamp: Date.now(),
id: 112,
startTime: Date.now()
};
describe("Trace Reporter", ()=>{
describe("JSON reporter", ()=>{
it("should write the trace events to JSON file", async ()=>{
const tmpDir = await (0, _promises.mkdtemp)((0, _path.join)((0, _os.tmpdir)(), "json-reporter"));
(0, _shared.setGlobal)("distDir", tmpDir);
(0, _shared.setGlobal)("phase", "anything");
_.reporter.report(TRACE_EVENT);
await _.reporter.flushAll();
const traceFilename = (0, _path.join)(tmpDir, "trace");
const traces = JSON.parse(await (0, _promises.readFile)(traceFilename, "utf-8"));
expect(traces.length).toEqual(1);
expect(traces[0].name).toEqual("test-span");
expect(traces[0].id).toEqual(127);
expect(traces[0].duration).toEqual(321);
expect(traces[0].traceId).toBeDefined();
});
});
describe("Telemetry reporter", ()=>{
it("should record telemetry event", async ()=>{
const recordMock = jest.fn();
const telemetryMock = {
record: recordMock
};
(0, _shared.setGlobal)("telemetry", telemetryMock);
// This should be ignored.
_.reporter.report(TRACE_EVENT);
expect(recordMock).toHaveBeenCalledTimes(0);
_.reporter.report(WEBPACK_INVALIDATED_EVENT);
expect(recordMock).toHaveBeenCalledTimes(1);
expect(recordMock).toHaveBeenCalledWith({
eventName: "WEBPACK_INVALIDATED",
payload: {
durationInMicroseconds: 100
}
});
});
});
});
//# sourceMappingURL=index.test.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/trace/report/index.test.ts"],"names":["TRACE_EVENT","name","duration","timestamp","Date","now","id","startTime","WEBPACK_INVALIDATED_EVENT","describe","it","tmpDir","mkdtemp","join","tmpdir","setGlobal","reporter","report","flushAll","traceFilename","traces","JSON","parse","readFile","expect","length","toEqual","traceId","toBeDefined","recordMock","jest","fn","telemetryMock","record","toHaveBeenCalledTimes","toHaveBeenCalledWith","eventName","payload","durationInMicroseconds"],"mappings":";;;;0BAAkC;kBACT;wBACC;sBACL;oBACE;AAEvB,MAAMA,cAAc;IAClBC,MAAM;IACNC,UAAU;IACVC,WAAWC,KAAKC,GAAG;IACnBC,IAAI;IACJC,WAAWH,KAAKC,GAAG;AACrB;AACA,MAAMG,4BAA4B;IAChCP,MAAM;IACNC,UAAU;IACVC,WAAWC,KAAKC,GAAG;IACnBC,IAAI;IACJC,WAAWH,KAAKC,GAAG;AACrB;AAEAI,SAAS,kBAAkB;IACzBA,SAAS,iBAAiB;QACxBC,GAAG,8CAA8C;YAC/C,MAAMC,SAAS,MAAMC,IAAAA,iBAAO,EAACC,IAAAA,UAAI,EAACC,IAAAA,UAAM,KAAI;YAC5CC,IAAAA,iBAAS,EAAC,WAAWJ;YACrBI,IAAAA,iBAAS,EAAC,SAAS;YACnBC,UAAQ,CAACC,MAAM,CAACjB;YAChB,MAAMgB,UAAQ,CAACE,QAAQ;YACvB,MAAMC,gBAAgBN,IAAAA,UAAI,EAACF,QAAQ;YACnC,MAAMS,SAASC,KAAKC,KAAK,CAAC,MAAMC,IAAAA,kBAAQ,EAACJ,eAAe;YACxDK,OAAOJ,OAAOK,MAAM,EAAEC,OAAO,CAAC;YAC9BF,OAAOJ,MAAM,CAAC,EAAE,CAACnB,IAAI,EAAEyB,OAAO,CAAC;YAC/BF,OAAOJ,MAAM,CAAC,EAAE,CAACd,EAAE,EAAEoB,OAAO,CAAC;YAC7BF,OAAOJ,MAAM,CAAC,EAAE,CAAClB,QAAQ,EAAEwB,OAAO,CAAC;YACnCF,OAAOJ,MAAM,CAAC,EAAE,CAACO,OAAO,EAAEC,WAAW;QACvC;IACF;IAEAnB,SAAS,sBAAsB;QAC7BC,GAAG,iCAAiC;YAClC,MAAMmB,aAAaC,KAAKC,EAAE;YAC1B,MAAMC,gBAAgB;gBACpBC,QAAQJ;YACV;YACAd,IAAAA,iBAAS,EAAC,aAAaiB;YACvB,0BAA0B;YAC1BhB,UAAQ,CAACC,MAAM,CAACjB;YAChBwB,OAAOK,YAAYK,qBAAqB,CAAC;YACzClB,UAAQ,CAACC,MAAM,CAACT;YAChBgB,OAAOK,YAAYK,qBAAqB,CAAC;YACzCV,OAAOK,YAAYM,oBAAoB,CAAC;gBACtCC,WAAW;gBACXC,SAAS;oBACPC,wBAAwB;gBAC1B;YACF;QACF;IACF;AACF"}

18
node_modules/next/dist/trace/report/to-json.d.ts generated vendored Normal file
View File

@ -0,0 +1,18 @@
import type { TraceEvent } from '../types';
declare const localEndpoint: {
serviceName: string;
ipv4: string;
port: number;
};
type Event = TraceEvent & {
localEndpoint?: typeof localEndpoint;
};
export declare function batcher(reportEvents: (evts: Event[]) => Promise<void>): {
flushAll: () => Promise<void>;
report: (event: Event) => void;
};
declare const _default: {
flushAll: () => Promise<void | undefined> | undefined;
report: (event: TraceEvent) => void;
};
export default _default;

161
node_modules/next/dist/trace/report/to-json.js generated vendored Normal file
View File

@ -0,0 +1,161 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
batcher: 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;
},
default: function() {
return _default;
}
});
const _crypto = require("crypto");
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
};
}
const localEndpoint = {
serviceName: "nextjs",
ipv4: "127.0.0.1",
port: 9411
};
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));
}
}
};
}
let writeStream;
let traceId;
let batch;
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);
});
}
}
const reportToLocalHost = (event)=>{
const distDir = _shared.traceGlobals.get("distDir");
const phase = _shared.traceGlobals.get("phase");
if (!distDir || !phase) {
return;
}
if (!traceId) {
traceId = process.env.TRACE_ID || (0, _crypto.randomBytes)(8).toString("hex");
}
if (!batch) {
batch = batcher(async (events)=>{
if (!writeStream) {
await _fs.default.promises.mkdir(distDir, {
recursive: true
});
const file = _path.default.join(distDir, "trace");
writeStream = new RotatingWriteStream(file, // Development is limited to 50MB, production is unlimited
phase === _constants.PHASE_DEVELOPMENT_SERVER ? 52428800 : Infinity);
}
const eventsJson = JSON.stringify(events);
try {
await writeStream.write(eventsJson + "\n");
} catch (err) {
console.log(err);
}
});
}
batch.report({
...event,
traceId
});
};
const _default = {
flushAll: ()=>batch ? batch.flushAll().then(()=>{
const phase = _shared.traceGlobals.get("phase");
// Only end writeStream when manually flushing in production
if (phase !== _constants.PHASE_DEVELOPMENT_SERVER) {
return writeStream.end();
}
}) : undefined,
report: reportToLocalHost
};
//# sourceMappingURL=to-json.js.map

1
node_modules/next/dist/trace/report/to-json.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/trace/report/to-json.ts"],"names":["batcher","localEndpoint","serviceName","ipv4","port","reportEvents","events","queue","Set","flushAll","Promise","all","length","report","event","push","evts","slice","add","then","delete","writeStream","traceId","batch","writeStreamOptions","flags","encoding","RotatingWriteStream","constructor","file","sizeLimit","size","createWriteStream","fs","rotate","end","unlinkSync","err","code","rotatePromise","undefined","write","data","drainPromise","resolve","_reject","once","reportToLocalHost","distDir","traceGlobals","get","phase","process","env","TRACE_ID","randomBytes","toString","promises","mkdir","recursive","path","join","PHASE_DEVELOPMENT_SERVER","Infinity","eventsJson","JSON","stringify","console","log"],"mappings":";;;;;;;;;;;;;;;IAkBgBA,OAAO;eAAPA;;IAkIhB,OAYC;eAZD;;;wBApJ4B;wBACC;2DACd;6DACE;2BACwB;;;;;;AAGzC,MAAMC,gBAAgB;IACpBC,aAAa;IACbC,MAAM;IACNC,MAAM;AACR;AAOO,SAASJ,QAAQK,YAA8C;IACpE,MAAMC,SAAkB,EAAE;IAC1B,6DAA6D;IAC7D,MAAMC,QAAQ,IAAIC;IAClB,OAAO;QACLC,UAAU;YACR,MAAMC,QAAQC,GAAG,CAACJ;YAClB,IAAID,OAAOM,MAAM,GAAG,GAAG;gBACrB,M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C,GAAG,CAAC/B;YACd;QACF;IACF;IAEAd,MAAMV,MAAM,CAAC;QACX,GAAGC,KAAK;QACRQ;IACF;AACF;MAEA,WAAe;IACbb,UAAU,IACRc,QACIA,MAAMd,QAAQ,GAAGU,IAAI,CAAC;YACpB,MAAMgC,QAAQF,oBAAY,CAACC,GAAG,CAAC;YAC/B,4DAA4D;YAC5D,IAAIC,UAAUW,mCAAwB,EAAE;gBACtC,OAAOzC,YAAYc,GAAG;YACxB;QACF,KACAK;IACN3B,QAAQkC;AACV"}

View File

@ -0,0 +1,6 @@
import type { TraceEvent } from '../types';
declare const _default: {
flushAll: () => void;
report: ({ name, duration }: TraceEvent) => void;
};
export default _default;

36
node_modules/next/dist/trace/report/to-telemetry.js generated vendored Normal file
View 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

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/trace/report/to-telemetry.ts"],"names":["TRACE_EVENT_ACCESSLIST","Map","Object","entries","reportToTelemetry","name","duration","eventName","get","telemetry","traceGlobals","record","payload","durationInMicroseconds","flushAll","report"],"mappings":";;;;+BA4BA;;;eAAA;;;wBA3B6B;AAG7B,MAAMA,yBAAyB,IAAIC,IACjCC,OAAOC,OAAO,CAAC;IACb,uBAAuB;AACzB;AAGF,MAAMC,oBAAoB,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAc;IACvD,MAAMC,YAAYP,uBAAuBQ,GAAG,CAACH;IAC7C,IAAI,CAACE,WAAW;QACd;IACF;IACA,MAAME,YAAmCC,oBAAY,CAACF,GAAG,CAAC;IAC1D,IAAI,CAACC,WAAW;QACd;IACF;IAEAA,UAAUE,MAAM,CAAC;QACfJ;QACAK,SAAS;YACPC,wBAAwBP;QAC1B;IACF;AACF;MAEA,WAAe;IACbQ,UAAU,KAAO;IACjBC,QAAQX;AACV"}

5
node_modules/next/dist/trace/report/types.d.ts generated vendored Normal file
View File

@ -0,0 +1,5 @@
import type { TraceEvent } from '../types';
export type Reporter = {
flushAll: () => Promise<void> | void;
report: (event: TraceEvent) => void;
};

6
node_modules/next/dist/trace/report/types.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

1
node_modules/next/dist/trace/report/types.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}