@barefootjs/jsx 0.39.5 → 0.39.6

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 (57) hide show
  1. package/dist/adapters/array-method.d.ts +93 -0
  2. package/dist/adapters/array-method.d.ts.map +1 -0
  3. package/dist/adapters/attr-plan.d.ts +135 -0
  4. package/dist/adapters/attr-plan.d.ts.map +1 -0
  5. package/dist/adapters/boolean-result.d.ts +84 -9
  6. package/dist/adapters/boolean-result.d.ts.map +1 -1
  7. package/dist/adapters/callback-method.d.ts +126 -0
  8. package/dist/adapters/callback-method.d.ts.map +1 -0
  9. package/dist/adapters/component-props.d.ts +99 -0
  10. package/dist/adapters/component-props.d.ts.map +1 -0
  11. package/dist/adapters/component-tree.d.ts +25 -0
  12. package/dist/adapters/component-tree.d.ts.map +1 -0
  13. package/dist/adapters/literal-value.d.ts +22 -0
  14. package/dist/adapters/literal-value.d.ts.map +1 -0
  15. package/dist/adapters/loop-plan.d.ts +53 -0
  16. package/dist/adapters/loop-plan.d.ts.map +1 -0
  17. package/dist/adapters/prop-classes.d.ts +37 -0
  18. package/dist/adapters/prop-classes.d.ts.map +1 -0
  19. package/dist/expression-parser.d.ts +38 -0
  20. package/dist/expression-parser.d.ts.map +1 -1
  21. package/dist/index.d.ts +17 -3
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1765 -914
  24. package/dist/jsx-to-ir.d.ts +465 -1
  25. package/dist/jsx-to-ir.d.ts.map +1 -1
  26. package/dist/nullable-signal-attr.d.ts +19 -0
  27. package/dist/nullable-signal-attr.d.ts.map +1 -1
  28. package/package.json +2 -2
  29. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +1 -1
  30. package/src/__tests__/action-accessor.test.ts +6 -24
  31. package/src/__tests__/array-method-catalogue.test.ts +99 -0
  32. package/src/__tests__/attr-plan.test.ts +121 -0
  33. package/src/__tests__/binding-scope-ratchet.test.ts +12 -12
  34. package/src/__tests__/boolean-result-expr.test.ts +106 -0
  35. package/src/__tests__/boolean-result.test.ts +34 -1
  36. package/src/__tests__/callback-method.test.ts +189 -0
  37. package/src/__tests__/component-props.test.ts +148 -0
  38. package/src/__tests__/delegated-handler-preamble.test.ts +4 -4
  39. package/src/__tests__/dsl-shared-helpers.test.ts +166 -0
  40. package/src/__tests__/issue-3240-nested-static-map-event-delegation.test.ts +1 -1
  41. package/src/__tests__/loop-plan.test.ts +104 -0
  42. package/src/__tests__/map-call-decisions.test.ts +521 -0
  43. package/src/__tests__/nullable-signal-attr.test.ts +45 -0
  44. package/src/adapters/array-method.ts +193 -0
  45. package/src/adapters/attr-plan.ts +200 -0
  46. package/src/adapters/boolean-result.ts +208 -12
  47. package/src/adapters/callback-method.ts +301 -0
  48. package/src/adapters/component-props.ts +144 -0
  49. package/src/adapters/component-tree.ts +118 -0
  50. package/src/adapters/literal-value.ts +36 -0
  51. package/src/adapters/loop-plan.ts +88 -0
  52. package/src/adapters/prop-classes.ts +73 -0
  53. package/src/expression-parser.ts +537 -374
  54. package/src/index.ts +53 -2
  55. package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +9 -7
  56. package/src/jsx-to-ir.ts +1328 -991
  57. package/src/nullable-signal-attr.ts +78 -0
package/src/index.ts CHANGED
@@ -122,12 +122,62 @@ export type { ParsedExprEmitter, LoweringEmitter, HigherOrderMethod, ArrayMethod
122
122
  export { collectLoopBoundNames } from './adapters/loop-bound-names.ts'
123
123
  export { filterCaptureCollisions } from './adapters/filter-capture-collisions.ts'
124
124
  export { templateNameCollisionErrors } from './adapters/template-name-collisions.ts'
125
- export { isBooleanResultParsed, stringifyBooleanTernaryBranches } from './adapters/boolean-result.ts'
125
+ export {
126
+ collectBooleanValueNames,
127
+ isAriaBooleanAttr,
128
+ isBooleanResultExpr,
129
+ isBooleanResultParsed,
130
+ isExplicitStringCall,
131
+ stringifyBooleanTernaryBranches,
132
+ } from './adapters/boolean-result.ts'
133
+ export { isBareStringLiteral, isLiteralIndex, isStringTypeInfo } from './adapters/literal-value.ts'
134
+ export { collectBooleanTypedProps, collectNullableOptionalProps, isBooleanTypedPropRef } from './adapters/prop-classes.ts'
135
+ export type { BooleanTypedPropContext } from './adapters/prop-classes.ts'
136
+ export { collectImportedLoopChildComponentErrors, hasClientInteractivity } from './adapters/component-tree.ts'
137
+ export {
138
+ ARRAY_METHOD_CATALOGUE,
139
+ emitArrayMethod,
140
+ lowerArrayMethod,
141
+ prefixedArrayMethodSpelling,
142
+ } from './adapters/array-method.ts'
143
+ export {
144
+ emitCallbackEval,
145
+ isPredicateMethod,
146
+ lowerCallbackMethod,
147
+ nestedCallbackRefusal,
148
+ sortEvalPlan,
149
+ sortRefusal,
150
+ } from './adapters/callback-method.ts'
151
+ export type {
152
+ CallbackEvalHelper,
153
+ CallbackEvalOperand,
154
+ CallbackEvalPlan,
155
+ CallbackEvalSpelling,
156
+ CallbackLoweringOptions,
157
+ CallbackPlan,
158
+ PredicateMethod,
159
+ } from './adapters/callback-method.ts'
160
+ export type {
161
+ ArrayMethodArg,
162
+ ArrayMethodDefault,
163
+ ArrayMethodEntry,
164
+ ArrayMethodHelper,
165
+ ArrayMethodParam,
166
+ ArrayMethodPlan,
167
+ ArrayMethodSpelling,
168
+ } from './adapters/array-method.ts'
126
169
  export { derivesScopeFromSlot } from './adapters/child-scope.ts'
170
+ export { childTemplateName, componentPropKey, isEmptyComponentProps, planComponentProps, spellComponentProps } from './adapters/component-props.ts'
171
+ export type { ComponentPropEntry, ComponentPropSegment, ComponentPropSpelling, ComponentPropsOptions, SpelledComponentPropSegment } from './adapters/component-props.ts'
172
+ export { parseUndefinedAlternateTernary, planAttrExpression, planSpreadAttr, unsupportedAttrExpression } from './adapters/attr-plan.ts'
173
+ export type { AttrExpressionPlan, AttrPlanContext, SpreadAttrPlan, SpreadPlanContext, UndefinedAlternateTernary } from './adapters/attr-plan.ts'
174
+ export { planLoop } from './adapters/loop-plan.ts'
175
+ export type { LoopPlan, LoopPlanContext } from './adapters/loop-plan.ts'
127
176
  export { evaluateStaticLiteral, isFullyStaticLiteral, resolveStaticLoopSource } from './static-literal.ts'
128
177
  export {
129
178
  arithmeticOperandIsNull,
130
179
  arithmeticOperandIsUndefined,
180
+ arithmeticOperandCoercion,
131
181
  bareGetterCallName,
132
182
  attrValueMayBeNullish,
133
183
  collectNullableSignalGetters,
@@ -137,6 +187,7 @@ export {
137
187
  NULL_COERCING_ARITHMETIC_OPS,
138
188
  nullableSignalAttrGetter,
139
189
  type NullishAttrContext,
190
+ type ArithmeticCoercion,
140
191
  } from './nullable-signal-attr.ts'
141
192
  export { importsSearchParams, searchParamsLocalNames, envSignalLocalNames, envSignalReaderFor, ENV_SIGNAL_READERS, queryHrefLocalNames, matchSearchParamsMethodCall } from './adapters/env-signal.ts'
142
193
  export type { EnvSignalReader } from './adapters/env-signal.ts'
@@ -253,7 +304,7 @@ export { ErrorCodes, createError, formatError, generateCodeFrame } from './error
253
304
  export { isValueReferenceIdentifier, collectValueReferencedNames } from './value-references.ts'
254
305
 
255
306
  // Expression Parser
256
- export { parseExpression, tsNodeToParsedExpr, asCallbackMethodCall, CALLBACK_METHODS, sortComparatorFromArrow, serializeParsedExpr, freeVarsInBody, freeIdentifiers, renameFreeIdentifiers, materializeGetterCalls, isSupported, isSupportedValue, exprToString, stringifyParsedExpr, identifierPath, parseBlockBody, parseBlockBodyTolerant, foldBlockToExpr, predicateTernaryToLogical, containsHigherOrder, extractArrowBodyExpression, parseStyleObjectEntries, hasUnsafeStyleValue, parseProviderObjectLiteral, isFunctionShapedExpression, type ProviderObjectMember, type FoldBlockOptions } from './expression-parser.ts'
307
+ export { parseExpression, tsNodeToParsedExpr, asCallbackMethodCall, hasOpaqueCall, unboundCallbackParamRead, unboundCallbackParamReason, CALLBACK_METHODS, sortComparatorFromArrow, serializeParsedExpr, freeVarsInBody, freeIdentifiers, renameFreeIdentifiers, materializeGetterCalls, isSupported, isSupportedValue, exprToString, stringifyParsedExpr, identifierPath, parseBlockBody, parseBlockBodyTolerant, foldBlockToExpr, predicateTernaryToLogical, containsHigherOrder, extractArrowBodyExpression, parseStyleObjectEntries, hasUnsafeStyleValue, parseProviderObjectLiteral, isFunctionShapedExpression, type ProviderObjectMember, type FoldBlockOptions } from './expression-parser.ts'
257
308
  export type { StyleObjectEntry } from './expression-parser.ts'
258
309
  export { literalMemberIndex } from './literal-member-index.ts'
259
310
  export { PARSED_EXPR_KINDS, ARRAY_METHOD_NAMES, SORT_KEY_TYPES, SORT_KEY_TARGETS, SORT_KEY_DIRECTIONS } from './expression-parser.ts'
@@ -221,7 +221,7 @@ function emitKeyedLookup(
221
221
  if (hasBindings) {
222
222
  // TDZ-safe shape — see #951.
223
223
  ls.push(` const __bfLoopItem = ${arrayExpr}.find(item => String(${keyWithItem}) === key)`)
224
- ls.push(` if (__bfLoopItem) {`)
224
+ ls.push(` if (__bfLoopItem !== undefined) {`)
225
225
  ls.push(` const ${param} = __bfLoopItem`)
226
226
  if (preambleLine) ls.push(` ${preambleLine}`)
227
227
  if (idxLine) ls.push(` ${idxLine}`)
@@ -239,8 +239,10 @@ function emitKeyedLookup(
239
239
  // the item null guard — a `.find()` miss (stale-DOM race, e.g. the
240
240
  // clicked row's key no longer in the current array) must short-circuit
241
241
  // before a preamble that dereferences the item ever runs (BUG-4).
242
+ // Every item guard here tests for that miss (`undefined`), never
243
+ // truthiness: a row item can be `0`, `''` or `false` (#3433).
242
244
  ls.push(` const ${param} = ${arrayExpr}.find(item => String(${keyWithItem}) === key)`)
243
- ls.push(` if (${param}) {`)
245
+ ls.push(` if (${param} !== undefined) {`)
244
246
  if (preambleLine) ls.push(` ${preambleLine}`)
245
247
  if (idxLine) ls.push(` ${idxLine}`)
246
248
  ls.push(` ;${handlerCall}`)
@@ -273,14 +275,14 @@ function emitKeyedLookup(
273
275
  ? substituteLoopBindings(rawKey, nested.paramBindings, 'item')
274
276
  : rawKey.replace(identifierPattern(nested.param, 'g'), 'item')
275
277
  const outerRef = hasBindings ? '__bfLoopItem' : param
276
- ls.push(` const ${nested.param} = ${outerRef} && ${nested.array}.find(item => String(${innerKeyExpr}) === innerKey${nested.depth})`)
278
+ ls.push(` const ${nested.param} = ${outerRef} !== undefined ? ${nested.array}.find(item => String(${innerKeyExpr}) === innerKey${nested.depth}) : undefined`)
277
279
  }
278
280
  const outerGuard = hasBindings ? '__bfLoopItem' : param
279
281
  const allParams = [outerGuard, ...ev.nestedLoops.map(n => n.param)]
280
282
  // Preamble and idx binding run INSIDE the combined item guard (BUG-4) —
281
283
  // a nested `.find()` miss must short-circuit before the preamble runs.
282
284
  const idxLine = indexBindingLine(ev.handler, indexParam, `${arrayExpr}.findIndex(item => String(${keyWithItem}) === outerKey)`)
283
- ls.push(` if (${allParams.join(' && ')}) {`)
285
+ ls.push(` if (${allParams.map(p => `${p} !== undefined`).join(' && ')}) {`)
284
286
  if (preambleLine) ls.push(` ${preambleLine}`)
285
287
  if (idxLine) ls.push(` ${idxLine}`)
286
288
  ls.push(` ;${handlerCall}`)
@@ -301,7 +303,7 @@ function emitDynamicIndexLookup(
301
303
  ls.push(` const idx = Array.from(li.parentElement.children).indexOf(li)`)
302
304
  if (hasBindings) {
303
305
  ls.push(` const __bfLoopItem = ${arrayExpr}[idx]`)
304
- ls.push(` if (__bfLoopItem) {`)
306
+ ls.push(` if (__bfLoopItem !== undefined) {`)
305
307
  ls.push(` const ${param} = __bfLoopItem`)
306
308
  if (preambleLine) ls.push(` ${preambleLine}`)
307
309
  if (idxLine) ls.push(` ${idxLine}`)
@@ -311,7 +313,7 @@ function emitDynamicIndexLookup(
311
313
  // Preamble and idx binding run INSIDE the item null guard (BUG-4) — an
312
314
  // out-of-range index (stale-DOM race) must short-circuit first.
313
315
  ls.push(` const ${param} = ${arrayExpr}[idx]`)
314
- ls.push(` if (${param}) {`)
316
+ ls.push(` if (${param} !== undefined) {`)
315
317
  if (preambleLine) ls.push(` ${preambleLine}`)
316
318
  if (idxLine) ls.push(` ${idxLine}`)
317
319
  ls.push(` ;${handlerCall}`)
@@ -338,7 +340,7 @@ function emitStaticIndexLookup(
338
340
  ls.push(` const ${param} = ${arrayExpr}[__idx]`)
339
341
  // Preamble and idx binding run INSIDE the item null guard (BUG-4) — an
340
342
  // out-of-range index (stale-DOM race) must short-circuit first.
341
- ls.push(` if (${param}) {`)
343
+ ls.push(` if (${param} !== undefined) {`)
342
344
  // Nested static `.map()` params (#3240): static arrays carry no
343
345
  // data-key markers, so — unlike `emitKeyedLookup`'s nested branch, which
344
346
  // resolves each level via `closest('[data-key-N]')` — each nested level's