sitedrift 0.3.0 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sitedrift",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
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": {
@@ -35,12 +35,20 @@ async function devResponse(context, route) {
35
35
  if (context.request.method === 'GET' && accept.includes('text/html')) {
36
36
  const clean = pathname.replace(/^\/+/, '');
37
37
  const candidates = pathname.endsWith('/')
38
- ? [`/__sitedrift/source/${clean}index.html`]
39
- : [`/__sitedrift/source/${clean}.html`, `/__sitedrift/source/${clean}/index.html`];
40
- if (pathname === '/') candidates.unshift('/__sitedrift/source/index.html');
38
+ ? [`/__sitedrift/source/${clean}index.html.txt`]
39
+ : [`/__sitedrift/source/${clean}.html.txt`, `/__sitedrift/source/${clean}/index.html.txt`];
40
+ if (pathname === '/') candidates.unshift('/__sitedrift/source/index.html.txt');
41
41
  for (const pathname of candidates) {
42
42
  const response = await context.env.ASSETS.fetch(new URL(pathname, requestUrl));
43
- if (response.ok) return response;
43
+ if (response.ok) {
44
+ const headers = new Headers(response.headers);
45
+ headers.set('content-type', 'text/html; charset=utf-8');
46
+ return new Response(response.body, {
47
+ status: response.status,
48
+ statusText: response.statusText,
49
+ headers,
50
+ });
51
+ }
44
52
  }
45
53
  }
46
54
  return context.env.ASSETS.fetch(routeUrl);
@@ -64,6 +72,9 @@ async function liveResponse(context, route, live) {
64
72
 
65
73
  export async function onRequest(context) {
66
74
  const requestUrl = new URL(context.request.url);
75
+ if (requestUrl.pathname.startsWith('/__sitedrift/source')) {
76
+ return new Response('Not found.', { status: 404 });
77
+ }
67
78
  const match = requestUrl.pathname.match(/^\/__sitedrift\/(dev|live)(\/.*)?$/);
68
79
  if (!match) return context.env.ASSETS.fetch(context.request);
69
80
  if (!['GET', 'HEAD'].includes(context.request.method)) {
@@ -60,7 +60,7 @@ export function installCloudflarePreview({
60
60
 
61
61
  for (const file of files) {
62
62
  const relative = path.relative(output, file);
63
- const preserved = path.join(source, relative);
63
+ const preserved = path.join(source, `${relative}.txt`);
64
64
  fs.mkdirSync(path.dirname(preserved), { recursive: true });
65
65
  fs.copyFileSync(file, preserved);
66
66
  fs.writeFileSync(file, renderHostedViewer({