@tiendanube/nexo 0.1.4 → 0.1.7
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/.prettierrc +4 -0
- package/README.md +395 -1
- package/package.json +13 -5
- package/tsconfig.json +5 -15
- package/actions/actions.d.ts +0 -52
- package/actions/actions.js +0 -16
- package/actions/index.d.ts +0 -1
- package/actions/index.js +0 -17
- package/core/nexoClient.d.ts +0 -13
- package/core/nexoClient.js +0 -28
- package/core/transporter.d.ts +0 -21
- package/core/transporter.js +0 -56
- package/core/utils.d.ts +0 -4
- package/core/utils.js +0 -18
- package/helpers/helpers.d.ts +0 -15
- package/helpers/helpers.js +0 -145
- package/helpers/index.d.ts +0 -1
- package/helpers/index.js +0 -17
- package/index.d.ts +0 -8
- package/index.js +0 -7
- package/react/index.d.ts +0 -1
- package/react/index.js +0 -17
- package/react/react.d.ts +0 -2
- package/react/react.js +0 -66
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -1 +1,395 @@
|
|
|
1
|
-
# nexo
|
|
1
|
+
# `@tiendanube/nexo`
|
|
2
|
+
***Nexo*** provides tools that allow communication between an external application and the Nuvemshop administrator.
|
|
3
|
+
|
|
4
|
+
Communication between the Admin and the App is done through messages following the observer pattern ( events subscribe/unsubscribe)
|
|
5
|
+
|
|
6
|
+
The messages that can be exchanged and are defined as [Actions](#actions), these actions are typed and associated to [Helpers](#helpers) that allows them to be used as promises
|
|
7
|
+
|
|
8
|
+
- [`@tiendanube/nexo`](#tiendanubenexo)
|
|
9
|
+
- [Instalation](#instalation)
|
|
10
|
+
- [Getting Started](#getting-started)
|
|
11
|
+
- [Create a Nexo instance.](#create-a-nexo-instance)
|
|
12
|
+
- [Check if the app is connected](#check-if-the-app-is-connected)
|
|
13
|
+
- [Enable route synchronization](#enable-route-synchronization)
|
|
14
|
+
- [Get Session Token](#get-session-token)
|
|
15
|
+
- [Actions](#actions)
|
|
16
|
+
- [Helpers](#helpers)
|
|
17
|
+
- [connect](#connect)
|
|
18
|
+
- [iAmReady](#iamready)
|
|
19
|
+
- [navigateExit](#navigateexit)
|
|
20
|
+
- [getSessionToken](#getsessiontoken)
|
|
21
|
+
- [syncPathname](#syncpathname)
|
|
22
|
+
- [getStoreInfo](#getstoreinfo)
|
|
23
|
+
- [getIsMobileDevice](#getismobiledevice)
|
|
24
|
+
- [goTo](#goto)
|
|
25
|
+
- [goToOldAdmin](#gotooldadmin)
|
|
26
|
+
- [copyToClipboard](#copytoclipboard)
|
|
27
|
+
- [navigateHeader](#navigateheader)
|
|
28
|
+
- [navigateHeaderRemove](#navigateheaderremove)
|
|
29
|
+
|
|
30
|
+
## Instalation
|
|
31
|
+
```
|
|
32
|
+
$ npm install @tiendanube/nexo
|
|
33
|
+
```
|
|
34
|
+
```
|
|
35
|
+
$ yarn add @tiendanube/nexo
|
|
36
|
+
```
|
|
37
|
+
## Getting Started
|
|
38
|
+
|
|
39
|
+
### Create a Nexo instance.
|
|
40
|
+
|
|
41
|
+
| Config | Type | Description |
|
|
42
|
+
|----------|---------------------------|--------------------------------------------------------------------|
|
|
43
|
+
| clientId | `string` required | This value is provided by Nuvemshop |
|
|
44
|
+
| log | `boolean` default `false` | Allows to show the message transfers between the App and the Admin |
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import nexo from '@tiendanube/nexo';
|
|
48
|
+
|
|
49
|
+
const instance = nexo.create({
|
|
50
|
+
clientId: '123',
|
|
51
|
+
log: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export default instance;
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Check if the app is connected
|
|
59
|
+
Through the `connect` util you can check if the Admin allows you to exchange messages and at the same time with `iAmReady` notify that your application is ready to show.
|
|
60
|
+
|
|
61
|
+
To react application
|
|
62
|
+
```tsx
|
|
63
|
+
import { useEffect, useState } from 'react';
|
|
64
|
+
import { connect, iAmReady } from '@tiendanube/nexo/helpers';
|
|
65
|
+
import nexo from './nexoClient'; // Nexo instance
|
|
66
|
+
|
|
67
|
+
function App() {
|
|
68
|
+
const [isConnect, setIsConnect] = useState(false);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
connect(nexo).then(() => {
|
|
72
|
+
setIsConnect(true);
|
|
73
|
+
iAmReady(nexo);
|
|
74
|
+
});
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
if (!isConnect) return <MyAppSkeleton />;
|
|
78
|
+
|
|
79
|
+
return <MyApp />
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Enable route synchronization
|
|
84
|
+
|
|
85
|
+
This functionality will allow you to record the app navigation of your app in the browser URL via fragment (#myroute)
|
|
86
|
+
|
|
87
|
+
This example is made with `react-router-dom`
|
|
88
|
+
|
|
89
|
+
```jsx
|
|
90
|
+
import { useEffect } from 'react';
|
|
91
|
+
|
|
92
|
+
import { useLocation, useHistory } from 'react-router-dom';
|
|
93
|
+
import { syncPathname } from '@tiendanube/nexo/helpers';
|
|
94
|
+
import nexo from './nexoClient';
|
|
95
|
+
import {
|
|
96
|
+
ACTION_NAVIGATE_SYNC,
|
|
97
|
+
NavigateSyncResponse,
|
|
98
|
+
} from '@tiendanube/nexo/actions';
|
|
99
|
+
|
|
100
|
+
function NexoSyncRoute({ children }: { children: React.ReactNode }) {
|
|
101
|
+
const { pathname } = useLocation();
|
|
102
|
+
const { push: goTo, replace: replaceTo } = useHistory();
|
|
103
|
+
|
|
104
|
+
//to send the current path of the app to the browser url
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
syncPathname(nexo, pathname);
|
|
107
|
+
}, [pathname]);
|
|
108
|
+
|
|
109
|
+
//to navigate in the app if the browser url changes
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const unsuscribe = nexo.suscribe(
|
|
112
|
+
ACTION_NAVIGATE_SYNC,
|
|
113
|
+
({ path, replace }: NavigateSyncResponse) => {
|
|
114
|
+
replace ? goTo(path) : replaceTo(path);
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return unsuscribe;
|
|
119
|
+
}, [goTo, replaceTo]);
|
|
120
|
+
|
|
121
|
+
return children;
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Get Session Token
|
|
126
|
+
Through the `getSessionToken` util we can obtain a session token (JWT) that will be used to verify the authenticity of the request to your Backend. The JWT is signed with the Application's Client Secret
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import axios from "axios";
|
|
130
|
+
import { getSessionToken } from '@tiendanube/nexo/helpers';
|
|
131
|
+
import nexo from "./nexoClient";
|
|
132
|
+
|
|
133
|
+
const axiosIntance = axios.create({
|
|
134
|
+
baseURL: 'https://my-backend.com',
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
axiosIntance.interceptors.request.use(async (request) => {
|
|
138
|
+
const token = await getSessionToken(nexo);
|
|
139
|
+
const bearerToken = `Bearer ${token}`;
|
|
140
|
+
request.headers = { ...request.headers, Authorization: bearerToken };
|
|
141
|
+
return request;
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export default axiosIntance;
|
|
145
|
+
```
|
|
146
|
+
## Actions
|
|
147
|
+
|
|
148
|
+
| Internal name | External name | Description | Payload request | Data response |
|
|
149
|
+
|-----------------------------|----------------------------------|-------------------------------------------------------------------------|------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
|
|
150
|
+
| `app/navigate/exit` | `ACTION_NAVEGATE_EXIT` | To navigate to the route from which the application was accessed. | - | - |
|
|
151
|
+
| `app/navigate/sync` | `ACTION_NAVIGATE_SYNC` | To update his current location to propagate the internal navegation. | `{ pathname: string }` | - |
|
|
152
|
+
| `app/navigate/goTo` | `ACTION_NAVIGATE_GOTO` | To navigate to a specific route in Admin | `{ pathname: string}` | `{ path: string, replace?: boolean }` |
|
|
153
|
+
| `app/navigate/pathname` | `ACTION_NAVIGATE_PATHNAME` | To current subPathname, which represents the path of the embedded app. | - | `{ pathname: string}` |
|
|
154
|
+
| `app/auth/sessionToken` | `ACTION_AUTH_SESSION_TOKEN` | To requests the session token (JWT) | - | `{ token: string }` |
|
|
155
|
+
| `app/store/info` | `ACTION_STORE_INFO` | To request information about current Store logged | - | `{ id: string, name: string, url: string, country: string, language: string, currency: string }` |
|
|
156
|
+
| `app/utils/copyToClipboard` | `ACTION_UTILS_COPY_TO_CLIPBOARD` | To copy the sent text to the device's clipboard | `{ text: string }` | `{ success: boolean }` |
|
|
157
|
+
| `app/navigate/goToOldAdmin` | `ACTION_NAVIGATE_GOTO_OLD_ADMIN` | To navigate to a specific route located in the old admin (admin/...) | `{ pathToOldAdmin: string}` | |
|
|
158
|
+
| `app/navigate/header` | `ACTION_NAVIGATE_HEADER` | To show the navigation action in the Header Top | `{ goTo?: 'back' \| string, goToAdmin?: string, text?: string, remove?: boolean }` | |
|
|
159
|
+
| `app/device` | `ACTION_DEVICE` | To requests information about if mobile device | - | `{ isMobileDevice: boolean}` |
|
|
160
|
+
|
|
161
|
+
## Helpers
|
|
162
|
+
|
|
163
|
+
### connect
|
|
164
|
+
|
|
165
|
+
To wait if the application is ready to render
|
|
166
|
+
|
|
167
|
+
**Arguments**
|
|
168
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
169
|
+
`ttl (number)`: Maximum time waiting for the admin, default 3000
|
|
170
|
+
|
|
171
|
+
**Response**
|
|
172
|
+
`Promise<void>` Success or Fail
|
|
173
|
+
|
|
174
|
+
**Example**
|
|
175
|
+
```ts
|
|
176
|
+
connect(nexo).then(() => {
|
|
177
|
+
//success
|
|
178
|
+
}).catch(() => {
|
|
179
|
+
//fail
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### iAmReady
|
|
184
|
+
|
|
185
|
+
To notify that the app is rendering
|
|
186
|
+
|
|
187
|
+
**Arguments**
|
|
188
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
189
|
+
|
|
190
|
+
**Response**
|
|
191
|
+
`void`
|
|
192
|
+
|
|
193
|
+
**Example**
|
|
194
|
+
```ts
|
|
195
|
+
iAmReady(nexo);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### navigateExit
|
|
199
|
+
|
|
200
|
+
To navigate to the route from which the application was accessed.
|
|
201
|
+
|
|
202
|
+
**Action**: `app/navigate/exit`
|
|
203
|
+
|
|
204
|
+
**Arguments**
|
|
205
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
206
|
+
|
|
207
|
+
**Response**
|
|
208
|
+
`void`
|
|
209
|
+
|
|
210
|
+
**Example**
|
|
211
|
+
```ts
|
|
212
|
+
navigateExit(nexo);
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
### getSessionToken
|
|
217
|
+
|
|
218
|
+
To requests the session token (JWT)
|
|
219
|
+
|
|
220
|
+
**Action**: `app/auth/sessionToken`
|
|
221
|
+
|
|
222
|
+
**Arguments**
|
|
223
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
224
|
+
|
|
225
|
+
**Response**
|
|
226
|
+
`Promise<token: string>`: Promise with session token
|
|
227
|
+
|
|
228
|
+
**Example**
|
|
229
|
+
```ts
|
|
230
|
+
const token = await getSessionToken(nexo);
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### syncPathname
|
|
234
|
+
To update his current location to propagate the internal navegation.
|
|
235
|
+
|
|
236
|
+
**Action**: `app/navigate/sync`
|
|
237
|
+
|
|
238
|
+
**Arguments**
|
|
239
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
240
|
+
|
|
241
|
+
**Response**
|
|
242
|
+
`Promise<token: string>`: Promise with session token
|
|
243
|
+
|
|
244
|
+
**Example**
|
|
245
|
+
```ts
|
|
246
|
+
syncPathname(nexo, pathname);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### getStoreInfo
|
|
250
|
+
To request information about current Store
|
|
251
|
+
|
|
252
|
+
**Action**: `app/store/info`
|
|
253
|
+
|
|
254
|
+
**Arguments**
|
|
255
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
256
|
+
|
|
257
|
+
**Response**
|
|
258
|
+
`Promise<StoreInfoResponse>`: Promise with store info
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
StoreInfoResponse {
|
|
262
|
+
id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
url: string;
|
|
265
|
+
country: string;
|
|
266
|
+
language: string;
|
|
267
|
+
currency: string;
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Example**
|
|
272
|
+
```ts
|
|
273
|
+
const storeInfo = await getStoreInfo(nexo);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
### getIsMobileDevice
|
|
278
|
+
To check if the app is being loaded from the Mobile Device
|
|
279
|
+
|
|
280
|
+
**Action**: `app/device`
|
|
281
|
+
|
|
282
|
+
**Arguments**
|
|
283
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
284
|
+
|
|
285
|
+
**Response**
|
|
286
|
+
`Promise<boolean>`: True / False
|
|
287
|
+
|
|
288
|
+
**Example**
|
|
289
|
+
```ts
|
|
290
|
+
const isMobileDevice = await getIsMobileDevice(nexo);
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### goTo
|
|
294
|
+
|
|
295
|
+
To navigate to a specific route in Admin
|
|
296
|
+
|
|
297
|
+
**Action**: `app/navigate/goTo`
|
|
298
|
+
|
|
299
|
+
**Arguments**
|
|
300
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
301
|
+
`path (string)`: Specific path to navigate
|
|
302
|
+
|
|
303
|
+
**Response**
|
|
304
|
+
`void`
|
|
305
|
+
|
|
306
|
+
**Example**
|
|
307
|
+
```ts
|
|
308
|
+
goTo(nexo, '/products');
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### goToOldAdmin
|
|
312
|
+
|
|
313
|
+
To navigate to a specific route in Old Admin, only available Web mode (non mobile device)
|
|
314
|
+
|
|
315
|
+
**Action**: `app/navigate/goToOldAdmin`
|
|
316
|
+
|
|
317
|
+
**Arguments**
|
|
318
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
319
|
+
`path (string)`: Specific path to navigate
|
|
320
|
+
|
|
321
|
+
**Response**
|
|
322
|
+
`void`
|
|
323
|
+
|
|
324
|
+
**Example**
|
|
325
|
+
```ts
|
|
326
|
+
goToOldAdmin(nexo, '/products');
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### copyToClipboard
|
|
330
|
+
|
|
331
|
+
To copy the sent text to the device's clipboard
|
|
332
|
+
|
|
333
|
+
**Action**: `app/utils/copyToClipboard`
|
|
334
|
+
|
|
335
|
+
**Arguments**
|
|
336
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
337
|
+
`text (string)`: Text to copy
|
|
338
|
+
|
|
339
|
+
**Response**
|
|
340
|
+
`Promise<boolean>`: If copied successfully
|
|
341
|
+
|
|
342
|
+
**Example**
|
|
343
|
+
```ts
|
|
344
|
+
copyToClipboard(nexo, 'text to copy');
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
### navigateHeader
|
|
349
|
+
|
|
350
|
+
To show the navigation action in the Header Top, only available Web mode (non mobile device)
|
|
351
|
+
|
|
352
|
+
**Action**: `app/utils/copyToClipboard`
|
|
353
|
+
|
|
354
|
+
**Arguments**
|
|
355
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
356
|
+
`config (NavigateHeaderRequest)`: Config to navegate header
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
NavigateHeaderRequest {
|
|
360
|
+
goTo: "back" | string;
|
|
361
|
+
text: string;
|
|
362
|
+
};
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
**Response**
|
|
366
|
+
`void`
|
|
367
|
+
|
|
368
|
+
**Example**
|
|
369
|
+
```ts
|
|
370
|
+
navigateHeader(nexo, { goTo: '/', text: 'Product List' });
|
|
371
|
+
//or
|
|
372
|
+
navigateHeader(nexo, { goTo: 'back', text: 'Back' });
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
### navigateHeaderRemove
|
|
377
|
+
|
|
378
|
+
Remove the action of Header Top, only available Web mode (non mobile device)
|
|
379
|
+
|
|
380
|
+
**Action**: `app/utils/copyToClipboard`
|
|
381
|
+
|
|
382
|
+
**Arguments**
|
|
383
|
+
`nexo (NexoClient)`: The Nexo Instance
|
|
384
|
+
|
|
385
|
+
**Response**
|
|
386
|
+
`void`
|
|
387
|
+
|
|
388
|
+
**Example**
|
|
389
|
+
```ts
|
|
390
|
+
navigateHeaderRemove(nexo);
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiendanube/nexo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"lint": "eslint .",
|
|
11
|
+
"lint:fix": "eslint --fix",
|
|
12
|
+
"format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc"
|
|
10
13
|
},
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
@@ -19,8 +22,13 @@
|
|
|
19
22
|
},
|
|
20
23
|
"homepage": "https://github.com/TiendaNube/cumulus#readme",
|
|
21
24
|
"devDependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"typescript": "
|
|
24
|
-
"
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "5.36.1",
|
|
26
|
+
"@typescript-eslint/parser": "5.36.1",
|
|
27
|
+
"eslint": "8.23.0",
|
|
28
|
+
"eslint-config-prettier": "8.5.0",
|
|
29
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
30
|
+
"eslint-plugin-react": "7.31.1",
|
|
31
|
+
"prettier": "2.7.1",
|
|
32
|
+
"typescript": "4.8.2"
|
|
25
33
|
}
|
|
26
34
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "es5",
|
|
4
|
-
"lib": [
|
|
5
|
-
"dom",
|
|
6
|
-
"dom.iterable",
|
|
7
|
-
"esnext"
|
|
8
|
-
],
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
9
5
|
"module": "commonjs",
|
|
10
6
|
"declaration": true,
|
|
11
7
|
"outDir": ".",
|
|
12
8
|
"strict": true,
|
|
13
|
-
"
|
|
14
|
-
"esModuleInterop": true,
|
|
9
|
+
"esModuleInterop": true
|
|
15
10
|
},
|
|
16
|
-
"include": [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"exclude": [
|
|
20
|
-
"node_modules",
|
|
21
|
-
"**/__tests__/*"
|
|
22
|
-
]
|
|
23
|
-
}
|
|
11
|
+
"include": ["src"],
|
|
12
|
+
"exclude": ["node_modules", "**/__tests__/*"]
|
|
13
|
+
}
|
package/actions/actions.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export declare const ACTION_READY = "app/ready";
|
|
2
|
-
export declare const ACTION_CONNECTED = "app/connected";
|
|
3
|
-
export declare const ACTION_NAVIGATE_EXIT = "app/navigate/exit";
|
|
4
|
-
export declare const ACTION_NAVIGATE_BACK = "app/navigate/back";
|
|
5
|
-
export declare const ACTION_NAVIGATE_GOTO = "app/navigate/goTo";
|
|
6
|
-
export declare type NavigateGoToRequest = {
|
|
7
|
-
pathname: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const ACTION_NAVIGATE_PATHNAME = "app/navigate/pathname";
|
|
10
|
-
export declare type NavigatePathnameResponse = {
|
|
11
|
-
pathname: string | null;
|
|
12
|
-
};
|
|
13
|
-
export declare const ACTION_NAVIGATE_SYNC = "app/navigate/sync";
|
|
14
|
-
export declare type NavigateSyncResponse = {
|
|
15
|
-
path: string;
|
|
16
|
-
replace?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export declare const ACTION_AUTH_SESSION_TOKEN = "app/auth/sessionToken";
|
|
19
|
-
export declare type AuthSessionTokenResponse = {
|
|
20
|
-
token: string;
|
|
21
|
-
};
|
|
22
|
-
export declare const ACTION_DEVICE = "app/device";
|
|
23
|
-
export declare type DeviceResponse = {
|
|
24
|
-
isMobile: boolean;
|
|
25
|
-
};
|
|
26
|
-
export declare const ACTION_STORE_INFO = "app/store/info";
|
|
27
|
-
export declare type StoreInfoResponse = {
|
|
28
|
-
id: string;
|
|
29
|
-
name: string;
|
|
30
|
-
url: string;
|
|
31
|
-
country: string;
|
|
32
|
-
language: string;
|
|
33
|
-
currency: string;
|
|
34
|
-
};
|
|
35
|
-
export declare const ACTION_UTILS_COPY_TO_CLIPBOARD = "app/utils/copyToClipboard";
|
|
36
|
-
export declare type CopyToClipboardRequest = {
|
|
37
|
-
text: string;
|
|
38
|
-
};
|
|
39
|
-
export declare type CopyToClipboardResponse = {
|
|
40
|
-
success: boolean;
|
|
41
|
-
};
|
|
42
|
-
export declare const ACTION_NAVIGATE_GOTO_OLD_ADMIN = "app/navigate/goToOldAdmin";
|
|
43
|
-
export declare type NavigateGoToOldAdminRequest = {
|
|
44
|
-
pathToOldAdmin: string;
|
|
45
|
-
};
|
|
46
|
-
export declare const ACTION_NAVIGATE_HEADER = "app/navigate/header";
|
|
47
|
-
export declare type NavigateHeaderRequest = {
|
|
48
|
-
goTo?: "back" | string;
|
|
49
|
-
goToAdmin?: string;
|
|
50
|
-
text?: string;
|
|
51
|
-
remove?: boolean;
|
|
52
|
-
};
|
package/actions/actions.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ACTION_NAVIGATE_HEADER = exports.ACTION_NAVIGATE_GOTO_OLD_ADMIN = exports.ACTION_UTILS_COPY_TO_CLIPBOARD = exports.ACTION_STORE_INFO = exports.ACTION_DEVICE = exports.ACTION_AUTH_SESSION_TOKEN = exports.ACTION_NAVIGATE_SYNC = exports.ACTION_NAVIGATE_PATHNAME = exports.ACTION_NAVIGATE_GOTO = exports.ACTION_NAVIGATE_BACK = exports.ACTION_NAVIGATE_EXIT = exports.ACTION_CONNECTED = exports.ACTION_READY = void 0;
|
|
4
|
-
exports.ACTION_READY = "app/ready";
|
|
5
|
-
exports.ACTION_CONNECTED = "app/connected";
|
|
6
|
-
exports.ACTION_NAVIGATE_EXIT = "app/navigate/exit";
|
|
7
|
-
exports.ACTION_NAVIGATE_BACK = "app/navigate/back";
|
|
8
|
-
exports.ACTION_NAVIGATE_GOTO = "app/navigate/goTo";
|
|
9
|
-
exports.ACTION_NAVIGATE_PATHNAME = "app/navigate/pathname";
|
|
10
|
-
exports.ACTION_NAVIGATE_SYNC = "app/navigate/sync";
|
|
11
|
-
exports.ACTION_AUTH_SESSION_TOKEN = "app/auth/sessionToken";
|
|
12
|
-
exports.ACTION_DEVICE = 'app/device';
|
|
13
|
-
exports.ACTION_STORE_INFO = "app/store/info";
|
|
14
|
-
exports.ACTION_UTILS_COPY_TO_CLIPBOARD = "app/utils/copyToClipboard";
|
|
15
|
-
exports.ACTION_NAVIGATE_GOTO_OLD_ADMIN = "app/navigate/goToOldAdmin";
|
|
16
|
-
exports.ACTION_NAVIGATE_HEADER = "app/navigate/header";
|
package/actions/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./actions";
|
package/actions/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./actions"), exports);
|
package/core/nexoClient.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Dispatch, Suscribe } from "./transporter";
|
|
2
|
-
declare type OnReady = (callback: () => void) => void;
|
|
3
|
-
export interface NexoClient {
|
|
4
|
-
clientId: string;
|
|
5
|
-
dispatch: Dispatch;
|
|
6
|
-
suscribe: Suscribe;
|
|
7
|
-
onReady: OnReady;
|
|
8
|
-
}
|
|
9
|
-
export declare const create: ({ clientId, log, }: {
|
|
10
|
-
clientId: string;
|
|
11
|
-
log?: boolean | undefined;
|
|
12
|
-
}) => NexoClient;
|
|
13
|
-
export {};
|
package/core/nexoClient.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.create = void 0;
|
|
4
|
-
var actions_1 = require("../actions/actions");
|
|
5
|
-
var transporter_1 = require("./transporter");
|
|
6
|
-
var create = function (_a) {
|
|
7
|
-
var clientId = _a.clientId, _b = _a.log, log = _b === void 0 ? false : _b;
|
|
8
|
-
var isReadyMutable = false;
|
|
9
|
-
var _c = (0, transporter_1.registerIframe)(log), dispatch = _c.dispatch, suscribe = _c.suscribe;
|
|
10
|
-
var onReady = function (callback) {
|
|
11
|
-
if (isReadyMutable) {
|
|
12
|
-
throw new Error("onReady should be run only once");
|
|
13
|
-
}
|
|
14
|
-
var readyUnsuscribe = suscribe(actions_1.ACTION_CONNECTED, function () {
|
|
15
|
-
callback();
|
|
16
|
-
readyUnsuscribe();
|
|
17
|
-
isReadyMutable = true;
|
|
18
|
-
});
|
|
19
|
-
dispatch({ type: actions_1.ACTION_CONNECTED });
|
|
20
|
-
};
|
|
21
|
-
return {
|
|
22
|
-
clientId: clientId,
|
|
23
|
-
dispatch: dispatch,
|
|
24
|
-
suscribe: suscribe,
|
|
25
|
-
onReady: onReady,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
exports.create = create;
|
package/core/transporter.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare type Dispatch = (event: Message) => void;
|
|
2
|
-
declare type Unsuscribe = () => void;
|
|
3
|
-
export declare type Suscribe = (type: string, callback: any) => Unsuscribe;
|
|
4
|
-
export declare type OnReady = () => void;
|
|
5
|
-
export interface Message<T = unknown> {
|
|
6
|
-
type: string;
|
|
7
|
-
payload?: T;
|
|
8
|
-
}
|
|
9
|
-
export interface MessageToSend extends Message {
|
|
10
|
-
source: {
|
|
11
|
-
host: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare type Handler = (message: Message) => void;
|
|
15
|
-
export declare const createHandler: (type: string, callback: (payload: unknown) => void) => Handler;
|
|
16
|
-
export declare const suscribeAndUnsuscribeHandlers: (handlers: Handler[], handler: Handler) => () => void;
|
|
17
|
-
export declare const registerIframe: (log?: boolean) => {
|
|
18
|
-
dispatch: Dispatch;
|
|
19
|
-
suscribe: Suscribe;
|
|
20
|
-
};
|
|
21
|
-
export {};
|
package/core/transporter.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerIframe = exports.suscribeAndUnsuscribeHandlers = exports.createHandler = void 0;
|
|
4
|
-
var dispatchMessage = function (message) {
|
|
5
|
-
if (window.parent === window) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (!("postMessage" in window.parent)) {
|
|
9
|
-
console.error("can not send a event", message);
|
|
10
|
-
}
|
|
11
|
-
logger("dispatched", message.type, message.payload);
|
|
12
|
-
window.parent.postMessage(message, "*");
|
|
13
|
-
};
|
|
14
|
-
var createHandler = function (type, callback) {
|
|
15
|
-
return function (message) {
|
|
16
|
-
if (message.type === type) {
|
|
17
|
-
logger("received", message.type, message.payload);
|
|
18
|
-
callback(message.payload);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.createHandler = createHandler;
|
|
23
|
-
var logger = function (from, type, payload) {
|
|
24
|
-
if (isLogged) {
|
|
25
|
-
var color = from === "dispatched" ? "#f5ec7f" : "#00cc35";
|
|
26
|
-
console.group("%c " + from, "color: " + color);
|
|
27
|
-
console.log("👉 ", type);
|
|
28
|
-
var stringPayload = JSON.stringify(payload);
|
|
29
|
-
stringPayload && console.log("📦 " + stringPayload);
|
|
30
|
-
console.groupEnd();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var suscribeAndUnsuscribeHandlers = function (handlers, handler) {
|
|
34
|
-
handlers.push(handler);
|
|
35
|
-
return function () {
|
|
36
|
-
handlers.splice(handlers.indexOf(handler), 1);
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
exports.suscribeAndUnsuscribeHandlers = suscribeAndUnsuscribeHandlers;
|
|
40
|
-
var isLogged = false;
|
|
41
|
-
var registerIframe = function (log) {
|
|
42
|
-
if (log === void 0) { log = false; }
|
|
43
|
-
isLogged = log;
|
|
44
|
-
var handlers = [];
|
|
45
|
-
window.addEventListener("message", function (event) {
|
|
46
|
-
handlers.forEach(function (handler) { return handler(event.data); });
|
|
47
|
-
});
|
|
48
|
-
return {
|
|
49
|
-
dispatch: dispatchMessage,
|
|
50
|
-
suscribe: function (type, callback) {
|
|
51
|
-
var handler = (0, exports.createHandler)(type, callback);
|
|
52
|
-
return (0, exports.suscribeAndUnsuscribeHandlers)(handlers, handler);
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.registerIframe = registerIframe;
|
package/core/utils.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { NexoClient } from "./NexoClient";
|
|
2
|
-
import { Message } from "./transporter";
|
|
3
|
-
export declare const message: <TPayload = unknown>(type: string, payload?: TPayload | undefined) => Message;
|
|
4
|
-
export declare const asyncAction: <TResponse, TRequest = undefined>(nexo: NexoClient, action: string, payload?: TRequest | undefined) => Promise<TResponse>;
|
package/core/utils.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.asyncAction = exports.message = void 0;
|
|
4
|
-
var message = function (type, payload) { return ({
|
|
5
|
-
type: type,
|
|
6
|
-
payload: payload,
|
|
7
|
-
}); };
|
|
8
|
-
exports.message = message;
|
|
9
|
-
var asyncAction = function (nexo, action, payload) {
|
|
10
|
-
return new Promise(function (resolve) {
|
|
11
|
-
var unsuscribe = nexo.suscribe(action, function (response) {
|
|
12
|
-
resolve(response);
|
|
13
|
-
unsuscribe();
|
|
14
|
-
});
|
|
15
|
-
nexo.dispatch((0, exports.message)(action, payload));
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
exports.asyncAction = asyncAction;
|
package/helpers/helpers.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { StoreInfoResponse, NavigateHeaderRequest } from "../actions/actions";
|
|
2
|
-
import { NexoClient } from "../core/nexoClient";
|
|
3
|
-
export declare const connect: (nexo: NexoClient, ttl?: number) => Promise<void>;
|
|
4
|
-
export declare const iAmReady: (nexo: NexoClient) => void;
|
|
5
|
-
export declare const navigateExit: (nexo: NexoClient) => void;
|
|
6
|
-
export declare const navigateBack: (nexo: NexoClient) => void;
|
|
7
|
-
export declare const getSessionToken: (nexo: NexoClient) => Promise<string>;
|
|
8
|
-
export declare const getCurrentPathname: (nexo: NexoClient) => Promise<string | null>;
|
|
9
|
-
export declare const syncPathname: (nexo: NexoClient, pathname: string) => void;
|
|
10
|
-
export declare const getStoreInfo: (nexo: NexoClient) => Promise<StoreInfoResponse>;
|
|
11
|
-
export declare const getIsMobileDevice: (nexo: NexoClient) => Promise<boolean>;
|
|
12
|
-
export declare const goTo: (nexo: NexoClient, pathname: string) => void;
|
|
13
|
-
export declare const copyToClipboard: (nexo: NexoClient, text: string) => Promise<boolean>;
|
|
14
|
-
export declare const navigateHeader: (nexo: NexoClient, config: NavigateHeaderRequest) => void;
|
|
15
|
-
export declare const navigateHeaderRemove: (nexo: NexoClient) => void;
|
package/helpers/helpers.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.navigateHeaderRemove = exports.navigateHeader = exports.copyToClipboard = exports.goTo = exports.getIsMobileDevice = exports.getStoreInfo = exports.syncPathname = exports.getCurrentPathname = exports.getSessionToken = exports.navigateBack = exports.navigateExit = exports.iAmReady = exports.connect = void 0;
|
|
40
|
-
var actions_1 = require("../actions/actions");
|
|
41
|
-
var utils_1 = require("../core/utils");
|
|
42
|
-
var connect = function (nexo, ttl) {
|
|
43
|
-
if (ttl === void 0) { ttl = 3000; }
|
|
44
|
-
return new Promise(function (resolve, reject) {
|
|
45
|
-
var timeOut = setTimeout(function () {
|
|
46
|
-
reject(new Error("Timeout"));
|
|
47
|
-
}, ttl);
|
|
48
|
-
nexo.onReady(function () {
|
|
49
|
-
resolve();
|
|
50
|
-
clearTimeout(timeOut);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
exports.connect = connect;
|
|
55
|
-
var iAmReady = function (nexo) {
|
|
56
|
-
nexo.dispatch((0, utils_1.message)(actions_1.ACTION_READY));
|
|
57
|
-
};
|
|
58
|
-
exports.iAmReady = iAmReady;
|
|
59
|
-
var navigateExit = function (nexo) {
|
|
60
|
-
nexo.dispatch((0, utils_1.message)(actions_1.ACTION_NAVIGATE_EXIT));
|
|
61
|
-
};
|
|
62
|
-
exports.navigateExit = navigateExit;
|
|
63
|
-
var navigateBack = function (nexo) {
|
|
64
|
-
nexo.dispatch((0, utils_1.message)(actions_1.ACTION_NAVIGATE_BACK));
|
|
65
|
-
};
|
|
66
|
-
exports.navigateBack = navigateBack;
|
|
67
|
-
var getSessionToken = function (nexo) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
-
var token;
|
|
69
|
-
return __generator(this, function (_a) {
|
|
70
|
-
switch (_a.label) {
|
|
71
|
-
case 0: return [4 /*yield*/, (0, utils_1.asyncAction)(nexo, actions_1.ACTION_AUTH_SESSION_TOKEN)];
|
|
72
|
-
case 1:
|
|
73
|
-
token = (_a.sent()).token;
|
|
74
|
-
return [2 /*return*/, token];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}); };
|
|
78
|
-
exports.getSessionToken = getSessionToken;
|
|
79
|
-
var getCurrentPathname = function (nexo) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
-
var pathname;
|
|
81
|
-
return __generator(this, function (_a) {
|
|
82
|
-
switch (_a.label) {
|
|
83
|
-
case 0: return [4 /*yield*/, (0, utils_1.asyncAction)(nexo, actions_1.ACTION_NAVIGATE_PATHNAME)];
|
|
84
|
-
case 1:
|
|
85
|
-
pathname = (_a.sent()).pathname;
|
|
86
|
-
return [2 /*return*/, pathname];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}); };
|
|
90
|
-
exports.getCurrentPathname = getCurrentPathname;
|
|
91
|
-
var syncPathname = function (nexo, pathname) {
|
|
92
|
-
nexo.dispatch((0, utils_1.message)(actions_1.ACTION_NAVIGATE_SYNC, { pathname: pathname }));
|
|
93
|
-
};
|
|
94
|
-
exports.syncPathname = syncPathname;
|
|
95
|
-
var getStoreInfo = function (nexo) { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
-
return __generator(this, function (_a) {
|
|
97
|
-
switch (_a.label) {
|
|
98
|
-
case 0: return [4 /*yield*/, (0, utils_1.asyncAction)(nexo, actions_1.ACTION_STORE_INFO)];
|
|
99
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}); };
|
|
103
|
-
exports.getStoreInfo = getStoreInfo;
|
|
104
|
-
var getIsMobileDevice = function (nexo) { return __awaiter(void 0, void 0, void 0, function () {
|
|
105
|
-
var device;
|
|
106
|
-
return __generator(this, function (_a) {
|
|
107
|
-
switch (_a.label) {
|
|
108
|
-
case 0: return [4 /*yield*/, (0, utils_1.asyncAction)(nexo, actions_1.ACTION_DEVICE)];
|
|
109
|
-
case 1:
|
|
110
|
-
device = _a.sent();
|
|
111
|
-
return [2 /*return*/, device.isMobile];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}); };
|
|
115
|
-
exports.getIsMobileDevice = getIsMobileDevice;
|
|
116
|
-
var goTo = function (nexo, pathname) {
|
|
117
|
-
nexo.dispatch((0, utils_1.message)(actions_1.ACTION_NAVIGATE_GOTO, { pathname: pathname }));
|
|
118
|
-
};
|
|
119
|
-
exports.goTo = goTo;
|
|
120
|
-
var copyToClipboard = function (nexo, text) { return __awaiter(void 0, void 0, void 0, function () {
|
|
121
|
-
var success;
|
|
122
|
-
return __generator(this, function (_a) {
|
|
123
|
-
switch (_a.label) {
|
|
124
|
-
case 0: return [4 /*yield*/, (0, utils_1.asyncAction)(nexo, actions_1.ACTION_UTILS_COPY_TO_CLIPBOARD, { text: text })];
|
|
125
|
-
case 1:
|
|
126
|
-
success = (_a.sent()).success;
|
|
127
|
-
return [2 /*return*/, success];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}); };
|
|
131
|
-
exports.copyToClipboard = copyToClipboard;
|
|
132
|
-
var navigateHeader = function (nexo, config) {
|
|
133
|
-
nexo.dispatch({
|
|
134
|
-
type: actions_1.ACTION_NAVIGATE_HEADER,
|
|
135
|
-
payload: config,
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
exports.navigateHeader = navigateHeader;
|
|
139
|
-
var navigateHeaderRemove = function (nexo) {
|
|
140
|
-
nexo.dispatch({
|
|
141
|
-
type: actions_1.ACTION_NAVIGATE_HEADER,
|
|
142
|
-
payload: { remove: true },
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
exports.navigateHeaderRemove = navigateHeaderRemove;
|
package/helpers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./helpers";
|
package/helpers/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./helpers"), exports);
|
package/index.d.ts
DELETED
package/index.js
DELETED
package/react/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./react";
|
package/react/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./react"), exports);
|
package/react/react.d.ts
DELETED
package/react/react.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.useNexoConnect = void 0;
|
|
40
|
-
var react_1 = require("react");
|
|
41
|
-
var helpers_1 = require("../helpers");
|
|
42
|
-
function useNexoConnect(nexo) {
|
|
43
|
-
var _this = this;
|
|
44
|
-
var _a = (0, react_1.useState)(false), isConnect = _a[0], setIsConnect = _a[1];
|
|
45
|
-
(0, react_1.useEffect)(function () {
|
|
46
|
-
(0, helpers_1.connect)(nexo).then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
-
var pathname;
|
|
48
|
-
return __generator(this, function (_a) {
|
|
49
|
-
switch (_a.label) {
|
|
50
|
-
case 0: return [4 /*yield*/, (0, helpers_1.getCurrentPathname)(nexo)];
|
|
51
|
-
case 1:
|
|
52
|
-
pathname = _a.sent();
|
|
53
|
-
if (pathname && pathname !== window.location.pathname) {
|
|
54
|
-
window.location.replace(window.location.origin + pathname);
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
}
|
|
57
|
-
setIsConnect(true);
|
|
58
|
-
(0, helpers_1.iAmReady)(nexo);
|
|
59
|
-
return [2 /*return*/];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}); });
|
|
63
|
-
}, [nexo]);
|
|
64
|
-
return isConnect;
|
|
65
|
-
}
|
|
66
|
-
exports.useNexoConnect = useNexoConnect;
|