pict 1.0.78 → 1.0.80

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict",
3
- "version": "1.0.78",
3
+ "version": "1.0.80",
4
4
  "description": "Pict browser library.",
5
5
  "main": "source/Pict.js",
6
6
  "scripts": {
@@ -43,10 +43,10 @@
43
43
  },
44
44
  "homepage": "https://github.com/stevenvelozo/pict#readme",
45
45
  "devDependencies": {
46
- "quackage": "^1.0.8"
46
+ "quackage": "^1.0.11"
47
47
  },
48
48
  "dependencies": {
49
49
  "cachetrax": "^1.0.3",
50
- "fable": "^3.0.54"
50
+ "fable": "^3.0.56"
51
51
  }
52
52
  }
@@ -20,8 +20,8 @@ class PictApplication extends libFableServiceBase
20
20
  {
21
21
  constructor(pFable, pOptions, pServiceHash)
22
22
  {
23
- super(pFable, pOptions, pServiceHash);
24
- this.options = this.fable.Utility.extend(JSON.parse(JSON.stringify(defaultPictSettings)), this.options);
23
+ let tmpOptions = Object.assign({}, defaultPictSettings, pOptions);
24
+ super(pFable, tmpOptions, pServiceHash);
25
25
  this.serviceType = 'PictApplication';
26
26
 
27
27
  this.AppData = this.fable.AppData;
@@ -24,8 +24,8 @@ class PictView extends libFableServiceBase
24
24
  {
25
25
  constructor(pFable, pOptions, pServiceHash)
26
26
  {
27
- super(pFable, pOptions, pServiceHash);
28
- this.options = this.fable.Utility.extend(JSON.parse(JSON.stringify(defaultPictViewSettings)), this.options);
27
+ let tmpOptions = Object.assign({}, defaultPictViewSettings, pOptions);
28
+ super(pFable, tmpOptions, pServiceHash);
29
29
  this.serviceType = 'PictView';
30
30
 
31
31
  // Wire in the essential Pict service
package/source/Pict.js CHANGED
@@ -26,21 +26,19 @@ class Pict extends libFable
26
26
 
27
27
  this.Bundle = {};
28
28
 
29
+ this.serviceManager.extraServiceInitialization = (pService) =>
30
+ {
31
+ // Decorate services with pict so we can use that instead of fable to eliminate confusion
32
+ pService.pict = this;
33
+ return pService;
34
+ }
29
35
  // Log noisness goes from 0 - 5, where 5 is show me everything.
30
36
  this.LogNoisiness = 0;
31
37
 
32
- if (typeof(this.settings.Manifests) == 'object')
38
+ // Load manifest sets
39
+ if (this.settings.Manifests)
33
40
  {
34
- let tmpManifestKeys = Object.keys(this.settings.Manifests);
35
- if (tmpManifestKeys.length > 0)
36
- {
37
- for (let i = 0; i < tmpManifestKeys.length; i++ )
38
- {
39
- // Load each manifest
40
- let tmpManifestKey = tmpManifestKeys[i];
41
- this.serviceManager.instantiateServiceProvider('Manifest', this.settings.Manifests[tmpManifestKey], tmpManifestKey);
42
- }
43
- }
41
+ this.loadManifestSet(this.settings.Manifests);
44
42
  }
45
43
 
46
44
  this._DefaultPictTemplatesInitialized = false;
@@ -50,6 +48,26 @@ class Pict extends libFable
50
48
  this.serviceManager.addServiceType('PictApplication', require('./Pict-Application.js'));
51
49
  }
52
50
 
51
+ // Load manifests in as Hashed services
52
+ loadManifestSet (pManifestSet)
53
+ {
54
+ if (typeof(pManifestSet) != 'object')
55
+ {
56
+ this.log.warn(`PICT [${this.UUID}] could not load Manifest Set; pManifestSet was not an object.`);
57
+ return false;
58
+ }
59
+ let tmpManifestKeys = Object.keys(pManifestSet.Manifests);
60
+ if (tmpManifestKeys.length > 0)
61
+ {
62
+ for (let i = 0; i < tmpManifestKeys.length; i++ )
63
+ {
64
+ // Load each manifest
65
+ let tmpManifestKey = tmpManifestKeys[i];
66
+ this.serviceManager.instantiateServiceProvider('Manifest', pManifestSet[tmpManifestKey], tmpManifestKey);
67
+ }
68
+ }
69
+ }
70
+
53
71
  // Just passing an options will construct one for us.
54
72
  // Passing a hash will set the hash.
55
73
  // Passing a prototype will use that!
@@ -108,6 +126,14 @@ class Pict extends libFable
108
126
  let tmpHash = pHash.trim();
109
127
  let tmpData = (typeof(pData) === 'object') ? pData : {};
110
128
 
129
+ if (this.LogNoisiness > 4)
130
+ {
131
+ this.log.trace(`PICT Template [fEntityRender]::[${tmpHash}] with tmpData:`, tmpData);
132
+ }
133
+ else if (this.LogNoisiness > 0)
134
+ {
135
+ this.log.trace(`PICT Template [fEntityRender]::[${tmpHash}]`);
136
+ }
111
137
 
112
138
  let tmpEntity = false;
113
139
  let tmpEntityID = false;
@@ -181,6 +207,16 @@ class Pict extends libFable
181
207
  {
182
208
  let tmpHash = pHash.trim();
183
209
  let tmpData = (typeof(pData) === 'object') ? pData : {};
210
+
211
+ if (this.LogNoisiness > 4)
212
+ {
213
+ this.log.trace(`PICT Template [fNotEmptyRender]::[${tmpHash}] with tmpData:`, tmpData);
214
+ }
215
+ else if (this.LogNoisiness > 2)
216
+ {
217
+ this.log.trace(`PICT Template [fNotEmptyRender]::[${tmpHash}]`);
218
+ }
219
+
184
220
  // Should switch this to indexOf so pipes can be in the content.
185
221
  let tmpHashParts = tmpHash.split('|');
186
222
 
@@ -203,6 +239,15 @@ class Pict extends libFable
203
239
  let tmpHash = pHash.trim();
204
240
  let tmpData = (typeof(pData) === 'object') ? pData : {};
205
241
 
242
+ if (this.LogNoisiness > 4)
243
+ {
244
+ this.log.trace(`PICT Template [fTemplateRender]::[${tmpHash}] with tmpData:`, tmpData);
245
+ }
246
+ else if (this.LogNoisiness > 0)
247
+ {
248
+ this.log.trace(`PICT Template [fTemplateRender]::[${tmpHash}]`);
249
+ }
250
+
206
251
  let tmpTemplateHash = false;
207
252
  let tmpAddressOfData = false;
208
253
 
@@ -244,6 +289,15 @@ class Pict extends libFable
244
289
  let tmpHash = pHash.trim();
245
290
  let tmpData = (typeof(pData) === 'object') ? pData : {};
246
291
 
292
+ if (this.LogNoisiness > 4)
293
+ {
294
+ this.log.trace(`PICT Template [fTemplateSetRender]::[${tmpHash}] with tmpData:`, tmpData);
295
+ }
296
+ else if (this.LogNoisiness > 0)
297
+ {
298
+ this.log.trace(`PICT Template [fTemplateSetRender]::[${tmpHash}]`);
299
+ }
300
+
247
301
  let tmpTemplateHash = false;
248
302
  let tmpAddressOfData = false;
249
303
 
@@ -284,6 +338,16 @@ class Pict extends libFable
284
338
  {
285
339
  let tmpHash = pHash.trim();
286
340
  let tmpData = (typeof(pData) === 'object') ? pData : {};
341
+
342
+ if (this.LogNoisiness > 4)
343
+ {
344
+ this.log.trace(`PICT Template [fDataRender]::[${tmpHash}] with tmpData:`, tmpData);
345
+ }
346
+ else if (this.LogNoisiness > 3)
347
+ {
348
+ this.log.trace(`PICT Template [fDataRender]::[${tmpHash}]`);
349
+ }
350
+
287
351
  let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
288
352
  if ((tmpValue == null) || (tmpValue == 'undefined') || (typeof(tmpValue) == 'undefined'))
289
353
  {
@@ -299,6 +363,16 @@ class Pict extends libFable
299
363
  {
300
364
  let tmpHash = pHash.trim();
301
365
  let tmpData = (typeof(pData) === 'object') ? pData : {};
366
+
367
+ if (this.LogNoisiness > 4)
368
+ {
369
+ this.log.trace(`PICT Template [fDollars]::[${tmpHash}] with tmpData:`, tmpData);
370
+ }
371
+ else if (this.LogNoisiness > 3)
372
+ {
373
+ this.log.trace(`PICT Template [fDollars]::[${tmpHash}]`);
374
+ }
375
+
302
376
  let tmpColumnData = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
303
377
  return this.defaultServices.DataFormat.formatterDollars(tmpColumnData);
304
378
  });
@@ -307,6 +381,16 @@ class Pict extends libFable
307
381
  {
308
382
  let tmpHash = pHash.trim();
309
383
  let tmpData = (typeof(pData) === 'object') ? pData : {};
384
+
385
+ if (this.LogNoisiness > 4)
386
+ {
387
+ this.log.trace(`PICT Template [fDigits]::[${tmpHash}] with tmpData:`, tmpData);
388
+ }
389
+ else if (this.LogNoisiness > 3)
390
+ {
391
+ this.log.trace(`PICT Template [fDigits]::[${tmpHash}]`);
392
+ }
393
+
310
394
  let tmpColumnData = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
311
395
  return this.defaultServices.DataFormat.formatterAddCommasToNumber(this.defaultServices.DataFormat.formatterRoundNumber(tmpColumnData, 2));
312
396
  });
@@ -315,6 +399,11 @@ class Pict extends libFable
315
399
  {
316
400
  let tmpHash = pHash.trim();
317
401
 
402
+ if (this.LogNoisiness > 3)
403
+ {
404
+ this.log.trace(`PICT Template [fRandomNumberString]::[${tmpHash}]`);
405
+ }
406
+
318
407
  let tmpStringLength = 4;
319
408
  let tmpMaxNumber = 9999;
320
409
 
@@ -336,11 +425,50 @@ class Pict extends libFable
336
425
  this.defaultServices.MetaTemplate.addPattern('{~RandomNumberString:', '~}',fRandomNumberString);
337
426
  this.defaultServices.MetaTemplate.addPattern('{~RNS:', '~}',fRandomNumberString);
338
427
 
428
+ let fRandomNumber = (pHash, pData)=>
429
+ {
430
+ let tmpHash = pHash.trim();
431
+
432
+ if (this.LogNoisiness > 3)
433
+ {
434
+ this.log.trace(`PICT Template [fRandomNumber]::[${tmpHash}]`);
435
+ }
436
+
437
+ let tmpMinimumNumber = 0;
438
+ let tmpMaxNumber = 9999999;
439
+
440
+ if (tmpHash.length > 0)
441
+ {
442
+ let tmpHashParts = tmpHash.split(',');
443
+ if (tmpHashParts.length > 0)
444
+ {
445
+ tmpMinimumNumber = parseInt(tmpHashParts[0]);
446
+ }
447
+ if (tmpHashParts.length > 1)
448
+ {
449
+ tmpMaxNumber = parseInt(tmpHashParts[1]);
450
+ }
451
+ }
452
+
453
+ return this.defaultServices.DataGeneration.randomIntegerBetween(tmpMinimumNumber, tmpMaxNumber);
454
+ };
455
+ this.defaultServices.MetaTemplate.addPattern('{~RandomNumber:', '~}',fRandomNumber);
456
+ this.defaultServices.MetaTemplate.addPattern('{~RN:', '~}',fRandomNumber);
339
457
 
340
458
  let fPascalCaseIdentifier = (pHash, pData)=>
341
459
  {
342
460
  let tmpHash = pHash.trim();
343
461
  let tmpData = (typeof(pData) === 'object') ? pData : {};
462
+
463
+ if (this.LogNoisiness > 4)
464
+ {
465
+ this.log.trace(`PICT Template [fPascalCaseIdentifier]::[${tmpHash}] with tmpData:`, tmpData);
466
+ }
467
+ else if (this.LogNoisiness > 3)
468
+ {
469
+ this.log.trace(`PICT Template [fPascalCaseIdentifier]::[${tmpHash}]`);
470
+ }
471
+
344
472
  let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
345
473
  if ((tmpValue == null) || (tmpValue == 'undefined') || (typeof(tmpValue) == 'undefined'))
346
474
  {
@@ -350,6 +478,50 @@ class Pict extends libFable
350
478
  };
351
479
  this.defaultServices.MetaTemplate.addPattern('{~PascalCaseIdentifier:', '~}',fPascalCaseIdentifier);
352
480
 
481
+ let fLogValue = (pHash, pData)=>
482
+ {
483
+ let tmpHash = pHash.trim();
484
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
485
+
486
+ let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
487
+ let tmpValueType = typeof(tmpValue);
488
+ if ((tmpValue == null) || (tmpValueType == 'undefined'))
489
+ {
490
+ this.log.trace(`PICT Template Log Value: [${tmpHash}] is ${tmpValueType}.`);
491
+ }
492
+ else if (tmpValueType == 'object')
493
+ {
494
+ this.log.trace(`PICT Template Log Value: [${tmpHash}] is an obect.`, tmpValue);
495
+ }
496
+ else
497
+ {
498
+ this.log.trace(`PICT Template Log Value: [${tmpHash}] if a ${tmpValueType} = [${tmpValue}]`);
499
+ }
500
+ return '';
501
+ };
502
+ this.defaultServices.MetaTemplate.addPattern('{~LogValue:', '~}',fLogValue);
503
+ this.defaultServices.MetaTemplate.addPattern('{~LV:', '~}',fLogValue);
504
+
505
+
506
+ let fLogStatement = (pHash, pData)=>
507
+ {
508
+ let tmpHash = pHash.trim();
509
+ this.log.trace(`PICT Template Log Message: ${tmpHash}`);
510
+ return '';
511
+ };
512
+ this.defaultServices.MetaTemplate.addPattern('{~LogStatement:', '~}',fLogStatement);
513
+ this.defaultServices.MetaTemplate.addPattern('{~LS:', '~}',fLogStatement);
514
+
515
+ let fBreakpoint = (pHash, pData)=>
516
+ {
517
+ let tmpHash = pHash.trim();
518
+ let tmpError = new Error(`PICT Template Breakpoint: ${tmpHash}`);
519
+ this.log.trace(`PICT Template Breakpoint: ${tmpHash}`, tmpError.stack);
520
+ debugger;
521
+ return '';
522
+ };
523
+ this.defaultServices.MetaTemplate.addPattern('{~Breakpoint', '~}',fBreakpoint);
524
+
353
525
  this._DefaultPictTemplatesInitialized = true;
354
526
  }
355
527
  }
@@ -266,6 +266,8 @@ suite
266
266
 
267
267
  testPict.AppData = {Records:_SampleChocoData, EntityName: 'Choco', Title: 'Choco Deluxe Records'};
268
268
 
269
+ testPict.LogNoisiness = 4;
270
+
269
271
  testPict.TemplateProvider.addTemplate('Choco-Row', '<p>{~Data:Record.name~} is a file of {~Data:Record.size~} bytes big.</p>');
270
272
  testPict.TemplateProvider.addTemplate('Choco-Screen', '<h1>{~D:AppData.Title~}</h1>{~TS:Choco-Row:AppData.Records.files~}');
271
273