Universal Layer Manager
    Preparing search index...

    Function layerMachine

    • Type Parameters

      Parameters

      • initialEnabledState: "disabled" | "enabled"
      • initialVisibleState: "hidden" | "visible"

      Returns StateMachine<
          LayerContext<TLayer, TGroup>,

              | { type: "LAYER.ENABLED" }
              | { type: "LAYER.DISABLED" }
              | { type: "PARENT.VISIBLE" }
              | { type: "PARENT.HIDDEN" }
              | { type: "PARENT.OPACITY_CHANGED"; opacity: number }
              | { type: "LAYER.SET_OPACITY"; opacity: number }
              | { type: "LAYER.SET_TIME_INFO"; timeInfo: LayerTimeInfo }
              | { type: "LAYER.SET_LAYER_DATA"; layerData: TLayer },
          {},
          never,
          ToParameterizedObject<
              {
                  "Notify Parent that layer is visible": NonReducibleUnknown;
                  "Notify Manager of visibility change": { visible: boolean };
                  "Update Computed Opacity": { opacity: number };
                  "Change Layer Opacity": { opacity: number };
                  "Change Layer Time Info": { timeInfo: LayerTimeInfo };
                  "Change Layer Data": { layerData: TLayer };
              },
          >,
          never,
          never,
          { disabled: "hidden" }
          | { enabled: "hidden" | "visible" },
          string,
          {
              layerManagerRef: LayerManager<TLayer, TGroup>;
              layerId: string;
              parentRef: ParentLayerActor | null;
              layerName: string;
              listMode?: "hide" | "show";
              opacity?: number;
              timeInfo?: LayerTimeInfo;
              layerData: TLayer;
          },
          NonReducibleUnknown,
          EventObject,
          MetaObject,
          ToStateSchema<
              {
                  id: "layer";
                  description: "A machine that represents a layer on the map.";
                  context: (
                      __namedParameters: {
                          spawn: {
                              <TSrc extends never>(
                                  logic: TSrc,
                                  ...__namedParameters: never,
                              ): ActorRefFromLogic<never>;
                              <TLogic extends AnyActorLogic>(
                                  src: TLogic,
                                  ...__namedParameters: ConditionalRequired<
                                      [
                                          options?: {
                                              id?: ...;
                                              systemId?: ...;
                                              input?: ...;
                                              syncSnapshot?: ...;
                                          } & { [K in (...)]: (...) },
                                      ],
                                      IsNotNever<RequiredLogicInput<TLogic>>,
                                  >,
                              ): ActorRefFromLogic<TLogic>;
                          };
                          input: {
                              layerManagerRef: LayerManager<TLayer, TGroup>;
                              layerId: string;
                              parentRef: ParentLayerActor | null;
                              layerName: string;
                              listMode?: "hide" | "show";
                              opacity?: number;
                              timeInfo?: LayerTimeInfo;
                              layerData: TLayer;
                          };
                          self: ActorRef<
                              MachineSnapshot<
                                  LayerContext<TLayer, TGroup>,

                                      | { type: "LAYER.ENABLED" }
                                      | { type: "LAYER.DISABLED" }
                                      | { type: "PARENT.VISIBLE" }
                                      | { type: "PARENT.HIDDEN" }
                                      | { type: "PARENT.OPACITY_CHANGED"; opacity: number }
                                      | { type: "LAYER.SET_OPACITY"; opacity: number }
                                      | { type: "LAYER.SET_TIME_INFO"; timeInfo: LayerTimeInfo }
                                      | { type: "LAYER.SET_LAYER_DATA"; layerData: TLayer },
                                  Record<string, AnyActorRef | undefined>,
                                  StateValue,
                                  string,
                                  unknown,
                                  any,
                                  any,
                              >,

                                  | { type: "LAYER.ENABLED" }
                                  | { type: "LAYER.DISABLED" }
                                  | { type: "PARENT.VISIBLE" }
                                  | { type: "PARENT.HIDDEN" }
                                  | { type: "PARENT.OPACITY_CHANGED"; opacity: number }
                                  | { type: "LAYER.SET_OPACITY"; opacity: number }
                                  | { type: "LAYER.SET_TIME_INFO"; timeInfo: LayerTimeInfo }
                                  | { type: "LAYER.SET_LAYER_DATA"; layerData: TLayer },
                              AnyEventObject,
                          >;
                      },
                  ) => {
                      layerManagerRef: LayerManager<TLayer, TGroup>;
                      parentRef: ParentLayerActor | null;
                      layerId: string;
                      layerName: string;
                      listMode: "hide" | "show";
                      opacity: number;
                      computedOpacity: number;
                      layerType: "layer";
                      timeInfo: LayerTimeInfo | undefined;
                      layerData: TLayer;
                  };
                  initial: "disabled"
                  | "enabled";
                  states: {
                      enabled: {
                          initial: "hidden" | "visible";
                          description: "The layer is enabled";
                          states: {
                              visible: {
                                  description: "The layer should appear visible on the map";
                                  entry: readonly [
                                      { type: "Notify Parent that layer is visible" },
                                      {
                                          type: "Notify Manager of visibility change";
                                          params: { visible: true };
                                      },
                                  ];
                                  exit: readonly [
                                      {
                                          type: "Notify Manager of visibility change";
                                          params: { visible: false };
                                      },
                                  ];
                                  on: { "PARENT.HIDDEN": { target: "hidden" } };
                              };
                              hidden: {
                                  description: "The layer should appear hidden on the map as its parent is hidden";
                                  on: { "PARENT.VISIBLE": { target: "visible" } };
                              };
                          };
                          on: { "LAYER.DISABLED": { target: "disabled" } };
                      };
                      disabled: {
                          description: "The layer is disabled";
                          initial: "hidden";
                          states: {
                              hidden: {
                                  description: "The layer should always appear hidden on the map";
                              };
                          };
                          on: { "LAYER.ENABLED": { target: "enabled.visible" } };
                      };
                  };
                  on: {
                      "PARENT.OPACITY_CHANGED": {
                          actions: readonly [
                              {
                                  type: "Update Computed Opacity";
                                  params: (
                                      __namedParameters: {
                                          context: LayerContext;
                                          event: { type: "PARENT.OPACITY_CHANGED"; opacity: number };
                                      },
                                  ) => { type: "PARENT.OPACITY_CHANGED"; opacity: number };
                              },
                          ];
                      };
                      "LAYER.SET_OPACITY": {
                          actions: readonly [
                              {
                                  type: "Change Layer Opacity";
                                  params: (
                                      __namedParameters: {
                                          context: LayerContext;
                                          event: { type: "LAYER.SET_OPACITY"; opacity: number };
                                      },
                                  ) => { type: "LAYER.SET_OPACITY"; opacity: number };
                              },
                          ];
                      };
                      "LAYER.SET_TIME_INFO": {
                          actions: readonly [
                              {
                                  type: "Change Layer Time Info";
                                  params: (
                                      __namedParameters: {
                                          context: LayerContext;
                                          event: { type: "LAYER.SET_TIME_INFO"; timeInfo: LayerTimeInfo };
                                      },
                                  ) => { type: "LAYER.SET_TIME_INFO"; timeInfo: LayerTimeInfo };
                              },
                          ];
                      };
                      "LAYER.SET_LAYER_DATA": {
                          actions: readonly [
                              {
                                  type: "Change Layer Data";
                                  params: (
                                      __namedParameters: {
                                          context: LayerContext;
                                          event: { type: "LAYER.SET_LAYER_DATA"; layerData: TLayer };
                                      },
                                  ) => { type: "LAYER.SET_LAYER_DATA"; layerData: TLayer };
                              },
                          ];
                      };
                  };
              },
          >,
      >