-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
142 lines (120 loc) · 4.27 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* Copyright 2012-2013 Sam Elsamman
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
'use strict';
// Node Modules
let Bluebird = require('bluebird');
let Semotus = require('@havenlife/semotus');
let Persistor = require('@havenlife/persistor'); // Only used for the typescript path
let ObjectTemplate = require('@havenlife/supertype').default;
// Local Modules
let getTemplates = require('./lib/getTemplates').getTemplates;
let listen = require('./lib/listen').listen;
let typescript = require('./lib/typescript'); // Only used for the typescript path
// Module Global Variables
let AmorphicContext = require('./lib/AmorphicContext');
// TODO: This should be a default set in Semotus
Semotus.maxCallTime = 60 * 1000; // Max time for call interlock
// TODO: Figure out what this does
// Typescript standard extends helper
let __extends;
if (this && this.__extends) {
__extends = this.__extends;
}
else {
__extends = (function z() {
let extendStatics;
if (Object.setPrototypeOf) {
extendStatics = Object.setPrototypeOf;
}
else {
if ({ __proto__: [] } instanceof Array) {
extendStatics = function w(d, b) {
d.__proto__ = b;
};
}
else {
extendStatics = function y(d, b) {
for (let p in b) {
if (b.hasOwnProperty(p)) {
d[p] = b[p];
}
}
};
}
}
return function x(d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
if (b === null) {
d.prototype = Object.create(b);
}
else {
__.prototype = b.prototype;
d.prototype = new __();
}
};
})();
}
/**
* Mixin class implementation
*
* @param {unknown} Base unknown
*
* @constructor
*
* @returns {unknown} unknown.
*/
function Remoteable (Base) {
return (function n(_super) {
__extends(classOne, _super);
function classOne() {
return _super !== null && _super.apply(this, arguments) || this;
}
return classOne;
}(Base));
}
function Bindable (Base) {
return (function n(_super) {
__extends(classOne, _super);
function classOne() {
return _super !== null && _super.apply(this, arguments) || this;
}
return classOne;
}(Base));
}
let toExport = {
getTemplates: getTemplates,
listen: listen,
Remoteable: Remoteable,
Bindable: Bindable,
Persistable: Persistor.Persistable,
Persistor: Persistor.Persistor
// Additional decorators added here by the subsequent bindDecorators call
};
// bindDecorators will need to be called before importing templates to bind to the correct
// subtype of ObjectTemplate (either semotus or persistor). By default we bind to persistor in case
// someone has mocha tests that use the object model.
toExport.bindDecorators = typescript.bindDecorators.bind(toExport);
toExport.bindDecorators(Persistor(ObjectTemplate, null, ObjectTemplate)); // For tests
Object.defineProperty(toExport.Remoteable.prototype, 'amorphic', {get: function s() {
return this.__objectTemplate__;
}});
module.exports = toExport;