arc-ux 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arc-ux",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "A purely functional router for independently evaluating a path against a list of routes",
5
5
  "main": "src/ArcUX.js",
6
6
  "type": "module",
package/src/ArcUX.js CHANGED
@@ -1,4 +1,4 @@
1
- import {ArcRouter, ArcEvents, Log, is} from "arc-lib";
1
+ import {ArcRouter, ArcEvents, is} from "arc-lib";
2
2
  import {createRoot} from "react-dom/client";
3
3
  import React from "react";
4
4
  import Html from "./Html.js";
@@ -50,7 +50,6 @@ class ArcUX {
50
50
  setKeyVal(_key, _value, _suppressEmit=false) {
51
51
  this.#keyVal[_key] = _value;
52
52
  if(!_suppressEmit) {
53
- Log.dRed(`Emitting: ${_key}`, [_value]);
54
53
  this.emit(_key, [_value]);
55
54
  }
56
55
  }
@@ -155,7 +154,6 @@ class ArcUX {
155
154
  _ctx.response.status = 200;
156
155
  _ctx.response.body = this.#Html.getString();
157
156
  } catch (e) {
158
- Log.catch(e);
159
157
  _ctx.response.status = 500;
160
158
  _ctx.response.body = {message: e.message};
161
159
  }
@@ -24,7 +24,7 @@ class App extends React.Component {
24
24
  async componentDidMount() {
25
25
  const initialRoute = this.props.ArcUX.getKeyVal('route');
26
26
 
27
- Log.dGreen(`Our initial route is ${initialRoute}`);
27
+ this.props.ArcUX.emit('log', {message: `Our initial route is ${initialRoute}`})
28
28
  const match = this.props.ArcUX.renderRoute(initialRoute);
29
29
  if(match){
30
30
  this.setState({
@@ -50,6 +50,12 @@ class App extends React.Component {
50
50
  }
51
51
 
52
52
  const RoutedComponent = this.state.target;
53
+
54
+ if(!RoutedComponent){
55
+ this.props.ArcUX.emit('log', {message: "Could not render anything. No AppLoader. No route matched. No NotFound handler. Returning null."})
56
+ return null;
57
+ }
58
+
53
59
  const Modal = this.state.modal ? this.state.modal.modal : null;
54
60
  if(Shell){
55
61
  return (
@@ -69,10 +75,10 @@ class App extends React.Component {
69
75
  }
70
76
 
71
77
  loadRoute(_newRoute) {
72
- Log.dRed('New route called?', [_newRoute])
78
+ this.props.ArcUX.emit('log', [{message: `New route called:`, data: [_newRoute]}])
73
79
  const match = this.props.ArcUX.renderRoute(_newRoute);
74
80
  if(!match){
75
- Log.dRed('Not Found handler missing');
81
+ this.props.ArcUX.emit('log', [{message: 'Not Found handler missing'}]);
76
82
  return;
77
83
  }
78
84
  const fullHistoryString = decodeURI(_newRoute);