prunelle 0.9.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.
- package/llms.txt +18 -18
- package/package.json +2 -2
- package/src/a11y/declaration.ts +4 -7
- package/src/build/bundle.ts +6 -2
- package/src/build/index.ts +3 -1
- package/src/build/island-promote.ts +42 -2
- package/src/build/islands.ts +59 -8
- package/src/build/manifest.ts +98 -0
- package/src/build/plugin-host.ts +11 -1
- package/src/build/prerender.ts +6 -1
- package/src/build/reach.ts +4 -3
- package/src/build/resolve.ts +5 -1
- package/src/build/routes.ts +18 -0
- package/src/cli/check-forms.ts +8 -0
- package/src/cli/check-links.ts +14 -5
- package/src/cli/check.ts +12 -6
- package/src/cli/commands.ts +5 -3
- package/src/cli/form-opaque-children.ts +40 -0
- package/src/compiler/analyze.ts +20 -14
- package/src/compiler/cacheability-private.ts +13 -3
- package/src/compiler/compliance-contrast.ts +48 -10
- package/src/compiler/compliance-rules.ts +72 -0
- package/src/compiler/compliance.ts +6 -66
- package/src/compiler/dom-attrs.ts +178 -22
- package/src/compiler/dom.ts +31 -44
- package/src/compiler/emit.ts +17 -6
- package/src/compiler/expr-context.ts +260 -207
- package/src/compiler/props-body.ts +263 -21
- package/src/compiler/props.ts +155 -5
- package/src/compiler/signal-reads.ts +142 -29
- package/src/compiler/spread-handlers.ts +25 -13
- package/src/compiler/ssr-emit.ts +3 -3
- package/src/compiler/ssr-helpers.ts +0 -5
- package/src/compiler/ssr.ts +4 -2
- package/src/dev/host-check.ts +2 -1
- package/src/dev/reload.ts +4 -1
- package/src/dom/attrs.ts +93 -25
- package/src/dom/extras.ts +89 -49
- package/src/dom/field-marks.ts +9 -1
- package/src/dom/index.ts +19 -13
- package/src/dom/loop.ts +259 -188
- package/src/dom/prefetch.ts +4 -1
- package/src/dom/regions.ts +25 -8
- package/src/dom/swap.ts +11 -10
- package/src/dom/trusted.ts +4 -4
- package/src/eco/declaration.ts +5 -1
- package/src/eco/index.ts +3 -0
- package/src/index.ts +3 -2
- package/src/plugins/config.ts +1 -1
- package/src/plugins/public.ts +4 -0
- package/src/plugins/types.ts +8 -1
- package/src/reactivity/graph.ts +244 -41
- package/src/reactivity/hmr.ts +14 -3
- package/src/reactivity/index.ts +219 -235
- package/src/reactivity/resource.ts +17 -3
- package/src/reactivity/seed.ts +118 -16
- package/src/reactivity/selector.ts +85 -47
- package/src/reactivity/server-seed.ts +31 -23
- package/src/reactivity/store.ts +316 -136
- package/src/server/action-protect.ts +3 -0
- package/src/server/action-registry.ts +5 -1
- package/src/server/cache-invalidation.ts +4 -3
- package/src/server/compress.ts +52 -17
- package/src/server/consent.ts +5 -3
- package/src/server/cookies.ts +27 -8
- package/src/server/cors.ts +98 -0
- package/src/server/csp-report.ts +8 -4
- package/src/server/health.ts +9 -0
- package/src/server/http.ts +3 -1
- package/src/server/index.ts +25 -13
- package/src/server/loader.ts +1 -0
- package/src/server/plugin-host.ts +41 -9
- package/src/server/plugin-route-shadow.ts +24 -0
- package/src/server/rate-limit.ts +13 -3
- package/src/server/region.ts +19 -2
- package/src/server/request-handler.ts +58 -22
- package/src/server/request-log.ts +1 -1
- package/src/server/route-cache.ts +14 -2
- package/src/server/route-table.ts +21 -11
- package/src/server/router.ts +2 -1
- package/src/server/routing.ts +100 -42
- package/src/server/sanitize-html.ts +3 -1
- package/src/server/serve-handlers.ts +10 -4
- package/src/server/served-file.ts +19 -14
- package/src/server/shared-store.ts +10 -1
- package/src/server/static-dir.ts +21 -3
- package/src/server/webhook.ts +6 -4
- package/src/ssr/context.ts +149 -51
- package/src/ssr/index.ts +41 -46
- package/src/ssr/region.ts +9 -3
- package/src/style.ts +12 -5
- package/src/test/browser.ts +3 -1
- package/src/test/build-reuse.ts +22 -7
- package/src/test/index.ts +7 -3
- package/src/ts-plugin/diagnostics.ts +56 -18
- package/ts-plugin.cjs +465 -131
|
@@ -68,22 +68,49 @@ function propKeyName(node: Node): string | undefined {
|
|
|
68
68
|
return undefined
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
/** Follows an identifier to the top-level `const` that holds it, so a config kept in a variable reads like an inline one. */
|
|
72
|
+
type ResolveConst = (node: Node) => Node
|
|
73
|
+
|
|
74
|
+
function topLevelConsts(program: Program): ResolveConst {
|
|
75
|
+
const consts = new Map<string, Node>()
|
|
76
|
+
for (const stmt of program.body) {
|
|
77
|
+
const decl = stmt.type === 'ExportNamedDeclaration' ? stmt.declaration : stmt
|
|
78
|
+
if (decl?.type !== 'VariableDeclaration' || decl.kind !== 'const')
|
|
79
|
+
continue
|
|
80
|
+
for (const d of decl.declarations) {
|
|
81
|
+
if (d.id.type === 'Identifier' && d.init !== null)
|
|
82
|
+
consts.set(d.id.name, d.init)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const resolve: ResolveConst = (node) => {
|
|
86
|
+
let inner = unwrapTsExpr(node)
|
|
87
|
+
for (let depth = 0; inner.type === 'Identifier' && depth < 8; depth++) {
|
|
88
|
+
const init = consts.get(inner.name)
|
|
89
|
+
if (init === undefined)
|
|
90
|
+
break
|
|
91
|
+
inner = unwrapTsExpr(init)
|
|
92
|
+
}
|
|
93
|
+
return inner
|
|
94
|
+
}
|
|
95
|
+
return resolve
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function staticString(node: Node, resolve: ResolveConst): string | undefined {
|
|
99
|
+
const inner = resolve(node)
|
|
73
100
|
if (inner.type === 'Literal' && typeof inner.value === 'string')
|
|
74
101
|
return inner.value
|
|
75
102
|
return undefined
|
|
76
103
|
}
|
|
77
104
|
|
|
78
|
-
function extractConfigObject(program: Program): Extract<Node, { type: 'ObjectExpression' }> | undefined {
|
|
105
|
+
function extractConfigObject(program: Program, resolve: ResolveConst): Extract<Node, { type: 'ObjectExpression' }> | undefined {
|
|
79
106
|
for (const stmt of program.body) {
|
|
80
107
|
if (stmt.type !== 'ExportDefaultDeclaration')
|
|
81
108
|
continue
|
|
82
|
-
const decl =
|
|
109
|
+
const decl = resolve(stmt.declaration)
|
|
83
110
|
if (decl.type === 'ObjectExpression')
|
|
84
111
|
return decl
|
|
85
112
|
if (decl.type === 'CallExpression' && decl.arguments[0] !== undefined) {
|
|
86
|
-
const arg =
|
|
113
|
+
const arg = resolve(decl.arguments[0])
|
|
87
114
|
if (arg.type === 'ObjectExpression')
|
|
88
115
|
return arg
|
|
89
116
|
}
|
|
@@ -91,8 +118,24 @@ function extractConfigObject(program: Program): Extract<Node, { type: 'ObjectExp
|
|
|
91
118
|
return undefined
|
|
92
119
|
}
|
|
93
120
|
|
|
94
|
-
function
|
|
95
|
-
const
|
|
121
|
+
function collectIgnoredRules(array: Extract<Node, { type: 'ArrayExpression' }>, resolve: ResolveConst, rules: ComplianceRule[]): void {
|
|
122
|
+
for (const el of array.elements) {
|
|
123
|
+
if (el === null)
|
|
124
|
+
continue
|
|
125
|
+
if (el.type === 'SpreadElement') {
|
|
126
|
+
const spread = resolve(el.argument)
|
|
127
|
+
if (spread.type === 'ArrayExpression')
|
|
128
|
+
collectIgnoredRules(spread, resolve, rules)
|
|
129
|
+
continue
|
|
130
|
+
}
|
|
131
|
+
const s = staticString(el, resolve)
|
|
132
|
+
if (s !== undefined)
|
|
133
|
+
rules.push(s as ComplianceRule)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function parseStaticCompliance(node: Node, resolve: ResolveConst): ComplianceConfig | undefined {
|
|
138
|
+
const obj = resolve(node)
|
|
96
139
|
if (obj.type !== 'ObjectExpression')
|
|
97
140
|
return undefined
|
|
98
141
|
const out: ComplianceConfig = {}
|
|
@@ -100,7 +143,7 @@ function parseStaticCompliance(node: Node): ComplianceConfig | undefined {
|
|
|
100
143
|
if (prop.type !== 'Property')
|
|
101
144
|
continue
|
|
102
145
|
const key = propKeyName(prop.key)
|
|
103
|
-
const val =
|
|
146
|
+
const val = resolve(prop.value)
|
|
104
147
|
if (key === 'publicBody' && val.type === 'Literal' && typeof val.value === 'boolean') {
|
|
105
148
|
out.publicBody = val.value
|
|
106
149
|
}
|
|
@@ -109,13 +152,7 @@ function parseStaticCompliance(node: Node): ComplianceConfig | undefined {
|
|
|
109
152
|
}
|
|
110
153
|
else if (key === 'ignore' && val.type === 'ArrayExpression') {
|
|
111
154
|
const rules: ComplianceRule[] = []
|
|
112
|
-
|
|
113
|
-
if (el !== null && el.type !== 'SpreadElement') {
|
|
114
|
-
const s = staticString(el)
|
|
115
|
-
if (s !== undefined)
|
|
116
|
-
rules.push(s as ComplianceRule)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
155
|
+
collectIgnoredRules(val, resolve, rules)
|
|
119
156
|
out.ignore = rules
|
|
120
157
|
}
|
|
121
158
|
}
|
|
@@ -145,16 +182,17 @@ export function readStaticProjectConfig(projectRoot: string | undefined): { site
|
|
|
145
182
|
try {
|
|
146
183
|
const code = readFileSync(cfgPath, 'utf8')
|
|
147
184
|
const parsed = parseSync(cfgPath, code, { lang: 'ts', sourceType: 'module' })
|
|
148
|
-
const
|
|
185
|
+
const resolve = topLevelConsts(parsed.program)
|
|
186
|
+
const obj = parsed.errors.length === 0 ? extractConfigObject(parsed.program, resolve) : undefined
|
|
149
187
|
if (obj !== undefined) {
|
|
150
188
|
for (const prop of obj.properties) {
|
|
151
189
|
if (prop.type !== 'Property')
|
|
152
190
|
continue
|
|
153
191
|
const key = propKeyName(prop.key)
|
|
154
192
|
if (key === 'site')
|
|
155
|
-
site = staticString(prop.value)
|
|
193
|
+
site = staticString(prop.value, resolve)
|
|
156
194
|
else if (key === 'compliance')
|
|
157
|
-
compliance = parseStaticCompliance(prop.value)
|
|
195
|
+
compliance = parseStaticCompliance(prop.value, resolve)
|
|
158
196
|
}
|
|
159
197
|
}
|
|
160
198
|
}
|