@sladg/apex-state 3.0.4 → 3.0.5

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
@@ -852,6 +852,11 @@ var is = {
852
852
  var pathCache = /* @__PURE__ */ new Map();
853
853
  var MAX_CACHE_SIZE = 1e3;
854
854
  var getPathParts = (path) => {
855
+ if (typeof path !== "string") {
856
+ throw new TypeError(
857
+ `[apex-state] Path must be a string, received ${typeof path}: ${JSON.stringify(path)}. Paths must be dot-notation strings like "user.email" or "items.0.name".`
858
+ );
859
+ }
855
860
  let parts = pathCache.get(path);
856
861
  if (!parts) {
857
862
  parts = path.split(".");
@@ -2660,7 +2665,6 @@ var createProvider = (storeConfig) => {
2660
2665
  initialState: rawInitialState,
2661
2666
  children
2662
2667
  }) => {
2663
- const [wasmReady, setWasmReady] = useState(isLegacy || isWasmLoaded());
2664
2668
  const prepared = useMemo(
2665
2669
  () => prepareInitialState(rawInitialState),
2666
2670
  // Only initialize once - ignore changes to initialState after mount
@@ -2693,35 +2697,37 @@ var createProvider = (storeConfig) => {
2693
2697
  _debug: debugTrack ? ref(debugTrack) : null
2694
2698
  };
2695
2699
  }, []);
2700
+ const [ready, setReady] = useState(
2701
+ () => isLegacy || store._internal.pipeline !== null
2702
+ );
2696
2703
  useEffect(() => {
2697
2704
  if (isLegacy) return;
2698
- if (isWasmLoaded()) {
2705
+ let cancelled = false;
2706
+ const ensurePipeline = () => {
2707
+ if (cancelled) return;
2699
2708
  if (!store._internal.pipeline) {
2700
2709
  initPipeline(
2701
2710
  store._internal,
2702
2711
  prepared.initialState
2703
2712
  );
2704
2713
  }
2705
- return;
2714
+ setReady(true);
2715
+ };
2716
+ if (isWasmLoaded()) {
2717
+ ensurePipeline();
2718
+ } else {
2719
+ loadWasm2().then(ensurePipeline).catch((error) => {
2720
+ console.error("[apex-state] Failed to load WASM:", error);
2721
+ });
2706
2722
  }
2707
- loadWasm2().then(() => {
2708
- initPipeline(
2709
- store._internal,
2710
- prepared.initialState
2711
- );
2712
- setWasmReady(true);
2713
- }).catch((error) => {
2714
- console.error("[apex-state] Failed to load WASM:", error);
2715
- throw error;
2716
- });
2717
- }, []);
2718
- useEffect(() => {
2719
2723
  return () => {
2724
+ cancelled = true;
2720
2725
  store._internal.pipeline?.destroy();
2721
2726
  store._internal.pipeline = null;
2727
+ setReady(false);
2722
2728
  };
2723
2729
  }, []);
2724
- if (!wasmReady) {
2730
+ if (!ready) {
2725
2731
  return null;
2726
2732
  }
2727
2733
  return /* @__PURE__ */ jsx(