@retion-miniapp/sdk 0.1.0 → 0.3.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.
@@ -1,65 +0,0 @@
1
- declare const ErrorCode: {
2
- /** Không chạy trong app Retion (vd mở trên trình duyệt) và không có mock handler. */
3
- readonly NOT_IN_HOST: "NOT_IN_HOST";
4
- /** Host không phản hồi trong thời gian chờ. */
5
- readonly TIMEOUT: "TIMEOUT";
6
- /** Host (phiên bản app hiện tại) chưa hỗ trợ API này. */
7
- readonly NOT_SUPPORTED: "NOT_SUPPORTED";
8
- /** Tham số truyền vào không hợp lệ. */
9
- readonly INVALID_PARAMS: "INVALID_PARAMS";
10
- /** User từ chối / huỷ thao tác. */
11
- readonly USER_CANCELLED: "USER_CANCELLED";
12
- /** Lỗi khác phía host. */
13
- readonly HOST_ERROR: "HOST_ERROR";
14
- };
15
- type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode] | (string & {});
16
- declare class MiniAppError extends Error {
17
- readonly code: ErrorCode;
18
- readonly method?: string;
19
- constructor(code: ErrorCode, message: string, method?: string);
20
- /** Chuẩn hoá lỗi từ host / mock (object thuần, Error, string) về MiniAppError. */
21
- static from(error: unknown, method?: string): MiniAppError;
22
- }
23
-
24
- /** Param theo conversation mà host truyền khi mở mini app. */
25
- interface RouteParams {
26
- /** Page (kênh) đang mở mini app. Mỗi page là 1 instance mini app riêng. */
27
- page_id?: string;
28
- /** Khách hàng của conversation. Đổi trong cùng page → onContextChange (nếu context_update). */
29
- client_id?: string;
30
- org_id?: string;
31
- message_id?: string;
32
- comment_id?: string;
33
- locale?: string;
34
- is_page_admin?: string | number;
35
- [key: string]: unknown;
36
- }
37
- /** Callback thay cho await (tuỳ chọn). */
38
- interface CallbackOptions<T> {
39
- success?: (result: T) => void;
40
- fail?: (error: MiniAppError) => void;
41
- }
42
- type MockHandler = (method: string, params: unknown) => unknown;
43
- interface UserInfo {
44
- id: string;
45
- name: string;
46
- avatar?: string;
47
- role?: string;
48
- }
49
- interface SystemInfo {
50
- platform: 'ios' | 'android' | 'web';
51
- /** Version app host (undefined khi chạy ngoài app). */
52
- appVersion?: string;
53
- sdkVersion: string;
54
- inHost: boolean;
55
- theme?: 'light' | 'dark';
56
- }
57
- interface PageInfo {
58
- page_id: string;
59
- name: string;
60
- avatar?: string;
61
- /** Kênh của page: facebook, zalo, instagram, chatwork, ... */
62
- platform: string;
63
- }
64
-
65
- export { type CallbackOptions as C, ErrorCode as E, type MockHandler as M, type PageInfo as P, type RouteParams as R, type SystemInfo as S, type UserInfo as U, MiniAppError as a };
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkC2AZ33LI_cjs = require('../chunk-C2AZ33LI.cjs');
4
- var vue = require('vue');
5
-
6
- function useRouteParams() {
7
- const params = vue.shallowRef(chunkC2AZ33LI_cjs.getRouteParams());
8
- const off = chunkC2AZ33LI_cjs.onContextChange((next) => {
9
- params.value = next;
10
- });
11
- if (vue.getCurrentScope()) {
12
- vue.onScopeDispose(off);
13
- }
14
- return params;
15
- }
16
-
17
- exports.useRouteParams = useRouteParams;
18
- //# sourceMappingURL=index.cjs.map
19
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/vue/index.ts"],"names":["shallowRef","getRouteParams","onContextChange","getCurrentScope","onScopeDispose"],"mappings":";;;;;AAWO,SAAS,cAAA,GAA0C;AACxD,EAAA,MAAM,MAAA,GAASA,cAAA,CAAWC,gCAAA,EAAgB,CAAA;AAC1C,EAAA,MAAM,GAAA,GAAMC,iCAAA,CAAgB,CAAC,IAAA,KAAS;AACpC,IAAA,MAAA,CAAO,KAAA,GAAQ,IAAA;AAAA,EACjB,CAAC,CAAA;AACD,EAAA,IAAIC,qBAAgB,EAAG;AACrB,IAAAC,kBAAA,CAAe,GAAG,CAAA;AAAA,EACpB;AACA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["import { getCurrentScope, onScopeDispose, shallowRef, type ShallowRef } from 'vue';\nimport { getRouteParams, onContextChange } from '../apis/route';\nimport type { RouteParams } from '../types';\n\n/**\n * Route params reactive — tự cập nhật khi host đổi conversation (context_update).\n * Gọi trong setup() hoặc effectScope; ngoài scope sẽ không tự huỷ lắng nghe.\n * @example\n * const params = useRouteParams();\n * watch(() => params.value.client_id, fetchData, { immediate: true });\n */\nexport function useRouteParams(): ShallowRef<RouteParams> {\n const params = shallowRef(getRouteParams());\n const off = onContextChange((next) => {\n params.value = next;\n });\n if (getCurrentScope()) {\n onScopeDispose(off);\n }\n return params;\n}\n"]}
@@ -1,13 +0,0 @@
1
- import { ShallowRef } from 'vue';
2
- import { R as RouteParams } from '../types-8g8OpZsj.cjs';
3
-
4
- /**
5
- * Route params reactive — tự cập nhật khi host đổi conversation (context_update).
6
- * Gọi trong setup() hoặc effectScope; ngoài scope sẽ không tự huỷ lắng nghe.
7
- * @example
8
- * const params = useRouteParams();
9
- * watch(() => params.value.client_id, fetchData, { immediate: true });
10
- */
11
- declare function useRouteParams(): ShallowRef<RouteParams>;
12
-
13
- export { useRouteParams };
@@ -1,13 +0,0 @@
1
- import { ShallowRef } from 'vue';
2
- import { R as RouteParams } from '../types-8g8OpZsj.js';
3
-
4
- /**
5
- * Route params reactive — tự cập nhật khi host đổi conversation (context_update).
6
- * Gọi trong setup() hoặc effectScope; ngoài scope sẽ không tự huỷ lắng nghe.
7
- * @example
8
- * const params = useRouteParams();
9
- * watch(() => params.value.client_id, fetchData, { immediate: true });
10
- */
11
- declare function useRouteParams(): ShallowRef<RouteParams>;
12
-
13
- export { useRouteParams };
package/dist/vue/index.js DELETED
@@ -1,17 +0,0 @@
1
- import { getRouteParams, onContextChange } from '../chunk-PVXYU6XK.js';
2
- import { shallowRef, getCurrentScope, onScopeDispose } from 'vue';
3
-
4
- function useRouteParams() {
5
- const params = shallowRef(getRouteParams());
6
- const off = onContextChange((next) => {
7
- params.value = next;
8
- });
9
- if (getCurrentScope()) {
10
- onScopeDispose(off);
11
- }
12
- return params;
13
- }
14
-
15
- export { useRouteParams };
16
- //# sourceMappingURL=index.js.map
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/vue/index.ts"],"names":[],"mappings":";;;AAWO,SAAS,cAAA,GAA0C;AACxD,EAAA,MAAM,MAAA,GAAS,UAAA,CAAW,cAAA,EAAgB,CAAA;AAC1C,EAAA,MAAM,GAAA,GAAM,eAAA,CAAgB,CAAC,IAAA,KAAS;AACpC,IAAA,MAAA,CAAO,KAAA,GAAQ,IAAA;AAAA,EACjB,CAAC,CAAA;AACD,EAAA,IAAI,iBAAgB,EAAG;AACrB,IAAA,cAAA,CAAe,GAAG,CAAA;AAAA,EACpB;AACA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["import { getCurrentScope, onScopeDispose, shallowRef, type ShallowRef } from 'vue';\nimport { getRouteParams, onContextChange } from '../apis/route';\nimport type { RouteParams } from '../types';\n\n/**\n * Route params reactive — tự cập nhật khi host đổi conversation (context_update).\n * Gọi trong setup() hoặc effectScope; ngoài scope sẽ không tự huỷ lắng nghe.\n * @example\n * const params = useRouteParams();\n * watch(() => params.value.client_id, fetchData, { immediate: true });\n */\nexport function useRouteParams(): ShallowRef<RouteParams> {\n const params = shallowRef(getRouteParams());\n const off = onContextChange((next) => {\n params.value = next;\n });\n if (getCurrentScope()) {\n onScopeDispose(off);\n }\n return params;\n}\n"]}