added fonts

This commit is contained in:
guus committed 2025-07-02 11:28:41 +02:00
1 parent 4134e3a234
commit 142d2986b6
9079 files changed
+1498421 -2

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
export declare function formatConsoleArgs(args: unknown[]): string;
export declare function parseConsoleArgs(args: unknown[]): {
environmentName: string | null;
error: Error | null;
};
+171
View File
@@ -0,0 +1,171 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
formatConsoleArgs: null,
parseConsoleArgs: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
formatConsoleArgs: function() {
return formatConsoleArgs;
},
parseConsoleArgs: function() {
return parseConsoleArgs;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _iserror = /*#__PURE__*/ _interop_require_default._(require("../../lib/is-error"));
function formatObject(arg, depth) {
switch(typeof arg){
case 'object':
if (arg === null) {
return 'null';
} else if (Array.isArray(arg)) {
let result = '[';
if (depth < 1) {
for(let i = 0; i < arg.length; i++){
if (result !== '[') {
result += ',';
}
if (Object.prototype.hasOwnProperty.call(arg, i)) {
result += formatObject(arg[i], depth + 1);
}
}
} else {
result += arg.length > 0 ? '...' : '';
}
result += ']';
return result;
} else if (arg instanceof Error) {
return arg + '';
} else {
const keys = Object.keys(arg);
let result = '{';
if (depth < 1) {
for(let i = 0; i < keys.length; i++){
const key = keys[i];
const desc = Object.getOwnPropertyDescriptor(arg, 'key');
if (desc && !desc.get && !desc.set) {
const jsonKey = JSON.stringify(key);
if (jsonKey !== '"' + key + '"') {
result += jsonKey + ': ';
} else {
result += key + ': ';
}
result += formatObject(desc.value, depth + 1);
}
}
} else {
result += keys.length > 0 ? '...' : '';
}
result += '}';
return result;
}
case 'string':
return JSON.stringify(arg);
default:
return String(arg);
}
}
function formatConsoleArgs(args) {
let message;
let idx;
if (typeof args[0] === 'string') {
message = args[0];
idx = 1;
} else {
message = '';
idx = 0;
}
let result = '';
let startQuote = false;
for(let i = 0; i < message.length; ++i){
const char = message[i];
if (char !== '%' || i === message.length - 1 || idx >= args.length) {
result += char;
continue;
}
const code = message[++i];
switch(code){
case 'c':
{
// TODO: We should colorize with HTML instead of turning into a string.
// Ignore for now.
result = startQuote ? "" + result + "]" : "[" + result;
startQuote = !startQuote;
idx++;
break;
}
case 'O':
case 'o':
{
result += formatObject(args[idx++], 0);
break;
}
case 'd':
case 'i':
{
result += parseInt(args[idx++], 10);
break;
}
case 'f':
{
result += parseFloat(args[idx++]);
break;
}
case 's':
{
result += String(args[idx++]);
break;
}
default:
result += '%' + code;
}
}
for(; idx < args.length; idx++){
result += (idx > 0 ? ' ' : '') + formatObject(args[idx], 0);
}
return result;
}
function parseConsoleArgs(args) {
// See
// https://github.com/facebook/react/blob/65a56d0e99261481c721334a3ec4561d173594cd/packages/react-devtools-shared/src/backend/flight/renderer.js#L88-L93
//
// Logs replayed from the server look like this:
// [
// "%c%s%c %o\n\n%s\n\n%s\n",
// "background: #e6e6e6; ...",
// " Server ", // can also be e.g. " Prerender "
// "",
// Error,
// "The above error occurred in the <Page> component.",
// ...
// ]
if (args.length > 3 && typeof args[0] === 'string' && args[0].startsWith('%c%s%c ') && typeof args[1] === 'string' && typeof args[2] === 'string' && typeof args[3] === 'string') {
const environmentName = args[2];
const maybeError = args[4];
return {
environmentName: environmentName.trim(),
error: (0, _iserror.default)(maybeError) ? maybeError : null
};
}
return {
environmentName: null,
error: null
};
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=console.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/lib/console.ts"],"sourcesContent":["import isError from '../../lib/is-error'\n\nfunction formatObject(arg: unknown, depth: number) {\n switch (typeof arg) {\n case 'object':\n if (arg === null) {\n return 'null'\n } else if (Array.isArray(arg)) {\n let result = '['\n if (depth < 1) {\n for (let i = 0; i < arg.length; i++) {\n if (result !== '[') {\n result += ','\n }\n if (Object.prototype.hasOwnProperty.call(arg, i)) {\n result += formatObject(arg[i], depth + 1)\n }\n }\n } else {\n result += arg.length > 0 ? '...' : ''\n }\n result += ']'\n return result\n } else if (arg instanceof Error) {\n return arg + ''\n } else {\n const keys = Object.keys(arg)\n let result = '{'\n if (depth < 1) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n const desc = Object.getOwnPropertyDescriptor(arg, 'key')\n if (desc && !desc.get && !desc.set) {\n const jsonKey = JSON.stringify(key)\n if (jsonKey !== '\"' + key + '\"') {\n result += jsonKey + ': '\n } else {\n result += key + ': '\n }\n result += formatObject(desc.value, depth + 1)\n }\n }\n } else {\n result += keys.length > 0 ? '...' : ''\n }\n result += '}'\n return result\n }\n case 'string':\n return JSON.stringify(arg)\n default:\n return String(arg)\n }\n}\n\nexport function formatConsoleArgs(args: unknown[]): string {\n let message: string\n let idx: number\n if (typeof args[0] === 'string') {\n message = args[0]\n idx = 1\n } else {\n message = ''\n idx = 0\n }\n let result = ''\n let startQuote = false\n for (let i = 0; i < message.length; ++i) {\n const char = message[i]\n if (char !== '%' || i === message.length - 1 || idx >= args.length) {\n result += char\n continue\n }\n\n const code = message[++i]\n switch (code) {\n case 'c': {\n // TODO: We should colorize with HTML instead of turning into a string.\n // Ignore for now.\n result = startQuote ? `${result}]` : `[${result}`\n startQuote = !startQuote\n idx++\n break\n }\n case 'O':\n case 'o': {\n result += formatObject(args[idx++], 0)\n break\n }\n case 'd':\n case 'i': {\n result += parseInt(args[idx++] as any, 10)\n break\n }\n case 'f': {\n result += parseFloat(args[idx++] as any)\n break\n }\n case 's': {\n result += String(args[idx++])\n break\n }\n default:\n result += '%' + code\n }\n }\n\n for (; idx < args.length; idx++) {\n result += (idx > 0 ? ' ' : '') + formatObject(args[idx], 0)\n }\n\n return result\n}\n\nexport function parseConsoleArgs(args: unknown[]): {\n environmentName: string | null\n error: Error | null\n} {\n // See\n // https://github.com/facebook/react/blob/65a56d0e99261481c721334a3ec4561d173594cd/packages/react-devtools-shared/src/backend/flight/renderer.js#L88-L93\n //\n // Logs replayed from the server look like this:\n // [\n // \"%c%s%c %o\\n\\n%s\\n\\n%s\\n\",\n // \"background: #e6e6e6; ...\",\n // \" Server \", // can also be e.g. \" Prerender \"\n // \"\",\n // Error,\n // \"The above error occurred in the <Page> component.\",\n // ...\n // ]\n if (\n args.length > 3 &&\n typeof args[0] === 'string' &&\n args[0].startsWith('%c%s%c ') &&\n typeof args[1] === 'string' &&\n typeof args[2] === 'string' &&\n typeof args[3] === 'string'\n ) {\n const environmentName = args[2]\n const maybeError = args[4]\n\n return {\n environmentName: environmentName.trim(),\n error: isError(maybeError) ? maybeError : null,\n }\n }\n\n return {\n environmentName: null,\n error: null,\n }\n}\n"],"names":["formatConsoleArgs","parseConsoleArgs","formatObject","arg","depth","Array","isArray","result","i","length","Object","prototype","hasOwnProperty","call","Error","keys","key","desc","getOwnPropertyDescriptor","get","set","jsonKey","JSON","stringify","value","String","args","message","idx","startQuote","char","code","parseInt","parseFloat","startsWith","environmentName","maybeError","trim","error","isError"],"mappings":";;;;;;;;;;;;;;;IAuDgBA,iBAAiB;eAAjBA;;IA2DAC,gBAAgB;eAAhBA;;;;kEAlHI;AAEpB,SAASC,aAAaC,GAAY,EAAEC,KAAa;IAC/C,OAAQ,OAAOD;QACb,KAAK;YACH,IAAIA,QAAQ,MAAM;gBAChB,OAAO;YACT,OAAO,IAAIE,MAAMC,OAAO,CAACH,MAAM;gBAC7B,IAAII,SAAS;gBACb,IAAIH,QAAQ,GAAG;oBACb,IAAK,IAAII,IAAI,GAAGA,IAAIL,IAAIM,MAAM,EAAED,IAAK;wBACnC,IAAID,WAAW,KAAK;4BAClBA,UAAU;wBACZ;wBACA,IAAIG,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACV,KAAKK,IAAI;4BAChDD,UAAUL,Line truncated