@vtex/checkout 0.0.12 → 0.0.13
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +24 -24
- package/.next/cache/config.json +3 -3
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +2 -2
- package/.next/server/chunks/151.js +1 -1
- package/.next/server/chunks/400.js +1 -1
- package/.next/server/chunks/561.js +1 -1
- package/.next/server/chunks/742.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/_app.js +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_error.js +1 -1
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/cart.html +1 -1
- package/.next/server/pages/cart.js.nft.json +1 -1
- package/.next/server/pages/error.html +1 -1
- package/.next/server/pages/error.js.nft.json +1 -1
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/information.html +1 -1
- package/.next/server/pages/information.js.nft.json +1 -1
- package/.next/server/pages/order-placed.html +1 -1
- package/.next/server/pages/order-placed.js.nft.json +1 -1
- package/.next/server/pages/payment.html +1 -1
- package/.next/server/pages/payment.js.nft.json +1 -1
- package/.next/server/pages/review.html +1 -1
- package/.next/server/pages/review.js.nft.json +1 -1
- package/.next/server/pages/shipping.html +1 -1
- package/.next/server/pages/shipping.js.nft.json +1 -1
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +24 -24
- package/.next/standalone/.next/prerender-manifest.json +1 -1
- package/.next/standalone/.next/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/chunks/151.js +1 -1
- package/.next/standalone/.next/server/chunks/400.js +1 -1
- package/.next/standalone/.next/server/chunks/561.js +1 -1
- package/.next/standalone/.next/server/chunks/742.js +1 -0
- package/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/.next/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/pages/_app.js +1 -1
- package/.next/standalone/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/_error.js +1 -1
- package/.next/standalone/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/cart.html +1 -1
- package/.next/standalone/.next/server/pages/cart.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/error.html +1 -1
- package/.next/standalone/.next/server/pages/error.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/index.html +1 -1
- package/.next/standalone/.next/server/pages/index.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/information.html +1 -1
- package/.next/standalone/.next/server/pages/information.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/order-placed.html +1 -1
- package/.next/standalone/.next/server/pages/order-placed.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/payment.html +1 -1
- package/.next/standalone/.next/server/pages/payment.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/review.html +1 -1
- package/.next/standalone/.next/server/pages/review.js.nft.json +1 -1
- package/.next/standalone/.next/server/pages/shipping.html +1 -1
- package/.next/standalone/.next/server/pages/shipping.js.nft.json +1 -1
- package/.next/standalone/.next/static/Dy7RV2YAc3voKTjrMjrI5/_buildManifest.js +1 -0
- package/.next/standalone/.next/static/chunks/456.d0c10e7c0ce84ef8.js +1 -0
- package/.next/standalone/.next/static/chunks/{858-372be54ae975a073.js → 858-1c1883c607497c24.js} +1 -1
- package/.next/standalone/.next/static/chunks/924.b720bde500a651c7.js +1 -0
- package/.next/standalone/.next/static/chunks/mf-manifest.json +56 -56
- package/.next/standalone/.next/static/chunks/mf-stats.json +56 -56
- package/.next/standalone/.next/static/chunks/pages/_app-d8576c2c66c05a4f.js +195 -0
- package/.next/standalone/.next/static/chunks/pages/cart-408a82c2f82b88d1.js +1 -0
- package/.next/standalone/.next/static/chunks/pages/{error-331472d09555969f.js → error-a20335b41929838f.js} +1 -1
- package/.next/standalone/.next/static/chunks/pages/{information-96e2cce9a5a1bfdc.js → information-8920684dd00e6078.js} +1 -1
- package/.next/standalone/.next/static/chunks/pages/{order-placed-bc02732f16535ebb.js → order-placed-a78ee1dcf9432df1.js} +1 -1
- package/.next/standalone/.next/static/chunks/pages/{payment-c2285d778f0449e4.js → payment-b3db6fc0d7bc2ef7.js} +1 -1
- package/.next/standalone/.next/static/chunks/pages/{review-cf79c48f70f71d0b.js → review-eaa87581db411f66.js} +1 -1
- package/.next/standalone/.next/static/chunks/pages/{shipping-1e24a2859b3e066c.js → shipping-f16d48c1a72c6183.js} +1 -1
- package/.next/standalone/.next/static/chunks/{webpack-a9c09a4cddf677b4.js → webpack-07f9b5dfd3b20756.js} +1 -1
- package/.next/standalone/.next/static/css/{6f48a3a477d7e03e.css → 1b9c68ce247985c9.css} +1 -1
- package/.next/standalone/.next/static/css/{e6f9533bbaf3999e.css → ab4e3e0dc94ec5e0.css} +1 -1
- package/.next/trace +276 -275
- package/dist/cli.d.ts +9 -0
- package/dist/cli.js +10 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/dev.d.ts +3 -1
- package/dist/commands/dev.js +14 -4
- package/dist/commands/dev.js.map +1 -1
- package/dist/index.d.ts +1 -9
- package/dist/index.js +1 -9
- package/dist/index.js.map +1 -1
- package/dist/surface/api.d.ts +16 -0
- package/dist/surface/api.js +55 -0
- package/dist/surface/api.js.map +1 -0
- package/dist/surface/types.d.ts +43 -0
- package/dist/surface/types.js +2 -0
- package/dist/surface/types.js.map +1 -0
- package/dist/types.d.ts +7 -4
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -3
- package/.next/server/chunks/104.js +0 -1
- package/.next/standalone/.next/server/chunks/104.js +0 -1
- package/.next/standalone/.next/static/E_3fZE-WCdQWBqglZ53mq/_buildManifest.js +0 -1
- package/.next/standalone/.next/static/chunks/456.8fc06f16f32f699b.js +0 -1
- package/.next/standalone/.next/static/chunks/924.8b5dd24dd3a4f649.js +0 -1
- package/.next/standalone/.next/static/chunks/pages/_app-5614585568072a7b.js +0 -195
- package/.next/standalone/.next/static/chunks/pages/cart-151a914a26302c7c.js +0 -1
- /package/.next/standalone/.next/static/{E_3fZE-WCdQWBqglZ53mq → Dy7RV2YAc3voKTjrMjrI5}/_ssgManifest.js +0 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
|
2
|
+
import * as hooks_ from './hooks/index.js';
|
|
3
|
+
import { Dev as dev, Build as build, Create as create } from './commands/index.js';
|
|
4
|
+
export declare const hooks: typeof hooks_;
|
|
5
|
+
export declare const commands: {
|
|
6
|
+
dev: typeof dev;
|
|
7
|
+
build: typeof build;
|
|
8
|
+
create: typeof create;
|
|
9
|
+
};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
|
2
|
+
import * as hooks_ from './hooks/index.js';
|
|
3
|
+
import { Dev as dev, Build as build, Create as create, } from './commands/index.js';
|
|
4
|
+
export const hooks = hooks_;
|
|
5
|
+
export const commands = {
|
|
6
|
+
dev,
|
|
7
|
+
build,
|
|
8
|
+
create,
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EACL,GAAG,IAAI,GAAG,EACV,KAAK,IAAI,KAAK,EACd,MAAM,IAAI,MAAM,GACjB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC;AAE5B,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,GAAG;IACH,KAAK;IACL,MAAM;CACP,CAAC"}
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export declare class Dev extends Command {
|
|
|
6
6
|
};
|
|
7
7
|
static description: string;
|
|
8
8
|
static examples: never[];
|
|
9
|
-
static flags: {
|
|
9
|
+
static flags: {
|
|
10
|
+
'show-placeholders': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
10
12
|
/**
|
|
11
13
|
* TODO: Currently, we're getting PATH, ACCOUNT_NAME, and PORT
|
|
12
14
|
* via CLI arguments. However, this information will later come from
|
package/dist/commands/dev.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from 'path';
|
|
|
6
6
|
import http from 'http';
|
|
7
7
|
import { WebSocket, WebSocketServer } from 'ws';
|
|
8
8
|
import { spawn, spawnSync } from 'child_process';
|
|
9
|
-
import { Command, Args } from '@oclif/core';
|
|
9
|
+
import { Command, Args, Flags } from '@oclif/core';
|
|
10
10
|
import { IS_DEBUGGING, CORE_PATH, STANDALONE_PATH, CHECKOUTRC_PATH, STATIC_TMP_FOLDER, } from '../lib/constants.js';
|
|
11
11
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
12
12
|
import { bundle } from '../lib/bundler.js';
|
|
@@ -37,7 +37,7 @@ const setupCheckoutCore = async () => {
|
|
|
37
37
|
await fs.writeFile(CHECKOUTRC_PATH, 'updated');
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
const createExtensionsServer = async ({ port, accountName, path: checkoutPath, }) => {
|
|
40
|
+
const createExtensionsServer = async ({ port, accountName, path: checkoutPath, showPlaceholders, }) => {
|
|
41
41
|
const app = express();
|
|
42
42
|
app.use(cors({
|
|
43
43
|
origin: `http://localhost:${port}`,
|
|
@@ -58,6 +58,7 @@ const createExtensionsServer = async ({ port, accountName, path: checkoutPath, }
|
|
|
58
58
|
app.get('/extensions-config', (_, res) => res.json({
|
|
59
59
|
accountName,
|
|
60
60
|
extensionsServerPort: EXTENSIONS_SERVER_PORT,
|
|
61
|
+
showPlaceholders,
|
|
61
62
|
}));
|
|
62
63
|
app.post('/graphql', createProxyMiddleware({
|
|
63
64
|
target: `https://${accountName}.vtexcommercestable.com.br/api/checkout-bff/graphql`,
|
|
@@ -72,6 +73,9 @@ const createExtensionsServer = async ({ port, accountName, path: checkoutPath, }
|
|
|
72
73
|
app.use('/assets', express.static(path.resolve(checkoutPath, STATIC_TMP_FOLDER)));
|
|
73
74
|
server.listen(EXTENSIONS_SERVER_PORT, () => {
|
|
74
75
|
logger.debug(`Extensions server running at http://localhost:${EXTENSIONS_SERVER_PORT} `);
|
|
76
|
+
if (showPlaceholders) {
|
|
77
|
+
logger.debug('ℹ️ Displaying placeholders at all extension points. Extensions will not be displayed.');
|
|
78
|
+
}
|
|
75
79
|
});
|
|
76
80
|
const checkoutServer = path.resolve(CORE_PATH, 'standalone', 'server.js');
|
|
77
81
|
const child = spawn(process.execPath, [checkoutServer], {
|
|
@@ -107,7 +111,12 @@ export class Dev extends Command {
|
|
|
107
111
|
};
|
|
108
112
|
static description = 'Run checkout in development mode';
|
|
109
113
|
static examples = [];
|
|
110
|
-
static flags = {
|
|
114
|
+
static flags = {
|
|
115
|
+
'show-placeholders': Flags.boolean({
|
|
116
|
+
description: 'Show placeholders for extension points',
|
|
117
|
+
default: false,
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
111
120
|
/**
|
|
112
121
|
* TODO: Currently, we're getting PATH, ACCOUNT_NAME, and PORT
|
|
113
122
|
* via CLI arguments. However, this information will later come from
|
|
@@ -116,13 +125,14 @@ export class Dev extends Command {
|
|
|
116
125
|
* sourced from the faststore.config.json file.
|
|
117
126
|
*/ async run() {
|
|
118
127
|
const CHECKOUT_PORT = '4301';
|
|
119
|
-
const { args } = await this.parse(Dev);
|
|
128
|
+
const { args, flags } = await this.parse(Dev);
|
|
120
129
|
const checkoutPath = path.resolve(args.path);
|
|
121
130
|
await setupCheckoutCore();
|
|
122
131
|
const extensionsServer = await createExtensionsServer({
|
|
123
132
|
port: CHECKOUT_PORT,
|
|
124
133
|
accountName: args.accountName,
|
|
125
134
|
path: checkoutPath,
|
|
135
|
+
showPlaceholders: flags['show-placeholders'],
|
|
126
136
|
});
|
|
127
137
|
bundle({
|
|
128
138
|
mode: 'development',
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa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O,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE7C,MAAM,iBAAiB,EAAE,CAAC;QAE1B,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CAAC;YACpD,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,YAAY;YAClB,gBAAgB,EAAE,KAAK,CAAC,mBAAmB,CAAC;SAC7C,CAAC,CAAC;QAEH,MAAM,CAAC;YACL,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,GAAG,EAAE;gBACb,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;gBACtC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;SACF,CAAC,CAAC;IACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
export { run } from '@oclif/core';
|
|
2
1
|
export * from './types.js';
|
|
3
|
-
|
|
4
|
-
import { Dev as dev, Build as build, Create as create } from './commands/index.js';
|
|
5
|
-
export declare const hooks: typeof hooks_;
|
|
6
|
-
export declare const commands: {
|
|
7
|
-
dev: typeof dev;
|
|
8
|
-
build: typeof build;
|
|
9
|
-
create: typeof create;
|
|
10
|
-
};
|
|
2
|
+
export { defineExtensions, useSettings, useExtension, useCart, } from './surface/api.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
export { run } from '@oclif/core';
|
|
2
1
|
export * from './types.js';
|
|
3
|
-
|
|
4
|
-
import { Dev as dev, Build as build, Create as create, } from './commands/index.js';
|
|
5
|
-
export const hooks = hooks_;
|
|
6
|
-
export const commands = {
|
|
7
|
-
dev,
|
|
8
|
-
build,
|
|
9
|
-
create,
|
|
10
|
-
};
|
|
2
|
+
export { defineExtensions, useSettings, useExtension, useCart, } from './surface/api.js';
|
|
11
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,OAAO,GACR,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ExtensionPointApi, ExtensionPoints } from '../types.js';
|
|
3
|
+
type ApiProviderProps = {
|
|
4
|
+
api: ExtensionPointApi;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare const ApiProvider: ({ api, children }: ApiProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const useApi: () => ExtensionPointApi;
|
|
9
|
+
export declare const useCart: () => import("./types.js").UseCart;
|
|
10
|
+
export declare const useExtension: () => import("./types.js").UseExtension;
|
|
11
|
+
export declare const useSettings: () => import("./types.js").UseSettings;
|
|
12
|
+
type ExtensionPointHocProps = {
|
|
13
|
+
api: ExtensionPointApi;
|
|
14
|
+
};
|
|
15
|
+
export declare const defineExtensions: (extensions: ExtensionPoints) => Record<string, (props: ExtensionPointHocProps) => ReactNode>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
const ApiContext = createContext(undefined);
|
|
4
|
+
export const ApiProvider = ({ api, children }) => {
|
|
5
|
+
return _jsx(ApiContext.Provider, { value: api, children: children });
|
|
6
|
+
};
|
|
7
|
+
export const useApi = () => {
|
|
8
|
+
const context = useContext(ApiContext);
|
|
9
|
+
if (context === undefined) {
|
|
10
|
+
throw new Error('useApi must be used within an ApiProvider');
|
|
11
|
+
}
|
|
12
|
+
return context;
|
|
13
|
+
};
|
|
14
|
+
export const useCart = () => {
|
|
15
|
+
const api = useApi();
|
|
16
|
+
const { extensionPoint } = api.useExtension();
|
|
17
|
+
const useCart = api.useCart;
|
|
18
|
+
if (useCart) {
|
|
19
|
+
return useCart();
|
|
20
|
+
}
|
|
21
|
+
throw new ExtensionPointException({
|
|
22
|
+
extensionPoint,
|
|
23
|
+
hookName: 'useCart',
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export const useExtension = () => {
|
|
27
|
+
const api = useApi();
|
|
28
|
+
return api.useExtension();
|
|
29
|
+
};
|
|
30
|
+
export const useSettings = () => {
|
|
31
|
+
const api = useApi();
|
|
32
|
+
return api.useSettings();
|
|
33
|
+
};
|
|
34
|
+
export const defineExtensions = (extensions) => {
|
|
35
|
+
const _extensions = extensions;
|
|
36
|
+
const hoc = (Component) => (props) => (_jsx(ApiProvider, { ...props, children: _jsx(Component, {}) }));
|
|
37
|
+
return Object.keys(extensions).reduce((components, key) => {
|
|
38
|
+
const Component = _extensions[key];
|
|
39
|
+
if (Component !== undefined) {
|
|
40
|
+
return {
|
|
41
|
+
...components,
|
|
42
|
+
[key]: hoc(Component),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return components;
|
|
46
|
+
}, {});
|
|
47
|
+
};
|
|
48
|
+
class ExtensionPointException extends Error {
|
|
49
|
+
constructor({ extensionPoint, hookName }) {
|
|
50
|
+
const message = `The extension point ${extensionPoint} has no access to the hook ${hookName}`;
|
|
51
|
+
super(message);
|
|
52
|
+
this.name = 'ExtensionPointException';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/surface/api.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAa,MAAM,OAAO,CAAC;AAQ7D,MAAM,UAAU,GAAG,aA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C9D,MAAM,WAAW,GAAG,UAAyD,CAAC;IAC9E,MAAM,GAAG,GAAG,CAAC,SAA0B,EAAE,EAAE,CAAC,CAAC,KAA6B,EAAE,EAAE,CAC5E,CACE,KAAC,WAAW,OAAK,KAAK,YACpB,KAAC,SAAS,KAAG,GACD,CACf,CAAC;IAEJ,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAEnC,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE;QACpB,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO;gBACL,GAAG,UAAU;gBACb,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC;aACtB,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAOF,MAAM,uBAAwB,SAAQ,KAAK;IACzC,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAgC;QACpE,MAAM,OAAO,GAAG,uBAAuB,cAAc,8BAA8B,QAAQ,EAAE,CAAC;QAC9F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ExtensionPointsKeys } from '../types.js';
|
|
2
|
+
export type AddItemData = {
|
|
3
|
+
quantity: number;
|
|
4
|
+
id: string;
|
|
5
|
+
seller: string;
|
|
6
|
+
};
|
|
7
|
+
export type BaseCartItem = {
|
|
8
|
+
quantity: number;
|
|
9
|
+
imageUrl: string;
|
|
10
|
+
productUrl: string;
|
|
11
|
+
};
|
|
12
|
+
export type CartAvailableItem = BaseCartItem & {
|
|
13
|
+
status: 'available';
|
|
14
|
+
price: number;
|
|
15
|
+
};
|
|
16
|
+
export type CartUnavailableItem = BaseCartItem & {
|
|
17
|
+
status: 'unavailable';
|
|
18
|
+
price?: number;
|
|
19
|
+
};
|
|
20
|
+
export type CartItem = CartAvailableItem | CartUnavailableItem;
|
|
21
|
+
export type UseCart = {
|
|
22
|
+
items: CartItem[];
|
|
23
|
+
addItem: (data: AddItemData) => Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
type Branding = {
|
|
26
|
+
color?: string;
|
|
27
|
+
logo?: string;
|
|
28
|
+
};
|
|
29
|
+
export type UseSettings = {
|
|
30
|
+
branding: Branding;
|
|
31
|
+
};
|
|
32
|
+
export type UseCartItem = CartAvailableItem | CartUnavailableItem;
|
|
33
|
+
export type UseExtension = {
|
|
34
|
+
account: string;
|
|
35
|
+
extensionPoint: ExtensionPointsKeys;
|
|
36
|
+
};
|
|
37
|
+
export type ExtensionPointApi = {
|
|
38
|
+
useExtension: () => UseExtension;
|
|
39
|
+
useSettings: () => UseSettings;
|
|
40
|
+
useCart?: () => UseCart;
|
|
41
|
+
useCartItem?: () => UseCartItem;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/surface/types.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { ExtensionPointApi } from './surface/types.js';
|
|
3
|
+
export * from './surface/types.js';
|
|
4
|
+
export type ExtensionPointComponent = (props: {
|
|
5
|
+
api: ExtensionPointApi;
|
|
6
|
+
}) => ReactNode;
|
|
7
|
+
export type ExtensionPointsKeys = 'cart.cart-list.after' | 'app.layout.footer' | 'cart.sidebar.action-button.before' | 'cart.cart-item.footer' | 'app.mini-cart-item.footer';
|
|
8
|
+
export type ExtensionPoints = Partial<Record<ExtensionPointsKeys, () => ReactNode>>;
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './surface/types.js';
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex/checkout",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"author": "VTEX",
|
|
5
5
|
"bin": {
|
|
6
6
|
"checkout": "./bin/run.js"
|
|
@@ -26,8 +26,11 @@
|
|
|
26
26
|
"cors": "2.8.5",
|
|
27
27
|
"typescript": "^5.3.3"
|
|
28
28
|
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "^18",
|
|
31
|
+
"@types/react": "^18"
|
|
32
|
+
},
|
|
29
33
|
"devDependencies": {
|
|
30
|
-
"@types/react": "^18.3.5",
|
|
31
34
|
"@types/cors": "2.8.17"
|
|
32
35
|
},
|
|
33
36
|
"engines": {
|
|
@@ -41,7 +44,7 @@
|
|
|
41
44
|
"dirname": "checkout",
|
|
42
45
|
"commands": {
|
|
43
46
|
"strategy": "explicit",
|
|
44
|
-
"target": "./dist/
|
|
47
|
+
"target": "./dist/cli.js",
|
|
45
48
|
"identifier": "commands"
|
|
46
49
|
},
|
|
47
50
|
"plugins": [
|