domflax 0.1.0 → 0.1.2

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.
Files changed (39) hide show
  1. package/README.md +159 -0
  2. package/dist/{chunk-4HHISSMR.js → chunk-DNHOGPYV.js} +2675 -1503
  3. package/dist/chunk-DNHOGPYV.js.map +1 -0
  4. package/dist/{chunk-ZJ2S36GY.js → chunk-DOQEBGWB.js} +33 -20
  5. package/dist/chunk-DOQEBGWB.js.map +1 -0
  6. package/dist/{chunk-77SLHRN6.js → chunk-DWLB7FRR.js} +341 -176
  7. package/dist/chunk-DWLB7FRR.js.map +1 -0
  8. package/dist/cli.cjs +2209 -774
  9. package/dist/cli.cjs.map +1 -1
  10. package/dist/cli.js +234 -116
  11. package/dist/cli.js.map +1 -1
  12. package/dist/index.cjs +3021 -1699
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +477 -54
  15. package/dist/index.d.ts +477 -54
  16. package/dist/index.js +49 -3
  17. package/dist/pattern-CV607P87.d.ts +547 -0
  18. package/dist/pattern-F5xBtIE-.d.cts +547 -0
  19. package/dist/pattern-kit.cjs +60 -39
  20. package/dist/pattern-kit.cjs.map +1 -1
  21. package/dist/pattern-kit.d.cts +3 -18
  22. package/dist/pattern-kit.d.ts +3 -18
  23. package/dist/pattern-kit.js +3 -1
  24. package/dist/pattern-kit.js.map +1 -1
  25. package/dist/{types-BQ7l6dVe.d.ts → resolve-ops-DIwEelH-.d.cts} +26 -251
  26. package/dist/{types-BQ7l6dVe.d.cts → resolve-ops-DIwEelH-.d.ts} +26 -251
  27. package/dist/verify.d.cts +1 -1
  28. package/dist/verify.d.ts +1 -1
  29. package/dist/webpack-loader.cjs +2975 -1699
  30. package/dist/webpack-loader.cjs.map +1 -1
  31. package/dist/webpack-loader.d.cts +2 -2
  32. package/dist/webpack-loader.d.ts +2 -2
  33. package/dist/webpack-loader.js +3 -3
  34. package/package.json +3 -6
  35. package/dist/chunk-4HHISSMR.js.map +0 -1
  36. package/dist/chunk-77SLHRN6.js.map +0 -1
  37. package/dist/chunk-ZJ2S36GY.js.map +0 -1
  38. package/dist/pattern-CX6iBzTD.d.ts +0 -237
  39. package/dist/pattern-P4FIKAUB.d.cts +0 -237
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @domflax/core — public type contract (packages/core/src/types.ts)
2
+ * @domflax/core — type contract, part 1/3: IR + style primitives.
3
3
  *
4
- * SINGLE SOURCE OF TRUTH for the whole monorepo. Pure type/interface declarations
5
- * only: ZERO runtime. Every downstream package imports these exact names.
4
+ * Pure type/interface declarations only: ZERO runtime. Covers type utilities, identity
5
+ * primitives, source spans, the StyleMap model, NodeMeta, author tokens, the IR node union,
6
+ * the expr registry / document, traversal types, and node specs. This is the bottom layer of
7
+ * the type contract — it imports nothing from the sibling type modules.
6
8
  *
7
- * Compiles under: strict, verbatimModuleSyntax, isolatedDeclarations, erasableSyntaxOnly,
8
- * isolatedModules. No `const enum` (TS6 erasableSyntaxOnly): every closed set is a
9
- * string/number literal UNION here; the matching frozen `as const` runtime objects live in
10
- * sibling runtime modules (constants.ts), not in this file.
9
+ * (`PassPhase`/`PassCategory` live here too, in the primitive layer, so the resolver/op modules
10
+ * can reference them without a cycle through the pass-contract module.)
11
11
  */
12
12
  type Brand<T, B extends string> = T & {
13
13
  readonly __brand: B;
@@ -34,6 +34,8 @@ interface IdAllocator {
34
34
  }
35
35
  /** SAFETY: 0 lint · 1 safe · 2 default · 3 aggressive. (Runtime `SAFETY` object lives in constants.ts.) */
36
36
  type SafetyLevel = 0 | 1 | 2 | 3;
37
+ type PassPhase = 'flatten' | 'compress' | 'extract';
38
+ type PassCategory = `${PassPhase}/${string}`;
37
39
  interface Position {
38
40
  readonly line: number;
39
41
  readonly column: number;
@@ -301,6 +303,15 @@ interface NodeRefSpec {
301
303
  readonly ref: IRNodeId;
302
304
  }
303
305
  type NodeSpec = ElementSpec | TextSpec | ExprSpec | FragmentSpec | CommentSpec | NodeRefSpec;
306
+
307
+ /**
308
+ * @domflax/core — type contract, part 2/3: diagnostics, the style-resolver layer, the selector
309
+ * index, and the RewriteOp union + factory.
310
+ *
311
+ * Pure type/interface declarations only: ZERO runtime. Depends only on the IR/style primitives in
312
+ * `./ir`.
313
+ */
314
+
304
315
  type Severity = 'error' | 'warn' | 'info' | 'debug';
305
316
  type DiagnosticCode = 'DF_PATTERN_THREW' | 'DF_OP_PRECONDITION_FAILED' | 'DF_CROSSED_DYNAMIC_BOUNDARY' | 'DF_SAFETY_CEILING_EXCEEDED' | 'DF_STYLE_CONFLICT_UNRESOLVED' | 'DF_FIXPOINT_BUDGET' | 'DF_FIXPOINT_OSCILLATION' | 'DF_NON_INHERITABLE_FOLD' | 'DF_RELATIVE_UNIT_FOLD' | 'DF_CUSTOM_PROP_COUPLING' | 'DF_STRUCTURAL_PSEUDO_TARGET' | 'DF_SELECTOR_MEMBERSHIP' | 'DF_NODE_REMOVED' | 'DF_PATTERN_APPLIED' | 'DF_VERIFY_REVERTED' | 'DF_VERIFY_INCONCLUSIVE';
306
317
  interface Diagnostic {
@@ -393,6 +404,13 @@ interface StyleResolver {
393
404
  emit(styles: StyleMap, ctx: EmitContext): EmitResult;
394
405
  /** Reports every project selector referencing a class — compress safety (review-1 major). */
395
406
  selectorUsage(token: string): SelectorUsage;
407
+ /**
408
+ * OPTIONAL: produce a CSS stylesheet that defines the given class tokens, so a verifier can render
409
+ * a subtree with the provider's real styling applied. Tailwind generates the rules from its engine;
410
+ * the custom-CSS resolver returns its source stylesheets. Resolvers that cannot (the null/fake test
411
+ * resolvers) simply omit this — the verifier then falls back to inlining each element's computed style.
412
+ */
413
+ cssFor?(classes: readonly string[]): string;
396
414
  }
397
415
  interface SelectorIndex {
398
416
  targetedByCombinator(id: IRNodeId): boolean;
@@ -502,248 +520,5 @@ interface RewriteFactory {
502
520
  text(value: string): NodeSpec;
503
521
  keep(node: NodeLike): NodeSpec;
504
522
  }
505
- type PassPhase = 'flatten' | 'compress' | 'extract';
506
- type PassCategory = `${PassPhase}/${string}`;
507
- type Captures = Record<string, unknown>;
508
- /** Read-only style predicate over a normalized StyleMap (queries MEANING, not strings). */
509
- type StylePredicate = (sm: StyleMap) => boolean;
510
- /**
511
- * Relational precondition (review-2 blocker): describes ancestor/sibling/child subtree shape AND
512
- * ancestor LAYOUT context (review-4 blocker) so fuzzProve generates trees that exercise the
513
- * relational + parent-constraint branches, not just node-local ones.
514
- */
515
- interface TreeShapeSketch {
516
- readonly tag?: string | readonly string[];
517
- readonly requiredComputed?: Readonly<Record<string, string>>;
518
- readonly meta?: Partial<Record<keyof NodeMeta, boolean>>;
519
- readonly children?: readonly TreeShapeSketch[];
520
- }
521
- type ParentLayoutContext = 'block-flow' | 'flex-item' | 'flex-item-stretch' | 'grid-item' | 'fixed-size-ancestor' | 'percentage-sized-child' | 'inline-context';
522
- interface PreconditionSketch {
523
- readonly requiredComputed?: Readonly<Record<string, string>>;
524
- readonly childCount?: {
525
- readonly min?: number;
526
- readonly max?: number;
527
- };
528
- readonly forbid?: readonly string[];
529
- readonly ancestor?: TreeShapeSketch;
530
- readonly siblings?: readonly TreeShapeSketch[];
531
- readonly childShapes?: readonly TreeShapeSketch[];
532
- readonly parentContexts?: readonly ParentLayoutContext[];
533
- }
534
- interface PatternDoc {
535
- readonly title: string;
536
- readonly summary: string;
537
- readonly before?: string;
538
- readonly after?: string;
539
- readonly safetyRationale?: string;
540
- }
541
- /** Result of a successful match: op drafts (origin stamped later) + optional captures/diagnostics. */
542
- interface MatchResult<C extends Captures = Captures> {
543
- readonly ops: readonly RewriteOpDraft[];
544
- readonly captures?: C;
545
- readonly diagnostics?: readonly Diagnostic[];
546
- }
547
- interface MatchContext {
548
- readonly node: DeepReadonly<IRElement>;
549
- readonly doc: DeepReadonly<IRDocument>;
550
- readonly resolver: StyleResolver;
551
- readonly selectors: SelectorIndex;
552
- readonly safety: SafetyLevel;
553
- readonly phase: PassPhase;
554
- readonly iteration: number;
555
- parent(): DeepReadonly<IRElement> | null;
556
- elementChildren(): readonly DeepReadonly<IRElement>[];
557
- onlyElementChild(): DeepReadonly<IRElement> | null;
558
- computed(): StyleMap;
559
- computedOf(n: NodeLike): StyleMap;
560
- isOpaque(n?: ElementLike): boolean;
561
- ancestors(): readonly DeepReadonly<IRElement>[];
562
- closest(pred: (el: DeepReadonly<IRElement>) => boolean): DeepReadonly<IRElement> | null;
563
- prevSibling(): DeepReadonly<IRNode> | null;
564
- nextSibling(): DeepReadonly<IRNode> | null;
565
- nthChildIndex(): number;
566
- }
567
- /** Context handed to the `rewrite` phase: a MatchContext plus the typed captures. */
568
- interface RewriteContext<C extends Captures = Captures> extends MatchContext {
569
- readonly captures: C;
570
- }
571
- interface Pattern {
572
- readonly name: PatternName;
573
- readonly category: PassCategory;
574
- readonly safety: SafetyLevel;
575
- readonly priority?: number;
576
- readonly precondition?: PreconditionSketch;
577
- readonly doc?: PatternDoc;
578
- /** Pure. Returns a MatchResult (op drafts) or null on no-match. MUST NOT mutate. */
579
- evaluate(ctx: MatchContext, rw: RewriteFactory): MatchResult | null;
580
- }
581
- interface Pass {
582
- readonly phase: PassPhase;
583
- readonly category: PassCategory;
584
- readonly patterns: readonly Pattern[];
585
- }
586
- interface FixpointConfig {
587
- readonly maxIterations: number;
588
- readonly phases: Partial<Record<PassPhase, number>>;
589
- readonly onBudgetExhausted: 'warn' | 'error';
590
- readonly detectOscillation: boolean;
591
- }
592
- type HaltReason = 'converged' | 'budget' | 'oscillation' | 'error';
593
- interface PhaseRunResult {
594
- readonly phase: PassPhase;
595
- readonly iterations: number;
596
- readonly converged: boolean;
597
- readonly haltReason: HaltReason;
598
- readonly touched: ReadonlySet<IRNodeId>;
599
- readonly diagnostics: readonly Diagnostic[];
600
- }
601
- interface RewriteGroup {
602
- readonly pattern: PatternName;
603
- readonly anchor: IRNodeId;
604
- readonly ops: readonly RewriteOp[];
605
- }
606
- interface ApplyContext {
607
- readonly doc: IRDocument;
608
- readonly safetyCeiling: SafetyLevel;
609
- readonly normalizer: StyleNormalizer;
610
- readonly selectors: SelectorIndex;
611
- readonly resolver: StyleResolver;
612
- }
613
- interface StructuralInverse {
614
- readonly kind: 'structural';
615
- readonly describe: string;
616
- readonly snapshot: unknown;
617
- }
618
- interface AppliedOp {
619
- readonly op: RewriteOp;
620
- readonly inverse: RewriteOp | StructuralInverse;
621
- }
622
- interface OpValidationIssue {
623
- readonly op: RewriteOp;
624
- readonly code: DiagnosticCode;
625
- readonly message: string;
626
- }
627
- interface SkippedOpGroup {
628
- readonly group: RewriteGroup;
629
- readonly issues: readonly OpValidationIssue[];
630
- }
631
- interface ApplyResult {
632
- readonly touched: ReadonlySet<IRNodeId>;
633
- readonly removed: ReadonlySet<IRNodeId>;
634
- readonly created: ReadonlySet<IRNodeId>;
635
- readonly appliedGroups: number;
636
- readonly skipped: readonly SkippedOpGroup[];
637
- readonly journal: readonly AppliedOp[];
638
- readonly diagnostics: readonly Diagnostic[];
639
- }
640
- interface PassManager {
641
- run(doc: IRDocument, ctx: ApplyContext, config?: FixpointConfig): readonly PhaseRunResult[];
642
- }
643
- interface FrontendConfig {
644
- readonly jsxImportSource?: string;
645
- readonly preserveComments?: boolean;
646
- readonly [key: string]: unknown;
647
- }
648
- interface FrontendParseContext {
649
- readonly id: string;
650
- readonly kind: FileKind;
651
- readonly resolver: StyleResolver;
652
- readonly normalizer: StyleNormalizer;
653
- readonly config: FrontendConfig;
654
- onDiagnostic(d: Diagnostic): void;
655
- babelAst?: unknown;
656
- }
657
- interface ParseResult {
658
- readonly doc: IRDocument;
659
- readonly diagnostics: readonly Diagnostic[];
660
- }
661
- interface Frontend {
662
- readonly name: string;
663
- readonly langs: readonly FileKind[];
664
- canParse(id: string, code: string): boolean;
665
- parse(code: string, ctx: FrontendParseContext): ParseResult;
666
- }
667
- interface ReindentSpec {
668
- readonly baseIndent: string;
669
- readonly delta: number;
670
- }
671
- interface TextEdit {
672
- readonly span: SourceSpan;
673
- readonly replacement: string;
674
- readonly reindent?: ReindentSpec;
675
- readonly origin: string;
676
- }
677
- interface EditPlan {
678
- readonly moduleId: string;
679
- readonly ops: readonly RewriteOp[];
680
- readonly provenance: ReadonlyMap<number, PatternName>;
681
- }
682
- interface EncodedSourceMap {
683
- readonly version: 3;
684
- readonly sources: readonly string[];
685
- readonly sourcesContent?: readonly (string | null)[];
686
- readonly names: readonly string[];
687
- readonly mappings: string;
688
- readonly file?: string;
689
- }
690
- interface BackendContext {
691
- readonly normalizer: StyleNormalizer;
692
- readonly resolver: StyleResolver;
693
- readonly sink: SyntheticSink;
694
- readonly eol: '\n' | '\r\n';
695
- onDiagnostic(d: Diagnostic): void;
696
- }
697
- interface CodegenResult {
698
- readonly code: string;
699
- readonly map: EncodedSourceMap | null;
700
- readonly edits: readonly TextEdit[];
701
- readonly diagnostics: readonly Diagnostic[];
702
- }
703
- interface Backend {
704
- readonly name: string;
705
- readonly langs: readonly FileKind[];
706
- print(doc: IRDocument, plan: EditPlan, ctx: BackendContext): CodegenResult;
707
- }
708
- interface PipelineConfig {
709
- readonly safety: SafetyLevel;
710
- readonly fixpoint?: Partial<FixpointConfig>;
711
- readonly preserveComments?: boolean;
712
- readonly emitSourceMap?: boolean;
713
- }
714
- interface PipelineInput {
715
- readonly code: string;
716
- readonly id: string;
717
- readonly kind: FileKind;
718
- readonly frontend: Frontend;
719
- readonly backend: Backend;
720
- readonly resolver: StyleResolver;
721
- readonly normalizer: StyleNormalizer;
722
- readonly passes: readonly Pass[];
723
- readonly config?: PipelineConfig;
724
- readonly reporter?: Reporter;
725
- readonly babelAst?: unknown;
726
- }
727
- interface PipelineStats {
728
- readonly nodesIn: number;
729
- readonly nodesOut: number;
730
- readonly opsApplied: number;
731
- readonly iterations: Readonly<Record<PassPhase, number>>;
732
- readonly durationMs: number;
733
- }
734
- interface PipelineOutput {
735
- readonly code: string;
736
- readonly map: EncodedSourceMap | null;
737
- readonly changed: boolean;
738
- readonly touched: readonly SourceSpan[];
739
- readonly diagnostics: readonly Diagnostic[];
740
- readonly stats: PipelineStats;
741
- readonly doc: IRDocument;
742
- readonly editPlan: EditPlan;
743
- }
744
- /** The pure single-file pipeline. Adapters/orchestrator call this; the verifier reuses it. */
745
- interface Pipeline {
746
- run(input: PipelineInput): PipelineOutput;
747
- }
748
523
 
749
- export type { EncodedSourceMap as $, AttrMap as A, BackrefTable as B, CssProperty as C, PreconditionSketch as D, ElementLike as E, FrontendKind as F, PatternDoc as G, Diagnostic as H, IRNodeId as I, ApplyResult as J, RewriteGroup as K, ApplyContext as L, MatchContext as M, NodeLike as N, RewriteOp as O, Pattern as P, FixpointConfig as Q, RewriteOpDraft as R, StyleMap as S, StyleResolver as T, SelectorIndex as U, Visitor as V, Pass as W, PassManager as X, PhaseRunResult as Y, Pipeline as Z, SyntheticSink as _, StyleConflictPolicy as a, TextEdit as a$, AppliedOp as a0, AttrValue as a1, Backend as a2, BackendContext as a3, Brand as a4, ClassListForm as a5, ClassSegment as a6, ClassToken as a7, CodegenResult as a8, CommentSpec as a9, ParentLayoutContext as aA, ParseResult as aB, PassPhase as aC, PassTraceEntry as aD, PatternName as aE, PipelineConfig as aF, PipelineInput as aG, PipelineOutput as aH, PipelineStats as aI, Position as aJ, ReindentSpec as aK, Reporter as aL, ResolveInput as aM, ResolveResult as aN, ResolverDiagnostic as aO, RewriteContext as aP, SelectorUsage as aQ, Severity as aR, SkippedOpGroup as aS, SourceFile as aT, SourceFileId as aU, StructuralInverse as aV, StyleBlock as aW, StyleDecl as aX, StyleOrigin as aY, StylePredicate as aZ, SyntheticClass as a_, CssValue as aa, DeclSignature as ab, DeepReadonly as ac, DiagnosticCode as ad, DistributiveOmit as ae, EditPlan as af, ElementSpec as ag, EmitContext as ah, EmitResult as ai, ExprKind as aj, ExprRecord as ak, ExprSpec as al, FileKind as am, FragmentSpec as an, Frontend as ao, FrontendConfig as ap, FrontendParseContext as aq, HaltReason as ar, IRNodeBase as as, IRNodeKind as at, InheritedPropertyTable as au, NodeRefSpec as av, OpOrigin as aw, OpValidationIssue as ax, OpaqueReason as ay, OpaqueToken as az, NodeSpec as b, TextSpec as b0, TreeShapeSketch as b1, VisitContext as b2, VisitSignal as b3, StyleNormalizer as c, StyleCondition as d, ConditionKey as e, IRNamespace as f, ClassList as g, InlineStyle as h, SourceSpan as i, NodeMeta as j, Backref as k, IRNode as l, IRComment as m, IRDocument as n, IRElement as o, ExprRef as p, IRExpr as q, ExprRegistry as r, IRFragment as s, IdAllocator as t, IRText as u, SafetyLevel as v, Captures as w, RewriteFactory as x, MatchResult as y, PassCategory as z };
524
+ export type { DistributiveOmit as $, AttrMap as A, BackrefTable as B, CssProperty as C, DiagnosticCode as D, ElementLike as E, FileKind as F, FrontendKind as G, ExprRef as H, IRNodeId as I, IRExpr as J, ExprRegistry as K, IRFragment as L, IdAllocator as M, NodeLike as N, IRText as O, PatternName as P, AttrValue as Q, RewriteOpDraft as R, StyleMap as S, Brand as T, ClassListForm as U, Visitor as V, ClassSegment as W, ClassToken as X, CommentSpec as Y, CssValue as Z, DeclSignature as _, StyleConflictPolicy as a, ElementSpec as a0, EmitContext as a1, EmitResult as a2, ExprKind as a3, ExprRecord as a4, ExprSpec as a5, FragmentSpec as a6, IRNodeBase as a7, IRNodeKind as a8, InheritedPropertyTable as a9, NodeRefSpec as aa, OpOrigin as ab, OpaqueReason as ac, OpaqueToken as ad, PassTraceEntry as ae, Position as af, ResolveInput as ag, ResolveResult as ah, ResolverDiagnostic as ai, SelectorUsage as aj, Severity as ak, SourceFile as al, SourceFileId as am, StyleBlock as an, StyleDecl as ao, StyleOrigin as ap, SyntheticClass as aq, TextSpec as ar, VisitContext as as, VisitSignal as at, NodeSpec as b, StyleNormalizer as c, RewriteOp as d, IRDocument as e, SafetyLevel as f, SelectorIndex as g, StyleResolver as h, Diagnostic as i, SyntheticSink as j, SourceSpan as k, PassPhase as l, PassCategory as m, NodeMeta as n, DeepReadonly as o, IRElement as p, IRNode as q, RewriteFactory as r, Reporter as s, StyleCondition as t, ConditionKey as u, IRNamespace as v, ClassList as w, InlineStyle as x, Backref as y, IRComment as z };
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @domflax/core — public type contract (packages/core/src/types.ts)
2
+ * @domflax/core — type contract, part 1/3: IR + style primitives.
3
3
  *
4
- * SINGLE SOURCE OF TRUTH for the whole monorepo. Pure type/interface declarations
5
- * only: ZERO runtime. Every downstream package imports these exact names.
4
+ * Pure type/interface declarations only: ZERO runtime. Covers type utilities, identity
5
+ * primitives, source spans, the StyleMap model, NodeMeta, author tokens, the IR node union,
6
+ * the expr registry / document, traversal types, and node specs. This is the bottom layer of
7
+ * the type contract — it imports nothing from the sibling type modules.
6
8
  *
7
- * Compiles under: strict, verbatimModuleSyntax, isolatedDeclarations, erasableSyntaxOnly,
8
- * isolatedModules. No `const enum` (TS6 erasableSyntaxOnly): every closed set is a
9
- * string/number literal UNION here; the matching frozen `as const` runtime objects live in
10
- * sibling runtime modules (constants.ts), not in this file.
9
+ * (`PassPhase`/`PassCategory` live here too, in the primitive layer, so the resolver/op modules
10
+ * can reference them without a cycle through the pass-contract module.)
11
11
  */
12
12
  type Brand<T, B extends string> = T & {
13
13
  readonly __brand: B;
@@ -34,6 +34,8 @@ interface IdAllocator {
34
34
  }
35
35
  /** SAFETY: 0 lint · 1 safe · 2 default · 3 aggressive. (Runtime `SAFETY` object lives in constants.ts.) */
36
36
  type SafetyLevel = 0 | 1 | 2 | 3;
37
+ type PassPhase = 'flatten' | 'compress' | 'extract';
38
+ type PassCategory = `${PassPhase}/${string}`;
37
39
  interface Position {
38
40
  readonly line: number;
39
41
  readonly column: number;
@@ -301,6 +303,15 @@ interface NodeRefSpec {
301
303
  readonly ref: IRNodeId;
302
304
  }
303
305
  type NodeSpec = ElementSpec | TextSpec | ExprSpec | FragmentSpec | CommentSpec | NodeRefSpec;
306
+
307
+ /**
308
+ * @domflax/core — type contract, part 2/3: diagnostics, the style-resolver layer, the selector
309
+ * index, and the RewriteOp union + factory.
310
+ *
311
+ * Pure type/interface declarations only: ZERO runtime. Depends only on the IR/style primitives in
312
+ * `./ir`.
313
+ */
314
+
304
315
  type Severity = 'error' | 'warn' | 'info' | 'debug';
305
316
  type DiagnosticCode = 'DF_PATTERN_THREW' | 'DF_OP_PRECONDITION_FAILED' | 'DF_CROSSED_DYNAMIC_BOUNDARY' | 'DF_SAFETY_CEILING_EXCEEDED' | 'DF_STYLE_CONFLICT_UNRESOLVED' | 'DF_FIXPOINT_BUDGET' | 'DF_FIXPOINT_OSCILLATION' | 'DF_NON_INHERITABLE_FOLD' | 'DF_RELATIVE_UNIT_FOLD' | 'DF_CUSTOM_PROP_COUPLING' | 'DF_STRUCTURAL_PSEUDO_TARGET' | 'DF_SELECTOR_MEMBERSHIP' | 'DF_NODE_REMOVED' | 'DF_PATTERN_APPLIED' | 'DF_VERIFY_REVERTED' | 'DF_VERIFY_INCONCLUSIVE';
306
317
  interface Diagnostic {
@@ -393,6 +404,13 @@ interface StyleResolver {
393
404
  emit(styles: StyleMap, ctx: EmitContext): EmitResult;
394
405
  /** Reports every project selector referencing a class — compress safety (review-1 major). */
395
406
  selectorUsage(token: string): SelectorUsage;
407
+ /**
408
+ * OPTIONAL: produce a CSS stylesheet that defines the given class tokens, so a verifier can render
409
+ * a subtree with the provider's real styling applied. Tailwind generates the rules from its engine;
410
+ * the custom-CSS resolver returns its source stylesheets. Resolvers that cannot (the null/fake test
411
+ * resolvers) simply omit this — the verifier then falls back to inlining each element's computed style.
412
+ */
413
+ cssFor?(classes: readonly string[]): string;
396
414
  }
397
415
  interface SelectorIndex {
398
416
  targetedByCombinator(id: IRNodeId): boolean;
@@ -502,248 +520,5 @@ interface RewriteFactory {
502
520
  text(value: string): NodeSpec;
503
521
  keep(node: NodeLike): NodeSpec;
504
522
  }
505
- type PassPhase = 'flatten' | 'compress' | 'extract';
506
- type PassCategory = `${PassPhase}/${string}`;
507
- type Captures = Record<string, unknown>;
508
- /** Read-only style predicate over a normalized StyleMap (queries MEANING, not strings). */
509
- type StylePredicate = (sm: StyleMap) => boolean;
510
- /**
511
- * Relational precondition (review-2 blocker): describes ancestor/sibling/child subtree shape AND
512
- * ancestor LAYOUT context (review-4 blocker) so fuzzProve generates trees that exercise the
513
- * relational + parent-constraint branches, not just node-local ones.
514
- */
515
- interface TreeShapeSketch {
516
- readonly tag?: string | readonly string[];
517
- readonly requiredComputed?: Readonly<Record<string, string>>;
518
- readonly meta?: Partial<Record<keyof NodeMeta, boolean>>;
519
- readonly children?: readonly TreeShapeSketch[];
520
- }
521
- type ParentLayoutContext = 'block-flow' | 'flex-item' | 'flex-item-stretch' | 'grid-item' | 'fixed-size-ancestor' | 'percentage-sized-child' | 'inline-context';
522
- interface PreconditionSketch {
523
- readonly requiredComputed?: Readonly<Record<string, string>>;
524
- readonly childCount?: {
525
- readonly min?: number;
526
- readonly max?: number;
527
- };
528
- readonly forbid?: readonly string[];
529
- readonly ancestor?: TreeShapeSketch;
530
- readonly siblings?: readonly TreeShapeSketch[];
531
- readonly childShapes?: readonly TreeShapeSketch[];
532
- readonly parentContexts?: readonly ParentLayoutContext[];
533
- }
534
- interface PatternDoc {
535
- readonly title: string;
536
- readonly summary: string;
537
- readonly before?: string;
538
- readonly after?: string;
539
- readonly safetyRationale?: string;
540
- }
541
- /** Result of a successful match: op drafts (origin stamped later) + optional captures/diagnostics. */
542
- interface MatchResult<C extends Captures = Captures> {
543
- readonly ops: readonly RewriteOpDraft[];
544
- readonly captures?: C;
545
- readonly diagnostics?: readonly Diagnostic[];
546
- }
547
- interface MatchContext {
548
- readonly node: DeepReadonly<IRElement>;
549
- readonly doc: DeepReadonly<IRDocument>;
550
- readonly resolver: StyleResolver;
551
- readonly selectors: SelectorIndex;
552
- readonly safety: SafetyLevel;
553
- readonly phase: PassPhase;
554
- readonly iteration: number;
555
- parent(): DeepReadonly<IRElement> | null;
556
- elementChildren(): readonly DeepReadonly<IRElement>[];
557
- onlyElementChild(): DeepReadonly<IRElement> | null;
558
- computed(): StyleMap;
559
- computedOf(n: NodeLike): StyleMap;
560
- isOpaque(n?: ElementLike): boolean;
561
- ancestors(): readonly DeepReadonly<IRElement>[];
562
- closest(pred: (el: DeepReadonly<IRElement>) => boolean): DeepReadonly<IRElement> | null;
563
- prevSibling(): DeepReadonly<IRNode> | null;
564
- nextSibling(): DeepReadonly<IRNode> | null;
565
- nthChildIndex(): number;
566
- }
567
- /** Context handed to the `rewrite` phase: a MatchContext plus the typed captures. */
568
- interface RewriteContext<C extends Captures = Captures> extends MatchContext {
569
- readonly captures: C;
570
- }
571
- interface Pattern {
572
- readonly name: PatternName;
573
- readonly category: PassCategory;
574
- readonly safety: SafetyLevel;
575
- readonly priority?: number;
576
- readonly precondition?: PreconditionSketch;
577
- readonly doc?: PatternDoc;
578
- /** Pure. Returns a MatchResult (op drafts) or null on no-match. MUST NOT mutate. */
579
- evaluate(ctx: MatchContext, rw: RewriteFactory): MatchResult | null;
580
- }
581
- interface Pass {
582
- readonly phase: PassPhase;
583
- readonly category: PassCategory;
584
- readonly patterns: readonly Pattern[];
585
- }
586
- interface FixpointConfig {
587
- readonly maxIterations: number;
588
- readonly phases: Partial<Record<PassPhase, number>>;
589
- readonly onBudgetExhausted: 'warn' | 'error';
590
- readonly detectOscillation: boolean;
591
- }
592
- type HaltReason = 'converged' | 'budget' | 'oscillation' | 'error';
593
- interface PhaseRunResult {
594
- readonly phase: PassPhase;
595
- readonly iterations: number;
596
- readonly converged: boolean;
597
- readonly haltReason: HaltReason;
598
- readonly touched: ReadonlySet<IRNodeId>;
599
- readonly diagnostics: readonly Diagnostic[];
600
- }
601
- interface RewriteGroup {
602
- readonly pattern: PatternName;
603
- readonly anchor: IRNodeId;
604
- readonly ops: readonly RewriteOp[];
605
- }
606
- interface ApplyContext {
607
- readonly doc: IRDocument;
608
- readonly safetyCeiling: SafetyLevel;
609
- readonly normalizer: StyleNormalizer;
610
- readonly selectors: SelectorIndex;
611
- readonly resolver: StyleResolver;
612
- }
613
- interface StructuralInverse {
614
- readonly kind: 'structural';
615
- readonly describe: string;
616
- readonly snapshot: unknown;
617
- }
618
- interface AppliedOp {
619
- readonly op: RewriteOp;
620
- readonly inverse: RewriteOp | StructuralInverse;
621
- }
622
- interface OpValidationIssue {
623
- readonly op: RewriteOp;
624
- readonly code: DiagnosticCode;
625
- readonly message: string;
626
- }
627
- interface SkippedOpGroup {
628
- readonly group: RewriteGroup;
629
- readonly issues: readonly OpValidationIssue[];
630
- }
631
- interface ApplyResult {
632
- readonly touched: ReadonlySet<IRNodeId>;
633
- readonly removed: ReadonlySet<IRNodeId>;
634
- readonly created: ReadonlySet<IRNodeId>;
635
- readonly appliedGroups: number;
636
- readonly skipped: readonly SkippedOpGroup[];
637
- readonly journal: readonly AppliedOp[];
638
- readonly diagnostics: readonly Diagnostic[];
639
- }
640
- interface PassManager {
641
- run(doc: IRDocument, ctx: ApplyContext, config?: FixpointConfig): readonly PhaseRunResult[];
642
- }
643
- interface FrontendConfig {
644
- readonly jsxImportSource?: string;
645
- readonly preserveComments?: boolean;
646
- readonly [key: string]: unknown;
647
- }
648
- interface FrontendParseContext {
649
- readonly id: string;
650
- readonly kind: FileKind;
651
- readonly resolver: StyleResolver;
652
- readonly normalizer: StyleNormalizer;
653
- readonly config: FrontendConfig;
654
- onDiagnostic(d: Diagnostic): void;
655
- babelAst?: unknown;
656
- }
657
- interface ParseResult {
658
- readonly doc: IRDocument;
659
- readonly diagnostics: readonly Diagnostic[];
660
- }
661
- interface Frontend {
662
- readonly name: string;
663
- readonly langs: readonly FileKind[];
664
- canParse(id: string, code: string): boolean;
665
- parse(code: string, ctx: FrontendParseContext): ParseResult;
666
- }
667
- interface ReindentSpec {
668
- readonly baseIndent: string;
669
- readonly delta: number;
670
- }
671
- interface TextEdit {
672
- readonly span: SourceSpan;
673
- readonly replacement: string;
674
- readonly reindent?: ReindentSpec;
675
- readonly origin: string;
676
- }
677
- interface EditPlan {
678
- readonly moduleId: string;
679
- readonly ops: readonly RewriteOp[];
680
- readonly provenance: ReadonlyMap<number, PatternName>;
681
- }
682
- interface EncodedSourceMap {
683
- readonly version: 3;
684
- readonly sources: readonly string[];
685
- readonly sourcesContent?: readonly (string | null)[];
686
- readonly names: readonly string[];
687
- readonly mappings: string;
688
- readonly file?: string;
689
- }
690
- interface BackendContext {
691
- readonly normalizer: StyleNormalizer;
692
- readonly resolver: StyleResolver;
693
- readonly sink: SyntheticSink;
694
- readonly eol: '\n' | '\r\n';
695
- onDiagnostic(d: Diagnostic): void;
696
- }
697
- interface CodegenResult {
698
- readonly code: string;
699
- readonly map: EncodedSourceMap | null;
700
- readonly edits: readonly TextEdit[];
701
- readonly diagnostics: readonly Diagnostic[];
702
- }
703
- interface Backend {
704
- readonly name: string;
705
- readonly langs: readonly FileKind[];
706
- print(doc: IRDocument, plan: EditPlan, ctx: BackendContext): CodegenResult;
707
- }
708
- interface PipelineConfig {
709
- readonly safety: SafetyLevel;
710
- readonly fixpoint?: Partial<FixpointConfig>;
711
- readonly preserveComments?: boolean;
712
- readonly emitSourceMap?: boolean;
713
- }
714
- interface PipelineInput {
715
- readonly code: string;
716
- readonly id: string;
717
- readonly kind: FileKind;
718
- readonly frontend: Frontend;
719
- readonly backend: Backend;
720
- readonly resolver: StyleResolver;
721
- readonly normalizer: StyleNormalizer;
722
- readonly passes: readonly Pass[];
723
- readonly config?: PipelineConfig;
724
- readonly reporter?: Reporter;
725
- readonly babelAst?: unknown;
726
- }
727
- interface PipelineStats {
728
- readonly nodesIn: number;
729
- readonly nodesOut: number;
730
- readonly opsApplied: number;
731
- readonly iterations: Readonly<Record<PassPhase, number>>;
732
- readonly durationMs: number;
733
- }
734
- interface PipelineOutput {
735
- readonly code: string;
736
- readonly map: EncodedSourceMap | null;
737
- readonly changed: boolean;
738
- readonly touched: readonly SourceSpan[];
739
- readonly diagnostics: readonly Diagnostic[];
740
- readonly stats: PipelineStats;
741
- readonly doc: IRDocument;
742
- readonly editPlan: EditPlan;
743
- }
744
- /** The pure single-file pipeline. Adapters/orchestrator call this; the verifier reuses it. */
745
- interface Pipeline {
746
- run(input: PipelineInput): PipelineOutput;
747
- }
748
523
 
749
- export type { EncodedSourceMap as $, AttrMap as A, BackrefTable as B, CssProperty as C, PreconditionSketch as D, ElementLike as E, FrontendKind as F, PatternDoc as G, Diagnostic as H, IRNodeId as I, ApplyResult as J, RewriteGroup as K, ApplyContext as L, MatchContext as M, NodeLike as N, RewriteOp as O, Pattern as P, FixpointConfig as Q, RewriteOpDraft as R, StyleMap as S, StyleResolver as T, SelectorIndex as U, Visitor as V, Pass as W, PassManager as X, PhaseRunResult as Y, Pipeline as Z, SyntheticSink as _, StyleConflictPolicy as a, TextEdit as a$, AppliedOp as a0, AttrValue as a1, Backend as a2, BackendContext as a3, Brand as a4, ClassListForm as a5, ClassSegment as a6, ClassToken as a7, CodegenResult as a8, CommentSpec as a9, ParentLayoutContext as aA, ParseResult as aB, PassPhase as aC, PassTraceEntry as aD, PatternName as aE, PipelineConfig as aF, PipelineInput as aG, PipelineOutput as aH, PipelineStats as aI, Position as aJ, ReindentSpec as aK, Reporter as aL, ResolveInput as aM, ResolveResult as aN, ResolverDiagnostic as aO, RewriteContext as aP, SelectorUsage as aQ, Severity as aR, SkippedOpGroup as aS, SourceFile as aT, SourceFileId as aU, StructuralInverse as aV, StyleBlock as aW, StyleDecl as aX, StyleOrigin as aY, StylePredicate as aZ, SyntheticClass as a_, CssValue as aa, DeclSignature as ab, DeepReadonly as ac, DiagnosticCode as ad, DistributiveOmit as ae, EditPlan as af, ElementSpec as ag, EmitContext as ah, EmitResult as ai, ExprKind as aj, ExprRecord as ak, ExprSpec as al, FileKind as am, FragmentSpec as an, Frontend as ao, FrontendConfig as ap, FrontendParseContext as aq, HaltReason as ar, IRNodeBase as as, IRNodeKind as at, InheritedPropertyTable as au, NodeRefSpec as av, OpOrigin as aw, OpValidationIssue as ax, OpaqueReason as ay, OpaqueToken as az, NodeSpec as b, TextSpec as b0, TreeShapeSketch as b1, VisitContext as b2, VisitSignal as b3, StyleNormalizer as c, StyleCondition as d, ConditionKey as e, IRNamespace as f, ClassList as g, InlineStyle as h, SourceSpan as i, NodeMeta as j, Backref as k, IRNode as l, IRComment as m, IRDocument as n, IRElement as o, ExprRef as p, IRExpr as q, ExprRegistry as r, IRFragment as s, IdAllocator as t, IRText as u, SafetyLevel as v, Captures as w, RewriteFactory as x, MatchResult as y, PassCategory as z };
524
+ export type { DistributiveOmit as $, AttrMap as A, BackrefTable as B, CssProperty as C, DiagnosticCode as D, ElementLike as E, FileKind as F, FrontendKind as G, ExprRef as H, IRNodeId as I, IRExpr as J, ExprRegistry as K, IRFragment as L, IdAllocator as M, NodeLike as N, IRText as O, PatternName as P, AttrValue as Q, RewriteOpDraft as R, StyleMap as S, Brand as T, ClassListForm as U, Visitor as V, ClassSegment as W, ClassToken as X, CommentSpec as Y, CssValue as Z, DeclSignature as _, StyleConflictPolicy as a, ElementSpec as a0, EmitContext as a1, EmitResult as a2, ExprKind as a3, ExprRecord as a4, ExprSpec as a5, FragmentSpec as a6, IRNodeBase as a7, IRNodeKind as a8, InheritedPropertyTable as a9, NodeRefSpec as aa, OpOrigin as ab, OpaqueReason as ac, OpaqueToken as ad, PassTraceEntry as ae, Position as af, ResolveInput as ag, ResolveResult as ah, ResolverDiagnostic as ai, SelectorUsage as aj, Severity as ak, SourceFile as al, SourceFileId as am, StyleBlock as an, StyleDecl as ao, StyleOrigin as ap, SyntheticClass as aq, TextSpec as ar, VisitContext as as, VisitSignal as at, NodeSpec as b, StyleNormalizer as c, RewriteOp as d, IRDocument as e, SafetyLevel as f, SelectorIndex as g, StyleResolver as h, Diagnostic as i, SyntheticSink as j, SourceSpan as k, PassPhase as l, PassCategory as m, NodeMeta as n, DeepReadonly as o, IRElement as p, IRNode as q, RewriteFactory as r, Reporter as s, StyleCondition as t, ConditionKey as u, IRNamespace as v, ClassList as w, InlineStyle as x, Backref as y, IRComment as z };
package/dist/verify.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { H as Diagnostic } from './types-BQ7l6dVe.cjs';
1
+ import { i as Diagnostic } from './resolve-ops-DIwEelH-.cjs';
2
2
 
3
3
  /**
4
4
  * @domflax/verify — public type contract (TYPED STUB)
package/dist/verify.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { H as Diagnostic } from './types-BQ7l6dVe.js';
1
+ import { i as Diagnostic } from './resolve-ops-DIwEelH-.js';
2
2
 
3
3
  /**
4
4
  * @domflax/verify — public type contract (TYPED STUB)