@useavalon/avalon 0.1.26 → 0.1.28

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.
@@ -1 +1 @@
1
- export const DEFAULT_STATIC_ASSETS_CONFIG={publicDir:`public`,buildDir:`dist`,compression:!0,cacheControl:`public, max-age=31536000, immutable`,mutableCacheControl:`public, max-age=0, must-revalidate`,headers:{}};export const VALID_V3_PRESETS=[`node_server`,`node_middleware`,`vercel`,`cloudflare_module`,`cloudflare_pages`,`deno_deploy`,`deno_server`,`netlify_functions`,`netlify_edge`,`aws_lambda`,`azure_swa`,`firebase_functions`,`render_com`,`static`,`browser`];export function resolvePresetName(e){if(VALID_V3_PRESETS.includes(e))return e;throw Error(`Unknown Nitro preset: "${e}". Valid presets: ${VALID_V3_PRESETS.join(`, `)}`)}export const DEFAULT_NITRO_CONFIG={preset:`node_server`,serverDir:`server`,streaming:!0};export function createNitroConfig(t,i){let a=t.pagesDir??i.pagesDir,o=i.layoutsDir,s={streaming:t.streaming??DEFAULT_NITRO_CONFIG.streaming,pagesDir:a,layoutsDir:o};if(t.runtimeConfig&&`nitro`in t.runtimeConfig)throw Error(`The "nitro" key in runtimeConfig is reserved by Nitro v3 and cannot be used.`);let c={avalon:s,...t.runtimeConfig},l={...DEFAULT_STATIC_ASSETS_CONFIG,...t.staticAssets},u=mergeRouteRules(createDefaultStaticAssetRouteRules(l),t.routeRules??{}),d=[{dir:l.publicDir??DEFAULT_STATIC_ASSETS_CONFIG.publicDir,baseURL:`/`,maxAge:0}],f=t.renderer===!1?!1:t.renderer??{handler:`./server/renderer.ts`};return{preset:resolvePresetName(t.preset??DEFAULT_NITRO_CONFIG.preset),serverDir:t.serverDir??DEFAULT_NITRO_CONFIG.serverDir,routeRules:u,runtimeConfig:c,publicRuntimeConfig:t.publicRuntimeConfig,renderer:f,compatibilityDate:t.compatibilityDate,traceDeps:t.traceDeps,rolldownConfig:t.rolldownConfig,serverEntry:t.serverEntry,compressPublicAssets:t.compressPublicAssets,publicAssets:d,staticAssets:l}}export function createDefaultStaticAssetRouteRules(t){let n=t.cacheControl??DEFAULT_STATIC_ASSETS_CONFIG.cacheControl,r=t.mutableCacheControl??DEFAULT_STATIC_ASSETS_CONFIG.mutableCacheControl;return{"/assets/**":{headers:{"Cache-Control":n,...t.headers}},"/islands/**":{headers:{"Cache-Control":n,...t.headers}},"/chunks/**":{headers:{"Cache-Control":n,...t.headers}},"/_nuxt/**":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff2":{headers:{"Cache-Control":n,...t.headers}},"/**/*.html":{headers:{"Cache-Control":r,...t.headers}},"/favicon.ico":{headers:{"Cache-Control":`public, max-age=86400`,...t.headers}},"/**/*.css":{headers:{"Cache-Control":r,...t.headers}}}}export function isValidPreset(e){return VALID_V3_PRESETS.includes(e)}export function mergeRouteRules(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]?n[e]={...n[e],...r,headers:{...n[e].headers,...r.headers}}:n[e]=r;return n}
1
+ export const DEFAULT_STATIC_ASSETS_CONFIG={publicDir:`public`,buildDir:`dist`,compression:!0,cacheControl:`public, max-age=31536000, immutable`,mutableCacheControl:`public, max-age=0, must-revalidate`,headers:{}};export const VALID_V3_PRESETS=[`node_server`,`node_middleware`,`vercel`,`cloudflare_module`,`cloudflare_pages`,`deno_deploy`,`deno_server`,`netlify`,`netlify_functions`,`netlify_edge`,`aws_lambda`,`azure_swa`,`firebase_functions`,`render_com`,`static`,`browser`];export function resolvePresetName(e){if(VALID_V3_PRESETS.includes(e))return e;throw Error(`Unknown Nitro preset: "${e}". Valid presets: ${VALID_V3_PRESETS.join(`, `)}`)}export const DEFAULT_NITRO_CONFIG={preset:`node_server`,serverDir:`server`,streaming:!0};export function createNitroConfig(t,i){let a=t.pagesDir??i.pagesDir,o=i.layoutsDir,s={streaming:t.streaming??DEFAULT_NITRO_CONFIG.streaming,pagesDir:a,layoutsDir:o};if(t.runtimeConfig&&`nitro`in t.runtimeConfig)throw Error(`The "nitro" key in runtimeConfig is reserved by Nitro v3 and cannot be used.`);let c={avalon:s,...t.runtimeConfig},l={...DEFAULT_STATIC_ASSETS_CONFIG,...t.staticAssets},u=mergeRouteRules(createDefaultStaticAssetRouteRules(l),t.routeRules??{}),d=[{dir:l.publicDir??DEFAULT_STATIC_ASSETS_CONFIG.publicDir,baseURL:`/`,maxAge:0}],f=t.renderer===!1?!1:t.renderer??{handler:`./server/renderer.ts`};return{preset:resolvePresetName(process.env.NITRO_PRESET??t.preset??DEFAULT_NITRO_CONFIG.preset),serverDir:t.serverDir??DEFAULT_NITRO_CONFIG.serverDir,routeRules:u,runtimeConfig:c,publicRuntimeConfig:t.publicRuntimeConfig,renderer:f,compatibilityDate:t.compatibilityDate,traceDeps:t.traceDeps,rolldownConfig:t.rolldownConfig,serverEntry:t.serverEntry,compressPublicAssets:t.compressPublicAssets,publicAssets:d,staticAssets:l}}export function createDefaultStaticAssetRouteRules(t){let n=t.cacheControl??DEFAULT_STATIC_ASSETS_CONFIG.cacheControl,r=t.mutableCacheControl??DEFAULT_STATIC_ASSETS_CONFIG.mutableCacheControl;return{"/assets/**":{headers:{"Cache-Control":n,...t.headers}},"/islands/**":{headers:{"Cache-Control":n,...t.headers}},"/chunks/**":{headers:{"Cache-Control":n,...t.headers}},"/_nuxt/**":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff":{headers:{"Cache-Control":n,...t.headers}},"/**/*.woff2":{headers:{"Cache-Control":n,...t.headers}},"/**/*.html":{headers:{"Cache-Control":r,...t.headers}},"/favicon.ico":{headers:{"Cache-Control":`public, max-age=86400`,...t.headers}},"/**/*.css":{headers:{"Cache-Control":r,...t.headers}}}}export function isValidPreset(e){return VALID_V3_PRESETS.includes(e)}export function mergeRouteRules(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]?n[e]={...n[e],...r,headers:{...n[e].headers,...r.headers}}:n[e]=r;return n}
@@ -1 +1 @@
1
- import{createRequire as e}from"node:module";import{dirname as t,join as n}from"node:path";import{resolveConfig as r,checkDirectoriesExist as i}from"./config.js";import{activateIntegrations as a,activateSingleIntegration as o}from"./integration-activator.js";import{discoverIntegrationsFromIslandUsage as s}from"./auto-discover.js";import{validateActiveIntegrations as c,formatValidationResults as l}from"./validation.js";import{createMDXPlugin as u}from"../build/mdx-plugin.js";import{mdxIslandTransform as d}from"../build/mdx-island-transform.js";import{pageIslandTransform as f}from"../build/page-island-transform.js";import{registry as p}from"../core/integrations/registry.js";import{createNitroIntegration as m}from"./nitro-integration.js";import{islandSidecarPlugin as h}from"./island-sidecar-plugin.js";import{createImagePlugin as g}from"./image-optimization.js";export async function collectIntegrationPlugins(e,t=!1){let n=[],r=[];for(let i of e){let e=await _(i,t);i===`lit`?r.push(...e):n.push(...e)}return[...r,...n]}async function _(e,t){let n=p.get(e);if(!n||typeof n.vitePlugin!=`function`)return[];try{let e=await n.vitePlugin();return(Array.isArray(e)?e:[e]).filter(e=>e!=null)}catch(t){return console.warn(`[avalon] Failed to load vite plugin for ${e}:`,t instanceof Error?t.message:t),[]}}async function v(e,t){let n=new Set;try{let r=await s(e.pagesDir,e.layoutsDir,t,e.modules?.dir);for(let t of r)e.integrations.includes(t)&&n.add(t)}catch{for(let t of e.integrations)n.add(t)}return n}async function y(e){if(!e.lazyIntegrations||e.integrations.length===0)return[...e.integrations];let t=await v(e);return t.size===0?[...e.integrations]:Array.from(t)}async function b(e){try{let t=await u({jsxImportSource:e.mdx.jsxImportSource,syntaxHighlighting:e.mdx.syntaxHighlighting,remarkPlugins:e.mdx.remarkPlugins,rehypePlugins:e.mdx.rehypePlugins,development:!0});return t.push(d({verbose:e.verbose})),t}catch(t){return e.showWarnings&&console.warn(`⚠️ Could not configure MDX plugin:`,t),[]}}function x(e,t,n){let{plugins:r,nitroOptions:i}=m(e,t);return globalThis.__nitroConfig=i,{plugins:r,options:i}}async function S(e,t,n){if(e.autoDiscoverIntegrations)try{let r=await s(e.pagesDir,e.layoutsDir,t,e.modules?.dir);for(let t of r)if(!n.has(t))try{await o(t,n,e.verbose)}catch(n){e.showWarnings&&console.warn(` ⚠️ Could not auto-load integration: ${t}`,n)}}catch(t){e.showWarnings&&console.warn(` ⚠️ Auto-discovery failed:`,t)}}function C(e,t){if(!e.validateIntegrations||t.size===0)return;let n=c(t,e.showWarnings);n.allValid||(console.error(l(n)),e.showWarnings&&console.warn(` ⚠️ Some integrations have validation issues.`))}export async function avalon(o){let s,c,l=new Set,u=r(o,!0),d=await y(u);d.length>0&&await a({...u,integrations:d},l);let p=await b(u),m=await g(u.image,u.verbose),_=[];l.size>0&&(_=await collectIntegrationPlugins(l,u.verbose));let v=[];if(o?.nitro){let{plugins:e}=x(u,o.nitro,u.verbose);v=e}let w=h({verbose:u.verbose}),T=e(import.meta.url),E=null;try{E=n(t(T.resolve(`@useavalon/avalon/client`)),`main.js`)}catch{}let D=new Set([`preact`,`react`,`vue`,`svelte`,`solid`,`lit`,`qwik`].flatMap(e=>[`/@useavalon/${e}/client`,`/@useavalon/${e}/client/hmr`])),O={name:`avalon`,enforce:`pre`,config(){return{oxc:{exclude:[/node_modules\/@useavalon\/.*\.tsx?$/]},ssr:{noExternal:[/^@useavalon\//]},optimizeDeps:{include:d.flatMap(e=>[`@useavalon/${e}/client`,`@useavalon/${e}/client/hmr`])}}},configResolved(e){c=e,s=r(o,e.command===`serve`),globalThis.__avalonConfig=s,i(s,e.root)},async resolveId(e){if(e===`/src/client/main.js`&&E)return E;if(D.has(e)){let t=e.slice(1);return(await this.resolve(t))?.id??null}return null},async transform(e,t){if(t.includes(`@useavalon/`)&&/\.tsx?$/.test(t)){let{transform:n}=await import(`oxc-transform`),r=await n(t,e,{sourcemap:!0,typescript:{onlyRemoveTypeImports:!1}});return{code:r.code,map:r.map,moduleType:`js`}}},async buildStart(){await S(s,c?.root,l),C(s,l)},configureServer(e){globalThis.__viteDevServer=e}},k=_.filter(e=>e.name?.includes(`lit`)),A=_.filter(e=>!e.name?.includes(`lit`));return[f({pagesDir:u.pagesDir,layoutsDir:u.layoutsDir,modules:u.modules,verbose:u.verbose}),...m,...k,...p,O,w,...v,...A]}export function getResolvedConfig(){return globalThis.__avalonConfig}export function getPagesDir(){return globalThis.__avalonConfig?.pagesDir??`src/pages`}export function getLayoutsDir(){return globalThis.__avalonConfig?.layoutsDir??`src/layouts`}export function getNitroConfig(){return globalThis.__nitroConfig}export function isNitroEnabled(){return globalThis.__nitroConfig!==void 0}
1
+ import{createRequire as e}from"node:module";import{dirname as t,join as n}from"node:path";import{resolveConfig as r,checkDirectoriesExist as i}from"./config.js";import{activateIntegrations as a,activateSingleIntegration as o}from"./integration-activator.js";import{discoverIntegrationsFromIslandUsage as s}from"./auto-discover.js";import{validateActiveIntegrations as c,formatValidationResults as l}from"./validation.js";import{createMDXPlugin as u}from"../build/mdx-plugin.js";import{mdxIslandTransform as d}from"../build/mdx-island-transform.js";import{pageIslandTransform as f}from"../build/page-island-transform.js";import{registry as p}from"../core/integrations/registry.js";import{createNitroIntegration as m}from"./nitro-integration.js";import{islandSidecarPlugin as h}from"./island-sidecar-plugin.js";import{createImagePlugin as g}from"./image-optimization.js";export async function collectIntegrationPlugins(e,t=!1){let n=[],r=[];for(let i of e){let e=await _(i,t);i===`lit`?r.push(...e):n.push(...e)}return[...r,...n]}async function _(e,t){let n=p.get(e);if(!n||typeof n.vitePlugin!=`function`)return[];try{let e=await n.vitePlugin();return(Array.isArray(e)?e:[e]).filter(e=>e!=null)}catch(t){return console.warn(`[avalon] Failed to load vite plugin for ${e}:`,t instanceof Error?t.message:t),[]}}async function v(e,t){let n=new Set;try{let r=await s(e.pagesDir,e.layoutsDir,t,e.modules?.dir);for(let t of r)e.integrations.includes(t)&&n.add(t)}catch{for(let t of e.integrations)n.add(t)}return n}async function y(e){if(!e.lazyIntegrations||e.integrations.length===0)return[...e.integrations];let t=await v(e);return t.size===0?[...e.integrations]:Array.from(t)}async function b(e){try{let t=await u({jsxImportSource:e.mdx.jsxImportSource,syntaxHighlighting:e.mdx.syntaxHighlighting,remarkPlugins:e.mdx.remarkPlugins,rehypePlugins:e.mdx.rehypePlugins,development:!0});return t.push(d({verbose:e.verbose})),t}catch(t){return e.showWarnings&&console.warn(`⚠️ Could not configure MDX plugin:`,t),[]}}function x(e,t,n){let{plugins:r,nitroOptions:i}=m(e,t);return globalThis.__nitroConfig=i,{plugins:r,options:i}}async function S(e,t,n){if(e.autoDiscoverIntegrations)try{let r=await s(e.pagesDir,e.layoutsDir,t,e.modules?.dir);for(let t of r)if(!n.has(t))try{await o(t,n,e.verbose)}catch(n){e.showWarnings&&console.warn(` ⚠️ Could not auto-load integration: ${t}`,n)}}catch(t){e.showWarnings&&console.warn(` ⚠️ Auto-discovery failed:`,t)}}function C(e,t){if(!e.validateIntegrations||t.size===0)return;let n=c(t,e.showWarnings);n.allValid||(console.error(l(n)),e.showWarnings&&console.warn(` ⚠️ Some integrations have validation issues.`))}export async function avalon(o){let s,c,l=new Set,u=r(o,!0),d=await y(u);d.length>0&&await a({...u,integrations:d},l);let p=await b(u),m=await g(u.image,u.verbose),_=[];l.size>0&&(_=await collectIntegrationPlugins(l,u.verbose));let v=[];if(o?.nitro){let{plugins:e}=x(u,o.nitro,u.verbose);v=e}let w=h({verbose:u.verbose}),T=e(import.meta.url),E=null;try{E=n(t(T.resolve(`@useavalon/avalon/client`)),`main.js`)}catch{}let D=new Set([`preact`,`react`,`vue`,`svelte`,`solid`,`lit`,`qwik`].flatMap(e=>[`/@useavalon/${e}/client`,`/@useavalon/${e}/client/hmr`])),O={name:`avalon`,enforce:`pre`,config(){let e={preact:[`preact`,`preact/hooks`],react:[`react`,`react-dom`,`react-dom/client`],vue:[`vue`],svelte:[`svelte`,`svelte/internal`],solid:[`solid-js`,`solid-js/web`],lit:[`lit`,`@lit-labs/ssr-client`],qwik:[`@builder.io/qwik`]},t=d.flatMap(t=>e[t]??[]);return{oxc:{exclude:[/node_modules\/@useavalon\/.*\.tsx?$/]},ssr:{noExternal:[/^@useavalon\//]},optimizeDeps:{exclude:[`@useavalon/avalon`,...d.map(e=>`@useavalon/${e}`)],include:t}}},configResolved(e){c=e,s=r(o,e.command===`serve`),globalThis.__avalonConfig=s,i(s,e.root)},async resolveId(e){if(e===`/src/client/main.js`&&E)return E;if(D.has(e)){let t=e.slice(1);return(await this.resolve(t))?.id??null}return null},async transform(e,t){if(t.includes(`@useavalon/`)&&/\.tsx?$/.test(t)){let{transform:n}=await import(`oxc-transform`),r=await n(t,e,{sourcemap:!0,typescript:{onlyRemoveTypeImports:!1}});return{code:r.code,map:r.map,moduleType:`js`}}},async buildStart(){await S(s,c?.root,l),C(s,l)},configureServer(e){globalThis.__viteDevServer=e}},k=_.filter(e=>e.name?.includes(`lit`)),A=_.filter(e=>!e.name?.includes(`lit`));return[f({pagesDir:u.pagesDir,layoutsDir:u.layoutsDir,modules:u.modules,verbose:u.verbose}),...m,...k,...p,O,w,...v,...A]}export function getResolvedConfig(){return globalThis.__avalonConfig}export function getPagesDir(){return globalThis.__avalonConfig?.pagesDir??`src/pages`}export function getLayoutsDir(){return globalThis.__avalonConfig?.layoutsDir??`src/layouts`}export function getNitroConfig(){return globalThis.__nitroConfig}export function isNitroEnabled(){return globalThis.__nitroConfig!==void 0}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useavalon/avalon",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Multi-framework islands architecture for the modern web",
5
5
  "license": "MIT",
6
6
  "type": "module",