@symbo.ls/utils 3.14.742 → 3.14.756
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 +7 -1
- package/cdn.js +66 -1
- package/dist/cjs/cdn.js +2 -2
- package/dist/esm/cdn.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/cdn.js
CHANGED
|
@@ -61,15 +61,72 @@ export const getCdnProviderFromConfig = (symbolsConfig = {}) => {
|
|
|
61
61
|
return PACKAGE_MANAGER_TO_CDN[packageManager] || null
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
// npm-style caret/tilde RANGE prefixes (`^6.0.1`, `~6.0.1`) resolve to a
|
|
65
|
+
// single concrete version once the operator is dropped — but every
|
|
66
|
+
// CDN_PROVIDERS.formatUrl above concatenates `@${version}` into a URL path
|
|
67
|
+
// segment VERBATIM, with zero awareness of npm range syntax. A raw,
|
|
68
|
+
// unstripped `^6.0.1` observed live (system--workspace-ui.at.symbo.ls,
|
|
69
|
+
// 2026-08-10 probe — tickets/opus.md "P1 Monaco retry loop / P1 prismjs+
|
|
70
|
+
// fuse.js", same importmap family) produced `.../codemirror@^6.0.1`, which
|
|
71
|
+
// esm.sh resolved to a build lacking codemirror 6's `basicSetup` export —
|
|
72
|
+
// `SyntaxError: The requested module '/codemirror@^6.0.1...' does not
|
|
73
|
+
// provide an export named 'basicSetup'` — an uncaught page error that
|
|
74
|
+
// survived SPA navigation to an unrelated route. Only the two common
|
|
75
|
+
// npm-default prefixes are stripped; anything else (compound ranges,
|
|
76
|
+
// `x`/`*` wildcards, dist-tags like `next`) is left exactly as declared —
|
|
77
|
+
// this fixes the concretely observed failure mode without guessing at CDN
|
|
78
|
+
// behavior for shapes nobody has reported.
|
|
79
|
+
export const stripVersionRangePrefix = (version) => {
|
|
80
|
+
if (typeof version !== 'string') return version
|
|
81
|
+
const m = version.trim().match(/^[\^~](\d.*)$/)
|
|
82
|
+
return m ? m[1] : version
|
|
83
|
+
}
|
|
84
|
+
|
|
64
85
|
export const getCDNUrl = (
|
|
65
86
|
packageName,
|
|
66
87
|
version = 'latest',
|
|
67
88
|
provider = 'esmsh'
|
|
68
89
|
) => {
|
|
69
90
|
const cdnConfig = CDN_PROVIDERS[provider] || CDN_PROVIDERS.esmsh
|
|
70
|
-
return cdnConfig.formatUrl(packageName, version)
|
|
91
|
+
return cdnConfig.formatUrl(packageName, stripVersionRangePrefix(version))
|
|
71
92
|
}
|
|
72
93
|
|
|
94
|
+
// SMBLS-IMPORTMAP-SKIP — shared with packages/smbls/src/prepare.js's own
|
|
95
|
+
// client-side loader (fc660da57, tickets/opus.md "runtime importmap loader
|
|
96
|
+
// burns ~25-40s retrying unresolvable specifiers"). That fix only covers
|
|
97
|
+
// prepareDependencies()'s EAGER boot-time fetch loop; it never touches
|
|
98
|
+
// `getImportMapScript` below, which builds the `<script type="importmap">`
|
|
99
|
+
// HTML embedded directly into SSR'd project pages. Live-reproduced
|
|
100
|
+
// 2026-08-10 on system--workspace-ui.at.symbo.ls: frank-compiled `await
|
|
101
|
+
// import('@symbo-ls/workspace-shared/functions/*.js')` calls resolve
|
|
102
|
+
// through THIS importmap — a completely separate resolution path from
|
|
103
|
+
// prepareDependencies() — so permanently-unresolvable specifiers kept
|
|
104
|
+
// round-tripping esm.sh (404) then pkg.symbo.ls (502) on every LAZY `await
|
|
105
|
+
// import(...)` regardless of whether the client-side loader fix is live.
|
|
106
|
+
// Same two shapes as prepare.js's `UNRESOLVABLE_DEP_RE`:
|
|
107
|
+
// - `node:*` — a Node.js builtin protocol; there is no CDN URL for it.
|
|
108
|
+
// - `@symbo-ls/*` — the GitHub Packages private-registry scope; an
|
|
109
|
+
// anonymous browser fetch has no auth header to send, so this 404s by
|
|
110
|
+
// construction, every time.
|
|
111
|
+
const UNRESOLVABLE_DEP_RE = /^node:|^@symbo-ls\//
|
|
112
|
+
|
|
113
|
+
export const isUnresolvableDependency = (name) =>
|
|
114
|
+
typeof name === 'string' && UNRESOLVABLE_DEP_RE.test(name)
|
|
115
|
+
|
|
116
|
+
// A DIFFERENT failure mode: a template placeholder that never got
|
|
117
|
+
// interpolated before landing in a project's `dependencies` (e.g.
|
|
118
|
+
// `<shared>/functions/diagnoseAuth.js`, `…/aiService.js` — both observed
|
|
119
|
+
// live). `<`/`>`/the horizontal-ellipsis character can never appear in a
|
|
120
|
+
// real npm specifier or URL path segment. Unlike the two cases above this
|
|
121
|
+
// ISN'T expected-by-design — it's a bug upstream of this function (most
|
|
122
|
+
// likely frank's free-var → `importPath` classification) — so callers that
|
|
123
|
+
// distinguish "silently skip" from "skip and warn" can do so via this
|
|
124
|
+
// separate predicate.
|
|
125
|
+
const MALFORMED_DEP_RE = /[<>…]/
|
|
126
|
+
|
|
127
|
+
export const isMalformedDependency = (name) =>
|
|
128
|
+
typeof name === 'string' && MALFORMED_DEP_RE.test(name)
|
|
129
|
+
|
|
73
130
|
/**
|
|
74
131
|
* Generate an HTML <script type="importmap"> tag from project dependencies.
|
|
75
132
|
*
|
|
@@ -106,9 +163,17 @@ export const getImportMapScript = (
|
|
|
106
163
|
const pin = options.pin || {}
|
|
107
164
|
const imports = {}
|
|
108
165
|
for (const pkgName of keys) {
|
|
166
|
+
// See SMBLS-IMPORTMAP-SKIP above — these can never resolve from an
|
|
167
|
+
// anonymous browser fetch (or are a bug upstream of this function), so
|
|
168
|
+
// omit them entirely instead of shipping a URL that always 404s/502s.
|
|
169
|
+
// A bare `import()` for an omitted specifier still fails when the code
|
|
170
|
+
// that needs it actually runs — but it fails FAST, at resolution time
|
|
171
|
+
// with zero network round trips, instead of after two doomed requests.
|
|
172
|
+
if (isUnresolvableDependency(pkgName) || isMalformedDependency(pkgName)) continue
|
|
109
173
|
const version = pin[pkgName] || dependencies[pkgName] || 'latest'
|
|
110
174
|
imports[pkgName] = getCDNUrl(pkgName, version, defaultProvider)
|
|
111
175
|
}
|
|
176
|
+
if (!Object.keys(imports).length) return ''
|
|
112
177
|
|
|
113
178
|
const openTag = '<script type="importmap">'
|
|
114
179
|
const closeTag = '</' + 'script>'
|
package/dist/cjs/cdn.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var x=(t,s)=>{for(var e in s)l(t,e,{get:s[e],enumerable:!0})},D=(t,s,e,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of b(s))!E.call(t,r)&&r!==e&&l(t,r,{get:()=>s[r],enumerable:!(o=h(s,r))||o.enumerable});return t};var U=t=>D(l({},"__esModule",{value:!0}),t);var N={};x(N,{CDN_PROVIDERS:()=>n,PACKAGE_MANAGER_TO_CDN:()=>m,getCDNUrl:()=>i,getCdnProviderFromConfig:()=>C,getImportMapScript:()=>j,isMalformedDependency:()=>g,isUnresolvableDependency:()=>u,stripVersionRangePrefix:()=>a});module.exports=U(N);const n={skypack:{url:"https://cdn.skypack.dev",formatUrl:(t,s)=>`${n.skypack.url}/${t}${s!=="latest"?`@${s}`:""}`},esmsh:{url:"https://esm.sh",formatUrl:(t,s)=>`${n.esmsh.url}/${t}${s!=="latest"?`@${s}`:""}`},unpkg:{url:"https://unpkg.com",formatUrl:(t,s)=>`${n.unpkg.url}/${t}${s!=="latest"?`@${s}`:""}?module`},jsdelivr:{url:"https://cdn.jsdelivr.net/npm",formatUrl:(t,s)=>`${n.jsdelivr.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`},symbols:{url:"https://pkg.symbo.ls",formatUrl:(t,s)=>`${n.symbols.url}/${t}${s!=="latest"?`@${s}`:""}/+esm`}},m={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},C=(t={})=>{const{packageManager:s}=t;return m[s]||null},a=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},i=(t,s="latest",e="esmsh")=>(n[e]||n.esmsh).formatUrl(t,a(s)),R=/^node:|^@symbo-ls\//,u=t=>typeof t=="string"&&R.test(t),_=/[<>…]/,g=t=>typeof t=="string"&&_.test(t),j=(t,s="skypack",e={})=>{const o=t.dependencies||{},r=Object.keys(o);if(!r.length)return"";const $=e.pin||{},c={};for(const p of r){if(u(p)||g(p))continue;const f=$[p]||o[p]||"latest";c[p]=i(p,f,s)}if(!Object.keys(c).length)return"";const k='<script type="importmap">',d="<\/script>",y=`{
|
|
2
2
|
"imports": ${JSON.stringify(c,null,2)}
|
|
3
|
-
}`;return`${k}${
|
|
3
|
+
}`;return`${k}${y}${d}`};
|
package/dist/esm/cdn.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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`}},
|
|
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`}},g={"esm.sh":"esmsh",unpkg:"unpkg",skypack:"skypack",jsdelivr:"jsdelivr","pkg.symbo.ls":"symbols"},b=(t={})=>{const{packageManager:s}=t;return g[s]||null},$=t=>{if(typeof t!="string")return t;const s=t.trim().match(/^[\^~](\d.*)$/);return s?s[1]:t},k=(t,s="latest",n="esmsh")=>(e[n]||e.esmsh).formatUrl(t,$(s)),d=/^node:|^@symbo-ls\//,y=t=>typeof t=="string"&&d.test(t),f=/[<>…]/,h=t=>typeof t=="string"&&f.test(t),E=(t,s="skypack",n={})=>{const o=t.dependencies||{},c=Object.keys(o);if(!c.length)return"";const l=n.pin||{},p={};for(const r of c){if(y(r)||h(r))continue;const u=l[r]||o[r]||"latest";p[r]=k(r,u,s)}if(!Object.keys(p).length)return"";const m='<script type="importmap">',a="<\/script>",i=`{
|
|
2
2
|
"imports": ${JSON.stringify(p,null,2)}
|
|
3
|
-
}`;return`${m}${
|
|
3
|
+
}`;return`${m}${i}${a}`};export{e as CDN_PROVIDERS,g as PACKAGE_MANAGER_TO_CDN,k as getCDNUrl,b as getCdnProviderFromConfig,E as getImportMapScript,h as isMalformedDependency,y as isUnresolvableDependency,$ as stripVersionRangePrefix};
|