@phantom/react-sdk 0.0.9 → 0.0.10

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
@@ -284,3 +284,9 @@ useAccountEffect({
284
284
  },
285
285
  });
286
286
  ```
287
+
288
+ ## Extension API Reference
289
+
290
+ ### useIsInstalled
291
+
292
+ The `useIsInstalled` hook provides a function to check whether the phantom extension is installed
@@ -0,0 +1,5 @@
1
+ declare function useIsInstalled(): {
2
+ isInstalled: () => Promise<boolean>;
3
+ };
4
+
5
+ export { useIsInstalled };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/extension/index.ts
31
+ var extension_exports = {};
32
+ __export(extension_exports, {
33
+ useIsInstalled: () => useIsInstalled
34
+ });
35
+ module.exports = __toCommonJS(extension_exports);
36
+ var import_extension = require("@phantom/browser-sdk/extension");
37
+
38
+ // src/extension/useIsInstalled.ts
39
+ var React2 = __toESM(require("react"));
40
+
41
+ // src/PhantomContext.tsx
42
+ var import_browser_sdk = require("@phantom/browser-sdk");
43
+ var React = __toESM(require("react"));
44
+ var import_jsx_runtime = require("react/jsx-runtime");
45
+ var PhantomContext = React.createContext({ phantom: void 0, isReady: false });
46
+ function usePhantom() {
47
+ const context = React.useContext(PhantomContext);
48
+ if (!context) {
49
+ throw new Error("usePhantom must be used within a PhantomProvider");
50
+ }
51
+ return context;
52
+ }
53
+
54
+ // src/extension/useIsInstalled.ts
55
+ function useIsInstalled() {
56
+ const { phantom } = usePhantom();
57
+ const isInstalled = React2.useCallback(async () => {
58
+ if (!phantom?.extension) {
59
+ throw new Error("Phantom extension plugin not found.");
60
+ }
61
+ return await phantom.extension.isInstalled();
62
+ }, [phantom]);
63
+ return { isInstalled };
64
+ }
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ useIsInstalled
68
+ });
@@ -0,0 +1,22 @@
1
+ import {
2
+ usePhantom
3
+ } from "../chunk-5KSEZ3MC.mjs";
4
+
5
+ // src/extension/index.ts
6
+ import "@phantom/browser-sdk/extension";
7
+
8
+ // src/extension/useIsInstalled.ts
9
+ import * as React from "react";
10
+ function useIsInstalled() {
11
+ const { phantom } = usePhantom();
12
+ const isInstalled = React.useCallback(async () => {
13
+ if (!phantom?.extension) {
14
+ throw new Error("Phantom extension plugin not found.");
15
+ }
16
+ return await phantom.extension.isInstalled();
17
+ }, [phantom]);
18
+ return { isInstalled };
19
+ }
20
+ export {
21
+ useIsInstalled
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantom/react-sdk",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -10,6 +10,11 @@
10
10
  "require": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts"
12
12
  },
13
+ "./extension": {
14
+ "import": "./dist/extension/index.mjs",
15
+ "require": "./dist/extension/index.js",
16
+ "types": "./dist/extension/index.d.ts"
17
+ },
13
18
  "./solana": {
14
19
  "import": "./dist/solana/index.mjs",
15
20
  "require": "./dist/solana/index.js",
@@ -26,15 +31,15 @@
26
31
  ],
27
32
  "license": "MIT",
28
33
  "scripts": {
29
- "build": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/auto-confirm/index.ts --format cjs,esm --dts",
34
+ "build": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/extension/index.ts src/auto-confirm/index.ts --format cjs,esm --dts",
30
35
  "?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
31
36
  "pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
32
- "dev": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/auto-confirm/index.ts --format cjs,esm --dts --watch",
37
+ "dev": "rimraf ./dist && tsup src/index.ts src/solana/index.ts src/extension/index.ts src/auto-confirm/index.ts --format cjs,esm --dts --watch",
33
38
  "lint": "tsc --noEmit && eslint --cache . --ext .ts,.tsx",
34
39
  "test": "jest"
35
40
  },
36
41
  "dependencies": {
37
- "@phantom/browser-sdk": "^0.0.9"
42
+ "@phantom/browser-sdk": "^0.0.10"
38
43
  },
39
44
  "devDependencies": {
40
45
  "@testing-library/dom": "^10.4.0",