halfcab 14.0.0 → 14.0.1
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 +20 -2
- package/package.json +1 -1
package/halfcab.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import eventEmitter from './eventEmitter/index.mjs'
|
|
|
13
13
|
import qs from 'qs'
|
|
14
14
|
import * as deepDiff from 'deep-object-diff'
|
|
15
15
|
import clone from 'fast-clone'
|
|
16
|
+
import LRU from 'nanolru'
|
|
16
17
|
|
|
17
18
|
let cssTag = cssInject
|
|
18
19
|
let componentCSSString = ''
|
|
@@ -80,11 +81,29 @@ let html = (strings, ...values) => {
|
|
|
80
81
|
return litHtml(strings, ...values)
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
function resolveTemplate (value) {
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
return value.map(resolveTemplate).join('')
|
|
87
|
+
}
|
|
88
|
+
if (value && typeof value === 'object' && value.strings) {
|
|
89
|
+
let result = ''
|
|
90
|
+
const { strings, values } = value
|
|
91
|
+
for (let i = 0; i < strings.length; i++) {
|
|
92
|
+
result += strings[i]
|
|
93
|
+
if (i < values.length) {
|
|
94
|
+
result += resolveTemplate(values[i])
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return result
|
|
98
|
+
}
|
|
99
|
+
return value === undefined || value === null ? '' : String(value)
|
|
100
|
+
}
|
|
101
|
+
|
|
83
102
|
function ssr (rootComponent) {
|
|
84
103
|
// Simple fallback for SSR since lit-html produces objects
|
|
85
104
|
let componentsString = ''
|
|
86
105
|
try {
|
|
87
|
-
componentsString =
|
|
106
|
+
componentsString = resolveTemplate(rootComponent)
|
|
88
107
|
} catch (e) {}
|
|
89
108
|
return {componentsString, stylesString: componentCSSString}
|
|
90
109
|
}
|
|
@@ -468,7 +487,6 @@ function cachedComponent (Class, args, id) {
|
|
|
468
487
|
return new Class().render(args)
|
|
469
488
|
}
|
|
470
489
|
|
|
471
|
-
function LRU () {}
|
|
472
490
|
|
|
473
491
|
export {
|
|
474
492
|
getRouteComponent,
|
package/package.json
CHANGED