@polyipseity/obsidian-plugin-library 1.33.1 → 1.34.0

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.js CHANGED
@@ -1602,8 +1602,8 @@ function typedOwnKeys(self0) {
1602
1602
  function typedKeys() {
1603
1603
  return (obj) => deepFreeze(Object.keys(obj));
1604
1604
  }
1605
- function inSet(set2, obj) {
1606
- return contravariant(set2).includes(obj);
1605
+ function inSet(set, obj) {
1606
+ return contravariant(set).includes(obj);
1607
1607
  }
1608
1608
  function insertAt(self0, index, ...items) {
1609
1609
  self0.splice(index, 0, ...items);
@@ -2162,12 +2162,12 @@ var LibraryLocales;
2162
2162
  // src/components/find.svelte
2163
2163
  import "svelte/internal/disclose-version";
2164
2164
  import { t as i18nt } from "i18next";
2165
- import { isEmpty as isEmpty2 } from "lodash-es";
2165
+ import { isEmpty as isEmpty2, noop as noop2 } from "lodash-es";
2166
2166
  import { onMount } from "svelte";
2167
2167
  import { setIcon } from "obsidian";
2168
2168
  import { slide } from "svelte/transition";
2169
2169
  import * as $ from "svelte/internal/client";
2170
- var root = $.from_html(`<div class="document-search-container" role="search"><div class="document-search _polyipseity_obsidian-plugin-library-svelte-find"><div class="document-search-buttons"><button></button> <button></button> <button></button></div> <input class="document-search-input" type="text" role="searchbox"/> <div class="document-search-buttons"><button class="document-search-button"></button> <button class="document-search-button"></button> <div class="document-search-results"> </div> <button class="document-search-close-button"></button></div></div></div>`);
2170
+ var root = $.from_html(`<div class="document-search-container" role="search"><div class="document-search _polyipseity_obsidian-plugin-library-svelte-find"><div class="document-search-buttons"><button type="button"></button> <button type="button"></button> <button type="button"></button></div> <input class="document-search-input" type="text" role="searchbox"/> <div class="document-search-buttons"><button type="button" class="document-search-button"></button> <button type="button" class="document-search-button"></button> <div class="document-search-results" aria-live="polite"> </div> <button type="button" class="document-search-close-button"></button></div></div></div>`);
2171
2171
  var $$css = {
2172
2172
  hash: "_polyipseity_obsidian-plugin-library-svelte-find",
2173
2173
  code: ".document-search._polyipseity_obsidian-plugin-library-svelte-find {flex-wrap:wrap;}.is-mobile .document-search._polyipseity_obsidian-plugin-library-svelte-find .document-search-button.mod-cta:where(._polyipseity_obsidian-plugin-library-svelte-find) {background-color:var(--interactive-accent);color:var(--text-on-accent);}"
@@ -2175,30 +2175,15 @@ var $$css = {
2175
2175
  function Find($$anchor, $$props) {
2176
2176
  $.push($$props, true);
2177
2177
  $.append_styles($$anchor, $$css);
2178
- const i18n = $.prop($$props, "i18n", 3, i18nt), params = $.prop($$props, "params", 19, () => ({
2178
+ const i18n = $.prop($$props, "i18n", 3, i18nt), params = $.prop($$props, "params", 31, () => $.proxy({
2179
2179
  caseSensitive: false,
2180
2180
  findText: "",
2181
2181
  regex: false,
2182
2182
  wholeWord: false
2183
- })), onClose = $.prop($$props, "onClose", 3, () => {
2184
- }), onFind = $.prop($$props, "onFind", 3, (_direction, _params) => {
2185
- }), onParamsChanged = $.prop($$props, "onParamsChanged", 3, (_params) => {
2186
- }), results = $.prop($$props, "results", 3, ""), focused = $.prop($$props, "focused", 3, false);
2187
- let stateI18n = $.state(i18n());
2188
- const stateParams = $.proxy(cloneAsWritable(params()));
2189
- let stateResults = $.state(results());
2183
+ })), results = $.prop($$props, "results", 3, ""), onClose = $.prop($$props, "onClose", 3, noop2), onFind = $.prop($$props, "onFind", 3, noop2), onParamsChanged = $.prop($$props, "onParamsChanged", 3, noop2), initialFocus = $.prop($$props, "initialFocus", 3, false);
2190
2184
  $.user_effect(() => {
2191
- onParamsChanged()(stateParams);
2185
+ onParamsChanged()(params());
2192
2186
  });
2193
- function setI18n(i18n0) {
2194
- $.set(stateI18n, i18n0);
2195
- }
2196
- function getParamsRef() {
2197
- return stateParams;
2198
- }
2199
- function setResults(results0) {
2200
- $.set(stateResults, results0);
2201
- }
2202
2187
  let inputElement = null;
2203
2188
  function focus() {
2204
2189
  inputElement === null || inputElement === void 0 ? void 0 : inputElement.focus();
@@ -2206,31 +2191,31 @@ function Find($$anchor, $$props) {
2206
2191
  function blur() {
2207
2192
  inputElement === null || inputElement === void 0 ? void 0 : inputElement.blur();
2208
2193
  }
2209
- if (focused()) {
2194
+ if (initialFocus()) {
2210
2195
  onMount(focus);
2211
2196
  }
2212
- var $$exports = { setI18n, getParamsRef, setResults, focus, blur };
2197
+ var $$exports = { focus, blur };
2213
2198
  var div = root();
2214
2199
  var div_1 = $.child(div);
2215
2200
  var div_2 = $.child(div_1);
2216
2201
  var button = $.child(div_2);
2217
2202
  button.__click = (event) => {
2218
- stateParams.caseSensitive = !stateParams.caseSensitive;
2203
+ params(params().caseSensitive = !params().caseSensitive, true);
2219
2204
  consumeEvent(event);
2220
2205
  };
2221
- $.action(button, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.case-sensitive-icon"));
2206
+ $.action(button, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.case-sensitive-icon"));
2222
2207
  var button_1 = $.sibling(button, 2);
2223
2208
  button_1.__click = (event) => {
2224
- stateParams.wholeWord = !stateParams.wholeWord;
2209
+ params(params().wholeWord = !params().wholeWord, true);
2225
2210
  consumeEvent(event);
2226
2211
  };
2227
- $.action(button_1, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.whole-word-icon"));
2212
+ $.action(button_1, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.whole-word-icon"));
2228
2213
  var button_2 = $.sibling(button_1, 2);
2229
2214
  button_2.__click = (event) => {
2230
- stateParams.regex = !stateParams.regex;
2215
+ params(params().regex = !params().regex, true);
2231
2216
  consumeEvent(event);
2232
2217
  };
2233
- $.action(button_2, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.regex-icon"));
2218
+ $.action(button_2, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.regex-icon"));
2234
2219
  $.reset(div_2);
2235
2220
  var input = $.sibling(div_2, 2);
2236
2221
  $.remove_input_defaults(input);
@@ -2239,21 +2224,25 @@ function Find($$anchor, $$props) {
2239
2224
  onClose()();
2240
2225
  consumeEvent(event);
2241
2226
  }
2227
+ if (event.key === "Enter" && isEmpty2(getKeyModifiers(event))) {
2228
+ onFind()("next", params());
2229
+ consumeEvent(event);
2230
+ }
2242
2231
  };
2243
2232
  $.bind_this(input, ($$value) => inputElement = $$value, () => inputElement);
2244
2233
  var div_3 = $.sibling(input, 2);
2245
2234
  var button_3 = $.child(div_3);
2246
2235
  button_3.__click = (event) => {
2247
- onFind()("previous", stateParams);
2236
+ onFind()("previous", params());
2248
2237
  consumeEvent(event);
2249
2238
  };
2250
- $.action(button_3, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.previous-icon"));
2239
+ $.action(button_3, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.previous-icon"));
2251
2240
  var button_4 = $.sibling(button_3, 2);
2252
2241
  button_4.__click = (event) => {
2253
- onFind()("next", stateParams);
2242
+ onFind()("next", params());
2254
2243
  consumeEvent(event);
2255
2244
  };
2256
- $.action(button_4, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.next-icon"));
2245
+ $.action(button_4, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.next-icon"));
2257
2246
  var div_4 = $.sibling(button_4, 2);
2258
2247
  var text = $.child(div_4, true);
2259
2248
  $.reset(div_4);
@@ -2262,35 +2251,35 @@ function Find($$anchor, $$props) {
2262
2251
  onClose()();
2263
2252
  consumeEvent(event);
2264
2253
  };
2265
- $.action(button_5, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => $.get(stateI18n)("asset:components.find.close-icon"));
2254
+ $.action(button_5, ($$node, $$action_arg) => setIcon?.($$node, $$action_arg), () => i18n()("asset:components.find.close-icon"));
2266
2255
  $.reset(div_3);
2267
2256
  $.reset(div_1);
2268
2257
  $.reset(div);
2269
2258
  $.template_effect(
2270
2259
  ($0, $1, $2, $3, $4, $5, $6) => {
2271
- $.set_class(button, 1, `document-search-button${stateParams.caseSensitive ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
2260
+ $.set_class(button, 1, `document-search-button${params().caseSensitive ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
2272
2261
  $.set_attribute(button, "aria-label", $0);
2273
- $.set_class(button_1, 1, `document-search-button${stateParams.wholeWord ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
2262
+ $.set_class(button_1, 1, `document-search-button${params().wholeWord ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
2274
2263
  $.set_attribute(button_1, "aria-label", $1);
2275
- $.set_class(button_2, 1, `document-search-button${stateParams.regex ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
2264
+ $.set_class(button_2, 1, `document-search-button${params().regex ? " mod-cta" : ""}`, "_polyipseity_obsidian-plugin-library-svelte-find");
2276
2265
  $.set_attribute(button_2, "aria-label", $2);
2277
2266
  $.set_attribute(input, "placeholder", $3);
2278
2267
  $.set_attribute(button_3, "aria-label", $4);
2279
2268
  $.set_attribute(button_4, "aria-label", $5);
2280
- $.set_text(text, $.get(stateResults));
2269
+ $.set_text(text, results());
2281
2270
  $.set_attribute(button_5, "aria-label", $6);
2282
2271
  },
2283
2272
  [
2284
- () => $.get(stateI18n)("components.find.case-sensitive"),
2285
- () => $.get(stateI18n)("components.find.whole-word"),
2286
- () => $.get(stateI18n)("components.find.regex"),
2287
- () => $.get(stateI18n)("components.find.input-placeholder"),
2288
- () => $.get(stateI18n)("components.find.previous"),
2289
- () => $.get(stateI18n)("components.find.next"),
2290
- () => $.get(stateI18n)("components.find.close")
2273
+ () => i18n()("components.find.case-sensitive"),
2274
+ () => i18n()("components.find.whole-word"),
2275
+ () => i18n()("components.find.regex"),
2276
+ () => i18n()("components.find.input-placeholder"),
2277
+ () => i18n()("components.find.previous"),
2278
+ () => i18n()("components.find.next"),
2279
+ () => i18n()("components.find.close")
2291
2280
  ]
2292
2281
  );
2293
- $.bind_value(input, () => stateParams.findText, ($$value) => stateParams.findText = $$value);
2282
+ $.bind_value(input, () => params().findText, ($$value) => params(params().findText = $$value, true));
2294
2283
  $.transition(3, div, () => slide);
2295
2284
  $.append($$anchor, div);
2296
2285
  return $.pop($$exports);
@@ -2333,9 +2322,9 @@ function fixArray(defaults, from, key, types) {
2333
2322
  const default1 = default0;
2334
2323
  return default1.map(primitiveOfE);
2335
2324
  }
2336
- function fixInSet(defaults, from, key, set2) {
2325
+ function fixInSet(defaults, from, key, set) {
2337
2326
  const val = from[key];
2338
- return inSet(set2, val) ? val : defaults[key];
2327
+ return inSet(set, val) ? val : defaults[key];
2339
2328
  }
2340
2329
 
2341
2330
  // src/documentation.ts
@@ -2356,7 +2345,7 @@ import {
2356
2345
  ValueComponent
2357
2346
  } from "obsidian";
2358
2347
  import { Directory, Encoding, Filesystem } from "@capacitor/filesystem";
2359
- import { cloneDeep, constant, noop as noop2 } from "lodash-es";
2348
+ import { cloneDeep, constant, noop as noop3 } from "lodash-es";
2360
2349
 
2361
2350
  // src/private.ts
2362
2351
  function revealPrivate(context, args, func, fallback) {
@@ -2509,7 +2498,7 @@ var UpdatableUI = class {
2509
2498
  try {
2510
2499
  if ("onChange" in comp && typeof comp.onChange === "function") {
2511
2500
  try {
2512
- comp.onChange(noop2);
2501
+ comp.onChange(noop3);
2513
2502
  } catch (error) {
2514
2503
  activeSelf(settingEl).console.error(error);
2515
2504
  }
@@ -2595,7 +2584,7 @@ var UpdatableUI = class {
2595
2584
  }
2596
2585
  };
2597
2586
  function statusUI(ui, element) {
2598
- ui.new(constant(element), noop2, () => {
2587
+ ui.new(constant(element), noop3, () => {
2599
2588
  element.textContent = null;
2600
2589
  });
2601
2590
  return deepFreeze({
@@ -2770,8 +2759,8 @@ ${error.name}: ${error.message}`,
2770
2759
  activeSelf(noticeEl).console.error(`${message()}
2771
2760
  `, error);
2772
2761
  }
2773
- function readStateCollaboratively(implType, state2) {
2774
- return launderUnchecked(state2)[implType];
2762
+ function readStateCollaboratively(implType, state) {
2763
+ return launderUnchecked(state)[implType];
2775
2764
  }
2776
2765
  function recordViewStateHistory(context, result) {
2777
2766
  revealPrivate(
@@ -2780,7 +2769,7 @@ function recordViewStateHistory(context, result) {
2780
2769
  (result0) => {
2781
2770
  result0.history = true;
2782
2771
  },
2783
- noop2
2772
+ noop3
2784
2773
  );
2785
2774
  }
2786
2775
  async function saveFileAs(context, adapter, data) {
@@ -2816,7 +2805,7 @@ function updateView(context, view) {
2816
2805
  leaf.updateHeader();
2817
2806
  workspace.requestUpdateLayout();
2818
2807
  },
2819
- noop2
2808
+ noop3
2820
2809
  );
2821
2810
  if ("titleEl" in view) {
2822
2811
  const { titleEl } = view;
@@ -2845,8 +2834,8 @@ function useSubsettings(element) {
2845
2834
  }
2846
2835
  return ret;
2847
2836
  }
2848
- function writeStateCollaboratively(state2, implType, implState) {
2849
- return Object.assign(launderUnchecked(state2), { [implType]: implState });
2837
+ function writeStateCollaboratively(state, implType, implState) {
2838
+ return Object.assign(launderUnchecked(state), { [implType]: implState });
2850
2839
  }
2851
2840
 
2852
2841
  // src/documentation.ts
@@ -2941,15 +2930,15 @@ var DocumentationMarkdownView = class _DocumentationMarkdownView extends ItemVie
2941
2930
  } = this;
2942
2931
  return key === null ? super.getIcon() : i18n.t(key);
2943
2932
  }
2944
- async setState(state2, result) {
2933
+ async setState(state, result) {
2945
2934
  const { context, element } = this, ownState = readStateCollaboratively(
2946
2935
  _DocumentationMarkdownView.type.namespaced(context),
2947
- state2
2936
+ state
2948
2937
  ), { value, valid } = _DocumentationMarkdownView.State.fix(ownState);
2949
2938
  if (!valid) {
2950
2939
  printMalformedData(context, ownState, value);
2951
2940
  }
2952
- await super.setState(state2, result);
2941
+ await super.setState(state, result);
2953
2942
  const { data } = value;
2954
2943
  this.state = value;
2955
2944
  await MarkdownRenderer.render(this.app, data, element, "", this);
@@ -2981,7 +2970,7 @@ var Registered0 = class {
2981
2970
  constructor(context) {
2982
2971
  this.context = context;
2983
2972
  }
2984
- async open(active, state2) {
2973
+ async open(active, state) {
2985
2974
  const {
2986
2975
  context,
2987
2976
  context: {
@@ -2998,7 +2987,7 @@ var Registered0 = class {
2998
2987
  /* @__PURE__ */ new Map([
2999
2988
  [
3000
2989
  DocumentationMarkdownView.type,
3001
- state2
2990
+ state
3002
2991
  ]
3003
2992
  ])
3004
2993
  ),
@@ -3231,7 +3220,7 @@ function importable(...args) {
3231
3220
  }
3232
3221
 
3233
3222
  // src/keys.ts
3234
- import { constant as constant2, noop as noop3 } from "lodash-es";
3223
+ import { constant as constant2, noop as noop4 } from "lodash-es";
3235
3224
  import { around as around2 } from "monkey-around";
3236
3225
  function newHotkeyListener(context, ids) {
3237
3226
  const {
@@ -3292,7 +3281,7 @@ function newHotkeyListener(context, ids) {
3292
3281
  this0.baked = false;
3293
3282
  }
3294
3283
  },
3295
- noop3
3284
+ noop4
3296
3285
  );
3297
3286
  next.apply(this, args);
3298
3287
  };
@@ -3317,11 +3306,11 @@ function newHotkeyListener(context, ids) {
3317
3306
  }
3318
3307
  return true;
3319
3308
  },
3320
- noop3
3309
+ noop4
3321
3310
  );
3322
3311
  };
3323
3312
  },
3324
- constant2(noop3)
3313
+ constant2(noop4)
3325
3314
  );
3326
3315
  }
3327
3316
 
@@ -3329,7 +3318,7 @@ function newHotkeyListener(context, ids) {
3329
3318
  import {
3330
3319
  Modal
3331
3320
  } from "obsidian";
3332
- import { constant as constant3, noop as noop4 } from "lodash-es";
3321
+ import { constant as constant3, noop as noop5 } from "lodash-es";
3333
3322
 
3334
3323
  // src/settings-widgets.ts
3335
3324
  function closeSetting(container) {
@@ -3484,7 +3473,7 @@ var ListModal = class _ListModal extends Modal {
3484
3473
  this.placeholder = placeholder;
3485
3474
  this.modalUI = new UpdatableUI();
3486
3475
  this.ui = new UpdatableUI();
3487
- this.#setupListSubUI = noop4;
3476
+ this.#setupListSubUI = noop5;
3488
3477
  this.data = [...data];
3489
3478
  this.#inputter = inputter;
3490
3479
  this.#callback = options?.callback ?? (() => {
@@ -3935,7 +3924,7 @@ var DialogModal = class extends Modal {
3935
3924
  });
3936
3925
  this.#title = options?.title;
3937
3926
  this.#description = options?.description;
3938
- this.#draw = options?.draw ?? noop4;
3927
+ this.#draw = options?.draw ?? noop5;
3939
3928
  }
3940
3929
  #cancel;
3941
3930
  #confirm;
@@ -4040,7 +4029,7 @@ var DialogModal = class extends Modal {
4040
4029
  };
4041
4030
 
4042
4031
  // src/patch.ts
4043
- import { constant as constant4, noop as noop5 } from "lodash-es";
4032
+ import { constant as constant4, noop as noop6 } from "lodash-es";
4044
4033
  import { around as around3 } from "monkey-around";
4045
4034
  async function patchPlugin(context, id, patcher) {
4046
4035
  return revealPrivateAsync(
@@ -4098,7 +4087,7 @@ async function patchPlugin(context, id, patcher) {
4098
4087
  throw error;
4099
4088
  }
4100
4089
  },
4101
- constant4(noop5)
4090
+ constant4(noop6)
4102
4091
  );
4103
4092
  }
4104
4093
  function patchWindows(workspace, patcher) {