@derivesome/react 1.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/.package.json.~undo-tree~ +9 -0
- package/.tsconfig.cjs.json.~undo-tree~ +5 -0
- package/.tsconfig.json.~undo-tree~ +5 -0
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -0
- package/dist/cjs/hooks/index.js +18 -0
- package/dist/cjs/hooks/index.js.map +1 -0
- package/dist/cjs/hooks/useDerived.d.ts +6 -0
- package/dist/cjs/hooks/useDerived.d.ts.map +1 -0
- package/dist/cjs/hooks/useDerived.js +42 -0
- package/dist/cjs/hooks/useDerived.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.d.ts.map +1 -0
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/index.js.map +1 -0
- package/dist/esm/hooks/useDerived.d.ts +6 -0
- package/dist/esm/hooks/useDerived.d.ts.map +1 -0
- package/dist/esm/hooks/useDerived.js +36 -0
- package/dist/esm/hooks/useDerived.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/package.json +48 -0
- package/package.json~ +43 -0
- package/src/.index.ts.~undo-tree~ +6 -0
- package/src/hooks/.index.ts.~undo-tree~ +6 -0
- package/src/hooks/.useDerived.ts.~undo-tree~ +354 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/index.ts~ +1 -0
- package/src/hooks/useDerived.ts +73 -0
- package/src/hooks/useDerived.ts~ +75 -0
- package/src/index.ts +1 -0
- package/src/index.ts~ +0 -0
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.cjs.json~ +0 -0
- package/tsconfig.json +24 -0
- package/tsconfig.json~ +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
(undo-tree-save-format-version . 1)
|
|
2
|
+
"56a9f68c987cd66a99651b94567f0642e95d42f5"
|
|
3
|
+
[nil nil nil nil (27034 14043 905609 217000) 0 nil]
|
|
4
|
+
([nil nil ((nil rear-nonsticky nil 1069 . 1070) (nil fontified nil 1 . 1070) (1 . 1070) (t 27034 14030 526651 464000)) nil (27034 14043 905608 616000) 0 nil])
|
|
5
|
+
([nil nil ((26 . 31) (#("c" 0 1 (face font-lock-string-face fontified t)) . -26) (undo-tree-id0 . -1) (#("o" 0 1 (face font-lock-string-face fontified t)) . -27) (undo-tree-id1 . -1) (#("r" 0 1 (face font-lock-string-face fontified t)) . -28) (undo-tree-id2 . -1) (#("e" 0 1 (face font-lock-string-face fontified t)) . -29) (undo-tree-id3 . -1) 30) nil (27034 14064 435666 899000) 0 nil])
|
|
6
|
+
([nil nil ((#("9" 0 1 (face font-lock-string-face fontified t)) . -53) (undo-tree-id191 . -1) (undo-tree-id192 . -1) (undo-tree-id193 . -1) (undo-tree-id194 . -1) (undo-tree-id195 . -1) (undo-tree-id196 . -1) (undo-tree-id197 . -1) (undo-tree-id198 . -1) (undo-tree-id199 . -1) (undo-tree-id200 . -1) (undo-tree-id201 . -1) (undo-tree-id202 . -1) (undo-tree-id203 . -1) (undo-tree-id204 . -1) (undo-tree-id205 . -1) (undo-tree-id206 . -1) (undo-tree-id207 . -1) (undo-tree-id208 . -1) (undo-tree-id209 . -1) (undo-tree-id210 . -1) (undo-tree-id211 . -1) (undo-tree-id212 . -1) (undo-tree-id213 . -1) (undo-tree-id214 . -1) (undo-tree-id215 . -1) (undo-tree-id216 . -1) (undo-tree-id217 . -1) (undo-tree-id218 . -1) 54 (52 . 54) (#("3" 0 1 (face font-lock-string-face fontified t)) . -52) (undo-tree-id219 . -1) (undo-tree-id220 . -1) (undo-tree-id221 . -1) (undo-tree-id222 . -1) (undo-tree-id223 . -1) (undo-tree-id224 . -1) (undo-tree-id225 . -1) (undo-tree-id226 . -1) (undo-tree-id227 . -1) (undo-tree-id228 . -1) (undo-tree-id229 . -1) (undo-tree-id230 . -1) (undo-tree-id231 . -1) (undo-tree-id232 . -1) (undo-tree-id233 . -1) (undo-tree-id234 . -1) (undo-tree-id235 . -1) (undo-tree-id236 . -1) (undo-tree-id237 . -1) (undo-tree-id238 . -1) (undo-tree-id239 . -1) (undo-tree-id240 . -1) (undo-tree-id241 . -1) (undo-tree-id242 . -1) (undo-tree-id243 . -1) (undo-tree-id244 . -1) (undo-tree-id245 . -1) (undo-tree-id246 . -1) (undo-tree-id247 . -1) (undo-tree-id248 . -1) (undo-tree-id249 . -1) (undo-tree-id250 . -1) (undo-tree-id251 . -1) (undo-tree-id252 . -1) (undo-tree-id253 . -1) (undo-tree-id254 . -1) (undo-tree-id255 . -1) (undo-tree-id256 . -1) (undo-tree-id257 . -1) (undo-tree-id258 . -1) 53 (t 27034 14068 674267 87000)) nil (27034 14072 857197 770000) 0 nil] [nil nil ((31 . 36) (t 27034 14045 326501 884000)) ((#("-core" 0 5 (face font-lock-string-face fontified t)) . 31) (undo-tree-id4 . -4) (undo-tree-id5 . -4) (undo-tree-id6 . -4) (undo-tree-id7 . -4) (undo-tree-id8 . -4) (undo-tree-id9 . -4) (undo-tree-id10 . -4) (undo-tree-id11 . -4) (undo-tree-id12 . -4) (undo-tree-id13 . -4) (undo-tree-id14 . -4) (undo-tree-id15 . -4) (undo-tree-id16 . -4) (undo-tree-id17 . -4) (undo-tree-id18 . -4) (undo-tree-id19 . -4) (undo-tree-id20 . -4) (undo-tree-id21 . -4) (undo-tree-id22 . -4) (undo-tree-id23 . -4) (undo-tree-id24 . -4) (undo-tree-id25 . -4) (undo-tree-id26 . -4) (undo-tree-id27 . -4) (undo-tree-id28 . -4) (undo-tree-id29 . -4) (undo-tree-id30 . -4) (undo-tree-id31 . -4) (undo-tree-id32 . -4) (undo-tree-id33 . -4) (undo-tree-id34 . -4) (undo-tree-id35 . -4) (undo-tree-id36 . -4) (undo-tree-id37 . -4) (undo-tree-id38 . -4) (undo-tree-id39 . -4) (undo-tree-id40 . -4) (undo-tree-id41 . -4) (undo-tree-id42 . -4) (undo-tree-id43 . -4) (undo-tree-id44 . -4) (undo-tree-id45 . -4) (undo-tree-id46 . -4) (undo-tree-id47 . -4) (undo-tree-id48 . -4) (undo-tree-id49 . -4) (undo-tree-id50 . -4) (undo-tree-id51 . -4) (undo-tree-id52 . -4) (undo-tree-id53 . -4) (undo-tree-id54 . -4) (undo-tree-id55 . -4) (undo-tree-id56 . -4) (undo-tree-id57 . -4) (undo-tree-id58 . -4) (undo-tree-id59 . -4) (undo-tree-id60 . -4) (undo-tree-id61 . -4) (undo-tree-id62 . -4) (undo-tree-id63 . -4) (undo-tree-id64 . -4) (undo-tree-id65 . -4) (undo-tree-id66 . -4) (undo-tree-id67 . -4) (undo-tree-id68 . -4) (undo-tree-id69 . -4) (undo-tree-id70 . -4) (undo-tree-id71 . -4) (undo-tree-id72 . -4) (undo-tree-id73 . -4) (undo-tree-id74 . -4) (undo-tree-id75 . -4) (undo-tree-id76 . -4) (undo-tree-id77 . -4) (undo-tree-id78 . -4) (undo-tree-id79 . -4) (undo-tree-id80 . -4) (undo-tree-id81 . -4) (undo-tree-id82 . -4) (undo-tree-id83 . -4) (undo-tree-id84 . -4) (undo-tree-id85 . -4) (undo-tree-id86 . -4) (undo-tree-id87 . -4) (undo-tree-id88 . -4) (undo-tree-id89 . -4) (undo-tree-id90 . -4) (undo-tree-id91 . -4) (undo-tree-id92 . -4) (undo-tree-id93 . -4) (undo-tree-id94 . -4) (undo-tree-id95 . -4) (undo-tree-id96 . -4) (undo-tree-id97 . -4) (undo-tree-id98 . -4) (undo-tree-id99 . -4) (undo-tree-id100 . -4) (undo-tree-id101 . -4) (undo-tree-id102 . -4) (undo-tree-id103 . -4) (undo-tree-id104 . -4) (undo-tree-id105 . -4) (undo-tree-id106 . -4) (undo-tree-id107 . -4) (undo-tree-id108 . -4) (undo-tree-id109 . -4) (undo-tree-id110 . -4) (undo-tree-id111 . -4) (undo-tree-id112 . -4) (undo-tree-id113 . -4) (undo-tree-id114 . -4) (undo-tree-id115 . -4) (undo-tree-id116 . -4) (undo-tree-id117 . -4) (undo-tree-id118 . -4) (undo-tree-id119 . -4) (undo-tree-id120 . -4) (undo-tree-id121 . -4) (undo-tree-id122 . -4) (undo-tree-id123 . -4) (undo-tree-id124 . -4) (undo-tree-id125 . -4) (undo-tree-id126 . -4) (undo-tree-id127 . -4) (undo-tree-id128 . -4) (undo-tree-id129 . -4) (undo-tree-id130 . -4) (undo-tree-id131 . -4) (undo-tree-id132 . -4) (undo-tree-id133 . -4) (undo-tree-id134 . -4) (undo-tree-id135 . -4) (undo-tree-id136 . -4) (undo-tree-id137 . -4) (undo-tree-id138 . -4) (undo-tree-id139 . -4) (undo-tree-id140 . -4) (undo-tree-id141 . -4) (undo-tree-id142 . -4) (undo-tree-id143 . -4) (undo-tree-id144 . -4) (undo-tree-id145 . -4) (undo-tree-id146 . -4) (undo-tree-id147 . -4) (undo-tree-id148 . -4) (undo-tree-id149 . -4) (undo-tree-id150 . -4) (undo-tree-id151 . -4) (undo-tree-id152 . -4) (undo-tree-id153 . -4) (undo-tree-id154 . -4) (undo-tree-id155 . -4) (undo-tree-id156 . -4) (undo-tree-id157 . -4) (undo-tree-id158 . -4) (undo-tree-id159 . -4) (undo-tree-id160 . -4) (undo-tree-id161 . -4) (undo-tree-id162 . -4) (undo-tree-id163 . -4) (undo-tree-id164 . -4) (undo-tree-id165 . -4) (undo-tree-id166 . -4) (undo-tree-id167 . -4) (undo-tree-id168 . -4) (undo-tree-id169 . -4) (undo-tree-id170 . -4) (undo-tree-id171 . -4) (undo-tree-id172 . -4) (undo-tree-id173 . -4) (undo-tree-id174 . -4) (undo-tree-id175 . -4) (undo-tree-id176 . -4) (undo-tree-id177 . -4) (undo-tree-id178 . -4) (undo-tree-id179 . -4) (undo-tree-id180 . -4) (undo-tree-id181 . -4) (undo-tree-id182 . -4) (undo-tree-id183 . -4) (undo-tree-id184 . -4) (undo-tree-id185 . -4) (undo-tree-id186 . -4) (undo-tree-id187 . -4) (undo-tree-id188 . -4) (undo-tree-id189 . -4) (undo-tree-id190 . -4) (t 27034 14049 2464 820000)) (27034 14049 8922 469000) 0 nil])
|
|
7
|
+
([nil current ((1028 . 1029) (1016 . 1027) (#("\"" 0 1 (fontified nil)) . -1016) (1016 . 1017) (#("\"" 0 1 (face font-lock-string-face fontified nil)) . -1016) (1016 . 1017) (1015 . 1017) (#("\"" 0 1 (fontified nil)) . -1015) (1013 . 1016) (1004 . 1012) (996 . 1004) (995 . 997) (#("\"" 0 1 (fontified nil)) . -995) (995 . 996) (990 . 995) (t 27034 14072 854225 212000)) nil (27034 14089 619663 933000) 0 nil])
|
|
8
|
+
nil
|
|
9
|
+
nil
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
(undo-tree-save-format-version . 1)
|
|
2
|
+
"9c2c82f612122cccd843a880ce857e85134d7a8d"
|
|
3
|
+
[nil nil nil nil (27034 14020 449167 605000) 0 nil]
|
|
4
|
+
([nil current ((nil rear-nonsticky nil 150 . 151) (nil fontified nil 1 . 151) (1 . 151) (t 27034 14018 566772 789000)) nil (27034 14020 449164 437000) 0 nil])
|
|
5
|
+
nil
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
(undo-tree-save-format-version . 1)
|
|
2
|
+
"e72cba7416b4e9cad945b1fef0ff20e8a4d43172"
|
|
3
|
+
[nil nil nil nil (27034 14008 574842 570000) 0 nil]
|
|
4
|
+
([nil current ((nil rear-nonsticky nil 612 . 613) (nil fontified nil 1 . 613) (1 . 613) (t 27034 14004 754913 419000)) nil (27034 14008 574839 478000) 0 nil])
|
|
5
|
+
nil
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useDerived"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Reference } from "@derivesome/core";
|
|
2
|
+
import { Dispatch, SetStateAction } from "react";
|
|
3
|
+
export declare const useDerivedValue: <D extends Reference<any>, R = D extends Reference<infer K> ? K : never>(d: D) => R;
|
|
4
|
+
export declare const useSetDerived: <D extends Reference<any>, R = D extends Reference<infer K> ? K : never>(d: D) => Dispatch<SetStateAction<R>>;
|
|
5
|
+
export declare const useDerived: <D extends Reference<any>, R = D extends Reference<infer K> ? K : never>(d: D) => [R, Dispatch<SetStateAction<R>>];
|
|
6
|
+
//# sourceMappingURL=useDerived.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDerived.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDerived.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,QAAQ,EACR,cAAc,EAIf,MAAM,OAAO,CAAC;AAEf,eAAO,MAAM,eAAe,GAC1B,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EACxB,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAE5C,GAAG,CAAC,KACH,CA4BF,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EACxB,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAE5C,GAAG,CAAC,KACH,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAW5B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EACxB,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAE5C,GAAG,CAAC,KACH,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAKjC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDerived = exports.useSetDerived = exports.useDerivedValue = void 0;
|
|
4
|
+
const core_1 = require("@derivesome/core");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const useDerivedValue = (d) => {
|
|
7
|
+
const ref = (0, react_1.useRef)(d).current;
|
|
8
|
+
const old = (0, react_1.useRef)(d.peek());
|
|
9
|
+
return (0, react_1.useSyncExternalStore)((0, react_1.useCallback)((callback) => {
|
|
10
|
+
const unsub = ref.subscribe((next) => {
|
|
11
|
+
callback();
|
|
12
|
+
old.current = next;
|
|
13
|
+
});
|
|
14
|
+
callback();
|
|
15
|
+
return () => {
|
|
16
|
+
unsub();
|
|
17
|
+
};
|
|
18
|
+
}, [ref]), () => {
|
|
19
|
+
const nextSnap = ref.peek();
|
|
20
|
+
if ((0, core_1.compare)(old.current, nextSnap)) {
|
|
21
|
+
return old.current;
|
|
22
|
+
}
|
|
23
|
+
return nextSnap;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.useDerivedValue = useDerivedValue;
|
|
27
|
+
const useSetDerived = (d) => {
|
|
28
|
+
const ref = (0, react_1.useRef)(d).current;
|
|
29
|
+
const setter = (0, react_1.useCallback)((fn) => {
|
|
30
|
+
ref.set(fn);
|
|
31
|
+
}, [ref]);
|
|
32
|
+
return setter;
|
|
33
|
+
};
|
|
34
|
+
exports.useSetDerived = useSetDerived;
|
|
35
|
+
const useDerived = (d) => {
|
|
36
|
+
const ref = (0, react_1.useRef)(d).current;
|
|
37
|
+
const current = (0, exports.useDerivedValue)(ref);
|
|
38
|
+
const setter = (0, exports.useSetDerived)(ref);
|
|
39
|
+
return [current, setter];
|
|
40
|
+
};
|
|
41
|
+
exports.useDerived = useDerived;
|
|
42
|
+
//# sourceMappingURL=useDerived.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDerived.js","sourceRoot":"","sources":["../../../src/hooks/useDerived.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AACtD,iCAMe;AAER,MAAM,eAAe,GAAG,CAI7B,CAAI,EACD,EAAE;IACL,MAAM,GAAG,GAAG,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,cAAM,EAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAEhC,OAAO,IAAA,4BAAoB,EACzB,IAAA,mBAAW,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OAAO,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC;AAVW,QAAA,UAAU,cAUrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./hooks"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Reference } from "@derivesome/core";
|
|
2
|
+
import { Dispatch, SetStateAction } from "react";
|
|
3
|
+
export declare const useDerivedValue: <D extends Reference<any>, R = D extends Reference<infer K> ? K : never>(d: D) => R;
|
|
4
|
+
export declare const useSetDerived: <D extends Reference<any>, R = D extends Reference<infer K> ? K : never>(d: D) => Dispatch<SetStateAction<R>>;
|
|
5
|
+
export declare const useDerived: <D extends Reference<any>, R = D extends Reference<infer K> ? K : never>(d: D) => [R, Dispatch<SetStateAction<R>>];
|
|
6
|
+
//# sourceMappingURL=useDerived.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDerived.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDerived.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,QAAQ,EACR,cAAc,EAIf,MAAM,OAAO,CAAC;AAEf,eAAO,MAAM,eAAe,GAC1B,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EACxB,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAE5C,GAAG,CAAC,KACH,CA4BF,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EACxB,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAE5C,GAAG,CAAC,KACH,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAW5B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EACxB,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAE5C,GAAG,CAAC,KACH,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAKjC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { compare } from "@derivesome/core";
|
|
2
|
+
import { useCallback, useRef, useSyncExternalStore, } from "react";
|
|
3
|
+
export const useDerivedValue = (d) => {
|
|
4
|
+
const ref = useRef(d).current;
|
|
5
|
+
const old = useRef(d.peek());
|
|
6
|
+
return useSyncExternalStore(useCallback((callback) => {
|
|
7
|
+
const unsub = ref.subscribe((next) => {
|
|
8
|
+
callback();
|
|
9
|
+
old.current = next;
|
|
10
|
+
});
|
|
11
|
+
callback();
|
|
12
|
+
return () => {
|
|
13
|
+
unsub();
|
|
14
|
+
};
|
|
15
|
+
}, [ref]), () => {
|
|
16
|
+
const nextSnap = ref.peek();
|
|
17
|
+
if (compare(old.current, nextSnap)) {
|
|
18
|
+
return old.current;
|
|
19
|
+
}
|
|
20
|
+
return nextSnap;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export const useSetDerived = (d) => {
|
|
24
|
+
const ref = useRef(d).current;
|
|
25
|
+
const setter = useCallback((fn) => {
|
|
26
|
+
ref.set(fn);
|
|
27
|
+
}, [ref]);
|
|
28
|
+
return setter;
|
|
29
|
+
};
|
|
30
|
+
export const useDerived = (d) => {
|
|
31
|
+
const ref = useRef(d).current;
|
|
32
|
+
const current = useDerivedValue(ref);
|
|
33
|
+
const setter = useSetDerived(ref);
|
|
34
|
+
return [current, setter];
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useDerived.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDerived.js","sourceRoot":"","sources":["../../../src/hooks/useDerived.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAGL,WAAW,EACX,MAAM,EACN,oBAAoB,GACrB,MAAM,OAAO,CAAC;AAEf,MAAM,CAAC,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OAAO,CAAC;IAC9B,MAAM,OAAO,GAAG,eAAe,CAAO,GAAG,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,aAAa,CAAO,GAAG,CAAC,CAAC;IACxC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@derivesome/react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"types": "./dist/cjs/index.d.ts",
|
|
7
|
+
"typings": "./dist/cjs/index.d.ts",
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"files": [
|
|
12
|
+
"*"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/esm/index.d.ts",
|
|
18
|
+
"default": "./dist/esm/index.js"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/cjs/index.d.ts",
|
|
22
|
+
"default": "./dist/cjs/index.js"
|
|
23
|
+
},
|
|
24
|
+
"default": {
|
|
25
|
+
"types": "./dist/cjs/index.d.ts",
|
|
26
|
+
"default": "./dist/cjs/index.js"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^25.2.1",
|
|
32
|
+
"@types/react": "^19.2.14",
|
|
33
|
+
"prettier": "^3.8.1",
|
|
34
|
+
"tsx": "^4.21.0",
|
|
35
|
+
"typescript": "^5.9.3",
|
|
36
|
+
"vitest": "^4.0.18",
|
|
37
|
+
"@derivesome/core": "1.0.3"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"react": "^19.2.4"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"test": "vitest",
|
|
44
|
+
"build": "tsc -p tsconfig.json && echo '{\"type\":\"module\"}' > dist/esm/package.json && tsc -p tsconfig.cjs.json",
|
|
45
|
+
"format": "prettier ./src --write",
|
|
46
|
+
"check": "tsc -p ./tsconfig.json --noEmit"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/package.json~
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@derivesome/react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"types": "./dist/cjs/index.d.ts",
|
|
7
|
+
"typings": "./dist/cjs/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "vitest",
|
|
10
|
+
"build": "tsc -p tsconfig.json && echo '{\"type\":\"module\"}' > dist/esm/package.json && tsc -p tsconfig.cjs.json",
|
|
11
|
+
"format": "prettier ./src --write",
|
|
12
|
+
"check": "tsc -p ./tsconfig.json --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"files": ["*"],
|
|
18
|
+
"packageManager": "pnpm@10.28.2",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/esm/index.d.ts",
|
|
23
|
+
"default": "./dist/esm/index.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/cjs/index.d.ts",
|
|
27
|
+
"default": "./dist/cjs/index.js"
|
|
28
|
+
},
|
|
29
|
+
"default": {
|
|
30
|
+
"types": "./dist/cjs/index.d.ts",
|
|
31
|
+
"default": "./dist/cjs/index.js"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^25.2.1",
|
|
37
|
+
"prettier": "^3.8.1",
|
|
38
|
+
"@derivesome/core": "workspace:*",
|
|
39
|
+
"tsx": "^4.21.0",
|
|
40
|
+
"typescript": "^5.9.3",
|
|
41
|
+
"vitest": "^4.0.18"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(undo-tree-save-format-version . 1)
|
|
2
|
+
"7559e096c2d0766a51ef6708af212fff5b007dd3"
|
|
3
|
+
[nil nil nil nil (27034 14839 469076 509000) 0 nil]
|
|
4
|
+
([nil nil ((22 . 25) (1 . 22) (t 27034 14097 497979 193000)) nil (27034 14839 469075 532000) 0 nil])
|
|
5
|
+
([nil current ((25 . 26)) nil (27034 14839 469072 246000) 0 nil])
|
|
6
|
+
nil
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(undo-tree-save-format-version . 1)
|
|
2
|
+
"7bbd5ff650c24919e5ed593bdca20279eac333fa"
|
|
3
|
+
[nil nil nil nil (27034 14830 824773 285000) 0 nil]
|
|
4
|
+
([nil nil ((28 . 30) (18 . 28) (#("useDerived" 0 10 (part-side typescript)) . -18) (18 . 28) (#("user" 0 4 (part-side typescript)) . -18) (undo-tree-id0 . -4) (undo-tree-id1 . -4) (undo-tree-id2 . -1) (undo-tree-id3 . -1) (undo-tree-id4 . -1) (undo-tree-id5 . -1) (undo-tree-id6 . -1) (undo-tree-id7 . -1) (undo-tree-id8 . -1) (undo-tree-id9 . -1) (undo-tree-id10 . -1) (undo-tree-id11 . -1) (undo-tree-id12 . -1) (undo-tree-id13 . -1) (undo-tree-id14 . -1) (undo-tree-id15 . -1) (undo-tree-id16 . -1) (undo-tree-id17 . -1) (undo-tree-id18 . -1) (undo-tree-id19 . -1) (undo-tree-id20 . -1) (undo-tree-id21 . -1) (undo-tree-id22 . -1) (undo-tree-id23 . -2) (undo-tree-id24 . -2) (undo-tree-id25 . -2) (undo-tree-id26 . -2) (undo-tree-id27 . -2) (undo-tree-id28 . -2) (undo-tree-id29 . -2) (undo-tree-id30 . -2) (undo-tree-id31 . -2) (undo-tree-id32 . -2) (undo-tree-id33 . -2) (undo-tree-id34 . -2) (undo-tree-id35 . -2) (undo-tree-id36 . -2) (undo-tree-id37 . -2) (undo-tree-id38 . -2) (undo-tree-id39 . -2) (undo-tree-id40 . -2) (undo-tree-id41 . -2) (undo-tree-id42 . -2) (undo-tree-id43 . -2) (undo-tree-id44 . -3) (undo-tree-id45 . -3) (undo-tree-id46 . -3) (undo-tree-id47 . -3) (undo-tree-id48 . -3) (undo-tree-id49 . -3) (undo-tree-id50 . -3) (undo-tree-id51 . -3) (undo-tree-id52 . -3) (undo-tree-id53 . -3) (undo-tree-id54 . -3) (undo-tree-id55 . -3) (undo-tree-id56 . -3) (undo-tree-id57 . -3) (undo-tree-id58 . -3) (undo-tree-id59 . -3) (undo-tree-id60 . -3) (undo-tree-id61 . -3) (undo-tree-id62 . -3) (undo-tree-id63 . -3) (undo-tree-id64 . -3) (undo-tree-id65 . -3) (undo-tree-id66 . -3) (undo-tree-id67 . -3) (undo-tree-id68 . -3) (undo-tree-id69 . -3) (undo-tree-id70 . -3) (undo-tree-id71 . -3) (undo-tree-id72 . -3) (undo-tree-id73 . -3) (undo-tree-id74 . -3) (undo-tree-id75 . -4) (undo-tree-id76 . -4) (undo-tree-id77 . -4) (undo-tree-id78 . -4) (undo-tree-id79 . -4) (undo-tree-id80 . -4) (undo-tree-id81 . -4) (undo-tree-id82 . -4) (undo-tree-id83 . -4) (undo-tree-id84 . -4) (undo-tree-id85 . -4) (undo-tree-id86 . -4) (undo-tree-id87 . -4) (undo-tree-id88 . -4) (undo-tree-id89 . -4) (undo-tree-id90 . -4) (undo-tree-id91 . -4) (undo-tree-id92 . -4) (undo-tree-id93 . -4) (undo-tree-id94 . -4) (undo-tree-id95 . -4) (undo-tree-id96 . -4) (undo-tree-id97 . -4) (undo-tree-id98 . -4) (undo-tree-id99 . -4) (undo-tree-id100 . -4) (undo-tree-id101 . -4) (undo-tree-id102 . -4) (undo-tree-id103 . -4) (undo-tree-id104 . -4) (undo-tree-id105 . -4) (undo-tree-id106 . -4) (undo-tree-id107 . -4) (undo-tree-id108 . -4) (undo-tree-id109 . -4) (undo-tree-id110 . -4) (undo-tree-id111 . -4) (undo-tree-id112 . -4) (undo-tree-id113 . -4) (undo-tree-id114 . -4) (undo-tree-id115 . -4) (undo-tree-id116 . -4) (undo-tree-id117 . -4) (undo-tree-id118 . -4) (undo-tree-id119 . -4) (undo-tree-id120 . -4) (undo-tree-id121 . -4) (undo-tree-id122 . -4) (undo-tree-id123 . -4) (undo-tree-id124 . -4) 22 (1 . 22) (t 27034 14825 671158 760000)) nil (27034 14830 824770 480000) 0 nil])
|
|
5
|
+
([nil current ((30 . 31)) nil (27034 14830 824079 918000) 0 nil])
|
|
6
|
+
nil
|