@statewalker/platform.core 0.5.1 → 0.5.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/README.md +82 -36
- package/dist/commands/copy-to-clipboard/index.js +1 -1
- package/dist/commands/copy-to-clipboard/index.js.map +1 -1
- package/dist/commands/download-blob/index.js +1 -1
- package/dist/commands/download-blob/index.js.map +1 -1
- package/dist/commands/download-to-files/index.js +1 -1
- package/dist/commands/download-to-files/index.js.map +1 -1
- package/dist/commands/pick-directory/index.js +1 -1
- package/dist/commands/pick-directory/index.js.map +1 -1
- package/dist/commands/pick-file/index.js +1 -1
- package/dist/commands/pick-file/index.js.map +1 -1
- package/dist/commands/preference-get/index.js +1 -1
- package/dist/commands/preference-get/index.js.map +1 -1
- package/dist/commands/preference-set/index.js +1 -1
- package/dist/commands/preference-set/index.js.map +1 -1
- package/package.json +9 -5
- package/src/commands/copy-to-clipboard/index.ts +1 -1
- package/src/commands/download-blob/index.ts +1 -1
- package/src/commands/download-to-files/index.ts +1 -1
- package/src/commands/pick-directory/index.ts +1 -1
- package/src/commands/pick-file/index.ts +1 -1
- package/src/commands/preference-get/index.ts +1 -1
- package/src/commands/preference-set/index.ts +1 -1
package/README.md
CHANGED
|
@@ -1,52 +1,78 @@
|
|
|
1
1
|
# @statewalker/platform.core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## What it is
|
|
4
|
+
|
|
5
|
+
The contract for host capabilities: pick a directory or files, download, copy to the clipboard, read and write durable preferences, and keep application state in the URL. Each capability is a command declaration for the workspace's `Commands` bus (`@statewalker/shared-commands`). This package declares them; `@statewalker/platform.browser` and `@statewalker/platform.node` answer them.
|
|
4
6
|
|
|
5
7
|
## Why it exists
|
|
6
8
|
|
|
7
|
-
Fragments need
|
|
9
|
+
Fragments need to ask the host for things like "let the user choose a folder" without knowing whether they run in a browser tab, a Node test or another shell. Putting the typed contract here, with no host code, lets a fragment call `PickDirectoryCommand` the same way everywhere, and lets tests register fake handlers. The package touches no `window`, `document` or other browser global, so it runs unchanged in Node.
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## How to use
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
```sh
|
|
14
|
+
pnpm add @statewalker/platform.core
|
|
15
|
+
```
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| [`pick-file/`](src/commands/pick-file/) | `platform:pick-file` | File picker returning `{ blobs: Blob[]; names }`. |
|
|
17
|
-
| [`download-to-files/`](src/commands/download-to-files/) | `platform:download-to-files` | Stream a URL into a `FilesApi` path with optional resume + `AbortSignal`. |
|
|
18
|
-
| [`copy-to-clipboard/`](src/commands/copy-to-clipboard/) | `platform:copy-to-clipboard` | Copy text. |
|
|
19
|
-
| [`download-blob/`](src/commands/download-blob/) | `platform:download-blob` | Trigger a browser "Save As" for a `Blob`. |
|
|
20
|
-
| [`preference-get/`](src/commands/preference-get/) | `platform:preference-get` | Read a durable host-provided key/value pair. |
|
|
21
|
-
| [`preference-set/`](src/commands/preference-set/) | `platform:preference-set` | Write a durable host-provided key/value pair. |
|
|
17
|
+
1. Make sure a host implementation is active (for example `@statewalker/platform.browser` as a manifest root).
|
|
18
|
+
2. Get the bus with `getCommands(ctx)`.
|
|
19
|
+
3. Call a declaration: `getCommands(ctx).call(Declaration, payload).promise`.
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
| Declaration | Key | Payload -> result |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| `PickDirectoryCommand` | `platform:pick-directory` | `{ title? }` -> `{ files: FilesApi; label }` |
|
|
24
|
+
| `PickFileCommand` | `platform:pick-file` | `{ title?, accept?, multiple? }` -> `{ blobs: Blob[]; names: string[] }` |
|
|
25
|
+
| `DownloadToFilesCommand` | `platform:download-to-files` | `{ url, files, path, resume?, onProgress?, signal? }` -> `{ bytes }` |
|
|
26
|
+
| `CopyToClipboardCommand` | `platform:copy-to-clipboard` | `{ text }` -> `void` |
|
|
27
|
+
| `DownloadBlobCommand` | `platform:download-blob` | `{ blob, filename }` -> `void` |
|
|
28
|
+
| `PreferenceGetCommand` | `platform:preference-get` | `{ key }` -> `{ value }` |
|
|
29
|
+
| `PreferenceSetCommand` | `platform:preference-set` | `{ key, value }` -> `void` |
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
Each key is also exported as a constant (`PICK_DIRECTORY_COMMAND_KEY`, `PICK_FILE_COMMAND_KEY`, `DOWNLOAD_TO_FILES_COMMAND_KEY`, `COPY_TO_CLIPBOARD_COMMAND_KEY`, `DOWNLOAD_BLOB_COMMAND_KEY`, `PREFERENCE_GET_COMMAND_KEY`, `PREFERENCE_SET_COMMAND_KEY`), with payload and result types named after the command (`PickDirectoryPayload`, `PickDirectoryResult`, ..., `DownloadProgress`). `FilesApi` is from `@statewalker/webrun-files`.
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
## Examples
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
import { getCommands, getUrlStateView } from "@statewalker/platform.core";
|
|
35
|
+
Ask for a directory and handle cancellation:
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
```ts
|
|
38
|
+
import { getCommands, isUserCancelled, PickDirectoryCommand } from "@statewalker/platform.core";
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const { files, label } = await getCommands(ctx).call(PickDirectoryCommand, {
|
|
42
|
+
title: "Select workspace",
|
|
43
|
+
}).promise;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (!isUserCancelled(error)) throw error;
|
|
46
|
+
}
|
|
34
47
|
```
|
|
35
48
|
|
|
36
|
-
|
|
37
|
-
- **`UrlStateView`** — bidirectional URL ↔ model state synchronisation. Fragments register `UrlSerializer`s; the browser binding (in `platform.browser`) flushes serialised state to `location.hash` and feeds incoming `hashchange` back. Auto-created on first access.
|
|
38
|
-
|
|
39
|
-
## Usage
|
|
49
|
+
Store a preference:
|
|
40
50
|
|
|
41
51
|
```ts
|
|
42
|
-
import { getCommands,
|
|
52
|
+
import { getCommands, PreferenceGetCommand, PreferenceSetCommand } from "@statewalker/platform.core";
|
|
43
53
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
});
|
|
54
|
+
const commands = getCommands(ctx);
|
|
55
|
+
await commands.call(PreferenceSetCommand, { key: "theme", value: "dark" }).promise;
|
|
56
|
+
const { value } = await commands.call(PreferenceGetCommand, { key: "theme" }).promise;
|
|
47
57
|
```
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
Download into a `FilesApi` with progress:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { DownloadToFilesCommand, getCommands } from "@statewalker/platform.core";
|
|
63
|
+
|
|
64
|
+
const controller = new AbortController();
|
|
65
|
+
const { bytes } = await getCommands(ctx).call(DownloadToFilesCommand, {
|
|
66
|
+
url: "https://example.com/model.bin",
|
|
67
|
+
files,
|
|
68
|
+
path: "/models/model.bin",
|
|
69
|
+
resume: true,
|
|
70
|
+
onProgress: ({ loaded, total }) => console.log(loaded, total),
|
|
71
|
+
signal: controller.signal,
|
|
72
|
+
}).promise;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Keep state in the URL:
|
|
50
76
|
|
|
51
77
|
```ts
|
|
52
78
|
import { getUrlStateView, type UrlSerializer } from "@statewalker/platform.core";
|
|
@@ -56,19 +82,39 @@ const serializer: UrlSerializer = {
|
|
|
56
82
|
deserialize: (state) => switchToSession(state.query.session),
|
|
57
83
|
};
|
|
58
84
|
|
|
59
|
-
const
|
|
85
|
+
const view = getUrlStateView(ctx);
|
|
86
|
+
const unregister = view.register(serializer);
|
|
87
|
+
view.sync(); // the host binding writes view.buildState() to the URL
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Signal cancellation from a handler:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { UserCancelledError } from "@statewalker/platform.core";
|
|
94
|
+
|
|
95
|
+
command.reject(new UserCancelledError());
|
|
60
96
|
```
|
|
61
97
|
|
|
62
98
|
## Internals
|
|
63
99
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
100
|
+
### A call with no handler fails at once
|
|
101
|
+
|
|
102
|
+
Every declaration uses the `async` dispatch policy of `@statewalker/shared-commands`: when no handler is registered at call time, the call rejects immediately with `CommandError` with `kind: "no-handlers"` (`commandKey` names the command). A handler registered later does not pick up earlier calls. This happens on a host that does not implement a command (for example the pickers or the clipboard under `@statewalker/platform.node`), or when the call is made before the host fragment has started: start the platform fragment before the fragments that call it, and catch the error where the host may lack the command. A handler that takes the call without settling it (a listener that only observes) still leaves it pending.
|
|
103
|
+
|
|
104
|
+
### Cancellation is a type, not a string
|
|
105
|
+
|
|
106
|
+
`UserCancelledError` (`name === "UserCancelledError"`) and `isUserCancelled(error)` let callers tell "the user closed the dialog" from a real failure with one `instanceof` check, instead of matching `AbortError` names or messages.
|
|
107
|
+
|
|
108
|
+
### The bus and the URL view are per workspace or per context
|
|
109
|
+
|
|
110
|
+
`getCommands(ctx)` returns `getWorkspace(ctx).requireAdapter(Commands)` from `@statewalker/workspace.core`, created on first use, so all fragments under one workspace share one bus. `setCommands` and `removeCommands` are kept only so old start-up code compiles; they do nothing except log `[platform-api] setCommands is deprecated and a no-op: ...`.
|
|
111
|
+
|
|
112
|
+
`getUrlStateView(ctx)` (with `setUrlStateView` and `removeUrlStateView`) stores a `Navigation` instance (also exported as `UrlStateView`) under the context key `model:url-state`. `Navigation` extends `BaseClass` from `@statewalker/shared-baseclass`; `sync()` notifies `onUpdate` listeners, `buildState()` folds all serializers over `{ path: "", query: {} }`, and `applyUrl(state)` feeds an incoming URL state to every serializer. One `#syncing` flag blocks re-entry, so a write to the URL never triggers a read back into the model in the same turn, and the reverse.
|
|
67
113
|
|
|
68
|
-
|
|
114
|
+
### Dependencies
|
|
69
115
|
|
|
70
|
-
- `@statewalker/
|
|
116
|
+
`@statewalker/shared-commands` (command declarations and bus), `@statewalker/workspace.core` (the workspace that owns the bus), `@statewalker/shared-adapters` and `@statewalker/shared-baseclass` (the URL view adapter and its observable base), `@statewalker/webrun-files` (the `FilesApi` type in payloads).
|
|
71
117
|
|
|
72
118
|
## License
|
|
73
119
|
|
|
74
|
-
MIT
|
|
120
|
+
MIT
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, passthrough } from "@statewalker/shared-commands";
|
|
2
2
|
//#region src/commands/copy-to-clipboard/index.ts
|
|
3
3
|
const COPY_TO_CLIPBOARD_COMMAND_KEY = "platform:copy-to-clipboard";
|
|
4
|
-
const CopyToClipboardCommand = Command.
|
|
4
|
+
const CopyToClipboardCommand = Command.async(COPY_TO_CLIPBOARD_COMMAND_KEY).input(passthrough()).output(passthrough()).build();
|
|
5
5
|
//#endregion
|
|
6
6
|
export { COPY_TO_CLIPBOARD_COMMAND_KEY, CopyToClipboardCommand };
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/copy-to-clipboard/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const COPY_TO_CLIPBOARD_COMMAND_KEY = \"platform:copy-to-clipboard\";\n\nexport interface CopyToClipboardPayload {\n text: string;\n}\n\nexport const CopyToClipboardCommand = Command.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/copy-to-clipboard/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const COPY_TO_CLIPBOARD_COMMAND_KEY = \"platform:copy-to-clipboard\";\n\nexport interface CopyToClipboardPayload {\n text: string;\n}\n\nexport const CopyToClipboardCommand = Command.async(COPY_TO_CLIPBOARD_COMMAND_KEY)\n .input(passthrough<CopyToClipboardPayload>())\n .output(passthrough<void>())\n .build();\n"],"mappings":";;AAEA,MAAa,gCAAgC;AAM7C,MAAa,yBAAyB,QAAQ,MAAM,6BAA6B,CAAC,CAC/E,MAAM,YAAoC,CAAC,CAAC,CAC5C,OAAO,YAAkB,CAAC,CAAC,CAC3B,MAAM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, passthrough } from "@statewalker/shared-commands";
|
|
2
2
|
//#region src/commands/download-blob/index.ts
|
|
3
3
|
const DOWNLOAD_BLOB_COMMAND_KEY = "platform:download-blob";
|
|
4
|
-
const DownloadBlobCommand = Command.
|
|
4
|
+
const DownloadBlobCommand = Command.async(DOWNLOAD_BLOB_COMMAND_KEY).input(passthrough()).output(passthrough()).build();
|
|
5
5
|
//#endregion
|
|
6
6
|
export { DOWNLOAD_BLOB_COMMAND_KEY, DownloadBlobCommand };
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/download-blob/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const DOWNLOAD_BLOB_COMMAND_KEY = \"platform:download-blob\";\n\nexport interface DownloadBlobPayload {\n blob: Blob;\n filename: string;\n}\n\nexport const DownloadBlobCommand = Command.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/download-blob/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const DOWNLOAD_BLOB_COMMAND_KEY = \"platform:download-blob\";\n\nexport interface DownloadBlobPayload {\n blob: Blob;\n filename: string;\n}\n\nexport const DownloadBlobCommand = Command.async(DOWNLOAD_BLOB_COMMAND_KEY)\n .input(passthrough<DownloadBlobPayload>())\n .output(passthrough<void>())\n .build();\n"],"mappings":";;AAEA,MAAa,4BAA4B;AAOzC,MAAa,sBAAsB,QAAQ,MAAM,yBAAyB,CAAC,CACxE,MAAM,YAAiC,CAAC,CAAC,CACzC,OAAO,YAAkB,CAAC,CAAC,CAC3B,MAAM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, passthrough } from "@statewalker/shared-commands";
|
|
2
2
|
//#region src/commands/download-to-files/index.ts
|
|
3
3
|
const DOWNLOAD_TO_FILES_COMMAND_KEY = "platform:download-to-files";
|
|
4
|
-
const DownloadToFilesCommand = Command.
|
|
4
|
+
const DownloadToFilesCommand = Command.async(DOWNLOAD_TO_FILES_COMMAND_KEY).input(passthrough()).output(passthrough()).build();
|
|
5
5
|
//#endregion
|
|
6
6
|
export { DOWNLOAD_TO_FILES_COMMAND_KEY, DownloadToFilesCommand };
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/download-to-files/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\nimport type { FilesApi } from \"@statewalker/webrun-files\";\n\nexport const DOWNLOAD_TO_FILES_COMMAND_KEY = \"platform:download-to-files\";\n\nexport interface DownloadProgress {\n loaded: number;\n total?: number;\n}\n\nexport interface DownloadToFilesPayload {\n url: string;\n files: FilesApi;\n path: string;\n resume?: boolean;\n onProgress?: (progress: DownloadProgress) => void;\n signal?: AbortSignal;\n}\n\nexport interface DownloadToFilesResult {\n bytes: number;\n}\n\nexport const DownloadToFilesCommand = Command.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/download-to-files/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\nimport type { FilesApi } from \"@statewalker/webrun-files\";\n\nexport const DOWNLOAD_TO_FILES_COMMAND_KEY = \"platform:download-to-files\";\n\nexport interface DownloadProgress {\n loaded: number;\n total?: number;\n}\n\nexport interface DownloadToFilesPayload {\n url: string;\n files: FilesApi;\n path: string;\n resume?: boolean;\n onProgress?: (progress: DownloadProgress) => void;\n signal?: AbortSignal;\n}\n\nexport interface DownloadToFilesResult {\n bytes: number;\n}\n\nexport const DownloadToFilesCommand = Command.async(DOWNLOAD_TO_FILES_COMMAND_KEY)\n .input(passthrough<DownloadToFilesPayload>())\n .output(passthrough<DownloadToFilesResult>())\n .build();\n"],"mappings":";;AAGA,MAAa,gCAAgC;AAoB7C,MAAa,yBAAyB,QAAQ,MAAM,6BAA6B,CAAC,CAC/E,MAAM,YAAoC,CAAC,CAAC,CAC5C,OAAO,YAAmC,CAAC,CAAC,CAC5C,MAAM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, passthrough } from "@statewalker/shared-commands";
|
|
2
2
|
//#region src/commands/pick-directory/index.ts
|
|
3
3
|
const PICK_DIRECTORY_COMMAND_KEY = "platform:pick-directory";
|
|
4
|
-
const PickDirectoryCommand = Command.
|
|
4
|
+
const PickDirectoryCommand = Command.async(PICK_DIRECTORY_COMMAND_KEY).input(passthrough()).output(passthrough()).build();
|
|
5
5
|
//#endregion
|
|
6
6
|
export { PICK_DIRECTORY_COMMAND_KEY, PickDirectoryCommand };
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/pick-directory/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\nimport type { FilesApi } from \"@statewalker/webrun-files\";\n\nexport const PICK_DIRECTORY_COMMAND_KEY = \"platform:pick-directory\";\n\nexport interface PickDirectoryPayload {\n title?: string;\n}\n\nexport interface PickDirectoryResult {\n files: FilesApi;\n label: string;\n}\n\nexport const PickDirectoryCommand = Command.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/pick-directory/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\nimport type { FilesApi } from \"@statewalker/webrun-files\";\n\nexport const PICK_DIRECTORY_COMMAND_KEY = \"platform:pick-directory\";\n\nexport interface PickDirectoryPayload {\n title?: string;\n}\n\nexport interface PickDirectoryResult {\n files: FilesApi;\n label: string;\n}\n\nexport const PickDirectoryCommand = Command.async(PICK_DIRECTORY_COMMAND_KEY)\n .input(passthrough<PickDirectoryPayload>())\n .output(passthrough<PickDirectoryResult>())\n .build();\n"],"mappings":";;AAGA,MAAa,6BAA6B;AAW1C,MAAa,uBAAuB,QAAQ,MAAM,0BAA0B,CAAC,CAC1E,MAAM,YAAkC,CAAC,CAAC,CAC1C,OAAO,YAAiC,CAAC,CAAC,CAC1C,MAAM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, passthrough } from "@statewalker/shared-commands";
|
|
2
2
|
//#region src/commands/pick-file/index.ts
|
|
3
3
|
const PICK_FILE_COMMAND_KEY = "platform:pick-file";
|
|
4
|
-
const PickFileCommand = Command.
|
|
4
|
+
const PickFileCommand = Command.async(PICK_FILE_COMMAND_KEY).input(passthrough()).output(passthrough()).build();
|
|
5
5
|
//#endregion
|
|
6
6
|
export { PICK_FILE_COMMAND_KEY, PickFileCommand };
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/pick-file/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const PICK_FILE_COMMAND_KEY = \"platform:pick-file\";\n\nexport interface PickFilePayload {\n title?: string;\n accept?: string[];\n multiple?: boolean;\n}\n\nexport interface PickFileResult {\n blobs: Blob[];\n names: string[];\n}\n\nexport const PickFileCommand = Command.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/pick-file/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const PICK_FILE_COMMAND_KEY = \"platform:pick-file\";\n\nexport interface PickFilePayload {\n title?: string;\n accept?: string[];\n multiple?: boolean;\n}\n\nexport interface PickFileResult {\n blobs: Blob[];\n names: string[];\n}\n\nexport const PickFileCommand = Command.async(PICK_FILE_COMMAND_KEY)\n .input(passthrough<PickFilePayload>())\n .output(passthrough<PickFileResult>())\n .build();\n"],"mappings":";;AAEA,MAAa,wBAAwB;AAarC,MAAa,kBAAkB,QAAQ,MAAM,qBAAqB,CAAC,CAChE,MAAM,YAA6B,CAAC,CAAC,CACrC,OAAO,YAA4B,CAAC,CAAC,CACrC,MAAM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, passthrough } from "@statewalker/shared-commands";
|
|
2
2
|
//#region src/commands/preference-get/index.ts
|
|
3
3
|
const PREFERENCE_GET_COMMAND_KEY = "platform:preference-get";
|
|
4
|
-
const PreferenceGetCommand = Command.
|
|
4
|
+
const PreferenceGetCommand = Command.async(PREFERENCE_GET_COMMAND_KEY).input(passthrough()).output(passthrough()).build();
|
|
5
5
|
//#endregion
|
|
6
6
|
export { PREFERENCE_GET_COMMAND_KEY, PreferenceGetCommand };
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/preference-get/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const PREFERENCE_GET_COMMAND_KEY = \"platform:preference-get\";\n\nexport interface PreferenceGetPayload {\n key: string;\n}\n\nexport interface PreferenceGetResult {\n value: unknown | undefined;\n}\n\nexport const PreferenceGetCommand = Command.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/preference-get/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const PREFERENCE_GET_COMMAND_KEY = \"platform:preference-get\";\n\nexport interface PreferenceGetPayload {\n key: string;\n}\n\nexport interface PreferenceGetResult {\n value: unknown | undefined;\n}\n\nexport const PreferenceGetCommand = Command.async(PREFERENCE_GET_COMMAND_KEY)\n .input(passthrough<PreferenceGetPayload>())\n .output(passthrough<PreferenceGetResult>())\n .build();\n"],"mappings":";;AAEA,MAAa,6BAA6B;AAU1C,MAAa,uBAAuB,QAAQ,MAAM,0BAA0B,CAAC,CAC1E,MAAM,YAAkC,CAAC,CAAC,CAC1C,OAAO,YAAiC,CAAC,CAAC,CAC1C,MAAM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, passthrough } from "@statewalker/shared-commands";
|
|
2
2
|
//#region src/commands/preference-set/index.ts
|
|
3
3
|
const PREFERENCE_SET_COMMAND_KEY = "platform:preference-set";
|
|
4
|
-
const PreferenceSetCommand = Command.
|
|
4
|
+
const PreferenceSetCommand = Command.async(PREFERENCE_SET_COMMAND_KEY).input(passthrough()).output(passthrough()).build();
|
|
5
5
|
//#endregion
|
|
6
6
|
export { PREFERENCE_SET_COMMAND_KEY, PreferenceSetCommand };
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/preference-set/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const PREFERENCE_SET_COMMAND_KEY = \"platform:preference-set\";\n\nexport interface PreferenceSetPayload {\n key: string;\n value: unknown;\n}\n\nexport const PreferenceSetCommand = Command.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/commands/preference-set/index.ts"],"sourcesContent":["import { Command, passthrough } from \"@statewalker/shared-commands\";\n\nexport const PREFERENCE_SET_COMMAND_KEY = \"platform:preference-set\";\n\nexport interface PreferenceSetPayload {\n key: string;\n value: unknown;\n}\n\nexport const PreferenceSetCommand = Command.async(PREFERENCE_SET_COMMAND_KEY)\n .input(passthrough<PreferenceSetPayload>())\n .output(passthrough<void>())\n .build();\n"],"mappings":";;AAEA,MAAa,6BAA6B;AAO1C,MAAa,uBAAuB,QAAQ,MAAM,0BAA0B,CAAC,CAC1E,MAAM,YAAkC,CAAC,CAAC,CAC1C,OAAO,YAAkB,CAAC,CAAC,CAC3B,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/platform.core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Platform-capability
|
|
7
|
-
"
|
|
6
|
+
"description": "Platform-capability command declarations (pickers, downloads, clipboard, preferences, URL state) shared by statewalker fragments.",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/statewalker/statewalker-kernel/issues"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/statewalker/statewalker-kernel/tree/main/packages/platform.core#readme",
|
|
8
11
|
"author": {
|
|
9
12
|
"name": "Mikhail Kotelnikov",
|
|
10
13
|
"email": "mikhail.kotelnikov@gmail.com"
|
|
@@ -12,7 +15,8 @@
|
|
|
12
15
|
"license": "MIT",
|
|
13
16
|
"repository": {
|
|
14
17
|
"type": "git",
|
|
15
|
-
"url": "git+
|
|
18
|
+
"url": "git+https://github.com/statewalker/statewalker-kernel.git",
|
|
19
|
+
"directory": "packages/platform.core"
|
|
16
20
|
},
|
|
17
21
|
"exports": {
|
|
18
22
|
".": {
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
"@statewalker/shared-baseclass": "^0.1.0",
|
|
32
36
|
"@statewalker/shared-commands": "^0.2.0",
|
|
33
37
|
"@statewalker/webrun-files": "^0.10.0",
|
|
34
|
-
"@statewalker/workspace.core": "^0.5.
|
|
38
|
+
"@statewalker/workspace.core": "^0.5.2"
|
|
35
39
|
},
|
|
36
40
|
"devDependencies": {
|
|
37
41
|
"rimraf": "^6.1.3",
|
|
@@ -6,7 +6,7 @@ export interface CopyToClipboardPayload {
|
|
|
6
6
|
text: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const CopyToClipboardCommand = Command.
|
|
9
|
+
export const CopyToClipboardCommand = Command.async(COPY_TO_CLIPBOARD_COMMAND_KEY)
|
|
10
10
|
.input(passthrough<CopyToClipboardPayload>())
|
|
11
11
|
.output(passthrough<void>())
|
|
12
12
|
.build();
|
|
@@ -7,7 +7,7 @@ export interface DownloadBlobPayload {
|
|
|
7
7
|
filename: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const DownloadBlobCommand = Command.
|
|
10
|
+
export const DownloadBlobCommand = Command.async(DOWNLOAD_BLOB_COMMAND_KEY)
|
|
11
11
|
.input(passthrough<DownloadBlobPayload>())
|
|
12
12
|
.output(passthrough<void>())
|
|
13
13
|
.build();
|
|
@@ -21,7 +21,7 @@ export interface DownloadToFilesResult {
|
|
|
21
21
|
bytes: number;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const DownloadToFilesCommand = Command.
|
|
24
|
+
export const DownloadToFilesCommand = Command.async(DOWNLOAD_TO_FILES_COMMAND_KEY)
|
|
25
25
|
.input(passthrough<DownloadToFilesPayload>())
|
|
26
26
|
.output(passthrough<DownloadToFilesResult>())
|
|
27
27
|
.build();
|
|
@@ -12,7 +12,7 @@ export interface PickDirectoryResult {
|
|
|
12
12
|
label: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const PickDirectoryCommand = Command.
|
|
15
|
+
export const PickDirectoryCommand = Command.async(PICK_DIRECTORY_COMMAND_KEY)
|
|
16
16
|
.input(passthrough<PickDirectoryPayload>())
|
|
17
17
|
.output(passthrough<PickDirectoryResult>())
|
|
18
18
|
.build();
|
|
@@ -13,7 +13,7 @@ export interface PickFileResult {
|
|
|
13
13
|
names: string[];
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const PickFileCommand = Command.
|
|
16
|
+
export const PickFileCommand = Command.async(PICK_FILE_COMMAND_KEY)
|
|
17
17
|
.input(passthrough<PickFilePayload>())
|
|
18
18
|
.output(passthrough<PickFileResult>())
|
|
19
19
|
.build();
|
|
@@ -10,7 +10,7 @@ export interface PreferenceGetResult {
|
|
|
10
10
|
value: unknown | undefined;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const PreferenceGetCommand = Command.
|
|
13
|
+
export const PreferenceGetCommand = Command.async(PREFERENCE_GET_COMMAND_KEY)
|
|
14
14
|
.input(passthrough<PreferenceGetPayload>())
|
|
15
15
|
.output(passthrough<PreferenceGetResult>())
|
|
16
16
|
.build();
|
|
@@ -7,7 +7,7 @@ export interface PreferenceSetPayload {
|
|
|
7
7
|
value: unknown;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const PreferenceSetCommand = Command.
|
|
10
|
+
export const PreferenceSetCommand = Command.async(PREFERENCE_SET_COMMAND_KEY)
|
|
11
11
|
.input(passthrough<PreferenceSetPayload>())
|
|
12
12
|
.output(passthrough<void>())
|
|
13
13
|
.build();
|