@bakery-framework/plugin-vue 2.4.2 → 2.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakery-framework/plugin-vue",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "Bakery vue plugin.",
5
5
  "keywords": [
6
6
  "bakery",
@@ -43,7 +43,7 @@
43
43
  "vue": "^3.5.38"
44
44
  },
45
45
  "dependencies": {
46
- "@bakery-framework/core": "^2.4.2"
46
+ "@bakery-framework/core": "^2.4.3"
47
47
  },
48
48
  "engines": {
49
49
  "bun": ">=1.4.0"
package/src/actions.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { Bakery, hostKey } from '@bakery-framework/core/core/bakery'
2
- import { fs, response, toHash } from '@bakery-framework/core/utils'
2
+ import {
3
+ fs,
4
+ requestOrigin,
5
+ response,
6
+ toHash,
7
+ } from '@bakery-framework/core/utils'
3
8
  import type { VueMeta } from './types'
4
9
  import { collectExportedFunctionNames } from './utils'
5
10
 
@@ -33,15 +38,18 @@ export function validateActionRequest(req: Request, url: URL): Response | null {
33
38
  return response.error('Server actions require a JSON body', 415)
34
39
  }
35
40
 
36
- const origin = req.headers.get('origin')
37
- if (origin && origin !== url.origin) {
38
- return response.error('Cross-origin server action rejected', 403)
39
- }
40
-
41
41
  const fetchSite = req.headers.get('sec-fetch-site')
42
42
  if (fetchSite && fetchSite !== 'same-origin' && fetchSite !== 'none') {
43
43
  return response.error('Cross-site server action rejected', 403)
44
44
  }
45
+ // Settled, as in `checkSameOrigin`: behind a proxy that ends TLS, `Origin`
46
+ // names a scheme this server never saw.
47
+ if (fetchSite) return null
48
+
49
+ const origin = req.headers.get('origin')
50
+ if (origin && origin !== requestOrigin(req, url)) {
51
+ return response.error('Cross-origin server action rejected', 403)
52
+ }
45
53
 
46
54
  return null
47
55
  }
package/src/compile.ts CHANGED
@@ -123,6 +123,13 @@ export function vuePluginOptionsFingerprint(): string {
123
123
  )
124
124
  }
125
125
 
126
+ /**
127
+ * Elements no component resolves. `selectedcontent` belongs to the customizable
128
+ * `<select>`, and Vue's list of HTML tags predates it: compiled as a component,
129
+ * every page holding one warned in development.
130
+ */
131
+ const BUILT_IN_ELEMENTS = ['iconify-icon', 'selectedcontent']
132
+
126
133
  export function resolveIsCustomElement(tag: string): boolean {
127
134
  const ce = vuePluginOptions?.customElements
128
135
  const userFn = vuePluginOptions?.compilerOptions?.isCustomElement
@@ -137,9 +144,7 @@ export function resolveIsCustomElement(tag: string): boolean {
137
144
  if (userFn(tag)) return true
138
145
  }
139
146
 
140
- if (tag === 'iconify-icon') return true
141
-
142
- return false
147
+ return BUILT_IN_ELEMENTS.includes(tag)
143
148
  }
144
149
 
145
150
  export async function parseVue(
@@ -286,10 +291,13 @@ export async function compileStyleBlock(
286
291
  export function assembleComponent(options: AssembleComponentOptions): string {
287
292
  const { scriptCode, renderCode, isRoot, scopeId, layoutRoute } = options
288
293
  const COMPONENT_VAR = '__sfc__'
289
- let output = scriptCode.replace(
290
- /\bexport\s+default\s*/,
291
- `const ${COMPONENT_VAR} = `,
292
- )
294
+ // A plain `<script>` with no `export default` has nothing to rewrite, and
295
+ // everything below hangs off the variable all the same. Measured: the module
296
+ // answered 200 and died with `ReferenceError: __sfc__ is not defined`, on a
297
+ // blank page, with `--build` exiting 0.
298
+ let output = /\bexport\s+default\b/.test(scriptCode)
299
+ ? scriptCode.replace(/\bexport\s+default\s*/, `const ${COMPONENT_VAR} = `)
300
+ : `${scriptCode}\nconst ${COMPONENT_VAR} = {};`
293
301
 
294
302
  if (renderCode) {
295
303
  // No export strip here, deliberately. `compileTemplateBlock` has already
@@ -353,12 +361,15 @@ export function assembleComponent(options: AssembleComponentOptions): string {
353
361
  */
354
362
  function buildRuntimeCustomElementCheck(): string {
355
363
  const ce = vuePluginOptions.customElements
364
+ const builtIn = JSON.stringify(BUILT_IN_ELEMENTS)
356
365
 
357
366
  if (typeof ce === 'function') {
358
- return `(tag) => { try { return (${ce.toString()})(tag) || tag === 'iconify-icon' } catch { return tag === 'iconify-icon' } }`
367
+ return `(tag) => { try { return (${ce.toString()})(tag) || ${builtIn}.includes(tag) } catch { return ${builtIn}.includes(tag) } }`
359
368
  }
360
369
 
361
- const tags = [...new Set([...(Array.isArray(ce) ? ce : []), 'iconify-icon'])]
370
+ const tags = [
371
+ ...new Set([...(Array.isArray(ce) ? ce : []), ...BUILT_IN_ELEMENTS]),
372
+ ]
362
373
  return `(tag) => ${JSON.stringify(tags)}.includes(tag)`
363
374
  }
364
375