minimal-piral 1.3.0-beta.6062 → 1.3.0-beta.6067

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.
@@ -876,51 +876,63 @@ __webpack_require__.r(__webpack_exports__);
876
876
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js");
877
877
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
878
878
  /* harmony import */ var _hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../hooks */ "../../framework/piral-core/esm/hooks/globalState.js");
879
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils */ "../../framework/piral-core/esm/utils/routes.js");
880
- /* harmony import */ var _app_codegen__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../app.codegen */ "../../framework/piral-core/app.codegen");
881
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
882
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
883
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
884
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
879
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils */ "../../framework/piral-core/esm/utils/routes.js");
880
+ /* harmony import */ var _app_codegen__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../app.codegen */ "../../framework/piral-core/app.codegen");
885
881
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
886
882
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
887
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
888
883
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
889
884
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
885
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
886
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
887
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
890
888
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
889
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
890
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
891
891
 
892
892
 
893
893
 
894
894
 
895
895
 
896
- function useRoutes() {
896
+ function useShellRoutes() {
897
897
  var routes = (0,_hooks__WEBPACK_IMPORTED_MODULE_1__.useGlobalState)(function (s) {
898
898
  return s.routes;
899
899
  });
900
+ return react__WEBPACK_IMPORTED_MODULE_0__.useMemo(function () {
901
+ return Object.entries(routes).map(function (_ref) {
902
+ var _ref2 = _slicedToArray(_ref, 2),
903
+ path = _ref2[0],
904
+ Component = _ref2[1];
905
+ return {
906
+ path: path,
907
+ Component: Component,
908
+ meta: (Component === null || Component === void 0 ? void 0 : Component.meta) || {},
909
+ matcher: (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createRouteMatcher)(path)
910
+ };
911
+ });
912
+ }, [routes]);
913
+ }
914
+ function usePiletRoutes() {
900
915
  var pages = (0,_hooks__WEBPACK_IMPORTED_MODULE_1__.useGlobalState)(function (s) {
901
916
  return s.registry.pages;
902
917
  });
903
- return (0,_app_codegen__WEBPACK_IMPORTED_MODULE_2__.useRouteFilter)([].concat(_toConsumableArray(Object.entries(routes).map(function (_ref) {
904
- var _ref2 = _slicedToArray(_ref, 2),
905
- path = _ref2[0],
906
- Component = _ref2[1];
907
- return {
908
- path: path,
909
- Component: Component,
910
- meta: {},
911
- matcher: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createRouteMatcher)(path)
912
- };
913
- })), _toConsumableArray(Object.entries(pages).map(function (_ref3) {
914
- var _ref4 = _slicedToArray(_ref3, 2),
915
- path = _ref4[0],
916
- entry = _ref4[1];
917
- return {
918
- path: path,
919
- Component: entry.component,
920
- meta: entry.meta,
921
- matcher: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createRouteMatcher)(path)
922
- };
923
- }))));
918
+ return react__WEBPACK_IMPORTED_MODULE_0__.useMemo(function () {
919
+ return Object.entries(pages).map(function (_ref3) {
920
+ var _ref4 = _slicedToArray(_ref3, 2),
921
+ path = _ref4[0],
922
+ entry = _ref4[1];
923
+ return {
924
+ path: path,
925
+ Component: entry.component,
926
+ meta: entry.meta,
927
+ matcher: (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createRouteMatcher)(path)
928
+ };
929
+ });
930
+ }, [pages]);
931
+ }
932
+ function useRoutes() {
933
+ var shellRoutes = useShellRoutes();
934
+ var piletRoutes = usePiletRoutes();
935
+ return (0,_app_codegen__WEBPACK_IMPORTED_MODULE_3__.useRouteFilter)([].concat(_toConsumableArray(shellRoutes), _toConsumableArray(piletRoutes)));
924
936
  }
925
937
  /**
926
938
  * The component for defining the exclusive routes to be used.
@@ -2211,11 +2223,22 @@ if (typeof window !== 'undefined' && 'customElements' in window) {
2211
2223
  * This is a virtual element to render children defined in React / by Piral in other
2212
2224
  * frameworks.
2213
2225
  *
2226
+ * Internally, you can use the assignContent function to populate the content to be
2227
+ * rendered once the element is attached / mounted in the DOM.
2228
+ *
2214
2229
  * Usage:
2215
2230
  *
2216
2231
  * ```
2217
2232
  * <piral-content cid="123"></piral-content>
2218
2233
  * ```
2234
+ *
2235
+ * where you'd
2236
+ *
2237
+ * ```
2238
+ * window.assignContent("123", myReactContent)
2239
+ * ```
2240
+ *
2241
+ * beforehand.
2219
2242
  */
2220
2243
  var PiralContent = /*#__PURE__*/function (_HTMLElement4) {
2221
2244
  _inherits(PiralContent, _HTMLElement4);
@@ -3630,12 +3653,12 @@ function installPiralDebug(options) {
3630
3653
  debug: debugApiVersion,
3631
3654
  instance: {
3632
3655
  name: "minimal-piral",
3633
- version: "1.3.0-beta.6062",
3656
+ version: "1.3.0-beta.6067",
3634
3657
  dependencies: "tslib,react,react-dom,react-router,react-router-dom"
3635
3658
  },
3636
3659
  build: {
3637
- date: "2023-10-09T00:01:51.533Z",
3638
- cli: "1.3.0-beta.6062",
3660
+ date: "2023-10-09T11:06:00.715Z",
3661
+ cli: "1.3.0-beta.6067",
3639
3662
  compat: "1"
3640
3663
  }
3641
3664
  };
@@ -44528,4 +44551,4 @@ var instance = (0,piral_core__WEBPACK_IMPORTED_MODULE_2__.createInstance)({
44528
44551
 
44529
44552
  /******/ })()
44530
44553
  ;
44531
- //# sourceMappingURL=index.b7f3e2.js.map
44554
+ //# sourceMappingURL=index.f4ba94.js.map