winui-svelte 0.0.3 → 0.0.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.
Files changed (102) hide show
  1. package/API.md +118 -6
  2. package/README.md +70 -90
  3. package/dist/bindings/.dynwinrt-managed +1 -1
  4. package/dist/components/convert.d.ts +3 -3
  5. package/dist/components/convert.d.ts.map +1 -1
  6. package/dist/components/fluent-glyph.d.ts +4 -0
  7. package/dist/components/fluent-glyph.d.ts.map +1 -1
  8. package/dist/components/generated/controls/FontIcon.svelte.d.ts +1 -1
  9. package/dist/components/generated/controls/FontIconSource.svelte.d.ts +1 -1
  10. package/dist/components/generated/controls/UIElement.svelte.d.ts +1 -1
  11. package/dist/components/index.d.ts +3 -1
  12. package/dist/components/index.d.ts.map +1 -1
  13. package/dist/css/runtime/resources.d.ts +1 -1
  14. package/dist/dev/dev-window.d.ts +23 -0
  15. package/dist/dev/dev-window.d.ts.map +1 -0
  16. package/dist/dev/dev-window.js +42 -0
  17. package/dist/dev/dev-window.js.map +1 -0
  18. package/dist/dev/index.d.ts +3 -0
  19. package/dist/dev/index.d.ts.map +1 -0
  20. package/dist/dev/index.js +2 -0
  21. package/dist/dev/index.js.map +1 -0
  22. package/dist/dev/start-dev.d.ts +47 -0
  23. package/dist/dev/start-dev.d.ts.map +1 -0
  24. package/dist/dev/start-dev.js +81 -0
  25. package/dist/dev/start-dev.js.map +1 -0
  26. package/dist/enums.d.ts +2 -0
  27. package/dist/enums.d.ts.map +1 -1
  28. package/dist/enums.js +2 -0
  29. package/dist/enums.js.map +1 -1
  30. package/dist/web-apis/window-geometry.d.ts +39 -0
  31. package/dist/web-apis/window-geometry.d.ts.map +1 -0
  32. package/dist/web-apis/window-geometry.js +95 -0
  33. package/dist/web-apis/window-geometry.js.map +1 -0
  34. package/dist/win2d/Canvas.svelte +1 -0
  35. package/dist/window/anchor.d.ts +92 -0
  36. package/dist/window/anchor.d.ts.map +1 -0
  37. package/dist/window/anchor.js +100 -0
  38. package/dist/window/anchor.js.map +1 -0
  39. package/dist/window/backdrop.d.ts +4 -1
  40. package/dist/window/backdrop.d.ts.map +1 -1
  41. package/dist/window/backdrop.js +10 -2
  42. package/dist/window/backdrop.js.map +1 -1
  43. package/dist/window/create-window.d.ts +1 -1
  44. package/dist/window/create-window.d.ts.map +1 -1
  45. package/dist/window/create-window.js +3 -1
  46. package/dist/window/create-window.js.map +1 -1
  47. package/dist/window/css-pixels.d.ts +14 -0
  48. package/dist/window/css-pixels.d.ts.map +1 -0
  49. package/dist/window/css-pixels.js +12 -0
  50. package/dist/window/css-pixels.js.map +1 -0
  51. package/dist/window/dock.d.ts +51 -0
  52. package/dist/window/dock.d.ts.map +1 -0
  53. package/dist/window/dock.js +69 -0
  54. package/dist/window/dock.js.map +1 -0
  55. package/dist/window/index.d.ts +4 -0
  56. package/dist/window/index.d.ts.map +1 -1
  57. package/dist/window/index.js +2 -0
  58. package/dist/window/index.js.map +1 -1
  59. package/dist/window/native.d.ts +2 -0
  60. package/dist/window/native.d.ts.map +1 -1
  61. package/dist/window/native.js +10 -0
  62. package/dist/window/native.js.map +1 -1
  63. package/dist/window/transparent-backdrop.d.ts +11 -0
  64. package/dist/window/transparent-backdrop.d.ts.map +1 -0
  65. package/dist/window/transparent-backdrop.js +35 -0
  66. package/dist/window/transparent-backdrop.js.map +1 -0
  67. package/dist/window/window-handle.d.ts +17 -0
  68. package/dist/window/window-handle.d.ts.map +1 -1
  69. package/dist/window/window-handle.js +23 -0
  70. package/dist/window/window-handle.js.map +1 -1
  71. package/dist/window/window-host.svelte.d.ts +17 -12
  72. package/dist/window/window-host.svelte.d.ts.map +1 -1
  73. package/dist/window/window-host.svelte.js +168 -14
  74. package/dist/window/window-host.svelte.js.map +1 -1
  75. package/dist/winui.d.ts +5 -0
  76. package/dist/winui.d.ts.map +1 -1
  77. package/dist/winui.js +5 -0
  78. package/dist/winui.js.map +1 -1
  79. package/package.json +25 -7
  80. package/src/components/convert.ts +3 -3
  81. package/src/components/fluent-glyph.ts +6 -0
  82. package/src/components/generated/controls/FontIcon.svelte.ts +1 -1
  83. package/src/components/generated/controls/FontIconSource.svelte.ts +1 -1
  84. package/src/components/generated/controls/UIElement.svelte.ts +1 -1
  85. package/src/components/index.ts +3 -1
  86. package/src/dev/dev-window.ts +63 -0
  87. package/src/dev/index.ts +2 -0
  88. package/src/dev/start-dev.ts +120 -0
  89. package/src/enums.ts +2 -0
  90. package/src/web-apis/window-geometry.ts +106 -0
  91. package/src/window/anchor.ts +156 -0
  92. package/src/window/backdrop.ts +11 -2
  93. package/src/window/create-window.ts +5 -1
  94. package/src/window/css-pixels.ts +18 -0
  95. package/src/window/dock.ts +99 -0
  96. package/src/window/index.ts +4 -0
  97. package/src/window/native.ts +12 -0
  98. package/src/window/transparent-backdrop.ts +38 -0
  99. package/src/window/window-handle.ts +26 -0
  100. package/src/window/window-host.svelte.ts +210 -27
  101. package/src/winui.ts +5 -0
  102. package/web-types.json +3203 -1507
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-window.d.ts","sourceRoot":"","sources":["../../src/dev/dev-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,yGAAyG;AACzG,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;AAE5H,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,WAAW,CAAC;IACrB,kGAAkG;IAClG,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B,MAAM,EAAE,eAAe,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,aAAa,iBAoCrD"}
@@ -0,0 +1,42 @@
1
+ import { createWindowModuleRunner } from "../vite/runner.js";
2
+ import { runOnUiThread } from "../window/thread.js";
3
+ /**
4
+ * The window's side of `startDev`: enters the apartment, loads the component
5
+ * through the module server (so a saved file updates the open window) and
6
+ * opens it in a window.
7
+ */
8
+ export async function runDevWindow(data) {
9
+ await runOnUiThread(async () => {
10
+ const { runner } = createWindowModuleRunner(data.modules);
11
+ const { createWindow, exitWhenHostEnds, runWindow } = await runner.import("winui-svelte/window");
12
+ const { default: component } = await runner.import(data.component);
13
+ const { createHostChannel, createMessagePortTransport } = await runner.import("winui-svelte/state");
14
+ const { link } = data;
15
+ await runWindow({
16
+ onStart() {
17
+ const hasLink = link !== null;
18
+ if (!hasLink) {
19
+ createWindow({
20
+ ...data.window,
21
+ component,
22
+ props: data.props
23
+ });
24
+ return;
25
+ }
26
+ const channel = createHostChannel({
27
+ transport: createMessagePortTransport({ port: link })
28
+ });
29
+ exitWhenHostEnds({ link: channel });
30
+ createWindow({
31
+ ...data.window,
32
+ component,
33
+ props: {
34
+ ...data.props,
35
+ channel
36
+ }
37
+ });
38
+ }
39
+ });
40
+ });
41
+ }
42
+ //# sourceMappingURL=dev-window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-window.js","sourceRoot":"","sources":["../../src/dev/dev-window.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAgBtD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAmB;IACpD,MAAM,aAAa,CAAC,KAAK,IAAI,EAAE;QAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAsB,qBAAqB,CAAC,CAAC;QACtH,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnE,MAAM,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAC3E,oBAAoB,CACrB,CAAC;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,MAAM,SAAS,CAAC;YACd,OAAO;gBACL,MAAM,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;gBAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,YAAY,CAAC;wBACX,GAAG,IAAI,CAAC,MAAM;wBACd,SAAS;wBACT,KAAK,EAAE,IAAI,CAAC,KAAK;qBAClB,CAAC,CAAC;oBACH,OAAO;gBACT,CAAC;gBAED,MAAM,OAAO,GAAG,iBAAiB,CAAC;oBAChC,SAAS,EAAE,0BAA0B,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;iBACtD,CAAC,CAAC;gBACH,gBAAgB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;gBACpC,YAAY,CAAC;oBACX,GAAG,IAAI,CAAC,MAAM;oBACd,SAAS;oBACT,KAAK,EAAE;wBACL,GAAG,IAAI,CAAC,KAAK;wBACb,OAAO;qBACR;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { DevOptions } from "./start-dev.js";
2
+ export { startDev } from "./start-dev.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dev/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { startDev } from "./start-dev.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dev/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { DevWindowChrome } from "./dev-window.js";
2
+ import type { Json } from "../messaging/json.js";
3
+ import type { Transport } from "../state/host.js";
4
+ /** What `startDev` opens and where its modules come from. */
5
+ export interface DevOptions {
6
+ /** The folder of the app's sources, which the dev server serves and watches. */
7
+ root: string;
8
+ /** The window's root component, as a path under `root` that starts with a slash (`"/App.svelte"`). */
9
+ component: string;
10
+ /** The component's props: JSON, since they cross to the window's thread. */
11
+ props?: Record<string, Json>;
12
+ /** The window's title, size, backdrop and the other chrome `createWindow` takes, besides its content and owner. */
13
+ window?: DevWindowChrome;
14
+ /**
15
+ * The app's link to the framework that starts it (a Tauri core, an Electron
16
+ * main process, a script): `"stdio"` when it started this process as a
17
+ * sidecar and speaks JSON lines on its pipes, or a transport of its own
18
+ * (`utilityProcess`'s parent port, say). The component then gets a
19
+ * `channel` prop (`hostState`, `channel.send`), and the window closes when
20
+ * the link ends.
21
+ */
22
+ host?: "stdio" | Transport;
23
+ /** The app's Vite config, whose plugins should include `winuiSvelte()`; the plugin's defaults serve without one. */
24
+ configFile?: string;
25
+ /** Modules Node loads itself rather than Vite: an app's own native modules. */
26
+ isNative?: (file: string) => boolean;
27
+ }
28
+ /**
29
+ * Opens the app in a window and keeps it live: a saved `.svelte` or `.ts`
30
+ * file updates the open window without a restart. It starts the Windows App
31
+ * SDK, a Vite dev server for the app's modules and the window's thread, so the
32
+ * host is one call:
33
+ *
34
+ * ```ts
35
+ * import { startDev } from "winui-svelte/dev";
36
+ *
37
+ * process.exitCode = await startDev({
38
+ * root: import.meta.dirname,
39
+ * component: "/App.svelte",
40
+ * window: { title: "My app" }
41
+ * });
42
+ * ```
43
+ *
44
+ * @returns The exit code, once the window has closed and the dev server has stopped.
45
+ */
46
+ export declare function startDev({ component, props, window, host, ...serverOptions }: DevOptions): Promise<string | number>;
47
+ //# sourceMappingURL=start-dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-dev.d.ts","sourceRoot":"","sources":["../../src/dev/start-dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQpD,6DAA6D;AAC7D,MAAM,WAAW,UAAU;IACzB,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IAEb,sGAAsG;IACtG,SAAS,EAAE,MAAM,CAAC;IAElB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE7B,mHAAmH;IACnH,MAAM,CAAC,EAAE,eAAe,CAAC;IAEzB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE3B,oHAAoH;IACpH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACtC;AA8BD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAU,EAAE,MAAW,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,EAAE,UAAU,4BAgCxG"}
@@ -0,0 +1,81 @@
1
+ import { createStdioTransport, reserveStdout } from "../state/host.js";
2
+ import { startModuleServer } from "../vite/server.js";
3
+ import { initWindowsAppSdk } from "../window/bootstrap.js";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ import { MessageChannel, Worker } from "node:worker_threads";
7
+ // The window's thread is a worker that loads this package's dev-window module,
8
+ // from source (.ts) or from the published package (.js).
9
+ const WINDOW_MODULE = path.join(import.meta.dirname, `dev-window${path.extname(import.meta.filename)}`);
10
+ const WORKER_SOURCE = `const { workerData } = require("node:worker_threads");
11
+ import(workerData.moduleUrl).then(module => module.runDevWindow(workerData.data));`;
12
+ // The host's transport and the window's end of a MessageChannel, joined: what
13
+ // the host sends reaches the window, what the window sends reaches the host.
14
+ function linkTo(host) {
15
+ const isStdio = host === "stdio";
16
+ if (isStdio) {
17
+ reserveStdout();
18
+ }
19
+ const transport = isStdio ? createStdioTransport() : host;
20
+ const link = new MessageChannel();
21
+ transport.listen({
22
+ message: frame => link.port1.postMessage(frame),
23
+ malformed: reason => process.stderr.write(`host: malformed message: ${reason}
24
+ `),
25
+ closed: () => link.port1.close()
26
+ });
27
+ link.port1.on("message", frame => transport.send(frame));
28
+ return link;
29
+ }
30
+ /**
31
+ * Opens the app in a window and keeps it live: a saved `.svelte` or `.ts`
32
+ * file updates the open window without a restart. It starts the Windows App
33
+ * SDK, a Vite dev server for the app's modules and the window's thread, so the
34
+ * host is one call:
35
+ *
36
+ * ```ts
37
+ * import { startDev } from "winui-svelte/dev";
38
+ *
39
+ * process.exitCode = await startDev({
40
+ * root: import.meta.dirname,
41
+ * component: "/App.svelte",
42
+ * window: { title: "My app" }
43
+ * });
44
+ * ```
45
+ *
46
+ * @returns The exit code, once the window has closed and the dev server has stopped.
47
+ */
48
+ export async function startDev({ component, props = {}, window = {}, host, ...serverOptions }) {
49
+ const link = host === undefined ? null : linkTo(host);
50
+ initWindowsAppSdk();
51
+ const modules = new MessageChannel();
52
+ const server = await startModuleServer({
53
+ ...serverOptions,
54
+ port: modules.port1
55
+ });
56
+ const data = {
57
+ modules: modules.port2,
58
+ link: link?.port2 ?? null,
59
+ component,
60
+ props,
61
+ window
62
+ };
63
+ const worker = new Worker(WORKER_SOURCE, {
64
+ eval: true,
65
+ workerData: {
66
+ moduleUrl: pathToFileURL(WINDOW_MODULE).href,
67
+ data
68
+ },
69
+ transferList: link === null ? [modules.port2] : [modules.port2, link.port2]
70
+ });
71
+ worker.on("error", error => {
72
+ process.stderr.write(`${error.stack ?? String(error)}\n`);
73
+ process.exitCode = 1;
74
+ });
75
+ const code = await new Promise(resolve => {
76
+ worker.on("exit", resolve);
77
+ });
78
+ await server.close();
79
+ return process.exitCode ?? code;
80
+ }
81
+ //# sourceMappingURL=start-dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-dev.js","sourceRoot":"","sources":["../../src/dev/start-dev.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAiC7D,+EAA+E;AAC/E,yDAAyD;AACzD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACxG,MAAM,aAAa,GAAG;mFAC6D,CAAC;AAEpF,8EAA8E;AAC9E,6EAA6E;AAC7E,SAAS,MAAM,CAAC,IAAyB;IACvC,MAAM,OAAO,GAAG,IAAI,KAAK,OAAO,CAAC;IACjC,IAAI,OAAO,EAAE,CAA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AAI;QACzB,SAAS;QACT,KAAK;QACL,MAAM;KACP,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,EAAE;QACvC,IAAI,EAAE,IAAI;QACV,UAAU,EAAE;YACV,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,IAAI;YAC5C,IAAI;SACL;QACD,YAAY,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC;KAC5E,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,IAAI,OAAO,CAAS,OAAO,CAAC,EAAE;QAC/C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,OAAO,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC;AAClC,CAAC"}
package/dist/enums.d.ts CHANGED
@@ -6,7 +6,9 @@ export { XamlKind } from "./components/xaml-source.js";
6
6
  export { FocusKind } from "./renderer/host/focus-element.js";
7
7
  export { TrayGesture } from "./tray/click-detector.js";
8
8
  export { TrayBalloonIcon } from "./tray/tray-core.js";
9
+ export { SizeToContent, WindowAnchor } from "./window/anchor.js";
9
10
  export { Backdrop } from "./window/backdrop.js";
10
11
  export { TitleBarHeight, WindowPresentation, WindowTheme } from "./window/chrome.js";
12
+ export { DockDisplay } from "./window/dock.js";
11
13
  export { PickerLocation } from "./window/pickers.js";
12
14
  //# sourceMappingURL=enums.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAMA,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAC/G,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAMA,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAC/G,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/enums.js CHANGED
@@ -11,7 +11,9 @@ export { XamlKind } from "./components/xaml-source.js";
11
11
  export { FocusKind } from "./renderer/host/focus-element.js";
12
12
  export { TrayGesture } from "./tray/click-detector.js";
13
13
  export { TrayBalloonIcon } from "./tray/tray-core.js";
14
+ export { SizeToContent, WindowAnchor } from "./window/anchor.js";
14
15
  export { Backdrop } from "./window/backdrop.js";
15
16
  export { TitleBarHeight, WindowPresentation, WindowTheme } from "./window/chrome.js";
17
+ export { DockDisplay } from "./window/dock.js";
16
18
  export { PickerLocation } from "./window/pickers.js";
17
19
  //# sourceMappingURL=enums.js.map
package/dist/enums.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,iBAAiB;AAEjB,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAC/G,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,iBAAiB;AAEjB,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAC/G,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { AppWindow } from "../winui.js";
2
+ /**
3
+ * One window's size and place as the web's `window` has them (`outerWidth`,
4
+ * `outerHeight`, `screenX`, `screenY`, `devicePixelRatio`, `resizeTo`,
5
+ * `resizeBy`, `moveTo`, `moveBy`), in CSS pixels, over its `AppWindow`. A
6
+ * process holds many windows, so there is no `window` global for it; a
7
+ * `WindowHandle` gives each window its own (`handle.geometry`).
8
+ *
9
+ * CSS pixels are WinUI's device-independent pixels, at the window's scale.
10
+ */
11
+ export declare class WindowGeometry {
12
+ private readonly appWindow;
13
+ private readonly readScale;
14
+ /** Made by `WindowHandle`. */
15
+ constructor(appWindow: AppWindow, readScale: () => number);
16
+ /** Device pixels per CSS pixel. */
17
+ get devicePixelRatio(): number;
18
+ /** The window's width with its frame, in CSS pixels. */
19
+ get outerWidth(): number;
20
+ /** The window's height with its frame, in CSS pixels. */
21
+ get outerHeight(): number;
22
+ /** The window's left edge on the desktop, in CSS pixels at this window's scale. */
23
+ get screenX(): number;
24
+ /** The window's top edge on the desktop, in CSS pixels at this window's scale. */
25
+ get screenY(): number;
26
+ /**
27
+ * Resizes the window (frame included) to `width` by `height` CSS pixels,
28
+ * keeping its top-left corner: `AppWindow.Resize`. A side that
29
+ * `sizeToContent` sets is set again by the content.
30
+ */
31
+ resizeTo(width: number, height: number): void;
32
+ /** Grows (or shrinks) the window by `width` and `height` CSS pixels. */
33
+ resizeBy(width: number, height: number): void;
34
+ /** Puts the window's top-left corner at `x`, `y` CSS pixels on the desktop: `AppWindow.Move`. */
35
+ moveTo(x: number, y: number): void;
36
+ /** Moves the window by `x` and `y` CSS pixels. */
37
+ moveBy(x: number, y: number): void;
38
+ }
39
+ //# sourceMappingURL=window-geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window-geometry.d.ts","sourceRoot":"","sources":["../../src/web-apis/window-geometry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IAEzC,8BAA8B;gBAClB,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,MAAM;IAKzD,mCAAmC;IAEnC,IAAI,gBAAgB,WAEnB;IAED,wDAAwD;IACxD,IAAI,UAAU,WAKb;IAED,yDAAyD;IACzD,IAAI,WAAW,WAKd;IAED,mFAAmF;IACnF,IAAI,OAAO,WAKV;IAED,kFAAkF;IAClF,IAAI,OAAO,WAKV;IAED;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IActC,wEAAwE;IAExE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAItC,iGAAiG;IACjG,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAc3B,kDAAkD;IAElD,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;CAG5B"}
@@ -0,0 +1,95 @@
1
+ import { toCssPixels, toDevicePixels } from "../window/css-pixels.js";
2
+ /**
3
+ * One window's size and place as the web's `window` has them (`outerWidth`,
4
+ * `outerHeight`, `screenX`, `screenY`, `devicePixelRatio`, `resizeTo`,
5
+ * `resizeBy`, `moveTo`, `moveBy`), in CSS pixels, over its `AppWindow`. A
6
+ * process holds many windows, so there is no `window` global for it; a
7
+ * `WindowHandle` gives each window its own (`handle.geometry`).
8
+ *
9
+ * CSS pixels are WinUI's device-independent pixels, at the window's scale.
10
+ */
11
+ export class WindowGeometry {
12
+ appWindow;
13
+ readScale;
14
+ /** Made by `WindowHandle`. */
15
+ constructor(appWindow, readScale) {
16
+ this.appWindow = appWindow;
17
+ this.readScale = readScale;
18
+ }
19
+ /** Device pixels per CSS pixel. */
20
+ // fallow-ignore-next-line unused-class-member
21
+ get devicePixelRatio() {
22
+ return this.readScale();
23
+ }
24
+ /** The window's width with its frame, in CSS pixels. */
25
+ get outerWidth() {
26
+ return toCssPixels({
27
+ value: this.appWindow.size.width,
28
+ scale: this.readScale()
29
+ });
30
+ }
31
+ /** The window's height with its frame, in CSS pixels. */
32
+ get outerHeight() {
33
+ return toCssPixels({
34
+ value: this.appWindow.size.height,
35
+ scale: this.readScale()
36
+ });
37
+ }
38
+ /** The window's left edge on the desktop, in CSS pixels at this window's scale. */
39
+ get screenX() {
40
+ return toCssPixels({
41
+ value: this.appWindow.position.x,
42
+ scale: this.readScale()
43
+ });
44
+ }
45
+ /** The window's top edge on the desktop, in CSS pixels at this window's scale. */
46
+ get screenY() {
47
+ return toCssPixels({
48
+ value: this.appWindow.position.y,
49
+ scale: this.readScale()
50
+ });
51
+ }
52
+ /**
53
+ * Resizes the window (frame included) to `width` by `height` CSS pixels,
54
+ * keeping its top-left corner: `AppWindow.Resize`. A side that
55
+ * `sizeToContent` sets is set again by the content.
56
+ */
57
+ resizeTo(width, height) {
58
+ const scale = this.readScale();
59
+ this.appWindow.resize({
60
+ width: toDevicePixels({
61
+ value: width,
62
+ scale
63
+ }),
64
+ height: toDevicePixels({
65
+ value: height,
66
+ scale
67
+ })
68
+ });
69
+ }
70
+ /** Grows (or shrinks) the window by `width` and `height` CSS pixels. */
71
+ // fallow-ignore-next-line unused-class-member
72
+ resizeBy(width, height) {
73
+ this.resizeTo(this.outerWidth + width, this.outerHeight + height);
74
+ }
75
+ /** Puts the window's top-left corner at `x`, `y` CSS pixels on the desktop: `AppWindow.Move`. */
76
+ moveTo(x, y) {
77
+ const scale = this.readScale();
78
+ this.appWindow.move({
79
+ x: toDevicePixels({
80
+ value: x,
81
+ scale
82
+ }),
83
+ y: toDevicePixels({
84
+ value: y,
85
+ scale
86
+ })
87
+ });
88
+ }
89
+ /** Moves the window by `x` and `y` CSS pixels. */
90
+ // fallow-ignore-next-line unused-class-member
91
+ moveBy(x, y) {
92
+ this.moveTo(this.screenX + x, this.screenY + y);
93
+ }
94
+ }
95
+ //# sourceMappingURL=window-geometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window-geometry.js","sourceRoot":"","sources":["../../src/web-apis/window-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGxE;;;;;;;;GAQG;AACH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ACpB,KAAK,EAAE,KAAK;gBACZ,KAAK;aACN,CAAC;YACF,MAAM,EAAE,cAAc,CAAC;gBACrB,KAAK,EAAE,MAAM;gBACb,KAAK;aACN,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,wEAAwE;IACxE,8CAA8C;IAC9C,QAAQ,CAAC,KAAa,EAAE,MAAc;QACpC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,EAAE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,CAAC;IACpE,CAAC;IAED,iGAAiG;IACjG,MAAM,CAAC,CAAS,EAAE,CAAS;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAClB,CAAC,EAAE,cAAc,CAAC;gBAChB,KAAK,EAAE,CAAC;gBACR,KAAK;aACN,CAAC;YACF,CAAC,EAAE,cAAc,CAAC;gBAChB,KAAK,EAAE,CAAC;gBACR,KAAK;aACN,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,kDAAkD;IAClD,8CAA8C;IAC9C,MAAM,CAAC,CAAS,EAAE,CAAS;QACzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC;CACF"}
@@ -58,6 +58,7 @@
58
58
  onsizechanged={(...args) => {
59
59
  const control = native;
60
60
  if (control) {
61
+ // noinspection JSUnresolvedReference: WebStorm 2026.3 misses CanvasControl's FrameworkElement base; tsc has it
61
62
  size = {
62
63
  width: control.actualWidth,
63
64
  height: control.actualHeight
@@ -0,0 +1,92 @@
1
+ /**
2
+ * A corner of a window or of a display's work area. A window that changes
3
+ * size keeps its anchor corner where it is; a window docked to an anchor sits
4
+ * against that corner.
5
+ */
6
+ export declare const WindowAnchor: {
7
+ readonly topLeft: "topLeft";
8
+ readonly topRight: "topRight";
9
+ readonly bottomLeft: "bottomLeft";
10
+ readonly bottomRight: "bottomRight";
11
+ };
12
+ /** One of `WindowAnchor`'s values. */
13
+ export type WindowAnchor = (typeof WindowAnchor)[keyof typeof WindowAnchor];
14
+ /**
15
+ * Which of a window's sides follow its content: the width, the height, both,
16
+ * or neither (the window keeps the size its props and its user give it).
17
+ */
18
+ export declare const SizeToContent: {
19
+ readonly none: "none";
20
+ readonly width: "width";
21
+ readonly height: "height";
22
+ readonly both: "both";
23
+ };
24
+ /** One of `SizeToContent`'s values. */
25
+ export type SizeToContent = (typeof SizeToContent)[keyof typeof SizeToContent];
26
+ /** A position and a size in device pixels, as AppWindow and DisplayArea have them. */
27
+ export interface WindowBounds {
28
+ x: number;
29
+ y: number;
30
+ width: number;
31
+ height: number;
32
+ }
33
+ /** A size in device pixels. */
34
+ export interface WindowSize {
35
+ width: number;
36
+ height: number;
37
+ }
38
+ /** The least and the most a window may be, in device pixels; `Infinity` is no most. */
39
+ export interface WindowLimits {
40
+ minWidth: number;
41
+ minHeight: number;
42
+ maxWidth: number;
43
+ maxHeight: number;
44
+ }
45
+ /**
46
+ * The window `bounds` at `size` with its `anchor` corner where it was: a
47
+ * window anchored bottom-right that grows taller grows upward.
48
+ */
49
+ export declare function anchoredBounds({ bounds, size, anchor }: {
50
+ bounds: WindowBounds;
51
+ size: WindowSize;
52
+ anchor: WindowAnchor;
53
+ }): {
54
+ x: number;
55
+ y: number;
56
+ width: number;
57
+ height: number;
58
+ };
59
+ /**
60
+ * Where a window of `size` sits against the `anchor` corner of `area` (a
61
+ * display's work area), `inset` device pixels in from both of its edges.
62
+ */
63
+ export declare function dockedBounds({ area, size, anchor, inset }: {
64
+ area: WindowBounds;
65
+ size: WindowSize;
66
+ anchor: WindowAnchor;
67
+ inset: number;
68
+ }): {
69
+ x: number;
70
+ y: number;
71
+ width: number;
72
+ height: number;
73
+ };
74
+ /**
75
+ * The bounds a window sized to its content takes: the sides `mode` names go to
76
+ * `desired` (what the content asks for, frame included) within `limits`, and
77
+ * the `anchor` corner stays. null when the window is already that size, so a
78
+ * caller makes no call for it.
79
+ */
80
+ export declare function fittedBounds({ bounds, desired, mode, anchor, limits }: {
81
+ bounds: WindowBounds;
82
+ desired: WindowSize;
83
+ mode: SizeToContent;
84
+ anchor: WindowAnchor;
85
+ limits: WindowLimits;
86
+ }): {
87
+ x: number;
88
+ y: number;
89
+ width: number;
90
+ height: number;
91
+ } | null;
92
+ //# sourceMappingURL=anchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/window/anchor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,sCAAsC;AACtC,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,uCAAuC;AACvC,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,+BAA+B;AAC/B,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uFAAuF;AACvF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAwBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;IACvD,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;CACtB;;;;;EAQA;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IAC1D,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;;;;;EAQA;AAUD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;IACtE,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;CACtB;;;;;SAyBA"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * A corner of a window or of a display's work area. A window that changes
3
+ * size keeps its anchor corner where it is; a window docked to an anchor sits
4
+ * against that corner.
5
+ */
6
+ export const WindowAnchor = {
7
+ topLeft: "topLeft",
8
+ topRight: "topRight",
9
+ bottomLeft: "bottomLeft",
10
+ bottomRight: "bottomRight"
11
+ };
12
+ /**
13
+ * Which of a window's sides follow its content: the width, the height, both,
14
+ * or neither (the window keeps the size its props and its user give it).
15
+ */
16
+ export const SizeToContent = {
17
+ none: "none",
18
+ width: "width",
19
+ height: "height",
20
+ both: "both"
21
+ };
22
+ const ANCHOR_SIDES = {
23
+ [WindowAnchor.topLeft]: {
24
+ isRight: false,
25
+ isBottom: false
26
+ },
27
+ [WindowAnchor.topRight]: {
28
+ isRight: true,
29
+ isBottom: false
30
+ },
31
+ [WindowAnchor.bottomLeft]: {
32
+ isRight: false,
33
+ isBottom: true
34
+ },
35
+ [WindowAnchor.bottomRight]: {
36
+ isRight: true,
37
+ isBottom: true
38
+ }
39
+ };
40
+ /**
41
+ * The window `bounds` at `size` with its `anchor` corner where it was: a
42
+ * window anchored bottom-right that grows taller grows upward.
43
+ */
44
+ export function anchoredBounds({ bounds, size, anchor }) {
45
+ const { isRight, isBottom } = ANCHOR_SIDES[anchor];
46
+ return {
47
+ x: isRight ? bounds.x + bounds.width - size.width : bounds.x,
48
+ y: isBottom ? bounds.y + bounds.height - size.height : bounds.y,
49
+ width: size.width,
50
+ height: size.height
51
+ };
52
+ }
53
+ /**
54
+ * Where a window of `size` sits against the `anchor` corner of `area` (a
55
+ * display's work area), `inset` device pixels in from both of its edges.
56
+ */
57
+ export function dockedBounds({ area, size, anchor, inset }) {
58
+ const { isRight, isBottom } = ANCHOR_SIDES[anchor];
59
+ return {
60
+ x: isRight ? area.x + area.width - size.width - inset : area.x + inset,
61
+ y: isBottom ? area.y + area.height - size.height - inset : area.y + inset,
62
+ width: size.width,
63
+ height: size.height
64
+ };
65
+ }
66
+ function clamp({ value, least, most }) {
67
+ return Math.min(Math.max(value, least), most);
68
+ }
69
+ /**
70
+ * The bounds a window sized to its content takes: the sides `mode` names go to
71
+ * `desired` (what the content asks for, frame included) within `limits`, and
72
+ * the `anchor` corner stays. null when the window is already that size, so a
73
+ * caller makes no call for it.
74
+ */
75
+ export function fittedBounds({ bounds, desired, mode, anchor, limits }) {
76
+ const isWidthFitted = mode === SizeToContent.width || mode === SizeToContent.both;
77
+ const isHeightFitted = mode === SizeToContent.height || mode === SizeToContent.both;
78
+ const size = {
79
+ width: isWidthFitted ? clamp({
80
+ value: desired.width,
81
+ least: limits.minWidth,
82
+ most: limits.maxWidth
83
+ }) : bounds.width,
84
+ height: isHeightFitted ? clamp({
85
+ value: desired.height,
86
+ least: limits.minHeight,
87
+ most: limits.maxHeight
88
+ }) : bounds.height
89
+ };
90
+ const isUnchanged = size.width === bounds.width && size.height === bounds.height;
91
+ if (isUnchanged) {
92
+ return null;
93
+ }
94
+ return anchoredBounds({
95
+ bounds,
96
+ size,
97
+ anchor
98
+ });
99
+ }
100
+ //# sourceMappingURL=anchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.js","sourceRoot":"","sources":["../../src/window/anchor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;CAClB,CAAC;AAKX;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;CACJ,CAAC;AA2BX,MAAM,YAAY,GAAG;IACnB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,KAAK;KAChB;IACD,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE;QACvB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;KAChB;IACD,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;QACzB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,IAAI;KACf;IACD,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;QAC1B,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf;CAID,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAIpD;IACC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO;QACL,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC5D,CAAC,EAA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I,CAAC;IAClF,MAAM,cAAc,GAAG,IAAI,KAAK,aAAa,CAAC,MAAM,IAAI,IAAI,KAAK,aAAa,CAAC,IAAI,CAAC;IACpF,MAAM,IAAI,GAAG;QACX,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;YAC3B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,MAAM,CAAC,QAAQ;YACtB,IAAI,EAAE,MAAM,CAAC,QAAQ;SACtB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;QACjB,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;YAC7B,KAAK,EAAE,OAAO,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,SAAS;YACvB,IAAI,EAAE,MAAM,CAAC,SAAS;SACvB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM;KACnB,CAAC;IACF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC;IACjF,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,cAAc,CAAC;QACpB,MAAM;QACN,IAAI;QACJ,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
@@ -3,7 +3,9 @@ import type { FrameworkElement, Window } from "../winui.js";
3
3
  * The material behind a window's content. Acrylic blurs and tints what is
4
4
  * behind the window (`acrylicBase` and `acrylicThin` are its other two
5
5
  * variants, made by the system backdrop controller); Mica tints with the desktop wallpaper (Mica Alt more
6
- * strongly, as a tabbed title bar has it); none leaves the theme's solid color.
6
+ * strongly, as a tabbed title bar has it); transparent shows the desktop
7
+ * through every pixel the content leaves clear (with per-pixel alpha; pair it
8
+ * with `isBorderless`); none leaves the theme's solid color.
7
9
  */
8
10
  export declare const Backdrop: {
9
11
  readonly acrylic: "acrylic";
@@ -12,6 +14,7 @@ export declare const Backdrop: {
12
14
  readonly mica: "mica";
13
15
  readonly micaAlt: "micaAlt";
14
16
  readonly none: "none";
17
+ readonly transparent: "transparent";
15
18
  };
16
19
  /** One of `Backdrop`'s values. */
17
20
  export type Backdrop = (typeof Backdrop)[keyof typeof Backdrop];
@@ -1 +1 @@
1
- {"version":3,"file":"backdrop.d.ts","sourceRoot":"","sources":["../../src/window/backdrop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG9D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;;;;;;;CAOX,CAAC;AAEX,kCAAkC;AAClC,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAgChE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;CACpB,cAsBA"}
1
+ {"version":3,"file":"backdrop.d.ts","sourceRoot":"","sources":["../../src/window/backdrop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG9D;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ;;;;;;;;CAQX,CAAC;AAEX,kCAAkC;AAClC,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAgChE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;CACpB,cA2BA"}