@symbo.ls/utils 3.14.691 → 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,17 @@
1
1
  # @symbo.ls/utils
2
2
 
3
+ ## 3.14.707
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
9
+ ## 3.14.702
10
+
11
+ ### Patch Changes
12
+
13
+ - Auto-generated cross-repo patch release.
14
+
3
15
  ## 3.14.691
4
16
 
5
17
  ### 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/cjs/env.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var N=(t,o)=>{for(var c in o)n(t,c,{get:o[c],enumerable:!0})},a=(t,o,c,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of g(o))!l.call(t,e)&&e!==c&&n(t,e,{get:()=>o[e],enumerable:!(i=x(o,e))||i.enumerable});return t};var d=t=>a(n({},"__esModule",{value:!0}),t);var P={};N(P,{ENV:()=>E,NODE_ENV:()=>s,getNev:()=>v,isDevelopment:()=>m,isLocal:()=>V,isNotProduction:()=>O,isProduction:()=>r,isStaging:()=>D,isTest:()=>p,isTesting:()=>u});module.exports=d(P);// @preserve-env
2
- const s="production",E=s,r=(t=s)=>t==="production",p=(t=s)=>t==="testing"||t==="test",u=p,D=(t=s)=>t==="staging",V=(t=s)=>t==="local",m=(t=s)=>t==="development"||t==="dev"||t==="local",v=(t,o=s)=>o[t],O=(t=s)=>!r(t);
1
+ "use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var d=(t,o)=>{for(var n in o)c(t,n,{get:o[n],enumerable:!0})},x=(t,o,n,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of a(o))!l.call(t,s)&&s!==n&&c(t,s,{get:()=>o[s],enumerable:!(i=u(o,s))||i.enumerable});return t};var f=t=>x(c({},"__esModule",{value:!0}),t);var y={};d(y,{ENV:()=>N,NODE_ENV:()=>e,getNev:()=>D,isDevelopment:()=>E,isLocal:()=>m,isLoudDevRuntime:()=>v,isNotProduction:()=>V,isProduction:()=>p,isStaging:()=>h,isTest:()=>r,isTesting:()=>g});module.exports=f(y);// @preserve-env
2
+ const e="production",N=e,p=(t=e)=>t==="production",r=(t=e)=>t==="testing"||t==="test",g=r,h=(t=e)=>t==="staging",m=(t=e)=>t==="local",E=(t=e)=>t==="development"||t==="dev"||t==="local",D=(t,o=e)=>o[t],V=(t=e)=>!p(t),v=t=>{const o=t&&"env"in t?t.env:typeof process<"u"&&process.env?"production":void 0;if(o&&o!=="production")return!0;const n=t&&"hostname"in t?t.hostname:typeof location<"u"?location.hostname:void 0;return typeof n=="string"&&n?n==="localhost"||n==="127.0.0.1"||n.endsWith(".localhost"):!1};
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/dist/esm/env.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @preserve-env
2
- const o="production",n=o,e=(t=o)=>t==="production",c=(t=o)=>t==="testing"||t==="test",i=c,r=(t=o)=>t==="staging",p=(t=o)=>t==="local",x=(t=o)=>t==="development"||t==="dev"||t==="local",g=(t,s=o)=>s[t],l=(t=o)=>!e(t);export{n as ENV,o as NODE_ENV,g as getNev,x as isDevelopment,p as isLocal,l as isNotProduction,e as isProduction,r as isStaging,c as isTest,i as isTesting};
2
+ const o="production",i=o,s=(t=o)=>t==="production",c=(t=o)=>t==="testing"||t==="test",p=c,r=(t=o)=>t==="staging",u=(t=o)=>t==="local",a=(t=o)=>t==="development"||t==="dev"||t==="local",l=(t,e=o)=>e[t],d=(t=o)=>!s(t),x=t=>{const e=t&&"env"in t?t.env:typeof process<"u"&&process.env?"production":void 0;if(e&&e!=="production")return!0;const n=t&&"hostname"in t?t.hostname:typeof location<"u"?location.hostname:void 0;return typeof n=="string"&&n?n==="localhost"||n==="127.0.0.1"||n.endsWith(".localhost"):!1};export{i as ENV,o as NODE_ENV,l as getNev,a as isDevelopment,u as isLocal,x as isLoudDevRuntime,d as isNotProduction,s as isProduction,r as isStaging,c as isTest,p as isTesting};
package/env.js CHANGED
@@ -13,3 +13,59 @@ export const isDevelopment = (env = NODE_ENV) =>
13
13
  env === 'development' || env === 'dev' || env === 'local'
14
14
  export const getNev = (key, env = NODE_ENV) => env[key]
15
15
  export const isNotProduction = (env = NODE_ENV) => !isProduction(env)
16
+
17
+ /**
18
+ * FRAMEWORK-6: shared gate for dev-only loud-failure diagnostics, usable by
19
+ * any package (originally lived only in `@symbo.ls/element/src/devRuntime.js`
20
+ * — moved here so `@symbo.ls/scratch`, which `element` itself depends on,
21
+ * can gate its own loud-dev warnings without a reverse dependency).
22
+ *
23
+ * Why a hybrid gate instead of `process.env.NODE_ENV !== 'production'` alone:
24
+ * the dist build (`esbuild --minify`, default platform=browser) auto-defines
25
+ * `process.env.NODE_ENV` to `"production"` and dead-code-eliminates any
26
+ * branch gated on it — verified against `dist/esm/src/create.js`, where a
27
+ * NODE_ENV-only-gated warning was compiled out entirely. Consumers resolve
28
+ * `dist/esm`, not `src` (see the workspace bundle), so a NODE_ENV-only gate
29
+ * can never fire in a real dev browser session.
30
+ *
31
+ * Why not hostname alone: node/test consumers (vitest, SSR) resolve source,
32
+ * where NODE_ENV is live and `location` may not exist.
33
+ *
34
+ * So:
35
+ * - build-time leg — `process.env.NODE_ENV` — live for source/test
36
+ * consumers; folds to `false` at dist build time (esbuild substitutes the
37
+ * literal, leaving the guarded `process` reference unreachable).
38
+ * - runtime leg — `location.hostname` is `localhost`, `127.0.0.1`, or any
39
+ * `*.localhost` — survives the dist build, so dev servers
40
+ * (`workspace.localhost:1355` etc.) still get loud failures.
41
+ *
42
+ * A visitor on a production domain (`my.symbols.app`, `*.symbo.ls`, custom
43
+ * domains) matches neither leg and never sees console noise from this.
44
+ *
45
+ * @param {object} [overrides] test-only injection: `{ env, hostname }`
46
+ * @returns {boolean}
47
+ */
48
+ export const isLoudDevRuntime = (overrides) => {
49
+ const env =
50
+ overrides && 'env' in overrides
51
+ ? overrides.env
52
+ : typeof process !== 'undefined' && process.env
53
+ ? process.env.NODE_ENV
54
+ : undefined
55
+ if (env && env !== 'production') return true
56
+
57
+ const hostname =
58
+ overrides && 'hostname' in overrides
59
+ ? overrides.hostname
60
+ : typeof location !== 'undefined'
61
+ ? location.hostname
62
+ : undefined
63
+ if (typeof hostname === 'string' && hostname) {
64
+ return (
65
+ hostname === 'localhost' ||
66
+ hostname === '127.0.0.1' ||
67
+ hostname.endsWith('.localhost')
68
+ )
69
+ }
70
+ return false
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "3.14.691",
3
+ "version": "3.14.707",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",