blogger-plugin 0.0.4 → 0.0.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.
- package/README.md +36 -4
- package/dist/vite.cjs +131 -83
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +132 -84
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,21 +76,53 @@ export default defineConfig({
|
|
|
76
76
|
plugins: [
|
|
77
77
|
react(),
|
|
78
78
|
blogger({
|
|
79
|
-
// Unhandled requests will be proxied to this Blogger blog
|
|
79
|
+
// Required: Unhandled requests will be proxied to this Blogger blog
|
|
80
80
|
proxyBlog: "https://example.blogspot.com",
|
|
81
81
|
|
|
82
|
-
// (optional) Custom entry
|
|
82
|
+
// (optional) Custom entry module paths
|
|
83
83
|
// Defaults to one of: src/{index|main}.{tsx|ts|jsx|js}
|
|
84
|
-
//
|
|
84
|
+
// modules: ["src/my-entry.ts"],
|
|
85
|
+
|
|
86
|
+
// (optional) Custom CSS file paths to inject into the template
|
|
87
|
+
// styles: ["src/custom-styles.css"],
|
|
85
88
|
|
|
86
89
|
// (optional) Custom Blogger XML template path
|
|
87
|
-
// Defaults to one of: src/{template|theme}.xml
|
|
90
|
+
// Defaults to one of: {index|template|theme}.xml or src/{index|template|theme}.xml
|
|
88
91
|
// template: "src/my-template.xml",
|
|
89
92
|
}),
|
|
90
93
|
],
|
|
91
94
|
});
|
|
92
95
|
```
|
|
93
96
|
|
|
97
|
+
### Configuration Options
|
|
98
|
+
|
|
99
|
+
The `blogger()` plugin accepts the following options:
|
|
100
|
+
|
|
101
|
+
| Option | Type | Default | Description |
|
|
102
|
+
| ----------- | ---------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
103
|
+
| `proxyBlog` | `string` | **Required** | The URL of your proxy Blogger blog. All unhandled requests during development and preview will be proxied to this blog. |
|
|
104
|
+
| `modules` | `string[]` | Auto-detected | Custom entry module paths to include in your build. If not specified, the plugin will search for: `src/index.{tsx\|ts\|jsx\|js}`, `src/main.{tsx\|ts\|jsx\|js}` |
|
|
105
|
+
| `styles` | `string[]` | `undefined` | Custom CSS file paths to inject into the template. Useful for global stylesheets or critical CSS. |
|
|
106
|
+
| `template` | `string` | Auto-detected | Path to your Blogger XML template file. If not specified, the plugin will search for: `{index\|template\|theme}.xml`, `src/{index\|template\|theme}.xml` |
|
|
107
|
+
|
|
108
|
+
### Example with All Options
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import blogger from "blogger-plugin/vite";
|
|
112
|
+
import { defineConfig } from "vite";
|
|
113
|
+
|
|
114
|
+
export default defineConfig({
|
|
115
|
+
plugins: [
|
|
116
|
+
blogger({
|
|
117
|
+
proxyBlog: "https://example.blogspot.com",
|
|
118
|
+
modules: ["src/main.tsx"],
|
|
119
|
+
styles: ["src/globals.css", "src/theme.css"],
|
|
120
|
+
template: "src/template.xml",
|
|
121
|
+
}),
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
94
126
|
**6**. **Start the development server**
|
|
95
127
|
|
|
96
128
|
```shell
|
package/dist/vite.cjs
CHANGED
|
@@ -71,8 +71,17 @@ async function updateTailwindCache(root, content) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// src/constants.ts
|
|
74
|
-
var
|
|
75
|
-
|
|
74
|
+
var DEFAULT_MODULES = [
|
|
75
|
+
"src/index.tsx",
|
|
76
|
+
"src/index.ts",
|
|
77
|
+
"src/index.jsx",
|
|
78
|
+
"src/index.js",
|
|
79
|
+
"src/main.tsx",
|
|
80
|
+
"src/main.ts",
|
|
81
|
+
"src/main.jsx",
|
|
82
|
+
"src/main.js"
|
|
83
|
+
];
|
|
84
|
+
var DEFAULT_TEMPLATES = ["index.xml", "template.xml", "theme.xml", "src/index.xml", "src/template.xml", "src/theme.xml"];
|
|
76
85
|
|
|
77
86
|
// src/utils.ts
|
|
78
87
|
function escapeHtml(str) {
|
|
@@ -139,8 +148,8 @@ function getRequestUrl(req) {
|
|
|
139
148
|
const hostHeader = req.headers.host;
|
|
140
149
|
const protocol = Array.isArray(xForwardedProtoHeader) ? xForwardedProtoHeader[0] : xForwardedProtoHeader != null ? xForwardedProtoHeader : req.socket && "encrypted" in req.socket && req.socket.encrypted ? "https" : "http";
|
|
141
150
|
const host = Array.isArray(xForwardedHostHeader) ? xForwardedHostHeader[0] : xForwardedHostHeader != null ? xForwardedHostHeader : hostHeader;
|
|
142
|
-
if (host && req.
|
|
143
|
-
return new URL(`${protocol}://${host}${req.
|
|
151
|
+
if (host && req.originalUrl) {
|
|
152
|
+
return new URL(`${protocol}://${host}${req.originalUrl}`);
|
|
144
153
|
}
|
|
145
154
|
return null;
|
|
146
155
|
}
|
|
@@ -253,100 +262,143 @@ function errorHtml(reqUrl) {
|
|
|
253
262
|
}
|
|
254
263
|
|
|
255
264
|
// src/vite.ts
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
265
|
+
var viteMajor = Number(_vite.version.split(".")[0]);
|
|
266
|
+
var bundlerKey = viteMajor >= 8 ? "rolldownOptions" : "rollupOptions";
|
|
267
|
+
var BloggerPluginContext = class {
|
|
268
|
+
constructor(options) {
|
|
269
|
+
if (typeof options.template !== "undefined" && typeof options.template !== "string") {
|
|
270
|
+
throw new Error("Option 'template' must be a string");
|
|
271
|
+
}
|
|
272
|
+
if (typeof options.modules !== "undefined" && !Array.isArray(options.modules)) {
|
|
273
|
+
throw new Error("Option 'modules' must be an array");
|
|
274
|
+
}
|
|
275
|
+
if (typeof options.styles !== "undefined" && !Array.isArray(options.styles)) {
|
|
276
|
+
throw new Error("Option 'styles' must be an array");
|
|
277
|
+
}
|
|
278
|
+
if (typeof options.proxyBlog !== "string") {
|
|
279
|
+
throw new Error("Option 'proxyBlog' must be a string");
|
|
280
|
+
}
|
|
281
|
+
let proxyBlog;
|
|
282
|
+
try {
|
|
283
|
+
proxyBlog = new URL(options.proxyBlog);
|
|
284
|
+
} catch (e) {
|
|
285
|
+
throw new Error("Option 'proxyBlog' must be a valid url");
|
|
286
|
+
}
|
|
287
|
+
this.options = options;
|
|
288
|
+
this.root = process.cwd();
|
|
289
|
+
this.modules = [];
|
|
290
|
+
this.styles = [];
|
|
291
|
+
this.template = void 0;
|
|
292
|
+
this.name = void 0;
|
|
293
|
+
this.proxyBlog = proxyBlog;
|
|
294
|
+
this.viteConfig = void 0;
|
|
295
|
+
this.tailwind = false;
|
|
296
|
+
this.input = void 0;
|
|
297
|
+
this.headTags = [];
|
|
298
|
+
this.html = void 0;
|
|
271
299
|
}
|
|
272
|
-
|
|
273
|
-
root
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
html: void 0,
|
|
281
|
-
resolve(config) {
|
|
282
|
-
this.root = config.root ? path2.resolve(config.root) : this.root;
|
|
283
|
-
if (userOptions.entry) {
|
|
284
|
-
const providedPath = path2.resolve(this.root, userOptions.entry);
|
|
285
|
-
if (fs2.existsSync(providedPath)) {
|
|
286
|
-
this.entry = providedPath;
|
|
287
|
-
} else {
|
|
288
|
-
throw new Error(`Provided entry file does not exist: ${providedPath}`);
|
|
300
|
+
resolve(config) {
|
|
301
|
+
this.root = config.root ? path2.resolve(config.root) : this.root;
|
|
302
|
+
if (this.options.modules) {
|
|
303
|
+
for (let i = 0; i < this.options.modules.length; i++) {
|
|
304
|
+
const module = this.options.modules[i];
|
|
305
|
+
const modulePath = path2.resolve(this.root, module);
|
|
306
|
+
if (this.modules.includes(modulePath)) {
|
|
307
|
+
continue;
|
|
289
308
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
this.entry = fullPath;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
309
|
+
if (fs2.existsSync(modulePath)) {
|
|
310
|
+
this.modules.push(modulePath);
|
|
311
|
+
} else {
|
|
312
|
+
throw new Error(`The path provided at modules[${i}] does not exist: ${modulePath}`);
|
|
297
313
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
for (const module of DEFAULT_MODULES) {
|
|
317
|
+
const modulePath = path2.resolve(this.root, module);
|
|
318
|
+
if (fs2.existsSync(modulePath)) {
|
|
319
|
+
this.modules.push(modulePath);
|
|
320
|
+
break;
|
|
305
321
|
}
|
|
306
322
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
323
|
+
}
|
|
324
|
+
if (this.options.styles) {
|
|
325
|
+
for (let i = 0; i < this.options.styles.length; i++) {
|
|
326
|
+
const style = this.options.styles[i];
|
|
327
|
+
const stylePath = path2.resolve(this.root, style);
|
|
328
|
+
if (this.styles.includes(stylePath)) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (fs2.existsSync(stylePath)) {
|
|
332
|
+
this.styles.push(stylePath);
|
|
311
333
|
} else {
|
|
312
|
-
throw new Error(`
|
|
334
|
+
throw new Error(`The path provided at styles[${i}] does not exist: ${stylePath}`);
|
|
313
335
|
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (this.options.template) {
|
|
339
|
+
const templatePath = path2.resolve(this.root, this.options.template);
|
|
340
|
+
if (fs2.existsSync(templatePath)) {
|
|
341
|
+
this.template = templatePath;
|
|
314
342
|
} else {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
343
|
+
throw new Error(`Provided template file does not exist: ${templatePath}`);
|
|
344
|
+
}
|
|
345
|
+
} else {
|
|
346
|
+
for (const file of DEFAULT_TEMPLATES) {
|
|
347
|
+
const fullPath = path2.resolve(this.root, file);
|
|
348
|
+
if (fs2.existsSync(fullPath)) {
|
|
349
|
+
this.template = fullPath;
|
|
350
|
+
break;
|
|
321
351
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
352
|
+
}
|
|
353
|
+
if (!this.template) {
|
|
354
|
+
throw new Error(
|
|
355
|
+
`No template file found.
|
|
356
|
+
Tried: ${DEFAULT_TEMPLATES.join(", ")}
|
|
357
|
+
\u{1F449} Tip: You can pass a custom template as shown:
|
|
327
358
|
blogger({ template: "src/my-template.xml" })`
|
|
328
|
-
|
|
329
|
-
}
|
|
359
|
+
);
|
|
330
360
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
361
|
+
}
|
|
362
|
+
this.name = path2.basename(this.template, path2.extname(this.template));
|
|
363
|
+
for (const modulePath of this.modules) {
|
|
364
|
+
this.headTags.push(`<script type="module" src="/${path2.relative(this.root, modulePath).replaceAll("\\", "/")}"></script>`);
|
|
365
|
+
}
|
|
366
|
+
for (const stylePath of this.styles) {
|
|
367
|
+
this.headTags.push(`<link rel="stylesheet" href="/${path2.relative(this.root, stylePath).replaceAll("\\", "/")}">`);
|
|
368
|
+
}
|
|
369
|
+
this.input = `virtual:blogger-plugin/${this.name}.html`;
|
|
370
|
+
this.html = `<!DOCTYPE html>
|
|
334
371
|
<html>
|
|
335
372
|
<head>
|
|
336
|
-
<!--head
|
|
337
|
-
|
|
373
|
+
<!--head-->${this.headTags.length > 0 ? `
|
|
374
|
+
${this.headTags.join("\n ")}` : ""}
|
|
338
375
|
</head>
|
|
339
376
|
<body>
|
|
340
377
|
<!--body-->
|
|
341
378
|
</body>
|
|
342
379
|
</html>`;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
346
382
|
function isViteDevServer(server) {
|
|
347
383
|
return "hot" in server && "transformRequest" in server && "transformIndexHtml" in server;
|
|
348
384
|
}
|
|
349
385
|
function useServerMiddleware(server, ctx, _this) {
|
|
386
|
+
const input = ctx.viteConfig.build[bundlerKey].input;
|
|
387
|
+
const htmlPathnames = [];
|
|
388
|
+
for (const entry of Array.isArray(input) ? input : typeof input === "object" ? Object.values(input) : typeof input === "string" ? [input] : []) {
|
|
389
|
+
if (entry === ctx.input) {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const entryPath = path2.resolve(ctx.root, entry);
|
|
393
|
+
if (!entryPath.endsWith(".html")) {
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const relativePath = path2.relative(ctx.root, entry).replaceAll("\\", "/");
|
|
397
|
+
htmlPathnames.push(`/${relativePath}`);
|
|
398
|
+
if (relativePath.endsWith("index.html")) {
|
|
399
|
+
htmlPathnames.push(`/${relativePath.replace(/index\.html$/, "")}`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
350
402
|
return () => {
|
|
351
403
|
var _a;
|
|
352
404
|
(_a = server.httpServer) == null ? void 0 : _a.once("listening", () => {
|
|
@@ -357,7 +409,7 @@ function useServerMiddleware(server, ctx, _this) {
|
|
|
357
409
|
server.middlewares.use(async (req, res, next) => {
|
|
358
410
|
var _a2;
|
|
359
411
|
const url = getRequestUrl(req);
|
|
360
|
-
if (!req.url || !req.originalUrl || !url) {
|
|
412
|
+
if (!req.url || !req.originalUrl || !url || htmlPathnames.includes(url.pathname.replace(/\/+/g, "/"))) {
|
|
361
413
|
next();
|
|
362
414
|
return;
|
|
363
415
|
}
|
|
@@ -415,11 +467,9 @@ function useServerMiddleware(server, ctx, _this) {
|
|
|
415
467
|
}
|
|
416
468
|
htmlTemplateContent = replaceHost(htmlTemplateContent, proxyUrl.host, url.host, url.protocol);
|
|
417
469
|
if (isViteDevServer(server)) {
|
|
418
|
-
const htmlTags = [];
|
|
419
|
-
htmlTags.push(`<script type='module' src='/${escapeHtml(path2.relative(ctx.root, ctx.entry).replace("\\", "/"))}'></script>`);
|
|
420
470
|
const template = await server.transformIndexHtml(
|
|
421
471
|
req.url,
|
|
422
|
-
replaceBloggerPluginHeadComment(htmlTemplateContent,
|
|
472
|
+
replaceBloggerPluginHeadComment(htmlTemplateContent, ctx.headTags.join("")),
|
|
423
473
|
req.originalUrl
|
|
424
474
|
);
|
|
425
475
|
res.end(template);
|
|
@@ -447,15 +497,13 @@ function useServerMiddleware(server, ctx, _this) {
|
|
|
447
497
|
};
|
|
448
498
|
}
|
|
449
499
|
function blogger(userOptions) {
|
|
450
|
-
const ctx =
|
|
500
|
+
const ctx = new BloggerPluginContext(userOptions);
|
|
451
501
|
return {
|
|
452
502
|
name: "vite-plugin-blogger",
|
|
453
503
|
config(config) {
|
|
454
504
|
var _a;
|
|
455
505
|
ctx.resolve(config);
|
|
456
506
|
config.build || (config.build = {});
|
|
457
|
-
const major = Number(_vite.version.split(".")[0]);
|
|
458
|
-
const bundlerKey = major >= 8 ? "rolldownOptions" : "rollupOptions";
|
|
459
507
|
(_a = config.build)[bundlerKey] || (_a[bundlerKey] = {});
|
|
460
508
|
const bundlerOptions = config.build[bundlerKey];
|
|
461
509
|
if (Array.isArray(bundlerOptions.input)) {
|
package/dist/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/blogger-plugin/blogger-plugin/packages/blogger-plugin/dist/vite.cjs","../src/vite.ts","../src/cache.ts","../src/constants.ts","../src/utils.ts"],"names":["dirname","_a"],"mappings":"AAAA;ACAA,uGAAoB;AACpB,mHAAsB;AACtB,gCAAyB;AACzB;AAOE;AAAA,4BACK;ADJP;AACA;AERA;AACA;AACA,iDAAmC;AAEnC,IAAM,oBAAA,EAAsB,wBAAA;AAE5B,SAAS,eAAA,CAAgB,IAAA,EAA6B;AACpD,EAAA,GAAA,CAAI,CAAI,EAAA,CAAA,UAAA,CAAW,IAAI,CAAA,EAAG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AAA;AACW,MAAA;AACvB,MAAA;AACgB,MAAA;AACL,MAAA;AACmB,QAAA;AACoB,MAAA;AACxC,QAAA;AACjC,MAAA;AACsB,QAAA;AAC7B,MAAA;AAEuE,MAAA;AAEJ,MAAA;AAED,MAAA;AACpE,IAAA;AACuB,IAAA;AACJ,MAAA;AAC6D,MAAA;AAE5D,MAAA;AACW,QAAA;AAEK,QAAA;AACsC,UAAA;AACtE,QAAA;AACK,MAAA;AACuB,QAAA;AAC9B,MAAA;AACF,IAAA;AACkB,IAAA;AACU,MAAA;AACb,QAAA;AACb,MAAA;AACF,IAAA;AACS,IAAA;AACe,MAAA;AACT,QAAA;AACb,MAAA;AACF,IAAA;AACuB,IAAA;AACO,MAAA;AAC1B,QAAA;AACF,MAAA;AAC8B,MAAA;AACP,MAAA;AAEyC,MAAA;AAC9D,QAAA;AACF,MAAA;AAEE,MAAA;AACoC,MAAA;AAC1B,MAAA;AACV,QAAA;AACF,MAAA;AAE8B,MAAA;AACD,MAAA;AACC,MAAA;AACD,MAAA;AAIlB,MAAA;AASI,QAAA;AAGO,QAAA;AAG0E,MAAA;AAMzB,MAAA;AACJ,MAAA;AAEpC,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAStB,EAAA;AAAA;AAAA;AAAA;AAAA;AAKU,EAAA;AAAA;AAAA;AAAA;AAID,EAAA;AAAA;AAAA;AAAA,OAAA;AAK0D,MAAA;AACK,MAAA;AACnF,IAAA;AACc,IAAA;AACsE,MAAA;AACtD,MAAA;AACY,QAAA;AACxC,MAAA;AACF,IAAA;AACwB,IAAA;AACsB,MAAA;AAC9C,IAAA;AAC+B,IAAA;AACe,MAAA;AAC9C,IAAA;AACF,EAAA;AACF;ADsJ2F;AACA;AACA","file":"/home/runner/work/blogger-plugin/blogger-plugin/packages/blogger-plugin/dist/vite.cjs","sourcesContent":[null,"import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport {\n type MinimalPluginContextWithoutEnvironment,\n type Plugin,\n type PreviewServer,\n type ResolvedConfig,\n type UserConfig,\n type ViteDevServer,\n version,\n} from 'vite';\nimport { clearTailwindCache, removeTailwindCache, updateTailwindCache } from './cache';\nimport { DEFAULT_ENTRIES, DEFAULT_TEMPLATES } from './constants';\nimport {\n errorHtml,\n escapeHtml,\n getBloggerPluginHeadComment,\n getRequestUrl,\n isTailwindPlugin,\n replaceBloggerPluginHeadComment,\n replaceHost,\n toWebHeaders,\n} from './utils';\n\ninterface BloggerPluginContext {\n root: string;\n entry: string;\n template: string;\n proxyBlog: URL;\n viteConfig: ResolvedConfig;\n tailwind: boolean;\n input: string;\n html: string;\n resolve(root: UserConfig): void;\n}\n\nfunction createBloggerPluginContext(userOptions: BloggerPluginOptions): BloggerPluginContext {\n if (typeof userOptions.entry !== 'undefined' && typeof userOptions.entry !== 'string') {\n throw new Error(\"Option 'entry' must be a string\");\n }\n if (typeof userOptions.template !== 'undefined' && typeof userOptions.template !== 'string') {\n throw new Error(\"Option 'template' must be a string\");\n }\n if (typeof userOptions.proxyBlog !== 'string') {\n throw new Error(\"Option 'proxyBlog' must be a string\");\n }\n let proxyBlog: URL;\n try {\n proxyBlog = new URL(userOptions.proxyBlog);\n } catch {\n throw new Error(\"Option 'proxyBlog' must be a valid url\");\n }\n return {\n root: process.cwd(),\n entry: undefined as unknown as string,\n template: undefined as unknown as string,\n proxyBlog,\n viteConfig: undefined as unknown as ResolvedConfig,\n tailwind: false,\n input: undefined as unknown as string,\n html: undefined as unknown as string,\n resolve(config: UserConfig) {\n this.root = config.root ? path.resolve(config.root) : this.root;\n\n if (userOptions.entry) {\n const providedPath = path.resolve(this.root, userOptions.entry);\n if (fs.existsSync(providedPath)) {\n this.entry = providedPath;\n } else {\n throw new Error(`Provided entry file does not exist: ${providedPath}`);\n }\n } else {\n for (const file of DEFAULT_ENTRIES) {\n const fullPath = path.resolve(this.root, 'src', file);\n if (fs.existsSync(fullPath)) {\n this.entry = fullPath;\n break;\n }\n }\n\n if (!this.entry) {\n throw new Error(\n 'No entry file found in \"src\".\\n' +\n `Tried: ${DEFAULT_ENTRIES.map((c) => path.join('src', c)).join(', ')}\\n` +\n '👉 Tip: You can pass a custom entry like:\\n' +\n ' blogger({ entry: \"src/my-entry.ts\" })',\n );\n }\n }\n\n if (userOptions.template) {\n const providedPath = path.resolve(this.root, userOptions.template);\n if (fs.existsSync(providedPath)) {\n this.template = providedPath;\n } else {\n throw new Error(`Provided template file does not exist: ${providedPath}`);\n }\n } else {\n for (const file of DEFAULT_TEMPLATES) {\n const fullPath = path.resolve(this.root, 'src', file);\n if (fs.existsSync(fullPath)) {\n this.template = fullPath;\n break;\n }\n }\n\n if (!this.template) {\n throw new Error(\n 'No template file found in \"src\".\\n' +\n `Tried: ${DEFAULT_TEMPLATES.map((c) => path.join('src', c)).join(', ')}\\n` +\n '👉 Tip: You can pass a custom template like:\\n' +\n ' blogger({ template: \"src/my-template.xml\" })',\n );\n }\n }\n\n const name = path.basename(this.entry, path.extname(this.entry));\n this.input = `virtual:blogger-plugin/${name}.html`;\n this.html = `<!DOCTYPE html>\n<html>\n<head>\n <!--head-->\n <script type=\"module\" src=\"/${path.relative(this.root, this.entry).replace('\\\\', '/')}\"></script>\n</head>\n<body>\n <!--body-->\n</body>\n</html>`;\n },\n };\n}\n\nfunction isViteDevServer(server: ViteDevServer | PreviewServer): server is ViteDevServer {\n return 'hot' in server && 'transformRequest' in server && 'transformIndexHtml' in server;\n}\n\nfunction useServerMiddleware(server: ViteDevServer | PreviewServer, ctx: BloggerPluginContext, _this: MinimalPluginContextWithoutEnvironment) {\n return () => {\n server.httpServer?.once('listening', () => {\n setTimeout(() => {\n _this.info(`Unhandled requests will be proxied to ${ctx.proxyBlog.origin}`);\n }, 0);\n });\n\n server.middlewares.use(async (req, res, next) => {\n const url = getRequestUrl(req);\n\n if (!req.url || !req.originalUrl || !url) {\n next();\n return;\n }\n\n const start = Date.now();\n\n const proxyUrl = new URL(`${ctx.proxyBlog.origin}${req.originalUrl}`);\n\n const viewParam = proxyUrl.searchParams.get('view');\n proxyUrl.searchParams.set('view', `${isViteDevServer(server) ? '-DevServer' : '-PreviewServer'}${viewParam?.startsWith('-') ? viewParam : ''}`);\n\n const proxyRequest = new Request(proxyUrl, {\n method: req.method,\n headers: toWebHeaders(req.headers),\n body: ['GET', 'HEAD'].includes(req.method ?? '') ? undefined : Readable.toWeb(req),\n redirect: 'manual',\n });\n\n const proxyResponse = await fetch(proxyRequest).catch((error) => {\n if (error instanceof Error) {\n _this.warn({\n message: `${error.name}: ${error.message}`,\n cause: error.cause,\n stack: error.stack,\n });\n } else {\n _this.warn('Fetch failed');\n }\n return null;\n });\n\n if (proxyResponse) {\n res.statusCode = proxyResponse.status;\n res.statusMessage = proxyResponse.statusText;\n\n proxyResponse.headers.forEach((value, key) => {\n if (key === 'location') {\n const redirectUrl = new URL(value, proxyUrl);\n if (redirectUrl.host === url.host || redirectUrl.host === proxyUrl.host) {\n redirectUrl.host = url.host;\n redirectUrl.protocol = url.protocol;\n const viewParam = redirectUrl.searchParams.get('view')?.replaceAll('-DevServer', '').replaceAll('-PreviewServer', '');\n if (viewParam) {\n redirectUrl.searchParams.set('view', viewParam);\n } else {\n redirectUrl.searchParams.delete('view');\n }\n res.setHeader('location', redirectUrl.pathname + redirectUrl.search + redirectUrl.hash);\n } else {\n res.setHeader('location', redirectUrl.href);\n }\n } else if (['content-type', 'x-robots-tag', 'date', 'location'].includes(key)) {\n res.setHeader(key, value);\n }\n });\n\n const contentType = proxyResponse.headers.get('content-type');\n\n if (contentType?.startsWith('text/html')) {\n let htmlTemplateContent = await proxyResponse.text();\n\n if (ctx.tailwind && isViteDevServer(server)) {\n await updateTailwindCache(ctx.root, htmlTemplateContent);\n }\n\n htmlTemplateContent = replaceHost(htmlTemplateContent, proxyUrl.host, url.host, url.protocol);\n\n if (isViteDevServer(server)) {\n const htmlTags: string[] = [];\n\n htmlTags.push(`<script type='module' src='/${escapeHtml(path.relative(ctx.root, ctx.entry).replace('\\\\', '/'))}'></script>`);\n\n const template = await server.transformIndexHtml(\n req.url,\n replaceBloggerPluginHeadComment(htmlTemplateContent, htmlTags.join('')),\n req.originalUrl,\n );\n\n res.end(template);\n } else {\n const xmlTemplateContent = fs.readFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template.xml'), 'utf8');\n\n const htmlTagsStr = getBloggerPluginHeadComment(xmlTemplateContent, true);\n\n const template = replaceBloggerPluginHeadComment(htmlTemplateContent, htmlTagsStr ?? '');\n\n res.end(template);\n }\n } else if (contentType && /^(text\\/)|(application\\/(.*\\+)?(xml|json))/.test(contentType)) {\n const content = await proxyResponse.text();\n\n res.end(replaceHost(content, proxyUrl.host, url.host, url.protocol));\n } else {\n res.end(new Uint8Array(await proxyResponse.arrayBuffer()));\n }\n } else {\n res.statusCode = 500;\n res.statusMessage = 'Internal Server Error';\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(errorHtml(proxyUrl.href));\n }\n\n const duration = Date.now() - start;\n\n _this.info(`${req.method} ${req.originalUrl} -> ${res.statusCode} ${res.statusMessage} (${duration}ms)`);\n });\n };\n}\n\nexport interface BloggerPluginOptions {\n entry?: string;\n template?: string;\n proxyBlog: string;\n}\n\nexport default function blogger(userOptions: BloggerPluginOptions): Plugin {\n const ctx = createBloggerPluginContext(userOptions);\n\n return {\n name: 'vite-plugin-blogger',\n config(config) {\n // resolve plugin context\n ctx.resolve(config);\n\n // modify vite config\n config.build ||= {};\n const major = Number(version.split('.')[0]);\n const bundlerKey = (major >= 8 ? 'rolldownOptions' : 'rollupOptions') as 'rollupOptions';\n config.build[bundlerKey] ||= {};\n const bundlerOptions = config.build[bundlerKey];\n if (Array.isArray(bundlerOptions.input)) {\n bundlerOptions.input = [...bundlerOptions.input, ctx.input];\n } else if (typeof bundlerOptions.input === 'object' && bundlerOptions.input !== null) {\n bundlerOptions.input[ctx.input] = ctx.input;\n } else {\n bundlerOptions.input = ctx.input;\n }\n\n const originalTemplateXmlContent = fs.readFileSync(ctx.template, 'utf8');\n // remove contents between comments from template\n const modifiedTemplateXmlContent = replaceBloggerPluginHeadComment(replaceBloggerPluginHeadComment(originalTemplateXmlContent, ''), '', true);\n\n fs.writeFileSync(ctx.template, modifiedTemplateXmlContent, 'utf-8');\n },\n configResolved(config) {\n ctx.viteConfig = config;\n ctx.tailwind = config.plugins.flat(Number.POSITIVE_INFINITY).some((plugin) => isTailwindPlugin(plugin));\n\n if (ctx.tailwind) {\n clearTailwindCache(ctx.root);\n\n if (config.command === 'build') {\n updateTailwindCache(ctx.root, fs.readFileSync(ctx.template, 'utf-8'));\n }\n } else {\n removeTailwindCache(ctx.root);\n }\n },\n resolveId(source) {\n if (source === ctx.input) {\n return ctx.input;\n }\n },\n load(id) {\n if (id === ctx.input) {\n return ctx.html;\n }\n },\n writeBundle(_, bundle) {\n if (!(ctx.input in bundle)) {\n return;\n }\n const asset = bundle[ctx.input];\n delete bundle[ctx.input];\n\n if (asset.type !== 'asset' || typeof asset.source !== 'string') {\n return;\n }\n const regex =\n /<!DOCTYPE html>\\s*<html[^>]*>\\s*<head>([\\s\\S]*?)<!--head-->([\\s\\S]*?)<\\/head>\\s*<body>([\\s\\S]*?)<!--body-->([\\s\\S]*?)<\\/body>\\s*<\\/html>/i;\n const match = asset.source.match(regex);\n if (!match) {\n return;\n }\n\n const afterHeadBegin = match[1];\n const beforeHeadEnd = match[2];\n const afterBodyBegin = match[3];\n const beforeBodyEnd = match[4];\n\n const headContent = (afterHeadBegin + beforeHeadEnd)\n // boolean attributes to empty string\n .replace(/\\b(crossorigin|defer|async|disabled|checked)\\b(?!=)/g, (_, $1: string) => `${$1}=\"\"`)\n // convert attributes to single quotes safely\n .replace(/(\\w+)=(\".*?\"|'.*?')/g, (_, $1: string, $2: string) => {\n const v = $2\n // remove quotes\n .slice(1, -1)\n // escape special XML chars\n .replace(/&/g, '&')\n .replace(/'/g, ''')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n return `${$1}='${v}'`;\n })\n // self-close void tags\n .replace(/<(link|meta|img|br|hr|input)([^>]*?)>/gi, (_, $1: string, $2: string) => `<${$1}${$2} />`)\n // remove whitespace between tags\n .replace(/>\\s+</g, '><')\n // trim overall\n .trim();\n\n const originalTemplateXmlContent = fs.readFileSync(ctx.template, 'utf8');\n const modifiedTemplateXmlContent = replaceBloggerPluginHeadComment(originalTemplateXmlContent, headContent, true);\n\n const templateTagsXmlContent = `<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE html>\n<html>\n<head>\n <!--head:afterbegin:begin-->\n\n <!--head:afterbegin:end-->\n\n <!--head:beforeend:begin-->\n ${headContent}\n <!--head:beforeend:end-->\n</head>\n<body>\n <!--body:afterbegin:begin-->\n ${afterBodyBegin.trim()}\n <!--body:afterbegin:end-->\n\n <!--body:beforeend:begin-->\n ${beforeBodyEnd.trim()}\n <!--body:beforeend:end-->\n</body>\n</html>`;\n\n fs.writeFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template.xml'), modifiedTemplateXmlContent);\n fs.writeFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template-tags.xml'), templateTagsXmlContent);\n },\n closeBundle() {\n const htmlDir = path.resolve(ctx.viteConfig.build.outDir, 'virtual:blogger-plugin');\n if (fs.existsSync(htmlDir)) {\n fs.rmSync(htmlDir, { recursive: true });\n }\n },\n configureServer(server) {\n return useServerMiddleware(server, ctx, this);\n },\n configurePreviewServer(server) {\n return useServerMiddleware(server, ctx, this);\n },\n };\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { getTailwindClasses } from 'tailwindcss-iso';\n\nconst TAILWIND_CACHE_FILE = '.tailwind-classes.json';\n\nfunction readFileContent(file: string): string | null {\n if (!fs.existsSync(file)) {\n return null;\n }\n return fs.readFileSync(file, 'utf-8');\n}\n\nfunction writeFileContent(file: string, content: string): boolean {\n const dirname = path.dirname(file);\n\n if (!fs.existsSync(dirname)) {\n fs.mkdirSync(dirname, { recursive: true });\n }\n\n const current = readFileContent(file);\n if (current === null || content !== current) {\n fs.writeFileSync(file, content, 'utf8');\n return true;\n }\n\n return false;\n}\n\nfunction removeFile(file: string): boolean {\n if (!fs.existsSync(file)) {\n return false;\n }\n fs.rmSync(file);\n return true;\n}\n\nfunction getTailwindCacheFile(root: string): string {\n return path.resolve(root, TAILWIND_CACHE_FILE);\n}\n\nexport function readTailwindCache(root: string): string[] | null {\n const content = readFileContent(getTailwindCacheFile(root));\n if (!content) {\n return null;\n }\n try {\n return JSON.parse(content);\n } catch {\n return null;\n }\n}\n\nexport function writeTailwindCache(root: string, classes: string[]): { updated: boolean; content: string } {\n const file = getTailwindCacheFile(root);\n const content = JSON.stringify(classes, null, 2);\n const updated = writeFileContent(file, content);\n return { updated, content };\n}\n\nexport function clearTailwindCache(root: string): void {\n writeTailwindCache(root, []);\n}\n\nexport function removeTailwindCache(root: string): void {\n removeFile(getTailwindCacheFile(root));\n}\n\nexport async function updateTailwindCache(root: string, content: string): Promise<void> {\n const classes = (await getTailwindClasses({\n content,\n })) as string[];\n\n writeTailwindCache(root, [...new Set([...(readTailwindCache(root) ?? []), ...classes])]);\n}\n","export const DEFAULT_ENTRIES = ['index.tsx', 'index.ts', 'index.jsx', 'index.js', 'main.tsx', 'main.ts', 'main.jsx', 'main.js'];\n\nexport const DEFAULT_TEMPLATES = ['template.xml', 'theme.xml'];\n","import type { IncomingHttpHeaders, IncomingMessage, OutgoingHttpHeaders } from 'node:http';\n\nexport function escapeHtml(str: string) {\n if (str === '') return '';\n return str.replace(/[&<>\"'`]/g, (ch) => {\n switch (ch) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case \"'\":\n return ''';\n case '`':\n return '`';\n default:\n return ch;\n }\n });\n}\n\nexport function escapeRegex(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function toWebHeaders(httpHeaders: IncomingHttpHeaders | OutgoingHttpHeaders): Headers {\n const headers = new Headers();\n for (const [name, value] of Object.entries(httpHeaders)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(name, item);\n }\n } else {\n headers.set(name, String(value ?? ''));\n }\n }\n return headers;\n}\n\nexport const BLOGGER_PLUGIN_HEAD_COMMENT_REGEX = /(<!--blogger-plugin:head:begin-->)([\\s\\S]*?)(<!--blogger-plugin:head:end-->)/;\n\nexport const BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX =\n /(<b:comment><!--blogger-plugin:head:begin--><\\/b:comment>)([\\s\\S]*?)(<b:comment><!--blogger-plugin:head:end--><\\/b:comment>)/;\n\nexport function replaceBloggerPluginHeadComment(input: string, replacement: string, bcomment = false) {\n if (bcomment) {\n return input.replace(BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX, (_, start: string, _content: string, end: string) => `${start}${replacement}${end}`);\n }\n return input.replace(BLOGGER_PLUGIN_HEAD_COMMENT_REGEX, (_, start: string, _content: string, end: string) => `${start}${replacement}${end}`);\n}\n\nexport function getBloggerPluginHeadComment(input: string, bcomment = false) {\n if (bcomment) {\n return input.match(BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX)?.[2] ?? null;\n }\n return input.match(BLOGGER_PLUGIN_HEAD_COMMENT_REGEX)?.[2] ?? null;\n}\n\nexport function replaceHost(input: string, oldHost: string, newHost: string, newProtocol?: string) {\n return input.replace(\n new RegExp(`(https?:)?(\\\\/\\\\/|\\\\\\\\/\\\\\\\\/)${escapeRegex(oldHost)}`, 'g'),\n (_, protocol, slash) => `${protocol ? (newProtocol ?? protocol) : ''}${slash ?? ''}${newHost}`,\n );\n}\n\nexport function getRequestUrl(req: IncomingMessage): URL | null {\n const xForwardedProtoHeader = req.headers['x-forwarded-proto'];\n const xForwardedHostHeader = req.headers['x-forwarded-host'];\n const hostHeader = req.headers.host;\n\n const protocol = Array.isArray(xForwardedProtoHeader)\n ? xForwardedProtoHeader[0]\n : (xForwardedProtoHeader ?? (req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https' : 'http'));\n const host = Array.isArray(xForwardedHostHeader) ? xForwardedHostHeader[0] : (xForwardedHostHeader ?? hostHeader);\n\n if (host && req.url) {\n return new URL(`${protocol}://${host}${req.url}`);\n }\n\n return null;\n}\n\nexport function isBloggerPath(path: string) {\n return (\n path === '/' ||\n path === '/search' ||\n /^\\/search\\/label(\\/[^/]+)?\\/?$/.test(path) ||\n /^p\\/.+\\.html$/.test(path) ||\n /^\\/\\d{4}\\/\\d{2}(\\/?|\\/[^/\\s]+\\.html)$/.test(path)\n );\n}\n\nconst TAILWIND_PLUGIN_NAMES = new Set(['@tailwindcss/vite:scan']);\n\nexport function isTailwindPlugin(plugin: { name: string }): boolean {\n return TAILWIND_PLUGIN_NAMES.has(plugin.name);\n}\n\nexport function errorHtml(reqUrl: string) {\n return `<!DOCTYPE html>\n<html>\n\n<head>\n <meta charset='UTF-8'/>\n <meta content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=5, user-scalable=yes' name='viewport'/>\n <title>500 Internal Server Error</title>\n <link rel='icon' href='data:,' />\n <style>\n *, ::before, ::after {\n box-sizing: border-box;\n }\n body {\n min-height: 100svh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n margin: 0;\n padding: 20px;\n background-color: #f5f5f5;\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", Segoe UI Symbol, \"Noto Color Emoji\";\n }\n .card {\n padding: 24px;\n background-color: #ffffff;\n border: 1px solid #e5e5e5;\n max-width: 448px;\n border-radius: 14px;\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);\n display: flex;\n flex-direction: column;\n gap: 24px;\n }\n .card-content {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n .card-title {\n font-weight: 600;\n }\n .card-description {\n font-size: 14px;\n opacity: 0.85;\n }\n .card-footer {\n display: flex;\n align-items: center;\n }\n .button {\n display: inline-flex;\n white-space: nowrap;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 8px 16px;\n font-weight: 500;\n background-color: #171717;\n outline: none;\n border: none;\n color: #ffffff;\n border-radius: 8px;\n min-height: 36px;\n }\n .button:hover {\n opacity: 0.9;\n }\n .button svg {\n wiheadersdth: 16px;\n height: 16px;\n flex-shrink: 0;\n }\n .card-footer .button {\n flex-grow: 1;\n }\n </style>\n</head>\n\n<body>\n <div class='card'>\n <div class='card-content'>\n <div class='card-title'>500 Internal Server Error</div>\n <div class='card-description'>Failed to fetch: ${escapeHtml(reqUrl)}</div>\n </div>\n <div class='card-footer'>\n <button class='button' type='button'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-refresh-ccw\" aria-hidden=\"true\"><path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path><path d=\"M3 3v5h5\"></path><path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path><path d=\"M16 16h5v5\"></path></svg>\n Reload\n </button>\n </div>\n </div>\n <script>\n const button = document.getElementsByTagName('button')[0];\n button.addEventListener('click', () => {\n window.location.reload();\n });\n </script>\n</body>\n\n</html>`;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/blogger-plugin/blogger-plugin/packages/blogger-plugin/dist/vite.cjs","../src/vite.ts","../src/cache.ts","../src/constants.ts","../src/utils.ts"],"names":["dirname","_a"],"mappings":"AAAA;ACAA,uGAAoB;AACpB,mHAAsB;AACtB,gCAAyB;AACzB;AAOE;AAAW,4BACN;ADJP;AACA;AERA;AACA;AACA,iDAAmC;AAEnC,IAAM,oBAAA,EAAsB,wBAAA;AAE5B,SAAS,eAAA,CAAgB,IAA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MAAA;AAE8B,MAAA;AACD,MAAA;AACC,MAAA;AACD,MAAA;AAIlB,MAAA;AASI,QAAA;AAGO,QAAA;AAG0E,MAAA;AAMzB,MAAA;AACJ,MAAA;AAEpC,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAStB,EAAA;AAAA;AAAA;AAAA;AAAA;AAKU,EAAA;AAAA;AAAA;AAAA;AAID,EAAA;AAAA;AAAA;AAAA,OAAA;AAK0D,MAAA;AACK,MAAA;AACnF,IAAA;AACc,IAAA;AACsE,MAAA;AACtD,MAAA;AACY,QAAA;AACxC,MAAA;AACF,IAAA;AACwB,IAAA;AACsB,MAAA;AAC9C,IAAA;AAC+B,IAAA;AACe,MAAA;AAC9C,IAAA;AACF,EAAA;AACF;AD2J2F;AACA;AACA","file":"/home/runner/work/blogger-plugin/blogger-plugin/packages/blogger-plugin/dist/vite.cjs","sourcesContent":[null,"import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport {\n type MinimalPluginContextWithoutEnvironment,\n type Plugin,\n type PreviewServer,\n type ResolvedConfig,\n type UserConfig,\n type ViteDevServer,\n version as viteVersion,\n} from 'vite';\nimport { clearTailwindCache, removeTailwindCache, updateTailwindCache } from './cache';\nimport { DEFAULT_MODULES, DEFAULT_TEMPLATES } from './constants';\nimport {\n errorHtml,\n getBloggerPluginHeadComment,\n getRequestUrl,\n isTailwindPlugin,\n replaceBloggerPluginHeadComment,\n replaceHost,\n toWebHeaders,\n} from './utils';\n\nconst viteMajor = Number(viteVersion.split('.')[0]);\nconst bundlerKey = (viteMajor >= 8 ? 'rolldownOptions' : 'rollupOptions') as 'rollupOptions';\n\nclass BloggerPluginContext {\n options: BloggerPluginOptions;\n root: string;\n modules: string[];\n styles: string[];\n template: string;\n name: string;\n proxyBlog: URL;\n viteConfig: ResolvedConfig;\n tailwind: boolean;\n input: string;\n html: string;\n headTags: string[];\n\n constructor(options: BloggerPluginOptions) {\n if (typeof options.template !== 'undefined' && typeof options.template !== 'string') {\n throw new Error(\"Option 'template' must be a string\");\n }\n if (typeof options.modules !== 'undefined' && !Array.isArray(options.modules)) {\n throw new Error(\"Option 'modules' must be an array\");\n }\n if (typeof options.styles !== 'undefined' && !Array.isArray(options.styles)) {\n throw new Error(\"Option 'styles' must be an array\");\n }\n if (typeof options.proxyBlog !== 'string') {\n throw new Error(\"Option 'proxyBlog' must be a string\");\n }\n let proxyBlog: URL;\n try {\n proxyBlog = new URL(options.proxyBlog);\n } catch {\n throw new Error(\"Option 'proxyBlog' must be a valid url\");\n }\n\n this.options = options;\n this.root = process.cwd();\n this.modules = [];\n this.styles = [];\n this.template = undefined as unknown as string;\n this.name = undefined as unknown as string;\n this.proxyBlog = proxyBlog;\n this.viteConfig = undefined as unknown as ResolvedConfig;\n this.tailwind = false;\n this.input = undefined as unknown as string;\n this.headTags = [];\n this.html = undefined as unknown as string;\n }\n\n resolve(config: UserConfig) {\n this.root = config.root ? path.resolve(config.root) : this.root;\n\n if (this.options.modules) {\n for (let i = 0; i < this.options.modules.length; i++) {\n const module = this.options.modules[i];\n const modulePath = path.resolve(this.root, module);\n if (this.modules.includes(modulePath)) {\n continue;\n }\n if (fs.existsSync(modulePath)) {\n this.modules.push(modulePath);\n } else {\n throw new Error(`The path provided at modules[${i}] does not exist: ${modulePath}`);\n }\n }\n } else {\n for (const module of DEFAULT_MODULES) {\n const modulePath = path.resolve(this.root, module);\n if (fs.existsSync(modulePath)) {\n this.modules.push(modulePath);\n break;\n }\n }\n }\n\n if (this.options.styles) {\n for (let i = 0; i < this.options.styles.length; i++) {\n const style = this.options.styles[i];\n const stylePath = path.resolve(this.root, style);\n if (this.styles.includes(stylePath)) {\n continue;\n }\n if (fs.existsSync(stylePath)) {\n this.styles.push(stylePath);\n } else {\n throw new Error(`The path provided at styles[${i}] does not exist: ${stylePath}`);\n }\n }\n }\n\n if (this.options.template) {\n const templatePath = path.resolve(this.root, this.options.template);\n if (fs.existsSync(templatePath)) {\n this.template = templatePath;\n } else {\n throw new Error(`Provided template file does not exist: ${templatePath}`);\n }\n } else {\n for (const file of DEFAULT_TEMPLATES) {\n const fullPath = path.resolve(this.root, file);\n if (fs.existsSync(fullPath)) {\n this.template = fullPath;\n break;\n }\n }\n\n if (!this.template) {\n throw new Error(\n 'No template file found.\\n' +\n `Tried: ${DEFAULT_TEMPLATES.join(', ')}\\n` +\n '👉 Tip: You can pass a custom template as shown:\\n' +\n ' blogger({ template: \"src/my-template.xml\" })',\n );\n }\n }\n\n this.name = path.basename(this.template, path.extname(this.template));\n\n for (const modulePath of this.modules) {\n this.headTags.push(`<script type=\"module\" src=\"/${path.relative(this.root, modulePath).replaceAll('\\\\', '/')}\"></script>`);\n }\n for (const stylePath of this.styles) {\n this.headTags.push(`<link rel=\"stylesheet\" href=\"/${path.relative(this.root, stylePath).replaceAll('\\\\', '/')}\">`);\n }\n\n this.input = `virtual:blogger-plugin/${this.name}.html`;\n this.html = `<!DOCTYPE html>\n<html>\n<head>\n <!--head-->${this.headTags.length > 0 ? `\\n ${this.headTags.join('\\n ')}` : ''}\n</head>\n<body>\n <!--body-->\n</body>\n</html>`;\n }\n}\n\nfunction isViteDevServer(server: ViteDevServer | PreviewServer): server is ViteDevServer {\n return 'hot' in server && 'transformRequest' in server && 'transformIndexHtml' in server;\n}\n\nfunction useServerMiddleware(server: ViteDevServer | PreviewServer, ctx: BloggerPluginContext, _this: MinimalPluginContextWithoutEnvironment) {\n const input = ctx.viteConfig.build[bundlerKey].input;\n const htmlPathnames: string[] = [];\n for (const entry of Array.isArray(input) ? input : typeof input === 'object' ? Object.values(input) : typeof input === 'string' ? [input] : []) {\n if (entry === ctx.input) {\n continue;\n }\n const entryPath = path.resolve(ctx.root, entry);\n if (!entryPath.endsWith('.html')) {\n continue;\n }\n const relativePath = path.relative(ctx.root, entry).replaceAll('\\\\', '/');\n htmlPathnames.push(`/${relativePath}`);\n if (relativePath.endsWith('index.html')) {\n htmlPathnames.push(`/${relativePath.replace(/index\\.html$/, '')}`);\n }\n }\n\n return () => {\n server.httpServer?.once('listening', () => {\n setTimeout(() => {\n _this.info(`Unhandled requests will be proxied to ${ctx.proxyBlog.origin}`);\n }, 0);\n });\n\n server.middlewares.use(async (req, res, next) => {\n const url = getRequestUrl(req);\n\n if (!req.url || !req.originalUrl || !url || htmlPathnames.includes(url.pathname.replace(/\\/+/g, '/'))) {\n next();\n return;\n }\n\n const start = Date.now();\n\n const proxyUrl = new URL(`${ctx.proxyBlog.origin}${req.originalUrl}`);\n\n const viewParam = proxyUrl.searchParams.get('view');\n proxyUrl.searchParams.set('view', `${isViteDevServer(server) ? '-DevServer' : '-PreviewServer'}${viewParam?.startsWith('-') ? viewParam : ''}`);\n\n const proxyRequest = new Request(proxyUrl, {\n method: req.method,\n headers: toWebHeaders(req.headers),\n body: ['GET', 'HEAD'].includes(req.method ?? '') ? undefined : Readable.toWeb(req),\n redirect: 'manual',\n });\n\n const proxyResponse = await fetch(proxyRequest).catch((error) => {\n if (error instanceof Error) {\n _this.warn({\n message: `${error.name}: ${error.message}`,\n cause: error.cause,\n stack: error.stack,\n });\n } else {\n _this.warn('Fetch failed');\n }\n return null;\n });\n\n if (proxyResponse) {\n res.statusCode = proxyResponse.status;\n res.statusMessage = proxyResponse.statusText;\n\n proxyResponse.headers.forEach((value, key) => {\n if (key === 'location') {\n const redirectUrl = new URL(value, proxyUrl);\n if (redirectUrl.host === url.host || redirectUrl.host === proxyUrl.host) {\n redirectUrl.host = url.host;\n redirectUrl.protocol = url.protocol;\n const viewParam = redirectUrl.searchParams.get('view')?.replaceAll('-DevServer', '').replaceAll('-PreviewServer', '');\n if (viewParam) {\n redirectUrl.searchParams.set('view', viewParam);\n } else {\n redirectUrl.searchParams.delete('view');\n }\n res.setHeader('location', redirectUrl.pathname + redirectUrl.search + redirectUrl.hash);\n } else {\n res.setHeader('location', redirectUrl.href);\n }\n } else if (['content-type', 'x-robots-tag', 'date', 'location'].includes(key)) {\n res.setHeader(key, value);\n }\n });\n\n const contentType = proxyResponse.headers.get('content-type');\n\n if (contentType?.startsWith('text/html')) {\n let htmlTemplateContent = await proxyResponse.text();\n\n if (ctx.tailwind && isViteDevServer(server)) {\n await updateTailwindCache(ctx.root, htmlTemplateContent);\n }\n\n htmlTemplateContent = replaceHost(htmlTemplateContent, proxyUrl.host, url.host, url.protocol);\n\n if (isViteDevServer(server)) {\n const template = await server.transformIndexHtml(\n req.url,\n replaceBloggerPluginHeadComment(htmlTemplateContent, ctx.headTags.join('')),\n req.originalUrl,\n );\n\n res.end(template);\n } else {\n const xmlTemplateContent = fs.readFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template.xml'), 'utf8');\n\n const htmlTagsStr = getBloggerPluginHeadComment(xmlTemplateContent, true);\n\n const template = replaceBloggerPluginHeadComment(htmlTemplateContent, htmlTagsStr ?? '');\n\n res.end(template);\n }\n } else if (contentType && /^(text\\/)|(application\\/(.*\\+)?(xml|json))/.test(contentType)) {\n const content = await proxyResponse.text();\n\n res.end(replaceHost(content, proxyUrl.host, url.host, url.protocol));\n } else {\n res.end(new Uint8Array(await proxyResponse.arrayBuffer()));\n }\n } else {\n res.statusCode = 500;\n res.statusMessage = 'Internal Server Error';\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(errorHtml(proxyUrl.href));\n }\n\n const duration = Date.now() - start;\n\n _this.info(`${req.method} ${req.originalUrl} -> ${res.statusCode} ${res.statusMessage} (${duration}ms)`);\n });\n };\n}\n\nexport interface BloggerPluginOptions {\n modules?: string[];\n styles?: string[];\n template?: string;\n proxyBlog: string;\n}\n\nexport default function blogger(userOptions: BloggerPluginOptions): Plugin {\n const ctx = new BloggerPluginContext(userOptions);\n\n return {\n name: 'vite-plugin-blogger',\n config(config) {\n // resolve plugin context\n ctx.resolve(config);\n\n // modify vite config\n config.build ||= {};\n config.build[bundlerKey] ||= {};\n const bundlerOptions = config.build[bundlerKey];\n if (Array.isArray(bundlerOptions.input)) {\n bundlerOptions.input = [...bundlerOptions.input, ctx.input];\n } else if (typeof bundlerOptions.input === 'object' && bundlerOptions.input !== null) {\n bundlerOptions.input[ctx.input] = ctx.input;\n } else {\n bundlerOptions.input = ctx.input;\n }\n\n const originalTemplateXmlContent = fs.readFileSync(ctx.template, 'utf8');\n // remove contents between comments from template\n const modifiedTemplateXmlContent = replaceBloggerPluginHeadComment(replaceBloggerPluginHeadComment(originalTemplateXmlContent, ''), '', true);\n\n fs.writeFileSync(ctx.template, modifiedTemplateXmlContent, 'utf-8');\n },\n configResolved(config) {\n ctx.viteConfig = config;\n ctx.tailwind = config.plugins.flat(Number.POSITIVE_INFINITY).some((plugin) => isTailwindPlugin(plugin));\n\n if (ctx.tailwind) {\n clearTailwindCache(ctx.root);\n\n if (config.command === 'build') {\n updateTailwindCache(ctx.root, fs.readFileSync(ctx.template, 'utf-8'));\n }\n } else {\n removeTailwindCache(ctx.root);\n }\n },\n resolveId(source) {\n if (source === ctx.input) {\n return ctx.input;\n }\n },\n load(id) {\n if (id === ctx.input) {\n return ctx.html;\n }\n },\n writeBundle(_, bundle) {\n if (!(ctx.input in bundle)) {\n return;\n }\n const asset = bundle[ctx.input];\n delete bundle[ctx.input];\n\n if (asset.type !== 'asset' || typeof asset.source !== 'string') {\n return;\n }\n const regex =\n /<!DOCTYPE html>\\s*<html[^>]*>\\s*<head>([\\s\\S]*?)<!--head-->([\\s\\S]*?)<\\/head>\\s*<body>([\\s\\S]*?)<!--body-->([\\s\\S]*?)<\\/body>\\s*<\\/html>/i;\n const match = asset.source.match(regex);\n if (!match) {\n return;\n }\n\n const afterHeadBegin = match[1];\n const beforeHeadEnd = match[2];\n const afterBodyBegin = match[3];\n const beforeBodyEnd = match[4];\n\n const headContent = (afterHeadBegin + beforeHeadEnd)\n // boolean attributes to empty string\n .replace(/\\b(crossorigin|defer|async|disabled|checked)\\b(?!=)/g, (_, $1: string) => `${$1}=\"\"`)\n // convert attributes to single quotes safely\n .replace(/(\\w+)=(\".*?\"|'.*?')/g, (_, $1: string, $2: string) => {\n const v = $2\n // remove quotes\n .slice(1, -1)\n // escape special XML chars\n .replace(/&/g, '&')\n .replace(/'/g, ''')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n return `${$1}='${v}'`;\n })\n // self-close void tags\n .replace(/<(link|meta|img|br|hr|input)([^>]*?)>/gi, (_, $1: string, $2: string) => `<${$1}${$2} />`)\n // remove whitespace between tags\n .replace(/>\\s+</g, '><')\n // trim overall\n .trim();\n\n const originalTemplateXmlContent = fs.readFileSync(ctx.template, 'utf8');\n const modifiedTemplateXmlContent = replaceBloggerPluginHeadComment(originalTemplateXmlContent, headContent, true);\n\n const templateTagsXmlContent = `<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE html>\n<html>\n<head>\n <!--head:afterbegin:begin-->\n\n <!--head:afterbegin:end-->\n\n <!--head:beforeend:begin-->\n ${headContent}\n <!--head:beforeend:end-->\n</head>\n<body>\n <!--body:afterbegin:begin-->\n ${afterBodyBegin.trim()}\n <!--body:afterbegin:end-->\n\n <!--body:beforeend:begin-->\n ${beforeBodyEnd.trim()}\n <!--body:beforeend:end-->\n</body>\n</html>`;\n\n fs.writeFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template.xml'), modifiedTemplateXmlContent);\n fs.writeFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template-tags.xml'), templateTagsXmlContent);\n },\n closeBundle() {\n const htmlDir = path.resolve(ctx.viteConfig.build.outDir, 'virtual:blogger-plugin');\n if (fs.existsSync(htmlDir)) {\n fs.rmSync(htmlDir, { recursive: true });\n }\n },\n configureServer(server) {\n return useServerMiddleware(server, ctx, this);\n },\n configurePreviewServer(server) {\n return useServerMiddleware(server, ctx, this);\n },\n };\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { getTailwindClasses } from 'tailwindcss-iso';\n\nconst TAILWIND_CACHE_FILE = '.tailwind-classes.json';\n\nfunction readFileContent(file: string): string | null {\n if (!fs.existsSync(file)) {\n return null;\n }\n return fs.readFileSync(file, 'utf-8');\n}\n\nfunction writeFileContent(file: string, content: string): boolean {\n const dirname = path.dirname(file);\n\n if (!fs.existsSync(dirname)) {\n fs.mkdirSync(dirname, { recursive: true });\n }\n\n const current = readFileContent(file);\n if (current === null || content !== current) {\n fs.writeFileSync(file, content, 'utf8');\n return true;\n }\n\n return false;\n}\n\nfunction removeFile(file: string): boolean {\n if (!fs.existsSync(file)) {\n return false;\n }\n fs.rmSync(file);\n return true;\n}\n\nfunction getTailwindCacheFile(root: string): string {\n return path.resolve(root, TAILWIND_CACHE_FILE);\n}\n\nexport function readTailwindCache(root: string): string[] | null {\n const content = readFileContent(getTailwindCacheFile(root));\n if (!content) {\n return null;\n }\n try {\n return JSON.parse(content);\n } catch {\n return null;\n }\n}\n\nexport function writeTailwindCache(root: string, classes: string[]): { updated: boolean; content: string } {\n const file = getTailwindCacheFile(root);\n const content = JSON.stringify(classes, null, 2);\n const updated = writeFileContent(file, content);\n return { updated, content };\n}\n\nexport function clearTailwindCache(root: string): void {\n writeTailwindCache(root, []);\n}\n\nexport function removeTailwindCache(root: string): void {\n removeFile(getTailwindCacheFile(root));\n}\n\nexport async function updateTailwindCache(root: string, content: string): Promise<void> {\n const classes = (await getTailwindClasses({\n content,\n })) as string[];\n\n writeTailwindCache(root, [...new Set([...(readTailwindCache(root) ?? []), ...classes])]);\n}\n","export const DEFAULT_MODULES = [\n 'src/index.tsx',\n 'src/index.ts',\n 'src/index.jsx',\n 'src/index.js',\n 'src/main.tsx',\n 'src/main.ts',\n 'src/main.jsx',\n 'src/main.js',\n] as const;\n\nexport const DEFAULT_TEMPLATES = ['index.xml', 'template.xml', 'theme.xml', 'src/index.xml', 'src/template.xml', 'src/theme.xml'] as const;\n","import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'node:http';\nimport type { Connect } from 'vite';\n\nexport function escapeHtml(str: string) {\n if (str === '') return '';\n return str.replace(/[&<>\"'`]/g, (ch) => {\n switch (ch) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case \"'\":\n return ''';\n case '`':\n return '`';\n default:\n return ch;\n }\n });\n}\n\nexport function escapeRegex(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function toWebHeaders(httpHeaders: IncomingHttpHeaders | OutgoingHttpHeaders): Headers {\n const headers = new Headers();\n for (const [name, value] of Object.entries(httpHeaders)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(name, item);\n }\n } else {\n headers.set(name, String(value ?? ''));\n }\n }\n return headers;\n}\n\nexport const BLOGGER_PLUGIN_HEAD_COMMENT_REGEX = /(<!--blogger-plugin:head:begin-->)([\\s\\S]*?)(<!--blogger-plugin:head:end-->)/;\n\nexport const BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX =\n /(<b:comment><!--blogger-plugin:head:begin--><\\/b:comment>)([\\s\\S]*?)(<b:comment><!--blogger-plugin:head:end--><\\/b:comment>)/;\n\nexport function replaceBloggerPluginHeadComment(input: string, replacement: string, bcomment = false) {\n if (bcomment) {\n return input.replace(BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX, (_, start: string, _content: string, end: string) => `${start}${replacement}${end}`);\n }\n return input.replace(BLOGGER_PLUGIN_HEAD_COMMENT_REGEX, (_, start: string, _content: string, end: string) => `${start}${replacement}${end}`);\n}\n\nexport function getBloggerPluginHeadComment(input: string, bcomment = false) {\n if (bcomment) {\n return input.match(BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX)?.[2] ?? null;\n }\n return input.match(BLOGGER_PLUGIN_HEAD_COMMENT_REGEX)?.[2] ?? null;\n}\n\nexport function replaceHost(input: string, oldHost: string, newHost: string, newProtocol?: string) {\n return input.replace(\n new RegExp(`(https?:)?(\\\\/\\\\/|\\\\\\\\/\\\\\\\\/)${escapeRegex(oldHost)}`, 'g'),\n (_, protocol, slash) => `${protocol ? (newProtocol ?? protocol) : ''}${slash ?? ''}${newHost}`,\n );\n}\n\nexport function getRequestUrl(req: Connect.IncomingMessage): URL | null {\n const xForwardedProtoHeader = req.headers['x-forwarded-proto'];\n const xForwardedHostHeader = req.headers['x-forwarded-host'];\n const hostHeader = req.headers.host;\n\n const protocol = Array.isArray(xForwardedProtoHeader)\n ? xForwardedProtoHeader[0]\n : (xForwardedProtoHeader ?? (req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https' : 'http'));\n const host = Array.isArray(xForwardedHostHeader) ? xForwardedHostHeader[0] : (xForwardedHostHeader ?? hostHeader);\n\n if (host && req.originalUrl) {\n return new URL(`${protocol}://${host}${req.originalUrl}`);\n }\n\n return null;\n}\n\nexport function isBloggerPath(path: string) {\n return (\n path === '/' ||\n path === '/search' ||\n /^\\/search\\/label(\\/[^/]+)?\\/?$/.test(path) ||\n /^p\\/.+\\.html$/.test(path) ||\n /^\\/\\d{4}\\/\\d{2}(\\/?|\\/[^/\\s]+\\.html)$/.test(path)\n );\n}\n\nconst TAILWIND_PLUGIN_NAMES = new Set(['@tailwindcss/vite:scan']);\n\nexport function isTailwindPlugin(plugin: { name: string }): boolean {\n return TAILWIND_PLUGIN_NAMES.has(plugin.name);\n}\n\nexport function errorHtml(reqUrl: string) {\n return `<!DOCTYPE html>\n<html>\n\n<head>\n <meta charset='UTF-8'/>\n <meta content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=5, user-scalable=yes' name='viewport'/>\n <title>500 Internal Server Error</title>\n <link rel='icon' href='data:,' />\n <style>\n *, ::before, ::after {\n box-sizing: border-box;\n }\n body {\n min-height: 100svh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n margin: 0;\n padding: 20px;\n background-color: #f5f5f5;\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", Segoe UI Symbol, \"Noto Color Emoji\";\n }\n .card {\n padding: 24px;\n background-color: #ffffff;\n border: 1px solid #e5e5e5;\n max-width: 448px;\n border-radius: 14px;\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);\n display: flex;\n flex-direction: column;\n gap: 24px;\n }\n .card-content {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n .card-title {\n font-weight: 600;\n }\n .card-description {\n font-size: 14px;\n opacity: 0.85;\n }\n .card-footer {\n display: flex;\n align-items: center;\n }\n .button {\n display: inline-flex;\n white-space: nowrap;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 8px 16px;\n font-weight: 500;\n background-color: #171717;\n outline: none;\n border: none;\n color: #ffffff;\n border-radius: 8px;\n min-height: 36px;\n }\n .button:hover {\n opacity: 0.9;\n }\n .button svg {\n wiheadersdth: 16px;\n height: 16px;\n flex-shrink: 0;\n }\n .card-footer .button {\n flex-grow: 1;\n }\n </style>\n</head>\n\n<body>\n <div class='card'>\n <div class='card-content'>\n <div class='card-title'>500 Internal Server Error</div>\n <div class='card-description'>Failed to fetch: ${escapeHtml(reqUrl)}</div>\n </div>\n <div class='card-footer'>\n <button class='button' type='button'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-refresh-ccw\" aria-hidden=\"true\"><path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path><path d=\"M3 3v5h5\"></path><path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path><path d=\"M16 16h5v5\"></path></svg>\n Reload\n </button>\n </div>\n </div>\n <script>\n const button = document.getElementsByTagName('button')[0];\n button.addEventListener('click', () => {\n window.location.reload();\n });\n </script>\n</body>\n\n</html>`;\n}\n"]}
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as fs2 from "fs";
|
|
|
3
3
|
import * as path2 from "path";
|
|
4
4
|
import { Readable } from "stream";
|
|
5
5
|
import {
|
|
6
|
-
version
|
|
6
|
+
version as viteVersion
|
|
7
7
|
} from "vite";
|
|
8
8
|
|
|
9
9
|
// src/cache.ts
|
|
@@ -71,8 +71,17 @@ async function updateTailwindCache(root, content) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// src/constants.ts
|
|
74
|
-
var
|
|
75
|
-
|
|
74
|
+
var DEFAULT_MODULES = [
|
|
75
|
+
"src/index.tsx",
|
|
76
|
+
"src/index.ts",
|
|
77
|
+
"src/index.jsx",
|
|
78
|
+
"src/index.js",
|
|
79
|
+
"src/main.tsx",
|
|
80
|
+
"src/main.ts",
|
|
81
|
+
"src/main.jsx",
|
|
82
|
+
"src/main.js"
|
|
83
|
+
];
|
|
84
|
+
var DEFAULT_TEMPLATES = ["index.xml", "template.xml", "theme.xml", "src/index.xml", "src/template.xml", "src/theme.xml"];
|
|
76
85
|
|
|
77
86
|
// src/utils.ts
|
|
78
87
|
function escapeHtml(str) {
|
|
@@ -139,8 +148,8 @@ function getRequestUrl(req) {
|
|
|
139
148
|
const hostHeader = req.headers.host;
|
|
140
149
|
const protocol = Array.isArray(xForwardedProtoHeader) ? xForwardedProtoHeader[0] : xForwardedProtoHeader != null ? xForwardedProtoHeader : req.socket && "encrypted" in req.socket && req.socket.encrypted ? "https" : "http";
|
|
141
150
|
const host = Array.isArray(xForwardedHostHeader) ? xForwardedHostHeader[0] : xForwardedHostHeader != null ? xForwardedHostHeader : hostHeader;
|
|
142
|
-
if (host && req.
|
|
143
|
-
return new URL(`${protocol}://${host}${req.
|
|
151
|
+
if (host && req.originalUrl) {
|
|
152
|
+
return new URL(`${protocol}://${host}${req.originalUrl}`);
|
|
144
153
|
}
|
|
145
154
|
return null;
|
|
146
155
|
}
|
|
@@ -253,100 +262,143 @@ function errorHtml(reqUrl) {
|
|
|
253
262
|
}
|
|
254
263
|
|
|
255
264
|
// src/vite.ts
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
265
|
+
var viteMajor = Number(viteVersion.split(".")[0]);
|
|
266
|
+
var bundlerKey = viteMajor >= 8 ? "rolldownOptions" : "rollupOptions";
|
|
267
|
+
var BloggerPluginContext = class {
|
|
268
|
+
constructor(options) {
|
|
269
|
+
if (typeof options.template !== "undefined" && typeof options.template !== "string") {
|
|
270
|
+
throw new Error("Option 'template' must be a string");
|
|
271
|
+
}
|
|
272
|
+
if (typeof options.modules !== "undefined" && !Array.isArray(options.modules)) {
|
|
273
|
+
throw new Error("Option 'modules' must be an array");
|
|
274
|
+
}
|
|
275
|
+
if (typeof options.styles !== "undefined" && !Array.isArray(options.styles)) {
|
|
276
|
+
throw new Error("Option 'styles' must be an array");
|
|
277
|
+
}
|
|
278
|
+
if (typeof options.proxyBlog !== "string") {
|
|
279
|
+
throw new Error("Option 'proxyBlog' must be a string");
|
|
280
|
+
}
|
|
281
|
+
let proxyBlog;
|
|
282
|
+
try {
|
|
283
|
+
proxyBlog = new URL(options.proxyBlog);
|
|
284
|
+
} catch (e) {
|
|
285
|
+
throw new Error("Option 'proxyBlog' must be a valid url");
|
|
286
|
+
}
|
|
287
|
+
this.options = options;
|
|
288
|
+
this.root = process.cwd();
|
|
289
|
+
this.modules = [];
|
|
290
|
+
this.styles = [];
|
|
291
|
+
this.template = void 0;
|
|
292
|
+
this.name = void 0;
|
|
293
|
+
this.proxyBlog = proxyBlog;
|
|
294
|
+
this.viteConfig = void 0;
|
|
295
|
+
this.tailwind = false;
|
|
296
|
+
this.input = void 0;
|
|
297
|
+
this.headTags = [];
|
|
298
|
+
this.html = void 0;
|
|
271
299
|
}
|
|
272
|
-
|
|
273
|
-
root
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
html: void 0,
|
|
281
|
-
resolve(config) {
|
|
282
|
-
this.root = config.root ? path2.resolve(config.root) : this.root;
|
|
283
|
-
if (userOptions.entry) {
|
|
284
|
-
const providedPath = path2.resolve(this.root, userOptions.entry);
|
|
285
|
-
if (fs2.existsSync(providedPath)) {
|
|
286
|
-
this.entry = providedPath;
|
|
287
|
-
} else {
|
|
288
|
-
throw new Error(`Provided entry file does not exist: ${providedPath}`);
|
|
300
|
+
resolve(config) {
|
|
301
|
+
this.root = config.root ? path2.resolve(config.root) : this.root;
|
|
302
|
+
if (this.options.modules) {
|
|
303
|
+
for (let i = 0; i < this.options.modules.length; i++) {
|
|
304
|
+
const module = this.options.modules[i];
|
|
305
|
+
const modulePath = path2.resolve(this.root, module);
|
|
306
|
+
if (this.modules.includes(modulePath)) {
|
|
307
|
+
continue;
|
|
289
308
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
this.entry = fullPath;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
309
|
+
if (fs2.existsSync(modulePath)) {
|
|
310
|
+
this.modules.push(modulePath);
|
|
311
|
+
} else {
|
|
312
|
+
throw new Error(`The path provided at modules[${i}] does not exist: ${modulePath}`);
|
|
297
313
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
for (const module of DEFAULT_MODULES) {
|
|
317
|
+
const modulePath = path2.resolve(this.root, module);
|
|
318
|
+
if (fs2.existsSync(modulePath)) {
|
|
319
|
+
this.modules.push(modulePath);
|
|
320
|
+
break;
|
|
305
321
|
}
|
|
306
322
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
323
|
+
}
|
|
324
|
+
if (this.options.styles) {
|
|
325
|
+
for (let i = 0; i < this.options.styles.length; i++) {
|
|
326
|
+
const style = this.options.styles[i];
|
|
327
|
+
const stylePath = path2.resolve(this.root, style);
|
|
328
|
+
if (this.styles.includes(stylePath)) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (fs2.existsSync(stylePath)) {
|
|
332
|
+
this.styles.push(stylePath);
|
|
311
333
|
} else {
|
|
312
|
-
throw new Error(`
|
|
334
|
+
throw new Error(`The path provided at styles[${i}] does not exist: ${stylePath}`);
|
|
313
335
|
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (this.options.template) {
|
|
339
|
+
const templatePath = path2.resolve(this.root, this.options.template);
|
|
340
|
+
if (fs2.existsSync(templatePath)) {
|
|
341
|
+
this.template = templatePath;
|
|
314
342
|
} else {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
343
|
+
throw new Error(`Provided template file does not exist: ${templatePath}`);
|
|
344
|
+
}
|
|
345
|
+
} else {
|
|
346
|
+
for (const file of DEFAULT_TEMPLATES) {
|
|
347
|
+
const fullPath = path2.resolve(this.root, file);
|
|
348
|
+
if (fs2.existsSync(fullPath)) {
|
|
349
|
+
this.template = fullPath;
|
|
350
|
+
break;
|
|
321
351
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
352
|
+
}
|
|
353
|
+
if (!this.template) {
|
|
354
|
+
throw new Error(
|
|
355
|
+
`No template file found.
|
|
356
|
+
Tried: ${DEFAULT_TEMPLATES.join(", ")}
|
|
357
|
+
\u{1F449} Tip: You can pass a custom template as shown:
|
|
327
358
|
blogger({ template: "src/my-template.xml" })`
|
|
328
|
-
|
|
329
|
-
}
|
|
359
|
+
);
|
|
330
360
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
361
|
+
}
|
|
362
|
+
this.name = path2.basename(this.template, path2.extname(this.template));
|
|
363
|
+
for (const modulePath of this.modules) {
|
|
364
|
+
this.headTags.push(`<script type="module" src="/${path2.relative(this.root, modulePath).replaceAll("\\", "/")}"></script>`);
|
|
365
|
+
}
|
|
366
|
+
for (const stylePath of this.styles) {
|
|
367
|
+
this.headTags.push(`<link rel="stylesheet" href="/${path2.relative(this.root, stylePath).replaceAll("\\", "/")}">`);
|
|
368
|
+
}
|
|
369
|
+
this.input = `virtual:blogger-plugin/${this.name}.html`;
|
|
370
|
+
this.html = `<!DOCTYPE html>
|
|
334
371
|
<html>
|
|
335
372
|
<head>
|
|
336
|
-
<!--head
|
|
337
|
-
|
|
373
|
+
<!--head-->${this.headTags.length > 0 ? `
|
|
374
|
+
${this.headTags.join("\n ")}` : ""}
|
|
338
375
|
</head>
|
|
339
376
|
<body>
|
|
340
377
|
<!--body-->
|
|
341
378
|
</body>
|
|
342
379
|
</html>`;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
346
382
|
function isViteDevServer(server) {
|
|
347
383
|
return "hot" in server && "transformRequest" in server && "transformIndexHtml" in server;
|
|
348
384
|
}
|
|
349
385
|
function useServerMiddleware(server, ctx, _this) {
|
|
386
|
+
const input = ctx.viteConfig.build[bundlerKey].input;
|
|
387
|
+
const htmlPathnames = [];
|
|
388
|
+
for (const entry of Array.isArray(input) ? input : typeof input === "object" ? Object.values(input) : typeof input === "string" ? [input] : []) {
|
|
389
|
+
if (entry === ctx.input) {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const entryPath = path2.resolve(ctx.root, entry);
|
|
393
|
+
if (!entryPath.endsWith(".html")) {
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
const relativePath = path2.relative(ctx.root, entry).replaceAll("\\", "/");
|
|
397
|
+
htmlPathnames.push(`/${relativePath}`);
|
|
398
|
+
if (relativePath.endsWith("index.html")) {
|
|
399
|
+
htmlPathnames.push(`/${relativePath.replace(/index\.html$/, "")}`);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
350
402
|
return () => {
|
|
351
403
|
var _a;
|
|
352
404
|
(_a = server.httpServer) == null ? void 0 : _a.once("listening", () => {
|
|
@@ -357,7 +409,7 @@ function useServerMiddleware(server, ctx, _this) {
|
|
|
357
409
|
server.middlewares.use(async (req, res, next) => {
|
|
358
410
|
var _a2;
|
|
359
411
|
const url = getRequestUrl(req);
|
|
360
|
-
if (!req.url || !req.originalUrl || !url) {
|
|
412
|
+
if (!req.url || !req.originalUrl || !url || htmlPathnames.includes(url.pathname.replace(/\/+/g, "/"))) {
|
|
361
413
|
next();
|
|
362
414
|
return;
|
|
363
415
|
}
|
|
@@ -415,11 +467,9 @@ function useServerMiddleware(server, ctx, _this) {
|
|
|
415
467
|
}
|
|
416
468
|
htmlTemplateContent = replaceHost(htmlTemplateContent, proxyUrl.host, url.host, url.protocol);
|
|
417
469
|
if (isViteDevServer(server)) {
|
|
418
|
-
const htmlTags = [];
|
|
419
|
-
htmlTags.push(`<script type='module' src='/${escapeHtml(path2.relative(ctx.root, ctx.entry).replace("\\", "/"))}'></script>`);
|
|
420
470
|
const template = await server.transformIndexHtml(
|
|
421
471
|
req.url,
|
|
422
|
-
replaceBloggerPluginHeadComment(htmlTemplateContent,
|
|
472
|
+
replaceBloggerPluginHeadComment(htmlTemplateContent, ctx.headTags.join("")),
|
|
423
473
|
req.originalUrl
|
|
424
474
|
);
|
|
425
475
|
res.end(template);
|
|
@@ -447,15 +497,13 @@ function useServerMiddleware(server, ctx, _this) {
|
|
|
447
497
|
};
|
|
448
498
|
}
|
|
449
499
|
function blogger(userOptions) {
|
|
450
|
-
const ctx =
|
|
500
|
+
const ctx = new BloggerPluginContext(userOptions);
|
|
451
501
|
return {
|
|
452
502
|
name: "vite-plugin-blogger",
|
|
453
503
|
config(config) {
|
|
454
504
|
var _a;
|
|
455
505
|
ctx.resolve(config);
|
|
456
506
|
config.build || (config.build = {});
|
|
457
|
-
const major = Number(version.split(".")[0]);
|
|
458
|
-
const bundlerKey = major >= 8 ? "rolldownOptions" : "rollupOptions";
|
|
459
507
|
(_a = config.build)[bundlerKey] || (_a[bundlerKey] = {});
|
|
460
508
|
const bundlerOptions = config.build[bundlerKey];
|
|
461
509
|
if (Array.isArray(bundlerOptions.input)) {
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vite.ts","../src/cache.ts","../src/constants.ts","../src/utils.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport {\n type MinimalPluginContextWithoutEnvironment,\n type Plugin,\n type PreviewServer,\n type ResolvedConfig,\n type UserConfig,\n type ViteDevServer,\n version,\n} from 'vite';\nimport { clearTailwindCache, removeTailwindCache, updateTailwindCache } from './cache';\nimport { DEFAULT_ENTRIES, DEFAULT_TEMPLATES } from './constants';\nimport {\n errorHtml,\n escapeHtml,\n getBloggerPluginHeadComment,\n getRequestUrl,\n isTailwindPlugin,\n replaceBloggerPluginHeadComment,\n replaceHost,\n toWebHeaders,\n} from './utils';\n\ninterface BloggerPluginContext {\n root: string;\n entry: string;\n template: string;\n proxyBlog: URL;\n viteConfig: ResolvedConfig;\n tailwind: boolean;\n input: string;\n html: string;\n resolve(root: UserConfig): void;\n}\n\nfunction createBloggerPluginContext(userOptions: BloggerPluginOptions): BloggerPluginContext {\n if (typeof userOptions.entry !== 'undefined' && typeof userOptions.entry !== 'string') {\n throw new Error(\"Option 'entry' must be a string\");\n }\n if (typeof userOptions.template !== 'undefined' && typeof userOptions.template !== 'string') {\n throw new Error(\"Option 'template' must be a string\");\n }\n if (typeof userOptions.proxyBlog !== 'string') {\n throw new Error(\"Option 'proxyBlog' must be a string\");\n }\n let proxyBlog: URL;\n try {\n proxyBlog = new URL(userOptions.proxyBlog);\n } catch {\n throw new Error(\"Option 'proxyBlog' must be a valid url\");\n }\n return {\n root: process.cwd(),\n entry: undefined as unknown as string,\n template: undefined as unknown as string,\n proxyBlog,\n viteConfig: undefined as unknown as ResolvedConfig,\n tailwind: false,\n input: undefined as unknown as string,\n html: undefined as unknown as string,\n resolve(config: UserConfig) {\n this.root = config.root ? path.resolve(config.root) : this.root;\n\n if (userOptions.entry) {\n const providedPath = path.resolve(this.root, userOptions.entry);\n if (fs.existsSync(providedPath)) {\n this.entry = providedPath;\n } else {\n throw new Error(`Provided entry file does not exist: ${providedPath}`);\n }\n } else {\n for (const file of DEFAULT_ENTRIES) {\n const fullPath = path.resolve(this.root, 'src', file);\n if (fs.existsSync(fullPath)) {\n this.entry = fullPath;\n break;\n }\n }\n\n if (!this.entry) {\n throw new Error(\n 'No entry file found in \"src\".\\n' +\n `Tried: ${DEFAULT_ENTRIES.map((c) => path.join('src', c)).join(', ')}\\n` +\n '👉 Tip: You can pass a custom entry like:\\n' +\n ' blogger({ entry: \"src/my-entry.ts\" })',\n );\n }\n }\n\n if (userOptions.template) {\n const providedPath = path.resolve(this.root, userOptions.template);\n if (fs.existsSync(providedPath)) {\n this.template = providedPath;\n } else {\n throw new Error(`Provided template file does not exist: ${providedPath}`);\n }\n } else {\n for (const file of DEFAULT_TEMPLATES) {\n const fullPath = path.resolve(this.root, 'src', file);\n if (fs.existsSync(fullPath)) {\n this.template = fullPath;\n break;\n }\n }\n\n if (!this.template) {\n throw new Error(\n 'No template file found in \"src\".\\n' +\n `Tried: ${DEFAULT_TEMPLATES.map((c) => path.join('src', c)).join(', ')}\\n` +\n '👉 Tip: You can pass a custom template like:\\n' +\n ' blogger({ template: \"src/my-template.xml\" })',\n );\n }\n }\n\n const name = path.basename(this.entry, path.extname(this.entry));\n this.input = `virtual:blogger-plugin/${name}.html`;\n this.html = `<!DOCTYPE html>\n<html>\n<head>\n <!--head-->\n <script type=\"module\" src=\"/${path.relative(this.root, this.entry).replace('\\\\', '/')}\"></script>\n</head>\n<body>\n <!--body-->\n</body>\n</html>`;\n },\n };\n}\n\nfunction isViteDevServer(server: ViteDevServer | PreviewServer): server is ViteDevServer {\n return 'hot' in server && 'transformRequest' in server && 'transformIndexHtml' in server;\n}\n\nfunction useServerMiddleware(server: ViteDevServer | PreviewServer, ctx: BloggerPluginContext, _this: MinimalPluginContextWithoutEnvironment) {\n return () => {\n server.httpServer?.once('listening', () => {\n setTimeout(() => {\n _this.info(`Unhandled requests will be proxied to ${ctx.proxyBlog.origin}`);\n }, 0);\n });\n\n server.middlewares.use(async (req, res, next) => {\n const url = getRequestUrl(req);\n\n if (!req.url || !req.originalUrl || !url) {\n next();\n return;\n }\n\n const start = Date.now();\n\n const proxyUrl = new URL(`${ctx.proxyBlog.origin}${req.originalUrl}`);\n\n const viewParam = proxyUrl.searchParams.get('view');\n proxyUrl.searchParams.set('view', `${isViteDevServer(server) ? '-DevServer' : '-PreviewServer'}${viewParam?.startsWith('-') ? viewParam : ''}`);\n\n const proxyRequest = new Request(proxyUrl, {\n method: req.method,\n headers: toWebHeaders(req.headers),\n body: ['GET', 'HEAD'].includes(req.method ?? '') ? undefined : Readable.toWeb(req),\n redirect: 'manual',\n });\n\n const proxyResponse = await fetch(proxyRequest).catch((error) => {\n if (error instanceof Error) {\n _this.warn({\n message: `${error.name}: ${error.message}`,\n cause: error.cause,\n stack: error.stack,\n });\n } else {\n _this.warn('Fetch failed');\n }\n return null;\n });\n\n if (proxyResponse) {\n res.statusCode = proxyResponse.status;\n res.statusMessage = proxyResponse.statusText;\n\n proxyResponse.headers.forEach((value, key) => {\n if (key === 'location') {\n const redirectUrl = new URL(value, proxyUrl);\n if (redirectUrl.host === url.host || redirectUrl.host === proxyUrl.host) {\n redirectUrl.host = url.host;\n redirectUrl.protocol = url.protocol;\n const viewParam = redirectUrl.searchParams.get('view')?.replaceAll('-DevServer', '').replaceAll('-PreviewServer', '');\n if (viewParam) {\n redirectUrl.searchParams.set('view', viewParam);\n } else {\n redirectUrl.searchParams.delete('view');\n }\n res.setHeader('location', redirectUrl.pathname + redirectUrl.search + redirectUrl.hash);\n } else {\n res.setHeader('location', redirectUrl.href);\n }\n } else if (['content-type', 'x-robots-tag', 'date', 'location'].includes(key)) {\n res.setHeader(key, value);\n }\n });\n\n const contentType = proxyResponse.headers.get('content-type');\n\n if (contentType?.startsWith('text/html')) {\n let htmlTemplateContent = await proxyResponse.text();\n\n if (ctx.tailwind && isViteDevServer(server)) {\n await updateTailwindCache(ctx.root, htmlTemplateContent);\n }\n\n htmlTemplateContent = replaceHost(htmlTemplateContent, proxyUrl.host, url.host, url.protocol);\n\n if (isViteDevServer(server)) {\n const htmlTags: string[] = [];\n\n htmlTags.push(`<script type='module' src='/${escapeHtml(path.relative(ctx.root, ctx.entry).replace('\\\\', '/'))}'></script>`);\n\n const template = await server.transformIndexHtml(\n req.url,\n replaceBloggerPluginHeadComment(htmlTemplateContent, htmlTags.join('')),\n req.originalUrl,\n );\n\n res.end(template);\n } else {\n const xmlTemplateContent = fs.readFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template.xml'), 'utf8');\n\n const htmlTagsStr = getBloggerPluginHeadComment(xmlTemplateContent, true);\n\n const template = replaceBloggerPluginHeadComment(htmlTemplateContent, htmlTagsStr ?? '');\n\n res.end(template);\n }\n } else if (contentType && /^(text\\/)|(application\\/(.*\\+)?(xml|json))/.test(contentType)) {\n const content = await proxyResponse.text();\n\n res.end(replaceHost(content, proxyUrl.host, url.host, url.protocol));\n } else {\n res.end(new Uint8Array(await proxyResponse.arrayBuffer()));\n }\n } else {\n res.statusCode = 500;\n res.statusMessage = 'Internal Server Error';\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(errorHtml(proxyUrl.href));\n }\n\n const duration = Date.now() - start;\n\n _this.info(`${req.method} ${req.originalUrl} -> ${res.statusCode} ${res.statusMessage} (${duration}ms)`);\n });\n };\n}\n\nexport interface BloggerPluginOptions {\n entry?: string;\n template?: string;\n proxyBlog: string;\n}\n\nexport default function blogger(userOptions: BloggerPluginOptions): Plugin {\n const ctx = createBloggerPluginContext(userOptions);\n\n return {\n name: 'vite-plugin-blogger',\n config(config) {\n // resolve plugin context\n ctx.resolve(config);\n\n // modify vite config\n config.build ||= {};\n const major = Number(version.split('.')[0]);\n const bundlerKey = (major >= 8 ? 'rolldownOptions' : 'rollupOptions') as 'rollupOptions';\n config.build[bundlerKey] ||= {};\n const bundlerOptions = config.build[bundlerKey];\n if (Array.isArray(bundlerOptions.input)) {\n bundlerOptions.input = [...bundlerOptions.input, ctx.input];\n } else if (typeof bundlerOptions.input === 'object' && bundlerOptions.input !== null) {\n bundlerOptions.input[ctx.input] = ctx.input;\n } else {\n bundlerOptions.input = ctx.input;\n }\n\n const originalTemplateXmlContent = fs.readFileSync(ctx.template, 'utf8');\n // remove contents between comments from template\n const modifiedTemplateXmlContent = replaceBloggerPluginHeadComment(replaceBloggerPluginHeadComment(originalTemplateXmlContent, ''), '', true);\n\n fs.writeFileSync(ctx.template, modifiedTemplateXmlContent, 'utf-8');\n },\n configResolved(config) {\n ctx.viteConfig = config;\n ctx.tailwind = config.plugins.flat(Number.POSITIVE_INFINITY).some((plugin) => isTailwindPlugin(plugin));\n\n if (ctx.tailwind) {\n clearTailwindCache(ctx.root);\n\n if (config.command === 'build') {\n updateTailwindCache(ctx.root, fs.readFileSync(ctx.template, 'utf-8'));\n }\n } else {\n removeTailwindCache(ctx.root);\n }\n },\n resolveId(source) {\n if (source === ctx.input) {\n return ctx.input;\n }\n },\n load(id) {\n if (id === ctx.input) {\n return ctx.html;\n }\n },\n writeBundle(_, bundle) {\n if (!(ctx.input in bundle)) {\n return;\n }\n const asset = bundle[ctx.input];\n delete bundle[ctx.input];\n\n if (asset.type !== 'asset' || typeof asset.source !== 'string') {\n return;\n }\n const regex =\n /<!DOCTYPE html>\\s*<html[^>]*>\\s*<head>([\\s\\S]*?)<!--head-->([\\s\\S]*?)<\\/head>\\s*<body>([\\s\\S]*?)<!--body-->([\\s\\S]*?)<\\/body>\\s*<\\/html>/i;\n const match = asset.source.match(regex);\n if (!match) {\n return;\n }\n\n const afterHeadBegin = match[1];\n const beforeHeadEnd = match[2];\n const afterBodyBegin = match[3];\n const beforeBodyEnd = match[4];\n\n const headContent = (afterHeadBegin + beforeHeadEnd)\n // boolean attributes to empty string\n .replace(/\\b(crossorigin|defer|async|disabled|checked)\\b(?!=)/g, (_, $1: string) => `${$1}=\"\"`)\n // convert attributes to single quotes safely\n .replace(/(\\w+)=(\".*?\"|'.*?')/g, (_, $1: string, $2: string) => {\n const v = $2\n // remove quotes\n .slice(1, -1)\n // escape special XML chars\n .replace(/&/g, '&')\n .replace(/'/g, ''')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n return `${$1}='${v}'`;\n })\n // self-close void tags\n .replace(/<(link|meta|img|br|hr|input)([^>]*?)>/gi, (_, $1: string, $2: string) => `<${$1}${$2} />`)\n // remove whitespace between tags\n .replace(/>\\s+</g, '><')\n // trim overall\n .trim();\n\n const originalTemplateXmlContent = fs.readFileSync(ctx.template, 'utf8');\n const modifiedTemplateXmlContent = replaceBloggerPluginHeadComment(originalTemplateXmlContent, headContent, true);\n\n const templateTagsXmlContent = `<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE html>\n<html>\n<head>\n <!--head:afterbegin:begin-->\n\n <!--head:afterbegin:end-->\n\n <!--head:beforeend:begin-->\n ${headContent}\n <!--head:beforeend:end-->\n</head>\n<body>\n <!--body:afterbegin:begin-->\n ${afterBodyBegin.trim()}\n <!--body:afterbegin:end-->\n\n <!--body:beforeend:begin-->\n ${beforeBodyEnd.trim()}\n <!--body:beforeend:end-->\n</body>\n</html>`;\n\n fs.writeFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template.xml'), modifiedTemplateXmlContent);\n fs.writeFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template-tags.xml'), templateTagsXmlContent);\n },\n closeBundle() {\n const htmlDir = path.resolve(ctx.viteConfig.build.outDir, 'virtual:blogger-plugin');\n if (fs.existsSync(htmlDir)) {\n fs.rmSync(htmlDir, { recursive: true });\n }\n },\n configureServer(server) {\n return useServerMiddleware(server, ctx, this);\n },\n configurePreviewServer(server) {\n return useServerMiddleware(server, ctx, this);\n },\n };\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { getTailwindClasses } from 'tailwindcss-iso';\n\nconst TAILWIND_CACHE_FILE = '.tailwind-classes.json';\n\nfunction readFileContent(file: string): string | null {\n if (!fs.existsSync(file)) {\n return null;\n }\n return fs.readFileSync(file, 'utf-8');\n}\n\nfunction writeFileContent(file: string, content: string): boolean {\n const dirname = path.dirname(file);\n\n if (!fs.existsSync(dirname)) {\n fs.mkdirSync(dirname, { recursive: true });\n }\n\n const current = readFileContent(file);\n if (current === null || content !== current) {\n fs.writeFileSync(file, content, 'utf8');\n return true;\n }\n\n return false;\n}\n\nfunction removeFile(file: string): boolean {\n if (!fs.existsSync(file)) {\n return false;\n }\n fs.rmSync(file);\n return true;\n}\n\nfunction getTailwindCacheFile(root: string): string {\n return path.resolve(root, TAILWIND_CACHE_FILE);\n}\n\nexport function readTailwindCache(root: string): string[] | null {\n const content = readFileContent(getTailwindCacheFile(root));\n if (!content) {\n return null;\n }\n try {\n return JSON.parse(content);\n } catch {\n return null;\n }\n}\n\nexport function writeTailwindCache(root: string, classes: string[]): { updated: boolean; content: string } {\n const file = getTailwindCacheFile(root);\n const content = JSON.stringify(classes, null, 2);\n const updated = writeFileContent(file, content);\n return { updated, content };\n}\n\nexport function clearTailwindCache(root: string): void {\n writeTailwindCache(root, []);\n}\n\nexport function removeTailwindCache(root: string): void {\n removeFile(getTailwindCacheFile(root));\n}\n\nexport async function updateTailwindCache(root: string, content: string): Promise<void> {\n const classes = (await getTailwindClasses({\n content,\n })) as string[];\n\n writeTailwindCache(root, [...new Set([...(readTailwindCache(root) ?? []), ...classes])]);\n}\n","export const DEFAULT_ENTRIES = ['index.tsx', 'index.ts', 'index.jsx', 'index.js', 'main.tsx', 'main.ts', 'main.jsx', 'main.js'];\n\nexport const DEFAULT_TEMPLATES = ['template.xml', 'theme.xml'];\n","import type { IncomingHttpHeaders, IncomingMessage, OutgoingHttpHeaders } from 'node:http';\n\nexport function escapeHtml(str: string) {\n if (str === '') return '';\n return str.replace(/[&<>\"'`]/g, (ch) => {\n switch (ch) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case \"'\":\n return ''';\n case '`':\n return '`';\n default:\n return ch;\n }\n });\n}\n\nexport function escapeRegex(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function toWebHeaders(httpHeaders: IncomingHttpHeaders | OutgoingHttpHeaders): Headers {\n const headers = new Headers();\n for (const [name, value] of Object.entries(httpHeaders)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(name, item);\n }\n } else {\n headers.set(name, String(value ?? ''));\n }\n }\n return headers;\n}\n\nexport const BLOGGER_PLUGIN_HEAD_COMMENT_REGEX = /(<!--blogger-plugin:head:begin-->)([\\s\\S]*?)(<!--blogger-plugin:head:end-->)/;\n\nexport const BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX =\n /(<b:comment><!--blogger-plugin:head:begin--><\\/b:comment>)([\\s\\S]*?)(<b:comment><!--blogger-plugin:head:end--><\\/b:comment>)/;\n\nexport function replaceBloggerPluginHeadComment(input: string, replacement: string, bcomment = false) {\n if (bcomment) {\n return input.replace(BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX, (_, start: string, _content: string, end: string) => `${start}${replacement}${end}`);\n }\n return input.replace(BLOGGER_PLUGIN_HEAD_COMMENT_REGEX, (_, start: string, _content: string, end: string) => `${start}${replacement}${end}`);\n}\n\nexport function getBloggerPluginHeadComment(input: string, bcomment = false) {\n if (bcomment) {\n return input.match(BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX)?.[2] ?? null;\n }\n return input.match(BLOGGER_PLUGIN_HEAD_COMMENT_REGEX)?.[2] ?? null;\n}\n\nexport function replaceHost(input: string, oldHost: string, newHost: string, newProtocol?: string) {\n return input.replace(\n new RegExp(`(https?:)?(\\\\/\\\\/|\\\\\\\\/\\\\\\\\/)${escapeRegex(oldHost)}`, 'g'),\n (_, protocol, slash) => `${protocol ? (newProtocol ?? protocol) : ''}${slash ?? ''}${newHost}`,\n );\n}\n\nexport function getRequestUrl(req: IncomingMessage): URL | null {\n const xForwardedProtoHeader = req.headers['x-forwarded-proto'];\n const xForwardedHostHeader = req.headers['x-forwarded-host'];\n const hostHeader = req.headers.host;\n\n const protocol = Array.isArray(xForwardedProtoHeader)\n ? xForwardedProtoHeader[0]\n : (xForwardedProtoHeader ?? (req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https' : 'http'));\n const host = Array.isArray(xForwardedHostHeader) ? xForwardedHostHeader[0] : (xForwardedHostHeader ?? hostHeader);\n\n if (host && req.url) {\n return new URL(`${protocol}://${host}${req.url}`);\n }\n\n return null;\n}\n\nexport function isBloggerPath(path: string) {\n return (\n path === '/' ||\n path === '/search' ||\n /^\\/search\\/label(\\/[^/]+)?\\/?$/.test(path) ||\n /^p\\/.+\\.html$/.test(path) ||\n /^\\/\\d{4}\\/\\d{2}(\\/?|\\/[^/\\s]+\\.html)$/.test(path)\n );\n}\n\nconst TAILWIND_PLUGIN_NAMES = new Set(['@tailwindcss/vite:scan']);\n\nexport function isTailwindPlugin(plugin: { name: string }): boolean {\n return TAILWIND_PLUGIN_NAMES.has(plugin.name);\n}\n\nexport function errorHtml(reqUrl: string) {\n return `<!DOCTYPE html>\n<html>\n\n<head>\n <meta charset='UTF-8'/>\n <meta content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=5, user-scalable=yes' name='viewport'/>\n <title>500 Internal Server Error</title>\n <link rel='icon' href='data:,' />\n <style>\n *, ::before, ::after {\n box-sizing: border-box;\n }\n body {\n min-height: 100svh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n margin: 0;\n padding: 20px;\n background-color: #f5f5f5;\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", Segoe UI Symbol, \"Noto Color Emoji\";\n }\n .card {\n padding: 24px;\n background-color: #ffffff;\n border: 1px solid #e5e5e5;\n max-width: 448px;\n border-radius: 14px;\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);\n display: flex;\n flex-direction: column;\n gap: 24px;\n }\n .card-content {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n .card-title {\n font-weight: 600;\n }\n .card-description {\n font-size: 14px;\n opacity: 0.85;\n }\n .card-footer {\n display: flex;\n align-items: center;\n }\n .button {\n display: inline-flex;\n white-space: nowrap;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 8px 16px;\n font-weight: 500;\n background-color: #171717;\n outline: none;\n border: none;\n color: #ffffff;\n border-radius: 8px;\n min-height: 36px;\n }\n .button:hover {\n opacity: 0.9;\n }\n .button svg {\n wiheadersdth: 16px;\n height: 16px;\n flex-shrink: 0;\n }\n .card-footer .button {\n flex-grow: 1;\n }\n </style>\n</head>\n\n<body>\n <div class='card'>\n <div class='card-content'>\n <div class='card-title'>500 Internal Server Error</div>\n <div class='card-description'>Failed to fetch: ${escapeHtml(reqUrl)}</div>\n </div>\n <div class='card-footer'>\n <button class='button' type='button'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-refresh-ccw\" aria-hidden=\"true\"><path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path><path d=\"M3 3v5h5\"></path><path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path><path d=\"M16 16h5v5\"></path></svg>\n Reload\n </button>\n </div>\n </div>\n <script>\n const button = document.getElementsByTagName('button')[0];\n button.addEventListener('click', () => {\n window.location.reload();\n });\n </script>\n</body>\n\n</html>`;\n}\n"],"mappings":";AAAA,YAAYA,SAAQ;AACpB,YAAYC,WAAU;AACtB,SAAS,gBAAgB;AACzB;AAAA,EAOE;AAAA,OACK;;;ACXP,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,0BAA0B;AAEnC,IAAM,sBAAsB;AAE5B,SAAS,gBAAgB,MAA6B;AACpD,MAAI,CAAI,cAAW,IAAI,GAAG;AACxB,WAAO;AAAA,EACT;AACA,SAAU,gBAAa,MAAM,OAAO;AACtC;AAEA,SAAS,iBAAiB,MAAc,SAA0B;AAChE,QAAMC,WAAe,aAAQ,IAAI;AAEjC,MAAI,CAAI,cAAWA,QAAO,GAAG;AAC3B,IAAG,aAAUA,UAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EAC3C;AAEA,QAAM,UAAU,gBAAgB,IAAI;AACpC,MAAI,YAAY,QAAQ,YAAY,SAAS;AAC3C,IAAG,iBAAc,MAAM,SAAS,MAAM;AACtC,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEA,SAAS,WAAW,MAAuB;AACzC,MAAI,CAAI,cAAW,IAAI,GAAG;AACxB,WAAO;AAAA,EACT;AACA,EAAG,UAAO,IAAI;AACd,SAAO;AACT;AAEA,SAAS,qBAAqB,MAAsB;AAClD,SAAY,aAAQ,MAAM,mBAAmB;AAC/C;AAEO,SAAS,kBAAkB,MAA+B;AAC/D,QAAM,UAAU,gBAAgB,qBAAqB,IAAI,CAAC;AAC1D,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AACA,MAAI;AACF,WAAO,KAAK,MAAM,OAAO;AAAA,EAC3B,SAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,mBAAmB,MAAc,SAA0D;AACzG,QAAM,OAAO,qBAAqB,IAAI;AACtC,QAAM,UAAU,KAAK,UAAU,SAAS,MAAM,CAAC;AAC/C,QAAM,UAAU,iBAA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,QAAQ,MAAM,MAAM;AACvB,eAAO,GAAG,EAAE,KAAK,CAAC;AAAA,MACpB,CAAC,EAEA,QAAQ,2CAA2C,CAACA,IAAG,IAAY,OAAe,IAAI,EAAE,GAAG,EAAE,KAAK,EAElG,QAAQ,UAAU,IAAI,EAEtB,KAAK;AAER,YAAM,6BAAgC,iBAAa,IAAI,UAAU,MAAM;AACvE,YAAM,6BAA6B,gCAAgC,4BAA4B,aAAa,IAAI;AAEhH,YAAM,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASjC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,IAKX,eAAe,KAAK,CAAC;AAAA;AAAA;AAAA;AAAA,IAIrB,cAAc,KAAK,CAAC;AAAA;AAAA;AAAA;AAKlB,MAAG,kBAAmB,cAAQ,IAAI,WAAW,MAAM,QAAQ,cAAc,GAAG,0BAA0B;AACtG,MAAG,kBAAmB,cAAQ,IAAI,WAAW,MAAM,QAAQ,mBAAmB,GAAG,sBAAsB;AAAA,IACzG;AAAA,IACA,cAAc;AACZ,YAAM,UAAe,cAAQ,IAAI,WAAW,MAAM,QAAQ,wBAAwB;AAClF,UAAO,eAAW,OAAO,GAAG;AAC1B,QAAG,WAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,MACxC;AAAA,IACF;AAAA,IACA,gBAAgB,QAAQ;AACtB,aAAO,oBAAoB,QAAQ,KAAK,IAAI;AAAA,IAC9C;AAAA,IACA,uBAAuB,QAAQ;AAC7B,aAAO,oBAAoB,QAAQ,KAAK,IAAI;AAAA,IAC9C;AAAA,EACF;AACF;","names":["fs","path","dirname","_a","viewParam","_"]}
|
|
1
|
+
{"version":3,"sources":["../src/vite.ts","../src/cache.ts","../src/constants.ts","../src/utils.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport {\n type MinimalPluginContextWithoutEnvironment,\n type Plugin,\n type PreviewServer,\n type ResolvedConfig,\n type UserConfig,\n type ViteDevServer,\n version as viteVersion,\n} from 'vite';\nimport { clearTailwindCache, removeTailwindCache, updateTailwindCache } from './cache';\nimport { DEFAULT_MODULES, DEFAULT_TEMPLATES } from './constants';\nimport {\n errorHtml,\n getBloggerPluginHeadComment,\n getRequestUrl,\n isTailwindPlugin,\n replaceBloggerPluginHeadComment,\n replaceHost,\n toWebHeaders,\n} from './utils';\n\nconst viteMajor = Number(viteVersion.split('.')[0]);\nconst bundlerKey = (viteMajor >= 8 ? 'rolldownOptions' : 'rollupOptions') as 'rollupOptions';\n\nclass BloggerPluginContext {\n options: BloggerPluginOptions;\n root: string;\n modules: string[];\n styles: string[];\n template: string;\n name: string;\n proxyBlog: URL;\n viteConfig: ResolvedConfig;\n tailwind: boolean;\n input: string;\n html: string;\n headTags: string[];\n\n constructor(options: BloggerPluginOptions) {\n if (typeof options.template !== 'undefined' && typeof options.template !== 'string') {\n throw new Error(\"Option 'template' must be a string\");\n }\n if (typeof options.modules !== 'undefined' && !Array.isArray(options.modules)) {\n throw new Error(\"Option 'modules' must be an array\");\n }\n if (typeof options.styles !== 'undefined' && !Array.isArray(options.styles)) {\n throw new Error(\"Option 'styles' must be an array\");\n }\n if (typeof options.proxyBlog !== 'string') {\n throw new Error(\"Option 'proxyBlog' must be a string\");\n }\n let proxyBlog: URL;\n try {\n proxyBlog = new URL(options.proxyBlog);\n } catch {\n throw new Error(\"Option 'proxyBlog' must be a valid url\");\n }\n\n this.options = options;\n this.root = process.cwd();\n this.modules = [];\n this.styles = [];\n this.template = undefined as unknown as string;\n this.name = undefined as unknown as string;\n this.proxyBlog = proxyBlog;\n this.viteConfig = undefined as unknown as ResolvedConfig;\n this.tailwind = false;\n this.input = undefined as unknown as string;\n this.headTags = [];\n this.html = undefined as unknown as string;\n }\n\n resolve(config: UserConfig) {\n this.root = config.root ? path.resolve(config.root) : this.root;\n\n if (this.options.modules) {\n for (let i = 0; i < this.options.modules.length; i++) {\n const module = this.options.modules[i];\n const modulePath = path.resolve(this.root, module);\n if (this.modules.includes(modulePath)) {\n continue;\n }\n if (fs.existsSync(modulePath)) {\n this.modules.push(modulePath);\n } else {\n throw new Error(`The path provided at modules[${i}] does not exist: ${modulePath}`);\n }\n }\n } else {\n for (const module of DEFAULT_MODULES) {\n const modulePath = path.resolve(this.root, module);\n if (fs.existsSync(modulePath)) {\n this.modules.push(modulePath);\n break;\n }\n }\n }\n\n if (this.options.styles) {\n for (let i = 0; i < this.options.styles.length; i++) {\n const style = this.options.styles[i];\n const stylePath = path.resolve(this.root, style);\n if (this.styles.includes(stylePath)) {\n continue;\n }\n if (fs.existsSync(stylePath)) {\n this.styles.push(stylePath);\n } else {\n throw new Error(`The path provided at styles[${i}] does not exist: ${stylePath}`);\n }\n }\n }\n\n if (this.options.template) {\n const templatePath = path.resolve(this.root, this.options.template);\n if (fs.existsSync(templatePath)) {\n this.template = templatePath;\n } else {\n throw new Error(`Provided template file does not exist: ${templatePath}`);\n }\n } else {\n for (const file of DEFAULT_TEMPLATES) {\n const fullPath = path.resolve(this.root, file);\n if (fs.existsSync(fullPath)) {\n this.template = fullPath;\n break;\n }\n }\n\n if (!this.template) {\n throw new Error(\n 'No template file found.\\n' +\n `Tried: ${DEFAULT_TEMPLATES.join(', ')}\\n` +\n '👉 Tip: You can pass a custom template as shown:\\n' +\n ' blogger({ template: \"src/my-template.xml\" })',\n );\n }\n }\n\n this.name = path.basename(this.template, path.extname(this.template));\n\n for (const modulePath of this.modules) {\n this.headTags.push(`<script type=\"module\" src=\"/${path.relative(this.root, modulePath).replaceAll('\\\\', '/')}\"></script>`);\n }\n for (const stylePath of this.styles) {\n this.headTags.push(`<link rel=\"stylesheet\" href=\"/${path.relative(this.root, stylePath).replaceAll('\\\\', '/')}\">`);\n }\n\n this.input = `virtual:blogger-plugin/${this.name}.html`;\n this.html = `<!DOCTYPE html>\n<html>\n<head>\n <!--head-->${this.headTags.length > 0 ? `\\n ${this.headTags.join('\\n ')}` : ''}\n</head>\n<body>\n <!--body-->\n</body>\n</html>`;\n }\n}\n\nfunction isViteDevServer(server: ViteDevServer | PreviewServer): server is ViteDevServer {\n return 'hot' in server && 'transformRequest' in server && 'transformIndexHtml' in server;\n}\n\nfunction useServerMiddleware(server: ViteDevServer | PreviewServer, ctx: BloggerPluginContext, _this: MinimalPluginContextWithoutEnvironment) {\n const input = ctx.viteConfig.build[bundlerKey].input;\n const htmlPathnames: string[] = [];\n for (const entry of Array.isArray(input) ? input : typeof input === 'object' ? Object.values(input) : typeof input === 'string' ? [input] : []) {\n if (entry === ctx.input) {\n continue;\n }\n const entryPath = path.resolve(ctx.root, entry);\n if (!entryPath.endsWith('.html')) {\n continue;\n }\n const relativePath = path.relative(ctx.root, entry).replaceAll('\\\\', '/');\n htmlPathnames.push(`/${relativePath}`);\n if (relativePath.endsWith('index.html')) {\n htmlPathnames.push(`/${relativePath.replace(/index\\.html$/, '')}`);\n }\n }\n\n return () => {\n server.httpServer?.once('listening', () => {\n setTimeout(() => {\n _this.info(`Unhandled requests will be proxied to ${ctx.proxyBlog.origin}`);\n }, 0);\n });\n\n server.middlewares.use(async (req, res, next) => {\n const url = getRequestUrl(req);\n\n if (!req.url || !req.originalUrl || !url || htmlPathnames.includes(url.pathname.replace(/\\/+/g, '/'))) {\n next();\n return;\n }\n\n const start = Date.now();\n\n const proxyUrl = new URL(`${ctx.proxyBlog.origin}${req.originalUrl}`);\n\n const viewParam = proxyUrl.searchParams.get('view');\n proxyUrl.searchParams.set('view', `${isViteDevServer(server) ? '-DevServer' : '-PreviewServer'}${viewParam?.startsWith('-') ? viewParam : ''}`);\n\n const proxyRequest = new Request(proxyUrl, {\n method: req.method,\n headers: toWebHeaders(req.headers),\n body: ['GET', 'HEAD'].includes(req.method ?? '') ? undefined : Readable.toWeb(req),\n redirect: 'manual',\n });\n\n const proxyResponse = await fetch(proxyRequest).catch((error) => {\n if (error instanceof Error) {\n _this.warn({\n message: `${error.name}: ${error.message}`,\n cause: error.cause,\n stack: error.stack,\n });\n } else {\n _this.warn('Fetch failed');\n }\n return null;\n });\n\n if (proxyResponse) {\n res.statusCode = proxyResponse.status;\n res.statusMessage = proxyResponse.statusText;\n\n proxyResponse.headers.forEach((value, key) => {\n if (key === 'location') {\n const redirectUrl = new URL(value, proxyUrl);\n if (redirectUrl.host === url.host || redirectUrl.host === proxyUrl.host) {\n redirectUrl.host = url.host;\n redirectUrl.protocol = url.protocol;\n const viewParam = redirectUrl.searchParams.get('view')?.replaceAll('-DevServer', '').replaceAll('-PreviewServer', '');\n if (viewParam) {\n redirectUrl.searchParams.set('view', viewParam);\n } else {\n redirectUrl.searchParams.delete('view');\n }\n res.setHeader('location', redirectUrl.pathname + redirectUrl.search + redirectUrl.hash);\n } else {\n res.setHeader('location', redirectUrl.href);\n }\n } else if (['content-type', 'x-robots-tag', 'date', 'location'].includes(key)) {\n res.setHeader(key, value);\n }\n });\n\n const contentType = proxyResponse.headers.get('content-type');\n\n if (contentType?.startsWith('text/html')) {\n let htmlTemplateContent = await proxyResponse.text();\n\n if (ctx.tailwind && isViteDevServer(server)) {\n await updateTailwindCache(ctx.root, htmlTemplateContent);\n }\n\n htmlTemplateContent = replaceHost(htmlTemplateContent, proxyUrl.host, url.host, url.protocol);\n\n if (isViteDevServer(server)) {\n const template = await server.transformIndexHtml(\n req.url,\n replaceBloggerPluginHeadComment(htmlTemplateContent, ctx.headTags.join('')),\n req.originalUrl,\n );\n\n res.end(template);\n } else {\n const xmlTemplateContent = fs.readFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template.xml'), 'utf8');\n\n const htmlTagsStr = getBloggerPluginHeadComment(xmlTemplateContent, true);\n\n const template = replaceBloggerPluginHeadComment(htmlTemplateContent, htmlTagsStr ?? '');\n\n res.end(template);\n }\n } else if (contentType && /^(text\\/)|(application\\/(.*\\+)?(xml|json))/.test(contentType)) {\n const content = await proxyResponse.text();\n\n res.end(replaceHost(content, proxyUrl.host, url.host, url.protocol));\n } else {\n res.end(new Uint8Array(await proxyResponse.arrayBuffer()));\n }\n } else {\n res.statusCode = 500;\n res.statusMessage = 'Internal Server Error';\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(errorHtml(proxyUrl.href));\n }\n\n const duration = Date.now() - start;\n\n _this.info(`${req.method} ${req.originalUrl} -> ${res.statusCode} ${res.statusMessage} (${duration}ms)`);\n });\n };\n}\n\nexport interface BloggerPluginOptions {\n modules?: string[];\n styles?: string[];\n template?: string;\n proxyBlog: string;\n}\n\nexport default function blogger(userOptions: BloggerPluginOptions): Plugin {\n const ctx = new BloggerPluginContext(userOptions);\n\n return {\n name: 'vite-plugin-blogger',\n config(config) {\n // resolve plugin context\n ctx.resolve(config);\n\n // modify vite config\n config.build ||= {};\n config.build[bundlerKey] ||= {};\n const bundlerOptions = config.build[bundlerKey];\n if (Array.isArray(bundlerOptions.input)) {\n bundlerOptions.input = [...bundlerOptions.input, ctx.input];\n } else if (typeof bundlerOptions.input === 'object' && bundlerOptions.input !== null) {\n bundlerOptions.input[ctx.input] = ctx.input;\n } else {\n bundlerOptions.input = ctx.input;\n }\n\n const originalTemplateXmlContent = fs.readFileSync(ctx.template, 'utf8');\n // remove contents between comments from template\n const modifiedTemplateXmlContent = replaceBloggerPluginHeadComment(replaceBloggerPluginHeadComment(originalTemplateXmlContent, ''), '', true);\n\n fs.writeFileSync(ctx.template, modifiedTemplateXmlContent, 'utf-8');\n },\n configResolved(config) {\n ctx.viteConfig = config;\n ctx.tailwind = config.plugins.flat(Number.POSITIVE_INFINITY).some((plugin) => isTailwindPlugin(plugin));\n\n if (ctx.tailwind) {\n clearTailwindCache(ctx.root);\n\n if (config.command === 'build') {\n updateTailwindCache(ctx.root, fs.readFileSync(ctx.template, 'utf-8'));\n }\n } else {\n removeTailwindCache(ctx.root);\n }\n },\n resolveId(source) {\n if (source === ctx.input) {\n return ctx.input;\n }\n },\n load(id) {\n if (id === ctx.input) {\n return ctx.html;\n }\n },\n writeBundle(_, bundle) {\n if (!(ctx.input in bundle)) {\n return;\n }\n const asset = bundle[ctx.input];\n delete bundle[ctx.input];\n\n if (asset.type !== 'asset' || typeof asset.source !== 'string') {\n return;\n }\n const regex =\n /<!DOCTYPE html>\\s*<html[^>]*>\\s*<head>([\\s\\S]*?)<!--head-->([\\s\\S]*?)<\\/head>\\s*<body>([\\s\\S]*?)<!--body-->([\\s\\S]*?)<\\/body>\\s*<\\/html>/i;\n const match = asset.source.match(regex);\n if (!match) {\n return;\n }\n\n const afterHeadBegin = match[1];\n const beforeHeadEnd = match[2];\n const afterBodyBegin = match[3];\n const beforeBodyEnd = match[4];\n\n const headContent = (afterHeadBegin + beforeHeadEnd)\n // boolean attributes to empty string\n .replace(/\\b(crossorigin|defer|async|disabled|checked)\\b(?!=)/g, (_, $1: string) => `${$1}=\"\"`)\n // convert attributes to single quotes safely\n .replace(/(\\w+)=(\".*?\"|'.*?')/g, (_, $1: string, $2: string) => {\n const v = $2\n // remove quotes\n .slice(1, -1)\n // escape special XML chars\n .replace(/&/g, '&')\n .replace(/'/g, ''')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n return `${$1}='${v}'`;\n })\n // self-close void tags\n .replace(/<(link|meta|img|br|hr|input)([^>]*?)>/gi, (_, $1: string, $2: string) => `<${$1}${$2} />`)\n // remove whitespace between tags\n .replace(/>\\s+</g, '><')\n // trim overall\n .trim();\n\n const originalTemplateXmlContent = fs.readFileSync(ctx.template, 'utf8');\n const modifiedTemplateXmlContent = replaceBloggerPluginHeadComment(originalTemplateXmlContent, headContent, true);\n\n const templateTagsXmlContent = `<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE html>\n<html>\n<head>\n <!--head:afterbegin:begin-->\n\n <!--head:afterbegin:end-->\n\n <!--head:beforeend:begin-->\n ${headContent}\n <!--head:beforeend:end-->\n</head>\n<body>\n <!--body:afterbegin:begin-->\n ${afterBodyBegin.trim()}\n <!--body:afterbegin:end-->\n\n <!--body:beforeend:begin-->\n ${beforeBodyEnd.trim()}\n <!--body:beforeend:end-->\n</body>\n</html>`;\n\n fs.writeFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template.xml'), modifiedTemplateXmlContent);\n fs.writeFileSync(path.resolve(ctx.viteConfig.build.outDir, 'template-tags.xml'), templateTagsXmlContent);\n },\n closeBundle() {\n const htmlDir = path.resolve(ctx.viteConfig.build.outDir, 'virtual:blogger-plugin');\n if (fs.existsSync(htmlDir)) {\n fs.rmSync(htmlDir, { recursive: true });\n }\n },\n configureServer(server) {\n return useServerMiddleware(server, ctx, this);\n },\n configurePreviewServer(server) {\n return useServerMiddleware(server, ctx, this);\n },\n };\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { getTailwindClasses } from 'tailwindcss-iso';\n\nconst TAILWIND_CACHE_FILE = '.tailwind-classes.json';\n\nfunction readFileContent(file: string): string | null {\n if (!fs.existsSync(file)) {\n return null;\n }\n return fs.readFileSync(file, 'utf-8');\n}\n\nfunction writeFileContent(file: string, content: string): boolean {\n const dirname = path.dirname(file);\n\n if (!fs.existsSync(dirname)) {\n fs.mkdirSync(dirname, { recursive: true });\n }\n\n const current = readFileContent(file);\n if (current === null || content !== current) {\n fs.writeFileSync(file, content, 'utf8');\n return true;\n }\n\n return false;\n}\n\nfunction removeFile(file: string): boolean {\n if (!fs.existsSync(file)) {\n return false;\n }\n fs.rmSync(file);\n return true;\n}\n\nfunction getTailwindCacheFile(root: string): string {\n return path.resolve(root, TAILWIND_CACHE_FILE);\n}\n\nexport function readTailwindCache(root: string): string[] | null {\n const content = readFileContent(getTailwindCacheFile(root));\n if (!content) {\n return null;\n }\n try {\n return JSON.parse(content);\n } catch {\n return null;\n }\n}\n\nexport function writeTailwindCache(root: string, classes: string[]): { updated: boolean; content: string } {\n const file = getTailwindCacheFile(root);\n const content = JSON.stringify(classes, null, 2);\n const updated = writeFileContent(file, content);\n return { updated, content };\n}\n\nexport function clearTailwindCache(root: string): void {\n writeTailwindCache(root, []);\n}\n\nexport function removeTailwindCache(root: string): void {\n removeFile(getTailwindCacheFile(root));\n}\n\nexport async function updateTailwindCache(root: string, content: string): Promise<void> {\n const classes = (await getTailwindClasses({\n content,\n })) as string[];\n\n writeTailwindCache(root, [...new Set([...(readTailwindCache(root) ?? []), ...classes])]);\n}\n","export const DEFAULT_MODULES = [\n 'src/index.tsx',\n 'src/index.ts',\n 'src/index.jsx',\n 'src/index.js',\n 'src/main.tsx',\n 'src/main.ts',\n 'src/main.jsx',\n 'src/main.js',\n] as const;\n\nexport const DEFAULT_TEMPLATES = ['index.xml', 'template.xml', 'theme.xml', 'src/index.xml', 'src/template.xml', 'src/theme.xml'] as const;\n","import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'node:http';\nimport type { Connect } from 'vite';\n\nexport function escapeHtml(str: string) {\n if (str === '') return '';\n return str.replace(/[&<>\"'`]/g, (ch) => {\n switch (ch) {\n case '&':\n return '&';\n case '<':\n return '<';\n case '>':\n return '>';\n case '\"':\n return '"';\n case \"'\":\n return ''';\n case '`':\n return '`';\n default:\n return ch;\n }\n });\n}\n\nexport function escapeRegex(str: string) {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function toWebHeaders(httpHeaders: IncomingHttpHeaders | OutgoingHttpHeaders): Headers {\n const headers = new Headers();\n for (const [name, value] of Object.entries(httpHeaders)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(name, item);\n }\n } else {\n headers.set(name, String(value ?? ''));\n }\n }\n return headers;\n}\n\nexport const BLOGGER_PLUGIN_HEAD_COMMENT_REGEX = /(<!--blogger-plugin:head:begin-->)([\\s\\S]*?)(<!--blogger-plugin:head:end-->)/;\n\nexport const BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX =\n /(<b:comment><!--blogger-plugin:head:begin--><\\/b:comment>)([\\s\\S]*?)(<b:comment><!--blogger-plugin:head:end--><\\/b:comment>)/;\n\nexport function replaceBloggerPluginHeadComment(input: string, replacement: string, bcomment = false) {\n if (bcomment) {\n return input.replace(BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX, (_, start: string, _content: string, end: string) => `${start}${replacement}${end}`);\n }\n return input.replace(BLOGGER_PLUGIN_HEAD_COMMENT_REGEX, (_, start: string, _content: string, end: string) => `${start}${replacement}${end}`);\n}\n\nexport function getBloggerPluginHeadComment(input: string, bcomment = false) {\n if (bcomment) {\n return input.match(BLOGGER_PLUGIN_HEAD_BCOMMENT_REGEX)?.[2] ?? null;\n }\n return input.match(BLOGGER_PLUGIN_HEAD_COMMENT_REGEX)?.[2] ?? null;\n}\n\nexport function replaceHost(input: string, oldHost: string, newHost: string, newProtocol?: string) {\n return input.replace(\n new RegExp(`(https?:)?(\\\\/\\\\/|\\\\\\\\/\\\\\\\\/)${escapeRegex(oldHost)}`, 'g'),\n (_, protocol, slash) => `${protocol ? (newProtocol ?? protocol) : ''}${slash ?? ''}${newHost}`,\n );\n}\n\nexport function getRequestUrl(req: Connect.IncomingMessage): URL | null {\n const xForwardedProtoHeader = req.headers['x-forwarded-proto'];\n const xForwardedHostHeader = req.headers['x-forwarded-host'];\n const hostHeader = req.headers.host;\n\n const protocol = Array.isArray(xForwardedProtoHeader)\n ? xForwardedProtoHeader[0]\n : (xForwardedProtoHeader ?? (req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https' : 'http'));\n const host = Array.isArray(xForwardedHostHeader) ? xForwardedHostHeader[0] : (xForwardedHostHeader ?? hostHeader);\n\n if (host && req.originalUrl) {\n return new URL(`${protocol}://${host}${req.originalUrl}`);\n }\n\n return null;\n}\n\nexport function isBloggerPath(path: string) {\n return (\n path === '/' ||\n path === '/search' ||\n /^\\/search\\/label(\\/[^/]+)?\\/?$/.test(path) ||\n /^p\\/.+\\.html$/.test(path) ||\n /^\\/\\d{4}\\/\\d{2}(\\/?|\\/[^/\\s]+\\.html)$/.test(path)\n );\n}\n\nconst TAILWIND_PLUGIN_NAMES = new Set(['@tailwindcss/vite:scan']);\n\nexport function isTailwindPlugin(plugin: { name: string }): boolean {\n return TAILWIND_PLUGIN_NAMES.has(plugin.name);\n}\n\nexport function errorHtml(reqUrl: string) {\n return `<!DOCTYPE html>\n<html>\n\n<head>\n <meta charset='UTF-8'/>\n <meta content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=5, user-scalable=yes' name='viewport'/>\n <title>500 Internal Server Error</title>\n <link rel='icon' href='data:,' />\n <style>\n *, ::before, ::after {\n box-sizing: border-box;\n }\n body {\n min-height: 100svh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n margin: 0;\n padding: 20px;\n background-color: #f5f5f5;\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", Segoe UI Symbol, \"Noto Color Emoji\";\n }\n .card {\n padding: 24px;\n background-color: #ffffff;\n border: 1px solid #e5e5e5;\n max-width: 448px;\n border-radius: 14px;\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);\n display: flex;\n flex-direction: column;\n gap: 24px;\n }\n .card-content {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n .card-title {\n font-weight: 600;\n }\n .card-description {\n font-size: 14px;\n opacity: 0.85;\n }\n .card-footer {\n display: flex;\n align-items: center;\n }\n .button {\n display: inline-flex;\n white-space: nowrap;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 8px 16px;\n font-weight: 500;\n background-color: #171717;\n outline: none;\n border: none;\n color: #ffffff;\n border-radius: 8px;\n min-height: 36px;\n }\n .button:hover {\n opacity: 0.9;\n }\n .button svg {\n wiheadersdth: 16px;\n height: 16px;\n flex-shrink: 0;\n }\n .card-footer .button {\n flex-grow: 1;\n }\n </style>\n</head>\n\n<body>\n <div class='card'>\n <div class='card-content'>\n <div class='card-title'>500 Internal Server Error</div>\n <div class='card-description'>Failed to fetch: ${escapeHtml(reqUrl)}</div>\n </div>\n <div class='card-footer'>\n <button class='button' type='button'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-refresh-ccw\" aria-hidden=\"true\"><path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path><path d=\"M3 3v5h5\"></path><path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path><path d=\"M16 16h5v5\"></path></svg>\n Reload\n </button>\n </div>\n </div>\n <script>\n const button = document.getElementsByTagName('button')[0];\n button.addEventListener('click', () => {\n window.location.reload();\n });\n </script>\n</body>\n\n</html>`;\n}\n"],"mappings":";AAAA,YAAYA,SAAQ;AACpB,YAAYC,WAAU;AACtB,SAAS,gBAAgB;AACzB;AAAA,EAOE,WAAW;AAAA,OACN;;;ACXP,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,0BAA0B;AAEnC,IAAM,sBAAsB;AAE5B,SAAS,gBAAgB,MAA6B;AACpD,MAAI,CAAI,cAAW,IAAI,GAAG;AACxB,WAAO;AAAA,EACT;AACA,SAAU,gBAAa,MAAM,OAAO;AACtC;AAEA,SAAS,iBAAiB,MAAc,SAA0B;AAChE,QAAMC,WAAe,aAAQ,IAAI;AAEjC,MAAI,CAAI,cAAWA,QAAO,GAAG;AAC3B,IAAG,aAAUA,UAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EAC3C;AAEA,QAAM,UAAU,gBAAgB,IAAI;AACpC,MAAI,YAAY,QAAQ,YAAY,SAAS;AAC3C,IAAG,iBAAc,MAAM,SAAS,MAAM;AACtC,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEA,SAAS,WAAW,MAAuB;AACzC,MAAI,CAAI,cAAW,IAAI,GAAG;AACxB,WAAO;AAAA,EACT;AACA,EAAG,UAAO,IAAI;AACd,SAAO;AACT;AAEA,S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