@vindo/react 0.0.4 → 0.0.6

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/lib/client.js CHANGED
@@ -246,7 +246,19 @@ export function render({head, body}, chunk) {
246
246
  var head = ReactDom.createRoot(head)
247
247
  var body = ReactDom.createRoot(body)
248
248
 
249
-
249
+ /**
250
+ * Proxy handler
251
+ */
252
+ function getter(target, key) {
253
+ switch(key) {
254
+ case 'set':
255
+ case 'update':
256
+ case 'render':
257
+ return update
258
+ }
259
+ return target.data.state[key]
260
+ }
261
+
250
262
  /**
251
263
  * Re-render DOM
252
264
  */
@@ -274,18 +286,10 @@ export function render({head, body}, chunk) {
274
286
  * Reference for mouse event functions
275
287
  */
276
288
  chunk.refs = {
277
- meta: args.meta,
278
289
  state: new Proxy(event, {
279
- get(target, key) {
280
- switch(key) {
281
- case 'set':
282
- case 'update':
283
- case 'render':
284
- return update
285
- }
286
- return target.data.state[key]
287
- }
288
- })
290
+ get: getter
291
+ }),
292
+ meta: args.meta,
289
293
  }
290
294
 
291
295
  /**
@@ -297,7 +301,7 @@ export function render({head, body}, chunk) {
297
301
  /**
298
302
  * Set only for dynamic content coming from server
299
303
  */
300
- if(args.data.children) {
304
+ if(args.data && args.data.children) {
301
305
  args.data.children = transform(args.data.children, chunk)[0]
302
306
  }
303
307
  body.render(chunk.body(args))
@@ -312,8 +316,12 @@ export function render({head, body}, chunk) {
312
316
  path: new URL(location.href)
313
317
  })
314
318
  }
315
-
316
- _http.get({type: 'hydrate'}).then(data => event.render(data))
319
+ /**
320
+ * Make sure the entire page has finished loading, including all dependent resources (images, scripts, CSS files, etc.).
321
+ */
322
+ window.onload = function onload() {
323
+ _http.get({type: 'hydrate'}).then(data => event.render(data))
324
+ }
317
325
  }
318
326
 
319
327
 
package/lib/server.js CHANGED
@@ -358,7 +358,7 @@ function prepare(component, {meta, store, state}) {
358
358
  */
359
359
  const {children, ...props} = component.props
360
360
  const data = {
361
- meta: {name, bundle: true, ...meta},
361
+ meta: {name, bundle: false, ...meta},
362
362
  data: {
363
363
  props,
364
364
  children: isFunc(component.type) ? null : component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vindo/react",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "React SSR for @vindo/core framework.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",