@hyperfixi/vite-plugin 2.3.1 → 2.4.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/index.d.cts CHANGED
@@ -111,7 +111,7 @@ interface HyperfixiPluginOptions {
111
111
  * - 'slavic': pl, ru, uk
112
112
  * - 'south-asian': hi, bn
113
113
  * - 'priority': 13 most common languages
114
- * - 'all': All 21 supported languages
114
+ * - 'all': All 24 supported languages
115
115
  */
116
116
  region?: 'western' | 'east-asian' | 'slavic' | 'south-asian' | 'priority' | 'all';
117
117
  /**
@@ -209,6 +209,29 @@ interface HtmxUsage {
209
209
  urlManagement: Set<string>;
210
210
  /** Whether hx-confirm is used */
211
211
  usesConfirm: boolean;
212
+ /**
213
+ * htmx v4 reactive/streaming surface detected. Each flag pulls in the
214
+ * corresponding bundle module; collectively they're what makes
215
+ * `hyperfixi-hx-v4.js` the right premade choice when none would do.
216
+ *
217
+ * Optional to keep older fixture literals (and callers that ignore
218
+ * htmx v4) compatible. Scanner code always emits explicit `false`.
219
+ */
220
+ needsHxLive?: boolean;
221
+ /** sse-connect / sse-swap detected. Pulls in `@hyperfixi/core/htmx/sse`. */
222
+ needsSSE?: boolean;
223
+ /** ws-connect / ws-send detected. Pulls in `@hyperfixi/core/htmx/ws`. */
224
+ needsWS?: boolean;
225
+ /**
226
+ * `bind $x to <expr>.<prop>` detected inside an `_=` attribute. Implies
227
+ * reactivity (the bind feature lives in `@hyperfixi/reactivity`).
228
+ */
229
+ needsBindToProperty?: boolean;
230
+ /**
231
+ * Any hx-v4-class feature → vite-generated bundle should auto-install
232
+ * `@hyperfixi/reactivity`. Derived from needsHxLive || needsBindToProperty.
233
+ */
234
+ needsReactivity?: boolean;
212
235
  }
213
236
  /**
214
237
  * Usage information detected from a single file
@@ -224,6 +247,26 @@ interface FileUsage {
224
247
  detectedLanguages: Set<string>;
225
248
  /** HTMX/Fixi attribute usage (if detected) */
226
249
  htmx?: HtmxUsage;
250
+ /**
251
+ * Reactivity-requiring constructs detected directly inside `_=` script
252
+ * bodies (independent of htmx attributes). Today: `bind` features
253
+ * (`live`/`when`/`bind`/`^var`). When true, the generated bundle should
254
+ * auto-install `@hyperfixi/reactivity`.
255
+ *
256
+ * Kept top-level rather than under `htmx` because authors may use these
257
+ * features without any htmx attributes at all (pure `_=` reactive code).
258
+ * The aggregator OR-merges this with `htmx.needsReactivity`.
259
+ *
260
+ * Optional so older callers / fixtures that build `FileUsage` literals
261
+ * without these fields stay valid; the scanner always emits explicit
262
+ * `false` so reads can rely on the value being defined post-scan.
263
+ */
264
+ needsReactivity?: boolean;
265
+ /**
266
+ * Explicit-property `bind` form (`bind $x to <expr>.<prop>`) detected
267
+ * in an `_=` body. Implies `needsReactivity` too.
268
+ */
269
+ needsBindToProperty?: boolean;
227
270
  }
228
271
  /**
229
272
  * Aggregated usage information across all files
@@ -239,6 +282,17 @@ interface AggregatedUsage {
239
282
  detectedLanguages: Set<string>;
240
283
  /** Aggregated HTMX/Fixi usage across all files */
241
284
  htmx: HtmxUsage;
285
+ /**
286
+ * Whether any file uses reactivity-requiring constructs (either via
287
+ * `hx-live` attributes or inside `_=` scripts). Drives the generated
288
+ * bundle's auto-install of `@hyperfixi/reactivity`.
289
+ *
290
+ * Optional to keep test fixtures compatible; the aggregator always
291
+ * emits an explicit boolean.
292
+ */
293
+ needsReactivity?: boolean;
294
+ /** Whether any file uses explicit-property bind. */
295
+ needsBindToProperty?: boolean;
242
296
  /** Map of file paths to their usage */
243
297
  fileUsage: Map<string, FileUsage>;
244
298
  }
@@ -392,35 +446,41 @@ declare class DomainAggregator {
392
446
  */
393
447
 
394
448
  /**
395
- * Semantic analyzer interface for multilingual support.
396
- * This matches the interface from @lokascript/semantic.
449
+ * Result shape returned by the semantic parse function.
450
+ * Matches `ParseWithConfidenceResult` from `@lokascript/semantic`.
397
451
  */
398
- interface SemanticAnalysisResult {
452
+ interface SemanticParseResult {
399
453
  confidence: number;
400
454
  node?: unknown;
401
- errors?: string[];
402
- }
403
- interface SemanticAnalyzer {
404
- analyze(input: string, language: string): SemanticAnalysisResult;
405
- supportsLanguage(language: string): boolean;
455
+ error?: string | undefined;
406
456
  }
457
+ /**
458
+ * Function that parses input in a given language and returns a confidence
459
+ * score plus an optional semantic node. Matches `parseSemantic` / `parseWithConfidence`
460
+ * from `@lokascript/semantic`.
461
+ */
462
+ type SemanticParseFn = (input: string, language: string) => SemanticParseResult;
463
+ /**
464
+ * Function that checks whether a language is registered for parsing.
465
+ * Matches `isLanguageRegistered` from `@lokascript/semantic`.
466
+ */
467
+ type SupportsLanguageFn = (language: string) => boolean;
407
468
  type BuildASTFn = (node: unknown) => {
408
469
  ast: ASTNode;
409
470
  warnings: string[];
410
471
  };
411
472
  /**
412
473
  * Configure the semantic parser for multilingual compilation.
413
- * Call this with the semantic analyzer from @lokascript/semantic.
414
474
  *
415
475
  * @example
416
476
  * ```typescript
417
- * import { createSemanticAnalyzer, buildAST } from '@lokascript/semantic';
477
+ * import { parseSemantic, isLanguageRegistered, buildAST } from '@lokascript/semantic';
418
478
  * import { setSemanticParser } from '@hyperfixi/vite-plugin';
419
479
  *
420
- * setSemanticParser(createSemanticAnalyzer(), buildAST);
480
+ * setSemanticParser(parseSemantic, isLanguageRegistered, buildAST);
421
481
  * ```
422
482
  */
423
- declare function setSemanticParser(analyzer: SemanticAnalyzer, buildAST: BuildASTFn): void;
483
+ declare function setSemanticParser(parse: SemanticParseFn, supports: SupportsLanguageFn, buildAST: BuildASTFn): void;
424
484
  /**
425
485
  * Clear the semantic parser (for testing).
426
486
  */
@@ -462,7 +522,7 @@ interface CompileOptions {
462
522
  /**
463
523
  * Language Keywords for Detection
464
524
  *
465
- * Maps of keywords for each of the 21 supported languages.
525
+ * Maps of keywords for each of the 24 supported languages.
466
526
  * Used by the scanner to detect which languages are used in hyperscript templates.
467
527
  *
468
528
  * Note: These are a representative subset of keywords - enough to reliably
@@ -472,7 +532,7 @@ interface CompileOptions {
472
532
  /**
473
533
  * All supported language codes.
474
534
  */
475
- declare const SUPPORTED_LANGUAGES: readonly ["en", "es", "pt", "fr", "de", "it", "vi", "pl", "ru", "uk", "ja", "zh", "ko", "ar", "hi", "bn", "th", "tr", "id", "sw", "qu", "tl"];
535
+ declare const SUPPORTED_LANGUAGES: readonly ["en", "es", "pt", "fr", "de", "it", "vi", "pl", "ru", "uk", "ja", "zh", "ko", "ar", "he", "hi", "bn", "th", "tr", "id", "ms", "sw", "qu", "tl"];
476
536
  type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
477
537
  /**
478
538
  * Regional bundle mappings.
package/dist/index.d.ts CHANGED
@@ -111,7 +111,7 @@ interface HyperfixiPluginOptions {
111
111
  * - 'slavic': pl, ru, uk
112
112
  * - 'south-asian': hi, bn
113
113
  * - 'priority': 13 most common languages
114
- * - 'all': All 21 supported languages
114
+ * - 'all': All 24 supported languages
115
115
  */
116
116
  region?: 'western' | 'east-asian' | 'slavic' | 'south-asian' | 'priority' | 'all';
117
117
  /**
@@ -209,6 +209,29 @@ interface HtmxUsage {
209
209
  urlManagement: Set<string>;
210
210
  /** Whether hx-confirm is used */
211
211
  usesConfirm: boolean;
212
+ /**
213
+ * htmx v4 reactive/streaming surface detected. Each flag pulls in the
214
+ * corresponding bundle module; collectively they're what makes
215
+ * `hyperfixi-hx-v4.js` the right premade choice when none would do.
216
+ *
217
+ * Optional to keep older fixture literals (and callers that ignore
218
+ * htmx v4) compatible. Scanner code always emits explicit `false`.
219
+ */
220
+ needsHxLive?: boolean;
221
+ /** sse-connect / sse-swap detected. Pulls in `@hyperfixi/core/htmx/sse`. */
222
+ needsSSE?: boolean;
223
+ /** ws-connect / ws-send detected. Pulls in `@hyperfixi/core/htmx/ws`. */
224
+ needsWS?: boolean;
225
+ /**
226
+ * `bind $x to <expr>.<prop>` detected inside an `_=` attribute. Implies
227
+ * reactivity (the bind feature lives in `@hyperfixi/reactivity`).
228
+ */
229
+ needsBindToProperty?: boolean;
230
+ /**
231
+ * Any hx-v4-class feature → vite-generated bundle should auto-install
232
+ * `@hyperfixi/reactivity`. Derived from needsHxLive || needsBindToProperty.
233
+ */
234
+ needsReactivity?: boolean;
212
235
  }
213
236
  /**
214
237
  * Usage information detected from a single file
@@ -224,6 +247,26 @@ interface FileUsage {
224
247
  detectedLanguages: Set<string>;
225
248
  /** HTMX/Fixi attribute usage (if detected) */
226
249
  htmx?: HtmxUsage;
250
+ /**
251
+ * Reactivity-requiring constructs detected directly inside `_=` script
252
+ * bodies (independent of htmx attributes). Today: `bind` features
253
+ * (`live`/`when`/`bind`/`^var`). When true, the generated bundle should
254
+ * auto-install `@hyperfixi/reactivity`.
255
+ *
256
+ * Kept top-level rather than under `htmx` because authors may use these
257
+ * features without any htmx attributes at all (pure `_=` reactive code).
258
+ * The aggregator OR-merges this with `htmx.needsReactivity`.
259
+ *
260
+ * Optional so older callers / fixtures that build `FileUsage` literals
261
+ * without these fields stay valid; the scanner always emits explicit
262
+ * `false` so reads can rely on the value being defined post-scan.
263
+ */
264
+ needsReactivity?: boolean;
265
+ /**
266
+ * Explicit-property `bind` form (`bind $x to <expr>.<prop>`) detected
267
+ * in an `_=` body. Implies `needsReactivity` too.
268
+ */
269
+ needsBindToProperty?: boolean;
227
270
  }
228
271
  /**
229
272
  * Aggregated usage information across all files
@@ -239,6 +282,17 @@ interface AggregatedUsage {
239
282
  detectedLanguages: Set<string>;
240
283
  /** Aggregated HTMX/Fixi usage across all files */
241
284
  htmx: HtmxUsage;
285
+ /**
286
+ * Whether any file uses reactivity-requiring constructs (either via
287
+ * `hx-live` attributes or inside `_=` scripts). Drives the generated
288
+ * bundle's auto-install of `@hyperfixi/reactivity`.
289
+ *
290
+ * Optional to keep test fixtures compatible; the aggregator always
291
+ * emits an explicit boolean.
292
+ */
293
+ needsReactivity?: boolean;
294
+ /** Whether any file uses explicit-property bind. */
295
+ needsBindToProperty?: boolean;
242
296
  /** Map of file paths to their usage */
243
297
  fileUsage: Map<string, FileUsage>;
244
298
  }
@@ -392,35 +446,41 @@ declare class DomainAggregator {
392
446
  */
393
447
 
394
448
  /**
395
- * Semantic analyzer interface for multilingual support.
396
- * This matches the interface from @lokascript/semantic.
449
+ * Result shape returned by the semantic parse function.
450
+ * Matches `ParseWithConfidenceResult` from `@lokascript/semantic`.
397
451
  */
398
- interface SemanticAnalysisResult {
452
+ interface SemanticParseResult {
399
453
  confidence: number;
400
454
  node?: unknown;
401
- errors?: string[];
402
- }
403
- interface SemanticAnalyzer {
404
- analyze(input: string, language: string): SemanticAnalysisResult;
405
- supportsLanguage(language: string): boolean;
455
+ error?: string | undefined;
406
456
  }
457
+ /**
458
+ * Function that parses input in a given language and returns a confidence
459
+ * score plus an optional semantic node. Matches `parseSemantic` / `parseWithConfidence`
460
+ * from `@lokascript/semantic`.
461
+ */
462
+ type SemanticParseFn = (input: string, language: string) => SemanticParseResult;
463
+ /**
464
+ * Function that checks whether a language is registered for parsing.
465
+ * Matches `isLanguageRegistered` from `@lokascript/semantic`.
466
+ */
467
+ type SupportsLanguageFn = (language: string) => boolean;
407
468
  type BuildASTFn = (node: unknown) => {
408
469
  ast: ASTNode;
409
470
  warnings: string[];
410
471
  };
411
472
  /**
412
473
  * Configure the semantic parser for multilingual compilation.
413
- * Call this with the semantic analyzer from @lokascript/semantic.
414
474
  *
415
475
  * @example
416
476
  * ```typescript
417
- * import { createSemanticAnalyzer, buildAST } from '@lokascript/semantic';
477
+ * import { parseSemantic, isLanguageRegistered, buildAST } from '@lokascript/semantic';
418
478
  * import { setSemanticParser } from '@hyperfixi/vite-plugin';
419
479
  *
420
- * setSemanticParser(createSemanticAnalyzer(), buildAST);
480
+ * setSemanticParser(parseSemantic, isLanguageRegistered, buildAST);
421
481
  * ```
422
482
  */
423
- declare function setSemanticParser(analyzer: SemanticAnalyzer, buildAST: BuildASTFn): void;
483
+ declare function setSemanticParser(parse: SemanticParseFn, supports: SupportsLanguageFn, buildAST: BuildASTFn): void;
424
484
  /**
425
485
  * Clear the semantic parser (for testing).
426
486
  */
@@ -462,7 +522,7 @@ interface CompileOptions {
462
522
  /**
463
523
  * Language Keywords for Detection
464
524
  *
465
- * Maps of keywords for each of the 21 supported languages.
525
+ * Maps of keywords for each of the 24 supported languages.
466
526
  * Used by the scanner to detect which languages are used in hyperscript templates.
467
527
  *
468
528
  * Note: These are a representative subset of keywords - enough to reliably
@@ -472,7 +532,7 @@ interface CompileOptions {
472
532
  /**
473
533
  * All supported language codes.
474
534
  */
475
- declare const SUPPORTED_LANGUAGES: readonly ["en", "es", "pt", "fr", "de", "it", "vi", "pl", "ru", "uk", "ja", "zh", "ko", "ar", "hi", "bn", "th", "tr", "id", "sw", "qu", "tl"];
535
+ declare const SUPPORTED_LANGUAGES: readonly ["en", "es", "pt", "fr", "de", "it", "vi", "pl", "ru", "uk", "ja", "zh", "ko", "ar", "he", "hi", "bn", "th", "tr", "id", "ms", "sw", "qu", "tl"];
476
536
  type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
477
537
  /**
478
538
  * Regional bundle mappings.