Skip to content

Commit

Permalink
[skip ci] Example of adding sequenceadapter in afterAttach for baseTr…
Browse files Browse the repository at this point in the history
…ackConfig
  • Loading branch information
cmdcolin committed Nov 1, 2023
1 parent 52f2498 commit 96edcaa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
33 changes: 31 additions & 2 deletions packages/core/pluggableElementTypes/models/baseTrackConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { types, Instance } from 'mobx-state-tree'
import { ConfigurationSchema } from '../../configuration'
import { types, Instance, getSnapshot, getRoot } from 'mobx-state-tree'
import { ConfigurationSchema, readConfObject } from '../../configuration'
import PluginManager from '../../PluginManager'
import { getSession, notEmpty } from '../../util'

/**
* #config BaseTrack
Expand Down Expand Up @@ -81,6 +82,14 @@ export function createBaseTrackConfig(pluginManager: PluginManager) {
),
}),

/**
* #slot
*/
sequenceAdapters: {
type: 'frozen',
defaultValue: {},
},

/**
* #slot
*/
Expand Down Expand Up @@ -189,6 +198,26 @@ export function createBaseTrackConfig(pluginManager: PluginManager) {
const length = self.displays.push(conf)
return self.displays[length - 1]
},
setSequenceAdapters(a: Record<string, unknown>) {
self.sequenceAdapters = a
},
afterAttach() {
const { assemblyManager } = getRoot<any>(self)
const assemblyNames = readConfObject(
self,
'assemblyNames',
) as string[]
const map = Object.fromEntries(
assemblyNames
.map(a => {
const conf = assemblyManager.get(a)?.configuration
return conf ? ([a, getSnapshot(conf)] as const) : undefined
})
.filter(notEmpty),
)
console.log({ c: readConfObject(self), map })
self.setSequenceAdapters(map)
},
}),
},
)
Expand Down
1 change: 1 addition & 0 deletions packages/web-core/src/BaseWebSession/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export function BaseWebSession({
* #getter
*/
get assemblyManager(): AssemblyManager {
console.log('here', self.root.assemblyManager, getSnapshot(self.root))
return self.root.assemblyManager
},
/**
Expand Down

0 comments on commit 96edcaa

Please sign in to comment.