@dirwell/theme-ledger 0.0.2 → 0.0.4
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/README.md +12 -2
- package/dist/client.js +24 -24
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +13 -36
- package/dist/index.mjs.map +1 -1
- package/dist/{model-BgCmoksr.d.mts → model-CeW-leLg.d.mts} +3 -3
- package/dist/model.d.mts +1 -1
- package/dist/source/Ledger.svelte +90 -54
- package/dist/styles.css +195 -546
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ThemeAction, c as ThemeLabels, i as ThemePage, o as ThemeColumn, s as ThemeCustomization, t as FrameworkRenderer } from "./model-
|
|
1
|
+
import { a as ThemeAction, c as ThemeLabels, i as ThemePage, o as ThemeColumn, s as ThemeCustomization, t as FrameworkRenderer } from "./model-CeW-leLg.mjs";
|
|
2
2
|
import { ExplorerTheme } from "@dirwell/core";
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
export interface LedgerThemeOptions extends ThemeCustomization {
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { copyJsonObject, escapeHtml, projectListingEntry } from "@dirwell/core";
|
|
4
|
-
import path from "node:path";
|
|
5
4
|
import { render } from "svelte/server";
|
|
6
5
|
import * as $ from "svelte/internal/server";
|
|
7
6
|
import { onMount, tick, untrack } from "svelte";
|
|
@@ -10,20 +9,9 @@ import { ListingDataError, loadListing, parseListingEntries } from "@dirwell/cor
|
|
|
10
9
|
const pageAsset = (theme, directory, page = 1) => `${theme}-page-${createHash("sha256").update(directory).digest("hex").slice(0, 24)}-${page}.json`;
|
|
11
10
|
function folderDataHref(entry, context, theme) {
|
|
12
11
|
if (entry.exitsExplorer || entry.href === null || !(entry.kind === "directory" || entry.link?.targetKind === "directory")) return null;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const target = new URL(entry.href, base);
|
|
17
|
-
const rootPath = root.pathname.endsWith("/") ? root.pathname : root.pathname.slice(0, root.pathname.lastIndexOf("/") + 1);
|
|
18
|
-
const directoryPath = target.pathname.endsWith("/") ? target.pathname : target.pathname.slice(0, target.pathname.lastIndexOf("/") + 1);
|
|
19
|
-
const logical = directoryPath.slice(rootPath.length).split("/").filter(Boolean).map(decodeURIComponent).join("/");
|
|
20
|
-
const filename = pageAsset(theme, logical);
|
|
21
|
-
if (context.pageDataHref !== void 0) return context.pageDataHref(theme, logical, 1);
|
|
22
|
-
if (context.mode === "mpa") return context.assetHref(filename);
|
|
23
|
-
const href = new URL(filename, new URL(directoryPath, target));
|
|
24
|
-
if (href.origin !== new URL(fake).origin) return href.href;
|
|
25
|
-
if (context.documentBaseHref === null && !entry.href.startsWith("/")) return path.posix.relative(context.directoryPath || ".", path.posix.join(logical, filename)).split("/").map((segment) => segment === ".." || segment === "." ? segment : encodeURIComponent(segment)).join("/");
|
|
26
|
-
return href.pathname;
|
|
12
|
+
const logical = context.directoryPathForEntry(entry.id);
|
|
13
|
+
if (logical === null) return null;
|
|
14
|
+
return context.pageDataHref?.(theme, logical, 1) ?? context.assetHrefForDirectory(logical, pageAsset(theme, logical));
|
|
27
15
|
}
|
|
28
16
|
function createThemePage(context, theme, title) {
|
|
29
17
|
const directoryPath = context.directory.current.relativePath;
|
|
@@ -32,20 +20,13 @@ function createThemePage(context, theme, title) {
|
|
|
32
20
|
mode: context.mode,
|
|
33
21
|
outputName: context.outputName,
|
|
34
22
|
assetHref: context.assetHref,
|
|
23
|
+
assetHrefForDirectory: context.assetHrefForDirectory,
|
|
24
|
+
directoryPathForEntry: context.directoryPathForEntry,
|
|
35
25
|
hrefForDirectory: context.hrefForDirectory,
|
|
36
26
|
documentBaseHref: context.documentBaseHref,
|
|
37
27
|
directoryPath
|
|
38
28
|
};
|
|
39
|
-
const dataForDirectory = (logicalPath) => context.hasPageForDirectory?.(logicalPath) === false ? null :
|
|
40
|
-
id: logicalPath,
|
|
41
|
-
name: logicalPath,
|
|
42
|
-
kind: "directory",
|
|
43
|
-
href: context.hrefForDirectory(logicalPath),
|
|
44
|
-
exitsExplorer: false,
|
|
45
|
-
size: 0,
|
|
46
|
-
modifiedAt: "",
|
|
47
|
-
link: null
|
|
48
|
-
}, safeContext, theme.name);
|
|
29
|
+
const dataForDirectory = (logicalPath) => context.hasPageForDirectory?.(logicalPath) === false ? null : context.pageDataHref?.(theme.name, logicalPath, 1) ?? context.assetHrefForDirectory(logicalPath, pageAsset(theme.name, logicalPath));
|
|
49
30
|
const entries = context.directory.entries.map((entry) => {
|
|
50
31
|
const record = projectListingEntry(entry, context);
|
|
51
32
|
return theme.entryData === void 0 ? record : {
|
|
@@ -714,7 +695,7 @@ function Ledger($$renderer, $$props) {
|
|
|
714
695
|
let virtual = $.derived(() => ready && rows().length > 500);
|
|
715
696
|
let offsets = $.derived(() => {
|
|
716
697
|
const values = [0];
|
|
717
|
-
for (const entry of rows()) values.push(values.at(-1) + (heights.get(entry.id) ??
|
|
698
|
+
for (const entry of rows()) values.push(values.at(-1) + (heights.get(entry.id) ?? 52));
|
|
718
699
|
return values;
|
|
719
700
|
});
|
|
720
701
|
let start = $.derived(() => {
|
|
@@ -762,10 +743,6 @@ function Ledger($$renderer, $$props) {
|
|
|
762
743
|
}, viewDefaults(model));
|
|
763
744
|
}
|
|
764
745
|
const isDirectory = directoryLike;
|
|
765
|
-
function safeHref(record) {
|
|
766
|
-
if (typeof location !== "undefined" && location.protocol === "file:" && isDirectory(record) && !record.exitsExplorer && record.href?.endsWith("/")) return record.href + "index.html";
|
|
767
|
-
return record.href;
|
|
768
|
-
}
|
|
769
746
|
async function hydrateData() {
|
|
770
747
|
if (complete() || !model.manifestHref || location.protocol === "file:") return;
|
|
771
748
|
const local = abort, token = navigation;
|
|
@@ -876,7 +853,7 @@ function Ledger($$renderer, $$props) {
|
|
|
876
853
|
window.removeEventListener("popstate", onPop);
|
|
877
854
|
};
|
|
878
855
|
});
|
|
879
|
-
$$renderer.push(`<header class="page-header"><div class="wordmark">`);
|
|
856
|
+
$$renderer.push(`<main data-explorer="" data-framework="svelte"${$.attr("aria-busy", busy)}><header class="page-header"><div class="wordmark">`);
|
|
880
857
|
if (header) {
|
|
881
858
|
$$renderer.push("<!--[0-->");
|
|
882
859
|
header($$renderer, { model });
|
|
@@ -893,7 +870,7 @@ function Ledger($$renderer, $$props) {
|
|
|
893
870
|
let crumb = each_array[$$index];
|
|
894
871
|
$$renderer.push(`<!---->/ <a${$.attr("href", crumb.href)}>${$.escape(crumb.name)}</a>`);
|
|
895
872
|
}
|
|
896
|
-
$$renderer.push(`<!--]--></nav></header> <
|
|
873
|
+
$$renderer.push(`<!--]--></nav></header> <div class="toolbar"><label class="search-field">${$.escape(ui().labels.searchDirectory)}<input type="search"${$.attr("placeholder", ui().labels.searchFiles)}${$.attr("value", query)}${$.attr("disabled", !ready || !complete(), true)}/></label> <fieldset${$.attr("disabled", !ready || !complete(), true)}><legend>${$.escape(ui().labels.types)}</legend><!--[-->`);
|
|
897
874
|
const each_array_1 = $.ensure_array_like([
|
|
898
875
|
"directory",
|
|
899
876
|
"file",
|
|
@@ -982,7 +959,7 @@ function Ledger($$renderer, $$props) {
|
|
|
982
959
|
$$renderer.push(`<!--]--> `);
|
|
983
960
|
if (failure === "folder" && retryRequest) $$renderer.push(`<!--[0--><a${$.attr("href", retryRequest[1])}>${$.escape(ui().labels.openNative)}</a>`);
|
|
984
961
|
else $$renderer.push("<!--[-1-->");
|
|
985
|
-
$$renderer.push(`<!--]--> <div class="entry-head"${$.attr("data-custom-columns", Boolean(model.ui?.columns))}${$.attr_style("", { "
|
|
962
|
+
$$renderer.push(`<!--]--> <div class="entry-head"${$.attr("data-custom-columns", Boolean(model.ui?.columns))}${$.attr_style("", { "--dw-entry-columns": model.ui?.columns ? ui().columns.map((column) => column === "name" ? "minmax(0,1fr)" : "minmax(0,12rem)").join(" ") : void 0 })}><!--[-->`);
|
|
986
963
|
const each_array_2 = $.ensure_array_like(ui().columns);
|
|
987
964
|
for (let $$index_2 = 0, $$length = each_array_2.length; $$index_2 < $$length; $$index_2++) {
|
|
988
965
|
let column = each_array_2[$$index_2];
|
|
@@ -998,14 +975,14 @@ function Ledger($$renderer, $$props) {
|
|
|
998
975
|
const each_array_3 = $.ensure_array_like(rows().slice(start(), end()));
|
|
999
976
|
for (let index = 0, $$length = each_array_3.length; index < $$length; index++) {
|
|
1000
977
|
let entry = each_array_3[index];
|
|
1001
|
-
$$renderer.push(`<li class="entry" data-entry=""${$.attr("data-custom-columns", Boolean(model.ui?.columns))}${$.attr("data-id", entry.id)}${$.attr("data-order", start() + index)}${$.attr("data-active", selected === entry.id)}${$.attr_style("", { "
|
|
978
|
+
$$renderer.push(`<li class="entry" data-entry=""${$.attr("data-custom-columns", Boolean(model.ui?.columns))}${$.attr("data-id", entry.id)}${$.attr("data-order", start() + index)}${$.attr("data-active", selected === entry.id)}${$.attr_style("", { "--dw-entry-columns": model.ui?.columns ? ui().columns.map((column) => column === "name" ? "minmax(0,1fr)" : "minmax(0,12rem)").join(" ") : void 0 })}><!--[-->`);
|
|
1002
979
|
const each_array_4 = $.ensure_array_like(ui().columns);
|
|
1003
980
|
for (let $$index_3 = 0, $$length = each_array_4.length; $$index_3 < $$length; $$index_3++) {
|
|
1004
981
|
let column = each_array_4[$$index_3];
|
|
1005
982
|
if (column === "name") {
|
|
1006
983
|
$$renderer.push(`<!--[0--><span class="identity">`);
|
|
1007
984
|
if (entry.href) {
|
|
1008
|
-
$$renderer.push(`<!--[0--><a class="name"${$.attr("href",
|
|
985
|
+
$$renderer.push(`<!--[0--><a class="name"${$.attr("href", entry.href)}${$.attr("target", entry.exitsExplorer ? "_blank" : void 0)}${$.attr("rel", entry.exitsExplorer ? "noopener" : void 0)}>`);
|
|
1009
986
|
if (row) {
|
|
1010
987
|
$$renderer.push("<!--[0-->");
|
|
1011
988
|
row($$renderer, {
|
|
@@ -1054,7 +1031,7 @@ function Ledger($$renderer, $$props) {
|
|
|
1054
1031
|
const each_array_5 = $.ensure_array_like(ui().actions);
|
|
1055
1032
|
for (let $$index_4 = 0, $$length = each_array_5.length; $$index_4 < $$length; $$index_4++) {
|
|
1056
1033
|
let action = each_array_5[$$index_4];
|
|
1057
|
-
if (action === "download" && entry.href && !isDirectory(entry) && !entry.link?.unavailable) $$renderer.push(`<!--[0--><a${$.attr("href",
|
|
1034
|
+
if (action === "download" && entry.href && !isDirectory(entry) && !entry.link?.unavailable) $$renderer.push(`<!--[0--><a${$.attr("href", entry.href)} download="">${$.escape(ui().labels.download)}</a>`);
|
|
1058
1035
|
else if (action !== "download") $$renderer.push(`<!--[1--><button${$.attr("disabled", !ready || action === "copy-link" && !entry.href, true)}${$.attr("aria-label", (action === "copy-link" ? ui().labels.copyLink : ui().labels.copyPath) + ": " + entry.name)}>${$.escape(action === "copy-link" ? ui().labels.copyLink : ui().labels.copyPath)}</button>`);
|
|
1059
1036
|
else $$renderer.push("<!--[-1-->");
|
|
1060
1037
|
$$renderer.push(`<!--]-->`);
|