@symbo.ls/utils 3.14.702 → 3.14.707

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @symbo.ls/utils
2
2
 
3
+ ## 3.14.707
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
3
9
  ## 3.14.702
4
10
 
5
11
  ### Patch Changes
package/cdn.js CHANGED
@@ -1,9 +1,5 @@
1
1
  'use strict'
2
2
 
3
- function onlyDotsAndNumbers (str) {
4
- return /^[0-9.]+$/.test(str) && str !== ''
5
- }
6
-
7
3
  export const CDN_PROVIDERS = {
8
4
  skypack: {
9
5
  url: 'https://cdn.skypack.dev',
@@ -25,14 +21,25 @@ export const CDN_PROVIDERS = {
25
21
  formatUrl: (pkg, version) =>
26
22
  `${CDN_PROVIDERS.jsdelivr.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}/+esm`
27
23
  },
24
+ // pkg.symbo.ls — our own proxy (server/workers/packages). It is a raw file
25
+ // PASSTHROUGH (GCS bucket → jsDelivr → unpkg), not a CJS→ESM transformer,
26
+ // so the artifact you get is entirely decided by the path you ask for:
27
+ //
28
+ // /smbls@3.14.706 → jsDelivr's default file = dist/smbls.iife.js
29
+ // /smbls@3.14.706/+esm → jsDelivr's ESM build ✅ importable
30
+ //
31
+ // This provider previously emitted the bare/`/<version>.js` forms, both of
32
+ // which resolve to the IIFE — `var Smbls=(()=>{…})()`, a script with zero
33
+ // exports. Any `import … from 'smbls'` against an importmap built that way
34
+ // fails at link time, and `smbls init --runtime browser` scaffolds shipped
35
+ // exactly that. `/+esm` is jsDelivr's on-the-fly ESM transform and works
36
+ // for CJS-only third-party packages too (js-beautify, prismjs, lottie-web
37
+ // all verified), which is what makes this a complete esm.sh replacement on
38
+ // a domain we control rather than a smbls-only special case.
28
39
  symbols: {
29
40
  url: 'https://pkg.symbo.ls',
30
- formatUrl: (pkg, version) => {
31
- if (pkg.split('/').length > 2 || !onlyDotsAndNumbers(version)) {
32
- return `${CDN_PROVIDERS.symbols.url}/${pkg}`
33
- }
34
- return `${CDN_PROVIDERS.symbols.url}/${pkg}/${version}.js`
35
- }
41
+ formatUrl: (pkg, version) =>
42
+ `${CDN_PROVIDERS.symbols.url}/${pkg}${version !== 'latest' ? `@${version}` : ''}/+esm`
36
43
  }
37
44
  }
38
45
 
@@ -77,15 +84,29 @@ export const getCDNUrl = (
77
84
  * bundle onto the page as raw HTML (tickets/smbls.md — the ~355KB "fake
78
85
  * importmap" bug). Splitting the tag here means neither the source nor any
79
86
  * minified/bundled copy of it ever carries that literal substring.
87
+ *
88
+ * `options.pin` — `{ [pkgName]: version }` — overrides the version declared in
89
+ * the project's dependencies. A host that INJECTS a runtime into the page must
90
+ * pin the matching importmap entry to the version it injected, or the page
91
+ * carries two different copies of the same package: one inlined, one resolved
92
+ * from whatever the registry's floating tag points at that hour. Deployed
93
+ * *.at.symbo.ls pages shipped `"smbls": "latest"` against an inlined IIFE from
94
+ * a months-old pin, and the client half moved 683 → 704 in a single evening
95
+ * under already-published sites (tickets/smbls.md).
80
96
  */
81
- export const getImportMapScript = (data, defaultProvider = 'skypack') => {
97
+ export const getImportMapScript = (
98
+ data,
99
+ defaultProvider = 'skypack',
100
+ options = {}
101
+ ) => {
82
102
  const dependencies = data.dependencies || {}
83
103
  const keys = Object.keys(dependencies)
84
104
  if (!keys.length) return ''
85
105
 
106
+ const pin = options.pin || {}
86
107
  const imports = {}
87
108
  for (const pkgName of keys) {
88
- const version = dependencies[pkgName] || 'latest'
109
+ const version = pin[pkgName] || dependencies[pkgName] || 'latest'
89
110
  imports[pkgName] = getCDNUrl(pkgName, version, defaultProvider)
90
111
  }
91
112
 
package/dist/cjs/cdn.js CHANGED
@@ -1,3 +1,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}`};
1
+ "use strict";var p=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var h=(t,s)=>{for(var e in s)p(t,e,{get:s[e],enumerable:!0})},C=(t,s,e,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of y(s))!f.call(t,r)&&r!==e&&p(t,r,{get:()=>s[r],enumerable:!(n=d(s,r))||n.enumerable});return t};var b=t=>C(p({},"__esModule",{value:!0}),t);var N={};h(N,{CDN_PROVIDERS:()=>o,PACKAGE_MANAGER_TO_CDN:()=>m,getCDNUrl:()=>a,getCdnProviderFromConfig:()=>U,getImportMapScript:()=>j});module.exports=b(N);const o={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${o.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${o.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${o.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${o.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${o.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},m={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},U=(t={})=>{const{packageManager:s}=t;return m[s]||null},a=(t,s="latest",e="esmsh")=>(o[e]||o.esmsh).formatUrl(t,s),j=(t,s="skypack",e={})=>{const n=t.dependencies||{},r=Object.keys(n);if(!r.length)return"";const $=e.pin||{},c={};for(const l of r){const i=$[l]||n[l]||"latest";c[l]=a(l,i,s)}const k='<script type="importmap">',u="<\/script>",g=`{
2
+ "imports": ${JSON.stringify(c,null,2)}
3
+ }`;return`${k}${g}${u}`};
package/dist/esm/cdn.js CHANGED
@@ -1,3 +1,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};
1
+ const e={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${e.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${e.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${e.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${e.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${e.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},u={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},i=(t={})=>{const{packageManager:s}=t;return u[s]||null},g=(t,s="latest",o="esmsh")=>(e[o]||e.esmsh).formatUrl(t,s),d=(t,s="skypack",o={})=>{const n=t.dependencies||{},l=Object.keys(n);if(!l.length)return"";const c=o.pin||{},p={};for(const r of l){const k=c[r]||n[r]||"latest";p[r]=g(r,k,s)}const m='<script type="importmap">',a="<\/script>",$=`{
2
+ "imports": ${JSON.stringify(p,null,2)}
3
+ }`;return`${m}${$}${a}`};export{e as CDN_PROVIDERS,u as PACKAGE_MANAGER_TO_CDN,g as getCDNUrl,i as getCdnProviderFromConfig,d as getImportMapScript};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.702",
3
+ "version": "3.14.707",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",