@d-najd/universal-media-tracker-sdk 0.3.10 → 0.3.13

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.
@@ -0,0 +1,18 @@
1
+ import Handler from './types/handler/base/Handler';
2
+ import Navigator from './navigator/Navigator';
3
+ export default interface AppApi {
4
+ plugins: AppPluginsApi;
5
+ ui: AppUIApi;
6
+ }
7
+ export interface AppPluginsApi {
8
+ getHandlersMatching(condition: (entry: Handler) => boolean): Handler[];
9
+ /**
10
+ * key is id of the plugin
11
+ * @param condition key is pluginId, value is handler
12
+ */
13
+ getHandlersMatchingWithPluginId(condition: (entry: [string, Handler]) => boolean): Map<string, Handler[]>;
14
+ invokeCallbackOnHandler<T, R>(id: string, args: T): Promise<R>;
15
+ }
16
+ export interface AppUIApi {
17
+ navigator: Navigator;
18
+ }
package/dist/AppApi.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/Plugin.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import PluginConfig from './types/PluginConfig';
2
+ import Handler from './types/handler/base/Handler';
2
3
  import CreateCatalogHandler from './types/handler/media/catalog/CreateCatalogHandler';
3
4
  import CreateResourceHandler from './types/handler/media/CreateResourceHandler';
4
5
  import CreatePluginSourceHandler from './types/handler/plugin/source/CreatePluginSourceHandler';
@@ -6,12 +7,14 @@ import CreateHandler from './types/handler/base/CreateHandler';
6
7
  import CreatePluginFactoryHandler from './types/handler/plugin/factory/CreatePluginFactoryHandler';
7
8
  import CreateScreenHandler from './types/handler/ui/screen/CreateScreenHandler';
8
9
  import CreateCustomScreenHandler from './types/handler/ui/screen/CreateCustomScreenHandler';
10
+ import AppApi from './AppApi';
9
11
  export default class Plugin {
10
12
  readonly config: PluginConfig;
13
+ app: AppApi;
11
14
  /**
12
15
  * key is the handler id
13
16
  */
14
- private handlers;
17
+ protected handlers: Map<string, Handler>;
15
18
  private counter;
16
19
  private loaded;
17
20
  constructor(options: PluginConfig);
package/dist/Plugin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export default class Plugin {
2
2
  config;
3
+ app = {}; // Stub, set before onLoad
3
4
  /**
4
5
  * key is the handler id
5
6
  */
@@ -88,7 +89,10 @@ export default class Plugin {
88
89
  const newHandler = {
89
90
  id: `${this.config.id}-ui-screen-${this.counter++}`,
90
91
  ...handler,
91
- type: 'ui-screen'
92
+ type: 'ui-screen',
93
+ callback: () => {
94
+ throw Error("Don't use regular callback for ui!");
95
+ }
92
96
  };
93
97
  return this.defineHandler(newHandler);
94
98
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { default as Plugin } from './Plugin';
2
+ export { default as AppApi } from './AppApi';
3
+ export * from './AppApi';
2
4
  export { default as TriState } from './types/TriState';
3
5
  export { default as PluginSpec } from './types/PluginSpec';
4
6
  export { default as PluginConfig } from './types/PluginConfig';
@@ -19,6 +21,12 @@ export { default as ScreenHandlerResponse } from './types/handler/ui/screen/Scre
19
21
  export { default as ScreenHandlerArgs } from './types/handler/ui/screen/ScreenHandlerArgs';
20
22
  export { default as CreateScreenHandler } from './types/handler/ui/screen/CreateScreenHandler';
21
23
  export { default as CreateCustomScreenHandler } from './types/handler/ui/screen/CreateCustomScreenHandler';
24
+ export { default as PluginSourceHandlerResponse } from './types/handler/plugin/source/PluginSourceHandlerResponse';
25
+ export { default as PluginSourceHandlerArgs } from './types/handler/plugin/source/PluginSourceHandlerArgs';
26
+ export { default as CreatePluginSourceHandler } from './types/handler/plugin/source/CreatePluginSourceHandler';
27
+ export { default as PluginFactoryHandlerResponse } from './types/handler/plugin/factory/PluginFactoryHandlerResponse';
28
+ export { default as PluginFactoryHandlerArgs } from './types/handler/plugin/factory/PluginFactoryHandlerArgs';
29
+ export { default as CreatePluginFactoryHandler } from './types/handler/plugin/factory/CreatePluginFactoryHandler';
22
30
  export { default as MetaPreview } from './types/handler/media/catalog/MetaPreview';
23
31
  export { default as CreateCatalogHandler } from './types/handler/media/catalog/CreateCatalogHandler';
24
32
  export { default as CatalogHandlerResponse } from './types/handler/media/catalog/CatalogHandlerResponse';
@@ -26,9 +34,3 @@ export { default as CatalogHandlerArgs } from './types/handler/media/catalog/Cat
26
34
  export { default as ResourceBrowseOptionDefaults } from './types/handler/media/browse-option/ResourceBrowseOptionDefaults';
27
35
  export { default as ResourceBrowseOptionArgs } from './types/handler/media/browse-option/ResourceBrowseOptionArgs';
28
36
  export { default as ResourceBrowseOption } from './types/handler/media/browse-option/ResourceBrowseOption';
29
- export { default as PluginSourceHandlerResponse } from './types/handler/plugin/source/PluginSourceHandlerResponse';
30
- export { default as PluginSourceHandlerArgs } from './types/handler/plugin/source/PluginSourceHandlerArgs';
31
- export { default as CreatePluginSourceHandler } from './types/handler/plugin/source/CreatePluginSourceHandler';
32
- export { default as PluginFactoryHandlerResponse } from './types/handler/plugin/factory/PluginFactoryHandlerResponse';
33
- export { default as PluginFactoryHandlerArgs } from './types/handler/plugin/factory/PluginFactoryHandlerArgs';
34
- export { default as CreatePluginFactoryHandler } from './types/handler/plugin/factory/CreatePluginFactoryHandler';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  // Auto‑generated barrel file – do not edit manually
2
2
  export { default as Plugin } from './Plugin';
3
+ export * from './AppApi';
3
4
  export * from './types/handler/ui/screen/ZustandStoreWrapper';
@@ -6,5 +6,6 @@ type BaseHandler<T = any, R = any> = {
6
6
  readonly id?: string;
7
7
  readonly type?: string;
8
8
  readonly callback: (args: T) => Promise<R>;
9
+ readonly callbackSync?: (args: T) => R;
9
10
  };
10
11
  export default BaseHandler;
@@ -4,5 +4,6 @@ type Handler<T = any, R = any> = BaseHandler<T, R> & {
4
4
  readonly id: string;
5
5
  readonly type: HandlerTypes | string;
6
6
  readonly callback: (args: T) => Promise<R>;
7
+ readonly callbackSync?: (args: T) => R;
7
8
  };
8
9
  export default Handler;
@@ -1,7 +1,7 @@
1
1
  import BaseHandler from '../../base/BaseHandler';
2
2
  import ScreenHandlerArgs from './ScreenHandlerArgs';
3
3
  import ScreenHandlerResponse from './ScreenHandlerResponse';
4
- type CreateCustomScreenHandler<S = any> = BaseHandler<ScreenHandlerArgs<S>, ScreenHandlerResponse> & {
4
+ type CreateCustomScreenHandler<S extends StoreWrapper<S> = StoreWrapper> = BaseHandler<ScreenHandlerArgs<S>, ScreenHandlerResponse> & {
5
5
  /**
6
6
  * /library/:id
7
7
  */
@@ -10,5 +10,6 @@ type CreateCustomScreenHandler<S = any> = BaseHandler<ScreenHandlerArgs<S>, Scre
10
10
  * If undefined screen state won't be stored
11
11
  */
12
12
  readonly initialState?: S;
13
+ readonly callbackSync: (args: ScreenHandlerArgs<S>) => ScreenHandlerResponse;
13
14
  };
14
15
  export default CreateCustomScreenHandler;
@@ -1,7 +1,6 @@
1
1
  import CreateCustomScreenHandler from './CreateCustomScreenHandler';
2
- import { ZustandStoreWrapper } from "./ZustandStoreWrapper";
3
2
  /**
4
3
  * Uses zustand, react is also recommended
5
4
  */
6
- type CreateScreenHandler<S = any> = CreateCustomScreenHandler<ZustandStoreWrapper<S>> & {};
5
+ type CreateScreenHandler<S extends StoreWrapper<S> = StoreWrapper> = CreateCustomScreenHandler<S> & {};
7
6
  export default CreateScreenHandler;
@@ -1,10 +1,8 @@
1
- import Navigator from '../../../../navigator/Navigator';
2
- type ScreenHandlerArgs<S = any> = {
1
+ type ScreenHandlerArgs<S extends StoreWrapper<S> = StoreWrapper> = {
3
2
  /**
4
3
  * If undefined in handler won't be passed here
5
4
  */
6
5
  readonly state?: S;
7
- readonly navigator: Navigator;
8
6
  /**
9
7
  * /library/1
10
8
  */
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
2
  type ScreenHandlerResponse = {
3
- readonly content: ReactNode;
3
+ readonly content: () => ReactNode;
4
4
  };
5
5
  export default ScreenHandlerResponse;
@@ -1,4 +1,4 @@
1
- type StoreWrapper<T> = {
2
- getState(): T;
3
- setState(state: T): void;
1
+ type StoreWrapper<T = any> = {
2
+ getStateFromWrapper(): T;
3
+ setStateFromWrapper(state: T): void;
4
4
  };
@@ -1,3 +1,3 @@
1
1
  import { StoreApi, UseBoundStore } from "zustand";
2
- export type ZustandStoreWrapper<S> = UseBoundStore<StoreApi<S>> & StoreWrapper<S>;
2
+ export type ZustandStoreWrapper<S = any> = UseBoundStore<StoreApi<S>> & StoreWrapper<S>;
3
3
  export declare function createZustandStoreWrapper<S>(initial: S): ZustandStoreWrapper<S>;
@@ -7,8 +7,8 @@ export function createZustandStoreWrapper(initial) {
7
7
  return store.getState();
8
8
  return selector(store.getState());
9
9
  });
10
- hook.getState = store.getState;
11
- hook.setState = store.setState;
10
+ hook.getStateFromWrapper = store.getState;
11
+ hook.setStateFromWrapper = store.setState;
12
12
  hook.subscribe = store.subscribe;
13
13
  return hook;
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-najd/universal-media-tracker-sdk",
3
- "version": "0.3.10",
3
+ "version": "0.3.13",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [