@hedystia/astro 2.3.18 → 2.3.20
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/dist/index.cjs +8 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +8 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +0 -23
package/dist/index.cjs
CHANGED
|
@@ -2,11 +2,6 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
6
|
-
let node_fs = require("node:fs");
|
|
7
|
-
node_fs = require_runtime.__toESM(node_fs);
|
|
8
|
-
let node_path = require("node:path");
|
|
9
|
-
node_path = require_runtime.__toESM(node_path);
|
|
10
5
|
let _hedystia_view_vite = require("@hedystia/view/vite");
|
|
11
6
|
//#region src/index.ts
|
|
12
7
|
function getRenderer() {
|
|
@@ -17,47 +12,17 @@ function getRenderer() {
|
|
|
17
12
|
};
|
|
18
13
|
}
|
|
19
14
|
function src_default(options = {}) {
|
|
20
|
-
const { plugins
|
|
15
|
+
const { plugins } = (0, _hedystia_view_vite.viewPlugin)(options);
|
|
21
16
|
return {
|
|
22
17
|
name: "@hedystia/astro",
|
|
23
|
-
hooks: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
"astro:build:done": async ({ dir }) => {
|
|
32
|
-
if (collectedCSS.size > 0) {
|
|
33
|
-
const css = Array.from(collectedCSS.values()).join("\n");
|
|
34
|
-
injectCSSIntoHTML(dir.pathname, css);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function injectCSSIntoHTML(dir, css) {
|
|
41
|
-
const styleTag = `<style data-hedystia-css">${css.replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
42
|
-
for (const file of findHTMLFiles(dir)) {
|
|
43
|
-
let content = node_fs.default.readFileSync(file, "utf-8");
|
|
44
|
-
if (content.includes("data-hedystia-css")) continue;
|
|
45
|
-
if (content.includes("</head>")) content = content.replace("</head>", `${styleTag}</head>`);
|
|
46
|
-
else content = `${styleTag}${content}`;
|
|
47
|
-
node_fs.default.writeFileSync(file, content, "utf-8");
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function findHTMLFiles(dir) {
|
|
51
|
-
const files = [];
|
|
52
|
-
const walk = (d) => {
|
|
53
|
-
for (const entry of node_fs.default.readdirSync(d, { withFileTypes: true })) {
|
|
54
|
-
const full = node_path.default.join(d, entry.name);
|
|
55
|
-
if (entry.isDirectory()) walk(full);
|
|
56
|
-
else if (entry.name.endsWith(".html")) files.push(full);
|
|
57
|
-
}
|
|
18
|
+
hooks: { "astro:config:setup": async ({ addRenderer, updateConfig }) => {
|
|
19
|
+
addRenderer(getRenderer());
|
|
20
|
+
updateConfig({ vite: {
|
|
21
|
+
plugins: [...plugins, configEnvironmentPlugin()],
|
|
22
|
+
ssr: { noExternal: ["@hedystia/view"] }
|
|
23
|
+
} });
|
|
24
|
+
} }
|
|
58
25
|
};
|
|
59
|
-
walk(dir);
|
|
60
|
-
return files;
|
|
61
26
|
}
|
|
62
27
|
function configEnvironmentPlugin() {
|
|
63
28
|
return {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { viewPlugin } from \"@hedystia/view/vite\";\nimport type { AstroIntegration, AstroRenderer } from \"astro\";\nimport type { Plugin, UserConfig } from \"vite\";\n\nfunction getRenderer(): AstroRenderer {\n return {\n name: \"@hedystia/astro\",\n clientEntrypoint: \"@hedystia/astro/client.js\",\n serverEntrypoint: \"@hedystia/astro/server.js\",\n };\n}\n\nexport { getRenderer as getContainerRenderer };\n\nexport interface Options {\n include?: string[];\n exclude?: string[];\n}\n\nexport default function (options: Options = {}): AstroIntegration {\n const { plugins } = viewPlugin(options);\n\n return {\n name: \"@hedystia/astro\",\n hooks: {\n \"astro:config:setup\": async ({ addRenderer, updateConfig }) => {\n addRenderer(getRenderer());\n updateConfig({\n vite: {\n plugins: [...plugins, configEnvironmentPlugin()],\n ssr: {\n noExternal: [\"@hedystia/view\"],\n },\n },\n });\n },\n },\n };\n}\n\nfunction configEnvironmentPlugin(): Plugin {\n return {\n name: \"@hedystia/astro:config-environment\",\n configEnvironment(environmentName: string): UserConfig | Promise<UserConfig> | undefined {\n return {\n optimizeDeps: {\n include: environmentName === \"client\" ? [\"@hedystia/astro/client.js\"] : [],\n exclude: [\"@hedystia/astro/server.js\"],\n },\n };\n },\n };\n}\n"],"mappings":";;;;;;AAIA,SAAS,cAA6B;CACpC,OAAO;EACL,MAAM;EACN,kBAAkB;EAClB,kBAAkB;CACpB;AACF;AASA,SAAA,YAAyB,UAAmB,CAAC,GAAqB;CAChE,MAAM,EAAE,aAAA,GAAA,oBAAA,YAAuB,OAAO;CAEtC,OAAO;EACL,MAAM;EACN,OAAO,EACL,sBAAsB,OAAO,EAAE,aAAa,mBAAmB;GAC7D,YAAY,YAAY,CAAC;GACzB,aAAa,EACX,MAAM;IACJ,SAAS,CAAC,GAAG,SAAS,wBAAwB,CAAC;IAC/C,KAAK,EACH,YAAY,CAAC,gBAAgB,EAC/B;GACF,EACF,CAAC;EACH,EACF;CACF;AACF;AAEA,SAAS,0BAAkC;CACzC,OAAO;EACL,MAAM;EACN,kBAAkB,iBAAuE;GACvF,OAAO,EACL,cAAc;IACZ,SAAS,oBAAoB,WAAW,CAAC,2BAA2B,IAAI,CAAC;IACzE,SAAS,CAAC,2BAA2B;GACvC,EACF;EACF;CACF;AACF"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
1
|
import { viewPlugin } from "@hedystia/view/vite";
|
|
4
2
|
//#region src/index.ts
|
|
5
3
|
function getRenderer() {
|
|
@@ -10,47 +8,17 @@ function getRenderer() {
|
|
|
10
8
|
};
|
|
11
9
|
}
|
|
12
10
|
function src_default(options = {}) {
|
|
13
|
-
const { plugins
|
|
11
|
+
const { plugins } = viewPlugin(options);
|
|
14
12
|
return {
|
|
15
13
|
name: "@hedystia/astro",
|
|
16
|
-
hooks: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
"astro:build:done": async ({ dir }) => {
|
|
25
|
-
if (collectedCSS.size > 0) {
|
|
26
|
-
const css = Array.from(collectedCSS.values()).join("\n");
|
|
27
|
-
injectCSSIntoHTML(dir.pathname, css);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function injectCSSIntoHTML(dir, css) {
|
|
34
|
-
const styleTag = `<style data-hedystia-css">${css.replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
35
|
-
for (const file of findHTMLFiles(dir)) {
|
|
36
|
-
let content = fs.readFileSync(file, "utf-8");
|
|
37
|
-
if (content.includes("data-hedystia-css")) continue;
|
|
38
|
-
if (content.includes("</head>")) content = content.replace("</head>", `${styleTag}</head>`);
|
|
39
|
-
else content = `${styleTag}${content}`;
|
|
40
|
-
fs.writeFileSync(file, content, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function findHTMLFiles(dir) {
|
|
44
|
-
const files = [];
|
|
45
|
-
const walk = (d) => {
|
|
46
|
-
for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
|
|
47
|
-
const full = path.join(d, entry.name);
|
|
48
|
-
if (entry.isDirectory()) walk(full);
|
|
49
|
-
else if (entry.name.endsWith(".html")) files.push(full);
|
|
50
|
-
}
|
|
14
|
+
hooks: { "astro:config:setup": async ({ addRenderer, updateConfig }) => {
|
|
15
|
+
addRenderer(getRenderer());
|
|
16
|
+
updateConfig({ vite: {
|
|
17
|
+
plugins: [...plugins, configEnvironmentPlugin()],
|
|
18
|
+
ssr: { noExternal: ["@hedystia/view"] }
|
|
19
|
+
} });
|
|
20
|
+
} }
|
|
51
21
|
};
|
|
52
|
-
walk(dir);
|
|
53
|
-
return files;
|
|
54
22
|
}
|
|
55
23
|
function configEnvironmentPlugin() {
|
|
56
24
|
return {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { viewPlugin } from \"@hedystia/view/vite\";\nimport type { AstroIntegration, AstroRenderer } from \"astro\";\nimport type { Plugin, UserConfig } from \"vite\";\n\nfunction getRenderer(): AstroRenderer {\n return {\n name: \"@hedystia/astro\",\n clientEntrypoint: \"@hedystia/astro/client.js\",\n serverEntrypoint: \"@hedystia/astro/server.js\",\n };\n}\n\nexport { getRenderer as getContainerRenderer };\n\nexport interface Options {\n include?: string[];\n exclude?: string[];\n}\n\nexport default function (options: Options = {}): AstroIntegration {\n const { plugins } = viewPlugin(options);\n\n return {\n name: \"@hedystia/astro\",\n hooks: {\n \"astro:config:setup\": async ({ addRenderer, updateConfig }) => {\n addRenderer(getRenderer());\n updateConfig({\n vite: {\n plugins: [...plugins, configEnvironmentPlugin()],\n ssr: {\n noExternal: [\"@hedystia/view\"],\n },\n },\n });\n },\n },\n };\n}\n\nfunction configEnvironmentPlugin(): Plugin {\n return {\n name: \"@hedystia/astro:config-environment\",\n configEnvironment(environmentName: string): UserConfig | Promise<UserConfig> | undefined {\n return {\n optimizeDeps: {\n include: environmentName === \"client\" ? [\"@hedystia/astro/client.js\"] : [],\n exclude: [\"@hedystia/astro/server.js\"],\n },\n };\n },\n };\n}\n"],"mappings":";;AAIA,SAAS,cAA6B;CACpC,OAAO;EACL,MAAM;EACN,kBAAkB;EAClB,kBAAkB;CACpB;AACF;AASA,SAAA,YAAyB,UAAmB,CAAC,GAAqB;CAChE,MAAM,EAAE,YAAY,WAAW,OAAO;CAEtC,OAAO;EACL,MAAM;EACN,OAAO,EACL,sBAAsB,OAAO,EAAE,aAAa,mBAAmB;GAC7D,YAAY,YAAY,CAAC;GACzB,aAAa,EACX,MAAM;IACJ,SAAS,CAAC,GAAG,SAAS,wBAAwB,CAAC;IAC/C,KAAK,EACH,YAAY,CAAC,gBAAgB,EAC/B;GACF,EACF,CAAC;EACH,EACF;CACF;AACF;AAEA,SAAS,0BAAkC;CACzC,OAAO;EACL,MAAM;EACN,kBAAkB,iBAAuE;GACvF,OAAO,EACL,cAAc;IACZ,SAAS,oBAAoB,WAAW,CAAC,2BAA2B,IAAI,CAAC;IACzE,SAAS,CAAC,2BAA2B;GACvC,EACF;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
|
-
exports.__toESM = __toESM;
|