@panomc/theme-core 1.0.0-dev.65 → 1.0.0-dev.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panomc/theme-core",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.67",
|
|
4
4
|
"description": "The Pano theme engine: hooks factories, plugin engine, headless page controllers, default views and the theme CLI. Themes depend on this package instead of forking vanilla-theme.",
|
|
5
5
|
"author": "PanoMC",
|
|
6
6
|
"pano": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@fortawesome/fontawesome-free": "^6.7.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@panomc/sdk": "^2.0.0-dev.
|
|
64
|
+
"@panomc/sdk": "^2.0.0-dev.67",
|
|
65
65
|
"@sveltejs/adapter-node": "^6.0.0",
|
|
66
66
|
"@sveltejs/kit": "^3.1.0",
|
|
67
67
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"vite": "^8.3.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@panomc/sdk": "2.0.0-dev.
|
|
74
|
+
"@panomc/sdk": "2.0.0-dev.67",
|
|
75
75
|
"@sveltejs/adapter-node": "^6.0.0",
|
|
76
76
|
"@sveltejs/kit": "^3.1.0",
|
|
77
77
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
@@ -54,3 +54,34 @@ describe("handleFetch", () => {
|
|
|
54
54
|
expect(sent.headers.get("cookie")).toBe("a=b");
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
describe("handleError", () => {
|
|
59
|
+
const event = { url: new URL("http://127.0.0.1:3000/ticket/2") };
|
|
60
|
+
|
|
61
|
+
const logged = (run) => {
|
|
62
|
+
const log = console.log;
|
|
63
|
+
const errorLog = console.error;
|
|
64
|
+
const calls = [];
|
|
65
|
+
console.log = (...args) => calls.push(args);
|
|
66
|
+
console.error = (...args) => calls.push(args);
|
|
67
|
+
try {
|
|
68
|
+
run();
|
|
69
|
+
} finally {
|
|
70
|
+
console.log = log;
|
|
71
|
+
console.error = errorLog;
|
|
72
|
+
}
|
|
73
|
+
return calls.length;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
test("a 404 from a load is not logged as a server error", () => {
|
|
77
|
+
const { handleError } = createThemeHooks({ internalLibsHash: "x", runtimeShimsHash: "x", suppressNoisyErrors: false });
|
|
78
|
+
|
|
79
|
+
expect(logged(() => handleError({ error: { status: 404, message: "NOT_EXISTS" }, event, status: 404 }))).toBe(0);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("an unexpected error is still logged", () => {
|
|
83
|
+
const { handleError } = createThemeHooks({ internalLibsHash: "x", runtimeShimsHash: "x", suppressNoisyErrors: false });
|
|
84
|
+
|
|
85
|
+
expect(logged(() => handleError({ error: new Error("boom"), event, status: 500 }))).toBe(2);
|
|
86
|
+
});
|
|
87
|
+
});
|
package/src/kit/hooks-server.js
CHANGED
|
@@ -46,6 +46,18 @@ function getCookieWithHttpFallback(cookies, baseName) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/** In production, skip logging common client/bot noise (wrong method, stray POST to non-action routes). */
|
|
49
|
+
/**
|
|
50
|
+
* Whether [status] is a client error (400-499): an expected answer such as a 404, not a failure.
|
|
51
|
+
*
|
|
52
|
+
* @param {unknown} status
|
|
53
|
+
* @returns {boolean}
|
|
54
|
+
*/
|
|
55
|
+
export function isClientErrorStatus(status) {
|
|
56
|
+
const code = Number(status);
|
|
57
|
+
|
|
58
|
+
return Number.isInteger(code) && code >= 400 && code < 500;
|
|
59
|
+
}
|
|
60
|
+
|
|
49
61
|
function shouldSuppressServerErrorLog(error) {
|
|
50
62
|
if (process.env.NODE_ENV !== "production") return false;
|
|
51
63
|
if (error?.status === 405) return true;
|
|
@@ -323,8 +335,12 @@ ${importMapEntries}
|
|
|
323
335
|
}
|
|
324
336
|
|
|
325
337
|
/** @type {import('@sveltejs/kit').HandleServerError} */
|
|
326
|
-
function handleError({ error, event }) {
|
|
327
|
-
|
|
338
|
+
function handleError({ error, event, status }) {
|
|
339
|
+
// A 4xx (a missing ticket, page or post: `error(404, "NOT_EXISTS")`) is an answer, not a fault
|
|
340
|
+
// of this server, so it is never logged; only what ends in a 5xx is.
|
|
341
|
+
const failed = !isClientErrorStatus(status ?? error?.status);
|
|
342
|
+
|
|
343
|
+
if (failed && (!suppressNoisyErrors || !shouldSuppressServerErrorLog(error))) {
|
|
328
344
|
console.log("!!! [GLOBAL ERROR EVENT]:", event.url.href);
|
|
329
345
|
console.error("!!! [GLOBAL ERROR CONTENT]:", error);
|
|
330
346
|
}
|
|
@@ -99,27 +99,18 @@
|
|
|
99
99
|
|
|
100
100
|
const items = panoApi.ui.sidebar.get("home");
|
|
101
101
|
|
|
102
|
-
/*
|
|
103
|
-
const defaultHeaderBg =
|
|
104
|
-
typeof themeSettings.defaultHeaderBg === "undefined"
|
|
105
|
-
? true
|
|
106
|
-
: themeSettings.defaultHeaderBg;
|
|
107
|
-
|
|
108
|
-
$: headerBgImage = defaultHeaderBg
|
|
109
|
-
? "/assets/img/default-header-bg.png"
|
|
110
|
-
: themeSettings.files?.headerBackgroundImage
|
|
111
|
-
? "/api/v1/theme/file/" + themeSettings.files?.headerBackgroundImage
|
|
112
|
-
: "";
|
|
113
|
-
|
|
102
|
+
/* Play card background image */
|
|
114
103
|
$: defaultPlayCardBg =
|
|
115
104
|
typeof themeSettings.defaultPlayCardBg === "undefined"
|
|
116
105
|
? true
|
|
117
106
|
: themeSettings.defaultPlayCardBg;
|
|
118
107
|
|
|
108
|
+
// The play card's default background is the bundled image, not whatever the header shows: turning the
|
|
109
|
+
// header's default image off must not empty the play card.
|
|
119
110
|
$: playCardBgImage = themeSettings.files?.playCardBackgroundImage
|
|
120
111
|
? "/api/v1/theme/file/" + themeSettings.files?.playCardBackgroundImage
|
|
121
112
|
: defaultPlayCardBg
|
|
122
|
-
?
|
|
113
|
+
? "/assets/img/default-header-bg.png"
|
|
123
114
|
: "";
|
|
124
115
|
|
|
125
116
|
$: playCardOpacity = themeSettings.playCardBgOpacity ?? 0.5;
|
|
@@ -219,7 +219,9 @@
|
|
|
219
219
|
<div class="col-md-6 d-flex align-items-center">
|
|
220
220
|
<div class="form-check form-switch">
|
|
221
221
|
<input
|
|
222
|
-
checked={$themeSettings.breadcrumbEnabled
|
|
222
|
+
checked={typeof $themeSettings.breadcrumbEnabled === "undefined"
|
|
223
|
+
? true
|
|
224
|
+
: $themeSettings.breadcrumbEnabled}
|
|
223
225
|
class="pano-theme-settings-view__check form-check-input"
|
|
224
226
|
id="breadcrumb-enabled"
|
|
225
227
|
on:change={(e) =>
|