@tishlang/tish-desktop-api 1.1.1 → 1.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tishlang/tish-desktop-api",
3
- "version": "1.1.1",
3
+ "version": "1.2.2",
4
4
  "description": "Core UI bridge and app-api façade (invoke, listen, state.*) — no UI kit dependency",
5
5
  "license": "PIF",
6
6
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
- "@tishlang/tish-desktop-shared": "1.1.1"
43
+ "@tishlang/tish-desktop-shared": "1.2.2"
44
44
  },
45
45
  "keywords": [
46
46
  "tish",
package/src/appApi.tish CHANGED
@@ -6,7 +6,9 @@ import { EVT_STATE_CHANGED } from "@tishlang/tish-desktop-shared"
6
6
  fn bridge() {
7
7
  let g = globalThis
8
8
  let b = g.__TISH_APP__
9
- if (b === null || b === undefined) b = g.__TISH_DESKTOP__
9
+ if (b === null || b === undefined) {
10
+ b = g.__TISH_DESKTOP__
11
+ }
10
12
  if (b === null || b === undefined) {
11
13
  console.error("tish-app bridge not installed — import bridge.js or web-bridge.js first")
12
14
  return null
@@ -16,7 +18,9 @@ fn bridge() {
16
18
 
17
19
  export fn getCurrentWindowLabel() {
18
20
  let b = bridge()
19
- if (b === null) return "main"
21
+ if (b === null) {
22
+ return "main"
23
+ }
20
24
  return b.getCurrentWindowLabel()
21
25
  }
22
26
 
@@ -56,9 +60,15 @@ export fn statePatch(path, value) {
56
60
  export fn useSharedState(path, onChange) {
57
61
  return listen(EVT_STATE_CHANGED, (payload) => {
58
62
  let p = payload.path
59
- if (p === undefined) p = payload.key
60
- if (path !== null && path !== undefined && p !== path) return
61
- if (onChange) onChange(payload.value, p, payload.revision, payload.source)
63
+ if (p === undefined) {
64
+ p = payload.key
65
+ }
66
+ if (path !== null && path !== undefined && p !== path) {
67
+ return
68
+ }
69
+ if (onChange) {
70
+ onChange(payload.value, p, payload.revision, payload.source)
71
+ }
62
72
  })
63
73
  }
64
74
 
package/src/bridge.js CHANGED
@@ -36,11 +36,20 @@ export function installBridge() {
36
36
  protocol: "desktop/v1",
37
37
  surface: "webview",
38
38
  getCurrentWindowLabel() {
39
+ if (typeof g.__TISH_WINDOW_LABEL__ === "string" && g.__TISH_WINDOW_LABEL__) {
40
+ return g.__TISH_WINDOW_LABEL__;
41
+ }
39
42
  try {
40
- return g.__TAURI__?.webviewWindow?.getCurrentWebviewWindow?.()?.label ?? "main";
43
+ const l =
44
+ g.__TAURI__?.webviewWindow?.getCurrentWebviewWindow?.()?.label ??
45
+ g.__TAURI__?.window?.getCurrentWindow?.()?.label;
46
+ if (typeof l === "string" && l) return l;
41
47
  } catch {
42
- return "main";
48
+ /* fall through */
43
49
  }
50
+ return typeof g.__TISH_WINDOW_LABEL__ === "string" && g.__TISH_WINDOW_LABEL__
51
+ ? g.__TISH_WINDOW_LABEL__
52
+ : "main";
44
53
  },
45
54
  async invoke(cmd, args = {}) {
46
55
  const core = g.__TAURI__?.core;
@@ -1,15 +1,4 @@
1
1
  // UI façade over window.__TISH_APP__ / __TISH_DESKTOP__ (injected by bridge.js).
2
2
  // Re-exports app-api helpers for backward compatibility.
3
3
 
4
- export {
5
- getCurrentWindowLabel,
6
- invoke,
7
- listen,
8
- emit,
9
- stateGet,
10
- stateSet,
11
- statePatch,
12
- useSharedState,
13
- Platform,
14
- PROTOCOL,
15
- } from "./appApi.tish"
4
+ export { getCurrentWindowLabel, invoke, listen, emit, stateGet, stateSet, statePatch, useSharedState, Platform, PROTOCOL } from "./appApi.tish"