bunja 2.0.0-alpha.2 → 2.0.0-alpha.3

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/bunja.ts CHANGED
@@ -94,12 +94,7 @@ export class BunjaStore {
94
94
  this.#getScopeInstance(scope, readScope(scope)),
95
95
  ]),
96
96
  );
97
- const bunjaInstanceMap = new Map(
98
- bunja.relatedBunjas.map((relatedBunja) => [
99
- relatedBunja,
100
- this.#getBunjaInstance(relatedBunja, scopeInstanceMap),
101
- ]),
102
- );
97
+ const bunjaInstanceMap = new Map();
103
98
  bunjaFn.use = <T>(dep: Dep<T>) => {
104
99
  if (dep instanceof Bunja) {
105
100
  return bunjaInstanceMap.get(dep as Bunja<unknown>)!.value as T;
@@ -109,6 +104,12 @@ export class BunjaStore {
109
104
  }
110
105
  throw new Error("`bunja.use` can only be used with Bunja or Scope.");
111
106
  };
107
+ for (const relatedBunja of bunja.relatedBunjas) {
108
+ bunjaInstanceMap.set(
109
+ relatedBunja,
110
+ this.#getBunjaInstance(relatedBunja, scopeInstanceMap),
111
+ );
112
+ }
112
113
  const bunjaInstance = this.#getBunjaInstance(bunja, scopeInstanceMap);
113
114
  return { bunjaInstance, bunjaInstanceMap, scopeInstanceMap };
114
115
  }
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disjukr/bunja",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.3",
4
4
  "license": "Zlib",
5
5
  "exports": {
6
6
  ".": "./bunja.ts",
@@ -55,12 +55,13 @@ var BunjaStore = class {
55
55
  }
56
56
  #getBaked(bunja$1, readScope) {
57
57
  const scopeInstanceMap = new Map(bunja$1.relatedScopes.map((scope) => [scope, this.#getScopeInstance(scope, readScope(scope))]));
58
- const bunjaInstanceMap = new Map(bunja$1.relatedBunjas.map((relatedBunja) => [relatedBunja, this.#getBunjaInstance(relatedBunja, scopeInstanceMap)]));
58
+ const bunjaInstanceMap = new Map();
59
59
  bunjaFn.use = (dep) => {
60
60
  if (dep instanceof Bunja) return bunjaInstanceMap.get(dep).value;
61
61
  if (dep instanceof Scope) return scopeInstanceMap.get(dep).value;
62
62
  throw new Error("`bunja.use` can only be used with Bunja or Scope.");
63
63
  };
64
+ for (const relatedBunja of bunja$1.relatedBunjas) bunjaInstanceMap.set(relatedBunja, this.#getBunjaInstance(relatedBunja, scopeInstanceMap));
64
65
  const bunjaInstance = this.#getBunjaInstance(bunja$1, scopeInstanceMap);
65
66
  return {
66
67
  bunjaInstance,
@@ -56,12 +56,13 @@ var BunjaStore = class {
56
56
  }
57
57
  #getBaked(bunja$1, readScope) {
58
58
  const scopeInstanceMap = new Map(bunja$1.relatedScopes.map((scope) => [scope, this.#getScopeInstance(scope, readScope(scope))]));
59
- const bunjaInstanceMap = new Map(bunja$1.relatedBunjas.map((relatedBunja) => [relatedBunja, this.#getBunjaInstance(relatedBunja, scopeInstanceMap)]));
59
+ const bunjaInstanceMap = new Map();
60
60
  bunjaFn.use = (dep) => {
61
61
  if (dep instanceof Bunja) return bunjaInstanceMap.get(dep).value;
62
62
  if (dep instanceof Scope) return scopeInstanceMap.get(dep).value;
63
63
  throw new Error("`bunja.use` can only be used with Bunja or Scope.");
64
64
  };
65
+ for (const relatedBunja of bunja$1.relatedBunjas) bunjaInstanceMap.set(relatedBunja, this.#getBunjaInstance(relatedBunja, scopeInstanceMap));
65
66
  const bunjaInstance = this.#getBunjaInstance(bunja$1, scopeInstanceMap);
66
67
  return {
67
68
  bunjaInstance,
package/dist/bunja.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const require_bunja = require('./bunja-bUA1rGXy.cjs');
2
+ const require_bunja = require('./bunja-RF4EuS_C.cjs');
3
3
 
4
4
  exports.Bunja = require_bunja.Bunja
5
5
  exports.BunjaStore = require_bunja.BunjaStore
package/dist/bunja.js CHANGED
@@ -1,3 +1,3 @@
1
- import { Bunja, BunjaStore, Scope, bunja, createBunjaStore, createScope } from "./bunja-wcx846sL.js";
1
+ import { Bunja, BunjaStore, Scope, bunja, createBunjaStore, createScope } from "./bunja-DGNjfjPa.js";
2
2
 
3
3
  export { Bunja, BunjaStore, Scope, bunja, createBunjaStore, createScope };
package/dist/react.cjs CHANGED
@@ -22,10 +22,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  }) : target, mod));
23
23
 
24
24
  //#endregion
25
- const require_bunja = require('./bunja-bUA1rGXy.cjs');
25
+ const require_bunja = require('./bunja-RF4EuS_C.cjs');
26
26
  const { createContext, createElement, use, useEffect, useState } = __toESM(require("react"));
27
27
 
28
28
  //#region react.ts
29
+ "use client";
29
30
  const BunjaStoreContext = createContext(require_bunja.createBunjaStore());
30
31
  function BunjaStoreProvider({ children }) {
31
32
  const [value] = useState(require_bunja.createBunjaStore);
package/dist/react.js CHANGED
@@ -1,7 +1,8 @@
1
- import { createBunjaStore, createScope } from "./bunja-wcx846sL.js";
1
+ import { createBunjaStore, createScope } from "./bunja-DGNjfjPa.js";
2
2
  import { createContext, createElement, use, useEffect, useState } from "react";
3
3
 
4
4
  //#region react.ts
5
+ "use client";
5
6
  const BunjaStoreContext = createContext(createBunjaStore());
6
7
  function BunjaStoreProvider({ children }) {
7
8
  const [value] = useState(createBunjaStore);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bunja",
3
3
  "type": "module",
4
- "version": "2.0.0-alpha.2",
4
+ "version": "2.0.0-alpha.3",
5
5
  "description": "State Lifetime Manager",
6
6
  "main": "dist/bunja.cjs",
7
7
  "module": "dist/bunja.js",
package/react.ts CHANGED
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import {
2
4
  type Context,
3
5
  createContext,