@sockethub/activity-streams 4.4.0-alpha.3
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/LICENSE +22 -0
- package/README.md +110 -0
- package/coverage/tmp/coverage-93035-1649152159175-0.json +1 -0
- package/dist/activity-streams.min.js +2 -0
- package/dist/activity-streams.min.js.LICENSE.txt +16 -0
- package/karma.config.js +22 -0
- package/package.json +51 -0
- package/src/activity-streams.d.ts +1 -0
- package/src/activity-streams.js +220 -0
- package/src/activity-streams.test.js +192 -0
- package/webpack.config.js +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Nick Jennings
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# @sockethub/activity-streams.js
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/package/@sockethub/activity-streams)
|
|
4
|
+
[](https://npmjs.org/package/@sockethub/activity-streams)
|
|
5
|
+
|
|
6
|
+
A simple tool to facilitate handling and referencing activity streams and it's objects, cutting down on verbosity.
|
|
7
|
+
|
|
8
|
+
Designed to run in both `node.js` and the `browser`.
|
|
9
|
+
|
|
10
|
+
I am learning about JSON-LD and ActivityStreams2 as I write this library, so suggestions for improvement are very welcome.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
### Node.js
|
|
15
|
+
|
|
16
|
+
`$ npm install @sockethub/activity-streams`
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
const ASFactory = require('@sockethub/activity-streams');
|
|
20
|
+
const ActivityStreams = ASFactory({
|
|
21
|
+
failOnUnkownObjectProperties: false // default
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Browser
|
|
26
|
+
|
|
27
|
+
`<script src="http://example.com/activity-streams.js"></script>`
|
|
28
|
+
|
|
29
|
+
Once included in a web-page, the `ActivityStreams` base object should be on the global scope, with the sub-properties `ActivityStreams.Object` and `ActivityStreams.Stream`.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Example
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
|
|
36
|
+
const ActivityStreams = ASFactory();
|
|
37
|
+
|
|
38
|
+
ActivityStreams.Object.create({
|
|
39
|
+
id: 'irc://exampleUser@irc.freenode.net',
|
|
40
|
+
type: "person",
|
|
41
|
+
name: 'Example User',
|
|
42
|
+
url: "http://activitystrea.ms",
|
|
43
|
+
image: {
|
|
44
|
+
url: "http://activitystrea.ms/avatar.jpg",
|
|
45
|
+
mediaType: "image/jpeg",
|
|
46
|
+
width: 250,
|
|
47
|
+
height: 250
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
ActivityStreams.on('activity-object-create', function (obj) {
|
|
52
|
+
console.log('this object was just created: ', obj);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
ActivityStreams.Object.create({
|
|
56
|
+
id: 'irc://irc.freenode.net/activitystreams',
|
|
57
|
+
type: "chatroom",
|
|
58
|
+
name: '#activitystreams'
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const exampleUser = ActivityStreams.Object.get('irc://exampleUser@irc.freenode.net');
|
|
62
|
+
// ... returns:
|
|
63
|
+
// {
|
|
64
|
+
// id: 'irc://exampleUser@irc.freenode.net',
|
|
65
|
+
// type: "person",
|
|
66
|
+
// name: 'Example User',
|
|
67
|
+
// url: "http://activitystrea.ms",
|
|
68
|
+
// image: {
|
|
69
|
+
// url: "http://activitystrea.ms/avatar.jpg",
|
|
70
|
+
// mediaType: "image/jpeg",
|
|
71
|
+
// width: 250,
|
|
72
|
+
// height: 250
|
|
73
|
+
// }
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
ActivityStreams.Stream({
|
|
77
|
+
context: 'send',
|
|
78
|
+
actor: 'irc://exampleUser@irc.freenode.net',
|
|
79
|
+
object: {
|
|
80
|
+
type: "message",
|
|
81
|
+
content: "hello world!"
|
|
82
|
+
},
|
|
83
|
+
target: 'irc://irc.freenode.net/activitystreams'
|
|
84
|
+
});
|
|
85
|
+
// ... returns:
|
|
86
|
+
// {
|
|
87
|
+
// '@context': 'send',
|
|
88
|
+
// actor: {
|
|
89
|
+
// id: 'irc://exampleUser@irc.freenode.net',
|
|
90
|
+
// type: "person",
|
|
91
|
+
// name: 'Example User',
|
|
92
|
+
// url: "http://activitystrea.ms",
|
|
93
|
+
// image: {
|
|
94
|
+
// url: "http://activitystrea.ms/avatar.jpg",
|
|
95
|
+
// mediaType: "image/jpeg",
|
|
96
|
+
// width: 250,
|
|
97
|
+
// height: 250
|
|
98
|
+
// }
|
|
99
|
+
// },
|
|
100
|
+
// object: {
|
|
101
|
+
// type: "message",
|
|
102
|
+
// content: "hello world!"
|
|
103
|
+
// },
|
|
104
|
+
// target: {
|
|
105
|
+
// id: 'irc://irc.freenode.net/activitystreams',
|
|
106
|
+
// type: "chatroom",
|
|
107
|
+
// name: '#activitystreams'
|
|
108
|
+
// }
|
|
109
|
+
// }
|
|
110
|
+
```
|