-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.js
90 lines (68 loc) · 1.97 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
var define;
if (typeof define === "undefined") {
define = function (classInstance) {
classInstance (require, exports, module);
};
}
define (function (require, exports, module) {
var MODULE_NAME = 'dataflo.ws';
var common = require ('./common'),
color = {};
color.error = function (message) {return message}
color.path = function (message) {return message}
color.dataflows = function (message) {return message}
function DF () {
}
module.exports = DF;
DF.registry = {};
DF.common = common;
DF.color = color;
DF.browserPlatform = true;
DF.cordovaPlatform = (typeof window !== "undefined") && (window.PhoneGap || window.Cordova || window.cordova) && true;
// var flow = require ('./flow');
// DF.flow = flow;
DF.main = function () {
return window;
}
DF.global = function () {
return window;
}
DF.instanceTypes = [
'initiator', // 'initiator' is deprecated in favor of 'service'
'service',
'task'
];
function registryLookup (instanceType, instanceName) {
var instanceClass = DF.registry[instanceType] &&
DF.registry[instanceType][instanceName];
// console.error (
// 'you need to run dataflows.register ("'
// +instanceType+'", "'+instanceName
// +'", instance) before using this task'
// );
var error;
if (!instanceClass) {
error = new Error ("instance class not found for " + [instanceType, instanceName].join ("/"));
throw error;
}
return instanceClass;
}
DF.instanceTypes.forEach (function (instanceType) {
DF.registry[instanceType] = {};
DF[instanceType] = function (instanceName) {
return registryLookup (instanceType, instanceName);
};
});
/**
* Register base entities for dataflo.ws processing.
*/
DF.register = function (instanceType, instanceName, instanceClass) {
if (!DF.registry[instanceType]) {
console.warn(
'Unexpected instance type. Predefined types is: ['+instanceTypes.join(', ')+']'
);
return;
}
DF.registry[instanceType][instanceName] = instanceClass;
};
});