Class: Lutaml::Xsd::Spa::Strategies::VueCdnStrategy
- Inherits:
-
OutputStrategy
- Object
- OutputStrategy
- Lutaml::Xsd::Spa::Strategies::VueCdnStrategy
- Defined in:
- lib/lutaml/xsd/spa/strategies/vue_cdn_strategy.rb
Overview
VueCdnStrategy - Generates HTML that loads Vue app from CDN
This strategy generates an HTML file that loads Vue.js and the pre-built application assets from CDN/external sources. The resulting HTML is smaller but requires network access and must be served via HTTP (not file://).
Note: When opening HTML via file:// protocol, browsers block loading external JS files due to CORS. Use VueInlinedStrategy for local files.
Constant Summary collapse
- VUE_CDN_URL =
Vue 3 CDN URLs
"https://unpkg.com/vue@3.4.21/dist/vue.global.prod.js"- VUE_ROUTER_CDN_URL =
"https://unpkg.com/vue-router@4.3.0/dist/vue-router.global.prod.js"- PINIA_CDN_URL =
"https://unpkg.com/pinia@2.1.7/dist/pinia.iife.prod.js"- DEFAULT_CDN_BASE =
Default CDN base URL for app assets
"https://cdn.example.com/lutaml-xsd"
Instance Attribute Summary collapse
-
#config_loader ⇒ Object
readonly
Returns the value of attribute config_loader.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
Attributes inherited from OutputStrategy
Instance Method Summary collapse
-
#generate(data, _renderer) ⇒ Array<String>
Generate HTML file with CDN-loaded Vue app.
-
#initialize(output_path, config_loader, verbose: false, **options) ⇒ VueCdnStrategy
constructor
Initialize Vue CDN strategy.
Methods inherited from OutputStrategy
Constructor Details
#initialize(output_path, config_loader, verbose: false, **options) ⇒ VueCdnStrategy
Initialize Vue CDN strategy
43 44 45 46 47 48 |
# File 'lib/lutaml/xsd/spa/strategies/vue_cdn_strategy.rb', line 43 def initialize(output_path, config_loader, verbose: false, **) super(verbose: verbose) @output_path = output_path @config_loader = config_loader @options = end |
Instance Attribute Details
#config_loader ⇒ Object (readonly)
Returns the value of attribute config_loader.
34 35 36 |
# File 'lib/lutaml/xsd/spa/strategies/vue_cdn_strategy.rb', line 34 def config_loader @config_loader end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
34 35 36 |
# File 'lib/lutaml/xsd/spa/strategies/vue_cdn_strategy.rb', line 34 def @options end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
34 35 36 |
# File 'lib/lutaml/xsd/spa/strategies/vue_cdn_strategy.rb', line 34 def output_path @output_path end |
Instance Method Details
#generate(data, _renderer) ⇒ Array<String>
Generate HTML file with CDN-loaded Vue app
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/lutaml/xsd/spa/strategies/vue_cdn_strategy.rb', line 55 def generate(data, _renderer) log "Generating Vue CDN SPA (HTML loads Vue from CDN)..." # Build complete HTML document html = build_html_document(data) # Write to file prepare_output files = [write_file(output_path, html)] # Copy assets to output directory asset_files = copy_assets log "✓ Vue CDN SPA generated: #{output_path}" log " Note: Assets copied to #{output_dir}/app.iife.js and #{output_dir}/style.css" log " Serve via HTTP to load assets correctly (not file://)" files + asset_files end |