pict 1.0.385 → 1.0.387
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/dist/pict.js +18 -5
- package/dist/pict.js.map +1 -1
- package/dist/pict.min.js +1 -1
- package/dist/pict.min.js.map +1 -1
- package/package.json +1 -1
- package/source/Pict-CSS.js +31 -2
package/dist/pict.js
CHANGED
|
@@ -6218,7 +6218,7 @@ try{if(!global.localStorage)return false;}catch(_){return false;}var val=global.
|
|
|
6218
6218
|
// presumably different callback function.
|
|
6219
6219
|
// This makes sure that own properties are retained, so that
|
|
6220
6220
|
// decorations and such are not lost along the way.
|
|
6221
|
-
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],191:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],192:[function(require,module,exports){module.exports={"name":"pict","version":"1.0.
|
|
6221
|
+
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],191:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],192:[function(require,module,exports){module.exports={"name":"pict","version":"1.0.387","description":"Pict browser library.","main":"source/Pict.js","scripts":{"start":"node source/Pict.js","test":"npx quack test","tests":"npx quack test -g","coverage":"npx quack coverage","build":"npx quack build","prepublishOnly":"npx quack build","docker-dev-build":"docker build ./ -f Dockerfile_LUXURYCode -t pict-image:local","docker-dev-run":"docker run -it -d --name pict-dev -p 37447:8080 -p 19506:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/pict\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" pict-image:local","docker-dev-shell":"docker exec -it pict-dev /bin/bash","lint":"eslint source/**/*.js test/**/*.js","types":"tsc -p ."},"files":["source/","dist/","types/"],"types":"types/source/Pict.d.ts","mocha":{"diff":true,"extension":["js"],"package":"./package.json","reporter":"spec","slow":"75","timeout":"5000","ui":"tdd","watch-files":["source/**/*.js","test/**/*.js"],"watch-ignore":["lib/vendor"]},"repository":{"type":"git","url":"git+https://stevenvelozo@github.com/stevenvelozo/pict.git"},"author":"steven velozo <steven@velozo.com>","license":"MIT","bugs":{"url":"https://github.com/fable-retold/pict/issues"},"homepage":"https://github.com/fable-retold/pict#readme","devDependencies":{"@eslint/js":"^9.39.1","@types/jquery":"^3.5.33","@types/sinon":"^17.0.4","eslint":"^9.39.1","globals":"^16.5.0","pict-docuserve":"^1.4.19","quackage":"^1.3.0","sinon":"^20.0.0","typescript":"^5.9.3"},"dependencies":{"cachetrax":"^1.0.6","fable":"^3.1.78","pict-application":"^1.0.34","pict-provider":"^1.0.13","pict-template":"^1.0.15","pict-view":"^1.0.68"}};},{}],193:[function(require,module,exports){// This assumes Pict has been required in the browser. Delcare these as globals so linter can do its job.
|
|
6222
6222
|
/* global Pict, _Pict: writeable *//**
|
|
6223
6223
|
* Simple function to load a pict Application
|
|
6224
6224
|
*
|
|
@@ -6234,17 +6234,30 @@ if(document.readyState!='loading')fCallback();// Modern browsers have event list
|
|
|
6234
6234
|
else if(document.addEventListener)document.addEventListener('DOMContentLoaded',function(){fCallback();});//@ts-ignore IE <= 8 and ... other abominations
|
|
6235
6235
|
else document.attachEvent('onreadystatechange',function(){if(document.readyState=='complete')fCallback();});};},{}],195:[function(require,module,exports){const libFableServiceBase=require('fable').ServiceProviderBase;const defaultConfiguration={// This is the address for the <script /> tag that contains the CSS.
|
|
6236
6236
|
CSSElementAddress:'#PICT-CSS'};class PictCSS extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);/** @type {any} */this.options;/** @type {{ ContentAssignment: import('./Pict-Content-Assignment') }} */this.services;/** @type {import('fable')} */this.fable;// No merging of options necessary
|
|
6237
|
-
if(typeof this.options.CSSElementAddress==='undefined'){this.options.CSSElementAddress=defaultConfiguration.CSSElementAddress;}this.inlineCSSMap={}
|
|
6237
|
+
if(typeof this.options.CSSElementAddress==='undefined'){this.options.CSSElementAddress=defaultConfiguration.CSSElementAddress;}this.inlineCSSMap={};// Dirty flag for injectCSS(): only rewrite the <style> element when a
|
|
6238
|
+
// fragment was actually added/removed/changed. Views call injectCSS() on
|
|
6239
|
+
// every render, and the DOM write (innerHTML of the full concatenated CSS)
|
|
6240
|
+
// forces the browser to reparse the whole stylesheet and repaint -- doing
|
|
6241
|
+
// that on every navigation paints a brief unstyled flash. Start dirty so
|
|
6242
|
+
// the first injectCSS() always writes.
|
|
6243
|
+
this._cssDirty=true;this.fable.addSolverFunction(this.fable.expressionParser,'createcsscolorrgbfromnumeric',this.createCssColorRGBFromNumeric.bind(this),'Create a CSS color from RGB components');}// Add a CSS fragment to the CSS map (each view can have its own CSS fragment)
|
|
6238
6244
|
// Hash is shared across all views, so if 10 views all load the "My-Table-View" fragment, it will only be loaded once.
|
|
6239
|
-
addCSS(pHash,pContent,pPriority,pProvider){let tmpPriority=typeof pPriority!=='undefined'?pPriority:1000;let tmpProvidor=typeof pProvider==='string'?pProvider:'Unknown'
|
|
6245
|
+
addCSS(pHash,pContent,pPriority,pProvider){let tmpPriority=typeof pPriority!=='undefined'?pPriority:1000;let tmpProvidor=typeof pProvider==='string'?pProvider:'Unknown';// Only mark dirty when the fragment is new or its content/priority actually
|
|
6246
|
+
// changed, so a view re-registering identical CSS does not force a rewrite.
|
|
6247
|
+
let tmpExisting=this.inlineCSSMap[pHash];if(!tmpExisting||tmpExisting.Content!==pContent||tmpExisting.Priority!==tmpPriority){this._cssDirty=true;}this.inlineCSSMap[pHash]={Hash:pHash,Content:pContent,Provider:tmpProvidor,Priority:tmpPriority};}removeCSS(pHash){if(this.inlineCSSMap[pHash]){this._cssDirty=true;}delete this.inlineCSSMap[pHash];}createCssColorRGBFromNumeric(pRed,pGreen,pBlue){// 1. cast red, green and blue to floating point numbers
|
|
6240
6248
|
// 2. If the numbers are all three less than or equal to 1.0, multiply each by 255 and round to the nearest integer.
|
|
6241
6249
|
// 2a. If any of the numbers are greater than 1.0, round each to the nearest integer and make sure it's less than or equal to 255.
|
|
6242
6250
|
// 3. Return a #RRGGBB string.
|
|
6243
6251
|
let tmpRed=parseFloat(pRed);let tmpGreen=parseFloat(pGreen);let tmpBlue=parseFloat(pBlue);if(isNaN(tmpRed)||isNaN(tmpGreen)||isNaN(tmpBlue)){return'#000000';}if(tmpRed<=1.0&&tmpGreen<=1.0&&tmpBlue<=1.0){tmpRed=Math.round(tmpRed*255);tmpGreen=Math.round(tmpGreen*255);tmpBlue=Math.round(tmpBlue*255);}// If they are less than or equal to 255, cast them to integers and round them.
|
|
6244
6252
|
else if(tmpRed<=255&&tmpGreen<=255&&tmpBlue<=255){tmpRed=Math.round(tmpRed);tmpGreen=Math.round(tmpGreen);tmpBlue=Math.round(tmpBlue);}// Otherwise get the maximum of the three and quantize them to 255
|
|
6245
6253
|
else{let tmpMax=Math.max(Math.max(tmpRed,tmpGreen),tmpBlue);tmpRed=Math.round(tmpRed/tmpMax*255);tmpGreen=Math.round(tmpGreen/tmpMax*255);tmpBlue=Math.round(tmpBlue/tmpMax*255);}tmpRed=Math.abs(tmpRed);tmpGreen=Math.abs(tmpGreen);tmpBlue=Math.abs(tmpBlue);let tmpRedHex=tmpRed.toString(16).padStart(2,'0');let tmpGreenHex=tmpGreen.toString(16).padStart(2,'0');let tmpBlueHex=tmpBlue.toString(16).padStart(2,'0');return`#${tmpRedHex}${tmpGreenHex}${tmpBlueHex}`;}generateCSS(){let tmpCSS='';let tmpCSSHashes=Object.keys(this.inlineCSSMap);// Sort the hashes by Priority
|
|
6246
|
-
tmpCSSHashes.sort((a,b)=>{return this.inlineCSSMap[a].Priority-this.inlineCSSMap[b].Priority;});for(let i=0;i<tmpCSSHashes.length;i++){let tmpCSSFragment=this.inlineCSSMap[tmpCSSHashes[i]];let tmpCSSComment=tmpCSSFragment.Hash;if(tmpCSSFragment.Hash!=tmpCSSFragment.Provider){tmpCSSComment=`${tmpCSSComment} from ${tmpCSSFragment.Provider}`;}tmpCSS+=`/* ${tmpCSSComment} */\n${tmpCSSFragment.Content}\n`;}return tmpCSS;}// Inject the CSS into the magic DOM element for it
|
|
6247
|
-
|
|
6254
|
+
tmpCSSHashes.sort((a,b)=>{return this.inlineCSSMap[a].Priority-this.inlineCSSMap[b].Priority;});for(let i=0;i<tmpCSSHashes.length;i++){let tmpCSSFragment=this.inlineCSSMap[tmpCSSHashes[i]];let tmpCSSComment=tmpCSSFragment.Hash;if(tmpCSSFragment.Hash!=tmpCSSFragment.Provider){tmpCSSComment=`${tmpCSSComment} from ${tmpCSSFragment.Provider}`;}tmpCSS+=`/* ${tmpCSSComment} */\n${tmpCSSFragment.Content}\n`;}return tmpCSS;}// Inject the CSS into the magic DOM element for it.
|
|
6255
|
+
// Skips the DOM write when nothing has changed since the last injection (see
|
|
6256
|
+
// the _cssDirty notes in the constructor) -- this is what keeps per-render
|
|
6257
|
+
// injectCSS() calls from reparsing the whole stylesheet and flickering on
|
|
6258
|
+
// navigation. Pass pForceInjection = true to write unconditionally, e.g. if a
|
|
6259
|
+
// caller mutated inlineCSSMap directly instead of using addCSS()/removeCSS().
|
|
6260
|
+
injectCSS(pForceInjection){if(!pForceInjection&&!this._cssDirty){return;}this._cssDirty=false;this.services.ContentAssignment.assignContent(this.options.CSSElementAddress,this.generateCSS());}}module.exports=PictCSS;},{"fable":68}],196:[function(require,module,exports){const libFableServiceBase=require('fable').ServiceProviderBase;/**
|
|
6248
6261
|
* Class for moving content around in the DOM.
|
|
6249
6262
|
*/class PictContentAssignment extends libFableServiceBase{/**
|
|
6250
6263
|
* @param {import('fable')} pFable - The Fable library instance.
|