├── .gitignore
├── routes
└── index.js
├── components
└── counter.js
├── tsconfig.json
├── nitro.config.js
├── package.json
├── LICENSE
├── README.md
└── public
└── counter.client.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .generated
2 | .nitro
3 | .output
4 | node_modules
5 | .islands
--------------------------------------------------------------------------------
/routes/index.js:
--------------------------------------------------------------------------------
1 | import { Counter } from "~/components/counter";
2 |
3 | export default defineRenderHandler(() => {
4 | return {
5 | body: ,
6 | };
7 | });
8 |
--------------------------------------------------------------------------------
/components/counter.js:
--------------------------------------------------------------------------------
1 | import { useState } from 'preact/hooks';
2 |
3 | export function Counter() {
4 | const [count, setCount] = useState(0);
5 | return ;
6 | }
7 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./.nitro/types/tsconfig.json",
3 | "compilerOptions": {
4 | "strict": true,
5 | "jsx": "preserve",
6 | "jsxImportSource": "preact",
7 | "outDir": "dist"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/nitro.config.js:
--------------------------------------------------------------------------------
1 | import { defineNitroConfig } from "nitropack/config";
2 | import { withIslands } from "nitro-preact-islands";
3 |
4 | export default withIslands(
5 | defineNitroConfig({
6 | publicAssets: [
7 | {
8 | dir: "public",
9 | baseURL: "/public",
10 | },
11 | ],
12 | })
13 | );
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nitro-prev",
3 | "version": "1.0.1",
4 | "license": "MIT",
5 | "type": "module",
6 | "main": "index.js",
7 | "scripts": {
8 | "build": "nitro build",
9 | "dev": "nitro dev"
10 | },
11 | "dependencies": {
12 | "preact": "^10.20.0",
13 | "preact-render-to-string": "^6.4.1"
14 | },
15 | "devDependencies": {
16 | "nitro-preact-islands": "^0.0.6",
17 | "nitropack": "^2.9.4"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 reaper
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # prev-nitro
2 |
3 | This is a tiny boilerplate that adds support for preact-islands into [unjs/nitro](https://nitro.unjs.io).
4 |
5 | So you get the amazing DX from nitro and h3 to be able to deploy anywhere and you get preact islands for when you wish to add interactivity.
6 |
7 | ## Usage
8 |
9 | - Clone this template using Github or using degit
10 |
11 | ```sh
12 | npx degit barelyhuman/prev-nitro
13 | ```
14 |
15 | Replace `` with the name of your project.
16 |
17 | - Install Dependencies
18 |
19 | ```sh
20 | npm i # delete the `yarn.lock` file in using this command
21 | # or
22 | yarn i
23 | ```
24 |
25 | - Run in Dev Mode
26 |
27 | ```sh
28 | npm run dev
29 | # or
30 | yarn dev
31 | ```
32 |
33 | - Build for production usage
34 |
35 | ```sh
36 | npm run build
37 | # or
38 | yarn build
39 | ```
40 |
41 | # Docs
42 |
43 | You can go through the [nitro documentation](https://nitro.unjs.io) to understand how to work with nitro.
44 |
45 | ## License
46 |
47 | reaper Open License for both OSS and Commercial.
48 |
49 | The source is provided as is and licenses of other dependecies used by the source are still viable. Please read them carefully.
50 |
--------------------------------------------------------------------------------
/public/counter.client.js:
--------------------------------------------------------------------------------
1 | (() => {
2 | var __defProp = Object.defineProperty;
3 | var __getOwnPropNames = Object.getOwnPropertyNames;
4 | var __esm = (fn, res) => function __init() {
5 | return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6 | };
7 | var __export = (target, all) => {
8 | for (var name in all)
9 | __defProp(target, name, { get: all[name], enumerable: true });
10 | };
11 |
12 | // node_modules/preact/dist/preact.module.js
13 | function h(n2, l3) {
14 | for (var u3 in l3)
15 | n2[u3] = l3[u3];
16 | return n2;
17 | }
18 | function p(n2) {
19 | var l3 = n2.parentNode;
20 | l3 && l3.removeChild(n2);
21 | }
22 | function y(l3, u3, i3) {
23 | var t3, o4, r3, f3 = {};
24 | for (r3 in u3)
25 | "key" == r3 ? t3 = u3[r3] : "ref" == r3 ? o4 = u3[r3] : f3[r3] = u3[r3];
26 | if (arguments.length > 2 && (f3.children = arguments.length > 3 ? n.call(arguments, 2) : i3), "function" == typeof l3 && null != l3.defaultProps)
27 | for (r3 in l3.defaultProps)
28 | void 0 === f3[r3] && (f3[r3] = l3.defaultProps[r3]);
29 | return d(l3, f3, t3, o4, null);
30 | }
31 | function d(n2, i3, t3, o4, r3) {
32 | var f3 = { type: n2, props: i3, key: t3, ref: o4, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, __h: null, constructor: void 0, __v: null == r3 ? ++u : r3 };
33 | return null == r3 && null != l.vnode && l.vnode(f3), f3;
34 | }
35 | function k(n2) {
36 | return n2.children;
37 | }
38 | function b(n2, l3) {
39 | this.props = n2, this.context = l3;
40 | }
41 | function g(n2, l3) {
42 | if (null == l3)
43 | return n2.__ ? g(n2.__, n2.__.__k.indexOf(n2) + 1) : null;
44 | for (var u3; l3 < n2.__k.length; l3++)
45 | if (null != (u3 = n2.__k[l3]) && null != u3.__e)
46 | return u3.__e;
47 | return "function" == typeof n2.type ? g(n2) : null;
48 | }
49 | function m(n2) {
50 | var l3, u3;
51 | if (null != (n2 = n2.__) && null != n2.__c) {
52 | for (n2.__e = n2.__c.base = null, l3 = 0; l3 < n2.__k.length; l3++)
53 | if (null != (u3 = n2.__k[l3]) && null != u3.__e) {
54 | n2.__e = n2.__c.base = u3.__e;
55 | break;
56 | }
57 | return m(n2);
58 | }
59 | }
60 | function w(n2) {
61 | (!n2.__d && (n2.__d = true) && t.push(n2) && !x.__r++ || o !== l.debounceRendering) && ((o = l.debounceRendering) || r)(x);
62 | }
63 | function x() {
64 | var n2, l3, u3, i3, o4, r3, e3, c3;
65 | for (t.sort(f); n2 = t.shift(); )
66 | n2.__d && (l3 = t.length, i3 = void 0, o4 = void 0, e3 = (r3 = (u3 = n2).__v).__e, (c3 = u3.__P) && (i3 = [], (o4 = h({}, r3)).__v = r3.__v + 1, L(c3, r3, o4, u3.__n, void 0 !== c3.ownerSVGElement, null != r3.__h ? [e3] : null, i3, null == e3 ? g(r3) : e3, r3.__h), M(i3, r3), r3.__e != e3 && m(r3)), t.length > l3 && t.sort(f));
67 | x.__r = 0;
68 | }
69 | function P(n2, l3, u3, i3, t3, o4, r3, f3, e3, a3) {
70 | var h3, p2, y2, _2, b3, m3, w3, x2 = i3 && i3.__k || s, P2 = x2.length;
71 | for (u3.__k = [], h3 = 0; h3 < l3.length; h3++)
72 | if (null != (_2 = u3.__k[h3] = null == (_2 = l3[h3]) || "boolean" == typeof _2 || "function" == typeof _2 ? null : "string" == typeof _2 || "number" == typeof _2 || "bigint" == typeof _2 ? d(null, _2, null, null, _2) : v(_2) ? d(k, { children: _2 }, null, null, null) : _2.__b > 0 ? d(_2.type, _2.props, _2.key, _2.ref ? _2.ref : null, _2.__v) : _2)) {
73 | if (_2.__ = u3, _2.__b = u3.__b + 1, null === (y2 = x2[h3]) || y2 && _2.key == y2.key && _2.type === y2.type)
74 | x2[h3] = void 0;
75 | else
76 | for (p2 = 0; p2 < P2; p2++) {
77 | if ((y2 = x2[p2]) && _2.key == y2.key && _2.type === y2.type) {
78 | x2[p2] = void 0;
79 | break;
80 | }
81 | y2 = null;
82 | }
83 | L(n2, _2, y2 = y2 || c, t3, o4, r3, f3, e3, a3), b3 = _2.__e, (p2 = _2.ref) && y2.ref != p2 && (w3 || (w3 = []), y2.ref && w3.push(y2.ref, null, _2), w3.push(p2, _2.__c || b3, _2)), null != b3 ? (null == m3 && (m3 = b3), "function" == typeof _2.type && _2.__k === y2.__k ? _2.__d = e3 = C(_2, e3, n2) : e3 = $(n2, _2, y2, x2, b3, e3), "function" == typeof u3.type && (u3.__d = e3)) : e3 && y2.__e == e3 && e3.parentNode != n2 && (e3 = g(y2));
84 | }
85 | for (u3.__e = m3, h3 = P2; h3--; )
86 | null != x2[h3] && ("function" == typeof u3.type && null != x2[h3].__e && x2[h3].__e == u3.__d && (u3.__d = A(i3).nextSibling), q(x2[h3], x2[h3]));
87 | if (w3)
88 | for (h3 = 0; h3 < w3.length; h3++)
89 | O(w3[h3], w3[++h3], w3[++h3]);
90 | }
91 | function C(n2, l3, u3) {
92 | for (var i3, t3 = n2.__k, o4 = 0; t3 && o4 < t3.length; o4++)
93 | (i3 = t3[o4]) && (i3.__ = n2, l3 = "function" == typeof i3.type ? C(i3, l3, u3) : $(u3, i3, i3, t3, i3.__e, l3));
94 | return l3;
95 | }
96 | function $(n2, l3, u3, i3, t3, o4) {
97 | var r3, f3, e3;
98 | if (void 0 !== l3.__d)
99 | r3 = l3.__d, l3.__d = void 0;
100 | else if (null == u3 || t3 != o4 || null == t3.parentNode)
101 | n:
102 | if (null == o4 || o4.parentNode !== n2)
103 | n2.appendChild(t3), r3 = null;
104 | else {
105 | for (f3 = o4, e3 = 0; (f3 = f3.nextSibling) && e3 < i3.length; e3 += 1)
106 | if (f3 == t3)
107 | break n;
108 | n2.insertBefore(t3, o4), r3 = o4;
109 | }
110 | return void 0 !== r3 ? r3 : t3.nextSibling;
111 | }
112 | function A(n2) {
113 | var l3, u3, i3;
114 | if (null == n2.type || "string" == typeof n2.type)
115 | return n2.__e;
116 | if (n2.__k) {
117 | for (l3 = n2.__k.length - 1; l3 >= 0; l3--)
118 | if ((u3 = n2.__k[l3]) && (i3 = A(u3)))
119 | return i3;
120 | }
121 | return null;
122 | }
123 | function H(n2, l3, u3, i3, t3) {
124 | var o4;
125 | for (o4 in u3)
126 | "children" === o4 || "key" === o4 || o4 in l3 || T(n2, o4, null, u3[o4], i3);
127 | for (o4 in l3)
128 | t3 && "function" != typeof l3[o4] || "children" === o4 || "key" === o4 || "value" === o4 || "checked" === o4 || u3[o4] === l3[o4] || T(n2, o4, l3[o4], u3[o4], i3);
129 | }
130 | function I(n2, l3, u3) {
131 | "-" === l3[0] ? n2.setProperty(l3, null == u3 ? "" : u3) : n2[l3] = null == u3 ? "" : "number" != typeof u3 || a.test(l3) ? u3 : u3 + "px";
132 | }
133 | function T(n2, l3, u3, i3, t3) {
134 | var o4;
135 | n:
136 | if ("style" === l3)
137 | if ("string" == typeof u3)
138 | n2.style.cssText = u3;
139 | else {
140 | if ("string" == typeof i3 && (n2.style.cssText = i3 = ""), i3)
141 | for (l3 in i3)
142 | u3 && l3 in u3 || I(n2.style, l3, "");
143 | if (u3)
144 | for (l3 in u3)
145 | i3 && u3[l3] === i3[l3] || I(n2.style, l3, u3[l3]);
146 | }
147 | else if ("o" === l3[0] && "n" === l3[1])
148 | o4 = l3 !== (l3 = l3.replace(/Capture$/, "")), l3 = l3.toLowerCase() in n2 ? l3.toLowerCase().slice(2) : l3.slice(2), n2.l || (n2.l = {}), n2.l[l3 + o4] = u3, u3 ? i3 || n2.addEventListener(l3, o4 ? z : j, o4) : n2.removeEventListener(l3, o4 ? z : j, o4);
149 | else if ("dangerouslySetInnerHTML" !== l3) {
150 | if (t3)
151 | l3 = l3.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
152 | else if ("width" !== l3 && "height" !== l3 && "href" !== l3 && "list" !== l3 && "form" !== l3 && "tabIndex" !== l3 && "download" !== l3 && "rowSpan" !== l3 && "colSpan" !== l3 && l3 in n2)
153 | try {
154 | n2[l3] = null == u3 ? "" : u3;
155 | break n;
156 | } catch (n3) {
157 | }
158 | "function" == typeof u3 || (null == u3 || false === u3 && "-" !== l3[4] ? n2.removeAttribute(l3) : n2.setAttribute(l3, u3));
159 | }
160 | }
161 | function j(n2) {
162 | return this.l[n2.type + false](l.event ? l.event(n2) : n2);
163 | }
164 | function z(n2) {
165 | return this.l[n2.type + true](l.event ? l.event(n2) : n2);
166 | }
167 | function L(n2, u3, i3, t3, o4, r3, f3, e3, c3) {
168 | var s3, a3, p2, y2, d3, _2, g3, m3, w3, x2, C2, S, $2, A2, H2, I2 = u3.type;
169 | if (void 0 !== u3.constructor)
170 | return null;
171 | null != i3.__h && (c3 = i3.__h, e3 = u3.__e = i3.__e, u3.__h = null, r3 = [e3]), (s3 = l.__b) && s3(u3);
172 | try {
173 | n:
174 | if ("function" == typeof I2) {
175 | if (m3 = u3.props, w3 = (s3 = I2.contextType) && t3[s3.__c], x2 = s3 ? w3 ? w3.props.value : s3.__ : t3, i3.__c ? g3 = (a3 = u3.__c = i3.__c).__ = a3.__E : ("prototype" in I2 && I2.prototype.render ? u3.__c = a3 = new I2(m3, x2) : (u3.__c = a3 = new b(m3, x2), a3.constructor = I2, a3.render = B), w3 && w3.sub(a3), a3.props = m3, a3.state || (a3.state = {}), a3.context = x2, a3.__n = t3, p2 = a3.__d = true, a3.__h = [], a3._sb = []), null == a3.__s && (a3.__s = a3.state), null != I2.getDerivedStateFromProps && (a3.__s == a3.state && (a3.__s = h({}, a3.__s)), h(a3.__s, I2.getDerivedStateFromProps(m3, a3.__s))), y2 = a3.props, d3 = a3.state, a3.__v = u3, p2)
176 | null == I2.getDerivedStateFromProps && null != a3.componentWillMount && a3.componentWillMount(), null != a3.componentDidMount && a3.__h.push(a3.componentDidMount);
177 | else {
178 | if (null == I2.getDerivedStateFromProps && m3 !== y2 && null != a3.componentWillReceiveProps && a3.componentWillReceiveProps(m3, x2), !a3.__e && null != a3.shouldComponentUpdate && false === a3.shouldComponentUpdate(m3, a3.__s, x2) || u3.__v === i3.__v) {
179 | for (u3.__v !== i3.__v && (a3.props = m3, a3.state = a3.__s, a3.__d = false), a3.__e = false, u3.__e = i3.__e, u3.__k = i3.__k, u3.__k.forEach(function(n3) {
180 | n3 && (n3.__ = u3);
181 | }), C2 = 0; C2 < a3._sb.length; C2++)
182 | a3.__h.push(a3._sb[C2]);
183 | a3._sb = [], a3.__h.length && f3.push(a3);
184 | break n;
185 | }
186 | null != a3.componentWillUpdate && a3.componentWillUpdate(m3, a3.__s, x2), null != a3.componentDidUpdate && a3.__h.push(function() {
187 | a3.componentDidUpdate(y2, d3, _2);
188 | });
189 | }
190 | if (a3.context = x2, a3.props = m3, a3.__P = n2, S = l.__r, $2 = 0, "prototype" in I2 && I2.prototype.render) {
191 | for (a3.state = a3.__s, a3.__d = false, S && S(u3), s3 = a3.render(a3.props, a3.state, a3.context), A2 = 0; A2 < a3._sb.length; A2++)
192 | a3.__h.push(a3._sb[A2]);
193 | a3._sb = [];
194 | } else
195 | do {
196 | a3.__d = false, S && S(u3), s3 = a3.render(a3.props, a3.state, a3.context), a3.state = a3.__s;
197 | } while (a3.__d && ++$2 < 25);
198 | a3.state = a3.__s, null != a3.getChildContext && (t3 = h(h({}, t3), a3.getChildContext())), p2 || null == a3.getSnapshotBeforeUpdate || (_2 = a3.getSnapshotBeforeUpdate(y2, d3)), P(n2, v(H2 = null != s3 && s3.type === k && null == s3.key ? s3.props.children : s3) ? H2 : [H2], u3, i3, t3, o4, r3, f3, e3, c3), a3.base = u3.__e, u3.__h = null, a3.__h.length && f3.push(a3), g3 && (a3.__E = a3.__ = null), a3.__e = false;
199 | } else
200 | null == r3 && u3.__v === i3.__v ? (u3.__k = i3.__k, u3.__e = i3.__e) : u3.__e = N(i3.__e, u3, i3, t3, o4, r3, f3, c3);
201 | (s3 = l.diffed) && s3(u3);
202 | } catch (n3) {
203 | u3.__v = null, (c3 || null != r3) && (u3.__e = e3, u3.__h = !!c3, r3[r3.indexOf(e3)] = null), l.__e(n3, u3, i3);
204 | }
205 | }
206 | function M(n2, u3) {
207 | l.__c && l.__c(u3, n2), n2.some(function(u4) {
208 | try {
209 | n2 = u4.__h, u4.__h = [], n2.some(function(n3) {
210 | n3.call(u4);
211 | });
212 | } catch (n3) {
213 | l.__e(n3, u4.__v);
214 | }
215 | });
216 | }
217 | function N(l3, u3, i3, t3, o4, r3, f3, e3) {
218 | var s3, a3, h3, y2 = i3.props, d3 = u3.props, _2 = u3.type, k3 = 0;
219 | if ("svg" === _2 && (o4 = true), null != r3) {
220 | for (; k3 < r3.length; k3++)
221 | if ((s3 = r3[k3]) && "setAttribute" in s3 == !!_2 && (_2 ? s3.localName === _2 : 3 === s3.nodeType)) {
222 | l3 = s3, r3[k3] = null;
223 | break;
224 | }
225 | }
226 | if (null == l3) {
227 | if (null === _2)
228 | return document.createTextNode(d3);
229 | l3 = o4 ? document.createElementNS("http://www.w3.org/2000/svg", _2) : document.createElement(_2, d3.is && d3), r3 = null, e3 = false;
230 | }
231 | if (null === _2)
232 | y2 === d3 || e3 && l3.data === d3 || (l3.data = d3);
233 | else {
234 | if (r3 = r3 && n.call(l3.childNodes), a3 = (y2 = i3.props || c).dangerouslySetInnerHTML, h3 = d3.dangerouslySetInnerHTML, !e3) {
235 | if (null != r3)
236 | for (y2 = {}, k3 = 0; k3 < l3.attributes.length; k3++)
237 | y2[l3.attributes[k3].name] = l3.attributes[k3].value;
238 | (h3 || a3) && (h3 && (a3 && h3.__html == a3.__html || h3.__html === l3.innerHTML) || (l3.innerHTML = h3 && h3.__html || ""));
239 | }
240 | if (H(l3, d3, y2, o4, e3), h3)
241 | u3.__k = [];
242 | else if (P(l3, v(k3 = u3.props.children) ? k3 : [k3], u3, i3, t3, o4 && "foreignObject" !== _2, r3, f3, r3 ? r3[0] : i3.__k && g(i3, 0), e3), null != r3)
243 | for (k3 = r3.length; k3--; )
244 | null != r3[k3] && p(r3[k3]);
245 | e3 || ("value" in d3 && void 0 !== (k3 = d3.value) && (k3 !== l3.value || "progress" === _2 && !k3 || "option" === _2 && k3 !== y2.value) && T(l3, "value", k3, y2.value, false), "checked" in d3 && void 0 !== (k3 = d3.checked) && k3 !== l3.checked && T(l3, "checked", k3, y2.checked, false));
246 | }
247 | return l3;
248 | }
249 | function O(n2, u3, i3) {
250 | try {
251 | "function" == typeof n2 ? n2(u3) : n2.current = u3;
252 | } catch (n3) {
253 | l.__e(n3, i3);
254 | }
255 | }
256 | function q(n2, u3, i3) {
257 | var t3, o4;
258 | if (l.unmount && l.unmount(n2), (t3 = n2.ref) && (t3.current && t3.current !== n2.__e || O(t3, null, u3)), null != (t3 = n2.__c)) {
259 | if (t3.componentWillUnmount)
260 | try {
261 | t3.componentWillUnmount();
262 | } catch (n3) {
263 | l.__e(n3, u3);
264 | }
265 | t3.base = t3.__P = null, n2.__c = void 0;
266 | }
267 | if (t3 = n2.__k)
268 | for (o4 = 0; o4 < t3.length; o4++)
269 | t3[o4] && q(t3[o4], u3, i3 || "function" != typeof n2.type);
270 | i3 || null == n2.__e || p(n2.__e), n2.__ = n2.__e = n2.__d = void 0;
271 | }
272 | function B(n2, l3, u3) {
273 | return this.constructor(n2, u3);
274 | }
275 | function D(u3, i3, t3) {
276 | var o4, r3, f3;
277 | l.__ && l.__(u3, i3), r3 = (o4 = "function" == typeof t3) ? null : t3 && t3.__k || i3.__k, f3 = [], L(i3, u3 = (!o4 && t3 || i3).__k = y(k, null, [u3]), r3 || c, c, void 0 !== i3.ownerSVGElement, !o4 && t3 ? [t3] : r3 ? null : i3.firstChild ? n.call(i3.childNodes) : null, f3, !o4 && t3 ? t3 : r3 ? r3.__e : i3.firstChild, o4), M(f3, u3);
278 | }
279 | var n, l, u, i, t, o, r, f, e, c, s, a, v;
280 | var init_preact_module = __esm({
281 | "node_modules/preact/dist/preact.module.js"() {
282 | c = {};
283 | s = [];
284 | a = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
285 | v = Array.isArray;
286 | n = s.slice, l = { __e: function(n2, l3, u3, i3) {
287 | for (var t3, o4, r3; l3 = l3.__; )
288 | if ((t3 = l3.__c) && !t3.__)
289 | try {
290 | if ((o4 = t3.constructor) && null != o4.getDerivedStateFromError && (t3.setState(o4.getDerivedStateFromError(n2)), r3 = t3.__d), null != t3.componentDidCatch && (t3.componentDidCatch(n2, i3 || {}), r3 = t3.__d), r3)
291 | return t3.__E = t3;
292 | } catch (l4) {
293 | n2 = l4;
294 | }
295 | throw n2;
296 | } }, u = 0, i = function(n2) {
297 | return null != n2 && void 0 === n2.constructor;
298 | }, b.prototype.setState = function(n2, l3) {
299 | var u3;
300 | u3 = null != this.__s && this.__s !== this.state ? this.__s : this.__s = h({}, this.state), "function" == typeof n2 && (n2 = n2(h({}, u3), this.props)), n2 && h(u3, n2), null != n2 && this.__v && (l3 && this._sb.push(l3), w(this));
301 | }, b.prototype.forceUpdate = function(n2) {
302 | this.__v && (this.__e = true, n2 && this.__h.push(n2), w(this));
303 | }, b.prototype.render = k, t = [], r = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, f = function(n2, l3) {
304 | return n2.__v.__b - l3.__v.__b;
305 | }, x.__r = 0, e = 0;
306 | }
307 | });
308 |
309 | // node_modules/preact/hooks/dist/hooks.module.js
310 | function d2(t3, u3) {
311 | l.__h && l.__h(r2, t3, o2 || u3), o2 = 0;
312 | var i3 = r2.__H || (r2.__H = { __: [], __h: [] });
313 | return t3 >= i3.__.length && i3.__.push({ __V: c2 }), i3.__[t3];
314 | }
315 | function h2(n2) {
316 | return o2 = 1, s2(B2, n2);
317 | }
318 | function s2(n2, u3, i3) {
319 | var o4 = d2(t2++, 2);
320 | if (o4.t = n2, !o4.__c && (o4.__ = [i3 ? i3(u3) : B2(void 0, u3), function(n3) {
321 | var t3 = o4.__N ? o4.__N[0] : o4.__[0], r3 = o4.t(t3, n3);
322 | t3 !== r3 && (o4.__N = [r3, o4.__[1]], o4.__c.setState({}));
323 | }], o4.__c = r2, !r2.u)) {
324 | var f3 = function(n3, t3, r3) {
325 | if (!o4.__c.__H)
326 | return true;
327 | var u4 = o4.__c.__H.__.filter(function(n4) {
328 | return n4.__c;
329 | });
330 | if (u4.every(function(n4) {
331 | return !n4.__N;
332 | }))
333 | return !c3 || c3.call(this, n3, t3, r3);
334 | var i4 = false;
335 | return u4.forEach(function(n4) {
336 | if (n4.__N) {
337 | var t4 = n4.__[0];
338 | n4.__ = n4.__N, n4.__N = void 0, t4 !== n4.__[0] && (i4 = true);
339 | }
340 | }), !(!i4 && o4.__c.props === n3) && (!c3 || c3.call(this, n3, t3, r3));
341 | };
342 | r2.u = true;
343 | var c3 = r2.shouldComponentUpdate, e3 = r2.componentWillUpdate;
344 | r2.componentWillUpdate = function(n3, t3, r3) {
345 | if (this.__e) {
346 | var u4 = c3;
347 | c3 = void 0, f3(n3, t3, r3), c3 = u4;
348 | }
349 | e3 && e3.call(this, n3, t3, r3);
350 | }, r2.shouldComponentUpdate = f3;
351 | }
352 | return o4.__N || o4.__;
353 | }
354 | function b2() {
355 | for (var t3; t3 = f2.shift(); )
356 | if (t3.__P && t3.__H)
357 | try {
358 | t3.__H.__h.forEach(k2), t3.__H.__h.forEach(w2), t3.__H.__h = [];
359 | } catch (r3) {
360 | t3.__H.__h = [], l.__e(r3, t3.__v);
361 | }
362 | }
363 | function j2(n2) {
364 | var t3, r3 = function() {
365 | clearTimeout(u3), g2 && cancelAnimationFrame(t3), setTimeout(n2);
366 | }, u3 = setTimeout(r3, 100);
367 | g2 && (t3 = requestAnimationFrame(r3));
368 | }
369 | function k2(n2) {
370 | var t3 = r2, u3 = n2.__c;
371 | "function" == typeof u3 && (n2.__c = void 0, u3()), r2 = t3;
372 | }
373 | function w2(n2) {
374 | var t3 = r2;
375 | n2.__c = n2.__(), r2 = t3;
376 | }
377 | function B2(n2, t3) {
378 | return "function" == typeof t3 ? t3(n2) : t3;
379 | }
380 | var t2, r2, u2, i2, o2, f2, c2, e2, a2, v2, l2, m2, g2;
381 | var init_hooks_module = __esm({
382 | "node_modules/preact/hooks/dist/hooks.module.js"() {
383 | init_preact_module();
384 | o2 = 0;
385 | f2 = [];
386 | c2 = [];
387 | e2 = l.__b;
388 | a2 = l.__r;
389 | v2 = l.diffed;
390 | l2 = l.__c;
391 | m2 = l.unmount;
392 | l.__b = function(n2) {
393 | r2 = null, e2 && e2(n2);
394 | }, l.__r = function(n2) {
395 | a2 && a2(n2), t2 = 0;
396 | var i3 = (r2 = n2.__c).__H;
397 | i3 && (u2 === r2 ? (i3.__h = [], r2.__h = [], i3.__.forEach(function(n3) {
398 | n3.__N && (n3.__ = n3.__N), n3.__V = c2, n3.__N = n3.i = void 0;
399 | })) : (i3.__h.forEach(k2), i3.__h.forEach(w2), i3.__h = [], t2 = 0)), u2 = r2;
400 | }, l.diffed = function(t3) {
401 | v2 && v2(t3);
402 | var o4 = t3.__c;
403 | o4 && o4.__H && (o4.__H.__h.length && (1 !== f2.push(o4) && i2 === l.requestAnimationFrame || ((i2 = l.requestAnimationFrame) || j2)(b2)), o4.__H.__.forEach(function(n2) {
404 | n2.i && (n2.__H = n2.i), n2.__V !== c2 && (n2.__ = n2.__V), n2.i = void 0, n2.__V = c2;
405 | })), u2 = r2 = null;
406 | }, l.__c = function(t3, r3) {
407 | r3.some(function(t4) {
408 | try {
409 | t4.__h.forEach(k2), t4.__h = t4.__h.filter(function(n2) {
410 | return !n2.__ || w2(n2);
411 | });
412 | } catch (u3) {
413 | r3.some(function(n2) {
414 | n2.__h && (n2.__h = []);
415 | }), r3 = [], l.__e(u3, t4.__v);
416 | }
417 | }), l2 && l2(t3, r3);
418 | }, l.unmount = function(t3) {
419 | m2 && m2(t3);
420 | var r3, u3 = t3.__c;
421 | u3 && u3.__H && (u3.__H.__.forEach(function(n2) {
422 | try {
423 | k2(n2);
424 | } catch (n3) {
425 | r3 = n3;
426 | }
427 | }), u3.__H = void 0, r3 && l.__e(r3, u3.__v));
428 | };
429 | g2 = "function" == typeof requestAnimationFrame;
430 | }
431 | });
432 |
433 | // node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
434 | function o3(o4, e3, n2, t3, f3, l3) {
435 | var s3, u3, a3 = {};
436 | for (u3 in e3)
437 | "ref" == u3 ? s3 = e3[u3] : a3[u3] = e3[u3];
438 | var i3 = { type: o4, props: a3, key: n2, ref: s3, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, __h: null, constructor: void 0, __v: --_, __source: f3, __self: l3 };
439 | if ("function" == typeof o4 && (s3 = o4.defaultProps))
440 | for (u3 in s3)
441 | void 0 === a3[u3] && (a3[u3] = s3[u3]);
442 | return l.vnode && l.vnode(i3), i3;
443 | }
444 | var _;
445 | var init_jsxRuntime_module = __esm({
446 | "node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js"() {
447 | init_preact_module();
448 | init_preact_module();
449 | _ = 0;
450 | }
451 | });
452 |
453 | // components/counter.js
454 | var counter_exports = {};
455 | __export(counter_exports, {
456 | default: () => Counter
457 | });
458 | function Counter() {
459 | const [count, setCount] = h2(0);
460 | return /* @__PURE__ */ o3("button", { onClick: (_2) => setCount(count + 1), children: count });
461 | }
462 | var init_counter = __esm({
463 | "components/counter.js"() {
464 | init_hooks_module();
465 | init_jsxRuntime_module();
466 | }
467 | });
468 |
469 | // .generated/counter.client.js
470 | init_preact_module();
471 | var restoreTree = (type, props = {}) => {
472 | if (typeof props.children === "object") {
473 | if (Array.isArray(props.children)) {
474 | return y(
475 | type,
476 | props,
477 | ...props.children.map((x2) => {
478 | return restoreTree(x2.type, x2.props);
479 | })
480 | );
481 | }
482 | return y(
483 | type,
484 | props,
485 | restoreTree(props.children.type, props.children.props || {})
486 | );
487 | }
488 | return y(type, props);
489 | };
490 | function mergePropsWithDOM(rootNode, props) {
491 | const scripts = /* @__PURE__ */ new Map();
492 | function walk(node, propPoint) {
493 | Array.from(node.childNodes || []).filter((x2) => {
494 | if (x2.localName != "script") {
495 | return true;
496 | } else {
497 | scripts.set(x2.src, x2);
498 | }
499 | }).forEach((child, index) => {
500 | let _prop = propPoint;
501 | if (Array.isArray(propPoint) && propPoint[index]) {
502 | _prop = propPoint[index];
503 | }
504 | if (/^island-(.*)+/.test(child.localName)) {
505 | _prop.type = child.localName;
506 | if (_prop.props) {
507 | _prop.props["data-props"] = JSON.stringify(_prop.props);
508 | }
509 | }
510 | if (child.childNodes.length > 0) {
511 | if (propPoint.children) {
512 | walk(child, propPoint.children);
513 | }
514 | }
515 | });
516 | }
517 | walk(rootNode, props);
518 | rootNode.innerHTML = "";
519 | const scriptNodes = [...scripts].map(([k3, v3]) => v3);
520 | rootNode.append(...scriptNodes);
521 | }
522 | customElements.define("island-counter", class IslandCounter extends HTMLElement {
523 | async connectedCallback() {
524 | const c3 = await Promise.resolve().then(() => (init_counter(), counter_exports));
525 | const props = JSON.parse(this.dataset.props || "{}");
526 | mergePropsWithDOM(this, props);
527 | D(restoreTree(c3.default, props), this, this);
528 | }
529 | });
530 | })();
531 |
--------------------------------------------------------------------------------