@capri-js/preact
Advanced tools
Comparing version 3.1.3 to 4.0.0-next.1
@@ -1,3 +0,2 @@ | ||
import { HydrationAdapter } from "capri/vite-plugin"; | ||
declare const adapter: HydrationAdapter; | ||
export default adapter; | ||
import { ComponentType } from "preact"; | ||
export default function hydrate(component: ComponentType, props: Record<string, unknown>, element: Element): void; |
import { h, hydrate as hydrateComponent } from "preact"; | ||
const adapter = { | ||
hydrate(component, props, element) { | ||
return hydrateComponent(h(component, props), element.parentElement); | ||
}, | ||
renderChildren() { | ||
return h("capri-children", { | ||
export default function hydrate(component, props, element) { | ||
const children = element.querySelector("capri-children"); | ||
if (children) { | ||
props.children = h("capri-children", { | ||
style: { display: "contents" }, | ||
dangerouslySetInnerHTML: { __html: "" }, | ||
}); | ||
}, | ||
}; | ||
export default adapter; | ||
} | ||
return hydrateComponent(h(component, props), element.parentElement); | ||
} |
@@ -1,8 +0,2 @@ | ||
import { IslandOptions } from "capri"; | ||
import { ComponentType } from "preact"; | ||
export type { RenderFunction } from "capri"; | ||
export { prerender as renderToString } from "preact-iso"; | ||
export declare function island<T extends ComponentType<any>>(component: T, options?: IslandOptions): T; | ||
export declare function lagoon<T extends ComponentType<any>>(factory: () => Promise<{ | ||
default: T; | ||
}>): (props: any) => import("preact").VNode<any>; | ||
import { CapriAdapterPluginOptions } from "capri/vite-plugin"; | ||
export default function (opts?: CapriAdapterPluginOptions): import("vite").Plugin[]; |
@@ -1,20 +0,17 @@ | ||
import { createIslandComponent } from "capri"; | ||
import { h } from "preact"; | ||
import { lazy } from "preact-iso"; | ||
export { prerender as renderToString } from "preact-iso"; | ||
export function island(component, options = {}) { | ||
return createIslandComponent(component, options, ({ props, children, scriptProps, scriptContent }) => { | ||
const wrappedChildren = children && | ||
h("capri-children", { style: { display: "contents" } }, children); | ||
return h("capri-island", { style: { display: "contents" } }, h(component, props, wrappedChildren), h("script", { | ||
...scriptProps, | ||
dangerouslySetInnerHTML: { __html: scriptContent }, | ||
})); | ||
import { capri } from "capri/vite-plugin"; | ||
export default function (opts = {}) { | ||
const resolve = (f) => new URL(f, import.meta.url).pathname; | ||
return capri({ | ||
...opts, | ||
adapter: { | ||
hydrate: resolve("./hydrate.js"), | ||
island: { | ||
server: resolve("./island.server.jsx"), | ||
}, | ||
lagoon: { | ||
server: resolve("./lagoon.server.jsx"), | ||
client: resolve("./lagoon.client.jsx"), | ||
}, | ||
}, | ||
}); | ||
} | ||
export function lagoon(factory) { | ||
const Comp = lazy(factory); | ||
return (props) => { | ||
return h("capri-lagoon", { style: { display: "contents" } }, h(Comp, props)); | ||
}; | ||
} |
{ | ||
"name": "@capri-js/preact", | ||
"version": "3.1.3", | ||
"version": "4.0.0-next.1", | ||
"description": "", | ||
@@ -19,10 +19,6 @@ "author": "Felix Gnass <fgnass@gmail.com>", | ||
".": { | ||
"browser": "./lib/browser.js", | ||
"default": "./lib/index.js" | ||
}, | ||
"./vite-plugin": { | ||
"default": "./lib/vite-plugin.js" | ||
}, | ||
"./hydrate": { | ||
"default": "./lib/hydrate.js" | ||
"./server": { | ||
"default": "./lib/server.js" | ||
} | ||
@@ -35,7 +31,4 @@ }, | ||
], | ||
"vite-plugin": [ | ||
"lib/vite-plugin.d.ts" | ||
], | ||
"hydrate": [ | ||
"lib/hydrate.d.ts" | ||
"server": [ | ||
"lib/server.d.ts" | ||
] | ||
@@ -45,3 +38,3 @@ } | ||
"dependencies": { | ||
"capri": "^3.3.0", | ||
"capri": "^4.0.0-next.1", | ||
"preact-iso": "^2.3.0" | ||
@@ -48,0 +41,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14
3699
62
2
+ Addedbraces@3.0.3(transitive)
+ Addedcapri@4.1.0(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedurl-join@5.0.0(transitive)
- Removedcapri@3.3.0(transitive)
Updatedcapri@^4.0.0-next.1