dsh-tiddlywiki 0.22.2 → 0.22.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/lib/index.js CHANGED
@@ -5732,6 +5732,27 @@ async function ensurePlugin(wikiPath, twRoot, name) {
5732
5732
  await writeWikiInfo(wikiPath, info);
5733
5733
  return true;
5734
5734
  }
5735
+ /**
5736
+ * The theme the TW runtime is ACTUALLY showing, as a catalog-style name
5737
+ * (`tiddlywiki/heavier`), or undefined when unknown (wiki down, no `$:/theme`).
5738
+ *
5739
+ * `$:/theme` holds the active theme title and is normally written as
5740
+ * `$:/themes/<name>` (that is what this route's own POST writes), but a user
5741
+ * who picked a theme in TW's Control Panel can leave the fully-qualified
5742
+ * title there — strip the prefix so both shapes compare against the catalog.
5743
+ * Without this the settings page could only guess "the last loaded theme"
5744
+ * (v0.22.3), and one click on 应用主题 silently overwrote the real choice.
5745
+ */
5746
+ async function readActiveThemeName(client) {
5747
+ try {
5748
+ const tiddler = await client?.get("$:/theme");
5749
+ const raw = typeof tiddler?.text === "string" ? tiddler.text.trim() : "";
5750
+ if (raw.length === 0) return void 0;
5751
+ return raw.startsWith("$:/themes/") ? raw.slice(10) : raw;
5752
+ } catch {
5753
+ return;
5754
+ }
5755
+ }
5735
5756
  /** Enumerate bundled official plugins + themes + languages of tiddlywiki. */
5736
5757
  async function bundledCatalog(twRoot) {
5737
5758
  const themeHasCss = async (dir) => {
@@ -5953,6 +5974,7 @@ function registerAdminRoutes(ctx, deps) {
5953
5974
  git = null;
5954
5975
  }
5955
5976
  const view = deps.server.status();
5977
+ const themeActive = await readActiveThemeName(deps.getClient());
5956
5978
  json(res, {
5957
5979
  ok: true,
5958
5980
  server: {
@@ -5962,7 +5984,8 @@ function registerAdminRoutes(ctx, deps) {
5962
5984
  info: {
5963
5985
  plugins: info.plugins,
5964
5986
  themes: info.themes,
5965
- languages: info.languages ?? []
5987
+ languages: info.languages ?? [],
5988
+ themeActive
5966
5989
  },
5967
5990
  catalog,
5968
5991
  config: maskConfigSecrets(deps.config.get()),
@@ -9695,6 +9718,6 @@ function apply(ctx, rawConfig = {}) {
9695
9718
  }, "dsh-tiddlywiki: host teardown");
9696
9719
  }
9697
9720
  //#endregion
9698
- export { AGENT_WRITTEN_TAG, ALL_ARTICLES_MARKER_TITLE, ALL_ARTICLES_TEXT, ALL_ARTICLES_TITLE, AutoCommitter, CLIP_BRIDGE_BOOKMARKLET, CLIP_BRIDGE_DEFAULT_PORT, CLIP_BRIDGE_DOC_TEXT, CLIP_BRIDGE_DOC_TITLE, CLIP_BRIDGE_DRAG_HREF, CLIP_BRIDGE_MARKER_TITLE, ClipBridge, ConfigStore, DEFAULT_NOTE_TYPE, DEFAULT_PROMPT_MODE, DOC_NOTE_TAG, DOC_NOTE_TEXT, DOC_NOTE_TITLE, DSH_DOCS_TAG, GitFace, HOME_DEFAULT_TIDDLERS, HOME_INDEX_ITEMS, HOME_INDEX_MARKER_TITLE, HUMAN_EDITED_TAG, LOCATION_STATE_VERSION, MARKDOWN_PLUGIN, MASKED_SECRET, MENUBAR_THEME_MARKER_TITLE, MENUBAR_THEME_TEXT, MENUBAR_THEME_TIDDLER, MISSING_TYPE_FILTER, PATH_PREFIX, PROMPT_GOVERNANCE_BLOCKS, PROMPT_MODES, PROMPT_SECTION_NAME, PROMPT_SECTION_ORDER, RENDER_BUNDLE_TEXT, RENDER_MARKER_TITLE, RENDER_PLUGIN_FILE, RENDER_PLUGIN_TITLE, SEED_DEFS, SEED_MARKER_VERSION, SEND_TO_AGENT_BUNDLE_TEXT, SEND_TO_AGENT_MARKER_TITLE, SEND_TO_AGENT_PLUGIN_TITLE, SESSION_SUMMARY_PREFIX, STARTER_DOCS_ITEMS, STARTER_DOCS_MARKER_TITLE, TEXT_LIST_FILTER, TRASH_INDEX_TITLE, TRASH_PREFIX, TW_PROXY_PATH, TW_PROXY_PREFIX, TW_WEB_HOST_DEFAULT, TW_WEB_HOST_TIDDLER, TiddlyWebClient, TrashIndexUnavailableError, UI_STYLES_MARKER_TITLE, UI_STYLE_ITEMS, WikiServer, WriteConflictError, apply, assertNoConflict, assertPublicImageUrl, buildBinaryTiddler, buildClipTiddler, buildImageNoteTiddler, buildPromptText, buildWriteTiddler, bundledCatalog, checkAllSeeds, cleanTiddler, clearLocationState, deepMerge, defaultLocationStateFile, defineTool, docNoteText, downloadClipImage, dshHomePath, ensureLanguage, ensurePlugin, ensureTwWebHost, escapeInline, escapePromptBraces, expandEnvPath, flattenTiddlerFields, flushPendingWrites, hashText, hostAllowed, imageExtensionForMime, inject, isBinaryType, isPrivateAddress, isSafeUrl, listWikiCandidates, locationPath, maskConfigSecrets, name, needsRestartAfterSeeds, normalizeLocation, normalizePromptMode, normalizeThemes, openInTwEditor, parseClipPayload, parseSeedMarker, pickImageMime, readLocationState, readSeedMarker, readWikiInfo, registerAdminRoutes, registerRoutes, registerTiddlywikiTools, removeSeedById, resolveClipTitle, resolveTwRoot, runAllSeeds, runSeedById, sanitizeTwFragment, seedAllArticles, seedClipBridge, seedDocNote, seedHomeIndex, seedMenubarTheme, seedRenderRoute, seedSendToAgent, seedStarterDocs, seedUiStyles, stripMaskedSecrets, switchWiki, tiddlywikiToolSummary, toolSignatureLines, unseedClipBridge, waitForFileWrite, writeLocationState, writeSeedMarker, writeSessionSummary, writeWikiInfo };
9721
+ export { AGENT_WRITTEN_TAG, ALL_ARTICLES_MARKER_TITLE, ALL_ARTICLES_TEXT, ALL_ARTICLES_TITLE, AutoCommitter, CLIP_BRIDGE_BOOKMARKLET, CLIP_BRIDGE_DEFAULT_PORT, CLIP_BRIDGE_DOC_TEXT, CLIP_BRIDGE_DOC_TITLE, CLIP_BRIDGE_DRAG_HREF, CLIP_BRIDGE_MARKER_TITLE, ClipBridge, ConfigStore, DEFAULT_NOTE_TYPE, DEFAULT_PROMPT_MODE, DOC_NOTE_TAG, DOC_NOTE_TEXT, DOC_NOTE_TITLE, DSH_DOCS_TAG, GitFace, HOME_DEFAULT_TIDDLERS, HOME_INDEX_ITEMS, HOME_INDEX_MARKER_TITLE, HUMAN_EDITED_TAG, LOCATION_STATE_VERSION, MARKDOWN_PLUGIN, MASKED_SECRET, MENUBAR_THEME_MARKER_TITLE, MENUBAR_THEME_TEXT, MENUBAR_THEME_TIDDLER, MISSING_TYPE_FILTER, PATH_PREFIX, PROMPT_GOVERNANCE_BLOCKS, PROMPT_MODES, PROMPT_SECTION_NAME, PROMPT_SECTION_ORDER, RENDER_BUNDLE_TEXT, RENDER_MARKER_TITLE, RENDER_PLUGIN_FILE, RENDER_PLUGIN_TITLE, SEED_DEFS, SEED_MARKER_VERSION, SEND_TO_AGENT_BUNDLE_TEXT, SEND_TO_AGENT_MARKER_TITLE, SEND_TO_AGENT_PLUGIN_TITLE, SESSION_SUMMARY_PREFIX, STARTER_DOCS_ITEMS, STARTER_DOCS_MARKER_TITLE, TEXT_LIST_FILTER, TRASH_INDEX_TITLE, TRASH_PREFIX, TW_PROXY_PATH, TW_PROXY_PREFIX, TW_WEB_HOST_DEFAULT, TW_WEB_HOST_TIDDLER, TiddlyWebClient, TrashIndexUnavailableError, UI_STYLES_MARKER_TITLE, UI_STYLE_ITEMS, WikiServer, WriteConflictError, apply, assertNoConflict, assertPublicImageUrl, buildBinaryTiddler, buildClipTiddler, buildImageNoteTiddler, buildPromptText, buildWriteTiddler, bundledCatalog, checkAllSeeds, cleanTiddler, clearLocationState, deepMerge, defaultLocationStateFile, defineTool, docNoteText, downloadClipImage, dshHomePath, ensureLanguage, ensurePlugin, ensureTwWebHost, escapeInline, escapePromptBraces, expandEnvPath, flattenTiddlerFields, flushPendingWrites, hashText, hostAllowed, imageExtensionForMime, inject, isBinaryType, isPrivateAddress, isSafeUrl, listWikiCandidates, locationPath, maskConfigSecrets, name, needsRestartAfterSeeds, normalizeLocation, normalizePromptMode, normalizeThemes, openInTwEditor, parseClipPayload, parseSeedMarker, pickImageMime, readActiveThemeName, readLocationState, readSeedMarker, readWikiInfo, registerAdminRoutes, registerRoutes, registerTiddlywikiTools, removeSeedById, resolveClipTitle, resolveTwRoot, runAllSeeds, runSeedById, sanitizeTwFragment, seedAllArticles, seedClipBridge, seedDocNote, seedHomeIndex, seedMenubarTheme, seedRenderRoute, seedSendToAgent, seedStarterDocs, seedUiStyles, stripMaskedSecrets, switchWiki, tiddlywikiToolSummary, toolSignatureLines, unseedClipBridge, waitForFileWrite, writeLocationState, writeSeedMarker, writeSessionSummary, writeWikiInfo };
9699
9722
 
9700
9723
  //# sourceMappingURL=index.js.map