@fias/arche-sdk 1.0.0
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/README.md +356 -0
- package/dist/bridge.d.ts +56 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +190 -0
- package/dist/bridge.js.map +1 -0
- package/dist/cli/create-plugin.d.ts +3 -0
- package/dist/cli/create-plugin.d.ts.map +1 -0
- package/dist/cli/create-plugin.js +80 -0
- package/dist/cli/create-plugin.js.map +1 -0
- package/dist/context.d.ts +6 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +9 -0
- package/dist/context.js.map +1 -0
- package/dist/fias.d.ts +30 -0
- package/dist/fias.d.ts.map +1 -0
- package/dist/fias.js +40 -0
- package/dist/fias.js.map +1 -0
- package/dist/hooks.d.ts +37 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +116 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +323 -0
- package/dist/provider.d.ts +25 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +47 -0
- package/dist/provider.js.map +1 -0
- package/dist/types.d.ts +118 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
- package/templates/default/fias-plugin.json +11 -0
- package/templates/default/index.html +12 -0
- package/templates/default/package.json +23 -0
- package/templates/default/src/App.tsx +12 -0
- package/templates/default/src/index.tsx +12 -0
- package/templates/default/tsconfig.json +17 -0
- package/templates/default/vite.config.ts +18 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const TEMPLATE_DIR = path.resolve(__dirname, '../../templates/default');
|
|
40
|
+
function copyDir(src, dest, replacements) {
|
|
41
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
42
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
43
|
+
const srcPath = path.join(src, entry.name);
|
|
44
|
+
const destPath = path.join(dest, entry.name);
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
copyDir(srcPath, destPath, replacements);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
let content = fs.readFileSync(srcPath, 'utf-8');
|
|
50
|
+
for (const [key, value] of Object.entries(replacements)) {
|
|
51
|
+
content = content.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), value);
|
|
52
|
+
}
|
|
53
|
+
fs.writeFileSync(destPath, content);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function main() {
|
|
58
|
+
const projectName = process.argv[2];
|
|
59
|
+
if (!projectName) {
|
|
60
|
+
console.error('Usage: create-fias-plugin <project-name>');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
const targetDir = path.resolve(process.cwd(), projectName);
|
|
64
|
+
if (fs.existsSync(targetDir)) {
|
|
65
|
+
console.error(`Error: Directory "${projectName}" already exists.`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
console.log(`Creating FIAS plugin project: ${projectName}`);
|
|
69
|
+
copyDir(TEMPLATE_DIR, targetDir, { name: projectName });
|
|
70
|
+
console.log(`
|
|
71
|
+
Plugin created at ./${projectName}
|
|
72
|
+
|
|
73
|
+
Next steps:
|
|
74
|
+
cd ${projectName}
|
|
75
|
+
npm install
|
|
76
|
+
npm run dev
|
|
77
|
+
`);
|
|
78
|
+
}
|
|
79
|
+
main();
|
|
80
|
+
//# sourceMappingURL=create-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-plugin.js","sourceRoot":"","sources":["../../src/cli/create-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAyB;AACzB,2CAA6B;AAE7B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS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ClB,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC;IAE3D,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,qBAAqB,WAAW,mBAAmB,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,iCAAiC,WAAW,EAAE,CAAC,CAAC;IAE5D,OAAO,CAAC,YAAY,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAExD,OAAO,CAAC,GAAG,CAAC;sBACQ,WAAW;;;OAG1B,WAAW;;;CAGjB,CAAC,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,iBAAiB,4CAAyC,CAAC"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiasBridgeContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* React context providing the bridge instance to all SDK hooks.
|
|
7
|
+
*/
|
|
8
|
+
exports.FiasBridgeContext = (0, react_1.createContext)(null);
|
|
9
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AAGtC;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,qBAAa,EAAoB,IAAI,CAAC,CAAC"}
|
package/dist/fias.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility namespace for imperative bridge operations.
|
|
3
|
+
* These can be called outside of React components.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { fias } from '@fias/arche-sdk';
|
|
8
|
+
*
|
|
9
|
+
* fias.ready();
|
|
10
|
+
* fias.showToast('Hello from plugin!');
|
|
11
|
+
* fias.resize(600);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const fias: {
|
|
15
|
+
/**
|
|
16
|
+
* Signal to the host that the plugin is loaded and ready.
|
|
17
|
+
* Called automatically by FiasProvider — only use manually
|
|
18
|
+
* if not using React.
|
|
19
|
+
*/
|
|
20
|
+
readonly ready: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Request the host to resize the plugin iframe to the given height.
|
|
23
|
+
*/
|
|
24
|
+
readonly resize: (height: number) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Show a platform toast notification.
|
|
27
|
+
*/
|
|
28
|
+
readonly showToast: (message: string, variant?: "info" | "success" | "warning" | "error") => void;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=fias.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fias.d.ts","sourceRoot":"","sources":["../src/fias.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI;IACf;;;;OAIG;0BACM,IAAI;IAIb;;OAEG;8BACY,MAAM,KAAG,IAAI;IAI5B;;OAEG;kCACgB,MAAM,YAAW,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,KAAY,IAAI;CAGpF,CAAC"}
|
package/dist/fias.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fias = void 0;
|
|
4
|
+
const bridge_1 = require("./bridge");
|
|
5
|
+
/**
|
|
6
|
+
* Utility namespace for imperative bridge operations.
|
|
7
|
+
* These can be called outside of React components.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { fias } from '@fias/arche-sdk';
|
|
12
|
+
*
|
|
13
|
+
* fias.ready();
|
|
14
|
+
* fias.showToast('Hello from plugin!');
|
|
15
|
+
* fias.resize(600);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
exports.fias = {
|
|
19
|
+
/**
|
|
20
|
+
* Signal to the host that the plugin is loaded and ready.
|
|
21
|
+
* Called automatically by FiasProvider — only use manually
|
|
22
|
+
* if not using React.
|
|
23
|
+
*/
|
|
24
|
+
ready() {
|
|
25
|
+
(0, bridge_1.getBridge)().ready();
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Request the host to resize the plugin iframe to the given height.
|
|
29
|
+
*/
|
|
30
|
+
resize(height) {
|
|
31
|
+
(0, bridge_1.getBridge)().resize(height);
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Show a platform toast notification.
|
|
35
|
+
*/
|
|
36
|
+
showToast(message, variant = 'info') {
|
|
37
|
+
(0, bridge_1.getBridge)().showToast(message, variant);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=fias.js.map
|
package/dist/fias.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fias.js","sourceRoot":"","sources":["../src/fias.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AAErC;;;;;;;;;;;;GAYG;AACU,QAAA,IAAI,GAAG;IAClB;;;;OAIG;IACH,KAAK;QACH,IAAA,kBAAS,GAAE,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAc;QACnB,IAAA,kBAAS,GAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,OAAe,EAAE,UAAoD,MAAM;QACnF,IAAA,kBAAS,GAAE,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACO,CAAC"}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { FiasUser, FiasTheme, FiasStorageApi, EntityInvocationApi, FiasNavigationApi } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Access the current user's profile information.
|
|
4
|
+
* Requires the `user:profile:read` permission in fias-plugin.json.
|
|
5
|
+
*
|
|
6
|
+
* @returns The current user's profile or null while loading.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useFiasUser(): FiasUser | null;
|
|
9
|
+
/**
|
|
10
|
+
* Access platform theme tokens for consistent styling.
|
|
11
|
+
* Automatically updates when the platform theme changes (e.g., light/dark mode).
|
|
12
|
+
* Requires the `theme:read` permission in fias-plugin.json.
|
|
13
|
+
*
|
|
14
|
+
* @returns The current theme tokens or null while loading.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useFiasTheme(): FiasTheme | null;
|
|
17
|
+
/**
|
|
18
|
+
* Access the plugin's sandboxed storage.
|
|
19
|
+
* Requires the `storage:sandbox` permission in fias-plugin.json.
|
|
20
|
+
*
|
|
21
|
+
* @returns Storage API methods (readFile, writeFile, listFiles, deleteFile).
|
|
22
|
+
*/
|
|
23
|
+
export declare function useFiasStorage(): FiasStorageApi;
|
|
24
|
+
/**
|
|
25
|
+
* Invoke platform entities (AI models, etc.) through the bridge.
|
|
26
|
+
* Requires the `entities:invoke` permission in fias-plugin.json.
|
|
27
|
+
*
|
|
28
|
+
* @returns Entity invocation API (invoke, isLoading, result, error).
|
|
29
|
+
*/
|
|
30
|
+
export declare function useEntityInvocation(): EntityInvocationApi;
|
|
31
|
+
/**
|
|
32
|
+
* Navigate within the plugin's route space.
|
|
33
|
+
*
|
|
34
|
+
* @returns Navigation API (navigateTo, currentPath).
|
|
35
|
+
*/
|
|
36
|
+
export declare function useFiasNavigation(): FiasNavigationApi;
|
|
37
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,cAAc,EACd,mBAAmB,EAGnB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAcjB;;;;;GAKG;AACH,wBAAgB,WAAW,IAAI,QAAQ,GAAG,IAAI,CAe7C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAS/C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAwB/C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,mBAAmB,CA2BzD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,CAgBrD"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFiasUser = useFiasUser;
|
|
4
|
+
exports.useFiasTheme = useFiasTheme;
|
|
5
|
+
exports.useFiasStorage = useFiasStorage;
|
|
6
|
+
exports.useEntityInvocation = useEntityInvocation;
|
|
7
|
+
exports.useFiasNavigation = useFiasNavigation;
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const context_1 = require("./context");
|
|
10
|
+
/**
|
|
11
|
+
* Internal helper to get bridge from context, throws if not wrapped in FiasProvider.
|
|
12
|
+
*/
|
|
13
|
+
function useBridge() {
|
|
14
|
+
const bridge = (0, react_1.useContext)(context_1.FiasBridgeContext);
|
|
15
|
+
if (!bridge) {
|
|
16
|
+
throw new Error('useBridge must be used within a <FiasProvider>');
|
|
17
|
+
}
|
|
18
|
+
return bridge;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Access the current user's profile information.
|
|
22
|
+
* Requires the `user:profile:read` permission in fias-plugin.json.
|
|
23
|
+
*
|
|
24
|
+
* @returns The current user's profile or null while loading.
|
|
25
|
+
*/
|
|
26
|
+
function useFiasUser() {
|
|
27
|
+
const bridge = useBridge();
|
|
28
|
+
const [user, setUser] = (0, react_1.useState)(null);
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
let mounted = true;
|
|
31
|
+
bridge.request('get_user', {}).then((data) => {
|
|
32
|
+
if (mounted)
|
|
33
|
+
setUser(data);
|
|
34
|
+
});
|
|
35
|
+
return () => {
|
|
36
|
+
mounted = false;
|
|
37
|
+
};
|
|
38
|
+
}, [bridge]);
|
|
39
|
+
return user;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Access platform theme tokens for consistent styling.
|
|
43
|
+
* Automatically updates when the platform theme changes (e.g., light/dark mode).
|
|
44
|
+
* Requires the `theme:read` permission in fias-plugin.json.
|
|
45
|
+
*
|
|
46
|
+
* @returns The current theme tokens or null while loading.
|
|
47
|
+
*/
|
|
48
|
+
function useFiasTheme() {
|
|
49
|
+
const bridge = useBridge();
|
|
50
|
+
const [theme, setTheme] = (0, react_1.useState)(bridge.getTheme());
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
return bridge.onThemeUpdate(setTheme);
|
|
53
|
+
}, [bridge]);
|
|
54
|
+
return theme;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Access the plugin's sandboxed storage.
|
|
58
|
+
* Requires the `storage:sandbox` permission in fias-plugin.json.
|
|
59
|
+
*
|
|
60
|
+
* @returns Storage API methods (readFile, writeFile, listFiles, deleteFile).
|
|
61
|
+
*/
|
|
62
|
+
function useFiasStorage() {
|
|
63
|
+
const bridge = useBridge();
|
|
64
|
+
const readFile = (0, react_1.useCallback)((path) => bridge.request('storage_read', { path }), [bridge]);
|
|
65
|
+
const writeFile = (0, react_1.useCallback)((path, content) => bridge.request('storage_write', { path, content }), [bridge]);
|
|
66
|
+
const listFiles = (0, react_1.useCallback)((prefix) => bridge.request('storage_list', { prefix }), [bridge]);
|
|
67
|
+
const deleteFile = (0, react_1.useCallback)((path) => bridge.request('storage_delete', { path }), [bridge]);
|
|
68
|
+
return { readFile, writeFile, listFiles, deleteFile };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Invoke platform entities (AI models, etc.) through the bridge.
|
|
72
|
+
* Requires the `entities:invoke` permission in fias-plugin.json.
|
|
73
|
+
*
|
|
74
|
+
* @returns Entity invocation API (invoke, isLoading, result, error).
|
|
75
|
+
*/
|
|
76
|
+
function useEntityInvocation() {
|
|
77
|
+
const bridge = useBridge();
|
|
78
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
79
|
+
const [result, setResult] = (0, react_1.useState)(null);
|
|
80
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
81
|
+
const invoke = (0, react_1.useCallback)(async (params) => {
|
|
82
|
+
setIsLoading(true);
|
|
83
|
+
setError(null);
|
|
84
|
+
try {
|
|
85
|
+
const res = await bridge.request('entity_invoke', params);
|
|
86
|
+
setResult(res);
|
|
87
|
+
return res;
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
91
|
+
setError(e);
|
|
92
|
+
throw e;
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
setIsLoading(false);
|
|
96
|
+
}
|
|
97
|
+
}, [bridge]);
|
|
98
|
+
return { invoke, isLoading, result, error };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Navigate within the plugin's route space.
|
|
102
|
+
*
|
|
103
|
+
* @returns Navigation API (navigateTo, currentPath).
|
|
104
|
+
*/
|
|
105
|
+
function useFiasNavigation() {
|
|
106
|
+
const bridge = useBridge();
|
|
107
|
+
const [currentPath, setCurrentPath] = (0, react_1.useState)(bridge.getCurrentPath());
|
|
108
|
+
(0, react_1.useEffect)(() => {
|
|
109
|
+
return bridge.onNavigationUpdate(setCurrentPath);
|
|
110
|
+
}, [bridge]);
|
|
111
|
+
const navigateTo = (0, react_1.useCallback)((path) => {
|
|
112
|
+
bridge.request('navigate', { path });
|
|
113
|
+
}, [bridge]);
|
|
114
|
+
return { navigateTo, currentPath };
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;AA8BA,kCAeC;AASD,oCASC;AAQD,wCAwBC;AAQD,kDA2BC;AAOD,8CAgBC;AAzJD,iCAAqE;AACrE,uCAA8C;AAY9C;;GAEG;AACH,SAAS,SAAS;IAChB,MAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,2BAAiB,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW;IACzB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAkB,IAAI,CAAC,CAAC;IAExD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,MAAM,CAAC,OAAO,CAAW,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACrD,IAAI,OAAO;gBAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACV,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CA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M,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IAExE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACnD,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,UAAU,GAAG,IAAA,mBAAW,EAC5B,CAAC,IAAY,EAAE,EAAE;QACf,MAAM,CAAC,OAAO,CAAO,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AACrC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { FiasProvider } from './provider';
|
|
2
|
+
export { useFiasUser, useFiasTheme, useFiasStorage, useEntityInvocation, useFiasNavigation, } from './hooks';
|
|
3
|
+
export { fias } from './fias';
|
|
4
|
+
export { FiasBridge, getBridge, resetBridge } from './bridge';
|
|
5
|
+
export type { FiasUser, FiasTheme, FiasStorageApi, EntityInvocationApi, EntityInvocationParams, EntityInvocationResult, FiasNavigationApi, PluginPermission, BridgeMessage, BridgeResponse, BridgeInitMessage, PluginToHostMessageType, HostToPluginMessageType, } from './types';
|
|
6
|
+
//# 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,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EACL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG9D,YAAY,EAEV,QAAQ,EACR,SAAS,EAET,cAAc,EAEd,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EAEtB,iBAAiB,EAEjB,gBAAgB,EAEhB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetBridge = exports.getBridge = exports.FiasBridge = exports.fias = exports.useFiasNavigation = exports.useEntityInvocation = exports.useFiasStorage = exports.useFiasTheme = exports.useFiasUser = exports.FiasProvider = void 0;
|
|
4
|
+
// Components
|
|
5
|
+
var provider_1 = require("./provider");
|
|
6
|
+
Object.defineProperty(exports, "FiasProvider", { enumerable: true, get: function () { return provider_1.FiasProvider; } });
|
|
7
|
+
// Hooks
|
|
8
|
+
var hooks_1 = require("./hooks");
|
|
9
|
+
Object.defineProperty(exports, "useFiasUser", { enumerable: true, get: function () { return hooks_1.useFiasUser; } });
|
|
10
|
+
Object.defineProperty(exports, "useFiasTheme", { enumerable: true, get: function () { return hooks_1.useFiasTheme; } });
|
|
11
|
+
Object.defineProperty(exports, "useFiasStorage", { enumerable: true, get: function () { return hooks_1.useFiasStorage; } });
|
|
12
|
+
Object.defineProperty(exports, "useEntityInvocation", { enumerable: true, get: function () { return hooks_1.useEntityInvocation; } });
|
|
13
|
+
Object.defineProperty(exports, "useFiasNavigation", { enumerable: true, get: function () { return hooks_1.useFiasNavigation; } });
|
|
14
|
+
// Utilities
|
|
15
|
+
var fias_1 = require("./fias");
|
|
16
|
+
Object.defineProperty(exports, "fias", { enumerable: true, get: function () { return fias_1.fias; } });
|
|
17
|
+
// Bridge (advanced usage / testing)
|
|
18
|
+
var bridge_1 = require("./bridge");
|
|
19
|
+
Object.defineProperty(exports, "FiasBridge", { enumerable: true, get: function () { return bridge_1.FiasBridge; } });
|
|
20
|
+
Object.defineProperty(exports, "getBridge", { enumerable: true, get: function () { return bridge_1.getBridge; } });
|
|
21
|
+
Object.defineProperty(exports, "resetBridge", { enumerable: true, get: function () { return bridge_1.resetBridge; } });
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AAErB,QAAQ;AACR,iCAMiB;AALf,oGAAA,WAAW,OAAA;AACX,qGAAA,YAAY,OAAA;AACZ,uGAAA,cAAc,OAAA;AACd,4GAAA,mBAAmB,OAAA;AACnB,0GAAA,iBAAiB,OAAA;AAGnB,YAAY;AACZ,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAEb,oCAAoC;AACpC,mCAA8D;AAArD,oGAAA,UAAU,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,qGAAA,WAAW,OAAA"}
|