@barefootjs/jsx 0.17.1 → 0.18.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.
Files changed (79) hide show
  1. package/dist/adapters/interface.d.ts +20 -4
  2. package/dist/adapters/interface.d.ts.map +1 -1
  3. package/dist/adapters/parsed-expr-emitter.d.ts +3 -1
  4. package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
  5. package/dist/analyzer-context.d.ts.map +1 -1
  6. package/dist/analyzer.d.ts.map +1 -1
  7. package/dist/augment-inherited-props.d.ts +19 -0
  8. package/dist/augment-inherited-props.d.ts.map +1 -1
  9. package/dist/compiler.d.ts.map +1 -1
  10. package/dist/expression-parser.d.ts +1 -0
  11. package/dist/expression-parser.d.ts.map +1 -1
  12. package/dist/index.d.ts +19 -3
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +815 -251
  15. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  16. package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
  17. package/dist/ir-to-client-js/control-flow/plan/build-loop.d.ts.map +1 -1
  18. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +9 -0
  19. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
  20. package/dist/ir-to-client-js/control-flow/stringify/loop.d.ts.map +1 -1
  21. package/dist/ir-to-client-js/control-flow/stringify/template-parse.d.ts +19 -0
  22. package/dist/ir-to-client-js/control-flow/stringify/template-parse.d.ts.map +1 -1
  23. package/dist/ir-to-client-js/emit-registration.d.ts +4 -2
  24. package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
  25. package/dist/ir-to-client-js/html-template.d.ts +41 -0
  26. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  27. package/dist/ir-to-client-js/types.d.ts +22 -1
  28. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  29. package/dist/jsx-to-ir.d.ts.map +1 -1
  30. package/dist/loop-destructure.d.ts +55 -18
  31. package/dist/loop-destructure.d.ts.map +1 -1
  32. package/dist/lowering-registry.d.ts +13 -0
  33. package/dist/lowering-registry.d.ts.map +1 -1
  34. package/dist/relocate.d.ts +28 -0
  35. package/dist/relocate.d.ts.map +1 -1
  36. package/dist/ssr-defaults.d.ts.map +1 -1
  37. package/dist/types.d.ts +68 -0
  38. package/dist/types.d.ts.map +1 -1
  39. package/package.json +2 -2
  40. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +284 -12
  41. package/src/__tests__/augment-inherited-props.test.ts +96 -0
  42. package/src/__tests__/compiler-runtime-contract.test.ts +11 -1
  43. package/src/__tests__/compiler-stress-1244.test.ts +13 -4
  44. package/src/__tests__/csr-substitution-safety-divergence.test.ts +137 -0
  45. package/src/__tests__/destructured-map-params.test.ts +11 -1
  46. package/src/__tests__/expression-parser.test.ts +63 -2
  47. package/src/__tests__/ir-sort-comparator.test.ts +261 -0
  48. package/src/__tests__/loop-destructure.test.ts +313 -0
  49. package/src/__tests__/loop-hoisted-template.test.ts +235 -0
  50. package/src/__tests__/props-destructuring.test.ts +110 -0
  51. package/src/__tests__/serialize-parsed-expr.test.ts +70 -3
  52. package/src/__tests__/ssr-defaults.test.ts +20 -0
  53. package/src/__tests__/staged-ir/11-template-primitive-registry.test.ts +231 -1
  54. package/src/__tests__/tagged-template-interleave.test.ts +268 -0
  55. package/src/__tests__/unsupported-expression.test.ts +194 -7
  56. package/src/adapters/interface.ts +20 -4
  57. package/src/adapters/parsed-expr-emitter.ts +19 -2
  58. package/src/analyzer-context.ts +20 -0
  59. package/src/analyzer.ts +74 -1
  60. package/src/augment-inherited-props.ts +139 -9
  61. package/src/compiler.ts +4 -0
  62. package/src/expression-parser.ts +237 -56
  63. package/src/index.ts +23 -1
  64. package/src/ir-to-client-js/collect-elements.ts +15 -1
  65. package/src/ir-to-client-js/compute-inlinability.ts +6 -1
  66. package/src/ir-to-client-js/control-flow/plan/build-loop.ts +1 -0
  67. package/src/ir-to-client-js/control-flow/plan/loop.ts +9 -0
  68. package/src/ir-to-client-js/control-flow/stringify/loop.ts +30 -8
  69. package/src/ir-to-client-js/control-flow/stringify/template-parse.ts +30 -0
  70. package/src/ir-to-client-js/emit-registration.ts +4 -2
  71. package/src/ir-to-client-js/html-template.ts +198 -1
  72. package/src/ir-to-client-js/index.ts +1 -0
  73. package/src/ir-to-client-js/types.ts +22 -0
  74. package/src/jsx-to-ir.ts +409 -24
  75. package/src/loop-destructure.ts +89 -36
  76. package/src/lowering-registry.ts +16 -0
  77. package/src/relocate.ts +201 -14
  78. package/src/ssr-defaults.ts +34 -32
  79. package/src/types.ts +65 -0
package/src/types.ts CHANGED
@@ -695,6 +695,26 @@ export interface RestExcludeKey {
695
695
  isIdent: boolean
696
696
  }
697
697
 
698
+ /**
699
+ * Structured, non-string form of a `.map()` callback destructure accessor
700
+ * step — one entry per `.foo` / `["a-b"]` / `[0]` step folded into
701
+ * {@link LoopParamBinding.path}. Adapters that need to build their own
702
+ * accessor expression (rather than splice `path` in as a JS suffix) walk
703
+ * `segments` instead of parsing `path` with a regex (repo rule: never parse
704
+ * JS/TS syntax with regex or string matching).
705
+ *
706
+ * - `{ kind: 'field', key, isIdent }`: an object-property step. `isIdent`
707
+ * uses the same `ts.isIdentifierStart`/`isIdentifierPart` classification
708
+ * as {@link RestExcludeKey.isIdent} — an adapter choosing between a native
709
+ * `.foo` accessor and a quoted/bracketed one (`["data-priority"]`, a
710
+ * quoted map key, ...) reads this instead of re-deriving the identifier
711
+ * rule itself.
712
+ * - `{ kind: 'index', index }`: an array-position step (`[0]`, `[1]`, ...).
713
+ */
714
+ export type LoopBindingPathSegment =
715
+ | { kind: 'field'; key: string; isIdent: boolean }
716
+ | { kind: 'index'; index: number }
717
+
698
718
  /**
699
719
  * Destructured binding extracted from a `.map()` callback's item parameter.
700
720
  *
@@ -721,6 +741,24 @@ export interface LoopParamBinding {
721
741
  rest?:
722
742
  | { kind: 'object'; exclude: readonly RestExcludeKey[] }
723
743
  | { kind: 'array'; from: number }
744
+ /**
745
+ * Structured form of `path` (see {@link LoopBindingPathSegment}).
746
+ *
747
+ * - Fixed bindings (`rest` unset): the full accessor from the loop item to
748
+ * this binding, one segment per `path` step. Always non-empty — a fixed
749
+ * binding always has at least one accessor step.
750
+ * - Rest bindings (`rest` set): the structured form of the PARENT prefix
751
+ * (i.e. of `path`, which for rest bindings holds the parent prefix, not
752
+ * an accessor to the rest binding itself) — possibly empty when the
753
+ * rest sits at the loop root (`({ ...rest }) => …` / `([...rest]) => …`).
754
+ *
755
+ * Optional only so older/foreign IR (built before this field existed)
756
+ * still type-checks; `extractLoopParamBindings` always populates it now.
757
+ * Downstream gates (`isLowerableLoopDestructure`) treat a missing
758
+ * `segments` as "unknown shape" and refuse conservatively rather than
759
+ * reading it as "binding at the loop root".
760
+ */
761
+ segments?: readonly LoopBindingPathSegment[]
724
762
  }
725
763
 
726
764
  export interface IRComponent {
@@ -1710,6 +1748,24 @@ export interface ErrorSuggestion {
1710
1748
  replacement?: string
1711
1749
  }
1712
1750
 
1751
+ /**
1752
+ * A diagnostic an adapter intentionally emits for a shared conformance
1753
+ * fixture (packages/adapter-tests) instead of lowering it — the adapter's
1754
+ * machine-readable known-limitations declaration. Consumed by the adapter's
1755
+ * own conformance test (as `expectedDiagnostics`) and by `bf compat`
1756
+ * (issue-URL attribution). Tracked limitations carry the `known-limitation`
1757
+ * label: https://github.com/piconic-ai/barefootjs/labels/known-limitation
1758
+ */
1759
+ export interface ConformancePin {
1760
+ /** Diagnostic code, e.g. 'BF101'. */
1761
+ code: string
1762
+ severity: 'error' | 'warning'
1763
+ /** Tracking issue URL (known-limitation label) for this refusal, when one exists. */
1764
+ issue?: string
1765
+ }
1766
+ /** Keyed by shared-fixture id (`JSXFixture.id`). */
1767
+ export type ConformancePins = Record<string, ReadonlyArray<ConformancePin>>
1768
+
1713
1769
  // =============================================================================
1714
1770
  // Compile Options & Results
1715
1771
  // =============================================================================
@@ -1770,6 +1826,15 @@ export interface FileOutput {
1770
1826
  path: string
1771
1827
  content: string
1772
1828
  type: 'markedTemplate' | 'clientJs' | 'ir' | 'sourceMap' | 'types' | 'ssrDefaults'
1829
+ /**
1830
+ * The exported component this file was generated for. Set on
1831
+ * `markedTemplate` / `ssrDefaults` outputs so the build pipeline can pair
1832
+ * them per component without guessing from file basenames — a
1833
+ * single-component file's template is named after the SOURCE file
1834
+ * (`index.html.ep`), not the component, so the basename alone can't
1835
+ * recover the component name (#2132).
1836
+ */
1837
+ componentName?: string
1773
1838
  }
1774
1839
 
1775
1840
  export interface CompileResult {