astro-font-loader 0.1.4 → 0.1.5

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/css/get.d.ts CHANGED
@@ -16,7 +16,7 @@ export type GetFontsCssOptions = {
16
16
  *
17
17
  * @param {GetFontsCssOptions} [options={}] - Options including filter and output directory.
18
18
  * @param {FontsPackageInfo | null} fontPackageInformation - Information about the font package, including the CSS file path.
19
- * @returns {string} The processed CSS string, or an empty string if the CSS file is missing or no package info is provided.
19
+ * @returns {string} The processed and minified CSS string, or an empty string if the CSS file is missing or no package info is provided.
20
20
  */
21
21
  export declare function getFontsCss(options: GetFontsCssOptions | undefined, fontPackageInformation: FontsPackageInfo | null): string;
22
22
  //# sourceMappingURL=get.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../src/css/get.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,iEAAiE;IACjE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,kBAAkB,YAAK,EAChC,sBAAsB,EAAE,gBAAgB,GAAG,IAAI,GAC7C,MAAM,CAYR"}
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../src/css/get.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,iEAAiE;IACjE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAiBF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,kBAAkB,YAAK,EAChC,sBAAsB,EAAE,gBAAgB,GAAG,IAAI,GAC7C,MAAM,CAaR"}
package/dist/css/get.js CHANGED
@@ -1,6 +1,20 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { filterCssFontFaces } from "./filter.js";
3
3
  import { transformCss } from "./transform.js";
4
+ /**
5
+ * Minifies a CSS string by removing comments, extra whitespace, and newlines.
6
+ *
7
+ * @param css - The CSS string to minify.
8
+ * @returns The minified CSS string.
9
+ */
10
+ function minifyCss(css) {
11
+ return css
12
+ .replace(/\/\*[\s\S]*?\*\//g, "")
13
+ .replace(/\s+/g, " ")
14
+ .replace(/\s*([{}:;,])\s*/g, "$1")
15
+ .replace(/;}/g, "}")
16
+ .trim();
17
+ }
4
18
  /**
5
19
  * Loads, filters, and transforms the CSS for font-face rules from a font package.
6
20
  *
@@ -9,7 +23,7 @@ import { transformCss } from "./transform.js";
9
23
  *
10
24
  * @param {GetFontsCssOptions} [options={}] - Options including filter and output directory.
11
25
  * @param {FontsPackageInfo | null} fontPackageInformation - Information about the font package, including the CSS file path.
12
- * @returns {string} The processed CSS string, or an empty string if the CSS file is missing or no package info is provided.
26
+ * @returns {string} The processed and minified CSS string, or an empty string if the CSS file is missing or no package info is provided.
13
27
  */
14
28
  export function getFontsCss(options = {}, fontPackageInformation) {
15
29
  const { filter, outputDir = "fonts" } = options;
@@ -19,6 +33,7 @@ export function getFontsCss(options = {}, fontPackageInformation) {
19
33
  }
20
34
  let rawCss = readFileSync(fontPackageInformation.cssPath, "utf-8");
21
35
  rawCss = filterCssFontFaces(rawCss, filter);
22
- return transformCss(rawCss, outputDir, filter);
36
+ const transformedCss = transformCss(rawCss, outputDir, filter);
37
+ return minifyCss(transformedCss);
23
38
  }
24
39
  //# sourceMappingURL=get.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get.js","sourceRoot":"","sources":["../../src/css/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAY9C;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAC1B,UAA8B,EAAE,EAChC,sBAA+C;IAE/C,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC;IAChD,IACC,CAAC,sBAAsB;QACvB,CAAC,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAC1C,CAAC;QACF,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,MAAM,GAAG,YAAY,CAAC,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAChD,CAAC"}
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../src/css/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAY9C;;;;;GAKG;AACH,SAAS,SAAS,CAAC,GAAW;IAC7B,OAAO,GAAG;SACR,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC;SACjC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,IAAI,EAAE,CAAC;AACV,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAC1B,UAA8B,EAAE,EAChC,sBAA+C;IAE/C,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC;IAChD,IACC,CAAC,sBAAsB;QACvB,CAAC,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAC1C,CAAC;QACF,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,MAAM,GAAG,YAAY,CAAC,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/D,OAAO,SAAS,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Mikey Sleevi <development@frogman.simplelogin.com>",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.1.4",
7
+ "version": "0.1.5",
8
8
  "engines": {
9
9
  "node": ">=18.0.0"
10
10
  },