prunelle 0.8.0 → 0.10.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 (209) hide show
  1. package/llms.txt +68 -51
  2. package/package.json +7 -2
  3. package/src/a11y/declaration.ts +10 -17
  4. package/src/a11y/index.ts +69 -125
  5. package/src/animate.ts +127 -0
  6. package/src/build/asides.ts +51 -0
  7. package/src/build/bundle.ts +94 -136
  8. package/src/build/client-entries.ts +6 -6
  9. package/src/build/client-outputs.ts +75 -0
  10. package/src/build/client-plugin.ts +9 -4
  11. package/src/build/ecoindex.ts +4 -2
  12. package/src/build/files.ts +18 -0
  13. package/src/build/graph.ts +14 -6
  14. package/src/build/index.ts +23 -11
  15. package/src/build/island-promote.ts +42 -2
  16. package/src/build/islands.ts +63 -9
  17. package/src/build/key-types.ts +31 -0
  18. package/src/build/manifest.ts +117 -1
  19. package/src/build/plugin-host.ts +13 -1
  20. package/src/build/prerender.ts +8 -3
  21. package/src/build/reach.ts +18 -4
  22. package/src/build/report.ts +1 -1
  23. package/src/build/resolve.ts +5 -1
  24. package/src/build/route-types.ts +16 -0
  25. package/src/build/routes.ts +42 -15
  26. package/src/build/seed-ids.ts +65 -0
  27. package/src/build/seed-writes.ts +111 -0
  28. package/src/build/static-headers.ts +2 -2
  29. package/src/build/static.ts +1 -1
  30. package/src/cli/check-cache.ts +51 -0
  31. package/src/cli/check-consent.ts +95 -0
  32. package/src/cli/check-forms.ts +10 -2
  33. package/src/cli/check-links-patterns.ts +101 -0
  34. package/src/cli/check-links.ts +30 -105
  35. package/src/cli/check-regions.ts +185 -0
  36. package/src/cli/check-security.ts +50 -6
  37. package/src/cli/check.ts +49 -21
  38. package/src/cli/commands.ts +138 -16
  39. package/src/cli/docs.ts +21 -2
  40. package/src/cli/form-opaque-children.ts +40 -0
  41. package/src/cli/index.ts +1 -1
  42. package/src/cli/inspect.ts +2 -0
  43. package/src/cli/mcp-tools.ts +2 -2
  44. package/src/cli/new.ts +9 -5
  45. package/src/cli/upgrade-names.ts +14 -2
  46. package/src/cli/upgrade.ts +3 -0
  47. package/src/compiler/analyze.ts +22 -16
  48. package/src/compiler/cacheability-private.ts +13 -3
  49. package/src/compiler/cacheability.ts +24 -2
  50. package/src/compiler/compliance-contrast.ts +322 -0
  51. package/src/compiler/compliance-empty.ts +24 -0
  52. package/src/compiler/compliance-rgaa-content.ts +95 -0
  53. package/src/compiler/compliance-rgaa-criteria.ts +45 -0
  54. package/src/compiler/compliance-rgaa-pages.ts +140 -0
  55. package/src/compiler/compliance-rgaa.ts +19 -0
  56. package/src/compiler/compliance-rules.ts +72 -0
  57. package/src/compiler/compliance-third-party.ts +59 -0
  58. package/src/compiler/compliance-urls.ts +52 -0
  59. package/src/compiler/compliance.ts +61 -93
  60. package/src/compiler/cookie-inventory.ts +119 -0
  61. package/src/compiler/dom-attrs.ts +178 -22
  62. package/src/compiler/dom.ts +31 -44
  63. package/src/compiler/emit.ts +17 -6
  64. package/src/compiler/expr-context.ts +260 -207
  65. package/src/compiler/foreign-imports.ts +5 -3
  66. package/src/compiler/mistakes.ts +18 -9
  67. package/src/compiler/props-body.ts +263 -21
  68. package/src/compiler/props-pattern.ts +211 -0
  69. package/src/compiler/props.ts +324 -343
  70. package/src/compiler/signal-reads.ts +142 -29
  71. package/src/compiler/spread-handlers.ts +25 -13
  72. package/src/compiler/ssr-emit.ts +510 -0
  73. package/src/compiler/ssr-helpers.ts +165 -121
  74. package/src/compiler/ssr.ts +28 -441
  75. package/src/context.ts +14 -1
  76. package/src/dev/child.ts +1 -1
  77. package/src/dev/host-check.ts +2 -1
  78. package/src/dev/hot-islands.ts +71 -0
  79. package/src/dev/index.ts +31 -18
  80. package/src/dev/protocol.ts +1 -1
  81. package/src/dev/queue.ts +3 -2
  82. package/src/dev/reload.ts +5 -2
  83. package/src/dev/supervisor.ts +3 -1
  84. package/src/dev/watchers.ts +6 -2
  85. package/src/dom/action.ts +97 -14
  86. package/src/dom/attrs.ts +93 -25
  87. package/src/dom/extras.ts +91 -50
  88. package/src/dom/field-marks.ts +32 -0
  89. package/src/dom/hot.ts +9 -0
  90. package/src/dom/index.ts +44 -18
  91. package/src/dom/island-hot.ts +29 -0
  92. package/src/dom/island.ts +13 -2
  93. package/src/dom/loop.ts +259 -188
  94. package/src/dom/prefetch.ts +135 -0
  95. package/src/dom/regions.ts +515 -0
  96. package/src/dom/swap.ts +246 -0
  97. package/src/dom/trusted.ts +22 -0
  98. package/src/dom/upload.ts +44 -0
  99. package/src/eco/declaration.ts +44 -41
  100. package/src/eco/index.ts +8 -5
  101. package/src/href.ts +31 -0
  102. package/src/index.ts +12 -5
  103. package/src/plugins/config.ts +1 -1
  104. package/src/plugins/context.ts +7 -1
  105. package/src/plugins/daily.ts +27 -0
  106. package/src/plugins/index.ts +3 -3
  107. package/src/plugins/order.ts +1 -1
  108. package/src/plugins/public.ts +12 -5
  109. package/src/plugins/services.ts +88 -14
  110. package/src/plugins/types.ts +128 -10
  111. package/src/reactivity/graph.ts +244 -41
  112. package/src/reactivity/hmr.ts +101 -0
  113. package/src/reactivity/index.ts +243 -239
  114. package/src/reactivity/resource.ts +129 -0
  115. package/src/reactivity/seed.ts +141 -0
  116. package/src/reactivity/selector.ts +85 -47
  117. package/src/reactivity/server-seed.ts +202 -0
  118. package/src/reactivity/store.ts +331 -97
  119. package/src/rgpd/draft.ts +171 -0
  120. package/src/rgpd/forms.ts +85 -0
  121. package/src/rgpd/index.ts +57 -0
  122. package/src/server/action-flash.ts +1 -0
  123. package/src/server/action-protect.ts +3 -0
  124. package/src/server/action-registry.ts +11 -9
  125. package/src/server/action.ts +51 -19
  126. package/src/server/app-secret.ts +14 -8
  127. package/src/server/cache-invalidation.ts +97 -0
  128. package/src/server/compress.ts +55 -18
  129. package/src/server/consent.ts +21 -5
  130. package/src/server/cookie-inventory.ts +78 -0
  131. package/src/server/cookies.ts +77 -8
  132. package/src/server/cors.ts +98 -0
  133. package/src/server/csp-report.ts +90 -0
  134. package/src/server/discard.ts +13 -0
  135. package/src/server/document.ts +2 -2
  136. package/src/server/env.ts +1 -1
  137. package/src/server/errors.ts +9 -2
  138. package/src/server/field-errors.ts +91 -0
  139. package/src/server/form-schema.ts +16 -11
  140. package/src/server/health.ts +41 -11
  141. package/src/server/http.ts +28 -11
  142. package/src/server/index.ts +122 -307
  143. package/src/server/loader.ts +2 -0
  144. package/src/server/page.ts +3 -9
  145. package/src/server/plugin-host.ts +66 -16
  146. package/src/server/plugin-route-shadow.ts +24 -0
  147. package/src/server/public.ts +14 -3
  148. package/src/server/rate-limit.ts +49 -10
  149. package/src/server/region.ts +22 -2
  150. package/src/server/request-handler.ts +406 -0
  151. package/src/server/request-log.ts +94 -0
  152. package/src/server/route-cache.ts +55 -8
  153. package/src/server/route-input.ts +54 -0
  154. package/src/server/route-table.ts +53 -27
  155. package/src/server/router.ts +2 -1
  156. package/src/server/routing.ts +104 -45
  157. package/src/server/sanitize-html.ts +4 -2
  158. package/src/server/security.ts +38 -8
  159. package/src/server/serve-handlers.ts +16 -6
  160. package/src/server/served-file.ts +19 -14
  161. package/src/server/shared-store.ts +323 -0
  162. package/src/server/start.ts +12 -5
  163. package/src/server/static-dir.ts +34 -12
  164. package/src/server/stream.ts +2 -1
  165. package/src/server/surface.ts +39 -0
  166. package/src/server/webhook.ts +50 -0
  167. package/src/server/workers.ts +168 -0
  168. package/src/ssr/consent-banner.ts +20 -16
  169. package/src/ssr/consent-texts.ts +40 -0
  170. package/src/ssr/context.ts +174 -53
  171. package/src/ssr/cookie-table.ts +75 -0
  172. package/src/ssr/index.ts +63 -58
  173. package/src/ssr/navigation.ts +161 -14
  174. package/src/ssr/region.ts +9 -3
  175. package/src/style.ts +12 -5
  176. package/src/test/browser.ts +53 -23
  177. package/src/test/build-reuse.ts +85 -0
  178. package/src/test/index.ts +51 -8
  179. package/src/test/mount.ts +53 -0
  180. package/src/test/outside.ts +94 -0
  181. package/src/ts-plugin/diagnostics.ts +56 -18
  182. package/templates/_shared/AGENTS.md +1 -1
  183. package/templates/_shared/Dockerfile +22 -0
  184. package/templates/_shared/dockerignore +9 -0
  185. package/templates/_shared/gitignore +2 -0
  186. package/templates/app/.env.example +3 -1
  187. package/templates/app/compose.yaml +32 -0
  188. package/templates/app/db/migrations/001_notes.sql +7 -0
  189. package/templates/app/db/schema.ts +11 -0
  190. package/templates/app/package.json +1 -0
  191. package/templates/app/prunelle.config.ts +6 -0
  192. package/templates/app/src/actions/notes.ts +26 -0
  193. package/templates/app/src/auth.ts +4 -2
  194. package/templates/app/src/db.ts +5 -0
  195. package/templates/app/src/routes/dashboard/index.tsx +26 -1
  196. package/templates/app/src/routes/privacy.tsx +6 -2
  197. package/templates/app/tests/app.test.ts +14 -3
  198. package/templates/plugin/AGENTS.md +11 -0
  199. package/templates/plugin/CLAUDE.md +1 -0
  200. package/templates/plugin/README.md +27 -0
  201. package/templates/plugin/gitignore +2 -0
  202. package/templates/plugin/llms.txt +19 -0
  203. package/templates/plugin/package.json +33 -0
  204. package/templates/plugin/src/index.ts +40 -0
  205. package/templates/plugin/tests/fixture/prunelle.config.ts +4 -0
  206. package/templates/plugin/tests/fixture/src/routes/index.tsx +11 -0
  207. package/templates/plugin/tests/plugin.test.ts +42 -0
  208. package/templates/plugin/tsconfig.json +19 -0
  209. package/ts-plugin.cjs +4058 -2246
@@ -4,7 +4,9 @@ import type { JSXElement, Node, Program } from 'oxc-parser'
4
4
  import type { ModuleAnalysis } from './analyze'
5
5
  import type { EcoJsxRule } from './compliance-eco'
6
6
  import type { RgaaJsxRule, RgaaScope } from './compliance-rgaa'
7
+
7
8
  import type { CompilerWarning } from './mistakes'
9
+ import type { ComplianceConfig, ComplianceRule } from './compliance-rules'
8
10
  import { existsSync, readFileSync } from 'node:fs'
9
11
  import { basename, join } from 'node:path'
10
12
  import { parseSync, visitorKeys } from 'oxc-parser'
@@ -21,63 +23,20 @@ import {
21
23
  hasNonEmptyAttr,
22
24
  INTERACTIVE_ANCESTORS,
23
25
  mergeRgaaScope,
24
- RGAA_JSX_RULES,
26
+
25
27
  staticStringValueOf,
26
28
  } from './compliance-rgaa'
27
29
  import { STATEMENT_PLACEHOLDER } from '../a11y/declaration'
28
- import { checkEcoElement, ECO_JSX_RULES, largePublicFileWarnings } from './compliance-eco'
29
- import { CSS_IMPORT_RE, CSS_URL_RE, parseOrigin, thirdPartyLoads, thirdPartyOrigin } from './compliance-urls'
30
+ import { checkEcoElement, largePublicFileWarnings } from './compliance-eco'
31
+ import { COMPLIANCE_RULES } from './compliance-rules'
32
+ import { contrastFindings } from './compliance-contrast'
33
+ import { rendersNoText } from './compliance-empty'
34
+ import { rgaaPageFindings } from './compliance-rgaa-pages'
35
+ import { checkThirdPartyComponent, checkThirdPartyElement } from './compliance-third-party'
36
+ import { CSS_IMPORT_RE, CSS_URL_RE, parseOrigin, thirdPartyOrigin } from './compliance-urls'
30
37
  import { formatDiagnostic, formatLoc, getLineStarts, isComponentTag, jsxTagName, lineIndexAtOffset, unwrapTsExpr } from './shared'
31
38
 
32
- export type ComplianceRule =
33
- | RgaaJsxRule
34
- | EcoJsxRule
35
- | 'rgesn/large-public-file'
36
- | 'rgesn/declaration'
37
- | 'rgesn/island-by-value'
38
- | 'rgpd/third-party-url'
39
- | 'rgpd/consent-retention'
40
- | 'rgpd/privacy-notice'
41
- | 'lcen/legal-notice'
42
- | 'rgaa/document-lang'
43
- | 'rgaa/accessibility-statement'
44
- | 'security/csrf-off'
45
- | 'security/proxy-no-site'
46
- | FormWarningRule
47
-
48
- /** The warnings of the form-vs-action check (`cli/check-forms.ts`), silenced like the compliance rules. */
49
- export type FormWarningRule = 'action/unguarded-public-form' | 'form/invalid-option' | 'form/schema-unsupported' | 'form/unchecked'
50
-
51
- export interface ComplianceConfig {
52
- /** Compliance rules to silence across the app. */
53
- ignore?: readonly ComplianceRule[] | undefined
54
- /** Set `true` for French public-sector sites (RGAA requires an accessibility statement page). */
55
- publicBody?: boolean | undefined
56
- /** Custom route path for the legal notice page, or `false` to silence `lcen/legal-notice`. */
57
- legalNotice?: string | false | undefined
58
- /** Custom route path for the privacy notice page, or `false` to silence `rgpd/privacy-notice`. */
59
- privacyNotice?: string | false | undefined
60
- }
61
-
62
- const COMPLIANCE_RULES = new Set<ComplianceRule>([
63
- ...RGAA_JSX_RULES,
64
- ...ECO_JSX_RULES,
65
- 'rgesn/large-public-file',
66
- 'rgesn/declaration',
67
- 'rgesn/island-by-value',
68
- 'rgpd/third-party-url',
69
- 'rgpd/consent-retention',
70
- 'rgpd/privacy-notice',
71
- 'lcen/legal-notice',
72
- 'rgaa/document-lang',
73
- 'rgaa/accessibility-statement',
74
- 'security/csrf-off',
75
- 'security/proxy-no-site',
76
- 'action/unguarded-public-form',
77
- 'form/invalid-option',
78
- 'form/schema-unsupported',
79
- 'form/unchecked',
80
- ])
39
+ export type { ComplianceConfig, ComplianceRule, FormWarningRule } from './compliance-rules'
81
40
 
82
41
  // The CNIL recommends keeping a cookie choice, consent or refusal, 6 months before asking again.
83
42
  const CNIL_CHOICE_MAX_AGE = 15_552_000
@@ -91,14 +50,15 @@ const PERSONAL_DATA_TYPES = new Set(['email', 'tel'])
91
50
  const PERSONAL_DATA_NAMES = new Set(['email', 'phone', 'tel'])
92
51
  const ACCESSIBILITY_PATHS = new Set(['/accessibilite', '/accessibility', '/declaration-accessibilite', '/accessibility-statement'])
93
52
  const ECO_DECLARATION_PATHS = new Set(['/ecoconception', '/declaration-ecoconception', '/eco-design'])
94
- // The marker the `prunelle new` legal and privacy notices put in front of every detail the publisher must supply.
95
- const TEMPLATE_PLACEHOLDER = '[to fill in'
53
+ // The markers in front of every detail the publisher must supply: `[to fill in` in the `prunelle new` notices, `[à compléter` in the pages `prunelle a11y`, `prunelle eco` and `prunelle rgpd` draft.
54
+ const TEMPLATE_PLACEHOLDER = /\[to fill in/g
55
+ const DRAFT_PLACEHOLDER = new RegExp(STATEMENT_PLACEHOLDER.replace('[', '\\['), 'g')
96
56
 
97
- interface NoticeDetails { rule: ComplianceRule, page: string, law: string, marker: string }
57
+ interface NoticeDetails { rule: ComplianceRule, page: string, law: string, marker: RegExp }
98
58
  const LEGAL_NOTICE_DETAILS: NoticeDetails = { rule: 'lcen/legal-notice', page: 'legal notice', law: 'French law (LCEN art. 1-1) requires the publisher\'s identity, address and phone, the publication director and the host\'s name, address and phone', marker: TEMPLATE_PLACEHOLDER }
99
- const PRIVACY_NOTICE_DETAILS: NoticeDetails = { rule: 'rgpd/privacy-notice', page: 'privacy notice', law: 'the RGPD (art. 13) requires the controller\'s identity and contact, the purposes and legal basis, the retention periods, the recipients and the rights of the people concerned', marker: TEMPLATE_PLACEHOLDER }
100
- const ECO_DECLARATION_DETAILS: NoticeDetails = { rule: 'rgesn/declaration', page: 'eco-design declaration', law: 'the RGESN 2024 asks it to name the service, the evaluating entity and a contact, the minimum hardware profile and the planned actions, and to justify each criterion', marker: STATEMENT_PLACEHOLDER }
101
- const STATEMENT_DETAILS: NoticeDetails = { rule: 'rgaa/accessibility-statement', page: 'accessibility statement', law: 'the RGAA requires it to name the publisher, the site it covers and the pages audited, and to give a contact for accessibility feedback', marker: STATEMENT_PLACEHOLDER }
59
+ const PRIVACY_NOTICE_DETAILS: NoticeDetails = { rule: 'rgpd/privacy-notice', page: 'privacy notice', law: 'the RGPD (art. 13) requires the controller\'s identity and contact, the purposes and legal basis, the retention periods, the recipients and the rights of the people concerned', marker: new RegExp(`${TEMPLATE_PLACEHOLDER.source}|${DRAFT_PLACEHOLDER.source}`, 'g') }
60
+ const ECO_DECLARATION_DETAILS: NoticeDetails = { rule: 'rgesn/declaration', page: 'eco-design declaration', law: 'the RGESN 2024 asks it to name the service, the evaluating entity and a contact, the minimum hardware profile and the planned actions, and to justify each criterion', marker: DRAFT_PLACEHOLDER }
61
+ const STATEMENT_DETAILS: NoticeDetails = { rule: 'rgaa/accessibility-statement', page: 'accessibility statement', law: 'the RGAA requires it to name the publisher, the site it covers and the pages audited, and to give a contact for accessibility feedback', marker: DRAFT_PLACEHOLDER }
102
62
  const LOCALE_PREFIX_RE = /^\/(?:[a-z]{2}(?:-[a-z]{2})?|:[a-z_]\w*(?:=[^/]+)?\??|\[\[?[^\]]+\]\]?)(\/.+)$/i
103
63
 
104
64
  const LINE_IGNORE_RE = /(?:^|[\s{;(,])\/\/\s*prunelle-ignore(-file)?[ \t]+([^\r\n]+)/g
@@ -248,25 +208,6 @@ function collectDirectLabelTargets(root: Node | null | undefined): Set<string> {
248
208
  return targets
249
209
  }
250
210
 
251
- function checkThirdPartyElement(
252
- element: JSXElement,
253
- tag: string,
254
- filename: string,
255
- ignores: IgnoreMap,
256
- warnings: CompilerWarning[],
257
- ): void {
258
- for (const load of thirdPartyLoads(element, tag)) {
259
- if (isIgnoredAt(ignores, 'rgpd/third-party-url', load.start))
260
- continue
261
- warnings.push({
262
- rule: 'rgpd/third-party-url',
263
- urlOrigin: load.origin,
264
- start: load.start,
265
- message: `[rgpd/third-party-url] <${tag} ${load.attr}="${load.url}"> in ${filename} loads a third-party resource without consent: self-host it (e.g. @prunellejs/seo fonts or public/) or wrap it in <ConsentGate category="...">.`,
266
- })
267
- }
268
- }
269
-
270
211
  // A gate on the essential category always renders its children, so it holds nothing back until consent.
271
212
  function opensConsentGate(element: JSXElement, resolvedTag: string | undefined): boolean {
272
213
  return resolvedTag === 'ConsentGate' && staticStringValueOf(findAttr(element.openingElement.attributes, 'category')?.value ?? null) !== 'essential'
@@ -377,14 +318,17 @@ export function checkCompliance(
377
318
  isIgnored,
378
319
  warnings,
379
320
  }
321
+ const thirdPartyIgnored = (offset: number): boolean => isIgnoredAt(ignores, 'rgpd/third-party-url', offset)
380
322
  if (isComponentTag(tag)) {
381
323
  checkRgaaComponent(node, tag, ctx)
324
+ if (ancestors.consentGateDepth === 0)
325
+ checkThirdPartyComponent(node, tag, filename, thirdPartyIgnored, warnings)
382
326
  }
383
327
  else {
384
328
  checkRgaaElement(node, tag, ctx)
385
329
  checkEcoElement(node, tag, ctx)
386
330
  if (ancestors.consentGateDepth === 0)
387
- checkThirdPartyElement(node, tag, filename, ignores, warnings)
331
+ checkThirdPartyElement(node, tag, filename, thirdPartyIgnored, warnings)
388
332
  }
389
333
  }
390
334
  visit(attrs, ancestors, scope, labelTargets)
@@ -531,6 +475,8 @@ export interface ProjectComplianceInput {
531
475
  lang?: string | undefined
532
476
  /** A plugin sets `<html lang>` per request, so a missing `lang` is not a mistake. */
533
477
  langFromPlugin?: boolean | undefined
478
+ /** A plugin reports a page with no title itself, so `rgaa/page-title` would say it twice. */
479
+ titleChecked?: boolean | undefined
534
480
  }
535
481
 
536
482
  /** True when a plugin sets `<html lang>` from the request's locale (`@prunellejs/i18n`). */
@@ -538,6 +484,18 @@ export function pluginSetsLang(plugins: readonly { name: string }[]): boolean {
538
484
  return plugins.some(p => p.name === '@prunellejs/i18n')
539
485
  }
540
486
 
487
+ function contrastWarnings(relFile: string, code: string): string[] {
488
+ const ignores = parsePrunelleIgnores(code)
489
+ return contrastFindings(code)
490
+ .filter(finding => !isIgnoredAt(ignores, 'rgaa/contrast', finding.offset))
491
+ .map(finding => formatDiagnostic(formatLoc(relFile, code, finding.offset), finding.message, 'warning'))
492
+ }
493
+
494
+ /** True when a plugin warns about a page with no title (`@prunellejs/seo`). */
495
+ export function pluginChecksTitle(plugins: readonly { name: string }[]): boolean {
496
+ return plugins.some(p => p.name === '@prunellejs/seo')
497
+ }
498
+
541
499
  /** Collects project-level CSS third-party URL warnings and the LCEN, RGPD and RGAA notice warnings for `prunelle check` and production `prunelle build`. */
542
500
  export function collectProjectComplianceWarnings(input: ProjectComplianceInput): string[] {
543
501
  const { root, srcDir, routesDir, routeFiles, analyses, compliance, consentMaxAge, site, lang, langFromPlugin } = input
@@ -557,6 +515,8 @@ export function collectProjectComplianceWarnings(input: ProjectComplianceInput):
557
515
  for (const cssFile of [...srcFiles.filter(file => file.endsWith('.css')), ...publicCss]) {
558
516
  const code = readFileSync(cssFile, 'utf8')
559
517
  warnings.push(...checkCssCompliance(relPosix(root, cssFile), code, compliance, site))
518
+ if (!isRuleIgnored('rgaa/contrast', compliance))
519
+ warnings.push(...contrastWarnings(relPosix(root, cssFile), code))
560
520
  }
561
521
 
562
522
  const pagePaths: string[] = []
@@ -569,7 +529,7 @@ export function collectProjectComplianceWarnings(input: ProjectComplianceInput):
569
529
  const routePath = fileToRoutePath(routesDir, file)
570
530
  pagePaths.push(routePath)
571
531
  if (isLegalNoticePath(routePath, compliance) && !isRuleIgnored('lcen/legal-notice', compliance))
572
- warnings.push(...placeholderWarnings(relPosix(root, file), readFileSync(file, 'utf8'), LEGAL_NOTICE_DETAILS))
532
+ warnings.push(...legalNoticeWarnings(relPosix(root, file), readFileSync(file, 'utf8'), analysis))
573
533
  if (matchesNoticePath(routePath, compliance?.privacyNotice, DEFAULT_PRIVACY_PATHS) && !isRuleIgnored('rgpd/privacy-notice', compliance))
574
534
  warnings.push(...placeholderWarnings(relPosix(root, file), readFileSync(file, 'utf8'), PRIVACY_NOTICE_DETAILS))
575
535
  // Any site that publishes a statement, public body or not, publishes what it says.
@@ -581,6 +541,10 @@ export function collectProjectComplianceWarnings(input: ProjectComplianceInput):
581
541
  warnings.push(...checkRouteCompliance(pagePaths, compliance))
582
542
  if (pagePaths.length > 0 && lang === undefined && langFromPlugin !== true && !isRuleIgnored('rgaa/document-lang', compliance))
583
543
  warnings.push(formatDiagnostic('prunelle.config.ts:1:1', '[rgaa/document-lang] No lang in prunelle.config.ts, so every page says <html lang="en"> and @prunellejs/ui speaks English: set lang: \'fr\' (or the language your pages are written in).', 'warning'))
544
+ for (const finding of rgaaPageFindings({ root, routesDir, routeFiles, analyses, titleChecked: input.titleChecked === true, source: file => readFileSync(file, 'utf8') })) {
545
+ if (!isRuleIgnored(finding.rule, compliance) && !parsePrunelleIgnores(readFileSync(join(root, finding.file), 'utf8')).fileRules.has(finding.rule))
546
+ warnings.push(formatDiagnostic(`${finding.file}:${finding.line}:1`, `[${finding.rule}] ${finding.message}`, 'warning'))
547
+ }
584
548
  warnings.push(...largePublicFileWarnings(root, isRuleIgnored('rgesn/large-public-file', compliance), publicDir))
585
549
  if (!isRuleIgnored('rgpd/privacy-notice', compliance) && !pagePaths.some(p => matchesNoticePath(p, compliance?.privacyNotice, DEFAULT_PRIVACY_PATHS))) {
586
550
  const tsxFiles = [...new Set([...srcFiles.filter(file => file.endsWith('.tsx')), ...routeFiles.filter(file => file.endsWith('.tsx'))])].sort()
@@ -589,7 +553,7 @@ export function collectProjectComplianceWarnings(input: ProjectComplianceInput):
589
553
  return warnings
590
554
  }
591
555
 
592
- function isPersonalDataInput(el: JSXElement): boolean {
556
+ export function isPersonalDataInput(el: JSXElement): boolean {
593
557
  if (jsxTagName(el.openingElement.name) !== 'input')
594
558
  return false
595
559
  const attrs = el.openingElement.attributes
@@ -637,21 +601,25 @@ function privacyNoticeWarnings(root: string, tsxFiles: readonly string[], analys
637
601
  return []
638
602
  }
639
603
 
604
+ // A legal notice route that renders no text is a page, not a notice; one with text still has its placeholders checked.
605
+ function legalNoticeWarnings(relFile: string, code: string, analysis: ModuleAnalysis): string[] {
606
+ const { rule, page, law } = LEGAL_NOTICE_DETAILS
607
+ if (parsePrunelleIgnores(code).fileRules.has(rule) || !rendersNoText(analysis.program))
608
+ return placeholderWarnings(relFile, code, LEGAL_NOTICE_DETAILS)
609
+ return [formatDiagnostic(`${relFile}:1:1`, `[${rule}] The ${page} page ${relFile} renders no text: ${law}; write it in the page.`, 'warning')]
610
+ }
611
+
640
612
  // One warning for the first unfilled detail outside comments and ignores: the publisher fills them all in one pass.
641
613
  function placeholderWarnings(relFile: string, code: string, notice: NoticeDetails): string[] {
642
- if (!code.includes(notice.marker))
643
- return []
644
- const ignores = parsePrunelleIgnores(code)
645
- if (ignores.fileRules.has(notice.rule))
646
- return []
647
- const comments = parseSync(relFile, code, { lang: relFile.endsWith('.tsx') ? 'tsx' : 'ts' }).comments
648
- const inComment = (offset: number): boolean => comments.some(c => offset >= c.start && offset < c.end)
649
- for (let from = 0; ;) {
650
- const offset = code.indexOf(notice.marker, from)
651
- if (offset === -1)
614
+ let ignores: ReturnType<typeof parsePrunelleIgnores> | undefined
615
+ let comments: { start: number, end: number }[] | undefined
616
+ for (const { index: offset, 0: marker } of code.matchAll(notice.marker)) {
617
+ ignores ??= parsePrunelleIgnores(code)
618
+ if (ignores.fileRules.has(notice.rule))
652
619
  return []
653
- if (!inComment(offset) && !isIgnoredAt(ignores, notice.rule, offset))
654
- return [formatDiagnostic(formatLoc(relFile, code, offset), `[${notice.rule}] The ${notice.page} still holds "${notice.marker} ...]" placeholders: ${notice.law}; replace every placeholder in ${relFile}.`, 'warning')]
655
- from = offset + notice.marker.length
620
+ comments ??= parseSync(relFile, code, { lang: relFile.endsWith('.tsx') ? 'tsx' : 'ts' }).comments
621
+ if (!comments.some(c => offset >= c.start && offset < c.end) && !isIgnoredAt(ignores, notice.rule, offset))
622
+ return [formatDiagnostic(formatLoc(relFile, code, offset), `[${notice.rule}] The ${notice.page} still holds "${marker} ...]" placeholders: ${notice.law}; replace every placeholder in ${relFile}.`, 'warning')]
656
623
  }
624
+ return []
657
625
  }
@@ -0,0 +1,119 @@
1
+ // The cookies an app sets with `cookies.set(...)`, read from its source for `<CookieTable>` and `prunelle check`.
2
+
3
+ import type { Argument, Expression, Node, ObjectExpression, Program } from 'oxc-parser'
4
+ import { parseSync } from 'oxc-parser'
5
+ import { walk } from './ast'
6
+ import { unwrapTsExpr } from './shared'
7
+ import { staticLiteralOrTemplate } from './ssr-helpers'
8
+
9
+ /** One cookie the app sets; a field left out could not be read from the source. `lifetime` is in seconds, or `'session'` for a cookie that ends with the browser session. */
10
+ export interface AppCookie {
11
+ name?: string | undefined
12
+ purpose?: string | undefined
13
+ category?: string | undefined
14
+ lifetime?: number | 'session' | undefined
15
+ }
16
+
17
+ export interface ScannedCookie extends AppCookie {
18
+ file: string
19
+ /** Offset of the first `cookies.set` call for this cookie. */
20
+ start: number
21
+ }
22
+
23
+ /** `ctx.cookies.set(...)` and `cookies.set(...)`, but not `map.set(...)`. */
24
+ export function isCookieSet(callee: Expression): boolean {
25
+ const member = unwrapTsExpr(callee)
26
+ if (member.type !== 'MemberExpression' || member.computed || member.property.type !== 'Identifier' || member.property.name !== 'set')
27
+ return false
28
+ const owner = unwrapTsExpr(member.object)
29
+ if (owner.type === 'Identifier')
30
+ return owner.name === 'cookies'
31
+ return owner.type === 'MemberExpression' && !owner.computed && owner.property.type === 'Identifier' && owner.property.name === 'cookies'
32
+ }
33
+
34
+ function staticString(node: Node | undefined): string | undefined {
35
+ if (node === undefined)
36
+ return undefined
37
+ const literal = staticLiteralOrTemplate(node)
38
+ return literal.ok && typeof literal.value === 'string' ? literal.value : undefined
39
+ }
40
+
41
+ // `31536000` and `60 * 60 * 24 * 365`.
42
+ function staticSeconds(node: Node): number | undefined {
43
+ const n = unwrapTsExpr(node)
44
+ if (n.type === 'Literal')
45
+ return typeof n.value === 'number' ? n.value : undefined
46
+ if (n.type !== 'BinaryExpression' || (n.operator !== '*' && n.operator !== '+'))
47
+ return undefined
48
+ const left = staticSeconds(n.left)
49
+ const right = staticSeconds(n.right)
50
+ if (left === undefined || right === undefined)
51
+ return undefined
52
+ return n.operator === '*' ? left * right : left + right
53
+ }
54
+
55
+ function propertiesOf(options: ObjectExpression): { props: Map<string, Node>, open: boolean } {
56
+ const props = new Map<string, Node>()
57
+ let open = false
58
+ for (const prop of options.properties) {
59
+ const key = prop.type === 'Property' && !prop.computed && prop.key.type === 'Identifier' ? prop.key.name : undefined
60
+ if (key === undefined || prop.type !== 'Property')
61
+ open = true
62
+ else
63
+ props.set(key, prop.value)
64
+ }
65
+ return { props, open }
66
+ }
67
+
68
+ // A spread or computed key may hold any option, so an option it could hold is unreadable rather than absent.
69
+ function readOptions(options: Argument | undefined): Omit<AppCookie, 'name'> {
70
+ if (options === undefined)
71
+ return { category: 'essential', lifetime: 'session' }
72
+ if (options.type !== 'ObjectExpression')
73
+ return {}
74
+ const { props, open } = propertiesOf(options)
75
+ const maxAge = props.get('maxAge')
76
+ return {
77
+ purpose: staticString(props.get('purpose')),
78
+ category: props.has('category') ? staticString(props.get('category')) : open ? undefined : 'essential',
79
+ lifetime: maxAge !== undefined ? staticSeconds(maxAge) : props.has('expires') || open ? undefined : 'session',
80
+ }
81
+ }
82
+
83
+ /** Each `cookies.set(...)` call of a module, in source order. */
84
+ export function scanCookieSets(file: string, code: string, program?: Program): ScannedCookie[] {
85
+ if (!code.includes('cookies'))
86
+ return []
87
+ const found: ScannedCookie[] = []
88
+ walk(program ?? parseSync(file, code, { lang: file.endsWith('x') ? 'tsx' : 'ts' }).program, (node): undefined => {
89
+ if (node.type === 'CallExpression' && isCookieSet(node.callee))
90
+ found.push({ file, start: node.start, name: staticString(node.arguments[0]), ...readOptions(node.arguments[2]) })
91
+ return undefined
92
+ })
93
+ return found
94
+ }
95
+
96
+ /** One entry per cookie name, each field from the first call that sets it readably; a cookie whose name cannot be read keeps an entry of its own. */
97
+ export function mergeCookies(scanned: readonly ScannedCookie[]): ScannedCookie[] {
98
+ const byName = new Map<string, ScannedCookie>()
99
+ const merged: ScannedCookie[] = []
100
+ for (const cookie of scanned) {
101
+ const seen = cookie.name === undefined ? undefined : byName.get(cookie.name)
102
+ if (seen !== undefined) {
103
+ seen.purpose ??= cookie.purpose
104
+ seen.category ??= cookie.category
105
+ seen.lifetime ??= cookie.lifetime
106
+ continue
107
+ }
108
+ const entry = { ...cookie }
109
+ merged.push(entry)
110
+ if (cookie.name !== undefined)
111
+ byName.set(cookie.name, entry)
112
+ }
113
+ return merged
114
+ }
115
+
116
+ /** The fields `<CookieTable>` cannot show, in the order of its columns. */
117
+ export function unreadableFields(cookie: AppCookie): ('name' | 'purpose' | 'category' | 'lifetime')[] {
118
+ return (['name', 'purpose', 'category', 'lifetime'] as const).filter(field => cookie[field] === undefined)
119
+ }
@@ -4,23 +4,143 @@ import type { JSXElement, Node, Program } from 'oxc-parser'
4
4
  import { walk } from './ast'
5
5
  import { DELEGATED_EVENTS } from './emit'
6
6
  import { isStaticPropExpr } from './props'
7
- import {
8
- cleanJsxText,
9
- collectPatternNames,
10
- DOM_PROPS,
11
- escapeRawText,
12
- escapeStaticAttr,
13
- EVENT_ATTR,
14
- filterMeaningfulChildren,
15
- isBlockedAttr,
16
- isStringBoolAttr,
17
- isUnsafeUrlAttr,
18
- jsxTagName,
19
- unwrapTsExpr,
20
- } from './shared'
7
+ import { cleanJsxText, collectPatternNames, DOM_PROPS, escapeRawText, escapeStaticAttr, EVENT_ATTR, filterMeaningfulChildren, isBlockedAttr, isStringBoolAttr, isUnsafeUrlAttr, jsxTagName, unwrapTsExpr } from './shared'
21
8
  import { formatStaticAttrValue, formatStaticStyleExpr, staticLiteralOrTemplate } from './ssr-helpers'
22
9
 
23
10
  const SIMPLE_CALLEE_RE = /^[A-Za-z_$][\w$.]*$/
11
+ const PURE_CALL_GLOBALS = new Set(['String', 'Number', 'Boolean', 'parseInt', 'parseFloat', 'encodeURI', 'encodeURIComponent', 'decodeURI', 'decodeURIComponent'])
12
+ const PURE_UNARY_OPS = new Set(['!', '+', '-', '~', 'typeof', 'void'])
13
+ const ROW_SIGNAL_RE = /^_(?:r|i)\d+\.value$/
14
+ const SIMPLE_PROP_RE = /^[A-Za-z_$][\w$]*\.[A-Za-z_$][\w$]*$/
15
+ const LEAF_DOM_OPS = ['setText', 'setClass', 'setAttr', 'setStyle'] as const
16
+ const DELEGATED_EVENT_OP_RE = /^_e\d+\.\$\$[a-z]+ = /
17
+
18
+ function collectMemberDepKeys(node: Extract<Node, { type: 'MemberExpression' }>, scopeRewrites: ReadonlyMap<string, string>, keys: Set<string>): boolean {
19
+ const segments: { computed: boolean, name?: string, expr?: Node }[] = []
20
+ let cur: Node = node
21
+ while (cur.type === 'MemberExpression' || cur.type === 'ChainExpression') {
22
+ if (cur.type === 'ChainExpression') {
23
+ cur = unwrapTsExpr(cur.expression)
24
+ continue
25
+ }
26
+ if (cur.computed)
27
+ segments.push({ computed: true, expr: cur.property })
28
+ else if (cur.property.type === 'Identifier')
29
+ segments.push({ computed: false, name: cur.property.name })
30
+ else
31
+ return false
32
+ cur = unwrapTsExpr(cur.object)
33
+ }
34
+ if (cur.type !== 'Identifier')
35
+ return false
36
+ segments.reverse()
37
+ if (segments.some(s => s.computed && !collectLeafDepKeys(s.expr!, scopeRewrites, keys)))
38
+ return false
39
+ const rw = scopeRewrites.get(cur.name)
40
+ if (rw !== undefined) {
41
+ if (ROW_SIGNAL_RE.test(rw)) {
42
+ keys.add(`row:${rw}`)
43
+ return true
44
+ }
45
+ if (!SIMPLE_PROP_RE.test(rw) || segments.some(s => s.computed))
46
+ return false
47
+ keys.add(`rw:${rw}.${segments.map(s => s.name).join('.')}`)
48
+ return true
49
+ }
50
+ if (!segments[0]!.computed && segments[0]!.name === 'value') {
51
+ keys.add(`sig:${cur.name}`)
52
+ return true
53
+ }
54
+ if (segments.some(s => s.computed))
55
+ return false
56
+ const path = segments.map(s => s.name!)
57
+ keys.add(path[path.length - 1] === 'value' ? `sig:${cur.name}.${path.slice(0, -1).join('.')}` : `mem:${cur.name}.${path.join('.')}`)
58
+ return true
59
+ }
60
+
61
+ function collectLeafDepKeys(rawNode: Node, scopeRewrites: ReadonlyMap<string, string>, keys: Set<string>): boolean {
62
+ const node = unwrapTsExpr(rawNode)
63
+ switch (node.type) {
64
+ case 'Literal': return true
65
+ case 'ChainExpression': return collectLeafDepKeys(node.expression, scopeRewrites, keys)
66
+ case 'TemplateLiteral': return node.expressions.every(e => collectLeafDepKeys(e, scopeRewrites, keys))
67
+ case 'UnaryExpression': return PURE_UNARY_OPS.has(node.operator) && collectLeafDepKeys(node.argument, scopeRewrites, keys)
68
+ case 'BinaryExpression':
69
+ case 'LogicalExpression': return collectLeafDepKeys(node.left, scopeRewrites, keys) && collectLeafDepKeys(node.right, scopeRewrites, keys)
70
+ case 'ConditionalExpression': return collectLeafDepKeys(node.test, scopeRewrites, keys) && collectLeafDepKeys(node.consequent, scopeRewrites, keys) && collectLeafDepKeys(node.alternate, scopeRewrites, keys)
71
+ case 'ObjectExpression': return node.properties.every(p => p.type === 'Property' && p.kind === 'init' && (!p.computed || collectLeafDepKeys(p.key, scopeRewrites, keys)) && collectLeafDepKeys(p.value, scopeRewrites, keys))
72
+ case 'ArrayExpression': return node.elements.every(el => el === null || (el.type !== 'SpreadElement' && collectLeafDepKeys(el, scopeRewrites, keys)))
73
+ case 'CallExpression': {
74
+ const c = node.callee
75
+ const isPure = (c.type === 'Identifier' && PURE_CALL_GLOBALS.has(c.name))
76
+ || (c.type === 'MemberExpression' && !c.computed && c.object.type === 'Identifier' && c.object.name === 'Math' && c.property.type === 'Identifier')
77
+ return isPure && node.arguments.every(a => a.type !== 'SpreadElement' && collectLeafDepKeys(a, scopeRewrites, keys))
78
+ }
79
+ case 'Identifier': {
80
+ const rw = scopeRewrites.get(node.name)
81
+ if (rw === undefined)
82
+ return true
83
+ if (ROW_SIGNAL_RE.test(rw)) { keys.add(`row:${rw}`); return true }
84
+ if (SIMPLE_PROP_RE.test(rw)) { keys.add(`rw:${rw}`); return true }
85
+ return false
86
+ }
87
+ case 'MemberExpression': return collectMemberDepKeys(node, scopeRewrites, keys)
88
+ default: return false
89
+ }
90
+ }
91
+
92
+ /** Returns a canonical key when `rawNode` is a pure leaf expression subscribing to exactly one reactive root/path, or `undefined` when coalescing could break fine-grained updates or hide calls. */
93
+ export function extractLeafDepKey(rawNode: Node, scopeRewrites: ReadonlyMap<string, string>, isStyle = false): string | undefined {
94
+ if (isStyle) {
95
+ const root = unwrapTsExpr(rawNode)
96
+ if (root.type === 'Identifier' || root.type === 'MemberExpression' || root.type === 'ChainExpression')
97
+ return undefined
98
+ }
99
+ const keys = new Set<string>()
100
+ return collectLeafDepKeys(rawNode, scopeRewrites, keys) && keys.size === 1 ? keys.values().next().value : undefined
101
+ }
102
+
103
+ /** Merges barrier-free leaf DOM effects sharing the exact same single reactive dependency key into one `__effect` placed at the last op of the group. */
104
+ export function coalesceLeafEffects(ops: string[], depKeys: ReadonlyMap<number, string>, alias: (name: string) => string): void {
105
+ if (depKeys.size < 2)
106
+ return
107
+ const effPrefix = `${alias('effect')}(() => `
108
+ const effSuffix = ');'
109
+ const leafPrefixes = LEAF_DOM_OPS.map(name => `${alias(name)}(`)
110
+ const isNonBarrier = (op: string): boolean => {
111
+ if (op.startsWith('const _txt') || DELEGATED_EVENT_OP_RE.test(op))
112
+ return true
113
+ const body = op.startsWith(effPrefix) && op.endsWith(effSuffix) ? op.slice(effPrefix.length, -effSuffix.length) : op
114
+ return leafPrefixes.some(p => body.startsWith(p))
115
+ }
116
+ const groups = new Map<string, number[]>()
117
+ let merged = false
118
+ const flush = (): void => {
119
+ for (const indices of groups.values()) {
120
+ if (indices.length < 2)
121
+ continue
122
+ const stmts = indices.map(idx => ops[idx]!.slice(effPrefix.length, -effSuffix.length))
123
+ for (let j = 0; j < indices.length - 1; j++)
124
+ ops[indices[j]!] = ''
125
+ ops[indices[indices.length - 1]!] = `${effPrefix}{ ${stmts.join('; ')}; }${effSuffix}`
126
+ merged = true
127
+ }
128
+ groups.clear()
129
+ }
130
+ for (let i = 0; i < ops.length; i++) {
131
+ const op = ops[i]!
132
+ if (!isNonBarrier(op)) {
133
+ flush()
134
+ continue
135
+ }
136
+ const key = depKeys.get(i)
137
+ if (key !== undefined && op.startsWith(effPrefix) && op.endsWith(effSuffix))
138
+ groups.set(key, [...(groups.get(key) ?? []), i])
139
+ }
140
+ flush()
141
+ if (merged)
142
+ ops.splice(0, ops.length, ...ops.filter(op => op !== ''))
143
+ }
24
144
 
25
145
  function isPlainInitObject(node: Node): boolean {
26
146
  const cur = unwrapTsExpr(node)
@@ -88,6 +208,29 @@ function wrapDomOp(stmt: string, isStatic: boolean, use: (name: string) => strin
88
208
  return isStatic ? `${stmt};` : `${use('effect')}(() => ${stmt});`
89
209
  }
90
210
 
211
+ function pushLeafDomOp(
212
+ ops: string[],
213
+ depKeys: Map<number, string> | undefined,
214
+ stmt: string,
215
+ expr: Node,
216
+ scopeRewrites: ReadonlyMap<string, string>,
217
+ use: (name: string) => string,
218
+ isStyle = false,
219
+ staticStyleNames?: ReadonlySet<string>,
220
+ ): void {
221
+ if (isStaticDomExpr(expr, scopeRewrites, isStyle, staticStyleNames)) {
222
+ ops.push(`${stmt};`)
223
+ return
224
+ }
225
+ const idx = ops.length
226
+ ops.push(`${use('effect')}(() => ${stmt});`)
227
+ if (depKeys !== undefined) {
228
+ const key = extractLeafDepKey(expr, scopeRewrites, isStyle)
229
+ if (key !== undefined)
230
+ depKeys.set(idx, key)
231
+ }
232
+ }
233
+
91
234
  export function formatSetTextOp(
92
235
  targetVar: string,
93
236
  exprCode: string,
@@ -98,6 +241,18 @@ export function formatSetTextOp(
98
241
  return wrapDomOp(`${use('setText')}(${targetVar}, ${exprCode})`, isStaticDomExpr(expr, scopeRewrites), use)
99
242
  }
100
243
 
244
+ export function pushTextSlotOp(
245
+ ops: string[],
246
+ depKeys: Map<number, string>,
247
+ targetVar: string,
248
+ exprCode: string,
249
+ expr: Node,
250
+ scopeRewrites: ReadonlyMap<string, string>,
251
+ use: (name: string) => string,
252
+ ): void {
253
+ pushLeafDomOp(ops, depKeys, `${use('setText')}(${targetVar}, ${exprCode})`, expr, scopeRewrites, use)
254
+ }
255
+
101
256
  /** Rewrites a JSX component tag's root identifier through `scopeRewrites` (`<Icon />` -> `__p.Icon`, `<ui.Icon />` -> `__p.ui.Icon`). */
102
257
  export function resolveComponentCallee(tag: string, scopeRewrites: ReadonlyMap<string, string>): string {
103
258
  const dot = tag.indexOf('.')
@@ -116,6 +271,7 @@ export interface ElementAttrCompileContext {
116
271
  scopeRewrites: ReadonlyMap<string, string>
117
272
  staticStyleNames?: ReadonlySet<string> | undefined
118
273
  ops: string[]
274
+ depKeys?: Map<number, string> | undefined
119
275
  postChildOps: string[]
120
276
  delegatedEvents: Set<string>
121
277
  use: (name: string) => string
@@ -129,14 +285,14 @@ function emitDomExprAttr(
129
285
  expr: Node,
130
286
  isSelect: boolean,
131
287
  ): string {
132
- const { tag, elVar, scopeRewrites, staticStyleNames, ops, postChildOps, use, compileExpression } = ctx
288
+ const { tag, elVar, scopeRewrites, staticStyleNames, ops, depKeys, postChildOps, use, compileExpression } = ctx
133
289
 
134
290
  if (name === 'style') {
135
291
  const staticStyle = formatStaticStyleExpr(expr)
136
292
  if (staticStyle !== undefined)
137
293
  return staticStyle
138
294
  const exprCode = compileExpression(expr, scopeRewrites)
139
- ops.push(wrapDomOp(`${use('setStyle')}(${elVar}, ${exprCode})`, isStaticDomExpr(expr, scopeRewrites, true, staticStyleNames), use))
295
+ pushLeafDomOp(ops, depKeys, `${use('setStyle')}(${elVar}, ${exprCode})`, expr, scopeRewrites, use, true, staticStyleNames)
140
296
  return ''
141
297
  }
142
298
 
@@ -150,19 +306,19 @@ function emitDomExprAttr(
150
306
  }
151
307
 
152
308
  const exprCode = compileExpression(expr, scopeRewrites)
153
- const isStatic = isStaticDomExpr(expr, scopeRewrites)
154
309
  if (name === 'class') {
155
- ops.push(wrapDomOp(`${use('setClass')}(${elVar}, ${exprCode})`, isStatic, use))
310
+ pushLeafDomOp(ops, depKeys, `${use('setClass')}(${elVar}, ${exprCode})`, expr, scopeRewrites, use)
156
311
  }
157
312
  else if (DOM_PROPS.has(name)) {
158
- const targetOps = isSelect && name === 'value' ? postChildOps : ops
313
+ const isSelectVal = isSelect && name === 'value'
314
+ const targetOps = isSelectVal ? postChildOps : ops
159
315
  // Only a <select multiple> pulls in setSelectValues, so other pages ship none of it.
160
- const multiple = isSelect && name === 'value' && ctx.el.openingElement.attributes.some(a => a.type === 'JSXAttribute' && jsxTagName(a.name) === 'multiple')
316
+ const multiple = isSelectVal && ctx.el.openingElement.attributes.some(a => a.type === 'JSXAttribute' && jsxTagName(a.name) === 'multiple')
161
317
  const call = multiple ? `${use('setSelectValues')}(${elVar}, ${exprCode})` : `${use('setProp')}(${elVar}, ${JSON.stringify(name)}, ${exprCode})`
162
- targetOps.push(wrapDomOp(call, isStatic, use))
318
+ pushLeafDomOp(targetOps, undefined, call, expr, scopeRewrites, use)
163
319
  }
164
320
  else {
165
- ops.push(wrapDomOp(`${use('setAttr')}(${elVar}, ${JSON.stringify(name)}, ${exprCode})`, isStatic, use))
321
+ pushLeafDomOp(ops, depKeys, `${use('setAttr')}(${elVar}, ${JSON.stringify(name)}, ${exprCode})`, expr, scopeRewrites, use)
166
322
  }
167
323
  return ''
168
324
  }