Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/full-tips-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fuzdev/fuz_css': minor
---

switch to blake3 hashing, add optional peer dep `@fuzdev/blake3_wasm`
109 changes: 69 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"node": ">=22.15"
},
"peerDependencies": {
"@fuzdev/blake3_wasm": "^0.1.0",
"@fuzdev/fuz_util": ">=0.52.0",
"@fuzdev/gro": ">=0.195.0",
"@sveltejs/acorn-typescript": "^1",
Expand All @@ -39,6 +40,9 @@
"zod": "^4"
},
"peerDependenciesMeta": {
"@fuzdev/blake3_wasm": {
"optional": true
},
"@fuzdev/fuz_util": {
"optional": true
},
Expand All @@ -63,15 +67,16 @@
},
"devDependencies": {
"@changesets/changelog-git": "^0.2.1",
"@fuzdev/blake3_wasm": "^0.1.0",
"@fuzdev/fuz_code": "^0.45.1",
"@fuzdev/fuz_ui": "^0.185.2",
"@fuzdev/fuz_util": "^0.52.1",
"@fuzdev/fuz_util": "^0.53.0",
"@fuzdev/gro": "^0.196.0",
"@jridgewell/trace-mapping": "^0.3.31",
"@ryanatkn/eslint-config": "^0.9.0",
"@sveltejs/acorn-typescript": "^1.0.8",
"@sveltejs/acorn-typescript": "^1.0.9",
"@sveltejs/adapter-static": "^3.0.10",
"@sveltejs/kit": "^2.50.1",
"@sveltejs/kit": "^2.53.4",
"@sveltejs/package": "^2.5.7",
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@types/estree": "^1.0.8",
Expand All @@ -84,9 +89,9 @@
"magic-string": "^0.30.21",
"prettier": "^3.7.4",
"prettier-plugin-svelte": "^3.4.1",
"svelte": "^5.49.1",
"svelte-check": "^4.3.6",
"svelte2tsx": "^0.7.47",
"svelte": "^5.53.7",
"svelte-check": "^4.4.4",
"svelte2tsx": "^0.7.51",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.48.1",
Expand Down
3 changes: 1 addition & 2 deletions src/lib/css_ruleset_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const parse_ruleset = (css: string): ParsedRuleset => {
* @mutates rules - pushes extracted rules to the array
*/
const walk_css_children = (
node: Omit<AST.CSS.StyleSheet, 'attributes' | 'content'> | AST.CSS.Atrule,
node: Omit<AST.CSS.StyleSheetFile, 'attributes' | 'content'> | AST.CSS.Atrule,
original_css: string,
rules: Array<ParsedRule>,
): void => {
Expand All @@ -72,7 +72,6 @@ const walk_css_children = (
for (const child of children) {
if (child.type === 'Rule') {
extract_rule(child, original_css, rules);
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
} else if (child.type === 'Atrule' && child.block) {
// Recurse into at-rules (like @media) - rules are in block.children
walk_css_block(child.block, original_css, rules);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/gen_fuz_css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ export const gen_fuz_css = (options: GenFuzCssOptions = {}): Gen => {
if (!style_rule_index) {
if (typeof base_css === 'string') {
// Custom CSS string provided (replacement)
style_rule_index = await create_style_rule_index(base_css);
style_rule_index = create_style_rule_index(base_css);
} else if (typeof base_css === 'function') {
// Callback to modify default CSS
const default_css = await load_default_style_css(deps);
const modified_css = base_css(default_css);
style_rule_index = await create_style_rule_index(modified_css);
style_rule_index = create_style_rule_index(modified_css);
} else {
// Use default style.css (undefined or null - null handled by include_base flag)
style_rule_index = await load_style_rule_index(deps);
Expand Down
10 changes: 5 additions & 5 deletions src/lib/style_rule_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import {parseCss, type AST} from 'svelte/compiler';
import {hash_secure} from '@fuzdev/fuz_util/hash.js';
import {hash_blake3} from '@fuzdev/fuz_util/hash_blake3.js';

import {extract_css_variables} from './css_variable_utils.js';
import type {CacheDeps} from './deps.js';
Expand Down Expand Up @@ -503,7 +503,7 @@ export const load_style_rule_index = async (
if (css === null) {
throw new Error(`Failed to read style.css from ${path}`);
}
const content_hash = await hash_secure(css);
const content_hash = hash_blake3(css);
return parse_style_css(css, content_hash);
};

Expand All @@ -512,10 +512,10 @@ export const load_style_rule_index = async (
* Use this to parse user-provided base styles instead of loading from file.
*
* @param css - raw CSS string to parse
* @returns promise resolving to `StyleRuleIndex`
* @returns `StyleRuleIndex`
*/
export const create_style_rule_index = async (css: string): Promise<StyleRuleIndex> => {
const content_hash = await hash_secure(css);
export const create_style_rule_index = (css: string): StyleRuleIndex => {
const content_hash = hash_blake3(css);
return parse_style_css(css, content_hash);
};

Expand Down
Loading
Loading