Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,100 @@
export type _PerformanceEntryType = "mark" | "measure" | "resource" | "event";
// --------------------------------------
// Performance entry polyfills
// --------------------------------------
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/supportedEntryTypes_static
export declare const _supportedEntryTypes: _PerformanceEntryType[];
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry
export declare class _PerformanceEntry implements globalThis.PerformanceEntry {
readonly __unenv__: true;
detail: any | undefined;
entryType: _PerformanceEntryType;
name: string;
startTime: number;
constructor(name: string, options?: PerformanceMarkOptions);
get duration(): number;
toJSON(): {};
}
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark
export declare class _PerformanceMark extends _PerformanceEntry implements globalThis.PerformanceMark {
entryType: "mark";
}
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMeasure
export declare class _PerformanceMeasure extends _PerformanceEntry implements globalThis.PerformanceMeasure {
entryType: "measure";
}
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
export declare class _PerformanceResourceTiming extends _PerformanceEntry implements globalThis.PerformanceResourceTiming {
entryType: "resource";
serverTiming: readonly PerformanceServerTiming[];
connectEnd: number;
connectStart: number;
decodedBodySize: number;
domainLookupEnd: number;
domainLookupStart: number;
encodedBodySize: number;
fetchStart: number;
initiatorType: string;
name: string;
nextHopProtocol: string;
redirectEnd: number;
redirectStart: number;
requestStart: number;
responseEnd: number;
responseStart: number;
secureConnectionStart: number;
startTime: number;
transferSize: number;
workerStart: number;
responseStatus: number;
}
// --------------------------------------
// PerformanceObserver polyfill
// --------------------------------------
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver
export declare class _PerformanceObserver implements globalThis.PerformanceObserver {
readonly __unenv__: true;
static supportedEntryTypes: ReadonlyArray<string>;
_callback: PerformanceObserverCallback | null;
constructor(callback: PerformanceObserverCallback);
takeRecords(): unknown;
disconnect(): void;
observe(options: PerformanceObserverInit): void;
}
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserverEntryList
export declare class _PerformanceObserverEntryList implements globalThis.PerformanceObserverEntryList {
readonly __unenv__: true;
getEntries(): PerformanceEntryList;
getEntriesByName(_name: string, _type?: string | undefined): PerformanceEntryList;
getEntriesByType(type: string): PerformanceEntryList;
}
// --------------------------------------
// Performance polyfill
// --------------------------------------
// https://developer.mozilla.org/en-US/docs/Web/API/Performance
export declare class _Performance<PerformanceEntryT extends PerformanceEntry = PerformanceEntry> implements globalThis.Performance {
readonly __unenv__: true;
timeOrigin: number;
eventCounts: EventCounts;
_entries: PerformanceEntry[];
_resourceTimingBufferSize: number;
navigation: any;
timing: any;
onresourcetimingbufferfull: ((this: Performance, ev: Event) => any) | null;
now(): number;
clearMarks(markName?: string | undefined): void;
clearMeasures(measureName?: string | undefined): void;
clearResourceTimings(): void;
getEntries(): PerformanceEntryT[];
getEntriesByName(name: string, type?: string | undefined): PerformanceEntryT[];
getEntriesByType(type: string): PerformanceEntryT[];
mark(name: string, options?: PerformanceMarkOptions | undefined): PerformanceMark;
measure(measureName: string, startOrMeasureOptions?: string | PerformanceMeasureOptions, endMark?: string): PerformanceMeasure;
setResourceTimingBufferSize(maxSize: number): void;
toJSON();
addEventListener<K extends "resourcetimingbufferfull">(type: K, listener: (this: Performance, ev: PerformanceEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
removeEventListener<K extends "resourcetimingbufferfull">(type: K, listener: (this: Performance, ev: PerformanceEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
dispatchEvent(event: Event): boolean;
}

View file

@ -0,0 +1,184 @@
import { createNotImplementedError } from "../../_internal/utils.mjs";
const _timeOrigin = globalThis.performance?.timeOrigin ?? Date.now();
const _performanceNow = globalThis.performance?.now ? globalThis.performance.now.bind(globalThis.performance) : () => Date.now() - _timeOrigin;
// --------------------------------------
// Performance entry polyfills
// --------------------------------------
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/supportedEntryTypes_static
export const _supportedEntryTypes = [
"event",
"mark",
"measure",
"resource"
];
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry
export class _PerformanceEntry {
__unenv__ = true;
detail;
entryType = "event";
name;
startTime;
constructor(name, options) {
this.name = name;
this.startTime = options?.startTime || _performanceNow();
this.detail = options?.detail;
}
get duration() {
return _performanceNow() - this.startTime;
}
toJSON() {
return {
name: this.name,
entryType: this.entryType,
startTime: this.startTime,
duration: this.duration,
detail: this.detail
};
}
}
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark
export class _PerformanceMark extends _PerformanceEntry {
entryType = "mark";
}
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMeasure
export class _PerformanceMeasure extends _PerformanceEntry {
entryType = "measure";
}
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
export class _PerformanceResourceTiming extends _PerformanceEntry {
entryType = "resource";
serverTiming = [];
connectEnd = 0;
connectStart = 0;
decodedBodySize = 0;
domainLookupEnd = 0;
domainLookupStart = 0;
encodedBodySize = 0;
fetchStart = 0;
initiatorType = "";
name = "";
nextHopProtocol = "";
redirectEnd = 0;
redirectStart = 0;
requestStart = 0;
responseEnd = 0;
responseStart = 0;
secureConnectionStart = 0;
startTime = 0;
transferSize = 0;
workerStart = 0;
responseStatus = 0;
}
// --------------------------------------
// PerformanceObserver polyfill
// --------------------------------------
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver
export class _PerformanceObserver {
__unenv__ = true;
static supportedEntryTypes = _supportedEntryTypes;
_callback = null;
constructor(callback) {
this._callback = callback;
}
takeRecords() {
return [];
}
disconnect() {
throw createNotImplementedError("PerformanceObserver.disconnect");
}
observe(options) {
throw createNotImplementedError("PerformanceObserver.observe");
}
}
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserverEntryList
export class _PerformanceObserverEntryList {
__unenv__ = true;
getEntries() {
return [];
}
getEntriesByName(_name, _type) {
return [];
}
getEntriesByType(type) {
return [];
}
}
// --------------------------------------
// Performance polyfill
// --------------------------------------
// https://developer.mozilla.org/en-US/docs/Web/API/Performance
export class _Performance {
__unenv__ = true;
timeOrigin = _timeOrigin;
eventCounts = new Map();
_entries = [];
_resourceTimingBufferSize = 0;
navigation = undefined;
timing = undefined;
onresourcetimingbufferfull = null;
now() {
// https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
if (this.timeOrigin === _timeOrigin) {
return _performanceNow();
}
return Date.now() - this.timeOrigin;
}
clearMarks(markName) {
this._entries = markName ? this._entries.filter((e) => e.name !== markName) : this._entries.filter((e) => e.entryType !== "mark");
}
clearMeasures(measureName) {
this._entries = measureName ? this._entries.filter((e) => e.name !== measureName) : this._entries.filter((e) => e.entryType !== "measure");
}
clearResourceTimings() {
this._entries = this._entries.filter((e) => e.entryType !== "resource" || e.entryType !== "navigation");
}
getEntries() {
return this._entries;
}
getEntriesByName(name, type) {
return this._entries.filter((e) => e.name === name && (!type || e.entryType === type));
}
getEntriesByType(type) {
return this._entries.filter((e) => e.entryType === type);
}
mark(name, options) {
const entry = new _PerformanceMark(name, options);
this._entries.push(entry);
return entry;
}
measure(measureName, startOrMeasureOptions, endMark) {
let start;
let end;
if (typeof startOrMeasureOptions === "string") {
start = this.getEntriesByName(startOrMeasureOptions, "mark")[0]?.startTime;
end = this.getEntriesByName(endMark, "mark")[0]?.startTime;
} else {
start = Number.parseFloat(startOrMeasureOptions?.start) || this.now();
end = Number.parseFloat(startOrMeasureOptions?.end) || this.now();
}
const entry = new _PerformanceMeasure(measureName, {
startTime: start,
detail: {
start,
end
}
});
this._entries.push(entry);
return entry;
}
setResourceTimingBufferSize(maxSize) {
this._resourceTimingBufferSize = maxSize;
}
toJSON() {
return this;
}
addEventListener(type, listener, options) {
throw createNotImplementedError("Performance.addEventListener");
}
removeEventListener(type, listener, options) {
throw createNotImplementedError("Performance.removeEventListener");
}
dispatchEvent(event) {
throw createNotImplementedError("Performance.dispatchEvent");
}
}

View file

@ -0,0 +1,12 @@
export { type _PerformanceEntryType, _PerformanceEntry, _PerformanceMark, _PerformanceMeasure, _PerformanceResourceTiming, _Performance, _PerformanceObserver, _PerformanceObserverEntryList } from "./_polyfills.mjs";
export declare const PerformanceEntry: typeof globalThis.PerformanceEntry;
export declare const PerformanceMark: typeof globalThis.PerformanceMark;
export declare const PerformanceMeasure: typeof globalThis.PerformanceMeasure;
export declare const PerformanceResourceTiming: typeof globalThis.PerformanceResourceTiming;
export declare const PerformanceObserver: typeof globalThis.PerformanceObserver;
export declare const Performance: typeof globalThis.Performance;
export declare const PerformanceObserverEntryList: typeof globalThis.PerformanceObserverEntryList;
// workerd implements a subset of globalThis.performance (as of last check, only timeOrigin set to 0 + now() implemented)
// We already use performance.now() from globalThis.performance, if provided (see top of this file)
// If we detect this condition, we can just use polyfill instead.
export declare const performance: unknown;

View file

@ -0,0 +1,14 @@
// https://developer.mozilla.org/en-US/docs/Web/API/Performance_API
import { _PerformanceEntry, _PerformanceMark, _PerformanceMeasure, _PerformanceResourceTiming, _Performance, _PerformanceObserver, _PerformanceObserverEntryList } from "./_polyfills.mjs";
export { _PerformanceEntry, _PerformanceMark, _PerformanceMeasure, _PerformanceResourceTiming, _Performance, _PerformanceObserver, _PerformanceObserverEntryList } from "./_polyfills.mjs";
export const PerformanceEntry = globalThis.PerformanceEntry || _PerformanceEntry;
export const PerformanceMark = globalThis.PerformanceMark || _PerformanceMark;
export const PerformanceMeasure = globalThis.PerformanceMeasure || _PerformanceMeasure;
export const PerformanceResourceTiming = globalThis.PerformanceResourceTiming || _PerformanceResourceTiming;
export const PerformanceObserver = globalThis.PerformanceObserver || _PerformanceObserver;
export const Performance = globalThis.Performance || _Performance;
export const PerformanceObserverEntryList = globalThis.PerformanceObserverEntryList || _PerformanceObserverEntryList;
// workerd implements a subset of globalThis.performance (as of last check, only timeOrigin set to 0 + now() implemented)
// We already use performance.now() from globalThis.performance, if provided (see top of this file)
// If we detect this condition, we can just use polyfill instead.
export const performance = globalThis.performance && "addEventListener" in globalThis.performance ? globalThis.performance : new _Performance();