cloudcommerce 2.6.0 → 2.6.1
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/.vscode/settings.json +4 -1
- package/CHANGELOG.md +11 -0
- package/ecomplus-stores/barradoce/.devcontainer/devcontainer.json +10 -4
- package/ecomplus-stores/barradoce/.vscode/settings.json +3 -0
- package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
- package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
- package/ecomplus-stores/barradoce/functions/ssr/src/components/CartSidebar.vue +11 -11
- package/ecomplus-stores/barradoce/functions/ssr/src/components/ProductDetails.vue +23 -13
- package/ecomplus-stores/barradoce/functions/ssr/src/components/SearchModal.vue +9 -6
- package/ecomplus-stores/barradoce/functions/ssr/src/components/SearchShowcase.vue +19 -17
- package/ecomplus-stores/barradoce/functions/ssr/src/components/ShippingCalculator.vue +10 -10
- package/ecomplus-stores/barradoce/functions/ssr/src/main/content/Sections.astro +3 -0
- package/ecomplus-stores/barradoce/functions/ssr/src/state/midd-search-engine.ts +19 -0
- package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/barradoce/package.json +2 -2
- package/ecomplus-stores/barradoce/tailwind.config.cjs +5 -3
- package/package.json +2 -2
- package/packages/api/package.json +1 -1
- package/packages/apps/affiliate-program/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +1 -1
- package/packages/apps/fb-conversions/package.json +1 -1
- package/packages/apps/flash-courier/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/galaxpay/package.json +1 -1
- package/packages/apps/google-analytics/package.json +1 -1
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/mandae/package.json +1 -1
- package/packages/apps/melhor-envio/package.json +1 -1
- package/packages/apps/mercadopago/package.json +1 -1
- package/packages/apps/pagarme/package.json +1 -1
- package/packages/apps/pagarme-v5/package.json +1 -1
- package/packages/apps/paghiper/package.json +1 -1
- package/packages/apps/pix/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/apps/webhooks/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +1 -1
- package/packages/eslint/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/feeds/package.json +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/package.json +1 -1
- package/packages/storefront/src/lib/composables/use-search-modal.ts +3 -1
- package/packages/storefront/src/lib/composables/use-search-showcase.ts +2 -1
- package/packages/storefront/src/lib/layouts/BaseHead.astro +2 -1
- package/packages/storefront/src/lib/layouts/use-page-main.ts +9 -5
- package/packages/storefront/src/lib/state/search-engine.ts +21 -11
- package/packages/test-base/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/storefront/src/lib/scripts/experimental-web-ide.ts +0 -29
- package/packages/storefront/src/web-ide/webcontainer.ts +0 -104
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Categories } from '@cloudcommerce/api/types';
|
|
2
|
+
import type { SearchEngineInstance } from '@@sf/state/search-engine';
|
|
2
3
|
import { ref, watch, toRef } from 'vue';
|
|
3
4
|
import Wade from 'wade';
|
|
4
5
|
import { clearAccents } from '@@sf/sf-lib';
|
|
@@ -8,6 +9,7 @@ export interface Props {
|
|
|
8
9
|
term: string;
|
|
9
10
|
fetchDebounce?: number;
|
|
10
11
|
productsLimit?: number;
|
|
12
|
+
searchEngine?: SearchEngineInstance;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
const wadeDocs: Array<{
|
|
@@ -39,7 +41,7 @@ if (wadeDocs.length) {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export const useSearchModal = (props: Props) => {
|
|
42
|
-
const searchEngine = new SearchEngine({
|
|
44
|
+
const searchEngine = props.searchEngine || new SearchEngine({
|
|
43
45
|
debounce: props.fetchDebounce || 300,
|
|
44
46
|
});
|
|
45
47
|
searchEngine.pageSize.value = props.productsLimit || 12;
|
|
@@ -30,6 +30,7 @@ export interface Props {
|
|
|
30
30
|
ssrError?: string | null;
|
|
31
31
|
canUseUrlParams?: boolean;
|
|
32
32
|
showcase?: Ref<HTMLElement | null>;
|
|
33
|
+
searchEngine?: SearchEngineInstance;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
const useSearchShowcase = (props: Props) => {
|
|
@@ -43,7 +44,7 @@ const useSearchShowcase = (props: Props) => {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
const products = shallowReactive<SearchItem[]>(props.products || []);
|
|
46
|
-
const searchEngine = new SearchEngine({ debounce: 50 });
|
|
47
|
+
const searchEngine = props.searchEngine || new SearchEngine({ debounce: 50 });
|
|
47
48
|
if (term === undefined && !import.meta.env.SSR) {
|
|
48
49
|
term = new URLSearchParams(window.location.search).get('q') || null;
|
|
49
50
|
}
|
|
@@ -168,6 +168,7 @@ const inlineJSONLd = JSON.stringify({
|
|
|
168
168
|
url: `https://${domain}/`,
|
|
169
169
|
logo: `https://${domain}${settings.logo}`,
|
|
170
170
|
});
|
|
171
|
+
const generator = `e-com.plus @cloudcommerce/storefront, ${Astro.generator}`;
|
|
171
172
|
---
|
|
172
173
|
|
|
173
174
|
<meta charset="UTF-8">
|
|
@@ -179,7 +180,7 @@ const inlineJSONLd = JSON.stringify({
|
|
|
179
180
|
{title && <title>{title}</title>}
|
|
180
181
|
{description && <meta name="description" content={description}>}
|
|
181
182
|
<meta name="author" content={settings.name}>
|
|
182
|
-
<meta name="generator" content={
|
|
183
|
+
<meta name="generator" content={generator}>
|
|
183
184
|
<link rel="canonical" href={canonicalUrl} />
|
|
184
185
|
{shortcutIcon && <link rel="apple-touch-icon" href={shortcutIcon} />}
|
|
185
186
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
@@ -12,6 +12,7 @@ export interface Props {
|
|
|
12
12
|
routeContext: RouteContext;
|
|
13
13
|
handleCustomSection?: (type: `${string}:${string}`, content: Record<string, any>) =>
|
|
14
14
|
Promise<{ props: Record<string, any> }>;
|
|
15
|
+
searchEngine?: UseSearchShowcaseProps['searchEngine'];
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
type PageContentHero = Exclude<PageContent['hero'], undefined>;
|
|
@@ -48,7 +49,7 @@ type CustomSection = { type: `${string}:${string}`, props: any };
|
|
|
48
49
|
type ProductDetailsProps = { hasDescription?: boolean, hasSpecifications?: boolean };
|
|
49
50
|
|
|
50
51
|
export const usePageSections = async <T extends CustomSection = CustomSection>
|
|
51
|
-
({ routeContext, handleCustomSection }: Props) => {
|
|
52
|
+
({ routeContext, handleCustomSection, searchEngine }: Props) => {
|
|
52
53
|
const { cmsContent } = routeContext;
|
|
53
54
|
let sectionsContent = cmsContent?.sections;
|
|
54
55
|
if (
|
|
@@ -181,11 +182,14 @@ export const usePageSections = async <T extends CustomSection = CustomSection>
|
|
|
181
182
|
props.term = routeContext.searchPageTerm || null;
|
|
182
183
|
}
|
|
183
184
|
if (props.term !== undefined || props.fixedParams) {
|
|
184
|
-
const {
|
|
185
|
+
const {
|
|
186
|
+
searchEngine: resultSearchEngine,
|
|
187
|
+
fetching,
|
|
188
|
+
} = useSearchShowcase({ ...props, searchEngine });
|
|
185
189
|
await fetching;
|
|
186
|
-
props.products =
|
|
187
|
-
props.resultMeta =
|
|
188
|
-
props.ssrError =
|
|
190
|
+
props.products = resultSearchEngine.products;
|
|
191
|
+
props.resultMeta = resultSearchEngine.meta;
|
|
192
|
+
props.ssrError = resultSearchEngine.fetchError.value?.message;
|
|
189
193
|
}
|
|
190
194
|
sections[index] = { type, props };
|
|
191
195
|
return;
|
|
@@ -68,6 +68,8 @@ export const search = async ({
|
|
|
68
68
|
return response;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
type SearchOptions = Parameters<typeof search>[0];
|
|
72
|
+
|
|
71
73
|
export class SearchEngine {
|
|
72
74
|
fields?: readonly string[];
|
|
73
75
|
term = ref<string | null>(null);
|
|
@@ -76,6 +78,7 @@ export class SearchEngine {
|
|
|
76
78
|
params = reactive<Exclude<ApiConfig['params'], string | undefined>>({});
|
|
77
79
|
pageSize = ref(24);
|
|
78
80
|
pageNumber = ref(1);
|
|
81
|
+
#middlewares: Array<(opt: SearchOptions) => void> = [];
|
|
79
82
|
#isFetching = ref(false);
|
|
80
83
|
isFetching = computed(() => this.#isFetching.value);
|
|
81
84
|
#wasFetched = ref(false);
|
|
@@ -130,18 +133,22 @@ export class SearchEngine {
|
|
|
130
133
|
});
|
|
131
134
|
}
|
|
132
135
|
let response: Awaited<ReturnType<typeof search>> | null | undefined;
|
|
136
|
+
const searchOptions = {
|
|
137
|
+
term: this.term.value,
|
|
138
|
+
params: {
|
|
139
|
+
...this.params,
|
|
140
|
+
limit,
|
|
141
|
+
offset,
|
|
142
|
+
count: this.isWithCount.value || undefined,
|
|
143
|
+
buckets: this.isWithBuckets.value || undefined,
|
|
144
|
+
},
|
|
145
|
+
fields: this.fields,
|
|
146
|
+
};
|
|
133
147
|
try {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
limit,
|
|
139
|
-
offset,
|
|
140
|
-
count: this.isWithCount.value || undefined,
|
|
141
|
-
buckets: this.isWithBuckets.value || undefined,
|
|
142
|
-
},
|
|
143
|
-
fields: this.fields,
|
|
144
|
-
});
|
|
148
|
+
for (let i = 0; i < this.#middlewares.length; i++) {
|
|
149
|
+
this.#middlewares[i](searchOptions);
|
|
150
|
+
}
|
|
151
|
+
response = await this.#search(searchOptions);
|
|
145
152
|
} catch (err: any) {
|
|
146
153
|
if (this.#fulfillFetching) {
|
|
147
154
|
this.#fetchError.value = err;
|
|
@@ -162,6 +169,9 @@ export class SearchEngine {
|
|
|
162
169
|
}
|
|
163
170
|
}
|
|
164
171
|
|
|
172
|
+
addMiddleware(cb: (options: SearchOptions) => void) {
|
|
173
|
+
this.#middlewares.push(cb);
|
|
174
|
+
}
|
|
165
175
|
setResult(data: Partial<SearchResult<'v1'>>) {
|
|
166
176
|
if (data.meta) {
|
|
167
177
|
Object.assign(this.meta, data.meta);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { initVM } from '../../web-ide/webcontainer';
|
|
2
|
-
|
|
3
|
-
const cliTextareaId = 'IDEcli';
|
|
4
|
-
const serverIframeId = 'IDEserver';
|
|
5
|
-
|
|
6
|
-
if (!import.meta.env.SSR) {
|
|
7
|
-
const cliTextarea = document.createElement('textarea');
|
|
8
|
-
cliTextarea.id = cliTextareaId;
|
|
9
|
-
document.body.appendChild(cliTextarea);
|
|
10
|
-
const serverIframe = document.createElement('iframe');
|
|
11
|
-
serverIframe.id = serverIframeId;
|
|
12
|
-
serverIframe.width = '100%';
|
|
13
|
-
serverIframe.height = '100%';
|
|
14
|
-
serverIframe.style.cssText = 'border: 1px solid #EEE; height: calc(100vh - 30px)';
|
|
15
|
-
document.body.appendChild(serverIframe);
|
|
16
|
-
|
|
17
|
-
const initIDE = async () => {
|
|
18
|
-
const repo = 'ecomplus/store';
|
|
19
|
-
const { vm, startDevServer } = await initVM({ repo, cliTextarea });
|
|
20
|
-
vm.on('server-ready', (port, href) => {
|
|
21
|
-
console.log({ port, href });
|
|
22
|
-
const url = new URL(href);
|
|
23
|
-
url.searchParams.set('webcontainer', 'dev');
|
|
24
|
-
serverIframe.src = `${url}`;
|
|
25
|
-
});
|
|
26
|
-
startDevServer();
|
|
27
|
-
};
|
|
28
|
-
initIDE();
|
|
29
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { WebContainer } from '@webcontainer/api';
|
|
2
|
-
|
|
3
|
-
export const genContainerFiles = ({ repo, ghToken, repoDir }: {
|
|
4
|
-
repo: string,
|
|
5
|
-
ghToken?: string,
|
|
6
|
-
repoDir: string,
|
|
7
|
-
}) => ({
|
|
8
|
-
'git.js': {
|
|
9
|
-
file: {
|
|
10
|
-
contents: `
|
|
11
|
-
import fs from 'node:fs';
|
|
12
|
-
import { join as joinPath } from 'node:path';
|
|
13
|
-
import { clone, pull } from 'isomorphic-git';
|
|
14
|
-
import * as http from 'isomorphic-git/http/node/index.cjs';
|
|
15
|
-
const dir = joinPath(process.cwd(), '${repoDir}');
|
|
16
|
-
const isClone = process.argv.find((val) => val === '--clone');
|
|
17
|
-
const options = {
|
|
18
|
-
fs,
|
|
19
|
-
http,
|
|
20
|
-
dir,
|
|
21
|
-
singleBranch: true,
|
|
22
|
-
ref: 'c59d5884ab86899da1c7fd154bf4009cac0a60e9',
|
|
23
|
-
};
|
|
24
|
-
${(ghToken
|
|
25
|
-
? `
|
|
26
|
-
options.oauth2format = 'github';
|
|
27
|
-
options.token = '${ghToken}';`
|
|
28
|
-
: '')}
|
|
29
|
-
if (isClone) {
|
|
30
|
-
options.url = 'https://github.com/${repo}.git';
|
|
31
|
-
options.depth = 1;
|
|
32
|
-
clone(options);
|
|
33
|
-
} else {
|
|
34
|
-
pull(options);
|
|
35
|
-
}
|
|
36
|
-
`,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
'package.json': {
|
|
40
|
-
file: {
|
|
41
|
-
contents: `
|
|
42
|
-
{
|
|
43
|
-
"name": "git-app",
|
|
44
|
-
"version": "1.0.0",
|
|
45
|
-
"type": "module",
|
|
46
|
-
"private": true,
|
|
47
|
-
"description": "",
|
|
48
|
-
"author": "",
|
|
49
|
-
"license": "ISC",
|
|
50
|
-
"scripts": {
|
|
51
|
-
"git:clone": "node git.js --clone",
|
|
52
|
-
"git:pull": "node git.js --pull"
|
|
53
|
-
},
|
|
54
|
-
"dependencies": {
|
|
55
|
-
"isomorphic-git": "^1.25.3"
|
|
56
|
-
}
|
|
57
|
-
}`,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export const initVM = async ({ repo, ghToken, cliTextarea }: {
|
|
63
|
-
repo: string,
|
|
64
|
-
ghToken?: string,
|
|
65
|
-
cliTextarea: HTMLTextAreaElement,
|
|
66
|
-
}) => {
|
|
67
|
-
const vm = await WebContainer.boot();
|
|
68
|
-
const repoDir = 'store';
|
|
69
|
-
const files = genContainerFiles({ repo, ghToken, repoDir });
|
|
70
|
-
await vm.mount(files);
|
|
71
|
-
const exec = async (command: string, args: string[]) => {
|
|
72
|
-
const cliArgs = args.reduce((acc, opt) => `${acc} ${opt}`, '');
|
|
73
|
-
const cli = `$ ${command}${cliArgs}\n`;
|
|
74
|
-
cliTextarea.value += cli;
|
|
75
|
-
const proc = await vm.spawn(command, args);
|
|
76
|
-
if (import.meta.env.DEV || (window as any).DEBUG) {
|
|
77
|
-
proc.output.pipeTo(new WritableStream({
|
|
78
|
-
write(stdout) {
|
|
79
|
-
console.debug?.('webcontainer', { stdout });
|
|
80
|
-
},
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
if (await proc.exit !== 0) {
|
|
84
|
-
throw new Error(`${command} failed`);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
await exec('npm', ['install']);
|
|
88
|
-
await exec('npm', ['run', 'git:clone']);
|
|
89
|
-
await exec('npm', ['--prefix', repoDir, 'ci', '--omit=dev', '--ignore-scripts']);
|
|
90
|
-
const ssrDir = `${repoDir}/functions/ssr`;
|
|
91
|
-
await exec('npm', ['--prefix', ssrDir, 'ci']);
|
|
92
|
-
await vm.fs.writeFile(
|
|
93
|
-
`${ssrDir}/.env`,
|
|
94
|
-
`ECOM_STORE_ID=${window.ECOM_STORE_ID}\n`,
|
|
95
|
-
);
|
|
96
|
-
const startDevServer = async () => {
|
|
97
|
-
await exec('npm', ['--prefix', repoDir, 'run', 'dev']);
|
|
98
|
-
};
|
|
99
|
-
return {
|
|
100
|
-
vm,
|
|
101
|
-
vmExec: exec,
|
|
102
|
-
startDevServer,
|
|
103
|
-
};
|
|
104
|
-
};
|