@polyipseity/obsidian-plugin-library 1.23.2 → 1.25.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
@@ -8,8 +8,7 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
9
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
10
  }) : x)(function(x) {
11
- if (typeof require !== "undefined")
12
- return require.apply(this, arguments);
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
12
  throw Error('Dynamic require of "' + x + '" is not supported');
14
13
  });
15
14
  var __esm = (fn, res) => function __init() {
@@ -58,8 +57,7 @@ var require_lz_string = __commonJS({
58
57
  }
59
58
  var LZString2 = {
60
59
  compressToBase64: function(input) {
61
- if (input == null)
62
- return "";
60
+ if (input == null) return "";
63
61
  var res = LZString2._compress(input, 6, function(a) {
64
62
  return keyStrBase64.charAt(a);
65
63
  });
@@ -76,26 +74,21 @@ var require_lz_string = __commonJS({
76
74
  }
77
75
  },
78
76
  decompressFromBase64: function(input) {
79
- if (input == null)
80
- return "";
81
- if (input == "")
82
- return null;
77
+ if (input == null) return "";
78
+ if (input == "") return null;
83
79
  return LZString2._decompress(input.length, 32, function(index) {
84
80
  return getBaseValue(keyStrBase64, input.charAt(index));
85
81
  });
86
82
  },
87
83
  compressToUTF16: function(input) {
88
- if (input == null)
89
- return "";
84
+ if (input == null) return "";
90
85
  return LZString2._compress(input, 15, function(a) {
91
86
  return f(a + 32);
92
87
  }) + " ";
93
88
  },
94
89
  decompressFromUTF16: function(compressed) {
95
- if (compressed == null)
96
- return "";
97
- if (compressed == "")
98
- return null;
90
+ if (compressed == null) return "";
91
+ if (compressed == "") return null;
99
92
  return LZString2._decompress(compressed.length, 16384, function(index) {
100
93
  return compressed.charCodeAt(index) - 32;
101
94
  });
@@ -129,18 +122,15 @@ var require_lz_string = __commonJS({
129
122
  },
130
123
  //compress into a string that is already URI encoded
131
124
  compressToEncodedURIComponent: function(input) {
132
- if (input == null)
133
- return "";
125
+ if (input == null) return "";
134
126
  return LZString2._compress(input, 6, function(a) {
135
127
  return keyStrUriSafe.charAt(a);
136
128
  });
137
129
  },
138
130
  //decompress from an output of compressToEncodedURIComponent
139
131
  decompressFromEncodedURIComponent: function(input) {
140
- if (input == null)
141
- return "";
142
- if (input == "")
143
- return null;
132
+ if (input == null) return "";
133
+ if (input == "") return null;
144
134
  input = input.replace(/ /g, "+");
145
135
  return LZString2._decompress(input.length, 32, function(index) {
146
136
  return getBaseValue(keyStrUriSafe, input.charAt(index));
@@ -152,8 +142,7 @@ var require_lz_string = __commonJS({
152
142
  });
153
143
  },
154
144
  _compress: function(uncompressed, bitsPerChar, getCharFromInt) {
155
- if (uncompressed == null)
156
- return "";
145
+ if (uncompressed == null) return "";
157
146
  var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
158
147
  for (ii = 0; ii < uncompressed.length; ii += 1) {
159
148
  context_c = uncompressed.charAt(ii);
@@ -338,16 +327,13 @@ var require_lz_string = __commonJS({
338
327
  if (context_data_position == bitsPerChar - 1) {
339
328
  context_data.push(getCharFromInt(context_data_val));
340
329
  break;
341
- } else
342
- context_data_position++;
330
+ } else context_data_position++;
343
331
  }
344
332
  return context_data.join("");
345
333
  },
346
334
  decompress: function(compressed) {
347
- if (compressed == null)
348
- return "";
349
- if (compressed == "")
350
- return null;
335
+ if (compressed == null) return "";
336
+ if (compressed == "") return null;
351
337
  return LZString2._decompress(compressed.length, 32768, function(index) {
352
338
  return compressed.charCodeAt(index);
353
339
  });
@@ -1695,8 +1681,7 @@ function lazyProxy(initializer) {
1695
1681
  },
1696
1682
  get(target, property, receiver) {
1697
1683
  const own = Reflect.getOwnPropertyDescriptor(target, property);
1698
- if (!(own?.configurable ?? true) && // eslint-disable-next-line @typescript-eslint/no-extra-parens
1699
- (!(own?.writable ?? true) || own?.set && !own.get)) {
1684
+ if (!(own?.configurable ?? true) && (!(own?.writable ?? true) || own?.set && !own.get)) {
1700
1685
  return Reflect.get(target, property, receiver);
1701
1686
  }
1702
1687
  const ret = Reflect.get(
@@ -1756,8 +1741,7 @@ function lazyProxy(initializer) {
1756
1741
  },
1757
1742
  set(target, property, newValue, receiver) {
1758
1743
  const own = Reflect.getOwnPropertyDescriptor(target, property);
1759
- if (!(own?.configurable ?? true) && // eslint-disable-next-line @typescript-eslint/no-extra-parens
1760
- (!(own?.writable ?? true) || own?.get && !own.set) && !Reflect.set(target, property, newValue, receiver)) {
1744
+ if (!(own?.configurable ?? true) && (!(own?.writable ?? true) || own?.get && !own.set) && !Reflect.set(target, property, newValue, receiver)) {
1761
1745
  return false;
1762
1746
  }
1763
1747
  return Reflect.set(
@@ -1853,7 +1837,7 @@ function mapFirstCodePoint(str, map, mapRest = identity) {
1853
1837
  }
1854
1838
  function multireplace(self0, replacements) {
1855
1839
  return self0.replace(
1856
- alternativeRegExp(Object.keys(replacements)),
1840
+ alternativeRegExp([...replacements.keys()]),
1857
1841
  (match) => replacements.get(match) ?? match
1858
1842
  );
1859
1843
  }
@@ -1957,7 +1941,7 @@ function unexpected() {
1957
1941
  }
1958
1942
 
1959
1943
  // assets/locales.ts
1960
- import merge from "ts-deepmerge";
1944
+ import { merge } from "ts-deepmerge";
1961
1945
  function syncLocale() {
1962
1946
  return function fn(locale2) {
1963
1947
  return locale2;
@@ -2374,8 +2358,7 @@ function create_fragment(ctx) {
2374
2358
  if (is_function(
2375
2359
  /*onClose*/
2376
2360
  ctx[2]
2377
- ))
2378
- ctx[2].apply(this, arguments);
2361
+ )) ctx[2].apply(this, arguments);
2379
2362
  }))),
2380
2363
  listen(
2381
2364
  div4,
@@ -2400,12 +2383,11 @@ function create_fragment(ctx) {
2400
2383
  attr(button0, "aria-label", button0_aria_label_value);
2401
2384
  }
2402
2385
  if (setIcon_action && is_function(setIcon_action.update) && dirty & /*i18n*/
2403
- 2)
2404
- setIcon_action.update.call(
2405
- null,
2406
- /*i18n*/
2407
- ctx[1]("asset:components.find.case-sensitive-icon")
2408
- );
2386
+ 2) setIcon_action.update.call(
2387
+ null,
2388
+ /*i18n*/
2389
+ ctx[1]("asset:components.find.case-sensitive-icon")
2390
+ );
2409
2391
  if (!current || dirty & /*params*/
2410
2392
  1 && button1_class_value !== (button1_class_value = null_to_empty(`document-search-button${/*params*/
2411
2393
  ctx[0].wholeWord ? " mod-cta" : ""}`) + " _polyipseity_obsidian-plugin-library-svelte-find")) {
@@ -2417,12 +2399,11 @@ function create_fragment(ctx) {
2417
2399
  attr(button1, "aria-label", button1_aria_label_value);
2418
2400
  }
2419
2401
  if (setIcon_action_1 && is_function(setIcon_action_1.update) && dirty & /*i18n*/
2420
- 2)
2421
- setIcon_action_1.update.call(
2422
- null,
2423
- /*i18n*/
2424
- ctx[1]("asset:components.find.whole-word-icon")
2425
- );
2402
+ 2) setIcon_action_1.update.call(
2403
+ null,
2404
+ /*i18n*/
2405
+ ctx[1]("asset:components.find.whole-word-icon")
2406
+ );
2426
2407
  if (!current || dirty & /*params*/
2427
2408
  1 && button2_class_value !== (button2_class_value = null_to_empty(`document-search-button${/*params*/
2428
2409
  ctx[0].regex ? " mod-cta" : ""}`) + " _polyipseity_obsidian-plugin-library-svelte-find")) {
@@ -2434,12 +2415,11 @@ function create_fragment(ctx) {
2434
2415
  attr(button2, "aria-label", button2_aria_label_value);
2435
2416
  }
2436
2417
  if (setIcon_action_2 && is_function(setIcon_action_2.update) && dirty & /*i18n*/
2437
- 2)
2438
- setIcon_action_2.update.call(
2439
- null,
2440
- /*i18n*/
2441
- ctx[1]("asset:components.find.regex-icon")
2442
- );
2418
+ 2) setIcon_action_2.update.call(
2419
+ null,
2420
+ /*i18n*/
2421
+ ctx[1]("asset:components.find.regex-icon")
2422
+ );
2443
2423
  if (!current || dirty & /*i18n*/
2444
2424
  2 && input_placeholder_value !== (input_placeholder_value = /*i18n*/
2445
2425
  ctx[1]("components.find.input-placeholder"))) {
@@ -2460,31 +2440,28 @@ function create_fragment(ctx) {
2460
2440
  attr(button3, "aria-label", button3_aria_label_value);
2461
2441
  }
2462
2442
  if (setIcon_action_3 && is_function(setIcon_action_3.update) && dirty & /*i18n*/
2463
- 2)
2464
- setIcon_action_3.update.call(
2465
- null,
2466
- /*i18n*/
2467
- ctx[1]("asset:components.find.previous-icon")
2468
- );
2443
+ 2) setIcon_action_3.update.call(
2444
+ null,
2445
+ /*i18n*/
2446
+ ctx[1]("asset:components.find.previous-icon")
2447
+ );
2469
2448
  if (!current || dirty & /*i18n*/
2470
2449
  2 && button4_aria_label_value !== (button4_aria_label_value = /*i18n*/
2471
2450
  ctx[1]("components.find.next"))) {
2472
2451
  attr(button4, "aria-label", button4_aria_label_value);
2473
2452
  }
2474
2453
  if (setIcon_action_4 && is_function(setIcon_action_4.update) && dirty & /*i18n*/
2475
- 2)
2476
- setIcon_action_4.update.call(
2477
- null,
2478
- /*i18n*/
2479
- ctx[1]("asset:components.find.next-icon")
2480
- );
2454
+ 2) setIcon_action_4.update.call(
2455
+ null,
2456
+ /*i18n*/
2457
+ ctx[1]("asset:components.find.next-icon")
2458
+ );
2481
2459
  if (!current || dirty & /*results*/
2482
- 16)
2483
- set_data(
2484
- t6,
2485
- /*results*/
2486
- ctx[4]
2487
- );
2460
+ 16) set_data(
2461
+ t6,
2462
+ /*results*/
2463
+ ctx[4]
2464
+ );
2488
2465
  if (!current || dirty & /*i18n*/
2489
2466
  2 && button5_aria_label_value !== (button5_aria_label_value = /*i18n*/
2490
2467
  ctx[1]("components.find.close"))) {
@@ -2492,29 +2469,23 @@ function create_fragment(ctx) {
2492
2469
  }
2493
2470
  },
2494
2471
  i(local) {
2495
- if (current)
2496
- return;
2472
+ if (current) return;
2497
2473
  add_render_callback(() => {
2498
- if (!current)
2499
- return;
2500
- if (!div4_transition)
2501
- div4_transition = create_bidirectional_transition(div4, slide, {}, true);
2474
+ if (!current) return;
2475
+ if (!div4_transition) div4_transition = create_bidirectional_transition(div4, slide, {}, true);
2502
2476
  div4_transition.run(1);
2503
2477
  });
2504
2478
  current = true;
2505
2479
  },
2506
2480
  o(local) {
2507
- if (!div4_transition)
2508
- div4_transition = create_bidirectional_transition(div4, slide, {}, false);
2481
+ if (!div4_transition) div4_transition = create_bidirectional_transition(div4, slide, {}, false);
2509
2482
  div4_transition.run(0);
2510
2483
  current = false;
2511
2484
  },
2512
2485
  d(detaching) {
2513
- if (detaching)
2514
- detach(div4);
2486
+ if (detaching) detach(div4);
2515
2487
  ctx[13](null);
2516
- if (detaching && div4_transition)
2517
- div4_transition.end();
2488
+ if (detaching && div4_transition) div4_transition.end();
2518
2489
  mounted = false;
2519
2490
  run_all(dispose);
2520
2491
  }
@@ -2574,24 +2545,17 @@ function instance($$self, $$props, $$invalidate) {
2574
2545
  }
2575
2546
  };
2576
2547
  $$self.$$set = ($$props2) => {
2577
- if ("i18n" in $$props2)
2578
- $$invalidate(1, i18n = $$props2.i18n);
2579
- if ("params" in $$props2)
2580
- $$invalidate(0, params = $$props2.params);
2581
- if ("onClose" in $$props2)
2582
- $$invalidate(2, onClose = $$props2.onClose);
2583
- if ("onFind" in $$props2)
2584
- $$invalidate(3, onFind = $$props2.onFind);
2585
- if ("onParamsChanged" in $$props2)
2586
- $$invalidate(6, onParamsChanged = $$props2.onParamsChanged);
2587
- if ("results" in $$props2)
2588
- $$invalidate(4, results = $$props2.results);
2548
+ if ("i18n" in $$props2) $$invalidate(1, i18n = $$props2.i18n);
2549
+ if ("params" in $$props2) $$invalidate(0, params = $$props2.params);
2550
+ if ("onClose" in $$props2) $$invalidate(2, onClose = $$props2.onClose);
2551
+ if ("onFind" in $$props2) $$invalidate(3, onFind = $$props2.onFind);
2552
+ if ("onParamsChanged" in $$props2) $$invalidate(6, onParamsChanged = $$props2.onParamsChanged);
2553
+ if ("results" in $$props2) $$invalidate(4, results = $$props2.results);
2589
2554
  };
2590
2555
  $$self.$$.update = () => {
2591
2556
  if ($$self.$$.dirty & /*onParamsChanged, params*/
2592
2557
  65) {
2593
- $:
2594
- onParamsChanged(params);
2558
+ $: onParamsChanged(params);
2595
2559
  }
2596
2560
  };
2597
2561
  return [
@@ -2724,37 +2688,10 @@ async function revealPrivateAsync(context, args, func, fallback) {
2724
2688
  context.language.value.t("errors.private-API-changed"),
2725
2689
  error
2726
2690
  );
2727
- return await fallback(error);
2691
+ return fallback(error);
2728
2692
  }
2729
2693
  }
2730
2694
 
2731
- // sources/platform.ts
2732
- var Platform;
2733
- ((Platform2) => {
2734
- Platform2.DESKTOP = deepFreeze(["darwin", "linux", "win32"]);
2735
- Platform2.MOBILE = deepFreeze(["android", "ios"]);
2736
- Platform2.ALL = deepFreeze([...Platform2.DESKTOP, ...Platform2.MOBILE, "unknown"]);
2737
- Platform2.CURRENT = (() => {
2738
- const { userAgent } = self.navigator;
2739
- if (userAgent.includes("like Mac")) {
2740
- return "ios";
2741
- }
2742
- if (userAgent.includes("Android")) {
2743
- return "android";
2744
- }
2745
- if (userAgent.includes("Mac")) {
2746
- return "darwin";
2747
- }
2748
- if (userAgent.includes("Win")) {
2749
- return "win32";
2750
- }
2751
- if (userAgent.includes("Linux") || userAgent.includes("X11")) {
2752
- return "linux";
2753
- }
2754
- return "unknown";
2755
- })();
2756
- })(Platform || (Platform = {}));
2757
-
2758
2695
  // sources/obsidian.ts
2759
2696
  import { around } from "monkey-around";
2760
2697
  import { saveAs } from "file-saver";
@@ -3112,9 +3049,9 @@ function recordViewStateHistory(context, result) {
3112
3049
  }, noop2);
3113
3050
  }
3114
3051
  async function saveFileAs(context, adapter, data) {
3115
- const { CURRENT, MOBILE } = Platform;
3116
- if (inSet(MOBILE, CURRENT)) {
3117
- await revealPrivateAsync(context, [adapter], async ({ fs }) => {
3052
+ if (await revealPrivateAsync(context, [adapter], async ({ fs }) => {
3053
+ if ("open" in fs && fs.open.length === 1) {
3054
+ const { length } = fs.open;
3118
3055
  await fs.open(
3119
3056
  (await Filesystem.writeFile({
3120
3057
  data: await data.text(),
@@ -3123,7 +3060,10 @@ async function saveFileAs(context, adapter, data) {
3123
3060
  path: data.name
3124
3061
  })).uri
3125
3062
  );
3126
- }, noop2);
3063
+ return true;
3064
+ }
3065
+ return false;
3066
+ }, constant(false))) {
3127
3067
  return;
3128
3068
  }
3129
3069
  saveAs(data);
@@ -4190,6 +4130,36 @@ function patchWindows(workspace, patcher) {
4190
4130
  }
4191
4131
  }
4192
4132
 
4133
+ // sources/platform.ts
4134
+ import { Platform as Platform0 } from "obsidian";
4135
+ var Platform;
4136
+ ((Platform2) => {
4137
+ Platform2.DESKTOP = deepFreeze(["darwin", "linux", "win32"]);
4138
+ Platform2.MOBILE = deepFreeze(["android", "ios"]);
4139
+ Platform2.ALL = deepFreeze([...Platform2.DESKTOP, ...Platform2.MOBILE, "unknown"]);
4140
+ Platform2.CURRENT = (() => {
4141
+ if (Platform0.isIosApp) {
4142
+ return "ios";
4143
+ }
4144
+ if (Platform0.isAndroidApp) {
4145
+ return "android";
4146
+ }
4147
+ if (Platform0.isDesktopApp) {
4148
+ const { userAgent } = self.navigator;
4149
+ if (userAgent.includes("Mac")) {
4150
+ return "darwin";
4151
+ }
4152
+ if (userAgent.includes("Win")) {
4153
+ return "win32";
4154
+ }
4155
+ if (userAgent.includes("Linux") || userAgent.includes("X11")) {
4156
+ return "linux";
4157
+ }
4158
+ }
4159
+ return "unknown";
4160
+ })();
4161
+ })(Platform || (Platform = {}));
4162
+
4193
4163
  // sources/settings.ts
4194
4164
  import { constant as constant4, isEmpty as isEmpty3, isNil as isNil3, throttle } from "lodash-es";
4195
4165
  import deepEqual2 from "deep-equal";
@@ -4212,8 +4182,8 @@ var AbstractSettingsManager = class extends ResourceComponent {
4212
4182
  let prev = accessor(this.value);
4213
4183
  return this.#onMutate.listen(async () => {
4214
4184
  const settings = this.value, cur = accessor(settings), prev0 = prev;
4215
- if (prev0 !== cur) {
4216
- prev = cur;
4185
+ prev = cur;
4186
+ if (!deepEqual2(cur, prev0, { strict: true })) {
4217
4187
  await callback(cur, prev0, settings);
4218
4188
  }
4219
4189
  });