@tiendanube/nexo 0.1.7 → 0.2.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/actions/actions.d.ts +52 -0
- package/actions/actions.js +16 -0
- package/actions/index.d.ts +1 -0
- package/actions/index.js +17 -0
- package/core/nexoClient.d.ts +13 -0
- package/core/nexoClient.js +28 -0
- package/core/transporter.d.ts +21 -0
- package/core/transporter.js +56 -0
- package/core/utils.d.ts +4 -0
- package/core/utils.js +18 -0
- package/helpers/helpers.d.ts +16 -0
- package/helpers/helpers.js +149 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +17 -0
- package/index.d.ts +8 -0
- package/index.js +7 -0
- package/package.json +10 -4
|
@@ -0,0 +1,52 @@
|
|
|
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 type NavigateGoToRequest = {
|
|
7
|
+
pathname: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const ACTION_NAVIGATE_PATHNAME = "app/navigate/pathname";
|
|
10
|
+
export type NavigatePathnameResponse = {
|
|
11
|
+
pathname: string | null;
|
|
12
|
+
};
|
|
13
|
+
export declare const ACTION_NAVIGATE_SYNC = "app/navigate/sync";
|
|
14
|
+
export type NavigateSyncResponse = {
|
|
15
|
+
path: string;
|
|
16
|
+
replace?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const ACTION_AUTH_SESSION_TOKEN = "app/auth/sessionToken";
|
|
19
|
+
export type AuthSessionTokenResponse = {
|
|
20
|
+
token: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const ACTION_DEVICE = "app/device";
|
|
23
|
+
export type DeviceResponse = {
|
|
24
|
+
isMobile: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const ACTION_STORE_INFO = "app/store/info";
|
|
27
|
+
export 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 type CopyToClipboardRequest = {
|
|
37
|
+
text: string;
|
|
38
|
+
};
|
|
39
|
+
export type CopyToClipboardResponse = {
|
|
40
|
+
success: boolean;
|
|
41
|
+
};
|
|
42
|
+
export declare const ACTION_NAVIGATE_GOTO_OLD_ADMIN = "app/navigate/goToOldAdmin";
|
|
43
|
+
export type NavigateGoToOldAdminRequest = {
|
|
44
|
+
pathToOldAdmin: string;
|
|
45
|
+
};
|
|
46
|
+
export declare const ACTION_NAVIGATE_HEADER = "app/navigate/header";
|
|
47
|
+
export type NavigateHeaderRequest = {
|
|
48
|
+
goTo?: 'back' | string;
|
|
49
|
+
goToAdmin?: string;
|
|
50
|
+
text?: string;
|
|
51
|
+
remove?: boolean;
|
|
52
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './actions';
|
package/actions/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Dispatch, Suscribe } from './transporter';
|
|
2
|
+
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 {};
|
|
@@ -0,0 +1,28 @@
|
|
|
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type Dispatch = (event: Message) => void;
|
|
2
|
+
type Unsuscribe = () => void;
|
|
3
|
+
export type Suscribe = (type: string, callback: any) => Unsuscribe;
|
|
4
|
+
export 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 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 {};
|
|
@@ -0,0 +1,56 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 goToOldAdmin: (nexo: NexoClient, pathToOldAdmin: string) => void;
|
|
14
|
+
export declare const copyToClipboard: (nexo: NexoClient, text: string) => Promise<boolean>;
|
|
15
|
+
export declare const navigateHeader: (nexo: NexoClient, config: NavigateHeaderRequest) => void;
|
|
16
|
+
export declare const navigateHeaderRemove: (nexo: NexoClient) => void;
|
|
@@ -0,0 +1,149 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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.goToOldAdmin = 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 goToOldAdmin = function (nexo, pathToOldAdmin) {
|
|
121
|
+
nexo.dispatch((0, utils_1.message)(actions_1.ACTION_NAVIGATE_GOTO_OLD_ADMIN, { pathToOldAdmin: pathToOldAdmin }));
|
|
122
|
+
};
|
|
123
|
+
exports.goToOldAdmin = goToOldAdmin;
|
|
124
|
+
var copyToClipboard = function (nexo, text) { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
+
var success;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0: return [4 /*yield*/, (0, utils_1.asyncAction)(nexo, actions_1.ACTION_UTILS_COPY_TO_CLIPBOARD, { text: text })];
|
|
129
|
+
case 1:
|
|
130
|
+
success = (_a.sent()).success;
|
|
131
|
+
return [2 /*return*/, success];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}); };
|
|
135
|
+
exports.copyToClipboard = copyToClipboard;
|
|
136
|
+
var navigateHeader = function (nexo, config) {
|
|
137
|
+
nexo.dispatch({
|
|
138
|
+
type: actions_1.ACTION_NAVIGATE_HEADER,
|
|
139
|
+
payload: config,
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
exports.navigateHeader = navigateHeader;
|
|
143
|
+
var navigateHeaderRemove = function (nexo) {
|
|
144
|
+
nexo.dispatch({
|
|
145
|
+
type: actions_1.ACTION_NAVIGATE_HEADER,
|
|
146
|
+
payload: { remove: true },
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
exports.navigateHeaderRemove = navigateHeaderRemove;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './helpers';
|
package/helpers/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
ADDED
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiendanube/nexo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
+
"publish:release": "yarn version apply && yarn build && yarn npm publish --tolerate-republish --access public",
|
|
9
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
11
|
"lint": "eslint .",
|
|
11
12
|
"lint:fix": "eslint --fix",
|
|
@@ -29,6 +30,11 @@
|
|
|
29
30
|
"eslint-plugin-prettier": "4.2.1",
|
|
30
31
|
"eslint-plugin-react": "7.31.1",
|
|
31
32
|
"prettier": "2.7.1",
|
|
32
|
-
"typescript": "4.
|
|
33
|
-
}
|
|
34
|
-
|
|
33
|
+
"typescript": "4.9.5"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=16.x <=18.x",
|
|
37
|
+
"yarn": ">=3.4.1"
|
|
38
|
+
},
|
|
39
|
+
"packageManager": "yarn@3.4.1"
|
|
40
|
+
}
|