@lomray/react-mobx-manager 2.0.0-beta.3 → 2.0.0-beta.5
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Response } from 'express';
|
|
2
1
|
import Manager from "../manager.js";
|
|
3
2
|
/**
|
|
4
3
|
* Stream mobx manager stores
|
|
@@ -33,14 +32,7 @@ declare class StreamStores {
|
|
|
33
32
|
/**
|
|
34
33
|
* Listen react stream and push suspense stores state to client
|
|
35
34
|
*/
|
|
36
|
-
static
|
|
37
|
-
/**
|
|
38
|
-
* Begin listen stream
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* Begin listen stream
|
|
42
|
-
*/
|
|
43
|
-
protected beginStream(res: Response): void;
|
|
35
|
+
static getStreamState(html: string, manager: Manager): string | undefined;
|
|
44
36
|
/**
|
|
45
37
|
* Parse suspensions and related stores context id from application shell
|
|
46
38
|
* @protected
|
|
@@ -67,6 +59,6 @@ declare class StreamStores {
|
|
|
67
59
|
* Parse complete suspense chunk
|
|
68
60
|
* @protected
|
|
69
61
|
*/
|
|
70
|
-
protected obtainCompleteSuspense(html: string):
|
|
62
|
+
protected obtainCompleteSuspense(html: string): string | undefined;
|
|
71
63
|
}
|
|
72
64
|
export { StreamStores as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";class t{constructor(t){Object.defineProperty(this,"suspendIds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.manager=t}static
|
|
1
|
+
"use strict";class t{constructor(t){Object.defineProperty(this,"suspendIds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"manager",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.manager=t}static getStreamState(e,s){const n=new t(s);return n.obtainSuspensions(e),n.obtainCompleteSuspense(e)}obtainSuspensions(t){if(this.suspendIds)return;const e=[...t.matchAll(/<template id="(?<templateId>[^"]+)".+?<script data-context-id="(?<contextId>[^"]+)".+?data-count="(?<count>[^"]+)">/g)];e.length&&(this.suspendIds=e.reduce(((t,{groups:e})=>{const{templateId:s,contextId:n,count:r}=null!=e?e:{};return s?{...t,[s]:{contextId:n,count:Number(r)}}:t}),{}))}replaceSuspendIds(t,e){if(t)return this.suspendIds[e]=this.suspendIds[t],delete this.suspendIds[t],e}obtainCompleteSuspense(t){var e,s,n;if(!t.startsWith("<div hidden id="))return;const{from:r,to:i}=null!==(s=null===(e=t.match(/\$RC\("(?<from>[^"]+)","(?<to>[^"]+)"\)/))||void 0===e?void 0:e.groups)&&void 0!==s?s:{},o=this.replaceSuspendIds(r,i);if(!o)return;const{contextId:u,count:d}=null!==(n=this.suspendIds[o])&&void 0!==n?n:{};if(!u||!d)return;const a=this.manager.getStoresRelations(),c=this.manager.createContextId(u),l=[...Array(d)].reduce(((t,e,s)=>{const n=`${c}${s}`;return a.has(n)&&t.push(...a.get(n).ids),t}),[]);if(!l.length)return;return`<script>window.mobxManager.pushInit(${JSON.stringify(this.manager.toJSON(l))});<\/script>`}}module.exports=t;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lomray/react-mobx-manager",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
4
4
|
"description": "This package provides Mobx stores manager for react.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
"@lomray/eslint-config-react": "^3.0.0",
|
|
61
61
|
"@lomray/prettier-config": "^1.2.0",
|
|
62
62
|
"@rollup/plugin-terser": "^0.4.3",
|
|
63
|
-
"@types/express": "^4.17.17",
|
|
64
63
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
65
64
|
"@types/react": "^18.2.7",
|
|
66
65
|
"eslint": "^8.41.0",
|