@fuzdev/fuz_code 0.41.1 → 0.42.0

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/Code.svelte CHANGED
@@ -27,7 +27,7 @@
27
27
  | {
28
28
  content?: undefined;
29
29
  /**
30
- * Pre-highlighted HTML from the `svelte_preprocess_code_static` preprocessor.
30
+ * Pre-highlighted HTML from the `svelte_preprocess_fuz_code` preprocessor.
31
31
  * When provided, skips runtime syntax highlighting entirely.
32
32
  *
33
33
  * Named `dangerous_raw_html` to signal that it bypasses sanitization,
@@ -8,7 +8,7 @@ type $$ComponentProps = SvelteHTMLElements['code'] & ({
8
8
  } | {
9
9
  content?: undefined;
10
10
  /**
11
- * Pre-highlighted HTML from the `svelte_preprocess_code_static` preprocessor.
11
+ * Pre-highlighted HTML from the `svelte_preprocess_fuz_code` preprocessor.
12
12
  * When provided, skips runtime syntax highlighting entirely.
13
13
  *
14
14
  * Named `dangerous_raw_html` to signal that it bypasses sanitization,
@@ -1,6 +1,6 @@
1
1
  import { type PreprocessorGroup } from 'svelte/compiler';
2
2
  import type { SyntaxStyler } from './syntax_styler.js';
3
- export interface PreprocessCodeStaticOptions {
3
+ export interface PreprocessFuzCodeOptions {
4
4
  /** File patterns to exclude. */
5
5
  exclude?: Array<string | RegExp>;
6
6
  /** Custom syntax styler. @default syntax_styler_global */
@@ -20,5 +20,5 @@ export interface PreprocessCodeStaticOptions {
20
20
  */
21
21
  on_error?: 'log' | 'throw';
22
22
  }
23
- export declare const svelte_preprocess_code_static: (options?: PreprocessCodeStaticOptions) => PreprocessorGroup;
24
- //# sourceMappingURL=svelte_preprocess_code_static.d.ts.map
23
+ export declare const svelte_preprocess_fuz_code: (options?: PreprocessFuzCodeOptions) => PreprocessorGroup;
24
+ //# sourceMappingURL=svelte_preprocess_fuz_code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svelte_preprocess_fuz_code.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/svelte_preprocess_fuz_code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,iBAAiB,EAAW,MAAM,iBAAiB,CAAC;AAKxE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,wBAAwB;IACxC,gCAAgC;IAChC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAEjC,0DAA0D;IAC1D,aAAa,CAAC,EAAE,YAAY,CAAC;IAE7B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,0BAA0B,GACtC,UAAS,wBAA6B,KACpC,iBA0DF,CAAC"}
@@ -2,12 +2,12 @@ import { parse } from 'svelte/compiler';
2
2
  import MagicString from 'magic-string';
3
3
  import { walk } from 'zimmerframe';
4
4
  import { syntax_styler_global } from './syntax_styler_global.js';
5
- export const svelte_preprocess_code_static = (options = {}) => {
5
+ export const svelte_preprocess_fuz_code = (options = {}) => {
6
6
  const { exclude = [], syntax_styler = syntax_styler_global, cache = true, component_imports = ['@fuzdev/fuz_code/Code.svelte'], on_error = process.env.CI ? 'throw' : 'log', } = options;
7
7
  // In-memory cache: content+lang hash → highlighted HTML
8
8
  const highlight_cache = new Map();
9
9
  return {
10
- name: 'code-static',
10
+ name: 'fuz-code',
11
11
  markup: ({ content, filename }) => {
12
12
  // Skip excluded files
13
13
  if (should_exclude(filename, exclude)) {
@@ -251,7 +251,7 @@ const escape_js_string = (html) => {
251
251
  * Handle errors during highlighting.
252
252
  */
253
253
  const handle_error = (error, options) => {
254
- const message = `[code-static] Highlighting failed${options.filename ? ` in ${options.filename}` : ''}: ${error instanceof Error ? error.message : String(error)}`;
254
+ const message = `[fuz-code] Highlighting failed${options.filename ? ` in ${options.filename}` : ''}: ${error instanceof Error ? error.message : String(error)}`;
255
255
  if (options.on_error === 'throw') {
256
256
  throw new Error(message);
257
257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_code",
3
- "version": "0.41.1",
3
+ "version": "0.42.0",
4
4
  "description": "syntax styling utilities and components for TypeScript, Svelte, and Markdown",
5
5
  "glyph": "🎨",
6
6
  "logo": "logo.svg",
@@ -5,7 +5,7 @@ import {walk} from 'zimmerframe';
5
5
  import {syntax_styler_global} from './syntax_styler_global.js';
6
6
  import type {SyntaxStyler} from './syntax_styler.js';
7
7
 
8
- export interface PreprocessCodeStaticOptions {
8
+ export interface PreprocessFuzCodeOptions {
9
9
  /** File patterns to exclude. */
10
10
  exclude?: Array<string | RegExp>;
11
11
 
@@ -30,8 +30,8 @@ export interface PreprocessCodeStaticOptions {
30
30
  on_error?: 'log' | 'throw';
31
31
  }
32
32
 
33
- export const svelte_preprocess_code_static = (
34
- options: PreprocessCodeStaticOptions = {},
33
+ export const svelte_preprocess_fuz_code = (
34
+ options: PreprocessFuzCodeOptions = {},
35
35
  ): PreprocessorGroup => {
36
36
  const {
37
37
  exclude = [],
@@ -45,7 +45,7 @@ export const svelte_preprocess_code_static = (
45
45
  const highlight_cache: Map<string, string> = new Map();
46
46
 
47
47
  return {
48
- name: 'code-static',
48
+ name: 'fuz-code',
49
49
 
50
50
  markup: ({content, filename}) => {
51
51
  // Skip excluded files
@@ -340,7 +340,7 @@ const escape_js_string = (html: string): string => {
340
340
  * Handle errors during highlighting.
341
341
  */
342
342
  const handle_error = (error: unknown, options: FindCodeUsagesOptions): void => {
343
- const message = `[code-static] Highlighting failed${options.filename ? ` in ${options.filename}` : ''}: ${error instanceof Error ? error.message : String(error)}`;
343
+ const message = `[fuz-code] Highlighting failed${options.filename ? ` in ${options.filename}` : ''}: ${error instanceof Error ? error.message : String(error)}`;
344
344
 
345
345
  if (options.on_error === 'throw') {
346
346
  throw new Error(message);
@@ -1 +0,0 @@
1
- {"version":3,"file":"svelte_preprocess_code_static.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/svelte_preprocess_code_static.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,iBAAiB,EAAW,MAAM,iBAAiB,CAAC;AAKxE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,2BAA2B;IAC3C,gCAAgC;IAChC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAEjC,0DAA0D;IAC1D,aAAa,CAAC,EAAE,YAAY,CAAC;IAE7B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,6BAA6B,GACzC,UAAS,2BAAgC,KACvC,iBA0DF,CAAC"}