@dirwell/theme-ledger 0.0.1 → 0.0.3
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 +13 -1
- package/dist/client.js +25 -25
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +16 -33
- package/dist/index.mjs.map +1 -1
- package/dist/{model-B0qQsjRT.d.mts → model-CeW-leLg.d.mts} +5 -3
- package/dist/model.d.mts +1 -1
- package/dist/source/Ledger.svelte +76 -19
- package/dist/source/shared/live-search.mjs +28 -0
- package/dist/source/shared/navigation.mjs +1 -0
- 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 : {
|
|
@@ -67,6 +48,10 @@ function createThemePage(context, theme, title) {
|
|
|
67
48
|
manifestHref: context.listing?.manifestHref ?? null,
|
|
68
49
|
...context.listing ? { listingRevision: context.listing.revision } : {},
|
|
69
50
|
updatesHref: context.updatesHref ?? null,
|
|
51
|
+
...context.searchQueryHref ? {
|
|
52
|
+
searchQueryHref: context.searchQueryHref,
|
|
53
|
+
searchRefreshIntervalMs: context.searchRefreshIntervalMs
|
|
54
|
+
} : {},
|
|
70
55
|
total: context.listing?.page.total ?? entries.length,
|
|
71
56
|
entries,
|
|
72
57
|
sort: context.sort,
|
|
@@ -530,6 +515,7 @@ async function fetchThemePage(dataHref, pageHref, theme, signal, fresh = false,
|
|
|
530
515
|
if (data.ui !== void 0) resolveCustomization(data.ui);
|
|
531
516
|
const result = {
|
|
532
517
|
...data,
|
|
518
|
+
searchQueryHref: link(data.searchQueryHref ?? null),
|
|
533
519
|
updatesHref: link(data.updatesHref ?? null),
|
|
534
520
|
entries,
|
|
535
521
|
dataHref: source.href,
|
|
@@ -757,10 +743,6 @@ function Ledger($$renderer, $$props) {
|
|
|
757
743
|
}, viewDefaults(model));
|
|
758
744
|
}
|
|
759
745
|
const isDirectory = directoryLike;
|
|
760
|
-
function safeHref(record) {
|
|
761
|
-
if (typeof location !== "undefined" && location.protocol === "file:" && isDirectory(record) && !record.exitsExplorer && record.href?.endsWith("/")) return record.href + "index.html";
|
|
762
|
-
return record.href;
|
|
763
|
-
}
|
|
764
746
|
async function hydrateData() {
|
|
765
747
|
if (complete() || !model.manifestHref || location.protocol === "file:") return;
|
|
766
748
|
const local = abort, token = navigation;
|
|
@@ -969,7 +951,7 @@ function Ledger($$renderer, $$props) {
|
|
|
969
951
|
});
|
|
970
952
|
});
|
|
971
953
|
$$renderer.push(`</label> `);
|
|
972
|
-
if (model.searchIndexHref) $$renderer.push(`<!--[0--><button${$.attr("disabled", !ready
|
|
954
|
+
if (model.searchIndexHref || model.searchQueryHref) $$renderer.push(`<!--[0--><button${$.attr("disabled", !ready, true)}>${$.escape(ui().labels.searchArchive)}</button>`);
|
|
973
955
|
else $$renderer.push("<!--[-1-->");
|
|
974
956
|
$$renderer.push(`<!--]--></div> <section class="listing-card"><div class="listing-summary">${$.escape(countParts()[0])}<span data-visible-count="">${$.escape(complete() ? rows().length : entries.length)}</span>${$.escape(countParts().slice(1).join("__COUNT__"))}<span role="status" aria-live="polite">${$.escape(busy ? ui().labels.loading : error)}</span></div> `);
|
|
975
957
|
if (failure && failure !== "copy") $$renderer.push(`<!--[0--><button${$.attr("disabled", busy, true)}>${$.escape(ui().labels.retry)}</button>`);
|
|
@@ -1000,7 +982,7 @@ function Ledger($$renderer, $$props) {
|
|
|
1000
982
|
if (column === "name") {
|
|
1001
983
|
$$renderer.push(`<!--[0--><span class="identity">`);
|
|
1002
984
|
if (entry.href) {
|
|
1003
|
-
$$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)}>`);
|
|
1004
986
|
if (row) {
|
|
1005
987
|
$$renderer.push("<!--[0-->");
|
|
1006
988
|
row($$renderer, {
|
|
@@ -1049,7 +1031,7 @@ function Ledger($$renderer, $$props) {
|
|
|
1049
1031
|
const each_array_5 = $.ensure_array_like(ui().actions);
|
|
1050
1032
|
for (let $$index_4 = 0, $$length = each_array_5.length; $$index_4 < $$length; $$index_4++) {
|
|
1051
1033
|
let action = each_array_5[$$index_4];
|
|
1052
|
-
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>`);
|
|
1053
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>`);
|
|
1054
1036
|
else $$renderer.push("<!--[-1-->");
|
|
1055
1037
|
$$renderer.push(`<!--]-->`);
|
|
@@ -1121,7 +1103,8 @@ function createLedgerTheme(options = {}, renderer) {
|
|
|
1121
1103
|
const model = {
|
|
1122
1104
|
...createThemePage(context, theme, options.title ?? ui.brand.name ?? "Dirwell"),
|
|
1123
1105
|
...publishedUi === void 0 ? {} : { ui: publishedUi },
|
|
1124
|
-
searchIndexHref: theme.searchIndex === false ? null : context.searchIndexHref
|
|
1106
|
+
searchIndexHref: theme.searchIndex === false ? null : context.searchIndexHref,
|
|
1107
|
+
searchQueryHref: theme.searchIndex === false ? null : context.searchQueryHref ?? null
|
|
1125
1108
|
};
|
|
1126
1109
|
const { script, scriptName, styles } = await loadResources();
|
|
1127
1110
|
const json = JSON.stringify(model).replaceAll("<", "\\u003c");
|