x-essential-lib 0.11.12 → 0.11.13

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.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as EventType, t as Emitter } from "./vendor.nkww20g1.js";
1
+ import { n as EventType, t as Emitter } from "./vendor.hsixv85u.js";
2
2
  import { Ref } from "vue";
3
3
  import { VuetifyOptions } from "vuetify";
4
4
  import { AxiosInstance } from "axios";
@@ -185,7 +185,7 @@ export declare function useSystem(): {
185
185
  isMobile: () => boolean;
186
186
  compactWidth: import("vue").ComputedRef<string>;
187
187
  minimizeApp: () => Promise<void>;
188
- safeAreaInset: {
188
+ safeAreaInsets: {
189
189
  top: number;
190
190
  bottom: number;
191
191
  left: number;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(){try{document.getElementById(`x-essential-lib`)?.remove();const e = document.createElement(`style`);e.setAttribute(`id`, `x-essential-lib`);const t = document.createTextNode(`.fade-leave-active[data-v-x-essential-lib-c3545c8d]{transition:opacity .5s}.fade-leave-to[data-v-x-essential-lib-c3545c8d]{opacity:0}.x-cont[data-v-x-essential-lib-c3545c8d]{justify-content:center;align-items:center;display:flex;position:absolute;inset:0;overflow:hidden}.lds-spinner[data-v-x-essential-lib-c3545c8d]{color:official;width:40px;height:40px;display:inline-block;position:relative}.lds-spinner div[data-v-x-essential-lib-c3545c8d]{transform-origin:20px 20px;animation:1.2s linear infinite lds-spinner-x-essential-lib-c3545c8d}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:after{content:" ";background:#9e9e9e;border-radius:5%;width:2px;height:6px;display:block;position:absolute;top:3px;left:18px}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:first-child{animation-delay:-1.1s;transform:rotate(0)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(2){animation-delay:-1s;transform:rotate(30deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(3){animation-delay:-.9s;transform:rotate(60deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(4){animation-delay:-.8s;transform:rotate(90deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(5){animation-delay:-.7s;transform:rotate(120deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(6){animation-delay:-.6s;transform:rotate(150deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(7){animation-delay:-.5s;transform:rotate(180deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(8){animation-delay:-.4s;transform:rotate(210deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(9){animation-delay:-.3s;transform:rotate(240deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(10){animation-delay:-.2s;transform:rotate(270deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(11){animation-delay:-.1s;transform:rotate(300deg)}.lds-spinner div[data-v-x-essential-lib-c3545c8d]:nth-child(12){animation-delay:0s;transform:rotate(330deg)}@keyframes lds-spinner-x-essential-lib-c3545c8d{0%{opacity:1}to{opacity:0}}.x-item[data-v-x-essential-lib-cfcda9d9]{width:600px}@media (width<=600px){.x-item[data-v-x-essential-lib-cfcda9d9]{width:calc(100vw - 16px)}}.x-cont[data-v-x-essential-lib-b973907d]{z-index:9999;position:fixed;bottom:50px;left:50%;transform:translate(-50%)}`);e.appendChild(t);document.head.appendChild(e);}catch(e){console.error('rolldown-plugin-inject-css', e);}})()
2
- import { a as invoke, c as string, d as usePreferredDark, i as debounce, l as api, o as custom, r as toLower, s as email$1, u as mitt_default } from "./vendor.nkww20g1.js";
2
+ import { a as minimizeApp, c as isTauri, d as string, f as api, i as mergeInsets, l as custom, m as usePreferredDark, o as toLower, p as mitt_default, r as insets, s as debounce, u as email$1 } from "./vendor.hsixv85u.js";
3
3
  import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, isRef, normalizeStyle, onBeforeMount, onBeforeUnmount, onMounted, onUnmounted, openBlock, provide, reactive, ref, renderList, resolveComponent, toDisplayString, unref, useTemplateRef, watch, watchEffect, withCtx, withKeys, withModifiers } from "vue";
4
4
  import { useI18n } from "vue-i18n";
5
5
  import { useDisplay, useTheme } from "vuetify";
@@ -702,35 +702,33 @@ function useSystem() {
702
702
  else if (display.width.value <= 1920) return "768px";
703
703
  else return "1024px";
704
704
  });
705
- async function minimizeApp() {
705
+ async function minimizeApp$1() {
706
706
  navigator.Backbutton?.goHome(() => {}, () => {});
707
- invoke("goHome");
707
+ if (isTauri()) await minimizeApp();
708
708
  }
709
- const safeAreaInset = reactive({
709
+ const safeAreaInsets = reactive({
710
710
  top: 0,
711
711
  bottom: 0,
712
712
  left: 0,
713
713
  right: 0
714
714
  });
715
- function getSafeAreaVar(name) {
716
- const str = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
717
- return parseFloat(str) || 0;
718
- }
719
- function syncSafeArea() {
720
- safeAreaInset.top = getSafeAreaVar("--safe-area-inset-top");
721
- safeAreaInset.bottom = getSafeAreaVar("--safe-area-inset-bottom");
722
- safeAreaInset.left = getSafeAreaVar("--safe-area-inset-left");
723
- safeAreaInset.right = getSafeAreaVar("--safe-area-inset-right");
715
+ async function syncInsets() {
716
+ const result = await insets();
717
+ const { top, bottom, left, right } = mergeInsets(result.statusBars, result.navigationBars, result.displayCutout);
718
+ safeAreaInsets.top = top;
719
+ safeAreaInsets.bottom = bottom;
720
+ safeAreaInsets.left = left;
721
+ safeAreaInsets.right = right;
724
722
  }
725
723
  const handleResize = debounce(() => {
726
- syncSafeArea();
724
+ syncInsets();
727
725
  }, 250);
728
726
  function onResize() {
729
727
  handleResize();
730
728
  }
731
729
  onMounted(() => {
732
730
  window.addEventListener("resize", onResize);
733
- syncSafeArea();
731
+ syncInsets();
734
732
  });
735
733
  onUnmounted(() => {
736
734
  window.removeEventListener("resize", onResize);
@@ -759,8 +757,8 @@ function useSystem() {
759
757
  return {
760
758
  isMobile,
761
759
  compactWidth,
762
- minimizeApp,
763
- safeAreaInset,
760
+ minimizeApp: minimizeApp$1,
761
+ safeAreaInsets,
764
762
  nameList,
765
763
  sentenceOfAsk
766
764
  };
@@ -4677,6 +4677,28 @@ var Resource = class {
4677
4677
  await this.close();
4678
4678
  }
4679
4679
  };
4680
+ /**
4681
+ * Checks whether the code is running inside a Tauri webview.
4682
+ *
4683
+ * Useful for frontends that are also served on the web, to guard calls to APIs
4684
+ * that only exist inside the application.
4685
+ *
4686
+ * @example
4687
+ * ```typescript
4688
+ * import { isTauri } from '@tauri-apps/api/core';
4689
+ * import { getVersion } from '@tauri-apps/api/app';
4690
+ *
4691
+ * const version = isTauri() ? await getVersion() : 'web';
4692
+ * ```
4693
+ *
4694
+ * @returns `true` when running inside a Tauri app, `false` otherwise (e.g. in a
4695
+ * browser or in unit tests).
4696
+ *
4697
+ * @since 2.0.0
4698
+ */
4699
+ function isTauri() {
4700
+ return !!(globalThis || window).isTauri;
4701
+ }
4680
4702
 
4681
4703
  //#endregion
4682
4704
  //#region node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js
@@ -5209,6 +5231,34 @@ function toLower(value) {
5209
5231
  return toString(value).toLowerCase();
5210
5232
  }
5211
5233
 
5234
+ //#endregion
5235
+ //#region node_modules/.pnpm/tauri-plugin-z9@0.1.4/node_modules/tauri-plugin-z9/dist-js/index.mjs
5236
+ async function minimizeApp() {
5237
+ return await invoke("plugin:z9|minimize_app");
5238
+ }
5239
+ async function insets() {
5240
+ return await invoke("plugin:z9|insets");
5241
+ }
5242
+ function mergeInsets(...allInsets) {
5243
+ let top = 0;
5244
+ let bottom = 0;
5245
+ let left = 0;
5246
+ let right = 0;
5247
+ for (const insets of allInsets) {
5248
+ if (!insets) continue;
5249
+ if (insets.top > top) top = insets.top;
5250
+ if (insets.bottom > bottom) bottom = insets.bottom;
5251
+ if (insets.left > left) left = insets.left;
5252
+ if (insets.right > right) right = insets.right;
5253
+ }
5254
+ return {
5255
+ top,
5256
+ bottom,
5257
+ left,
5258
+ right
5259
+ };
5260
+ }
5261
+
5212
5262
  //#endregion
5213
5263
  //#region node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/index.d.ts
5214
5264
  var [EventType] = [
@@ -5383,4 +5433,4 @@ var [Emitter] = [
5383
5433
  ];
5384
5434
 
5385
5435
  //#endregion
5386
- export { invoke as a, string as c, usePreferredDark as d, debounce as i, api as l, EventType as n, custom as o, toLower as r, email as s, Emitter as t, mitt_default as u };
5436
+ export { minimizeApp as a, isTauri as c, string as d, api as f, mergeInsets as i, custom as l, usePreferredDark as m, EventType as n, toLower as o, mitt_default as p, insets as r, debounce as s, Emitter as t, email as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-essential-lib",
3
- "version": "0.11.12",
3
+ "version": "0.11.13",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -44,11 +44,12 @@
44
44
  "picomatch": "^4.0.7",
45
45
  "rolldown": "^1.2.12",
46
46
  "sass": "^1.105.1",
47
+ "tauri-plugin-z9": "^0.1.4",
47
48
  "tsdown": "^0.23.0",
48
49
  "typescript": "^6.0.3",
49
50
  "vite": "^8.3.2",
50
51
  "vue-tsc": "^3.3.12",
51
- "x-config-lib": "^0.1.10",
52
+ "x-config-lib": "^0.1.11",
52
53
  "x-config-oxfmt": "^0.1.7",
53
54
  "x-config-oxlint": "^0.1.8",
54
55
  "zod": "^4.6.5"