@symbo.ls/sync 3.14.599 → 3.14.700

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,13 @@
1
1
  # @symbo.ls/sync
2
2
 
3
+ ## 3.14.700
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+ - Updated dependencies
9
+ - @symbo.ls/scratch@3.14.700
10
+
3
11
  ## 3.14.599
4
12
 
5
13
  ### Patch Changes
package/applier.js CHANGED
@@ -69,3 +69,59 @@ export const applyOpsToCtx = (ctx, changes) => {
69
69
  }
70
70
  return topLevelChanged
71
71
  }
72
+
73
+ /**
74
+ * Design-system re-init source for HMR/livesync.
75
+ *
76
+ * `ctx.designSystem` is scratch's PROCESSED config, mutated in place at
77
+ * boot — feeding it back into `init()` (as the handlers previously did) is
78
+ * a double-processing hazard: processed color entries re-enter the token
79
+ * transformers and the emitted CSS vars can lose their alpha channel
80
+ * (captured live: `--color-transparent` rgba(0,0,0,0) → rgba(0,0,0,1),
81
+ * i.e. every `background: 'transparent'` element painted solid black
82
+ * until a manual reload).
83
+ *
84
+ * This helper keeps a PRISTINE raw copy on the context (`__rawDesignSystem`):
85
+ * - seed it once from a raw source (server snapshot DS, or the project's
86
+ * authored DS before processing),
87
+ * - apply DS ops against the raw copy,
88
+ * - hand `init()` a deep clone of raw (never the live processed object),
89
+ * with the shared-library design systems deep-defaulted in — the same
90
+ * merge boot performs — so a re-init doesn't strip brand tokens.
91
+ */
92
+ export const seedRawDesignSystem = (ctx, rawDs) => {
93
+ if (!ctx || !rawDs || typeof rawDs !== 'object') return
94
+ ctx.__rawDesignSystem = JSON.parse(JSON.stringify(rawDs))
95
+ }
96
+
97
+ const deepDefaultsInto = (target, source) => {
98
+ for (const k in source) {
99
+ if (FORBIDDEN_SEGMENTS.has(k)) continue
100
+ const sv = source[k]
101
+ const tv = target[k]
102
+ if (sv && typeof sv === 'object' && !Array.isArray(sv)) {
103
+ if (!tv || typeof tv !== 'object' || Array.isArray(tv)) {
104
+ if (!(k in target)) target[k] = JSON.parse(JSON.stringify(sv))
105
+ continue
106
+ }
107
+ deepDefaultsInto(tv, sv)
108
+ } else if (!(k in target)) {
109
+ target[k] = sv
110
+ }
111
+ }
112
+ }
113
+
114
+ export const buildReinitDesignSystem = (ctx, dsOps) => {
115
+ if (!ctx || !ctx.__rawDesignSystem) return null
116
+ if (Array.isArray(dsOps) && dsOps.length) {
117
+ const holder = { designSystem: ctx.__rawDesignSystem }
118
+ applyOpsToCtx(holder, dsOps)
119
+ }
120
+ const out = JSON.parse(JSON.stringify(ctx.__rawDesignSystem))
121
+ const libs = Array.isArray(ctx.sharedLibraries) ? ctx.sharedLibraries : []
122
+ for (const lib of libs) {
123
+ const libDs = lib && lib.designSystem
124
+ if (libDs && typeof libDs === 'object') deepDefaultsInto(out, libDs)
125
+ }
126
+ return out
127
+ }
@@ -1 +1 @@
1
- var s=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var g=(r,e)=>{for(var n in e)s(r,n,{get:e[n],enumerable:!0})},x=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of h(e))!A.call(r,t)&&t!==n&&s(r,t,{get:()=>e[t],enumerable:!(o=y(e,t))||o.enumerable});return r};var S=r=>x(s({},"__esModule",{value:!0}),r);var k={};g(k,{FORBIDDEN_SEGMENTS:()=>f,applyOpsToCtx:()=>_,deletePath:()=>a,isSafePath:()=>u,setPath:()=>l});module.exports=S(k);const f=new Set(["__proto__","constructor","prototype"]),u=r=>{if(!Array.isArray(r))return!1;for(let e=0;e<r.length;e++)if(f.has(r[e]))return!1;return!0},a=(r,e)=>{!r||!u(e)||e.reduce((n,o,t,i)=>{if(n&&o in n){if(t!==i.length-1)return n[o];delete n[o]}},r)},l=(r,e,n,o=!1)=>{!r||!u(e)||e.reduce((t,i,d,p)=>{if(t){if(d!==p.length-1)return!t[i]&&o&&(t[i]={}),t[i];t[i]=n}},r)},_=(r,e)=>{const n=new Set;if(!Array.isArray(e))return n;for(const[o,t,i]of e)if(!(!Array.isArray(t)||!t.length))switch(n.add(t[0]),o){case"delete":a(r,t);break;case"update":case"set":l(r,t,i,!0);break;default:break}return n};
1
+ var o=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var c=(e,r)=>{for(var n in r)o(e,n,{get:r[n],enumerable:!0})},h=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of g(r))!_.call(e,t)&&t!==n&&o(e,t,{get:()=>r[t],enumerable:!(i=A(r,t))||i.enumerable});return e};var b=e=>h(o({},"__esModule",{value:!0}),e);var N={};c(N,{FORBIDDEN_SEGMENTS:()=>f,applyOpsToCtx:()=>d,buildReinitDesignSystem:()=>D,deletePath:()=>u,isSafePath:()=>a,seedRawDesignSystem:()=>m,setPath:()=>l});module.exports=b(N);const f=new Set(["__proto__","constructor","prototype"]),a=e=>{if(!Array.isArray(e))return!1;for(let r=0;r<e.length;r++)if(f.has(e[r]))return!1;return!0},u=(e,r)=>{!e||!a(r)||r.reduce((n,i,t,s)=>{if(n&&i in n){if(t!==s.length-1)return n[i];delete n[i]}},e)},l=(e,r,n,i=!1)=>{!e||!a(r)||r.reduce((t,s,S,p)=>{if(t){if(S!==p.length-1)return!t[s]&&i&&(t[s]={}),t[s];t[s]=n}},e)},d=(e,r)=>{const n=new Set;if(!Array.isArray(r))return n;for(const[i,t,s]of r)if(!(!Array.isArray(t)||!t.length))switch(n.add(t[0]),i){case"delete":u(e,t);break;case"update":case"set":l(e,t,s,!0);break;default:break}return n},m=(e,r)=>{!e||!r||typeof r!="object"||(e.__rawDesignSystem=JSON.parse(JSON.stringify(r)))},y=(e,r)=>{for(const n in r){if(f.has(n))continue;const i=r[n],t=e[n];if(i&&typeof i=="object"&&!Array.isArray(i)){if(!t||typeof t!="object"||Array.isArray(t)){n in e||(e[n]=JSON.parse(JSON.stringify(i)));continue}y(t,i)}else n in e||(e[n]=i)}},D=(e,r)=>{if(!e||!e.__rawDesignSystem)return null;if(Array.isArray(r)&&r.length){const t={designSystem:e.__rawDesignSystem};d(t,r)}const n=JSON.parse(JSON.stringify(e.__rawDesignSystem)),i=Array.isArray(e.sharedLibraries)?e.sharedLibraries:[];for(const t of i){const s=t&&t.designSystem;s&&typeof s=="object"&&y(n,s)}return n};
@@ -1 +1 @@
1
- var p=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var u=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},y=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of d(r))!g.call(t,s)&&s!==e&&p(t,s,{get:()=>r[s],enumerable:!(n=m(r,s))||n.enumerable});return t};var A=t=>y(p({},"__esModule",{value:!0}),t);var b={};u(b,{onOps:()=>w,onSnapshot:()=>S});module.exports=A(b);var c=require("smbls"),h=require("@symbo.ls/utils"),l=require("./applier.js");const S=(t,r,e)=>{let n=!1;return(s={})=>{let{data:o}=s;const{schema:a}=s;o&&(o=t.call("deepDestringifyFunctions",o,Array.isArray(o)?[]:{}),Object.entries(o).forEach(([i,f])=>{e[i]&&typeof e[i]=="object"?i==="designSystem"?n&&(0,c.init)(f):(0,h.overwriteShallow)(e[i],f):e[i]=f}),n=!0,a&&(e.schema=a))}},w=(t,r,e)=>(n={})=>{let{changes:s}=n;if(!s||!Array.isArray(s)||!s.length)return;s=t.call("deepDestringifyFunctions",s,Array.isArray(s)?[]:{});const o=(0,l.applyOpsToCtx)(e,s);if(o.has("state")&&r.update(e.state),["pages","components","snippets","functions","assets"].some(a=>o.has(a))){const{pathname:a,search:i,hash:f}=e.window.location;t.call("router",a+i+f,t.__ref.root,{},{scrollToTop:!1})}o.has("designSystem")&&(0,c.init)(e.designSystem)};
1
+ var h=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var A=(t,i)=>{for(var s in i)h(t,s,{get:i[s],enumerable:!0})},S=(t,i,s,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of g(i))!u.call(t,e)&&e!==s&&h(t,e,{get:()=>i[e],enumerable:!(a=y(i,e))||a.enumerable});return t};var w=t=>S(h({},"__esModule",{value:!0}),t);var D={};A(D,{onOps:()=>b,onSnapshot:()=>O});module.exports=w(D);var m=require("smbls"),c=require("@symbo.ls/utils"),f=require("./applier.js");const O=(t,i,s)=>{let a=!1;return(e={})=>{let{data:n}=e;const{schema:l}=e;n&&(n=t.call("deepDestringifyFunctions",n,Array.isArray(n)?[]:{}),Object.entries(n).forEach(([o,r])=>{if(s[o]&&typeof s[o]=="object")if(o==="designSystem"){if((0,f.seedRawDesignSystem)(s,r),a){const p=(0,f.buildReinitDesignSystem)(s);p&&(0,m.init)(p)}}else(0,c.overwriteShallow)(s[o],r);else s[o]=r}),a=!0,l&&(s.schema=l))}},b=(t,i,s)=>(a={})=>{let{changes:e}=a;if(!e||!Array.isArray(e)||!e.length)return;e=t.call("deepDestringifyFunctions",e,Array.isArray(e)?[]:{});const n=e.filter(r=>Array.isArray(r)&&Array.isArray(r[1])&&r[1][0]==="designSystem"),l=n.length?e.filter(r=>!n.includes(r)):e,o=(0,f.applyOpsToCtx)(s,l);if(n.length&&o.add("designSystem"),o.has("state")&&i.update(s.state),["pages","components","snippets","functions","assets"].some(r=>o.has(r))){const{pathname:r,search:p,hash:d}=s.window.location;t.call("router",r+p+d,t.__ref.root,{},{scrollToTop:!1})}if(o.has("designSystem")){const r=(0,f.buildReinitDesignSystem)(s,n);(0,m.init)(r||s.designSystem)}};
@@ -1 +1 @@
1
- const a=new Set(["__proto__","constructor","prototype"]),s=r=>{if(!Array.isArray(r))return!1;for(let t=0;t<r.length;t++)if(a.has(r[t]))return!1;return!0},l=(r,t)=>{!r||!s(t)||t.reduce((n,i,e,o)=>{if(n&&i in n){if(e!==o.length-1)return n[i];delete n[i]}},r)},d=(r,t,n,i=!1)=>{!r||!s(t)||t.reduce((e,o,u,f)=>{if(e){if(u!==f.length-1)return!e[o]&&i&&(e[o]={}),e[o];e[o]=n}},r)},p=(r,t)=>{const n=new Set;if(!Array.isArray(t))return n;for(const[i,e,o]of t)if(!(!Array.isArray(e)||!e.length))switch(n.add(e[0]),i){case"delete":l(r,e);break;case"update":case"set":d(r,e,o,!0);break;default:break}return n};export{a as FORBIDDEN_SEGMENTS,p as applyOpsToCtx,l as deletePath,s as isSafePath,d as setPath};
1
+ const o=new Set(["__proto__","constructor","prototype"]),f=e=>{if(!Array.isArray(e))return!1;for(let r=0;r<e.length;r++)if(o.has(e[r]))return!1;return!0},l=(e,r)=>{!e||!f(r)||r.reduce((n,i,t,s)=>{if(n&&i in n){if(t!==s.length-1)return n[i];delete n[i]}},e)},d=(e,r,n,i=!1)=>{!e||!f(r)||r.reduce((t,s,y,u)=>{if(t){if(y!==u.length-1)return!t[s]&&i&&(t[s]={}),t[s];t[s]=n}},e)},S=(e,r)=>{const n=new Set;if(!Array.isArray(r))return n;for(const[i,t,s]of r)if(!(!Array.isArray(t)||!t.length))switch(n.add(t[0]),i){case"delete":l(e,t);break;case"update":case"set":d(e,t,s,!0);break;default:break}return n},p=(e,r)=>{!e||!r||typeof r!="object"||(e.__rawDesignSystem=JSON.parse(JSON.stringify(r)))},a=(e,r)=>{for(const n in r){if(o.has(n))continue;const i=r[n],t=e[n];if(i&&typeof i=="object"&&!Array.isArray(i)){if(!t||typeof t!="object"||Array.isArray(t)){n in e||(e[n]=JSON.parse(JSON.stringify(i)));continue}a(t,i)}else n in e||(e[n]=i)}},A=(e,r)=>{if(!e||!e.__rawDesignSystem)return null;if(Array.isArray(r)&&r.length){const t={designSystem:e.__rawDesignSystem};S(t,r)}const n=JSON.parse(JSON.stringify(e.__rawDesignSystem)),i=Array.isArray(e.sharedLibraries)?e.sharedLibraries:[];for(const t of i){const s=t&&t.designSystem;s&&typeof s=="object"&&a(n,s)}return n};export{o as FORBIDDEN_SEGMENTS,S as applyOpsToCtx,A as buildReinitDesignSystem,l as deletePath,f as isSafePath,p as seedRawDesignSystem,d as setPath};
@@ -1 +1 @@
1
- import{init as p}from"smbls";import{overwriteShallow as c}from"@symbo.ls/utils";import{applyOpsToCtx as h}from"./applier.js";const g=(n,f,s)=>{let a=!1;return(e={})=>{let{data:t}=e;const{schema:o}=e;t&&(t=n.call("deepDestringifyFunctions",t,Array.isArray(t)?[]:{}),Object.entries(t).forEach(([r,i])=>{s[r]&&typeof s[r]=="object"?r==="designSystem"?a&&p(i):c(s[r],i):s[r]=i}),a=!0,o&&(s.schema=o))}},u=(n,f,s)=>(a={})=>{let{changes:e}=a;if(!e||!Array.isArray(e)||!e.length)return;e=n.call("deepDestringifyFunctions",e,Array.isArray(e)?[]:{});const t=h(s,e);if(t.has("state")&&f.update(s.state),["pages","components","snippets","functions","assets"].some(o=>t.has(o))){const{pathname:o,search:r,hash:i}=s.window.location;n.call("router",o+r+i,n.__ref.root,{},{scrollToTop:!1})}t.has("designSystem")&&p(s.designSystem)};export{u as onOps,g as onSnapshot};
1
+ import{init as p}from"smbls";import{overwriteShallow as c}from"@symbo.ls/utils";import{applyOpsToCtx as d,seedRawDesignSystem as y,buildReinitDesignSystem as h}from"./applier.js";const S=(n,l,e)=>{let o=!1;return(r={})=>{let{data:t}=r;const{schema:a}=r;t&&(t=n.call("deepDestringifyFunctions",t,Array.isArray(t)?[]:{}),Object.entries(t).forEach(([i,s])=>{if(e[i]&&typeof e[i]=="object")if(i==="designSystem"){if(y(e,s),o){const f=h(e);f&&p(f)}}else c(e[i],s);else e[i]=s}),o=!0,a&&(e.schema=a))}},w=(n,l,e)=>(o={})=>{let{changes:r}=o;if(!r||!Array.isArray(r)||!r.length)return;r=n.call("deepDestringifyFunctions",r,Array.isArray(r)?[]:{});const t=r.filter(s=>Array.isArray(s)&&Array.isArray(s[1])&&s[1][0]==="designSystem"),a=t.length?r.filter(s=>!t.includes(s)):r,i=d(e,a);if(t.length&&i.add("designSystem"),i.has("state")&&l.update(e.state),["pages","components","snippets","functions","assets"].some(s=>i.has(s))){const{pathname:s,search:f,hash:m}=e.window.location;n.call("router",s+f+m,n.__ref.root,{},{scrollToTop:!1})}if(i.has("designSystem")){const s=h(e,t);p(s||e.designSystem)}};export{w as onOps,S as onSnapshot};
package/handlers.js CHANGED
@@ -5,7 +5,11 @@
5
5
 
6
6
  import { init } from 'smbls'
7
7
  import { overwriteShallow } from '@symbo.ls/utils'
8
- import { applyOpsToCtx } from './applier.js'
8
+ import {
9
+ applyOpsToCtx,
10
+ seedRawDesignSystem,
11
+ buildReinitDesignSystem
12
+ } from './applier.js'
9
13
 
10
14
  export const onSnapshot = (el, s, ctx) => {
11
15
  // The FIRST snapshot the server pushes on connect is just the already-rendered
@@ -33,7 +37,15 @@ export const onSnapshot = (el, s, ctx) => {
33
37
  Object.entries(data).forEach(([key, val]) => {
34
38
  if (ctx[key] && typeof ctx[key] === 'object') {
35
39
  if (key === 'designSystem') {
36
- if (booted) init(val)
40
+ // Track the RAW server copy on every snapshot (the boot snapshot
41
+ // included) — it is the only clean re-init source. Never init from
42
+ // `ctx.designSystem`: that object is scratch's processed config
43
+ // and re-processing it corrupts emitted vars (transparent→black).
44
+ seedRawDesignSystem(ctx, val)
45
+ if (booted) {
46
+ const raw = buildReinitDesignSystem(ctx)
47
+ if (raw) init(raw)
48
+ }
37
49
  } else {
38
50
  overwriteShallow(ctx[key], val)
39
51
  }
@@ -59,7 +71,19 @@ export const onOps =
59
71
  Array.isArray(changes) ? [] : {}
60
72
  )
61
73
 
62
- const changed = applyOpsToCtx(ctx, changes)
74
+ // DS ops are split off BEFORE the ctx apply: they must land on the raw
75
+ // copy (buildReinitDesignSystem applies them there), never be spliced
76
+ // into the live processed config — a processed/raw hybrid fed back into
77
+ // init() is the double-processing hazard.
78
+ const dsOps = changes.filter(
79
+ (op) => Array.isArray(op) && Array.isArray(op[1]) && op[1][0] === 'designSystem'
80
+ )
81
+ const otherOps = dsOps.length
82
+ ? changes.filter((op) => !dsOps.includes(op))
83
+ : changes
84
+
85
+ const changed = applyOpsToCtx(ctx, otherOps)
86
+ if (dsOps.length) changed.add('designSystem')
63
87
 
64
88
  // State changes → re-run state. Editor-driven navigation now goes
65
89
  // through explicit `el.router(route)` calls (or a dedicated `navigate`
@@ -90,6 +114,11 @@ export const onOps =
90
114
  }
91
115
 
92
116
  if (changed.has('designSystem')) {
93
- init(ctx.designSystem)
117
+ // Re-init from the raw copy + shared-library defaults — see the
118
+ // seedRawDesignSystem note in onSnapshot. Fall back to the live
119
+ // config ONLY when no raw source was ever seeded (a client that
120
+ // never received a snapshot), matching the old behavior.
121
+ const raw = buildReinitDesignSystem(ctx, dsOps)
122
+ init(raw || ctx.designSystem)
94
123
  }
95
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/sync",
3
- "version": "3.14.599",
3
+ "version": "3.14.700",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@symbo.ls/router": "^3.14.599",
49
49
  "@symbo.ls/utils": "^3.14.599",
50
- "@symbo.ls/scratch": "^3.14.599",
50
+ "@symbo.ls/scratch": "^3.14.700",
51
51
  "@symbo.ls/default-config": "^3.14.599",
52
52
  "chalk": "^5.6.2",
53
53
  "socket.io-client": "^4.8.3"