@@ -67,10 +67,11 @@ function restoreStateFromDSL(dsl: string) {
6767 if ( sharedComponentInstances ) {
6868 restoreSharedComponentInstances ( sharedComponentInstances ) ;
6969 }
70+
71+ regenerateAllEventDeps ( ) ;
7072}
7173
7274function restoreGlobal ( { data, style, events, meta } : ReturnType < typeof parseDSL > ) {
73- restoreEventDep ( DepsFromType . Global , { events } ) ;
7475 return globalStore . setState ( store => {
7576 store . globalData = data ;
7677 store . globalStyle = style ;
@@ -84,7 +85,6 @@ function restorePageInstances(pages: PageInstance[]) {
8485 const { key, componentInstances, pluginInstances } = page ;
8586 page . componentInstances = restoreComponentInstances ( key , componentInstances ) ;
8687 page . pluginInstances = restorePluginInstances ( key , pluginInstances ! ) ;
87- restoreEventDep ( DepsFromType . Page , page ) ;
8888 } ) ;
8989 return pagesStore . setState ( store => ( store . pages = pages ) ) ;
9090}
@@ -93,15 +93,13 @@ function restoreComponentInstances(pageKey: number, iComponentInstances: Compone
9393 const componentInstances = iComponentInstances . filter ( filterComponent ) ;
9494 const indexMap = generateComponentsIndex ( componentInstances ) ;
9595 addPageComponentInstanceIndexMap ( pageKey , indexMap ) ;
96- componentInstances . forEach ( R . unary ( R . partial ( restoreEventDep , [ DepsFromType . Component ] ) ) ) ;
9796 return componentInstances ;
9897}
9998
10099function restorePluginInstances ( pageKey : number , iPluginInstances : PluginInstance [ ] ) {
101100 const pluginInstances = iPluginInstances . filter ( filterPlugin ) ;
102101 const indexMap = generatePluginsIndex ( pluginInstances ) ;
103102 addPagePluginInstanceIndexMap ( pageKey , indexMap ) ;
104- pluginInstances . forEach ( R . unary ( R . partial ( restoreEventDep , [ DepsFromType . Plugin ] ) ) ) ;
105103 return pluginInstances ;
106104}
107105
@@ -111,10 +109,44 @@ function restoreSharedComponentInstances(iComponentInstances: ComponentInstance[
111109
112110 const indexMap = generateComponentsIndex ( componentInstances ) ;
113111 setSharedComponentIndexMap ( indexMap ) ;
114- componentInstances . forEach ( R . unary ( R . partial ( restoreEventDep , [ DepsFromType . Component ] ) ) ) ;
115112 return componentInstances ;
116113}
117114
115+ function restoreEditInfo ( { maxKeys, layoutMode, pageMode } : EditInfoDSL ) {
116+ editStore . setState ( editStore => {
117+ editStore . layoutMode = layoutMode ;
118+ editStore . pageMode = pageMode ;
119+ } ) ;
120+
121+ if ( maxKeys ) {
122+ setMaxKey ( InstanceKeyType . Page , maxKeys [ InstanceKeyType . Page ] ) ;
123+ setMaxKey ( InstanceKeyType . Component , maxKeys [ InstanceKeyType . Component ] ) ;
124+ setMaxKey ( InstanceKeyType . HotArea , maxKeys [ InstanceKeyType . HotArea ] ) ;
125+ setMaxKey ( InstanceKeyType . Plugin , maxKeys [ InstanceKeyType . Plugin ] ) ;
126+ setMaxKey ( InstanceKeyType . Action , maxKeys [ InstanceKeyType . Action ] ) ;
127+ }
128+ }
129+
130+ interface ExtraInfo {
131+ owner : UserRecord ;
132+ }
133+
134+ function restoreExtraInfo ( { owner } : ExtraInfo ) {
135+ return editStore . setState ( store => {
136+ store . owner = owner ;
137+ } , true ) ;
138+ }
139+
140+ export function regenerateAllEventDeps ( ) {
141+ restoreEventDep ( DepsFromType . Global , { events : globalStore . globalEvents } ) ;
142+ pagesStore . pages . forEach ( page => {
143+ restoreEventDep ( DepsFromType . Page , page ) ;
144+ page . componentInstances . forEach ( R . unary ( R . partial ( restoreEventDep , [ DepsFromType . Component ] ) ) ) ;
145+ page . pluginInstances . forEach ( R . unary ( R . partial ( restoreEventDep , [ DepsFromType . Plugin ] ) ) ) ;
146+ } ) ;
147+ sharedStore . sharedComponentInstances . forEach ( R . unary ( R . partial ( restoreEventDep , [ DepsFromType . Component ] ) ) ) ;
148+ }
149+
118150function restoreEventDep (
119151 depsFromType : DepsFromType ,
120152 instance : PageInstance | ComponentInstance | PluginInstance | HotArea | { events : EventInstance [ ] } ,
@@ -141,28 +173,3 @@ function restoreEventDep(
141173 }
142174 } ) ;
143175}
144-
145- function restoreEditInfo ( { maxKeys, layoutMode, pageMode } : EditInfoDSL ) {
146- editStore . setState ( editStore => {
147- editStore . layoutMode = layoutMode ;
148- editStore . pageMode = pageMode ;
149- } ) ;
150-
151- if ( maxKeys ) {
152- setMaxKey ( InstanceKeyType . Page , maxKeys [ InstanceKeyType . Page ] ) ;
153- setMaxKey ( InstanceKeyType . Component , maxKeys [ InstanceKeyType . Component ] ) ;
154- setMaxKey ( InstanceKeyType . HotArea , maxKeys [ InstanceKeyType . HotArea ] ) ;
155- setMaxKey ( InstanceKeyType . Plugin , maxKeys [ InstanceKeyType . Plugin ] ) ;
156- setMaxKey ( InstanceKeyType . Action , maxKeys [ InstanceKeyType . Action ] ) ;
157- }
158- }
159-
160- interface ExtraInfo {
161- owner : UserRecord ;
162- }
163-
164- function restoreExtraInfo ( { owner } : ExtraInfo ) {
165- return editStore . setState ( store => {
166- store . owner = owner ;
167- } , true ) ;
168- }
0 commit comments