@ereo/client 0.2.13 → 0.2.14

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.js CHANGED
@@ -6,6 +6,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
8
 
9
+ // src/islands.ts
10
+ import { createElement } from "react";
11
+
9
12
  // src/hydration.ts
10
13
  function parseHydrationDirective(props) {
11
14
  if (props["client:load"]) {
@@ -174,7 +177,7 @@ class IslandRegistry {
174
177
  var islandRegistry = new IslandRegistry;
175
178
  async function hydrateIslands() {
176
179
  const { hydrateRoot } = await import("react-dom/client");
177
- const { createElement } = await import("react");
180
+ const { createElement: createElement2 } = await import("react");
178
181
  const islandElements = document.querySelectorAll("[data-island]");
179
182
  for (const element of islandElements) {
180
183
  const islandId = element.getAttribute("data-island");
@@ -202,7 +205,7 @@ async function hydrateIslands() {
202
205
  const triggerCleanup = createHydrationTrigger(strategy, element, () => {
203
206
  if (islandRegistry.isHydrated(islandId))
204
207
  return;
205
- const root = hydrateRoot(element, createElement(component, props));
208
+ const root = hydrateRoot(element, createElement2(component, props));
206
209
  islandRegistry.markHydrated(islandId);
207
210
  islandRegistry.setCleanup(islandId, () => {
208
211
  triggerCleanup();
@@ -232,20 +235,13 @@ function createIsland(component, name) {
232
235
  const { strategy, media } = parseHydrationDirective(props);
233
236
  const cleanProps = stripHydrationProps(props);
234
237
  const islandId = generateIslandId();
235
- return {
236
- type: "div",
237
- props: {
238
- "data-island": islandId,
239
- "data-component": name,
240
- "data-props": JSON.stringify(cleanProps),
241
- "data-strategy": strategy,
242
- "data-media": media || undefined,
243
- children: {
244
- type: component,
245
- props: cleanProps
246
- }
247
- }
248
- };
238
+ return createElement("div", {
239
+ "data-island": islandId,
240
+ "data-component": name,
241
+ "data-props": JSON.stringify(cleanProps),
242
+ "data-strategy": strategy,
243
+ "data-media": media || undefined
244
+ }, createElement(component, cleanProps));
249
245
  };
250
246
  }
251
247
  function initializeIslands() {
@@ -682,7 +678,7 @@ import {
682
678
  useState as useState3,
683
679
  useCallback as useCallback2,
684
680
  useMemo as useMemo2,
685
- createElement as createElement2
681
+ createElement as createElement3
686
682
  } from "react";
687
683
 
688
684
  // src/matches.ts
@@ -691,7 +687,7 @@ import {
691
687
  useContext as useContext2,
692
688
  useState as useState2,
693
689
  useMemo,
694
- createElement
690
+ createElement as createElement2
695
691
  } from "react";
696
692
  var MatchesContext = createContext2(null);
697
693
  function useMatches() {
@@ -707,7 +703,7 @@ function MatchesProvider({
707
703
  }) {
708
704
  const [matches, setMatches] = useState2(initialMatches);
709
705
  const value = useMemo(() => ({ matches, setMatches }), [matches]);
710
- return createElement(MatchesContext.Provider, { value }, children);
706
+ return createElement2(MatchesContext.Provider, { value }, children);
711
707
  }
712
708
 
713
709
  // src/hooks.ts
@@ -811,7 +807,7 @@ function LoaderDataProvider({
811
807
  }) {
812
808
  const [data, setData] = useState3(initialData);
813
809
  const value = useMemo2(() => ({ data, setData }), [data]);
814
- return createElement2(LoaderDataContext.Provider, { value }, children);
810
+ return createElement3(LoaderDataContext.Provider, { value }, children);
815
811
  }
816
812
  function ActionDataProvider({
817
813
  children,
@@ -822,7 +818,7 @@ function ActionDataProvider({
822
818
  setData(undefined);
823
819
  }, []);
824
820
  const value = useMemo2(() => ({ data, setData, clearData }), [data, clearData]);
825
- return createElement2(ActionDataContext.Provider, { value }, children);
821
+ return createElement3(ActionDataContext.Provider, { value }, children);
826
822
  }
827
823
  var defaultNavigationState = {
828
824
  status: "idle"
@@ -857,7 +853,7 @@ function NavigationProvider({
857
853
  startSubmitting,
858
854
  complete
859
855
  }), [state, startLoading, startSubmitting, complete]);
860
- return createElement2(NavigationContext.Provider, { value }, children);
856
+ return createElement3(NavigationContext.Provider, { value }, children);
861
857
  }
862
858
  function ErrorProvider({
863
859
  children,
@@ -868,7 +864,7 @@ function ErrorProvider({
868
864
  setError(undefined);
869
865
  }, []);
870
866
  const value = useMemo2(() => ({ error, setError, clearError }), [error, clearError]);
871
- return createElement2(ErrorContext.Provider, { value }, children);
867
+ return createElement3(ErrorContext.Provider, { value }, children);
872
868
  }
873
869
  function ParamsProvider({
874
870
  children,
@@ -876,7 +872,7 @@ function ParamsProvider({
876
872
  }) {
877
873
  const [params, setParams] = useState3(initialParams);
878
874
  const value = useMemo2(() => ({ params, setParams }), [params]);
879
- return createElement2(ParamsContext.Provider, { value }, children);
875
+ return createElement3(ParamsContext.Provider, { value }, children);
880
876
  }
881
877
  var defaultLocation = {
882
878
  pathname: "/",
@@ -891,7 +887,7 @@ function LocationProvider({
891
887
  }) {
892
888
  const [location, setLocation] = useState3(initialLocation);
893
889
  const value = useMemo2(() => ({ location, setLocation }), [location]);
894
- return createElement2(LocationContext.Provider, { value }, children);
890
+ return createElement3(LocationContext.Provider, { value }, children);
895
891
  }
896
892
  function EreoProvider({
897
893
  children,
@@ -903,7 +899,7 @@ function EreoProvider({
903
899
  location,
904
900
  matches
905
901
  }) {
906
- return createElement2(MatchesProvider, { initialMatches: matches, children: createElement2(LocationProvider, { initialLocation: location, children: createElement2(ParamsProvider, { initialParams: params, children: createElement2(ErrorProvider, { initialError: error, children: createElement2(NavigationProvider, { initialState: navigationState, children: createElement2(ActionDataProvider, { initialData: actionData, children: createElement2(LoaderDataProvider, { initialData: loaderData, children }) }) }) }) }) }) });
902
+ return createElement3(MatchesProvider, { initialMatches: matches, children: createElement3(LocationProvider, { initialLocation: location, children: createElement3(ParamsProvider, { initialParams: params, children: createElement3(ErrorProvider, { initialError: error, children: createElement3(NavigationProvider, { initialState: navigationState, children: createElement3(ActionDataProvider, { initialData: actionData, children: createElement3(LoaderDataProvider, { initialData: loaderData, children }) }) }) }) }) }) });
907
903
  }
908
904
  function useLoaderDataContext() {
909
905
  const context = useContext3(LoaderDataContext);
@@ -1528,7 +1524,7 @@ async function preloadRoute(path, options) {
1528
1524
  } catch {}
1529
1525
  }
1530
1526
  // src/form.ts
1531
- import { createElement as createElement3, useCallback as useCallback5, useRef as useRef3, useState as useState6, useEffect as useEffect4, useContext as useContext4, createContext as createContext4 } from "react";
1527
+ import { createElement as createElement4, useCallback as useCallback5, useRef as useRef3, useState as useState6, useEffect as useEffect4, useContext as useContext4, createContext as createContext4 } from "react";
1532
1528
  var FormContext = createContext4(null);
1533
1529
  function FormProvider({
1534
1530
  children,
@@ -1536,7 +1532,7 @@ function FormProvider({
1536
1532
  }) {
1537
1533
  const [actionData, setActionData] = useState6(initialActionData);
1538
1534
  const [state, setState] = useState6("idle");
1539
- return createElement3(FormContext.Provider, { value: { actionData, state, setActionData, setState } }, children);
1535
+ return createElement4(FormContext.Provider, { value: { actionData, state, setActionData, setState } }, children);
1540
1536
  }
1541
1537
  function useFormContext() {
1542
1538
  return useContext4(FormContext);
@@ -1694,14 +1690,14 @@ function Form({
1694
1690
  }
1695
1691
  }, [method, resolvedAction, onSubmitStart, onSubmitEnd, replace, preventScrollReset, encType, fetcherKey, formContext, onSubmit]);
1696
1692
  const formMethod = method.toLowerCase() === "get" ? "get" : "post";
1697
- return createElement3("form", {
1693
+ return createElement4("form", {
1698
1694
  ref: formRef,
1699
1695
  method: formMethod,
1700
1696
  action: resolvedAction,
1701
1697
  encType,
1702
1698
  onSubmit: handleSubmit,
1703
1699
  ...props
1704
- }, method !== "get" && method !== "post" ? createElement3("input", {
1700
+ }, method !== "get" && method !== "post" ? createElement4("input", {
1705
1701
  type: "hidden",
1706
1702
  name: "_method",
1707
1703
  value: method.toUpperCase()
@@ -2454,7 +2450,7 @@ class RouteError extends Error {
2454
2450
  import {
2455
2451
  createContext as createContext5,
2456
2452
  useContext as useContext7,
2457
- createElement as createElement4
2453
+ createElement as createElement5
2458
2454
  } from "react";
2459
2455
  var OutletElementContext = createContext5(null);
2460
2456
  var OutletDataContext = createContext5(null);
@@ -2465,7 +2461,7 @@ function Outlet({ context } = {}) {
2465
2461
  }
2466
2462
  const child = elementCtx.element;
2467
2463
  if (context !== undefined) {
2468
- return createElement4(OutletDataContext.Provider, { value: { data: context } }, child);
2464
+ return createElement5(OutletDataContext.Provider, { value: { data: context } }, child);
2469
2465
  }
2470
2466
  return child;
2471
2467
  }
@@ -2482,9 +2478,9 @@ function OutletProvider({
2482
2478
  context
2483
2479
  }) {
2484
2480
  const elementValue = { element };
2485
- let tree = createElement4(OutletElementContext.Provider, { value: elementValue }, children);
2481
+ let tree = createElement5(OutletElementContext.Provider, { value: elementValue }, children);
2486
2482
  if (context !== undefined) {
2487
- tree = createElement4(OutletDataContext.Provider, { value: { data: context } }, tree);
2483
+ tree = createElement5(OutletDataContext.Provider, { value: { data: context } }, tree);
2488
2484
  }
2489
2485
  return tree;
2490
2486
  }
@@ -2749,7 +2745,7 @@ async function resolveAwait(deferred) {
2749
2745
  return deferred.promise;
2750
2746
  }
2751
2747
  // src/scroll-restoration.ts
2752
- import { useEffect as useEffect8, useRef as useRef6, createElement as createElement5 } from "react";
2748
+ import { useEffect as useEffect8, useRef as useRef6, createElement as createElement6 } from "react";
2753
2749
  var memoryStore = new Map;
2754
2750
  var MAX_SCROLL_ENTRIES = 100;
2755
2751
  function getScrollPosition(key, storageKey) {
@@ -2836,7 +2832,7 @@ function ScrollRestoration({
2836
2832
  };
2837
2833
  }, [getKey, storageKey]);
2838
2834
  if (nonce !== undefined) {
2839
- return createElement5("script", {
2835
+ return createElement6("script", {
2840
2836
  nonce,
2841
2837
  suppressHydrationWarning: true,
2842
2838
  dangerouslySetInnerHTML: {
package/dist/islands.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Selective hydration for interactive components.
5
5
  * Static content stays static, only islands get hydrated.
6
6
  */
7
- import type { ComponentType } from 'react';
7
+ import { type ComponentType } from 'react';
8
8
  import type { HydrationStrategy } from '@ereo/core';
9
9
  import { type HydrationProps } from './hydration';
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"islands.d.ts","sourceRoot":"","sources":["../src/islands.ts"],"names":[],"mappings":"AAAA;;;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sB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CA+DpD;AAOD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAEzF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,CAE/E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,GAC7C,IAAI,CAIN;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,IAAI,EAAE,MAAM,GACX,aAAa,CAAC,CAAC,GAAG,cAAc,CAAC,CAyBnC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAQxC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ereo/client",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "license": "MIT",
5
5
  "author": "Ereo Team",
6
6
  "homepage": "https://ereojs.github.io/ereoJS",
@@ -32,7 +32,7 @@
32
32
  "typecheck": "tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@ereo/core": "^0.2.13"
35
+ "@ereo/core": "^0.2.14"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/react": "^18.2.0",