@heyputer/puter.js 2.0.11 → 2.0.13

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
@@ -1,29 +1,43 @@
1
- # Puter.js
1
+ <h3 align="center">Puter.js</h3>
2
2
 
3
- The official JavaScript SDK for [Puter.com](https://puter.com) — Free, Serverless, Cloud and AI from the frontend code.
3
+ <p align="center">The official JavaScript SDK for <a href="https://puter.com">Puter.com</a></p>
4
+ <p align="center">Free, Serverless, Cloud and AI from the frontend code.</p>
4
5
 
5
- ---
6
+ <p align="center">
7
+ <a href="https://developer.puter.com" target="_blank">Learn More</a>
8
+ ·
9
+ <a href="https://docs.puter.com" target="_blank">Docs</a>
10
+ ·
11
+ <a href="https://developer.puter.com/tutorials">Tutorials</a>
12
+ ·
13
+ <a href="https://github.com/Puter-Apps/">Examples</a>
14
+ ·
15
+ <a href="https://twitter.com/HeyPuter">X</a>
16
+ </p>
17
+
18
+
19
+ <br>
6
20
 
7
- ## Installation (npm)
21
+ ## Installation
8
22
 
23
+
24
+ ### NPM:
9
25
  ```sh
10
26
  npm install @heyputer/puter.js
11
27
  ```
12
28
 
13
- ### Importing
29
+ ### CDN:
14
30
 
15
- ### Node.js (with Auth Token)
16
-
17
- ```js
18
- const {init} = require("@heyputer/puter.js/src/init.cjs"); // NODE JS ONLY
19
- // or
20
- import {init} from "@heyputer/puter.js/src/init.cjs";
31
+ Include Puter.js directly in your HTML via CDN in the `<head>` section:
21
32
 
22
- const puter = init(process.env.puterAuthToken); // uses your auth token
23
- const puter2 = init(process.env.puterAuthToken2); // use some other auth token
33
+ ```html
34
+ <script src="https://js.puter.com/v2/"></script>
24
35
  ```
36
+ <br>
37
+
38
+ ## Usage
25
39
 
26
- ### Browser (without Auth Token)
40
+ ### Browser
27
41
 
28
42
  #### ES Modules
29
43
 
@@ -45,14 +59,19 @@ const puter = require('@heyputer/puter.js');
45
59
  require('@heyputer/puter.js'); // puter will be available globally
46
60
  ```
47
61
 
48
- #### CDN
62
+ ### Node.js (with Auth Token)
49
63
 
50
- Include Puter.js directly in your HTML via CDN in the `<head>` section:
64
+ ```js
65
+ const {init} = require("@heyputer/puter.js/src/init.cjs"); // NODE JS ONLY
66
+ // or
67
+ import {init} from "@heyputer/puter.js/src/init.cjs";
51
68
 
52
- ```html
53
- <script src="https://js.puter.com/v2/"></script>
69
+ const puter = init(process.env.puterAuthToken); // uses your auth token
70
+ const puter2 = init(process.env.puterAuthToken2); // use some other auth token
54
71
  ```
55
72
 
73
+ <br>
74
+
56
75
  ## Usage Example
57
76
 
58
77
  After importing, you can use the global `puter` object:
@@ -67,6 +86,21 @@ puter.ai.chat('What color was Napoleon\'s white horse?').then(response => {
67
86
  });
68
87
  ```
69
88
 
89
+ <br>
90
+
91
+ ## Setting Custom Origins
92
+ By default puter.js uses the official Puter API and GUI origins. You can customize these origins by setting global variables before importing the SDK like so:
93
+
94
+ ```js
95
+ // For API origin
96
+ globalThis.PUTER_API_ORIGIN = 'https://custom-api.puter.com';
97
+ // For GUI origin
98
+ globalThis.PUTER_ORIGIN = 'https://custom-gui.puter.com';
99
+
100
+ import {puter} from '@heyputer/puter.js'; // or however you import it for your env
101
+ ```
102
+ <br>
103
+
70
104
  ---
71
105
 
72
106
  ## Documentation & Community
@@ -77,4 +111,8 @@ puter.ai.chat('What color was Napoleon\'s white horse?').then(response => {
77
111
  - [Puter.com](https://puter.com)
78
112
  - [Discord](https://discord.com/invite/PQcx7Teh8u)
79
113
  - [Reddit](https://reddit.com/r/puter)
80
- - [X (Twitter)](https://twitter.com/HeyPuter)
114
+ - [X (Twitter)](https://twitter.com/HeyPuter)
115
+
116
+ ## License
117
+
118
+ Apache-2.0