halfcab 15.0.2 → 15.0.3
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/halfcab.mjs +2 -43
- package/package.json +1 -3
package/halfcab.mjs
CHANGED
|
@@ -12,18 +12,14 @@ import marked from 'marked'
|
|
|
12
12
|
import { decode } from 'html-entities'
|
|
13
13
|
import eventEmitter from './eventEmitter/index.mjs'
|
|
14
14
|
import qs from 'qs'
|
|
15
|
-
import LRU from 'nanolru'
|
|
16
|
-
import Component from 'nanocomponent'
|
|
17
15
|
import * as deepDiff from 'deep-object-diff'
|
|
18
16
|
import clone from 'fast-clone'
|
|
19
17
|
|
|
20
|
-
const cache = LRU(5000)
|
|
21
|
-
|
|
22
18
|
let cssTag = cssInject
|
|
23
19
|
let componentCSSString = ''
|
|
24
20
|
let routesArray = []
|
|
25
21
|
let externalRoutes = []
|
|
26
|
-
let state = {}
|
|
22
|
+
let state = {} // TODO - implement diffing using proxy objects rather than deepDiff
|
|
27
23
|
let router
|
|
28
24
|
let rootEl
|
|
29
25
|
let components
|
|
@@ -513,39 +509,6 @@ function rerender () {
|
|
|
513
509
|
debounce(stateUpdated)
|
|
514
510
|
}
|
|
515
511
|
|
|
516
|
-
class PureComponent extends Component {
|
|
517
|
-
createElement (args) {
|
|
518
|
-
this.args = clone(args)
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
update (args) {
|
|
522
|
-
let diff = deepDiff.diff(this.args, args)
|
|
523
|
-
Object.keys(diff).forEach(key => {
|
|
524
|
-
if (typeof diff[key] === 'function') {
|
|
525
|
-
this[key] = args[key]
|
|
526
|
-
}
|
|
527
|
-
})
|
|
528
|
-
return !!Object.keys(diff).find(key => typeof diff[key] !== 'function')
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
function cachedComponent (Class, args, id) {
|
|
533
|
-
let instance
|
|
534
|
-
if (id) {
|
|
535
|
-
let found = cache.get(id)
|
|
536
|
-
if (found) {
|
|
537
|
-
instance = found
|
|
538
|
-
} else {
|
|
539
|
-
instance = new Class()
|
|
540
|
-
cache.set(id, instance)
|
|
541
|
-
}
|
|
542
|
-
return instance.render(args)
|
|
543
|
-
} else {
|
|
544
|
-
instance = new Class()
|
|
545
|
-
return instance.createElement(args)
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
512
|
export {
|
|
550
513
|
getRouteComponent,
|
|
551
514
|
rerender,
|
|
@@ -567,9 +530,5 @@ export {
|
|
|
567
530
|
resetTouched,
|
|
568
531
|
nextTick,
|
|
569
532
|
addToHoldingPen,
|
|
570
|
-
removeFromHoldingPen
|
|
571
|
-
Component,
|
|
572
|
-
LRU,
|
|
573
|
-
cachedComponent,
|
|
574
|
-
PureComponent
|
|
533
|
+
removeFromHoldingPen
|
|
575
534
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "halfcab",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A simple universal JavaScript framework focused on making use of es2015 template strings to build components.",
|
|
6
6
|
"main": "halfcab.mjs",
|
|
@@ -59,8 +59,6 @@
|
|
|
59
59
|
"html-entities": "^2.3.2",
|
|
60
60
|
"lit": "^3.3.2",
|
|
61
61
|
"marked": "^0.7.0",
|
|
62
|
-
"nanocomponent": "^6.5.2",
|
|
63
|
-
"nanolru": "^1.0.0",
|
|
64
62
|
"qs": "^6.5.2",
|
|
65
63
|
"shifty-router": "^0.1.1"
|
|
66
64
|
},
|