bunja 2.0.0-alpha.9 → 2.0.0

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/README.md CHANGED
@@ -19,7 +19,7 @@ depended on somewhere in the render tree and ends when all dependencies
19
19
  disappear.
20
20
 
21
21
  Therefore, when writing a state to manage a WebSocket, you only need to create a
22
- function that establishes the WebSocket connection and an dispose handler that
22
+ function that establishes the WebSocket connection and a disposal handler that
23
23
  terminates the connection.\
24
24
  The library automatically tracks the actual usage period and calls the init and
25
25
  dispose as needed.
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disjukr/bunja",
3
- "version": "2.0.0-alpha.9",
3
+ "version": "2.0.0",
4
4
  "license": "Zlib",
5
5
  "exports": {
6
6
  ".": "./bunja.ts",
@@ -108,14 +108,14 @@ var BunjaStore = class BunjaStore {
108
108
  const bunjaInstanceMap = /* @__PURE__ */ new Map();
109
109
  const scopeInstanceMap = /* @__PURE__ */ new Map();
110
110
  function getUse(map, addDep, getInstance) {
111
- return (dep) => {
111
+ return ((dep) => {
112
112
  const d = dep;
113
113
  addDep(d);
114
114
  if (map.has(d)) return map.get(d).value;
115
115
  const instance = getInstance(d);
116
116
  map.set(d, instance);
117
117
  return instance.value;
118
- };
118
+ });
119
119
  }
120
120
  const useScope = getUse(scopeInstanceMap, (dep) => this.#bakingContext.currentBunja.addScope(dep), (dep) => this.#getScopeInstance(dep, readScope(dep)));
121
121
  const useBunja = getUse(bunjaInstanceMap, (dep) => this.#bakingContext.currentBunja.addParent(dep), (dep) => {
@@ -107,14 +107,14 @@ var BunjaStore = class BunjaStore {
107
107
  const bunjaInstanceMap = /* @__PURE__ */ new Map();
108
108
  const scopeInstanceMap = /* @__PURE__ */ new Map();
109
109
  function getUse(map, addDep, getInstance) {
110
- return (dep) => {
110
+ return ((dep) => {
111
111
  const d = dep;
112
112
  addDep(d);
113
113
  if (map.has(d)) return map.get(d).value;
114
114
  const instance = getInstance(d);
115
115
  map.set(d, instance);
116
116
  return instance.value;
117
- };
117
+ });
118
118
  }
119
119
  const useScope = getUse(scopeInstanceMap, (dep) => this.#bakingContext.currentBunja.addScope(dep), (dep) => this.#getScopeInstance(dep, readScope(dep)));
120
120
  const useBunja = getUse(bunjaInstanceMap, (dep) => this.#bakingContext.currentBunja.addParent(dep), (dep) => {
package/dist/bunja.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_bunja = require('./bunja-DO4Cr7x-.cjs');
1
+ const require_bunja = require('./bunja-CaephaLd.cjs');
2
2
 
3
3
  exports.Bunja = require_bunja.Bunja;
4
4
  exports.BunjaStore = require_bunja.BunjaStore;
package/dist/bunja.js CHANGED
@@ -1,3 +1,3 @@
1
- import { Bunja, BunjaStore, Scope, bunja, createBunjaStore, createReadScopeFn, createScope, delayUnmount } from "./bunja-DxIUFo_M.js";
1
+ import { Bunja, BunjaStore, Scope, bunja, createBunjaStore, createReadScopeFn, createScope, delayUnmount } from "./bunja-EJqDbU0A.js";
2
2
 
3
3
  export { Bunja, BunjaStore, Scope, bunja, createBunjaStore, createReadScopeFn, createScope, delayUnmount };
package/dist/react.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  const require_chunk = require('./chunk-CUT6urMc.cjs');
5
- const require_bunja = require('./bunja-DO4Cr7x-.cjs');
5
+ const require_bunja = require('./bunja-CaephaLd.cjs');
6
6
  const react = require_chunk.__toESM(require("react"));
7
7
 
8
8
  //#region react.ts
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
 
4
- import { createBunjaStore, createReadScopeFn, createScope, delayUnmount } from "./bunja-DxIUFo_M.js";
4
+ import { createBunjaStore, createReadScopeFn, createScope, delayUnmount } from "./bunja-EJqDbU0A.js";
5
5
  import { createContext, createElement, use, useEffect, useMemo, useState } from "react";
6
6
 
7
7
  //#region react.ts
package/dist/solid.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_bunja = require('./bunja-DO4Cr7x-.cjs');
2
+ const require_bunja = require('./bunja-CaephaLd.cjs');
3
3
  const solid_js = require_chunk.__toESM(require("solid-js"));
4
4
 
5
5
  //#region solid.ts
@@ -36,8 +36,11 @@ const defaultReadScope = (scope) => {
36
36
  };
37
37
  function useBunja(bunja, scopeValuePairs) {
38
38
  const store = (0, solid_js.useContext)(BunjaStoreContext);
39
- const readScope = scopeValuePairs ? require_bunja.createReadScopeFn(scopeValuePairs, defaultReadScope) : defaultReadScope;
40
- const entry = (0, solid_js.createMemo)(() => store.get(access(bunja), readScope));
39
+ const readScope = (0, solid_js.createMemo)(() => {
40
+ const pairs = access(scopeValuePairs);
41
+ return pairs ? require_bunja.createReadScopeFn(pairs, defaultReadScope) : defaultReadScope;
42
+ });
43
+ const entry = (0, solid_js.createMemo)(() => store.get(access(bunja), readScope()));
41
44
  (0, solid_js.createEffect)(() => {
42
45
  const cleanup = entry().mount();
43
46
  (0, solid_js.onCleanup)(() => setTimeout(cleanup));
package/dist/solid.d.cts CHANGED
@@ -9,6 +9,6 @@ declare function BunjaStoreProvider(props: ParentProps): JSX.Element;
9
9
  declare const scopeContextMap: Map<Scope<unknown>, Context<MaybeAccessor<unknown>>>;
10
10
  declare function bindScope<T>(scope: Scope<T>, context: Context<MaybeAccessor<T>>): void;
11
11
  declare function createScopeFromContext<T>(context: Context<T>, hash?: HashFn<AccessedValue<T>>): Scope<AccessedValue<T>>;
12
- declare function useBunja<T>(bunja: MaybeAccessor<Bunja<T>>, scopeValuePairs?: ScopeValuePair<any>[]): Accessor<T>;
12
+ declare function useBunja<T>(bunja: MaybeAccessor<Bunja<T>>, scopeValuePairs?: MaybeAccessor<ScopeValuePair<any>[]>): Accessor<T>;
13
13
  //#endregion
14
14
  export { BunjaStoreContext, BunjaStoreProvider, bindScope, createScopeFromContext, scopeContextMap, useBunja };
package/dist/solid.d.ts CHANGED
@@ -9,6 +9,6 @@ declare function BunjaStoreProvider(props: ParentProps): JSX.Element;
9
9
  declare const scopeContextMap: Map<Scope<unknown>, Context<MaybeAccessor<unknown>>>;
10
10
  declare function bindScope<T>(scope: Scope<T>, context: Context<MaybeAccessor<T>>): void;
11
11
  declare function createScopeFromContext<T>(context: Context<T>, hash?: HashFn<AccessedValue<T>>): Scope<AccessedValue<T>>;
12
- declare function useBunja<T>(bunja: MaybeAccessor<Bunja<T>>, scopeValuePairs?: ScopeValuePair<any>[]): Accessor<T>;
12
+ declare function useBunja<T>(bunja: MaybeAccessor<Bunja<T>>, scopeValuePairs?: MaybeAccessor<ScopeValuePair<any>[]>): Accessor<T>;
13
13
  //#endregion
14
14
  export { BunjaStoreContext, BunjaStoreProvider, bindScope, createScopeFromContext, scopeContextMap, useBunja };
package/dist/solid.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createBunjaStore, createReadScopeFn, createScope } from "./bunja-DxIUFo_M.js";
1
+ import { createBunjaStore, createReadScopeFn, createScope } from "./bunja-EJqDbU0A.js";
2
2
  import { createComponent, createContext, createEffect, createMemo, createRoot, getOwner, onCleanup, useContext } from "solid-js";
3
3
 
4
4
  //#region solid.ts
@@ -35,8 +35,11 @@ const defaultReadScope = (scope) => {
35
35
  };
36
36
  function useBunja(bunja, scopeValuePairs) {
37
37
  const store = useContext(BunjaStoreContext);
38
- const readScope = scopeValuePairs ? createReadScopeFn(scopeValuePairs, defaultReadScope) : defaultReadScope;
39
- const entry = createMemo(() => store.get(access(bunja), readScope));
38
+ const readScope = createMemo(() => {
39
+ const pairs = access(scopeValuePairs);
40
+ return pairs ? createReadScopeFn(pairs, defaultReadScope) : defaultReadScope;
41
+ });
42
+ const entry = createMemo(() => store.get(access(bunja), readScope()));
40
43
  createEffect(() => {
41
44
  const cleanup = entry().mount();
42
45
  onCleanup(() => setTimeout(cleanup));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bunja",
3
3
  "type": "module",
4
- "version": "2.0.0-alpha.9",
4
+ "version": "2.0.0",
5
5
  "description": "State Lifetime Manager",
6
6
  "main": "dist/bunja.cjs",
7
7
  "module": "dist/bunja.js",
package/solid.ts CHANGED
@@ -83,13 +83,16 @@ const defaultReadScope: ReadScope = <T>(scope: Scope<T>) => {
83
83
 
84
84
  export function useBunja<T>(
85
85
  bunja: MaybeAccessor<Bunja<T>>,
86
- scopeValuePairs?: ScopeValuePair<any>[],
86
+ scopeValuePairs?: MaybeAccessor<ScopeValuePair<any>[]>,
87
87
  ): Accessor<T> {
88
88
  const store = useContext(BunjaStoreContext);
89
- const readScope = scopeValuePairs
90
- ? createReadScopeFn(scopeValuePairs, defaultReadScope)
91
- : defaultReadScope;
92
- const entry = createMemo(() => store.get(access(bunja), readScope));
89
+ const readScope = createMemo(() => {
90
+ const pairs = access(scopeValuePairs);
91
+ return pairs
92
+ ? createReadScopeFn(pairs, defaultReadScope)
93
+ : defaultReadScope;
94
+ });
95
+ const entry = createMemo(() => store.get(access(bunja), readScope()));
93
96
  createEffect(() => {
94
97
  const cleanup = entry().mount();
95
98
  onCleanup(() => setTimeout(cleanup));