@@ -194,7 +194,7 @@ jobs:
194194
195195 # Execute the importmap generation script
196196 echo "Executing importmap generation script..."
197- VERSION=$VERSION CORE_VERSION=$CORE_VERSION CORE_ENTRY=$core_entry node generate-importmap.js
197+ VERSION=$VERSION CORE_VERSION=$CORE_VERSION CORE_ENTRY=$core_entry LIT_VERSION=$LIT_VERSION node generate-importmap.js
198198 rm generate-importmap.js
199199
200200 # The importmap generation script also handles the latest importmap update logic
@@ -229,41 +229,124 @@ jobs:
229229 echo "Copying importmap loader to CDN root..."
230230 cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/importmap-loader.js.template cdn/importmap.js
231231
232- # Get Lit version from peerDependencies
233- echo "Getting Lit version from package.json peerDependencies ..."
232+ # Get Lit version from renderer package dependencies
233+ echo "Getting Lit version from renderer package dependencies ..."
234234 LIT_VERSION=$(node -e "
235- const pkg = require('./package.json');
236- const litVersion = pkg.peerDependencies && pkg.peerDependencies .lit
237- ? pkg.peerDependencies .lit.replace(/[^0-9.]/g, '')
235+ const pkg = require('./packages/renderer/ package.json');
236+ const litVersion = pkg.dependencies && pkg.dependencies .lit
237+ ? pkg.dependencies .lit.replace(/[^0-9.]/g, '')
238238 : '3.0.0'; // fallback to stable version if not specified
239239 console.log(litVersion);
240240 ")
241241 echo "Using Lit version: $LIT_VERSION"
242242
243- # Download and bundle Lit dependency
243+ # Download and bundle Lit dependency with version directory structure
244244 echo "Downloading Lit dependency from unpkg..."
245- mkdir -p cdn/lit
245+ mkdir -p cdn/lit/$LIT_VERSION
246246
247247 # Use curl to download the Lit package with specific version
248- curl -s "https://www.unpkg.com/lit@$LIT_VERSION/index.js" > cdn/lit/index.js
248+ curl -s "https://www.unpkg.com/lit@$LIT_VERSION/index.js" > cdn/lit/$LIT_VERSION/index.js
249+
250+ # Create an index.html file in the versioned directory
251+ cat > cdn/lit/$LIT_VERSION/index.html << EOF
252+ <!DOCTYPE html>
253+ <html>
254+ <head>
255+ <meta charset="UTF-8">
256+ <title>Lit v$LIT_VERSION</title>
257+ <link rel="preconnect" href="https://fonts.googleapis.com">
258+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
259+ <link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;1,400&display=swap" rel="stylesheet">
260+ <style>
261+ :root {
262+ --primary : # 2185d0;
263+ --text : # 333;
264+ --bg : # fff;
265+ --code-bg : # f5f5f5;
266+ --border : # eaeaea;
267+ }
268+
269+ @media (prefers-color-scheme: dark) {
270+ :root {
271+ --primary : # 54c8ff;
272+ --text : # f0f0f0;
273+ --bg : # 121212;
274+ --code-bg : # 1e1e1e;
275+ --border : # 333;
276+ }
277+ }
278+
279+ body {
280+ font-family : ' Lato' , -apple-system, sans-serif;
281+ max-width : 800px;
282+ margin : 0 auto;
283+ padding : 2rem;
284+ color : var(--text);
285+ background-color : var(--bg);
286+ line-height : 1.6;
287+ }
288+
289+ h1, h2, h3 { color : var(--primary); }
290+
291+ pre {
292+ background : var(--code-bg);
293+ padding : 1rem;
294+ border-radius : 5px;
295+ overflow-x : auto;
296+ }
297+
298+ code {
299+ background : var(--code-bg);
300+ padding : 0.2rem 0.4rem;
301+ border-radius : 3px;
302+ font-family : monospace;
303+ }
304+
305+ a { color : var(--primary); }
306+ </style>
307+ </head>
308+ <body>
309+ <h1>Lit <span style="opacity : 0.7;">v$LIT_VERSION</span></h1>
310+ <p>This is the Lit library hosted for Semantic UI Next. It's a dependency for the renderer package.</p>
311+
312+ <h2>Usage</h2>
313+ <p>This package is automatically included in the importmap when using Semantic UI Next from the CDN:</p>
314+ <pre><code>import { html } from 'lit';</code></pre>
315+
316+ <p>Main entry point : <a href="./index.js">index.js</a></p>
317+
318+ <h2>Documentation</h2>
319+ <p>For Lit documentation, visit the <a href="https://lit.dev/" target="_blank">official Lit website</a>.</p>
320+
321+ <p><a href="/index.html">Back to CDN home</a></p>
322+ </body>
323+ </html>
324+ EOF
325+
326+ # Create a redirect at the base path
327+ mkdir -p cdn/lit
328+ echo "Creating redirect for lit to version $LIT_VERSION"
329+ cat > cdn/lit/index.html << EOF
330+ <!DOCTYPE html>
331+ <html>
332+ <head>
333+ <meta http-equiv="refresh" content="0;URL=./$LIT_VERSION/">
334+ <title>Redirecting to Lit $LIT_VERSION</title>
335+ </head>
336+ <body>
337+ <p>Redirecting to <a href="./$LIT_VERSION/">Lit v$LIT_VERSION</a></p>
338+ </body>
339+ </html>
340+ EOF
249341
250342 # Add Lit to our importmap
251343 echo "Adding Lit to importmap..."
252344 cd cdn
253- # Create a temporary script to add Lit to existing importmaps
254- cat > add-lit-to-importmap.js << 'EOF'
255- const fs = require('fs');
256- const files = fs.readdirSync('.').filter(f => f.startsWith('importmap-') && f.endsWith('.json'));
257- files.forEach(file => {
258- const importmap = JSON.parse(fs.readFileSync(file, 'utf8'));
259- if (!importmap.imports.lit) {
260- importmap.imports.lit = 'https://cdn.semantic-ui.com/lit/index.js';
261- fs.writeFileSync(file, JSON.stringify(importmap, null, 2));
262- console.log(`Added Lit to ${file}`);
263- }
264- });
265- EOF
266- node add-lit-to-importmap.js
345+ # Copy the script template for adding Lit to importmaps
346+ cp $GITHUB_WORKSPACE/scripts/assets/templates/cdn/add-lit-to-importmap.js.template add-lit-to-importmap.js
347+ # Execute the script with ESM support, passing the LIT_VERSION
348+ LIT_VERSION=$LIT_VERSION node --input-type=module add-lit-to-importmap.js
349+ # Clean up
267350 rm add-lit-to-importmap.js
268351 cd ..
269352
0 commit comments