@dirwell/theme-crosswave 0.0.2 → 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/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-Dr7YgDTv.mjs";
1
+ import { a as ThemeAction, c as ThemeLabels, i as ThemePage, o as ThemeColumn, s as ThemeCustomization, t as FrameworkRenderer } from "./model-Bvw3-a6R.mjs";
2
2
  import { ExplorerTheme, ListingEntry } from "@dirwell/core";
3
3
  //#region src/icons.d.ts
4
4
  type CrosswaveIcon = "all" | "folder" | "image" | "audio" | "video" | "document" | "other" | "link" | "back" | "search" | "pause" | "play" | "controller";
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 mime from "mime";
6
5
  import { computed, createSSRApp, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, unref, watch, watchEffect } from "vue";
7
6
  import { renderToString, ssrIncludeBooleanAttr, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderClass, ssrRenderDynamicAttr, ssrRenderList, ssrRenderSlot, ssrRenderStyle } from "vue/server-renderer";
@@ -11,20 +10,9 @@ import { ListingDataError, loadListing, parseListingEntries } from "@dirwell/cor
11
10
  const pageAsset = (theme, directory, page = 1) => `${theme}-page-${createHash("sha256").update(directory).digest("hex").slice(0, 24)}-${page}.json`;
12
11
  function folderDataHref(entry, context, theme) {
13
12
  if (entry.exitsExplorer || entry.href === null || !(entry.kind === "directory" || entry.link?.targetKind === "directory")) return null;
14
- const fake = "https://dirwell.invalid/";
15
- const base = new URL(context.documentBaseHref ?? `${context.directoryPath ? context.directoryPath + "/" : ""}`, fake);
16
- const root = new URL(context.hrefForDirectory(""), base);
17
- const target = new URL(entry.href, base);
18
- const rootPath = root.pathname.endsWith("/") ? root.pathname : root.pathname.slice(0, root.pathname.lastIndexOf("/") + 1);
19
- const directoryPath = target.pathname.endsWith("/") ? target.pathname : target.pathname.slice(0, target.pathname.lastIndexOf("/") + 1);
20
- const logical = directoryPath.slice(rootPath.length).split("/").filter(Boolean).map(decodeURIComponent).join("/");
21
- const filename = pageAsset(theme, logical);
22
- if (context.pageDataHref !== void 0) return context.pageDataHref(theme, logical, 1);
23
- if (context.mode === "mpa") return context.assetHref(filename);
24
- const href = new URL(filename, new URL(directoryPath, target));
25
- if (href.origin !== new URL(fake).origin) return href.href;
26
- 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("/");
27
- return href.pathname;
13
+ const logical = context.directoryPathForEntry(entry.id);
14
+ if (logical === null) return null;
15
+ return context.pageDataHref?.(theme, logical, 1) ?? context.assetHrefForDirectory(logical, pageAsset(theme, logical));
28
16
  }
29
17
  function createThemePage(context, theme, title) {
30
18
  const directoryPath = context.directory.current.relativePath;
@@ -33,20 +21,13 @@ function createThemePage(context, theme, title) {
33
21
  mode: context.mode,
34
22
  outputName: context.outputName,
35
23
  assetHref: context.assetHref,
24
+ assetHrefForDirectory: context.assetHrefForDirectory,
25
+ directoryPathForEntry: context.directoryPathForEntry,
36
26
  hrefForDirectory: context.hrefForDirectory,
37
27
  documentBaseHref: context.documentBaseHref,
38
28
  directoryPath
39
29
  };
40
- const dataForDirectory = (logicalPath) => context.hasPageForDirectory?.(logicalPath) === false ? null : folderDataHref({
41
- id: logicalPath,
42
- name: logicalPath,
43
- kind: "directory",
44
- href: context.hrefForDirectory(logicalPath),
45
- exitsExplorer: false,
46
- size: 0,
47
- modifiedAt: "",
48
- link: null
49
- }, safeContext, theme.name);
30
+ const dataForDirectory = (logicalPath) => context.hasPageForDirectory?.(logicalPath) === false ? null : context.pageDataHref?.(theme.name, logicalPath, 1) ?? context.assetHrefForDirectory(logicalPath, pageAsset(theme.name, logicalPath));
50
31
  const entries = context.directory.entries.map((entry) => {
51
32
  const record = projectListingEntry(entry, context);
52
33
  return theme.entryData === void 0 ? record : {
@@ -1135,9 +1116,6 @@ var App_server_default = {
1135
1116
  if (listScroll.value) listScroll.value.scrollTop = 0;
1136
1117
  });
1137
1118
  let wave, gamepad, abort, navigation = 0, timer, lastPad = 0, pressed = /* @__PURE__ */ new Set(), disposed = false, padIdentity = null, motionQuery;
1138
- function safeHref(entry) {
1139
- return typeof location !== "undefined" && location.protocol === "file:" && directoryLike(entry) && !entry.exitsExplorer && entry.href?.endsWith("/") ? entry.href + "index.html" : entry.href;
1140
- }
1141
1119
  async function loadComplete() {
1142
1120
  if (complete.value || !model.value.manifestHref || location.protocol === "file:") return;
1143
1121
  const local = abort, token = navigation;
@@ -1531,7 +1509,7 @@ var App_server_default = {
1531
1509
  ssrRenderList(visibleRows.value, (entry, visibleIndex) => {
1532
1510
  _push(`<li${ssrRenderAttr("aria-posinset", start.value + visibleIndex + 1)}${ssrRenderAttr("aria-setsize", rows.value.length)} class="${ssrRenderClass(["cw-row", { "cw-selected": active.value?.id === entry.id }])}" data-cw-entry${ssrRenderAttr("data-custom-columns", Boolean(model.value.ui?.columns))}${ssrRenderAttr("data-id", entry.id)}>`);
1533
1511
  if (entry.href) {
1534
- _push(`<a class="cw-entry"${ssrRenderAttr("href", safeHref(entry))}${ssrRenderAttr("target", entry.exitsExplorer ? "_blank" : void 0)}${ssrRenderAttr("rel", entry.exitsExplorer ? "noopener" : void 0)}>`);
1512
+ _push(`<a class="cw-entry"${ssrRenderAttr("href", entry.href)}${ssrRenderAttr("target", entry.exitsExplorer ? "_blank" : void 0)}${ssrRenderAttr("rel", entry.exitsExplorer ? "noopener" : void 0)}>`);
1535
1513
  ssrRenderSlot(_ctx.$slots, "row", {
1536
1514
  model: model.value,
1537
1515
  entry,
@@ -1576,7 +1554,7 @@ var App_server_default = {
1576
1554
  _push(`<!--[-->`);
1577
1555
  ssrRenderList(ui.value.actions, (action) => {
1578
1556
  _push(`<!--[-->`);
1579
- if (action === "download" && entry.href && !unref(directoryLike)(entry) && !entry.link?.unavailable) _push(`<a${ssrRenderAttr("href", safeHref(entry))} download>${ssrInterpolate(ui.value.labels.download)}</a>`);
1557
+ if (action === "download" && entry.href && !unref(directoryLike)(entry) && !entry.link?.unavailable) _push(`<a${ssrRenderAttr("href", entry.href)} download>${ssrInterpolate(ui.value.labels.download)}</a>`);
1580
1558
  else if (action !== "download") _push(`<button${ssrIncludeBooleanAttr(!ready.value || action === "copy-link" && !entry.href) ? " disabled" : ""}${ssrRenderAttr("aria-label", (action === "copy-link" ? ui.value.labels.copyLink : ui.value.labels.copyPath) + ": " + entry.name)}>${ssrInterpolate(action === "copy-link" ? ui.value.labels.copyLink : ui.value.labels.copyPath)}</button>`);
1581
1559
  else _push(`<!---->`);
1582
1560
  _push(`<!--]-->`);