@useavalon/avalon 0.3.2-canary.12 → 0.3.2-canary.13
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/dist/mod.d.ts +1 -1
- package/dist/mod.js +1 -1
- package/dist/src/build/page-island-await.js +1 -1
- package/dist/src/build/page-island-transform.js +2 -2
- package/dist/src/islands/island.d.ts +8 -1
- package/dist/src/islands/island.js +1 -1
- package/dist/src/islands/types.d.ts +2 -0
- package/package.json +2 -2
package/dist/mod.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type { HydrationDirectiveDefinition, HydrationDirectiveFn, } from "./src/
|
|
|
22
22
|
export { getDirective, getRegisteredDirectives, isCustomDirective, registerHydrationDirective, unregisterHydrationDirective, } from "./src/islands/hydration-directives.ts";
|
|
23
23
|
export type { PreloadIntegrationsOptions } from "./src/islands/integration-loader.ts";
|
|
24
24
|
export { DEFAULT_PRELOAD_FRAMEWORKS, detectAndLoadIntegration, detectFrameworksFromPageContent, loadIntegration, preloadIntegrations, } from "./src/islands/integration-loader.ts";
|
|
25
|
-
export { default as Island, type IslandProps, renderIsland } from "./src/islands/island.tsx";
|
|
25
|
+
export { default as Island, type IslandProps, renderIsland, withListKey, } from "./src/islands/island.tsx";
|
|
26
26
|
export type { CacheConfig as IslandCacheConfig, CacheStats as IslandCacheStats, } from "./src/islands/render-cache.ts";
|
|
27
27
|
export { clearCache, clearIslandCache, configureCache, getCacheConfig, getCacheStats, invalidateCacheForFile, invalidateCacheForPath, logCacheStats, } from "./src/islands/render-cache.ts";
|
|
28
28
|
export type { Framework, RenderParams, SvelteSSRCSSEntry } from "./src/islands/types.ts";
|
package/dist/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{ACTION_ERROR_STATUS,ActionError,createActionClient,defineAction,isAction,isActionError}from"./src/actions/define.js";export{findActionsEntryInfo,generateActionTypes,getActionsWatchDir}from"./src/build/actions-types-generator.js";export{generateIslandManifest,getIslandBundlePath,loadIslandManifest}from"./src/build/island-manifest.js";export{generateIslandTypes,watchAndGenerateTypes}from"./src/build/island-types-generator.js";export{mdxIslandTransform}from"./src/build/mdx-island-transform.js";export{pageIslandTransform}from"./src/build/page-island-transform.js";export{registry as integrationRegistry}from"./src/core/integrations/registry.js";export{registerBuiltinDirectives}from"./src/islands/builtin-directives.js";export{analyzeComponentFile,renderComponentSSROnly}from"./src/islands/component-analysis.js";export{addSvelteSSRCSS,clearSvelteComponentCSS,generateComponentScopeId,getSvelteComponentCSS,getSvelteSSRCSS,getSvelteSSRCSSForHead,getSvelteSSRCSSStats}from"./src/islands/css-utils.js";export{createIslandRegistry,createIslandResolver,createIslandValidator,createIslandWatcher,DEFAULT_DISCOVERY_CONFIG,discoverAllIslands,discoverIslandDirectories,discoverIslandsInDirectory,formatCircularDependency,formatValidationError,formatValidationResult,formatValidationWarning,getDefaultIslandsPath,getQualifiedIslandName,hasDefaultIslandsDirectory,ISLAND_FILE_EXTENSIONS,IslandRegistry,IslandResolver,IslandValidator,IslandWatcher,isIslandsDirectory,isSupportedIslandExtension,parseQualifiedIslandName,validateAllIslands}from"./src/islands/discovery/index.js";export{detectFramework,detectFrameworkFromSrc,resolveIslandPath}from"./src/islands/framework-detection.js";export{getDirective,getRegisteredDirectives,isCustomDirective,registerHydrationDirective,unregisterHydrationDirective}from"./src/islands/hydration-directives.js";export{DEFAULT_PRELOAD_FRAMEWORKS,detectAndLoadIntegration,detectFrameworksFromPageContent,loadIntegration,preloadIntegrations}from"./src/islands/integration-loader.js";export{default as Island,renderIsland}from"./src/islands/island.js";export{clearCache,clearIslandCache,configureCache,getCacheConfig,getCacheStats,invalidateCacheForFile,invalidateCacheForPath,logCacheStats}from"./src/islands/render-cache.js";export{renderToHtml}from"./src/render/ssr.js";export{createNitroCoordinationPlugin,createNitroIntegration,createVirtualModulesPlugin,getAvalonConfig,getViteDevServer,isDevelopmentMode,RESOLVED_VIRTUAL_IDS,VIRTUAL_MODULE_IDS}from"./src/vite-plugin/nitro-integration.js";export{avalon,getLayoutsDir,getNitroConfig,getPagesDir,getResolvedConfig,isNitroEnabled}from"./src/vite-plugin/plugin.js";export async function build(e){throw Error("avalon build() is not available in the published package. Use `vite build` or the Avalon CLI instead.")}export{IslandErrorBoundary,withIslandErrorBoundary}from"./src/components/IslandErrorBoundary.js";export{LayoutErrorBoundary}from"./src/components/LayoutErrorBoundary.js";export*from"./src/layout-system.js";export{clearDiscoveryCache,clearMiddlewareCache,discoverScopedMiddleware,executeScopedMiddleware,getContextValue,getMatchingMiddleware,getMiddlewareCacheSize,hasContextValue,invalidateMiddleware,setContextValue}from"./src/middleware/index.js";export{usePersistentState}from"./src/persistence/use-persistent-state.js";export{CRON_ALIASES,CronConfigSchema,CronJobSchema,CronScheduleSchema,isValidCronExpression}from"./src/schemas/cron.js";
|
|
1
|
+
export{ACTION_ERROR_STATUS,ActionError,createActionClient,defineAction,isAction,isActionError}from"./src/actions/define.js";export{findActionsEntryInfo,generateActionTypes,getActionsWatchDir}from"./src/build/actions-types-generator.js";export{generateIslandManifest,getIslandBundlePath,loadIslandManifest}from"./src/build/island-manifest.js";export{generateIslandTypes,watchAndGenerateTypes}from"./src/build/island-types-generator.js";export{mdxIslandTransform}from"./src/build/mdx-island-transform.js";export{pageIslandTransform}from"./src/build/page-island-transform.js";export{registry as integrationRegistry}from"./src/core/integrations/registry.js";export{registerBuiltinDirectives}from"./src/islands/builtin-directives.js";export{analyzeComponentFile,renderComponentSSROnly}from"./src/islands/component-analysis.js";export{addSvelteSSRCSS,clearSvelteComponentCSS,generateComponentScopeId,getSvelteComponentCSS,getSvelteSSRCSS,getSvelteSSRCSSForHead,getSvelteSSRCSSStats}from"./src/islands/css-utils.js";export{createIslandRegistry,createIslandResolver,createIslandValidator,createIslandWatcher,DEFAULT_DISCOVERY_CONFIG,discoverAllIslands,discoverIslandDirectories,discoverIslandsInDirectory,formatCircularDependency,formatValidationError,formatValidationResult,formatValidationWarning,getDefaultIslandsPath,getQualifiedIslandName,hasDefaultIslandsDirectory,ISLAND_FILE_EXTENSIONS,IslandRegistry,IslandResolver,IslandValidator,IslandWatcher,isIslandsDirectory,isSupportedIslandExtension,parseQualifiedIslandName,validateAllIslands}from"./src/islands/discovery/index.js";export{detectFramework,detectFrameworkFromSrc,resolveIslandPath}from"./src/islands/framework-detection.js";export{getDirective,getRegisteredDirectives,isCustomDirective,registerHydrationDirective,unregisterHydrationDirective}from"./src/islands/hydration-directives.js";export{DEFAULT_PRELOAD_FRAMEWORKS,detectAndLoadIntegration,detectFrameworksFromPageContent,loadIntegration,preloadIntegrations}from"./src/islands/integration-loader.js";export{default as Island,renderIsland,withListKey}from"./src/islands/island.js";export{clearCache,clearIslandCache,configureCache,getCacheConfig,getCacheStats,invalidateCacheForFile,invalidateCacheForPath,logCacheStats}from"./src/islands/render-cache.js";export{renderToHtml}from"./src/render/ssr.js";export{createNitroCoordinationPlugin,createNitroIntegration,createVirtualModulesPlugin,getAvalonConfig,getViteDevServer,isDevelopmentMode,RESOLVED_VIRTUAL_IDS,VIRTUAL_MODULE_IDS}from"./src/vite-plugin/nitro-integration.js";export{avalon,getLayoutsDir,getNitroConfig,getPagesDir,getResolvedConfig,isNitroEnabled}from"./src/vite-plugin/plugin.js";export async function build(e){throw Error("avalon build() is not available in the published package. Use `vite build` or the Avalon CLI instead.")}export{IslandErrorBoundary,withIslandErrorBoundary}from"./src/components/IslandErrorBoundary.js";export{LayoutErrorBoundary}from"./src/components/LayoutErrorBoundary.js";export*from"./src/layout-system.js";export{clearDiscoveryCache,clearMiddlewareCache,discoverScopedMiddleware,executeScopedMiddleware,getContextValue,getMatchingMiddleware,getMiddlewareCacheSize,hasContextValue,invalidateMiddleware,setContextValue}from"./src/middleware/index.js";export{usePersistentState}from"./src/persistence/use-persistent-state.js";export{CRON_ALIASES,CronConfigSchema,CronJobSchema,CronScheduleSchema,isValidCronExpression}from"./src/schemas/cron.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{parseSync as e,visitorKeys as t}from"oxc-parser";const n=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`]);function r(e){return!!e&&typeof e==`object`&&typeof e.type==`string`}function i(e){let t=e;for(;t.type===`ParenthesizedExpression`&&r(t.expression);)t=t.expression;return t}function*a(e){let n=t[e.type];if(n)for(let t of n){let n=e[t];if(Array.isArray(n))for(let e of n)r(e)&&(yield e);else r(n)&&(yield n)}}function*o(e){let t=[];function*n(e){yield{node:e,ancestors:t},t.push(e);for(let t of a(e))yield*n(t);t.pop()}yield*n(e)}function s(t,n){let r=e(n.endsWith(`.jsx`)?`page.jsx`:`page.tsx`,t.replace(/\bawait\b/g,`void `),{lang:n.endsWith(`.jsx`)?`jsx`:`tsx`,range:!0});if(r.errors.length>0){let e=r.errors[0];throw Error(`[avalon] failed to parse ${n} after island transform: ${e.message}`)}return r.program}function c(e,t){return e.type===`UnaryExpression`&&e.operator===`void`&&t.startsWith(`await`,e.start)}function l(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e[r]===`
|
|
2
|
-
`&&n++;return n}function u(e){return r(e)&&e.type===`Identifier`&&typeof e.name==`string`?e.name:null}function d(e,t){return u(e.id)||(t?.type===`VariableDeclarator`?u(t.id):t?.type===`AssignmentExpression`?u(t.left):null)}function f(e){for(let t=e.length-1;t>=0;t--)if(n.has(e[t].type))return{fn:e[t],parent:t>0?e[t-1]:null};return null}function p(e){return e?e.type===`MethodDefinition`||e.type===`Property`&&e.method===!0:!1}function m(e){let t=new Set;for(let{node:n}of o(e)){if(n.type!==`ExportDefaultDeclaration`||!r(n.declaration))continue;let e=n.declaration,i=u(e)??u(e.id);i&&t.add(i)}return t}function h(e,t,n,r){let i=l(n,r);throw Error(`[avalon] island at ${t}:${i} sits inside a ${e} that cannot be marked async. Move it into the page default export, a nested function, or a .map() callback.`)}function g(e,t,r){let
|
|
2
|
+
`&&n++;return n}function u(e){return r(e)&&e.type===`Identifier`&&typeof e.name==`string`?e.name:null}function d(e,t){return u(e.id)||(t?.type===`VariableDeclarator`?u(t.id):t?.type===`AssignmentExpression`?u(t.left):null)}function f(e){for(let t=e.length-1;t>=0;t--)if(n.has(e[t].type))return{fn:e[t],parent:t>0?e[t-1]:null};return null}function p(e){return e?e.type===`MethodDefinition`||e.type===`Property`&&e.method===!0:!1}function m(e){let t=new Set;for(let{node:n}of o(e)){if(n.type!==`ExportDefaultDeclaration`||!r(n.declaration))continue;let e=n.declaration,i=u(e)??u(e.id);i&&t.add(i)}return t}function h(e,t,n,r){let i=l(n,r);throw Error(`[avalon] island at ${t}:${i} sits inside a ${e} that cannot be marked async. Move it into the page default export, a nested function, or a .map() callback.`)}function g(e,t,n,r){p(e.parent)&&h(`method`,t,n,r),e.fn.generator===!0&&h(`generator`,t,n,r)}function _(e,t,n){let r=new Set;for(let{node:i,ancestors:a}of o(e))if(c(i,n)){let e=f(a);if(!e)continue;g(e,t,n,i.start),r.add(e.fn)}return r}function v(e){let t=new Map;for(let{node:n,ancestors:r}of o(e)){if(n.type!==`JSXElement`)continue;let e=C(n);if(!e)continue;let i=t.get(e)??[];i.push({ancestors:r.slice()}),t.set(e,i)}return t}function y(e){let t=new Map;for(let{node:r,ancestors:i}of o(e))n.has(r.type)&&t.set(r,i.at(-1)??null);return t}function b(e,t,n){let r=d(e,t);return!r||!/^[A-Z]/.test(r)||n.has(r)?null:r}function x(e,t,n,r){let i=f(e);return!i||t.has(i.fn)?!1:(g(i,n,r,i.fn.start),t.add(i.fn),!0)}function S(e,t,n,r){let i=y(e),a=v(e),o=m(e),s=!0;for(;s;){s=!1;for(let e of t){let c=b(e,i.get(e)??null,o);if(c)for(let e of a.get(c)??[])x(e.ancestors,t,n,r)&&(s=!0)}}}function C(e){if(!r(e.openingElement))return null;let t=e.openingElement.name;return r(t)&&t.type===`JSXIdentifier`&&typeof t.name==`string`?t.name:null}function w(e){let t=[];for(let n of e)n.async!==!0&&t.push({start:n.start,end:n.start,text:`async `});return t}function T(e){if(!r(e.callee))return null;let t=i(e.callee),n=t.type===`ChainExpression`&&r(t.expression)?t.expression:t;return n.type===`MemberExpression`?n:null}function E(e){let t=T(e);return!t||t.computed===!0||!r(t.property)?null:u(t.property)}function D(e){if(e.type!==`CallExpression`)return!1;let t=i(r(e.callee)?e.callee:e);return t.type!==`MemberExpression`||t.computed===!0?!1:u(t.object)===`Promise`&&u(t.property)===`all`}function O(e){if(e.optional===!0)return!0;if(!r(e.callee))return!1;let t=i(e.callee);return t.type===`ChainExpression`?!0:t.type===`MemberExpression`&&t.optional===!0}function k(e){let t=Array.isArray(e.arguments)?e.arguments:[];return t[0]&&r(t[0])?i(t[0]):null}function A(e,t,n){if(!e)return!1;if(t.has(e))return!0;let r=u(e);return!!(r&&n.has(r))}const j=new Set([`map`,`flatMap`]),M=new Set([`forEach`,`filter`,`reduce`,`reduceRight`,`some`,`every`,`find`,`findIndex`,`findLast`,`findLastIndex`]);function N(e,t,n,r,i){for(let{node:a}of o(e)){if(a.type!==`CallExpression`)continue;let e=E(a);!e||!M.has(e)||A(k(a),t,n)&&h(`${e}() callback`,r,i,a.start)}}function P(e,t,n,r){if(e.type!==`CallExpression`)return null;let i=E(e);if(!i||!j.has(i)||!A(k(e),n,r))return null;let a=t.at(-1)??null;return a&&D(a)?null:e}function F(e,t,n,r,i){let a=!0;for(;a;){a=!1;for(let{node:s,ancestors:c}of o(e)){if(!P(s,c,t,n))continue;let e=f(c);e&&(g(e,r,i,s.start),!t.has(e.fn)&&(t.add(e.fn),a=!0))}}}function I(e,t){let n=T(e),i=n&&r(n.property)?n.property:null;return[{start:e.start,end:e.start,text:`(await Promise.all(`},...i?[{start:i.start,end:i.end,text:`map`}]:[],{start:e.end,end:e.end,text:t?` ?? [])).flat()`:`)).flat()`}]}function L(e){let t=O(e);return E(e)===`flatMap`?I(e,t):[{start:e.start,end:e.start,text:`await Promise.all(`},{start:e.end,end:e.end,text:t?` ?? [])`:`)`}]}function R(e,t){let n=z(t,e),r=[];for(let{node:i,ancestors:a}of o(e))P(i,a,t,n)&&r.push(...L(i));return r}function z(e,t){let n=m(t),r=new Set;for(let{node:i,ancestors:a}of o(t)){if(!e.has(i))continue;let t=d(i,a.at(-1)??null);t&&/^[A-Z]/.test(t)&&!n.has(t)&&r.add(t)}return r}function B(e,t){if(e.type===`JSXSpreadAttribute`&&r(e.argument))return`...${t.slice(e.argument.start,e.argument.end)}`;if(e.type!==`JSXAttribute`||!r(e.name))return null;let n=typeof e.name.name==`string`?e.name.name:null;if(!n||n===`key`)return null;if(!r(e.value))return`${n}: true`;if(e.value.type===`JSXExpressionContainer`&&r(e.value.expression)){let r=e.value.expression;return`${n}: ${t.slice(r.start,r.end)}`}return`${n}: ${t.slice(e.value.start,e.value.end)}`}function V(e,t){if(e.type!==`JSXAttribute`||!r(e.name)||(typeof e.name.name==`string`?e.name.name:null)!==`key`||!r(e.value))return null;if(e.value.type===`JSXExpressionContainer`&&r(e.value.expression)){let n=e.value.expression;return t.slice(n.start,n.end)}return t.slice(e.value.start,e.value.end)}function H(e,t){let n=[],i=null,a=e&&Array.isArray(e.attributes)?e.attributes:[];for(let e of a){if(!r(e))continue;let a=V(e,t);if(a!=null){i=a;continue}let o=B(e,t);o&&n.push(o)}return{props:n,keyExpr:i}}function U(e,t,n){let i=r(e.openingElement)?e.openingElement:null,{props:a,keyExpr:o}=H(i,n);if(i?.selfClosing!==!0&&r(e.closingElement)){let t=n.slice(i?i.end:e.start,e.closingElement.start);t.trim()&&a.push(`children: (${t})`)}let s=`await ${t}(${a.length>0?`{ ${a.join(`, `)} }`:`{}`})`;return o==null?s:`__pageKeyed(${o}, ${s})`}function W(e,t,n){let r=z(t,e);if(r.size===0)return[];let i=[];for(let{node:t,ancestors:a}of o(e)){if(t.type!==`JSXElement`)continue;let e=C(t);if(!e||!r.has(e))continue;let o=a.at(-1),s=o?.type===`JSXElement`||o?.type===`JSXFragment`,c=U(t,e,n);i.push({start:t.start,end:t.end,text:s?`{${c}}`:c})}return i}function G(e,t){let n=[...t].sort((e,t)=>t.start-e.start||t.end-e.end),r=e;for(let e of n)r=r.slice(0,e.start)+e.text+r.slice(e.end);return r}export function ensureAwaitContextsAsync(e,t){let n=s(e,t),r=_(n,t,e),i=z(r,n),a=0;for(;r.size!==a;)a=r.size,i=z(r,n),F(n,r,i,t,e),S(n,r,t,e);return N(n,r,i,t,e),G(e,[...w(r),...R(n,r),...W(n,r,e)])}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{dirname as e}from"node:path";import{addToManifest as t,generateComponentId as n}from"../server-islands/manifest.js";import{ensureAwaitContextsAsync as r}from"./page-island-await.js";function i(e){let t=[],n=/^[ \t]*import\s+([A-Z]\w*)\s+from\s+(['"][^'"]+['"])/gm,r=null;for(r=n.exec(e);r!==null;r=n.exec(e))t.push({localName:r[1],importPath:r[2].slice(1,-1),fullMatch:r[0].trimStart()});return t}const a=[{prefix:`@shared/`,map:e=>`/app/shared/${e}`},{prefix:`@modules/`,map:e=>`/app/modules/${e}`},{prefix:`@/`,map:e=>`/app/${e}`},{prefix:`$components/`,map:e=>`/src/components/${e}`},{prefix:`$islands/`,map:e=>`/src/islands/${e}`},{prefix:`~/`,map:e=>`/src/${e}`}];function o(e){return e.startsWith(`/`)?e:`/${e}`}function s(e,t){for(let{find:n,replacement:r}of t){let t=o(r);if(typeof n==`string`){if(e===n||e.startsWith(`${n}/`))return`${t}${e.slice(n.length)}`}else if(n.test(e))return e.replace(n,t)}return null}function c(e){for(let{prefix:t,map:n}of a)if(e.startsWith(t))return n(e.slice(t.length));return null}function l(t,n){if(!t.startsWith(`.`))return null;let r=n.replaceAll(`\\`,`/`),i=r.indexOf(`/app/`);if(i===-1&&(i=r.indexOf(`/src/`)),i===-1)return null;let a=e(r.slice(i)).split(`/`);for(let e of t.split(`/`))e===`..`?a.pop():e!==`.`&&a.push(e);return a.join(`/`)}function u(e,t,n=[]){return e.startsWith(`/`)?e:s(e,n)??c(e)??l(e,t)??`/src/${e.split(`/`).pop()}`}function d(e){if(e.endsWith(`.vue`))return`vue`;if(e.endsWith(`.svelte`))return`svelte`;if(e.includes(`.solid.`))return`solid`;if(e.includes(`.lit.`))return`lit`;if(e.includes(`.qwik.`))return`qwik`;if(e.includes(`.react.`))return`react`;if(e.endsWith(`.tsx`)||e.endsWith(`.jsx`))return`preact`}function f(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/${i}/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/${e}/[^/]+/${n.pagesDirName}/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}function p(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/${i}/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/${e}/[^/]+/${n.layoutsDirName}/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}const m=new Set([`qwik`]);function h(e){let t=d(e);return t!==void 0&&m.has(t)}const g=String.raw`[\s][^>]*island[\s]*[={]`,_=String.raw`[\s][^>]*server[\s]*[={]`,v=String.raw`[\s/>]`;function y(e,t){return t.some(t=>RegExp(`<${t}${g}`).test(e))}function b(e,t){return t.some(t=>RegExp(`<${t}${_}`).test(e))}function x(e,t){return t.some(t=>h(t.importPath)?RegExp(`<${t.localName}${v}`).test(e):!1)}function S(e,r,i,a=[]){let o=new Map;for(let s of r){let r=u(s.importPath,i,a),c=d(r),l=RegExp(`<${s.localName}${g}`),f=RegExp(`<${s.localName}${_}`),p=l.test(e),h=f.test(e);if(p||h){o.set(s.localName,{srcPath:r,framework:c,importPath:s.importPath,autoIsland:!1,hasServerProp:h}),h&&t(n(r),r);continue}c&&m.has(c)&&RegExp(`<${s.localName}${v}`).test(e)&&o.set(s.localName,{srcPath:r,framework:c,importPath:s.importPath,autoIsland:!0,hasServerProp:!1})}return o}function C(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function w(e,t){let n=e[t];for(t++;t<e.length&&e[t]!==n;)e[t]===`\\`&&t++,t++;return t<e.length?t+1:t}function T(e,t){for(t++;t<e.length&&e[t]!=="`";){if(e[t]===`\\`){t+=2;continue}if(e[t]===`$`&&e[t+1]===`{`){t=E(t+1,e);continue}t++}return t<e.length?t+1:t}function E(e,t){let n=e+1,r=1;for(;n<t.length&&r>0;){let e=t[n];e===`{`?(r++,n++):e===`}`?(r--,r>0&&n++):e===`'`||e===`"`||e==="`"?n=w(t,n):n++}return n<t.length?n+1:n}function D(e,t){let n=t+1,r=E(t,e);return{value:e.slice(n,r-1),endIdx:r}}function O(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n;)e[r]===`\\`&&r++,r++;return{value:`"${e.slice(t+1,r)}"`,endIdx:r+1}}function k(e,t){let n=t,r=t;for(;r<e.length&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;let i=e.slice(n,r);if(!i)return null;if(r=C(e,r),e[r]!==`=`)return{name:i,value:null,endIdx:r};if(r=C(e,r+1),e[r]===`{`){let t=D(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}if(e[r]===`"`||e[r]===`'`){let t=O(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}return null}function A(e,t,n){if(e[t]===`/`&&e[t+1]===`>`)return{endIdx:t+2,selfClosing:!0};if(e[t]===`>`){let r=`</${n}>`,i=e.indexOf(r,t+1);return i===-1?null:{endIdx:i+r.length,selfClosing:!1}}return null}function j(e,t,n){let r=C(e,t+1+n.length),i=null,a=null,o=[];for(;r<e.length;){r=C(e,r);let t=A(e,r,n);if(t)return{endIdx:t.endIdx,islandProp:i,serverProp:a,otherProps:
|
|
2
|
-
`,t);return n===-1?e.length:n+1}if(n===`/*`){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}return-1}function F(e,t){let n=e.indexOf(`*/`,t+3);if(n===-1)return-1;let r=n+2;for(;r<e.length&&/\s/.test(e[r]);)r++;return r<e.length&&e[r]===`}`?r+1:-1}function I(e,t,n){if(!e.startsWith(n,t))return!1;let r=t+n.length;return r>=e.length||!/[a-zA-Z0-9_$]/.test(e[r])}function L(e,t,n,r,i){let a=`<${t}`,o=``,s=0;for(;s<e.length;){let c=P(e,s);if(c!==-1){o+=e.slice(s,c),s=c;continue}let{text:l,next:u}=R(e,s,{tag:a,componentName:t,srcPath:n,framework:r,autoIsland:i});o+=l,s=u}return o}function R(e,t,n){if(!I(e,t,n.tag))return{text:e[t],next:t+1};let r=j(e,t,n.componentName);if(!r||!r.islandProp&&!r.serverProp&&!n.autoIsland){let n=r?r.endIdx:t+1;return{text:e.slice(t,n),next:n}}let i=M(r,n.srcPath,n.framework,n.autoIsland&&!r.islandProp,n.componentName);return{text:N(e,t)?`{${i}}`:i,next:r.endIdx}}function z(e){if(/\bexport\s+default\s+function\b(?!\s*\*)/.test(e))return e.replace(/\bexport\s+default\s+function\b(?!\s*\*)/,`export default async function`);let t=/\bexport\s+default\s+(\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/;if(t.test(e))return e.replace(t,`export default async $1 =>`);let n=/\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;/.exec(e);if(n){let t=n[1].replaceAll(`$`,String.raw`\$&`),r=new RegExp(String.raw`(^|[^.\w])function\s+${t}\s*\(`,`m`),i=new RegExp(String.raw`\basync\s+function\s+${t}\b`);if(r.test(e)&&!i.test(e))return e.replace(r,e=>e.replace(`function`,`async function`));let a=new RegExp(String.raw`(\b(?:const|let|var)\s+${t}\s*=\s*)(?!async\b)(\([^)]*\)\s*=>|function\b|[A-Za-z_$][\w$]*\s*=>)`);if(a.test(e))return e.replace(a,`$1async $2`)}return e}export function pageIslandTransform(e={}){let{pagesDir:t=`src/pages`,layoutsDir:n=`src/layouts`,modules:a=null}=e,o=[];return{name:`avalon:page-island-transform`,enforce:`pre`,configResolved(e){o=e.resolve?.alias??[]},transform(e,s){let c=p(s,n,a);if(!f(s,t,a)&&!c)return null;let l=i(e);if(l.length===0)return null;let u=l.map(e=>e.localName);if(!y(e,u)&&!b(e,u)&&!x(e,l))return null;let d=S(e,l,s,o);if(d.size===0)return null;let m=`import { renderIsland as __pageRenderIsland } from '@useavalon/avalon';\n${e}`;for(let[e,t]of d)m=L(m,e,t.srcPath,t.framework,t.autoIsland);return m.includes(`__pageRenderIsland(`)&&(m=z(m),m=r(m,s)),{code:m,map:null}}}}
|
|
1
|
+
import{dirname as e}from"node:path";import{addToManifest as t,generateComponentId as n}from"../server-islands/manifest.js";import{ensureAwaitContextsAsync as r}from"./page-island-await.js";function i(e){let t=[],n=/^[ \t]*import\s+([A-Z]\w*)\s+from\s+(['"][^'"]+['"])/gm,r=null;for(r=n.exec(e);r!==null;r=n.exec(e))t.push({localName:r[1],importPath:r[2].slice(1,-1),fullMatch:r[0].trimStart()});return t}const a=[{prefix:`@shared/`,map:e=>`/app/shared/${e}`},{prefix:`@modules/`,map:e=>`/app/modules/${e}`},{prefix:`@/`,map:e=>`/app/${e}`},{prefix:`$components/`,map:e=>`/src/components/${e}`},{prefix:`$islands/`,map:e=>`/src/islands/${e}`},{prefix:`~/`,map:e=>`/src/${e}`}];function o(e){return e.startsWith(`/`)?e:`/${e}`}function s(e,t){for(let{find:n,replacement:r}of t){let t=o(r);if(typeof n==`string`){if(e===n||e.startsWith(`${n}/`))return`${t}${e.slice(n.length)}`}else if(n.test(e))return e.replace(n,t)}return null}function c(e){for(let{prefix:t,map:n}of a)if(e.startsWith(t))return n(e.slice(t.length));return null}function l(t,n){if(!t.startsWith(`.`))return null;let r=n.replaceAll(`\\`,`/`),i=r.indexOf(`/app/`);if(i===-1&&(i=r.indexOf(`/src/`)),i===-1)return null;let a=e(r.slice(i)).split(`/`);for(let e of t.split(`/`))e===`..`?a.pop():e!==`.`&&a.push(e);return a.join(`/`)}function u(e,t,n=[]){return e.startsWith(`/`)?e:s(e,n)??c(e)??l(e,t)??`/src/${e.split(`/`).pop()}`}function d(e){if(e.endsWith(`.vue`))return`vue`;if(e.endsWith(`.svelte`))return`svelte`;if(e.includes(`.solid.`))return`solid`;if(e.includes(`.lit.`))return`lit`;if(e.includes(`.qwik.`))return`qwik`;if(e.includes(`.react.`))return`react`;if(e.endsWith(`.tsx`)||e.endsWith(`.jsx`))return`preact`}function f(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/${i}/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/${e}/[^/]+/${n.pagesDirName}/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}function p(e,t,n){let r=e.replaceAll(`\\`,`/`),i=t.replace(/^\//,``);if(r.includes(`/${i}/`)&&/\.(tsx|jsx)$/.test(r))return!0;if(n){let e=n.dir.replace(/^\//,``);if(RegExp(`/${e}/[^/]+/${n.layoutsDirName}/`).test(r)&&/\.(tsx|jsx)$/.test(r))return!0}return!1}const m=new Set([`qwik`]);function h(e){let t=d(e);return t!==void 0&&m.has(t)}const g=String.raw`[\s][^>]*island[\s]*[={]`,_=String.raw`[\s][^>]*server[\s]*[={]`,v=String.raw`[\s/>]`;function y(e,t){return t.some(t=>RegExp(`<${t}${g}`).test(e))}function b(e,t){return t.some(t=>RegExp(`<${t}${_}`).test(e))}function x(e,t){return t.some(t=>h(t.importPath)?RegExp(`<${t.localName}${v}`).test(e):!1)}function S(e,r,i,a=[]){let o=new Map;for(let s of r){let r=u(s.importPath,i,a),c=d(r),l=RegExp(`<${s.localName}${g}`),f=RegExp(`<${s.localName}${_}`),p=l.test(e),h=f.test(e);if(p||h){o.set(s.localName,{srcPath:r,framework:c,importPath:s.importPath,autoIsland:!1,hasServerProp:h}),h&&t(n(r),r);continue}c&&m.has(c)&&RegExp(`<${s.localName}${v}`).test(e)&&o.set(s.localName,{srcPath:r,framework:c,importPath:s.importPath,autoIsland:!0,hasServerProp:!1})}return o}function C(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function w(e,t){let n=e[t];for(t++;t<e.length&&e[t]!==n;)e[t]===`\\`&&t++,t++;return t<e.length?t+1:t}function T(e,t){for(t++;t<e.length&&e[t]!=="`";){if(e[t]===`\\`){t+=2;continue}if(e[t]===`$`&&e[t+1]===`{`){t=E(t+1,e);continue}t++}return t<e.length?t+1:t}function E(e,t){let n=e+1,r=1;for(;n<t.length&&r>0;){let e=t[n];e===`{`?(r++,n++):e===`}`?(r--,r>0&&n++):e===`'`||e===`"`||e==="`"?n=w(t,n):n++}return n<t.length?n+1:n}function D(e,t){let n=t+1,r=E(t,e);return{value:e.slice(n,r-1),endIdx:r}}function O(e,t){let n=e[t],r=t+1;for(;r<e.length&&e[r]!==n;)e[r]===`\\`&&r++,r++;return{value:`"${e.slice(t+1,r)}"`,endIdx:r+1}}function k(e,t){let n=t,r=t;for(;r<e.length&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;let i=e.slice(n,r);if(!i)return null;if(r=C(e,r),e[r]!==`=`)return{name:i,value:null,endIdx:r};if(r=C(e,r+1),e[r]===`{`){let t=D(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}if(e[r]===`"`||e[r]===`'`){let t=O(e,r);return{name:i,value:t.value,endIdx:t.endIdx}}return null}function A(e,t,n){if(e[t]===`/`&&e[t+1]===`>`)return{endIdx:t+2,selfClosing:!0};if(e[t]===`>`){let r=`</${n}>`,i=e.indexOf(r,t+1);return i===-1?null:{endIdx:i+r.length,selfClosing:!1}}return null}function j(e,t,n){let r=C(e,t+1+n.length),i=null,a=null,o=null,s=[];for(;r<e.length;){r=C(e,r);let t=A(e,r,n);if(t)return{endIdx:t.endIdx,islandProp:i,serverProp:a,keyProp:o,otherProps:s};let c=k(e,r);if(!c)return null;if(r=c.endIdx,c.name===`island`)i=c.value??`{}`;else if(c.name===`server`)a=c.value??`{}`;else if(c.name===`key`)o=c.value;else{let e=c.value===null?`${c.name}: true`:`${c.name}: ${c.value}`;s.push(e)}}return null}function M(e,t,n,r,i){let a=n?`, framework: "${n}"`:``,o=e.otherProps.length>0?`, props: { ${e.otherProps.join(`, `)} }`:``,s=e.keyProp==null?``:`, key: (${e.keyProp})`,c=`, component: ${i}`;if(r)return`await __pageRenderIsland({ src: "`+t+`"`+a+c+o+s+`, ssr: true, ssrOnly: true })`;if(e.serverProp){let n=`, server: (${e.serverProp})`,r=e.islandProp?`, island: (${e.islandProp})`:``;return`await __pageRenderIsland({ src: "`+t+`"`+a+c+n+r+o+s+` })`}let l=e.islandProp??``;return`await __pageRenderIsland({ src: "`+t+`"`+a+c+`, ...(`+l+`)`+o+`, ssr: (`+l+`).ssr !== undefined ? (`+l+`).ssr : true`+s+` })`}function N(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return!1;let r=e[n];return r===`>`?e[n-1]!==`=`:r===`}`}function P(e,t){let n=e.slice(t,t+2);if(e[t]==="`")return T(e,t);if(e[t]===`{`&&n===`{/`&&e[t+2]===`*`)return F(e,t);if(n===`//`){let n=e.indexOf(`
|
|
2
|
+
`,t);return n===-1?e.length:n+1}if(n===`/*`){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}return-1}function F(e,t){let n=e.indexOf(`*/`,t+3);if(n===-1)return-1;let r=n+2;for(;r<e.length&&/\s/.test(e[r]);)r++;return r<e.length&&e[r]===`}`?r+1:-1}function I(e,t,n){if(!e.startsWith(n,t))return!1;let r=t+n.length;return r>=e.length||!/[a-zA-Z0-9_$]/.test(e[r])}function L(e,t,n,r,i){let a=`<${t}`,o=``,s=0;for(;s<e.length;){let c=P(e,s);if(c!==-1){o+=e.slice(s,c),s=c;continue}let{text:l,next:u}=R(e,s,{tag:a,componentName:t,srcPath:n,framework:r,autoIsland:i});o+=l,s=u}return o}function R(e,t,n){if(!I(e,t,n.tag))return{text:e[t],next:t+1};let r=j(e,t,n.componentName);if(!r||!r.islandProp&&!r.serverProp&&!n.autoIsland){let n=r?r.endIdx:t+1;return{text:e.slice(t,n),next:n}}let i=M(r,n.srcPath,n.framework,n.autoIsland&&!r.islandProp,n.componentName);return{text:N(e,t)?`{${i}}`:i,next:r.endIdx}}function z(e){if(/\bexport\s+default\s+function\b(?!\s*\*)/.test(e))return e.replace(/\bexport\s+default\s+function\b(?!\s*\*)/,`export default async function`);let t=/\bexport\s+default\s+(\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/;if(t.test(e))return e.replace(t,`export default async $1 =>`);let n=/\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;/.exec(e);if(n){let t=n[1].replaceAll(`$`,String.raw`\$&`),r=new RegExp(String.raw`(^|[^.\w])function\s+${t}\s*\(`,`m`),i=new RegExp(String.raw`\basync\s+function\s+${t}\b`);if(r.test(e)&&!i.test(e))return e.replace(r,e=>e.replace(`function`,`async function`));let a=new RegExp(String.raw`(\b(?:const|let|var)\s+${t}\s*=\s*)(?!async\b)(\([^)]*\)\s*=>|function\b|[A-Za-z_$][\w$]*\s*=>)`);if(a.test(e))return e.replace(a,`$1async $2`)}return e}export function pageIslandTransform(e={}){let{pagesDir:t=`src/pages`,layoutsDir:n=`src/layouts`,modules:a=null}=e,o=[];return{name:`avalon:page-island-transform`,enforce:`pre`,configResolved(e){o=e.resolve?.alias??[]},transform(e,s){let c=p(s,n,a);if(!f(s,t,a)&&!c)return null;let l=i(e);if(l.length===0)return null;let u=l.map(e=>e.localName);if(!y(e,u)&&!b(e,u)&&!x(e,l))return null;let d=S(e,l,s,o);if(d.size===0)return null;let m=`import { renderIsland as __pageRenderIsland } from '@useavalon/avalon';\n${e}`;for(let[e,t]of d)m=L(m,e,t.srcPath,t.framework,t.autoIsland);return m.includes(`__pageRenderIsland(`)&&(m=z(m),m=r(m,s)),m.includes(`__pageKeyed(`)&&(m=m.replace(`import { renderIsland as __pageRenderIsland } from '@useavalon/avalon';`,`import { renderIsland as __pageRenderIsland, withListKey as __pageKeyed } from '@useavalon/avalon';`)),{code:m,map:null}}}}
|
|
@@ -42,7 +42,14 @@ export interface IslandProps {
|
|
|
42
42
|
server?: ServerIslandProp;
|
|
43
43
|
/** Island directive for combined server + client islands */
|
|
44
44
|
island?: IslandDirective;
|
|
45
|
+
/** React/Preact list key — set on the host VNode, never serialized into props */
|
|
46
|
+
key?: string | number;
|
|
45
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Attach a list key to a VNode returned from a rewritten helper call.
|
|
50
|
+
* Pages import this as `__pageKeyed` from the island transform.
|
|
51
|
+
*/
|
|
52
|
+
export declare function withListKey(key: unknown, vnode: JSX.Element): JSX.Element;
|
|
46
53
|
/**
|
|
47
54
|
* Universal Island component – renders `<avalon-island>` custom elements for better DOM structure.
|
|
48
55
|
*
|
|
@@ -66,4 +73,4 @@ export default function Island({ src, condition, conditionArg, props, children,
|
|
|
66
73
|
* Error isolation: If SSR fails, returns an error placeholder instead of throwing,
|
|
67
74
|
* allowing the page to continue rendering other islands.
|
|
68
75
|
*/
|
|
69
|
-
export declare function renderIsland({ src, condition, conditionArg, props, children, ssr, framework, ssrOnly, renderOptions, component: preloadedComponent, server, island, }: IslandProps): Promise<JSX.Element>;
|
|
76
|
+
export declare function renderIsland({ src, condition, conditionArg, props, children, ssr, framework, ssrOnly, renderOptions, component: preloadedComponent, server, island, key, }: IslandProps): Promise<JSX.Element>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getIslandBundlePath as e}from"../build/island-manifest.js";import{shellH as t,shellFragment as n}from"../render/shell-engine.js";import{addToManifest as r,generateComponentId as i}from"../server-islands/manifest.js";import{renderServerIsland as a}from"../server-islands/renderer.js";import{devError as o,devLog as s,devWarn as c,isDev as l,logRenderTiming as u}from"../utils/dev-logger.js";import{analyzeComponentFile as d,renderComponentSSROnly as f}from"./component-analysis.js";import{detectFramework as p}from"./framework-detection.js";import{isCustomDirective as m,serializeDirectiveScript as h}from"./hydration-directives.js";import{detectFrameworkFromPath as g,loadIntegration as _}from"./integration-loader.js";import{addModulepreload as v}from"./modulepreload-collector.js";import{generatePerIslandScript as y}from"./per-island-script.js";import{addUniversalCSS as b}from"./universal-css-collector.js";import{addUniversalHead as x}from"./universal-head-collector.js";function S(e){return`island-${e.replaceAll(/[^a-zA-Z0-9]/g,`-`)}`}function
|
|
1
|
+
import{getIslandBundlePath as e}from"../build/island-manifest.js";import{shellH as t,shellFragment as n}from"../render/shell-engine.js";import{addToManifest as r,generateComponentId as i}from"../server-islands/manifest.js";import{renderServerIsland as a}from"../server-islands/renderer.js";import{devError as o,devLog as s,devWarn as c,isDev as l,logRenderTiming as u}from"../utils/dev-logger.js";import{analyzeComponentFile as d,renderComponentSSROnly as f}from"./component-analysis.js";import{detectFramework as p}from"./framework-detection.js";import{isCustomDirective as m,serializeDirectiveScript as h}from"./hydration-directives.js";import{detectFrameworkFromPath as g,loadIntegration as _}from"./integration-loader.js";import{addModulepreload as v}from"./modulepreload-collector.js";import{generatePerIslandScript as y}from"./per-island-script.js";import{addUniversalCSS as b}from"./universal-css-collector.js";import{addUniversalHead as x}from"./universal-head-collector.js";function S(e,r){return r==null?e:t(n(),{key:r},e)}export function withListKey(e,t){return S(t,e)}function w(e){return`island-${e.replaceAll(/[^a-zA-Z0-9]/g,`-`)}`}function T(){return globalThis.__avalonHydrationMode===void 0?globalThis.__viteDevServer?!1:typeof __AVALON_PER_ISLAND__<`u`?__AVALON_PER_ISLAND__:!l():globalThis.__avalonHydrationMode===`per-island`}function E(r,i){if(!T()||i.shouldSkipHydration)return r;let a=e(i.src);i.condition===`on:client`&&v(a);let o=m(i.condition),s=o?h(i.condition):void 0,c=y({islandId:i.islandId,componentSrc:a,framework:i.framework,condition:i.condition,conditionArg:i.conditionArg,propsJson:JSON.stringify(i.props),isCustomDirective:o,directiveScript:s??void 0});return t(n(),null,r,t(`div`,{dangerouslySetInnerHTML:{__html:c},"data-island-script":``}))}function D(e){let t={};e.renderId&&(t[`data-solid-render-id`]=e.renderId);let n=e.metadata;return n?.tagName&&(t[`data-tag-name`]=n.tagName),t}function O(t,n,r,i,a){let o={"data-condition":n,"data-src":e(t),"data-props":JSON.stringify(r),"data-render-strategy":`hydrate`,...D(i)};if(m(n)){o[`data-custom-directive`]=n;let e=h(n);e&&(o[`data-directive-script`]=e)}return a&&(o[`data-condition-arg`]=a),o}function k(e){return e.startsWith(`<script`)?`script`:e.startsWith(`<style`)?`style`:e.startsWith(`<meta`)?`meta`:e.startsWith(`<link`)?`link`:e.includes(`window._$HY`)||e.includes(`_$HY=`)?`script`:`other`}function A(e){let t=e.match(/<style[^>]*>([\s\S]*?)<\/style>/i);return t?t[1].trim():null}function j(e,t,n,r){if(e.css&&b(e.css,t,n,e.scopeId),e.head){let i=e.head.trim(),a=k(i);if(a===`style`){let a=A(i);a&&(s(`${r} Extracting CSS from head <style> tag`),b(a,t,n,e.scopeId));return}x(e.head,t,n,a)}}function M(e){let{islandId:n,detectedFramework:r,shouldSkipHydration:i,src:a,condition:o,conditionArg:c,props:l,hydrationData:u,children:d}=e,f={id:n,"data-framework":r},p=i?{"data-render-strategy":`ssr-only`}:O(a,o,l,u,c);r===`lit`&&s(`🔍 [Island Component] ${a} - Lit hydration data:`,{hydrationDataKeys:Object.keys(u),metadata:u.metadata});let m={...f,...p},h;return h=typeof d==`string`?t(`avalon-island`,{...m,dangerouslySetInnerHTML:{__html:d}}):t(`avalon-island`,m,d),E(h,{islandId:n,src:a,condition:o,conditionArg:c,props:l,framework:r,shouldSkipHydration:i})}function N(n){let{islandId:r,detectedFramework:i,shouldSkipHydration:a,src:o,condition:s,props:c,hydrationData:l,conditionArg:u}=n;if(a)return t(`avalon-island`,{id:r,"data-render-strategy":`ssr-only`,"data-framework":i});let d={id:r,"data-condition":s,"data-src":e(o),"data-props":JSON.stringify(c),"data-render-strategy":`hydrate`,"data-framework":i,...D(l)};if(m(s)){d[`data-custom-directive`]=s;let e=h(s);e&&(d[`data-directive-script`]=e)}return u&&(d[`data-condition-arg`]=u),E(t(`avalon-island`,d),{islandId:r,src:o,condition:s,conditionArg:u,props:c,framework:i,shouldSkipHydration:a})}export default function P({src:e,condition:t=`on:client`,conditionArg:n,props:r={},children:i,ssr:a=t!==`on:client`,framework:o,ssrOnly:l=!1,renderOptions:u={},hydrationData:d={}}){let f=w(e),p=l||!!u.forceSSROnly,m=o||g(e),h=i!=null&&i!==``;return s(`🔍 [Island Component] ${e}`,{ssr:a,ssrOnly:l,hasChildren:h,framework:o,condition:t}),a&&h?M({islandId:f,detectedFramework:m,shouldSkipHydration:p,src:e,condition:t,conditionArg:n,props:r,hydrationData:d,children:i}):(a&&!h&&p&&c(`${e}: SSR-only component has no rendered content. This may indicate a rendering error.`),N({islandId:f,detectedFramework:m,shouldSkipHydration:p,src:e,condition:t,props:r,hydrationData:d,conditionArg:n}))}function F(n,r){let i=r instanceof Error?r.message:String(r);return o(`🚨 Island SSR failed for ${n}:`,r),r instanceof Error&&r.stack&&o(`Stack trace:`,r.stack),t(`avalon-island`,{id:w(n),"data-src":e(n),"data-ssr-error":i,"data-render-strategy":`client-only`})}async function I({src:e,condition:t,conditionArg:n,props:r,children:i,ssr:a,framework:s,ssrOnly:c,renderOptions:u,component:d}){let f=`🏝️ [${e}]`;if(!a||i)return P({src:e,condition:t,conditionArg:n,props:r,children:i,ssr:a,framework:s,ssrOnly:c,renderOptions:u});let p;try{p=await _(s)}catch(i){return o(`${f} Failed to load ${s} integration:`,i),P({src:e,condition:t,conditionArg:n,props:r,ssr:!1,framework:s,ssrOnly:c,renderOptions:u})}try{let i=await p.render({component:d??null,props:r,src:e,condition:t,ssrOnly:c,viteServer:globalThis.__viteDevServer,isDev:l()});return j(i,e,s,f),P({src:e,condition:t,conditionArg:n,props:r,children:i.html,ssr:!0,framework:s,ssrOnly:c,renderOptions:u,hydrationData:c?void 0:i.hydrationData})}catch(i){return o(`${f} Fast path SSR failed:`,i),P({src:e,condition:t,conditionArg:n,props:r,ssr:!1,framework:s,ssrOnly:c,renderOptions:u})}}async function L(e,t,n,r){if(t||n.detectScripts===!1)return t;try{let t=await d(e,n);if(t.decision.warnings?.length)for(let e of t.decision.warnings)c(`${r} Analysis warning: ${e}`);return!t.decision.shouldHydrate}catch(e){return c(`${r} Component analysis failed:`,e),t}}async function R(e){return e.endsWith(`.vue`)?`vue`:e.endsWith(`.svelte`)?`svelte`:e.endsWith(`.tsx`)||e.endsWith(`.jsx`)||e.endsWith(`.ts`)||e.endsWith(`.js`)?p(e):`unknown`}async function z(e,t,n,r,i,a,o){let s=await R(e),c=s,u=await(await B(s,a)).render({component:o??null,props:n,src:e,condition:t,ssrOnly:r,viteServer:globalThis.__viteDevServer,isDev:l()});return j(u,e,s,a),P({src:e,condition:t,props:n,children:u.html,ssr:!0,framework:c,ssrOnly:r,renderOptions:i,hydrationData:r?void 0:u.hydrationData})}async function B(e,t){try{s(`${t} Loading integration for framework: ${e}`);let n=await _(e);return s(`${t} ✅ Integration loaded successfully`),n}catch(n){throw o(`${t} Failed to load ${e} integration:`,n),Error(`Failed to load integration for framework '${e}'. Make sure @useavalon/${e} is installed.\nInstall it with: deno add @useavalon/${e}`,{cause:n})}}export async function renderIsland({src:o,condition:s=`on:client`,conditionArg:c,props:d={},children:f,ssr:p=s!==`on:client`,framework:m,ssrOnly:h=!1,renderOptions:_={},component:v,server:y,island:b,key:x}){let C=l()?performance.now():0,w=`🏝️ [${o}]`;try{if(y){let s=i(o);r(s,o);let c=m||g(o),l=a(s,d,y,b,b?e(o):void 0,o,c);return S(t(n(),null,t(`div`,{dangerouslySetInnerHTML:{__html:l},"data-server-island-wrapper":``})),x)}return h&&!p&&(p=!0),S(m?await I({src:o,condition:s,conditionArg:c,props:d,children:f,ssr:p,framework:m,ssrOnly:h,renderOptions:_,component:v}):await V({src:o,condition:s,conditionArg:c,props:d,children:f,ssr:p,ssrOnly:h,renderOptions:_,logPrefix:w,component:v}),x)}catch(e){return S(F(o,e),x)}finally{l()&&u(o,performance.now()-C)}}async function V(e){let{src:t,condition:n,conditionArg:r,props:i,children:a,ssr:c,ssrOnly:l,renderOptions:u,logPrefix:d,component:f}=e;if(s(`🔍 [renderIsland] ${t} - Starting render (slow path)`,{ssr:c,ssrOnly:l,hasChildren:!!a,condition:n}),await L(t,l,u,d))return H(t,n,i,a,c,u,d);if(!c||a)return P({src:t,condition:n,conditionArg:r,props:i,children:a,ssr:c,renderOptions:u});try{return await z(t,n,i,l,u,d,f)}catch(e){let a=await R(t);return o(`${d} Framework rendering failed:`,e),P({src:t,condition:n,conditionArg:r,props:i,ssr:!1,framework:a,renderOptions:u})}}function H(e,t,n,r,i,a,s){return i&&!r?f({src:e,condition:t,props:n,renderOptions:a}).catch(r=>(o(`${s} SSR failed for SSR-only component:`,r),P({src:e,condition:t,props:n,ssr:!1,ssrOnly:!0,renderOptions:a}))):P({src:e,condition:t,props:n,children:r,ssr:i,ssrOnly:!0,renderOptions:a})}
|
|
@@ -31,6 +31,8 @@ export interface IslandProps {
|
|
|
31
31
|
renderOptions?: AnalyzerOptions;
|
|
32
32
|
/** Server island configuration — defers rendering to a server endpoint after page load */
|
|
33
33
|
server?: ServerIslandProp;
|
|
34
|
+
/** React/Preact list key — set on the host VNode, never serialized into props */
|
|
35
|
+
key?: string | number;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* Parameters for framework-specific render functions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useavalon/avalon",
|
|
3
|
-
"version": "0.3.2-canary.
|
|
3
|
+
"version": "0.3.2-canary.13",
|
|
4
4
|
"description": "Multi-framework islands architecture for the modern web",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
},
|
|
165
165
|
"dependencies": {
|
|
166
166
|
"@mdx-js/rollup": "^3.0.0",
|
|
167
|
-
"@useavalon/core": "^0.3.2-canary.
|
|
167
|
+
"@useavalon/core": "^0.3.2-canary.13",
|
|
168
168
|
"h3": "^2.0.1-rc.16",
|
|
169
169
|
"marked": "^17.0.4",
|
|
170
170
|
"oxc-parser": "^0.120.0",
|