nv-facutil-def-bw-attr 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +41 -41
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -155,25 +155,25 @@ const load_script_cb = async (self,attr,type,val,accessor_name,extra)=>{
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
const load_all_libs = async(self,ATTRS)=>{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
158
|
+
let ps = [];
|
|
159
|
+
for(let attr in ATTRS) {
|
|
160
|
+
let d = ATTRS[attr];
|
|
161
|
+
if(d.action==="load_script") {
|
|
162
|
+
let impt_name = d.extra.impt_name;
|
|
163
|
+
let accessor_name = d.accessor_name;
|
|
164
|
+
if(is_script_loaded(impt_name)) {
|
|
165
|
+
ps.push([true,window[impt_name]]);
|
|
166
|
+
} else {
|
|
167
|
+
ps.push(
|
|
168
|
+
load_script(self[accessor_name],impt_name).then(cond=>{
|
|
169
|
+
return cond?[true,window[impt_name]]:[false,impt_name,self[accessor_name]];
|
|
170
|
+
}).catch(e=>[false,impt_name,self[accessor_name]])
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return await Promise.all(ps);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
const DFLT_ACTS = {
|
|
@@ -205,13 +205,13 @@ const init_dflts = (self,ATTRS)=>{
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
const exec_when_attr_change = async (ACTIONS,ATTRS,self,attr,val)=>{
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
208
|
+
let {action,type,accessor_name,extra} = ATTRS[attr];
|
|
209
|
+
if(typeof(action) === "string") {
|
|
210
|
+
return ACTIONS[action](self,attr,type,val,accessor_name,extra);
|
|
211
|
+
} else if(typeof(action)=== "function") {
|
|
212
|
+
return action(self,attr,type,val,accessor_name,extra);
|
|
213
|
+
} else {
|
|
214
|
+
}
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
module.exports = (ACTIONS,ATTRS)=>{
|
|
@@ -228,24 +228,24 @@ module.exports = (ACTIONS,ATTRS)=>{
|
|
|
228
228
|
////
|
|
229
229
|
let init_dflts_and_rtrn_attr_change_executor = (self)=>{
|
|
230
230
|
init_dflts(self,ATTRS);
|
|
231
|
-
return (attr,val)=>exec_when_attr_change(ACTIONS,ATTRS,self,attr,val);
|
|
231
|
+
return (attr,val)=>exec_when_attr_change(ACTIONS,ATTRS,self,attr,val);
|
|
232
232
|
}
|
|
233
233
|
////
|
|
234
234
|
return ({
|
|
235
|
-
|
|
236
|
-
creat_load_libs : (self)=>()=>load_all_libs(self,ATTRS)
|
|
235
|
+
init_dflts_and_rtrn_attr_change_executor,
|
|
236
|
+
creat_load_libs : (self)=>()=>load_all_libs(self,ATTRS),
|
|
237
|
+
attr_to_accessor_name,
|
|
238
|
+
def_bool_accessor,
|
|
239
|
+
def_str_accessor,
|
|
240
|
+
def_num_accessor,
|
|
241
|
+
def_json_accessor,
|
|
242
|
+
is_script_loaded,
|
|
243
|
+
load_script,
|
|
244
|
+
init_dflts,
|
|
245
|
+
exec_when_attr_change,
|
|
246
|
+
load_all_libs
|
|
237
247
|
})
|
|
238
248
|
}
|
|
239
249
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
def_bool_accessor,
|
|
243
|
-
def_str_accessor,
|
|
244
|
-
def_num_accessor,
|
|
245
|
-
def_json_accessor,
|
|
246
|
-
is_script_loaded,
|
|
247
|
-
load_script,
|
|
248
|
-
init_dflts,
|
|
249
|
-
exec_when_attr_change,
|
|
250
|
-
load_all_libs
|
|
251
|
-
].forEach(r=>{module.exports[r.name]=r});
|
|
250
|
+
|
|
251
|
+
|