@astrojs/solid-js
Advanced tools
Comparing version 0.1.2 to 0.1.3
# @astrojs/solid-js | ||
## 0.1.3 | ||
### Patch Changes | ||
- [#3455](https://github.com/withastro/astro/pull/3455) [`e9a77d86`](https://github.com/withastro/astro/commit/e9a77d861907adccfa75811f9aaa555f186d78f8) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Update client hydration to check for `ssr` attribute. Requires `astro@^1.0.0-beta.36`. | ||
## 0.1.2 | ||
@@ -4,0 +10,0 @@ |
import { sharedConfig } from 'solid-js'; | ||
import { hydrate, createComponent } from 'solid-js/web'; | ||
import { hydrate, render, createComponent } from 'solid-js/web'; | ||
export default (element) => (Component, props, childHTML) => { | ||
// Prepare global object expected by Solid's hydration logic | ||
if (!window._$HY) { | ||
window._$HY = { events: [], completed: new WeakSet(), r: {} }; | ||
} | ||
// Perform actual hydration | ||
let children; | ||
hydrate( | ||
() => | ||
createComponent(Component, { | ||
...props, | ||
get children() { | ||
if (childHTML != null) { | ||
// hydrating | ||
if (sharedConfig.context) children = element.querySelector('astro-fragment'); | ||
export default (element) => | ||
(Component, props, childHTML, { client }) => { | ||
// Prepare global object expected by Solid's hydration logic | ||
if (!window._$HY) { | ||
window._$HY = { events: [], completed: new WeakSet(), r: {} }; | ||
} | ||
if (!element.hasAttribute('ssr')) return; | ||
if (children == null) { | ||
children = document.createElement('astro-fragment'); | ||
children.innerHTML = childHTML; | ||
const fn = client === 'only' ? render : hydrate; | ||
// Perform actual hydration | ||
let children; | ||
fn( | ||
() => | ||
createComponent(Component, { | ||
...props, | ||
get children() { | ||
if (childHTML != null) { | ||
// hydrating | ||
if (sharedConfig.context) { | ||
children = element.querySelector('astro-fragment'); | ||
} | ||
if (children == null) { | ||
children = document.createElement('astro-fragment'); | ||
children.innerHTML = childHTML; | ||
} | ||
} | ||
} | ||
return children; | ||
}, | ||
}), | ||
element | ||
); | ||
}; | ||
return children; | ||
}, | ||
}), | ||
element | ||
); | ||
}; |
{ | ||
"name": "@astrojs/solid-js", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Use Solid components within Astro", | ||
@@ -28,14 +28,9 @@ "type": "module", | ||
}, | ||
"scripts": { | ||
"build": "astro-scripts build \"src/**/*.ts\" && tsc", | ||
"build:ci": "astro-scripts build \"src/**/*.ts\"", | ||
"dev": "astro-scripts dev \"src/**/*.ts\"" | ||
}, | ||
"dependencies": { | ||
"babel-preset-solid": "^1.3.13" | ||
"babel-preset-solid": "^1.4.2" | ||
}, | ||
"devDependencies": { | ||
"astro": "workspace:*", | ||
"astro-scripts": "workspace:*", | ||
"solid-js": "^1.3.14" | ||
"astro": "1.0.0-beta.38", | ||
"astro-scripts": "0.0.4", | ||
"solid-js": "^1.4.3" | ||
}, | ||
@@ -47,3 +42,8 @@ "peerDependencies": { | ||
"node": "^14.15.0 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"build": "astro-scripts build \"src/**/*.ts\" && tsc", | ||
"build:ci": "astro-scripts build \"src/**/*.ts\"", | ||
"dev": "astro-scripts dev \"src/**/*.ts\"" | ||
} | ||
} | ||
} |
@@ -5,8 +5,4 @@ import { renderToString, ssr, createComponent } from 'solid-js/web'; | ||
if (typeof Component !== 'function') return false; | ||
try { | ||
const { html } = renderToStaticMarkup(Component, props, children); | ||
return typeof html === 'string'; | ||
} catch (err) { | ||
return false; | ||
} | ||
const { html } = renderToStaticMarkup(Component, props, children); | ||
return typeof html === 'string'; | ||
} | ||
@@ -13,0 +9,0 @@ |
179
14828
Updatedbabel-preset-solid@^1.4.2