@sockethub/activity-streams 4.4.0-alpha.3 → 4.4.0-alpha.4
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see activity-streams.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(self,(
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(self,(()=>{return t={804:(t,e,r)=>{"use strict";var n=r(618),o=r(205),i=r(191),c=r(516),s=r(981);(t.exports=function(t,e){var r,o,u,a,f;return arguments.length<2||"string"!=typeof t?(a=e,e=t,t=null):a=arguments[2],n(t)?(r=s.call(t,"c"),o=s.call(t,"e"),u=s.call(t,"w")):(r=u=!0,o=!1),f={value:e,configurable:r,enumerable:o,writable:u},a?i(c(a),f):f}).gs=function(t,e,r){var u,a,f,l;return"string"!=typeof t?(f=r,r=e,e=t,t=null):f=arguments[3],n(e)?o(e)?n(r)?o(r)||(f=r,r=void 0):r=void 0:(f=e,e=r=void 0):e=void 0,n(t)?(u=s.call(t,"c"),a=s.call(t,"e")):(u=!0,a=!1),l={get:e,set:r,configurable:u,enumerable:a},f?i(c(f),l):l}},430:t=>{"use strict";t.exports=function(){}},191:(t,e,r)=>{"use strict";t.exports=r(560)()?Object.assign:r(346)},560:t=>{"use strict";t.exports=function(){var t,e=Object.assign;return"function"==typeof e&&(e(t={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},346:(t,e,r)=>{"use strict";var n=r(103),o=r(745),i=Math.max;t.exports=function(t,e){var r,c,s,u=i(arguments.length,2);for(t=Object(o(t)),s=function(n){try{t[n]=e[n]}catch(t){r||(r=t)}},c=1;c<u;++c)n(e=arguments[c]).forEach(s);if(void 0!==r)throw r;return t}},914:(t,e,r)=>{"use strict";var n=r(430)();t.exports=function(t){return t!==n&&null!==t}},103:(t,e,r)=>{"use strict";t.exports=r(446)()?Object.keys:r(137)},446:t=>{"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(t){return!1}}},137:(t,e,r)=>{"use strict";var n=r(914),o=Object.keys;t.exports=function(t){return o(n(t)?Object(t):t)}},516:(t,e,r)=>{"use strict";var n=r(914),o=Array.prototype.forEach,i=Object.create,c=function(t,e){var r;for(r in t)e[r]=t[r]};t.exports=function(t){var e=i(null);return o.call(arguments,(function(t){n(t)&&c(Object(t),e)})),e}},290:t=>{"use strict";t.exports=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");return t}},745:(t,e,r)=>{"use strict";var n=r(914);t.exports=function(t){if(!n(t))throw new TypeError("Cannot use null or undefined");return t}},981:(t,e,r)=>{"use strict";t.exports=r(591)()?String.prototype.contains:r(42)},591:t=>{"use strict";var e="razdwatrzy";t.exports=function(){return"function"==typeof e.contains&&!0===e.contains("dwa")&&!1===e.contains("foo")}},42:t=>{"use strict";var e=String.prototype.indexOf;t.exports=function(t){return e.call(this,t,arguments[1])>-1}},370:(t,e,r)=>{"use strict";var n,o,i,c,s,u,a,f=r(804),l=r(290),p=Function.prototype.apply,y=Function.prototype.call,b=Object.create,d=Object.defineProperty,h=Object.defineProperties,v=Object.prototype.hasOwnProperty,O={configurable:!0,enumerable:!1,writable:!0};o=function(t,e){var r,o;return l(e),o=this,n.call(this,t,r=function(){i.call(o,t,r),p.call(e,this,arguments)}),r.__eeOnceListener__=e,this},s={on:n=function(t,e){var r;return l(e),v.call(this,"__ee__")?r=this.__ee__:(r=O.value=b(null),d(this,"__ee__",O),O.value=null),r[t]?"object"==typeof r[t]?r[t].push(e):r[t]=[r[t],e]:r[t]=e,this},once:o,off:i=function(t,e){var r,n,o,i;if(l(e),!v.call(this,"__ee__"))return this;if(!(r=this.__ee__)[t])return this;if("object"==typeof(n=r[t]))for(i=0;o=n[i];++i)o!==e&&o.__eeOnceListener__!==e||(2===n.length?r[t]=n[i?0:1]:n.splice(i,1));else n!==e&&n.__eeOnceListener__!==e||delete r[t];return this},emit:c=function(t){var e,r,n,o,i;if(v.call(this,"__ee__")&&(o=this.__ee__[t]))if("object"==typeof o){for(r=arguments.length,i=new Array(r-1),e=1;e<r;++e)i[e-1]=arguments[e];for(o=o.slice(),e=0;n=o[e];++e)p.call(n,this,i)}else switch(arguments.length){case 1:y.call(o,this);break;case 2:y.call(o,this,arguments[1]);break;case 3:y.call(o,this,arguments[1],arguments[2]);break;default:for(r=arguments.length,i=new Array(r-1),e=1;e<r;++e)i[e-1]=arguments[e];p.call(o,this,i)}}},u={on:f(n),once:f(o),off:f(i),emit:f(c)},a=h({},u),t.exports=e=function(t){return null==t?b(a):h(Object(t),u)},e.methods=s},372:(t,e,r)=>{"use strict";var n=r(60);t.exports=function(t){if("function"!=typeof t)return!1;if(!hasOwnProperty.call(t,"length"))return!1;try{if("number"!=typeof t.length)return!1;if("function"!=typeof t.call)return!1;if("function"!=typeof t.apply)return!1}catch(t){return!1}return!n(t)}},940:(t,e,r)=>{"use strict";var n=r(618),o={object:!0,function:!0,undefined:!0};t.exports=function(t){return!!n(t)&&hasOwnProperty.call(o,typeof t)}},205:(t,e,r)=>{"use strict";var n=r(372),o=/^\s*class[\s{/}]/,i=Function.prototype.toString;t.exports=function(t){return!!n(t)&&!o.test(i.call(t))}},60:(t,e,r)=>{"use strict";var n=r(940);t.exports=function(t){if(!n(t))return!1;try{return!!t.constructor&&t.constructor.prototype===t}catch(t){return!1}}},618:t=>{"use strict";t.exports=function(t){return null!=t}},142:(t,e,r)=>{const n=r(370)(),o={stream:["id","type","actor","target","object","context","context","published","error"],object:["id","type","context","alias","attachedTo","attachment","attributedTo","attributedWith","content","contentMap","context","contextOf","name","endTime","generator","generatorOf","group","icon","image","inReplyTo","members","memberOf","message","location","locationOf","objectOf","originOf","presence","preview","previewOf","provider","providerOf","published","rating","relationship","resultOf","replies","role","scope","scopeOf","startTime","status","summary","topic","tag","tagOf","targetOf","title","titleMap","updated","url"]},i={"@id":"id","@type":"type",verb:"type",displayName:"name",objectType:"type",platform:"context"},c={actor:{primary:"id",props:o},target:{primary:"id",props:o},object:{primary:"content",props:o}};let s=new Map,u=!1,a=!0,f=[],l={};function p(t,e){return!("object"!=typeof l[t]||!l[t].includes(e))}function y(t,e){return t[i[e]]=t[e],delete t[e],t}function b(t,e={}){const r=Object.keys(e).filter((e=>{if(!o[t].includes(e))return e}));for(let t of r)if(i[t])e=y(e,t);else if(!p(e.type,t)&&!f.includes(e.type)){const e=`invalid property: "${t}"`;if(u)throw new Error(e);a&&console.warn(e)}}function d(t){b("stream",t),"object"==typeof t.object&&b("object",t.object);const e=function(t){let e={};for(let r of Object.keys(t))if("string"==typeof t[r])e[r]=s.get(t[r])||t[r];else if(Array.isArray(t[r])){e[r]=[];for(let n of t[r])"string"==typeof n&&e[r].push(s.get(n)||n)}else e[r]=t[r];for(let t of Object.keys(c))if("string"==typeof e[t]){let r={};r[c[t].primary]=e[t],e[t]=r}return e}(t);return n.emit("activity-stream",e),e}const h={create:function(t){return b("object",t),s.set(t.id,t),n.emit("activity-object-create",t),t},delete:function(t){const e=s.delete(t);return e&&n.emit("activity-object-delete",t),e},get:function(t,e){let r=s.get(t);if(!r){if(!e)return t;r={id:t}}return r},list:function(){return s.keys()}};function v(t={}){f=t.specialObjs||[],u="boolean"==typeof t.failOnUnknownObjectProperties?t.failOnUnknownObjectProperties:u,a="boolean"==typeof t.warnOnUnknownObjectProperties?t.warnOnUnknownObjectProperties:a;for(let e of Object.keys(t.customProps||{}))"object"==typeof t.customProps[e]&&(l[e]=t.customProps[e]);return{Stream:d,Object:h,on:function(t,e){return n.on(t,e)},once:function(t,e){return n.once(t,e)},off:function(t,e){return n.off(t,e)}}}t.exports&&(t.exports=v),"object"==typeof window&&(window.ASFactory=v)}},e={},function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}(142);var t,e}));
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sockethub/activity-streams",
|
|
3
|
-
"version": "4.4.0-alpha.
|
|
3
|
+
"version": "4.4.0-alpha.4",
|
|
4
4
|
"description": "A simple tool to facilitate handling and referencing activity streams without unnecessary verbosity",
|
|
5
5
|
"main": "./src/activity-streams.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"event-emitter": "^0.3.5"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"c8": "7.
|
|
10
|
+
"c8": "7.12.0",
|
|
11
11
|
"chai": "4.3.6",
|
|
12
|
-
"karma": "6.
|
|
12
|
+
"karma": "6.4.0",
|
|
13
13
|
"karma-chai": "0.1.0",
|
|
14
|
-
"karma-chrome-launcher": "3.1.
|
|
14
|
+
"karma-chrome-launcher": "3.1.1",
|
|
15
15
|
"karma-firefox-launcher": "2.1.2",
|
|
16
16
|
"karma-mocha": "2.0.1",
|
|
17
|
-
"mocha": "
|
|
18
|
-
"webpack": "5.
|
|
19
|
-
"webpack-cli": "4.
|
|
17
|
+
"mocha": "10.0.0",
|
|
18
|
+
"webpack": "5.74.0",
|
|
19
|
+
"webpack-cli": "4.10.0"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "https://github.com/sockethub/sockethub/issues"
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/sockethub/sockethub/tree/master/packages/activity-streams.js",
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "c6d34ff44d2be479e4ea42c46da649612342a680"
|
|
51
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
declare module '@sockethub/activity-streams';
|
|
1
|
+
declare module '@sockethub/activity-streams';
|
package/src/activity-streams.js
CHANGED
|
@@ -28,10 +28,10 @@ const ee = EventEmitter(),
|
|
|
28
28
|
'id', 'type', 'context',
|
|
29
29
|
'alias', 'attachedTo', 'attachment', 'attributedTo', 'attributedWith',
|
|
30
30
|
'content', 'contentMap', 'context', 'contextOf', 'name', 'endTime', 'generator',
|
|
31
|
-
'generatorOf', 'group', 'icon', 'image', 'inReplyTo', 'members', 'memberOf',
|
|
32
|
-
'message', 'location', 'locationOf', 'objectOf', 'originOf', 'presence',
|
|
33
|
-
'preview', 'previewOf', 'provider', 'providerOf', 'published', 'rating',
|
|
34
|
-
'relationship', 'resultOf', 'replies', 'role', 'scope', 'scopeOf', 'startTime',
|
|
31
|
+
'generatorOf', 'group', 'icon', 'image', 'inReplyTo', 'members', 'memberOf',
|
|
32
|
+
'message', 'location', 'locationOf', 'objectOf', 'originOf', 'presence',
|
|
33
|
+
'preview', 'previewOf', 'provider', 'providerOf', 'published', 'rating',
|
|
34
|
+
'relationship', 'resultOf', 'replies', 'role', 'scope', 'scopeOf', 'startTime',
|
|
35
35
|
'status', 'summary', 'topic', 'tag', 'tagOf', 'targetOf', 'title', 'titleMap',
|
|
36
36
|
'updated', 'url'
|
|
37
37
|
]
|
|
@@ -61,6 +61,7 @@ const ee = EventEmitter(),
|
|
|
61
61
|
|
|
62
62
|
let objs = new Map(),
|
|
63
63
|
failOnUnknownObjectProperties = false,
|
|
64
|
+
warnOnUnknownObjectProperties = true,
|
|
64
65
|
specialObjs = [], // the objects don't get rejected for bad props
|
|
65
66
|
customProps = {};
|
|
66
67
|
|
|
@@ -85,7 +86,7 @@ function validateObject(type, obj = {}) {
|
|
|
85
86
|
for (let key of unknownKeys) {
|
|
86
87
|
if (rename[key]) {
|
|
87
88
|
// rename property instead of fail
|
|
88
|
-
obj = renameProp(obj, key)
|
|
89
|
+
obj = renameProp(obj, key);
|
|
89
90
|
continue;
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -100,7 +101,7 @@ function validateObject(type, obj = {}) {
|
|
|
100
101
|
const err = `invalid property: "${key}"`;
|
|
101
102
|
if (failOnUnknownObjectProperties) {
|
|
102
103
|
throw new Error(err);
|
|
103
|
-
} else {
|
|
104
|
+
} else if (warnOnUnknownObjectProperties) {
|
|
104
105
|
console.warn(err);
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -148,7 +149,7 @@ function Stream(meta) {
|
|
|
148
149
|
if (typeof meta.object === 'object') {
|
|
149
150
|
validateObject('object', meta.object);
|
|
150
151
|
}
|
|
151
|
-
const stream = expandStream(meta)
|
|
152
|
+
const stream = expandStream(meta);
|
|
152
153
|
ee.emit('activity-stream', stream);
|
|
153
154
|
return stream;
|
|
154
155
|
}
|
|
@@ -190,7 +191,10 @@ const _Object = {
|
|
|
190
191
|
|
|
191
192
|
function ASFactory(opts = {}) {
|
|
192
193
|
specialObjs = opts.specialObjs || [];
|
|
193
|
-
failOnUnknownObjectProperties = typeof opts.failOnUnknownObjectProperties === 'boolean' ?
|
|
194
|
+
failOnUnknownObjectProperties = typeof opts.failOnUnknownObjectProperties === 'boolean' ?
|
|
195
|
+
opts.failOnUnknownObjectProperties : failOnUnknownObjectProperties;
|
|
196
|
+
warnOnUnknownObjectProperties = typeof opts.warnOnUnknownObjectProperties === 'boolean' ?
|
|
197
|
+
opts.warnOnUnknownObjectProperties : warnOnUnknownObjectProperties;
|
|
194
198
|
for (let propName of Object.keys(opts.customProps || {})) {
|
|
195
199
|
if (typeof opts.customProps[propName] === 'object') {
|
|
196
200
|
customProps[propName] = opts.customProps[propName];
|
|
@@ -213,7 +217,7 @@ function ASFactory(opts = {}) {
|
|
|
213
217
|
}
|
|
214
218
|
|
|
215
219
|
if (typeof module === 'object' && module.exports) {
|
|
216
|
-
module.exports = ASFactory
|
|
220
|
+
module.exports = ASFactory;
|
|
217
221
|
}
|
|
218
222
|
if (typeof window === 'object') {
|
|
219
223
|
window.ASFactory = ASFactory;
|