@magmonium/cli 0.7.8

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 (204) hide show
  1. package/README.md +392 -0
  2. package/bin/README.md +244 -0
  3. package/bin/cli.js +55 -0
  4. package/bin/commands/assets-wc.js +249 -0
  5. package/bin/commands/assets.js +943 -0
  6. package/bin/commands/build.js +242 -0
  7. package/bin/commands/clean.js +621 -0
  8. package/bin/commands/compile-i18n.js +91 -0
  9. package/bin/commands/config-ci.js +266 -0
  10. package/bin/commands/configure-wc.js +167 -0
  11. package/bin/commands/connect.js +188 -0
  12. package/bin/commands/create-app.js +946 -0
  13. package/bin/commands/deploy.js +100 -0
  14. package/bin/commands/fix-i18n.js +40 -0
  15. package/bin/commands/generate.js +765 -0
  16. package/bin/commands/init/config-files.js +1114 -0
  17. package/bin/commands/init/mag-assets.js +541 -0
  18. package/bin/commands/init/mag-cli-config.js +120 -0
  19. package/bin/commands/init/monorepo-structure.js +735 -0
  20. package/bin/commands/init/package-json.js +308 -0
  21. package/bin/commands/init/project-structure.js +189 -0
  22. package/bin/commands/init/pwa-files.js +204 -0
  23. package/bin/commands/init/source-files.js +2596 -0
  24. package/bin/commands/init.js +591 -0
  25. package/bin/commands/lib.js +508 -0
  26. package/bin/commands/patch-wc-env.js +136 -0
  27. package/bin/commands/refractor.js +51 -0
  28. package/bin/commands/sanitize-i18n.js +41 -0
  29. package/bin/commands/translate.js +32 -0
  30. package/bin/commands/zip.js +540 -0
  31. package/package.json +53 -0
  32. package/src/compilers/button-group-compiler.d.ts +18 -0
  33. package/src/compilers/button-group-compiler.d.ts.map +1 -0
  34. package/src/compilers/button-group-compiler.js +151 -0
  35. package/src/compilers/button-group-compiler.js.map +1 -0
  36. package/src/compilers/copy-compiler.d.ts +14 -0
  37. package/src/compilers/copy-compiler.d.ts.map +1 -0
  38. package/src/compilers/copy-compiler.js +170 -0
  39. package/src/compilers/copy-compiler.js.map +1 -0
  40. package/src/compilers/field-compiler.d.ts +15 -0
  41. package/src/compilers/field-compiler.d.ts.map +1 -0
  42. package/src/compilers/field-compiler.js +153 -0
  43. package/src/compilers/field-compiler.js.map +1 -0
  44. package/src/compilers/form-compiler.d.ts +15 -0
  45. package/src/compilers/form-compiler.d.ts.map +1 -0
  46. package/src/compilers/form-compiler.js +220 -0
  47. package/src/compilers/form-compiler.js.map +1 -0
  48. package/src/compilers/logo-compiler.d.ts +14 -0
  49. package/src/compilers/logo-compiler.d.ts.map +1 -0
  50. package/src/compilers/logo-compiler.js +114 -0
  51. package/src/compilers/logo-compiler.js.map +1 -0
  52. package/src/compilers/options-compiler.d.ts +46 -0
  53. package/src/compilers/options-compiler.d.ts.map +1 -0
  54. package/src/compilers/options-compiler.js +329 -0
  55. package/src/compilers/options-compiler.js.map +1 -0
  56. package/src/compilers/pwa-build.d.ts +7 -0
  57. package/src/compilers/pwa-build.d.ts.map +1 -0
  58. package/src/compilers/pwa-build.js +62 -0
  59. package/src/compilers/pwa-build.js.map +1 -0
  60. package/src/compilers/svg-compiler.d.ts +12 -0
  61. package/src/compilers/svg-compiler.d.ts.map +1 -0
  62. package/src/compilers/svg-compiler.js +123 -0
  63. package/src/compilers/svg-compiler.js.map +1 -0
  64. package/src/compilers/tabs-compiler.d.ts +25 -0
  65. package/src/compilers/tabs-compiler.d.ts.map +1 -0
  66. package/src/compilers/tabs-compiler.js +422 -0
  67. package/src/compilers/tabs-compiler.js.map +1 -0
  68. package/src/compilers/theme-compiler.d.ts +14 -0
  69. package/src/compilers/theme-compiler.d.ts.map +1 -0
  70. package/src/compilers/theme-compiler.js +144 -0
  71. package/src/compilers/theme-compiler.js.map +1 -0
  72. package/src/compilers/translation-compiler.d.ts +17 -0
  73. package/src/compilers/translation-compiler.d.ts.map +1 -0
  74. package/src/compilers/translation-compiler.js +232 -0
  75. package/src/compilers/translation-compiler.js.map +1 -0
  76. package/src/compilers/web-component/index.d.ts +3 -0
  77. package/src/compilers/web-component/index.d.ts.map +1 -0
  78. package/src/compilers/web-component/index.js +6 -0
  79. package/src/compilers/web-component/index.js.map +1 -0
  80. package/src/compilers/web-component/lib/builder.d.ts +45 -0
  81. package/src/compilers/web-component/lib/builder.d.ts.map +1 -0
  82. package/src/compilers/web-component/lib/builder.js +341 -0
  83. package/src/compilers/web-component/lib/builder.js.map +1 -0
  84. package/src/compilers/web-component/lib/class-name.d.ts +4 -0
  85. package/src/compilers/web-component/lib/class-name.d.ts.map +1 -0
  86. package/src/compilers/web-component/lib/class-name.js +24 -0
  87. package/src/compilers/web-component/lib/class-name.js.map +1 -0
  88. package/src/compilers/web-component/lib/config-data.d.ts +9 -0
  89. package/src/compilers/web-component/lib/config-data.d.ts.map +1 -0
  90. package/src/compilers/web-component/lib/config-data.js +14 -0
  91. package/src/compilers/web-component/lib/config-data.js.map +1 -0
  92. package/src/compilers/web-component/lib/ng-build.d.ts +8 -0
  93. package/src/compilers/web-component/lib/ng-build.d.ts.map +1 -0
  94. package/src/compilers/web-component/lib/ng-build.js +685 -0
  95. package/src/compilers/web-component/lib/ng-build.js.map +1 -0
  96. package/src/compilers/web-component/lib/resource-inliner.d.ts +9 -0
  97. package/src/compilers/web-component/lib/resource-inliner.d.ts.map +1 -0
  98. package/src/compilers/web-component/lib/resource-inliner.js +355 -0
  99. package/src/compilers/web-component/lib/resource-inliner.js.map +1 -0
  100. package/src/compilers/web-component/lib/web-component-name.d.ts +3 -0
  101. package/src/compilers/web-component/lib/web-component-name.d.ts.map +1 -0
  102. package/src/compilers/web-component/lib/web-component-name.js +47 -0
  103. package/src/compilers/web-component/lib/web-component-name.js.map +1 -0
  104. package/src/compilers/web-component/lib/web-component-wrapper.d.ts +3 -0
  105. package/src/compilers/web-component/lib/web-component-wrapper.d.ts.map +1 -0
  106. package/src/compilers/web-component/lib/web-component-wrapper.js +335 -0
  107. package/src/compilers/web-component/lib/web-component-wrapper.js.map +1 -0
  108. package/src/compilers/web-component/model/type.d.ts +29 -0
  109. package/src/compilers/web-component/model/type.d.ts.map +1 -0
  110. package/src/compilers/web-component/model/type.js +3 -0
  111. package/src/compilers/web-component/model/type.js.map +1 -0
  112. package/src/compilers/worker-compiler.d.ts +12 -0
  113. package/src/compilers/worker-compiler.d.ts.map +1 -0
  114. package/src/compilers/worker-compiler.js +123 -0
  115. package/src/compilers/worker-compiler.js.map +1 -0
  116. package/src/compilers/yaml-compiler.d.ts +18 -0
  117. package/src/compilers/yaml-compiler.d.ts.map +1 -0
  118. package/src/compilers/yaml-compiler.js +139 -0
  119. package/src/compilers/yaml-compiler.js.map +1 -0
  120. package/src/core/base-compiler.d.ts +17 -0
  121. package/src/core/base-compiler.d.ts.map +1 -0
  122. package/src/core/base-compiler.js +78 -0
  123. package/src/core/base-compiler.js.map +1 -0
  124. package/src/core/config.d.ts +640 -0
  125. package/src/core/config.d.ts.map +1 -0
  126. package/src/core/config.js +432 -0
  127. package/src/core/config.js.map +1 -0
  128. package/src/core/file-watcher.d.ts +23 -0
  129. package/src/core/file-watcher.d.ts.map +1 -0
  130. package/src/core/file-watcher.js +63 -0
  131. package/src/core/file-watcher.js.map +1 -0
  132. package/src/index.d.ts +31 -0
  133. package/src/index.d.ts.map +1 -0
  134. package/src/index.js +34 -0
  135. package/src/index.js.map +1 -0
  136. package/src/types/asset-configs.d.ts +189 -0
  137. package/src/types/asset-configs.d.ts.map +1 -0
  138. package/src/types/asset-configs.js +7 -0
  139. package/src/types/asset-configs.js.map +1 -0
  140. package/src/types/theme.d.ts +67 -0
  141. package/src/types/theme.d.ts.map +1 -0
  142. package/src/types/theme.js +3 -0
  143. package/src/types/theme.js.map +1 -0
  144. package/src/utils/file-utils.d.ts +16 -0
  145. package/src/utils/file-utils.d.ts.map +1 -0
  146. package/src/utils/file-utils.js +58 -0
  147. package/src/utils/file-utils.js.map +1 -0
  148. package/src/utils/i18n-compile-validator.d.ts +20 -0
  149. package/src/utils/i18n-compile-validator.d.ts.map +1 -0
  150. package/src/utils/i18n-compile-validator.js +198 -0
  151. package/src/utils/i18n-compile-validator.js.map +1 -0
  152. package/src/utils/i18n-fixer.d.ts +39 -0
  153. package/src/utils/i18n-fixer.d.ts.map +1 -0
  154. package/src/utils/i18n-fixer.js +396 -0
  155. package/src/utils/i18n-fixer.js.map +1 -0
  156. package/src/utils/i18n-sanitizer.d.ts +17 -0
  157. package/src/utils/i18n-sanitizer.d.ts.map +1 -0
  158. package/src/utils/i18n-sanitizer.js +101 -0
  159. package/src/utils/i18n-sanitizer.js.map +1 -0
  160. package/src/utils/i18n-utils.d.ts +21 -0
  161. package/src/utils/i18n-utils.d.ts.map +1 -0
  162. package/src/utils/i18n-utils.js +89 -0
  163. package/src/utils/i18n-utils.js.map +1 -0
  164. package/src/utils/interactive-translator.d.ts +18 -0
  165. package/src/utils/interactive-translator.d.ts.map +1 -0
  166. package/src/utils/interactive-translator.js +401 -0
  167. package/src/utils/interactive-translator.js.map +1 -0
  168. package/src/utils/llama-cpp-translator.d.ts +33 -0
  169. package/src/utils/llama-cpp-translator.d.ts.map +1 -0
  170. package/src/utils/llama-cpp-translator.js +267 -0
  171. package/src/utils/llama-cpp-translator.js.map +1 -0
  172. package/src/utils/logger.d.ts +14 -0
  173. package/src/utils/logger.d.ts.map +1 -0
  174. package/src/utils/logger.js +42 -0
  175. package/src/utils/logger.js.map +1 -0
  176. package/src/utils/ollama-translator.d.ts +38 -0
  177. package/src/utils/ollama-translator.d.ts.map +1 -0
  178. package/src/utils/ollama-translator.js +371 -0
  179. package/src/utils/ollama-translator.js.map +1 -0
  180. package/src/utils/option-utils.d.ts +58 -0
  181. package/src/utils/option-utils.d.ts.map +1 -0
  182. package/src/utils/option-utils.js +123 -0
  183. package/src/utils/option-utils.js.map +1 -0
  184. package/src/utils/platform-utils.d.ts +33 -0
  185. package/src/utils/platform-utils.d.ts.map +1 -0
  186. package/src/utils/platform-utils.js +114 -0
  187. package/src/utils/platform-utils.js.map +1 -0
  188. package/src/utils/pwa-utils.d.ts +28 -0
  189. package/src/utils/pwa-utils.d.ts.map +1 -0
  190. package/src/utils/pwa-utils.js +48 -0
  191. package/src/utils/pwa-utils.js.map +1 -0
  192. package/src/utils/translation-manager.d.ts +43 -0
  193. package/src/utils/translation-manager.d.ts.map +1 -0
  194. package/src/utils/translation-manager.js +302 -0
  195. package/src/utils/translation-manager.js.map +1 -0
  196. package/src/utils/web-translation-providers.d.ts +53 -0
  197. package/src/utils/web-translation-providers.d.ts.map +1 -0
  198. package/src/utils/web-translation-providers.js +190 -0
  199. package/src/utils/web-translation-providers.js.map +1 -0
  200. package/src/utils/yaml-utils.d.ts +9 -0
  201. package/src/utils/yaml-utils.d.ts.map +1 -0
  202. package/src/utils/yaml-utils.js +26 -0
  203. package/src/utils/yaml-utils.js.map +1 -0
  204. package/templates/mag-compile.config.js +77 -0
@@ -0,0 +1,335 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWebComponentWrapper = createWebComponentWrapper;
4
+ const tslib_1 = require("tslib");
5
+ const node_fs_1 = require("node:fs");
6
+ const path_1 = require("path");
7
+ const sass = tslib_1.__importStar(require("sass"));
8
+ function findWorkspaceRoot(startPath) {
9
+ let current = (0, path_1.resolve)(startPath);
10
+ for (let i = 0; i < 10; i++) {
11
+ if ((0, node_fs_1.existsSync)((0, path_1.join)(current, 'nx.json')) ||
12
+ (0, node_fs_1.existsSync)((0, path_1.join)(current, 'tsconfig.base.json'))) {
13
+ return current;
14
+ }
15
+ const parent = (0, path_1.dirname)(current);
16
+ if (parent === current)
17
+ break;
18
+ current = parent;
19
+ }
20
+ return startPath;
21
+ }
22
+ function compileGlobalStyles(componentPath) {
23
+ const workspaceRoot = findWorkspaceRoot(componentPath);
24
+ const sassLibPath = (0, path_1.join)(workspaceRoot, 'libs/one/src/lib/shared/sass');
25
+ // Find project.json to get global styles
26
+ let currentDir = (0, path_1.dirname)(componentPath);
27
+ let projectJsonPath = '';
28
+ for (let i = 0; i < 10; i++) {
29
+ const checkPath = (0, path_1.join)(currentDir, 'project.json');
30
+ if ((0, node_fs_1.existsSync)(checkPath)) {
31
+ projectJsonPath = checkPath;
32
+ break;
33
+ }
34
+ const parentDir = (0, path_1.dirname)(currentDir);
35
+ if (parentDir === currentDir)
36
+ break;
37
+ currentDir = parentDir;
38
+ }
39
+ const stylesToCompile = [];
40
+ // ALWAYS include foundational reset first
41
+ const resetSassPath = (0, path_1.resolve)(sassLibPath, '_reset.sass');
42
+ if ((0, node_fs_1.existsSync)(resetSassPath)) {
43
+ stylesToCompile.push(resetSassPath);
44
+ }
45
+ let externalStyles = '';
46
+ let preconnectMatches = [];
47
+ const extraIncludePaths = [];
48
+ if (projectJsonPath) {
49
+ try {
50
+ const projectJson = JSON.parse((0, node_fs_1.readFileSync)(projectJsonPath, 'utf8'));
51
+ const projectStyles = projectJson.targets?.build?.options?.styles || [];
52
+ const projectRoot = (0, path_1.dirname)(projectJsonPath);
53
+ // Respect stylePreprocessorOptions.includePaths from project.json
54
+ const includePaths = projectJson.targets?.build?.options?.stylePreprocessorOptions
55
+ ?.includePaths || [];
56
+ for (const p of includePaths) {
57
+ extraIncludePaths.push((0, path_1.resolve)(workspaceRoot, p));
58
+ }
59
+ for (const style of projectStyles) {
60
+ const stylePath = typeof style === 'string' ? style : style.input;
61
+ const fullStylePath = (0, path_1.resolve)(workspaceRoot, stylePath);
62
+ if ((0, node_fs_1.existsSync)(fullStylePath) &&
63
+ !stylesToCompile.includes(fullStylePath)) {
64
+ stylesToCompile.push(fullStylePath);
65
+ }
66
+ }
67
+ // Also check index.html for fonts/links
68
+ const indexOption = projectJson.targets?.build?.options?.index;
69
+ const indexHtmlPath = indexOption
70
+ ? (0, path_1.resolve)(workspaceRoot, indexOption)
71
+ : (0, path_1.join)(projectRoot, 'src/index.html');
72
+ if ((0, node_fs_1.existsSync)(indexHtmlPath)) {
73
+ const indexContent = (0, node_fs_1.readFileSync)(indexHtmlPath, 'utf8');
74
+ const linkRegex = /<link[^>]+rel=['"]stylesheet['"][^>]*>/g;
75
+ externalStyles = (indexContent.match(linkRegex) || []).join('\n');
76
+ const preconnectRegex = /<link[^>]+rel=['"]preconnect['"][^>]*>/g;
77
+ preconnectMatches = indexContent.match(preconnectRegex) || [];
78
+ }
79
+ }
80
+ catch {
81
+ console.warn('⚠️ Failed to parse project.json for global styles');
82
+ }
83
+ }
84
+ let combinedCss = '';
85
+ for (const style of stylesToCompile) {
86
+ try {
87
+ const result = sass.compile(style, {
88
+ loadPaths: [
89
+ sassLibPath,
90
+ (0, path_1.dirname)(style),
91
+ workspaceRoot,
92
+ ...extraIncludePaths,
93
+ ],
94
+ style: 'compressed',
95
+ });
96
+ combinedCss += result.css;
97
+ }
98
+ catch (error) {
99
+ console.warn('⚠️ SASS compile failed for', style, ':', error);
100
+ }
101
+ }
102
+ // Collect font stylesheet URLs to inject into document.head at runtime.
103
+ const urlRegex = /href=['"]([^'"]+)['"]/g;
104
+ const fontUrls = [];
105
+ let match;
106
+ while ((match = urlRegex.exec(externalStyles)) !== null) {
107
+ fontUrls.push(match[1]);
108
+ }
109
+ // Collect preconnect hints (url + crossorigin flag) to inject into document.head.
110
+ const preconnectUrls = [];
111
+ for (const preconnectLink of preconnectMatches) {
112
+ const hrefMatch = /href=['"]([^'"]+)['"]/.exec(preconnectLink);
113
+ if (hrefMatch) {
114
+ preconnectUrls.push({
115
+ url: hrefMatch[1],
116
+ crossorigin: /crossorigin/.test(preconnectLink),
117
+ });
118
+ }
119
+ }
120
+ // Transform selectors for Shadow DOM scoping using :host.
121
+ const css = combinedCss
122
+ // 1. Replace html/body with :host for Shadow DOM scoping
123
+ // Include '}' in leading group to handle minified CSS where selectors immediately follow closing braces
124
+ .replace(/(^|[\s,}])(?:body|html)([\s,{]|$)/g, `$1:host$2`)
125
+ // 2. Remove overflow from :host rules to prevent internal scrollbars
126
+ .replace(/:host\s*\{([^}]+)\}/g, (_m, inner) => {
127
+ const cleaned = inner.replace(/overflow(?:-[xy])?\s*:[^;]+;?/g, '');
128
+ return `:host{${cleaned}}`;
129
+ })
130
+ // 3. No element selector scoping needed — Shadow DOM provides natural isolation
131
+ // 4. Scoped box-sizing reset using :host
132
+ .replace(/\*\{box-sizing:border-box\}/g, `:host *,:host *::before,:host *::after{box-sizing:border-box}`)
133
+ .replace(/`/g, '\\`');
134
+ return { css, fontUrls, preconnectUrls };
135
+ }
136
+ function generateWrapperCode(config) {
137
+ const { componentPath, appConfigPath } = config;
138
+ const hasAppConfig = !!appConfigPath && !!componentPath;
139
+ const appConfigRelPath = hasAppConfig
140
+ ? (() => {
141
+ const rel = (0, path_1.relative)(componentPath, appConfigPath).replace(/\\/g, '/');
142
+ return rel.startsWith('.') ? rel : `./${rel}`;
143
+ })()
144
+ : '';
145
+ const { css: globalStylesCss, fontUrls: globalFontUrls, preconnectUrls: globalPreconnectUrls, } = config.componentPath
146
+ ? compileGlobalStyles(config.componentPath)
147
+ : { css: '', fontUrls: [], preconnectUrls: [] };
148
+ const providersExpr = hasAppConfig
149
+ ? `{
150
+ ..._userAppConfig,
151
+ providers: [
152
+ ...(_userAppConfig.providers || []),
153
+ { provide: ASSET_BASE_URL, useValue: (function() {
154
+ try {
155
+ // When loaded as a blob, import.meta.url is the blob URL which cannot be resolved.
156
+ // The original URL is stored in data-wc-src on the script element by RemoteLoaderService.
157
+ const scripts = document.querySelectorAll('script[data-wc-src]');
158
+ const lastScript = scripts[scripts.length - 1] as HTMLScriptElement | undefined;
159
+ const rawUrl = lastScript?.dataset?.['wcSrc'] || import.meta.url;
160
+ // Resolve relative paths to absolute so new URL('..', base) works correctly.
161
+ const absoluteUrl = new URL(rawUrl, window.location.href).href;
162
+ const baseUrl = new URL('..', absoluteUrl).href;
163
+ const wcRoot = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
164
+ return wcRoot;
165
+ } catch (e) {
166
+ return './assets';
167
+ }
168
+ })()
169
+ }
170
+ ]
171
+ }`
172
+ : `{
173
+ providers: [
174
+ { provide: ASSET_BASE_URL, useValue: (function() {
175
+ try {
176
+ // When loaded as a blob, import.meta.url is the blob URL which cannot be resolved.
177
+ // The original URL is stored in data-wc-src on the script element by RemoteLoaderService.
178
+ const scripts = document.querySelectorAll('script[data-wc-src]');
179
+ const lastScript = scripts[scripts.length - 1] as HTMLScriptElement | undefined;
180
+ const rawUrl = lastScript?.dataset?.['wcSrc'] || import.meta.url;
181
+ // Resolve relative paths to absolute so new URL('..', base) works correctly.
182
+ const absoluteUrl = new URL(rawUrl, window.location.href).href;
183
+ const baseUrl = new URL('..', absoluteUrl).href;
184
+ const wcRoot = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
185
+ return wcRoot;
186
+ } catch (e) {
187
+ return './assets';
188
+ }
189
+ })()
190
+ },
191
+ provideZonelessChangeDetection(),
192
+ provideHttpClient(withFetch(), withInterceptors([mInterceptor])),
193
+ provideAppInitializer(initMagmoniumApp({ backend: 'http://localhost:8000' })),
194
+ { provide: ThemeStore, useFactory: themeStoreFactory },
195
+ { provide: TranslateService, useFactory: translateServiceFactory },
196
+ { provide: LOGIN_COMPONENT, useValue: LoginOneComponent },
197
+ LoginStore,
198
+ { provide: LOGIN_STORE, useExisting: LoginStore },
199
+ ],
200
+ }`;
201
+ return `
202
+ import { createCustomElement } from '@angular/elements';
203
+ import { provideHttpClient, withFetch, withInterceptors } from '@angular/common/http';
204
+ import { ${config.className} } from './${config.componentName}';
205
+ import { provideAppInitializer, provideZonelessChangeDetection, ViewEncapsulation } from '@angular/core';
206
+ import { createApplication, ɵSharedStylesHost } from '@angular/platform-browser';
207
+ import {
208
+ SharedStoreRegistry,
209
+ ThemeStore,
210
+ TranslateService,
211
+ initMagmoniumApp,
212
+ LOGIN_COMPONENT,
213
+ LOGIN_STORE,
214
+ LoginOneComponent,
215
+ LoginStore,
216
+ mInterceptor,
217
+ ASSET_BASE_URL,
218
+ HttpService
219
+ } from '@magmonium/one';
220
+ ${hasAppConfig ? `import { appConfig as _userAppConfig } from '${appConfigRelPath}';` : ''}
221
+
222
+ const _globalStylesCss = \`${globalStylesCss}\`;
223
+ const _fontUrls: string[] = ${JSON.stringify(globalFontUrls)};
224
+ const _preconnectUrls: Array<{ url: string; crossorigin: boolean }> = ${JSON.stringify(globalPreconnectUrls)};
225
+
226
+ // Inject font preconnect hints and stylesheets into document.head once at load time.
227
+ (function _injectDocumentFonts() {
228
+ for (const { url, crossorigin } of _preconnectUrls) {
229
+ if (!document.querySelector(\`link[rel="preconnect"][href="\${url}"]\`)) {
230
+ const link = document.createElement('link');
231
+ link.rel = 'preconnect';
232
+ link.href = url;
233
+ if (crossorigin) link.crossOrigin = '';
234
+ document.head.appendChild(link);
235
+ }
236
+ }
237
+ for (const url of _fontUrls) {
238
+ if (!document.querySelector(\`link[rel="stylesheet"][href="\${url}"]\`)) {
239
+ const link = document.createElement('link');
240
+ link.rel = 'stylesheet';
241
+ link.href = url;
242
+ document.head.appendChild(link);
243
+ }
244
+ }
245
+ })();
246
+
247
+ export function themeStoreFactory() {
248
+ return SharedStoreRegistry.getThemeStore() || new ThemeStore();
249
+ }
250
+
251
+ export function translateServiceFactory() {
252
+ return SharedStoreRegistry.getTranslateService() || new TranslateService();
253
+ }
254
+
255
+ (async function () {
256
+ try {
257
+ // Create application (NOT bootstrap)
258
+ const app = await createApplication(${providersExpr});
259
+
260
+ // CRITICAL: Prevent infinite recursion; enable Shadow DOM for style isolation
261
+ if ((${config.className} as any).ɵcmp) {
262
+ // 1. Change selector to avoid collision with Custom Element name
263
+ (${config.className} as any).ɵcmp.selectors = [['ng-component']];
264
+ // 2. Enable Shadow DOM for proper style encapsulation
265
+ (${config.className} as any).ɵcmp.encapsulation = ViewEncapsulation.ShadowDom;
266
+ // 3. Strip [_ngcontent-xxx] attribute selectors compiled for Emulated encapsulation —
267
+ // Shadow DOM does not add those attributes to elements, so they would never match.
268
+ const cmp = (${config.className} as any).ɵcmp;
269
+ if (Array.isArray(cmp.styles)) {
270
+ cmp.styles = cmp.styles.map((s: string) => s.replace(/\\[_ngcontent-[^\\]]+\\]/g, ''));
271
+ }
272
+ }
273
+
274
+ const themeStore = app.injector.get(ThemeStore);
275
+ const assetBaseUrl = app.injector.get(ASSET_BASE_URL);
276
+
277
+ // Override HttpService.assetUrl so non-'one' assets resolve against the WC's own asset path.
278
+ const httpService = app.injector.get(HttpService);
279
+ httpService.setAssetUrl(assetBaseUrl);
280
+ httpService.setPublicUrl(assetBaseUrl);
281
+
282
+ const styleId = 'm-global-resets-${config.selector}';
283
+
284
+ const customElement = class extends (createCustomElement(${config.className}, {
285
+ injector: app.injector,
286
+ }) as any) {
287
+ connectedCallback() {
288
+ super.connectedCallback();
289
+ // Allow content to grow naturally.
290
+ this['style'].display = 'block';
291
+
292
+ // Inject global CSS into Shadow Root for style encapsulation.
293
+ // Theme vars are inherited automatically from document.documentElement (CSS custom properties pierce shadow DOM).
294
+ if (_globalStylesCss && this['shadowRoot'] && !this['shadowRoot'].getElementById(styleId)) {
295
+ const style = document.createElement('style');
296
+ style.id = styleId;
297
+ style.textContent = _globalStylesCss;
298
+ this['shadowRoot'].insertBefore(style, this['shadowRoot'].firstChild);
299
+ }
300
+ }
301
+ };
302
+
303
+ const elementName = '${config.selector}';
304
+ if (!customElements.get(elementName)) {
305
+ customElements.define(elementName, customElement as any);
306
+ }
307
+
308
+ await customElements.whenDefined(elementName);
309
+
310
+ window.dispatchEvent(
311
+ new CustomEvent('${config.selector}-ready', {
312
+ detail: {
313
+ selector: elementName,
314
+ timestamp: Date.now(),
315
+ providersResolved: true,
316
+ },
317
+ })
318
+ );
319
+ } catch (error:any) {
320
+ console.error('❌ Failed to load web component:', error);
321
+ }
322
+ })();
323
+
324
+ export { ${config.className} };
325
+ export default ${config.className};
326
+ `;
327
+ }
328
+ function createWebComponentWrapper(config) {
329
+ const wrapperContent = generateWrapperCode(config);
330
+ const componentPath = config.componentPath || '';
331
+ const wrapperPath = (0, path_1.resolve)(componentPath, `${config.selector}.ts`);
332
+ (0, node_fs_1.writeFileSync)(wrapperPath, wrapperContent);
333
+ return wrapperPath;
334
+ }
335
+ //# sourceMappingURL=web-component-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-component-wrapper.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/compilers/web-component/lib/web-component-wrapper.ts"],"names":[],"mappings":";;AAqWA,8DAMC;;AA3WD,qCAAkE;AAClE,+BAAwD;AACxD,mDAA6B;AAG7B,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,IAAI,OAAO,GAAG,IAAA,cAAO,EAAC,SAAS,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,IACE,IAAA,oBAAU,EAAC,IAAA,WAAI,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACpC,IAAA,oBAAU,EAAC,IAAA,WAAI,EAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,EAC/C,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,MAAM,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,OAAO;YAAE,MAAM;QAC9B,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,mBAAmB,CAAC,aAAqB;IAKhD,MAAM,aAAa,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,aAAa,EAAE,8BAA8B,CAAC,CAAC;IAExE,yCAAyC;IACzC,IAAI,UAAU,GAAG,IAAA,cAAO,EAAC,aAAa,CAAC,CAAC;IACxC,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,SAAS,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACnD,IAAI,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;;;;;;;;;;;;;;;;;;MAsBA;QACF,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4BA,CAAC;IAEL,OAAO;;;WAGE,MAAM,CAAC,SAAS,cAAc,MAAM,CAAC,aAAa;;;;;;;;;;;;;;;;EAgB3D,YAAY,CAAC,CAAC,CAAC,gDAAgD,gBAAgB,IAAI,CAAC,CAAC,CAAC,EAAE;;6BAE7D,eAAe;8BACd,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;wEACY,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CAkClE,aAAa;;;WAG5C,MAAM,CAAC,SAAS;;SAElB,MAAM,CAAC,SAAS;;SAEhB,MAAM,CAAC,SAAS;;;qBAGJ,MAAM,CAAC,SAAS;;;;;;;;;;;;;;uCAcE,MAAM,CAAC,QAAQ;;+DAES,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;;2BAmBpD,MAAM,CAAC,QAAQ;;;;;;;;yBAQjB,MAAM,CAAC,QAAQ;;;;;;;;;;;;;WAa7B,MAAM,CAAC,SAAS;iBACV,MAAM,CAAC,SAAS;GAC9B,CAAC;AACJ,CAAC;AAED,SAAgB,yBAAyB,CAAC,MAA0B;IAClE,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;IACjD,MAAM,WAAW,GAAG,IAAA,cAAO,EAAC,aAAa,EAAE,GAAG,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC;IACpE,IAAA,uBAAa,EAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC3C,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,29 @@
1
+ export type WebComponentBaseConfig = {
2
+ app: string;
3
+ version: string;
4
+ name?: string;
5
+ description?: string;
6
+ company?: string;
7
+ componentPath?: string;
8
+ selector: string;
9
+ appId?: string;
10
+ link?: string;
11
+ appConfigPath?: string;
12
+ icon?: string;
13
+ logo?: string;
14
+ pwa?: {
15
+ desc?: string;
16
+ color?: string;
17
+ bgcolor?: string;
18
+ };
19
+ };
20
+ export type WebComponentConfigWithSpecificComponent = WebComponentBaseConfig & {
21
+ componentName: string;
22
+ };
23
+ export type WebComponentConfig = WebComponentConfigWithSpecificComponent & {
24
+ selector: string;
25
+ className: string;
26
+ componentFileName?: string;
27
+ timestamp?: string;
28
+ };
29
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../../../libs/cli/src/compilers/web-component/model/type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG,sBAAsB,GAAG;IAC7E,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,uCAAuC,GAAG;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/compilers/web-component/model/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { BaseCompiler } from '../core/base-compiler';
2
+ import { WorkerCompilerConfig } from '../core/config';
3
+ export declare class WorkerCompiler extends BaseCompiler {
4
+ private workerMapping;
5
+ constructor(config: WorkerCompilerConfig);
6
+ compile(): Promise<void>;
7
+ watch(): Promise<void>;
8
+ private loadWorkerMapping;
9
+ private compileWorkers;
10
+ private compileWorker;
11
+ }
12
+ //# sourceMappingURL=worker-compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-compiler.d.ts","sourceRoot":"","sources":["../../../../../libs/cli/src/compilers/worker-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAOtD,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,aAAa,CAA8B;gBAEvC,MAAM,EAAE,oBAAoB;IAIlC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAaxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAmCd,iBAAiB;YA8BjB,cAAc;YAQd,aAAa;CAgD5B"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkerCompiler = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const base_compiler_1 = require("../core/base-compiler");
6
+ const fs_1 = require("fs");
7
+ const path_1 = tslib_1.__importDefault(require("path"));
8
+ const child_process_1 = require("child_process");
9
+ const chokidar_1 = tslib_1.__importDefault(require("chokidar"));
10
+ class WorkerCompiler extends base_compiler_1.BaseCompiler {
11
+ constructor(config) {
12
+ super(config);
13
+ this.workerMapping = {};
14
+ }
15
+ async compile() {
16
+ this.logger.info('Compiling web workers...');
17
+ try {
18
+ await this.loadWorkerMapping();
19
+ await this.compileWorkers();
20
+ this.logger.success('Worker compilation completed!');
21
+ }
22
+ catch (error) {
23
+ this.logger.error(`Worker compilation failed: ${error}`);
24
+ throw error;
25
+ }
26
+ }
27
+ async watch() {
28
+ this.logger.info('Watching for worker changes...');
29
+ await this.compile();
30
+ const watchPaths = this.config.inputPaths.concat(Object.values(this.workerMapping));
31
+ const watcher = chokidar_1.default.watch(watchPaths, {
32
+ ignored: /node_modules/,
33
+ ignoreInitial: true,
34
+ });
35
+ watcher.on('change', async (filePath) => {
36
+ this.logger.info(`Worker file changed: ${filePath}`);
37
+ if (filePath.includes('worker-mapping.json')) {
38
+ await this.loadWorkerMapping();
39
+ }
40
+ await this.compileWorkers();
41
+ });
42
+ watcher.on('add', async (filePath) => {
43
+ this.logger.info(`Worker file added: ${filePath}`);
44
+ await this.compile();
45
+ });
46
+ watcher.on('unlink', async (filePath) => {
47
+ this.logger.info(`Worker file removed: ${filePath}`);
48
+ await this.compile();
49
+ });
50
+ }
51
+ async loadWorkerMapping() {
52
+ for (const inputPath of this.config.inputPaths) {
53
+ const mappingFile = path_1.default.join(inputPath, 'worker-mapping.json');
54
+ try {
55
+ const content = await fs_1.promises.readFile(mappingFile, 'utf-8');
56
+ const mapping = JSON.parse(content);
57
+ // Validate mapping format
58
+ if (typeof mapping !== 'object' || mapping === null) {
59
+ throw new Error('Worker mapping must be an object');
60
+ }
61
+ Object.assign(this.workerMapping, mapping);
62
+ this.logger.info(`Loaded worker mapping: ${Object.keys(mapping).length} workers`);
63
+ }
64
+ catch (error) {
65
+ if (error.code !== 'ENOENT') {
66
+ this.logger.error(`Failed to load worker mapping from ${mappingFile}: ${error}`);
67
+ throw error;
68
+ }
69
+ // File doesn't exist, continue with empty mapping
70
+ this.logger.info(`No worker mapping found at ${mappingFile}`);
71
+ }
72
+ }
73
+ }
74
+ async compileWorkers() {
75
+ await this.ensureOutputDir();
76
+ for (const [workerName, workerPath] of Object.entries(this.workerMapping)) {
77
+ await this.compileWorker(workerName, workerPath);
78
+ }
79
+ }
80
+ async compileWorker(workerName, workerPath) {
81
+ try {
82
+ // Check if source file exists
83
+ try {
84
+ await fs_1.promises.access(workerPath);
85
+ }
86
+ catch {
87
+ this.logger.warn(`Worker source file not found: ${workerPath}`);
88
+ return;
89
+ }
90
+ const outputFileName = `${workerName}.worker.js`;
91
+ this.logger.info(`Compiling worker: ${workerName} from ${workerPath}`);
92
+ // Compile to the output path
93
+ const outputFilePath = path_1.default.join(this.outputPath, outputFileName);
94
+ // Use esbuild for compilation and minification
95
+ const esbuildCommand = [
96
+ 'npx esbuild',
97
+ `"${workerPath}"`,
98
+ `--outfile="${outputFilePath}"`,
99
+ '--bundle',
100
+ '--minify',
101
+ '--target=es2020',
102
+ '--format=iife',
103
+ '--platform=browser',
104
+ '--legal-comments=none',
105
+ ].join(' ');
106
+ (0, child_process_1.execSync)(esbuildCommand, {
107
+ stdio: 'pipe',
108
+ cwd: process.cwd(),
109
+ });
110
+ this.logger.success(`Generated: ${outputFilePath}`);
111
+ this.emit('fileGenerated', {
112
+ filePath: outputFilePath,
113
+ fileName: outputFileName,
114
+ });
115
+ }
116
+ catch (error) {
117
+ this.logger.error(`Failed to compile worker ${workerName}: ${error}`);
118
+ throw error;
119
+ }
120
+ }
121
+ }
122
+ exports.WorkerCompiler = WorkerCompiler;
123
+ //# sourceMappingURL=worker-compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-compiler.js","sourceRoot":"","sources":["../../../../../libs/cli/src/compilers/worker-compiler.ts"],"names":[],"mappings":";;;;AAAA,yDAAqD;AAErD,2BAAoC;AACpC,wDAAwB;AACxB,iDAAyC;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AC/B,UAAU;gBACV,UAAU;gBACV,iBAAiB;gBACjB,eAAe;gBACf,oBAAoB;gBACpB,uBAAuB;aACxB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEZ,IAAA,wBAAQ,EAAC,cAAc,EAAE;gBACvB,KAAK,EAAE,MAAM;gBACb,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;aACnB,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,cAAc,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;gBACzB,QAAQ,EAAE,cAAc;gBACxB,QAAQ,EAAE,cAAc;aACzB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,UAAU,KAAK,KAAK,EAAE,CAAC,CAAC;YACtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA7ID,wCA6IC"}
@@ -0,0 +1,18 @@
1
+ import { BaseCompiler } from '../core/base-compiler';
2
+ import { YamlCompilerConfig } from '../core/config';
3
+ export declare class YamlCompiler<T = unknown> extends BaseCompiler {
4
+ private watcher;
5
+ private assetType;
6
+ private validationRules;
7
+ private ajvValidate;
8
+ constructor(config: YamlCompilerConfig);
9
+ compile(): Promise<void>;
10
+ watch(): Promise<void>;
11
+ private findYAMLFiles;
12
+ private processYAMLFiles;
13
+ private validateAsset;
14
+ private validateWithSchema;
15
+ private isYAMLFile;
16
+ stopWatching(): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=yaml-compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-compiler.d.ts","sourceRoot":"","sources":["../../../../../libs/cli/src/compilers/yaml-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAkB,MAAM,gBAAgB,CAAC;AAQpE,qBAAa,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,YAAY;IACzD,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,WAAW,CAAiC;gBAExC,MAAM,EAAE,kBAAkB;IAahC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkCxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YA6Bd,aAAa;YAeb,gBAAgB;IA6B9B,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,UAAU;IAKZ,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAMpC"}