@blastlauncher/runtime 1.0.1

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/.eslintrc.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ extends: ["../../.eslintrc.js"],
3
+ settings: {
4
+ "import/core-modules": ["@raycast/api"],
5
+ },
6
+ };
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # @blastlauncher/runtime
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Initial npm publish
8
+ - Updated dependencies
9
+ - @blastlauncher/api@1.0.1
10
+ - @blastlauncher/renderer@1.0.1
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2023 Yukai Huang
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/App.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { Server } from "rpc-websockets";
2
+ export type AppProps = {
3
+ server: Server;
4
+ };
5
+ export declare const App: ({ server }: AppProps) => JSX.Element;
package/dist/App.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.App = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const api_1 = require("@blastlauncher/api");
6
+ const CommandList_1 = require("./components/CommandList");
7
+ const App = ({ server }) => {
8
+ return ((0, jsx_runtime_1.jsx)(api_1.WsServerProvider, { server: server, children: (0, jsx_runtime_1.jsx)(api_1.NavigationProvider, { children: (0, jsx_runtime_1.jsx)(CommandList_1.CommandList, {}) }) }));
9
+ };
10
+ exports.App = App;
@@ -0,0 +1 @@
1
+ export declare const CommandList: () => JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CommandList = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const api_1 = require("@raycast/api");
9
+ const os_1 = __importDefault(require("os"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const utils_1 = require("./utils");
12
+ // TODO: gather all available commands from modules
13
+ // Install with the following command
14
+ // npm install --prefix ~/.blast/extensions @BlastLauncher/todo-list@0.0.2
15
+ const pkg = path_1.default.join(os_1.default.homedir(), ".blast/extensions/node_modules/@BlastLauncher/todo-list/index.js");
16
+ const TODOCommand = (0, utils_1.evalCommandModule)(pkg);
17
+ const CommandList = () => {
18
+ return ((0, jsx_runtime_1.jsx)(api_1.List, { isLoading: false, searchBarPlaceholder: "Search for apps and commands...", children: (0, jsx_runtime_1.jsx)(api_1.List.Item, { title: "Test item", actions: (0, jsx_runtime_1.jsx)(api_1.ActionPanel, { children: (0, jsx_runtime_1.jsx)(api_1.Action.Push, { title: "Open Command", target: (0, jsx_runtime_1.jsx)(TODOCommand, {}) }) }) }) }));
19
+ };
20
+ exports.CommandList = CommandList;
@@ -0,0 +1 @@
1
+ export declare function evalCommandModule(pkg: string): any;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.evalCommandModule = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const eval_1 = __importDefault(require("eval"));
9
+ const react_1 = __importDefault(require("react"));
10
+ function evalCommandModule(pkg) {
11
+ const jsCode = fs_1.default.readFileSync(pkg, "utf8");
12
+ const mod = (0, eval_1.default)(jsCode, pkg, {
13
+ require,
14
+ _jsx: react_1.default.createElement,
15
+ _jsxFragment: react_1.default.Fragment,
16
+ }, true);
17
+ // If we use rollup for bundling, we can use the following:
18
+ // return mod;
19
+ // https://github.com/rollup/rollup/issues/3284
20
+ //
21
+ // Stay mod.default for compatibility with official raycast build, might be changed in the future
22
+ return mod.default;
23
+ }
24
+ exports.evalCommandModule = evalCommandModule;
@@ -0,0 +1 @@
1
+ import "./utils/window";
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./utils/window");
4
+ const renderer_1 = require("@blastlauncher/renderer");
5
+ const App_1 = require("./App");
6
+ const connectDevtools_1 = require("./utils/connectDevtools");
7
+ const run_1 = require("./utils/run");
8
+ (0, connectDevtools_1.connect)();
9
+ (0, run_1.run)(App_1.App, {
10
+ server: (0, renderer_1.runServer)(),
11
+ });
@@ -0,0 +1 @@
1
+ export declare function connect(): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.connect = void 0;
4
+ const react_devtools_core_1 = require("react-devtools-core");
5
+ const websocket_1 = require("websocket");
6
+ function connect() {
7
+ (0, react_devtools_core_1.connectToDevTools)({
8
+ websocket: new websocket_1.w3cwebsocket("ws://localhost:8097"),
9
+ });
10
+ }
11
+ exports.connect = connect;
@@ -0,0 +1,4 @@
1
+ import type { Server } from "rpc-websockets";
2
+ export declare function run(App: (...args: any) => JSX.Element, props: {
3
+ server: Server;
4
+ }): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.run = void 0;
7
+ const renderer_1 = require("@blastlauncher/renderer");
8
+ const react_1 = __importDefault(require("react"));
9
+ function run(App, props) {
10
+ (0, renderer_1.render)(react_1.default.createElement(App, props), props.server);
11
+ }
12
+ exports.run = run;
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ global.window = globalThis;
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@blastlauncher/runtime",
3
+ "version": "1.0.1",
4
+ "main": "dist/index.js",
5
+ "dependencies": {
6
+ "@raycast/api": "npm:@blastlauncher/api@*",
7
+ "eval": "^0.1.8",
8
+ "react": "^18.2.0",
9
+ "react-devtools-core": "^4.27.1",
10
+ "websocket": "^1.0.34",
11
+ "@blastlauncher/api": "1.0.1",
12
+ "@blastlauncher/renderer": "1.0.1"
13
+ },
14
+ "devDependencies": {
15
+ "@types/react": "18.0.9",
16
+ "@types/websocket": "^1.0.5",
17
+ "raycast-original": "npm:@raycast/api@*",
18
+ "rimraf": "^4.1.1",
19
+ "rpc-websockets": "^7.5.0"
20
+ },
21
+ "repository": "https://github.com/BlastLauncher/blast.git",
22
+ "scripts": {
23
+ "build": "rimraf dist/ && tsc",
24
+ "build:watch": "rimraf dist/ && tsc -w",
25
+ "start:dev": "nodemon --watch dist --exec node dist/index.js",
26
+ "start": "node dist/index.js"
27
+ }
28
+ }
@@ -0,0 +1,4 @@
1
+ // Create a module alias for raycast-original to @raycast/api
2
+ declare module "@raycast/api" {
3
+ export * from "raycast-original";
4
+ }
@@ -0,0 +1,19 @@
1
+ declare module "react-devtools-core" {
2
+ import { w3cwebsocket as W3CWebSocket } from "websocket";
3
+ type ResolveNativeStyle = any;
4
+ type DevToolsSettingsManager = any;
5
+
6
+ interface ConnectOptions {
7
+ host?: string;
8
+ nativeStyleEditorValidAttributes?: ReadonlyArray<string>;
9
+ port?: number;
10
+ useHttps?: boolean;
11
+ resolveRNStyle?: ResolveNativeStyle;
12
+ retryConnectionDelay?: number;
13
+ isAppActive?: () => boolean;
14
+ websocket?: WebSocket | W3CWebSocket | null;
15
+ devToolsSettingsManager?: DevToolsSettingsManager | null;
16
+ }
17
+
18
+ export function connectToDevTools(options?: ConnectOptions): void;
19
+ }
package/src/App.tsx ADDED
@@ -0,0 +1,18 @@
1
+ import { NavigationProvider, WsServerProvider } from "@blastlauncher/api";
2
+ import type { Server } from "rpc-websockets";
3
+
4
+ import { CommandList } from "./components/CommandList";
5
+
6
+ export type AppProps = {
7
+ server: Server;
8
+ };
9
+
10
+ export const App = ({ server }: AppProps) => {
11
+ return (
12
+ <WsServerProvider server={server}>
13
+ <NavigationProvider>
14
+ <CommandList />
15
+ </NavigationProvider>
16
+ </WsServerProvider>
17
+ );
18
+ };
@@ -0,0 +1,27 @@
1
+ import { ActionPanel, List, Action } from "@raycast/api";
2
+ import os from "os";
3
+ import path from "path";
4
+
5
+ import { evalCommandModule } from "./utils";
6
+
7
+ // TODO: gather all available commands from modules
8
+ // Install with the following command
9
+ // npm install --prefix ~/.blast/extensions @BlastLauncher/todo-list@0.0.2
10
+ const pkg = path.join(os.homedir(), ".blast/extensions/node_modules/@BlastLauncher/todo-list/index.js");
11
+
12
+ const TODOCommand = evalCommandModule(pkg);
13
+
14
+ export const CommandList = () => {
15
+ return (
16
+ <List isLoading={false} searchBarPlaceholder="Search for apps and commands...">
17
+ <List.Item
18
+ title="Test item"
19
+ actions={
20
+ <ActionPanel>
21
+ <Action.Push title="Open Command" target={<TODOCommand />} />
22
+ </ActionPanel>
23
+ }
24
+ />
25
+ </List>
26
+ );
27
+ };
@@ -0,0 +1,26 @@
1
+ import fs from "fs";
2
+
3
+ import _eval from "eval";
4
+ import React from "react";
5
+
6
+ export function evalCommandModule(pkg: string) {
7
+ const jsCode = fs.readFileSync(pkg, "utf8");
8
+
9
+ const mod: any = _eval(
10
+ jsCode,
11
+ pkg,
12
+ {
13
+ require,
14
+ _jsx: React.createElement,
15
+ _jsxFragment: React.Fragment,
16
+ },
17
+ true
18
+ );
19
+
20
+ // If we use rollup for bundling, we can use the following:
21
+ // return mod;
22
+ // https://github.com/rollup/rollup/issues/3284
23
+ //
24
+ // Stay mod.default for compatibility with official raycast build, might be changed in the future
25
+ return mod.default;
26
+ }
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ import "./utils/window";
2
+
3
+ import { runServer } from "@blastlauncher/renderer";
4
+
5
+ import { App } from "./App";
6
+ import { connect } from "./utils/connectDevtools";
7
+ import { run } from "./utils/run";
8
+
9
+ connect();
10
+
11
+ run(App, {
12
+ server: runServer(),
13
+ });
@@ -0,0 +1,8 @@
1
+ import { connectToDevTools } from "react-devtools-core";
2
+ import { w3cwebsocket as W3CWebSocket } from "websocket";
3
+
4
+ export function connect() {
5
+ connectToDevTools({
6
+ websocket: new W3CWebSocket("ws://localhost:8097"),
7
+ });
8
+ }
@@ -0,0 +1,7 @@
1
+ import { render } from "@blastlauncher/renderer";
2
+ import React, { Attributes } from "react";
3
+ import type { Server } from "rpc-websockets";
4
+
5
+ export function run(App: (...args: any) => JSX.Element, props: { server: Server }) {
6
+ render(React.createElement(App, props as Attributes), props.server);
7
+ }
@@ -0,0 +1 @@
1
+ global.window = globalThis;
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": [
4
+ "src/**/*"
5
+ ],
6
+ "compilerOptions": {
7
+ "outDir": "dist",
8
+ "declaration": true
9
+ }
10
+ }