@barefootjs/jsx 0.39.6 → 0.39.8
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/adapters/attr-plan.d.ts +8 -1
- package/dist/adapters/attr-plan.d.ts.map +1 -1
- package/dist/adapters/callback-method.d.ts +44 -0
- package/dist/adapters/callback-method.d.ts.map +1 -1
- package/dist/adapters/component-props.d.ts +80 -13
- package/dist/adapters/component-props.d.ts.map +1 -1
- package/dist/adapters/computed-const.d.ts +52 -0
- package/dist/adapters/computed-const.d.ts.map +1 -0
- package/dist/adapters/dangerous-inner-html.d.ts +10 -0
- package/dist/adapters/dangerous-inner-html.d.ts.map +1 -1
- package/dist/adapters/dsl-template-adapter.d.ts +151 -0
- package/dist/adapters/dsl-template-adapter.d.ts.map +1 -0
- package/dist/adapters/element-shell.d.ts +44 -0
- package/dist/adapters/element-shell.d.ts.map +1 -0
- package/dist/adapters/interface.d.ts +2 -0
- package/dist/adapters/interface.d.ts.map +1 -1
- package/dist/adapters/jsx-adapter.d.ts +4 -0
- package/dist/adapters/jsx-adapter.d.ts.map +1 -1
- package/dist/adapters/literal-value.d.ts +2 -2
- package/dist/adapters/literal-value.d.ts.map +1 -1
- package/dist/adapters/parsed-expr-emitter.d.ts +27 -0
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/adapters/style-object.d.ts +33 -0
- package/dist/adapters/style-object.d.ts.map +1 -0
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/augment-inherited-props.d.ts +7 -0
- package/dist/augment-inherited-props.d.ts.map +1 -1
- package/dist/children-nullish.d.ts +22 -0
- package/dist/children-nullish.d.ts.map +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/expression-parser.d.ts +9 -19
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/fold-render-reassignments.d.ts +43 -0
- package/dist/fold-render-reassignments.d.ts.map +1 -0
- package/dist/free-refs.d.ts +15 -0
- package/dist/free-refs.d.ts.map +1 -1
- package/dist/index.d.ts +21 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24620 -23233
- package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts +2 -1
- package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/insert.d.ts +2 -2
- package/dist/ir-to-client-js/control-flow/plan/insert.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +10 -9
- package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
- package/dist/ir-to-client-js/csr-substitute.d.ts +0 -13
- package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-reactive.d.ts +1 -1
- package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-registration.d.ts +10 -8
- package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
- package/dist/ir-to-client-js/generate-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts +9 -19
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/identifiers.d.ts +6 -8
- package/dist/ir-to-client-js/identifiers.d.ts.map +1 -1
- package/dist/ir-to-client-js/imports.d.ts +23 -2
- package/dist/ir-to-client-js/imports.d.ts.map +1 -1
- package/dist/ir-to-client-js/index.d.ts.map +1 -1
- package/dist/ir-to-client-js/phases/props-extraction.d.ts +3 -2
- package/dist/ir-to-client-js/phases/props-extraction.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/declaration-emit.d.ts +5 -0
- package/dist/ir-to-client-js/plan/declaration-emit.d.ts.map +1 -1
- package/dist/ir-to-client-js/prop-handling.d.ts +11 -12
- package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
- package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts +1 -1
- package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts.map +1 -1
- package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
- package/dist/ir-to-client-js/rewrite-destructured-props.d.ts +1 -1
- package/dist/ir-to-client-js/rewrite-destructured-props.d.ts.map +1 -1
- package/dist/ir-to-client-js/safe-html.d.ts +20 -2
- package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +3 -3
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +15 -11
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +43 -12
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/prop-rewrite.d.ts +18 -0
- package/dist/prop-rewrite.d.ts.map +1 -1
- package/dist/props-binding.d.ts +43 -6
- package/dist/props-binding.d.ts.map +1 -1
- package/dist/relocate.d.ts +16 -0
- package/dist/relocate.d.ts.map +1 -1
- package/dist/scanner/js-scanner.d.ts.map +1 -1
- package/dist/scanner/js-scanner.js +30 -2
- package/dist/signal-prop-name-collision.d.ts +6 -5
- package/dist/signal-prop-name-collision.d.ts.map +1 -1
- package/dist/ssr-defaults.d.ts +28 -0
- package/dist/ssr-defaults.d.ts.map +1 -1
- package/dist/ssr-seed-plan.d.ts +37 -18
- package/dist/ssr-seed-plan.d.ts.map +1 -1
- package/dist/types.d.ts +162 -20
- package/dist/types.d.ts.map +1 -1
- package/dist/value-references.d.ts +21 -0
- package/dist/value-references.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +18 -18
- package/src/__tests__/adapter-output.test.ts +5 -3
- package/src/__tests__/analyzer.test.ts +33 -0
- package/src/__tests__/arithmetic-lowering.test.ts +44 -0
- package/src/__tests__/block-memo-type.test.ts +51 -0
- package/src/__tests__/callback-method.test.ts +75 -0
- package/src/__tests__/children-read.test.ts +226 -0
- package/src/__tests__/client-only-date-lowering.test.ts +2 -2
- package/src/__tests__/client-template-escape-soundness.test.ts +31 -1
- package/src/__tests__/component-props.test.ts +68 -1
- package/src/__tests__/computed-const.test.ts +101 -0
- package/src/__tests__/constant-inlining-tree.test.ts +136 -0
- package/src/__tests__/destructure-default-reads-earlier-param.test.ts +138 -0
- package/src/__tests__/dsl-template-adapter.test.ts +173 -0
- package/src/__tests__/element-shell.test.ts +78 -0
- package/src/__tests__/event-handler-verbatim.test.ts +73 -0
- package/src/__tests__/expression-parser.test.ts +1 -44
- package/src/__tests__/fold-render-reassignments.test.ts +96 -0
- package/src/__tests__/inlinable-local-method-call.test.ts +81 -0
- package/src/__tests__/memo-body-expr.test.ts +120 -0
- package/src/__tests__/nullable-signal-attr.test.ts +67 -3
- package/src/__tests__/prop-handling.test.ts +35 -16
- package/src/__tests__/props-alias-const.test.ts +65 -0
- package/src/__tests__/reference-graph-identifiers.test.ts +161 -0
- package/src/__tests__/runtime-import-detection.test.ts +134 -0
- package/src/__tests__/signal-prop-name-collision.test.ts +30 -0
- package/src/__tests__/signal-prop-seed.test.ts +90 -0
- package/src/__tests__/ssr-defaults.test.ts +19 -1
- package/src/__tests__/ssr-seed-plan.test.ts +173 -1
- package/src/__tests__/static-template-reachability.test.ts +137 -0
- package/src/__tests__/style-object-plan.test.ts +54 -0
- package/src/__tests__/zero-param-helper-inline.test.ts +57 -0
- package/src/adapters/attr-plan.ts +29 -1
- package/src/adapters/callback-method.ts +85 -0
- package/src/adapters/component-props.ts +130 -12
- package/src/adapters/computed-const.ts +185 -0
- package/src/adapters/dangerous-inner-html.ts +33 -0
- package/src/adapters/dsl-template-adapter.ts +248 -0
- package/src/adapters/element-shell.ts +160 -0
- package/src/adapters/interface.ts +8 -0
- package/src/adapters/jsx-adapter.ts +12 -6
- package/src/adapters/literal-value.ts +2 -2
- package/src/adapters/parsed-expr-emitter.ts +34 -0
- package/src/adapters/style-object.ts +61 -0
- package/src/analyzer.ts +382 -94
- package/src/augment-inherited-props.ts +12 -0
- package/src/children-nullish.ts +33 -0
- package/src/debug.ts +2 -2
- package/src/errors.ts +12 -0
- package/src/expression-parser.ts +56 -53
- package/src/fold-render-reassignments.ts +314 -0
- package/src/free-refs.ts +77 -17
- package/src/index.ts +27 -10
- package/src/ir-to-client-js/compute-inlinability.ts +122 -19
- package/src/ir-to-client-js/control-flow/plan/event-collision.ts +2 -1
- package/src/ir-to-client-js/control-flow/plan/insert.ts +2 -2
- package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +3 -2
- package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +13 -12
- package/src/ir-to-client-js/csr-substitute.ts +25 -37
- package/src/ir-to-client-js/emit-reactive.ts +2 -2
- package/src/ir-to-client-js/emit-registration.ts +31 -59
- package/src/ir-to-client-js/generate-init.ts +17 -1
- package/src/ir-to-client-js/html-template.ts +56 -120
- package/src/ir-to-client-js/identifiers.ts +75 -24
- package/src/ir-to-client-js/imports.ts +56 -19
- package/src/ir-to-client-js/index.ts +5 -3
- package/src/ir-to-client-js/init-declarations.ts +1 -1
- package/src/ir-to-client-js/phases/event-handlers.ts +2 -2
- package/src/ir-to-client-js/phases/props-extraction.ts +16 -15
- package/src/ir-to-client-js/plan/build-declaration-emit.ts +26 -52
- package/src/ir-to-client-js/plan/declaration-emit.ts +5 -0
- package/src/ir-to-client-js/prop-handling.ts +13 -54
- package/src/ir-to-client-js/prune-unused-prop-extractions.ts +7 -4
- package/src/ir-to-client-js/reactivity.ts +2 -2
- package/src/ir-to-client-js/rewrite-destructured-props.ts +27 -9
- package/src/ir-to-client-js/safe-html.ts +29 -35
- package/src/ir-to-client-js/stringify/declaration-emit.ts +1 -1
- package/src/ir-to-client-js/types.ts +3 -2
- package/src/ir-to-client-js/utils.ts +13 -26
- package/src/jsx-to-ir.ts +318 -130
- package/src/nullable-signal-attr.ts +156 -37
- package/src/prop-rewrite.ts +41 -0
- package/src/props-binding.ts +117 -7
- package/src/relocate.ts +40 -8
- package/src/scanner/__tests__/js-scanner.test.ts +37 -0
- package/src/scanner/js-scanner.ts +64 -4
- package/src/signal-prop-name-collision.ts +50 -24
- package/src/ssr-defaults.ts +47 -20
- package/src/ssr-seed-plan.ts +121 -29
- package/src/types.ts +165 -21
- package/src/value-references.ts +132 -0
|
@@ -162,7 +162,7 @@ describe('computeSsrSeedPlan', () => {
|
|
|
162
162
|
}
|
|
163
163
|
})
|
|
164
164
|
|
|
165
|
-
test('block-bodied memo →
|
|
165
|
+
test('block-bodied memo → derived from its fold (#3523)', () => {
|
|
166
166
|
const plan = planFor(`
|
|
167
167
|
'use client'
|
|
168
168
|
import { createMemo, createSignal } from '@barefootjs/client'
|
|
@@ -176,11 +176,64 @@ describe('computeSsrSeedPlan', () => {
|
|
|
176
176
|
}
|
|
177
177
|
`)
|
|
178
178
|
|
|
179
|
+
const label = step(plan, 'label')
|
|
180
|
+
expect(label.kind).toBe('derived')
|
|
181
|
+
if (label.kind === 'derived') expect(label.frees).toContain('on')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
test('block-bodied memo that does not fold → opaque', () => {
|
|
185
|
+
const plan = planFor(`
|
|
186
|
+
'use client'
|
|
187
|
+
import { createMemo, createSignal } from '@barefootjs/client'
|
|
188
|
+
function C() {
|
|
189
|
+
const [on, setOn] = createSignal(false)
|
|
190
|
+
const label = createMemo(() => {
|
|
191
|
+
let n = 0
|
|
192
|
+
for (const x of [1, 2]) n += x
|
|
193
|
+
return on() ? n : 0
|
|
194
|
+
})
|
|
195
|
+
return <p>{label()}</p>
|
|
196
|
+
}
|
|
197
|
+
`)
|
|
198
|
+
|
|
179
199
|
const label = step(plan, 'label')
|
|
180
200
|
expect(label.kind).toBe('opaque')
|
|
181
201
|
if (label.kind === 'opaque') expect(label.origin).toBe('memo')
|
|
182
202
|
})
|
|
183
203
|
|
|
204
|
+
test.each([
|
|
205
|
+
["(label = 'inner') => label"],
|
|
206
|
+
["(label = 'inner') => { const k = label\n return k }"],
|
|
207
|
+
])('memo callback with a parameter → opaque: %s', (callback) => {
|
|
208
|
+
const plan = planFor(`
|
|
209
|
+
'use client'
|
|
210
|
+
import { createMemo, createSignal } from '@barefootjs/client'
|
|
211
|
+
function C({ label }: { label: string }) {
|
|
212
|
+
const [on] = createSignal(false)
|
|
213
|
+
const m = createMemo(${callback})
|
|
214
|
+
return <p>{m()}{on() ? 'y' : 'n'}</p>
|
|
215
|
+
}
|
|
216
|
+
`)
|
|
217
|
+
expect(step(plan, 'm').kind).toBe('opaque')
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
test('block memo with a /* @client */ directive → opaque', () => {
|
|
221
|
+
const plan = planFor(`
|
|
222
|
+
'use client'
|
|
223
|
+
import { createMemo, createSignal } from '@barefootjs/client'
|
|
224
|
+
function C() {
|
|
225
|
+
const [date] = createSignal<Date | undefined>(undefined)
|
|
226
|
+
const label = createMemo(() => {
|
|
227
|
+
const d = date()
|
|
228
|
+
if (!d) return 'none'
|
|
229
|
+
return /* @client */ d.toLocaleDateString('en-US')
|
|
230
|
+
})
|
|
231
|
+
return <p>{label()}</p>
|
|
232
|
+
}
|
|
233
|
+
`)
|
|
234
|
+
expect(step(plan, 'label').kind).toBe('opaque')
|
|
235
|
+
})
|
|
236
|
+
|
|
184
237
|
test('object-literal body → derived (#2696: value-position object literal, isSupportedValue)', () => {
|
|
185
238
|
// Was `opaque` before `checkSupport` gained its `pos` parameter — a
|
|
186
239
|
// memo's WHOLE body is a value position (an assignment, never a
|
|
@@ -274,6 +327,65 @@ describe('computeSsrSeedPlan', () => {
|
|
|
274
327
|
}
|
|
275
328
|
})
|
|
276
329
|
|
|
330
|
+
test('a seed calling a zero-param local arrow helper derives through its body (#3562)', () => {
|
|
331
|
+
const plan = planFor(`
|
|
332
|
+
'use client'
|
|
333
|
+
import { createSignal } from '@barefootjs/client'
|
|
334
|
+
function C(props: { mode?: string; label?: string }) {
|
|
335
|
+
const isWide = () => props.mode === 'wide'
|
|
336
|
+
const [shown] = createSignal(isWide() ? props.label : 'narrow')
|
|
337
|
+
return <p>{shown()}</p>
|
|
338
|
+
}
|
|
339
|
+
`)
|
|
340
|
+
const shown = step(plan, 'shown')
|
|
341
|
+
expect(shown.kind).toBe('derived')
|
|
342
|
+
if (shown.kind === 'derived') expect(shown.frees).toEqual(['props'])
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
test('a helper whose body a callback param would capture stays opaque (#3562)', () => {
|
|
346
|
+
const plan = planFor(`
|
|
347
|
+
'use client'
|
|
348
|
+
import { createSignal } from '@barefootjs/client'
|
|
349
|
+
function C(props: { items: string[]; tag?: string }) {
|
|
350
|
+
const tag = props.tag
|
|
351
|
+
const matches = () => tag === 'x'
|
|
352
|
+
const [n] = createSignal(props.items.filter(tag => matches()).length)
|
|
353
|
+
return <p>{n()}</p>
|
|
354
|
+
}
|
|
355
|
+
`)
|
|
356
|
+
expect(step(plan, 'n').kind).toBe('opaque')
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
test.each([
|
|
360
|
+
['an async arrow', 'const helper = async () => props.flag'],
|
|
361
|
+
['a generator function', 'const helper = function* () { return props.flag }'],
|
|
362
|
+
['a body that mutates state', 'let n = 0\n const helper = () => (n += 1)'],
|
|
363
|
+
])('a helper call to %s stays opaque (#3562 review)', (_label, decl) => {
|
|
364
|
+
const plan = planFor(`
|
|
365
|
+
'use client'
|
|
366
|
+
import { createSignal } from '@barefootjs/client'
|
|
367
|
+
function C(props: { flag?: boolean }) {
|
|
368
|
+
${decl}
|
|
369
|
+
const [shown] = createSignal(helper() ? 'yes' : 'no')
|
|
370
|
+
return <p>{shown()}</p>
|
|
371
|
+
}
|
|
372
|
+
`)
|
|
373
|
+
expect(step(plan, 'shown').kind).toBe('opaque')
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
test('a helper that takes params is not inlined at a call site (#3562)', () => {
|
|
377
|
+
const plan = planFor(`
|
|
378
|
+
'use client'
|
|
379
|
+
import { createSignal } from '@barefootjs/client'
|
|
380
|
+
function C(props: { mode?: string }) {
|
|
381
|
+
const is = (m: string) => props.mode === m
|
|
382
|
+
const [wide] = createSignal(is('wide'))
|
|
383
|
+
return <p>{String(wide())}</p>
|
|
384
|
+
}
|
|
385
|
+
`)
|
|
386
|
+
expect(step(plan, 'wide').kind).toBe('opaque')
|
|
387
|
+
})
|
|
388
|
+
|
|
277
389
|
test('multi-hop const chain THROUGH TWO component-scope consts (#2685 review): still derived', () => {
|
|
278
390
|
const plan = planFor(`
|
|
279
391
|
'use client'
|
|
@@ -314,4 +426,64 @@ describe('computeSsrSeedPlan', () => {
|
|
|
314
426
|
const on = step(plan, 'on')
|
|
315
427
|
expect(on.kind).toBe('opaque')
|
|
316
428
|
})
|
|
429
|
+
|
|
430
|
+
test('a derived step reading only inlined module consts, or nothing, is constant (#3542)', () => {
|
|
431
|
+
const plan = planFor(`
|
|
432
|
+
'use client'
|
|
433
|
+
import { createSignal, createMemo } from '@barefootjs/client'
|
|
434
|
+
const PREFIX = 'pre'
|
|
435
|
+
function C(props: { label: string }) {
|
|
436
|
+
const [first] = createSignal([{ a: 'p' }].map((t) => t.a).join(','))
|
|
437
|
+
const [tagged] = createSignal(PREFIX + '-x')
|
|
438
|
+
const [label] = createSignal(props.label + '!')
|
|
439
|
+
const both = createMemo(() => PREFIX + first())
|
|
440
|
+
return <p>{first()}{tagged()}{label()}{both()}</p>
|
|
441
|
+
}
|
|
442
|
+
`)
|
|
443
|
+
const constantOf = (name: string) => {
|
|
444
|
+
const s = step(plan, name)
|
|
445
|
+
return s.kind === 'derived' ? s.constant : null
|
|
446
|
+
}
|
|
447
|
+
expect(constantOf('first')).toBe(true)
|
|
448
|
+
expect(constantOf('tagged')).toBe(true)
|
|
449
|
+
expect(constantOf('label')).toBe(false)
|
|
450
|
+
expect(constantOf('both')).toBe(false)
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
test('a destructure default reading an earlier prop re-binds the prop first, in parameter order (#3531)', () => {
|
|
454
|
+
const plan = planFor(`
|
|
455
|
+
'use client'
|
|
456
|
+
import { createSignal } from '@barefootjs/client'
|
|
457
|
+
function C({ a = 'x', b = a, c = b, off = false, on = !off, plain = 1 }: { a?: string; b?: string; c?: string; off?: boolean; on?: boolean; plain?: number }) {
|
|
458
|
+
const [v] = createSignal(c)
|
|
459
|
+
return <p>{v()}{String(on)}{plain}</p>
|
|
460
|
+
}
|
|
461
|
+
`)
|
|
462
|
+
expect(plan.steps.map(s => s.name)).toEqual(['b', 'c', 'on', 'v'])
|
|
463
|
+
const b = step(plan, 'b')
|
|
464
|
+
expect(b.kind).toBe('derived')
|
|
465
|
+
if (b.kind === 'derived') {
|
|
466
|
+
expect(b.origin).toBe('prop')
|
|
467
|
+
expect(b.parsed).toEqual({
|
|
468
|
+
kind: 'logical',
|
|
469
|
+
op: '??',
|
|
470
|
+
left: { kind: 'identifier', name: 'b' },
|
|
471
|
+
right: { kind: 'identifier', name: 'a' },
|
|
472
|
+
})
|
|
473
|
+
expect(b.constant).toBe(false)
|
|
474
|
+
}
|
|
475
|
+
const on = step(plan, 'on')
|
|
476
|
+
if (on.kind === 'derived') expect(on.expr).toBe('on ?? !off')
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
test('dependent prop defaults follow the reads, not the props type order (#3531)', () => {
|
|
480
|
+
const plan = planFor(`
|
|
481
|
+
'use client'
|
|
482
|
+
function C(props: { c?: string; b?: string; a?: string }) {
|
|
483
|
+
const { a = 'x', b = a, c = b } = props
|
|
484
|
+
return <p>{a}{b}{c}</p>
|
|
485
|
+
}
|
|
486
|
+
`)
|
|
487
|
+
expect(plan.steps.map(s => s.name)).toEqual(['b', 'c'])
|
|
488
|
+
})
|
|
317
489
|
})
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3509: whether a component's `template:` lambda takes the static path
|
|
3
|
+
* (`irToComponentTemplate`, expressions emitted as written) or the CSR path
|
|
4
|
+
* (`generateCsrTemplate`, signal/memo reads replaced by their initial values)
|
|
5
|
+
* is decided from the IR's free identifiers, not the expression text. The
|
|
6
|
+
* lambda runs at module scope, where a signal getter or memo is not defined,
|
|
7
|
+
* so an expression that reads one must take the CSR path wherever the read
|
|
8
|
+
* sits in it. The text check classified `label + count()` by its leading
|
|
9
|
+
* identifier (a prop) and sent it to the static path, which emitted a bare
|
|
10
|
+
* `count()`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, test, expect } from 'bun:test'
|
|
14
|
+
import { compileJSX } from '../compiler'
|
|
15
|
+
import { TestAdapter } from '../adapters/test-adapter'
|
|
16
|
+
|
|
17
|
+
const adapter = new TestAdapter()
|
|
18
|
+
|
|
19
|
+
function templateLambda(source: string): string {
|
|
20
|
+
const result = compileJSX(source, 'T.tsx', { adapter })
|
|
21
|
+
expect(result.errors.filter((e) => e.severity === 'error')).toHaveLength(0)
|
|
22
|
+
const clientJs = result.files.find((f) => f.type === 'clientJs')!
|
|
23
|
+
const line = clientJs.content.split('\n').find((l) => l.includes('hydrate('))
|
|
24
|
+
if (!line) throw new Error('no hydrate() call in client JS')
|
|
25
|
+
const match = line.match(/template: (\(_p\) => `.*`) \}\)$/)
|
|
26
|
+
if (!match) throw new Error(`no template lambda in: ${line}`)
|
|
27
|
+
return match[1]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Evaluate the lambda at "module scope": only the escape helpers exist. */
|
|
31
|
+
function render(lambda: string, props: Record<string, unknown>): string {
|
|
32
|
+
const template = new Function('escapeTextOrMarkup', 'escapeText', 'escapeAttr', `return ${lambda}`)(String, String, String)
|
|
33
|
+
return template(props)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const header = `
|
|
37
|
+
'use client'
|
|
38
|
+
import { createSignal, createMemo } from '@barefootjs/client'
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
describe('static template eligibility reads IR free identifiers (#3509)', () => {
|
|
42
|
+
test('a prop-first expression that calls a signal, in text, attribute and condition', () => {
|
|
43
|
+
const lambda = templateLambda(`${header}
|
|
44
|
+
export function PropFirst({ label }: { label: string }) {
|
|
45
|
+
const [count, setCount] = createSignal(0)
|
|
46
|
+
return (
|
|
47
|
+
<button data-x={label + count()} onClick={() => setCount(count() + 1)}>
|
|
48
|
+
{label + count()}
|
|
49
|
+
{label.length > count() ? <b>y</b> : <i>n</i>}
|
|
50
|
+
</button>
|
|
51
|
+
)
|
|
52
|
+
}`)
|
|
53
|
+
expect(lambda).not.toContain('count()')
|
|
54
|
+
const html = render(lambda, { label: 'Clicks: ' })
|
|
55
|
+
expect(html).toContain('data-x="Clicks: 0"')
|
|
56
|
+
expect(html).toContain('Clicks: 0')
|
|
57
|
+
expect(html).toContain('<b')
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('the result does not depend on operand order', () => {
|
|
61
|
+
const source = (expr: string) => `${header}
|
|
62
|
+
export function Order({ label }: { label: string }) {
|
|
63
|
+
const [count, setCount] = createSignal(0)
|
|
64
|
+
return <button onClick={() => setCount(count() + 1)}>{${expr}}</button>
|
|
65
|
+
}`
|
|
66
|
+
const propFirst = render(templateLambda(source('label + count()')), { label: 'n=' })
|
|
67
|
+
const signalFirst = render(templateLambda(source('count() + label')), { label: 'n=' })
|
|
68
|
+
expect(propFirst).toContain('n=0')
|
|
69
|
+
expect(signalFirst).toContain('0n=')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('a prop-first expression that reads a memo', () => {
|
|
73
|
+
const lambda = templateLambda(`${header}
|
|
74
|
+
export function Derived({ label }: { label: string }) {
|
|
75
|
+
const [count, setCount] = createSignal(1)
|
|
76
|
+
const doubled = createMemo(() => count() * 2)
|
|
77
|
+
return (
|
|
78
|
+
<button onClick={() => setCount(count() + 1)}>
|
|
79
|
+
{label + doubled()}
|
|
80
|
+
</button>
|
|
81
|
+
)
|
|
82
|
+
}`)
|
|
83
|
+
expect(lambda).not.toContain('doubled()')
|
|
84
|
+
expect(render(lambda, { label: 'x' })).toContain('x2')
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('a prop-only expression with a call renders from the prop', () => {
|
|
88
|
+
const lambda = templateLambda(`${header}
|
|
89
|
+
export function PropOnly({ label }: { label: string }) {
|
|
90
|
+
const [count, setCount] = createSignal(0)
|
|
91
|
+
return <button onClick={() => setCount(count() + 1)}>{label.toUpperCase()}</button>
|
|
92
|
+
}`)
|
|
93
|
+
expect(render(lambda, { label: 'hi' })).toContain('HI')
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test('a signal passed into an inlined JSX helper, in text, attribute and condition', () => {
|
|
97
|
+
const lambda = templateLambda(`${header}
|
|
98
|
+
export function Helper({ label }: { label: string }) {
|
|
99
|
+
const [count, setCount] = createSignal(0)
|
|
100
|
+
function text(value: number) {
|
|
101
|
+
return <span>{value}</span>
|
|
102
|
+
}
|
|
103
|
+
function attr(value: number) {
|
|
104
|
+
return <span data-x={value} />
|
|
105
|
+
}
|
|
106
|
+
function cond(value: number) {
|
|
107
|
+
return <span>{value ? <b>yes</b> : <i>no</i>}</span>
|
|
108
|
+
}
|
|
109
|
+
return (
|
|
110
|
+
<button onClick={() => setCount(count() + 1)}>
|
|
111
|
+
{label}
|
|
112
|
+
{text(count())}
|
|
113
|
+
{attr(count())}
|
|
114
|
+
{cond(count())}
|
|
115
|
+
</button>
|
|
116
|
+
)
|
|
117
|
+
}`)
|
|
118
|
+
expect(lambda).not.toContain('count()')
|
|
119
|
+
const html = render(lambda, { label: 'n' })
|
|
120
|
+
expect(html).toContain('data-x="0"')
|
|
121
|
+
expect(html).toContain('<i')
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
test('a signal passed into an inlined multi-return JSX helper', () => {
|
|
125
|
+
const lambda = templateLambda(`${header}
|
|
126
|
+
export function MultiHelper({ label }: { label: string }) {
|
|
127
|
+
const [count, setCount] = createSignal(0)
|
|
128
|
+
function pick(value: number) {
|
|
129
|
+
if (value > 0) return <b>{value}</b>
|
|
130
|
+
return <i>{value}</i>
|
|
131
|
+
}
|
|
132
|
+
return <button onClick={() => setCount(count() + 1)}>{label}{pick(count())}</button>
|
|
133
|
+
}`)
|
|
134
|
+
expect(lambda).not.toContain('count()')
|
|
135
|
+
expect(render(lambda, { label: 'n' })).toContain('<i')
|
|
136
|
+
})
|
|
137
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `planStyleObject` lowers a `style={{ … }}` attribute from the IR's parsed
|
|
3
|
+
* object literal, once for every template adapter (#3541).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, test, expect } from 'bun:test'
|
|
7
|
+
import { planStyleObject } from '../adapters/style-object'
|
|
8
|
+
import { parseExpression } from '../expression-parser'
|
|
9
|
+
|
|
10
|
+
/** An attribute value as the IR carries it: `parsed` holds the object literal. */
|
|
11
|
+
const attr = (source: string) => ({ expr: source, parsed: parseExpression(`(${source})`) })
|
|
12
|
+
|
|
13
|
+
describe('planStyleObject', () => {
|
|
14
|
+
test('kebab-cases keys and splits literal vs expression values', () => {
|
|
15
|
+
expect(planStyleObject(attr("{ backgroundColor: color, padding: '8px' }"))).toEqual([
|
|
16
|
+
{ cssKey: 'background-color', kind: 'expr', expr: 'color', parsed: { kind: 'identifier', name: 'color' } },
|
|
17
|
+
{ cssKey: 'padding', kind: 'literal', value: '8px' },
|
|
18
|
+
])
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('accepts the shorthand `{ color }` the text parser refused', () => {
|
|
22
|
+
expect(planStyleObject(attr('{ color }'))).toEqual([
|
|
23
|
+
{ cssKey: 'color', kind: 'expr', expr: 'color', parsed: { kind: 'identifier', name: 'color' } },
|
|
24
|
+
])
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('signal-getter calls and numbers are expressions; quoted and template keys are literals', () => {
|
|
28
|
+
const plan = planStyleObject(attr("{ background: bg(), 'z-index': '1', width: `10px`, padding: 8 }"))
|
|
29
|
+
expect(plan?.map(e => [e.cssKey, e.kind === 'literal' ? e.value : e.expr])).toEqual([
|
|
30
|
+
['background', 'bg()'],
|
|
31
|
+
['z-index', '1'],
|
|
32
|
+
['width', '10px'],
|
|
33
|
+
['padding', '8'],
|
|
34
|
+
])
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('vendor-prefixed keys keep the leading dash', () => {
|
|
38
|
+
expect(planStyleObject(attr("{ WebkitTransform: 'none', msTransform: 'none' }"))?.map(e => e.cssKey)).toEqual([
|
|
39
|
+
'-webkit-transform',
|
|
40
|
+
'-ms-transform',
|
|
41
|
+
])
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('a spread, a numeric key or a non-object value stays on the refusal path', () => {
|
|
45
|
+
expect(planStyleObject(attr('{ ...rest }'))).toBeNull()
|
|
46
|
+
expect(planStyleObject(attr("{ 1: 'a' }"))).toBeNull()
|
|
47
|
+
expect(planStyleObject(attr('color'))).toBeNull()
|
|
48
|
+
expect(planStyleObject(attr('{}'))).toBeNull()
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('an attribute without a parsed tree stays on the refusal path', () => {
|
|
52
|
+
expect(planStyleObject({ expr: '{ color }' })).toBeNull()
|
|
53
|
+
})
|
|
54
|
+
})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3562: the CSR template substitutes a zero-param local helper
|
|
3
|
+
* (`const isWide = () => props.mode === 'wide'`) like any other const, so a
|
|
4
|
+
* template call `isWide()` reads its body instead of falling back to empty.
|
|
5
|
+
* A helper that is not a synchronous, pure value (a body that mutates state,
|
|
6
|
+
* an async arrow, a generator) is left alone: splicing `() => ({ id:
|
|
7
|
+
* ++nextId })` produced `++(0)`, a SyntaxError in the client bundle.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, test, expect } from 'bun:test'
|
|
11
|
+
import { compileJSX } from '../compiler'
|
|
12
|
+
import { HonoAdapter } from '../../../adapter-hono/src/adapter/hono-adapter'
|
|
13
|
+
|
|
14
|
+
const PRELUDE = "'use client'\nimport { createSignal } from '@barefootjs/client'\n"
|
|
15
|
+
|
|
16
|
+
function compile(body: string, jsx: string) {
|
|
17
|
+
const source = `${PRELUDE}export function S(props: { mode?: string; flag?: boolean }) {\n${body}\nreturn ${jsx}\n}`
|
|
18
|
+
const result = compileJSX(source, 'S.tsx', { adapter: new HonoAdapter() })
|
|
19
|
+
const clientJs = result.files.find((f) => f.path.endsWith('.client.js'))?.content ?? ''
|
|
20
|
+
const template = clientJs.split('\n').find((l) => l.includes('hydrate(')) ?? ''
|
|
21
|
+
return { clientJs, template }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Evaluate the registered `template:` lambda against `props`. */
|
|
25
|
+
function render(template: string, props: Record<string, unknown>): string {
|
|
26
|
+
const lambda = template.match(/template: (\(_p\) => `.*`) \}\)/)?.[1]
|
|
27
|
+
expect(lambda).toBeDefined()
|
|
28
|
+
return new Function('escapeAttr', 'escapeTextOrMarkup', `return ${lambda}`)(String, String)(props)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('zero-param helper in the CSR template (#3562)', () => {
|
|
32
|
+
test('a pure helper call reads its body', () => {
|
|
33
|
+
const { template } = compile(
|
|
34
|
+
"const isWide = () => props.mode === 'wide'\nconst [shown] = createSignal(isWide() ? 'wide' : 'narrow')",
|
|
35
|
+
'<p data-shown={shown()}>x</p>',
|
|
36
|
+
)
|
|
37
|
+
expect(render(template, { mode: 'wide' })).toContain('data-shown="wide"')
|
|
38
|
+
expect(render(template, { mode: 'tall' })).toContain('data-shown="narrow"')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('a helper that mutates state is not spliced, and the bundle still parses', () => {
|
|
42
|
+
const { clientJs } = compile(
|
|
43
|
+
"let nextId = 0\nconst createField = () => ({ id: ++nextId, value: '' })\nconst [fields] = createSignal([createField()])",
|
|
44
|
+
'<ul>{fields().map((f) => <li key={f.id}>{f.value}</li>)}</ul>',
|
|
45
|
+
)
|
|
46
|
+
expect(clientJs).not.toContain('++(')
|
|
47
|
+
expect(() => new Bun.Transpiler({ loader: 'js' }).transformSync(clientJs)).not.toThrow()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test.each([
|
|
51
|
+
['an async arrow', 'const helper = async () => props.flag'],
|
|
52
|
+
['a generator function', 'const helper = function* () { return props.flag }'],
|
|
53
|
+
])('%s is not spliced', (_label, decl) => {
|
|
54
|
+
const { template } = compile(`${decl}\nconst [shown] = createSignal(helper() ? 'yes' : 'no')`, '<p data-shown={shown()}>x</p>')
|
|
55
|
+
expect(template).not.toContain('_p.flag')
|
|
56
|
+
})
|
|
57
|
+
})
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { exprToString, isSupported, parseExpression, type ParsedExpr } from '../expression-parser.ts'
|
|
14
14
|
import type { LoweringMatcher } from '../lowering-registry.ts'
|
|
15
15
|
import { attrValueMayBeNullish, nullableSignalAttrGetter, type NullishAttrContext } from '../nullable-signal-attr.ts'
|
|
16
|
-
import type { ConstantInfo, ExpressionAttr, SpreadAttr } from '../types.ts'
|
|
16
|
+
import type { CompilerError, ConstantInfo, ExpressionAttr, SpreadAttr } from '../types.ts'
|
|
17
17
|
import { isBooleanAttr } from '../html-constants.ts'
|
|
18
18
|
|
|
19
19
|
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/
|
|
@@ -41,6 +41,34 @@ export function unsupportedAttrExpression(
|
|
|
41
41
|
return { reason: support.reason ?? (parsed.kind === 'unsupported' ? parsed.reason : undefined) }
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The BF101 for an attribute value {@link unsupportedAttrExpression}
|
|
46
|
+
* refuses, worded for one adapter (`adapterLabel`, e.g. `Mojo`) and its
|
|
47
|
+
* template language (`languageLabel`, e.g. `Embedded Perl`); `null` when the
|
|
48
|
+
* value goes on to {@link planAttrExpression}.
|
|
49
|
+
*/
|
|
50
|
+
export function unsupportedAttrExpressionError(
|
|
51
|
+
expr: string,
|
|
52
|
+
attrName: string,
|
|
53
|
+
loweringMatchers: readonly LoweringMatcher[],
|
|
54
|
+
componentName: string,
|
|
55
|
+
adapterLabel: string,
|
|
56
|
+
languageLabel: string,
|
|
57
|
+
): CompilerError | null {
|
|
58
|
+
const refusal = unsupportedAttrExpression(expr, loweringMatchers)
|
|
59
|
+
if (!refusal) return null
|
|
60
|
+
const reasonLine = refusal.reason ? `\n${refusal.reason}` : ''
|
|
61
|
+
return {
|
|
62
|
+
code: 'BF101',
|
|
63
|
+
severity: 'error',
|
|
64
|
+
message: `Expression not supported on attribute '${attrName}': ${expr.trim()}${reasonLine}`,
|
|
65
|
+
loc: { file: componentName + '.tsx', start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
66
|
+
suggestion: {
|
|
67
|
+
message: `The ${adapterLabel} adapter cannot lower JS object literals or tagged-template-literal expressions into ${languageLabel}. Move the expression into a \`'use client'\` component (so hydration computes it), or expand it into discrete attributes whose values are values the adapter can lower.`,
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
44
72
|
/**
|
|
45
73
|
* The emission of an `{expr}` attribute value.
|
|
46
74
|
*
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
readsNestedCallbackIndex,
|
|
23
23
|
serializeParsedExpr,
|
|
24
24
|
sortComparatorFromArrow,
|
|
25
|
+
stringifyParsedExpr,
|
|
25
26
|
type ParsedExpr,
|
|
26
27
|
type SortComparator,
|
|
27
28
|
} from '../expression-parser.ts'
|
|
@@ -289,6 +290,90 @@ export function emitCallbackEval(
|
|
|
289
290
|
return spelling.call(plan.helper, operands)
|
|
290
291
|
}
|
|
291
292
|
|
|
293
|
+
/**
|
|
294
|
+
* Whether a call that reached an adapter's generic fallback has no lowering
|
|
295
|
+
* (#3493). A zero-arg call reads a getter (`props.value()`, a getter passed
|
|
296
|
+
* as a prop, a context getter `ctx.open()`), unless its receiver is rooted at
|
|
297
|
+
* a JavaScript global (`Date.now()`, `window.performance.now()`): `isGlobal`
|
|
298
|
+
* answers that from the component's bindings and the live loop scope, and a
|
|
299
|
+
* global has no binding in template scope (#3505). A call to a
|
|
300
|
+
* function-valued prop (`props.renderNode(node)`, a render prop) names a
|
|
301
|
+
* value a backend caller never passes, so the guard around it is never taken
|
|
302
|
+
* there; it keeps the callee read. Any other call with arguments
|
|
303
|
+
* (`s().localeCompare('m')`) would lose the call and its arguments.
|
|
304
|
+
* `propsObjectName` is the undestructured props parameter (`props`), `null`
|
|
305
|
+
* when the props are destructured: a destructured render prop is a
|
|
306
|
+
* bare-name call, which the adapters refuse on their own.
|
|
307
|
+
*/
|
|
308
|
+
export function isUnloweredCall(
|
|
309
|
+
callee: ParsedExpr,
|
|
310
|
+
args: readonly ParsedExpr[],
|
|
311
|
+
propsObjectName: string | null,
|
|
312
|
+
isGlobal: (name: string) => boolean,
|
|
313
|
+
): boolean {
|
|
314
|
+
if (args.length === 0) {
|
|
315
|
+
const root = memberRoot(callee)
|
|
316
|
+
return root !== null && isGlobal(root)
|
|
317
|
+
}
|
|
318
|
+
return !(callee.kind === 'member' && callee.object.kind === 'identifier' && callee.object.name === propsObjectName)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* The identifier a member chain is rooted at, through literal and computed
|
|
323
|
+
* access alike (`window.performance.now`, `Date[key]`,
|
|
324
|
+
* `globalThis[name].now`); `null` for any other callee.
|
|
325
|
+
*/
|
|
326
|
+
function memberRoot(callee: ParsedExpr): string | null {
|
|
327
|
+
if (callee.kind !== 'member' && callee.kind !== 'index-access') return null
|
|
328
|
+
let object = callee.object
|
|
329
|
+
while (object.kind === 'member' || object.kind === 'index-access') object = object.object
|
|
330
|
+
return object.kind === 'identifier' ? object.name : null
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* The BF101 for a call no template lowers: a method outside the array-method
|
|
335
|
+
* catalogue (`s().localeCompare('m')`), a zero-arg call on a JavaScript
|
|
336
|
+
* global (`Date.now()`), or any other callee that is not a getter, a template
|
|
337
|
+
* primitive or a lowering plugin's call. Read as its callee, the call and its
|
|
338
|
+
* arguments would silently disappear (#3493, #3505).
|
|
339
|
+
*/
|
|
340
|
+
export function unloweredCallRefusal(
|
|
341
|
+
callee: ParsedExpr,
|
|
342
|
+
args: readonly ParsedExpr[],
|
|
343
|
+
adapterName: string,
|
|
344
|
+
): { message: string; suggestion: string } {
|
|
345
|
+
const name = stringifyParsedExpr(callee)
|
|
346
|
+
return {
|
|
347
|
+
message: args.length === 0
|
|
348
|
+
? `Call '${name}()' reads a JavaScript global, which has no ${adapterName} template binding; read as a value it would drop the call`
|
|
349
|
+
: `Call '${name}(...)' has no ${adapterName} template lowering; read as a value it would drop the call and its arguments`,
|
|
350
|
+
suggestion: 'Pre-compute the value in the backend and pass it as a prop, or add /* @client */ for client-only evaluation (no SSR).',
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* BF101 for a `.filter(...).map(...)` predicate shape a DSL adapter's filter
|
|
356
|
+
* emitter has no form for: a conditional, a template literal, an object
|
|
357
|
+
* literal, a standalone arrow or regex, or an unsupported node (#3534). The
|
|
358
|
+
* emitters used to stand a truthy constant in for these, so every row
|
|
359
|
+
* rendered; the same predicate outside a loop is evaluated or refused, never
|
|
360
|
+
* guessed.
|
|
361
|
+
*/
|
|
362
|
+
export function filterPredicateShapeRefusal(shape: string, adapterName: string): { message: string; suggestion: string } {
|
|
363
|
+
return {
|
|
364
|
+
message: `Filter predicate contains ${shape}, which has no ${adapterName} loop-filter form`,
|
|
365
|
+
suggestion: `Rewrite the predicate as comparisons joined with && / || / !, or add /* @client */ for client-only evaluation (no SSR).`,
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** BF101 for a loop filter whose predicate never reached the IR (#3534). */
|
|
370
|
+
export function missingFilterPredicateRefusal(raw: string, adapterName: string): { message: string; suggestion: string } {
|
|
371
|
+
return {
|
|
372
|
+
message: `Filter predicate '${raw}' has no ${adapterName} loop-filter form`,
|
|
373
|
+
suggestion: `Rewrite the predicate as an expression-body arrow, or add /* @client */ for client-only evaluation (no SSR).`,
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
292
377
|
/**
|
|
293
378
|
* The BF101 for a callback method nested inside a filter predicate, which a
|
|
294
379
|
* predicate emitter has no scalar form for.
|