@heyputer/puter.js 1.0.1 → 2.0.0
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 +15 -46
- package/package.json +3 -4
- package/webpack.config.js +11 -11
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Puter.js
|
|
2
2
|
|
|
3
|
-
The official JavaScript SDK for [Puter.com](https://puter.com) —
|
|
3
|
+
The official JavaScript SDK for [Puter.com](https://puter.com) — Free, Serverless, Cloud and AI from the frontend code.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -15,24 +15,30 @@ npm install @heyputer/puter.js
|
|
|
15
15
|
#### ES Modules
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
-
import '@heyputer/
|
|
18
|
+
import puter from '@heyputer/puterjs';
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
#### CommonJS
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
|
-
require('@heyputer/puter.js');
|
|
24
|
+
const puter = require('@heyputer/puter.js');
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
#### CDN
|
|
28
|
+
|
|
29
|
+
Include Puter.js directly in your HTML via CDN in the `<head>` section:
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
```html
|
|
32
|
+
<script src="https://js.puter.com/v2/"></script>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage Example
|
|
30
36
|
|
|
31
37
|
```js
|
|
32
38
|
// Print a message
|
|
33
39
|
puter.print('Hello from Puter.js!');
|
|
34
40
|
|
|
35
|
-
// Chat with GPT-
|
|
41
|
+
// Chat with GPT-5 nano
|
|
36
42
|
puter.ai.chat('What color was Napoleon\'s white horse?').then(response => {
|
|
37
43
|
puter.print(response);
|
|
38
44
|
});
|
|
@@ -40,49 +46,12 @@ puter.ai.chat('What color was Napoleon\'s white horse?').then(response => {
|
|
|
40
46
|
|
|
41
47
|
---
|
|
42
48
|
|
|
43
|
-
## CDN Usage
|
|
44
|
-
|
|
45
|
-
Include Puter.js directly in your HTML via CDN:
|
|
46
|
-
|
|
47
|
-
```html
|
|
48
|
-
<script src="https://js.puter.com/v2/"></script>
|
|
49
|
-
<script>
|
|
50
|
-
puter.print('Hello from Puter.js via CDN!');
|
|
51
|
-
puter.ai.chat('What color was Napoleon\'s white horse?').then(response => {
|
|
52
|
-
puter.print(response);
|
|
53
|
-
});
|
|
54
|
-
</script>
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
49
|
## Documentation & Community
|
|
60
50
|
|
|
61
|
-
- [
|
|
51
|
+
- [Developer Site](https://developer.puter.com)
|
|
52
|
+
- [API Docs](https://docs.puter.com)
|
|
62
53
|
- [Live Demo](https://docs.puter.com/playground/)
|
|
63
54
|
- [Puter.com](https://puter.com)
|
|
64
55
|
- [Discord](https://discord.com/invite/PQcx7Teh8u)
|
|
65
56
|
- [Reddit](https://reddit.com/r/puter)
|
|
66
|
-
- [X (Twitter)](https://twitter.com/HeyPuter)
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## Local Development Example
|
|
71
|
-
|
|
72
|
-
Make sure the development server is running.
|
|
73
|
-
|
|
74
|
-
```html
|
|
75
|
-
<html>
|
|
76
|
-
<body>
|
|
77
|
-
<script src="http://puter.localhost:4100/sdk/puter.dev.js"></script>
|
|
78
|
-
<script>
|
|
79
|
-
// Loading ...
|
|
80
|
-
puter.print(`Loading...`);
|
|
81
|
-
|
|
82
|
-
// Chat with GPT-3.5 Turbo
|
|
83
|
-
puter.ai.chat(`What color was Napoleon's white horse?`).then((response) => {
|
|
84
|
-
puter.print(response);
|
|
85
|
-
});
|
|
86
|
-
</script>
|
|
87
|
-
</body>
|
|
88
|
-
</html>
|
|
57
|
+
- [X (Twitter)](https://twitter.com/HeyPuter)
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyputer/puter.js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Puter.js - A JavaScript library for interacting with Puter services.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"webpack-cli": "^5.1.4"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@heyputer/kv.js": "^0.1.92"
|
|
29
|
-
"@heyputer/putility": "^1.0.3"
|
|
28
|
+
"@heyputer/kv.js": "^0.1.92"
|
|
30
29
|
}
|
|
31
30
|
}
|
package/webpack.config.js
CHANGED
|
@@ -11,15 +11,15 @@ import { fileURLToPath } from 'url';
|
|
|
11
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
|
|
13
13
|
export default {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
entry: './src/index.js',
|
|
15
|
+
output: {
|
|
16
|
+
filename: 'puter.js',
|
|
17
|
+
path: path.resolve(__dirname, 'dist'),
|
|
18
|
+
},
|
|
19
|
+
plugins: [
|
|
20
|
+
new webpack.DefinePlugin({
|
|
21
|
+
'globalThis.PUTER_ORIGIN': JSON.stringify(process.env.PUTER_ORIGIN || 'https://puter.com'),
|
|
22
|
+
'globalThis.PUTER_API_ORIGIN': JSON.stringify(process.env.PUTER_API_ORIGIN || 'https://api.puter.com'),
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
25
|
};
|