brew-js-react 0.4.0 → 0.4.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,4 +1,4 @@
1
- /*! brew-js-react v0.4.0 | (c) misonou | https://hackmd.io/@misonou/brew-js-react */
1
+ /*! brew-js-react v0.4.1 | (c) misonou | https://hackmd.io/@misonou/brew-js-react */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("brew-js"), require("react"), require("react-dom"), (function webpackLoadOptionalExternalModule() { try { return require("react-dom/client"); } catch(e) {} }()), require("zeta-dom"), require("zeta-dom-react"), require("waterpipe"), require("jQuery"));
@@ -214,6 +214,7 @@ __webpack_require__.d(src_namespaceObject, {
214
214
  "useAnimateMixin": () => (useAnimateMixin),
215
215
  "useAnimateSequenceMixin": () => (useAnimateSequenceMixin),
216
216
  "useAppReady": () => (useAppReady),
217
+ "useAppReadyState": () => (useAppReadyState),
217
218
  "useFlyoutMixin": () => (useFlyoutMixin),
218
219
  "useFocusStateMixin": () => (useFocusStateMixin),
219
220
  "useLanguage": () => (useLanguage),
@@ -890,6 +891,11 @@ function renderView() {
890
891
  var views = makeArray(arguments);
891
892
  var rootProps = isFunction(views[0]) ? {} : views.shift();
892
893
  var defaultView = views[0];
894
+ each(views, function (i, v) {
895
+ if (!routeMap.has(v)) {
896
+ throw new Error('Invalid argument to renderView: ' + (isFunction(v) ? v.name : v));
897
+ }
898
+ });
893
899
  views.sort(sortViews);
894
900
  return /*#__PURE__*/external_commonjs_react_commonjs2_react_amd_react_root_React_.createElement(ViewContainer, {
895
901
  rootProps: rootProps,
@@ -952,15 +958,14 @@ definePrototype(ViewState, {
952
958
  }
953
959
  });
954
960
  function useAppReady() {
955
- var sReady = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(false);
956
- var ready = sReady[0],
957
- setReady = sReady[1];
958
- (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
959
- app_app.ready.then(function () {
960
- setReady(true);
961
- });
962
- }, []);
963
- return ready;
961
+ return useAppReadyState().ready;
962
+ }
963
+ function useAppReadyState() {
964
+ var readyState = (0,external_zeta_dom_react_.useObservableProperty)(app_app, 'readyState');
965
+ return {
966
+ ready: readyState === 'ready',
967
+ error: readyState === 'error'
968
+ };
964
969
  }
965
970
  function useRouteParam(name, defaultValue) {
966
971
  var container = useViewContainerState();
@@ -1773,15 +1778,6 @@ function createUseFunction(ctor) {
1773
1778
  };
1774
1779
  }
1775
1780
 
1776
- function disposeMixin(mixin) {
1777
- mixin.disposed = true;
1778
- setImmediate(function () {
1779
- if (mixin.disposed) {
1780
- mixin.dispose();
1781
- }
1782
- });
1783
- }
1784
-
1785
1781
  var useAnimateMixin = createUseFunction(AnimateMixin);
1786
1782
  var useAnimateSequenceMixin = createUseFunction(AnimateSequenceMixin);
1787
1783
  var useFlyoutMixin = createUseFunction(FlyoutMixin);
@@ -1789,14 +1785,9 @@ var useFocusStateMixin = createUseFunction(FocusStateMixin);
1789
1785
  var useLoadingStateMixin = createUseFunction(LoadingStateMixin);
1790
1786
  var useScrollableMixin = createUseFunction(ScrollableMixin);
1791
1787
  function useMixin(ctor) {
1792
- var mixin = (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useState)(function () {
1788
+ return (0,external_zeta_dom_react_.useSingleton)(function () {
1793
1789
  return new ctor();
1794
- })[0].reset();
1795
- (0,external_commonjs_react_commonjs2_react_amd_react_root_React_.useEffect)(function () {
1796
- mixin.disposed = false;
1797
- return disposeMixin.bind(0, mixin);
1798
- }, []);
1799
- return mixin;
1790
+ }).reset();
1800
1791
  }
1801
1792
  function useMixinRef(mixin) {
1802
1793
  return mixin && mixin.getMixin().reset();