@altano/astro-prettier-response 0.0.2 → 1.0.1

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 CHANGED
@@ -95,7 +95,7 @@ export default defineConfig({
95
95
  });
96
96
  ```
97
97
 
98
- And if you like the behavior but you just hate seeing this logged every time you build, then configure Astro to disable minification yourself and the integration will stop logging:
98
+ And if you like the default behavior but you just hate seeing this logged every time you build, then configure Astro to disable minification yourself and the integration will stop logging:
99
99
 
100
100
  ```js
101
101
  import prettierResponse from "@altano/astro-prettier-response";
@@ -112,7 +112,7 @@ export default defineConfig({
112
112
  });
113
113
  ```
114
114
 
115
- This will leave minification enabled but will still run your output through Prettier.
115
+ This will do exactly the same thing (disable minification) and will still run your output through Prettier, but the log line will go away.
116
116
 
117
117
  ## How This Integration Works
118
118
 
package/dist/index.d.ts CHANGED
@@ -1,3 +1,24 @@
1
- export { default } from "./integration.js";
2
- export type { AstroPrettierResponseConfig } from "./config.js";
1
+ import { z } from "astro/zod";
2
+ import { AstroIntegration } from "astro";
3
+
4
+ //#region src/integration.d.ts
5
+ declare const integration: (options?: {
6
+ disableMinifiers?: boolean | undefined;
7
+ formatXml?: boolean | undefined;
8
+ }) => AstroIntegration & {};
9
+ //#endregion
10
+ //#region src/config.d.ts
11
+ declare const ConfigSchema: z.ZodDefault<z.ZodOptional<z.ZodObject<{
12
+ disableMinifiers: z.ZodDefault<z.ZodBoolean>;
13
+ formatXml: z.ZodDefault<z.ZodBoolean>;
14
+ }, "strict", z.ZodTypeAny, {
15
+ disableMinifiers: boolean;
16
+ formatXml: boolean;
17
+ }, {
18
+ disableMinifiers?: boolean | undefined;
19
+ formatXml?: boolean | undefined;
20
+ }>>>;
21
+ type AstroPrettierResponseConfig = z.infer<typeof ConfigSchema>;
22
+ //#endregion
23
+ export { AstroPrettierResponseConfig, integration as default };
3
24
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,103 +1,52 @@
1
- // src/integration.ts
2
1
  import { runtimeLogger } from "@inox-tools/runtime-logger";
3
- import {
4
- addVirtualImports,
5
- createResolver,
6
- defineIntegration
7
- } from "astro-integration-kit";
8
-
9
- // src/config.ts
2
+ import { addVirtualImports, createResolver, defineIntegration } from "astro-integration-kit";
10
3
  import { z } from "astro/zod";
11
- var ConfigSchema = z.object({
12
- /**
13
- * Astro/Vite will minify your HTML/JS/CSS by default. Astro lightly
14
- * compresses your HTML (not a full minifier) while Vite will fully compress
15
- * your CSS/JS. Since we're going for prettiest output here, it makes sense
16
- * for this integration to fully disable such minification.
17
- *
18
- * If you set this to false, and you use the default Astro config with
19
- * minification enabled, you will still get your output formatted by
20
- * Prettier, but it will be minified output that is formatted. So, for
21
- * example, most of the variable names in your JS will be one character
22
- * letters.
23
- *
24
- * @defaultValue true
25
- */
26
- disableMinifiers: z.boolean().default(true),
27
- /**
28
- * Install `@prettier/plugin-xml` package if you enable this
29
- *
30
- * Use the official Prettier plugin to format xml as well. Sitemaps and rss
31
- * feeds are xml, so this would probably do something on your stock Astro
32
- * site. Note: the Prettier output is only marginally better because xml is
33
- * very whitespace sensitive and so Prettier's formatting is very strict and
34
- * not that much prettier.
35
- *
36
- * @defaultValue false
37
- */
38
- formatXml: z.boolean().default(false)
4
+
5
+ //#region src/config.ts
6
+ const ConfigSchema = z.object({
7
+ disableMinifiers: z.boolean().default(true),
8
+ formatXml: z.boolean().default(false)
39
9
  }).strict().optional().default({});
40
10
 
41
- // src/integration.ts
42
- var integration_default = defineIntegration({
43
- name: "astro-prettier-response",
44
- optionsSchema: ConfigSchema,
45
- setup({ options, name }) {
46
- const { resolve } = createResolver(import.meta.url);
47
- return {
48
- hooks: {
49
- "astro:config:setup": (params) => {
50
- addVirtualImports(params, {
51
- name,
52
- imports: {
53
- "virtual:astro-prettier-response/config": `export default ${JSON.stringify(ConfigSchema.parse(options))}`
54
- }
55
- });
56
- runtimeLogger(params, { name: "astro-prettier-response" });
57
- const { config, updateConfig, addMiddleware, logger } = params;
58
- if (options.disableMinifiers) {
59
- let didConfigOverride = false;
60
- if (config.compressHTML !== false) {
61
- didConfigOverride = true;
62
- updateConfig({
63
- compressHTML: false
64
- });
65
- }
66
- if (config?.vite?.build?.minify !== false) {
67
- didConfigOverride = true;
68
- updateConfig({
69
- vite: {
70
- build: {
71
- minify: false
72
- }
73
- }
74
- });
75
- }
76
- if (config?.vite?.build?.cssMinify !== false) {
77
- didConfigOverride = true;
78
- updateConfig({
79
- vite: {
80
- build: {
81
- cssMinify: false
82
- }
83
- }
84
- });
85
- }
86
- if (didConfigOverride) {
87
- logger.info(
88
- `Disabling minification of html/css/js in Astro config (https://github.com/altano/npm-packages/tree/main/packages/astro-prettier-response#config-overrides)`
89
- );
90
- }
91
- }
92
- addMiddleware({
93
- entrypoint: resolve("./middleware/index.js"),
94
- order: "post"
95
- });
96
- }
97
- }
98
- };
99
- }
11
+ //#endregion
12
+ //#region src/integration.ts
13
+ const integration = defineIntegration({
14
+ name: "astro-prettier-response",
15
+ optionsSchema: ConfigSchema,
16
+ setup({ options, name }) {
17
+ const { resolve } = createResolver(import.meta.url);
18
+ return { hooks: { "astro:config:setup": (params) => {
19
+ addVirtualImports(params, {
20
+ name,
21
+ imports: { "virtual:astro-prettier-response/config": `export default ${JSON.stringify(ConfigSchema.parse(options))}` }
22
+ });
23
+ runtimeLogger(params, { name: "astro-prettier-response" });
24
+ const { config, updateConfig, addMiddleware, logger } = params;
25
+ if (options.disableMinifiers) {
26
+ let didConfigOverride = false;
27
+ if (config.compressHTML !== false) {
28
+ didConfigOverride = true;
29
+ updateConfig({ compressHTML: false });
30
+ }
31
+ if (config?.vite?.build?.minify !== false) {
32
+ didConfigOverride = true;
33
+ updateConfig({ vite: { build: { minify: false } } });
34
+ }
35
+ if (config?.vite?.build?.cssMinify !== false) {
36
+ didConfigOverride = true;
37
+ updateConfig({ vite: { build: { cssMinify: false } } });
38
+ }
39
+ if (didConfigOverride) logger.info(`Disabling minification of html/css/js in Astro config (https://github.com/altano/npm-packages/tree/main/packages/astro-prettier-response#config-overrides)`);
40
+ }
41
+ addMiddleware({
42
+ entrypoint: resolve("./middleware/index.js"),
43
+ order: "post"
44
+ });
45
+ } } };
46
+ }
100
47
  });
101
- export {
102
- integration_default as default
103
- };
48
+ var integration_default = integration;
49
+
50
+ //#endregion
51
+ export { integration_default as default };
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ConfigSchema: z.ZodDefault<\n z.ZodOptional<\n z.ZodObject<\n {\n disableMinifiers: z.ZodDefault<z.ZodBoolean>;\n formatXml: z.ZodDefault<z.ZodBoolean>;\n },\n \"strict\",\n z.ZodTypeAny,\n {\n disableMinifiers: boolean;\n formatXml: boolean;\n },\n {\n disableMinifiers?: boolean | undefined;\n formatXml?: boolean | undefined;\n }\n >\n >\n>","integration: (options?: {\n disableMinifiers?: boolean | undefined;\n formatXml?: boolean | undefined;\n}) => AstroIntegration & {}"],"sources":["../src/config.ts","../src/integration.ts"],"sourcesContent":["import { z } from \"astro/zod\";\n\nexport const ConfigSchema: z.ZodDefault<\n z.ZodOptional<\n z.ZodObject<\n {\n disableMinifiers: z.ZodDefault<z.ZodBoolean>;\n formatXml: z.ZodDefault<z.ZodBoolean>;\n },\n \"strict\",\n z.ZodTypeAny,\n {\n disableMinifiers: boolean;\n formatXml: boolean;\n },\n {\n disableMinifiers?: boolean | undefined;\n formatXml?: boolean | undefined;\n }\n >\n >\n> = z\n .object({\n /**\n * Astro/Vite will minify your HTML/JS/CSS by default. Astro lightly\n * compresses your HTML (not a full minifier) while Vite will fully compress\n * your CSS/JS. Since we're going for prettiest output here, it makes sense\n * for this integration to fully disable such minification.\n *\n * If you set this to false, and you use the default Astro config with\n * minification enabled, you will still get your output formatted by\n * Prettier, but it will be minified output that is formatted. So, for\n * example, most of the variable names in your JS will be one character\n * letters.\n *\n * @defaultValue true\n */\n disableMinifiers: z.boolean().default(true),\n /**\n * Install `@prettier/plugin-xml` package if you enable this\n *\n * Use the official Prettier plugin to format xml as well. Sitemaps and rss\n * feeds are xml, so this would probably do something on your stock Astro\n * site. Note: the Prettier output is only marginally better because xml is\n * very whitespace sensitive and so Prettier's formatting is very strict and\n * not that much prettier.\n *\n * @defaultValue false\n */\n formatXml: z.boolean().default(false),\n })\n .strict()\n .optional()\n .default({});\n\nexport type AstroPrettierResponseConfig = z.infer<typeof ConfigSchema>;\n","import { runtimeLogger } from \"@inox-tools/runtime-logger\";\nimport {\n addVirtualImports,\n createResolver,\n defineIntegration,\n} from \"astro-integration-kit\";\nimport { ConfigSchema } from \"./config.js\";\nimport type { AstroIntegration } from \"astro\";\n\nconst integration: (options?: {\n disableMinifiers?: boolean | undefined;\n formatXml?: boolean | undefined;\n}) => AstroIntegration & {} = defineIntegration({\n name: \"astro-prettier-response\",\n optionsSchema: ConfigSchema,\n setup({ options, name }) {\n const { resolve } = createResolver(import.meta.url);\n\n return {\n hooks: {\n \"astro:config:setup\": (params) => {\n addVirtualImports(params, {\n name,\n imports: {\n \"virtual:astro-prettier-response/config\": `export default ${JSON.stringify(ConfigSchema.parse(options))}`,\n },\n });\n\n runtimeLogger(params, { name: \"astro-prettier-response\" });\n\n const { config, updateConfig, addMiddleware, logger } = params;\n\n if (options.disableMinifiers) {\n let didConfigOverride = false;\n\n if (config.compressHTML !== false) {\n didConfigOverride = true;\n updateConfig({\n compressHTML: false,\n });\n }\n\n if (config?.vite?.build?.minify !== false) {\n didConfigOverride = true;\n updateConfig({\n vite: {\n build: {\n minify: false,\n },\n },\n });\n }\n\n if (config?.vite?.build?.cssMinify !== false) {\n didConfigOverride = true;\n updateConfig({\n vite: {\n build: {\n cssMinify: false,\n },\n },\n });\n }\n\n if (didConfigOverride) {\n logger.info(\n `Disabling minification of html/css/js in Astro config (https://github.com/altano/npm-packages/tree/main/packages/astro-prettier-response#config-overrides)`,\n );\n }\n }\n\n addMiddleware({\n entrypoint: resolve(\"./middleware/index.js\"),\n order: \"post\",\n });\n },\n },\n };\n },\n});\n\nexport default integration;\n"],"mappings":";;;;;AAEA,MAAaA,eAmBT,EACD,OAAO;CAeN,kBAAkB,EAAE,SAAS,CAAC,QAAQ,KAAK;CAY3C,WAAW,EAAE,SAAS,CAAC,QAAQ,MAAM;AACtC,EAAC,CACD,QAAQ,CACR,UAAU,CACV,QAAQ,CAAE,EAAC;;;;AC5Cd,MAAMC,cAGwB,kBAAkB;CAC9C,MAAM;CACN,eAAe;CACf,MAAM,EAAE,SAAS,MAAM,EAAE;EACvB,MAAM,EAAE,SAAS,GAAG,eAAe,OAAO,KAAK,IAAI;AAEnD,SAAO,EACL,OAAO,EACL,sBAAsB,CAAC,WAAW;AAChC,qBAAkB,QAAQ;IACxB;IACA,SAAS,EACP,2CAA2C,iBAAiB,KAAK,UAAU,aAAa,MAAM,QAAQ,CAAC,CAAC,EACzG;GACF,EAAC;AAEF,iBAAc,QAAQ,EAAE,MAAM,0BAA2B,EAAC;GAE1D,MAAM,EAAE,QAAQ,cAAc,eAAe,QAAQ,GAAG;AAExD,OAAI,QAAQ,kBAAkB;IAC5B,IAAI,oBAAoB;AAExB,QAAI,OAAO,iBAAiB,OAAO;AACjC,yBAAoB;AACpB,kBAAa,EACX,cAAc,MACf,EAAC;IACH;AAED,QAAI,QAAQ,MAAM,OAAO,WAAW,OAAO;AACzC,yBAAoB;AACpB,kBAAa,EACX,MAAM,EACJ,OAAO,EACL,QAAQ,MACT,EACF,EACF,EAAC;IACH;AAED,QAAI,QAAQ,MAAM,OAAO,cAAc,OAAO;AAC5C,yBAAoB;AACpB,kBAAa,EACX,MAAM,EACJ,OAAO,EACL,WAAW,MACZ,EACF,EACF,EAAC;IACH;AAED,QAAI,kBACF,QAAO,MACJ,4JACF;GAEJ;AAED,iBAAc;IACZ,YAAY,QAAQ,wBAAwB;IAC5C,OAAO;GACR,EAAC;EACH,EACF,EACF;CACF;AACF,EAAC;AAEF,0BAAe"}
@@ -1,2 +1,7 @@
1
- export declare const onRequest: import("astro").MiddlewareHandler;
1
+ import { MiddlewareHandler } from "astro";
2
+
3
+ //#region src/middleware/index.d.ts
4
+ declare const onRequest: MiddlewareHandler;
5
+ //#endregion
6
+ export { onRequest };
2
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,94 +1,86 @@
1
- // src/middleware/index.ts
2
1
  import { defineMiddleware } from "astro/middleware";
3
-
4
- // src/middleware/filename.ts
5
2
  import mime from "mime-types";
3
+ import { logger } from "@it-astro:logger:astro-prettier-response";
4
+ import prettier from "prettier";
5
+ import config from "virtual:astro-prettier-response/config";
6
6
 
7
- // src/middleware/is400.ts
7
+ //#region src/middleware/is400.ts
8
8
  function is400(status) {
9
- return status >= 400 && status < 500;
9
+ return status >= 400 && status < 500;
10
10
  }
11
11
 
12
- // src/middleware/filename.ts
12
+ //#endregion
13
+ //#region src/middleware/filename.ts
13
14
  function synthesizeFilename(response) {
14
- const contentType = response.headers.get("content-type");
15
- if (contentType == null) {
16
- if (is400(response.status)) {
17
- return "index.html";
18
- }
19
- return null;
20
- }
21
- const extensionFromContentType = mime.extension(contentType);
22
- if (!extensionFromContentType) {
23
- return null;
24
- }
25
- return `file.${extensionFromContentType}`;
15
+ const contentType = response.headers.get("content-type");
16
+ /* v8 ignore next 8 */
17
+ if (contentType == null) {
18
+ if (is400(response.status)) return "index.html";
19
+ return null;
20
+ }
21
+ const extensionFromContentType = mime.extension(contentType);
22
+ if (!extensionFromContentType) return null;
23
+ return `file.${extensionFromContentType}`;
26
24
  }
27
25
 
28
- // src/middleware/format.ts
29
- import { logger } from "@it-astro:logger:astro-prettier-response";
30
-
31
- // src/middleware/prettier.ts
32
- import prettier from "prettier";
33
- import config from "virtual:astro-prettier-response/config";
26
+ //#endregion
27
+ //#region src/middleware/prettier.ts
34
28
  function enhanceOptions(options = {}) {
35
- if (!config.formatXml) {
36
- return options;
37
- }
38
- const givenPlugins = options.plugins ?? [];
39
- return {
40
- ...options,
41
- plugins: [...givenPlugins, "@prettier/plugin-xml"]
42
- };
29
+ if (!config.formatXml) return options;
30
+ const givenPlugins = options.plugins ?? [];
31
+ return {
32
+ ...options,
33
+ plugins: [...givenPlugins, "@prettier/plugin-xml"]
34
+ };
43
35
  }
44
36
  async function format(source, options) {
45
- return prettier.format(source, enhanceOptions(options));
37
+ return prettier.format(source, enhanceOptions(options));
46
38
  }
47
39
  async function getFileInfo(source, options) {
48
- return prettier.getFileInfo(source, enhanceOptions(options));
40
+ return prettier.getFileInfo(source, enhanceOptions(options));
49
41
  }
50
42
 
51
- // src/middleware/format.ts
43
+ //#endregion
44
+ //#region src/middleware/format.ts
52
45
  async function formatOrReturn(filepath, source) {
53
- try {
54
- const result = await format(source, {
55
- filepath
56
- });
57
- logger.debug(`successfully formatted`);
58
- return result;
59
- } catch (e) {
60
- logger.error(`failed to format`);
61
- return source;
62
- }
46
+ try {
47
+ const result = await format(source, { filepath });
48
+ logger.debug(`successfully formatted`);
49
+ return result;
50
+ } catch (e) {
51
+ logger.error(`failed to format`);
52
+ return source;
53
+ }
63
54
  }
64
55
 
65
- // src/middleware/index.ts
66
- import { logger as logger2 } from "@it-astro:logger:astro-prettier-response";
67
- var onRequest = defineMiddleware(async (context, next) => {
68
- const response = await next();
69
- if (!response.ok && !is400(response.status)) {
70
- logger2.debug(`NOT formatting (status is not 2xx or 4xx)`);
71
- return response;
72
- }
73
- const filename = synthesizeFilename(response);
74
- if (filename == null) {
75
- logger2.debug(`NOT formatting (couldn't determine filename/extension)`);
76
- return response;
77
- }
78
- const fileInfo = await getFileInfo(filename);
79
- if (fileInfo?.inferredParser == null) {
80
- logger2.debug(`NOT formatting (Prettier has no parser for this file type)`);
81
- return response;
82
- }
83
- const clone = response.clone();
84
- const source = await clone.text();
85
- const processedSource = await formatOrReturn(filename, source);
86
- return new Response(processedSource, {
87
- status: response.status,
88
- headers: clone.headers,
89
- statusText: clone.statusText
90
- });
56
+ //#endregion
57
+ //#region src/middleware/index.ts
58
+ const onRequest = defineMiddleware(async (context, next) => {
59
+ const response = await next();
60
+ if (!response.ok && !is400(response.status)) {
61
+ logger.debug(`NOT formatting (status is not 2xx or 4xx)`);
62
+ return response;
63
+ }
64
+ const filename = synthesizeFilename(response);
65
+ if (filename == null) {
66
+ logger.debug(`NOT formatting (couldn't determine filename/extension)`);
67
+ return response;
68
+ }
69
+ const fileInfo = await getFileInfo(filename);
70
+ if (fileInfo?.inferredParser == null) {
71
+ logger.debug(`NOT formatting (Prettier has no parser for this file type)`);
72
+ return response;
73
+ }
74
+ const clone = response.clone();
75
+ const source = await clone.text();
76
+ const processedSource = await formatOrReturn(filename, source);
77
+ return new Response(processedSource, {
78
+ status: response.status,
79
+ headers: clone.headers,
80
+ statusText: clone.statusText
81
+ });
91
82
  });
92
- export {
93
- onRequest
94
- };
83
+
84
+ //#endregion
85
+ export { onRequest };
86
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["status: number","response: Response","options: Options","source: string","options?: Options","filepath: string","source: string","e: unknown","onRequest: MiddlewareHandler"],"sources":["../../src/middleware/is400.ts","../../src/middleware/filename.ts","../../src/middleware/prettier.ts","../../src/middleware/format.ts","../../src/middleware/index.ts"],"sourcesContent":["export function is400(status: number): boolean {\n return status >= 400 && status < 500;\n}\n","import mime from \"mime-types\";\nimport { is400 } from \"./is400.js\";\n\nexport function synthesizeFilename(response: Response): string | null {\n const contentType = response.headers.get(\"content-type\");\n // I don't know how to produce a null content-type in testing\n /* v8 ignore next 8 */\n if (contentType == null) {\n if (is400(response.status)) {\n // let's just say all 400 responses with no Content-Type are html?\n return \"index.html\";\n }\n\n return null;\n }\n\n // We have a content-type, so derive the filename from that\n const extensionFromContentType = mime.extension(contentType);\n if (!extensionFromContentType) {\n // I'm pretty sure everything that Prettier can parse has a mime-type in the\n // mime-types db, so this is probably something we don't know anything\n // about. Let's just bail.\n return null;\n }\n\n return `file.${extensionFromContentType}`;\n}\n","import prettier, { type Options } from \"prettier\";\nimport config from \"virtual:astro-prettier-response/config\";\n\nfunction enhanceOptions(options: Options = {}): Options {\n if (!config.formatXml) {\n return options;\n }\n\n const givenPlugins = options.plugins ?? [];\n return {\n ...options,\n plugins: [...givenPlugins, \"@prettier/plugin-xml\"],\n };\n}\n\nexport async function format(\n source: string,\n options?: Options,\n): Promise<string> {\n return prettier.format(source, enhanceOptions(options));\n}\n\nexport async function getFileInfo(\n source: string,\n options?: Options,\n): Promise<prettier.FileInfoResult> {\n return prettier.getFileInfo(source, enhanceOptions(options));\n}\n","import { logger } from \"@it-astro:logger:astro-prettier-response\";\nimport { format } from \"./prettier.js\";\n\nexport async function formatOrReturn(\n filepath: string,\n source: string,\n): Promise<string> {\n try {\n const result = await format(source, {\n filepath: filepath,\n });\n logger.debug(`successfully formatted`);\n return result;\n } catch (e: unknown) {\n logger.error(`failed to format`);\n return source;\n }\n}\n","import { defineMiddleware } from \"astro/middleware\";\nimport { synthesizeFilename } from \"./filename.js\";\nimport { formatOrReturn } from \"./format.js\";\nimport { getFileInfo } from \"./prettier.js\";\nimport { is400 } from \"./is400.js\";\nimport { logger } from \"@it-astro:logger:astro-prettier-response\";\nimport type { MiddlewareHandler } from \"astro\";\n\nexport const onRequest: MiddlewareHandler = defineMiddleware(\n async (context, next) => {\n const response = await next();\n\n // Only attempt formatting on Responses that are OK or have a 400 error (e.g.\n // redirect pages or 404 pages)\n if (!response.ok && !is400(response.status)) {\n logger.debug(`NOT formatting (status is not 2xx or 4xx)`);\n return response;\n }\n\n const filename = synthesizeFilename(response);\n if (filename == null) {\n logger.debug(`NOT formatting (couldn't determine filename/extension)`);\n return response;\n }\n const fileInfo = await getFileInfo(filename);\n if (fileInfo?.inferredParser == null) {\n logger.debug(\n `NOT formatting (Prettier has no parser for this file type)`,\n );\n return response;\n }\n\n const clone = response.clone();\n const source = await clone.text();\n const processedSource = await formatOrReturn(filename, source);\n\n return new Response(processedSource, {\n status: response.status,\n headers: clone.headers,\n statusText: clone.statusText,\n });\n },\n);\n"],"mappings":";;;;;;;AAAA,SAAgB,MAAMA,QAAyB;AAC7C,QAAO,UAAU,OAAO,SAAS;AAClC;;;;ACCD,SAAgB,mBAAmBC,UAAmC;CACpE,MAAM,cAAc,SAAS,QAAQ,IAAI,eAAe;;AAGxD,KAAI,eAAe,MAAM;AACvB,MAAI,MAAM,SAAS,OAAO,CAExB,QAAO;AAGT,SAAO;CACR;CAGD,MAAM,2BAA2B,KAAK,UAAU,YAAY;AAC5D,MAAK,yBAIH,QAAO;AAGT,SAAQ,OAAO,yBAAyB;AACzC;;;;ACvBD,SAAS,eAAeC,UAAmB,CAAE,GAAW;AACtD,MAAK,OAAO,UACV,QAAO;CAGT,MAAM,eAAe,QAAQ,WAAW,CAAE;AAC1C,QAAO;EACL,GAAG;EACH,SAAS,CAAC,GAAG,cAAc,sBAAuB;CACnD;AACF;AAED,eAAsB,OACpBC,QACAC,SACiB;AACjB,QAAO,SAAS,OAAO,QAAQ,eAAe,QAAQ,CAAC;AACxD;AAED,eAAsB,YACpBD,QACAC,SACkC;AAClC,QAAO,SAAS,YAAY,QAAQ,eAAe,QAAQ,CAAC;AAC7D;;;;ACxBD,eAAsB,eACpBC,UACAC,QACiB;AACjB,KAAI;EACF,MAAM,SAAS,MAAM,OAAO,QAAQ,EACxB,SACX,EAAC;AACF,SAAO,OAAO,wBAAwB;AACtC,SAAO;CACR,SAAQC,GAAY;AACnB,SAAO,OAAO,kBAAkB;AAChC,SAAO;CACR;AACF;;;;ACTD,MAAaC,YAA+B,iBAC1C,OAAO,SAAS,SAAS;CACvB,MAAM,WAAW,MAAM,MAAM;AAI7B,MAAK,SAAS,OAAO,MAAM,SAAS,OAAO,EAAE;AAC3C,SAAO,OAAO,2CAA2C;AACzD,SAAO;CACR;CAED,MAAM,WAAW,mBAAmB,SAAS;AAC7C,KAAI,YAAY,MAAM;AACpB,SAAO,OAAO,wDAAwD;AACtE,SAAO;CACR;CACD,MAAM,WAAW,MAAM,YAAY,SAAS;AAC5C,KAAI,UAAU,kBAAkB,MAAM;AACpC,SAAO,OACJ,4DACF;AACD,SAAO;CACR;CAED,MAAM,QAAQ,SAAS,OAAO;CAC9B,MAAM,SAAS,MAAM,MAAM,MAAM;CACjC,MAAM,kBAAkB,MAAM,eAAe,UAAU,OAAO;AAE9D,QAAO,IAAI,SAAS,iBAAiB;EACnC,QAAQ,SAAS;EACjB,SAAS,MAAM;EACf,YAAY,MAAM;CACnB;AACF,EACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altano/astro-prettier-response",
3
- "version": "0.0.2",
3
+ "version": "1.0.1",
4
4
  "description": "Prettier html/css/js for your Astro site",
5
5
  "keywords": [
6
6
  "astro",
@@ -27,6 +27,7 @@
27
27
  },
28
28
  "files": [
29
29
  "dist/**/*.js",
30
+ "dist/**/*.js.map",
30
31
  "dist/**/*.d.ts"
31
32
  ],
32
33
  "dependencies": {
@@ -40,19 +41,19 @@
40
41
  "@prettier/plugin-xml": "^3.4.1",
41
42
  "@types/mime-types": "^2.1.4",
42
43
  "@types/node": "^22.13.10",
43
- "@vitest/coverage-v8": "^3.1.1",
44
- "astro": "^5.5.6",
44
+ "@vitest/coverage-v8": "^3.1.4",
45
+ "astro": "^5.10.1",
45
46
  "depcheck": "^1.4.7",
46
47
  "prettier": "^3.5.3",
47
- "tsup": "^8.4.0",
48
+ "tsdown": "^0.12.9",
48
49
  "typescript": "^5.8.2",
49
50
  "vite": "^6.2.6",
50
- "vitest": "^3.1.1",
51
+ "vitest": "^3.1.4",
51
52
  "zx": "^8.5.2",
52
- "@altano/build-config": "0.0.0",
53
- "@altano/tiny-async-pool": "3.0.2",
54
- "@altano/testing": "0.0.0",
55
- "@altano/tsconfig": "0.0.0"
53
+ "@altano/build-config": "0.0.1",
54
+ "@altano/testing": "0.0.1",
55
+ "@altano/tiny-async-pool": "4.0.1",
56
+ "@altano/tsconfig": "0.0.1"
56
57
  },
57
58
  "peerDependencies": {
58
59
  "astro": "5.x.x",
@@ -65,14 +66,13 @@
65
66
  "access": "public"
66
67
  },
67
68
  "scripts": {
68
- "build": "tsup --config ./tsup.config.ts",
69
- "build:types": "tsc --project tsconfig.declarations.json",
70
- "check:types:astro-fixtures": "node --experimental-strip-types ./scripts/check-fixtures.ts",
69
+ "build": "tsdown",
70
+ "check:types:astro": "node --experimental-strip-types ./scripts/check-fixtures.ts",
71
71
  "check:types:src": "tsc --noEmit",
72
72
  "check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
73
73
  "check:unused-dependencies": "depcheck",
74
74
  "clean": "rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist",
75
- "dev": "tsup --watch",
75
+ "dev": "tsdown --watch",
76
76
  "format": "prettier --write src",
77
77
  "lint": "eslint",
78
78
  "lint:fix": "TIMING=1 eslint src/**/*.ts* --fix",
package/dist/config.d.ts DELETED
@@ -1,38 +0,0 @@
1
- import { z } from "astro/zod";
2
- export declare const ConfigSchema: z.ZodDefault<z.ZodOptional<z.ZodObject<{
3
- /**
4
- * Astro/Vite will minify your HTML/JS/CSS by default. Astro lightly
5
- * compresses your HTML (not a full minifier) while Vite will fully compress
6
- * your CSS/JS. Since we're going for prettiest output here, it makes sense
7
- * for this integration to fully disable such minification.
8
- *
9
- * If you set this to false, and you use the default Astro config with
10
- * minification enabled, you will still get your output formatted by
11
- * Prettier, but it will be minified output that is formatted. So, for
12
- * example, most of the variable names in your JS will be one character
13
- * letters.
14
- *
15
- * @defaultValue true
16
- */
17
- disableMinifiers: z.ZodDefault<z.ZodBoolean>;
18
- /**
19
- * Install `@prettier/plugin-xml` package if you enable this
20
- *
21
- * Use the official Prettier plugin to format xml as well. Sitemaps and rss
22
- * feeds are xml, so this would probably do something on your stock Astro
23
- * site. Note: the Prettier output is only marginally better because xml is
24
- * very whitespace sensitive and so Prettier's formatting is very strict and
25
- * not that much prettier.
26
- *
27
- * @defaultValue false
28
- */
29
- formatXml: z.ZodDefault<z.ZodBoolean>;
30
- }, "strict", z.ZodTypeAny, {
31
- disableMinifiers: boolean;
32
- formatXml: boolean;
33
- }, {
34
- disableMinifiers?: boolean | undefined;
35
- formatXml?: boolean | undefined;
36
- }>>>;
37
- export type AstroPrettierResponseConfig = z.infer<typeof ConfigSchema>;
38
- //# sourceMappingURL=config.d.ts.map
@@ -1,6 +0,0 @@
1
- declare const _default: (options?: {
2
- disableMinifiers?: boolean | undefined;
3
- formatXml?: boolean | undefined;
4
- } | undefined) => import("astro").AstroIntegration & {};
5
- export default _default;
6
- //# sourceMappingURL=integration.d.ts.map
@@ -1,2 +0,0 @@
1
- export declare function synthesizeFilename(response: Response): string | null;
2
- //# sourceMappingURL=filename.d.ts.map
@@ -1,2 +0,0 @@
1
- export declare function formatOrReturn(filepath: string, source: string): Promise<string>;
2
- //# sourceMappingURL=format.d.ts.map
@@ -1,2 +0,0 @@
1
- export declare function is400(status: number): boolean;
2
- //# sourceMappingURL=is400.d.ts.map
@@ -1,4 +0,0 @@
1
- import prettier, { type Options } from "prettier";
2
- export declare function format(source: string, options?: Options): Promise<string>;
3
- export declare function getFileInfo(source: string, options?: Options): Promise<prettier.FileInfoResult>;
4
- //# sourceMappingURL=prettier.d.ts.map