t23-sfc-compile.mjs 1.8 KB

12345678910111213141516171819202122232425262728293031
  1. import assert from 'node:assert/strict'
  2. import { readFileSync } from 'node:fs'
  3. import { parse, compileScript, compileTemplate } from '@vue/compiler-sfc'
  4. const files = [
  5. 'src/modules/cockpit/components/MapCanvas.vue',
  6. 'src/modules/cockpit/components/PipeEnhancement.vue',
  7. 'src/modules/cockpit/CockpitShell.vue',
  8. ]
  9. for (const file of files) {
  10. const source = readFileSync(file, 'utf8')
  11. const { descriptor } = parse(source, { filename: file })
  12. const script = compileScript(descriptor, { id: `t23-${file}` })
  13. const template = compileTemplate({ source: descriptor.template.content, filename: file, id: `t23-${file}`, compilerOptions: { bindingMetadata: script.bindings } })
  14. assert.deepEqual(template.errors, [], `${file} template errors`)
  15. console.log(`PASS ${file}`)
  16. }
  17. const shellSource = readFileSync('src/modules/cockpit/CockpitShell.vue', 'utf8')
  18. assert.match(shellSource, /@pipeline-pick="selectPipeEnhancement"/)
  19. assert.match(shellSource, /<PipeEnhancement\b[^>]*:plan="pipeEnhancementPlan"[^>]*@close="closePipeEnhancement"\s*\/>/)
  20. assert.match(shellSource, /visiblePipes: modeLayerPlan\.value\.pipelines/)
  21. assert.match(shellSource, /visibleComponents: modeLayerPlan\.value\.facilities/)
  22. assert.match(shellSource, /usePipeEnhancementStore/)
  23. assert.match(shellSource, /pipeEnhancementStore\.clear\(\)/)
  24. console.log('PASS CockpitShell Three.js and Pinia public seam')
  25. const enhancementSource = readFileSync('src/modules/cockpit/components/PipeEnhancement.vue', 'utf8')
  26. assert.match(enhancementSource, /mountGeneration/)
  27. assert.match(enhancementSource, /generation !== mountGeneration/)
  28. assert.match(enhancementSource, /JSON\.stringify\(\[props\.plan\.object/)
  29. console.log('PASS Pinia selection and async mount guards')
  30. console.log(`T23 SFC compile: ${files.length + 2}/${files.length + 2}`)