sitedrift 0.3.5 → 0.3.6

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.
Files changed (2) hide show
  1. package/assets/viewer.js +0 -66
  2. package/package.json +1 -1
package/assets/viewer.js CHANGED
@@ -87,72 +87,12 @@
87
87
  : config[side] + normalizeRoute(route);
88
88
  }
89
89
  function framePost(side, type, data = {}) {
90
- if (config.hosted) {
91
- const win = frame(side).contentWindow;
92
- const scrolling = frame(side).contentDocument?.scrollingElement;
93
- if (type === 'scroll' && scrolling) scrolling.scrollTop = Number(data.y) || 0;
94
- if (type === 'reload') win?.location.reload();
95
- return;
96
- }
97
90
  frame(side).contentWindow?.postMessage(
98
91
  { source: 'sitedrift-parent', side, type, ...data },
99
92
  config.hosted ? '*' : config.frameOrigins[side],
100
93
  );
101
94
  }
102
95
 
103
- function hostedSnapshot(side) {
104
- if (!config.hosted) return;
105
- const iframe = frame(side);
106
- const doc = iframe.contentDocument;
107
- const win = iframe.contentWindow;
108
- if (!doc || !win) return;
109
- const q = (selector) => doc.querySelector(selector);
110
- const images = [...doc.querySelectorAll('img')];
111
- const title = (doc.title || '').trim();
112
- const description = q('meta[name="description"]')?.content?.trim() || '';
113
- const canonical = q('link[rel="canonical"]')?.href || '';
114
- const checks = [
115
- ['Title present', !!title],
116
- ['Title 30–60 chars', title.length >= 30 && title.length <= 60, String(title.length)],
117
- ['Meta description', !!description],
118
- ['Description 70–160', description.length >= 70 && description.length <= 160, String(description.length)],
119
- ['Exactly one H1', doc.querySelectorAll('h1').length === 1, `${doc.querySelectorAll('h1').length} found`],
120
- ['Canonical link', !!q('link[rel="canonical"]')],
121
- ['Viewport meta', !!q('meta[name="viewport"]')],
122
- ['html lang', !!doc.documentElement.lang],
123
- ['Open Graph title', !!q('meta[property="og:title"]')],
124
- ['Open Graph image', !!q('meta[property="og:image"]')],
125
- ['Not noindex', !(q('meta[name="robots"]')?.content || '').toLowerCase().includes('noindex')],
126
- ['Favicon', !!q('link[rel~="icon"]')],
127
- ['Images have alt', images.every((image) => image.hasAttribute('alt')), `${images.filter((image) => !image.hasAttribute('alt')).length} missing`],
128
- ].map(([label, ok, note]) => ({ label, ok, note }));
129
- const url = new URL(iframe.src);
130
- const route = (url.pathname.slice(proxyPath(side).length) || '/') + url.search + url.hash;
131
- renderMetadata(side, {
132
- route,
133
- meta: {
134
- title,
135
- description,
136
- canonical,
137
- heading: q('h1')?.textContent?.trim() || '',
138
- siteName: q('meta[property="og:site_name"]')?.content?.trim() || '',
139
- icon: q('link[rel~="icon"]')?.href || '',
140
- checks,
141
- },
142
- });
143
- fetchStatus(side, route);
144
- const reportScroll = () => {
145
- const root = doc.scrollingElement || doc.documentElement;
146
- frameState[side] = {
147
- y: Number(win.scrollY) || 0,
148
- max: Math.max(0, root.scrollHeight - win.innerHeight),
149
- };
150
- syncFrom(side);
151
- };
152
- win.addEventListener('scroll', reportScroll, { passive: true });
153
- reportScroll();
154
- }
155
-
156
96
  function statusBadges(side) {
157
97
  return [
158
98
  document.querySelector('.label[data-label="' + side + '"] .status-badge'),
@@ -565,12 +505,6 @@
565
505
  runFrameKey(message.key, side, message);
566
506
  }
567
507
  });
568
- if (config.hosted) {
569
- for (const side of ['dev', 'live']) {
570
- frame(side).addEventListener('load', () => hostedSnapshot(side));
571
- }
572
- }
573
-
574
508
  scrollButton.addEventListener('click', () => {
575
509
  syncScroll = !syncScroll;
576
510
  scrollButton.classList.toggle('active', syncScroll);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sitedrift",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Catch the drift between dev and live — frame your local site and production side-by-side on the same route, locked scroll, with a difference-blend overlay. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "bin": {