@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.
- package/dist/AppApi.d.ts +18 -0
- package/dist/AppApi.js +1 -0
- package/dist/Plugin.d.ts +4 -1
- package/dist/Plugin.js +5 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +1 -0
- package/dist/types/handler/base/BaseHandler.d.ts +1 -0
- package/dist/types/handler/base/Handler.d.ts +1 -0
- package/dist/types/handler/ui/screen/CreateCustomScreenHandler.d.ts +2 -1
- package/dist/types/handler/ui/screen/CreateScreenHandler.d.ts +1 -2
- package/dist/types/handler/ui/screen/ScreenHandlerArgs.d.ts +1 -3
- package/dist/types/handler/ui/screen/ScreenHandlerResponse.d.ts +1 -1
- package/dist/types/handler/ui/screen/StoreWrapper.d.ts +3 -3
- package/dist/types/handler/ui/screen/ZustandStoreWrapper.d.ts +1 -1
- package/dist/types/handler/ui/screen/ZustandStoreWrapper.js +2 -2
- package/package.json +1 -1
package/dist/AppApi.d.ts
ADDED
|
@@ -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
|
-
|
|
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,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 =
|
|
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 =
|
|
5
|
+
type CreateScreenHandler<S extends StoreWrapper<S> = StoreWrapper> = CreateCustomScreenHandler<S> & {};
|
|
7
6
|
export default CreateScreenHandler;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
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,4 +1,4 @@
|
|
|
1
|
-
type StoreWrapper<T> = {
|
|
2
|
-
|
|
3
|
-
|
|
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.
|
|
11
|
-
hook.
|
|
10
|
+
hook.getStateFromWrapper = store.getState;
|
|
11
|
+
hook.setStateFromWrapper = store.setState;
|
|
12
12
|
hook.subscribe = store.subscribe;
|
|
13
13
|
return hook;
|
|
14
14
|
}
|