@symbiosis-lab/moss-api 0.7.11 → 0.10.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/README.md CHANGED
@@ -1,145 +1,38 @@
1
- # moss-api
1
+ # @symbiosis-lab/moss-api
2
2
 
3
- [![CI](https://github.com/Symbiosis-Lab/moss-api/actions/workflows/ci.yml/badge.svg)](https://github.com/Symbiosis-Lab/moss-api/actions/workflows/ci.yml)
4
- [![codecov](https://codecov.io/gh/Symbiosis-Lab/moss-api/branch/main/graph/badge.svg)](https://codecov.io/gh/Symbiosis-Lab/moss-api)
5
- [![npm version](https://badge.fury.io/js/%40symbiosis-lab%2Fmoss-api.svg)](https://www.npmjs.com/package/@symbiosis-lab/moss-api)
3
+ > TypeScript API for writing moss plugins.
6
4
 
7
- Official API for building Moss plugins. Provides types and utilities for plugin development.
5
+ [![npm](https://img.shields.io/npm/v/@symbiosis-lab/moss-api)](https://www.npmjs.com/package/@symbiosis-lab/moss-api)
6
+ [![downloads](https://img.shields.io/npm/dm/@symbiosis-lab/moss-api)](https://www.npmjs.com/package/@symbiosis-lab/moss-api)
7
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
8
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/@symbiosis-lab/moss-api)](https://bundlephobia.com/package/@symbiosis-lab/moss-api)
8
9
 
9
- ## Installation
10
+ > **Read-only mirror.** Source lives in the private moss monorepo. PRs cannot be merged here — see [CONTRIBUTING.md](CONTRIBUTING.md).
10
11
 
11
- ```bash
12
- npm install @symbiosis-lab/moss-api
13
- ```
14
-
15
- ## Usage
16
-
17
- ### Types
18
-
19
- ```typescript
20
- import type {
21
- OnDeployContext,
22
- AfterDeployContext,
23
- HookResult,
24
- PluginManifest,
25
- PluginCategory,
26
- } from "@symbiosis-lab/moss-api";
27
-
28
- // Define your plugin manifest
29
- const manifest: PluginManifest = {
30
- name: "my-plugin",
31
- version: "1.0.0",
32
- entry: "main.js",
33
- category: "deployer",
34
- };
35
-
36
- // Implement a hook
37
- async function onDeploy(context: OnDeployContext): Promise<HookResult> {
38
- // Your deployment logic here
39
- return { success: true, message: "Deployed successfully" };
40
- }
41
- ```
42
-
43
- ### Utilities
44
-
45
- ```typescript
46
- import {
47
- setMessageContext,
48
- reportProgress,
49
- reportError,
50
- reportComplete,
51
- log,
52
- warn,
53
- error,
54
- } from "@symbiosis-lab/moss-api";
55
-
56
- // Set plugin context (call once at plugin initialization)
57
- setMessageContext("my-plugin", "on_deploy");
58
-
59
- // Report progress during long operations
60
- await reportProgress("deploying", 50, 100, "Uploading files...");
12
+ [moss](https://mosspub.com) is a desktop publishing app; this package is its plugin API surface. Use it to write plugins that publish posts, manage site assets, or extend the editor.
61
13
 
62
- // Log messages
63
- await log("Deployment started");
64
- await warn("Deprecation warning");
65
- await error("Something went wrong");
14
+ - [Quickstart](#quickstart)
15
+ - [Stability](#stability)
16
+ - [Discussions](https://github.com/Symbiosis-Lab/moss-api/discussions) · [Issues](https://github.com/Symbiosis-Lab/moss-api/issues) · [moss.pub](https://mosspub.com)
66
17
 
67
- // Report errors with context
68
- await reportError("Upload failed", "network", false);
18
+ ## Quickstart
69
19
 
70
- // Report completion with success and result
71
- await reportComplete(true, { url: "https://example.com" });
72
-
73
- // Report completion with failure
74
- await reportComplete(false, undefined, "Deployment failed");
75
- ```
76
-
77
- ### Browser Utilities
78
-
79
- ```typescript
80
- import { openBrowser, closeBrowser } from "@symbiosis-lab/moss-api";
81
-
82
- // Open authentication page in plugin browser window
83
- await openBrowser("https://example.com/auth");
84
-
85
- // Close browser window when done
86
- await closeBrowser();
20
+ ```sh
21
+ npm install @symbiosis-lab/moss-api
87
22
  ```
88
23
 
89
- ### Tauri Utilities
90
-
91
- ```typescript
92
- import { getTauriCore, isTauriAvailable } from "@symbiosis-lab/moss-api";
24
+ ```ts
25
+ import { getTauriCore, fetchUrl } from "@symbiosis-lab/moss-api";
93
26
 
94
- // Check if running in Tauri environment
95
- if (isTauriAvailable()) {
96
- const core = getTauriCore();
97
- const result = await core.invoke("my_command", { arg: "value" });
98
- }
27
+ const html = await fetchUrl("https://example.com");
28
+ console.log(html);
99
29
  ```
100
30
 
101
- ## API Reference
102
-
103
- ### Types
104
-
105
- | Type | Description |
106
- |------|-------------|
107
- | `ProjectInfo` | Project metadata (type, folders, files) |
108
- | `PluginManifest` | Plugin configuration (name, version, entry, category) |
109
- | `PluginCategory` | Union: "generator" \| "deployer" \| "syndicator" \| "enhancer" \| "processor" |
110
- | `BaseContext` | Base hook context with project info |
111
- | `BeforeBuildContext` | Context for before_build hook |
112
- | `OnBuildContext` | Context for on_build hook (includes source files) |
113
- | `OnDeployContext` | Context for on_deploy hook (includes output files) |
114
- | `AfterDeployContext` | Context for after_deploy hook (includes articles, deployment) |
115
- | `SourceFiles` | Categorized source files (markdown, pages, docx, other) |
116
- | `ArticleInfo` | Article metadata for syndication |
117
- | `DeploymentInfo` | Deployment result (method, url, timestamp, metadata) |
118
- | `HookResult` | Standard hook return type |
119
- | `PluginMessage` | Union of all message types |
120
- | `LogMessage` | Log message with level |
121
- | `ProgressMessage` | Progress update message |
122
- | `ErrorMessage` | Error message with context and fatal flag |
123
- | `CompleteMessage` | Completion message with result |
124
-
125
- ### Functions
31
+ ## Stability
126
32
 
127
- | Function | Description |
128
- |----------|-------------|
129
- | `getTauriCore()` | Get Tauri API (throws if unavailable) |
130
- | `isTauriAvailable()` | Check if Tauri is available |
131
- | `setMessageContext(pluginName, hookName)` | Set context for messages |
132
- | `getMessageContext()` | Get current message context |
133
- | `sendMessage(message)` | Send raw message to Moss |
134
- | `reportProgress(phase, current, total, message?)` | Report progress |
135
- | `reportError(error, context?, fatal?)` | Report error |
136
- | `reportComplete(success, result?, error?)` | Report completion |
137
- | `log(message)` | Log info message |
138
- | `warn(message)` | Log warning message |
139
- | `error(message)` | Log error message |
140
- | `openBrowser(url)` | Open URL in plugin browser |
141
- | `closeBrowser()` | Close plugin browser |
33
+ This package is 0.x. The API may change between minor versions until 1.0.
34
+ Breaking changes are documented in [CHANGELOG.md](./CHANGELOG.md).
142
35
 
143
36
  ## License
144
37
 
145
- MIT - see [LICENSE](LICENSE) for details.
38
+ MIT see [LICENSE](LICENSE).
@@ -0,0 +1,159 @@
1
+ //#region ../../node_modules/.pnpm/@tauri-apps+api@2.10.1/node_modules/@tauri-apps/api/external/tslib/tslib.es6.js
2
+ /******************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */
16
+ function __classPrivateFieldGet(receiver, state, kind, f) {
17
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
+ }
21
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
22
+ if (kind === "m") throw new TypeError("Private method is not writable");
23
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
25
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
26
+ }
27
+
28
+ //#endregion
29
+ //#region ../../node_modules/.pnpm/@tauri-apps+api@2.10.1/node_modules/@tauri-apps/api/core.js
30
+ var _Channel_onmessage, _Channel_nextMessageIndex, _Channel_pendingMessages, _Channel_messageEndIndex, _Resource_rid;
31
+ /**
32
+ * Invoke your custom commands.
33
+ *
34
+ * This package is also accessible with `window.__TAURI__.core` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
35
+ * @module
36
+ */
37
+ /**
38
+ * A key to be used to implement a special function
39
+ * on your types that define how your type should be serialized
40
+ * when passing across the IPC.
41
+ * @example
42
+ * Given a type in Rust that looks like this
43
+ * ```rs
44
+ * #[derive(serde::Serialize, serde::Deserialize)
45
+ * enum UserId {
46
+ * String(String),
47
+ * Number(u32),
48
+ * }
49
+ * ```
50
+ * `UserId::String("id")` would be serialized into `{ String: "id" }`
51
+ * and so we need to pass the same structure back to Rust
52
+ * ```ts
53
+ * import { SERIALIZE_TO_IPC_FN } from "@tauri-apps/api/core"
54
+ *
55
+ * class UserIdString {
56
+ * id
57
+ * constructor(id) {
58
+ * this.id = id
59
+ * }
60
+ *
61
+ * [SERIALIZE_TO_IPC_FN]() {
62
+ * return { String: this.id }
63
+ * }
64
+ * }
65
+ *
66
+ * class UserIdNumber {
67
+ * id
68
+ * constructor(id) {
69
+ * this.id = id
70
+ * }
71
+ *
72
+ * [SERIALIZE_TO_IPC_FN]() {
73
+ * return { Number: this.id }
74
+ * }
75
+ * }
76
+ *
77
+ * type UserId = UserIdString | UserIdNumber
78
+ * ```
79
+ *
80
+ */
81
+ const SERIALIZE_TO_IPC_FN = "__TAURI_TO_IPC_KEY__";
82
+ /**
83
+ * Stores the callback in a known location, and returns an identifier that can be passed to the backend.
84
+ * The backend uses the identifier to `eval()` the callback.
85
+ *
86
+ * @return An unique identifier associated with the callback function.
87
+ *
88
+ * @since 1.0.0
89
+ */
90
+ function transformCallback(callback, once = false) {
91
+ return window.__TAURI_INTERNALS__.transformCallback(callback, once);
92
+ }
93
+ var Channel = class {
94
+ constructor(onmessage) {
95
+ _Channel_onmessage.set(this, void 0);
96
+ _Channel_nextMessageIndex.set(this, 0);
97
+ _Channel_pendingMessages.set(this, []);
98
+ _Channel_messageEndIndex.set(this, void 0);
99
+ __classPrivateFieldSet(this, _Channel_onmessage, onmessage || (() => {}), "f");
100
+ this.id = transformCallback((rawMessage) => {
101
+ const index = rawMessage.index;
102
+ if ("end" in rawMessage) {
103
+ if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) this.cleanupCallback();
104
+ else __classPrivateFieldSet(this, _Channel_messageEndIndex, index, "f");
105
+ return;
106
+ }
107
+ const message = rawMessage.message;
108
+ if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")) {
109
+ __classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message);
110
+ __classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
111
+ while (__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") in __classPrivateFieldGet(this, _Channel_pendingMessages, "f")) {
112
+ const message$1 = __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
113
+ __classPrivateFieldGet(this, _Channel_onmessage, "f").call(this, message$1);
114
+ delete __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f")];
115
+ __classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") + 1, "f");
116
+ }
117
+ if (__classPrivateFieldGet(this, _Channel_nextMessageIndex, "f") === __classPrivateFieldGet(this, _Channel_messageEndIndex, "f")) this.cleanupCallback();
118
+ } else __classPrivateFieldGet(this, _Channel_pendingMessages, "f")[index] = message;
119
+ });
120
+ }
121
+ cleanupCallback() {
122
+ window.__TAURI_INTERNALS__.unregisterCallback(this.id);
123
+ }
124
+ set onmessage(handler) {
125
+ __classPrivateFieldSet(this, _Channel_onmessage, handler, "f");
126
+ }
127
+ get onmessage() {
128
+ return __classPrivateFieldGet(this, _Channel_onmessage, "f");
129
+ }
130
+ [(_Channel_onmessage = /* @__PURE__ */ new WeakMap(), _Channel_nextMessageIndex = /* @__PURE__ */ new WeakMap(), _Channel_pendingMessages = /* @__PURE__ */ new WeakMap(), _Channel_messageEndIndex = /* @__PURE__ */ new WeakMap(), SERIALIZE_TO_IPC_FN)]() {
131
+ return `__CHANNEL__:${this.id}`;
132
+ }
133
+ toJSON() {
134
+ return this[SERIALIZE_TO_IPC_FN]();
135
+ }
136
+ };
137
+ /**
138
+ * Sends a message to the backend.
139
+ * @example
140
+ * ```typescript
141
+ * import { invoke } from '@tauri-apps/api/core';
142
+ * await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
143
+ * ```
144
+ *
145
+ * @param cmd The command name.
146
+ * @param args The optional arguments to pass to the command.
147
+ * @param options The request options.
148
+ * @return A promise resolving or rejecting to the backend response.
149
+ *
150
+ * @since 1.0.0
151
+ */
152
+ async function invoke(cmd, args = {}, options) {
153
+ return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
154
+ }
155
+ _Resource_rid = /* @__PURE__ */ new WeakMap();
156
+
157
+ //#endregion
158
+ export { invoke, transformCallback };
159
+ //# sourceMappingURL=core-serM6jqp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-serM6jqp.mjs","names":["message"],"sources":["../../../node_modules/.pnpm/@tauri-apps+api@2.10.1/node_modules/@tauri-apps/api/external/tslib/tslib.es6.js","../../../node_modules/.pnpm/@tauri-apps+api@2.10.1/node_modules/@tauri-apps/api/core.js"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\n\r\nfunction __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nfunction __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\ntypeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\n\nexport { __classPrivateFieldGet, __classPrivateFieldSet };\n","import { __classPrivateFieldSet, __classPrivateFieldGet } from './external/tslib/tslib.es6.js';\n\n// Copyright 2019-2024 Tauri Programme within The Commons Conservancy\n// SPDX-License-Identifier: Apache-2.0\n// SPDX-License-Identifier: MIT\nvar _Channel_onmessage, _Channel_nextMessageIndex, _Channel_pendingMessages, _Channel_messageEndIndex, _Resource_rid;\n/**\n * Invoke your custom commands.\n *\n * This package is also accessible with `window.__TAURI__.core` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.\n * @module\n */\n/**\n * A key to be used to implement a special function\n * on your types that define how your type should be serialized\n * when passing across the IPC.\n * @example\n * Given a type in Rust that looks like this\n * ```rs\n * #[derive(serde::Serialize, serde::Deserialize)\n * enum UserId {\n * String(String),\n * Number(u32),\n * }\n * ```\n * `UserId::String(\"id\")` would be serialized into `{ String: \"id\" }`\n * and so we need to pass the same structure back to Rust\n * ```ts\n * import { SERIALIZE_TO_IPC_FN } from \"@tauri-apps/api/core\"\n *\n * class UserIdString {\n * id\n * constructor(id) {\n * this.id = id\n * }\n *\n * [SERIALIZE_TO_IPC_FN]() {\n * return { String: this.id }\n * }\n * }\n *\n * class UserIdNumber {\n * id\n * constructor(id) {\n * this.id = id\n * }\n *\n * [SERIALIZE_TO_IPC_FN]() {\n * return { Number: this.id }\n * }\n * }\n *\n * type UserId = UserIdString | UserIdNumber\n * ```\n *\n */\n// if this value changes, make sure to update it in:\n// 1. ipc.js\n// 2. process-ipc-message-fn.js\nconst SERIALIZE_TO_IPC_FN = '__TAURI_TO_IPC_KEY__';\n/**\n * Stores the callback in a known location, and returns an identifier that can be passed to the backend.\n * The backend uses the identifier to `eval()` the callback.\n *\n * @return An unique identifier associated with the callback function.\n *\n * @since 1.0.0\n */\nfunction transformCallback(\n// TODO: Make this not optional in v3\ncallback, once = false) {\n return window.__TAURI_INTERNALS__.transformCallback(callback, once);\n}\nclass Channel {\n constructor(onmessage) {\n _Channel_onmessage.set(this, void 0);\n // the index is used as a mechanism to preserve message order\n _Channel_nextMessageIndex.set(this, 0);\n _Channel_pendingMessages.set(this, []);\n _Channel_messageEndIndex.set(this, void 0);\n __classPrivateFieldSet(this, _Channel_onmessage, onmessage || (() => { }), \"f\");\n this.id = transformCallback((rawMessage) => {\n const index = rawMessage.index;\n if ('end' in rawMessage) {\n if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, \"f\")) {\n this.cleanupCallback();\n }\n else {\n __classPrivateFieldSet(this, _Channel_messageEndIndex, index, \"f\");\n }\n return;\n }\n const message = rawMessage.message;\n // Process the message if we're at the right order\n if (index == __classPrivateFieldGet(this, _Channel_nextMessageIndex, \"f\")) {\n __classPrivateFieldGet(this, _Channel_onmessage, \"f\").call(this, message);\n __classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, \"f\") + 1, \"f\");\n // process pending messages\n while (__classPrivateFieldGet(this, _Channel_nextMessageIndex, \"f\") in __classPrivateFieldGet(this, _Channel_pendingMessages, \"f\")) {\n const message = __classPrivateFieldGet(this, _Channel_pendingMessages, \"f\")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, \"f\")];\n __classPrivateFieldGet(this, _Channel_onmessage, \"f\").call(this, message);\n // eslint-disable-next-line @typescript-eslint/no-array-delete\n delete __classPrivateFieldGet(this, _Channel_pendingMessages, \"f\")[__classPrivateFieldGet(this, _Channel_nextMessageIndex, \"f\")];\n __classPrivateFieldSet(this, _Channel_nextMessageIndex, __classPrivateFieldGet(this, _Channel_nextMessageIndex, \"f\") + 1, \"f\");\n }\n if (__classPrivateFieldGet(this, _Channel_nextMessageIndex, \"f\") === __classPrivateFieldGet(this, _Channel_messageEndIndex, \"f\")) {\n this.cleanupCallback();\n }\n }\n // Queue the message if we're not\n else {\n // eslint-disable-next-line security/detect-object-injection\n __classPrivateFieldGet(this, _Channel_pendingMessages, \"f\")[index] = message;\n }\n });\n }\n cleanupCallback() {\n window.__TAURI_INTERNALS__.unregisterCallback(this.id);\n }\n set onmessage(handler) {\n __classPrivateFieldSet(this, _Channel_onmessage, handler, \"f\");\n }\n get onmessage() {\n return __classPrivateFieldGet(this, _Channel_onmessage, \"f\");\n }\n [(_Channel_onmessage = new WeakMap(), _Channel_nextMessageIndex = new WeakMap(), _Channel_pendingMessages = new WeakMap(), _Channel_messageEndIndex = new WeakMap(), SERIALIZE_TO_IPC_FN)]() {\n return `__CHANNEL__:${this.id}`;\n }\n toJSON() {\n // eslint-disable-next-line security/detect-object-injection\n return this[SERIALIZE_TO_IPC_FN]();\n }\n}\nclass PluginListener {\n constructor(plugin, event, channelId) {\n this.plugin = plugin;\n this.event = event;\n this.channelId = channelId;\n }\n async unregister() {\n return invoke(`plugin:${this.plugin}|remove_listener`, {\n event: this.event,\n channelId: this.channelId\n });\n }\n}\n/**\n * Adds a listener to a plugin event.\n *\n * @returns The listener object to stop listening to the events.\n *\n * @since 2.0.0\n */\nasync function addPluginListener(plugin, event, cb) {\n const handler = new Channel(cb);\n try {\n await invoke(`plugin:${plugin}|register_listener`, {\n event,\n handler\n });\n return new PluginListener(plugin, event, handler.id);\n }\n catch {\n // TODO(v3): remove this fallback\n // note: we must try with camelCase here for backwards compatibility\n await invoke(`plugin:${plugin}|registerListener`, { event, handler });\n return new PluginListener(plugin, event, handler.id);\n }\n}\n/**\n * Get permission state for a plugin.\n *\n * This should be used by plugin authors to wrap their actual implementation.\n */\nasync function checkPermissions(plugin) {\n return invoke(`plugin:${plugin}|check_permissions`);\n}\n/**\n * Request permissions.\n *\n * This should be used by plugin authors to wrap their actual implementation.\n */\nasync function requestPermissions(plugin) {\n return invoke(`plugin:${plugin}|request_permissions`);\n}\n/**\n * Sends a message to the backend.\n * @example\n * ```typescript\n * import { invoke } from '@tauri-apps/api/core';\n * await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });\n * ```\n *\n * @param cmd The command name.\n * @param args The optional arguments to pass to the command.\n * @param options The request options.\n * @return A promise resolving or rejecting to the backend response.\n *\n * @since 1.0.0\n */\nasync function invoke(cmd, args = {}, options) {\n return window.__TAURI_INTERNALS__.invoke(cmd, args, options);\n}\n/**\n * Convert a device file path to an URL that can be loaded by the webview.\n * Note that `asset:` and `http://asset.localhost` must be added to [`app.security.csp`](https://v2.tauri.app/reference/config/#csp-1) in `tauri.conf.json`.\n * Example CSP value: `\"csp\": \"default-src 'self' ipc: http://ipc.localhost; img-src 'self' asset: http://asset.localhost\"` to use the asset protocol on image sources.\n *\n * Additionally, `\"enable\" : \"true\"` must be added to [`app.security.assetProtocol`](https://v2.tauri.app/reference/config/#assetprotocolconfig)\n * in `tauri.conf.json` and its access scope must be defined on the `scope` array on the same `assetProtocol` object.\n *\n * @param filePath The file path.\n * @param protocol The protocol to use. Defaults to `asset`. You only need to set this when using a custom protocol.\n * @example\n * ```typescript\n * import { appDataDir, join } from '@tauri-apps/api/path';\n * import { convertFileSrc } from '@tauri-apps/api/core';\n * const appDataDirPath = await appDataDir();\n * const filePath = await join(appDataDirPath, 'assets/video.mp4');\n * const assetUrl = convertFileSrc(filePath);\n *\n * const video = document.getElementById('my-video');\n * const source = document.createElement('source');\n * source.type = 'video/mp4';\n * source.src = assetUrl;\n * video.appendChild(source);\n * video.load();\n * ```\n *\n * @return the URL that can be used as source on the webview.\n *\n * @since 1.0.0\n */\nfunction convertFileSrc(filePath, protocol = 'asset') {\n return window.__TAURI_INTERNALS__.convertFileSrc(filePath, protocol);\n}\n/**\n * A rust-backed resource stored through `tauri::Manager::resources_table` API.\n *\n * The resource lives in the main process and does not exist\n * in the Javascript world, and thus will not be cleaned up automatically\n * except on application exit. If you want to clean it up early, call {@linkcode Resource.close}\n *\n * @example\n * ```typescript\n * import { Resource, invoke } from '@tauri-apps/api/core';\n * export class DatabaseHandle extends Resource {\n * static async open(path: string): Promise<DatabaseHandle> {\n * const rid: number = await invoke('open_db', { path });\n * return new DatabaseHandle(rid);\n * }\n *\n * async execute(sql: string): Promise<void> {\n * await invoke('execute_sql', { rid: this.rid, sql });\n * }\n * }\n * ```\n */\nclass Resource {\n get rid() {\n return __classPrivateFieldGet(this, _Resource_rid, \"f\");\n }\n constructor(rid) {\n _Resource_rid.set(this, void 0);\n __classPrivateFieldSet(this, _Resource_rid, rid, \"f\");\n }\n /**\n * Destroys and cleans up this resource from memory.\n * **You should not call any method on this object anymore and should drop any reference to it.**\n */\n async close() {\n return invoke('plugin:resources|close', {\n rid: this.rid\n });\n }\n}\n_Resource_rid = new WeakMap();\nfunction isTauri() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n return !!(globalThis || window).isTauri;\n}\n\nexport { Channel, PluginListener, Resource, SERIALIZE_TO_IPC_FN, addPluginListener, checkPermissions, convertFileSrc, invoke, isTauri, requestPermissions, transformCallback };\n"],"x_google_ignoreList":[0,1],"mappings":"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"}
@@ -0,0 +1,83 @@
1
+ import { invoke, transformCallback } from "./core-serM6jqp.mjs";
2
+
3
+ //#region ../../node_modules/.pnpm/@tauri-apps+api@2.10.1/node_modules/@tauri-apps/api/event.js
4
+ /**
5
+ * The event system allows you to emit events to the backend and listen to events from it.
6
+ *
7
+ * This package is also accessible with `window.__TAURI__.event` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.
8
+ * @module
9
+ */
10
+ /**
11
+ * @since 1.1.0
12
+ */
13
+ var TauriEvent;
14
+ (function(TauriEvent$1) {
15
+ TauriEvent$1["WINDOW_RESIZED"] = "tauri://resize";
16
+ TauriEvent$1["WINDOW_MOVED"] = "tauri://move";
17
+ TauriEvent$1["WINDOW_CLOSE_REQUESTED"] = "tauri://close-requested";
18
+ TauriEvent$1["WINDOW_DESTROYED"] = "tauri://destroyed";
19
+ TauriEvent$1["WINDOW_FOCUS"] = "tauri://focus";
20
+ TauriEvent$1["WINDOW_BLUR"] = "tauri://blur";
21
+ TauriEvent$1["WINDOW_SCALE_FACTOR_CHANGED"] = "tauri://scale-change";
22
+ TauriEvent$1["WINDOW_THEME_CHANGED"] = "tauri://theme-changed";
23
+ TauriEvent$1["WINDOW_CREATED"] = "tauri://window-created";
24
+ TauriEvent$1["WEBVIEW_CREATED"] = "tauri://webview-created";
25
+ TauriEvent$1["DRAG_ENTER"] = "tauri://drag-enter";
26
+ TauriEvent$1["DRAG_OVER"] = "tauri://drag-over";
27
+ TauriEvent$1["DRAG_DROP"] = "tauri://drag-drop";
28
+ TauriEvent$1["DRAG_LEAVE"] = "tauri://drag-leave";
29
+ })(TauriEvent || (TauriEvent = {}));
30
+ /**
31
+ * Unregister the event listener associated with the given name and id.
32
+ *
33
+ * @ignore
34
+ * @param event The event name
35
+ * @param eventId Event identifier
36
+ * @returns
37
+ */
38
+ async function _unlisten(event, eventId) {
39
+ window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(event, eventId);
40
+ await invoke("plugin:event|unlisten", {
41
+ event,
42
+ eventId
43
+ });
44
+ }
45
+ /**
46
+ * Listen to an emitted event to any {@link EventTarget|target}.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { listen } from '@tauri-apps/api/event';
51
+ * const unlisten = await listen<string>('error', (event) => {
52
+ * console.log(`Got error, payload: ${event.payload}`);
53
+ * });
54
+ *
55
+ * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
56
+ * unlisten();
57
+ * ```
58
+ *
59
+ * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
60
+ * @param handler Event handler callback.
61
+ * @param options Event listening options.
62
+ * @returns A promise resolving to a function to unlisten to the event.
63
+ * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
64
+ *
65
+ * @since 1.0.0
66
+ */
67
+ async function listen(event, handler, options) {
68
+ var _a;
69
+ return invoke("plugin:event|listen", {
70
+ event,
71
+ target: typeof (options === null || options === void 0 ? void 0 : options.target) === "string" ? {
72
+ kind: "AnyLabel",
73
+ label: options.target
74
+ } : (_a = options === null || options === void 0 ? void 0 : options.target) !== null && _a !== void 0 ? _a : { kind: "Any" },
75
+ handler: transformCallback(handler)
76
+ }).then((eventId) => {
77
+ return async () => _unlisten(event, eventId);
78
+ });
79
+ }
80
+
81
+ //#endregion
82
+ export { listen };
83
+ //# sourceMappingURL=event-BovtnpSn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-BovtnpSn.mjs","names":[],"sources":["../../../node_modules/.pnpm/@tauri-apps+api@2.10.1/node_modules/@tauri-apps/api/event.js"],"sourcesContent":["import { invoke, transformCallback } from './core.js';\n\n// Copyright 2019-2024 Tauri Programme within The Commons Conservancy\n// SPDX-License-Identifier: Apache-2.0\n// SPDX-License-Identifier: MIT\n/**\n * The event system allows you to emit events to the backend and listen to events from it.\n *\n * This package is also accessible with `window.__TAURI__.event` when [`app.withGlobalTauri`](https://v2.tauri.app/reference/config/#withglobaltauri) in `tauri.conf.json` is set to `true`.\n * @module\n */\n/**\n * @since 1.1.0\n */\nvar TauriEvent;\n(function (TauriEvent) {\n TauriEvent[\"WINDOW_RESIZED\"] = \"tauri://resize\";\n TauriEvent[\"WINDOW_MOVED\"] = \"tauri://move\";\n TauriEvent[\"WINDOW_CLOSE_REQUESTED\"] = \"tauri://close-requested\";\n TauriEvent[\"WINDOW_DESTROYED\"] = \"tauri://destroyed\";\n TauriEvent[\"WINDOW_FOCUS\"] = \"tauri://focus\";\n TauriEvent[\"WINDOW_BLUR\"] = \"tauri://blur\";\n TauriEvent[\"WINDOW_SCALE_FACTOR_CHANGED\"] = \"tauri://scale-change\";\n TauriEvent[\"WINDOW_THEME_CHANGED\"] = \"tauri://theme-changed\";\n TauriEvent[\"WINDOW_CREATED\"] = \"tauri://window-created\";\n TauriEvent[\"WEBVIEW_CREATED\"] = \"tauri://webview-created\";\n TauriEvent[\"DRAG_ENTER\"] = \"tauri://drag-enter\";\n TauriEvent[\"DRAG_OVER\"] = \"tauri://drag-over\";\n TauriEvent[\"DRAG_DROP\"] = \"tauri://drag-drop\";\n TauriEvent[\"DRAG_LEAVE\"] = \"tauri://drag-leave\";\n})(TauriEvent || (TauriEvent = {}));\n/**\n * Unregister the event listener associated with the given name and id.\n *\n * @ignore\n * @param event The event name\n * @param eventId Event identifier\n * @returns\n */\nasync function _unlisten(event, eventId) {\n window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(event, eventId);\n await invoke('plugin:event|unlisten', {\n event,\n eventId\n });\n}\n/**\n * Listen to an emitted event to any {@link EventTarget|target}.\n *\n * @example\n * ```typescript\n * import { listen } from '@tauri-apps/api/event';\n * const unlisten = await listen<string>('error', (event) => {\n * console.log(`Got error, payload: ${event.payload}`);\n * });\n *\n * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted\n * unlisten();\n * ```\n *\n * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.\n * @param handler Event handler callback.\n * @param options Event listening options.\n * @returns A promise resolving to a function to unlisten to the event.\n * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.\n *\n * @since 1.0.0\n */\nasync function listen(event, handler, options) {\n var _a;\n const target = typeof (options === null || options === void 0 ? void 0 : options.target) === 'string'\n ? { kind: 'AnyLabel', label: options.target }\n : ((_a = options === null || options === void 0 ? void 0 : options.target) !== null && _a !== void 0 ? _a : { kind: 'Any' });\n return invoke('plugin:event|listen', {\n event,\n target,\n handler: transformCallback(handler)\n }).then((eventId) => {\n return async () => _unlisten(event, eventId);\n });\n}\n/**\n * Listens once to an emitted event to any {@link EventTarget|target}.\n *\n * @example\n * ```typescript\n * import { once } from '@tauri-apps/api/event';\n * interface LoadedPayload {\n * loggedIn: boolean,\n * token: string\n * }\n * const unlisten = await once<LoadedPayload>('loaded', (event) => {\n * console.log(`App is loaded, loggedIn: ${event.payload.loggedIn}, token: ${event.payload.token}`);\n * });\n *\n * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted\n * unlisten();\n * ```\n *\n * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.\n * @param handler Event handler callback.\n * @param options Event listening options.\n * @returns A promise resolving to a function to unlisten to the event.\n * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.\n *\n * @since 1.0.0\n */\nasync function once(event, handler, options) {\n return listen(event, (eventData) => {\n void _unlisten(event, eventData.id);\n handler(eventData);\n }, options);\n}\n/**\n * Emits an event to all {@link EventTarget|targets}.\n *\n * @example\n * ```typescript\n * import { emit } from '@tauri-apps/api/event';\n * await emit('frontend-loaded', { loggedIn: true, token: 'authToken' });\n * ```\n *\n * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.\n * @param payload Event payload.\n *\n * @since 1.0.0\n */\nasync function emit(event, payload) {\n await invoke('plugin:event|emit', {\n event,\n payload\n });\n}\n/**\n * Emits an event to all {@link EventTarget|targets} matching the given target.\n *\n * @example\n * ```typescript\n * import { emitTo } from '@tauri-apps/api/event';\n * await emitTo('main', 'frontend-loaded', { loggedIn: true, token: 'authToken' });\n * ```\n *\n * @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.\n * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.\n * @param payload Event payload.\n *\n * @since 2.0.0\n */\nasync function emitTo(target, event, payload) {\n const eventTarget = typeof target === 'string' ? { kind: 'AnyLabel', label: target } : target;\n await invoke('plugin:event|emit_to', {\n target: eventTarget,\n event,\n payload\n });\n}\n\nexport { TauriEvent, emit, emitTo, listen, once };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;AAcA,IAAI;CACH,SAAU,cAAY;AACnB,cAAW,oBAAoB;AAC/B,cAAW,kBAAkB;AAC7B,cAAW,4BAA4B;AACvC,cAAW,sBAAsB;AACjC,cAAW,kBAAkB;AAC7B,cAAW,iBAAiB;AAC5B,cAAW,iCAAiC;AAC5C,cAAW,0BAA0B;AACrC,cAAW,oBAAoB;AAC/B,cAAW,qBAAqB;AAChC,cAAW,gBAAgB;AAC3B,cAAW,eAAe;AAC1B,cAAW,eAAe;AAC1B,cAAW,gBAAgB;GAC5B,eAAe,aAAa,EAAE,EAAE;;;;;;;;;AASnC,eAAe,UAAU,OAAO,SAAS;AACrC,QAAO,iCAAiC,mBAAmB,OAAO,QAAQ;AAC1E,OAAM,OAAO,yBAAyB;EAClC;EACA;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAwBN,eAAe,OAAO,OAAO,SAAS,SAAS;CAC3C,IAAI;AAIJ,QAAO,OAAO,uBAAuB;EACjC;EACA,QALW,QAAQ,YAAY,QAAQ,YAAY,KAAK,IAAI,KAAK,IAAI,QAAQ,YAAY,WACvF;GAAE,MAAM;GAAY,OAAO,QAAQ;GAAQ,IACzC,KAAK,YAAY,QAAQ,YAAY,KAAK,IAAI,KAAK,IAAI,QAAQ,YAAY,QAAQ,OAAO,KAAK,IAAI,KAAK,EAAE,MAAM,OAAO;EAI3H,SAAS,kBAAkB,QAAQ;EACtC,CAAC,CAAC,MAAM,YAAY;AACjB,SAAO,YAAY,UAAU,OAAO,QAAQ;GAC9C"}