@weavix/sdk-react 0.0.1 → 0.0.2

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.
Files changed (33) hide show
  1. package/README.md +36 -28
  2. package/dist/index.mjs +528 -835
  3. package/dist/index.mjs.map +1 -1
  4. package/dist/plugin-sdk-react/src/__tests__/setup.d.ts +1 -0
  5. package/dist/plugin-sdk-react/src/__tests__/setup.d.ts.map +1 -0
  6. package/dist/plugin-sdk-react/src/components/ErrorBoundary.d.ts +17 -0
  7. package/dist/plugin-sdk-react/src/components/ErrorBoundary.d.ts.map +1 -0
  8. package/dist/plugin-sdk-react/src/components/PluginError.d.ts +9 -0
  9. package/dist/plugin-sdk-react/src/components/PluginError.d.ts.map +1 -0
  10. package/dist/plugin-sdk-react/src/components/PluginLoader.d.ts +6 -0
  11. package/dist/plugin-sdk-react/src/components/PluginLoader.d.ts.map +1 -0
  12. package/dist/plugin-sdk-react/src/components/PluginProvider.d.ts +107 -0
  13. package/dist/plugin-sdk-react/src/components/PluginProvider.d.ts.map +1 -0
  14. package/dist/plugin-sdk-react/src/hooks/useConfirm.d.ts +6 -0
  15. package/dist/plugin-sdk-react/src/hooks/useConfirm.d.ts.map +1 -0
  16. package/dist/plugin-sdk-react/src/hooks/useContext.d.ts +20 -0
  17. package/dist/plugin-sdk-react/src/hooks/useContext.d.ts.map +1 -0
  18. package/dist/plugin-sdk-react/src/hooks/useIsYateam.d.ts +13 -0
  19. package/dist/plugin-sdk-react/src/hooks/useIsYateam.d.ts.map +1 -0
  20. package/dist/plugin-sdk-react/src/hooks/useLanguage.d.ts +13 -0
  21. package/dist/plugin-sdk-react/src/hooks/useLanguage.d.ts.map +1 -0
  22. package/dist/plugin-sdk-react/src/hooks/useLocalizedString.d.ts +6 -0
  23. package/dist/plugin-sdk-react/src/hooks/useLocalizedString.d.ts.map +1 -0
  24. package/dist/plugin-sdk-react/src/hooks/useTheme.d.ts +14 -0
  25. package/dist/plugin-sdk-react/src/hooks/useTheme.d.ts.map +1 -0
  26. package/dist/plugin-sdk-react/src/hooks/useToaster.d.ts +8 -0
  27. package/dist/plugin-sdk-react/src/hooks/useToaster.d.ts.map +1 -0
  28. package/dist/plugin-sdk-react/src/hooks/useUserId.d.ts +13 -0
  29. package/dist/plugin-sdk-react/src/hooks/useUserId.d.ts.map +1 -0
  30. package/dist/plugin-sdk-react/src/index.d.ts +16 -0
  31. package/dist/plugin-sdk-react/src/index.d.ts.map +1 -0
  32. package/package.json +7 -13
  33. package/dist/index.d.ts +0 -265
@@ -0,0 +1,17 @@
1
+ import { Component, ReactNode } from 'react';
2
+ interface ErrorBoundaryProps {
3
+ children: ReactNode;
4
+ fallback: (error: Error) => ReactNode;
5
+ }
6
+ interface ErrorBoundaryState {
7
+ hasError: boolean;
8
+ error: Error | null;
9
+ }
10
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
11
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
12
+ constructor(props: ErrorBoundaryProps);
13
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
14
+ render(): ReactNode;
15
+ }
16
+ export {};
17
+ //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,UAAU,kBAAkB;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;CACzC;AAED,UAAU,kBAAkB;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACvB;AAED,qBAAa,aAAc,SAAQ,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAChF,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB;gBAIrD,KAAK,EAAE,kBAAkB;IAKrC,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;IAI1D,MAAM;CAOT"}
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ export interface PluginErrorProps {
3
+ error: Error;
4
+ }
5
+ /**
6
+ * Дефолтный компонент для отображения ошибки инициализации плагина
7
+ */
8
+ export declare const PluginError: FC<PluginErrorProps>;
9
+ //# sourceMappingURL=PluginError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginError.d.ts","sourceRoot":"","sources":["../../../../src/components/PluginError.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,oBAAoB,CAAC;AAE5B,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,KAAK,CAAC;CAChB;AAsCD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAsB,EAAE,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { FC } from 'react';
2
+ /**
3
+ * Простой лоадер для отображения во время инициализации плагина
4
+ */
5
+ export declare const PluginLoader: FC;
6
+ //# sourceMappingURL=PluginLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/PluginLoader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,qBAAqB,CAAC;AAW7B;;GAEG;AACH,eAAO,MAAM,YAAY,EAAuB,EAAE,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { BasicContext, Theme } from '../../../plugin-sdk-core/src/index.ts';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * Generic registerHandler — no Tracker-specific types.
5
+ */
6
+ export type RegisterHandlerFunction = (methodName: string, handler: (...args: unknown[]) => unknown) => void;
7
+ interface CommonPluginContextValue {
8
+ /** Current host theme. Updated reactively on theme.changed. */
9
+ theme: Theme | undefined;
10
+ /** Current host language. Updated reactively on language.changed. */
11
+ language: string | undefined;
12
+ /** Service in which the plugin was opened. */
13
+ service: string;
14
+ /** User ID. */
15
+ userId?: string;
16
+ /** Is this a yateam environment? */
17
+ isYateam?: boolean;
18
+ /** Origin of the parent window (host). */
19
+ origin: string;
20
+ /** Slot in which the plugin is opened. */
21
+ slot: string;
22
+ /** URL inside the plugin. */
23
+ innerUrl: string;
24
+ /** Plugin query parameters. */
25
+ queryParams: Record<string, string>;
26
+ /** Register a handler for responding to host requests. */
27
+ registerHandler: RegisterHandlerFunction;
28
+ }
29
+ /**
30
+ * Plugin context at contextLevel = 'basic'.
31
+ * slotContext contains only entityId.
32
+ */
33
+ export interface BasicPluginContextValue extends CommonPluginContextValue {
34
+ /** Page context — only entityId at basic level. */
35
+ slotContext: BasicContext | undefined;
36
+ /** Context level declared in the manifest. */
37
+ contextLevel: 'basic';
38
+ }
39
+ /**
40
+ * Plugin context at contextLevel = 'full'.
41
+ * slotContext contains the full slot object.
42
+ */
43
+ export interface FullPluginContextValue extends CommonPluginContextValue {
44
+ /** Page context — full slot object at full level. */
45
+ slotContext: unknown;
46
+ /** Context level declared in the manifest. */
47
+ contextLevel: 'full';
48
+ }
49
+ export type PluginContextValue = BasicPluginContextValue | FullPluginContextValue;
50
+ /**
51
+ * Hook for getting theme, language, slot and slot context from PluginProvider.
52
+ *
53
+ * All values are reactive — updated automatically on push events from the host:
54
+ * - `theme` — on `theme.changed`
55
+ * - `language` — on `language.changed`
56
+ * - `slotContext` — on `context.changed`
57
+ *
58
+ * Supports two context levels:
59
+ * - `'basic'` (default) — slotContext contains only `{ entityId }`.
60
+ * - `'full'` — slotContext contains the full slot object.
61
+ * Requires `contextLevel: "full"` in the plugin manifest.
62
+ */
63
+ export declare function usePluginContext(): BasicPluginContextValue;
64
+ export declare function usePluginContext(level: 'basic'): BasicPluginContextValue;
65
+ export declare function usePluginContext(level: 'full'): FullPluginContextValue;
66
+ export interface PluginProviderProps {
67
+ children: ReactNode;
68
+ /**
69
+ * Automatically resize the plugin container when content changes.
70
+ * @default true
71
+ */
72
+ autoResize?: boolean;
73
+ /**
74
+ * Component to display during initialization.
75
+ * @default undefined (nothing shown)
76
+ */
77
+ fallback?: ReactNode;
78
+ /**
79
+ * Component to display on initialization error.
80
+ * @default <PluginError error={error} />
81
+ */
82
+ errorFallback?: (error: Error) => ReactNode;
83
+ /**
84
+ * Automatically notify the host that the plugin is ready after initialization.
85
+ * @default true
86
+ */
87
+ autoNotifyReady?: boolean;
88
+ }
89
+ export declare const isInternalUrl: (url: string) => boolean;
90
+ /**
91
+ * Generic plugin provider.
92
+ * Wraps the application and manages the plugin lifecycle.
93
+ *
94
+ * After initialization, theme, language and slot context are available via
95
+ * `usePluginContext()` and update reactively on push events from the host.
96
+ * @example
97
+ * ```tsx
98
+ * root.render(
99
+ * <PluginProvider>
100
+ * <App />
101
+ * </PluginProvider>
102
+ * );
103
+ * ```
104
+ */
105
+ export declare function PluginProvider({ children, autoResize, fallback, errorFallback, autoNotifyReady, }: PluginProviderProps): import("react/jsx-runtime").JSX.Element;
106
+ export {};
107
+ //# sourceMappingURL=PluginProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/PluginProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,YAAY,EAEjB,KAAK,KAAK,EAKb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,KAAK,SAAS,EAOjB,MAAM,OAAO,CAAC;AASf;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,KACvC,IAAI,CAAC;AAEV,UAAU,wBAAwB;IAC9B,+DAA+D;IAC/D,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,0DAA0D;IAC1D,eAAe,EAAE,uBAAuB,CAAC;CAC5C;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACrE,mDAAmD;IACnD,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IAEtC,8CAA8C;IAC9C,YAAY,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,wBAAwB;IACpE,qDAAqD;IACrD,WAAW,EAAE,OAAO,CAAC;IAErB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,kBAAkB,GAAG,uBAAuB,GAAG,sBAAsB,CAAC;AAelF;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,uBAAuB,CAAC;AAC5D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAAC;AAC1E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB,CAAC;AAwDxE,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;IAC5C;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,YAOxC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,EAC3B,QAAQ,EACR,UAAiB,EACjB,QAAQ,EACR,aAAa,EACb,eAAsB,GACzB,EAAE,mBAAmB,2CA+KrB"}
@@ -0,0 +1,6 @@
1
+ import { ConfirmOptions, ConfirmResult } from '../../../plugin-sdk-core/src/index.ts';
2
+ export type UseConfirmReturn = {
3
+ show: (options: ConfirmOptions) => Promise<ConfirmResult>;
4
+ };
5
+ export declare const useConfirm: () => UseConfirmReturn;
6
+ //# sourceMappingURL=useConfirm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConfirm.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useConfirm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAS,MAAM,kBAAkB,CAAC;AAGlF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7D,CAAC;AAQF,eAAO,MAAM,UAAU,EAAqB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Reactive hook for receiving the current slot context pushed by the host.
3
+ * @template T - Type of the context object (defaults to `unknown`)
4
+ * @returns Current context, or `undefined` until the first event arrives from the host.
5
+ * @example
6
+ * ```tsx
7
+ * interface IssueContext {
8
+ * key: string;
9
+ * summary: string;
10
+ * }
11
+ *
12
+ * function App() {
13
+ * const context = useContext<IssueContext>();
14
+ * if (!context) return <Loader />;
15
+ * return <div>{context.summary}</div>;
16
+ * }
17
+ * ```
18
+ */
19
+ export declare function useContext<T = unknown>(): T | undefined;
20
+ //# sourceMappingURL=useContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContext.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useContext.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,GAAG,SAAS,CAmBvD"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Реактивный хук для получения текущей сборки приложения.
3
+ * @returns Является ли ятимом приложение (например, 'true'), или `undefined` до получения первого события.
4
+ * @example
5
+ * ```tsx
6
+ * function App() {
7
+ * const isYateam = useIsYateam();
8
+ * return <span>Ятим ли сейчас?: {isYateam}</span>;
9
+ * }
10
+ * ```
11
+ */
12
+ export declare function useIsYateam(): boolean | undefined;
13
+ //# sourceMappingURL=useIsYateam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsYateam.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useIsYateam.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,OAAO,GAAG,SAAS,CAajD"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Реактивный хук для получения текущего языка хоста.
3
+ * @returns Код текущего языка (например, `'ru'`, `'en'`), или `undefined` до получения первого события.
4
+ * @example
5
+ * ```tsx
6
+ * function App() {
7
+ * const language = useLanguage();
8
+ * return <span>Текущий язык: {language}</span>;
9
+ * }
10
+ * ```
11
+ */
12
+ export declare function useLanguage(): string | undefined;
13
+ //# sourceMappingURL=useLanguage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLanguage.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useLanguage.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,SAAS,CAmBhD"}
@@ -0,0 +1,6 @@
1
+ import { LocalizedString } from '../../../plugin-sdk-core/src/index.ts';
2
+ /**
3
+ * Хук для получения локализованной строки на основе текущего языка из контекста.
4
+ */
5
+ export declare const useLocalizedString: (fallbackLanguage?: string) => (value: LocalizedString) => string;
6
+ //# sourceMappingURL=useLocalizedString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalizedString.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useLocalizedString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,kBAAkB,CAAC;AAW5E;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAA6B,CACxD,gBAAgB,CAAC,EAAE,MAAM,KACxB,CAAC,KAAK,EAAE,eAAe,KAAK,MAAM,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Theme } from '../../../plugin-sdk-core/src/index.ts';
2
+ /**
3
+ * Реактивный хук для получения текущей темы хоста.
4
+ * @returns Текущая тема (`'light'` | `'dark'` и т.д.), или `undefined` до получения первого события.
5
+ * @example
6
+ * ```tsx
7
+ * function App() {
8
+ * const theme = useTheme();
9
+ * return <div className={theme}>...</div>;
10
+ * }
11
+ * ```
12
+ */
13
+ export declare function useTheme(): Theme | undefined;
14
+ //# sourceMappingURL=useTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAM,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,IAAI,KAAK,GAAG,SAAS,CAmB5C"}
@@ -0,0 +1,8 @@
1
+ import { ToastOptions } from '../../../plugin-sdk-core/src/index.ts';
2
+ export type UseToasterReturn = {
3
+ add: (options: ToastOptions) => Promise<{
4
+ name: string;
5
+ }>;
6
+ };
7
+ export declare const useToaster: () => UseToasterReturn;
8
+ //# sourceMappingURL=useToaster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToaster.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useToaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,kBAAkB,CAAC;AAG5D,MAAM,MAAM,gBAAgB,GAAG;IAC3B,GAAG,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7D,CAAC;AAQF,eAAO,MAAM,UAAU,EAAqB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Реактивный хук для получения айди текущего пользователя.
3
+ * @returns Айди пользователя (например, `'qwertyu'`), или `undefined` до получения первого события.
4
+ * @example
5
+ * ```tsx
6
+ * function App() {
7
+ * const userId = useUserId();
8
+ * return <span>Айди: {userId}</span>;
9
+ * }
10
+ * ```
11
+ */
12
+ export declare function useUserId(): string | undefined;
13
+ //# sourceMappingURL=useUserId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUserId.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUserId.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAc9C"}
@@ -0,0 +1,16 @@
1
+ export { ErrorBoundary } from './components/ErrorBoundary';
2
+ export { PluginError } from './components/PluginError';
3
+ export type { PluginErrorProps } from './components/PluginError';
4
+ export { PluginLoader } from './components/PluginLoader';
5
+ export { PluginProvider, usePluginContext, isInternalUrl } from './components/PluginProvider';
6
+ export type { BasicPluginContextValue, FullPluginContextValue, PluginContextValue, PluginProviderProps, RegisterHandlerFunction, } from './components/PluginProvider';
7
+ export { useConfirm } from './hooks/useConfirm';
8
+ export { useIsYateam } from './hooks/useIsYateam';
9
+ export { useLanguage } from './hooks/useLanguage';
10
+ export { useLocalizedString } from './hooks/useLocalizedString';
11
+ export { useTheme } from './hooks/useTheme';
12
+ export { useToaster } from './hooks/useToaster';
13
+ export { useUserId } from './hooks/useUserId';
14
+ export { getField, getLocalizedString, hostApi, METHOD_NOT_SUPPORTED, MISSING_REQUIRED_SCOPE, PLUGIN_ID_IS_NOT_CORRECT, PLUGIN_ID_OR_SLOT_NOT_PROVIDED, PluginActionError, uiApi, UNKNOWN_ERROR, VALIDATION_ERROR, on, dispatchHostEvent, } from '../../plugin-sdk-core/src/index.ts';
15
+ export type { BasicContext, ConfirmOptions, ConfirmResult, ContextLevel, ContentSizeUpdateRequest, HostEventCallback, HostEventContract, HostEventMethod, LocalizedString, Theme, ToastAction, ToastOptions, Unsubscribe, } from '../../plugin-sdk-core/src/index.ts';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9F,YAAY,EACR,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GAC1B,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EACH,QAAQ,EACR,kBAAkB,EAClB,OAAO,EACP,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,8BAA8B,EAC9B,iBAAiB,EACjB,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,EAAE,EACF,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACR,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,KAAK,EACL,WAAW,EACX,YAAY,EACZ,WAAW,GACd,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavix/sdk-react",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",
@@ -11,27 +11,21 @@
11
11
  "dist",
12
12
  "README.md"
13
13
  ],
14
- "keywords": [],
15
- "author": "Tracker Team",
16
- "license": "UNLICENSED",
17
- "description": "React hooks for Tracker plugin SDK (Weavix flavor)",
18
- "publishConfig": {
19
- "registry": "https://registry.npmjs.org/",
20
- "access": "public"
21
- },
22
14
  "dependencies": {
23
- "@weavix/sdk-core": "0.0.1"
15
+ "@weavix/sdk-core": "0.0.2"
24
16
  },
25
17
  "peerDependencies": {
26
18
  "react": "^18.0.0"
27
19
  },
20
+ "publishConfig": {
21
+ "registry": "https://registry.npmjs.org/",
22
+ "access": "public"
23
+ },
28
24
  "devDependencies": {
29
25
  "@testing-library/jest-dom": "*",
30
26
  "@testing-library/react": "*",
31
27
  "@types/jest": "*",
32
- "@types/react": "^18.0.0",
33
- "@tracker-plugin-sdk/core-shared": "0.0.0",
34
- "@tracker-plugin-sdk/react-shared": "0.0.0"
28
+ "@types/react": "^18.0.0"
35
29
  },
36
30
  "scripts": {
37
31
  "build": "vite build",
package/dist/index.d.ts DELETED
@@ -1,265 +0,0 @@
1
- import { ConfirmOptions } from '@weavix/sdk-core';
2
- import { ConfirmResult } from '@weavix/sdk-core';
3
- import { ContentSizeUpdateRequest } from '@weavix/sdk-core';
4
- import type { FC } from 'react';
5
- import { GetDataResultMap } from '@weavix/sdk-core';
6
- import { getField } from '@weavix/sdk-core';
7
- import { getLocalizedString } from '@weavix/sdk-core';
8
- import { HandlerFunction } from '@weavix/sdk-core';
9
- import { Handlers } from '@weavix/sdk-core';
10
- import { hostApi } from '@weavix/sdk-core';
11
- import { HostEventCallback } from '@weavix/sdk-core';
12
- import { HostEventContract } from '@weavix/sdk-core';
13
- import { HostEventMethod } from '@weavix/sdk-core';
14
- import { JSX as JSX_2 } from 'react/jsx-runtime';
15
- import { LocalizedString } from '@weavix/sdk-core';
16
- import { METHOD_NOT_SUPPORTED } from '@weavix/sdk-core';
17
- import { MISSING_REQUIRED_SCOPE } from '@weavix/sdk-core';
18
- import { PLUGIN_ID_IS_NOT_CORRECT } from '@weavix/sdk-core';
19
- import { PLUGIN_ID_OR_SLOT_NOT_PROVIDED } from '@weavix/sdk-core';
20
- import { PluginActionError } from '@weavix/sdk-core';
21
- import { ReactNode } from 'react';
22
- import { SlotContextMap } from '@weavix/sdk-core';
23
- import { Theme } from '@weavix/sdk-core';
24
- import { ToastAction } from '@weavix/sdk-core';
25
- import { ToastOptions } from '@weavix/sdk-core';
26
- import { TrackerApi } from '@weavix/sdk-core';
27
- import { trackerApi } from '@weavix/sdk-core';
28
- import { TrackerApiCallOptions } from '@weavix/sdk-core';
29
- import { TrackerApiInitOptions } from '@weavix/sdk-core';
30
- import { TrackerApiV3 } from '@weavix/sdk-core';
31
- import { TriggerActionData } from '@weavix/sdk-core';
32
- import { uiApi } from '@weavix/sdk-core';
33
- import { UNKNOWN_ERROR } from '@weavix/sdk-core';
34
- import { Unsubscribe } from '@weavix/sdk-core';
35
- import { VALIDATION_ERROR } from '@weavix/sdk-core';
36
-
37
- export { ConfirmOptions }
38
-
39
- declare type ConfirmOptions_2 = {
40
- title?: string;
41
- message: string;
42
- textButtonApply?: string;
43
- textButtonCancel?: string;
44
- theme?: 'normal' | 'danger';
45
- };
46
-
47
- export { ConfirmResult }
48
-
49
- declare type ConfirmResult_2 = { confirmed: boolean };
50
-
51
- export { ContentSizeUpdateRequest }
52
-
53
- export { getField }
54
-
55
- export { getLocalizedString }
56
-
57
- export { hostApi }
58
-
59
- export { HostEventCallback }
60
-
61
- export { HostEventContract }
62
-
63
- export { HostEventMethod }
64
-
65
- export { LocalizedString }
66
-
67
- /**
68
- * Структурный shape `LocalizedString` — общая база, к которой структурно
69
- * совместимы api-types `LocalizedString` обоих flavors. Реальная функция
70
- * `getLocalizedString` читает только ключи `ru` и `en`, поэтому более
71
- * узкие api-types-варианты (с дополнительными ключами) совместимы.
72
- */
73
- declare type LocalizedString_2 = string | { ru?: string; en?: string };
74
-
75
- export { METHOD_NOT_SUPPORTED }
76
-
77
- export { MISSING_REQUIRED_SCOPE }
78
-
79
- export { PLUGIN_ID_IS_NOT_CORRECT }
80
-
81
- export { PLUGIN_ID_OR_SLOT_NOT_PROVIDED }
82
-
83
- export { PluginActionError }
84
-
85
- /**
86
- * Дефолтный компонент для отображения ошибки инициализации плагина
87
- */
88
- export declare const PluginError = PluginErrorImpl as FC<PluginErrorProps>;
89
-
90
- export declare interface PluginErrorProps {
91
- error: Error;
92
- }
93
-
94
- /**
95
- * Простой лоадер для отображения во время инициализации плагина
96
- */
97
- export declare const PluginLoader = PluginLoaderImpl as FC;
98
-
99
- /**
100
- * Сигнатура registerHandler: для 'getData' тип handler зависит от слота (GetDataResultMap[TSlot]).
101
- */
102
- export declare type RegisterHandlerFunction<TSlot extends keyof SlotContextMap> = <TKey extends keyof Handlers>(methodName: TKey, handler: TKey extends 'getData' ? TSlot extends keyof GetDataResultMap ? () => GetDataResultMap[TSlot] : never : HandlerFunction<TKey>) => void;
103
-
104
- export { SlotContextMap }
105
-
106
- export { Theme }
107
-
108
- export { ToastAction }
109
-
110
- declare type ToastAction_2 = {
111
- label: string;
112
- onClick: () => void;
113
- };
114
-
115
- export { ToastOptions }
116
-
117
- declare type ToastOptions_2 = {
118
- name?: string;
119
- title: string;
120
- content?: string;
121
- theme?: 'success' | 'danger' | 'warning' | 'info';
122
- autoHiding?: number;
123
- isClosable?: boolean;
124
- actions?: ToastAction_2[];
125
- };
126
-
127
- export { TrackerApi }
128
-
129
- export { trackerApi }
130
-
131
- export { TrackerApiCallOptions }
132
-
133
- export { TrackerApiInitOptions }
134
-
135
- export { TrackerApiV3 }
136
-
137
- /**
138
- * Стабильные данные контекста — не меняются после инициализации.
139
- * Реактивные значения (theme, language, slotContext) доступны через useTrackerPluginContext().
140
- */
141
- export declare interface TrackerPluginContextValue<TSlot extends keyof SlotContextMap = keyof SlotContextMap> {
142
- /** Текущая тема хоста. Обновляется реактивно при получении theme.changed. */
143
- theme: Theme | undefined;
144
- /** Текущий язык хоста. Обновляется реактивно при получении language.changed. */
145
- language: string | undefined;
146
- /** Сервис, в котором открылся плагин. */
147
- service: string;
148
- /** Id пользователя. */
149
- userId?: string;
150
- /** Это ятим? */
151
- isYateam?: boolean;
152
- /** Origin родительского окна (хоста). */
153
- origin: string;
154
- /** Слот, в котором открыт плагин. */
155
- slot: TSlot;
156
- /** URL внутри плагина. */
157
- innerUrl: string;
158
- /** Query-параметры плагина */
159
- queryParams: Record<string, string>;
160
- /** Контекст страницы. Обновляется реактивно при получении context.changed. */
161
- slotContext: SlotContextMap[TSlot] | undefined;
162
- /** Регистрация обработчика для ответов на запросы хоста. */
163
- registerHandler: RegisterHandlerFunction<TSlot>;
164
- }
165
-
166
- /**
167
- * Провайдер для инициализации плагина Tracker.
168
- * Оборачивает приложение и управляет жизненным циклом плагина.
169
- *
170
- * После инициализации тема, язык и контекст страницы доступны через
171
- * `useTrackerPluginContext()` и обновляются реактивно при push-событиях от хоста.
172
- * @example
173
- * ```tsx
174
- * root.render(
175
- * <TrackerPluginProvider>
176
- * <App />
177
- * </TrackerPluginProvider>
178
- * );
179
- * ```
180
- */
181
- export declare function TrackerPluginProvider({ children, autoResize, fallback, errorFallback, autoNotifyReady, }: TrackerPluginProviderProps): JSX_2.Element;
182
-
183
- export declare interface TrackerPluginProviderProps {
184
- children: ReactNode;
185
- /**
186
- * Автоматически изменять размер контейнера плагина при изменении содержимого
187
- * @default true
188
- */
189
- autoResize?: boolean;
190
- /**
191
- * Компонент для отображения во время инициализации
192
- * @default <PluginLoader />
193
- */
194
- fallback?: ReactNode;
195
- /**
196
- * Компонент для отображения при ошибке инициализации
197
- * @default <PluginError error={error} />
198
- */
199
- errorFallback?: (error: Error) => ReactNode;
200
- /**
201
- * Автоматически уведомить хост о готовности плагина после инициализации
202
- * @default true
203
- */
204
- autoNotifyReady?: boolean;
205
- }
206
-
207
- export { TriggerActionData }
208
-
209
- export { uiApi }
210
-
211
- export { UNKNOWN_ERROR }
212
-
213
- export { Unsubscribe }
214
-
215
- export declare const useConfirm = useConfirmImpl as () => UseConfirmReturn;
216
-
217
- declare type UseConfirmReturn = {
218
- show: (options: ConfirmOptions_2) => Promise<ConfirmResult_2>;
219
- };
220
-
221
- /**
222
- * Хук для получения локализованной строки на основе текущего языка из контекста.
223
- */
224
- export declare const useLocalizedString = useLocalizedStringImpl as (
225
- fallbackLanguage?: string,
226
- ) => (value: LocalizedString_2) => string;
227
-
228
- export declare const useToaster = useToasterImpl as () => UseToasterReturn;
229
-
230
- declare type UseToasterReturn = {
231
- add: (options: ToastOptions_2) => Promise<{ name: string }>;
232
- };
233
-
234
- /**
235
- * Хук для получения темы, языка, слота и контекста слота из TrackerPluginProvider.
236
- *
237
- * Все значения реактивны — обновляются автоматически при push-событиях от хоста:
238
- * - `theme` — при `theme.changed`
239
- * - `language` — при `language.changed`
240
- * - `slotContext` — при `context.changed`
241
- *
242
- * Без generic — возвращает union; после проверки `slot === 'issue.action'` и т.п. сужается тип `slotContext`.
243
- * С generic — сразу типизирует под один слот: `useTrackerPluginContext<'issue.action'>()`.
244
- * @example
245
- * ```tsx
246
- * // Без generic — сужение через slot
247
- * const { slot, slotContext, theme, language } = useTrackerPluginContext();
248
- * if (slot === 'issue.action') {
249
- * // slotContext: Issue
250
- * }
251
- *
252
- * // С generic — сразу типизировано
253
- * const { slotContext } = useTrackerPluginContext<'issue.action'>();
254
- * // slotContext: Issue | undefined
255
- * ```
256
- */
257
- export declare function useTrackerPluginContext(): {
258
- [K in keyof SlotContextMap]: TrackerPluginContextValue<K>;
259
- }[keyof SlotContextMap];
260
-
261
- export declare function useTrackerPluginContext<TSlot extends keyof SlotContextMap>(): TrackerPluginContextValue<TSlot>;
262
-
263
- export { VALIDATION_ERROR }
264
-
265
- export { }