@pajecawav/yamf 0.0.1 → 0.0.2
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/components/Head.js.map +1 -1
- package/dist/context/ssr.js.map +1 -1
- package/dist/hooks/useEvent.js.map +1 -1
- package/dist/hooks/useHead.js.map +1 -1
- package/dist/island/client.js.map +1 -1
- package/dist/page.js.map +1 -1
- package/dist/server/entry.mjs +1 -1
- package/dist/server/entry.mjs.map +1 -1
- package/dist/server/island/server.mjs.map +1 -1
- package/dist/vite/index.mjs +3 -2
- package/dist/vite/index.mjs.map +1 -1
- package/dist/vite/islands.mjs.map +1 -1
- package/dist/vite/shared/utils.mjs.map +1 -1
- package/dist/vite/virtual-assets.mjs +0 -1
- package/dist/vite/virtual-assets.mjs.map +1 -1
- package/dist/vite/virtual-pages.mjs +0 -1
- package/dist/vite/virtual-pages.mjs.map +1 -1
- package/dist/vite/virtual-template.mjs +0 -1
- package/dist/vite/virtual-template.mjs.map +1 -1
- package/package.json +16 -19
- package/src/components/Head.tsx +1 -1
- package/src/hooks/useEvent.tsx +1 -1
- package/src/hooks/useHead.tsx +1 -1
- package/src/island/server.tsx +1 -1
- package/src/server/entry.tsx +2 -2
- package/src/vite/index.ts +6 -2
- package/src/vite/islands.ts +0 -1
- package/src/vite/virtual-assets.ts +0 -1
- package/src/vite/virtual-pages.ts +0 -1
- package/src/vite/virtual-template.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Head.js","names":[],"sources":["../../src/components/Head.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Head.js","names":[],"sources":["../../src/components/Head.tsx"],"sourcesContent":["import type { ResolvableHead } from \"unhead/types\";\nimport { useHead } from \"#/hooks/useHead\";\n\nexport type HeadProps = ResolvableHead;\n\nexport const Head = (props: HeadProps): void => {\n\tuseHead(props);\n};\n"],"mappings":";;AAKA,MAAa,QAAQ,UAA2B;CAC/C,QAAQ,MAAM"}
|
package/dist/context/ssr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr.js","names":[],"sources":["../../src/context/ssr.ts"],"sourcesContent":["import { type Context, createContext, useContext } from \"hono/jsx\";\nimport type { H3Event } from \"nitro\";\nimport type { EventHandlerRequest } from \"nitro/h3\";\nimport type { ServerUnhead } from \"unhead/server\";\n\ninterface SSRContextValue {\n\thead: ServerUnhead;\n\tevent: H3Event<EventHandlerRequest>;\n}\n\nexport const SSRContext: Context<SSRContextValue | null> = createContext<SSRContextValue | null>(\n\tnull,\n);\n\nexport const useSSRContext = (): SSRContextValue | null => {\n\treturn useContext(SSRContext);\n};\n"],"mappings":";;AAUA,MAAa,aAA8C,cAC1D,KACA;AAED,MAAa,sBAA8C;
|
|
1
|
+
{"version":3,"file":"ssr.js","names":[],"sources":["../../src/context/ssr.ts"],"sourcesContent":["import { type Context, createContext, useContext } from \"hono/jsx\";\nimport type { H3Event } from \"nitro\";\nimport type { EventHandlerRequest } from \"nitro/h3\";\nimport type { ServerUnhead } from \"unhead/server\";\n\ninterface SSRContextValue {\n\thead: ServerUnhead;\n\tevent: H3Event<EventHandlerRequest>;\n}\n\nexport const SSRContext: Context<SSRContextValue | null> = createContext<SSRContextValue | null>(\n\tnull,\n);\n\nexport const useSSRContext = (): SSRContextValue | null => {\n\treturn useContext(SSRContext);\n};\n"],"mappings":";;AAUA,MAAa,aAA8C,cAC1D,KACA;AAED,MAAa,sBAA8C;CAC1D,OAAO,WAAW,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEvent.js","names":[],"sources":["../../src/hooks/useEvent.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useEvent.js","names":[],"sources":["../../src/hooks/useEvent.tsx"],"sourcesContent":["import type { H3Event } from \"nitro\";\nimport type { EventHandlerRequest } from \"nitro/h3\";\nimport { useSSRContext } from \"#/context/ssr\";\n\nexport const useEvent = (): H3Event<EventHandlerRequest> => {\n\tconst ctx = useSSRContext();\n\n\tif (!ctx) {\n\t\tthrow new Error(\"SSR context not found\");\n\t}\n\n\treturn ctx.event;\n};\n"],"mappings":";;AAIA,MAAa,iBAA+C;CAC3D,MAAM,MAAM,eAAe;CAE3B,IAAI,CAAC,KACJ,MAAM,IAAI,MAAM,wBAAwB;CAGzC,OAAO,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHead.js","names":["useHead"],"sources":["../../src/hooks/useHead.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useHead.js","names":["useHead"],"sources":["../../src/hooks/useHead.tsx"],"sourcesContent":["import { useHead as _useHead } from \"unhead\";\nimport type { ClientUnhead } from \"unhead/client\";\nimport { createHead } from \"unhead/client\";\nimport type { ResolvableHead } from \"unhead/types\";\nimport { useSSRContext } from \"#/context/ssr\";\n\ndeclare global {\n\tinterface Window {\n\t\t__UNHEAD__?: ClientUnhead;\n\t}\n}\n\nif (!import.meta.env.SSR) {\n\twindow.__UNHEAD__ = createHead();\n}\n\nexport const useHead = (input?: ResolvableHead): void => {\n\tif (import.meta.env.SSR) {\n\t\tconst ctx = useSSRContext();\n\n\t\tif (ctx?.head) {\n\t\t\t_useHead(ctx.head, input);\n\t\t}\n\t} else if (window.__UNHEAD__) {\n\t\t_useHead(window.__UNHEAD__, input);\n\t}\n};\n"],"mappings":";;;;AAYA,IAAI,CAAC,OAAO,KAAK,IAAI,KACpB,OAAO,aAAa,YAAY;AAGjC,MAAaA,aAAW,UAAiC;CACxD,IAAI,OAAO,KAAK,IAAI,KAAK;EACxB,MAAM,MAAM,eAAe;EAE3B,IAAI,KAAK,MACR,QAAS,IAAI,MAAM,MAAM;QAEpB,IAAI,OAAO,YACjB,QAAS,OAAO,YAAY,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../../src/island/client.tsx"],"sourcesContent":["import { parse } from \"devalue\";\nimport type { FC } from \"hono/jsx\";\nimport { hydrateRoot } from \"hono/jsx/dom/client\";\nimport { withLeadingSlash } from \"ufo\";\nimport type { IslandClientDirective } from \"./types\";\n\ndeclare let __island_raw_import__: <T>(file: string) => Promise<T>;\n\nconst listeners = new WeakMap<Element, VoidFunction>();\n\nconst observer = new IntersectionObserver(entries => {\n\tfor (const entry of entries) {\n\t\tif (entry.isIntersecting) {\n\t\t\tlisteners.get(entry.target)?.();\n\t\t\tunobserve(entry.target);\n\t\t}\n\t}\n});\n\nconst observe = (target: Element, cb: VoidFunction) => {\n\tobserver.observe(target);\n\tlisteners.set(target, cb);\n};\n\nconst unobserve = (target: Element) => {\n\tobserver.unobserve(target);\n\tlisteners.delete(target);\n};\n\ncustomElements.define(\n\t\"yamf-island\",\n\tclass extends HTMLElement {\n\t\tpublic connectedCallback() {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst islandProps = parse(this.getAttribute(\"island-props\") ?? \"{}\");\n\t\t\tconst islandSrc = this.getAttribute(\"island-src\");\n\t\t\tconst islandEntry = this.getAttribute(\"island-entry\");\n\t\t\tconst islandClient = (this.getAttribute(\"island-client\") ??\n\t\t\t\t\"load\") as IslandClientDirective;\n\n\t\t\tif (!islandSrc) {\n\t\t\t\tthrow new Error(\"Missing island-src attribute\");\n\t\t\t}\n\n\t\t\tif (!islandEntry) {\n\t\t\t\tthrow new Error(\"Missing island-entry attribute\");\n\t\t\t}\n\n\t\t\tconst hydrateIsland = (mod: Record<string, FC>) => {\n\t\t\t\tconst Comp = mod[islandEntry];\n\n\t\t\t\tif (!Comp) {\n\t\t\t\t\tthrow new Error(`Missing island entry ${islandEntry} in ${islandSrc}`);\n\t\t\t\t}\n\n\t\t\t\thydrateRoot(this, <Comp {...islandProps} />);\n\t\t\t};\n\n\t\t\tconst initIsland = () => {\n\t\t\t\tconst src = withLeadingSlash(islandSrc);\n\t\t\t\tvoid __island_raw_import__<Record<string, FC>>(src).then(hydrateIsland);\n\t\t\t};\n\n\t\t\tswitch (islandClient) {\n\t\t\t\tcase \"load\":\n\t\t\t\t\tinitIsland();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"idle\":\n\t\t\t\t\trequestIdleCallback(initIsland);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"visible\":\n\t\t\t\t\t// yamf-island has `display: contents` which breaks IntersectionObserver\n\t\t\t\t\t// so we have to observe the first child instead if it exists\n\t\t\t\t\tif (this.firstElementChild) {\n\t\t\t\t\t\tobserve(this.firstElementChild, initIsland);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinitIsland();\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"skip\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n\t\t\t\t\tthrow new Error(`Invalid island-client value: ${islandClient}`);\n\t\t\t}\n\t\t}\n\n\t\tpublic disconnectedCallback() {\n\t\t\tunobserve(this);\n\t\t}\n\t},\n);\n"],"mappings":";;;;;AAQA,MAAM,4BAAY,IAAI,SAAgC;AAEtD,MAAM,WAAW,IAAI,sBAAqB,YAAW;
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../src/island/client.tsx"],"sourcesContent":["import { parse } from \"devalue\";\nimport type { FC } from \"hono/jsx\";\nimport { hydrateRoot } from \"hono/jsx/dom/client\";\nimport { withLeadingSlash } from \"ufo\";\nimport type { IslandClientDirective } from \"./types\";\n\ndeclare let __island_raw_import__: <T>(file: string) => Promise<T>;\n\nconst listeners = new WeakMap<Element, VoidFunction>();\n\nconst observer = new IntersectionObserver(entries => {\n\tfor (const entry of entries) {\n\t\tif (entry.isIntersecting) {\n\t\t\tlisteners.get(entry.target)?.();\n\t\t\tunobserve(entry.target);\n\t\t}\n\t}\n});\n\nconst observe = (target: Element, cb: VoidFunction) => {\n\tobserver.observe(target);\n\tlisteners.set(target, cb);\n};\n\nconst unobserve = (target: Element) => {\n\tobserver.unobserve(target);\n\tlisteners.delete(target);\n};\n\ncustomElements.define(\n\t\"yamf-island\",\n\tclass extends HTMLElement {\n\t\tpublic connectedCallback() {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst islandProps = parse(this.getAttribute(\"island-props\") ?? \"{}\");\n\t\t\tconst islandSrc = this.getAttribute(\"island-src\");\n\t\t\tconst islandEntry = this.getAttribute(\"island-entry\");\n\t\t\tconst islandClient = (this.getAttribute(\"island-client\") ??\n\t\t\t\t\"load\") as IslandClientDirective;\n\n\t\t\tif (!islandSrc) {\n\t\t\t\tthrow new Error(\"Missing island-src attribute\");\n\t\t\t}\n\n\t\t\tif (!islandEntry) {\n\t\t\t\tthrow new Error(\"Missing island-entry attribute\");\n\t\t\t}\n\n\t\t\tconst hydrateIsland = (mod: Record<string, FC>) => {\n\t\t\t\tconst Comp = mod[islandEntry];\n\n\t\t\t\tif (!Comp) {\n\t\t\t\t\tthrow new Error(`Missing island entry ${islandEntry} in ${islandSrc}`);\n\t\t\t\t}\n\n\t\t\t\thydrateRoot(this, <Comp {...islandProps} />);\n\t\t\t};\n\n\t\t\tconst initIsland = () => {\n\t\t\t\tconst src = withLeadingSlash(islandSrc);\n\t\t\t\tvoid __island_raw_import__<Record<string, FC>>(src).then(hydrateIsland);\n\t\t\t};\n\n\t\t\tswitch (islandClient) {\n\t\t\t\tcase \"load\":\n\t\t\t\t\tinitIsland();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"idle\":\n\t\t\t\t\trequestIdleCallback(initIsland);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"visible\":\n\t\t\t\t\t// yamf-island has `display: contents` which breaks IntersectionObserver\n\t\t\t\t\t// so we have to observe the first child instead if it exists\n\t\t\t\t\tif (this.firstElementChild) {\n\t\t\t\t\t\tobserve(this.firstElementChild, initIsland);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinitIsland();\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"skip\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n\t\t\t\t\tthrow new Error(`Invalid island-client value: ${islandClient}`);\n\t\t\t}\n\t\t}\n\n\t\tpublic disconnectedCallback() {\n\t\t\tunobserve(this);\n\t\t}\n\t},\n);\n"],"mappings":";;;;;AAQA,MAAM,4BAAY,IAAI,SAAgC;AAEtD,MAAM,WAAW,IAAI,sBAAqB,YAAW;CACpD,KAAK,MAAM,SAAS,SACnB,IAAI,MAAM,gBAAgB;EACzB,UAAU,IAAI,MAAM,OAAO,IAAI;EAC/B,UAAU,MAAM,OAAO;;EAGxB;AAEF,MAAM,WAAW,QAAiB,OAAqB;CACtD,SAAS,QAAQ,OAAO;CACxB,UAAU,IAAI,QAAQ,GAAG;;AAG1B,MAAM,aAAa,WAAoB;CACtC,SAAS,UAAU,OAAO;CAC1B,UAAU,OAAO,OAAO;;AAGzB,eAAe,OACd,eACA,cAAc,YAAY;CACzB,oBAA2B;EAE1B,MAAM,cAAc,MAAM,KAAK,aAAa,eAAe,IAAI,KAAK;EACpE,MAAM,YAAY,KAAK,aAAa,aAAa;EACjD,MAAM,cAAc,KAAK,aAAa,eAAe;EACrD,MAAM,eAAgB,KAAK,aAAa,gBAAgB,IACvD;EAED,IAAI,CAAC,WACJ,MAAM,IAAI,MAAM,+BAA+B;EAGhD,IAAI,CAAC,aACJ,MAAM,IAAI,MAAM,iCAAiC;EAGlD,MAAM,iBAAiB,QAA4B;GAClD,MAAM,OAAO,IAAI;GAEjB,IAAI,CAAC,MACJ,MAAM,IAAI,MAAM,wBAAwB,YAAY,MAAM,YAAY;GAGvE,YAAY,MAAM,oBAAC,MAAD,EAAM,GAAI,aAAe,CAAA,CAAC;;EAG7C,MAAM,mBAAmB;GACxB,MAAM,MAAM,iBAAiB,UAAU;GACvC,sBAA+C,IAAI,CAAC,KAAK,cAAc;;EAGxE,QAAQ,cAAR;GACC,KAAK;IACJ,YAAY;IACZ;GACD,KAAK;IACJ,oBAAoB,WAAW;IAC/B;GACD,KAAK;IAGJ,IAAI,KAAK,mBACR,QAAQ,KAAK,mBAAmB,WAAW;SAE3C,YAAY;IAEb;GACD,KAAK,QACJ;GACD,SAEC,MAAM,IAAI,MAAM,gCAAgC,eAAe;;;CAIlE,uBAA8B;EAC7B,UAAU,KAAK;;EAGjB"}
|
package/dist/page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","names":[],"sources":["../src/page.tsx"],"sourcesContent":["import type { Child, FC, PropsWithChildren } from \"hono/jsx\";\nimport { Fragment } from \"hono/jsx\";\nimport { renderToReadableStream } from \"hono/jsx/streaming\";\nimport { Hono } from \"hono/tiny\";\nimport type { EventHandlerRequest, EventHandlerResponse, H3Event } from \"nitro/h3\";\nimport { HTTPResponse, withServerTiming } from \"nitro/h3\";\nimport type { Unhead } from \"unhead/server\";\nimport { transformHtmlTemplate } from \"unhead/server\";\nimport { createStreamableHead, wrapStream } from \"unhead/stream/server\";\nimport type { ResolvableHead, ResolvableLink } from \"unhead/types\";\nimport { clientAssets } from \"virtual:yamf:assets\";\nimport { template } from \"virtual:yamf:template\";\nimport { SSRContext } from \"./context/ssr\";\nimport type { ImportAssetsResult } from \"./shared/assets\";\n\nexport type PageHandler = (\n\tevent: H3Event<EventHandlerRequest>,\n\tparams: {\n\t\tserverAssets?: ImportAssetsResult;\n\t\thead?: ResolvableHead;\n\t\tLayout?: FC<PropsWithChildren>;\n\t},\n) => EventHandlerResponse;\n\nexport type PageRenderer = (\n\tevent: H3Event<EventHandlerRequest>,\n\tparams: { head: Unhead },\n) => HTTPResponse | Promise<HTTPResponse> | Child | Promise<Child>;\n\ninterface DefinePageOptions {\n\trender: PageRenderer;\n\tstream?: boolean;\n\tLayout?: FC<PropsWithChildren>;\n}\n\nexport const definePage = (options: DefinePageOptions): PageHandler => {\n\treturn async (event, { serverAssets, head: headInit, Layout = options.Layout ?? Fragment }) => {\n\t\tconst assets = serverAssets ? clientAssets.merge(serverAssets) : clientAssets;\n\n\t\tconst { head } = createStreamableHead({ init: [headInit] });\n\n\t\thead.push({\n\t\t\tlink: [\n\t\t\t\t...assets.js.map((attrs): ResolvableLink => ({ rel: \"modulepreload\", ...attrs })),\n\t\t\t\t...assets.css.map((attrs): ResolvableLink => ({ rel: \"stylesheet\", ...attrs })),\n\t\t\t],\n\t\t\tscript: [{ type: \"module\", src: assets.entry }],\n\t\t});\n\n\t\tconst content = await options.render(event, { head });\n\n\t\tif (content instanceof HTTPResponse) {\n\t\t\treturn content;\n\t\t}\n\n\t\tconst App = async () => (\n\t\t\t<SSRContext value={{ head, event }}>\n\t\t\t\t<Layout>{content}</Layout>\n\t\t\t</SSRContext>\n\t\t);\n\n\t\tconst responseInit = {\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"text/html; charset=utf-8\",\n\t\t\t},\n\t\t};\n\n\t\tif (!options.stream) {\n\t\t\t// TODO: figure out how expensive this is\n\t\t\treturn new Hono()\n\t\t\t\t.get(\"/\", async c =>\n\t\t\t\t\twithServerTiming(event, \"#render\", async () => {\n\t\t\t\t\t\tconst response = await c.html(<App />);\n\n\t\t\t\t\t\tlet html = await response.text();\n\n\t\t\t\t\t\thtml = transformHtmlTemplate(\n\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\ttemplate.replace(\"<!--ssr-outlet-->\", html ?? \"\"),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn new Response(html, responseInit);\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.request(\"/\");\n\t\t}\n\n\t\tconst stream = wrapStream(head, renderToReadableStream(<App />), template);\n\n\t\treturn new Response(stream, responseInit);\n\t};\n};\n"],"mappings":";;;;;;;;;;;AAmCA,MAAa,cAAc,YAA4C;
|
|
1
|
+
{"version":3,"file":"page.js","names":[],"sources":["../src/page.tsx"],"sourcesContent":["import type { Child, FC, PropsWithChildren } from \"hono/jsx\";\nimport { Fragment } from \"hono/jsx\";\nimport { renderToReadableStream } from \"hono/jsx/streaming\";\nimport { Hono } from \"hono/tiny\";\nimport type { EventHandlerRequest, EventHandlerResponse, H3Event } from \"nitro/h3\";\nimport { HTTPResponse, withServerTiming } from \"nitro/h3\";\nimport type { Unhead } from \"unhead/server\";\nimport { transformHtmlTemplate } from \"unhead/server\";\nimport { createStreamableHead, wrapStream } from \"unhead/stream/server\";\nimport type { ResolvableHead, ResolvableLink } from \"unhead/types\";\nimport { clientAssets } from \"virtual:yamf:assets\";\nimport { template } from \"virtual:yamf:template\";\nimport { SSRContext } from \"./context/ssr\";\nimport type { ImportAssetsResult } from \"./shared/assets\";\n\nexport type PageHandler = (\n\tevent: H3Event<EventHandlerRequest>,\n\tparams: {\n\t\tserverAssets?: ImportAssetsResult;\n\t\thead?: ResolvableHead;\n\t\tLayout?: FC<PropsWithChildren>;\n\t},\n) => EventHandlerResponse;\n\nexport type PageRenderer = (\n\tevent: H3Event<EventHandlerRequest>,\n\tparams: { head: Unhead },\n) => HTTPResponse | Promise<HTTPResponse> | Child | Promise<Child>;\n\ninterface DefinePageOptions {\n\trender: PageRenderer;\n\tstream?: boolean;\n\tLayout?: FC<PropsWithChildren>;\n}\n\nexport const definePage = (options: DefinePageOptions): PageHandler => {\n\treturn async (event, { serverAssets, head: headInit, Layout = options.Layout ?? Fragment }) => {\n\t\tconst assets = serverAssets ? clientAssets.merge(serverAssets) : clientAssets;\n\n\t\tconst { head } = createStreamableHead({ init: [headInit] });\n\n\t\thead.push({\n\t\t\tlink: [\n\t\t\t\t...assets.js.map((attrs): ResolvableLink => ({ rel: \"modulepreload\", ...attrs })),\n\t\t\t\t...assets.css.map((attrs): ResolvableLink => ({ rel: \"stylesheet\", ...attrs })),\n\t\t\t],\n\t\t\tscript: [{ type: \"module\", src: assets.entry }],\n\t\t});\n\n\t\tconst content = await options.render(event, { head });\n\n\t\tif (content instanceof HTTPResponse) {\n\t\t\treturn content;\n\t\t}\n\n\t\tconst App = async () => (\n\t\t\t<SSRContext value={{ head, event }}>\n\t\t\t\t<Layout>{content}</Layout>\n\t\t\t</SSRContext>\n\t\t);\n\n\t\tconst responseInit = {\n\t\t\theaders: {\n\t\t\t\t\"Content-Type\": \"text/html; charset=utf-8\",\n\t\t\t},\n\t\t};\n\n\t\tif (!options.stream) {\n\t\t\t// TODO: figure out how expensive this is\n\t\t\treturn new Hono()\n\t\t\t\t.get(\"/\", async c =>\n\t\t\t\t\twithServerTiming(event, \"#render\", async () => {\n\t\t\t\t\t\tconst response = await c.html(<App />);\n\n\t\t\t\t\t\tlet html = await response.text();\n\n\t\t\t\t\t\thtml = transformHtmlTemplate(\n\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\ttemplate.replace(\"<!--ssr-outlet-->\", html ?? \"\"),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn new Response(html, responseInit);\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.request(\"/\");\n\t\t}\n\n\t\tconst stream = wrapStream(head, renderToReadableStream(<App />), template);\n\n\t\treturn new Response(stream, responseInit);\n\t};\n};\n"],"mappings":";;;;;;;;;;;AAmCA,MAAa,cAAc,YAA4C;CACtE,OAAO,OAAO,OAAO,EAAE,cAAc,MAAM,UAAU,SAAS,QAAQ,UAAU,eAAe;EAC9F,MAAM,SAAS,eAAe,aAAa,MAAM,aAAa,GAAG;EAEjE,MAAM,EAAE,SAAS,qBAAqB,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;EAE3D,KAAK,KAAK;GACT,MAAM,CACL,GAAG,OAAO,GAAG,KAAK,WAA2B;IAAE,KAAK;IAAiB,GAAG;IAAO,EAAE,EACjF,GAAG,OAAO,IAAI,KAAK,WAA2B;IAAE,KAAK;IAAc,GAAG;IAAO,EAAE,CAC/E;GACD,QAAQ,CAAC;IAAE,MAAM;IAAU,KAAK,OAAO;IAAO,CAAC;GAC/C,CAAC;EAEF,MAAM,UAAU,MAAM,QAAQ,OAAO,OAAO,EAAE,MAAM,CAAC;EAErD,IAAI,mBAAmB,cACtB,OAAO;EAGR,MAAM,MAAM,YACX,oBAAC,YAAD;GAAY,OAAO;IAAE;IAAM;IAAO;aACjC,oBAAC,QAAD,EAAA,UAAS,SAAiB,CAAA;GACd,CAAA;EAGd,MAAM,eAAe,EACpB,SAAS,EACR,gBAAgB,4BAChB,EACD;EAED,IAAI,CAAC,QAAQ,QAEZ,OAAO,IAAI,MAAM,CACf,IAAI,KAAK,OAAM,MACf,iBAAiB,OAAO,WAAW,YAAY;GAG9C,IAAI,OAAO,OAAM,MAFM,EAAE,KAAK,oBAAC,KAAD,EAAO,CAAA,CAAC,EAEZ,MAAM;GAEhC,OAAO,sBACN,MACA,SAAS,QAAQ,qBAAqB,QAAQ,GAAG,CACjD;GAED,OAAO,IAAI,SAAS,MAAM,aAAa;IACtC,CACF,CACA,QAAQ,IAAI;EAGf,MAAM,SAAS,WAAW,MAAM,uBAAuB,oBAAC,KAAD,EAAO,CAAA,CAAC,EAAE,SAAS;EAE1E,OAAO,IAAI,SAAS,QAAQ,aAAa"}
|
package/dist/server/entry.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HTTPError, defineHandler, writeEarlyHints } from "nitro/h3";
|
|
2
1
|
import path from "node:path";
|
|
2
|
+
import { HTTPError, defineHandler, writeEarlyHints } from "nitro/h3";
|
|
3
3
|
import { addRoute, createRouter, findRoute } from "rou3";
|
|
4
4
|
import { withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
5
5
|
import { clientAssets } from "virtual:yamf:assets";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.mjs","names":["serverAssets"],"sources":["../../src/server/entry.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"entry.mjs","names":["serverAssets"],"sources":["../../src/server/entry.tsx"],"sourcesContent":["import path from \"node:path\";\nimport type { FC, PropsWithChildren } from \"hono/jsx\";\nimport type { EventHandlerRequest, EventHandlerWithFetch, H3Event } from \"nitro/h3\";\nimport { defineHandler, HTTPError, writeEarlyHints } from \"nitro/h3\";\nimport { addRoute, createRouter, findRoute } from \"rou3\";\nimport { withLeadingSlash, withoutTrailingSlash } from \"ufo\";\nimport type { ResolvableHead } from \"unhead/types\";\nimport { clientAssets } from \"virtual:yamf:assets\";\nimport { pages, assets as serverAssets } from \"virtual:yamf:pages\";\nimport type { PageHandler } from \"#/page\";\n\ninterface Route {\n\thandler: () => Promise<PageHandler>;\n\tserverAssets?: ImportAssetsResult;\n}\n\nconst router = createRouter<Route>();\n\nfor (const [relativePath, handler] of Object.entries(pages).toSorted((a, b) =>\n\ta[0].localeCompare(b[0]),\n)) {\n\tconst ext = path.extname(relativePath);\n\n\tlet route = path.relative(\"/src/pages\", relativePath);\n\n\tif (ext.length) {\n\t\troute = route.slice(0, -ext.length);\n\t}\n\n\troute =\n\t\troute\n\t\t\t.replace(/\\.[A-Za-z]+$/, \"\")\n\t\t\t.replace(/\\(([^(/\\\\]+)\\)[/\\\\]/g, \"\")\n\t\t\t.replace(/\\[\\.{3}]/g, \"**\")\n\t\t\t.replace(/\\[\\.{3}([^\\]]+)]/g, (_, p: string) => \"**:\" + p.replace(/[^\\w-]/g, \"_\"))\n\t\t\t.replace(/\\[([^/\\]]+)]/g, (_, p: string) => \":\" + p.replace(/[^\\w-]/g, \"_\"))\n\t\t\t.replace(/(\\/|^)index$/, \"\") || \"/\";\n\n\troute = withLeadingSlash(withoutTrailingSlash(route));\n\n\taddRoute(router, \"GET\", route, {\n\t\thandler,\n\t\tserverAssets: serverAssets[relativePath],\n\t});\n}\n\nexport type ServerEntry = EventHandlerWithFetch<EventHandlerRequest, Promise<unknown>>;\n\nexport interface DefineServerEntryOptions {\n\thead?: ResolvableHead | ((event: H3Event<EventHandlerRequest>) => ResolvableHead);\n\tLayout?: FC<PropsWithChildren>;\n}\n\nexport const defineServerEntry = (options?: DefineServerEntryOptions): ServerEntry => {\n\treturn defineHandler(async event => {\n\t\tconst route = findRoute(router, \"GET\", event.url.pathname);\n\n\t\tif (!route) {\n\t\t\tthrow new HTTPError(\"Not found\", { status: 404 });\n\t\t}\n\n\t\tconst { handler, serverAssets } = route.data;\n\t\tevent.context.params = route.params;\n\n\t\tconst assets = serverAssets ? serverAssets.merge(clientAssets) : clientAssets;\n\n\t\tawait writeEarlyHints(event, {\n\t\t\tlink: [\n\t\t\t\t...assets.js.map(script => `<${script.href}>; rel=modulepreload`),\n\t\t\t\t...assets.css.map(style => `<${style.href}>; rel=preload; as=style`),\n\t\t\t],\n\t\t});\n\n\t\treturn (await handler())(event, {\n\t\t\tserverAssets,\n\t\t\thead: typeof options?.head === \"function\" ? options.head(event) : options?.head,\n\t\t\tLayout: options?.Layout,\n\t\t});\n\t});\n};\n"],"mappings":";;;;;;;AAgBA,MAAM,SAAS,cAAqB;AAEpC,KAAK,MAAM,CAAC,cAAc,YAAY,OAAO,QAAQ,MAAM,CAAC,UAAU,GAAG,MACxE,EAAE,GAAG,cAAc,EAAE,GAAG,CACxB,EAAE;CACF,MAAM,MAAM,KAAK,QAAQ,aAAa;CAEtC,IAAI,QAAQ,KAAK,SAAS,cAAc,aAAa;CAErD,IAAI,IAAI,QACP,QAAQ,MAAM,MAAM,GAAG,CAAC,IAAI,OAAO;CAGpC,QACC,MACE,QAAQ,gBAAgB,GAAG,CAC3B,QAAQ,wBAAwB,GAAG,CACnC,QAAQ,aAAa,KAAK,CAC1B,QAAQ,sBAAsB,GAAG,MAAc,QAAQ,EAAE,QAAQ,WAAW,IAAI,CAAC,CACjF,QAAQ,kBAAkB,GAAG,MAAc,MAAM,EAAE,QAAQ,WAAW,IAAI,CAAC,CAC3E,QAAQ,gBAAgB,GAAG,IAAI;CAElC,QAAQ,iBAAiB,qBAAqB,MAAM,CAAC;CAErD,SAAS,QAAQ,OAAO,OAAO;EAC9B;EACA,cAAcA,OAAa;EAC3B,CAAC;;AAUH,MAAa,qBAAqB,YAAoD;CACrF,OAAO,cAAc,OAAM,UAAS;EACnC,MAAM,QAAQ,UAAU,QAAQ,OAAO,MAAM,IAAI,SAAS;EAE1D,IAAI,CAAC,OACJ,MAAM,IAAI,UAAU,aAAa,EAAE,QAAQ,KAAK,CAAC;EAGlD,MAAM,EAAE,SAAS,iBAAiB,MAAM;EACxC,MAAM,QAAQ,SAAS,MAAM;EAE7B,MAAM,SAAS,eAAe,aAAa,MAAM,aAAa,GAAG;EAEjE,MAAM,gBAAgB,OAAO,EAC5B,MAAM,CACL,GAAG,OAAO,GAAG,KAAI,WAAU,IAAI,OAAO,KAAK,sBAAsB,EACjE,GAAG,OAAO,IAAI,KAAI,UAAS,IAAI,MAAM,KAAK,0BAA0B,CACpE,EACD,CAAC;EAEF,QAAQ,MAAM,SAAS,EAAE,OAAO;GAC/B;GACA,MAAM,OAAO,SAAS,SAAS,aAAa,QAAQ,KAAK,MAAM,GAAG,SAAS;GAC3E,QAAQ,SAAS;GACjB,CAAC;GACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":[],"sources":["../../../src/island/server.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"server.mjs","names":[],"sources":["../../../src/island/server.tsx"],"sourcesContent":["import { stringify } from \"devalue\";\nimport type { Child, FC } from \"hono/jsx\";\nimport type { ImportAssetsResultRaw } from \"#/shared/assets\";\nimport type { IslandClientDirective } from \"./types\";\n\ndeclare module \"hono/jsx\" {\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\tnamespace JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"yamf-island\": {\n\t\t\t\t\"island-props\"?: string;\n\t\t\t\t\"island-src\": string;\n\t\t\t\t\"island-entry\": string;\n\t\t\t\t\"island-client\": IslandClientDirective;\n\t\t\t\tchildren: Child;\n\t\t\t\tstyle?: JSX.CSSProperties;\n\t\t\t};\n\t\t}\n\t}\n}\n\nexport const createIsland = (\n\tComponent: FC,\n\texportName: string,\n\tassets: ImportAssetsResultRaw,\n): FC => {\n\tconst ComponentWrapper: FC & { name: string } = props => {\n\t\tif (!assets.entry) {\n\t\t\tthrow new Error(`Missing island entry for island ${Component.name}`);\n\t\t}\n\n\t\treturn (\n\t\t\t<yamf-island\n\t\t\t\tisland-props={stringify(props)}\n\t\t\t\tisland-src={assets.entry}\n\t\t\t\tisland-entry={exportName}\n\t\t\t\tisland-client={props[\"yamf-client\"] as IslandClientDirective}\n\t\t\t\t// TODO: export CSS?\n\t\t\t\tstyle={{ display: \"contents\" }}\n\t\t\t>\n\t\t\t\t<Component {...props} />\n\t\t\t</yamf-island>\n\t\t);\n\t};\n\n\tObject.defineProperty(ComponentWrapper, \"name\", {\n\t\tvalue: Component.name,\n\t});\n\n\treturn ComponentWrapper;\n};\n"],"mappings":";;;AAqBA,MAAa,gBACZ,WACA,YACA,WACQ;CACR,MAAM,oBAA0C,UAAS;EACxD,IAAI,CAAC,OAAO,OACX,MAAM,IAAI,MAAM,mCAAmC,UAAU,OAAO;EAGrE,OACC,oBAAC,eAAD;GACC,gBAAc,UAAU,MAAM;GAC9B,cAAY,OAAO;GACnB,gBAAc;GACd,iBAAe,MAAM;GAErB,OAAO,EAAE,SAAS,YAAY;aAE9B,oBAAC,WAAD,EAAW,GAAI,OAAS,CAAA;GACX,CAAA;;CAIhB,OAAO,eAAe,kBAAkB,QAAQ,EAC/C,OAAO,UAAU,MACjB,CAAC;CAEF,OAAO"}
|
package/dist/vite/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { islands } from "./islands.mjs";
|
|
|
2
2
|
import { virtualAssets } from "./virtual-assets.mjs";
|
|
3
3
|
import { virtualPages } from "./virtual-pages.mjs";
|
|
4
4
|
import { virtualTemplate } from "./virtual-template.mjs";
|
|
5
|
-
import { nitro } from "nitro/vite";
|
|
6
5
|
import { existsSync } from "node:fs";
|
|
6
|
+
import { nitro } from "nitro/vite";
|
|
7
7
|
//#region src/vite/index.ts
|
|
8
8
|
const yamf = (options) => {
|
|
9
9
|
const plugins = [];
|
|
@@ -11,6 +11,7 @@ const yamf = (options) => {
|
|
|
11
11
|
name: "yamf:config",
|
|
12
12
|
config() {
|
|
13
13
|
return {
|
|
14
|
+
ssr: { noExternal: ["@pajecawav/yamf"] },
|
|
14
15
|
optimizeDeps: { include: [
|
|
15
16
|
"hono",
|
|
16
17
|
"hono/jsx/dom/client",
|
|
@@ -21,7 +22,7 @@ const yamf = (options) => {
|
|
|
21
22
|
environments: {
|
|
22
23
|
...existsSync("./src/server.tsx") ? { ssr: { build: {
|
|
23
24
|
cssCodeSplit: false,
|
|
24
|
-
|
|
25
|
+
rolldownOptions: { input: "./src/server.tsx" }
|
|
25
26
|
} } } : {},
|
|
26
27
|
client: { build: { rolldownOptions: { input: "./src/client/index.ts" } } }
|
|
27
28
|
}
|
package/dist/vite/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/vite/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/vite/index.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport type { NitroPluginConfig } from \"nitro/vite\";\nimport { nitro } from \"nitro/vite\";\nimport type { EnvironmentOptions, PluginOption } from \"vite\";\nimport { islands } from \"./islands\";\nimport { virtualAssets } from \"./virtual-assets\";\nimport { virtualPages } from \"./virtual-pages\";\nimport { virtualTemplate } from \"./virtual-template\";\n\nexport interface YamfOptions {\n\tnitro?: NitroPluginConfig;\n}\n\nconst yamf = (options?: YamfOptions): PluginOption[] => {\n\tconst plugins: PluginOption[] = [];\n\n\t// TODO: extendable config\n\tplugins.push({\n\t\tname: \"yamf:config\",\n\t\tconfig() {\n\t\t\tconst ssrEnv: EnvironmentOptions = {\n\t\t\t\tbuild: {\n\t\t\t\t\t// TODO: figure out if this should be true\n\t\t\t\t\tcssCodeSplit: false,\n\t\t\t\t\trolldownOptions: {\n\t\t\t\t\t\tinput: \"./src/server.tsx\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tssr: {\n\t\t\t\t\t// we need to inline because otherwise fullstack plugin fails to build manifest for assets imports\n\t\t\t\t\tnoExternal: [\"@pajecawav/yamf\"],\n\t\t\t\t},\n\t\t\t\toptimizeDeps: {\n\t\t\t\t\tinclude: [\n\t\t\t\t\t\t\"hono\",\n\t\t\t\t\t\t\"hono/jsx/dom/client\",\n\t\t\t\t\t\t\"hono/jsx/jsx-runtime\",\n\t\t\t\t\t\t\"devalue\",\n\t\t\t\t\t\t\"ufo\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tenvironments: {\n\t\t\t\t\t...(existsSync(\"./src/server.tsx\") ? { ssr: ssrEnv } : {}),\n\t\t\t\t\tclient: {\n\t\t\t\t\t\tbuild: {\n\t\t\t\t\t\t\trolldownOptions: {\n\t\t\t\t\t\t\t\tinput: \"./src/client/index.ts\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t});\n\n\tplugins.push(islands());\n\n\tplugins.push(virtualAssets());\n\tplugins.push(virtualPages());\n\tplugins.push(virtualTemplate());\n\n\tplugins.push(\n\t\tnitro({\n\t\t\tserverDir: \"./src\",\n\t\t\trenderer: false,\n\t\t\t...options?.nitro,\n\t\t\tcompressPublicAssets: {\n\t\t\t\tgzip: true,\n\t\t\t\tbrotli: true,\n\t\t\t},\n\t\t\tpublicAssets: [\n\t\t\t\t{\n\t\t\t\t\tbaseURL: \"assets\",\n\t\t\t\t\tdir: \"./public/assets\",\n\t\t\t\t\tmaxAge: 365 * 24 * 60 * 60,\n\t\t\t\t},\n\t\t\t],\n\t\t}),\n\t);\n\n\treturn plugins;\n};\n\nexport default yamf;\n"],"mappings":";;;;;;;AAaA,MAAM,QAAQ,YAA0C;CACvD,MAAM,UAA0B,EAAE;CAGlC,QAAQ,KAAK;EACZ,MAAM;EACN,SAAS;GAWR,OAAO;IACN,KAAK,EAEJ,YAAY,CAAC,kBAAkB,EAC/B;IACD,cAAc,EACb,SAAS;KACR;KACA;KACA;KACA;KACA;KACA,EACD;IACD,cAAc;KACb,GAAI,WAAW,mBAAmB,GAAG,EAAE,KAAK,EAxB7C,OAAO;MAEN,cAAc;MACd,iBAAiB,EAChB,OAAO,oBACP;MACD,EAkBkD,EAAE,GAAG,EAAE;KACzD,QAAQ,EACP,OAAO,EACN,iBAAiB,EAChB,OAAO,yBACP,EACD,EACD;KACD;IACD;;EAEF,CAAC;CAEF,QAAQ,KAAK,SAAS,CAAC;CAEvB,QAAQ,KAAK,eAAe,CAAC;CAC7B,QAAQ,KAAK,cAAc,CAAC;CAC5B,QAAQ,KAAK,iBAAiB,CAAC;CAE/B,QAAQ,KACP,MAAM;EACL,WAAW;EACX,UAAU;EACV,GAAG,SAAS;EACZ,sBAAsB;GACrB,MAAM;GACN,QAAQ;GACR;EACD,cAAc,CACb;GACC,SAAS;GACT,KAAK;GACL,QAAQ,MAAM,KAAK,KAAK;GACxB,CACD;EACD,CAAC,CACF;CAED,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"islands.mjs","names":[],"sources":["../../src/vite/islands.ts"],"sourcesContent":["// reference https://github.com/hi-ogawa/vite-plugin-fullstack/blob/28e9540a68529c58842e9a3bf17d2193a065d524/examples/island/src/framework/island/plugin.ts\nimport { generate } from \"@babel/generator\";\nimport { parse } from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport {\n\tcallExpression,\n\texportDefaultDeclaration,\n\texportNamedDeclaration,\n\tfunctionDeclaration,\n\tfunctionExpression,\n\tidentifier,\n\timportDeclaration,\n\timportDefaultSpecifier,\n\timportNamespaceSpecifier,\n\tmemberExpression,\n\tstringLiteral,\n\tvariableDeclaration,\n\tvariableDeclarator,\n} from \"@babel/types\";\nimport type { Plugin } from \"vite\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nconst traverse = (_traverse.default as typeof _traverse) ?? _traverse;\n\nconst ISLAND_REGEX = /\\.island\\.(j|t)sx?$/;\n\nexport const islands = (): Plugin[] => {\n\treturn [\n\t\t{\n\t\t\tname: \"yamf:islands\",\n\t\t\t// enforce: \"pre\",\n\t\t\ttransform: {\n\t\t\t\tfilter: { id: ISLAND_REGEX },\n\t\t\t\thandler(code, id) {\n\t\t\t\t\tif (this.environment.name !== \"ssr\") {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst seenExports = new Set<string>();\n\n\t\t\t\t\tconst ast = parse(code, {\n\t\t\t\t\t\tsourceType: \"module\",\n\t\t\t\t\t\tplugins: [\"typescript\", \"jsx\"],\n\t\t\t\t\t});\n\n\t\t\t\t\ttraverse(ast, {\n\t\t\t\t\t\tProgram(path) {\n\t\t\t\t\t\t\t// prepends server island runtime\n\t\t\t\t\t\t\t// import * as __runtime from \"yamf/server\";\n\t\t\t\t\t\t\tpath.unshiftContainer(\n\t\t\t\t\t\t\t\t\"body\",\n\t\t\t\t\t\t\t\timportDeclaration(\n\t\t\t\t\t\t\t\t\t[importNamespaceSpecifier(identifier(\"__runtime\"))],\n\t\t\t\t\t\t\t\t\tstringLiteral(\"@pajecawav/yamf/server\"),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// prepends asset imports for the island:\n\t\t\t\t\t\t\t// import __assets from \"MODULE_ID?assets=client\";\n\t\t\t\t\t\t\tpath.unshiftContainer(\n\t\t\t\t\t\t\t\t\"body\",\n\t\t\t\t\t\t\t\timportDeclaration(\n\t\t\t\t\t\t\t\t\t[importDefaultSpecifier(identifier(\"__assets\"))],\n\t\t\t\t\t\t\t\t\tstringLiteral(`${id}?assets=client`),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tExportDefaultDeclaration(path) {\n\t\t\t\t\t\t\tconst declarationType = path.node.declaration.type;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\t\tdeclarationType === \"FunctionDeclaration\" ||\n\t\t\t\t\t\t\t\t\tdeclarationType === \"FunctionExpression\" ||\n\t\t\t\t\t\t\t\t\tdeclarationType === \"ArrowFunctionExpression\"\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst originalFunction =\n\t\t\t\t\t\t\t\tpath.node.declaration.type === \"FunctionExpression\" ||\n\t\t\t\t\t\t\t\tpath.node.declaration.type === \"ArrowFunctionExpression\"\n\t\t\t\t\t\t\t\t\t? path.node.declaration\n\t\t\t\t\t\t\t\t\t: functionExpression(\n\t\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\t\tpath.node.declaration.params,\n\t\t\t\t\t\t\t\t\t\t\tpath.node.declaration.body,\n\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\tpath.node.declaration.async,\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst islandIdentifier = identifier(\"__ISLAND__\");\n\n\t\t\t\t\t\t\tpath.insertBefore(\n\t\t\t\t\t\t\t\tvariableDeclaration(\"const\", [\n\t\t\t\t\t\t\t\t\tvariableDeclarator(islandIdentifier, originalFunction),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tpath.replaceWith(\n\t\t\t\t\t\t\t\texportDefaultDeclaration(\n\t\t\t\t\t\t\t\t\tcallExpression(\n\t\t\t\t\t\t\t\t\t\tmemberExpression(\n\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__runtime\"),\n\t\t\t\t\t\t\t\t\t\t\tidentifier(\"createIsland\"),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\tislandIdentifier,\n\t\t\t\t\t\t\t\t\t\t\tstringLiteral(\"default\"),\n\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__assets\"),\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tExportNamedDeclaration(path) {\n\t\t\t\t\t\t\tif (path.node.declaration?.type === \"VariableDeclaration\") {\n\t\t\t\t\t\t\t\tconst declaration = path.node.declaration.declarations.at(0);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!declaration ||\n\t\t\t\t\t\t\t\t\tdeclaration.id.type !== \"Identifier\" ||\n\t\t\t\t\t\t\t\t\tseenExports.has(declaration.id.name)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst exportName = declaration.id.name;\n\t\t\t\t\t\t\t\tseenExports.add(exportName);\n\n\t\t\t\t\t\t\t\tconst islandIdentifier = identifier(`__wrap_${exportName}`);\n\n\t\t\t\t\t\t\t\tpath.insertBefore(\n\t\t\t\t\t\t\t\t\tvariableDeclaration(\"const\", [\n\t\t\t\t\t\t\t\t\t\tvariableDeclarator(islandIdentifier, declaration.init),\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tpath.replaceWith(\n\t\t\t\t\t\t\t\t\texportNamedDeclaration(\n\t\t\t\t\t\t\t\t\t\tvariableDeclaration(\"const\", [\n\t\t\t\t\t\t\t\t\t\t\tvariableDeclarator(\n\t\t\t\t\t\t\t\t\t\t\t\tidentifier(exportName),\n\t\t\t\t\t\t\t\t\t\t\t\tcallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmemberExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__runtime\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"createIsland\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tislandIdentifier,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstringLiteral(exportName),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__assets\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else if (path.node.declaration?.type === \"FunctionDeclaration\") {\n\t\t\t\t\t\t\t\tconst declaration = path.node.declaration;\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!declaration ||\n\t\t\t\t\t\t\t\t\tdeclaration.id?.type !== \"Identifier\" ||\n\t\t\t\t\t\t\t\t\tseenExports.has(declaration.id.name)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst exportName = declaration.id.name;\n\t\t\t\t\t\t\t\tseenExports.add(exportName);\n\n\t\t\t\t\t\t\t\tconst islandIdentifier = identifier(`__wrap_${exportName}`);\n\n\t\t\t\t\t\t\t\tpath.insertBefore(\n\t\t\t\t\t\t\t\t\tfunctionDeclaration(\n\t\t\t\t\t\t\t\t\t\tislandIdentifier,\n\t\t\t\t\t\t\t\t\t\tdeclaration.params,\n\t\t\t\t\t\t\t\t\t\tdeclaration.body,\n\t\t\t\t\t\t\t\t\t\tdeclaration.generator,\n\t\t\t\t\t\t\t\t\t\tdeclaration.async,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tpath.replaceWith(\n\t\t\t\t\t\t\t\t\texportNamedDeclaration(\n\t\t\t\t\t\t\t\t\t\tvariableDeclaration(\"const\", [\n\t\t\t\t\t\t\t\t\t\t\tvariableDeclarator(\n\t\t\t\t\t\t\t\t\t\t\t\tidentifier(exportName),\n\t\t\t\t\t\t\t\t\t\t\t\tcallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmemberExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__runtime\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"createIsland\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tislandIdentifier,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstringLiteral(exportName),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__assets\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tconst result = generate(ast);\n\n\t\t\t\t\treturn { code: result.code, map: result.map };\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"yamf:islands:raw-import\",\n\t\t\ttransform: {\n\t\t\t\torder: \"post\",\n\t\t\t\thandler(code) {\n\t\t\t\t\tif (code.includes(\"__island_raw_import__\")) {\n\t\t\t\t\t\treturn code.replaceAll(\"__island_raw_import__\", \"import\");\n\t\t\t\t\t}\n\n\t\t\t\t\treturn undefined;\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t];\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"islands.mjs","names":[],"sources":["../../src/vite/islands.ts"],"sourcesContent":["// reference https://github.com/hi-ogawa/vite-plugin-fullstack/blob/28e9540a68529c58842e9a3bf17d2193a065d524/examples/island/src/framework/island/plugin.ts\nimport { generate } from \"@babel/generator\";\nimport { parse } from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport {\n\tcallExpression,\n\texportDefaultDeclaration,\n\texportNamedDeclaration,\n\tfunctionDeclaration,\n\tfunctionExpression,\n\tidentifier,\n\timportDeclaration,\n\timportDefaultSpecifier,\n\timportNamespaceSpecifier,\n\tmemberExpression,\n\tstringLiteral,\n\tvariableDeclaration,\n\tvariableDeclarator,\n} from \"@babel/types\";\nimport type { Plugin } from \"vite\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nconst traverse = (_traverse.default as typeof _traverse) ?? _traverse;\n\nconst ISLAND_REGEX = /\\.island\\.(j|t)sx?$/;\n\nexport const islands = (): Plugin[] => {\n\treturn [\n\t\t{\n\t\t\tname: \"yamf:islands\",\n\t\t\ttransform: {\n\t\t\t\tfilter: { id: ISLAND_REGEX },\n\t\t\t\thandler(code, id) {\n\t\t\t\t\tif (this.environment.name !== \"ssr\") {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst seenExports = new Set<string>();\n\n\t\t\t\t\tconst ast = parse(code, {\n\t\t\t\t\t\tsourceType: \"module\",\n\t\t\t\t\t\tplugins: [\"typescript\", \"jsx\"],\n\t\t\t\t\t});\n\n\t\t\t\t\ttraverse(ast, {\n\t\t\t\t\t\tProgram(path) {\n\t\t\t\t\t\t\t// prepends server island runtime\n\t\t\t\t\t\t\t// import * as __runtime from \"yamf/server\";\n\t\t\t\t\t\t\tpath.unshiftContainer(\n\t\t\t\t\t\t\t\t\"body\",\n\t\t\t\t\t\t\t\timportDeclaration(\n\t\t\t\t\t\t\t\t\t[importNamespaceSpecifier(identifier(\"__runtime\"))],\n\t\t\t\t\t\t\t\t\tstringLiteral(\"@pajecawav/yamf/server\"),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// prepends asset imports for the island:\n\t\t\t\t\t\t\t// import __assets from \"MODULE_ID?assets=client\";\n\t\t\t\t\t\t\tpath.unshiftContainer(\n\t\t\t\t\t\t\t\t\"body\",\n\t\t\t\t\t\t\t\timportDeclaration(\n\t\t\t\t\t\t\t\t\t[importDefaultSpecifier(identifier(\"__assets\"))],\n\t\t\t\t\t\t\t\t\tstringLiteral(`${id}?assets=client`),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tExportDefaultDeclaration(path) {\n\t\t\t\t\t\t\tconst declarationType = path.node.declaration.type;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t\t\tdeclarationType === \"FunctionDeclaration\" ||\n\t\t\t\t\t\t\t\t\tdeclarationType === \"FunctionExpression\" ||\n\t\t\t\t\t\t\t\t\tdeclarationType === \"ArrowFunctionExpression\"\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst originalFunction =\n\t\t\t\t\t\t\t\tpath.node.declaration.type === \"FunctionExpression\" ||\n\t\t\t\t\t\t\t\tpath.node.declaration.type === \"ArrowFunctionExpression\"\n\t\t\t\t\t\t\t\t\t? path.node.declaration\n\t\t\t\t\t\t\t\t\t: functionExpression(\n\t\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\t\tpath.node.declaration.params,\n\t\t\t\t\t\t\t\t\t\t\tpath.node.declaration.body,\n\t\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\t\tpath.node.declaration.async,\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst islandIdentifier = identifier(\"__ISLAND__\");\n\n\t\t\t\t\t\t\tpath.insertBefore(\n\t\t\t\t\t\t\t\tvariableDeclaration(\"const\", [\n\t\t\t\t\t\t\t\t\tvariableDeclarator(islandIdentifier, originalFunction),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tpath.replaceWith(\n\t\t\t\t\t\t\t\texportDefaultDeclaration(\n\t\t\t\t\t\t\t\t\tcallExpression(\n\t\t\t\t\t\t\t\t\t\tmemberExpression(\n\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__runtime\"),\n\t\t\t\t\t\t\t\t\t\t\tidentifier(\"createIsland\"),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\tislandIdentifier,\n\t\t\t\t\t\t\t\t\t\t\tstringLiteral(\"default\"),\n\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__assets\"),\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tExportNamedDeclaration(path) {\n\t\t\t\t\t\t\tif (path.node.declaration?.type === \"VariableDeclaration\") {\n\t\t\t\t\t\t\t\tconst declaration = path.node.declaration.declarations.at(0);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!declaration ||\n\t\t\t\t\t\t\t\t\tdeclaration.id.type !== \"Identifier\" ||\n\t\t\t\t\t\t\t\t\tseenExports.has(declaration.id.name)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst exportName = declaration.id.name;\n\t\t\t\t\t\t\t\tseenExports.add(exportName);\n\n\t\t\t\t\t\t\t\tconst islandIdentifier = identifier(`__wrap_${exportName}`);\n\n\t\t\t\t\t\t\t\tpath.insertBefore(\n\t\t\t\t\t\t\t\t\tvariableDeclaration(\"const\", [\n\t\t\t\t\t\t\t\t\t\tvariableDeclarator(islandIdentifier, declaration.init),\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tpath.replaceWith(\n\t\t\t\t\t\t\t\t\texportNamedDeclaration(\n\t\t\t\t\t\t\t\t\t\tvariableDeclaration(\"const\", [\n\t\t\t\t\t\t\t\t\t\t\tvariableDeclarator(\n\t\t\t\t\t\t\t\t\t\t\t\tidentifier(exportName),\n\t\t\t\t\t\t\t\t\t\t\t\tcallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmemberExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__runtime\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"createIsland\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tislandIdentifier,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstringLiteral(exportName),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__assets\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else if (path.node.declaration?.type === \"FunctionDeclaration\") {\n\t\t\t\t\t\t\t\tconst declaration = path.node.declaration;\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!declaration ||\n\t\t\t\t\t\t\t\t\tdeclaration.id?.type !== \"Identifier\" ||\n\t\t\t\t\t\t\t\t\tseenExports.has(declaration.id.name)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst exportName = declaration.id.name;\n\t\t\t\t\t\t\t\tseenExports.add(exportName);\n\n\t\t\t\t\t\t\t\tconst islandIdentifier = identifier(`__wrap_${exportName}`);\n\n\t\t\t\t\t\t\t\tpath.insertBefore(\n\t\t\t\t\t\t\t\t\tfunctionDeclaration(\n\t\t\t\t\t\t\t\t\t\tislandIdentifier,\n\t\t\t\t\t\t\t\t\t\tdeclaration.params,\n\t\t\t\t\t\t\t\t\t\tdeclaration.body,\n\t\t\t\t\t\t\t\t\t\tdeclaration.generator,\n\t\t\t\t\t\t\t\t\t\tdeclaration.async,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tpath.replaceWith(\n\t\t\t\t\t\t\t\t\texportNamedDeclaration(\n\t\t\t\t\t\t\t\t\t\tvariableDeclaration(\"const\", [\n\t\t\t\t\t\t\t\t\t\t\tvariableDeclarator(\n\t\t\t\t\t\t\t\t\t\t\t\tidentifier(exportName),\n\t\t\t\t\t\t\t\t\t\t\t\tcallExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\tmemberExpression(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__runtime\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"createIsland\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tislandIdentifier,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstringLiteral(exportName),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tidentifier(\"__assets\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tconst result = generate(ast);\n\n\t\t\t\t\treturn { code: result.code, map: result.map };\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"yamf:islands:raw-import\",\n\t\t\ttransform: {\n\t\t\t\torder: \"post\",\n\t\t\t\thandler(code) {\n\t\t\t\t\tif (code.includes(\"__island_raw_import__\")) {\n\t\t\t\t\t\treturn code.replaceAll(\"__island_raw_import__\", \"import\");\n\t\t\t\t\t}\n\n\t\t\t\t\treturn undefined;\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t];\n};\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/shared/utils.ts"],"sourcesContent":["export const js = (str: TemplateStringsArray, ...args: unknown[]): string => {\n\treturn str.reduce((acc, cur, i) => {\n\t\treturn acc + cur + String(args[i]);\n\t}, \"\");\n};\n"],"mappings":";AAAA,MAAa,MAAM,KAA2B,GAAG,SAA4B;
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/shared/utils.ts"],"sourcesContent":["export const js = (str: TemplateStringsArray, ...args: unknown[]): string => {\n\treturn str.reduce((acc, cur, i) => {\n\t\treturn acc + cur + String(args[i]);\n\t}, \"\");\n};\n"],"mappings":";AAAA,MAAa,MAAM,KAA2B,GAAG,SAA4B;CAC5E,OAAO,IAAI,QAAQ,KAAK,KAAK,MAAM;EAClC,OAAO,MAAM,MAAM,OAAO,KAAK,GAAG;IAChC,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-assets.mjs","names":[],"sources":["../../src/vite/virtual-assets.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport { js } from \"../shared/utils\";\n\nexport const virtualAssets = (): Plugin => {\n\tconst virtualModuleId = \"virtual:yamf:assets\";\n\tconst resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n\treturn {\n\t\tname: \"yamf:virtual-assets\",\n\t\
|
|
1
|
+
{"version":3,"file":"virtual-assets.mjs","names":[],"sources":["../../src/vite/virtual-assets.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport { js } from \"../shared/utils\";\n\nexport const virtualAssets = (): Plugin => {\n\tconst virtualModuleId = \"virtual:yamf:assets\";\n\tconst resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n\treturn {\n\t\tname: \"yamf:virtual-assets\",\n\t\tresolveId(id) {\n\t\t\tif (id === virtualModuleId) {\n\t\t\t\treturn resolvedVirtualModuleId;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tload(id) {\n\t\t\tif (id !== resolvedVirtualModuleId) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn js`\nimport clientAssets from \"./src/client/index.ts?assets=client\";\n\nexport { clientAssets };\n`.trim();\n\t\t},\n\t};\n};\n"],"mappings":";;AAGA,MAAa,sBAA8B;CAC1C,MAAM,kBAAkB;CACxB,MAAM,0BAA0B,OAAO;CAEvC,OAAO;EACN,MAAM;EACN,UAAU,IAAI;GACb,IAAI,OAAO,iBACV,OAAO;;EAKT,KAAK,IAAI;GACR,IAAI,OAAO,yBACV;GAGD,OAAO,EAAE;;;;EAIV,MAAM;;EAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-pages.mjs","names":[],"sources":["../../src/vite/virtual-pages.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport { js } from \"../shared/utils\";\n\nexport const virtualPages = (): Plugin => {\n\tconst virtualModuleId = \"virtual:yamf:pages\";\n\tconst resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n\treturn {\n\t\tname: \"yamf:virtual-pages\",\n\t\
|
|
1
|
+
{"version":3,"file":"virtual-pages.mjs","names":[],"sources":["../../src/vite/virtual-pages.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport { js } from \"../shared/utils\";\n\nexport const virtualPages = (): Plugin => {\n\tconst virtualModuleId = \"virtual:yamf:pages\";\n\tconst resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n\treturn {\n\t\tname: \"yamf:virtual-pages\",\n\t\tresolveId(id) {\n\t\t\tif (id === virtualModuleId) {\n\t\t\t\treturn resolvedVirtualModuleId;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tload(id) {\n\t\t\tif (id !== resolvedVirtualModuleId) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn js`\nconst pages = import.meta.glob(\"/src/pages/**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}\", {\n\timport: \"default\",\n});\nconst assets = import.meta.glob(\n\t\"/src/pages/**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}\",\n\t{\n\t\timport: \"default\",\n\t\tquery: \"?assets=ssr\",\n\t\teager: true,\n\t},\n);\n\nexport { pages, assets };\n`.trim();\n\t\t},\n\t};\n};\n"],"mappings":";;AAGA,MAAa,qBAA6B;CACzC,MAAM,kBAAkB;CACxB,MAAM,0BAA0B,OAAO;CAEvC,OAAO;EACN,MAAM;EACN,UAAU,IAAI;GACb,IAAI,OAAO,iBACV,OAAO;;EAKT,KAAK,IAAI;GACR,IAAI,OAAO,yBACV;GAGD,OAAO,EAAE;;;;;;;;;;;;;;EAcV,MAAM;;EAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-template.mjs","names":[],"sources":["../../src/vite/virtual-template.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { relative } from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport { js } from \"../shared/utils\";\n\nconst TEMPLATE_PATH = \"./src/template.html\";\n\nconst DEFAULT_TEMPLATE = /* html */ `\n<!DOCTYPE html>\n<html>\n <head></head>\n <body>\n <!--ssr-outlet-->\n </body>\n</html>\n`.trim();\n\nexport const virtualTemplate = (): Plugin => {\n\tconst virtualModuleId = \"virtual:yamf:template\";\n\tconst resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n\treturn {\n\t\tname: \"yamf:virtual-template\",\n\t\
|
|
1
|
+
{"version":3,"file":"virtual-template.mjs","names":[],"sources":["../../src/vite/virtual-template.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { relative } from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport { js } from \"../shared/utils\";\n\nconst TEMPLATE_PATH = \"./src/template.html\";\n\nconst DEFAULT_TEMPLATE = /* html */ `\n<!DOCTYPE html>\n<html>\n <head></head>\n <body>\n <!--ssr-outlet-->\n </body>\n</html>\n`.trim();\n\nexport const virtualTemplate = (): Plugin => {\n\tconst virtualModuleId = \"virtual:yamf:template\";\n\tconst resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n\treturn {\n\t\tname: \"yamf:virtual-template\",\n\t\tresolveId(id) {\n\t\t\tif (id === virtualModuleId) {\n\t\t\t\treturn resolvedVirtualModuleId;\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tasync load(id) {\n\t\t\tif (id !== resolvedVirtualModuleId) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst template = await readFile(TEMPLATE_PATH, \"utf8\");\n\n\t\t\t\treturn js`export const template = ${JSON.stringify(template)};`;\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n\t\t\t\t\treturn js`export const template = ${JSON.stringify(DEFAULT_TEMPLATE)};`;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\thandleHotUpdate({ file, server }) {\n\t\t\tif (relative(file, TEMPLATE_PATH) === \"\") {\n\t\t\t\tconst mod = server.moduleGraph.getModuleById(resolvedVirtualModuleId);\n\n\t\t\t\tif (mod) {\n\t\t\t\t\tserver.moduleGraph.invalidateModule(mod);\n\t\t\t\t}\n\n\t\t\t\t// TODO: should reload?\n\t\t\t\t// server.ws.send({ type: \"full-reload\" });\n\t\t\t}\n\t\t},\n\t};\n};\n"],"mappings":";;;;AAKA,MAAM,gBAAgB;AAEtB,MAAM,mBAA8B;;;;;;;;EAQlC,MAAM;AAER,MAAa,wBAAgC;CAC5C,MAAM,kBAAkB;CACxB,MAAM,0BAA0B,OAAO;CAEvC,OAAO;EACN,MAAM;EACN,UAAU,IAAI;GACb,IAAI,OAAO,iBACV,OAAO;;EAKT,MAAM,KAAK,IAAI;GACd,IAAI,OAAO,yBACV;GAGD,IAAI;IACH,MAAM,WAAW,MAAM,SAAS,eAAe,OAAO;IAEtD,OAAO,EAAE,2BAA2B,KAAK,UAAU,SAAS,CAAC;YACrD,OAAO;IACf,IAAI,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,UAC/D,OAAO,EAAE,2BAA2B,KAAK,UAAU,iBAAiB,CAAC;IAGtE,MAAM;;;EAGR,gBAAgB,EAAE,MAAM,UAAU;GACjC,IAAI,SAAS,MAAM,cAAc,KAAK,IAAI;IACzC,MAAM,MAAM,OAAO,YAAY,cAAc,wBAAwB;IAErE,IAAI,KACH,OAAO,YAAY,iBAAiB,IAAI;;;EAO3C"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pajecawav/yamf",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"description": "Yet another meta framework",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/pajecawav/yamf#readme",
|
|
@@ -35,36 +35,33 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/generator": "^7.29.1",
|
|
38
|
-
"@babel/parser": "^7.29.
|
|
38
|
+
"@babel/parser": "^7.29.3",
|
|
39
39
|
"@babel/traverse": "^7.29.0",
|
|
40
40
|
"@babel/types": "^7.29.0",
|
|
41
|
-
"devalue": "^5.
|
|
41
|
+
"devalue": "^5.8.0",
|
|
42
42
|
"nitro": "3.0.260429-beta",
|
|
43
43
|
"rou3": "^0.8.1",
|
|
44
|
-
"ufo": "^1.6.
|
|
44
|
+
"ufo": "^1.6.4",
|
|
45
45
|
"unhead": "^3.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@commitlint/config-conventional": "^20.5.0",
|
|
50
|
-
"@eslint/js": "^10.0.1",
|
|
51
|
-
"@pajecawav/prettier-config": "^1.0.0",
|
|
48
|
+
"@pajecawav/tools": "^0.0.2",
|
|
52
49
|
"@types/babel__generator": "^7.27.0",
|
|
53
50
|
"@types/babel__traverse": "^7.28.0",
|
|
54
|
-
"@types/node": "^24.12.
|
|
51
|
+
"@types/node": "^24.12.3",
|
|
55
52
|
"@vitest/coverage-v8": "^4.1.5",
|
|
56
53
|
"@vitest/ui": "^4.1.5",
|
|
57
54
|
"cross-env": "^10.1.0",
|
|
58
|
-
"
|
|
55
|
+
"hono": "^4.12.18",
|
|
59
56
|
"husky": "^9.1.7",
|
|
60
|
-
"lint-staged": "^16.4.0",
|
|
61
57
|
"npm-run-all2": "^8.0.4",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
58
|
+
"oxfmt": "^0.48.0",
|
|
59
|
+
"oxlint": "^1.63.0",
|
|
60
|
+
"oxlint-tsgolint": "^0.22.1",
|
|
61
|
+
"publint": "^0.3.20",
|
|
62
|
+
"tsdown": "0.22.0",
|
|
65
63
|
"typescript": "^6.0.3",
|
|
66
|
-
"
|
|
67
|
-
"vite": "^8.0.0",
|
|
64
|
+
"vite": "^8.0.11",
|
|
68
65
|
"vitest": "^4.1.5"
|
|
69
66
|
},
|
|
70
67
|
"scripts": {
|
|
@@ -75,10 +72,10 @@
|
|
|
75
72
|
"test:coverage": "vitest run --coverage",
|
|
76
73
|
"test:ui": "vitest --ui",
|
|
77
74
|
"lint": "run-p -l lint:*",
|
|
78
|
-
"lint:
|
|
75
|
+
"lint:oxlint": "oxlint .",
|
|
79
76
|
"lint:tsc": "tsc -b --noEmit",
|
|
80
|
-
"lint:format": "
|
|
77
|
+
"lint:format": "pt format --check",
|
|
81
78
|
"lint:package": "publint",
|
|
82
|
-
"format": "
|
|
79
|
+
"format": "pt format"
|
|
83
80
|
}
|
|
84
81
|
}
|
package/src/components/Head.tsx
CHANGED
package/src/hooks/useEvent.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useSSRContext } from "#/context/ssr";
|
|
2
1
|
import type { H3Event } from "nitro";
|
|
3
2
|
import type { EventHandlerRequest } from "nitro/h3";
|
|
3
|
+
import { useSSRContext } from "#/context/ssr";
|
|
4
4
|
|
|
5
5
|
export const useEvent = (): H3Event<EventHandlerRequest> => {
|
|
6
6
|
const ctx = useSSRContext();
|
package/src/hooks/useHead.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useSSRContext } from "#/context/ssr";
|
|
2
1
|
import { useHead as _useHead } from "unhead";
|
|
3
2
|
import type { ClientUnhead } from "unhead/client";
|
|
4
3
|
import { createHead } from "unhead/client";
|
|
5
4
|
import type { ResolvableHead } from "unhead/types";
|
|
5
|
+
import { useSSRContext } from "#/context/ssr";
|
|
6
6
|
|
|
7
7
|
declare global {
|
|
8
8
|
interface Window {
|
package/src/island/server.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ImportAssetsResultRaw } from "#/shared/assets";
|
|
2
1
|
import { stringify } from "devalue";
|
|
3
2
|
import type { Child, FC } from "hono/jsx";
|
|
3
|
+
import type { ImportAssetsResultRaw } from "#/shared/assets";
|
|
4
4
|
import type { IslandClientDirective } from "./types";
|
|
5
5
|
|
|
6
6
|
declare module "hono/jsx" {
|
package/src/server/entry.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "node:path";
|
|
2
2
|
import type { FC, PropsWithChildren } from "hono/jsx";
|
|
3
3
|
import type { EventHandlerRequest, EventHandlerWithFetch, H3Event } from "nitro/h3";
|
|
4
4
|
import { defineHandler, HTTPError, writeEarlyHints } from "nitro/h3";
|
|
5
|
-
import path from "node:path";
|
|
6
5
|
import { addRoute, createRouter, findRoute } from "rou3";
|
|
7
6
|
import { withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
8
7
|
import type { ResolvableHead } from "unhead/types";
|
|
9
8
|
import { clientAssets } from "virtual:yamf:assets";
|
|
10
9
|
import { pages, assets as serverAssets } from "virtual:yamf:pages";
|
|
10
|
+
import type { PageHandler } from "#/page";
|
|
11
11
|
|
|
12
12
|
interface Route {
|
|
13
13
|
handler: () => Promise<PageHandler>;
|
package/src/vite/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import type { NitroPluginConfig } from "nitro/vite";
|
|
2
3
|
import { nitro } from "nitro/vite";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
4
|
import type { EnvironmentOptions, PluginOption } from "vite";
|
|
5
5
|
import { islands } from "./islands";
|
|
6
6
|
import { virtualAssets } from "./virtual-assets";
|
|
@@ -22,13 +22,17 @@ const yamf = (options?: YamfOptions): PluginOption[] => {
|
|
|
22
22
|
build: {
|
|
23
23
|
// TODO: figure out if this should be true
|
|
24
24
|
cssCodeSplit: false,
|
|
25
|
-
|
|
25
|
+
rolldownOptions: {
|
|
26
26
|
input: "./src/server.tsx",
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
|
+
ssr: {
|
|
33
|
+
// we need to inline because otherwise fullstack plugin fails to build manifest for assets imports
|
|
34
|
+
noExternal: ["@pajecawav/yamf"],
|
|
35
|
+
},
|
|
32
36
|
optimizeDeps: {
|
|
33
37
|
include: [
|
|
34
38
|
"hono",
|
package/src/vite/islands.ts
CHANGED