@grafana/scenes 5.12.0 → 5.13.0--canary.887.10699625611.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -30,6 +30,7 @@ class SceneObjectBase {
|
|
30
30
|
this._deactivationHandlers = /* @__PURE__ */ new Map();
|
31
31
|
this._subs = new Subscription();
|
32
32
|
this._refCount = 0;
|
33
|
+
this._UNSAFE_PARENT_ACTIVATION = false;
|
33
34
|
if (!state.key) {
|
34
35
|
state.key = v4();
|
35
36
|
}
|
@@ -186,12 +187,19 @@ class SceneObjectBase {
|
|
186
187
|
}
|
187
188
|
}
|
188
189
|
activate() {
|
190
|
+
let parentDeactivate;
|
191
|
+
if (this.parent && !this.parent.isActive && this._UNSAFE_PARENT_ACTIVATION) {
|
192
|
+
parentDeactivate = this.parent.activate();
|
193
|
+
}
|
189
194
|
if (!this.isActive) {
|
190
195
|
this._internalActivate();
|
191
196
|
}
|
192
197
|
this._refCount++;
|
193
198
|
let called = false;
|
194
199
|
return () => {
|
200
|
+
if (parentDeactivate) {
|
201
|
+
parentDeactivate();
|
202
|
+
}
|
195
203
|
this._refCount--;
|
196
204
|
if (called) {
|
197
205
|
const msg = `SceneObject cancelation handler returned by activate() called a second time`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SceneObjectBase.js","sources":["../../../src/core/SceneObjectBase.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { Subscription, Unsubscribable } from 'rxjs';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BusEvent, BusEventHandler, BusEventType, EventBus, EventBusSrv } from '@grafana/data';\nimport {\n SceneObject,\n SceneComponent,\n SceneObjectUrlSyncHandler,\n SceneStateChangedHandler,\n SceneActivationHandler,\n SceneDeactivationHandler,\n CancelActivationHandler,\n SceneObjectState,\n UseStateHookOptions,\n SceneStatelessBehavior,\n} from './types';\n\nimport { SceneComponentWrapper } from './SceneComponentWrapper';\nimport { SceneObjectStateChangedEvent } from './events';\nimport { cloneSceneObject } from './sceneGraph/utils';\nimport { SceneVariableDependencyConfigLike } from '../variables/types';\nimport { SceneObjectRef } from './SceneObjectRef';\n\nexport abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState>\n implements SceneObject<TState>\n{\n private _isActive = false;\n private _state: TState;\n private _activationHandlers: SceneActivationHandler[] = [];\n private _deactivationHandlers = new Map<object, SceneDeactivationHandler>();\n private _ref?: SceneObjectRef<this>;\n\n protected _events?: EventBus;\n protected _parent?: SceneObject;\n protected _subs = new Subscription();\n protected _refCount = 0;\n\n protected _variableDependency: SceneVariableDependencyConfigLike | undefined;\n protected _urlSync: SceneObjectUrlSyncHandler | undefined;\n\n public constructor(state: TState) {\n if (!state.key) {\n state.key = uuidv4();\n }\n\n this._events = new EventBusSrv();\n\n this._state = Object.freeze(state);\n this._setParent(this._state);\n }\n\n /** Current state */\n public get state(): TState {\n return this._state;\n }\n\n /** True if currently being active (ie displayed for visual objects) */\n public get isActive(): boolean {\n return this._isActive;\n }\n\n /** Returns the parent, undefined for root object */\n public get parent(): SceneObject | undefined {\n return this._parent;\n }\n\n /** Returns variable dependency config */\n public get variableDependency(): SceneVariableDependencyConfigLike | undefined {\n return this._variableDependency;\n }\n\n /** Returns url sync config */\n public get urlSync(): SceneObjectUrlSyncHandler | undefined {\n return this._urlSync;\n }\n\n /**\n * Used in render functions when rendering a SceneObject.\n * Wraps the component in an EditWrapper that handles edit mode\n */\n public get Component(): SceneComponent<this> {\n return SceneComponentWrapper as SceneComponent<this>;\n }\n\n private _setParent(state: Partial<TState>) {\n forEachChild(state, (child) => {\n // If we already have a parent and it's not this, then we likely have a bug\n if (child._parent && child._parent !== this) {\n console.warn(\n 'SceneObject already has a parent set that is different from the new parent. You cannot share the same SceneObject instance in multiple scenes or in multiple different places of the same scene graph. Use SceneObject.clone() to duplicate a SceneObject or store a state key reference and use sceneGraph.findObject to locate it.',\n child,\n this\n );\n }\n child._parent = this;\n });\n }\n\n /**\n * Subscribe to the scene state subject\n **/\n public subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable {\n return this._events!.subscribe(SceneObjectStateChangedEvent, (event) => {\n if (event.payload.changedObject === this) {\n handler(event.payload.newState as TState, event.payload.prevState as TState);\n }\n });\n }\n\n /**\n * Subscribe to the scene event\n **/\n public subscribeToEvent<T extends BusEvent>(eventType: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable {\n return this._events!.subscribe(eventType, handler);\n }\n\n public setState(update: Partial<TState>) {\n const prevState = this._state;\n const newState: TState = {\n ...this._state,\n ...update,\n };\n\n this._state = Object.freeze(newState);\n this._setParent(update);\n\n // Handles cases when $data, $timeRange, or $variables are changed\n this._handleActivationOfChangedStateProps(prevState, newState);\n\n // Bubble state change event. This is event is subscribed to by UrlSyncManager and UndoManager\n this.publishEvent(\n new SceneObjectStateChangedEvent({\n prevState,\n newState,\n partialUpdate: update,\n changedObject: this,\n }),\n true\n );\n }\n\n /**\n * This handles activation and deactivation of $data, $timeRange and $variables when they change\n * during the active phase of the scene object.\n */\n private _handleActivationOfChangedStateProps(prevState: TState, newState: TState) {\n if (!this.isActive) {\n return;\n }\n\n if (prevState.$behaviors !== newState.$behaviors) {\n this._handleChangedBehaviors(prevState.$behaviors, newState.$behaviors);\n }\n\n if (prevState.$data !== newState.$data) {\n this._handleChangedStateActivation(prevState.$data, newState.$data);\n }\n\n if (prevState.$variables !== newState.$variables) {\n this._handleChangedStateActivation(prevState.$variables, newState.$variables);\n }\n\n if (prevState.$timeRange !== newState.$timeRange) {\n this._handleChangedStateActivation(prevState.$timeRange, newState.$timeRange);\n }\n }\n\n private _handleChangedStateActivation(oldValue: SceneObject | undefined, newValue: SceneObject | undefined) {\n if (oldValue) {\n const deactivationHandler = this._deactivationHandlers.get(oldValue);\n if (deactivationHandler) {\n deactivationHandler();\n this._deactivationHandlers.delete(oldValue);\n }\n }\n\n if (newValue) {\n this._deactivationHandlers.set(newValue, newValue.activate());\n }\n }\n\n private _handleChangedBehaviors(\n oldValue: Array<SceneObject | SceneStatelessBehavior> | undefined,\n newValue: Array<SceneObject | SceneStatelessBehavior> | undefined\n ) {\n // Handle removed behaviors\n if (oldValue) {\n for (const oldBehavior of oldValue) {\n if (!newValue || !newValue.includes(oldBehavior)) {\n const deactivationHandler = this._deactivationHandlers.get(oldBehavior);\n if (deactivationHandler) {\n deactivationHandler();\n this._deactivationHandlers.delete(oldBehavior);\n }\n }\n }\n }\n\n // Handle new behaviors\n if (newValue) {\n for (const newBehavior of newValue) {\n if (!oldValue || !oldValue.includes(newBehavior)) {\n this._activateBehavior(newBehavior);\n }\n }\n }\n }\n\n /*\n * Publish an event and optionally bubble it up the scene\n **/\n public publishEvent(event: BusEvent, bubble?: boolean) {\n this._events!.publish(event);\n\n if (bubble && this.parent) {\n this.parent.publishEvent(event, bubble);\n }\n }\n\n public getRoot(): SceneObject {\n return !this._parent ? this : this._parent.getRoot();\n }\n\n private _internalActivate() {\n this._isActive = true;\n\n const { $data, $variables, $timeRange, $behaviors } = this.state;\n\n this._activationHandlers.forEach((handler) => {\n const result = handler();\n if (result) {\n this._deactivationHandlers.set(result, result);\n }\n });\n\n if ($timeRange && !$timeRange.isActive) {\n this._deactivationHandlers.set($timeRange, $timeRange.activate());\n }\n\n if ($variables && !$variables.isActive) {\n this._deactivationHandlers.set($variables, $variables.activate());\n }\n\n if ($data && !$data.isActive) {\n this._deactivationHandlers.set($data, $data.activate());\n }\n\n if ($behaviors) {\n for (const behavior of $behaviors) {\n this._activateBehavior(behavior);\n }\n }\n }\n\n private _activateBehavior(behavior: SceneObject | SceneStatelessBehavior): SceneDeactivationHandler | void {\n if (behavior instanceof SceneObjectBase) {\n this._deactivationHandlers.set(behavior, behavior.activate());\n } else if (typeof behavior === 'function') {\n const deactivate = behavior(this);\n if (deactivate) {\n this._deactivationHandlers.set(behavior, deactivate);\n }\n }\n }\n\n /**\n * This is primarily called from SceneComponentWrapper when the SceneObject's Component is mounted.\n * But in some scenarios this can also be called directly from another scene object. When called manually from another scene object\n * make sure to call the returned function when the source scene object is deactivated.\n */\n public activate(): CancelActivationHandler {\n if (!this.isActive) {\n this._internalActivate();\n }\n\n this._refCount++;\n\n let called = false;\n\n return () => {\n this._refCount--;\n\n if (called) {\n const msg = `SceneObject cancelation handler returned by activate() called a second time`;\n throw new Error(msg);\n }\n\n called = true;\n\n if (this._refCount === 0) {\n this._internalDeactivate();\n }\n };\n }\n\n /**\n * Called by the SceneComponentWrapper when the react component is unmounted.\n * Don't override this, instead use addActivationHandler. The activation handler can return a deactivation handler.\n */\n private _internalDeactivate(): void {\n this._isActive = false;\n\n for (let handler of this._deactivationHandlers.values()) {\n handler();\n }\n\n this._deactivationHandlers.clear();\n\n // Clear subscriptions and listeners\n this._events!.removeAllListeners();\n this._subs.unsubscribe();\n this._subs = new Subscription();\n }\n\n /**\n * Utility hook to get and subscribe to state\n */\n public useState(): TState {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useSceneObjectState(this);\n }\n\n /** Force a re-render, should only be needed when variable values change */\n public forceRender(): void {\n this.setState({});\n }\n\n /**\n * Will create new SceneObject with shallow-cloned state, but all state items of type SceneObject are deep cloned\n */\n public clone(withState?: Partial<TState>): this {\n return cloneSceneObject(this, withState);\n }\n\n /**\n * Allows external code to register code that is executed on activate and deactivate. This allow you\n * to wire up scene objects that need to respond to state changes in other objects from the outside.\n **/\n public addActivationHandler(handler: SceneActivationHandler) {\n this._activationHandlers.push(handler);\n }\n\n /**\n * Loop through state and call callback for each direct child scene object.\n * Checks 1 level deep properties and arrays. So a scene object hidden in a nested plain object will not be detected.\n */\n public forEachChild(callback: (child: SceneObjectBase) => void) {\n forEachChild(this.state, callback);\n }\n\n /** Returns a SceneObjectRef that will resolve to this object */\n public getRef(): SceneObjectRef<this> {\n if (!this._ref) {\n this._ref = new SceneObjectRef(this);\n }\n\n return this._ref;\n }\n}\n\n/**\n * This hook is always returning model.state instead of a useState that remembers the last state emitted on the subject\n * The reason for this is so that if the model instance change this function will always return the latest state.\n */\nexport function useSceneObjectState<TState extends SceneObjectState>(\n model: SceneObject<TState>,\n options?: UseStateHookOptions\n): TState {\n const [_, setState] = useState<TState>(model.state);\n const stateAtFirstRender = model.state;\n const shouldActivateOrKeepAlive = options?.shouldActivateOrKeepAlive ?? false;\n\n useEffect(() => {\n let unactivate: CancelActivationHandler | undefined;\n\n if (shouldActivateOrKeepAlive) {\n unactivate = model.activate();\n }\n\n const s = model.subscribeToState((state) => {\n setState(state);\n });\n\n // Re-render component if the state changed between first render and useEffect (mount)\n if (model.state !== stateAtFirstRender) {\n setState(model.state);\n }\n\n return () => {\n s.unsubscribe();\n\n if (unactivate) {\n unactivate();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [model, shouldActivateOrKeepAlive]);\n\n return model.state;\n}\n\nfunction forEachChild<T extends object>(state: T, callback: (child: SceneObjectBase) => void) {\n for (const propValue of Object.values(state)) {\n if (propValue instanceof SceneObjectBase) {\n callback(propValue);\n }\n\n if (Array.isArray(propValue)) {\n for (const child of propValue) {\n if (child instanceof SceneObjectBase) {\n callback(child);\n }\n }\n }\n }\n}\n"],"names":["uuidv4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAe,eAEtB,CAAA;AAAA,EAeS,YAAY,KAAe,EAAA;AAdlC,IAAA,IAAA,CAAQ,SAAY,GAAA,KAAA,CAAA;AAEpB,IAAA,IAAA,CAAQ,sBAAgD,EAAC,CAAA;AACzD,IAAQ,IAAA,CAAA,qBAAA,uBAA4B,GAAsC,EAAA,CAAA;AAK1E,IAAU,IAAA,CAAA,KAAA,GAAQ,IAAI,YAAa,EAAA,CAAA;AACnC,IAAA,IAAA,CAAU,SAAY,GAAA,CAAA,CAAA;AAMpB,IAAI,IAAA,CAAC,MAAM,GAAK,EAAA;AACd,MAAA,KAAA,CAAM,MAAMA,EAAO,EAAA,CAAA;AAAA,KACrB;AAEA,IAAK,IAAA,CAAA,OAAA,GAAU,IAAI,WAAY,EAAA,CAAA;AAE/B,IAAK,IAAA,CAAA,MAAA,GAAS,MAAO,CAAA,MAAA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AAA,yBAAyB,CAAC,CAAA,CAAA;AAErC,EAAA,OAAO,KAAM,CAAA,KAAA,CAAA;AACf,CAAA;AAEA,SAAS,YAAA,CAA+B,OAAU,QAA4C,EAAA;AAC5F,EAAA,KAAA,MAAW,SAAa,IAAA,MAAA,CAAO,MAAO,CAAA,KAAK,CAAG,EAAA;AAC5C,IAAA,IAAI,qBAAqB,eAAiB,EAAA;AACxC,MAAA,QAAA,CAAS,SAAS,CAAA,CAAA;AAAA,KACpB;AAEA,IAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,SAAS,CAAG,EAAA;AAC5B,MAAA,KAAA,MAAW,SAAS,SAAW,EAAA;AAC7B,QAAA,IAAI,iBAAiB,eAAiB,EAAA;AACpC,UAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAAA,SAChB;AAAA,OACF;AAAA,KACF;AAAA,GACF;AACF;;;;"}
|
1
|
+
{"version":3,"file":"SceneObjectBase.js","sources":["../../../src/core/SceneObjectBase.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { Subscription, Unsubscribable } from 'rxjs';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BusEvent, BusEventHandler, BusEventType, EventBus, EventBusSrv } from '@grafana/data';\nimport {\n SceneObject,\n SceneComponent,\n SceneObjectUrlSyncHandler,\n SceneStateChangedHandler,\n SceneActivationHandler,\n SceneDeactivationHandler,\n CancelActivationHandler,\n SceneObjectState,\n UseStateHookOptions,\n SceneStatelessBehavior,\n} from './types';\n\nimport { SceneComponentWrapper } from './SceneComponentWrapper';\nimport { SceneObjectStateChangedEvent } from './events';\nimport { cloneSceneObject } from './sceneGraph/utils';\nimport { SceneVariableDependencyConfigLike } from '../variables/types';\nimport { SceneObjectRef } from './SceneObjectRef';\n\nexport abstract class SceneObjectBase<TState extends SceneObjectState = SceneObjectState>\n implements SceneObject<TState>\n{\n private _isActive = false;\n private _state: TState;\n private _activationHandlers: SceneActivationHandler[] = [];\n private _deactivationHandlers = new Map<object, SceneDeactivationHandler>();\n private _ref?: SceneObjectRef<this>;\n\n protected _events?: EventBus;\n protected _parent?: SceneObject;\n protected _subs = new Subscription();\n protected _refCount = 0;\n\n protected _variableDependency: SceneVariableDependencyConfigLike | undefined;\n protected _urlSync: SceneObjectUrlSyncHandler | undefined;\n\n /**\n * @experimental feature to support rendering a child scene object without it's parent being rendered.\n * This flag will make it so that the parent is activated (if it's inactive) when this object is activated.\n */\n public _UNSAFE_PARENT_ACTIVATION = false;\n\n public constructor(state: TState) {\n if (!state.key) {\n state.key = uuidv4();\n }\n\n this._events = new EventBusSrv();\n\n this._state = Object.freeze(state);\n this._setParent(this._state);\n }\n\n /** Current state */\n public get state(): TState {\n return this._state;\n }\n\n /** True if currently being active (ie displayed for visual objects) */\n public get isActive(): boolean {\n return this._isActive;\n }\n\n /** Returns the parent, undefined for root object */\n public get parent(): SceneObject | undefined {\n return this._parent;\n }\n\n /** Returns variable dependency config */\n public get variableDependency(): SceneVariableDependencyConfigLike | undefined {\n return this._variableDependency;\n }\n\n /** Returns url sync config */\n public get urlSync(): SceneObjectUrlSyncHandler | undefined {\n return this._urlSync;\n }\n\n /**\n * Used in render functions when rendering a SceneObject.\n * Wraps the component in an EditWrapper that handles edit mode\n */\n public get Component(): SceneComponent<this> {\n return SceneComponentWrapper as SceneComponent<this>;\n }\n\n private _setParent(state: Partial<TState>) {\n forEachChild(state, (child) => {\n // If we already have a parent and it's not this, then we likely have a bug\n if (child._parent && child._parent !== this) {\n console.warn(\n 'SceneObject already has a parent set that is different from the new parent. You cannot share the same SceneObject instance in multiple scenes or in multiple different places of the same scene graph. Use SceneObject.clone() to duplicate a SceneObject or store a state key reference and use sceneGraph.findObject to locate it.',\n child,\n this\n );\n }\n child._parent = this;\n });\n }\n\n /**\n * Subscribe to the scene state subject\n **/\n public subscribeToState(handler: SceneStateChangedHandler<TState>): Unsubscribable {\n return this._events!.subscribe(SceneObjectStateChangedEvent, (event) => {\n if (event.payload.changedObject === this) {\n handler(event.payload.newState as TState, event.payload.prevState as TState);\n }\n });\n }\n\n /**\n * Subscribe to the scene event\n **/\n public subscribeToEvent<T extends BusEvent>(eventType: BusEventType<T>, handler: BusEventHandler<T>): Unsubscribable {\n return this._events!.subscribe(eventType, handler);\n }\n\n public setState(update: Partial<TState>) {\n const prevState = this._state;\n const newState: TState = {\n ...this._state,\n ...update,\n };\n\n this._state = Object.freeze(newState);\n this._setParent(update);\n\n // Handles cases when $data, $timeRange, or $variables are changed\n this._handleActivationOfChangedStateProps(prevState, newState);\n\n // Bubble state change event. This is event is subscribed to by UrlSyncManager and UndoManager\n this.publishEvent(\n new SceneObjectStateChangedEvent({\n prevState,\n newState,\n partialUpdate: update,\n changedObject: this,\n }),\n true\n );\n }\n\n /**\n * This handles activation and deactivation of $data, $timeRange and $variables when they change\n * during the active phase of the scene object.\n */\n private _handleActivationOfChangedStateProps(prevState: TState, newState: TState) {\n if (!this.isActive) {\n return;\n }\n\n if (prevState.$behaviors !== newState.$behaviors) {\n this._handleChangedBehaviors(prevState.$behaviors, newState.$behaviors);\n }\n\n if (prevState.$data !== newState.$data) {\n this._handleChangedStateActivation(prevState.$data, newState.$data);\n }\n\n if (prevState.$variables !== newState.$variables) {\n this._handleChangedStateActivation(prevState.$variables, newState.$variables);\n }\n\n if (prevState.$timeRange !== newState.$timeRange) {\n this._handleChangedStateActivation(prevState.$timeRange, newState.$timeRange);\n }\n }\n\n private _handleChangedStateActivation(oldValue: SceneObject | undefined, newValue: SceneObject | undefined) {\n if (oldValue) {\n const deactivationHandler = this._deactivationHandlers.get(oldValue);\n if (deactivationHandler) {\n deactivationHandler();\n this._deactivationHandlers.delete(oldValue);\n }\n }\n\n if (newValue) {\n this._deactivationHandlers.set(newValue, newValue.activate());\n }\n }\n\n private _handleChangedBehaviors(\n oldValue: Array<SceneObject | SceneStatelessBehavior> | undefined,\n newValue: Array<SceneObject | SceneStatelessBehavior> | undefined\n ) {\n // Handle removed behaviors\n if (oldValue) {\n for (const oldBehavior of oldValue) {\n if (!newValue || !newValue.includes(oldBehavior)) {\n const deactivationHandler = this._deactivationHandlers.get(oldBehavior);\n if (deactivationHandler) {\n deactivationHandler();\n this._deactivationHandlers.delete(oldBehavior);\n }\n }\n }\n }\n\n // Handle new behaviors\n if (newValue) {\n for (const newBehavior of newValue) {\n if (!oldValue || !oldValue.includes(newBehavior)) {\n this._activateBehavior(newBehavior);\n }\n }\n }\n }\n\n /*\n * Publish an event and optionally bubble it up the scene\n **/\n public publishEvent(event: BusEvent, bubble?: boolean) {\n this._events!.publish(event);\n\n if (bubble && this.parent) {\n this.parent.publishEvent(event, bubble);\n }\n }\n\n public getRoot(): SceneObject {\n return !this._parent ? this : this._parent.getRoot();\n }\n\n private _internalActivate() {\n this._isActive = true;\n\n const { $data, $variables, $timeRange, $behaviors } = this.state;\n\n this._activationHandlers.forEach((handler) => {\n const result = handler();\n if (result) {\n this._deactivationHandlers.set(result, result);\n }\n });\n\n if ($timeRange && !$timeRange.isActive) {\n this._deactivationHandlers.set($timeRange, $timeRange.activate());\n }\n\n if ($variables && !$variables.isActive) {\n this._deactivationHandlers.set($variables, $variables.activate());\n }\n\n if ($data && !$data.isActive) {\n this._deactivationHandlers.set($data, $data.activate());\n }\n\n if ($behaviors) {\n for (const behavior of $behaviors) {\n this._activateBehavior(behavior);\n }\n }\n }\n\n private _activateBehavior(behavior: SceneObject | SceneStatelessBehavior): SceneDeactivationHandler | void {\n if (behavior instanceof SceneObjectBase) {\n this._deactivationHandlers.set(behavior, behavior.activate());\n } else if (typeof behavior === 'function') {\n const deactivate = behavior(this);\n if (deactivate) {\n this._deactivationHandlers.set(behavior, deactivate);\n }\n }\n }\n\n /**\n * This is primarily called from SceneComponentWrapper when the SceneObject's Component is mounted.\n * But in some scenarios this can also be called directly from another scene object. When called manually from another scene object\n * make sure to call the returned function when the source scene object is deactivated.\n */\n public activate(): CancelActivationHandler {\n // If parent is not active, activate parent first\n let parentDeactivate: CancelActivationHandler | undefined;\n if (this.parent && !this.parent.isActive && this._UNSAFE_PARENT_ACTIVATION) {\n parentDeactivate = this.parent.activate();\n }\n\n if (!this.isActive) {\n this._internalActivate();\n }\n\n this._refCount++;\n\n let called = false;\n\n return () => {\n if (parentDeactivate) {\n parentDeactivate();\n }\n\n this._refCount--;\n\n if (called) {\n const msg = `SceneObject cancelation handler returned by activate() called a second time`;\n throw new Error(msg);\n }\n\n called = true;\n\n if (this._refCount === 0) {\n this._internalDeactivate();\n }\n };\n }\n\n /**\n * Called by the SceneComponentWrapper when the react component is unmounted.\n * Don't override this, instead use addActivationHandler. The activation handler can return a deactivation handler.\n */\n private _internalDeactivate(): void {\n this._isActive = false;\n\n for (let handler of this._deactivationHandlers.values()) {\n handler();\n }\n\n this._deactivationHandlers.clear();\n\n // Clear subscriptions and listeners\n this._events!.removeAllListeners();\n this._subs.unsubscribe();\n this._subs = new Subscription();\n }\n\n /**\n * Utility hook to get and subscribe to state\n */\n public useState(): TState {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useSceneObjectState(this);\n }\n\n /** Force a re-render, should only be needed when variable values change */\n public forceRender(): void {\n this.setState({});\n }\n\n /**\n * Will create new SceneObject with shallow-cloned state, but all state items of type SceneObject are deep cloned\n */\n public clone(withState?: Partial<TState>): this {\n return cloneSceneObject(this, withState);\n }\n\n /**\n * Allows external code to register code that is executed on activate and deactivate. This allow you\n * to wire up scene objects that need to respond to state changes in other objects from the outside.\n **/\n public addActivationHandler(handler: SceneActivationHandler) {\n this._activationHandlers.push(handler);\n }\n\n /**\n * Loop through state and call callback for each direct child scene object.\n * Checks 1 level deep properties and arrays. So a scene object hidden in a nested plain object will not be detected.\n */\n public forEachChild(callback: (child: SceneObjectBase) => void) {\n forEachChild(this.state, callback);\n }\n\n /** Returns a SceneObjectRef that will resolve to this object */\n public getRef(): SceneObjectRef<this> {\n if (!this._ref) {\n this._ref = new SceneObjectRef(this);\n }\n\n return this._ref;\n }\n}\n\n/**\n * This hook is always returning model.state instead of a useState that remembers the last state emitted on the subject\n * The reason for this is so that if the model instance change this function will always return the latest state.\n */\nexport function useSceneObjectState<TState extends SceneObjectState>(\n model: SceneObject<TState>,\n options?: UseStateHookOptions\n): TState {\n const [_, setState] = useState<TState>(model.state);\n const stateAtFirstRender = model.state;\n const shouldActivateOrKeepAlive = options?.shouldActivateOrKeepAlive ?? false;\n\n useEffect(() => {\n let unactivate: CancelActivationHandler | undefined;\n\n if (shouldActivateOrKeepAlive) {\n unactivate = model.activate();\n }\n\n const s = model.subscribeToState((state) => {\n setState(state);\n });\n\n // Re-render component if the state changed between first render and useEffect (mount)\n if (model.state !== stateAtFirstRender) {\n setState(model.state);\n }\n\n return () => {\n s.unsubscribe();\n\n if (unactivate) {\n unactivate();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [model, shouldActivateOrKeepAlive]);\n\n return model.state;\n}\n\nfunction forEachChild<T extends object>(state: T, callback: (child: SceneObjectBase) => void) {\n for (const propValue of Object.values(state)) {\n if (propValue instanceof SceneObjectBase) {\n callback(propValue);\n }\n\n if (Array.isArray(propValue)) {\n for (const child of propValue) {\n if (child instanceof SceneObjectBase) {\n callback(child);\n }\n }\n }\n }\n}\n"],"names":["uuidv4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAe,eAEtB,CAAA;AAAA,EAqBS,YAAY,KAAe,EAAA;AApBlC,IAAA,IAAA,CAAQ,SAAY,GAAA,KAAA,CAAA;AAEpB,IAAA,IAAA,CAAQ,sBAAgD,EAAC,CAAA;AACzD,IAAQ,IAAA,CAAA,qBAAA,uBAA4B,GAAsC,EAAA,CAAA;AAK1E,IAAU,IAAA,CAAA,KAAA,GAAQ,IAAI,YAAa,EAAA,CAAA;AACnC,IAAA,IAAA,CAAU,SAAY,GAAA,CAAA,CAAA;AAStB,IAAA,IAAA,CAAO,yBAA4B,GAAA,KAAA,CAAA;AAGjC,IAAI,IAAA,CAAC,MAAM,GAAK,EAAA;AACd,MAAA,KAAA,CAAM,MAAMA,EAAO,EAAA,CAAA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A,KAAA,CAAM,gBAAiB,CAAA,CAAC,KAAU,KAAA;AAC1C,MAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAAA,KACf,CAAA,CAAA;AAGD,IAAI,IAAA,KAAA,CAAM,UAAU,kBAAoB,EAAA;AACtC,MAAA,QAAA,CAAS,MAAM,KAAK,CAAA,CAAA;AAAA,KACtB;AAEA,IAAA,OAAO,MAAM;AACX,MAAA,CAAA,CAAE,WAAY,EAAA,CAAA;AAEd,MAAA,IAAI,UAAY,EAAA;AACd,QAAW,UAAA,EAAA,CAAA;AAAA,OACb;AAAA,KACF,CAAA;AAAA,GAEC,EAAA,CAAC,KAAO,EAAA,yBAAyB,CAAC,CAAA,CAAA;AAErC,EAAA,OAAO,KAAM,CAAA,KAAA,CAAA;AACf,CAAA;AAEA,SAAS,YAAA,CAA+B,OAAU,QAA4C,EAAA;AAC5F,EAAA,KAAA,MAAW,SAAa,IAAA,MAAA,CAAO,MAAO,CAAA,KAAK,CAAG,EAAA;AAC5C,IAAA,IAAI,qBAAqB,eAAiB,EAAA;AACxC,MAAA,QAAA,CAAS,SAAS,CAAA,CAAA;AAAA,KACpB;AAEA,IAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,SAAS,CAAG,EAAA;AAC5B,MAAA,KAAA,MAAW,SAAS,SAAW,EAAA;AAC7B,QAAA,IAAI,iBAAiB,eAAiB,EAAA;AACpC,UAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAAA,SAChB;AAAA,OACF;AAAA,KACF;AAAA,GACF;AACF;;;;"}
|
package/dist/esm/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { getUrlWithAppState } from './components/SceneApp/utils';\nimport { registerRuntimePanelPlugin } from './components/VizPanel/registerRuntimePanelPlugin';\nimport { cloneSceneObjectState } from './core/sceneGraph/utils';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport { renderPrometheusLabelFilters } from './variables/utils';\nimport {\n isAdHocVariable,\n isQueryVariable,\n isTextBoxVariable,\n isCustomVariable,\n isDataSourceVariable,\n isConstantVariable,\n isIntervalVariable,\n isGroupByVariable,\n} from './variables/variants/guards';\n\nexport * from './core/types';\nexport * from './core/events';\nexport { sceneGraph } from './core/sceneGraph';\nexport * as behaviors from './behaviors';\nexport * as dataLayers from './querying/layers';\n\nexport { SceneObjectBase, useSceneObjectState } from './core/SceneObjectBase';\nexport { SceneDataNode } from './core/SceneDataNode';\nexport { SceneTimeRange } from './core/SceneTimeRange';\nexport { SceneTimeZoneOverride } from './core/SceneTimeZoneOverride';\n\nexport { SceneQueryRunner, type QueryRunnerState } from './querying/SceneQueryRunner';\nexport {\n type ExtraQueryDescriptor,\n type ExtraQueryProvider,\n type ExtraQueryDataProcessor,\n} from './querying/ExtraQueryProvider';\nexport { SceneDataLayerSet, SceneDataLayerSetBase } from './querying/SceneDataLayerSet';\nexport { SceneDataLayerBase } from './querying/layers/SceneDataLayerBase';\nexport { SceneDataLayerControls } from './querying/layers/SceneDataLayerControls';\nexport { SceneDataTransformer } from './querying/SceneDataTransformer';\nexport { registerQueryWithController } from './querying/registerQueryWithController';\nexport { registerRuntimeDataSource, RuntimeDataSource } from './querying/RuntimeDataSource';\nexport type {\n SceneQueryControllerLike,\n SceneQueryControllerEntryType,\n SceneQueryControllerEntry,\n} from './behaviors/SceneQueryController';\n\nexport * from './variables/types';\nexport { VariableDependencyConfig } from './variables/VariableDependencyConfig';\nexport { formatRegistry, type FormatVariable } from './variables/interpolation/formatRegistry';\nexport { VariableValueSelectors } from './variables/components/VariableValueSelectors';\nexport { VariableValueControl } from './variables/components/VariableValueControl';\nexport { SceneVariableSet } from './variables/sets/SceneVariableSet';\nexport { ConstantVariable } from './variables/variants/ConstantVariable';\nexport { CustomVariable } from './variables/variants/CustomVariable';\nexport { DataSourceVariable } from './variables/variants/DataSourceVariable';\nexport { QueryVariable } from './variables/variants/query/QueryVariable';\nexport { TestVariable } from './variables/variants/TestVariable';\nexport { TextBoxVariable } from './variables/variants/TextBoxVariable';\nexport {\n MultiValueVariable,\n type MultiValueVariableState,\n type VariableGetOptionsArgs,\n} from './variables/variants/MultiValueVariable';\nexport { LocalValueVariable } from './variables/variants/LocalValueVariable';\nexport { IntervalVariable } from './variables/variants/IntervalVariable';\nexport { AdHocFiltersVariable } from './variables/adhoc/AdHocFiltersVariable';\nexport { GroupByVariable } from './variables/groupby/GroupByVariable';\nexport { type MacroVariableConstructor } from './variables/macros/types';\n\nexport { type UrlSyncManagerLike, UrlSyncManager, getUrlSyncManager } from './services/UrlSyncManager';\nexport { useUrlSync } from './services/useUrlSync';\nexport { UrlSyncContextProvider } from './services/UrlSyncContextProvider';\nexport { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig';\n\nexport { EmbeddedScene, type EmbeddedSceneState } from './components/EmbeddedScene';\nexport { VizPanel, type VizPanelState } from './components/VizPanel/VizPanel';\nexport { VizPanelMenu } from './components/VizPanel/VizPanelMenu';\nexport { NestedScene } from './components/NestedScene';\nexport { SceneCanvasText } from './components/SceneCanvasText';\nexport { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton';\nexport { SceneTimePicker } from './components/SceneTimePicker';\nexport { SceneRefreshPicker, type SceneRefreshPickerState } from './components/SceneRefreshPicker';\nexport { SceneTimeRangeTransformerBase } from './core/SceneTimeRangeTransformerBase';\nexport { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare';\nexport { SceneByFrameRepeater } from './components/SceneByFrameRepeater';\nexport { SceneByVariableRepeater } from './components/SceneByVariableRepeater';\nexport { SceneControlsSpacer } from './components/SceneControlsSpacer';\nexport {\n SceneFlexLayout,\n SceneFlexItem,\n type SceneFlexItemState,\n type SceneFlexItemLike,\n} from './components/layout/SceneFlexLayout';\nexport { SceneCSSGridLayout, SceneCSSGridItem } from './components/layout/CSSGrid/SceneCSSGridLayout';\nexport { SceneGridLayout } from './components/layout/grid/SceneGridLayout';\nexport { SceneGridItem } from './components/layout/grid/SceneGridItem';\nexport { SceneGridRow } from './components/layout/grid/SceneGridRow';\nexport { type SceneGridItemStateLike, type SceneGridItemLike } from './components/layout/grid/types';\nexport { SplitLayout } from './components/layout/split/SplitLayout';\nexport {\n type SceneAppPageLike,\n type SceneRouteMatch,\n type SceneAppPageState,\n type SceneAppDrilldownView,\n type SceneAppRoute,\n} from './components/SceneApp/types';\nexport { SceneApp, useSceneApp } from './components/SceneApp/SceneApp';\nexport { SceneAppPage } from './components/SceneApp/SceneAppPage';\nexport { SceneReactObject } from './components/SceneReactObject';\nexport { SceneObjectRef } from './core/SceneObjectRef';\nexport {\n PanelBuilders,\n PanelOptionsBuilders,\n FieldConfigBuilders,\n FieldConfigOverridesBuilder,\n} from './core/PanelBuilders';\nexport { FieldConfigBuilder } from './core/PanelBuilders/FieldConfigBuilder';\nexport { VizPanelBuilder } from './core/PanelBuilders/VizPanelBuilder';\nexport { SceneDebugger } from './components/SceneDebugger/SceneDebugger';\nexport { VariableValueSelectWrapper } from './variables/components/VariableValueSelectors';\nexport { renderSelectForVariable } from './variables/components/VariableValueSelect';\nexport { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder';\nexport { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders';\nexport { type VizConfig } from './core/PanelBuilders/types';\n\nexport const sceneUtils = {\n getUrlWithAppState,\n registerRuntimePanelPlugin,\n registerRuntimeDataSource,\n registerVariableMacro,\n cloneSceneObjectState,\n syncStateFromSearchParams,\n getUrlState,\n renderPrometheusLabelFilters,\n\n // Variable guards\n isAdHocVariable,\n isConstantVariable,\n isCustomVariable,\n isDataSourceVariable,\n isIntervalVariable,\n isQueryVariable,\n isTextBoxVariable,\n isGroupByVariable,\n};\n\nexport { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HO,MAAM,UAAa,GAAA;AAAA,EACxB,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,4BAAA;AAAA,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AACF;;;;"}
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { getUrlWithAppState } from './components/SceneApp/utils';\nimport { registerRuntimePanelPlugin } from './components/VizPanel/registerRuntimePanelPlugin';\nimport { cloneSceneObjectState } from './core/sceneGraph/utils';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport { renderPrometheusLabelFilters } from './variables/utils';\nimport {\n isAdHocVariable,\n isQueryVariable,\n isTextBoxVariable,\n isCustomVariable,\n isDataSourceVariable,\n isConstantVariable,\n isIntervalVariable,\n isGroupByVariable,\n} from './variables/variants/guards';\n\nexport * from './core/types';\nexport * from './core/events';\nexport { sceneGraph } from './core/sceneGraph';\nexport * as behaviors from './behaviors';\nexport * as dataLayers from './querying/layers';\n\nexport { SceneObjectBase, useSceneObjectState } from './core/SceneObjectBase';\nexport { SceneDataNode } from './core/SceneDataNode';\nexport { SceneTimeRange } from './core/SceneTimeRange';\nexport { SceneTimeZoneOverride } from './core/SceneTimeZoneOverride';\n\nexport { SceneQueryRunner, type QueryRunnerState } from './querying/SceneQueryRunner';\nexport {\n type ExtraQueryDescriptor,\n type ExtraQueryProvider,\n type ExtraQueryDataProcessor,\n} from './querying/ExtraQueryProvider';\nexport { SceneDataLayerSet, SceneDataLayerSetBase } from './querying/SceneDataLayerSet';\nexport { SceneDataLayerBase } from './querying/layers/SceneDataLayerBase';\nexport { SceneDataLayerControls } from './querying/layers/SceneDataLayerControls';\nexport { SceneDataTransformer, type SceneDataTransformerState } from './querying/SceneDataTransformer';\nexport { registerQueryWithController } from './querying/registerQueryWithController';\nexport { registerRuntimeDataSource, RuntimeDataSource } from './querying/RuntimeDataSource';\nexport type {\n SceneQueryControllerLike,\n SceneQueryControllerEntryType,\n SceneQueryControllerEntry,\n} from './behaviors/SceneQueryController';\n\nexport * from './variables/types';\nexport { VariableDependencyConfig } from './variables/VariableDependencyConfig';\nexport { formatRegistry, type FormatVariable } from './variables/interpolation/formatRegistry';\nexport { VariableValueSelectors } from './variables/components/VariableValueSelectors';\nexport { VariableValueControl } from './variables/components/VariableValueControl';\nexport { SceneVariableSet } from './variables/sets/SceneVariableSet';\nexport { ConstantVariable } from './variables/variants/ConstantVariable';\nexport { CustomVariable } from './variables/variants/CustomVariable';\nexport { DataSourceVariable } from './variables/variants/DataSourceVariable';\nexport { QueryVariable } from './variables/variants/query/QueryVariable';\nexport { TestVariable } from './variables/variants/TestVariable';\nexport { TextBoxVariable } from './variables/variants/TextBoxVariable';\nexport {\n MultiValueVariable,\n type MultiValueVariableState,\n type VariableGetOptionsArgs,\n} from './variables/variants/MultiValueVariable';\nexport { LocalValueVariable } from './variables/variants/LocalValueVariable';\nexport { IntervalVariable } from './variables/variants/IntervalVariable';\nexport { AdHocFiltersVariable } from './variables/adhoc/AdHocFiltersVariable';\nexport { GroupByVariable } from './variables/groupby/GroupByVariable';\nexport { type MacroVariableConstructor } from './variables/macros/types';\n\nexport { type UrlSyncManagerLike, UrlSyncManager, getUrlSyncManager } from './services/UrlSyncManager';\nexport { useUrlSync } from './services/useUrlSync';\nexport { UrlSyncContextProvider } from './services/UrlSyncContextProvider';\nexport { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig';\n\nexport { EmbeddedScene, type EmbeddedSceneState } from './components/EmbeddedScene';\nexport { VizPanel, type VizPanelState } from './components/VizPanel/VizPanel';\nexport { VizPanelMenu } from './components/VizPanel/VizPanelMenu';\nexport { NestedScene } from './components/NestedScene';\nexport { SceneCanvasText } from './components/SceneCanvasText';\nexport { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton';\nexport { SceneTimePicker } from './components/SceneTimePicker';\nexport { SceneRefreshPicker, type SceneRefreshPickerState } from './components/SceneRefreshPicker';\nexport { SceneTimeRangeTransformerBase } from './core/SceneTimeRangeTransformerBase';\nexport { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare';\nexport { SceneByFrameRepeater } from './components/SceneByFrameRepeater';\nexport { SceneByVariableRepeater } from './components/SceneByVariableRepeater';\nexport { SceneControlsSpacer } from './components/SceneControlsSpacer';\nexport {\n SceneFlexLayout,\n SceneFlexItem,\n type SceneFlexItemState,\n type SceneFlexItemLike,\n} from './components/layout/SceneFlexLayout';\nexport { SceneCSSGridLayout, SceneCSSGridItem } from './components/layout/CSSGrid/SceneCSSGridLayout';\nexport { SceneGridLayout } from './components/layout/grid/SceneGridLayout';\nexport { SceneGridItem } from './components/layout/grid/SceneGridItem';\nexport { SceneGridRow } from './components/layout/grid/SceneGridRow';\nexport { type SceneGridItemStateLike, type SceneGridItemLike } from './components/layout/grid/types';\nexport { SplitLayout } from './components/layout/split/SplitLayout';\nexport {\n type SceneAppPageLike,\n type SceneRouteMatch,\n type SceneAppPageState,\n type SceneAppDrilldownView,\n type SceneAppRoute,\n} from './components/SceneApp/types';\nexport { SceneApp, useSceneApp } from './components/SceneApp/SceneApp';\nexport { SceneAppPage } from './components/SceneApp/SceneAppPage';\nexport { SceneReactObject } from './components/SceneReactObject';\nexport { SceneObjectRef } from './core/SceneObjectRef';\nexport {\n PanelBuilders,\n PanelOptionsBuilders,\n FieldConfigBuilders,\n FieldConfigOverridesBuilder,\n} from './core/PanelBuilders';\nexport { FieldConfigBuilder } from './core/PanelBuilders/FieldConfigBuilder';\nexport { VizPanelBuilder } from './core/PanelBuilders/VizPanelBuilder';\nexport { SceneDebugger } from './components/SceneDebugger/SceneDebugger';\nexport { VariableValueSelectWrapper } from './variables/components/VariableValueSelectors';\nexport { renderSelectForVariable } from './variables/components/VariableValueSelect';\nexport { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder';\nexport { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders';\nexport { type VizConfig } from './core/PanelBuilders/types';\n\nexport const sceneUtils = {\n getUrlWithAppState,\n registerRuntimePanelPlugin,\n registerRuntimeDataSource,\n registerVariableMacro,\n cloneSceneObjectState,\n syncStateFromSearchParams,\n getUrlState,\n renderPrometheusLabelFilters,\n\n // Variable guards\n isAdHocVariable,\n isConstantVariable,\n isCustomVariable,\n isDataSourceVariable,\n isIntervalVariable,\n isQueryVariable,\n isTextBoxVariable,\n isGroupByVariable,\n};\n\nexport { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HO,MAAM,UAAa,GAAA;AAAA,EACxB,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,4BAAA;AAAA,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AACF;;;;"}
|
package/dist/index.d.ts
CHANGED
@@ -364,6 +364,11 @@ declare abstract class SceneObjectBase<TState extends SceneObjectState = SceneOb
|
|
364
364
|
protected _refCount: number;
|
365
365
|
protected _variableDependency: SceneVariableDependencyConfigLike | undefined;
|
366
366
|
protected _urlSync: SceneObjectUrlSyncHandler | undefined;
|
367
|
+
/**
|
368
|
+
* @experimental feature to support rendering a child scene object without it's parent being rendered.
|
369
|
+
* This flag will make it so that the parent is activated (if it's inactive) when this object is activated.
|
370
|
+
*/
|
371
|
+
_UNSAFE_PARENT_ACTIVATION: boolean;
|
367
372
|
constructor(state: TState);
|
368
373
|
/** Current state */
|
369
374
|
get state(): TState;
|
@@ -2712,4 +2717,4 @@ declare const sceneUtils: {
|
|
2712
2717
|
isGroupByVariable: typeof isGroupByVariable;
|
2713
2718
|
};
|
2714
2719
|
|
2715
|
-
export { AdHocFiltersVariable, CancelActivationHandler, ConstantVariable, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariable, CustomVariableValue, DataLayerFilter, DataRequestEnricher, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, FiltersRequestEnricher, FormatVariable, GroupByVariable, InterpolationFormatParameter, IntervalVariable, LocalValueVariable, MacroVariableConstructor, MultiValueVariable, MultiValueVariableState, NestedScene, PanelBuilders, PanelOptionsBuilders, QueryRunnerState, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformer, SceneDeactivationHandler, SceneDebugger, SceneFlexItem, SceneFlexItemLike, SceneFlexItemState, SceneFlexLayout, SceneGridItem, SceneGridItemLike, SceneGridItemStateLike, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeLike, SceneTimeRangeState, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UrlSyncManagerLike, UseStateHookOptions, UserActionEvent, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableDependencyConfig, VariableGetOptionsArgs, VariableValue, VariableValueControl, VariableValueOption, VariableValueSelectWrapper, VariableValueSelectors, VariableValueSingle, VizConfig, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelMenu, VizPanelState, index$1 as behaviors, index as dataLayers, formatRegistry, getUrlSyncManager, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, renderSelectForVariable, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
|
2720
|
+
export { AdHocFiltersVariable, CancelActivationHandler, ConstantVariable, ControlsLayout, CustomFormatterVariable, CustomTransformOperator, CustomTransformerDefinition, CustomVariable, CustomVariableValue, DataLayerFilter, DataRequestEnricher, DataSourceVariable, DeepPartial, EmbeddedScene, EmbeddedSceneState, ExtraQueryDataProcessor, ExtraQueryDescriptor, ExtraQueryProvider, FieldConfigBuilder, FieldConfigBuilders, FieldConfigOverridesBuilder, FiltersRequestEnricher, FormatVariable, GroupByVariable, InterpolationFormatParameter, IntervalVariable, LocalValueVariable, MacroVariableConstructor, MultiValueVariable, MultiValueVariableState, NestedScene, PanelBuilders, PanelOptionsBuilders, QueryRunnerState, QueryVariable, RuntimeDataSource, SafeSerializableSceneObject, SceneActivationHandler, SceneApp, SceneAppDrilldownView, SceneAppPage, SceneAppPageLike, SceneAppPageState, SceneAppRoute, SceneByFrameRepeater, SceneByVariableRepeater, SceneCSSGridItem, SceneCSSGridLayout, SceneCanvasText, SceneComponent, SceneComponentProps, SceneControlsSpacer, SceneDataLayerBase, SceneDataLayerControls, SceneDataLayerProvider, SceneDataLayerProviderState, SceneDataLayerSet, SceneDataLayerSetBase, SceneDataNode, SceneDataProvider, SceneDataProviderResult, SceneDataQuery, SceneDataState, SceneDataTransformer, SceneDataTransformerState, SceneDeactivationHandler, SceneDebugger, SceneFlexItem, SceneFlexItemLike, SceneFlexItemState, SceneFlexLayout, SceneGridItem, SceneGridItemLike, SceneGridItemStateLike, SceneGridLayout, SceneGridRow, SceneLayout, SceneLayoutChildOptions, SceneLayoutState, SceneObject, SceneObjectBase, SceneObjectRef, SceneObjectState, SceneObjectStateChangedEvent, SceneObjectStateChangedPayload, SceneObjectUrlSyncConfig, SceneObjectUrlSyncHandler, SceneObjectUrlValue, SceneObjectUrlValues, SceneObjectWithUrlSync, SceneQueryControllerEntry, SceneQueryControllerEntryType, SceneQueryControllerLike, SceneQueryRunner, SceneReactObject, SceneRefreshPicker, SceneRefreshPickerState, SceneRouteMatch, SceneStateChangedHandler, SceneStatelessBehavior, SceneTimePicker, SceneTimeRange, SceneTimeRangeCompare, SceneTimeRangeLike, SceneTimeRangeState, SceneTimeRangeTransformerBase, SceneTimeZoneOverride, SceneToolbarButton, SceneToolbarInput, SceneVariable, SceneVariableDependencyConfigLike, SceneVariableSet, SceneVariableSetState, SceneVariableState, SceneVariableValueChangedEvent, SceneVariables, SplitLayout, TestVariable, TextBoxVariable, UrlSyncContextProvider, UrlSyncManager, UrlSyncManagerLike, UseStateHookOptions, UserActionEvent, ValidateAndUpdateResult, VariableCustomFormatterFn, VariableDependencyConfig, VariableGetOptionsArgs, VariableValue, VariableValueControl, VariableValueOption, VariableValueSelectWrapper, VariableValueSelectors, VariableValueSingle, VizConfig, VizConfigBuilder, VizConfigBuilders, VizPanel, VizPanelBuilder, VizPanelMenu, VizPanelState, index$1 as behaviors, index as dataLayers, formatRegistry, getUrlSyncManager, isCustomVariableValue, isDataLayer, isDataRequestEnricher, isFiltersRequestEnricher, isSceneObject, registerQueryWithController, registerRuntimeDataSource, renderSelectForVariable, sceneGraph, sceneUtils, useSceneApp, useSceneObjectState, useUrlSync };
|
package/dist/index.js
CHANGED
@@ -241,6 +241,7 @@ class SceneObjectBase {
|
|
241
241
|
this._deactivationHandlers = /* @__PURE__ */ new Map();
|
242
242
|
this._subs = new rxjs.Subscription();
|
243
243
|
this._refCount = 0;
|
244
|
+
this._UNSAFE_PARENT_ACTIVATION = false;
|
244
245
|
if (!state.key) {
|
245
246
|
state.key = uuid.v4();
|
246
247
|
}
|
@@ -397,12 +398,19 @@ class SceneObjectBase {
|
|
397
398
|
}
|
398
399
|
}
|
399
400
|
activate() {
|
401
|
+
let parentDeactivate;
|
402
|
+
if (this.parent && !this.parent.isActive && this._UNSAFE_PARENT_ACTIVATION) {
|
403
|
+
parentDeactivate = this.parent.activate();
|
404
|
+
}
|
400
405
|
if (!this.isActive) {
|
401
406
|
this._internalActivate();
|
402
407
|
}
|
403
408
|
this._refCount++;
|
404
409
|
let called = false;
|
405
410
|
return () => {
|
411
|
+
if (parentDeactivate) {
|
412
|
+
parentDeactivate();
|
413
|
+
}
|
406
414
|
this._refCount--;
|
407
415
|
if (called) {
|
408
416
|
const msg = `SceneObject cancelation handler returned by activate() called a second time`;
|