@podium/utils
Advanced tools
Comparing version 4.4.42 to 4.5.0
@@ -0,1 +1,9 @@ | ||
# [4.5.0](https://github.com/podium-lib/utils/compare/v4.4.42...v4.5.0) (2023-11-16) | ||
### Features | ||
* add strategy and scope fields to AssetCss and AssetJs classes ([5a8ecb1](https://github.com/podium-lib/utils/commit/5a8ecb17ec41f252016b004caef5f207f80ada35)) | ||
* update default document template to use asset strategy ([0688b03](https://github.com/podium-lib/utils/commit/0688b03821989263270d72b3a5833041f24ef46c)) | ||
## [4.4.42](https://github.com/podium-lib/utils/compare/v4.4.41...v4.4.42) (2023-11-16) | ||
@@ -2,0 +10,0 @@ |
@@ -28,2 +28,4 @@ import { IncomingMessage, ServerResponse } from 'http'; | ||
data?: Array<{ key: string; value: string }>; | ||
strategy?: "beforeInteractive" | "afterInteractive" | "lazy"; | ||
scope?: "content" | "fallback" | "all"; | ||
}); | ||
@@ -41,2 +43,4 @@ | ||
data?: Array<{ key: string; value: string }>; | ||
strategy?: "beforeInteractive" | "afterInteractive" | "lazy"; | ||
scope?: "content" | "fallback" | "all"; | ||
toHTML(): string; | ||
@@ -62,2 +66,4 @@ toJSON(): Record<string, any>; | ||
data?: Array<{ key: string; value: string }>; | ||
strategy?: "beforeInteractive" | "afterInteractive" | "lazy"; | ||
scope?: "content" | "fallback" | "all"; | ||
}); | ||
@@ -75,2 +81,4 @@ | ||
data?: Array<{ key: string; value: string }>; | ||
strategy?: "beforeInteractive" | "afterInteractive" | "lazy"; | ||
scope?: "content" | "fallback" | "all"; | ||
toHTML(): string; | ||
@@ -77,0 +85,0 @@ toJSON(): Record<string, any>; |
@@ -21,2 +21,4 @@ 'use strict'; | ||
const _as = Symbol('podium:asset:css:as'); | ||
const _strategy = Symbol('podium:asset:css:strategy'); | ||
const _scope = Symbol('podium:asset:css:scope'); | ||
@@ -42,2 +44,4 @@ const toUndefined = value => { | ||
as = '', | ||
strategy = undefined, | ||
scope = undefined, | ||
} = {}) { | ||
@@ -61,2 +65,4 @@ if (validate.css(value).error) | ||
this[_as] = as; | ||
this[_strategy] = strategy; | ||
this[_scope] = scope; | ||
} | ||
@@ -146,2 +152,18 @@ | ||
get strategy() { | ||
return this[_strategy]; | ||
} | ||
set strategy(value) { | ||
this[_strategy] = value; | ||
} | ||
get scope() { | ||
return this[_scope]; | ||
} | ||
set scope(value) { | ||
this[_scope] = value; | ||
} | ||
toJSON() { | ||
@@ -158,2 +180,4 @@ return { | ||
as: toUndefined(this.as), | ||
strategy: toUndefined(this.strategy), | ||
scope: toUndefined(this.scope) | ||
}; | ||
@@ -160,0 +184,0 @@ } |
@@ -21,2 +21,4 @@ 'use strict'; | ||
const _data = Symbol('podium:asset:js:data'); | ||
const _strategy = Symbol('podium:asset:js:strategy'); | ||
const _scope = Symbol('podium:asset:js:scope'); | ||
@@ -43,2 +45,4 @@ const toUndefined = (value) => { | ||
data = [], | ||
strategy = undefined, | ||
scope = undefined, | ||
} = {}) { | ||
@@ -62,2 +66,4 @@ if (validate.js(value).error) | ||
this[_data] = data; | ||
this[_strategy] = strategy; | ||
this[_scope] = scope; | ||
} | ||
@@ -147,2 +153,18 @@ | ||
get strategy() { | ||
return this[_strategy]; | ||
} | ||
set strategy(value) { | ||
this[_strategy] = value; | ||
} | ||
get scope() { | ||
return this[_scope]; | ||
} | ||
set scope(value) { | ||
this[_scope] = value; | ||
} | ||
toJSON() { | ||
@@ -159,2 +181,4 @@ return { | ||
data: toUndefined(this.data), | ||
strategy: toUndefined(this.strategy), | ||
scope: toUndefined(this.scope), | ||
}; | ||
@@ -161,0 +185,0 @@ } |
@@ -20,3 +20,3 @@ 'use strict'; | ||
${styles.map(utils.buildLinkElement).join('\n ')} | ||
${scripts.map(utils.buildScriptElement).join('\n ')} | ||
${scripts.filter((script) => script.strategy === "beforeInteractive").map(utils.buildScriptElement).join('\n ')} | ||
<title>${incoming.view.title ? incoming.view.title : ''}</title> | ||
@@ -27,2 +27,4 @@ ${head} | ||
${body} | ||
${scripts.filter((script) => script.strategy === "afterInteractive" || !script.strategy).map(utils.buildScriptElement).join('\n ')} | ||
${scripts.filter((script) => script.strategy === "lazy").map((script) => `<script type="module">import("${script.value}")</script>`).join('\n ')} | ||
</body> | ||
@@ -29,0 +31,0 @@ </html>`; |
{ | ||
"name": "@podium/utils", | ||
"version": "4.4.42", | ||
"version": "4.5.0", | ||
"description": "Common generic utility methods shared by @podium modules.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53978
941