@symbo.ls/utils 3.14.656 → 3.14.663
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/CHANGELOG.md +6 -0
- package/cdn.js +18 -2
- package/dist/cjs/cdn.js +3 -3
- package/dist/esm/cdn.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/cdn.js
CHANGED
|
@@ -65,6 +65,18 @@ export const getCDNUrl = (
|
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Generate an HTML <script type="importmap"> tag from project dependencies.
|
|
68
|
+
*
|
|
69
|
+
* The closing tag is built via string concatenation (`'</' + 'script>'`) so
|
|
70
|
+
* this module's source never carries the literal closing-tag sequence as a
|
|
71
|
+
* single substring. This package is bundled verbatim into the smbls IIFE
|
|
72
|
+
* that ships to the browser (and can be re-embedded as a string, e.g. for
|
|
73
|
+
* SSR), and HTML parsing terminates a script element at the first such byte
|
|
74
|
+
* sequence regardless of JS string-literal context. That sequence sitting
|
|
75
|
+
* whole in this source would prematurely close ANY outer script tag that
|
|
76
|
+
* happens to inline this bundle's source text, dumping the remainder of the
|
|
77
|
+
* bundle onto the page as raw HTML (tickets/smbls.md — the ~355KB "fake
|
|
78
|
+
* importmap" bug). Splitting the tag here means neither the source nor any
|
|
79
|
+
* minified/bundled copy of it ever carries that literal substring.
|
|
68
80
|
*/
|
|
69
81
|
export const getImportMapScript = (data, defaultProvider = 'skypack') => {
|
|
70
82
|
const dependencies = data.dependencies || {}
|
|
@@ -77,7 +89,11 @@ export const getImportMapScript = (data, defaultProvider = 'skypack') => {
|
|
|
77
89
|
imports[pkgName] = getCDNUrl(pkgName, version, defaultProvider)
|
|
78
90
|
}
|
|
79
91
|
|
|
80
|
-
|
|
92
|
+
const openTag = '<script type="importmap">'
|
|
93
|
+
const closeTag = '</' + 'script>'
|
|
94
|
+
const body = `{
|
|
81
95
|
"imports": ${JSON.stringify(imports, null, 2)}
|
|
82
|
-
}
|
|
96
|
+
}`
|
|
97
|
+
|
|
98
|
+
return `${openTag}${body}${closeTag}`
|
|
83
99
|
}
|
package/dist/cjs/cdn.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var
|
|
2
|
-
"imports": ${JSON.stringify(
|
|
3
|
-
}
|
|
1
|
+
"use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var y=(s,t)=>{for(var r in t)p(s,r,{get:t[r],enumerable:!0})},f=(s,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d(t))!g.call(s,n)&&n!==r&&p(s,n,{get:()=>t[n],enumerable:!(o=i(t,n))||o.enumerable});return s};var h=s=>f(p({},"__esModule",{value:!0}),s);var N={};y(N,{CDN_PROVIDERS:()=>e,PACKAGE_MANAGER_TO_CDN:()=>c,getCDNUrl:()=>m,getCdnProviderFromConfig:()=>C,getImportMapScript:()=>j});module.exports=h(N);function b(s){return/^[0-9.]+$/.test(s)&&s!==""}const e={skypack:{url:"https://cdn.skypack.dev",formatUrl:(s,t)=>`${e.skypack.url}/${s}${t!=="latest"?`@${t}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(s,t)=>`${e.esmsh.url}/${s}${t!=="latest"?`@${t}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(s,t)=>`${e.unpkg.url}/${s}${t!=="latest"?`@${t}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(s,t)=>`${e.jsdelivr.url}/${s}${t!=="latest"?`@${t}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(s,t)=>s.split("/").length>2||!b(t)?`${e.symbols.url}/${s}`:`${e.symbols.url}/${s}/${t}.js`}},c={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},C=(s={})=>{const{packageManager:t}=s;return c[t]||null},m=(s,t="latest",r="esmsh")=>(e[r]||e.esmsh).formatUrl(s,t),j=(s,t="skypack")=>{const r=s.dependencies||{},o=Object.keys(r);if(!o.length)return"";const n={};for(const l of o){const k=r[l]||"latest";n[l]=m(l,k,t)}const u='<script type="importmap">',a="<\/script>",$=`{
|
|
2
|
+
"imports": ${JSON.stringify(n,null,2)}
|
|
3
|
+
}`;return`${u}${$}${a}`};
|
package/dist/esm/cdn.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function
|
|
2
|
-
"imports": ${JSON.stringify(
|
|
3
|
-
}
|
|
1
|
+
function a(t){return/^[0-9.]+$/.test(t)&&t!==""}const r={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${r.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${r.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${r.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${r.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>t.split("/").length>2||!a(s)?`${r.symbols.url}/${t}`:`${r.symbols.url}/${t}/${s}.js`}},$={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},i=(t={})=>{const{packageManager:s}=t;return $[s]||null},k=(t,s="latest",e="esmsh")=>(r[e]||r.esmsh).formatUrl(t,s),d=(t,s="skypack")=>{const e=t.dependencies||{},n=Object.keys(e);if(!n.length)return"";const l={};for(const o of n){const u=e[o]||"latest";l[o]=k(o,u,s)}const p='<script type="importmap">',c="<\/script>",m=`{
|
|
2
|
+
"imports": ${JSON.stringify(l,null,2)}
|
|
3
|
+
}`;return`${p}${m}${c}`};export{r as CDN_PROVIDERS,$ as PACKAGE_MANAGER_TO_CDN,k as getCDNUrl,i as getCdnProviderFromConfig,d as getImportMapScript};
|