@lilaquadrat/design-core 0.1.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/README.md +236 -0
- package/html/index.html +25 -0
- package/html/index.mail.html +15 -0
- package/html/index.server.html +29 -0
- package/package.json +148 -0
- package/src/client-entry.ts +28 -0
- package/src/components/partials/action.partial.vue +30 -0
- package/src/components/partials/client-only.partial.vue +11 -0
- package/src/components/partials/error.partial.vue +73 -0
- package/src/components/partials/main-components.partial.vue +167 -0
- package/src/components/partials/mediadetection.partial.vue +71 -0
- package/src/components/partials/qrcode.partial.vue +35 -0
- package/src/customs.ts +12 -0
- package/src/env.d.ts +1 -0
- package/src/functions/PaymenyProviderFactory.ts +27 -0
- package/src/functions/lila-dom.ts +100 -0
- package/src/functions/shopify.provider.ts +378 -0
- package/src/functions/stripe.provider.ts +181 -0
- package/src/globals.d.ts +19 -0
- package/src/index.ts +47 -0
- package/src/interfaces/AppState.interface.ts +4 -0
- package/src/interfaces/EditorConfiguration.interface.ts +15 -0
- package/src/interfaces/EventDeclaration.interface.ts +19 -0
- package/src/interfaces/FrontendConfig.interface.ts +42 -0
- package/src/interfaces/GenericEvents.interface.ts +6 -0
- package/src/interfaces/GenericState.interface.ts +5 -0
- package/src/interfaces/IconsPartial.ts +9 -0
- package/src/interfaces/IdTokenExtended.interface.ts +7 -0
- package/src/interfaces/ModuleBaseProps.interface.ts +8 -0
- package/src/interfaces/PaymentProvider.interface.ts +13 -0
- package/src/libs/ActionNotice.ts +235 -0
- package/src/libs/Models.class.ts +482 -0
- package/src/main.ts +84 -0
- package/src/mixins/createCookieString.ts +78 -0
- package/src/mixins/createModelDeclaration.ts +29 -0
- package/src/mixins/createRouter.ts +30 -0
- package/src/mixins/date.ts +23 -0
- package/src/mixins/formatSize.ts +12 -0
- package/src/mixins/getAnchor.ts +14 -0
- package/src/mixins/getRoutes.ts +50 -0
- package/src/mixins/hasSlotContent.ts +32 -0
- package/src/mixins/hooks.ts +104 -0
- package/src/mixins/loadComponents.ts +107 -0
- package/src/mixins/logger.ts +32 -0
- package/src/mixins/replaceVariables.ts +19 -0
- package/src/mixins/scroll.ts +83 -0
- package/src/models/Address.model.ts +24 -0
- package/src/models/Contact.model.ts +22 -0
- package/src/models.ts +2 -0
- package/src/plugins/auth.ts +121 -0
- package/src/plugins/currency.ts +26 -0
- package/src/plugins/events.ts +156 -0
- package/src/plugins/filters.ts +43 -0
- package/src/plugins/inview.ts +351 -0
- package/src/plugins/replacer.ts +18 -0
- package/src/plugins/resize.ts +128 -0
- package/src/plugins/signupFlow.ts +89 -0
- package/src/plugins/traceable.ts +53 -0
- package/src/plugins/translations.ts +29 -0
- package/src/plugins/youtube.ts +80 -0
- package/src/routes.ts +132 -0
- package/src/server-entry.ts +113 -0
- package/src/stores/calls.store.ts +33 -0
- package/src/stores/cart.store.ts +186 -0
- package/src/stores/content.store.ts +83 -0
- package/src/stores/editor.store.ts +27 -0
- package/src/stores/files.store.ts +166 -0
- package/src/stores/main.store.ts +184 -0
- package/src/stores/user.store.ts +124 -0
- package/src/translations/de.ts +138 -0
- package/src/views/content.view.vue +219 -0
- package/src/views/download.view.vue +143 -0
- package/src/views/editor.view.vue +243 -0
- package/src/views/login.view.vue +82 -0
- package/src/views/signup-account.view.vue +64 -0
- package/tooling/cypress/config.ts +80 -0
- package/tooling/cypress/generate-manifest.js +5 -0
- package/tooling/cypress/manifest-utils.mjs +40 -0
- package/tooling/cypress/run-parallel.mjs +77 -0
- package/tooling/cypress/support/commands.ts +436 -0
- package/tooling/cypress/support/e2e.ts +17 -0
- package/tooling/eslint.config.js +223 -0
- package/tooling/preview.plugin.ts +134 -0
- package/tooling/ssr-test/index.mjs +391 -0
- package/tooling/stylelint.config.mjs +24 -0
- package/tooling/vite.ts +246 -0
package/tooling/vite.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { defineConfig, type UserConfig } from 'vite';
|
|
6
|
+
import vue from '@vitejs/plugin-vue';
|
|
7
|
+
|
|
8
|
+
import { visualizer } from 'rollup-plugin-visualizer';
|
|
9
|
+
|
|
10
|
+
import previewBundle, { dropPreviewAssets, previewBuildOptions } from './preview.plugin.ts';
|
|
11
|
+
|
|
12
|
+
export type Target = 'local' | 'next' | 'live';
|
|
13
|
+
|
|
14
|
+
export interface ViteFactoryOptions {
|
|
15
|
+
/**
|
|
16
|
+
* the project config keyed by target, as exported from its own config.ts.
|
|
17
|
+
* it is only serialised into __FRONTEND_CONFIG__, so its shape is the
|
|
18
|
+
* project's business
|
|
19
|
+
*/
|
|
20
|
+
config: Record<Target, unknown>
|
|
21
|
+
/**
|
|
22
|
+
* absolute path to the project root (the folder holding index.html)
|
|
23
|
+
*/
|
|
24
|
+
root: string
|
|
25
|
+
/**
|
|
26
|
+
* project relative path to the less folder holding variables, mixins and
|
|
27
|
+
* fonts - these are the design and never ship with the package
|
|
28
|
+
*/
|
|
29
|
+
lessDir?: string
|
|
30
|
+
/**
|
|
31
|
+
* project relative entry for the ssr build
|
|
32
|
+
*/
|
|
33
|
+
ssrEntry?: string
|
|
34
|
+
/**
|
|
35
|
+
* project relative entry for the ssr preflight fixtures (mode ssr-test).
|
|
36
|
+
* it exports the design's viewData and module registries so the test suite
|
|
37
|
+
* can read them without a bundler of its own
|
|
38
|
+
*/
|
|
39
|
+
ssrFixturesEntry?: string
|
|
40
|
+
/**
|
|
41
|
+
* additional defines merged over the framework ones
|
|
42
|
+
*/
|
|
43
|
+
define?: Record<string, string>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function resolveTarget (mode: string): Target {
|
|
47
|
+
|
|
48
|
+
if(mode === 'production') return 'live';
|
|
49
|
+
if(mode === 'next') return 'next';
|
|
50
|
+
|
|
51
|
+
return 'local';
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* the html templates the ssr build emits alongside the bundle. a project may
|
|
57
|
+
* override either by keeping a file of the same name in its root, otherwise the
|
|
58
|
+
* package template is used.
|
|
59
|
+
*/
|
|
60
|
+
function resolveTemplate (root: string, name: string) {
|
|
61
|
+
|
|
62
|
+
const projectTemplate = resolve(root, name);
|
|
63
|
+
|
|
64
|
+
if(existsSync(projectTemplate)) return projectTemplate;
|
|
65
|
+
|
|
66
|
+
return fileURLToPath(new URL(`../html/${name}`, import.meta.url));
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function createViteConfig (options: ViteFactoryOptions) {
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* absolute on purpose: the globalVars below are prepended to every less file,
|
|
74
|
+
* including the ones inside the package, where a project relative path would
|
|
75
|
+
* resolve against node_modules
|
|
76
|
+
*/
|
|
77
|
+
const lessDir = resolve(options.root, options.lessDir ?? './src/assets/less');
|
|
78
|
+
const ssrEntry = options.ssrEntry ?? '/src/server-entry.ts';
|
|
79
|
+
const ssrFixturesEntry = options.ssrFixturesEntry ?? '/src/ssr-test.fixtures.ts';
|
|
80
|
+
|
|
81
|
+
return defineConfig((settings): UserConfig => {
|
|
82
|
+
|
|
83
|
+
const target = resolveTarget(settings.mode);
|
|
84
|
+
const isProduction = target === 'live';
|
|
85
|
+
/**
|
|
86
|
+
* shareable static module gallery: preview routes, hash history, no auth and
|
|
87
|
+
* inlined assets, so the output runs from file:// without a server
|
|
88
|
+
*/
|
|
89
|
+
const isPreview = settings.mode === 'preview';
|
|
90
|
+
/**
|
|
91
|
+
* a second ssr bundle holding nothing but the design's fixtures, so the ssr
|
|
92
|
+
* preflight can read viewData and the registries while still rendering
|
|
93
|
+
* through the real dist/server build
|
|
94
|
+
*/
|
|
95
|
+
const isSsrTest = settings.mode === 'ssr-test';
|
|
96
|
+
/**
|
|
97
|
+
* builds meant to be handed out rather than debugged: minified, no
|
|
98
|
+
* sourcemaps, no vue dev instrumentation
|
|
99
|
+
*/
|
|
100
|
+
const isOptimized = isProduction || isPreview;
|
|
101
|
+
const config = options.config[target];
|
|
102
|
+
const viteConfig: UserConfig = {
|
|
103
|
+
plugins: [
|
|
104
|
+
vue(),
|
|
105
|
+
visualizer(),
|
|
106
|
+
...isPreview ? [previewBundle()] : [dropPreviewAssets()]
|
|
107
|
+
],
|
|
108
|
+
base : './',
|
|
109
|
+
server: {
|
|
110
|
+
host: '0.0.0.0',
|
|
111
|
+
},
|
|
112
|
+
optimizeDeps: {
|
|
113
|
+
// keep both packages in source form: their less needs the project
|
|
114
|
+
// variables injected below, which a prebundle would not see
|
|
115
|
+
exclude: ['@lilaquadrat/studio', '@lilaquadrat/design-core']
|
|
116
|
+
},
|
|
117
|
+
build: {
|
|
118
|
+
cssCodeSplit : false,
|
|
119
|
+
cssMinify : isOptimized,
|
|
120
|
+
sourcemap : !isOptimized,
|
|
121
|
+
minify : isOptimized,
|
|
122
|
+
rolldownOptions: {
|
|
123
|
+
output: {
|
|
124
|
+
dir : 'dist/app',
|
|
125
|
+
// rolldown manual chunking: split deps into a vendor chunk, but
|
|
126
|
+
// never emit a chunk smaller than minSize - small groups fall back
|
|
127
|
+
// into the entry instead of producing hundreds of tiny files.
|
|
128
|
+
codeSplitting: {
|
|
129
|
+
minSize: 30_000,
|
|
130
|
+
groups : [
|
|
131
|
+
{ name: 'qrcode', test: /[\\/]node_modules[\\/]qrcode[\\/]/, minSize: 0 },
|
|
132
|
+
{ name: 'vendor', test: /[\\/]node_modules[\\/]/ },
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
assetFileNames: (assetInfo: { name?: string }) => {
|
|
136
|
+
if (assetInfo.name?.endsWith('woff') || assetInfo.name?.endsWith('png')) {
|
|
137
|
+
return '[name][extname]';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return '[name]-[hash][extname]';
|
|
141
|
+
},
|
|
142
|
+
chunkFileNames: '[name]-[hash].js',
|
|
143
|
+
entryFileNames: '[name]-[hash].js',
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
css: {
|
|
148
|
+
devSourcemap : true,
|
|
149
|
+
preprocessorOptions: {
|
|
150
|
+
less: {
|
|
151
|
+
sourceMap : true,
|
|
152
|
+
globalVars: {
|
|
153
|
+
globalVariables: `true; @import (reference) "${lessDir}/variables.less";`,
|
|
154
|
+
globalMixins : `true; @import (reference) "${lessDir}/mixins.less";`,
|
|
155
|
+
globalFonts : `true; @import (reference) "${lessDir}/fonts.less";`,
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
resolve: {
|
|
161
|
+
alias: {
|
|
162
|
+
'~fonts': resolve(options.root, 'src/assets/fonts'),
|
|
163
|
+
'@' : resolve(options.root, 'src'),
|
|
164
|
+
},
|
|
165
|
+
/**
|
|
166
|
+
* a linked @lilaquadrat/design-core resolves these from its own
|
|
167
|
+
* node_modules, which would give the app a second vue and a second
|
|
168
|
+
* pinia - one app instance registering into a store nobody reads.
|
|
169
|
+
* dedupe pins every shared runtime to the project copy.
|
|
170
|
+
*/
|
|
171
|
+
dedupe: [
|
|
172
|
+
'vue',
|
|
173
|
+
'vue-router',
|
|
174
|
+
'vue-i18n',
|
|
175
|
+
'pinia',
|
|
176
|
+
'@lilaquadrat/interfaces',
|
|
177
|
+
'@lilaquadrat/sdk',
|
|
178
|
+
'@lilaquadrat/studio',
|
|
179
|
+
'@auth0/auth0-spa-js',
|
|
180
|
+
'axios',
|
|
181
|
+
'dayjs',
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
define: {
|
|
185
|
+
'__FRONTEND_CONFIG__' : JSON.stringify(config),
|
|
186
|
+
'__TARGET__' : JSON.stringify(target),
|
|
187
|
+
'__PREVIEW__' : JSON.stringify(isPreview),
|
|
188
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: isOptimized ? 'false' : 'true',
|
|
189
|
+
__VUE_PROD_DEVTOOLS__ : isOptimized ? 'false' : 'true',
|
|
190
|
+
...options.define
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
if (isPreview) {
|
|
195
|
+
|
|
196
|
+
viteConfig.build = previewBuildOptions(viteConfig.build);
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (settings.isSsrBuild) {
|
|
201
|
+
|
|
202
|
+
viteConfig.build = {
|
|
203
|
+
...viteConfig.build,
|
|
204
|
+
rolldownOptions: {
|
|
205
|
+
input : isSsrTest ? ssrFixturesEntry : ssrEntry,
|
|
206
|
+
plugins: isSsrTest ? [] : [
|
|
207
|
+
{
|
|
208
|
+
name: 'emit-html-templates',
|
|
209
|
+
async generateBundle () {
|
|
210
|
+
const { readFile } = await import('node:fs/promises');
|
|
211
|
+
const [mailHtml, serverHtml] = await Promise.all([
|
|
212
|
+
readFile(resolveTemplate(options.root, 'index.mail.html'), 'utf-8'),
|
|
213
|
+
readFile(resolveTemplate(options.root, 'index.server.html'), 'utf-8'),
|
|
214
|
+
]);
|
|
215
|
+
|
|
216
|
+
this.emitFile({ type: 'asset', fileName: 'index.mail.html', source: mailHtml });
|
|
217
|
+
this.emitFile({ type: 'asset', fileName: 'index.server.html', source: serverHtml });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
output: {
|
|
222
|
+
...viteConfig.build?.rolldownOptions?.output,
|
|
223
|
+
codeSplitting : false,
|
|
224
|
+
inlineDynamicImports: true,
|
|
225
|
+
dir : isSsrTest ? 'dist/ssr-test' : 'dist/server',
|
|
226
|
+
entryFileNames : '[name].js',
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
ssrManifest: !isSsrTest,
|
|
230
|
+
}
|
|
231
|
+
viteConfig.ssr = {
|
|
232
|
+
target : 'webworker',
|
|
233
|
+
noExternal: true,
|
|
234
|
+
external : ['node:stream', 'http', 'https', 'crypto', 'path', 'highlight.js'],
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return viteConfig;
|
|
240
|
+
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export default createViteConfig;
|
|
246
|
+
export { previewBundle, dropPreviewAssets, previewBuildOptions };
|