@jamesmddoyle/phantom 0.2.4 → 0.2.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"1793228583037"}
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
<div style="display: contents">
|
|
23
23
|
<script>
|
|
24
24
|
{
|
|
25
|
-
|
|
25
|
+
__sveltekit_15nbta3 = {
|
|
26
26
|
base: "/_dashboard",
|
|
27
|
-
version: "
|
|
27
|
+
version: "1793228583037",
|
|
28
28
|
assets: "/_dashboard"
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const element = document.currentScript.parentElement;
|
|
32
32
|
|
|
33
33
|
import("/_dashboard/_app/immutable/entry/start.DRnrjJWJ.js").then(async (kit) => {
|
|
34
|
-
kit.init(
|
|
34
|
+
kit.init(__sveltekit_15nbta3);
|
|
35
35
|
const app = await import("/_dashboard/_app/immutable/entry/app.xWq8izru.js");
|
|
36
36
|
kit.start(app, element);
|
|
37
37
|
});
|
package/dist/package.json
CHANGED
package/dist/static.js
CHANGED
|
@@ -11,7 +11,29 @@ const MIME_TYPES = {
|
|
|
11
11
|
".json": "application/json",
|
|
12
12
|
};
|
|
13
13
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
-
|
|
14
|
+
/** The published build first, then the repo build during development. */
|
|
15
|
+
const DASHBOARD_FOLDERS = [path.join(__dirname, "dashboard-ui"), path.join(__dirname, "../dashboard/build")];
|
|
16
|
+
/**
|
|
17
|
+
* Decodes a request path and joins it onto the folder.
|
|
18
|
+
* Returns null when the path can't be decoded or ends up outside the folder.
|
|
19
|
+
*/
|
|
20
|
+
function resolveInside(folder, requestPath) {
|
|
21
|
+
let decodedPath;
|
|
22
|
+
try {
|
|
23
|
+
decodedPath = decodeURIComponent(requestPath);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const filePath = path.join(folder, decodedPath);
|
|
29
|
+
const isInside = filePath === folder || filePath.startsWith(folder + path.sep);
|
|
30
|
+
return isInside ? filePath : null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Finds the dashboard file for a request. Returns null when the request isn't for the dashboard,
|
|
34
|
+
* or when its path leaves the dashboard folder, so the request ends in a 404.
|
|
35
|
+
*/
|
|
36
|
+
export async function handleStaticFile(requestPath, folders = DASHBOARD_FOLDERS) {
|
|
15
37
|
const isDashboardBase = requestPath.startsWith("/_dashboard");
|
|
16
38
|
const isAppAsset = requestPath.startsWith("/_app");
|
|
17
39
|
const isPhantomSVG = requestPath === "/phantom.svg";
|
|
@@ -23,9 +45,10 @@ export async function handleStaticFile(requestPath) {
|
|
|
23
45
|
}
|
|
24
46
|
if (cleanPath === "" || cleanPath === "/")
|
|
25
47
|
cleanPath = "/index.html";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
48
|
+
for (const folder of folders) {
|
|
49
|
+
const filePath = resolveInside(folder, cleanPath);
|
|
50
|
+
if (!filePath)
|
|
51
|
+
return null;
|
|
29
52
|
try {
|
|
30
53
|
const content = await fs.readFile(filePath);
|
|
31
54
|
const ext = path.extname(filePath);
|
|
@@ -41,10 +64,9 @@ export async function handleStaticFile(requestPath) {
|
|
|
41
64
|
}
|
|
42
65
|
}
|
|
43
66
|
// SPA fallback for /_dashboard sub-routes
|
|
44
|
-
const
|
|
45
|
-
for (const fallback of fallbackPaths) {
|
|
67
|
+
for (const folder of folders) {
|
|
46
68
|
try {
|
|
47
|
-
const indexContent = await fs.readFile(
|
|
69
|
+
const indexContent = await fs.readFile(path.join(folder, "index.html"));
|
|
48
70
|
return { body: indexContent, headers: { "Content-Type": "text/html" } };
|
|
49
71
|
}
|
|
50
72
|
catch {
|