@xpufx/paseo-slash 0.1.0 → 0.1.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/client/console.tsx
CHANGED
|
@@ -24,16 +24,23 @@ export interface ClipboardEnvironment {
|
|
|
24
24
|
* `react-native-web` `Clipboard.setString` reports success even when its
|
|
25
25
|
* `document.execCommand("copy")` fails, which leaves the previous clipboard
|
|
26
26
|
* item in place while the UI claims success (xpufx-org/paseo#278); it is only
|
|
27
|
-
* usable off-DOM (native), where it is the real platform clipboard.
|
|
28
|
-
*
|
|
27
|
+
* usable off-DOM (native), where it is the real platform clipboard. The same
|
|
28
|
+
* applies to any `setStringAsync` whose DOM fallback is that unverified
|
|
29
|
+
* `execCommand`. In a DOM the checked `execCommand` fallback is preferred to
|
|
30
|
+
* those unverifiable paths.
|
|
29
31
|
*/
|
|
30
32
|
export function clipboardTierOrder(env: ClipboardEnvironment): ClipboardTier[] {
|
|
31
33
|
const tiers: ClipboardTier[] = [];
|
|
32
34
|
if (env.hasNavigatorClipboard) tiers.push("navigator");
|
|
33
35
|
if (env.hasHostCopyText) tiers.push("host");
|
|
34
|
-
|
|
36
|
+
// On a DOM both RN-web paths are unverifiable: `setString` reports success
|
|
37
|
+
// even when its `execCommand` no-ops, and a `setStringAsync` that falls back
|
|
38
|
+
// to it does the same. Off-DOM they are the real native clipboard, so they
|
|
39
|
+
// lead there; on a DOM only the checked `execCommand` fallback is honest.
|
|
40
|
+
const rnDomOk = !env.isDom;
|
|
41
|
+
if (env.hasRnSetStringAsync && rnDomOk) {
|
|
35
42
|
tiers.push("rnAsync");
|
|
36
|
-
} else if (env.hasRnClipboard &&
|
|
43
|
+
} else if (env.hasRnClipboard && rnDomOk) {
|
|
37
44
|
tiers.push("rnSync");
|
|
38
45
|
}
|
|
39
46
|
tiers.push("execCommand");
|
package/index.client.tsx
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
3
|
+
import { Icon, Modal, useToast, ScrollView, FlatList, TextInput as HostTextInput, copyText } from "@getpaseo/plugin/client/react-native";
|
|
4
|
+
import { initClientHelpers, registerCommandCenterItem, registerSidebarSurface } from "./client/vendor/paseo-plugin-helper/index";
|
|
5
|
+
import { registerSlashCommands } from "./client/commands";
|
|
6
|
+
import { SlashConsole } from "./client/console";
|
|
7
|
+
|
|
8
|
+
initClientHelpers({ Icon, Modal, useRpc, useToast, copyText, ScrollView, FlatList, TextInput: HostTextInput });
|
|
9
|
+
|
|
10
|
+
const SLASH_CONSOLE_SURFACE = "slash-console";
|
|
11
|
+
|
|
12
|
+
export default function contribute(client: PluginClientContext) {
|
|
13
|
+
registerSidebarSurface(client, {
|
|
14
|
+
id: SLASH_CONSOLE_SURFACE,
|
|
15
|
+
title: "S/ash console",
|
|
16
|
+
icon: "Terminal",
|
|
17
|
+
Component: SlashConsole,
|
|
18
|
+
});
|
|
19
|
+
const removeCommandCenter = registerCommandCenterItem(client, {
|
|
20
|
+
id: "slash-console",
|
|
21
|
+
title: "S/ash console",
|
|
22
|
+
icon: "Terminal",
|
|
23
|
+
keywords: ["slash", "console", "settings", "commands"],
|
|
24
|
+
context: "global",
|
|
25
|
+
onSelect({ openSurface }) {
|
|
26
|
+
openSurface(SLASH_CONSOLE_SURFACE);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const removeCommands = registerSlashCommands(client);
|
|
30
|
+
return () => {
|
|
31
|
+
removeCommandCenter();
|
|
32
|
+
removeCommands();
|
|
33
|
+
};
|
|
34
|
+
}
|
package/index.server.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PluginServerContext } from "@getpaseo/plugin/server";
|
|
2
|
+
import {
|
|
3
|
+
catalogRpc,
|
|
4
|
+
exportBundleRpc,
|
|
5
|
+
importBundleRpc,
|
|
6
|
+
listCommandsRpc,
|
|
7
|
+
operationsListRpc,
|
|
8
|
+
runCommandRpc,
|
|
9
|
+
slashSettingsContract,
|
|
10
|
+
} from "./shared/resources";
|
|
11
|
+
import {
|
|
12
|
+
handleExportBundle,
|
|
13
|
+
handleGetSettings,
|
|
14
|
+
handleImportBundle,
|
|
15
|
+
handleListCatalog,
|
|
16
|
+
handleListCommands,
|
|
17
|
+
handleListOperations,
|
|
18
|
+
handleResetSettings,
|
|
19
|
+
handleRunCommand,
|
|
20
|
+
handleUpdateSettings,
|
|
21
|
+
log,
|
|
22
|
+
} from "./server/resources";
|
|
23
|
+
|
|
24
|
+
export default function contribute(server: PluginServerContext) {
|
|
25
|
+
server.handle(slashSettingsContract.get, handleGetSettings);
|
|
26
|
+
server.handle(slashSettingsContract.update, handleUpdateSettings);
|
|
27
|
+
server.handle(slashSettingsContract.reset, handleResetSettings);
|
|
28
|
+
server.handle(listCommandsRpc, handleListCommands);
|
|
29
|
+
server.handle(catalogRpc, handleListCatalog);
|
|
30
|
+
server.handle(operationsListRpc, handleListOperations);
|
|
31
|
+
server.handle(runCommandRpc, handleRunCommand);
|
|
32
|
+
server.handle(exportBundleRpc, handleExportBundle);
|
|
33
|
+
server.handle(importBundleRpc, handleImportBundle);
|
|
34
|
+
log.info("slash plugin contributed: send/open/rpc verbs over settings-doc storage");
|
|
35
|
+
return () => {};
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@xpufx/paseo-slash",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.2",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
8
8
|
"test": "vitest run --passWithNoTests"
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
"paseo-plugin.json",
|
|
12
12
|
"README.md",
|
|
13
13
|
"LICENSE",
|
|
14
|
+
"index.client.tsx",
|
|
15
|
+
"index.server.ts",
|
|
14
16
|
"client",
|
|
15
17
|
"server",
|
|
16
18
|
"shared",
|
package/server/resources.ts
CHANGED