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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
define.class(function(require){
console.log('Loading bootdali', define.$environment);
var path = require('path')
var fs = require('fs')
var ExternalApps = require('$system/server/externalapps')
var FileWatcher = require('$system/server/filewatcher')
var BusServer = require('$system/rpc/busserver')
var HTMLParser = require('$system/parse/htmlparser')
var ScriptError = require('$system/parse/scripterror')
var legacy_support = 0
var Texture = require('$system/platform/$platform/texture$platform')
this.atConstructor = function(
args,
compname,
rootserver){
define.$platform = 'dali'
define.loadImage = function(name){
return Texture.fromImage({path:name});
}
this.width = parseInt(args['-width']) || 1920;
this.height = parseInt(args['-height']) || 1080;
this.name = args['-name'] || 'dreemgl';
if (compname.indexOf('http') >= 0) {
this.server = compname;
console.log('remote dreemgl server', compname);
}
this.onTizen = false;
this.dalilib = 'dali';
try {
this.onTizen = fs.statSync('/etc/tizen-release').isFile();
} catch (e) {
}
if (! this.onTizen ) {
var daliRoot = process.env['DESKTOP_PREFIX'].replace('/dali-env/opt', '');
this.dalilib = daliRoot + '/dali-toolkit/node-addon/build/Release/dali'
}
if ('-dumpprog' in args) {
var dp = args['-dumpprog'];
this.dumpprog = (dp.length > 0) ? args['-dumpprog'] : 'stdout';
}
this.args = args
this.compname = compname
this.rootserver = rootserver
this.busserver = new BusServer()
this.initDali();
this.session = Math.random() * 1000000
this.slow_watcher = new FileWatcher()
this.slow_watcher.atChange = function(){
this.reload()
}.bind(this)
this.components = {}
this.paths = ""
for(var key in define.paths){
if(this.paths) this.paths += ',\n\t\t'
this.paths += '$'+key+':"$root/'+key+'"'
}
define.atRequire = function(filename){
this.slow_watcher.watch(filename)
}.bind(this)
this.reload()
}
this.atChange = function(){
}
this.destroy = function(){
if(this.mycomposition && this.mycomposition.destroy) this.mycomposition.destroy()
this.mycomposition = undefined
}
this.initDali = function() {
this.DaliApi = require('./dali_api');
this.DaliApi.initialize({width: this.width, height: this.height, name: this.name, dalilib: this.dalilib, dumpprog: this.dumpprog});
}
this.loadComposition = function(composition){
require.clearCache()
if (composition) {
this.composition = new composition(undefined, undefined, this.server)
}
else {
var Composition = require(define.expandVariables(this.filename))
this.composition = new Composition(this.busserver, this.session)
}
}
this.reload = function(){
this.destroy()
require.clearCache()
if (this.server) {
var self = this;
require.async(self.server).then(function(composition){
return self.loadComposition(composition);
}).catch(function(error){
console.log('Composition load failure', error.stack)
})
}
else {
var dir = '$root/'
var jsname = dir + this.compname+'.js'
try {
if(fs.existsSync(define.expandVariables(jsname))){
this.filename = jsname
return this.loadComposition()
}
else{
var jsname = dir + this.compname + '/index.js'
if(fs.existsSync(define.expandVariables(jsname))){
this.filename = jsname
return this.loadComposition()
}
}
}
finally{
}
}
this.screenname = this.compname;
console.log('bootdali.reload: Unable to load', this.compname);
}
this.loadHTML = function(title, boot){
return '';
}
this.loadTemplate = function(title, boot){
console.warn('warning: bootdali.loadTemplate not written');
return '';
}
})
|