diff --git a/lib/connect.d.ts b/lib/connect.d.ts index ad74ae837..be712f910 100644 --- a/lib/connect.d.ts +++ b/lib/connect.d.ts @@ -1,19 +1,20 @@ -import { IModelType } from "mobx-state-tree"; +import { IModelType } from 'mobx-state-tree'; declare const _default: IModelType<{ - connected?: any; username?: any; password?: any; resource?: any; host?: any; }, { - connected: boolean; username: string | null; password: string | null; resource: string; host: string; } & { - onConnect: () => true; - onDisconnect: () => false; + connected: boolean; + connecting: boolean; +} & { + onConnect: () => void; + onDisconnect: () => void; } & { afterCreate: () => void; login: () => Promise<{}>; diff --git a/lib/connect.js b/lib/connect.js index 9105299e8..6200069a9 100644 --- a/lib/connect.js +++ b/lib/connect.js @@ -1,20 +1,29 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); +// tslint:disable-next-line:no_unused-variable var mobx_state_tree_1 = require("mobx-state-tree"); var mobx_1 = require("mobx"); exports.default = mobx_state_tree_1.types - .model("XmppConnect", { - connected: false, + .model('XmppConnect', { username: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.string), password: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.string), resource: mobx_state_tree_1.types.string, host: mobx_state_tree_1.types.string }) + .volatile(function (self) { return ({ + connected: false, + connecting: false +}); }) + .named('Connect') .actions(function (self) { return { - onConnect: function () { return (self.connected = true); }, - onDisconnect: function () { return (self.connected = false); } + onConnect: function () { + self.connected = true; + }, + onDisconnect: function () { + self.connected = false; + } }; }) .actions(function (self) { @@ -25,9 +34,11 @@ exports.default = mobx_state_tree_1.types provider.onDisconnected = self.onDisconnect; }, login: mobx_state_tree_1.flow(function (user, password, host) { + var e_1; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: + _a.trys.push([0, 2, 3, 4]); if (user) { self.username = user; } @@ -37,10 +48,18 @@ exports.default = mobx_state_tree_1.types if (host) { self.host = host; } + self.connecting = true; return [4 /*yield*/, provider.login(self.username, self.password, self.host, self.resource)]; case 1: _a.sent(); - return [2 /*return*/]; + return [2 /*return*/, true]; + case 2: + e_1 = _a.sent(); + throw e_1; + case 3: + self.connecting = false; + return [7 /*endfinally*/]; + case 4: return [2 /*return*/]; } }); }), diff --git a/lib/connect.js.map b/lib/connect.js.map index 53cdc6d4f..f985bf5bd 100644 --- a/lib/connect.js.map +++ b/lib/connect.js.map @@ -1 +1 @@ -{"version":3,"file":"connect.js","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAClE,6BAA4B;AAE5B,kBAAe,uBAAK;KACjB,KAAK,CAAC,aAAa,EAAE;IACpB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,uBAAK,CAAC,KAAK,CAAC,uBAAK,CAAC,MAAM,CAAC;IACnC,QAAQ,EAAE,uBAAK,CAAC,KAAK,CAAC,uBAAK,CAAC,MAAM,CAAC;IACnC,QAAQ,EAAE,uBAAK,CAAC,MAAM;IACtB,IAAI,EAAE,uBAAK,CAAC,MAAM;CACnB,CAAC;KACD,OAAO,CAAC,UAAA,IAAI;IACX,MAAM,CAAC;QACL,SAAS,EAAE,cAAM,OAAA,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,EAAvB,CAAuB;QACxC,YAAY,EAAE,cAAM,OAAA,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,EAAxB,CAAwB;KAC7C,CAAC;AACJ,CAAC,CAAC;KACD,OAAO,CAAC,UAAA,IAAI;IACH,IAAA,kDAAQ,CAAkB;IAClC,MAAM,CAAC;QACL,WAAW,EAAE;YACX,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;YACtC,QAAQ,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC;QAC9C,CAAC;QACD,KAAK,EAAE,sBAAI,CAAC,UAAU,IAAa,EAAE,QAAiB,EAAE,IAAa;;;;wBACnE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;4BACT,IAAI,CAAC,QAAQ,G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;QACF,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,UAAU,EAAE,sBAAI,CAAC;;;;wBACf,QAAQ,CAAC,sBAAsB,EAAE,CAAA;wBACjC,qBAAM,IAAI,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,WAAI,CAAC,cAAM,OAAA,CAAC,IAAI,CAAC,SAAS,EAAf,CAAe,EAAE,OAAO,CAAC,EAApC,CAAoC,CAAC,EAAA;;wBAAlE,SAAkE,CAAA;;;;SACnE,CAAC;KACH,CAAA;AACH,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 66c389a86..95a0ccf4e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var roster_1 = require("./roster"); +// NOTE: this import introduces globals (from strophe) which may limit the modularity of this repo require("./XmppStropheV2"); exports.default = roster_1.default; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/index.js.map b/lib/index.js.map index f14cd57fb..82e6c3d48 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,mCAA6B;AAC7B,2BAAwB;AAExB,kBAAe,gBAAM,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,mCAA6B;AAC7B,kGAAkG;AAClG,2BAAwB;AAExB,kBAAe,gBAAM,CAAA"} \ No newline at end of file diff --git a/lib/iq.d.ts b/lib/iq.d.ts index d17eff3ca..1988b6f05 100644 --- a/lib/iq.d.ts +++ b/lib/iq.d.ts @@ -1,6 +1,5 @@ import { IModelType } from 'mobx-state-tree'; -declare const _default: IModelType<{ - connected?: any; +declare const iqStore: IModelType<{ username?: any; password?: any; resource?: any; @@ -8,14 +7,16 @@ declare const _default: IModelType<{ } & { iq?: any; }, { - connected: boolean; username: string | null; password: string | null; resource: string; host: string; } & { - onConnect: () => true; - onDisconnect: () => false; + connected: boolean; + connecting: boolean; +} & { + onConnect: () => void; + onDisconnect: () => void; } & { afterCreate: () => void; login: () => Promise<{}>; @@ -29,4 +30,4 @@ declare const _default: IModelType<{ afterCreate: () => void; sendIQ: (a1: any) => Promise; }>; -export default _default; +export default iqStore; diff --git a/lib/iq.js b/lib/iq.js index 6e9461cee..641e178f9 100644 --- a/lib/iq.js +++ b/lib/iq.js @@ -1,14 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); +// tslint:disable-next-line:no_unused-variable var mobx_state_tree_1 = require("mobx-state-tree"); var utils_1 = require("./utils"); var mobx_1 = require("mobx"); var connect_1 = require("./connect"); -exports.default = mobx_state_tree_1.types +var iqStore = mobx_state_tree_1.types .compose(connect_1.default, mobx_state_tree_1.types.model('XmppIQ', { iq: mobx_state_tree_1.types.frozen })) + .named('IQ') .actions(function (self) { return { onIQ: function (iq) { return (self.iq = iq); } @@ -55,4 +57,5 @@ exports.default = mobx_state_tree_1.types }) }; }); +exports.default = iqStore; //# sourceMappingURL=iq.js.map \ No newline at end of file diff --git a/lib/iq.js.map b/lib/iq.js.map index 35280653c..d79d22084 100644 --- a/lib/iq.js.map +++ b/lib/iq.js.map @@ -1 +1 @@ -{"version":3,"file":"iq.js","sourceRoot":"","sources":["../src/iq.ts"],"names":[],"mappings":";;;AAAA,mDAAiE;AACjE,iCAA2B;AAC3B,6BAA2B;AAC3B,qCAA+B;AAE/B,kBAAe,uBAAK;KACjB,OAAO,CAAC,iBAAO,EAAE,uBAAK,CAAC,KAAK,CAAC,QAAQ,EAAE;IACtC,EAAE,EAAE,uBAAK,CAAC,MAAM;CACjB,CAAC,CACD;KACA,OAAO,CAAC,UAAA,IAAI;IACX,MAAM,CAAC;QACL,IAAI,EAAE,UAAC,EAAO,IAAK,OAAA,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,EAAd,CAAc;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KAAK,OAAO,CAAC,CAAC,CAAC;wCAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;oCACvF,CAAC;oCAAC,IAAI,CAAC,CAAC;wCACN,OAAO,CAAC,MAAM,CAAC,CAAA;oCACjB,CAAC;gCACH,CAAC,CACF;4BAVD,CAUC,CACF,EAAA;4BAZD,sBAAO,SAYN,EAAA;;;SACF,CAAC;KACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEJ,kBAAe,OAAO,CAAA"} \ No newline at end of file diff --git a/lib/message.d.ts b/lib/message.d.ts index 2161e81bb..9455a7d71 100644 --- a/lib/message.d.ts +++ b/lib/message.d.ts @@ -1,6 +1,5 @@ import { IModelType } from 'mobx-state-tree'; declare const _default: IModelType<{ - connected?: any; username?: any; password?: any; resource?: any; @@ -10,14 +9,16 @@ declare const _default: IModelType<{ } & { message?: any; }, { - connected: boolean; username: string | null; password: string | null; resource: string; host: string; } & { - onConnect: () => true; - onDisconnect: () => false; + connected: boolean; + connecting: boolean; +} & { + onConnect: () => void; + onDisconnect: () => void; } & { afterCreate: () => void; login: () => Promise<{}>; diff --git a/lib/message.js b/lib/message.js index eb6063a7e..bd52b660a 100644 --- a/lib/message.js +++ b/lib/message.js @@ -1,5 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +// tslint:disable-next-line:no_unused-variable var mobx_state_tree_1 = require("mobx-state-tree"); var iq_1 = require("./iq"); var MEDIA = 'hippware.com/hxep/media'; @@ -7,6 +8,7 @@ exports.default = mobx_state_tree_1.types .compose(iq_1.default, mobx_state_tree_1.types.model('XmppMessage', { message: mobx_state_tree_1.types.frozen })) + .named('Message') .actions(function (self) { return { onMessage: function (message) { return (self.message = message); } diff --git a/lib/message.js.map b/lib/message.js.map index b07cf345d..e128f6df4 100644 --- a/lib/message.js.map +++ b/lib/message.js.map @@ -1 +1 @@ -{"version":3,"file":"message.js","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":";;AAAA,mDAA2D;AAC3D,2BAAqB;AAErB,IAAM,KAAK,GAAG,yBAAyB,CAAA;AAEvC,kBAAe,uBAAK;KACjB,OAAO,CACN,YAAE,EACF,uBAAK,CAAC,KAAK,CAAC,aAAa,EAAE;IACzB,OAAO,EAAE,uBAAK,CAAC,MAAM;CACtB,CAAC,CACH;KACA,OAAO,CAAC,UAAA,IAAI;IACX,MAAM,CAAC;QACL,SAAS,EAAE,UAAC,OAAY,IAAK,OAAA,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,EAAxB,CAAwB;KACtD,CAAA;AACH,CAAC,CAAC;KACD,OAAO,CAAC,UAAA,IAAI;IACH,IAAA,kDAAQ,CAAiB;IACjC,MAAM,CAAC;QACL,WAAW,EAAE;YACX,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;YACjB,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QACrC,CAAC;QACD,WAAW,EAAE,UAAC,GAAQ;YACpB,IAAI,MAAM,GAAG,IAAI,CAAC;gBAChB,EAAE,EAAK,GAAI,CAAC,EAAG,SAAI,IAAI,CAAC,IAAM;gBAC9B,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,GAAG,CAAC,EAAE;aACX,CAAC;iBACC,CAAC,CAAC,MAAM,CAAC;iBACT,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;YACpB,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;gBACd,MAAM,GAAG,MAAM;qBACZ,EAAE,EAAE;qBACJ,CAAC,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;qBAC5B,CAAC,CAAC,KAAK,CAAC;qBACR,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YACjB,CAAC;YACD,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QAC7B,CAAC;KACF,CAAA;AACH,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"message.js","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":";;AAAA,8CAA8C;AAC9C,mDAA2D;AAC3D,2BAAqB;AAErB,IAAM,KAAK,GAAG,yBAAyB,CAAA;AAEvC,kBAAe,uBAAK;KACjB,OAAO,CACN,YAAE,EACF,uBAAK,CAAC,KAAK,CAAC,aAAa,EAAE;IACzB,OAAO,EAAE,uBAAK,CAAC,MAAM;CACtB,CAAC,CACH;KACA,KAAK,CAAC,SAAS,CAAC;KAChB,OAAO,CAAC,UAAA,IAAI;IACX,MAAM,CAAC;QACL,SAAS,EAAE,UAAC,OAAY,IAAK,OAAA,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,EAAxB,CAAwB;KACtD,CAAA;AACH,CAAC,CAAC;KACD,OAAO,CAAC,UAAA,IAAI;IACH,IAAA,kDAAQ,CAAiB;IACjC,MAAM,CAAC;QACL,WAAW,EAAE;YACX,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;YACjB,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QACrC,CAAC;QACD,WAAW,EAAE,UAAC,GAAQ;YACpB,IAAI,MAAM,GAAG,IAAI,CAAC;gBAChB,EAAE,EAAK,GAAI,CAAC,EAAG,SAAI,IAAI,CAAC,IAAM;gBAC9B,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,GAAG,CAAC,EAAE;aACX,CAAC;iBACC,CAAC,CAAC,MAAM,CAAC;iBACT,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;YACpB,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;gBACd,MAAM,GAAG,MAAM;qBACZ,EAAE,EAAE;qBACJ,CAAC,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;qBAC5B,CAAC,CAAC,KAAK,CAAC;qBACR,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YACjB,CAAC;YACD,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QAC7B,CAAC;KACF,CAAA;AACH,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/lib/model.d.ts b/lib/model.d.ts index 0baf308da..6042f9cdb 100644 --- a/lib/model.d.ts +++ b/lib/model.d.ts @@ -1,105 +1,17 @@ import { IModelType, ISimpleType, ISnapshottable } from 'mobx-state-tree'; import { IObservableArray } from 'mobx'; -export declare const FileSource: IModelType<{ - uri?: any; - contentType?: any; - cached?: any; -}, { - uri: string; - contentType: string; - cached: boolean; -}>; -export declare const File: IModelType<{ - id?: any; - item?: any; - source?: any; - width?: any; - height?: any; - error?: any; - loaded?: any; - loading?: any; - isNew?: any; -}, { - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; -}>; export declare const Status: ISimpleType<"available" | "unavailable">; -export declare const ProfileList: IModelType<{ - relation?: any; - user?: any; +export declare const Image: IModelType<{ + tros?: any; + url?: any; + thumbnail?: any; }, { - relation: string; - user: string; -} & { - loadPage: (a1: number) => Promise; - load: () => Promise; + tros: string; + url: string; + thumbnail: string; } & { - readonly loading: boolean; - readonly finished: boolean; - readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & { - readonly followers: { - relation: string; - user: string; - } & { - loadPage: (a1: number) => Promise; - load: () => Promise; - } & any & { - readonly $treenode?: any; - }; - readonly following: { - relation: string; - user: string; - } & { - loadPage: (a1: number) => Promise; - load: () => Promise; - } & any & { - readonly $treenode?: any; - }; - } & { - readonly $treenode?: any; - })[]; + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; }>; export declare const Profile: IModelType<{ user?: any; @@ -114,21 +26,12 @@ export declare const Profile: IModelType<{ }, { user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -141,90 +44,24 @@ export declare const Profile: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -245,21 +82,12 @@ export declare const OwnProfile: IModelType<{ }, { user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -272,90 +100,24 @@ export declare const OwnProfile: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -364,4 +126,3 @@ export declare const OwnProfile: IModelType<{ phoneNumber: string; }>; export declare type IProfile = typeof Profile.Type; -export declare type IProfileList = typeof ProfileList.Type; diff --git a/lib/model.js b/lib/model.js index a0ba5496d..b1aa8145d 100644 --- a/lib/model.js +++ b/lib/model.js @@ -1,119 +1,25 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var tslib_1 = require("tslib"); +// tslint:disable-next-line:no_unused-variable var mobx_state_tree_1 = require("mobx-state-tree"); -exports.FileSource = mobx_state_tree_1.types.model('FileSource', { - uri: mobx_state_tree_1.types.string, - contentType: mobx_state_tree_1.types.string, - cached: false -}); -exports.File = mobx_state_tree_1.types.model('File', { - id: mobx_state_tree_1.types.identifier(mobx_state_tree_1.types.string), - item: mobx_state_tree_1.types.string, - source: exports.FileSource, - width: mobx_state_tree_1.types.number, - height: mobx_state_tree_1.types.number, - error: mobx_state_tree_1.types.string, - loaded: false, - loading: false, - isNew: false -}); +var paging_1 = require("./paging"); exports.Status = mobx_state_tree_1.types.enumeration('status', ['available', 'unavailable']); -exports.ProfileList = mobx_state_tree_1.types - .model('ProfileList', { - relation: mobx_state_tree_1.types.string, - user: mobx_state_tree_1.types.string +exports.Image = mobx_state_tree_1.types + .model('Image', { + tros: mobx_state_tree_1.types.string, + url: mobx_state_tree_1.types.string, + thumbnail: mobx_state_tree_1.types.string // S3 URL that will be replaced to local path after loading }) - .extend(function (self) { - var service = mobx_state_tree_1.getEnv(self).service; - var loading = false; - var finished = false; - var result = []; - function lastId() { - return result.length ? result[result.length - 1].user : null; - } + .actions(function (self) { return { - views: { - get loading() { - return loading; - }, - get finished() { - return finished; - }, - get length() { - return result.length; - }, - get list() { - return result; - } - }, - actions: { - // TODO fix code duplicate here, was not able to pass optional param because of generics - loadPage: mobx_state_tree_1.flow(function (max) { - var _a, list, count, e_1; - return tslib_1.__generator(this, function (_b) { - switch (_b.label) { - case 0: - if (loading || finished) { - return [2 /*return*/, result]; - } - loading = true; - _b.label = 1; - case 1: - _b.trys.push([1, 3, 4, 5]); - return [4 /*yield*/, service.loadRelations(self.user, self.relation, lastId(), max)]; - case 2: - _a = _b.sent(), list = _a.list, count = _a.count; - result.push.apply(result, list); - finished = result.length === count; - return [3 /*break*/, 5]; - case 3: - e_1 = _b.sent(); - console.log('ERROR:', e_1); - return [3 /*break*/, 5]; - case 4: - loading = false; - return [7 /*endfinally*/]; - case 5: return [2 /*return*/, result]; - } - }); - }), - load: mobx_state_tree_1.flow(function load() { - var _a, list, count, e_2; - return tslib_1.__generator(this, function (_b) { - switch (_b.label) { - case 0: - if (loading || finished) { - return [2 /*return*/, result]; - } - loading = true; - _b.label = 1; - case 1: - _b.trys.push([1, 3, 4, 5]); - return [4 /*yield*/, service.loadRelations(self.user, self.relation, lastId())]; - case 2: - _a = _b.sent(), list = _a.list, count = _a.count; - result.push.apply(result, list); - finished = result.length === count; - return [3 /*break*/, 5]; - case 3: - e_2 = _b.sent(); - console.log('ERROR:', e_2); - return [3 /*break*/, 5]; - case 4: - loading = false; - return [7 /*endfinally*/]; - case 5: return [2 /*return*/, result]; - } - }); - }) - } + setURL: function (url) { return (self.url = url); }, + setThumbnail: function (thumbnail) { return (self.thumbnail = thumbnail); } }; }); exports.Profile = mobx_state_tree_1.types .model('Profile', { user: mobx_state_tree_1.types.identifier(mobx_state_tree_1.types.string), - avatar: mobx_state_tree_1.types.maybe(exports.File), + avatar: mobx_state_tree_1.types.maybe(exports.Image), handle: '', firstName: '', lastName: '', @@ -127,16 +33,10 @@ exports.Profile = mobx_state_tree_1.types var followers, following; return { get followers() { - if (!followers) { - followers = exports.ProfileList.create({ relation: 'follower', user: self.user }, { service: mobx_state_tree_1.getRoot(self) }); - } - return followers; + return followers || (followers = paging_1.create(self, 'loadRelations', self.user, 'follower')); }, get following() { - if (!following) { - following = exports.ProfileList.create({ relation: 'following', user: self.user }, { service: mobx_state_tree_1.getRoot(self) }); - } - return following; + return following || (following = paging_1.create(self, 'loadRelations', self.user, 'following')); } }; }); diff --git a/lib/model.js.map b/lib/model.js.map index 7cada3a1a..73350e2d8 100644 --- a/lib/model.js.map +++ b/lib/model.js.map @@ -1 +1 @@ -{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";;;AAAA,mDAAkH;AAGrG,QAAA,UAAU,GAAG,uBAAK,CAAC,KAAK,CAAC,YAAY,EAAE;IAClD,GAAG,EAAE,uBAAK,CAAC,MAAM;IACjB,WAAW,EAAE,uBAAK,CAAC,MAAM;IACzB,MAAM,EAAE,KAAK;CACd,CAAC,CAAA;AAEW,QAAA,IAAI,GAAG,uBAAK,CAAC,KAAK,CAAC,MAAM,EAAE;IACtC,EAAE,EAAE,uBAAK,CAAC,UAAU,CAAC,uBAAK,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,uBAAK,CAAC,MAAM;IAClB,MAAM,EAAE,kBAAU;IAClB,KAAK,EAAE,uBAAK,CAAC,MAAM;IACnB,MAAM,EAAE,uBAAK,CAAC,MAAM;IACpB,KAAK,EAAE,uBAAK,CAAC,MAAM;IACnB,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,KAAK;CACb,CAAC,CAAA;AAEW,QAAA,MAAM,GAAG,uBAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,CAAA;AAElE,QAAA,WAAW,GAAG,uBAAK;KAC7B,KAAK,CAAC,aAAa,EAAE;IACpB,QAAQ,EAAE,uBAAK,CAAC,MAAM;IACtB,IAAI,EAAE,uBAAK,CAAC,MAAM;CACnB,CAAC;KACD,MAAM,CAAC,UAAA,IAAI;IACF,IAAA,gDAAO,CAAiB;IAChC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,IAAM,MAAM,GAAoB,EAAE,CAAA;IAElC;QACE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAA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B,CAAC,CACH,CAAA"} \ No newline at end of file diff --git a/lib/paging.d.ts b/lib/paging.d.ts new file mode 100644 index 000000000..8fdd5df86 --- /dev/null +++ b/lib/paging.d.ts @@ -0,0 +1,12 @@ +import { IModelType } from 'mobx-state-tree'; +export declare function create(target: any, requestName: string, ...params: Array): IPaginableList; +export declare const PaginableList: IModelType<{}, { + loadPage: (a1: number) => Promise; + load: () => Promise; +} & { + readonly loading: boolean; + readonly finished: boolean; + readonly length: number; + readonly list: any[]; +}>; +export declare type IPaginableList = typeof PaginableList.Type; diff --git a/lib/paging.js b/lib/paging.js new file mode 100644 index 000000000..abcde1e0f --- /dev/null +++ b/lib/paging.js @@ -0,0 +1,101 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var tslib_1 = require("tslib"); +// tslint:disable-next-line:no_unused-variable +var mobx_state_tree_1 = require("mobx-state-tree"); +function create(target, requestName) { + var params = []; + for (var _i = 2; _i < arguments.length; _i++) { + params[_i - 2] = arguments[_i]; + } + return exports.PaginableList.create({}, { request: (_a = mobx_state_tree_1.getRoot(target)[requestName]).bind.apply(_a, [mobx_state_tree_1.getRoot(target)].concat(params)) }); + var _a; +} +exports.create = create; +exports.PaginableList = mobx_state_tree_1.types.model('PaginableList', {}).extend(function (self) { + var request = mobx_state_tree_1.getEnv(self).request; + var loading = false; + var finished = false; + var result = []; + function lastId() { + return result.length ? result[result.length - 1].user : null; + } + return { + views: { + get loading() { + return loading; + }, + get finished() { + return finished; + }, + get length() { + return result.length; + }, + get list() { + return result; + } + }, + actions: { + // TODO fix code duplicate here, was not able to pass optional param because of generics + loadPage: mobx_state_tree_1.flow(function (max) { + var _a, list, count, e_1; + return tslib_1.__generator(this, function (_b) { + switch (_b.label) { + case 0: + if (loading || finished) { + return [2 /*return*/, result]; + } + loading = true; + _b.label = 1; + case 1: + _b.trys.push([1, 3, 4, 5]); + return [4 /*yield*/, request(lastId(), max)]; + case 2: + _a = _b.sent(), list = _a.list, count = _a.count; + result.push.apply(result, list); + finished = result.length === count; + return [3 /*break*/, 5]; + case 3: + e_1 = _b.sent(); + console.log('ERROR:', e_1); + return [3 /*break*/, 5]; + case 4: + loading = false; + return [7 /*endfinally*/]; + case 5: return [2 /*return*/, result]; + } + }); + }), + load: mobx_state_tree_1.flow(function load() { + var _a, list, count, e_2; + return tslib_1.__generator(this, function (_b) { + switch (_b.label) { + case 0: + if (loading || finished) { + return [2 /*return*/, result]; + } + loading = true; + _b.label = 1; + case 1: + _b.trys.push([1, 3, 4, 5]); + return [4 /*yield*/, request(lastId())]; + case 2: + _a = _b.sent(), list = _a.list, count = _a.count; + result.push.apply(result, list); + finished = result.length === count; + return [3 /*break*/, 5]; + case 3: + e_2 = _b.sent(); + console.log('ERROR:', e_2); + return [3 /*break*/, 5]; + case 4: + loading = false; + return [7 /*endfinally*/]; + case 5: return [2 /*return*/, result]; + } + }); + }) + } + }; +}); +//# sourceMappingURL=paging.js.map \ No newline at end of file diff --git a/lib/paging.js.map b/lib/paging.js.map new file mode 100644 index 000000000..566a5eb61 --- /dev/null +++ b/lib/paging.js.map @@ -0,0 +1 @@ +{"version":3,"file":"paging.js","sourceRoot":"","sources":["../src/paging.ts"],"names":[],"mappings":";;;AAAA,8CAA8C;AAC9C,mDAA0E;AAE1E,gBAAuB,MAAW,EAAE,WAAmB;IAAE,gBAAqB;SAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;QAArB,+BAAqB;;IAC5E,MAAM,CAAC,qBAAa,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAA,KAAA,yBAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAA,CAAC,IAAI,YAAC,yBAAO,CAAC,MAAM,CAAC,SAAK,MAAM,EAAC,EAAE,CAAC,CAAA;;AAC7G,CAAC;AAFD,wBAEC;AAEY,QAAA,aAAa,GAAG,uBAAK,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,UAAA,IAAI;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AAa;;;;;4BACrB,EAAE,CAAC,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC;gCACxB,MAAM,gBAAC,MAAM,EAAA;4BACf,CAAC;4BACD,OAAO,GAAG,IAAI,CAAA;;;;4BAEY,qBAAM,OAAO,CAAC,MAAM,EAAE,CAAC,EAAA;;4BAAzC,KAAkB,SAAuB,EAAvC,IAAI,UAAA,EAAE,KAAK,WAAA;4BACnB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;4BAC/B,QAAQ,GAAG,MAAM,CAAC,MAAM,KAAK,KAAK,CAAA;;;;4BAElC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAC,CAAC,CAAA;;;4BAExB,OAAO,GAAG,KAAK,CAAA;;gCAEjB,sBAAO,MAAM,EAAA;;;aACd,CAAC;SACH;KACF,CAAA;AACH,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/lib/profile.d.ts b/lib/profile.d.ts index b0bbde58a..d8c86b1be 100644 --- a/lib/profile.d.ts +++ b/lib/profile.d.ts @@ -1,7 +1,6 @@ import { IModelType, IExtendedObservableMap, ISnapshottable } from 'mobx-state-tree'; import { IReactionDisposer, IObservableArray } from 'mobx'; -declare const _default: IModelType<{ - connected?: any; +declare const profileStore: IModelType<{ username?: any; password?: any; resource?: any; @@ -14,14 +13,16 @@ declare const _default: IModelType<{ profile?: any; profiles?: any; }, { - connected: boolean; username: string | null; password: string | null; resource: string; host: string; } & { - onConnect: () => true; - onDisconnect: () => false; + connected: boolean; + connecting: boolean; +} & { + onConnect: () => void; + onDisconnect: () => void; } & { afterCreate: () => void; login: () => Promise<{}>; @@ -47,21 +48,12 @@ declare const _default: IModelType<{ profile: ({ user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -74,90 +66,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -170,21 +96,12 @@ declare const _default: IModelType<{ profiles: IExtendedObservableMap<{ user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -197,90 +114,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -303,21 +154,12 @@ declare const _default: IModelType<{ registerProfile: (profile: { user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -330,90 +172,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -422,21 +198,12 @@ declare const _default: IModelType<{ }) => { user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -449,90 +216,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -550,4 +251,4 @@ declare const _default: IModelType<{ afterCreate: () => IReactionDisposer; beforeDestroy: () => void; }>; -export default _default; +export default profileStore; diff --git a/lib/profile.js b/lib/profile.js index 5dfad2958..f1c9d6020 100644 --- a/lib/profile.js +++ b/lib/profile.js @@ -1,8 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); +// tslint:disable-next-line:no_unused-variable var mobx_state_tree_1 = require("mobx-state-tree"); var model_1 = require("./model"); +// tslint:disable-next-line:no_unused-variable var mobx_1 = require("mobx"); var register_1 = require("./register"); var USER = 'hippware.com/hxep/user'; @@ -54,12 +56,13 @@ function processFields(fields) { }); return result; } -exports.default = mobx_state_tree_1.types +var profileStore = mobx_state_tree_1.types .compose(register_1.default, mobx_state_tree_1.types.model('XmppProfile', { // own profile profile: mobx_state_tree_1.types.maybe(model_1.OwnProfile), profiles: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.map(model_1.Profile), {}) })) + .named('Profile') .actions(function (self) { return { registerProfile: function (profile) { return self.profiles.put(profile) && self.profiles.get(profile.user); }, @@ -69,11 +72,10 @@ exports.default = mobx_state_tree_1.types .actions(function (self) { return { loadProfile: mobx_state_tree_1.flow(function (user) { - var isOwn, node, fields, iq_1, stanza, data, e_1; + var isOwn, node, fields, iq, stanza, data; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: - _a.trys.push([0, 2, , 3]); if (!user) { throw new Error('User should not be null'); } @@ -88,11 +90,11 @@ exports.default = mobx_state_tree_1.types fields.push('email'); fields.push('phone_number'); } - iq_1 = $iq({ type: 'get' }).c('get', { xmlns: USER, node: node }); + iq = $iq({ type: 'get' }).c('get', { xmlns: USER, node: node }); fields.forEach(function (field) { - iq_1 = iq_1.c('field', { var: field }).up(); + iq = iq.c('field', { var: field }).up(); }); - return [4 /*yield*/, self.sendIQ(iq_1)]; + return [4 /*yield*/, self.sendIQ(iq)]; case 1: stanza = _a.sent(); data = processFields(stanza.fields.field); @@ -103,12 +105,7 @@ exports.default = mobx_state_tree_1.types else { return [2 /*return*/, self.registerProfile(tslib_1.__assign({ user: user }, data))]; } - return [3 /*break*/, 3]; - case 2: - e_1 = _a.sent(); - console.error(e_1); - return [3 /*break*/, 3]; - case 3: return [2 /*return*/]; + return [2 /*return*/]; } }); }) @@ -239,4 +236,5 @@ exports.default = mobx_state_tree_1.types } }; }); +exports.default = profileStore; //# sourceMappingURL=profile.js.map \ No newline at end of file diff --git a/lib/profile.js.map b/lib/profile.js.map index 308f201ba..3142ce138 100644 --- a/lib/profile.js.map +++ b/lib/profile.js.map @@ -1 +1 @@ -{"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":";;;AAAA,mDAA6H;AAC7H,iCAAkF;AAClF,6BAAmE;AACnE,uCAAiC;AAEjC,IAAM,IAAI,GAAG,wBAAwB,CAAA;AACrC,IAAM,MAAM,GAAG,gCAAgC,CAAA;AAE/C,uBAAuB,IAAc;IAAd,qBAAA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IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;YACrB,QAAQ,EAAE,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC,CAAC,CAAA;AAEJ,kBAAe,YAAY,CAAA"} \ No newline at end of file diff --git a/lib/register.d.ts b/lib/register.d.ts index 35a55aae6..cdc678dc5 100644 --- a/lib/register.d.ts +++ b/lib/register.d.ts @@ -1,6 +1,5 @@ import { IModelType } from 'mobx-state-tree'; declare const _default: IModelType<{ - connected?: any; username?: any; password?: any; resource?: any; @@ -10,14 +9,16 @@ declare const _default: IModelType<{ } & { message?: any; } & {}, { - connected: boolean; username: string | null; password: string | null; resource: string; host: string; } & { - onConnect: () => true; - onDisconnect: () => false; + connected: boolean; + connecting: boolean; +} & { + onConnect: () => void; + onDisconnect: () => void; } & { afterCreate: () => void; login: () => Promise<{}>; diff --git a/lib/register.js b/lib/register.js index e89bb5ffd..80ada4218 100644 --- a/lib/register.js +++ b/lib/register.js @@ -1,6 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); +// tslint:disable-next-line:no_unused-variable var mobx_state_tree_1 = require("mobx-state-tree"); var utils_1 = require("./utils"); var message_1 = require("./message"); @@ -50,7 +51,7 @@ exports.default = mobx_state_tree_1.types.compose(message_1.default, mobx_state_ throw d.text ? new Error(d.text) : error_1; } return [3 /*break*/, 4]; - case 4: throw new Error('Cannot register user'); + case 4: return [2 /*return*/]; } }); }) diff --git a/lib/register.js.map b/lib/register.js.map index 2759b23cc..5d8dafa97 100644 --- a/lib/register.js.map +++ b/lib/register.js.map @@ -1 +1 @@ -{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":";;;AAAA,mDAAiE;AACjE,iCAA2B;AAC3B,qCAA+B;AAE/B,kBAAe,uBAAK,CAAC,OAAO,CAAC,iBAAO,EAAE,uBAAK,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CA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e,CAAC,OAAK,EAAE,UAAU,CAAC,CAAC,eAAe,CAAA;4BAC9E,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAA;wBACjC,CAAC;wBAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;4BACX,MAAM,OAAK,CAAA;wBACb,CAAC;wBACD,EAAE,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC;4BACd,KAA0B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAA1C,IAAI,UAAA,EAAE,MAAM,YAAA,EAAE,KAAK,WAAA,CAAuB;4BAClD,4CAA4C;4BAC5C,QAAQ,CAAC,IAAI,GAAG,MAAO,CAAA;4BACvB,IAAI,CAAC,IAAI,GAAG,MAAO,CAAA;4BACnB,IAAI,CAAC,QAAQ,GAAG,IAAK,CAAA;4BACrB,IAAI,CAAC,QAAQ,GAAG,KAAM,CAAA;4BACtB,MAAM,gBAAC,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAA;wBAC1C,CAAC;wBAAC,IAAI,CAAC,CAAC;4BACN,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAK,CAAA;wBAC1C,CAAC;;;;;SAEJ,CAAC;KACH,CAAA;AACH,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/lib/roster.d.ts b/lib/roster.d.ts index cff44a7c7..195529cc8 100644 --- a/lib/roster.d.ts +++ b/lib/roster.d.ts @@ -1,7 +1,6 @@ -import { ISnapshottable, IModelType, IExtendedObservableMap } from 'mobx-state-tree'; +import { IModelType, ISnapshottable, IExtendedObservableMap } from 'mobx-state-tree'; import { IReactionDisposer, IObservableArray } from 'mobx'; declare const _default: IModelType<{ - connected?: any; username?: any; password?: any; resource?: any; @@ -16,14 +15,16 @@ declare const _default: IModelType<{ } & { roster?: any; }, { - connected: boolean; username: string | null; password: string | null; resource: string; host: string; } & { - onConnect: () => true; - onDisconnect: () => false; + connected: boolean; + connecting: boolean; +} & { + onConnect: () => void; + onDisconnect: () => void; } & { afterCreate: () => void; login: () => Promise<{}>; @@ -49,21 +50,12 @@ declare const _default: IModelType<{ profile: ({ user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -76,90 +68,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -172,21 +98,12 @@ declare const _default: IModelType<{ profiles: IExtendedObservableMap<{ user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -199,90 +116,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -305,21 +156,12 @@ declare const _default: IModelType<{ registerProfile: (profile: { user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -332,90 +174,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -424,21 +200,12 @@ declare const _default: IModelType<{ }) => { user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -451,90 +218,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; @@ -555,21 +256,12 @@ declare const _default: IModelType<{ roster: IObservableArray<{ user: string; avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; + tros: string; + url: string; + thumbnail: string; + } & { + setURL: (url: string) => string; + setThumbnail: (thumbnail: string) => string; } & { readonly $treenode?: any; }) | null; @@ -582,90 +274,24 @@ declare const _default: IModelType<{ roles: IObservableArray & ISnapshottable; } & { readonly followers: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; readonly following: { - relation: string; - user: string; - } & { loadPage: (a1: number) => Promise; load: () => Promise; } & { readonly loading: boolean; readonly finished: boolean; readonly length: number; - readonly list: ({ - user: string; - avatar: ({ - id: string; - item: string; - source: { - uri: string; - contentType: string; - cached: boolean; - } & { - readonly $treenode?: any; - }; - width: number; - height: number; - error: string; - loaded: boolean; - loading: boolean; - isNew: boolean; - } & { - readonly $treenode?: any; - }) | null; - handle: string; - firstName: string; - lastName: string; - status: "available" | "unavailable"; - followersSize: number; - botsSize: number; - roles: IObservableArray & ISnapshottable; - } & any & { - readonly $treenode?: any; - })[]; + readonly list: any[]; } & { readonly $treenode?: any; }; diff --git a/lib/roster.js b/lib/roster.js index d68c39075..dfd903bad 100644 --- a/lib/roster.js +++ b/lib/roster.js @@ -1,7 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); +// tslint:disable-next-line:no_unused-variable var mobx_state_tree_1 = require("mobx-state-tree"); +// tslint:disable-next-line:no_unused-variable var mobx_1 = require("mobx"); var utils_1 = require("./utils"); var model_1 = require("./model"); @@ -11,8 +13,10 @@ var NEW_GROUP = '__new__'; var BLOCKED_GROUP = '__blocked__'; exports.default = mobx_state_tree_1.types .compose(profile_1.default, mobx_state_tree_1.types.model('XmppRoster', { + // roster might work better as a map: https://mobx.js.org/refguide/map.html roster: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.array(mobx_state_tree_1.types.reference(model_1.Profile)), []) })) + .named('WockyClient') .actions(function (self) { var provider = mobx_state_tree_1.getEnv(self).provider; return { @@ -31,13 +35,14 @@ exports.default = mobx_state_tree_1.types var days = Math.trunc((new Date().getTime() - createdTime) / (60 * 60 * 1000 * 24)); var groups = group && group.indexOf(' ') > 0 ? group.split(' ') : [group]; var existed = self.roster.findIndex(function (u) { return u.user === user; }); + var rolesArr = roles && roles.role ? (Array.isArray(roles.role) ? roles.role : [roles.role]) : []; var data = { user: user, firstName: firstName, lastName: lastName, handle: handle, avatar: avatar, - roles: roles && roles.role, + roles: rolesArr, isNew: groups.includes(NEW_GROUP) && days <= 7, isBlocked: group === BLOCKED_GROUP, isFollowed: subscription === 'to' || subscription === 'both' || ask === 'subscribe', @@ -57,7 +62,6 @@ exports.default = mobx_state_tree_1.types }; }) .actions(function (self) { - var provider = mobx_state_tree_1.getEnv(self).provider; return { onPresence: function (stanza) { try { diff --git a/lib/roster.js.map b/lib/roster.js.map index 77c1881af..fa3a31d00 100644 --- a/lib/roster.js.map +++ b/lib/roster.js.map @@ -1 +1 @@ -{"version":3,"file":"roster.js","sourceRoot":"","sources":["../src/roster.ts"],"names":[],"mappings":";;;AAAA,mDAA8I;AAC9I,6BAAmE;AACnE,iCAA2B;AAC3B,iCAAiC;AACjC,qCAAoC;AAEpC,IAAM,MAAM,GAAG,kBAAkB,CAAA;AACjC,IAAM,SAAS,GAAG,SAAS,CAAA;AAC3B,IAAM,aAAa,GAAG,aAAa,CAAA;AAEnC,kBAAe,uBAAK;KACjB,OAAO,CACN,iBAAY,EACZ,uBAAK,CAAC,KAAK,CAAC,YAAY,EAAE;IACxB,MAAM,EAAE,uBAAK,CAAC,QAAQ,CAAC,uBAAK,CAAC,KAAK,CAAC,uBAAK,CAA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;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QACrB,CAAC;KACF,CAAA;AACH,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/package.json b/package.json index 5f44c72b4..513ac0383 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "license": "CC0-1.0", "scripts": { "build": "tsc", - "test": "npm run mocha --recursive ./test/*", + "lint": "tslint -c tslint.json 'src/**/*.ts'", + "test": "npm run lint && npm run mocha --recursive ./test/*", "mocha": "mocha -r ts-node/register --require ./test/support/setup.js --timeout 10000" }, "devDependencies": { @@ -18,6 +19,7 @@ "node-fetch": "^1.7.3", "promise": "^8.0.1", "ts-node": "3.3.0", + "tslint": "^3.15.1", "typescript": "2.5.2", "websocket": "^1.0.25", "@types/strophe": "1.2.27", diff --git a/src/connect.ts b/src/connect.ts index 91bb82dea..7d09ede3c 100644 --- a/src/connect.ts +++ b/src/connect.ts @@ -1,48 +1,60 @@ -import { types, flow, getEnv, IModelType } from "mobx-state-tree"; -import { when } from "mobx"; +// tslint:disable-next-line:no_unused-variable +import { types, flow, getEnv, IModelType } from 'mobx-state-tree' +import { when } from 'mobx' export default types - .model("XmppConnect", { - connected: false, + .model('XmppConnect', { username: types.maybe(types.string), password: types.maybe(types.string), resource: types.string, host: types.string }) + .volatile(self => ({ + connected: false, + connecting: false + })) + .named('Connect') .actions(self => { return { - onConnect: () => (self.connected = true), - onDisconnect: () => (self.connected = false) - }; + onConnect: () => { + self.connected = true + }, + onDisconnect: () => { + self.connected = false + } + } }) .actions(self => { - const { provider } = getEnv(self); + const { provider } = getEnv(self) return { afterCreate: () => { - provider.onConnected = self.onConnect; - provider.onDisconnected = self.onDisconnect; + provider.onConnected = self.onConnect + provider.onDisconnected = self.onDisconnect }, login: flow(function*(user?: string, password?: string, host?: string) { - if (user) { - self.username = user; + try { + if (user) { + self.username = user + } + if (password) { + self.password = password + } + if (host) { + self.host = host + } + self.connecting = true + yield provider.login(self.username, self.password, self.host, self.resource) + return true + } catch (e) { + throw e + } finally { + self.connecting = false } - if (password) { - self.password = password; - } - if (host) { - self.host = host; - } - yield provider.login( - self.username, - self.password, - self.host, - self.resource - ); }), sendStanza: provider.sendStanza, disconnect: flow(function*() { - provider.disconnectAfterSending(); - yield new Promise(resolve => when(() => !self.connected, resolve)); + provider.disconnectAfterSending() + yield new Promise(resolve => when(() => !self.connected, resolve)) }) - }; - }); + } + }) diff --git a/src/index.ts b/src/index.ts index 5473215ac..b398b1a55 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import roster from './roster' +// NOTE: this import introduces globals (from strophe) which may limit the modularity of this repo import './XmppStropheV2' export default roster diff --git a/src/iq.ts b/src/iq.ts index d4201809d..0b87ea070 100644 --- a/src/iq.ts +++ b/src/iq.ts @@ -1,13 +1,18 @@ +// tslint:disable-next-line:no_unused-variable import { types, flow, getEnv, IModelType } from 'mobx-state-tree' import Utils from './utils' import { when } from 'mobx' import connect from './connect' -export default types - .compose(connect, types.model('XmppIQ', { - iq: types.frozen - }) +const iqStore = types + // export default types + .compose( + connect, + types.model('XmppIQ', { + iq: types.frozen + }) ) + .named('IQ') .actions(self => { return { onIQ: (iq: any) => (self.iq = iq) @@ -20,7 +25,7 @@ export default types self.iq = {} provider.onIQ = self.onIQ }, - sendIQ: flow(function* (data: any, withoutTo: boolean = false) { + sendIQ: flow(function*(data: any, withoutTo: boolean = false) { if (!data.tree().getAttribute('id')) { data.tree().setAttribute('id', Utils.getUniqueId('iq')) } @@ -38,9 +43,7 @@ export default types () => { const stanza = self.iq if (stanza.type === 'error') { - reject( - stanza.error && stanza.error.text ? stanza.error.text['#text'] : stanza.error - ) + reject(stanza.error && stanza.error.text ? stanza.error.text['#text'] : stanza.error) } else { resolve(stanza) } @@ -50,3 +53,5 @@ export default types }) } }) + +export default iqStore diff --git a/src/message.ts b/src/message.ts index 644ae9ca4..0648f36a4 100644 --- a/src/message.ts +++ b/src/message.ts @@ -1,3 +1,4 @@ +// tslint:disable-next-line:no_unused-variable import { types, getEnv, IModelType } from 'mobx-state-tree' import iq from './iq' @@ -10,6 +11,7 @@ export default types message: types.frozen }) ) + .named('Message') .actions(self => { return { onMessage: (message: any) => (self.message = message) diff --git a/src/model.ts b/src/model.ts index af3d4419d..b8197c0bb 100644 --- a/src/model.ts +++ b/src/model.ts @@ -1,98 +1,28 @@ +// tslint:disable-next-line:no_unused-variable import { types, getEnv, getParent, getRoot, flow, IModelType, ISimpleType, ISnapshottable } from 'mobx-state-tree' +// tslint:disable-next-line:no_unused-variable import { IObservableArray } from 'mobx' - -export const FileSource = types.model('FileSource', { - uri: types.string, - contentType: types.string, - cached: false -}) - -export const File = types.model('File', { - id: types.identifier(types.string), - item: types.string, - source: FileSource, - width: types.number, - height: types.number, - error: types.string, - loaded: false, - loading: false, - isNew: false -}) +import { create, IPaginableList } from './paging' export const Status = types.enumeration('status', ['available', 'unavailable']) -export const ProfileList = types - .model('ProfileList', { - relation: types.string, - user: types.string +export const Image = types + .model('Image', { + tros: types.string, // TROS URL + url: types.string, // S3 URL that will be replaced to local path after loading + thumbnail: types.string // S3 URL that will be replaced to local path after loading }) - .extend(self => { - const { service } = getEnv(self) - let loading = false - let finished = false - const result: Array = [] - - function lastId() { - return result.length ? result[result.length - 1].user : null - } - + .actions(self => { return { - views: { - get loading() { - return loading - }, - get finished() { - return finished - }, - get length() { - return result.length - }, - get list() { - return result - } - }, - actions: { - // TODO fix code duplicate here, was not able to pass optional param because of generics - loadPage: flow(function*(max: number) { - if (loading || finished) { - return result - } - loading = true - try { - const { list, count } = yield service.loadRelations(self.user, self.relation, lastId(), max) - result.push.apply(result, list) - finished = result.length === count - } catch (e) { - console.log('ERROR:', e) - } finally { - loading = false - } - return result - }), - load: flow>(function* load() { - if (loading || finished) { - return result - } - loading = true - try { - const { list, count } = yield service.loadRelations(self.user, self.relation, lastId()) - result.push.apply(result, list) - finished = result.length === count - } catch (e) { - console.log('ERROR:', e) - } finally { - loading = false - } - return result - }) - } + setURL: (url: string) => (self.url = url), + setThumbnail: (thumbnail: string) => (self.thumbnail = thumbnail) } }) export const Profile = types .model('Profile', { user: types.identifier(types.string), - avatar: types.maybe(File), + avatar: types.maybe(Image), handle: '', firstName: '', lastName: '', @@ -103,19 +33,13 @@ export const Profile = types }) .views(self => { // lazy instantiation because we need to inject root service into ProfileList and root instance is attached later - let followers: IProfileList, following: IProfileList + let followers: IPaginableList, following: IPaginableList return { get followers() { - if (!followers) { - followers = ProfileList.create({ relation: 'follower', user: self.user }, { service: getRoot(self) }) - } - return followers + return followers || (followers = create(self, 'loadRelations', self.user, 'follower')) }, get following() { - if (!following) { - following = ProfileList.create({ relation: 'following', user: self.user }, { service: getRoot(self) }) - } - return following + return following || (following = create(self, 'loadRelations', self.user, 'following')) } } }) @@ -129,5 +53,3 @@ export const OwnProfile = types.compose( ) export type IProfile = typeof Profile.Type - -export type IProfileList = typeof ProfileList.Type diff --git a/src/paging.ts b/src/paging.ts new file mode 100644 index 000000000..b5606da1b --- /dev/null +++ b/src/paging.ts @@ -0,0 +1,71 @@ +// tslint:disable-next-line:no_unused-variable +import { types, getEnv, flow, getRoot, IModelType } from 'mobx-state-tree' + +export function create(target: any, requestName: string, ...params: Array): IPaginableList { + return PaginableList.create({}, { request: getRoot(target)[requestName].bind(getRoot(target), ...params) }) +} + +export const PaginableList = types.model('PaginableList', {}).extend(self => { + const { request } = getEnv(self) + let loading = false + let finished = false + const result: Array = [] + + function lastId() { + return result.length ? result[result.length - 1].user : null + } + + return { + views: { + get loading() { + return loading + }, + get finished() { + return finished + }, + get length() { + return result.length + }, + get list() { + return result + } + }, + actions: { + // TODO fix code duplicate here, was not able to pass optional param because of generics + loadPage: flow(function*(max: number) { + if (loading || finished) { + return result + } + loading = true + try { + const { list, count } = yield request(lastId(), max) + result.push.apply(result, list) + finished = result.length === count + } catch (e) { + console.log('ERROR:', e) + } finally { + loading = false + } + return result + }), + load: flow>(function* load() { + if (loading || finished) { + return result + } + loading = true + try { + const { list, count } = yield request(lastId()) + result.push.apply(result, list) + finished = result.length === count + } catch (e) { + console.log('ERROR:', e) + } finally { + loading = false + } + return result + }) + } + } +}) + +export type IPaginableList = typeof PaginableList.Type diff --git a/src/profile.ts b/src/profile.ts index 267026a8f..9a77a7500 100644 --- a/src/profile.ts +++ b/src/profile.ts @@ -1,5 +1,7 @@ +// tslint:disable-next-line:no_unused-variable import { types, flow, getSnapshot, applySnapshot, IModelType, IExtendedObservableMap, ISnapshottable } from 'mobx-state-tree' -import { Profile, OwnProfile, IProfile, ProfileList, IProfileList } from './model' +import { Profile, OwnProfile, IProfile } from './model' +// tslint:disable-next-line:no_unused-variable import { autorun, IReactionDisposer, IObservableArray } from 'mobx' import register from './register' @@ -53,7 +55,7 @@ function processFields(fields: [any]) { return result } -export default types +const profileStore = types .compose( register, types.model('XmppProfile', { @@ -62,6 +64,7 @@ export default types profiles: types.optional(types.map(Profile), {}) }) ) + .named('Profile') .actions(self => { return { registerProfile: (profile: IProfile): IProfile => self.profiles.put(profile) && self.profiles.get(profile.user)!, @@ -71,35 +74,31 @@ export default types .actions(self => { return { loadProfile: flow(function*(user: string) { - try { - if (!user) { - throw new Error('User should not be null') - } - // try to connect - if (!self.connected) { - throw new Error('XMPP is not connected!') - } - const isOwn = user === self.username - const node = `user/${user}` - const fields = ['avatar', 'handle', 'first_name', 'tagline', 'last_name', 'bots+size', 'followers+size', 'followed+size', 'roles'] - if (isOwn) { - fields.push('email') - fields.push('phone_number') - } - let iq = $iq({ type: 'get' }).c('get', { xmlns: USER, node }) - fields.forEach(field => { - iq = iq.c('field', { var: field }).up() - }) - const stanza = yield self.sendIQ(iq) - const data = processFields(stanza.fields.field) - if (isOwn) { - self.profile = OwnProfile.create({ user, ...data }) - return self.profile - } else { - return self.registerProfile({ user, ...data }) - } - } catch (e) { - console.error(e) + if (!user) { + throw new Error('User should not be null') + } + // try to connect + if (!self.connected) { + throw new Error('XMPP is not connected!') + } + const isOwn = user === self.username + const node = `user/${user}` + const fields = ['avatar', 'handle', 'first_name', 'tagline', 'last_name', 'bots+size', 'followers+size', 'followed+size', 'roles'] + if (isOwn) { + fields.push('email') + fields.push('phone_number') + } + let iq = $iq({ type: 'get' }).c('get', { xmlns: USER, node }) + fields.forEach(field => { + iq = iq.c('field', { var: field }).up() + }) + const stanza = yield self.sendIQ(iq) + const data = processFields(stanza.fields.field) + if (isOwn) { + self.profile = OwnProfile.create({ user, ...data }) + return self.profile + } else { + return self.registerProfile({ user, ...data }) } }) } @@ -194,3 +193,5 @@ export default types } } }) + +export default profileStore diff --git a/src/register.ts b/src/register.ts index cd34a962a..1e1c79fdc 100644 --- a/src/register.ts +++ b/src/register.ts @@ -1,3 +1,4 @@ +// tslint:disable-next-line:no_unused-variable import { types, flow, getEnv, IModelType } from 'mobx-state-tree' import Utils from './utils' import message from './message' @@ -35,7 +36,6 @@ export default types.compose(message, types.model('XmppRegister', {})).actions(s throw d.text ? new Error(d.text) : error } } - throw new Error('Cannot register user') }) } }) diff --git a/src/roster.ts b/src/roster.ts index b3e9e6ddb..ebbf7db74 100644 --- a/src/roster.ts +++ b/src/roster.ts @@ -1,5 +1,7 @@ -import { types, flow, getEnv, getSnapshot, applySnapshot, ISnapshottable, IModelType, isAlive, IExtendedObservableMap } from 'mobx-state-tree' -import { autorun, IReactionDisposer, IObservableArray } from 'mobx' +// tslint:disable-next-line:no_unused-variable +import { types, flow, getEnv, IModelType, isAlive, ISnapshottable, IExtendedObservableMap } from 'mobx-state-tree' +// tslint:disable-next-line:no_unused-variable +import { autorun, when, reaction, IReactionDisposer, IObservableArray } from 'mobx' import Utils from './utils' import { Profile } from './model' import profileStore from './profile' @@ -12,9 +14,11 @@ export default types .compose( profileStore, types.model('XmppRoster', { + // roster might work better as a map: https://mobx.js.org/refguide/map.html roster: types.optional(types.array(types.reference(Profile)), []) }) ) + .named('WockyClient') .actions(self => { const { provider } = getEnv(self) return { @@ -32,13 +36,15 @@ export default types const days = Math.trunc((new Date().getTime() - createdTime) / (60 * 60 * 1000 * 24)) const groups = group && group.indexOf(' ') > 0 ? group.split(' ') : [group] const existed = self.roster.findIndex(u => u.user === user) + const rolesArr = roles && roles.role ? (Array.isArray(roles.role) ? roles.role : [roles.role]) : [] + const data = { user, firstName, lastName, handle, avatar, - roles: roles && roles.role, + roles: rolesArr, isNew: groups.includes(NEW_GROUP) && days <= 7, isBlocked: group === BLOCKED_GROUP, isFollowed: subscription === 'to' || subscription === 'both' || ask === 'subscribe', @@ -57,7 +63,6 @@ export default types } }) .actions(self => { - const { provider } = getEnv(self) return { onPresence: (stanza: any) => { try { @@ -111,6 +116,7 @@ export default types .actions(self => { let handler1: any, handler2: any const { provider } = getEnv(self) + return { afterCreate: () => { handler1 = autorun('roster.handler1', () => { diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 000000000..09e8dd2d5 --- /dev/null +++ b/src/test.ts @@ -0,0 +1,19 @@ +import { createXmpp } from '../test/support/testuser' +import { when } from 'mobx' + +describe('test', () => { + it('first', async done => { + try { + const user1 = await createXmpp(31) + when( + () => user1.profile !== null, + async () => { + console.log(await user1.profile!.followers.load()) + done() + } + ) + } catch (e) { + done(e) + } + }) +}) diff --git a/test/profile.test.ts b/test/profile.test.ts index 9f037bfad..617ecd39a 100644 --- a/test/profile.test.ts +++ b/test/profile.test.ts @@ -1,8 +1,6 @@ import { expect } from 'chai' -import { destroy } from 'mobx-state-tree' import { createXmpp } from './support/testuser' import { when } from 'mobx' -import { ProfileList, IProfile, IProfileList } from '../src/model' import { IXmppService } from '../src' let user1: IXmppService, user2: IXmppService, user3: IXmppService diff --git a/test/support/testuser.ts b/test/support/testuser.ts index 7df220784..2aaf93e07 100644 --- a/test/support/testuser.ts +++ b/test/support/testuser.ts @@ -4,7 +4,7 @@ import XmppService, { IXmppService } from '../../src/index' export async function createXmpp(num: any): Promise { const data = testDataNew(num) const provider = new XmppStropheV2() - const service = XmppService.create({ resource: data.resource, host: 'testing.dev.tinyrobot.com' }, { provider }) + const service = XmppService.create({ resource: data.resource, host: 'testing.dev.tinyrobot.com' }, { provider, logger: {log: () => {}} }) await service.register(data.provider_data) await service.login() return service diff --git a/test/xmpp.test.ts b/test/xmpp.test.ts index 8ce01ee3f..db08382ee 100644 --- a/test/xmpp.test.ts +++ b/test/xmpp.test.ts @@ -1,8 +1,6 @@ import { expect } from 'chai' -import { destroy } from 'mobx-state-tree' import { createXmpp } from './support/testuser' import { when } from 'mobx' -import { ProfileList } from '../src/model' import { IXmppService } from '../src' let user1: IXmppService, user2: IXmppService diff --git a/tslint.json b/tslint.json new file mode 100644 index 000000000..e38b8c4d8 --- /dev/null +++ b/tslint.json @@ -0,0 +1,76 @@ +{ + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": false, + "indent": [ + true, + "spaces" + ], + "interface-name": true, + "jsdoc-format": true, + "no-consecutive-blank-lines" : true, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-eval": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-shadowed-variable": true, + "no-switch-case-fall-through": true, + "no-unreachable": true, + "no-unused-expression": true, + "no_unused-variable": [ + true + ], + "no-use-before-declare": false, + "no-var-keyword": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace", + "check-catch" + ], + "quotemark": [ + true, + "single" + ], + "semicolon": [true, "never"], + "trailing-comma": [ + true, + { + "multiline": "never", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} diff --git a/yarn.lock b/yarn.lock index b8e61a1a7..197e0f3ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -44,6 +44,17 @@ asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +brace-expansion@^1.1.7: + version "1.1.8" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + chai@4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c" @@ -77,6 +88,10 @@ color-name@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" +colors@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" + combined-stream@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" @@ -91,6 +106,10 @@ commander@2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + debug@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" @@ -117,6 +136,10 @@ diff@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" +diff@^2.2.1: + version "2.2.3" + resolved "https://registry.yarnpkg.com/diff/-/diff-2.2.3.tgz#60eafd0d28ee906e4e8ff0a52c1229521033bf99" + diff@^3.1.0: version "3.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c" @@ -135,6 +158,12 @@ escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" +findup-sync@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16" + dependencies: + glob "~5.0.0" + form-data@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.1.tgz#6fb94fbd71885306d73d15cc497fe4cc4ecd44bf" @@ -143,6 +172,10 @@ form-data@^2.3.1: combined-stream "^1.0.5" mime-types "^2.1.12" +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + get-func-name@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" @@ -155,6 +188,27 @@ glob@3.2.3: inherits "2" minimatch "~0.2.11" +glob@^7.0.3: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@~5.0.0: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" + graceful-fs@~2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-2.0.3.tgz#7cd2cdb228a4a3f36e95efa6cc142de7d1a136d0" @@ -177,6 +231,13 @@ iconv-lite@~0.4.13: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + inherits@2: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -214,6 +275,12 @@ mime-types@^2.1.12: dependencies: mime-db "~1.30.0" +"minimatch@2 || 3", minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + minimatch@~0.2.11: version "0.2.14" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" @@ -229,6 +296,10 @@ minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + mkdirp@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" @@ -286,10 +357,31 @@ node-fetch@^1.7.3: encoding "^0.1.11" is-stream "^1.0.1" +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +optimist@~0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + parse-passwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + pathval@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" @@ -300,6 +392,12 @@ promise@^8.0.1: dependencies: asap "~2.0.3" +resolve@^1.1.7: + version "1.5.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" + dependencies: + path-parse "^1.0.5" + sigmund@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" @@ -314,6 +412,10 @@ source-map@^0.5.6: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" +sprintf-js@^1.0.3: + version "1.1.1" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.1.tgz#36be78320afe5801f6cea3ee78b6e5aab940ea0c" + strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" @@ -362,6 +464,18 @@ tslib@^1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.8.1.tgz#6946af2d1d651a7b1863b531d6e5afa41aa44eac" +tslint@^3.15.1: + version "3.15.1" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-3.15.1.tgz#da165ca93d8fdc2c086b51165ee1bacb48c98ea5" + dependencies: + colors "^1.1.2" + diff "^2.2.1" + findup-sync "~0.3.0" + glob "^7.0.3" + optimist "~0.6.0" + resolve "^1.1.7" + underscore.string "^3.3.4" + type-detect@^4.0.0: version "4.0.5" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.5.tgz#d70e5bc81db6de2a381bcaca0c6e0cbdc7635de2" @@ -376,6 +490,17 @@ typescript@2.5.2: version "2.5.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.2.tgz#038a95f7d9bbb420b1bf35ba31d4c5c1dd3ffe34" +underscore.string@^3.3.4: + version "3.3.4" + resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-3.3.4.tgz#2c2a3f9f83e64762fdc45e6ceac65142864213db" + dependencies: + sprintf-js "^1.0.3" + util-deprecate "^1.0.2" + +util-deprecate@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + v8flags@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-3.0.1.tgz#dce8fc379c17d9f2c9e9ed78d89ce00052b1b76b" @@ -391,6 +516,14 @@ websocket@^1.0.25: typedarray-to-buffer "^3.1.2" yaeti "^0.0.6" +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + xmldom@^0.1.27: version "0.1.27" resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.27.tgz#d501f97b3bdb403af8ef9ecc20573187aadac0e9"