@wavemaker-ai/angular-app 1.0.0-rc.309 → 1.0.0-rc.647469

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.
@@ -1,287 +0,0 @@
1
- /**
2
- * ngx-bootstrap patching utilities.
3
- * Canonical path: build-scripts/ next to build.js only (angular-app tarball → generated-app/build-scripts/).
4
- * Do not rely on a separate copy under config/.
5
- *
6
- * Provides Rollup plugin for bundling and standalone function for patching ESM files.
7
- * Patches: PositioningService (DestroyRef, reopen), ComponentLoader (subscriptions),
8
- * Dropdown/Modal (ngx-bootstrap v20 compatibility).
9
- */
10
-
11
- import fs from 'fs';
12
- import path from 'path';
13
-
14
- // ============================================
15
- // Utilities
16
- // ============================================
17
-
18
- const matchesModule = (id, ...modules) =>
19
- modules.some(mod => id.includes(`ngx-bootstrap-${mod}`) || id.includes(`ngx-bootstrap/${mod}`));
20
-
21
- const applyReplacement = (code, pattern, replacement, logMsg) => {
22
- const patched = code.replace(pattern, replacement);
23
- const changed = patched !== code;
24
- if (changed && logMsg) console.log(` ✅ ${logMsg}`);
25
- return { code: patched, changed };
26
- };
27
-
28
- // ============================================
29
- // Patch Definitions
30
- // ============================================
31
-
32
- const PATCHES = {
33
- positioning: {
34
- matcher: (id) => matchesModule(id, 'positioning'),
35
- apply: (code) => {
36
- let current = code;
37
- let anyChanged = false;
38
-
39
- // DestroyRef injection fix
40
- if (current.includes('takeUntilDestroyed()') && !current.includes('const __destroyRef = i0.inject(i0.DestroyRef)')) {
41
- const r1 = applyReplacement(
42
- current,
43
- /(constructor\s*\(\s*ngZone\s*,\s*rendererFactory\s*,\s*platformId\s*\)\s*\{)/,
44
- '$1\n const __destroyRef = i0.inject(i0.DestroyRef);',
45
- null
46
- );
47
- const r2 = applyReplacement(
48
- r1.code,
49
- /takeUntilDestroyed\(\)/g,
50
- 'takeUntilDestroyed(__destroyRef)',
51
- 'Patched PositioningService: DestroyRef injection'
52
- );
53
- current = r2.code;
54
- anyChanged = r2.changed || anyChanged;
55
- }
56
-
57
- // Repair bad reopen line: a plain replacement string cannot contain literal $$ (see reopen fix below).
58
- if (current.includes('this.update$.next')) {
59
- const beforeRepair = current;
60
- current = current.replace(/this\.update\$\.next\(null\);?/g, () => 'this.update$$.next(null);');
61
- if (current !== beforeRepair) {
62
- anyChanged = true;
63
- console.log(' ✅ Patched PositioningService: Repair update$$.next reopen line');
64
- }
65
- }
66
-
67
- // Reopen fix: pristine addPositionElement only calls set(); gate on that body (not global
68
- // this.enable(); / calcPosition’s update$$) so the patch still applies after ngx-bootstrap edits.
69
- const needsPositioningReopenFix =
70
- /addPositionElement\(options\)\s*\{\s*\n\s*this\.positionElements\.set\(_getHtmlElement\(options\.element\),\s*options\);\s*\n\s*\}/m.test(
71
- current
72
- );
73
- if (needsPositioningReopenFix) {
74
- const result = applyReplacement(
75
- current,
76
- /this\.positionElements\.set\(_getHtmlElement\(options\.element\),\s*options\);/g,
77
- 'this.positionElements.set(_getHtmlElement(options.element), options);\n this.enable();\n this.update$$$$.next(null);',
78
- 'Patched PositioningService: Reopen fix'
79
- );
80
- current = result.code;
81
- anyChanged = result.changed || anyChanged;
82
- }
83
-
84
- // BS5: computeAutoPlacement returns hyphenated keys (e.g. bottom-end) not in PlacementForBs5;
85
- // lookup is undefined → dataPlacement.split throws during PositioningService Map.forEach (wm-libs).
86
- if (!current.includes('PlacementForBs5[data.placement] ?? data.placement')) {
87
- const r3 = applyReplacement(
88
- current,
89
- /const dataPlacement = getBsVer\(\)\.isBs5\s*\n\s*\?\s*PlacementForBs5\[data\.placement\]\s*\n\s*:\s*data\.placement;/,
90
- `const dataPlacementRaw = getBsVer().isBs5
91
- ? PlacementForBs5[data.placement] ?? data.placement
92
- : data.placement;
93
- const dataPlacement = dataPlacementRaw ?? '';`,
94
- 'Patched updateContainerClass: BS5 placement fallback'
95
- );
96
- current = r3.code;
97
- anyChanged = r3.changed || anyChanged;
98
- }
99
- if (!current.includes('String(dataPlacement).split(/[\\s-]/)[0]')) {
100
- const safeReplaceLine =
101
- 'containerClass = containerClass.replace(/left|right|top|bottom|end|start/g, `' +
102
- '${(String(dataPlacement).split(/[\\s-]/)[0] || \'bottom\')}`' +
103
- ');';
104
- const r4 = applyReplacement(
105
- current,
106
- /containerClass = containerClass\.replace\(\/left\|right\|top\|bottom\|end\|start\/g, `\$\{dataPlacement\.split\(' '\)\[0\]\}`\);/,
107
- safeReplaceLine,
108
- 'Patched updateContainerClass: safe placement primary axis'
109
- );
110
- current = r4.code;
111
- anyChanged = r4.changed || anyChanged;
112
- }
113
-
114
- return { code: current, wasPatched: anyChanged };
115
- }
116
- },
117
-
118
- componentLoader: {
119
- matcher: (id) => matchesModule(id, 'component-loader'),
120
- apply: (code) => {
121
- let current = code;
122
- let anyChanged = false;
123
-
124
- const patches = [
125
- {
126
- condition: !current.includes('this._onShownSubscription = this.onShown.subscribe'),
127
- pattern: /this\.onShown\.subscribe\(\(\)\s*=>\s*\{/g,
128
- replacement: 'this._onShownSubscription = this.onShown.subscribe(() => {',
129
- msg: 'Patched ComponentLoader: Subscription tracking'
130
- },
131
- {
132
- condition: !/hide\([^)]*\)\s*\{[\s\S]*?_unsubscribePositioning\(\)[\s\S]*?_posService\.deletePositionElement/.test(current),
133
- pattern: /(hide\([^)]*\)\s*\{\s*\n\s*if\s*\(\s*!this\._componentRef\s*\)\s*\{\s*\n\s*return\s+this;\s*\n\s*\}\s*\n\s*)(this\._posService\.deletePositionElement)/,
134
- replacement: '$1this._unsubscribePositioning();\n $2',
135
- msg: 'Patched ComponentLoader: Hide cleanup'
136
- },
137
- {
138
- condition: !current.includes('if (this._onShownSubscription)'),
139
- pattern: /(_unsubscribePositioning\(\)\s*\{\s*\n\s*)(if\s*\(\s*!this\._zoneSubscription\s*\))/,
140
- replacement: `$1if (this._onShownSubscription) {\n this._onShownSubscription.unsubscribe();\n this._onShownSubscription = void 0;\n }\n $2`,
141
- msg: 'Patched ComponentLoader: Unsubscribe fix'
142
- }
143
- ];
144
-
145
- for (const { condition, pattern, replacement, msg } of patches) {
146
- if (condition) {
147
- const result = applyReplacement(current, pattern, replacement, msg);
148
- current = result.code;
149
- anyChanged = result.changed || anyChanged;
150
- }
151
- }
152
-
153
- return { code: current, wasPatched: anyChanged };
154
- }
155
- },
156
-
157
- dropdown: {
158
- matcher: (id) => matchesModule(id, 'dropdown'),
159
- apply: (code) => {
160
- // ngx-bootstrap 20 + Bootstrap 5: host `.show` toggles dropdown visibility. Removing it breaks
161
- // datetime timepicker (dropdown menu) and similar `[dropdown]` hosts — restore if stripped.
162
- if (
163
- code.includes(
164
- 'properties: { "class.dropup": "dropup", "class.open": "isOpen", "class.show": "isOpen" }'
165
- )
166
- ) {
167
- return { code, wasPatched: false };
168
- }
169
- const result = applyReplacement(
170
- code,
171
- /properties: \{ "class\.dropup": "dropup", "class\.open": "isOpen" \}/,
172
- 'properties: { "class.dropup": "dropup", "class.open": "isOpen", "class.show": "isOpen" }',
173
- 'Patched Dropdown: Restore BS5 show class on directive host'
174
- );
175
- return { code: result.code, wasPatched: result.changed };
176
- }
177
- },
178
-
179
- modal: {
180
- matcher: (id) => matchesModule(id, 'modal'),
181
- apply: (code) => {
182
- if (!code.includes("SHOW: 'show'")) {
183
- return { code, wasPatched: false };
184
- }
185
- const result = applyReplacement(
186
- code,
187
- /SHOW: 'show'/g,
188
- "SHOW: 'in'",
189
- 'Patched Modal: SHOW class to in'
190
- );
191
- return { code: result.code, wasPatched: result.changed };
192
- }
193
- },
194
-
195
- typeahead: {
196
- matcher: (id) => matchesModule(id, 'typeahead'),
197
- apply: (code) => {
198
- let current = code;
199
- let anyChanged = false;
200
-
201
- if (current.includes(':host.dropdown-menu,.dropdown-menu{overflow-y:auto;height:100px}')) {
202
- const result = applyReplacement(
203
- current,
204
- /:host\.dropdown-menu,\.dropdown-menu\{overflow-y:auto;height:100px\}/g,
205
- '',
206
- 'Patched Typeahead: Remove overflow-y and height styles'
207
- );
208
- current = result.code;
209
- anyChanged = result.changed || anyChanged;
210
- }
211
-
212
- return { code: current, wasPatched: anyChanged };
213
- }
214
- }
215
- };
216
-
217
- // ============================================
218
- // Rollup Plugin
219
- // ============================================
220
-
221
- export function ngxBootstrapPatchPlugin() {
222
- return {
223
- name: 'ngx-bootstrap-patch',
224
- transform(code, id) {
225
- for (const patch of Object.values(PATCHES)) {
226
- if (patch.matcher(id)) {
227
- const result = patch.apply(code);
228
- if (result.wasPatched || result.code !== code) {
229
- return { code: result.code, map: null };
230
- }
231
- }
232
- }
233
- return null;
234
- }
235
- };
236
- }
237
- /**
238
- * Files to patch in node_modules/ngx-bootstrap (fesm2022 only for Angular 17+)
239
- */
240
- const FILES_TO_PATCH = [
241
- { path: 'positioning/fesm2022/ngx-bootstrap-positioning.mjs', patchKey: 'positioning' },
242
- { path: 'component-loader/fesm2022/ngx-bootstrap-component-loader.mjs', patchKey: 'componentLoader' },
243
- { path: 'dropdown/fesm2022/ngx-bootstrap-dropdown.mjs', patchKey: 'dropdown' },
244
- { path: 'modal/fesm2022/ngx-bootstrap-modal.mjs', patchKey: 'modal' },
245
- { path: 'typeahead/fesm2022/ngx-bootstrap-typeahead.mjs', patchKey: 'typeahead' }
246
- ];
247
-
248
- /**
249
- * Patch ngx-bootstrap ESM files directly in node_modules.
250
- * Call this from build.js before Angular build.
251
- */
252
- export function patchNgxBootstrapFiles(nodeModulesPath = 'node_modules') {
253
- console.log('\n🔧 Patching ngx-bootstrap ESM files...\n');
254
-
255
- const ngxPath = path.join(nodeModulesPath, 'ngx-bootstrap');
256
- let totalPatched = 0;
257
-
258
- for (const { path: filePath, patchKey } of FILES_TO_PATCH) {
259
- const fullPath = path.join(ngxPath, filePath);
260
-
261
- if (!fs.existsSync(fullPath)) continue;
262
-
263
- const code = fs.readFileSync(fullPath, 'utf-8');
264
- const patch = PATCHES[patchKey];
265
-
266
- if (patch) {
267
- const result = patch.apply(code);
268
- if (result.wasPatched) {
269
- fs.writeFileSync(fullPath, result.code, 'utf-8');
270
- totalPatched++;
271
- }
272
- }
273
- }
274
-
275
- console.log(
276
- totalPatched > 0
277
- ? `\n✅ Patched ${totalPatched} ngx-bootstrap file(s)\n`
278
- : '\n✓ ngx-bootstrap files already patched or no patches needed\n'
279
- );
280
-
281
- return totalPatched;
282
- }
283
-
284
- // CLI entry point
285
- if (process.argv[1]?.includes('ngx-bootstrap-patch')) {
286
- patchNgxBootstrapFiles();
287
- }
@@ -1,13 +0,0 @@
1
- // Default WMAppProperties - will be overridden by application-specific properties
2
- export const WMAppProperties = {
3
- name: 'wavemaker-ng-runtime',
4
- type: 'APPLICATION',
5
- platformType: 'WEB',
6
- supportedLanguages: {
7
- 'en': { moment: 'en' }
8
- },
9
- languageBundleSources: 'STATIC',
10
- preferredLanguage: 'en',
11
- fontConfig: {}
12
- };
13
-
package/src/typings.d.ts DELETED
@@ -1,27 +0,0 @@
1
- // Global type declarations for jQuery extensions
2
- // Using declaration merging to extend existing jQuery types
3
-
4
- declare global {
5
- interface JQueryStatic {
6
- ui?: {
7
- widget?: any;
8
- [key: string]: any;
9
- };
10
- }
11
-
12
- interface JQuery {
13
- DataTable?(options?: any): any;
14
- destroy?(): void;
15
- datatable?(method: string, ...args: any[]): any;
16
- datatable?(options?: any): any;
17
- }
18
-
19
- // Extend jQuery.fn namespace for DataTable plugin
20
- namespace JQueryStatic {
21
- interface fn {
22
- DataTable?: any;
23
- }
24
- }
25
- }
26
-
27
- export {};