@dr.pogodin/react-global-state 0.20.0 → 0.21.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/build/code/GlobalState.js +7 -2
- package/build/code/GlobalState.js.map +1 -1
- package/build/code/GlobalStateProvider.js +2 -2
- package/build/code/GlobalStateProvider.js.map +1 -1
- package/build/code/index.js +6 -6
- package/build/code/index.js.map +1 -1
- package/build/code/useAsyncCollection.js +4 -4
- package/build/code/useAsyncCollection.js.map +1 -1
- package/build/code/useAsyncData.js +3 -3
- package/build/code/useAsyncData.js.map +1 -1
- package/build/code/useGlobalState.js +3 -8
- package/build/code/useGlobalState.js.map +1 -1
- package/build/code/utils.js +1 -1
- package/build/code/utils.js.map +1 -1
- package/build/types/utils.d.ts +1 -1
- package/package.json +15 -16
- package/tstyche.config.json +1 -1
- package/build/cjs/GlobalState.js +0 -289
- package/build/cjs/GlobalState.js.map +0 -1
- package/build/cjs/GlobalStateProvider.js +0 -100
- package/build/cjs/GlobalStateProvider.js.map +0 -1
- package/build/cjs/SsrContext.js +0 -15
- package/build/cjs/SsrContext.js.map +0 -1
- package/build/cjs/index.js +0 -88
- package/build/cjs/index.js.map +0 -1
- package/build/cjs/useAsyncCollection.js +0 -283
- package/build/cjs/useAsyncCollection.js.map +0 -1
- package/build/cjs/useAsyncData.js +0 -273
- package/build/cjs/useAsyncData.js.map +0 -1
- package/build/cjs/useGlobalState.js +0 -148
- package/build/cjs/useGlobalState.js.map +0 -1
- package/build/cjs/utils.js +0 -91
- package/build/cjs/utils.js.map +0 -1
package/build/code/utils.js
CHANGED
package/build/code/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["cloneDeep","isDebugMode","process","env","NODE_ENV","REACT_GLOBAL_STATE_DEBUG","cloneDeepBailKeys","Set","cloneDeepForLog","value","key","has","console","warn","start","Date","now","res","time","add","escape","x","replace","toString","hash","items","map","join"],"sources":["../../src/utils.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"utils.js","names":["cloneDeep","isDebugMode","process","env","NODE_ENV","REACT_GLOBAL_STATE_DEBUG","cloneDeepBailKeys","Set","cloneDeepForLog","value","key","has","console","warn","start","Date","now","res","time","add","escape","x","replace","toString","hash","items","map","join"],"sources":["../../src/utils.ts"],"sourcesContent":["import type { GetFieldType } from 'lodash';\nimport cloneDeep from 'lodash/cloneDeep.js';\n\nexport type CallbackT = () => void;\n\n// TODO: This (ForceT, LockT, and TypeLock) probably should be moved to JS Utils\n// lib.\n\nexport declare const force: unique symbol;\nexport declare const lock: unique symbol;\n\nexport type ForceT = typeof force;\nexport type LockT = typeof lock;\n\nexport type TypeLock<\n Unlocked extends ForceT | LockT,\n\n // TODO: Revise later.\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n LockedT extends never | void,\n UnlockedT,\n> = Unlocked extends ForceT ? UnlockedT : LockedT;\n\n/**\n * Given the type of state, `StateT`, and the type of state path, `PathT`,\n * it evaluates the type of value at that path of the state, if it can be\n * evaluated from the path type (it is possible when `PathT` is a string\n * literal type, and `StateT` elements along this path have appropriate\n * types); otherwise it falls back to the specified `UnknownT` type,\n * which should be set either `never` (for input arguments), or `void`\n * (for return types) - `never` and `void` in those places forbid assignments,\n * and are not auto-inferred to more permissible types.\n *\n * BEWARE: When StateT is any the construct resolves to any for any string\n * paths.\n */\nexport type ValueAtPathT<\n StateT,\n PathT extends null | string | undefined,\n\n // TODO: Revise later.\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-invalid-void-type\n UnknownT extends never | undefined | void,\n> = unknown extends StateT\n ? UnknownT\n : string extends PathT\n ? UnknownT\n : PathT extends null | undefined\n ? StateT\n : GetFieldType<StateT, PathT> extends undefined\n ? UnknownT : GetFieldType<StateT, PathT>;\n\nexport type ValueOrInitializerT<ValueT> = ValueT | (() => ValueT);\n\n/**\n * Returns 'true' if debug logging should be performed; 'false' otherwise.\n *\n * BEWARE: The actual safeguards for the debug logging still should read\n * if (process.env.NODE_ENV !== 'production' && isDebugMode()) {\n * // Some debug logging\n * }\n * to ensure that debug code is stripped out by Webpack in production mode.\n *\n * @returns\n * @ignore\n */\nexport function isDebugMode(): boolean {\n try {\n return process.env.NODE_ENV !== 'production'\n && !!process.env.REACT_GLOBAL_STATE_DEBUG;\n } catch {\n return false;\n }\n}\n\nconst cloneDeepBailKeys = new Set<string>();\n\n/**\n * Deep-clones given value for logging purposes, or returns the value itself\n * if the previous clone attempt, with the same key, took more than 300ms\n * (to avoid situations when large payload in the global state slows down\n * development versions of the app due to the logging overhead).\n */\nexport function cloneDeepForLog<T>(value: T, key: string = ''): T {\n if (cloneDeepBailKeys.has(key)) {\n // eslint-disable-next-line no-console\n console.warn(`The logged value won't be clonned (key \"${key}\").`);\n return value;\n }\n\n const start = Date.now();\n const res = cloneDeep(value);\n const time = Date.now() - start;\n if (time > 300) {\n // eslint-disable-next-line no-console\n console.warn(`${time}ms spent to clone the logged value (key \"${key}\").`);\n cloneDeepBailKeys.add(key);\n }\n\n return res;\n}\n\n/**\n * Converts given value to an escaped string. For now, we are good with the most\n * trivial escape logic:\n * - '%' characters are replaced by '%0' code pair;\n * - '/' characters are replaced by '%1' code pair.\n */\nexport function escape(x: number | string): string {\n return typeof x === 'string'\n ? x.replace(/%/g, '%0').replace(/\\//g, '%1')\n : x.toString();\n}\n\n/**\n * Hashes given string array. For our current needs we are fine to go with\n * the most trivial implementation, which probably should not be called \"hash\"\n * in the strict sense: we just escape each given string to not include '/'\n * characters, and then we join all those strings using '/' as the separator.\n */\nexport function hash(items: Array<number | string>): string {\n return items.map(escape).join('/');\n}\n"],"mappings":"AACA,OAAOA,SAAS,MAAM,qBAAqB;;AAI3C;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,S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CAACN,MAAM,CAAC,CAACO,IAAI,CAAC,GAAG,CAAC;AACpC","ignoreList":[]}
|
package/build/types/utils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dr.pogodin/react-global-state",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Hook-based global state for React",
|
|
5
5
|
"main": "./build/code/index.js",
|
|
6
6
|
"types": "./build/types/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
|
-
"require": "./build/cjs/index.js",
|
|
9
8
|
"types": "./build/types/index.d.ts",
|
|
10
9
|
"default": "./build/code/index.js"
|
|
11
10
|
},
|
|
12
11
|
"scripts": {
|
|
13
|
-
"build": "rimraf build && npm run build:types && npm run build:code
|
|
14
|
-
"build:cjs": "rimraf buidl/cjs && babel src -x .ts,.tsx --out-dir build/cjs --source-maps",
|
|
12
|
+
"build": "rimraf build && npm run build:types && npm run build:code",
|
|
15
13
|
"build:code": "rimraf build/code && babel src -x .ts,.tsx --out-dir build/code --source-maps --config-file ./babel.module.config.js",
|
|
16
14
|
"build:types": "rimraf build/types && tsc --project tsconfig.types.json",
|
|
17
15
|
"jest": "npm run jest:types && npm run jest:logic",
|
|
18
|
-
"jest:logic": "jest --config jest/config.json -w 1",
|
|
16
|
+
"jest:logic": "jest --config jest/config.json -w 1 --no-cache",
|
|
19
17
|
"jest:types": "tstyche",
|
|
20
18
|
"lint": "eslint",
|
|
21
19
|
"test": "npm run lint && npm run typecheck && npm run jest",
|
|
@@ -42,34 +40,35 @@
|
|
|
42
40
|
},
|
|
43
41
|
"dependencies": {
|
|
44
42
|
"@babel/runtime": "^7.28.4",
|
|
45
|
-
"@dr.pogodin/js-utils": "^0.1.
|
|
43
|
+
"@dr.pogodin/js-utils": "^0.1.4",
|
|
46
44
|
"@types/lodash": "^4.17.20",
|
|
47
45
|
"lodash": "^4.17.21",
|
|
48
46
|
"uuid": "^13.0.0"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
49
|
"@babel/cli": "^7.28.3",
|
|
52
|
-
"@babel/core": "^7.28.
|
|
50
|
+
"@babel/core": "^7.28.5",
|
|
53
51
|
"@babel/node": "^7.28.0",
|
|
54
|
-
"@babel/plugin-transform-runtime": "^7.28.
|
|
55
|
-
"@babel/preset-env": "^7.28.
|
|
56
|
-
"@babel/preset-react": "^7.
|
|
57
|
-
"@babel/preset-typescript": "^7.
|
|
58
|
-
"@dr.pogodin/eslint-configs": "^0.1.
|
|
52
|
+
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
53
|
+
"@babel/preset-env": "^7.28.5",
|
|
54
|
+
"@babel/preset-react": "^7.28.5",
|
|
55
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
56
|
+
"@dr.pogodin/eslint-configs": "^0.1.1",
|
|
59
57
|
"@testing-library/dom": "^10.4.1",
|
|
60
58
|
"@testing-library/react": "^16.3.0",
|
|
61
|
-
"@tsconfig/recommended": "^1.0.
|
|
59
|
+
"@tsconfig/recommended": "^1.0.11",
|
|
62
60
|
"@types/jest": "^30.0.0",
|
|
63
61
|
"@types/pretty": "^2.0.3",
|
|
64
62
|
"@types/react": "^19.2.2",
|
|
65
|
-
"@types/react-dom": "^19.2.
|
|
63
|
+
"@types/react-dom": "^19.2.2",
|
|
66
64
|
"babel-jest": "^30.2.0",
|
|
65
|
+
"babel-plugin-add-import-extension": "^1.6.0",
|
|
67
66
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
68
67
|
"jest": "^30.2.0",
|
|
69
68
|
"jest-environment-jsdom": "^30.2.0",
|
|
70
69
|
"mockdate": "^3.0.5",
|
|
71
|
-
"rimraf": "^6.0
|
|
72
|
-
"tstyche": "^
|
|
70
|
+
"rimraf": "^6.1.0",
|
|
71
|
+
"tstyche": "^5.0.0",
|
|
73
72
|
"typescript": "^5.9.3"
|
|
74
73
|
},
|
|
75
74
|
"peerDependencies": {
|
package/tstyche.config.json
CHANGED
package/build/cjs/GlobalState.js
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _lodash = require("lodash");
|
|
8
|
-
var _utils = require("./utils");
|
|
9
|
-
const ERR_NO_SSR_WATCH = 'GlobalState must not be watched at server side';
|
|
10
|
-
class GlobalState {
|
|
11
|
-
#asyncDataAbortCallbacks = {};
|
|
12
|
-
#dependencies = {};
|
|
13
|
-
#initialState;
|
|
14
|
-
|
|
15
|
-
// TODO: It is tempting to replace watchers here by
|
|
16
|
-
// Emitter from @dr.pogodin/js-utils, but we need to clone
|
|
17
|
-
// current watchers for emitting later, and this is not something
|
|
18
|
-
// Emitter supports right now.
|
|
19
|
-
#watchers = [];
|
|
20
|
-
#nextNotifierId;
|
|
21
|
-
#currentState;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new global state object.
|
|
25
|
-
* @param initialState Intial global state content.
|
|
26
|
-
* @param ssrContext Server-side rendering context.
|
|
27
|
-
*/
|
|
28
|
-
constructor(initialState, ssrContext) {
|
|
29
|
-
this.#currentState = initialState;
|
|
30
|
-
this.#initialState = initialState;
|
|
31
|
-
if (ssrContext) {
|
|
32
|
-
/* eslint-disable no-param-reassign */
|
|
33
|
-
ssrContext.dirty = false;
|
|
34
|
-
ssrContext.pending = [];
|
|
35
|
-
ssrContext.state = this.#currentState;
|
|
36
|
-
/* eslint-enable no-param-reassign */
|
|
37
|
-
|
|
38
|
-
this.ssrContext = ssrContext;
|
|
39
|
-
}
|
|
40
|
-
if (process.env.NODE_ENV !== 'production' && (0, _utils.isDebugMode)()) {
|
|
41
|
-
/* eslint-disable no-console */
|
|
42
|
-
let msg = 'New ReactGlobalState created';
|
|
43
|
-
if (ssrContext) msg += ' (SSR mode)';
|
|
44
|
-
console.groupCollapsed(msg);
|
|
45
|
-
console.log('Initial state:', (0, _utils.cloneDeepForLog)(initialState));
|
|
46
|
-
console.groupEnd();
|
|
47
|
-
/* eslint-enable no-console */
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Returns the number of currently registered async data abort callbacks,
|
|
53
|
-
* just for the sake of testing the library.
|
|
54
|
-
*/
|
|
55
|
-
get numAsyncDataAbortCallbacks() {
|
|
56
|
-
return Object.keys(this.#asyncDataAbortCallbacks).length;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* If `aborted` is "true" and there is an abort callback registered for
|
|
61
|
-
* the specified operation, it triggers the callback. Then, in any case,
|
|
62
|
-
* it drops the callback.
|
|
63
|
-
*/
|
|
64
|
-
asyncDataLoadDone(opid, aborted) {
|
|
65
|
-
if (aborted) this.#asyncDataAbortCallbacks[opid]?.();
|
|
66
|
-
delete this.#asyncDataAbortCallbacks[opid];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Drops the record of dependencies, if any, for the given path.
|
|
71
|
-
*/
|
|
72
|
-
dropDependencies(path) {
|
|
73
|
-
delete this.#dependencies[path];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Checks if given `deps` are different from previously recorded ones for
|
|
78
|
-
* the given `path`. If they are, `deps` are recorded as the new deps for
|
|
79
|
-
* the `path`, and also the array is frozen, to prevent it from being
|
|
80
|
-
* modified.
|
|
81
|
-
*
|
|
82
|
-
* TODO: This may not work as expected if path string is not normalized,
|
|
83
|
-
* and the for the same path different alternative ways to spell it down
|
|
84
|
-
* are used. We should normalize given path here, I guess, or on a higher
|
|
85
|
-
* level in the logic?
|
|
86
|
-
*/
|
|
87
|
-
hasChangedDependencies(path, deps) {
|
|
88
|
-
const prevDeps = this.#dependencies[path];
|
|
89
|
-
let changed = !prevDeps || prevDeps.length !== deps.length;
|
|
90
|
-
for (let i = 0; !changed && i < deps.length; ++i) {
|
|
91
|
-
changed = prevDeps[i] !== deps[i];
|
|
92
|
-
}
|
|
93
|
-
this.#dependencies[path] = Object.freeze(deps);
|
|
94
|
-
return changed;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Gets entire state, the same way as .get(null, opts) would do.
|
|
99
|
-
* @param opts.initialState
|
|
100
|
-
* @param opts.initialValue
|
|
101
|
-
*/
|
|
102
|
-
getEntireState(opts) {
|
|
103
|
-
let state = opts?.initialState ? this.#initialState : this.#currentState;
|
|
104
|
-
if (state !== undefined || opts?.initialValue === undefined) return state;
|
|
105
|
-
const iv = opts.initialValue;
|
|
106
|
-
state = (0, _lodash.isFunction)(iv) ? iv() : iv;
|
|
107
|
-
if (this.#currentState === undefined) this.setEntireState(state);
|
|
108
|
-
return state;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Notifies all connected state watchers that a state update has happened.
|
|
113
|
-
*/
|
|
114
|
-
notifyStateUpdate(path, value) {
|
|
115
|
-
if (process.env.NODE_ENV !== 'production' && (0, _utils.isDebugMode)()) {
|
|
116
|
-
/* eslint-disable no-console */
|
|
117
|
-
const p = typeof path === 'string' ? `"${path}"` : 'none (entire state update)';
|
|
118
|
-
console.groupCollapsed(`ReactGlobalState update. Path: ${p}`);
|
|
119
|
-
console.log('New value:', (0, _utils.cloneDeepForLog)(value, path ?? ''));
|
|
120
|
-
console.log('New state:', (0, _utils.cloneDeepForLog)(this.#currentState));
|
|
121
|
-
console.groupEnd();
|
|
122
|
-
/* eslint-enable no-console */
|
|
123
|
-
}
|
|
124
|
-
if (this.ssrContext) {
|
|
125
|
-
this.ssrContext.dirty = true;
|
|
126
|
-
this.ssrContext.state = this.#currentState;
|
|
127
|
-
} else if (!this.#nextNotifierId) {
|
|
128
|
-
this.#nextNotifierId = setTimeout(() => {
|
|
129
|
-
this.#nextNotifierId = undefined;
|
|
130
|
-
const watchers = [...this.#watchers];
|
|
131
|
-
for (const watcher of watchers) watcher();
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Registers an abort callback for an async data retrieval operation with
|
|
138
|
-
* the given operation ID. Throws if already registered.
|
|
139
|
-
*/
|
|
140
|
-
setAsyncDataAbortCallback(opid, cb) {
|
|
141
|
-
this.#asyncDataAbortCallbacks[opid] = cb;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Sets entire state, the same way as .set(null, value) would do.
|
|
146
|
-
* @param value
|
|
147
|
-
*/
|
|
148
|
-
setEntireState(value) {
|
|
149
|
-
if (this.#currentState !== value) {
|
|
150
|
-
this.#currentState = value;
|
|
151
|
-
this.notifyStateUpdate(null, value);
|
|
152
|
-
}
|
|
153
|
-
return value;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Gets current or initial value at the specified "path" of the global state.
|
|
158
|
-
* @param path Dot-delimitered state path.
|
|
159
|
-
* @param options Additional options.
|
|
160
|
-
* @param options.initialState If "true" the value will be read
|
|
161
|
-
* from the initial state instead of the current one.
|
|
162
|
-
* @param options.initialValue If the value read from the "path" is
|
|
163
|
-
* "undefined", this "initialValue" will be returned instead. In such case
|
|
164
|
-
* "initialValue" will also be written to the "path" of the current global
|
|
165
|
-
* state (no matter "initialState" flag), if "undefined" is stored there.
|
|
166
|
-
* @return Retrieved value.
|
|
167
|
-
*/
|
|
168
|
-
|
|
169
|
-
// .get() without arguments just falls back to .getEntireState().
|
|
170
|
-
|
|
171
|
-
// This variant attempts to automatically resolve and check the type of value
|
|
172
|
-
// at the given path, as precise as the actual state and path types permit.
|
|
173
|
-
// If the automatic path resolution is not possible, the ValueT fallsback
|
|
174
|
-
// to `never` (or to `undefined` in some cases), effectively forbidding
|
|
175
|
-
// to use this .get() variant.
|
|
176
|
-
|
|
177
|
-
// This variant is not callable by default (without generic arguments),
|
|
178
|
-
// otherwise it allows to set the correct ValueT directly.
|
|
179
|
-
|
|
180
|
-
get(path, opts) {
|
|
181
|
-
if ((0, _lodash.isNil)(path)) {
|
|
182
|
-
const res = this.getEntireState(opts);
|
|
183
|
-
return res;
|
|
184
|
-
}
|
|
185
|
-
const state = opts?.initialState ? this.#initialState : this.#currentState;
|
|
186
|
-
let res = (0, _lodash.get)(state, path);
|
|
187
|
-
if (res !== undefined || opts?.initialValue === undefined) return res;
|
|
188
|
-
const iv = opts.initialValue;
|
|
189
|
-
res = (0, _lodash.isFunction)(iv) ? iv() : iv;
|
|
190
|
-
|
|
191
|
-
// TODO: Revise.
|
|
192
|
-
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
193
|
-
if (!opts.initialState || this.get(path) === undefined) {
|
|
194
|
-
this.set(path, res);
|
|
195
|
-
}
|
|
196
|
-
return res;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Writes the `value` to given global state `path`.
|
|
201
|
-
* @param path Dot-delimitered state path. If not given, entire
|
|
202
|
-
* global state content is replaced by the `value`.
|
|
203
|
-
* @param value The value.
|
|
204
|
-
* @return Given `value` itself.
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
// This variant attempts automatic value type resolution & checking.
|
|
208
|
-
|
|
209
|
-
// This variant is disabled by default, otherwise allows to give
|
|
210
|
-
// expected value type explicitly.
|
|
211
|
-
|
|
212
|
-
set(path, value) {
|
|
213
|
-
if ((0, _lodash.isNil)(path)) return this.setEntireState(value);
|
|
214
|
-
|
|
215
|
-
// TODO: Revise.
|
|
216
|
-
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
217
|
-
if (value !== this.get(path)) {
|
|
218
|
-
const root = {
|
|
219
|
-
state: this.#currentState
|
|
220
|
-
};
|
|
221
|
-
let segIdx = 0;
|
|
222
|
-
|
|
223
|
-
// TODO: It is not 100% correct, as `pos` can be an array, or any other
|
|
224
|
-
// value as we travel through the state tree. To simplify the typing for
|
|
225
|
-
// now, I guess, we can go with this record type, though.
|
|
226
|
-
let pos = root;
|
|
227
|
-
const pathSegments = (0, _lodash.toPath)(`state.${path}`);
|
|
228
|
-
for (; segIdx < pathSegments.length - 1; segIdx += 1) {
|
|
229
|
-
const seg = pathSegments[segIdx];
|
|
230
|
-
|
|
231
|
-
// TODO: Revise: Typing is not quite correct here, but it works fine in the runtime.
|
|
232
|
-
const next = pos[seg];
|
|
233
|
-
if (Array.isArray(next)) pos[seg] = [...next];else if ((0, _lodash.isObject)(next)) pos[seg] = {
|
|
234
|
-
...next
|
|
235
|
-
};else {
|
|
236
|
-
// We arrived to a state sub-segment, where the remaining part of
|
|
237
|
-
// the update path does not exist yet. We rely on lodash's set()
|
|
238
|
-
// function to create the remaining path, and set the value.
|
|
239
|
-
(0, _lodash.set)(pos, pathSegments.slice(segIdx), value);
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
pos = pos[seg];
|
|
243
|
-
}
|
|
244
|
-
if (segIdx === pathSegments.length - 1) {
|
|
245
|
-
pos[pathSegments[segIdx]] = value;
|
|
246
|
-
}
|
|
247
|
-
this.#currentState = root.state;
|
|
248
|
-
this.notifyStateUpdate(path, value);
|
|
249
|
-
}
|
|
250
|
-
return value;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Unsubscribes `callback` from watching state updates; no operation if
|
|
255
|
-
* `callback` is not subscribed to the state updates.
|
|
256
|
-
* @param callback
|
|
257
|
-
* @throws if {@link SsrContext} is attached to the state instance: the state
|
|
258
|
-
* watching functionality is intended for client-side (non-SSR) only.
|
|
259
|
-
*/
|
|
260
|
-
unWatch(callback) {
|
|
261
|
-
if (this.ssrContext) throw new Error(ERR_NO_SSR_WATCH);
|
|
262
|
-
const watchers = this.#watchers;
|
|
263
|
-
const pos = watchers.indexOf(callback);
|
|
264
|
-
if (pos >= 0) {
|
|
265
|
-
watchers[pos] = watchers[watchers.length - 1];
|
|
266
|
-
watchers.pop();
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Subscribes `callback` to watch state updates; no operation if
|
|
272
|
-
* `callback` is already subscribed to this state instance.
|
|
273
|
-
* @param callback It will be called without any arguments every
|
|
274
|
-
* time the state content changes (note, howhever, separate state updates can
|
|
275
|
-
* be applied to the state at once, and watching callbacks will be called once
|
|
276
|
-
* after such bulk update).
|
|
277
|
-
* @throws if {@link SsrContext} is attached to the state instance: the state
|
|
278
|
-
* watching functionality is intended for client-side (non-SSR) only.
|
|
279
|
-
*/
|
|
280
|
-
watch(callback) {
|
|
281
|
-
if (this.ssrContext) throw new Error(ERR_NO_SSR_WATCH);
|
|
282
|
-
const watchers = this.#watchers;
|
|
283
|
-
if (!watchers.includes(callback)) {
|
|
284
|
-
watchers.push(callback);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
exports.default = GlobalState;
|
|
289
|
-
//# sourceMappingURL=GlobalState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalState.js","names":["_lodash","require","_utils","ERR_NO_SSR_WATCH","GlobalState","asyncDataAbortCallbacks","dependencies","initialState","watchers","nextNotifierId","currentState","constructor","ssrContext","dirty","pending","state","process","env","NODE_ENV","isDebugMode","msg","console","groupCollapsed","log","cloneDeepForLog","groupEnd","numAsyncDataAbortCallbacks","Object","keys","length","asyncDataLoadDone","opid","aborted","dropDependencies","path","hasChangedDependencies","deps","prevDeps","changed","i","freeze","getEntireState","opts","undefined","initialValue","iv","isFunction","setEntireState","notifyStateUpdate","value","p","setTimeout","watcher","setAsyncDataAbortCallback","cb","get","isNil","res","set","root","segIdx","pos","pathSegments","toPath","seg","next","Array","isArray","isObject","slice","unWatch","callback","Error","indexOf","pop","watch","includes","push","exports","default"],"sources":["../../src/GlobalState.ts"],"sourcesContent":["import {\n get,\n isFunction,\n isObject,\n isNil,\n set,\n toPath,\n} from 'lodash';\n\nimport type SsrContext from './SsrContext';\n\nimport {\n type CallbackT,\n type ForceT,\n type LockT,\n type TypeLock,\n type ValueAtPathT,\n type ValueOrInitializerT,\n cloneDeepForLog,\n isDebugMode,\n} from './utils';\n\nconst ERR_NO_SSR_WATCH = 'GlobalState must not be watched at server side';\n\ntype GetOptsT<T> = {\n initialState?: boolean;\n initialValue?: ValueOrInitializerT<T>;\n};\n\nexport default class GlobalState<\n StateT,\n SsrContextT extends SsrContext<StateT> = SsrContext<StateT>,\n> {\n readonly ssrContext?: SsrContextT;\n\n #asyncDataAbortCallbacks: Record<string, () => void> = {};\n\n #dependencies: Record<string, readonly unknown[]> = {};\n\n #initialState: StateT;\n\n // TODO: It is tempting to replace watchers here by\n // Emitter from @dr.pogodin/js-utils, but we need to clone\n // current watchers for emitting later, and this is not something\n // Emitter supports right now.\n #watchers: CallbackT[] = [];\n\n #nextNotifierId?: NodeJS.Timeout;\n\n #currentState: StateT;\n\n /**\n * Creates a new global state object.\n * @param initialState Intial global state content.\n * @param ssrContext Server-side rendering context.\n */\n constructor(\n initialState: StateT,\n ssrContext?: SsrContextT,\n ) {\n this.#currentState = initialState;\n this.#initialState = initialState;\n\n if (ssrContext) {\n /* eslint-disable no-param-reassign */\n ssrContext.dirty = false;\n ssrContext.pending = [];\n ssrContext.state = this.#currentState;\n /* eslint-enable no-param-reassign */\n\n this.ssrContext = ssrContext;\n }\n\n if (process.env.NODE_ENV !== 'production' && isDebugMode()) {\n /* eslint-disable no-console */\n let msg = 'New ReactGlobalState created';\n if (ssrContext) msg += ' (SSR mode)';\n console.groupCollapsed(msg);\n console.log('Initial state:', cloneDeepForLog(initialState));\n console.groupEnd();\n /* eslint-enable no-console */\n }\n }\n\n /**\n * Returns the number of currently registered async data abort callbacks,\n * just for the sake of testing the library.\n */\n get numAsyncDataAbortCallbacks(): number {\n return Object.keys(this.#asyncDataAbortCallbacks).length;\n }\n\n /**\n * If `aborted` is \"true\" and there is an abort callback registered for\n * the specified operation, it triggers the callback. Then, in any case,\n * it drops the callback.\n */\n asyncDataLoadDone(opid: string, aborted: boolean): void {\n if (aborted) this.#asyncDataAbortCallbacks[opid]?.();\n delete this.#asyncDataAbortCallbacks[opid];\n }\n\n /**\n * Drops the record of dependencies, if any, for the given path.\n */\n dropDependencies(path: string): void {\n delete this.#dependencies[path];\n }\n\n /**\n * Checks if given `deps` are different from previously recorded ones for\n * the given `path`. If they are, `deps` are recorded as the new deps for\n * the `path`, and also the array is frozen, to prevent it from being\n * modified.\n *\n * TODO: This may not work as expected if path string is not normalized,\n * and the for the same path different alternative ways to spell it down\n * are used. We should normalize given path here, I guess, or on a higher\n * level in the logic?\n */\n hasChangedDependencies(path: string, deps: unknown[]): boolean {\n const prevDeps = this.#dependencies[path];\n let changed = !prevDeps || prevDeps.length !== deps.length;\n for (let i = 0; !changed && i < deps.length; ++i) {\n changed = prevDeps![i] !== deps[i];\n }\n this.#dependencies[path] = Object.freeze(deps);\n return changed;\n }\n\n /**\n * Gets entire state, the same way as .get(null, opts) would do.\n * @param opts.initialState\n * @param opts.initialValue\n */\n getEntireState(opts?: GetOptsT<StateT>): StateT {\n let state = opts?.initialState ? this.#initialState : this.#currentState;\n if (state !== undefined || opts?.initialValue === undefined) return state;\n\n const iv = opts.initialValue;\n state = isFunction(iv) ? iv() : iv;\n if (this.#currentState === undefined) this.setEntireState(state);\n return state;\n }\n\n /**\n * Notifies all connected state watchers that a state update has happened.\n */\n private notifyStateUpdate(path: null | string | undefined, value: unknown) {\n if (process.env.NODE_ENV !== 'production' && isDebugMode()) {\n /* eslint-disable no-console */\n const p = typeof path === 'string'\n ? `\"${path}\"` : 'none (entire state update)';\n console.groupCollapsed(`ReactGlobalState update. Path: ${p}`);\n console.log('New value:', cloneDeepForLog(value, path ?? ''));\n console.log('New state:', cloneDeepForLog(this.#currentState));\n console.groupEnd();\n /* eslint-enable no-console */\n }\n\n if (this.ssrContext) {\n this.ssrContext.dirty = true;\n this.ssrContext.state = this.#currentState;\n } else if (!this.#nextNotifierId) {\n this.#nextNotifierId = setTimeout(() => {\n this.#nextNotifierId = undefined;\n const watchers = [...this.#watchers];\n for (const watcher of watchers) watcher();\n });\n }\n }\n\n /**\n * Registers an abort callback for an async data retrieval operation with\n * the given operation ID. Throws if already registered.\n */\n setAsyncDataAbortCallback(opid: string, cb: () => void): void {\n this.#asyncDataAbortCallbacks[opid] = cb;\n }\n\n /**\n * Sets entire state, the same way as .set(null, value) would do.\n * @param value\n */\n setEntireState(value: StateT): StateT {\n if (this.#currentState !== value) {\n this.#currentState = value;\n this.notifyStateUpdate(null, value);\n }\n return value;\n }\n\n /**\n * Gets current or initial value at the specified \"path\" of the global state.\n * @param path Dot-delimitered state path.\n * @param options Additional options.\n * @param options.initialState If \"true\" the value will be read\n * from the initial state instead of the current one.\n * @param options.initialValue If the value read from the \"path\" is\n * \"undefined\", this \"initialValue\" will be returned instead. In such case\n * \"initialValue\" will also be written to the \"path\" of the current global\n * state (no matter \"initialState\" flag), if \"undefined\" is stored there.\n * @return Retrieved value.\n */\n\n // .get() without arguments just falls back to .getEntireState().\n get(): StateT;\n\n // This variant attempts to automatically resolve and check the type of value\n // at the given path, as precise as the actual state and path types permit.\n // If the automatic path resolution is not possible, the ValueT fallsback\n // to `never` (or to `undefined` in some cases), effectively forbidding\n // to use this .get() variant.\n get<\n PathT extends null | string | undefined,\n ValueArgT extends ValueAtPathT<StateT, PathT, never>,\n ValueResT extends ValueAtPathT<StateT, PathT, void>,\n >(path: PathT, opts?: GetOptsT<ValueArgT>): ValueResT;\n\n // This variant is not callable by default (without generic arguments),\n // otherwise it allows to set the correct ValueT directly.\n get<Forced extends ForceT | LockT = LockT, ValueT = void>(\n path?: null | string,\n opts?: GetOptsT<TypeLock<Forced, never, ValueT>>,\n ): TypeLock<Forced, void, ValueT>;\n\n get<ValueT>(path?: null | string, opts?: GetOptsT<ValueT>): ValueT {\n if (isNil(path)) {\n const res = this.getEntireState((opts as unknown) as GetOptsT<StateT>);\n return (res as unknown) as ValueT;\n }\n\n const state = opts?.initialState ? this.#initialState : this.#currentState;\n\n let res = get(state, path) as ValueT;\n if (res !== undefined || opts?.initialValue === undefined) return res;\n\n const iv = opts.initialValue;\n res = isFunction(iv) ? iv() : iv;\n\n // TODO: Revise.\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n if (!opts.initialState || (this.get(path) as unknown) === undefined) {\n this.set<ForceT, unknown>(path, res);\n }\n\n return res;\n }\n\n /**\n * Writes the `value` to given global state `path`.\n * @param path Dot-delimitered state path. If not given, entire\n * global state content is replaced by the `value`.\n * @param value The value.\n * @return Given `value` itself.\n */\n\n // This variant attempts automatic value type resolution & checking.\n set<\n PathT extends null | string | undefined,\n ValueArgT extends ValueAtPathT<StateT, PathT, never>,\n ValueResT extends ValueAtPathT<StateT, PathT, void>,\n >(path: PathT, value: ValueArgT): ValueResT;\n\n // This variant is disabled by default, otherwise allows to give\n // expected value type explicitly.\n set<Forced extends ForceT | LockT = LockT, ValueT = never>(\n path: null | string | undefined,\n value: TypeLock<Forced, never, ValueT>,\n ): TypeLock<Forced, void, ValueT>;\n\n set(path: null | string | undefined, value: unknown): unknown {\n if (isNil(path)) return this.setEntireState(value as StateT);\n\n // TODO: Revise.\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n if (value !== this.get(path)) {\n const root = { state: this.#currentState };\n let segIdx = 0;\n\n // TODO: It is not 100% correct, as `pos` can be an array, or any other\n // value as we travel through the state tree. To simplify the typing for\n // now, I guess, we can go with this record type, though.\n let pos: Record<string, unknown> = root;\n const pathSegments = toPath(`state.${path}`);\n for (; segIdx < pathSegments.length - 1; segIdx += 1) {\n const seg = pathSegments[segIdx]!;\n\n // TODO: Revise: Typing is not quite correct here, but it works fine in the runtime.\n const next = pos[seg];\n if (Array.isArray(next)) pos[seg] = [...(next as unknown[])];\n else if (isObject(next)) pos[seg] = { ...next };\n else {\n // We arrived to a state sub-segment, where the remaining part of\n // the update path does not exist yet. We rely on lodash's set()\n // function to create the remaining path, and set the value.\n set(pos, pathSegments.slice(segIdx), value);\n break;\n }\n pos = pos[seg] as Record<string, unknown>;\n }\n\n if (segIdx === pathSegments.length - 1) {\n pos[pathSegments[segIdx]!] = value;\n }\n\n this.#currentState = root.state;\n\n this.notifyStateUpdate(path, value);\n }\n return value;\n }\n\n /**\n * Unsubscribes `callback` from watching state updates; no operation if\n * `callback` is not subscribed to the state updates.\n * @param callback\n * @throws if {@link SsrContext} is attached to the state instance: the state\n * watching functionality is intended for client-side (non-SSR) only.\n */\n unWatch(callback: CallbackT): void {\n if (this.ssrContext) throw new Error(ERR_NO_SSR_WATCH);\n\n const watchers = this.#watchers;\n const pos = watchers.indexOf(callback);\n if (pos >= 0) {\n watchers[pos] = watchers[watchers.length - 1]!;\n watchers.pop();\n }\n }\n\n /**\n * Subscribes `callback` to watch state updates; no operation if\n * `callback` is already subscribed to this state instance.\n * @param callback It will be called without any arguments every\n * time the state content changes (note, howhever, separate state updates can\n * be applied to the state at once, and watching callbacks will be called once\n * after such bulk update).\n * @throws if {@link SsrContext} is attached to the state instance: the state\n * watching functionality is intended for client-side (non-SSR) only.\n */\n watch(callback: CallbackT): void {\n if (this.ssrContext) throw new Error(ERR_NO_SSR_WATCH);\n\n const watchers = this.#watchers;\n if (!watchers.includes(callback)) {\n watchers.push(callback);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAWA,IAAAC,MAAA,GAAAD,OAAA;AAWA,MAAME,gBAAgB,GAAG,gDAAgD;AAO1D,MAAMC,WAAW,CAG9B;EAGA,CAACC,uBAAuB,GAA+B,CAAC,CAAC;EAEzD,CAACC,YAAY,GAAuC,CAAC,CAAC;EAEtD,CAACC,YAAY;;EAEb;EACA;EACA;EACA;EACA,CAACC,QAAQ,GAAgB,EAAE;EAE3B,CAACC,cAAc;EAEf,CAACC,YAAY;;EAEb;AACF;AACA;AACA;AACA;EACEC,WAAWA,CACTJ,YAAoB,EACpBK,UAAwB,EACxB;IACA,IAAI,CAAC,CAACF,YAAY,GAAG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AK,CAACrE,gBAAgB,CAAC;IAEtD,MAAMK,QAAQ,GAAG,IAAI,CAAC,CAACA,QAAQ;IAC/B,MAAMqD,GAAG,GAAGrD,QAAQ,CAACiE,OAAO,CAACF,QAAQ,CAAC;IACtC,IAAIV,GAAG,IAAI,CAAC,EAAE;MACZrD,QAAQ,CAACqD,GAAG,CAAC,GAAGrD,QAAQ,CAACA,QAAQ,CAACqB,MAAM,GAAG,CAAC,CAAE;MAC9CrB,QAAQ,CAACkE,GAAG,CAAC,CAAC;IAChB;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,KAAKA,CAACJ,QAAmB,EAAQ;IAC/B,IAAI,IAAI,CAAC3D,UAAU,EAAE,MAAM,IAAI4D,KAAK,CAACrE,gBAAgB,CAAC;IAEtD,MAAMK,QAAQ,GAAG,IAAI,CAAC,CAACA,QAAQ;IAC/B,IAAI,CAACA,QAAQ,CAACoE,QAAQ,CAACL,QAAQ,CAAC,EAAE;MAChC/D,QAAQ,CAACqE,IAAI,CAACN,QAAQ,CAAC;IACzB;EACF;AACF;AAACO,OAAA,CAAAC,OAAA,GAAA3E,WAAA","ignoreList":[]}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
exports.getGlobalState = getGlobalState;
|
|
9
|
-
exports.getSsrContext = getSsrContext;
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
var _react = require("react");
|
|
12
|
-
var _GlobalState = _interopRequireDefault(require("./GlobalState"));
|
|
13
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
const Context = /*#__PURE__*/(0, _react.createContext)(null);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Gets {@link GlobalState} instance from the context. In most cases
|
|
18
|
-
* you should use {@link useGlobalState}, and other hooks to interact with
|
|
19
|
-
* the global state, instead of accessing it directly.
|
|
20
|
-
* @return
|
|
21
|
-
*/
|
|
22
|
-
function getGlobalState() {
|
|
23
|
-
// TODO: Think about it: on one hand we on purpose called this function
|
|
24
|
-
// as getGlobalState(), so that ppl looking for the state hook prefer using
|
|
25
|
-
// useGlobalState(), while this getGlobalState() is reserved for nieche cases;
|
|
26
|
-
// on the other hand, perhaps we can rename it into useSomething, to both
|
|
27
|
-
// follow conventions, and to keep stuff clearly named at the same time.
|
|
28
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
29
|
-
const globalState = (0, _react.use)(Context);
|
|
30
|
-
if (!globalState) throw new Error('Missing GlobalStateProvider');
|
|
31
|
-
return globalState;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @category Hooks
|
|
36
|
-
* @desc Gets SSR context.
|
|
37
|
-
* @param throwWithoutSsrContext If `true` (default),
|
|
38
|
-
* this hook will throw if no SSR context is attached to the global state;
|
|
39
|
-
* set `false` to not throw in such case. In either case the hook will throw
|
|
40
|
-
* if the {@link <GlobalStateProvider>} (hence the state) is missing.
|
|
41
|
-
* @returns SSR context.
|
|
42
|
-
* @throws
|
|
43
|
-
* - If current component has no parent {@link <GlobalStateProvider>}
|
|
44
|
-
* in the rendered React tree.
|
|
45
|
-
* - If `throwWithoutSsrContext` is `true`, and there is no SSR context attached
|
|
46
|
-
* to the global state provided by {@link <GlobalStateProvider>}.
|
|
47
|
-
*/
|
|
48
|
-
function getSsrContext(throwWithoutSsrContext = true) {
|
|
49
|
-
const {
|
|
50
|
-
ssrContext
|
|
51
|
-
} = getGlobalState();
|
|
52
|
-
if (!ssrContext && throwWithoutSsrContext) {
|
|
53
|
-
throw new Error('No SSR context found');
|
|
54
|
-
}
|
|
55
|
-
return ssrContext;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Provides global state to its children.
|
|
59
|
-
* @param prop.children Component children, which will be provided with
|
|
60
|
-
* the global state, and rendered in place of the provider.
|
|
61
|
-
* @param prop.initialState Initial content of the global state.
|
|
62
|
-
* @param prop.ssrContext Server-side rendering (SSR) context.
|
|
63
|
-
* @param prop.stateProxy This option is useful for code
|
|
64
|
-
* splitting and SSR implementation:
|
|
65
|
-
* - If `true`, this provider instance will fetch and reuse the global state
|
|
66
|
-
* from a parent provider.
|
|
67
|
-
* - If `GlobalState` instance, it will be used by this provider.
|
|
68
|
-
* - If not given, a new `GlobalState` instance will be created and used.
|
|
69
|
-
*/
|
|
70
|
-
const GlobalStateProvider = ({
|
|
71
|
-
children,
|
|
72
|
-
...rest
|
|
73
|
-
}) => {
|
|
74
|
-
const [localState, setLocalState] = (0, _react.useState)();
|
|
75
|
-
let state;
|
|
76
|
-
|
|
77
|
-
// Below we cast `rest.stateProxy` as "boolean" for safe backward
|
|
78
|
-
// compatibility with plain JavaScript (as TypeScript typings only
|
|
79
|
-
// permit "true" or GlobalState value; while legacy codebase may
|
|
80
|
-
// pass in a boolean value here, occasionally equal "false").
|
|
81
|
-
if ('stateProxy' in rest && rest.stateProxy) {
|
|
82
|
-
if (localState) setLocalState(undefined);
|
|
83
|
-
state = rest.stateProxy === true ? getGlobalState() : rest.stateProxy;
|
|
84
|
-
} else if (localState) {
|
|
85
|
-
state = localState;
|
|
86
|
-
} else {
|
|
87
|
-
const {
|
|
88
|
-
initialState,
|
|
89
|
-
ssrContext
|
|
90
|
-
} = rest;
|
|
91
|
-
state = new _GlobalState.default((0, _lodash.isFunction)(initialState) ? initialState() : initialState, ssrContext);
|
|
92
|
-
setLocalState(state);
|
|
93
|
-
}
|
|
94
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Context, {
|
|
95
|
-
value: state,
|
|
96
|
-
children: children
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
var _default = exports.default = GlobalStateProvider;
|
|
100
|
-
//# sourceMappingURL=GlobalStateProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalStateProvider.js","names":["_lodash","require","_react","_GlobalState","_interopRequireDefault","_jsxRuntime","Context","createContext","getGlobalState","globalState","use","Error","getSsrContext","throwWithoutSsrContext","ssrContext","GlobalStateProvider","children","rest","localState","setLocalState","useState","state","stateProxy","undefined","initialState","GlobalState","isFunction","jsx","value","_default","exports","default"],"sources":["../../src/GlobalStateProvider.tsx"],"sourcesContent":["import { isFunction } from 'lodash';\n\nimport {\n type ReactNode,\n createContext,\n use,\n useState,\n} from 'react';\n\nimport GlobalState from './GlobalState';\nimport type SsrContext from './SsrContext';\n\nimport type { ValueOrInitializerT } from './utils';\n\nconst Context = createContext<GlobalState<unknown> | null>(null);\n\n/**\n * Gets {@link GlobalState} instance from the context. In most cases\n * you should use {@link useGlobalState}, and other hooks to interact with\n * the global state, instead of accessing it directly.\n * @return\n */\nexport function getGlobalState<\n StateT,\n SsrContextT extends SsrContext<StateT> = SsrContext<StateT>,\n>(): GlobalState<StateT, SsrContextT> {\n // TODO: Think about it: on one hand we on purpose called this function\n // as getGlobalState(), so that ppl looking for the state hook prefer using\n // useGlobalState(), while this getGlobalState() is reserved for nieche cases;\n // on the other hand, perhaps we can rename it into useSomething, to both\n // follow conventions, and to keep stuff clearly named at the same time.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const globalState = use(Context);\n if (!globalState) throw new Error('Missing GlobalStateProvider');\n return globalState as GlobalState<StateT, SsrContextT>;\n}\n\n/**\n * @category Hooks\n * @desc Gets SSR context.\n * @param throwWithoutSsrContext If `true` (default),\n * this hook will throw if no SSR context is attached to the global state;\n * set `false` to not throw in such case. In either case the hook will throw\n * if the {@link <GlobalStateProvider>} (hence the state) is missing.\n * @returns SSR context.\n * @throws\n * - If current component has no parent {@link <GlobalStateProvider>}\n * in the rendered React tree.\n * - If `throwWithoutSsrContext` is `true`, and there is no SSR context attached\n * to the global state provided by {@link <GlobalStateProvider>}.\n */\nexport function getSsrContext<\n SsrContextT extends SsrContext<unknown>,\n>(\n throwWithoutSsrContext = true,\n): SsrContextT | undefined {\n const { ssrContext } = getGlobalState<SsrContextT['state'], SsrContextT>();\n if (!ssrContext && throwWithoutSsrContext) {\n throw new Error('No SSR context found');\n }\n return ssrContext;\n}\n\ntype NewStateProps<StateT, SsrContextT extends SsrContext<StateT>> = {\n initialState: ValueOrInitializerT<StateT>;\n ssrContext?: SsrContextT;\n};\n\ntype GlobalStateProviderProps<\n StateT,\n SsrContextT extends SsrContext<StateT>,\n> = {\n children?: ReactNode;\n} & (NewStateProps<StateT, SsrContextT> | {\n stateProxy: true | GlobalState<StateT, SsrContextT>;\n});\n\n/**\n * Provides global state to its children.\n * @param prop.children Component children, which will be provided with\n * the global state, and rendered in place of the provider.\n * @param prop.initialState Initial content of the global state.\n * @param prop.ssrContext Server-side rendering (SSR) context.\n * @param prop.stateProxy This option is useful for code\n * splitting and SSR implementation:\n * - If `true`, this provider instance will fetch and reuse the global state\n * from a parent provider.\n * - If `GlobalState` instance, it will be used by this provider.\n * - If not given, a new `GlobalState` instance will be created and used.\n */\nconst GlobalStateProvider = <\n StateT,\n SsrContextT extends SsrContext<StateT> = SsrContext<StateT>,\n>(\n { children, ...rest }: GlobalStateProviderProps<StateT, SsrContextT>,\n): ReactNode => {\n type GST = GlobalState<StateT, SsrContextT>;\n\n const [localState, setLocalState] = useState<GST>();\n\n let state: GST;\n\n // Below we cast `rest.stateProxy` as \"boolean\" for safe backward\n // compatibility with plain JavaScript (as TypeScript typings only\n // permit \"true\" or GlobalState value; while legacy codebase may\n // pass in a boolean value here, occasionally equal \"false\").\n if ('stateProxy' in rest && (rest.stateProxy as boolean)) {\n if (localState) setLocalState(undefined);\n state = rest.stateProxy === true ? getGlobalState() : rest.stateProxy;\n } else if (localState) {\n state = localState;\n } else {\n const {\n initialState,\n ssrContext,\n } = rest as NewStateProps<StateT, SsrContextT>;\n\n state = new GlobalState(\n isFunction(initialState) ? initialState() : initialState,\n ssrContext,\n );\n\n setLocalState(state);\n }\n\n return <Context value={state}>{children}</Context>;\n};\n\nexport default GlobalStateProvider;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAwC,IAAAI,WAAA,GAAAJ,OAAA;AAKxC,MAAMK,OAAO,gBAAG,IAAAC,oBAAa,EAA8B,IAAI,CAAC;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAGQ;EACpC;EACA;EACA;EACA;EACA;EACA;EACA,MAAMC,WAAW,GAAG,IAAAC,UAAG,EAACJ,OAAO,CAAC;EAChC,IAAI,CAACG,WAAW,EAAE,MAAM,IAAIE,KAAK,CAAC,6BAA6B,CAAC;EAChE,OAAOF,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAG3BC,sBAAsB,GAAG,IAAI,EACJ;EACzB,MAAM;IAAEC;EAAW,CAAC,GAAGN,cAAc,CAAoC,CAAC;EAC1E,IAAI,CAACM,UAAU,IAAID,sBAAsB,EAAE;IACzC,MAAM,IAAIF,KAAK,CAAC,sBAAsB,CAAC;EACzC;EACA,OAAOG,UAAU;AACnB;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAGA,CAI1B;EAAEC,QAAQ;EAAE,GAAGC;AAAoD,CAAC,KACtD;EAGd,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAAM,CAAC;EAEnD,IAAIC,KAAU;;EAEd;EACA;EACA;EACA;EACA,IAAI,YAAY,IAAIJ,IAAI,IAAKA,IAAI,CAACK,UAAsB,EAAE;IACxD,IAAIJ,UAAU,EAAEC,aAAa,CAACI,SAAS,CAAC;IACxCF,KAAK,GAAGJ,IAAI,CAACK,UAAU,KAAK,IAAI,GAAGd,cAAc,CAAC,CAAC,GAAGS,IAAI,CAACK,UAAU;EACvE,CAAC,MAAM,IAAIJ,UAAU,EAAE;IACrBG,KAAK,GAAGH,UAAU;EACpB,CAAC,MAAM;IACL,MAAM;MACJM,YAAY;MACZV;IACF,CAAC,GAAGG,IAA0C;IAE9CI,KAAK,GAAG,IAAII,oBAAW,CACrB,IAAAC,kBAAU,EAACF,YAAY,CAAC,GAAGA,YAAY,CAAC,CAAC,GAAGA,YAAY,EACxDV,UACF,CAAC;IAEDK,aAAa,CAACE,KAAK,CAAC;EACtB;EAEA,oBAAO,IAAAhB,WAAA,CAAAsB,GAAA,EAACrB,OAAO;IAACsB,KAAK,EAAEP,KAAM;IAAAL,QAAA,EAAEA;EAAQ,CAAU,CAAC;AACpD,CAAC;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEahB,mBAAmB","ignoreList":[]}
|
package/build/cjs/SsrContext.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
class SsrContext {
|
|
8
|
-
dirty = false;
|
|
9
|
-
pending = [];
|
|
10
|
-
constructor(state) {
|
|
11
|
-
this.state = state;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.default = SsrContext;
|
|
15
|
-
//# sourceMappingURL=SsrContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SsrContext.js","names":["SsrContext","dirty","pending","constructor","state","exports","default"],"sources":["../../src/SsrContext.ts"],"sourcesContent":["export default class SsrContext<StateT> {\n dirty: boolean = false;\n\n pending: Array<Promise<void>> = [];\n\n constructor(public state?: StateT) { }\n}\n"],"mappings":";;;;;;AAAe,MAAMA,UAAU,CAAS;EACtCC,KAAK,GAAY,KAAK;EAEtBC,OAAO,GAAyB,EAAE;EAElCC,WAAWA,CAAQC,KAAc,EAAE;IAAA,KAAhBA,KAAc,GAAdA,KAAc;EAAI;AACvC;AAACC,OAAA,CAAAC,OAAA,GAAAN,UAAA","ignoreList":[]}
|