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 +1 -1
- package/deno.json +1 -1
- package/dist/{bunja-DO4Cr7x-.cjs → bunja-CaephaLd.cjs} +2 -2
- package/dist/{bunja-DxIUFo_M.js → bunja-EJqDbU0A.js} +2 -2
- package/dist/bunja.cjs +1 -1
- package/dist/bunja.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/solid.cjs +6 -3
- package/dist/solid.d.cts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/solid.js +6 -3
- package/package.json +1 -1
- package/solid.ts +8 -5
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
|
|
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
|
@@ -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
package/dist/bunja.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Bunja, BunjaStore, Scope, bunja, createBunjaStore, createReadScopeFn, createScope, delayUnmount } from "./bunja-
|
|
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
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-
|
|
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-
|
|
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 =
|
|
40
|
-
|
|
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-
|
|
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 =
|
|
39
|
-
|
|
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
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 =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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));
|