@lilaquadrat/design-core 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +76 -3
  2. package/html/index.server.html +1 -8
  3. package/package.json +54 -54
  4. package/src/client-entry.ts +8 -8
  5. package/src/components/partials/error.partial.vue +19 -19
  6. package/src/components/partials/main-components.partial.vue +75 -70
  7. package/src/components/partials/qrcode.partial.vue +8 -8
  8. package/src/functions/AuthProviderFactory.ts +30 -0
  9. package/src/functions/PaymenyProviderFactory.ts +11 -11
  10. package/src/functions/auth0.provider.ts +75 -0
  11. package/src/functions/keycloak.provider.ts +228 -0
  12. package/src/functions/lila-dom.ts +50 -50
  13. package/src/functions/shopify.provider.ts +176 -154
  14. package/src/functions/stripe.provider.ts +120 -108
  15. package/src/globals.d.ts +1 -2
  16. package/src/index.ts +9 -7
  17. package/src/interfaces/AuthCallbackResult.interface.ts +5 -0
  18. package/src/interfaces/AuthConfig.interface.ts +13 -0
  19. package/src/interfaces/AuthProvider.interface.ts +15 -0
  20. package/src/interfaces/FrontendConfig.interface.ts +11 -40
  21. package/src/interfaces/GenericEvents.interface.ts +1 -1
  22. package/src/interfaces/IdTokenExtended.interface.ts +13 -4
  23. package/src/interfaces/PaymentProvider.interface.ts +2 -2
  24. package/src/interfaces/RenderOptions.interface.ts +12 -0
  25. package/src/libs/ActionNotice.ts +125 -125
  26. package/src/libs/Models.class.ts +219 -221
  27. package/src/main.ts +41 -36
  28. package/src/mixins/createCookieString.ts +50 -36
  29. package/src/mixins/createModelDeclaration.ts +22 -19
  30. package/src/mixins/createRouter.ts +12 -12
  31. package/src/mixins/date.ts +4 -2
  32. package/src/mixins/formatSize.ts +5 -5
  33. package/src/mixins/getAnchor.ts +1 -1
  34. package/src/mixins/getRoutes.ts +13 -25
  35. package/src/mixins/hasSlotContent.ts +22 -16
  36. package/src/mixins/hooks.ts +101 -60
  37. package/src/mixins/loadComponents.ts +60 -58
  38. package/src/mixins/logger.ts +17 -13
  39. package/src/mixins/replaceVariables.ts +10 -8
  40. package/src/mixins/scroll.ts +61 -45
  41. package/src/models/Address.model.ts +7 -7
  42. package/src/models/Contact.model.ts +14 -14
  43. package/src/plugins/analytics.ts +198 -0
  44. package/src/plugins/auth.ts +74 -60
  45. package/src/plugins/currency.ts +10 -10
  46. package/src/plugins/events.ts +101 -97
  47. package/src/plugins/filters.ts +21 -18
  48. package/src/plugins/replacer.ts +7 -6
  49. package/src/plugins/signupFlow.ts +45 -43
  50. package/src/plugins/traceable.ts +28 -26
  51. package/src/plugins/translations.ts +9 -9
  52. package/src/plugins/youtube.ts +39 -34
  53. package/src/routes.ts +108 -108
  54. package/src/server-entry.ts +75 -77
  55. package/src/stores/calls.store.ts +14 -14
  56. package/src/stores/cart.store.ts +116 -107
  57. package/src/stores/content.store.ts +87 -45
  58. package/src/stores/editor.store.ts +16 -16
  59. package/src/stores/files.store.ts +72 -72
  60. package/src/stores/main.store.ts +155 -109
  61. package/src/stores/user.store.ts +72 -68
  62. package/src/translations/de.ts +127 -127
  63. package/src/views/content.view.vue +81 -143
  64. package/src/views/download.view.vue +25 -23
  65. package/src/views/editor.view.vue +150 -125
  66. package/src/views/login.view.vue +35 -36
  67. package/src/views/signup-account.view.vue +14 -14
  68. package/tooling/cypress/config.ts +68 -54
  69. package/tooling/cypress/manifest-utils.mjs +34 -22
  70. package/tooling/cypress/run-parallel.mjs +41 -35
  71. package/tooling/cypress/support/commands.ts +458 -300
  72. package/tooling/eslint.config.js +1 -223
  73. package/tooling/preview.plugin.js +132 -0
  74. package/tooling/ssr-test/index.mjs +205 -203
  75. package/tooling/vite.d.ts +36 -0
  76. package/tooling/vite.js +234 -0
  77. package/src/interfaces/EditorConfiguration.interface.ts +0 -15
  78. package/tooling/preview.plugin.ts +0 -134
  79. package/tooling/stylelint.config.mjs +0 -24
  80. package/tooling/vite.ts +0 -260
@@ -1,113 +1,111 @@
1
1
  import { renderToString } from 'vue/server-renderer';
2
- import { getAppInstance, type AppComponents } from './main';
2
+ import { getAppInstance } from './main';
3
3
 
4
4
  import { basename } from 'path';
5
- import type { Content, Customers, List } from '@lilaquadrat/interfaces';
6
- import type { RouteRecordRaw } from 'vue-router';
7
- import useContentStore from './stores/content.store';
5
+ import type RenderOptions from './interfaces/RenderOptions.interface';
8
6
  import { dynamicRoutes } from './routes';
9
7
  import hooks from './mixins/hooks';
10
8
 
11
- export async function render (url: string, context: any, contextData: Content[], recipientData: Customers, list: List, manifest: Record<string, string[]>, options: {cdnUrl: string, components: AppComponents, routes?: readonly RouteRecordRaw[]}) {
12
- const { app, router, pinia } = getAppInstance(context, options.routes ?? dynamicRoutes, false, options.components);
9
+ export async function render({ url, context, manifest, cdnUrl, components, routes }: RenderOptions) {
13
10
 
14
- hooks(router, { initAuth: false });
11
+ const { app, router, pinia } = getAppInstance(context, routes ?? dynamicRoutes, false, components);
15
12
 
16
- await router.push(url);
17
- await router.isReady();
13
+ hooks(router, { initAuth: false });
18
14
 
19
- const contentStore = useContentStore();
15
+ await router.push(url);
16
+ await router.isReady();
20
17
 
21
- /**
18
+ /**
22
19
  * for pdfs all images must be preloaded
23
20
  * because there will be no hydration
24
21
  */
25
- if(context.renderTarget === 'pdf') {
22
+ if(context.renderTarget === 'pdf' && context.editor) {
26
23
 
27
- context.settings.preloadImages = true;
24
+ context.editor.preloadImages = true;
28
25
 
29
- }
26
+ }
30
27
 
31
- if(contextData) contentStore.addMulti(contextData);
32
- if(recipientData) contentStore.recipient = recipientData;
33
- if(list) contentStore.list = list;
28
+ // passing SSR context object which will be available via useSSRContext()
29
+ // @vitejs/plugin-vue injects code into a component's setup() that registers
30
+ // itself on ctx.modules. After the render, ctx.modules would contain all the
31
+ // components that have been instantiated during this render call.
32
+ const ctx: { modules?: Set<string> } = {};
33
+ const html = await renderToString(app, ctx);
34
+ const initialState = JSON.stringify(pinia.state.value).replace(/</g, '\\u003c');
35
+ // the SSR manifest generated by Vite contains module -> chunk/asset mapping
36
+ // which we can then use to determine what files need to be preloaded for this
37
+ // request.
38
+ const preloadLinks = renderPreloadLinks(ctx.modules as Set<string>, manifest, cdnUrl);
34
39
 
35
- // passing SSR context object which will be available via useSSRContext()
36
- // @vitejs/plugin-vue injects code into a component's setup() that registers
37
- // itself on ctx.modules. After the render, ctx.modules would contain all the
38
- // components that have been instantiated during this render call.
39
- const ctx: { modules?: Set<string> } = {};
40
- const html = await renderToString(app, ctx);
41
- const initialState = JSON.stringify(pinia.state.value).replace(/</g, '\\u003c');
42
- // the SSR manifest generated by Vite contains module -> chunk/asset mapping
43
- // which we can then use to determine what files need to be preloaded for this
44
- // request.
45
- const preloadLinks = renderPreloadLinks(ctx.modules as Set<string>, manifest, options);
40
+ return { html, preloadLinks, initialState, url };
46
41
 
47
- return { html, preloadLinks, initialState, url };
48
42
  }
49
43
 
50
- function renderPreloadLinks (modulesSet: Set<string>, manifest: Record<string, string[]>, options: {cdnUrl: string}) {
51
- let links = '';
52
- const seen = new Set();
44
+ function renderPreloadLinks(modulesSet: Set<string>, manifest: Record<string, string[]>, cdnUrl: string) {
53
45
 
54
- modulesSet?.forEach((id) => {
46
+ let links = '';
47
+ const seen = new Set();
55
48
 
56
- const files = manifest[id];
49
+ modulesSet?.forEach((id) => {
57
50
 
58
- if (files) {
51
+ const files = manifest[id];
59
52
 
60
- files.forEach((file: string) => {
53
+ if (files) {
61
54
 
62
- if (!seen.has(file)) {
63
- seen.add(file);
55
+ files.forEach((file: string) => {
64
56
 
65
- const filename = basename(file);
57
+ if (!seen.has(file)) {
66
58
 
67
- if (manifest[filename]) {
59
+ seen.add(file);
68
60
 
69
- for (const depFile of manifest[filename]) {
70
- links += renderPreloadLink(depFile, options.cdnUrl);
71
- seen.add(depFile);
72
- }
61
+ const filename = basename(file);
73
62
 
74
- }
63
+ if (manifest[filename]) {
75
64
 
76
- links += renderPreloadLink(file, options.cdnUrl);
77
- }
65
+ for (const depFile of manifest[filename]) {
78
66
 
79
- });
80
- }
67
+ links += renderPreloadLink(depFile, cdnUrl);
68
+ seen.add(depFile);
69
+
70
+ }
71
+
72
+ }
81
73
 
82
- });
74
+ links += renderPreloadLink(file, cdnUrl);
75
+
76
+ }
83
77
 
84
- return links;
78
+ });
79
+
80
+ }
81
+
82
+ });
83
+
84
+ return links;
85
85
 
86
86
  }
87
87
 
88
- function renderPreloadLink (file: string, base: string) {
89
- if (!file) return '';
90
-
91
- const fileExtMap: Record<string, { rel: string, as?: string, type?: string, crossorigin?: boolean }> = {
92
- '.js' : { rel: 'modulepreload', crossorigin: true },
93
- '.css' : { rel: 'stylesheet' },
94
- '.woff' : { rel: 'preload', as: 'font', type: 'font/woff', crossorigin: true },
95
- '.woff2': { rel: 'preload', as: 'font', type: 'font/woff2', crossorigin: true },
96
- '.gif' : { rel: 'preload', as: 'image', type: 'image/gif' },
97
- '.jpg' : { rel: 'preload', as: 'image', type: 'image/jpeg' },
98
- '.jpeg' : { rel: 'preload', as: 'image', type: 'image/jpeg' },
99
- '.png' : { rel: 'preload', as: 'image', type: 'image/png' }
100
- };
101
- const ext = Object.keys(fileExtMap).find(ext => file.endsWith(ext));
102
-
103
- if (!ext) return '';
104
-
105
- const { rel, as, type, crossorigin } = fileExtMap[ext];
106
- let link = `<link rel="${rel}" href="${base}${file}"`;
107
-
108
- if (as) link += ` as="${as}"`;
109
- if (type) link += ` type="${type}"`;
110
- if (crossorigin) link += ' crossorigin';
111
-
112
- return `${link}>`;
113
- }
88
+ function renderPreloadLink(file: string, base: string) {
89
+
90
+ if (!file) return '';
91
+
92
+ const fileExtMap: Record<string, { rel: string, as?: string, type?: string, crossorigin?: boolean }> = {
93
+ '.js': { rel: 'modulepreload', crossorigin: true },
94
+ '.css': { rel: 'stylesheet' },
95
+ '.woff': { rel: 'preload', as: 'font', type: 'font/woff', crossorigin: true },
96
+ '.woff2': { rel: 'preload', as: 'font', type: 'font/woff2', crossorigin: true }
97
+ };
98
+ const ext = Object.keys(fileExtMap).find(ext => file.endsWith(ext));
99
+
100
+ if (!ext) return '';
101
+
102
+ const { rel, as, type, crossorigin } = fileExtMap[ext];
103
+ let link = `<link rel="${rel}" href="${base}${file}"`;
104
+
105
+ if (as) link += ` as="${as}"`;
106
+ if (type) link += ` type="${type}"`;
107
+ if (crossorigin) link += ' crossorigin';
108
+
109
+ return `${link}>`;
110
+
111
+ }
@@ -4,29 +4,29 @@ import { v4 as uuid } from 'uuid';
4
4
 
5
5
  export const useCallStore = defineStore('calls', () => {
6
6
 
7
- const calls = ref<Record<string, 'pending' | 'resolved' | 'rejected'>>({});
7
+ const calls = ref<Record<string, 'pending' | 'resolved' | 'rejected'>>({});
8
8
 
9
- function addCall () {
9
+ function addCall() {
10
10
 
11
- const id = uuid();
11
+ const id = uuid();
12
12
 
13
- calls.value[id] = 'pending';
13
+ calls.value[id] = 'pending';
14
14
 
15
- return id;
15
+ return id;
16
16
 
17
- }
17
+ }
18
18
 
19
- function updateCall (id: string, state: 'pending' | 'resolved' | 'rejected') {
19
+ function updateCall(id: string, state: 'pending' | 'resolved' | 'rejected') {
20
20
 
21
- calls.value[id] = state;
21
+ calls.value[id] = state;
22
22
 
23
- }
23
+ }
24
24
 
25
- return {
26
- calls,
27
- addCall,
28
- updateCall
29
- }
25
+ return {
26
+ calls,
27
+ addCall,
28
+ updateCall
29
+ }
30
30
 
31
31
  })
32
32
 
@@ -6,180 +6,189 @@ import type { Agreement } from '@lilaquadrat/interfaces';
6
6
 
7
7
  export const useCartStore = defineStore('cart', () => {
8
8
 
9
- const products = ref<any[]>([]);
10
- const costSummary = ref<number>(0);
11
- const itemsQuantity = ref<number>(0);
12
- const mainStore = useMainStore();
13
- const paymentProvider = PaymentProviderFactory(mainStore.config?.payment?.type as 'internal' | 'shopify' | 'stripe', mainStore.config?.payment?.options);
14
- const cartCache = ref();
9
+ const products = ref<any[]>([]);
10
+ const costSummary = ref<number>(0);
11
+ const itemsQuantity = ref<number>(0);
12
+ const mainStore = useMainStore();
13
+ const paymentProvider = PaymentProviderFactory(mainStore.paymentProvider?.type as 'internal' | 'shopify' | 'stripe', mainStore.paymentProvider?.options);
14
+ const cartCache = ref();
15
+ const prename = ref<string>('');
16
+ const name = ref<string>('');
15
17
 
16
- async function getCart (attributes?: Record<string, string>) {
18
+ async function getCart(attributes?: Record<string, string>) {
17
19
 
18
- if(cartCache.value) return Promise.resolve(cartCache.value);
19
- if(!attributes) return Promise.reject('ATTRIBUTES_MISSING');
20
+ if(cartCache.value) return Promise.resolve(cartCache.value);
21
+ if(!attributes) return Promise.reject('ATTRIBUTES_MISSING');
20
22
 
21
- const list = attributes.list;
23
+ const list = attributes.list;
22
24
 
23
- if(!list) return Promise.reject('NO_LIST_GIVEN');
25
+ if(!list) return Promise.reject('NO_LIST_GIVEN');
24
26
 
25
- const cartId = `lila-cart-${list}`;
26
- const storedCart = localStorage.getItem(cartId);
27
+ const cartId = `lila-cart-${list}`;
28
+ const storedCart = localStorage.getItem(cartId);
27
29
 
28
- if(storedCart) {
30
+ if(storedCart) {
29
31
 
30
- try {
32
+ try {
31
33
 
32
- cartCache.value = JSON.parse(storedCart);
33
- products.value = await paymentProvider.getCartWithProducts(cartCache.value.id);
34
+ cartCache.value = JSON.parse(storedCart);
34
35
 
35
- } catch (error) {
36
+ const cartDocument = await paymentProvider.getCartWithProducts(cartCache.value.id);
37
+
38
+ products.value = cartDocument.items || [];
39
+ prename.value = cartDocument.prename || '';
40
+ name.value = cartDocument.name || '';
41
+
42
+ } catch (error) {
36
43
 
37
- console.error(error);
38
- localStorage.removeItem(cartId);
39
- cartCache.value = undefined;
40
- await getCart(attributes);
44
+ console.error(error);
45
+ localStorage.removeItem(cartId);
46
+ cartCache.value = undefined;
47
+ await getCart(attributes);
41
48
 
42
- }
49
+ }
43
50
 
44
- updateSummary();
51
+ updateSummary();
45
52
 
46
- } else {
53
+ } else {
47
54
 
48
- const newCart = await paymentProvider.getCart(attributes);
55
+ const newCart = await paymentProvider.getCart(attributes);
49
56
 
50
- localStorage.setItem(cartId, JSON.stringify(newCart));
57
+ localStorage.setItem(cartId, JSON.stringify(newCart));
51
58
 
52
- cartCache.value = newCart;
59
+ cartCache.value = newCart;
53
60
 
54
- }
61
+ }
55
62
 
56
- return Promise.resolve(cartCache.value);
63
+ return Promise.resolve(cartCache.value);
57
64
 
58
- }
65
+ }
59
66
 
60
- function getFinishedCart (cartId: string) {
67
+ function getFinishedCart(cartId: string) {
61
68
 
62
- return paymentProvider.getFinishedCart(cartId);
69
+ return paymentProvider.getFinishedCart(cartId);
63
70
 
64
- }
71
+ }
65
72
 
66
- function importCart (cart: any[]) {
73
+ function importCart(cart: any[]) {
67
74
 
68
- console.log(cart);
75
+ console.log(cart);
69
76
 
70
- products.value = cart;
71
- updateSummary();
77
+ products.value = cart;
78
+ updateSummary();
72
79
 
73
- }
80
+ }
74
81
 
75
- function updateSummary () {
82
+ function updateSummary() {
76
83
 
77
- let costs = 0;
78
- let quantity = 0;
84
+ let costs = 0;
85
+ let quantity = 0;
79
86
 
80
- products.value.forEach((single) => {
87
+ products.value.forEach((single) => {
81
88
 
82
- costs += ((single.price.amount || 0) / 100) * single.quantity;
83
- quantity += single.quantity;
89
+ costs += ((single.price.amount || 0) / 100) * single.quantity;
90
+ quantity += single.quantity;
84
91
 
85
- });
92
+ });
86
93
 
87
- costSummary.value = Math.round(costs * 100) / 100
88
- itemsQuantity.value = quantity;
94
+ costSummary.value = Math.round(costs * 100) / 100
95
+ itemsQuantity.value = quantity;
89
96
 
90
- }
97
+ }
91
98
 
92
- function updateAgreements (acceptedAgreements: Agreement[]) {
99
+ function updateAgreements(acceptedAgreements: Agreement[], customer?: { prename?: string, name?: string }) {
93
100
 
94
- const attributes: Record<string, string> = {...cartCache.value.attributes};
101
+ const attributes: Record<string, string> = {...cartCache.value.attributes};
95
102
 
96
- acceptedAgreements.forEach((single, index) => {
103
+ acceptedAgreements.forEach((single, index) => {
97
104
 
98
- attributes[`agreement_${index}`] = single.contentId;
105
+ attributes[`agreement_${index}`] = single.contentId;
99
106
 
100
- });
107
+ });
101
108
 
102
- console.log(acceptedAgreements, cartCache.value, attributes);
103
- return paymentProvider.updateCartAttributes(cartCache.value.id, attributes);
109
+ console.log(acceptedAgreements, cartCache.value, attributes);
110
+ return paymentProvider.updateCartAttributes(cartCache.value.id, attributes, customer);
104
111
 
105
- }
112
+ }
106
113
 
107
- function getProductInCart (productId: string) {
114
+ function getProductInCart(productId: string) {
108
115
 
109
- if(!productId) return null;
110
- return products.value.find((single) => single.id === productId);
116
+ if(!productId) return null;
117
+ return products.value.find((single) => single.id === productId);
111
118
 
112
- }
119
+ }
113
120
 
114
- async function addProduct (productId: string) {
121
+ async function addProduct(productId: string) {
115
122
 
116
- const product = await paymentProvider.getProduct(productId);
117
- const cart = await getCart();
118
- const existingProduct = getProductInCart(product.id);
123
+ const product = await paymentProvider.getProduct(productId);
124
+ const cart = await getCart();
125
+ const existingProduct = getProductInCart(product.id);
119
126
 
120
- if(!existingProduct) {
127
+ if(!existingProduct) {
121
128
 
122
- const updatedProduct = await paymentProvider.addToCart(cart.id, product, 1);
129
+ const updatedProduct = await paymentProvider.addToCart(cart.id, product, 1);
123
130
 
124
- products.value.push({...updatedProduct, quantity: 1});
125
- updateSummary();
131
+ products.value.push({...updatedProduct, quantity: 1});
132
+ updateSummary();
126
133
 
127
- } else {
134
+ } else {
128
135
 
129
- console.log('update instead of add', product.id, existingProduct.quantity);
130
- updateQuantity(product.id, existingProduct.quantity + 1);
136
+ console.log('update instead of add', product.id, existingProduct.quantity);
137
+ updateQuantity(product.id, existingProduct.quantity + 1);
131
138
 
132
- }
139
+ }
133
140
 
134
- }
141
+ }
135
142
 
136
- async function updateQuantity (productId: string, quantity: number) {
143
+ async function updateQuantity(productId: string, quantity: number) {
137
144
 
138
- const existingProduct = getProductInCart(productId);
139
- const cart = await getCart();
145
+ const existingProduct = getProductInCart(productId);
146
+ const cart = await getCart();
140
147
 
141
- paymentProvider.updateQuantity(cart.id, existingProduct, quantity)
148
+ paymentProvider.updateQuantity(cart.id, existingProduct, quantity)
142
149
 
143
- existingProduct.quantity = quantity;
144
- updateSummary();
150
+ existingProduct.quantity = quantity;
151
+ updateSummary();
145
152
 
146
- }
153
+ }
147
154
 
148
- async function removeProduct (productId: string) {
155
+ async function removeProduct(productId: string) {
149
156
 
150
- const existingProduct = getProductInCart(productId);
151
- const cart = await getCart();
157
+ const existingProduct = getProductInCart(productId);
158
+ const cart = await getCart();
152
159
 
153
- await paymentProvider.removeFromCart(cart.id, existingProduct);
160
+ await paymentProvider.removeFromCart(cart.id, existingProduct);
154
161
 
155
- const index = products.value.findIndex((single) => single.id === productId);
162
+ const index = products.value.findIndex((single) => single.id === productId);
156
163
 
157
- products.value.splice(index, 1);
158
- updateSummary();
164
+ products.value.splice(index, 1);
165
+ updateSummary();
159
166
 
160
- }
167
+ }
161
168
 
162
- function finalize () {
169
+ function finalize() {
163
170
 
164
- return paymentProvider.finalize(cartCache.value.id);
171
+ return paymentProvider.finalize(cartCache.value.id);
165
172
 
166
- }
173
+ }
167
174
 
168
- return {
169
- addProduct,
170
- updateQuantity,
171
- removeProduct,
172
- updateAgreements,
173
- importCart,
174
- products,
175
- getProductInCart,
176
- costSummary,
177
- itemsQuantity,
178
- getCart,
179
- finalize,
180
- getFinishedCart,
181
- cart: cartCache
182
- }
175
+ return {
176
+ addProduct,
177
+ updateQuantity,
178
+ removeProduct,
179
+ updateAgreements,
180
+ importCart,
181
+ products,
182
+ getProductInCart,
183
+ costSummary,
184
+ itemsQuantity,
185
+ getCart,
186
+ finalize,
187
+ getFinishedCart,
188
+ prename,
189
+ name,
190
+ cart: cartCache
191
+ }
183
192
 
184
193
  })
185
194