@wizzlethorpe/vaults 0.13.0 → 0.13.1

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.
@@ -855,10 +855,13 @@ async function applyInstance(vault, vaultPath, meta) {
855
855
  const id = typeof fm.id === "string" && fm.id ? fm.id : await instanceId(vault.id, vaultPath);
856
856
  const dataJson = fm.data_json && typeof fm.data_json === "object" && !Array.isArray(fm.data_json) ? rewriteVaultPaths(structuredClone(fm.data_json), vault.id) : null;
857
857
  if (dataJson) await ensureEmbeddedIds(dataJson, vault.id, vaultPath);
858
- const overlay = await buildOverlay(vault, vaultPath, meta, docName);
858
+ const derived = {};
859
+ const overlay = await buildOverlay(vault, vaultPath, meta, docName, derived);
860
+ const tokenFloor = derived.tokenTexture && !dataJson?.prototypeToken?.texture?.src && !fm?.data?.prototypeToken?.texture?.src ? { prototypeToken: { texture: { src: derived.tokenTexture } } } : null;
859
861
  const existing = collection.get(id);
860
862
  if (existing) {
861
- const updatePatch = dataJson ? deepMerge(structuredClone(dataJson), overlay) : overlay;
863
+ const base = tokenFloor ? deepMerge(structuredClone(tokenFloor), dataJson ?? {}) : dataJson;
864
+ const updatePatch = base ? deepMerge(structuredClone(base), overlay) : overlay;
862
865
  try {
863
866
  await existing.update(updatePatch);
864
867
  } catch (err) {
@@ -866,6 +869,7 @@ async function applyInstance(vault, vaultPath, meta) {
866
869
  }
867
870
  return;
868
871
  }
872
+ if (tokenFloor) deepMerge(baseData, tokenFloor);
869
873
  if (dataJson) deepMerge(baseData, dataJson);
870
874
  baseData._id = id;
871
875
  deepMerge(baseData, overlay);
@@ -959,7 +963,7 @@ async function ensureInstanceFolder(vault, docName) {
959
963
  return null;
960
964
  }
961
965
  }
962
- async function buildOverlay(vault, vaultPath, meta, docName) {
966
+ async function buildOverlay(vault, vaultPath, meta, docName, derived = {}) {
963
967
  const overlay = {
964
968
  // Prefer the page's frontmatter `title:` over the filename — the wiki
965
969
  // already treats title as the page's display name, and a doc named
@@ -973,7 +977,7 @@ async function buildOverlay(vault, vaultPath, meta, docName) {
973
977
  const localImg = imageUrlFromMeta(vault.id, meta.image);
974
978
  if (localImg) {
975
979
  overlay.img = localImg;
976
- if (docName === "Actor") setPath(overlay, "prototypeToken.texture.src", localImg);
980
+ if (docName === "Actor") derived.tokenTexture = localImg;
977
981
  }
978
982
  }
979
983
  const fm = meta?.foundry;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wizzlethorpe/vaults",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Sync an Obsidian vault to a Cloudflare-hosted wiki with role-based access. Renders locally, deploys to Cloudflare Pages.",
5
5
  "keywords": [
6
6
  "obsidian",