@lolyjs/core 0.1.0-alpha.6 → 0.1.0-alpha.9

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/dist/index.cjs CHANGED
@@ -5141,6 +5141,11 @@ var import_react2 = require("react");
5141
5141
  // modules/runtime/client/RouterView.tsx
5142
5142
  var import_jsx_runtime = require("react/jsx-runtime");
5143
5143
  function RouterView({ state }) {
5144
+ console.log("[loly:RouterView] Rendering", {
5145
+ url: state.url,
5146
+ hasRoute: !!state.route,
5147
+ hasComponents: !!state.components
5148
+ });
5144
5149
  if (!state.route) {
5145
5150
  if (state.components === null) {
5146
5151
  return null;
@@ -5152,6 +5157,11 @@ function RouterView({ state }) {
5152
5157
  }
5153
5158
  const { Page, layouts } = state.components;
5154
5159
  const { params, props } = state;
5160
+ console.log("[loly:RouterView] Creating page element", {
5161
+ hasPage: !!Page,
5162
+ layoutsCount: layouts.length,
5163
+ paramsKeys: Object.keys(params)
5164
+ });
5155
5165
  let element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Page, { params, ...props });
5156
5166
  const layoutChain = layouts.slice().reverse();
5157
5167
  for (const Layout of layoutChain) {
@@ -5622,6 +5632,10 @@ function AppShell({
5622
5632
  notFoundRoute,
5623
5633
  errorRoute
5624
5634
  }) {
5635
+ console.log("[loly:AppShell] Component rendering", {
5636
+ url: initialState.url,
5637
+ hasRoute: !!initialState.route
5638
+ });
5625
5639
  const [state, setState] = (0, import_react2.useState)(initialState);
5626
5640
  const handlersRef = (0, import_react2.useRef)({
5627
5641
  setState,
@@ -5630,6 +5644,11 @@ function AppShell({
5630
5644
  errorRoute
5631
5645
  });
5632
5646
  (0, import_react2.useEffect)(() => {
5647
+ console.log("[loly:AppShell] Updating handlersRef", {
5648
+ routesCount: routes.length,
5649
+ hasNotFound: !!notFoundRoute,
5650
+ hasError: !!errorRoute
5651
+ });
5633
5652
  handlersRef.current = {
5634
5653
  setState,
5635
5654
  routes,
@@ -5638,7 +5657,8 @@ function AppShell({
5638
5657
  };
5639
5658
  }, [routes, notFoundRoute, errorRoute]);
5640
5659
  (0, import_react2.useEffect)(() => {
5641
- console.log("[loly:AppShell] Setting up event listeners");
5660
+ const effectId = Math.random().toString(36).substring(7);
5661
+ console.log("[loly:AppShell] Setting up event listeners", { effectId });
5642
5662
  let isMounted = true;
5643
5663
  let listenerCount = 0;
5644
5664
  async function handleNavigate(nextUrl, options) {
@@ -5661,6 +5681,7 @@ function AppShell({
5661
5681
  });
5662
5682
  return () => {
5663
5683
  console.log("[loly:AppShell] Cleaning up event listeners", {
5684
+ effectId,
5664
5685
  wasMounted: isMounted,
5665
5686
  listenersToRemove: listenerCount
5666
5687
  });
@@ -5678,6 +5699,7 @@ function AppShell({
5678
5699
 
5679
5700
  // modules/runtime/client/bootstrap.tsx
5680
5701
  var import_jsx_runtime3 = require("react/jsx-runtime");
5702
+ var __loly_hydrated = false;
5681
5703
  async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute, errorRoute) {
5682
5704
  const isInitialNotFound = initialData?.notFound === true;
5683
5705
  const isInitialError = initialData?.error === true;
@@ -5704,7 +5726,7 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
5704
5726
  initialComponents = await notFoundRoute.load();
5705
5727
  } else {
5706
5728
  console.warn(
5707
- `[client] No route match found for ${initialUrl}. Available routes:`,
5729
+ `[client] No route match found for ${initialUrl}. Routes:`,
5708
5730
  routes.map((r) => r.pattern)
5709
5731
  );
5710
5732
  }
@@ -5718,21 +5740,24 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
5718
5740
  };
5719
5741
  }
5720
5742
  function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
5721
- console.log("[loly:runtime] bootstrapClient called", {
5722
- routesCount: routes.length,
5723
- hasNotFound: !!notFoundRoute,
5724
- hasError: !!errorRoute
5725
- });
5743
+ if (__loly_hydrated) {
5744
+ console.warn("[loly:runtime] bootstrapClient SKIPPED (already hydrated)");
5745
+ return;
5746
+ }
5747
+ __loly_hydrated = true;
5748
+ console.log("[loly:runtime] bootstrapClient START");
5726
5749
  (async function bootstrap() {
5727
5750
  const container = document.getElementById(APP_CONTAINER_ID2);
5728
5751
  const initialData = getWindowData();
5729
5752
  console.log("[loly:runtime] bootstrap starting", {
5730
5753
  hasContainer: !!container,
5731
- containerId: APP_CONTAINER_ID2,
5732
- hasInitialData: !!initialData
5754
+ hasInitialData: !!initialData,
5755
+ containerId: APP_CONTAINER_ID2
5733
5756
  });
5734
5757
  if (!container) {
5735
- console.error(`[loly:runtime] Container #${APP_CONTAINER_ID2} not found for hydration`);
5758
+ console.error(
5759
+ `[loly:runtime] Container #${APP_CONTAINER_ID2} not found.`
5760
+ );
5736
5761
  return;
5737
5762
  }
5738
5763
  const initialUrl = window.location.pathname + window.location.search;
@@ -5766,13 +5791,9 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
5766
5791
  }
5767
5792
  )
5768
5793
  );
5769
- console.log("[loly:runtime] React app hydrated successfully");
5794
+ console.log("[loly:runtime] Hydrated successfully");
5770
5795
  } catch (error) {
5771
- console.error(
5772
- "[loly:runtime] Error loading initial route components for",
5773
- initialUrl,
5774
- error
5775
- );
5796
+ console.error("[loly:runtime] Error during hydration:", error);
5776
5797
  window.location.reload();
5777
5798
  }
5778
5799
  })();