@phantom/browser-sdk 0.0.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 ADDED
@@ -0,0 +1,3 @@
1
+ # Phantom Browser SDK
2
+
3
+ WIP
@@ -0,0 +1,16 @@
1
+ type ChainPlugin<T> = {
2
+ name: string;
3
+ create: () => T;
4
+ };
5
+ type CreatePhantomConfig = {
6
+ chainPlugins?: ChainPlugin<unknown>[];
7
+ };
8
+ interface Phantom {
9
+ }
10
+ /**
11
+ * Creates a Phantom instance with the provided chain plugins.
12
+ * Each plugin extends the Phantom interface via declaration merging.
13
+ */
14
+ declare function createPhantom({ chainPlugins }: CreatePhantomConfig): Phantom;
15
+
16
+ export { ChainPlugin, CreatePhantomConfig, Phantom, createPhantom };
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ createPhantom: () => createPhantom
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+ function createPhantom({ chainPlugins = [] }) {
27
+ const phantom = {};
28
+ for (const plugin of chainPlugins) {
29
+ phantom[plugin.name] = plugin.create();
30
+ }
31
+ return phantom;
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ createPhantom
36
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,11 @@
1
+ // src/index.ts
2
+ function createPhantom({ chainPlugins = [] }) {
3
+ const phantom = {};
4
+ for (const plugin of chainPlugins) {
5
+ phantom[plugin.name] = plugin.create();
6
+ }
7
+ return phantom;
8
+ }
9
+ export {
10
+ createPhantom
11
+ };
@@ -0,0 +1,14 @@
1
+ import { ChainPlugin } from '../index.js';
2
+
3
+ type Solana = {
4
+ getProvider: () => NonNullable<unknown> | null;
5
+ };
6
+ declare function createSolanaPlugin(): ChainPlugin<Solana>;
7
+
8
+ declare module "../index" {
9
+ interface Phantom {
10
+ solana: Solana;
11
+ }
12
+ }
13
+
14
+ export { createSolanaPlugin };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/solana/index.ts
21
+ var solana_exports = {};
22
+ __export(solana_exports, {
23
+ createSolanaPlugin: () => createSolanaPlugin
24
+ });
25
+ module.exports = __toCommonJS(solana_exports);
26
+
27
+ // src/solana/getProvider.ts
28
+ function getProvider() {
29
+ return window.phantom?.solana ?? null;
30
+ }
31
+
32
+ // src/solana/plugin.ts
33
+ var solana = {
34
+ getProvider
35
+ };
36
+ function createSolanaPlugin() {
37
+ return {
38
+ name: "solana",
39
+ create: () => solana
40
+ };
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ createSolanaPlugin
45
+ });
@@ -0,0 +1,18 @@
1
+ // src/solana/getProvider.ts
2
+ function getProvider() {
3
+ return window.phantom?.solana ?? null;
4
+ }
5
+
6
+ // src/solana/plugin.ts
7
+ var solana = {
8
+ getProvider
9
+ };
10
+ function createSolanaPlugin() {
11
+ return {
12
+ name: "solana",
13
+ create: () => solana
14
+ };
15
+ }
16
+ export {
17
+ createSolanaPlugin
18
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@phantom/browser-sdk",
3
+ "version": "0.0.2",
4
+ "main": "dist/index.js",
5
+ "module": "dist/index.mjs",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.mjs",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./solana": {
14
+ "import": "./dist/solana/index.mjs",
15
+ "require": "./dist/solana/index.js",
16
+ "types": "./dist/solana/index.d.ts"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "license": "MIT",
23
+ "scripts": {
24
+ "build": "rm -rf dist && tsup src/index.ts src/solana/index.ts --format cjs,esm --dts",
25
+ "dev": "rm -rf dist && tsup src/index.ts src/solana/index.ts --format cjs,esm --dts --watch",
26
+ "lint": "tsc --noEmit && eslint --cache . --ext .ts,.tsx",
27
+ "test": "jest"
28
+ },
29
+ "devDependencies": {
30
+ "eslint": "8.53.0",
31
+ "tsup": "^6.7.0",
32
+ "typescript": "^5.0.4"
33
+ }
34
+ }