@picked/svelte 0.0.65-next.4 → 0.0.66-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
/** @file Renders a resolved html-asset field and re-executes its Picked-tagged scripts. */
|
|
3
|
-
import { isHtmlAssetValue, rehydrateScripts,
|
|
2
|
+
/** @file Renders a resolved html-asset field into a shadow root and re-executes its Picked-tagged scripts. */
|
|
3
|
+
import { isHtmlAssetValue, rehydrateScripts, supportsShadowRoot } from '@picked/client'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
/** The resolved html-asset field value (for example `content.body`). */
|
|
@@ -12,16 +12,15 @@
|
|
|
12
12
|
const value = $derived(isHtmlAssetValue(html) ? html : null)
|
|
13
13
|
const markup = $derived(value?.content ?? '')
|
|
14
14
|
|
|
15
|
-
let
|
|
15
|
+
let host = $state<HTMLDivElement>()
|
|
16
16
|
|
|
17
17
|
$effect(() => {
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
}
|
|
18
|
+
if (!supportsShadowRoot() || !host) return
|
|
19
|
+
|
|
20
|
+
const shadow = host.shadowRoot ?? host.attachShadow({ mode: 'open' })
|
|
21
|
+
shadow.innerHTML = markup
|
|
22
|
+
if (markup) void rehydrateScripts(shadow)
|
|
21
23
|
})
|
|
22
24
|
</script>
|
|
23
25
|
|
|
24
|
-
{
|
|
25
|
-
<!-- eslint-disable-next-line svelte/no-at-html-tags -- markup is a trusted, Picked-transformed html-asset field, not arbitrary user input -->
|
|
26
|
-
<div bind:this={container}>{@html markup}</div>
|
|
27
|
-
{/key}
|
|
26
|
+
<div bind:this={host}></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66-next.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"d3": "^7.9.0"
|
|
6
6
|
},
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
},
|
|
107
107
|
"module": "./dist/index.js",
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"@picked/client": "0.0.
|
|
109
|
+
"@picked/client": "0.0.66-next.1",
|
|
110
110
|
"effector": "^23.3.0",
|
|
111
111
|
"svelte": "^5.46.4"
|
|
112
112
|
},
|